@shwfed/nuxt 0.1.26 → 0.1.28

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.26",
4
+ "version": "0.1.28",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -1,23 +1,29 @@
1
- export type NavigationCommand = Readonly<{
2
- type: 'navigation';
3
- id: string;
4
- title: string;
5
- icon?: string;
6
- path: string;
7
- }>;
8
- export type APICommand = Readonly<{
9
- type: 'api';
10
- id: string;
11
- title: string;
12
- icon?: string;
13
- }>;
14
- export type Command = NavigationCommand | APICommand;
1
+ import type { Scope } from 'effect';
2
+ import { Effect } from 'effect';
15
3
  declare const _default: typeof __VLS_export;
16
4
  export default _default;
17
5
  declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
18
- commands?: ReadonlyArray<Command>;
6
+ commands?: ReadonlyArray<Readonly<{
7
+ id: string;
8
+ title: string;
9
+ children: ReadonlyArray<Readonly<{
10
+ id: string;
11
+ title: string;
12
+ icon?: string;
13
+ effect: Effect.Effect<void, never, Scope.Scope>;
14
+ }>>;
15
+ }>>;
19
16
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
20
- commands?: ReadonlyArray<Command>;
17
+ commands?: ReadonlyArray<Readonly<{
18
+ id: string;
19
+ title: string;
20
+ children: ReadonlyArray<Readonly<{
21
+ id: string;
22
+ title: string;
23
+ icon?: string;
24
+ effect: Effect.Effect<void, never, Scope.Scope>;
25
+ }>>;
26
+ }>>;
21
27
  }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
22
28
  default?: (props: {}) => any;
23
29
  }>;
@@ -1,16 +1,17 @@
1
1
  <script>
2
- import { useHead, useRouter } from "#app";
2
+ import { useHead } from "#app";
3
3
  import { ref } from "vue";
4
4
  import { CommandDialog, CommandInput, CommandList, CommandGroup, CommandEmpty, CommandItem, CommandSeparator } from "./ui/command";
5
5
  import { TooltipProvider } from "./ui/tooltip";
6
6
  import { Toaster } from "vue-sonner";
7
- import { useLocalStorage, useMagicKeys, whenever } from "@vueuse/core";
7
+ import { useMagicKeys, whenever } from "@vueuse/core";
8
8
  import { useI18n } from "vue-i18n";
9
9
  import { Icon } from "@iconify/vue";
10
+ import { Effect } from "effect";
10
11
  </script>
11
12
 
12
13
  <script setup>
