@use-voltra/expo-plugin 1.4.1 → 2.0.0-rc.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.
- 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
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMainAppTargetSettings = getMainAppTargetSettings;
|
|
4
|
-
/**
|
|
5
|
-
* Reads build settings from the main app target to synchronize code signing with the widget extension.
|
|
6
|
-
*
|
|
7
|
-
* @param xcodeProject The Xcode project instance
|
|
8
|
-
* @returns The main app target's build settings, or null if not found
|
|
9
|
-
*/
|
|
10
|
-
function getMainAppTargetSettings(xcodeProject) {
|
|
11
|
-
try {
|
|
12
|
-
const mainAppTarget = xcodeProject.getFirstTarget()?.firstTarget;
|
|
13
|
-
if (!mainAppTarget) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
// Get the build configuration list for the main app target
|
|
17
|
-
const buildConfigurationListId = mainAppTarget.buildConfigurationList;
|
|
18
|
-
if (!buildConfigurationListId) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
// Extract UUID from buildConfigurationListId (it might include a comment like "UUID /* comment */")
|
|
22
|
-
const buildConfigurationListUuid = buildConfigurationListId.split(' ')[0];
|
|
23
|
-
const buildConfigurationList = xcodeProject.hash.project.objects['XCConfigurationList']?.[buildConfigurationListUuid];
|
|
24
|
-
if (!buildConfigurationList || !buildConfigurationList.buildConfigurations) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
// Get the first build configuration (usually Debug) to read settings
|
|
28
|
-
const firstConfigRef = buildConfigurationList.buildConfigurations[0];
|
|
29
|
-
if (!firstConfigRef) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
// Extract UUID from config reference (it might include a comment)
|
|
33
|
-
const firstConfigUuid = typeof firstConfigRef === 'string' ? firstConfigRef.split(' ')[0] : firstConfigRef.value?.split(' ')[0];
|
|
34
|
-
if (!firstConfigUuid) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
const buildConfiguration = xcodeProject.hash.project.objects['XCBuildConfiguration']?.[firstConfigUuid];
|
|
38
|
-
if (!buildConfiguration || !buildConfiguration.buildSettings) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
const buildSettings = buildConfiguration.buildSettings;
|
|
42
|
-
// Extract deployment target (remove quotes if present)
|
|
43
|
-
const deploymentTarget = buildSettings.IPHONEOS_DEPLOYMENT_TARGET?.replace(/^"|"$/g, '') ||
|
|
44
|
-
buildSettings['IPHONEOS_DEPLOYMENT_TARGET']?.replace(/^"|"$/g, '') ||
|
|
45
|
-
null;
|
|
46
|
-
// Extract code signing settings
|
|
47
|
-
const codeSignStyle = buildSettings.CODE_SIGN_STYLE?.replace(/^"|"$/g, '') ||
|
|
48
|
-
buildSettings['CODE_SIGN_STYLE']?.replace(/^"|"$/g, '') ||
|
|
49
|
-
null;
|
|
50
|
-
const developmentTeam = buildSettings.DEVELOPMENT_TEAM?.replace(/^"|"$/g, '') ||
|
|
51
|
-
buildSettings['DEVELOPMENT_TEAM']?.replace(/^"|"$/g, '') ||
|
|
52
|
-
null;
|
|
53
|
-
const provisioningProfileSpecifier = buildSettings.PROVISIONING_PROFILE_SPECIFIER?.replace(/^"|"$/g, '') ||
|
|
54
|
-
buildSettings['PROVISIONING_PROFILE_SPECIFIER']?.replace(/^"|"$/g, '') ||
|
|
55
|
-
null;
|
|
56
|
-
if (!deploymentTarget) {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
deploymentTarget,
|
|
61
|
-
codeSignStyle: codeSignStyle || undefined,
|
|
62
|
-
developmentTeam: developmentTeam || undefined,
|
|
63
|
-
provisioningProfileSpecifier: provisioningProfileSpecifier || undefined,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
// If we can't read the settings, return null and use fallback values
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=mainAppSettings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mainAppSettings.js","sourceRoot":"","sources":["../../../../src/ios-widget/xcode/mainAppSettings.ts"],"names":[],"mappings":";;AAeA,4DA+EC;AArFD;;;;;GAKG;AACH,SAAgB,wBAAwB,CAAC,YAA0B;IACjE,IAAI,CAAC;QACH,MAAM,aAAa,GAAG,YAAY,CAAC,cAAc,EAAE,EAAE,WAAW,CAAA;QAEhE,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,OAAO,IAAI,CAAA;QACb,CAAC;QAED,2DAA2D;QAC3D,MAAM,wBAAwB,GAAG,aAAa,CAAC,sBAAsB,CAAA;QACrE,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAA;QACb,CAAC;QAED,oGAAoG;QACpG,MAAM,0BAA0B,GAAG,wBAAwB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QAEzE,MAAM,sBAAsB,GAC1B,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,qBAAqB,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAA;QACxF,IAAI,CAAC,sBAAsB,IAAI,CAAC,sBAAsB,CAAC,mBAAmB,EAAE,CAAC;YAC3E,OAAO,IAAI,CAAA;QACb,CAAC;QAED,qEAAqE;QACrE,MAAM,cAAc,GAAG,sBAAsB,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAA;QACpE,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO,IAAI,CAAA;QACb,CAAC;QAED,kEAAkE;QAClE,MAAM,eAAe,GACnB,OAAO,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,K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CAAC;QAED,OAAO;YACL,gBAAgB;YAChB,aAAa,EAAE,aAAa,IAAI,SAAS;YACzC,eAAe,EAAE,eAAe,IAAI,SAAS;YAC7C,4BAA4B,EAAE,4BAA4B,IAAI,SAAS;SACxE,CAAA;IACH,CAAC;IAAC,MAAM,CAAC;QACP,qEAAqE;QACrE,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.addProductFile = addProductFile;
|
|
4
|
-
exports.ensureProductFile = ensureProductFile;
|
|
5
|
-
function findProductFileReference(xcodeProject, targetName) {
|
|
6
|
-
const fileReferenceSection = xcodeProject.pbxFileReferenceSection();
|
|
7
|
-
const targetProductName = `${targetName}.appex`;
|
|
8
|
-
for (const key of Object.keys(fileReferenceSection)) {
|
|
9
|
-
if (/_comment$/.test(key)) {
|
|
10
|
-
continue;
|
|
11
|
-
}
|
|
12
|
-
const entry = fileReferenceSection[key];
|
|
13
|
-
const path = typeof entry?.path === 'string' ? entry.path.replace(/^"|"$/g, '') : '';
|
|
14
|
-
const name = typeof entry?.name === 'string' ? entry.name.replace(/^"|"$/g, '') : '';
|
|
15
|
-
if (path === targetProductName || name === targetProductName) {
|
|
16
|
-
return { fileRef: key };
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
function findBuildFileForFileRef(xcodeProject, fileRef) {
|
|
22
|
-
const buildFileSection = xcodeProject.pbxBuildFileSection();
|
|
23
|
-
for (const key of Object.keys(buildFileSection)) {
|
|
24
|
-
if (/_comment$/.test(key)) {
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
const entry = buildFileSection[key];
|
|
28
|
-
if (entry?.fileRef === fileRef) {
|
|
29
|
-
return { uuid: key };
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Adds the product file (.appex) for the widget extension.
|
|
36
|
-
*/
|
|
37
|
-
function addProductFile(xcodeProject, options) {
|
|
38
|
-
const { targetName, groupName } = options;
|
|
39
|
-
const productFileOptions = {
|
|
40
|
-
basename: `${targetName}.appex`,
|
|
41
|
-
group: groupName,
|
|
42
|
-
explicitFileType: 'wrapper.app-extension',
|
|
43
|
-
settings: {
|
|
44
|
-
ATTRIBUTES: ['RemoveHeadersOnCopy'],
|
|
45
|
-
},
|
|
46
|
-
includeInIndex: 0,
|
|
47
|
-
path: `${targetName}.appex`,
|
|
48
|
-
sourceTree: 'BUILT_PRODUCTS_DIR',
|
|
49
|
-
};
|
|
50
|
-
const productFile = xcodeProject.addProductFile(targetName, productFileOptions);
|
|
51
|
-
return productFile;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Ensures the product file (.appex) exists and returns it.
|
|
55
|
-
*/
|
|
56
|
-
function ensureProductFile(xcodeProject, options) {
|
|
57
|
-
const { targetName, groupName } = options;
|
|
58
|
-
const existingFile = findProductFileReference(xcodeProject, targetName);
|
|
59
|
-
if (!existingFile) {
|
|
60
|
-
return addProductFile(xcodeProject, options);
|
|
61
|
-
}
|
|
62
|
-
const buildFile = findBuildFileForFileRef(xcodeProject, existingFile.fileRef);
|
|
63
|
-
const productFile = {
|
|
64
|
-
uuid: buildFile?.uuid ?? xcodeProject.generateUuid(),
|
|
65
|
-
fileRef: existingFile.fileRef,
|
|
66
|
-
basename: `${targetName}.appex`,
|
|
67
|
-
group: groupName,
|
|
68
|
-
};
|
|
69
|
-
if (!buildFile) {
|
|
70
|
-
xcodeProject.addToPbxBuildFileSection(productFile);
|
|
71
|
-
}
|
|
72
|
-
return productFile;
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=productFile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"productFile.js","sourceRoot":"","sources":["../../../../src/ios-widget/xcode/productFile.ts"],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,EAAE,GAAG,UAAU,QAAQ;QAC/B,KAAK,EAAE,SAAS;KACjB,CAAA;IAED,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,YAAY,CAAC,wBAAwB,CAAC,WAAkB,CAAC,CAAA;IAC3D,CAAC;IAED,OAAO,WAAW,CAAA;AACpB,CAAC"}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.configureTarget = configureTarget;
|
|
4
|
-
exports.ensureTargetAttributes = ensureTargetAttributes;
|
|
5
|
-
exports.ensureTargetDependency = ensureTargetDependency;
|
|
6
|
-
const constants_1 = require("../../constants");
|
|
7
|
-
// ============================================================================
|
|
8
|
-
// Main Function
|
|
9
|
-
// ============================================================================
|
|
10
|
-
/**
|
|
11
|
-
* Configures the widget extension target in the Xcode project.
|
|
12
|
-
*
|
|
13
|
-
* This:
|
|
14
|
-
* - Adds the target to PBXNativeTarget section
|
|
15
|
-
* - Adds the target to PBXProject section
|
|
16
|
-
* - Adds a dependency from the main app to the widget extension
|
|
17
|
-
*/
|
|
18
|
-
function configureTarget(xcodeProject, options) {
|
|
19
|
-
const target = addToPbxNativeTargetSection(xcodeProject, options);
|
|
20
|
-
addToPbxProjectSection(xcodeProject, target);
|
|
21
|
-
addTargetDependency(xcodeProject, target);
|
|
22
|
-
return target;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Ensures target attributes (LastSwiftMigration) exist for the target.
|
|
26
|
-
*/
|
|
27
|
-
function ensureTargetAttributes(xcodeProject, targetUuid) {
|
|
28
|
-
const projectSection = xcodeProject.pbxProjectSection();
|
|
29
|
-
const firstProject = xcodeProject.getFirstProject();
|
|
30
|
-
if (!projectSection[firstProject.uuid].attributes.TargetAttributes) {
|
|
31
|
-
projectSection[firstProject.uuid].attributes.TargetAttributes = {};
|
|
32
|
-
}
|
|
33
|
-
if (!projectSection[firstProject.uuid].attributes.TargetAttributes[targetUuid]) {
|
|
34
|
-
projectSection[firstProject.uuid].attributes.TargetAttributes[targetUuid] = {
|
|
35
|
-
LastSwiftMigration: constants_1.IOS.LAST_SWIFT_MIGRATION,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Ensures a target dependency exists so the main app depends on the widget extension.
|
|
41
|
-
*/
|
|
42
|
-
function ensureTargetDependency(xcodeProject, targetUuid) {
|
|
43
|
-
if (!xcodeProject.hash.project.objects['PBXTargetDependency']) {
|
|
44
|
-
xcodeProject.hash.project.objects['PBXTargetDependency'] = {};
|
|
45
|
-
}
|
|
46
|
-
if (!xcodeProject.hash.project.objects['PBXContainerItemProxy']) {
|
|
47
|
-
xcodeProject.hash.project.objects['PBXContainerItemProxy'] = {};
|
|
48
|
-
}
|
|
49
|
-
const mainTargetUuid = xcodeProject.getFirstTarget().uuid;
|
|
50
|
-
const mainTarget = xcodeProject.pbxNativeTargetSection()[mainTargetUuid];
|
|
51
|
-
const existingDeps = mainTarget?.dependencies ?? [];
|
|
52
|
-
const targetDependencySection = xcodeProject.hash.project.objects['PBXTargetDependency'] || {};
|
|
53
|
-
const alreadyExists = existingDeps.some((dep) => {
|
|
54
|
-
const dependency = targetDependencySection[dep.value];
|
|
55
|
-
return dependency?.target === targetUuid;
|
|
56
|
-
});
|
|
57
|
-
if (!alreadyExists) {
|
|
58
|
-
xcodeProject.addTargetDependency(mainTargetUuid, [targetUuid]);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
// ============================================================================
|
|
62
|
-
// Helper Functions
|
|
63
|
-
// ============================================================================
|
|
64
|
-
/**
|
|
65
|
-
* Adds the widget extension target to the PBXNativeTarget section.
|
|
66
|
-
*/
|
|
67
|
-
function addToPbxNativeTargetSection(xcodeProject, options) {
|
|
68
|
-
const { targetName, targetUuid, productFile, xCConfigurationList } = options;
|
|
69
|
-
const target = {
|
|
70
|
-
uuid: targetUuid,
|
|
71
|
-
pbxNativeTarget: {
|
|
72
|
-
isa: 'PBXNativeTarget',
|
|
73
|
-
name: targetName,
|
|
74
|
-
productName: targetName,
|
|
75
|
-
productReference: productFile.fileRef,
|
|
76
|
-
productType: `"com.apple.product-type.app-extension"`,
|
|
77
|
-
buildConfigurationList: xCConfigurationList.uuid,
|
|
78
|
-
buildPhases: [],
|
|
79
|
-
buildRules: [],
|
|
80
|
-
dependencies: [],
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
xcodeProject.addToPbxNativeTargetSection(target);
|
|
84
|
-
return target;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Adds the target to the PBXProject section.
|
|
88
|
-
*/
|
|
89
|
-
function addToPbxProjectSection(xcodeProject, target) {
|
|
90
|
-
xcodeProject.addToPbxProjectSection(target);
|
|
91
|
-
// Add target attributes to project section
|
|
92
|
-
const projectSection = xcodeProject.pbxProjectSection();
|
|
93
|
-
const firstProject = xcodeProject.getFirstProject();
|
|
94
|
-
if (!projectSection[firstProject.uuid].attributes.TargetAttributes) {
|
|
95
|
-
projectSection[firstProject.uuid].attributes.TargetAttributes = {};
|
|
96
|
-
}
|
|
97
|
-
projectSection[firstProject.uuid].attributes.TargetAttributes[target.uuid] = {
|
|
98
|
-
LastSwiftMigration: constants_1.IOS.LAST_SWIFT_MIGRATION,
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Adds a target dependency so the main app depends on the widget extension.
|
|
103
|
-
*/
|
|
104
|
-
function addTargetDependency(xcodeProject, target) {
|
|
105
|
-
if (!xcodeProject.hash.project.objects['PBXTargetDependency']) {
|
|
106
|
-
xcodeProject.hash.project.objects['PBXTargetDependency'] = {};
|
|
107
|
-
}
|
|
108
|
-
if (!xcodeProject.hash.project.objects['PBXContainerItemProxy']) {
|
|
109
|
-
xcodeProject.hash.project.objects['PBXContainerItemProxy'] = {};
|
|
110
|
-
}
|
|
111
|
-
xcodeProject.addTargetDependency(xcodeProject.getFirstTarget().uuid, [target.uuid]);
|
|
112
|
-
}
|
|
113
|
-
//# sourceMappingURL=target.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"target.js","sourceRoot":"","sources":["../../../../src/ios-widget/xcode/target.ts"],"names":[],"mappings":";;AAkCA,0CAMC;AAKD,wDAaC;AAKD,wDAqBC;AAlFD,+CAAqC;AAoBrC,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E;;;;;;;GAOG;AACH,SAAgB,eAAe,CAAC,YAA0B,EAAE,OAA+B;IACzF,MAAM,MAAM,GAAG,2BAA2B,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IACjE,sBAAsB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;IAC5C,mBAAmB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;IAEzC,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CAAC,YAA0B,EAAE,UAAkB;IACnF,MAAM,cAAc,GAAG,YAAY,CAAC,iBAAiB,EAAE,CAAA;IACvD,MAAM,YAAY,GAAG,YAAY,CAAC,eAAe,EAAE,CAAA;IAEnD,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC;QACnE,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,gBAAgB,GAAG,EAAE,CAAA;IACpE,CAAC;IAED,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/E,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,gBAAgB,CAAC,UAAU,CAAC,GAAG;YAC1E,kBAAkB,EAAE,eAAG,CAAC,oBAAoB;SAC7C,CAAA;IACH,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CAAC,YAA0B,E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C,qBAAqB,CAAC,GAAG,EAAE,CAAA;IAC/D,CAAC;IACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,uBAAuB,CAAC,EAAE,CAAC;QAChE,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,uBAAuB,CAAC,GAAG,EAAE,CAAA;IACjE,CAAC;IAED,YAAY,CAAC,mBAAmB,CAAC,YAAY,CAAC,cAAc,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;AACrF,CAAC"}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.getWidgetFiles = getWidgetFiles;
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
39
|
-
const logger_1 = require("./logger");
|
|
40
|
-
/**
|
|
41
|
-
* Scans the widget extension target directory and returns categorized file lists.
|
|
42
|
-
*
|
|
43
|
-
* This function only reads the directory structure - it does NOT copy or create files.
|
|
44
|
-
* File generation should be done before this is called.
|
|
45
|
-
*
|
|
46
|
-
* @param targetPath - Path to the widget extension target directory
|
|
47
|
-
* @param targetName - Name of the target (for entitlements file)
|
|
48
|
-
* @returns Categorized lists of files for Xcode project configuration
|
|
49
|
-
*/
|
|
50
|
-
function getWidgetFiles(targetPath, targetName) {
|
|
51
|
-
const widgetFiles = {
|
|
52
|
-
swiftFiles: [],
|
|
53
|
-
entitlementFiles: [],
|
|
54
|
-
plistFiles: [],
|
|
55
|
-
assetDirectories: [],
|
|
56
|
-
intentFiles: [],
|
|
57
|
-
};
|
|
58
|
-
if (!fs.existsSync(targetPath)) {
|
|
59
|
-
logger_1.logger.warn(`Widget target directory does not exist: ${targetPath}`);
|
|
60
|
-
// Still include required generated files even if directory doesn't exist yet
|
|
61
|
-
const initialStatesFile = 'VoltraWidgetInitialStates.swift';
|
|
62
|
-
widgetFiles.swiftFiles.push(initialStatesFile);
|
|
63
|
-
const targetEntitlements = `${targetName}.entitlements`;
|
|
64
|
-
widgetFiles.entitlementFiles.push(targetEntitlements);
|
|
65
|
-
return widgetFiles;
|
|
66
|
-
}
|
|
67
|
-
const files = fs.readdirSync(targetPath);
|
|
68
|
-
for (const file of files) {
|
|
69
|
-
const itemPath = path.join(targetPath, file);
|
|
70
|
-
const isDirectory = fs.lstatSync(itemPath).isDirectory();
|
|
71
|
-
// Handle directories (Assets.xcassets)
|
|
72
|
-
if (isDirectory) {
|
|
73
|
-
if (file === 'Assets.xcassets') {
|
|
74
|
-
widgetFiles.assetDirectories.push(file);
|
|
75
|
-
}
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
// Categorize files by extension
|
|
79
|
-
const ext = path.extname(file).toLowerCase();
|
|
80
|
-
switch (ext) {
|
|
81
|
-
case '.swift':
|
|
82
|
-
widgetFiles.swiftFiles.push(file);
|
|
83
|
-
break;
|
|
84
|
-
case '.entitlements':
|
|
85
|
-
widgetFiles.entitlementFiles.push(file);
|
|
86
|
-
break;
|
|
87
|
-
case '.plist':
|
|
88
|
-
widgetFiles.plistFiles.push(file);
|
|
89
|
-
break;
|
|
90
|
-
case '.intentdefinition':
|
|
91
|
-
widgetFiles.intentFiles.push(file);
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
// Always include the target entitlements file
|
|
96
|
-
const targetEntitlements = `${targetName}.entitlements`;
|
|
97
|
-
if (!widgetFiles.entitlementFiles.includes(targetEntitlements)) {
|
|
98
|
-
widgetFiles.entitlementFiles.push(targetEntitlements);
|
|
99
|
-
}
|
|
100
|
-
// Always include VoltraWidgetInitialStates.swift (generated by config plugin)
|
|
101
|
-
const initialStatesFile = 'VoltraWidgetInitialStates.swift';
|
|
102
|
-
if (!widgetFiles.swiftFiles.includes(initialStatesFile)) {
|
|
103
|
-
widgetFiles.swiftFiles.push(initialStatesFile);
|
|
104
|
-
}
|
|
105
|
-
return widgetFiles;
|
|
106
|
-
}
|
|
107
|
-
//# sourceMappingURL=fileDiscovery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fileDiscovery.js","sourceRoot":"","sources":["../../../src/ut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ED,gCAAgC;QAChC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAA;QAE5C,QAAQ,GAAG,EAAE,CAAC;YACZ,KAAK,QAAQ;gBACX,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBACjC,MAAK;YACP,KAAK,eAAe;gBAClB,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBACvC,MAAK;YACP,KAAK,QAAQ;gBACX,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBACjC,MAAK;YACP,KAAK,mBAAmB;gBACtB,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBAClC,MAAK;QACT,CAAC;IACH,CAAC;IAED,8CAA8C;IAC9C,MAAM,kBAAkB,GAAG,GAAG,UAAU,eAAe,CAAA;IACvD,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC/D,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;IACvD,CAAC;IAED,8EAA8E;IAC9E,MAAM,iBAAiB,GAAG,iCAAiC,CAAA;IAC3D,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACxD,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;IAChD,CAAC;IAED,OAAO,WAAW,CAAA;AACpB,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ensureURLScheme = ensureURLScheme;
|
|
4
|
-
/**
|
|
5
|
-
* Ensures the main app has a URL scheme set so widgetURL can open it.
|
|
6
|
-
* This is an optional feature for deep linking from widgets.
|
|
7
|
-
*
|
|
8
|
-
* @param config - The Expo config object
|
|
9
|
-
* @returns The modified config with URL scheme ensured
|
|
10
|
-
*/
|
|
11
|
-
function ensureURLScheme(config) {
|
|
12
|
-
const scheme = typeof config.scheme === 'string' ? config.scheme : config.ios?.bundleIdentifier;
|
|
13
|
-
if (!scheme) {
|
|
14
|
-
return config;
|
|
15
|
-
}
|
|
16
|
-
const existingInfoPlist = config.ios?.infoPlist || {};
|
|
17
|
-
const existingTypes = existingInfoPlist.CFBundleURLTypes || [];
|
|
18
|
-
// Check if scheme already exists
|
|
19
|
-
const hasScheme = existingTypes.some((t) => Array.isArray(t?.CFBundleURLSchemes) && t.CFBundleURLSchemes.includes(scheme));
|
|
20
|
-
if (hasScheme) {
|
|
21
|
-
return config;
|
|
22
|
-
}
|
|
23
|
-
// Add the URL scheme
|
|
24
|
-
return {
|
|
25
|
-
...config,
|
|
26
|
-
ios: {
|
|
27
|
-
...config.ios,
|
|
28
|
-
infoPlist: {
|
|
29
|
-
...existingInfoPlist,
|
|
30
|
-
CFBundleURLTypes: [
|
|
31
|
-
...existingTypes,
|
|
32
|
-
{
|
|
33
|
-
CFBundleURLSchemes: [scheme],
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=urlScheme.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"urlScheme.js","sourceRoot":"","sources":["../../../src/utils/urlScheme.ts"],"names":[],"mappings":";;AASA,0CAmCC;AA1CD;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,MAAkB;IAChD,MAAM,MAAM,GAAG,OAAQ,MAAc,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAE,MAAc,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,gBAAgB,CAAA;IAEjH,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,MAAM,CAAA;IACf,CAAC;IAED,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,EAAE,SAAS,IAAI,EAAE,CAAA;IACrD,MAAM,aAAa,GAAI,iBAAiB,CAAC,gBAA0B,IAAI,EAAE,CAAA;IAEzE,iCAAiC;IACjC,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,CAClC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,CACrF,CAAA;IAED,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,MAAM,CAAA;IACf,CAAC;IAED,qBAAqB;IACrB,OAAO;QACL,GAAG,MAAM;QACT,GAAG,EAAE;YACH,GAAG,MAAM,CAAC,GAAG;YACb,SAAS,EAAE;gBACT,GAAG,iBAAiB;gBACpB,gBAAgB,EAAE;oBAChB,GAAG,aAAa;oBAChB;wBACE,kBAAkB,EAAE,CAAC,MAAM,CAAC;qBAC7B;iBACF;aACF;SACF;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import { vdConvert } from 'vd-tool';
|
|
4
|
-
import { DEFAULT_ANDROID_USER_IMAGES_PATH, MAX_IMAGE_SIZE_BYTES } from '../../constants';
|
|
5
|
-
import { logger } from '../../utils/logger';
|
|
6
|
-
// ============================================================================
|
|
7
|
-
// Main Function
|
|
8
|
-
// ============================================================================
|
|
9
|
-
/**
|
|
10
|
-
* Generates all asset files for Android widgets.
|
|
11
|
-
*
|
|
12
|
-
* This creates:
|
|
13
|
-
* - res/drawable/ directory structure
|
|
14
|
-
* - Copies user images to drawable resources as Android-compatible resources
|
|
15
|
-
* - Copies widget preview images to drawable resources
|
|
16
|
-
* - Validates image sizes for widget compatibility
|
|
17
|
-
*
|
|
18
|
-
* @returns Map of widgetId to preview image drawable resource name
|
|
19
|
-
*/
|
|
20
|
-
export async function generateAndroidAssets(options) {
|
|
21
|
-
const { platformProjectRoot, projectRoot, userImagesPath = DEFAULT_ANDROID_USER_IMAGES_PATH, widgets } = options;
|
|
22
|
-
// Create res/drawable directory
|
|
23
|
-
const drawablePath = path.join(platformProjectRoot, 'app', 'src', 'main', 'res', 'drawable');
|
|
24
|
-
logger.info(`Generating Android assets in ${drawablePath}`);
|
|
25
|
-
// Collect asset paths from the user images directory (including subdirectories)
|
|
26
|
-
const assets = [];
|
|
27
|
-
const fullUserImagesPath = path.join(projectRoot, userImagesPath);
|
|
28
|
-
function collectAssetsRecursively(dirPath) {
|
|
29
|
-
if (!fs.existsSync(dirPath) || !fs.lstatSync(dirPath).isDirectory()) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const files = fs.readdirSync(dirPath);
|
|
33
|
-
for (const file of files) {
|
|
34
|
-
const sourcePath = path.join(dirPath, file);
|
|
35
|
-
const stat = fs.lstatSync(sourcePath);
|
|
36
|
-
if (stat.isDirectory()) {
|
|
37
|
-
// Recursively collect from subdirectories
|
|
38
|
-
collectAssetsRecursively(sourcePath);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
// Add relative path to assets array
|
|
42
|
-
const relativePath = path.relative(projectRoot, sourcePath);
|
|
43
|
-
assets.push(relativePath);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
collectAssetsRecursively(fullUserImagesPath);
|
|
48
|
-
// Copy user images to drawable resources
|
|
49
|
-
const copiedImages = await copyUserImagesToAndroid(assets, projectRoot, drawablePath);
|
|
50
|
-
if (copiedImages.length > 0) {
|
|
51
|
-
logger.info(`Copied ${copiedImages.length} user image(s) to Android drawable resources`);
|
|
52
|
-
}
|
|
53
|
-
// Copy preview images to drawable resources
|
|
54
|
-
const previewImageMap = await copyPreviewImagesToAndroid(widgets, projectRoot, drawablePath);
|
|
55
|
-
if (previewImageMap.size > 0) {
|
|
56
|
-
logger.info(`Copied ${previewImageMap.size} preview image(s) to Android drawable resources`);
|
|
57
|
-
}
|
|
58
|
-
return previewImageMap;
|
|
59
|
-
}
|
|
60
|
-
// ============================================================================
|
|
61
|
-
// Image Handling
|
|
62
|
-
// ============================================================================
|
|
63
|
-
// Android supports these image/drawable extensions
|
|
64
|
-
const VALID_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.gif', '.webp', '.xml', '.svg'];
|
|
65
|
-
/**
|
|
66
|
-
* Checks if an image file exceeds the size limit for widgets.
|
|
67
|
-
* Logs a warning if the image is too large.
|
|
68
|
-
*
|
|
69
|
-
* @param imagePath - Path to the image file
|
|
70
|
-
* @returns true if the image is within the size limit, false otherwise
|
|
71
|
-
*/
|
|
72
|
-
function checkImageSize(imagePath) {
|
|
73
|
-
const stats = fs.statSync(imagePath);
|
|
74
|
-
const imageSizeInBytes = stats.size;
|
|
75
|
-
if (imageSizeInBytes >= MAX_IMAGE_SIZE_BYTES) {
|
|
76
|
-
const fileName = path.basename(imagePath);
|
|
77
|
-
logger.warnRed(`Image "${fileName}" is ${imageSizeInBytes} bytes (${(imageSizeInBytes / 1024).toFixed(2)}KB). ` +
|
|
78
|
-
`This image may not display correctly in Android widgets as images should be kept small for performance.`);
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Flattens path and sanitizes name.
|
|
85
|
-
* E.g. "assets/login/User-Icon.png" -> "login_user_icon"
|
|
86
|
-
*/
|
|
87
|
-
function sanitizeDrawableName(filePath) {
|
|
88
|
-
const dirName = path.dirname(filePath); // e.g. "assets/login" or "."
|
|
89
|
-
const fileName = path.parse(filePath).name; // e.g. "User-Icon"
|
|
90
|
-
// Combine directory parts (ignoring '.' or root) with filename
|
|
91
|
-
let nameParts = [];
|
|
92
|
-
// If the file is in a subfolder relative to the project root, include it
|
|
93
|
-
if (dirName !== '.' && dirName !== 'assets') {
|
|
94
|
-
// Split path by separator and add to parts
|
|
95
|
-
const parts = dirName.split(path.sep);
|
|
96
|
-
// Filter out 'assets', 'voltra', 'voltra-android' if they are the top folders to avoid redundant prefixes
|
|
97
|
-
const cleanParts = parts.filter((p) => p !== 'assets' && p !== 'voltra' && p !== 'voltra-android' && p !== '.');
|
|
98
|
-
nameParts = [...nameParts, ...cleanParts];
|
|
99
|
-
}
|
|
100
|
-
nameParts.push(fileName);
|
|
101
|
-
// Join with underscore
|
|
102
|
-
let finalName = nameParts.join('_').toLowerCase();
|
|
103
|
-
// Replace invalid characters
|
|
104
|
-
finalName = finalName.replace(/[^a-z0-9_]/g, '_');
|
|
105
|
-
// Ensure start with letter
|
|
106
|
-
if (!/^[a-z]/.test(finalName)) {
|
|
107
|
-
finalName = `img_${finalName}`;
|
|
108
|
-
}
|
|
109
|
-
return finalName;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Process SVG image: Convert to Android Vector Drawable (XML) and write to destination.
|
|
113
|
-
*/
|
|
114
|
-
async function processSvgImage(sourcePath, destinationPath) {
|
|
115
|
-
try {
|
|
116
|
-
// vd-tool converts a file to XML. We'll copy the SVG to the destination first
|
|
117
|
-
// so it has the sanitized name, then convert it there.
|
|
118
|
-
fs.copyFileSync(sourcePath, destinationPath);
|
|
119
|
-
await vdConvert(destinationPath);
|
|
120
|
-
// Remove the temporary SVG file at the destination
|
|
121
|
-
fs.unlinkSync(destinationPath);
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
// Cleanup if something failed
|
|
125
|
-
if (fs.existsSync(destinationPath)) {
|
|
126
|
-
fs.unlinkSync(destinationPath);
|
|
127
|
-
}
|
|
128
|
-
throw new Error(`Failed to convert SVG to Vector Drawable: ${sourcePath}. Error: ${error}`);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Process Bitmap/XML image: Check size and copy to destination.
|
|
133
|
-
*/
|
|
134
|
-
function processBitmapImage(sourcePath, destinationPath) {
|
|
135
|
-
const extension = path.extname(sourcePath).toLowerCase();
|
|
136
|
-
// Check image size for widget compatibility (warns if too large) - only for image files
|
|
137
|
-
if (extension !== '.xml') {
|
|
138
|
-
checkImageSize(sourcePath);
|
|
139
|
-
}
|
|
140
|
-
fs.copyFileSync(sourcePath, destinationPath);
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Copies assets to the Android drawable resources directory.
|
|
144
|
-
*
|
|
145
|
-
* Assets are validated for existence and extension, then copied to res/drawable/
|
|
146
|
-
* with Android-compatible names. SVGs are converted to XML.
|
|
147
|
-
*
|
|
148
|
-
* @param assets - Array of asset file paths (relative to project root)
|
|
149
|
-
* @param projectRoot - Path to the project root
|
|
150
|
-
* @param drawablePath - Path to the res/drawable directory in the Android project
|
|
151
|
-
* @returns Array of drawable resource names that were copied
|
|
152
|
-
*/
|
|
153
|
-
async function copyUserImagesToAndroid(assets, projectRoot, drawablePath) {
|
|
154
|
-
const copiedImages = [];
|
|
155
|
-
// Ensure drawable directory exists
|
|
156
|
-
if (!fs.existsSync(drawablePath)) {
|
|
157
|
-
fs.mkdirSync(drawablePath, { recursive: true });
|
|
158
|
-
}
|
|
159
|
-
// Iterate over the assets array
|
|
160
|
-
for (const assetPath of assets) {
|
|
161
|
-
const sourceFile = path.join(projectRoot, assetPath);
|
|
162
|
-
const extension = path.extname(assetPath).toLowerCase();
|
|
163
|
-
// VALIDATION: Check file existence
|
|
164
|
-
if (!fs.existsSync(sourceFile)) {
|
|
165
|
-
logger.warn(`⚠️ Warning: Asset not found at ${sourceFile}. Skipping.`);
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
// VALIDATION: Check extension
|
|
169
|
-
if (!VALID_EXTENSIONS.includes(extension)) {
|
|
170
|
-
throw new Error(`❌ Validating ${assetPath}: '${extension}' is not a supported Android drawable extension. Supported: ${VALID_EXTENSIONS.join(', ')}`);
|
|
171
|
-
}
|
|
172
|
-
// SANITIZATION: Generate new filename
|
|
173
|
-
const cleanName = sanitizeDrawableName(assetPath);
|
|
174
|
-
const destinationFile = path.join(drawablePath, `${cleanName}${extension}`);
|
|
175
|
-
// Process based on extension
|
|
176
|
-
if (extension === '.svg') {
|
|
177
|
-
await processSvgImage(sourceFile, destinationFile);
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
processBitmapImage(sourceFile, destinationFile);
|
|
181
|
-
}
|
|
182
|
-
copiedImages.push(cleanName);
|
|
183
|
-
}
|
|
184
|
-
return copiedImages;
|
|
185
|
-
}
|
|
186
|
-
// ============================================================================
|
|
187
|
-
// Preview Images
|
|
188
|
-
// ============================================================================
|
|
189
|
-
/**
|
|
190
|
-
* Copies preview images to Android drawable resources.
|
|
191
|
-
* Returns a map of widgetId to drawable resource name.
|
|
192
|
-
*/
|
|
193
|
-
async function copyPreviewImagesToAndroid(widgets, projectRoot, drawablePath) {
|
|
194
|
-
const previewImageMap = new Map();
|
|
195
|
-
// Ensure drawable directory exists
|
|
196
|
-
if (!fs.existsSync(drawablePath)) {
|
|
197
|
-
fs.mkdirSync(drawablePath, { recursive: true });
|
|
198
|
-
}
|
|
199
|
-
for (const widget of widgets) {
|
|
200
|
-
if (!widget.previewImage) {
|
|
201
|
-
continue;
|
|
202
|
-
}
|
|
203
|
-
const sourcePath = path.join(projectRoot, widget.previewImage);
|
|
204
|
-
// Validate file exists
|
|
205
|
-
if (!fs.existsSync(sourcePath)) {
|
|
206
|
-
logger.warn(`Preview image not found for widget '${widget.id}' at ${widget.previewImage}`);
|
|
207
|
-
continue;
|
|
208
|
-
}
|
|
209
|
-
// Warn if image exceeds size limit (does not block copy for Android widgets)
|
|
210
|
-
checkImageSize(sourcePath);
|
|
211
|
-
// Generate drawable resource name
|
|
212
|
-
const ext = path.extname(widget.previewImage).toLowerCase();
|
|
213
|
-
const drawableName = `voltra_widget_${widget.id}_preview`;
|
|
214
|
-
const destinationPath = path.join(drawablePath, `${drawableName}${ext}`);
|
|
215
|
-
// Copy file
|
|
216
|
-
fs.copyFileSync(sourcePath, destinationPath);
|
|
217
|
-
logger.info(`Copied preview image for widget '${widget.id}' to ${drawableName}${ext}`);
|
|
218
|
-
previewImageMap.set(widget.id, drawableName);
|
|
219
|
-
}
|
|
220
|
-
return previewImageMap;
|
|
221
|
-
}
|
|
222
|
-
export { copyPreviewImagesToAndroid };
|
|
223
|
-
//# sourceMappingURL=assets.js.map
|