@xunlei-open/miniapp 0.1.1-beta.4 → 0.1.1-beta.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 CHANGED
@@ -40,4 +40,14 @@ Vue / React 项目安装并声明对应框架模块;Vanilla 无需模块。额
40
40
 
41
41
  事件源码默认放在 `src/events`,并在 manifest 的 `scripts` 中声明。纯事件应用无需页面入口。事件或图标更新后,宿主若有缓存需重新加载应用。
42
42
 
43
+ ### 事件依赖与开发重建
44
+
45
+ 事件入口输出在 `events/`;公共分块、Worker、WASM 等依赖可以按 Vite 默认规则输出到 `assets/`,无需在应用中强制配置 `events/assets/`。Worker 及其依赖修改也会触发事件重建。
46
+
47
+ 开发模式先完成整个构建和校验,再写入依赖,最后逐个原子替换事件入口。编译或校验失败保留已有产物。输出路径必须位于输出目录内,不允许符号链接绕过边界,不得覆盖页面入口、清单或图标。与已有依赖同名且内容不同会报错;请使用包含内容哈希的依赖文件名。同内容资源可以复用。
48
+
49
+ 开发会话期间保留旧依赖,让已经运行的事件和 Worker 仍能加载旧版本;删除源码只清理本次会话拥有且未被外部修改的事件入口。旧哈希资源会增加磁盘占用;停止 dev 后,默认的生产全量构建会清理输出目录,仅保留本次产物。自定义 `emptyOutDir: false` 时由应用自行管理旧文件。
50
+
51
+ 多个入口不是一个原子事务,事件构建与独立的外部写文件进程也不构成跨进程锁;不要让 dev 和生产构建同时写同一个输出目录。入口更新后仍需按宿主缓存行为重载应用。
52
+
43
53
  [示例代码](https://github.com/xunlei-open/miniapp-devkit/tree/main/examples) · [官方文档](https://open.xunlei.com/doc/miniapp/introduction)
package/dist/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as validateBuiltMiniapp, n as buildMiniapp, r as devMiniapp, t as packageMiniapp } from "./package-DgpqUgd3.mjs";
1
+ import { i as validateBuiltMiniapp, n as buildMiniapp, r as devMiniapp, t as packageMiniapp } from "./package-C8hjCdJF.mjs";
2
2
  import { parseArgs } from "node:util";
3
3
  //#region src/cli.ts
