@stacksjs/desktop-build 0.75.735 → 0.75.755
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/dist/craft-runtime.d.ts +5 -2
- package/dist/craft-runtime.js +1 -1
- package/package.json +11 -11
package/dist/craft-runtime.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DesktopTargetName } from '@stacksjs/types';
|
|
2
2
|
/** The archive Craft publishes for a target, or null when it publishes none. */
|
|
3
3
|
export declare function craftRuntimeAsset(target: DesktopTargetName): string | null;
|
|
4
|
-
/** The runtime's file name inside
|
|
5
|
-
export declare function craftRuntimeBinaryName(target: DesktopTargetName): string;
|
|
4
|
+
/** The runtime profile's file name inside the archive. */
|
|
5
|
+
export declare function craftRuntimeBinaryName(target: DesktopTargetName, profile?: CraftRuntimeProfile): string;
|
|
6
6
|
/**
|
|
7
7
|
* The companions found beside a Windows runtime that the app does not
|
|
8
8
|
* already name, so a build includes `WebView2Loader.dll` without being told.
|
|
@@ -40,6 +40,7 @@ export declare interface CraftReleaseManifest {
|
|
|
40
40
|
export declare interface FetchCraftRuntimeOptions {
|
|
41
41
|
target: DesktopTargetName
|
|
42
42
|
version: string
|
|
43
|
+
profile?: CraftRuntimeProfile
|
|
43
44
|
directory: string
|
|
44
45
|
fetcher?: (url: string) => Promise<Response>
|
|
45
46
|
unpack?: (archive: string, directory: string) => void
|
|
@@ -50,3 +51,5 @@ export declare interface CraftRuntime {
|
|
|
50
51
|
version: string
|
|
51
52
|
fetched: boolean
|
|
52
53
|
}
|
|
54
|
+
declare type CraftRuntimeProfile = 'full' | 'webview';
|
|
55
|
+
export {};
|
package/dist/craft-runtime.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash}from"node:crypto";import{existsSync,mkdirSync,readdirSync,readFileSync,renameSync,rmSync,writeFileSync}from"node:fs";import{dirname,join}from"node:path";export const CRAFT_RELEASE_REPOSITORY="craft-native/craft";export function craftRuntimeAsset(target){const names={"darwin-arm64":"craft-darwin-arm64.zip","darwin-x64":"craft-darwin-x64.zip","linux-x64":"craft-linux-x64.zip","win32-x64":"craft-windows-x64.zip"};return names[target]??null}export function craftRuntimeBinaryName(target){return target.startsWith("win32-")
|
|
1
|
+
import{createHash}from"node:crypto";import{existsSync,mkdirSync,readdirSync,readFileSync,renameSync,rmSync,writeFileSync}from"node:fs";import{dirname,join}from"node:path";export const CRAFT_RELEASE_REPOSITORY="craft-native/craft";export function craftRuntimeAsset(target){const names={"darwin-arm64":"craft-darwin-arm64.zip","darwin-x64":"craft-darwin-x64.zip","linux-x64":"craft-linux-x64.zip","win32-x64":"craft-windows-x64.zip"};return names[target]??null}export function craftRuntimeBinaryName(target,profile="full"){const name=profile==="webview"?"craft-webview":"craft";return target.startsWith("win32-")?`${name}.exe`:name}export const WINDOWS_RUNTIME_COMPANIONS=["WebView2Loader.dll"];export function windowsRuntimeCompanions(runtime,alreadyNamed=[]){const named=new Set(alreadyNamed.map((file)=>file.split(/[\\/]/).pop().toLowerCase()));return WINDOWS_RUNTIME_COMPANIONS.filter((name)=>!named.has(name.toLowerCase())).map((name)=>join(dirname(runtime),name)).filter((file)=>existsSync(file))}export function parseCraftReleaseManifest(text,tag){let parsed;try{parsed=JSON.parse(text)}catch{throw new Error(`Craft ${tag}: release-manifest.json is not JSON`)}const manifest=parsed;if(manifest?.tag!==tag)throw new Error(`Craft ${tag}: release-manifest.json is for ${String(manifest?.tag)}`);if(!Array.isArray(manifest.assets))throw new Error(`Craft ${tag}: release-manifest.json lists no assets`);for(const asset of manifest.assets){if(typeof asset?.name!=="string"||!Number.isSafeInteger(asset.size)||typeof asset.sha256!=="string"||!/^[0-9a-f]{64}$/.test(asset.sha256))throw new Error(`Craft ${tag}: release-manifest.json has an asset without a name, size and SHA-256`)}return manifest}function unpackArchive(archive,directory){const attempts=[["unzip","-oq",archive,"-d",directory],["tar","-xf",archive,"-C",directory]];let failure="";for(const command of attempts){try{const result=Bun.spawnSync(command,{stdout:"ignore",stderr:"pipe"});if(result.exitCode===0)return;failure=result.stderr.toString().trim()||`${command[0]} exited with ${result.exitCode}`}catch(error){failure=error instanceof Error?error.message:String(error)}}throw new Error(`Could not unpack ${archive}: ${failure}`)}export async function fetchCraftRuntime(options){const{target,directory}=options;const version=options.version.replace(/^v/,"");if(!/^\d+\.\d+\.\d+(?:-[\w.]+)?$/.test(version))throw new Error(`Not a Craft version: ${options.version}`);const tag=`v${version}`;const asset=craftRuntimeAsset(target);if(!asset)throw new Error(`Craft publishes no runtime for ${target}. Build one there and name it in desktop.webview.runtime['${target}'].`);const binaryName=craftRuntimeBinaryName(target,options.profile);const binary=join(directory,binaryName);const stamp=join(directory,".craft-version");if(existsSync(binary)&&existsSync(stamp)&&readFileSync(stamp,"utf8").split(" ")[0]===tag)return{binary,version,fetched:false};const fetcher=options.fetcher??((url)=>fetch(url));const base=`https://github.com/${CRAFT_RELEASE_REPOSITORY}/releases/download/${tag}`;const get=async(name)=>{const url=`${base}/${name}`;options.onFetch?.(url);let response;try{response=await fetcher(url)}catch(error){throw new Error(`Could not download ${url}: ${error instanceof Error?error.message:String(error)}`)}if(!response.ok)throw new Error(`Could not download ${url}: HTTP ${response.status}`);return response};const manifest=parseCraftReleaseManifest(await(await get("release-manifest.json")).text(),tag);const listed=manifest.assets.find((entry)=>entry.name===asset);if(!listed)throw new Error(`Craft ${tag} lists no ${asset} in its release manifest.`);const bytes=new Uint8Array(await(await get(asset)).arrayBuffer());const sha256=createHash("sha256").update(bytes).digest("hex");if(bytes.byteLength!==listed.size||sha256!==listed.sha256)throw new Error(`${asset} from Craft ${tag} is not the published file: got ${bytes.byteLength} bytes, sha256 ${sha256}; the release manifest says ${listed.size} bytes, sha256 ${listed.sha256}.`);const staging=`${directory}.fetching`;rmSync(staging,{recursive:true,force:true});mkdirSync(staging,{recursive:true});try{const archive=join(staging,asset);writeFileSync(archive,bytes);(options.unpack??unpackArchive)(archive,staging);rmSync(archive,{force:true});if(!existsSync(join(staging,binaryName)))throw new Error(`${asset} from Craft ${tag} has no ${binaryName} inside (it has: ${readdirSync(staging).join(", ")||"nothing"}).`);writeFileSync(join(staging,".craft-version"),`${tag} ${sha256}`);rmSync(directory,{recursive:true,force:true});mkdirSync(dirname(directory),{recursive:true});renameSync(staging,directory)}finally{rmSync(staging,{recursive:true,force:true})}return{binary,version,fetched:true}}export function installedCraftVersion(root){for(const from of[root,import.meta.dir]){try{let folder=dirname(Bun.resolveSync("craft-native",from));for(let depth=0;depth<6;depth++,folder=dirname(folder)){const file=join(folder,"package.json");if(!existsSync(file))continue;const pkg=JSON.parse(readFileSync(file,"utf8"));if(pkg.name==="craft-native"&&pkg.version)return pkg.version}}catch{}}return null}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/desktop-build",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.755",
|
|
6
6
|
"description": "Build and launch Craft desktop applications for Stacks",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -73,17 +73,17 @@
|
|
|
73
73
|
"prepublishOnly": "bun run build"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@stacksjs/config": "0.75.
|
|
77
|
-
"@stacksjs/router": "0.75.
|
|
78
|
-
"@stacksjs/server": "0.75.
|
|
79
|
-
"@stacksjs/storage": "0.75.
|
|
76
|
+
"@stacksjs/config": "0.75.755",
|
|
77
|
+
"@stacksjs/router": "0.75.755",
|
|
78
|
+
"@stacksjs/server": "0.75.755",
|
|
79
|
+
"@stacksjs/storage": "0.75.755",
|
|
80
80
|
"craft-native": ">=0.0.505"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
|
-
"@stacksjs/config": "0.75.
|
|
84
|
-
"@stacksjs/router": "0.75.
|
|
85
|
-
"@stacksjs/server": "0.75.
|
|
86
|
-
"@stacksjs/storage": "0.75.
|
|
83
|
+
"@stacksjs/config": "0.75.755",
|
|
84
|
+
"@stacksjs/router": "0.75.755",
|
|
85
|
+
"@stacksjs/server": "0.75.755",
|
|
86
|
+
"@stacksjs/storage": "0.75.755"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|
|
89
89
|
"@stacksjs/config": {
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
}
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
|
-
"@stacksjs/build": "0.75.
|
|
104
|
-
"better-dx": "^0.2.
|
|
103
|
+
"@stacksjs/build": "0.75.755",
|
|
104
|
+
"better-dx": "^0.2.41"
|
|
105
105
|
}
|
|
106
106
|
}
|