@lynx-js/web-constants 0.7.0 → 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 CHANGED
@@ -1,5 +1,135 @@
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
+
111
+ ## 0.7.1
112
+
113
+ ### Patch Changes
114
+
115
+ - Support NPM provenance. ([#30](https://github.com/lynx-family/lynx-stack/pull/30))
116
+
117
+ - fix: some valus should be updateable by global scope ([#130](https://github.com/lynx-family/lynx-stack/pull/130))
118
+
119
+ Now we add an allowlist to allow some identifiers could be updated by globalThis.
120
+
121
+ For those values in the allowlist:
122
+
123
+ ```
124
+ globalThis.foo = 'xx';
125
+ console.log(foo); //'xx'
126
+ ```
127
+
128
+ - refractor: improve some internal logic for element creating in MTS ([#71](https://github.com/lynx-family/lynx-stack/pull/71))
129
+
130
+ - Updated dependencies [[`c617453`](https://github.com/lynx-family/lynx-stack/commit/c617453aea967aba702967deb2916b5c883f03bb)]:
131
+ - @lynx-js/web-worker-rpc@0.7.1
132
+
3
133
  ## 0.7.0
4
134
 
5
135
  ### Minor Changes
@@ -8,4 +8,5 @@ export declare const lynxRuntimeValue: unique symbol;
8
8
  export declare const lynxDefaultDisplayLinearAttribute: "lynx-default-display-linear";
9
9
  export declare const lynxViewRootDomId: "lynx-view-root";
10
10
  export declare const __lynx_timing_flag: "__lynx_timing_flag";
11
- export declare const lynxViewEntryIdPrefix = "lynx-view-id";
11
+ export declare const lynxViewEntryIdPrefix: "lynx-view-id";
12
+ export declare const globalMuteableVars: readonly ["registerDataProcessor"];
package/dist/constants.js CHANGED
@@ -12,4 +12,7 @@ export const lynxDefaultDisplayLinearAttribute = 'lynx-default-display-linear';
12
12
  export const lynxViewRootDomId = 'lynx-view-root';
13
13
  export const __lynx_timing_flag = '__lynx_timing_flag';
14
14
  export const lynxViewEntryIdPrefix = 'lynx-view-id';
15
+ export const globalMuteableVars = [
16
+ 'registerDataProcessor',
17
+ ];
15
18
  //# sourceMappingURL=constants.js.map
@@ -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);
@@ -29,10 +29,6 @@ export interface CreateOperation extends ElementOperationBase {
29
29
  type: OperationType.Create;
30
30
  tag: string;
31
31
  cssId?: number;
32
- /**
33
- * parent component unique id
34
- */
35
- puid: string;
36
32
  }
37
33
  export interface SetAttributeOperation extends ElementOperationBase {
38
34
  type: OperationType.SetAttribute;
@@ -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
  }
@@ -0,0 +1,2 @@
1
+ export type NapiModulesMap = Record<string, string>;
2
+ export type NapiModulesCall = (name: string, data: any, moduleName: string) => Promise<any> | any;
@@ -0,0 +1,5 @@
1
+ // Copyright 2023 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ export {};
5
+ //# sourceMappingURL=NapiModules.js.map
@@ -4,5 +4,4 @@ export interface PageConfig {
4
4
  defaultDisplayLinear: boolean;
5
5
  }
6
6
  export interface BrowserConfig {
7
- supportAtScope: boolean;
8
7
  }
@@ -11,3 +11,4 @@ export * from './MainThreadStartConfigs.js';
11
11
  export * from './NativeApp.js';
12
12
  export * from './UpdateDataOptions.js';
13
13
  export * from './NativeModules.js';
14
+ export * from './NapiModules.js';
@@ -11,4 +11,5 @@ export * from './MainThreadStartConfigs.js';
11
11
  export * from './NativeApp.js';
12
12
  export * from './UpdateDataOptions.js';
13
13
  export * from './NativeModules.js';
14
+ export * from './NapiModules.js';
14
15
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "@lynx-js/web-constants",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/lynx-family/lynx-stack.git",
10
+ "directory": "packages/web-platform/web-constants"
11
+ },
7
12
  "license": "Apache-2.0",
8
13
  "type": "module",
9
14
  "main": "dist/index.js",
@@ -18,6 +23,6 @@
18
23
  "**/*.css"
19
24
  ],
20
25
  "dependencies": {
21
- "@lynx-js/web-worker-rpc": "0.7.0"
26
+ "@lynx-js/web-worker-rpc": "0.8.0"
22
27
  }
23
28
  }