@use-voltra/expo-plugin 1.3.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 +34 -0
- package/build/cjs/android/files/assets.js +259 -0
- package/build/cjs/android/files/assets.js.map +1 -0
- package/build/cjs/android/files/fonts.js +69 -0
- package/build/cjs/android/files/fonts.js.map +1 -0
- package/build/cjs/android/files/index.js +81 -0
- package/build/cjs/android/files/index.js.map +1 -0
- package/build/cjs/android/files/initialStates.js +83 -0
- package/build/cjs/android/files/initialStates.js.map +1 -0
- package/build/cjs/android/files/kotlin.js +142 -0
- package/build/cjs/android/files/kotlin.js.map +1 -0
- package/build/cjs/android/files/xml.js +247 -0
- package/build/cjs/android/files/xml.js.map +1 -0
- package/build/cjs/android/index.js +33 -0
- package/build/cjs/android/index.js.map +1 -0
- package/build/cjs/android/manifest.js +63 -0
- package/build/cjs/android/manifest.js.map +1 -0
- package/build/cjs/constants.js +48 -0
- package/build/cjs/constants.js.map +1 -0
- package/build/cjs/index.js +71 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/ios/eas.js +28 -0
- package/build/cjs/ios/eas.js.map +1 -0
- package/build/cjs/ios/entitlements.js +46 -0
- package/build/cjs/ios/entitlements.js.map +1 -0
- package/build/cjs/ios/index.js +39 -0
- package/build/cjs/ios/index.js.map +1 -0
- package/build/cjs/ios/infoPlist.js +51 -0
- package/build/cjs/ios/infoPlist.js.map +1 -0
- package/build/cjs/ios/pushNotifications.js +22 -0
- package/build/cjs/ios/pushNotifications.js.map +1 -0
- package/build/cjs/ios-widget/eas.js +66 -0
- package/build/cjs/ios-widget/eas.js.map +1 -0
- package/build/cjs/ios-widget/files/assets.js +199 -0
- package/build/cjs/ios-widget/files/assets.js.map +1 -0
- package/build/cjs/ios-widget/files/entitlements.js +77 -0
- package/build/cjs/ios-widget/files/entitlements.js.map +1 -0
- package/build/cjs/ios-widget/files/index.js +92 -0
- package/build/cjs/ios-widget/files/index.js.map +1 -0
- package/build/cjs/ios-widget/files/infoPlist.js +91 -0
- package/build/cjs/ios-widget/files/infoPlist.js.map +1 -0
- package/build/cjs/ios-widget/files/swift.js +256 -0
- package/build/cjs/ios-widget/files/swift.js.map +1 -0
- package/build/cjs/ios-widget/fonts.js +151 -0
- package/build/cjs/ios-widget/fonts.js.map +1 -0
- package/build/cjs/ios-widget/index.js +46 -0
- package/build/cjs/ios-widget/index.js.map +1 -0
- package/build/cjs/ios-widget/podfile.js +43 -0
- package/build/cjs/ios-widget/podfile.js.map +1 -0
- package/build/cjs/ios-widget/widgetPlist.js +99 -0
- package/build/cjs/ios-widget/widgetPlist.js.map +1 -0
- package/build/cjs/ios-widget/xcode/buildPhases.js +245 -0
- package/build/cjs/ios-widget/xcode/buildPhases.js.map +1 -0
- package/build/cjs/ios-widget/xcode/configurationList.js +91 -0
- package/build/cjs/ios-widget/xcode/configurationList.js.map +1 -0
- package/build/cjs/ios-widget/xcode/groups.js +65 -0
- package/build/cjs/ios-widget/xcode/groups.js.map +1 -0
- package/build/cjs/ios-widget/xcode/index.js +155 -0
- package/build/cjs/ios-widget/xcode/index.js.map +1 -0
- package/build/cjs/ios-widget/xcode/mainAppSettings.js +71 -0
- package/build/cjs/ios-widget/xcode/mainAppSettings.js.map +1 -0
- package/build/cjs/ios-widget/xcode/productFile.js +74 -0
- package/build/cjs/ios-widget/xcode/productFile.js.map +1 -0
- package/build/cjs/ios-widget/xcode/target.js +113 -0
- package/build/cjs/ios-widget/xcode/target.js.map +1 -0
- package/build/cjs/package.json +3 -0
- package/build/cjs/types.js +3 -0
- package/build/cjs/types.js.map +1 -0
- package/build/cjs/utils/entitlements.js +21 -0
- package/build/cjs/utils/entitlements.js.map +1 -0
- package/build/cjs/utils/fileDiscovery.js +107 -0
- package/build/cjs/utils/fileDiscovery.js.map +1 -0
- package/build/cjs/utils/fonts.js +75 -0
- package/build/cjs/utils/fonts.js.map +1 -0
- package/build/cjs/utils/logger.js +51 -0
- package/build/cjs/utils/logger.js.map +1 -0
- package/build/cjs/utils/prerender.js +191 -0
- package/build/cjs/utils/prerender.js.map +1 -0
- package/build/cjs/utils/urlScheme.js +40 -0
- package/build/cjs/utils/urlScheme.js.map +1 -0
- package/build/cjs/validation.js +231 -0
- package/build/cjs/validation.js.map +1 -0
- package/build/esm/android/files/assets.js +223 -0
- package/build/esm/android/files/assets.js.map +1 -0
- package/build/esm/android/files/fonts.js +33 -0
- package/build/esm/android/files/fonts.js.map +1 -0
- package/build/esm/android/files/index.js +77 -0
- package/build/esm/android/files/index.js.map +1 -0
- package/build/esm/android/files/initialStates.js +44 -0
- package/build/esm/android/files/initialStates.js.map +1 -0
- package/build/esm/android/files/kotlin.js +103 -0
- package/build/esm/android/files/kotlin.js.map +1 -0
- package/build/esm/android/files/xml.js +206 -0
- package/build/esm/android/files/xml.js.map +1 -0
- package/build/esm/android/index.js +29 -0
- package/build/esm/android/index.js.map +1 -0
- package/build/esm/android/manifest.js +59 -0
- package/build/esm/android/manifest.js.map +1 -0
- package/build/esm/constants.js +45 -0
- package/build/esm/constants.js.map +1 -0
- package/build/esm/index.js +69 -0
- package/build/esm/index.js.map +1 -0
- package/build/esm/ios/eas.js +24 -0
- package/build/esm/ios/eas.js.map +1 -0
- package/build/esm/ios/entitlements.js +42 -0
- package/build/esm/ios/entitlements.js.map +1 -0
- package/build/esm/ios/index.js +34 -0
- package/build/esm/ios/index.js.map +1 -0
- package/build/esm/ios/infoPlist.js +47 -0
- package/build/esm/ios/infoPlist.js.map +1 -0
- package/build/esm/ios/pushNotifications.js +18 -0
- package/build/esm/ios/pushNotifications.js.map +1 -0
- package/build/esm/ios-widget/eas.js +62 -0
- package/build/esm/ios-widget/eas.js.map +1 -0
- package/build/esm/ios-widget/files/assets.js +163 -0
- package/build/esm/ios-widget/files/assets.js.map +1 -0
- package/build/esm/ios-widget/files/entitlements.js +37 -0
- package/build/esm/ios-widget/files/entitlements.js.map +1 -0
- package/build/esm/ios-widget/files/index.js +55 -0
- package/build/esm/ios-widget/files/index.js.map +1 -0
- package/build/esm/ios-widget/files/infoPlist.js +55 -0
- package/build/esm/ios-widget/files/infoPlist.js.map +1 -0
- package/build/esm/ios-widget/files/swift.js +217 -0
- package/build/esm/ios-widget/files/swift.js.map +1 -0
- package/build/esm/ios-widget/fonts.js +111 -0
- package/build/esm/ios-widget/fonts.js.map +1 -0
- package/build/esm/ios-widget/index.js +42 -0
- package/build/esm/ios-widget/index.js.map +1 -0
- package/build/esm/ios-widget/podfile.js +39 -0
- package/build/esm/ios-widget/podfile.js.map +1 -0
- package/build/esm/ios-widget/widgetPlist.js +92 -0
- package/build/esm/ios-widget/widgetPlist.js.map +1 -0
- package/build/esm/ios-widget/xcode/buildPhases.js +208 -0
- package/build/esm/ios-widget/xcode/buildPhases.js.map +1 -0
- package/build/esm/ios-widget/xcode/configurationList.js +87 -0
- package/build/esm/ios-widget/xcode/configurationList.js.map +1 -0
- package/build/esm/ios-widget/xcode/groups.js +61 -0
- package/build/esm/ios-widget/xcode/groups.js.map +1 -0
- package/build/esm/ios-widget/xcode/index.js +118 -0
- package/build/esm/ios-widget/xcode/index.js.map +1 -0
- package/build/esm/ios-widget/xcode/mainAppSettings.js +68 -0
- package/build/esm/ios-widget/xcode/mainAppSettings.js.map +1 -0
- package/build/esm/ios-widget/xcode/productFile.js +70 -0
- package/build/esm/ios-widget/xcode/productFile.js.map +1 -0
- package/build/esm/ios-widget/xcode/target.js +108 -0
- package/build/esm/ios-widget/xcode/target.js.map +1 -0
- package/build/esm/package.json +3 -0
- package/build/esm/types.js +2 -0
- package/build/esm/types.js.map +1 -0
- package/build/esm/utils/entitlements.js +18 -0
- package/build/esm/utils/entitlements.js.map +1 -0
- package/build/esm/utils/fileDiscovery.js +71 -0
- package/build/esm/utils/fileDiscovery.js.map +1 -0
- package/build/esm/utils/fonts.js +39 -0
- package/build/esm/utils/fonts.js.map +1 -0
- package/build/esm/utils/logger.js +48 -0
- package/build/esm/utils/logger.js.map +1 -0
- package/build/esm/utils/prerender.js +152 -0
- package/build/esm/utils/prerender.js.map +1 -0
- package/build/esm/utils/urlScheme.js +37 -0
- package/build/esm/utils/urlScheme.js.map +1 -0
- package/build/esm/validation.js +193 -0
- package/build/esm/validation.js.map +1 -0
- package/build/types/android/files/assets.d.ts +26 -0
- package/build/types/android/files/assets.d.ts.map +1 -0
- package/build/types/android/files/fonts.d.ts +19 -0
- package/build/types/android/files/fonts.d.ts.map +1 -0
- package/build/types/android/files/index.d.ts +21 -0
- package/build/types/android/files/index.d.ts.map +1 -0
- package/build/types/android/files/initialStates.d.ts +14 -0
- package/build/types/android/files/initialStates.d.ts.map +1 -0
- package/build/types/android/files/kotlin.d.ts +11 -0
- package/build/types/android/files/kotlin.d.ts.map +1 -0
- package/build/types/android/files/xml.d.ts +25 -0
- package/build/types/android/files/xml.d.ts.map +1 -0
- package/build/types/android/index.d.ts +12 -0
- package/build/types/android/index.d.ts.map +1 -0
- package/build/types/android/manifest.d.ts +15 -0
- package/build/types/android/manifest.d.ts.map +1 -0
- package/build/types/constants.d.ts +29 -0
- package/build/types/constants.d.ts.map +1 -0
- package/build/types/index.d.ts +13 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/ios/eas.d.ts +12 -0
- package/build/types/ios/eas.d.ts.map +1 -0
- package/build/types/ios/entitlements.d.ts +14 -0
- package/build/types/ios/entitlements.d.ts.map +1 -0
- package/build/types/ios/index.d.ts +19 -0
- package/build/types/ios/index.d.ts.map +1 -0
- package/build/types/ios/infoPlist.d.ts +21 -0
- package/build/types/ios/infoPlist.d.ts.map +1 -0
- package/build/types/ios/pushNotifications.d.ts +10 -0
- package/build/types/ios/pushNotifications.d.ts.map +1 -0
- package/build/types/ios-widget/eas.d.ts +15 -0
- package/build/types/ios-widget/eas.d.ts.map +1 -0
- package/build/types/ios-widget/files/assets.d.ts +13 -0
- package/build/types/ios-widget/files/assets.d.ts.map +1 -0
- package/build/types/ios-widget/files/entitlements.d.ts +17 -0
- package/build/types/ios-widget/files/entitlements.d.ts.map +1 -0
- package/build/types/ios-widget/files/index.d.ts +24 -0
- package/build/types/ios-widget/files/index.d.ts.map +1 -0
- package/build/types/ios-widget/files/infoPlist.d.ts +10 -0
- package/build/types/ios-widget/files/infoPlist.d.ts.map +1 -0
- package/build/types/ios-widget/files/swift.d.ts +15 -0
- package/build/types/ios-widget/files/swift.d.ts.map +1 -0
- package/build/types/ios-widget/fonts.d.ts +22 -0
- package/build/types/ios-widget/fonts.d.ts.map +1 -0
- package/build/types/ios-widget/index.d.ts +31 -0
- package/build/types/ios-widget/index.d.ts.map +1 -0
- package/build/types/ios-widget/podfile.d.ts +9 -0
- package/build/types/ios-widget/podfile.d.ts.map +1 -0
- package/build/types/ios-widget/widgetPlist.d.ts +20 -0
- package/build/types/ios-widget/widgetPlist.d.ts.map +1 -0
- package/build/types/ios-widget/xcode/buildPhases.d.ts +25 -0
- package/build/types/ios-widget/xcode/buildPhases.d.ts.map +1 -0
- package/build/types/ios-widget/xcode/configurationList.d.ts +20 -0
- package/build/types/ios-widget/xcode/configurationList.d.ts.map +1 -0
- package/build/types/ios-widget/xcode/groups.d.ts +15 -0
- package/build/types/ios-widget/xcode/groups.d.ts.map +1 -0
- package/build/types/ios-widget/xcode/index.d.ts +20 -0
- package/build/types/ios-widget/xcode/index.d.ts.map +1 -0
- package/build/types/ios-widget/xcode/mainAppSettings.d.ts +15 -0
- package/build/types/ios-widget/xcode/mainAppSettings.d.ts.map +1 -0
- package/build/types/ios-widget/xcode/productFile.d.ts +14 -0
- package/build/types/ios-widget/xcode/productFile.d.ts.map +1 -0
- package/build/types/ios-widget/xcode/target.d.ts +42 -0
- package/build/types/ios-widget/xcode/target.d.ts.map +1 -0
- package/build/types/types.d.ts +261 -0
- package/build/types/types.d.ts.map +1 -0
- package/build/types/utils/entitlements.d.ts +9 -0
- package/build/types/utils/entitlements.d.ts.map +1 -0
- package/build/types/utils/fileDiscovery.d.ts +13 -0
- package/build/types/utils/fileDiscovery.d.ts.map +1 -0
- package/build/types/utils/fonts.d.ts +2 -0
- package/build/types/utils/fonts.d.ts.map +1 -0
- package/build/types/utils/logger.d.ts +30 -0
- package/build/types/utils/logger.d.ts.map +1 -0
- package/build/types/utils/prerender.d.ts +25 -0
- package/build/types/utils/prerender.d.ts.map +1 -0
- package/build/types/utils/urlScheme.d.ts +10 -0
- package/build/types/utils/urlScheme.d.ts.map +1 -0
- package/build/types/validation.d.ts +17 -0
- package/build/types/validation.d.ts.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured logging utility for the Voltra plugin
|
|
3
|
+
*/
|
|
4
|
+
const PREFIX = '[Voltra]';
|
|
5
|
+
// ANSI color codes
|
|
6
|
+
const RED = '\x1b[31m';
|
|
7
|
+
const RESET = '\x1b[0m';
|
|
8
|
+
export const logger = {
|
|
9
|
+
/**
|
|
10
|
+
* Log an informational message
|
|
11
|
+
*/
|
|
12
|
+
info: (message) => {
|
|
13
|
+
console.log(`${PREFIX} ${message}`);
|
|
14
|
+
},
|
|
15
|
+
/**
|
|
16
|
+
* Log a warning message
|
|
17
|
+
*/
|
|
18
|
+
warn: (message) => {
|
|
19
|
+
console.warn(`${PREFIX} ⚠️ ${message}`);
|
|
20
|
+
},
|
|
21
|
+
/**
|
|
22
|
+
* Log a warning message in red (for critical warnings)
|
|
23
|
+
*/
|
|
24
|
+
warnRed: (message) => {
|
|
25
|
+
console.warn(`${RED}${PREFIX} ⚠️ ${message}${RESET}`);
|
|
26
|
+
},
|
|
27
|
+
/**
|
|
28
|
+
* Log an error message
|
|
29
|
+
*/
|
|
30
|
+
error: (message) => {
|
|
31
|
+
console.error(`${PREFIX} ❌ ${message}`);
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* Log a success message
|
|
35
|
+
*/
|
|
36
|
+
success: (message) => {
|
|
37
|
+
console.log(`${PREFIX} ✅ ${message}`);
|
|
38
|
+
},
|
|
39
|
+
/**
|
|
40
|
+
* Log a debug message (only when VOLTRA_DEBUG env var is set)
|
|
41
|
+
*/
|
|
42
|
+
debug: (message) => {
|
|
43
|
+
if (process.env.VOLTRA_DEBUG) {
|
|
44
|
+
console.log(`${PREFIX} 🔍 ${message}`);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,GAAG,UAAU,CAAA;AAEzB,mBAAmB;AACnB,MAAM,GAAG,GAAG,UAAU,CAAA;AACtB,MAAM,KAAK,GAAG,SAAS,CAAA;AAEvB,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB;;OAEG;IACH,IAAI,EAAE,CAAC,OAAe,EAAQ,EAAE;QAC9B,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,IAAI,OAAO,EAAE,CAAC,CAAA;IACrC,CAAC;IAED;;OAEG;IACH,IAAI,EAAE,CAAC,OAAe,EAAQ,EAAE;QAC9B,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,QAAQ,OAAO,EAAE,CAAC,CAAA;IAC1C,CAAC;IAED;;OAEG;IACH,OAAO,EAAE,CAAC,OAAe,EAAQ,EAAE;QACjC,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,MAAM,QAAQ,OAAO,GAAG,KAAK,EAAE,CAAC,CAAA;IACxD,CAAC;IAED;;OAEG;IACH,KAAK,EAAE,CAAC,OAAe,EAAQ,EAAE;QAC/B,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,MAAM,OAAO,EAAE,CAAC,CAAA;IACzC,CAAC;IAED;;OAEG;IACH,OAAO,EAAE,CAAC,OAAe,EAAQ,EAAE;QACjC,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,MAAM,OAAO,EAAE,CAAC,CAAA;IACvC,CAAC;IAED;;OAEG;IACH,KAAK,EAAE,CAAC,OAAe,EAAQ,EAAE;QAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,OAAO,OAAO,EAAE,CAAC,CAAA;QACxC,CAAC;IACH,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import vm from 'node:vm';
|
|
4
|
+
import * as babel from '@babel/core';
|
|
5
|
+
import { MODULE_EXTENSIONS } from '../constants';
|
|
6
|
+
/**
|
|
7
|
+
* Check if a module specifier is a relative or absolute path (local file)
|
|
8
|
+
*/
|
|
9
|
+
function isLocalModule(moduleSpecifier) {
|
|
10
|
+
return moduleSpecifier.startsWith('.') || moduleSpecifier.startsWith('/');
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a module path, trying different extensions
|
|
14
|
+
*/
|
|
15
|
+
function resolveModulePath(moduleSpecifier, fromDir) {
|
|
16
|
+
const basePath = path.resolve(fromDir, moduleSpecifier);
|
|
17
|
+
for (const ext of MODULE_EXTENSIONS) {
|
|
18
|
+
const fullPath = basePath + ext;
|
|
19
|
+
if (fs.existsSync(fullPath) && fs.statSync(fullPath).isFile()) {
|
|
20
|
+
return fullPath;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// Try index files if it's a directory
|
|
24
|
+
if (fs.existsSync(basePath) && fs.statSync(basePath).isDirectory()) {
|
|
25
|
+
for (const ext of MODULE_EXTENSIONS) {
|
|
26
|
+
const indexPath = path.join(basePath, 'index' + ext);
|
|
27
|
+
if (fs.existsSync(indexPath)) {
|
|
28
|
+
return indexPath;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
function getProjectBabelConfigPath(projectRoot) {
|
|
35
|
+
const configPath = path.join(projectRoot, 'babel.config.js');
|
|
36
|
+
return fs.existsSync(configPath) ? configPath : null;
|
|
37
|
+
}
|
|
38
|
+
function getFallbackExpoPreset(projectRoot) {
|
|
39
|
+
return require.resolve('babel-preset-expo', { paths: [projectRoot] });
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Transpile a file with Babel
|
|
43
|
+
*/
|
|
44
|
+
function transpileFile(filePath, projectRoot) {
|
|
45
|
+
const code = fs.readFileSync(filePath, 'utf8');
|
|
46
|
+
const projectBabelConfigPath = getProjectBabelConfigPath(projectRoot);
|
|
47
|
+
const result = babel.transformSync(code, {
|
|
48
|
+
cwd: projectRoot,
|
|
49
|
+
filename: filePath,
|
|
50
|
+
...(projectBabelConfigPath
|
|
51
|
+
? { configFile: projectBabelConfigPath }
|
|
52
|
+
: {
|
|
53
|
+
babelrc: false,
|
|
54
|
+
configFile: false,
|
|
55
|
+
presets: [getFallbackExpoPreset(projectRoot)],
|
|
56
|
+
}),
|
|
57
|
+
});
|
|
58
|
+
if (!result || !result.code) {
|
|
59
|
+
throw new Error(`Babel transpilation failed for ${filePath}`);
|
|
60
|
+
}
|
|
61
|
+
return result.code;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Evaluate a widget module using Babel transpilation and Node.js VM.
|
|
65
|
+
* This allows executing widget code that uses JSX and React components.
|
|
66
|
+
* Local module dependencies are also transpiled with the same Babel settings.
|
|
67
|
+
*/
|
|
68
|
+
function evaluateWidgetModule(projectRoot, filePath) {
|
|
69
|
+
// Cache for already-evaluated modules to handle circular dependencies
|
|
70
|
+
const moduleCache = new Map();
|
|
71
|
+
/**
|
|
72
|
+
* Custom require that transpiles local modules with Babel
|
|
73
|
+
*/
|
|
74
|
+
function customRequire(moduleSpecifier, currentDir) {
|
|
75
|
+
// For non-local modules (npm packages), use native require
|
|
76
|
+
if (!isLocalModule(moduleSpecifier)) {
|
|
77
|
+
return require(moduleSpecifier);
|
|
78
|
+
}
|
|
79
|
+
// Resolve the local module path
|
|
80
|
+
const resolvedPath = resolveModulePath(moduleSpecifier, currentDir);
|
|
81
|
+
if (!resolvedPath) {
|
|
82
|
+
throw new Error(`Cannot resolve module '${moduleSpecifier}' from '${currentDir}'`);
|
|
83
|
+
}
|
|
84
|
+
// Return cached module if already evaluated
|
|
85
|
+
if (moduleCache.has(resolvedPath)) {
|
|
86
|
+
return moduleCache.get(resolvedPath);
|
|
87
|
+
}
|
|
88
|
+
// Transpile and evaluate the module
|
|
89
|
+
const transpiledCode = transpileFile(resolvedPath, projectRoot);
|
|
90
|
+
const moduleDir = path.dirname(resolvedPath);
|
|
91
|
+
const mockModule = { exports: {} };
|
|
92
|
+
// Create require function bound to the module's directory
|
|
93
|
+
const boundRequire = (spec) => customRequire(spec, moduleDir);
|
|
94
|
+
const context = vm.createContext({
|
|
95
|
+
exports: mockModule.exports,
|
|
96
|
+
module: mockModule,
|
|
97
|
+
require: boundRequire,
|
|
98
|
+
__filename: resolvedPath,
|
|
99
|
+
__dirname: moduleDir,
|
|
100
|
+
console: console,
|
|
101
|
+
process: process,
|
|
102
|
+
});
|
|
103
|
+
// Cache before evaluation to handle circular dependencies
|
|
104
|
+
moduleCache.set(resolvedPath, mockModule.exports);
|
|
105
|
+
const script = new vm.Script(transpiledCode, { filename: resolvedPath });
|
|
106
|
+
script.runInContext(context);
|
|
107
|
+
// Update cache with final exports (in case module.exports was reassigned)
|
|
108
|
+
moduleCache.set(resolvedPath, mockModule.exports);
|
|
109
|
+
return mockModule.exports;
|
|
110
|
+
}
|
|
111
|
+
// Evaluate the entry module
|
|
112
|
+
const exports = customRequire(filePath, path.dirname(filePath));
|
|
113
|
+
const widgetVariants = exports.default || exports;
|
|
114
|
+
if (!widgetVariants || typeof widgetVariants !== 'object') {
|
|
115
|
+
throw new Error('Widget file must export a WidgetVariants object or have a default export of WidgetVariants');
|
|
116
|
+
}
|
|
117
|
+
return widgetVariants;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Prerender widget initial states for build-time inclusion.
|
|
121
|
+
*
|
|
122
|
+
* Widget code is transpiled with Babel and executed in a Node.js VM sandbox.
|
|
123
|
+
* This function loads widget files that export WidgetVariants for widgets with initialStatePath configured,
|
|
124
|
+
* renders them to JSON, and returns a map of prerendered states that can be bundled into the app.
|
|
125
|
+
*
|
|
126
|
+
* @param widgets - Array of widget configurations
|
|
127
|
+
* @param projectRoot - Root directory of the Expo project
|
|
128
|
+
* @param renderer - The renderer function to use (voltra/server or voltra/android/server)
|
|
129
|
+
* @returns Map of widgetId -> prerendered widget state as JSON string
|
|
130
|
+
*/
|
|
131
|
+
export async function prerenderWidgetState(widgets, projectRoot, renderer) {
|
|
132
|
+
const prerenderedStates = new Map();
|
|
133
|
+
for (const widget of widgets) {
|
|
134
|
+
if (!widget.initialStatePath) {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
// Resolve the absolute path to the widget file
|
|
139
|
+
const absoluteWidgetPath = path.resolve(projectRoot, widget.initialStatePath);
|
|
140
|
+
// Evaluate the module (transpiles with Babel and executes in VM)
|
|
141
|
+
const widgetVariants = evaluateWidgetModule(projectRoot, absoluteWidgetPath);
|
|
142
|
+
// Render the widget variants to a JSON string
|
|
143
|
+
const prerenderedState = renderer(widgetVariants);
|
|
144
|
+
prerenderedStates.set(widget.id, prerenderedState);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
throw new Error(`Failed to prerender widget state for ${widget.id} (${widget.initialStatePath}): ${error instanceof Error ? error.message : String(error)}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return prerenderedStates;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=prerender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prerender.js","sourceRoot":"","sources":["../../../src/utils/prerender.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OA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AM,CAAC,gBAAgB,MAC3E,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,CACH,CAAA;QACH,CAAC;IACH,CAAC;IAED,OAAO,iBAAiB,CAAA;AAC1B,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensures the main app has a URL scheme set so widgetURL can open it.
|
|
3
|
+
* This is an optional feature for deep linking from widgets.
|
|
4
|
+
*
|
|
5
|
+
* @param config - The Expo config object
|
|
6
|
+
* @returns The modified config with URL scheme ensured
|
|
7
|
+
*/
|
|
8
|
+
export function ensureURLScheme(config) {
|
|
9
|
+
const scheme = typeof config.scheme === 'string' ? config.scheme : config.ios?.bundleIdentifier;
|
|
10
|
+
if (!scheme) {
|
|
11
|
+
return config;
|
|
12
|
+
}
|
|
13
|
+
const existingInfoPlist = config.ios?.infoPlist || {};
|
|
14
|
+
const existingTypes = existingInfoPlist.CFBundleURLTypes || [];
|
|
15
|
+
// Check if scheme already exists
|
|
16
|
+
const hasScheme = existingTypes.some((t) => Array.isArray(t?.CFBundleURLSchemes) && t.CFBundleURLSchemes.includes(scheme));
|
|
17
|
+
if (hasScheme) {
|
|
18
|
+
return config;
|
|
19
|
+
}
|
|
20
|
+
// Add the URL scheme
|
|
21
|
+
return {
|
|
22
|
+
...config,
|
|
23
|
+
ios: {
|
|
24
|
+
...config.ios,
|
|
25
|
+
infoPlist: {
|
|
26
|
+
...existingInfoPlist,
|
|
27
|
+
CFBundleURLTypes: [
|
|
28
|
+
...existingTypes,
|
|
29
|
+
{
|
|
30
|
+
CFBundleURLSchemes: [scheme],
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=urlScheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urlScheme.js","sourceRoot":"","sources":["../../../src/utils/urlScheme.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,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"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* Validation functions for the Voltra plugin
|
|
5
|
+
*/
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// iOS Widget Validation
|
|
8
|
+
// ============================================================================
|
|
9
|
+
const VALID_FAMILIES = new Set([
|
|
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') {
|
|
25
|
+
throw new Error('Widget ID is required and must be a string');
|
|
26
|
+
}
|
|
27
|
+
if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(widget.id)) {
|
|
28
|
+
throw new Error(`Widget ID '${widget.id}' is invalid. ` +
|
|
29
|
+
'Must start with a letter or underscore and contain only alphanumeric characters and underscores.');
|
|
30
|
+
}
|
|
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
|
+
}
|
|
52
|
+
// ============================================================================
|
|
53
|
+
// Android Widget Validation
|
|
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`);
|
|
75
|
+
}
|
|
76
|
+
// Validate targetCellWidth
|
|
77
|
+
if (typeof widget.targetCellWidth !== 'number') {
|
|
78
|
+
throw new Error(`Widget '${widget.id}': targetCellWidth is required and must be a number`);
|
|
79
|
+
}
|
|
80
|
+
if (!Number.isInteger(widget.targetCellWidth) || widget.targetCellWidth < 1) {
|
|
81
|
+
throw new Error(`Widget '${widget.id}': targetCellWidth must be a positive integer (typically 1-5)`);
|
|
82
|
+
}
|
|
83
|
+
// Validate targetCellHeight
|
|
84
|
+
if (typeof widget.targetCellHeight !== 'number') {
|
|
85
|
+
throw new Error(`Widget '${widget.id}': targetCellHeight is required and must be a number`);
|
|
86
|
+
}
|
|
87
|
+
if (!Number.isInteger(widget.targetCellHeight) || widget.targetCellHeight < 1) {
|
|
88
|
+
throw new Error(`Widget '${widget.id}': targetCellHeight must be a positive integer (typically 1-5)`);
|
|
89
|
+
}
|
|
90
|
+
// Validate minCellWidth if provided
|
|
91
|
+
if (widget.minCellWidth !== undefined) {
|
|
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`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// Validate minCellHeight if provided
|
|
97
|
+
if (widget.minCellHeight !== undefined) {
|
|
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
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Validate previewImage if provided
|
|
105
|
+
if (widget.previewImage !== undefined) {
|
|
106
|
+
if (typeof widget.previewImage !== 'string' || !widget.previewImage.trim()) {
|
|
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
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// Validate previewLayout if provided
|
|
123
|
+
if (widget.previewLayout !== undefined) {
|
|
124
|
+
if (typeof widget.previewLayout !== 'string' || !widget.previewLayout.trim()) {
|
|
125
|
+
throw new Error(`Widget '${widget.id}': previewLayout must be a non-empty string`);
|
|
126
|
+
}
|
|
127
|
+
const ext = path.extname(widget.previewLayout).toLowerCase();
|
|
128
|
+
if (ext !== '.xml') {
|
|
129
|
+
throw new Error(`Widget '${widget.id}': previewLayout must be an XML file. Got: ${ext}`);
|
|
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
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// ============================================================================
|
|
141
|
+
// Plugin Props Validation
|
|
142
|
+
// ============================================================================
|
|
143
|
+
/**
|
|
144
|
+
* Validates the plugin props at entry point.
|
|
145
|
+
* Throws an error if validation fails.
|
|
146
|
+
*/
|
|
147
|
+
export function validateProps(props) {
|
|
148
|
+
// Validate group identifier format if provided
|
|
149
|
+
if (props.groupIdentifier !== undefined) {
|
|
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
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Validate iOS widgets if provided
|
|
158
|
+
if (props.widgets !== undefined) {
|
|
159
|
+
if (!Array.isArray(props.widgets)) {
|
|
160
|
+
throw new Error('widgets must be an array');
|
|
161
|
+
}
|
|
162
|
+
// Check for duplicate widget IDs
|
|
163
|
+
const seenIds = new Set();
|
|
164
|
+
for (const widget of props.widgets) {
|
|
165
|
+
validateWidgetConfig(widget);
|
|
166
|
+
if (seenIds.has(widget.id)) {
|
|
167
|
+
throw new Error(`Duplicate widget ID: '${widget.id}'`);
|
|
168
|
+
}
|
|
169
|
+
seenIds.add(widget.id);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// Validate Android configuration if provided
|
|
173
|
+
if (props.android !== undefined) {
|
|
174
|
+
if (typeof props.android !== 'object' || props.android === null) {
|
|
175
|
+
throw new Error('android configuration must be an object');
|
|
176
|
+
}
|
|
177
|
+
if (props.android.widgets !== undefined) {
|
|
178
|
+
if (!Array.isArray(props.android.widgets)) {
|
|
179
|
+
throw new Error('android.widgets must be an array');
|
|
180
|
+
}
|
|
181
|
+
// Check for duplicate widget IDs
|
|
182
|
+
const seenIds = new Set();
|
|
183
|
+
for (const widget of props.android.widgets) {
|
|
184
|
+
validateAndroidWidgetConfig(widget);
|
|
185
|
+
if (seenIds.has(widget.id)) {
|
|
186
|
+
throw new Error(`Duplicate Android widget ID: '${widget.id}'`);
|
|
187
|
+
}
|
|
188
|
+
seenIds.add(widget.id);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAI5B;;GAEG;AAEH,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E,MAAM,cAAc,GAAsB,IAAI,GAAG,CAAC;IAChD,aAAa;IACb,cAAc;IACd,aAAa;IACb,kBAAkB;IAClB,mBAAmB;IACnB,sBAAsB;IACtB,iBAAiB;CAClB,CAAC,CAAA;AAEF;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAoB;IACvD,qBAAqB;IACrB,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,OAAO,MAAM,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;QACh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,CAAC,EAAE,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;IAED,6CAA6C;IAC7C,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAChC,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YAChE,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAA;QAC5D,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YACxC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC1C,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;YACrD,CAAC;YAED,iCAAiC;YACjC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAA;YACjC,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;gBAC3C,2BAA2B,CAAC,MAAM,CAAC,CAAA;gBAEnC,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;oBAC3B,MAAM,IAAI,KAAK,CAAC,iCAAiC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAA;gBAChE,CAAC;gBACD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;YACxB,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AndroidWidgetConfig } from '../../types';
|
|
2
|
+
export interface GenerateAndroidAssetsOptions {
|
|
3
|
+
platformProjectRoot: string;
|
|
4
|
+
projectRoot: string;
|
|
5
|
+
userImagesPath?: string;
|
|
6
|
+
widgets: AndroidWidgetConfig[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Generates all asset files for Android widgets.
|
|
10
|
+
*
|
|
11
|
+
* This creates:
|
|
12
|
+
* - res/drawable/ directory structure
|
|
13
|
+
* - Copies user images to drawable resources as Android-compatible resources
|
|
14
|
+
* - Copies widget preview images to drawable resources
|
|
15
|
+
* - Validates image sizes for widget compatibility
|
|
16
|
+
*
|
|
17
|
+
* @returns Map of widgetId to preview image drawable resource name
|
|
18
|
+
*/
|
|
19
|
+
export declare function generateAndroidAssets(options: GenerateAndroidAssetsOptions): Promise<Map<string, string>>;
|
|
20
|
+
/**
|
|
21
|
+
* Copies preview images to Android drawable resources.
|
|
22
|
+
* Returns a map of widgetId to drawable resource name.
|
|
23
|
+
*/
|
|
24
|
+
declare function copyPreviewImagesToAndroid(widgets: AndroidWidgetConfig[], projectRoot: string, drawablePath: string): Promise<Map<string, string>>;
|
|
25
|
+
export { copyPreviewImagesToAndroid };
|
|
26
|
+
//# sourceMappingURL=assets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../../../src/android/files/assets.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAGtD,MAAM,WAAW,4BAA4B;IAC3C,mBAAmB,EAAE,MAAM,CAAA;IAC3B,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,OAAO,EAAE,mBAAmB,EAAE,CAAA;CAC/B;AAMD;;;;;;;;;;GAUG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAiD/G;AAgKD;;;GAGG;AACH,iBAAe,0BAA0B,CACvC,OAAO,EAAE,mBAAmB,EAAE,EAC9B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAqC9B;AAED,OAAO,EAAE,0BAA0B,EAAE,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Font configuration for Android widgets.
|
|
3
|
+
*
|
|
4
|
+
* Copies custom font files to the Android assets/fonts/ directory
|
|
5
|
+
* so they can be loaded by TextBitmapRenderer via Typeface.createFromAsset().
|
|
6
|
+
*/
|
|
7
|
+
export interface CopyAndroidFontsOptions {
|
|
8
|
+
platformProjectRoot: string;
|
|
9
|
+
projectRoot: string;
|
|
10
|
+
fonts: string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Copies custom font files to android/app/src/main/assets/fonts/.
|
|
14
|
+
*
|
|
15
|
+
* Resolves each path relative to the project root.
|
|
16
|
+
* If a path points to a directory, all .ttf/.otf files inside it are copied.
|
|
17
|
+
*/
|
|
18
|
+
export declare function copyAndroidFonts(options: CopyAndroidFontsOptions): Promise<void>;
|
|
19
|
+
//# sourceMappingURL=fonts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fonts.d.ts","sourceRoot":"","sources":["../../../../src/android/files/fonts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,MAAM,WAAW,uBAAuB;IACtC,mBAAmB,EAAE,MAAM,CAAA;IAC3B,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBtF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
import type { AndroidWidgetConfig } from '../../types';
|
|
3
|
+
export interface GenerateAndroidWidgetFilesProps {
|
|
4
|
+
widgets: AndroidWidgetConfig[];
|
|
5
|
+
userImagesPath?: string;
|
|
6
|
+
fonts?: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Plugin step that generates all Android widget files.
|
|
10
|
+
*
|
|
11
|
+
* This creates:
|
|
12
|
+
* - Kotlin receiver classes for each widget
|
|
13
|
+
* - res/xml/{widget_id}_info.xml (widget provider info)
|
|
14
|
+
* - res/layout/voltra_widget_placeholder.xml (placeholder layout)
|
|
15
|
+
* - res/values/voltra_widgets.xml (widget descriptions)
|
|
16
|
+
* - res/drawable/ images (user images as drawable resources)
|
|
17
|
+
*
|
|
18
|
+
* This should run before configureAndroidManifest so the files exist when the manifest is configured.
|
|
19
|
+
*/
|
|
20
|
+
export declare const generateAndroidWidgetFiles: ConfigPlugin<GenerateAndroidWidgetFilesProps>;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/android/files/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAoB,MAAM,sBAAsB,CAAA;AAErE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAOtD,MAAM,WAAW,+BAA+B;IAC9C,OAAO,EAAE,mBAAmB,EAAE,CAAA;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;CACjB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,0BAA0B,EAAE,YAAY,CAAC,+BAA+B,CAsEpF,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AndroidWidgetConfig } from '../../types';
|
|
2
|
+
export interface GenerateInitialStatesOptions {
|
|
3
|
+
widgets: AndroidWidgetConfig[];
|
|
4
|
+
projectRoot: string;
|
|
5
|
+
platformProjectRoot: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Generates the initial states JSON file for Android widgets.
|
|
9
|
+
*
|
|
10
|
+
* This file (voltra_initial_states.json) is placed in the Android assets directory
|
|
11
|
+
* and contains the pre-rendered payloads for all widgets that have an initialStatePath.
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateAndroidInitialStates(options: GenerateInitialStatesOptions): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=initialStates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialStates.d.ts","sourceRoot":"","sources":["../../../../src/android/files/initialStates.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAItD,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,mBAAmB,EAAE,CAAA;IAC9B,WAAW,EAAE,MAAM,CAAA;IACnB,mBAAmB,EAAE,MAAM,CAAA;CAC5B;AAID;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,CAwCvG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AndroidWidgetConfig } from '../../types';
|
|
2
|
+
export interface GenerateKotlinFilesProps {
|
|
3
|
+
platformProjectRoot: string;
|
|
4
|
+
packageName: string;
|
|
5
|
+
widgets: AndroidWidgetConfig[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Generates Kotlin receiver classes for all configured widgets
|
|
9
|
+
*/
|
|
10
|
+
export declare function generateWidgetReceivers(props: GenerateKotlinFilesProps): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=kotlin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kotlin.d.ts","sourceRoot":"","sources":["../../../../src/android/files/kotlin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEtD,MAAM,WAAW,wBAAwB;IACvC,mBAAmB,EAAE,MAAM,CAAA;IAC3B,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,mBAAmB,EAAE,CAAA;CAC/B;AAMD;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB5F"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AndroidWidgetConfig } from '../../types';
|
|
2
|
+
export interface GenerateXmlFilesProps {
|
|
3
|
+
platformProjectRoot: string;
|
|
4
|
+
projectRoot: string;
|
|
5
|
+
widgets: AndroidWidgetConfig[];
|
|
6
|
+
previewImageMap: Map<string, string>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Generates widget info XML files for all widgets
|
|
10
|
+
*/
|
|
11
|
+
export declare function generateWidgetInfoFiles(props: {
|
|
12
|
+
platformProjectRoot: string;
|
|
13
|
+
widgets: AndroidWidgetConfig[];
|
|
14
|
+
}): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Generates placeholder layout XML
|
|
17
|
+
*/
|
|
18
|
+
export declare function generateWidgetPlaceholderLayouts(props: {
|
|
19
|
+
platformProjectRoot: string;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Generates preview layouts for widgets
|
|
23
|
+
*/
|
|
24
|
+
export declare function generateWidgetPreviewLayouts(props: GenerateXmlFilesProps): Promise<void>;
|
|
25
|
+
//# sourceMappingURL=xml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xml.d.ts","sourceRoot":"","sources":["../../../../src/android/files/xml.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAGtD,MAAM,WAAW,qBAAqB;IACpC,mBAAmB,EAAE,MAAM,CAAA;IAC3B,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,mBAAmB,EAAE,CAAA;IAC9B,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACrC;AAMD;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,KAAK,EAAE;IACnD,mBAAmB,EAAE,MAAM,CAAA;IAC3B,OAAO,EAAE,mBAAmB,EAAE,CAAA;CAC/B,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBhB;AAED;;GAEG;AACH,wBAAsB,gCAAgC,CAAC,KAAK,EAAE;IAAE,mBAAmB,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAU5G;AAED;;GAEG;AACH,wBAAsB,4BAA4B,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoB9F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
import type { AndroidPluginProps } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Main Android configuration plugin.
|
|
5
|
+
*
|
|
6
|
+
* This orchestrates all Android-related configuration in the correct order:
|
|
7
|
+
* 1. Validate widget configurations with file existence checks
|
|
8
|
+
* 2. Generate widget files (Kotlin receivers, XML metadata, resources)
|
|
9
|
+
* 3. Configure AndroidManifest (receiver entries)
|
|
10
|
+
*/
|
|
11
|
+
export declare const withAndroid: ConfigPlugin<AndroidPluginProps>;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/android/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,sBAAsB,CAAA;AAEhE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAKlD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,EAAE,YAAY,CAAC,kBAAkB,CAsBxD,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
import type { AndroidWidgetConfig } from '../types';
|
|
3
|
+
export interface ConfigureAndroidManifestProps {
|
|
4
|
+
widgets: AndroidWidgetConfig[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Plugin step that adds widget receiver entries to AndroidManifest.xml
|
|
8
|
+
*
|
|
9
|
+
* This adds a <receiver> entry for each widget with:
|
|
10
|
+
* - The generated receiver class name
|
|
11
|
+
* - APPWIDGET_UPDATE intent filter
|
|
12
|
+
* - Widget provider metadata reference
|
|
13
|
+
*/
|
|
14
|
+
export declare const configureAndroidManifest: ConfigPlugin<ConfigureAndroidManifestProps>;
|
|
15
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/android/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,sBAAsB,CAAA;AAGxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAEnD,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,mBAAmB,EAAE,CAAA;CAC/B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,EAAE,YAAY,CAAC,6BAA6B,CAsDhF,CAAA"}
|