@buoy-gg/notifications 7.0.41 → 7.0.42

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 (71) hide show
  1. package/lib/commonjs/components/LocalNotificationTest.js +1 -185
  2. package/lib/commonjs/components/NotificationTestView.js +1 -329
  3. package/lib/commonjs/components/NotificationToolView.js +1 -673
  4. package/lib/commonjs/components/notificationStyles.js +1 -292
  5. package/lib/commonjs/expo.js +1 -247
  6. package/lib/commonjs/index.js +1 -148
  7. package/lib/commonjs/json.js +1 -58
  8. package/lib/commonjs/payload.js +1 -68
  9. package/lib/commonjs/preset.js +1 -56
  10. package/lib/commonjs/preview.js +1 -18
  11. package/lib/commonjs/recorder.js +1 -339
  12. package/lib/commonjs/runtime.js +1 -110
  13. package/lib/commonjs/storage.js +1 -61
  14. package/lib/commonjs/types.js +0 -1
  15. package/lib/module/components/LocalNotificationTest.js +1 -180
  16. package/lib/module/components/NotificationTestView.js +1 -324
  17. package/lib/module/components/NotificationToolView.js +1 -668
  18. package/lib/module/components/notificationStyles.js +1 -288
  19. package/lib/module/expo.js +1 -241
  20. package/lib/module/index.js +1 -13
  21. package/lib/module/json.js +1 -51
  22. package/lib/module/payload.js +1 -63
  23. package/lib/module/preset.js +1 -50
  24. package/lib/module/preview.js +1 -14
  25. package/lib/module/recorder.js +1 -332
  26. package/lib/module/runtime.js +1 -103
  27. package/lib/module/storage.js +1 -56
  28. package/lib/module/types.js +0 -1
  29. package/package.json +2 -2
  30. package/lib/commonjs/components/LocalNotificationTest.js.map +0 -1
  31. package/lib/commonjs/components/NotificationTestView.js.map +0 -1
  32. package/lib/commonjs/components/NotificationToolView.js.map +0 -1
  33. package/lib/commonjs/components/notificationStyles.js.map +0 -1
  34. package/lib/commonjs/expo.js.map +0 -1
  35. package/lib/commonjs/index.js.map +0 -1
  36. package/lib/commonjs/json.js.map +0 -1
  37. package/lib/commonjs/payload.js.map +0 -1
  38. package/lib/commonjs/preset.js.map +0 -1
  39. package/lib/commonjs/preview.js.map +0 -1
  40. package/lib/commonjs/recorder.js.map +0 -1
  41. package/lib/commonjs/runtime.js.map +0 -1
  42. package/lib/commonjs/storage.js.map +0 -1
  43. package/lib/commonjs/types.js.map +0 -1
  44. package/lib/module/components/LocalNotificationTest.js.map +0 -1
  45. package/lib/module/components/NotificationTestView.js.map +0 -1
  46. package/lib/module/components/NotificationToolView.js.map +0 -1
  47. package/lib/module/components/notificationStyles.js.map +0 -1
  48. package/lib/module/expo.js.map +0 -1
  49. package/lib/module/index.js.map +0 -1
  50. package/lib/module/json.js.map +0 -1
  51. package/lib/module/payload.js.map +0 -1
  52. package/lib/module/preset.js.map +0 -1
  53. package/lib/module/preview.js.map +0 -1
  54. package/lib/module/recorder.js.map +0 -1
  55. package/lib/module/runtime.js.map +0 -1
  56. package/lib/module/storage.js.map +0 -1
  57. package/lib/module/types.js.map +0 -1
  58. package/lib/typescript/components/LocalNotificationTest.d.ts.map +0 -1
  59. package/lib/typescript/components/NotificationTestView.d.ts.map +0 -1
  60. package/lib/typescript/components/NotificationToolView.d.ts.map +0 -1
  61. package/lib/typescript/components/notificationStyles.d.ts.map +0 -1
  62. package/lib/typescript/expo.d.ts.map +0 -1
  63. package/lib/typescript/index.d.ts.map +0 -1
  64. package/lib/typescript/json.d.ts.map +0 -1
  65. package/lib/typescript/payload.d.ts.map +0 -1
  66. package/lib/typescript/preset.d.ts.map +0 -1
  67. package/lib/typescript/preview.d.ts.map +0 -1
  68. package/lib/typescript/recorder.d.ts.map +0 -1
  69. package/lib/typescript/runtime.d.ts.map +0 -1
  70. package/lib/typescript/storage.d.ts.map +0 -1
  71. package/lib/typescript/types.d.ts.map +0 -1
