2020-02-12 16:41:51 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
|
|
|
|
|
|
|
// This is a specialised implementation of a System module loader.
|
|
|
|
|
2020-05-29 06:24:06 -04:00
|
|
|
"use strict";
|
|
|
|
|
2020-02-26 11:59:33 -05:00
|
|
|
// @ts-nocheck
|
|
|
|
/* eslint-disable */
|
2020-06-18 09:06:48 -04:00
|
|
|
let System, __instantiate;
|
2020-02-12 16:41:51 -05:00
|
|
|
(() => {
|
2020-06-17 13:44:40 -04:00
|
|
|
const r = new Map();
|
|
|
|
|
2020-02-12 16:41:51 -05:00
|
|
|
System = {
|
2020-02-26 11:59:33 -05:00
|
|
|
register(id, d, f) {
|
2020-06-17 13:44:40 -04:00
|
|
|
r.set(id, { d, f, exp: {} });
|
2020-03-28 13:03:49 -04:00
|
|
|
},
|
2020-02-12 16:41:51 -05:00
|
|
|
};
|
2020-04-01 23:14:30 -04:00
|
|
|
async function dI(mid, src) {
|
|
|
|
let id = mid.replace(/\.\w+$/i, "");
|
|
|
|
if (id.includes("./")) {
|
|
|
|
const [o, ...ia] = id.split("/").reverse(),
|
|
|
|
[, ...sa] = src.split("/").reverse(),
|
|
|
|
oa = [o];
|
|
|
|
let s = 0,
|
|
|
|
i;
|
|
|
|
while ((i = ia.shift())) {
|
|
|
|
if (i === "..") s++;
|
|
|
|
else if (i === ".") break;
|
|
|
|
else oa.push(i);
|
|
|
|
}
|
|
|
|
if (s < sa.length) oa.push(...sa.slice(s));
|
|
|
|
id = oa.reverse().join("/");
|
|
|
|
}
|
2020-06-17 13:44:40 -04:00
|
|
|
return r.has(id) ? gExpA(id) : import(mid);
|
2020-04-01 23:14:30 -04:00
|
|
|
}
|
2020-06-17 13:44:40 -04:00
|
|
|
|
2020-03-04 08:26:00 -05:00
|
|
|
function gC(id, main) {
|
2020-02-12 16:41:51 -05:00
|
|
|
return {
|
|
|
|
id,
|
2020-04-01 23:14:30 -04:00
|
|
|
import: (m) => dI(m, id),
|
2020-03-28 13:03:49 -04:00
|
|
|
meta: { url: id, main },
|
2020-02-12 16:41:51 -05:00
|
|
|
};
|
2020-03-04 08:26:00 -05:00
|
|
|
}
|
2020-06-17 13:44:40 -04:00
|
|
|
|
2020-03-04 08:26:00 -05:00
|
|
|
function gE(exp) {
|
2020-02-26 11:59:33 -05:00
|
|
|
return (id, v) => {
|
2020-09-30 04:51:19 -04:00
|
|
|
const e = typeof id === "string" ? { [id]: v } : id;
|
|
|
|
for (const [id, value] of Object.entries(e)) {
|
2020-02-12 16:41:51 -05:00
|
|
|
Object.defineProperty(exp, id, {
|
|
|
|
value,
|
|
|
|
writable: true,
|
2020-03-28 13:03:49 -04:00
|
|
|
enumerable: true,
|
2020-02-12 16:41:51 -05:00
|
|
|
});
|
|
|
|
}
|
2020-09-30 04:51:19 -04:00
|
|
|
return v;
|
2020-02-12 16:41:51 -05:00
|
|
|
};
|
2020-03-04 08:26:00 -05:00
|
|
|
}
|
2020-06-17 13:44:40 -04:00
|
|
|
|
2020-03-04 08:26:00 -05:00
|
|
|
function rF(main) {
|
2020-06-17 13:44:40 -04:00
|
|
|
for (const [id, m] of r.entries()) {
|
2020-03-04 08:26:00 -05:00
|
|
|
const { f, exp } = m;
|
|
|
|
const { execute: e, setters: s } = f(gE(exp), gC(id, id === main));
|
2020-02-26 11:59:33 -05:00
|
|
|
delete m.f;
|
2020-03-04 08:26:00 -05:00
|
|
|
m.e = e;
|
|
|
|
m.s = s;
|
2020-02-12 16:41:51 -05:00
|
|
|
}
|
2020-03-04 08:26:00 -05:00
|
|
|
}
|
2020-06-17 13:44:40 -04:00
|
|
|
|
2020-03-04 08:26:00 -05:00
|
|
|
async function gExpA(id) {
|
2020-06-17 13:44:40 -04:00
|
|
|
if (!r.has(id)) return;
|
|
|
|
const m = r.get(id);
|
2020-03-04 08:26:00 -05:00
|
|
|
if (m.s) {
|
|
|
|
const { d, e, s } = m;
|
|
|
|
delete m.s;
|
|
|
|
delete m.e;
|
|
|
|
for (let i = 0; i < s.length; i++) s[i](await gExpA(d[i]));
|
|
|
|
const r = e();
|
|
|
|
if (r) await r;
|
2020-02-12 16:41:51 -05:00
|
|
|
}
|
2020-03-04 08:26:00 -05:00
|
|
|
return m.exp;
|
|
|
|
}
|
2020-06-17 13:44:40 -04:00
|
|
|
|
2020-03-04 08:26:00 -05:00
|
|
|
function gExp(id) {
|
2020-06-17 13:44:40 -04:00
|
|
|
if (!r.has(id)) return;
|
|
|
|
const m = r.get(id);
|
2020-03-04 08:26:00 -05:00
|
|
|
if (m.s) {
|
|
|
|
const { d, e, s } = m;
|
|
|
|
delete m.s;
|
|
|
|
delete m.e;
|
|
|
|
for (let i = 0; i < s.length; i++) s[i](gExp(d[i]));
|
|
|
|
e();
|
2020-02-26 11:59:33 -05:00
|
|
|
}
|
2020-03-04 08:26:00 -05:00
|
|
|
return m.exp;
|
|
|
|
}
|
2020-06-18 09:06:48 -04:00
|
|
|
__instantiate = (m, a) => {
|
|
|
|
System = __instantiate = undefined;
|
2020-03-04 08:26:00 -05:00
|
|
|
rF(m);
|
2020-06-18 09:06:48 -04:00
|
|
|
return a ? gExpA(m) : gExp(m);
|
2020-02-26 11:59:33 -05:00
|
|
|
};
|
2020-02-12 16:41:51 -05:00
|
|
|
})();
|