@samline/notify 1.0.1 → 2.0.0

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.
Files changed (83) hide show
  1. package/{LICENSE → LICENSE.md} +2 -2
  2. package/README.md +27 -160
  3. package/dist/_runtime.d.mts +87 -0
  4. package/dist/_runtime.d.ts +87 -0
  5. package/dist/_runtime.js +97 -0
  6. package/dist/_runtime.mjs +83 -0
  7. package/dist/browser/assets-client-B-VVPPYQ.js +114 -0
  8. package/dist/browser/assets-client-CUzxHubR.mjs +108 -0
  9. package/dist/browser/index-client-BBOQyMFk.mjs +173 -0
  10. package/dist/browser/index-client-Czb7hTpD.js +181 -0
  11. package/dist/browser/index.d.mts +134 -0
  12. package/dist/browser/index.d.ts +134 -0
  13. package/dist/browser/index.js +34 -0
  14. package/dist/browser/index.mjs +26 -0
  15. package/dist/browser/render-client-CjcQoukB.js +981 -0
  16. package/dist/browser/render-client-bGRSTd-L.mjs +974 -0
  17. package/dist/core/index.d.mts +68 -0
  18. package/dist/core/index.d.ts +68 -0
  19. package/dist/core/index.js +1 -0
  20. package/dist/core/index.mjs +1 -0
  21. package/dist/index.d.mts +131 -0
  22. package/dist/index.d.ts +131 -0
  23. package/dist/index.js +1240 -0
  24. package/dist/index.mjs +1228 -0
  25. package/dist/react/index.d.mts +158 -0
  26. package/dist/react/index.d.ts +158 -0
  27. package/dist/react/index.js +1116 -0
  28. package/dist/react/index.mjs +1107 -0
  29. package/dist/styles.css +612 -364
  30. package/dist/svelte/assets-client-B-VVPPYQ.js +114 -0
  31. package/dist/svelte/assets-client-CUzxHubR.mjs +108 -0
  32. package/dist/svelte/index-client-DbXbWMIe.js +177 -0
  33. package/dist/svelte/index-client-Dj_WfPK9.mjs +170 -0
  34. package/dist/svelte/index.d.mts +14 -0
  35. package/dist/svelte/index.d.ts +14 -0
  36. package/dist/svelte/index.js +43 -0
  37. package/dist/svelte/index.mjs +36 -0
  38. package/dist/svelte/render-client-CjcQoukB.js +981 -0
  39. package/dist/svelte/render-client-bGRSTd-L.mjs +974 -0
  40. package/dist/vue/assets-client-B-VVPPYQ.js +114 -0
  41. package/dist/vue/assets-client-CUzxHubR.mjs +108 -0
  42. package/dist/vue/index-client-DbXbWMIe.js +177 -0
  43. package/dist/vue/index-client-Dj_WfPK9.mjs +170 -0
  44. package/dist/vue/index.d.mts +50 -0
  45. package/dist/vue/index.d.ts +50 -0
  46. package/dist/vue/index.js +110 -0
  47. package/dist/vue/index.mjs +104 -0
  48. package/dist/vue/render-client-CjcQoukB.js +981 -0
  49. package/dist/vue/render-client-bGRSTd-L.mjs +974 -0
  50. package/package.json +140 -95
  51. package/dist/browser-notify.js +0 -68
  52. package/dist/cc-2Yt7NqMX.mjs +0 -21
  53. package/dist/cc-B6peeNak.mjs +0 -33
  54. package/dist/cc-BWuAzFJ6.js +0 -12
  55. package/dist/cc-CaBHsjUt.js +0 -34
  56. package/dist/cc-DGff5sSY.js +0 -21
  57. package/dist/cc-he3fHS3P.mjs +0 -12
  58. package/dist/notify.d.mts +0 -44
  59. package/dist/notify.d.mts.map +0 -1
  60. package/dist/notify.d.ts +0 -44
  61. package/dist/notify.d.ts.map +0 -1
  62. package/dist/notify.js +0 -90
  63. package/dist/notify.mjs +0 -87
  64. package/dist/react-notify-12s-7LOZlSBi.js +0 -1068
  65. package/dist/react-notify-12s-BjWbwTu8.mjs +0 -1066
  66. package/dist/react.d.mts +0 -66
  67. package/dist/react.d.mts.map +0 -1
  68. package/dist/react.d.ts +0 -66
  69. package/dist/react.d.ts.map +0 -1
  70. package/dist/react.js +0 -18
  71. package/dist/react.mjs +0 -10
  72. package/dist/svelte.d.mts +0 -45
  73. package/dist/svelte.d.mts.map +0 -1
  74. package/dist/svelte.d.ts +0 -45
  75. package/dist/svelte.d.ts.map +0 -1
  76. package/dist/svelte.js +0 -168
  77. package/dist/svelte.mjs +0 -165
  78. package/dist/vue.d.mts +0 -103
  79. package/dist/vue.d.mts.map +0 -1
  80. package/dist/vue.d.ts +0 -103
  81. package/dist/vue.d.ts.map +0 -1
  82. package/dist/vue.js +0 -2099
  83. package/dist/vue.mjs +0 -2096