13
- const props = defineProps({
14
+ defineProps({
14
15
  commands: { type: Array, required: false }
15
16
  });
16
17
  const { t } = useI18n();
@@ -26,29 +27,6 @@ const { meta_k } = useMagicKeys();
26
27
  whenever(() => meta_k?.value, () => {
27
28
  isCommandOpen.value = !isCommandOpen.value;
28
29
  });
29
- const router = useRouter();
30
- const recent = useLocalStorage("recent-commands", []);
31
- function addRecent(id) {
32
- if (recent.value.includes(id)) {
33
- recent.value.splice(recent.value.indexOf(id), 1);
34
- }
35
- recent.value.unshift(id);
36
- recent.value.splice(10);
37
- }
38
- async function handleCommandSelect(event) {
39
- const value = event.detail.value;
40
- const command = props.commands?.find((command2) => command2.title === value);
41
- if (!command) return;
42
- switch (command.type) {
43
- case "navigation":
44
- isCommandOpen.value = false;
45
- addRecent(command.id);
46
- await router.push(command.path);
47
- break;
48
- case "api":
49
- break;
50
- }
51
- }
52
30
  </script>
53
31
 
54
32
  <template>
@@ -73,40 +51,30 @@ async function handleCommandSelect(event) {
73
51
  </section>
74
52
  </CommandEmpty>
75
53
 
76
- <CommandGroup
77
- v-if="recent.length > 0"
78
- :heading="t('recent')"
54
+ <template
55
+ v-for="(group, i) in commands?.filter((group2) => group2.children.length > 0)"
56
+ :key="group.id"
79
57
  >
80
- <CommandItem
81
- v-for="command in commands"
82
- :key="command.title"
83
- :value="command.title"
84
- @select="handleCommandSelect"
85
- >
86
- <Icon
87
- v-if="command.icon"
88
- :icon="command.icon"
89
- />
90
- <span>{{ command.title }}</span>
91
- </CommandItem>
92
- </CommandGroup>
93
-
94
- <CommandSeparator v-if="recent.length > 0" />
95
-
96
- <CommandGroup :heading="t('navigation')">
97
- <CommandItem
98
- v-for="command in commands"
99
- :key="command.title"
100
- :value="command.title"
101
- @select="handleCommandSelect"
102
- >
103
- <Icon
104
- v-if="command.icon"
105
- :icon="command.icon"
106
- />
107
- <span>{{ command.title }}</span>
108
- </CommandItem>
109
- </CommandGroup>
58
+ <CommandGroup :heading="group.title">
59
+ <CommandItem
60
+ v-for="child in group.children"
61
+ :key="child.id"
62
+ :value="child.id"
63
+ @select="
64
+ child.effect.pipe(Effect.scoped).pipe(Effect.tap(() => {
65
+ isCommandOpen = false;
66
+ })).pipe(Effect.runPromise)
67
+ "
68
+ >
69
+ <Icon
70
+ v-if="child.icon"
71
+ :icon="child.icon"
72
+ />
73
+ <span>{{ child.title }}</span>
74
+ </CommandItem>
75
+ </CommandGroup>
76
+ <CommandSeparator v-if="i !== Object.keys(commands ?? {}).length - 1" />
77
+ </template>
110
78
  </CommandList>
111
79
  </CommandDialog>
112
80
  </ClientOnly>
@@ -117,19 +85,13 @@ async function handleCommandSelect(event) {
117
85
  <i18n lang="json">
118
86
  {
119
87
  "zh": {
120
- "command-palette-empty": "无搜索结果",
121
- "navigation": "导航",
122
- "recent": "最近访问"
88
+ "command-palette-empty": "无搜索结果"
123
89
  },
124
90
  "ja": {
125
- "command-palette-empty": "結果はありません",
126
- "navigation": "ナビゲーション",
127
- "recent": "最近使用"
91
+ "command-palette-empty": "結果はありません"
128
92
  },
129
93
  "en": {
130
- "command-palette-empty": "No results",
131
- "navigation": "Navigation",
132
- "recent": "Recent"
94
+ "command-palette-empty": "No results"
133
95
  }
134
96
  }
135
97
  </i18n>
@@ -1,23 +1,29 @@
1
- export type NavigationCommand = Readonly<{
2
- type: 'navigation';
3
- id: string;
4
- title: string;
5
- icon?: string;
6
- path: string;
7
- }>;
8
- export type APICommand = Readonly<{
9
- type: 'api';
10
- id: string;
11
- title: string;
12
- icon?: string;
13
- }>;
14
- export type Command = NavigationCommand | APICommand;
1
+ import type { Scope } from 'effect';
2
+ import { Effect } from 'effect';
15
3
  declare const _default: typeof __VLS_export;
16
4
  export default _default;
17
5
  declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
18
- commands?: ReadonlyArray<Command>;
6
+ commands?: ReadonlyArray<Readonly<{
7
+ id: string;
8
+ title: string;
9
+ children: ReadonlyArray<Readonly<{
10
+ id: string;
11
+ title: string;
12
+ icon?: string;
13
+ effect: Effect.Effect<void, never, Scope.Scope>;
14
+ }>>;
15
+ }>>;
19
16
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
20
- commands?: ReadonlyArray<Command>;
17
+ commands?: ReadonlyArray<Readonly<{
18
+ id: string;
19
+ title: string;
20
+ children: ReadonlyArray<Readonly<{
21
+ id: string;
22
+ title: string;
23
+ icon?: string;
24
+ effect: Effect.Effect<void, never, Scope.Scope>;
25
+ }>>;
26
+ }>>;
21
27
  }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
22
28
  default?: (props: {}) => any;
23
29
  }>;
@@ -8,7 +8,7 @@ export function createEnvironment(options) {
8
8
  homogeneousAggregateLiterals: false,
9
9
  unlistedVariablesAreDyn: true
10
10
  });
11
- env.registerType("Date", TZDate).registerVariable("now", "Date").registerFunction("date(string): Date", (date) => {
11
+ env.registerType("Date", TZDate).registerVariable("now", "Date").registerVariable("today", "Date").registerFunction("date(string): Date", (date) => {
12
12
  return new TZDate(date);
13
13
  }).registerOperator("Date < Date", (date1, date2) => {
14
14
  return isBefore(date1, date2);
@@ -20,7 +20,8 @@ export default defineNuxtPlugin({
20
20
  */
21
21
  evaluate: (...args) => (context) => {
22
22
  return env.evaluate(String.raw(...args), defu(context, {
23
- now: /* @__PURE__ */ new Date()
23
+ now: /* @__PURE__ */ new Date(),
24
+ today: /* @__PURE__ */ new Date()
24
25
  }));
25
26
  }
26
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -51,6 +51,7 @@
51
51
  "date-fns": "^4.1.0",
52
52
  "defu": "^6.1.4",
53
53
  "dot-prop": "^10.1.0",
54
+ "effect": "^3.19.15",
54
55
  "markdown-it": "^14.1.0",
55
56
  "reka-ui": "^2.7.0",
56
57
  "tailwind-merge": "^3.4.0",