@wolfstar/vite-server 0.2.4 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as createViteConfig, i as _checkPrivateRedeclaration, n as ServerBuilder, r as _assertClassBrand, s as defaultBuilderContext, t as createBuildLogger } from "./logger-5tpPvmoV.js";
1
+ import { a as createViteConfig, i as _checkPrivateRedeclaration, n as ServerBuilder, r as _assertClassBrand, s as defaultBuilderContext, t as createBuildLogger } from "./logger-BgqD-3--.js";
2
2
  import { toNodeHandler } from "srvx/node";
3
3
 
4
4
  //#region \0@oxc-project+runtime@0.151.0/helpers/esm/classPrivateMethodInitSpec.js
@@ -1,9 +1,21 @@
1
1
  import { a as ViteModule, i as ViteHooks, n as ServerBuilder, r as ServerHooks, s as toArray, t as defaultBuilderContext } from "./context-VAAA2m2X.js";
2
- import { BuilderLogLevel, ResolvedStarsConfig } from "@wolfstar/schema";
2
+ import { BuilderLogLevel, ResolvedStarsConfig, StarsEnvSetupOptions } from "@wolfstar/schema";
3
3
  //#region src/plugins.d.ts
4
+ /**
5
+ * The module that loads the project's environment (`env` in `stars.config`). It is virtual so its import can come
6
+ * first in the entry: ES modules evaluate their imports in order, and every `@wolfstar/plugin-*` registration (and the
7
+ * bot's own modules) may read `process.env` as soon as it is evaluated.
8
+ */
9
+ export declare const STARS_ENV_MODULE = "\0stars:env";
10
+ /**
11
+ * The source of the env module: `setup()` from `@wolfstar/env-utilities` called with the resolved options.
12
+ * `specifier` lets a host that cannot resolve bare specifiers (a `data:` URL preload) point at the file itself.
13
+ */
14
+ export declare function envModuleSource(options: Readonly<StarsEnvSetupOptions>, specifier?: string): string;
4
15
  /**
5
16
  * Activates installed WolfStar plugins without making applications maintain a list
6
- * of side-effect-only plugin registration imports in their entry point.
17
+ * of side-effect-only plugin registration imports in their entry point, and registers the project's environment
18
+ * ahead of them.
7
19
  */
8
20
  export declare function pluginRegistrations(config: ResolvedStarsConfig): object;
9
21
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","names":[],"sources":["../../src/plugins.ts","../../src/logger.ts"],"mappings":";;;;;;;wBAgBgB,oBAAoB,QAAQ;;;wBCd5B,kBAAkB,MAAM,YAAY,MAAM,OAAO,iBAAiB;;;;EAKnE,OAAA;EACA,OAAA;EACE,SAAA;EAMD,QAAA"}
1
+ {"version":3,"file":"internal.d.ts","names":[],"sources":["../../src/plugins.ts","../../src/logger.ts"],"mappings":";;;;;;;;qBAiBa;;;;;wBAMG,gBAAgB,SAAS,SAAS,uBAAuB;;;;;;wBASzD,oBAAoB,QAAQ;;;wBC9B5B,kBAAkB,MAAM,YAAY,MAAM,OAAO,iBAAiB;;;;EAKnE,OAAA;EACA,OAAA;EACE,SAAA;EAMD,QAAA"}
@@ -1,3 +1,3 @@
1
- import { c as pluginRegistrations, n as ServerBuilder, o as toArray, s as defaultBuilderContext, t as createBuildLogger } from "./logger-5tpPvmoV.js";
1
+ import { c as STARS_ENV_MODULE, l as envModuleSource, n as ServerBuilder, o as toArray, s as defaultBuilderContext, t as createBuildLogger, u as pluginRegistrations } from "./logger-BgqD-3--.js";
2
2
 
3
- export { ServerBuilder, createBuildLogger, defaultBuilderContext, pluginRegistrations, toArray };
3
+ export { STARS_ENV_MODULE, ServerBuilder, createBuildLogger, defaultBuilderContext, envModuleSource, pluginRegistrations, toArray };
@@ -7,18 +7,39 @@ import { EventEmitter } from "node:events";
7
7
  //#region src/plugins.ts
8
8
  const PLUGIN_PACKAGE = /^@wolfstar\/plugin-[^/]+$/;