package/dist/react.d.mts DELETED
@@ -1,66 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode } from 'react';
3
-
4
- type NotifyState = "success" | "loading" | "error" | "warning" | "info" | "action";
5
- interface NotifyStyles {
6
- title?: string;
7
- description?: string;
8
- badge?: string;
9
- button?: string;
10
- }
11
- interface NotifyButton {
12
- title: string;
13
- onClick: () => void;
14
- }
15
- declare const NOTIFY_POSITIONS: readonly ["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"];
16
- type NotifyPosition = (typeof NOTIFY_POSITIONS)[number];
17
- interface NotifyOptions {
18
- title?: string;
19
- description?: string;
20
- type?: NotifyState;
21
- position?: NotifyPosition;
22
- duration?: number | null;
23
- icon?: any;
24
- styles?: NotifyStyles;
25
- fill?: string;
26
- roundness?: number;
27
- autopilot?: boolean | {
28
- expand?: number;
29
- collapse?: number;
30
- };
31
- button?: NotifyButton;
32
- }
33
-
34
- type NotifyOffsetValue = number | string;
35
- type NotifyOffsetConfig = Partial<Record<"top" | "right" | "bottom" | "left", NotifyOffsetValue>>;
36
- interface NotifyToasterProps {
37
- children?: ReactNode;
38
- position?: NotifyPosition;
39
- offset?: NotifyOffsetValue | NotifyOffsetConfig;
40
- options?: Partial<NotifyOptions>;
41
- theme?: "light" | "dark" | "system";
42
- }
43
- interface NotifyPromiseOptions<T = unknown> {
44
- loading: NotifyOptions;
45
- success: NotifyOptions | ((data: T) => NotifyOptions);
46
- error: NotifyOptions | ((err: unknown) => NotifyOptions);
47
- action?: NotifyOptions | ((data: T) => NotifyOptions);
48
- position?: NotifyPosition;
49
- }
50
- declare const notify: {
51
- show: (opts: NotifyOptions) => string;
52
- success: (opts: NotifyOptions) => string;
53
- error: (opts: NotifyOptions) => string;
54
- warning: (opts: NotifyOptions) => string;
55
- info: (opts: NotifyOptions) => string;
56
- action: (opts: NotifyOptions) => string;
57
- promise: <T>(promise: Promise<T> | (() => Promise<T>), opts: NotifyPromiseOptions<T>) => Promise<T>;
58
- dismiss: (id: string) => void;
59
- clear: (position?: NotifyPosition) => void;
60
- };
61
- declare function showNotifyToast(options: NotifyOptions): string;
62
- declare function Toaster({ children, position, offset, options, theme, }: NotifyToasterProps): react_jsx_runtime.JSX.Element;
63
-
64
- export { Toaster, notify, showNotifyToast };
65
- export type { NotifyButton, NotifyOptions, NotifyPosition, NotifyState, NotifyStyles };
66
- //# sourceMappingURL=react.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react.d.mts","sources":["../src/types.ts","../src/toast.tsx"],"mappings":";;;AAAA,KAAK,WAAW;AAChB,UAAU,YAAY;AACtB;AACA;AACA;AACA;AACA;AACA,UAAU,YAAY;AACtB;AACA;AACA;AACA,cAAc,gBAAgB;AAC9B,KAAK,cAAc,WAAW,gBAAgB;AAC9C,UAAU,aAAa;AACvB;AACA;AACA,WAAW,WAAW;AACtB,eAAe,cAAc;AAC7B;AACA;AACA,aAAa,YAAY;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,YAAY;AACzB;;ACzBA,KAAK,iBAAiB;AACtB,KAAK,kBAAkB,GAAG,OAAO,CAAC,MAAM,sCAAsC,iBAAiB;AAC/F,UAAU,kBAAkB;AAC5B,eAAe,SAAS;AACxB,eAAe,cAAc;AAC7B,aAAa,iBAAiB,GAAG,kBAAkB;AACnD,cAAc,OAAO,CAAC,aAAa;AACnC;AACA;AACA,UAAU,oBAAoB;AAC9B,aAAa,aAAa;AAC1B,aAAa,aAAa,iBAAiB,aAAa;AACxD,WAAW,aAAa,sBAAsB,aAAa;AAC3D,aAAa,aAAa,iBAAiB,aAAa;AACxD,eAAe,cAAc;AAC7B;AACA,cAAc,MAAM;AACpB,iBAAiB,aAAa;AAC9B,oBAAoB,aAAa;AACjC,kBAAkB,aAAa;AAC/B,oBAAoB,aAAa;AACjC,iBAAiB,aAAa;AAC9B,mBAAmB,aAAa;AAChC,0BAA0B,OAAO,aAAa,OAAO,YAAY,oBAAoB,QAAQ,OAAO;AACpG;AACA,uBAAuB,cAAc;AACrC;AACA,iBAAiB,eAAe,UAAU,aAAa;AACvD,iBAAiB,OAAO,kDAAkD,kBAAkB,GAAG,iBAAiB,CAAC,GAAG,CAAC,OAAO;;;;","names":[]}
package/dist/react.d.ts DELETED
@@ -1,66 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode } from 'react';
3
-
4
- type NotifyState = "success" | "loading" | "error" | "warning" | "info" | "action";
5
- interface NotifyStyles {
6
- title?: string;
7
- description?: string;
8
- badge?: string;
9
- button?: string;
10
- }
11
- interface NotifyButton {
12
- title: string;
13
- onClick: () => void;
14
- }
15
- declare const NOTIFY_POSITIONS: readonly ["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"];
16
- type NotifyPosition = (typeof NOTIFY_POSITIONS)[number];
17
- interface NotifyOptions {
18
- title?: string;
19
- description?: string;
20
- type?: NotifyState;
21
- position?: NotifyPosition;
22
- duration?: number | null;
23
- icon?: any;
24
- styles?: NotifyStyles;
25
- fill?: string;
26
- roundness?: number;
27
- autopilot?: boolean | {
28
- expand?: number;
29
- collapse?: number;
30
- };
31
- button?: NotifyButton;
32
- }
33
-
34
- type NotifyOffsetValue = number | string;
35
- type NotifyOffsetConfig = Partial<Record<"top" | "right" | "bottom" | "left", NotifyOffsetValue>>;
36
- interface NotifyToasterProps {
37
- children?: ReactNode;
38
- position?: NotifyPosition;
39
- offset?: NotifyOffsetValue | NotifyOffsetConfig;
40
- options?: Partial<NotifyOptions>;
41
- theme?: "light" | "dark" | "system";
42
- }
43
- interface NotifyPromiseOptions<T = unknown> {
44
- loading: NotifyOptions;
45
- success: NotifyOptions | ((data: T) => NotifyOptions);
46
- error: NotifyOptions | ((err: unknown) => NotifyOptions);
47
- action?: NotifyOptions | ((data: T) => NotifyOptions);
48
- position?: NotifyPosition;
49
- }
50
- declare const notify: {
51
- show: (opts: NotifyOptions) => string;
52
- success: (opts: NotifyOptions) => string;
53
- error: (opts: NotifyOptions) => string;
54
- warning: (opts: NotifyOptions) => string;
55
- info: (opts: NotifyOptions) => string;
56
- action: (opts: NotifyOptions) => string;
57
- promise: <T>(promise: Promise<T> | (() => Promise<T>), opts: NotifyPromiseOptions<T>) => Promise<T>;
58
- dismiss: (id: string) => void;
59
- clear: (position?: NotifyPosition) => void;
60
- };
61
- declare function showNotifyToast(options: NotifyOptions): string;
62
- declare function Toaster({ children, position, offset, options, theme, }: NotifyToasterProps): react_jsx_runtime.JSX.Element;
63
-
64
- export { Toaster, notify, showNotifyToast };
65
- export type { NotifyButton, NotifyOptions, NotifyPosition, NotifyState, NotifyStyles };
66
- //# sourceMappingURL=react.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react.d.ts","sources":["../src/types.ts","../src/toast.tsx"],"mappings":";;;AAAA,KAAK,WAAW;AAChB,UAAU,YAAY;AACtB;AACA;AACA;AACA;AACA;AACA,UAAU,YAAY;AACtB;AACA;AACA;AACA,cAAc,gBAAgB;AAC9B,KAAK,cAAc,WAAW,gBAAgB;AAC9C,UAAU,aAAa;AACvB;AACA;AACA,WAAW,WAAW;AACtB,eAAe,cAAc;AAC7B;AACA;AACA,aAAa,YAAY;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,YAAY;AACzB;;ACzBA,KAAK,iBAAiB;AACtB,KAAK,kBAAkB,GAAG,OAAO,CAAC,MAAM,sCAAsC,iBAAiB;AAC/F,UAAU,kBAAkB;AAC5B,eAAe,SAAS;AACxB,eAAe,cAAc;AAC7B,aAAa,iBAAiB,GAAG,kBAAkB;AACnD,cAAc,OAAO,CAAC,aAAa;AACnC;AACA;AACA,UAAU,oBAAoB;AAC9B,aAAa,aAAa;AAC1B,aAAa,aAAa,iBAAiB,aAAa;AACxD,WAAW,aAAa,sBAAsB,aAAa;AAC3D,aAAa,aAAa,iBAAiB,aAAa;AACxD,eAAe,cAAc;AAC7B;AACA,cAAc,MAAM;AACpB,iBAAiB,aAAa;AAC9B,oBAAoB,aAAa;AACjC,kBAAkB,aAAa;AAC/B,oBAAoB,aAAa;AACjC,iBAAiB,aAAa;AAC9B,mBAAmB,aAAa;AAChC,0BAA0B,OAAO,aAAa,OAAO,YAAY,oBAAoB,QAAQ,OAAO;AACpG;AACA,uBAAuB,cAAc;AACrC;AACA,iBAAiB,eAAe,UAAU,aAAa;AACvD,iBAAiB,OAAO,kDAAkD,kBAAkB,GAAG,iBAAiB,CAAC,GAAG,CAAC,OAAO;;;;","names":[]}
package/dist/react.js DELETED
@@ -1,18 +0,0 @@
1
- function __insertCSS(code) {
2
- if (!code || typeof document == 'undefined') return
3
- let head = document.head || document.getElementsByTagName('head')[0]
4
- let style = document.createElement('style')
5
- style.type = 'text/css'
6
- head.appendChild(style)
7
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
8
- }
9
-
10
- Object.defineProperty(exports, '__esModule', { value: true });
11
-
12
- var reactNotify12s = require('./react-notify-12s-7LOZlSBi.js');
13
-
14
-
15
-
16
- exports.Toaster = reactNotify12s.Toaster;
17
- exports.notify = reactNotify12s.notify;
18
- exports.showNotifyToast = reactNotify12s.showNotifyToast;
package/dist/react.mjs DELETED
@@ -1,10 +0,0 @@
1
- function __insertCSS(code) {
2
- if (!code || typeof document == 'undefined') return
3
- let head = document.head || document.getElementsByTagName('head')[0]
4
- let style = document.createElement('style')
5
- style.type = 'text/css'
6
- head.appendChild(style)
7
- ;style.styleSheet ? (style.styleSheet.cssText = code) : style.appendChild(document.createTextNode(code))
8
- }
9
-
10
- export { T as Toaster, n as notify, s as showNotifyToast } from './react-notify-12s-BjWbwTu8.mjs';
package/dist/svelte.d.mts DELETED
@@ -1,45 +0,0 @@
1
- import * as svelte_store from 'svelte/store';
2
-
3
- type NotifyState = "success" | "loading" | "error" | "warning" | "info" | "action";
4
- interface NotifyStyles {
5
- title?: string;
6
- description?: string;
7
- badge?: string;
8
- button?: string;
9
- }
10
- interface NotifyButton {
11
- title: string;
12
- onClick: () => void;
13
- }
14
- declare const NOTIFY_POSITIONS: readonly ["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"];
15
- type NotifyPosition = (typeof NOTIFY_POSITIONS)[number];
16
- interface NotifyOptions {
17
- title?: string;
18
- description?: string;
19
- type?: NotifyState;
20
- position?: NotifyPosition;
21
- duration?: number | null;
22
- icon?: any;
23
- styles?: NotifyStyles;
24
- fill?: string;
25
- roundness?: number;
26
- autopilot?: boolean | {
27
- expand?: number;
28
- collapse?: number;
29
- };
30
- button?: NotifyButton;
31
- }
32
-
33
- interface NotifyItem extends NotifyOptions {
34
- id: string;
35
- instanceId: string;
36
- exiting?: boolean;
37
- autoExpandDelayMs?: number;
38
- autoCollapseDelayMs?: number;
39
- }
40
-
41
- declare const notifyToasts: svelte_store.Writable<NotifyItem[]>;
42
- declare function showNotifyToast(options: NotifyOptions): string;
43
-
44
- export { notifyToasts, showNotifyToast };
45
- //# sourceMappingURL=svelte.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"svelte.d.mts","sources":["../src/types.ts","../src/core/notify-core.ts","../src/svelte-notify.ts"],"mappings":";;AAAA,KAAK,WAAW;AAChB,UAAU,YAAY;AACtB;AACA;AACA;AACA;AACA;AACA,UAAU,YAAY;AACtB;AACA;AACA;AACA,cAAc,gBAAgB;AAC9B,KAAK,cAAc,WAAW,gBAAgB;AAC9C,UAAU,aAAa;AACvB;AACA;AACA,WAAW,WAAW;AACtB,eAAe,cAAc;AAC7B;AACA;AACA,aAAa,YAAY;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,YAAY;AACzB;;AC1BA,UAAU,UAAU,SAAS,aAAa;AAC1C;AACA;AACA;AACA;AACA;AACA;;ACLA,cAAc,YAAY,EAAE,YAAY,CAAC,QAAQ,CAACA,UAA6B;AAC/E,iBAAiB,eAAe,UAAU,aAAa;;;;","names":["__core_notify_core.NotifyItem"]}
package/dist/svelte.d.ts DELETED
@@ -1,45 +0,0 @@
1
- import * as svelte_store from 'svelte/store';
2
-
3
- type NotifyState = "success" | "loading" | "error" | "warning" | "info" | "action";
4
- interface NotifyStyles {
5
- title?: string;
6
- description?: string;
7
- badge?: string;
8
- button?: string;
9
- }
10
- interface NotifyButton {
11
- title: string;
12
- onClick: () => void;
13
- }
14
- declare const NOTIFY_POSITIONS: readonly ["top-left", "top-center", "top-right", "bottom-left", "bottom-center", "bottom-right"];
15
- type NotifyPosition = (typeof NOTIFY_POSITIONS)[number];
16
- interface NotifyOptions {
17
- title?: string;
18
- description?: string;
19
- type?: NotifyState;
20
- position?: NotifyPosition;
21
- duration?: number | null;
22
- icon?: any;
23
- styles?: NotifyStyles;
24
- fill?: string;
25
- roundness?: number;
26
- autopilot?: boolean | {
27
- expand?: number;
28
- collapse?: number;
29
- };
30
- button?: NotifyButton;
31
- }
32
-
33
- interface NotifyItem extends NotifyOptions {
34
- id: string;
35
- instanceId: string;
36
- exiting?: boolean;
37
- autoExpandDelayMs?: number;
38
- autoCollapseDelayMs?: number;
39
- }
40
-
41
- declare const notifyToasts: svelte_store.Writable<NotifyItem[]>;
42
- declare function showNotifyToast(options: NotifyOptions): string;
43
-
44
- export { notifyToasts, showNotifyToast };
45
- //# sourceMappingURL=svelte.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"svelte.d.ts","sources":["../src/types.ts","../src/core/notify-core.ts","../src/svelte-notify.ts"],"mappings":";;AAAA,KAAK,WAAW;AAChB,UAAU,YAAY;AACtB;AACA;AACA;AACA;AACA;AACA,UAAU,YAAY;AACtB;AACA;AACA;AACA,cAAc,gBAAgB;AAC9B,KAAK,cAAc,WAAW,gBAAgB;AAC9C,UAAU,aAAa;AACvB;AACA;AACA,WAAW,WAAW;AACtB,eAAe,cAAc;AAC7B;AACA;AACA,aAAa,YAAY;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,YAAY;AACzB;;AC1BA,UAAU,UAAU,SAAS,aAAa;AAC1C;AACA;AACA;AACA;AACA;AACA;;ACLA,cAAc,YAAY,EAAE,YAAY,CAAC,QAAQ,CAACA,UAA6B;AAC/E,iBAAiB,eAAe,UAAU,aAAa;;;;","names":["__core_notify_core.NotifyItem"]}
package/dist/svelte.js DELETED
@@ -1,168 +0,0 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
- var cc = require('./cc-BWuAzFJ6.js');
4
-
5
- // Store the references to globals in case someone tries to monkey patch these, causing the below
6
- // to de-opt (this occurs often when using popular extensions).
7
- const noop = ()=>{};
8
-
9
- /**
10
- * @param {unknown} a
11
- * @param {unknown} b
12
- * @returns {boolean}
13
- */ function safe_not_equal(a, b) {
14
- return a != a ? b == b : a !== b || a !== null && typeof a === 'object' || typeof a === 'function';
15
- }
16
-
17
- var _globalThis_document;
18
- /** allow users to ignore aborted signal errors if `reason.name === 'StaleReactionError` */ new class StaleReactionError extends Error {
19
- constructor(...args){
20
- super(...args), this.name = 'StaleReactionError', this.message = 'The reaction that called `getAbortSignal()` was re-run or destroyed';
21
- }
22
- }();
23
- // We gotta write it like this because after downleveling the pure comment may end up in the wrong location
24
- !!((_globalThis_document = globalThis.document) == null ? void 0 : _globalThis_document.contentType) && /* @__PURE__ */ globalThis.document.contentType.includes('xml');
25
-
26
- /**
27
- * @type {Array<SubscribeInvalidateTuple<any> | any>}
28
- */ const subscriber_queue = [];
29
- /**
30
- * Create a `Writable` store that allows both updating and reading by subscription.
31
- *
32
- * @template T
33
- * @param {T} [value] initial value
34
- * @param {StartStopNotifier<T>} [start]
35
- * @returns {Writable<T>}
36
- */ function writable(value, start = noop) {
37
- /** @type {Unsubscriber | null} */ let stop = null;
38
- /** @type {Set<SubscribeInvalidateTuple<T>>} */ const subscribers = new Set();
39
- /**
40
- * @param {T} new_value
41
- * @returns {void}
42
- */ function set(new_value) {
43
- if (safe_not_equal(value, new_value)) {
44
- value = new_value;
45
- if (stop) {
46
- // store is ready
47
- const run_queue = !subscriber_queue.length;
48
- for (const subscriber of subscribers){
49
- subscriber[1]();
50
- subscriber_queue.push(subscriber, value);
51
- }
52
- if (run_queue) {
53
- for(let i = 0; i < subscriber_queue.length; i += 2){
54
- subscriber_queue[i][0](subscriber_queue[i + 1]);
55
- }
56
- subscriber_queue.length = 0;
57
- }
58
- }
59
- }
60
- }
61
- /**
62
- * @param {Updater<T>} fn
63
- * @returns {void}
64
- */ function update(fn) {
65
- set(fn(/** @type {T} */ value));
66
- }
67
- /**
68
- * @param {Subscriber<T>} run
69
- * @param {() => void} [invalidate]
70
- * @returns {Unsubscriber}
71
- */ function subscribe(run, invalidate = noop) {
72
- /** @type {SubscribeInvalidateTuple<T>} */ const subscriber = [
73
- run,
74
- invalidate
75
- ];
76
- subscribers.add(subscriber);
77
- if (subscribers.size === 1) {
78
- stop = start(set, update) || noop;
79
- }
80
- run(/** @type {T} */ value);
81
- return ()=>{
82
- subscribers.delete(subscriber);
83
- if (subscribers.size === 0 && stop) {
84
- stop();
85
- stop = null;
86
- }
87
- };
88
- }
89
- return {
90
- set,
91
- update,
92
- subscribe
93
- };
94
- }
95
-
96
- // Notify logic (no React dependencies)
97
- // Provides toast management and utilities for VanillaJS, Vue, Svelte, etc.
98
- class NotifyCore {
99
- generateId() {
100
- return `${++this.idCounter}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
101
- }
102
- subscribe(fn) {
103
- this.listeners.add(fn);
104
- fn(this.toasts);
105
- return ()=>this.listeners.delete(fn);
106
- }
107
- emit() {
108
- for (const fn of this.listeners)fn(this.toasts);
109
- }
110
- update(fn) {
111
- this.toasts = fn(this.toasts);
112
- this.emit();
113
- }
114
- dismiss(id) {
115
- const item = this.toasts.find((t)=>t.id === id);
116
- if (!item || item.exiting) return;
117
- this.update((prev)=>prev.map((t)=>t.id === id ? cc._extends({}, t, {
118
- exiting: true
119
- }) : t));
120
- setTimeout(()=>this.update((prev)=>prev.filter((t)=>t.id !== id)), 600);
121
- }
122
- show(opts) {
123
- var _ref, _ref1, _opts_type;
124
- // Use a unique identifier based on options (e.g., the title or a generated key)
125
- // If not provided, use a default one
126
- const id = opts.title ? `notify-${opts.title}` : "notify-default";
127
- const prevItem = this.toasts.find((t)=>t.id === id);
128
- const instanceId = (_ref = prevItem == null ? void 0 : prevItem.instanceId) != null ? _ref : this.generateId();
129
- // Set the state correctly
130
- const state = (_ref1 = (_opts_type = opts.type) != null ? _opts_type : prevItem == null ? void 0 : prevItem.type) != null ? _ref1 : "success";
131
- const item = cc._extends({}, prevItem, opts, {
132
- id,
133
- instanceId,
134
- type: state
135
- });
136
- this.update((prev)=>{
137
- const filtered = prev.filter((t)=>t.id !== id);
138
- return [
139
- ...filtered,
140
- item
141
- ];
142
- });
143
- return id;
144
- }
145
- getToasts() {
146
- return this.toasts;
147
- }
148
- constructor(){
149
- this.toasts = [];
150
- this.listeners = new Set();
151
- this.position = "top-right";
152
- this.options = undefined;
153
- this.idCounter = 0;
154
- }
155
- }
156
- // Global instance for multiplatform usage
157
- const notifyCore = new NotifyCore();
158
-
159
- // Svelte wrapper for Notify
160
- // Provides a store and function to show toasts in Svelte
161
- const notifyToasts = writable(notifyCore.getToasts());
162
- notifyCore.subscribe((t)=>notifyToasts.set(t));
163
- function showNotifyToast(options) {
164
- return notifyCore.show(options);
165
- }
166
-
167
- exports.notifyToasts = notifyToasts;
168
- exports.showNotifyToast = showNotifyToast;
package/dist/svelte.mjs DELETED
@@ -1,165 +0,0 @@
1
- import { _ as _extends } from './cc-he3fHS3P.mjs';
2
-
3
- // Store the references to globals in case someone tries to monkey patch these, causing the below
4
- // to de-opt (this occurs often when using popular extensions).
5
- const noop = ()=>{};
6
-
7
- /**
8
- * @param {unknown} a
9
- * @param {unknown} b
10
- * @returns {boolean}
11
- */ function safe_not_equal(a, b) {
12
- return a != a ? b == b : a !== b || a !== null && typeof a === 'object' || typeof a === 'function';
13
- }
14
-
15
- var _globalThis_document;
16
- /** allow users to ignore aborted signal errors if `reason.name === 'StaleReactionError` */ new class StaleReactionError extends Error {
17
- constructor(...args){
18
- super(...args), this.name = 'StaleReactionError', this.message = 'The reaction that called `getAbortSignal()` was re-run or destroyed';
19
- }
20
- }();
21
- // We gotta write it like this because after downleveling the pure comment may end up in the wrong location
22
- !!((_globalThis_document = globalThis.document) == null ? void 0 : _globalThis_document.contentType) && /* @__PURE__ */ globalThis.document.contentType.includes('xml');
23
-
24
- /**
25
- * @type {Array<SubscribeInvalidateTuple<any> | any>}
26
- */ const subscriber_queue = [];
27
- /**
28
- * Create a `Writable` store that allows both updating and reading by subscription.
29
- *
30
- * @template T
31
- * @param {T} [value] initial value
32
- * @param {StartStopNotifier<T>} [start]
33
- * @returns {Writable<T>}
34
- */ function writable(value, start = noop) {
35
- /** @type {Unsubscriber | null} */ let stop = null;
36
- /** @type {Set<SubscribeInvalidateTuple<T>>} */ const subscribers = new Set();
37
- /**
38
- * @param {T} new_value
39
- * @returns {void}
40
- */ function set(new_value) {
41
- if (safe_not_equal(value, new_value)) {
42
- value = new_value;
43
- if (stop) {
44
- // store is ready
45
- const run_queue = !subscriber_queue.length;
46
- for (const subscriber of subscribers){
47
- subscriber[1]();
48
- subscriber_queue.push(subscriber, value);
49
- }
50
- if (run_queue) {
51
- for(let i = 0; i < subscriber_queue.length; i += 2){
52
- subscriber_queue[i][0](subscriber_queue[i + 1]);
53
- }
54
- subscriber_queue.length = 0;
55
- }
56
- }
57
- }
58
- }
59
- /**
60
- * @param {Updater<T>} fn
61
- * @returns {void}
62
- */ function update(fn) {
63
- set(fn(/** @type {T} */ value));
64
- }
65
- /**
66
- * @param {Subscriber<T>} run
67
- * @param {() => void} [invalidate]
68
- * @returns {Unsubscriber}
69
- */ function subscribe(run, invalidate = noop) {
70
- /** @type {SubscribeInvalidateTuple<T>} */ const subscriber = [
71
- run,
72
- invalidate
73
- ];
74
- subscribers.add(subscriber);
75
- if (subscribers.size === 1) {
76
- stop = start(set, update) || noop;
77
- }
78
- run(/** @type {T} */ value);
79
- return ()=>{
80
- subscribers.delete(subscriber);
81
- if (subscribers.size === 0 && stop) {
82
- stop();
83
- stop = null;
84
- }
85
- };
86
- }
87
- return {
88
- set,
89
- update,
90
- subscribe
91
- };
92
- }
93
-
94
- // Notify logic (no React dependencies)
95
- // Provides toast management and utilities for VanillaJS, Vue, Svelte, etc.
96
- class NotifyCore {
97
- generateId() {
98
- return `${++this.idCounter}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
99
- }
100
- subscribe(fn) {
101
- this.listeners.add(fn);
102
- fn(this.toasts);
103
- return ()=>this.listeners.delete(fn);
104
- }
105
- emit() {
106
- for (const fn of this.listeners)fn(this.toasts);
107
- }
108
- update(fn) {
109
- this.toasts = fn(this.toasts);
110
- this.emit();
111
- }
112
- dismiss(id) {
113
- const item = this.toasts.find((t)=>t.id === id);
114
- if (!item || item.exiting) return;
115
- this.update((prev)=>prev.map((t)=>t.id === id ? _extends({}, t, {
116
- exiting: true
117
- }) : t));
118
- setTimeout(()=>this.update((prev)=>prev.filter((t)=>t.id !== id)), 600);
119
- }
120
- show(opts) {
121
- var _ref, _ref1, _opts_type;
122
- // Use a unique identifier based on options (e.g., the title or a generated key)
123
- // If not provided, use a default one
124
- const id = opts.title ? `notify-${opts.title}` : "notify-default";
125
- const prevItem = this.toasts.find((t)=>t.id === id);
126
- const instanceId = (_ref = prevItem == null ? void 0 : prevItem.instanceId) != null ? _ref : this.generateId();
127
- // Set the state correctly
128
- const state = (_ref1 = (_opts_type = opts.type) != null ? _opts_type : prevItem == null ? void 0 : prevItem.type) != null ? _ref1 : "success";
129
- const item = _extends({}, prevItem, opts, {
130
- id,
131
- instanceId,
132
- type: state
133
- });
134
- this.update((prev)=>{
135
- const filtered = prev.filter((t)=>t.id !== id);
136
- return [
137
- ...filtered,
138
- item
139
- ];
140
- });
141
- return id;
142
- }
143
- getToasts() {
144
- return this.toasts;
145
- }
146
- constructor(){
147
- this.toasts = [];
148
- this.listeners = new Set();
149
- this.position = "top-right";
150
- this.options = undefined;
151
- this.idCounter = 0;
152
- }
153
- }
154
- // Global instance for multiplatform usage
155
- const notifyCore = new NotifyCore();
156
-
157
- // Svelte wrapper for Notify
158
- // Provides a store and function to show toasts in Svelte
159
- const notifyToasts = writable(notifyCore.getToasts());
160
- notifyCore.subscribe((t)=>notifyToasts.set(t));
161
- function showNotifyToast(options) {
162
- return notifyCore.show(options);
163
- }
164
-
165
- export { notifyToasts, showNotifyToast };