@lynx-js/web-core-canary 0.17.2 → 0.18.0-canary-20251010-7e06ca90

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,28 @@
1
1
  # @lynx-js/web-core
2
2
 
3
+ ## 0.18.0-canary-20251010093237-7e06ca90219bfcda958ae57cb91eb0a2e284eb02
4
+
5
+ ### Minor Changes
6
+
7
+ - fix: ([#1837](https://github.com/lynx-family/lynx-stack/pull/1837))
8
+
9
+ 1. `LynxView.updateData()` cannot trigger `dataProcessor`.
10
+
11
+ 2. **This is a break change:** The second parameter of `LynxView.updateData()` has been changed from `UpdateDataType` to `string`, which is the `processorName` (default is `default` which will use `defaultDataProcessor`). This change is to better align with Native. The current complete type is as follows:
12
+
13
+ ```ts
14
+ LynxView.updateData(data: Cloneable, processorName?: string | undefined, callback?: (() => void) | undefined): void
15
+ ```
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [[`77397fd`](https://github.com/lynx-family/lynx-stack/commit/77397fd535cf60556f8f82f7ef8dae8a623d1625)]:
20
+ - @lynx-js/web-worker-runtime@0.18.0-canary-20251010093237-7e06ca90219bfcda958ae57cb91eb0a2e284eb02
21
+ - @lynx-js/web-constants@0.18.0-canary-20251010093237-7e06ca90219bfcda958ae57cb91eb0a2e284eb02
22
+ - @lynx-js/web-elements@0.8.8-canary-20251010093237-7e06ca90219bfcda958ae57cb91eb0a2e284eb02
23
+ - @lynx-js/web-mainthread-apis@0.18.0-canary-20251010093237-7e06ca90219bfcda958ae57cb91eb0a2e284eb02
24
+ - @lynx-js/web-worker-rpc@0.18.0-canary-20251010093237-7e06ca90219bfcda958ae57cb91eb0a2e284eb02
25
+
3
26
  ## 0.17.2
4
27
 
5
28
  ### Patch Changes
@@ -330,25 +353,25 @@
330
353
  lynxView.initI18nResources = [
331
354
  {
332
355
  options: {
333
- locale: 'en',
334
- channel: '1',
335
- fallback_url: '',
356
+ locale: "en",
357
+ channel: "1",
358
+ fallback_url: "",
336
359
  },
337
360
  resource: {
338
- hello: 'hello',
339
- lynx: 'lynx web platform1',
361
+ hello: "hello",
362
+ lynx: "lynx web platform1",
340
363
  },
341
364
  },
342
365
  ];
343
- lynxView.addEventListener('i18nResourceMissed', (e) => {
366
+ lynxView.addEventListener("i18nResourceMissed", (e) => {
344
367
  console.log(e);
345
368
  });
346
369
 
347
370
  // mts
348
371
  _I18nResourceTranslation({
349
- locale: 'en',
350
- channel: '1',
351
- fallback_url: '',
372
+ locale: "en",
373
+ channel: "1",
374
+ fallback_url: "",
352
375
  });
353
376
  ```
354
377
 
@@ -756,8 +779,8 @@
756
779
  }
757
780
  };`,
758
781
  ],
759
- { type: 'text/javascript' },
760
- ),
782
+ { type: "text/javascript" }
783
+ )
761
784
  ),
762
785
  };
763
786
  lynxView.nativeModulesMap = nativeModulesMap;
@@ -872,8 +895,8 @@
872
895
  };
873
896
  };`,
874
897
  ],
875
- { type: 'text/javascript' },
876
- ),
898
+ { type: "text/javascript" }
899
+ )
877
900
  );
878
901
 
879
902
  const color_methods = URL.createObjectURL(
@@ -888,8 +911,8 @@
888
911
  };
889
912
  };`,
890
913
  ],
891
- { type: 'text/javascript' },
892
- ),
914
+ { type: "text/javascript" }
915
+ )
893
916
  );
894
917
 
