@lynx-js/web-core-wasm-canary 0.0.0 → 0.0.1-canary-20260116-ce265e8f

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.
Files changed (204) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/{LICENSE → LICENSE.txt} +1 -1
  3. package/Notice.txt +1 -0
  4. package/README.md +1 -0
  5. package/binary/client/client.d.ts +263 -0
  6. package/binary/client/client.js +1339 -0
  7. package/binary/client/client_bg.wasm +0 -0
  8. package/binary/client/client_bg.wasm.d.ts +70 -0
  9. package/binary/client/client_debug.d.ts +263 -0
  10. package/binary/client/client_debug.js +1339 -0
  11. package/binary/client/client_debug_bg.wasm +0 -0
  12. package/binary/client/client_debug_bg.wasm.d.ts +70 -0
  13. package/binary/encode/encode.d.ts +157 -0
  14. package/binary/encode/encode.js +17 -0
  15. package/binary/encode/encode_bg.js +749 -0
  16. package/binary/encode/encode_bg.wasm +0 -0
  17. package/binary/encode/encode_bg.wasm.d.ts +50 -0
  18. package/binary/encode/encode_debug.d.ts +157 -0
  19. package/binary/encode/encode_debug.js +17 -0
  20. package/binary/encode/encode_debug_bg.js +822 -0
  21. package/binary/encode/encode_debug_bg.wasm +0 -0
  22. package/binary/encode/encode_debug_bg.wasm.d.ts +50 -0
  23. package/binary/encode/package.json +4 -0
  24. package/css/in_shadow.css +10 -0
  25. package/css/index.css +119 -0
  26. package/dist/client/LynxCrossThreadContext.d.ts +22 -0
  27. package/dist/client/LynxCrossThreadContext.js +44 -0
  28. package/dist/client/background/background-apis/createBackgroundLynx.d.ts +24 -0
  29. package/dist/client/background/background-apis/createBackgroundLynx.js +38 -0
  30. package/dist/client/background/background-apis/createChunkLoading.d.ts +7 -0
  31. package/dist/client/background/background-apis/createChunkLoading.js +66 -0
  32. package/dist/client/background/background-apis/createElement.d.ts +5 -0
  33. package/dist/client/background/background-apis/createElement.js +18 -0
  34. package/dist/client/background/background-apis/createNapiLoader.d.ts +5 -0
  35. package/dist/client/background/background-apis/createNapiLoader.js +23 -0
  36. package/dist/client/background/background-apis/createNativeApp.d.ts +4 -0
  37. package/dist/client/background/background-apis/createNativeApp.js +98 -0
  38. package/dist/client/background/background-apis/createNativeModules.d.ts +3 -0
  39. package/dist/client/background/background-apis/createNativeModules.js +33 -0
  40. package/dist/client/background/background-apis/createPerformanceApis.d.ts +3 -0
  41. package/dist/client/background/background-apis/createPerformanceApis.js +47 -0
  42. package/dist/client/background/background-apis/createTimingSystem.d.ts +8 -0
  43. package/dist/client/background/background-apis/createTimingSystem.js +86 -0
  44. package/dist/client/background/background-apis/crossThreadHandlers/createGetCustomSection.d.ts +3 -0
  45. package/dist/client/background/background-apis/crossThreadHandlers/createGetCustomSection.js +14 -0
  46. package/dist/client/background/background-apis/crossThreadHandlers/createGetPathInfo.d.ts +3 -0
  47. package/dist/client/background/background-apis/crossThreadHandlers/createGetPathInfo.js +23 -0
  48. package/dist/client/background/background-apis/crossThreadHandlers/createInvokeUIMethod.d.ts +3 -0
  49. package/dist/client/background/background-apis/crossThreadHandlers/createInvokeUIMethod.js +24 -0
  50. package/dist/client/background/background-apis/crossThreadHandlers/createJSObjectDestructionObserver.d.ts +2 -0
  51. package/dist/client/background/background-apis/crossThreadHandlers/createJSObjectDestructionObserver.js +12 -0
  52. package/dist/client/background/background-apis/crossThreadHandlers/registerDisposeHandler.d.ts +3 -0
  53. package/dist/client/background/background-apis/crossThreadHandlers/registerDisposeHandler.js +9 -0
  54. package/dist/client/background/background-apis/crossThreadHandlers/registerPublicComponentEventHandler.d.ts +3 -0
  55. package/dist/client/background/background-apis/crossThreadHandlers/registerPublicComponentEventHandler.js +8 -0
  56. package/dist/client/background/background-apis/crossThreadHandlers/registerPublishEventHandler.d.ts +3 -0
  57. package/dist/client/background/background-apis/crossThreadHandlers/registerPublishEventHandler.js +8 -0
  58. package/dist/client/background/background-apis/crossThreadHandlers/registerSendGlobalEvent.d.ts +3 -0
  59. package/dist/client/background/background-apis/crossThreadHandlers/registerSendGlobalEvent.js +10 -0
  60. package/dist/client/background/background-apis/crossThreadHandlers/registerUpdateDataHandler.d.ts +3 -0
  61. package/dist/client/background/background-apis/crossThreadHandlers/registerUpdateDataHandler.js +5 -0
  62. package/dist/client/background/background-apis/crossThreadHandlers/registerUpdateGlobalPropsHandler.d.ts +3 -0
  63. package/dist/client/background/background-apis/crossThreadHandlers/registerUpdateGlobalPropsHandler.js +5 -0
  64. package/dist/client/background/background-apis/crossThreadHandlers/registerUpdateI18nResource.d.ts +3 -0
  65. package/dist/client/background/background-apis/crossThreadHandlers/registerUpdateI18nResource.js +9 -0
  66. package/dist/client/background/background-apis/startBackgroundThread.d.ts +2 -0
  67. package/dist/client/background/background-apis/startBackgroundThread.js +42 -0
  68. package/dist/client/background/index.d.ts +1 -0
  69. package/dist/client/background/index.js +15 -0
  70. package/dist/client/decodeWorker/cssLoader.d.ts +12 -0
  71. package/dist/client/decodeWorker/cssLoader.js +96 -0
  72. package/dist/client/decodeWorker/decode.worker.d.ts +1 -0
  73. package/dist/client/decodeWorker/decode.worker.js +338 -0
  74. package/dist/client/decodeWorker/types.d.ts +32 -0
  75. package/dist/client/decodeWorker/types.js +2 -0
  76. package/dist/client/endpoints.d.ts +53 -0
  77. package/dist/client/endpoints.js +37 -0
  78. package/dist/client/index.d.ts +3 -0
  79. package/dist/client/index.js +3 -0
  80. package/dist/client/mainthread/Background.d.ts +30 -0
  81. package/dist/client/mainthread/Background.js +207 -0
  82. package/dist/client/mainthread/ExposureServices.d.ts +11 -0
  83. package/dist/client/mainthread/ExposureServices.js +211 -0
  84. package/dist/client/mainthread/I18n.d.ts +9 -0
  85. package/dist/client/mainthread/I18n.js +44 -0
  86. package/dist/client/mainthread/LynxView.d.ts +170 -0
  87. package/dist/client/mainthread/LynxView.js +367 -0
  88. package/dist/client/mainthread/LynxViewInstance.d.ts +56 -0
  89. package/dist/client/mainthread/LynxViewInstance.js +196 -0
  90. package/dist/client/mainthread/StyleManager.d.ts +15 -0
  91. package/dist/client/mainthread/StyleManager.js +72 -0
  92. package/dist/client/mainthread/TemplateManager.d.ts +11 -0
  93. package/dist/client/mainthread/TemplateManager.js +257 -0
  94. package/dist/client/mainthread/createIFrameRealm.d.ts +6 -0
  95. package/dist/client/mainthread/createIFrameRealm.js +68 -0
  96. package/dist/client/mainthread/createMainThreadGlobalAPIs.d.ts +3 -0
  97. package/dist/client/mainthread/createMainThreadGlobalAPIs.js +82 -0
  98. package/dist/client/mainthread/crossThreadHandlers/queryNodes.d.ts +3 -0
  99. package/dist/client/mainthread/crossThreadHandlers/queryNodes.js +74 -0
  100. package/dist/client/mainthread/crossThreadHandlers/registerGetPathInfoHandler.d.ts +3 -0
  101. package/dist/client/mainthread/crossThreadHandlers/registerGetPathInfoHandler.js +51 -0
  102. package/dist/client/mainthread/crossThreadHandlers/registerInvokeUIMethodHandler.d.ts +3 -0
  103. package/dist/client/mainthread/crossThreadHandlers/registerInvokeUIMethodHandler.js +49 -0
  104. package/dist/client/mainthread/crossThreadHandlers/registerNapiModulesCallHandler.d.ts +3 -0
  105. package/dist/client/mainthread/crossThreadHandlers/registerNapiModulesCallHandler.js +8 -0
  106. package/dist/client/mainthread/crossThreadHandlers/registerNativeModulesCallHandler.d.ts +3 -0
  107. package/dist/client/mainthread/crossThreadHandlers/registerNativeModulesCallHandler.js +7 -0
  108. package/dist/client/mainthread/crossThreadHandlers/registerSelectComponentHandler.d.ts +3 -0
  109. package/dist/client/mainthread/crossThreadHandlers/registerSelectComponentHandler.js +20 -0
  110. package/dist/client/mainthread/crossThreadHandlers/registerSetNativePropsHandler.d.ts +3 -0
  111. package/dist/client/mainthread/crossThreadHandlers/registerSetNativePropsHandler.js +28 -0
  112. package/dist/client/mainthread/crossThreadHandlers/registerTriggerComponentEventHandler.d.ts +3 -0
  113. package/dist/client/mainthread/crossThreadHandlers/registerTriggerComponentEventHandler.js +12 -0
  114. package/dist/client/mainthread/crossThreadHandlers/registerTriggerElementMethodEndpointHandler.d.ts +3 -0
  115. package/dist/client/mainthread/crossThreadHandlers/registerTriggerElementMethodEndpointHandler.js +29 -0
  116. package/dist/client/mainthread/elementAPIs/WASMJSBinding.d.ts +38 -0
  117. package/dist/client/mainthread/elementAPIs/WASMJSBinding.js +122 -0
  118. package/dist/client/mainthread/elementAPIs/createCrossThreadEvent.d.ts +2 -0
  119. package/dist/client/mainthread/elementAPIs/createCrossThreadEvent.js +77 -0
  120. package/dist/client/mainthread/elementAPIs/createElementAPI.d.ts +3 -0
  121. package/dist/client/mainthread/elementAPIs/createElementAPI.js +346 -0
  122. package/dist/client/mainthread/elementAPIs/index.d.ts +2 -0
  123. package/dist/client/mainthread/elementAPIs/index.js +3 -0
  124. package/dist/client/mainthread/elementAPIs/pureElementPAPIs.d.ts +26 -0
  125. package/dist/client/mainthread/elementAPIs/pureElementPAPIs.js +85 -0
  126. package/dist/client/mainthread/utils/convertLengthToPx.d.ts +1 -0
  127. package/dist/client/mainthread/utils/convertLengthToPx.js +25 -0
  128. package/dist/client/wasm.d.ts +11 -0
  129. package/dist/client/wasm.js +52 -0
  130. package/dist/client/webElementsDynamicLoader.d.ts +8 -0
  131. package/dist/client/webElementsDynamicLoader.js +80 -0
  132. package/dist/client_prod/static/css/async/web-core-main-chunk.css +1 -0
  133. package/dist/client_prod/static/css/client.css +1 -0
  134. package/dist/client_prod/static/js/async/lynx-core-chunk.js +3 -0
  135. package/dist/client_prod/static/js/async/web-core-main-chunk.js +303 -0
  136. package/dist/client_prod/static/js/async/web-core-template-loader-thread.js +8 -0
  137. package/dist/client_prod/static/js/async/web-core-worker-chunk.js +1 -0
  138. package/dist/client_prod/static/js/async/web-elements-audio.js +1 -0
  139. package/dist/client_prod/static/js/async/web-elements-foldview.js +1 -0
  140. package/dist/client_prod/static/js/async/web-elements-input.js +1 -0
  141. package/dist/client_prod/static/js/async/web-elements-list.js +1 -0
  142. package/dist/client_prod/static/js/async/web-elements-overlay.js +1 -0
  143. package/dist/client_prod/static/js/async/web-elements-refrshview.js +1 -0
  144. package/dist/client_prod/static/js/async/web-elements-swiper.js +1 -0
  145. package/dist/client_prod/static/js/async/web-elements-textarea.js +1 -0
  146. package/dist/client_prod/static/js/async/web-elements-viewpager.js +1 -0
  147. package/dist/client_prod/static/js/client.js +2 -0
  148. package/dist/client_prod/static/wasm/7ff75609.module.wasm +0 -0
  149. package/dist/constants.d.ts +58 -0
  150. package/dist/constants.js +114 -0
  151. package/dist/encode/encodeCSS.d.ts +3 -0
  152. package/dist/encode/encodeCSS.js +99 -0
  153. package/dist/encode/encodeElementTemplate.d.ts +2 -0
  154. package/dist/encode/encodeElementTemplate.js +52 -0
  155. package/dist/encode/index.d.ts +1 -0
  156. package/dist/encode/index.js +7 -0
  157. package/dist/encode/webEncoder.d.ts +21 -0
  158. package/dist/encode/webEncoder.js +125 -0
  159. package/dist/types/BTSChunk.d.ts +3 -0
  160. package/dist/types/BTSChunk.js +5 -0
  161. package/dist/types/Cloneable.d.ts +2 -0
  162. package/dist/types/Cloneable.js +2 -0
  163. package/dist/types/DecodedTemplate.d.ts +10 -0
  164. package/dist/types/DecodedTemplate.js +7 -0
  165. package/dist/types/Element.d.ts +35 -0
  166. package/dist/types/Element.js +5 -0
  167. package/dist/types/ElementTemplateData.d.ts +15 -0
  168. package/dist/types/ElementTemplateData.js +7 -0
  169. package/dist/types/EventType.d.ts +56 -0
  170. package/dist/types/EventType.js +5 -0
  171. package/dist/types/I18nTypes.d.ts +21 -0
  172. package/dist/types/I18nTypes.js +2 -0
  173. package/dist/types/IElementPAPI.d.ts +184 -0
  174. package/dist/types/IElementPAPI.js +2 -0
  175. package/dist/types/IMtsBinding.d.ts +11 -0
  176. package/dist/types/IMtsBinding.js +7 -0
  177. package/dist/types/JSRealm.d.ts +5 -0
  178. package/dist/types/JSRealm.js +7 -0
  179. package/dist/types/LynxContextEventTarget.d.ts +12 -0
  180. package/dist/types/LynxContextEventTarget.js +5 -0
  181. package/dist/types/MainThreadLynx.d.ts +15 -0
  182. package/dist/types/MainThreadLynx.js +2 -0
  183. package/dist/types/NapiModules.d.ts +9 -0
  184. package/dist/types/NapiModules.js +5 -0
  185. package/dist/types/NativeApp.d.ts +120 -0
  186. package/dist/types/NativeApp.js +5 -0
  187. package/dist/types/NativeModules.d.ts +2 -0
  188. package/dist/types/NativeModules.js +5 -0
  189. package/dist/types/PageConfig.d.ts +9 -0
  190. package/dist/types/PageConfig.js +2 -0
  191. package/dist/types/ProcessDataCallback.d.ts +1 -0
  192. package/dist/types/ProcessDataCallback.js +2 -0
  193. package/dist/types/TimingAPIs.d.ts +32 -0
  194. package/dist/types/TimingAPIs.js +5 -0
  195. package/dist/types/UpdateDataOptions.d.ts +8 -0
  196. package/dist/types/UpdateDataOptions.js +6 -0
  197. package/dist/types/WorkerStartMessage.d.ts +14 -0
  198. package/dist/types/WorkerStartMessage.js +5 -0
  199. package/dist/types/index.d.ts +20 -0
  200. package/dist/types/index.js +7 -0
  201. package/eslint.config.js +34 -0
  202. package/package.json +87 -4
  203. package/index.js +0 -1
  204. package/selfIdentity.plist +0 -0
