skinsuite 0.2.0 → 0.2.1

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
@@ -288,6 +288,22 @@ npm test # 先构建,再用 node:test 跑 dist 产物
288
288
 
289
289
  ⚠️ `src/` 里的相对 import **必须带 `.js` 后缀**:包以 `moduleResolution: NodeNext` 编译,TS 会把 `.js` 映射回 `.ts` 源码,而产物里的相对说明符是原样保留的 —— 不带后缀浏览器与 Node 的原生 ESM 都解析不到。
290
290
 
291
+ ### 关于 exports:类型统一指向 `src/`,运行时才分 `dist/`
292
+
293
+ ```jsonc
294
+ ".": { "types": "./src/index.ts", "import": "./dist/index.js" },
295
+ "./vue": { "types": "./src/vue/index.ts", "import": "./src/vue/index.ts" },
296
+ "./vite": { "types": "./src/vite/index.ts", "import": "./src/vite/index.ts" }
297
+ ```
298
+
299
+ `./vue` / `./vite` 含 `.vue` 与构建期代码,**只能以源码形态发布**(`tsc` 编不出 SFC)。
300
+ 于是根入口的类型也必须指向 `src/index.ts`:若它指向 `dist/index.d.ts`,同一个类型在
301
+ 一个程序里会有**两个身份**(dist 的 d.ts 与 vue 层引用的 src),composite 项目做声明
302
+ 产出时直接红 —— `TS2883: The inferred type of 'X' cannot be named without a reference
303
+ to '...' from '../../node_modules/skinsuite/src/types'`。
304
+
305
+ `dist/` 仍然保留(`.js` + `.d.ts` + sourcemap),运行时走它,纯 JS 消费者不受影响。
306
+
291
307
  ---
292
308
 
293
309
  ## License
@@ -235,16 +235,23 @@ VITE_THEME_DIR=src/theme
235
235
 
236
236
  缺省就是 `src/theme`,可不写。**换目录只改这一个变量,不动代码。**
237
237
 
238
- ### 5.2 tsconfig / env 类型(可选)
238
+ ### 5.2 tsconfig / env 类型(必做一行)
239
239
 
240
- `skinsuite/vite` 自带 `virtual:theme` 的类型声明,宿主通过引入 `skinsuite/vite` 即可获得,
241
- 一般无需自写。若你的 `vue-tsc` 报找不到 `virtual:theme`,确认 `vite.config.ts` 已被 tsconfig
242
- 纳入检查范围,或补一句:
240
+ `skinsuite/vite` 自带 `virtual:theme` 的类型声明(`src/vite/theme.d.ts`),但**类型声明只有在
241
+ 被纳入 TS 程序时才有意义**。在你项目的 `src/vite-env.d.ts` 里加一行:
243
242
 
244
243
  ```ts
245
- /// <reference types="skinsuite/vite" />
244
+ /// <reference types="vite/client" />
245
+ import "skinsuite/vite"; // 让 theme.d.ts 的 declare module 'virtual:theme' 进程序
246
246
  ```
247
247
 
248
+ 🔴 **不要写 `/// <reference types="skinsuite/vite" />`**——`reference types` 解析不到包的
249
+ **子路径**入口,症状是 `vue-tsc -b` 报 `Cannot find module or type declarations for side-effect
250
+ import of 'virtual:theme'`(TS2882),而 `vite build` / 浏览器全正常,很容易误判成「只是编辑器问题」。
251
+
252
+ `import` 写在 `.d.ts` 里是**纯类型侧**的:不产生任何运行时代码,也不会把插件打进产物,只是
253
+ 把 `src/vite/index.ts` 上的 `/// <reference path="./theme.d.ts" />` 带进程序。
254
+
248
255
  ---
249
256
 
250
257
  ## 六、bootstrap.ts(启动编排,从这开始写)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skinsuite",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "多主题 / 多版式机制的纯内核(零运行时依赖):目录名与默认值的白名单常量、主题包契约类型、明暗 mode 与色系 tone、CSS 变量 token 的安全校验、设备维度 URL 参数读取。不碰 DOM / 构建器 / 路由,可在任意前端(Vue / React / Node / SSR)复用。",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -8,7 +8,7 @@
8
8
  "types": "./dist/index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
- "types": "./dist/index.d.ts",
11
+ "types": "./src/index.ts",
12
12
  "import": "./dist/index.js"
13
13
  },
14
14
  "./vue": {