@fast-china/utils 2.0.0 → 2.0.2

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 (80) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/Fast.png +0 -0
  3. package/README.md +27 -29
  4. package/README.zh.md +27 -29
  5. package/dist/base64/index.mjs.map +1 -1
  6. package/dist/crypto/index.d.mts +265 -96
  7. package/dist/crypto/index.mjs +563 -261
  8. package/dist/crypto/index.mjs.map +1 -1
  9. package/dist/identity/index.d.mts +5 -5
  10. package/dist/identity/index.mjs +2 -2
  11. package/dist/identity/index.mjs.map +1 -1
  12. package/dist/index.d.mts +3 -3
  13. package/dist/index.global.min.js +3 -0
  14. package/dist/index.global.min.js.map +1 -0
  15. package/dist/index.mjs +2 -2
  16. package/dist/storage/index.d.mts +11 -8
  17. package/dist/storage/index.mjs +21 -18
  18. package/dist/storage/index.mjs.map +1 -1
  19. package/dist/vue/emits.mjs.map +1 -1
  20. package/dist/vue/index.d.mts +2 -2
  21. package/dist/vue/install.d.mts +11 -29
  22. package/dist/vue/install.mjs +25 -25
  23. package/dist/vue/install.mjs.map +1 -1
  24. package/dist/vue/props.mjs.map +1 -1
  25. package/dist/vue/render.d.mts +2 -3
  26. package/dist/vue/render.mjs +3 -9
  27. package/dist/vue/render.mjs.map +1 -1
  28. package/docs/API.md +30 -14
  29. package/docs/API.zh-CN.md +30 -14
  30. package/docs/DEVELOPMENT_RELEASE.zh-CN.md +4 -4
  31. package/docs/RUNTIME_CONTRACT.md +10 -10
  32. package/package.json +9 -11
  33. package/dist/array/index.d.mts.map +0 -1
  34. package/dist/async/index.d.mts.map +0 -1
  35. package/dist/base64/index.d.mts.map +0 -1
  36. package/dist/color/index.d.mts.map +0 -1
  37. package/dist/crypto/index.d.mts.map +0 -1
  38. package/dist/date/index.d.mts.map +0 -1
  39. package/dist/dom/style.d.mts.map +0 -1
  40. package/dist/env/index.d.mts.map +0 -1
  41. package/dist/identity/index.d.mts.map +0 -1
  42. package/dist/logger/index.d.mts.map +0 -1
  43. package/dist/number/index.d.mts.map +0 -1
  44. package/dist/object/index.d.mts.map +0 -1
  45. package/dist/storage/index.d.mts.map +0 -1
  46. package/dist/string/index.d.mts.map +0 -1
  47. package/dist/vue/emits.d.mts.map +0 -1
  48. package/dist/vue/expose.d.mts.map +0 -1
  49. package/dist/vue/func.d.mts.map +0 -1
  50. package/dist/vue/install.d.mts.map +0 -1
  51. package/dist/vue/props.d.mts.map +0 -1
  52. package/dist/vue/render.d.mts.map +0 -1
  53. package/dist/vue/slots.d.mts.map +0 -1
  54. package/dist/vue/with.d.mts.map +0 -1
  55. package/src/array/index.ts +0 -173
  56. package/src/async/index.ts +0 -475
  57. package/src/base64/index.ts +0 -374
  58. package/src/color/index.ts +0 -208
  59. package/src/crypto/index.ts +0 -670
  60. package/src/date/index.ts +0 -451
  61. package/src/dom/index.ts +0 -6
  62. package/src/dom/style.ts +0 -92
  63. package/src/env/index.ts +0 -169
  64. package/src/identity/index.ts +0 -144
  65. package/src/index.ts +0 -20
  66. package/src/internal/text.ts +0 -46
  67. package/src/logger/index.ts +0 -219
  68. package/src/number/index.ts +0 -235
  69. package/src/object/index.ts +0 -160
  70. package/src/storage/index.ts +0 -524
  71. package/src/string/index.ts +0 -328
  72. package/src/vue/emits.ts +0 -71
  73. package/src/vue/expose.ts +0 -11
  74. package/src/vue/func.ts +0 -17
  75. package/src/vue/index.ts +0 -13
  76. package/src/vue/install.ts +0 -185
  77. package/src/vue/props.ts +0 -39
  78. package/src/vue/render.ts +0 -41
  79. package/src/vue/slots.ts +0 -23
  80. package/src/vue/with.ts +0 -10
