@lynx-js/web-core 0.8.0 → 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 CHANGED
@@ -1,5 +1,75 @@
1
1
  # @lynx-js/web-core
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 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))
8
+
9
+ "warning: This is a breaking change."
10
+
11
+ `nativeModulesMap` will be a map: key is module-name, value should be a esm url which export default a
12
+ function with two parameters(you never need to use `this`):
13
+
14
+ - `NativeModules`: oriented `NativeModules`, which you can use to call
15
+ other Native-Modules.
16
+
17
+ - `NativeModulesCall`: trigger `onNativeModulesCall`, same as the deprecated `this.nativeModulesCall`.
18
+
19
+ example:
20
+
21
+ ```js
22
+ const nativeModulesMap = {
23
+ CustomModule: URL.createObjectURL(
24
+ new Blob(
25
+ [
26
+ `export default function(NativeModules, NativeModulesCall) {
27
+ return {
28
+ async getColor(data, callback) {
29
+ const color = await NativeModulesCall('getColor', data);
30
+ callback(color);
31
+ },
32
+ }
33
+ };`,
34
+ ],
35
+ { type: 'text/javascript' },
36
+ ),
37
+ ),
38
+ };
39
+ lynxView.nativeModulesMap = nativeModulesMap;
40
+ ```
41
+
42
+ In addition, we will use Promise.all to load `nativeModules`, which will optimize performance in the case of multiple modules.
43
+
44
+ - refractor: remove entryId concept ([#217](https://github.com/lynx-family/lynx-stack/pull/217))
45
+
46
+ After the PR #198
47
+ All contents are isolated by a shadowroot.
48
+ Therefore we don't need to add the entryId selector to avoid the lynx-view's style taking effect on the whole page.
49
+
50
+ ### Patch Changes
51
+
52
+ - refactor: code clean ([#266](https://github.com/lynx-family/lynx-stack/pull/266))
53
+
54
+ - refactor: clean the decodeOperations implementation ([#261](https://github.com/lynx-family/lynx-stack/pull/261))
55
+
56
+ - fix: When the width and height of lynx-view are not auto, the width and height of the `lynx-tag="page"` need to be correctly set to 100%. ([#228](https://github.com/lynx-family/lynx-stack/pull/228))
57
+
58
+ - refactor: remove customelement defined detecting logic ([#247](https://github.com/lynx-family/lynx-stack/pull/247))
59
+
60
+ Before this commit, for those element with tag without `-`, we always try to detect if the `x-${tagName}` is defined.
61
+
62
+ After this commit, we pre-define a map(could be override by the `overrideLynxTagToHTMLTagMap`) to make that transformation for tag name.
63
+
64
+ This change is a path to SSR and the MTS support.
65
+
66
+ - fix: 'error' event for main-thread \_reportError ([#283](https://github.com/lynx-family/lynx-stack/pull/283))
67
+
68
+ - Updated dependencies [[`5b5e090`](https://github.com/lynx-family/lynx-stack/commit/5b5e090fdf0e896f1c38a49bf3ed9889117c4fb8), [`b844e75`](https://github.com/lynx-family/lynx-stack/commit/b844e751f566d924256365d37aec4c86c520ec00), [`53230f0`](https://github.com/lynx-family/lynx-stack/commit/53230f012216f3a627853e11d544e4be175c5b9b), [`6f16827`](https://github.com/lynx-family/lynx-stack/commit/6f16827d1f4d7364870d354fc805a8868c110f1e), [`d2d55ef`](https://github.com/lynx-family/lynx-stack/commit/d2d55ef9fe438c35921d9db0daa40d5228822ecc)]:
69
+ - @lynx-js/web-worker-runtime@0.9.0
70
+ - @lynx-js/web-constants@0.9.0
71
+ - @lynx-js/web-worker-rpc@0.9.0
72
+
3
73
  ## 0.8.0
4
74
 
5
75
  ### Minor Changes
@@ -1,4 +1,4 @@
1
- import { type Cloneable, type NapiModulesCall, type NapiModulesMap, type NativeModulesCall, type UpdateDataType } from '@lynx-js/web-constants';
1
+ import { type Cloneable, type NapiModulesCall, type NapiModulesMap, type NativeModulesCall, type NativeModulesMap, type UpdateDataType } from '@lynx-js/web-constants';
2
2
  /**
3
3
  * Based on our experiences, these elements are almost used in all lynx cards.
4
4
  */
@@ -7,16 +7,14 @@ import { type Cloneable, type NapiModulesCall, type NapiModulesMap, type NativeM
7
7
  * @param {Cloneable} globalProps [optional] The globalProps value of this Lynx card
8
8
  * @param {Cloneable} initData [oprional] The initial data of this Lynx card
9
9
  * @param {Record<string,string>} overrideLynxTagToHTMLTagMap [optional] use this property/attribute to override the lynx tag -> html tag map
10
- * @param {string} nativeModulesUrl [optional] It is a esm url, use to customize NativeModules.
11
- * @param {INativeModulesCall} onNativeModulesCall [optional] the NativeModules value handler. Arguments will be cached before this property is assigned.
10
+ * @param {NativeModulesMap} nativeModulesMap [optional] use to customize NativeModules. key is module-name, value is esm url.
11
+ * @param {NativeModulesCall} onNativeModulesCall [optional] the NativeModules value handler. Arguments will be cached before this property is assigned.
12
12
  * @param {"auto" | null} height [optional] set it to "auto" for height auto-sizing
13
13
  * @param {"auto" | null} width [optional] set it to "auto" for width auto-sizing
14
14
  * @param {NapiModulesMap} napiModulesMap [optional] the napiModule which is called in lynx-core. key is module-name, value is esm url.
15
15
  * @param {NapiModulesCall} onNapiModulesCall [optional] the NapiModule value handler.
16
16
  * @param {"false" | "true" | null} injectHeadLinks [optional] @default true set it to "false" to disable injecting the <link href="" ref="stylesheet"> styles into shadowroot
17
17
  *
18
- * @property entryId the currently Lynx view entryId.
19
- *
20
18
  * @event error lynx card fired an error
21
19
  *
22
20
  * @example
@@ -65,13 +63,6 @@ export declare class LynxView extends HTMLElement {
65
63
  */
66
64
  get initData(): Cloneable;
67
65
  set initData(val: string | Cloneable);
68
- /**
69
- * @public
70
- * @readonly
71
- * @property
72
- * The random generated entryId of current lynxview
73
- */
74
- get entryId(): string | undefined;
75
66
  /**
76
67
  * @public
77
68
  * @property
@@ -87,13 +78,15 @@ export declare class LynxView extends HTMLElement {
87
78
  set onNativeModulesCall(handler: NativeModulesCall);
88
79
  /**
89
80
  * @public
90
- * @property nativeModules
81
+ * @property nativeModulesMap
82
+ * @default {}
91
83
  */
92
- get nativeModulesUrl(): string | undefined;
93
- set nativeModulesUrl(val: string);
84
+ get nativeModulesMap(): NativeModulesMap | undefined;
85
+ set nativeModulesMap(map: NativeModulesMap);
94
86
  /**
95
87
  * @param
96
- * @property
88
+ * @property napiModulesMap
89
+ * @default {}
97
90
  */
98
91
  get napiModulesMap(): NapiModulesMap | undefined;
99
92
  set napiModulesMap(map: NapiModulesMap);
@@ -2,7 +2,7 @@
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
4
  import { createLynxView, } from './createLynxView.js';
5
- import { cardIdAttribute, lynxViewEntryIdPrefix, lynxViewRootDomId, } from '@lynx-js/web-constants';
5
+ import { lynxViewRootDomId, } from '@lynx-js/web-constants';
6
6
  import { inShadowRootStyles } from './inShadowRootStyles.js';
7
7
  /**
8
8
  * Based on our experiences, these elements are almost used in all lynx cards.
@@ -12,16 +12,14 @@ import { inShadowRootStyles } from './inShadowRootStyles.js';
12
12
  * @param {Cloneable} globalProps [optional] The globalProps value of this Lynx card
13
13
  * @param {Cloneable} initData [oprional] The initial data of this Lynx card
14
14
  * @param {Record<string,string>} overrideLynxTagToHTMLTagMap [optional] use this property/attribute to override the lynx tag -> html tag map
15
- * @param {string} nativeModulesUrl [optional] It is a esm url, use to customize NativeModules.
16
- * @param {INativeModulesCall} onNativeModulesCall [optional] the NativeModules value handler. Arguments will be cached before this property is assigned.
15
+ * @param {NativeModulesMap} nativeModulesMap [optional] use to customize NativeModules. key is module-name, value is esm url.
16
+ * @param {NativeModulesCall} onNativeModulesCall [optional] the NativeModules value handler. Arguments will be cached before this property is assigned.
17
17
  * @param {"auto" | null} height [optional] set it to "auto" for height auto-sizing
18
18
  * @param {"auto" | null} width [optional] set it to "auto" for width auto-sizing
19
19
  * @param {NapiModulesMap} napiModulesMap [optional] the napiModule which is called in lynx-core. key is module-name, value is esm url.
20
20
  * @param {NapiModulesCall} onNapiModulesCall [optional] the NapiModule value handler.
21
21
  * @param {"false" | "true" | null} injectHeadLinks [optional] @default true set it to "false" to disable injecting the <link href="" ref="stylesheet"> styles into shadowroot
22
22
  *
23
- * @property entryId the currently Lynx view entryId.
24
- *
25
23
  * @event error lynx card fired an error
26
24
  *
27
25
  * @example
@@ -48,7 +46,7 @@ export class LynxView extends HTMLElement {
48
46
  'globalProps',
49
47
  'initData',
50
48
  'overrideLynxTagToHTMLTagMap',
51
- 'nativeModulesUrl',
49
+ 'nativeModulesMap',
52
50
  ];
53
51
  static attributeCamelCaseMap = Object.fromEntries(this.observedAttributeAsProperties.map((nm) => [nm.toLocaleLowerCase(), nm]));
54
52
  /**
@@ -102,16 +100,6 @@ export class LynxView extends HTMLElement {
102
100
  this.#initData = val;
103
101
  }
104
102
  }
105
- #entryId;
106
- /**
107
- * @public
108
- * @readonly
109
- * @property
110
- * The random generated entryId of current lynxview
111
- */
112
- get entryId() {
113
- return this.#entryId;
114
- }
115
103
  #overrideLynxTagToHTMLTagMap = { 'page': 'div' };
116
104
  /**
117
105
  * @public
@@ -146,21 +134,23 @@ export class LynxView extends HTMLElement {
146
134
  }
147
135
  }
148
136
  }
149
- #nativeModulesUrl;
137
+ #nativeModulesMap = {};
150
138
  /**
151
139
  * @public
152
- * @property nativeModules
140
+ * @property nativeModulesMap
141
+ * @default {}
153
142
  */
154
- get nativeModulesUrl() {
155
- return this.#nativeModulesUrl;
143
+ get nativeModulesMap() {
144
+ return this.#nativeModulesMap;
156
145
  }
157
- set nativeModulesUrl(val) {
158
- this.#nativeModulesUrl = val;
146
+ set nativeModulesMap(map) {
147
+ this.#nativeModulesMap = map;
159
148
  }
160
149
  #napiModulesMap = {};
161
150
  /**
162
151
  * @param
163
- * @property
152
+ * @property napiModulesMap
153
+ * @default {}
164
154
  */
165
155
  get napiModulesMap() {
166
156
  return this.#napiModulesMap;
@@ -329,22 +319,23 @@ export class LynxView extends HTMLElement {
329
319
  if (this.#url) {
330
320
  const rootDom = document.createElement('div');
331
321
  rootDom.id = lynxViewRootDomId;
332
- const entryId = `${lynxViewEntryIdPrefix}-${LynxView
333
- .lynxViewCount++}`;
334
- this.#entryId = entryId;
335
- rootDom.setAttribute(cardIdAttribute, entryId);
336
322
  rootDom.setAttribute('part', lynxViewRootDomId);
337
- const commonEventDetail = {
338
- entryId,
323
+ const tagMap = {
324
+ 'page': 'div',
325
+ 'view': 'x-view',
326
+ 'text': 'x-text',
327
+ 'image': 'x-image',
328
+ 'list': 'x-list',
329
+ 'svg': 'x-svg',
330
+ ...this.overrideLynxTagToHTMLTagMap,
339
331
  };
340
332
  const lynxView = createLynxView({
341
- entryId,
333
+ tagMap,
342
334
  rootDom,
343
335
  templateUrl: this.#url,
344
336
  globalProps: this.#globalProps,
345
337
  initData: this.#initData,
346
- overrideLynxTagToHTMLTagMap: this.#overrideLynxTagToHTMLTagMap,
347
- nativeModulesUrl: this.#nativeModulesUrl,
338
+ nativeModulesMap: this.#nativeModulesMap,
348
339
  napiModulesMap: this.#napiModulesMap,
349
340
  callbacks: {
350
341
  nativeModulesCall: (...args) => {
@@ -362,9 +353,7 @@ export class LynxView extends HTMLElement {
362
353
  return this.#onNapiModulesCall?.(...args);
363
354
  },
364
355
  onError: () => {
365
- this.dispatchEvent(new CustomEvent('error', {
366
- detail: commonEventDetail,
367
- }));
356
+ this.dispatchEvent(new CustomEvent('error', {}));
368
357
  },
369
358
  },
370
359
  });
@@ -1,19 +1,19 @@
1
- import type { Cloneable, NapiModulesMap, UpdateDataType } from '@lynx-js/web-constants';
1
+ import type { Cloneable, NapiModulesMap, NativeModulesMap, sendGlobalEventEndpoint, UpdateDataType } from '@lynx-js/web-constants';
2
2
  import { startUIThread } from '../uiThread/startUIThread.js';
3
+ import type { RpcCallType } from '@lynx-js/web-worker-rpc';
3
4
  export interface LynxViewConfigs {
4
5
  templateUrl: string;
5
6
  initData: Cloneable;
6
7
  globalProps: Cloneable;
7
- entryId: string;
8
8
  rootDom: HTMLElement;
9
9
  callbacks: Parameters<typeof startUIThread>[3];
10
- overrideLynxTagToHTMLTagMap?: Record<string, string>;
11
- nativeModulesUrl: string | undefined;
10
+ nativeModulesMap: NativeModulesMap;
12
11
  napiModulesMap: NapiModulesMap;
12
+ tagMap: Record<string, string>;
13
13
  }
14
14
  export interface LynxView {
15
15
  updateData(data: Cloneable, updateDataType: UpdateDataType, callback?: () => void): void;
16
16
  dispose(): Promise<void>;
17
- sendGlobalEvent(name: string, params?: Cloneable[]): void;
17
+ sendGlobalEvent: RpcCallType<typeof sendGlobalEventEndpoint>;
18
18
  }
19
19
  export declare function createLynxView(configs: LynxViewConfigs): LynxView;
@@ -3,13 +3,14 @@
3
3
  // LICENSE file in the root directory of this source tree.
4
4
  import { startUIThread } from '../uiThread/startUIThread.js';
5
5
  export function createLynxView(configs) {
6
- const { rootDom, callbacks, templateUrl, globalProps, entryId, initData, overrideLynxTagToHTMLTagMap, nativeModulesUrl, napiModulesMap, } = configs;
6
+ const { rootDom, callbacks, templateUrl, globalProps, initData, nativeModulesMap, napiModulesMap, tagMap, } = configs;
7
7
  return startUIThread(templateUrl, {
8
+ tagMap,
8
9
  initData,
9
10
  globalProps,
10
- entryId,
11
+ nativeModulesMap,
11
12
  napiModulesMap,
12
13
  browserConfig: {},
13
- }, rootDom, callbacks, overrideLynxTagToHTMLTagMap, nativeModulesUrl);
14
+ }, rootDom, callbacks);
14
15
  }
15
16
  //# sourceMappingURL=createLynxView.js.map
@@ -3,10 +3,8 @@ import type { Rpc } from '@lynx-js/web-worker-rpc';
3
3
  import type { RuntimePropertyOnElement } from '../../types/RuntimePropertyOnElement.js';
4
4
  export declare function registerFlushElementTreeHandler(mainThreadRpc: Rpc, endpoint: typeof flushElementTreeEndpoint, options: {
5
5
  pageConfig: PageConfig;
6
- overrideTagMap: Record<string, string>;
7
6
  backgroundRpc: Rpc;
8
7
  rootDom: HTMLElement;
9
- entryId: string;
10
8
  }, onCommit: (info: {
11
9
  pipelineId: string | undefined;
12
10
  timingFlags: string[];
@@ -1,18 +1,16 @@
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 { cardIdAttribute, componentIdAttribute, lynxDefaultDisplayLinearAttribute, lynxRuntimeValue, lynxTagAttribute, lynxUniqueIdAttribute, parentComponentUniqueIdAttribute, postMainThreadEvent, publicComponentEventEndpoint, publishEventEndpoint, } from '@lynx-js/web-constants';
4
+ import { componentIdAttribute, lynxDefaultDisplayLinearAttribute, lynxRuntimeValue, lynxTagAttribute, lynxUniqueIdAttribute, parentComponentUniqueIdAttribute, postMainThreadEvent, publicComponentEventEndpoint, publishEventEndpoint, } from '@lynx-js/web-constants';
5
5
  import { decodeElementOperation } from '../decodeElementOperation.js';
6
- import { getElementTag } from '../getElementTag.js';
7
6
  import { createCrossThreadEvent } from '../../utils/createCrossThreadEvent.js';
8
- function applyPageAttributes(page, pageConfig, entryId) {
9
- page.setAttribute(cardIdAttribute, entryId);
7
+ function applyPageAttributes(page, pageConfig) {
10
8
  if (pageConfig.defaultDisplayLinear === false) {
11
9
  page.setAttribute(lynxDefaultDisplayLinearAttribute, 'false');
12
10
  }
13
11
  }
14
12
  export function registerFlushElementTreeHandler(mainThreadRpc, endpoint, options, onCommit, markTimingInternal) {
15
- const { pageConfig, overrideTagMap, backgroundRpc, rootDom, entryId, } = options;
13
+ const { pageConfig, backgroundRpc, rootDom, } = options;
16
14
  const uniqueIdToElement = [];
17
15
  const uniqueIdToCssInJsRule = [];
18
16
  const rootStyleElementForCssInJs = document.createElement('style');
@@ -20,8 +18,7 @@ export function registerFlushElementTreeHandler(mainThreadRpc, endpoint, options
20
18
  rootDom.append(rootStyleElementForCssInJs);
21
19
  }
22
20
  const createElementImpl = (tag) => {
23
- const htmlTag = getElementTag(tag, overrideTagMap);
24
- const element = document.createElement(htmlTag);
21
+ const element = document.createElement(tag);
25
22
  element[lynxRuntimeValue] = {
26
23
  dataset: {},
27
24
  eventHandler: {},
@@ -61,15 +58,13 @@ export function registerFlushElementTreeHandler(mainThreadRpc, endpoint, options
61
58
  ]);
62
59
  }
63
60
  };
64
- mainThreadRpc.registerHandler(endpoint, (operations, options, cardCss) => {
61
+ mainThreadRpc.registerHandler(endpoint, (operations, options, cardCss, timingFlags) => {
65
62
  const { pipelineOptions } = options;
66
63
  const pipelineId = pipelineOptions?.pipelineID;
67
- const timingFlags = [];
68
64
  markTimingInternal('dispatch_start', pipelineId);
69
65
  markTimingInternal('layout_start', pipelineId);
70
66
  markTimingInternal('ui_operation_flush_start', pipelineId);
71
67
  const page = decodeElementOperation(operations, {
72
- timingFlags,
73
68
  uniqueIdToElement,
74
69
  uniqueIdToCssInJsRule,
75
70
  createElementImpl,
@@ -87,7 +82,7 @@ export function registerFlushElementTreeHandler(mainThreadRpc, endpoint, options
87
82
  styleElement.innerHTML = cardCss;
88
83
  rootDom.append(styleElement);
89
84
  rootDom.append(page);
90
- applyPageAttributes(page, pageConfig, entryId);
85
+ applyPageAttributes(page, pageConfig);
91
86
  }
92
87
  markTimingInternal('layout_end', pipelineId);
93
88
  markTimingInternal('dispatch_end', pipelineId);
@@ -1,7 +1,6 @@
1
1
  import type { ElementOperation } from '@lynx-js/web-constants';
2
2
  import type { RuntimePropertyOnElement } from '../types/RuntimePropertyOnElement.js';
3
3
  export declare function decodeElementOperation<T extends HTMLElement & RuntimePropertyOnElement>(operations: ElementOperation[], options: {
4
- timingFlags: string[];
5
4
  uniqueIdToElement: (WeakRef<T> | undefined)[];
6
5
  uniqueIdToCssInJsRule: (WeakRef<CSSStyleRule> | undefined)[];
7
6
  createElementImpl: (tag: string) => T;
@@ -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 { cssIdAttribute, lynxTagAttribute, lynxUniqueIdAttribute, OperationType, lynxRuntimeValue, LynxEventNameToW3cByTagName, LynxEventNameToW3cCommon, W3cEventNameToLynx, __lynx_timing_flag, } from '@lynx-js/web-constants';
4
+ import { cssIdAttribute, lynxUniqueIdAttribute, OperationType, lynxRuntimeValue, LynxEventNameToW3cByTagName, LynxEventNameToW3cCommon, W3cEventNameToLynx, __lynx_timing_flag, lynxTagAttribute, } from '@lynx-js/web-constants';
5
5
  function getElement(uniqueId, uniqueIdToElement) {
6
6
  const element = uniqueIdToElement[uniqueId]?.deref();
7
7
  if (element) {
@@ -18,7 +18,6 @@ function createElement(tag, uniqueId, uniqueIdToElement, createElementImpl) {
18
18
  }
19
19
  const element = createElementImpl(tag);
20
20
  element.setAttribute(lynxUniqueIdAttribute, uniqueId.toString());
21
- element.setAttribute(lynxTagAttribute, tag);
22
21
  uniqueIdToElement[uniqueId] = new WeakRef(element);
23
22
  return element;
24
23
  }
@@ -39,7 +38,7 @@ function handleHtmlEvent(event) {
39
38
  }
40
39
  }
41
40
  export function decodeElementOperation(operations, options) {
42
- const { uniqueIdToElement, uniqueIdToCssInJsRule, createElementImpl, createStyleRuleImpl, eventHandler, timingFlags, } = options;
41
+ const { uniqueIdToElement, uniqueIdToCssInJsRule, createElementImpl, createStyleRuleImpl, eventHandler, } = options;
43
42
  let pageElement;
44
43
  for (const op of operations) {
45
44
  if (op.type === OperationType.Create) {
@@ -47,8 +46,6 @@ export function decodeElementOperation(operations, options) {
47
46
  if (typeof op.cssId === 'number') {
48
47
  element.setAttribute(cssIdAttribute, op.cssId.toString());
49
48
  }
50
- if (op.tag === 'page')
51
- pageElement = element;
52
49
  }
53
50
  else {
54
51
  const target = getElement(op.uid, uniqueIdToElement);
@@ -87,8 +84,8 @@ export function decodeElementOperation(operations, options) {
87
84
  }
88
85
  else {
89
86
  target.setAttribute(op.key, op.value);
90
- if (op.value && op.key === __lynx_timing_flag) {
91
- timingFlags.push(op.value);
87
+ if (op.key === lynxTagAttribute && op.value === 'page') {
88
+ pageElement = target;
92
89
  }
93
90
  }
94
91
  }
@@ -4,4 +4,4 @@ export declare function startUIThread(templateUrl: string, configs: Omit<MainThr
4
4
  nativeModulesCall: NativeModulesCall;
5
5
  napiModulesCall: NapiModulesCall;
6
6
  onError?: () => void;
7
- }, overrideTagMap: Record<string, string> | undefined, nativeModulesUrl: string | undefined): LynxView;
7
+ }): LynxView;
@@ -16,9 +16,9 @@ import { flushElementTreeEndpoint, mainThreadChunkReadyEndpoint, mainThreadStart
16
16
  import { loadTemplate } from '../utils/loadTemplate.js';
17
17
  import { createUpdateData } from './crossThreadHandlers/createUpdateData.js';
18
18
  import { registerNapiModulesCallHandler } from './crossThreadHandlers/registerNapiModulesCallHandler.js';
19
- export function startUIThread(templateUrl, configs, rootDom, callbacks, overrideTagMap = {}, nativeModulesUrl) {
19
+ export function startUIThread(templateUrl, configs, rootDom, callbacks) {
20
20
  const createLynxStartTiming = performance.now() + performance.timeOrigin;
21
- const { entryId, napiModulesMap } = configs;
21
+ const { nativeModulesMap, napiModulesMap } = configs;
22
22
  const { mainThreadRpc, backgroundRpc, terminateWorkers, } = bootWorkers();
23
23
  const sendGlobalEvent = backgroundRpc.createCall(sendGlobalEventEndpoint);
24
24
  const uiThreadFpReady = backgroundRpc.createCall(uiThreadFpReadyEndpoint);
@@ -31,7 +31,7 @@ export function startUIThread(templateUrl, configs, rootDom, callbacks, override
31
31
  mainThreadStart({
32
32
  ...configs,
33
33
  template,
34
- nativeModulesUrl,
34
+ nativeModulesMap,
35
35
  napiModulesMap,
36
36
  });
37
37
  });
@@ -40,10 +40,8 @@ export function startUIThread(templateUrl, configs, rootDom, callbacks, override
40
40
  const { pageConfig } = mainChunkInfo;
41
41
  registerFlushElementTreeHandler(mainThreadRpc, flushElementTreeEndpoint, {
42
42
  pageConfig,
43
- overrideTagMap,
44
43
  backgroundRpc,
45
44
  rootDom,
46
- entryId,
47
45
  }, (info) => {
48
46
  const { pipelineId, timingFlags, isFP } = info;
49
47
  if (isFP) {
@@ -29,6 +29,7 @@ function generateJavascriptUrl(obj, injectVars, injectWithBind, muteableVars) {
29
29
  const mainThreadInjectVars = [
30
30
  'lynx',
31
31
  'globalThis',
32
+ '_ReportError',
32
33
  '__AddConfig',
33
34
  '__AddDataset',
34
35
  '__GetAttributes',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-core",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -24,13 +24,13 @@
24
24
  "**/*.css"
25
25
  ],
26
26
  "dependencies": {
27
- "@lynx-js/web-constants": "0.8.0",
28
- "@lynx-js/web-worker-rpc": "0.8.0",
29
- "@lynx-js/web-worker-runtime": "0.8.0"
27
+ "@lynx-js/web-constants": "0.9.0",
28
+ "@lynx-js/web-worker-rpc": "0.9.0",
29
+ "@lynx-js/web-worker-runtime": "0.9.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@lynx-js/lynx-core": "0.1.0",
33
- "@lynx-js/web-elements": "0.4.0"
33
+ "@lynx-js/web-elements": "0.5.0"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@lynx-js/lynx-core": "0.1.0",
@@ -1 +0,0 @@
1
- export declare function getElementTag(tag: string, tagMap: Record<string, string>, currentLoadingTags?: Promise<any>[]): string;
@@ -1,20 +0,0 @@
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 function getElementTag(tag, tagMap, currentLoadingTags) {
5
- if (tagMap[tag]) {
6
- return tagMap[tag];
7
- }
8
- if (customElements.get(tag)) {
9
- tagMap[tag] = tag;
10
- return tag;
11
- }
12
- const normizedTag = tag.includes('-') ? tag : `x-${tag}`;
13
- if (customElements.get(normizedTag)) {
14
- tagMap[tag] = normizedTag;
15
- return normizedTag;
16
- }
17
- currentLoadingTags?.push(customElements.whenDefined(normizedTag));
18
- return normizedTag;
19
- }
20
- //# sourceMappingURL=getElementTag.js.map