craft-native 0.0.92 → 0.0.95
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/README.md +17 -0
- package/dist/android/src/index.d.ts +3 -0
- package/dist/android/src/index.js +8 -4
- package/dist/android/templates/CraftBridge.kt.template +271 -72
- package/dist/android/templates/CraftNative.kt.template +12 -6
- package/dist/android/templates/MainActivity.kt.template +86 -9
- package/dist/api/mobile.d.ts +32 -0
- package/dist/binary-resolver.d.ts +4 -0
- package/dist/cli.js +17 -8
- package/dist/index.cjs +77 -49
- package/dist/index.d.cts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +78 -50
- package/dist/ios/templates/CraftApp.swift +450 -27
- package/dist/mobile.js +24 -1
- package/dist/sdk-version.d.ts +1 -0
- package/package.json +2 -2
package/dist/mobile.js
CHANGED
|
@@ -501,6 +501,13 @@ var lifecycle = {
|
|
|
501
501
|
return () => document.removeEventListener("visibilitychange", handler);
|
|
502
502
|
}
|
|
503
503
|
};
|
|
504
|
+
function bridgeNotification(options, now = Date.now()) {
|
|
505
|
+
const { scheduleAt, ...rest } = options;
|
|
506
|
+
if (scheduleAt === undefined)
|
|
507
|
+
return rest;
|
|
508
|
+
const wait = Math.ceil(scheduleAt - now);
|
|
509
|
+
return wait > 0 ? { ...rest, delay: wait } : rest;
|
|
510
|
+
}
|
|
504
511
|
var notifications = {
|
|
505
512
|
async show(options) {
|
|
506
513
|
const craft = getCraftMobile();
|
|
@@ -514,7 +521,7 @@ var notifications = {
|
|
|
514
521
|
async schedule(options) {
|
|
515
522
|
const craft = getCraftMobile();
|
|
516
523
|
if (typeof window !== "undefined" && craft?.notifications) {
|
|
517
|
-
return craft.notifications.schedule(options);
|
|
524
|
+
return craft.notifications.schedule(bridgeNotification(options));
|
|
518
525
|
}
|
|
519
526
|
throw new Error("Scheduled notifications not available in web");
|
|
520
527
|
},
|
|
@@ -631,7 +638,22 @@ var pushNotifications = {
|
|
|
631
638
|
return onCraftEvent("craftPushToken", (detail) => callback(String(detail.token ?? "")));
|
|
632
639
|
},
|
|
633
640
|
onNotification(callback) {
|
|
641
|
+
const craft = getCraftRoot();
|
|
642
|
+
if (craft?.notifications?.onTap) {
|
|
643
|
+
return craft.notifications.onTap((detail) => {
|
|
644
|
+
callback(detail ?? {});
|
|
645
|
+
}) ?? (() => {});
|
|
646
|
+
}
|
|
634
647
|
return onCraftEvent("craftNotificationResponse", (detail) => callback(detail));
|
|
648
|
+
},
|
|
649
|
+
onReceive(callback) {
|
|
650
|
+
const craft = getCraftRoot();
|
|
651
|
+
if (craft?.notifications?.onReceive) {
|
|
652
|
+
return craft.notifications.onReceive((detail) => {
|
|
653
|
+
callback(detail ?? {});
|
|
654
|
+
}) ?? (() => {});
|
|
655
|
+
}
|
|
656
|
+
return onCraftEvent("craftNotificationReceived", (detail) => callback(detail));
|
|
635
657
|
}
|
|
636
658
|
};
|
|
637
659
|
var health = {
|
|
@@ -779,6 +801,7 @@ export {
|
|
|
779
801
|
device,
|
|
780
802
|
deepLinks,
|
|
781
803
|
camera,
|
|
804
|
+
bridgeNotification,
|
|
782
805
|
biometrics,
|
|
783
806
|
appReview,
|
|
784
807
|
_webFallbackDeviceId,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SDK_VERSION: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "craft-native",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.95",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Build desktop apps with web languages - TypeScript SDK for Craft",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
@@ -94,6 +94,6 @@
|
|
|
94
94
|
"@stacksjs/clapp": "^0.2.0",
|
|
95
95
|
"@types/bun": "^1.2.0",
|
|
96
96
|
"@types/node": "^22.0.0",
|
|
97
|
-
"better-dx": "^0.2.
|
|
97
|
+
"better-dx": "^0.2.25"
|
|
98
98
|
}
|
|
99
99
|
}
|