mini-three-adapter 0.1.1 → 0.1.3

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.
Files changed (51) hide show
  1. package/AGENTS.md +85 -85
  2. package/README.md +159 -159
  3. package/dist/build/rollup.js +60 -9
  4. package/dist/build/rollup.js.map +1 -1
  5. package/dist/build/vite.js +60 -9
  6. package/dist/build/vite.js.map +1 -1
  7. package/dist/{chunk-Z7AMDRN3.js → chunk-3QUEDYTT.js} +12 -5
  8. package/dist/chunk-3QUEDYTT.js.map +1 -0
  9. package/dist/{chunk-WLRQDTSZ.js → chunk-52IMRKOX.js} +3 -3
  10. package/dist/{chunk-WLRQDTSZ.js.map → chunk-52IMRKOX.js.map} +1 -1
  11. package/dist/{chunk-3UGQWFH3.js → chunk-J7VBWZRR.js} +87 -27
  12. package/dist/chunk-J7VBWZRR.js.map +1 -0
  13. package/dist/{chunk-4UEBRAK6.js → chunk-LCJNTN6F.js} +19 -9
  14. package/dist/chunk-LCJNTN6F.js.map +1 -0
  15. package/dist/{chunk-MTBMOFAL.js → chunk-OL7NVZZJ.js} +29 -14
  16. package/dist/chunk-OL7NVZZJ.js.map +1 -0
  17. package/dist/{chunk-LB3WL24R.js → chunk-WZ2HKYC5.js} +8 -4
  18. package/dist/chunk-WZ2HKYC5.js.map +1 -0
  19. package/dist/core/index.d.ts +15 -5
  20. package/dist/core/index.js +2 -2
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +6 -6
  23. package/dist/platforms/browser.d.ts +2 -2
  24. package/dist/platforms/browser.js +3 -3
  25. package/dist/platforms/wechat-game.d.ts +2 -2
  26. package/dist/platforms/wechat-game.js +4 -4
  27. package/dist/platforms/wechat-miniprogram.d.ts +2 -2
  28. package/dist/platforms/wechat-miniprogram.js +4 -4
  29. package/dist/polyfills/index.d.ts +8 -1
  30. package/dist/polyfills/index.js +1 -1
  31. package/dist/{runtime-7uUOoFhC.d.ts → runtime-DnEkKZjo.d.ts} +1 -1
  32. package/dist/scope.d.ts +1 -1
  33. package/dist/{types-BzK0LQMa.d.ts → types-X_5SJh4y.d.ts} +7 -0
  34. package/docs/02-architecture.md +126 -126
  35. package/docs/03-module-map.md +99 -99
  36. package/docs/04-api-reference.md +294 -291
  37. package/docs/05-build-plugin.md +33 -5
  38. package/docs/06-platform-notes.md +116 -108
  39. package/docs/07-integration-guide.md +14 -0
  40. package/docs/09-testing-and-release.md +209 -206
  41. package/docs/10-ai-playbook.md +141 -140
  42. package/docs/11-compat-matrix.md +96 -94
  43. package/docs/adr/0007-capability-probe-fallback.md +57 -0
  44. package/docs/adr/README.md +1 -0
  45. package/llms.txt +69 -65
  46. package/package.json +1 -1
  47. package/dist/chunk-3UGQWFH3.js.map +0 -1
  48. package/dist/chunk-4UEBRAK6.js.map +0 -1
  49. package/dist/chunk-LB3WL24R.js.map +0 -1
  50. package/dist/chunk-MTBMOFAL.js.map +0 -1
  51. package/dist/chunk-Z7AMDRN3.js.map +0 -1
