runtime-compiler 3.0.2 → 3.0.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/index.d.ts +27 -30
- package/index.js +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -10,21 +10,40 @@ export type Identifier<T> = Value<T> & {
|
|
|
10
10
|
export type ExportedDependency<T> = number & {
|
|
11
11
|
"~type": T
|
|
12
12
|
};
|
|
13
|
-
interface
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
export interface Scope {
|
|
14
|
+
body: string;
|
|
15
|
+
/**
|
|
16
|
+
* Next available id.
|
|
17
|
+
*/
|
|
18
|
+
id: number;
|
|
16
19
|
}
|
|
17
20
|
/**
|
|
18
|
-
*
|
|
19
|
-
|
|
21
|
+
* Declare a variable in the current scope.
|
|
22
|
+
*/
|
|
23
|
+
export declare const declareLocal: (<T>(scope: Scope, expr: Expression<T>) => Identifier<T>) | ((scope: Scope, expr: string) => string);
|
|
24
|
+
/**
|
|
25
|
+
* Export a local expression to a parent local variable
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* // Fork scope
|
|
29
|
+
* const childScope = {
|
|
30
|
+
* body: '',
|
|
31
|
+
* id: parentScope.id
|
|
32
|
+
* };
|
|
33
|
+
* // let d0;{let d1=1;d0=d1}
|
|
34
|
+
* const id = exportLocal(childScope, declareLocal(childScope, '1'), parentScope); // d0
|
|
20
35
|
*/
|
|
21
|
-
export declare const
|
|
36
|
+
export declare const exportLocal: ((<T>(scope: Scope, expr: Expression<T>, parentScope: Scope) => Identifier<T>) | ((scope: Scope, expr: string, parentScope: Scope) => string));
|
|
37
|
+
/**
|
|
38
|
+
* External dependencies
|
|
39
|
+
*/
|
|
40
|
+
export declare const $: any[];
|
|
22
41
|
/**
|
|
23
42
|
* Export a local dependency.
|
|
24
43
|
* Use in `default` and `build` mode.
|
|
25
44
|
* @param value
|
|
26
45
|
*/
|
|
27
|
-
export declare const exportDependency: <T>(value: Expression<T>) => ExportedDependency<T>;
|
|
46
|
+
export declare const exportDependency: <T>(scope: Scope, value: Expression<T>) => ExportedDependency<T>;
|
|
28
47
|
/**
|
|
29
48
|
* Mark a slot to export a dependency.
|
|
30
49
|
* Use in `hydrate` mode.
|
|
@@ -40,29 +59,7 @@ export declare const getDependency: <T>(idx: ExportedDependency<T>) => T;
|
|
|
40
59
|
*/
|
|
41
60
|
export declare const injectExternal: <T>(val: T) => Value<T>;
|
|
42
61
|
/**
|
|
43
|
-
* Evaluate to statements instead of a function.
|
|
44
|
-
* Use in `default` and `build` mode.
|
|
45
|
-
*/
|
|
46
|
-
export declare const evaluateToStatements: () => string;
|
|
47
|
-
/**
|
|
48
|
-
* Evaluate code to a function.
|
|
49
|
-
* Use in `build` mode.
|
|
50
|
-
*/
|
|
51
|
-
export declare const evaluateToFn: (extraCode: string) => Expression<(...args: any[]) => any>;
|
|
52
|
-
/**
|
|
53
62
|
* Run evaluated code.
|
|
54
63
|
* Use in `default` mode.
|
|
55
64
|
*/
|
|
56
|
-
export declare const evaluate: (
|
|
57
|
-
/**
|
|
58
|
-
* Hydrate a built function.
|
|
59
|
-
* Use in `hydrate` mode.
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* hydratedCode += `
|
|
63
|
-
* import { hydrate } from 'runtime-compiler';
|
|
64
|
-
* const compiled = hydrate(${evaluateToFn(app)});
|
|
65
|
-
* `;
|
|
66
|
-
*/
|
|
67
|
-
export declare const hydrate: <T>(compiledFn: (externalDependencies: any[]) => T) => T;
|
|
68
|
-
export {};
|
|
65
|
+
export declare const evaluate: (statements: string) => void;
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let
|
|
1
|
+
export let declareLocal=(e,a)=>(e.body+=`let d`+e.id+`=`+a+`;`,`d`+ e.id++);export let exportLocal=(e,a,o)=>{let s=`d`+ o.id++;o.body+=`let `+s+`;{`+e.body+s+`=`+a+`}`;return s};export let $=[];export let exportDependency=(e,a)=>(e.body+=`$[`+$.length+`]=`+a+`;`,$.push(null)-1);export let markExported=()=>$.push(null)-1;export let getDependency=e=>$[e];export let injectExternal=e=>`$[`+($.push(e)-1)+`]`;export let evaluate=e=>{globalThis.__rt_externals__=$;(0,eval)(`{let $=__rt_externals__;`+e+`}`)};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"runtime-compiler","version":"3.0.
|
|
1
|
+
{"name":"runtime-compiler","version":"3.0.4","description":"Universal compiler system","keywords":[],"repository":{},"homepage":"","license":"MIT","type":"module","exports":{"./utils":"./utils.js",".":"./index.js","./config":"./config/index.js","./call":"./call.js","./config/loader/hydrate":"./config/loader/hydrate.js","./config/loader/build":"./config/loader/build.js","./config/mode/build":"./config/mode/build.js","./config/mode/hydrate":"./config/mode/hydrate.js"}}
|