895
918
  lynxView.napiModuleMap = {
@@ -906,7 +929,7 @@
906
929
 
907
930
  ```js
908
931
  lynxView.onNapiModulesCall = (name, data, moduleName) => {
909
- if (name === 'getColor' && moduleName === 'color_methods') {
932
+ if (name === "getColor" && moduleName === "color_methods") {
910
933
  return data.color;
911
934
  }
912
935
  };
@@ -985,8 +1008,8 @@
985
1008
  }
986
1009
  };`,
987
1010
  ],
988
- { type: 'text/javascript' },
989
- ),
1011
+ { type: "text/javascript" }
1012
+ )
990
1013
  );
991
1014
  ```
992
1015
 
@@ -998,7 +1021,7 @@
998
1021
 
999
1022
  ```js
1000
1023
  lynxView.onNativeModulesCall = (name, data, callback) => {
1001
- if (name === 'getColor') {
1024
+ if (name === "getColor") {
1002
1025
  callback(data.color);
1003
1026
  }
1004
1027
  };
@@ -1008,7 +1031,7 @@
1008
1031
 
1009
1032
  ```js
1010
1033
  lynxView.onNativeModulesCall = (name, data, moduleName) => {
1011
- if (name === 'getColor' && moduleName === 'bridge') {
1034
+ if (name === "getColor" && moduleName === "bridge") {
1012
1035
  return data.color;
1013
1036
  }
1014
1037
  };
@@ -1366,7 +1389,7 @@
1366
1389
  This flag changes the behaviour of cascading. It provide a way to do this
1367
1390
 
1368
1391
  ```jsx
1369
- <view class='class-a class-b' />;
1392
+ <view class="class-a class-b" />
1370
1393
  ```
1371
1394
 
1372
1395
  The class-b will override (cascading) styles of class-a.
@@ -1424,7 +1447,7 @@
1424
1447
  ```
1425
1448
  * @param {string} url [required] The url of the entry of your Lynx card
1426
1449
  * @param {Cloneable} globalProps [optional] The globalProps value of this Lynx card
1427
- * @param {Cloneable} initData [oprional] The initial data of this Lynx card
1450
+ * @param {Cloneable} initData [optional] The initial data of this Lynx card
1428
1451
  * @param {Record<string,string>} overrideLynxTagToHTMLTagMap [optional] use this property/attribute to override the lynx tag -> html tag map
1429
1452
  * @param {NativeModulesCallHandler} onNativeModulesCall [optional] the NativeModules.bridge.call value handler. Arguments will be cached before this property is assigned.
1430
1453
  *
@@ -1466,11 +1489,11 @@
1466
1489
  There is also a simple way to use this feature
1467
1490
 
1468
1491
  ```javascript
1469
- import { LynxCard } from '@lynx-js/web-core';
1470
- import { loadElement } from '@lynx-js/web-elements/lazy';
1471
- import '@lynx-js/web-elements/index.css';
1472
- import '@lynx-js/web-core/index.css';
1473
- import './index.css';
1492
+ import { LynxCard } from "@lynx-js/web-core";
1493
+ import { loadElement } from "@lynx-js/web-elements/lazy";
1494
+ import "@lynx-js/web-elements/index.css";
1495
+ import "@lynx-js/web-core/index.css";
1496
+ import "./index.css";
1474
1497
 
1475
1498
  const lynxcard = new LynxCard({
1476
1499
  ...beforeConfigs,
@@ -1,4 +1,4 @@
1
- import { type Cloneable, type I18nResourceTranslationOptions, type InitI18nResources, type LynxTemplate, type NapiModulesCall, type NapiModulesMap, type NativeModulesCall, type NativeModulesMap, type UpdateDataType } from '@lynx-js/web-constants';
1
+ import { type Cloneable, type I18nResourceTranslationOptions, type InitI18nResources, type LynxTemplate, type NapiModulesCall, type NapiModulesMap, type NativeModulesCall, type NativeModulesMap } from '@lynx-js/web-constants';
2
2
  export type INapiModulesCall = (name: string, data: any, moduleName: string, lynxView: LynxView, dispatchNapiModules: (data: Cloneable) => void) => Promise<{
3
3
  data: unknown;
4
4
  transfer?: Transferable[];
@@ -12,7 +12,7 @@ export type INapiModulesCall = (name: string, data: any, moduleName: string, lyn
12
12
  /**
13
13
  * @property {string} url [required] (attribute: "url") The url of the entry of your Lynx card
14
14
  * @property {Cloneable} globalProps [optional] (attribute: "global-props") The globalProps value of this Lynx card
15
- * @property {Cloneable} initData [oprional] (attribute: "init-data") The initial data of this Lynx card
15
+ * @property {Cloneable} initData [optional] (attribute: "init-data") The initial data of this Lynx card
16
16
  * @property {Record<string,string>} overrideLynxTagToHTMLTagMap [optional] use this property/attribute to override the lynx tag -> html tag map
17
17
  * @property {NativeModulesMap} nativeModulesMap [optional] use to customize NativeModules. key is module-name, value is esm url.
18
18
  * @property {NativeModulesCall} onNativeModulesCall [optional] the NativeModules value handler. Arguments will be cached before this property is assigned.
@@ -132,7 +132,7 @@ export declare class LynxView extends HTMLElement {
132
132
  * @method
133
133
  * update the `__initData` and trigger essential flow
134
134
  */
135
- updateData(data: Cloneable, updateDataType: UpdateDataType, callback?: () => void): void;
135
+ updateData(data: Cloneable, processorName?: string, callback?: () => void): void;
136
136
  /**
137
137
  * @public
138
138
  * @method
@@ -9,7 +9,7 @@ import { inShadowRootStyles, lynxDisposedAttribute, lynxTagAttribute, } from '@l
9
9
  /**
10
10
  * @property {string} url [required] (attribute: "url") The url of the entry of your Lynx card
11
11
  * @property {Cloneable} globalProps [optional] (attribute: "global-props") The globalProps value of this Lynx card
12
- * @property {Cloneable} initData [oprional] (attribute: "init-data") The initial data of this Lynx card
12
+ * @property {Cloneable} initData [optional] (attribute: "init-data") The initial data of this Lynx card
13
13
  * @property {Record<string,string>} overrideLynxTagToHTMLTagMap [optional] use this property/attribute to override the lynx tag -> html tag map
14
14
  * @property {NativeModulesMap} nativeModulesMap [optional] use to customize NativeModules. key is module-name, value is esm url.
15
15
  * @property {NativeModulesCall} onNativeModulesCall [optional] the NativeModules value handler. Arguments will be cached before this property is assigned.
@@ -220,8 +220,8 @@ export class LynxView extends HTMLElement {
220
220
  * @method
221
221
  * update the `__initData` and trigger essential flow
222
222
  */
223
- updateData(data, updateDataType, callback) {
224
- this.#instance?.updateData(data, updateDataType, callback);
223
+ updateData(data, processorName, callback) {
224
+ this.#instance?.updateData(data, processorName, callback);
225
225
  }
226
226
  /**
227
227
  * @public
@@ -1,4 +1,4 @@
1
- import type { Cloneable, SSRDumpInfo, I18nResourceTranslationOptions, InitI18nResources, NapiModulesMap, NativeModulesMap, sendGlobalEventEndpoint, UpdateDataType } from '@lynx-js/web-constants';
1
+ import type { Cloneable, SSRDumpInfo, I18nResourceTranslationOptions, InitI18nResources, NapiModulesMap, NativeModulesMap, sendGlobalEventEndpoint } from '@lynx-js/web-constants';
2
2
  import { type StartUIThreadCallbacks } from '../uiThread/startUIThread.js';
3
3
  import type { RpcCallType } from '@lynx-js/web-worker-rpc';
4
4
  export interface LynxViewConfigs {
@@ -16,7 +16,7 @@ export interface LynxViewConfigs {
16
16
  ssr?: SSRDumpInfo;
17
17
  }
18
18
  export interface LynxView {
19
- updateData(data: Cloneable, updateDataType: UpdateDataType, callback?: () => void): void;
19
+ updateData(data: Cloneable, processorName?: string, callback?: () => void): void;
20
20
  dispose(): Promise<void>;
21
21
  sendGlobalEvent: RpcCallType<typeof sendGlobalEventEndpoint>;
22
22
  updateGlobalProps: (data: Cloneable) => void;
@@ -3,6 +3,6 @@ import { Rpc } from '@lynx-js/web-worker-rpc';
3
3
  import type { StartUIThreadCallbacks } from './startUIThread.js';
4
4
  export declare function createRenderAllOnUI(mainToBackgroundRpc: Rpc, shadowRoot: ShadowRoot, loadTemplate: TemplateLoader, markTimingInternal: (timingKey: string, pipelineId?: string, timeStamp?: number) => void, flushMarkTimingInternal: () => void, callbacks: StartUIThreadCallbacks, ssrDumpInfo: SSRDumpInfo | undefined): {
5
5
  start: (configs: StartMainThreadContextConfig) => Promise<void>;
6
- updateDataMainThread: (args_0: Cloneable, args_1: Record<string, string>) => Promise<void>;
6
+ updateDataMainThread: (args_0: Cloneable, args_1: import("@lynx-js/web-constants").UpdateDataOptions | undefined) => Promise<void>;
7
7
  updateI18nResourcesMainThread: (data: Cloneable) => void;
8
8
  };
@@ -1,7 +1,7 @@
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
- import { i18nResourceMissedEventName, I18nResources, lynxUniqueIdAttribute, } from '@lynx-js/web-constants';
4
+ import { updateDataEndpoint, i18nResourceMissedEventName, I18nResources, lynxUniqueIdAttribute, } from '@lynx-js/web-constants';
5
5
  import { Rpc } from '@lynx-js/web-worker-rpc';
6
6
  import { dispatchLynxViewEvent } from '../utils/dispatchLynxViewEvent.js';
7
7
  import { createExposureMonitor } from './crossThreadHandlers/createExposureMonitor.js';
@@ -83,7 +83,7 @@ export function createRenderAllOnUI(mainToBackgroundRpc, shadowRoot, loadTemplat
83
83
  const { exposureChangedCallback } = createExposureMonitor(shadowRoot);
84
84
  const mtsRealm = createIFrameRealm(shadowRoot);
85
85
  const mtsGlobalThis = mtsRealm.globalWindow;
86
- const { startMainThread } = prepareMainThreadAPIs(mainToBackgroundRpc, shadowRoot, document, mtsRealm, exposureChangedCallback, markTimingInternal, flushMarkTimingInternal, (err, _, release) => {
86
+ const { startMainThread, handleUpdatedData } = prepareMainThreadAPIs(mainToBackgroundRpc, shadowRoot, document, mtsRealm, exposureChangedCallback, markTimingInternal, flushMarkTimingInternal, (err, _, release) => {
87
87
  callbacks.onError?.(err, release, 'lepus.js');
88
88
  }, triggerI18nResourceFallback, (initI18nResources) => {
89
89
  i18nResources.setData(initI18nResources);
@@ -125,18 +125,18 @@ export function createRenderAllOnUI(mainToBackgroundRpc, shadowRoot, loadTemplat
125
125
  await startMainThread(configs);
126
126
  }
127
127
  // Process any pending update calls that were queued while mtsGlobalThis was undefined
128
- for (const args of pendingUpdateCalls) {
129
- mtsGlobalThis.updatePage?.(...args);
128
+ for (const [newData, options] of pendingUpdateCalls) {
129
+ handleUpdatedData(newData, options);
130
130
  }
131
131
  pendingUpdateCalls.length = 0;
132
132
  };
133
- const updateDataMainThread = async (...args) => {
133
+ const updateDataMainThread = async (newData, options) => {
134
134
  if (mtsGlobalThis) {
135
- mtsGlobalThis.updatePage?.(...args);
135
+ return handleUpdatedData(newData, options);
136
136
  }
137
137
  else {
138
138
  // Cache the call if mtsGlobalThis is not yet initialized
139
- pendingUpdateCalls.push(args);
139
+ pendingUpdateCalls.push([newData, options]);
140
140
  }
141
141
  };
142
142
  const updateI18nResourcesMainThread = (data) => {
@@ -3,6 +3,6 @@ import type { Rpc } from '@lynx-js/web-worker-rpc';
3
3
  import type { StartUIThreadCallbacks } from './startUIThread.js';
4
4
  export declare function createRenderMultiThread(mainThreadRpc: Rpc, shadowRoot: ShadowRoot, loadTemplate: TemplateLoader, callbacks: StartUIThreadCallbacks): {
5
5
  start: (args_0: import("@lynx-js/web-constants").StartMainThreadContextConfig) => void;
6
- updateDataMainThread: (args_0: import("@lynx-js/web-constants").Cloneable, args_1: Record<string, string>) => Promise<void>;
6
+ updateDataMainThread: (args_0: import("@lynx-js/web-constants").Cloneable, args_1: import("@lynx-js/web-constants").UpdateDataOptions | undefined) => Promise<void>;
7
7
  updateI18nResourcesMainThread: (args_0: import("@lynx-js/web-constants").Cloneable) => void;
8
8
  };
@@ -1,4 +1,4 @@
1
1
  import type { RpcCallType } from '@lynx-js/web-worker-rpc';
2
2
  import type { LynxView } from '../../apis/createLynxView.js';
3
3
  import { updateDataEndpoint } from '@lynx-js/web-constants';
4
- export declare function createUpdateData(updateDataMainThread: RpcCallType<typeof updateDataEndpoint>, updateDataBackground: RpcCallType<typeof updateDataEndpoint>): LynxView['updateData'];
4
+ export declare function createUpdateData(updateDataMainThread: RpcCallType<typeof updateDataEndpoint>): LynxView['updateData'];
@@ -1,14 +1,10 @@
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
- import { updateDataEndpoint, } from '@lynx-js/web-constants';
5
- export function createUpdateData(updateDataMainThread, updateDataBackground) {
6
- return (data, _updateDataType, callback) => {
7
- Promise.all([
8
- // There is no need to process options for now, as they have default values.
9
- updateDataMainThread(data, {}),
10
- updateDataBackground(data, {}),
11
- ]).then(() => callback?.());
4
+ import { updateDataEndpoint } from '@lynx-js/web-constants';
5
+ export function createUpdateData(updateDataMainThread) {
6
+ return (data, processorName, callback) => {
7
+ updateDataMainThread(data, { processorName }).then(() => callback?.());
12
8
  };
13
9
  }
14
10
  //# sourceMappingURL=createUpdateData.js.map
@@ -4,6 +4,5 @@ import type { StartUIThreadCallbacks } from './startUIThread.js';
4
4
  export declare function startBackground(backgroundRpc: Rpc, shadowRoot: ShadowRoot, callbacks: StartUIThreadCallbacks): {
5
5
  sendGlobalEvent: (args_0: string, args_1: Cloneable[] | undefined) => void;
6
6
  markTiming: (args_0: import("@lynx-js/web-constants").MarkTiming[]) => void;
7
- updateDataBackground: (args_0: Cloneable, args_1: Record<string, string>) => Promise<void>;
8
7
  updateI18nResourceBackground: (data: InitI18nResources, options: I18nResourceTranslationOptions) => void;
9
8
  };
@@ -1,4 +1,4 @@
1
- import { getCacheI18nResourcesKey, markTimingEndpoint, sendGlobalEventEndpoint, updateDataEndpoint, updateI18nResourceEndpoint, } from '@lynx-js/web-constants';
1
+ import { getCacheI18nResourcesKey, markTimingEndpoint, sendGlobalEventEndpoint, updateI18nResourceEndpoint, } from '@lynx-js/web-constants';
2
2
  import { registerInvokeUIMethodHandler } from './crossThreadHandlers/registerInvokeUIMethodHandler.js';
3
3
  import { registerNativePropsHandler } from './crossThreadHandlers/registerSetNativePropsHandler.js';
4
4
  import { registerNativeModulesCallHandler } from './crossThreadHandlers/registerNativeModulesCallHandler.js';
@@ -22,7 +22,6 @@ export function startBackground(backgroundRpc, shadowRoot, callbacks) {
22
22
  registerReportErrorHandler(backgroundRpc, 'app-service.js', callbacks.onError);
23
23
  const sendGlobalEvent = backgroundRpc.createCall(sendGlobalEventEndpoint);
24
24
  const markTiming = backgroundRpc.createCall(markTimingEndpoint);
25
- const updateDataBackground = backgroundRpc.createCall(updateDataEndpoint);
26
25
  const updateI18nResourceBackground = (data, options) => {
27
26
  const matchedResources = data.find(i => getCacheI18nResourcesKey(i.options)
28
27
  === getCacheI18nResourcesKey(options));
@@ -33,7 +32,6 @@ export function startBackground(backgroundRpc, shadowRoot, callbacks) {
33
32
  return {
34
33
  sendGlobalEvent,
35
34
  markTiming,
36
- updateDataBackground,
37
35
  updateI18nResourceBackground,
38
36
  };
39
37
  }
@@ -13,7 +13,7 @@ export function startUIThread(templateUrl, configs, shadowRoot, lynxGroupId, thr
13
13
  const createLynxStartTiming = performance.now() + performance.timeOrigin;
14
14
  const allOnUI = threadStrategy === 'all-on-ui';
15
15
  const { mainThreadRpc, backgroundRpc, terminateWorkers, } = bootWorkers(lynxGroupId, allOnUI, configs.browserConfig);
16
- const { markTiming, sendGlobalEvent, updateDataBackground, updateI18nResourceBackground, } = startBackground(backgroundRpc, shadowRoot, callbacks);
16
+ const { markTiming, sendGlobalEvent, updateI18nResourceBackground, } = startBackground(backgroundRpc, shadowRoot, callbacks);
17
17
  const cacheMarkTimings = {
18
18
  records: [],
19
19
  timeout: null,
@@ -43,7 +43,7 @@ export function startUIThread(templateUrl, configs, shadowRoot, lynxGroupId, thr
43
43
  });
44
44
  });
45
45
  return {
46
- updateData: createUpdateData(updateDataMainThread, updateDataBackground),
46
+ updateData: createUpdateData(updateDataMainThread),
47
47
  dispose: createDispose(backgroundRpc, terminateWorkers),
48
48
  sendGlobalEvent,
49
49
  updateGlobalProps: backgroundRpc.createCall(updateGlobalPropsEndpoint),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-core-canary",
3
- "version": "0.17.2",
3
+ "version": "0.18.0-canary-20251010-7e06ca90",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -25,14 +25,14 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "@lynx-js/offscreen-document": "npm:@lynx-js/offscreen-document-canary@0.1.4",
28
- "@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.17.2",
29
- "@lynx-js/web-mainthread-apis": "npm:@lynx-js/web-mainthread-apis-canary@0.17.2",
30
- "@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.17.2",
31
- "@lynx-js/web-worker-runtime": "npm:@lynx-js/web-worker-runtime-canary@0.17.2"
28
+ "@lynx-js/web-constants": "npm:@lynx-js/web-constants-canary@0.18.0-canary-20251010-7e06ca90",
29
+ "@lynx-js/web-mainthread-apis": "npm:@lynx-js/web-mainthread-apis-canary@0.18.0-canary-20251010-7e06ca90",
30
+ "@lynx-js/web-worker-rpc": "npm:@lynx-js/web-worker-rpc-canary@0.18.0-canary-20251010-7e06ca90",
31
+ "@lynx-js/web-worker-runtime": "npm:@lynx-js/web-worker-runtime-canary@0.18.0-canary-20251010-7e06ca90"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@lynx-js/lynx-core": "0.1.3",
35
- "@lynx-js/web-elements": "npm:@lynx-js/web-elements-canary@0.8.7"
35
+ "@lynx-js/web-elements": "npm:@lynx-js/web-elements-canary@0.8.8-canary-20251010-7e06ca90"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@lynx-js/lynx-core": "0.1.3",