Skip to content

Commit 05cc0a3

Browse files
committed
update packages
1 parent fa1b21f commit 05cc0a3

File tree

5 files changed

+235
-132
lines changed

5 files changed

+235
-132
lines changed

Assets/Resources/react/rpg/index.js

Lines changed: 73 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ ___CSS_LOADER_EXPORT___.locals = {
6161
"use strict";
6262

6363

64-
var stylesInDom = [];
64+
var stylesInDOM = [];
6565

6666
function getIndexByIdentifier(identifier) {
6767
var result = -1;
6868

69-
for (var i = 0; i < stylesInDom.length; i++) {
70-
if (stylesInDom[i].identifier === identifier) {
69+
for (var i = 0; i < stylesInDOM.length; i++) {
70+
if (stylesInDOM[i].identifier === identifier) {
7171
result = i;
7272
break;
7373
}
@@ -86,20 +86,24 @@ function modulesToDom(list, options) {
8686
var count = idCountMap[id] || 0;
8787
var identifier = "".concat(id, " ").concat(count);
8888
idCountMap[id] = count + 1;
89-
var index = getIndexByIdentifier(identifier);
89+
var indexByIdentifier = getIndexByIdentifier(identifier);
9090
var obj = {
9191
css: item[1],
9292
media: item[2],
93-
sourceMap: item[3]
93+
sourceMap: item[3],
94+
supports: item[4],
95+
layer: item[5]
9496
};
9597

96-
if (index !== -1) {
97-
stylesInDom[index].references++;
98-
stylesInDom[index].updater(obj);
98+
if (indexByIdentifier !== -1) {
99+
stylesInDOM[indexByIdentifier].references++;
100+
stylesInDOM[indexByIdentifier].updater(obj);
99101
} else {
100-
stylesInDom.push({
102+
var updater = addElementStyle(obj, options);
103+
options.byIndex = i;
104+
stylesInDOM.splice(i, 0, {
101105
identifier: identifier,
102-
updater: addStyle(obj, options),
106+
updater: updater,
103107
references: 1
104108
});
105109
}
@@ -110,12 +114,13 @@ function modulesToDom(list, options) {
110114
return identifiers;
111115
}
112116

113-
function addStyle(obj, options) {
117+
function addElementStyle(obj, options) {
114118
var api = options.domAPI(options);
115119
api.update(obj);
116-
return function updateStyle(newObj) {
120+
121+
var updater = function updater(newObj) {
117122
if (newObj) {
118-
if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap) {
123+
if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
119124
return;
120125
}
121126

@@ -124,6 +129,8 @@ function addStyle(obj, options) {
124129
api.remove();
125130
}
126131
};
132+
133+
return updater;
127134
}
128135

129136
module.exports = function (list, options) {
@@ -136,7 +143,7 @@ module.exports = function (list, options) {
136143
for (var i = 0; i < lastIdentifiers.length; i++) {
137144
var identifier = lastIdentifiers[i];
138145
var index = getIndexByIdentifier(identifier);
139-
stylesInDom[index].references--;
146+
stylesInDOM[index].references--;
140147
}
141148

142149
var newLastIdentifiers = modulesToDom(newList, options);
@@ -146,10 +153,10 @@ module.exports = function (list, options) {
146153

147154
var _index = getIndexByIdentifier(_identifier);
148155

149-
if (stylesInDom[_index].references === 0) {
150-
stylesInDom[_index].updater();
156+
if (stylesInDOM[_index].references === 0) {
157+
stylesInDOM[_index].updater();
151158

152-
stylesInDom.splice(_index, 1);
159+
stylesInDOM.splice(_index, 1);
153160
}
154161
}
155162

@@ -213,10 +220,10 @@ module.exports = insertBySelector;
213220

214221
/* istanbul ignore next */
215222
function insertStyleElement(options) {
216-
var style = document.createElement("style");
217-
options.setAttributes(style, options.attributes);
218-
options.insert(style);
219-
return style;
223+
var element = document.createElement("style");
224+
options.setAttributes(element, options.attributes);
225+
options.insert(element, options.options);
226+
return element;
220227
}
221228

222229
module.exports = insertStyleElement;
@@ -230,11 +237,11 @@ module.exports = insertStyleElement;
230237

231238

232239
/* istanbul ignore next */
233-
function setAttributesWithoutAttributes(style) {
240+
function setAttributesWithoutAttributes(styleElement) {
234241
var nonce = true ? __webpack_require__.nc : 0;
235242

236243
if (nonce) {
237-
style.setAttribute("nonce", nonce);
244+
styleElement.setAttribute("nonce", nonce);
238245
}
239246
}
240247

@@ -249,46 +256,68 @@ module.exports = setAttributesWithoutAttributes;
249256

250257

251258
/* istanbul ignore next */
252-
function apply(style, options, obj) {
253-
var css = obj.css;
254-
var media = obj.media;
255-
var sourceMap = obj.sourceMap;
259+
function apply(styleElement, options, obj) {
260+
var css = "";
256261

257-
if (media) {
258-
style.setAttribute("media", media);
259-
} else {
260-
style.removeAttribute("media");
262+
if (obj.supports) {
263+
css += "@supports (".concat(obj.supports, ") {");
264+
}
265+
266+
if (obj.media) {
267+
css += "@media ".concat(obj.media, " {");
268+
}
269+
270+
var needLayer = typeof obj.layer !== "undefined";
271+
272+
if (needLayer) {
273+
css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
261274
}
262275

276+
css += obj.css;
277+
278+
if (needLayer) {
279+
css += "}";
280+
}
281+
282+
if (obj.media) {
283+
css += "}";
284+
}
285+
286+
if (obj.supports) {
287+
css += "}";
288+
}
289+
290+
var sourceMap = obj.sourceMap;
291+
263292
if (sourceMap && typeof btoa !== "undefined") {
264293
css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
265294
} // For old IE
266295

267296
/* istanbul ignore if */
268297

269298

270-
options.styleTagTransform(css, style);
299+
options.styleTagTransform(css, styleElement, options.options);
271300
}
272301

273-
function removeStyleElement(style) {
302+
function removeStyleElement(styleElement) {
274303
// istanbul ignore if
275-
if (style.parentNode === null) {
304+
if (styleElement.parentNode === null) {
276305
return false;
277306
}
278307

279-
style.parentNode.removeChild(style);
308+
styleElement.parentNode.removeChild(styleElement);
280309
}
281310
/* istanbul ignore next */
282311

283312

284313
function domAPI(options) {
285-
var style = options.insertStyleElement(options);
314+
var styleElement = options.insertStyleElement(options);
286315
return {
287316
update: function update(obj) {
288-
apply(style, options, obj);
317+
apply(styleElement, options, obj);
289318
},
290319
remove: function remove() {
291-
removeStyleElement(style);
320+
removeStyleElement(styleElement);
292321
}
293322
};
294323
}
@@ -304,15 +333,15 @@ module.exports = domAPI;
304333

305334

306335
/* istanbul ignore next */
307-
function styleTagTransform(css, style) {
308-
if (style.styleSheet) {
309-
style.styleSheet.cssText = css;
336+
function styleTagTransform(css, styleElement) {
337+
if (styleElement.styleSheet) {
338+
styleElement.styleSheet.cssText = css;
310339
} else {
311-
while (style.firstChild) {
312-
style.removeChild(style.firstChild);
340+
while (styleElement.firstChild) {
341+
styleElement.removeChild(styleElement.firstChild);
313342
}
314343

315-
style.appendChild(document.createTextNode(css));
344+
styleElement.appendChild(document.createTextNode(css));
316345
}
317346
}
318347

react/rpg/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818
"redux-persist": "^6.0.0"
1919
},
2020
"devDependencies": {
21-
"@reactunity/scripts": "^0.6.0",
21+
"@reactunity/scripts": "^0.6.1",
2222
"@types/react": "^17.0.22",
2323
"@types/react-redux": "^7.1.18",
24-
"@types/webpack-env": "^1.16.2",
2524
"typescript": "^4.4.3"
2625
}
2726
}

react/rpg/src/react-unity.d.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

react/rpg/tsconfig.json

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,40 @@
1-
{
2-
"compileOnSave": false,
3-
"compilerOptions": {
4-
"baseUrl": "./",
5-
"outDir": "./dist",
6-
"sourceMap": false,
7-
"allowJs": true,
8-
"pretty": true,
9-
"declaration": false,
10-
"module": "esnext",
11-
"moduleResolution": "node",
12-
"preserveSymlinks": true,
13-
"importHelpers": false,
14-
"strict": true,
15-
"strictNullChecks": false,
16-
"noImplicitAny": false,
17-
"allowSyntheticDefaultImports": true,
18-
"jsx": "react-jsx",
19-
"target": "ES5",
20-
"skipLibCheck": true,
21-
"lib": [],
22-
"preserveConstEnums": true,
23-
"esModuleInterop": true,
24-
"forceConsistentCasingInFileNames": true,
25-
"noFallthroughCasesInSwitch": true,
26-
"resolveJsonModule": true,
27-
"isolatedModules": true,
28-
"noEmit": true
29-
},
30-
"files": [
31-
"src/index.tsx"
32-
],
33-
"include": [
34-
"src"
35-
]
36-
}
1+
{
2+
"compileOnSave": false,
3+
"compilerOptions": {
4+
"baseUrl": "./",
5+
"outDir": "./dist",
6+
"sourceMap": false,
7+
"allowJs": true,
8+
"pretty": true,
9+
"declaration": false,
10+
"module": "esnext",
11+
"moduleResolution": "node",
12+
"preserveSymlinks": true,
13+
"importHelpers": false,
14+
"strict": true,
15+
"strictNullChecks": false,
16+
"noImplicitAny": false,
17+
"allowSyntheticDefaultImports": true,
18+
"jsx": "react-jsx",
19+
"target": "ES5",
20+
"skipLibCheck": true,
21+
"lib": [],
22+
"preserveConstEnums": true,
23+
"esModuleInterop": true,
24+
"forceConsistentCasingInFileNames": true,
25+
"noFallthroughCasesInSwitch": true,
26+
"resolveJsonModule": true,
27+
"isolatedModules": true,
28+
"noEmit": true,
29+
"types": [
30+
"@reactunity/scripts/main",
31+
"@reactunity/scripts/ugui"
32+
]
33+
},
34+
"files": [
35+
"src/index.tsx"
36+
],
37+
"include": [
38+
"src"
39+
]
40+
}

0 commit comments

Comments
 (0)