9
9
  /**
10
+ * The module that loads the project's environment (`env` in `stars.config`). It is virtual so its import can come
11
+ * first in the entry: ES modules evaluate their imports in order, and every `@wolfstar/plugin-*` registration (and the
12
+ * bot's own modules) may read `process.env` as soon as it is evaluated.
13
+ */
14
+ const STARS_ENV_MODULE = "\0stars:env";
15
+ /**
16
+ * The source of the env module: `setup()` from `@wolfstar/env-utilities` called with the resolved options.
17
+ * `specifier` lets a host that cannot resolve bare specifiers (a `data:` URL preload) point at the file itself.
18
+ */
19
+ function envModuleSource(options, specifier = "@wolfstar/env-utilities") {
20
+ return `import { setup } from ${JSON.stringify(specifier)};\nsetup(${JSON.stringify(options)});\n`;
21
+ }
22
+ /**
10
23
  * Activates installed WolfStar plugins without making applications maintain a list
11
- * of side-effect-only plugin registration imports in their entry point.
24
+ * of side-effect-only plugin registration imports in their entry point, and registers the project's environment
25
+ * ahead of them.
12
26
  */
13
27
  function pluginRegistrations(config) {
14
28
  const plugins = findPluginDependencies(config.root);
15
29
  const entry = resolve(config.entry);
30
+ const env = config.env?.enabled ? config.env.options : null;
16
31
  return {
17
32
  name: "stars:plugin-registrations",
33
+ resolveId(id) {
34
+ return env !== null && id === "\0stars:env" ? STARS_ENV_MODULE : null;
35
+ },
36
+ load(id) {
37
+ return env !== null && id === "\0stars:env" ? envModuleSource(env) : null;
38
+ },
18
39
  transform(code, id) {
19
- if (plugins.length === 0 || cleanId(id) !== entry) return null;
40
+ if (plugins.length === 0 && env === null || cleanId(id) !== entry) return null;
20
41
  return {
21
- code: `${plugins.map((name) => `import ${JSON.stringify(`${name}/register`)};`).join("\n")}\n${code}`,
42
+ code: `${[...env === null ? [] : [STARS_ENV_MODULE], ...plugins.map((name) => `${name}/register`)].map((specifier) => `import ${JSON.stringify(specifier)};`).join("\n")}\n${code}`,
22
43
  map: null
23
44
  };
24
45
  }
@@ -294,5 +315,5 @@ function createBuildLogger(vite, log) {
294
315
  }
295
316
 
296
317
  //#endregion
297
- export { createViteConfig as a, pluginRegistrations as c, _checkPrivateRedeclaration as i, ServerBuilder as n, toArray as o, _assertClassBrand as r, defaultBuilderContext as s, createBuildLogger as t };
298
- //# sourceMappingURL=logger-5tpPvmoV.js.map
318
+ export { createViteConfig as a, STARS_ENV_MODULE as c, _checkPrivateRedeclaration as i, envModuleSource as l, ServerBuilder as n, toArray as o, _assertClassBrand as r, defaultBuilderContext as s, createBuildLogger as t, pluginRegistrations as u };
319
+ //# sourceMappingURL=logger-BgqD-3--.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger-BgqD-3--.js","names":[],"sources":["../../src/plugins.ts","../../src/context.ts","../../src/config.ts","../../src/lifecycle.ts","../../src/logger.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport type { ResolvedStarsConfig, StarsEnvSetupOptions } from '@wolfstar/schema';\n\ninterface PackageJson {\n\tdependencies?: Record<string, string>;\n\toptionalDependencies?: Record<string, string>;\n\texports?: unknown;\n}\n\nconst PLUGIN_PACKAGE = /^@wolfstar\\/plugin-[^/]+$/;\n\n/**\n * The module that loads the project's environment (`env` in `stars.config`). It is virtual so its import can come\n * first in the entry: ES modules evaluate their imports in order, and every `@wolfstar/plugin-*` registration (and the\n * bot's own modules) may read `process.env` as soon as it is evaluated.\n */\nexport const STARS_ENV_MODULE = '\\0stars:env';\n\n/**\n * The source of the env module: `setup()` from `@wolfstar/env-utilities` called with the resolved options.\n * `specifier` lets a host that cannot resolve bare specifiers (a `data:` URL preload) point at the file itself.\n */\nexport function envModuleSource(options: Readonly<StarsEnvSetupOptions>, specifier = '@wolfstar/env-utilities'): string {\n\treturn `import { setup } from ${JSON.stringify(specifier)};\\nsetup(${JSON.stringify(options)});\\n`;\n}\n\n/**\n * Activates installed WolfStar plugins without making applications maintain a list\n * of side-effect-only plugin registration imports in their entry point, and registers the project's environment\n * ahead of them.\n */\nexport function pluginRegistrations(config: ResolvedStarsConfig): object {\n\tconst plugins = findPluginDependencies(config.root);\n\tconst entry = resolve(config.entry);\n\t// Optional: hosts and tests may hand over a configuration resolved before `env` existed.\n\tconst env = config.env?.enabled ? config.env.options : null;\n\n\treturn {\n\t\tname: 'stars:plugin-registrations',\n\t\tresolveId(id: string) {\n\t\t\treturn env !== null && id === STARS_ENV_MODULE ? STARS_ENV_MODULE : null;\n\t\t},\n\t\tload(id: string) {\n\t\t\treturn env !== null && id === STARS_ENV_MODULE ? envModuleSource(env) : null;\n\t\t},\n\t\ttransform(code: string, id: string) {\n\t\t\tif ((plugins.length === 0 && env === null) || cleanId(id) !== entry) return null;\n\n\t\t\tconst specifiers = [...(env === null ? [] : [STARS_ENV_MODULE]), ...plugins.map((name) => `${name}/register`)];\n\t\t\treturn { code: `${specifiers.map((specifier) => `import ${JSON.stringify(specifier)};`).join('\\n')}\\n${code}`, map: null };\n\t\t}\n\t};\n}\n\nfunction findPluginDependencies(root: string): string[] {\n\tconst packageJson = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')) as PackageJson;\n\treturn [...new Set([...Object.keys(packageJson.dependencies ?? {}), ...Object.keys(packageJson.optionalDependencies ?? {})])]\n\t\t.filter((name) => PLUGIN_PACKAGE.test(name) && mayExportRegister(root, name))\n\t\t.sort();\n}\n\n/**\n * Not every `@wolfstar/plugin-*` package is activated through a `/register` entrypoint: some (`plugin-cache`,\n * `plugin-gateway`, `plugin-sharder`) are libraries used directly, and injecting an import of a subpath they do not\n * export breaks the build. Only a package whose `exports` map is known and has no `./register` subpath is skipped —\n * one that is not installed, or declares no `exports`, keeps being injected so a missing install still surfaces as a\n * resolution error.\n */\nfunction mayExportRegister(root: string, name: string): boolean {\n\tconst packageJson = readInstalledPackageJson(root, name);\n\tif (packageJson?.exports === undefined || packageJson.exports === null) return true;\n\treturn exportsSubpath(packageJson.exports, './register');\n}\n\nfunction readInstalledPackageJson(root: string, name: string): PackageJson | null {\n\tlet directory = resolve(root);\n\twhile (true) {\n\t\ttry {\n\t\t\treturn JSON.parse(readFileSync(join(directory, 'node_modules', name, 'package.json'), 'utf8')) as PackageJson;\n\t\t} catch {\n\t\t\tconst parent = dirname(directory);\n\t\t\tif (parent === directory) return null;\n\t\t\tdirectory = parent;\n\t\t}\n\t}\n}\n\nfunction exportsSubpath(exports: unknown, subpath: string): boolean {\n\t// A string, an array, or an object of conditions only is the sugar for the `\".\"` subpath alone.\n\tif (typeof exports !== 'object' || exports === null || Array.isArray(exports)) return false;\n\n\tconst keys = Object.keys(exports);\n\tif (!keys.some((key) => key.startsWith('.'))) return false;\n\tif (Object.hasOwn(exports, subpath)) return (exports as Record<string, unknown>)[subpath] !== null;\n\n\treturn keys.some((key) => {\n\t\tconst star = key.indexOf('*');\n\t\tif (star === -1) return false;\n\t\tconst prefix = key.slice(0, star);\n\t\tconst suffix = key.slice(star + 1);\n\t\treturn subpath.length >= key.length && subpath.startsWith(prefix) && subpath.endsWith(suffix);\n\t});\n}\n\nfunction cleanId(id: string): string {\n\treturn resolve(id.replace(/^\\0/, '').split('?', 1)[0]!);\n}\n","import { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { BuilderContext } from '@wolfstar/schema';\nimport { pluginRegistrations } from './plugins.js';\n\n/** Default host for standalone use. Dependencies always resolve from the application. */\nexport const defaultBuilderContext: BuilderContext = {\n\tpluginRegistrations,\n\tasync importFromProject<T>(root: string, id: string, hint: string): Promise<T> {\n\t\tlet entry: string;\n\t\ttry {\n\t\t\tentry = createRequire(join(root, 'package.json')).resolve(id);\n\t\t} catch (cause) {\n\t\t\tthrow new Error(`Cannot resolve ${id} from ${root}. ${hint}`, { cause });\n\t\t}\n\t\treturn (await import(pathToFileURL(entry).href)) as T;\n\t}\n};\n","import { basename } from 'node:path';\nimport type { BuilderContext, ResolvedStarsConfig } from '@wolfstar/schema';\nimport type { InlineConfig, Plugin, UserConfig } from 'vite';\nimport { defaultBuilderContext } from './context.js';\n\nexport type ViteModule = typeof import('vite');\nexport interface ViteHooks {\n\tconfigure?(options: InlineConfig, command: 'build' | 'serve'): void | Promise<void>;\n}\n\n/** Defaults are applied after Vite loads its config, so explicit project options win. */\nexport function createViteConfig(config: ResolvedStarsConfig, context: BuilderContext = defaultBuilderContext): InlineConfig {\n\tconst defaults: Plugin = {\n\t\tname: 'stars:server-defaults',\n\t\tenforce: 'pre',\n\t\tconfig(options) {\n\t\t\toptions.build ??= {};\n\t\t\toptions.build.ssr ??= config.entry;\n\t\t\toptions.build.outDir ??= config.build.outDir;\n\t\t\toptions.build.sourcemap ??= true;\n\t\t\toptions.build.rollupOptions ??= {};\n\t\t\tconst output = options.build.rollupOptions.output;\n\t\t\tif (!Array.isArray(output)) options.build.rollupOptions.output = { entryFileNames: basename(config.build.output), ...output };\n\t\t\toptions.resolve ??= {};\n\t\t\toptions.resolve.tsconfigPaths ??= true;\n\t\t}\n\t};\n\tconst inline = config.vite as UserConfig;\n\treturn {\n\t\t...inline,\n\t\troot: config.root,\n\t\tconfigFile: config.build.configFile ?? false,\n\t\tplugins: [defaults, context.pluginRegistrations(config) as Plugin, ...toArray(inline.plugins)]\n\t};\n}\n\nexport function toArray<T>(value: T | T[] | undefined): T[] {\n\treturn value === undefined ? [] : Array.isArray(value) ? value : [value];\n}\n","import { EventEmitter } from 'node:events';\nimport type { Builder, BuilderContext, BuilderEvents, BuildOutcome, ResolvedStarsConfig } from '@wolfstar/schema';\nimport { defaultBuilderContext } from './context.js';\n\nexport interface ServerHooks {\n\tbeforeBuild?(config: ResolvedStarsConfig): void | Promise<void>;\n\tafterBuild?(outcome: BuildOutcome): void | Promise<void>;\n\tclose?(): void | Promise<void>;\n}\n\n/** Shared lifecycle: coalesce concurrent builds, report failures and drain work before close. */\nexport abstract class ServerBuilder extends EventEmitter<BuilderEvents> implements Builder {\n\tpublic readonly tool = 'vite' as const;\n\tprotected closed = false;\n\tprotected active: Promise<BuildOutcome> | null = null;\n\tprotected watching: Promise<void> | null = null;\n\tprotected stopWatching: (() => Promise<void>) | null = null;\n\t#closing: Promise<void> | null = null;\n\tprotected constructor(\n\t\tprotected readonly config: ResolvedStarsConfig,\n\t\tprotected readonly context: BuilderContext = defaultBuilderContext,\n\t\tprotected readonly hooks: ServerHooks = {}\n\t) {\n\t\tsuper();\n\t}\n\tpublic build(): Promise<BuildOutcome> {\n\t\tif (this.closed) return Promise.reject(new Error('The server builder is closed. Create a new builder to restart.'));\n\t\tif (this.active) return this.active;\n\t\tthis.active = this.runBuild().finally(() => {\n\t\t\tthis.active = null;\n\t\t});\n\t\treturn this.active;\n\t}\n\tprivate async runBuild(): Promise<BuildOutcome> {\n\t\tconst started = performance.now();\n\t\tthis.emit('start');\n\t\tlet message: string | null = null;\n\t\ttry {\n\t\t\tawait this.hooks.beforeBuild?.(this.config);\n\t\t\tawait this.compile();\n\t\t} catch (error) {\n\t\t\tmessage = error instanceof Error ? error.message : String(error);\n\t\t}\n\t\tconst outcome = { ok: message === null, durationMs: Math.round(performance.now() - started), message };\n\t\ttry {\n\t\t\tawait this.hooks.afterBuild?.(outcome);\n\t\t} catch (error) {\n\t\t\toutcome.ok = false;\n\t\t\toutcome.message = error instanceof Error ? error.message : String(error);\n\t\t}\n\t\tif (!this.closed) this.emit(outcome.ok ? 'success' : 'failure', outcome);\n\t\treturn outcome;\n\t}\n\tprotected abstract compile(): Promise<void>;\n\tprotected abstract startWatching(): Promise<void>;\n\tpublic watch(): Promise<void> {\n\t\tif (this.closed) return Promise.reject(new Error('The server builder is closed.'));\n\t\tthis.watching ??= this.startWatching().catch(async (error: unknown) => {\n\t\t\tconst stop = this.stopWatching;\n\t\t\tthis.stopWatching = null;\n\t\t\tawait stop?.();\n\t\t\tthis.watching = null;\n\t\t\tthrow error;\n\t\t});\n\t\treturn this.watching;\n\t}\n\tpublic close(): Promise<void> {\n\t\tthis.closed = true;\n\t\tthis.#closing ??= (async () => {\n\t\t\ttry {\n\t\t\t\tawait this.watching?.catch(() => {});\n\t\t\t\tconst stop = this.stopWatching;\n\t\t\t\tthis.stopWatching = null;\n\t\t\t\ttry {\n\t\t\t\t\tawait stop?.();\n\t\t\t\t} finally {\n\t\t\t\t\tawait this.active;\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tawait this.hooks.close?.();\n\t\t\t}\n\t\t})();\n\t\treturn this.#closing;\n\t}\n}\n","import type { BuilderLogLevel } from '@wolfstar/schema';\nimport type { ViteModule } from './config.js';\nexport function createBuildLogger(vite: ViteModule, log: (level: BuilderLogLevel, text: string) => void) {\n\tconst logger = vite.createLogger('warn', { allowClearScreen: false });\n\tconst warned = new Set<string>();\n\treturn {\n\t\t...logger,\n\t\tinfo: (text: string) => log('info', text),\n\t\twarn: (text: string) => log('warn', text),\n\t\twarnOnce(text: string) {\n\t\t\tif (!warned.has(text)) {\n\t\t\t\twarned.add(text);\n\t\t\t\tlog('warn', text);\n\t\t\t}\n\t\t},\n\t\terror: (text: string) => log('error', text)\n\t};\n}\n"],"mappings":";;;;;;;AAUA,MAAM,iBAAiB;;;;;;AAOvB,MAAa,mBAAmB;;;;;AAMhC,SAAgB,gBAAgB,SAAyC,YAAY,2BAAmC;CACvH,OAAO,yBAAyB,KAAK,UAAU,SAAS,EAAE,WAAW,KAAK,UAAU,OAAO,EAAE;AAC9F;;;;;;AAOA,SAAgB,oBAAoB,QAAqC;CACxE,MAAM,UAAU,uBAAuB,OAAO,IAAI;CAClD,MAAM,QAAQ,QAAQ,OAAO,KAAK;CAElC,MAAM,MAAM,OAAO,KAAK,UAAU,OAAO,IAAI,UAAU;CAEvD,OAAO;EACN,MAAM;EACN,UAAU,IAAY;GACrB,OAAO,QAAQ,QAAQ,uBAA0B,mBAAmB;EACrE;EACA,KAAK,IAAY;GAChB,OAAO,QAAQ,QAAQ,uBAA0B,gBAAgB,GAAG,IAAI;EACzE;EACA,UAAU,MAAc,IAAY;GACnC,IAAK,QAAQ,WAAW,KAAK,QAAQ,QAAS,QAAQ,EAAE,MAAM,OAAO,OAAO;GAG5E,OAAO;IAAE,MAAM,GAAG,CADE,GAAI,QAAQ,OAAO,CAAC,IAAI,CAAC,gBAAgB,GAAI,GAAG,QAAQ,KAAK,SAAS,GAAG,KAAK,UAAU,CACjF,CAAC,CAAC,KAAK,cAAc,UAAU,KAAK,UAAU,SAAS,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE,IAAI;IAAQ,KAAK;GAAK;EAC1H;CACD;AACD;AAEA,SAAS,uBAAuB,MAAwB;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AAW,OAAO;EACvE,OAAO;CACR;CAGA,AAAO,QAAuB;EAC7B,IAAI,KAAK,QAAQ,OAAO,QAAQ,uBAAO,IAAI,MAAM,+BAA+B,CAAC;EACjF,KAAK,aAAa,KAAK,cAAc,CAAC,CAAC,MAAM,OAAO,UAAmB;GACtE,MAAM,OAAO,KAAK;GAClB,KAAK,eAAe;GACpB,MAAM,OAAO;GACb,KAAK,WAAW;GAChB,MAAM;EACP,CAAC;EACD,OAAO,KAAK;CACb;CACA,AAAO,QAAuB;EAC7B,KAAK,SAAS;EACd,kFAAmB,YAAY;GAC9B,IAAI;IACH,MAAM,KAAK,UAAU,YAAY,CAAC,CAAC;IACnC,MAAM,OAAO,KAAK;IAClB,KAAK,eAAe;IACpB,IAAI;KACH,MAAM,OAAO;IACd,UAAU;KACT,MAAM,KAAK;IACZ;GACD,UAAU;IACT,MAAM,KAAK,MAAM,QAAQ;GAC1B;EACD,EAAC,CAAE;EACH,wCAAO;CACR;AACD;;;;AClFA,SAAgB,kBAAkB,MAAkB,KAAqD;CACxG,MAAM,SAAS,KAAK,aAAa,QAAQ,EAAE,kBAAkB,MAAM,CAAC;CACpE,MAAM,yBAAS,IAAI,IAAY;CAC/B,OAAO;EACN,GAAG;EACH,OAAO,SAAiB,IAAI,QAAQ,IAAI;EACxC,OAAO,SAAiB,IAAI,QAAQ,IAAI;EACxC,SAAS,MAAc;GACtB,IAAI,CAAC,OAAO,IAAI,IAAI,GAAG;IACtB,OAAO,IAAI,IAAI;IACf,IAAI,QAAQ,IAAI;GACjB;EACD;EACA,QAAQ,SAAiB,IAAI,SAAS,IAAI;CAC3C;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wolfstar/vite-server",
3
- "version": "0.2.4",
3
+ "version": "0.3.0",
4
4
  "description": "Vite build and watch integration for Stars projects",
5
5
  "keywords": [
6
6
  "api",
@@ -51,7 +51,7 @@
51
51
  "provenance": true
52
52
  },
53
53
  "dependencies": {
54
- "@wolfstar/schema": "^0.3.0",
54
+ "@wolfstar/schema": "^0.4.0",
55
55
  "srvx": "^1.0.5"
56
56
  },
57
57
  "devDependencies": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger-5tpPvmoV.js","names":[],"sources":["../../src/plugins.ts","../../src/context.ts","../../src/config.ts","../../src/lifecycle.ts","../../src/logger.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport type { ResolvedStarsConfig } from '@wolfstar/schema';\n\ninterface PackageJson {\n\tdependencies?: Record<string, string>;\n\toptionalDependencies?: Record<string, string>;\n\texports?: unknown;\n}\n\nconst PLUGIN_PACKAGE = /^@wolfstar\\/plugin-[^/]+$/;\n\n/**\n * Activates installed WolfStar plugins without making applications maintain a list\n * of side-effect-only plugin registration imports in their entry point.\n */\nexport function pluginRegistrations(config: ResolvedStarsConfig): object {\n\tconst plugins = findPluginDependencies(config.root);\n\tconst entry = resolve(config.entry);\n\n\treturn {\n\t\tname: 'stars:plugin-registrations',\n\t\ttransform(code: string, id: string) {\n\t\t\tif (plugins.length === 0 || cleanId(id) !== entry) return null;\n\n\t\t\tconst registrations = plugins.map((name) => `import ${JSON.stringify(`${name}/register`)};`).join('\\n');\n\t\t\treturn { code: `${registrations}\\n${code}`, map: null };\n\t\t}\n\t};\n}\n\nfunction findPluginDependencies(root: string): string[] {\n\tconst packageJson = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')) as PackageJson;\n\treturn [...new Set([...Object.keys(packageJson.dependencies ?? {}), ...Object.keys(packageJson.optionalDependencies ?? {})])]\n\t\t.filter((name) => PLUGIN_PACKAGE.test(name) && mayExportRegister(root, name))\n\t\t.sort();\n}\n\n/**\n * Not every `@wolfstar/plugin-*` package is activated through a `/register` entrypoint: some (`plugin-cache`,\n * `plugin-gateway`, `plugin-sharder`) are libraries used directly, and injecting an import of a subpath they do not\n * export breaks the build. Only a package whose `exports` map is known and has no `./register` subpath is skipped —\n * one that is not installed, or declares no `exports`, keeps being injected so a missing install still surfaces as a\n * resolution error.\n */\nfunction mayExportRegister(root: string, name: string): boolean {\n\tconst packageJson = readInstalledPackageJson(root, name);\n\tif (packageJson?.exports === undefined || packageJson.exports === null) return true;\n\treturn exportsSubpath(packageJson.exports, './register');\n}\n\nfunction readInstalledPackageJson(root: string, name: string): PackageJson | null {\n\tlet directory = resolve(root);\n\twhile (true) {\n\t\ttry {\n\t\t\treturn JSON.parse(readFileSync(join(directory, 'node_modules', name, 'package.json'), 'utf8')) as PackageJson;\n\t\t} catch {\n\t\t\tconst parent = dirname(directory);\n\t\t\tif (parent === directory) return null;\n\t\t\tdirectory = parent;\n\t\t}\n\t}\n}\n\nfunction exportsSubpath(exports: unknown, subpath: string): boolean {\n\t// A string, an array, or an object of conditions only is the sugar for the `\".\"` subpath alone.\n\tif (typeof exports !== 'object' || exports === null || Array.isArray(exports)) return false;\n\n\tconst keys = Object.keys(exports);\n\tif (!keys.some((key) => key.startsWith('.'))) return false;\n\tif (Object.hasOwn(exports, subpath)) return (exports as Record<string, unknown>)[subpath] !== null;\n\n\treturn keys.some((key) => {\n\t\tconst star = key.indexOf('*');\n\t\tif (star === -1) return false;\n\t\tconst prefix = key.slice(0, star);\n\t\tconst suffix = key.slice(star + 1);\n\t\treturn subpath.length >= key.length && subpath.startsWith(prefix) && subpath.endsWith(suffix);\n\t});\n}\n\nfunction cleanId(id: string): string {\n\treturn resolve(id.replace(/^\\0/, '').split('?', 1)[0]!);\n}\n","import { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { BuilderContext } from '@wolfstar/schema';\nimport { pluginRegistrations } from './plugins.js';\n\n/** Default host for standalone use. Dependencies always resolve from the application. */\nexport const defaultBuilderContext: BuilderContext = {\n\tpluginRegistrations,\n\tasync importFromProject<T>(root: string, id: string, hint: string): Promise<T> {\n\t\tlet entry: string;\n\t\ttry {\n\t\t\tentry = createRequire(join(root, 'package.json')).resolve(id);\n\t\t} catch (cause) {\n\t\t\tthrow new Error(`Cannot resolve ${id} from ${root}. ${hint}`, { cause });\n\t\t}\n\t\treturn (await import(pathToFileURL(entry).href)) as T;\n\t}\n};\n","import { basename } from 'node:path';\nimport type { BuilderContext, ResolvedStarsConfig } from '@wolfstar/schema';\nimport type { InlineConfig, Plugin, UserConfig } from 'vite';\nimport { defaultBuilderContext } from './context.js';\n\nexport type ViteModule = typeof import('vite');\nexport interface ViteHooks {\n\tconfigure?(options: InlineConfig, command: 'build' | 'serve'): void | Promise<void>;\n}\n\n/** Defaults are applied after Vite loads its config, so explicit project options win. */\nexport function createViteConfig(config: ResolvedStarsConfig, context: BuilderContext = defaultBuilderContext): InlineConfig {\n\tconst defaults: Plugin = {\n\t\tname: 'stars:server-defaults',\n\t\tenforce: 'pre',\n\t\tconfig(options) {\n\t\t\toptions.build ??= {};\n\t\t\toptions.build.ssr ??= config.entry;\n\t\t\toptions.build.outDir ??= config.build.outDir;\n\t\t\toptions.build.sourcemap ??= true;\n\t\t\toptions.build.rollupOptions ??= {};\n\t\t\tconst output = options.build.rollupOptions.output;\n\t\t\tif (!Array.isArray(output)) options.build.rollupOptions.output = { entryFileNames: basename(config.build.output), ...output };\n\t\t\toptions.resolve ??= {};\n\t\t\toptions.resolve.tsconfigPaths ??= true;\n\t\t}\n\t};\n\tconst inline = config.vite as UserConfig;\n\treturn {\n\t\t...inline,\n\t\troot: config.root,\n\t\tconfigFile: config.build.configFile ?? false,\n\t\tplugins: [defaults, context.pluginRegistrations(config) as Plugin, ...toArray(inline.plugins)]\n\t};\n}\n\nexport function toArray<T>(value: T | T[] | undefined): T[] {\n\treturn value === undefined ? [] : Array.isArray(value) ? value : [value];\n}\n","import { EventEmitter } from 'node:events';\nimport type { Builder, BuilderContext, BuilderEvents, BuildOutcome, ResolvedStarsConfig } from '@wolfstar/schema';\nimport { defaultBuilderContext } from './context.js';\n\nexport interface ServerHooks {\n\tbeforeBuild?(config: ResolvedStarsConfig): void | Promise<void>;\n\tafterBuild?(outcome: BuildOutcome): void | Promise<void>;\n\tclose?(): void | Promise<void>;\n}\n\n/** Shared lifecycle: coalesce concurrent builds, report failures and drain work before close. */\nexport abstract class ServerBuilder extends EventEmitter<BuilderEvents> implements Builder {\n\tpublic readonly tool = 'vite' as const;\n\tprotected closed = false;\n\tprotected active: Promise<BuildOutcome> | null = null;\n\tprotected watching: Promise<void> | null = null;\n\tprotected stopWatching: (() => Promise<void>) | null = null;\n\t#closing: Promise<void> | null = null;\n\tprotected constructor(\n\t\tprotected readonly config: ResolvedStarsConfig,\n\t\tprotected readonly context: BuilderContext = defaultBuilderContext,\n\t\tprotected readonly hooks: ServerHooks = {}\n\t) {\n\t\tsuper();\n\t}\n\tpublic build(): Promise<BuildOutcome> {\n\t\tif (this.closed) return Promise.reject(new Error('The server builder is closed. Create a new builder to restart.'));\n\t\tif (this.active) return this.active;\n\t\tthis.active = this.runBuild().finally(() => {\n\t\t\tthis.active = null;\n\t\t});\n\t\treturn this.active;\n\t}\n\tprivate async runBuild(): Promise<BuildOutcome> {\n\t\tconst started = performance.now();\n\t\tthis.emit('start');\n\t\tlet message: string | null = null;\n\t\ttry {\n\t\t\tawait this.hooks.beforeBuild?.(this.config);\n\t\t\tawait this.compile();\n\t\t} catch (error) {\n\t\t\tmessage = error instanceof Error ? error.message : String(error);\n\t\t}\n\t\tconst outcome = { ok: message === null, durationMs: Math.round(performance.now() - started), message };\n\t\ttry {\n\t\t\tawait this.hooks.afterBuild?.(outcome);\n\t\t} catch (error) {\n\t\t\toutcome.ok = false;\n\t\t\toutcome.message = error instanceof Error ? error.message : String(error);\n\t\t}\n\t\tif (!this.closed) this.emit(outcome.ok ? 'success' : 'failure', outcome);\n\t\treturn outcome;\n\t}\n\tprotected abstract compile(): Promise<void>;\n\tprotected abstract startWatching(): Promise<void>;\n\tpublic watch(): Promise<void> {\n\t\tif (this.closed) return Promise.reject(new Error('The server builder is closed.'));\n\t\tthis.watching ??= this.startWatching().catch(async (error: unknown) => {\n\t\t\tconst stop = this.stopWatching;\n\t\t\tthis.stopWatching = null;\n\t\t\tawait stop?.();\n\t\t\tthis.watching = null;\n\t\t\tthrow error;\n\t\t});\n\t\treturn this.watching;\n\t}\n\tpublic close(): Promise<void> {\n\t\tthis.closed = true;\n\t\tthis.#closing ??= (async () => {\n\t\t\ttry {\n\t\t\t\tawait this.watching?.catch(() => {});\n\t\t\t\tconst stop = this.stopWatching;\n\t\t\t\tthis.stopWatching = null;\n\t\t\t\ttry {\n\t\t\t\t\tawait stop?.();\n\t\t\t\t} finally {\n\t\t\t\t\tawait this.active;\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tawait this.hooks.close?.();\n\t\t\t}\n\t\t})();\n\t\treturn this.#closing;\n\t}\n}\n","import type { BuilderLogLevel } from '@wolfstar/schema';\nimport type { ViteModule } from './config.js';\nexport function createBuildLogger(vite: ViteModule, log: (level: BuilderLogLevel, text: string) => void) {\n\tconst logger = vite.createLogger('warn', { allowClearScreen: false });\n\tconst warned = new Set<string>();\n\treturn {\n\t\t...logger,\n\t\tinfo: (text: string) => log('info', text),\n\t\twarn: (text: string) => log('warn', text),\n\t\twarnOnce(text: string) {\n\t\t\tif (!warned.has(text)) {\n\t\t\t\twarned.add(text);\n\t\t\t\tlog('warn', text);\n\t\t\t}\n\t\t},\n\t\terror: (text: string) => log('error', text)\n\t};\n}\n"],"mappings":";;;;;;;AAUA,MAAM,iBAAiB;;;;;AAMvB,SAAgB,oBAAoB,QAAqC;CACxE,MAAM,UAAU,uBAAuB,OAAO,IAAI;CAClD,MAAM,QAAQ,QAAQ,OAAO,KAAK;CAElC,OAAO;EACN,MAAM;EACN,UAAU,MAAc,IAAY;GACnC,IAAI,QAAQ,WAAW,KAAK,QAAQ,EAAE,MAAM,OAAO,OAAO;GAG1D,OAAO;IAAE,MAAM,GADO,QAAQ,KAAK,SAAS,UAAU,KAAK,UAAU,GAAG,KAAK,UAAU,EAAE,EAAE,CAAC,CAAC,KAAK,IACpE,EAAE,IAAI;IA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