@cmtlyt/lingshu-toolkit 0.1.1 → 0.3.0

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 (76) hide show
  1. package/README.md +2 -0
  2. package/dist/607.js +288 -108
  3. package/dist/707.js +136 -0
  4. package/dist/react/index.d.ts +7 -0
  5. package/dist/react/index.js +129 -8
  6. package/dist/react/use-boolean/index.d.ts +6 -0
  7. package/dist/react/use-boolean/index.js +16 -0
  8. package/dist/react/use-boolean/index.test.d.ts +1 -0
  9. package/dist/react/use-controllable-value/index.js +1 -2
  10. package/dist/react/use-counter/index.js +2 -2
  11. package/dist/react/use-force-update/index.d.ts +1 -0
  12. package/dist/react/use-force-update/index.js +6 -0
  13. package/dist/react/use-force-update/index.test.d.ts +1 -0
  14. package/dist/react/use-mount/index.d.ts +1 -0
  15. package/dist/react/use-mount/index.js +16 -0
  16. package/dist/react/use-mount/index.test.d.ts +1 -0
  17. package/dist/react/use-ref-state/index.d.ts +8 -0
  18. package/dist/react/use-ref-state/index.js +35 -0
  19. package/dist/react/use-ref-state/index.test.d.ts +1 -0
  20. package/dist/react/use-storage/index.d.ts +2 -0
  21. package/dist/react/use-storage/index.js +15 -0
  22. package/dist/react/use-storage/index.test.d.ts +1 -0
  23. package/dist/react/use-title/index.d.ts +6 -0
  24. package/dist/react/use-title/index.js +24 -0
  25. package/dist/react/use-title/index.test.d.ts +1 -0
  26. package/dist/react/use-toggle/index.d.ts +10 -0
  27. package/dist/react/use-toggle/index.js +26 -0
  28. package/dist/react/use-toggle/index.test.d.ts +1 -0
  29. package/dist/react/use-valid-data/index.d.ts +4 -2
  30. package/dist/react/use-valid-data/index.js +5 -2
  31. package/dist/shared/animation/__test__/animation-pause-resume.test.d.ts +1 -0
  32. package/dist/shared/animation/__test__/animation.test.d.ts +1 -0
  33. package/dist/shared/animation/__test__/step-animation.test.d.ts +1 -0
  34. package/dist/shared/animation/__test__/utils.test.d.ts +1 -0
  35. package/dist/shared/animation/index.d.ts +3 -0
  36. package/dist/shared/animation/index.js +71 -0
  37. package/dist/shared/animation/types.d.ts +22 -0
  38. package/dist/shared/animation/types.js +0 -0
  39. package/dist/shared/animation/utils.d.ts +16 -0
  40. package/dist/shared/animation/utils.js +138 -0
  41. package/dist/shared/condition-merge/index.d.ts +31 -0
  42. package/dist/shared/condition-merge/index.js +30 -0
  43. package/dist/shared/condition-merge/index.test-d.d.ts +1 -0
  44. package/dist/shared/condition-merge/index.test-d.js +108 -0
  45. package/dist/shared/condition-merge/index.test.d.ts +1 -0
  46. package/dist/shared/create-storage-handler/index.browser.test.d.ts +1 -0
  47. package/dist/shared/create-storage-handler/index.d.ts +10 -0
  48. package/dist/shared/create-storage-handler/index.js +68 -0
  49. package/dist/shared/create-storage-handler/index.test.d.ts +1 -0
  50. package/dist/shared/data-handler/index.d.ts +7 -2
  51. package/dist/shared/data-handler/index.js +4 -4
  52. package/dist/shared/data-handler/tools.d.ts +36 -12
  53. package/dist/shared/data-handler/tools.js +8 -2
  54. package/dist/shared/data-handler/types.d.ts +3 -2
  55. package/dist/shared/index.d.ts +5 -0
  56. package/dist/shared/index.js +2 -1
  57. package/dist/shared/logger/index.d.ts +5 -1
  58. package/dist/shared/logger/index.js +2 -2
  59. package/dist/shared/throw-error/index.d.ts +2 -2
  60. package/dist/shared/throw-error/index.js +4 -4
  61. package/dist/shared/types/base.d.ts +8 -0
  62. package/dist/shared/types/base.js +0 -0
  63. package/dist/shared/types/index.d.ts +2 -2
  64. package/dist/shared/types/index.js +2 -0
  65. package/dist/shared/types/pack.d.ts +9 -0
  66. package/dist/shared/types/pack.js +1 -0
  67. package/dist/shared/with-resolvers/index.d.ts +6 -0
  68. package/dist/shared/with-resolvers/index.js +15 -0
  69. package/dist/shared/with-resolvers/index.test.d.ts +1 -0
  70. package/dist/test/utils.d.ts +13 -0
  71. package/dist/vue/index.d.ts +1 -0
  72. package/dist/vue/index.js +29 -0
  73. package/dist/vue/use-title/index.d.ts +6 -0
  74. package/dist/vue/use-title/index.js +29 -0
  75. package/dist/vue/use-title/index.test.d.ts +1 -0
  76. package/package.json +16 -4