4
4
  const HELP = `Xunlei Miniapp CLI
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as readMiniappManifest, c as defineConfig, i as validateBuiltMiniapp, l as defineMiniappModule, n as buildMiniapp, o as validateMiniappDirectory, r as devMiniapp, s as validateSourceManifest, t as packageMiniapp, u as loadMiniappConfig } from "./package-DgpqUgd3.mjs";
1
+ import { a as readMiniappManifest, c as defineConfig, i as validateBuiltMiniapp, l as defineMiniappModule, n as buildMiniapp, o as validateMiniappDirectory, r as devMiniapp, s as validateSourceManifest, t as packageMiniapp, u as loadMiniappConfig } from "./package-C8hjCdJF.mjs";
2
2
  export { buildMiniapp, defineConfig, defineMiniappModule, devMiniapp, loadMiniappConfig, packageMiniapp, readMiniappManifest, validateBuiltMiniapp, validateMiniappDirectory, validateSourceManifest };
@@ -1,9 +1,9 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { createWriteStream, existsSync } from "node:fs";
3
- import { basename, dirname, isAbsolute, relative, resolve, sep, win32 } from "node:path";
3
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep, win32 } from "node:path";
4
4
  import { pathToFileURL } from "node:url";
5
- import { build, createServer, loadConfigFromFile, mergeConfig, minify, normalizePath } from "vite";
6
- import { copyFile, lstat, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
5
+ import { build, createServer, loadConfigFromFile, mergeConfig, minify } from "vite";
6
+ import { copyFile, lstat, mkdir, mkdtemp, readFile, readdir, rename, rm, rmdir, writeFile } from "node:fs/promises";
7
7
  import { pipeline } from "node:stream/promises";
8
8
  import yazl from "yazl";
9
9
  import miniappPlugin from "@xunlei-open/vite-plugin-miniapp";
@@ -303,13 +303,104 @@ function localDevEntry(root, outDir, manifestFile, manifest) {
303
303
  };
304
304
  }
305
305
  //#endregion
306
+ //#region src/event-output.ts
307
+ /** Event entries are replaceable; dependencies are immutable for the dev session. */
308
+ function eventOutput(outDir, protectedFiles) {
309
+ const root = resolve(outDir);
310
+ const key = (name) => name.toLowerCase();
311
+ const protectedNames = new Set(protectedFiles.map(key));
312
+ let previousEntries = /* @__PURE__ */ new Map();
313
+ function target(name) {
314
+ if (!name || isAbsolute(name) || name.includes("\\") || name.includes(":") || name.split("/").some((part) => !part || part === "." || part === ".." || /[. ]$/.test(part))) throw new Error(`Event build emitted an invalid output path: ${name}`);
315
+ const path = resolve(root, name);
316
+ const rel = relative(root, path);
317
+ if (!rel || rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)) throw new Error(`Event build emitted a file outside the output directory: ${name}`);
318
+ return path;
319
+ }
320
+ async function checkPath(path) {
321
+ for (let current = path;; current = dirname(current)) {
322
+ if ((await lstat(current).catch((error) => {
323
+ if (error.code === "ENOENT") return void 0;
324
+ throw error;
325
+ }))?.isSymbolicLink()) throw new Error(`Event output contains a symbolic link: ${current}`);
326
+ if (current === root) break;
327
+ }
328
+ }
329
+ async function existing(path) {
330
+ return readFile(path).catch((error) => {
331
+ if (error.code === "ENOENT") return void 0;
332
+ throw error;
333
+ });
334
+ }
335
+ return async (files, entries, requiredEntries) => {
336
+ const names = /* @__PURE__ */ new Set();
337
+ const contents = /* @__PURE__ */ new Map();
338
+ const unchanged = /* @__PURE__ */ new Set();
339
+ for (const [name, content] of files) {
340
+ target(name);
341
+ if (protectedNames.has(key(name))) throw new Error(`Event build would overwrite a protected file: ${name}`);
342
+ if (names.has(key(name))) throw new Error(`Event build emitted conflicting output names: ${name}`);
343
+ names.add(key(name));
344
+ contents.set(name, Buffer.from(content));
345
+ }
346
+ for (const entry of entries) if (!entry.startsWith("events/") || !files.has(entry)) throw new Error(`Invalid event entry: ${entry}`);
347
+ for (const entry of requiredEntries) {
348
+ const name = relative(root, resolve(root, entry)).split(sep).join("/");
349
+ if (!entries.has(name)) throw new Error(`manifest script "${entry}" has no built event entry`);
350
+ }
351
+ for (const [name, bytes] of contents) {
352
+ const path = target(name);
353
+ await checkPath(path);
354
+ const old = await existing(path);
355
+ if (old?.equals(bytes)) unchanged.add(name);
356
+ if (old && !old.equals(bytes)) {
357
+ if (!entries.has(name)) throw new Error(`Event output conflicts with an existing file: ${name}. Use content-hashed dependency filenames.`);
358
+ const owned = previousEntries.get(name);
359
+ if (owned && !owned.equals(old)) throw new Error(`Event entry was modified outside the event build: ${name}`);
360
+ }
361
+ }
362
+ for (const [name, bytes] of previousEntries) {
363
+ if (entries.has(name)) continue;
364
+ await checkPath(target(name));
365
+ const old = await existing(target(name));
366
+ if (old && !old.equals(bytes)) throw new Error(`Event entry was modified outside the event build: ${name}`);
367
+ }
368
+ await mkdir(root, { recursive: true });
369
+ const staging = await mkdtemp(join(root, ".miniapp-events-"));
370
+ const staged = [];
371
+ try {
372
+ const ordered = [...contents].filter(([name]) => !unchanged.has(name)).sort(([a], [b]) => Number(entries.has(a)) - Number(entries.has(b)));
373
+ for (const [index, [, bytes]] of ordered.entries()) {
374
+ const path = join(staging, String(index));
375
+ staged.push(path);
376
+ await writeFile(path, bytes);
377
+ }
378
+ for (const [index, [name]] of ordered.entries()) {
379
+ const path = target(name);
380
+ await mkdir(dirname(path), { recursive: true });
381
+ await rename(staged[index], path);
382
+ }
383
+ for (const name of previousEntries.keys()) if (!entries.has(name)) await rm(target(name), { force: true });
384
+ previousEntries = new Map([...contents].filter(([name]) => entries.has(name)));
385
+ } finally {
386
+ for (const path of staged) await rm(path, { force: true });
387
+ await rmdir(staging);
388
+ }
389
+ };
390
+ }
391
+ //#endregion
306
392
  //#region src/dev-events.ts
307
393
  /** Build sandbox scripts on disk independently from the page's Vite HMR graph. */
308
394
  function devEvents(config, outDir, manifest, mode) {
309
395
  const eventsDir = resolve(config.root, config.eventsDir);
310
396
  let server;
311
397
  let dependencies = /* @__PURE__ */ new Set();
312
- let outputs = /* @__PURE__ */ new Set();
398
+ const publish = eventOutput(outDir, [
399
+ "manifest.json",
400
+ "index.html",
401
+ ...manifest.entry ? [manifest.entry.url] : [],
402
+ ...manifest.icon ? [manifest.icon] : []
403
+ ]);
313
404
  let pending = Promise.resolve();
314
405
  let stopped = false;
315
406
  let failed = false;
@@ -320,6 +411,16 @@ function devEvents(config, outDir, manifest, mode) {
320
411
  })).some((source) => source.isFile() && !source.name.endsWith(".d.ts") && config.eventsExtensions.some((ext) => source.name.endsWith(ext)));
321
412
  const nextDependencies = /* @__PURE__ */ new Set();
322
413
  const files = /* @__PURE__ */ new Map();
414
+ const entries = /* @__PURE__ */ new Set();
415
+ const trackDependencies = () => ({
416
+ name: "miniapp-dev-events-dependencies",
417
+ generateBundle() {
418
+ for (const file of this.getModuleIds()) {
419
+ const path = file.split("?")[0];
420
+ if (isAbsolute(path)) nextDependencies.add(resolve(path));
421
+ }
422
+ }
423
+ });
323
424
  if (hasEntries) {
324
425
  const eventConfig = await loadMiniappConfig(config.root, {
325
426
  command: "build",
@@ -335,6 +436,10 @@ function devEvents(config, outDir, manifest, mode) {
335
436
  mode,
336
437
  publicDir: false,
337
438
  logLevel: "warn",
439
+ worker: {
440
+ ...eventConfig.vite.worker,
441
+ plugins: () => [...eventConfig.vite.worker?.plugins?.() ?? [], trackDependencies()]
442
+ },
338
443
  plugins: [
339
444
  ...eventConfig.vite.plugins ?? [],
340
445
  miniappPlugin({
@@ -342,15 +447,7 @@ function devEvents(config, outDir, manifest, mode) {
342
447
  eventsDir: config.eventsDir,
343
448
  eventsExtensions: config.eventsExtensions
344
449
  }),
345
- {
346
- name: "miniapp-dev-events-output",
347
- generateBundle() {
348
- for (const file of this.getModuleIds()) {
349
- const path = file.split("?")[0];
350
- if (isAbsolute(path)) nextDependencies.add(resolve(path));
351
- }
352
- }
353
- }
450
+ trackDependencies()
354
451
  ],
355
452
  build: {
356
453
  ...options,
@@ -376,26 +473,16 @@ function devEvents(config, outDir, manifest, mode) {
376
473
  });
377
474
  for (const bundle of Array.isArray(result) ? result : [result]) {
378
475
  if (!("output" in bundle)) throw new Error("Unexpected event build watcher");
379
- for (const file of bundle.output) files.set(file.fileName, file.type === "chunk" ? file.code : file.source);
476
+ for (const file of bundle.output) {
477
+ if (files.has(file.fileName)) throw new Error(`Event build emitted duplicate output: ${file.fileName}`);
478
+ files.set(file.fileName, file.type === "chunk" ? file.code : file.source);
479
+ if (file.type === "chunk" && file.isEntry) entries.add(file.fileName);
480
+ }
380
481
  }
381
482
  }
382
483
  dependencies = nextDependencies;
383
484
  server.watcher.add([...dependencies]);
384
- for (const name of files.keys()) {
385
- const path = normalizePath(relative(outDir, resolve(outDir, name)));
386
- if (!path.startsWith("events/") || path.includes("../")) throw new Error(`Event build emitted a file outside events/: ${name}`);
387
- }
388
- for (const [name, content] of files) {
389
- const path = resolve(outDir, name);
390
- await mkdir(dirname(path), { recursive: true });
391
- await writeFile(path, content);
392
- }
393
- for (const name of outputs) if (!files.has(name)) await rm(resolve(outDir, name), { force: true });
394
- outputs = new Set(files.keys());
395
- for (const script of manifest.scripts ?? []) {
396
- const entry = normalizePath(relative(outDir, resolve(outDir, script.entry)));
397
- if (!outputs.has(entry)) throw new Error(`manifest script "${script.entry}" has no built event entry. Add its source to ${config.eventsDir}.`);
398
- }
485
+ await publish(files, entries, (manifest.scripts ?? []).map((script) => script.entry));
399
486
  if (hasEntries) server.config.logger.info("[miniapp] Event scripts built. Reload the application in the host if it caches scripts.");
400
487
  }
401
488
  function onChange(event, file) {
@@ -576,4 +663,4 @@ async function packageMiniapp(options = {}) {
576
663
  //#endregion
577
664
  export { readMiniappManifest as a, defineConfig as c, validateBuiltMiniapp as i, defineMiniappModule as l, buildMiniapp as n, validateMiniappDirectory as o, devMiniapp as r, validateSourceManifest as s, packageMiniapp as t, loadMiniappConfig as u };
578
665
 
579
- //# sourceMappingURL=package-DgpqUgd3.mjs.map
666
+ //# sourceMappingURL=package-C8hjCdJF.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-C8hjCdJF.mjs","names":["viteBuild"],"sources":["../src/config.ts","../src/validate.ts","../src/dev-entry.ts","../src/event-output.ts","../src/dev-events.ts","../src/vite.ts","../src/package.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { resolve } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport { loadConfigFromFile, mergeConfig, type ConfigEnv, type UserConfig } from 'vite'\nimport type {\n MiniappModule,\n MiniappUserConfig,\n ResolvedMiniappConfig,\n} from './types.js'\n\nconst CONFIG_FILES = [\n 'miniapp.config.ts',\n 'miniapp.config.mts',\n 'miniapp.config.js',\n 'miniapp.config.mjs',\n 'miniapp.config.cts',\n 'miniapp.config.cjs',\n] as const\n\nconst DEFAULT_EVENT_EXTENSIONS = ['.ts', '.js']\n\nexport function defineConfig(config: MiniappUserConfig): MiniappUserConfig {\n return config\n}\n\nexport function defineMiniappModule(module: MiniappModule): MiniappModule {\n return module\n}\n\nasync function loadModules(names: string[], configFile: string, env: ConfigEnv): Promise<UserConfig> {\n if (!Array.isArray(names) || names.some(name => typeof name !== 'string' || !name.trim())) {\n throw new Error('miniapp.config modules must be an array of module names')\n }\n const require = createRequire(configFile)\n let config: UserConfig = {}\n for (const name of new Set(names)) {\n try {\n const { default: module } = await import(pathToFileURL(require.resolve(name)).href)\n if (!module || typeof module !== 'object' || typeof module.name !== 'string' || !module.vite) {\n throw new Error('must export a MiniappModule with name and vite fields')\n }\n config = mergeConfig(config, await resolveViteConfig(module.vite, env))\n } catch (error) {\n throw new Error(`Failed to load miniapp module \"${name}\" from ${configFile}: ${error instanceof Error ? error.message : String(error)}`, { cause: error })\n }\n }\n return config\n}\n\nfunction findConfigFile(root: string): string {\n const matches = CONFIG_FILES.map((file) => resolve(root, file)).filter(existsSync)\n\n if (matches.length === 0) {\n throw new Error(`No miniapp.config file found in ${root}`)\n }\n if (matches.length > 1) {\n throw new Error(\n `Multiple miniapp config files found: ${matches.map((file) => file.split('/').at(-1)).join(', ')}`,\n )\n }\n\n return matches[0]!\n}\n\nfunction assertUserConfig(value: unknown, configFile: string): MiniappUserConfig {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new Error(`${configFile} must export a configuration object`)\n }\n return value as MiniappUserConfig\n}\n\nasync function resolveViteConfig(\n vite: MiniappUserConfig['vite'],\n env: ConfigEnv,\n): Promise<UserConfig> {\n if (!vite) return {}\n const config = typeof vite === 'function' ? await vite(env) : vite\n if (typeof config !== 'object' || config === null || Array.isArray(config)) {\n throw new Error('miniapp.config vite must resolve to a Vite configuration object')\n }\n return config\n}\n\nexport async function loadMiniappConfig(\n rootDirectory: string,\n env: ConfigEnv,\n): Promise<ResolvedMiniappConfig> {\n const root = resolve(rootDirectory)\n const configFile = findConfigFile(root)\n const loaded = await loadConfigFromFile(env, configFile, root)\n\n if (!loaded) {\n throw new Error(`Failed to load ${configFile}`)\n }\n\n const config = assertUserConfig(loaded.config, configFile)\n const eventsExtensions = config.events?.extensions ?? DEFAULT_EVENT_EXTENSIONS\n\n if (eventsExtensions.length === 0) {\n throw new Error('events.extensions must contain at least one file extension')\n }\n\n return {\n root,\n configFile,\n manifestFile: config.manifest ?? 'manifest.json',\n eventsDir: config.events?.dir ?? 'src/events',\n eventsExtensions,\n packageOutDir: config.package?.outDir ?? 'release',\n packageFileName: config.package?.fileName,\n vite: mergeConfig(\n await loadModules(config.modules ?? [], configFile, env),\n await resolveViteConfig(config.vite, env),\n ),\n }\n}\n","import { lstat, readFile, readdir } from 'node:fs/promises'\nimport { isAbsolute, relative, resolve, sep, win32 } from 'node:path'\nimport type { MiniappManifest } from '@xunlei-open/miniapp-types'\nimport type { MiniappValidationResult } from './types.js'\n\nfunction assertNonEmptyString(value: unknown, field: string): asserts value is string {\n if (typeof value !== 'string' || value.trim() === '') {\n throw new Error(`manifest.${field} must be a non-empty string`)\n }\n}\n\nfunction resolvePackagePath(directory: string, value: string, field: string): string {\n if (isAbsolute(value) || win32.isAbsolute(value)) {\n throw new Error(`manifest.${field} must be relative to the package root`)\n }\n\n const target = resolve(directory, value)\n const relativePath = relative(directory, target)\n if (relativePath === '..' || relativePath.startsWith(`..${sep}`)) {\n throw new Error(`manifest.${field} points outside the package root`)\n }\n return target\n}\n\nasync function assertPackageFile(\n directory: string,\n value: unknown,\n field: string,\n): Promise<void> {\n assertNonEmptyString(value, field)\n const target = resolvePackagePath(directory, value, field)\n let stat\n try {\n stat = await lstat(target)\n } catch {\n throw new Error(`manifest.${field} points to a missing file: ${value}`)\n }\n if (!stat.isFile() || stat.isSymbolicLink()) {\n throw new Error(`manifest.${field} must point to a regular package file: ${value}`)\n }\n}\n\nasync function collectFiles(directory: string, current = directory): Promise<string[]> {\n const entries = await readdir(current, { withFileTypes: true })\n const files: string[] = []\n\n for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {\n const absolutePath = resolve(current, entry.name)\n const packagePath = relative(directory, absolutePath).split(sep).join('/')\n\n if (entry.isSymbolicLink()) {\n throw new Error(`Package must not contain symbolic links: ${packagePath}`)\n }\n if (entry.isDirectory()) {\n files.push(...(await collectFiles(directory, absolutePath)))\n continue\n }\n if (entry.isFile()) files.push(packagePath)\n }\n\n return files\n}\n\nexport async function readMiniappManifest(manifestPath: string): Promise<MiniappManifest> {\n let value: unknown\n try {\n value = JSON.parse(await readFile(manifestPath, 'utf8'))\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error)\n throw new Error(`Unable to read manifest: ${reason}`)\n }\n\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new Error('manifest.json must contain a JSON object')\n }\n\n const manifest = value as MiniappManifest\n assertNonEmptyString(manifest.name, 'name')\n assertNonEmptyString(manifest.title, 'title')\n assertNonEmptyString(manifest.version, 'version')\n return manifest\n}\n\nexport async function validateSourceManifest(manifestPath: string): Promise<MiniappManifest> {\n return readMiniappManifest(manifestPath)\n}\n\nexport async function validateMiniappDirectory(\n directoryPath: string,\n): Promise<MiniappValidationResult> {\n const directory = resolve(directoryPath)\n const directoryStat = await lstat(directory).catch(() => undefined)\n if (!directoryStat?.isDirectory()) {\n throw new Error(`Miniapp output directory does not exist: ${directory}`)\n }\n\n const manifestPath = resolve(directory, 'manifest.json')\n const manifest = await readMiniappManifest(manifestPath)\n\n if (manifest.icon !== undefined) {\n await assertPackageFile(directory, manifest.icon, 'icon')\n }\n if (manifest.entry && (manifest.entry.type ?? 'miniapp') === 'miniapp') {\n await assertPackageFile(directory, manifest.entry.url, 'entry.url')\n const html = await readFile(resolve(directory, manifest.entry.url), 'utf8')\n if (html.startsWith('<!-- miniapp-dev-entry:')) {\n throw new Error('Output contains a development entry. Run build before validating or packaging.')\n }\n }\n for (const [index, script] of (manifest.scripts ?? []).entries()) {\n await assertPackageFile(directory, script.entry, `scripts[${index}].entry`)\n }\n\n const files = await collectFiles(directory)\n const sourcemap = files.find((file) => file.endsWith('.map'))\n if (sourcemap) {\n throw new Error(`Package must not contain sourcemaps: ${sourcemap}`)\n }\n const dependency = files.find((file) => file.split('/').includes('node_modules'))\n if (dependency) {\n throw new Error(`Package must not contain node_modules: ${dependency}`)\n }\n\n return { directory, manifestPath, manifest, files }\n}\n","import { createHash } from 'node:crypto'\nimport { copyFile, mkdir, readFile, rm, writeFile } from 'node:fs/promises'\nimport { dirname, isAbsolute, relative, resolve, sep, win32 } from 'node:path'\nimport type { MiniappManifest } from '@xunlei-open/miniapp-types'\nimport { minify, type Plugin, type ViteDevServer } from 'vite'\nimport { parse, parseFragment, serialize, type DefaultTreeAdapterMap } from 'parse5'\n\nfunction localPath(root: string, file: string): string {\n const target = resolve(root, file)\n const rel = relative(root, target)\n if (isAbsolute(file) || win32.isAbsolute(file) || rel === '..' || rel.startsWith(`..${sep}`)) {\n throw new Error(`Miniapp development entry must stay inside its directory: ${file}`)\n }\n return target\n}\n\nexport function localDevEntry(\n root: string,\n outDir: string,\n manifestFile: string,\n manifest: MiniappManifest,\n) {\n const entry = manifest.entry?.url\n if (manifest.entry && (manifest.entry.type ?? 'miniapp') !== 'miniapp') {\n throw new Error('Local HMR requires a miniapp HTML entry')\n }\n const source = entry ? localPath(root, entry) : undefined\n const output = entry ? localPath(outDir, entry) : undefined\n const iconSource = manifest.icon ? localPath(root, manifest.icon) : undefined\n const iconOutput = manifest.icon ? localPath(outDir, manifest.icon) : undefined\n let iconUpdates = Promise.resolve()\n let stopped = false\n const rootFromOutput = relative(outDir, root)\n if (!rootFromOutput || (!rootFromOutput.startsWith(`..${sep}`) && rootFromOutput !== '..' && !isAbsolute(rootFromOutput))) {\n throw new Error('Development output must not be the project root or its parent')\n }\n let server: ViteDevServer\n let entryUrl: string | undefined\n let pagePath: string\n const inlineModules = new Map<string, string>()\n let clientCode: Promise<string> | undefined\n\n function loadClientCode() {\n return clientCode ??= readFile(new URL('./dev-client.js', import.meta.url), 'utf8')\n .then(code => minify('dev-client.js', code))\n .then(result => result.code.trim().replace(/<\\/script/gi, '<\\\\/script'))\n }\n\n async function copyIcon() {\n if (!iconSource || !iconOutput) return\n await mkdir(dirname(iconOutput), { recursive: true })\n await copyFile(iconSource, iconOutput)\n }\n\n function onIconChange(event: string, file: string) {\n if (stopped || !iconSource || resolve(file) !== iconSource) return\n if (!['add', 'change', 'unlink'].includes(event)) return\n iconUpdates = iconUpdates.then(async () => {\n if (stopped) return\n if (event === 'unlink') await rm(iconOutput!, { force: true })\n else await copyIcon()\n server.config.logger.info('[miniapp] Manifest icon updated. Reload the application in the host to refresh its icon.')\n }).catch(error => {\n server.config.logger.error(`[miniapp] Icon sync failed: ${error instanceof Error ? error.message : String(error)}`)\n })\n }\n\n function rewriteEntry(html: string, bootstrap: string): string {\n const document = parse(html)\n const modules = new Map<string, string>()\n function visit(node: DefaultTreeAdapterMap['node']) {\n if ('tagName' in node) {\n for (const attr of node.attrs) {\n if (attr.name === 'src' || attr.name === 'poster' ||\n (attr.name === 'href' && ['link', 'image', 'use'].includes(node.tagName)) ||\n (attr.name === 'data' && node.tagName === 'object')) {\n if (attr.value && !attr.value.startsWith('#')) attr.value = new URL(attr.value, entryUrl).href\n }\n }\n if (node.tagName === 'script' &&\n node.attrs.some(attr => attr.name === 'type' && attr.value.toLowerCase() === 'module') &&\n !node.attrs.some(attr => attr.name === 'src')) {\n // Framework-injected preambles must resolve imports against HTTP, not file://.\n const code = node.childNodes.map(child => 'value' in child ? child.value : '').join('')\n const hash = createHash('sha256').update(code).digest('hex').slice(0, 16)\n const url = new URL(`./@miniapp-dev/inline-${modules.size}-${hash}.js`, entryUrl)\n const id = url.pathname.slice(server.config.base.length - 1)\n modules.set(id, code)\n node.childNodes = []\n node.attrs.push({ name: 'src', value: url.href })\n }\n if (node.tagName === 'script' &&\n node.attrs.some(attr => attr.name === 'type' && attr.value.toLowerCase() === 'module') &&\n node.attrs.some(attr => attr.name === 'src' && new URL(attr.value, entryUrl).origin === new URL(entryUrl!).origin)) {\n node.attrs.push({ name: 'data-miniapp-dev-module', value: '' })\n // Inert placeholders do not hold DOMContentLoaded or window.load open.\n node.attrs.find(attr => attr.name === 'type')!.value = 'application/x-miniapp-dev-module'\n node.attrs.find(attr => attr.name === 'src')!.name = 'data-miniapp-dev-src'\n }\n }\n if ('childNodes' in node) node.childNodes.forEach(visit)\n if ('content' in node) visit(node.content as DefaultTreeAdapterMap['documentFragment'])\n }\n visit(document)\n const htmlNode = document.childNodes.find(node => 'tagName' in node && node.tagName === 'html') as DefaultTreeAdapterMap['element']\n const head = htmlNode.childNodes.find(node => 'tagName' in node && node.tagName === 'head') as DefaultTreeAdapterMap['element']\n const script = parseFragment(`<script data-miniapp-dev-load-error>${bootstrap}</script>`).childNodes[0] as DefaultTreeAdapterMap['element']\n script.attrs.push({ name: 'data-miniapp-dev-probe', value: new URL(server.config.base, entryUrl).href })\n script.parentNode = head\n head.childNodes.unshift(script)\n inlineModules.clear()\n for (const [path, code] of modules) inlineModules.set(path, code)\n return serialize(document)\n }\n\n async function writeEntry() {\n if (!source || !output) return\n const html = await server.transformIndexHtml(pagePath, await readFile(source, 'utf8'))\n await mkdir(dirname(output), { recursive: true })\n await writeFile(output, `<!-- miniapp-dev-entry: run build before packaging -->\\n${rewriteEntry(html, await loadClientCode())}`)\n // Remove only bootstrap files generated by the previous external-script version.\n const oldClient = resolve(dirname(output), 'miniapp-dev-client.js')\n const oldCode = await readFile(oldClient, 'utf8').catch(() => '')\n if (oldCode.startsWith('// Local development bootstrap: must work without the dev server.')) {\n await rm(oldClient, { force: true })\n }\n }\n\n const plugin: Plugin = {\n name: 'miniapp-local-dev-entry',\n apply: 'serve',\n async closeBundle() {\n stopped = true\n server?.watcher.off('all', onIconChange)\n await iconUpdates\n },\n resolveId(id) {\n if (inlineModules.has(id.split('?')[0]!)) return id\n },\n load(id) {\n return inlineModules.get(id.split('?')[0]!)\n },\n async handleHotUpdate(context) {\n if (resolve(context.file) !== source) return\n await writeEntry()\n // Vite's HTML reload filter otherwise compares against the file:// pathname.\n context.server.ws.send({ type: 'full-reload', path: '*' })\n return []\n },\n }\n\n return {\n plugin,\n async write(devServer: ViteDevServer) {\n server = devServer\n await mkdir(outDir, { recursive: true })\n if (entry) {\n const url = server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0]\n if (!url) throw new Error('Cannot determine the Vite development server URL')\n server.config.server.origin ??= new URL(url).origin\n entryUrl = new URL(entry.replaceAll('\\\\', '/'), url).href\n pagePath = new URL(entryUrl).pathname\n await writeEntry()\n }\n await copyFile(resolve(root, manifestFile), resolve(outDir, 'manifest.json'))\n await copyIcon()\n if (iconSource) {\n server.watcher.add(iconSource)\n server.watcher.on('all', onIconChange)\n }\n },\n }\n}\n","import { lstat, mkdir, mkdtemp, readFile, rename, rm, rmdir, writeFile } from 'node:fs/promises'\nimport { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'\n\nexport type EventFiles = Map<string, string | Uint8Array>\n\n/** Event entries are replaceable; dependencies are immutable for the dev session. */\nexport function eventOutput(outDir: string, protectedFiles: string[]) {\n const root = resolve(outDir)\n const key = (name: string) => name.toLowerCase()\n const protectedNames = new Set(protectedFiles.map(key))\n let previousEntries = new Map<string, Buffer>()\n\n function target(name: string) {\n if (!name || isAbsolute(name) || name.includes('\\\\') || name.includes(':')\n || name.split('/').some(part => !part || part === '.' || part === '..' || /[. ]$/.test(part))) {\n throw new Error(`Event build emitted an invalid output path: ${name}`)\n }\n const path = resolve(root, name)\n const rel = relative(root, path)\n if (!rel || rel === '..' || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {\n throw new Error(`Event build emitted a file outside the output directory: ${name}`)\n }\n return path\n }\n\n async function checkPath(path: string) {\n // Do not allow symlinks/junctions to bypass the output-directory boundary.\n for (let current = path; ; current = dirname(current)) {\n const stat = await lstat(current).catch(error => {\n if (error.code === 'ENOENT') return undefined\n throw error\n })\n if (stat?.isSymbolicLink()) throw new Error(`Event output contains a symbolic link: ${current}`)\n if (current === root) break\n }\n }\n\n async function existing(path: string) {\n return readFile(path).catch(error => {\n if (error.code === 'ENOENT') return undefined\n throw error\n })\n }\n\n return async (files: EventFiles, entries: Set<string>, requiredEntries: string[]) => {\n const names = new Set<string>()\n const contents = new Map<string, Buffer>()\n const unchanged = new Set<string>()\n // Validate the entire result before publishing any part of it.\n for (const [name, content] of files) {\n target(name)\n if (protectedNames.has(key(name))) throw new Error(`Event build would overwrite a protected file: ${name}`)\n if (names.has(key(name))) throw new Error(`Event build emitted conflicting output names: ${name}`)\n names.add(key(name))\n contents.set(name, Buffer.from(content))\n }\n for (const entry of entries) {\n if (!entry.startsWith('events/') || !files.has(entry)) throw new Error(`Invalid event entry: ${entry}`)\n }\n for (const entry of requiredEntries) {\n const name = relative(root, resolve(root, entry)).split(sep).join('/')\n if (!entries.has(name)) throw new Error(`manifest script \"${entry}\" has no built event entry`)\n }\n for (const [name, bytes] of contents) {\n const path = target(name)\n await checkPath(path)\n const old = await existing(path)\n if (old?.equals(bytes)) unchanged.add(name)\n if (old && !old.equals(bytes)) {\n if (!entries.has(name)) throw new Error(`Event output conflicts with an existing file: ${name}. Use content-hashed dependency filenames.`)\n const owned = previousEntries.get(name)\n if (owned && !owned.equals(old)) throw new Error(`Event entry was modified outside the event build: ${name}`)\n }\n }\n // A removed entry is ours only while its bytes still match what we published.\n for (const [name, bytes] of previousEntries) {\n if (entries.has(name)) continue\n await checkPath(target(name))\n const old = await existing(target(name))\n if (old && !old.equals(bytes)) throw new Error(`Event entry was modified outside the event build: ${name}`)\n }\n\n await mkdir(root, { recursive: true })\n const staging = await mkdtemp(join(root, '.miniapp-events-'))\n const staged: string[] = []\n try {\n const ordered = [...contents].filter(([name]) => !unchanged.has(name))\n .sort(([a], [b]) => Number(entries.has(a)) - Number(entries.has(b)))\n for (const [index, [, bytes]] of ordered.entries()) {\n const path = join(staging, String(index))\n staged.push(path)\n await writeFile(path, bytes)\n }\n // Publish dependencies first, then atomically replace each entry file.\n for (const [index, [name]] of ordered.entries()) {\n const path = target(name)\n await mkdir(dirname(path), { recursive: true })\n await rename(staged[index]!, path)\n }\n for (const name of previousEntries.keys()) {\n if (!entries.has(name)) await rm(target(name), { force: true })\n }\n previousEntries = new Map([...contents].filter(([name]) => entries.has(name)))\n // Keep old dependencies: an already-running event/Worker may still import them.\n } finally {\n for (const path of staged) await rm(path, { force: true })\n await rmdir(staging)\n }\n }\n}\n","import { readdir } from 'node:fs/promises'\nimport { dirname, isAbsolute, relative, resolve, sep } from 'node:path'\nimport type { MiniappManifest } from '@xunlei-open/miniapp-types'\nimport miniappPlugin from '@xunlei-open/vite-plugin-miniapp'\nimport { build, type Plugin, type ViteDevServer } from 'vite'\nimport { eventOutput } from './event-output.js'\nimport { loadMiniappConfig } from './config.js'\nimport type { ResolvedMiniappConfig } from './types.js'\n\n/** Build sandbox scripts on disk independently from the page's Vite HMR graph. */\nexport function devEvents(config: ResolvedMiniappConfig, outDir: string, manifest: MiniappManifest, mode: string) {\n const eventsDir = resolve(config.root, config.eventsDir)\n let server: ViteDevServer\n let dependencies = new Set<string>()\n const publish = eventOutput(outDir, ['manifest.json', 'index.html',\n ...(manifest.entry ? [manifest.entry.url] : []),\n ...(manifest.icon ? [manifest.icon] : []),\n ])\n let pending = Promise.resolve()\n let stopped = false\n let failed = false\n\n async function rebuild() {\n const sources = await readdir(eventsDir, { withFileTypes: true }).catch(error => {\n if (error.code === 'ENOENT') return []\n throw error\n })\n const hasEntries = sources.some(source => source.isFile()\n && !source.name.endsWith('.d.ts')\n && config.eventsExtensions.some(ext => source.name.endsWith(ext)))\n const nextDependencies = new Set<string>()\n const files = new Map<string, string | Uint8Array>()\n const entries = new Set<string>()\n const trackDependencies = (): Plugin => ({\n name: 'miniapp-dev-events-dependencies',\n generateBundle() {\n for (const file of this.getModuleIds()) {\n const path = file.split('?')[0]!\n if (isAbsolute(path)) nextDependencies.add(resolve(path))\n }\n },\n })\n if (hasEntries) {\n // Vite plugins can hold server state. Never reuse the live page's instances.\n const eventConfig = await loadMiniappConfig(config.root, {\n command: 'build', mode, isSsrBuild: false, isPreview: false,\n })\n const options = eventConfig.vite.build\n const result = await build({\n ...eventConfig.vite,\n root: config.root,\n configFile: false,\n mode,\n publicDir: false,\n logLevel: 'warn',\n worker: {\n ...eventConfig.vite.worker,\n plugins: () => [...(eventConfig.vite.worker?.plugins?.() ?? []), trackDependencies()],\n },\n plugins: [\n ...(eventConfig.vite.plugins ?? []),\n miniappPlugin({\n eventsOnly: true,\n eventsDir: config.eventsDir,\n eventsExtensions: config.eventsExtensions,\n }),\n trackDependencies(),\n ],\n build: {\n ...options,\n outDir,\n emptyOutDir: false,\n copyPublicDir: false,\n write: false,\n watch: null,\n lib: false,\n ssr: false,\n sourcemap: false,\n minify: false,\n manifest: false,\n ssrManifest: false,\n // Only sandbox entries; never rebuild/overwrite the local HMR HTML.\n rolldownOptions: undefined,\n rollupOptions: {\n ...options?.rollupOptions,\n ...options?.rolldownOptions,\n input: undefined,\n output: undefined,\n },\n },\n })\n for (const bundle of Array.isArray(result) ? result : [result]) {\n if (!('output' in bundle)) throw new Error('Unexpected event build watcher')\n for (const file of bundle.output) {\n if (files.has(file.fileName)) throw new Error(`Event build emitted duplicate output: ${file.fileName}`)\n files.set(file.fileName, file.type === 'chunk' ? file.code : file.source)\n if (file.type === 'chunk' && file.isEntry) entries.add(file.fileName)\n }\n }\n }\n\n dependencies = nextDependencies\n server.watcher.add([...dependencies])\n await publish(files, entries, (manifest.scripts ?? []).map(script => script.entry))\n if (hasEntries) server.config.logger.info('[miniapp] Event scripts built. Reload the application in the host if it caches scripts.')\n }\n\n function onChange(event: string, file: string) {\n if (stopped || !['add', 'change', 'unlink'].includes(event)) return\n const path = resolve(file)\n const entry = dirname(path) === eventsDir && config.eventsExtensions.some(ext => path.endsWith(ext))\n const relativeToOutput = relative(outDir, path)\n if (relativeToOutput !== '..' && !relativeToOutput.startsWith(`..${sep}`) && !isAbsolute(relativeToOutput)) return\n if (!entry && !dependencies.has(path) && !failed) return\n pending = pending.then(async () => {\n if (stopped) return\n try {\n await rebuild()\n failed = false\n } catch (error) {\n failed = true\n server.config.logger.error(`[miniapp] Event build failed: ${error instanceof Error ? error.message : String(error)}`)\n }\n })\n }\n\n const plugin: Plugin = {\n name: 'miniapp-dev-events',\n apply: 'serve',\n async closeBundle() {\n stopped = true\n server?.watcher.off('all', onChange)\n await pending\n },\n }\n\n return {\n plugin,\n async start(devServer: ViteDevServer) {\n server = devServer\n await rebuild()\n server.watcher.add(eventsDir)\n server.watcher.on('all', onChange)\n },\n }\n}\n","import { resolve } from 'node:path'\nimport miniappPlugin from '@xunlei-open/vite-plugin-miniapp'\nimport {\n build as viteBuild,\n createServer,\n mergeConfig,\n type ConfigEnv,\n type InlineConfig,\n type ViteDevServer,\n} from 'vite'\nimport { loadMiniappConfig } from './config.js'\nimport { localDevEntry } from './dev-entry.js'\nimport { devEvents } from './dev-events.js'\nimport type {\n BuildMiniappOptions,\n DevMiniappOptions,\n ResolvedMiniappConfig,\n} from './types.js'\nimport {\n validateMiniappDirectory,\n validateSourceManifest,\n} from './validate.js'\n\nfunction configEnv(command: ConfigEnv['command'], mode: string): ConfigEnv {\n return { command, mode, isSsrBuild: false, isPreview: false }\n}\n\nfunction createInlineConfig(config: ResolvedMiniappConfig): InlineConfig {\n return mergeConfig(config.vite, {\n root: config.root,\n configFile: false,\n plugins: [\n miniappPlugin({\n eventsDir: config.eventsDir,\n eventsExtensions: config.eventsExtensions,\n manifestFile: config.manifestFile,\n }),\n ],\n })\n}\n\nexport function resolveOutputDirectory(config: ResolvedMiniappConfig): string {\n return resolve(config.root, config.vite.build?.outDir ?? 'dist')\n}\n\nexport async function buildMiniapp(\n options: BuildMiniappOptions = {},\n): Promise<{ config: ResolvedMiniappConfig; outDir: string }> {\n const root = options.root ?? process.cwd()\n const mode = options.mode ?? 'production'\n const config = await loadMiniappConfig(root, configEnv('build', mode))\n\n await viteBuild(createInlineConfig(config))\n\n const outDir = resolveOutputDirectory(config)\n await validateMiniappDirectory(outDir)\n return { config, outDir }\n}\n\nexport async function validateBuiltMiniapp(\n options: BuildMiniappOptions = {},\n) {\n const root = options.root ?? process.cwd()\n const mode = options.mode ?? 'production'\n const config = await loadMiniappConfig(root, configEnv('build', mode))\n return validateMiniappDirectory(resolveOutputDirectory(config))\n}\n\nexport async function devMiniapp(\n options: DevMiniappOptions = {},\n): Promise<ViteDevServer> {\n const root = options.root ?? process.cwd()\n const mode = options.mode ?? 'development'\n const config = await loadMiniappConfig(root, configEnv('serve', mode))\n const manifest = await validateSourceManifest(\n resolve(config.root, config.manifestFile),\n )\n\n const inlineConfig = createInlineConfig(config)\n const outDir = resolveOutputDirectory(config)\n const devEntry = localDevEntry(config.root, outDir, config.manifestFile, manifest)\n const events = devEvents(config, outDir, manifest, mode)\n inlineConfig.plugins = [...(inlineConfig.plugins ?? []), devEntry.plugin, events.plugin]\n inlineConfig.server = {\n ...inlineConfig.server,\n // Local file pages have an opaque (\"null\") origin. Explicit user CORS wins.\n cors: inlineConfig.server?.cors ?? {\n origin: [/^https?:\\/\\/(?:(?:[^:]+\\.)?localhost|127\\.0\\.0\\.1|\\[::1\\])(?::\\d+)?$/, 'null'],\n },\n ...(options.host ? { host: options.host } : {}),\n ...(options.port ? { port: options.port } : {}),\n }\n if (!manifest.entry) {\n // Keep Vite's file watcher for sandbox builds without opening an HTTP/HMR server.\n inlineConfig.server.middlewareMode = true\n inlineConfig.server.hmr = false\n inlineConfig.server.open = false\n }\n\n const server = await createServer(inlineConfig)\n try {\n if (manifest.entry) await server.listen()\n await devEntry.write(server)\n await events.start(server)\n } catch (error) {\n await server.close()\n throw error\n }\n if (manifest.entry) {\n server.printUrls()\n server.bindCLIShortcuts({ print: true })\n }\n console.log(`\\nLoad this directory in Xunlei: ${outDir}\\n`)\n return server\n}\n","import { createWriteStream } from 'node:fs'\nimport { mkdir, rm } from 'node:fs/promises'\nimport { basename, dirname, isAbsolute, relative, resolve, sep } from 'node:path'\nimport { pipeline } from 'node:stream/promises'\nimport yazl from 'yazl'\nimport { loadMiniappConfig } from './config.js'\nimport type {\n PackageMiniappOptions,\n ResolvedMiniappConfig,\n} from './types.js'\nimport { validateMiniappDirectory } from './validate.js'\nimport { buildMiniapp, resolveOutputDirectory } from './vite.js'\n\nconst ZIP_DATE = new Date('1980-01-01T00:00:00.000Z')\n\nfunction safeFilePart(value: string): string {\n return value.trim().replace(/[^a-zA-Z0-9._-]+/g, '-').replace(/^-+|-+$/g, '') || 'miniapp'\n}\n\nfunction resolveArchivePath(\n config: ResolvedMiniappConfig,\n manifest: { name: string; version: string },\n explicitPath?: string,\n): string {\n if (explicitPath) {\n if (!explicitPath.toLowerCase().endsWith('.zip')) {\n throw new Error('--out must end with .zip')\n }\n return isAbsolute(explicitPath) ? explicitPath : resolve(config.root, explicitPath)\n }\n\n const fileName =\n config.packageFileName ??\n `${safeFilePart(manifest.name)}-${safeFilePart(manifest.version)}.zip`\n if (!fileName.toLowerCase().endsWith('.zip')) {\n throw new Error('package.fileName must end with .zip')\n }\n if (basename(fileName) !== fileName) {\n throw new Error('package.fileName must not contain a directory')\n }\n return resolve(config.root, config.packageOutDir, fileName)\n}\n\nasync function writeZip(\n directory: string,\n files: string[],\n outFile: string,\n): Promise<void> {\n await mkdir(dirname(outFile), { recursive: true })\n\n const archive = new yazl.ZipFile()\n const output = createWriteStream(outFile)\n const completed = pipeline(archive.outputStream, output)\n try {\n for (const file of files) {\n archive.addFile(resolve(directory, file), file, {\n mtime: ZIP_DATE,\n mode: 0o644,\n compress: true,\n })\n }\n archive.end()\n await completed\n } catch (error) {\n await rm(outFile, { force: true })\n throw error\n }\n}\n\nexport async function packageMiniapp(\n options: PackageMiniappOptions = {},\n): Promise<{ outFile: string; outDir: string }> {\n let config: ResolvedMiniappConfig\n let outDir: string\n\n if (options.build ?? true) {\n ;({ config, outDir } = await buildMiniapp(options))\n } else {\n const root = options.root ?? process.cwd()\n const mode = options.mode ?? 'production'\n config = await loadMiniappConfig(root, {\n command: 'build',\n mode,\n isSsrBuild: false,\n isPreview: false,\n })\n outDir = resolveOutputDirectory(config)\n }\n\n const validated = await validateMiniappDirectory(outDir)\n const outFile = resolveArchivePath(config, validated.manifest, options.outFile)\n const archiveRelativeToOutput = relative(outDir, outFile)\n if (\n archiveRelativeToOutput === '' ||\n (!archiveRelativeToOutput.startsWith(`..${sep}`) && archiveRelativeToOutput !== '..')\n ) {\n throw new Error('Package output must be outside the build output directory')\n }\n\n await writeZip(outDir, validated.files, outFile)\n return { outFile, outDir }\n}\n"],"mappings":";;;;;;;;;;;;AAWA,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,2BAA2B,CAAC,OAAO,KAAK;AAE9C,SAAgB,aAAa,QAA8C;CACzE,OAAO;AACT;AAEA,SAAgB,oBAAoB,QAAsC;CACxE,OAAO;AACT;AAEA,eAAe,YAAY,OAAiB,YAAoB,KAAqC;CACnG,IAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,MAAK,SAAQ,OAAO,SAAS,YAAY,CAAC,KAAK,KAAK,CAAC,GACtF,MAAM,IAAI,MAAM,yDAAyD;CAE3E,MAAM,UAAU,cAAc,UAAU;CACxC,IAAI,SAAqB,CAAC;CAC1B,KAAK,MAAM,QAAQ,IAAI,IAAI,KAAK,GAC9B,IAAI;EACF,MAAM,EAAE,SAAS,WAAW,MAAM,OA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AAO;CACxD,IACE,4BAA4B,MAC3B,CAAC,wBAAwB,WAAW,KAAK,KAAK,KAAK,4BAA4B,MAEhF,MAAM,IAAI,MAAM,2DAA2D;CAG7E,MAAM,SAAS,QAAQ,UAAU,OAAO,OAAO;CAC/C,OAAO;EAAE;EAAS;CAAO;AAC3B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xunlei-open/miniapp",
3
- "version": "0.1.1-beta.4",
3
+ "version": "0.1.1-beta.5",
4
4
  "description": "Unified development CLI for Xunlei Miniapps",