package/src/vue/render.ts DELETED
@@ -1,41 +0,0 @@
1
- import { getCurrentInstance } from "vue";
2
-
3
- import type { VNode } from "vue";
4
-
5
- /** Vue 2.7 与 Vue 3 组件实例中渲染函数可能出现的位置。 */
6
- interface CompatibleVueInstance {
7
- /** Vue 2.7 兼容实例上的公共代理。 */
8
- proxy?: CompatibleVueProxy;
9
- /** Vue 3 内部组件实例直接持有的渲染函数。 */
10
- render?: () => VNode;
11
- }
12
-
13
- /** Vue 2.7 公共代理中允许写入渲染函数的最小结构。 */
14
- interface CompatibleVueProxy {
15
- /** 当前组件的可变 Options API 配置。 */
16
- $options?: CompatibleVueOptions;
17
- }
18
-
19
- /** TSX Helper 需要写入的最小组件选项。 */
20
- interface CompatibleVueOptions {
21
- /** 当前组件渲染函数;调用 {@link useRender} 后替换为传入函数。 */
22
- render?: () => VNode;
23
- }
24
-
25
- /**
26
- * 在当前 Vue 2.7/3 组件实例上安装 TSX 渲染函数。
27
- *
28
- * @remarks 组件的 `setup` 可以继续返回状态对象,因此状态能够显示在 Vue Devtools 中。
29
- * @param render - 当前组件的渲染函数。
30
- * @throws 不在组件 `setup` 调用栈中使用时抛出 `Error`。
31
- */
32
- export function useRender(render: () => VNode): void {
33
- const instance = getCurrentInstance();
34
- if (instance === null) throw new Error("useRender must be called from inside a setup function.");
35
- const compatible = instance as unknown as CompatibleVueInstance;
36
- if (compatible.proxy?.$options !== undefined && !("render" in compatible)) {
37
- compatible.proxy.$options.render = render;
38
- return;
39
- }
40
- compatible.render = render;
41
- }
package/src/vue/slots.ts DELETED
@@ -1,23 +0,0 @@
1
- import type { SlotsType, VNode } from "vue";
2
-
3
- /** Slot 名到 Props 类型的内部声明映射。 */
4
- type RawSlots = Record<string, unknown>;
5
- /** 根据 Slot Props 是否为 never 生成无参数或有参数的 Slot 签名。 */
6
- type VueSlot<Properties> = [Properties] extends [never] ? () => VNode[] : (properties: Properties) => VNode[];
7
-
8
- /** 把 Slot 名称与作用域参数映射为 Vue 3 Slot 函数。 */
9
- export type TypedSlots<Slots extends RawSlots> = {
10
- [Name in keyof Slots]: VueSlot<Slots[Name]>;
11
- };
12
-
13
- /** Vue 3 `slots` 选项接受的运行时声明与官方静态类型标记。 */
14
- export type TypedSlotsDeclaration<Slots extends RawSlots> = SlotsType<Partial<TypedSlots<Slots>>>;
15
-
16
- /**
17
- * 为 Options API 的 `slots` 选项创建带作用域参数的类型声明。
18
- *
19
- * @returns 运行时 `Object` 构造器,并携带仅供 TypeScript 使用的 Slot 类型标记。
20
- */
21
- export function makeSlots<Slots extends RawSlots>(): TypedSlotsDeclaration<Slots> {
22
- return Object as TypedSlotsDeclaration<Slots>;
23
- }
package/src/vue/with.ts DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * 保留传入值并显式指定其 TypeScript 类型。
3
- *
4
- * @remarks 未传值时运行时结果为 `undefined`,仅适合为 reactive 对象的初始字段提供类型。
5
- * @param data - 可选的原始值。
6
- * @returns 传入值本身;省略时返回类型化的 `undefined`。
7
- */
8
- export function withDefineType<Value>(data?: Value): Value {
9
- return data as Value;
10
- }