@lynx-js/web-core-server 0.13.5 → 0.14.0
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 +43 -0
- package/dist/createLynxView.d.ts +1 -1
- package/dist/createLynxView.js +9 -2
- package/dist/utils/loadTemplate.js +3 -0
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
# @lynx-js/web-core-server
|
|
2
2
|
|
|
3
|
+
## 0.14.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- feat: add `_SetSourceMapRelease(errInfo)` MTS API. ([#1118](https://github.com/lynx-family/lynx-stack/pull/1118))
|
|
8
|
+
|
|
9
|
+
You can get `errInfo.release` through `e.detail.release` in the error event callback of lynx-view.
|
|
10
|
+
|
|
11
|
+
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.
|
|
12
|
+
|
|
13
|
+
- 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))
|
|
14
|
+
|
|
15
|
+
`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.
|
|
16
|
+
|
|
17
|
+
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.
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
// ui thread
|
|
21
|
+
lynxView.initI18nResources = [
|
|
22
|
+
{
|
|
23
|
+
options: {
|
|
24
|
+
locale: 'en',
|
|
25
|
+
channel: '1',
|
|
26
|
+
fallback_url: '',
|
|
27
|
+
},
|
|
28
|
+
resource: {
|
|
29
|
+
hello: 'hello',
|
|
30
|
+
lynx: 'lynx web platform1',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
lynxView.addEventListener('i18nResourceMissed', (e) => {
|
|
35
|
+
console.log(e);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// mts
|
|
39
|
+
_I18nResourceTranslation({
|
|
40
|
+
locale: 'en',
|
|
41
|
+
channel: '1',
|
|
42
|
+
fallback_url: '',
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
3
46
|
## 0.13.5
|
|
4
47
|
|
|
5
48
|
### Patch Changes
|
package/dist/createLynxView.d.ts
CHANGED
|
@@ -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;
|
package/dist/createLynxView.js
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "0.14.0",
|
|
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.
|
|
26
|
-
"@lynx-js/web-constants": "0.
|
|
27
|
-
"@lynx-js/web-elements-template": "0.7.
|
|
28
|
-
"@lynx-js/web-mainthread-apis": "0.
|
|
29
|
-
"@lynx-js/web-worker-rpc": "0.
|
|
25
|
+
"@lynx-js/offscreen-document": "0.1.2",
|
|
26
|
+
"@lynx-js/web-constants": "0.14.0",
|
|
27
|
+
"@lynx-js/web-elements-template": "0.7.6",
|
|
28
|
+
"@lynx-js/web-mainthread-apis": "0.14.0",
|
|
29
|
+
"@lynx-js/web-worker-rpc": "0.14.0"
|
|
30
30
|
}
|
|
31
31
|
}
|