@use-voltra/expo-plugin 1.4.0 → 2.0.0-rc.1
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 -29
- package/build/cjs/constants.js +3 -43
- package/build/cjs/constants.js.map +1 -1
- package/build/cjs/index.js +23 -69
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/types.js +4 -0
- package/build/cjs/types.js.map +1 -1
- package/build/cjs/utils/localePick.js +48 -0
- package/build/cjs/utils/localePick.js.map +1 -0
- package/build/cjs/utils/prerender.js +15 -9
- package/build/cjs/utils/prerender.js.map +1 -1
- package/build/cjs/utils/widgetLabel.js +19 -0
- package/build/cjs/utils/widgetLabel.js.map +1 -0
- package/build/cjs/validation.js +75 -166
- package/build/cjs/validation.js.map +1 -1
- package/build/esm/constants.js +2 -42
- package/build/esm/constants.js.map +1 -1
- package/build/esm/index.js +8 -69
- package/build/esm/index.js.map +1 -1
- package/build/esm/types.js +4 -0
- package/build/esm/types.js.map +1 -1
- package/build/esm/utils/localePick.js +44 -0
- package/build/esm/utils/localePick.js.map +1 -0
- package/build/esm/utils/prerender.js +15 -9
- package/build/esm/utils/prerender.js.map +1 -1
- package/build/esm/utils/widgetLabel.js +15 -0
- package/build/esm/utils/widgetLabel.js.map +1 -0
- package/build/esm/validation.js +71 -163
- package/build/esm/validation.js.map +1 -1
- package/build/types/constants.d.ts +2 -26
- package/build/types/constants.d.ts.map +1 -1
- package/build/types/index.d.ts +10 -12
- package/build/types/index.d.ts.map +1 -1
- package/build/types/types.d.ts +9 -260
- package/build/types/types.d.ts.map +1 -1
- package/build/types/utils/localePick.d.ts +7 -0
- package/build/types/utils/localePick.d.ts.map +1 -0
- package/build/types/utils/prerender.d.ts +6 -3
- package/build/types/utils/prerender.d.ts.map +1 -1
- package/build/types/utils/widgetLabel.d.ts +8 -0
- package/build/types/utils/widgetLabel.d.ts.map +1 -0
- package/build/types/validation.d.ts +6 -14
- package/build/types/validation.d.ts.map +1 -1
- package/package.json +11 -11
- package/build/cjs/android/files/assets.js +0 -259
- package/build/cjs/android/files/assets.js.map +0 -1
- package/build/cjs/android/files/fonts.js +0 -69
- package/build/cjs/android/files/fonts.js.map +0 -1
- package/build/cjs/android/files/index.js +0 -81
- package/build/cjs/android/files/index.js.map +0 -1
- package/build/cjs/android/files/initialStates.js +0 -83
- package/build/cjs/android/files/initialStates.js.map +0 -1
- package/build/cjs/android/files/kotlin.js +0 -142
- package/build/cjs/android/files/kotlin.js.map +0 -1
- package/build/cjs/android/files/xml.js +0 -247
- package/build/cjs/android/files/xml.js.map +0 -1
- package/build/cjs/android/index.js +0 -33
- package/build/cjs/android/index.js.map +0 -1
- package/build/cjs/android/manifest.js +0 -92
- package/build/cjs/android/manifest.js.map +0 -1
- package/build/cjs/ios/eas.js +0 -28
- package/build/cjs/ios/eas.js.map +0 -1
- package/build/cjs/ios/entitlements.js +0 -46
- package/build/cjs/ios/entitlements.js.map +0 -1
- package/build/cjs/ios/index.js +0 -39
- package/build/cjs/ios/index.js.map +0 -1
- package/build/cjs/ios/infoPlist.js +0 -51
- package/build/cjs/ios/infoPlist.js.map +0 -1
- package/build/cjs/ios/pushNotifications.js +0 -22
- package/build/cjs/ios/pushNotifications.js.map +0 -1
- package/build/cjs/ios-widget/eas.js +0 -66
- package/build/cjs/ios-widget/eas.js.map +0 -1
- package/build/cjs/ios-widget/files/assets.js +0 -199
- package/build/cjs/ios-widget/files/assets.js.map +0 -1
- package/build/cjs/ios-widget/files/entitlements.js +0 -77
- package/build/cjs/ios-widget/files/entitlements.js.map +0 -1
- package/build/cjs/ios-widget/files/index.js +0 -92
- package/build/cjs/ios-widget/files/index.js.map +0 -1
- package/build/cjs/ios-widget/files/infoPlist.js +0 -91
- package/build/cjs/ios-widget/files/infoPlist.js.map +0 -1
- package/build/cjs/ios-widget/files/swift.js +0 -256
- package/build/cjs/ios-widget/files/swift.js.map +0 -1
- package/build/cjs/ios-widget/fonts.js +0 -151
- package/build/cjs/ios-widget/fonts.js.map +0 -1
- package/build/cjs/ios-widget/index.js +0 -46
- package/build/cjs/ios-widget/index.js.map +0 -1
- package/build/cjs/ios-widget/podfile.js +0 -43
- package/build/cjs/ios-widget/podfile.js.map +0 -1
- package/build/cjs/ios-widget/widgetPlist.js +0 -99
- package/build/cjs/ios-widget/widgetPlist.js.map +0 -1
- package/build/cjs/ios-widget/xcode/buildPhases.js +0 -245
- package/build/cjs/ios-widget/xcode/buildPhases.js.map +0 -1
- package/build/cjs/ios-widget/xcode/configurationList.js +0 -91
- package/build/cjs/ios-widget/xcode/configurationList.js.map +0 -1
- package/build/cjs/ios-widget/xcode/groups.js +0 -65
- package/build/cjs/ios-widget/xcode/groups.js.map +0 -1
- package/build/cjs/ios-widget/xcode/index.js +0 -155
- package/build/cjs/ios-widget/xcode/index.js.map +0 -1
- package/build/cjs/ios-widget/xcode/mainAppSettings.js +0 -71
- package/build/cjs/ios-widget/xcode/mainAppSettings.js.map +0 -1
- package/build/cjs/ios-widget/xcode/productFile.js +0 -74
- package/build/cjs/ios-widget/xcode/productFile.js.map +0 -1
- package/build/cjs/ios-widget/xcode/target.js +0 -113
- package/build/cjs/ios-widget/xcode/target.js.map +0 -1
- package/build/cjs/utils/fileDiscovery.js +0 -107
- package/build/cjs/utils/fileDiscovery.js.map +0 -1
- package/build/cjs/utils/urlScheme.js +0 -40
- package/build/cjs/utils/urlScheme.js.map +0 -1
- package/build/esm/android/files/assets.js +0 -223
- package/build/esm/android/files/assets.js.map +0 -1
- package/build/esm/android/files/fonts.js +0 -33
- package/build/esm/android/files/fonts.js.map +0 -1
- package/build/esm/android/files/index.js +0 -77
- package/build/esm/android/files/index.js.map +0 -1
- package/build/esm/android/files/initialStates.js +0 -44
- package/build/esm/android/files/initialStates.js.map +0 -1
- package/build/esm/android/files/kotlin.js +0 -103
- package/build/esm/android/files/kotlin.js.map +0 -1
- package/build/esm/android/files/xml.js +0 -206
- package/build/esm/android/files/xml.js.map +0 -1
- package/build/esm/android/index.js +0 -29
- package/build/esm/android/index.js.map +0 -1
- package/build/esm/android/manifest.js +0 -88
- package/build/esm/android/manifest.js.map +0 -1
- package/build/esm/ios/eas.js +0 -24
- package/build/esm/ios/eas.js.map +0 -1
- package/build/esm/ios/entitlements.js +0 -42
- package/build/esm/ios/entitlements.js.map +0 -1
- package/build/esm/ios/index.js +0 -34
- package/build/esm/ios/index.js.map +0 -1
- package/build/esm/ios/infoPlist.js +0 -47
- package/build/esm/ios/infoPlist.js.map +0 -1
- package/build/esm/ios/pushNotifications.js +0 -18
- package/build/esm/ios/pushNotifications.js.map +0 -1
- package/build/esm/ios-widget/eas.js +0 -62
- package/build/esm/ios-widget/eas.js.map +0 -1
- package/build/esm/ios-widget/files/assets.js +0 -163
- package/build/esm/ios-widget/files/assets.js.map +0 -1
- package/build/esm/ios-widget/files/entitlements.js +0 -37
- package/build/esm/ios-widget/files/entitlements.js.map +0 -1
- package/build/esm/ios-widget/files/index.js +0 -55
- package/build/esm/ios-widget/files/index.js.map +0 -1
- package/build/esm/ios-widget/files/infoPlist.js +0 -55
- package/build/esm/ios-widget/files/infoPlist.js.map +0 -1
- package/build/esm/ios-widget/files/swift.js +0 -217
- package/build/esm/ios-widget/files/swift.js.map +0 -1
- package/build/esm/ios-widget/fonts.js +0 -111
- package/build/esm/ios-widget/fonts.js.map +0 -1
- package/build/esm/ios-widget/index.js +0 -42
- package/build/esm/ios-widget/index.js.map +0 -1
- package/build/esm/ios-widget/podfile.js +0 -39
- package/build/esm/ios-widget/podfile.js.map +0 -1
- package/build/esm/ios-widget/widgetPlist.js +0 -92
- package/build/esm/ios-widget/widgetPlist.js.map +0 -1
- package/build/esm/ios-widget/xcode/buildPhases.js +0 -208
- package/build/esm/ios-widget/xcode/buildPhases.js.map +0 -1
- package/build/esm/ios-widget/xcode/configurationList.js +0 -87
- package/build/esm/ios-widget/xcode/configurationList.js.map +0 -1
- package/build/esm/ios-widget/xcode/groups.js +0 -61
- package/build/esm/ios-widget/xcode/groups.js.map +0 -1
- package/build/esm/ios-widget/xcode/index.js +0 -118
- package/build/esm/ios-widget/xcode/index.js.map +0 -1
- package/build/esm/ios-widget/xcode/mainAppSettings.js +0 -68
- package/build/esm/ios-widget/xcode/mainAppSettings.js.map +0 -1
- package/build/esm/ios-widget/xcode/productFile.js +0 -70
- package/build/esm/ios-widget/xcode/productFile.js.map +0 -1
- package/build/esm/ios-widget/xcode/target.js +0 -108
- package/build/esm/ios-widget/xcode/target.js.map +0 -1
- package/build/esm/utils/fileDiscovery.js +0 -71
- package/build/esm/utils/fileDiscovery.js.map +0 -1
- package/build/esm/utils/urlScheme.js +0 -37
- package/build/esm/utils/urlScheme.js.map +0 -1
- package/build/types/android/files/assets.d.ts +0 -26
- package/build/types/android/files/assets.d.ts.map +0 -1
- package/build/types/android/files/fonts.d.ts +0 -19
- package/build/types/android/files/fonts.d.ts.map +0 -1
- package/build/types/android/files/index.d.ts +0 -21
- package/build/types/android/files/index.d.ts.map +0 -1
- package/build/types/android/files/initialStates.d.ts +0 -14
- package/build/types/android/files/initialStates.d.ts.map +0 -1
- package/build/types/android/files/kotlin.d.ts +0 -11
- package/build/types/android/files/kotlin.d.ts.map +0 -1
- package/build/types/android/files/xml.d.ts +0 -25
- package/build/types/android/files/xml.d.ts.map +0 -1
- package/build/types/android/index.d.ts +0 -12
- package/build/types/android/index.d.ts.map +0 -1
- package/build/types/android/manifest.d.ts +0 -16
- package/build/types/android/manifest.d.ts.map +0 -1
- package/build/types/ios/eas.d.ts +0 -12
- package/build/types/ios/eas.d.ts.map +0 -1
- package/build/types/ios/entitlements.d.ts +0 -14
- package/build/types/ios/entitlements.d.ts.map +0 -1
- package/build/types/ios/index.d.ts +0 -19
- package/build/types/ios/index.d.ts.map +0 -1
- package/build/types/ios/infoPlist.d.ts +0 -21
- package/build/types/ios/infoPlist.d.ts.map +0 -1
- package/build/types/ios/pushNotifications.d.ts +0 -10
- package/build/types/ios/pushNotifications.d.ts.map +0 -1
- package/build/types/ios-widget/eas.d.ts +0 -15
- package/build/types/ios-widget/eas.d.ts.map +0 -1
- package/build/types/ios-widget/files/assets.d.ts +0 -13
- package/build/types/ios-widget/files/assets.d.ts.map +0 -1
- package/build/types/ios-widget/files/entitlements.d.ts +0 -17
- package/build/types/ios-widget/files/entitlements.d.ts.map +0 -1
- package/build/types/ios-widget/files/index.d.ts +0 -24
- package/build/types/ios-widget/files/index.d.ts.map +0 -1
- package/build/types/ios-widget/files/infoPlist.d.ts +0 -10
- package/build/types/ios-widget/files/infoPlist.d.ts.map +0 -1
- package/build/types/ios-widget/files/swift.d.ts +0 -15
- package/build/types/ios-widget/files/swift.d.ts.map +0 -1
- package/build/types/ios-widget/fonts.d.ts +0 -22
- package/build/types/ios-widget/fonts.d.ts.map +0 -1
- package/build/types/ios-widget/index.d.ts +0 -31
- package/build/types/ios-widget/index.d.ts.map +0 -1
- package/build/types/ios-widget/podfile.d.ts +0 -9
- package/build/types/ios-widget/podfile.d.ts.map +0 -1
- package/build/types/ios-widget/widgetPlist.d.ts +0 -20
- package/build/types/ios-widget/widgetPlist.d.ts.map +0 -1
- package/build/types/ios-widget/xcode/buildPhases.d.ts +0 -25
- package/build/types/ios-widget/xcode/buildPhases.d.ts.map +0 -1
- package/build/types/ios-widget/xcode/configurationList.d.ts +0 -20
- package/build/types/ios-widget/xcode/configurationList.d.ts.map +0 -1
- package/build/types/ios-widget/xcode/groups.d.ts +0 -15
- package/build/types/ios-widget/xcode/groups.d.ts.map +0 -1
- package/build/types/ios-widget/xcode/index.d.ts +0 -20
- package/build/types/ios-widget/xcode/index.d.ts.map +0 -1
- package/build/types/ios-widget/xcode/mainAppSettings.d.ts +0 -15
- package/build/types/ios-widget/xcode/mainAppSettings.d.ts.map +0 -1
- package/build/types/ios-widget/xcode/productFile.d.ts +0 -14
- package/build/types/ios-widget/xcode/productFile.d.ts.map +0 -1
- package/build/types/ios-widget/xcode/target.d.ts +0 -42
- package/build/types/ios-widget/xcode/target.d.ts.map +0 -1
- package/build/types/utils/fileDiscovery.d.ts +0 -13
- package/build/types/utils/fileDiscovery.d.ts.map +0 -1
- package/build/types/utils/urlScheme.d.ts +0 -10
- package/build/types/utils/urlScheme.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widgetLabel.js","sourceRoot":"","sources":["../../../src/utils/widgetLabel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEjD,MAAM,UAAU,oBAAoB,CAAC,KAAkB;IACrD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAkB;IACnD,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,kBAAkB,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAA;AAChD,CAAC"}
|
package/build/esm/validation.js
CHANGED
|
@@ -1,196 +1,104 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
|
+
/** Widget id: Swift / Kotlin identifier fragment and Android XML token fragment */
|
|
4
|
+
const WIDGET_ID_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
6
|
+
* Locale keys in app.json become iOS `.lproj` folder names and Android `values-*` qualifiers (after mapping).
|
|
5
7
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
'systemSmall',
|
|
11
|
-
'systemMedium',
|
|
12
|
-
'systemLarge',
|
|
13
|
-
'systemExtraLarge',
|
|
14
|
-
'accessoryCircular',
|
|
15
|
-
'accessoryRectangular',
|
|
16
|
-
'accessoryInline',
|
|
17
|
-
]);
|
|
18
|
-
/**
|
|
19
|
-
* Validates a widget configuration.
|
|
20
|
-
* Throws an error if validation fails.
|
|
21
|
-
*/
|
|
22
|
-
export function validateWidgetConfig(widget) {
|
|
23
|
-
// Validate widget ID
|
|
24
|
-
if (!widget.id || typeof widget.id !== 'string') {
|
|
8
|
+
const LOCALE_KEY_PATTERN = /^[a-zA-Z][a-zA-Z0-9]*([_-][a-zA-Z0-9]+)*$/;
|
|
9
|
+
const MAX_LOCALE_KEY_LENGTH = 32;
|
|
10
|
+
export function validateHomeScreenWidgetId(widgetId) {
|
|
11
|
+
if (!widgetId || typeof widgetId !== 'string') {
|
|
25
12
|
throw new Error('Widget ID is required and must be a string');
|
|
26
13
|
}
|
|
27
|
-
if (
|
|
28
|
-
throw new Error(`Widget ID '${
|
|
14
|
+
if (!WIDGET_ID_PATTERN.test(widgetId)) {
|
|
15
|
+
throw new Error(`Widget ID '${widgetId}' is invalid. ` +
|
|
29
16
|
'Must start with a letter or underscore and contain only alphanumeric characters and underscores.');
|
|
30
17
|
}
|
|
31
|
-
// Validate display name
|
|
32
|
-
if (!widget.displayName?.trim()) {
|
|
33
|
-
throw new Error(`Widget '${widget.id}': displayName is required`);
|
|
34
|
-
}
|
|
35
|
-
// Validate description
|
|
36
|
-
if (!widget.description?.trim()) {
|
|
37
|
-
throw new Error(`Widget '${widget.id}': description is required`);
|
|
38
|
-
}
|
|
39
|
-
// Validate supported families if provided
|
|
40
|
-
if (widget.supportedFamilies) {
|
|
41
|
-
if (!Array.isArray(widget.supportedFamilies)) {
|
|
42
|
-
throw new Error(`Widget '${widget.id}': supportedFamilies must be an array`);
|
|
43
|
-
}
|
|
44
|
-
for (const family of widget.supportedFamilies) {
|
|
45
|
-
if (!VALID_FAMILIES.has(family)) {
|
|
46
|
-
throw new Error(`Widget '${widget.id}': Invalid widget family '${family}'. ` +
|
|
47
|
-
`Valid families are: ${Array.from(VALID_FAMILIES).join(', ')}`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
18
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Validates an Android widget configuration.
|
|
57
|
-
* Throws an error if validation fails.
|
|
58
|
-
*/
|
|
59
|
-
export function validateAndroidWidgetConfig(widget, projectRoot) {
|
|
60
|
-
// Validate widget ID
|
|
61
|
-
if (!widget.id || typeof widget.id !== 'string') {
|
|
62
|
-
throw new Error('Widget ID is required and must be a string');
|
|
63
|
-
}
|
|
64
|
-
if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(widget.id)) {
|
|
65
|
-
throw new Error(`Widget ID '${widget.id}' is invalid. ` +
|
|
66
|
-
'Must start with a letter or underscore and contain only alphanumeric characters and underscores.');
|
|
67
|
-
}
|
|
68
|
-
// Validate display name
|
|
69
|
-
if (!widget.displayName?.trim()) {
|
|
70
|
-
throw new Error(`Widget '${widget.id}': displayName is required`);
|
|
71
|
-
}
|
|
72
|
-
// Validate description
|
|
73
|
-
if (!widget.description?.trim()) {
|
|
74
|
-
throw new Error(`Widget '${widget.id}': description is required`);
|
|
19
|
+
export function assertValidLocaleKey(localeKey, widgetId, fieldName) {
|
|
20
|
+
if (localeKey.trim() !== localeKey) {
|
|
21
|
+
throw new Error(`Widget '${widgetId}': ${fieldName} locale key '${localeKey}' must not have leading or trailing whitespace`);
|
|
75
22
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
throw new Error(`Widget '${widget.id}': targetCellWidth is required and must be a number`);
|
|
23
|
+
if (!localeKey) {
|
|
24
|
+
throw new Error(`Widget '${widgetId}': ${fieldName} locale map contains an empty locale key`);
|
|
79
25
|
}
|
|
80
|
-
if (
|
|
81
|
-
throw new Error(`Widget '${
|
|
26
|
+
if (localeKey.length > MAX_LOCALE_KEY_LENGTH) {
|
|
27
|
+
throw new Error(`Widget '${widgetId}': ${fieldName} locale key '${localeKey}' exceeds ${MAX_LOCALE_KEY_LENGTH} characters`);
|
|
82
28
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
29
|
+
if (!LOCALE_KEY_PATTERN.test(localeKey)) {
|
|
30
|
+
throw new Error(`Widget '${widgetId}': ${fieldName} locale key '${localeKey}' is invalid. ` +
|
|
31
|
+
'Use BCP-47-style tags (e.g. en, pl, pt-BR, zh-Hans). Letters, digits, single separators _ or - only.');
|
|
86
32
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (typeof widget.minCellWidth !== 'number' || !Number.isInteger(widget.minCellWidth) || widget.minCellWidth < 1) {
|
|
93
|
-
throw new Error(`Widget '${widget.id}': minCellWidth must be a positive integer`);
|
|
33
|
+
}
|
|
34
|
+
export function validateWidgetLabel(value, widgetId, fieldName) {
|
|
35
|
+
if (typeof value === 'string') {
|
|
36
|
+
if (!value.trim()) {
|
|
37
|
+
throw new Error(`Widget '${widgetId}': ${fieldName} is required`);
|
|
94
38
|
}
|
|
39
|
+
return;
|
|
95
40
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (typeof widget.minCellHeight !== 'number' ||
|
|
99
|
-
!Number.isInteger(widget.minCellHeight) ||
|
|
100
|
-
widget.minCellHeight < 1) {
|
|
101
|
-
throw new Error(`Widget '${widget.id}': minCellHeight must be a positive integer`);
|
|
102
|
-
}
|
|
41
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
42
|
+
throw new Error(`Widget '${widgetId}': ${fieldName} must be a string or a locale map (e.g. { "en": "...", "pl": "..." })`);
|
|
103
43
|
}
|
|
104
|
-
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
throw new Error(`Widget '${widget.id}': previewImage must be a non-empty string`);
|
|
108
|
-
}
|
|
109
|
-
const ext = path.extname(widget.previewImage).toLowerCase();
|
|
110
|
-
const validImageExts = ['.png', '.jpg', '.jpeg', '.webp'];
|
|
111
|
-
if (!validImageExts.includes(ext)) {
|
|
112
|
-
throw new Error(`Widget '${widget.id}': previewImage must be a PNG, JPG, JPEG, or WebP file. Got: ${ext}`);
|
|
113
|
-
}
|
|
114
|
-
// Check file exists if projectRoot is provided
|
|
115
|
-
if (projectRoot) {
|
|
116
|
-
const fullPath = path.join(projectRoot, widget.previewImage);
|
|
117
|
-
if (!fs.existsSync(fullPath)) {
|
|
118
|
-
throw new Error(`Widget '${widget.id}': previewImage file not found at ${widget.previewImage}`);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
44
|
+
const entries = Object.entries(value);
|
|
45
|
+
if (entries.length === 0) {
|
|
46
|
+
throw new Error(`Widget '${widgetId}': ${fieldName} locale map must not be empty`);
|
|
121
47
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
48
|
+
const localeKeys = new Set();
|
|
49
|
+
for (const [locale, v] of entries) {
|
|
50
|
+
assertValidLocaleKey(locale, widgetId, fieldName);
|
|
51
|
+
const normalized = locale.toLowerCase().replace(/_/g, '-');
|
|
52
|
+
if (localeKeys.has(normalized)) {
|
|
53
|
+
throw new Error(`Widget '${widgetId}': ${fieldName} duplicates locale '${locale}' (underscore and hyphen forms count as the same, e.g. pt_BR vs pt-BR)`);
|
|
126
54
|
}
|
|
127
|
-
|
|
128
|
-
if (
|
|
129
|
-
throw new Error(`Widget '${
|
|
130
|
-
}
|
|
131
|
-
// Check file exists if projectRoot is provided
|
|
132
|
-
if (projectRoot) {
|
|
133
|
-
const fullPath = path.join(projectRoot, widget.previewLayout);
|
|
134
|
-
if (!fs.existsSync(fullPath)) {
|
|
135
|
-
throw new Error(`Widget '${widget.id}': previewLayout file not found at ${widget.previewLayout}`);
|
|
136
|
-
}
|
|
55
|
+
localeKeys.add(normalized);
|
|
56
|
+
if (typeof v !== 'string' || !v.trim()) {
|
|
57
|
+
throw new Error(`Widget '${widgetId}': ${fieldName}.${locale} must be a non-empty string`);
|
|
137
58
|
}
|
|
138
59
|
}
|
|
139
60
|
}
|
|
140
|
-
// ============================================================================
|
|
141
|
-
// Plugin Props Validation
|
|
142
|
-
// ============================================================================
|
|
143
61
|
/**
|
|
144
|
-
* Validates
|
|
145
|
-
* Throws an error if validation fails.
|
|
62
|
+
* Validates optional initialStatePath: plain string or locale map of project-relative file paths.
|
|
146
63
|
*/
|
|
147
|
-
export function
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (typeof props.groupIdentifier !== 'string') {
|
|
151
|
-
throw new Error('groupIdentifier must be a string');
|
|
152
|
-
}
|
|
153
|
-
if (!props.groupIdentifier.startsWith('group.')) {
|
|
154
|
-
throw new Error(`groupIdentifier '${props.groupIdentifier}' must start with 'group.'`);
|
|
155
|
-
}
|
|
64
|
+
export function validateInitialStatePath(value, widgetId, projectRoot) {
|
|
65
|
+
if (value === undefined) {
|
|
66
|
+
return;
|
|
156
67
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
throw new Error('widgets must be an array');
|
|
68
|
+
const assertPathExists = (relativePath, ctx) => {
|
|
69
|
+
if (!relativePath.trim()) {
|
|
70
|
+
throw new Error(`Widget '${widgetId}': initialStatePath ${ctx} must be a non-empty path`);
|
|
161
71
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (seenIds.has(widget.id)) {
|
|
167
|
-
throw new Error(`Duplicate widget ID: '${widget.id}'`);
|
|
72
|
+
if (projectRoot) {
|
|
73
|
+
const fullPath = path.join(projectRoot, relativePath);
|
|
74
|
+
if (!fs.existsSync(fullPath)) {
|
|
75
|
+
throw new Error(`Widget '${widgetId}': initialStatePath file not found at ${relativePath}`);
|
|
168
76
|
}
|
|
169
|
-
seenIds.add(widget.id);
|
|
170
77
|
}
|
|
78
|
+
};
|
|
79
|
+
if (typeof value === 'string') {
|
|
80
|
+
assertPathExists(value, '');
|
|
81
|
+
return;
|
|
171
82
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
83
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
84
|
+
throw new Error(`Widget '${widgetId}': initialStatePath must be a string or a locale map of paths (e.g. { "en": "./widgets/en.tsx", "pl": "./widgets/pl.tsx" })`);
|
|
85
|
+
}
|
|
86
|
+
const entries = Object.entries(value);
|
|
87
|
+
if (entries.length === 0) {
|
|
88
|
+
throw new Error(`Widget '${widgetId}': initialStatePath locale map must not be empty`);
|
|
89
|
+
}
|
|
90
|
+
const localeKeys = new Set();
|
|
91
|
+
for (const [locale, v] of entries) {
|
|
92
|
+
assertValidLocaleKey(locale, widgetId, 'initialStatePath');
|
|
93
|
+
const normalized = locale.toLowerCase().replace(/_/g, '-');
|
|
94
|
+
if (localeKeys.has(normalized)) {
|
|
95
|
+
throw new Error(`Widget '${widgetId}': initialStatePath duplicates locale '${locale}' (underscore and hyphen forms count as the same)`);
|
|
179
96
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
// Check for duplicate widget IDs
|
|
185
|
-
const seenIds = new Set();
|
|
186
|
-
for (const widget of props.android.widgets) {
|
|
187
|
-
validateAndroidWidgetConfig(widget);
|
|
188
|
-
if (seenIds.has(widget.id)) {
|
|
189
|
-
throw new Error(`Duplicate Android widget ID: '${widget.id}'`);
|
|
190
|
-
}
|
|
191
|
-
seenIds.add(widget.id);
|
|
192
|
-
}
|
|
97
|
+
localeKeys.add(normalized);
|
|
98
|
+
if (typeof v !== 'string' || !v.trim()) {
|
|
99
|
+
throw new Error(`Widget '${widgetId}': initialStatePath.${locale} must be a non-empty path string`);
|
|
193
100
|
}
|
|
101
|
+
assertPathExists(v, `.${locale}`);
|
|
194
102
|
}
|
|
195
103
|
}
|
|
196
104
|
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,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E,MAAM,IAAI,KAAK,CACb,WAAW,QAAQ,6HAA6H,CACjJ,CAAA;IACH,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,CAAA;IAChE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,WAAW,QAAQ,kDAAkD,CAAC,CAAA;IACxF,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAA;IACpC,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC;QAClC,oBAAoB,CAAC,MAAM,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAA;QAE1D,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QAC1D,IAAI,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CACb,WAAW,QAAQ,0CAA0C,MAAM,mDAAmD,CACvH,CAAA;QACH,CAAC;QACD,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QAE1B,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,WAAW,QAAQ,uBAAuB,MAAM,kCAAkC,CAAC,CAAA;QACrG,CAAC;QACD,gBAAgB,CAAC,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC,CAAA;IACnC,CAAC;AACH,CAAC"}
|
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
import type { WidgetFamily } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Constants for the Voltra plugin
|
|
4
|
-
*/
|
|
5
|
-
export declare const IOS: {
|
|
6
|
-
/** Minimum iOS deployment target version */
|
|
7
|
-
readonly DEPLOYMENT_TARGET: "17.0";
|
|
8
|
-
/** Swift language version */
|
|
9
|
-
readonly SWIFT_VERSION: "5.0";
|
|
10
|
-
/** Target device families (1 = iPhone, 2 = iPad) */
|
|
11
|
-
readonly DEVICE_FAMILY: "1,2";
|
|
12
|
-
/** Last Swift migration version for Xcode */
|
|
13
|
-
readonly LAST_SWIFT_MIGRATION: 1250;
|
|
14
|
-
};
|
|
15
|
-
/** Default path for user-provided widget images */
|
|
16
|
-
export declare const DEFAULT_USER_IMAGES_PATH = "./assets/voltra";
|
|
17
|
-
/** Default path for user-provided Android widget images */
|
|
18
|
-
export declare const DEFAULT_ANDROID_USER_IMAGES_PATH = "./assets/voltra-android";
|
|
19
|
-
/** Maximum image size in bytes for Live Activities (4KB limit) */
|
|
20
|
-
export declare const MAX_IMAGE_SIZE_BYTES = 4096;
|
|
21
|
-
/** Supported image extensions for widget assets */
|
|
22
|
-
export declare const SUPPORTED_IMAGE_EXTENSIONS: RegExp;
|
|
23
|
-
/** Default widget families when not specified */
|
|
24
|
-
export declare const DEFAULT_WIDGET_FAMILIES: WidgetFamily[];
|
|
25
|
-
/** Maps JS widget family names to SwiftUI WidgetFamily enum cases */
|
|
26
|
-
export declare const WIDGET_FAMILY_MAP: Record<WidgetFamily, string>;
|
|
27
1
|
/** Extensions to try when resolving module paths for pre-rendering */
|
|
28
2
|
export declare const MODULE_EXTENSIONS: string[];
|
|
3
|
+
/** Maximum image size in bytes for widget / Live Activity assets (4KB limit) */
|
|
4
|
+
export declare const MAX_IMAGE_SIZE_BYTES = 4096;
|
|
29
5
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,UAAqC,CAAA;AAEnE,gFAAgF;AAChF,eAAO,MAAM,oBAAoB,OAAO,CAAA"}
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export default withVoltra;
|
|
12
|
-
export type { AndroidPluginConfig, AndroidWidgetConfig, AndroidWidgetServerUpdateConfig, ConfigPluginProps, VoltraConfigPlugin, WidgetConfig, WidgetFamily, WidgetServerUpdateConfig, } from './types';
|
|
1
|
+
export { MAX_IMAGE_SIZE_BYTES, MODULE_EXTENSIONS } from './constants';
|
|
2
|
+
export type { WidgetInitialStatePath, WidgetLabel, WidgetLocalizedCopy } from './types';
|
|
3
|
+
export { assertValidLocaleKey, validateHomeScreenWidgetId, validateInitialStatePath, validateWidgetLabel, } from './validation';
|
|
4
|
+
export { addApplicationGroupsEntitlement } from './utils/entitlements';
|
|
5
|
+
export { resolveFontPaths } from './utils/fonts';
|
|
6
|
+
export { normalizeLocaleTag, pickLocalizedValue } from './utils/localePick';
|
|
7
|
+
export { logger } from './utils/logger';
|
|
8
|
+
export type { PrerenderableWidget, PrerenderedWidgetStates, WidgetRenderer } from './utils/prerender';
|
|
9
|
+
export { prerenderWidgetState } from './utils/prerender';
|
|
10
|
+
export { isWidgetLocalizedMap, widgetLabelEnglish } from './utils/widgetLabel';
|
|
13
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACrE,YAAY,EAAE,sBAAsB,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AACvF,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,YAAY,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACrG,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA"}
|