craft-native 0.0.158 → 0.0.160
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/dist/android/templates/CraftNative.kt.template +24 -1
- package/dist/android/templates/CraftNativeCapabilities.kt.template +309 -4
- package/dist/android/templates/MainActivityNative.kt.template +606 -48
- package/dist/api/mobile.d.ts +3 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/ios/src/index.d.ts +2 -0
- package/dist/ios/src/index.js +16 -6
- package/dist/ios/templates/CraftHealth.swift +11 -0
- package/dist/ios/templates/CraftHybrid.swift +19 -0
- package/dist/ios/templates/CraftNativeScreen.swift +403 -45
- package/package.json +1 -1
package/dist/api/mobile.d.ts
CHANGED
|
@@ -1238,7 +1238,9 @@ export declare const pushNotifications: {
|
|
|
1238
1238
|
*/
|
|
1239
1239
|
onReceive(callback: (data: Record<string, unknown>) => void): () => void;
|
|
1240
1240
|
};
|
|
1241
|
-
export type HealthDataType = 'steps' | 'heartRate' | 'activeEnergy' | 'distance' | 'workouts' | 'restingHeartRate' | 'heartRateVariability' | 'bodyMass' | 'sleep'
|
|
1241
|
+
export type HealthDataType = 'steps' | 'heartRate' | 'activeEnergy' | 'distance' | 'workouts' | 'restingHeartRate' | 'heartRateVariability' | 'bodyMass' | 'sleep'
|
|
1242
|
+
/** Food logged by any app, per day: kcal eaten, then grams of protein, carbohydrate and fat. Read only. */
|
|
1243
|
+
| 'dietaryEnergy' | 'dietaryProtein' | 'dietaryCarbohydrates' | 'dietaryFat';
|
|
1242
1244
|
/** The types with one value per day. `sleep` is hours asleep, counted on the day you woke. */
|
|
1243
1245
|
export type HealthDailyType = Exclude<HealthDataType, 'workouts'>;
|
|
1244
1246
|
export interface HealthAuthorizationOptions {
|
package/dist/cli.js
CHANGED
|
@@ -3303,7 +3303,7 @@ function pinCraftNativeDependency(packagePath, craftVersion) {
|
|
|
3303
3303
|
`);
|
|
3304
3304
|
}
|
|
3305
3305
|
// package.json
|
|
3306
|
-
var version = "0.0.
|
|
3306
|
+
var version = "0.0.160";
|
|
3307
3307
|
|
|
3308
3308
|
// bin/cli.ts
|
|
3309
3309
|
var spawnedFrom = process6.env[CRAFT_CLI_SPAWN_MARKER];
|
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
package/dist/ios/src/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generates native iOS apps from web content using WKWebView.
|
|
5
5
|
*/
|
|
6
|
+
/** This package's version, which the app names in its user agent (`Craft/<version>`). */
|
|
7
|
+
export declare function resolveCraftVersion(startDir?: string): string;
|
|
6
8
|
export type CraftAppearance = 'light' | 'dark' | 'system';
|
|
7
9
|
export interface CraftConfig {
|
|
8
10
|
appName: string;
|
package/dist/ios/src/index.js
CHANGED
|
@@ -144,13 +144,22 @@ function createNativeMutationValidator() {
|
|
|
144
144
|
|
|
145
145
|
// ../ios/src/index.ts
|
|
146
146
|
var TEMPLATES_DIR = join2(dirname2(import.meta.dir), "templates");
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
function resolveCraftVersion(startDir = import.meta.dir) {
|
|
148
|
+
let directory = resolve(startDir);
|
|
149
|
+
while (true) {
|
|
150
|
+
try {
|
|
151
|
+
const packageJSON = JSON.parse(readFileSync2(join2(directory, "package.json"), "utf8"));
|
|
152
|
+
if (packageJSON.name === "@craft-native/ios" && typeof packageJSON.version === "string" && packageJSON.version.length > 0)
|
|
153
|
+
return packageJSON.version;
|
|
154
|
+
} catch {}
|
|
155
|
+
const parent = dirname2(directory);
|
|
156
|
+
if (parent === directory)
|
|
157
|
+
break;
|
|
158
|
+
directory = parent;
|
|
152
159
|
}
|
|
153
|
-
|
|
160
|
+
return "0.0.0";
|
|
161
|
+
}
|
|
162
|
+
var CRAFT_VERSION = resolveCraftVersion();
|
|
154
163
|
function normalizeNativePath(raw) {
|
|
155
164
|
if (typeof raw !== "string")
|
|
156
165
|
return null;
|
|
@@ -1277,6 +1286,7 @@ export {
|
|
|
1277
1286
|
run,
|
|
1278
1287
|
restoreShell,
|
|
1279
1288
|
resolveRuntimeDir,
|
|
1289
|
+
resolveCraftVersion,
|
|
1280
1290
|
resolveAppearance,
|
|
1281
1291
|
renderWatchEntitlements,
|
|
1282
1292
|
renderUsageDescriptions,
|
|
@@ -106,6 +106,12 @@ final class CraftHealth {
|
|
|
106
106
|
if let sleepType = HKObjectType.categoryType(forIdentifier: .sleepAnalysis) {
|
|
107
107
|
readTypes.insert(sleepType)
|
|
108
108
|
}
|
|
109
|
+
case "dietaryEnergy", "dietaryProtein", "dietaryCarbohydrates", "dietaryFat":
|
|
110
|
+
// What a food log (MyFitnessPal, Lose It!, Cronometer...)
|
|
111
|
+
// writes to Apple Health: read only, never written back.
|
|
112
|
+
if let dietaryType = Self.healthQuantity(type)?.type {
|
|
113
|
+
readTypes.insert(dietaryType)
|
|
114
|
+
}
|
|
109
115
|
default:
|
|
110
116
|
break
|
|
111
117
|
}
|
|
@@ -261,6 +267,11 @@ final class CraftHealth {
|
|
|
261
267
|
case "restingHeartRate": return (HKQuantityType.quantityType(forIdentifier: .restingHeartRate), bpm, .discreteAverage)
|
|
262
268
|
case "heartRateVariability": return (HKQuantityType.quantityType(forIdentifier: .heartRateVariabilitySDNN), .secondUnit(with: .milli), .discreteAverage)
|
|
263
269
|
case "bodyMass": return (HKQuantityType.quantityType(forIdentifier: .bodyMass), .gramUnit(with: .kilo), .mostRecent)
|
|
270
|
+
// A day's food, summed over every meal any app logged: kcal and grams.
|
|
271
|
+
case "dietaryEnergy": return (HKQuantityType.quantityType(forIdentifier: .dietaryEnergyConsumed), .kilocalorie(), .cumulativeSum)
|
|
272
|
+
case "dietaryProtein": return (HKQuantityType.quantityType(forIdentifier: .dietaryProtein), .gram(), .cumulativeSum)
|
|
273
|
+
case "dietaryCarbohydrates": return (HKQuantityType.quantityType(forIdentifier: .dietaryCarbohydrates), .gram(), .cumulativeSum)
|
|
274
|
+
case "dietaryFat": return (HKQuantityType.quantityType(forIdentifier: .dietaryFatTotal), .gram(), .cumulativeSum)
|
|
264
275
|
default: return nil
|
|
265
276
|
}
|
|
266
277
|
}
|
|
@@ -1457,6 +1457,19 @@ final class CraftHybridController: UIViewController, UINavigationControllerDeleg
|
|
|
1457
1457
|
return popRecognizers(of: nav).contains { $0 === recognizer }
|
|
1458
1458
|
}
|
|
1459
1459
|
|
|
1460
|
+
private func nativeScreenContainsHorizontalScroll(_ screen: CraftNativeScreenController) -> Bool {
|
|
1461
|
+
guard let root = screen.viewIfLoaded else { return false }
|
|
1462
|
+
func visit(_ view: UIView) -> Bool {
|
|
1463
|
+
if let scroll = view as? UIScrollView,
|
|
1464
|
+
scroll.isScrollEnabled,
|
|
1465
|
+
scroll.alwaysBounceHorizontal || scroll.contentSize.width > scroll.bounds.width + 1 {
|
|
1466
|
+
return true
|
|
1467
|
+
}
|
|
1468
|
+
return view.subviews.contains(where: visit)
|
|
1469
|
+
}
|
|
1470
|
+
return visit(root)
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1460
1473
|
/// The edge swipe goes ahead of the web view's own gestures, which
|
|
1461
1474
|
/// otherwise hold every touch over the page until the page has answered it.
|
|
1462
1475
|
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
|
@@ -1470,6 +1483,12 @@ final class CraftHybridController: UIViewController, UINavigationControllerDeleg
|
|
|
1470
1483
|
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
|
|
1471
1484
|
guard let nav = visibleStack, isPopRecognizer(gestureRecognizer),
|
|
1472
1485
|
nav.viewControllers.count > 1, nav.transitionCoordinator == nil else { return false }
|
|
1486
|
+
if let native = nav.topViewController as? CraftNativeScreenController,
|
|
1487
|
+
gestureRecognizer !== nav.interactivePopGestureRecognizer,
|
|
1488
|
+
nativeScreenContainsHorizontalScroll(native) {
|
|
1489
|
+
let moved = (gestureRecognizer as? UIPanGestureRecognizer)?.translation(in: nav.view).x ?? 0
|
|
1490
|
+
if gestureRecognizer.location(in: nav.view).x - moved > 32 { return false }
|
|
1491
|
+
}
|
|
1473
1492
|
guard let slot = nav.topViewController as? CraftHybridWebSlot else { return true }
|
|
1474
1493
|
// Over the page, only from its left edge: a swipe across the page is
|
|
1475
1494
|
// the page's (a carousel, a slider).
|