@@ -1,185 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.LocalNotificationTest = LocalNotificationTest;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _reactNative = require("react-native");
9
- var _sharedUi = require("@buoy-gg/shared-ui");
10
- var _NotificationTestView = require("./NotificationTestView");
11
- var _jsxRuntime = require("react/jsx-runtime");
12
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
13
- function LocalNotificationTest({
14
- snapshot,
15
- onAction,
16
- onViewActivity
17
- }) {
18
- const [title, setTitle] = (0, _react.useState)("Test notification");
19
- const [message, setMessage] = (0, _react.useState)("Tap to open the app.");
20
- const [data, setData] = (0, _react.useState)("{}");
21
- const [seconds, setSeconds] = (0, _react.useState)("1");
22
- const [busy, setBusy] = (0, _react.useState)(false);
23
- const lock = (0, _react.useRef)(false);
24
- const [error, setError] = (0, _react.useState)(null);
25
- const [latest, setLatest] = (0, _react.useState)(null);
26
- let custom = {};
27
- let validation = null;
28
- try {
29
- custom = JSON.parse(data);
30
- if (!custom || typeof custom !== "object" || Array.isArray(custom)) throw new Error();
31
- } catch {
32
- validation = "Custom data must be a JSON object. Open Options to edit it.";
33
- }
34
- async function send() {
35
- if (lock.current || validation) return;
36
- lock.current = true;
37
- setBusy(true);
38
- setLatest(null);
39
- setError(null);
40
- const test = {
41
- testId: `buoy-local-${Date.now()}-${Math.random().toString(36).slice(2)}`,
42
- startedAt: Date.now(),
43
- appId: snapshot?.appId ?? null
44
- };
45
- try {
46
- await onAction("setCaptureSession", {
47
- runId: test.testId,
48
- durationMs: 1800000
49
- });
50
- await onAction("scheduleLocal", {
51
- title,
52
- body: message,
53
- data: {
54
- ...custom,
55
- __buoyTestId: test.testId
56
- },
57
- seconds: Number(seconds)
58
- });
59
- setLatest(test);
60
- } catch (error) {
61
- setError(error instanceof Error ? error.message : String(error));
62
- } finally {
63
- lock.current = false;
64
- setBusy(false);
65
- }
66
- }
67
- const events = latest && latest.appId === snapshot?.appId ? snapshot.events.filter(event => event.testId === latest.testId && event.capturedAt >= latest.startedAt) : [];
68
- const received = events.some(event => event.kind === "received");
69
- const tapped = events.some(event => event.kind === "response" || event.kind === "startup-response");
70
- const outcome = events.some(event => event.kind === "app-outcome");
71
- const supported = !!snapshot?.capabilities.includes("local-scheduling");
72
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_NotificationTestView.NotificationTestView, {
73
- title: title,
74
- message: message,
75
- onTitleChange: setTitle,
76
- onMessageChange: setMessage,
77
- appName: "This app",
78
- appearance: snapshot?.preview,
79
- destination: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
80
- style: s.destination,
81
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
82
- style: s.field,
83
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
84
- style: s.label,
85
- children: "Device"
86
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
87
- style: s.value,
88
- children: "This device"
89
- })]
90
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
91
- style: s.field,
92
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
93
- style: s.label,
94
- children: "Delivery"
95
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
96
- style: s.value,
97
- children: "Local notification"
98
- })]
99
- })]
100
- }),
101
- options: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
102
- style: s.options,
103
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
104
- style: s.label,
105
- children: "Send after"
106
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.NightSegmented, {
107
- tabs: [{
108
- key: "1",
109
- label: "1 second"
110
- }, {
111
- key: "10",
112
- label: "10 seconds"
113
- }],
114
- activeKey: seconds,
115
- onChange: setSeconds,
116
- size: "sm",
117
- glass: true
118
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
119
- style: s.label,
120
- children: "Custom data"
121
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TextInput, {
122
- accessibilityLabel: "Notification custom data",
123
- value: data,
124
- onChangeText: setData,
125
- multiline: true,
126
- autoCapitalize: "none",
127
- autoCorrect: false,
128
- style: s.json
129
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
130
- style: s.label,
131
- children: "Use the delay to leave the app before delivery. Simulator push and raw APNs payloads are available on desktop."
132
- })]
133
- }),
134
- result: latest ? {
135
- title: outcome ? "App reported an outcome" : tapped ? "Notification tapped" : received ? "Received by app" : "Notification scheduled",
136
- message: tapped ? "Open Activity to inspect the app’s response." : "Tap the notification to test what opens."
137
- } : null,
138
- onViewActivity: onViewActivity,
139
- onSend: () => {
140
- void send();
141
- },
142
- busy: busy,
143
- disabled: !supported || !!validation,
144
- error: error ?? validation,
145
- hint: !supported ? "Connect Expo notification capture to send a local test." : seconds === "10" ? "You have 10 seconds to leave the app." : "Sends locally on this device after one second."
146
- });
147
- }
148
- const s = _reactNative.StyleSheet.create({
149
- destination: {
150
- flexDirection: "row",
151
- gap: 12
152
- },
153
- field: {
154
- flex: 1,
155
- gap: 7
156
- },
157
- label: {
158
- color: _sharedUi.night.color.textSecondary,
159
- fontSize: 12,
160
- lineHeight: 18
161
- },
162
- value: {
163
- color: _sharedUi.night.color.text,
164
- fontSize: 13,
165
- borderWidth: 1,
166
- borderColor: _sharedUi.night.color.glassBorder,
167
- backgroundColor: _sharedUi.night.color.glass,
168
- borderRadius: 10,
169
- padding: 11
170
- },
171
- options: {
172
- gap: 12
173
- },
174
- json: {
175
- color: _sharedUi.night.color.text,
176
- fontSize: 12,
177
- minHeight: 100,
178
- textAlignVertical: "top",
179
- padding: 12,
180
- borderWidth: 1,
181
- borderColor: _sharedUi.night.color.glassBorder,
182
- borderRadius: 10
183
- }
184
- });
185
- //# sourceMappingURL=LocalNotificationTest.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.LocalNotificationTest=LocalNotificationTest;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _NotificationTestView=require("./NotificationTestView");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(i,u){if("function"==typeof WeakMap)var h=new WeakMap,p=new WeakMap;return(_interopRequireWildcard=function(e,l){if(!l&&e&&e.__esModule)return e;var a,r,n={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return n;if(a=l?p:h){if(a.has(e))return a.get(e);a.set(e,n)}for(const o in e)"default"!==o&&{}.hasOwnProperty.call(e,o)&&((r=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,o))&&(r.get||r.set)?a(n,o,r):n[o]=e[o]);return n})(i,u)}function LocalNotificationTest({snapshot:i,onAction:u,onViewActivity:h}){const[p,e]=(0,_react.useState)("Test notification");const[l,a]=(0,_react.useState)("Tap to open the app.");const[r,n]=(0,_react.useState)("{}");const[o,w]=(0,_react.useState)("1");const[T,x]=(0,_react.useState)(false);const y=(0,_react.useRef)(false);const[_,v]=(0,_react.useState)(null);const[c,m]=(0,_react.useState)(null);let d={};let f=null;try{d=JSON.parse(r);if(!d||typeof d!=="object"||Array.isArray(d))throw new Error}catch{f="Custom data must be a JSON object. Open Options to edit it."}async function N(){if(y.current||f)return;y.current=true;x(true);m(null);v(null);const t={testId:`buoy-local-${Date.now()}-${Math.random().toString(36).slice(2)}`,startedAt:Date.now(),appId:i?.appId??null};try{await u("setCaptureSession",{runId:t.testId,durationMs:18e5});await u("scheduleLocal",{title:p,body:l,data:{...d,__buoyTestId:t.testId},seconds:Number(o)});m(t)}catch(b){v(b instanceof Error?b.message:String(b))}finally{y.current=false;x(false)}}const g=c&&c.appId===i?.appId?i.events.filter(t=>t.testId===c.testId&&t.capturedAt>=c.startedAt):[];const C=g.some(t=>t.kind==="received");const j=g.some(t=>t.kind==="response"||t.kind==="startup-response");const k=g.some(t=>t.kind==="app-outcome");const S=!!i?.capabilities.includes("local-scheduling");return(0,_jsxRuntime.jsx)(_NotificationTestView.NotificationTestView,{title:p,message:l,onTitleChange:e,onMessageChange:a,appName:"This app",appearance:i?.preview,destination:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:s.destination,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:s.field,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:s.label,children:"Device"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:s.value,children:"This device"})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:s.field,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:s.label,children:"Delivery"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:s.value,children:"Local notification"})]})]}),options:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:s.options,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:s.label,children:"Send after"}),(0,_jsxRuntime.jsx)(_sharedUi.NightSegmented,{tabs:[{key:"1",label:"1 second"},{key:"10",label:"10 seconds"}],activeKey:o,onChange:w,size:"sm",glass:true}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:s.label,children:"Custom data"}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{accessibilityLabel:"Notification custom data",value:r,onChangeText:n,multiline:true,autoCapitalize:"none",autoCorrect:false,style:s.json}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:s.label,children:"Use the delay to leave the app before delivery. Simulator push and raw APNs payloads are available on desktop."})]}),result:c?{title:k?"App reported an outcome":j?"Notification tapped":C?"Received by app":"Notification scheduled",message:j?"Open Activity to inspect the app\u2019s response.":"Tap the notification to test what opens."}:null,onViewActivity:h,onSend:()=>{void N()},busy:T,disabled:!S||!!f,error:_??f,hint:!S?"Connect Expo notification capture to send a local test.":o==="10"?"You have 10 seconds to leave the app.":"Sends locally on this device after one second."})}const s=_reactNative.StyleSheet.create({destination:{flexDirection:"row",gap:12},field:{flex:1,gap:7},label:{color:_sharedUi.night.color.textSecondary,fontSize:12,lineHeight:18},value:{color:_sharedUi.night.color.text,fontSize:13,borderWidth:1,borderColor:_sharedUi.night.color.glassBorder,backgroundColor:_sharedUi.night.color.glass,borderRadius:10,padding:11},options:{gap:12},json:{color:_sharedUi.night.color.text,fontSize:12,minHeight:100,textAlignVertical:"top",padding:12,borderWidth:1,borderColor:_sharedUi.night.color.glassBorder,borderRadius:10}});
@@ -1,329 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.NotificationTestView = NotificationTestView;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _reactNative = require("react-native");
9
- var _sharedUi = require("@buoy-gg/shared-ui");
10
- var _jsxRuntime = require("react/jsx-runtime");
11
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
12
- function NotificationTestView(props) {
13
- const [iconFailed, setIconFailed] = (0, _react.useState)(false);
14
- (0, _react.useEffect)(() => setIconFailed(false), [props.appearance?.iconUri]);
15
- const ink = props.appearance?.textColor ? {
16
- color: props.appearance.textColor
17
- } : undefined;
18
- const [optionsOpen, setOptionsOpen] = (0, _react.useState)(false);
19
- const insets = (0, _sharedUi.useSafeAreaInsets)({
20
- minBottom: 12
21
- });
22
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
23
- style: s.root,
24
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
25
- testID: "notification-test-scroll",
26
- style: s.root,
27
- contentContainerStyle: s.scroll,
28
- keyboardShouldPersistTaps: "handled",
29
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
30
- style: s.content,
31
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
32
- style: s.intro,
33
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
34
- accessibilityRole: "header",
35
- style: s.heading,
36
- children: "Test a notification"
37
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
38
- style: s.caption,
39
- children: "Send a test notification to your app."
40
- })]
41
- }), props.destination, props.previewNote ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
42
- style: s.caption,
43
- children: props.previewNote
44
- }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
45
- style: [s.preview, props.appearance?.backgroundColor ? {
46
- backgroundColor: props.appearance.backgroundColor,
47
- borderColor: props.appearance.backgroundColor
48
- } : undefined],
49
- accessibilityLabel: "Notification preview",
50
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
51
- style: s.row,
52
- children: [props.appearance?.iconUri && !iconFailed ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
53
- testID: "buoy-internal-notification-preview",
54
- source: {
55
- uri: props.appearance.iconUri
56
- },
57
- accessibilityLabel: `${props.appearance.appName ?? props.appName} icon`,
58
- style: s.appIcon,
59
- onError: () => setIconFailed(true)
60
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
61
- style: s.iconFallback,
62
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.NotificationsIcon, {
63
- size: 22,
64
- color: _sharedUi.night.color.accent
65
- })
66
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
67
- numberOfLines: 1,
68
- style: [s.caption, s.appName, ink],
69
- children: props.appearance?.appName ?? props.appName
70
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
71
- style: [s.caption, ink],
72
- children: "now"
73
- })]
74
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TextInput, {
75
- accessibilityLabel: "Notification title",
76
- placeholder: "Title",
77
- placeholderTextColor: _sharedUi.night.color.placeholder,
78
- value: props.title,
79
- onChangeText: props.onTitleChange,
80
- style: [s.input, s.title, ink],
81
- editable: !props.busy
82
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TextInput, {
83
- accessibilityLabel: "Notification message",
84
- placeholder: "Message",
85
- placeholderTextColor: _sharedUi.night.color.placeholder,
86
- value: props.message,
87
- onChangeText: props.onMessageChange,
88
- style: [s.input, ink],
89
- editable: !props.busy
90
- })]
91
- }), props.result && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
92
- accessibilityRole: "summary",
93
- accessibilityLiveRegion: "polite",
94
- testID: "notification-test-result",
95
- style: s.result,
96
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
97
- style: s.row,
98
- children: [props.result.failed ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.XCircle, {
99
- size: 16,
100
- color: _sharedUi.night.color.danger
101
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.CheckCircle, {
102
- size: 16,
103
- color: _sharedUi.night.color.accent
104
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
105
- style: s.resultTitle,
106
- children: props.result.title
107
- })]
108
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
109
- style: s.caption,
110
- children: props.result.message
111
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Pressable, {
112
- accessibilityRole: "button",
113
- accessibilityLabel: "View activity",
114
- onPress: props.onViewActivity,
115
- style: s.secondary,
116
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
117
- style: s.secondaryText,
118
- children: "View activity"
119
- })
120
- })]
121
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
122
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Pressable, {
123
- accessibilityRole: "button",
124
- accessibilityLabel: "Notification options",
125
- accessibilityState: {
126
- expanded: optionsOpen
127
- },
128
- onPress: () => setOptionsOpen(!optionsOpen),
129
- style: s.options,
130
- children: [optionsOpen ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.ChevronDown, {
131
- size: 12,
132
- color: _sharedUi.night.color.textSecondary
133
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.ChevronRight, {
134
- size: 12,
135
- color: _sharedUi.night.color.textSecondary
136
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
137
- style: s.caption,
138
- children: "Options"
139
- })]
140
- }), optionsOpen && props.options]
141
- })]
142
- })
143
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
144
- style: [s.footer, {
145
- paddingBottom: insets.bottom
146
- }],
147
- children: [!!props.error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
148
- accessibilityRole: "alert",
149
- style: s.error,
150
- children: props.error
151
- }), !!props.notice && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
152
- accessibilityLiveRegion: "polite",
153
- style: s.caption,
154
- children: props.notice
155
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
156
- style: s.footerRow,
157
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
158
- style: [s.caption, s.hint],
159
- children: props.hint
160
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Pressable, {
161
- accessibilityRole: "button",
162
- accessibilityLabel: props.busy ? "Sending…" : "Send notification",
163
- accessibilityState: {
164
- disabled: props.disabled || props.busy
165
- },
166
- disabled: props.disabled || props.busy,
167
- onPress: props.onSend,
168
- style: ({
169
- pressed
170
- }) => [s.send, (props.disabled || props.busy) && s.disabled, pressed && s.pressed],
171
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_sharedUi.NotificationsIcon, {
172
- size: 15,
173
- color: _sharedUi.night.color.onAccent
174
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
175
- style: s.sendText,
176
- children: props.busy ? "Sending…" : "Send notification"
177
- })]
178
- })]
179
- })]
180
- })]
181
- });
182
- }
183
- const s = _reactNative.StyleSheet.create({
184
- root: {
185
- flex: 1,
186
- minHeight: 0,
187
- minWidth: 0
188
- },
189
- scroll: {
190
- padding: 16,
191
- flexGrow: 1
192
- },
193
- content: {
194
- width: "100%",
195
- maxWidth: 620,
196
- alignSelf: "center",
197
- gap: 20
198
- },
199
- intro: {
200
- gap: 8,
201
- paddingTop: 8
202
- },
203
- heading: {
204
- color: _sharedUi.night.color.text,
205
- fontSize: 22,
206
- fontWeight: "600",
207
- letterSpacing: -0.5
208
- },
209
- caption: {
210
- color: _sharedUi.night.color.textSecondary,
211
- fontSize: 12,
212
- lineHeight: 18
213
- },
214
- row: {
215
- flexDirection: "row",
216
- alignItems: "center",
217
- gap: 8
218
- },
219
- appName: {
220
- flex: 1,
221
- fontWeight: "600"
222
- },
223
- appIcon: {
224
- width: 36,
225
- height: 36,
226
- borderRadius: 8
227
- },
228
- iconFallback: {
229
- width: 36,
230
- height: 36,
231
- alignItems: "center",
232
- justifyContent: "center",
233
- borderRadius: 8,
234
- backgroundColor: _sharedUi.night.color.fillSecondary
235
- },
236
- preview: {
237
- padding: 16,
238
- gap: 8,
239
- borderWidth: 1,
240
- borderColor: _sharedUi.night.color.glassBorder,
241
- borderRadius: 20,
242
- backgroundColor: _sharedUi.night.color.glass
243
- },
244
- input: {
245
- color: _sharedUi.night.color.text,
246
- fontSize: 14,
247
- padding: 6,
248
- minHeight: 36
249
- },
250
- title: {
251
- fontSize: 16,
252
- fontWeight: "600"
253
- },
254
- result: {
255
- gap: 10,
256
- padding: 16,
257
- borderWidth: 1,
258
- borderColor: _sharedUi.night.color.glassBorder,
259
- borderRadius: 14
260
- },
261
- resultTitle: {
262
- color: _sharedUi.night.color.text,
263
- fontWeight: "500",
264
- fontSize: 13,
265
- flexShrink: 1
266
- },
267
- secondary: {
268
- alignSelf: "flex-start",
269
- paddingHorizontal: 14,
270
- paddingVertical: 8,
271
- borderRadius: 24,
272
- backgroundColor: _sharedUi.night.color.fillSecondary
273
- },
274
- secondaryText: {
275
- color: _sharedUi.night.color.accent,
276
- fontSize: 13
277
- },
278
- options: {
279
- flexDirection: "row",
280
- alignItems: "center",
281
- gap: 6,
282
- paddingVertical: 12
283
- },
284
- footer: {
285
- padding: 14,
286
- gap: 8,
287
- borderTopWidth: 1,
288
- borderTopColor: _sharedUi.night.color.separator
289
- },
290
- footerRow: {
291
- flexDirection: "row",
292
- flexWrap: "wrap",
293
- alignItems: "center",
294
- justifyContent: "space-between",
295
- gap: 12
296
- },
297
- hint: {
298
- flexGrow: 1,
299
- flexShrink: 1,
300
- flexBasis: 200
301
- },
302
- send: {
303
- flexDirection: "row",
304
- alignItems: "center",
305
- justifyContent: "center",
306
- gap: 8,
307
- borderRadius: 24,
308
- paddingHorizontal: 18,
309
- paddingVertical: 12,
310
- backgroundColor: _sharedUi.night.color.accent
311
- },
312
- sendText: {
313
- color: _sharedUi.night.color.onAccent,
314
- fontSize: 13,
315
- fontWeight: "600"
316
- },
317
- disabled: {
318
- opacity: 0.4
319
- },
320
- pressed: {
321
- opacity: 0.8
322
- },
323
- error: {
324
- color: _sharedUi.night.color.danger,
325
- fontSize: 12,
326
- lineHeight: 18
327
- }
328
- });
329
- //# sourceMappingURL=NotificationTestView.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.NotificationTestView=NotificationTestView;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,d){if("function"==typeof WeakMap)var a=new WeakMap,o=new WeakMap;return(_interopRequireWildcard=function(t,c){if(!c&&t&&t.__esModule)return t;var i,n,l={__proto__:null,default:t};if(null===t||"object"!=typeof t&&"function"!=typeof t)return l;if(i=c?o:a){if(i.has(t))return i.get(t);i.set(t,l)}for(const r in t)"default"!==r&&{}.hasOwnProperty.call(t,r)&&((n=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(t,r))&&(n.get||n.set)?i(l,r,n):l[r]=t[r]);return l})(e,d)}function NotificationTestView(e){const[d,a]=(0,_react.useState)(false);(0,_react.useEffect)(()=>a(false),[e.appearance?.iconUri]);const o=e.appearance?.textColor?{color:e.appearance.textColor}:void 0;const[t,c]=(0,_react.useState)(false);const i=(0,_sharedUi.useSafeAreaInsets)({minBottom:12});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:s.root,children:[(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{testID:"notification-test-scroll",style:s.root,contentContainerStyle:s.scroll,keyboardShouldPersistTaps:"handled",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:s.content,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:s.intro,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{accessibilityRole:"header",style:s.heading,children:"Test a notification"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:s.caption,children:"Send a test notification to your app."})]}),e.destination,e.previewNote?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:s.caption,children:e.previewNote}):(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[s.preview,e.appearance?.backgroundColor?{backgroundColor:e.appearance.backgroundColor,borderColor:e.appearance.backgroundColor}:void 0],accessibilityLabel:"Notification preview",children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:s.row,children:[e.appearance?.iconUri&&!d?(0,_jsxRuntime.jsx)(_reactNative.Image,{testID:"buoy-internal-notification-preview",source:{uri:e.appearance.iconUri},accessibilityLabel:`${e.appearance.appName??e.appName} icon`,style:s.appIcon,onError:()=>a(true)}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:s.iconFallback,children:(0,_jsxRuntime.jsx)(_sharedUi.NotificationsIcon,{size:22,color:_sharedUi.night.color.accent})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{numberOfLines:1,style:[s.caption,s.appName,o],children:e.appearance?.appName??e.appName}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[s.caption,o],children:"now"})]}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{accessibilityLabel:"Notification title",placeholder:"Title",placeholderTextColor:_sharedUi.night.color.placeholder,value:e.title,onChangeText:e.onTitleChange,style:[s.input,s.title,o],editable:!e.busy}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{accessibilityLabel:"Notification message",placeholder:"Message",placeholderTextColor:_sharedUi.night.color.placeholder,value:e.message,onChangeText:e.onMessageChange,style:[s.input,o],editable:!e.busy})]}),e.result&&(0,_jsxRuntime.jsxs)(_reactNative.View,{accessibilityRole:"summary",accessibilityLiveRegion:"polite",testID:"notification-test-result",style:s.result,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:s.row,children:[e.result.failed?(0,_jsxRuntime.jsx)(_sharedUi.XCircle,{size:16,color:_sharedUi.night.color.danger}):(0,_jsxRuntime.jsx)(_sharedUi.CheckCircle,{size:16,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:s.resultTitle,children:e.result.title})]}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:s.caption,children:e.result.message}),(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:"View activity",onPress:e.onViewActivity,style:s.secondary,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:s.secondaryText,children:"View activity"})})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:"Notification options",accessibilityState:{expanded:t},onPress:()=>c(!t),style:s.options,children:[t?(0,_jsxRuntime.jsx)(_sharedUi.ChevronDown,{size:12,color:_sharedUi.night.color.textSecondary}):(0,_jsxRuntime.jsx)(_sharedUi.ChevronRight,{size:12,color:_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:s.caption,children:"Options"})]}),t&&e.options]})]})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[s.footer,{paddingBottom:i.bottom}],children:[!!e.error&&(0,_jsxRuntime.jsx)(_reactNative.Text,{accessibilityRole:"alert",style:s.error,children:e.error}),!!e.notice&&(0,_jsxRuntime.jsx)(_reactNative.Text,{accessibilityLiveRegion:"polite",style:s.caption,children:e.notice}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:s.footerRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[s.caption,s.hint],children:e.hint}),(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.busy?"Sending\u2026":"Send notification",accessibilityState:{disabled:e.disabled||e.busy},disabled:e.disabled||e.busy,onPress:e.onSend,style:({pressed:n})=>[s.send,(e.disabled||e.busy)&&s.disabled,n&&s.pressed],children:[(0,_jsxRuntime.jsx)(_sharedUi.NotificationsIcon,{size:15,color:_sharedUi.night.color.onAccent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:s.sendText,children:e.busy?"Sending\u2026":"Send notification"})]})]})]})]})}const s=_reactNative.StyleSheet.create({root:{flex:1,minHeight:0,minWidth:0},scroll:{padding:16,flexGrow:1},content:{width:"100%",maxWidth:620,alignSelf:"center",gap:20},intro:{gap:8,paddingTop:8},heading:{color:_sharedUi.night.color.text,fontSize:22,fontWeight:"600",letterSpacing:-.5},caption:{color:_sharedUi.night.color.textSecondary,fontSize:12,lineHeight:18},row:{flexDirection:"row",alignItems:"center",gap:8},appName:{flex:1,fontWeight:"600"},appIcon:{width:36,height:36,borderRadius:8},iconFallback:{width:36,height:36,alignItems:"center",justifyContent:"center",borderRadius:8,backgroundColor:_sharedUi.night.color.fillSecondary},preview:{padding:16,gap:8,borderWidth:1,borderColor:_sharedUi.night.color.glassBorder,borderRadius:20,backgroundColor:_sharedUi.night.color.glass},input:{color:_sharedUi.night.color.text,fontSize:14,padding:6,minHeight:36},title:{fontSize:16,fontWeight:"600"},result:{gap:10,padding:16,borderWidth:1,borderColor:_sharedUi.night.color.glassBorder,borderRadius:14},resultTitle:{color:_sharedUi.night.color.text,fontWeight:"500",fontSize:13,flexShrink:1},secondary:{alignSelf:"flex-start",paddingHorizontal:14,paddingVertical:8,borderRadius:24,backgroundColor:_sharedUi.night.color.fillSecondary},secondaryText:{color:_sharedUi.night.color.accent,fontSize:13},options:{flexDirection:"row",alignItems:"center",gap:6,paddingVertical:12},footer:{padding:14,gap:8,borderTopWidth:1,borderTopColor:_sharedUi.night.color.separator},footerRow:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",gap:12},hint:{flexGrow:1,flexShrink:1,flexBasis:200},send:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8,borderRadius:24,paddingHorizontal:18,paddingVertical:12,backgroundColor:_sharedUi.night.color.accent},sendText:{color:_sharedUi.night.color.onAccent,fontSize:13,fontWeight:"600"},disabled:{opacity:.4},pressed:{opacity:.8},error:{color:_sharedUi.night.color.danger,fontSize:12,lineHeight:18}});