@lynx-js/web-core-server 0.15.7 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/index.js +513 -482
- package/dist/legacy-wasm-chunk.js +61 -47
- package/dist/static/wasm/8dc0062c.module.wasm +0 -0
- package/dist/static/wasm/fe95f285.module.wasm +0 -0
- package/package.json +6 -6
- package/dist/static/wasm/43143691.module.wasm +0 -0
- package/dist/static/wasm/57807697.module.wasm +0 -0
package/dist/index.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import node_os from "node:os";
|
|
2
2
|
import promises from "node:fs/promises";
|
|
3
3
|
import node_path from "node:path";
|
|
4
|
+
import node_vm from "node:vm";
|
|
5
|
+
import node_fs from "node:fs";
|
|
4
6
|
var __webpack_modules__ = {
|
|
5
|
-
"../web-style-transformer/dist/standard.js": function(
|
|
6
|
-
__webpack_require__.a(
|
|
7
|
+
"../web-style-transformer/dist/standard.js": function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
8
|
+
__webpack_require__.a(__webpack_module__, async function(__webpack_handle_async_dependencies__, __webpack_async_result__) {
|
|
7
9
|
try {
|
|
8
10
|
__webpack_require__.d(__webpack_exports__, {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
Fz: ()=>_standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.Fz,
|
|
12
|
+
Qn: ()=>_standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.Qn,
|
|
13
|
+
aC: ()=>_standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.aC,
|
|
14
|
+
bL: ()=>_standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.bL,
|
|
15
|
+
iG: ()=>_standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.iG,
|
|
16
|
+
lI: ()=>_standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.lI,
|
|
17
|
+
qB: ()=>_standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.qB,
|
|
18
|
+
yc: ()=>_standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.yc
|
|
17
19
|
});
|
|
18
20
|
var _standard_bg_wasm__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../web-style-transformer/dist/standard_bg.wasm");
|
|
19
21
|
var _standard_bg_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../web-style-transformer/dist/standard_bg.js");
|
|
@@ -21,7 +23,7 @@ var __webpack_modules__ = {
|
|
|
21
23
|
_standard_bg_wasm__WEBPACK_IMPORTED_MODULE_1__
|
|
22
24
|
]);
|
|
23
25
|
_standard_bg_wasm__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
|
|
24
|
-
(0, _standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.
|
|
26
|
+
(0, _standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.lI)(_standard_bg_wasm__WEBPACK_IMPORTED_MODULE_1__);
|
|
25
27
|
_standard_bg_wasm__WEBPACK_IMPORTED_MODULE_1__.__wbindgen_start();
|
|
26
28
|
__webpack_async_result__();
|
|
27
29
|
} catch (e) {
|
|
@@ -29,40 +31,53 @@ var __webpack_modules__ = {
|
|
|
29
31
|
}
|
|
30
32
|
});
|
|
31
33
|
},
|
|
32
|
-
"../web-style-transformer/dist/standard_bg.js": function(
|
|
34
|
+
"../web-style-transformer/dist/standard_bg.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
33
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
Fz: ()=>__wbg_new_58353953ad2097cc,
|
|
37
|
+
Qn: ()=>__wbindgen_throw,
|
|
38
|
+
aC: ()=>transform_raw_u16_inline_style_ptr,
|
|
39
|
+
bL: ()=>__wbindgen_init_externref_table,
|
|
40
|
+
iG: ()=>transform_raw_u16_inline_style_ptr_parsed,
|
|
41
|
+
lI: ()=>__wbg_set_wasm,
|
|
42
|
+
qB: ()=>__wbg_push_73fd7b5550ebf707,
|
|
43
|
+
yc: ()=>__wbindgen_string_new
|
|
42
44
|
});
|
|
43
|
-
module = __webpack_require__.hmd(module);
|
|
44
45
|
let wasm;
|
|
45
46
|
function __wbg_set_wasm(val) {
|
|
46
47
|
wasm = val;
|
|
47
48
|
}
|
|
49
|
+
let cachedUint8ArrayMemory0 = null;
|
|
50
|
+
function getUint8ArrayMemory0() {
|
|
51
|
+
if (null === cachedUint8ArrayMemory0 || 0 === cachedUint8ArrayMemory0.byteLength) cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
52
|
+
return cachedUint8ArrayMemory0;
|
|
53
|
+
}
|
|
48
54
|
const lTextDecoder = 'undefined' == typeof TextDecoder ? (0, module.require)('util').TextDecoder : TextDecoder;
|
|
49
55
|
let cachedTextDecoder = new lTextDecoder('utf-8', {
|
|
50
56
|
ignoreBOM: true,
|
|
51
57
|
fatal: true
|
|
52
58
|
});
|
|
53
59
|
cachedTextDecoder.decode();
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
61
|
+
let numBytesDecoded = 0;
|
|
62
|
+
function decodeText(ptr, len) {
|
|
63
|
+
numBytesDecoded += len;
|
|
64
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
65
|
+
cachedTextDecoder = new lTextDecoder('utf-8', {
|
|
66
|
+
ignoreBOM: true,
|
|
67
|
+
fatal: true
|
|
68
|
+
});
|
|
69
|
+
cachedTextDecoder.decode();
|
|
70
|
+
numBytesDecoded = len;
|
|
71
|
+
}
|
|
72
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
58
73
|
}
|
|
59
74
|
function getStringFromWasm0(ptr, len) {
|
|
60
75
|
ptr >>>= 0;
|
|
61
|
-
return
|
|
76
|
+
return decodeText(ptr, len);
|
|
62
77
|
}
|
|
63
78
|
let WASM_VECTOR_LEN = 0;
|
|
64
79
|
const lTextEncoder = 'undefined' == typeof TextEncoder ? (0, module.require)('util').TextEncoder : TextEncoder;
|
|
65
|
-
|
|
80
|
+
const cachedTextEncoder = new lTextEncoder('utf-8');
|
|
66
81
|
const encodeString = 'function' == typeof cachedTextEncoder.encodeInto ? function(arg, view) {
|
|
67
82
|
return cachedTextEncoder.encodeInto(arg, view);
|
|
68
83
|
} : function(arg, view) {
|
|
@@ -120,11 +135,11 @@ var __webpack_modules__ = {
|
|
|
120
135
|
const ret = wasm.transform_raw_u16_inline_style_ptr_parsed(ptr0, len0, ptr1, len1);
|
|
121
136
|
return ret;
|
|
122
137
|
}
|
|
123
|
-
function
|
|
138
|
+
function __wbg_new_58353953ad2097cc() {
|
|
124
139
|
const ret = new Array();
|
|
125
140
|
return ret;
|
|
126
141
|
}
|
|
127
|
-
function
|
|
142
|
+
function __wbg_push_73fd7b5550ebf707(arg0, arg1) {
|
|
128
143
|
const ret = arg0.push(arg1);
|
|
129
144
|
return ret;
|
|
130
145
|
}
|
|
@@ -145,19 +160,19 @@ var __webpack_modules__ = {
|
|
|
145
160
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
146
161
|
}
|
|
147
162
|
},
|
|
148
|
-
"../web-style-transformer/standard.js": function(
|
|
149
|
-
__webpack_require__.a(
|
|
163
|
+
"../web-style-transformer/standard.js": function(__webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
164
|
+
__webpack_require__.a(__webpack_module__, async function(__webpack_handle_async_dependencies__, __webpack_async_result__) {
|
|
150
165
|
try {
|
|
151
166
|
__webpack_require__.r(__webpack_exports__);
|
|
152
167
|
__webpack_require__.d(__webpack_exports__, {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
__wbg_set_wasm: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.
|
|
156
|
-
__wbindgen_init_externref_table: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.
|
|
157
|
-
__wbindgen_string_new: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.
|
|
158
|
-
__wbindgen_throw: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.
|
|
159
|
-
transform_raw_u16_inline_style_ptr: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.
|
|
160
|
-
transform_raw_u16_inline_style_ptr_parsed: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.
|
|
168
|
+
__wbg_new_58353953ad2097cc: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.Fz,
|
|
169
|
+
__wbg_push_73fd7b5550ebf707: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.qB,
|
|
170
|
+
__wbg_set_wasm: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.lI,
|
|
171
|
+
__wbindgen_init_externref_table: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.bL,
|
|
172
|
+
__wbindgen_string_new: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.yc,
|
|
173
|
+
__wbindgen_throw: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.Qn,
|
|
174
|
+
transform_raw_u16_inline_style_ptr: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.aC,
|
|
175
|
+
transform_raw_u16_inline_style_ptr_parsed: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.iG
|
|
161
176
|
});
|
|
162
177
|
var _dist_standard_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../web-style-transformer/dist/standard.js");
|
|
163
178
|
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([
|
|
@@ -170,15 +185,15 @@ var __webpack_modules__ = {
|
|
|
170
185
|
}
|
|
171
186
|
});
|
|
172
187
|
},
|
|
173
|
-
"../web-style-transformer/dist/standard_bg.wasm": function(
|
|
188
|
+
"../web-style-transformer/dist/standard_bg.wasm": function(module1, exports, __webpack_require__) {
|
|
174
189
|
var WEBPACK_IMPORTED_MODULE_0 = __webpack_require__("../web-style-transformer/dist/standard_bg.js");
|
|
175
|
-
|
|
190
|
+
module1.exports = __webpack_require__.v(exports, module1.id, "8dc0062c26e8c5a1", {
|
|
176
191
|
"./standard_bg.js": {
|
|
177
|
-
|
|
178
|
-
__wbindgen_string_new: WEBPACK_IMPORTED_MODULE_0.
|
|
179
|
-
|
|
180
|
-
__wbindgen_throw: WEBPACK_IMPORTED_MODULE_0.
|
|
181
|
-
__wbindgen_init_externref_table: WEBPACK_IMPORTED_MODULE_0.
|
|
192
|
+
__wbg_new_58353953ad2097cc: WEBPACK_IMPORTED_MODULE_0.Fz,
|
|
193
|
+
__wbindgen_string_new: WEBPACK_IMPORTED_MODULE_0.yc,
|
|
194
|
+
__wbg_push_73fd7b5550ebf707: WEBPACK_IMPORTED_MODULE_0.qB,
|
|
195
|
+
__wbindgen_throw: WEBPACK_IMPORTED_MODULE_0.Qn,
|
|
196
|
+
__wbindgen_init_externref_table: WEBPACK_IMPORTED_MODULE_0.bL
|
|
182
197
|
}
|
|
183
198
|
});
|
|
184
199
|
}
|
|
@@ -187,14 +202,12 @@ var __webpack_module_cache__ = {};
|
|
|
187
202
|
function __webpack_require__(moduleId) {
|
|
188
203
|
var cachedModule = __webpack_module_cache__[moduleId];
|
|
189
204
|
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
190
|
-
var
|
|
205
|
+
var module1 = __webpack_module_cache__[moduleId] = {
|
|
191
206
|
id: moduleId,
|
|
192
|
-
loaded: false,
|
|
193
207
|
exports: {}
|
|
194
208
|
};
|
|
195
|
-
__webpack_modules__[moduleId](
|
|
196
|
-
|
|
197
|
-
return module.exports;
|
|
209
|
+
__webpack_modules__[moduleId](module1, module1.exports, __webpack_require__);
|
|
210
|
+
return module1.exports;
|
|
198
211
|
}
|
|
199
212
|
__webpack_require__.m = __webpack_modules__;
|
|
200
213
|
(()=>{
|
|
@@ -231,11 +244,11 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
231
244
|
ret[webpackExports] = dep;
|
|
232
245
|
return ret;
|
|
233
246
|
});
|
|
234
|
-
__webpack_require__.a = (
|
|
247
|
+
__webpack_require__.a = (module1, body, hasAwait)=>{
|
|
235
248
|
var queue;
|
|
236
249
|
hasAwait && ((queue = []).d = -1);
|
|
237
250
|
var depQueues = new Set();
|
|
238
|
-
var exports =
|
|
251
|
+
var exports = module1.exports;
|
|
239
252
|
var currentDeps;
|
|
240
253
|
var outerResolve;
|
|
241
254
|
var reject;
|
|
@@ -247,7 +260,7 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
247
260
|
promise[webpackQueues] = (fn)=>{
|
|
248
261
|
queue && fn(queue), depQueues.forEach(fn), promise["catch"](function() {});
|
|
249
262
|
};
|
|
250
|
-
|
|
263
|
+
module1.exports = promise;
|
|
251
264
|
body((deps)=>{
|
|
252
265
|
currentDeps = wrapDeps(deps);
|
|
253
266
|
var fn;
|
|
@@ -281,19 +294,6 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
281
294
|
return promises;
|
|
282
295
|
}, []));
|
|
283
296
|
})();
|
|
284
|
-
(()=>{
|
|
285
|
-
__webpack_require__.hmd = (module)=>{
|
|
286
|
-
module = Object.create(module);
|
|
287
|
-
if (!module.children) module.children = [];
|
|
288
|
-
Object.defineProperty(module, 'exports', {
|
|
289
|
-
enumerable: true,
|
|
290
|
-
set: ()=>{
|
|
291
|
-
throw new Error('ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: ' + module.id);
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
return module;
|
|
295
|
-
};
|
|
296
|
-
})();
|
|
297
297
|
(()=>{
|
|
298
298
|
__webpack_require__.u = (chunkId)=>"legacy-wasm-chunk.js";
|
|
299
299
|
})();
|
|
@@ -352,7 +352,7 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
352
352
|
})();
|
|
353
353
|
(()=>{
|
|
354
354
|
var installedChunks = {
|
|
355
|
-
|
|
355
|
+
410: 0
|
|
356
356
|
};
|
|
357
357
|
var installChunk = (data)=>{
|
|
358
358
|
var __webpack_ids__ = data.__webpack_ids__;
|
|
@@ -387,24 +387,16 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
387
387
|
}
|
|
388
388
|
};
|
|
389
389
|
})();
|
|
390
|
-
const lynxUniqueIdAttribute = 'l-uid';
|
|
391
390
|
const cssIdAttribute = 'l-css-id';
|
|
392
391
|
const componentIdAttribute = 'l-comp-id';
|
|
393
392
|
const parentComponentUniqueIdAttribute = 'l-p-comp-uid';
|
|
393
|
+
const lynxEntryNameAttribute = 'l-e-name';
|
|
394
394
|
const lynxTagAttribute = 'lynx-tag';
|
|
395
|
-
const lynxDatasetAttribute = 'l-dset';
|
|
396
395
|
const lynxComponentConfigAttribute = 'l-comp-cfg';
|
|
397
396
|
const lynxDisposedAttribute = 'l-disposed';
|
|
398
397
|
const lynxElementTemplateMarkerAttribute = 'l-template';
|
|
399
|
-
const lynxPartIdAttribute = 'l-part';
|
|
400
398
|
const lynxDefaultDisplayLinearAttribute = 'lynx-default-display-linear';
|
|
401
399
|
const __lynx_timing_flag = '__lynx_timing_flag';
|
|
402
|
-
const globalMuteableVars = [
|
|
403
|
-
'registerDataProcessor',
|
|
404
|
-
'registerWorkletInternal',
|
|
405
|
-
'lynxWorkletImpl',
|
|
406
|
-
'runWorklet'
|
|
407
|
-
];
|
|
408
400
|
const systemInfo = {
|
|
409
401
|
platform: 'web',
|
|
410
402
|
lynxSdkVersion: '3.0'
|
|
@@ -418,10 +410,6 @@ const inShadowRootStyles = [
|
|
|
418
410
|
overflow: visible;
|
|
419
411
|
}`
|
|
420
412
|
];
|
|
421
|
-
const constants_globalDisallowedVars = [
|
|
422
|
-
'navigator',
|
|
423
|
-
'postMessage'
|
|
424
|
-
];
|
|
425
413
|
const W3cEventNameToLynx = {
|
|
426
414
|
click: 'tap',
|
|
427
415
|
lynxscroll: 'scroll',
|
|
@@ -473,12 +461,12 @@ class Rpc {
|
|
|
473
461
|
};
|
|
474
462
|
}
|
|
475
463
|
#onMessage = async (message)=>{
|
|
476
|
-
const
|
|
477
|
-
if (
|
|
464
|
+
const handler = this.#handlerMap.get(message.name);
|
|
465
|
+
if (handler) {
|
|
478
466
|
const lockViewer = message.sync ? new Int32Array(message.lock) : void 0;
|
|
479
467
|
const replyTempEndpoint = !message.sync && message.retId ? Rpc.createRetEndpoint(message.retId) : void 0;
|
|
480
468
|
try {
|
|
481
|
-
const result = await
|
|
469
|
+
const result = await handler(...message.data);
|
|
482
470
|
let retData, transfer = [];
|
|
483
471
|
if (message.sync) retData = result;
|
|
484
472
|
else if (message.hasTransfer) ({ data: retData, transfer } = result || {});
|
|
@@ -521,8 +509,8 @@ class Rpc {
|
|
|
521
509
|
createCall(endpoint) {
|
|
522
510
|
return (...args)=>this.invoke(endpoint, args);
|
|
523
511
|
}
|
|
524
|
-
registerHandler(endpoint,
|
|
525
|
-
this.#handlerMap.set(endpoint.name,
|
|
512
|
+
registerHandler(endpoint, handler) {
|
|
513
|
+
this.#handlerMap.set(endpoint.name, handler);
|
|
526
514
|
const currentCache = this.#messageCache[endpoint.name];
|
|
527
515
|
if (currentCache?.length) {
|
|
528
516
|
this.#messageCache[endpoint.name] = void 0;
|
|
@@ -660,6 +648,9 @@ createRpcEndpoint('updateGlobalProps', false, false);
|
|
|
660
648
|
createRpcEndpoint('updateI18nResources', false, false);
|
|
661
649
|
createRpcEndpoint('updateI18nResource', false, false);
|
|
662
650
|
const dispatchI18nResourceEndpoint = createRpcEndpoint('dispatchI18nResource', false, false);
|
|
651
|
+
const queryComponentEndpoint = createRpcEndpoint('queryComponent', false, true);
|
|
652
|
+
const updateBTSTemplateCacheEndpoint = createRpcEndpoint('updateBTSTemplateCacheEndpoint', false, true);
|
|
653
|
+
createRpcEndpoint('loadTemplateMultiThread', false, true);
|
|
663
654
|
var NativeApp_IdentifierType;
|
|
664
655
|
(function(IdentifierType) {
|
|
665
656
|
IdentifierType[IdentifierType["ID_SELECTOR"] = 0] = "ID_SELECTOR";
|
|
@@ -741,115 +732,48 @@ class LynxCrossThreadContext extends EventTarget {
|
|
|
741
732
|
});
|
|
742
733
|
}
|
|
743
734
|
}
|
|
744
|
-
const
|
|
745
|
-
|
|
746
|
-
'
|
|
747
|
-
'
|
|
748
|
-
'_SetSourceMapRelease',
|
|
749
|
-
'__AddConfig',
|
|
750
|
-
'__AddDataset',
|
|
751
|
-
'__GetAttributes',
|
|
752
|
-
'__GetComponentID',
|
|
753
|
-
'__GetDataByKey',
|
|
754
|
-
'__GetDataset',
|
|
755
|
-
'__GetElementConfig',
|
|
756
|
-
'__GetElementUniqueID',
|
|
757
|
-
'__GetID',
|
|
758
|
-
'__GetTag',
|
|
759
|
-
'__SetAttribute',
|
|
760
|
-
'__SetConfig',
|
|
761
|
-
'__SetDataset',
|
|
762
|
-
'__SetID',
|
|
763
|
-
'__UpdateComponentID',
|
|
764
|
-
'__UpdateComponentInfo',
|
|
765
|
-
'__GetConfig',
|
|
766
|
-
'__GetAttributeByName',
|
|
767
|
-
'__UpdateListCallbacks',
|
|
768
|
-
'__AppendElement',
|
|
769
|
-
'__ElementIsEqual',
|
|
770
|
-
'__FirstElement',
|
|
771
|
-
'__GetChildren',
|
|
772
|
-
'__GetParent',
|
|
773
|
-
'__InsertElementBefore',
|
|
774
|
-
'__LastElement',
|
|
775
|
-
'__NextElement',
|
|
776
|
-
'__RemoveElement',
|
|
777
|
-
'__ReplaceElement',
|
|
778
|
-
'__ReplaceElements',
|
|
779
|
-
'__SwapElement',
|
|
780
|
-
'__CreateComponent',
|
|
781
|
-
'__CreateElement',
|
|
782
|
-
'__CreatePage',
|
|
783
|
-
'__CreateView',
|
|
784
|
-
'__CreateText',
|
|
785
|
-
'__CreateRawText',
|
|
786
|
-
'__CreateImage',
|
|
787
|
-
'__CreateScrollView',
|
|
788
|
-
'__CreateWrapperElement',
|
|
789
|
-
'__CreateList',
|
|
790
|
-
'__AddEvent',
|
|
791
|
-
'__GetEvent',
|
|
792
|
-
'__GetEvents',
|
|
793
|
-
'__SetEvents',
|
|
794
|
-
'__AddClass',
|
|
795
|
-
'__SetClasses',
|
|
796
|
-
'__GetClasses',
|
|
797
|
-
'__AddInlineStyle',
|
|
798
|
-
'__SetInlineStyles',
|
|
799
|
-
'__SetCSSId',
|
|
800
|
-
'__OnLifecycleEvent',
|
|
801
|
-
'__FlushElementTree',
|
|
802
|
-
'__LoadLepusChunk',
|
|
803
|
-
'SystemInfo',
|
|
804
|
-
'_I18nResourceTranslation',
|
|
805
|
-
'_AddEventListener',
|
|
806
|
-
'__GetTemplateParts',
|
|
807
|
-
'__MarkPartElement',
|
|
808
|
-
'__MarkTemplateElement',
|
|
809
|
-
'__GetPageElement',
|
|
810
|
-
'__ElementFromBinary'
|
|
811
|
-
];
|
|
812
|
-
const backgroundInjectVars = [
|
|
813
|
-
'NativeModules',
|
|
814
|
-
'globalThis',
|
|
815
|
-
'lynx',
|
|
816
|
-
'lynxCoreInject',
|
|
817
|
-
'SystemInfo'
|
|
735
|
+
const currentSupportedTemplateVersion = 2;
|
|
736
|
+
const globalDisallowedVars = [
|
|
737
|
+
'navigator',
|
|
738
|
+
'postMessage'
|
|
818
739
|
];
|
|
819
|
-
const
|
|
820
|
-
|
|
821
|
-
|
|
740
|
+
const templateUpgraders = [
|
|
741
|
+
(template)=>{
|
|
742
|
+
const defaultInjectStr = "Card,setTimeout,setInterval,clearInterval,clearTimeout,NativeModules,Component,ReactLynx,nativeAppId,Behavior,LynxJSBI,lynx,window,document,frames,location,navigator,localStorage,history,Caches,screen,alert,confirm,prompt,fetch,XMLHttpRequest,__WebSocket__,webkit,Reporter,print,global,requestAnimationFrame,cancelAnimationFrame";
|
|
743
|
+
template.appType = template.lepusCode.root.startsWith('(function (globDynamicComponentEntry') ? 'lazy' : 'card';
|
|
744
|
+
template.manifest = Object.fromEntries(Object.entries(template.manifest).map(([key, value])=>[
|
|
745
|
+
key,
|
|
746
|
+
`module.exports={init: (lynxCoreInject) => { var {${defaultInjectStr}} = lynxCoreInject.tt; var module = {exports:{}}; var exports=module.exports; ${value}\n return module.exports; } }`
|
|
747
|
+
]));
|
|
748
|
+
template.version = 2;
|
|
749
|
+
return template;
|
|
750
|
+
}
|
|
822
751
|
];
|
|
823
|
-
const generateModuleContent = (content,
|
|
824
|
-
'//# allFunctionsCalledOnLoad
|
|
825
|
-
|
|
826
|
-
'
|
|
827
|
-
'
|
|
828
|
-
'
|
|
829
|
-
injectVars.join(','),
|
|
830
|
-
'} = lynx_runtime;',
|
|
831
|
-
...injectWithBind.map((nm)=>`const ${nm} = lynx_runtime.${nm}?.bind(lynx_runtime);`),
|
|
832
|
-
';var globDynamicComponentEntry = \'__Card__\';',
|
|
833
|
-
0 !== globalDisallowedVars.length ? `var ${globalDisallowedVars.join('=')}=undefined;` : '',
|
|
834
|
-
'var {__globalProps} = lynx;',
|
|
835
|
-
'lynx_runtime._updateVars=()=>{',
|
|
836
|
-
...muteableVars.map((nm)=>`${nm} = lynx_runtime.__lynxGlobalBindingValues.${nm};`),
|
|
837
|
-
'};\n',
|
|
752
|
+
const generateModuleContent = (content, eager, appType)=>[
|
|
753
|
+
eager ? '//# allFunctionsCalledOnLoad' : '',
|
|
754
|
+
'\n(function() { "use strict"; const ',
|
|
755
|
+
globalDisallowedVars.join('=void 0,'),
|
|
756
|
+
'=void 0;\n',
|
|
757
|
+
'lazy' === appType ? 'module.exports=\n' : '',
|
|
838
758
|
content,
|
|
839
|
-
'\n
|
|
759
|
+
'\n})()'
|
|
840
760
|
].join('');
|
|
841
|
-
async function generateJavascriptUrl(obj,
|
|
761
|
+
async function generateJavascriptUrl(obj, createJsModuleUrl, eager, appType, templateName) {
|
|
842
762
|
const processEntry = async ([name, content])=>[
|
|
843
763
|
name,
|
|
844
|
-
await createJsModuleUrl(generateModuleContent(content,
|
|
764
|
+
await createJsModuleUrl(generateModuleContent(content, eager, appType), `${templateName}-${name.replaceAll('/', '')}.js`)
|
|
845
765
|
];
|
|
846
766
|
return Promise.all(Object.entries(obj).filter(([_, content])=>'string' == typeof content).map(processEntry)).then(Object.fromEntries);
|
|
847
767
|
}
|
|
848
768
|
async function generateTemplate(template, createJsModuleUrl, templateName) {
|
|
769
|
+
template.version = template.version ?? 1;
|
|
770
|
+
if (template.version > currentSupportedTemplateVersion) throw new Error("Unsupported template, please upgrade your web-platform dependencies");
|
|
771
|
+
let upgrader;
|
|
772
|
+
while(template.version < currentSupportedTemplateVersion && (upgrader = templateUpgraders[template.version - 1]))template = upgrader(template);
|
|
849
773
|
return {
|
|
850
774
|
...template,
|
|
851
|
-
lepusCode: await generateJavascriptUrl(template.lepusCode,
|
|
852
|
-
manifest: await generateJavascriptUrl(template.manifest,
|
|
775
|
+
lepusCode: await generateJavascriptUrl(template.lepusCode, createJsModuleUrl, true, template.appType, templateName),
|
|
776
|
+
manifest: await generateJavascriptUrl(template.manifest, createJsModuleUrl, false, template.appType, templateName)
|
|
853
777
|
};
|
|
854
778
|
}
|
|
855
779
|
function registerCallLepusMethodHandler(rpc, runtime) {
|
|
@@ -861,163 +785,34 @@ function registerGetCustomSectionHandler(rpc, customSections) {
|
|
|
861
785
|
rpc.registerHandler(getCustomSectionsEndpoint, (key)=>customSections[key]?.content);
|
|
862
786
|
}
|
|
863
787
|
function createMainThreadLynx(config, SystemInfo) {
|
|
788
|
+
const requestAnimationFrameBrowserImpl = requestAnimationFrame;
|
|
789
|
+
const cancelAnimationFrameBrowserImpl = cancelAnimationFrame;
|
|
790
|
+
const setTimeoutBrowserImpl = setTimeout;
|
|
791
|
+
const clearTimeoutBrowserImpl = clearTimeout;
|
|
792
|
+
const setIntervalBrowserImpl = setInterval;
|
|
793
|
+
const clearIntervalBrowserImpl = clearInterval;
|
|
864
794
|
return {
|
|
865
795
|
getJSContext () {
|
|
866
796
|
return config.jsContext;
|
|
867
797
|
},
|
|
868
798
|
requestAnimationFrame (cb) {
|
|
869
|
-
return
|
|
799
|
+
return requestAnimationFrameBrowserImpl(cb);
|
|
870
800
|
},
|
|
871
|
-
cancelAnimationFrame (
|
|
872
|
-
return
|
|
801
|
+
cancelAnimationFrame (handler) {
|
|
802
|
+
return cancelAnimationFrameBrowserImpl(handler);
|
|
873
803
|
},
|
|
874
804
|
__globalProps: config.globalProps,
|
|
875
805
|
getCustomSectionSync (key) {
|
|
876
|
-
return config.customSections[key]?.content;
|
|
806
|
+
return config.lynxTemplate.customSections[key]?.content;
|
|
877
807
|
},
|
|
878
808
|
markPipelineTiming: config.callbacks.markTiming,
|
|
879
|
-
SystemInfo
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
97,
|
|
885
|
-
115,
|
|
886
|
-
109,
|
|
887
|
-
1,
|
|
888
|
-
0,
|
|
889
|
-
0,
|
|
890
|
-
0,
|
|
891
|
-
1,
|
|
892
|
-
4,
|
|
893
|
-
1,
|
|
894
|
-
96,
|
|
895
|
-
0,
|
|
896
|
-
0,
|
|
897
|
-
3,
|
|
898
|
-
2,
|
|
899
|
-
1,
|
|
900
|
-
0,
|
|
901
|
-
10,
|
|
902
|
-
7,
|
|
903
|
-
1,
|
|
904
|
-
5,
|
|
905
|
-
0,
|
|
906
|
-
208,
|
|
907
|
-
112,
|
|
908
|
-
26,
|
|
909
|
-
11
|
|
910
|
-
]));
|
|
911
|
-
let wasm;
|
|
912
|
-
async function initWasm() {
|
|
913
|
-
const supportsReferenceTypes = await referenceTypes();
|
|
914
|
-
wasm = supportsReferenceTypes ? await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../web-style-transformer/standard.js")) : await __webpack_require__.e("501").then(__webpack_require__.bind(__webpack_require__, "../web-style-transformer/legacy.js"));
|
|
915
|
-
}
|
|
916
|
-
function transformInlineStyleString(str) {
|
|
917
|
-
return wasm.transform_raw_u16_inline_style_ptr(str) ?? str;
|
|
918
|
-
}
|
|
919
|
-
function transformParsedStyles(styles) {
|
|
920
|
-
let childStyle = [];
|
|
921
|
-
let transformedStyle = [];
|
|
922
|
-
for (const [property, value] of styles){
|
|
923
|
-
const transformedResult = wasm.transform_raw_u16_inline_style_ptr_parsed(property, value);
|
|
924
|
-
if (transformedResult) {
|
|
925
|
-
const [transformedStyleForCurrent, childStyleForCurrent] = transformedResult;
|
|
926
|
-
transformedStyle = transformedStyle.concat(transformedStyleForCurrent);
|
|
927
|
-
if (childStyleForCurrent) childStyle = childStyle.concat(childStyleForCurrent);
|
|
928
|
-
} else transformedStyle.push([
|
|
929
|
-
property,
|
|
930
|
-
value
|
|
931
|
-
]);
|
|
932
|
-
}
|
|
933
|
-
return {
|
|
934
|
-
childStyle,
|
|
935
|
-
transformedStyle
|
|
809
|
+
SystemInfo,
|
|
810
|
+
setTimeout: setTimeoutBrowserImpl,
|
|
811
|
+
clearTimeout: clearTimeoutBrowserImpl,
|
|
812
|
+
setInterval: setIntervalBrowserImpl,
|
|
813
|
+
clearInterval: clearIntervalBrowserImpl
|
|
936
814
|
};
|
|
937
815
|
}
|
|
938
|
-
function flattenStyleInfo(styleInfo, enableCSSSelector) {
|
|
939
|
-
function flattenOneStyleInfo(cssId) {
|
|
940
|
-
const oneInfo = styleInfo[cssId];
|
|
941
|
-
const imports = oneInfo?.imports;
|
|
942
|
-
if (oneInfo && imports?.length) {
|
|
943
|
-
for (const im of imports){
|
|
944
|
-
const flatInfo = flattenOneStyleInfo(im);
|
|
945
|
-
if (flatInfo) {
|
|
946
|
-
oneInfo.content.push(...flatInfo.content);
|
|
947
|
-
oneInfo.rules.push(...enableCSSSelector ? flatInfo.rules : flatInfo.rules.map((i)=>({
|
|
948
|
-
...i
|
|
949
|
-
})));
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
oneInfo.imports = void 0;
|
|
953
|
-
}
|
|
954
|
-
return oneInfo;
|
|
955
|
-
}
|
|
956
|
-
Object.keys(styleInfo).map((cssId)=>{
|
|
957
|
-
flattenOneStyleInfo(cssId);
|
|
958
|
-
});
|
|
959
|
-
}
|
|
960
|
-
function transformToWebCss(styleInfo) {
|
|
961
|
-
for (const cssInfos of Object.values(styleInfo))for (const rule of cssInfos.rules){
|
|
962
|
-
const { sel: selectors, decl: declarations } = rule;
|
|
963
|
-
const { transformedStyle, childStyle } = transformParsedStyles(declarations);
|
|
964
|
-
rule.decl = transformedStyle;
|
|
965
|
-
if (childStyle.length > 0) cssInfos.rules.push({
|
|
966
|
-
sel: selectors.map((selector)=>selector.toSpliced(-2, 1, [
|
|
967
|
-
'>'
|
|
968
|
-
], [
|
|
969
|
-
'*'
|
|
970
|
-
], [], [], [])),
|
|
971
|
-
decl: childStyle
|
|
972
|
-
});
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
function genCssContent(styleInfo, pageConfig) {
|
|
976
|
-
function getExtraSelectors(cssId) {
|
|
977
|
-
let suffix = '';
|
|
978
|
-
if (pageConfig.enableRemoveCSSScope) suffix += `[${lynxTagAttribute}]`;
|
|
979
|
-
else if (void 0 !== cssId) suffix += `[${cssIdAttribute}="${cssId}"]`;
|
|
980
|
-
else suffix += `[${lynxTagAttribute}]`;
|
|
981
|
-
return suffix;
|
|
982
|
-
}
|
|
983
|
-
const finalCssContent = [];
|
|
984
|
-
for (const [cssId, cssInfos] of Object.entries(styleInfo)){
|
|
985
|
-
const suffix = getExtraSelectors(cssId);
|
|
986
|
-
const declarationContent = cssInfos.rules.map((rule)=>{
|
|
987
|
-
const { sel: selectorList, decl: declarations } = rule;
|
|
988
|
-
const selectorString = selectorList.map((selectors)=>selectors.toSpliced(-4, 0, [
|
|
989
|
-
suffix
|
|
990
|
-
]).flat().join('')).join(',');
|
|
991
|
-
const declarationString = declarations.map(([k, v])=>`${k}:${v};`).join('');
|
|
992
|
-
return `${selectorString}{${declarationString}}`;
|
|
993
|
-
}).join('');
|
|
994
|
-
finalCssContent.push(...cssInfos.content, declarationContent);
|
|
995
|
-
}
|
|
996
|
-
return finalCssContent.join('\n');
|
|
997
|
-
}
|
|
998
|
-
function genCssOGInfo(styleInfo) {
|
|
999
|
-
return Object.fromEntries(Object.entries(styleInfo).map(([cssId, cssInfos])=>{
|
|
1000
|
-
const oneCssOGInfo = {};
|
|
1001
|
-
cssInfos.rules = cssInfos.rules.filter((oneCssInfo)=>{
|
|
1002
|
-
oneCssInfo.sel = oneCssInfo.sel.filter((selectorList)=>{
|
|
1003
|
-
const [classSelectors, pseudoClassSelectors, pseudoElementSelectors, combinator] = selectorList;
|
|
1004
|
-
if (1 === classSelectors.length && '.' === classSelectors[0][0] && 0 === pseudoClassSelectors.length && 0 === pseudoElementSelectors.length && 0 === combinator.length) {
|
|
1005
|
-
const selectorName = classSelectors[0].substring(1);
|
|
1006
|
-
const currentDeclarations = oneCssOGInfo[selectorName];
|
|
1007
|
-
if (currentDeclarations) currentDeclarations.push(...oneCssInfo.decl);
|
|
1008
|
-
else oneCssOGInfo[selectorName] = oneCssInfo.decl;
|
|
1009
|
-
return false;
|
|
1010
|
-
}
|
|
1011
|
-
return true;
|
|
1012
|
-
});
|
|
1013
|
-
return oneCssInfo.sel.length > 0;
|
|
1014
|
-
});
|
|
1015
|
-
return [
|
|
1016
|
-
cssId,
|
|
1017
|
-
oneCssOGInfo
|
|
1018
|
-
];
|
|
1019
|
-
}));
|
|
1020
|
-
}
|
|
1021
816
|
const cacheForCamelize = {};
|
|
1022
817
|
function camelize(str) {
|
|
1023
818
|
if (cacheForCamelize[str]) return cacheForCamelize[str];
|
|
@@ -1258,6 +1053,62 @@ V('offset-distance');
|
|
|
1258
1053
|
function queryCSSProperty(index) {
|
|
1259
1054
|
return cssPropertyMap[index];
|
|
1260
1055
|
}
|
|
1056
|
+
const referenceTypes = async ()=>WebAssembly.validate(new Uint8Array([
|
|
1057
|
+
0,
|
|
1058
|
+
97,
|
|
1059
|
+
115,
|
|
1060
|
+
109,
|
|
1061
|
+
1,
|
|
1062
|
+
0,
|
|
1063
|
+
0,
|
|
1064
|
+
0,
|
|
1065
|
+
1,
|
|
1066
|
+
4,
|
|
1067
|
+
1,
|
|
1068
|
+
96,
|
|
1069
|
+
0,
|
|
1070
|
+
0,
|
|
1071
|
+
3,
|
|
1072
|
+
2,
|
|
1073
|
+
1,
|
|
1074
|
+
0,
|
|
1075
|
+
10,
|
|
1076
|
+
7,
|
|
1077
|
+
1,
|
|
1078
|
+
5,
|
|
1079
|
+
0,
|
|
1080
|
+
208,
|
|
1081
|
+
112,
|
|
1082
|
+
26,
|
|
1083
|
+
11
|
|
1084
|
+
]));
|
|
1085
|
+
let wasm;
|
|
1086
|
+
async function initWasm() {
|
|
1087
|
+
const supportsReferenceTypes = await referenceTypes();
|
|
1088
|
+
wasm = supportsReferenceTypes ? await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "../web-style-transformer/standard.js")) : await __webpack_require__.e("8").then(__webpack_require__.bind(__webpack_require__, "../web-style-transformer/legacy.js"));
|
|
1089
|
+
}
|
|
1090
|
+
function transformInlineStyleString(str) {
|
|
1091
|
+
return wasm.transform_raw_u16_inline_style_ptr(str) ?? str;
|
|
1092
|
+
}
|
|
1093
|
+
function transformParsedStyles(styles) {
|
|
1094
|
+
let childStyle = [];
|
|
1095
|
+
let transformedStyle = [];
|
|
1096
|
+
for (const [property, value] of styles){
|
|
1097
|
+
const transformedResult = wasm.transform_raw_u16_inline_style_ptr_parsed(property, value);
|
|
1098
|
+
if (transformedResult) {
|
|
1099
|
+
const [transformedStyleForCurrent, childStyleForCurrent] = transformedResult;
|
|
1100
|
+
transformedStyle = transformedStyle.concat(transformedStyleForCurrent);
|
|
1101
|
+
if (childStyleForCurrent) childStyle = childStyle.concat(childStyleForCurrent);
|
|
1102
|
+
} else transformedStyle.push([
|
|
1103
|
+
property,
|
|
1104
|
+
value
|
|
1105
|
+
]);
|
|
1106
|
+
}
|
|
1107
|
+
return {
|
|
1108
|
+
childStyle,
|
|
1109
|
+
transformedStyle
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1261
1112
|
var uppercasePattern = /[A-Z]/g;
|
|
1262
1113
|
var msPattern = /^ms-/;
|
|
1263
1114
|
var hyphenate_style_name_cache = {};
|
|
@@ -1305,11 +1156,11 @@ const __AddConfig = /*#__PURE__*/ (element, type, value)=>{
|
|
|
1305
1156
|
const __AddDataset = /*#__PURE__*/ (element, key, value)=>{
|
|
1306
1157
|
const currentDataset = __GetDataset(element);
|
|
1307
1158
|
currentDataset[key] = value;
|
|
1308
|
-
element.setAttribute(
|
|
1159
|
+
element.setAttribute("l-dset", encodeURIComponent(JSON.stringify(currentDataset)));
|
|
1309
1160
|
value ? element.setAttribute('data-' + key, value.toString()) : element.removeAttribute('data-' + key);
|
|
1310
1161
|
};
|
|
1311
1162
|
const __GetDataset = /*#__PURE__*/ (element)=>{
|
|
1312
|
-
const datasetString = element.getAttribute(
|
|
1163
|
+
const datasetString = element.getAttribute("l-dset");
|
|
1313
1164
|
const currentDataset = datasetString ? JSON.parse(decodeURIComponent(datasetString)) : {};
|
|
1314
1165
|
return currentDataset;
|
|
1315
1166
|
};
|
|
@@ -1327,7 +1178,7 @@ const __GetElementConfig = /*#__PURE__*/ (element)=>{
|
|
|
1327
1178
|
return currentComponentConfigString ? JSON.parse(decodeURIComponent(currentComponentConfigString)) : {};
|
|
1328
1179
|
};
|
|
1329
1180
|
const __GetAttributeByName = /*#__PURE__*/ (element, name)=>element.getAttribute(name);
|
|
1330
|
-
const __GetElementUniqueID = /*#__PURE__*/ (element)=>element && element.getAttribute ? Number(element.getAttribute(
|
|
1181
|
+
const __GetElementUniqueID = /*#__PURE__*/ (element)=>element && element.getAttribute ? Number(element.getAttribute("l-uid")) : -1;
|
|
1331
1182
|
const __GetID = /*#__PURE__*/ (element)=>element.getAttribute('id');
|
|
1332
1183
|
const __SetID = /*#__PURE__*/ (element, id)=>id ? element.setAttribute('id', id) : element.removeAttribute('id');
|
|
1333
1184
|
const __GetTag = /*#__PURE__*/ (element)=>element.getAttribute(lynxTagAttribute);
|
|
@@ -1335,7 +1186,7 @@ const __SetConfig = /*#__PURE__*/ (element, config)=>{
|
|
|
1335
1186
|
element.setAttribute(lynxComponentConfigAttribute, encodeURIComponent(JSON.stringify(config)));
|
|
1336
1187
|
};
|
|
1337
1188
|
const __SetDataset = /*#__PURE__*/ (element, dataset)=>{
|
|
1338
|
-
element.setAttribute(
|
|
1189
|
+
element.setAttribute("l-dset", encodeURIComponent(JSON.stringify(dataset)));
|
|
1339
1190
|
for (const [key, value] of Object.entries(dataset))element.setAttribute('data-' + key, value.toString());
|
|
1340
1191
|
};
|
|
1341
1192
|
const __UpdateComponentID = /*#__PURE__*/ (element, componentID)=>element.setAttribute(componentIdAttribute, componentID);
|
|
@@ -1345,8 +1196,11 @@ const __UpdateComponentInfo = /*#__PURE__*/ (element, params)=>{
|
|
|
1345
1196
|
void 0 !== params.cssID && element.setAttribute(cssIdAttribute, params.cssID + '');
|
|
1346
1197
|
void 0 !== params.name && element.setAttribute('name', params.name);
|
|
1347
1198
|
};
|
|
1348
|
-
const __SetCSSId = /*#__PURE__*/ (elements, cssId)=>{
|
|
1349
|
-
for (const element of elements)
|
|
1199
|
+
const __SetCSSId = /*#__PURE__*/ (elements, cssId, entryName)=>{
|
|
1200
|
+
for (const element of elements){
|
|
1201
|
+
element.setAttribute(cssIdAttribute, cssId + '');
|
|
1202
|
+
entryName && element.setAttribute(lynxEntryNameAttribute, entryName);
|
|
1203
|
+
}
|
|
1350
1204
|
};
|
|
1351
1205
|
const __SetClasses = /*#__PURE__*/ (element, classname)=>{
|
|
1352
1206
|
classname ? element.setAttribute('class', classname) : element.removeAttribute('class');
|
|
@@ -1390,9 +1244,9 @@ const __GetTemplateParts = (templateElement)=>{
|
|
|
1390
1244
|
if (!isTemplate) return {};
|
|
1391
1245
|
const templateUniqueId = __GetElementUniqueID(templateElement);
|
|
1392
1246
|
const parts = {};
|
|
1393
|
-
const partElements = templateElement.querySelectorAll(`[
|
|
1247
|
+
const partElements = templateElement.querySelectorAll(`[l-uid="${templateUniqueId}"] [l-part]:not([l-uid="${templateUniqueId}"] [${lynxElementTemplateMarkerAttribute}] [l-part])`);
|
|
1394
1248
|
for (const partElement of partElements){
|
|
1395
|
-
const partId = partElement.getAttribute(
|
|
1249
|
+
const partId = partElement.getAttribute("l-part");
|
|
1396
1250
|
if (partId) parts[partId] = partElement;
|
|
1397
1251
|
}
|
|
1398
1252
|
return parts;
|
|
@@ -1401,7 +1255,7 @@ const __MarkTemplateElement = (element)=>{
|
|
|
1401
1255
|
element.setAttribute(lynxElementTemplateMarkerAttribute, '');
|
|
1402
1256
|
};
|
|
1403
1257
|
const __MarkPartElement = (element, partId)=>{
|
|
1404
|
-
element.setAttribute(
|
|
1258
|
+
element.setAttribute("l-part", partId);
|
|
1405
1259
|
};
|
|
1406
1260
|
function toCloneableObject(obj) {
|
|
1407
1261
|
const cloneableObj = {};
|
|
@@ -1445,9 +1299,9 @@ function createCrossThreadEvent(domEvent, eventName) {
|
|
|
1445
1299
|
changedTouches: isTrusted ? changedTouches.map(toCloneableObject) : changedTouches
|
|
1446
1300
|
});
|
|
1447
1301
|
}
|
|
1448
|
-
const currentTargetDatasetString = currentTargetElement?.getAttribute(
|
|
1302
|
+
const currentTargetDatasetString = currentTargetElement?.getAttribute("l-dset");
|
|
1449
1303
|
const currentTargetDataset = currentTargetDatasetString ? JSON.parse(decodeURIComponent(currentTargetDatasetString)) : {};
|
|
1450
|
-
const targetDatasetString = targetElement.getAttribute(
|
|
1304
|
+
const targetDatasetString = targetElement.getAttribute("l-dset");
|
|
1451
1305
|
const targetDataset = targetDatasetString ? JSON.parse(decodeURIComponent(targetDatasetString)) : {};
|
|
1452
1306
|
return {
|
|
1453
1307
|
type: eventName,
|
|
@@ -1455,29 +1309,18 @@ function createCrossThreadEvent(domEvent, eventName) {
|
|
|
1455
1309
|
target: {
|
|
1456
1310
|
id: targetElement.getAttribute('id'),
|
|
1457
1311
|
dataset: targetDataset,
|
|
1458
|
-
uniqueId: Number(targetElement.getAttribute(
|
|
1312
|
+
uniqueId: Number(targetElement.getAttribute("l-uid"))
|
|
1459
1313
|
},
|
|
1460
1314
|
currentTarget: currentTargetElement ? {
|
|
1461
1315
|
id: currentTargetElement.getAttribute('id'),
|
|
1462
1316
|
dataset: currentTargetDataset,
|
|
1463
|
-
uniqueId: Number(currentTargetElement.getAttribute(
|
|
1317
|
+
uniqueId: Number(currentTargetElement.getAttribute("l-uid"))
|
|
1464
1318
|
} : null,
|
|
1465
1319
|
detail: domEvent.detail ?? {},
|
|
1466
1320
|
params,
|
|
1467
1321
|
...otherProperties
|
|
1468
1322
|
};
|
|
1469
1323
|
}
|
|
1470
|
-
function decodeCssOG(classes, styleInfo, cssId) {
|
|
1471
|
-
const classList = classes.split(' ').filter((e)=>e);
|
|
1472
|
-
let declarations = [];
|
|
1473
|
-
const currentStyleInfo = styleInfo[cssId ?? '0'];
|
|
1474
|
-
if (currentStyleInfo) for (const oneClassName of classList){
|
|
1475
|
-
const oneRule = currentStyleInfo[oneClassName];
|
|
1476
|
-
if (oneRule) declarations.push(...oneRule);
|
|
1477
|
-
}
|
|
1478
|
-
else console.warn(`[lynx-web] cannot find styleinfo for cssid ${cssId}`);
|
|
1479
|
-
return declarations.map(([property, value])=>`${property}:${value};`).join('');
|
|
1480
|
-
}
|
|
1481
1324
|
const exposureRelatedAttributes = new Set([
|
|
1482
1325
|
'exposure-id',
|
|
1483
1326
|
'exposure-area',
|
|
@@ -1492,36 +1335,13 @@ const exposureRelatedAttributes = new Set([
|
|
|
1492
1335
|
]);
|
|
1493
1336
|
function createMainThreadGlobalThis(config) {
|
|
1494
1337
|
let timingFlags = [];
|
|
1495
|
-
|
|
1496
|
-
const {
|
|
1338
|
+
const { callbacks, tagMap, pageConfig, lynxTemplate, rootDom, globalProps, ssrHydrateInfo, ssrHooks, mtsRealm, document } = config;
|
|
1339
|
+
const { elementTemplate, lepusCode } = lynxTemplate;
|
|
1497
1340
|
const lynxUniqueIdToElement = ssrHydrateInfo?.lynxUniqueIdToElement ?? [];
|
|
1498
|
-
const lynxUniqueIdToStyleRulesIndex = ssrHydrateInfo?.lynxUniqueIdToStyleRulesIndex ?? [];
|
|
1499
1341
|
const elementToRuntimeInfoMap = new WeakMap();
|
|
1500
1342
|
let pageElement = lynxUniqueIdToElement[1]?.deref();
|
|
1501
1343
|
let uniqueIdInc = lynxUniqueIdToElement.length || 1;
|
|
1502
|
-
const varsUpdateHandlers = [];
|
|
1503
|
-
const lynxGlobalBindingValues = {};
|
|
1504
1344
|
const exposureChangedElements = new Set();
|
|
1505
|
-
flattenStyleInfo(styleInfo, pageConfig.enableCSSSelector);
|
|
1506
|
-
transformToWebCss(styleInfo);
|
|
1507
|
-
const cssOGInfo = pageConfig.enableCSSSelector ? {} : genCssOGInfo(styleInfo);
|
|
1508
|
-
let cardStyleElement;
|
|
1509
|
-
if (ssrHydrateInfo?.cardStyleElement) cardStyleElement = ssrHydrateInfo.cardStyleElement;
|
|
1510
|
-
else {
|
|
1511
|
-
cardStyleElement = callbacks.createElement('style');
|
|
1512
|
-
cardStyleElement.innerHTML = genCssContent(styleInfo, pageConfig);
|
|
1513
|
-
rootDom.append(cardStyleElement);
|
|
1514
|
-
}
|
|
1515
|
-
const cardStyleElementSheet = cardStyleElement.sheet;
|
|
1516
|
-
const updateCssOGStyle = (uniqueId, newStyles)=>{
|
|
1517
|
-
if (void 0 !== lynxUniqueIdToStyleRulesIndex[uniqueId]) {
|
|
1518
|
-
const rule = cardStyleElementSheet.cssRules[lynxUniqueIdToStyleRulesIndex[uniqueId]];
|
|
1519
|
-
rule.style.cssText = newStyles;
|
|
1520
|
-
} else {
|
|
1521
|
-
const index = cardStyleElementSheet.insertRule(`[${lynxUniqueIdAttribute}="${uniqueId}"]{${newStyles}}`, cardStyleElementSheet.cssRules.length);
|
|
1522
|
-
lynxUniqueIdToStyleRulesIndex[uniqueId] = index;
|
|
1523
|
-
}
|
|
1524
|
-
};
|
|
1525
1345
|
const commonHandler = (event)=>{
|
|
1526
1346
|
if (!event.currentTarget) return;
|
|
1527
1347
|
const currentTarget = event.currentTarget;
|
|
@@ -1542,7 +1362,7 @@ function createMainThreadGlobalThis(config) {
|
|
|
1542
1362
|
if (hname) {
|
|
1543
1363
|
crossThreadEvent.target.elementRefptr = event.target;
|
|
1544
1364
|
if (crossThreadEvent.currentTarget) crossThreadEvent.currentTarget.elementRefptr = event.currentTarget;
|
|
1545
|
-
|
|
1365
|
+
mtsRealm.globalWindow.runWorklet?.(hname.value, [
|
|
1546
1366
|
crossThreadEvent
|
|
1547
1367
|
]);
|
|
1548
1368
|
}
|
|
@@ -1600,8 +1420,8 @@ function createMainThreadGlobalThis(config) {
|
|
|
1600
1420
|
{
|
|
1601
1421
|
eventName = eventName.toLowerCase();
|
|
1602
1422
|
const isCapture = eventType.startsWith('capture');
|
|
1603
|
-
const
|
|
1604
|
-
return
|
|
1423
|
+
const handler = isCapture ? runtimeInfo.eventHandlerMap[eventName]?.capture : runtimeInfo.eventHandlerMap[eventName]?.bind;
|
|
1424
|
+
return handler?.handler;
|
|
1605
1425
|
}
|
|
1606
1426
|
};
|
|
1607
1427
|
const __GetEvents = (element)=>{
|
|
@@ -1611,11 +1431,11 @@ function createMainThreadGlobalThis(config) {
|
|
|
1611
1431
|
info.bind,
|
|
1612
1432
|
info.capture
|
|
1613
1433
|
])if (atomInfo) {
|
|
1614
|
-
const { type, handler
|
|
1615
|
-
if (
|
|
1434
|
+
const { type, handler } = atomInfo;
|
|
1435
|
+
if (handler) eventInfos.push({
|
|
1616
1436
|
type: type,
|
|
1617
1437
|
name: lynxEventName,
|
|
1618
|
-
function:
|
|
1438
|
+
function: handler
|
|
1619
1439
|
});
|
|
1620
1440
|
}
|
|
1621
1441
|
return eventInfos;
|
|
@@ -1626,12 +1446,12 @@ function createMainThreadGlobalThis(config) {
|
|
|
1626
1446
|
const __CreateElement = (tag, parentComponentUniqueId)=>{
|
|
1627
1447
|
const uniqueId = uniqueIdInc++;
|
|
1628
1448
|
const htmlTag = tagMap[tag] ?? tag;
|
|
1629
|
-
const element =
|
|
1449
|
+
const element = document.createElement(htmlTag);
|
|
1630
1450
|
lynxUniqueIdToElement[uniqueId] = new WeakRef(element);
|
|
1631
1451
|
const parentComponentCssID = lynxUniqueIdToElement[parentComponentUniqueId]?.deref()?.getAttribute(cssIdAttribute);
|
|
1632
1452
|
parentComponentCssID && '0' !== parentComponentCssID && element.setAttribute(cssIdAttribute, parentComponentCssID);
|
|
1633
1453
|
element.setAttribute(lynxTagAttribute, tag);
|
|
1634
|
-
element.setAttribute(
|
|
1454
|
+
element.setAttribute("l-uid", uniqueId + '');
|
|
1635
1455
|
element.setAttribute(parentComponentUniqueIdAttribute, parentComponentUniqueId + '');
|
|
1636
1456
|
return element;
|
|
1637
1457
|
};
|
|
@@ -1707,7 +1527,7 @@ function createMainThreadGlobalThis(config) {
|
|
|
1707
1527
|
elementToRuntimeInfoMap.set(element, runtimeInfo);
|
|
1708
1528
|
};
|
|
1709
1529
|
const __SwapElement = (childA, childB)=>{
|
|
1710
|
-
const temp =
|
|
1530
|
+
const temp = document.createElement('div');
|
|
1711
1531
|
childA.replaceWith(temp);
|
|
1712
1532
|
childB.replaceWith(childA);
|
|
1713
1533
|
temp.replaceWith(childB);
|
|
@@ -1722,21 +1542,24 @@ function createMainThreadGlobalThis(config) {
|
|
|
1722
1542
|
const __AddClassForCSSOG = (element, className)=>{
|
|
1723
1543
|
const newClassName = ((element.getAttribute('class') ?? '') + ' ' + className).trim();
|
|
1724
1544
|
element.setAttribute('class', newClassName);
|
|
1725
|
-
const
|
|
1726
|
-
|
|
1545
|
+
const cssId = element.getAttribute(cssIdAttribute);
|
|
1546
|
+
const uniqueId = Number(element.getAttribute("l-uid"));
|
|
1547
|
+
callbacks.updateCssOGStyle(uniqueId, newClassName, cssId);
|
|
1727
1548
|
};
|
|
1728
1549
|
const __SetClassesForCSSOG = (element, classNames)=>{
|
|
1729
1550
|
__SetClasses(element, classNames);
|
|
1730
|
-
const
|
|
1731
|
-
|
|
1551
|
+
const cssId = element.getAttribute(cssIdAttribute);
|
|
1552
|
+
const uniqueId = Number(element.getAttribute("l-uid"));
|
|
1553
|
+
callbacks.updateCssOGStyle(uniqueId, classNames ?? '', cssId);
|
|
1732
1554
|
};
|
|
1733
1555
|
const __LoadLepusChunk = (path)=>{
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
const entry = lepusModule.exports;
|
|
1738
|
-
entry?.(mtsGlobalThis);
|
|
1556
|
+
try {
|
|
1557
|
+
path = lepusCode?.[path] ?? path;
|
|
1558
|
+
mtsRealm.loadScriptSync(path);
|
|
1739
1559
|
return true;
|
|
1560
|
+
} catch (e) {
|
|
1561
|
+
console.error(`failed to load lepus chunk ${path}`, e);
|
|
1562
|
+
return false;
|
|
1740
1563
|
}
|
|
1741
1564
|
};
|
|
1742
1565
|
const __FlushElementTree = (_subTree, options)=>{
|
|
@@ -1764,7 +1587,7 @@ function createMainThreadGlobalThis(config) {
|
|
|
1764
1587
|
};
|
|
1765
1588
|
const applyEventsForElementTemplate = (data, element)=>{
|
|
1766
1589
|
const uniqueId = uniqueIdInc++;
|
|
1767
|
-
element.setAttribute(
|
|
1590
|
+
element.setAttribute("l-uid", uniqueId + '');
|
|
1768
1591
|
for (const event of data.events || []){
|
|
1769
1592
|
const { type, name, value } = event;
|
|
1770
1593
|
__AddEvent(element, type, name, value);
|
|
@@ -1776,14 +1599,14 @@ function createMainThreadGlobalThis(config) {
|
|
|
1776
1599
|
}
|
|
1777
1600
|
};
|
|
1778
1601
|
const __ElementFromBinary = (templateId, parentComponentUniId)=>{
|
|
1779
|
-
const elementTemplateData =
|
|
1602
|
+
const elementTemplateData = elementTemplate[templateId];
|
|
1780
1603
|
if (elementTemplateData) {
|
|
1781
1604
|
let clonedElements;
|
|
1782
1605
|
if (templateIdToTemplate[templateId]) clonedElements = Array.from(templateIdToTemplate[templateId].content.cloneNode(true).children);
|
|
1783
1606
|
else {
|
|
1784
1607
|
clonedElements = elementTemplateData.map((data)=>createElementForElementTemplateData(data, parentComponentUniId));
|
|
1785
1608
|
if (rootDom.cloneNode) {
|
|
1786
|
-
const template =
|
|
1609
|
+
const template = document.createElement('template');
|
|
1787
1610
|
template.content.append(...clonedElements);
|
|
1788
1611
|
templateIdToTemplate[templateId] = template;
|
|
1789
1612
|
rootDom.append(template);
|
|
@@ -1865,48 +1688,30 @@ function createMainThreadGlobalThis(config) {
|
|
|
1865
1688
|
__LoadLepusChunk,
|
|
1866
1689
|
__GetPageElement,
|
|
1867
1690
|
__globalProps: globalProps,
|
|
1691
|
+
__QueryComponent: callbacks.__QueryComponent,
|
|
1868
1692
|
SystemInfo,
|
|
1869
1693
|
lynx: createMainThreadLynx(config, SystemInfo),
|
|
1870
1694
|
_ReportError: (err, _)=>callbacks._ReportError(err, _, release),
|
|
1871
1695
|
_SetSourceMapRelease: (errInfo)=>release = errInfo?.release,
|
|
1872
1696
|
__OnLifecycleEvent: callbacks.__OnLifecycleEvent,
|
|
1873
1697
|
__FlushElementTree,
|
|
1874
|
-
__lynxGlobalBindingValues: lynxGlobalBindingValues,
|
|
1875
1698
|
_I18nResourceTranslation: callbacks._I18nResourceTranslation,
|
|
1876
1699
|
_AddEventListener: ()=>{},
|
|
1877
|
-
|
|
1878
|
-
varsUpdateHandlers.push(handler);
|
|
1879
|
-
},
|
|
1880
|
-
set renderPage (foo){
|
|
1881
|
-
renderPage = foo;
|
|
1882
|
-
queueMicrotask(callbacks.mainChunkReady);
|
|
1883
|
-
},
|
|
1884
|
-
get renderPage () {
|
|
1885
|
-
return renderPage;
|
|
1886
|
-
}
|
|
1700
|
+
renderPage: void 0
|
|
1887
1701
|
};
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
return target[prop] ?? globalThis[prop];
|
|
1702
|
+
Object.assign(mtsRealm.globalWindow, mtsGlobalThis);
|
|
1703
|
+
Object.defineProperty(mtsRealm.globalWindow, 'renderPage', {
|
|
1704
|
+
get () {
|
|
1705
|
+
return mtsGlobalThis.renderPage;
|
|
1893
1706
|
},
|
|
1894
|
-
set
|
|
1895
|
-
|
|
1896
|
-
|
|
1707
|
+
set (v) {
|
|
1708
|
+
mtsGlobalThis.renderPage = v;
|
|
1709
|
+
queueMicrotask(callbacks.mainChunkReady);
|
|
1897
1710
|
},
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
}
|
|
1901
|
-
});
|
|
1902
|
-
for (const nm of globalMuteableVars)Object.defineProperty(mtsGlobalThis, nm, {
|
|
1903
|
-
get: ()=>lynxGlobalBindingValues[nm],
|
|
1904
|
-
set: (v)=>{
|
|
1905
|
-
lynxGlobalBindingValues[nm] = v;
|
|
1906
|
-
for (const handler1 of varsUpdateHandlers)handler1();
|
|
1907
|
-
}
|
|
1711
|
+
configurable: true,
|
|
1712
|
+
enumerable: true
|
|
1908
1713
|
});
|
|
1909
|
-
return
|
|
1714
|
+
return mtsRealm.globalWindow;
|
|
1910
1715
|
}
|
|
1911
1716
|
function createExposureService(rootDom, postExposure) {
|
|
1912
1717
|
let working = true;
|
|
@@ -1916,7 +1721,7 @@ function createExposureService(rootDom, postExposure) {
|
|
|
1916
1721
|
const onScreen = new Map();
|
|
1917
1722
|
function exposureEventHandler(ev) {
|
|
1918
1723
|
const exposureEvent = createCrossThreadEvent(ev, ev.type);
|
|
1919
|
-
exposureEvent.detail['unique-id'] = parseFloat(ev.target.getAttribute(
|
|
1724
|
+
exposureEvent.detail['unique-id'] = parseFloat(ev.target.getAttribute("l-uid"));
|
|
1920
1725
|
const exposureID = exposureEvent.detail.exposureID;
|
|
1921
1726
|
if ('exposure' === ev.type) {
|
|
1922
1727
|
exposureCache.push(exposureEvent);
|
|
@@ -1966,9 +1771,179 @@ function createExposureService(rootDom, postExposure) {
|
|
|
1966
1771
|
switchExposureService
|
|
1967
1772
|
};
|
|
1968
1773
|
}
|
|
1774
|
+
function decodeCssOG(classes, styleInfo, cssId) {
|
|
1775
|
+
const classList = classes.split(' ').filter((e)=>e);
|
|
1776
|
+
let declarations = [];
|
|
1777
|
+
const currentStyleInfo = styleInfo[cssId ?? '0'];
|
|
1778
|
+
if (currentStyleInfo) for (const oneClassName of classList){
|
|
1779
|
+
const oneRule = currentStyleInfo[oneClassName];
|
|
1780
|
+
if (oneRule) declarations.push(...oneRule);
|
|
1781
|
+
}
|
|
1782
|
+
else console.warn(`[lynx-web] cannot find styleinfo for cssid ${cssId}`);
|
|
1783
|
+
return declarations.map(([property, value])=>`${property}:${value};`).join('');
|
|
1784
|
+
}
|
|
1785
|
+
function flattenStyleInfo(styleInfo, enableCSSSelector) {
|
|
1786
|
+
function flattenOneStyleInfo(cssId) {
|
|
1787
|
+
const oneInfo = styleInfo[cssId];
|
|
1788
|
+
const imports = oneInfo?.imports;
|
|
1789
|
+
if (oneInfo && imports?.length) {
|
|
1790
|
+
for (const im of imports){
|
|
1791
|
+
const flatInfo = flattenOneStyleInfo(im);
|
|
1792
|
+
if (flatInfo) {
|
|
1793
|
+
oneInfo.content.push(...flatInfo.content);
|
|
1794
|
+
oneInfo.rules.push(...enableCSSSelector ? flatInfo.rules : flatInfo.rules.map((i)=>({
|
|
1795
|
+
...i
|
|
1796
|
+
})));
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
oneInfo.imports = void 0;
|
|
1800
|
+
}
|
|
1801
|
+
return oneInfo;
|
|
1802
|
+
}
|
|
1803
|
+
Object.keys(styleInfo).map((cssId)=>{
|
|
1804
|
+
flattenOneStyleInfo(cssId);
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1807
|
+
function transformToWebCss(styleInfo) {
|
|
1808
|
+
for (const cssInfos of Object.values(styleInfo))for (const rule of cssInfos.rules){
|
|
1809
|
+
const { sel: selectors, decl: declarations } = rule;
|
|
1810
|
+
const { transformedStyle, childStyle } = transformParsedStyles(declarations);
|
|
1811
|
+
rule.decl = transformedStyle;
|
|
1812
|
+
if (childStyle.length > 0) cssInfos.rules.push({
|
|
1813
|
+
sel: selectors.map((selector)=>selector.toSpliced(-2, 1, [
|
|
1814
|
+
'>'
|
|
1815
|
+
], [
|
|
1816
|
+
'*'
|
|
1817
|
+
], [], [], [])),
|
|
1818
|
+
decl: childStyle
|
|
1819
|
+
});
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
function genCssContent(styleInfo, pageConfig, entryName) {
|
|
1823
|
+
function getExtraSelectors(cssId) {
|
|
1824
|
+
let suffix;
|
|
1825
|
+
suffix = pageConfig.enableRemoveCSSScope ? `[${lynxTagAttribute}]` : void 0 !== cssId ? `[${cssIdAttribute}="${cssId}"]` : `[${lynxTagAttribute}]`;
|
|
1826
|
+
suffix = entryName ? `${suffix}[${lynxEntryNameAttribute}=${JSON.stringify(entryName)}]` : `${suffix}:not([${lynxEntryNameAttribute}])`;
|
|
1827
|
+
return suffix;
|
|
1828
|
+
}
|
|
1829
|
+
const finalCssContent = [];
|
|
1830
|
+
for (const [cssId, cssInfos] of Object.entries(styleInfo)){
|
|
1831
|
+
const suffix = getExtraSelectors(cssId);
|
|
1832
|
+
const declarationContent = cssInfos.rules.map((rule)=>{
|
|
1833
|
+
const { sel: selectorList, decl: declarations } = rule;
|
|
1834
|
+
const selectorString = selectorList.map((selectors)=>selectors.toSpliced(-4, 0, [
|
|
1835
|
+
suffix
|
|
1836
|
+
]).flat().join('')).join(',');
|
|
1837
|
+
const declarationString = declarations.map(([k, v])=>`${k}:${v};`).join('');
|
|
1838
|
+
return `${selectorString}{${declarationString}}`;
|
|
1839
|
+
}).join('');
|
|
1840
|
+
finalCssContent.push(...cssInfos.content, declarationContent);
|
|
1841
|
+
}
|
|
1842
|
+
return finalCssContent.join('\n');
|
|
1843
|
+
}
|
|
1844
|
+
function genCssOGInfo(styleInfo) {
|
|
1845
|
+
return Object.fromEntries(Object.entries(styleInfo).map(([cssId, cssInfos])=>{
|
|
1846
|
+
const oneCssOGInfo = {};
|
|
1847
|
+
cssInfos.rules = cssInfos.rules.filter((oneCssInfo)=>{
|
|
1848
|
+
oneCssInfo.sel = oneCssInfo.sel.filter((selectorList)=>{
|
|
1849
|
+
const [classSelectors, pseudoClassSelectors, pseudoElementSelectors, combinator] = selectorList;
|
|
1850
|
+
if (1 === classSelectors.length && '.' === classSelectors[0][0] && 0 === pseudoClassSelectors.length && 0 === pseudoElementSelectors.length && 0 === combinator.length) {
|
|
1851
|
+
const selectorName = classSelectors[0].substring(1);
|
|
1852
|
+
const currentDeclarations = oneCssOGInfo[selectorName];
|
|
1853
|
+
if (currentDeclarations) currentDeclarations.push(...oneCssInfo.decl);
|
|
1854
|
+
else oneCssOGInfo[selectorName] = oneCssInfo.decl;
|
|
1855
|
+
return false;
|
|
1856
|
+
}
|
|
1857
|
+
return true;
|
|
1858
|
+
});
|
|
1859
|
+
return oneCssInfo.sel.length > 0;
|
|
1860
|
+
});
|
|
1861
|
+
return [
|
|
1862
|
+
cssId,
|
|
1863
|
+
oneCssOGInfo
|
|
1864
|
+
];
|
|
1865
|
+
}));
|
|
1866
|
+
}
|
|
1867
|
+
function appendStyleElement(styleInfo, pageConfig, rootDom, document, entryName, ssrHydrateInfo) {
|
|
1868
|
+
const lynxUniqueIdToStyleRulesIndex = ssrHydrateInfo?.lynxUniqueIdToStyleRulesIndex ?? [];
|
|
1869
|
+
flattenStyleInfo(styleInfo, pageConfig.enableCSSSelector);
|
|
1870
|
+
transformToWebCss(styleInfo);
|
|
1871
|
+
const cssOGInfo = pageConfig.enableCSSSelector ? {} : genCssOGInfo(styleInfo);
|
|
1872
|
+
let cardStyleElement;
|
|
1873
|
+
if (ssrHydrateInfo?.cardStyleElement) cardStyleElement = ssrHydrateInfo.cardStyleElement;
|
|
1874
|
+
else {
|
|
1875
|
+
cardStyleElement = document.createElement('style');
|
|
1876
|
+
cardStyleElement.textContent = genCssContent(styleInfo, pageConfig, entryName);
|
|
1877
|
+
rootDom.appendChild(cardStyleElement);
|
|
1878
|
+
}
|
|
1879
|
+
const cardStyleElementSheet = cardStyleElement.sheet;
|
|
1880
|
+
const updateCssOGStyle = (uniqueId, newClassName, cssID)=>{
|
|
1881
|
+
const newStyles = decodeCssOG(newClassName, cssOGInfo, cssID);
|
|
1882
|
+
if (void 0 !== lynxUniqueIdToStyleRulesIndex[uniqueId]) {
|
|
1883
|
+
const rule = cardStyleElementSheet.cssRules[lynxUniqueIdToStyleRulesIndex[uniqueId]];
|
|
1884
|
+
rule.style.cssText = newStyles;
|
|
1885
|
+
} else {
|
|
1886
|
+
const index = cardStyleElementSheet.insertRule(`[l-uid="${uniqueId}"]{${newStyles}}`, cardStyleElementSheet.cssRules.length);
|
|
1887
|
+
lynxUniqueIdToStyleRulesIndex[uniqueId] = index;
|
|
1888
|
+
}
|
|
1889
|
+
};
|
|
1890
|
+
const updateLazyComponentStyle = (styleInfo, entryName)=>{
|
|
1891
|
+
flattenStyleInfo(styleInfo, pageConfig.enableCSSSelector);
|
|
1892
|
+
transformToWebCss(styleInfo);
|
|
1893
|
+
const newStyleSheet = genCssContent(styleInfo, pageConfig, entryName);
|
|
1894
|
+
cardStyleElement.textContent += newStyleSheet;
|
|
1895
|
+
};
|
|
1896
|
+
return {
|
|
1897
|
+
updateCssOGStyle,
|
|
1898
|
+
updateLazyComponentStyle
|
|
1899
|
+
};
|
|
1900
|
+
}
|
|
1901
|
+
function createQueryComponent(loadTemplate, updateLazyComponentStyle, backgroundThreadRpc, mtsGlobalThisRef, jsContext, mtsRealm) {
|
|
1902
|
+
const updateBTSTemplateCache = backgroundThreadRpc.createCall(updateBTSTemplateCacheEndpoint);
|
|
1903
|
+
const __QueryComponentImpl = (url, callback)=>{
|
|
1904
|
+
loadTemplate(url).then(async (template)=>{
|
|
1905
|
+
const updateBTSCachePromise = updateBTSTemplateCache(url, template);
|
|
1906
|
+
let lepusRootChunkExport = await mtsRealm.loadScript(template.lepusCode.root);
|
|
1907
|
+
if (mtsGlobalThisRef.mtsGlobalThis.processEvalResult) lepusRootChunkExport = mtsGlobalThisRef.mtsGlobalThis.processEvalResult(lepusRootChunkExport, url);
|
|
1908
|
+
updateLazyComponentStyle(template.styleInfo, url);
|
|
1909
|
+
await updateBTSCachePromise;
|
|
1910
|
+
jsContext.dispatchEvent({
|
|
1911
|
+
type: '__OnDynamicJSSourcePrepared',
|
|
1912
|
+
data: url
|
|
1913
|
+
});
|
|
1914
|
+
callback?.({
|
|
1915
|
+
code: 0,
|
|
1916
|
+
data: {
|
|
1917
|
+
url,
|
|
1918
|
+
evalResult: lepusRootChunkExport
|
|
1919
|
+
}
|
|
1920
|
+
});
|
|
1921
|
+
}).catch((error)=>{
|
|
1922
|
+
console.error("lynx web: lazy bundle load failed:", error);
|
|
1923
|
+
callback?.({
|
|
1924
|
+
code: -1,
|
|
1925
|
+
data: void 0
|
|
1926
|
+
});
|
|
1927
|
+
});
|
|
1928
|
+
return null;
|
|
1929
|
+
};
|
|
1930
|
+
backgroundThreadRpc.registerHandler(queryComponentEndpoint, (url)=>{
|
|
1931
|
+
const ret = new Promise((resolve)=>{
|
|
1932
|
+
__QueryComponentImpl(url, (result)=>{
|
|
1933
|
+
resolve({
|
|
1934
|
+
code: result.code,
|
|
1935
|
+
detail: {
|
|
1936
|
+
schema: url
|
|
1937
|
+
}
|
|
1938
|
+
});
|
|
1939
|
+
});
|
|
1940
|
+
});
|
|
1941
|
+
return ret;
|
|
1942
|
+
});
|
|
1943
|
+
return __QueryComponentImpl;
|
|
1944
|
+
}
|
|
1969
1945
|
const initWasmPromise = initWasm();
|
|
1970
|
-
|
|
1971
|
-
function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, createElement, commitDocument, markTimingInternal, flushMarkTimingInternal, reportError, triggerI18nResourceFallback, initialI18nResources, ssrHooks) {
|
|
1946
|
+
function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, document, mtsRealm, commitDocument, markTimingInternal, flushMarkTimingInternal, reportError, triggerI18nResourceFallback, initialI18nResources, loadTemplate, ssrHooks) {
|
|
1972
1947
|
const postTimingFlags = backgroundThreadRpc.createCall(postTimingFlagsEndpoint);
|
|
1973
1948
|
const backgroundStart = backgroundThreadRpc.createCall(BackgroundThreadStartEndpoint);
|
|
1974
1949
|
const publishEvent = backgroundThreadRpc.createCall(publishEventEndpoint);
|
|
@@ -1979,49 +1954,34 @@ function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, createElement, comm
|
|
|
1979
1954
|
async function startMainThread(config, ssrHydrateInfo) {
|
|
1980
1955
|
let isFp = true;
|
|
1981
1956
|
const { globalProps, template, browserConfig, nativeModulesMap, napiModulesMap, tagMap, initI18nResources } = config;
|
|
1982
|
-
const { styleInfo, pageConfig, customSections, cardType
|
|
1957
|
+
const { styleInfo, pageConfig, customSections, cardType } = template;
|
|
1983
1958
|
markTimingInternal('decode_start');
|
|
1984
1959
|
await initWasmPromise;
|
|
1985
|
-
const lepusCodeEntries = await Promise.all(Object.entries(lepusCode).map(async ([name, url])=>{
|
|
1986
|
-
const cachedModule = moduleCache[url];
|
|
1987
|
-
if (cachedModule) return [
|
|
1988
|
-
name,
|
|
1989
|
-
cachedModule
|
|
1990
|
-
];
|
|
1991
|
-
{
|
|
1992
|
-
const { default: evaluateModule } = await import(url);
|
|
1993
|
-
const module = {
|
|
1994
|
-
exports: evaluateModule
|
|
1995
|
-
};
|
|
1996
|
-
moduleCache[url] = module;
|
|
1997
|
-
return [
|
|
1998
|
-
name,
|
|
1999
|
-
module
|
|
2000
|
-
];
|
|
2001
|
-
}
|
|
2002
|
-
}));
|
|
2003
|
-
const lepusCodeLoaded = Object.fromEntries(lepusCodeEntries);
|
|
2004
|
-
const entry = lepusCodeLoaded['root'].exports;
|
|
2005
1960
|
const jsContext = new LynxCrossThreadContext({
|
|
2006
1961
|
rpc: backgroundThreadRpc,
|
|
2007
1962
|
receiveEventEndpoint: dispatchJSContextOnMainThreadEndpoint,
|
|
2008
1963
|
sendEventEndpoint: dispatchCoreContextOnBackgroundEndpoint
|
|
2009
1964
|
});
|
|
2010
1965
|
const i18nResources = initialI18nResources(initI18nResources);
|
|
1966
|
+
const { updateCssOGStyle, updateLazyComponentStyle } = appendStyleElement(styleInfo, pageConfig, rootDom, document, void 0, ssrHydrateInfo);
|
|
1967
|
+
const mtsGlobalThisRef = {
|
|
1968
|
+
mtsGlobalThis: void 0
|
|
1969
|
+
};
|
|
1970
|
+
const __QueryComponent = createQueryComponent(loadTemplate, updateLazyComponentStyle, backgroundThreadRpc, mtsGlobalThisRef, jsContext, mtsRealm);
|
|
2011
1971
|
const mtsGlobalThis = createMainThreadGlobalThis({
|
|
1972
|
+
lynxTemplate: template,
|
|
1973
|
+
mtsRealm,
|
|
2012
1974
|
jsContext,
|
|
2013
1975
|
tagMap,
|
|
2014
1976
|
browserConfig,
|
|
2015
|
-
customSections,
|
|
2016
|
-
elementTemplate,
|
|
2017
1977
|
globalProps,
|
|
2018
1978
|
pageConfig,
|
|
2019
|
-
styleInfo,
|
|
2020
|
-
lepusCode: lepusCodeLoaded,
|
|
2021
1979
|
rootDom,
|
|
2022
1980
|
ssrHydrateInfo,
|
|
2023
1981
|
ssrHooks,
|
|
1982
|
+
document,
|
|
2024
1983
|
callbacks: {
|
|
1984
|
+
updateCssOGStyle,
|
|
2025
1985
|
mainChunkReady: ()=>{
|
|
2026
1986
|
markTimingInternal('data_processor_start');
|
|
2027
1987
|
let initData = config.initData;
|
|
@@ -2041,8 +2001,7 @@ function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, createElement, comm
|
|
|
2041
2001
|
v.content
|
|
2042
2002
|
])),
|
|
2043
2003
|
nativeModulesMap,
|
|
2044
|
-
napiModulesMap
|
|
2045
|
-
browserConfig
|
|
2004
|
+
napiModulesMap
|
|
2046
2005
|
});
|
|
2047
2006
|
if (ssrHydrateInfo) {
|
|
2048
2007
|
for (const event of ssrHydrateInfo.events){
|
|
@@ -2087,19 +2046,19 @@ function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, createElement, comm
|
|
|
2087
2046
|
markTiming: (a, b)=>markTimingInternal(b, a),
|
|
2088
2047
|
publishEvent,
|
|
2089
2048
|
publicComponentEvent,
|
|
2090
|
-
createElement,
|
|
2091
2049
|
_I18nResourceTranslation: (options)=>{
|
|
2092
2050
|
const matchedInitI18nResources = i18nResources.data?.find((i)=>getCacheI18nResourcesKey(i.options) === getCacheI18nResourcesKey(options));
|
|
2093
2051
|
dispatchI18nResource(matchedInitI18nResources?.resource);
|
|
2094
2052
|
if (matchedInitI18nResources) return matchedInitI18nResources.resource;
|
|
2095
2053
|
return triggerI18nResourceFallback(options);
|
|
2096
|
-
}
|
|
2054
|
+
},
|
|
2055
|
+
__QueryComponent
|
|
2097
2056
|
}
|
|
2098
2057
|
});
|
|
2058
|
+
mtsGlobalThisRef.mtsGlobalThis = mtsGlobalThis;
|
|
2099
2059
|
markTimingInternal('decode_end');
|
|
2100
|
-
|
|
2060
|
+
await mtsRealm.loadScript(template.lepusCode.root);
|
|
2101
2061
|
jsContext.__start();
|
|
2102
|
-
return mtsGlobalThis;
|
|
2103
2062
|
}
|
|
2104
2063
|
return {
|
|
2105
2064
|
startMainThread
|
|
@@ -2116,7 +2075,7 @@ async function loadTemplate_createJsModuleUrl(content, filename) {
|
|
|
2116
2075
|
});
|
|
2117
2076
|
return fileUrl;
|
|
2118
2077
|
}
|
|
2119
|
-
async function
|
|
2078
|
+
async function loadTemplate_loadTemplate(rawTemplate, templateName = Math.random().toString(36).substring(2, 7)) {
|
|
2120
2079
|
if (templateCache.has(rawTemplate)) return templateCache.get(rawTemplate);
|
|
2121
2080
|
templateName += Math.random().toString(36).substring(2, 7);
|
|
2122
2081
|
const decodedTemplate = templateCache.get(rawTemplate) ?? await generateTemplate(rawTemplate, loadTemplate_createJsModuleUrl, templateName + '-lepusCode');
|
|
@@ -2135,7 +2094,7 @@ const OperationType = {
|
|
|
2135
2094
|
RemoveChild: 9,
|
|
2136
2095
|
StyleDeclarationSetProperty: 10,
|
|
2137
2096
|
StyleDeclarationRemoveProperty: 11,
|
|
2138
|
-
|
|
2097
|
+
SetTextContent: 12,
|
|
2139
2098
|
sheetInsertRule: 13,
|
|
2140
2099
|
sheetRuleUpdateCssText: 14
|
|
2141
2100
|
};
|
|
@@ -2158,12 +2117,12 @@ class OffscreenCSSStyleDeclaration {
|
|
|
2158
2117
|
const ancestorDocument = Symbol('ancestorDocument');
|
|
2159
2118
|
const _attributes = Symbol('_attributes');
|
|
2160
2119
|
const _children = Symbol('_children');
|
|
2161
|
-
const
|
|
2120
|
+
const textContent = Symbol('textContent');
|
|
2162
2121
|
const _cssRuleContents = Symbol('_cssRuleContents');
|
|
2163
2122
|
const OffscreenElement_uniqueId = Symbol('uniqueId');
|
|
2164
2123
|
const _style = Symbol('_style');
|
|
2165
2124
|
class OffscreenElement extends EventTarget {
|
|
2166
|
-
[
|
|
2125
|
+
[textContent] = '';
|
|
2167
2126
|
[_style];
|
|
2168
2127
|
[_attributes] = new Map();
|
|
2169
2128
|
_parentElement = null;
|
|
@@ -2310,10 +2269,13 @@ class OffscreenElement extends EventTarget {
|
|
|
2310
2269
|
this[ancestorDocument][enableEvent](type, this[OffscreenElement_uniqueId]);
|
|
2311
2270
|
super.addEventListener(type, callback, options);
|
|
2312
2271
|
}
|
|
2313
|
-
|
|
2314
|
-
|
|
2272
|
+
get textContent() {
|
|
2273
|
+
return this[textContent];
|
|
2274
|
+
}
|
|
2275
|
+
set textContent(text1) {
|
|
2276
|
+
this[ancestorDocument][operations].push(OperationType.SetTextContent, this[OffscreenElement_uniqueId], text1);
|
|
2315
2277
|
for (const child of this.children)child.remove();
|
|
2316
|
-
this[
|
|
2278
|
+
this[textContent] = text1;
|
|
2317
2279
|
if (this[_cssRuleContents]) this[_cssRuleContents] = [];
|
|
2318
2280
|
}
|
|
2319
2281
|
}
|
|
@@ -2561,13 +2523,35 @@ const templateXOverlayNg = `<style>
|
|
|
2561
2523
|
right: 0;
|
|
2562
2524
|
bottom: 0;
|
|
2563
2525
|
position: fixed;
|
|
2526
|
+
overscroll-behavior: contain;
|
|
2527
|
+
scrollbar-width: none;
|
|
2528
|
+
}
|
|
2529
|
+
#dialog[open]::-webkit-scrollbar {
|
|
2530
|
+
display: none;
|
|
2564
2531
|
}
|
|
2565
2532
|
#dialog::backdrop {
|
|
2566
2533
|
background-color: transparent;
|
|
2567
2534
|
}
|
|
2535
|
+
.overlay-inner {
|
|
2536
|
+
position: sticky;
|
|
2537
|
+
top: 0;
|
|
2538
|
+
width: 100%;
|
|
2539
|
+
height: 100%;
|
|
2540
|
+
pointer-events: none;
|
|
2541
|
+
}
|
|
2542
|
+
.overlay-inner > * {
|
|
2543
|
+
pointer-events: auto;
|
|
2544
|
+
}
|
|
2545
|
+
.overlay-placeholder {
|
|
2546
|
+
width: 100%;
|
|
2547
|
+
height: 1px;
|
|
2548
|
+
}
|
|
2568
2549
|
</style>
|
|
2569
2550
|
<dialog id="dialog" part="dialog">
|
|
2570
|
-
<
|
|
2551
|
+
<div class="overlay-inner">
|
|
2552
|
+
<slot></slot>
|
|
2553
|
+
</div>
|
|
2554
|
+
<div class="overlay-placeholder"></div>
|
|
2571
2555
|
</dialog>`;
|
|
2572
2556
|
const templateXRefreshView = `<style>
|
|
2573
2557
|
.bounce-container {
|
|
@@ -2740,7 +2724,7 @@ function escapeHtml(string) {
|
|
|
2740
2724
|
}
|
|
2741
2725
|
return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
|
|
2742
2726
|
}
|
|
2743
|
-
function
|
|
2727
|
+
function getTextContentImpl(buffer, element, shadowrootTemplates) {
|
|
2744
2728
|
const localName = element.localName;
|
|
2745
2729
|
buffer.push('<');
|
|
2746
2730
|
buffer.push(localName);
|
|
@@ -2753,8 +2737,8 @@ function getInnerHTMLImpl(buffer, element, shadowrootTemplates) {
|
|
|
2753
2737
|
buffer.push('"');
|
|
2754
2738
|
}
|
|
2755
2739
|
}
|
|
2756
|
-
const partId = element[_attributes].get(
|
|
2757
|
-
buffer.push(' ',
|
|
2740
|
+
const partId = element[_attributes].get("l-part") ?? element[_attributes].get("l-uid");
|
|
2741
|
+
buffer.push(' ', "l-part", '="', partId, '"');
|
|
2758
2742
|
buffer.push('>');
|
|
2759
2743
|
const templateImpl = shadowrootTemplates[localName];
|
|
2760
2744
|
if (templateImpl) {
|
|
@@ -2762,14 +2746,14 @@ function getInnerHTMLImpl(buffer, element, shadowrootTemplates) {
|
|
|
2762
2746
|
buffer.push('<template shadowrootmode="open">', template, '</template>');
|
|
2763
2747
|
}
|
|
2764
2748
|
if (element[_cssRuleContents]?.length) buffer.push(...element[_cssRuleContents]);
|
|
2765
|
-
if (element[
|
|
2766
|
-
else for (const child of element[_children])
|
|
2749
|
+
if (element[textContent]) buffer.push(element[textContent]);
|
|
2750
|
+
else for (const child of element[_children])getTextContentImpl(buffer, child, shadowrootTemplates);
|
|
2767
2751
|
buffer.push('</');
|
|
2768
2752
|
buffer.push(localName);
|
|
2769
2753
|
buffer.push('>');
|
|
2770
2754
|
}
|
|
2771
2755
|
function dumpHTMLString(buffer, element, shadowrootTemplates) {
|
|
2772
|
-
for (const child of element[_children])
|
|
2756
|
+
for (const child of element[_children])getTextContentImpl(buffer, child, shadowrootTemplates);
|
|
2773
2757
|
}
|
|
2774
2758
|
const builtinElementTemplates = {
|
|
2775
2759
|
'scroll-view': templateScrollView,
|
|
@@ -2796,12 +2780,12 @@ const builtinTagTransformMap = {
|
|
|
2796
2780
|
};
|
|
2797
2781
|
OffscreenElement.prototype.toJSON = function() {
|
|
2798
2782
|
return {
|
|
2799
|
-
ssrID: this[_attributes].get(
|
|
2783
|
+
ssrID: this[_attributes].get("l-part") ?? this[_attributes].get("l-uid")
|
|
2800
2784
|
};
|
|
2801
2785
|
};
|
|
2802
2786
|
async function createLynxView(config) {
|
|
2803
2787
|
const { template: rawTemplate, browserConfig, tagMap, initData, globalProps, overrideElementTemplates = {}, hydrateUrl, autoSize, injectStyles, lynxViewStyle, threadStrategy = 'all-on-ui', initI18nResources } = config;
|
|
2804
|
-
const template = await
|
|
2788
|
+
const template = await loadTemplate_loadTemplate(rawTemplate, config.templateName);
|
|
2805
2789
|
const { promise: firstPaintReadyPromise, resolve: firstPaintReady } = Promise.withResolvers();
|
|
2806
2790
|
const mainWithBackgroundChannel = new MessageChannel();
|
|
2807
2791
|
const backgroundThreadRpc = new Rpc(mainWithBackgroundChannel.port1, 'background-thread');
|
|
@@ -2810,22 +2794,69 @@ async function createLynxView(config) {
|
|
|
2810
2794
|
});
|
|
2811
2795
|
const i18nResources = new I18nResources();
|
|
2812
2796
|
const events = [];
|
|
2813
|
-
const
|
|
2797
|
+
const mtsVMContext = node_vm.createContext(node_vm.constants.DONT_CONTEXTIFY);
|
|
2798
|
+
Object.assign(mtsVMContext, {
|
|
2799
|
+
document: offscreenDocument,
|
|
2800
|
+
module: {
|
|
2801
|
+
exports: null
|
|
2802
|
+
}
|
|
2803
|
+
});
|
|
2804
|
+
const loadScriptSync = (url)=>{
|
|
2805
|
+
const scriptContent = node_fs.readFileSync(url);
|
|
2806
|
+
const script = new node_vm.Script(scriptContent.toString(), {
|
|
2807
|
+
filename: url
|
|
2808
|
+
});
|
|
2809
|
+
mtsVMContext.module = {
|
|
2810
|
+
exports: null
|
|
2811
|
+
};
|
|
2812
|
+
script.runInContext(mtsVMContext);
|
|
2813
|
+
const ret = mtsVMContext.module.exports;
|
|
2814
|
+
mtsVMContext.module = {
|
|
2815
|
+
exports: null
|
|
2816
|
+
};
|
|
2817
|
+
return ret;
|
|
2818
|
+
};
|
|
2819
|
+
const loadScript = async (url)=>new Promise((resolve, reject)=>{
|
|
2820
|
+
node_fs.readFile(url, (err, data)=>{
|
|
2821
|
+
if (err) return void reject(err);
|
|
2822
|
+
try {
|
|
2823
|
+
const script = new node_vm.Script(data.toString(), {
|
|
2824
|
+
filename: url
|
|
2825
|
+
});
|
|
2826
|
+
mtsVMContext.module = {
|
|
2827
|
+
exports: null
|
|
2828
|
+
};
|
|
2829
|
+
script.runInContext(mtsVMContext);
|
|
2830
|
+
const ret = mtsVMContext.module.exports;
|
|
2831
|
+
mtsVMContext.module = {
|
|
2832
|
+
exports: null
|
|
2833
|
+
};
|
|
2834
|
+
resolve(ret);
|
|
2835
|
+
} catch (e) {
|
|
2836
|
+
reject(e);
|
|
2837
|
+
}
|
|
2838
|
+
});
|
|
2839
|
+
});
|
|
2840
|
+
const { startMainThread } = prepareMainThreadAPIs(backgroundThreadRpc, offscreenDocument, offscreenDocument, {
|
|
2841
|
+
globalWindow: mtsVMContext,
|
|
2842
|
+
loadScript,
|
|
2843
|
+
loadScriptSync
|
|
2844
|
+
}, ()=>{
|
|
2814
2845
|
firstPaintReady();
|
|
2815
2846
|
}, ()=>{}, ()=>{}, ()=>{}, ()=>{}, (initI18nResources)=>{
|
|
2816
2847
|
i18nResources.setData(initI18nResources);
|
|
2817
2848
|
return i18nResources;
|
|
2818
|
-
}, {
|
|
2849
|
+
}, ()=>{}, {
|
|
2819
2850
|
__AddEvent (element, eventName, eventData, eventOptions) {
|
|
2820
2851
|
events.push([
|
|
2821
|
-
Number(element.getAttribute(
|
|
2852
|
+
Number(element.getAttribute("l-uid")),
|
|
2822
2853
|
eventName,
|
|
2823
2854
|
eventData,
|
|
2824
2855
|
eventOptions
|
|
2825
2856
|
]);
|
|
2826
2857
|
}
|
|
2827
2858
|
});
|
|
2828
|
-
|
|
2859
|
+
await startMainThread({
|
|
2829
2860
|
template,
|
|
2830
2861
|
initData,
|
|
2831
2862
|
globalProps,
|
|
@@ -2844,7 +2875,7 @@ async function createLynxView(config) {
|
|
|
2844
2875
|
};
|
|
2845
2876
|
async function renderToString() {
|
|
2846
2877
|
await firstPaintReadyPromise;
|
|
2847
|
-
const ssrEncodeData =
|
|
2878
|
+
const ssrEncodeData = mtsVMContext?.ssrEncode?.();
|
|
2848
2879
|
const ssrDumpInfo = {
|
|
2849
2880
|
ssrEncodeData,
|
|
2850
2881
|
events
|