@fast-china/utils 2.1.9 → 2.1.11

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 (72) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +5 -2
  3. package/README.zh.md +5 -2
  4. package/dist/array/index.mjs +21 -21
  5. package/dist/array/index.mjs.map +1 -1
  6. package/dist/async/index.mjs +32 -32
  7. package/dist/async/index.mjs.map +1 -1
  8. package/dist/base64/index.mjs +44 -51
  9. package/dist/base64/index.mjs.map +1 -1
  10. package/dist/color/index.mjs +33 -33
  11. package/dist/color/index.mjs.map +1 -1
  12. package/dist/crypto/index.mjs +153 -155
  13. package/dist/crypto/index.mjs.map +1 -1
  14. package/dist/date/index.mjs +79 -46
  15. package/dist/date/index.mjs.map +1 -1
  16. package/dist/dom/style.mjs +7 -7
  17. package/dist/dom/style.mjs.map +1 -1
  18. package/dist/env/index.mjs +9 -14
  19. package/dist/env/index.mjs.map +1 -1
  20. package/dist/function/index.mjs +4 -4
  21. package/dist/function/index.mjs.map +1 -1
  22. package/dist/identity/index.mjs +7 -7
  23. package/dist/identity/index.mjs.map +1 -1
  24. package/dist/index.d.mts +393 -366
  25. package/dist/index.global.min.js +2 -2
  26. package/dist/index.global.min.js.map +1 -1
  27. package/dist/index.mjs +2 -1
  28. package/dist/internal/text.mjs +70 -26
  29. package/dist/internal/text.mjs.map +1 -1
  30. package/dist/logger/index.mjs +12 -13
  31. package/dist/logger/index.mjs.map +1 -1
  32. package/dist/number/index.mjs +63 -42
  33. package/dist/number/index.mjs.map +1 -1
  34. package/dist/object/index.mjs +32 -31
  35. package/dist/object/index.mjs.map +1 -1
  36. package/dist/storage/index.mjs +58 -63
  37. package/dist/storage/index.mjs.map +1 -1
  38. package/dist/string/index.mjs +60 -64
  39. package/dist/string/index.mjs.map +1 -1
  40. package/dist/vue/breakpoints.mjs +14 -10
  41. package/dist/vue/breakpoints.mjs.map +1 -1
  42. package/dist/vue/element-size.mjs +4 -4
  43. package/dist/vue/element-size.mjs.map +1 -1
  44. package/dist/vue/emits.mjs +7 -7
  45. package/dist/vue/emits.mjs.map +1 -1
  46. package/dist/vue/event-listener.mjs +5 -5
  47. package/dist/vue/event-listener.mjs.map +1 -1
  48. package/dist/vue/expose.mjs +3 -3
  49. package/dist/vue/expose.mjs.map +1 -1
  50. package/dist/vue/func.mjs +2 -2
  51. package/dist/vue/func.mjs.map +1 -1
  52. package/dist/vue/index.mjs +2 -1
  53. package/dist/vue/install.mjs +24 -24
  54. package/dist/vue/install.mjs.map +1 -1
  55. package/dist/vue/now.mjs +4 -5
  56. package/dist/vue/now.mjs.map +1 -1
  57. package/dist/vue/props.mjs +5 -5
  58. package/dist/vue/props.mjs.map +1 -1
  59. package/dist/vue/render.mjs +2 -2
  60. package/dist/vue/render.mjs.map +1 -1
  61. package/dist/vue/resize-observer.mjs +4 -6
  62. package/dist/vue/resize-observer.mjs.map +1 -1
  63. package/dist/vue/slots.mjs.map +1 -1
  64. package/dist/vue/transition.mjs +58 -0
  65. package/dist/vue/transition.mjs.map +1 -0
  66. package/dist/vue/window-size.mjs +2 -4
  67. package/dist/vue/window-size.mjs.map +1 -1
  68. package/dist/vue/with.mjs +1 -1
  69. package/dist/vue/with.mjs.map +1 -1
  70. package/package.json +2 -1
  71. package/dist/internal/runtime.mjs +0 -32
  72. package/dist/internal/runtime.mjs.map +0 -1
@@ -1,26 +1,22 @@
1
- import { getRuntimeUni, runtimeGlobals } from "../internal/runtime.mjs";
2
1
  import { decodeSecureBase64, encodeSecureBase64 } from "../base64/index.mjs";
3
2
  //#region src/storage/index.ts
4
3
  /**
5
4
  * 读取并校验当前运行时的全局 uni-app 同步 Storage。
6
5
  *
7
- * @returns 检测到 uni-app 时返回同步 Storage;普通浏览器环境返回 `undefined`。
6
+ * @returns 检测到可用的 uni-app 同步 Storage 时返回 `true`。
8
7
  * @throws `TypeError` 当全局 `uni` 存在但缺少本库需要的同步 Storage 方法。
9
8
  */
