@lynx-js/web-constants 0.13.4 → 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 CHANGED
@@ -1,5 +1,95 @@
1
1
  # @lynx-js/web-constants
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
+
46
+ - feat: supports `lynx.getI18nResource()` and `onI18nResourceReady` event in bts. ([#1088](https://github.com/lynx-family/lynx-stack/pull/1088))
47
+
48
+ - `lynx.getI18nResource()` can be used to get i18nResource in bts, it has two data sources:
49
+ - the result of `_I18nResourceTranslation()`
50
+ - lynx-view `updateI18nResources(data: InitI18nResources, options: I18nResourceTranslationOptions)`, it will be matched to the correct i8nResource as a result of `lynx.getI18nResource()`
51
+ - `onI18nResourceReady` event can be used to listen `_I18nResourceTranslation` and lynx-view `updateI18nResources` execution.
52
+
53
+ - refactor: make the opcode be a plain array ([#1051](https://github.com/lynx-family/lynx-stack/pull/1051))
54
+
55
+ #1042
56
+
57
+ - feat: add `updateI18nResources` method of lynx-view. ([#1085](https://github.com/lynx-family/lynx-stack/pull/1085))
58
+
59
+ Now you can use `updateI18nResources` to update i18nResources, and then use \_I18nResourceTranslation() to get the updated result.
60
+
61
+ - Updated dependencies []:
62
+ - @lynx-js/web-worker-rpc@0.14.0
63
+
64
+ ## 0.13.5
65
+
66
+ ### Patch Changes
67
+
68
+ - refactor: move some internal status to dom's attribute ([#945](https://github.com/lynx-family/lynx-stack/pull/945))
69
+
70
+ It's essential for SSR
71
+
72
+ - fix: target.id is undefined ([#1016](https://github.com/lynx-family/lynx-stack/pull/1016))
73
+
74
+ - feat: add new pageConfig configuration: enableJSDataProcessor ([#886](https://github.com/lynx-family/lynx-stack/pull/886))
75
+
76
+ - refactor: move component config info to attribute ([#984](https://github.com/lynx-family/lynx-stack/pull/984))
77
+
78
+ - refactor: save dataset on an attribute ([#981](https://github.com/lynx-family/lynx-stack/pull/981))
79
+
80
+ On lynx, the `data-*` attributes have different behaviors than the HTMLElement has.
81
+
82
+ The dataset will be treated as properties, the key will not be applied the camel-case <-> hyphenate name transformation.
83
+
84
+ Before this commit we use it as a runtime data, but after this commit we will use encodeURI(JSON.stringify(dataset)) to encode it as a string.
85
+
86
+ - refactor: create elements of `elementToRuntimeInfoMap` on demand ([#986](https://github.com/lynx-family/lynx-stack/pull/986))
87
+
88
+ - refactor: implement mts apis in closure pattern ([#1004](https://github.com/lynx-family/lynx-stack/pull/1004))
89
+
90
+ - Updated dependencies []:
91
+ - @lynx-js/web-worker-rpc@0.13.5
92
+
3
93
  ## 0.13.4
4
94
 
5
95
  ### Patch Changes
@@ -1,7 +1,10 @@
1
- export declare const lynxUniqueIdAttribute: "lynx-unique-id";
2
- export declare const cssIdAttribute: "lynx-css-id";
3
- export declare const componentIdAttribute: "lynx-component-id";
1
+ export declare const lynxUniqueIdAttribute: "l-uid";
2
+ export declare const cssIdAttribute: "l-css-id";
3
+ export declare const componentIdAttribute: "l-comp-id";
4
+ export declare const parentComponentUniqueIdAttribute: "l-p-comp-uid";
4
5
  export declare const lynxTagAttribute: "lynx-tag";
6
+ export declare const lynxDatasetAttribute: "l-dset";
7
+ export declare const lynxComponentConfigAttribute: "l-comp-cfg";
5
8
  export declare const lynxDefaultDisplayLinearAttribute: "lynx-default-display-linear";
6
9
  export declare const lynxDefaultOverflowVisibleAttribute: "lynx-default-overflow-visible";
7
10
  export declare const __lynx_timing_flag: "__lynx_timing_flag";
package/dist/constants.js CHANGED
@@ -1,10 +1,13 @@
1
1
  // Copyright 2023 The Lynx Authors. All rights reserved.
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
- export const lynxUniqueIdAttribute = 'lynx-unique-id';
5
- export const cssIdAttribute = 'lynx-css-id';
6
- export const componentIdAttribute = 'lynx-component-id';
4
+ export const lynxUniqueIdAttribute = 'l-uid';
5
+ export const cssIdAttribute = 'l-css-id';
6
+ export const componentIdAttribute = 'l-comp-id';
7
+ export const parentComponentUniqueIdAttribute = 'l-p-comp-uid';
7
8
  export const lynxTagAttribute = 'lynx-tag';
9
+ export const lynxDatasetAttribute = 'l-dset';
10
+ export const lynxComponentConfigAttribute = 'l-comp-cfg';
8
11
  export const lynxDefaultDisplayLinearAttribute = 'lynx-default-display-linear';
9
12
  export const lynxDefaultOverflowVisibleAttribute = 'lynx-default-overflow-visible';
10
13
  export const __lynx_timing_flag = '__lynx_timing_flag';
@@ -2,12 +2,8 @@ import type { ExposureWorkerEvent, LynxCrossThreadEvent } from './types/EventTyp
2
2
  import type { Cloneable, CloneableObject } from './types/Cloneable.js';
3
3
  import type { StartMainThreadContextConfig } from './types/MainThreadStartConfigs.js';
4
4
  import type { IdentifierType, InvokeCallbackRes } from './types/NativeApp.js';
5
- import type { LynxTemplate } from './types/LynxModule.js';
6
- import type { NapiModulesMap } from './types/NapiModules.js';
7
- import type { NativeModulesMap } from './types/NativeModules.js';
8
- import type { ElementOperation } from '@lynx-js/offscreen-document';
9
- import type { BrowserConfig } from './types/PageConfig.js';
10
5
  import type { ElementAnimationOptions } from './types/Element.js';
6
+ import type { BackMainThreadContextConfig } from './types/index.js';
11
7
  export declare const postExposureEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[{
12
8
  exposures: ExposureWorkerEvent[];
13
9
  disExposures: ExposureWorkerEvent[];
@@ -24,21 +20,12 @@ export declare const mainThreadStartEndpoint: import("@lynx-js/web-worker-rpc/di
24
20
  export declare const updateDataEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[Cloneable, Record<string, string>], void>;
25
21
  export declare const sendGlobalEventEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[string, Cloneable[] | undefined]>;
26
22
  export declare const disposeEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[], void>;
27
- export declare const BackgroundThreadStartEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[{
28
- initData: unknown;
29
- globalProps: unknown;
30
- template: LynxTemplate;
31
- cardType: string;
32
- customSections: Record<string, Cloneable>;
33
- nativeModulesMap: NativeModulesMap;
34
- napiModulesMap: NapiModulesMap;
35
- browserConfig: BrowserConfig;
36
- }], void>;
23
+ export declare const BackgroundThreadStartEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[BackMainThreadContextConfig], void>;
37
24
  /**
38
25
  * Error message, info
39
26
  */
40
- export declare const reportErrorEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[string, unknown]>;
41
- export declare const flushElementTreeEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[operations: ElementOperation[]], void>;
27
+ export declare const reportErrorEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[Error, unknown, string]>;
28
+ export declare const flushElementTreeEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[operations: (string | number)[]], void>;
42
29
  export declare const callLepusMethodEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsync<[name: string, data: unknown], void>;
43
30
  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>;
44
31
  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>;
@@ -65,3 +52,6 @@ export declare const dispatchJSContextOnMainThreadEndpoint: import("@lynx-js/web
65
52
  }]>;
66
53
  export declare const triggerElementMethodEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[method: string, id: string, options: ElementAnimationOptions]>;
67
54
  export declare const updateGlobalPropsEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[Cloneable]>;
55
+ export declare const updateI18nResourcesEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[Cloneable]>;
56
+ export declare const updateI18nResourceEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[Cloneable]>;
57
+ export declare const dispatchI18nResourceEndpoint: import("@lynx-js/web-worker-rpc/dist/RpcEndpoint.js").RpcEndpointAsyncVoid<[Cloneable]>;
package/dist/endpoints.js CHANGED
@@ -33,4 +33,7 @@ export const dispatchCoreContextOnBackgroundEndpoint = createRpcEndpoint('dispat
33
33
  export const dispatchJSContextOnMainThreadEndpoint = createRpcEndpoint('dispatchJSContextOnMainThread', false, false);
34
34
  export const triggerElementMethodEndpoint = createRpcEndpoint('__triggerElementMethod', false, false);
35
35
  export const updateGlobalPropsEndpoint = createRpcEndpoint('updateGlobalProps', false, false);
36
+ export const updateI18nResourcesEndpoint = createRpcEndpoint('updateI18nResources', false, false);
37
+ export const updateI18nResourceEndpoint = createRpcEndpoint('updateI18nResource', false, false);
38
+ export const dispatchI18nResourceEndpoint = createRpcEndpoint('dispatchI18nResource', false, false);
36
39
  //# sourceMappingURL=endpoints.js.map
@@ -0,0 +1,15 @@
1
+ import type { Cloneable } from './Cloneable.js';
2
+ import type { LynxTemplate } from './LynxModule.js';
3
+ import type { NapiModulesMap } from './NapiModules.js';
4
+ import type { NativeModulesMap } from './NativeModules.js';
5
+ import type { BrowserConfig } from './PageConfig.js';
6
+ export interface BackMainThreadContextConfig {
7
+ initData: unknown;
8
+ globalProps: unknown;
9
+ template: LynxTemplate;
10
+ cardType: string;
11
+ customSections: Record<string, Cloneable>;
12
+ nativeModulesMap: NativeModulesMap;
13
+ napiModulesMap: NapiModulesMap;
14
+ browserConfig: BrowserConfig;
15
+ }
@@ -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=BackThreadStartConfigs.js.map
@@ -1,2 +1,2 @@
1
- export type Cloneable<T = string | number | null | boolean | undefined> = T | Record<string, T> | T[];
1
+ export type Cloneable<T = string | number | null | boolean | undefined> = T | Record<string, T> | T[] | Array<Record<string, Cloneable>>;
2
2
  export type CloneableObject<T = string | number | null | boolean | undefined> = Record<string, T | T[]>;
@@ -1,3 +1,26 @@
1
+ import type { LynxEventType } from './EventType.js';
2
+ export interface LynxRuntimeInfo {
3
+ eventHandlerMap: Record<string, {
4
+ capture: {
5
+ type: LynxEventType;
6
+ handler: string | {
7
+ type: 'worklet';
8
+ value: unknown;
9
+ };
10
+ } | undefined;
11
+ bind: {
12
+ type: LynxEventType;
13
+ handler: string | {
14
+ type: 'worklet';
15
+ value: unknown;
16
+ };
17
+ } | undefined;
18
+ }>;
19
+ componentAtIndex?: ComponentAtIndexCallback;
20
+ enqueueComponent?: EnqueueComponentCallback;
21
+ }
22
+ export type ComponentAtIndexCallback = (list: WebFiberElementImpl, listID: number, cellIndex: number, operationID: number, enableReuseNotification: boolean) => void;
23
+ export type EnqueueComponentCallback = (list: WebFiberElementImpl, listID: number, sign: number) => void;
1
24
  export declare const enum AnimationOperation {
2
25
  START = 0,
3
26
  PLAY = 1,
@@ -11,3 +34,33 @@ export interface ElementAnimationOptions {
11
34
  keyframes?: any;
12
35
  timingOptions?: Record<string, any>;
13
36
  }
37
+ export interface WebFiberElementImpl {
38
+ getAttributeNames: () => string[];
39
+ getAttribute: (name: string) => string | null;
40
+ setAttribute: (name: string, value: string) => void;
41
+ removeAttribute: (name: string) => void;
42
+ append: (...children: WebFiberElementImpl[]) => void;
43
+ appendChild: (child: WebFiberElementImpl) => void;
44
+ removeChild: (child: WebFiberElementImpl) => WebFiberElementImpl;
45
+ insertBefore: (child: WebFiberElementImpl, ref?: WebFiberElementImpl | null) => WebFiberElementImpl;
46
+ replaceWith: (...newElement: WebFiberElementImpl[]) => void;
47
+ addEventListener: (type: string, handler: (ev: Event) => void, options: {
48
+ capture?: boolean;
49
+ passive?: boolean;
50
+ }) => void;
51
+ removeEventListener: (type: string, handler: (ev: Event) => void, options?: {
52
+ capture?: boolean;
53
+ }) => void;
54
+ innerHTML: string;
55
+ readonly tagName: string;
56
+ readonly firstElementChild: WebFiberElementImpl | null;
57
+ readonly children: WebFiberElementImpl[];
58
+ readonly parentElement: WebFiberElementImpl | null;
59
+ readonly parentNode: WebFiberElementImpl | null;
60
+ readonly lastElementChild: WebFiberElementImpl | null;
61
+ readonly nextElementSibling: WebFiberElementImpl | null;
62
+ readonly style: {
63
+ removeProperty(name: string): void;
64
+ setProperty(name: string, value: string, priority?: 'important' | '' | null): void;
65
+ };
66
+ }
@@ -1,10 +1,11 @@
1
1
  import type { Cloneable } from './Cloneable.js';
2
+ import type { WebFiberElementImpl } from './Element.js';
2
3
  export type LynxEventType = 'bindEvent' | 'catchEvent' | 'capture-bind' | 'capture-catch';
3
4
  export interface LynxCrossThreadEventTarget {
4
5
  dataset: {
5
6
  [key: string]: Cloneable;
6
7
  };
7
- id?: string;
8
+ id: string | null;
8
9
  uniqueId: number;
9
10
  }
10
11
  export interface LynxCrossThreadEvent<T = {
@@ -38,3 +39,16 @@ export type ExposureEvent = {
38
39
  detail: ExposureEventDetail;
39
40
  };
40
41
  export type ExposureWorkerEvent = LynxCrossThreadEvent<ExposureEventDetail> & ExposureEventDetail;
42
+ export type MinimalRawEventObject = {
43
+ type: string;
44
+ target: Pick<WebFiberElementImpl, 'getAttribute'> | null;
45
+ currentTarget: Pick<WebFiberElementImpl, 'getAttribute'> | null;
46
+ detail?: Cloneable;
47
+ isTrusted: boolean;
48
+ timeStamp: number;
49
+ propertyName?: string;
50
+ animationName?: string;
51
+ touches?: unknown[];
52
+ targetTouches?: unknown[];
53
+ changedTouches?: unknown[];
54
+ };
@@ -0,0 +1,29 @@
1
+ import type { Cloneable } from './Cloneable.js';
2
+ export interface I18nResourceTranslationOptions {
3
+ locale: string;
4
+ channel: string;
5
+ fallback_url?: string;
6
+ [key: string]: Cloneable;
7
+ }
8
+ export declare const getCacheI18nResourcesKey: (options: I18nResourceTranslationOptions) => string;
9
+ export interface CacheI18nResources {
10
+ /** the i18nResource key currently being used by the page */
11
+ curCacheKey: string;
12
+ /** the complete set of all requested i18nResources */
13
+ i18nResources: Map<string, unknown>;
14
+ }
15
+ export type InitI18nResources = Array<{
16
+ options: I18nResourceTranslationOptions;
17
+ resource: Record<string, unknown>;
18
+ }>;
19
+ export declare const i18nResourceMissedEventName: "i18nResourceMissed";
20
+ export declare class I18nResources {
21
+ data?: InitI18nResources;
22
+ constructor(data?: InitI18nResources);
23
+ setData(data: InitI18nResources): void;
24
+ }
25
+ export declare class I18nResource {
26
+ data?: Cloneable;
27
+ constructor(data?: Cloneable);
28
+ setData(data: Cloneable): void;
29
+ }
@@ -0,0 +1,25 @@
1
+ export const getCacheI18nResourcesKey = (options) => {
2
+ return `${options.locale}_${options.channel}_${options.fallback_url}`;
3
+ };
4
+ export const i18nResourceMissedEventName = 'i18nResourceMissed';
5
+ // The purpose of using class is to keep the reference when reassigning
6
+ export class I18nResources {
7
+ data;
8
+ constructor(data) {
9
+ this.data = data;
10
+ }
11
+ setData(data) {
12
+ this.data = data;
13
+ }
14
+ }
15
+ // The purpose of using class is to keep the reference when reassigning
16
+ export class I18nResource {
17
+ data;
18
+ constructor(data) {
19
+ this.data = data;
20
+ }
21
+ setData(data) {
22
+ this.data = data;
23
+ }
24
+ }
25
+ //# sourceMappingURL=I18n.js.map
@@ -0,0 +1,157 @@
1
+ import type { systemInfo } from '../constants.js';
2
+ import type { Cloneable } from './Cloneable.js';
3
+ import type { ComponentAtIndexCallback, EnqueueComponentCallback, WebFiberElementImpl } from './Element.js';
4
+ import type { LynxEventType } from './EventType.js';
5
+ import type { FlushElementTreeOptions } from './FlushElementTreeOptions.js';
6
+ import type { I18nResourceTranslationOptions } from './index.js';
7
+ import type { MainThreadLynx } from './MainThreadLynx.js';
8
+ import type { ProcessDataCallback } from './ProcessDataCallback.js';
9
+ type ElementPAPIEventHandler = string | {
10
+ type: 'worklet';
11
+ value: unknown;
12
+ } | undefined;
13
+ export type AddEventPAPI = (element: WebFiberElementImpl, eventType: LynxEventType, eventName: string, newEventHandler: ElementPAPIEventHandler) => void;
14
+ export type GetEventPAPI = (element: WebFiberElementImpl, eventName: string, eventType: LynxEventType) => ElementPAPIEventHandler;
15
+ export type GetEventsPAPI = (element: WebFiberElementImpl) => {
16
+ type: LynxEventType;
17
+ name: string;
18
+ function: ElementPAPIEventHandler;
19
+ }[];
20
+ export type SetEventsPAPI = (element: WebFiberElementImpl, listeners: {
21
+ type: LynxEventType;
22
+ name: string;
23
+ function: ElementPAPIEventHandler;
24
+ }[]) => void;
25
+ export type AppendElementPAPI = (parent: WebFiberElementImpl, child: WebFiberElementImpl) => void;
26
+ export type ElementIsEqualPAPI = (left: WebFiberElementImpl, right: WebFiberElementImpl) => boolean;
27
+ export type FirstElementPAPI = (element: WebFiberElementImpl) => WebFiberElementImpl | null;
28
+ export type GetChildrenPAPI = (element: WebFiberElementImpl) => WebFiberElementImpl[];
29
+ export type GetParentPAPI = (element: WebFiberElementImpl) => WebFiberElementImpl | null;
30
+ export type InsertElementBeforePAPI = (parent: WebFiberElementImpl, child: WebFiberElementImpl, ref?: WebFiberElementImpl | null) => WebFiberElementImpl;
31
+ export type LastElementPAPI = (element: WebFiberElementImpl) => WebFiberElementImpl | null;
32
+ export type NextElementPAPI = (element: WebFiberElementImpl) => WebFiberElementImpl | null;
33
+ export type RemoveElementPAPI = (parent: WebFiberElementImpl, child: WebFiberElementImpl) => WebFiberElementImpl;
34
+ export type ReplaceElementPAPI = (newElement: WebFiberElementImpl, oldElement: WebFiberElementImpl) => void;
35
+ export type ReplaceElementsPAPI = (parent: WebFiberElementImpl, newChildren: WebFiberElementImpl[] | WebFiberElementImpl, oldChildren?: WebFiberElementImpl[] | WebFiberElementImpl | null | undefined) => void;
36
+ export type AddConfigPAPI = (element: WebFiberElementImpl, type: string, value: Cloneable) => void;
37
+ export type AddDatasetPAPI = (element: WebFiberElementImpl, key: string, value: Cloneable) => void;
38
+ export type GetDatasetPAPI = (element: WebFiberElementImpl) => Record<string, Cloneable>;
39
+ export type GetDataByKeyPAPI = (element: WebFiberElementImpl, key: string) => Cloneable | undefined;
40
+ export type GetAttributesPAPI = (element: WebFiberElementImpl) => Record<string, string>;
41
+ export type GetComponentIdPAPI = (element: WebFiberElementImpl) => string | null;
42
+ export type GetElementConfigPAPI = (element: WebFiberElementImpl) => Record<string, Cloneable>;
43
+ export type GetElementUniqueIDPAPI = (element: WebFiberElementImpl) => number;
44
+ export type GetIDPAPI = (element: WebFiberElementImpl) => string | null;
45
+ export type GetTagPAPI = (element: WebFiberElementImpl) => string;
46
+ export type SetConfigPAPI = (element: WebFiberElementImpl, config: Record<string, Cloneable>) => void;
47
+ export type SetDatasetPAPI = (element: WebFiberElementImpl, dataset: Record<string, Cloneable>) => void;
48
+ export type SetIDPAPI = (element: WebFiberElementImpl, id: string | null) => void;
49
+ export type UpdateComponentIDPAPI = (element: WebFiberElementImpl, componentID: string) => void;
50
+ export type GetClassesPAPI = (element: WebFiberElementImpl) => string[];
51
+ export type CreateViewPAPI = (parentComponentUniqueID: number) => WebFiberElementImpl;
52
+ export type SwapElementPAPI = (childA: WebFiberElementImpl, childB: WebFiberElementImpl) => void;
53
+ export type UpdateListInfoAttributeValue = {
54
+ insertAction: {
55
+ position: number;
56
+ }[];
57
+ removeAction: {
58
+ position: number;
59
+ }[];
60
+ };
61
+ export type SetAttributePAPI = (element: WebFiberElementImpl, key: string, value: string | null | undefined | UpdateListInfoAttributeValue) => void;
62
+ export type UpdateListCallbacksPAPI = (element: WebFiberElementImpl, componentAtIndex: ComponentAtIndexCallback, enqueueComponent: EnqueueComponentCallback) => void;
63
+ export type CreateTextPAPI = CreateViewPAPI;
64
+ export type CreateRawTextPAPI = (text: string) => WebFiberElementImpl;
65
+ export type CreateImagePAPI = CreateViewPAPI;
66
+ export type CreateScrollViewPAPI = CreateViewPAPI;
67
+ export type CreateWrapperElementPAPI = CreateViewPAPI;
68
+ export type CreateComponentPAPI = (componentParentUniqueID: number, componentID: string, cssID: number, entryName: string, name: string, path: string, config: Record<string, Cloneable> | null | undefined, info: Record<string, Cloneable> | null | undefined) => WebFiberElementImpl;
69
+ export type CreateElementPAPI = (tagName: string, parentComponentUniqueId: number, info?: Record<string, Cloneable> | null | undefined) => WebFiberElementImpl;
70
+ export type CreatePagePAPI = (componentID: string, cssID: number, info: Record<string, Cloneable> | null | undefined) => WebFiberElementImpl;
71
+ export type CreateListPAPI = (parentComponentUniqueId: number, componentAtIndex: ComponentAtIndexCallback, enqueueComponent: EnqueueComponentCallback) => WebFiberElementImpl;
72
+ export type AddClassPAPI = (element: WebFiberElementImpl, className: string) => void;
73
+ export type SetClassesPAPI = (element: WebFiberElementImpl, classNames: string | null) => void;
74
+ export type AddInlineStylePAPI = (element: WebFiberElementImpl, key: number | string, value: string | number | null | undefined) => void;
75
+ export type SetInlineStylesPAPI = (element: WebFiberElementImpl, value: string | Record<string, string> | undefined) => void;
76
+ export type SetCSSIdPAPI = (elements: WebFiberElementImpl[], cssId: number | null) => void;
77
+ export type GetPageElementPAPI = () => WebFiberElementImpl | undefined;
78
+ export type GetTemplatePartsPAPI = (templateElement: WebFiberElementImpl) => Record<string, WebFiberElementImpl> | undefined;
79
+ interface JSErrorInfo {
80
+ release: string;
81
+ }
82
+ export interface MainThreadGlobalThis {
83
+ __AddEvent: AddEventPAPI;
84
+ __GetEvent: GetEventPAPI;
85
+ __GetEvents: GetEventsPAPI;
86
+ __SetEvents: SetEventsPAPI;
87
+ __AppendElement: AppendElementPAPI;
88
+ __ElementIsEqual: ElementIsEqualPAPI;
89
+ __FirstElement: FirstElementPAPI;
90
+ __GetChildren: GetChildrenPAPI;
91
+ __GetParent: GetParentPAPI;
92
+ __InsertElementBefore: InsertElementBeforePAPI;
93
+ __LastElement: LastElementPAPI;
94
+ __NextElement: NextElementPAPI;
95
+ __RemoveElement: RemoveElementPAPI;
96
+ __ReplaceElement: ReplaceElementPAPI;
97
+ __ReplaceElements: ReplaceElementsPAPI;
98
+ __AddConfig: AddConfigPAPI;
99
+ __AddDataset: AddDatasetPAPI;
100
+ __GetDataset: GetDatasetPAPI;
101
+ __GetDataByKey: GetDataByKeyPAPI;
102
+ __GetAttributes: GetAttributesPAPI;
103
+ __GetComponentID: GetComponentIdPAPI;
104
+ __GetElementConfig: GetElementConfigPAPI;
105
+ __GetElementUniqueID: GetElementUniqueIDPAPI;
106
+ __GetID: GetIDPAPI;
107
+ __GetTag: GetTagPAPI;
108
+ __SetConfig: SetConfigPAPI;
109
+ __GetConfig: GetElementConfigPAPI;
110
+ __SetDataset: SetDatasetPAPI;
111
+ __SetID: SetIDPAPI;
112
+ __UpdateComponentID: UpdateComponentIDPAPI;
113
+ __GetClasses: GetClassesPAPI;
114
+ __CreateView: CreateViewPAPI;
115
+ __SwapElement: SwapElementPAPI;
116
+ __CreateText: CreateTextPAPI;
117
+ __CreateRawText: CreateRawTextPAPI;
118
+ __CreateImage: CreateImagePAPI;
119
+ __CreateScrollView: CreateScrollViewPAPI;
120
+ __CreateWrapperElement: CreateWrapperElementPAPI;
121
+ __CreateComponent: CreateComponentPAPI;
122
+ __CreateElement: CreateElementPAPI;
123
+ __CreatePage: CreatePagePAPI;
124
+ __CreateList: CreateListPAPI;
125
+ __SetAttribute: SetAttributePAPI;
126
+ __UpdateListCallbacks: UpdateListCallbacksPAPI;
127
+ __AddClass: AddClassPAPI;
128
+ __SetClasses: SetClassesPAPI;
129
+ __AddInlineStyle: AddInlineStylePAPI;
130
+ __SetInlineStyles: SetInlineStylesPAPI;
131
+ __SetCSSId: SetCSSIdPAPI;
132
+ __GetPageElement: GetPageElementPAPI;
133
+ __GetTemplateParts: GetTemplatePartsPAPI;
134
+ __globalProps: unknown;
135
+ SystemInfo: typeof systemInfo;
136
+ globalThis?: MainThreadGlobalThis;
137
+ lynx: MainThreadLynx;
138
+ processData?: ProcessDataCallback;
139
+ ssrEncode?: () => string;
140
+ ssrHydrate?: (encodeData?: string) => void;
141
+ _ReportError: (error: Error, _: unknown) => void;
142
+ _SetSourceMapRelease: (errInfo: JSErrorInfo) => void;
143
+ __OnLifecycleEvent: (lifeCycleEvent: Cloneable) => void;
144
+ __LoadLepusChunk: (path: string) => boolean;
145
+ __FlushElementTree: (_subTree: unknown, options: FlushElementTreeOptions) => void;
146
+ _I18nResourceTranslation: (options: I18nResourceTranslationOptions) => unknown | undefined;
147
+ _AddEventListener: (...args: unknown[]) => void;
148
+ /**
149
+ * private fields
150
+ */
151
+ _updateVars: () => void;
152
+ __lynxGlobalBindingValues: Record<string, unknown>;
153
+ renderPage: ((data: unknown) => void) | undefined;
154
+ updatePage?: (data: Cloneable, options?: Record<string, string>) => void;
155
+ runWorklet?: (obj: unknown, event: unknown) => void;
156
+ }
157
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MainThreadGlobalThis.js.map
@@ -0,0 +1,10 @@
1
+ import type { Cloneable } from './Cloneable.js';
2
+ import type { LynxContextEventTarget } from './LynxContextEventTarget.js';
3
+ export interface MainThreadLynx {
4
+ getJSContext: () => LynxContextEventTarget;
5
+ requestAnimationFrame: (cb: () => void) => number;
6
+ cancelAnimationFrame: (handler: number) => void;
7
+ __globalProps: unknown;
8
+ getCustomSectionSync: (key: string) => Cloneable;
9
+ markPipelineTiming: (pipelineId: string, timingKey: string) => void;
10
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=MainThreadLynx.js.map
@@ -1,4 +1,5 @@
1
1
  import type { Cloneable } from './Cloneable.js';
2
+ import type { InitI18nResources } from './index.js';
2
3
  import type { LynxTemplate } from './LynxModule.js';
3
4
  import type { NapiModulesMap } from './NapiModules.js';
4
5
  import type { NativeModulesMap } from './NativeModules.js';
@@ -11,4 +12,5 @@ export interface StartMainThreadContextConfig {
11
12
  nativeModulesMap: NativeModulesMap;
12
13
  napiModulesMap: NapiModulesMap;
13
14
  tagMap: Record<string, string>;
15
+ initI18nResources: InitI18nResources;
14
16
  }
@@ -3,7 +3,7 @@ export type NapiModulesMap = Record<string, string>;
3
3
  export type NapiModulesCall = (name: string, data: any, moduleName: string, dispatchNapiModules: (data: Cloneable) => void) => Promise<{
4
4
  data: unknown;
5
5
  transfer?: unknown[];
6
- }> | {
6
+ } | undefined> | {
7
7
  data: unknown;
8
8
  transfer?: unknown[];
9
- } | undefined;
9
+ } | undefined | Promise<undefined>;
@@ -1,4 +1,5 @@
1
1
  import type { CloneableObject } from './Cloneable.js';
2
+ import type { I18nResource } from './I18n.js';
2
3
  import type { LynxContextEventTarget } from './LynxContextEventTarget.js';
3
4
  import type { PerformancePipelineOptions } from './Performance.js';
4
5
  export declare const enum IdentifierType {
@@ -108,4 +109,5 @@ export interface NativeApp {
108
109
  createJSObjectDestructionObserver(callback: (...args: unknown[]) => unknown): {};
109
110
  setSharedData<T>(dataKey: string, dataVal: T): void;
110
111
  getSharedData<T = unknown>(dataKey: string): T | undefined;
112
+ i18nResource: I18nResource;
111
113
  }
@@ -3,6 +3,7 @@ export interface PageConfig {
3
3
  enableRemoveCSSScope: boolean;
4
4
  defaultDisplayLinear: boolean;
5
5
  defaultOverflowVisible: boolean;
6
+ enableJSDataProcessor: boolean;
6
7
  }
7
8
  export interface BrowserConfig {
8
9
  pixelRatio: number;
@@ -13,3 +13,7 @@ export * from './NapiModules.js';
13
13
  export * from './FlushElementTreeOptions.js';
14
14
  export * from './LynxContextEventTarget.js';
15
15
  export * from './Element.js';
16
+ export * from './MainThreadGlobalThis.js';
17
+ export * from './MainThreadLynx.js';
18
+ export * from './I18n.js';
19
+ export * from './BackThreadStartConfigs.js';
@@ -13,4 +13,8 @@ export * from './NapiModules.js';
13
13
  export * from './FlushElementTreeOptions.js';
14
14
  export * from './LynxContextEventTarget.js';
15
15
  export * from './Element.js';
16
+ export * from './MainThreadGlobalThis.js';
17
+ export * from './MainThreadLynx.js';
18
+ export * from './I18n.js';
19
+ export * from './BackThreadStartConfigs.js';
16
20
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-constants",
3
- "version": "0.13.4",
3
+ "version": "0.14.0",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -23,9 +23,9 @@
23
23
  "**/*.css"
24
24
  ],
25
25
  "dependencies": {
26
- "@lynx-js/web-worker-rpc": "0.13.4"
26
+ "@lynx-js/web-worker-rpc": "0.14.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@lynx-js/offscreen-document": "0.1.0"
29
+ "@lynx-js/offscreen-document": "0.1.2"
30
30
  }
31
31
  }