@xunlei-open/miniapp 1.2.0 → 1.3.0-beta.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/README.md CHANGED
@@ -44,6 +44,11 @@ Vue / React 项目安装并声明对应框架模块;Vanilla 无需模块。额
44
44
 
45
45
  事件源码默认放在 `src/events`,并在 manifest 的 `scripts` 中声明。纯事件应用无需页面入口。事件或图标更新后,宿主若有缓存需重新加载应用。
46
46
 
47
+ 页面应用可用 `entry.file_associations` 声明关联的文件后缀,例如
48
+ `"entry": { "url": "index.html", "file_associations": [".jpg", ".png", ".tar.gz"] }`。
49
+ 后缀必须带点,不接受空白、路径分隔符或 `*`、`?` 通配符;匹配忽略大小写。
50
+ 开发服务及构建、校验和打包命令会校验此字段。`in_app_webview` 不支持非空关联列表。
51
+
47
52
  ### 事件依赖与开发重建
48
53
 
49
54
  事件入口输出在 `events/`;公共分块、Worker、WASM 等依赖可以按 Vite 默认规则输出到 `assets/`,无需在应用中强制配置 `events/assets/`。Worker 及其依赖修改也会触发事件重建。
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { i as validateBuiltMiniapp, n as buildMiniapp, r as devMiniapp, t as packageMiniapp } from "./package-jNl57UKj.mjs";
2
1
  import { parseArgs } from "node:util";
