Skip to content

Commit 929b116

Browse files
committed
update build script
1 parent f2b341b commit 929b116

File tree

9 files changed

+186
-47
lines changed

9 files changed

+186
-47
lines changed

.vscode/extensions.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"recommendations": [
3+
"oxc.oxc-vscode",
4+
"esbenp.prettier-vscode",
5+
"redhat.vscode-yaml"
6+
]
7+
}

.vscode/settings.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.codeActionsOnSave": {
4+
"source.fixAll.eslint": "explicit",
5+
"source.organizeImports": "explicit"
6+
},
7+
"editor.defaultFormatter": "esbenp.prettier-vscode",
8+
"[yaml]": {
9+
"editor.defaultFormatter": "redhat.vscode-yaml"
10+
}
11+
}

bun.lock

Lines changed: 111 additions & 0 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"types": "dist/index.d.ts",
77
"scripts": {
88
"prepare": "bun run build",
9-
"build": "vite build",
9+
"build": "tsc --noEmit && vite build",
1010
"lint": "oxlint src examples && prettier --check src examples",
1111
"lint:fix": "oxlint src examples --fix && prettier --write src examples"
1212
},
@@ -18,7 +18,9 @@
1818
"@types/react-native": "^0.73.0",
1919
"oxlint": "^1.26.0",
2020
"prettier": "^3.6.2",
21-
"typescript": "^5.9.3"
21+
"typescript": "^5.9.3",
22+
"vite": "^7.2.0",
23+
"vite-plugin-dts": "^4.5.4"
2224
},
2325
"keywords": [
2426
"react-component",

src/events/EventManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
2-
EmitterSubscription,
2+
type EmitterSubscription,
33
NativeEventEmitter,
4-
NativeModule,
4+
type NativeModule,
55
} from 'react-native';
66
import OSNotification from '../OSNotification';
77
import NotificationWillDisplayEvent from './NotificationWillDisplayEvent';

src/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import invariant from 'invariant';
2-
import { NativeModule } from 'react-native';
2+
import type { NativeModule } from 'react-native';
33

