@fast-china/utils 2.1.6 → 2.1.7
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/CHANGELOG.md +7 -0
- package/README.md +2 -0
- package/README.zh.md +2 -0
- package/THIRD_PARTY_LICENSES.md +26 -0
- package/dist/crypto/index.mjs +2240 -33
- package/dist/crypto/index.mjs.map +1 -1
- package/dist/dom/index.mjs +2 -0
- package/dist/index.d.mts +1918 -32
- package/dist/index.global.min.js.map +1 -1
- package/dist/index.mjs +2 -0
- package/dist/vue/index.mjs +15 -0
- package/package.json +4 -6
- package/dist/array/index.d.mts +0 -94
- package/dist/async/index.d.mts +0 -145
- package/dist/base64/index.d.mts +0 -106
- package/dist/color/index.d.mts +0 -89
- package/dist/crypto/index.d.mts +0 -327
- package/dist/date/index.d.mts +0 -190
- package/dist/dom/style.d.mts +0 -29
- package/dist/env/index.d.mts +0 -62
- package/dist/function/index.d.mts +0 -13
- package/dist/identity/index.d.mts +0 -77
- package/dist/internal/text.d.mts +0 -15
- package/dist/logger/index.d.mts +0 -90
- package/dist/number/index.d.mts +0 -89
- package/dist/object/index.d.mts +0 -114
- package/dist/storage/index.d.mts +0 -115
- package/dist/string/index.d.mts +0 -141
- package/dist/vue/breakpoints.d.mts +0 -21
- package/dist/vue/element-size.d.mts +0 -25
- package/dist/vue/emits.d.mts +0 -23
- package/dist/vue/event-listener.d.mts +0 -16
- package/dist/vue/expose.d.mts +0 -11
- package/dist/vue/func.d.mts +0 -13
- package/dist/vue/index.d.mts +0 -15
- package/dist/vue/install.d.mts +0 -50
- package/dist/vue/now.d.mts +0 -13
- package/dist/vue/props.d.mts +0 -22
- package/dist/vue/render.d.mts +0 -11
- package/dist/vue/resize-observer.d.mts +0 -15
- package/dist/vue/slots.d.mts +0 -18
- package/dist/vue/window-size.d.mts +0 -16
- package/dist/vue/with.d.mts +0 -11
- package/docs/API.md +0 -155
- package/docs/API.zh-CN.md +0 -154
- package/docs/DEVELOPMENT_RELEASE.zh-CN.md +0 -65
- package/docs/RUNTIME_CONTRACT.md +0 -44
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# Fast.Utils 开发与发布
|
|
2
|
-
|
|
3
|
-
## 基线
|
|
4
|
-
|
|
5
|
-
- Node.js:`^22.18.0 || ^24.18.0`。
|
|
6
|
-
- pnpm:`^11.0.0`,不固定补丁版本。
|
|
7
|
-
- TypeScript 6、tsdown、ESLint 10 Flat Config、Prettier 3。
|
|
8
|
-
- 发布格式:包管理器使用 ESM、`.mjs` 与 `.d.mts`,CDN 使用压缩 IIFE;两类 JavaScript 产物均提供 Source Map。
|
|
9
|
-
- 根目录是唯一 npm 发布单元,根 `dist/` 是唯一产物目录。
|
|
10
|
-
|
|
11
|
-
应用环境包括现代浏览器、WebView、Vue 3 和 uni-app。
|
|
12
|
-
|
|
13
|
-
## 安装与命令
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
corepack enable
|
|
17
|
-
pnpm install --frozen-lockfile
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
| 命令 | 用途 |
|
|
21
|
-
| ------------------- | ---------------------------------------------------------------------- |
|
|
22
|
-
| `pnpm dev` | 使用 tsdown 监听源码并增量构建 |
|
|
23
|
-
| `pnpm build` | 使用 tsdown 构建 ESM 模块与压缩 IIFE |
|
|
24
|
-
| `pnpm typecheck` | 检查源码与构建配置类型 |
|
|
25
|
-
| `pnpm lint` | 运行零警告 ESLint |
|
|
26
|
-
| `pnpm format:check` | 检查 Prettier |
|
|
27
|
-
| `pnpm test:types` | 验证公开消费者类型 |
|
|
28
|
-
| `pnpm test:runtime` | 运行单元、平台与 Vue Runtime 测试 |
|
|
29
|
-
| `pnpm test:package` | 验证 Tarball、公开入口、声明、Source Map、Tree Shaking、体积与 Publint |
|
|
30
|
-
| `pnpm check` | 运行统一质量门禁 |
|
|
31
|
-
|
|
32
|
-
## 修改公共模块
|
|
33
|
-
|
|
34
|
-
新增公共模块时必须同步:
|
|
35
|
-
|
|
36
|
-
1. 在 `src/<module>/index.ts` 定义具名 API 和 TSDoc。
|
|
37
|
-
2. 在 `src/index.ts` 统一重新导出公共 API。
|
|
38
|
-
3. 不为模块增加 `package.json#exports` 子路径或独立构建入口。
|
|
39
|
-
4. 增加源码类型、消费者类型、单元和真实包测试。
|
|
40
|
-
5. 更新双语 README、API 和 Changelog。
|
|
41
|
-
|
|
42
|
-
禁止在导入阶段访问浏览器或 uni-app 全局对象。平台能力应在调用阶段解析;`configureStorage` 在调用时自动检测全局 `uni`。
|
|
43
|
-
|
|
44
|
-
## 依赖与锁文件
|
|
45
|
-
|
|
46
|
-
- Runtime Dependency 必须证明无法由平台能力或小型实现替代。
|
|
47
|
-
- Vue 3.3+ 是必须安装的 Peer Dependency;ESM 与 IIFE 均保持外部引用,不打包进发布产物。
|
|
48
|
-
- 依赖升级后使用当前 pnpm 11 更新 Lockfile,并通过 Frozen Lockfile 安装验证。
|
|
49
|
-
- 不混用 npm、Yarn 或不同 pnpm 主版本改写 Lockfile。
|
|
50
|
-
|
|
51
|
-
## CI
|
|
52
|
-
|
|
53
|
-
CI 在 Node 22 与 24 上运行,使用 Frozen Lockfile,并执行 `pnpm check` 与 Pack Dry Run。不得通过关闭类型、Lint、测试或包验证来修复门禁。
|
|
54
|
-
|
|
55
|
-
## 发布
|
|
56
|
-
|
|
57
|
-
仓库只采用人工发布流程,不声明或配置 OIDC Trusted Publishing:
|
|
58
|
-
|
|
59
|
-
1. 更新 SemVer 与 `CHANGELOG.md` 日期。
|
|
60
|
-
2. 执行 `pnpm install --frozen-lockfile`。
|
|
61
|
-
3. 执行 `pnpm check`。
|
|
62
|
-
4. 人工检查 `pnpm --config.ignore-scripts=true pack --dry-run` 清单。
|
|
63
|
-
5. 由维护者在可信环境执行 npm Publish,并创建对应 `v<version>` Tag。
|
|
64
|
-
|
|
65
|
-
未经明确授权,不执行 Publish、Push、Tag 或 Release。npm 已发布版本不可覆盖;发布后缺陷必须通过新 Patch 或 Pre-release 修复。
|
package/docs/RUNTIME_CONTRACT.md
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# Fast.Utils runtime contract / 运行时契约
|
|
2
|
-
|
|
3
|
-
## Runtime and package contract
|
|
4
|
-
|
|
5
|
-
- Runtime platforms: ES2022 modern browsers, WebViews, Vue 3 applications, and uni-app.
|
|
6
|
-
- Package format: one public named-export ESM entry for package managers and one separately minified IIFE entry for CDN use; CommonJS and UMD are not shipped.
|
|
7
|
-
- Framework boundary: Vue remains external to the package-manager build and is a required peer in `^3.5.11`.
|
|
8
|
-
- Vue browser composables: event and observer helpers use native platform APIs, return manual stop handles where exposed, and clean up automatically with the current Vue scope. Window size and breakpoints use `0`/`false` outside browsers; `useNow` returns a non-updating initial Date during SSR.
|
|
9
|
-
- uni-app boundary: the first Storage operation, or an earlier `configureStorage({ prefix })` call, detects global `uni` and uses its synchronous Storage API.
|
|
10
|
-
- Browser storage: applications import `Local` and `Session` directly; `configureStorage()` is needed only to override defaults before the first operation.
|
|
11
|
-
- Storage operation overrides: `set/get({ crypto })` select JSON or Base64 for one operation without mutating global configuration. The v3 envelope does not identify its codec, so callers must use matching options for the same entry.
|
|
12
|
-
- Storage read typing: `get<Value = string>()` defaults to `string | undefined` when no generic is supplied; codecs still restore the original runtime JSON value.
|
|
13
|
-
- Stateful browser defaults: Storage, Identity, and default Logger configuration are page-global by design. Storage and Identity reject conflicting reconfiguration; `configureLogger` replaces the default Logger configuration while preserving the exported facade reference.
|
|
14
|
-
- Randomness: every random generation entry prefers Web Crypto and falls back to `Math.random()` when unavailable.
|
|
15
|
-
- Publishing: the repository root is the only package, `dist/` is the only build output, and `package.json#exports` is the complete public path whitelist.
|
|
16
|
-
|
|
17
|
-
Importing a module does not itself read `window`, browser Storage, or `uni`, so unsupported platform capabilities fail only when the corresponding API is called.
|
|
18
|
-
|
|
19
|
-
## Public API policy
|
|
20
|
-
|
|
21
|
-
- Stateless Array, Date, String, Number, Object, Base64, Color, DOM, Env, Async, and Crypto capabilities use named exports.
|
|
22
|
-
- The public API uses named functions instead of mutable aggregate utility objects.
|
|
23
|
-
- Base64 and Crypto text decoders return primitive strings typed as `DecodedText`. They can be used directly as strings; an explicit `.parseJson<T = any>()` call attempts JSON parsing and falls back to the original string for invalid JSON. The first text decode lazily installs a non-enumerable `String.prototype.parseJson` and rejects a foreign same-name property instead of overwriting it. Storage codecs continue to parse JSON automatically and strictly.
|
|
24
|
-
- Stateful browser capabilities use cohesive package-owned objects: `Local`, `Session`, `installationIdentity`, and Logger instances. Logger exposes the matching `debug`, `log`, `warn`, and `error` levels, defaults to the `debug` minimum, and receives scope on each method rather than storing it in child instances. `createLogger` returns isolated instances, while `configureLogger` only changes the default `logger` facade.
|
|
25
|
-
- Internal adapters and client factories are implementation details and are not public export paths.
|
|
26
|
-
- Removing a named function, changing Storage/ciphertext formats, raising the browser syntax target, or changing the Vue peer range requires an explicit major-version Breaking Change.
|
|
27
|
-
|
|
28
|
-
## 运行时与包契约
|
|
29
|
-
|
|
30
|
-
- 运行平台:ES2022 现代浏览器、WebView、Vue 3 应用和 uni-app。
|
|
31
|
-
- 包格式:包管理器使用单一公开具名导出 ESM 入口,CDN 使用单独压缩的 IIFE;不发布 CommonJS 或 UMD。
|
|
32
|
-
- Vue 边界:Vue 不会打进包管理器使用的构建产物,是 `^3.5.11` 的必需 Peer。
|
|
33
|
-
- Vue 浏览器 Composable:事件和观察器 Helper 直接使用原生平台 API,在公开停止函数时支持手动清理,并随当前 Vue 作用域自动清理。非浏览器环境下窗口尺寸和断点状态分别使用 `0` 与 `false`,`useNow` 在 SSR 时只返回调用时的静态 Date。
|
|
34
|
-
- uni-app:首次 Storage 操作或更早的 `configureStorage({ prefix })` 调用会检测全局 `uni`,并使用其同步 Storage API。
|
|
35
|
-
- Storage:直接从包导入 `Local` 和 `Session` 即可;只有覆盖默认值时才需在首次操作前调用 `configureStorage()`。
|
|
36
|
-
- Storage 单次覆盖:`set/get({ crypto })` 只为当前操作选择 JSON 或 Base64,不修改全局配置。v3 包络不记录 Codec,调用方必须对同一条目使用匹配的读写选项。
|
|
37
|
-
- Storage 读取类型:`get<Value = string>()` 未传泛型时默认推断为 `string | undefined`,Codec 在运行时仍恢复原始 JSON 值。
|
|
38
|
-
- 状态:Storage、Identity 与默认 Logger 配置按浏览器页面全局共享。Storage 和 Identity 的冲突配置明确抛错;`configureLogger` 替换默认 Logger 的配置,同时保持导出的门面引用稳定。
|
|
39
|
-
- 随机数:所有随机生成入口都优先使用 Web Crypto,缺失时回退到 `Math.random()`。
|
|
40
|
-
- 发布:根目录是唯一 npm 包,`dist/` 是唯一构建输出,`exports` 是完整公共路径白名单。
|
|
41
|
-
|
|
42
|
-
模块导入本身不读取 `window`、浏览器 Storage 或 `uni`,不具备对应平台能力时只在调用相关 API 时明确失败。
|
|
43
|
-
|
|
44
|
-
无状态能力统一使用具名导出。Base64 与 Crypto 文本解码入口返回原始字符串类型 `DecodedText`,可以直接作为字符串使用;`.parseJson<T = any>()` 只在显式调用时尝试解析 JSON,非法 JSON 回退为原始字符串。首次文本解码会按需安装不可枚举的 `String.prototype.parseJson`,若同名属性已被其他实现占用则拒绝覆盖并抛错。Storage Codec 继续严格自动解析 JSON。有状态浏览器能力使用 `Local`、`Session`、`installationIdentity` 和 Logger 实例;Logger 提供与 Sink 同名的 `debug`、`log`、`warn`、`error` 级别,默认最低级别为 `debug`,作用域随每次调用传入,不创建 Child Logger。`createLogger` 返回隔离实例,`configureLogger` 只修改默认 `logger` 门面。
|