@shwfed/nuxt 0.1.72 → 0.1.74

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.74",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -31,6 +31,7 @@ const {
31
31
  }
32
32
  } = useRuntimeConfig();
33
33
  useHead({
34
+ title: () => active.value && getTabLabel(active.value),
34
35
  bodyAttrs: {
35
36
  style: {
36
37
  "--primary": "#2DA8BC",
@@ -51,23 +52,24 @@ const { start: startProfileCloseTimer, stop: stopProfileCloseTimer } = useTimeou
51
52
  const { meta_k } = useMagicKeys();
52
53
  whenever(() => meta_k?.value, () => ui.isCommandPaletteOpen = !ui.isCommandPaletteOpen);
53
54
  setGlobalDslContext(await props.dsl?.pipe(Effect.scoped).pipe(Effect.runPromise) ?? {});
55
+ const navigationItem = 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 navigationGroup = z.object({
63
+ id: z.union([z.string(), z.number()]),
64
+ title: z.string(),
65
+ icon: z.string().optional(),
66
+ children: z.array(navigationItem)
67
+ });
68
+ const navigationEntry = z.union([navigationGroup, navigationItem]);
54
69
  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
70
  try {
69
71
  const result = $dsl.evaluate`${config.sidebar.menus}`();
70
- return z.array(z.union([group, item])).parse(result);
72
+ return z.array(navigationEntry).parse(result);
71
73
  } catch {
72
74
  return [];
73
75
  }
@@ -80,16 +82,8 @@ const {
80
82
  } = useFavorite("navigation", navigationItems);
81
83
  const isNavigationItemActive = (itemRoute) => isRouteActive(route.path, itemRoute);
82
84
  const getTabLabel = (tab) => {
83
- return resolveNavigationTitle(navigations.value, tab);
85
+ return resolveNavigationTitle(navigationItems.value, tab);
84
86
  };
85
- const activeTabLabel = computed(() => {
86
- if (active.value === void 0)
87
- return void 0;
88
- return getTabLabel(active.value);
89
- });
90
- useHead(() => ({
91
- title: activeTabLabel.value
92
- }));
93
87
  const profileName = computed(() => {
94
88
  if (config.profile.name === void 0)
95
89
  return t("profile");
@@ -173,6 +167,18 @@ const profileCommands = computed(() => {
173
167
  return [];
174
168
  }
175
169
  });
170
+ const isBodyInit = (value) => {
171
+ return typeof value === "string" || value instanceof Blob || value instanceof ArrayBuffer || ArrayBuffer.isView(value) || value instanceof FormData || value instanceof URLSearchParams || value instanceof ReadableStream;
172
+ };
173
+ const toApiRequestBody = (value) => {
174
+ if (value === void 0 || value === null)
175
+ return value;
176
+ if (isBodyInit(value))
177
+ return value;
178
+ if (typeof value === "object")
179
+ return value;
180
+ return void 0;
181
+ };
176
182
  const executeCommandEffect = async (effect) => {
177
183
  if (effect === void 0)
178
184
  return false;
@@ -189,7 +195,7 @@ const executeCommandEffect = async (effect) => {
189
195
  logout: $logout,
190
196
  request: async (requestAction) => $api(requestAction.url, {
191
197
  method: requestAction.method,
192
- body: requestAction.body,
198
+ body: toApiRequestBody(requestAction.body),
193
199
  query: requestAction.query,
194
200
  headers: requestAction.headers
195
201
  })
@@ -207,7 +213,14 @@ const executeProfileCommand = async (effect) => {
207
213
  if (effect === void 0 || await executeCommandEffect(effect))
208
214
  ui.isProfileDropdownOpen = false;
209
215
  };
210
- const paletteNavigation = computed(() => splitNavigationForPalette(navigations.value));
216
+ const normalizedNavigationForPalette = computed(() => {
217
+ try {
218
+ return z.array(navigationEntry).parse(navigations.value);
219
+ } catch {
220
+ return navigationItems.value;
221
+ }
222
+ });
223
+ const paletteNavigation = computed(() => splitNavigationForPalette(normalizedNavigationForPalette.value));
211
224
  const favoriteRoutesForPalette = computed(() => paletteNavigation.value.favoriteRoutes);
212
225
  const navigationForPalette = computed(() => paletteNavigation.value.navigationEntries);
213
226
  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.74",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",