@mapl/web 0.2.0-alpha.3 → 0.2.0-alpha.5
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/README.md +130 -119
- package/compiler/aot.d.ts +2 -1
- package/compiler/aot.js +1 -1
- package/compiler/jit.d.ts +4 -3
- package/compiler/jit.js +1 -1
- package/constants.js +1 -1
- package/core/context.d.ts +0 -2
- package/core/context.js +1 -1
- package/package.json +11 -13
- package/compiler/aot-loader.d.ts +0 -1
- package/compiler/aot-loader.js +0 -1
- package/compiler/config.d.ts +0 -5
- package/compiler/config.js +0 -1
- package/compiler/index.d.ts +0 -11
- package/compiler/index.js +0 -1
package/README.md
CHANGED
|
@@ -50,51 +50,57 @@ export default router(
|
|
|
50
50
|
|
|
51
51
|
// build.ts
|
|
52
52
|
import app from './main.ts';
|
|
53
|
-
import {
|
|
53
|
+
import { injectCompiledHandler } from '@mapl/web/compiler/jit';
|
|
54
|
+
import { evaluateToString } from "runtime-compiler/jit";
|
|
54
55
|
|
|
55
|
-
import { rolldown } from
|
|
56
|
-
import
|
|
57
|
-
|
|
56
|
+
import { rolldown } from "rolldown";
|
|
57
|
+
import terser from '@rollup/plugin-terser';
|
|
58
|
+
|
|
59
|
+
import { writeFileSync } from "node:fs";
|
|
58
60
|
|
|
59
61
|
// Output file
|
|
60
|
-
const
|
|
62
|
+
const OUTPUT = "./index.js";
|
|
63
|
+
const HANDLER = injectCompiledHandler(app);
|
|
61
64
|
|
|
62
65
|
writeFileSync(
|
|
63
|
-
|
|
64
|
-
`
|
|
65
|
-
|
|
66
|
+
OUTPUT,
|
|
67
|
+
`import 'runtime-compiler/hydrate-loader';
|
|
68
|
+
|
|
69
|
+
import app from './main.js';
|
|
70
|
+
import hydrateRouter from '@mapl/web/compiler/aot';
|
|
71
|
+
hydrateRouter(app);
|
|
66
72
|
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
import { hydrate } from 'runtime-compiler/hydrate';
|
|
74
|
+
(${evaluateToString()})(...hydrate());
|
|
69
75
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
import { getDependency } from 'runtime-compiler';
|
|
77
|
+
export default {
|
|
78
|
+
fetch: getDependency(${HANDLER})
|
|
79
|
+
};`,
|
|
74
80
|
);
|
|
75
81
|
const input = await rolldown({
|
|
76
82
|
input: ENTRY,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
plugins: [
|
|
84
|
+
terser({
|
|
85
|
+
module: true,
|
|
86
|
+
mangle: false,
|
|
87
|
+
compress: {
|
|
88
|
+
// passes should be at least 2
|
|
89
|
+
passes: 3,
|
|
90
|
+
},
|
|
91
|
+
}),
|
|
92
|
+
],
|
|
93
|
+
});
|
|
94
|
+
const output = await input.write({
|
|
95
|
+
file: ENTRY,
|
|
96
|
+
inlineDynamicImports: true,
|
|
86
97
|
});
|
|
87
|
-
const output = await input.generate();
|
|
88
|
-
const code = minifySync(output.output[0].code, {
|
|
89
|
-
module: true,
|
|
90
|
-
mangle: false,
|
|
91
|
-
}).code;
|
|
92
|
-
|
|
93
|
-
writeFileSync(ENTRY, code);
|
|
94
98
|
```
|
|
95
99
|
|
|
96
100
|
Example output:
|
|
97
101
|
```js
|
|
102
|
+
let isHydrating = !1;
|
|
103
|
+
isHydrating = !0;
|
|
98
104
|
var core_default = (middlewares, handlers, children) => [
|
|
99
105
|
middlewares,
|
|
100
106
|
handlers,
|
|
@@ -104,51 +110,46 @@ var core_default = (middlewares, handlers, children) => [
|
|
|
104
110
|
let attach = (prop, f) => [1, f, prop],
|
|
105
111
|
noType = { type: null },
|
|
106
112
|
mergeData = (...dat) =>
|
|
107
|
-
0 === dat.length ? noType : Object.assign({ type: null }, ...dat)
|
|
108
|
-
|
|
109
|
-
[
|
|
113
|
+
0 === dat.length ? noType : Object.assign({ type: null }, ...dat),
|
|
114
|
+
compiledDependencies = [],
|
|
115
|
+
externalDependencies = [],
|
|
116
|
+
getDependency = (c) => compiledDependencies[c],
|
|
117
|
+
injectExternalDependency = (e) => '_' + externalDependencies.push(e);
|
|
118
|
+
var f,
|
|
119
|
+
handler,
|
|
120
|
+
main_default = core_default(
|
|
110
121
|
[
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
122
|
+
((f = (c) => {
|
|
123
|
+
console.log(c.req), getDependency(logID)(), getDependency(logID2)();
|
|
124
|
+
}),
|
|
125
|
+
[0, f]),
|
|
126
|
+
attach('id', () => performance.now()),
|
|
115
127
|
],
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
),
|
|
132
|
-
],
|
|
133
|
-
),
|
|
134
|
-
},
|
|
135
|
-
);
|
|
136
|
-
let AsyncFunction = (async () => {}).constructor,
|
|
137
|
-
compilerState = [, , , , ,],
|
|
138
|
-
compileErrorHandler$1 = (scope) =>
|
|
139
|
-
(scope[3] ??= compilerState[4](scope[2][0], scope[2][1], scope)),
|
|
128
|
+
[((handler = (c) => c.id), ['', '/path', handler, mergeData()])],
|
|
129
|
+
{
|
|
130
|
+
'/api': core_default(
|
|
131
|
+
[attach('body', async (c) => c.req.text())],
|
|
132
|
+
[['POST', '/body', (c) => c.body, mergeData()]],
|
|
133
|
+
),
|
|
134
|
+
},
|
|
135
|
+
);
|
|
136
|
+
let hooks,
|
|
137
|
+
_ = Symbol.for('@safe-std/error'),
|
|
138
|
+
AsyncFunction =
|
|
139
|
+
(injectExternalDependency((u) => Array.isArray(u) && u[0] === _),
|
|
140
|
+
(async () => {}).constructor),
|
|
141
|
+
compileErrorHandler = (scope) =>
|
|
142
|
+
(scope[3] ??= hooks.compileErrorHandler(scope[2][0], scope[2][1], scope)),
|
|
140
143
|
clearErrorHandler = (scope) => {
|
|
141
144
|
null != scope[2] && (scope[3] = null);
|
|
142
145
|
},
|
|
143
|
-
createContext = (scope) =>
|
|
144
|
-
scope[1]
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
: ((scope[0] = !0), clearErrorHandler(scope), 'return (async()=>{'),
|
|
151
|
-
setTmp = (scope) => (scope[4] ? 't' : ((scope[4] = !0), 'let t')),
|
|
146
|
+
createContext = (scope) => (
|
|
147
|
+
scope[1] || ((scope[1] = !0), clearErrorHandler(scope)), ''
|
|
148
|
+
),
|
|
149
|
+
createAsyncScope = (scope) => (
|
|
150
|
+
scope[0] || ((scope[0] = !0), clearErrorHandler(scope)), ''
|
|
151
|
+
),
|
|
152
|
+
setTmp = (scope) => ((scope[4] = !0), ''),
|
|
152
153
|
hydrateDependency = (group, scope, prefix) => {
|
|
153
154
|
null != group[2] && ((scope[2] = group[2]), (scope[3] = null));
|
|
154
155
|
for (let i = 0, middlewares = group[0]; i < middlewares.length; i++) {
|
|
@@ -157,21 +158,21 @@ let AsyncFunction = (async () => {}).constructor,
|
|
|
157
158
|
id = middleware[0];
|
|
158
159
|
-1 === id
|
|
159
160
|
? fn(scope)
|
|
160
|
-
: (
|
|
161
|
+
: (injectExternalDependency(fn),
|
|
161
162
|
fn.length > 0 && createContext(scope),
|
|
162
163
|
fn instanceof AsyncFunction && createAsyncScope(scope),
|
|
163
164
|
1 === id
|
|
164
165
|
? createContext(scope)
|
|
165
166
|
: 2 === id
|
|
166
|
-
? (setTmp(scope), compileErrorHandler
|
|
167
|
+
? (setTmp(scope), compileErrorHandler(scope))
|
|
167
168
|
: 3 === id &&
|
|
168
169
|
(setTmp(scope),
|
|
169
|
-
compileErrorHandler
|
|
170
|
+
compileErrorHandler(scope),
|
|
170
171
|
createContext(scope)));
|
|
171
172
|
}
|
|
172
173
|
for (let i = 0, handlers = group[1]; i < handlers.length; i++) {
|
|
173
174
|
let handler = handlers[i];
|
|
174
|
-
|
|
175
|
+
hooks.compileHandler(
|
|
175
176
|
handler[2],
|
|
176
177
|
handler[3],
|
|
177
178
|
prefix + ('/' === handler[1] || '' !== prefix ? '' : handler[1]),
|
|
@@ -186,64 +187,74 @@ let AsyncFunction = (async () => {}).constructor,
|
|
|
186
187
|
scope.slice(),
|
|
187
188
|
'/' === childPrefix ? prefix : prefix + childPrefix,
|
|
188
189
|
);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
190
|
+
};
|
|
191
|
+
(() => {
|
|
192
|
+
let hook = (fn) => (injectExternalDependency(fn), '');
|
|
193
|
+
(hooks = { compileHandler: hook, compileErrorHandler: hook }),
|
|
194
|
+
hydrateDependency(main_default, [!1, !1, , '', !1], '');
|
|
195
|
+
})(),
|
|
196
|
+
((_$1, _1, _2, _3, _4, _5, _6) => {
|
|
197
|
+
_$1.push(
|
|
198
|
+
(() => {
|
|
199
|
+
var t = ['text/html', 'application/json'].map((c) => [
|
|
200
|
+
'Content-Type',
|
|
201
|
+
c,
|
|
202
|
+
]),
|
|
203
|
+
[mwh, mwj] = t,
|
|
204
|
+
[mwoh, mwoj] = t.map((c) => ({ headers: [c] })),
|
|
205
|
+
[mwn, mwb] = [404, 400].map((s) => new Response(null, { status: s })),
|
|
206
|
+
mwc = (r) => ({ status: 200, req: r, headers: [] });
|
|
207
|
+
return (r) => {
|
|
208
|
+
let u = r.url,
|
|
209
|
+
s = u.indexOf('/', 12) + 1,
|
|
210
|
+
e = u.indexOf('?', s),
|
|
211
|
+
p = -1 === e ? u.slice(s) : u.slice(s, e);
|
|
212
|
+
if ('POST' === r.method && 'api' === p) {
|
|
213
|
+
let c = mwc(r);
|
|
214
|
+
return (
|
|
215
|
+
_2(c),
|
|
216
|
+
(c.id = _3()),
|
|
217
|
+
(async () => ((c.body = await _5(c)), new Response(_6(c), c)))()
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
if ('path' === p) {
|
|
221
|
+
let c = mwc(r);
|
|
222
|
+
return _2(c), (c.id = _3()), new Response(_4(c), c);
|
|
223
|
+
}
|
|
224
|
+
return mwn;
|
|
225
|
+
};
|
|
226
|
+
})(),
|
|
227
|
+
);
|
|
216
228
|
})(
|
|
217
|
-
...((
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
(u) => Array.isArray(u) && u[0] === _,
|
|
225
|
-
(r) => ({ status: 200, req: r, headers: [] }),
|
|
226
|
-
].concat(compilerState[1])),
|
|
227
|
-
),
|
|
228
|
-
};
|
|
229
|
-
export { aot_default as default };
|
|
229
|
+
...(() => {
|
|
230
|
+
let n = [compiledDependencies].concat(externalDependencies);
|
|
231
|
+
return (externalDependencies.length = 0), n;
|
|
232
|
+
})(),
|
|
233
|
+
);
|
|
234
|
+
var _1_default = { fetch: getDependency(0) };
|
|
235
|
+
export { _1_default as default };
|
|
230
236
|
```
|
|
231
237
|
|
|
232
238
|
### Hydration
|
|
233
239
|
```ts
|
|
234
|
-
import { isHydrating } from '
|
|
240
|
+
import { isHydrating } from 'runtime-compiler/config';
|
|
235
241
|
|
|
236
242
|
// false while building the output string
|
|
237
243
|
// true while only building dependencies
|
|
238
244
|
// Use this to for minifiedrs to eliminate unused code path in final output
|
|
239
|
-
isHydrating
|
|
245
|
+
isHydrating;
|
|
240
246
|
```
|
|
241
247
|
|
|
242
248
|
### Compiling external dependencies
|
|
243
249
|
```ts
|
|
244
|
-
import {
|
|
250
|
+
import { injectDependency, markDependency, getDependency } from 'runtime-compiler';
|
|
251
|
+
import { isHydrating } from 'runtime-compiler/config';
|
|
252
|
+
|
|
253
|
+
// Better tree shaking
|
|
254
|
+
const hello = isHydrating
|
|
255
|
+
? markDependency<() => void>()
|
|
256
|
+
: injectDependency<() => void>(`() => console.log('hello')`);
|
|
245
257
|
|
|
246
|
-
const hello = injectLocalDependency<() => void>(`() => console.log('hello')`);
|
|
247
258
|
// After compiler is executed
|
|
248
|
-
|
|
259
|
+
getDependency(hello)();
|
|
249
260
|
```
|
package/compiler/aot.d.ts
CHANGED
package/compiler/aot.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hydrateDependency,
|
|
1
|
+
import{hydrateDependency,setHooks}from"@mapl/framework";import{injectExternalDependency}from"runtime-compiler";import"../core/context.js";export default router=>{let hook=fn=>{injectExternalDependency(fn);return``};setHooks({compileHandler:hook,compileErrorHandler:hook});hydrateDependency(router,[false,false,,``,false],``)};
|
package/compiler/jit.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RouterTag } from "../core/index.js";
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const compileToHandler: (router: RouterTag) => (
|
|
2
|
+
import { type CompiledDependency } from "runtime-compiler";
|
|
3
|
+
export declare const injectCompiledHandler: (router: RouterTag) => CompiledDependency<(req: Request) => any>;
|
|
4
|
+
export declare const compileToHandler: (router: RouterTag) => Promise<(req: Request) => any>;
|
|
5
|
+
export declare const compileToHandlerSync: (router: RouterTag) => ((req: Request) => any);
|
package/compiler/jit.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{compileGroup,createArgSet,AsyncFunction,setHooks,
|
|
1
|
+
import{compileGroup,createArgSet,AsyncFunction,setHooks,contextInit,setContextInit}from"@mapl/framework";import compile from"@mapl/router/method/compiler";import{countParams}from"@mapl/router/path";import{insertItem}from"@mapl/router/method";import{getDependency,injectDependency,injectExternalDependency}from"runtime-compiler";import{evaluate,evaluateSync}from"runtime-compiler/jit";let urlRouter;let paramArgs=createArgSet(new Array(16).fill(0).map((_1,i)=>`q`+i));let compileReturn=(dat,fnAsync,scopeAsync,contextCreated,result)=>{let typ=dat.type;if(typ===`raw`)return`return `+result;fnAsync&&(result=`await `+result);let str=typ==null?`return new Response(`+result+(contextCreated?`,c)`:`)`):contextCreated?`c.headers.push(`+(typ===`json`?`mwj`:`mwh`)+`);return new Response(`+(typ===`json`?`JSON.stringify(`+result+`)`:result)+`,c)`:`return new Response(`+(typ===`json`?`JSON.stringify(`+result+`),mwoj`:result+`,mwoh`)+`)`;return fnAsync&&!scopeAsync?`return (async()=>{`+str+`})()`:str};let compileToState=router=>{urlRouter={};setHooks({compileHandler:(fn,dat,path,scope)=>{let call=injectExternalDependency(fn)+`(`;let paramCount=countParams(path);paramCount>0&&(call+=paramArgs[paramCount]);if(fn.length>paramCount){call+=paramCount===0?`c`:`,c`;if(!scope[1])return contextInit+compileReturn(dat,fn instanceof AsyncFunction,scope[0],true,call+`)`)}return compileReturn(dat,fn instanceof AsyncFunction,scope[0],scope[1],call+`)`)},compileErrorHandler:(fn,dat,scope)=>{let call=injectExternalDependency(fn)+`(t`;if(fn.length>1){call+=`,c`;if(!scope[1])return contextInit+compileReturn(dat,fn instanceof AsyncFunction,scope[0],true,call+`)`)}return compileReturn(dat,fn instanceof AsyncFunction,scope[0],scope[1],call+`)`)},registerCompiled:(method,path,content)=>insertItem(urlRouter,method,path,content)});setContextInit(`let c=mwc(r);`);compileGroup(router,[false,false,,`return mwb`,false],``,``)};export let injectCompiledHandler=router=>{compileToState(router);return injectDependency(`(()=>{var t=["text/html","application/json"].map(c=>["Content-Type",c]),[mwh,mwj]=t,[mwoh,mwoj]=t.map(c=>({headers:[c]})),[mwn,mwb]=[404,400].map(s=>new Response(null,{status:s})),mwc=(r)=>({status:200,req:r,headers:[]});return(r)=>{`+compile(urlRouter,`r.method`,`let u=r.url,s=u.indexOf("/",12)+1,e=u.indexOf("?",s),p=e===-1?u.slice(s):u.slice(s,e);`,1)+`return mwn}})()`)};export let compileToHandler=async router=>{let id=injectCompiledHandler(router);await evaluate();return getDependency(id)};export let compileToHandlerSync=router=>{let id=injectCompiledHandler(router);evaluateSync();return getDependency(id)};
|
package/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{CTX,PATH,REQ,URL,PATH_START,PATH_END,TMP}from"@mapl/framework/constants";export*from"@mapl/framework/constants";export let WEB=`mw`;export let LOCAL_DEPS=WEB+`l`;export let CTX_FN=WEB+`c`;export let CTX_INIT=`let `+CTX+`=`+CTX_FN+`(`+REQ+`);`;export let PARSE_PATH=`let `+URL+`=`+REQ+`.url,`+PATH_START+`=`+URL+`.indexOf("/",12)+1,`+PATH_END+`=`+URL+`.indexOf("?",`+PATH_START+`),`+PATH+`=`+PATH_END+`===-1?`+URL+`.slice(`+PATH_START+`):`+URL+`.slice(`+PATH_START+`,`+PATH_END+`);`;export let CHTML=WEB+`h`;export let CJSON=WEB+`j`;export let OHTML=WEB+`oh`;export let OJSON=WEB+`oj`;export let R404=WEB+`n`;export let R400=WEB+`b`;export let GLOBALS=`var `+TMP+`=["text/html","application/json"].map(c=>["Content-Type",c]),[`+CHTML+`,`+CJSON+`]=`+TMP+`,[`+OHTML+`,`+OJSON+`]=`+TMP+`.map(c=>({headers:[c]})),[`+R404+`,`+R400+`]=[404,400].map(s=>new Response(null,{status:s})),`+CTX_FN+`=(r)=>({status:200,req:r,headers:[]});`;
|
package/core/context.d.ts
CHANGED
package/core/context.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export{};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapl/web",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.5",
|
|
4
4
|
"description": "A compiled web framework for all runtimes",
|
|
5
5
|
"keywords": ["fast", "lightweight", "cross-runtime", "framework", "web", "backend"],
|
|
6
6
|
"repository": {
|
|
@@ -12,28 +12,26 @@
|
|
|
12
12
|
"main": "./index.js",
|
|
13
13
|
"types": "./index.d.ts",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@mapl/framework": "^0.3
|
|
15
|
+
"@mapl/framework": "^0.4.3",
|
|
16
16
|
"@mapl/router": "^0.6.2",
|
|
17
|
-
"@safe-std/error": "^1.0.1"
|
|
17
|
+
"@safe-std/error": "^1.0.1",
|
|
18
|
+
"runtime-compiler": "^1.0.6"
|
|
18
19
|
},
|
|
19
20
|
"optionalDependencies": {
|
|
20
21
|
"secure-headers": "^0.0.6"
|
|
21
22
|
},
|
|
22
23
|
"exports": {
|
|
23
|
-
".": "./index.js",
|
|
24
|
-
"./constants": "./constants.js",
|
|
25
|
-
"./core/utils": "./core/utils.js",
|
|
26
24
|
"./core/middleware": "./core/middleware.js",
|
|
27
|
-
"./
|
|
28
|
-
"./core": "./core/index.js",
|
|
25
|
+
"./constants": "./constants.js",
|
|
29
26
|
"./core/context": "./core/context.js",
|
|
27
|
+
"./core": "./core/index.js",
|
|
28
|
+
"./utils/secure-headers": "./utils/secure-headers.js",
|
|
30
29
|
"./core/handler": "./core/handler.js",
|
|
30
|
+
"./utils/cors": "./utils/cors.js",
|
|
31
|
+
"./core/utils": "./core/utils.js",
|
|
31
32
|
"./utils/headers": "./utils/headers.js",
|
|
32
|
-
"./compiler/aot": "./compiler/aot.js",
|
|
33
33
|
"./compiler/jit": "./compiler/jit.js",
|
|
34
|
-
"
|
|
35
|
-
"./compiler/aot
|
|
36
|
-
"./utils/secure-headers": "./utils/secure-headers.js",
|
|
37
|
-
"./compiler/config": "./compiler/config.js"
|
|
34
|
+
".": "./index.js",
|
|
35
|
+
"./compiler/aot": "./compiler/aot.js"
|
|
38
36
|
}
|
|
39
37
|
}
|
package/compiler/aot-loader.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/compiler/aot-loader.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{hydrating}from"./config.js";hydrating();
|
package/compiler/config.d.ts
DELETED
package/compiler/config.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
let hydrateDependency=false;export let isHydrating=()=>hydrateDependency;export let hydrating=()=>{hydrateDependency=true};
|
package/compiler/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type LocalDependency<T = unknown> = number & [T];
|
|
2
|
-
declare let;
|
|
3
|
-
/**
|
|
4
|
-
* Inject a dependency
|
|
5
|
-
*/
|
|
6
|
-
export declare const injectLocalDependency: <T>(val: string) => LocalDependency<T>;
|
|
7
|
-
/**
|
|
8
|
-
* Get local dependency value
|
|
9
|
-
* @param i
|
|
10
|
-
*/
|
|
11
|
-
export declare const localDependency: <T>(i: LocalDependency<T>) => T;
|
package/compiler/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{externalDependencies}from"@mapl/framework";import{isHydrating}from"./config.js";export let compiledDeps=[];let localDeps=``,localDepsCnt=0;export let injectLocalDependency=val=>{if(!isHydrating())localDeps+=`mwl.push(`+val+`);`;return localDepsCnt++};export let localDependencies=()=>localDeps;export let localDependency=i=>compiledDeps[i];export let stateToArgs=()=>{let depsString=`me,mwc,mwl`;for(let i=0;i<externalDependencies.length;i++)depsString+=`,f`+(i+1);return depsString};
|