@lynx-js/web-constants-canary 0.16.0 → 0.16.1-canary-20250910-c24b6021

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @lynx-js/web-constants
2
2
 
3
+ ## 0.16.1-canary-20250910033502-c24b60214bbb194adfd96985f3f80d1e0f5a0e08
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @lynx-js/web-worker-rpc@0.16.1-canary-20250910033502-c24b60214bbb194adfd96985f3f80d1e0f5a0e08
9
+
3
10
  ## 0.16.0
4
11
 
5
12
  ### Minor Changes
@@ -178,25 +185,25 @@
178
185
  lynxView.initI18nResources = [
179
186
  {
180
187
  options: {
181
- locale: 'en',
182
- channel: '1',
183
- fallback_url: '',
188
+ locale: "en",
189
+ channel: "1",
190
+ fallback_url: "",
184
191
  },
185
192
  resource: {
186
- hello: 'hello',
187
- lynx: 'lynx web platform1',
193
+ hello: "hello",
194
+ lynx: "lynx web platform1",
188
195
  },
189
196
  },
190
197
  ];
191
- lynxView.addEventListener('i18nResourceMissed', (e) => {
198
+ lynxView.addEventListener("i18nResourceMissed", (e) => {
192
199
  console.log(e);
193
200
  });
194
201
 
195
202
  // mts
196
203
  _I18nResourceTranslation({
197
- locale: 'en',
198
- channel: '1',
199
- fallback_url: '',
204
+ locale: "en",
205
+ channel: "1",
206
+ fallback_url: "",
200
207
  });
201
208
  ```
202
209
 
@@ -435,8 +442,8 @@
435
442
  }
436
443
  };`,
437
444
  ],
438
- { type: 'text/javascript' },
439
- ),
445
+ { type: "text/javascript" }
446
+ )
440
447
  ),
441
448
  };
442
449
  lynxView.nativeModulesMap = nativeModulesMap;
@@ -522,8 +529,8 @@
522
529
  };
523
530
  };`,
524
531
  ],
525
- { type: 'text/javascript' },
526
- ),
532
+ { type: "text/javascript" }
533
+ )
527
534
  );
528
535
 
529
536
  const color_methods = URL.createObjectURL(
@@ -538,8 +545,8 @@
538
545
  };
539
546
  };`,
540
547
  ],
541
- { type: 'text/javascript' },
542
- ),
548
+ { type: "text/javascript" }
549
+ )
543
550
  );
544
551
 
545
552
  lynxView.napiModuleMap = {
@@ -556,7 +563,7 @@
556
563
 
557
564
  ```js
558
565
  lynxView.onNapiModulesCall = (name, data, moduleName) => {
559
- if (name === 'getColor' && moduleName === 'color_methods') {
566
+ if (name === "getColor" && moduleName === "color_methods") {
560
567
  return data.color;
561
568
  }
562
569
  };
@@ -620,8 +627,8 @@
620
627
  }
621
628
  };`,
622
629
  ],
623
- { type: 'text/javascript' },
624
- ),
630
+ { type: "text/javascript" }
631
+ )
625
632
  );
626
633
  ```
627
634
 
@@ -633,7 +640,7 @@
633
640
 
634
641
  ```js
