@lynx-js/web-constants 0.7.1 → 0.9.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 +170 -0
- package/dist/constants.d.ts +0 -2
- package/dist/constants.js +0 -2
- package/dist/endpoints.d.ts +8 -5
- package/dist/endpoints.js +4 -4
- package/dist/types/MainThreadStartConfigs.d.ts +5 -2
- package/dist/types/NapiModules.d.ts +2 -0
- package/dist/types/NapiModules.js +5 -0
- package/dist/types/NativeModules.d.ts +1 -10
- package/dist/types/PageConfig.d.ts +0 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,175 @@
|
|
|
1
1
|
# @lynx-js/web-constants
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- refractor: remove entryId concept ([#217](https://github.com/lynx-family/lynx-stack/pull/217))
|
|
8
|
+
|
|
9
|
+
After the PR #198
|
|
10
|
+
All contents are isolated by a shadowroot.
|
|
11
|
+
Therefore we don't need to add the entryId selector to avoid the lynx-view's style taking effect on the whole page.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- feat: `nativeModulesUrl` of lynx-view is changed to `nativeModulesMap`, and the usage is completely aligned with `napiModulesMap`. ([#220](https://github.com/lynx-family/lynx-stack/pull/220))
|
|
16
|
+
|
|
17
|
+
"warning: This is a breaking change."
|
|
18
|
+
|
|
19
|
+
`nativeModulesMap` will be a map: key is module-name, value should be a esm url which export default a
|
|
20
|
+
function with two parameters(you never need to use `this`):
|
|
21
|
+
|
|
22
|
+
- `NativeModules`: oriented `NativeModules`, which you can use to call
|
|
23
|
+
other Native-Modules.
|
|
24
|
+
|
|
25
|
+
- `NativeModulesCall`: trigger `onNativeModulesCall`, same as the deprecated `this.nativeModulesCall`.
|
|
26
|
+
|
|
27
|
+
example:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
const nativeModulesMap = {
|
|
31
|
+
CustomModule: URL.createObjectURL(
|
|
32
|
+
new Blob(
|
|
33
|
+
[
|
|
34
|
+
`export default function(NativeModules, NativeModulesCall) {
|
|
35
|
+
return {
|
|
36
|
+
async getColor(data, callback) {
|
|
37
|
+
const color = await NativeModulesCall('getColor', data);
|
|
38
|
+
callback(color);
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
};`,
|
|
42
|
+
],
|
|
43
|
+
{ type: 'text/javascript' },
|
|
44
|
+
),
|
|
45
|
+
),
|
|
46
|
+
};
|
|
47
|
+
lynxView.nativeModulesMap = nativeModulesMap;
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
In addition, we will use Promise.all to load `nativeModules`, which will optimize performance in the case of multiple modules.
|
|
51
|
+
|
|
52
|
+
- refactor: clean the decodeOperations implementation ([#261](https://github.com/lynx-family/lynx-stack/pull/261))
|
|
53
|
+
|
|
54
|
+
- refactor: remove customelement defined detecting logic ([#247](https://github.com/lynx-family/lynx-stack/pull/247))
|
|
55
|
+
|
|
56
|
+
Before this commit, for those element with tag without `-`, we always try to detect if the `x-${tagName}` is defined.
|
|
57
|
+
|
|
58
|
+
After this commit, we pre-define a map(could be override by the `overrideLynxTagToHTMLTagMap`) to make that transformation for tag name.
|
|
59
|
+
|
|
60
|
+
This change is a path to SSR and the MTS support.
|
|
61
|
+
|
|
62
|
+
- Updated dependencies [[`53230f0`](https://github.com/lynx-family/lynx-stack/commit/53230f012216f3a627853e11d544e4be175c5b9b)]:
|
|
63
|
+
- @lynx-js/web-worker-rpc@0.9.0
|
|
64
|
+
|
|
65
|
+
## 0.8.0
|
|
66
|
+
|
|
67
|
+
### Minor Changes
|
|
68
|
+
|
|
69
|
+
- refactor: remove web-elements/lazy and loadNewTag ([#123](https://github.com/lynx-family/lynx-stack/pull/123))
|
|
70
|
+
|
|
71
|
+
- remove @lynx-js/web-elements/lazy
|
|
72
|
+
- remove loadElement
|
|
73
|
+
- remove loadNewTag callback
|
|
74
|
+
|
|
75
|
+
**This is a breaking change**
|
|
76
|
+
|
|
77
|
+
Now we removed the default lazy loading preinstalled in web-core
|
|
78
|
+
|
|
79
|
+
Please add the following statement in your web project
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
import "@lynx-js/web-elements/all";
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- feat: `createRpcEndpoint` adds a new parameter: `hasReturnTransfer`. ([#194](https://github.com/lynx-family/lynx-stack/pull/194))
|
|
88
|
+
|
|
89
|
+
When `isSync`: false, `hasReturn`: true, you can add `transfer` to the callback postMessage created.
|
|
90
|
+
|
|
91
|
+
At this time, the return value structure of register-handler is changed: `{ data: unknown; transfer: Transferable[]; } | Promise<{ data: unknown; transfer: Transferable[];}>`.
|
|
92
|
+
|
|
93
|
+
- feat: add two prop of lynx-view about `napiLoader`: ([#173](https://github.com/lynx-family/lynx-stack/pull/173))
|
|
94
|
+
|
|
95
|
+
- `napiModulesMap`: [optional] the napiModule which is called in lynx-core. key is module-name, value is esm url.
|
|
96
|
+
|
|
97
|
+
- `onNapiModulesCall`: [optional] the NapiModule value handler.
|
|
98
|
+
|
|
99
|
+
**Warning:** This is the internal implementation of `@lynx-js/lynx-core`. In most cases, this API is not required for projects.
|
|
100
|
+
|
|
101
|
+
1. The `napiModulesMap` value should be a esm url which export default a function with two parameters:
|
|
102
|
+
|
|
103
|
+
- `NapiModules`: oriented `napiModulesMap`, which you can use to call other Napi-Modules
|
|
104
|
+
|
|
105
|
+
- `NapiModulesCall`: trigger `onNapiModulesCall`
|
|
106
|
+
|
|
107
|
+
example:
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
const color_environment = URL.createObjectURL(
|
|
111
|
+
new Blob(
|
|
112
|
+
[
|
|
113
|
+
`export default function(NapiModules, NapiModulesCall) {
|
|
114
|
+
return {
|
|
115
|
+
getColor() {
|
|
116
|
+
NapiModules.color_methods.getColor({ color: 'green' }, color => {
|
|
117
|
+
console.log(color);
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
ColorEngine: class ColorEngine {
|
|
121
|
+
getColor(name) {
|
|
122
|
+
NapiModules.color_methods.getColor({ color: 'green' }, color => {
|
|
123
|
+
console.log(color);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
};`,
|
|
129
|
+
],
|
|
130
|
+
{ type: 'text/javascript' },
|
|
131
|
+
),
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
const color_methods = URL.createObjectURL(
|
|
135
|
+
new Blob(
|
|
136
|
+
[
|
|
137
|
+
`export default function(NapiModules, NapiModulesCall) {
|
|
138
|
+
return {
|
|
139
|
+
async getColor(data, callback) {
|
|
140
|
+
const color = await NapiModulesCall('getColor', data);
|
|
141
|
+
callback(color);
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
};`,
|
|
145
|
+
],
|
|
146
|
+
{ type: 'text/javascript' },
|
|
147
|
+
),
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
lynxView.napiModuleMap = {
|
|
151
|
+
color_environment: color_environment,
|
|
152
|
+
color_methods: color_methods,
|
|
153
|
+
};
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
2. The `onNapiModulesCall` function has three parameters:
|
|
157
|
+
|
|
158
|
+
- `name`: the first parameter of `NapiModulesCall`, the function name
|
|
159
|
+
- `data`: the second parameter of `NapiModulesCall`, data
|
|
160
|
+
- `moduleName`: the module-name of the called napi-module
|
|
161
|
+
|
|
162
|
+
```js
|
|
163
|
+
lynxView.onNapiModulesCall = (name, data, moduleName) => {
|
|
164
|
+
if (name === 'getColor' && moduleName === 'color_methods') {
|
|
165
|
+
return data.color;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
- Updated dependencies [[`ec4e1ce`](https://github.com/lynx-family/lynx-stack/commit/ec4e1ce0d7612d6c0701792a46c78cd52130bad4)]:
|
|
171
|
+
- @lynx-js/web-worker-rpc@0.8.0
|
|
172
|
+
|
|
3
173
|
## 0.7.1
|
|
4
174
|
|
|
5
175
|
### Patch Changes
|
package/dist/constants.d.ts
CHANGED
|
@@ -2,11 +2,9 @@ export declare const lynxUniqueIdAttribute: "lynx-unique-id";
|
|
|
2
2
|
export declare const cssIdAttribute: "lynx-css-id";
|
|
3
3
|
export declare const componentIdAttribute: "lynx-component-id";
|
|
4
4
|
export declare const parentComponentUniqueIdAttribute: "lynx-parent-component-uid";
|
|
5
|
-
export declare const cardIdAttribute: "lynx-card-id";
|
|
6
5
|
export declare const lynxTagAttribute: "lynx-tag";
|
|
7
6
|
export declare const lynxRuntimeValue: unique symbol;
|
|
8
7
|
export declare const lynxDefaultDisplayLinearAttribute: "lynx-default-display-linear";
|
|
9
8
|
export declare const lynxViewRootDomId: "lynx-view-root";
|
|
10
9
|
export declare const __lynx_timing_flag: "__lynx_timing_flag";
|
|
11
|
-
export declare const lynxViewEntryIdPrefix: "lynx-view-id";
|
|
12
10
|
export declare const globalMuteableVars: readonly ["registerDataProcessor"];
|
package/dist/constants.js
CHANGED
|
@@ -5,13 +5,11 @@ export const lynxUniqueIdAttribute = 'lynx-unique-id';
|
|
|
5
5
|
export const cssIdAttribute = 'lynx-css-id';
|
|
6
6
|
export const componentIdAttribute = 'lynx-component-id';
|
|
7
7
|
export const parentComponentUniqueIdAttribute = 'lynx-parent-component-uid';
|
|
8
|
-
export const cardIdAttribute = 'lynx-card-id';
|
|
9
8
|
export const lynxTagAttribute = 'lynx-tag';
|
|
10
9
|
export const lynxRuntimeValue = Symbol('lynx-runtime-value');
|
|
11
10
|
export const lynxDefaultDisplayLinearAttribute = 'lynx-default-display-linear';
|
|
12
11
|
export const lynxViewRootDomId = 'lynx-view-root';
|
|
13
12
|
export const __lynx_timing_flag = '__lynx_timing_flag';
|
|
14
|
-
export const lynxViewEntryIdPrefix = 'lynx-view-id';
|
|
15
13
|
export const globalMuteableVars = [
|
|
16
14
|
'registerDataProcessor',
|
|
17
15
|
];
|
package/dist/endpoints.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import type { ElementOperation, FlushElementTreeOptions } from './types/ElementO
|
|
|
6
6
|
import type { PageConfig } from './types/PageConfig.js';
|
|
7
7
|
import type { IdentifierType, InvokeCallbackRes } from './types/NativeApp.js';
|
|
8
8
|
import type { LynxTemplate } from './types/LynxModule.js';
|
|
9
|
+
import type { NapiModulesMap } from './types/NapiModules.js';
|
|
10
|
+
import type { NativeModulesMap } from './types/NativeModules.js';
|
|
9
11
|
export declare const postExposureEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[{
|
|
10
12
|
exposures: ExposureWorkerEvent[];
|
|
11
13
|
disExposures: ExposureWorkerEvent[];
|
|
@@ -33,14 +35,14 @@ export declare const BackgroundThreadStartEndpoint: import("@lynx-js/web-worker-
|
|
|
33
35
|
template: LynxTemplate;
|
|
34
36
|
cardType: string;
|
|
35
37
|
customSections: Record<string, Cloneable>;
|
|
36
|
-
|
|
38
|
+
nativeModulesMap: NativeModulesMap;
|
|
39
|
+
napiModulesMap: NapiModulesMap;
|
|
37
40
|
}], void>;
|
|
38
|
-
export declare const loadNewTagEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[tag: string], void>;
|
|
39
41
|
/**
|
|
40
|
-
*
|
|
42
|
+
* Error message, info
|
|
41
43
|
*/
|
|
42
|
-
export declare const reportErrorEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").
|
|
43
|
-
export declare const flushElementTreeEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").
|
|
44
|
+
export declare const reportErrorEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[string, unknown]>;
|
|
45
|
+
export declare const flushElementTreeEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[operations: ElementOperation[], FlushElementTreeOptions, styleContent: string | undefined, timingFlags: string[]]>;
|
|
44
46
|
export declare const mainThreadChunkReadyEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[{
|
|
45
47
|
pageConfig: PageConfig;
|
|
46
48
|
}]>;
|
|
@@ -49,6 +51,7 @@ export declare const callLepusMethodEndpoint: import("@lynx-js/web-worker-rpc/di
|
|
|
49
51
|
export declare const invokeUIMethodEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[type: IdentifierType, identifier: string, component_id: string, method: string, params: object, root_unique_id: number | undefined], InvokeCallbackRes>;
|
|
50
52
|
export declare const setNativePropsEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[type: IdentifierType, identifier: string, component_id: string, first_only: boolean, native_props: object, root_unique_id: number | undefined], void>;
|
|
51
53
|
export declare const nativeModulesCallEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[name: string, data: Cloneable, moduleName: string], any>;
|
|
54
|
+
export declare const napiModulesCallEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncWithTransfer<[name: string, data: Cloneable, moduleName: string], any>;
|
|
52
55
|
export declare const getCustomSectionsEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[string], Cloneable>;
|
|
53
56
|
export declare const postTimingInfoFromBackgroundThread: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[timingKey: string, pipelineId: string | undefined, timeStamp: number]>;
|
|
54
57
|
export declare const triggerComponentEventEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[id: string, params: {
|
package/dist/endpoints.js
CHANGED
|
@@ -15,18 +15,18 @@ export const postTimingResult = createRpcEndpoint('postTimingResult', false, fal
|
|
|
15
15
|
export const uiThreadFpReadyEndpoint = createRpcEndpoint('uiThreadFpReady', false, false);
|
|
16
16
|
export const onLifecycleEventEndpoint = createRpcEndpoint('__OnLifecycleEvent', false, false);
|
|
17
17
|
export const BackgroundThreadStartEndpoint = createRpcEndpoint('start', false, true);
|
|
18
|
-
export const loadNewTagEndpoint = createRpcEndpoint('loadNewTag', false, true);
|
|
19
18
|
/**
|
|
20
|
-
*
|
|
19
|
+
* Error message, info
|
|
21
20
|
*/
|
|
22
|
-
export const reportErrorEndpoint = createRpcEndpoint('reportError', false,
|
|
23
|
-
export const flushElementTreeEndpoint = createRpcEndpoint('flushElementTree', false,
|
|
21
|
+
export const reportErrorEndpoint = createRpcEndpoint('reportError', false, false);
|
|
22
|
+
export const flushElementTreeEndpoint = createRpcEndpoint('flushElementTree', false, false);
|
|
24
23
|
export const mainThreadChunkReadyEndpoint = createRpcEndpoint('mainThreadChunkReady', false, false);
|
|
25
24
|
export const postTimingInfoFromMainThread = createRpcEndpoint('postTimingInfoFromMainThread', false, false);
|
|
26
25
|
export const callLepusMethodEndpoint = createRpcEndpoint('callLepusMethod', false, true);
|
|
27
26
|
export const invokeUIMethodEndpoint = createRpcEndpoint('__invokeUIMethod', false, true);
|
|
28
27
|
export const setNativePropsEndpoint = createRpcEndpoint('__setNativeProps', false, true);
|
|
29
28
|
export const nativeModulesCallEndpoint = createRpcEndpoint('nativeModulesCall', false, true);
|
|
29
|
+
export const napiModulesCallEndpoint = createRpcEndpoint('napiModulesCall', false, true, true);
|
|
30
30
|
export const getCustomSectionsEndpoint = createRpcEndpoint('getCustomSections', false, true);
|
|
31
31
|
export const postTimingInfoFromBackgroundThread = createRpcEndpoint('postTimingInfoFromBackgroundThread', false, false);
|
|
32
32
|
export const triggerComponentEventEndpoint = createRpcEndpoint('__triggerComponentEvent', false, false);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { Cloneable } from './Cloneable.js';
|
|
2
2
|
import type { LynxTemplate } from './LynxModule.js';
|
|
3
|
+
import type { NapiModulesMap } from './NapiModules.js';
|
|
4
|
+
import type { NativeModulesMap } from './NativeModules.js';
|
|
3
5
|
import type { BrowserConfig } from './PageConfig.js';
|
|
4
6
|
export interface MainThreadStartConfigs {
|
|
5
7
|
template: LynxTemplate;
|
|
6
8
|
initData: Cloneable;
|
|
7
9
|
globalProps: Cloneable;
|
|
8
|
-
entryId: string;
|
|
9
10
|
browserConfig: BrowserConfig;
|
|
10
|
-
|
|
11
|
+
nativeModulesMap: NativeModulesMap;
|
|
12
|
+
napiModulesMap: NapiModulesMap;
|
|
13
|
+
tagMap: Record<string, string>;
|
|
11
14
|
}
|
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export type NativeModulesMap = Record<string, string>;
|
|
2
2
|
export type NativeModulesCall = (name: string, data: any, moduleName: string) => Promise<any> | any;
|
|
3
|
-
export type OneNativeModule = {
|
|
4
|
-
[k: string]: (this: NativeModuleHandlerContext, ...args: Cloneable[]) => Promise<Cloneable>;
|
|
5
|
-
};
|
|
6
|
-
export type NativeModuleHandlerContext = {
|
|
7
|
-
nativeModulesCall: (name: string, data: Cloneable) => Promise<Cloneable>;
|
|
8
|
-
};
|
|
9
|
-
export type customNativeModules = {
|
|
10
|
-
[k: string]: OneNativeModule;
|
|
11
|
-
};
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/web-constants",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
"**/*.css"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@lynx-js/web-worker-rpc": "0.
|
|
26
|
+
"@lynx-js/web-worker-rpc": "0.9.0"
|
|
27
27
|
}
|
|
28
28
|
}
|