@lynx-js/web-core-server 0.19.4 → 0.19.6

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/dist/131.js ADDED
@@ -0,0 +1,1395 @@
1
+ import { __webpack_require__ } from "./rslib-runtime.js";
2
+ import node_os from "node:os";
3
+ import promises from "node:fs/promises";
4
+ import node_path from "node:path";
5
+ import node_vm from "node:vm";
6
+ import node_fs from "node:fs";
7
+ __webpack_require__.add({
8
+ "../web-constants/dist/constants.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
9
+ __webpack_require__.d(__webpack_exports__, {
10
+ Gm: ()=>lynxDefaultDisplayLinearAttribute,
11
+ Gq: ()=>lynxTagAttribute,
12
+ I7: ()=>__lynx_timing_flag,
13
+ JA: ()=>lynxDisposedAttribute,
14
+ OE: ()=>inShadowRootStyles,
15
+ Pb: ()=>lynxEntryNameAttribute,
16
+ c1: ()=>systemInfo,
17
+ er: ()=>parentComponentUniqueIdAttribute,
18
+ js: ()=>cssIdAttribute,
19
+ pP: ()=>componentIdAttribute,
20
+ tl: ()=>lynxComponentConfigAttribute,
21
+ y: ()=>lynxElementTemplateMarkerAttribute
22
+ });
23
+ const cssIdAttribute = 'l-css-id';
24
+ const componentIdAttribute = 'l-comp-id';
25
+ const parentComponentUniqueIdAttribute = 'l-p-comp-uid';
26
+ const lynxEntryNameAttribute = 'l-e-name';
27
+ const lynxTagAttribute = 'lynx-tag';
28
+ const lynxComponentConfigAttribute = 'l-comp-cfg';
29
+ const lynxDisposedAttribute = 'l-disposed';
30
+ const lynxElementTemplateMarkerAttribute = 'l-template';
31
+ const lynxDefaultDisplayLinearAttribute = 'lynx-default-display-linear';
32
+ const __lynx_timing_flag = '__lynx_timing_flag';
33
+ const systemInfo = {
34
+ platform: 'web',
35
+ lynxSdkVersion: '3.0'
36
+ };
37
+ const inShadowRootStyles = [
38
+ ` [lynx-default-display-linear="false"] * {
39
+ --lynx-display: flex;
40
+ --lynx-display-toggle: var(--lynx-display-flex);
41
+ }`,
42
+ `[lynx-default-overflow-visible="true"] x-view{
43
+ overflow: visible;
44
+ }`
45
+ ];
46
+ },
47
+ "../web-constants/dist/endpoints.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
48
+ __webpack_require__.d(__webpack_exports__, {
49
+ F6: ()=>postTimingFlagsEndpoint,
50
+ Fw: ()=>getCustomSectionsEndpoint,
51
+ Is: ()=>dispatchJSContextOnMainThreadEndpoint,
52
+ JW: ()=>publishEventEndpoint,
53
+ Ke: ()=>publicComponentEventEndpoint,
54
+ Ve: ()=>updateDataEndpoint,
55
+ WS: ()=>updateBTSTemplateCacheEndpoint,
56
+ a$: ()=>BackgroundThreadStartEndpoint,
57
+ eZ: ()=>switchExposureServiceEndpoint,
58
+ iH: ()=>callLepusMethodEndpoint,
59
+ jK: ()=>dispatchCoreContextOnBackgroundEndpoint,
60
+ mB: ()=>dispatchI18nResourceEndpoint,
61
+ nk: ()=>queryComponentEndpoint,
62
+ pd: ()=>postExposureEndpoint
63
+ });
64
+ var _lynx_js_web_worker_rpc__rspack_import_0 = __webpack_require__("../web-worker-rpc/dist/RpcEndpoint.js");
65
+ const postExposureEndpoint = (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('__postExposure', false, false);
66
+ const publicComponentEventEndpoint = (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('publicComponentEvent', false, false);
67
+ const publishEventEndpoint = (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('publishEvent', false, false);
68
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('postOffscreenEventEndpoint', false, false);
69
+ const switchExposureServiceEndpoint = (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('switchExposureServiceEndpoint', false, false);
70
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('mainThreadStart', false, false);
71
+ const updateDataEndpoint = (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('updateData', false, true);
72
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('sendGlobalEventEndpoint', false, false);
73
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('dispose', false, true);
74
+ const BackgroundThreadStartEndpoint = (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('start', false, true);
75
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('reportError', false, false);
76
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('flushElementTree', false, true);
77
+ const callLepusMethodEndpoint = (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('callLepusMethod', false, true);
78
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('multiThreadExposureChangedEndpoint', false, false);
79
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('__invokeUIMethod', false, true);
80
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('__setNativeProps', false, true);
81
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('__getPathInfo', false, true);
82
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('nativeModulesCall', false, true);
83
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('napiModulesCall', false, true, true);
84
+ const getCustomSectionsEndpoint = (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('getCustomSections', false, true);
85
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('markTiming', false, false);
86
+ const postTimingFlagsEndpoint = (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('postTimingFlags', false, false);
87
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('__triggerComponentEvent', false, false);
88
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('__selectComponent', false, true);
89
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('dispatchLynxViewEvent', false, false);
90
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('dispatchNapiModule', false, false);
91
+ const dispatchCoreContextOnBackgroundEndpoint = (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('dispatchCoreContextOnBackground', false, false);
92
+ const dispatchJSContextOnMainThreadEndpoint = (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('dispatchJSContextOnMainThread', false, false);
93
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('__triggerElementMethod', false, false);
94
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('updateGlobalProps', false, false);
95
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('updateI18nResources', false, false);
96
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('updateI18nResource', false, false);
97
+ const dispatchI18nResourceEndpoint = (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('dispatchI18nResource', false, false);
98
+ const queryComponentEndpoint = (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('queryComponent', false, true);
99
+ const updateBTSTemplateCacheEndpoint = (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('updateBTSTemplateCacheEndpoint', false, true);
100
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('loadTemplateMultiThread', false, true);
101
+ (0, _lynx_js_web_worker_rpc__rspack_import_0.H)('reload', false, false);
102
+ },
103
+ "../web-constants/dist/eventName.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
104
+ __webpack_require__.d(__webpack_exports__, {
105
+ $4: ()=>W3cEventNameToLynx,
106
+ im: ()=>LynxEventNameToW3cCommon,
107
+ vQ: ()=>LynxEventNameToW3cByTagName
108
+ });
109
+ const W3cEventNameToLynx = {
110
+ click: 'tap',
111
+ lynxscroll: 'scroll',
112
+ lynxscrollend: 'scrollend',
113
+ overlaytouch: 'touch',
114
+ lynxfocus: 'focus',
115
+ lynxblur: 'blur',
116
+ lynxinput: 'input'
117
+ };
118
+ const LynxEventNameToW3cByTagName = {
119
+ 'X-INPUT': {
120
+ blur: 'lynxblur',
121
+ focus: 'lynxfocus',
122
+ input: 'lynxinput'
123
+ },
124
+ 'X-TEXTAREA': {
125
+ blur: 'lynxblur',
126
+ focus: 'lynxfocus',
127
+ input: 'lynxinput'
128
+ }
129
+ };
130
+ const LynxEventNameToW3cCommon = {
131
+ tap: 'click',
132
+ scroll: 'lynxscroll',
133
+ scrollend: 'lynxscrollend',
134
+ touch: 'overlaytouch'
135
+ };
136
+ },
137
+ "../web-constants/dist/index.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
138
+ __webpack_require__.d(__webpack_exports__, {
139
+ $4: ()=>_eventName_js__rspack_import_1.$4,
140
+ C6: ()=>"l-dset",
141
+ F6: ()=>_endpoints_js__rspack_import_2.F6,
142
+ Fw: ()=>_endpoints_js__rspack_import_2.Fw,
143
+ Gm: ()=>_constants_js__rspack_import_0.Gm,
144
+ Gq: ()=>_constants_js__rspack_import_0.Gq,
145
+ HO: ()=>_types_index_js__rspack_import_3.HO,
146
+ I7: ()=>_constants_js__rspack_import_0.I7,
147
+ Is: ()=>_endpoints_js__rspack_import_2.Is,
148
+ JA: ()=>_constants_js__rspack_import_0.JA,
149
+ JW: ()=>_endpoints_js__rspack_import_2.JW,
150
+ Ke: ()=>_endpoints_js__rspack_import_2.Ke,
151
+ O4: ()=>_types_index_js__rspack_import_3.O4,
152
+ OE: ()=>_constants_js__rspack_import_0.OE,
153
+ Pb: ()=>_constants_js__rspack_import_0.Pb,
154
+ SP: ()=>"l-uid",
155
+ Ve: ()=>_endpoints_js__rspack_import_2.Ve,
156
+ WS: ()=>_endpoints_js__rspack_import_2.WS,
157
+ Yx: ()=>_utils_index_js__rspack_import_4.Yx,
158
+ a$: ()=>_endpoints_js__rspack_import_2.a$,
159
+ c1: ()=>_constants_js__rspack_import_0.c1,
160
+ eZ: ()=>_endpoints_js__rspack_import_2.eZ,
161
+ er: ()=>_constants_js__rspack_import_0.er,
162
+ gI: ()=>_types_index_js__rspack_import_3.gI,
163
+ iH: ()=>_endpoints_js__rspack_import_2.iH,
164
+ im: ()=>_eventName_js__rspack_import_1.im,
165
+ jK: ()=>_endpoints_js__rspack_import_2.jK,
166
+ js: ()=>_constants_js__rspack_import_0.js,
167
+ mB: ()=>_endpoints_js__rspack_import_2.mB,
168
+ nk: ()=>_endpoints_js__rspack_import_2.nk,
169
+ oZ: ()=>"l-part",
170
+ pP: ()=>_constants_js__rspack_import_0.pP,
171
+ pd: ()=>_endpoints_js__rspack_import_2.pd,
172
+ tf: ()=>_utils_index_js__rspack_import_4.tf,
173
+ tl: ()=>_constants_js__rspack_import_0.tl,
174
+ vQ: ()=>_eventName_js__rspack_import_1.vQ,
175
+ y: ()=>_constants_js__rspack_import_0.y
176
+ });
177
+ var _constants_js__rspack_import_0 = __webpack_require__("../web-constants/dist/constants.js");
178
+ var _eventName_js__rspack_import_1 = __webpack_require__("../web-constants/dist/eventName.js");
179
+ var _endpoints_js__rspack_import_2 = __webpack_require__("../web-constants/dist/endpoints.js");
180
+ var _types_index_js__rspack_import_3 = __webpack_require__("../web-constants/dist/types/index.js");
181
+ var _utils_index_js__rspack_import_4 = __webpack_require__("../web-constants/dist/utils/index.js");
182
+ },
183
+ "../web-constants/dist/types/Element.js" () {
184
+ var AnimationOperation;
185
+ (function(AnimationOperation) {
186
+ AnimationOperation[AnimationOperation["START"] = 0] = "START";
187
+ AnimationOperation[AnimationOperation["PLAY"] = 1] = "PLAY";
188
+ AnimationOperation[AnimationOperation["PAUSE"] = 2] = "PAUSE";
189
+ AnimationOperation[AnimationOperation["CANCEL"] = 3] = "CANCEL";
190
+ AnimationOperation[AnimationOperation["FINISH"] = 4] = "FINISH";
191
+ })(AnimationOperation || (AnimationOperation = {}));
192
+ },
193
+ "../web-constants/dist/types/I18n.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
194
+ __webpack_require__.d(__webpack_exports__, {
195
+ HO: ()=>getCacheI18nResourcesKey,
196
+ gI: ()=>I18nResources
197
+ });
198
+ const getCacheI18nResourcesKey = (options)=>`${options.locale}_${options.channel}_${options.fallback_url}`;
199
+ class I18nResources {
200
+ data;
201
+ constructor(data){
202
+ this.data = data;
203
+ }
204
+ setData(data) {
205
+ this.data = data;
206
+ }
207
+ }
208
+ },
209
+ "../web-constants/dist/types/LynxContextEventTarget.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
210
+ __webpack_require__.d(__webpack_exports__, {
211
+ U: ()=>DispatchEventResult
212
+ });
213
+ const DispatchEventResult = {
214
+ NotCanceled: 0,
215
+ CanceledByEventHandler: 1,
216
+ CanceledByDefaultEventHandler: 2,
217
+ CanceledBeforeDispatch: 3
218
+ };
219
+ },
220
+ "../web-constants/dist/types/NativeApp.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
221
+ __webpack_require__.d(__webpack_exports__, {
222
+ O: ()=>ErrorCode
223
+ });
224
+ var IdentifierType;
225
+ (function(IdentifierType) {
226
+ IdentifierType[IdentifierType["ID_SELECTOR"] = 0] = "ID_SELECTOR";
227
+ IdentifierType[IdentifierType["REF_ID"] = 1] = "REF_ID";
228
+ IdentifierType[IdentifierType["UNIQUE_ID"] = 2] = "UNIQUE_ID";
229
+ })(IdentifierType || (IdentifierType = {}));
230
+ var ErrorCode;
231
+ (function(ErrorCode) {
232
+ ErrorCode[ErrorCode["SUCCESS"] = 0] = "SUCCESS";
233
+ ErrorCode[ErrorCode["UNKNOWN"] = 1] = "UNKNOWN";
234
+ ErrorCode[ErrorCode["NODE_NOT_FOUND"] = 2] = "NODE_NOT_FOUND";
235
+ ErrorCode[ErrorCode["METHOD_NOT_FOUND"] = 3] = "METHOD_NOT_FOUND";
236
+ ErrorCode[ErrorCode["PARAM_INVALID"] = 4] = "PARAM_INVALID";
237
+ ErrorCode[ErrorCode["SELECTOR_NOT_SUPPORTED"] = 5] = "SELECTOR_NOT_SUPPORTED";
238
+ ErrorCode[ErrorCode["NO_UI_FOR_NODE"] = 6] = "NO_UI_FOR_NODE";
239
+ })(ErrorCode || (ErrorCode = {}));
240
+ },
241
+ "../web-constants/dist/types/UpdateDataOptions.js" () {
242
+ var NativeUpdateDataType;
243
+ (function(NativeUpdateDataType) {
244
+ NativeUpdateDataType[NativeUpdateDataType["UPDATE"] = 0] = "UPDATE";
245
+ NativeUpdateDataType[NativeUpdateDataType["RESET"] = 1] = "RESET";
246
+ })(NativeUpdateDataType || (NativeUpdateDataType = {}));
247
+ },
248
+ "../web-constants/dist/types/index.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
249
+ __webpack_require__.d(__webpack_exports__, {
250
+ HO: ()=>_I18n_js__rspack_import_3.HO,
251
+ O4: ()=>_NativeApp_js__rspack_import_0.O,
252
+ gI: ()=>_I18n_js__rspack_import_3.gI
253
+ });
254
+ var _NativeApp_js__rspack_import_0 = __webpack_require__("../web-constants/dist/types/NativeApp.js");
255
+ __webpack_require__("../web-constants/dist/types/UpdateDataOptions.js");
256
+ __webpack_require__("../web-constants/dist/types/Element.js");
257
+ var _I18n_js__rspack_import_3 = __webpack_require__("../web-constants/dist/types/I18n.js");
258
+ },
259
+ "../web-constants/dist/utils/LynxCrossThreadContext.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
260
+ __webpack_require__.d(__webpack_exports__, {
261
+ t: ()=>LynxCrossThreadContext
262
+ });
263
+ var _types_LynxContextEventTarget_js__rspack_import_0 = __webpack_require__("../web-constants/dist/types/LynxContextEventTarget.js");
264
+ class LynxCrossThreadContext extends EventTarget {
265
+ _config;
266
+ constructor(_config){
267
+ super();
268
+ this._config = _config;
269
+ }
270
+ postMessage(...args) {
271
+ console.error('[lynx-web] postMessage not implemented, args:', ...args);
272
+ }
273
+ dispatchEvent(event) {
274
+ const { rpc, sendEventEndpoint } = this._config;
275
+ rpc.invoke(sendEventEndpoint, [
276
+ event
277
+ ]);
278
+ return _types_LynxContextEventTarget_js__rspack_import_0.U.CanceledBeforeDispatch;
279
+ }
280
+ __start() {
281
+ const { rpc, receiveEventEndpoint } = this._config;
282
+ rpc.registerHandler(receiveEventEndpoint, ({ type, data })=>{
283
+ super.dispatchEvent(new MessageEvent(type, {
284
+ data: data ?? {}
285
+ }));
286
+ });
287
+ }
288
+ }
289
+ },
290
+ "../web-constants/dist/utils/generateTemplate.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
291
+ __webpack_require__.d(__webpack_exports__, {
292
+ Y: ()=>generateTemplate
293
+ });
294
+ const currentSupportedTemplateVersion = 2;
295
+ const globalDisallowedVars = [
296
+ 'navigator',
297
+ 'postMessage',
298
+ 'window'
299
+ ];
300
+ const templateUpgraders = [
301
+ (template)=>{
302
+ template.appType = template.appType ?? (template.lepusCode.root.startsWith('(function (globDynamicComponentEntry') ? 'lazy' : 'card');
303
+ template.version = 2;
304
+ template.lepusCode = Object.fromEntries(Object.entries(template.lepusCode).filter(([_, content])=>'string' == typeof content));
305
+ return template;
306
+ }
307
+ ];
308
+ const generateModuleContent = (fileName, content, eager, appType)=>[
309
+ eager ? '//# allFunctionsCalledOnLoad' : '',
310
+ '\n(function() { "use strict"; const ',
311
+ globalDisallowedVars.join('=void 0,'),
312
+ '=void 0;\n',
313
+ 'card' !== appType ? 'module.exports=\n' : '',
314
+ content,
315
+ '\n})()',
316
+ '\n//# sourceURL=',
317
+ fileName
318
+ ].join('');
319
+ async function generateJavascriptUrl(obj, createJsModuleUrl, eager, appType, templateName) {
320
+ return Promise.all(Object.entries(obj).filter(([_, content])=>'string' == typeof content).map(async ([name, content])=>[
321
+ name,
322
+ await createJsModuleUrl(generateModuleContent(`${templateName}/${name.replaceAll('/', '_')}.js`, content, eager, appType), `${templateName}-${name.replaceAll('/', '_')}.js`)
323
+ ])).then(Object.fromEntries);
324
+ }
325
+ async function generateTemplate(template, createJsModuleUrl, templateName) {
326
+ template.version = template.version ?? 1;
327
+ if (template.version > currentSupportedTemplateVersion) throw new Error("Unsupported template, please upgrade your web-platform dependencies");
328
+ let upgrader;
329
+ while(template.version < currentSupportedTemplateVersion && (upgrader = templateUpgraders[template.version - 1]))template = upgrader(template);
330
+ return {
331
+ ...template,
332
+ lepusCode: await generateJavascriptUrl(template.lepusCode, createJsModuleUrl, true, template.appType, templateName)
333
+ };
334
+ }
335
+ },
336
+ "../web-constants/dist/utils/index.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
337
+ __webpack_require__.d(__webpack_exports__, {
338
+ Yx: ()=>_generateTemplate_js__rspack_import_1.Y,
339
+ tf: ()=>_LynxCrossThreadContext_js__rspack_import_0.t
340
+ });
341
+ var _LynxCrossThreadContext_js__rspack_import_0 = __webpack_require__("../web-constants/dist/utils/LynxCrossThreadContext.js");
342
+ var _generateTemplate_js__rspack_import_1 = __webpack_require__("../web-constants/dist/utils/generateTemplate.js");
343
+ },
344
+ "../web-worker-rpc/dist/Rpc.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
345
+ __webpack_require__.d(__webpack_exports__, {
346
+ C: ()=>Rpc
347
+ });
348
+ class Rpc {
349
+ port;
350
+ name;
351
+ incId = 0;
352
+ #messageQueue = [];
353
+ #messageCache = {};
354
+ #textEncoder = new TextEncoder();
355
+ #textDecoder = new TextDecoder();
356
+ #handlerMap = new Map();
357
+ constructor(port, name){
358
+ this.port = port;
359
+ this.name = name;
360
+ if (port) port.onmessage = (ev)=>this.#onMessage(ev.data);
361
+ }
362
+ setMessagePort(port) {
363
+ if (this.port) throw new Error('Rpc port already set');
364
+ this.port = port;
365
+ for (const item of this.#messageQueue)this.postMessage(item.message, item.detail);
366
+ this.#messageQueue = [];
367
+ port.onmessage = (ev)=>this.#onMessage(ev.data);
368
+ }
369
+ postMessage(message, detail) {
370
+ if (this.port) this.port.postMessage(message, detail);
371
+ else this.#messageQueue.push({
372
+ message: message,
373
+ detail
374
+ });
375
+ }
376
+ get nextRetId() {
377
+ return `ret_${this.name}_${this.incId++}`;
378
+ }
379
+ static createRetEndpoint(retId) {
380
+ return {
381
+ name: retId,
382
+ hasReturn: false,
383
+ isSync: false
384
+ };
385
+ }
386
+ #onMessage = async (message)=>{
387
+ const handler = this.#handlerMap.get(message.name);
388
+ if (handler) {
389
+ const lockViewer = message.sync ? new Int32Array(message.lock) : void 0;
390
+ const replyTempEndpoint = !message.sync && message.retId ? Rpc.createRetEndpoint(message.retId) : void 0;
391
+ try {
392
+ const result = await handler(...message.data);
393
+ let retData, transfer = [];
394
+ if (message.sync) retData = result;
395
+ else if (message.hasTransfer) ({ data: retData, transfer } = result || {});
396
+ else retData = result;
397
+ if (message.sync) {
398
+ if (message.buf) {
399
+ const retStr = JSON.stringify(retData);
400
+ const lengthViewer = new Uint32Array(message.buf, 0, 1);
401
+ const bufViewer = new Uint8Array(message.buf, 4);
402
+ const retCache = new Uint8Array(message.buf.byteLength - 4);
403
+ const { written: byteLength } = this.#textEncoder.encodeInto(retStr, retCache);
404
+ lengthViewer[0] = byteLength;
405
+ bufViewer.set(retCache, 0);
406
+ }
407
+ Atomics.store(lockViewer, 0, 1);
408
+ Atomics.notify(lockViewer, 0);
409
+ } else if (message.retId) this.invoke(replyTempEndpoint, [
410
+ retData,
411
+ false
412
+ ], transfer || []);
413
+ } catch (e) {
414
+ console.error(e);
415
+ if (message.sync) {
416
+ Atomics.store(lockViewer, 0, 2);
417
+ Atomics.notify(lockViewer, 0);
418
+ lockViewer[1] = 2;
419
+ } else this.invoke(replyTempEndpoint, [
420
+ void 0,
421
+ true
422
+ ]);
423
+ }
424
+ } else {
425
+ const cache = this.#messageCache[message.name];
426
+ if (cache) cache.push(message);
427
+ else this.#messageCache[message.name] = [
428
+ message
429
+ ];
430
+ }
431
+ };
432
+ createCall(endpoint) {
433
+ return (...args)=>this.invoke(endpoint, args);
434
+ }
435
+ registerHandler(endpoint, handler) {
436
+ this.#handlerMap.set(endpoint.name, handler);
437
+ const currentCache = this.#messageCache[endpoint.name];
438
+ if (currentCache?.length) {
439
+ this.#messageCache[endpoint.name] = void 0;
440
+ for (const message of currentCache)this.#onMessage(message);
441
+ }
442
+ }
443
+ registerHandlerRef(endpoint, target, propertyName) {
444
+ this.registerHandler(endpoint, (...args)=>target[propertyName]?.call(target, ...args));
445
+ }
446
+ registerHandlerLazy(endpoint, target, propertyName) {
447
+ if (target[propertyName]) this.registerHandlerRef(endpoint, target, propertyName);
448
+ else {
449
+ let property;
450
+ const rpc = this;
451
+ Object.defineProperty(target, propertyName, {
452
+ get () {
453
+ return property;
454
+ },
455
+ set (v) {
456
+ property = v;
457
+ if (v) rpc.registerHandlerRef(endpoint, target, propertyName);
458
+ }
459
+ });
460
+ }
461
+ }
462
+ removeHandler(rpc) {
463
+ this.#handlerMap.delete(rpc.name);
464
+ }
465
+ invoke(endpoint, parameters, transfer = []) {
466
+ if (endpoint.isSync) {
467
+ const sharedBuffer = endpoint.bufferSize ? new SharedArrayBuffer(endpoint.bufferSize + 4) : void 0;
468
+ const lock = new SharedArrayBuffer(4);
469
+ const lockViewer = new Int32Array(lock);
470
+ lockViewer[0] = 0;
471
+ const message = {
472
+ name: endpoint.name,
473
+ data: parameters,
474
+ sync: true,
475
+ lock: lock,
476
+ buf: sharedBuffer
477
+ };
478
+ this.postMessage(message, {
479
+ transfer
480
+ });
481
+ Atomics.wait(lockViewer, 0, 0);
482
+ if (2 === lockViewer[0]) throw null;
483
+ if (!sharedBuffer) return;
484
+ {
485
+ const byteLength = new Uint32Array(sharedBuffer, 0, 4)[0];
486
+ const sharedBufferView = new Uint8Array(sharedBuffer, 4, byteLength);
487
+ const localBuf = new Uint8Array(byteLength);
488
+ localBuf.set(sharedBufferView, 0);
489
+ const ret = localBuf ? JSON.parse(this.#textDecoder.decode(localBuf)) : void 0;
490
+ return ret;
491
+ }
492
+ }
493
+ if (endpoint.hasReturn) {
494
+ let promise, resolve, reject;
495
+ promise = new Promise((res, rej)=>{
496
+ resolve = res;
497
+ reject = rej;
498
+ });
499
+ const retHandler = Rpc.createRetEndpoint(this.nextRetId);
500
+ this.registerHandler(retHandler, (returnValue, error)=>{
501
+ if (error) reject();
502
+ resolve(returnValue);
503
+ });
504
+ const message = {
505
+ name: endpoint.name,
506
+ data: parameters,
507
+ sync: false,
508
+ retId: retHandler?.name,
509
+ hasTransfer: endpoint.hasReturnTransfer
510
+ };
511
+ this.postMessage(message, {
512
+ transfer
513
+ });
514
+ return promise;
515
+ }
516
+ {
517
+ const message = {
518
+ name: endpoint.name,
519
+ data: parameters,
520
+ sync: false
521
+ };
522
+ this.postMessage(message, {
523
+ transfer
524
+ });
525
+ }
526
+ }
527
+ createCallbackify(endpoint, callbackAt) {
528
+ const call = this.createCall(endpoint);
529
+ return (...params)=>{
530
+ const callback = params.at(callbackAt);
531
+ params.splice(callbackAt, 1);
532
+ call(...params).then(callback);
533
+ };
534
+ }
535
+ }
536
+ },
537
+ "../web-worker-rpc/dist/RpcEndpoint.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
538
+ __webpack_require__.d(__webpack_exports__, {
539
+ H: ()=>createRpcEndpoint
540
+ });
541
+ function createRpcEndpoint(name, isSync, hasReturn = true, hasReturnTransfer = false, bufferSize) {
542
+ return {
543
+ name,
544
+ isSync,
545
+ hasReturn,
546
+ hasReturnTransfer,
547
+ bufferSize
548
+ };
549
+ }
550
+ }
551
+ });
552
+ const dist = __webpack_require__("../web-constants/dist/index.js");
553
+ const templateCache = new Map();
554
+ let tmpDir;
555
+ const tmpDirPromise = promises.mkdtemp(node_path.join(node_os.tmpdir(), 'lynx'));
556
+ async function createJsModuleUrl(content, filename) {
557
+ if (!tmpDir) tmpDir = await tmpDirPromise;
558
+ const fileUrl = node_path.join(tmpDir, filename);
559
+ await promises.writeFile(fileUrl, content, {
560
+ flag: 'w+'
561
+ });
562
+ return fileUrl;
563
+ }
564
+ async function loadTemplate(rawTemplate, templateName = Math.random().toString(36).substring(2, 7)) {
565
+ if (templateCache.has(rawTemplate)) return templateCache.get(rawTemplate);
566
+ templateName += Math.random().toString(36).substring(2, 7);
567
+ const decodedTemplate = templateCache.get(rawTemplate) ?? await (0, dist.Yx)(rawTemplate, createJsModuleUrl, templateName + '-lepusCode');
568
+ templateCache.set(rawTemplate, decodedTemplate);
569
+ return decodedTemplate;
570
+ }
571
+ const OperationType = {
572
+ CreateElement: 1,
573
+ SetAttribute: 2,
574
+ RemoveAttribute: 3,
575
+ Append: 4,
576
+ Remove: 5,
577
+ ReplaceWith: 6,
578
+ InsertBefore: 7,
579
+ EnableEvent: 8,
580
+ RemoveChild: 9,
581
+ StyleDeclarationSetProperty: 10,
582
+ StyleDeclarationRemoveProperty: 11,
583
+ SetTextContent: 12,
584
+ sheetInsertRule: 13,
585
+ sheetRuleUpdateCssText: 14
586
+ };
587
+ class OffscreenCSSStyleDeclaration {
588
+ _parent;
589
+ constructor(parent){
590
+ this._parent = parent;
591
+ }
592
+ setProperty(property, value, priority) {
593
+ this._parent[ancestorDocument][operations].push(OperationType.StyleDeclarationSetProperty, this._parent[OffscreenElement_uniqueId], property, value, priority ?? '');
594
+ const currentStyle = this._parent.getAttribute('style') ?? '';
595
+ this._parent[_attributes].set('style', currentStyle + `${property}:${value}${priority ? ` !${priority}` : ''};`);
596
+ }
597
+ removeProperty(property) {
598
+ this._parent[ancestorDocument][operations].push(OperationType.StyleDeclarationRemoveProperty, this._parent[OffscreenElement_uniqueId], property);
599
+ const currentStyle = this._parent.getAttribute('style') ?? '';
600
+ this._parent[_attributes].set('style', currentStyle + `${property}:inital;`);
601
+ }
602
+ }
603
+ const ancestorDocument = Symbol('ancestorDocument');
604
+ const _attributes = Symbol('_attributes');
605
+ const _children = Symbol('_children');
606
+ const textContent = Symbol('textContent');
607
+ const _cssRuleContents = Symbol('_cssRuleContents');
608
+ const OffscreenElement_uniqueId = Symbol('uniqueId');
609
+ const _style = Symbol('_style');
610
+ class OffscreenElement extends EventTarget {
611
+ [textContent] = '';
612
+ [_style];
613
+ [_attributes] = new Map();
614
+ _parentElement = null;
615
+ [_children] = [];
616
+ [_cssRuleContents];
617
+ #sheet;
618
+ [OffscreenElement_uniqueId];
619
+ [ancestorDocument];
620
+ localName;
621
+ constructor(localName, elementUniqueId){
622
+ super();
623
+ this.localName = localName;
624
+ this[OffscreenElement_uniqueId] = elementUniqueId;
625
+ }
626
+ get sheet() {
627
+ if (!this.#sheet) {
628
+ const uid = this[OffscreenElement_uniqueId];
629
+ const ancestor = this[ancestorDocument];
630
+ const cssRules = [];
631
+ this.#sheet = {
632
+ cssRules,
633
+ insertRule: (rule, index)=>{
634
+ cssRules.splice(index, 0, {
635
+ style: {
636
+ set cssText (text){
637
+ ancestor[operations].push(OperationType.sheetRuleUpdateCssText, uid, index, text);
638
+ }
639
+ }
640
+ });
641
+ if (!this[_cssRuleContents]) this[_cssRuleContents] = [];
642
+ this[_cssRuleContents].splice(index, 0, rule);
643
+ this[ancestorDocument][operations].push(OperationType.sheetInsertRule, uid, index, rule);
644
+ return index;
645
+ }
646
+ };
647
+ }
648
+ return this.#sheet;
649
+ }
650
+ get tagName() {
651
+ return this.localName.toUpperCase();
652
+ }
653
+ get style() {
654
+ if (!this[_style]) this[_style] = new OffscreenCSSStyleDeclaration(this);
655
+ return this[_style];
656
+ }
657
+ get children() {
658
+ return this[_children].slice();
659
+ }
660
+ get parentElement() {
661
+ return this._parentElement;
662
+ }
663
+ get parentNode() {
664
+ return this._parentElement;
665
+ }
666
+ get firstElementChild() {
667
+ return this[_children][0] ?? null;
668
+ }
669
+ get lastElementChild() {
670
+ return this[_children][this[_children].length - 1] ?? null;
671
+ }
672
+ get nextElementSibling() {
673
+ const parent = this._parentElement;
674
+ if (parent) {
675
+ const nextElementSiblingIndex = parent[_children].indexOf(this);
676
+ if (nextElementSiblingIndex >= 0) return parent[_children][nextElementSiblingIndex + 1] || null;
677
+ }
678
+ return null;
679
+ }
680
+ _remove() {
681
+ if (this._parentElement) {
682
+ const currentIdx = this._parentElement[_children].indexOf(this);
683
+ this._parentElement[_children].splice(currentIdx, 1);
684
+ this._parentElement = null;
685
+ }
686
+ }
687
+ setAttribute(qualifiedName, value) {
688
+ this[_attributes].set(qualifiedName, value);
689
+ this[ancestorDocument][operations].push(OperationType.SetAttribute, this[OffscreenElement_uniqueId], qualifiedName, value);
690
+ }
691
+ getAttribute(qualifiedName) {
692
+ return this[_attributes].get(qualifiedName) ?? null;
693
+ }
694
+ removeAttribute(qualifiedName) {
695
+ this[_attributes].delete(qualifiedName);
696
+ this[ancestorDocument][operations].push(OperationType.RemoveAttribute, this[OffscreenElement_uniqueId], qualifiedName);
697
+ }
698
+ append(...nodes) {
699
+ this[ancestorDocument][operations].push(OperationType.Append, this[OffscreenElement_uniqueId], nodes.length, ...nodes.map((node)=>node[OffscreenElement_uniqueId]));
700
+ for (const node of nodes){
701
+ node._remove();
702
+ node._parentElement = this;
703
+ }
704
+ this[_children].push(...nodes);
705
+ }
706
+ appendChild(node) {
707
+ this[ancestorDocument][operations].push(OperationType.Append, this[OffscreenElement_uniqueId], 1, node[OffscreenElement_uniqueId]);
708
+ node._remove();
709
+ node._parentElement = this;
710
+ this[_children].push(node);
711
+ return node;
712
+ }
713
+ replaceWith(...nodes) {
714
+ this[ancestorDocument][operations].push(OperationType.ReplaceWith, this[OffscreenElement_uniqueId], nodes.length, ...nodes.map((node)=>node[OffscreenElement_uniqueId]));
715
+ if (this._parentElement) {
716
+ const parent = this._parentElement;
717
+ this._parentElement = null;
718
+ const currentIdx = parent[_children].indexOf(this);
719
+ parent[_children].splice(currentIdx, 1, ...nodes);
720
+ for (const node of nodes)node._parentElement = parent;
721
+ }
722
+ }
723
+ getAttributeNames() {
724
+ return [
725
+ ...this[_attributes].keys()
726
+ ];
727
+ }
728
+ remove() {
729
+ this[ancestorDocument][operations].push(OperationType.Remove, this[OffscreenElement_uniqueId]);
730
+ this._remove();
731
+ }
732
+ insertBefore(newNode, refNode) {
733
+ newNode._remove();
734
+ if (refNode) {
735
+ const refNodeIndex = this[_children].indexOf(refNode);
736
+ if (refNodeIndex >= 0) {
737
+ newNode._parentElement = this;
738
+ this[_children].splice(refNodeIndex, 0, newNode);
739
+ }
740
+ } else {
741
+ newNode._parentElement = this;
742
+ this[_children].push(newNode);
743
+ }
744
+ this[ancestorDocument][operations].push(OperationType.InsertBefore, this[OffscreenElement_uniqueId], newNode[OffscreenElement_uniqueId], refNode?.[OffscreenElement_uniqueId] ?? 0);
745
+ return newNode;
746
+ }
747
+ removeChild(child) {
748
+ if (!child) throw new DOMException('The node to be removed is not a child of this node.', 'NotFoundError');
749
+ if (child._parentElement !== this) throw new DOMException('The node to be removed is not a child of this node.', 'NotFoundError');
750
+ this[ancestorDocument][operations].push(OperationType.RemoveChild, this[OffscreenElement_uniqueId], child[OffscreenElement_uniqueId]);
751
+ child._remove();
752
+ return child;
753
+ }
754
+ addEventListener(type, callback, options) {
755
+ this[ancestorDocument][enableEvent](type, this[OffscreenElement_uniqueId]);
756
+ super.addEventListener(type, callback, options);
757
+ }
758
+ get textContent() {
759
+ return this[textContent];
760
+ }
761
+ set textContent(text1) {
762
+ this[ancestorDocument][operations].push(OperationType.SetTextContent, this[OffscreenElement_uniqueId], text1);
763
+ for (const child of this.children)child.remove();
764
+ this[textContent] = text1;
765
+ if (this[_cssRuleContents]) this[_cssRuleContents] = [];
766
+ }
767
+ }
768
+ const propagationStopped = Symbol('propagationStopped');
769
+ const eventPhase = Symbol('eventPhase');
770
+ class OffscreenEvent extends Event {
771
+ _target;
772
+ [eventPhase] = Event.CAPTURING_PHASE;
773
+ constructor(type, _target){
774
+ super(type);
775
+ this._target = _target;
776
+ }
777
+ get target() {
778
+ return this._target;
779
+ }
780
+ [propagationStopped] = false;
781
+ stopImmediatePropagation() {
782
+ this[propagationStopped] = true;
783
+ super.stopImmediatePropagation();
784
+ }
785
+ stopPropagation() {
786
+ this[propagationStopped] = true;
787
+ super.stopPropagation();
788
+ }
789
+ get eventPhase() {
790
+ return this[eventPhase];
791
+ }
792
+ }
793
+ const operations = Symbol('operations');
794
+ const enableEvent = Symbol('enableEvent');
795
+ const getElementByUniqueId = Symbol('getElementByUniqueId');
796
+ const _onEvent = Symbol('_onEvent');
797
+ const _uniqueIdInc = Symbol('uniqueIdInc');
798
+ const _uniqueIdToElement = Symbol('_uniqueIdToElement');
799
+ class OffscreenDocument extends OffscreenElement {
800
+ _callbacks;
801
+ [_uniqueIdInc] = 1;
802
+ [_uniqueIdToElement] = [];
803
+ [operations] = [];
804
+ [getElementByUniqueId](uniqueId) {
805
+ return this[_uniqueIdToElement][uniqueId]?.deref();
806
+ }
807
+ [enableEvent];
808
+ constructor(_callbacks){
809
+ const enableEventImpl = (eventType, uid)=>{
810
+ this[operations].push(OperationType.EnableEvent, uid, eventType);
811
+ };
812
+ super('', 0);
813
+ this._callbacks = _callbacks;
814
+ this[ancestorDocument] = this;
815
+ this[enableEvent] = enableEventImpl;
816
+ }
817
+ commit() {
818
+ const currentOperations = this[operations];
819
+ this[operations] = [];
820
+ this._callbacks.onCommit(currentOperations);
821
+ }
822
+ createElement(tagName) {
823
+ const uniqueId = this[_uniqueIdInc]++;
824
+ const element = new OffscreenElement(tagName, uniqueId);
825
+ element[ancestorDocument] = this;
826
+ this[_uniqueIdToElement][uniqueId] = new WeakRef(element);
827
+ this[operations].push(OperationType.CreateElement, uniqueId, tagName);
828
+ return element;
829
+ }
830
+ [_onEvent] = (eventType, targetUniqueId, bubbles, otherProperties)=>{
831
+ const target = this[getElementByUniqueId](targetUniqueId);
832
+ if (target) {
833
+ const bubblePath = [];
834
+ let tempTarget = target;
835
+ while(tempTarget.parentElement){
836
+ bubblePath.push(tempTarget.parentElement);
837
+ tempTarget = tempTarget.parentElement;
838
+ }
839
+ const event = new OffscreenEvent(eventType, target);
840
+ Object.assign(event, otherProperties);
841
+ event[eventPhase] = Event.CAPTURING_PHASE;
842
+ for(let ii = bubblePath.length - 1; ii >= 0; ii--){
843
+ const currentPhaseTarget = bubblePath[ii];
844
+ currentPhaseTarget.dispatchEvent(event);
845
+ if (event[propagationStopped]) return;
846
+ }
847
+ event[eventPhase] = Event.AT_TARGET;
848
+ target.dispatchEvent(event);
849
+ if (bubbles) {
850
+ event[eventPhase] = Event.BUBBLING_PHASE;
851
+ for (const currentPhaseTarget of bubblePath){
852
+ currentPhaseTarget.dispatchEvent(event);
853
+ if (event[propagationStopped]) return;
854
+ }
855
+ }
856
+ }
857
+ };
858
+ }
859
+ const templateScrollView = `<style>
860
+ .placeholder-dom {
861
+ display: none;
862
+ flex: 0 0 0;
863
+ align-self: stretch;
864
+ min-height: 0;
865
+ min-width: 0;
866
+ }
867
+ .mask {
868
+ z-index: 1;
869
+ position: sticky;
870
+ }
871
+ .observer-container {
872
+ flex-direction: inherit;
873
+ overflow: visible;
874
+ }
875
+ .observer {
876
+ display: flex;
877
+ }
878
+ ::-webkit-scrollbar {
879
+ display: none;
880
+ }
881
+
882
+ @keyframes topFading {
883
+ 0% {
884
+ box-shadow: transparent 0px 0px 0px 0px;
885
+ }
886
+ 5% {
887
+ box-shadow: var(--scroll-view-bg-color) 0px 0px
888
+ var(--scroll-view-fading-edge-length)
889
+ var(--scroll-view-fading-edge-length);
890
+ }
891
+ 100% {
892
+ box-shadow: var(--scroll-view-bg-color) 0px 0px
893
+ var(--scroll-view-fading-edge-length)
894
+ var(--scroll-view-fading-edge-length);
895
+ }
896
+ }
897
+ @keyframes botFading {
898
+ 0% {
899
+ box-shadow: var(--scroll-view-bg-color) 0px 0px
900
+ var(--scroll-view-fading-edge-length)
901
+ var(--scroll-view-fading-edge-length);
902
+ }
903
+ 95% {
904
+ box-shadow: var(--scroll-view-bg-color) 0px 0px
905
+ var(--scroll-view-fading-edge-length)
906
+ var(--scroll-view-fading-edge-length);
907
+ }
908
+ 100% {
909
+ box-shadow: transparent 0px 0px 0px 0px;
910
+ }
911
+ }
912
+ </style>
913
+ <div
914
+ class="mask placeholder-dom"
915
+ id="top-fade-mask"
916
+ part="top-fade-mask"
917
+ ></div>
918
+ <div
919
+ class="observer-container placeholder-dom"
920
+ part="upper-threshold-observer"
921
+ >
922
+ <div
923
+ class="observer placeholder-dom"
924
+ id="upper-threshold-observer"
925
+ ></div>
926
+ </div>
927
+ <slot></slot>
928
+ <div
929
+ class="observer-container placeholder-dom"
930
+ part="lower-threshold-observer"
931
+ >
932
+ <div
933
+ class="observer placeholder-dom"
934
+ id="lower-threshold-observer"
935
+ ></div>
936
+ </div>
937
+ <div
938
+ class="mask placeholder-dom"
939
+ id="bot-fade-mask"
940
+ part="bot-fade-mask"
941
+ ></div>`;
942
+ const templateXAudioTT = '<audio id="audio"></audio>';
943
+ const XSSDetector = /<\s*script/g;
944
+ const templateXImage = (attributes)=>{
945
+ const { src } = attributes;
946
+ if (src && XSSDetector.test(src)) throw new Error("detected <script, this is a potential XSS attack, please check your src");
947
+ return `<img part="img" alt="" loading="lazy" id="img" ${src ? `src="${src}"` : ''}/> `;
948
+ };
949
+ const templateFilterImage = templateXImage;
950
+ const templateXInput = `<style>
951
+ #input:focus {
952
+ outline: none;
953
+ }
954
+ #form {
955
+ display: none;
956
+ }
957
+ </style>
958
+ <form id="form" part="form" method="dialog">
959
+ <input
960
+ id="input"
961
+ part="input"
962
+ step="any"
963
+ type="text"
964
+ inputmode="text"
965
+ spell-check="true"
966
+ />
967
+ </form>`;
968
+ const templateXList = `<style>
969
+ .placeholder-dom {
970
+ display: none;
971
+ flex: 0 0 0;
972
+ align-self: stretch;
973
+ min-height: 0;
974
+ min-width: 0;
975
+ }
976
+ .observer-container {
977
+ flex-direction: inherit;
978
+ overflow: visible;
979
+ }
980
+ .observer {
981
+ display: flex;
982
+ }
983
+ </style>
984
+ <div id="content" part="content">
985
+ <div
986
+ class="observer-container placeholder-dom"
987
+ part="upper-threshold-observer"
988
+ >
989
+ <div
990
+ class="observer placeholder-dom"
991
+ id="upper-threshold-observer"
992
+ ></div>
993
+ </div>
994
+ <slot part="slot"></slot>
995
+ <div
996
+ class="observer-container placeholder-dom"
997
+ part="lower-threshold-observer"
998
+ >
999
+ <div
1000
+ class="observer placeholder-dom"
1001
+ id="lower-threshold-observer"
1002
+ ></div>
1003
+ </div>
1004
+ </div>`;
1005
+ const templateXOverlayNg = `<style>
1006
+ #dialog[open] {
1007
+ top: 0;
1008
+ left: 0;
1009
+ right: 0;
1010
+ bottom: 0;
1011
+ position: fixed;
1012
+ overscroll-behavior: contain;
1013
+ scrollbar-width: none;
1014
+ }
1015
+ #dialog[open]::-webkit-scrollbar {
1016
+ display: none;
1017
+ }
1018
+ #dialog::backdrop {
1019
+ background-color: transparent;
1020
+ }
1021
+ .overlay-inner {
1022
+ position: sticky;
1023
+ top: 0;
1024
+ width: 100%;
1025
+ height: 100%;
1026
+ pointer-events: none;
1027
+ }
1028
+ .overlay-inner > * {
1029
+ pointer-events: auto;
1030
+ }
1031
+ .overlay-placeholder {
1032
+ width: 100%;
1033
+ height: 1px;
1034
+ }
1035
+ </style>
1036
+ <dialog id="dialog" part="dialog">
1037
+ <div class="overlay-inner">
1038
+ <slot></slot>
1039
+ </div>
1040
+ <div class="overlay-placeholder"></div>
1041
+ </dialog>`;
1042
+ const templateXRefreshView = `<style>
1043
+ .bounce-container {
1044
+ overflow: scroll;
1045
+ overscroll-behavior: contain;
1046
+ scroll-snap-type: y mandatory;
1047
+ scroll-behavior: smooth;
1048
+ scrollbar-width: none;
1049
+ }
1050
+ .overflow-placeholder {
1051
+ min-height: 30%;
1052
+ min-width: 100%;
1053
+ flex-shrink: 0;
1054
+ scroll-snap-align: none;
1055
+ }
1056
+ .not-shrink {
1057
+ height: 100%;
1058
+ width: 100%;
1059
+ min-height: 100%;
1060
+ min-width: 100%;
1061
+ flex-shrink: 0;
1062
+ }
1063
+ .vertical {
1064
+ display: flex;
1065
+ flex-direction: column;
1066
+ }
1067
+ #content {
1068
+ scroll-snap-align: center;
1069
+ }
1070
+ </style>
1071
+ <div id="container" part="container" class="bounce-container not-shrink vertical">
1072
+ <div
1073
+ id="placeholder-top"
1074
+ class="overflow-placeholder bounce-item"
1075
+ part="placeholder-top"
1076
+ ></div>
1077
+ <slot name="header"></slot>
1078
+ <div id="content" part="content" class="not-shrink vertical">
1079
+ <slot part="slot"></slot>
1080
+ </div>
1081
+ <slot name="footer"></slot>
1082
+ <div
1083
+ id="placeholder-bot"
1084
+ class="overflow-placeholder bounce-item"
1085
+ part="placeholder-bot"
1086
+ ></div>
1087
+ </div>`;
1088
+ const templateXSwiper = `<style>
1089
+ #bounce-padding {
1090
+ display: none;
1091
+ flex: 0 0 0;
1092
+ align-self: stretch;
1093
+ scroll-snap-align: none;
1094
+ flex-basis: 100%;
1095
+ }
1096
+ #content {
1097
+ position: relative;
1098
+ display: flex;
1099
+ flex: 0 0 100%;
1100
+ flex-direction: inherit;
1101
+ flex-wrap: inherit;
1102
+ align-self: stretch;
1103
+ justify-content: inherit;
1104
+ align-items: inherit;
1105
+ overflow: inherit;
1106
+ scrollbar-width: none;
1107
+ scroll-snap-align: start;
1108
+ scroll-snap-type: inherit;
1109
+ }
1110
+ div::-webkit-scrollbar {
1111
+ display: none;
1112
+ }
1113
+ #indicator-container {
1114
+ display: none;
1115
+ }
1116
+ #indicator-container > div {
1117
+ animation-name: indicator-dot;
1118
+ animation-duration: 100ms;
1119
+ }
1120
+ @keyframes indicator-dot {
1121
+ 30%,
1122
+ 70% {
1123
+ background-color: var(--indicator-color);
1124
+ }
1125
+ 31%,
1126
+ 69% {
1127
+ background-color: var(--indicator-active-color);
1128
+ }
1129
+ }
1130
+ </style>
1131
+ <style id="indicator-style"></style>
1132
+ <div id="bounce-padding" part="bounce-padding"></div>
1133
+ <div id="indicator-container" part="indicator-container"></div>
1134
+ <div id="content" part="content">
1135
+ <slot part="slot-start" name="circular-start" id="circular-start"></slot>
1136
+ <slot part="slot"></slot>
1137
+ <slot part="slot-end" name="circular-end" id="circular-end"></slot>
1138
+ </div>`;
1139
+ const templateXText = '<div id="inner-box" part="inner-box"><slot part="slot"></slot><slot name="inline-truncation"></slot></div>';
1140
+ const templateInlineImage = templateXImage;
1141
+ const templateXTextarea = `<style>
1142
+ #textarea:focus,
1143
+ #textarea:focus-visible {
1144
+ border: inherit;
1145
+ outline: inherit;
1146
+ }
1147
+ </style>
1148
+ <form id="form" part="form" method="dialog">
1149
+ <textarea id="textarea" part="textarea"></textarea>
1150
+ </form>`;
1151
+ const templateXViewpageNg = `<style>
1152
+ #bounce-padding {
1153
+ display: none;
1154
+ flex: 0 0 0;
1155
+ align-self: stretch;
1156
+ scroll-snap-align: none;
1157
+ flex-basis: 100%;
1158
+ }
1159
+ #content {
1160
+ flex: 0 0 100%;
1161
+ flex-direction: row;
1162
+ align-self: stretch;
1163
+ display: inherit;
1164
+ justify-content: inherit;
1165
+ align-items: inherit;
1166
+ overflow: inherit;
1167
+ scrollbar-width: none;
1168
+ scroll-snap-type: inherit;
1169
+ }
1170
+ #content::-webkit-scrollbar {
1171
+ display: none;
1172
+ }
1173
+ </style>
1174
+ <div id="bounce-padding" part="bounce-padding"></div>
1175
+ <div id="content" part="content">
1176
+ <slot></slot>
1177
+ </div>`;
1178
+ const matchHtmlRegExp = /["'&<>]/;
1179
+ function escapeHtml(string) {
1180
+ const str = '' + string;
1181
+ const match = matchHtmlRegExp.exec(str);
1182
+ if (!match) return str;
1183
+ let escape;
1184
+ let html = '';
1185
+ let index;
1186
+ let lastIndex = 0;
1187
+ for(index = match.index; index < str.length; index++){
1188
+ switch(str.charCodeAt(index)){
1189
+ case 34:
1190
+ escape = '&quot;';
1191
+ break;
1192
+ case 38:
1193
+ escape = '&amp;';
1194
+ break;
1195
+ case 39:
1196
+ escape = '&#x27;';
1197
+ break;
1198
+ case 60:
1199
+ escape = '&lt;';
1200
+ break;
1201
+ case 62:
1202
+ escape = '&gt;';
1203
+ break;
1204
+ default:
1205
+ continue;
1206
+ }
1207
+ if (lastIndex !== index) html += str.substring(lastIndex, index);
1208
+ lastIndex = index + 1;
1209
+ html += escape;
1210
+ }
1211
+ return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
1212
+ }
1213
+ function getTextContentImpl(buffer, element, shadowrootTemplates) {
1214
+ const localName = element.localName;
1215
+ buffer.push('<');
1216
+ buffer.push(localName);
1217
+ for (const [key, value] of element[_attributes]){
1218
+ buffer.push(' ');
1219
+ buffer.push(key);
1220
+ if (value.length > 0) {
1221
+ buffer.push('="');
1222
+ buffer.push(escapeHtml(value));
1223
+ buffer.push('"');
1224
+ }
1225
+ }
1226
+ const partId = element[_attributes].get(dist.oZ) ?? element[_attributes].get(dist.SP);
1227
+ buffer.push(' ', dist.oZ, '="', partId, '"');
1228
+ buffer.push('>');
1229
+ const templateImpl = shadowrootTemplates[localName];
1230
+ if (templateImpl) {
1231
+ const template = 'function' == typeof templateImpl ? templateImpl(Object.fromEntries(element[_attributes].entries())) : templateImpl;
1232
+ buffer.push('<template shadowrootmode="open">', template, '</template>');
1233
+ }
1234
+ if (element[_cssRuleContents]?.length) buffer.push(...element[_cssRuleContents]);
1235
+ if (element[textContent]) buffer.push(element[textContent]);
1236
+ else for (const child of element[_children])getTextContentImpl(buffer, child, shadowrootTemplates);
1237
+ buffer.push('</');
1238
+ buffer.push(localName);
1239
+ buffer.push('>');
1240
+ }
1241
+ function dumpHTMLString(buffer, element, shadowrootTemplates) {
1242
+ for (const child of element[_children])getTextContentImpl(buffer, child, shadowrootTemplates);
1243
+ }
1244
+ const Rpc = __webpack_require__("../web-worker-rpc/dist/Rpc.js");
1245
+ const builtinElementTemplates = {
1246
+ 'scroll-view': templateScrollView,
1247
+ 'x-audio-tt': templateXAudioTT,
1248
+ 'x-image': templateXImage,
1249
+ 'filter-image': templateFilterImage,
1250
+ 'x-input': templateXInput,
1251
+ 'x-list': templateXList,
1252
+ 'x-overlay-ng': templateXOverlayNg,
1253
+ 'x-refresh-view': templateXRefreshView,
1254
+ 'x-swiper': templateXSwiper,
1255
+ 'x-text': templateXText,
1256
+ 'inline-image': templateInlineImage,
1257
+ 'x-textarea': templateXTextarea,
1258
+ 'x-viewpage-ng': templateXViewpageNg
1259
+ };
1260
+ const builtinTagTransformMap = {
1261
+ page: 'div',
1262
+ view: 'x-view',
1263
+ text: 'x-text',
1264
+ image: 'x-image',
1265
+ list: 'x-list',
1266
+ svg: 'x-svg',
1267
+ input: 'x-input',
1268
+ 'x-input-ng': 'x-input'
1269
+ };
1270
+ OffscreenElement.prototype.toJSON = function() {
1271
+ return {
1272
+ ssrID: this[_attributes].get(dist.oZ) ?? this[_attributes].get(dist.SP)
1273
+ };
1274
+ };
1275
+ async function createLynxView(config) {
1276
+ const { template: rawTemplate, browserConfig, tagMap, initData, globalProps, overrideElementTemplates = {}, hydrateUrl, autoSize, injectStyles, lynxViewStyle, threadStrategy = 'all-on-ui', initI18nResources } = config;
1277
+ const template = await loadTemplate(rawTemplate, config.templateName);
1278
+ const { promise: firstPaintReadyPromise, resolve: firstPaintReady } = Promise.withResolvers();
1279
+ const mainWithBackgroundChannel = new MessageChannel();
1280
+ const backgroundThreadRpc = new Rpc.C(mainWithBackgroundChannel.port1, 'background-thread');
1281
+ const offscreenDocument = new OffscreenDocument({
1282
+ onCommit: ()=>{}
1283
+ });
1284
+ const i18nResources = new dist.gI();
1285
+ const events = [];
1286
+ const mtsVMContext = node_vm.createContext(node_vm.constants.DONT_CONTEXTIFY);
1287
+ Object.assign(mtsVMContext, {
1288
+ document: offscreenDocument,
1289
+ module: {
1290
+ exports: null
1291
+ }
1292
+ });
1293
+ const loadScriptSync = (url)=>{
1294
+ const scriptContent = node_fs.readFileSync(url);
1295
+ const script = new node_vm.Script(scriptContent.toString(), {
1296
+ filename: url
1297
+ });
1298
+ mtsVMContext.module = {
1299
+ exports: null
1300
+ };
1301
+ script.runInContext(mtsVMContext);
1302
+ const ret = mtsVMContext.module.exports;
1303
+ mtsVMContext.module = {
1304
+ exports: null
1305
+ };
1306
+ return ret;
1307
+ };
1308
+ const loadScript = async (url)=>new Promise((resolve, reject)=>{
1309
+ node_fs.readFile(url, (err, data)=>{
1310
+ if (err) return void reject(err);
1311
+ try {
1312
+ const script = new node_vm.Script(data.toString(), {
1313
+ filename: url
1314
+ });
1315
+ mtsVMContext.module = {
1316
+ exports: null
1317
+ };
1318
+ script.runInContext(mtsVMContext);
1319
+ const ret = mtsVMContext.module.exports;
1320
+ mtsVMContext.module = {
1321
+ exports: null
1322
+ };
1323
+ resolve(ret);
1324
+ } catch (e) {
1325
+ reject(e);
1326
+ }
1327
+ });
1328
+ });
1329
+ const { prepareMainThreadAPIs } = await import("./27.js").then(__webpack_require__.bind(__webpack_require__, "../web-mainthread-apis/dist/index.js"));
1330
+ const { startMainThread } = prepareMainThreadAPIs(backgroundThreadRpc, offscreenDocument, offscreenDocument, {
1331
+ globalWindow: mtsVMContext,
1332
+ loadScript,
1333
+ loadScriptSync
1334
+ }, ()=>{
1335
+ firstPaintReady();
1336
+ }, ()=>{}, ()=>{}, ()=>{}, ()=>{}, (initI18nResources)=>{
1337
+ i18nResources.setData(initI18nResources);
1338
+ return i18nResources;
1339
+ }, ()=>{}, {
1340
+ __AddEvent (element, eventName, eventData, eventOptions) {
1341
+ events.push([
1342
+ Number(element.getAttribute(dist.SP)),
1343
+ eventName,
1344
+ eventData,
1345
+ eventOptions
1346
+ ]);
1347
+ }
1348
+ }, 'all-on-ui' === threadStrategy);
1349
+ await startMainThread({
1350
+ template,
1351
+ initData,
1352
+ globalProps,
1353
+ browserConfig,
1354
+ nativeModulesMap: {},
1355
+ napiModulesMap: {},
1356
+ tagMap: {
1357
+ ...builtinTagTransformMap,
1358
+ ...tagMap
1359
+ },
1360
+ initI18nResources
1361
+ });
1362
+ const elementTemplates = {
1363
+ ...builtinElementTemplates,
1364
+ ...overrideElementTemplates
1365
+ };
1366
+ async function renderToString() {
1367
+ await firstPaintReadyPromise;
1368
+ const ssrEncodeData = mtsVMContext?.ssrEncode?.();
1369
+ const ssrDumpInfo = {
1370
+ ssrEncodeData,
1371
+ events
1372
+ };
1373
+ const buffer = [];
1374
+ buffer.push('<lynx-view url="', hydrateUrl, '" ssr ="', encodeURI(JSON.stringify(ssrDumpInfo)), '" ', 'thread-strategy="', threadStrategy, '"');
1375
+ if (autoSize) buffer.push(' height="auto" width="auto"');
1376
+ if (lynxViewStyle) buffer.push(' style="', lynxViewStyle, '"');
1377
+ buffer.push('><template shadowrootmode="open">', '<style>', injectStyles, '\n', dist.OE.join('\n'), '</style>');
1378
+ dumpHTMLString(buffer, offscreenDocument, elementTemplates);
1379
+ buffer.push('</template>');
1380
+ buffer.push('</lynx-view>');
1381
+ return buffer.join('');
1382
+ }
1383
+ return {
1384
+ renderToString
1385
+ };
1386
+ }
1387
+ if (!globalThis.requestAnimationFrame) {
1388
+ globalThis.requestAnimationFrame = (cb)=>setTimeout(cb, 0);
1389
+ globalThis.cancelAnimationFrame = (id)=>{
1390
+ clearTimeout(id);
1391
+ };
1392
+ }
1393
+ export { createLynxView };
1394
+
1395
+ //# sourceMappingURL=131.js.map