@sency/react-native-smkit-ui 2.3.0 → 2.3.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.
@@ -15,9 +15,11 @@ Pod::Spec.new do |s|
15
15
  s.source = { :git => "https://github.com/sency-ai/smkit-ui-react-native-demo.git", :tag => "#{s.version}" }
16
16
 
17
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
18
- s.dependency "SMKitUI", "= 1.9.7"
18
+ # Required for direct Swift imports in SMKitUIManager.swift.
19
+ s.dependency "SMBase", "= 2.0.2"
20
+ s.dependency "SMKitUI", "= 2.0.2"
19
21
  # Required so the bridge can reference InstructionVideoConfig and VideoDisplayMode (defined in SMKit).
20
- s.dependency "SMKit", "= 1.9.7"
22
+ s.dependency "SMKit", "= 2.0.2"
21
23
 
22
24
  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
23
25
  # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
package/src/SMWorkout.tsx CHANGED
@@ -315,6 +315,7 @@ export type ExerciseOptions = {
315
315
  guidanceVideoSegments?: Record<string, GuidanceVideoSegment | GuidanceVideoSegmentConfig> | null;
316
316
  stretchSetConfig?: StretchSetConfig | null;
317
317
  side?: string | null;
318
+ showTargetProgress?: boolean;
318
319
  };
319
320
 
320
321
  export class SMExercise {
@@ -378,6 +379,7 @@ export class SMExercise {
378
379
  : serializeGuidanceVideoSegments(this.options.guidanceVideoSegments),
379
380
  stretchSetConfig: this.options.stretchSetConfig?.toJSON() ?? (this.options.stretchSetConfig === null ? null : undefined),
380
381
  side: this.options.side ?? undefined,
382
+ showTargetProgress: this.options.showTargetProgress,
381
383
  });
382
384
  }
383
385
  }
package/src/index.tsx CHANGED
@@ -20,12 +20,88 @@ const SMKitUIManager = NativeModules['SMKitUIManager']
20
20
  }
21
21
  );
22
22
 
23
+ function getErrorMessage(error: unknown): string {
24
+ if (error instanceof Error) {
25
+ return error.message;
26
+ }
27
+ if (typeof error === 'string') {
28
+ return error;
29
+ }
30
+ if (error && typeof error === 'object') {
31
+ const nativeError = error as { message?: unknown; name?: unknown; code?: unknown };
32
+ return [nativeError.name, nativeError.code, nativeError.message]
33
+ .filter((value): value is string => typeof value === 'string')
34
+ .join(' ');
35
+ }
36
+ return '';
37
+ }
38
+
39
+ function isLegacyConfigureBridgeError(error: unknown): boolean {
40
+ const message = getErrorMessage(error).toLowerCase();
41
+ if (message.includes("doesn't seem to be linked")) {
42
+ return false;
43
+ }
44
+ return (
45
+ message.includes('configure') &&
46
+ (
47
+ message.includes('argument') ||
48
+ message.includes('expected') ||
49
+ message.includes('selector') ||
50
+ message.includes('unrecognized') ||
51
+ message.includes('not recognized') ||
52
+ message.includes('method not found') ||
53
+ message.includes('is not a function')
54
+ )
55
+ );
56
+ }
57
+
58
+ async function applyLegacyConfigureLanguageFallback(
59
+ language: SMWorkoutLibrary.Language
60
+ ): Promise<void> {
61
+ if (language === SMWorkoutLibrary.Language.English) {
62
+ return;
63
+ }
64
+
65
+ const setSessionLanguage = SMKitUIManager.setSessionLanguage;
66
+ const setPhoneCalibrationLanguage = SMKitUIManager.setPhoneCalibrationLanguage;
67
+
68
+ if (typeof setSessionLanguage === 'function') {
69
+ try {
70
+ await setSessionLanguage(language);
71
+ } catch {
72
+ // Older native packages may not expose language setters. Configure should remain usable.
73
+ }
74
+ }
75
+
76
+ if (typeof setPhoneCalibrationLanguage === 'function') {
77
+ try {
78
+ await setPhoneCalibrationLanguage(language);
79
+ } catch {
80
+ // Best-effort parity for native packages released before configure-time language.
81
+ }
82
+ }
83
+ }
84
+
23
85
  /**
24
86
  * This function will configure the sdk
25
87
  * @param {string} key - your auth key
26
- */
27
- export function configure(key: string): Promise<string> {
28
- return SMKitUIManager.configure(key);
88
+ * @param {SMWorkoutLibrary.Language} language - Optional configure language. Defaults to English.
89
+ */
90
+ export async function configure(
91
+ key: string,
92
+ language: SMWorkoutLibrary.Language = SMWorkoutLibrary.Language.English
93
+ ): Promise<string> {
94
+ try {
95
+ return await SMKitUIManager.configure(key, language);
96
+ } catch (error) {
97
+ if (!isLegacyConfigureBridgeError(error)) {
98
+ throw error;
99
+ }
100
+
101
+ const result = await SMKitUIManager.configure(key);
102
+ await applyLegacyConfigureLanguageFallback(language);
103
+ return result;
104
+ }
29
105
  }
30
106
 
31
107
  /**