@lynx-js/web-core 0.13.3 → 0.13.4

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,22 @@
1
1
  # @lynx-js/web-core
2
2
 
3
+ ## 0.13.4
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: lynx-view supports `updateGlobalProps` method, which can be used to update lynx.\_\_globalProps ([#918](https://github.com/lynx-family/lynx-stack/pull/918))
8
+
9
+ - feat: supports `lynx.getElementById()` && `animate()`. ([#912](https://github.com/lynx-family/lynx-stack/pull/912))
10
+
11
+ After this commit, you can use `lynx.getElementById()` to get the element by id, and use `element.animate()` to animate the element.
12
+
13
+ - Updated dependencies [[`96d3133`](https://github.com/lynx-family/lynx-stack/commit/96d3133b149b61af01c5478f4dc7b0a071137d98), [`75e5b2f`](https://github.com/lynx-family/lynx-stack/commit/75e5b2ff16ecf5f7072a45cd130e653dee747461), [`569618d`](https://github.com/lynx-family/lynx-stack/commit/569618d8e2665f5c9e1672f7ee5900ec2a5179a2), [`f9f88d6`](https://github.com/lynx-family/lynx-stack/commit/f9f88d6fb9c42d3370a6622d9d799d671ffcf1a7)]:
14
+ - @lynx-js/web-mainthread-apis@0.13.4
15
+ - @lynx-js/offscreen-document@0.1.0
16
+ - @lynx-js/web-worker-runtime@0.13.4
17
+ - @lynx-js/web-constants@0.13.4
18
+ - @lynx-js/web-worker-rpc@0.13.4
19
+
3
20
  ## 0.13.3
4
21
 
5
22
  ### Patch Changes
@@ -29,7 +29,7 @@ export type INapiModulesCall = (name: string, data: any, moduleName: string, lyn
29
29
  * @event error lynx card fired an error
30
30
  *
31
31
  * @example
32
- * HTML Exmaple
32
+ * HTML Example
33
33
  *
34
34
  * Note that you should declarae the size of lynx-view
35
35
  *
@@ -41,7 +41,7 @@ export type INapiModulesCall = (name: string, data: any, moduleName: string, lyn
41
41
  * React 19 Example
42
42
  * ```jsx
43
43
  * <lynx-view url={myLynxCardUrl} rawData={{}} globalProps={{}} style={{height:'300px', width:'300px'}}>
44
- * </lynx-vew>
44
+ * </lynx-view>
45
45
  * ```
46
46
  */
47
47
  export declare class LynxView extends HTMLElement {
@@ -118,6 +118,12 @@ export declare class LynxView extends HTMLElement {
118
118
  * update the `__initData` and trigger essential flow
119
119
  */
120
120
  updateData(data: Cloneable, updateDataType: UpdateDataType, callback?: () => void): void;
121
+ /**
122
+ * @public
123
+ * @method
124
+ * update the `__globalProps`
125
+ */
126
+ updateGlobalProps(data: Cloneable): void;
121
127
  /**
122
128
  * @public
123
129
  * @method
@@ -26,7 +26,7 @@ import { inShadowRootStyles, } from '@lynx-js/web-constants';
26
26
  * @event error lynx card fired an error
27
27
  *
28
28
  * @example
29
- * HTML Exmaple
29
+ * HTML Example
30
30
  *
31
31
  * Note that you should declarae the size of lynx-view
32
32
  *
@@ -38,7 +38,7 @@ import { inShadowRootStyles, } from '@lynx-js/web-constants';
38
38
  * React 19 Example
39
39
  * ```jsx
40
40
  * <lynx-view url={myLynxCardUrl} rawData={{}} globalProps={{}} style={{height:'300px', width:'300px'}}>
41
- * </lynx-vew>
41
+ * </lynx-view>
42
42
  * ```
43
43
  */
44
44
  export class LynxView extends HTMLElement {
@@ -196,6 +196,14 @@ export class LynxView extends HTMLElement {
196
196
  updateData(data, updateDataType, callback) {
197
197
  this.#instance?.updateData(data, updateDataType, callback);
198
198
  }
199
+ /**
200
+ * @public
201
+ * @method
202
+ * update the `__globalProps`
203
+ */
204
+ updateGlobalProps(data) {
205
+ this.#instance?.updateGlobalProps(data);
206
+ }
199
207
  /**
200
208
  * @public
201
209
  * @method
@@ -17,5 +17,6 @@ export interface LynxView {
17
17
  updateData(data: Cloneable, updateDataType: UpdateDataType, callback?: () => void): void;
18
18
  dispose(): Promise<void>;
19
19
  sendGlobalEvent: RpcCallType<typeof sendGlobalEventEndpoint>;
20
+ updateGlobalProps: (data: Cloneable) => void;
20
21
  }
21
22
  export declare function createLynxView(configs: LynxViewConfigs): LynxView;
@@ -40,7 +40,7 @@ export function registerInvokeUIMethodHandler(rpc, shadowRoot) {
40
40
  }
41
41
  }
42
42
  catch (e) {
43
- console.error(`[lynx-web] invokeUIMethod: apply method faild with`, e, element);
43
+ console.error(`[lynx-web] invokeUIMethod: apply method failed with`, e, element);
44
44
  code = ErrorCode.PARAM_INVALID;
45
45
  }
46
46
  }, (error) => {
@@ -0,0 +1,2 @@
1
+ import type { Rpc } from '@lynx-js/web-worker-rpc';
2
+ export declare function registerTriggerElementMethodEndpointHandler(rpc: Rpc, shadowRoot: ShadowRoot): void;
@@ -0,0 +1,32 @@
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
+ import {
5
+ // componentIdAttribute,
6
+ triggerElementMethodEndpoint, } from '@lynx-js/web-constants';
7
+ import { AnimationOperation, } from '@lynx-js/web-constants';
8
+ export function registerTriggerElementMethodEndpointHandler(rpc, shadowRoot) {
9
+ const animationMap = new Map();
10
+ rpc.registerHandler(triggerElementMethodEndpoint, (method, id, options) => {
11
+ if (method === 'animate') {
12
+ switch (options.operation) {
13
+ case AnimationOperation.START:
14
+ animationMap.set(options.id, shadowRoot.querySelector(id)?.animate(options.keyframes, options.timingOptions));
15
+ break;
16
+ case AnimationOperation.PLAY:
17
+ animationMap.get(options.id)?.play();
18
+ break;
19
+ case AnimationOperation.PAUSE:
20
+ animationMap.get(options.id)?.pause();
21
+ break;
22
+ case AnimationOperation.CANCEL:
23
+ animationMap.get(options.id)?.cancel();
24
+ break;
25
+ case AnimationOperation.FINISH:
26
+ animationMap.get(options.id)?.finish();
27
+ break;
28
+ }
29
+ }
30
+ });
31
+ }
32
+ //# sourceMappingURL=registerTriggerElementMethodEndpointHandler.js.map
@@ -6,6 +6,7 @@ import { registerTriggerComponentEventHandler } from './crossThreadHandlers/regi
6
6
  import { registerSelectComponentHandler } from './crossThreadHandlers/registerSelectComponentHandler.js';
7
7
  import { registerNapiModulesCallHandler } from './crossThreadHandlers/registerNapiModulesCallHandler.js';
8
8
  import { registerDispatchLynxViewEventHandler } from './crossThreadHandlers/registerDispatchLynxViewEventHandler.js';
9
+ import { registerTriggerElementMethodEndpointHandler } from './crossThreadHandlers/registerTriggerElementMethodEndpointHandler.js';
9
10
  export function startBackground(backgroundRpc, shadowRoot, callbacks) {
10
11
  registerInvokeUIMethodHandler(backgroundRpc, shadowRoot);
11
12
  registerNativePropsHandler(backgroundRpc, shadowRoot);
@@ -14,6 +15,7 @@ export function startBackground(backgroundRpc, shadowRoot, callbacks) {
14
15
  registerNativeModulesCallHandler(backgroundRpc, callbacks.nativeModulesCall);
15
16
  registerNapiModulesCallHandler(backgroundRpc, callbacks.napiModulesCall);
16
17
  registerDispatchLynxViewEventHandler(backgroundRpc, shadowRoot);
18
+ registerTriggerElementMethodEndpointHandler(backgroundRpc, shadowRoot);
17
19
  const sendGlobalEvent = backgroundRpc.createCall(sendGlobalEventEndpoint);
18
20
  const markTiming = backgroundRpc.createCall(markTimingEndpoint);
19
21
  const updateDataBackground = backgroundRpc.createCall(updateDataEndpoint);
@@ -3,7 +3,7 @@
3
3
  // LICENSE file in the root directory of this source tree.
4
4
  import { bootWorkers } from './bootWorkers.js';
5
5
  import { createDispose } from './crossThreadHandlers/createDispose.js';
6
- import {} from '@lynx-js/web-constants';
6
+ import { updateGlobalPropsEndpoint, } from '@lynx-js/web-constants';
7
7
  import { loadTemplate } from '../utils/loadTemplate.js';
8
8
  import { createUpdateData } from './crossThreadHandlers/createUpdateData.js';
9
9
  import { startBackground } from './startBackground.js';
@@ -37,6 +37,7 @@ export function startUIThread(templateUrl, configs, shadowRoot, lynxGroupId, thr
37
37
  updateData: createUpdateData(updateDataMainThread, updateDataBackground),
38
38
  dispose: createDispose(backgroundRpc, terminateWorkers),
39
39
  sendGlobalEvent,
40
+ updateGlobalProps: backgroundRpc.createCall(updateGlobalPropsEndpoint),
40
41
  };
41
42
  }
42
43
  //# sourceMappingURL=startUIThread.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/web-core",
3
- "version": "0.13.3",
3
+ "version": "0.13.4",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [],
@@ -24,15 +24,15 @@
24
24
  "**/*.css"
25
25
  ],
26
26
  "dependencies": {
27
- "@lynx-js/offscreen-document": "0.0.4",
28
- "@lynx-js/web-constants": "0.13.3",
29
- "@lynx-js/web-mainthread-apis": "0.13.3",
30
- "@lynx-js/web-worker-rpc": "0.13.3",
31
- "@lynx-js/web-worker-runtime": "0.13.3"
27
+ "@lynx-js/offscreen-document": "0.1.0",
28
+ "@lynx-js/web-constants": "0.13.4",
29
+ "@lynx-js/web-mainthread-apis": "0.13.4",
30
+ "@lynx-js/web-worker-rpc": "0.13.4",
31
+ "@lynx-js/web-worker-runtime": "0.13.4"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@lynx-js/lynx-core": "0.1.2",
35
- "@lynx-js/web-elements": "0.7.3"
35
+ "@lynx-js/web-elements": "0.7.4"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@lynx-js/lynx-core": "0.1.2",