@lynx-js/web-core 0.11.0 → 0.12.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,53 @@
1
1
  # @lynx-js/web-core
2
2
 
3
+ ## 0.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - feat: improve compatibility for chrome 108 & support linear-gradient for nested x-text ([#590](https://github.com/lynx-family/lynx-stack/pull/590))
8
+
9
+ **This is a breaking change**
10
+
11
+ - Please upgrade your `@lynx-js/web-elements` to >=0.6.0
12
+ - Please upgrade your `@lynx-js/web-core` to >=0.12.0
13
+ - The compiled lynx template json won't be impacted.
14
+
15
+ On chrome 108, the `-webkit-background-clip:text` cannot be computed by a `var(--css-var-value-text)`
16
+
17
+ Therefore we move the logic into style transformation logic.
18
+
19
+ Now the following status is supported
20
+
21
+ ```
22
+ <text style="color:linear-gradient()">
23
+ <text>
24
+ <text>
25
+ </text>
26
+ ```
27
+
28
+ ### Patch Changes
29
+
30
+ - feat: allow user to implement custom template load function ([#587](https://github.com/lynx-family/lynx-stack/pull/587))
31
+
32
+ ```js
33
+ lynxView.customTemplateLoader = (url) => {
34
+ return (await (await fetch(url, {
35
+ method: 'GET',
36
+ })).json());
37
+ };
38
+ ```
39
+
40
+ - feat: support mts event with target methods ([#564](https://github.com/lynx-family/lynx-stack/pull/564))
41
+
42
+ After this commit, developers are allowed to invoke `event.target.setStyleProperty` in mts handler
43
+
44
+ - fix: crash on removing a id attribute ([#582](https://github.com/lynx-family/lynx-stack/pull/582))
45
+
46
+ - Updated dependencies [[`f1ca29b`](https://github.com/lynx-family/lynx-stack/commit/f1ca29bd766377dd46583f15e1e75bca447699cd)]:
47
+ - @lynx-js/web-worker-runtime@0.12.0
48
+ - @lynx-js/web-constants@0.12.0
49
+ - @lynx-js/web-worker-rpc@0.12.0
50
+
3
51
  ## 0.11.0
4
52
 
5
53
  ### Minor Changes
@@ -1,4 +1,4 @@
1
- import { type Cloneable, type NapiModulesCall, type NapiModulesMap, type NativeModulesCall, type NativeModulesMap, type UpdateDataType } from '@lynx-js/web-constants';
1
+ import { type Cloneable, type LynxTemplate, type NapiModulesCall, type NapiModulesMap, type NativeModulesCall, type NativeModulesMap, type UpdateDataType } 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[];
@@ -22,6 +22,7 @@ export type INapiModulesCall = (name: string, data: any, moduleName: string, lyn
22
22
  * @property {INapiModulesCall} onNapiModulesCall [optional] the NapiModule value handler.
23
23
  * @property {"false" | "true" | null} injectHeadLinks [optional] @default true set it to "false" to disable injecting the <link href="" ref="stylesheet"> styles into shadowroot
24
24
  * @property {number} lynxGroupId [optional] (attribute: "lynx-group-id") the background shared context id, which is used to share webworker between different lynx cards
25
+ * @property {(string)=>Promise<LynxTemplate>} customTemplateLoader [optional] the custom template loader, which is used to load the template
25
26
  *
26
27
  * @event error lynx card fired an error
27
28
  *
@@ -142,6 +143,12 @@ export declare class LynxView extends HTMLElement {
142
143
  * @private
143
144
  */
144
145
  disconnectedCallback(): void;
146
+ /**
147
+ * @public
148
+ * allow user to customize the template loader
149
+ * @param url the url of the template
150
+ */
151
+ customTemplateLoader?: (url: string) => Promise<LynxTemplate>;
145
152
  /**
146
153
  * @private
147
154
  */
@@ -20,6 +20,7 @@ import { inShadowRootStyles } from './inShadowRootStyles.js';
20
20
  * @property {INapiModulesCall} onNapiModulesCall [optional] the NapiModule value handler.
21
21
  * @property {"false" | "true" | null} injectHeadLinks [optional] @default true set it to "false" to disable injecting the <link href="" ref="stylesheet"> styles into shadowroot
22
22
  * @property {number} lynxGroupId [optional] (attribute: "lynx-group-id") the background shared context id, which is used to share webworker between different lynx cards
23
+ * @property {(string)=>Promise<LynxTemplate>} customTemplateLoader [optional] the custom template loader, which is used to load the template
23
24
  *
24
25
  * @event error lynx card fired an error
25
26
  *
@@ -252,6 +253,12 @@ export class LynxView extends HTMLElement {
252
253
  this.shadowRoot.innerHTML = '';
253
254
  }
254
255
  }
256
+ /**
257
+ * @public
258
+ * allow user to customize the template loader
259
+ * @param url the url of the template
260
+ */
261
+ customTemplateLoader;
255
262
  /**
256
263
  * @private the flag to group all changes into one render operation
257
264
  */
@@ -308,6 +315,7 @@ export class LynxView extends HTMLElement {
308
315
  onError: () => {
309
316
  this.dispatchEvent(new CustomEvent('error', {}));
310
317
  },
318
+ customTemplateLoader: this.customTemplateLoader,
311
319
  },
312
320
  });
313
321
  this.#instance = lynxView;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { createLynxView } from './apis/createLynxView.js';
2
2
  export { LynxView } from './apis/LynxView.js';
3
+ export type { LynxTemplate } from '@lynx-js/web-constants';
@@ -1,7 +1,8 @@
1
1
  import type { LynxView } from '../apis/createLynxView.js';
2
- import { type MainThreadStartConfigs, type NapiModulesCall, type NativeModulesCall } from '@lynx-js/web-constants';
2
+ import { type LynxTemplate, type MainThreadStartConfigs, type NapiModulesCall, type NativeModulesCall } from '@lynx-js/web-constants';
3
3
  export declare function startUIThread(templateUrl: string, configs: Omit<MainThreadStartConfigs, 'template'>, shadowRoot: ShadowRoot, lynxGroupId: number | undefined, callbacks: {
4
4
  nativeModulesCall: NativeModulesCall;
5
5
  napiModulesCall: NapiModulesCall;
6
6
  onError?: () => void;
7
+ customTemplateLoader?: (url: string) => Promise<LynxTemplate>;
7
8
  }): LynxView;
@@ -17,7 +17,6 @@ import { registerNapiModulesCallHandler } from './crossThreadHandlers/registerNa
17
17
  import { registerDispatchLynxViewEventHandler } from './crossThreadHandlers/registerDispatchLynxViewEventHandler.js';
18
18
  export function startUIThread(templateUrl, configs, shadowRoot, lynxGroupId, callbacks) {
19
19
  const createLynxStartTiming = performance.now() + performance.timeOrigin;
20
- const { nativeModulesMap, napiModulesMap } = configs;
21
20
  const { mainThreadRpc, backgroundRpc, terminateWorkers, } = bootWorkers(lynxGroupId);
22
21
  const sendGlobalEvent = backgroundRpc.createCall(sendGlobalEventEndpoint);
23
22
  const mainThreadStart = mainThreadRpc.createCall(mainThreadStartEndpoint);
@@ -29,13 +28,11 @@ export function startUIThread(templateUrl, configs, shadowRoot, lynxGroupId, cal
29
28
  };
30
29
  markTimingInternal('create_lynx_start', undefined, createLynxStartTiming);
31
30
  markTimingInternal('load_template_start');
32
- loadTemplate(templateUrl).then((template) => {
31
+ loadTemplate(templateUrl, callbacks.customTemplateLoader).then((template) => {
33
32
  markTimingInternal('load_template_end');
34
33
  mainThreadStart({
35
34
  ...configs,
36
35
  template,
37
- nativeModulesMap,
38
- napiModulesMap,
39
36
  });
40
37
  });
41
38
  registerReportErrorHandler(mainThreadRpc, callbacks.onError);
@@ -1,2 +1,2 @@
1
1
  import { type LynxTemplate } from '@lynx-js/web-constants';
2
- export declare function loadTemplate(url: string): Promise<LynxTemplate>;
2
+ export declare function loadTemplate(url: string, customTemplateLoader?: (url: string) => Promise<LynxTemplate>): Promise<LynxTemplate>;
@@ -93,13 +93,15 @@ const backgroundInjectWithBind = [
93
93
  'Card',
94
94
  'Component',
95
95
  ];
96
- export async function loadTemplate(url) {
96
+ export async function loadTemplate(url, customTemplateLoader) {
97
97
  const cachedTemplate = TemplateCache[url];
98
98
  if (cachedTemplate)
99
99
  return cachedTemplate;
100
- const template = (await (await fetch(url, {
101
- method: 'GET',
102
- })).json());
100
+ const template = customTemplateLoader
101
+ ? await customTemplateLoader(url)
102
+ : (await (await fetch(url, {
103
+ method: 'GET',
104
+ })).json());
103
105
  const decodedTemplate = {
104
106
  ...template,
105
107
  lepusCode: generateJavascriptUrl(template.lepusCode, mainThreadInjectVars, [], globalMuteableVars),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-core",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -25,16 +25,16 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "@lynx-js/offscreen-document": "0.0.0",
28
- "@lynx-js/web-constants": "0.11.0",
29
- "@lynx-js/web-worker-rpc": "0.11.0",
30
- "@lynx-js/web-worker-runtime": "0.11.0"
28
+ "@lynx-js/web-constants": "0.12.0",
29
+ "@lynx-js/web-worker-rpc": "0.12.0",
30
+ "@lynx-js/web-worker-runtime": "0.12.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@lynx-js/lynx-core": "0.1.2",
34
- "@lynx-js/web-elements": "0.5.4"
34
+ "@lynx-js/web-elements": "0.6.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@lynx-js/lynx-core": "0.1.2",
38
- "@lynx-js/web-elements": ">=0.3.1"
38
+ "@lynx-js/web-elements": ">=0.6.0"
39
39
  }
40
40
  }
@@ -1,4 +0,0 @@
1
- export interface LynxExposureModule {
2
- resumeExposure: () => void;
3
- stopExposure: () => void;
4
- }
@@ -1,5 +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 {};
5
- //# sourceMappingURL=LynxExposureModule.js.map