2026-05-30 09:55:25 +08:00
|
|
|
(function(exports) {
|
|
|
|
|
"use strict";
|
|
|
|
|
const DEFAULT_VERSIONS = {
|
2026-06-03 18:48:56 +08:00
|
|
|
"state": "1.0.11",
|
2026-06-03 18:54:31 +08:00
|
|
|
"bootstrap": "1.0.3",
|
2026-06-03 18:48:56 +08:00
|
|
|
"base": "1.0.7",
|
|
|
|
|
"datatable": "1.0.6",
|
|
|
|
|
"kanban": "1.0.0",
|
|
|
|
|
"mindmap": "1.0.0",
|
|
|
|
|
"chart": "1.0.0",
|
|
|
|
|
"editor": "1.0.0",
|
2026-06-03 18:54:31 +08:00
|
|
|
"loader": "1.0.1"
|
2026-05-30 09:55:25 +08:00
|
|
|
};
|
|
|
|
|
const Loader = {
|
|
|
|
|
load: (...pkgs) => {
|
|
|
|
|
if (typeof document === "undefined") return;
|
|
|
|
|
const currentScript = document.currentScript;
|
|
|
|
|
const currentUrl = currentScript ? currentScript.src : "";
|
2026-06-03 18:48:56 +08:00
|
|
|
let tpl = "https://cdn.jsdelivr.net/npm/@apigo.cc/{project}@{tag}/dist/{project}.min.js";
|
|
|
|
|
if (currentUrl) {
|
|
|
|
|
if (currentUrl.includes("esm.sh")) {
|
|
|
|
|
tpl = "https://esm.sh/@apigo.cc/{project}@{tag}/dist/{project}.min.js";
|
|
|
|
|
} else if (currentUrl.includes("unpkg.com")) {
|
|
|
|
|
tpl = "https://unpkg.com/@apigo.cc/{project}@{tag}/dist/{project}.min.js";
|
|
|
|
|
} else if (currentUrl.includes("unpkg.zhimg.com")) {
|
|
|
|
|
tpl = "https://unpkg.zhimg.com/@apigo.cc/{project}@{tag}/dist/{project}.min.js";
|
|
|
|
|
} else if (currentUrl.includes("npm.elemecdn.com")) {
|
|
|
|
|
tpl = "https://npm.elemecdn.com/@apigo.cc/{project}@{tag}/dist/{project}.min.js";
|
|
|
|
|
} else if (currentUrl.includes("jsdelivr.net")) {
|
|
|
|
|
tpl = "https://cdn.jsdelivr.net/npm/@apigo.cc/{project}@{tag}/dist/{project}.min.js";
|
2026-05-30 09:55:25 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const importMap = { imports: {} };
|
|
|
|
|
pkgs.forEach((pkg) => {
|
|
|
|
|
let [name, version] = pkg.split(":");
|
2026-06-03 18:48:56 +08:00
|
|
|
const key = name.toLowerCase();
|
|
|
|
|
const fullKey = `@apigo.cc/${key}`;
|
|
|
|
|
let url = "";
|
|
|
|
|
try {
|
|
|
|
|
if (typeof localStorage !== "undefined") {
|
|
|
|
|
url = localStorage.getItem(`dev:${fullKey}`) || "";
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
}
|
|
|
|
|
if (!url) {
|
|
|
|
|
version = version || DEFAULT_VERSIONS[key] || "latest";
|
|
|
|
|
url = tpl.replace(/{project}/g, key).replace(/{tag}/g, version);
|
|
|
|
|
}
|
|
|
|
|
importMap.imports[fullKey] = url;
|
2026-05-30 09:55:25 +08:00
|
|
|
});
|
|
|
|
|
const script = document.createElement("script");
|
|
|
|
|
script.type = "importmap";
|
|
|
|
|
script.textContent = JSON.stringify(importMap);
|
|
|
|
|
if (currentScript) {
|
|
|
|
|
currentScript.parentNode.insertBefore(script, currentScript);
|
|
|
|
|
} else {
|
|
|
|
|
document.head.appendChild(script);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
globalThis.Loader = Loader;
|
|
|
|
|
exports.Loader = Loader;
|
|
|
|
|
exports.default = Loader;
|
|
|
|
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
|
|
|
})(this.Loader = this.Loader || {});
|