@yongdall/assets 0.2.0 → 0.3.0
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/bin.mjs +2 -8
- package/bin.mjs.map +1 -1
- package/cli/assets.mjs +3 -2
- package/cli/assets.mjs.map +1 -1
- package/index.mjs +81 -8
- package/index.mjs.map +1 -1
- package/package.json +6 -5
package/bin.mjs
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import { assets, initAssets } from "#index";
|
|
2
|
+
import cli from "#cli/assets";
|
|
4
3
|
|
|
5
4
|
//#region cli/assets/bin.mjs
|
|
6
|
-
|
|
7
|
-
await initAssets(projectRoot, assetsRoot, pluginAssets, nodeModules, {
|
|
8
|
-
title: configuration.title || "",
|
|
9
|
-
bootModule: configuration.bootModule,
|
|
10
|
-
bootName: configuration.bootName
|
|
11
|
-
}, boot);
|
|
5
|
+
await cli();
|
|
12
6
|
|
|
13
7
|
//#endregion
|
|
14
8
|
//# sourceMappingURL=bin.mjs.map
|
package/bin.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.mjs","names":[],"sources":["../../cli/assets/bin.mjs"],"sourcesContent":["#!/usr/bin/env node\nimport
|
|
1
|
+
{"version":3,"file":"bin.mjs","names":[],"sources":["../../cli/assets/bin.mjs"],"sourcesContent":["#!/usr/bin/env node\n\nimport cli from '#cli/assets';\nawait cli();\n"],"mappings":";;;;AAGA,MAAM,KAAK"}
|
package/cli/assets.mjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { assetsRoot, loadBoot, loadProjectConfiguration, projectRoot } from "@yongdall/configuration";
|
|
2
2
|
import { assets, initAssets } from "#index";
|
|
3
3
|
|
|
4
4
|
//#region cli/assets/cli/assets.mjs
|
|
5
5
|
async function assets_default() {
|
|
6
6
|
const { pluginAssets, nodeModules } = await assets(projectRoot);
|
|
7
|
+
const configuration = await loadProjectConfiguration();
|
|
7
8
|
await initAssets(projectRoot, assetsRoot, pluginAssets, nodeModules, {
|
|
8
9
|
title: configuration.title || "",
|
|
9
10
|
bootModule: configuration.bootModule,
|
|
10
11
|
bootName: configuration.bootName
|
|
11
|
-
},
|
|
12
|
+
}, await loadBoot());
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
//#endregion
|
package/cli/assets.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.mjs","names":[],"sources":["../../../cli/assets/cli/assets.mjs"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"assets.mjs","names":[],"sources":["../../../cli/assets/cli/assets.mjs"],"sourcesContent":["import { assetsRoot, loadBoot, loadProjectConfiguration, projectRoot } from '@yongdall/configuration';\nimport { initAssets, assets } from '#index';\n\n\nexport default async function() {\n\tconst { pluginAssets, nodeModules } = await assets(projectRoot);\n\tconst configuration = await loadProjectConfiguration();\n\tawait initAssets(projectRoot, assetsRoot, pluginAssets, nodeModules, {\n\t\ttitle: configuration.title || '',\n\t\tbootModule: configuration.bootModule,\n\t\tbootName: configuration.bootName,\n\t}, await loadBoot());\n\n}\n"],"mappings":";;;;AAIA,gCAAgC;CAC/B,MAAM,EAAE,cAAc,gBAAgB,MAAM,OAAO,YAAY;CAC/D,MAAM,gBAAgB,MAAM,0BAA0B;AACtD,OAAM,WAAW,aAAa,YAAY,cAAc,aAAa;EACpE,OAAO,cAAc,SAAS;EAC9B,YAAY,cAAc;EAC1B,UAAU,cAAc;EACxB,EAAE,MAAM,UAAU,CAAC"}
|
package/index.mjs
CHANGED
|
@@ -108,9 +108,9 @@ function createImportmap(root, plugins, nodeModules = {}) {
|
|
|
108
108
|
const exports = esm || {};
|
|
109
109
|
const encodedName = encodeURIComponent(pathPosix.join(itemName, version)).replace(/%2F/gi, "/").replace(/%40/g, "@");
|
|
110
110
|
imports[itemName + "/"] = pathPosix.join(`${root}/assets/node_modules/`, encodedName, "./");
|
|
111
|
-
for (const [k,
|
|
112
|
-
const key = pathPosix.join(itemName, k);
|
|
113
|
-
imports[key] = pathPosix.join(`${root}/assets/node_modules/`, encodedName,
|
|
111
|
+
for (const [k, esmPath] of Object.entries(exports)) {
|
|
112
|
+
const key = pathPosix.join(itemName, k.replace(/^[./\/]+/, ""));
|
|
113
|
+
imports[key] = pathPosix.join(`${root}/assets/node_modules/`, encodedName, esmPath.replace(/^[./\/]+/, ""));
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
for (const [origin, assets] of Object.entries(plugins)) {
|
|
@@ -169,6 +169,77 @@ function createImportmap(root, plugins, nodeModules = {}) {
|
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region cli/assets/toESM.mjs
|
|
174
|
+
/**
|
|
175
|
+
* @typedef {Object} PackageJSON
|
|
176
|
+
* @property {"commonjs" | "module"} [type] - 模块类型声明
|
|
177
|
+
* @property {string} [main] - CommonJS 入口点
|
|
178
|
+
* @property {string} [module] - 社区约定的 ESM 入口点 (非标准但广泛使用)
|
|
179
|
+
* @property {string | Record<string, any>} [exports] - 现代导出映射字段
|
|
180
|
+
*/
|
|
181
|
+
/**
|
|
182
|
+
*
|
|
183
|
+
* @param {Record<string, string> | string | null} [value]
|
|
184
|
+
* @param {boolean} [isModule]
|
|
185
|
+
*/
|
|
186
|
+
function readExport(value, isModule) {
|
|
187
|
+
if (!value) return null;
|
|
188
|
+
if (typeof value === "string") {
|
|
189
|
+
if (isModule || value.endsWith(".mjs")) return value;
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
if (typeof value !== "object") return null;
|
|
193
|
+
if (value.import) {
|
|
194
|
+
const esmPath = value.import;
|
|
195
|
+
if (typeof esmPath === "string") return esmPath;
|
|
196
|
+
}
|
|
197
|
+
if (value.module) {
|
|
198
|
+
const esmPath = value.module;
|
|
199
|
+
if (typeof esmPath === "string") return esmPath;
|
|
200
|
+
}
|
|
201
|
+
if (isModule && value.default) {
|
|
202
|
+
const esmPath = value.default;
|
|
203
|
+
if (typeof esmPath === "string") return esmPath;
|
|
204
|
+
}
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* 解析 package.json 并提取 ESM 文件的路径映射。
|
|
209
|
+
*
|
|
210
|
+
* 该函数优先读取 `exports` 字段中的 `import` 条件。
|
|
211
|
+
* 如果不存在 `exports`,则尝试读取 `module` 字段或 `type: module` 下的 `main` 字段。
|
|
212
|
+
*
|
|
213
|
+
* @param {PackageJSON} pkg - package.json 对象内容
|
|
214
|
+
* @returns {Record<string, string> | null}
|
|
215
|
+
* 返回一个对象,键为子路径名称(根路径为空字符串 ""),值为相对文件路径。
|
|
216
|
+
* 如果未检测到 ESM 入口,返回 null。
|
|
217
|
+
*
|
|
218
|
+
*/
|
|
219
|
+
function toESM(pkg) {
|
|
220
|
+
/** @type {Record<string, string>} */
|
|
221
|
+
const result = {};
|
|
222
|
+
const { exports } = pkg;
|
|
223
|
+
const isModule = pkg.type === "module";
|
|
224
|
+
if (exports) {
|
|
225
|
+
const esmPath = readExport(exports, isModule);
|
|
226
|
+
if (esmPath) result[""] = esmPath;
|
|
227
|
+
if (typeof exports === "object") for (const [key, value] of Object.entries(exports)) {
|
|
228
|
+
if (!key.startsWith(".") && key !== ".") continue;
|
|
229
|
+
const esmPath = readExport(value, isModule);
|
|
230
|
+
if (!esmPath) continue;
|
|
231
|
+
result[key] = esmPath;
|
|
232
|
+
}
|
|
233
|
+
if (Object.keys(result)) return result;
|
|
234
|
+
}
|
|
235
|
+
const esmPath = readExport(pkg.module, true) || readExport(pkg.main, isModule);
|
|
236
|
+
if (esmPath) {
|
|
237
|
+
result[""] = esmPath;
|
|
238
|
+
return result;
|
|
239
|
+
}
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
|
|
172
243
|
//#endregion
|
|
173
244
|
//#region cli/assets/assets.mjs
|
|
174
245
|
/** @import {NodeModuleAssets, PluginAssets} from './types.mjs' */
|
|
@@ -205,10 +276,12 @@ async function readPluginPackageJSON(path) {
|
|
|
205
276
|
async function findNodeModule(root, name) {
|
|
206
277
|
for (let basepath = await fsPromises.realpath(root);;) {
|
|
207
278
|
const path = pathFn.resolve(basepath, "node_modules", name);
|
|
208
|
-
const
|
|
279
|
+
const packageJson = await fsPromises.readFile(pathFn.resolve(path, "package.json"), "utf-8").then((v) => JSON.parse(v)).catch(() => null);
|
|
280
|
+
const version = packageJson?.version;
|
|
209
281
|
if (version && typeof version === "string") return {
|
|
210
282
|
path,
|
|
211
|
-
version
|
|
283
|
+
version,
|
|
284
|
+
packageJson
|
|
212
285
|
};
|
|
213
286
|
const parent = pathFn.dirname(basepath);
|
|
214
287
|
if (parent === basepath) break;
|
|
@@ -249,9 +322,10 @@ async function assets(projectRoot) {
|
|
|
249
322
|
for (const [name, value] of Object.entries(await loadCfg("nodeModules") || {})) {
|
|
250
323
|
const info = await findNodeModule(projectRoot, name);
|
|
251
324
|
if (!info) continue;
|
|
325
|
+
const { esm } = value;
|
|
252
326
|
nodeModules[name] = {
|
|
253
|
-
|
|
254
|
-
|
|
327
|
+
esm: typeof esm === "object" && esm || toESM(info.packageJson),
|
|
328
|
+
path: info.path,
|
|
255
329
|
version: String(info.version || value.version || "VERSION").replace(/[^.\da-zA-Z_-]/g, "")
|
|
256
330
|
};
|
|
257
331
|
}
|
|
@@ -409,7 +483,6 @@ async function initAssets(root, assetsDir, pluginAssets, nodeModules, { serverRo
|
|
|
409
483
|
await fsPromises.symlink(pathFn.resolve(assetsDir, `bootloader.${date}.js`), pathFn.resolve(assetsDir, `bootloader.js`));
|
|
410
484
|
await fsPromises.symlink(pathFn.resolve(assetsDir, `importmap.${date}.js`), pathFn.resolve(assetsDir, `importmap.js`));
|
|
411
485
|
await fsPromises.symlink(pathFn.resolve(assetsDir, `importmap.${date}.json`), pathFn.resolve(assetsDir, `importmap.json`));
|
|
412
|
-
await fsPromises.symlink(pathFn.resolve(assetsDir, "index.html"), pathFn.resolve(root, "index.html")).catch(() => {});
|
|
413
486
|
}
|
|
414
487
|
|
|
415
488
|
//#endregion
|
package/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../cli/assets/createImportmap.mjs","../../cli/assets/assets.mjs","../../cli/assets/initAssets.mjs"],"sourcesContent":["/** @import {NodeModuleAssets, PluginAssets} from './types.mjs' */\nimport { pluginIdRegex } from '@yongdall/common';\nimport * as pathPosix from 'node:path/posix';\n\n\n/**\n * \n * @param {string} text \n * @param {Record<string, string | undefined>} values \n * @returns \n */\nfunction replace(text, values) {\n\tconst { index } = /#|\\?/.exec(text) || { index: Infinity };\n\treturn text.replace(/\\{%([^%]*)%\\}/g, (_, k, no) => {\n\t\tconst v = k in values && values[k];\n\t\tif (typeof v !== 'string') { return ''; }\n\t\tconst s = encodeURIComponent(v);\n\t\tif (index < no) { return s; }\n\t\treturn s.replace(/%2F/ig, '/').replace(/%40/g, '@');\n\t});\n}\n/**\n * \n * @param {Record<string, Record<string, string>>} scopes \n * @param {string} scope \n * @returns \n */\nfunction getScope(scopes, scope) {\n\tif (!(scope in scopes)) {\n\t\tscopes[scope] = {};\n\t}\n\treturn scopes[scope];\n}\n\n/**\n * \n * @param {string} serverRoot \n * @param {string} origin \n * @param {string} version \n * @param {Record<string, string>} scope \n * @param {Record<string, string>} map \n * @param {Record<string, string>} [values] \n */\nfunction replaceScope(serverRoot, origin, version, scope, map, values) {\n\n\tconst assetsRoot = `${serverRoot}/assets`;\n\tconst originRoot = `${assetsRoot}/plugins/${origin}/${version}`;\n\tconst value = {\n\t\t...values,\n\t\torigin,\n\t\t'root:server': serverRoot,\n\t\t'root:assets': assetsRoot,\n\t\t'root:origin': originRoot,\n\t};\n\tfor (const [path, url] of Object.entries(map)) {\n\t\tscope[replace(path, { origin })] = replace(url, { url: scope[path], ...value });\n\t}\n}\n/**\n * \n * @param {string} root \n * @param {Record<string, PluginAssets | undefined>} plugins \n * @param {Record<string, NodeModuleAssets>} [nodeModules] \n * @returns \n */\nexport default function createImportmap(root, plugins, nodeModules = {}) {\n\t/** @type {Record<string, string>} */\n\tconst imports = {};\n\t/** @type {Record<string, Record<string, string>>} */\n\tconst scopes = {};\n\n\n\tfor (const [itemName, assets] of Object.entries(plugins)) {\n\t\tif (!assets) { continue; }\n\t\tconst { dir, esm, alias, version } = assets;\n\t\tconst encodedPlugin = encodeURIComponent(itemName).replace(/%2F/ig, '/').replace(/%40/g, '@');\n\n\t\tconst assetsRoot = pathPosix.join(`${root}/assets/plugins/`, itemName, version);\n\t\t/** @type {Record<string, string>} */\n\t\tconst scope = { '@/': pathPosix.join(assetsRoot, `./`) };\n\t\tscopes[`${root}/assets/plugins/${encodedPlugin}/`] = scope;\n\t\tif (!esm) { continue; }\n\t\tconst nameRoot = [...new Set([itemName, pathPosix.join(itemName, dir || '')])];\n\t\tconst indexEsm = alias?.['.'];\n\t\tif (indexEsm && Object.hasOwn(esm, indexEsm)) {\n\t\t\tconst indexFile = esm[indexEsm];\n\t\t\tif (indexFile) {\n\t\t\t\tconst indexPath = pathPosix.join(assetsRoot, indexFile);\n\t\t\t\tscope['@'] = indexPath;\n\t\t\t\tfor (const name of nameRoot) {\n\t\t\t\t\timports[name] = indexPath;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const name of nameRoot) {\n\t\t\tconst path = encodeURIComponent(name).replace(/%2F/ig, '/').replace(/%40/g, '@');\n\t\t\tfor (const [k, v] of Object.entries(esm)) {\n\t\t\t\tconst key = pathPosix.join(name, k);\n\t\t\t\tif (nameRoot.includes(key)) { continue; }\n\t\t\t\timports[key] = pathPosix.join(`${root}/assets/plugins/`, path, version, v);\n\t\t\t}\n\t\t\tif (alias) {\n\t\t\t\tfor (const [k, ev] of Object.entries(alias)) {\n\t\t\t\t\tconst v = Object.hasOwn(esm, ev) && esm[ev];\n\t\t\t\t\tif (!v) { continue; }\n\t\t\t\t\tconst key = pathPosix.join(name, k);\n\t\t\t\t\tif (nameRoot.includes(key)) { continue; }\n\t\t\t\t\timports[key] = pathPosix.join(`${root}/assets/plugins/`, path, version, v);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor (const [itemName, { esm, version }] of Object.entries(nodeModules)) {\n\t\t// TODO: 从 package.json 中加载\n\t\tconst exports = esm || {};\n\t\tconst encodedName = encodeURIComponent(pathPosix.join(itemName, version)).replace(/%2F/ig, '/').replace(/%40/g, '@');\n\t\timports[itemName + '/'] = pathPosix.join(`${root}/assets/node_modules/`, encodedName, './');\n\t\tfor (const [k, v] of Object.entries(exports)) {\n\t\t\tconst key = pathPosix.join(itemName, k);\n\t\t\timports[key] = pathPosix.join(`${root}/assets/node_modules/`, encodedName, v);\n\t\t}\n\t}\n\tfor (const [origin, assets] of Object.entries(plugins)) {\n\t\tif (!assets) { continue; }\n\t\tconst { importmap, esm, version } = assets;\n\n\t\t/** @type {Record<string, string>} */\n\t\tconst esmValues = {};\n\t\tfor (const [k, v] of Object.entries(esm || {})) {\n\t\t\tesmValues[`esm:${k}`] = v;\n\t\t}\n\t\tif (!importmap) { continue; }\n\t\tfor (const [id, map] of Object.entries(importmap)) {\n\t\t\tif (!map) { continue; }\n\t\t\tif (id === '/') {\n\t\t\t\treplaceScope(root, origin, version, imports, map, esmValues);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (id[0] === '/') {\n\t\t\t\treplaceScope(root, origin, version, getScope(scopes, id), map, { ...esmValues, scope: id });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (id === '.') {\n\t\t\t\tconst scope = `${root}/assets/plugins/${origin}/`;\n\t\t\t\treplaceScope(root, origin, version, getScope(scopes, scope), map, { ...esmValues, scope, plugin: origin });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (id[0] === '.') { continue; }\n\t\t\tif (id === '*') {\n\t\t\t\tfor (const plugin of Object.keys(plugins)) {\n\t\t\t\t\tconst scope = `${root}/assets/plugins/${plugin}/`;\n\t\t\t\t\treplaceScope(root, origin, version, getScope(scopes, scope), map, { ...esmValues, scope, plugin });\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!pluginIdRegex.test(id)) { continue; }\n\t\t\tconst scope = `${root}/assets/plugins/${id}/`;\n\t\t\treplaceScope(root, origin, version, getScope(scopes, scope), map, { ...esmValues, scope, plugin: id });\n\t\t}\n\t}\n\n\treturn { imports, scopes };\n}\n","/** @import {NodeModuleAssets, PluginAssets} from './types.mjs' */\nimport * as pathFn from 'node:path';\nimport * as fsPromises from 'node:fs/promises';\nimport { loadCfg } from '@yongdall/configuration';\nimport pluginRoots from '@yongdall/plugins';\n\n/**\n * \n * @param {string} path \n * @returns \n */\nasync function importIfExist(path) {\n\tconst r = await fsPromises.stat(path).catch(() => null);\n\tif (!r?.isFile()) { return null; }\n\treturn await import(path).catch(e => { console.error(e); return null; });\n}\n/**\n * \n * @param {string} path \n */\nasync function readPluginPackageJSON(path) {\n\tconst file = pathFn.resolve(path, 'package.json');\n\tconst packageJson = await fsPromises.readFile(file, 'utf-8')\n\t\t.then(v => JSON.parse(v))\n\t\t.catch(e => { console.error(e); return null; });\n\tconst version = packageJson?.version;\n\tif (version && typeof version === 'string') {\n\t\treturn { version };\n\t}\n\treturn null;\n}\n/**\n * \n * @param {string} root \n * @param {string} name \n */\nasync function findNodeModule(root, name) {\n\tfor (let basepath = await fsPromises.realpath(root); ;) {\n\t\tconst path = pathFn.resolve(basepath, 'node_modules', name);\n\t\tconst packageJson = await fsPromises.readFile(pathFn.resolve(path, 'package.json'), 'utf-8').then(v => JSON.parse(v)).catch(() => null);\n\t\tconst version = packageJson?.version;\n\t\tif (version && typeof version === 'string') {\n\t\t\treturn { path, version };\n\t\t}\n\t\tconst parent = pathFn.dirname(basepath);\n\t\tif (parent === basepath) { break; }\n\t\tbasepath = parent;\n\t}\n\treturn null;\n}\n/**\n * \n * @param {string} projectRoot\n */\nexport default async function assets(projectRoot) {\n\n\n\t/** @type {Record<string, NodeModuleAssets & {path: string}>} */\n\tconst nodeModules = Object.create(null);\n\t/** @type {Record<string, PluginAssets & {path: string}>} */\n\tconst pluginAssets = Object.create(null);\n\n\tconst now = `${Date.now()}`;\n\n\tfor (const [plugin, { root: pluginRoot, development }] of Object.entries(pluginRoots)) {\n\n\t\tconst assets = await importIfExist(pathFn.resolve(pluginRoot, 'assets.yongdall.mjs'));\n\t\tif (!assets) { continue; }\n\t\tconst assetPackage = await readPluginPackageJSON(pluginRoot);\n\t\tpluginAssets[plugin] = {\n\t\t\t...assets, path: pathFn.resolve(pluginRoot, assets.dir || ''),\n\t\t\tversion: !development && String(assets.version || assetPackage?.version || '').replace(/[^.\\da-zA-Z_-]/g, '') || now,\n\t\t};\n\t\tfor (const [name, value] of Object.entries(assets?.nodeModules || {})) {\n\t\t\tif (!value) { continue; }\n\t\t\tconst info = await findNodeModule(pluginRoot, name);\n\t\t\tif (!info) { continue; }\n\t\t\tnodeModules[name] = {\n\t\t\t\t...value, ...info,\n\t\t\t\tversion: String(info.version || value.version || now).replace(/[^.\\da-zA-Z_-]/g, ''),\n\t\t\t};\n\t\t}\n\t}\n\n\tfor (const [name, value] of Object.entries(await loadCfg('nodeModules') || {})) {\n\t\tconst info = await findNodeModule(projectRoot, name);\n\t\tif (!info) { continue; }\n\t\tnodeModules[name] = {\n\t\t\t...value, ...info,\n\t\t\tversion: String(info.version || value.version || 'VERSION').replace(/[^.\\da-zA-Z_-]/g, ''),\n\t\t};\n\t}\n\n\treturn {\n\t\tpluginAssets, nodeModules,\n\t};\n}\n","/** @import { Plugin } from '@yongdall/common' */\n/** @import {NodeModuleAssets, PluginAssets} from './types.mjs' */\nimport * as pathFn from 'node:path';\nimport * as pathPosix from 'node:path/posix';\nimport * as fsPromises from 'node:fs/promises';\nimport createImportmap from './createImportmap.mjs';\n\n/**\n * \n * @param {string} path \n * @returns {Promise<void>}\n */\nexport async function rm(path) {\n const stat = await fsPromises.lstat(path).catch(() => {})\n\t\tif (!stat) { return }\n\t\tif (!stat.isDirectory()) {\n\t\t\tawait fsPromises.unlink(path);\n\t\t\treturn\n\t\t}\n\t\tconst files = await fsPromises.readdir(path);\n\t\tfor (const file of files) {\n\t\t\tawait rm(pathFn.resolve(path, file));\n\t\t}\n\t\tawait fsPromises.rmdir(path);\n}\n\n\n/**\n * \n * @param {string} pluginsRoot \n * @param {Record<string, {path: string; version?: string;}>} plugins \n * @param {string} [type] \n * @returns {Promise<void>}\n */\nexport async function linkPluginAssets(pluginsRoot, plugins, type = 'Plugin Assets') {\n\tawait fsPromises.mkdir(pluginsRoot, { recursive: true })\n\tfor (const [plugin, {path, version}] of Object.entries(plugins)) {\n\t\tconsole.log(`Link ${type}: ${plugin}`);\n\t\tawait fsPromises.mkdir(pathFn.resolve(pluginsRoot, plugin), { recursive: true });\n\t\tawait fsPromises.symlink(path, pathFn.resolve(pluginsRoot, plugin, (version || `VERSION`).replace(/[^.\\da-zA-Z_-]/g, '')));\n}\n\n}\n/**\n * \n * @param {string} bootFileName\n * @param {string} [root] \n * @param {string} [title] \n * @param {string} [boot] \n * @param {string[]} [polyfill] \n * @returns {string}\n */\nexport function getIndexHtml(bootFileName, root, title, boot, polyfill) {\n\treturn `<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<title>${title || '拥道YongDall'}</title>\n${polyfill?.map(src => `<script src=\"${root || ''}/assets/${src}\"></script>`).join('\\n') || ''}\n<script src=\"${root || ''}/assets/${bootFileName}\"${boot ? ` boot-module=\"${boot}\"` : ''}></script>\n</head>\n<body></body>\n</html>\n`\n}\n\n/**\n * \n * @param {ReturnType<typeof createImportmap>} importmap\n * @param {Record<string, PluginAssets>} [plugins] \n */\nexport function getBootloaderJs(importmap, plugins) {\n\treturn `;(function() {\ndocument.write('<script type=\"importmap\">' + JSON.stringify(${JSON.stringify(importmap)}) + '</script>');\nwindow.yongdallPlugins = ${JSON.stringify(getPluginConfig(typeof plugins === 'object' && plugins || {}))};\nconst currentScript = document.currentScript;\nif (!currentScript) { return; }\nconst boot = currentScript.getAttribute('boot-module');\nif (boot) { import(boot); }\n})();`\n}\n/**\n * \n * @param {ReturnType<typeof createImportmap>} importmap\n */\nfunction getImportmapJs(importmap) {\n\treturn `document.write('<script type=\"importmap\">' + JSON.stringify(${JSON.stringify(importmap)}) + '</script>');`\n}\n\n/**\n * \n * @param {string} assetsDir\n */\nexport async function clearAssets(assetsDir) {\n\tconst stat = await fsPromises.lstat(assetsDir).catch(() => {})\n\tif (!stat) { return }\n\tif (!stat.isDirectory()) {\n\t\tawait fsPromises.unlink(assetsDir);\n\t\treturn\n\t}\n\tconst files = await fsPromises.readdir(assetsDir);\n\tfor (const file of files) {\n\t\tif (['index.html', 'plugins', 'node_modules'].includes(file) || /^(bootloader|importmap)(\\.\\d+)?\\.js(on)?$/.test(file)) {\n\t\t\tawait rm(pathFn.resolve(assetsDir, file));\n\t\t}\n\t}\n}\n\n/**\n * \n * @param {Record<string, PluginAssets>} pluginAssetDefines\n */\nfunction getPluginConfig(pluginAssetDefines) {\n\t/** @type {Record<string, Plugin>} */\n\tconst plugins = {}\n\tfor (const [plugin, assets] of Object.entries(pluginAssetDefines)) {\n\t\t/** @type {Plugin} */\n\t\tconst pluginDef = {}\n\t\tplugins[plugin] = pluginDef;\n\t\tif (!assets) { continue; }\n\t\tconst { files, hooks, styles } = assets;\n\t\tif (typeof hooks === 'string' && hooks) { pluginDef.hooks = hooks; }\n\t\tif (files && Object.keys(files).length) { pluginDef.assets = files; }\n\t\tif (Array.isArray(styles) && styles.length) { pluginDef.styles = styles; }\n\t\tpluginDef.version = assets.version;\n\t}\n\treturn plugins;\n}\n\n/**\n * \n * @param {string} root \n * @param {string} assetsDir \n * @param {Record<string, PluginAssets & {path: string}>} pluginAssets\n * @param {Record<string, NodeModuleAssets & {path: string}>} nodeModules\n * @param {object} options \n * @param {string} [options.serverRoot] \n * @param {string} [options.bootModule] \n * @param {string} [options.bootName] \n * @param {string} [options.title] \n * @param {object} bootConfig \n */\nexport default async function initAssets(root, assetsDir, pluginAssets, nodeModules, {\n\tserverRoot, bootModule, bootName, title,\n}, bootConfig) {\n\tconst sRoot = pathPosix.join('/', serverRoot || '', '.').replace(/\\/$/, '')\n\tconst importmap = createImportmap(sRoot, pluginAssets, nodeModules);\n\tawait clearAssets(assetsDir);\n\tawait linkPluginAssets(pathFn.resolve(assetsDir, 'plugins'), pluginAssets)\n\tawait linkPluginAssets(pathFn.resolve(assetsDir, 'node_modules'), nodeModules, 'Node Module')\n\tawait fsPromises.mkdir(pathFn.resolve(assetsDir), { recursive: true })\n\tconst polyfill = Object.values(pluginAssets).flatMap(v => v.polyfill || []);\n\n\tconst date = Date.now();\n\tawait fsPromises.writeFile(\n\t\tpathFn.resolve(assetsDir, `importmap.${date}.js`),\n\t\tgetImportmapJs(importmap),\n\t);\n\tawait fsPromises.writeFile(\n\t\tpathFn.resolve(assetsDir, `importmap.${date}.json`),\n\t\tJSON.stringify(importmap),\n\t);\n\tawait fsPromises.writeFile(\n\t\tpathFn.resolve(assetsDir, `bootloader.${date}.js`),\n\t\tgetBootloaderJs(importmap, pluginAssets),\n\t);\n\tawait fsPromises.writeFile(\n\t\tpathFn.resolve(assetsDir, 'index.html'),\n\t\tgetIndexHtml(`bootloader.${date}.js`, sRoot, title, bootModule, polyfill),\n\t);\n\tawait fsPromises.symlink(\n\t\tpathFn.resolve(assetsDir, `bootloader.${date}.js`),\n\t\tpathFn.resolve(assetsDir, `bootloader.js`),\n\t);\n\tawait fsPromises.symlink(\n\t\tpathFn.resolve(assetsDir, `importmap.${date}.js`),\n\t\tpathFn.resolve(assetsDir, `importmap.js`),\n\t);\n\tawait fsPromises.symlink(\n\t\tpathFn.resolve(assetsDir, `importmap.${date}.json`),\n\t\tpathFn.resolve(assetsDir, `importmap.json`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OAAM,YAAY,UAAU;AAC5B,OAAM,iBAAiB,OAAO,QAAQ,WAAW,UAAU,EAAE,aAAa;AAC1E,OAAM,iBAAiB,OAAO,QAAQ,WAAW,eAAe,EAAE,aAAa,cAAc;AAC7F,OAAM,WAAW,MAAM,OAAO,QAAQ,UAAU,EAAE,EAAE,WAAW,MAAM,CAAC;CACtE,MAAM,WAAW,OAAO,OAAO,aAAa,CAAC,SAAQ,MAAK,EAAE,YAAY,EAAE,CAAC;CAE3E,MAAM,OAAO,KAAK,KAAK;AACvB,OAAM,WAAW,UAChB,OAAO,QAAQ,WAAW,aAAa,KAAK,KAAK,EACjD,eAAe,UAAU,CACzB;AACD,OAAM,WAAW,UAChB,OAAO,QAAQ,WAAW,aAAa,KAAK,OAAO,EACnD,KAAK,UAAU,UAAU,CACzB;AACD,OAAM,WAAW,UAChB,OAAO,QAAQ,WAAW,cAAc,KAAK,KAAK,EAClD,gBAAgB,WAAW,aAAa,CACxC;AACD,OAAM,WAAW,UAChB,OAAO,QAAQ,WAAW,aAAa,EACvC,aAAa,cAAc,KAAK,MAAM,OAAO,OAAO,YAAY,SAAS,CACzE;AACD,OAAM,WAAW,QAChB,OAAO,QAAQ,WAAW,cAAc,KAAK,KAAK,EAClD,OAAO,QAAQ,WAAW,gBAAgB,CAC1C;AACD,OAAM,WAAW,QAChB,OAAO,QAAQ,WAAW,aAAa,KAAK,KAAK,EACjD,OAAO,QAAQ,WAAW,eAAe,CACzC;AACD,OAAM,WAAW,QAChB,OAAO,QAAQ,WAAW,aAAa,KAAK,OAAO,EACnD,OAAO,QAAQ,WAAW,iBAAiB,CAC3C;AACD,OAAM,WAAW,QAChB,OAAO,QAAQ,WAAW,aAAa,EACvC,OAAO,QAAQ,MAAM,aAAa,CAClC,CAAC,YAAY,GAAI"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../cli/assets/createImportmap.mjs","../../cli/assets/toESM.mjs","../../cli/assets/assets.mjs","../../cli/assets/initAssets.mjs"],"sourcesContent":["/** @import {NodeModuleAssets, PluginAssets} from './types.mjs' */\nimport { pluginIdRegex } from '@yongdall/common';\nimport * as pathPosix from 'node:path/posix';\n\n\n/**\n * \n * @param {string} text \n * @param {Record<string, string | undefined>} values \n * @returns \n */\nfunction replace(text, values) {\n\tconst { index } = /#|\\?/.exec(text) || { index: Infinity };\n\treturn text.replace(/\\{%([^%]*)%\\}/g, (_, k, no) => {\n\t\tconst v = k in values && values[k];\n\t\tif (typeof v !== 'string') { return ''; }\n\t\tconst s = encodeURIComponent(v);\n\t\tif (index < no) { return s; }\n\t\treturn s.replace(/%2F/ig, '/').replace(/%40/g, '@');\n\t});\n}\n/**\n * \n * @param {Record<string, Record<string, string>>} scopes \n * @param {string} scope \n * @returns \n */\nfunction getScope(scopes, scope) {\n\tif (!(scope in scopes)) {\n\t\tscopes[scope] = {};\n\t}\n\treturn scopes[scope];\n}\n\n/**\n * \n * @param {string} serverRoot \n * @param {string} origin \n * @param {string} version \n * @param {Record<string, string>} scope \n * @param {Record<string, string>} map \n * @param {Record<string, string>} [values] \n */\nfunction replaceScope(serverRoot, origin, version, scope, map, values) {\n\n\tconst assetsRoot = `${serverRoot}/assets`;\n\tconst originRoot = `${assetsRoot}/plugins/${origin}/${version}`;\n\tconst value = {\n\t\t...values,\n\t\torigin,\n\t\t'root:server': serverRoot,\n\t\t'root:assets': assetsRoot,\n\t\t'root:origin': originRoot,\n\t};\n\tfor (const [path, url] of Object.entries(map)) {\n\t\tscope[replace(path, { origin })] = replace(url, { url: scope[path], ...value });\n\t}\n}\n/**\n * \n * @param {string} root \n * @param {Record<string, PluginAssets | undefined>} plugins \n * @param {Record<string, NodeModuleAssets>} [nodeModules] \n * @returns \n */\nexport default function createImportmap(root, plugins, nodeModules = {}) {\n\t/** @type {Record<string, string>} */\n\tconst imports = {};\n\t/** @type {Record<string, Record<string, string>>} */\n\tconst scopes = {};\n\n\n\tfor (const [itemName, assets] of Object.entries(plugins)) {\n\t\tif (!assets) { continue; }\n\t\tconst { dir, esm, alias, version } = assets;\n\t\tconst encodedPlugin = encodeURIComponent(itemName).replace(/%2F/ig, '/').replace(/%40/g, '@');\n\n\t\tconst assetsRoot = pathPosix.join(`${root}/assets/plugins/`, itemName, version);\n\t\t/** @type {Record<string, string>} */\n\t\tconst scope = { '@/': pathPosix.join(assetsRoot, `./`) };\n\t\tscopes[`${root}/assets/plugins/${encodedPlugin}/`] = scope;\n\t\tif (!esm) { continue; }\n\t\tconst nameRoot = [...new Set([itemName, pathPosix.join(itemName, dir || '')])];\n\t\tconst indexEsm = alias?.['.'];\n\t\tif (indexEsm && Object.hasOwn(esm, indexEsm)) {\n\t\t\tconst indexFile = esm[indexEsm];\n\t\t\tif (indexFile) {\n\t\t\t\tconst indexPath = pathPosix.join(assetsRoot, indexFile);\n\t\t\t\tscope['@'] = indexPath;\n\t\t\t\tfor (const name of nameRoot) {\n\t\t\t\t\timports[name] = indexPath;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const name of nameRoot) {\n\t\t\tconst path = encodeURIComponent(name).replace(/%2F/ig, '/').replace(/%40/g, '@');\n\t\t\tfor (const [k, v] of Object.entries(esm)) {\n\t\t\t\tconst key = pathPosix.join(name, k);\n\t\t\t\tif (nameRoot.includes(key)) { continue; }\n\t\t\t\timports[key] = pathPosix.join(`${root}/assets/plugins/`, path, version, v);\n\t\t\t}\n\t\t\tif (alias) {\n\t\t\t\tfor (const [k, ev] of Object.entries(alias)) {\n\t\t\t\t\tconst v = Object.hasOwn(esm, ev) && esm[ev];\n\t\t\t\t\tif (!v) { continue; }\n\t\t\t\t\tconst key = pathPosix.join(name, k);\n\t\t\t\t\tif (nameRoot.includes(key)) { continue; }\n\t\t\t\t\timports[key] = pathPosix.join(`${root}/assets/plugins/`, path, version, v);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor (const [itemName, { esm, version }] of Object.entries(nodeModules)) {\n\t\tconst exports = esm || {};\n\t\tconst encodedName = encodeURIComponent(pathPosix.join(itemName, version)).replace(/%2F/ig, '/').replace(/%40/g, '@');\n\t\timports[itemName + '/'] = pathPosix.join(`${root}/assets/node_modules/`, encodedName, './');\n\t\tfor (const [k, esmPath] of Object.entries(exports)) {\n\t\t\tconst key = pathPosix.join(itemName, k.replace(/^[./\\/]+/, ''));\n\t\t\timports[key] = pathPosix.join(`${root}/assets/node_modules/`, encodedName, esmPath.replace(/^[./\\/]+/, ''));\n\t\t}\n\t}\n\tfor (const [origin, assets] of Object.entries(plugins)) {\n\t\tif (!assets) { continue; }\n\t\tconst { importmap, esm, version } = assets;\n\n\t\t/** @type {Record<string, string>} */\n\t\tconst esmValues = {};\n\t\tfor (const [k, v] of Object.entries(esm || {})) {\n\t\t\tesmValues[`esm:${k}`] = v;\n\t\t}\n\t\tif (!importmap) { continue; }\n\t\tfor (const [id, map] of Object.entries(importmap)) {\n\t\t\tif (!map) { continue; }\n\t\t\tif (id === '/') {\n\t\t\t\treplaceScope(root, origin, version, imports, map, esmValues);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (id[0] === '/') {\n\t\t\t\treplaceScope(root, origin, version, getScope(scopes, id), map, { ...esmValues, scope: id });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (id === '.') {\n\t\t\t\tconst scope = `${root}/assets/plugins/${origin}/`;\n\t\t\t\treplaceScope(root, origin, version, getScope(scopes, scope), map, { ...esmValues, scope, plugin: origin });\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (id[0] === '.') { continue; }\n\t\t\tif (id === '*') {\n\t\t\t\tfor (const plugin of Object.keys(plugins)) {\n\t\t\t\t\tconst scope = `${root}/assets/plugins/${plugin}/`;\n\t\t\t\t\treplaceScope(root, origin, version, getScope(scopes, scope), map, { ...esmValues, scope, plugin });\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!pluginIdRegex.test(id)) { continue; }\n\t\t\tconst scope = `${root}/assets/plugins/${id}/`;\n\t\t\treplaceScope(root, origin, version, getScope(scopes, scope), map, { ...esmValues, scope, plugin: id });\n\t\t}\n\t}\n\n\treturn { imports, scopes };\n}\n","/**\n * @typedef {Object} PackageJSON\n * @property {\"commonjs\" | \"module\"} [type] - 模块类型声明\n * @property {string} [main] - CommonJS 入口点\n * @property {string} [module] - 社区约定的 ESM 入口点 (非标准但广泛使用)\n * @property {string | Record<string, any>} [exports] - 现代导出映射字段\n */\n\n/**\n * \n * @param {Record<string, string> | string | null} [value] \n * @param {boolean} [isModule] \n */\nfunction readExport(value, isModule) {\n\tif (!value) { return null; }\n\tif (typeof value === 'string') {\n\t\tif (isModule || value.endsWith('.mjs')) {\n\t\t\treturn value;\n\t\t}\n\t\treturn null;\n\t}\n\tif (typeof value !== 'object') { return null; }\n\n\tif (value.import) {\n\t\tconst esmPath = value.import;\n\t\tif (typeof esmPath === 'string') { return esmPath; }\n\t}\n\tif (value.module) {\n\t\tconst esmPath = value.module;\n\t\tif (typeof esmPath === 'string') { return esmPath; }\n\t}\n\tif (isModule && value.default) {\n\t\tconst esmPath = value.default;\n\t\tif (typeof esmPath === 'string') { return esmPath; }\n\t}\n\treturn null;\n\n\n}\n/**\n * 解析 package.json 并提取 ESM 文件的路径映射。\n * \n * 该函数优先读取 `exports` 字段中的 `import` 条件。\n * 如果不存在 `exports`,则尝试读取 `module` 字段或 `type: module` 下的 `main` 字段。\n * \n * @param {PackageJSON} pkg - package.json 对象内容\n * @returns {Record<string, string> | null} \n * 返回一个对象,键为子路径名称(根路径为空字符串 \"\"),值为相对文件路径。\n * 如果未检测到 ESM 入口,返回 null。\n * \n */\nexport function toESM(pkg) {\n\t/** @type {Record<string, string>} */\n\tconst result = {};\n\tconst { exports } = pkg;\n\tconst isModule = pkg.type === 'module';\n\n\tif (exports) {\n\t\tconst esmPath = readExport(exports, isModule);\n\t\tif (esmPath) {\n\t\t\tresult[''] = esmPath;\n\t\t}\n\t\tif (typeof exports === 'object') {\n\t\t\tfor (const [key, value] of Object.entries(exports)) {\n\t\t\t\tif (!key.startsWith('.') && key !== '.') continue;\n\t\t\t\tconst esmPath = readExport(value, isModule);\n\t\t\t\tif (!esmPath) { continue; }\n\t\t\t\tresult[key] = esmPath;\n\t\t\t}\n\t\t}\n\t\tif (Object.keys(result)) { return result; }\n\t}\n\tconst esmPath = readExport(pkg.module, true) || readExport(pkg.main, isModule);\n\tif (esmPath) {\n\t\tresult[''] = esmPath;\n\t\treturn result;\n\t}\n\treturn null;\n}\n","/** @import {NodeModuleAssets, PluginAssets} from './types.mjs' */\nimport * as pathFn from 'node:path';\nimport * as fsPromises from 'node:fs/promises';\nimport { loadCfg } from '@yongdall/configuration';\nimport pluginRoots from '@yongdall/plugins';\nimport { toESM } from './toESM.mjs';\n\n/**\n * \n * @param {string} path \n * @returns \n */\nasync function importIfExist(path) {\n\tconst r = await fsPromises.stat(path).catch(() => null);\n\tif (!r?.isFile()) { return null; }\n\treturn await import(path).catch(e => { console.error(e); return null; });\n}\n/**\n * \n * @param {string} path \n */\nasync function readPluginPackageJSON(path) {\n\tconst file = pathFn.resolve(path, 'package.json');\n\tconst packageJson = await fsPromises.readFile(file, 'utf-8')\n\t\t.then(v => JSON.parse(v))\n\t\t.catch(e => { console.error(e); return null; });\n\tconst version = packageJson?.version;\n\tif (version && typeof version === 'string') {\n\t\treturn { version };\n\t}\n\treturn null;\n}\n/**\n * \n * @param {string} root \n * @param {string} name \n */\nasync function findNodeModule(root, name) {\n\tfor (let basepath = await fsPromises.realpath(root); ;) {\n\t\tconst path = pathFn.resolve(basepath, 'node_modules', name);\n\t\tconst packageJson = await fsPromises.readFile(pathFn.resolve(path, 'package.json'), 'utf-8').then(v => JSON.parse(v)).catch(() => null);\n\t\tconst version = packageJson?.version;\n\t\tif (version && typeof version === 'string') {\n\t\t\treturn { path, version, packageJson };\n\t\t}\n\t\tconst parent = pathFn.dirname(basepath);\n\t\tif (parent === basepath) { break; }\n\t\tbasepath = parent;\n\t}\n\treturn null;\n}\n/**\n * \n * @param {string} projectRoot\n */\nexport default async function assets(projectRoot) {\n\n\n\t/** @type {Record<string, NodeModuleAssets & {path: string}>} */\n\tconst nodeModules = Object.create(null);\n\t/** @type {Record<string, PluginAssets & {path: string}>} */\n\tconst pluginAssets = Object.create(null);\n\n\tconst now = `${Date.now()}`;\n\n\tfor (const [plugin, { root: pluginRoot, development }] of Object.entries(pluginRoots)) {\n\n\t\tconst assets = await importIfExist(pathFn.resolve(pluginRoot, 'assets.yongdall.mjs'));\n\t\tif (!assets) { continue; }\n\t\tconst assetPackage = await readPluginPackageJSON(pluginRoot);\n\t\tpluginAssets[plugin] = {\n\t\t\t...assets, path: pathFn.resolve(pluginRoot, assets.dir || ''),\n\t\t\tversion: !development && String(assets.version || assetPackage?.version || '').replace(/[^.\\da-zA-Z_-]/g, '') || now,\n\t\t};\n\t\tfor (const [name, value] of Object.entries(assets?.nodeModules || {})) {\n\t\t\tif (!value) { continue; }\n\t\t\tconst info = await findNodeModule(pluginRoot, name);\n\t\t\tif (!info) { continue; }\n\t\t\tnodeModules[name] = {\n\t\t\t\t...value, ...info,\n\t\t\t\tversion: String(info.version || value.version || now).replace(/[^.\\da-zA-Z_-]/g, ''),\n\t\t\t};\n\t\t}\n\t}\n\n\tfor (const [name, value] of Object.entries(await loadCfg('nodeModules') || {})) {\n\t\tconst info = await findNodeModule(projectRoot, name);\n\t\tif (!info) { continue; }\n\t\tconst {esm} = value;\n\t\tnodeModules[name] = {\n\t\t\tesm: typeof esm === 'object' && esm || toESM(info.packageJson),\n\t\t\tpath: info.path,\n\t\t\tversion: String(info.version || value.version || 'VERSION').replace(/[^.\\da-zA-Z_-]/g, ''),\n\t\t};\n\t}\n\n\treturn {\n\t\tpluginAssets, nodeModules,\n\t};\n}\n","/** @import { Plugin } from '@yongdall/common' */\n/** @import {NodeModuleAssets, PluginAssets} from './types.mjs' */\nimport * as pathFn from 'node:path';\nimport * as pathPosix from 'node:path/posix';\nimport * as fsPromises from 'node:fs/promises';\nimport createImportmap from './createImportmap.mjs';\n\n/**\n * \n * @param {string} path \n * @returns {Promise<void>}\n */\nexport async function rm(path) {\n const stat = await fsPromises.lstat(path).catch(() => {})\n\t\tif (!stat) { return }\n\t\tif (!stat.isDirectory()) {\n\t\t\tawait fsPromises.unlink(path);\n\t\t\treturn\n\t\t}\n\t\tconst files = await fsPromises.readdir(path);\n\t\tfor (const file of files) {\n\t\t\tawait rm(pathFn.resolve(path, file));\n\t\t}\n\t\tawait fsPromises.rmdir(path);\n}\n\n\n/**\n * \n * @param {string} pluginsRoot \n * @param {Record<string, {path: string; version?: string;}>} plugins \n * @param {string} [type] \n * @returns {Promise<void>}\n */\nexport async function linkPluginAssets(pluginsRoot, plugins, type = 'Plugin Assets') {\n\tawait fsPromises.mkdir(pluginsRoot, { recursive: true })\n\tfor (const [plugin, {path, version}] of Object.entries(plugins)) {\n\t\tconsole.log(`Link ${type}: ${plugin}`);\n\t\tawait fsPromises.mkdir(pathFn.resolve(pluginsRoot, plugin), { recursive: true });\n\t\tawait fsPromises.symlink(path, pathFn.resolve(pluginsRoot, plugin, (version || `VERSION`).replace(/[^.\\da-zA-Z_-]/g, '')));\n}\n\n}\n/**\n * \n * @param {string} bootFileName\n * @param {string} [root] \n * @param {string} [title] \n * @param {string} [boot] \n * @param {string[]} [polyfill] \n * @returns {string}\n */\nexport function getIndexHtml(bootFileName, root, title, boot, polyfill) {\n\treturn `<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<title>${title || '拥道YongDall'}</title>\n${polyfill?.map(src => `<script src=\"${root || ''}/assets/${src}\"></script>`).join('\\n') || ''}\n<script src=\"${root || ''}/assets/${bootFileName}\"${boot ? ` boot-module=\"${boot}\"` : ''}></script>\n</head>\n<body></body>\n</html>\n`\n}\n\n/**\n * \n * @param {ReturnType<typeof createImportmap>} importmap\n * @param {Record<string, PluginAssets>} [plugins] \n */\nexport function getBootloaderJs(importmap, plugins) {\n\treturn `;(function() {\ndocument.write('<script type=\"importmap\">' + JSON.stringify(${JSON.stringify(importmap)}) + '</script>');\nwindow.yongdallPlugins = ${JSON.stringify(getPluginConfig(typeof plugins === 'object' && plugins || {}))};\nconst currentScript = document.currentScript;\nif (!currentScript) { return; }\nconst boot = currentScript.getAttribute('boot-module');\nif (boot) { import(boot); }\n})();`\n}\n/**\n * \n * @param {ReturnType<typeof createImportmap>} importmap\n */\nfunction getImportmapJs(importmap) {\n\treturn `document.write('<script type=\"importmap\">' + JSON.stringify(${JSON.stringify(importmap)}) + '</script>');`\n}\n\n/**\n * \n * @param {string} assetsDir\n */\nexport async function clearAssets(assetsDir) {\n\tconst stat = await fsPromises.lstat(assetsDir).catch(() => {})\n\tif (!stat) { return }\n\tif (!stat.isDirectory()) {\n\t\tawait fsPromises.unlink(assetsDir);\n\t\treturn\n\t}\n\tconst files = await fsPromises.readdir(assetsDir);\n\tfor (const file of files) {\n\t\tif (['index.html', 'plugins', 'node_modules'].includes(file) || /^(bootloader|importmap)(\\.\\d+)?\\.js(on)?$/.test(file)) {\n\t\t\tawait rm(pathFn.resolve(assetsDir, file));\n\t\t}\n\t}\n}\n\n/**\n * \n * @param {Record<string, PluginAssets>} pluginAssetDefines\n */\nfunction getPluginConfig(pluginAssetDefines) {\n\t/** @type {Record<string, Plugin>} */\n\tconst plugins = {}\n\tfor (const [plugin, assets] of Object.entries(pluginAssetDefines)) {\n\t\t/** @type {Plugin} */\n\t\tconst pluginDef = {}\n\t\tplugins[plugin] = pluginDef;\n\t\tif (!assets) { continue; }\n\t\tconst { files, hooks, styles } = assets;\n\t\tif (typeof hooks === 'string' && hooks) { pluginDef.hooks = hooks; }\n\t\tif (files && Object.keys(files).length) { pluginDef.assets = files; }\n\t\tif (Array.isArray(styles) && styles.length) { pluginDef.styles = styles; }\n\t\tpluginDef.version = assets.version;\n\t}\n\treturn plugins;\n}\n\n/**\n * \n * @param {string} root \n * @param {string} assetsDir \n * @param {Record<string, PluginAssets & {path: string}>} pluginAssets\n * @param {Record<string, NodeModuleAssets & {path: string}>} nodeModules\n * @param {object} options \n * @param {string} [options.serverRoot] \n * @param {string} [options.bootModule] \n * @param {string} [options.bootName] \n * @param {string} [options.title] \n * @param {object} bootConfig \n */\nexport default async function initAssets(root, assetsDir, pluginAssets, nodeModules, {\n\tserverRoot, bootModule, bootName, title,\n}, bootConfig) {\n\tconst sRoot = pathPosix.join('/', serverRoot || '', '.').replace(/\\/$/, '')\n\tconst importmap = createImportmap(sRoot, pluginAssets, nodeModules);\n\tawait clearAssets(assetsDir);\n\tawait linkPluginAssets(pathFn.resolve(assetsDir, 'plugins'), pluginAssets)\n\tawait linkPluginAssets(pathFn.resolve(assetsDir, 'node_modules'), nodeModules, 'Node Module')\n\tawait fsPromises.mkdir(pathFn.resolve(assetsDir), { recursive: true })\n\tconst polyfill = Object.values(pluginAssets).flatMap(v => v.polyfill || []);\n\n\tconst date = Date.now();\n\tawait fsPromises.writeFile(\n\t\tpathFn.resolve(assetsDir, `importmap.${date}.js`),\n\t\tgetImportmapJs(importmap),\n\t);\n\tawait fsPromises.writeFile(\n\t\tpathFn.resolve(assetsDir, `importmap.${date}.json`),\n\t\tJSON.stringify(importmap),\n\t);\n\tawait fsPromises.writeFile(\n\t\tpathFn.resolve(assetsDir, `bootloader.${date}.js`),\n\t\tgetBootloaderJs(importmap, pluginAssets),\n\t);\n\tawait fsPromises.writeFile(\n\t\tpathFn.resolve(assetsDir, 'index.html'),\n\t\tgetIndexHtml(`bootloader.${date}.js`, sRoot, title, bootModule, polyfill),\n\t);\n\tawait fsPromises.symlink(\n\t\tpathFn.resolve(assetsDir, `bootloader.${date}.js`),\n\t\tpathFn.resolve(assetsDir, `bootloader.js`),\n\t);\n\tawait fsPromises.symlink(\n\t\tpathFn.resolve(assetsDir, `importmap.${date}.js`),\n\t\tpathFn.resolve(assetsDir, `importmap.js`),\n\t);\n\tawait fsPromises.symlink(\n\t\tpathFn.resolve(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AM,iBAAiB,OAAO,QAAQ,WAAW,UAAU,EAAE,aAAa;AAC1E,OAAM,iBAAiB,OAAO,QAAQ,WAAW,eAAe,EAAE,aAAa,cAAc;AAC7F,OAAM,WAAW,MAAM,OAAO,QAAQ,UAAU,EAAE,EAAE,WAAW,MAAM,CAAC;CACtE,MAAM,WAAW,OAAO,OAAO,aAAa,CAAC,SAAQ,MAAK,EAAE,YAAY,EAAE,CAAC;CAE3E,MAAM,OAAO,KAAK,KAAK;AACvB,OAAM,WAAW,UAChB,OAAO,QAAQ,WAAW,aAAa,KAAK,KAAK,EACjD,eAAe,UAAU,CACzB;AACD,OAAM,WAAW,UAChB,OAAO,QAAQ,WAAW,aAAa,KAAK,OAAO,EACnD,KAAK,UAAU,UAAU,CACzB;AACD,OAAM,WAAW,UAChB,OAAO,QAAQ,WAAW,cAAc,KAAK,KAAK,EAClD,gBAAgB,WAAW,aAAa,CACxC;AACD,OAAM,WAAW,UAChB,OAAO,QAAQ,WAAW,aAAa,EACvC,aAAa,cAAc,KAAK,MAAM,OAAO,OAAO,YAAY,SAAS,CACzE;AACD,OAAM,WAAW,QAChB,OAAO,QAAQ,WAAW,cAAc,KAAK,KAAK,EAClD,OAAO,QAAQ,WAAW,gBAAgB,CAC1C;AACD,OAAM,WAAW,QAChB,OAAO,QAAQ,WAAW,aAAa,KAAK,KAAK,EACjD,OAAO,QAAQ,WAAW,eAAe,CACzC;AACD,OAAM,WAAW,QAChB,OAAO,QAAQ,WAAW,aAAa,KAAK,OAAO,EACnD,OAAO,QAAQ,WAAW,iBAAiB,CAC3C"}
|
package/package.json
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"main": "./index.mjs",
|
|
5
5
|
"imports": {
|
|
6
|
-
"#index": "./index.mjs"
|
|
6
|
+
"#index": "./index.mjs",
|
|
7
|
+
"#cli/assets": "./cli/assets.mjs"
|
|
7
8
|
},
|
|
8
9
|
"exports": {
|
|
9
10
|
".": "./index.mjs"
|
|
10
11
|
},
|
|
11
|
-
"version": "0.
|
|
12
|
+
"version": "0.3.0",
|
|
12
13
|
"description": "",
|
|
13
14
|
"keywords": [],
|
|
14
15
|
"author": "",
|
|
@@ -18,9 +19,9 @@
|
|
|
18
19
|
"test.assets.yongdall": "./test.sh"
|
|
19
20
|
},
|
|
20
21
|
"dependencies": {
|
|
21
|
-
"@yongdall/plugins": "^0.
|
|
22
|
-
"@yongdall/common": "^0.
|
|
23
|
-
"@yongdall/configuration": "^0.
|
|
22
|
+
"@yongdall/plugins": "^0.3.0",
|
|
23
|
+
"@yongdall/common": "^0.3.0",
|
|
24
|
+
"@yongdall/configuration": "^0.3.0"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {}
|
|
26
27
|
}
|