@lynx-js/web-core-server-canary 0.19.4-canary-20260104-f4b90f3a → 0.19.5-canary-20260107-78c21890

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