@hlw-uni-mp/use 1.1.0 → 1.1.1

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/dist/index.d.mts CHANGED
@@ -1,5 +1,4 @@
1
1
  import * as pinia from 'pinia';
2
- import { PiniaPluginContext } from 'pinia';
3
2
  import { App, Ref, ComputedRef } from 'vue';
4
3
 
5
4
  /**
@@ -63,28 +62,13 @@ declare const hlw: {
63
62
  };
64
63
  type HlwInstance = typeof hlw;
65
64
 
66
- /**
67
- * 持久化配置项
68
- */
69
- interface PersistOptions {
70
- /** 自定义本地存储键名,默认为 store.$id */
71
- key?: string;
72
- /** 持久化白名单字段列表,默认持久化全部 state */
73
- paths?: string[];
74
- }
75
-
76
65
  declare module "pinia" {
77
66
  interface DefineStoreOptionsBase<S, Store> {
78
67
  /** 本地持久化配置 */
79
- unistorage?: boolean | PersistOptions;
68
+ unistorage?: boolean | object;
80
69
  }
81
70
  }
82
71
 
83
- /**
84
- * 创建 Pinia 本地持久化存储插件
85
- */
86
- declare function storage(): (context: PiniaPluginContext) => void;
87
-
88
72
  /**
89
73
  * 外观模式型
90
74
  */
