@h1r-ai/croche-react-native 0.5.0 → 0.5.2

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 (35) hide show
  1. package/README.md +14 -2
  2. package/android/src/main/java/dev/croche/reactnative/CrocheRuntimeModule.kt +6 -5
  3. package/android/src/main/java/dev/croche/reactnative/ProjectTimeZone.kt +14 -0
  4. package/android/src/test/java/dev/croche/reactnative/ProjectTimeZoneTest.kt +24 -0
  5. package/android/vendor/CrocheRuntimeSDK/android/dev/croche/android/CrocheProjectRecordProvider.kt +8 -1
  6. package/android/vendor/CrocheRuntimeSDK/consumer-rules.pro +1 -1
  7. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Croche.kt +120 -0
  8. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/CrocheAgent.kt +116 -0
  9. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/CrocheRuntime.kt +13 -3
  10. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/Host.kt +14 -3
  11. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectBinding.kt +79 -0
  12. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectPalRouting.kt +25 -0
  13. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectPlatform.kt +46 -0
  14. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ProjectTypes.kt +44 -0
  15. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/StreamHub.kt +27 -11
  16. package/android/vendor/CrocheRuntimeSDK/core/dev/croche/ffi/croche_ffi.kt +0 -2
  17. package/android/vendor/jniLibs/arm64-v8a/libcroche_ffi.so +0 -0
  18. package/android/vendor/jniLibs/armeabi-v7a/libcroche_ffi.so +0 -0
  19. package/android/vendor/jniLibs/x86_64/libcroche_ffi.so +0 -0
  20. package/ios/CrocheRuntimeBridge.swift +26 -4
  21. package/ios/vendor/CrocheRuntimeSDK/FFIStreamPort.swift +4 -1
  22. package/ios/vendor/CrocheRuntimeSDK/Host.swift +2 -1
  23. package/ios/vendor/CrocheRuntimeSDK/OpenOptions.swift +172 -0
  24. package/ios/vendor/CrocheRuntimeSDK/PortableSHA256.swift +42 -0
  25. package/ios/vendor/CrocheRuntimeSDK/Project.swift +271 -0
  26. package/ios/vendor/CrocheRuntimeSDK/Runtime.swift +57 -10
  27. package/ios/vendor/CrocheRuntimeSDK/StreamHub.swift +103 -9
  28. package/ios/vendor/CrocheRuntimeSDK/SubscriptionTypes.swift +22 -0
  29. package/ios/vendor/croche_ffiFFI.xcframework/Info.plist +5 -5
  30. package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64/Headers/croche_ffiFFI.h +0 -1
  31. package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64/libcroche_ffi.a +0 -0
  32. package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64_x86_64-simulator/Headers/croche_ffiFFI.h +0 -1
  33. package/ios/vendor/croche_ffiFFI.xcframework/ios-arm64_x86_64-simulator/libcroche_ffi.a +0 -0
  34. package/package.json +3 -3
  35. package/src/project.ts +9 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h1r-ai/croche-react-native",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -20,11 +20,11 @@
20
20
  "THIRD-PARTY-NOTICES"
21
21
  ],
22
22
  "peerDependencies": {
23
- "@h1r-ai/croche": "0.5.0",
23
+ "@h1r-ai/croche": "0.5.2",
24
24
  "react-native": ">=0.76"
25
25
  },
26
26
  "devDependencies": {
27
- "@h1r-ai/croche": "0.5.0"
27
+ "@h1r-ai/croche": "0.5.2"
28
28
  },
29
29
  "codegenConfig": {
30
30
  "name": "CrocheRuntimeSpec",
package/src/project.ts CHANGED
@@ -77,13 +77,17 @@ function pick(options: Options, keys: readonly string[]) {
77
77
  const source = options as unknown as Record<string, unknown>;
78
78
  return Object.fromEntries(keys.filter(key => source[key] !== undefined).map(key => [key, source[key]]));
79
79
  }
80
+ /** The user's language when the app gives none: the device locale, as BCP-47 (founder 10-12). */
81
+ function deviceLanguage(): string | undefined {
82
+ try { return Intl.DateTimeFormat().resolvedOptions().locale || undefined; } catch { return undefined; }
83
+ }
80
84
  function wire(options: Options) {
81
85
  return {
82
86
  host: pick(options, hostFields),
83
87
  ...(options.user === undefined ? {} : { user: options.user }),
84
88
  config: options.config,
85
89
  handlers: Object.keys(options.handlers ?? {}),
86
- ...(options.language === undefined ? {} : { language: options.language }),
90
+ ...((language => language === undefined ? {} : { language })(options.language ?? deviceLanguage())),
87
91
  runtime: pick(options, runtimeFields),
88
92
  ...pick(options, ['timeZone', 'attestation', 'android', 'backgroundDelivery']),
89
93
  };
@@ -314,6 +318,10 @@ export class Croche {
314
318
  if (['storageKey', 'identity', 'storage', 'serverKey'].some(key => Object.hasOwn(options, key))) {
315
319
  throw new CrocheError('invalid_configuration', 'storage, serverKey, storageKey and identity are not options on React Native.');
316
320
  }
321
+ // #587: refused rather than dropped until project agents have a per-agent task identifier (#581 Q9).
322
+ if (options.backgroundDelivery !== undefined && options.backgroundDelivery !== false) {
323
+ throw new CrocheError('invalid_configuration', 'backgroundDelivery is not available for project agents yet.');
324
+ }
317
325
  const handlers = { ...options.handlers };
318
326
  if (Object.values(handlers).some(handler => typeof handler !== 'function')) {
319
327
  throw new CrocheError('invalid_configuration', 'Every handler must be a function.');