@stacksjs/actions 0.75.224 → 0.75.226

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.
@@ -1,2 +1,2 @@
1
- import{existsSync,readFileSync,writeFileSync}from"node:fs";import{pathToFileURL}from"node:url";import process from"node:process";import{log}from"@stacksjs/cli";import{projectPath,storagePath}from"@stacksjs/path";import{craftBuilderSpecifier,craftBuilderVersion}from"./craft-entry";import{resolveCraftBuilderProvenance}from"./craft-provenance";import{androidRelease,assertCraftSupportsAndroid,assertCraftSupportsAndroidMapProvider,toCraftAndroidConfig,uploadAndroidMapping,validateAndroidMobileConfig}from"./android-config";import{resolveCrashReporting,resolveMobilePath,resolveNativeFonts,assertCraftSupportsNativeFonts}from"./ios-config";import{compileNativeScreens}from"./native-screens";import{writeAndroidIconTable}from"./android-icons";process.exitCode=1;function craftAndroidEntry(){const explicit=process.env.CRAFT_ANDROID_SRC;return explicit?pathToFileURL(explicit).href:craftBuilderSpecifier("android",projectPath())}async function loadCraftAndroidBuilder(){try{return await import(craftAndroidEntry())}catch(error){throw Error("Craft Android builder is unavailable. Install the current craft-native package or set CRAFT_ANDROID_SRC to packages/android/src/index.ts in a Craft checkout.",{cause:error})}}const configPath=projectPath("config/mobile.ts");if(!existsSync(configPath))throw Error("Missing config/mobile.ts. Add an android section before running `buddy build:android`.");const configModule=await import(`${pathToFileURL(configPath).href}?t=${Date.now()}`),androidSection=configModule.default.android;if(!androidSection)throw Error("config/mobile.ts must define an android section");const config={...androidSection,crashReporting:resolveCrashReporting(configModule.default.crashReporting,androidSection.crashReporting)};validateAndroidMobileConfig(config);const output=resolveMobilePath(projectPath(),config.output)??storagePath("framework/mobile/android"),webAssets=resolveMobilePath(projectPath(),config.webAssets),fallbackWebAssets=resolveMobilePath(projectPath(),config.fallbackWebAssets),craftConfig=toCraftAndroidConfig(config);craftConfig.nativeFonts=resolveNativeFonts(config.nativeFonts,projectPath());craftConfig.appIconPath=resolveMobilePath(projectPath(),config.appIcon);craftConfig.notificationIconPath=resolveMobilePath(projectPath(),config.notificationIcon);craftConfig.googleServicesFile=resolveMobilePath(projectPath(),config.googleServicesFile);if(process.env.NODE_ENV==="production"&&config.capabilities?.pushNotifications&&!craftConfig.googleServicesFile)throw Error("Production Android push notifications require android.googleServicesFile in config/mobile.ts");const appBundle=process.env.STACKS_ANDROID_BUNDLE==="1",release=appBundle||process.env.NODE_ENV==="production",native=config.renderer==="native",nativeBundle=native?await compileNativeScreens(config,projectPath(),output,void 0,"android"):null;if(nativeBundle){for(const diagnostic of nativeBundle.diagnostics??[])log.warn(`${diagnostic.file?`${diagnostic.file}: `:""}${diagnostic.message}`);log.info(`Compiled ${Object.keys(config.nativeScreens??{}).length} native screen path(s) into ${nativeBundle.outFile}`)}const{LUCIDE_TO_SF}=native?await import("@stacksjs/stx/native"):{LUCIDE_TO_SF:{}},iconsPath=native?writeAndroidIconTable(projectPath(),output,LUCIDE_TO_SF):null;if(native&&!iconsPath)log.warn("No @iconify-json/lucide in the app: Android draws its own glyphs for the screens' icons.");const builder=await loadCraftAndroidBuilder(),craftVersion=craftBuilderVersion(craftAndroidEntry(),projectPath());assertCraftSupportsNativeFonts(config.nativeFonts,craftVersion?.version);if(craftVersion)assertCraftSupportsAndroid(config,craftVersion.version,craftVersion.manifest,{appBundle});else log.warn(`Could not read the craft-native version behind ${craftAndroidEntry()}, so the build cannot check that it supports what config/mobile.ts asks for.`);assertCraftSupportsAndroidMapProvider(config,builder.nativeMapProviders);await builder.init({name:config.appName,packageName:config.packageName,output,config:craftConfig});await builder.build(native?{output,nativeBundlePath:nativeBundle.outFile,iconsPath:iconsPath??void 0,release,bundle:appBundle,compile:process.env.STACKS_ANDROID_SKIP_GRADLE!=="1"}:{output,htmlPath:webAssets??fallbackWebAssets,devServer:craftConfig.devServerURL,release,bundle:appBundle,compile:process.env.STACKS_ANDROID_SKIP_GRADLE!=="1"});if(release&&config.crashReporting?.key&&config.crashReporting.uploadSymbols!==!1&&process.env.STACKS_ANDROID_SKIP_GRADLE!=="1"){const upload=await uploadAndroidMapping(`${output}/app/build/outputs/mapping/release/mapping.txt`,config.crashReporting.host??"https://bughq.org",androidRelease(config),process.env.BUGHQ_UPLOAD_TOKEN);if(upload.ok)log.info(upload.message);else log.warn(upload.message)}const sourceRevision=Bun.spawnSync(["git","rev-parse","HEAD"],{cwd:projectPath()}).stdout.toString().trim(),generatedConfig=JSON.parse(readFileSync(`${output}/craft.config.json`,"utf8"));writeFileSync(`${output}/stacks-mobile.json`,`${JSON.stringify({schemaVersion:"1.0.0",platform:"android",sourceRevision,source:native?{kind:"native",site:craftConfig.devServerURL}:webAssets?{kind:"bundled",path:webAssets}:{kind:"remote",url:craftConfig.devServerURL,fallback:fallbackWebAssets?{kind:"bundled",path:fallbackWebAssets}:void 0},capabilities:config.capabilities??{},builder:resolveCraftBuilderProvenance(process.env.CRAFT_ANDROID_SRC),craft:generatedConfig},null,2)}
1
+ import{existsSync,readFileSync,writeFileSync}from"node:fs";import{pathToFileURL}from"node:url";import process from"node:process";import{log}from"@stacksjs/cli";import{projectPath,storagePath}from"@stacksjs/path";import{craftBuilderSpecifier,craftBuilderVersion}from"./craft-entry";import{resolveCraftBuilderProvenance}from"./craft-provenance";import{androidRelease,assertCraftSupportsAndroid,assertCraftSupportsAndroidMapProvider,toCraftAndroidConfig,uploadAndroidMapping,validateAndroidMobileConfig}from"./android-config";import{resolveCrashReporting,resolveMobilePath,resolveNativeFonts,assertCraftSupportsNativeFonts}from"./ios-config";import{compileNativeScreens}from"./native-screens";import{writeAndroidIconTable}from"./android-icons";process.exitCode=1;function craftAndroidEntry(){const explicit=process.env.CRAFT_ANDROID_SRC;return explicit?pathToFileURL(explicit).href:craftBuilderSpecifier("android",projectPath())}async function loadCraftAndroidBuilder(){try{return await import(craftAndroidEntry())}catch(error){throw Error("Craft Android builder is unavailable. Install the current craft-native package or set CRAFT_ANDROID_SRC to packages/android/src/index.ts in a Craft checkout.",{cause:error})}}const configPath=projectPath("config/mobile.ts");if(!existsSync(configPath))throw Error("Missing config/mobile.ts. Add an android section before running `buddy build:android`.");const configModule=await import(`${pathToFileURL(configPath).href}?t=${Date.now()}`),androidSection=configModule.default.android;if(!androidSection)throw Error("config/mobile.ts must define an android section");const config={...androidSection,crashReporting:resolveCrashReporting(configModule.default.crashReporting,androidSection.crashReporting)};validateAndroidMobileConfig(config);const output=resolveMobilePath(projectPath(),config.output)??storagePath("framework/mobile/android"),webAssets=resolveMobilePath(projectPath(),config.webAssets),fallbackWebAssets=resolveMobilePath(projectPath(),config.fallbackWebAssets),craftConfig=toCraftAndroidConfig(config);craftConfig.nativeFonts=resolveNativeFonts(config.nativeFonts,projectPath());craftConfig.appIconPath=resolveMobilePath(projectPath(),config.appIcon);craftConfig.notificationIconPath=resolveMobilePath(projectPath(),config.notificationIcon);craftConfig.googleServicesFile=resolveMobilePath(projectPath(),config.googleServicesFile);if(process.env.NODE_ENV==="production"&&config.capabilities?.pushNotifications&&!craftConfig.googleServicesFile)throw Error("Production Android push notifications require android.googleServicesFile in config/mobile.ts");const appBundle=process.env.STACKS_ANDROID_BUNDLE==="1",release=appBundle||process.env.NODE_ENV==="production",native=config.renderer==="native",builder=await loadCraftAndroidBuilder(),nativeBundle=native?await compileNativeScreens(config,projectPath(),output,void 0,"android",{routes:builder.nativeRouteBundles===!0}):null;if(nativeBundle){for(const diagnostic of nativeBundle.diagnostics??[])log.warn(`${diagnostic.file?`${diagnostic.file}: `:""}${diagnostic.message}`);log.info(`Compiled ${Object.keys(config.nativeScreens??{}).length} native screen path(s) into ${nativeBundle.outFile}`)}const{LUCIDE_TO_SF}=native?await import("@stacksjs/stx/native"):{LUCIDE_TO_SF:{}},iconsPath=native?writeAndroidIconTable(projectPath(),output,LUCIDE_TO_SF):null;if(native&&!iconsPath)log.warn("No @iconify-json/lucide in the app: Android draws its own glyphs for the screens' icons.");const craftVersion=craftBuilderVersion(craftAndroidEntry(),projectPath());assertCraftSupportsNativeFonts(config.nativeFonts,craftVersion?.version);if(craftVersion)assertCraftSupportsAndroid(config,craftVersion.version,craftVersion.manifest,{appBundle});else log.warn(`Could not read the craft-native version behind ${craftAndroidEntry()}, so the build cannot check that it supports what config/mobile.ts asks for.`);assertCraftSupportsAndroidMapProvider(config,builder.nativeMapProviders);await builder.init({name:config.appName,packageName:config.packageName,output,config:craftConfig});await builder.build(native?{output,nativeBundlePath:nativeBundle.outFile,iconsPath:iconsPath??void 0,release,bundle:appBundle,compile:process.env.STACKS_ANDROID_SKIP_GRADLE!=="1"}:{output,htmlPath:webAssets??fallbackWebAssets,devServer:craftConfig.devServerURL,release,bundle:appBundle,compile:process.env.STACKS_ANDROID_SKIP_GRADLE!=="1"});if(release&&config.crashReporting?.key&&config.crashReporting.uploadSymbols!==!1&&process.env.STACKS_ANDROID_SKIP_GRADLE!=="1"){const upload=await uploadAndroidMapping(`${output}/app/build/outputs/mapping/release/mapping.txt`,config.crashReporting.host??"https://bughq.org",androidRelease(config),process.env.BUGHQ_UPLOAD_TOKEN);if(upload.ok)log.info(upload.message);else log.warn(upload.message)}const sourceRevision=Bun.spawnSync(["git","rev-parse","HEAD"],{cwd:projectPath()}).stdout.toString().trim(),generatedConfig=JSON.parse(readFileSync(`${output}/craft.config.json`,"utf8"));writeFileSync(`${output}/stacks-mobile.json`,`${JSON.stringify({schemaVersion:"1.0.0",platform:"android",sourceRevision,source:native?{kind:"native",site:craftConfig.devServerURL}:webAssets?{kind:"bundled",path:webAssets}:{kind:"remote",url:craftConfig.devServerURL,fallback:fallbackWebAssets?{kind:"bundled",path:fallbackWebAssets}:void 0},capabilities:config.capabilities??{},builder:resolveCraftBuilderProvenance(process.env.CRAFT_ANDROID_SRC),craft:generatedConfig},null,2)}
2
2
  `);log.success(`Built the Craft Android project in ${output}`);await log.flush();process.exitCode=0;
package/dist/build/ios.js CHANGED
@@ -1,3 +1,3 @@
1
- import{existsSync,readFileSync,writeFileSync}from"node:fs";import{pathToFileURL}from"node:url";import process from"node:process";import{log}from"@stacksjs/cli";import{projectPath,storagePath}from"@stacksjs/path";import{craftBuilderSpecifier,craftBuilderVersion}from"./craft-entry";import{resolveCraftBuilderProvenance}from"./craft-provenance";import{assertCraftSupportsAppShortcuts,assertCraftSupportsCapabilities,assertCraftSupportsCrashReporting,portablePaths,resolveCrashReporting,resolveMobilePath,resolveNativeFonts,assertCraftSupportsNativeFonts,toCraftIosConfig,validateIosMobileConfig,writeIosActivityTypes}from"./ios-config";import{generateXcodeProject,resolveXcodegen}from"./ios-toolchain";import{compileNativeScreens}from"./native-screens";import{writeIosShellSupport}from"./ios-shell";process.exitCode=1;function craftIosEntry(){const explicit=process.env.CRAFT_IOS_SRC;return explicit?pathToFileURL(explicit).href:craftBuilderSpecifier("ios",projectPath())}async function loadCraftIosBuilder(){try{return await import(craftIosEntry())}catch(error){throw Error("Craft iOS builder is unavailable. Install the current craft-native package or set CRAFT_IOS_SRC to packages/ios/src/index.ts in a Craft checkout.",{cause:error})}}const configPath=projectPath("config/mobile.ts");if(!existsSync(configPath))throw Error("Missing config/mobile.ts. Add an ios section before running `buddy build:ios`.");const configModule=await import(`${pathToFileURL(configPath).href}?t=${Date.now()}`),mobile=configModule.default,config=mobile.ios;validateIosMobileConfig(config);if(config.swipeNavigation===!0&&config.swipeBack!=="webview")log.warn("ios.swipeNavigation turns on WebKit's edge swipe alongside the stx router's own. Remove it, or set ios.swipeBack: 'webview' for an app not on the router.");const output=resolveMobilePath(projectPath(),config.output)??storagePath("framework/mobile/ios"),generateProject=process.env.STACKS_IOS_SKIP_XCODEGEN!=="1",xcodegen=generateProject?await resolveXcodegen(projectPath()):null,webAssets=resolveMobilePath(projectPath(),config.webAssets),fallbackWebAssets=resolveMobilePath(projectPath(),config.fallbackWebAssets),crashReporting=resolveCrashReporting(mobile.crashReporting,config.crashReporting),craftConfig=toCraftIosConfig({...config,crashReporting});craftConfig.nativeFonts=resolveNativeFonts(config.nativeFonts,projectPath());craftConfig.appIconPath=resolveMobilePath(projectPath(),config.appIcon);craftConfig.splashImagePath=resolveMobilePath(projectPath(),config.splash?.image);craftConfig.splashImagePathDark=resolveMobilePath(projectPath(),config.splash?.imageDark);const nativeBundle=await compileNativeScreens(config,projectPath(),output);if(nativeBundle){craftConfig.nativeBundle=nativeBundle.outFile;for(const diagnostic of nativeBundle.diagnostics??[])log.warn(`${diagnostic.file?`${diagnostic.file}: `:""}${diagnostic.message}`);log.info(`Compiled ${Object.keys(config.nativeScreens??{}).length} native screen path(s) into ${nativeBundle.outFile}`)}const builder=await loadCraftIosBuilder(),craftVersion=craftBuilderVersion(craftIosEntry(),projectPath());assertCraftSupportsNativeFonts(config.nativeFonts,craftVersion?.version);assertCraftSupportsAppShortcuts(config.appShortcuts,craftVersion?.version);if(craftVersion){assertCraftSupportsCapabilities(config.capabilities,craftVersion.version,craftVersion.manifest);assertCraftSupportsCrashReporting(crashReporting,craftVersion.version,craftVersion.manifest)}else log.warn(`Could not read the craft-native version behind ${craftIosEntry()}, so the build cannot check that it supports every capability config/mobile.ts turns on.`);await builder.init({name:config.appName,bundleId:config.bundleId,teamId:config.teamId,output,config:craftConfig});const native=config.renderer==="native";if(native&&!nativeBundle)throw Error("ios.renderer 'native' needs native screens to draw: list them in ios.nativeScreens");await builder.build(native?{output,nativeBundlePath:nativeBundle.outFile,generateProject:!1}:{output,htmlPath:webAssets??fallbackWebAssets,devServer:craftConfig.devServerURL,generateProject:!1});if(xcodegen){generateXcodeProject(xcodegen,output);log.info(`Generated the Xcode project with xcodegen ${xcodegen.version} from Pantry`)}writeIosShellSupport(output,config,void 0,crashReporting);if(crashReporting)log.info(`Crash reporting to ${crashReporting.host??"https://bughq.org"}${crashReporting.uploadSymbols===!1?"":": dSYMs upload from Xcode Cloud when BUGHQ_UPLOAD_TOKEN is set in the workflow"}`);const activityTypes=writeIosActivityTypes(output,mobile);if(activityTypes)log.info(`Declared ${activityTypes.length} activity types, so a tapped Spotlight or Siri entry reaches the app`);const sourceRevision=Bun.spawnSync(["git","rev-parse","HEAD"],{cwd:projectPath()}).stdout.toString().trim(),craftConfigPath=`${output}/craft.config.json`,generatedConfig=portablePaths(JSON.parse(readFileSync(craftConfigPath,"utf8")),output,projectPath());writeFileSync(craftConfigPath,`${JSON.stringify(generatedConfig,null,2)}
1
+ import{existsSync,readFileSync,writeFileSync}from"node:fs";import{pathToFileURL}from"node:url";import process from"node:process";import{log}from"@stacksjs/cli";import{projectPath,storagePath}from"@stacksjs/path";import{craftBuilderSpecifier,craftBuilderVersion}from"./craft-entry";import{resolveCraftBuilderProvenance}from"./craft-provenance";import{assertCraftSupportsAppShortcuts,assertCraftSupportsCapabilities,assertCraftSupportsCrashReporting,portablePaths,resolveCrashReporting,resolveMobilePath,resolveNativeFonts,assertCraftSupportsNativeFonts,toCraftIosConfig,validateIosMobileConfig,writeIosActivityTypes}from"./ios-config";import{generateXcodeProject,resolveXcodegen}from"./ios-toolchain";import{compileNativeScreens}from"./native-screens";import{writeIosShellSupport}from"./ios-shell";process.exitCode=1;function craftIosEntry(){const explicit=process.env.CRAFT_IOS_SRC;return explicit?pathToFileURL(explicit).href:craftBuilderSpecifier("ios",projectPath())}async function loadCraftIosBuilder(){try{return await import(craftIosEntry())}catch(error){throw Error("Craft iOS builder is unavailable. Install the current craft-native package or set CRAFT_IOS_SRC to packages/ios/src/index.ts in a Craft checkout.",{cause:error})}}const configPath=projectPath("config/mobile.ts");if(!existsSync(configPath))throw Error("Missing config/mobile.ts. Add an ios section before running `buddy build:ios`.");const configModule=await import(`${pathToFileURL(configPath).href}?t=${Date.now()}`),mobile=configModule.default,config=mobile.ios;validateIosMobileConfig(config);if(config.swipeNavigation===!0&&config.swipeBack!=="webview")log.warn("ios.swipeNavigation turns on WebKit's edge swipe alongside the stx router's own. Remove it, or set ios.swipeBack: 'webview' for an app not on the router.");const output=resolveMobilePath(projectPath(),config.output)??storagePath("framework/mobile/ios"),generateProject=process.env.STACKS_IOS_SKIP_XCODEGEN!=="1",xcodegen=generateProject?await resolveXcodegen(projectPath()):null,webAssets=resolveMobilePath(projectPath(),config.webAssets),fallbackWebAssets=resolveMobilePath(projectPath(),config.fallbackWebAssets),crashReporting=resolveCrashReporting(mobile.crashReporting,config.crashReporting),craftConfig=toCraftIosConfig({...config,crashReporting});craftConfig.nativeFonts=resolveNativeFonts(config.nativeFonts,projectPath());craftConfig.appIconPath=resolveMobilePath(projectPath(),config.appIcon);craftConfig.splashImagePath=resolveMobilePath(projectPath(),config.splash?.image);craftConfig.splashImagePathDark=resolveMobilePath(projectPath(),config.splash?.imageDark);const builder=await loadCraftIosBuilder(),nativeBundle=await compileNativeScreens(config,projectPath(),output,void 0,"ios",{routes:builder.nativeRouteBundles===!0});if(nativeBundle){craftConfig.nativeBundle=nativeBundle.outFile;for(const diagnostic of nativeBundle.diagnostics??[])log.warn(`${diagnostic.file?`${diagnostic.file}: `:""}${diagnostic.message}`);log.info(`Compiled ${Object.keys(config.nativeScreens??{}).length} native screen path(s) into ${nativeBundle.outFile}`)}const craftVersion=craftBuilderVersion(craftIosEntry(),projectPath());assertCraftSupportsNativeFonts(config.nativeFonts,craftVersion?.version);assertCraftSupportsAppShortcuts(config.appShortcuts,craftVersion?.version);if(craftVersion){assertCraftSupportsCapabilities(config.capabilities,craftVersion.version,craftVersion.manifest);assertCraftSupportsCrashReporting(crashReporting,craftVersion.version,craftVersion.manifest)}else log.warn(`Could not read the craft-native version behind ${craftIosEntry()}, so the build cannot check that it supports every capability config/mobile.ts turns on.`);await builder.init({name:config.appName,bundleId:config.bundleId,teamId:config.teamId,output,config:craftConfig});const native=config.renderer==="native";if(native&&!nativeBundle)throw Error("ios.renderer 'native' needs native screens to draw: list them in ios.nativeScreens");await builder.build(native?{output,nativeBundlePath:nativeBundle.outFile,generateProject:!1}:{output,htmlPath:webAssets??fallbackWebAssets,devServer:craftConfig.devServerURL,generateProject:!1});if(xcodegen){generateXcodeProject(xcodegen,output);log.info(`Generated the Xcode project with xcodegen ${xcodegen.version} from Pantry`)}writeIosShellSupport(output,config,void 0,crashReporting);if(crashReporting)log.info(`Crash reporting to ${crashReporting.host??"https://bughq.org"}${crashReporting.uploadSymbols===!1?"":": dSYMs upload from Xcode Cloud when BUGHQ_UPLOAD_TOKEN is set in the workflow"}`);const activityTypes=writeIosActivityTypes(output,mobile);if(activityTypes)log.info(`Declared ${activityTypes.length} activity types, so a tapped Spotlight or Siri entry reaches the app`);const sourceRevision=Bun.spawnSync(["git","rev-parse","HEAD"],{cwd:projectPath()}).stdout.toString().trim(),craftConfigPath=`${output}/craft.config.json`,generatedConfig=portablePaths(JSON.parse(readFileSync(craftConfigPath,"utf8")),output,projectPath());writeFileSync(craftConfigPath,`${JSON.stringify(generatedConfig,null,2)}
2
2
  `);writeFileSync(`${output}/stacks-mobile.json`,`${JSON.stringify(portablePaths({schemaVersion:"1.0.0",platform:"ios",sourceRevision,source:native?{kind:"native",site:craftConfig.devServerURL}:webAssets?{kind:"bundled",path:webAssets}:{kind:"remote",url:craftConfig.devServerURL,fallback:fallbackWebAssets?{kind:"bundled",path:fallbackWebAssets}:void 0},capabilities:config.capabilities??{},builder:resolveCraftBuilderProvenance(process.env.CRAFT_IOS_SRC),craft:generatedConfig},output,projectPath()),null,2)}
3
3
  `);log.success(`Built the Craft iOS project in ${output}`);await log.flush();process.exitCode=0;
@@ -8,22 +8,32 @@ export declare function nativeScreenFiles(config: Pick<IosMobileConfig, 'nativeS
8
8
  /** The app script's file (`nativeApp`), or null when the app has none. */
9
9
  export declare function nativeAppFile(config: Pick<IosMobileConfig, 'nativeApp'>, root: string, section?: 'ios' | 'android'): string | null;
10
10
  /**
11
- * Compiles the app's native screens into the one bundle Craft runs them from,
12
- * and answers its path; nothing when the app has none. The bundle goes in the
13
- * generated project's own folder, so a rebuild replaces it and git never sees
14
- * it.
11
+ * Compiles the app's native screens into what Craft runs them from, and
12
+ * answers its path; nothing when the app has none. It goes in the generated
13
+ * project's own folder, so a rebuild replaces it and git never sees it.
14
+ *
15
+ * With `routes` (a Craft that runs each screen from its own file, its
16
+ * builder's `nativeRouteBundles`), that is a directory of one bundle per
17
+ * route. Every screen is a JavaScriptCore context that evaluates the whole
18
+ * file it is given, so one file of every screen made each tab, push and the
19
+ * app script parse all of them first: ~170 ms of main thread per screen for
20
+ * HQ's 17 MB. Otherwise, the one-file bundle.
15
21
  */
16
- export declare function compileNativeScreens(config: Pick<IosMobileConfig, 'nativeScreens' | 'nativeScreensDir' | 'nativeApp'>, root: string, output: string, compile?: CompileNativeBundle, section?: 'ios' | 'android'): Promise<{ outFile: string, diagnostics: NativeBundleResult['diagnostics'] } | null>;
22
+ export declare function compileNativeScreens(config: Pick<IosMobileConfig, 'nativeScreens' | 'nativeScreensDir' | 'nativeApp'>, root: string, output: string, compile?: CompileNativeBundle, section?: 'ios' | 'android', options?: { routes?: boolean }): Promise<{ outFile: string, diagnostics: NativeBundleResult['diagnostics'] } | null>;
17
23
  /** What stx's native compiler answers (`@stacksjs/stx/native`). */
18
24
  declare interface NativeBundleResult {
19
- outFile: string
25
+ outFile?: string
26
+ code?: string
27
+ routes?: Record<string, string>
20
28
  diagnostics?: Array<{ level?: string, message: string, file?: string }>
21
29
  }
22
30
  declare type CompileNativeBundle = (options: {
23
31
  screens: Record<string, string>
24
32
  initialScreen?: string
25
33
  minify?: boolean
26
- outFile: string
34
+ outFile?: string
35
+ /** One bundle per route, in this directory, instead of one for all. */
36
+ routesDir?: string
27
37
  root?: string
28
38
  /** The app script, run once beside the screens (stx 0.2.504 and later). */
29
39
  app?: string
@@ -1 +1 @@
1
- import{existsSync,mkdirSync}from"node:fs";import{join,resolve}from"node:path";export function nativeScreenFiles(config,root,section="ios"){const dir=resolve(root,config.nativeScreensDir??"resources/native"),files={};for(const name of Object.values(config.nativeScreens??{})){if(files[name])continue;const file=join(dir,`${name}.stx`);if(!existsSync(file))throw Error(`${section}.nativeScreens names the screen "${name}", but ${file} does not exist.`);files[name]=file}return files}export function nativeAppFile(config,root,section="ios"){if(!config.nativeApp)return null;const file=resolve(root,config.nativeApp);if(!existsSync(file))throw Error(`${section}.nativeApp names ${config.nativeApp}, but ${file} does not exist.`);return file}export async function compileNativeScreens(config,root,output,compile,section="ios"){const screens=nativeScreenFiles(config,root,section),names=Object.keys(screens),app=nativeAppFile(config,root,section);if(!names.length){if(app)throw Error(`${section}.nativeApp runs beside native screens: list them in ${section}.nativeScreens`);return null}const compileBundle=compile??(await import("@stacksjs/stx/native")).compileNativeBundle;mkdirSync(output,{recursive:!0});const outFile=join(output,"native-screens.js"),result=await compileBundle({screens,initialScreen:names[0],minify:!0,outFile,root,...app?{app}:{}});return{outFile:result.outFile||outFile,diagnostics:result.diagnostics??[]}}
1
+ import{existsSync,mkdirSync,rmSync,writeFileSync}from"node:fs";import{join,resolve}from"node:path";export function nativeScreenFiles(config,root,section="ios"){const dir=resolve(root,config.nativeScreensDir??"resources/native"),files={};for(const name of Object.values(config.nativeScreens??{})){if(files[name])continue;const file=join(dir,`${name}.stx`);if(!existsSync(file))throw Error(`${section}.nativeScreens names the screen "${name}", but ${file} does not exist.`);files[name]=file}return files}export function nativeAppFile(config,root,section="ios"){if(!config.nativeApp)return null;const file=resolve(root,config.nativeApp);if(!existsSync(file))throw Error(`${section}.nativeApp names ${config.nativeApp}, but ${file} does not exist.`);return file}export async function compileNativeScreens(config,root,output,compile,section="ios",options={}){const screens=nativeScreenFiles(config,root,section),names=Object.keys(screens),app=nativeAppFile(config,root,section);if(!names.length){if(app)throw Error(`${section}.nativeApp runs beside native screens: list them in ${section}.nativeScreens`);return null}const compileBundle=compile??(await import("@stacksjs/stx/native")).compileNativeBundle;mkdirSync(output,{recursive:!0});const outFile=join(output,"native-screens.js"),routesDir=join(output,"native-screens");rmSync(options.routes?outFile:routesDir,{recursive:!0,force:!0});if(options.routes){rmSync(routesDir,{recursive:!0,force:!0});const result=await compileBundle({screens,initialScreen:names[0],minify:!0,routesDir,root,...app?{app}:{}});if(result.routes&&Object.keys(result.routes).length)return{outFile:routesDir,diagnostics:result.diagnostics??[]};if(!result.code)throw Error("stx compiled no native bundle: it wrote no route files and returned no code");writeFileSync(outFile,result.code);return{outFile,diagnostics:result.diagnostics??[]}}const result=await compileBundle({screens,initialScreen:names[0],minify:!0,outFile,root,...app?{app}:{}});return{outFile:result.outFile||outFile,diagnostics:result.diagnostics??[]}}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/actions",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.224",
5
+ "version": "0.75.226",
6
6
  "description": "The Stacks actions.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -66,54 +66,54 @@
66
66
  "prepublishOnly": "bun run build"
67
67
  },
68
68
  "dependencies": {
69
- "@stacksjs/action-runner": "0.75.224",
70
- "@stacksjs/ai": "0.75.224",
71
- "@stacksjs/analytics": "0.75.224",
72
- "@stacksjs/api": "0.75.224",
73
- "@stacksjs/auth": "0.75.224",
74
- "@stacksjs/build": "0.75.224",
69
+ "@stacksjs/action-runner": "0.75.226",
70
+ "@stacksjs/ai": "0.75.226",
71
+ "@stacksjs/analytics": "0.75.226",
72
+ "@stacksjs/api": "0.75.226",
73
+ "@stacksjs/auth": "0.75.226",
74
+ "@stacksjs/build": "0.75.226",
75
75
  "@stacksjs/bumpx": "^0.2.21",
76
76
  "@stacksjs/bunpress": "^0.2.15",
77
- "@stacksjs/cli": "0.75.224",
78
- "@stacksjs/cloud": "0.75.224",
79
- "@stacksjs/cms": "0.75.224",
77
+ "@stacksjs/cli": "0.75.226",
78
+ "@stacksjs/cloud": "0.75.226",
79
+ "@stacksjs/cms": "0.75.226",
80
80
  "@stacksjs/components": "^0.2.567",
81
- "@stacksjs/config": "0.75.224",
82
- "@stacksjs/database": "0.75.224",
83
- "@stacksjs/desktop-build": "0.75.224",
84
- "@stacksjs/dns": "0.75.224",
85
- "@stacksjs/enums": "0.75.224",
86
- "@stacksjs/env": "0.75.224",
87
- "@stacksjs/error-handling": "0.75.224",
88
- "@stacksjs/github": "0.75.224",
81
+ "@stacksjs/config": "0.75.226",
82
+ "@stacksjs/database": "0.75.226",
83
+ "@stacksjs/desktop-build": "0.75.226",
84
+ "@stacksjs/dns": "0.75.226",
85
+ "@stacksjs/enums": "0.75.226",
86
+ "@stacksjs/env": "0.75.226",
87
+ "@stacksjs/error-handling": "0.75.226",
88
+ "@stacksjs/github": "0.75.226",
89
89
  "@stacksjs/gitit": "^0.2.5",
90
- "@stacksjs/i18n": "0.75.224",
91
- "@stacksjs/image": "0.75.224",
92
- "@stacksjs/logging": "0.75.224",
90
+ "@stacksjs/i18n": "0.75.226",
91
+ "@stacksjs/image": "0.75.226",
92
+ "@stacksjs/logging": "0.75.226",
93
93
  "@stacksjs/logsmith": "^0.2.11",
94
- "@stacksjs/mobile": "0.75.224",
95
- "@stacksjs/orm": "0.75.224",
96
- "@stacksjs/path": "0.75.224",
97
- "@stacksjs/payments": "0.75.224",
98
- "@stacksjs/queue": "0.75.224",
99
- "@stacksjs/registry": "0.75.224",
100
- "@stacksjs/router": "0.75.224",
94
+ "@stacksjs/mobile": "0.75.226",
95
+ "@stacksjs/orm": "0.75.226",
96
+ "@stacksjs/path": "0.75.226",
97
+ "@stacksjs/payments": "0.75.226",
98
+ "@stacksjs/queue": "0.75.226",
99
+ "@stacksjs/registry": "0.75.226",
100
+ "@stacksjs/router": "0.75.226",
101
101
  "@stacksjs/rpx": "^0.11.54",
102
- "@stacksjs/scheduler": "0.75.224",
103
- "@stacksjs/search-engine": "0.75.224",
104
- "@stacksjs/security": "0.75.224",
105
- "@stacksjs/server": "0.75.224",
106
- "@stacksjs/sites": "0.75.224",
107
- "@stacksjs/storage": "0.75.224",
108
- "@stacksjs/strings": "0.75.224",
102
+ "@stacksjs/scheduler": "0.75.226",
103
+ "@stacksjs/search-engine": "0.75.226",
104
+ "@stacksjs/security": "0.75.226",
105
+ "@stacksjs/server": "0.75.226",
106
+ "@stacksjs/sites": "0.75.226",
107
+ "@stacksjs/storage": "0.75.226",
108
+ "@stacksjs/strings": "0.75.226",
109
109
  "@stacksjs/stx": "^0.2.567",
110
110
  "@stacksjs/tlsx": "^0.13.19",
111
111
  "@stacksjs/ts-cloud": "^0.16.58",
112
112
  "@stacksjs/ts-md": "^0.1.1",
113
- "@stacksjs/tunnel": "0.75.224",
114
- "@stacksjs/types": "0.75.224",
115
- "@stacksjs/utils": "0.75.224",
116
- "@stacksjs/whois": "0.75.224",
113
+ "@stacksjs/tunnel": "0.75.226",
114
+ "@stacksjs/types": "0.75.226",
115
+ "@stacksjs/utils": "0.75.226",
116
+ "@stacksjs/whois": "0.75.226",
117
117
  "bun-plugin-stx": "^0.2.567"
118
118
  },
119
119
  "peerDependencies": {
@@ -129,7 +129,7 @@
129
129
  }
130
130
  },
131
131
  "devDependencies": {
132
- "@stacksjs/validation": "0.75.224",
132
+ "@stacksjs/validation": "0.75.226",
133
133
  "better-dx": "^0.2.24"
134
134
  }
135
135
  }