635
642
  lynxView.onNativeModulesCall = (name, data, callback) => {
636
- if (name === 'getColor') {
643
+ if (name === "getColor") {
637
644
  callback(data.color);
638
645
  }
639
646
  };
@@ -643,7 +650,7 @@
643
650
 
644
651
  ```js
645
652
  lynxView.onNativeModulesCall = (name, data, moduleName) => {
646
- if (name === 'getColor' && moduleName === 'bridge') {
653
+ if (name === "getColor" && moduleName === "bridge") {
647
654
  return data.color;
648
655
  }
649
656
  };
@@ -37,6 +37,7 @@ export interface LynxTemplate {
37
37
  };
38
38
  elementTemplate: Record<string, ElementTemplateData[]>;
39
39
  version?: number;
40
+ appType: 'card' | 'lazy';
40
41
  }
41
42
  export interface LynxJSModule {
42
43
  exports?: (lynx_runtime: any) => unknown;
@@ -42,12 +42,15 @@ const templateUpgraders = [
42
42
  'requestAnimationFrame',
43
43
  'cancelAnimationFrame',
44
44
  ].join(',');
45
+ template.appType = template.lepusCode.root.startsWith('(function (globDynamicComponentEntry')
46
+ ? 'lazy'
47
+ : 'card';
45
48
  /**
46
49
  * The template version 1 has no module wrapper for bts code
47
50
  */
48
51
  template.manifest = Object.fromEntries(Object.entries(template.manifest).map(([key, value]) => [
49
52
  key,
50
- `{init: (lynxCoreInject) => { var {${defaultInjectStr}} = lynxCoreInject.tt; var module = {exports:null}; ${value}\n return module.exports; } }`,
53
+ `module.exports={init: (lynxCoreInject) => { var {${defaultInjectStr}} = lynxCoreInject.tt; var module = {exports:null}; ${value}\n return module.exports; } }`,
51
54
  ]));
52
55
  template.lepusCode = Object.fromEntries(Object.entries(template.lepusCode).map(([key, value]) => [
53
56
  key,
@@ -57,17 +60,29 @@ const templateUpgraders = [
57
60
  return template;
58
61
  },
59
62
  ];
60
- const generateModuleContent = (content) => [
61
- '//# allFunctionsCalledOnLoad\n',
62
- '"use strict";\n',
63
- `(() => {const ${globalDisallowedVars.join('=void 0,')}=void 0;module.exports = `,
63
+ const generateModuleContent = (content, eager) =>
64
+ /**
65
+ * About the `allFunctionsCalledOnLoad` directive:
66
+ * https://v8.dev/blog/preparser#pife
67
+ * https://github.com/WICG/explicit-javascript-compile-hints-file-based?tab=readme-ov-file
68
+ * https://v8.dev/blog/explicit-compile-hints
69
+ * We should ensure the MTS code is parsed eagerly to avoid runtime parse delay.
70
+ * But for BTS code, we should not do this as it would increase the memory usage.
71
+ * JavaScript Engines, like V8, already had optimizations for code starts with "(function"
72
+ * to be parsed eagerly.
73
+ */
74
+ [
75
+ eager ? '//# allFunctionsCalledOnLoad' : '',
76
+ '\n(function() { "use strict"; const ',
77
+ globalDisallowedVars.join('=void 0,'),
78
+ '=void 0;\n',
64
79
  content,
65
80
  '\n})()',
66
81
  ].join('');
67
- async function generateJavascriptUrl(obj, createJsModuleUrl, templateName) {
82
+ async function generateJavascriptUrl(obj, createJsModuleUrl, eager, templateName) {
68
83
  const processEntry = async ([name, content]) => [
69
84
  name,
70
- await createJsModuleUrl(generateModuleContent(content), `${templateName}-${name.replaceAll('/', '')}.js`),
85
+ await createJsModuleUrl(generateModuleContent(content, eager), `${templateName}-${name.replaceAll('/', '')}.js`),
71
86
  ];
72
87
  return Promise.all(Object.entries(obj).filter(([_, content]) => typeof content === 'string').map(processEntry)).then(Object.fromEntries);
73
88
  }
@@ -83,8 +98,8 @@ export async function generateTemplate(template, createJsModuleUrl, templateName
83
98
  }
84
99
  return {
85
100
  ...template,
86
- lepusCode: await generateJavascriptUrl(template.lepusCode, createJsModuleUrl, templateName),
87
- manifest: await generateJavascriptUrl(template.manifest, createJsModuleUrl, templateName),
101
+ lepusCode: await generateJavascriptUrl(template.lepusCode, createJsModuleUrl, true, templateName),
102
+ manifest: await generateJavascriptUrl(template.manifest, createJsModuleUrl, false, templateName),
88
103
  };
89
104
  }
90
105
  //# sourceMappingURL=generateTemplate.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-constants-canary",
3
- "version": "0.16.0",
3
+ "version": "0.16.1-canary-20250910-c24b6021",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -23,7 +23,7 @@
23
23
  "**/*.css"
24
24
  ],
25
25
  "dependencies": {
26
- "@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.16.0"
26
+ "@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.16.1-canary-20250910-c24b6021"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@lynx-js/offscreen-document": "npm:@lynx-js/offscreen-document-canary@0.1.4"