@sency/react-native-smkit-ui 2.3.1 → 2.4.0
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 +9 -5
- package/android/build.gradle +38 -3
- package/android/src/main/java/com/smkituilibrary/SmkitUiLibraryModule.kt +16 -12
- package/android/src/main/java/com/smkituilibrary/mapper/SMMapper.kt +4 -2
- package/android/src/main/java/com/smkituilibrary/model/SMKitExercise.kt +1 -0
- package/ios/SMKitUIManager.mm +1 -1
- package/ios/SMKitUIManager.swift +11 -4
- package/lib/commonjs/SMWorkout.js +2 -1
- package/lib/commonjs/SMWorkout.js.map +1 -1
- package/lib/commonjs/index.js +54 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/SMWorkout.js +2 -1
- package/lib/module/SMWorkout.js.map +1 -1
- package/lib/module/index.js +54 -3
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/SMWorkout.d.ts +342 -0
- package/lib/typescript/SMWorkout.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +218 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/package.json +5 -2
- package/react-native-smkit-ui.podspec +4 -2
- package/src/SMWorkout.tsx +2 -0
- package/src/index.tsx +79 -3
|
@@ -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
|
-
|
|
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", "=
|
|
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
|
-
|
|
28
|
-
|
|
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
|
/**
|