runtime-compiler 2.0.3 → 2.0.6

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 CHANGED
@@ -1,14 +1,13 @@
1
- import type { LocalDependency } from "./index.ts";
2
- export type InferArgs<T extends LocalDependency<any>[]> = T extends [LocalDependency<infer First>, ...infer Rest extends LocalDependency<any>[]] ? [First, ...InferArgs<Rest>] : [];
1
+ import type { InferDependency, LocalDependency } from "./index.ts";
3
2
  /**
4
3
  * Inject dependency to an fn for later compilation
5
4
  */
6
5
  export declare const inject: <
7
6
  const Deps extends LocalDependency<any>[],
8
- Args extends any[],
9
- Ret
10
- >(deps: Deps, fn: (...args: [...InferArgs<Deps>, ...Args]) => Ret) => ((...args: Args) => Ret);
7
+ const Args extends any[],
8
+ const Ret
9
+ >(deps: Deps, fn: (...args: [...{ [K in keyof Deps] : InferDependency<Deps[K]> }, ...Args]) => Ret) => (...args: Args) => Ret;
11
10
  /**
12
11
  * Get fn injected dependency list
13
12
  */
14
- export declare const getDeps: (fn: (...args: any[]) => any) => LocalDependency<any>[] | undefined;
13
+ export declare const getDeps: (fn: any) => LocalDependency<any>[] | undefined;
package/call.js CHANGED
@@ -1 +1 @@
1
- let sym=Symbol();export let inject=(t,n)=>{n[sym]=t;return n};export let getDeps=t=>t[sym];
1
+ let sym=Symbol();export let inject=(t,n)=>(n[sym]=t,n);export let getDeps=t=>t[sym];
package/index.d.ts CHANGED
@@ -5,6 +5,9 @@ export type LocalDependency<T> = string & {
5
5
  export type ExportedDependency<T> = number & {
6
6
  [_]: T
7
7
  };
8
+ export type InferDependency<T extends {
9
+ [_]: any
10
+ }> = T[typeof _];
8
11
  /**
9
12
  * Inject a local dependency.
10
13
  * Use in `default` and `build` mode.
@@ -47,10 +50,10 @@ export declare const externalDependencyNames: () => string;
47
50
  */
48
51
  export declare const clear: () => void;
49
52
  /**
50
- * Clear compiler data.
53
+ * Equivalent to calling `evaluate`/`evaluateSync` in `default` or `build` mode.
51
54
  * Use in `hydrate` mode.
52
55
  */
53
- export declare const clearHydration: () => void;
56
+ export declare const finishHydration: () => void;
54
57
  /**
55
58
  * Lazily add the dependency when needed.
56
59
  */
@@ -61,10 +64,6 @@ export declare const lazyDependency: <T>(inject: (v: T) => string, val: T) => ((
61
64
  */
62
65
  export declare const evaluateCode: () => string;
63
66
  /**
64
- * Run hydration.
65
- */
66
- export declare const hydrate: () => any[];
67
- /**
68
67
  * Evaluate code to string.
69
68
  * Use in `default` and `build` mode.
70
69
  */
package/index.js CHANGED
@@ -1 +1 @@
1
- import{AsyncFunction}from"./utils.js";export let compiledDependencies=[];export let externalDependencies=[];export let cache={};export let localDeps=``;let localDepsCnt=0;export let injectDependency=e=>{localDeps+=`,$`+localDepsCnt+`=`+e;return`$`+ localDepsCnt++};export let asyncDeps=``;export let waitDependency=e=>{asyncDeps+=e+`,`};export let exportedDeps=``;let exportedDepsCnt=0;export let exportDependency=e=>{exportedDeps+=e+`,`;return exportedDepsCnt++};export let markExported=()=>exportedDepsCnt++;export let getDependency=e=>compiledDependencies[e];export let injectExternalDependency=e=>`_`+externalDependencies.push(e);export let externalDependencyNames=()=>{let e=`_,`;for(let S=0;S<externalDependencies.length;S++)e+=`_`+(S+1)+`,`;return e};export let clear=()=>{externalDependencies.length=0;cache={};localDeps=``;localDepsCnt=0;asyncDeps=``;exportedDeps=``};export let clearHydration=()=>{externalDependencies.length=0;cache={}};export let lazyDependency=(e,S)=>{let C=Symbol();return()=>cache[C]??=e(S)};export let evaluateCode=()=>`{var $`+localDeps+(asyncDeps===``?`;_.push(`:`;[`+asyncDeps+`]=await Promise.all([`+asyncDeps+`]);_.push(`)+exportedDeps+`)}`;export let hydrate=()=>{let e=[compiledDependencies].concat(externalDependencies);clearHydration();return e};export let evaluateToString=()=>`(`+externalDependencyNames()+`)=>`+evaluateCode();export let evaluateSync=()=>{try{Function(externalDependencyNames(),evaluateCode())(compiledDependencies,...externalDependencies)}finally{clear()}};export let evaluate=async()=>AsyncFunction(externalDependencyNames(),evaluateCode())(compiledDependencies,...externalDependencies).finally(clear);
1
+ import{AsyncFunction}from"./utils.js";export let compiledDependencies=[];export let externalDependencies=[];export let cache={};export let localDeps=``;let localDepsCnt=0;export let injectDependency=e=>{localDeps+=`,$`+localDepsCnt+`=`+e;return`$`+ localDepsCnt++};export let asyncDeps=``;export let waitDependency=e=>{asyncDeps+=e+`,`};export let exportedDeps=``;let exportedDepsCnt=0;export let exportDependency=e=>{exportedDeps+=e+`,`;return exportedDepsCnt++};export let markExported=()=>exportedDepsCnt++;export let getDependency=e=>compiledDependencies[e];export let injectExternalDependency=e=>`_`+externalDependencies.push(e);export let externalDependencyNames=()=>{let e=`_,`;for(let x=0;x<externalDependencies.length;x++)e+=`_`+(x+1)+`,`;return e};export let clear=()=>{externalDependencies.length=0;cache={};localDeps=``;localDepsCnt=0;asyncDeps=``;exportedDeps=``};export let finishHydration=()=>{externalDependencies.length=0;cache={}};export let lazyDependency=(e,x)=>{let S=Symbol();return()=>cache[S]??=e(x)};export let evaluateCode=()=>`{var $`+localDeps+(asyncDeps===``?`;_.push(`:`;[`+asyncDeps+`]=await Promise.all([`+asyncDeps+`]);_.push(`)+exportedDeps+`)}`;export let evaluateToString=()=>`(`+externalDependencyNames()+`)=>`+evaluateCode();export let evaluateSync=()=>{try{Function(externalDependencyNames(),evaluateCode())(compiledDependencies,...externalDependencies)}finally{clear()}};export let evaluate=async()=>AsyncFunction(externalDependencyNames(),evaluateCode())(compiledDependencies,...externalDependencies).finally(clear);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runtime-compiler",
3
- "version": "2.0.3",
3
+ "version": "2.0.6",
4
4
  "description": "Universal compiler system",
5
5
  "keywords": [],
6
6
  "repository": {},
@@ -10,11 +10,11 @@
10
10
  "exports": {
11
11
  "./call": "./call.js",
12
12
  "./utils": "./utils.js",
13
+ "./config/mode/build": "./config/mode/build.js",
13
14
  "./config/mode/hydrate": "./config/mode/hydrate.js",
14
- "./config": "./config/index.js",
15
15
  "./config/loader/build": "./config/loader/build.js",
16
- "./config/mode/build": "./config/mode/build.js",
17
16
  "./config/loader/hydrate": "./config/loader/hydrate.js",
17
+ "./config": "./config/index.js",
18
18
  ".": "./index.js"
19
19
  }
20
20
  }