runtime-compiler 3.1.8 → 3.2.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/index.d.ts +31 -17
- package/index.js +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -25,8 +25,31 @@ export interface Scope {
|
|
|
25
25
|
2: string;
|
|
26
26
|
slice: () => this;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* External dependencies
|
|
30
|
+
*/
|
|
31
|
+
export declare const $: any[];
|
|
32
|
+
/**
|
|
33
|
+
* Inject an external dependency.
|
|
34
|
+
*/
|
|
35
|
+
export declare const injectExternal: <T>(val: T) => Value<T>;
|
|
36
|
+
/**
|
|
37
|
+
* Get next available identifier name in a scope
|
|
38
|
+
*/
|
|
28
39
|
export declare const nextId: <T>(scope: Scope) => Identifier<T>;
|
|
29
|
-
|
|
40
|
+
export declare const content: <T>(scope: Scope) => string;
|
|
41
|
+
/**
|
|
42
|
+
* Declare a new variable in a scope
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* declareLocal(scope, '1;');
|
|
46
|
+
*/
|
|
47
|
+
export declare const declareLocal: <T>(scope: Scope, str: string) => Identifier<T>;
|
|
48
|
+
/**
|
|
49
|
+
* Declare a new variable in a scope
|
|
50
|
+
*/
|
|
51
|
+
export declare const declareExternal: <T>(scope: Scope, val: T) => Identifier<T>;
|
|
52
|
+
interface ExportToParent {
|
|
30
53
|
<T>(scope: Scope, expr: Expression<T>, parentScope: Scope): Identifier<T>;
|
|
31
54
|
(scope: Scope, expr: string, parentScope: Scope): string;
|
|
32
55
|
}
|
|
@@ -38,19 +61,15 @@ interface ExportLocal {
|
|
|
38
61
|
* // Fork scope
|
|
39
62
|
* const childScope = ['', parentScope.id];
|
|
40
63
|
* // let d0;{let d1=1;d0=d1}
|
|
41
|
-
* const id =
|
|
64
|
+
* const id = exportTo(childScope, declareLocal(childScope, '1'), parentScope); // d0
|
|
42
65
|
*/
|
|
43
|
-
export declare const
|
|
66
|
+
export declare const exportToParent: ExportToParent;
|
|
44
67
|
/**
|
|
45
68
|
* Mark current available variable id to be already in use.
|
|
46
69
|
* Use in `hydrate` mode.
|
|
47
70
|
* @param scope
|
|
48
71
|
*/
|
|
49
72
|
export declare const markDeclared: (scope: Scope) => void;
|
|
50
|
-
/**
|
|
51
|
-
* External dependencies
|
|
52
|
-
*/
|
|
53
|
-
export declare const $: any[];
|
|
54
73
|
export declare let statements: string;
|
|
55
74
|
interface ExportScope {
|
|
56
75
|
<T>(scope: Scope, value: Expression<T>): ExportedDependency<T>;
|
|
@@ -61,15 +80,14 @@ interface ExportScope {
|
|
|
61
80
|
* Use in `default` and `build` mode.
|
|
62
81
|
*/
|
|
63
82
|
export declare const exportScope: ExportScope;
|
|
64
|
-
interface ExportExpr {
|
|
65
|
-
<T>(value: Expression<T>): ExportedDependency<T>;
|
|
66
|
-
<T>(value: string): ExportedDependency<T>;
|
|
67
|
-
}
|
|
68
83
|
/**
|
|
69
|
-
* Export a
|
|
84
|
+
* Export a value.
|
|
70
85
|
* Use in `default` and `build` mode.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* exportLocal('1;');
|
|
71
89
|
*/
|
|
72
|
-
export declare const
|
|
90
|
+
export declare const exportLocal: <T>(value: string) => ExportedDependency<T>;
|
|
73
91
|
/**
|
|
74
92
|
* Mark a slot to export a dependency.
|
|
75
93
|
* Use in `hydrate` mode.
|
|
@@ -87,10 +105,6 @@ export declare const getDependency: <T>(idx: ExportedDependency<T>) => T;
|
|
|
87
105
|
*/
|
|
88
106
|
export declare const getStatements: () => string;
|
|
89
107
|
/**
|
|
90
|
-
* Inject an external dependency.
|
|
91
|
-
*/
|
|
92
|
-
export declare const injectExternal: <T>(val: T) => Value<T>;
|
|
93
|
-
/**
|
|
94
108
|
* Store temporary build data.
|
|
95
109
|
*/
|
|
96
110
|
export declare let buildData: any[];
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
;export let $=[];export let injectExternal=f=>`$[${$.push(f)-1}]`;export let nextId=e=>`d`+ e[1]++;export let content=e=>e[0]+e[2];export let declareLocal=(e,f)=>{let m=nextId(e);e[0]+=`let ${m}=`+f;return m};export let declareExternal=(f,m)=>{let h=nextId(f);f[0]+=`let ${h}=$[${$.push(m)-1}];`;return h};export let exportToParent=(e,f,h)=>{let g=nextId(h);h[0]+=`let ${g};{${content(e)+g}=${f}}`;return g};export let markDeclared=e=>{e[1]++};export let statements=``;export let exportScope=(f,p)=>(statements+=`{${content(f)}$[${$.length}]=${p}}`,$.length++);export let exportLocal=f=>(statements+=`$[${$.length}]=${f}`,$.length++);export let markExported=()=>$.length++;export let getDependency=f=>{if(statements.length>0){globalThis.__rt_externals__=$;(0,eval)(`{let $=__rt_externals__;`+statements+`}`);globalThis.__rt_externals__=null;statements=``;buildData=[]}return $[f]};export let getStatements=()=>{let e=statements;statements=``;buildData=[];return e};export let buildData=[];let nextSlot=0;export let createBuildSlot=()=>nextSlot++;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"runtime-compiler","version":"3.
|
|
1
|
+
{"name":"runtime-compiler","version":"3.2.0","description":"Universal compiler system","keywords":[],"repository":{},"homepage":"","license":"MIT","type":"module","exports":{"./utils":"./utils.js","./config":"./config/index.js",".":"./index.js","./config/mode/hydrate":"./config/mode/hydrate.js","./config/mode/build":"./config/mode/build.js","./config/loader/hydrate":"./config/loader/hydrate.js","./config/loader/build":"./config/loader/build.js"}}
|