@vlian/framework 1.2.63 → 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.
- package/README.md +24 -141
- package/dist/i18n.cjs +1 -0
- package/dist/i18n.d.ts +2 -0
- package/dist/i18n.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -9
- package/dist/index.js +1 -1
- package/dist/index.umd.js +10 -220
- package/dist/kernel/constants.cjs +1 -1
- package/dist/kernel/constants.d.ts +1 -3
- package/dist/kernel/constants.js +1 -1
- package/dist/kernel/custom-manager/i18n/I18nManager.cjs +1 -0
- package/dist/kernel/{manager → custom-manager}/i18n/I18nManager.d.ts +2 -1
- package/dist/kernel/custom-manager/i18n/I18nManager.js +1 -0
- package/dist/kernel/custom-manager/i18n/constants.cjs +1 -0
- package/dist/kernel/custom-manager/i18n/constants.d.ts +4 -0
- package/dist/kernel/custom-manager/i18n/constants.js +1 -0
- package/dist/kernel/{manager → custom-manager}/i18n/i18n.persistence.d.ts +2 -1
- package/dist/kernel/custom-manager/i18n/i18n.runtime.cjs +1 -0
- package/dist/kernel/custom-manager/i18n/i18n.runtime.d.ts +8 -0
- package/dist/kernel/custom-manager/i18n/i18n.runtime.js +1 -0
- package/dist/kernel/{manager → custom-manager}/i18n/i18n.schema.cjs +1 -1
- package/dist/kernel/{manager → custom-manager}/i18n/i18n.schema.d.ts +1 -1
- package/dist/kernel/custom-manager/i18n/i18n.schema.js +1 -0
- package/dist/kernel/custom-manager/i18n/index.cjs +1 -0
- package/dist/kernel/custom-manager/i18n/index.d.ts +7 -0
- package/dist/kernel/custom-manager/i18n/index.js +1 -0
- package/dist/kernel/custom-manager/i18n/types.d.ts +10 -0
- package/dist/kernel/custom-manager/index.cjs +1 -0
- package/dist/kernel/custom-manager/index.d.ts +4 -0
- package/dist/kernel/custom-manager/index.js +1 -0
- package/dist/kernel/custom-manager/theme/ThemeManager.cjs +1 -0
- package/dist/kernel/{manager → custom-manager}/theme/ThemeManager.d.ts +8 -1
- package/dist/kernel/custom-manager/theme/ThemeManager.js +1 -0
- package/dist/kernel/custom-manager/theme/constants.cjs +1 -0
- package/dist/kernel/custom-manager/theme/constants.d.ts +4 -0
- package/dist/kernel/custom-manager/theme/constants.js +1 -0
- package/dist/kernel/custom-manager/theme/index.cjs +1 -0
- package/dist/kernel/custom-manager/theme/index.d.ts +7 -0
- package/dist/kernel/custom-manager/theme/index.js +1 -0
- package/dist/kernel/custom-manager/theme/theme.dom.cjs +1 -0
- package/dist/kernel/custom-manager/theme/theme.dom.d.ts +10 -0
- package/dist/kernel/custom-manager/theme/theme.dom.js +1 -0
- package/dist/kernel/{manager → custom-manager}/theme/theme.persistence.d.ts +2 -1
- package/dist/kernel/custom-manager/theme/theme.schema.cjs +1 -0
- package/dist/kernel/{manager → custom-manager}/theme/theme.schema.d.ts +3 -1
- package/dist/kernel/custom-manager/theme/theme.schema.js +1 -0
- package/dist/kernel/custom-manager/theme/types.d.ts +14 -0
- package/dist/kernel/index.cjs +1 -1
- package/dist/kernel/index.d.ts +2 -2
- package/dist/kernel/index.js +1 -1
- package/dist/kernel/kernel.cjs +1 -1
- package/dist/kernel/kernel.d.ts +3 -7
- package/dist/kernel/kernel.js +1 -1
- package/dist/kernel/manager/index.cjs +1 -1
- package/dist/kernel/manager/index.d.ts +0 -2
- package/dist/kernel/manager/index.js +1 -1
- package/dist/kernel/types.d.ts +10 -39
- package/dist/theme.cjs +1 -0
- package/dist/theme.d.ts +2 -0
- package/dist/theme.js +1 -0
- package/package.json +28 -129
- package/dist/analytics/index.cjs +0 -1
- package/dist/analytics/index.d.ts +0 -2
- package/dist/analytics/index.js +0 -1
- package/dist/analytics.umd.js +0 -19
- package/dist/components/index.cjs +0 -1
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.js +0 -1
- package/dist/components/persistence.cjs +0 -1
- package/dist/components/persistence.d.ts +0 -12
- package/dist/components/persistence.js +0 -1
- package/dist/kernel/manager/i18n/I18nManager.cjs +0 -1
- package/dist/kernel/manager/i18n/I18nManager.js +0 -1
- package/dist/kernel/manager/i18n/i18n.schema.js +0 -1
- package/dist/kernel/manager/i18n/index.cjs +0 -1
- package/dist/kernel/manager/i18n/index.d.ts +0 -1
- package/dist/kernel/manager/i18n/index.js +0 -1
- package/dist/kernel/manager/i18nManager.cjs +0 -1
- package/dist/kernel/manager/i18nManager.d.ts +0 -1
- package/dist/kernel/manager/i18nManager.js +0 -1
- package/dist/kernel/manager/theme/ThemeManager.cjs +0 -1
- package/dist/kernel/manager/theme/ThemeManager.js +0 -1
- package/dist/kernel/manager/theme/index.cjs +0 -1
- package/dist/kernel/manager/theme/index.d.ts +0 -1
- package/dist/kernel/manager/theme/index.js +0 -1
- package/dist/kernel/manager/theme/theme.dom.cjs +0 -1
- package/dist/kernel/manager/theme/theme.dom.d.ts +0 -3
- package/dist/kernel/manager/theme/theme.dom.js +0 -1
- package/dist/kernel/manager/theme/theme.schema.cjs +0 -1
- package/dist/kernel/manager/theme/theme.schema.js +0 -1
- package/dist/kernel/manager/themeManager.cjs +0 -1
- package/dist/kernel/manager/themeManager.d.ts +0 -1
- package/dist/kernel/manager/themeManager.js +0 -1
- package/dist/library/index.cjs +0 -1
- package/dist/library/index.d.ts +0 -2
- package/dist/library/index.js +0 -1
- package/dist/library/locale/index.cjs +0 -1
- package/dist/library/locale/index.d.ts +0 -6
- package/dist/library/locale/index.js +0 -1
- package/dist/library/locale/langs/en-us/index.cjs +0 -1
- package/dist/library/locale/langs/en-us/index.d.ts +0 -3
- package/dist/library/locale/langs/en-us/index.js +0 -1
- package/dist/library/locale/langs/zh-cn/index.cjs +0 -1
- package/dist/library/locale/langs/zh-cn/index.d.ts +0 -3
- package/dist/library/locale/langs/zh-cn/index.js +0 -1
- package/dist/library/locale/types.d.ts +0 -38
- package/dist/library/storage/cache.cjs +0 -1
- package/dist/library/storage/cache.d.ts +0 -57
- package/dist/library/storage/cache.js +0 -1
- package/dist/library/storage/encryption.cjs +0 -1
- package/dist/library/storage/encryption.d.ts +0 -45
- package/dist/library/storage/encryption.js +0 -1
- package/dist/library/storage/index.cjs +0 -1
- package/dist/library/storage/index.d.ts +0 -62
- package/dist/library/storage/index.js +0 -1
- package/dist/state/StateManager.cjs +0 -1
- package/dist/state/StateManager.d.ts +0 -120
- package/dist/state/StateManager.js +0 -1
- package/dist/state/adapters/AdapterFactory.cjs +0 -1
- package/dist/state/adapters/AdapterFactory.d.ts +0 -51
- package/dist/state/adapters/AdapterFactory.js +0 -1
- package/dist/state/adapters/DefaultAdapter.cjs +0 -1
- package/dist/state/adapters/DefaultAdapter.d.ts +0 -38
- package/dist/state/adapters/DefaultAdapter.js +0 -1
- package/dist/state/adapters/ReduxAdapter.cjs +0 -1
- package/dist/state/adapters/ReduxAdapter.d.ts +0 -129
- package/dist/state/adapters/ReduxAdapter.js +0 -1
- package/dist/state/adapters/ZustandAdapter.cjs +0 -1
- package/dist/state/adapters/ZustandAdapter.d.ts +0 -46
- package/dist/state/adapters/ZustandAdapter.js +0 -1
- package/dist/state/adapters/index.cjs +0 -1
- package/dist/state/adapters/index.d.ts +0 -8
- package/dist/state/adapters/index.js +0 -1
- package/dist/state/adapters/types.cjs +0 -1
- package/dist/state/adapters/types.d.ts +0 -4
- package/dist/state/adapters/types.js +0 -1
- package/dist/state/core/DerivedStateInstance.cjs +0 -1
- package/dist/state/core/DerivedStateInstance.d.ts +0 -100
- package/dist/state/core/DerivedStateInstance.js +0 -1
- package/dist/state/core/StateInstance.cjs +0 -1
- package/dist/state/core/StateInstance.d.ts +0 -85
- package/dist/state/core/StateInstance.js +0 -1
- package/dist/state/core/StateRegistry.cjs +0 -1
- package/dist/state/core/StateRegistry.d.ts +0 -55
- package/dist/state/core/StateRegistry.js +0 -1
- package/dist/state/core/StateScope.cjs +0 -1
- package/dist/state/core/StateScope.d.ts +0 -71
- package/dist/state/core/StateScope.js +0 -1
- package/dist/state/core/index.cjs +0 -1
- package/dist/state/core/index.d.ts +0 -7
- package/dist/state/core/index.js +0 -1
- package/dist/state/index.cjs +0 -1
- package/dist/state/index.d.ts +0 -8
- package/dist/state/index.js +0 -1
- package/dist/state/types.d.ts +0 -230
- package/dist/state.umd.js +0 -41
- package/dist/types.cjs +0 -1
- package/dist/types.d.ts +0 -7
- package/dist/types.js +0 -1
- package/dist/utils/analytics.cjs +0 -1
- package/dist/utils/analytics.d.ts +0 -127
- package/dist/utils/analytics.js +0 -1
- package/dist/utils/configSecurity.cjs +0 -3
- package/dist/utils/configSecurity.d.ts +0 -100
- package/dist/utils/configSecurity.js +0 -3
- package/dist/utils/csrf.cjs +0 -1
- package/dist/utils/csrf.d.ts +0 -1
- package/dist/utils/csrf.js +0 -1
- package/dist/utils/errors/ErrorCodes.cjs +0 -1
- package/dist/utils/errors/ErrorCodes.d.ts +0 -1
- package/dist/utils/errors/ErrorCodes.js +0 -1
- package/dist/utils/errors.cjs +0 -1
- package/dist/utils/errors.d.ts +0 -30
- package/dist/utils/errors.js +0 -1
- package/dist/utils/index.cjs +0 -1
- package/dist/utils/index.d.ts +0 -39
- package/dist/utils/index.js +0 -1
- package/dist/utils/logger.cjs +0 -1
- package/dist/utils/logger.d.ts +0 -2
- package/dist/utils/logger.js +0 -1
- package/dist/utils/logger.types.cjs +0 -1
- package/dist/utils/logger.types.d.ts +0 -2
- package/dist/utils/logger.types.js +0 -1
- package/dist/utils/monitoring.cjs +0 -1
- package/dist/utils/monitoring.d.ts +0 -1
- package/dist/utils/monitoring.js +0 -1
- package/dist/utils/performance.cjs +0 -1
- package/dist/utils/performance.d.ts +0 -2
- package/dist/utils/performance.js +0 -1
- package/dist/utils/resourceLoader.cjs +0 -1
- package/dist/utils/resourceLoader.d.ts +0 -2
- package/dist/utils/resourceLoader.js +0 -1
- package/dist/utils/runtimeSecurity.cjs +0 -1
- package/dist/utils/runtimeSecurity.d.ts +0 -2
- package/dist/utils/runtimeSecurity.js +0 -1
- package/dist/utils/security.cjs +0 -1
- package/dist/utils/security.d.ts +0 -2
- package/dist/utils/security.js +0 -1
- package/dist/utils/traceId.cjs +0 -1
- package/dist/utils/traceId.d.ts +0 -1
- package/dist/utils/traceId.js +0 -1
- package/dist/utils/validation.cjs +0 -1
- package/dist/utils/validation.d.ts +0 -2
- package/dist/utils/validation.js +0 -1
- /package/dist/kernel/{manager → custom-manager}/i18n/i18n.persistence.cjs +0 -0
- /package/dist/kernel/{manager → custom-manager}/i18n/i18n.persistence.js +0 -0
- /package/dist/{library/locale → kernel/custom-manager/i18n}/types.cjs +0 -0
- /package/dist/{library/locale → kernel/custom-manager/i18n}/types.js +0 -0
- /package/dist/kernel/{manager → custom-manager}/theme/theme.persistence.cjs +0 -0
- /package/dist/kernel/{manager → custom-manager}/theme/theme.persistence.js +0 -0
- /package/dist/{state → kernel/custom-manager/theme}/types.cjs +0 -0
- /package/dist/{state → kernel/custom-manager/theme}/types.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vlian/framework",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"packageManager": "pnpm@10.27.0",
|
|
6
6
|
"description": "Secra Framework - 一个现代化的低代码框架",
|
|
@@ -15,62 +15,15 @@
|
|
|
15
15
|
"require": "./dist/index.cjs",
|
|
16
16
|
"browser": "./dist/index.umd.js"
|
|
17
17
|
},
|
|
18
|
-
"./
|
|
19
|
-
"types": "./dist/
|
|
20
|
-
"import": "./dist/
|
|
21
|
-
"require": "./dist/
|
|
18
|
+
"./theme": {
|
|
19
|
+
"types": "./dist/theme.d.ts",
|
|
20
|
+
"import": "./dist/theme.js",
|
|
21
|
+
"require": "./dist/theme.cjs"
|
|
22
22
|
},
|
|
23
|
-
"./
|
|
24
|
-
"types": "./dist/
|
|
25
|
-
"import": "./dist/
|
|
26
|
-
"require": "./dist/
|
|
27
|
-
},
|
|
28
|
-
"./utils/*": {
|
|
29
|
-
"types": "./dist/utils/*.d.ts",
|
|
30
|
-
"import": "./dist/utils/*.js",
|
|
31
|
-
"require": "./dist/utils/*.cjs"
|
|
32
|
-
},
|
|
33
|
-
"./state": {
|
|
34
|
-
"types": "./dist/state/index.d.ts",
|
|
35
|
-
"import": "./dist/state/index.js",
|
|
36
|
-
"require": "./dist/state/index.cjs",
|
|
37
|
-
"browser": "./dist/state.umd.js"
|
|
38
|
-
},
|
|
39
|
-
"./state/*": {
|
|
40
|
-
"types": "./dist/state/*.d.ts",
|
|
41
|
-
"import": "./dist/state/*.js",
|
|
42
|
-
"require": "./dist/state/*.cjs"
|
|
43
|
-
},
|
|
44
|
-
"./analytics": {
|
|
45
|
-
"types": "./dist/analytics/index.d.ts",
|
|
46
|
-
"import": "./dist/analytics/index.js",
|
|
47
|
-
"require": "./dist/analytics/index.cjs",
|
|
48
|
-
"browser": "./dist/analytics.umd.js"
|
|
49
|
-
},
|
|
50
|
-
"./analytics/*": {
|
|
51
|
-
"types": "./dist/analytics/*.d.ts",
|
|
52
|
-
"import": "./dist/analytics/*.js",
|
|
53
|
-
"require": "./dist/analytics/*.cjs"
|
|
54
|
-
},
|
|
55
|
-
"./library": {
|
|
56
|
-
"types": "./dist/library/index.d.ts",
|
|
57
|
-
"import": "./dist/library/index.js",
|
|
58
|
-
"require": "./dist/library/index.cjs"
|
|
59
|
-
},
|
|
60
|
-
"./library/*": {
|
|
61
|
-
"types": "./dist/library/*.d.ts",
|
|
62
|
-
"import": "./dist/library/*.js",
|
|
63
|
-
"require": "./dist/library/*.cjs"
|
|
64
|
-
},
|
|
65
|
-
"./components": {
|
|
66
|
-
"types": "./dist/components/index.d.ts",
|
|
67
|
-
"import": "./dist/components/index.js",
|
|
68
|
-
"require": "./dist/components/index.cjs"
|
|
69
|
-
},
|
|
70
|
-
"./components/*": {
|
|
71
|
-
"types": "./dist/components/*.d.ts",
|
|
72
|
-
"import": "./dist/components/*.js",
|
|
73
|
-
"require": "./dist/components/*.cjs"
|
|
23
|
+
"./i18n": {
|
|
24
|
+
"types": "./dist/i18n.d.ts",
|
|
25
|
+
"import": "./dist/i18n.js",
|
|
26
|
+
"require": "./dist/i18n.cjs"
|
|
74
27
|
},
|
|
75
28
|
"./kernel": {
|
|
76
29
|
"types": "./dist/kernel/index.d.ts",
|
|
@@ -86,44 +39,17 @@
|
|
|
86
39
|
},
|
|
87
40
|
"typesVersions": {
|
|
88
41
|
"*": {
|
|
89
|
-
"
|
|
90
|
-
"dist/
|
|
91
|
-
],
|
|
92
|
-
"core": [
|
|
93
|
-
"dist/core/index.d.ts"
|
|
94
|
-
],
|
|
95
|
-
"core/*": [
|
|
96
|
-
"dist/core/*.d.ts"
|
|
97
|
-
],
|
|
98
|
-
"utils": [
|
|
99
|
-
"dist/utils/index.d.ts"
|
|
100
|
-
],
|
|
101
|
-
"utils/*": [
|
|
102
|
-
"dist/utils/*.d.ts"
|
|
103
|
-
],
|
|
104
|
-
"state": [
|
|
105
|
-
"dist/state/index.d.ts"
|
|
106
|
-
],
|
|
107
|
-
"state/*": [
|
|
108
|
-
"dist/state/*.d.ts"
|
|
109
|
-
],
|
|
110
|
-
"analytics": [
|
|
111
|
-
"dist/analytics/index.d.ts"
|
|
112
|
-
],
|
|
113
|
-
"analytics/*": [
|
|
114
|
-
"dist/analytics/*.d.ts"
|
|
115
|
-
],
|
|
116
|
-
"library": [
|
|
117
|
-
"dist/library/index.d.ts"
|
|
42
|
+
"theme": [
|
|
43
|
+
"dist/theme.d.ts"
|
|
118
44
|
],
|
|
119
|
-
"
|
|
120
|
-
"dist/
|
|
45
|
+
"i18n": [
|
|
46
|
+
"dist/i18n.d.ts"
|
|
121
47
|
],
|
|
122
|
-
"
|
|
123
|
-
"dist/
|
|
48
|
+
"kernel": [
|
|
49
|
+
"dist/kernel/index.d.ts"
|
|
124
50
|
],
|
|
125
|
-
"
|
|
126
|
-
"dist/
|
|
51
|
+
"kernel/*": [
|
|
52
|
+
"dist/kernel/*.d.ts"
|
|
127
53
|
],
|
|
128
54
|
"*": [
|
|
129
55
|
"dist/*.d.ts"
|
|
@@ -135,17 +61,13 @@
|
|
|
135
61
|
"dist/index.d.ts",
|
|
136
62
|
"dist/index.js",
|
|
137
63
|
"dist/index.umd.js",
|
|
138
|
-
"dist/
|
|
139
|
-
"dist/
|
|
140
|
-
"dist/
|
|
141
|
-
"dist/
|
|
142
|
-
"dist/
|
|
143
|
-
"dist/
|
|
64
|
+
"dist/theme.cjs",
|
|
65
|
+
"dist/theme.d.ts",
|
|
66
|
+
"dist/theme.js",
|
|
67
|
+
"dist/i18n.cjs",
|
|
68
|
+
"dist/i18n.d.ts",
|
|
69
|
+
"dist/i18n.js",
|
|
144
70
|
"dist/kernel",
|
|
145
|
-
"dist/library",
|
|
146
|
-
"dist/state",
|
|
147
|
-
"dist/state.umd.js",
|
|
148
|
-
"dist/utils",
|
|
149
71
|
"README.md",
|
|
150
72
|
"LICENSE"
|
|
151
73
|
],
|
|
@@ -161,20 +83,15 @@
|
|
|
161
83
|
"clean": "rm -rf dist dist-temp",
|
|
162
84
|
"prepublishOnly": "npm run build && npm version patch --no-git-tag-version",
|
|
163
85
|
"publish:dry-run": "npm run prepublishOnly && npm publish --dry-run --access public",
|
|
164
|
-
"test": "vitest",
|
|
86
|
+
"test": "vitest --passWithNoTests",
|
|
165
87
|
"test:ui": "vitest --ui",
|
|
166
|
-
"test:run": "vitest run",
|
|
167
|
-
"test:coverage": "vitest run --coverage",
|
|
88
|
+
"test:run": "vitest run --passWithNoTests",
|
|
89
|
+
"test:coverage": "vitest run --coverage --passWithNoTests",
|
|
168
90
|
"lint": "eslint src --ext .ts,.tsx",
|
|
169
91
|
"format": "prettier --write \"src/**/*.{ts,tsx,json,md}\"",
|
|
170
|
-
"build:umd": "npm run build:umd:index
|
|
92
|
+
"build:umd": "npm run build:umd:index",
|
|
171
93
|
"build:umd:index": "UMD_TARGET=index rollup -c rollup.config.js",
|
|
172
|
-
"build:
|
|
173
|
-
"build:umd:analytics": "UMD_TARGET=analytics rollup -c rollup.config.js",
|
|
174
|
-
"build:prune": "rm -rf dist/core dist/core-bak dist/*.umd.cjs dist/*.umd.d.ts",
|
|
175
|
-
"docs:dev": "dumi dev",
|
|
176
|
-
"docs:build": "dumi build",
|
|
177
|
-
"docs:preview": "dumi preview"
|
|
94
|
+
"build:prune": "rm -rf dist/core dist/core-bak dist/*.umd.cjs dist/*.umd.d.ts"
|
|
178
95
|
},
|
|
179
96
|
"keywords": [
|
|
180
97
|
"framework",
|
|
@@ -203,37 +120,19 @@
|
|
|
203
120
|
"@types/react-dom": "^19.2.3",
|
|
204
121
|
"@vitest/coverage-v8": "4.0.16",
|
|
205
122
|
"@vitest/ui": "^4.0.16",
|
|
206
|
-
"antd": "^5.29.2",
|
|
207
|
-
"dumi": "^2.4.21",
|
|
208
123
|
"happy-dom": "^20.1.0",
|
|
209
124
|
"i18next": "^25.8.18",
|
|
210
125
|
"jsdom": "^27.4.0",
|
|
211
|
-
"react": "^19.2.3",
|
|
212
|
-
"react-dom": "^19.2.3",
|
|
213
|
-
"react-error-boundary": "^6.0.2",
|
|
214
|
-
"react-i18next": "^16.5.8",
|
|
215
|
-
"react-router-dom": "^7.12.0",
|
|
216
126
|
"rollup": "^4.55.1",
|
|
217
127
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
218
128
|
"typescript": "^5.9.3",
|
|
219
129
|
"vitest": "^4.0.16",
|
|
220
|
-
"@vlian/csrf": "workspace:*",
|
|
221
130
|
"@vlian/logger": "workspace:*",
|
|
222
|
-
"@vlian/monitoring": "workspace:*",
|
|
223
|
-
"@vlian/request": "workspace:*",
|
|
224
131
|
"@vlian/utils": "workspace:*"
|
|
225
132
|
},
|
|
226
133
|
"peerDependencies": {
|
|
227
134
|
"i18next": "^23.0.0 || ^24.0.0 || ^25.0.0",
|
|
228
|
-
"react": "^18.0.0 || ^19.0.0",
|
|
229
|
-
"react-dom": "^18.0.0 || ^19.0.0",
|
|
230
|
-
"react-i18next": "^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
231
|
-
"react-router-dom": "^7.0.0",
|
|
232
|
-
"react-error-boundary": "^6.0.0",
|
|
233
|
-
"@vlian/csrf": "^0.1.2",
|
|
234
135
|
"@vlian/logger": "^0.1.0",
|
|
235
|
-
"@vlian/monitoring": "^0.1.0",
|
|
236
|
-
"@vlian/request": "^0.1.0",
|
|
237
136
|
"@vlian/utils": "^2.0.1"
|
|
238
137
|
},
|
|
239
138
|
"dependencies": {
|
package/dist/analytics/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get AnalyticsService(){return _analytics.AnalyticsService},get getAnalytics(){return _analytics.getAnalytics},get initAnalytics(){return _analytics.initAnalytics}});const _analytics=require("../utils/analytics");
|
package/dist/analytics/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{AnalyticsService,initAnalytics,getAnalytics}from"../utils/analytics";
|
package/dist/analytics.umd.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* @vlian/framework v1.2.62
|
|
3
|
-
* Secra Framework - 一个现代化的低代码框架
|
|
4
|
-
* (c) 2026 Secra Framework Contributors
|
|
5
|
-
* Licensed under Apache-2.0
|
|
6
|
-
*/
|
|
7
|
-
(function (global, factory) {
|
|
8
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@vlian/utils'), require('@vlian/logger')) :
|
|
9
|
-
typeof define === 'function' && define.amd ? define(['exports', '@vlian/utils', '@vlian/logger'], factory) :
|
|
10
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.vlianFrameworkAnalytics = {}, global.VlianUtils, global.VlianLogger));
|
|
11
|
-
})(this, (function (exports, utils, logger) { 'use strict';
|
|
12
|
-
|
|
13
|
-
function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else {obj[key]=value;}return obj}class AnalyticsService{startBatchTimer(){if(this.batchTimer){return}this.batchTimer=setInterval(()=>{this.flush();},this.config.batchInterval);}stopBatchTimer(){if(this.batchTimer){clearInterval(this.batchTimer);this.batchTimer=null;}}track(event){if(!this.config.enabled){return}if(Math.random()>this.config.sampleRate){return}const anonymizedEvent={...event,timestamp:Date.now(),properties:this.anonymizeProperties(event.properties)};this.eventQueue.push(anonymizedEvent);if(this.config.onEvent){this.config.onEvent(anonymizedEvent);}if(this.eventQueue.length>=this.config.batchSize){this.flush();}}trackPageView(page,properties){this.track({type:"pageview",name:"page_view",properties:{page,...properties}});}trackClick(element,properties){this.track({type:"click",name:"click",properties:{element,...properties}});}trackCustom(name,properties){this.track({type:"custom",name,properties});}trackError(error,properties){this.track({type:"error",name:"error",properties:{errorName:error.name,errorMessage:error.message,errorStack:error.stack,...properties}});}trackPerformance(metrics,properties){this.track({type:"performance",name:"performance",properties:{...metrics,...properties}});}anonymizeProperties(properties){if(!this.config.anonymize||!properties){return properties}return utils.SecurityUtils.deepSanitize(properties)}flush(){if(this.eventQueue.length===0){return}const events=[...this.eventQueue];this.eventQueue=[];if(this.config.onBatch){this.config.onBatch(events);}logger.logger.debug(`分析服务批量上报 ${events.length} 个事件`);}enable(){this.config.enabled=true;this.startBatchTimer();}disable(){this.config.enabled=false;this.stopBatchTimer();this.flush();}destroy(){this.stopBatchTimer();this.flush();}constructor(config={}){_define_property(this,"config",void 0);_define_property(this,"eventQueue",[]);_define_property(this,"batchTimer",null);this.config={enabled:config.enabled??true,sampleRate:config.sampleRate??1,anonymize:config.anonymize??true,onEvent:config.onEvent??(()=>{}),onBatch:config.onBatch??(()=>{}),batchSize:config.batchSize??10,batchInterval:config.batchInterval??5e3};if(this.config.enabled){this.startBatchTimer();}}}let defaultAnalyticsService=null;function initAnalytics(config){if(!defaultAnalyticsService){defaultAnalyticsService=new AnalyticsService(config);}return defaultAnalyticsService}function getAnalytics(){if(!defaultAnalyticsService){return initAnalytics()}return defaultAnalyticsService}
|
|
14
|
-
|
|
15
|
-
exports.AnalyticsService = AnalyticsService;
|
|
16
|
-
exports.getAnalytics = getAnalytics;
|
|
17
|
-
exports.initAnalytics = initAnalytics;
|
|
18
|
-
|
|
19
|
-
}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type { PersistenceOptions, StorageLike } from './persistence';
|
package/dist/components/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get readPersistedValue(){return readPersistedValue},get resolveStorage(){return resolveStorage},get writePersistedValue(){return writePersistedValue}});function resolveStorage(storage){if(storage){return storage}if(typeof window==="undefined"||!window.localStorage){return null}return window.localStorage}function readPersistedValue(options,defaultKey){if(options.enabled===false){return null}const targetStorage=resolveStorage(options.storage);if(!targetStorage){return null}try{return targetStorage.getItem(options.key||defaultKey)}catch{return null}}function writePersistedValue(value,options,defaultKey){if(options.enabled===false||!value){return}const targetStorage=resolveStorage(options.storage);if(!targetStorage){return}try{targetStorage.setItem(options.key||defaultKey,value)}catch{}}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface StorageLike {
|
|
2
|
-
getItem(key: string): string | null;
|
|
3
|
-
setItem(key: string, value: string): void;
|
|
4
|
-
}
|
|
5
|
-
export interface PersistenceOptions {
|
|
6
|
-
enabled?: boolean;
|
|
7
|
-
key?: string;
|
|
8
|
-
storage?: StorageLike;
|
|
9
|
-
}
|
|
10
|
-
export declare function resolveStorage(storage?: StorageLike): StorageLike | null;
|
|
11
|
-
export declare function readPersistedValue(options: PersistenceOptions, defaultKey: string): string | null;
|
|
12
|
-
export declare function writePersistedValue(value: string | undefined, options: PersistenceOptions, defaultKey: string): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function resolveStorage(storage){if(storage){return storage}if(typeof window==="undefined"||!window.localStorage){return null}return window.localStorage}export function readPersistedValue(options,defaultKey){if(options.enabled===false){return null}const targetStorage=resolveStorage(options.storage);if(!targetStorage){return null}try{return targetStorage.getItem(options.key||defaultKey)}catch{return null}}export function writePersistedValue(value,options,defaultKey){if(options.enabled===false||!value){return}const targetStorage=resolveStorage(options.storage);if(!targetStorage){return}try{targetStorage.setItem(options.key||defaultKey,value)}catch{}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"I18nManager",{enumerable:true,get:function(){return I18nManager}});const _library=require("../../../library");const _constants=require("../../constants");const _i18npersistence=require("./i18n.persistence");const _i18nschema=require("./i18n.schema");function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}let I18nManager=class I18nManager{async initialize(context){this.config=context.config.i18n;this.cacheManager=context.cacheManager;const initialSnapshot=(0,_i18nschema.normalizeI18nSnapshot)(this.config.initial||{},_constants.DEFAULT_I18N);this.snapshot=await (0,_i18npersistence.loadI18nFromCache)(this.cacheManager,this.config.persistence,initialSnapshot);await (0,_library.setupI18n)({interpolation:{escapeValue:false},lng:this.snapshot.locale||"zh-CN",resources:this.snapshot.resources});await (0,_library.setLang)(this.snapshot.locale);this.initialized=true}getSnapshot(){return(0,_i18nschema.cloneI18nSnapshot)(this.snapshot)}subscribe(listener){this.listeners.add(listener);return()=>{this.listeners.delete(listener)}}async setLocale(locale){this.ensureInitialized();const prevSnapshot=this.snapshot;const nextSnapshot=(0,_i18nschema.mergeI18nSnapshot)(prevSnapshot,{locale});if((0,_i18nschema.isI18nEqual)(prevSnapshot,nextSnapshot)){return}this.snapshot=nextSnapshot;await (0,_library.setLang)(this.snapshot.locale);if(this.cacheManager){await (0,_i18npersistence.saveI18nToCache)(this.cacheManager,this.config.persistence,this.snapshot)}this.emit(this.snapshot,prevSnapshot)}ensureInitialized(){if(!this.initialized){throw new Error("I18nManager must be initialized before use.")}}emit(next,prev){for(const listener of this.listeners){try{listener((0,_i18nschema.cloneI18nSnapshot)(next),(0,_i18nschema.cloneI18nSnapshot)(prev))}catch{}}}constructor(){_define_property(this,"snapshot",(0,_i18nschema.cloneI18nSnapshot)(_constants.DEFAULT_I18N));_define_property(this,"config",_constants.DEFAULT_CONFIG.i18n);_define_property(this,"listeners",new Set);_define_property(this,"cacheManager",null);_define_property(this,"initialized",false)}};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}import{setupI18n,setLang}from"../../../library";import{DEFAULT_CONFIG,DEFAULT_I18N}from"../../constants";import{loadI18nFromCache,saveI18nToCache}from"./i18n.persistence";import{cloneI18nSnapshot,isI18nEqual,mergeI18nSnapshot,normalizeI18nSnapshot}from"./i18n.schema";export class I18nManager{async initialize(context){this.config=context.config.i18n;this.cacheManager=context.cacheManager;const initialSnapshot=normalizeI18nSnapshot(this.config.initial||{},DEFAULT_I18N);this.snapshot=await loadI18nFromCache(this.cacheManager,this.config.persistence,initialSnapshot);await setupI18n({interpolation:{escapeValue:false},lng:this.snapshot.locale||"zh-CN",resources:this.snapshot.resources});await setLang(this.snapshot.locale);this.initialized=true}getSnapshot(){return cloneI18nSnapshot(this.snapshot)}subscribe(listener){this.listeners.add(listener);return()=>{this.listeners.delete(listener)}}async setLocale(locale){this.ensureInitialized();const prevSnapshot=this.snapshot;const nextSnapshot=mergeI18nSnapshot(prevSnapshot,{locale});if(isI18nEqual(prevSnapshot,nextSnapshot)){return}this.snapshot=nextSnapshot;await setLang(this.snapshot.locale);if(this.cacheManager){await saveI18nToCache(this.cacheManager,this.config.persistence,this.snapshot)}this.emit(this.snapshot,prevSnapshot)}ensureInitialized(){if(!this.initialized){throw new Error("I18nManager must be initialized before use.")}}emit(next,prev){for(const listener of this.listeners){try{listener(cloneI18nSnapshot(next),cloneI18nSnapshot(prev))}catch{}}}constructor(){_define_property(this,"snapshot",cloneI18nSnapshot(DEFAULT_I18N));_define_property(this,"config",DEFAULT_CONFIG.i18n);_define_property(this,"listeners",new Set);_define_property(this,"cacheManager",null);_define_property(this,"initialized",false)}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function isPlainObject(value){return Object.prototype.toString.call(value)==="[object Object]"}export function cloneI18nSnapshot(snapshot){const resources=snapshot.resources?Object.fromEntries(Object.entries(snapshot.resources).map(([locale,value])=>[locale,{...value}])):undefined;return{locale:snapshot.locale,...resources?{resources}:{}}}export function normalizeI18nSnapshot(value,fallback){const source=isPlainObject(value)?value:{};const locale=typeof source.locale==="string"&&source.locale.trim()?source.locale:fallback.locale;const fallbackResources=fallback.resources;const incomingResources=isPlainObject(source.resources)?Object.fromEntries(Object.entries(source.resources).filter(([,resourceValue])=>isPlainObject(resourceValue)).map(([locale,resourceValue])=>[locale,{...resourceValue}])):undefined;const resources=incomingResources||fallbackResources?{...fallbackResources||{},...incomingResources||{}}:undefined;return{locale,...resources?{resources}:{}}}export function mergeI18nSnapshot(current,next){return normalizeI18nSnapshot({locale:next.locale??current.locale,resources:next.resources??current.resources},current)}export function isI18nEqual(left,right){if(left.locale!==right.locale){return false}const leftResources=left.resources||{};const rightResources=right.resources||{};const leftLocales=Object.keys(leftResources);const rightLocales=Object.keys(rightResources);if(leftLocales.length!==rightLocales.length){return false}for(const locale of leftLocales){if(leftResources[locale]!==rightResources[locale]){return false}}return true}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"I18nManager",{enumerable:true,get:function(){return _I18nManager.I18nManager}});const _I18nManager=require("./I18nManager");
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { I18nManager } from './I18nManager';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{I18nManager}from"./I18nManager";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"I18nManager",{enumerable:true,get:function(){return _i18n.I18nManager}});const _i18n=require("./i18n");
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { I18nManager } from './i18n';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{I18nManager}from"./i18n";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"ThemeManager",{enumerable:true,get:function(){return ThemeManager}});const _constants=require("../../constants");const _themedom=require("./theme.dom");const _themepersistence=require("./theme.persistence");const _themeschema=require("./theme.schema");function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}let ThemeManager=class ThemeManager{async initialize(context){this.config=context.config.theme;this.cacheManager=context.cacheManager;const initialTheme=(0,_themeschema.normalizeTheme)(this.config.initial||{},_constants.DEFAULT_THEME);this.theme=await (0,_themepersistence.loadThemeFromCache)(this.cacheManager,this.config.persistence,initialTheme);(0,_themedom.applyThemeToDocument)(this.theme);this.initialized=true}getTheme(){return(0,_themeschema.cloneTheme)(this.theme)}getSnapshot(){return this.getTheme()}subscribe(listener){this.listeners.add(listener);return()=>{this.listeners.delete(listener)}}async setTheme(nextTheme){this.ensureInitialized();const prevTheme=this.theme;const mergedTheme=(0,_themeschema.mergeTheme)(prevTheme,nextTheme);if((0,_themeschema.isThemeEqual)(prevTheme,mergedTheme)){return}this.theme=mergedTheme;(0,_themedom.applyThemeToDocument)(this.theme,prevTheme);if(this.cacheManager){await (0,_themepersistence.saveThemeToCache)(this.cacheManager,this.config.persistence,this.theme)}this.emit(this.theme,prevTheme)}ensureInitialized(){if(!this.initialized){throw new Error("ThemeManager must be initialized before use.")}}emit(next,prev){for(const listener of this.listeners){try{listener((0,_themeschema.cloneTheme)(next),(0,_themeschema.cloneTheme)(prev))}catch{}}}constructor(){_define_property(this,"theme",(0,_themeschema.cloneTheme)(_constants.DEFAULT_THEME));_define_property(this,"config",_constants.DEFAULT_CONFIG.theme);_define_property(this,"listeners",new Set);_define_property(this,"cacheManager",null);_define_property(this,"initialized",false)}};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}import{DEFAULT_CONFIG,DEFAULT_THEME}from"../../constants";import{applyThemeToDocument}from"./theme.dom";import{loadThemeFromCache,saveThemeToCache}from"./theme.persistence";import{cloneTheme,isThemeEqual,mergeTheme,normalizeTheme}from"./theme.schema";export class ThemeManager{async initialize(context){this.config=context.config.theme;this.cacheManager=context.cacheManager;const initialTheme=normalizeTheme(this.config.initial||{},DEFAULT_THEME);this.theme=await loadThemeFromCache(this.cacheManager,this.config.persistence,initialTheme);applyThemeToDocument(this.theme);this.initialized=true}getTheme(){return cloneTheme(this.theme)}getSnapshot(){return this.getTheme()}subscribe(listener){this.listeners.add(listener);return()=>{this.listeners.delete(listener)}}async setTheme(nextTheme){this.ensureInitialized();const prevTheme=this.theme;const mergedTheme=mergeTheme(prevTheme,nextTheme);if(isThemeEqual(prevTheme,mergedTheme)){return}this.theme=mergedTheme;applyThemeToDocument(this.theme,prevTheme);if(this.cacheManager){await saveThemeToCache(this.cacheManager,this.config.persistence,this.theme)}this.emit(this.theme,prevTheme)}ensureInitialized(){if(!this.initialized){throw new Error("ThemeManager must be initialized before use.")}}emit(next,prev){for(const listener of this.listeners){try{listener(cloneTheme(next),cloneTheme(prev))}catch{}}}constructor(){_define_property(this,"theme",cloneTheme(DEFAULT_THEME));_define_property(this,"config",DEFAULT_CONFIG.theme);_define_property(this,"listeners",new Set);_define_property(this,"cacheManager",null);_define_property(this,"initialized",false)}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"ThemeManager",{enumerable:true,get:function(){return _ThemeManager.ThemeManager}});const _ThemeManager=require("./ThemeManager");
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ThemeManager } from './ThemeManager';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{ThemeManager}from"./ThemeManager";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get applyThemeToDocument(){return applyThemeToDocument},get resolveThemeMode(){return resolveThemeMode}});function canUseDom(){return typeof document!=="undefined"}function resolveThemeMode(theme){if(theme.mode!=="system"){return theme.mode}if(typeof window!=="undefined"&&window.matchMedia("(prefers-color-scheme: dark)").matches){return"dark"}return"light"}function applyThemeToDocument(nextTheme,prevTheme){if(!canUseDom()){return}const root=document.documentElement;const nextMode=resolveThemeMode(nextTheme);const prevMode=prevTheme?resolveThemeMode(prevTheme):undefined;if(!prevMode||prevMode!==nextMode){root.classList.remove("light","dark");root.classList.add(nextMode)}if(!prevTheme||prevTheme.primaryColor!==nextTheme.primaryColor){if(nextTheme.primaryColor){root.style.setProperty("--app-primary-color",nextTheme.primaryColor)}else{root.style.removeProperty("--app-primary-color")}}const prevTokens=prevTheme?.tokens||{};const nextTokens=nextTheme.tokens||{};for(const token of Object.keys(prevTokens)){if(!(token in nextTokens)){root.style.removeProperty(`--${token}`)}}for(const[token,value]of Object.entries(nextTokens)){if(!prevTheme||prevTokens[token]!==value){root.style.setProperty(`--${token}`,String(value))}}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function canUseDom(){return typeof document!=="undefined"}export function resolveThemeMode(theme){if(theme.mode!=="system"){return theme.mode}if(typeof window!=="undefined"&&window.matchMedia("(prefers-color-scheme: dark)").matches){return"dark"}return"light"}export function applyThemeToDocument(nextTheme,prevTheme){if(!canUseDom()){return}const root=document.documentElement;const nextMode=resolveThemeMode(nextTheme);const prevMode=prevTheme?resolveThemeMode(prevTheme):undefined;if(!prevMode||prevMode!==nextMode){root.classList.remove("light","dark");root.classList.add(nextMode)}if(!prevTheme||prevTheme.primaryColor!==nextTheme.primaryColor){if(nextTheme.primaryColor){root.style.setProperty("--app-primary-color",nextTheme.primaryColor)}else{root.style.removeProperty("--app-primary-color")}}const prevTokens=prevTheme?.tokens||{};const nextTokens=nextTheme.tokens||{};for(const token of Object.keys(prevTokens)){if(!(token in nextTokens)){root.style.removeProperty(`--${token}`)}}for(const[token,value]of Object.entries(nextTokens)){if(!prevTheme||prevTokens[token]!==value){root.style.setProperty(`--${token}`,String(value))}}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get cloneTheme(){return cloneTheme},get isThemeEqual(){return isThemeEqual},get mergeTheme(){return mergeTheme},get normalizeTheme(){return normalizeTheme},get sanitizeTokens(){return sanitizeTokens}});const VALID_THEME_MODES=new Set(["light","dark","system"]);const TOKEN_NAME_PATTERN=/^[A-Za-z_][A-Za-z0-9_-]*$/;function isPlainObject(value){return Object.prototype.toString.call(value)==="[object Object]"}function hasOwnProperty(value,key){return Object.prototype.hasOwnProperty.call(value,key)}function cloneTheme(theme){return{...theme,...theme.tokens?{tokens:{...theme.tokens}}:{}}}function sanitizeTokens(tokens){if(!isPlainObject(tokens)){return undefined}const sanitizedTokens={};for(const[token,tokenValue]of Object.entries(tokens)){if(!TOKEN_NAME_PATTERN.test(token)){continue}if(typeof tokenValue==="string"||typeof tokenValue==="number"){sanitizedTokens[token]=tokenValue}}return Object.keys(sanitizedTokens).length>0?sanitizedTokens:undefined}function normalizeTheme(value,fallback){const source=isPlainObject(value)?value:{};const mode=VALID_THEME_MODES.has(source.mode)?source.mode:fallback.mode;const primaryColor=typeof source.primaryColor==="string"&&source.primaryColor.trim()?source.primaryColor:fallback.primaryColor;const fallbackTokens=sanitizeTokens(fallback.tokens);const incomingTokens=sanitizeTokens(source.tokens);return{mode,...primaryColor?{primaryColor}:{},...incomingTokens||fallbackTokens?{tokens:{...fallbackTokens||{},...incomingTokens||{}}}:{}}}function mergeTheme(current,next){const mergedTheme={mode:hasOwnProperty(next,"mode")&&VALID_THEME_MODES.has(next.mode)?next.mode:current.mode,...hasOwnProperty(next,"primaryColor")?typeof next.primaryColor==="string"&&next.primaryColor.trim()?{primaryColor:next.primaryColor}:{}:current.primaryColor?{primaryColor:current.primaryColor}:{},...hasOwnProperty(next,"tokens")?sanitizeTokens(next.tokens)?{tokens:sanitizeTokens(next.tokens)}:{}:current.tokens?{tokens:{...current.tokens}}:{}};return normalizeTheme(mergedTheme,DEFAULT_EMPTY_THEME)}const DEFAULT_EMPTY_THEME={mode:"light"};function isThemeEqual(left,right){if(left.mode!==right.mode||left.primaryColor!==right.primaryColor){return false}const leftTokens=left.tokens||{};const rightTokens=right.tokens||{};const leftKeys=Object.keys(leftTokens);const rightKeys=Object.keys(rightTokens);if(leftKeys.length!==rightKeys.length){return false}for(const key of leftKeys){if(leftTokens[key]!==rightTokens[key]){return false}}return true}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const VALID_THEME_MODES=new Set(["light","dark","system"]);const TOKEN_NAME_PATTERN=/^[A-Za-z_][A-Za-z0-9_-]*$/;function isPlainObject(value){return Object.prototype.toString.call(value)==="[object Object]"}function hasOwnProperty(value,key){return Object.prototype.hasOwnProperty.call(value,key)}export function cloneTheme(theme){return{...theme,...theme.tokens?{tokens:{...theme.tokens}}:{}}}export function sanitizeTokens(tokens){if(!isPlainObject(tokens)){return undefined}const sanitizedTokens={};for(const[token,tokenValue]of Object.entries(tokens)){if(!TOKEN_NAME_PATTERN.test(token)){continue}if(typeof tokenValue==="string"||typeof tokenValue==="number"){sanitizedTokens[token]=tokenValue}}return Object.keys(sanitizedTokens).length>0?sanitizedTokens:undefined}export function normalizeTheme(value,fallback){const source=isPlainObject(value)?value:{};const mode=VALID_THEME_MODES.has(source.mode)?source.mode:fallback.mode;const primaryColor=typeof source.primaryColor==="string"&&source.primaryColor.trim()?source.primaryColor:fallback.primaryColor;const fallbackTokens=sanitizeTokens(fallback.tokens);const incomingTokens=sanitizeTokens(source.tokens);return{mode,...primaryColor?{primaryColor}:{},...incomingTokens||fallbackTokens?{tokens:{...fallbackTokens||{},...incomingTokens||{}}}:{}}}export function mergeTheme(current,next){const mergedTheme={mode:hasOwnProperty(next,"mode")&&VALID_THEME_MODES.has(next.mode)?next.mode:current.mode,...hasOwnProperty(next,"primaryColor")?typeof next.primaryColor==="string"&&next.primaryColor.trim()?{primaryColor:next.primaryColor}:{}:current.primaryColor?{primaryColor:current.primaryColor}:{},...hasOwnProperty(next,"tokens")?sanitizeTokens(next.tokens)?{tokens:sanitizeTokens(next.tokens)}:{}:current.tokens?{tokens:{...current.tokens}}:{}};return normalizeTheme(mergedTheme,DEFAULT_EMPTY_THEME)}const DEFAULT_EMPTY_THEME={mode:"light"};export function isThemeEqual(left,right){if(left.mode!==right.mode||left.primaryColor!==right.primaryColor){return false}const leftTokens=left.tokens||{};const rightTokens=right.tokens||{};const leftKeys=Object.keys(leftTokens);const rightKeys=Object.keys(rightTokens);if(leftKeys.length!==rightKeys.length){return false}for(const key of leftKeys){if(leftTokens[key]!==rightTokens[key]){return false}}return true}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"ThemeManager",{enumerable:true,get:function(){return _theme.ThemeManager}});const _theme=require("./theme");
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ThemeManager } from './theme';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{ThemeManager}from"./theme";
|
package/dist/library/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});_export_star(require("./locale/index"),exports);_export_star(require("./storage/index"),exports);function _export_star(from,to){Object.keys(from).forEach(function(k){if(k!=="default"&&!Object.prototype.hasOwnProperty.call(to,k)){Object.defineProperty(to,k,{enumerable:true,get:function(){return from[k]}})}});return from}
|
package/dist/library/index.d.ts
DELETED
package/dist/library/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export*from"./locale/index";export*from"./storage/index";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _export(target,all){for(var name in all)Object.defineProperty(target,name,{enumerable:true,get:Object.getOwnPropertyDescriptor(all,name).get})}_export(exports,{get $t(){return $t},get reactI18nextInstance(){return reactI18nextInstance},get setLang(){return setLang},get setupI18n(){return setupI18n}});const _i18next=/*#__PURE__*/_interop_require_default(require("i18next"));const _reacti18next=require("react-i18next");function _interop_require_default(obj){return obj&&obj.__esModule?obj:{default:obj}}const reactI18nextInstance=_i18next.default.use(_reacti18next.initReactI18next);async function setupI18n(options,callback){await reactI18nextInstance.init(options,callback)}const $t=_i18next.default.t;async function setLang(locale,callback){await _i18next.default.changeLanguage(locale,callback)}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Callback, InitOptions } from "i18next";
|
|
2
|
-
export declare const reactI18nextInstance: import("i18next").i18n;
|
|
3
|
-
/** Setup plugin i18n */
|
|
4
|
-
export declare function setupI18n<T = unknown>(options: InitOptions<T>, callback?: Callback): Promise<void>;
|
|
5
|
-
export declare const $t: import("i18next").TFunction<["translation", ...string[]], undefined>;
|
|
6
|
-
export declare function setLang(locale: string, callback?: Callback): Promise<void>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import i18n from"i18next";import{initReactI18next}from"react-i18next";export const reactI18nextInstance=i18n.use(initReactI18next);export async function setupI18n(options,callback){await reactI18nextInstance.init(options,callback)}export const $t=i18n.t;export async function setLang(locale,callback){await i18n.changeLanguage(locale,callback)}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"default",{enumerable:true,get:function(){return _default}});const local={notfound:{home:"Back to Home"},defaultApp:{title:"Welcome to Secra Framework",description:"Framework has been successfully started! Please provide your app component to get started.",quickStart:{title:"Quick Start",description:"Provide the app option in your startup configuration to render your application:",code:"import { start } from '@vlian/framework';\nimport App from './App';\n\nstart({\n app: <App />,\n});"},nextSteps:{title:"Next Steps",step1:"Create your application root component (e.g., App.tsx)",step2:"Pass the app option in your startup configuration",step3:"Start developing your application features"},footer:"Secra Framework - Modern Low-Code Frontend Application Framework"}};const _default=local;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const local={notfound:{home:"Back to Home"},defaultApp:{title:"Welcome to Secra Framework",description:"Framework has been successfully started! Please provide your app component to get started.",quickStart:{title:"Quick Start",description:"Provide the app option in your startup configuration to render your application:",code:"import { start } from '@vlian/framework';\nimport App from './App';\n\nstart({\n app: <App />,\n});"},nextSteps:{title:"Next Steps",step1:"Create your application root component (e.g., App.tsx)",step2:"Pass the app option in your startup configuration",step3:"Start developing your application features"},footer:"Secra Framework - Modern Low-Code Frontend Application Framework"}};export default local;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"default",{enumerable:true,get:function(){return _default}});const local={notfound:{home:"回到首页"},defaultApp:{title:"欢迎使用 Secra Framework",description:"框架已成功启动!请提供您的应用组件以开始使用。",quickStart:{title:"快速开始",description:"在启动配置中提供 app 选项来渲染您的应用:",code:"import { start } from '@vlian/framework';\nimport App from './App';\n\nstart({\n app: <App />,\n});"},nextSteps:{title:"下一步",step1:"创建您的应用根组件(如 App.tsx)",step2:"在启动配置中传入 app 选项",step3:"开始开发您的应用功能"},footer:"Secra Framework - 现代化的低代码前端应用框架"}};const _default=local;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const local={notfound:{home:"回到首页"},defaultApp:{title:"欢迎使用 Secra Framework",description:"框架已成功启动!请提供您的应用组件以开始使用。",quickStart:{title:"快速开始",description:"在启动配置中提供 app 选项来渲染您的应用:",code:"import { start } from '@vlian/framework';\nimport App from './App';\n\nstart({\n app: <App />,\n});"},nextSteps:{title:"下一步",step1:"创建您的应用根组件(如 App.tsx)",step2:"在启动配置中传入 app 选项",step3:"开始开发您的应用功能"},footer:"Secra Framework - 现代化的低代码前端应用框架"}};export default local;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export type LangType = 'en-US' | 'zh-CN';
|
|
2
|
-
export type Schema = {
|
|
3
|
-
translation: {
|
|
4
|
-
notfound: {
|
|
5
|
-
home: string;
|
|
6
|
-
};
|
|
7
|
-
defaultApp: {
|
|
8
|
-
title: string;
|
|
9
|
-
description: string;
|
|
10
|
-
quickStart: {
|
|
11
|
-
title: string;
|
|
12
|
-
description: string;
|
|
13
|
-
code: string;
|
|
14
|
-
};
|
|
15
|
-
nextSteps: {
|
|
16
|
-
title: string;
|
|
17
|
-
step1: string;
|
|
18
|
-
step2: string;
|
|
19
|
-
step3: string;
|
|
20
|
-
};
|
|
21
|
-
footer: string;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
export type GetI18nKey<T extends Record<string, unknown>, K extends keyof T = keyof T> = K extends string ? T[K] extends Record<string, unknown> ? `${K}.${GetI18nKey<T[K]>}` : K : never;
|
|
26
|
-
export type I18nKey = GetI18nKey<Schema['translation']>;
|
|
27
|
-
export type TranslateOptions<Locales extends string> = import('react-i18next').TranslationProps<Locales>;
|
|
28
|
-
export interface $T {
|
|
29
|
-
(key: I18nKey): string;
|
|
30
|
-
(key: I18nKey, plural: number, options?: TranslateOptions<LangType>): string;
|
|
31
|
-
(key: I18nKey, defaultMsg: string, options?: TranslateOptions<I18nKey>): string;
|
|
32
|
-
(key: I18nKey, list: unknown[], options?: TranslateOptions<I18nKey>): string;
|
|
33
|
-
(key: I18nKey, list: unknown[], plural: number): string;
|
|
34
|
-
(key: I18nKey, list: unknown[], defaultMsg: string): string;
|
|
35
|
-
(key: I18nKey, named: Record<string, unknown>, options?: TranslateOptions<LangType>): string;
|
|
36
|
-
(key: I18nKey, named: Record<string, unknown>, plural: number): string;
|
|
37
|
-
(key: I18nKey, named: Record<string, unknown>, defaultMsg: string): string;
|
|
38
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"MultiLevelCache",{enumerable:true,get:function(){return MultiLevelCache}});function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}let MultiLevelCache=class MultiLevelCache{moveToHead(node){const nodeAsUnknown=node;if(nodeAsUnknown===this.head){return}if(node.prev){node.prev.next=node.next}if(node.next){node.next.prev=node.prev}if(nodeAsUnknown===this.tail){this.tail=node.prev}node.prev=null;node.next=this.head;if(this.head){this.head.prev=nodeAsUnknown}this.head=nodeAsUnknown;if(!this.tail){this.tail=nodeAsUnknown}}removeTail(){if(!this.tail){return}const key=this.tail.key;this.memoryCache.delete(key);if(this.tail.prev){this.tail.prev.next=null;this.tail=this.tail.prev}else{this.head=null;this.tail=null}}async get(key){const node=this.memoryCache.get(key);if(node){const item=node.value;if(item.expiresAt>Date.now()){this.moveToHead(node);return item.data}else{this.memoryCache.delete(key);if(node===this.head){this.head=node.next}if(node===this.tail){this.tail=node.prev}if(node.prev){node.prev.next=node.next}if(node.next){node.next.prev=node.prev}}}try{const stored=await this.storage.get(key);if(stored){const item=JSON.parse(stored);if(item.expiresAt>Date.now()){this.setInMemory(key,item);return item.data}else{await this.storage.remove(key)}}}catch(error){}return null}setInMemory(key,item){let node=this.memoryCache.get(key);if(node){node.value=item;this.moveToHead(node)}else{node={key,value:item,prev:null,next:this.head};if(this.head){this.head.prev=node}this.head=node;if(!this.tail){this.tail=node}this.memoryCache.set(key,node);if(this.memoryCache.size>this.config.maxSize){this.removeTail()}}}async set(key,data,ttl){const expiresAt=Date.now()+(ttl||this.config.defaultTTL);const item={data,expiresAt,createdAt:Date.now()};this.setInMemory(key,item);try{await this.storage.set(key,item)}catch(error){}}async delete(key){const node=this.memoryCache.get(key);if(node){if(node.prev){node.prev.next=node.next}if(node.next){node.next.prev=node.prev}if(node===this.head){this.head=node.next}if(node===this.tail){this.tail=node.prev}this.memoryCache.delete(key)}try{await this.storage.remove(key)}catch(error){}}async clear(){this.memoryCache.clear()}async cleanup(){const now=Date.now();const keysToDelete=[];const nodesToRemove=[];for(const[key,node]of this.memoryCache.entries()){if(node.value.expiresAt<=now){keysToDelete.push(key);nodesToRemove.push(node)}}if(keysToDelete.length>0){for(const node of nodesToRemove){if(node.prev){node.prev.next=node.next}if(node.next){node.next.prev=node.prev}if(node===this.head){this.head=node.next}if(node===this.tail){this.tail=node.prev}}keysToDelete.forEach(key=>this.memoryCache.delete(key))}}constructor(storage,config={}){_define_property(this,"memoryCache",new Map);_define_property(this,"storage",void 0);_define_property(this,"config",void 0);_define_property(this,"head",null);_define_property(this,"tail",null);this.storage=storage;this.config={defaultTTL:config.defaultTTL??24*60*60*1e3,maxSize:config.maxSize??100}}};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { StorageInstance } from '@vlian/utils';
|
|
2
|
-
/**
|
|
3
|
-
* 缓存配置
|
|
4
|
-
*/
|
|
5
|
-
export interface CacheConfig {
|
|
6
|
-
/**
|
|
7
|
-
* 默认过期时间(毫秒)
|
|
8
|
-
*/
|
|
9
|
-
defaultTTL?: number;
|
|
10
|
-
/**
|
|
11
|
-
* 最大缓存项数量
|
|
12
|
-
*/
|
|
13
|
-
maxSize?: number;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* 多级缓存管理器(使用 LRU 策略)
|
|
17
|
-
*/
|
|
18
|
-
export declare class MultiLevelCache {
|
|
19
|
-
private memoryCache;
|
|
20
|
-
private storage;
|
|
21
|
-
private config;
|
|
22
|
-
private head;
|
|
23
|
-
private tail;
|
|
24
|
-
constructor(storage: StorageInstance, config?: CacheConfig);
|
|
25
|
-
/**
|
|
26
|
-
* 将节点移到链表头部(最近使用)
|
|
27
|
-
*/
|
|
28
|
-
private moveToHead;
|
|
29
|
-
/**
|
|
30
|
-
* 移除尾部节点(最久未使用)
|
|
31
|
-
*/
|
|
32
|
-
private removeTail;
|
|
33
|
-
/**
|
|
34
|
-
* 获取缓存
|
|
35
|
-
*/
|
|
36
|
-
get<T>(key: string): Promise<T | null>;
|
|
37
|
-
/**
|
|
38
|
-
* 在内存中设置缓存(LRU)
|
|
39
|
-
*/
|
|
40
|
-
private setInMemory;
|
|
41
|
-
/**
|
|
42
|
-
* 设置缓存
|
|
43
|
-
*/
|
|
44
|
-
set<T>(key: string, data: T, ttl?: number): Promise<void>;
|
|
45
|
-
/**
|
|
46
|
-
* 删除缓存
|
|
47
|
-
*/
|
|
48
|
-
delete(key: string): Promise<void>;
|
|
49
|
-
/**
|
|
50
|
-
* 清空缓存
|
|
51
|
-
*/
|
|
52
|
-
clear(): Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* 清理过期项(优化版本:批量删除,减少 DOM 操作)
|
|
55
|
-
*/
|
|
56
|
-
cleanup(): Promise<void>;
|
|
57
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function _define_property(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}export class MultiLevelCache{moveToHead(node){const nodeAsUnknown=node;if(nodeAsUnknown===this.head){return}if(node.prev){node.prev.next=node.next}if(node.next){node.next.prev=node.prev}if(nodeAsUnknown===this.tail){this.tail=node.prev}node.prev=null;node.next=this.head;if(this.head){this.head.prev=nodeAsUnknown}this.head=nodeAsUnknown;if(!this.tail){this.tail=nodeAsUnknown}}removeTail(){if(!this.tail){return}const key=this.tail.key;this.memoryCache.delete(key);if(this.tail.prev){this.tail.prev.next=null;this.tail=this.tail.prev}else{this.head=null;this.tail=null}}async get(key){const node=this.memoryCache.get(key);if(node){const item=node.value;if(item.expiresAt>Date.now()){this.moveToHead(node);return item.data}else{this.memoryCache.delete(key);if(node===this.head){this.head=node.next}if(node===this.tail){this.tail=node.prev}if(node.prev){node.prev.next=node.next}if(node.next){node.next.prev=node.prev}}}try{const stored=await this.storage.get(key);if(stored){const item=JSON.parse(stored);if(item.expiresAt>Date.now()){this.setInMemory(key,item);return item.data}else{await this.storage.remove(key)}}}catch(error){}return null}setInMemory(key,item){let node=this.memoryCache.get(key);if(node){node.value=item;this.moveToHead(node)}else{node={key,value:item,prev:null,next:this.head};if(this.head){this.head.prev=node}this.head=node;if(!this.tail){this.tail=node}this.memoryCache.set(key,node);if(this.memoryCache.size>this.config.maxSize){this.removeTail()}}}async set(key,data,ttl){const expiresAt=Date.now()+(ttl||this.config.defaultTTL);const item={data,expiresAt,createdAt:Date.now()};this.setInMemory(key,item);try{await this.storage.set(key,item)}catch(error){}}async delete(key){const node=this.memoryCache.get(key);if(node){if(node.prev){node.prev.next=node.next}if(node.next){node.next.prev=node.prev}if(node===this.head){this.head=node.next}if(node===this.tail){this.tail=node.prev}this.memoryCache.delete(key)}try{await this.storage.remove(key)}catch(error){}}async clear(){this.memoryCache.clear()}async cleanup(){const now=Date.now();const keysToDelete=[];const nodesToRemove=[];for(const[key,node]of this.memoryCache.entries()){if(node.value.expiresAt<=now){keysToDelete.push(key);nodesToRemove.push(node)}}if(keysToDelete.length>0){for(const node of nodesToRemove){if(node.prev){node.prev.next=node.next}if(node.next){node.next.prev=node.prev}if(node===this.head){this.head=node.next}if(node===this.tail){this.tail=node.prev}}keysToDelete.forEach(key=>this.memoryCache.delete(key))}}constructor(storage,config={}){_define_property(this,"memoryCache",new Map);_define_property(this,"storage",void 0);_define_property(this,"config",void 0);_define_property(this,"head",null);_define_property(this,"tail",null);this.storage=storage;this.config={defaultTTL:config.defaultTTL??24*60*60*1e3,maxSize:config.maxSize??100}}}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"EncryptionUtils",{enumerable:true,get:function(){return EncryptionUtils}});const _utils=require("@vlian/utils");let EncryptionUtils=class EncryptionUtils{static async generateKey(){if(typeof window==="undefined"||!window.crypto||!window.crypto.subtle){throw new _utils.StorageError("加密功能需要浏览器支持 Web Crypto API")}try{return await window.crypto.subtle.generateKey({name:"AES-GCM",length:256},true,["encrypt","decrypt"])}catch(error){throw new _utils.StorageError("生成加密密钥失败",error instanceof Error?error:undefined)}}static async deriveKey(password,salt,iterations=1e5){if(typeof window==="undefined"||!window.crypto||!window.crypto.subtle){throw new _utils.StorageError("加密功能需要浏览器支持 Web Crypto API")}try{const encoder=new TextEncoder;const passwordKey=await window.crypto.subtle.importKey("raw",encoder.encode(password),"PBKDF2",false,["deriveBits","deriveKey"]);const saltBuffer=salt instanceof Uint8Array?salt:new Uint8Array(salt);return await window.crypto.subtle.deriveKey({name:"PBKDF2",salt:saltBuffer,iterations:iterations,hash:"SHA-256"},passwordKey,{name:"AES-GCM",length:256},false,["encrypt","decrypt"])}catch(error){throw new _utils.StorageError("密钥派生失败",error instanceof Error?error:undefined)}}static async importKey(keyString,salt){if(typeof window==="undefined"||!window.crypto||!window.crypto.subtle){throw new _utils.StorageError("加密功能需要浏览器支持 Web Crypto API")}try{let keySalt=salt;if(!keySalt){const saltKey="__encryption_salt__";const storedSalt=sessionStorage.getItem(saltKey);if(storedSalt){const saltArray=Uint8Array.from(JSON.parse(storedSalt));keySalt=saltArray}else{keySalt=window.crypto.getRandomValues(new Uint8Array(16));sessionStorage.setItem(saltKey,JSON.stringify(Array.from(keySalt)))}}return await this.deriveKey(keyString,keySalt)}catch(error){throw new _utils.StorageError("导入加密密钥失败",error instanceof Error?error:undefined)}}static async encrypt(data,key){if(typeof window==="undefined"||!window.crypto||!window.crypto.subtle){throw new _utils.StorageError("加密功能需要浏览器支持 Web Crypto API")}try{const encoder=new TextEncoder;const dataBuffer=encoder.encode(data);const iv=window.crypto.getRandomValues(new Uint8Array(12));const encrypted=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:iv},key,dataBuffer);const combined=new Uint8Array(iv.length+encrypted.byteLength);combined.set(iv);combined.set(new Uint8Array(encrypted),iv.length);return btoa(String.fromCharCode(...combined))}catch(error){throw new _utils.StorageError("加密数据失败",error instanceof Error?error:undefined)}}static async decrypt(encryptedData,key){if(typeof window==="undefined"||!window.crypto||!window.crypto.subtle){throw new _utils.StorageError("解密功能需要浏览器支持 Web Crypto API")}try{const combined=Uint8Array.from(atob(encryptedData),c=>c.charCodeAt(0));const iv=combined.slice(0,12);const encrypted=combined.slice(12);const decrypted=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:iv},key,encrypted);const decoder=new TextDecoder;return decoder.decode(decrypted)}catch(error){throw new _utils.StorageError("解密数据失败",error instanceof Error?error:undefined)}}static shouldEncrypt(key){return _utils.SecurityUtils.isSensitiveField(key)}};
|