x-runtime-lib 0.8.43 → 0.8.45

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,2 +1,2 @@
1
- import { Sandbox } from '@/utils';
1
+ import { Sandbox } from '../sandbox';
2
2
  export declare function bindBase(sandbox: Sandbox): void;
@@ -1,2 +1,2 @@
1
- import { Sandbox } from '@/utils';
1
+ import { Sandbox } from '../sandbox';
2
2
  export declare function bindCompute(sandbox: Sandbox): void;
@@ -0,0 +1,2 @@
1
+ import { Sandbox } from '../sandbox';
2
+ export declare function bind(sandbox: Sandbox): void;
@@ -1,2 +1,2 @@
1
- import { Sandbox } from '@/utils';
1
+ import { Sandbox } from '../sandbox';
2
2
  export declare function bindView(sandbox: Sandbox): void;
@@ -0,0 +1 @@
1
+ export * from './sandbox';
@@ -0,0 +1 @@
1
+ export declare const base = "\nvar __env__ = 'dev'\nvar __mode__ = 'editor'\n\nfunction __getEnvV1__() {\n return __env__\n}\n\nvar __pointerPosX__ = 0\nvar __pointerPosY__ = 0\n";
@@ -0,0 +1 @@
1
+ export declare const event = "\nvar __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 var callbacks = __events__[id]\n for (var i = 0; i < callbacks.length; i++) {\n if (callbacks[i] === callback) {\n return\n }\n }\n callbacks.push(callback)\n}\n\nfunction __triggerEventV1__(id, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16) {\n if (typeof(id) !== 'string' || !id) {\n return\n }\n if (!__events__[id]) {\n return\n }\n var callbacks = __events__[id]\n if (!callbacks) {\n return\n }\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16)\n }\n}\n";
@@ -0,0 +1 @@
1
+ export declare const runtime: string;
@@ -0,0 +1 @@
1
+ export declare const timer = "\nvar __timers__ = {}\nvar __currTimerId__ = 0\n\nfunction __createTimerV1__(interval, loop, count, immediate, callback) {\n if (!loop && count <= 0) {\n return\n }\n __currTimerId__ = __currTimerId__ + 1\n var 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 __timeoutCallbackV1__(timerId) {\n var 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";
@@ -8,14 +8,21 @@ interface Hooks {
8
8
  onStateChange: (stateId: string, newValue: any, oldValue: any) => void;
9
9
  }
10
10
  export declare class Sandbox {
11
+ id: string;
11
12
  parent: Sandbox | undefined;
13
+ children: {
14
+ [key: string]: Sandbox;
15
+ };
12
16
  org: string;
13
17
  env: Env;
14
18
  mode: Mode;
15
19
  type: 'page' | 'comp';
16
20
  eventBus: import("mitt").Emitter<Record<import("mitt").EventType, unknown>>;
17
21
  private hooks?;
18
- constructor(parent: Sandbox | undefined, org: string, env: Env, mode: Mode, type: 'page' | 'comp', hooks?: Hooks);
22
+ constructor(id: string, parent: Sandbox | undefined, org: string, env: Env, mode: Mode, type: 'page' | 'comp', hooks: Hooks);
23
+ dispose(): void;
24
+ private addChild;
25
+ private removeChild;
19
26
  private nodes;
20
27
  syncNodes(data: Data | undefined): void;
21
28
  getElementPropertyInner(node: any, propertyKeys: PropertyKeys): any;
@@ -35,16 +42,16 @@ export declare class Sandbox {
35
42
  getState(stateId: string): any;
36
43
  setState(stateId: string, newValue: string): void;
37
44
  private interpreter;
38
- private globalObject;
39
45
  createInterpreter(code: string): void;
40
46
  destroyInterpreter(): void;
41
47
  bindNativeFunction(name: string, func: Function): void;
42
48
  bindAsyncFunction(name: string, func: Function): void;
43
49
  pseudoToNative(obj: any): any;
44
50
  nativeToPseudo(obj: any): any;
45
- run(): void;
46
51
  getVariable(varName: string): any;
47
52
  setVariable(varName: string, value: any): void;
53
+ run(): void;
54
+ runCode(code: string): void;
48
55
  callFunction(funcName: string, params?: any[]): void;
49
56
  }
50
57
  export {};
@@ -4,5 +4,4 @@ export * from './node';
4
4
  export * from './property';
5
5
  export * from './provideInject';
6
6
  export * from './reactivity';
7
- export * from './sandbox';
8
7
  export * from './unifiedId';
@@ -13,3 +13,4 @@ export declare function getBreakpointProp(current: Breakpoint, props: {
13
13
  }): any;
14
14
  export declare function getField(object: any, keys: string[] | string): any;
15
15
  export declare function setField(object: any, keys: string[] | string, value: any): void;
16
+ export declare function addIndent(code: string, spaces?: number): string;
@@ -1,6 +1,6 @@
1
1
  import { Ref } from 'vue';
2
+ import { Sandbox } from '@/sandbox';
2
3
  import { Data, Depends, Env, Mode } from '@/types';
3
- import { Sandbox } from './sandbox';
4
4
  export declare function provideOrg(org: string): void;
5
5
  export declare function injectOrg(): string;
6
6
  export declare function provideEnv(env: Env): void;
@@ -1,4 +1,4 @@
1
+ import { Sandbox } from '@/sandbox';
1
2
  import { Reactivity, Trigger } from '@/types';
2
- import { Sandbox } from './sandbox';
3
3
  export declare function makeTriggerId(trigger: Trigger): string;
4
4
  export declare function triggerReactivity(sandbox: Sandbox, reactivity: Reactivity, triggerId: string, newValue: any, oldValue: any): void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "x-runtime-lib",
3
3
  "private": false,
4
- "version": "0.8.43",
4
+ "version": "0.8.45",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -1,3 +0,0 @@
1
- import { Sandbox } from '@/utils';
2
- declare function bind(sandbox: Sandbox): void;
3
- export default bind;
@@ -1,3 +0,0 @@
1
- import bind from './bind';
2
- import runtime from './runtime';
3
- export { bind, runtime };
@@ -1,2 +0,0 @@
1
- declare const base = "\nvar __env__ = 'dev'\nvar __mode__ = 'editor'\n\nfunction __getEnvV1__() {\n return __env__\n}\n\nvar __pointerPosX__ = 0\nvar __pointerPosY__ = 0\n";
2
- export default base;
@@ -1,2 +0,0 @@
1
- declare const event = "\nvar __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 var callbacks = __events__[id]\n for (var i = 0; i < callbacks.length; i++) {\n if (callbacks[i] === callback) {\n return\n }\n }\n callbacks.push(callback)\n}\n\nfunction __triggerEventV1__(id, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16) {\n if (typeof(id) !== 'string' || !id) {\n return\n }\n if (!__events__[id]) {\n return\n }\n var callbacks = __events__[id]\n if (!callbacks) {\n return\n }\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i](p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16)\n }\n}\n";
2
- export default event;
@@ -1,2 +0,0 @@
1
- declare const runtime: string;
2
- export default runtime;
@@ -1,2 +0,0 @@
1
- declare const timer = "\nvar __timers__ = {}\nvar __currTimerId__ = 0\n\nfunction __createTimerV1__(interval, loop, count, immediate, callback) {\n if (!loop && count <= 0) {\n return\n }\n __currTimerId__ = __currTimerId__ + 1\n var 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 __timeoutCallbackV1__(timerId) {\n var 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";
2
- export default timer;