@lynx-js/web-constants 0.7.1 → 0.8.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 +108 -0
- package/dist/endpoints.d.ts +3 -1
- package/dist/endpoints.js +1 -1
- package/dist/types/MainThreadStartConfigs.d.ts +2 -0
- package/dist/types/NapiModules.d.ts +2 -0
- package/dist/types/NapiModules.js +5 -0
- 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,113 @@
|
|
|
1
1
|
# @lynx-js/web-constants
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- refactor: remove web-elements/lazy and loadNewTag ([#123](https://github.com/lynx-family/lynx-stack/pull/123))
|
|
8
|
+
|
|
9
|
+
- remove @lynx-js/web-elements/lazy
|
|
10
|
+
- remove loadElement
|
|
11
|
+
- remove loadNewTag callback
|
|
12
|
+
|
|
13
|
+
**This is a breaking change**
|
|
14
|
+
|
|
15
|
+
Now we removed the default lazy loading preinstalled in web-core
|
|
16
|
+
|
|
17
|
+
Please add the following statement in your web project
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
import "@lynx-js/web-elements/all";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- feat: `createRpcEndpoint` adds a new parameter: `hasReturnTransfer`. ([#194](https://github.com/lynx-family/lynx-stack/pull/194))
|
|
26
|
+
|
|
27
|
+
When `isSync`: false, `hasReturn`: true, you can add `transfer` to the callback postMessage created.
|
|
28
|
+
|
|
29
|
+
At this time, the return value structure of register-handler is changed: `{ data: unknown; transfer: Transferable[]; } | Promise<{ data: unknown; transfer: Transferable[];}>`.
|
|
30
|
+
|
|
31
|
+
- feat: add two prop of lynx-view about `napiLoader`: ([#173](https://github.com/lynx-family/lynx-stack/pull/173))
|
|
32
|
+
|
|
33
|
+
- `napiModulesMap`: [optional] the napiModule which is called in lynx-core. key is module-name, value is esm url.
|
|
34
|
+
|
|
35
|
+
- `onNapiModulesCall`: [optional] the NapiModule value handler.
|
|
36
|
+
|
|
37
|
+
**Warning:** This is the internal implementation of `@lynx-js/lynx-core`. In most cases, this API is not required for projects.
|
|
38
|
+
|
|
39
|
+
1. The `napiModulesMap` value should be a esm url which export default a function with two parameters:
|
|
40
|
+
|
|
41
|
+
- `NapiModules`: oriented `napiModulesMap`, which you can use to call other Napi-Modules
|
|
42
|
+
|
|
43
|
+
- `NapiModulesCall`: trigger `onNapiModulesCall`
|
|
44
|
+
|
|
45
|
+
example:
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
const color_environment = URL.createObjectURL(
|
|
49
|
+
new Blob(
|
|
50
|
+
[
|
|
51
|
+
`export default function(NapiModules, NapiModulesCall) {
|
|
52
|
+
return {
|
|
53
|
+
getColor() {
|
|
54
|
+
NapiModules.color_methods.getColor({ color: 'green' }, color => {
|
|
55
|
+
console.log(color);
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
ColorEngine: class ColorEngine {
|
|
59
|
+
getColor(name) {
|
|
60
|
+
NapiModules.color_methods.getColor({ color: 'green' }, color => {
|
|
61
|
+
console.log(color);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
};`,
|
|
67
|
+
],
|
|
68
|
+
{ type: 'text/javascript' },
|
|
69
|
+
),
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const color_methods = URL.createObjectURL(
|
|
73
|
+
new Blob(
|
|
74
|
+
[
|
|
75
|
+
`export default function(NapiModules, NapiModulesCall) {
|
|
76
|
+
return {
|
|
77
|
+
async getColor(data, callback) {
|
|
78
|
+
const color = await NapiModulesCall('getColor', data);
|
|
79
|
+
callback(color);
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
};`,
|
|
83
|
+
],
|
|
84
|
+
{ type: 'text/javascript' },
|
|
85
|
+
),
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
lynxView.napiModuleMap = {
|
|
89
|
+
color_environment: color_environment,
|
|
90
|
+
color_methods: color_methods,
|
|
91
|
+
};
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
2. The `onNapiModulesCall` function has three parameters:
|
|
95
|
+
|
|
96
|
+
- `name`: the first parameter of `NapiModulesCall`, the function name
|
|
97
|
+
- `data`: the second parameter of `NapiModulesCall`, data
|
|
98
|
+
- `moduleName`: the module-name of the called napi-module
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
lynxView.onNapiModulesCall = (name, data, moduleName) => {
|
|
102
|
+
if (name === 'getColor' && moduleName === 'color_methods') {
|
|
103
|
+
return data.color;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- Updated dependencies [[`ec4e1ce`](https://github.com/lynx-family/lynx-stack/commit/ec4e1ce0d7612d6c0701792a46c78cd52130bad4)]:
|
|
109
|
+
- @lynx-js/web-worker-rpc@0.8.0
|
|
110
|
+
|
|
3
111
|
## 0.7.1
|
|
4
112
|
|
|
5
113
|
### Patch Changes
|
package/dist/endpoints.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ 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';
|
|
9
10
|
export declare const postExposureEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[{
|
|
10
11
|
exposures: ExposureWorkerEvent[];
|
|
11
12
|
disExposures: ExposureWorkerEvent[];
|
|
@@ -34,8 +35,8 @@ export declare const BackgroundThreadStartEndpoint: import("@lynx-js/web-worker-
|
|
|
34
35
|
cardType: string;
|
|
35
36
|
customSections: Record<string, Cloneable>;
|
|
36
37
|
nativeModulesUrl?: string;
|
|
38
|
+
napiModulesMap: NapiModulesMap;
|
|
37
39
|
}], void>;
|
|
38
|
-
export declare const loadNewTagEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[tag: string], void>;
|
|
39
40
|
/**
|
|
40
41
|
* threadLabel, Error message, info
|
|
41
42
|
*/
|
|
@@ -49,6 +50,7 @@ export declare const callLepusMethodEndpoint: import("@lynx-js/web-worker-rpc/di
|
|
|
49
50
|
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
51
|
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
52
|
export declare const nativeModulesCallEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[name: string, data: Cloneable, moduleName: string], any>;
|
|
53
|
+
export declare const napiModulesCallEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncWithTransfer<[name: string, data: Cloneable, moduleName: string], any>;
|
|
52
54
|
export declare const getCustomSectionsEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[string], Cloneable>;
|
|
53
55
|
export declare const postTimingInfoFromBackgroundThread: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[timingKey: string, pipelineId: string | undefined, timeStamp: number]>;
|
|
54
56
|
export declare const triggerComponentEventEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[id: string, params: {
|
package/dist/endpoints.js
CHANGED
|
@@ -15,7 +15,6 @@ 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
|
* threadLabel, Error message, info
|
|
21
20
|
*/
|
|
@@ -27,6 +26,7 @@ export const callLepusMethodEndpoint = createRpcEndpoint('callLepusMethod', fals
|
|
|
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,5 +1,6 @@
|
|
|
1
1
|
import type { Cloneable } from './Cloneable.js';
|
|
2
2
|
import type { LynxTemplate } from './LynxModule.js';
|
|
3
|
+
import type { NapiModulesMap } from './NapiModules.js';
|
|
3
4
|
import type { BrowserConfig } from './PageConfig.js';
|
|
4
5
|
export interface MainThreadStartConfigs {
|
|
5
6
|
template: LynxTemplate;
|
|
@@ -8,4 +9,5 @@ export interface MainThreadStartConfigs {
|
|
|
8
9
|
entryId: string;
|
|
9
10
|
browserConfig: BrowserConfig;
|
|
10
11
|
nativeModulesUrl?: string;
|
|
12
|
+
napiModulesMap: NapiModulesMap;
|
|
11
13
|
}
|
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.8.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.8.0"
|
|
27
27
|
}
|
|
28
28
|
}
|