x-runtime-lib 0.8.78 → 0.8.80

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.
@@ -1,5 +1,4 @@
1
- import { QuickJSContext, QuickJSHandle } from 'quickjs-emscripten';
1
+ import { QuickJSContext } from 'quickjs-emscripten';
2
2
  import { Sandbox } from '../sandbox';
3
3
  export declare function isVmAvail(sandbox: Sandbox): boolean;
4
- export declare function hostToVm(vm: QuickJSContext, value: any): QuickJSHandle;
5
- export declare function vmToHost(vm: QuickJSContext, value: QuickJSHandle): any;
4
+ export declare function hostToVm(vm: QuickJSContext, value: any): import("quickjs-emscripten").QuickJSHandle;
@@ -1,10 +1,8 @@
1
1
  import { QuickJSContext, QuickJSRuntime } from 'quickjs-emscripten';
2
2
  import { Data, Env, Mode, SandboxKind } from '@/types';
3
3
  import { PromiseManager } from './promiseManager';
4
- export type PropertyKeys = string[] | string;
5
- export declare function dotPropertyKeys(propertyKeys: PropertyKeys): string;
6
4
  interface Hooks {
7
- onElementPropertyChange: (nodeId: string, propertyKeys: PropertyKeys, newValue: any, oldValue: any) => void;
5
+ onElementPropertyChange: (nodeId: string, propertyKeys: string[], newValue: any, oldValue: any) => void;
8
6
  onCustomPropertyChange: (propertyKey: string, newValue: any, oldValue: any) => void;
9
7
  onAdaptSlotPropertyChange: (propertyKey: string, newValue: any, oldValue: any) => void;
10
8
  onStateChange: (stateId: string, newValue: any, oldValue: any) => void;
@@ -34,10 +32,8 @@ export declare class Sandbox {
34
32
  callFunction(funcName: string, ...ps: any): void;
35
33
  private nodes;
36
34
  syncNodes(data: Data | undefined): void;
37
- getElementPropertyInner(node: any, propertyKeys: PropertyKeys): any;
38
- getElementProperty(nodeId: string, propertyKeys: PropertyKeys): any;
39
- setElementPropertyInner(node: any, propertyKeys: PropertyKeys, newValue: any): void;
40
- setElementProperty(nodeId: string, propertyKeys: PropertyKeys, newValue: any): void;
35
+ getElementProperty(nodeId: string, propertyKeys: string[]): any;
36
+ setElementProperty(nodeId: string, propertyKeys: string[], newValue: any): void;
41
37
  private customProperties;
42
38
  resetCustomProperties(): void;
43
39
  getCustomProperty(key: string): any;
@@ -0,0 +1 @@
1
+ export declare const initCode = "\nlet __events__ = {}\n\nfunction __onEventV1__(id, callback) {\n if (typeof(id) !== 'string' || !id) {\n return\n }\n if (typeof(callback) !== 'function') {\n return\n }\n if (!__events__[id]) {\n __events__[id] = []\n }\n const callbacks = __events__[id]\n for (let i = 0; i < callbacks.length; i++) {\n if (callbacks[i] === callback) {\n return\n }\n }\n callbacks.push(callback)\n}\n\nfunction __triggerEventInner__(id, ...params) {\n if (typeof(id) !== 'string' || !id) {\n return\n }\n if (!__events__[id]) {\n return\n }\n const callbacks = __events__[id]\n if (!callbacks) {\n return\n }\n for (let i = 0; i < callbacks.length; i++) {\n callbacks[i](...params)\n }\n}\n\nlet __timers__ = {}\nlet __currTimerId__ = 0\n\nfunction __createTimerV1__(interval, loop, count, immediate, callback) {\n if (!loop && count <= 0) {\n return\n }\n const timer = {}\n timer.id = __currTimerId__++\n timer.interval = interval\n timer.loop = loop\n timer.count = count\n timer.immediate = immediate\n timer.callback = callback\n __timers__[timer.id] = timer\n if (timer.immediate) {\n __timeoutCallbackV1__(timer.id)\n } else {\n __timeoutV1__(timer.id, timer.interval)\n }\n}\n\nfunction __timeoutCallback__(timerId) {\n const timer = __timers__[timerId]\n if (timer) {\n timer.callback()\n // \u4FEE\u6539\u8BA1\u6570\n if (!timer.loop) {\n timer.count = timer.count - 1\n }\n // \u89E6\u53D1\u8D85\u65F6\n if (timer.loop || timer.count > 0) {\n __timeoutV1__(timer.id, timer.interval)\n }\n // \u56DE\u6536\n if (!timer.loop && timer.count <= 0) {\n delete __timers__[timer.id]\n }\n }\n}\n\nfunction __destroy__() {\n __events__ = {}\n __timers__ = {}\n}\n";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "x-runtime-lib",
3
3
  "private": false,
4
- "version": "0.8.78",
4
+ "version": "0.8.80",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -1 +0,0 @@
1
- export declare const event = "\nlet __events__ = {}\n\nfunction __onEventV1__(id, callback) {\n if (typeof(id) !== 'string' || !id) {\n return\n }\n if (typeof(callback) !== 'function') {\n return\n }\n if (!__events__[id]) {\n __events__[id] = []\n }\n const callbacks = __events__[id]\n for (let i = 0; i < callbacks.length; i++) {\n if (callbacks[i] === callback) {\n return\n }\n }\n callbacks.push(callback)\n}\n\nfunction __triggerEventInner__(id, ...params) {\n if (typeof(id) !== 'string' || !id) {\n return\n }\n if (!__events__[id]) {\n return\n }\n const callbacks = __events__[id]\n if (!callbacks) {\n return\n }\n for (let i = 0; i < callbacks.length; i++) {\n callbacks[i](...params)\n }\n}\n";
@@ -1 +0,0 @@
1
- export declare const initCode: string;
@@ -1 +0,0 @@
1
- export declare const timer = "\nlet __timers__ = {}\nlet __currTimerId__ = 0\n\nfunction __createTimerV1__(interval, loop, count, immediate, callback) {\n if (!loop && count <= 0) {\n return\n }\n __currTimerId__ = __currTimerId__ + 1\n const timer = {}\n timer.id = __currTimerId__\n timer.interval = interval\n timer.loop = loop\n timer.count = count\n timer.immediate = immediate\n timer.callback = callback\n __timers__[timer.id] = timer\n if (timer.immediate) {\n __timeoutCallbackV1__(timer.id)\n } else {\n __timeoutV1__(timer.id, timer.interval)\n }\n}\n\nfunction __timeoutCallback__(timerId) {\n const timer = __timers__[timerId]\n if (timer) {\n timer.callback()\n // \u4FEE\u6539\u8BA1\u6570\n if (!timer.loop) {\n timer.count = timer.count - 1\n }\n // \u89E6\u53D1\u8D85\u65F6\n if (timer.loop || timer.count > 0) {\n __timeoutV1__(timer.id, timer.interval)\n }\n // \u56DE\u6536\n if (!timer.loop && timer.count <= 0) {\n delete __timers__[timer.id]\n }\n }\n}\n";