@shwfed/nuxt 0.1.72 → 0.1.73

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/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
3
  "configKey": "shwfed",
4
- "version": "0.1.72",
4
+ "version": "0.1.73",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -51,23 +51,24 @@ const { start: startProfileCloseTimer, stop: stopProfileCloseTimer } = useTimeou
51
51
  const { meta_k } = useMagicKeys();
52
52
  whenever(() => meta_k?.value, () => ui.isCommandPaletteOpen = !ui.isCommandPaletteOpen);
53
53
  setGlobalDslContext(await props.dsl?.pipe(Effect.scoped).pipe(Effect.runPromise) ?? {});
54
+ const navigationItem = z.object({
55
+ id: z.union([z.string(), z.number()]),
56
+ title: z.string(),
57
+ icon: z.string().optional(),
58
+ route: z.string(),
59
+ keywords: z.array(z.string()).optional()
60
+ });
61
+ const navigationGroup = z.object({
62
+ id: z.union([z.string(), z.number()]),
63
+ title: z.string(),
64
+ icon: z.string().optional(),
65
+ children: z.array(navigationItem)
66
+ });
67
+ const navigationEntry = z.union([navigationGroup, navigationItem]);
54
68
  const navigationItems = computed(() => {
55
- const item = z.object({
56
- id: z.union([z.string(), z.number()]),
57
- title: z.string(),
58
- icon: z.string().optional(),
59
- route: z.string(),
60
- keywords: z.array(z.string()).optional()
61
- });
62
- const group = z.object({
63
- id: z.union([z.string(), z.number()]),
64
- title: z.string(),
65
- icon: z.string().optional(),
66
- children: z.array(item)
67
- });
68
69
  try {
69
70
  const result = $dsl.evaluate`${config.sidebar.menus}`();
70
- return z.array(z.union([group, item])).parse(result);
71
+ return z.array(navigationEntry).parse(result);
71
72
  } catch {
72
73
  return [];
73
74
  }
@@ -80,7 +81,7 @@ const {
80
81
  } = useFavorite("navigation", navigationItems);
81
82
  const isNavigationItemActive = (itemRoute) => isRouteActive(route.path, itemRoute);
82
83
  const getTabLabel = (tab) => {
83
- return resolveNavigationTitle(navigations.value, tab);
84
+ return resolveNavigationTitle(navigationItems.value, tab);
84
85
  };
85
86
  const activeTabLabel = computed(() => {
86
87
  if (active.value === void 0)
@@ -173,6 +174,18 @@ const profileCommands = computed(() => {
173
174
  return [];
174
175
  }
175
176
  });
177
+ const isBodyInit = (value) => {
178
+ return typeof value === "string" || value instanceof Blob || value instanceof ArrayBuffer || ArrayBuffer.isView(value) || value instanceof FormData || value instanceof URLSearchParams || value instanceof ReadableStream;
179
+ };
180
+ const toApiRequestBody = (value) => {
181
+ if (value === void 0 || value === null)
182
+ return value;
183
+ if (isBodyInit(value))
184
+ return value;
185
+ if (typeof value === "object")
186
+ return value;
187
+ return void 0;
188
+ };
176
189
  const executeCommandEffect = async (effect) => {
177
190
  if (effect === void 0)
178
191
  return false;
@@ -189,7 +202,7 @@ const executeCommandEffect = async (effect) => {
189
202
  logout: $logout,
190
203
  request: async (requestAction) => $api(requestAction.url, {
191
204
  method: requestAction.method,
192
- body: requestAction.body,
205
+ body: toApiRequestBody(requestAction.body),
193
206
  query: requestAction.query,
194
207
  headers: requestAction.headers
195
208
  })
@@ -207,7 +220,14 @@ const executeProfileCommand = async (effect) => {
207
220
  if (effect === void 0 || await executeCommandEffect(effect))
208
221
  ui.isProfileDropdownOpen = false;
209
222
  };
210
- const paletteNavigation = computed(() => splitNavigationForPalette(navigations.value));
223
+ const normalizedNavigationForPalette = computed(() => {
224
+ try {
225
+ return z.array(navigationEntry).parse(navigations.value);
226
+ } catch {
227
+ return navigationItems.value;
228
+ }
229
+ });
230
+ const paletteNavigation = computed(() => splitNavigationForPalette(normalizedNavigationForPalette.value));
211
231
  const favoriteRoutesForPalette = computed(() => paletteNavigation.value.favoriteRoutes);
212
232
  const navigationForPalette = computed(() => paletteNavigation.value.navigationEntries);
213
233
  const commandForPalette = computed(() => normalizeCommandsForPalette(profileCommands.value));
@@ -20,6 +20,31 @@ export function useFavorite(key, items) {
20
20
  const [id, of] = key2.split("::");
21
21
  return [id, of];
22
22
  };
23
+ if (key === "navigation" && typeof window !== "undefined" && typeof localStorage !== "undefined") {
24
+ const legacyStorageKey = "navigation-favorites";
25
+ const rawLegacy = localStorage.getItem(legacyStorageKey);
26
+ if (rawLegacy !== null) {
27
+ try {
28
+ const parsedLegacy = JSON.parse(rawLegacy);
29
+ if (Array.isArray(parsedLegacy)) {
30
+ const next = new Set(memo.value);
31
+ for (const entry of parsedLegacy) {
32
+ if (typeof entry !== "string") {
33
+ continue;
34
+ }
35
+ const [groupId, itemId, extra] = entry.split("::");
36
+ if (extra !== void 0 || groupId === void 0 || itemId === void 0 || groupId === "" || itemId === "") {
37
+ continue;
38
+ }
39
+ next.add(`${itemId}::${groupId}`);
40
+ }
41
+ memo.value = next;
42
+ localStorage.removeItem(legacyStorageKey);
43
+ }
44
+ } catch {
45
+ }
46
+ }
47
+ }
23
48
  return {
24
49
  favorite: (item, of) => {
25
50
  memo.value = new Set(memo.value).add(keyed(item, of));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
- "version": "0.1.72",
3
+ "version": "0.1.73",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",