44
export function isValidCallback(handler: Function) {
55
invariant(typeof handler === 'function', 'Must provide a valid callback');

src/index.ts

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ import {
1414
SUBSCRIPTION_CHANGED,
1515
USER_STATE_CHANGED,
1616
} from './events/events';
17-
import {
18-
NotificationEventName,
19-
NotificationEventTypeMap,
20-
NotificationClickEvent,
21-
} from './models/NotificationEvents';
22-
import {
23-
PushSubscriptionState,
24-
OSNotificationPermission,
25-
PushSubscriptionChangedState,
26-
} from './models/Subscription';
27-
import { UserState, UserChangedState } from './models/User';
2817
import NotificationWillDisplayEvent from './events/NotificationWillDisplayEvent';
29-
import { LiveActivitySetupOptions } from './models/LiveActivities';
30-
import {
18+
import { isNativeModuleLoaded, isValidCallback } from './helpers';
19+
import type {
3120
InAppMessage,
32-
InAppMessageEventTypeMap,
33-
InAppMessageEventName,
3421
InAppMessageClickEvent,
35-
InAppMessageWillDisplayEvent,
22+
InAppMessageDidDismissEvent,
3623
InAppMessageDidDisplayEvent,
24+
InAppMessageEventName,
25+
InAppMessageEventTypeMap,
3726
InAppMessageWillDismissEvent,
38-
InAppMessageDidDismissEvent,
27+
InAppMessageWillDisplayEvent,
3928
} from './models/InAppMessage';
40-
import { isValidCallback, isNativeModuleLoaded } from './helpers';
29+
import type { LiveActivitySetupOptions } from './models/LiveActivities';
30+
import type {
31+
NotificationClickEvent,
32+
NotificationEventName,
33+
NotificationEventTypeMap,
34+
} from './models/NotificationEvents';
35+
import {
36+
OSNotificationPermission,
37+
type PushSubscriptionChangedState,
38+
type PushSubscriptionState,
39+
} from './models/Subscription';
40+
import type { UserChangedState, UserState } from './models/User';
4141

4242
const RNOneSignal = NativeModules.OneSignal;
4343
const eventManager = new EventManager(RNOneSignal);
@@ -288,7 +288,7 @@ export namespace OneSignal {
288288
export namespace pushSubscription {
289289
/** Add a callback that fires when the OneSignal subscription state changes. */
290290
export function addEventListener(
291-
event: 'change',
291+
_event: 'change',
292292
listener: (event: PushSubscriptionChangedState) => void,
293293
) {
294294
if (!isNativeModuleLoaded(RNOneSignal)) return;
@@ -303,7 +303,7 @@ export namespace OneSignal {
303303

304304
/** Clears current subscription observers. */
305305
export function removeEventListener(
306-
event: 'change',
306+
_event: 'change',
307307
listener: (event: PushSubscriptionChangedState) => void,
308308
) {
309309
if (!isNativeModuleLoaded(RNOneSignal)) return;
@@ -410,7 +410,7 @@ export namespace OneSignal {
410410
* Important: When using the observer to retrieve the onesignalId, check the externalId as well to confirm the values are associated with the expected user.
411411
*/
412412
export function addEventListener(
413-
event: 'change',
413+
_event: 'change',
414414
listener: (event: UserChangedState) => void,
415415
) {
416416
if (!isNativeModuleLoaded(RNOneSignal)) return;
@@ -425,7 +425,7 @@ export namespace OneSignal {
425425

426426
/** Clears current user state observers. */
427427
export function removeEventListener(
428-
event: 'change',
428+
_event: 'change',
429429
listener: (event: UserChangedState) => void,
430430
) {
431431
if (!isNativeModuleLoaded(RNOneSignal)) return;
@@ -1002,20 +1002,20 @@ export namespace OneSignal {
10021002

10031003
export {
10041004
NotificationWillDisplayEvent,
1005-
NotificationClickEvent,
1006-
InAppMessage,
1007-
InAppMessageClickEvent,
1008-
InAppMessageWillDisplayEvent,
1009-
InAppMessageDidDisplayEvent,
1010-
InAppMessageWillDismissEvent,
1011-
InAppMessageDidDismissEvent,
1012-
PushSubscriptionState,
1013-
PushSubscriptionChangedState,
1014-
UserState,
1015-
UserChangedState,
10161005
OSNotificationPermission,
1006+
type InAppMessage,
1007+
type InAppMessageClickEvent,
1008+
type InAppMessageDidDismissEvent,
1009+
type InAppMessageDidDisplayEvent,
1010+
type InAppMessageWillDismissEvent,
1011+
type InAppMessageWillDisplayEvent,
1012+
type NotificationClickEvent,
1013+
type PushSubscriptionChangedState,
1014+
type PushSubscriptionState,
1015+
type UserChangedState,
1016+
type UserState,
10171017
};
10181018

1019+
export type { InAppMessageClickResult } from './models/InAppMessage';
1020+
export type { NotificationClickResult } from './models/NotificationEvents';
10191021
export { default as OSNotification } from './OSNotification';
1020-
export { NotificationClickResult } from './models/NotificationEvents';
1021-
export { InAppMessageClickResult } from './models/InAppMessage';

tsconfig.json

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
{
22
"compilerOptions": {
33
"outDir": "dist",
4-
"target": "es5",
5-
"moduleResolution": "node",
4+
"target": "es2020",
5+
"module": "esnext",
6+
"moduleResolution": "bundler",
67
"noImplicitAny": true,
7-
"lib": ["es6"],
8-
"rootDir": "src",
9-
"declaration": true,
10-
"allowSyntheticDefaultImports": true,
8+
"lib": ["es2020"],
119
"skipLibCheck": true,
10+
"allowSyntheticDefaultImports": true,
1211
"esModuleInterop": true,
1312
"strict": true,
14-
"noUnusedLocals": true
13+
"noUnusedLocals": true,
14+
"noUnusedParameters": true,
15+
16+
/**
17+
* Should use import type syntax instead of regular import when getting types/interfaces from a module
18+
*/
19+
"verbatimModuleSyntax": true
1520
},
1621
"exclude": ["node_modules", "dist", "android", "examples", "ios"]
1722
}

vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@ export default defineConfig({
1111
formats: ['es'],
1212
fileName: () => 'index.js',
1313
},
14+
rollupOptions: {
15+
external: ['react-native'],
16+
},
1417
},
1518
});

0 commit comments

Comments
 (0)