10
- const getGlobalUniStorage = () => {
11
- const value = getRuntimeUni();
12
- if (value === void 0) return void 0;
13
- if (typeof value !== "object" && typeof value !== "function" || value === null) throw new TypeError("全局 uni 对象未提供同步 Storage API。");
14
- const storage = value;
15
- if (typeof storage.getStorageSync !== "function" || typeof storage.getStorageInfoSync !== "function" || typeof storage.removeStorageSync !== "function" || typeof storage.setStorageSync !== "function") throw new TypeError("全局 uni 对象未提供同步 Storage API。");
16
- return storage;
9
+ const hasGlobalUniStorage = () => {
10
+ if (typeof uni === "undefined") return false;
11
+ if (uni === null || typeof uni.getStorageSync !== "function" || typeof uni.getStorageInfoSync !== "function" || typeof uni.removeStorageSync !== "function" || typeof uni.setStorageSync !== "function") throw new TypeError("The global uni object does not provide synchronous Storage APIs.");
12
+ return true;
17
13
  };
18
14
  /** 默认 JSON Codec;显式拒绝会被 JSON.stringify 静默丢弃的顶层值。 */
19
15
  const jsonCodec = {
20
16
  decode: (value) => JSON.parse(value),
21
17
  encode: (value) => {
22
18
  const encoded = JSON.stringify(value);
23
- if (typeof encoded !== "string") throw new TypeError("存储值无法序列化为 JSON。");
19
+ if (typeof encoded !== "string") throw new TypeError("The storage value cannot be serialized as JSON.");
24
20
  return encoded;
25
21
  }
26
22
  };
@@ -29,7 +25,7 @@ const base64StorageCodec = {
29
25
  decode: (value) => JSON.parse(decodeSecureBase64(value)),
30
26
  encode: (value) => {
31
27
  const encoded = JSON.stringify(value);
32
- if (typeof encoded !== "string") throw new TypeError("存储值无法序列化为 JSON。");
28
+ if (typeof encoded !== "string") throw new TypeError("The storage value cannot be serialized as JSON.");
33
29
  return encodeSecureBase64(encoded);
34
30
  }
35
31
  };
@@ -38,30 +34,30 @@ let activeConfiguration;
38
34
  /**
39
35
  * 判断未知值是否为非数组对象记录。
40
36
  *
41
- * @param value - JSON.parse 返回的未知值。
37
+ * @param value - JSON.parse 返回的未知值
42
38
  * @returns 值为非空、非数组对象时返回 `true`。
43
39
  */
44
40
  const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
45
41
  /**
46
42
  * 校验 Storage 业务键。
47
43
  *
48
- * @param key - 不含全局 Prefix 的业务键或业务键前缀。
44
+ * @param key - 不含全局 Prefix 的业务键或业务键前缀
49
45
  * @throws `TypeError` 当值不是非空字符串。
50
46
  */
51
47
  const assertKey = (key) => {
52
- if (typeof key !== "string" || key.length === 0) throw new TypeError("Storage 键必须是非空字符串。");
48
+ if (typeof key !== "string" || key.length === 0) throw new TypeError("Storage keys must be nonempty strings.");
53
49
  };
54
50
  /**
55
51
  * 创建浏览器 Storage 后端。
56
52
  *
57
53
  * @remarks 平台对象在调用阶段读取,因此导入模块不会访问浏览器全局对象。
58
54
  * @param kind - 选择 `localStorage` 或 `sessionStorage`。
59
- * @returns 统一的内部同步后端。
55
+ * @returns 统一的内部同步后端
60
56
  * @throws `Error` 当所选 Storage 在当前环境不可用。
61
57
  */
62
58
  const createWebStorageBackend = (kind) => {
63
- const storage = kind === "local" ? runtimeGlobals.localStorage : runtimeGlobals.sessionStorage;
64
- if (storage === void 0) throw new Error(`当前运行环境不支持 ${kind}Storage。`);
59
+ const storage = kind === "local" ? typeof localStorage === "undefined" ? void 0 : localStorage : typeof sessionStorage === "undefined" ? void 0 : sessionStorage;
60
+ if (storage === void 0) throw new Error(`The current runtime does not support ${kind}Storage.`);
65
61
  return {
66
62
  getItem: (key) => storage.getItem(key),
67
63
  keys: () => {
@@ -84,91 +80,90 @@ const createWebStorageBackend = (kind) => {
84
80
  * 把 uni-app 同步 Storage 适配为内部后端。
85
81
  *
86
82
  * @remarks uni-app 以空字符串同时表示“键缺失”和“真实空值”,因此空字符串需要结合键清单消除歧义。
87
- * @param storage - 已从全局 `uni` 读取并校验的同步 API。
88
- * @returns 统一的内部同步后端。
83
+ * @returns 统一的内部同步后端
89
84
  */
90
- const createUniStorageBackend = (storage) => ({
85
+ const createUniStorageBackend = () => ({
91
86
  getItem: (key) => {
92
- const value = storage.getStorageSync(key);
87
+ const value = uni.getStorageSync(key);
93
88
  if (value !== "") return value;
94
- return storage.getStorageInfoSync().keys.includes(key) ? value : void 0;
89
+ return uni.getStorageInfoSync().keys.includes(key) ? value : void 0;
95
90
  },
96
- keys: () => [...storage.getStorageInfoSync().keys],
91
+ keys: () => [...uni.getStorageInfoSync().keys],
97
92
  removeItem: (key) => {
98
- storage.removeStorageSync(key);
93
+ uni.removeStorageSync(key);
99
94
  },
100
95
  setItem: (key, value) => {
101
- storage.setStorageSync(key, value);
96
+ uni.setStorageSync(key, value);
102
97
  }
103
98
  });
104
99
  /**
105
100
  * 解析并校验版本化 Storage 包络。
106
101
  *
107
- * @param rawValue - 后端返回的原始值。
108
- * @param key - 用于错误定位的完整物理键。
109
- * @returns 当前 v3 包络。
102
+ * @param rawValue - 后端返回的原始值
103
+ * @param key - 用于错误定位的完整物理键
104
+ * @returns 当前 v3 包络
110
105
  * @throws `TypeError` 当原始值不是字符串、JSON 损坏、版本不支持或字段类型非法。
111
106
  */
112
107
  const parseStoredEnvelope = (rawValue, key) => {
113
- if (typeof rawValue !== "string") throw new TypeError(`Storage 条目“${key}”不是字符串。`);
108
+ if (typeof rawValue !== "string") throw new TypeError(`Storage entry "${key}" is not a string.`);
114
109
  try {
115
110
  const parsed = JSON.parse(rawValue);
116
- if (!isRecord(parsed) || parsed["version"] !== 3 || typeof parsed["data"] !== "string" || !(parsed["expiresAt"] === null || typeof parsed["expiresAt"] === "number" && Number.isFinite(parsed["expiresAt"]))) throw new TypeError("不支持该存储包络。");
111
+ if (!isRecord(parsed) || parsed["version"] !== 3 || typeof parsed["data"] !== "string" || !(parsed["expiresAt"] === null || typeof parsed["expiresAt"] === "number" && Number.isFinite(parsed["expiresAt"]))) throw new TypeError("Unsupported storage envelope.");
117
112
  return {
118
113
  data: parsed["data"],
119
114
  expiresAt: parsed["expiresAt"],
120
115
  version: 3
121
116
  };
122
117
  } catch (cause) {
123
- throw new TypeError(`Storage 条目“${key}”已损坏或不受支持。`, { cause });
118
+ throw new TypeError(`Storage entry "${key}" is corrupted or unsupported.`, { cause });
124
119
  }
125
120
  };
126
121
  /**
127
122
  * 创建绑定命名空间、Codec 与时钟的 Storage Area。
128
123
  *
129
124
  * @param backendFactory - 每次操作时解析平台后端的工厂,保证导入安全并反映平台可用性。
130
- * @param prefix - 已校验的全局物理键前缀。
131
- * @param codec - 业务值与包络文本之间的 Codec。
132
- * @param now - TTL 计算使用的可注入时钟。
133
- * @returns 完整的命名空间 Storage 操作集合。
125
+ * @param prefix - 已校验的全局物理键前缀
126
+ * @param codec - 业务值与包络文本之间的 Codec
127
+ * @param now - TTL 计算使用的可注入时钟
128
+ * @returns 完整的命名空间 Storage 操作集合
134
129
  */
135
130
  const createStorageArea = (backendFactory, prefix, codec, now) => {
136
131
  /**
137
132
  * 拼接物理键。
138
133
  *
139
- * @param key - 已校验业务键。
140
- * @returns 带当前命名空间前缀的物理键。
134
+ * @param key - 已校验业务键
135
+ * @returns 带当前命名空间前缀的物理键
141
136
  */
142
137
  const toStorageKey = (key) => `${prefix}${key}`;
143
138
  /**
144
139
  * 解析本次读写实际使用的 Codec。
145
140
  *
146
141
  * @param crypto - 单次 Base64 混淆开关;省略时沿用 Area 全局 Codec。
147
- * @returns 本次操作使用的全局、JSON 或 Base64 Codec。
142
+ * @returns 本次操作使用的全局、JSON 或 Base64 Codec
148
143
  * @throws `TypeError` 当 JavaScript 调用方传入非布尔值。
149
144
  */
150
145
  const resolveOperationCodec = (crypto) => {
151
146
  if (crypto === void 0) return codec;
152
- if (typeof crypto !== "boolean") throw new TypeError("Storage 单次 `crypto` 选项必须是布尔值。");
147
+ if (typeof crypto !== "boolean") throw new TypeError("The per-operation Storage `crypto` option must be a boolean.");
153
148
  return crypto ? base64StorageCodec : jsonCodec;
154
149
  };
155
150
  /**
156
151
  * 枚举当前命名空间中的业务键。
157
152
  *
158
- * @param backend - 本次操作使用的后端。
159
- * @returns 已移除物理前缀、去重并排序的业务键。
153
+ * @param backend - 本次操作使用的后端
154
+ * @returns 已移除物理前缀、去重并排序的业务键
160
155
  * @throws `TypeError` 当后端返回非字符串键。
161
156
  */
162
157
  const listBusinessKeys = (backend) => {
163
158
  const keys = backend.keys();
164
- if (!Array.isArray(keys) || !keys.every((key) => typeof key === "string")) throw new TypeError("Storage 后端返回的键必须是字符串。");
159
+ if (!Array.isArray(keys) || !keys.every((key) => typeof key === "string")) throw new TypeError("Keys returned by the Storage backend must be strings.");
165
160
  return [...new Set(keys.filter((key) => key.startsWith(prefix)).map((key) => key.slice(prefix.length)))].sort();
166
161
  };
167
162
  /**
168
163
  * 读取并处理单个包络。
169
164
  *
170
- * @param backend - 本次操作使用的后端。
171
- * @param key - 业务键。
165
+ * @param backend - 本次操作使用的后端
166
+ * @param key - 业务键
172
167
  * @returns 未过期包络;键缺失或已经过期时返回 `undefined`。
173
168
  * @throws `TypeError` 当键或包络非法。
174
169
  * @throws `RangeError` 当注入时钟返回非有限时间戳。
@@ -181,7 +176,7 @@ const createStorageArea = (backendFactory, prefix, codec, now) => {
181
176
  const envelope = parseStoredEnvelope(rawValue, storageKey);
182
177
  if (envelope.expiresAt === null) return envelope;
183
178
  const timestamp = now();
184
- if (!Number.isFinite(timestamp)) throw new RangeError("Storage 时钟必须返回有限时间戳。");
179
+ if (!Number.isFinite(timestamp)) throw new RangeError("The Storage clock must return a finite timestamp.");
185
180
  if (timestamp < envelope.expiresAt) return envelope;
186
181
  backend.removeItem(storageKey);
187
182
  };
@@ -197,7 +192,7 @@ const createStorageArea = (backendFactory, prefix, codec, now) => {
197
192
  try {
198
193
  return resolveOperationCodec(options.crypto).decode(envelope.data);
199
194
  } catch (cause) {
200
- throw new TypeError(`无法解码 Storage 条目“${toStorageKey(key)}”。`, { cause });
195
+ throw new TypeError(`Unable to decode Storage entry "${toStorageKey(key)}".`, { cause });
201
196
  }
202
197
  },
203
198
  has: (key) => readStoredEnvelope(backendFactory(), key) !== void 0,
@@ -222,20 +217,20 @@ const createStorageArea = (backendFactory, prefix, codec, now) => {
222
217
  },
223
218
  set(key, value, options = {}) {
224
219
  assertKey(key);
225
- if (value === void 0) throw new TypeError("不能存储顶层 `undefined`,请改为移除对应的键。");
220
+ if (value === void 0) throw new TypeError("Cannot store top-level `undefined`; remove the key instead.");
226
221
  let expiresAt = null;
227
222
  if (options.ttlMs !== void 0) {
228
- if (!Number.isFinite(options.ttlMs) || options.ttlMs <= 0) throw new RangeError("`ttlMs` 必须是大于 0 的有限数。");
223
+ if (!Number.isFinite(options.ttlMs) || options.ttlMs <= 0) throw new RangeError("`ttlMs` must be a finite number greater than 0.");
229
224
  const timestamp = now();
230
- if (!Number.isFinite(timestamp) || !Number.isFinite(timestamp + options.ttlMs)) throw new RangeError("Storage 过期时间超出支持的时间戳范围。");
225
+ if (!Number.isFinite(timestamp) || !Number.isFinite(timestamp + options.ttlMs)) throw new RangeError("The Storage expiration time exceeds the supported timestamp range.");
231
226
  expiresAt = timestamp + options.ttlMs;
232
227
  }
233
228
  let data;
234
229
  try {
235
230
  data = resolveOperationCodec(options.crypto).encode(value);
236
- if (typeof data !== "string") throw new TypeError("Storage Codec 必须返回字符串。");
231
+ if (typeof data !== "string") throw new TypeError("The Storage codec must return a string.");
237
232
  } catch (cause) {
238
- throw new TypeError("无法编码存储值。", { cause });
233
+ throw new TypeError("Unable to encode the storage value.", { cause });
239
234
  }
240
235
  backendFactory().setItem(toStorageKey(key), JSON.stringify({
241
236
  data,
@@ -248,30 +243,30 @@ const createStorageArea = (backendFactory, prefix, codec, now) => {
248
243
  /**
249
244
  * 获取已激活的全局 Storage 配置。
250
245
  *
251
- * @returns 显式配置或首次 Storage 操作创建的默认配置。
246
+ * @returns 显式配置或首次 Storage 操作创建的默认配置
252
247
  */
253
248
  const requireStorageConfiguration = () => {
254
249
  if (activeConfiguration === void 0) configureStorage();
255
- if (activeConfiguration === void 0) throw new Error("无法初始化 Storage 配置。");
250
+ if (activeConfiguration === void 0) throw new Error("Unable to initialize the Storage configuration.");
256
251
  return activeConfiguration;
257
252
  };
258
253
  /**
259
254
  * 创建稳定的公开 Storage 门面。
260
255
  *
261
- * @param select - 从激活配置选择 Local 或 Session 的函数。
262
- * @param name - 用于不可用错误的公开门面名称。
256
+ * @param select - 从激活配置选择 Local 或 Session 的函数
257
+ * @param name - 用于不可用错误的公开门面名称
263
258
  * @returns 可安全导入、并在首次调用时解析默认或显式配置的稳定对象。
264
259
  */
265
260
  const createStorageAreaProxy = (select, name) => {
266
261
  /**
267
262
  * 解析当前实际 Area。
268
263
  *
269
- * @returns 配置中的 Local 或 Session Area。
264
+ * @returns 配置中的 Local 或 Session Area
270
265
  * @throws `Error` 当 uni-app 模式请求 Session。
271
266
  */
272
267
  const getArea = () => {
273
268
  const area = select(requireStorageConfiguration());
274
- if (area === void 0) throw new Error(`uni-app 中不支持 ${name}。`);
269
+ if (area === void 0) throw new Error(`${name} is not supported in uni-app.`);
275
270
  return area;
276
271
  };
277
272
  return {
@@ -311,22 +306,22 @@ const Session = createStorageAreaProxy((configuration) => configuration.session,
311
306
  */
312
307
  function configureStorage(options = {}) {
313
308
  const prefix = options.prefix ?? "fast__";
314
- if (typeof prefix !== "string" || prefix.length === 0) throw new TypeError("Storage 前缀必须是非空字符串。");
315
- if (options.codec !== void 0 && options.crypto === true) throw new TypeError("Storage 的 Codec 和加密选项不能同时使用。");
309
+ if (typeof prefix !== "string" || prefix.length === 0) throw new TypeError("The Storage prefix must be a nonempty string.");
310
+ if (options.codec !== void 0 && options.crypto === true) throw new TypeError("Storage codec and crypto options cannot be used together.");
316
311
  const codec = options.codec ?? (options.crypto === true ? base64StorageCodec : jsonCodec);
317
312
  const now = options.now ?? Date.now;
318
313
  if (activeConfiguration !== void 0) {
319
314
  if (activeConfiguration.prefix === prefix && activeConfiguration.codec === codec && activeConfiguration.now === now) return;
320
- throw new Error("Storage 已使用其他选项完成配置。");
315
+ throw new Error("Storage is already configured with different options.");
321
316
  }
322
- const uni = getGlobalUniStorage();
317
+ const usesUniStorage = hasGlobalUniStorage();
323
318
  const configuration = {
324
319
  codec,
325
- local: createStorageArea(uni === void 0 ? () => createWebStorageBackend("local") : () => createUniStorageBackend(uni), prefix, codec, now),
320
+ local: createStorageArea(usesUniStorage ? () => createUniStorageBackend() : () => createWebStorageBackend("local"), prefix, codec, now),
326
321
  now,
327
322
  prefix
328
323
  };
329
- if (uni === void 0) configuration.session = createStorageArea(() => createWebStorageBackend("session"), prefix, codec, now);
324
+ if (!usesUniStorage) configuration.session = createStorageArea(() => createWebStorageBackend("session"), prefix, codec, now);
330
325
  activeConfiguration = configuration;
331
326
  }
332
327
  /** 返回 Storage 是否已经显式配置,或由首次 Storage 操作激活默认配置。 */
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/storage/index.ts"],"sourcesContent":["import { decodeSecureBase64, encodeSecureBase64 } from \"../base64/index\";\nimport { getRuntimeUni, runtimeGlobals } from \"../internal/runtime\";\n\n/** uni-app 同步存储信息中本库实际读取的字段。 */\ninterface UniStorageInfo {\n\t/** 当前平台可见的物理键快照。 */\n\tkeys: readonly string[];\n}\n\n/** 全局 `uni` 必须提供的同步存储 API 最小结构。 */\ninterface UniStorageLike {\n\t/**\n\t * 同步读取一个物理键的原始值。\n\t * @param key - 已包含全局命名空间前缀的物理键。\n\t * @returns 平台保存的值;键缺失时应返回 `undefined`、`null` 或空字符串。\n\t */\n\tgetStorageSync: (key: string) => unknown;\n\t/**\n\t * 同步读取平台当前可见的全部物理键。\n\t * @returns 至少包含只读 `keys` 数组的快照对象。\n\t */\n\tgetStorageInfoSync: () => UniStorageInfo;\n\t/**\n\t * 同步删除一个物理键;键不存在时应保持幂等。\n\t * @param key - 已包含全局命名空间前缀的物理键。\n\t */\n\tremoveStorageSync: (key: string) => void;\n\t/**\n\t * 同步写入已经序列化的包络文本。\n\t * @param key - 已包含全局命名空间前缀的物理键。\n\t * @param value - JSON 包络字符串,不是未经编码的业务值。\n\t */\n\tsetStorageSync: (key: string, value: string) => void;\n}\n\n/** Storage 业务值编码器。 */\nexport interface StorageCodec {\n\t/**\n\t * 把已编码文本恢复为业务值。\n\t * @param value - 由同一 Codec 的 `encode` 生成并持久化的文本。\n\t * @returns 解码后的业务值。\n\t * @throws 当文本损坏、格式不受支持或无法反序列化时应抛出错误。\n\t */\n\tdecode: (value: string) => unknown;\n\t/**\n\t * 把业务值编码为可持久化字符串。\n\t * @param value - 调用方传入的业务值。\n\t * @returns 可由同一 Codec 的 `decode` 无损恢复的文本。\n\t * @throws 当值不受支持或无法序列化时应抛出错误。\n\t */\n\tencode: (value: unknown) => string;\n}\n\n/** 程序入口调用 {@link configureStorage} 时使用的全局配置。 */\nexport interface StorageConfiguration {\n\t/** 自定义值编码器;默认使用严格 JSON Codec,同一应用生命周期内必须保持同一引用。 */\n\tcodec?: StorageCodec;\n\t/** 启用 Base64 可逆混淆;不提供加密、完整性或认证,不能与 `codec` 同时使用。 */\n\tcrypto?: boolean;\n\t/** 返回 Unix 毫秒时间戳的时钟;默认使用 `Date.now`,主要用于 TTL 测试与受控时间源。 */\n\tnow?: () => number;\n\t/** 所有物理键使用的非空命名空间前缀,默认 `fast__`。 */\n\tprefix?: string;\n}\n\n/** 单次 Storage 读取配置。 */\nexport interface StorageReadOptions {\n\t/**\n\t * 仅覆盖本次读取使用的 Codec;`true` 使用 Base64 混淆,`false` 使用 JSON,省略时使用全局配置。\n\t * 必须与写入该条目时使用的单次设置一致。\n\t */\n\tcrypto?: boolean;\n}\n\n/** 单次 Storage 写入配置。 */\nexport interface StorageWriteOptions extends StorageReadOptions {\n\t/** 从写入时刻开始的有效毫秒数;必须是大于 0 的有限数,省略时永久有效。 */\n\tttlMs?: number;\n}\n\n/** `Local` 与 `Session` 的统一操作接口。 */\nexport interface StorageArea {\n\t/** 当前全局 Storage 配置的物理键前缀;首次读取会激活默认配置。 */\n\treadonly prefix: string;\n\t/**\n\t * 删除当前命名空间内的全部键,不影响同一后端中的其他应用键。\n\t * @throws `Error` 当当前平台后端不可用。\n\t */\n\tclear: () => void;\n\t/**\n\t * 获取并解码业务值;已过期记录会在读取时删除。\n\t * @param key - 不含全局前缀的非空业务键。\n\t * @param options - 可选的单次 Base64 混淆开关;必须与写入时一致。\n\t * @returns 解码后的值;未传泛型时静态类型默认为 `string`,键缺失或过期时返回 `undefined`。\n\t * @throws 当键非法、包络损坏、Codec 解码失败或后端不可用时抛出错误。\n\t */\n\tget: <Value = string>(key: string, options?: StorageReadOptions) => Value | undefined;\n\t/**\n\t * 判断业务键是否具有有效且未过期的包络;不解码业务值。\n\t * @param key - 不含全局前缀的非空业务键。\n\t * @returns 键存在且包络有效时返回 `true`。\n\t */\n\thas: (key: string) => boolean;\n\t/**\n\t * 返回当前命名空间内的业务键快照。\n\t * @returns 已移除全局前缀并按字典序排列的新数组;不会自动清理过期项。\n\t */\n\tkeys: () => string[];\n\t/**\n\t * 扫描当前命名空间并删除全部过期记录。\n\t * @returns 本次实际删除的记录数量。\n\t * @throws 当发现损坏包络或后端不可用时抛出错误。\n\t */\n\tpruneExpired: () => number;\n\t/**\n\t * 删除单个业务键;键不存在时保持幂等。\n\t * @param key - 不含全局前缀的非空业务键。\n\t */\n\tremove: (key: string) => void;\n\t/**\n\t * 删除业务键以指定文本开头的全部条目,范围仍受全局命名空间限制。\n\t * @param keyPrefix - 不含全局前缀的非空业务键前缀。\n\t */\n\tremoveByPrefix: (keyPrefix: string) => void;\n\t/**\n\t * 编码并写入业务值,可附加惰性清理的 TTL。\n\t * @param key - 不含全局前缀的非空业务键。\n\t * @param value - 必须受当前 Codec 支持的业务值。\n\t * @param options - 可选的单次写入 TTL 与 Base64 混淆开关。\n\t * @throws 当键、TTL、业务值或后端写入无效时抛出错误。\n\t */\n\tset: <Value>(key: string, value: Value, options?: StorageWriteOptions) => void;\n}\n\n/** 浏览器 Storage 与 uni-app Storage 适配后的最小内部协议。 */\ninterface StorageBackend {\n\t/** 读取物理键原始值;缺失约定由上层统一规范为 `undefined`。 */\n\tgetItem: (key: string) => unknown;\n\t/** 枚举后端可见的全部物理键;返回值必须是不会随枚举过程变化的快照。 */\n\tkeys: () => readonly string[];\n\t/** 删除单个物理键;实现必须允许重复删除。 */\n\tremoveItem: (key: string) => void;\n\t/** 写入已经序列化的包络文本;配额和平台错误保持原样传播。 */\n\tsetItem: (key: string, value: string) => void;\n}\n\n/** 物理存储中的版本化包络;业务值始终先经 Codec 转为文本。 */\ninterface StoredEnvelope {\n\t/** Codec 编码后的业务文本;只有在包络结构校验通过后才能交给 Codec。 */\n\tdata: string;\n\t/** Unix 毫秒绝对过期时间戳;`null` 表示永久有效。 */\n\texpiresAt: number | null;\n\t/** 当前持久化协议版本;读取其他版本必须明确失败,不能猜测迁移。 */\n\tversion: 3;\n}\n\n/** 首次配置后冻结使用的解析结果和两个稳定门面。 */\ninterface ActiveStorageConfiguration {\n\t/** 首次配置后锁定的业务值 Codec 引用。 */\n\tcodec: StorageCodec;\n\t/** 已绑定 Local 后端、命名空间、Codec 与时钟的实际 Area。 */\n\tlocal: StorageArea;\n\t/** 首次配置后锁定的 TTL 时钟引用。 */\n\tnow: () => number;\n\t/** 所有 Area 共享的物理键命名空间前缀。 */\n\tprefix: string;\n\t/** 仅浏览器模式存在的 Session Area;uni-app 模式必须保持缺失。 */\n\tsession?: StorageArea;\n}\n\n/**\n * 读取并校验当前运行时的全局 uni-app 同步 Storage。\n *\n * @returns 检测到 uni-app 时返回同步 Storage;普通浏览器环境返回 `undefined`。\n * @throws `TypeError` 当全局 `uni` 存在但缺少本库需要的同步 Storage 方法。\n */\nconst getGlobalUniStorage = (): UniStorageLike | undefined => {\n\tconst value = getRuntimeUni();\n\tif (value === undefined) return undefined;\n\tif ((typeof value !== \"object\" && typeof value !== \"function\") || value === null) {\n\t\tthrow new TypeError(\"全局 uni 对象未提供同步 Storage API。\");\n\t}\n\tconst storage = value as Partial<UniStorageLike>;\n\tif (\n\t\ttypeof storage.getStorageSync !== \"function\" ||\n\t\ttypeof storage.getStorageInfoSync !== \"function\" ||\n\t\ttypeof storage.removeStorageSync !== \"function\" ||\n\t\ttypeof storage.setStorageSync !== \"function\"\n\t) {\n\t\tthrow new TypeError(\"全局 uni 对象未提供同步 Storage API。\");\n\t}\n\treturn storage as UniStorageLike;\n};\n\n/** 默认 JSON Codec;显式拒绝会被 JSON.stringify 静默丢弃的顶层值。 */\nconst jsonCodec: StorageCodec = {\n\tdecode: (value) => JSON.parse(value) as unknown,\n\tencode: (value) => {\n\t\tconst encoded = JSON.stringify(value);\n\t\tif (typeof encoded !== \"string\") throw new TypeError(\"存储值无法序列化为 JSON。\");\n\t\treturn encoded;\n\t},\n};\n\n/** Base64 混淆 Codec;只隐藏明文外观,不提供加密、完整性或认证。 */\nexport const base64StorageCodec: StorageCodec = {\n\tdecode: (value) => JSON.parse(decodeSecureBase64(value)) as unknown,\n\tencode: (value) => {\n\t\tconst encoded = JSON.stringify(value);\n\t\tif (typeof encoded !== \"string\") throw new TypeError(\"存储值无法序列化为 JSON。\");\n\t\treturn encodeSecureBase64(encoded);\n\t},\n};\n\n/** 页面级唯一配置;只允许幂等重复配置,避免模块加载顺序改变行为。 */\nlet activeConfiguration: ActiveStorageConfiguration | undefined;\n\n/**\n * 判断未知值是否为非数组对象记录。\n *\n * @param value - JSON.parse 返回的未知值。\n * @returns 值为非空、非数组对象时返回 `true`。\n */\nconst isRecord = (value: unknown): value is Record<string, unknown> => typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/**\n * 校验 Storage 业务键。\n *\n * @param key - 不含全局 Prefix 的业务键或业务键前缀。\n * @throws `TypeError` 当值不是非空字符串。\n */\nconst assertKey = (key: string): void => {\n\tif (typeof key !== \"string\" || key.length === 0) throw new TypeError(\"Storage 键必须是非空字符串。\");\n};\n\n/**\n * 创建浏览器 Storage 后端。\n *\n * @remarks 平台对象在调用阶段读取,因此导入模块不会访问浏览器全局对象。\n * @param kind - 选择 `localStorage` 或 `sessionStorage`。\n * @returns 统一的内部同步后端。\n * @throws `Error` 当所选 Storage 在当前环境不可用。\n */\nconst createWebStorageBackend = (kind: \"local\" | \"session\"): StorageBackend => {\n\tconst storage = kind === \"local\" ? runtimeGlobals.localStorage : runtimeGlobals.sessionStorage;\n\tif (storage === undefined) throw new Error(`当前运行环境不支持 ${kind}Storage。`);\n\treturn {\n\t\tgetItem: (key) => storage.getItem(key),\n\t\tkeys: () => {\n\t\t\tconst keys: string[] = [];\n\t\t\tfor (let index = 0; index < storage.length; index += 1) {\n\t\t\t\tconst key = storage.key(index);\n\t\t\t\tif (key !== null) keys.push(key);\n\t\t\t}\n\t\t\treturn keys;\n\t\t},\n\t\tremoveItem: (key) => {\n\t\t\tstorage.removeItem(key);\n\t\t},\n\t\tsetItem: (key, value) => {\n\t\t\tstorage.setItem(key, value);\n\t\t},\n\t};\n};\n\n/**\n * 把 uni-app 同步 Storage 适配为内部后端。\n *\n * @remarks uni-app 以空字符串同时表示“键缺失”和“真实空值”,因此空字符串需要结合键清单消除歧义。\n * @param storage - 已从全局 `uni` 读取并校验的同步 API。\n * @returns 统一的内部同步后端。\n */\nconst createUniStorageBackend = (storage: UniStorageLike): StorageBackend => ({\n\tgetItem: (key) => {\n\t\tconst value = storage.getStorageSync(key);\n\t\tif (value !== \"\") return value;\n\t\treturn storage.getStorageInfoSync().keys.includes(key) ? value : undefined;\n\t},\n\tkeys: () => [...storage.getStorageInfoSync().keys],\n\tremoveItem: (key) => {\n\t\tstorage.removeStorageSync(key);\n\t},\n\tsetItem: (key, value) => {\n\t\tstorage.setStorageSync(key, value);\n\t},\n});\n\n/**\n * 解析并校验版本化 Storage 包络。\n *\n * @param rawValue - 后端返回的原始值。\n * @param key - 用于错误定位的完整物理键。\n * @returns 当前 v3 包络。\n * @throws `TypeError` 当原始值不是字符串、JSON 损坏、版本不支持或字段类型非法。\n */\nconst parseStoredEnvelope = (rawValue: unknown, key: string): StoredEnvelope => {\n\tif (typeof rawValue !== \"string\") throw new TypeError(`Storage 条目“${key}”不是字符串。`);\n\ttry {\n\t\tconst parsed = JSON.parse(rawValue) as unknown;\n\t\tif (\n\t\t\t!isRecord(parsed) ||\n\t\t\tparsed[\"version\"] !== 3 ||\n\t\t\ttypeof parsed[\"data\"] !== \"string\" ||\n\t\t\t!(parsed[\"expiresAt\"] === null || (typeof parsed[\"expiresAt\"] === \"number\" && Number.isFinite(parsed[\"expiresAt\"])))\n\t\t) {\n\t\t\tthrow new TypeError(\"不支持该存储包络。\");\n\t\t}\n\t\treturn { data: parsed[\"data\"], expiresAt: parsed[\"expiresAt\"], version: 3 };\n\t} catch (cause) {\n\t\tthrow new TypeError(`Storage 条目“${key}”已损坏或不受支持。`, { cause });\n\t}\n};\n\n/**\n * 创建绑定命名空间、Codec 与时钟的 Storage Area。\n *\n * @param backendFactory - 每次操作时解析平台后端的工厂,保证导入安全并反映平台可用性。\n * @param prefix - 已校验的全局物理键前缀。\n * @param codec - 业务值与包络文本之间的 Codec。\n * @param now - TTL 计算使用的可注入时钟。\n * @returns 完整的命名空间 Storage 操作集合。\n */\nconst createStorageArea = (backendFactory: () => StorageBackend, prefix: string, codec: StorageCodec, now: () => number): StorageArea => {\n\t/**\n\t * 拼接物理键。\n\t *\n\t * @param key - 已校验业务键。\n\t * @returns 带当前命名空间前缀的物理键。\n\t */\n\tconst toStorageKey = (key: string) => `${prefix}${key}`;\n\t/**\n\t * 解析本次读写实际使用的 Codec。\n\t *\n\t * @param crypto - 单次 Base64 混淆开关;省略时沿用 Area 全局 Codec。\n\t * @returns 本次操作使用的全局、JSON 或 Base64 Codec。\n\t * @throws `TypeError` 当 JavaScript 调用方传入非布尔值。\n\t */\n\tconst resolveOperationCodec = (crypto: boolean | undefined) => {\n\t\tif (crypto === undefined) return codec;\n\t\tif (typeof crypto !== \"boolean\") throw new TypeError(\"Storage 单次 `crypto` 选项必须是布尔值。\");\n\t\treturn crypto ? base64StorageCodec : jsonCodec;\n\t};\n\t/**\n\t * 枚举当前命名空间中的业务键。\n\t *\n\t * @param backend - 本次操作使用的后端。\n\t * @returns 已移除物理前缀、去重并排序的业务键。\n\t * @throws `TypeError` 当后端返回非字符串键。\n\t */\n\tconst listBusinessKeys = (backend: StorageBackend) => {\n\t\tconst keys = backend.keys();\n\t\tif (!Array.isArray(keys) || !keys.every((key) => typeof key === \"string\")) {\n\t\t\tthrow new TypeError(\"Storage 后端返回的键必须是字符串。\");\n\t\t}\n\t\treturn [...new Set(keys.filter((key) => key.startsWith(prefix)).map((key) => key.slice(prefix.length)))].sort();\n\t};\n\t/**\n\t * 读取并处理单个包络。\n\t *\n\t * @param backend - 本次操作使用的后端。\n\t * @param key - 业务键。\n\t * @returns 未过期包络;键缺失或已经过期时返回 `undefined`。\n\t * @throws `TypeError` 当键或包络非法。\n\t * @throws `RangeError` 当注入时钟返回非有限时间戳。\n\t */\n\tconst readStoredEnvelope = (backend: StorageBackend, key: string): StoredEnvelope | undefined => {\n\t\tassertKey(key);\n\t\tconst storageKey = toStorageKey(key);\n\t\tconst rawValue = backend.getItem(storageKey);\n\t\tif (rawValue === null || rawValue === undefined) return undefined;\n\t\tconst envelope = parseStoredEnvelope(rawValue, storageKey);\n\t\tif (envelope.expiresAt === null) return envelope;\n\t\tconst timestamp = now();\n\t\tif (!Number.isFinite(timestamp)) throw new RangeError(\"Storage 时钟必须返回有限时间戳。\");\n\t\tif (timestamp < envelope.expiresAt) return envelope;\n\t\t// 过期项在读取时立即删除,后续 has/keys/pruneExpired 观察到一致状态。\n\t\tbackend.removeItem(storageKey);\n\t\treturn undefined;\n\t};\n\n\treturn {\n\t\tprefix,\n\t\tclear() {\n\t\t\tconst backend = backendFactory();\n\t\t\tfor (const key of listBusinessKeys(backend)) backend.removeItem(toStorageKey(key));\n\t\t},\n\t\tget<Value>(key: string, options: StorageReadOptions = {}): Value | undefined {\n\t\t\tconst envelope = readStoredEnvelope(backendFactory(), key);\n\t\t\tif (envelope === undefined) return undefined;\n\t\t\ttry {\n\t\t\t\treturn resolveOperationCodec(options.crypto).decode(envelope.data) as Value;\n\t\t\t} catch (cause) {\n\t\t\t\tthrow new TypeError(`无法解码 Storage 条目“${toStorageKey(key)}”。`, { cause });\n\t\t\t}\n\t\t},\n\t\thas: (key) => readStoredEnvelope(backendFactory(), key) !== undefined,\n\t\tkeys: () => listBusinessKeys(backendFactory()),\n\t\tpruneExpired() {\n\t\t\tconst backend = backendFactory();\n\t\t\tlet removed = 0;\n\t\t\tfor (const key of listBusinessKeys(backend)) {\n\t\t\t\t// read 同时处理删除;先读取一次用于区分“原本缺失”和“本轮因过期删除”。\n\t\t\t\tconst before = backend.getItem(toStorageKey(key));\n\t\t\t\tif (before !== null && before !== undefined && readStoredEnvelope(backend, key) === undefined) removed += 1;\n\t\t\t}\n\t\t\treturn removed;\n\t\t},\n\t\tremove(key: string) {\n\t\t\tassertKey(key);\n\t\t\tbackendFactory().removeItem(toStorageKey(key));\n\t\t},\n\t\tremoveByPrefix(keyPrefix: string) {\n\t\t\tassertKey(keyPrefix);\n\t\t\tconst backend = backendFactory();\n\t\t\tfor (const key of listBusinessKeys(backend)) if (key.startsWith(keyPrefix)) backend.removeItem(toStorageKey(key));\n\t\t},\n\t\tset<Value>(key: string, value: Value, options: StorageWriteOptions = {}) {\n\t\t\tassertKey(key);\n\t\t\tif (value === undefined) throw new TypeError(\"不能存储顶层 `undefined`,请改为移除对应的键。\");\n\t\t\tlet expiresAt: number | null = null;\n\t\t\tif (options.ttlMs !== undefined) {\n\t\t\t\tif (!Number.isFinite(options.ttlMs) || options.ttlMs <= 0) throw new RangeError(\"`ttlMs` 必须是大于 0 的有限数。\");\n\t\t\t\tconst timestamp = now();\n\t\t\t\tif (!Number.isFinite(timestamp) || !Number.isFinite(timestamp + options.ttlMs)) {\n\t\t\t\t\tthrow new RangeError(\"Storage 过期时间超出支持的时间戳范围。\");\n\t\t\t\t}\n\t\t\t\texpiresAt = timestamp + options.ttlMs;\n\t\t\t}\n\t\t\tlet data: string;\n\t\t\ttry {\n\t\t\t\tdata = resolveOperationCodec(options.crypto).encode(value);\n\t\t\t\tif (typeof data !== \"string\") throw new TypeError(\"Storage Codec 必须返回字符串。\");\n\t\t\t} catch (cause) {\n\t\t\t\tthrow new TypeError(\"无法编码存储值。\", { cause });\n\t\t\t}\n\t\t\tbackendFactory().setItem(toStorageKey(key), JSON.stringify({ data, expiresAt, version: 3 } satisfies StoredEnvelope));\n\t\t},\n\t};\n};\n\n/**\n * 获取已激活的全局 Storage 配置。\n *\n * @returns 显式配置或首次 Storage 操作创建的默认配置。\n */\nconst requireStorageConfiguration = (): ActiveStorageConfiguration => {\n\tif (activeConfiguration === undefined) configureStorage();\n\tif (activeConfiguration === undefined) throw new Error(\"无法初始化 Storage 配置。\");\n\treturn activeConfiguration;\n};\n\n/**\n * 创建稳定的公开 Storage 门面。\n *\n * @param select - 从激活配置选择 Local 或 Session 的函数。\n * @param name - 用于不可用错误的公开门面名称。\n * @returns 可安全导入、并在首次调用时解析默认或显式配置的稳定对象。\n */\nconst createStorageAreaProxy = (select: (configuration: ActiveStorageConfiguration) => StorageArea | undefined, name: string): StorageArea => {\n\t/**\n\t * 解析当前实际 Area。\n\t *\n\t * @returns 配置中的 Local 或 Session Area。\n\t * @throws `Error` 当 uni-app 模式请求 Session。\n\t */\n\tconst getArea = () => {\n\t\tconst area = select(requireStorageConfiguration());\n\t\tif (area === undefined) throw new Error(`uni-app 中不支持 ${name}。`);\n\t\treturn area;\n\t};\n\treturn {\n\t\tget prefix() {\n\t\t\treturn getArea().prefix;\n\t\t},\n\t\tclear: () => {\n\t\t\tgetArea().clear();\n\t\t},\n\t\tget: <Value>(key: string, options?: StorageReadOptions): Value | undefined => getArea().get<Value>(key, options),\n\t\thas: (key) => getArea().has(key),\n\t\tkeys: () => getArea().keys(),\n\t\tpruneExpired: () => getArea().pruneExpired(),\n\t\tremove: (key) => {\n\t\t\tgetArea().remove(key);\n\t\t},\n\t\tremoveByPrefix: (keyPrefix) => {\n\t\t\tgetArea().removeByPrefix(keyPrefix);\n\t\t},\n\t\tset: <Value>(key: string, value: Value, options?: StorageWriteOptions) => {\n\t\t\tgetArea().set(key, value, options);\n\t\t},\n\t};\n};\n\n/** 浏览器 localStorage 或自动检测的 uni-app Storage 全局业务入口。 */\nexport const Local: StorageArea = createStorageAreaProxy((configuration) => configuration.local, \"Local\");\n\n/** 浏览器 sessionStorage 的全局业务入口;uni-app 不提供会话存储。 */\nexport const Session: StorageArea = createStorageAreaProxy((configuration) => configuration.session, \"Session\");\n\n/**\n * 在首次 Storage 操作前可选配置 `Local` 与 `Session`。\n *\n * @remarks 不调用时在首次操作上使用 `fast__`、JSON Codec 与 `Date.now`。首次激活后只允许以完全相同的值和引用重复调用。若检测到\n * 全局 `uni`,则自动使用其同步 Storage 且只启用 `Local`,否则使用浏览器 `localStorage` 与 `sessionStorage`。\n * `crypto: true` 仅执行可逆 Base64 混淆,不能保护敏感数据。\n * @param options - 可选的全局键前缀、Codec、Base64 混淆选项与时钟。\n * @throws 配置非法、重复配置冲突或目标平台 Storage 不可用时抛出错误。\n */\nexport function configureStorage(options: StorageConfiguration = {}): void {\n\tconst prefix = options.prefix ?? \"fast__\";\n\tif (typeof prefix !== \"string\" || prefix.length === 0) {\n\t\tthrow new TypeError(\"Storage 前缀必须是非空字符串。\");\n\t}\n\tif (options.codec !== undefined && options.crypto === true) {\n\t\tthrow new TypeError(\"Storage 的 Codec 和加密选项不能同时使用。\");\n\t}\n\tconst codec = options.codec ?? (options.crypto === true ? base64StorageCodec : jsonCodec);\n\tconst now = options.now ?? Date.now;\n\tif (activeConfiguration !== undefined) {\n\t\t// 相同配置允许多个入口模块幂等调用;任何引用或值变化都视为冲突。\n\t\tif (activeConfiguration.prefix === prefix && activeConfiguration.codec === codec && activeConfiguration.now === now) {\n\t\t\treturn;\n\t\t}\n\t\tthrow new Error(\"Storage 已使用其他选项完成配置。\");\n\t}\n\tconst uni = getGlobalUniStorage();\n\tconst localBackend = uni === undefined ? () => createWebStorageBackend(\"local\") : () => createUniStorageBackend(uni);\n\tconst local = createStorageArea(localBackend, prefix, codec, now);\n\tconst configuration: ActiveStorageConfiguration = { codec, local, now, prefix };\n\tif (uni === undefined) {\n\t\tconfiguration.session = createStorageArea(() => createWebStorageBackend(\"session\"), prefix, codec, now);\n\t}\n\tactiveConfiguration = configuration;\n}\n\n/** 返回 Storage 是否已经显式配置,或由首次 Storage 操作激活默认配置。 */\nexport function isStorageConfigured(): boolean {\n\treturn activeConfiguration !== undefined;\n}\n"],"mappings":";;;;;;;;;AAgLA,MAAM,4BAAwD;CAC7D,MAAM,QAAQ,cAAc;CAC5B,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;CAChC,IAAK,OAAO,UAAU,YAAY,OAAO,UAAU,cAAe,UAAU,MAC3E,MAAM,IAAI,UAAU,6BAA6B;CAElD,MAAM,UAAU;CAChB,IACC,OAAO,QAAQ,mBAAmB,cAClC,OAAO,QAAQ,uBAAuB,cACtC,OAAO,QAAQ,sBAAsB,cACrC,OAAO,QAAQ,mBAAmB,YAElC,MAAM,IAAI,UAAU,6BAA6B;CAElD,OAAO;AACR;;AAGA,MAAM,YAA0B;CAC/B,SAAS,UAAU,KAAK,MAAM,KAAK;CACnC,SAAS,UAAU;EAClB,MAAM,UAAU,KAAK,UAAU,KAAK;EACpC,IAAI,OAAO,YAAY,UAAU,MAAM,IAAI,UAAU,iBAAiB;EACtE,OAAO;CACR;AACD;;AAGA,MAAa,qBAAmC;CAC/C,SAAS,UAAU,KAAK,MAAM,mBAAmB,KAAK,CAAC;CACvD,SAAS,UAAU;EAClB,MAAM,UAAU,KAAK,UAAU,KAAK;EACpC,IAAI,OAAO,YAAY,UAAU,MAAM,IAAI,UAAU,iBAAiB;EACtE,OAAO,mBAAmB,OAAO;CAClC;AACD;;AAGA,IAAI;;;;;;;AAQJ,MAAM,YAAY,UAAqD,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;;;;;;;AAQ1I,MAAM,aAAa,QAAsB;CACxC,IAAI,OAAO,QAAQ,YAAY,IAAI,WAAW,GAAG,MAAM,IAAI,UAAU,oBAAoB;AAC1F;;;;;;;;;AAUA,MAAM,2BAA2B,SAA8C;C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 } from \"../base64/index\";\n\n/** Storage 业务值编码器 */\nexport interface StorageCodec {\n\t/**\n\t * 把已编码文本恢复为业务值。\n\t * @param value - 由同一 Codec 的 `encode` 生成并持久化的文本\n\t * @returns 解码后的业务值\n\t * @throws 当文本损坏、格式不受支持或无法反序列化时应抛出错误。\n\t */\n\tdecode: (value: string) => unknown;\n\t/**\n\t * 把业务值编码为可持久化字符串。\n\t * @param value - 调用方传入的业务值\n\t * @returns 可由同一 Codec 的 `decode` 无损恢复的文本\n\t * @throws 当值不受支持或无法序列化时应抛出错误。\n\t */\n\tencode: (value: unknown) => string;\n}\n\n/** 程序入口调用 {@link configureStorage} 时使用的全局配置。 */\nexport interface StorageConfiguration {\n\t/** 自定义值编码器;默认使用严格 JSON Codec,同一应用生命周期内必须保持同一引用。 */\n\tcodec?: StorageCodec;\n\t/** 启用 Base64 可逆混淆;不提供加密、完整性或认证,不能与 `codec` 同时使用。 */\n\tcrypto?: boolean;\n\t/** 返回 Unix 毫秒时间戳的时钟;默认使用 `Date.now`,主要用于 TTL 测试与受控时间源。 */\n\tnow?: () => number;\n\t/** 所有物理键使用的非空命名空间前缀,默认 `fast__`。 */\n\tprefix?: string;\n}\n\n/** 单次 Storage 读取配置 */\nexport interface StorageReadOptions {\n\t/**\n\t * 仅覆盖本次读取使用的 Codec;`true` 使用 Base64 混淆,`false` 使用 JSON,省略时使用全局配置。\n\t * 必须与写入该条目时使用的单次设置一致。\n\t */\n\tcrypto?: boolean;\n}\n\n/** 单次 Storage 写入配置 */\nexport interface StorageWriteOptions extends StorageReadOptions {\n\t/** 从写入时刻开始的有效毫秒数;必须是大于 0 的有限数,省略时永久有效。 */\n\tttlMs?: number;\n}\n\n/** `Local` 与 `Session` 的统一操作接口 */\nexport interface StorageArea {\n\t/** 当前全局 Storage 配置的物理键前缀;首次读取会激活默认配置。 */\n\treadonly prefix: string;\n\t/**\n\t * 删除当前命名空间内的全部键,不影响同一后端中的其他应用键。\n\t * @throws `Error` 当当前平台后端不可用。\n\t */\n\tclear: () => void;\n\t/**\n\t * 获取并解码业务值;已过期记录会在读取时删除。\n\t * @param key - 不含全局前缀的非空业务键\n\t * @param options - 可选的单次 Base64 混淆开关;必须与写入时一致。\n\t * @returns 解码后的值;未传泛型时静态类型默认为 `string`,键缺失或过期时返回 `undefined`。\n\t * @throws 当键非法、包络损坏、Codec 解码失败或后端不可用时抛出错误。\n\t */\n\tget: <Value = string>(key: string, options?: StorageReadOptions) => Value | undefined;\n\t/**\n\t * 判断业务键是否具有有效且未过期的包络;不解码业务值。\n\t * @param key - 不含全局前缀的非空业务键\n\t * @returns 键存在且包络有效时返回 `true`。\n\t */\n\thas: (key: string) => boolean;\n\t/**\n\t * 返回当前命名空间内的业务键快照。\n\t * @returns 已移除全局前缀并按字典序排列的新数组;不会自动清理过期项。\n\t */\n\tkeys: () => string[];\n\t/**\n\t * 扫描当前命名空间并删除全部过期记录。\n\t * @returns 本次实际删除的记录数量\n\t * @throws 当发现损坏包络或后端不可用时抛出错误。\n\t */\n\tpruneExpired: () => number;\n\t/**\n\t * 删除单个业务键;键不存在时保持幂等。\n\t * @param key - 不含全局前缀的非空业务键\n\t */\n\tremove: (key: string) => void;\n\t/**\n\t * 删除业务键以指定文本开头的全部条目,范围仍受全局命名空间限制。\n\t * @param keyPrefix - 不含全局前缀的非空业务键前缀\n\t */\n\tremoveByPrefix: (keyPrefix: string) => void;\n\t/**\n\t * 编码并写入业务值,可附加惰性清理的 TTL。\n\t * @param key - 不含全局前缀的非空业务键\n\t * @param value - 必须受当前 Codec 支持的业务值\n\t * @param options - 可选的单次写入 TTL 与 Base64 混淆开关\n\t * @throws 当键、TTL、业务值或后端写入无效时抛出错误。\n\t */\n\tset: <Value>(key: string, value: Value, options?: StorageWriteOptions) => void;\n}\n\n/** 浏览器 Storage 与 uni-app Storage 适配后的最小内部协议 */\ninterface StorageBackend {\n\t/** 读取物理键原始值;缺失约定由上层统一规范为 `undefined`。 */\n\tgetItem: (key: string) => unknown;\n\t/** 枚举后端可见的全部物理键;返回值必须是不会随枚举过程变化的快照。 */\n\tkeys: () => readonly string[];\n\t/** 删除单个物理键;实现必须允许重复删除。 */\n\tremoveItem: (key: string) => void;\n\t/** 写入已经序列化的包络文本;配额和平台错误保持原样传播。 */\n\tsetItem: (key: string, value: string) => void;\n}\n\n/** 物理存储中的版本化包络;业务值始终先经 Codec 转为文本。 */\ninterface StoredEnvelope {\n\t/** Codec 编码后的业务文本;只有在包络结构校验通过后才能交给 Codec。 */\n\tdata: string;\n\t/** Unix 毫秒绝对过期时间戳;`null` 表示永久有效。 */\n\texpiresAt: number | null;\n\t/** 当前持久化协议版本;读取其他版本必须明确失败,不能猜测迁移。 */\n\tversion: 3;\n}\n\n/** 首次配置后冻结使用的解析结果和两个稳定门面。 */\ninterface ActiveStorageConfiguration {\n\t/** 首次配置后锁定的业务值 Codec 引用。 */\n\tcodec: StorageCodec;\n\t/** 已绑定 Local 后端、命名空间、Codec 与时钟的实际 Area。 */\n\tlocal: StorageArea;\n\t/** 首次配置后锁定的 TTL 时钟引用。 */\n\tnow: () => number;\n\t/** 所有 Area 共享的物理键命名空间前缀。 */\n\tprefix: string;\n\t/** 仅浏览器模式存在的 Session Area;uni-app 模式必须保持缺失。 */\n\tsession?: StorageArea;\n}\n\n/**\n * 读取并校验当前运行时的全局 uni-app 同步 Storage。\n *\n * @returns 检测到可用的 uni-app 同步 Storage 时返回 `true`。\n * @throws `TypeError` 当全局 `uni` 存在但缺少本库需要的同步 Storage 方法。\n */\nconst hasGlobalUniStorage = (): boolean => {\n\tif (typeof uni === \"undefined\") return false;\n\tif (\n\t\tuni === null ||\n\t\ttypeof uni.getStorageSync !== \"function\" ||\n\t\ttypeof uni.getStorageInfoSync !== \"function\" ||\n\t\ttypeof uni.removeStorageSync !== \"function\" ||\n\t\ttypeof uni.setStorageSync !== \"function\"\n\t) {\n\t\tthrow new TypeError(\"The global uni object does not provide synchronous Storage APIs.\");\n\t}\n\treturn true;\n};\n\n/** 默认 JSON Codec;显式拒绝会被 JSON.stringify 静默丢弃的顶层值。 */\nconst jsonCodec: StorageCodec = {\n\tdecode: (value) => JSON.parse(value) as unknown,\n\tencode: (value) => {\n\t\tconst encoded = JSON.stringify(value);\n\t\tif (typeof encoded !== \"string\") throw new TypeError(\"The storage value cannot be serialized as JSON.\");\n\t\treturn encoded;\n\t},\n};\n\n/** Base64 混淆 Codec;只隐藏明文外观,不提供加密、完整性或认证。 */\nexport const base64StorageCodec: StorageCodec = {\n\tdecode: (value) => JSON.parse(decodeSecureBase64(value)) as unknown,\n\tencode: (value) => {\n\t\tconst encoded = JSON.stringify(value);\n\t\tif (typeof encoded !== \"string\") throw new TypeError(\"The storage value cannot be serialized as JSON.\");\n\t\treturn encodeSecureBase64(encoded);\n\t},\n};\n\n/** 页面级唯一配置;只允许幂等重复配置,避免模块加载顺序改变行为。 */\nlet activeConfiguration: ActiveStorageConfiguration | undefined;\n\n/**\n * 判断未知值是否为非数组对象记录。\n *\n * @param value - JSON.parse 返回的未知值\n * @returns 值为非空、非数组对象时返回 `true`。\n */\nconst isRecord = (value: unknown): value is Record<string, unknown> => typeof value === \"object\" && value !== null && !Array.isArray(value);\n\n/**\n * 校验 Storage 业务键。\n *\n * @param key - 不含全局 Prefix 的业务键或业务键前缀\n * @throws `TypeError` 当值不是非空字符串。\n */\nconst assertKey = (key: string): void => {\n\tif (typeof key !== \"string\" || key.length === 0) throw new TypeError(\"Storage keys must be nonempty strings.\");\n};\n\n/**\n * 创建浏览器 Storage 后端。\n *\n * @remarks 平台对象在调用阶段读取,因此导入模块不会访问浏览器全局对象。\n * @param kind - 选择 `localStorage` 或 `sessionStorage`。\n * @returns 统一的内部同步后端\n * @throws `Error` 当所选 Storage 在当前环境不可用。\n */\nconst createWebStorageBackend = (kind: \"local\" | \"session\"): StorageBackend => {\n\tconst storage =\n\t\tkind === \"local\"\n\t\t\t? typeof localStorage === \"undefined\"\n\t\t\t\t? undefined\n\t\t\t\t: localStorage\n\t\t\t: typeof sessionStorage === \"undefined\"\n\t\t\t\t? undefined\n\t\t\t\t: sessionStorage;\n\tif (storage === undefined) throw new Error(`The current runtime does not support ${kind}Storage.`);\n\treturn {\n\t\tgetItem: (key) => storage.getItem(key),\n\t\tkeys: () => {\n\t\t\tconst keys: string[] = [];\n\t\t\tfor (let index = 0; index < storage.length; index += 1) {\n\t\t\t\tconst key = storage.key(index);\n\t\t\t\tif (key !== null) keys.push(key);\n\t\t\t}\n\t\t\treturn keys;\n\t\t},\n\t\tremoveItem: (key) => {\n\t\t\tstorage.removeItem(key);\n\t\t},\n\t\tsetItem: (key, value) => {\n\t\t\tstorage.setItem(key, value);\n\t\t},\n\t};\n};\n\n/**\n * 把 uni-app 同步 Storage 适配为内部后端。\n *\n * @remarks uni-app 以空字符串同时表示“键缺失”和“真实空值”,因此空字符串需要结合键清单消除歧义。\n * @returns 统一的内部同步后端\n */\nconst createUniStorageBackend = (): StorageBackend => ({\n\tgetItem: (key) => {\n\t\tconst value: unknown = uni.getStorageSync(key);\n\t\tif (value !== \"\") return value;\n\t\treturn uni.getStorageInfoSync().keys.includes(key) ? value : undefined;\n\t},\n\tkeys: () => [...uni.getStorageInfoSync().keys],\n\tremoveItem: (key) => {\n\t\tuni.removeStorageSync(key);\n\t},\n\tsetItem: (key, value) => {\n\t\tuni.setStorageSync(key, value);\n\t},\n});\n\n/**\n * 解析并校验版本化 Storage 包络。\n *\n * @param rawValue - 后端返回的原始值\n * @param key - 用于错误定位的完整物理键\n * @returns 当前 v3 包络\n * @throws `TypeError` 当原始值不是字符串、JSON 损坏、版本不支持或字段类型非法。\n */\nconst parseStoredEnvelope = (rawValue: unknown, key: string): StoredEnvelope => {\n\tif (typeof rawValue !== \"string\") throw new TypeError(`Storage entry \"${key}\" is not a string.`);\n\ttry {\n\t\tconst parsed = JSON.parse(rawValue) as unknown;\n\t\tif (\n\t\t\t!isRecord(parsed) ||\n\t\t\tparsed[\"version\"] !== 3 ||\n\t\t\ttypeof parsed[\"data\"] !== \"string\" ||\n\t\t\t!(parsed[\"expiresAt\"] === null || (typeof parsed[\"expiresAt\"] === \"number\" && Number.isFinite(parsed[\"expiresAt\"])))\n\t\t) {\n\t\t\tthrow new TypeError(\"Unsupported storage envelope.\");\n\t\t}\n\t\treturn { data: parsed[\"data\"], expiresAt: parsed[\"expiresAt\"], version: 3 };\n\t} catch (cause) {\n\t\tthrow new TypeError(`Storage entry \"${key}\" is corrupted or unsupported.`, { cause });\n\t}\n};\n\n/**\n * 创建绑定命名空间、Codec 与时钟的 Storage Area。\n *\n * @param backendFactory - 每次操作时解析平台后端的工厂,保证导入安全并反映平台可用性。\n * @param prefix - 已校验的全局物理键前缀\n * @param codec - 业务值与包络文本之间的 Codec\n * @param now - TTL 计算使用的可注入时钟\n * @returns 完整的命名空间 Storage 操作集合\n */\nconst createStorageArea = (backendFactory: () => StorageBackend, prefix: string, codec: StorageCodec, now: () => number): StorageArea => {\n\t/**\n\t * 拼接物理键。\n\t *\n\t * @param key - 已校验业务键\n\t * @returns 带当前命名空间前缀的物理键\n\t */\n\tconst toStorageKey = (key: string) => `${prefix}${key}`;\n\t/**\n\t * 解析本次读写实际使用的 Codec。\n\t *\n\t * @param crypto - 单次 Base64 混淆开关;省略时沿用 Area 全局 Codec。\n\t * @returns 本次操作使用的全局、JSON 或 Base64 Codec\n\t * @throws `TypeError` 当 JavaScript 调用方传入非布尔值。\n\t */\n\tconst resolveOperationCodec = (crypto: boolean | undefined) => {\n\t\tif (crypto === undefined) return codec;\n\t\tif (typeof crypto !== \"boolean\") throw new TypeError(\"The per-operation Storage `crypto` option must be a boolean.\");\n\t\treturn crypto ? base64StorageCodec : jsonCodec;\n\t};\n\t/**\n\t * 枚举当前命名空间中的业务键。\n\t *\n\t * @param backend - 本次操作使用的后端\n\t * @returns 已移除物理前缀、去重并排序的业务键\n\t * @throws `TypeError` 当后端返回非字符串键。\n\t */\n\tconst listBusinessKeys = (backend: StorageBackend) => {\n\t\tconst keys = backend.keys();\n\t\tif (!Array.isArray(keys) || !keys.every((key) => typeof key === \"string\")) {\n\t\t\tthrow new TypeError(\"Keys returned by the Storage backend must be strings.\");\n\t\t}\n\t\treturn [...new Set(keys.filter((key) => key.startsWith(prefix)).map((key) => key.slice(prefix.length)))].sort();\n\t};\n\t/**\n\t * 读取并处理单个包络。\n\t *\n\t * @param backend - 本次操作使用的后端\n\t * @param key - 业务键\n\t * @returns 未过期包络;键缺失或已经过期时返回 `undefined`。\n\t * @throws `TypeError` 当键或包络非法。\n\t * @throws `RangeError` 当注入时钟返回非有限时间戳。\n\t */\n\tconst readStoredEnvelope = (backend: StorageBackend, key: string): StoredEnvelope | undefined => {\n\t\tassertKey(key);\n\t\tconst storageKey = toStorageKey(key);\n\t\tconst rawValue = backend.getItem(storageKey);\n\t\tif (rawValue === null || rawValue === undefined) return undefined;\n\t\tconst envelope = parseStoredEnvelope(rawValue, storageKey);\n\t\tif (envelope.expiresAt === null) return envelope;\n\t\tconst timestamp = now();\n\t\tif (!Number.isFinite(timestamp)) throw new RangeError(\"The Storage clock must return a finite timestamp.\");\n\t\tif (timestamp < envelope.expiresAt) return envelope;\n\t\t// 过期项在读取时立即删除,后续 has/keys/pruneExpired 观察到一致状态。\n\t\tbackend.removeItem(storageKey);\n\t\treturn undefined;\n\t};\n\n\treturn {\n\t\tprefix,\n\t\tclear() {\n\t\t\tconst backend = backendFactory();\n\t\t\tfor (const key of listBusinessKeys(backend)) backend.removeItem(toStorageKey(key));\n\t\t},\n\t\tget<Value>(key: string, options: StorageReadOptions = {}): Value | undefined {\n\t\t\tconst envelope = readStoredEnvelope(backendFactory(), key);\n\t\t\tif (envelope === undefined) return undefined;\n\t\t\ttry {\n\t\t\t\treturn resolveOperationCodec(options.crypto).decode(envelope.data) as Value;\n\t\t\t} catch (cause) {\n\t\t\t\tthrow new TypeError(`Unable to decode Storage entry \"${toStorageKey(key)}\".`, { cause });\n\t\t\t}\n\t\t},\n\t\thas: (key) => readStoredEnvelope(backendFactory(), key) !== undefined,\n\t\tkeys: () => listBusinessKeys(backendFactory()),\n\t\tpruneExpired() {\n\t\t\tconst backend = backendFactory();\n\t\t\tlet removed = 0;\n\t\t\tfor (const key of listBusinessKeys(backend)) {\n\t\t\t\t// read 同时处理删除;先读取一次用于区分“原本缺失”和“本轮因过期删除”。\n\t\t\t\tconst before = backend.getItem(toStorageKey(key));\n\t\t\t\tif (before !== null && before !== undefined && readStoredEnvelope(backend, key) === undefined) removed += 1;\n\t\t\t}\n\t\t\treturn removed;\n\t\t},\n\t\tremove(key: string) {\n\t\t\tassertKey(key);\n\t\t\tbackendFactory().removeItem(toStorageKey(key));\n\t\t},\n\t\tremoveByPrefix(keyPrefix: string) {\n\t\t\tassertKey(keyPrefix);\n\t\t\tconst backend = backendFactory();\n\t\t\tfor (const key of listBusinessKeys(backend)) if (key.startsWith(keyPrefix)) backend.removeItem(toStorageKey(key));\n\t\t},\n\t\tset<Value>(key: string, value: Value, options: StorageWriteOptions = {}) {\n\t\t\tassertKey(key);\n\t\t\tif (value === undefined) throw new TypeError(\"Cannot store top-level `undefined`; remove the key instead.\");\n\t\t\tlet expiresAt: number | null = null;\n\t\t\tif (options.ttlMs !== undefined) {\n\t\t\t\tif (!Number.isFinite(options.ttlMs) || options.ttlMs <= 0) throw new RangeError(\"`ttlMs` must be a finite number greater than 0.\");\n\t\t\t\tconst timestamp = now();\n\t\t\t\tif (!Number.isFinite(timestamp) || !Number.isFinite(timestamp + options.ttlMs)) {\n\t\t\t\t\tthrow new RangeError(\"The Storage expiration time exceeds the supported timestamp range.\");\n\t\t\t\t}\n\t\t\t\texpiresAt = timestamp + options.ttlMs;\n\t\t\t}\n\t\t\tlet data: string;\n\t\t\ttry {\n\t\t\t\tdata = resolveOperationCodec(options.crypto).encode(value);\n\t\t\t\tif (typeof data !== \"string\") throw new TypeError(\"The Storage codec must return a string.\");\n\t\t\t} catch (cause) {\n\t\t\t\tthrow new TypeError(\"Unable to encode the storage value.\", { cause });\n\t\t\t}\n\t\t\tbackendFactory().setItem(toStorageKey(key), JSON.stringify({ data, expiresAt, version: 3 } satisfies StoredEnvelope));\n\t\t},\n\t};\n};\n\n/**\n * 获取已激活的全局 Storage 配置。\n *\n * @returns 显式配置或首次 Storage 操作创建的默认配置\n */\nconst requireStorageConfiguration = (): ActiveStorageConfiguration => {\n\tif (activeConfiguration === undefined) configureStorage();\n\tif (activeConfiguration === undefined) throw new Error(\"Unable to initialize the Storage configuration.\");\n\treturn activeConfiguration;\n};\n\n/**\n * 创建稳定的公开 Storage 门面。\n *\n * @param select - 从激活配置选择 Local 或 Session 的函数\n * @param name - 用于不可用错误的公开门面名称\n * @returns 可安全导入、并在首次调用时解析默认或显式配置的稳定对象。\n */\nconst createStorageAreaProxy = (select: (configuration: ActiveStorageConfiguration) => StorageArea | undefined, name: string): StorageArea => {\n\t/**\n\t * 解析当前实际 Area。\n\t *\n\t * @returns 配置中的 Local 或 Session Area\n\t * @throws `Error` 当 uni-app 模式请求 Session。\n\t */\n\tconst getArea = () => {\n\t\tconst area = select(requireStorageConfiguration());\n\t\tif (area === undefined) throw new Error(`${name} is not supported in uni-app.`);\n\t\treturn area;\n\t};\n\treturn {\n\t\tget prefix() {\n\t\t\treturn getArea().prefix;\n\t\t},\n\t\tclear: () => {\n\t\t\tgetArea().clear();\n\t\t},\n\t\tget: <Value>(key: string, options?: StorageReadOptions): Value | undefined => getArea().get<Value>(key, options),\n\t\thas: (key) => getArea().has(key),\n\t\tkeys: () => getArea().keys(),\n\t\tpruneExpired: () => getArea().pruneExpired(),\n\t\tremove: (key) => {\n\t\t\tgetArea().remove(key);\n\t\t},\n\t\tremoveByPrefix: (keyPrefix) => {\n\t\t\tgetArea().removeByPrefix(keyPrefix);\n\t\t},\n\t\tset: <Value>(key: string, value: Value, options?: StorageWriteOptions) => {\n\t\t\tgetArea().set(key, value, options);\n\t\t},\n\t};\n};\n\n/** 浏览器 localStorage 或自动检测的 uni-app Storage 全局业务入口。 */\nexport const Local: StorageArea = createStorageAreaProxy((configuration) => configuration.local, \"Local\");\n\n/** 浏览器 sessionStorage 的全局业务入口;uni-app 不提供会话存储。 */\nexport const Session: StorageArea = createStorageAreaProxy((configuration) => configuration.session, \"Session\");\n\n/**\n * 在首次 Storage 操作前可选配置 `Local` 与 `Session`。\n *\n * @remarks 不调用时在首次操作上使用 `fast__`、JSON Codec 与 `Date.now`。首次激活后只允许以完全相同的值和引用重复调用。若检测到\n * 全局 `uni`,则自动使用其同步 Storage 且只启用 `Local`,否则使用浏览器 `localStorage` 与 `sessionStorage`。\n * `crypto: true` 仅执行可逆 Base64 混淆,不能保护敏感数据。\n * @param options - 可选的全局键前缀、Codec、Base64 混淆选项与时钟。\n * @throws 配置非法、重复配置冲突或目标平台 Storage 不可用时抛出错误。\n */\nexport function configureStorage(options: StorageConfiguration = {}): void {\n\tconst prefix = options.prefix ?? \"fast__\";\n\tif (typeof prefix !== \"string\" || prefix.length === 0) {\n\t\tthrow new TypeError(\"The Storage prefix must be a nonempty string.\");\n\t}\n\tif (options.codec !== undefined && options.crypto === true) {\n\t\tthrow new TypeError(\"Storage codec and crypto options cannot be used together.\");\n\t}\n\tconst codec = options.codec ?? (options.crypto === true ? base64StorageCodec : jsonCodec);\n\tconst now = options.now ?? Date.now;\n\tif (activeConfiguration !== undefined) {\n\t\t// 相同配置允许多个入口模块幂等调用;任何引用或值变化都视为冲突。\n\t\tif (activeConfiguration.prefix === prefix && activeConfiguration.codec === codec && activeConfiguration.now === now) {\n\t\t\treturn;\n\t\t}\n\t\tthrow new Error(\"Storage is already configured with different options.\");\n\t}\n\tconst usesUniStorage = hasGlobalUniStorage();\n\tconst localBackend = usesUniStorage ? () => createUniStorageBackend() : () => createWebStorageBackend(\"local\");\n\tconst local = createStorageArea(localBackend, prefix, codec, now);\n\tconst configuration: ActiveStorageConfiguration = { codec, local, now, prefix };\n\tif (!usesUniStorage) {\n\t\tconfiguration.session = createStorageArea(() => createWebStorageBackend(\"session\"), prefix, codec, now);\n\t}\n\tactiveConfiguration = configuration;\n}\n\n/** 返回 Storage 是否已经显式配置,或由首次 Storage 操作激活默认配置。 */\nexport function isStorageConfigured(): boolean {\n\treturn activeConfiguration !== undefined;\n}\n"],"mappings":";;;;;;;;AA+IA,MAAM,4BAAqC;CAC1C,IAAI,OAAO,QAAQ,aAAa,OAAO;CACvC,IACC,QAAQ,QACR,OAAO,IAAI,mBAAmB,cAC9B,OAAO,IAAI,uBAAuB,cAClC,OAAO,IAAI,sBAAsB,cACjC,OAAO,IAAI,mBAAmB,YAE9B,MAAM,IAAI,UAAU,kEAAkE;CAEvF,OAAO;AACR;;AAGA,MAAM,YAA0B;CAC/B,SAAS,UAAU,KAAK,MAAM,KAAK;CACnC,SAAS,UAAU;EAClB,MAAM,UAAU,KAAK,UAAU,KAAK;EACpC,IAAI,OAAO,YAAY,UAAU,MAAM,IAAI,UAAU,iDAAiD;EACtG,OAAO;CACR;AACD;;AAGA,MAAa,qBAAmC;CAC/C,SAAS,UAAU,KAAK,MAAM,mBAAmB,KAAK,CAAC;CACvD,SAAS,UAAU;EAClB,MAAM,UAAU,KAAK,UAAU,KAAK;EACpC,IAAI,OAAO,YAAY,UAAU,MAAM,IAAI,UAAU,iDAAiD;EACtG,OAAO,mBAAmB,OAAO;CAClC;AACD;;AAGA,IAAI;;;;;;;AAQJ,MAAM,YAAY,UAAqD,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;;;;;;;AAQ1I,MAAM,aAAa,QAAsB;CACxC,IAAI,OAAO,QAAQ,YAAY,IAAI,WAAW,GAAG,MAAM,IAAI,UAAU,wCAAwC;AAC9G;;;;;;;;;AAUA,MAAM,2BAA2B,SAA8C;CAC9E,MAAM,UACL,SAAS,UACN,OAAO,iBAAiB,cACvB,KAAA,IACA,eACD,OAAO,mBAAmB,cACzB,KAAA,IACA;CACL,IAAI,YAAY,KAAA,GAAW,MAAM,IAAI,MAAM,wCAAwC,KAAK,SAAS;CACjG,OAAO;EACN,UAAU,QAAQ,QAAQ,QAAQ,GAAG;E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