@@ -0,0 +1,8 @@
1
+ import type { EventEmitter } from '../../../types/index.js';
2
+ import type { Rpc } from '@lynx-js/web-worker-rpc';
3
+ export type TimingSystem = {
4
+ registerGlobalEmitter: (globalEventEmitter: EventEmitter) => void;
5
+ markTimingInternal: (timingKey: string, pipelineId?: string) => void;
6
+ pipelineIdToTimingFlags: Map<string, string[]>;
7
+ };
8
+ export declare function createTimingSystem(mainThreadRpc: Rpc, uiThreadRpc: Rpc): TimingSystem;
@@ -0,0 +1,86 @@
1
+ // Copyright 2023 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { dispatchLynxViewEventEndpoint, markTimingEndpoint, postTimingFlagsEndpoint, } from '../../endpoints.js';
5
+ const ListenerKeys = {
6
+ onSetup: 'lynx.performance.timing.onSetup',
7
+ onUpdate: 'lynx.performance.timing.onUpdate',
8
+ };
9
+ export function createTimingSystem(mainThreadRpc, uiThreadRpc) {
10
+ let isFp = true;
11
+ const setupTiming = {};
12
+ const pipelineIdToTiming = new Map();
13
+ const pipelineIdToTimingFlags = new Map();
14
+ const dispatchLynxViewEvent = uiThreadRpc.createCall(dispatchLynxViewEventEndpoint);
15
+ let commonTimingFlags = [];
16
+ function markTimingInternal(markTimingRecords) {
17
+ for (let { timingKey, pipelineId, timeStamp } of markTimingRecords) {
18
+ if (!timeStamp)
19
+ timeStamp = performance.now() + performance.timeOrigin;
20
+ if (!pipelineId) {
21
+ setupTiming[timingKey] = timeStamp;
22
+ continue;
23
+ }
24
+ if (!pipelineIdToTiming.has(pipelineId)) {
25
+ pipelineIdToTiming.set(pipelineId, {});
26
+ }
27
+ const timingInfo = pipelineIdToTiming.get(pipelineId);
28
+ timingInfo[timingKey] = timeStamp;
29
+ }
30
+ }
31
+ const registerGlobalEmitter = (globalEventEmitter) => {
32
+ mainThreadRpc.registerHandler(postTimingFlagsEndpoint, (timingFlags, pipelineId) => {
33
+ if (!pipelineId) {
34
+ commonTimingFlags = commonTimingFlags.concat(timingFlags);
35
+ }
36
+ else
37
+ timingFlags = timingFlags.concat(commonTimingFlags);
38
+ if (isFp) {
39
+ const timingInfo = {
40
+ extra_timing: {},
41
+ setup_timing: setupTiming,
42
+ update_timings: {},
43
+ metrics: {},
44
+ has_reload: false,
45
+ thread_strategy: 0,
46
+ url: '',
47
+ };
48
+ globalEventEmitter.emit(ListenerKeys.onSetup, [timingInfo]);
49
+ dispatchLynxViewEvent('timing', setupTiming);
50
+ }
51
+ else {
52
+ const timings = (pipelineId ? pipelineIdToTiming.get(pipelineId) : undefined) ?? {};
53
+ const flags = [
54
+ ...timingFlags,
55
+ ...(pipelineIdToTimingFlags.get(pipelineId) ?? []),
56
+ ];
57
+ const timingInfo = {
58
+ extra_timing: {},
59
+ setup_timing: {},
60
+ update_timings: Object.fromEntries([...flags].map(flag => [flag, timings])),
61
+ metrics: {},
62
+ has_reload: false,
63
+ thread_strategy: 0,
64
+ url: '',
65
+ };
66
+ globalEventEmitter.emit(ListenerKeys.onUpdate, [timingInfo]);
67
+ dispatchLynxViewEvent('timing', timings);
68
+ }
69
+ if (pipelineId) {
70
+ pipelineIdToTimingFlags.delete(pipelineId);
71
+ pipelineIdToTiming.delete(pipelineId);
72
+ }
73
+ if (isFp) {
74
+ isFp = false;
75
+ }
76
+ });
77
+ };
78
+ mainThreadRpc.registerHandler(markTimingEndpoint, markTimingInternal);
79
+ uiThreadRpc.registerHandler(markTimingEndpoint, markTimingInternal);
80
+ return {
81
+ markTimingInternal: (timingKey, pipelineId, timeStamp) => markTimingInternal([{ timingKey, pipelineId, timeStamp }]),
82
+ registerGlobalEmitter,
83
+ pipelineIdToTimingFlags,
84
+ };
85
+ }
86
+ //# sourceMappingURL=createTimingSystem.js.map
@@ -0,0 +1,3 @@
1
+ import type { Rpc } from '@lynx-js/web-worker-rpc';
2
+ import type { Cloneable } from '../../../../types/index.js';
3
+ export declare function createGetCustomSection(rpc: Rpc, customSections: Record<string, Cloneable>): (key: string, callback: (object: Cloneable) => void) => void;
@@ -0,0 +1,14 @@
1
+ // Copyright 2023 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { getCustomSectionsEndpoint } from '../../../endpoints.js';
5
+ export function createGetCustomSection(rpc, customSections) {
6
+ const getCustomSections = rpc.createCall(getCustomSectionsEndpoint);
7
+ return (key, callback) => {
8
+ if (customSections[key]) {
9
+ return callback(customSections[key]);
10
+ }
11
+ getCustomSections(key).then(callback);
12
+ };
13
+ }
14
+ //# sourceMappingURL=createGetCustomSection.js.map
@@ -0,0 +1,3 @@
1
+ import type { Rpc } from '@lynx-js/web-worker-rpc';
2
+ import type { NativeApp } from '../../../../types/index.js';
3
+ export declare function createGetPathInfo(rpc: Rpc): NativeApp['getPathInfo'];
@@ -0,0 +1,23 @@
1
+ // Copyright 2023 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { getPathInfoEndpoint } from '../../../endpoints.js';
5
+ import { ErrorCode } from '../../../../constants.js';
6
+ export function createGetPathInfo(rpc) {
7
+ return (type, identifier, component_id, first_only, callback, root_unique_id) => {
8
+ rpc.invoke(getPathInfoEndpoint, [
9
+ type,
10
+ identifier,
11
+ component_id,
12
+ first_only,
13
+ root_unique_id,
14
+ ]).then(callback).catch((error) => {
15
+ console.error(`[lynx-web] getPathInfo failed`, error);
16
+ callback({
17
+ code: ErrorCode.UNKNOWN,
18
+ data: error.message || '',
19
+ });
20
+ });
21
+ };
22
+ }
23
+ //# sourceMappingURL=createGetPathInfo.js.map
@@ -0,0 +1,3 @@
1
+ import type { NativeApp } from '../../../../types/index.js';
2
+ import type { Rpc } from '@lynx-js/web-worker-rpc';
3
+ export declare function createInvokeUIMethod(rpc: Rpc): NativeApp['invokeUIMethod'];
@@ -0,0 +1,24 @@
1
+ // Copyright 2023 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { invokeUIMethodEndpoint } from '../../../endpoints.js';
5
+ import { ErrorCode } from '../../../../constants.js';
6
+ export function createInvokeUIMethod(rpc) {
7
+ return (type, identifier, component_id, method, params, callback, root_unique_id) => {
8
+ rpc.invoke(invokeUIMethodEndpoint, [
9
+ type,
10
+ identifier,
11
+ component_id,
12
+ method,
13
+ params,
14
+ root_unique_id,
15
+ ]).then(callback).catch((error) => {
16
+ console.error(`[lynx-web] invokeUIMethod failed`, error);
17
+ callback({
18
+ code: ErrorCode.UNKNOWN,
19
+ data: '',
20
+ });
21
+ });
22
+ };
23
+ }
24
+ //# sourceMappingURL=createInvokeUIMethod.js.map
@@ -0,0 +1,2 @@
1
+ import type { NativeApp } from '../../../../types/index.js';
2
+ export declare function createJSObjectDestructionObserver(): NativeApp['createJSObjectDestructionObserver'];
@@ -0,0 +1,12 @@
1
+ // Copyright 2023 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ export function createJSObjectDestructionObserver() {
5
+ const registry = new FinalizationRegistry((callback) => callback());
6
+ return (cleanupCallback) => {
7
+ const observedObject = {};
8
+ registry.register(observedObject, cleanupCallback);
9
+ return observedObject;
10
+ };
11
+ }
12
+ //# sourceMappingURL=createJSObjectDestructionObserver.js.map
@@ -0,0 +1,3 @@
1
+ import type { NativeApp } from '../../../../types/index.js';
2
+ import type { Rpc } from '@lynx-js/web-worker-rpc';
3
+ export declare function registerDisposeHandler(rpc: Rpc, nativeApp: NativeApp, destroyCard: typeof import('@lynx-js/lynx-core/web')['destroyCard'], callDestroyLifetimeFun: typeof import('@lynx-js/lynx-core/web')['callDestroyLifetimeFun']): void;
@@ -0,0 +1,9 @@
1
+ import { disposeEndpoint } from '../../../endpoints.js';
2
+ export function registerDisposeHandler(rpc, nativeApp, destroyCard, callDestroyLifetimeFun) {
3
+ rpc.registerHandler(disposeEndpoint, () => {
4
+ const id = nativeApp.id;
5
+ callDestroyLifetimeFun(id);
6
+ destroyCard(id);
7
+ });
8
+ }
9
+ //# sourceMappingURL=registerDisposeHandler.js.map
@@ -0,0 +1,3 @@
1
+ import type { NativeTTObject } from '../../../../types/index.js';
2
+ import type { Rpc } from '@lynx-js/web-worker-rpc';
3
+ export declare function registerPublicComponentEventHandler(rpc: Rpc, tt: NativeTTObject): void;
@@ -0,0 +1,8 @@
1
+ // Copyright 2023 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { publicComponentEventEndpoint } from '../../../endpoints.js';
5
+ export function registerPublicComponentEventHandler(rpc, tt) {
6
+ rpc.registerHandlerLazy(publicComponentEventEndpoint, tt, 'publicComponentEvent');
7
+ }
8
+ //# sourceMappingURL=registerPublicComponentEventHandler.js.map
@@ -0,0 +1,3 @@
1
+ import type { NativeTTObject } from '../../../../types/index.js';
2
+ import type { Rpc } from '@lynx-js/web-worker-rpc';
3
+ export declare function registerPublishEventHandler(rpc: Rpc, tt: NativeTTObject): void;
@@ -0,0 +1,8 @@
1
+ // Copyright 2023 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { publishEventEndpoint } from '../../../endpoints.js';
5
+ export function registerPublishEventHandler(rpc, tt) {
6
+ rpc.registerHandlerLazy(publishEventEndpoint, tt, 'publishEvent');
7
+ }
8
+ //# sourceMappingURL=registerPublishEventHandler.js.map
@@ -0,0 +1,3 @@
1
+ import type { NativeTTObject } from '../../../../types/index.js';
2
+ import type { Rpc } from '@lynx-js/web-worker-rpc';
3
+ export declare function registerSendGlobalEventHandler(rpc: Rpc, tt: NativeTTObject): void;
@@ -0,0 +1,10 @@
1
+ // Copyright 2023 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { sendGlobalEventEndpoint } from '../../../endpoints.js';
5
+ export function registerSendGlobalEventHandler(rpc, tt) {
6
+ rpc.registerHandler(sendGlobalEventEndpoint, (...args) => {
7
+ tt.GlobalEventEmitter.emit(...args);
8
+ });
9
+ }
10
+ //# sourceMappingURL=registerSendGlobalEvent.js.map
@@ -0,0 +1,3 @@
1
+ import type { NativeTTObject } from '../../../../types/index.js';
2
+ import type { Rpc } from '@lynx-js/web-worker-rpc';
3
+ export declare function registerUpdateDataHandler(rpc: Rpc, tt: NativeTTObject): void;
@@ -0,0 +1,5 @@
1
+ import { updateDataEndpoint } from '../../../endpoints.js';
2
+ export function registerUpdateDataHandler(rpc, tt) {
3
+ rpc.registerHandlerLazy(updateDataEndpoint, tt, 'updateCardData');
4
+ }
5
+ //# sourceMappingURL=registerUpdateDataHandler.js.map
@@ -0,0 +1,3 @@
1
+ import type { NativeTTObject } from '../../../../types/index.js';
2
+ import type { Rpc } from '@lynx-js/web-worker-rpc';
3
+ export declare function registerUpdateGlobalPropsHandler(rpc: Rpc, tt: NativeTTObject): void;
@@ -0,0 +1,5 @@
1
+ import { updateGlobalPropsEndpoint } from '../../../endpoints.js';
2
+ export function registerUpdateGlobalPropsHandler(rpc, tt) {
3
+ rpc.registerHandlerLazy(updateGlobalPropsEndpoint, tt, 'updateGlobalProps');
4
+ }
5
+ //# sourceMappingURL=registerUpdateGlobalPropsHandler.js.map
@@ -0,0 +1,3 @@
1
+ import type { II18nResource, NativeTTObject } from '../../../../types/index.js';
2
+ import type { Rpc } from '@lynx-js/web-worker-rpc';
3
+ export declare function registerUpdateI18nResource(mainThreadRpc: Rpc, i18nResource: II18nResource, tt: NativeTTObject): void;
@@ -0,0 +1,9 @@
1
+ import { dispatchI18nResourceEndpoint } from '../../../endpoints.js';
2
+ export function registerUpdateI18nResource(mainThreadRpc, i18nResource, tt) {
3
+ // dispatchI18nResource from mts
4
+ mainThreadRpc.registerHandler(dispatchI18nResourceEndpoint, (data) => {
5
+ i18nResource.setData(data);
6
+ tt.GlobalEventEmitter.emit('onI18nResourceReady', []);
7
+ });
8
+ }
9
+ //# sourceMappingURL=registerUpdateI18nResource.js.map
@@ -0,0 +1,2 @@
1
+ import type { WorkerStartMessage } from '../../../types/WorkerStartMessage.js';
2
+ export declare function startBackgroundThread(startMessage: WorkerStartMessage): void;
@@ -0,0 +1,42 @@
1
+ // Copyright 2023 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { Rpc } from '@lynx-js/web-worker-rpc';
5
+ import { createBackgroundLynx } from './createBackgroundLynx.js';
6
+ import { createNativeApp } from './createNativeApp.js';
7
+ import { registerDisposeHandler } from './crossThreadHandlers/registerDisposeHandler.js';
8
+ import { BackgroundThreadStartEndpoint } from '../../endpoints.js';
9
+ import { createNapiLoader } from './createNapiLoader.js';
10
+ import { createTimingSystem } from './createTimingSystem.js';
11
+ export function startBackgroundThread(startMessage) {
12
+ const { mainThreadMessagePort, napiModulesMap, nativeModulesMap, initData, globalProps, customSections, cardType, entryTemplateUrl, } = startMessage;
13
+ const mainThreadPort = mainThreadMessagePort;
14
+ const mainThreadRpc = new Rpc(mainThreadPort, 'bg-to-main');
15
+ const timingSystem = createTimingSystem(mainThreadRpc, mainThreadRpc);
16
+ timingSystem.markTimingInternal('load_core_start');
17
+ const nativeApp = createNativeApp(mainThreadRpc, timingSystem, nativeModulesMap, entryTemplateUrl);
18
+ const lynxCore = import(
19
+ /* webpackChunkName: "lynx-core-chunk" */
20
+ '@lynx-js/lynx-core/web');
21
+ const napiLoader = createNapiLoader(mainThreadRpc, napiModulesMap);
22
+ Promise.all([lynxCore, nativeApp, napiLoader]).then(([lynxCore, nativeApp, napiLoader]) => {
23
+ timingSystem.markTimingInternal('load_core_end');
24
+ globalThis['napiLoaderOnRT' + nativeApp.id] = napiLoader;
25
+ const nativeLynx = createBackgroundLynx(globalProps, customSections, nativeApp, mainThreadRpc);
26
+ const { loadCard, destroyCard, callDestroyLifetimeFun, nativeGlobal, loadDynamicComponent, } = lynxCore;
27
+ // @lynx-js/lynx-core >= 0.1.3 will export nativeGlobal and loadDynamicComponent
28
+ if (nativeGlobal && loadDynamicComponent) {
29
+ nativeGlobal.loadDynamicComponent = loadDynamicComponent;
30
+ }
31
+ mainThreadRpc.registerHandler(BackgroundThreadStartEndpoint, () => {
32
+ loadCard(nativeApp, {
33
+ initData,
34
+ cardType,
35
+ // @ts-ignore
36
+ updateData: initData,
37
+ }, nativeLynx);
38
+ });
39
+ registerDisposeHandler(mainThreadRpc, nativeApp, destroyCard, callDestroyLifetimeFun);
40
+ });
41
+ }
42
+ //# sourceMappingURL=startBackgroundThread.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ import { startBackgroundThread } from './background-apis/startBackgroundThread.js';
2
+ // @ts-expect-error
3
+ globalThis.nativeConsole = console;
4
+ globalThis.onmessage = async (ev) => {
5
+ const message = ev
6
+ .data;
7
+ if (!globalThis.SystemInfo) {
8
+ globalThis.SystemInfo = message.systemInfo;
9
+ }
10
+ startBackgroundThread(message);
11
+ };
12
+ Object.assign(globalThis, {
13
+ module: { exports: null },
14
+ });
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,12 @@
1
+ interface CSSRule {
2
+ sel: string[][][];
3
+ decl: [string, string][];
4
+ }
5
+ interface OneInfo {
6
+ content: string[];
7
+ rules: CSSRule[];
8
+ imports?: string[];
9
+ }
10
+ type StyleInfo = Record<string, OneInfo>;
11
+ export declare function loadStyleFromJSON(styleInfo: StyleInfo, configEnableCssSelector: boolean, entryName?: string): Uint8Array;
12
+ export {};
@@ -0,0 +1,96 @@
1
+ import { wasmInstance } from '../wasm.js';
2
+ export function loadStyleFromJSON(styleInfo, configEnableCssSelector, entryName) {
3
+ const rawStyleInfo = new wasmInstance.RawStyleInfo();
4
+ for (const [cssIdStr, info] of Object.entries(styleInfo)) {
5
+ const cssId = parseInt(cssIdStr, 10);
6
+ // Handle imports
7
+ if (info.imports) {
8
+ // imports in StyleInfo are filenames/hrefs, but RawStyleInfo expects cssIds.
9
+ // Wait, genStyleInfo output imports as string hrefs?
10
+ // RawStyleInfo: imports: Vec<i32>
11
+ // It seems genStyleInfo.ts produces imports array of strings, but RawStyleInfo needs integers.
12
+ // If the JSON only contains strings, we might have a problem mapping them back to IDs unless we have a map.
13
+ // However, WebEncodePlugin usually handles mapping.
14
+ // Let's check genStyleInfo again.
15
+ // node.type === 'ImportRule' => imports.push(node.href).
16
+ // If imports are paths, we can't easily convert to ID without extra info.
17
+ // BUT, current usage of imports in RawStyleInfo is strictly ID-based.
18
+ // If the input JSON has hrefs, we might skip imports or error.
19
+ // For now, I will omit imports if they are strings, or try to parse if they look like IDs.
20
+ // Actually, in the ecosystem, imports might not be fully supported in JSON mode yet or resolved differently.
21
+ // I will log or ignore for now, focusing on Rules.
22
+ }
23
+ // Handle rules
24
+ for (const rule of info.rules) {
25
+ const wasmRule = new wasmInstance.Rule('StyleRule');
26
+ // Declarations
27
+ for (const [prop, val] of rule.decl) {
28
+ wasmRule.push_declaration(prop, val);
29
+ }
30
+ // Selectors
31
+ const prelude = new wasmInstance.RulePrelude();
32
+ for (const selectorChain of rule.sel) {
33
+ const selector = new wasmInstance.Selector();
34
+ // Iterate in chunks of 4
35
+ for (let i = 0; i < selectorChain.length; i += 4) {
36
+ const plain = selectorChain[i] || [];
37
+ const pseudoClass = selectorChain[i + 1] || [];
38
+ const pseudoElement = selectorChain[i + 2] || [];
39
+ const combinator = selectorChain[i + 3] || [];
40
+ for (const s of plain) {
41
+ parseAndPushSelector(selector, s);
42
+ }
43
+ for (const s of pseudoClass) {
44
+ // Strip leading :
45
+ const val = s.startsWith(':') ? s.substring(1) : s;
46
+ selector.push_one_selector_section('PseudoClassSelector', val);
47
+ }
48
+ for (const s of pseudoElement) {
49
+ // Strip leading ::
50
+ const val = s.startsWith('::')
51
+ ? s.substring(2)
52
+ : s.startsWith(':')
53
+ ? s.substring(1)
54
+ : s;
55
+ selector.push_one_selector_section('PseudoElementSelector', val);
56
+ }
57
+ if (combinator.length > 0) {
58
+ selector.push_one_selector_section('Combinator', combinator[0]);
59
+ }
60
+ }
61
+ prelude.push_selector(selector);
62
+ }
63
+ wasmRule.set_prelude(prelude);
64
+ rawStyleInfo.push_rule(cssId, wasmRule);
65
+ }
66
+ }
67
+ // Use the new Rust method
68
+ return wasmInstance.DecodedStyleData.encode_from_raw_style_info(rawStyleInfo, configEnableCssSelector, entryName);
69
+ }
70
+ function parseAndPushSelector(selector, s) {
71
+ if (s.startsWith('.')) {
72
+ selector.push_one_selector_section('ClassSelector', s.substring(1));
73
+ }
74
+ else if (s.startsWith('#')) {
75
+ selector.push_one_selector_section('IdSelector', s.substring(1));
76
+ }
77
+ else if (s.startsWith('[')) {
78
+ // Attribute: [attr=val]
79
+ // Remove enclosing []
80
+ const content = s.substring(1, s.length - 1);
81
+ selector.push_one_selector_section('AttributeSelector', content);
82
+ }
83
+ else if (s === '*') {
84
+ selector.push_one_selector_section('UniversalSelector', '*');
85
+ }
86
+ else {
87
+ // Type selector
88
+ // It comes as [lynx-tag="div"] usually.
89
+ let content = s;
90
+ if (s.startsWith('[') && s.endsWith(']')) {
91
+ content = s.substring(1, s.length - 1);
92
+ }
93
+ selector.push_one_selector_section('AttributeSelector', content);
94
+ }
95
+ }
96
+ //# sourceMappingURL=cssLoader.js.map
@@ -0,0 +1 @@
1
+ export {};