@wow-two-beta/ui-vue 0.0.2 → 0.0.4
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/chunks/{FeedbackBus-BRbyOMCn.js → FeedbackBus-CTj18X4n.js} +17 -3
- package/dist/chunks/FeedbackBus-CTj18X4n.js.map +1 -0
- package/dist/chunks/Navbar.vue_vue_type_script_setup_true_lang-Cl2ejukE.js.map +1 -1
- package/dist/chunks/{NotificationItem.vue_vue_type_script_setup_true_lang-gi0uHIuK.js → NotificationItem.vue_vue_type_script_setup_true_lang-KC5Iusce.js} +2 -2
- package/dist/chunks/{NotificationItem.vue_vue_type_script_setup_true_lang-gi0uHIuK.js.map → NotificationItem.vue_vue_type_script_setup_true_lang-KC5Iusce.js.map} +1 -1
- package/dist/feedback/FeedbackBus.d.ts +21 -3
- package/dist/feedback/index.d.ts +1 -1
- package/dist/feedback/index.js +2 -2
- package/dist/index.js +1 -1
- package/dist/presentation/feedback/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/FeedbackBus-BRbyOMCn.js.map +0 -1
|
@@ -9,13 +9,27 @@ const NoticeTone = {
|
|
|
9
9
|
/** Refers to a destructive / error notice. */
|
|
10
10
|
Danger: Severity.Danger
|
|
11
11
|
};
|
|
12
|
-
function createFeedbackBus() {
|
|
12
|
+
function createFeedbackBus(options = {}) {
|
|
13
|
+
const { onError } = options;
|
|
13
14
|
const listeners = /* @__PURE__ */ new Set();
|
|
14
15
|
let idSeq = 0;
|
|
16
|
+
const report = (error, listener, notice) => {
|
|
17
|
+
if (!onError) return;
|
|
18
|
+
try {
|
|
19
|
+
onError(error, { listener, notice });
|
|
20
|
+
} catch {
|
|
21
|
+
}
|
|
22
|
+
};
|
|
15
23
|
return {
|
|
16
24
|
notify(notice) {
|
|
17
25
|
const published = { ...notice, id: notice.id ?? `n_${++idSeq}` };
|
|
18
|
-
for (const listener of [...listeners])
|
|
26
|
+
for (const listener of [...listeners]) {
|
|
27
|
+
try {
|
|
28
|
+
listener(published);
|
|
29
|
+
} catch (failure) {
|
|
30
|
+
report(failure, listener, published);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
19
33
|
return published.id;
|
|
20
34
|
},
|
|
21
35
|
subscribe(listener) {
|
|
@@ -36,4 +50,4 @@ export {
|
|
|
36
50
|
feedbackBus as f,
|
|
37
51
|
notify as n
|
|
38
52
|
};
|
|
39
|
-
//# sourceMappingURL=FeedbackBus-
|
|
53
|
+
//# sourceMappingURL=FeedbackBus-CTj18X4n.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FeedbackBus-CTj18X4n.js","sources":["../../src/feedback/FeedbackBus.ts"],"sourcesContent":["import type { VNode } from 'vue';\n\nimport { Severity } from '../foundation/utils';\n\n/** Defines the tone of a notice — the house `Severity` vocabulary minus `neutral` (a notice always carries intent). */\nexport const NoticeTone = {\n /** Refers to an informational notice. */\n Info: Severity.Info,\n /** Refers to a positive / success notice. */\n Success: Severity.Success,\n /** Refers to a caution / warning notice. */\n Warning: Severity.Warning,\n /** Refers to a destructive / error notice. */\n Danger: Severity.Danger,\n} as const;\n\nexport type NoticeTone = (typeof NoticeTone)[keyof typeof NoticeTone];\n\n/**\n * A renderable slice of a notice. React's `ReactNode` becomes `string | VNode`\n * for the same reason the `Toaster` payload did: notices travel as data through\n * `notify()`, not through a slot, so a caller who wants markup builds it with\n * `h()`. Structurally identical to `presentation/feedback`'s `ToastNode` — the\n * adapter's assignment is what keeps the two from drifting, and this module\n * cannot import that one (boundaries: `feedback` never reaches into\n * `presentation`).\n */\nexport type NoticeNode = string | VNode;\n\n/** Defines a feedback notice published on the bus — the headless payload a presentation adapter renders (toast, banner, notification center…). */\nexport interface FeedbackNotice {\n /** The semantic tone — maps 1:1 onto the toast `severity` vocabulary. */\n readonly tone: NoticeTone;\n\n /** The headline. */\n readonly title: NoticeNode;\n\n /** The optional supporting body. */\n readonly description?: NoticeNode;\n\n /** An optional action slot (e.g. a retry button) — passed through to the rendering surface. */\n readonly action?: NoticeNode;\n\n /** An optional stable identity — assigned by the bus (`n_<seq>`) when omitted; callers set it for future dedupe / notification-center use. */\n readonly id?: string;\n\n /** ms before the rendering surface auto-dismisses. Surface default when omitted; `Infinity` = sticky. */\n readonly durationMs?: number;\n}\n\n/** Defines a notice as delivered to subscribers — identity always assigned. */\nexport interface PublishedNotice extends FeedbackNotice {\n readonly id: string;\n}\n\n/** Defines a listener notified on every published notice. */\nexport type NoticeListener = (notice: PublishedNotice) => void;\n\n/** Defines the context handed to `onError` when a subscriber throws. */\nexport interface FeedbackErrorContext {\n /** The listener that threw. */\n readonly listener: NoticeListener;\n\n /** The notice being delivered when it threw. */\n readonly notice: PublishedNotice;\n}\n\n/** Defines the subscriber-failure handler — publishing must never break the publisher, so every listener throw lands here instead of propagating. */\nexport type FeedbackErrorHandler = (error: unknown, context: FeedbackErrorContext) => void;\n\n/** Defines the options for {@link createFeedbackBus}. */\nexport interface FeedbackBusOptions {\n /** Receives every subscriber failure. Omitted means failures are swallowed — a broken subscriber is never worth an app crash. */\n readonly onError?: FeedbackErrorHandler;\n}\n\n/**\n * Defines the module-scope feedback hub wiring app code to whatever surface renders notices.\n * Fire-and-forget pub/sub (no replay): a notice published with no subscriber is dropped, so mount\n * the adapter (`<FeedbackToasts/>`) before publishing. Nothing subscribes automatically — GWDNBM,\n * every wire is explicit:\n *\n * - **Notices in** — `notify({ tone, title })` from anywhere (composables, api client code, stores);\n * `feedbackQueryErrors(bus)` plugs a `/query` global error seam in.\n * - **Toasts out** — `<FeedbackToasts/>` (`/presentation/feedback`) subscribes and forwards each\n * notice into the imperative `toaster.toast()` API.\n *\n * Plain module state rather than a Vue plugin / `provide`: the bus is publisher-agnostic, and a\n * publisher is rarely inside a component's `setup()` (an interceptor, a store action). The\n * `bus` prop on the adapter is the isolation seam an app needs instead.\n */\nexport interface FeedbackBus {\n /** Publishes a notice to all subscribers — safe to call with none mounted (no-op), and never throws whatever a subscriber does; returns the notice id. */\n notify(notice: FeedbackNotice): string;\n\n /** Subscribes to published notices; returns an unsubscribe. */\n subscribe(listener: NoticeListener): () => void;\n}\n\n/**\n * Creates a {@link FeedbackBus} — one per app, module scope, shared by publishers and the rendering adapter.\n * Apps that don't need isolation use the default {@link feedbackBus}; pass `onError` to see the subscriber\n * failures the bus otherwise swallows.\n */\nexport function createFeedbackBus(options: FeedbackBusOptions = {}): FeedbackBus {\n const { onError } = options;\n const listeners = new Set<NoticeListener>();\n let idSeq = 0;\n\n /** Routes a subscriber failure to `onError` — a handler that itself throws is swallowed, since there is nowhere left to report. */\n const report = (error: unknown, listener: NoticeListener, notice: PublishedNotice): void => {\n if (!onError) return;\n try {\n onError(error, { listener, notice });\n } catch {\n // The handler is the last line of defence; a throw here must not reach the caller either.\n }\n };\n\n return {\n notify(notice: FeedbackNotice): string {\n const published: PublishedNotice = { ...notice, id: notice.id ?? `n_${++idSeq}` };\n // Every subscriber is invoked in isolation. A subscriber is adapter code the publisher does not own,\n // and `notify()` is called from click handlers, `catch` blocks and error boundaries — precisely where a\n // second exception masks the first and takes down the path that was meant to recover. So a throwing\n // subscriber costs only its own delivery: the rest of the fan-out still runs, `notify()` still returns\n // the id, and the failure surfaces on `onError` rather than in the caller.\n for (const listener of [...listeners]) {\n try {\n listener(published);\n } catch (failure) {\n report(failure, listener, published);\n }\n }\n return published.id;\n },\n\n subscribe(listener: NoticeListener): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n\n/** The default app-wide bus — what `notify` and the adapters bind to unless handed an explicit bus. */\nexport const feedbackBus: FeedbackBus = createFeedbackBus();\n\n/** Publishes a notice on the default {@link feedbackBus} — the everyday `notify({ tone: 'success', title: 'Saved' })` entry point. */\nexport function notify(notice: FeedbackNotice): string {\n return feedbackBus.notify(notice);\n}\n"],"names":[],"mappings":";AAKO,MAAM,aAAa;AAAA;AAAA,EAExB,MAAM,SAAS;AAAA;AAAA,EAEf,SAAS,SAAS;AAAA;AAAA,EAElB,SAAS,SAAS;AAAA;AAAA,EAElB,QAAQ,SAAS;AACnB;AA0FO,SAAS,kBAAkB,UAA8B,IAAiB;AAC/E,QAAM,EAAE,YAAY;AACpB,QAAM,gCAAgB,IAAA;AACtB,MAAI,QAAQ;AAGZ,QAAM,SAAS,CAAC,OAAgB,UAA0B,WAAkC;AAC1F,QAAI,CAAC,QAAS;AACd,QAAI;AACF,cAAQ,OAAO,EAAE,UAAU,OAAA,CAAQ;AAAA,IACrC,QAAQ;AAAA,IAER;AAAA,EACF;AAEA,SAAO;AAAA,IACL,OAAO,QAAgC;AACrC,YAAM,YAA6B,EAAE,GAAG,QAAQ,IAAI,OAAO,MAAM,KAAK,EAAE,KAAK,GAAA;AAM7E,iBAAW,YAAY,CAAC,GAAG,SAAS,GAAG;AACrC,YAAI;AACF,mBAAS,SAAS;AAAA,QACpB,SAAS,SAAS;AAChB,iBAAO,SAAS,UAAU,SAAS;AAAA,QACrC;AAAA,MACF;AACA,aAAO,UAAU;AAAA,IACnB;AAAA,IAEA,UAAU,UAAsC;AAC9C,gBAAU,IAAI,QAAQ;AACtB,aAAO,MAAM;AACX,kBAAU,OAAO,QAAQ;AAAA,MAC3B;AAAA,IACF;AAAA,EAAA;AAEJ;AAGO,MAAM,cAA2B,kBAAA;AAGjC,SAAS,OAAO,QAAgC;AACrD,SAAO,YAAY,OAAO,MAAM;AAClC;"}
|