@@ -272,4 +256,4 @@ interface UseRefsReturn<T = unknown> {
272
256
  */
273
257
  declare function useRefs<T = unknown>(): UseRefsReturn<T>;
274
258
 
275
- export { DEFAULT_THEME, type FontFamily, type FontFamilyPreset, type FontSize, type FontSizePreset, type HlwInstance, type HlwMsg, type InitThemeOptions, type PersistOptions, type ShareConfig, type ShareHandlers, THEME_COLORS, type ThemeColor, type ThemeMode, type ThemeState, type ToastCallback, type ToastRes, type UseRefsReturn, applyTheme, fontFamilyPresets, fontSizePresets, getTheme, hlw, initTheme, showShareMenu, storage, useMsg, useRefs, useShare, useTheme, useThemeStore };
259
+ export { DEFAULT_THEME, type FontFamily, type FontFamilyPreset, type FontSize, type FontSizePreset, type HlwInstance, type HlwMsg, type InitThemeOptions, type ShareConfig, type ShareHandlers, THEME_COLORS, type ThemeColor, type ThemeMode, type ThemeState, type ToastCallback, type ToastRes, type UseRefsReturn, applyTheme, fontFamilyPresets, fontSizePresets, getTheme, hlw, initTheme, showShareMenu, useMsg, useRefs, useShare, useTheme, useThemeStore };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import * as pinia from 'pinia';
2
- import { PiniaPluginContext } from 'pinia';
3
2
  import { App, Ref, ComputedRef } from 'vue';
4
3
 
5
4
  /**
@@ -63,28 +62,13 @@ declare const hlw: {
63
62
  };
64
63
  type HlwInstance = typeof hlw;
65
64
 
66
- /**
67
- * 持久化配置项
68
- */
69
- interface PersistOptions {
70
- /** 自定义本地存储键名,默认为 store.$id */
71
- key?: string;
72
- /** 持久化白名单字段列表,默认持久化全部 state */
73
- paths?: string[];
74
- }
75
-
76
65
  declare module "pinia" {
77
66
  interface DefineStoreOptionsBase<S, Store> {
78
67
  /** 本地持久化配置 */
79
- unistorage?: boolean | PersistOptions;
68
+ unistorage?: boolean | object;
80
69
  }
81
70
  }
82
71
 
83
- /**
84
- * 创建 Pinia 本地持久化存储插件
85
- */
86
- declare function storage(): (context: PiniaPluginContext) => void;
87
-
88
72
  /**
89
73
  * 外观模式型
90
74
  */
@@ -272,4 +256,4 @@ interface UseRefsReturn<T = unknown> {
272
256
  */
273
257
  declare function useRefs<T = unknown>(): UseRefsReturn<T>;
274
258
 
275
- export { DEFAULT_THEME, type FontFamily, type FontFamilyPreset, type FontSize, type FontSizePreset, type HlwInstance, type HlwMsg, type InitThemeOptions, type PersistOptions, type ShareConfig, type ShareHandlers, THEME_COLORS, type ThemeColor, type ThemeMode, type ThemeState, type ToastCallback, type ToastRes, type UseRefsReturn, applyTheme, fontFamilyPresets, fontSizePresets, getTheme, hlw, initTheme, showShareMenu, storage, useMsg, useRefs, useShare, useTheme, useThemeStore };
259
+ export { DEFAULT_THEME, type FontFamily, type FontFamilyPreset, type FontSize, type FontSizePreset, type HlwInstance, type HlwMsg, type InitThemeOptions, type ShareConfig, type ShareHandlers, THEME_COLORS, type ThemeColor, type ThemeMode, type ThemeState, type ToastCallback, type ToastRes, type UseRefsReturn, applyTheme, fontFamilyPresets, fontSizePresets, getTheme, hlw, initTheme, showShareMenu, useMsg, useRefs, useShare, useTheme, useThemeStore };
package/dist/index.js CHANGED
@@ -29,7 +29,6 @@ __export(index_exports, {
29
29
  hlw: () => hlw,
30
30
  initTheme: () => initTheme,
31
31
  showShareMenu: () => showShareMenu,
32
- storage: () => storage,
33
32
  useMsg: () => useMsg,
34
33
  useRefs: () => useRefs,
35
34
  useShare: () => useShare,
@@ -148,48 +147,9 @@ var import_vue = require("vue");
148
147
  // src/theme/store.ts
149
148
  var import_pinia2 = require("pinia");
150
149
 
151
- // src/storage/types.d.ts
150
+ // src/theme/types.d.ts
152
151
  var import_pinia = require("pinia");
153
152
 
154
- // src/storage/index.ts
155
- function storage() {
156
- return (context) => {
157
- const { store, options } = context;
158
- const config = options.unistorage;
159
- if (!config) return;
160
- const storageKey = typeof config === "object" && config?.key || store.$id;
161
- const paths = typeof config === "object" ? config?.paths : void 0;
162
- try {
163
- const cached = uni.getStorageSync(storageKey);
164
- if (cached) {
165
- const data = typeof cached === "string" ? JSON.parse(cached) : cached;
166
- if (typeof data === "object" && data !== null) {
167
- store.$patch(data);
168
- }
169
- }
170
- } catch (error) {
171
- console.error(`[Storage] \u6062\u590D ${store.$id} \u5931\u8D25:`, error);
172
- }
173
- store.$subscribe(
174
- (_, state) => {
175
- try {
176
- let toSave = state;
177
- if (paths && Array.isArray(paths)) {
178
- toSave = paths.reduce((acc, key) => {
179
- if (key in state) acc[key] = state[key];
180
- return acc;
181
- }, {});
182
- }
183
- uni.setStorageSync(storageKey, toSave);
184
- } catch (error) {
185
- console.error(`[Storage] \u4FDD\u5B58 ${store.$id} \u5931\u8D25:`, error);
186
- }
187
- },
188
- { detached: true }
189
- );
190
- };
191
- }
192
-
193
153
  // src/theme/store.ts
194
154
  var fontSizePresets = [
195
155
  {
@@ -396,7 +356,6 @@ function useRefs() {
396
356
  hlw,
397
357
  initTheme,
398
358
  showShareMenu,
399
- storage,
400
359
  useMsg,
401
360
  useRefs,
402
361
  useShare,
package/dist/index.mjs CHANGED
@@ -108,48 +108,9 @@ import { computed, toRef } from "vue";
108
108
  // src/theme/store.ts
109
109
  import { defineStore } from "pinia";
110
110
 
111
- // src/storage/types.d.ts
111
+ // src/theme/types.d.ts
112
112
  import "pinia";
113
113
 
114
- // src/storage/index.ts
115
- function storage() {
116
- return (context) => {
117
- const { store, options } = context;
118
- const config = options.unistorage;
119
- if (!config) return;
120
- const storageKey = typeof config === "object" && config?.key || store.$id;
121
- const paths = typeof config === "object" ? config?.paths : void 0;
122
- try {
123
- const cached = uni.getStorageSync(storageKey);
124
- if (cached) {
125
- const data = typeof cached === "string" ? JSON.parse(cached) : cached;
126
- if (typeof data === "object" && data !== null) {
127
- store.$patch(data);
128
- }
129
- }
130
- } catch (error) {
131
- console.error(`[Storage] \u6062\u590D ${store.$id} \u5931\u8D25:`, error);
132
- }
133
- store.$subscribe(
134
- (_, state) => {
135
- try {
136
- let toSave = state;
137
- if (paths && Array.isArray(paths)) {
138
- toSave = paths.reduce((acc, key) => {
139
- if (key in state) acc[key] = state[key];
140
- return acc;
141
- }, {});
142
- }
143
- uni.setStorageSync(storageKey, toSave);
144
- } catch (error) {
145
- console.error(`[Storage] \u4FDD\u5B58 ${store.$id} \u5931\u8D25:`, error);
146
- }
147
- },
148
- { detached: true }
149
- );
150
- };
151
- }
152
-
153
114
  // src/theme/store.ts
154
115
  var fontSizePresets = [
155
116
  {
@@ -355,7 +316,6 @@ export {
355
316
  hlw,
356
317
  initTheme,
357
318
  showShareMenu,
358
- storage,
359
319
  useMsg,
360
320
  useRefs,
361
321
  useShare,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hlw-uni-mp/use",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Universal Uni-App Vue 3 stateful composables library",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",