runtime-compiler 2.1.4 → 3.0.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/call.d.ts +14 -5
- package/call.js +1 -1
- package/index.d.ts +25 -8
- package/index.js +1 -1
- package/package.json +1 -1
- package/utils.d.ts +0 -1
- package/utils.js +1 -1
package/call.d.ts
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { Identifier, InferExpression } from "./index.ts";
|
|
2
|
+
declare const sym: unique symbol;
|
|
3
|
+
type sym = typeof sym;
|
|
4
|
+
export interface InjectedCall<Deps extends Identifier<any>[]> {
|
|
5
|
+
[sym]: Deps;
|
|
6
|
+
}
|
|
3
7
|
/**
|
|
4
8
|
* Inject dependency to an fn for later compilation
|
|
5
9
|
*/
|
|
6
10
|
export declare const inject: <
|
|
7
|
-
const Deps extends
|
|
11
|
+
const Deps extends Identifier<any>[],
|
|
8
12
|
const Args extends any[],
|
|
9
13
|
const Ret
|
|
10
|
-
>(deps: Deps, fn: (...args: [...{ [K in keyof Deps] :
|
|
14
|
+
>(deps: Deps, fn: (...args: [...{ [K in keyof Deps] : InferExpression<Deps[K]> }, ...Args]) => Ret) => ((...args: Args) => Ret) & InjectedCall<Deps>;
|
|
15
|
+
interface GetDepsFn {
|
|
16
|
+
<Deps extends Identifier<any>[]>(fn: InjectedCall<Deps>): Deps;
|
|
17
|
+
(fn: any): Identifier<any>[] | undefined;
|
|
18
|
+
}
|
|
11
19
|
/**
|
|
12
20
|
* Get fn injected dependency list
|
|
13
21
|
*/
|
|
14
|
-
export declare const getDeps:
|
|
22
|
+
export declare const getDeps: GetDepsFn;
|
|
23
|
+
export {};
|
package/call.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
let sym=Symbol();export let inject=(t,n)=>(n[sym]=t,n);export let getDeps=t=>t[sym];
|
package/index.d.ts
CHANGED
|
@@ -1,24 +1,41 @@
|
|
|
1
|
+
declare const _01: unique symbol;
|
|
2
|
+
export type Statements = string & {
|
|
3
|
+
[_01]: 0
|
|
4
|
+
};
|
|
5
|
+
declare const _02: unique symbol;
|
|
6
|
+
export type Statement = Statements & {
|
|
7
|
+
[_02]: 0
|
|
8
|
+
};
|
|
1
9
|
declare const _: unique symbol;
|
|
2
|
-
export type
|
|
10
|
+
export type Expression<T> = Statement & {
|
|
3
11
|
[_]: T
|
|
4
12
|
};
|
|
13
|
+
declare const _11: unique symbol;
|
|
14
|
+
export type Identifier<T> = Expression<T> & {
|
|
15
|
+
[_11]: 0
|
|
16
|
+
};
|
|
17
|
+
declare const _20: unique symbol;
|
|
5
18
|
export type ExportedDependency<T> = number & {
|
|
6
|
-
[
|
|
19
|
+
[_20]: 0
|
|
7
20
|
};
|
|
8
|
-
export type
|
|
21
|
+
export type InferExpression<T extends {
|
|
9
22
|
[_]: any
|
|
10
23
|
}> = T[typeof _];
|
|
24
|
+
interface InjectDependencyFn {
|
|
25
|
+
<T>(val: Expression<T>): Identifier<T>;
|
|
26
|
+
<T>(val: string): Identifier<T>;
|
|
27
|
+
}
|
|
11
28
|
/**
|
|
12
29
|
* Inject a local dependency.
|
|
13
30
|
* Use in `default` and `build` mode.
|
|
14
31
|
*/
|
|
15
|
-
export declare const injectDependency:
|
|
32
|
+
export declare const injectDependency: InjectDependencyFn;
|
|
16
33
|
/**
|
|
17
34
|
* Export a local dependency.
|
|
18
35
|
* Use in `default` and `build` mode.
|
|
19
36
|
* @param name
|
|
20
37
|
*/
|
|
21
|
-
export declare const exportDependency: <T>(name:
|
|
38
|
+
export declare const exportDependency: <T>(name: Expression<T>) => ExportedDependency<T>;
|
|
22
39
|
/**
|
|
23
40
|
* Mark a slot in compiled dependencies.
|
|
24
41
|
* Use in `hydrate` mode.
|
|
@@ -36,7 +53,7 @@ export declare const addExtraCode: (str: string) => void;
|
|
|
36
53
|
/**
|
|
37
54
|
* Inject an external dependency.
|
|
38
55
|
*/
|
|
39
|
-
export declare const injectExternalDependency: <T>(val: T) =>
|
|
56
|
+
export declare const injectExternalDependency: <T>(val: T) => Identifier<T>;
|
|
40
57
|
/**
|
|
41
58
|
* Get external dependency names.
|
|
42
59
|
* Use in `default` and `build` mode.
|
|
@@ -57,12 +74,12 @@ export declare const hydrate: () => any[];
|
|
|
57
74
|
* Get evaluated code.
|
|
58
75
|
* Use in `default` and `build` mode.
|
|
59
76
|
*/
|
|
60
|
-
export declare const evaluateCode: () =>
|
|
77
|
+
export declare const evaluateCode: () => Statements;
|
|
61
78
|
/**
|
|
62
79
|
* Evaluate code to string.
|
|
63
80
|
* Use in `default` and `build` mode.
|
|
64
81
|
*/
|
|
65
|
-
export declare const evaluateToString: () =>
|
|
82
|
+
export declare const evaluateToString: () => Expression<(...args: any[]) => any>;
|
|
66
83
|
/**
|
|
67
84
|
* Run evaluated code.
|
|
68
85
|
* Use in `default` and `build` mode.
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export let compiledDependencies=[];export let externalDependencies=[];export let localDeps=``;let localDepsCnt=0;export let injectDependency=e=>{localDeps+=`,$`+localDepsCnt+`=`+e;return`$`+ localDepsCnt++};export let exportedDeps=``;let exportedDepsCnt=0;export let exportDependency=e=>
|
|
1
|
+
export let compiledDependencies=[];export let externalDependencies=[];export let localDeps=``;let localDepsCnt=0;export let injectDependency=e=>{localDeps+=`,$`+localDepsCnt+`=`+e;return`$`+ localDepsCnt++};export let exportedDeps=``;let exportedDepsCnt=0;export let exportDependency=e=>(exportedDeps+=e+`,`,exportedDepsCnt++);export let markExported=()=>exportedDepsCnt++;export let getDependency=g=>compiledDependencies[g];export let extraCode=``;export let addExtraCode=e=>{extraCode+=e};export let injectExternalDependency=e=>`_`+externalDependencies.push(e);export let externalDependencyNames=()=>{let e=`_,`;for(let _=0;_<externalDependencies.length;_++)e+=`_`+(_+1)+`,`;return e};export let hydrate=()=>[compiledDependencies].concat(externalDependencies);export let evaluateCode=()=>`var $`+localDeps+`;_.push(`+exportedDeps+`);`+extraCode;export let evaluateToString=()=>`(`+externalDependencyNames()+`)=>{`+evaluateCode()+`}`;export let evaluate=()=>{try{return Function(externalDependencyNames(),evaluateCode())(compiledDependencies,...externalDependencies)}finally{localDeps=``;localDepsCnt=0;exportedDeps=``;extraCode=``}};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"runtime-compiler","version":"
|
|
1
|
+
{"name":"runtime-compiler","version":"3.0.0","description":"Universal compiler system","keywords":[],"repository":{},"homepage":"","license":"MIT","type":"module","exports":{"./config":"./config/index.js","./config/mode/hydrate":"./config/mode/hydrate.js","./config/loader/build":"./config/loader/build.js","./config/loader/hydrate":"./config/loader/hydrate.js","./config/mode/build":"./config/mode/build.js","./call":"./call.js","./utils":"./utils.js",".":"./index.js","./scope":"./scope.js"}}
|
package/utils.d.ts
CHANGED
package/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{injectDependency}from"./index.js";export let noOp=()=>``;export let injectConst=i=>injectDependency(JSON.stringify(i));export let injectArgsList=e=>e.length!==1?`...`+injectConst(e):injectConst(e[0]);export let AsyncFunction=(async()=>{}).constructor;
|
|
1
|
+
import{injectDependency}from"./index.js";export let noOp=()=>``;export let injectConst=i=>injectDependency(JSON.stringify(i));export let injectArgsList=e=>e.length!==1?`...`+injectConst(e):injectConst(e[0]);export let AsyncFunction=(async()=>{}).constructor;
|