5
5
  "type": "module",
6
6
  "module": "./dist/index.mjs",
@@ -45,8 +45,8 @@
45
45
  "parse5": "^8.0.1",
46
46
  "vite": "^8.2.0",
47
47
  "yazl": "^3.3.1",
48
- "@xunlei-open/miniapp-types": "^0.1.1-beta.4",
49
- "@xunlei-open/vite-plugin-miniapp": "^0.1.1-beta.4"
48
+ "@xunlei-open/miniapp-types": "^0.1.1-beta.5",
49
+ "@xunlei-open/vite-plugin-miniapp": "^0.1.1-beta.5"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/yazl": "^3.3.1"
@@ -1 +0,0 @@
1
- {"version":3,"file":"package-DgpqUgd3.mjs","names":["viteBuild"],"sources":["../src/config.ts","../src/validate.ts","../src/dev-entry.ts","../src/dev-events.ts","../src/vite.ts","../src/package.ts"],"sourcesContent":["import { existsSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { resolve } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport { loadConfigFromFile, mergeConfig, type ConfigEnv, type UserConfig } from 'vite'\nimport type {\n MiniappModule,\n MiniappUserConfig,\n ResolvedMiniappConfig,\n} from './types.js'\n\nconst CONFIG_FILES = [\n 'miniapp.config.ts',\n 'miniapp.config.mts',\n 'miniapp.config.js',\n 'miniapp.config.mjs',\n 'miniapp.config.cts',\n 'miniapp.config.cjs',\n] as const\n\nconst DEFAULT_EVENT_EXTENSIONS = ['.ts', '.js']\n\nexport function defineConfig(config: MiniappUserConfig): MiniappUserConfig {\n return config\n}\n\nexport function defineMiniappModule(module: MiniappModule): MiniappModule {\n return module\n}\n\nasync function loadModules(names: string[], configFile: string, env: ConfigEnv): Promise<UserConfig> {\n if (!Array.isArray(names) || names.some(name => typeof name !== 'string' || !name.trim())) {\n throw new Error('miniapp.config modules must be an array of module names')\n }\n const require = createRequire(configFile)\n let config: UserConfig = {}\n for (const name of new Set(names)) {\n try {\n const { default: module } = await import(pathToFileURL(require.resolve(name)).href)\n if (!module || typeof module !== 'object' || typeof module.name !== 'string' || !module.vite) {\n throw new Error('must export a MiniappModule with name and vite fields')\n }\n config = mergeConfig(config, await resolveViteConfig(module.vite, env))\n } catch (error) {\n throw new Error(`Failed to load miniapp module \"${name}\" from ${configFile}: ${error instanceof Error ? error.message : String(error)}`, { cause: error })\n }\n }\n return config\n}\n\nfunction findConfigFile(root: string): string {\n const matches = CONFIG_FILES.map((file) => resolve(root, file)).filter(existsSync)\n\n if (matches.length === 0) {\n throw new Error(`No miniapp.config file found in ${root}`)\n }\n if (matches.length > 1) {\n throw new Error(\n `Multiple miniapp config files found: ${matches.map((file) => file.split('/').at(-1)).join(', ')}`,\n )\n }\n\n return matches[0]!\n}\n\nfunction assertUserConfig(value: unknown, configFile: string): MiniappUserConfig {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new Error(`${configFile} must export a configuration object`)\n }\n return value as MiniappUserConfig\n}\n\nasync function resolveViteConfig(\n vite: MiniappUserConfig['vite'],\n env: ConfigEnv,\n): Promise<UserConfig> {\n if (!vite) return {}\n const config = typeof vite === 'function' ? await vite(env) : vite\n if (typeof config !== 'object' || config === null || Array.isArray(config)) {\n throw new Error('miniapp.config vite must resolve to a Vite configuration object')\n }\n return config\n}\n\nexport async function loadMiniappConfig(\n rootDirectory: string,\n env: ConfigEnv,\n): Promise<ResolvedMiniappConfig> {\n const root = resolve(rootDirectory)\n const configFile = findConfigFile(root)\n const loaded = await loadConfigFromFile(env, configFile, root)\n\n if (!loaded) {\n throw new Error(`Failed to load ${configFile}`)\n }\n\n const config = assertUserConfig(loaded.config, configFile)\n const eventsExtensions = config.events?.extensions ?? DEFAULT_EVENT_EXTENSIONS\n\n if (eventsExtensions.length === 0) {\n throw new Error('events.extensions must contain at least one file extension')\n }\n\n return {\n root,\n configFile,\n manifestFile: config.manifest ?? 'manifest.json',\n eventsDir: config.events?.dir ?? 'src/events',\n eventsExtensions,\n packageOutDir: config.package?.outDir ?? 'release',\n packageFileName: config.package?.fileName,\n vite: mergeConfig(\n await loadModules(config.modules ?? [], configFile, env),\n await resolveViteConfig(config.vite, env),\n ),\n }\n}\n","import { lstat, readFile, readdir } from 'node:fs/promises'\nimport { isAbsolute, relative, resolve, sep, win32 } from 'node:path'\nimport type { MiniappManifest } from '@xunlei-open/miniapp-types'\nimport type { MiniappValidationResult } from './types.js'\n\nfunction assertNonEmptyString(value: unknown, field: string): asserts value is string {\n if (typeof value !== 'string' || value.trim() === '') {\n throw new Error(`manifest.${field} must be a non-empty string`)\n }\n}\n\nfunction resolvePackagePath(directory: string, value: string, field: string): string {\n if (isAbsolute(value) || win32.isAbsolute(value)) {\n throw new Error(`manifest.${field} must be relative to the package root`)\n }\n\n const target = resolve(directory, value)\n const relativePath = relative(directory, target)\n if (relativePath === '..' || relativePath.startsWith(`..${sep}`)) {\n throw new Error(`manifest.${field} points outside the package root`)\n }\n return target\n}\n\nasync function assertPackageFile(\n directory: string,\n value: unknown,\n field: string,\n): Promise<void> {\n assertNonEmptyString(value, field)\n const target = resolvePackagePath(directory, value, field)\n let stat\n try {\n stat = await lstat(target)\n } catch {\n throw new Error(`manifest.${field} points to a missing file: ${value}`)\n }\n if (!stat.isFile() || stat.isSymbolicLink()) {\n throw new Error(`manifest.${field} must point to a regular package file: ${value}`)\n }\n}\n\nasync function collectFiles(directory: string, current = directory): Promise<string[]> {\n const entries = await readdir(current, { withFileTypes: true })\n const files: string[] = []\n\n for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {\n const absolutePath = resolve(current, entry.name)\n const packagePath = relative(directory, absolutePath).split(sep).join('/')\n\n if (entry.isSymbolicLink()) {\n throw new Error(`Package must not contain symbolic links: ${packagePath}`)\n }\n if (entry.isDirectory()) {\n files.push(...(await collectFiles(directory, absolutePath)))\n continue\n }\n if (entry.isFile()) files.push(packagePath)\n }\n\n return files\n}\n\nexport async function readMiniappManifest(manifestPath: string): Promise<MiniappManifest> {\n let value: unknown\n try {\n value = JSON.parse(await readFile(manifestPath, 'utf8'))\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error)\n throw new Error(`Unable to read manifest: ${reason}`)\n }\n\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new Error('manifest.json must contain a JSON object')\n }\n\n const manifest = value as MiniappManifest\n assertNonEmptyString(manifest.name, 'name')\n assertNonEmptyString(manifest.title, 'title')\n assertNonEmptyString(manifest.version, 'version')\n return manifest\n}\n\nexport async function validateSourceManifest(manifestPath: string): Promise<MiniappManifest> {\n return readMiniappManifest(manifestPath)\n}\n\nexport async function validateMiniappDirectory(\n directoryPath: string,\n): Promise<MiniappValidationResult> {\n const directory = resolve(directoryPath)\n const directoryStat = await lstat(directory).catch(() => undefined)\n if (!directoryStat?.isDirectory()) {\n throw new Error(`Miniapp output directory does not exist: ${directory}`)\n }\n\n const manifestPath = resolve(directory, 'manifest.json')\n const manifest = await readMiniappManifest(manifestPath)\n\n if (manifest.icon !== undefined) {\n await assertPackageFile(directory, manifest.icon, 'icon')\n }\n if (manifest.entry && (manifest.entry.type ?? 'miniapp') === 'miniapp') {\n await assertPackageFile(directory, manifest.entry.url, 'entry.url')\n const html = await readFile(resolve(directory, manifest.entry.url), 'utf8')\n if (html.startsWith('<!-- miniapp-dev-entry:')) {\n throw new Error('Output contains a development entry. Run build before validating or packaging.')\n }\n }\n for (const [index, script] of (manifest.scripts ?? []).entries()) {\n await assertPackageFile(directory, script.entry, `scripts[${index}].entry`)\n }\n\n const files = await collectFiles(directory)\n const sourcemap = files.find((file) => file.endsWith('.map'))\n if (sourcemap) {\n throw new Error(`Package must not contain sourcemaps: ${sourcemap}`)\n }\n const dependency = files.find((file) => file.split('/').includes('node_modules'))\n if (dependency) {\n throw new Error(`Package must not contain node_modules: ${dependency}`)\n }\n\n return { directory, manifestPath, manifest, files }\n}\n","import { createHash } from 'node:crypto'\nimport { copyFile, mkdir, readFile, rm, writeFile } from 'node:fs/promises'\nimport { dirname, isAbsolute, relative, resolve, sep, win32 } from 'node:path'\nimport type { MiniappManifest } from '@xunlei-open/miniapp-types'\nimport { minify, type Plugin, type ViteDevServer } from 'vite'\nimport { parse, parseFragment, serialize, type DefaultTreeAdapterMap } from 'parse5'\n\nfunction localPath(root: string, file: string): string {\n const target = resolve(root, file)\n const rel = relative(root, target)\n if (isAbsolute(file) || win32.isAbsolute(file) || rel === '..' || rel.startsWith(`..${sep}`)) {\n throw new Error(`Miniapp development entry must stay inside its directory: ${file}`)\n }\n return target\n}\n\nexport function localDevEntry(\n root: string,\n outDir: string,\n manifestFile: string,\n manifest: MiniappManifest,\n) {\n const entry = manifest.entry?.url\n if (manifest.entry && (manifest.entry.type ?? 'miniapp') !== 'miniapp') {\n throw new Error('Local HMR requires a miniapp HTML entry')\n }\n const source = entry ? localPath(root, entry) : undefined\n const output = entry ? localPath(outDir, entry) : undefined\n const iconSource = manifest.icon ? localPath(root, manifest.icon) : undefined\n const iconOutput = manifest.icon ? localPath(outDir, manifest.icon) : undefined\n let iconUpdates = Promise.resolve()\n let stopped = false\n const rootFromOutput = relative(outDir, root)\n if (!rootFromOutput || (!rootFromOutput.startsWith(`..${sep}`) && rootFromOutput !== '..' && !isAbsolute(rootFromOutput))) {\n throw new Error('Development output must not be the project root or its parent')\n }\n let server: ViteDevServer\n let entryUrl: string | undefined\n let pagePath: string\n const inlineModules = new Map<string, string>()\n let clientCode: Promise<string> | undefined\n\n function loadClientCode() {\n return clientCode ??= readFile(new URL('./dev-client.js', import.meta.url), 'utf8')\n .then(code => minify('dev-client.js', code))\n .then(result => result.code.trim().replace(/<\\/script/gi, '<\\\\/script'))\n }\n\n async function copyIcon() {\n if (!iconSource || !iconOutput) return\n await mkdir(dirname(iconOutput), { recursive: true })\n await copyFile(iconSource, iconOutput)\n }\n\n function onIconChange(event: string, file: string) {\n if (stopped || !iconSource || resolve(file) !== iconSource) return\n if (!['add', 'change', 'unlink'].includes(event)) return\n iconUpdates = iconUpdates.then(async () => {\n if (stopped) return\n if (event === 'unlink') await rm(iconOutput!, { force: true })\n else await copyIcon()\n server.config.logger.info('[miniapp] Manifest icon updated. Reload the application in the host to refresh its icon.')\n }).catch(error => {\n server.config.logger.error(`[miniapp] Icon sync failed: ${error instanceof Error ? error.message : String(error)}`)\n })\n }\n\n function rewriteEntry(html: string, bootstrap: string): string {\n const document = parse(html)\n const modules = new Map<string, string>()\n function visit(node: DefaultTreeAdapterMap['node']) {\n if ('tagName' in node) {\n for (const attr of node.attrs) {\n if (attr.name === 'src' || attr.name === 'poster' ||\n (attr.name === 'href' && ['link', 'image', 'use'].includes(node.tagName)) ||\n (attr.name === 'data' && node.tagName === 'object')) {\n if (attr.value && !attr.value.startsWith('#')) attr.value = new URL(attr.value, entryUrl).href\n }\n }\n if (node.tagName === 'script' &&\n node.attrs.some(attr => attr.name === 'type' && attr.value.toLowerCase() === 'module') &&\n !node.attrs.some(attr => attr.name === 'src')) {\n // Framework-injected preambles must resolve imports against HTTP, not file://.\n const code = node.childNodes.map(child => 'value' in child ? child.value : '').join('')\n const hash = createHash('sha256').update(code).digest('hex').slice(0, 16)\n const url = new URL(`./@miniapp-dev/inline-${modules.size}-${hash}.js`, entryUrl)\n const id = url.pathname.slice(server.config.base.length - 1)\n modules.set(id, code)\n node.childNodes = []\n node.attrs.push({ name: 'src', value: url.href })\n }\n if (node.tagName === 'script' &&\n node.attrs.some(attr => attr.name === 'type' && attr.value.toLowerCase() === 'module') &&\n node.attrs.some(attr => attr.name === 'src' && new URL(attr.value, entryUrl).origin === new URL(entryUrl!).origin)) {\n node.attrs.push({ name: 'data-miniapp-dev-module', value: '' })\n // Inert placeholders do not hold DOMContentLoaded or window.load open.\n node.attrs.find(attr => attr.name === 'type')!.value = 'application/x-miniapp-dev-module'\n node.attrs.find(attr => attr.name === 'src')!.name = 'data-miniapp-dev-src'\n }\n }\n if ('childNodes' in node) node.childNodes.forEach(visit)\n if ('content' in node) visit(node.content as DefaultTreeAdapterMap['documentFragment'])\n }\n visit(document)\n const htmlNode = document.childNodes.find(node => 'tagName' in node && node.tagName === 'html') as DefaultTreeAdapterMap['element']\n const head = htmlNode.childNodes.find(node => 'tagName' in node && node.tagName === 'head') as DefaultTreeAdapterMap['element']\n const script = parseFragment(`<script data-miniapp-dev-load-error>${bootstrap}</script>`).childNodes[0] as DefaultTreeAdapterMap['element']\n script.attrs.push({ name: 'data-miniapp-dev-probe', value: new URL(server.config.base, entryUrl).href })\n script.parentNode = head\n head.childNodes.unshift(script)\n inlineModules.clear()\n for (const [path, code] of modules) inlineModules.set(path, code)\n return serialize(document)\n }\n\n async function writeEntry() {\n if (!source || !output) return\n const html = await server.transformIndexHtml(pagePath, await readFile(source, 'utf8'))\n await mkdir(dirname(output), { recursive: true })\n await writeFile(output, `<!-- miniapp-dev-entry: run build before packaging -->\\n${rewriteEntry(html, await loadClientCode())}`)\n // Remove only bootstrap files generated by the previous external-script version.\n const oldClient = resolve(dirname(output), 'miniapp-dev-client.js')\n const oldCode = await readFile(oldClient, 'utf8').catch(() => '')\n if (oldCode.startsWith('// Local development bootstrap: must work without the dev server.')) {\n await rm(oldClient, { force: true })\n }\n }\n\n const plugin: Plugin = {\n name: 'miniapp-local-dev-entry',\n apply: 'serve',\n async closeBundle() {\n stopped = true\n server?.watcher.off('all', onIconChange)\n await iconUpdates\n },\n resolveId(id) {\n if (inlineModules.has(id.split('?')[0]!)) return id\n },\n load(id) {\n return inlineModules.get(id.split('?')[0]!)\n },\n async handleHotUpdate(context) {\n if (resolve(context.file) !== source) return\n await writeEntry()\n // Vite's HTML reload filter otherwise compares against the file:// pathname.\n context.server.ws.send({ type: 'full-reload', path: '*' })\n return []\n },\n }\n\n return {\n plugin,\n async write(devServer: ViteDevServer) {\n server = devServer\n await mkdir(outDir, { recursive: true })\n if (entry) {\n const url = server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0]\n if (!url) throw new Error('Cannot determine the Vite development server URL')\n server.config.server.origin ??= new URL(url).origin\n entryUrl = new URL(entry.replaceAll('\\\\', '/'), url).href\n pagePath = new URL(entryUrl).pathname\n await writeEntry()\n }\n await copyFile(resolve(root, manifestFile), resolve(outDir, 'manifest.json'))\n await copyIcon()\n if (iconSource) {\n server.watcher.add(iconSource)\n server.watcher.on('all', onIconChange)\n }\n },\n }\n}\n","import { mkdir, readdir, rm, writeFile } from 'node:fs/promises'\nimport { dirname, isAbsolute, relative, resolve, sep } from 'node:path'\nimport type { MiniappManifest } from '@xunlei-open/miniapp-types'\nimport miniappPlugin from '@xunlei-open/vite-plugin-miniapp'\nimport { build, normalizePath, type Plugin, type ViteDevServer } from 'vite'\nimport { loadMiniappConfig } from './config.js'\nimport type { ResolvedMiniappConfig } from './types.js'\n\n/** Build sandbox scripts on disk independently from the page's Vite HMR graph. */\nexport function devEvents(config: ResolvedMiniappConfig, outDir: string, manifest: MiniappManifest, mode: string) {\n const eventsDir = resolve(config.root, config.eventsDir)\n let server: ViteDevServer\n let dependencies = new Set<string>()\n let outputs = new Set<string>()\n let pending = Promise.resolve()\n let stopped = false\n let failed = false\n\n async function rebuild() {\n const sources = await readdir(eventsDir, { withFileTypes: true }).catch(error => {\n if (error.code === 'ENOENT') return []\n throw error\n })\n const hasEntries = sources.some(source => source.isFile()\n && !source.name.endsWith('.d.ts')\n && config.eventsExtensions.some(ext => source.name.endsWith(ext)))\n const nextDependencies = new Set<string>()\n const files = new Map<string, string | Uint8Array>()\n if (hasEntries) {\n // Vite plugins can hold server state. Never reuse the live page's instances.\n const eventConfig = await loadMiniappConfig(config.root, {\n command: 'build', mode, isSsrBuild: false, isPreview: false,\n })\n const options = eventConfig.vite.build\n const result = await build({\n ...eventConfig.vite,\n root: config.root,\n configFile: false,\n mode,\n publicDir: false,\n logLevel: 'warn',\n plugins: [\n ...(eventConfig.vite.plugins ?? []),\n miniappPlugin({\n eventsOnly: true,\n eventsDir: config.eventsDir,\n eventsExtensions: config.eventsExtensions,\n }),\n {\n name: 'miniapp-dev-events-output',\n generateBundle() {\n for (const file of this.getModuleIds()) {\n const path = file.split('?')[0]!\n if (isAbsolute(path)) nextDependencies.add(resolve(path))\n }\n },\n },\n ],\n build: {\n ...options,\n outDir,\n emptyOutDir: false,\n copyPublicDir: false,\n write: false,\n watch: null,\n lib: false,\n ssr: false,\n sourcemap: false,\n minify: false,\n manifest: false,\n ssrManifest: false,\n // Only sandbox entries; never rebuild/overwrite the local HMR HTML.\n rolldownOptions: undefined,\n rollupOptions: {\n ...options?.rollupOptions,\n ...options?.rolldownOptions,\n input: undefined,\n output: undefined,\n },\n },\n })\n for (const bundle of Array.isArray(result) ? result : [result]) {\n if (!('output' in bundle)) throw new Error('Unexpected event build watcher')\n for (const file of bundle.output) {\n files.set(file.fileName, file.type === 'chunk' ? file.code : file.source)\n }\n }\n }\n\n dependencies = nextDependencies\n server.watcher.add([...dependencies])\n // Publish only event outputs, and only after a successful compilation.\n for (const name of files.keys()) {\n const path = normalizePath(relative(outDir, resolve(outDir, name)))\n if (!path.startsWith('events/') || path.includes('../')) {\n throw new Error(`Event build emitted a file outside events/: ${name}`)\n }\n }\n for (const [name, content] of files) {\n const path = resolve(outDir, name)\n await mkdir(dirname(path), { recursive: true })\n await writeFile(path, content)\n }\n for (const name of outputs) {\n if (!files.has(name)) await rm(resolve(outDir, name), { force: true })\n }\n outputs = new Set(files.keys())\n for (const script of manifest.scripts ?? []) {\n const entry = normalizePath(relative(outDir, resolve(outDir, script.entry)))\n if (!outputs.has(entry)) {\n throw new Error(`manifest script \"${script.entry}\" has no built event entry. Add its source to ${config.eventsDir}.`)\n }\n }\n if (hasEntries) server.config.logger.info('[miniapp] Event scripts built. Reload the application in the host if it caches scripts.')\n }\n\n function onChange(event: string, file: string) {\n if (stopped || !['add', 'change', 'unlink'].includes(event)) return\n const path = resolve(file)\n const entry = dirname(path) === eventsDir && config.eventsExtensions.some(ext => path.endsWith(ext))\n const relativeToOutput = relative(outDir, path)\n if (relativeToOutput !== '..' && !relativeToOutput.startsWith(`..${sep}`) && !isAbsolute(relativeToOutput)) return\n if (!entry && !dependencies.has(path) && !failed) return\n pending = pending.then(async () => {\n if (stopped) return\n try {\n await rebuild()\n failed = false\n } catch (error) {\n failed = true\n server.config.logger.error(`[miniapp] Event build failed: ${error instanceof Error ? error.message : String(error)}`)\n }\n })\n }\n\n const plugin: Plugin = {\n name: 'miniapp-dev-events',\n apply: 'serve',\n async closeBundle() {\n stopped = true\n server?.watcher.off('all', onChange)\n await pending\n },\n }\n\n return {\n plugin,\n async start(devServer: ViteDevServer) {\n server = devServer\n await rebuild()\n server.watcher.add(eventsDir)\n server.watcher.on('all', onChange)\n },\n }\n}\n","import { resolve } from 'node:path'\nimport miniappPlugin from '@xunlei-open/vite-plugin-miniapp'\nimport {\n build as viteBuild,\n createServer,\n mergeConfig,\n type ConfigEnv,\n type InlineConfig,\n type ViteDevServer,\n} from 'vite'\nimport { loadMiniappConfig } from './config.js'\nimport { localDevEntry } from './dev-entry.js'\nimport { devEvents } from './dev-events.js'\nimport type {\n BuildMiniappOptions,\n DevMiniappOptions,\n ResolvedMiniappConfig,\n} from './types.js'\nimport {\n validateMiniappDirectory,\n validateSourceManifest,\n} from './validate.js'\n\nfunction configEnv(command: ConfigEnv['command'], mode: string): ConfigEnv {\n return { command, mode, isSsrBuild: false, isPreview: false }\n}\n\nfunction createInlineConfig(config: ResolvedMiniappConfig): InlineConfig {\n return mergeConfig(config.vite, {\n root: config.root,\n configFile: false,\n plugins: [\n miniappPlugin({\n eventsDir: config.eventsDir,\n eventsExtensions: config.eventsExtensions,\n manifestFile: config.manifestFile,\n }),\n ],\n })\n}\n\nexport function resolveOutputDirectory(config: ResolvedMiniappConfig): string {\n return resolve(config.root, config.vite.build?.outDir ?? 'dist')\n}\n\nexport async function buildMiniapp(\n options: BuildMiniappOptions = {},\n): Promise<{ config: ResolvedMiniappConfig; outDir: string }> {\n const root = options.root ?? process.cwd()\n const mode = options.mode ?? 'production'\n const config = await loadMiniappConfig(root, configEnv('build', mode))\n\n await viteBuild(createInlineConfig(config))\n\n const outDir = resolveOutputDirectory(config)\n await validateMiniappDirectory(outDir)\n return { config, outDir }\n}\n\nexport async function validateBuiltMiniapp(\n options: BuildMiniappOptions = {},\n) {\n const root = options.root ?? process.cwd()\n const mode = options.mode ?? 'production'\n const config = await loadMiniappConfig(root, configEnv('build', mode))\n return validateMiniappDirectory(resolveOutputDirectory(config))\n}\n\nexport async function devMiniapp(\n options: DevMiniappOptions = {},\n): Promise<ViteDevServer> {\n const root = options.root ?? process.cwd()\n const mode = options.mode ?? 'development'\n const config = await loadMiniappConfig(root, configEnv('serve', mode))\n const manifest = await validateSourceManifest(\n resolve(config.root, config.manifestFile),\n )\n\n const inlineConfig = createInlineConfig(config)\n const outDir = resolveOutputDirectory(config)\n const devEntry = localDevEntry(config.root, outDir, config.manifestFile, manifest)\n const events = devEvents(config, outDir, manifest, mode)\n inlineConfig.plugins = [...(inlineConfig.plugins ?? []), devEntry.plugin, events.plugin]\n inlineConfig.server = {\n ...inlineConfig.server,\n // Local file pages have an opaque (\"null\") origin. Explicit user CORS wins.\n cors: inlineConfig.server?.cors ?? {\n origin: [/^https?:\\/\\/(?:(?:[^:]+\\.)?localhost|127\\.0\\.0\\.1|\\[::1\\])(?::\\d+)?$/, 'null'],\n },\n ...(options.host ? { host: options.host } : {}),\n ...(options.port ? { port: options.port } : {}),\n }\n if (!manifest.entry) {\n // Keep Vite's file watcher for sandbox builds without opening an HTTP/HMR server.\n inlineConfig.server.middlewareMode = true\n inlineConfig.server.hmr = false\n inlineConfig.server.open = false\n }\n\n const server = await createServer(inlineConfig)\n try {\n if (manifest.entry) await server.listen()\n await devEntry.write(server)\n await events.start(server)\n } catch (error) {\n await server.close()\n throw error\n }\n if (manifest.entry) {\n server.printUrls()\n server.bindCLIShortcuts({ print: true })\n }\n console.log(`\\nLoad this directory in Xunlei: ${outDir}\\n`)\n return server\n}\n","import { createWriteStream } from 'node:fs'\nimport { mkdir, rm } from 'node:fs/promises'\nimport { basename, dirname, isAbsolute, relative, resolve, sep } from 'node:path'\nimport { pipeline } from 'node:stream/promises'\nimport yazl from 'yazl'\nimport { loadMiniappConfig } from './config.js'\nimport type {\n PackageMiniappOptions,\n ResolvedMiniappConfig,\n} from './types.js'\nimport { validateMiniappDirectory } from './validate.js'\nimport { buildMiniapp, resolveOutputDirectory } from './vite.js'\n\nconst ZIP_DATE = new Date('1980-01-01T00:00:00.000Z')\n\nfunction safeFilePart(value: string): string {\n return value.trim().replace(/[^a-zA-Z0-9._-]+/g, '-').replace(/^-+|-+$/g, '') || 'miniapp'\n}\n\nfunction resolveArchivePath(\n config: ResolvedMiniappConfig,\n manifest: { name: string; version: string },\n explicitPath?: string,\n): string {\n if (explicitPath) {\n if (!explicitPath.toLowerCase().endsWith('.zip')) {\n throw new Error('--out must end with .zip')\n }\n return isAbsolute(explicitPath) ? explicitPath : resolve(config.root, explicitPath)\n }\n\n const fileName =\n config.packageFileName ??\n `${safeFilePart(manifest.name)}-${safeFilePart(manifest.version)}.zip`\n if (!fileName.toLowerCase().endsWith('.zip')) {\n throw new Error('package.fileName must end with .zip')\n }\n if (basename(fileName) !== fileName) {\n throw new Error('package.fileName must not contain a directory')\n }\n return resolve(config.root, config.packageOutDir, fileName)\n}\n\nasync function writeZip(\n directory: string,\n files: string[],\n outFile: string,\n): Promise<void> {\n await mkdir(dirname(outFile), { recursive: true })\n\n const archive = new yazl.ZipFile()\n const output = createWriteStream(outFile)\n const completed = pipeline(archive.outputStream, output)\n try {\n for (const file of files) {\n archive.addFile(resolve(directory, file), file, {\n mtime: ZIP_DATE,\n mode: 0o644,\n compress: true,\n })\n }\n archive.end()\n await completed\n } catch (error) {\n await rm(outFile, { force: true })\n throw error\n }\n}\n\nexport async function packageMiniapp(\n options: PackageMiniappOptions = {},\n): Promise<{ outFile: string; outDir: string }> {\n let config: ResolvedMiniappConfig\n let outDir: string\n\n if (options.build ?? true) {\n ;({ config, outDir } = await buildMiniapp(options))\n } else {\n const root = options.root ?? process.cwd()\n const mode = options.mode ?? 'production'\n config = await loadMiniappConfig(root, {\n command: 'build',\n mode,\n isSsrBuild: false,\n isPreview: false,\n })\n outDir = resolveOutputDirectory(config)\n }\n\n const validated = await validateMiniappDirectory(outDir)\n const outFile = resolveArchivePath(config, validated.manifest, options.outFile)\n const archiveRelativeToOutput = relative(outDir, outFile)\n if (\n archiveRelativeToOutput === '' ||\n (!archiveRelativeToOutput.startsWith(`..${sep}`) && archiveRelativeToOutput !== '..')\n ) {\n throw new Error('Package output must be outside the build output directory')\n }\n\n await writeZip(outDir, validated.files, outFile)\n return { outFile, outDir }\n}\n"],"mappings":";;;;;;;;;;;;AAWA,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAM,2BAA2B,CAAC,OAAO,KAAK;AAE9C,SAAgB,aAAa,QAA8C;CACzE,OAAO;AACT;AAEA,SAAgB,oBAAoB,QAAsC;CACxE,OAAO;AACT;AAEA,eAAe,YAAY,OAAiB,YAAoB,KAAqC;CACnG,IAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,MAAK,SAAQ,OAAO,SAAS,YAAY,CAAC,KAAK,KAAK,CAAC,GACtF,MAAM,IAAI,MAAM,yDAAyD;CAE3E,MAAM,UAAU,cAAc,UAAU;CACxC,IAAI,SAAqB,CAAC;CAC1B,KAAK,MAAM,QAAQ,IAAI,IAAI,KAAK,GAC9B,IAAI;EACF,MAAM,EAAE,SAAS,WAAW,MAAM,OAAO,cAAc,QAAQ,QAAQ,IAAI,CAAC,CAAC,CAAC;EAC9E,IAAI,CAAC,UAAU,OAAO,WAAW,Y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