@@ -0,0 +1,15 @@
1
+ function withResolvers() {
2
+ return 'function' == typeof Promise.withResolvers ? Promise.withResolvers() : (()=>{
3
+ const resolver = {
4
+ promise: null,
5
+ resolve: null,
6
+ reject: null
7
+ };
8
+ resolver.promise = new Promise((resolve, reject)=>{
9
+ resolver.resolve = resolve;
10
+ resolver.reject = reject;
11
+ });
12
+ return resolver;
13
+ })();
14
+ }
15
+ export { withResolvers };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { Component, type PropsWithChildren } from 'react';
2
+ export declare class ErrorBoundary extends Component<PropsWithChildren<{
3
+ onError: () => void;
4
+ }>> {
5
+ state: {
6
+ hasError: boolean;
7
+ };
8
+ static getDerivedStateFromError(): {
9
+ hasError: boolean;
10
+ };
11
+ componentDidCatch(): void;
12
+ render(): import("react").ReactNode;
13
+ }
@@ -0,0 +1 @@
1
+ export * from './use-title';
@@ -0,0 +1,29 @@
1
+ import { onScopeDispose, ref, toValue, watch } from "vue";
2
+ import { dataHandler, $t, $dt } from "../707.js";
3
+ function setTitle(title) {
4
+ if (!title || "u" < typeof document) return;
5
+ const oldTitle = document.title;
6
+ document.title = title;
7
+ return oldTitle;
8
+ }
9
+ const validInfo = $dt({
10
+ restoreOnUnmount: $t.boolean(true)
11
+ });
12
+ function useTitle(newTitle = '', options = {}) {
13
+ const { restoreOnUnmount } = dataHandler(options, validInfo, {
14
+ unwrap: true
15
+ });
16
+ const title = ref(toValue(newTitle));
17
+ const originalTitle = setTitle(title.value);
18
+ watch(title, setTitle, {
19
+ flush: 'sync'
20
+ });
21
+ watch(()=>toValue(newTitle), (value)=>{
22
+ title.value = value;
23
+ });
24
+ if (restoreOnUnmount) onScopeDispose(()=>{
25
+ setTitle(originalTitle);
26
+ });
27
+ return title;
28
+ }
29
+ export { useTitle };
@@ -0,0 +1,6 @@
1
+ import { type MaybeRefOrGetter } from 'vue';
2
+ interface UseTitleOptions {
3
+ restoreOnUnmount: boolean;
4
+ }
5
+ export declare function useTitle(newTitle?: MaybeRefOrGetter<string>, options?: Partial<UseTitleOptions>): import("vue").Ref<string, string>;
6
+ export {};
@@ -0,0 +1,29 @@
1
+ import { onScopeDispose, ref, toValue, watch } from "vue";
2
+ import { $dt, $t, dataHandler } from "../../shared/data-handler/index.js";
3
+ function setTitle(title) {
4
+ if (!title || "u" < typeof document) return;
5
+ const oldTitle = document.title;
6
+ document.title = title;
7
+ return oldTitle;
8
+ }
9
+ const validInfo = $dt({
10
+ restoreOnUnmount: $t.boolean(true)
11
+ });
12
+ function useTitle(newTitle = '', options = {}) {
13
+ const { restoreOnUnmount } = dataHandler(options, validInfo, {
14
+ unwrap: true
15
+ });
16
+ const title = ref(toValue(newTitle));
17
+ const originalTitle = setTitle(title.value);
18
+ watch(title, setTitle, {
19
+ flush: 'sync'
20
+ });
21
+ watch(()=>toValue(newTitle), (value)=>{
22
+ title.value = value;
23
+ });
24
+ if (restoreOnUnmount) onScopeDispose(()=>{
25
+ setTitle(originalTitle);
26
+ });
27
+ return title;
28
+ }
29
+ export { useTitle };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmtlyt/lingshu-toolkit",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "main": "./dist/shared.js",
6
6
  "module": "./dist/shared.js",
@@ -25,6 +25,14 @@
25
25
  "./shared/*": {
26
26
  "types": "./dist/shared/*/index.d.ts",
27
27
  "import": "./dist/shared/*"
28
+ },
29
+ "./vue": {
30
+ "types": "./dist/vue/index.d.ts",
31
+ "import": "./dist/vue/index.js"
32
+ },
33
+ "./vue/*": {
34
+ "types": "./dist/vue/*/index.d.ts",
35
+ "import": "./dist/vue/*"
28
36
  }
29
37
  },
30
38
  "author": {
@@ -44,10 +52,12 @@
44
52
  "@vitest/browser-playwright": "4.0.18",
45
53
  "@vitest/coverage-v8": "4.0.18",
46
54
  "@vitest/ui": "4.0.18",
55
+ "cross-env": "^10.1.0",
47
56
  "esno": "^4.8.0",
48
57
  "husky": "^9.1.7",
49
58
  "jsdom": "^27.4.0",
50
59
  "lint-staged": "^16.2.7",
60
+ "playwright": "^1.58.1",
51
61
  "react": "^19.2.4",
52
62
  "react-dom": "^19.2.4",
53
63
  "rspress": "^1.47.1",
@@ -104,10 +114,12 @@
104
114
  "build:docs": "rspress build",
105
115
  "check": "biome check --write",
106
116
  "dev:docs": "rspress dev",
117
+ "dev:registry": "pnpm dlx serve src/public -p 3000",
118
+ "preview:docs": "rspress preview",
107
119
  "format": "biome format --write",
108
- "test": "vitest --config=vitest.browser.config.ts --coverage.enabled --ui",
109
- "test:ci": "vitest run --config=vitest.browser.config.ts",
110
- "test:lib:ci": "vitest run",
120
+ "test": "vitest --config=vitest.project.config.ts --coverage.enabled --ui",
121
+ "test:ci": "cross-env gen_file_disabled=true vitest run --config=vitest.project.config.ts",
122
+ "test:lib:ci": "cross-env gen_file_disabled=true vitest run",
111
123
  "test:lib": "vitest --coverage.enabled --ui",
112
124
  "script:gen-file": "esno scripts/gen-file.ts"
113
125
  }