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