@lynx-js/web-core-server 0.13.5 → 0.14.1

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,50 @@
1
1
  # @lynx-js/web-core-server
2
2
 
3
+ ## 0.14.1
4
+
5
+ ## 0.14.0
6
+
7
+ ### Patch Changes
8
+
9
+ - feat: add `_SetSourceMapRelease(errInfo)` MTS API. ([#1118](https://github.com/lynx-family/lynx-stack/pull/1118))
10
+
11
+ You can get `errInfo.release` through `e.detail.release` in the error event callback of lynx-view.
12
+
13
+ The `_SetSourceMapRelease` function is not complete yet, because it is currently limited by the Web platform and some functions and some props such as `err.stack` do not need to be supported for the time being.
14
+
15
+ - feat: add `_I18nResourceTranslation` api in mts && `init-i18n-resources` attr, `i18nResourceMissed` event of lynx-view. ([#1065](https://github.com/lynx-family/lynx-stack/pull/1065))
16
+
17
+ `init-i18n-resource` is the complete set of i18nResources that need to be maintained on the container side. Note: You need to pass this value when lynx-view is initialized.
18
+
19
+ You can use `_I18nResourceTranslation` in MTS to get the corresponding i18nResource from `init-i18n-resources`. If it is undefined, the `i18nResourceMissed` event will be dispatched.
20
+
21
+ ```js
22
+ // ui thread
23
+ lynxView.initI18nResources = [
24
+ {
25
+ options: {
26
+ locale: 'en',
27
+ channel: '1',
28
+ fallback_url: '',
29
+ },
30
+ resource: {
31
+ hello: 'hello',
32
+ lynx: 'lynx web platform1',
33
+ },
34
+ },
35
+ ];
36
+ lynxView.addEventListener('i18nResourceMissed', (e) => {
37
+ console.log(e);
38
+ });
39
+
40
+ // mts
41
+ _I18nResourceTranslation({
42
+ locale: 'en',
43
+ channel: '1',
44
+ fallback_url: '',
45
+ });
46
+ ```
47
+
3
48
  ## 0.13.5
4
49
 
5
50
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  import { type StartMainThreadContextConfig } from '@lynx-js/web-constants';
2
- interface LynxViewConfig extends Pick<StartMainThreadContextConfig, 'browserConfig' | 'tagMap' | 'initData' | 'globalProps' | 'template'> {
2
+ interface LynxViewConfig extends Pick<StartMainThreadContextConfig, 'browserConfig' | 'tagMap' | 'initData' | 'globalProps' | 'template' | 'initI18nResources'> {
3
3
  templateName?: string;
4
4
  hydrateUrl: string;
5
5
  injectStyles: string;
@@ -1,4 +1,4 @@
1
- import { inShadowRootStyles, lynxUniqueIdAttribute, } from '@lynx-js/web-constants';
1
+ import { I18nResources, inShadowRootStyles, lynxUniqueIdAttribute, } from '@lynx-js/web-constants';
2
2
  import { Rpc } from '@lynx-js/web-worker-rpc';
3
3
  import { prepareMainThreadAPIs } from '@lynx-js/web-mainthread-apis';
4
4
  import { loadTemplate } from './utils/loadTemplate.js';
@@ -35,7 +35,7 @@ OffscreenElement.prototype.toJSON = function toJSON() {
35
35
  };
36
36
  };
37
37
  export async function createLynxView(config) {
38
- const { template: rawTemplate, browserConfig, tagMap, initData, globalProps, overrideElementTemplates = {}, hydrateUrl, autoSize, injectStyles, lynxViewStyle, threadStrategy = 'all-on-ui', } = config;
38
+ const { template: rawTemplate, browserConfig, tagMap, initData, globalProps, overrideElementTemplates = {}, hydrateUrl, autoSize, injectStyles, lynxViewStyle, threadStrategy = 'all-on-ui', initI18nResources, } = config;
39
39
  const template = await loadTemplate(rawTemplate, config.templateName);
40
40
  const { promise: firstPaintReadyPromise, resolve: firstPaintReady } = Promise
41
41
  .withResolvers();
@@ -45,12 +45,18 @@ export async function createLynxView(config) {
45
45
  onCommit: () => {
46
46
  },
47
47
  });
48
+ const i18nResources = new I18nResources();
48
49
  const { startMainThread } = prepareMainThreadAPIs(backgroundThreadRpc, offscreenDocument, offscreenDocument.createElement.bind(offscreenDocument), () => {
49
50
  firstPaintReady();
50
51
  }, () => {
51
52
  // mark timing
52
53
  }, () => {
53
54
  // report error
55
+ }, () => {
56
+ // trigger i18n resource fallback
57
+ }, (initI18nResources) => {
58
+ i18nResources.setData(initI18nResources);
59
+ return i18nResources;
54
60
  });
55
61
  const runtime = await startMainThread({
56
62
  template,
@@ -63,6 +69,7 @@ export async function createLynxView(config) {
63
69
  ...builtinTagTransformMap,
64
70
  ...tagMap,
65
71
  },
72
+ initI18nResources,
66
73
  });
67
74
  const elementTemplates = {
68
75
  ...builtinElementTemplates,
@@ -40,6 +40,7 @@ const mainThreadInjectVars = [
40
40
  'lynx',
41
41
  'globalThis',
42
42
  '_ReportError',
43
+ '_SetSourceMapRelease',
43
44
  '__AddConfig',
44
45
  '__AddDataset',
45
46
  '__GetAttributes',
@@ -93,6 +94,8 @@ const mainThreadInjectVars = [
93
94
  '__FlushElementTree',
94
95
  '__LoadLepusChunk',
95
96
  'SystemInfo',
97
+ '_I18nResourceTranslation',
98
+ '_AddEventListener',
96
99
  ];
97
100
  const backgroundInjectVars = [
98
101
  'NativeModules',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-core-server",
3
- "version": "0.13.5",
3
+ "version": "0.14.1",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -22,10 +22,10 @@
22
22
  "README.md"
23
23
  ],
24
24
  "devDependencies": {
25
- "@lynx-js/offscreen-document": "0.1.1",
26
- "@lynx-js/web-constants": "0.13.5",
27
- "@lynx-js/web-elements-template": "0.7.5",
28
- "@lynx-js/web-mainthread-apis": "0.13.5",
29
- "@lynx-js/web-worker-rpc": "0.13.5"
25
+ "@lynx-js/offscreen-document": "0.1.2",
26
+ "@lynx-js/web-constants": "0.14.1",
27
+ "@lynx-js/web-elements-template": "0.7.7",
28
+ "@lynx-js/web-mainthread-apis": "0.14.1",
29
+ "@lynx-js/web-worker-rpc": "0.14.1"
30
30
  }
31
31
  }