runtime-compiler 3.0.2 → 3.0.3
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 +11 -17
- package/index.js +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ export type Identifier<T> = Value<T> & {
|
|
|
10
10
|
export type ExportedDependency<T> = number & {
|
|
11
11
|
"~type": T
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* External dependencies
|
|
15
|
+
*/
|
|
16
|
+
export declare const externals: any[];
|
|
13
17
|
interface InjectDependencyFn {
|
|
14
18
|
<T>(val: Expression<T>): Identifier<T>;
|
|
15
19
|
<T>(val: string): Identifier<T>;
|
|
@@ -42,27 +46,17 @@ export declare const injectExternal: <T>(val: T) => Value<T>;
|
|
|
42
46
|
/**
|
|
43
47
|
* Evaluate to statements instead of a function.
|
|
44
48
|
* Use in `default` and `build` mode.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* hydratedCode += `
|
|
52
|
+
* import { externals as $ } from 'runtime-compiler';
|
|
53
|
+
* ${evaluateToStatements()}
|
|
54
|
+
* `;
|
|
45
55
|
*/
|
|
46
56
|
export declare const evaluateToStatements: () => string;
|
|
47
57
|
/**
|
|
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
58
|
* Run evaluated code.
|
|
54
59
|
* Use in `default` mode.
|
|
55
60
|
*/
|
|
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;
|
|
61
|
+
export declare const evaluate: () => any;
|
|
68
62
|
export {};
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let externals=[];let localDeps=``;let localDepsCnt=0;let exportDeps=``;export let injectDependency=e=>{localDeps+=`,$`+localDepsCnt+`=`+e;return`$`+ localDepsCnt++};export let exportDependency=
|
|
1
|
+
export let externals=[];let localDeps=``;let localDepsCnt=0;let exportDeps=``;export let injectDependency=e=>{localDeps+=`,$`+localDepsCnt+`=`+e;return`$`+ localDepsCnt++};export let exportDependency=u=>(exportDeps+=`;$[`+externals.length+`]=`+u,externals.push(null)-1);export let markExported=()=>externals.push(null)-1;export let getDependency=u=>externals[u];export let injectExternal=u=>`$[`+(externals.push(u)-1)+`]`;export let evaluateToStatements=()=>localDeps.length===0?exportDeps+`;`:`{let `+localDeps.slice(1)+exportDeps+`}`;export let evaluate=()=>{globalThis.__runtime_compiler__=externals;(0,eval)(`{let $=__runtime_compiler__`+localDeps+exportDeps+`}`);delete globalThis.__runtime_compiler__};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"runtime-compiler","version":"3.0.
|
|
1
|
+
{"name":"runtime-compiler","version":"3.0.3","description":"Universal compiler system","keywords":[],"repository":{},"homepage":"","license":"MIT","type":"module","exports":{".":"./index.js","./config/loader/hydrate":"./config/loader/hydrate.js","./config":"./config/index.js","./call":"./call.js","./config/loader/build":"./config/loader/build.js","./config/mode/build":"./config/mode/build.js","./utils":"./utils.js","./config/mode/hydrate":"./config/mode/hydrate.js"}}
|