@lynx-js/web-core-server 0.15.2 → 0.15.4
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 +8 -0
- package/dist/index.js +2859 -6
- package/dist/legacy-wasm-chunk.js +176 -0
- package/dist/static/wasm/82481b55abcd3d16.module.wasm +0 -0
- package/dist/static/wasm/e2b9bfa6543ca3e1.module.wasm +0 -0
- package/package.json +10 -5
- package/dist/createLynxView.js +0 -116
- package/dist/dumpHTMLString.js +0 -48
- package/dist/utils/escapeHtml.js +0 -67
- package/dist/utils/loadTemplate.js +0 -29
package/dist/index.js
CHANGED
|
@@ -1,11 +1,2864 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import node_os from "node:os";
|
|
2
|
+
import promises from "node:fs/promises";
|
|
3
|
+
import node_path from "node:path";
|
|
4
|
+
var __webpack_modules__ = {
|
|
5
|
+
"../web-style-transformer/dist/standard.js": function(module, __webpack_exports__, __webpack_require__) {
|
|
6
|
+
__webpack_require__.a(module, async function(__webpack_handle_async_dependencies__, __webpack_async_result__) {
|
|
7
|
+
try {
|
|
8
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
9
|
+
C2: ()=>_standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.C2,
|
|
10
|
+
Or: ()=>_standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.Or,
|
|
11
|
+
Y1: ()=>_standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.Y1,
|
|
12
|
+
a9: ()=>_standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.a9,
|
|
13
|
+
gd: ()=>_standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.gd,
|
|
14
|
+
oT: ()=>_standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.oT,
|
|
15
|
+
pE: ()=>_standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.pE,
|
|
16
|
+
sy: ()=>_standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.sy,
|
|
17
|
+
xJ: ()=>_standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.xJ,
|
|
18
|
+
xQ: ()=>_standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.xQ
|
|
19
|
+
});
|
|
20
|
+
var _standard_bg_wasm__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../web-style-transformer/dist/standard_bg.wasm");
|
|
21
|
+
var _standard_bg_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../web-style-transformer/dist/standard_bg.js");
|
|
22
|
+
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([
|
|
23
|
+
_standard_bg_wasm__WEBPACK_IMPORTED_MODULE_1__
|
|
24
|
+
]);
|
|
25
|
+
_standard_bg_wasm__WEBPACK_IMPORTED_MODULE_1__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];
|
|
26
|
+
(0, _standard_bg_js__WEBPACK_IMPORTED_MODULE_0__.oT)(_standard_bg_wasm__WEBPACK_IMPORTED_MODULE_1__);
|
|
27
|
+
_standard_bg_wasm__WEBPACK_IMPORTED_MODULE_1__.__wbindgen_start();
|
|
28
|
+
__webpack_async_result__();
|
|
29
|
+
} catch (e) {
|
|
30
|
+
__webpack_async_result__(e);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
"../web-style-transformer/dist/standard_bg.js": function(module, __webpack_exports__, __webpack_require__) {
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
C2: ()=>__wbg_push_737cfc8c1432c2c6,
|
|
37
|
+
Or: ()=>__wbindgen_throw,
|
|
38
|
+
Y1: ()=>malloc,
|
|
39
|
+
a9: ()=>__wbg_new_78feb108b6472713,
|
|
40
|
+
gd: ()=>free,
|
|
41
|
+
oT: ()=>__wbg_set_wasm,
|
|
42
|
+
pE: ()=>transform_raw_u16_inline_style_ptr_parsed,
|
|
43
|
+
sy: ()=>__wbg_fromCharCode_5493f9b25e1ce0a1,
|
|
44
|
+
xJ: ()=>transform_raw_u16_inline_style_ptr,
|
|
45
|
+
xQ: ()=>__wbindgen_init_externref_table
|
|
46
|
+
});
|
|
47
|
+
module = __webpack_require__.hmd(module);
|
|
48
|
+
let wasm;
|
|
49
|
+
function __wbg_set_wasm(val) {
|
|
50
|
+
wasm = val;
|
|
51
|
+
}
|
|
52
|
+
let cachedUint16ArrayMemory0 = null;
|
|
53
|
+
function getUint16ArrayMemory0() {
|
|
54
|
+
if (null === cachedUint16ArrayMemory0 || 0 === cachedUint16ArrayMemory0.byteLength) cachedUint16ArrayMemory0 = new Uint16Array(wasm.memory.buffer);
|
|
55
|
+
return cachedUint16ArrayMemory0;
|
|
56
|
+
}
|
|
57
|
+
function getArrayU16FromWasm0(ptr, len) {
|
|
58
|
+
ptr >>>= 0;
|
|
59
|
+
return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
|
|
60
|
+
}
|
|
61
|
+
const lTextDecoder = 'undefined' == typeof TextDecoder ? (0, module.require)('util').TextDecoder : TextDecoder;
|
|
62
|
+
let cachedTextDecoder = new lTextDecoder('utf-8', {
|
|
63
|
+
ignoreBOM: true,
|
|
64
|
+
fatal: true
|
|
65
|
+
});
|
|
66
|
+
cachedTextDecoder.decode();
|
|
67
|
+
let cachedUint8ArrayMemory0 = null;
|
|
68
|
+
function getUint8ArrayMemory0() {
|
|
69
|
+
if (null === cachedUint8ArrayMemory0 || 0 === cachedUint8ArrayMemory0.byteLength) cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
70
|
+
return cachedUint8ArrayMemory0;
|
|
71
|
+
}
|
|
72
|
+
function getStringFromWasm0(ptr, len) {
|
|
73
|
+
ptr >>>= 0;
|
|
74
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
75
|
+
}
|
|
76
|
+
function transform_raw_u16_inline_style_ptr(ptr, len) {
|
|
77
|
+
const ret = wasm.transform_raw_u16_inline_style_ptr(ptr, len);
|
|
78
|
+
return ret;
|
|
79
|
+
}
|
|
80
|
+
function transform_raw_u16_inline_style_ptr_parsed(name_ptr, name_len, value_ptr, value_len) {
|
|
81
|
+
const ret = wasm.transform_raw_u16_inline_style_ptr_parsed(name_ptr, name_len, value_ptr, value_len);
|
|
82
|
+
return ret;
|
|
83
|
+
}
|
|
84
|
+
function malloc(size) {
|
|
85
|
+
const ret = wasm.malloc(size);
|
|
86
|
+
return ret >>> 0;
|
|
87
|
+
}
|
|
88
|
+
function free(ptr, size) {
|
|
89
|
+
wasm.free(ptr, size);
|
|
90
|
+
}
|
|
91
|
+
function __wbg_fromCharCode_5493f9b25e1ce0a1(arg0, arg1) {
|
|
92
|
+
const ret = String.fromCharCode(...getArrayU16FromWasm0(arg0, arg1));
|
|
93
|
+
return ret;
|
|
94
|
+
}
|
|
95
|
+
function __wbg_new_78feb108b6472713() {
|
|
96
|
+
const ret = new Array();
|
|
97
|
+
return ret;
|
|
98
|
+
}
|
|
99
|
+
function __wbg_push_737cfc8c1432c2c6(arg0, arg1) {
|
|
100
|
+
const ret = arg0.push(arg1);
|
|
101
|
+
return ret;
|
|
102
|
+
}
|
|
103
|
+
function __wbindgen_init_externref_table() {
|
|
104
|
+
const table = wasm.__wbindgen_export_0;
|
|
105
|
+
const offset = table.grow(4);
|
|
106
|
+
table.set(0, void 0);
|
|
107
|
+
table.set(offset + 0, void 0);
|
|
108
|
+
table.set(offset + 1, null);
|
|
109
|
+
table.set(offset + 2, true);
|
|
110
|
+
table.set(offset + 3, false);
|
|
111
|
+
}
|
|
112
|
+
function __wbindgen_throw(arg0, arg1) {
|
|
113
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"../web-style-transformer/standard.js": function(module, __webpack_exports__, __webpack_require__) {
|
|
117
|
+
__webpack_require__.a(module, async function(__webpack_handle_async_dependencies__, __webpack_async_result__) {
|
|
118
|
+
try {
|
|
119
|
+
__webpack_require__.r(__webpack_exports__);
|
|
120
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
121
|
+
__wbg_fromCharCode_5493f9b25e1ce0a1: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.sy,
|
|
122
|
+
__wbg_new_78feb108b6472713: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.a9,
|
|
123
|
+
__wbg_push_737cfc8c1432c2c6: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.C2,
|
|
124
|
+
__wbg_set_wasm: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.oT,
|
|
125
|
+
__wbindgen_init_externref_table: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.xQ,
|
|
126
|
+
__wbindgen_throw: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.Or,
|
|
127
|
+
free: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.gd,
|
|
128
|
+
malloc: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.Y1,
|
|
129
|
+
memory: ()=>_dist_standard_bg_wasm__WEBPACK_IMPORTED_MODULE_1__.memory,
|
|
130
|
+
transform_raw_u16_inline_style_ptr: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.xJ,
|
|
131
|
+
transform_raw_u16_inline_style_ptr_parsed: ()=>_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__.pE
|
|
132
|
+
});
|
|
133
|
+
var _dist_standard_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../web-style-transformer/dist/standard.js");
|
|
134
|
+
var _dist_standard_bg_wasm__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../web-style-transformer/dist/standard_bg.wasm");
|
|
135
|
+
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([
|
|
136
|
+
_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__,
|
|
137
|
+
_dist_standard_bg_wasm__WEBPACK_IMPORTED_MODULE_1__
|
|
138
|
+
]);
|
|
139
|
+
[_dist_standard_js__WEBPACK_IMPORTED_MODULE_0__, _dist_standard_bg_wasm__WEBPACK_IMPORTED_MODULE_1__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__;
|
|
140
|
+
__webpack_async_result__();
|
|
141
|
+
} catch (e) {
|
|
142
|
+
__webpack_async_result__(e);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
"../web-style-transformer/dist/standard_bg.wasm": function(module, exports, __webpack_require__) {
|
|
147
|
+
var WEBPACK_IMPORTED_MODULE_0 = __webpack_require__("../web-style-transformer/dist/standard_bg.js");
|
|
148
|
+
module.exports = __webpack_require__.v(exports, module.id, "e2b9bfa6543ca3e1", {
|
|
149
|
+
"./standard_bg.js": {
|
|
150
|
+
__wbg_fromCharCode_5493f9b25e1ce0a1: WEBPACK_IMPORTED_MODULE_0.sy,
|
|
151
|
+
__wbg_new_78feb108b6472713: WEBPACK_IMPORTED_MODULE_0.a9,
|
|
152
|
+
__wbg_push_737cfc8c1432c2c6: WEBPACK_IMPORTED_MODULE_0.C2,
|
|
153
|
+
__wbindgen_throw: WEBPACK_IMPORTED_MODULE_0.Or,
|
|
154
|
+
__wbindgen_init_externref_table: WEBPACK_IMPORTED_MODULE_0.xQ
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
var __webpack_module_cache__ = {};
|
|
160
|
+
function __webpack_require__(moduleId) {
|
|
161
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
162
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
163
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
164
|
+
id: moduleId,
|
|
165
|
+
loaded: false,
|
|
166
|
+
exports: {}
|
|
167
|
+
};
|
|
168
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
169
|
+
module.loaded = true;
|
|
170
|
+
return module.exports;
|
|
171
|
+
}
|
|
172
|
+
__webpack_require__.m = __webpack_modules__;
|
|
173
|
+
(()=>{
|
|
174
|
+
var webpackQueues = "function" == typeof Symbol ? Symbol("webpack queues") : "__webpack_queues__";
|
|
175
|
+
var webpackExports = "function" == typeof Symbol ? Symbol("webpack exports") : "__webpack_exports__";
|
|
176
|
+
var webpackError = "function" == typeof Symbol ? Symbol("webpack error") : "__webpack_error__";
|
|
177
|
+
var resolveQueue = (queue)=>{
|
|
178
|
+
if (queue && queue.d < 1) {
|
|
179
|
+
queue.d = 1;
|
|
180
|
+
queue.forEach((fn)=>fn.r--);
|
|
181
|
+
queue.forEach((fn)=>fn.r-- ? fn.r++ : fn());
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
var wrapDeps = (deps)=>deps.map((dep)=>{
|
|
185
|
+
if (null !== dep && "object" == typeof dep) {
|
|
186
|
+
if (dep[webpackQueues]) return dep;
|
|
187
|
+
if (dep.then) {
|
|
188
|
+
var queue = [];
|
|
189
|
+
queue.d = 0;
|
|
190
|
+
dep.then((r)=>{
|
|
191
|
+
obj[webpackExports] = r;
|
|
192
|
+
resolveQueue(queue);
|
|
193
|
+
}, (e)=>{
|
|
194
|
+
obj[webpackError] = e;
|
|
195
|
+
resolveQueue(queue);
|
|
196
|
+
});
|
|
197
|
+
var obj = {};
|
|
198
|
+
obj[webpackQueues] = (fn)=>fn(queue);
|
|
199
|
+
return obj;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
var ret = {};
|
|
203
|
+
ret[webpackQueues] = function() {};
|
|
204
|
+
ret[webpackExports] = dep;
|
|
205
|
+
return ret;
|
|
206
|
+
});
|
|
207
|
+
__webpack_require__.a = (module, body, hasAwait)=>{
|
|
208
|
+
var queue;
|
|
209
|
+
hasAwait && ((queue = []).d = -1);
|
|
210
|
+
var depQueues = new Set();
|
|
211
|
+
var exports = module.exports;
|
|
212
|
+
var currentDeps;
|
|
213
|
+
var outerResolve;
|
|
214
|
+
var reject;
|
|
215
|
+
var promise = new Promise((resolve, rej)=>{
|
|
216
|
+
reject = rej;
|
|
217
|
+
outerResolve = resolve;
|
|
218
|
+
});
|
|
219
|
+
promise[webpackExports] = exports;
|
|
220
|
+
promise[webpackQueues] = (fn)=>{
|
|
221
|
+
queue && fn(queue), depQueues.forEach(fn), promise["catch"](function() {});
|
|
222
|
+
};
|
|
223
|
+
module.exports = promise;
|
|
224
|
+
body((deps)=>{
|
|
225
|
+
currentDeps = wrapDeps(deps);
|
|
226
|
+
var fn;
|
|
227
|
+
var getResult = ()=>currentDeps.map((d)=>{
|
|
228
|
+
if (d[webpackError]) throw d[webpackError];
|
|
229
|
+
return d[webpackExports];
|
|
230
|
+
});
|
|
231
|
+
var promise = new Promise((resolve)=>{
|
|
232
|
+
fn = ()=>resolve(getResult);
|
|
233
|
+
fn.r = 0;
|
|
234
|
+
var fnQueue = (q)=>q !== queue && !depQueues.has(q) && (depQueues.add(q), q && !q.d && (fn.r++, q.push(fn)));
|
|
235
|
+
currentDeps.map((dep)=>dep[webpackQueues](fnQueue));
|
|
236
|
+
});
|
|
237
|
+
return fn.r ? promise : getResult();
|
|
238
|
+
}, (err)=>(err ? reject(promise[webpackError] = err) : outerResolve(exports), resolveQueue(queue)));
|
|
239
|
+
queue && queue.d < 0 && (queue.d = 0);
|
|
240
|
+
};
|
|
241
|
+
})();
|
|
242
|
+
(()=>{
|
|
243
|
+
__webpack_require__.d = (exports, definition)=>{
|
|
244
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
245
|
+
enumerable: true,
|
|
246
|
+
get: definition[key]
|
|
247
|
+
});
|
|
248
|
+
};
|
|
249
|
+
})();
|
|
250
|
+
(()=>{
|
|
251
|
+
__webpack_require__.f = {};
|
|
252
|
+
__webpack_require__.e = (chunkId)=>Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key)=>{
|
|
253
|
+
__webpack_require__.f[key](chunkId, promises);
|
|
254
|
+
return promises;
|
|
255
|
+
}, []));
|
|
256
|
+
})();
|
|
257
|
+
(()=>{
|
|
258
|
+
__webpack_require__.hmd = (module)=>{
|
|
259
|
+
module = Object.create(module);
|
|
260
|
+
if (!module.children) module.children = [];
|
|
261
|
+
Object.defineProperty(module, 'exports', {
|
|
262
|
+
enumerable: true,
|
|
263
|
+
set: ()=>{
|
|
264
|
+
throw new Error('ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: ' + module.id);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
return module;
|
|
268
|
+
};
|
|
269
|
+
})();
|
|
270
|
+
(()=>{
|
|
271
|
+
__webpack_require__.u = (chunkId)=>"legacy-wasm-chunk.js";
|
|
272
|
+
})();
|
|
273
|
+
(()=>{
|
|
274
|
+
__webpack_require__.g = (()=>{
|
|
275
|
+
if ('object' == typeof globalThis) return globalThis;
|
|
276
|
+
try {
|
|
277
|
+
return this || new Function('return this')();
|
|
278
|
+
} catch (e) {
|
|
279
|
+
if ('object' == typeof window) return window;
|
|
280
|
+
}
|
|
281
|
+
})();
|
|
282
|
+
})();
|
|
283
|
+
(()=>{
|
|
284
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
285
|
+
})();
|
|
286
|
+
(()=>{
|
|
287
|
+
__webpack_require__.r = (exports)=>{
|
|
288
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports, Symbol.toStringTag, {
|
|
289
|
+
value: 'Module'
|
|
290
|
+
});
|
|
291
|
+
Object.defineProperty(exports, '__esModule', {
|
|
292
|
+
value: true
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
})();
|
|
296
|
+
(()=>{
|
|
297
|
+
__webpack_require__.v = function(exports, wasmModuleId, wasmModuleHash, importsObj) {
|
|
298
|
+
return Promise.all([
|
|
299
|
+
import('fs'),
|
|
300
|
+
import('url')
|
|
301
|
+
]).then(([{ readFile }, { URL }])=>new Promise((resolve, reject)=>{
|
|
302
|
+
readFile(new URL("static/wasm/" + wasmModuleHash + ".module.wasm", import.meta.url), (err, buffer)=>{
|
|
303
|
+
if (err) return reject(err);
|
|
304
|
+
resolve({
|
|
305
|
+
arrayBuffer () {
|
|
306
|
+
return buffer;
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
})).then(function(x) {
|
|
311
|
+
return x.arrayBuffer();
|
|
312
|
+
}).then(function(bytes) {
|
|
313
|
+
return WebAssembly.instantiate(bytes, importsObj);
|
|
314
|
+
}).then(function(res) {
|
|
315
|
+
return Object.assign(exports, res.instance.exports);
|
|
316
|
+
});
|
|
317
|
+
};
|
|
318
|
+
})();
|
|
319
|
+
(()=>{
|
|
320
|
+
var scriptUrl;
|
|
321
|
+
if ("string" == typeof import.meta.url) scriptUrl = import.meta.url;
|
|
322
|
+
if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
|
|
323
|
+
scriptUrl = scriptUrl.replace(/^blob:/, "").replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
|
|
324
|
+
__webpack_require__.p = scriptUrl;
|
|
325
|
+
})();
|
|
326
|
+
(()=>{
|
|
327
|
+
var installedChunks = {
|
|
328
|
+
980: 0
|
|
329
|
+
};
|
|
330
|
+
var installChunk = (data)=>{
|
|
331
|
+
var __webpack_ids__ = data.__webpack_ids__;
|
|
332
|
+
var __webpack_modules__ = data.__webpack_modules__;
|
|
333
|
+
var __webpack_runtime__ = data.__webpack_runtime__;
|
|
334
|
+
var moduleId, chunkId, i = 0;
|
|
335
|
+
for(moduleId in __webpack_modules__)if (__webpack_require__.o(__webpack_modules__, moduleId)) __webpack_require__.m[moduleId] = __webpack_modules__[moduleId];
|
|
336
|
+
if (__webpack_runtime__) __webpack_runtime__(__webpack_require__);
|
|
337
|
+
for(; i < __webpack_ids__.length; i++){
|
|
338
|
+
chunkId = __webpack_ids__[i];
|
|
339
|
+
if (__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) installedChunks[chunkId][0]();
|
|
340
|
+
installedChunks[__webpack_ids__[i]] = 0;
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
__webpack_require__.f.j = function(chunkId, promises) {
|
|
344
|
+
var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : void 0;
|
|
345
|
+
if (0 !== installedChunkData) if (installedChunkData) promises.push(installedChunkData[1]);
|
|
346
|
+
else {
|
|
347
|
+
var promise = import("./" + __webpack_require__.u(chunkId)).then(installChunk, (e)=>{
|
|
348
|
+
if (0 !== installedChunks[chunkId]) installedChunks[chunkId] = void 0;
|
|
349
|
+
throw e;
|
|
350
|
+
});
|
|
351
|
+
var promise = Promise.race([
|
|
352
|
+
promise,
|
|
353
|
+
new Promise((resolve)=>{
|
|
354
|
+
installedChunkData = installedChunks[chunkId] = [
|
|
355
|
+
resolve
|
|
356
|
+
];
|
|
357
|
+
})
|
|
358
|
+
]);
|
|
359
|
+
promises.push(installedChunkData[1] = promise);
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
})();
|
|
363
|
+
const lynxUniqueIdAttribute = 'l-uid';
|
|
364
|
+
const cssIdAttribute = 'l-css-id';
|
|
365
|
+
const componentIdAttribute = 'l-comp-id';
|
|
366
|
+
const parentComponentUniqueIdAttribute = 'l-p-comp-uid';
|
|
367
|
+
const lynxTagAttribute = 'lynx-tag';
|
|
368
|
+
const lynxDatasetAttribute = 'l-dset';
|
|
369
|
+
const lynxComponentConfigAttribute = 'l-comp-cfg';
|
|
370
|
+
const lynxDisposedAttribute = 'l-disposed';
|
|
371
|
+
const lynxElementTemplateMarkerAttribute = 'l-template';
|
|
372
|
+
const lynxPartIdAttribute = 'l-part';
|
|
373
|
+
const lynxDefaultDisplayLinearAttribute = 'lynx-default-display-linear';
|
|
374
|
+
const __lynx_timing_flag = '__lynx_timing_flag';
|
|
375
|
+
const globalMuteableVars = [
|
|
376
|
+
'registerDataProcessor',
|
|
377
|
+
'registerWorkletInternal',
|
|
378
|
+
'lynxWorkletImpl',
|
|
379
|
+
'runWorklet'
|
|
380
|
+
];
|
|
381
|
+
const systemInfo = {
|
|
382
|
+
platform: 'web',
|
|
383
|
+
lynxSdkVersion: '3.0'
|
|
384
|
+
};
|
|
385
|
+
const inShadowRootStyles = [
|
|
386
|
+
` [lynx-default-display-linear="false"] * {
|
|
387
|
+
--lynx-display: flex;
|
|
388
|
+
--lynx-display-toggle: var(--lynx-display-flex);
|
|
389
|
+
}`,
|
|
390
|
+
`[lynx-default-overflow-visible="true"] x-view{
|
|
391
|
+
overflow: visible;
|
|
392
|
+
}`
|
|
393
|
+
];
|
|
394
|
+
const W3cEventNameToLynx = {
|
|
395
|
+
click: 'tap',
|
|
396
|
+
lynxscroll: 'scroll',
|
|
397
|
+
lynxscrollend: 'scrollend',
|
|
398
|
+
overlaytouch: 'touch',
|
|
399
|
+
lynxfocus: 'focus',
|
|
400
|
+
lynxblur: 'blur',
|
|
401
|
+
lynxinput: 'input'
|
|
402
|
+
};
|
|
403
|
+
const LynxEventNameToW3cByTagName = {
|
|
404
|
+
'X-INPUT': {
|
|
405
|
+
blur: 'lynxblur',
|
|
406
|
+
focus: 'lynxfocus',
|
|
407
|
+
input: 'lynxinput'
|
|
408
|
+
},
|
|
409
|
+
'X-TEXTAREA': {
|
|
410
|
+
blur: 'lynxblur',
|
|
411
|
+
focus: 'lynxfocus',
|
|
412
|
+
input: 'lynxinput'
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
const LynxEventNameToW3cCommon = {
|
|
416
|
+
tap: 'click',
|
|
417
|
+
scroll: 'lynxscroll',
|
|
418
|
+
scrollend: 'lynxscrollend',
|
|
419
|
+
touch: 'overlaytouch'
|
|
420
|
+
};
|
|
421
|
+
class Rpc {
|
|
422
|
+
port;
|
|
423
|
+
name;
|
|
424
|
+
incId = 0;
|
|
425
|
+
#messageCache = {};
|
|
426
|
+
#textEncoder = new TextEncoder();
|
|
427
|
+
#textDecoder = new TextDecoder();
|
|
428
|
+
#handlerMap = new Map();
|
|
429
|
+
constructor(port, name){
|
|
430
|
+
this.port = port;
|
|
431
|
+
this.name = name;
|
|
432
|
+
port.onmessage = (ev)=>this.#onMessage(ev.data);
|
|
433
|
+
}
|
|
434
|
+
get nextRetId() {
|
|
435
|
+
return `ret_${this.name}_${this.incId++}`;
|
|
436
|
+
}
|
|
437
|
+
static createRetEndpoint(retId) {
|
|
438
|
+
return {
|
|
439
|
+
name: retId,
|
|
440
|
+
hasReturn: false,
|
|
441
|
+
isSync: false
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
#onMessage = async (message)=>{
|
|
445
|
+
const handler1 = this.#handlerMap.get(message.name);
|
|
446
|
+
if (handler1) {
|
|
447
|
+
const lockViewer = message.sync ? new Int32Array(message.lock) : void 0;
|
|
448
|
+
const replyTempEndpoint = !message.sync && message.retId ? Rpc.createRetEndpoint(message.retId) : void 0;
|
|
449
|
+
try {
|
|
450
|
+
const result = await handler1(...message.data);
|
|
451
|
+
let retData, transfer = [];
|
|
452
|
+
if (message.sync) retData = result;
|
|
453
|
+
else if (message.hasTransfer) ({ data: retData, transfer } = result || {});
|
|
454
|
+
else retData = result;
|
|
455
|
+
if (message.sync) {
|
|
456
|
+
if (message.buf) {
|
|
457
|
+
const retStr = JSON.stringify(retData);
|
|
458
|
+
const lengthViewer = new Uint32Array(message.buf, 0, 1);
|
|
459
|
+
const bufViewer = new Uint8Array(message.buf, 4);
|
|
460
|
+
const retCache = new Uint8Array(message.buf.byteLength - 4);
|
|
461
|
+
const { written: byteLength } = this.#textEncoder.encodeInto(retStr, retCache);
|
|
462
|
+
lengthViewer[0] = byteLength;
|
|
463
|
+
bufViewer.set(retCache, 0);
|
|
464
|
+
}
|
|
465
|
+
Atomics.store(lockViewer, 0, 1);
|
|
466
|
+
Atomics.notify(lockViewer, 0);
|
|
467
|
+
} else if (message.retId) this.invoke(replyTempEndpoint, [
|
|
468
|
+
retData,
|
|
469
|
+
false
|
|
470
|
+
], transfer || []);
|
|
471
|
+
} catch (e) {
|
|
472
|
+
console.error(e);
|
|
473
|
+
if (message.sync) {
|
|
474
|
+
Atomics.store(lockViewer, 0, 2);
|
|
475
|
+
Atomics.notify(lockViewer, 0);
|
|
476
|
+
lockViewer[1] = 2;
|
|
477
|
+
} else this.invoke(replyTempEndpoint, [
|
|
478
|
+
void 0,
|
|
479
|
+
true
|
|
480
|
+
]);
|
|
481
|
+
}
|
|
482
|
+
} else {
|
|
483
|
+
const cache = this.#messageCache[message.name];
|
|
484
|
+
if (cache) cache.push(message);
|
|
485
|
+
else this.#messageCache[message.name] = [
|
|
486
|
+
message
|
|
487
|
+
];
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
createCall(endpoint) {
|
|
491
|
+
return (...args)=>this.invoke(endpoint, args);
|
|
492
|
+
}
|
|
493
|
+
registerHandler(endpoint, handler1) {
|
|
494
|
+
this.#handlerMap.set(endpoint.name, handler1);
|
|
495
|
+
const currentCache = this.#messageCache[endpoint.name];
|
|
496
|
+
if (currentCache?.length) {
|
|
497
|
+
this.#messageCache[endpoint.name] = void 0;
|
|
498
|
+
for (const message of currentCache)this.#onMessage(message);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
registerHandlerRef(endpoint, target, propertyName) {
|
|
502
|
+
this.registerHandler(endpoint, (...args)=>target[propertyName]?.call(target, ...args));
|
|
503
|
+
}
|
|
504
|
+
registerHandlerLazy(endpoint, target, propertyName) {
|
|
505
|
+
if (target[propertyName]) this.registerHandlerRef(endpoint, target, propertyName);
|
|
506
|
+
else {
|
|
507
|
+
let property;
|
|
508
|
+
const rpc = this;
|
|
509
|
+
Object.defineProperty(target, propertyName, {
|
|
510
|
+
get () {
|
|
511
|
+
return property;
|
|
512
|
+
},
|
|
513
|
+
set (v) {
|
|
514
|
+
property = v;
|
|
515
|
+
if (v) rpc.registerHandlerRef(endpoint, target, propertyName);
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
removeHandler(rpc) {
|
|
521
|
+
this.#handlerMap.delete(rpc.name);
|
|
522
|
+
}
|
|
523
|
+
invoke(endpoint, parameters, transfer = []) {
|
|
524
|
+
if (endpoint.isSync) {
|
|
525
|
+
const sharedBuffer = endpoint.bufferSize ? new SharedArrayBuffer(endpoint.bufferSize + 4) : void 0;
|
|
526
|
+
const lock = new SharedArrayBuffer(4);
|
|
527
|
+
const lockViewer = new Int32Array(lock);
|
|
528
|
+
lockViewer[0] = 0;
|
|
529
|
+
const message = {
|
|
530
|
+
name: endpoint.name,
|
|
531
|
+
data: parameters,
|
|
532
|
+
sync: true,
|
|
533
|
+
lock: lock,
|
|
534
|
+
buf: sharedBuffer
|
|
535
|
+
};
|
|
536
|
+
this.port.postMessage(message, {
|
|
537
|
+
transfer
|
|
538
|
+
});
|
|
539
|
+
Atomics.wait(lockViewer, 0, 0);
|
|
540
|
+
if (2 === lockViewer[0]) throw null;
|
|
541
|
+
if (!sharedBuffer) return;
|
|
542
|
+
{
|
|
543
|
+
const byteLength = new Uint32Array(sharedBuffer, 0, 4)[0];
|
|
544
|
+
const sharedBufferView = new Uint8Array(sharedBuffer, 4, byteLength);
|
|
545
|
+
const localBuf = new Uint8Array(byteLength);
|
|
546
|
+
localBuf.set(sharedBufferView, 0);
|
|
547
|
+
const ret = localBuf ? JSON.parse(this.#textDecoder.decode(localBuf)) : void 0;
|
|
548
|
+
return ret;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
if (endpoint.hasReturn) {
|
|
552
|
+
const { promise, resolve, reject } = Promise.withResolvers();
|
|
553
|
+
const retHandler = Rpc.createRetEndpoint(this.nextRetId);
|
|
554
|
+
this.registerHandler(retHandler, (returnValue, error)=>{
|
|
555
|
+
if (error) reject();
|
|
556
|
+
resolve(returnValue);
|
|
557
|
+
});
|
|
558
|
+
const message = {
|
|
559
|
+
name: endpoint.name,
|
|
560
|
+
data: parameters,
|
|
561
|
+
sync: false,
|
|
562
|
+
retId: retHandler?.name,
|
|
563
|
+
hasTransfer: endpoint.hasReturnTransfer
|
|
564
|
+
};
|
|
565
|
+
this.port.postMessage(message, {
|
|
566
|
+
transfer
|
|
567
|
+
});
|
|
568
|
+
return promise;
|
|
569
|
+
}
|
|
570
|
+
{
|
|
571
|
+
const message = {
|
|
572
|
+
name: endpoint.name,
|
|
573
|
+
data: parameters,
|
|
574
|
+
sync: false
|
|
575
|
+
};
|
|
576
|
+
this.port.postMessage(message, {
|
|
577
|
+
transfer
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
createCallbackify(endpoint, callbackAt) {
|
|
582
|
+
const call = this.createCall(endpoint);
|
|
583
|
+
return (...params)=>{
|
|
584
|
+
const callback = params.at(callbackAt);
|
|
585
|
+
params.splice(callbackAt, 1);
|
|
586
|
+
call(...params).then(callback);
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
function createRpcEndpoint(name, isSync, hasReturn = true, hasReturnTransfer = false, bufferSize) {
|
|
591
|
+
return {
|
|
592
|
+
name,
|
|
593
|
+
isSync,
|
|
594
|
+
hasReturn,
|
|
595
|
+
hasReturnTransfer,
|
|
596
|
+
bufferSize
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
const postExposureEndpoint = createRpcEndpoint('__postExposure', false, false);
|
|
600
|
+
const publicComponentEventEndpoint = createRpcEndpoint('publicComponentEvent', false, false);
|
|
601
|
+
const publishEventEndpoint = createRpcEndpoint('publishEvent', false, false);
|
|
602
|
+
createRpcEndpoint('postOffscreenEventEndpoint', false, false);
|
|
603
|
+
const switchExposureServiceEndpoint = createRpcEndpoint('switchExposureServiceEndpoint', false, false);
|
|
604
|
+
createRpcEndpoint('mainThreadStart', false, false);
|
|
605
|
+
createRpcEndpoint('updateData', false, true);
|
|
606
|
+
createRpcEndpoint('sendGlobalEventEndpoint', false, false);
|
|
607
|
+
createRpcEndpoint('dispose', false, true);
|
|
608
|
+
const BackgroundThreadStartEndpoint = createRpcEndpoint('start', false, true);
|
|
609
|
+
createRpcEndpoint('reportError', false, false);
|
|
610
|
+
createRpcEndpoint('flushElementTree', false, true);
|
|
611
|
+
const callLepusMethodEndpoint = createRpcEndpoint('callLepusMethod', false, true);
|
|
612
|
+
createRpcEndpoint('multiThreadExposureChangedEndpoint', false, false);
|
|
613
|
+
createRpcEndpoint('__invokeUIMethod', false, true);
|
|
614
|
+
createRpcEndpoint('__setNativeProps', false, true);
|
|
615
|
+
createRpcEndpoint('nativeModulesCall', false, true);
|
|
616
|
+
createRpcEndpoint('napiModulesCall', false, true, true);
|
|
617
|
+
const getCustomSectionsEndpoint = createRpcEndpoint('getCustomSections', false, true);
|
|
618
|
+
createRpcEndpoint('markTiming', false, false);
|
|
619
|
+
const postTimingFlagsEndpoint = createRpcEndpoint('postTimingFlags', false, false);
|
|
620
|
+
createRpcEndpoint('__triggerComponentEvent', false, false);
|
|
621
|
+
createRpcEndpoint('__selectComponent', false, true);
|
|
622
|
+
createRpcEndpoint('dispatchLynxViewEvent', false, false);
|
|
623
|
+
createRpcEndpoint('dispatchNapiModule', false, false);
|
|
624
|
+
const dispatchCoreContextOnBackgroundEndpoint = createRpcEndpoint('dispatchCoreContextOnBackground', false, false);
|
|
625
|
+
const dispatchJSContextOnMainThreadEndpoint = createRpcEndpoint('dispatchJSContextOnMainThread', false, false);
|
|
626
|
+
createRpcEndpoint('__triggerElementMethod', false, false);
|
|
627
|
+
createRpcEndpoint('updateGlobalProps', false, false);
|
|
628
|
+
createRpcEndpoint('updateI18nResources', false, false);
|
|
629
|
+
createRpcEndpoint('updateI18nResource', false, false);
|
|
630
|
+
const dispatchI18nResourceEndpoint = createRpcEndpoint('dispatchI18nResource', false, false);
|
|
631
|
+
var NativeApp_IdentifierType;
|
|
632
|
+
(function(IdentifierType) {
|
|
633
|
+
IdentifierType[IdentifierType["ID_SELECTOR"] = 0] = "ID_SELECTOR";
|
|
634
|
+
IdentifierType[IdentifierType["REF_ID"] = 1] = "REF_ID";
|
|
635
|
+
IdentifierType[IdentifierType["UNIQUE_ID"] = 2] = "UNIQUE_ID";
|
|
636
|
+
})(NativeApp_IdentifierType || (NativeApp_IdentifierType = {}));
|
|
637
|
+
var NativeApp_ErrorCode;
|
|
638
|
+
(function(ErrorCode) {
|
|
639
|
+
ErrorCode[ErrorCode["SUCCESS"] = 0] = "SUCCESS";
|
|
640
|
+
ErrorCode[ErrorCode["UNKNOWN"] = 1] = "UNKNOWN";
|
|
641
|
+
ErrorCode[ErrorCode["NODE_NOT_FOUND"] = 2] = "NODE_NOT_FOUND";
|
|
642
|
+
ErrorCode[ErrorCode["METHOD_NOT_FOUND"] = 3] = "METHOD_NOT_FOUND";
|
|
643
|
+
ErrorCode[ErrorCode["PARAM_INVALID"] = 4] = "PARAM_INVALID";
|
|
644
|
+
ErrorCode[ErrorCode["SELECTOR_NOT_SUPPORTED"] = 5] = "SELECTOR_NOT_SUPPORTED";
|
|
645
|
+
ErrorCode[ErrorCode["NO_UI_FOR_NODE"] = 6] = "NO_UI_FOR_NODE";
|
|
646
|
+
})(NativeApp_ErrorCode || (NativeApp_ErrorCode = {}));
|
|
647
|
+
var UpdateDataOptions_NativeUpdateDataType;
|
|
648
|
+
(function(NativeUpdateDataType) {
|
|
649
|
+
NativeUpdateDataType[NativeUpdateDataType["UPDATE"] = 0] = "UPDATE";
|
|
650
|
+
NativeUpdateDataType[NativeUpdateDataType["RESET"] = 1] = "RESET";
|
|
651
|
+
})(UpdateDataOptions_NativeUpdateDataType || (UpdateDataOptions_NativeUpdateDataType = {}));
|
|
652
|
+
var UpdateDataOptions_UpdateDataType;
|
|
653
|
+
(function(UpdateDataType) {
|
|
654
|
+
UpdateDataType[UpdateDataType["Unknown"] = 0] = "Unknown";
|
|
655
|
+
UpdateDataType[UpdateDataType["UpdateExplicitByUser"] = 1] = "UpdateExplicitByUser";
|
|
656
|
+
UpdateDataType[UpdateDataType["UpdateByKernelFromCtor"] = 2] = "UpdateByKernelFromCtor";
|
|
657
|
+
UpdateDataType[UpdateDataType["UpdateByKernelFromRender"] = 4] = "UpdateByKernelFromRender";
|
|
658
|
+
UpdateDataType[UpdateDataType["UpdateByKernelFromHydrate"] = 8] = "UpdateByKernelFromHydrate";
|
|
659
|
+
UpdateDataType[UpdateDataType["UpdateByKernelFromGetDerived"] = 16] = "UpdateByKernelFromGetDerived";
|
|
660
|
+
UpdateDataType[UpdateDataType["UpdateByKernelFromConflict"] = 32] = "UpdateByKernelFromConflict";
|
|
661
|
+
UpdateDataType[UpdateDataType["UpdateByKernelFromHMR"] = 64] = "UpdateByKernelFromHMR";
|
|
662
|
+
})(UpdateDataOptions_UpdateDataType || (UpdateDataOptions_UpdateDataType = {}));
|
|
663
|
+
const DispatchEventResult = {
|
|
664
|
+
NotCanceled: 0,
|
|
665
|
+
CanceledByEventHandler: 1,
|
|
666
|
+
CanceledByDefaultEventHandler: 2,
|
|
667
|
+
CanceledBeforeDispatch: 3
|
|
668
|
+
};
|
|
669
|
+
var Element_AnimationOperation;
|
|
670
|
+
(function(AnimationOperation) {
|
|
671
|
+
AnimationOperation[AnimationOperation["START"] = 0] = "START";
|
|
672
|
+
AnimationOperation[AnimationOperation["PLAY"] = 1] = "PLAY";
|
|
673
|
+
AnimationOperation[AnimationOperation["PAUSE"] = 2] = "PAUSE";
|
|
674
|
+
AnimationOperation[AnimationOperation["CANCEL"] = 3] = "CANCEL";
|
|
675
|
+
AnimationOperation[AnimationOperation["FINISH"] = 4] = "FINISH";
|
|
676
|
+
})(Element_AnimationOperation || (Element_AnimationOperation = {}));
|
|
677
|
+
const getCacheI18nResourcesKey = (options)=>`${options.locale}_${options.channel}_${options.fallback_url}`;
|
|
678
|
+
class I18nResources {
|
|
679
|
+
data;
|
|
680
|
+
constructor(data){
|
|
681
|
+
this.data = data;
|
|
682
|
+
}
|
|
683
|
+
setData(data) {
|
|
684
|
+
this.data = data;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
class LynxCrossThreadContext extends EventTarget {
|
|
688
|
+
_config;
|
|
689
|
+
constructor(_config){
|
|
690
|
+
super();
|
|
691
|
+
this._config = _config;
|
|
692
|
+
}
|
|
693
|
+
postMessage(...args) {
|
|
694
|
+
console.error('[lynx-web] postMessage not implemented, args:', ...args);
|
|
695
|
+
}
|
|
696
|
+
dispatchEvent(event) {
|
|
697
|
+
const { rpc, sendEventEndpoint } = this._config;
|
|
698
|
+
rpc.invoke(sendEventEndpoint, [
|
|
699
|
+
event
|
|
700
|
+
]);
|
|
701
|
+
return DispatchEventResult.CanceledBeforeDispatch;
|
|
702
|
+
}
|
|
703
|
+
__start() {
|
|
704
|
+
const { rpc, receiveEventEndpoint } = this._config;
|
|
705
|
+
rpc.registerHandler(receiveEventEndpoint, ({ type, data })=>{
|
|
706
|
+
super.dispatchEvent(new MessageEvent(type, {
|
|
707
|
+
data: data ?? {}
|
|
708
|
+
}));
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
const mainThreadInjectVars = [
|
|
713
|
+
'lynx',
|
|
714
|
+
'globalThis',
|
|
715
|
+
'_ReportError',
|
|
716
|
+
'_SetSourceMapRelease',
|
|
717
|
+
'__AddConfig',
|
|
718
|
+
'__AddDataset',
|
|
719
|
+
'__GetAttributes',
|
|
720
|
+
'__GetComponentID',
|
|
721
|
+
'__GetDataByKey',
|
|
722
|
+
'__GetDataset',
|
|
723
|
+
'__GetElementConfig',
|
|
724
|
+
'__GetElementUniqueID',
|
|
725
|
+
'__GetID',
|
|
726
|
+
'__GetTag',
|
|
727
|
+
'__SetAttribute',
|
|
728
|
+
'__SetConfig',
|
|
729
|
+
'__SetDataset',
|
|
730
|
+
'__SetID',
|
|
731
|
+
'__UpdateComponentID',
|
|
732
|
+
'__GetConfig',
|
|
733
|
+
'__UpdateListCallbacks',
|
|
734
|
+
'__AppendElement',
|
|
735
|
+
'__ElementIsEqual',
|
|
736
|
+
'__FirstElement',
|
|
737
|
+
'__GetChildren',
|
|
738
|
+
'__GetParent',
|
|
739
|
+
'__InsertElementBefore',
|
|
740
|
+
'__LastElement',
|
|
741
|
+
'__NextElement',
|
|
742
|
+
'__RemoveElement',
|
|
743
|
+
'__ReplaceElement',
|
|
744
|
+
'__ReplaceElements',
|
|
745
|
+
'__SwapElement',
|
|
746
|
+
'__CreateComponent',
|
|
747
|
+
'__CreateElement',
|
|
748
|
+
'__CreatePage',
|
|
749
|
+
'__CreateView',
|
|
750
|
+
'__CreateText',
|
|
751
|
+
'__CreateRawText',
|
|
752
|
+
'__CreateImage',
|
|
753
|
+
'__CreateScrollView',
|
|
754
|
+
'__CreateWrapperElement',
|
|
755
|
+
'__CreateList',
|
|
756
|
+
'__AddEvent',
|
|
757
|
+
'__GetEvent',
|
|
758
|
+
'__GetEvents',
|
|
759
|
+
'__SetEvents',
|
|
760
|
+
'__AddClass',
|
|
761
|
+
'__SetClasses',
|
|
762
|
+
'__GetClasses',
|
|
763
|
+
'__AddInlineStyle',
|
|
764
|
+
'__SetInlineStyles',
|
|
765
|
+
'__SetCSSId',
|
|
766
|
+
'__OnLifecycleEvent',
|
|
767
|
+
'__FlushElementTree',
|
|
768
|
+
'__LoadLepusChunk',
|
|
769
|
+
'SystemInfo',
|
|
770
|
+
'_I18nResourceTranslation',
|
|
771
|
+
'_AddEventListener',
|
|
772
|
+
'__GetTemplateParts',
|
|
773
|
+
'__MarkPartElement',
|
|
774
|
+
'__MarkTemplateElement',
|
|
775
|
+
'__GetPageElement',
|
|
776
|
+
'__ElementFromBinary'
|
|
777
|
+
];
|
|
778
|
+
const backgroundInjectVars = [
|
|
779
|
+
'NativeModules',
|
|
780
|
+
'globalThis',
|
|
781
|
+
'lynx',
|
|
782
|
+
'lynxCoreInject',
|
|
783
|
+
'SystemInfo'
|
|
784
|
+
];
|
|
785
|
+
const backgroundInjectWithBind = [
|
|
786
|
+
'Card',
|
|
787
|
+
'Component'
|
|
788
|
+
];
|
|
789
|
+
async function generateJavascriptUrl(obj, injectVars, injectWithBind, muteableVars, createJsModuleUrl, templateName) {
|
|
790
|
+
injectVars = injectVars.concat(muteableVars);
|
|
791
|
+
const generateModuleContent = (content)=>[
|
|
792
|
+
'//# allFunctionsCalledOnLoad\n',
|
|
793
|
+
'globalThis.module.exports = function(lynx_runtime) {',
|
|
794
|
+
'const module= {exports:{}};let exports = module.exports;',
|
|
795
|
+
'var {',
|
|
796
|
+
injectVars.join(','),
|
|
797
|
+
'} = lynx_runtime;',
|
|
798
|
+
...injectWithBind.map((nm)=>`const ${nm} = lynx_runtime.${nm}?.bind(lynx_runtime);`),
|
|
799
|
+
';var globDynamicComponentEntry = \'__Card__\';',
|
|
800
|
+
'var {__globalProps} = lynx;',
|
|
801
|
+
'lynx_runtime._updateVars=()=>{',
|
|
802
|
+
...muteableVars.map((nm)=>`${nm} = lynx_runtime.__lynxGlobalBindingValues.${nm};`),
|
|
803
|
+
'};\n',
|
|
804
|
+
content,
|
|
805
|
+
'\n return module.exports;}'
|
|
806
|
+
].join('');
|
|
807
|
+
const processEntry = templateName ? async ([name, content])=>[
|
|
808
|
+
name,
|
|
809
|
+
await createJsModuleUrl(generateModuleContent(content), `${templateName}-${name.replaceAll('/', '')}.js`)
|
|
810
|
+
] : async ([name, content])=>[
|
|
811
|
+
name,
|
|
812
|
+
await createJsModuleUrl(generateModuleContent(content))
|
|
813
|
+
];
|
|
814
|
+
return Promise.all(Object.entries(obj).filter(([_, content])=>'string' == typeof content).map(processEntry)).then(Object.fromEntries);
|
|
815
|
+
}
|
|
816
|
+
async function generateTemplate(template, createJsModuleUrl, templateName) {
|
|
817
|
+
if (!templateName) return {
|
|
818
|
+
...template,
|
|
819
|
+
lepusCode: await generateJavascriptUrl(template.lepusCode, mainThreadInjectVars, [], globalMuteableVars, createJsModuleUrl),
|
|
820
|
+
manifest: await generateJavascriptUrl(template.manifest, backgroundInjectVars, backgroundInjectWithBind, [], createJsModuleUrl)
|
|
821
|
+
};
|
|
822
|
+
return {
|
|
823
|
+
...template,
|
|
824
|
+
lepusCode: await generateJavascriptUrl(template.lepusCode, mainThreadInjectVars, [], globalMuteableVars, createJsModuleUrl, templateName),
|
|
825
|
+
manifest: await generateJavascriptUrl(template.manifest, backgroundInjectVars, backgroundInjectWithBind, [], createJsModuleUrl, templateName)
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
function registerCallLepusMethodHandler(rpc, runtime) {
|
|
829
|
+
rpc.registerHandler(callLepusMethodEndpoint, (methodName, data)=>{
|
|
830
|
+
runtime[methodName](data);
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
function registerGetCustomSectionHandler(rpc, customSections) {
|
|
834
|
+
rpc.registerHandler(getCustomSectionsEndpoint, (key)=>customSections[key]?.content);
|
|
835
|
+
}
|
|
836
|
+
function createMainThreadLynx(config) {
|
|
837
|
+
return {
|
|
838
|
+
getJSContext () {
|
|
839
|
+
return config.jsContext;
|
|
840
|
+
},
|
|
841
|
+
requestAnimationFrame (cb) {
|
|
842
|
+
return requestAnimationFrame(cb);
|
|
843
|
+
},
|
|
844
|
+
cancelAnimationFrame (handler1) {
|
|
845
|
+
return cancelAnimationFrame(handler1);
|
|
846
|
+
},
|
|
847
|
+
__globalProps: config.globalProps,
|
|
848
|
+
getCustomSectionSync (key) {
|
|
849
|
+
return config.customSections[key]?.content;
|
|
850
|
+
},
|
|
851
|
+
markPipelineTiming: config.callbacks.markTiming
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
const referenceTypes = async ()=>WebAssembly.validate(new Uint8Array([
|
|
855
|
+
0,
|
|
856
|
+
97,
|
|
857
|
+
115,
|
|
858
|
+
109,
|
|
859
|
+
1,
|
|
860
|
+
0,
|
|
861
|
+
0,
|
|
862
|
+
0,
|
|
863
|
+
1,
|
|
864
|
+
4,
|
|
865
|
+
1,
|
|
866
|
+
96,
|
|
867
|
+
0,
|
|
868
|
+
0,
|
|
869
|
+
3,
|
|
870
|
+
2,
|
|
871
|
+
1,
|
|
872
|
+
0,
|
|
873
|
+
10,
|
|
874
|
+
7,
|
|
875
|
+
1,
|
|
876
|
+
5,
|
|
877
|
+
0,
|
|
878
|
+
208,
|
|
879
|
+
112,
|
|
880
|
+
26,
|
|
881
|
+
11
|
|
882
|
+
]));
|
|
883
|
+
let wasm;
|
|
884
|
+
async function initWasm() {
|
|
885
|
+
const supportsReferenceTypes = await referenceTypes();
|
|
886
|
+
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"));
|
|
887
|
+
}
|
|
888
|
+
let HEAPU16;
|
|
889
|
+
const stringToUTF16 = (str)=>{
|
|
890
|
+
const len = str.length;
|
|
891
|
+
const ptr = wasm.malloc(len << 1);
|
|
892
|
+
if (!HEAPU16 || 0 == HEAPU16.byteLength) HEAPU16 = new Uint16Array(wasm.memory.buffer);
|
|
893
|
+
for(let i = 0; i < len; i++)HEAPU16[(ptr >> 1) + i] = str.charCodeAt(i);
|
|
894
|
+
return {
|
|
895
|
+
ptr,
|
|
896
|
+
len
|
|
897
|
+
};
|
|
898
|
+
};
|
|
899
|
+
function transformInlineStyleString(str) {
|
|
900
|
+
const { ptr, len } = stringToUTF16(str);
|
|
901
|
+
try {
|
|
902
|
+
const transformedStyle = wasm.transform_raw_u16_inline_style_ptr(ptr, len) ?? str;
|
|
903
|
+
wasm.free(ptr, len << 1);
|
|
904
|
+
return transformedStyle;
|
|
905
|
+
} catch (e) {
|
|
906
|
+
wasm.free(ptr, len << 1);
|
|
907
|
+
throw e;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
function transformParsedStyles(styles) {
|
|
911
|
+
let childStyle = [];
|
|
912
|
+
let transformedStyle = [];
|
|
913
|
+
for (const [property, value] of styles){
|
|
914
|
+
const { ptr: propertyPtr, len: propertyLen } = stringToUTF16(property);
|
|
915
|
+
const { ptr: valuePtr, len: valueLen } = stringToUTF16(value);
|
|
916
|
+
try {
|
|
917
|
+
const transformedResult = wasm.transform_raw_u16_inline_style_ptr_parsed(propertyPtr, propertyLen, valuePtr, valueLen);
|
|
918
|
+
wasm.free(propertyPtr, propertyLen << 1);
|
|
919
|
+
wasm.free(valuePtr, valueLen << 1);
|
|
920
|
+
if (transformedResult) {
|
|
921
|
+
const [transformedStyleForCurrent, childStyleForCurrent] = transformedResult;
|
|
922
|
+
transformedStyle = transformedStyle.concat(transformedStyleForCurrent);
|
|
923
|
+
if (childStyleForCurrent) childStyle = childStyle.concat(childStyleForCurrent);
|
|
924
|
+
} else transformedStyle.push([
|
|
925
|
+
property,
|
|
926
|
+
value
|
|
927
|
+
]);
|
|
928
|
+
} catch (e) {
|
|
929
|
+
wasm.free(propertyPtr, propertyLen << 1);
|
|
930
|
+
wasm.free(valuePtr, valueLen << 1);
|
|
931
|
+
throw e;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
return {
|
|
935
|
+
childStyle,
|
|
936
|
+
transformedStyle
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
function flattenStyleInfo(styleInfo, enableCSSSelector) {
|
|
940
|
+
function flattenOneStyleInfo(cssId) {
|
|
941
|
+
const oneInfo = styleInfo[cssId];
|
|
942
|
+
const imports = oneInfo?.imports;
|
|
943
|
+
if (oneInfo && imports?.length) {
|
|
944
|
+
for (const im of imports){
|
|
945
|
+
const flatInfo = flattenOneStyleInfo(im);
|
|
946
|
+
if (flatInfo) {
|
|
947
|
+
oneInfo.content.push(...flatInfo.content);
|
|
948
|
+
oneInfo.rules.push(...enableCSSSelector ? flatInfo.rules : flatInfo.rules.map((i)=>({
|
|
949
|
+
...i
|
|
950
|
+
})));
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
oneInfo.imports = void 0;
|
|
954
|
+
}
|
|
955
|
+
return oneInfo;
|
|
956
|
+
}
|
|
957
|
+
Object.keys(styleInfo).map((cssId)=>{
|
|
958
|
+
flattenOneStyleInfo(cssId);
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
function transformToWebCss(styleInfo) {
|
|
962
|
+
for (const cssInfos of Object.values(styleInfo))for (const rule of cssInfos.rules){
|
|
963
|
+
const { sel: selectors, decl: declarations } = rule;
|
|
964
|
+
const { transformedStyle, childStyle } = transformParsedStyles(declarations);
|
|
965
|
+
rule.decl = transformedStyle;
|
|
966
|
+
if (childStyle.length > 0) cssInfos.rules.push({
|
|
967
|
+
sel: selectors.map((selector)=>selector.toSpliced(-2, 1, [
|
|
968
|
+
'>'
|
|
969
|
+
], [
|
|
970
|
+
'*'
|
|
971
|
+
], [], [], [])),
|
|
972
|
+
decl: childStyle
|
|
973
|
+
});
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
function genCssContent(styleInfo, pageConfig) {
|
|
977
|
+
function getExtraSelectors(cssId) {
|
|
978
|
+
let suffix = '';
|
|
979
|
+
if (pageConfig.enableRemoveCSSScope) suffix += `[${lynxTagAttribute}]`;
|
|
980
|
+
else if (void 0 !== cssId) suffix += `[${cssIdAttribute}="${cssId}"]`;
|
|
981
|
+
else suffix += `[${lynxTagAttribute}]`;
|
|
982
|
+
return suffix;
|
|
983
|
+
}
|
|
984
|
+
const finalCssContent = [];
|
|
985
|
+
for (const [cssId, cssInfos] of Object.entries(styleInfo)){
|
|
986
|
+
const suffix = getExtraSelectors(cssId);
|
|
987
|
+
const declarationContent = cssInfos.rules.map((rule)=>{
|
|
988
|
+
const { sel: selectorList, decl: declarations } = rule;
|
|
989
|
+
const selectorString = selectorList.map((selectors)=>selectors.toSpliced(-4, 0, [
|
|
990
|
+
suffix
|
|
991
|
+
]).flat().join('')).join(',');
|
|
992
|
+
const declarationString = declarations.map(([k, v])=>`${k}:${v};`).join('');
|
|
993
|
+
return `${selectorString}{${declarationString}}`;
|
|
994
|
+
}).join('');
|
|
995
|
+
finalCssContent.push(...cssInfos.content, declarationContent);
|
|
996
|
+
}
|
|
997
|
+
return finalCssContent.join('\n');
|
|
998
|
+
}
|
|
999
|
+
function genCssOGInfo(styleInfo) {
|
|
1000
|
+
return Object.fromEntries(Object.entries(styleInfo).map(([cssId, cssInfos])=>{
|
|
1001
|
+
const oneCssOGInfo = {};
|
|
1002
|
+
cssInfos.rules = cssInfos.rules.filter((oneCssInfo)=>{
|
|
1003
|
+
oneCssInfo.sel = oneCssInfo.sel.filter((selectorList)=>{
|
|
1004
|
+
const [classSelectors, pseudoClassSelectors, pseudoElementSelectors, combinator] = selectorList;
|
|
1005
|
+
if (1 === classSelectors.length && '.' === classSelectors[0][0] && 0 === pseudoClassSelectors.length && 0 === pseudoElementSelectors.length && 0 === combinator.length) {
|
|
1006
|
+
const selectorName = classSelectors[0].substring(1);
|
|
1007
|
+
const currentDeclarations = oneCssOGInfo[selectorName];
|
|
1008
|
+
if (currentDeclarations) currentDeclarations.push(...oneCssInfo.decl);
|
|
1009
|
+
else oneCssOGInfo[selectorName] = oneCssInfo.decl;
|
|
1010
|
+
return false;
|
|
1011
|
+
}
|
|
1012
|
+
return true;
|
|
1013
|
+
});
|
|
1014
|
+
return oneCssInfo.sel.length > 0;
|
|
1015
|
+
});
|
|
1016
|
+
return [
|
|
1017
|
+
cssId,
|
|
1018
|
+
oneCssOGInfo
|
|
1019
|
+
];
|
|
1020
|
+
}));
|
|
1021
|
+
}
|
|
1022
|
+
const cacheForCamelize = {};
|
|
1023
|
+
function camelize(str) {
|
|
1024
|
+
if (cacheForCamelize[str]) return cacheForCamelize[str];
|
|
1025
|
+
const result = (str + '').replace(/-\D/g, function(match) {
|
|
1026
|
+
return match.charAt(1).toUpperCase();
|
|
1027
|
+
});
|
|
1028
|
+
cacheForCamelize[str] = result;
|
|
1029
|
+
return result;
|
|
1030
|
+
}
|
|
1031
|
+
let cssPropertyMap_index = 1;
|
|
1032
|
+
const cssPropertyMap = {};
|
|
1033
|
+
const cssPropertyReverseMap = {};
|
|
1034
|
+
const V = (name)=>{
|
|
1035
|
+
const k = cssPropertyMap_index++;
|
|
1036
|
+
const isX = name.startsWith('-x-');
|
|
1037
|
+
cssPropertyMap[k] = {
|
|
1038
|
+
name: camelize(name),
|
|
1039
|
+
dashName: name,
|
|
1040
|
+
isX
|
|
1041
|
+
};
|
|
1042
|
+
cssPropertyReverseMap[name] = k;
|
|
1043
|
+
};
|
|
1044
|
+
V('top');
|
|
1045
|
+
V('left');
|
|
1046
|
+
V('right');
|
|
1047
|
+
V('bottom');
|
|
1048
|
+
V('position');
|
|
1049
|
+
V('box-sizing');
|
|
1050
|
+
V('background-color');
|
|
1051
|
+
V('border-left-color');
|
|
1052
|
+
V('border-right-color');
|
|
1053
|
+
V('border-top-color');
|
|
1054
|
+
V('border-bottom-color');
|
|
1055
|
+
V('border-radius');
|
|
1056
|
+
V('border-top-left-radius');
|
|
1057
|
+
V('border-bottom-left-radius');
|
|
1058
|
+
V('border-top-right-radius');
|
|
1059
|
+
V('border-bottom-right-radius');
|
|
1060
|
+
V('border-width');
|
|
1061
|
+
V('border-left-width');
|
|
1062
|
+
V('border-right-width');
|
|
1063
|
+
V('border-top-width');
|
|
1064
|
+
V('border-bottom-width');
|
|
1065
|
+
V('color');
|
|
1066
|
+
V('opacity');
|
|
1067
|
+
V('display');
|
|
1068
|
+
V('overflow');
|
|
1069
|
+
V('height');
|
|
1070
|
+
V('width');
|
|
1071
|
+
V('max-width');
|
|
1072
|
+
V('min-width');
|
|
1073
|
+
V('max-height');
|
|
1074
|
+
V('min-height');
|
|
1075
|
+
V('padding');
|
|
1076
|
+
V('padding-left');
|
|
1077
|
+
V('padding-right');
|
|
1078
|
+
V('padding-top');
|
|
1079
|
+
V('padding-bottom');
|
|
1080
|
+
V('margin');
|
|
1081
|
+
V('margin-left');
|
|
1082
|
+
V('margin-right');
|
|
1083
|
+
V('margin-top');
|
|
1084
|
+
V('margin-bottom');
|
|
1085
|
+
V('white-space');
|
|
1086
|
+
V('letter-spacing');
|
|
1087
|
+
V('text-align');
|
|
1088
|
+
V('line-height');
|
|
1089
|
+
V('text-overflow');
|
|
1090
|
+
V('font-size');
|
|
1091
|
+
V('font-weight');
|
|
1092
|
+
V('flex');
|
|
1093
|
+
V('flex-grow');
|
|
1094
|
+
V('flex-shrink');
|
|
1095
|
+
V('flex-basis');
|
|
1096
|
+
V('flex-direction');
|
|
1097
|
+
V('flex-wrap');
|
|
1098
|
+
V('align-items');
|
|
1099
|
+
V('align-self');
|
|
1100
|
+
V('align-content');
|
|
1101
|
+
V('justify-content');
|
|
1102
|
+
V('background');
|
|
1103
|
+
V('border-color');
|
|
1104
|
+
V('font-family');
|
|
1105
|
+
V('font-style');
|
|
1106
|
+
V('transform');
|
|
1107
|
+
V('animation');
|
|
1108
|
+
V('animation-name');
|
|
1109
|
+
V('animation-duration');
|
|
1110
|
+
V('animation-timing-function');
|
|
1111
|
+
V('animation-delay');
|
|
1112
|
+
V('animation-iteration-count');
|
|
1113
|
+
V('animation-direction');
|
|
1114
|
+
V('animation-fill-mode');
|
|
1115
|
+
V('animation-play-state');
|
|
1116
|
+
V('line-spacing');
|
|
1117
|
+
V('border-style');
|
|
1118
|
+
V('order');
|
|
1119
|
+
V('box-shadow');
|
|
1120
|
+
V('transform-origin');
|
|
1121
|
+
V('linear-orientation');
|
|
1122
|
+
V('linear-weight-sum');
|
|
1123
|
+
V('linear-weight');
|
|
1124
|
+
V('linear-gravity');
|
|
1125
|
+
V('linear-layout-gravity');
|
|
1126
|
+
V('layout-animation-create-duration');
|
|
1127
|
+
V('layout-animation-create-timing-function');
|
|
1128
|
+
V('layout-animation-create-delay');
|
|
1129
|
+
V('layout-animation-create-property');
|
|
1130
|
+
V('layout-animation-delete-duration');
|
|
1131
|
+
V('layout-animation-delete-timing-function');
|
|
1132
|
+
V('layout-animation-delete-delay');
|
|
1133
|
+
V('layout-animation-delete-property');
|
|
1134
|
+
V('layout-animation-update-duration');
|
|
1135
|
+
V('layout-animation-update-timing-function');
|
|
1136
|
+
V('layout-animation-update-delay');
|
|
1137
|
+
V('adapt-font-size');
|
|
1138
|
+
V('aspect-ratio');
|
|
1139
|
+
V('text-decoration');
|
|
1140
|
+
V('text-shadow');
|
|
1141
|
+
V('background-image');
|
|
1142
|
+
V('background-position');
|
|
1143
|
+
V('background-origin');
|
|
1144
|
+
V('background-repeat');
|
|
1145
|
+
V('background-size');
|
|
1146
|
+
V('border');
|
|
1147
|
+
V('visibility');
|
|
1148
|
+
V('border-right');
|
|
1149
|
+
V('border-left');
|
|
1150
|
+
V('border-top');
|
|
1151
|
+
V('border-bottom');
|
|
1152
|
+
V('transition');
|
|
1153
|
+
V('transition-property');
|
|
1154
|
+
V('transition-duration');
|
|
1155
|
+
V('transition-delay');
|
|
1156
|
+
V('transition-timing-function');
|
|
1157
|
+
V('content');
|
|
1158
|
+
V('border-left-style');
|
|
1159
|
+
V('border-right-style');
|
|
1160
|
+
V('border-top-style');
|
|
1161
|
+
V('border-bottom-style');
|
|
1162
|
+
V('implicit-animation');
|
|
1163
|
+
V('overflow-x');
|
|
1164
|
+
V('overflow-y');
|
|
1165
|
+
V('word-break');
|
|
1166
|
+
V('background-clip');
|
|
1167
|
+
V('outline');
|
|
1168
|
+
V('outline-color');
|
|
1169
|
+
V('outline-style');
|
|
1170
|
+
V('outline-width');
|
|
1171
|
+
V('vertical-align');
|
|
1172
|
+
V('caret-color');
|
|
1173
|
+
V('direction');
|
|
1174
|
+
V('relative-id');
|
|
1175
|
+
V('relative-align-top');
|
|
1176
|
+
V('relative-align-right');
|
|
1177
|
+
V('relative-align-bottom');
|
|
1178
|
+
V('relative-align-left');
|
|
1179
|
+
V('relative-top-of');
|
|
1180
|
+
V('relative-right-of');
|
|
1181
|
+
V('relative-bottom-of');
|
|
1182
|
+
V('relative-left-of');
|
|
1183
|
+
V('relative-layout-once');
|
|
1184
|
+
V('relative-center');
|
|
1185
|
+
V('enter-transition-name');
|
|
1186
|
+
V('exit-transition-name');
|
|
1187
|
+
V('pause-transition-name');
|
|
1188
|
+
V('resume-transition-name');
|
|
1189
|
+
V('flex-flow');
|
|
1190
|
+
V('z-index');
|
|
1191
|
+
V('text-decoration-color');
|
|
1192
|
+
V('linear-cross-gravity');
|
|
1193
|
+
V('margin-inline-start');
|
|
1194
|
+
V('margin-inline-end');
|
|
1195
|
+
V('padding-inline-start');
|
|
1196
|
+
V('padding-inline-end');
|
|
1197
|
+
V('border-inline-start-color');
|
|
1198
|
+
V('border-inline-end-color');
|
|
1199
|
+
V('border-inline-start-width');
|
|
1200
|
+
V('border-inline-end-width');
|
|
1201
|
+
V('border-inline-start-style');
|
|
1202
|
+
V('border-inline-end-style');
|
|
1203
|
+
V('border-start-start-radius');
|
|
1204
|
+
V('border-end-start-radius');
|
|
1205
|
+
V('border-start-end-radius');
|
|
1206
|
+
V('border-end-end-radius');
|
|
1207
|
+
V('relative-align-inline-start');
|
|
1208
|
+
V('relative-align-inline-end');
|
|
1209
|
+
V('relative-inline-start-of');
|
|
1210
|
+
V('relative-inline-end-of');
|
|
1211
|
+
V('inset-inline-start');
|
|
1212
|
+
V('inset-inline-end');
|
|
1213
|
+
V('mask-image');
|
|
1214
|
+
V('grid-template-columns');
|
|
1215
|
+
V('grid-template-rows');
|
|
1216
|
+
V('grid-auto-columns');
|
|
1217
|
+
V('grid-auto-rows');
|
|
1218
|
+
V('grid-column-span');
|
|
1219
|
+
V('grid-row-span');
|
|
1220
|
+
V('grid-column-start');
|
|
1221
|
+
V('grid-column-end');
|
|
1222
|
+
V('grid-row-start');
|
|
1223
|
+
V('grid-row-end');
|
|
1224
|
+
V('grid-column-gap');
|
|
1225
|
+
V('grid-row-gap');
|
|
1226
|
+
V('justify-items');
|
|
1227
|
+
V('justify-self');
|
|
1228
|
+
V('grid-auto-flow');
|
|
1229
|
+
V('filter');
|
|
1230
|
+
V('list-main-axis-gap');
|
|
1231
|
+
V('list-cross-axis-gap');
|
|
1232
|
+
V('linear-direction');
|
|
1233
|
+
V('perspective');
|
|
1234
|
+
V('cursor');
|
|
1235
|
+
V('text-indent');
|
|
1236
|
+
V('clip-path');
|
|
1237
|
+
V('text-stroke');
|
|
1238
|
+
V('text-stroke-width');
|
|
1239
|
+
V('text-stroke-color');
|
|
1240
|
+
V('-x-auto-font-size');
|
|
1241
|
+
V('-x-auto-font-size-preset-sizes');
|
|
1242
|
+
V('mask');
|
|
1243
|
+
V('mask-repeat');
|
|
1244
|
+
V('mask-position');
|
|
1245
|
+
V('mask-clip');
|
|
1246
|
+
V('mask-origin');
|
|
1247
|
+
V('mask-size');
|
|
1248
|
+
V('gap');
|
|
1249
|
+
V('column-gap');
|
|
1250
|
+
V('row-gap');
|
|
1251
|
+
V('image-rendering');
|
|
1252
|
+
V('hyphens');
|
|
1253
|
+
V('-x-app-region');
|
|
1254
|
+
V('-x-animation-color-interpolation');
|
|
1255
|
+
V('-x-handle-color');
|
|
1256
|
+
V('-x-handle-size');
|
|
1257
|
+
V('offset-path');
|
|
1258
|
+
V('offset-distance');
|
|
1259
|
+
function queryCSSProperty(index) {
|
|
1260
|
+
return cssPropertyMap[index];
|
|
1261
|
+
}
|
|
1262
|
+
var uppercasePattern = /[A-Z]/g;
|
|
1263
|
+
var msPattern = /^ms-/;
|
|
1264
|
+
var hyphenate_style_name_cache = {};
|
|
1265
|
+
function toHyphenLower(match) {
|
|
1266
|
+
return '-' + match.toLowerCase();
|
|
1267
|
+
}
|
|
1268
|
+
function hyphenateStyleName(name) {
|
|
1269
|
+
if (hyphenate_style_name_cache.hasOwnProperty(name)) return hyphenate_style_name_cache[name];
|
|
1270
|
+
var hName = name.replace(uppercasePattern, toHyphenLower);
|
|
1271
|
+
return hyphenate_style_name_cache[name] = msPattern.test(hName) ? '-' + hName : hName;
|
|
1272
|
+
}
|
|
1273
|
+
const hyphenate_style_name = hyphenateStyleName;
|
|
1274
|
+
const __AppendElement = /*#__PURE__*/ (parent, child)=>parent.appendChild(child);
|
|
1275
|
+
const __ElementIsEqual = /*#__PURE__*/ (left, right)=>left === right;
|
|
1276
|
+
const __FirstElement = /*#__PURE__*/ (element)=>element.firstElementChild;
|
|
1277
|
+
const __GetChildren = /*#__PURE__*/ (element)=>element.children ? [
|
|
1278
|
+
...element.children
|
|
1279
|
+
] : null;
|
|
1280
|
+
const __GetParent = /*#__PURE__*/ (element)=>element.parentElement;
|
|
1281
|
+
const __InsertElementBefore = /*#__PURE__*/ (parent, child, ref)=>parent.insertBefore(child, ref);
|
|
1282
|
+
const __LastElement = /*#__PURE__*/ (element)=>element.lastElementChild;
|
|
1283
|
+
const __NextElement = /*#__PURE__*/ (element)=>element.nextElementSibling;
|
|
1284
|
+
const __RemoveElement = /*#__PURE__*/ (parent, child)=>parent.removeChild(child);
|
|
1285
|
+
const __ReplaceElement = /*#__PURE__*/ (newElement, oldElement)=>oldElement.replaceWith(newElement);
|
|
1286
|
+
const __ReplaceElements = /*#__PURE__*/ (parent, newChildren, oldChildren)=>{
|
|
1287
|
+
newChildren = Array.isArray(newChildren) ? newChildren : [
|
|
1288
|
+
newChildren
|
|
1289
|
+
];
|
|
1290
|
+
if (!oldChildren || Array.isArray(oldChildren) && oldChildren?.length === 0) parent.append(...newChildren);
|
|
1291
|
+
else {
|
|
1292
|
+
oldChildren = Array.isArray(oldChildren) ? oldChildren : [
|
|
1293
|
+
oldChildren
|
|
1294
|
+
];
|
|
1295
|
+
for(let ii = 1; ii < oldChildren.length; ii++)__RemoveElement(parent, oldChildren[ii]);
|
|
1296
|
+
const firstOldChildren = oldChildren[0];
|
|
1297
|
+
firstOldChildren.replaceWith(...newChildren);
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
1300
|
+
const __AddConfig = /*#__PURE__*/ (element, type, value)=>{
|
|
1301
|
+
const currentComponentConfigString = element.getAttribute(lynxComponentConfigAttribute);
|
|
1302
|
+
let currentComponentConfig = currentComponentConfigString ? JSON.parse(decodeURIComponent(currentComponentConfigString)) : {};
|
|
1303
|
+
currentComponentConfig[type] = value;
|
|
1304
|
+
element.setAttribute(lynxComponentConfigAttribute, encodeURIComponent(JSON.stringify(currentComponentConfig)));
|
|
1305
|
+
};
|
|
1306
|
+
const __AddDataset = /*#__PURE__*/ (element, key, value)=>{
|
|
1307
|
+
const currentDataset = __GetDataset(element);
|
|
1308
|
+
currentDataset[key] = value;
|
|
1309
|
+
element.setAttribute(lynxDatasetAttribute, encodeURIComponent(JSON.stringify(currentDataset)));
|
|
1310
|
+
value ? element.setAttribute('data-' + key, value.toString()) : element.removeAttribute('data-' + key);
|
|
1311
|
+
};
|
|
1312
|
+
const __GetDataset = /*#__PURE__*/ (element)=>{
|
|
1313
|
+
const datasetString = element.getAttribute(lynxDatasetAttribute);
|
|
1314
|
+
const currentDataset = datasetString ? JSON.parse(decodeURIComponent(datasetString)) : {};
|
|
1315
|
+
return currentDataset;
|
|
1316
|
+
};
|
|
1317
|
+
const __GetDataByKey = /*#__PURE__*/ (element, key)=>{
|
|
1318
|
+
const dataset = __GetDataset(element);
|
|
1319
|
+
return dataset[key];
|
|
1320
|
+
};
|
|
1321
|
+
const __GetAttributes = /*#__PURE__*/ (element)=>Object.fromEntries(element.getAttributeNames().map((attributeName)=>[
|
|
1322
|
+
attributeName,
|
|
1323
|
+
element.getAttribute(attributeName)
|
|
1324
|
+
]).filter(([, value])=>value));
|
|
1325
|
+
const __GetComponentID = /*#__PURE__*/ (element)=>element.getAttribute(componentIdAttribute);
|
|
1326
|
+
const __GetElementConfig = /*#__PURE__*/ (element)=>{
|
|
1327
|
+
const currentComponentConfigString = element.getAttribute(lynxComponentConfigAttribute);
|
|
1328
|
+
return currentComponentConfigString ? JSON.parse(decodeURIComponent(currentComponentConfigString)) : {};
|
|
1329
|
+
};
|
|
1330
|
+
const __GetElementUniqueID = /*#__PURE__*/ (element)=>element && element.getAttribute ? Number(element.getAttribute(lynxUniqueIdAttribute)) : -1;
|
|
1331
|
+
const __GetID = /*#__PURE__*/ (element)=>element.getAttribute('id');
|
|
1332
|
+
const __SetID = /*#__PURE__*/ (element, id)=>id ? element.setAttribute('id', id) : element.removeAttribute('id');
|
|
1333
|
+
const __GetTag = /*#__PURE__*/ (element)=>element.getAttribute(lynxTagAttribute);
|
|
1334
|
+
const __SetConfig = /*#__PURE__*/ (element, config)=>{
|
|
1335
|
+
element.setAttribute(lynxComponentConfigAttribute, encodeURIComponent(JSON.stringify(config)));
|
|
1336
|
+
};
|
|
1337
|
+
const __SetDataset = /*#__PURE__*/ (element, dataset)=>{
|
|
1338
|
+
element.setAttribute(lynxDatasetAttribute, encodeURIComponent(JSON.stringify(dataset)));
|
|
1339
|
+
for (const [key, value] of Object.entries(dataset))element.setAttribute('data-' + key, value.toString());
|
|
1340
|
+
};
|
|
1341
|
+
const __UpdateComponentID = /*#__PURE__*/ (element, componentID)=>element.setAttribute(componentIdAttribute, componentID);
|
|
1342
|
+
const __GetClasses = /*#__PURE__*/ (element)=>(element.getAttribute('class') ?? '').split(' ').filter((e)=>e);
|
|
1343
|
+
const __SetCSSId = /*#__PURE__*/ (elements, cssId)=>{
|
|
1344
|
+
for (const element of elements)element.setAttribute(cssIdAttribute, cssId + '');
|
|
1345
|
+
};
|
|
1346
|
+
const __SetClasses = /*#__PURE__*/ (element, classname)=>{
|
|
1347
|
+
classname ? element.setAttribute('class', classname) : element.removeAttribute('class');
|
|
1348
|
+
};
|
|
1349
|
+
const __AddInlineStyle = /*#__PURE__*/ (element, key, value)=>{
|
|
1350
|
+
let dashName;
|
|
1351
|
+
if ('number' == typeof key) {
|
|
1352
|
+
const queryResult = queryCSSProperty(key);
|
|
1353
|
+
dashName = queryResult.dashName;
|
|
1354
|
+
if (queryResult.isX) console.error(`[lynx-web] css property: ${dashName} is not supported.`);
|
|
1355
|
+
} else dashName = key;
|
|
1356
|
+
const valueStr = 'number' == typeof value ? value.toString() : value;
|
|
1357
|
+
if (valueStr) {
|
|
1358
|
+
const { transformedStyle } = transformParsedStyles([
|
|
1359
|
+
[
|
|
1360
|
+
dashName,
|
|
1361
|
+
valueStr
|
|
1362
|
+
]
|
|
1363
|
+
]);
|
|
1364
|
+
for (const [property, value] of transformedStyle)element.style.setProperty(property, value);
|
|
1365
|
+
} else element.style.removeProperty(dashName);
|
|
1366
|
+
};
|
|
1367
|
+
const __AddClass = /*#__PURE__*/ (element, className)=>{
|
|
1368
|
+
const newClassName = ((element.getAttribute('class') ?? '') + ' ' + className).trim();
|
|
1369
|
+
element.setAttribute('class', newClassName);
|
|
1370
|
+
};
|
|
1371
|
+
const __SetInlineStyles = /*#__PURE__*/ (element, value)=>{
|
|
1372
|
+
if (!value) return;
|
|
1373
|
+
if ('string' == typeof value) element.setAttribute('style', transformInlineStyleString(value));
|
|
1374
|
+
else {
|
|
1375
|
+
const { transformedStyle } = transformParsedStyles(Object.entries(value).map(([k, value])=>[
|
|
1376
|
+
hyphenate_style_name(k),
|
|
1377
|
+
value?.toString?.() ?? ''
|
|
1378
|
+
]));
|
|
1379
|
+
const transformedStyleStr = transformedStyle.map(([property, value])=>`${property}:${value};`).join('');
|
|
1380
|
+
element.setAttribute('style', transformedStyleStr);
|
|
1381
|
+
}
|
|
1382
|
+
};
|
|
1383
|
+
const __GetTemplateParts = (templateElement)=>{
|
|
1384
|
+
const isTemplate = null !== templateElement.getAttribute(lynxElementTemplateMarkerAttribute);
|
|
1385
|
+
if (!isTemplate) return {};
|
|
1386
|
+
const templateUniqueId = __GetElementUniqueID(templateElement);
|
|
1387
|
+
const parts = {};
|
|
1388
|
+
const partElements = templateElement.querySelectorAll(`[${lynxUniqueIdAttribute}="${templateUniqueId}"] [${lynxPartIdAttribute}]:not([${lynxUniqueIdAttribute}="${templateUniqueId}"] [${lynxElementTemplateMarkerAttribute}] [${lynxPartIdAttribute}])`);
|
|
1389
|
+
for (const partElement of partElements){
|
|
1390
|
+
const partId = partElement.getAttribute(lynxPartIdAttribute);
|
|
1391
|
+
if (partId) parts[partId] = partElement;
|
|
1392
|
+
}
|
|
1393
|
+
return parts;
|
|
1394
|
+
};
|
|
1395
|
+
const __MarkTemplateElement = (element)=>{
|
|
1396
|
+
element.setAttribute(lynxElementTemplateMarkerAttribute, '');
|
|
1397
|
+
};
|
|
1398
|
+
const __MarkPartElement = (element, partId)=>{
|
|
1399
|
+
element.setAttribute(lynxPartIdAttribute, partId);
|
|
1400
|
+
};
|
|
1401
|
+
function toCloneableObject(obj) {
|
|
1402
|
+
const cloneableObj = {};
|
|
1403
|
+
for(const key in obj){
|
|
1404
|
+
const value = obj[key];
|
|
1405
|
+
if ('boolean' == typeof value || 'number' == typeof value || 'string' == typeof value || null === value) cloneableObj[key] = value;
|
|
1406
|
+
}
|
|
1407
|
+
return cloneableObj;
|
|
1408
|
+
}
|
|
1409
|
+
function createCrossThreadEvent(domEvent, eventName) {
|
|
1410
|
+
const targetElement = domEvent.target;
|
|
1411
|
+
const currentTargetElement = domEvent.currentTarget.getAttribute ? domEvent.currentTarget : void 0;
|
|
1412
|
+
const type = domEvent.type;
|
|
1413
|
+
const params = {};
|
|
1414
|
+
const isTrusted = domEvent.isTrusted;
|
|
1415
|
+
const otherProperties = {};
|
|
1416
|
+
if (type.match(/^transition/)) Object.assign(params, {
|
|
1417
|
+
animation_type: 'keyframe-animation',
|
|
1418
|
+
animation_name: domEvent.propertyName,
|
|
1419
|
+
new_animator: true
|
|
1420
|
+
});
|
|
1421
|
+
else if (type.match(/animation/)) Object.assign(params, {
|
|
1422
|
+
animation_type: 'keyframe-animation',
|
|
1423
|
+
animation_name: domEvent.animationName,
|
|
1424
|
+
new_animator: true
|
|
1425
|
+
});
|
|
1426
|
+
else if (type.startsWith('touch')) {
|
|
1427
|
+
const touchEvent = domEvent;
|
|
1428
|
+
const touch = [
|
|
1429
|
+
...touchEvent.touches
|
|
1430
|
+
];
|
|
1431
|
+
const targetTouches = [
|
|
1432
|
+
...touchEvent.targetTouches
|
|
1433
|
+
];
|
|
1434
|
+
const changedTouches = [
|
|
1435
|
+
...touchEvent.changedTouches
|
|
1436
|
+
];
|
|
1437
|
+
Object.assign(otherProperties, {
|
|
1438
|
+
touches: isTrusted ? touch.map(toCloneableObject) : touch,
|
|
1439
|
+
targetTouches: isTrusted ? targetTouches.map(toCloneableObject) : targetTouches,
|
|
1440
|
+
changedTouches: isTrusted ? changedTouches.map(toCloneableObject) : changedTouches
|
|
1441
|
+
});
|
|
1442
|
+
}
|
|
1443
|
+
const currentTargetDatasetString = currentTargetElement?.getAttribute(lynxDatasetAttribute);
|
|
1444
|
+
const currentTargetDataset = currentTargetDatasetString ? JSON.parse(decodeURIComponent(currentTargetDatasetString)) : {};
|
|
1445
|
+
const targetDatasetString = targetElement.getAttribute(lynxDatasetAttribute);
|
|
1446
|
+
const targetDataset = targetDatasetString ? JSON.parse(decodeURIComponent(targetDatasetString)) : {};
|
|
1447
|
+
return {
|
|
1448
|
+
type: eventName,
|
|
1449
|
+
timestamp: domEvent.timeStamp,
|
|
1450
|
+
target: {
|
|
1451
|
+
id: targetElement.getAttribute('id'),
|
|
1452
|
+
dataset: targetDataset,
|
|
1453
|
+
uniqueId: Number(targetElement.getAttribute(lynxUniqueIdAttribute))
|
|
1454
|
+
},
|
|
1455
|
+
currentTarget: currentTargetElement ? {
|
|
1456
|
+
id: currentTargetElement.getAttribute('id'),
|
|
1457
|
+
dataset: currentTargetDataset,
|
|
1458
|
+
uniqueId: Number(currentTargetElement.getAttribute(lynxUniqueIdAttribute))
|
|
1459
|
+
} : null,
|
|
1460
|
+
detail: domEvent.detail ?? {},
|
|
1461
|
+
params,
|
|
1462
|
+
...otherProperties
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
function decodeCssOG(classes, styleInfo, cssId) {
|
|
1466
|
+
const classList = classes.split(' ').filter((e)=>e);
|
|
1467
|
+
let declarations = [];
|
|
1468
|
+
const currentStyleInfo = styleInfo[cssId ?? '0'];
|
|
1469
|
+
if (currentStyleInfo) for (const oneClassName of classList){
|
|
1470
|
+
const oneRule = currentStyleInfo[oneClassName];
|
|
1471
|
+
if (oneRule) declarations.push(...oneRule);
|
|
1472
|
+
}
|
|
1473
|
+
else console.warn(`[lynx-web] cannot find styleinfo for cssid ${cssId}`);
|
|
1474
|
+
return declarations.map(([property, value])=>`${property}:${value};`).join('');
|
|
1475
|
+
}
|
|
1476
|
+
const exposureRelatedAttributes = new Set([
|
|
1477
|
+
'exposure-id',
|
|
1478
|
+
'exposure-area',
|
|
1479
|
+
'exposure-screen-margin-top',
|
|
1480
|
+
'exposure-screen-margin-right',
|
|
1481
|
+
'exposure-screen-margin-bottom',
|
|
1482
|
+
'exposure-screen-margin-left',
|
|
1483
|
+
'exposure-ui-margin-top',
|
|
1484
|
+
'exposure-ui-margin-right',
|
|
1485
|
+
'exposure-ui-margin-bottom',
|
|
1486
|
+
'exposure-ui-margin-left'
|
|
1487
|
+
]);
|
|
1488
|
+
function createMainThreadGlobalThis(config) {
|
|
1489
|
+
let timingFlags = [];
|
|
1490
|
+
let renderPage;
|
|
1491
|
+
const { callbacks, tagMap, pageConfig, lepusCode, rootDom, globalProps, styleInfo, ssrHydrateInfo, ssrHooks } = config;
|
|
1492
|
+
const lynxUniqueIdToElement = ssrHydrateInfo?.lynxUniqueIdToElement ?? [];
|
|
1493
|
+
const lynxUniqueIdToStyleRulesIndex = ssrHydrateInfo?.lynxUniqueIdToStyleRulesIndex ?? [];
|
|
1494
|
+
const elementToRuntimeInfoMap = new WeakMap();
|
|
1495
|
+
let pageElement = lynxUniqueIdToElement[1]?.deref();
|
|
1496
|
+
let uniqueIdInc = lynxUniqueIdToElement.length || 1;
|
|
1497
|
+
const varsUpdateHandlers = [];
|
|
1498
|
+
const lynxGlobalBindingValues = {};
|
|
1499
|
+
const exposureChangedElements = new Set();
|
|
1500
|
+
flattenStyleInfo(styleInfo, pageConfig.enableCSSSelector);
|
|
1501
|
+
transformToWebCss(styleInfo);
|
|
1502
|
+
const cssOGInfo = pageConfig.enableCSSSelector ? {} : genCssOGInfo(styleInfo);
|
|
1503
|
+
let cardStyleElement;
|
|
1504
|
+
if (ssrHydrateInfo?.cardStyleElement) cardStyleElement = ssrHydrateInfo.cardStyleElement;
|
|
1505
|
+
else {
|
|
1506
|
+
cardStyleElement = callbacks.createElement('style');
|
|
1507
|
+
cardStyleElement.innerHTML = genCssContent(styleInfo, pageConfig);
|
|
1508
|
+
rootDom.append(cardStyleElement);
|
|
1509
|
+
}
|
|
1510
|
+
const cardStyleElementSheet = cardStyleElement.sheet;
|
|
1511
|
+
const updateCssOGStyle = (uniqueId, newStyles)=>{
|
|
1512
|
+
if (void 0 !== lynxUniqueIdToStyleRulesIndex[uniqueId]) {
|
|
1513
|
+
const rule = cardStyleElementSheet.cssRules[lynxUniqueIdToStyleRulesIndex[uniqueId]];
|
|
1514
|
+
rule.style.cssText = newStyles;
|
|
1515
|
+
} else {
|
|
1516
|
+
const index = cardStyleElementSheet.insertRule(`[${lynxUniqueIdAttribute}="${uniqueId}"]{${newStyles}}`, cardStyleElementSheet.cssRules.length);
|
|
1517
|
+
lynxUniqueIdToStyleRulesIndex[uniqueId] = index;
|
|
1518
|
+
}
|
|
6
1519
|
};
|
|
7
|
-
|
|
1520
|
+
const commonHandler = (event)=>{
|
|
1521
|
+
if (!event.currentTarget) return;
|
|
1522
|
+
const currentTarget = event.currentTarget;
|
|
1523
|
+
const isCapture = event.eventPhase === Event.CAPTURING_PHASE;
|
|
1524
|
+
const lynxEventName = W3cEventNameToLynx[event.type] ?? event.type;
|
|
1525
|
+
const runtimeInfo = elementToRuntimeInfoMap.get(currentTarget);
|
|
1526
|
+
if (runtimeInfo) {
|
|
1527
|
+
const hname = isCapture ? runtimeInfo.eventHandlerMap[lynxEventName]?.capture?.handler : runtimeInfo.eventHandlerMap[lynxEventName]?.bind?.handler;
|
|
1528
|
+
const crossThreadEvent = createCrossThreadEvent(event, lynxEventName);
|
|
1529
|
+
if ('string' == typeof hname) {
|
|
1530
|
+
const parentComponentUniqueId = Number(currentTarget.getAttribute(parentComponentUniqueIdAttribute));
|
|
1531
|
+
const parentComponent = lynxUniqueIdToElement[parentComponentUniqueId].deref();
|
|
1532
|
+
const componentId = parentComponent?.getAttribute(lynxTagAttribute) !== 'page' ? parentComponent?.getAttribute(componentIdAttribute) ?? void 0 : void 0;
|
|
1533
|
+
if (componentId) callbacks.publicComponentEvent(componentId, hname, crossThreadEvent);
|
|
1534
|
+
else callbacks.publishEvent(hname, crossThreadEvent);
|
|
1535
|
+
return true;
|
|
1536
|
+
}
|
|
1537
|
+
if (hname) {
|
|
1538
|
+
crossThreadEvent.target.elementRefptr = event.target;
|
|
1539
|
+
if (crossThreadEvent.currentTarget) crossThreadEvent.currentTarget.elementRefptr = event.currentTarget;
|
|
1540
|
+
mtsGlobalThis.runWorklet?.(hname.value, [
|
|
1541
|
+
crossThreadEvent
|
|
1542
|
+
]);
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
return false;
|
|
1546
|
+
};
|
|
1547
|
+
const commonCatchHandler = (event)=>{
|
|
1548
|
+
const handlerTriggered = commonHandler(event);
|
|
1549
|
+
if (handlerTriggered) event.stopPropagation();
|
|
1550
|
+
};
|
|
1551
|
+
const __AddEvent = (element, eventType, eventName, newEventHandler)=>{
|
|
1552
|
+
eventName = eventName.toLowerCase();
|
|
1553
|
+
const isCatch = 'catchEvent' === eventType || 'capture-catch' === eventType;
|
|
1554
|
+
const isCapture = eventType.startsWith('capture');
|
|
1555
|
+
const runtimeInfo = elementToRuntimeInfoMap.get(element) ?? {
|
|
1556
|
+
eventHandlerMap: {},
|
|
1557
|
+
componentAtIndex: void 0,
|
|
1558
|
+
enqueueComponent: void 0
|
|
1559
|
+
};
|
|
1560
|
+
const currentHandler = isCapture ? runtimeInfo.eventHandlerMap[eventName]?.capture : runtimeInfo.eventHandlerMap[eventName]?.bind;
|
|
1561
|
+
const currentRegisteredHandler = isCatch ? commonCatchHandler : commonHandler;
|
|
1562
|
+
if (currentHandler) {
|
|
1563
|
+
if (!newEventHandler) {
|
|
1564
|
+
element.removeEventListener(eventName, currentRegisteredHandler, {
|
|
1565
|
+
capture: isCapture
|
|
1566
|
+
});
|
|
1567
|
+
const isExposure = 'uiappear' === eventName || 'uidisappear' === eventName;
|
|
1568
|
+
if (isExposure && '-1' === element.getAttribute('exposure-id')) mtsGlobalThis.__SetAttribute(element, 'exposure-id', null);
|
|
1569
|
+
}
|
|
1570
|
+
} else if (newEventHandler) {
|
|
1571
|
+
const htmlEventName = LynxEventNameToW3cByTagName[element.tagName]?.[eventName] ?? LynxEventNameToW3cCommon[eventName] ?? eventName;
|
|
1572
|
+
element.addEventListener(htmlEventName, currentRegisteredHandler, {
|
|
1573
|
+
capture: isCapture
|
|
1574
|
+
});
|
|
1575
|
+
const isExposure = 'uiappear' === eventName || 'uidisappear' === eventName;
|
|
1576
|
+
if (isExposure && null === element.getAttribute('exposure-id')) mtsGlobalThis.__SetAttribute(element, 'exposure-id', '-1');
|
|
1577
|
+
}
|
|
1578
|
+
if (newEventHandler) {
|
|
1579
|
+
const info = {
|
|
1580
|
+
type: eventType,
|
|
1581
|
+
handler: newEventHandler
|
|
1582
|
+
};
|
|
1583
|
+
if (!runtimeInfo.eventHandlerMap[eventName]) runtimeInfo.eventHandlerMap[eventName] = {
|
|
1584
|
+
capture: void 0,
|
|
1585
|
+
bind: void 0
|
|
1586
|
+
};
|
|
1587
|
+
if (isCapture) runtimeInfo.eventHandlerMap[eventName].capture = info;
|
|
1588
|
+
else runtimeInfo.eventHandlerMap[eventName].bind = info;
|
|
1589
|
+
}
|
|
1590
|
+
elementToRuntimeInfoMap.set(element, runtimeInfo);
|
|
1591
|
+
};
|
|
1592
|
+
const __GetEvent = (element, eventName, eventType)=>{
|
|
1593
|
+
const runtimeInfo = elementToRuntimeInfoMap.get(element);
|
|
1594
|
+
if (!runtimeInfo) return;
|
|
1595
|
+
{
|
|
1596
|
+
eventName = eventName.toLowerCase();
|
|
1597
|
+
const isCapture = eventType.startsWith('capture');
|
|
1598
|
+
const handler1 = isCapture ? runtimeInfo.eventHandlerMap[eventName]?.capture : runtimeInfo.eventHandlerMap[eventName]?.bind;
|
|
1599
|
+
return handler1?.handler;
|
|
1600
|
+
}
|
|
1601
|
+
};
|
|
1602
|
+
const __GetEvents = (element)=>{
|
|
1603
|
+
const eventHandlerMap = elementToRuntimeInfoMap.get(element)?.eventHandlerMap ?? {};
|
|
1604
|
+
const eventInfos = [];
|
|
1605
|
+
for (const [lynxEventName, info] of Object.entries(eventHandlerMap))for (const atomInfo of [
|
|
1606
|
+
info.bind,
|
|
1607
|
+
info.capture
|
|
1608
|
+
])if (atomInfo) {
|
|
1609
|
+
const { type, handler: handler1 } = atomInfo;
|
|
1610
|
+
if (handler1) eventInfos.push({
|
|
1611
|
+
type: type,
|
|
1612
|
+
name: lynxEventName,
|
|
1613
|
+
function: handler1
|
|
1614
|
+
});
|
|
1615
|
+
}
|
|
1616
|
+
return eventInfos;
|
|
1617
|
+
};
|
|
1618
|
+
const __SetEvents = (element, listeners)=>{
|
|
1619
|
+
for (const { type: eventType, name: lynxEventName, function: eventHandler } of listeners)__AddEvent(element, eventType, lynxEventName, eventHandler);
|
|
1620
|
+
};
|
|
1621
|
+
const __CreateElement = (tag, parentComponentUniqueId)=>{
|
|
1622
|
+
const uniqueId = uniqueIdInc++;
|
|
1623
|
+
const htmlTag = tagMap[tag] ?? tag;
|
|
1624
|
+
const element = callbacks.createElement(htmlTag);
|
|
1625
|
+
lynxUniqueIdToElement[uniqueId] = new WeakRef(element);
|
|
1626
|
+
const parentComponentCssID = lynxUniqueIdToElement[parentComponentUniqueId]?.deref()?.getAttribute(cssIdAttribute);
|
|
1627
|
+
parentComponentCssID && '0' !== parentComponentCssID && element.setAttribute(cssIdAttribute, parentComponentCssID);
|
|
1628
|
+
element.setAttribute(lynxTagAttribute, tag);
|
|
1629
|
+
element.setAttribute(lynxUniqueIdAttribute, uniqueId + '');
|
|
1630
|
+
element.setAttribute(parentComponentUniqueIdAttribute, parentComponentUniqueId + '');
|
|
1631
|
+
return element;
|
|
1632
|
+
};
|
|
1633
|
+
const __CreateView = (parentComponentUniqueId)=>__CreateElement('view', parentComponentUniqueId);
|
|
1634
|
+
const __CreateText = (parentComponentUniqueId)=>__CreateElement('text', parentComponentUniqueId);
|
|
1635
|
+
const __CreateRawText = (text1)=>{
|
|
1636
|
+
const element = __CreateElement('raw-text', -1);
|
|
1637
|
+
element.setAttribute('text', text1);
|
|
1638
|
+
return element;
|
|
1639
|
+
};
|
|
1640
|
+
const __CreateImage = (parentComponentUniqueId)=>__CreateElement('image', parentComponentUniqueId);
|
|
1641
|
+
const __CreateScrollView = (parentComponentUniqueId)=>__CreateElement('scroll-view', parentComponentUniqueId);
|
|
1642
|
+
const __CreateWrapperElement = (parentComponentUniqueId)=>__CreateElement('lynx-wrapper', parentComponentUniqueId);
|
|
1643
|
+
const __CreatePage = (componentID, cssID)=>{
|
|
1644
|
+
const page = __CreateElement('page', 0);
|
|
1645
|
+
page.setAttribute('part', 'page');
|
|
1646
|
+
page.setAttribute(cssIdAttribute, cssID + '');
|
|
1647
|
+
page.setAttribute(parentComponentUniqueIdAttribute, '0');
|
|
1648
|
+
page.setAttribute(componentIdAttribute, componentID);
|
|
1649
|
+
__MarkTemplateElement(page);
|
|
1650
|
+
if (false === pageConfig.defaultDisplayLinear) page.setAttribute(lynxDefaultDisplayLinearAttribute, 'false');
|
|
1651
|
+
if (true === pageConfig.defaultOverflowVisible) page.setAttribute('lynx-default-overflow-visible', 'true');
|
|
1652
|
+
pageElement = page;
|
|
1653
|
+
return page;
|
|
1654
|
+
};
|
|
1655
|
+
const __CreateList = (parentComponentUniqueId, componentAtIndex, enqueueComponent)=>{
|
|
1656
|
+
const list = __CreateElement('list', parentComponentUniqueId);
|
|
1657
|
+
const runtimeInfo = {
|
|
1658
|
+
eventHandlerMap: {},
|
|
1659
|
+
componentAtIndex: componentAtIndex,
|
|
1660
|
+
enqueueComponent: enqueueComponent
|
|
1661
|
+
};
|
|
1662
|
+
elementToRuntimeInfoMap.set(list, runtimeInfo);
|
|
1663
|
+
return list;
|
|
1664
|
+
};
|
|
1665
|
+
const __CreateComponent = (componentParentUniqueID, componentID, cssID, _, name)=>{
|
|
1666
|
+
const component = __CreateElement('view', componentParentUniqueID);
|
|
1667
|
+
component.setAttribute(cssIdAttribute, cssID + '');
|
|
1668
|
+
component.setAttribute(componentIdAttribute, componentID);
|
|
1669
|
+
component.setAttribute('name', name);
|
|
1670
|
+
return component;
|
|
1671
|
+
};
|
|
1672
|
+
const __SetAttribute = (element, key, value)=>{
|
|
1673
|
+
const tag = element.getAttribute(lynxTagAttribute);
|
|
1674
|
+
if ('list' === tag && 'update-list-info' === key) {
|
|
1675
|
+
const listInfo = value;
|
|
1676
|
+
const { insertAction, removeAction } = listInfo;
|
|
1677
|
+
queueMicrotask(()=>{
|
|
1678
|
+
const runtimeInfo = elementToRuntimeInfoMap.get(element);
|
|
1679
|
+
if (runtimeInfo) {
|
|
1680
|
+
const componentAtIndex = runtimeInfo.componentAtIndex;
|
|
1681
|
+
const enqueueComponent = runtimeInfo.enqueueComponent;
|
|
1682
|
+
const uniqueId = __GetElementUniqueID(element);
|
|
1683
|
+
for (const action of insertAction)componentAtIndex?.(element, uniqueId, action.position, 0, false);
|
|
1684
|
+
for (const action of removeAction)enqueueComponent?.(element, uniqueId, action.position);
|
|
1685
|
+
}
|
|
1686
|
+
});
|
|
1687
|
+
} else {
|
|
1688
|
+
null == value ? element.removeAttribute(key) : element.setAttribute(key, value + '');
|
|
1689
|
+
if (key === __lynx_timing_flag && value) timingFlags.push(value);
|
|
1690
|
+
if (exposureRelatedAttributes.has(key)) exposureChangedElements.add(element);
|
|
1691
|
+
}
|
|
1692
|
+
};
|
|
1693
|
+
const __UpdateListCallbacks = (element, componentAtIndex, enqueueComponent)=>{
|
|
1694
|
+
const runtimeInfo = elementToRuntimeInfoMap.get(element) ?? {
|
|
1695
|
+
eventHandlerMap: {},
|
|
1696
|
+
componentAtIndex: componentAtIndex,
|
|
1697
|
+
enqueueComponent: enqueueComponent,
|
|
1698
|
+
uniqueId: __GetElementUniqueID(element)
|
|
1699
|
+
};
|
|
1700
|
+
runtimeInfo.componentAtIndex = componentAtIndex;
|
|
1701
|
+
runtimeInfo.enqueueComponent = enqueueComponent;
|
|
1702
|
+
elementToRuntimeInfoMap.set(element, runtimeInfo);
|
|
1703
|
+
};
|
|
1704
|
+
const __SwapElement = (childA, childB)=>{
|
|
1705
|
+
const temp = callbacks.createElement('div');
|
|
1706
|
+
childA.replaceWith(temp);
|
|
1707
|
+
childB.replaceWith(childA);
|
|
1708
|
+
temp.replaceWith(childB);
|
|
1709
|
+
};
|
|
1710
|
+
const __SetCSSIdForCSSOG = (elements, cssId)=>{
|
|
1711
|
+
for (const element of elements){
|
|
1712
|
+
element.setAttribute(cssIdAttribute, cssId + '');
|
|
1713
|
+
const cls = element.getAttribute('class');
|
|
1714
|
+
cls && __SetClassesForCSSOG(element, cls);
|
|
1715
|
+
}
|
|
1716
|
+
};
|
|
1717
|
+
const __AddClassForCSSOG = (element, className)=>{
|
|
1718
|
+
const newClassName = ((element.getAttribute('class') ?? '') + ' ' + className).trim();
|
|
1719
|
+
element.setAttribute('class', newClassName);
|
|
1720
|
+
const newStyleStr = decodeCssOG(newClassName, cssOGInfo, element.getAttribute(cssIdAttribute));
|
|
1721
|
+
updateCssOGStyle(Number(element.getAttribute(lynxUniqueIdAttribute)), newStyleStr);
|
|
1722
|
+
};
|
|
1723
|
+
const __SetClassesForCSSOG = (element, classNames)=>{
|
|
1724
|
+
__SetClasses(element, classNames);
|
|
1725
|
+
const newStyleStr = decodeCssOG(classNames ?? '', cssOGInfo, element.getAttribute(cssIdAttribute));
|
|
1726
|
+
updateCssOGStyle(Number(element.getAttribute(lynxUniqueIdAttribute)), newStyleStr ?? '');
|
|
1727
|
+
};
|
|
1728
|
+
const __LoadLepusChunk = (path)=>{
|
|
1729
|
+
const lepusModule = lepusCode[`${path}`];
|
|
1730
|
+
if (!lepusModule) return false;
|
|
1731
|
+
{
|
|
1732
|
+
const entry = lepusModule.exports;
|
|
1733
|
+
entry?.(mtsGlobalThis);
|
|
1734
|
+
return true;
|
|
1735
|
+
}
|
|
1736
|
+
};
|
|
1737
|
+
const __FlushElementTree = (_subTree, options)=>{
|
|
1738
|
+
const timingFlagsCopied = timingFlags;
|
|
1739
|
+
timingFlags = [];
|
|
1740
|
+
if (pageElement && !pageElement.parentNode && '' !== pageElement.getAttribute(lynxDisposedAttribute)) rootDom.append(pageElement);
|
|
1741
|
+
const exposureChangedElementsArray = Array.from(exposureChangedElements);
|
|
1742
|
+
exposureChangedElements.clear();
|
|
1743
|
+
callbacks.flushElementTree(options, timingFlagsCopied, exposureChangedElementsArray);
|
|
1744
|
+
};
|
|
1745
|
+
const __GetPageElement = ()=>pageElement;
|
|
1746
|
+
const templateIdToTemplate = {};
|
|
1747
|
+
const createElementForElementTemplateData = (data, parentComponentUniId)=>{
|
|
1748
|
+
const element = __CreateElement(data.type, parentComponentUniId);
|
|
1749
|
+
__SetID(element, data.id);
|
|
1750
|
+
__SetClasses(element, data.class.join(' '));
|
|
1751
|
+
for (const [key, value] of Object.entries(data.attributes))__SetAttribute(element, key, value);
|
|
1752
|
+
for (const [key, value] of Object.entries(data.builtinAttributes))__SetAttribute(element, key, value);
|
|
1753
|
+
for (const childData of data.children)__AppendElement(element, createElementForElementTemplateData(childData, parentComponentUniId));
|
|
1754
|
+
return element;
|
|
1755
|
+
};
|
|
1756
|
+
const applyEventsForElementTemplate = (data, element)=>{
|
|
1757
|
+
const uniqueId = uniqueIdInc++;
|
|
1758
|
+
element.setAttribute(lynxUniqueIdAttribute, uniqueId + '');
|
|
1759
|
+
for (const event of data.events){
|
|
1760
|
+
const { type, name, value } = event;
|
|
1761
|
+
__AddEvent(element, type, name, value);
|
|
1762
|
+
}
|
|
1763
|
+
for(let ii = 0; ii < data.children.length; ii++){
|
|
1764
|
+
const childData = data.children[ii];
|
|
1765
|
+
const childElement = element.children[ii];
|
|
1766
|
+
if (childData && childElement) applyEventsForElementTemplate(childData, childElement);
|
|
1767
|
+
}
|
|
1768
|
+
};
|
|
1769
|
+
const __ElementFromBinary = (templateId, parentComponentUniId)=>{
|
|
1770
|
+
const elementTemplateData = config.elementTemplate[templateId];
|
|
1771
|
+
if (elementTemplateData) {
|
|
1772
|
+
let clonedElements;
|
|
1773
|
+
if (templateIdToTemplate[templateId]) clonedElements = Array.from(templateIdToTemplate[templateId].content.cloneNode(true).children);
|
|
1774
|
+
else {
|
|
1775
|
+
clonedElements = elementTemplateData.map((data)=>createElementForElementTemplateData(data, parentComponentUniId));
|
|
1776
|
+
if (rootDom.cloneNode) {
|
|
1777
|
+
const template = callbacks.createElement('template');
|
|
1778
|
+
template.content.append(...clonedElements);
|
|
1779
|
+
templateIdToTemplate[templateId] = template;
|
|
1780
|
+
rootDom.append(template);
|
|
1781
|
+
return __ElementFromBinary(templateId, parentComponentUniId);
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
for(let ii = 0; ii < clonedElements.length; ii++){
|
|
1785
|
+
const data = elementTemplateData[ii];
|
|
1786
|
+
const element = clonedElements[ii];
|
|
1787
|
+
if (data && element) applyEventsForElementTemplate(data, element);
|
|
1788
|
+
}
|
|
1789
|
+
return clonedElements;
|
|
1790
|
+
}
|
|
1791
|
+
return [];
|
|
1792
|
+
};
|
|
1793
|
+
let release = '';
|
|
1794
|
+
const isCSSOG = !pageConfig.enableCSSSelector;
|
|
1795
|
+
const mtsGlobalThis = {
|
|
1796
|
+
__ElementFromBinary,
|
|
1797
|
+
__GetTemplateParts: rootDom.querySelectorAll ? __GetTemplateParts : void 0,
|
|
1798
|
+
__MarkTemplateElement: __MarkTemplateElement,
|
|
1799
|
+
__MarkPartElement: __MarkPartElement,
|
|
1800
|
+
__AddEvent: ssrHooks?.__AddEvent ?? __AddEvent,
|
|
1801
|
+
__GetEvent,
|
|
1802
|
+
__GetEvents,
|
|
1803
|
+
__SetEvents,
|
|
1804
|
+
__AppendElement: __AppendElement,
|
|
1805
|
+
__ElementIsEqual: __ElementIsEqual,
|
|
1806
|
+
__FirstElement: __FirstElement,
|
|
1807
|
+
__GetChildren: __GetChildren,
|
|
1808
|
+
__GetParent: __GetParent,
|
|
1809
|
+
__InsertElementBefore: __InsertElementBefore,
|
|
1810
|
+
__LastElement: __LastElement,
|
|
1811
|
+
__NextElement: __NextElement,
|
|
1812
|
+
__RemoveElement: __RemoveElement,
|
|
1813
|
+
__ReplaceElement: __ReplaceElement,
|
|
1814
|
+
__ReplaceElements: __ReplaceElements,
|
|
1815
|
+
__AddConfig: __AddConfig,
|
|
1816
|
+
__AddDataset: __AddDataset,
|
|
1817
|
+
__GetAttributes: __GetAttributes,
|
|
1818
|
+
__GetComponentID: __GetComponentID,
|
|
1819
|
+
__GetDataByKey: __GetDataByKey,
|
|
1820
|
+
__GetDataset: __GetDataset,
|
|
1821
|
+
__GetElementConfig: __GetElementConfig,
|
|
1822
|
+
__GetElementUniqueID: __GetElementUniqueID,
|
|
1823
|
+
__GetID: __GetID,
|
|
1824
|
+
__GetTag: __GetTag,
|
|
1825
|
+
__SetConfig: __SetConfig,
|
|
1826
|
+
__SetDataset: __SetDataset,
|
|
1827
|
+
__SetID: __SetID,
|
|
1828
|
+
__UpdateComponentID: __UpdateComponentID,
|
|
1829
|
+
__CreateElement,
|
|
1830
|
+
__CreateView,
|
|
1831
|
+
__CreateText,
|
|
1832
|
+
__CreateComponent,
|
|
1833
|
+
__CreatePage,
|
|
1834
|
+
__CreateRawText,
|
|
1835
|
+
__CreateImage,
|
|
1836
|
+
__CreateScrollView,
|
|
1837
|
+
__CreateWrapperElement,
|
|
1838
|
+
__CreateList,
|
|
1839
|
+
__SetAttribute,
|
|
1840
|
+
__SwapElement,
|
|
1841
|
+
__UpdateListCallbacks,
|
|
1842
|
+
__GetConfig: __GetElementConfig,
|
|
1843
|
+
__GetClasses: __GetClasses,
|
|
1844
|
+
__AddClass: isCSSOG ? __AddClassForCSSOG : __AddClass,
|
|
1845
|
+
__SetClasses: isCSSOG ? __SetClassesForCSSOG : __SetClasses,
|
|
1846
|
+
__AddInlineStyle: __AddInlineStyle,
|
|
1847
|
+
__SetCSSId: isCSSOG ? __SetCSSIdForCSSOG : __SetCSSId,
|
|
1848
|
+
__SetInlineStyles: __SetInlineStyles,
|
|
1849
|
+
__LoadLepusChunk,
|
|
1850
|
+
__GetPageElement,
|
|
1851
|
+
__globalProps: globalProps,
|
|
1852
|
+
SystemInfo: {
|
|
1853
|
+
...systemInfo,
|
|
1854
|
+
...config.browserConfig
|
|
1855
|
+
},
|
|
1856
|
+
lynx: createMainThreadLynx(config),
|
|
1857
|
+
_ReportError: (err, _)=>callbacks._ReportError(err, _, release),
|
|
1858
|
+
_SetSourceMapRelease: (errInfo)=>release = errInfo?.release,
|
|
1859
|
+
__OnLifecycleEvent: callbacks.__OnLifecycleEvent,
|
|
1860
|
+
__FlushElementTree,
|
|
1861
|
+
__lynxGlobalBindingValues: lynxGlobalBindingValues,
|
|
1862
|
+
_I18nResourceTranslation: callbacks._I18nResourceTranslation,
|
|
1863
|
+
_AddEventListener: ()=>{},
|
|
1864
|
+
set _updateVars (handler){
|
|
1865
|
+
varsUpdateHandlers.push(handler);
|
|
1866
|
+
},
|
|
1867
|
+
set renderPage (foo){
|
|
1868
|
+
renderPage = foo;
|
|
1869
|
+
queueMicrotask(callbacks.mainChunkReady);
|
|
1870
|
+
},
|
|
1871
|
+
get renderPage () {
|
|
1872
|
+
return renderPage;
|
|
1873
|
+
}
|
|
1874
|
+
};
|
|
1875
|
+
mtsGlobalThis.globalThis = new Proxy(mtsGlobalThis, {
|
|
1876
|
+
get: (target, prop)=>{
|
|
1877
|
+
if ('globalThis' === prop) return target;
|
|
1878
|
+
return target[prop] ?? globalThis[prop];
|
|
1879
|
+
},
|
|
1880
|
+
set: (target, prop, value)=>{
|
|
1881
|
+
target[prop] = value;
|
|
1882
|
+
return true;
|
|
1883
|
+
},
|
|
1884
|
+
ownKeys (target) {
|
|
1885
|
+
return Reflect.ownKeys(target).filter((key)=>'globalThis' !== key);
|
|
1886
|
+
}
|
|
1887
|
+
});
|
|
1888
|
+
for (const nm of globalMuteableVars)Object.defineProperty(mtsGlobalThis, nm, {
|
|
1889
|
+
get: ()=>lynxGlobalBindingValues[nm],
|
|
1890
|
+
set: (v)=>{
|
|
1891
|
+
lynxGlobalBindingValues[nm] = v;
|
|
1892
|
+
for (const handler1 of varsUpdateHandlers)handler1();
|
|
1893
|
+
}
|
|
1894
|
+
});
|
|
1895
|
+
return mtsGlobalThis;
|
|
1896
|
+
}
|
|
1897
|
+
function createExposureService(rootDom, postExposure) {
|
|
1898
|
+
let working = true;
|
|
1899
|
+
let exposureCache = [];
|
|
1900
|
+
let disexposureCache = [];
|
|
1901
|
+
let delayCallback = null;
|
|
1902
|
+
const onScreen = new Map();
|
|
1903
|
+
function exposureEventHandler(ev) {
|
|
1904
|
+
const exposureEvent = createCrossThreadEvent(ev, ev.type);
|
|
1905
|
+
exposureEvent.detail['unique-id'] = parseFloat(ev.target.getAttribute(lynxUniqueIdAttribute));
|
|
1906
|
+
const exposureID = exposureEvent.detail.exposureID;
|
|
1907
|
+
if ('exposure' === ev.type) {
|
|
1908
|
+
exposureCache.push(exposureEvent);
|
|
1909
|
+
onScreen.set(exposureID, exposureEvent);
|
|
1910
|
+
} else {
|
|
1911
|
+
disexposureCache.push(exposureEvent);
|
|
1912
|
+
onScreen.delete(exposureID);
|
|
1913
|
+
}
|
|
1914
|
+
if (!delayCallback) delayCallback = setTimeout(()=>{
|
|
1915
|
+
if (exposureCache.length > 0 || disexposureCache.length > 0) {
|
|
1916
|
+
const currentExposure = exposureCache;
|
|
1917
|
+
const currentDisexposure = disexposureCache;
|
|
1918
|
+
exposureCache = [];
|
|
1919
|
+
disexposureCache = [];
|
|
1920
|
+
postExposure({
|
|
1921
|
+
exposures: currentExposure,
|
|
1922
|
+
disExposures: currentDisexposure
|
|
1923
|
+
});
|
|
1924
|
+
}
|
|
1925
|
+
delayCallback = null;
|
|
1926
|
+
}, 50);
|
|
1927
|
+
}
|
|
1928
|
+
rootDom.addEventListener('exposure', exposureEventHandler, {
|
|
1929
|
+
passive: true
|
|
1930
|
+
});
|
|
1931
|
+
rootDom.addEventListener('disexposure', exposureEventHandler, {
|
|
1932
|
+
passive: true
|
|
1933
|
+
});
|
|
1934
|
+
function switchExposureService(enable, sendEvent) {
|
|
1935
|
+
if (enable && !working) postExposure({
|
|
1936
|
+
exposures: [
|
|
1937
|
+
...onScreen.values()
|
|
1938
|
+
],
|
|
1939
|
+
disExposures: []
|
|
1940
|
+
});
|
|
1941
|
+
else if (!enable && working) {
|
|
1942
|
+
if (sendEvent) postExposure({
|
|
1943
|
+
exposures: [],
|
|
1944
|
+
disExposures: [
|
|
1945
|
+
...onScreen.values()
|
|
1946
|
+
]
|
|
1947
|
+
});
|
|
1948
|
+
}
|
|
1949
|
+
working = enable;
|
|
1950
|
+
}
|
|
1951
|
+
return {
|
|
1952
|
+
switchExposureService
|
|
1953
|
+
};
|
|
1954
|
+
}
|
|
1955
|
+
const initWasmPromise = initWasm();
|
|
1956
|
+
const moduleCache = {};
|
|
1957
|
+
function prepareMainThreadAPIs(backgroundThreadRpc, rootDom, createElement, commitDocument, markTimingInternal, flushMarkTimingInternal, reportError, triggerI18nResourceFallback, initialI18nResources, ssrHooks) {
|
|
1958
|
+
const postTimingFlags = backgroundThreadRpc.createCall(postTimingFlagsEndpoint);
|
|
1959
|
+
const backgroundStart = backgroundThreadRpc.createCall(BackgroundThreadStartEndpoint);
|
|
1960
|
+
const publishEvent = backgroundThreadRpc.createCall(publishEventEndpoint);
|
|
1961
|
+
const publicComponentEvent = backgroundThreadRpc.createCall(publicComponentEventEndpoint);
|
|
1962
|
+
const postExposure = backgroundThreadRpc.createCall(postExposureEndpoint);
|
|
1963
|
+
const dispatchI18nResource = backgroundThreadRpc.createCall(dispatchI18nResourceEndpoint);
|
|
1964
|
+
markTimingInternal('lepus_execute_start');
|
|
1965
|
+
async function startMainThread(config, ssrHydrateInfo) {
|
|
1966
|
+
let isFp = true;
|
|
1967
|
+
const { globalProps, template, browserConfig, nativeModulesMap, napiModulesMap, tagMap, initI18nResources } = config;
|
|
1968
|
+
const { styleInfo, pageConfig, customSections, cardType, lepusCode, elementTemplate } = template;
|
|
1969
|
+
markTimingInternal('decode_start');
|
|
1970
|
+
await initWasmPromise;
|
|
1971
|
+
const lepusCodeEntries = await Promise.all(Object.entries(lepusCode).map(async ([name, url])=>{
|
|
1972
|
+
const cachedModule = moduleCache[url];
|
|
1973
|
+
if (cachedModule) return [
|
|
1974
|
+
name,
|
|
1975
|
+
cachedModule
|
|
1976
|
+
];
|
|
1977
|
+
{
|
|
1978
|
+
Object.assign(globalThis, {
|
|
1979
|
+
module: {}
|
|
1980
|
+
});
|
|
1981
|
+
await import(url);
|
|
1982
|
+
const module = globalThis.module;
|
|
1983
|
+
Object.assign(globalThis, {
|
|
1984
|
+
module: {}
|
|
1985
|
+
});
|
|
1986
|
+
moduleCache[url] = module;
|
|
1987
|
+
return [
|
|
1988
|
+
name,
|
|
1989
|
+
module
|
|
1990
|
+
];
|
|
1991
|
+
}
|
|
1992
|
+
}));
|
|
1993
|
+
const lepusCodeLoaded = Object.fromEntries(lepusCodeEntries);
|
|
1994
|
+
const entry = lepusCodeLoaded['root'].exports;
|
|
1995
|
+
const jsContext = new LynxCrossThreadContext({
|
|
1996
|
+
rpc: backgroundThreadRpc,
|
|
1997
|
+
receiveEventEndpoint: dispatchJSContextOnMainThreadEndpoint,
|
|
1998
|
+
sendEventEndpoint: dispatchCoreContextOnBackgroundEndpoint
|
|
1999
|
+
});
|
|
2000
|
+
const i18nResources = initialI18nResources(initI18nResources);
|
|
2001
|
+
const mtsGlobalThis = createMainThreadGlobalThis({
|
|
2002
|
+
jsContext,
|
|
2003
|
+
tagMap,
|
|
2004
|
+
browserConfig,
|
|
2005
|
+
customSections,
|
|
2006
|
+
elementTemplate,
|
|
2007
|
+
globalProps,
|
|
2008
|
+
pageConfig,
|
|
2009
|
+
styleInfo,
|
|
2010
|
+
lepusCode: lepusCodeLoaded,
|
|
2011
|
+
rootDom,
|
|
2012
|
+
ssrHydrateInfo,
|
|
2013
|
+
ssrHooks,
|
|
2014
|
+
callbacks: {
|
|
2015
|
+
mainChunkReady: ()=>{
|
|
2016
|
+
markTimingInternal('data_processor_start');
|
|
2017
|
+
let initData = config.initData;
|
|
2018
|
+
if (true !== pageConfig.enableJSDataProcessor && mtsGlobalThis.processData) initData = mtsGlobalThis.processData(config.initData);
|
|
2019
|
+
markTimingInternal('data_processor_end');
|
|
2020
|
+
registerCallLepusMethodHandler(backgroundThreadRpc, mtsGlobalThis);
|
|
2021
|
+
registerGetCustomSectionHandler(backgroundThreadRpc, customSections);
|
|
2022
|
+
const { switchExposureService } = createExposureService(rootDom, postExposure);
|
|
2023
|
+
backgroundThreadRpc.registerHandler(switchExposureServiceEndpoint, switchExposureService);
|
|
2024
|
+
backgroundStart({
|
|
2025
|
+
initData,
|
|
2026
|
+
globalProps,
|
|
2027
|
+
template,
|
|
2028
|
+
cardType: cardType ?? 'react',
|
|
2029
|
+
customSections: Object.fromEntries(Object.entries(customSections).filter(([, value])=>'lazy' !== value.type).map(([k, v])=>[
|
|
2030
|
+
k,
|
|
2031
|
+
v.content
|
|
2032
|
+
])),
|
|
2033
|
+
nativeModulesMap,
|
|
2034
|
+
napiModulesMap,
|
|
2035
|
+
browserConfig
|
|
2036
|
+
});
|
|
2037
|
+
if (ssrHydrateInfo) {
|
|
2038
|
+
for (const event of ssrHydrateInfo.events){
|
|
2039
|
+
const uniqueId = event[0];
|
|
2040
|
+
const element = ssrHydrateInfo.lynxUniqueIdToElement[uniqueId]?.deref();
|
|
2041
|
+
if (element) mtsGlobalThis.__AddEvent(element, event[1], event[2], event[3]);
|
|
2042
|
+
}
|
|
2043
|
+
mtsGlobalThis.ssrHydrate?.(ssrHydrateInfo.ssrEncodeData);
|
|
2044
|
+
} else {
|
|
2045
|
+
mtsGlobalThis.renderPage(initData);
|
|
2046
|
+
mtsGlobalThis.__FlushElementTree(void 0, {});
|
|
2047
|
+
}
|
|
2048
|
+
},
|
|
2049
|
+
flushElementTree: async (options, timingFlags, exposureChangedElements)=>{
|
|
2050
|
+
const pipelineId = options?.pipelineOptions?.pipelineID;
|
|
2051
|
+
markTimingInternal('dispatch_start', pipelineId);
|
|
2052
|
+
if (isFp) {
|
|
2053
|
+
isFp = false;
|
|
2054
|
+
jsContext.dispatchEvent({
|
|
2055
|
+
type: '__OnNativeAppReady',
|
|
2056
|
+
data: void 0
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
markTimingInternal('layout_start', pipelineId);
|
|
2060
|
+
markTimingInternal('ui_operation_flush_start', pipelineId);
|
|
2061
|
+
await commitDocument(exposureChangedElements);
|
|
2062
|
+
markTimingInternal('ui_operation_flush_end', pipelineId);
|
|
2063
|
+
markTimingInternal('layout_end', pipelineId);
|
|
2064
|
+
markTimingInternal('dispatch_end', pipelineId);
|
|
2065
|
+
flushMarkTimingInternal();
|
|
2066
|
+
requestAnimationFrame(()=>{
|
|
2067
|
+
postTimingFlags(timingFlags, pipelineId);
|
|
2068
|
+
});
|
|
2069
|
+
},
|
|
2070
|
+
_ReportError: reportError,
|
|
2071
|
+
__OnLifecycleEvent: (data)=>{
|
|
2072
|
+
jsContext.dispatchEvent({
|
|
2073
|
+
type: '__OnLifecycleEvent',
|
|
2074
|
+
data
|
|
2075
|
+
});
|
|
2076
|
+
},
|
|
2077
|
+
markTiming: (a, b)=>markTimingInternal(b, a),
|
|
2078
|
+
publishEvent,
|
|
2079
|
+
publicComponentEvent,
|
|
2080
|
+
createElement,
|
|
2081
|
+
_I18nResourceTranslation: (options)=>{
|
|
2082
|
+
const matchedInitI18nResources = i18nResources.data?.find((i)=>getCacheI18nResourcesKey(i.options) === getCacheI18nResourcesKey(options));
|
|
2083
|
+
dispatchI18nResource(matchedInitI18nResources?.resource);
|
|
2084
|
+
if (matchedInitI18nResources) return matchedInitI18nResources.resource;
|
|
2085
|
+
return triggerI18nResourceFallback(options);
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
});
|
|
2089
|
+
markTimingInternal('decode_end');
|
|
2090
|
+
entry(mtsGlobalThis);
|
|
2091
|
+
jsContext.__start();
|
|
2092
|
+
return mtsGlobalThis;
|
|
2093
|
+
}
|
|
2094
|
+
return {
|
|
2095
|
+
startMainThread
|
|
2096
|
+
};
|
|
2097
|
+
}
|
|
2098
|
+
const templateCache = new Map();
|
|
2099
|
+
let tmpDir;
|
|
2100
|
+
const tmpDirPromise = promises.mkdtemp(node_path.join(node_os.tmpdir(), 'lynx'));
|
|
2101
|
+
async function loadTemplate_createJsModuleUrl(content, filename) {
|
|
2102
|
+
if (!tmpDir) tmpDir = await tmpDirPromise;
|
|
2103
|
+
const fileUrl = node_path.join(tmpDir, filename);
|
|
2104
|
+
await promises.writeFile(fileUrl, content, {
|
|
2105
|
+
flag: 'w+'
|
|
2106
|
+
});
|
|
2107
|
+
return fileUrl;
|
|
2108
|
+
}
|
|
2109
|
+
async function loadTemplate(rawTemplate, templateName = Math.random().toString(36).substring(2, 7)) {
|
|
2110
|
+
if (templateCache.has(rawTemplate)) return templateCache.get(rawTemplate);
|
|
2111
|
+
templateName += Math.random().toString(36).substring(2, 7);
|
|
2112
|
+
const decodedTemplate = templateCache.get(rawTemplate) ?? await generateTemplate(rawTemplate, loadTemplate_createJsModuleUrl, templateName + '-lepusCode');
|
|
2113
|
+
templateCache.set(rawTemplate, decodedTemplate);
|
|
2114
|
+
return decodedTemplate;
|
|
2115
|
+
}
|
|
2116
|
+
const OperationType = {
|
|
2117
|
+
CreateElement: 1,
|
|
2118
|
+
SetAttribute: 2,
|
|
2119
|
+
RemoveAttribute: 3,
|
|
2120
|
+
Append: 4,
|
|
2121
|
+
Remove: 5,
|
|
2122
|
+
ReplaceWith: 6,
|
|
2123
|
+
InsertBefore: 7,
|
|
2124
|
+
EnableEvent: 8,
|
|
2125
|
+
RemoveChild: 9,
|
|
2126
|
+
StyleDeclarationSetProperty: 10,
|
|
2127
|
+
StyleDeclarationRemoveProperty: 11,
|
|
2128
|
+
SetInnerHTML: 12,
|
|
2129
|
+
sheetInsertRule: 13,
|
|
2130
|
+
sheetRuleUpdateCssText: 14
|
|
2131
|
+
};
|
|
2132
|
+
class OffscreenCSSStyleDeclaration {
|
|
2133
|
+
_parent;
|
|
2134
|
+
constructor(parent){
|
|
2135
|
+
this._parent = parent;
|
|
2136
|
+
}
|
|
2137
|
+
setProperty(property, value, priority) {
|
|
2138
|
+
this._parent[ancestorDocument][operations].push(OperationType.StyleDeclarationSetProperty, this._parent[OffscreenElement_uniqueId], property, value, priority ?? '');
|
|
2139
|
+
const currentStyle = this._parent.getAttribute('style') ?? '';
|
|
2140
|
+
this._parent[_attributes].set('style', currentStyle + `${property}:${value}${priority ? ` !${priority}` : ''};`);
|
|
2141
|
+
}
|
|
2142
|
+
removeProperty(property) {
|
|
2143
|
+
this._parent[ancestorDocument][operations].push(OperationType.StyleDeclarationRemoveProperty, this._parent[OffscreenElement_uniqueId], property);
|
|
2144
|
+
const currentStyle = this._parent.getAttribute('style') ?? '';
|
|
2145
|
+
this._parent[_attributes].set('style', currentStyle + `${property}:inital;`);
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
const ancestorDocument = Symbol('ancestorDocument');
|
|
2149
|
+
const _attributes = Symbol('_attributes');
|
|
2150
|
+
const _children = Symbol('_children');
|
|
2151
|
+
const innerHTML = Symbol('innerHTML');
|
|
2152
|
+
const _cssRuleContents = Symbol('_cssRuleContents');
|
|
2153
|
+
const OffscreenElement_uniqueId = Symbol('uniqueId');
|
|
2154
|
+
const _style = Symbol('_style');
|
|
2155
|
+
class OffscreenElement extends EventTarget {
|
|
2156
|
+
[innerHTML] = '';
|
|
2157
|
+
[_style];
|
|
2158
|
+
[_attributes] = new Map();
|
|
2159
|
+
_parentElement = null;
|
|
2160
|
+
[_children] = [];
|
|
2161
|
+
[_cssRuleContents];
|
|
2162
|
+
#sheet;
|
|
2163
|
+
[OffscreenElement_uniqueId];
|
|
2164
|
+
[ancestorDocument];
|
|
2165
|
+
localName;
|
|
2166
|
+
constructor(localName, elementUniqueId){
|
|
2167
|
+
super();
|
|
2168
|
+
this.localName = localName;
|
|
2169
|
+
this[OffscreenElement_uniqueId] = elementUniqueId;
|
|
2170
|
+
}
|
|
2171
|
+
get sheet() {
|
|
2172
|
+
if (!this.#sheet) {
|
|
2173
|
+
const uid = this[OffscreenElement_uniqueId];
|
|
2174
|
+
const ancestor = this[ancestorDocument];
|
|
2175
|
+
const cssRules = [];
|
|
2176
|
+
this.#sheet = {
|
|
2177
|
+
cssRules,
|
|
2178
|
+
insertRule: (rule, index)=>{
|
|
2179
|
+
cssRules.splice(index, 0, {
|
|
2180
|
+
style: {
|
|
2181
|
+
set cssText (text){
|
|
2182
|
+
ancestor[operations].push(OperationType.sheetRuleUpdateCssText, uid, index, text);
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
});
|
|
2186
|
+
if (!this[_cssRuleContents]) this[_cssRuleContents] = [];
|
|
2187
|
+
this[_cssRuleContents].splice(index, 0, rule);
|
|
2188
|
+
this[ancestorDocument][operations].push(OperationType.sheetInsertRule, uid, index, rule);
|
|
2189
|
+
return index;
|
|
2190
|
+
}
|
|
2191
|
+
};
|
|
2192
|
+
}
|
|
2193
|
+
return this.#sheet;
|
|
2194
|
+
}
|
|
2195
|
+
get tagName() {
|
|
2196
|
+
return this.localName.toUpperCase();
|
|
2197
|
+
}
|
|
2198
|
+
get style() {
|
|
2199
|
+
if (!this[_style]) this[_style] = new OffscreenCSSStyleDeclaration(this);
|
|
2200
|
+
return this[_style];
|
|
2201
|
+
}
|
|
2202
|
+
get children() {
|
|
2203
|
+
return this[_children].slice();
|
|
2204
|
+
}
|
|
2205
|
+
get parentElement() {
|
|
2206
|
+
return this._parentElement;
|
|
2207
|
+
}
|
|
2208
|
+
get parentNode() {
|
|
2209
|
+
return this._parentElement;
|
|
2210
|
+
}
|
|
2211
|
+
get firstElementChild() {
|
|
2212
|
+
return this[_children][0] ?? null;
|
|
2213
|
+
}
|
|
2214
|
+
get lastElementChild() {
|
|
2215
|
+
return this[_children][this[_children].length - 1] ?? null;
|
|
2216
|
+
}
|
|
2217
|
+
get nextElementSibling() {
|
|
2218
|
+
const parent = this._parentElement;
|
|
2219
|
+
if (parent) {
|
|
2220
|
+
const nextElementSiblingIndex = parent[_children].indexOf(this);
|
|
2221
|
+
if (nextElementSiblingIndex >= 0) return parent[_children][nextElementSiblingIndex + 1] || null;
|
|
2222
|
+
}
|
|
2223
|
+
return null;
|
|
2224
|
+
}
|
|
2225
|
+
_remove() {
|
|
2226
|
+
if (this._parentElement) {
|
|
2227
|
+
const currentIdx = this._parentElement[_children].indexOf(this);
|
|
2228
|
+
this._parentElement[_children].splice(currentIdx, 1);
|
|
2229
|
+
this._parentElement = null;
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
setAttribute(qualifiedName, value) {
|
|
2233
|
+
this[_attributes].set(qualifiedName, value);
|
|
2234
|
+
this[ancestorDocument][operations].push(OperationType.SetAttribute, this[OffscreenElement_uniqueId], qualifiedName, value);
|
|
2235
|
+
}
|
|
2236
|
+
getAttribute(qualifiedName) {
|
|
2237
|
+
return this[_attributes].get(qualifiedName) ?? null;
|
|
2238
|
+
}
|
|
2239
|
+
removeAttribute(qualifiedName) {
|
|
2240
|
+
this[_attributes].delete(qualifiedName);
|
|
2241
|
+
this[ancestorDocument][operations].push(OperationType.RemoveAttribute, this[OffscreenElement_uniqueId], qualifiedName);
|
|
2242
|
+
}
|
|
2243
|
+
append(...nodes) {
|
|
2244
|
+
this[ancestorDocument][operations].push(OperationType.Append, this[OffscreenElement_uniqueId], nodes.length, ...nodes.map((node)=>node[OffscreenElement_uniqueId]));
|
|
2245
|
+
for (const node of nodes){
|
|
2246
|
+
node._remove();
|
|
2247
|
+
node._parentElement = this;
|
|
2248
|
+
}
|
|
2249
|
+
this[_children].push(...nodes);
|
|
2250
|
+
}
|
|
2251
|
+
appendChild(node) {
|
|
2252
|
+
this[ancestorDocument][operations].push(OperationType.Append, this[OffscreenElement_uniqueId], 1, node[OffscreenElement_uniqueId]);
|
|
2253
|
+
node._remove();
|
|
2254
|
+
node._parentElement = this;
|
|
2255
|
+
this[_children].push(node);
|
|
2256
|
+
return node;
|
|
2257
|
+
}
|
|
2258
|
+
replaceWith(...nodes) {
|
|
2259
|
+
this[ancestorDocument][operations].push(OperationType.ReplaceWith, this[OffscreenElement_uniqueId], nodes.length, ...nodes.map((node)=>node[OffscreenElement_uniqueId]));
|
|
2260
|
+
if (this._parentElement) {
|
|
2261
|
+
const parent = this._parentElement;
|
|
2262
|
+
this._parentElement = null;
|
|
2263
|
+
const currentIdx = parent[_children].indexOf(this);
|
|
2264
|
+
parent[_children].splice(currentIdx, 1, ...nodes);
|
|
2265
|
+
for (const node of nodes)node._parentElement = parent;
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
getAttributeNames() {
|
|
2269
|
+
return [
|
|
2270
|
+
...this[_attributes].keys()
|
|
2271
|
+
];
|
|
2272
|
+
}
|
|
2273
|
+
remove() {
|
|
2274
|
+
this[ancestorDocument][operations].push(OperationType.Remove, this[OffscreenElement_uniqueId]);
|
|
2275
|
+
this._remove();
|
|
2276
|
+
}
|
|
2277
|
+
insertBefore(newNode, refNode) {
|
|
2278
|
+
newNode._remove();
|
|
2279
|
+
if (refNode) {
|
|
2280
|
+
const refNodeIndex = this[_children].indexOf(refNode);
|
|
2281
|
+
if (refNodeIndex >= 0) {
|
|
2282
|
+
newNode._parentElement = this;
|
|
2283
|
+
this[_children].splice(refNodeIndex, 0, newNode);
|
|
2284
|
+
}
|
|
2285
|
+
} else {
|
|
2286
|
+
newNode._parentElement = this;
|
|
2287
|
+
this[_children].push(newNode);
|
|
2288
|
+
}
|
|
2289
|
+
this[ancestorDocument][operations].push(OperationType.InsertBefore, this[OffscreenElement_uniqueId], newNode[OffscreenElement_uniqueId], refNode?.[OffscreenElement_uniqueId] ?? 0);
|
|
2290
|
+
return newNode;
|
|
2291
|
+
}
|
|
2292
|
+
removeChild(child) {
|
|
2293
|
+
if (!child) throw new DOMException('The node to be removed is not a child of this node.', 'NotFoundError');
|
|
2294
|
+
if (child._parentElement !== this) throw new DOMException('The node to be removed is not a child of this node.', 'NotFoundError');
|
|
2295
|
+
this[ancestorDocument][operations].push(OperationType.RemoveChild, this[OffscreenElement_uniqueId], child[OffscreenElement_uniqueId]);
|
|
2296
|
+
child._remove();
|
|
2297
|
+
return child;
|
|
2298
|
+
}
|
|
2299
|
+
addEventListener(type, callback, options) {
|
|
2300
|
+
this[ancestorDocument][enableEvent](type, this[OffscreenElement_uniqueId]);
|
|
2301
|
+
super.addEventListener(type, callback, options);
|
|
2302
|
+
}
|
|
2303
|
+
set innerHTML(text1) {
|
|
2304
|
+
this[ancestorDocument][operations].push(OperationType.SetInnerHTML, this[OffscreenElement_uniqueId], text1);
|
|
2305
|
+
for (const child of this.children)child.remove();
|
|
2306
|
+
this[innerHTML] = text1;
|
|
2307
|
+
if (this[_cssRuleContents]) this[_cssRuleContents] = [];
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
const propagationStopped = Symbol('propagationStopped');
|
|
2311
|
+
const eventPhase = Symbol('eventPhase');
|
|
2312
|
+
class OffscreenEvent extends Event {
|
|
2313
|
+
_target;
|
|
2314
|
+
[eventPhase] = Event.CAPTURING_PHASE;
|
|
2315
|
+
constructor(type, _target){
|
|
2316
|
+
super(type);
|
|
2317
|
+
this._target = _target;
|
|
2318
|
+
}
|
|
2319
|
+
get target() {
|
|
2320
|
+
return this._target;
|
|
2321
|
+
}
|
|
2322
|
+
[propagationStopped] = false;
|
|
2323
|
+
stopImmediatePropagation() {
|
|
2324
|
+
this[propagationStopped] = true;
|
|
2325
|
+
super.stopImmediatePropagation();
|
|
2326
|
+
}
|
|
2327
|
+
stopPropagation() {
|
|
2328
|
+
this[propagationStopped] = true;
|
|
2329
|
+
super.stopPropagation();
|
|
2330
|
+
}
|
|
2331
|
+
get eventPhase() {
|
|
2332
|
+
return this[eventPhase];
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
const operations = Symbol('operations');
|
|
2336
|
+
const enableEvent = Symbol('enableEvent');
|
|
2337
|
+
const getElementByUniqueId = Symbol('getElementByUniqueId');
|
|
2338
|
+
const _onEvent = Symbol('_onEvent');
|
|
2339
|
+
const _uniqueIdInc = Symbol('uniqueIdInc');
|
|
2340
|
+
const _uniqueIdToElement = Symbol('_uniqueIdToElement');
|
|
2341
|
+
class OffscreenDocument extends OffscreenElement {
|
|
2342
|
+
_callbacks;
|
|
2343
|
+
[_uniqueIdInc] = 1;
|
|
2344
|
+
[_uniqueIdToElement] = [];
|
|
2345
|
+
[operations] = [];
|
|
2346
|
+
[getElementByUniqueId](uniqueId) {
|
|
2347
|
+
return this[_uniqueIdToElement][uniqueId]?.deref();
|
|
2348
|
+
}
|
|
2349
|
+
[enableEvent];
|
|
2350
|
+
constructor(_callbacks){
|
|
2351
|
+
const enableEventImpl = (eventType, uid)=>{
|
|
2352
|
+
this[operations].push(OperationType.EnableEvent, uid, eventType);
|
|
2353
|
+
};
|
|
2354
|
+
super('', 0);
|
|
2355
|
+
this._callbacks = _callbacks;
|
|
2356
|
+
this[ancestorDocument] = this;
|
|
2357
|
+
this[enableEvent] = enableEventImpl;
|
|
2358
|
+
}
|
|
2359
|
+
commit() {
|
|
2360
|
+
const currentOperations = this[operations];
|
|
2361
|
+
this[operations] = [];
|
|
2362
|
+
this._callbacks.onCommit(currentOperations);
|
|
2363
|
+
}
|
|
2364
|
+
createElement(tagName) {
|
|
2365
|
+
const uniqueId = this[_uniqueIdInc]++;
|
|
2366
|
+
const element = new OffscreenElement(tagName, uniqueId);
|
|
2367
|
+
element[ancestorDocument] = this;
|
|
2368
|
+
this[_uniqueIdToElement][uniqueId] = new WeakRef(element);
|
|
2369
|
+
this[operations].push(OperationType.CreateElement, uniqueId, tagName);
|
|
2370
|
+
return element;
|
|
2371
|
+
}
|
|
2372
|
+
[_onEvent] = (eventType, targetUniqueId, bubbles, otherProperties)=>{
|
|
2373
|
+
const target = this[getElementByUniqueId](targetUniqueId);
|
|
2374
|
+
if (target) {
|
|
2375
|
+
const bubblePath = [];
|
|
2376
|
+
let tempTarget = target;
|
|
2377
|
+
while(tempTarget.parentElement){
|
|
2378
|
+
bubblePath.push(tempTarget.parentElement);
|
|
2379
|
+
tempTarget = tempTarget.parentElement;
|
|
2380
|
+
}
|
|
2381
|
+
const event = new OffscreenEvent(eventType, target);
|
|
2382
|
+
Object.assign(event, otherProperties);
|
|
2383
|
+
event[eventPhase] = Event.CAPTURING_PHASE;
|
|
2384
|
+
for(let ii = bubblePath.length - 1; ii >= 0; ii--){
|
|
2385
|
+
const currentPhaseTarget = bubblePath[ii];
|
|
2386
|
+
currentPhaseTarget.dispatchEvent(event);
|
|
2387
|
+
if (event[propagationStopped]) return;
|
|
2388
|
+
}
|
|
2389
|
+
event[eventPhase] = Event.AT_TARGET;
|
|
2390
|
+
target.dispatchEvent(event);
|
|
2391
|
+
if (bubbles) {
|
|
2392
|
+
event[eventPhase] = Event.BUBBLING_PHASE;
|
|
2393
|
+
for (const currentPhaseTarget of bubblePath){
|
|
2394
|
+
currentPhaseTarget.dispatchEvent(event);
|
|
2395
|
+
if (event[propagationStopped]) return;
|
|
2396
|
+
}
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
};
|
|
2400
|
+
}
|
|
2401
|
+
const templateScrollView = `<style>
|
|
2402
|
+
.placeholder-dom {
|
|
2403
|
+
display: none;
|
|
2404
|
+
flex: 0 0 0;
|
|
2405
|
+
align-self: stretch;
|
|
2406
|
+
min-height: 0;
|
|
2407
|
+
min-width: 0;
|
|
2408
|
+
}
|
|
2409
|
+
.mask {
|
|
2410
|
+
z-index: 1;
|
|
2411
|
+
position: sticky;
|
|
2412
|
+
}
|
|
2413
|
+
.observer-container {
|
|
2414
|
+
flex-direction: inherit;
|
|
2415
|
+
overflow: visible;
|
|
2416
|
+
}
|
|
2417
|
+
.observer {
|
|
2418
|
+
display: flex;
|
|
2419
|
+
}
|
|
2420
|
+
::-webkit-scrollbar {
|
|
2421
|
+
display: none;
|
|
2422
|
+
}
|
|
2423
|
+
|
|
2424
|
+
@keyframes topFading {
|
|
2425
|
+
0% {
|
|
2426
|
+
box-shadow: transparent 0px 0px 0px 0px;
|
|
2427
|
+
}
|
|
2428
|
+
5% {
|
|
2429
|
+
box-shadow: var(--scroll-view-bg-color) 0px 0px
|
|
2430
|
+
var(--scroll-view-fading-edge-length)
|
|
2431
|
+
var(--scroll-view-fading-edge-length);
|
|
2432
|
+
}
|
|
2433
|
+
100% {
|
|
2434
|
+
box-shadow: var(--scroll-view-bg-color) 0px 0px
|
|
2435
|
+
var(--scroll-view-fading-edge-length)
|
|
2436
|
+
var(--scroll-view-fading-edge-length);
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
@keyframes botFading {
|
|
2440
|
+
0% {
|
|
2441
|
+
box-shadow: var(--scroll-view-bg-color) 0px 0px
|
|
2442
|
+
var(--scroll-view-fading-edge-length)
|
|
2443
|
+
var(--scroll-view-fading-edge-length);
|
|
2444
|
+
}
|
|
2445
|
+
95% {
|
|
2446
|
+
box-shadow: var(--scroll-view-bg-color) 0px 0px
|
|
2447
|
+
var(--scroll-view-fading-edge-length)
|
|
2448
|
+
var(--scroll-view-fading-edge-length);
|
|
2449
|
+
}
|
|
2450
|
+
100% {
|
|
2451
|
+
box-shadow: transparent 0px 0px 0px 0px;
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
</style>
|
|
2455
|
+
<div
|
|
2456
|
+
class="mask placeholder-dom"
|
|
2457
|
+
id="top-fade-mask"
|
|
2458
|
+
part="top-fade-mask"
|
|
2459
|
+
></div>
|
|
2460
|
+
<div
|
|
2461
|
+
class="observer-container placeholder-dom"
|
|
2462
|
+
part="upper-threshold-observer"
|
|
2463
|
+
>
|
|
2464
|
+
<div
|
|
2465
|
+
class="observer placeholder-dom"
|
|
2466
|
+
id="upper-threshold-observer"
|
|
2467
|
+
></div>
|
|
2468
|
+
</div>
|
|
2469
|
+
<slot></slot>
|
|
2470
|
+
<div
|
|
2471
|
+
class="observer-container placeholder-dom"
|
|
2472
|
+
part="lower-threshold-observer"
|
|
2473
|
+
>
|
|
2474
|
+
<div
|
|
2475
|
+
class="observer placeholder-dom"
|
|
2476
|
+
id="lower-threshold-observer"
|
|
2477
|
+
></div>
|
|
2478
|
+
</div>
|
|
2479
|
+
<div
|
|
2480
|
+
class="mask placeholder-dom"
|
|
2481
|
+
id="bot-fade-mask"
|
|
2482
|
+
part="bot-fade-mask"
|
|
2483
|
+
></div>`;
|
|
2484
|
+
const templateXAudioTT = '<audio id="audio"></audio>';
|
|
2485
|
+
const XSSDetector = /<\s*script/g;
|
|
2486
|
+
const templateXImage = (attributes)=>{
|
|
2487
|
+
const { src } = attributes;
|
|
2488
|
+
if (src && XSSDetector.test(src)) throw new Error("detected <script, this is a potential XSS attack, please check your src");
|
|
2489
|
+
return `<img part="img" alt="" loading="lazy" id="img" ${src ? `src="${src}"` : ''}/> `;
|
|
2490
|
+
};
|
|
2491
|
+
const templateFilterImage = templateXImage;
|
|
2492
|
+
const templateXInput = `<style>
|
|
2493
|
+
#input:focus {
|
|
2494
|
+
outline: none;
|
|
2495
|
+
}
|
|
2496
|
+
#form {
|
|
2497
|
+
display: none;
|
|
2498
|
+
}
|
|
2499
|
+
</style>
|
|
2500
|
+
<form id="form" part="form" method="dialog">
|
|
2501
|
+
<input
|
|
2502
|
+
id="input"
|
|
2503
|
+
part="input"
|
|
2504
|
+
step="any"
|
|
2505
|
+
type="text"
|
|
2506
|
+
inputmode="text"
|
|
2507
|
+
spell-check="true"
|
|
2508
|
+
/>
|
|
2509
|
+
</form>`;
|
|
2510
|
+
const templateXList = `<style>
|
|
2511
|
+
.placeholder-dom {
|
|
2512
|
+
display: none;
|
|
2513
|
+
flex: 0 0 0;
|
|
2514
|
+
align-self: stretch;
|
|
2515
|
+
min-height: 0;
|
|
2516
|
+
min-width: 0;
|
|
2517
|
+
}
|
|
2518
|
+
.observer-container {
|
|
2519
|
+
flex-direction: inherit;
|
|
2520
|
+
overflow: visible;
|
|
2521
|
+
}
|
|
2522
|
+
.observer {
|
|
2523
|
+
display: flex;
|
|
2524
|
+
}
|
|
2525
|
+
</style>
|
|
2526
|
+
<div id="content" part="content">
|
|
2527
|
+
<div
|
|
2528
|
+
class="observer-container placeholder-dom"
|
|
2529
|
+
part="upper-threshold-observer"
|
|
2530
|
+
>
|
|
2531
|
+
<div
|
|
2532
|
+
class="observer placeholder-dom"
|
|
2533
|
+
id="upper-threshold-observer"
|
|
2534
|
+
></div>
|
|
2535
|
+
</div>
|
|
2536
|
+
<slot part="slot"></slot>
|
|
2537
|
+
<div
|
|
2538
|
+
class="observer-container placeholder-dom"
|
|
2539
|
+
part="lower-threshold-observer"
|
|
2540
|
+
>
|
|
2541
|
+
<div
|
|
2542
|
+
class="observer placeholder-dom"
|
|
2543
|
+
id="lower-threshold-observer"
|
|
2544
|
+
></div>
|
|
2545
|
+
</div>
|
|
2546
|
+
</div>`;
|
|
2547
|
+
const templateXOverlayNg = `<style>
|
|
2548
|
+
#dialog[open] {
|
|
2549
|
+
top: 0;
|
|
2550
|
+
left: 0;
|
|
2551
|
+
right: 0;
|
|
2552
|
+
bottom: 0;
|
|
2553
|
+
position: fixed;
|
|
2554
|
+
}
|
|
2555
|
+
#dialog::backdrop {
|
|
2556
|
+
background-color: transparent;
|
|
2557
|
+
}
|
|
2558
|
+
</style>
|
|
2559
|
+
<dialog id="dialog" part="dialog">
|
|
2560
|
+
<slot></slot>
|
|
2561
|
+
</dialog>`;
|
|
2562
|
+
const templateXRefreshView = `<style>
|
|
2563
|
+
.bounce-container {
|
|
2564
|
+
overflow: scroll;
|
|
2565
|
+
overscroll-behavior: contain;
|
|
2566
|
+
scroll-snap-type: y mandatory;
|
|
2567
|
+
scroll-behavior: smooth;
|
|
2568
|
+
scrollbar-width: none;
|
|
2569
|
+
}
|
|
2570
|
+
.overflow-placeholder {
|
|
2571
|
+
min-height: 30%;
|
|
2572
|
+
min-width: 100%;
|
|
2573
|
+
flex-shrink: 0;
|
|
2574
|
+
scroll-snap-align: none;
|
|
2575
|
+
}
|
|
2576
|
+
.not-shrink {
|
|
2577
|
+
height: 100%;
|
|
2578
|
+
width: 100%;
|
|
2579
|
+
min-height: 100%;
|
|
2580
|
+
min-width: 100%;
|
|
2581
|
+
flex-shrink: 0;
|
|
2582
|
+
}
|
|
2583
|
+
.vertical {
|
|
2584
|
+
display: flex;
|
|
2585
|
+
flex-direction: column;
|
|
2586
|
+
}
|
|
2587
|
+
#content {
|
|
2588
|
+
scroll-snap-align: center;
|
|
2589
|
+
}
|
|
2590
|
+
</style>
|
|
2591
|
+
<div id="container" part="container" class="bounce-container not-shrink vertical">
|
|
2592
|
+
<div
|
|
2593
|
+
id="placeholder-top"
|
|
2594
|
+
class="overflow-placeholder bounce-item"
|
|
2595
|
+
part="placeholder-top"
|
|
2596
|
+
></div>
|
|
2597
|
+
<slot name="header"></slot>
|
|
2598
|
+
<div id="content" part="content" class="not-shrink vertical">
|
|
2599
|
+
<slot part="slot"></slot>
|
|
2600
|
+
</div>
|
|
2601
|
+
<slot name="footer"></slot>
|
|
2602
|
+
<div
|
|
2603
|
+
id="placeholder-bot"
|
|
2604
|
+
class="overflow-placeholder bounce-item"
|
|
2605
|
+
part="placeholder-bot"
|
|
2606
|
+
></div>
|
|
2607
|
+
</div>`;
|
|
2608
|
+
const templateXSwiper = `<style>
|
|
2609
|
+
#bounce-padding {
|
|
2610
|
+
display: none;
|
|
2611
|
+
flex: 0 0 0;
|
|
2612
|
+
align-self: stretch;
|
|
2613
|
+
scroll-snap-align: none;
|
|
2614
|
+
flex-basis: 100%;
|
|
2615
|
+
}
|
|
2616
|
+
#content {
|
|
2617
|
+
position: relative;
|
|
2618
|
+
display: flex;
|
|
2619
|
+
flex: 0 0 100%;
|
|
2620
|
+
flex-direction: inherit;
|
|
2621
|
+
flex-wrap: inherit;
|
|
2622
|
+
align-self: stretch;
|
|
2623
|
+
justify-content: inherit;
|
|
2624
|
+
align-items: inherit;
|
|
2625
|
+
overflow: inherit;
|
|
2626
|
+
scrollbar-width: none;
|
|
2627
|
+
scroll-snap-align: start;
|
|
2628
|
+
scroll-snap-type: inherit;
|
|
2629
|
+
}
|
|
2630
|
+
div::-webkit-scrollbar {
|
|
2631
|
+
display: none;
|
|
2632
|
+
}
|
|
2633
|
+
#indicator-container {
|
|
2634
|
+
display: none;
|
|
2635
|
+
}
|
|
2636
|
+
#indicator-container > div {
|
|
2637
|
+
animation-name: indicator-dot;
|
|
2638
|
+
animation-duration: 100ms;
|
|
2639
|
+
}
|
|
2640
|
+
@keyframes indicator-dot {
|
|
2641
|
+
30%,
|
|
2642
|
+
70% {
|
|
2643
|
+
background-color: var(--indicator-color);
|
|
2644
|
+
}
|
|
2645
|
+
31%,
|
|
2646
|
+
69% {
|
|
2647
|
+
background-color: var(--indicator-active-color);
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
</style>
|
|
2651
|
+
<style id="indicator-style"></style>
|
|
2652
|
+
<div id="bounce-padding" part="bounce-padding"></div>
|
|
2653
|
+
<div id="indicator-container" part="indicator-container"></div>
|
|
2654
|
+
<div id="content" part="content">
|
|
2655
|
+
<slot part="slot-start" name="circular-start" id="circular-start"></slot>
|
|
2656
|
+
<slot part="slot"></slot>
|
|
2657
|
+
<slot part="slot-end" name="circular-end" id="circular-end"></slot>
|
|
2658
|
+
</div>`;
|
|
2659
|
+
const templateXText = '<div id="inner-box" part="inner-box"><slot part="slot"></slot><slot name="inline-truncation"></slot></div>';
|
|
2660
|
+
const templateInlineImage = templateXImage;
|
|
2661
|
+
const templateXTextarea = `<style>
|
|
2662
|
+
#textarea:focus,
|
|
2663
|
+
#textarea:focus-visible {
|
|
2664
|
+
border: inherit;
|
|
2665
|
+
outline: inherit;
|
|
2666
|
+
}
|
|
2667
|
+
</style>
|
|
2668
|
+
<form id="form" part="form" method="dialog">
|
|
2669
|
+
<textarea id="textarea" part="textarea"></textarea>
|
|
2670
|
+
</form>`;
|
|
2671
|
+
const templateXViewpageNg = `<style>
|
|
2672
|
+
#bounce-padding {
|
|
2673
|
+
display: none;
|
|
2674
|
+
flex: 0 0 0;
|
|
2675
|
+
align-self: stretch;
|
|
2676
|
+
scroll-snap-align: none;
|
|
2677
|
+
flex-basis: 100%;
|
|
2678
|
+
}
|
|
2679
|
+
#content {
|
|
2680
|
+
flex: 0 0 100%;
|
|
2681
|
+
flex-direction: row;
|
|
2682
|
+
align-self: stretch;
|
|
2683
|
+
display: inherit;
|
|
2684
|
+
justify-content: inherit;
|
|
2685
|
+
align-items: inherit;
|
|
2686
|
+
overflow: inherit;
|
|
2687
|
+
scrollbar-width: none;
|
|
2688
|
+
scroll-snap-type: inherit;
|
|
2689
|
+
}
|
|
2690
|
+
#content::-webkit-scrollbar {
|
|
2691
|
+
display: none;
|
|
2692
|
+
}
|
|
2693
|
+
</style>
|
|
2694
|
+
<div id="bounce-padding" part="bounce-padding"></div>
|
|
2695
|
+
<div id="content" part="content">
|
|
2696
|
+
<slot></slot>
|
|
2697
|
+
</div>`;
|
|
2698
|
+
const matchHtmlRegExp = /["'&<>]/;
|
|
2699
|
+
function escapeHtml(string) {
|
|
2700
|
+
const str = '' + string;
|
|
2701
|
+
const match = matchHtmlRegExp.exec(str);
|
|
2702
|
+
if (!match) return str;
|
|
2703
|
+
let escape;
|
|
2704
|
+
let html = '';
|
|
2705
|
+
let index;
|
|
2706
|
+
let lastIndex = 0;
|
|
2707
|
+
for(index = match.index; index < str.length; index++){
|
|
2708
|
+
switch(str.charCodeAt(index)){
|
|
2709
|
+
case 34:
|
|
2710
|
+
escape = '"';
|
|
2711
|
+
break;
|
|
2712
|
+
case 38:
|
|
2713
|
+
escape = '&';
|
|
2714
|
+
break;
|
|
2715
|
+
case 39:
|
|
2716
|
+
escape = ''';
|
|
2717
|
+
break;
|
|
2718
|
+
case 60:
|
|
2719
|
+
escape = '<';
|
|
2720
|
+
break;
|
|
2721
|
+
case 62:
|
|
2722
|
+
escape = '>';
|
|
2723
|
+
break;
|
|
2724
|
+
default:
|
|
2725
|
+
continue;
|
|
2726
|
+
}
|
|
2727
|
+
if (lastIndex !== index) html += str.substring(lastIndex, index);
|
|
2728
|
+
lastIndex = index + 1;
|
|
2729
|
+
html += escape;
|
|
2730
|
+
}
|
|
2731
|
+
return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
|
|
2732
|
+
}
|
|
2733
|
+
function getInnerHTMLImpl(buffer, element, shadowrootTemplates) {
|
|
2734
|
+
const localName = element.localName;
|
|
2735
|
+
buffer.push('<');
|
|
2736
|
+
buffer.push(localName);
|
|
2737
|
+
for (const [key, value] of element[_attributes]){
|
|
2738
|
+
buffer.push(' ');
|
|
2739
|
+
buffer.push(key);
|
|
2740
|
+
if (value.length > 0) {
|
|
2741
|
+
buffer.push('="');
|
|
2742
|
+
buffer.push(escapeHtml(value));
|
|
2743
|
+
buffer.push('"');
|
|
2744
|
+
}
|
|
2745
|
+
}
|
|
2746
|
+
const partId = element[_attributes].get(lynxPartIdAttribute) ?? element[_attributes].get(lynxUniqueIdAttribute);
|
|
2747
|
+
buffer.push(' ', lynxPartIdAttribute, '="', partId, '"');
|
|
2748
|
+
buffer.push('>');
|
|
2749
|
+
const templateImpl = shadowrootTemplates[localName];
|
|
2750
|
+
if (templateImpl) {
|
|
2751
|
+
const template = 'function' == typeof templateImpl ? templateImpl(Object.fromEntries(element[_attributes].entries())) : templateImpl;
|
|
2752
|
+
buffer.push('<template shadowrootmode="open">', template, '</template>');
|
|
2753
|
+
}
|
|
2754
|
+
if (element[_cssRuleContents]?.length) buffer.push(...element[_cssRuleContents]);
|
|
2755
|
+
if (element[innerHTML]) buffer.push(element[innerHTML]);
|
|
2756
|
+
else for (const child of element[_children])getInnerHTMLImpl(buffer, child, shadowrootTemplates);
|
|
2757
|
+
buffer.push('</');
|
|
2758
|
+
buffer.push(localName);
|
|
2759
|
+
buffer.push('>');
|
|
2760
|
+
}
|
|
2761
|
+
function dumpHTMLString(buffer, element, shadowrootTemplates) {
|
|
2762
|
+
for (const child of element[_children])getInnerHTMLImpl(buffer, child, shadowrootTemplates);
|
|
2763
|
+
}
|
|
2764
|
+
const builtinElementTemplates = {
|
|
2765
|
+
'scroll-view': templateScrollView,
|
|
2766
|
+
'x-audio-tt': templateXAudioTT,
|
|
2767
|
+
'x-image': templateXImage,
|
|
2768
|
+
'filter-image': templateFilterImage,
|
|
2769
|
+
'x-input': templateXInput,
|
|
2770
|
+
'x-list': templateXList,
|
|
2771
|
+
'x-overlay-ng': templateXOverlayNg,
|
|
2772
|
+
'x-refresh-view': templateXRefreshView,
|
|
2773
|
+
'x-swiper': templateXSwiper,
|
|
2774
|
+
'x-text': templateXText,
|
|
2775
|
+
'inline-image': templateInlineImage,
|
|
2776
|
+
'x-textarea': templateXTextarea,
|
|
2777
|
+
'x-viewpage-ng': templateXViewpageNg
|
|
2778
|
+
};
|
|
2779
|
+
const builtinTagTransformMap = {
|
|
2780
|
+
page: 'div',
|
|
2781
|
+
view: 'x-view',
|
|
2782
|
+
text: 'x-text',
|
|
2783
|
+
image: 'x-image',
|
|
2784
|
+
list: 'x-list',
|
|
2785
|
+
svg: 'x-svg'
|
|
2786
|
+
};
|
|
2787
|
+
OffscreenElement.prototype.toJSON = function() {
|
|
2788
|
+
return {
|
|
2789
|
+
ssrID: this[_attributes].get(lynxPartIdAttribute) ?? this[_attributes].get(lynxUniqueIdAttribute)
|
|
2790
|
+
};
|
|
2791
|
+
};
|
|
2792
|
+
async function createLynxView(config) {
|
|
2793
|
+
const { template: rawTemplate, browserConfig, tagMap, initData, globalProps, overrideElementTemplates = {}, hydrateUrl, autoSize, injectStyles, lynxViewStyle, threadStrategy = 'all-on-ui', initI18nResources } = config;
|
|
2794
|
+
const template = await loadTemplate(rawTemplate, config.templateName);
|
|
2795
|
+
const { promise: firstPaintReadyPromise, resolve: firstPaintReady } = Promise.withResolvers();
|
|
2796
|
+
const mainWithBackgroundChannel = new MessageChannel();
|
|
2797
|
+
const backgroundThreadRpc = new Rpc(mainWithBackgroundChannel.port1, 'background-thread');
|
|
2798
|
+
const offscreenDocument = new OffscreenDocument({
|
|
2799
|
+
onCommit: ()=>{}
|
|
2800
|
+
});
|
|
2801
|
+
const i18nResources = new I18nResources();
|
|
2802
|
+
const events = [];
|
|
2803
|
+
const { startMainThread } = prepareMainThreadAPIs(backgroundThreadRpc, offscreenDocument, offscreenDocument.createElement.bind(offscreenDocument), ()=>{
|
|
2804
|
+
firstPaintReady();
|
|
2805
|
+
}, ()=>{}, ()=>{}, ()=>{}, ()=>{}, (initI18nResources)=>{
|
|
2806
|
+
i18nResources.setData(initI18nResources);
|
|
2807
|
+
return i18nResources;
|
|
2808
|
+
}, {
|
|
2809
|
+
__AddEvent (element, eventName, eventData, eventOptions) {
|
|
2810
|
+
events.push([
|
|
2811
|
+
Number(element.getAttribute(lynxUniqueIdAttribute)),
|
|
2812
|
+
eventName,
|
|
2813
|
+
eventData,
|
|
2814
|
+
eventOptions
|
|
2815
|
+
]);
|
|
2816
|
+
}
|
|
2817
|
+
});
|
|
2818
|
+
const runtime = await startMainThread({
|
|
2819
|
+
template,
|
|
2820
|
+
initData,
|
|
2821
|
+
globalProps,
|
|
2822
|
+
browserConfig,
|
|
2823
|
+
nativeModulesMap: {},
|
|
2824
|
+
napiModulesMap: {},
|
|
2825
|
+
tagMap: {
|
|
2826
|
+
...builtinTagTransformMap,
|
|
2827
|
+
...tagMap
|
|
2828
|
+
},
|
|
2829
|
+
initI18nResources
|
|
2830
|
+
});
|
|
2831
|
+
const elementTemplates = {
|
|
2832
|
+
...builtinElementTemplates,
|
|
2833
|
+
...overrideElementTemplates
|
|
2834
|
+
};
|
|
2835
|
+
async function renderToString() {
|
|
2836
|
+
await firstPaintReadyPromise;
|
|
2837
|
+
const ssrEncodeData = runtime?.ssrEncode?.();
|
|
2838
|
+
const ssrDumpInfo = {
|
|
2839
|
+
ssrEncodeData,
|
|
2840
|
+
events
|
|
2841
|
+
};
|
|
2842
|
+
const buffer = [];
|
|
2843
|
+
buffer.push('<lynx-view url="', hydrateUrl, '" ssr ="', encodeURI(JSON.stringify(ssrDumpInfo)), '" ', 'thread-strategy="', threadStrategy, '"');
|
|
2844
|
+
if (autoSize) buffer.push(' height="auto" width="auto"');
|
|
2845
|
+
if (lynxViewStyle) buffer.push(' style="', lynxViewStyle, '"');
|
|
2846
|
+
buffer.push('><template shadowrootmode="open">', '<style>', injectStyles, '\n', inShadowRootStyles.join('\n'), '</style>');
|
|
2847
|
+
dumpHTMLString(buffer, offscreenDocument, elementTemplates);
|
|
2848
|
+
buffer.push('</template>');
|
|
2849
|
+
buffer.push('</lynx-view>');
|
|
2850
|
+
return buffer.join('');
|
|
2851
|
+
}
|
|
2852
|
+
return {
|
|
2853
|
+
renderToString
|
|
2854
|
+
};
|
|
2855
|
+
}
|
|
2856
|
+
if (!globalThis.requestAnimationFrame) {
|
|
2857
|
+
globalThis.requestAnimationFrame = (cb)=>setTimeout(cb, 0);
|
|
2858
|
+
globalThis.cancelAnimationFrame = (id)=>{
|
|
8
2859
|
clearTimeout(id);
|
|
9
2860
|
};
|
|
10
2861
|
}
|
|
2862
|
+
export { createLynxView };
|
|
2863
|
+
|
|
11
2864
|
//# sourceMappingURL=index.js.map
|