@solidnative-dev/notifications 0.0.0-stage → 0.1.0-alpha.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Solid Native contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,93 @@
1
- # Temporary Holding Version
1
+ # `@solidnative-dev/notifications`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ This package owns a bounded, portable local-notification contract. Native
4
+ permission values, displayed IDs, and foreground events are validated before
5
+ they enter application state. Subscription and diagnostic failures are
6
+ isolated from the platform event boundary.
7
+
8
+ The first backend is an explicit, wrapper-free New-Architecture Notify Kit
9
+ 10.5 adapter. The application resolves its generated `NotifeeApiModule` and
10
+ constructs React Native's low-level native event source; this portable package
11
+ accepts both by injection and never imports React Native or Notify Kit's
12
+ JavaScript facade:
13
+
14
+ ```ts
15
+ import { createNotifyKit10NotificationService } from "@solidnative-dev/notifications/notify-kit-10";
16
+ import { createNotificationEvent } from "@solidnative-dev/notifications/solid";
17
+
18
+ const notifications = createNotifyKit10NotificationService(
19
+ generatedNotifeeModule,
20
+ nativeEventSource,
21
+ {
22
+ platform: "android",
23
+ androidSmallIcon: "solid_native_notification",
24
+ },
25
+ );
26
+ const latestEvent = createNotificationEvent(notifications);
27
+
28
+ await notifications.requestPermission();
29
+ await notifications.display({
30
+ id: "sync-complete",
31
+ title: "Sync complete",
32
+ channel: { id: "application", name: "Application" },
33
+ });
34
+ ```
35
+
36
+ The checked-in E2E
37
+ [`NotifeeApiModule` seam](../../apps/native-e2e/adapters/NotifeeApiModule.ts)
38
+ shows the complete registry and `NativeEventEmitter` wiring. Keeping those two
39
+ React Native details in the application makes native initialization order and
40
+ the exact generated ABI reviewable. The product adapter narrows the native
41
+ module's 48 required methods to seven operations and reproduces the 10.5
42
+ channel, notification, permission, cancellation, and foreground-event
43
+ contract.
44
+
45
+ `createNotificationEvent` accepts either an available service or an accessor
46
+ whose service is loaded later. It replaces the native subscription when that
47
+ accessor changes and removes the current subscription with its Solid owner.
48
+ Subscription setup and removal failures flow through `onError`; failures in
49
+ that diagnostic hook are isolated so a broken native listener cannot halt the
50
+ reactive graph or prevent a later service handoff.
51
+ Every normalized kind enters the renderer's platform-event boundary under a
52
+ stable semantic name:
53
+
54
+ | Kind | Event name | Priority |
55
+ | ---------------- | -------------------------------------- | -------- |
56
+ | `delivered` | `platform.notification.delivered` | default |
57
+ | `pressed` | `platform.notification.pressed` | discrete |
58
+ | `action-pressed` | `platform.notification.action-pressed` | discrete |
59
+ | `dismissed` | `platform.notification.dismissed` | default |
60
+ | `unknown` | `platform.notification.unknown` | default |
61
+
62
+ Notification and action identifiers remain callback values; the causal event
63
+ records only the semantic name, source, priority, and bounded runtime identity.
64
+ The Notify Kit 10 adapter explicitly installs the portable body action
65
+ `{ id: "default", launchActivity: "default" }` on Android, so a tap reopens the
66
+ application and produces `pressed` without relying on Notify Kit's omission
67
+ default. Rich action buttons and background handlers remain outside this
68
+ minimal contract.
69
+ Background execution, remote push credentials, platform entitlements, and
70
+ application routing remain explicit shell responsibilities; this
71
+ local-delivery proof does not imply those features.
72
+
73
+ The wrapper-free adapter is physically qualified on both platforms. Run the
74
+ focused signed iPhone Release proof with a connected, unlocked device:
75
+
76
+ ```sh
77
+ SOLID_NATIVE_IOS_DESTINATION=<core-device-id> \
78
+ SOLID_NATIVE_IOS_TEAM=<development-team-id> \
79
+ pnpm --filter @solidnative-dev/native-e2e ios:notifications:test
80
+ ```
81
+
82
+ Its source-map gate requires the application adapter, generated ABI, and this
83
+ versioned product adapter exactly once, and rejects every Notify Kit JavaScript
84
+ facade source. The device path proves native permission, foreground delivery,
85
+ displayed-ID query, an exact content-private event/owner/computation
86
+ Solid/Fabric causal commit, cancellation, and non-terminating owner teardown.
87
+ On iOS, authorization and display are intentionally separate user-visible
88
+ operations: wait until the application is active again after the permission
89
+ sheet before calling `display`. An immediate continuation can still observe
90
+ UIKit's `Inactive` state, causing Notify Kit to route that delivery as a
91
+ background event. The Android physical proof additionally
92
+ inspects the operating system's notification content and presses its real body
93
+ action; iOS Notification Center inspection is not yet claimed.
@@ -0,0 +1,65 @@
1
+ export declare const NOTIFICATION_MAX_ID_LENGTH = 256;
2
+ export declare const NOTIFICATION_MAX_TITLE_LENGTH = 512;
3
+ export declare const NOTIFICATION_MAX_BODY_LENGTH = 4096;
4
+ export declare const NOTIFICATION_MAX_DISPLAYED_COUNT = 10000;
5
+ export type NotificationAuthorization = "not-determined" | "denied" | "authorized" | "provisional";
6
+ export type NotificationImportance = "low" | "default" | "high";
7
+ export type NotificationEventKind = "delivered" | "pressed" | "action-pressed" | "dismissed" | "unknown";
8
+ export interface NotificationPermission {
9
+ readonly authorization: NotificationAuthorization;
10
+ }
11
+ export interface NotificationChannel {
12
+ readonly id: string;
13
+ readonly name: string;
14
+ readonly importance?: NotificationImportance;
15
+ }
16
+ export interface LocalNotification {
17
+ readonly id: string;
18
+ readonly title?: string;
19
+ readonly body?: string;
20
+ /** Required by Android and validated on every platform for portability. */
21
+ readonly channel: NotificationChannel;
22
+ }
23
+ export interface NormalizedLocalNotification {
24
+ readonly id: string;
25
+ readonly title?: string;
26
+ readonly body?: string;
27
+ readonly channel: Readonly<{
28
+ id: string;
29
+ name: string;
30
+ importance: NotificationImportance;
31
+ }>;
32
+ }
33
+ export interface NotificationEvent {
34
+ readonly kind: NotificationEventKind;
35
+ readonly notificationId?: string;
36
+ readonly actionId?: string;
37
+ }
38
+ export interface NotificationAdapter {
39
+ getPermission(): Promise<unknown>;
40
+ requestPermission(): Promise<unknown>;
41
+ display(notification: NormalizedLocalNotification): Promise<unknown>;
42
+ getDisplayedNotificationIds(): Promise<unknown>;
43
+ cancel(notificationId: string): Promise<unknown>;
44
+ subscribe(listener: (event: unknown) => void): unknown;
45
+ }
46
+ export interface NotificationSubscriptionOptions {
47
+ readonly onError?: (error: unknown) => unknown;
48
+ }
49
+ export interface NotificationSubscription {
50
+ remove(): void;
51
+ }
52
+ export interface NotificationService {
53
+ getPermission(): Promise<NotificationPermission>;
54
+ requestPermission(): Promise<NotificationPermission>;
55
+ display(notification: LocalNotification): Promise<string>;
56
+ getDisplayedNotificationIds(): Promise<readonly string[]>;
57
+ cancel(notificationId: string): Promise<void>;
58
+ subscribe(listener: (event: NotificationEvent) => unknown, options?: NotificationSubscriptionOptions): NotificationSubscription;
59
+ }
60
+ /**
61
+ * Narrows an untrusted notification backend to bounded, portable values. The
62
+ * adapter remains responsible for platform translation and permission UI.
63
+ */
64
+ export declare function createNotificationService(adapter: NotificationAdapter): NotificationService;
65
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,MA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,CACvC,OAAO,EAAE,mBAAmB,GAC3B,mBAAmB,CAuFrB"}
package/dist/index.js ADDED
@@ -0,0 +1,183 @@
1
+ export const NOTIFICATION_MAX_ID_LENGTH = 256;
2
+ export const NOTIFICATION_MAX_TITLE_LENGTH = 512;
3
+ export const NOTIFICATION_MAX_BODY_LENGTH = 4_096;
4
+ export const NOTIFICATION_MAX_DISPLAYED_COUNT = 10_000;
5
+ function plainRecord(value, path) {
6
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
7
+ throw new TypeError(`${path} must be an object.`);
8
+ }
9
+ const prototype = Object.getPrototypeOf(value);
10
+ if (prototype !== Object.prototype && prototype !== null) {
11
+ throw new TypeError(`${path} must be a plain object.`);
12
+ }
13
+ return value;
14
+ }
15
+ function boundedString(value, path, maximumLength) {
16
+ if (typeof value !== "string" ||
17
+ value.length === 0 ||
18
+ value.length > maximumLength ||
19
+ value.includes("\0")) {
20
+ throw new TypeError(`${path} must be a 1-${maximumLength} character string without null bytes.`);
21
+ }
22
+ return value;
23
+ }
24
+ function notificationId(value, path = "Notification id") {
25
+ return boundedString(value, path, NOTIFICATION_MAX_ID_LENGTH);
26
+ }
27
+ function optionalString(value, path, maximumLength) {
28
+ return value === undefined
29
+ ? undefined
30
+ : boundedString(value, path, maximumLength);
31
+ }
32
+ function notificationPermission(value) {
33
+ const record = plainRecord(value, "Notification permission");
34
+ if (record.authorization !== "not-determined" &&
35
+ record.authorization !== "denied" &&
36
+ record.authorization !== "authorized" &&
37
+ record.authorization !== "provisional") {
38
+ throw new TypeError("Notification permission authorization status is invalid.");
39
+ }
40
+ return Object.freeze({ authorization: record.authorization });
41
+ }
42
+ function normalizedNotification(value) {
43
+ const notification = plainRecord(value, "Local notification");
44
+ const channel = plainRecord(notification.channel, "Local notification channel");
45
+ const title = optionalString(notification.title, "Notification title", NOTIFICATION_MAX_TITLE_LENGTH);
46
+ const body = optionalString(notification.body, "Notification body", NOTIFICATION_MAX_BODY_LENGTH);
47
+ if (title === undefined && body === undefined) {
48
+ throw new TypeError("A local notification requires a title or body.");
49
+ }
50
+ const importance = channel.importance ?? "default";
51
+ if (importance !== "low" &&
52
+ importance !== "default" &&
53
+ importance !== "high") {
54
+ throw new TypeError("Notification channel importance is invalid.");
55
+ }
56
+ return Object.freeze({
57
+ id: notificationId(notification.id),
58
+ ...(title === undefined ? {} : { title }),
59
+ ...(body === undefined ? {} : { body }),
60
+ channel: Object.freeze({
61
+ id: notificationId(channel.id, "Notification channel id"),
62
+ name: boundedString(channel.name, "Notification channel name", NOTIFICATION_MAX_TITLE_LENGTH),
63
+ importance,
64
+ }),
65
+ });
66
+ }
67
+ function notificationEvent(value) {
68
+ const event = plainRecord(value, "Notification event");
69
+ if (event.kind !== "delivered" &&
70
+ event.kind !== "pressed" &&
71
+ event.kind !== "action-pressed" &&
72
+ event.kind !== "dismissed" &&
73
+ event.kind !== "unknown") {
74
+ throw new TypeError("Notification event kind is invalid.");
75
+ }
76
+ const normalized = {
77
+ kind: event.kind,
78
+ ...(event.notificationId === undefined
79
+ ? {}
80
+ : {
81
+ notificationId: notificationId(event.notificationId, "Notification event id"),
82
+ }),
83
+ ...(event.actionId === undefined
84
+ ? {}
85
+ : {
86
+ actionId: boundedString(event.actionId, "Notification action id", NOTIFICATION_MAX_ID_LENGTH),
87
+ }),
88
+ };
89
+ return Object.freeze(normalized);
90
+ }
91
+ function adapterMethod(adapter, name) {
92
+ if (typeof adapter[name] !== "function") {
93
+ throw new TypeError(`Notification adapter ${name} must be a function.`);
94
+ }
95
+ }
96
+ function reportSubscriptionError(error, options) {
97
+ try {
98
+ const reported = options.onError?.(error);
99
+ void Promise.resolve(reported).catch(() => undefined);
100
+ }
101
+ catch {
102
+ // A diagnostic callback cannot escape a native event boundary.
103
+ }
104
+ }
105
+ /**
106
+ * Narrows an untrusted notification backend to bounded, portable values. The
107
+ * adapter remains responsible for platform translation and permission UI.
108
+ */
109
+ export function createNotificationService(adapter) {
110
+ if (typeof adapter !== "object" || adapter === null) {
111
+ throw new TypeError("Notification adapter must be an object.");
112
+ }
113
+ adapterMethod(adapter, "getPermission");
114
+ adapterMethod(adapter, "requestPermission");
115
+ adapterMethod(adapter, "display");
116
+ adapterMethod(adapter, "getDisplayedNotificationIds");
117
+ adapterMethod(adapter, "cancel");
118
+ adapterMethod(adapter, "subscribe");
119
+ return Object.freeze({
120
+ async getPermission() {
121
+ return notificationPermission(await adapter.getPermission());
122
+ },
123
+ async requestPermission() {
124
+ return notificationPermission(await adapter.requestPermission());
125
+ },
126
+ async display(notification) {
127
+ const normalized = normalizedNotification(notification);
128
+ const displayedId = notificationId(await adapter.display(normalized), "Displayed notification id");
129
+ if (displayedId !== normalized.id) {
130
+ throw new Error("The notification backend returned a different notification id.");
131
+ }
132
+ return displayedId;
133
+ },
134
+ async getDisplayedNotificationIds() {
135
+ const value = await adapter.getDisplayedNotificationIds();
136
+ if (!Array.isArray(value)) {
137
+ throw new TypeError("The notification backend returned a non-array displayed list.");
138
+ }
139
+ if (value.length > NOTIFICATION_MAX_DISPLAYED_COUNT) {
140
+ throw new RangeError(`Displayed notifications cannot exceed ${NOTIFICATION_MAX_DISPLAYED_COUNT} entries.`);
141
+ }
142
+ const ids = value.map((entry, index) => notificationId(entry, `Displayed notification id ${String(index)}`));
143
+ if (new Set(ids).size !== ids.length) {
144
+ throw new TypeError("Displayed notification ids must be unique.");
145
+ }
146
+ return Object.freeze(ids);
147
+ },
148
+ async cancel(id) {
149
+ await adapter.cancel(notificationId(id));
150
+ },
151
+ subscribe(listener, options = {}) {
152
+ if (typeof listener !== "function") {
153
+ throw new TypeError("Notification listener must be a function.");
154
+ }
155
+ let active = true;
156
+ const remove = adapter.subscribe((value) => {
157
+ if (!active)
158
+ return;
159
+ try {
160
+ const result = listener(notificationEvent(value));
161
+ void Promise.resolve(result).catch((error) => {
162
+ reportSubscriptionError(error, options);
163
+ });
164
+ }
165
+ catch (error) {
166
+ reportSubscriptionError(error, options);
167
+ }
168
+ });
169
+ if (typeof remove !== "function") {
170
+ throw new TypeError("Notification adapter subscribe must return a cleanup function.");
171
+ }
172
+ return Object.freeze({
173
+ remove() {
174
+ if (!active)
175
+ return;
176
+ active = false;
177
+ remove();
178
+ },
179
+ });
180
+ },
181
+ });
182
+ }
183
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAC9C,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AACjD,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,CAAC;AAClD,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC;AA0EvD,SAAS,WAAW,CAClB,KAAc,EACd,IAAY;IAEZ,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,qBAAqB,CAAC,CAAC;IACpD,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC/C,IAAI,SAAS,KAAK,MAAM,CAAC,SAAS,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACzD,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,0BAA0B,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,KAA0C,CAAC;AACpD,CAAC;AAED,SAAS,aAAa,CACpB,KAAc,EACd,IAAY,EACZ,aAAqB;IAErB,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,CAAC,MAAM,KAAK,CAAC;QAClB,KAAK,CAAC,MAAM,GAAG,aAAa;QAC5B,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EACpB,CAAC;QACD,MAAM,IAAI,SAAS,CACjB,GAAG,IAAI,gBAAgB,aAAa,uCAAuC,CA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B,gEAAgE,CACjE,CAAC;YACJ,CAAC;YACD,OAAO,MAAM,CAAC,MAAM,CAAC;gBACnB,MAAM;oBACJ,IAAI,CAAC,MAAM;wBAAE,OAAO;oBACpB,MAAM,GAAG,KAAK,CAAC;oBACf,MAAM,EAAE,CAAC;gBACX,CAAC;aACF,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { type NotificationService } from "./index.js";
2
+ export type { LocalNotification, NotificationAuthorization, NotificationEvent, NotificationPermission, NotificationService, } from "./index.js";
3
+ export declare const NOTIFY_KIT_10_FOREGROUND_EVENT = "app.notifee.notification-event";
4
+ /** The reviewed Notify Kit 10.5 native surface used by this adapter. */
5
+ export interface NotifyKit10NativeModule {
6
+ readonly getNotificationSettings: () => Promise<unknown>;
7
+ readonly requestPermission: (permissions: Readonly<Record<string, unknown>>) => Promise<unknown>;
8
+ readonly createChannel: (channel: Readonly<Record<string, unknown>>) => Promise<unknown>;
9
+ readonly displayNotification: (notification: Readonly<Record<string, unknown>>) => Promise<unknown>;
10
+ readonly getDisplayedNotifications: () => Promise<unknown>;
11
+ readonly cancelAllNotificationsWithIds: (ids: ReadonlyArray<string>, notificationType: number, tag: string | null) => Promise<unknown>;
12
+ readonly cancelNotification: (id: string) => Promise<unknown>;
13
+ }
14
+ export interface NotifyKit10NativeEventSubscription {
15
+ remove(): void;
16
+ }
17
+ /** Injected so the product package never imports React Native or Notify Kit. */
18
+ export interface NotifyKit10NativeEventSource {
19
+ addListener(eventName: string, listener: (event: unknown) => void): unknown;
20
+ }
21
+ export interface NotifyKit10NotificationServiceOptions {
22
+ readonly platform: "android" | "ios";
23
+ /** Android drawable resource name used as the status-bar icon. */
24
+ readonly androidSmallIcon?: string;
25
+ }
26
+ /**
27
+ * Adapts Notify Kit 10.5's generated native ABI without importing its
28
+ * React-oriented JavaScript facade. Native resolution and event transport stay
29
+ * application-owned so this package remains usable outside React Native.
30
+ */
31
+ export declare function createNotifyKit10NotificationService(native: NotifyKit10NativeModule, events: NotifyKit10NativeEventSource, options: NotifyKit10NotificationServiceOptions): NotificationService;
32
+ //# sourceMappingURL=notify-kit-10.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notify-kit-10.d.ts","sourceRoot":"","sources":["../src/notify-kit-10.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,mBAAmB,EACzB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,iBAAiB,EACjB,yBAAyB,EACzB,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,8BAA8B,mCAAmC,CAAC;AAE/E,wEAAwE;AACxE,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,uBAAuB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACzD,QAAQ,CAAC,iBAAiB,EAAE,CAC1B,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAC3C,OAAO,CAAC,OAAO,CAAC,CAAC;IACtB,QAAQ,CAAC,aAAa,EAAE,CACtB,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KACvC,OAAO,CAAC,OAAO,CAAC,CAAC;IACtB,QAAQ,CAAC,mBAAmB,EAAE,CAC5B,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAC5C,OAAO,CAAC,OAAO,CAAC,CAAC;IACtB,QAAQ,CAAC,yBAAyB,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3D,QAAQ,CAAC,6BAA6B,EAAE,CACtC,GAAG,EAAE,aAAa,CAAC,MAAM,CAAC,EAC1B,gBAAgB,EAAE,MAAM,EACxB,GAAG,EAAE,MAAM,GAAG,IAAI,KACf,OAAO,CAAC,OAAO,CAAC,CAAC;IACtB,QAAQ,CAAC,kBAAkB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/D;AAED,MAAM,WAAW,kCAAkC;IACjD,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,gFAAgF;AAChF,MAAM,WAAW,4BAA4B;IAC3C,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC;CAC7E;AAED,MAAM,WAAW,qCAAqC;IACpD,QAAQ,CAAC,QAAQ,EAAE,SAAS,GAAG,KAAK,CAAC;IACrC,kEAAkE;IAClE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACpC;AAiND;;;;GAIG;AACH,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,4BAA4B,EACpC,OAAO,EAAE,qCAAqC,GAC7C,mBAAmB,CAmGrB"}
@@ -0,0 +1,253 @@
1
+ import { createNotificationService, } from "./index.js";
2
+ export const NOTIFY_KIT_10_FOREGROUND_EVENT = "app.notifee.notification-event";
3
+ function plainRecord(value, path) {
4
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
5
+ throw new TypeError(`${path} must be an object.`);
6
+ }
7
+ const prototype = Object.getPrototypeOf(value);
8
+ if (prototype !== Object.prototype && prototype !== null) {
9
+ throw new TypeError(`${path} must be a plain object.`);
10
+ }
11
+ return value;
12
+ }
13
+ function nativeMethod(native, name) {
14
+ if (typeof native[name] !== "function") {
15
+ throw new TypeError(`Notify Kit native method ${name} must be a function.`);
16
+ }
17
+ }
18
+ function androidResourceName(value) {
19
+ if (typeof value !== "string" || !/^[a-z][a-z0-9_]{0,254}$/.test(value)) {
20
+ throw new TypeError("Android notification icon must be a lowercase drawable resource name.");
21
+ }
22
+ return value;
23
+ }
24
+ function authorization(value) {
25
+ switch (value) {
26
+ case -1:
27
+ return "not-determined";
28
+ case 0:
29
+ return "denied";
30
+ case 1:
31
+ return "authorized";
32
+ case 2:
33
+ return "provisional";
34
+ default:
35
+ throw new TypeError("Notify Kit returned an unsupported authorization status.");
36
+ }
37
+ }
38
+ function permission(value) {
39
+ const settings = plainRecord(value, "Notify Kit notification settings");
40
+ return Object.freeze({
41
+ authorization: authorization(settings.authorizationStatus),
42
+ });
43
+ }
44
+ function importance(value) {
45
+ switch (value) {
46
+ case "low":
47
+ return 2;
48
+ case "default":
49
+ return 3;
50
+ case "high":
51
+ return 4;
52
+ }
53
+ }
54
+ function notificationEvent(value) {
55
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
56
+ return Object.freeze({ kind: "unknown" });
57
+ }
58
+ const event = value;
59
+ const detail = event.detail !== null &&
60
+ typeof event.detail === "object" &&
61
+ !Array.isArray(event.detail)
62
+ ? event.detail
63
+ : undefined;
64
+ const notification = detail?.notification !== null &&
65
+ typeof detail?.notification === "object" &&
66
+ !Array.isArray(detail.notification)
67
+ ? detail.notification
68
+ : undefined;
69
+ const pressAction = detail?.pressAction !== null &&
70
+ typeof detail?.pressAction === "object" &&
71
+ !Array.isArray(detail.pressAction)
72
+ ? detail.pressAction
73
+ : undefined;
74
+ const kind = event.type === 3
75
+ ? "delivered"
76
+ : event.type === 1
77
+ ? "pressed"
78
+ : event.type === 2
79
+ ? "action-pressed"
80
+ : event.type === 0
81
+ ? "dismissed"
82
+ : "unknown";
83
+ return Object.freeze({
84
+ kind,
85
+ ...(typeof notification?.id === "string"
86
+ ? { notificationId: notification.id }
87
+ : {}),
88
+ ...(typeof pressAction?.id === "string"
89
+ ? { actionId: pressAction.id }
90
+ : {}),
91
+ });
92
+ }
93
+ function displayedNotificationIds(value) {
94
+ if (!Array.isArray(value)) {
95
+ throw new TypeError("Notify Kit returned a non-array displayed list.");
96
+ }
97
+ return value.map((entry, index) => {
98
+ const displayed = plainRecord(entry, `Notify Kit displayed notification ${String(index)}`);
99
+ const nested = displayed.notification;
100
+ if (nested !== undefined) {
101
+ const notification = plainRecord(nested, `Notify Kit displayed notification ${String(index)} payload`);
102
+ return notification.id ?? displayed.id;
103
+ }
104
+ return displayed.id;
105
+ });
106
+ }
107
+ function androidChannel(notification) {
108
+ return Object.freeze({
109
+ id: notification.channel.id,
110
+ name: notification.channel.name,
111
+ bypassDnd: false,
112
+ lights: true,
113
+ vibration: true,
114
+ badge: true,
115
+ importance: importance(notification.channel.importance),
116
+ visibility: 0,
117
+ });
118
+ }
119
+ function androidNotification(notification, smallIcon) {
120
+ return Object.freeze({
121
+ id: notification.id,
122
+ data: Object.freeze({}),
123
+ ...(notification.title === undefined ? {} : { title: notification.title }),
124
+ ...(notification.body === undefined ? {} : { body: notification.body }),
125
+ android: Object.freeze({
126
+ autoCancel: true,
127
+ asForegroundService: false,
128
+ lightUpScreen: false,
129
+ badgeIconType: 2,
130
+ colorized: false,
131
+ chronometerDirection: "up",
132
+ defaults: Object.freeze([-1]),
133
+ groupAlertBehavior: 0,
134
+ groupSummary: false,
135
+ localOnly: false,
136
+ ongoing: false,
137
+ loopSound: false,
138
+ onlyAlertOnce: false,
139
+ importance: 3,
140
+ showTimestamp: false,
141
+ smallIcon,
142
+ showChronometer: false,
143
+ visibility: 0,
144
+ circularLargeIcon: false,
145
+ channelId: notification.channel.id,
146
+ pressAction: Object.freeze({
147
+ id: "default",
148
+ launchActivity: "default",
149
+ }),
150
+ }),
151
+ });
152
+ }
153
+ function iosNotification(notification) {
154
+ return Object.freeze({
155
+ id: notification.id,
156
+ data: Object.freeze({}),
157
+ ...(notification.title === undefined ? {} : { title: notification.title }),
158
+ ...(notification.body === undefined ? {} : { body: notification.body }),
159
+ ios: Object.freeze({
160
+ foregroundPresentationOptions: Object.freeze({
161
+ alert: true,
162
+ badge: true,
163
+ sound: true,
164
+ banner: true,
165
+ list: true,
166
+ }),
167
+ }),
168
+ });
169
+ }
170
+ /**
171
+ * Adapts Notify Kit 10.5's generated native ABI without importing its
172
+ * React-oriented JavaScript facade. Native resolution and event transport stay
173
+ * application-owned so this package remains usable outside React Native.
174
+ */
175
+ export function createNotifyKit10NotificationService(native, events, options) {
176
+ if (native === null || typeof native !== "object") {
177
+ throw new TypeError("Notify Kit native module must be an object.");
178
+ }
179
+ for (const name of [
180
+ "getNotificationSettings",
181
+ "requestPermission",
182
+ "createChannel",
183
+ "displayNotification",
184
+ "getDisplayedNotifications",
185
+ "cancelAllNotificationsWithIds",
186
+ "cancelNotification",
187
+ ]) {
188
+ nativeMethod(native, name);
189
+ }
190
+ if (events === null ||
191
+ typeof events !== "object" ||
192
+ typeof events.addListener !== "function") {
193
+ throw new TypeError("Notify Kit native event source is invalid.");
194
+ }
195
+ if (options === null || typeof options !== "object") {
196
+ throw new TypeError("Notify Kit adapter options must be an object.");
197
+ }
198
+ if (options.platform !== "android" && options.platform !== "ios") {
199
+ throw new TypeError("Notify Kit platform must be android or ios.");
200
+ }
201
+ const smallIcon = options.androidSmallIcon === undefined
202
+ ? "ic_launcher"
203
+ : androidResourceName(options.androidSmallIcon);
204
+ return createNotificationService({
205
+ async getPermission() {
206
+ return permission(await native.getNotificationSettings.call(native));
207
+ },
208
+ async requestPermission() {
209
+ const requested = options.platform === "android"
210
+ ? Object.freeze({})
211
+ : Object.freeze({ alert: true, badge: true, sound: true });
212
+ return permission(await native.requestPermission.call(native, requested));
213
+ },
214
+ async display(notification) {
215
+ if (options.platform === "android") {
216
+ await native.createChannel.call(native, androidChannel(notification));
217
+ await native.displayNotification.call(native, androidNotification(notification, smallIcon));
218
+ }
219
+ else {
220
+ await native.displayNotification.call(native, iosNotification(notification));
221
+ }
222
+ return notification.id;
223
+ },
224
+ async getDisplayedNotificationIds() {
225
+ return displayedNotificationIds(await native.getDisplayedNotifications.call(native));
226
+ },
227
+ async cancel(notificationId) {
228
+ if (options.platform === "android") {
229
+ await native.cancelAllNotificationsWithIds.call(native, Object.freeze([notificationId]), 0, null);
230
+ }
231
+ else {
232
+ await native.cancelNotification.call(native, notificationId);
233
+ }
234
+ },
235
+ subscribe(listener) {
236
+ const subscription = events.addListener(NOTIFY_KIT_10_FOREGROUND_EVENT, (event) => listener(notificationEvent(event)));
237
+ if (subscription === null ||
238
+ typeof subscription !== "object" ||
239
+ typeof subscription.remove !==
240
+ "function") {
241
+ throw new TypeError("Notify Kit native event subscription must expose remove().");
242
+ }
243
+ let active = true;
244
+ return () => {
245
+ if (!active)
246
+ return;
247
+ active = false;
248
+ subscription.remove();
249
+ };
250
+ },
251
+ });
252
+ }
253
+ //# sourceMappingURL=notify-kit-10.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notify-kit-10.js","sourceRoot":"","sources":["../src/notify-kit-10.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,GAM1B,MAAM,YAAY,CAAC;AAUpB,MAAM,CAAC,MAAM,8BAA8B,GAAG,gCAAgC,CAAC;AAsC/E,SAAS,WAAW,CAClB,KAAc,EACd,IAAY;IAEZ,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,qBAAqB,CAAC,CAAC;IACpD,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC/C,IAAI,SAAS,KAAK,MAAM,CAAC,SAAS,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACzD,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,0BAA0B,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,KAA0C,CAAC;AACpD,CAAC;AAED,SAAS,YAAY,CACnB,MAA+B,EAC/B,IAAmC;IAEnC,IAAI,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,UAAU,EAAE,CAAC;QACvC,MAAM,IAAI,SAAS,CAAC,4BAA4B,IAAI,sBAAsB,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc;IACzC,IAAI,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,CAAC;AACL,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { type Accessor } from "solid-js";
2
+ import { type NotificationEvent, type NotificationService, type NotificationSubscriptionOptions } from "./index.js";
3
+ export interface NotificationEventAccessorOptions extends NotificationSubscriptionOptions {
4
+ readonly initialValue?: NotificationEvent;
5
+ }
6
+ export type NotificationEventSource = NotificationService | Accessor<NotificationService | undefined>;
7
+ /**
8
+ * Projects native foreground notification events into one fine-grained Solid
9
+ * accessor and removes the platform subscription with its current owner.
10
+ */
11
+ export declare function createNotificationEvent(source: NotificationEventSource, options?: NotificationEventAccessorOptions): Accessor<NotificationEvent | undefined>;
12
+ //# sourceMappingURL=solid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solid.d.ts","sourceRoot":"","sources":["../src/solid.ts"],"names":[],"mappings":"AACA,OAAO,EAAyC,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEhF,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,mBAAmB,EACxB,KAAK,+BAA+B,EACrC,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,gCAAiC,SAAQ,+BAA+B;IACvF,QAAQ,CAAC,YAAY,CAAC,EAAE,iBAAiB,CAAC;CAC3C;AAED,MAAM,MAAM,uBAAuB,GACjC,mBAAmB,GAAG,QAAQ,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC;AAsBlE;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,uBAAuB,EAC/B,OAAO,GAAE,gCAAqC,GAC7C,QAAQ,CAAC,iBAAiB,GAAG,SAAS,CAAC,CA6DzC"}
package/dist/solid.js ADDED
@@ -0,0 +1,61 @@
1
+ import { createCausalPlatformEventHandler } from "@solidnative-dev/core";
2
+ import { createEffect, createSignal, onCleanup } from "solid-js";
3
+ import {} from "./index.js";
4
+ const NOTIFICATION_EVENT_NAMES = Object.freeze({
5
+ delivered: "platform.notification.delivered",
6
+ pressed: "platform.notification.pressed",
7
+ "action-pressed": "platform.notification.action-pressed",
8
+ dismissed: "platform.notification.dismissed",
9
+ unknown: "platform.notification.unknown",
10
+ });
11
+ function reportAccessorError(error, options) {
12
+ try {
13
+ const reported = options.onError?.(error);
14
+ void Promise.resolve(reported).catch(() => undefined);
15
+ }
16
+ catch {
17
+ // Diagnostics cannot break subscription handoff or owner disposal.
18
+ }
19
+ }
20
+ /**
21
+ * Projects native foreground notification events into one fine-grained Solid
22
+ * accessor and removes the platform subscription with its current owner.
23
+ */
24
+ export function createNotificationEvent(source, options = {}) {
25
+ const [event, setEvent] = createSignal(options.initialValue);
26
+ const handlers = Object.freeze({
27
+ delivered: createCausalPlatformEventHandler(NOTIFICATION_EVENT_NAMES.delivered, setEvent),
28
+ pressed: createCausalPlatformEventHandler(NOTIFICATION_EVENT_NAMES.pressed, setEvent, { priority: "discrete" }),
29
+ "action-pressed": createCausalPlatformEventHandler(NOTIFICATION_EVENT_NAMES["action-pressed"], setEvent, { priority: "discrete" }),
30
+ dismissed: createCausalPlatformEventHandler(NOTIFICATION_EVENT_NAMES.dismissed, setEvent),
31
+ unknown: createCausalPlatformEventHandler(NOTIFICATION_EVENT_NAMES.unknown, setEvent),
32
+ });
33
+ let removeSubscription;
34
+ const removeCurrentSubscription = () => {
35
+ const remove = removeSubscription;
36
+ removeSubscription = undefined;
37
+ if (remove === undefined)
38
+ return;
39
+ try {
40
+ remove();
41
+ }
42
+ catch (error) {
43
+ reportAccessorError(error, options);
44
+ }
45
+ };
46
+ createEffect(() => (typeof source === "function" ? source() : source), (service) => {
47
+ removeCurrentSubscription();
48
+ if (service === undefined)
49
+ return;
50
+ try {
51
+ const subscription = service.subscribe((nextEvent) => handlers[nextEvent.kind](nextEvent), options);
52
+ removeSubscription = () => subscription.remove();
53
+ }
54
+ catch (error) {
55
+ reportAccessorError(error, options);
56
+ }
57
+ });
58
+ onCleanup(removeCurrentSubscription);
59
+ return event;
60
+ }
61
+ //# sourceMappingURL=solid.js.map
@@ -0,0 +1 @@
1
+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solidnative-dev/notifications",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-alpha.0",
4
+ "type": "module",
5
+ "description": "Validated local notifications and Solid-owned notification events.",
6
+ "license": "MIT",
7
+ "homepage": "https://solidnative.dev",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/solid-native/solid-native.git",
11
+ "directory": "packages/notifications"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "engines": {
17
+ "node": "^22.13.0 || ^24.3.0 || >=26.0.0"
18
+ },
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "default": "./dist/index.js"
23
+ },
24
+ "./solid": {
25
+ "types": "./dist/solid.d.ts",
26
+ "default": "./dist/solid.js"
27
+ },
28
+ "./notify-kit-10": {
29
+ "types": "./dist/notify-kit-10.d.ts",
30
+ "default": "./dist/notify-kit-10.js"
31
+ }
32
+ },
33
+ "files": [
34
+ "dist/index.d.ts",
35
+ "dist/index.d.ts.map",
36
+ "dist/index.js",
37
+ "dist/index.js.map",
38
+ "dist/notify-kit-10.d.ts",
39
+ "dist/notify-kit-10.d.ts.map",
40
+ "dist/notify-kit-10.js",
41
+ "dist/notify-kit-10.js.map",
42
+ "dist/solid.d.ts",
43
+ "dist/solid.d.ts.map",
44
+ "dist/solid.js",
45
+ "dist/solid.js.map"
46
+ ],
47
+ "dependencies": {
48
+ "@solidnative-dev/core": "0.1.0-alpha.0"
49
+ },
50
+ "peerDependencies": {
51
+ "solid-js": "2.0.4"
52
+ },
53
+ "devDependencies": {
54
+ "solid-js": "2.0.4"
55
+ },
56
+ "scripts": {
57
+ "build": "tsc -p tsconfig.json",
58
+ "check": "tsc -p tsconfig.json --noEmit",
59
+ "test": "pnpm build && node --conditions=browser --test test/*.test.mjs"
60
+ }
6
61
  }