@@ -1,206 +1,209 @@
1
- # 09 · 测试、构建与发布
2
-
3
- ## 9.1 常用命令
4
-
5
- ```bash
6
- npm install # 安装依赖
7
- npm run typecheck # tsc --noEmit(strict)
8
- npm test # vitest run(32 例)
9
- npm test -- --watch # 观察模式
10
- npm run build # tsup:dist/*.js + *.d.ts + sourcemap
11
- npm run check # typecheck + test + build
12
- ```
13
-
14
- Windows 说明:`vitest.config.ts` 使用**单 fork**(`pool: 'forks'`, `singleFork: true`, `fileParallelism: false`, `cache: false`),避免并行 worker 写入系统临时目录时的 `EPERM`。若仍遇到临时目录权限问题:
15
-
16
- ```bash
17
- TMP="$PWD/.tmp/vitest" TEMP="$PWD/.tmp/vitest" npm test
18
- ```
19
-
20
- ## 9.2 测试结构
21
-
22
- | 文件 | 覆盖 |
23
- | --- | --- |
24
- | `tests/scope-rewrite.test.ts` | AST 重写:自由变量、局部遮蔽、对象键、成员属性、`typeof`、import/export、自定义访问器 |
25
- | `tests/polyfills.test.ts` | EventTarget/once/remove、PointerEvent、Blob/URL/base64、URL 解析、TextEncoder、fetch、AbortController |
26
- | `tests/runtime.test.ts` | 画布补丁、scope 隔离、上下文缓存、触摸桥、多指、installGlobals 可逆、resize/dispose、能力报告 |
27
- | `tests/plugin.test.ts` | 资产扫描、未解析资源、模块过滤、WebGPU 告警、manifest 输出 |
28
- | `tests/helpers/mock-wx.ts` | 可注入的 `wx` 模拟器(`__setSize`、`__touch`、`__canvases`、`__images`) |
29
-
30
- **新功能必须带测试**。写测试时优先用 `createMockWx()` 注入,不要在测试里依赖真实 `wx` 或浏览器 DOM。
31
-
32
- ## 9.3 构建产物
33
-
34
- `tsup.config.ts` 有两套配置:
35
-
36
- | 配置 | 目标 | 输出 |
37
- | --- | --- | --- |
38
- | runtime | `es2019` / `platform: 'neutral'` / splitting / dts | `dist/index.js`、`dist/core/index.js`、`dist/scope.js`、`dist/polyfills/index.js`、`dist/platforms/*.js` + 共享 chunk |
39
- | build tooling | `node18` / `platform: 'node'` / 不 splitting / dts | `dist/build/vite.js`、`dist/build/rollup.js` |
40
-
41
- 要点:
42
-
43
- - `es2019` 让 esbuild 降级可选链与空值合并,减少开发者工具的语法报错。
44
- - `three` 被标记为 `external`,永远不会进适配层产物。
45
- - `sideEffects` 只声明平台入口文件,保证 tree-shaking 不误删必要的初始化。
46
- - `.d.ts` 由 tsup/dts 生成,`package.json` 的 `exports` 逐个子路径指向它们。
47
-
48
- 构建后冒烟:
49
-
50
- ```bash
51
- node --input-type=module -e "
52
- import { rewriteGlobals } from './dist/build/rollup.js';
53
- import { miniThree } from './dist/build/vite.js';
54
- import { createWeChatGameRuntime } from './dist/index.js';
55
- console.log(typeof rewriteGlobals, typeof miniThree, typeof createWeChatGameRuntime);
56
- "
57
- ```
58
-
59
- ## 9.4 建议的 CI 流程
60
-
61
- ```yaml
62
- # .github/workflows/ci.yml(示意)
63
- name: ci
64
- on: [push, pull_request]
65
- jobs:
66
- check:
67
- runs-on: ubuntu-latest
68
- steps:
69
- - uses: actions/checkout@v4
70
- - uses: actions/setup-node@v4
71
- with: { node-version: 20 }
72
- - run: npm ci
73
- - run: npm run check
74
- - name: Verify examples typecheck
75
- run: |
76
- cd examples/wechat-minigame && npm ci && npx tsc --noEmit -p tsconfig.json
77
- ```
78
-
79
- 额外建议:
80
-
81
- - 在 CI 中打印 `plugin.api.report()`,把 `parseFailures` / `missingAssets` 作为质量门禁(允许白名单)。
82
- - 建立回归用例集:按 controls / loaders / postprocessing / 动画 / 物理分类,每个类别挑选若干 three 官方示例场景,用 `examples/` 的三种平台工程跑通,结果写进 `docs/11-compat-matrix.md`。
83
-
84
- ## 9.5 发布到 npm
85
-
86
- ### 9.5.1 发布前检查
87
-
88
- ```bash
89
- npm run check # typecheck + 32 例测试 + tsup 构建
90
- npm run release:check # npm pack --dry-run --json,看将要发布的文件清单
91
- ```
92
-
93
- `package.json` 已配置 `prepublishOnly: "npm run clean && npm run check"`,`npm publish` 会自动清空 `dist/` 并跑一次完整构建与测试,既不会把未构建的产物发出去,也不会带入历史 hash chunk。发布前确认:
94
-
95
- - `files` 白名单只包含 `dist/`、`README.md`、`AGENTS.md`、`llms.txt`、`docs/`(当前约 73 个文件、156 KB)。
96
- - `exports` 里每个子路径的 `.js` 与 `.d.ts` 都存在。
97
- - `CHANGELOG.md` 已补上本次版本条目。
98
- - `docs/04-api-reference.md` 与 `package.json exports` 一致;`docs/03-module-map.md` 与文件树一致。
99
- - `docs/11-compat-matrix.md` 已登记验证过的 three / 基础库版本。
100
-
101
- `package.json` 已配置 `repository` / `homepage` / `bugs`,npm 包页面会展示源码入口与 issue 链接。若仓库迁移,同步修改这三个字段后再发布。
102
-
103
- ### 9.5.2 准备 npm 账号
104
-
105
- 1. 在 [npmjs.com](https://www.npmjs.com/signup) 注册账号,并在 **Account → 2FA** 开启双因素认证。
106
- 2. 检查包名是否可用(发布前再查一次,避免被占用):
107
-
108
- ```bash
109
- npm view mini-three-adapter version
110
- # 404 Not Found = 可用
111
- ```
112
-
113
- 3. 登录:
114
-
115
- ```bash
116
- npm login # 浏览器授权,最简单
117
- npm whoami # 确认已登录
118
- ```
119
-
120
- CI 或非交互环境用 granular access token(权限选 `Read and write`,并限定到该包):
121
-
122
- ```bash
123
- # 不要把这个文件提交到仓库
124
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
125
- ```
126
-
127
- ### 9.5.3 本地演练(推荐先做)
128
-
129
- 生成一个真实 tarball,在干净目录里装一次,确认子路径导入都能解析:
130
-
131
- ```bash
132
- npm pack # 得到 mini-three-adapter-0.1.0.tgz
133
- mkdir -p /tmp/m3-smoke && cd /tmp/m3-smoke
134
- npm init -y && npm pkg set type=module
135
- npm i /path/to/mini-three-adapter-0.1.0.tgz three
136
- node --input-type=module -e "
137
- import { createWeChatGameRuntime } from 'mini-three-adapter/wechat-game';
138
- import { createWeChatMiniProgramRuntime } from 'mini-three-adapter/wechat-miniprogram';
139
- import miniThree from 'mini-three-adapter/vite';
140
- import { getActiveScope } from 'mini-three-adapter/scope';
141
- console.log(typeof createWeChatGameRuntime, typeof createWeChatMiniProgramRuntime, typeof miniThree, typeof getActiveScope);
142
- "
143
- ```
144
-
145
- > 未登录也能执行这一步。`npm pack` 生成的文件记得从仓库目录删掉,或把它加进 `.gitignore`。
146
-
147
- ### 9.5.4 正式发布
148
-
149
- ```bash
150
- npm publish --access public
151
- ```
152
-
153
- `publishConfig.access` 已设为 `public`,`--access public` 可省略。执行后 `prepublishOnly` 会自动清空 `dist/` 并跑 `npm run check`。
154
-
155
- **npm 的版本号不可覆盖**:同一个 `0.1.0` 只能发一次,之后每次改动都要先升版本再发。24 小时内可以 `npm unpublish <pkg>@<version>` 撤回,超过时间就不能删了;公开包一旦被他人依赖,撤回会影响别人,尽量不要依赖这个能力。
156
-
157
- ### 9.5.5 发布后验证
158
-
159
- ```bash
160
- npm view mini-three-adapter version
161
- npm view mini-three-adapter exports --json
162
- ```
163
-
164
- 在任意新项目里执行 `npm i mini-three-adapter three`,再跑一遍 9.5.3 的 import 冒烟。CDN 会在发布后自动可用(如 `https://unpkg.com/mini-three-adapter/`),但小游戏构建走本地 node_modules,不依赖 CDN。
165
-
166
- ### 9.5.6 后续版本
167
-
168
- ```bash
169
- # 修 bug
170
- npm version patch && npm publish
171
- # 新增向后兼容能力
172
- npm version minor && npm publish
173
- # 破坏性变更(0.x 阶段也用 minor 时要写进 CHANGELOG)
174
- npm version major && npm publish
175
- ```
176
-
177
- `npm version` 会自动改 `package.json`、生成 git tag(若已 `git init`)。每次发布重复 9.5.1 的检查。
178
-
179
- CI 自动发布(`.github/workflows/publish.yml`)要点:用 `actions/setup-node` 配置 `registry-url`,把 `NPM_TOKEN` 放在仓库 Secrets 里,在 `npm ci && npm run check` 之后执行 `npm publish --provenance --access public`。`--provenance` 会在 npm 页面生成来源证明,需要仓库为 public 且 workflow 具备 `id-token: write` 权限。
180
-
181
- ### 9.5.7 其他分发方式
182
-
183
- | 方式 | 适用场景 |
184
- | --- | --- |
185
- | `npm pack` 把 `.tgz` 直接发给同事 | 还没决定公开,或需要在隔离环境试用;对方 `npm i ./xxx.tgz` |
186
- | `"mini-three-adapter": "file:../.."` | 本机多个项目复用同一份源码 |
187
- | 私有 registry(Verdaccio / GitHub Packages) | 只给团队内部使用,不想发到公共 npm |
188
- | `npm link` | 开发期实时联调,改源码立刻生效 |
189
-
190
- 发布到公共 npm 之后,业务项目只需 `npm i mini-three-adapter three`,`examples/*/package.json` 里的 `workspace:*` 改成 `"^0.1.0"` 即可。
191
-
192
- ## 9.6 版本策略
193
-
194
- - 遵循语义化版本;`0.x` 阶段 minor 可含破坏性变更,但必须在 CHANGELOG 与接入文档里写明。
195
- - `three` 是 optional peer,`>=0.163.0`(WebGL2 门槛)。three 大版本升级时,重点回归 `DEFAULT_GLOBAL_NAMES` 与 `patchElement` 的属性集合。
196
- - 微信基础库能力变化只影响 `capabilities.ts` / `wechat-common.ts` / `assets.ts`,不应扩散到 `core/`。
197
-
198
- ## 9.7 真机验收清单(发布前)
199
-
200
- - [ ] iOS / Android 各一台,WebGL2 正常出图
201
- - [ ] 多指缩放/旋转(OrbitControls)不卡死,`touchcancel` 后指针计数归零
202
- - [ ] 横竖屏切换后 `resize` 生效,画面不变形
203
- - [ ] 前后台切换后帧循环恢复
204
- - [ ] DRACO / KTX2 资源加载(含分包预下载 Worker)
205
- - [ ] `runtime.dispose()` 后无残留监听、无内存持续增长
206
- - [ ] `runtime.report()` 无 WebGL2 告警
1
+ # 09 · 测试、构建与发布
2
+
3
+ ## 9.1 常用命令
4
+
5
+ ```bash
6
+ npm install # 安装依赖
7
+ npm run typecheck # tsc --noEmit(strict)
8
+ npm test # vitest run(63 例)
9
+ npm test -- --watch # 观察模式
10
+ npm run build # tsup:dist/*.js + *.d.ts + sourcemap
11
+ npm run check # typecheck + test + build
12
+ ```
13
+
14
+ Windows 说明:`vitest.config.ts` 使用**单 fork**(`pool: 'forks'`, `singleFork: true`, `fileParallelism: false`, `cache: false`),避免并行 worker 写入系统临时目录时的 `EPERM`。若仍遇到临时目录权限问题:
15
+
16
+ ```bash
17
+ TMP="$PWD/.tmp/vitest" TEMP="$PWD/.tmp/vitest" npm test
18
+ ```
19
+
20
+ ## 9.2 测试结构
21
+
22
+ | 文件 | 覆盖 |
23
+ | --- | --- |
24
+ | `tests/scope-rewrite.test.ts` | AST 重写:自由变量、局部遮蔽、对象键、成员属性、`typeof`、import/export、自定义访问器 |
25
+ | `tests/polyfills.test.ts` | EventTarget/once/remove、PointerEvent、Blob/URL/base64、URL 解析、TextEncoder、fetch、AbortController |
26
+ | `tests/runtime.test.ts` | 画布补丁、scope 隔离、上下文缓存、触摸桥、多指、installGlobals 可逆、resize/dispose、能力报告 |
27
+ | `tests/plugin.test.ts` | 资产扫描、未解析资源、模块过滤、WebGPU 告警、manifest 输出 |
28
+ | `tests/image-events.test.ts` | 图片原生 `onload`/`onerror` → 合成事件桥接、`decode()` settle、宿主不可拦截时的 `warnOnce` 去重 |
29
+ | `tests/event-dispatch.test.ts` | 监听器 `this`、`event.target` / `currentTarget` 指向宿主元素(含 three `ImageLoader` 取图场景)、`event.target` 不暴露内部监听表 |
30
+ | `tests/capabilities.test.ts` | 离屏优先 / 主画布回退 / 无法探测返回 `undefined`、`webgl2Source` 三态、回退拿到上屏画布时按身份放弃 |
31
+ | `tests/helpers/mock-wx.ts` | 可注入的 `wx` 模拟器(`__setSize`、`__touch`、`__canvases`、`__images`) |
32
+
33
+ **新功能必须带测试**。写测试时优先用 `createMockWx()` 注入,不要在测试里依赖真实 `wx` 或浏览器 DOM。
34
+
35
+ ## 9.3 构建产物
36
+
37
+ `tsup.config.ts` 有两套配置:
38
+
39
+ | 配置 | 目标 | 输出 |
40
+ | --- | --- | --- |
41
+ | runtime | `es2019` / `platform: 'neutral'` / splitting / dts | `dist/index.js`、`dist/core/index.js`、`dist/scope.js`、`dist/polyfills/index.js`、`dist/platforms/*.js` + 共享 chunk |
42
+ | build tooling | `node18` / `platform: 'node'` / 不 splitting / dts | `dist/build/vite.js`、`dist/build/rollup.js` |
43
+
44
+ 要点:
45
+
46
+ - `es2019` 让 esbuild 降级可选链与空值合并,减少开发者工具的语法报错。
47
+ - `three` 被标记为 `external`,永远不会进适配层产物。
48
+ - `sideEffects` 只声明平台入口文件,保证 tree-shaking 不误删必要的初始化。
49
+ - `.d.ts` 由 tsup/dts 生成,`package.json` 的 `exports` 逐个子路径指向它们。
50
+
51
+ 构建后冒烟:
52
+
53
+ ```bash
54
+ node --input-type=module -e "
55
+ import { rewriteGlobals } from './dist/build/rollup.js';
56
+ import { miniThree } from './dist/build/vite.js';
57
+ import { createWeChatGameRuntime } from './dist/index.js';
58
+ console.log(typeof rewriteGlobals, typeof miniThree, typeof createWeChatGameRuntime);
59
+ "
60
+ ```
61
+
62
+ ## 9.4 建议的 CI 流程
63
+
64
+ ```yaml
65
+ # .github/workflows/ci.yml(示意)
66
+ name: ci
67
+ on: [push, pull_request]
68
+ jobs:
69
+ check:
70
+ runs-on: ubuntu-latest
71
+ steps:
72
+ - uses: actions/checkout@v4
73
+ - uses: actions/setup-node@v4
74
+ with: { node-version: 20 }
75
+ - run: npm ci
76
+ - run: npm run check
77
+ - name: Verify examples typecheck
78
+ run: |
79
+ cd examples/wechat-minigame && npm ci && npx tsc --noEmit -p tsconfig.json
80
+ ```
81
+
82
+ 额外建议:
83
+
84
+ - 在 CI 中打印 `plugin.api.report()`,把 `parseFailures` / `missingAssets` 作为质量门禁(允许白名单)。
85
+ - 建立回归用例集:按 controls / loaders / postprocessing / 动画 / 物理分类,每个类别挑选若干 three 官方示例场景,用 `examples/` 的三种平台工程跑通,结果写进 `docs/11-compat-matrix.md`。
86
+
87
+ ## 9.5 发布到 npm
88
+
89
+ ### 9.5.1 发布前检查
90
+
91
+ ```bash
92
+ npm run check # typecheck + 63 例测试 + tsup 构建
93
+ npm run release:check # npm pack --dry-run --json,看将要发布的文件清单
94
+ ```
95
+
96
+ `package.json` 已配置 `prepublishOnly: "npm run clean && npm run check"`,`npm publish` 会自动清空 `dist/` 并跑一次完整构建与测试,既不会把未构建的产物发出去,也不会带入历史 hash chunk。发布前确认:
97
+
98
+ - `files` 白名单只包含 `dist/`、`README.md`、`AGENTS.md`、`llms.txt`、`docs/`(当前约 73 个文件、156 KB)。
99
+ - `exports` 里每个子路径的 `.js` 与 `.d.ts` 都存在。
100
+ - `CHANGELOG.md` 已补上本次版本条目。
101
+ - `docs/04-api-reference.md` 与 `package.json exports` 一致;`docs/03-module-map.md` 与文件树一致。
102
+ - `docs/11-compat-matrix.md` 已登记验证过的 three / 基础库版本。
103
+
104
+ `package.json` 已配置 `repository` / `homepage` / `bugs`,npm 包页面会展示源码入口与 issue 链接。若仓库迁移,同步修改这三个字段后再发布。
105
+
106
+ ### 9.5.2 准备 npm 账号
107
+
108
+ 1. 在 [npmjs.com](https://www.npmjs.com/signup) 注册账号,并在 **Account → 2FA** 开启双因素认证。
109
+ 2. 检查包名是否可用(发布前再查一次,避免被占用):
110
+
111
+ ```bash
112
+ npm view mini-three-adapter version
113
+ # 404 Not Found = 可用
114
+ ```
115
+
116
+ 3. 登录:
117
+
118
+ ```bash
119
+ npm login # 浏览器授权,最简单
120
+ npm whoami # 确认已登录
121
+ ```
122
+
123
+ CI 或非交互环境用 granular access token(权限选 `Read and write`,并限定到该包):
124
+
125
+ ```bash
126
+ # 不要把这个文件提交到仓库
127
+ echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
128
+ ```
129
+
130
+ ### 9.5.3 本地演练(推荐先做)
131
+
132
+ 生成一个真实 tarball,在干净目录里装一次,确认子路径导入都能解析:
133
+
134
+ ```bash
135
+ npm pack # 得到 mini-three-adapter-0.1.0.tgz
136
+ mkdir -p /tmp/m3-smoke && cd /tmp/m3-smoke
137
+ npm init -y && npm pkg set type=module
138
+ npm i /path/to/mini-three-adapter-0.1.0.tgz three
139
+ node --input-type=module -e "
140
+ import { createWeChatGameRuntime } from 'mini-three-adapter/wechat-game';
141
+ import { createWeChatMiniProgramRuntime } from 'mini-three-adapter/wechat-miniprogram';
142
+ import miniThree from 'mini-three-adapter/vite';
143
+ import { getActiveScope } from 'mini-three-adapter/scope';
144
+ console.log(typeof createWeChatGameRuntime, typeof createWeChatMiniProgramRuntime, typeof miniThree, typeof getActiveScope);
145
+ "
146
+ ```
147
+
148
+ > 未登录也能执行这一步。`npm pack` 生成的文件记得从仓库目录删掉,或把它加进 `.gitignore`。
149
+
150
+ ### 9.5.4 正式发布
151
+
152
+ ```bash
153
+ npm publish --access public
154
+ ```
155
+
156
+ `publishConfig.access` 已设为 `public`,`--access public` 可省略。执行后 `prepublishOnly` 会自动清空 `dist/` 并跑 `npm run check`。
157
+
158
+ **npm 的版本号不可覆盖**:同一个 `0.1.0` 只能发一次,之后每次改动都要先升版本再发。24 小时内可以 `npm unpublish <pkg>@<version>` 撤回,超过时间就不能删了;公开包一旦被他人依赖,撤回会影响别人,尽量不要依赖这个能力。
159
+
160
+ ### 9.5.5 发布后验证
161
+
162
+ ```bash
163
+ npm view mini-three-adapter version
164
+ npm view mini-three-adapter exports --json
165
+ ```
166
+
167
+ 在任意新项目里执行 `npm i mini-three-adapter three`,再跑一遍 9.5.3 的 import 冒烟。CDN 会在发布后自动可用(如 `https://unpkg.com/mini-three-adapter/`),但小游戏构建走本地 node_modules,不依赖 CDN。
168
+
169
+ ### 9.5.6 后续版本
170
+
171
+ ```bash
172
+ # 修 bug
173
+ npm version patch && npm publish
174
+ # 新增向后兼容能力
175
+ npm version minor && npm publish
176
+ # 破坏性变更(0.x 阶段也用 minor 时要写进 CHANGELOG)
177
+ npm version major && npm publish
178
+ ```
179
+
180
+ `npm version` 会自动改 `package.json`、生成 git tag(若已 `git init`)。每次发布重复 9.5.1 的检查。
181
+
182
+ CI 自动发布(`.github/workflows/publish.yml`)要点:用 `actions/setup-node` 配置 `registry-url`,把 `NPM_TOKEN` 放在仓库 Secrets 里,在 `npm ci && npm run check` 之后执行 `npm publish --provenance --access public`。`--provenance` 会在 npm 页面生成来源证明,需要仓库为 public 且 workflow 具备 `id-token: write` 权限。
183
+
184
+ ### 9.5.7 其他分发方式
185
+
186
+ | 方式 | 适用场景 |
187
+ | --- | --- |
188
+ | `npm pack` 把 `.tgz` 直接发给同事 | 还没决定公开,或需要在隔离环境试用;对方 `npm i ./xxx.tgz` |
189
+ | `"mini-three-adapter": "file:../.."` | 本机多个项目复用同一份源码 |
190
+ | 私有 registry(Verdaccio / GitHub Packages) | 只给团队内部使用,不想发到公共 npm |
191
+ | `npm link` | 开发期实时联调,改源码立刻生效 |
192
+
193
+ 发布到公共 npm 之后,业务项目只需 `npm i mini-three-adapter three`,`examples/*/package.json` 里的 `workspace:*` 改成 `"^0.1.0"` 即可。
194
+
195
+ ## 9.6 版本策略
196
+
197
+ - 遵循语义化版本;`0.x` 阶段 minor 可含破坏性变更,但必须在 CHANGELOG 与接入文档里写明。
198
+ - `three` 是 optional peer,`>=0.163.0`(WebGL2 门槛)。three 大版本升级时,重点回归 `DEFAULT_GLOBAL_NAMES` 与 `patchElement` 的属性集合。
199
+ - 微信基础库能力变化只影响 `capabilities.ts` / `wechat-common.ts` / `assets.ts`,不应扩散到 `core/`。
200
+
201
+ ## 9.7 真机验收清单(发布前)
202
+
203
+ - [ ] iOS / Android 各一台,WebGL2 正常出图
204
+ - [ ] 多指缩放/旋转(OrbitControls)不卡死,`touchcancel` 后指针计数归零
205
+ - [ ] 横竖屏切换后 `resize` 生效,画面不变形
206
+ - [ ] 前后台切换后帧循环恢复
207
+ - [ ] DRACO / KTX2 资源加载(含分包预下载 Worker)
208
+ - [ ] `runtime.dispose()` 后无残留监听、无内存持续增长
209
+ - [ ] `runtime.report()` 无 WebGL2 告警