@shwfed/nuxt 0.11.8 → 0.11.10

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.11.8",
4
+ "version": "0.11.10",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -261,7 +261,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
261
261
  style?: string | undefined;
262
262
  }>) => any) | undefined;
263
263
  "onInitial-value-ready"?: (() => any) | undefined;
264
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, Record<string, (_props?: FieldsSlotProps) => unknown>>;
264
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, Record<string, (_props: FieldsSlotProps) => unknown>>;
265
265
  type __VLS_WithSlots<T, S> = T & {
266
266
  new (): {
267
267
  $slots: S;
@@ -25,6 +25,12 @@ function handleConfigUpdate(config2) {
25
25
  function handleInitialValueReady() {
26
26
  emit("initial-value-ready");
27
27
  }
28
+ function requireSlotProps(slotProps) {
29
+ if (!slotProps) {
30
+ throw new TypeError("missing slot props");
31
+ }
32
+ return slotProps;
33
+ }
28
34
  const fieldsRef = ref(null);
29
35
  defineExpose(new Proxy({}, {
30
36
  get(_target, property) {
@@ -89,7 +95,7 @@ export {
89
95
  >
90
96
  <slot
91
97
  :name="slotName"
92
- v-bind="slotProps ?? {}"
98
+ v-bind="requireSlotProps(slotProps)"
93
99
  />
94
100
  </template>
95
101
  </UiFields>
@@ -261,7 +261,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
261
261
  style?: string | undefined;
262
262
  }>) => any) | undefined;
263
263
  "onInitial-value-ready"?: (() => any) | undefined;
264
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, Record<string, (_props?: FieldsSlotProps) => unknown>>;
264
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, Record<string, (_props: FieldsSlotProps) => unknown>>;
265
265
  type __VLS_WithSlots<T, S> = T & {
266
266
  new (): {
267
267
  $slots: S;
@@ -23,10 +23,7 @@ function handleOpenUpdate(sessionId, open) {
23
23
  if (open) {
24
24
  return;
25
25
  }
26
- overlay.closeSync(sessionId, {
27
- _tag: "OverlayAborted",
28
- reason: "dismiss"
29
- });
26
+ overlay.closeSync(sessionId);
30
27
  }
31
28
  const renderedSessions = computed(() => {
32
29
  const nextSessions = [];
@@ -95,7 +92,7 @@ const renderedSessions = computed(() => {
95
92
  props: session.props,
96
93
  shell: session.shell,
97
94
  sessionId: session.sessionId,
98
- close: (value) => overlay.closeSync(session.sessionId, value),
95
+ close: (...args) => overlay.closeSync(session.sessionId, ...args),
99
96
  patch: (nextProps) => overlay.patchSync(session.sessionId, { props: nextProps }),
100
97
  isDesktop: modalSlotProps.isDesktop
101
98
  }"
@@ -1,11 +1,6 @@
1
- import { Context, Deferred, Effect, type Scope } from 'effect';
1
+ import { Context, Deferred, Effect, Option, type Scope } from 'effect';
2
2
  import { type VNode } from 'vue';
3
- export type OverlayAbortReason = 'close-all' | 'definition' | 'dismiss' | 'owner' | 'scope';
4
- export type OverlayAborted = Readonly<{
5
- _tag: 'OverlayAborted';
6
- reason: OverlayAbortReason;
7
- }>;
8
- export type OverlayResult = OverlayAborted | unknown;
3
+ export type OverlayResult = Option.Option<unknown>;
9
4
  export type OverlayShellProps = Readonly<{
10
5
  title?: string;
11
6
  description?: string;
@@ -26,7 +21,7 @@ export type OverlaySlotProps = Readonly<{
26
21
  props: OverlayBodyProps;
27
22
  shell: OverlayShellProps;
28
23
  sessionId: string;
29
- close: (value?: unknown) => void;
24
+ close: (...args: [value?: unknown]) => void;
30
25
  patch: (nextProps: Record<string, unknown>) => void;
31
26
  isDesktop: boolean;
32
27
  }>;
@@ -50,7 +45,7 @@ type OverlaySession = {
50
45
  export type OverlayHandle = Readonly<{
51
46
  sessionId: string;
52
47
  patch: (patch: OverlaySessionPatch) => Effect.Effect<void>;
53
- close: (value?: unknown) => Effect.Effect<void>;
48
+ close: (...args: [value?: unknown]) => Effect.Effect<void>;
54
49
  result: Effect.Effect<OverlayResult>;
55
50
  }>;
56
51
  export type OverlayDefinitionNotFoundError = Readonly<{
@@ -66,24 +61,23 @@ export interface OverlayRuntime {
66
61
  syncDefinitions: (ownerId: string, definitions: Array<OverlayDefinition>) => void;
67
62
  isOpen: (sessionId: string) => boolean;
68
63
  patchSync: (sessionId: string, patch: OverlaySessionPatch) => void;
69
- closeSync: (sessionId: string, value?: unknown) => void;
64
+ closeSync: (sessionId: string, ...args: [value?: unknown]) => void;
70
65
  closeTopSync: () => void;
71
66
  closeAllSync: () => void;
72
67
  open: (definitionId: string, options?: OverlaySessionInput) => Effect.Effect<OverlayHandle, OverlayDefinitionNotFoundError, Scope.Scope>;
73
68
  patch: (sessionId: string, patch: OverlaySessionPatch) => Effect.Effect<void>;
74
- close: (sessionId: string, value?: unknown) => Effect.Effect<void>;
69
+ close: (sessionId: string, ...args: [value?: unknown]) => Effect.Effect<void>;
75
70
  closeTop: () => Effect.Effect<void>;
76
71
  closeAll: () => Effect.Effect<void>;
77
72
  }
78
73
  declare const OverlayService_base: Context.TagClass<OverlayService, "shwfed/OverlayService", OverlayRuntime>;
79
74
  export declare class OverlayService extends OverlayService_base {
80
75
  }
81
- export declare function isOverlayAborted(value: unknown): value is OverlayAborted;
82
76
  export declare function useOverlay(): OverlayRuntime;
83
77
  export declare function provideOverlay<A, E, R>(effect: Effect.Effect<A, E, R>, runtime?: OverlayRuntime): Effect.Effect<A, E, Exclude<R, OverlayService>>;
84
78
  export declare function openOverlay(definitionId: string, options?: OverlaySessionInput): Effect.Effect<OverlayHandle, OverlayDefinitionNotFoundError, OverlayService | Scope.Scope>;
85
79
  export declare function patchOverlay(sessionId: string, patch: OverlaySessionPatch): Effect.Effect<void, never, OverlayService>;
86
- export declare function closeOverlay(sessionId: string, value?: unknown): Effect.Effect<void, never, OverlayService>;
80
+ export declare function closeOverlay(sessionId: string, ...args: [value?: unknown]): Effect.Effect<void, never, OverlayService>;
87
81
  export declare function closeTopOverlay(): Effect.Effect<void, never, OverlayService>;
88
82
  export declare function closeAllOverlays(): Effect.Effect<void, never, OverlayService>;
89
83
  export {};
@@ -3,12 +3,6 @@ import { reactive, ref } from "vue";
3
3
  import { ButtonActionService } from "./useButtonAction.js";
4
4
  export class OverlayService extends Context.Tag("shwfed/OverlayService")() {
5
5
  }
6
- function createAborted(reason) {
7
- return {
8
- _tag: "OverlayAborted",
9
- reason
10
- };
11
- }
12
6
  function createDefinitionNotFoundError(definitionId) {
13
7
  return {
14
8
  _tag: "OverlayDefinitionNotFoundError",
@@ -30,8 +24,11 @@ function getDefaultOverlayDescription(locale) {
30
24
  return "\u6253\u5F00\u7684\u5F39\u7A97";
31
25
  }
32
26
  }
33
- export function isOverlayAborted(value) {
34
- return typeof value === "object" && value !== null && Reflect.get(value, "_tag") === "OverlayAborted" && typeof Reflect.get(value, "reason") === "string";
27
+ function createResult(...args) {
28
+ if (args.length === 0) {
29
+ return Option.none();
30
+ }
31
+ return Option.some(args[0]);
35
32
  }
36
33
  function createOverlayRuntime() {
37
34
  const definitions = reactive({});
@@ -53,19 +50,19 @@ function createOverlayRuntime() {
53
50
  const [session] = sessions.value.splice(index, 1);
54
51
  return session;
55
52
  }
56
- function closeInternal(sessionId, value) {
53
+ function closeInternal(sessionId, result) {
57
54
  return Effect.gen(function* () {
58
55
  const session = removeSession(sessionId);
59
56
  if (!session) {
60
57
  return;
61
58
  }
62
- yield* Deferred.succeed(session.deferred, value);
59
+ yield* Deferred.succeed(session.deferred, result);
63
60
  });
64
61
  }
65
- function closeDefinitionSessions(definitionId, reason) {
62
+ function closeDefinitionSessions(definitionId) {
66
63
  const targetSessions = sessions.value.filter((session) => session.definitionId === definitionId).map((session) => session.sessionId);
67
64
  for (const sessionId of targetSessions) {
68
- void Effect.runPromise(closeInternal(sessionId, createAborted(reason)));
65
+ void Effect.runPromise(closeInternal(sessionId, Option.none()));
69
66
  }
70
67
  }
71
68
  function registerDefinition(definition) {
@@ -80,7 +77,7 @@ function createOverlayRuntime() {
80
77
  return;
81
78
  }
82
79
  Reflect.deleteProperty(definitions, definitionId);
83
- closeDefinitionSessions(definitionId, ownerId === void 0 ? "definition" : "owner");
80
+ closeDefinitionSessions(definitionId);
84
81
  }
85
82
  function syncDefinitions(ownerId, nextDefinitions) {
86
83
  const nextIds = nextDefinitions.map((definition) => definition.definitionId);
@@ -113,20 +110,20 @@ function createOverlayRuntime() {
113
110
  };
114
111
  }
115
112
  }
116
- function closeSync(sessionId, value) {
117
- void Effect.runPromise(closeInternal(sessionId, value));
113
+ function closeSync(sessionId, ...args) {
114
+ void Effect.runPromise(closeInternal(sessionId, createResult(...args)));
118
115
  }
119
116
  function closeTopSync() {
120
117
  const topSession = sessions.value.at(-1);
121
118
  if (!topSession) {
122
119
  return;
123
120
  }
124
- closeSync(topSession.sessionId, createAborted("dismiss"));
121
+ void Effect.runPromise(closeInternal(topSession.sessionId, Option.none()));
125
122
  }
126
123
  function closeAllSync() {
127
124
  const sessionIds = sessions.value.map((session) => session.sessionId);
128
125
  for (const sessionId of sessionIds) {
129
- closeSync(sessionId, createAborted("close-all"));
126
+ void Effect.runPromise(closeInternal(sessionId, Option.none()));
130
127
  }
131
128
  }
132
129
  function createHandle(session) {
@@ -135,7 +132,7 @@ function createOverlayRuntime() {
135
132
  patch: (patch) => Effect.sync(() => {
136
133
  patchSync(session.sessionId, patch);
137
134
  }),
138
- close: (value) => closeInternal(session.sessionId, value),
135
+ close: (...args) => closeInternal(session.sessionId, createResult(...args)),
139
136
  result: Deferred.await(session.deferred)
140
137
  };
141
138
  }
@@ -196,12 +193,12 @@ function createOverlayRuntime() {
196
193
  sessions.value.push(session);
197
194
  return createHandle(session);
198
195
  }),
199
- (handle) => closeInternal(handle.sessionId, createAborted("scope"))
196
+ (handle) => closeInternal(handle.sessionId, Option.none())
200
197
  ),
201
198
  patch: (sessionId, patch) => Effect.sync(() => {
202
199
  patchSync(sessionId, patch);
203
200
  }),
204
- close: (sessionId, value) => closeInternal(sessionId, value),
201
+ close: (sessionId, ...args) => closeInternal(sessionId, createResult(...args)),
205
202
  closeTop: () => Effect.sync(() => {
206
203
  closeTopSync();
207
204
  }),
@@ -224,8 +221,8 @@ export function openOverlay(definitionId, options) {
224
221
  export function patchOverlay(sessionId, patch) {
225
222
  return Effect.flatMap(OverlayService, (overlay) => overlay.patch(sessionId, patch));
226
223
  }
227
- export function closeOverlay(sessionId, value) {
228
- return Effect.flatMap(OverlayService, (overlay) => overlay.close(sessionId, value));
224
+ export function closeOverlay(sessionId, ...args) {
225
+ return Effect.flatMap(OverlayService, (overlay) => overlay.close(sessionId, ...args));
229
226
  }
230
227
  export function closeTopOverlay() {
231
228
  return Effect.flatMap(OverlayService, (overlay) => overlay.closeTop());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
- "version": "0.11.8",
3
+ "version": "0.11.10",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",