3
- //#region src/cli.ts
2
+ import { i as validateBuiltMiniapp, n as buildMiniapp, r as devMiniapp, t as packageMiniapp } from "./package-ByYNRr5n.mjs";
3
+ // src/cli.ts
4
4
  const HELP = `Xunlei Miniapp CLI
5
5
 
6
6
  Usage:
@@ -90,7 +90,6 @@ main().catch((error) => {
90
90
  console.error(`\n✖ ${message}\n`);
91
91
  process.exitCode = 1;
92
92
  });
93
- //#endregion
94
93
  export {};
95
94
 
96
95
  //# sourceMappingURL=cli.mjs.map
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { ConfigEnv, UserConfig, ViteDevServer } from "vite";
2
2
  import { MiniappManifest } from "@xunlei-open/miniapp-types";
3
- //#region src/types.d.ts
4
3
  /** 可直接返回的值或异步返回该值的承诺对象。 */
5
4
  type MaybePromise<T> = T | Promise<T>;
6
5
  interface MiniappEventsConfig {
@@ -77,30 +76,22 @@ interface PackageMiniappOptions extends BuildMiniappOptions {
77
76
  /** 输出压缩包路径,相对路径以项目根目录为基准;指定后优先于打包目录和文件名配置。 */
78
77
  outFile?: string;
79
78
  }
80
- //#endregion
81
- //#region src/config.d.ts
82
79
  export declare function defineConfig(config: MiniappUserConfig): MiniappUserConfig;
83
80
  export declare function defineMiniappModule(module: MiniappModule): MiniappModule;
84
81
  export declare function loadMiniappConfig(rootDirectory: string, env: ConfigEnv): Promise<ResolvedMiniappConfig>;
85
- //#endregion
86
- //#region src/package.d.ts
87
82
  export declare function packageMiniapp(options?: PackageMiniappOptions): Promise<{
88
83
  outFile: string;
89
84
  outDir: string;
90
85
  }>;
91
- //#endregion
92
- //#region src/validate.d.ts
86
+ /** 读取清单并校验必填元信息及入口文件关联,保留原始声明供构建使用。 */
93
87
  export declare function readMiniappManifest(manifestPath: string): Promise<MiniappManifest>;
94
88
  export declare function validateSourceManifest(manifestPath: string): Promise<MiniappManifest>;
95
89
  export declare function validateMiniappDirectory(directoryPath: string): Promise<MiniappValidationResult>;
96
- //#endregion
97
- //#region src/vite.d.ts
98
90
  export declare function buildMiniapp(options?: BuildMiniappOptions): Promise<{
99
91
  config: ResolvedMiniappConfig;
100
92
  outDir: string;
101
93
  }>;
102
94
  export declare function validateBuiltMiniapp(options?: BuildMiniappOptions): Promise<MiniappValidationResult>;
103
95
  export declare function devMiniapp(options?: DevMiniappOptions): Promise<ViteDevServer>;
104
- //#endregion
105
96
  export type { BuildMiniappOptions, DevMiniappOptions, MiniappEventsConfig, MiniappModule, MiniappPackageConfig, MiniappUserConfig, MiniappValidationResult, MiniappViteConfig, PackageMiniappOptions, ResolvedMiniappConfig };
106
97
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/config.ts","../src/package.ts","../src/validate.ts","../src/vite.ts"],"mappings":";;;;KAIY,aAAa,KAAK,IAAI,QAAQ;UAEzB;;EAEf;;EAEA;;UAGe;;EAEf;;EAEA;;;KAIU,oBAAoB,eAAe,KAAK,cAAc,aAAa;UAE9D;;EAEf;;IAEE;;;EAGF;;EAEA;;EAEA,SAAS;;EAET,UAAU;;EAEV,OAAO;;UAGQ;;EAEf;;EAEA,MAAM;;;UAIS;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,MAAM;;;UAIS;EACf;EACA;EACA,UAAU;EACV;;UAGe;;EAEf;;EAEA;;UAGe,0BAA0B;;EAEzC;;EAEA;;UAGe,8BAA8B;;EAE7C;;EAEA;;;;wBCrEc,aAAa,QAAQ,oBAAoB;wBAIzC,oBAAoB,QAAQ,gBAAgB;wBAwDtC,kBAAkB,uBAAuB,KAAK,YAAY,QAAQ;;;wBCclE,eACpB,UAAS,wBACR;EAAU;EAAiB;;;;wBCnCR,oBAAoB,uBAAuB,QAAQ;wBAoBnD,uBAAuB,uBAAuB,QAAQ;wBAItD,yBAAyB,wBAAwB,QAAQ;;;wBC7CzD,aACpB,UAAS,sBACR;EAAU,QAAQ;EAAuB;;wBAYtB,qBAAqB,UAAS,sBAAwB,QAAxB;wBAO9B,WAAW,UAAS,oBAAyB,QAAQ"}
1
+ {"version":3,"file":"index.d.mts","names":["_$__types_js0.MiniappValidationResult"],"sources":["../src/types.ts","../src/config.ts","../src/package.ts","../src/validate.ts","../src/vite.ts"],"mappings":";;;KAIY,aAAa,KAAK,IAAI,QAAQ;UAEzB;;EAEf;;EAEA;;UAGe;;EAEf;;EAEA;;;KAIU,oBAAoB,eAAe,KAAK,cAAc,aAAa;UAE9D;;EAEf;;IAEE;;;EAGF;;EAEA;;EAEA,SAAS;;EAET,UAAU;;EAEV,OAAO;;UAGQ;;EAEf;;EAEA,MAAM;;;UAIS;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,MAAM;;;UAIS;EACf;EACA;EACA,UAAU;EACV;;UAGe;;EAEf;;EAEA;;UAGe,0BAA0B;;EAEzC;;EAEA;;UAGe,8BAA8B;;EAE7C;;EAEA;;wBCrEc,aAAa,QAAQ,oBAAoB;wBAIzC,oBAAoB,QAAQ,gBAAgB;wBAwDtC,kBAAkB,uBAAuB,KAAK,YAAY,QAAQ;wBCclE,eACpB,UAAS,wBACR;EAAU;EAAiB;;;wBClCR,oBAAoB,uBAAuB,QAAQ;wBAwCnD,uBAAuB,uBAAuB,QAAQ;wBAItD,yBAAyB,wBAAwB,QAAQ;wBClEzD,aACpB,UAAS,sBACR;EAAU,QAAQ;EAAuB;;wBAYtB,qBAAqB,UAAS,sBAAwB,QAAxBA;wBAO9B,WAAW,UAAS,oBAAyB,QAAQ"}
package/dist/index.mjs CHANGED
@@ -1,2 +1 @@
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-jNl57UKj.mjs";
2
- export { buildMiniapp, defineConfig, defineMiniappModule, devMiniapp, loadMiniappConfig, packageMiniapp, readMiniappManifest, validateBuiltMiniapp, validateMiniappDirectory, validateSourceManifest };
1
+ export { n as buildMiniapp, c as defineConfig, l as defineMiniappModule, r as devMiniapp, u as loadMiniappConfig, t as packageMiniapp, a as readMiniappManifest, i as validateBuiltMiniapp, o as validateMiniappDirectory, s as validateSourceManifest } from "./package-ByYNRr5n.mjs";
@@ -1,15 +1,15 @@
1
- import { createRequire } from "node:module";
2
1
  import { createWriteStream, existsSync } from "node:fs";
3
- import { basename, dirname, isAbsolute, join, relative, resolve, sep, win32 } from "node:path";
4
- import { pathToFileURL } from "node:url";
5
- import { build, createServer, loadConfigFromFile, mergeConfig, minify } from "vite";
6
2
  import { copyFile, lstat, mkdir, mkdtemp, readFile, readdir, rename, rm, rmdir, writeFile } from "node:fs/promises";
3
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep, win32 } from "node:path";
7
4
  import { pipeline } from "node:stream/promises";
8
5
  import yazl from "yazl";
6
+ import { createRequire } from "node:module";
7
+ import { pathToFileURL } from "node:url";
8
+ import { build, createServer, loadConfigFromFile, mergeConfig, minify } from "vite";
9
9
  import miniappPlugin from "@xunlei-open/vite-plugin-miniapp";
10
10
  import { createHash } from "node:crypto";
11
11
  import { parse, parseFragment, serialize } from "parse5";
12
- //#region src/config.ts
12
+ // src/config.ts
13
13
  const CONFIG_FILES = [
14
14
  "miniapp.config.ts",
15
15
  "miniapp.config.mts",
@@ -83,8 +83,7 @@ async function loadMiniappConfig(rootDirectory, env) {
83
83
  vite
84
84
  };
85
85
  }
86
- //#endregion
87
- //#region src/validate.ts
86
+ // src/validate.ts
88
87
  function assertNonEmptyString(value, field) {
89
88
  if (typeof value !== "string" || value.trim() === "") throw new Error(`manifest.${field} must be a non-empty string`);
90
89
  }
@@ -121,6 +120,7 @@ async function collectFiles(directory, current = directory) {
121
120
  }
122
121
  return files;
123
122
  }
123
+ /** 读取清单并校验必填元信息及入口文件关联,保留原始声明供构建使用。 */
124
124
  async function readMiniappManifest(manifestPath) {
125
125
  let value;
126
126
  try {
@@ -134,8 +134,16 @@ async function readMiniappManifest(manifestPath) {
134
134
  assertNonEmptyString(manifest.name, "name");
135
135
  assertNonEmptyString(manifest.title, "title");
136
136
  assertNonEmptyString(manifest.version, "version");
137
+ assertFileAssociations(manifest.entry);
137
138
  return manifest;
138
139
  }
140
+ /** 在开发和打包阶段拒绝非法文件关联,归一化交由宿主运行时完成。 */
141
+ function assertFileAssociations(entry) {
142
+ const associations = entry?.file_associations;
143
+ if (associations === void 0) return;
144
+ if (!Array.isArray(associations) || associations.some((extension) => typeof extension !== "string" || !/^\.[^.\s/\\*?]+(?:\.[^.\s/\\*?]+)*$/u.test(extension))) throw new Error("manifest.entry.file_associations must contain dot-prefixed file extensions, such as .jpg or .tar.gz");
145
+ if (associations.length > 0 && (entry?.type ?? "miniapp") !== "miniapp") throw new Error("manifest.entry.file_associations is only supported by miniapp entries");
146
+ }
139
147
  async function validateSourceManifest(manifestPath) {
140
148
  return readMiniappManifest(manifestPath);
141
149
  }
@@ -162,8 +170,7 @@ async function validateMiniappDirectory(directoryPath) {
162
170
  files
163
171
  };
164
172
  }
165
- //#endregion
166
- //#region src/dev-entry.ts
173
+ // src/dev-entry.ts
167
174
  function localPath(root, file) {
168
175
  const target = resolve(root, file);
169
176
  const rel = relative(root, target);
@@ -312,8 +319,7 @@ function localDevEntry(root, outDir, manifestFile, manifest) {
312
319
  }
313
320
  };
314
321
  }
315
- //#endregion
316
- //#region src/event-output.ts
322
+ // src/event-output.ts
317
323
  /** Event entries are replaceable; dependencies are immutable for the dev session. */
318
324
  function eventOutput(outDir, protectedFiles) {
319
325
  const root = resolve(outDir);
@@ -398,8 +404,7 @@ function eventOutput(outDir, protectedFiles) {
398
404
  }
399
405
  };
400
406
  }
401
- //#endregion
402
- //#region src/dev-events.ts
407
+ // src/dev-events.ts
403
408
  /** Build sandbox scripts on disk independently from the page's Vite HMR graph. */
404
409
  function devEvents(config, outDir, manifest, mode) {
405
410
  const eventsDir = resolve(config.root, config.eventsDir);
@@ -535,8 +540,7 @@ function devEvents(config, outDir, manifest, mode) {
535
540
  }
536
541
  };
537
542
  }
538
- //#endregion
539
- //#region src/vite.ts
543
+ // src/vite.ts
540
544
  function configEnv(command, mode) {
541
545
  return {
542
546
  command,
@@ -620,8 +624,7 @@ async function devMiniapp(options = {}) {
620
624
  console.log(`\nLoad this directory in Xunlei: ${outDir}\n`);
621
625
  return server;
622
626
  }
623
- //#endregion
624
- //#region src/package.ts
627
+ // src/package.ts
625
628
  const ZIP_DATE = /* @__PURE__ */ new Date("1980-01-01T00:00:00.000Z");
626
629
  function safeFilePart(value) {
627
630
  return value.trim().replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "miniapp";
@@ -704,7 +707,6 @@ async function packageMiniapp(options = {}) {
704
707
  outDir
705
708
  };
706
709
  }
707
- //#endregion
708
710
  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 };
709
711
 
710
- //# sourceMappingURL=package-jNl57UKj.mjs.map
712
+ //# sourceMappingURL=package-ByYNRr5n.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-ByYNRr5n.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 { isAbsolute, relative, resolve, sep } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport { loadConfigFromFile, mergeConfig, type ConfigEnv, type UserConfig } from 'vite'\nimport type { MiniappModule, MiniappUserConfig, ResolvedMiniappConfig } 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(\n `Failed to load miniapp module \"${name}\" from ${configFile}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n )\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(`Multiple miniapp config files found: ${matches.map((file) => file.split('/').at(-1)).join(', ')}`)\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(vite: MiniappUserConfig['vite'], env: ConfigEnv): 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(rootDirectory: string, env: ConfigEnv): 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 const vite = mergeConfig(\n { build: { outDir: 'output' } },\n mergeConfig(await loadModules(config.modules ?? [], configFile, env), await resolveViteConfig(config.vite, env)),\n )\n const devOutDir = config.dev?.outDir ?? 'dist'\n const devPath = resolve(root, devOutDir)\n const buildPath = resolve(root, vite.build?.outDir ?? 'output')\n const contains = (parent: string, child: string) => {\n const path = relative(parent, child)\n return path === '' || (path !== '..' && !path.startsWith(`..${sep}`) && !isAbsolute(path))\n }\n if (contains(devPath, buildPath) || contains(buildPath, devPath)) {\n throw new Error('dev.outDir and vite.build.outDir must be separate directories, neither containing the other')\n }\n\n return {\n root,\n configFile,\n manifestFile: config.manifest ?? 'manifest.json',\n eventsDir: config.events?.dir ?? 'src/events',\n eventsExtensions,\n devOutDir,\n packageOutDir: config.package?.outDir ?? 'output',\n packageFileName: config.package?.fileName,\n vite,\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(directory: string, value: unknown, field: string): 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\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 assertFileAssociations(manifest.entry)\n return manifest\n}\n\n/** 在开发和打包阶段拒绝非法文件关联,归一化交由宿主运行时完成。 */\nfunction assertFileAssociations(entry: MiniappManifest['entry']): void {\n const associations = entry?.file_associations\n if (associations === undefined) return\n if (\n !Array.isArray(associations) ||\n associations.some(\n (extension) => typeof extension !== 'string' || !/^\\.[^.\\s/\\\\*?]+(?:\\.[^.\\s/\\\\*?]+)*$/u.test(extension),\n )\n ) {\n throw new Error(\n 'manifest.entry.file_associations must contain dot-prefixed file extensions, such as .jpg or .tar.gz',\n )\n }\n if (associations.length > 0 && (entry?.type ?? 'miniapp') !== 'miniapp') {\n throw new Error('manifest.entry.file_associations is only supported by miniapp entries')\n }\n}\n\nexport async function validateSourceManifest(manifestPath: string): Promise<MiniappManifest> {\n return readMiniappManifest(manifestPath)\n}\n\nexport async function validateMiniappDirectory(directoryPath: string): 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(root: string, outDir: string, manifestFile: string, manifest: MiniappManifest) {\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 (\n !rootFromOutput ||\n (!rootFromOutput.startsWith(`..${sep}`) && rootFromOutput !== '..' && !isAbsolute(rootFromOutput))\n ) {\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\n .then(async () => {\n if (stopped) return\n if (event === 'unlink') await rm(iconOutput!, { force: true })\n else await copyIcon()\n server.config.logger.info(\n '[miniapp] Manifest icon updated. Reload the application in the host to refresh its icon.',\n )\n })\n .catch((error) => {\n server.config.logger.error(\n `[miniapp] Icon sync failed: ${error instanceof Error ? error.message : String(error)}`,\n )\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 (\n attr.name === 'src' ||\n attr.name === 'poster' ||\n (attr.name === 'href' && ['link', 'image', 'use'].includes(node.tagName)) ||\n (attr.name === 'data' && node.tagName === 'object')\n ) {\n if (attr.value && !attr.value.startsWith('#')) attr.value = new URL(attr.value, entryUrl).href\n }\n }\n if (\n node.tagName === 'script' &&\n node.attrs.some((attr) => attr.name === 'type' && attr.value.toLowerCase() === 'module') &&\n !node.attrs.some((attr) => attr.name === 'src')\n ) {\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 (\n node.tagName === 'script' &&\n node.attrs.some((attr) => attr.name === 'type' && attr.value.toLowerCase() === 'module') &&\n node.attrs.some(\n (attr) => attr.name === 'src' && new URL(attr.value, entryUrl).origin === new URL(entryUrl!).origin,\n )\n ) {\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(\n (node) => 'tagName' in node && node.tagName === 'html',\n ) as DefaultTreeAdapterMap['element']\n const head = htmlNode.childNodes.find(\n (node) => 'tagName' in node && node.tagName === 'head',\n ) as DefaultTreeAdapterMap['element']\n const script = parseFragment(`<script data-miniapp-dev-load-error>${bootstrap}</script>`)\n .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(\n output,\n `<!-- miniapp-dev-entry: run build before packaging -->\\n${rewriteEntry(html, await loadClientCode())}`,\n )\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 (\n !name ||\n isAbsolute(name) ||\n name.includes('\\\\') ||\n name.includes(':') ||\n name.split('/').some((part) => !part || part === '.' || part === '..' || /[. ]$/.test(part))\n ) {\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))\n throw new Error(\n `Event output conflicts with an existing file: ${name}. Use content-hashed dependency filenames.`,\n )\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]\n .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, [\n 'manifest.json',\n '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(\n (source) =>\n source.isFile() &&\n !source.name.endsWith('.d.ts') &&\n config.eventsExtensions.some((ext) => source.name.endsWith(ext)),\n )\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',\n mode,\n isSsrBuild: false,\n 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(\n files,\n entries,\n (manifest.scripts ?? []).map((script) => script.entry),\n )\n if (hasEntries)\n server.config.logger.info(\n '[miniapp] Event scripts built. Reload the application in the host if it caches scripts.',\n )\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(\n `[miniapp] Event build failed: ${error instanceof Error ? error.message : String(error)}`,\n )\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 { BuildMiniappOptions, DevMiniappOptions, ResolvedMiniappConfig } from './types.js'\nimport { validateMiniappDirectory, validateSourceManifest } 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 ?? 'output')\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(options: BuildMiniappOptions = {}) {\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(options: DevMiniappOptions = {}): 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(resolve(config.root, config.manifestFile))\n\n const inlineConfig = createInlineConfig(config)\n const outDir = resolve(config.root, config.devOutDir)\n // Vite should ignore the on-disk development output as well as production output.\n inlineConfig.server = {\n ...inlineConfig.server,\n watch: {\n ...inlineConfig.server?.watch,\n ignored: [\n ...(Array.isArray(inlineConfig.server?.watch?.ignored)\n ? inlineConfig.server.watch.ignored\n : inlineConfig.server?.watch?.ignored\n ? [inlineConfig.server.watch.ignored]\n : []),\n `${outDir.replaceAll('\\\\', '/')}/**`,\n ],\n },\n }\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, mkdtemp, rename, rm, rmdir } 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 { PackageMiniappOptions, ResolvedMiniappConfig } 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 (\n value\n .trim()\n .replace(/[^a-zA-Z0-9._-]+/g, '-')\n .replace(/^-+|-+$/g, '') || 'miniapp'\n )\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 = config.packageFileName ?? `${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(directory: string, files: string[], outFile: string): Promise<void> {\n await mkdir(dirname(outFile), { recursive: true })\n const staging = await mkdtemp(resolve(dirname(outFile), '.miniapp-package-'))\n const temporaryArchive = resolve(staging, 'package.zip')\n const archive = new yazl.ZipFile()\n const output = createWriteStream(temporaryArchive)\n const completed = pipeline(archive.outputStream, output)\n // Observe stream failures immediately, including while entries are being added.\n void completed.catch(() => {})\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 await rename(temporaryArchive, outFile)\n } catch (error) {\n output.destroy()\n await completed.catch(() => {})\n throw error\n } finally {\n await rm(temporaryArchive, { force: true })\n await rmdir(staging)\n }\n}\n\nasync function removeBuildFiles(directory: string, files: string[]) {\n const directories = new Set<string>()\n for (const file of files) {\n const path = resolve(directory, file)\n const rel = relative(directory, path)\n if (!rel || rel === '..' || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {\n throw new Error(`Cannot clean a file outside the build output: ${file}`)\n }\n await rm(path, { force: true })\n for (let parent = dirname(path); parent !== directory; parent = dirname(parent)) directories.add(parent)\n }\n // Remove only empty directories; preserve the ZIP and any files added after validation.\n for (const path of [...directories].sort((a, b) => b.length - a.length)) {\n await rmdir(path).catch((error) => {\n if (!['ENOENT', 'ENOTEMPTY', 'EEXIST'].includes(error.code)) throw error\n })\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 archiveRelativeToDev = relative(resolve(config.root, config.devOutDir), outFile)\n if (\n archiveRelativeToDev === '' ||\n (archiveRelativeToDev !== '..' && !archiveRelativeToDev.startsWith(`..${sep}`) && !isAbsolute(archiveRelativeToDev))\n ) {\n throw new Error('Package output must be outside the development output directory')\n }\n // Repackaging with --no-build must not include the previous destination ZIP itself.\n const files = validated.files.filter((file) => relative(resolve(outDir, file), outFile) !== '')\n await writeZip(outDir, files, outFile)\n if (options.build ?? true) await removeBuildFiles(outDir, files)\n return { outFile, outDir }\n}\n"],"mappings":";;;;;;;;;;;;AAOA,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,MAAM,SAAS,OAAO,SAAS,YAAY,CAAC,KAAK,KAAK,CAAC,GACxF,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,YAAY,OAAO,OAA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ta.0",
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": "^1.2.0",
49
- "@xunlei-open/vite-plugin-miniapp": "^1.2.0"
48
+ "@xunlei-open/miniapp-types": "^1.3.0-beta.0",
49
+ "@xunlei-open/vite-plugin-miniapp": "^1.3.0-beta.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/yazl": "^3.3.1"
@@ -1 +0,0 @@
1
- {"version":3,"file":"package-jNl57UKj.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 { isAbsolute, relative, resolve, sep } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport { loadConfigFromFile, mergeConfig, type ConfigEnv, type UserConfig } from 'vite'\nimport type { MiniappModule, MiniappUserConfig, ResolvedMiniappConfig } 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(\n `Failed to load miniapp module \"${name}\" from ${configFile}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n )\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(`Multiple miniapp config files found: ${matches.map((file) => file.split('/').at(-1)).join(', ')}`)\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(vite: MiniappUserConfig['vite'], env: ConfigEnv): 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(rootDirectory: string, env: ConfigEnv): 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 const vite = mergeConfig(\n { build: { outDir: 'output' } },\n mergeConfig(await loadModules(config.modules ?? [], configFile, env), await resolveViteConfig(config.vite, env)),\n )\n const devOutDir = config.dev?.outDir ?? 'dist'\n const devPath = resolve(root, devOutDir)\n const buildPath = resolve(root, vite.build?.outDir ?? 'output')\n const contains = (parent: string, child: string) => {\n const path = relative(parent, child)\n return path === '' || (path !== '..' && !path.startsWith(`..${sep}`) && !isAbsolute(path))\n }\n if (contains(devPath, buildPath) || contains(buildPath, devPath)) {\n throw new Error('dev.outDir and vite.build.outDir must be separate directories, neither containing the other')\n }\n\n return {\n root,\n configFile,\n manifestFile: config.manifest ?? 'manifest.json',\n eventsDir: config.events?.dir ?? 'src/events',\n eventsExtensions,\n devOutDir,\n packageOutDir: config.package?.outDir ?? 'output',\n packageFileName: config.package?.fileName,\n vite,\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(directory: string, value: unknown, field: string): 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(directoryPath: string): 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(root: string, outDir: string, manifestFile: string, manifest: MiniappManifest) {\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 (\n !rootFromOutput ||\n (!rootFromOutput.startsWith(`..${sep}`) && rootFromOutput !== '..' && !isAbsolute(rootFromOutput))\n ) {\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\n .then(async () => {\n if (stopped) return\n if (event === 'unlink') await rm(iconOutput!, { force: true })\n else await copyIcon()\n server.config.logger.info(\n '[miniapp] Manifest icon updated. Reload the application in the host to refresh its icon.',\n )\n })\n .catch((error) => {\n server.config.logger.error(\n `[miniapp] Icon sync failed: ${error instanceof Error ? error.message : String(error)}`,\n )\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 (\n attr.name === 'src' ||\n attr.name === 'poster' ||\n (attr.name === 'href' && ['link', 'image', 'use'].includes(node.tagName)) ||\n (attr.name === 'data' && node.tagName === 'object')\n ) {\n if (attr.value && !attr.value.startsWith('#')) attr.value = new URL(attr.value, entryUrl).href\n }\n }\n if (\n node.tagName === 'script' &&\n node.attrs.some((attr) => attr.name === 'type' && attr.value.toLowerCase() === 'module') &&\n !node.attrs.some((attr) => attr.name === 'src')\n ) {\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 (\n node.tagName === 'script' &&\n node.attrs.some((attr) => attr.name === 'type' && attr.value.toLowerCase() === 'module') &&\n node.attrs.some(\n (attr) => attr.name === 'src' && new URL(attr.value, entryUrl).origin === new URL(entryUrl!).origin,\n )\n ) {\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(\n (node) => 'tagName' in node && node.tagName === 'html',\n ) as DefaultTreeAdapterMap['element']\n const head = htmlNode.childNodes.find(\n (node) => 'tagName' in node && node.tagName === 'head',\n ) as DefaultTreeAdapterMap['element']\n const script = parseFragment(`<script data-miniapp-dev-load-error>${bootstrap}</script>`)\n .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(\n output,\n `<!-- miniapp-dev-entry: run build before packaging -->\\n${rewriteEntry(html, await loadClientCode())}`,\n )\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 (\n !name ||\n isAbsolute(name) ||\n name.includes('\\\\') ||\n name.includes(':') ||\n name.split('/').some((part) => !part || part === '.' || part === '..' || /[. ]$/.test(part))\n ) {\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))\n throw new Error(\n `Event output conflicts with an existing file: ${name}. Use content-hashed dependency filenames.`,\n )\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]\n .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, [\n 'manifest.json',\n '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(\n (source) =>\n source.isFile() &&\n !source.name.endsWith('.d.ts') &&\n config.eventsExtensions.some((ext) => source.name.endsWith(ext)),\n )\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',\n mode,\n isSsrBuild: false,\n 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(\n files,\n entries,\n (manifest.scripts ?? []).map((script) => script.entry),\n )\n if (hasEntries)\n server.config.logger.info(\n '[miniapp] Event scripts built. Reload the application in the host if it caches scripts.',\n )\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(\n `[miniapp] Event build failed: ${error instanceof Error ? error.message : String(error)}`,\n )\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 { BuildMiniappOptions, DevMiniappOptions, ResolvedMiniappConfig } from './types.js'\nimport { validateMiniappDirectory, validateSourceManifest } 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 ?? 'output')\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(options: BuildMiniappOptions = {}) {\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(options: DevMiniappOptions = {}): 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(resolve(config.root, config.manifestFile))\n\n const inlineConfig = createInlineConfig(config)\n const outDir = resolve(config.root, config.devOutDir)\n // Vite should ignore the on-disk development output as well as production output.\n inlineConfig.server = {\n ...inlineConfig.server,\n watch: {\n ...inlineConfig.server?.watch,\n ignored: [\n ...(Array.isArray(inlineConfig.server?.watch?.ignored)\n ? inlineConfig.server.watch.ignored\n : inlineConfig.server?.watch?.ignored\n ? [inlineConfig.server.watch.ignored]\n : []),\n `${outDir.replaceAll('\\\\', '/')}/**`,\n ],\n },\n }\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, mkdtemp, rename, rm, rmdir } 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 { PackageMiniappOptions, ResolvedMiniappConfig } 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 (\n value\n .trim()\n .replace(/[^a-zA-Z0-9._-]+/g, '-')\n .replace(/^-+|-+$/g, '') || 'miniapp'\n )\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 = config.packageFileName ?? `${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(directory: string, files: string[], outFile: string): Promise<void> {\n await mkdir(dirname(outFile), { recursive: true })\n const staging = await mkdtemp(resolve(dirname(outFile), '.miniapp-package-'))\n const temporaryArchive = resolve(staging, 'package.zip')\n const archive = new yazl.ZipFile()\n const output = createWriteStream(temporaryArchive)\n const completed = pipeline(archive.outputStream, output)\n // Observe stream failures immediately, including while entries are being added.\n void completed.catch(() => {})\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 await rename(temporaryArchive, outFile)\n } catch (error) {\n output.destroy()\n await completed.catch(() => {})\n throw error\n } finally {\n await rm(temporaryArchive, { force: true })\n await rmdir(staging)\n }\n}\n\nasync function removeBuildFiles(directory: string, files: string[]) {\n const directories = new Set<string>()\n for (const file of files) {\n const path = resolve(directory, file)\n const rel = relative(directory, path)\n if (!rel || rel === '..' || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {\n throw new Error(`Cannot clean a file outside the build output: ${file}`)\n }\n await rm(path, { force: true })\n for (let parent = dirname(path); parent !== directory; parent = dirname(parent)) directories.add(parent)\n }\n // Remove only empty directories; preserve the ZIP and any files added after validation.\n for (const path of [...directories].sort((a, b) => b.length - a.length)) {\n await rmdir(path).catch((error) => {\n if (!['ENOENT', 'ENOTEMPTY', 'EEXIST'].includes(error.code)) throw error\n })\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 archiveRelativeToDev = relative(resolve(config.root, config.devOutDir), outFile)\n if (\n archiveRelativeToDev === '' ||\n (archiveRelativeToDev !== '..' && !archiveRelativeToDev.startsWith(`..${sep}`) && !isAbsolute(archiveRelativeToDev))\n ) {\n throw new Error('Package output must be outside the development output directory')\n }\n // Repackaging with --no-build must not include the previous destination ZIP itself.\n const files = validated.files.filter((file) => relative(resolve(outDir, file), outFile) !== '')\n await writeZip(outDir, files, outFile)\n if (options.build ?? true) await removeBuildFiles(outDir, files)\n return { outFile, outDir }\n}\n"],"mappings":";;;;;;;;;;;;AAOA,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,MAAM,SAAS,OAAO,SAAS,YAAY,CAAC,KAAK,KAAK,CAAC,GACxF,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,YAAY,OAAO,OAAO,SAAS,YAAY,CAAC,OAAO,MACtF,MAAM,IAAI,MAAM,uDAAuD;EAEzE,SAAS,YAAY,QAAQ,MAAM,kBAAkB,OAAO,MAAM,GAAG,CAAC;CACxE,SAAS,OAAO;EACd,MAAM,IAAI,MACR,kCAAkC,KAAK,SAAS,WAAW,IAAI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,KACpH,EAAE,OAAO,MAAM,CACjB;CACF;CAEF,OAAO;AACT;AAEA,SAAS,eAAe,MAAsB;CAC5C,MAAM,UAAU,aAAa,KAAK,SAAS,QAAQ,MAAM,IAAI,CAAC,CAAC,CAAC,OAAO,UAA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