@wolfstar/http-framework 5.0.0-next-20260919162943 → 5.1.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 +18 -3
- package/bin/stars.mjs +2 -0
- package/config.d.ts +1 -0
- package/config.js +1 -0
- package/dist/esm/auto-imports.d.ts +1 -1
- package/dist/esm/auto-imports.js +1 -1
- package/dist/esm/auto-imports.js.map +1 -1
- package/dist/esm/config.d.ts +1 -2
- package/dist/esm/config.js +2 -871
- package/dist/esm/index.js +10 -10
- package/package.json +22 -7
- package/schema.d.ts +1 -0
- package/schema.js +1 -0
- package/dist/esm/config.js.map +0 -1
- package/dist/esm/resolve-B0J5V4xC.d.ts +0 -829
- package/dist/esm/resolve-B0J5V4xC.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -475,9 +475,24 @@ client.on(Events.HmrPieceReloaded, async (piece) => {
|
|
|
475
475
|
|
|
476
476
|
### Project configuration (`stars.config.*`)
|
|
477
477
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
478
|
+
The typed project configuration consumed by the [`stars` CLI](../cli) — the `defineConfig` helper and the config
|
|
479
|
+
loader — lives in [`@wolfstar/schema`](../schema), a small package shared by `@wolfstar/http-framework`
|
|
480
|
+
and `@wolfstar/cli` so neither depends on the other's runtime. `@wolfstar/http-framework` re-exports its public
|
|
481
|
+
surface unchanged as `@wolfstar/http-framework/config`, so any tool can resolve a project's configuration without
|
|
482
|
+
pulling in `@wolfstar/cli` — most projects should keep importing it from here rather than depending on
|
|
483
|
+
`@wolfstar/schema` directly.
|
|
484
|
+
|
|
485
|
+
The package also exposes `@wolfstar/http-framework/schema`, forwarding the shared schema's types and loader,
|
|
486
|
+
like Nuxt's `nuxt/schema`. Both facades preserve the same exports and function identities; existing `/config`
|
|
487
|
+
imports remain supported. Tooling can read the package metadata through `@wolfstar/http-framework/package.json`.
|
|
488
|
+
|
|
489
|
+
```typescript
|
|
490
|
+
import type { StarsConfig, ResolvedStarsConfig } from '@wolfstar/http-framework/schema';
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
Installing `@wolfstar/http-framework` also gives a project the `stars` binary (it depends on `@wolfstar/cli` and
|
|
494
|
+
exposes it as `stars`, the way `nuxt` exposes `nuxi`'s binary), so a project needs no separate `@wolfstar/cli`
|
|
495
|
+
install to run `stars dev`/`stars build`.
|
|
481
496
|
|
|
482
497
|
```typescript
|
|
483
498
|
// stars.config.ts
|
package/bin/stars.mjs
ADDED
package/config.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@wolfstar/schema';
|
package/config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@wolfstar/schema';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResolvedImportsConfig } from "@wolfstar/schema";
|
|
2
2
|
import unplugin from "unimport/unplugin";
|
|
3
3
|
//#region src/auto-imports.d.ts
|
|
4
4
|
export interface AutoImportsPluginOptions extends Pick<ResolvedImportsConfig, 'dirs' | 'presets' | 'exclude' | 'dts'> {
|
package/dist/esm/auto-imports.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { dirname } from "node:path";
|
|
2
|
-
import { mkdirSync } from "node:fs";
|
|
3
2
|
import { resolveModuleExportNames } from "mlly";
|
|
3
|
+
import { mkdirSync } from "node:fs";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
5
|
import { createUnimport } from "unimport";
|
|
6
6
|
import unplugin from "unimport/unplugin";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-imports.js","names":[],"sources":["../../src/auto-imports.ts"],"sourcesContent":["/**\n * Nuxt-style auto imports for `@wolfstar/http-framework` projects.\n *\n * Wires `unimport` into `tsdown`'s rolldown pipeline: the framework's (and any configured preset's) exports, plus\n * the project's own {@link AutoImportsPluginOptions.dirs}, become usable without an explicit `import` statement, the\n * same way Nuxt's own exports and its `composables`/`utils` directories do. Only usable with the `tsdown` build\n * tool — `tsc` and `none` have no transform step to hook the injection into.\n *\n * @module @wolfstar/http-framework/auto-imports\n */\nimport { resolveModuleExportNames } from 'mlly';\nimport { mkdirSync } from 'node:fs';\nimport { dirname } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { createUnimport, type Import } from 'unimport';\nimport unplugin from 'unimport/unplugin';\nimport type { ResolvedImportsConfig } from '
|
|
1
|
+
{"version":3,"file":"auto-imports.js","names":[],"sources":["../../src/auto-imports.ts"],"sourcesContent":["/**\n * Nuxt-style auto imports for `@wolfstar/http-framework` projects.\n *\n * Wires `unimport` into `tsdown`'s rolldown pipeline: the framework's (and any configured preset's) exports, plus\n * the project's own {@link AutoImportsPluginOptions.dirs}, become usable without an explicit `import` statement, the\n * same way Nuxt's own exports and its `composables`/`utils` directories do. Only usable with the `tsdown` build\n * tool — `tsc` and `none` have no transform step to hook the injection into.\n *\n * @module @wolfstar/http-framework/auto-imports\n */\nimport { resolveModuleExportNames } from 'mlly';\nimport { mkdirSync } from 'node:fs';\nimport { dirname } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { createUnimport, type Import } from 'unimport';\nimport unplugin from 'unimport/unplugin';\nimport type { ResolvedImportsConfig } from '@wolfstar/schema';\n\n/**\n * Export names never auto-imported, even when a preset re-exports them under that name: names generic enough that\n * project code is likely to declare or import its own value with the same identifier.\n */\nconst BLOCKED_EXPORTS: ReadonlySet<string> = new Set(['Client', 'Message', 'Plugin', 'Store']);\n\n/**\n * Nuxt matches its own auto-import transform against every JS/TS file variant (`.js .mjs .cjs .ts .mts .cts .jsx\n * .tsx`, see `isJS` in `@nuxt/kit`), not `unimport`'s narrower unplugin default (`/\\.[jt]sx?$/`, which misses\n * `.mjs`/`.cjs`/`.mts`/`.cts`): whether a file gets auto imports must not depend on whether the project happens to\n * use TypeScript.\n */\nconst TRANSFORM_INCLUDE = [/\\.(?:[cm]?[jt]s|[jt]sx)$/];\n\nexport interface AutoImportsPluginOptions extends Pick<ResolvedImportsConfig, 'dirs' | 'presets' | 'exclude' | 'dts'> {\n\t/** Absolute project root, used to resolve `presets` against the project's own `node_modules`. */\n\troot: string;\n}\n\n/**\n * Scans every configured preset package for its export names, from the project's own `node_modules` so the result\n * matches what the project actually has installed. Packages that fail to resolve (not installed, or a preset the\n * user configured for a plugin they do not use) are skipped rather than failing the build.\n */\nasync function scanPresetImports(root: string, presets: readonly string[], excluded: ReadonlySet<string>): Promise<Import[]> {\n\tconst url = pathToFileURL(`${root}/package.json`).href;\n\tconst imports: Import[] = [];\n\n\tawait Promise.all(\n\t\tpresets.map(async (from) => {\n\t\t\tlet names: string[];\n\t\t\ttry {\n\t\t\t\tnames = await resolveModuleExportNames(from, { url });\n\t\t\t} catch {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfor (const name of names) {\n\t\t\t\tif (excluded.has(name)) continue;\n\t\t\t\timports.push({ name, from });\n\t\t\t}\n\t\t})\n\t);\n\n\treturn imports;\n}\n\n/**\n * Builds the rolldown plugin `tsdown.config.ts` adds to `plugins` to enable auto imports, as resolved from\n * {@link StarsImportsConfig} (see `@wolfstar/http-framework/config`).\n */\nexport async function autoImports(options: AutoImportsPluginOptions): Promise<ReturnType<typeof unplugin.rolldown>> {\n\tconst excluded = new Set([...BLOCKED_EXPORTS, ...options.exclude]);\n\tconst imports = await scanPresetImports(options.root, options.presets, excluded);\n\n\t// `unimport`'s unplugin writes `dts` on `buildStart` but does not create its parent directory.\n\tmkdirSync(dirname(options.dts), { recursive: true });\n\n\treturn unplugin.rolldown({\n\t\timports,\n\t\tdirs: [...options.dirs],\n\t\tinclude: TRANSFORM_INCLUDE,\n\t\tdts: options.dts\n\t});\n}\n\n/**\n * Generates the auto imports declaration file's contents without writing it, so `stars prepare --check` can diff it\n * against what is on disk the same way `stars codegen --check` does for i18next types.\n */\nexport async function generateAutoImportsDts(options: Pick<AutoImportsPluginOptions, 'root' | 'dirs' | 'presets' | 'exclude'>): Promise<string> {\n\tconst excluded = new Set([...BLOCKED_EXPORTS, ...options.exclude]);\n\tconst imports = await scanPresetImports(options.root, options.presets, excluded);\n\tconst ctx = createUnimport({ imports, dirs: [...options.dirs] });\n\tawait ctx.init();\n\treturn ctx.generateTypeDeclarations();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,kCAAuC,IAAI,IAAI;CAAC;CAAU;CAAW;CAAU;AAAO,CAAC;;;;;;;AAQ7F,MAAM,oBAAoB,CAAC,0BAA0B;;;;;;AAYrD,eAAe,kBAAkB,MAAc,SAA4B,UAAkD;CAC5H,MAAM,MAAM,cAAc,GAAG,KAAK,cAAc,CAAC,CAAC;CAClD,MAAM,UAAoB,CAAC;CAE3B,MAAM,QAAQ,IACb,QAAQ,IAAI,OAAO,SAAS;EAC3B,IAAI;EACJ,IAAI;GACH,QAAQ,MAAM,yBAAyB,MAAM,EAAE,IAAI,CAAC;EACrD,QAAQ;GACP;EACD;EAEA,KAAK,MAAM,QAAQ,OAAO;GACzB,IAAI,SAAS,IAAI,IAAI,GAAG;GACxB,QAAQ,KAAK;IAAE;IAAM;GAAK,CAAC;EAC5B;CACD,CAAC,CACF;CAEA,OAAO;AACR;;;;;AAMA,eAAsB,YAAY,SAAkF;CACnH,MAAM,2BAAW,IAAI,IAAI,CAAC,GAAG,iBAAiB,GAAG,QAAQ,OAAO,CAAC;CACjE,MAAM,UAAU,MAAM,kBAAkB,QAAQ,MAAM,QAAQ,SAAS,QAAQ;CAG/E,UAAU,QAAQ,QAAQ,GAAG,GAAG,EAAE,WAAW,KAAK,CAAC;CAEnD,OAAO,SAAS,SAAS;EACxB;EACA,MAAM,CAAC,GAAG,QAAQ,IAAI;EACtB,SAAS;EACT,KAAK,QAAQ;CACd,CAAC;AACF;;;;;AAMA,eAAsB,uBAAuB,SAAmG;CAC/I,MAAM,2BAAW,IAAI,IAAI,CAAC,GAAG,iBAAiB,GAAG,QAAQ,OAAO,CAAC;CACjE,MAAM,UAAU,MAAM,kBAAkB,QAAQ,MAAM,QAAQ,SAAS,QAAQ;CAC/E,MAAM,MAAM,eAAe;EAAE;EAAS,MAAM,CAAC,GAAG,QAAQ,IAAI;CAAE,CAAC;CAC/D,MAAM,IAAI,KAAK;CACf,OAAO,IAAI,yBAAyB;AACrC"}
|
package/dist/esm/config.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { CONFIG_EXTENSIONS, CONFIG_FILE_NAMES, type ConfigDiagnosticCode, type LoadConfigFileOptions, LoadStarsConfigOptions, type LoadedConfigFile, type PackageJsonLike, type ResolveConfigOptions, type ResolvedBuildConfig, type ResolvedCodegenConfig, type ResolvedDevConfig, type ResolvedExperimentalConfig, type ResolvedFutureConfig, type ResolvedI18nCodegenConfig, type ResolvedImportsConfig, type ResolvedNitroConfig, type ResolvedStarsConfig, type ResolvedTunnelConfig, type ResolvedTypecheckConfig, StarsBuildConfig, StarsBuildTool, StarsCodegenConfig, StarsCompatibilityVersion, StarsConfig, StarsDevConfig, StarsExperimentalConfig, StarsFutureConfig, StarsI18nCodegenConfig, StarsImportsConfig, StarsNitroConfig, StarsTsdownConfig, StarsTunnelConfig, StarsTypecheckConfig, StarsTypechecker, StarsViteConfig, configDiagnostics, defineConfig, discoverConfigFile, displayPath, loadConfigFile, loadStarsConfig, readProjectEnvFiles, resolveStarsConfig };
|
|
1
|
+
export * from "@wolfstar/schema";
|