Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/smooth-areas-pick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@inkcre/ui-web": patch
---

统一生成 Web UI 的公开类型声明,保留 Vue 组件、工具、语言包和 UnoCSS 的类型入口。
1 change: 0 additions & 1 deletion packages/web/histoire.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { HstVue } from "@histoire/plugin-vue";
import { resolve } from "path";
export default defineConfig({
plugins: [HstVue()],
viteIgnorePlugins: ["vite:dts"],
setupFile: "./stories/histoire.setup.ts",
storyMatch: ["stories/**/*.story.vue"],
storyIgnored: ["**/node_modules/**", "**/dist/**", "**/.histoire/**"],
Expand Down
9 changes: 4 additions & 5 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@
},
"scripts": {
"dev": "vite",
"build": "pnpm run clean && pnpm run type-check && pnpm run build:js && pnpm run build:subpaths && pnpm run build:subpath-types && pnpm run build:finalize && pnpm run build:skills",
"build": "pnpm run clean && pnpm run type-check && pnpm run build:js && pnpm run build:subpaths && pnpm run build:types && pnpm run build:finalize && pnpm run build:skills",
"build:js": "vite build",
"build:subpaths": "vite build --config vite.subpaths.config.js",
"build:subpath-types": "vue-tsc --declaration --emitDeclarationOnly --noEmit false --declarationMap false --composite false -p tsconfig.exports.json && vue-tsc --declaration --emitDeclarationOnly -p tsconfig.uno.json",
"build:types": "vue-tsc -p tsconfig.build.json && vue-tsc -p tsconfig.uno.json",
"build:finalize": "tsx ../../scripts/finalize-package.ts",
"build:tokens": "tsx ../../scripts/build-tokens.ts",
"build:skills": "pnpm run skill:generate:check",
"clean": "rimraf dist",
"preview": "vite preview",
"format": "oxfmt --config .oxfmtrc.json src stories styles .oxfmtrc.json .oxlintrc.json package.json DESIGN.md docs/design skill.seed.json component-manifest.json component-manifest.schema.json tsconfig.json tsconfig.build.json tsconfig.check.json tsconfig.exports.json tsconfig.uno.json env.d.ts histoire.config.ts uno.config.ts vite.config.js vite.subpaths.config.js",
"format:check": "oxfmt --check --config .oxfmtrc.json src stories styles .oxfmtrc.json .oxlintrc.json package.json DESIGN.md docs/design skill.seed.json component-manifest.json component-manifest.schema.json tsconfig.json tsconfig.build.json tsconfig.check.json tsconfig.exports.json tsconfig.uno.json env.d.ts histoire.config.ts uno.config.ts vite.config.js vite.subpaths.config.js",
"format": "oxfmt --config .oxfmtrc.json src stories styles .oxfmtrc.json .oxlintrc.json package.json DESIGN.md docs/design skill.seed.json component-manifest.json component-manifest.schema.json tsconfig.json tsconfig.build.json tsconfig.check.json tsconfig.uno.json env.d.ts histoire.config.ts uno.config.ts vite.config.js vite.subpaths.config.js",
"format:check": "oxfmt --check --config .oxfmtrc.json src stories styles .oxfmtrc.json .oxlintrc.json package.json DESIGN.md docs/design skill.seed.json component-manifest.json component-manifest.schema.json tsconfig.json tsconfig.build.json tsconfig.check.json tsconfig.uno.json env.d.ts histoire.config.ts uno.config.ts vite.config.js vite.subpaths.config.js",
"lint": "oxlint --config .oxlintrc.json src stories histoire.config.ts uno.config.ts vite.config.js vite.subpaths.config.js",
"lint:fix": "pnpm run lint --fix",
"skill:generate": "tsx ../../scripts/build-agent-skills.ts",
Expand Down Expand Up @@ -129,7 +129,6 @@
"sass": "^1.94.2",
"unocss": "^66.5.10",
"vite": "^7.2.7",
"vite-plugin-dts": "^4.5.4",
"vue": "3.5.25",
"vue-i18n": "^11.2.7",
"vue-router": "^4.0.0",
Expand Down
5 changes: 2 additions & 3 deletions packages/web/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"composite": false,
"declarationDir": "dist",
"declarationMap": false,
"noEmit": false,
"outDir": "dist",
"rootDir": "src"
},
"include": ["env.d.ts", "src/**/*"],
"exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"]
"files": ["env.d.ts", "src/index.ts", "src/locales/index.ts", "src/utils/index.ts"],
"include": []
}
11 changes: 0 additions & 11 deletions packages/web/tsconfig.exports.json

This file was deleted.

42 changes: 2 additions & 40 deletions packages/web/vite.config.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,18 @@
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import dts from "vite-plugin-dts";
import UnoCSS from "unocss/vite";
import { isAbsolute, relative, resolve, sep } from "path";
import { resolve } from "path";
import packageJson from "./package.json" with { type: "json" };

const externalDependencies = Object.keys({
...packageJson.dependencies,
...packageJson.peerDependencies,
});
const declarationRoot = resolve(__dirname, "dist");
const isExternalDependency = (id) =>
externalDependencies.some((dependency) => id === dependency || id.startsWith(`${dependency}/`));

const normalizeDeclarationOutput = (filePath, content) => {
const isInsideDist = filePath.startsWith(`${declarationRoot}${sep}`);
const outputPath = isInsideDist
? relative(declarationRoot, filePath)
: relative(__dirname, filePath);
if (outputPath.startsWith("..") || isAbsolute(outputPath)) {
throw new Error(`Declaration output escaped the web package: ${filePath}`);
}

const normalizedPath = outputPath.replace(/\.d\.vue\.ts$/, ".d.ts");
if (isInsideDist && normalizedPath === outputPath) return;

return {
filePath: resolve(declarationRoot, normalizedPath),
content,
};
};

const failOnDiagnostics = (diagnostics) => {
if (diagnostics.length > 0) {
throw new Error(`Declaration generation failed with ${diagnostics.length} diagnostic(s).`);
}
};

export default defineConfig({
plugins: [
vue(),
UnoCSS(),
dts({
tsconfigPath: resolve(__dirname, "tsconfig.build.json"),
rollupTypes: false,
pathsToAliases: false,
skipDiagnostics: false,
logDiagnostics: true,
afterDiagnostic: failOnDiagnostics,
beforeWriteFile: normalizeDeclarationOutput,
}),
],
plugins: [vue(), UnoCSS()],

build: {
lib: {
Expand Down
Loading