summaryrefslogtreecommitdiff
path: root/deno_typescript/system_loader.js
diff options
context:
space:
mode:
Diffstat (limited to 'deno_typescript/system_loader.js')
-rw-r--r--deno_typescript/system_loader.js41
1 files changed, 27 insertions, 14 deletions
diff --git a/deno_typescript/system_loader.js b/deno_typescript/system_loader.js
index 55f88e8c7..fdf1fa872 100644
--- a/deno_typescript/system_loader.js
+++ b/deno_typescript/system_loader.js
@@ -6,14 +6,17 @@
// @ts-nocheck
/* eslint-disable */
-let System, __instantiate;
+let System, __instantiateAsync, __instantiate;
+
(() => {
- const r = Object.create(null);
+ const r = new Map();
+
System = {
register(id, d, f) {
- r[id] = { d, f, exp: {} };
+ r.set(id, { d, f, exp: {} });
},
};
+
async function dI(mid, src) {
let id = mid.replace(/\.\w+$/i, "");
if (id.includes("./")) {
@@ -30,8 +33,9 @@ let System, __instantiate;
if (s < sa.length) oa.push(...sa.slice(s));
id = oa.reverse().join("/");
}
- return id in r ? gExpA(id) : import(mid);
+ return r.has(id) ? gExpA(id) : import(mid);
}
+
function gC(id, main) {
return {
id,
@@ -39,6 +43,7 @@ let System, __instantiate;
meta: { url: id, main },
};
}
+
function gE(exp) {
return (id, v) => {
v = typeof id === "string" ? { [id]: v } : id;
@@ -51,10 +56,9 @@ let System, __instantiate;
}
};
}
+
function rF(main) {
- let m;
- for (const id in r) {
- m = r[id];
+ for (const [id, m] of r.entries()) {
const { f, exp } = m;
const { execute: e, setters: s } = f(gE(exp), gC(id, id === main));
delete m.f;
@@ -62,9 +66,10 @@ let System, __instantiate;
m.s = s;
}
}
+
async function gExpA(id) {
- if (!(id in r)) return;
- const m = r[id];
+ if (!r.has(id)) return;
+ const m = r.get(id);
if (m.s) {
const { d, e, s } = m;
delete m.s;
@@ -75,9 +80,10 @@ let System, __instantiate;
}
return m.exp;
}
+
function gExp(id) {
- if (!(id in r)) return;
- const m = r[id];
+ if (!r.has(id)) return;
+ const m = r.get(id);
if (m.s) {
const { d, e, s } = m;
delete m.s;
@@ -87,9 +93,16 @@ let System, __instantiate;
}
return m.exp;
}
- __instantiate = (m, a) => {
- System = __instantiate = undefined;
+
+ __instantiateAsync = async (m) => {
+ System = __instantiateAsync = __instantiate = undefined;
+ rF(m);
+ return gExpA(m);
+ };
+
+ __instantiate = (m) => {
+ System = __instantiateAsync = __instantiate = undefined;
rF(m);
- return a ? gExpA(m) : gExp(m);
+ return gExp(m);
};
})();