crossnotify 0.0.1

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 (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +181 -0
  3. package/lib/module/Provider.js +27 -0
  4. package/lib/module/Provider.js.map +1 -0
  5. package/lib/module/Toast.native.js +323 -0
  6. package/lib/module/Toast.native.js.map +1 -0
  7. package/lib/module/Toaster.native.js +130 -0
  8. package/lib/module/Toaster.native.js.map +1 -0
  9. package/lib/module/index.js +6 -0
  10. package/lib/module/index.js.map +1 -0
  11. package/lib/module/index.web.js +85 -0
  12. package/lib/module/index.web.js.map +1 -0
  13. package/lib/module/notify.js +67 -0
  14. package/lib/module/notify.js.map +1 -0
  15. package/lib/module/package.json +1 -0
  16. package/lib/module/store.js +95 -0
  17. package/lib/module/store.js.map +1 -0
  18. package/lib/module/types.js +2 -0
  19. package/lib/module/types.js.map +1 -0
  20. package/lib/typescript/package.json +1 -0
  21. package/lib/typescript/src/Provider.d.ts +9 -0
  22. package/lib/typescript/src/Provider.d.ts.map +1 -0
  23. package/lib/typescript/src/Toast.native.d.ts +15 -0
  24. package/lib/typescript/src/Toast.native.d.ts.map +1 -0
  25. package/lib/typescript/src/Toaster.native.d.ts +7 -0
  26. package/lib/typescript/src/Toaster.native.d.ts.map +1 -0
  27. package/lib/typescript/src/index.d.ts +6 -0
  28. package/lib/typescript/src/index.d.ts.map +1 -0
  29. package/lib/typescript/src/index.web.d.ts +22 -0
  30. package/lib/typescript/src/index.web.d.ts.map +1 -0
  31. package/lib/typescript/src/notify.d.ts +13 -0
  32. package/lib/typescript/src/notify.d.ts.map +1 -0
  33. package/lib/typescript/src/store.d.ts +29 -0
  34. package/lib/typescript/src/store.d.ts.map +1 -0
  35. package/lib/typescript/src/types.d.ts +47 -0
  36. package/lib/typescript/src/types.d.ts.map +1 -0
  37. package/package.json +146 -0
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+
3
+ import { useMemo } from 'react';
4
+ import { StyleSheet, View } from 'react-native';
5
+ import { Toast } from "./Toast.native.js";
6
+ import { store, useToasts } from "./store.js";
7
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
+ // Optional peers — see the comment in Toast.native.tsx for why each require()
9
+ // must stay inline, in its own try/catch, right here (Metro's static
10
+ // optional-dependency detection is per-file).
11
+ let SafeAreaContext = null;
12
+ try {
13
+ SafeAreaContext = require('react-native-safe-area-context');
14
+ } catch {
15
+ SafeAreaContext = null;
16
+ }
17
+ let Reanimated = null;
18
+ try {
19
+ Reanimated = require('react-native-reanimated');
20
+ } catch {
21
+ Reanimated = null;
22
+ }
23
+
24
+ /** Test-only: lets __tests__ assert the guards resolved to null when a peer is absent. */
25
+ export const __optionalPeers = {
26
+ SafeAreaContext,
27
+ Reanimated
28
+ };
29
+
30
+ // Used only when react-native-safe-area-context isn't installed: a fixed
31
+ // approximation of a modern iOS device's safe area. Better than 0 padding,
32
+ // but not a substitute for the real per-device insets the library provides.
33
+ const FALLBACK_INSETS = {
34
+ top: 47,
35
+ bottom: 34
36
+ };
37
+ function useInsets() {
38
+ if (SafeAreaContext) {
39
+ // The presence of this optional peer is decided once at module-load
40
+ // time and never changes for the life of the app, so this call is
41
+ // stable across every render of a given app instance.
42
+ // eslint-disable-next-line react-hooks/rules-of-hooks
43
+ return SafeAreaContext.useSafeAreaInsets();
44
+ }
45
+ return FALLBACK_INSETS;
46
+ }
47
+ function groupForPosition(toasts, position, maxVisible) {
48
+ const inPosition = toasts.filter(toast => toast.position === position);
49
+ const visible = inPosition.slice(Math.max(0, inPosition.length - maxVisible));
50
+ return position === 'top' ? [...visible].reverse() : visible;
51
+ }
52
+ export function Toaster() {
53
+ const toasts = useToasts();
54
+ const insets = useInsets();
55
+ const {
56
+ maxVisible
57
+ } = store.getDefaults();
58
+ const topToasts = useMemo(() => groupForPosition(toasts, 'top', maxVisible), [toasts, maxVisible]);
59
+ const bottomToasts = useMemo(() => groupForPosition(toasts, 'bottom', maxVisible), [toasts, maxVisible]);
60
+ return /*#__PURE__*/_jsxs(View, {
61
+ style: StyleSheet.absoluteFillObject,
62
+ pointerEvents: "box-none",
63
+ children: [/*#__PURE__*/_jsx(View, {
64
+ style: [styles.stack, styles.top, {
65
+ paddingTop: insets.top + 12
66
+ }],
67
+ pointerEvents: "box-none",
68
+ children: topToasts.map(toast => /*#__PURE__*/_jsx(ToastSlot, {
69
+ toast: toast
70
+ }, toast.id))
71
+ }), /*#__PURE__*/_jsx(View, {
72
+ style: [styles.stack, styles.bottom, {
73
+ paddingBottom: insets.bottom + 12
74
+ }],
75
+ pointerEvents: "box-none",
76
+ children: bottomToasts.map(toast => /*#__PURE__*/_jsx(ToastSlot, {
77
+ toast: toast
78
+ }, toast.id))
79
+ })]
80
+ });
81
+ }
82
+ function ToastSlot({
83
+ toast
84
+ }) {
85
+ if (Reanimated) {
86
+ const AnimatedView = Reanimated.default.View;
87
+ return /*#__PURE__*/_jsx(AnimatedView, {
88
+ layout: Reanimated.LinearTransition,
89
+ style: styles.item,
90
+ children: /*#__PURE__*/_jsx(Toast, {
91
+ toast: toast,
92
+ onRequestDismiss: store.remove
93
+ })
94
+ });
95
+ }
96
+
97
+ // TODO: Animated fallback — no reflow animation when a toast is added or
98
+ // removed from the stack without reanimated; the stack just snaps to its
99
+ // new layout instead of animating it.
100
+ return /*#__PURE__*/_jsx(View, {
101
+ style: styles.item,
102
+ children: /*#__PURE__*/_jsx(Toast, {
103
+ toast: toast,
104
+ onRequestDismiss: store.remove
105
+ })
106
+ });
107
+ }
108
+ const styles = StyleSheet.create({
109
+ stack: {
110
+ position: 'absolute',
111
+ left: 0,
112
+ right: 0,
113
+ alignItems: 'center',
114
+ paddingHorizontal: 12
115
+ },
116
+ top: {
117
+ top: 0,
118
+ justifyContent: 'flex-start'
119
+ },
120
+ bottom: {
121
+ bottom: 0,
122
+ justifyContent: 'flex-end'
123
+ },
124
+ item: {
125
+ width: '100%',
126
+ alignItems: 'center',
127
+ marginBottom: 8
128
+ }
129
+ });
130
+ //# sourceMappingURL=Toaster.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useMemo","StyleSheet","View","Toast","store","useToasts","jsx","_jsx","jsxs","_jsxs","SafeAreaContext","require","Reanimated","__optionalPeers","FALLBACK_INSETS","top","bottom","useInsets","useSafeAreaInsets","groupForPosition","toasts","position","maxVisible","inPosition","filter","toast","visible","slice","Math","max","length","reverse","Toaster","insets","getDefaults","topToasts","bottomToasts","style","absoluteFillObject","pointerEvents","children","styles","stack","paddingTop","map","ToastSlot","id","paddingBottom","AnimatedView","default","layout","LinearTransition","item","onRequestDismiss","remove","create","left","right","alignItems","paddingHorizontal","justifyContent","width","marginBottom"],"sourceRoot":"../../src","sources":["Toaster.native.tsx"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAC/C,SAASC,KAAK,QAAQ,mBAAgB;AACtC,SAASC,KAAK,EAAEC,SAAS,QAAQ,YAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAG3C;AACA;AACA;AACA,IAAIC,eAAuE,GACzE,IAAI;AACN,IAAI;EACFA,eAAe,GAAGC,OAAO,CAAC,gCAAgC,CAAC;AAC7D,CAAC,CAAC,MAAM;EACND,eAAe,GAAG,IAAI;AACxB;AAEA,IAAIE,UAA2D,GAAG,IAAI;AACtE,IAAI;EACFA,UAAU,GAAGD,OAAO,CAAC,yBAAyB,CAAC;AACjD,CAAC,CAAC,MAAM;EACNC,UAAU,GAAG,IAAI;AACnB;;AAEA;AACA,OAAO,MAAMC,eAAe,GAAG;EAAEH,eAAe;EAAEE;AAAW,CAAC;;AAE9D;AACA;AACA;AACA,MAAME,eAAe,GAAG;EAAEC,GAAG,EAAE,EAAE;EAAEC,MAAM,EAAE;AAAG,CAAC;AAE/C,SAASC,SAASA,CAAA,EAAoC;EACpD,IAAIP,eAAe,EAAE;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,CACnD,CAAC;AAEX;AAEA,MAAMb,MAAM,GAAGxC,UAAU,CAACsD,MAAM,CAAC;EAC/Bb,KAAK,EAAE;IACLrB,QAAQ,EAAE,UAAU;IACpBmC,IAAI,EAAE,CAAC;IACPC,KAAK,EAAE,CAAC;IACRC,UAAU,EAAE,QAAQ;IACpBC,iBAAiB,EAAE;EACrB,CAAC;EACD5C,GAAG,EAAE;IACHA,GAAG,EAAE,CAAC;IACN6C,cAAc,EAAE;EAClB,CAAC;EACD5C,MAAM,EAAE;IACNA,MAAM,EAAE,CAAC;IACT4C,cAAc,EAAE;EAClB,CAAC;EACDR,IAAI,EAAE;IACJS,KAAK,EAAE,MAAM;IACbH,UAAU,EAAE,QAAQ;IACpBI,YAAY,EAAE;EAChB;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ export { notify } from "./notify.js";
4
+ export { default } from "./notify.js";
5
+ export { CrossNotifyProvider } from "./Provider.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["notify","default","CrossNotifyProvider"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,aAAU;AACjC,SAASC,OAAO,QAAQ,aAAU;AAClC,SAASC,mBAAmB,QAAQ,eAAY","ignoreList":[]}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ import { Fragment, createElement, useEffect, useState } from 'react';
4
+ import { Toaster as SonnerToaster, toast as sonnerToast } from 'sonner';
5
+ let defaults = {
6
+ preset: 'native',
7
+ position: 'bottom',
8
+ duration: 4000,
9
+ maxVisible: 3
10
+ };
11
+ function toSonnerPosition(position) {
12
+ return position === 'top' ? 'top-center' : 'bottom-center';
13
+ }
14
+ function resolveDuration(variant, options) {
15
+ if (options?.duration !== undefined) {
16
+ // Sonner only special-cases a literal Infinity as sticky; 0 would fire almost
17
+ // immediately (the same setTimeout(_, 0) coercion we guard against natively).
18
+ return options.duration === 0 ? Infinity : options.duration;
19
+ }
20
+ if (variant === 'loading') {
21
+ return Infinity;
22
+ }
23
+ return defaults.duration;
24
+ }
25
+ function upsertToast(message, variant, options) {
26
+ const sonnerOptions = {
27
+ id: options?.id,
28
+ description: options?.description,
29
+ duration: resolveDuration(variant, options),
30
+ position: toSonnerPosition(options?.position ?? defaults.position)
31
+ };
32
+ switch (variant) {
33
+ case 'success':
34
+ return String(sonnerToast.success(message, sonnerOptions));
35
+ case 'error':
36
+ return String(sonnerToast.error(message, sonnerOptions));
37
+ case 'loading':
38
+ return String(sonnerToast.loading(message, sonnerOptions));
39
+ default:
40
+ return String(sonnerToast(message, sonnerOptions));
41
+ }
42
+ }
43
+ const notify = (message, options) => upsertToast(message, options?.variant ?? 'default', options);
44
+ notify.success = (message, options) => upsertToast(message, 'success', options);
45
+ notify.error = (message, options) => upsertToast(message, 'error', options);
46
+ notify.loading = (message, options) => upsertToast(message, 'loading', options);
47
+ notify.dismiss = id => {
48
+ sonnerToast.dismiss(id);
49
+ };
50
+ notify.promise = (promise, messages, options) => {
51
+ sonnerToast.promise(promise, {
52
+ id: options?.id,
53
+ description: options?.description,
54
+ position: toSonnerPosition(options?.position ?? defaults.position),
55
+ loading: messages.loading,
56
+ success: messages.success,
57
+ error: messages.error
58
+ });
59
+ return promise;
60
+ };
61
+ export { notify };
62
+ export default notify;
63
+ export function CrossNotifyProvider({
64
+ children,
65
+ defaults: providedDefaults
66
+ }) {
67
+ const [resolved, setResolved] = useState(defaults);
68
+ useEffect(() => {
69
+ if (providedDefaults) {
70
+ defaults = {
71
+ ...defaults,
72
+ ...providedDefaults
73
+ };
74
+ setResolved(defaults);
75
+ }
76
+ // Defaults are written once at mount, mirroring the native provider.
77
+ // eslint-disable-next-line react-hooks/exhaustive-deps
78
+ }, []);
79
+ return /*#__PURE__*/createElement(Fragment, null, children, /*#__PURE__*/createElement(SonnerToaster, {
80
+ position: toSonnerPosition(resolved.position),
81
+ visibleToasts: resolved.maxVisible,
82
+ theme: 'system'
83
+ }));
84
+ }
85
+ //# sourceMappingURL=index.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Fragment","createElement","useEffect","useState","Toaster","SonnerToaster","toast","sonnerToast","defaults","preset","position","duration","maxVisible","toSonnerPosition","resolveDuration","variant","options","undefined","Infinity","upsertToast","message","sonnerOptions","id","description","String","success","error","loading","notify","dismiss","promise","messages","CrossNotifyProvider","children","providedDefaults","resolved","setResolved","visibleToasts","theme"],"sourceRoot":"../../src","sources":["index.web.ts"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,aAAa,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAEpE,SAASC,OAAO,IAAIC,aAAa,EAAEC,KAAK,IAAIC,WAAW,QAAQ,QAAQ;AAoBvE,IAAIC,QAAwB,GAAG;EAC7BC,MAAM,EAAE,QAAQ;EAChBC,QAAQ,EAAE,QAAQ;EAClBC,QAAQ,EAAE,IAAI;EACdC,UAAU,EAAE;AACd,CAAC;AAED,SAASC,gBAAgBA,CACvBH,QAAoC,EACJ;EAChC,OAAOA,QAAQ,KAAK,KAAK,GAAG,YAAY,GAAG,eAAe;AAC5D;AAEA,SAASI,eAAeA,CACtBC,OAAsB,EACtBC,OAAuB,EACf;EACR,IAAIA,OAAO,EAAEL,QAAQ,KAAKM,SAAS,EAAE;IACnC;IACA;IACA,OAAOD,OAAO,CAACL,QAAQ,KAAK,CAAC,GAAGO,QAAQ,GAAGF,OAAO,CAACL,QAAQ;EAC7D;EACA,IAAII,OAAO,KAAK,SAAS,EAAE;IACzB,OAAOG,QAAQ;EACjB;EACA,OAAOV,QAAQ,CAACG,QAAQ;AAC1B;AAEA,SAASQ,WAAWA,CAClBC,OAAe,EACfL,OAAsB,EACtBC,OAAuB,EACf;EACR,MAAMK,aAAa,GAAG;IACpBC,EAAE,EAAEN,OAAO,EAAEM,EAAE;IACfC,WAAW,EAAEP,OAAO,EAAEO,WAAW;IACjCZ,QAAQ,EAAEG,eAAe,CA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A,OAAO,EAAE;IAC3BR,EAAE,EAAEN,OAAO,EAAEM,EAAE;IACfC,WAAW,EAAEP,OAAO,EAAEO,WAAW;IACjCb,QAAQ,EAAEG,gBAAgB,CAACG,OAAO,EAAEN,QAAQ,IAAIF,QAAQ,CAACE,QAAQ,CAAC;IAClEiB,OAAO,EAAEI,QAAQ,CAACJ,OAAO;IACzBF,OAAO,EAAEM,QAAQ,CAACN,OAAO;IACzBC,KAAK,EAAEK,QAAQ,CAACL;EAClB,CAAC,CAAC;EAEF,OAAOI,OAAO;AAChB,CAAC;AAED,SAASF,MAAM;AACf,eAAeA,MAAM;AASrB,OAAO,SAASI,mBAAmBA,CAAC;EAClCC,QAAQ;EACRzB,QAAQ,EAAE0B;AACc,CAAC,EAAE;EAC3B,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGjC,QAAQ,CAACK,QAAQ,CAAC;EAElDN,SAAS,CAAC,MAAM;IACd,IAAIgC,gBAAgB,EAAE;MACpB1B,QAAQ,GAAG;QAAE,GAAGA,QAAQ;QAAE,GAAG0B;MAAiB,CAAC;MAC/CE,WAAW,CAAC5B,QAAQ,CAAC;IACvB;IACA;IACA;EACF,CAAC,EAAE,EAAE,CAAC;EAEN,oBAAOP,aAAa,CAClBD,QAAQ,EACR,IAAI,EACJiC,QAAQ,eACRhC,aAAa,CAACI,aAAa,EAAE;IAC3BK,QAAQ,EAAEG,gBAAgB,CAACsB,QAAQ,CAACzB,QAAQ,CAAC;IAC7C2B,aAAa,EAAEF,QAAQ,CAACvB,UAAU;IAClC0B,KAAK,EAAE;EACT,CAAC,CACH,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ import { store } from "./store.js";
4
+ function generateId() {
5
+ return `crossnotify-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
6
+ }
7
+ function resolveDuration(variant, options) {
8
+ if (options?.duration !== undefined) {
9
+ return options.duration;
10
+ }
11
+ if (variant === 'loading') {
12
+ return Infinity;
13
+ }
14
+ return store.getDefaults().duration;
15
+ }
16
+ function upsertToast(message, variant, options) {
17
+ const id = options?.id ?? generateId();
18
+ const defaults = store.getDefaults();
19
+ const toast = {
20
+ id,
21
+ message,
22
+ description: options?.description,
23
+ variant,
24
+ preset: options?.preset ?? defaults.preset,
25
+ position: options?.position ?? defaults.position,
26
+ duration: resolveDuration(variant, options),
27
+ createdAt: Date.now()
28
+ };
29
+ if (store.has(id)) {
30
+ store.update(id, toast);
31
+ } else {
32
+ store.add(toast);
33
+ }
34
+ return id;
35
+ }
36
+ const notify = (message, options) => upsertToast(message, options?.variant ?? 'default', options);
37
+ notify.success = (message, options) => upsertToast(message, 'success', options);
38
+ notify.error = (message, options) => upsertToast(message, 'error', options);
39
+ notify.loading = (message, options) => upsertToast(message, 'loading', options);
40
+ notify.dismiss = id => {
41
+ if (id) {
42
+ store.remove(id);
43
+ } else {
44
+ store.clear();
45
+ }
46
+ };
47
+ notify.promise = (promise, messages, options) => {
48
+ const id = notify.loading(messages.loading, options);
49
+ return promise.then(data => {
50
+ const message = typeof messages.success === 'function' ? messages.success(data) : messages.success;
51
+ upsertToast(message, 'success', {
52
+ ...options,
53
+ id
54
+ });
55
+ return data;
56
+ }, error => {
57
+ const message = typeof messages.error === 'function' ? messages.error(error) : messages.error;
58
+ upsertToast(message, 'error', {
59
+ ...options,
60
+ id
61
+ });
62
+ throw error;
63
+ });
64
+ };
65
+ export { notify };
66
+ export default notify;
67
+ //# sourceMappingURL=notify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["store","generateId","Date","now","Math","random","toString","slice","resolveDuration","variant","options","duration","undefined","Infinity","getDefaults","upsertToast","message","id","defaults","toast","description","preset","position","createdAt","has","update","add","notify","success","error","loading","dismiss","remove","clear","promise","messages","then","data"],"sourceRoot":"../../src","sources":["notify.ts"],"mappings":";;AAAA,SAASA,KAAK,QAAQ,YAAS;AAQ/B,SAASC,UAAUA,CAAA,EAAW;EAC5B,OAAO,eAAeC,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M,QAAQ,CAACN,KAAK;IACpBd,WAAW,CAACC,OAAO,EAAE,OAAO,EAAE;MAAE,GAAGN,OAAO;MAAEO;IAAG,CAAC,CAAC;IACjD,MAAMY,KAAK;EACb,CACF,CAAC;AACH,CAAC;AAED,SAASF,MAAM;AACf,eAAeA,MAAM","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ import { useSyncExternalStore } from 'react';
4
+ const DEFAULT_DEFAULTS = {
5
+ preset: 'native',
6
+ position: 'bottom',
7
+ duration: 4000,
8
+ maxVisible: 3
9
+ };
10
+ const DEFAULT_THEME = {
11
+ backgroundColor: '#1c1c1e',
12
+ textColor: '#ffffff',
13
+ successColor: '#30d158',
14
+ errorColor: '#ff453a',
15
+ accentColor: '#0a84ff',
16
+ radius: 999,
17
+ blurIntensity: 40
18
+ };
19
+ let toasts = [];
20
+ let defaults = {
21
+ ...DEFAULT_DEFAULTS
22
+ };
23
+ let theme = {
24
+ ...DEFAULT_THEME
25
+ };
26
+ const listeners = new Set();
27
+ function emit() {
28
+ for (const listener of listeners) {
29
+ listener();
30
+ }
31
+ }
32
+ function subscribe(listener) {
33
+ listeners.add(listener);
34
+ return () => listeners.delete(listener);
35
+ }
36
+ function getSnapshot() {
37
+ return toasts;
38
+ }
39
+ function add(toast) {
40
+ toasts = [...toasts, toast];
41
+ emit();
42
+ }
43
+ function update(id, patch) {
44
+ toasts = toasts.map(toast => toast.id === id ? {
45
+ ...toast,
46
+ ...patch
47
+ } : toast);
48
+ emit();
49
+ }
50
+ function has(id) {
51
+ return toasts.some(toast => toast.id === id);
52
+ }
53
+ function remove(id) {
54
+ toasts = toasts.filter(toast => toast.id !== id);
55
+ emit();
56
+ }
57
+ function clear() {
58
+ toasts = [];
59
+ emit();
60
+ }
61
+ function getDefaults() {
62
+ return defaults;
63
+ }
64
+ function setDefaults(next) {
65
+ defaults = {
66
+ ...defaults,
67
+ ...next
68
+ };
69
+ }
70
+ function getTheme() {
71
+ return theme;
72
+ }
73
+ function setTheme(next) {
74
+ theme = {
75
+ ...theme,
76
+ ...next
77
+ };
78
+ }
79
+ export const store = {
80
+ subscribe,
81
+ getSnapshot,
82
+ add,
83
+ update,
84
+ has,
85
+ remove,
86
+ clear,
87
+ getDefaults,
88
+ setDefaults,
89
+ getTheme,
90
+ setTheme
91
+ };
92
+ export function useToasts() {
93
+ return useSyncExternalStore(store.subscribe, store.getSnapshot);
94
+ }
95
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useSyncExternalStore","DEFAULT_DEFAULTS","preset","position","duration","maxVisible","DEFAULT_THEME","backgroundColor","textColor","successColor","errorColor","accentColor","radius","blurIntensity","toasts","defaults","theme","listeners","Set","emit","listener","subscribe","add","delete","getSnapshot","toast","update","id","patch","map","has","some","remove","filter","clear","getDefaults","setDefaults","next","getTheme","setTheme","store","useToasts"],"sourceRoot":"../../src","sources":["store.ts"],"mappings":";;AAAA,SAASA,oBAAoB,QAAQ,OAAO;AAK5C,MAAMC,gBAAgC,GAAG;EACvCC,MAAM,EAAE,QAAQ;EAChBC,QAAQ,EAAE,QAAQ;EAClBC,QAAQ,EAAE,IAAI;EACdC,UAAU,EAAE;AACd,CAAC;AAED,MAAMC,aAA0B,GAAG;EACjCC,eAAe,EAAE,SAAS;EAC1BC,SAAS,EAAE,SAAS;EACpBC,YAAY,EAAE,SAAS;EACvBC,UAAU,EAAE,SAAS;EACrBC,WAAW,EAAE,SAAS;EACtBC,MAAM,EAAE,GAAG;EACXC,aAAa,EAAE;AACjB,CAAC;AAED,IAAIC,MAAmB,GAAG,EAAE;AAC5B,IAAIC,QAAwB,GAAG;EAAE,GAAGd;AAAiB,CAAC;AACtD,IAAIe,KAAkB,GAAG;EAAE,GAAGV;AAAc,CAAC;AAC7C,MAAMW,SAAS,GAAG,IAAIC,GAAG,CAAW,CAAC;AAErC,SAASC,IAAIA,CAAA,EAAS;EACpB,KAAK,MAA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AgB;EAC/B,OAAOtB,KAAK;AACd;AAEA,SAASuB,QAAQA,CAACF,IAA0B,EAAQ;EAClDrB,KAAK,GAAG;IAAE,GAAGA,KAAK;IAAE,GAAGqB;EAAK,CAAC;AAC/B;AAEA,OAAO,MAAMG,KAAK,GAAG;EACnBnB,SAAS;EACTG,WAAW;EACXF,GAAG;EACHI,MAAM;EACNI,GAAG;EACHE,MAAM;EACNE,KAAK;EACLC,WAAW;EACXC,WAAW;EACXE,QAAQ;EACRC;AACF,CAAC;AAED,OAAO,SAASE,SAASA,CAAA,EAAgB;EACvC,OAAOzC,oBAAoB,CAACwC,KAAK,CAACnB,SAAS,EAAEmB,KAAK,CAAChB,WAAW,CAAC;AACjE","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,9 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { NotifyDefaults, NotifyTheme } from './types.js';
3
+ export interface CrossNotifyProviderProps {
4
+ children?: ReactNode;
5
+ defaults?: Partial<NotifyDefaults>;
6
+ theme?: Partial<NotifyTheme>;
7
+ }
8
+ export declare function CrossNotifyProvider({ children, defaults, theme, }: CrossNotifyProviderProps): import("react").JSX.Element;
9
+ //# sourceMappingURL=Provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/Provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAS,CAAC;AAE3D,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACnC,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAC9B;AAED,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,QAAQ,EACR,KAAK,GACN,EAAE,wBAAwB,+BAmB1B"}
@@ -0,0 +1,15 @@
1
+ import type { ToastData } from './types.js';
2
+ /** Test-only: lets __tests__ assert the guards resolved to null when a peer is absent. */
3
+ export declare const __optionalPeers: {
4
+ BlurView: typeof import("expo-blur").BlurView | null;
5
+ Haptics: typeof import("expo-haptics") | null;
6
+ SymbolView: typeof import("expo-symbols").SymbolView | null;
7
+ Reanimated: typeof import("react-native-reanimated") | null;
8
+ };
9
+ interface ToastProps {
10
+ toast: ToastData;
11
+ onRequestDismiss: (id: string) => void;
12
+ }
13
+ export declare function Toast(props: ToastProps): import("react").JSX.Element;
14
+ export {};
15
+ //# sourceMappingURL=Toast.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toast.native.d.ts","sourceRoot":"","sources":["../../../src/Toast.native.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAA+B,SAAS,EAAE,MAAM,YAAS,CAAC;AAwCtE,0FAA0F;AAC1F,eAAO,MAAM,eAAe;;;;;CAAgD,CAAC;AAqB7E,UAAU,UAAU;IAClB,KAAK,EAAE,SAAS,CAAC;IACjB,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,+BAKtC"}
@@ -0,0 +1,7 @@
1
+ /** Test-only: lets __tests__ assert the guards resolved to null when a peer is absent. */
2
+ export declare const __optionalPeers: {
3
+ SafeAreaContext: typeof import("react-native-safe-area-context") | null;
4
+ Reanimated: typeof import("react-native-reanimated") | null;
5
+ };
6
+ export declare function Toaster(): import("react").JSX.Element;
7
+ //# sourceMappingURL=Toaster.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toaster.native.d.ts","sourceRoot":"","sources":["../../../src/Toaster.native.tsx"],"names":[],"mappings":"AAwBA,0FAA0F;AAC1F,eAAO,MAAM,eAAe;;;CAAkC,CAAC;AA4B/D,wBAAgB,OAAO,gCAsCtB"}
@@ -0,0 +1,6 @@
1
+ export { notify } from './notify.js';
2
+ export { default } from './notify.js';
3
+ export { CrossNotifyProvider } from './Provider.js';
4
+ export type { CrossNotifyProviderProps } from './Provider.js';
5
+ export type { NotifyDefaults, NotifyOptions, NotifyPosition, NotifyPreset, NotifyPromiseMessages, NotifyTheme, NotifyVariant, ToastData, } from './types.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAU,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAY,CAAC;AACjD,YAAY,EAAE,wBAAwB,EAAE,MAAM,eAAY,CAAC;AAC3D,YAAY,EACV,cAAc,EACd,aAAa,EACb,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,WAAW,EACX,aAAa,EACb,SAAS,GACV,MAAM,YAAS,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { NotifyDefaults, NotifyOptions, NotifyPromiseMessages, NotifyTheme } from './types.js';
3
+ export type { NotifyDefaults, NotifyOptions, NotifyPosition, NotifyPreset, NotifyPromiseMessages, NotifyTheme, NotifyVariant, ToastData, } from './types.js';
4
+ interface Notify {
5
+ (message: string, options?: NotifyOptions): string;
6
+ success: (message: string, options?: NotifyOptions) => string;
7
+ error: (message: string, options?: NotifyOptions) => string;
8
+ loading: (message: string, options?: NotifyOptions) => string;
9
+ dismiss: (id?: string) => void;
10
+ promise: <T>(promise: Promise<T>, messages: NotifyPromiseMessages<T>, options?: NotifyOptions) => Promise<T>;
11
+ }
12
+ declare const notify: Notify;
13
+ export { notify };
14
+ export default notify;
15
+ export interface CrossNotifyProviderProps {
16
+ children?: ReactNode;
17
+ defaults?: Partial<NotifyDefaults>;
18
+ /** Accepted for API parity with the native provider; sonner themes itself via CSS on web. */
19
+ theme?: Partial<NotifyTheme>;
20
+ }
21
+ export declare function CrossNotifyProvider({ children, defaults: providedDefaults, }: CrossNotifyProviderProps): import("react").FunctionComponentElement<import("react").FragmentProps>;
22
+ //# sourceMappingURL=index.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../src/index.web.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,WAAW,EAEZ,MAAM,YAAS,CAAC;AAEjB,YAAY,EACV,cAAc,EACd,aAAa,EACb,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,WAAW,EACX,aAAa,EACb,SAAS,GACV,MAAM,YAAS,CAAC;AAsDjB,UAAU,MAAM;IACd,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;IACnD,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,KAAK,MAAM,CAAC;IAC9D,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,KAAK,MAAM,CAAC;IAC5D,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,KAAK,MAAM,CAAC;IAC9D,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,OAAO,EAAE,CAAC,CAAC,EACT,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,QAAQ,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAClC,OAAO,CAAC,EAAE,aAAa,KACpB,OAAO,CAAC,CAAC,CAAC,CAAC;CACjB;AAED,QAAA,MAAM,MAAM,EACuD,MAAM,CAAC;AAuB1E,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,eAAe,MAAM,CAAC;AAEtB,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IACnC,6FAA6F;IAC7F,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CAC9B;AAED,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,QAAQ,EAAE,gBAAgB,GAC3B,EAAE,wBAAwB,2EAsB1B"}
@@ -0,0 +1,13 @@
1
+ import type { NotifyOptions, NotifyPromiseMessages } from './types.js';
2
+ interface Notify {
3
+ (message: string, options?: NotifyOptions): string;
4
+ success: (message: string, options?: NotifyOptions) => string;
5
+ error: (message: string, options?: NotifyOptions) => string;
6
+ loading: (message: string, options?: NotifyOptions) => string;
7
+ dismiss: (id?: string) => void;
8
+ promise: <T>(promise: Promise<T>, messages: NotifyPromiseMessages<T>, options?: NotifyOptions) => Promise<T>;
9
+ }
10
+ declare const notify: Notify;
11
+ export { notify };
12
+ export default notify;
13
+ //# sourceMappingURL=notify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notify.d.ts","sourceRoot":"","sources":["../../../src/notify.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,qBAAqB,EAGtB,MAAM,YAAS,CAAC;AA+CjB,UAAU,MAAM;IACd,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;IACnD,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,KAAK,MAAM,CAAC;IAC9D,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,KAAK,MAAM,CAAC;IAC5D,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,KAAK,MAAM,CAAC;IAC9D,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,OAAO,EAAE,CAAC,CAAC,EACT,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,QAAQ,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAClC,OAAO,CAAC,EAAE,aAAa,KACpB,OAAO,CAAC,CAAC,CAAC,CAAC;CACjB;AAED,QAAA,MAAM,MAAM,EACuD,MAAM,CAAC;AAqC1E,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,eAAe,MAAM,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { NotifyDefaults, NotifyTheme, ToastData } from './types.js';
2
+ type Listener = () => void;
3
+ declare function subscribe(listener: Listener): () => void;
4
+ declare function getSnapshot(): ToastData[];
5
+ declare function add(toast: ToastData): void;
6
+ declare function update(id: string, patch: Partial<Omit<ToastData, 'id'>>): void;
7
+ declare function has(id: string): boolean;
8
+ declare function remove(id: string): void;
9
+ declare function clear(): void;
10
+ declare function getDefaults(): NotifyDefaults;
11
+ declare function setDefaults(next: Partial<NotifyDefaults>): void;
12
+ declare function getTheme(): NotifyTheme;
13
+ declare function setTheme(next: Partial<NotifyTheme>): void;
14
+ export declare const store: {
15
+ subscribe: typeof subscribe;
16
+ getSnapshot: typeof getSnapshot;
17
+ add: typeof add;
18
+ update: typeof update;
19
+ has: typeof has;
20
+ remove: typeof remove;
21
+ clear: typeof clear;
22
+ getDefaults: typeof getDefaults;
23
+ setDefaults: typeof setDefaults;
24
+ getTheme: typeof getTheme;
25
+ setTheme: typeof setTheme;
26
+ };
27
+ export declare function useToasts(): ToastData[];
28
+ export {};
29
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAS,CAAC;AAEtE,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC;AA8B3B,iBAAS,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,IAAI,CAGjD;AAED,iBAAS,WAAW,IAAI,SAAS,EAAE,CAElC;AAED,iBAAS,GAAG,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAGnC;AAED,iBAAS,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,GAAG,IAAI,CAKvE;AAED,iBAAS,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEhC;AAED,iBAAS,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAGhC;AAED,iBAAS,KAAK,IAAI,IAAI,CAGrB;AAED,iBAAS,WAAW,IAAI,cAAc,CAErC;AAED,iBAAS,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI,CAExD;AAED,iBAAS,QAAQ,IAAI,WAAW,CAE/B;AAED,iBAAS,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CAElD;AAED,eAAO,MAAM,KAAK;;;;;;;;;;;;CAYjB,CAAC;AAEF,wBAAgB,SAAS,IAAI,SAAS,EAAE,CAEvC"}
@@ -0,0 +1,47 @@
1
+ export type NotifyPreset = 'native' | 'glass' | 'flat' | 'minimal';
2
+ export type NotifyVariant = 'default' | 'success' | 'error' | 'loading';
3
+ export type NotifyPosition = 'top' | 'bottom';
4
+ export interface NotifyOptions {
5
+ id?: string;
6
+ description?: string;
7
+ variant?: NotifyVariant;
8
+ preset?: NotifyPreset;
9
+ position?: NotifyPosition;
10
+ /** Milliseconds before auto-dismiss. 0 or Infinity means sticky (no auto-dismiss). */
11
+ duration?: number;
12
+ }
13
+ export interface ToastData {
14
+ id: string;
15
+ message: string;
16
+ description?: string;
17
+ variant: NotifyVariant;
18
+ preset: NotifyPreset;
19
+ position: NotifyPosition;
20
+ duration: number;
21
+ createdAt: number;
22
+ }
23
+ export interface NotifyDefaults {
24
+ preset: NotifyPreset;
25
+ position: NotifyPosition;
26
+ duration: number;
27
+ /** Maximum number of toasts rendered per position at once; older ones are dropped from view. */
28
+ maxVisible: number;
29
+ }
30
+ export interface NotifyTheme {
31
+ backgroundColor: string;
32
+ textColor: string;
33
+ successColor: string;
34
+ errorColor: string;
35
+ /** Accent color for the default/loading variant icon. */
36
+ accentColor: string;
37
+ /** Pill corner radius. */
38
+ radius: number;
39
+ /** expo-blur intensity, 1-100. */
40
+ blurIntensity: number;
41
+ }
42
+ export interface NotifyPromiseMessages<T = unknown> {
43
+ loading: string;
44
+ success: string | ((data: T) => string);
45
+ error: string | ((error: unknown) => string);
46
+ }
47
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEnE,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAExE,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,sFAAsF;IACtF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM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