@stacksjs/desktop 0.2.113 → 0.2.115
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/index.d.ts +6 -0
- package/dist/index.js +89 -35
- package/dist/index.js.map +5 -4
- package/dist/packaging.d.ts +23 -0
- package/dist/types.d.ts +3 -0
- package/dist/window.d.ts +13 -5
- package/package.json +3 -8
package/dist/index.d.ts
CHANGED
|
@@ -73,6 +73,7 @@ export type {
|
|
|
73
73
|
WindowOptions,
|
|
74
74
|
} from './types';
|
|
75
75
|
export type { DesktopConfig } from './window';
|
|
76
|
+
export type { PackageConfig, PackageResult } from './packaging';
|
|
76
77
|
export type {
|
|
77
78
|
CaffeinateInstance,
|
|
78
79
|
CaffeinateOptions,
|
|
@@ -362,6 +363,7 @@ export {
|
|
|
362
363
|
// =============================================================================
|
|
363
364
|
export {
|
|
364
365
|
closeAllWindows,
|
|
366
|
+
craftWindowArguments,
|
|
365
367
|
createWindow,
|
|
366
368
|
createWindowWithHTML,
|
|
367
369
|
getActiveWindowIds,
|
|
@@ -374,6 +376,10 @@ export {
|
|
|
374
376
|
setDesktopConfig,
|
|
375
377
|
} from './window';
|
|
376
378
|
// =============================================================================
|
|
379
|
+
// Packaging & Code Signing (re-exported from Craft)
|
|
380
|
+
// =============================================================================
|
|
381
|
+
export { pack, packageApp } from './packaging';
|
|
382
|
+
// =============================================================================
|
|
377
383
|
// Power Management / Caffeinate
|
|
378
384
|
// =============================================================================
|
|
379
385
|
export {
|
package/dist/index.js
CHANGED
|
@@ -2633,7 +2633,7 @@ window.stxDialog = {
|
|
|
2633
2633
|
// src/window.ts
|
|
2634
2634
|
import process3 from "process";
|
|
2635
2635
|
import { existsSync } from "fs";
|
|
2636
|
-
import { join } from "path";
|
|
2636
|
+
import { dirname, join } from "path";
|
|
2637
2637
|
var currentConfig = {};
|
|
2638
2638
|
function setDesktopConfig(config) {
|
|
2639
2639
|
currentConfig = { ...currentConfig, ...config };
|
|
@@ -2656,6 +2656,7 @@ function prepareSidebarConfig(options) {
|
|
|
2656
2656
|
return config;
|
|
2657
2657
|
}
|
|
2658
2658
|
var DEFAULT_SEARCH_PATHS = [
|
|
2659
|
+
join(dirname(process3.execPath), "craft"),
|
|
2659
2660
|
join(process3.env.HOME || "", ".bun/bin/craft"),
|
|
2660
2661
|
join(process3.env.HOME || "", "Code/Tools/craft/packages/zig/zig-out/bin/craft"),
|
|
2661
2662
|
join(process3.env.HOME || "", "Code/craft/packages/zig/zig-out/bin/craft"),
|
|
@@ -2748,42 +2749,90 @@ function createWindowInstance(id, app) {
|
|
|
2748
2749
|
}
|
|
2749
2750
|
};
|
|
2750
2751
|
}
|
|
2752
|
+
function craftWindowArguments(url, options = {}) {
|
|
2753
|
+
const args = [
|
|
2754
|
+
"--url",
|
|
2755
|
+
url,
|
|
2756
|
+
"--title",
|
|
2757
|
+
options.title || "stx Desktop",
|
|
2758
|
+
"--width",
|
|
2759
|
+
String(options.width ?? 1200),
|
|
2760
|
+
"--height",
|
|
2761
|
+
String(options.height ?? 800)
|
|
2762
|
+
];
|
|
2763
|
+
if (options.darkMode)
|
|
2764
|
+
args.push("--dark");
|
|
2765
|
+
if (options.hotReload)
|
|
2766
|
+
args.push("--hot-reload");
|
|
2767
|
+
if (options.resizable === false)
|
|
2768
|
+
args.push("--no-resize");
|
|
2769
|
+
if (options.frameless)
|
|
2770
|
+
args.push("--frameless");
|
|
2771
|
+
if (options.alwaysOnTop)
|
|
2772
|
+
args.push("--always-on-top");
|
|
2773
|
+
if (options.titlebarHidden)
|
|
2774
|
+
args.push("--titlebar-hidden");
|
|
2775
|
+
if (options.systemTray)
|
|
2776
|
+
args.push("--system-tray");
|
|
2777
|
+
if (options.hideDockIcon)
|
|
2778
|
+
args.push("--hide-dock-icon");
|
|
2779
|
+
if (options.devTools === false)
|
|
2780
|
+
args.push("--no-devtools");
|
|
2781
|
+
if (options.nativeSidebar)
|
|
2782
|
+
args.push("--native-sidebar");
|
|
2783
|
+
if (options.sidebarWidth !== undefined)
|
|
2784
|
+
args.push("--sidebar-width", String(options.sidebarWidth));
|
|
2785
|
+
const sidebarConfig = prepareSidebarConfig(options);
|
|
2786
|
+
if (sidebarConfig)
|
|
2787
|
+
args.push("--sidebar-config", JSON.stringify(sidebarConfig));
|
|
2788
|
+
return args;
|
|
2789
|
+
}
|
|
2751
2790
|
async function createWindow(url, options = {}) {
|
|
2752
|
-
const {
|
|
2753
|
-
|
|
2754
|
-
width = 1200,
|
|
2755
|
-
height = 800,
|
|
2756
|
-
darkMode = false,
|
|
2757
|
-
hotReload = false,
|
|
2758
|
-
resizable = true,
|
|
2759
|
-
frameless = false,
|
|
2760
|
-
alwaysOnTop = false
|
|
2761
|
-
} = options;
|
|
2791
|
+
const id = `craft-window-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
2792
|
+
const craftPath = getCraftBinaryPath();
|
|
2762
2793
|
try {
|
|
2763
|
-
const { createApp } = await import("
|
|
2764
|
-
const craftPath = getCraftBinaryPath();
|
|
2794
|
+
const { createApp } = await import("craft-native");
|
|
2765
2795
|
const app = createApp({
|
|
2766
2796
|
url,
|
|
2767
2797
|
craftPath,
|
|
2768
2798
|
window: {
|
|
2769
|
-
title,
|
|
2770
|
-
width,
|
|
2771
|
-
height,
|
|
2772
|
-
darkMode,
|
|
2773
|
-
hotReload,
|
|
2774
|
-
resizable,
|
|
2775
|
-
frameless,
|
|
2776
|
-
alwaysOnTop
|
|
2799
|
+
title: options.title || "stx Desktop",
|
|
2800
|
+
width: options.width ?? 1200,
|
|
2801
|
+
height: options.height ?? 800,
|
|
2802
|
+
darkMode: options.darkMode ?? false,
|
|
2803
|
+
hotReload: options.hotReload ?? false,
|
|
2804
|
+
resizable: options.resizable ?? true,
|
|
2805
|
+
frameless: options.frameless ?? false,
|
|
2806
|
+
alwaysOnTop: options.alwaysOnTop ?? false,
|
|
2807
|
+
titlebarHidden: options.titlebarHidden ?? false,
|
|
2808
|
+
systemTray: options.systemTray ?? false,
|
|
2809
|
+
hideDockIcon: options.hideDockIcon ?? false,
|
|
2810
|
+
devTools: options.devTools ?? false,
|
|
2811
|
+
nativeSidebar: options.nativeSidebar ?? false,
|
|
2812
|
+
sidebarWidth: options.sidebarWidth,
|
|
2813
|
+
sidebarConfig: prepareSidebarConfig(options)
|
|
2777
2814
|
}
|
|
2778
2815
|
});
|
|
2779
|
-
const id = `craft-window-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
2780
2816
|
activeWindows.set(id, { app, url, options });
|
|
2781
2817
|
await app.show();
|
|
2782
2818
|
return createWindowInstance(id, app);
|
|
2783
|
-
} catch (
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2819
|
+
} catch (tsCraftError) {
|
|
2820
|
+
if (!craftPath) {
|
|
2821
|
+
console.error("Failed to create native window: no craft binary found and craft-native is not installed");
|
|
2822
|
+
console.error(` (craft-native error: ${tsCraftError.message})`);
|
|
2823
|
+
return null;
|
|
2824
|
+
}
|
|
2825
|
+
try {
|
|
2826
|
+
const { spawn } = await import("child_process");
|
|
2827
|
+
const child = spawn(craftPath, craftWindowArguments(url, options), { stdio: "inherit" });
|
|
2828
|
+
child.on("error", (err) => console.warn("craft child error:", err.message));
|
|
2829
|
+
const app = { close: () => child.kill() };
|
|
2830
|
+
activeWindows.set(id, { app, url, options });
|
|
2831
|
+
return createWindowInstance(id, app);
|
|
2832
|
+
} catch (binaryError) {
|
|
2833
|
+
console.error("Failed to spawn craft binary:", binaryError.message);
|
|
2834
|
+
return null;
|
|
2835
|
+
}
|
|
2787
2836
|
}
|
|
2788
2837
|
}
|
|
2789
2838
|
async function openDevWindow(port, options = {}) {
|
|
@@ -2795,8 +2844,8 @@ async function openDevWindow(port, options = {}) {
|
|
|
2795
2844
|
return false;
|
|
2796
2845
|
}
|
|
2797
2846
|
try {
|
|
2798
|
-
const { createApp } = await import("
|
|
2799
|
-
console.log("\u26A1 Opening native window via
|
|
2847
|
+
const { createApp } = await import("craft-native");
|
|
2848
|
+
console.log("\u26A1 Opening native window via craft-native\u2026");
|
|
2800
2849
|
const useSystemTray = !options.nativeSidebar;
|
|
2801
2850
|
const sidebarConfig = prepareSidebarConfig(options);
|
|
2802
2851
|
const app = createApp({
|
|
@@ -2855,8 +2904,8 @@ async function openDevWindow(port, options = {}) {
|
|
|
2855
2904
|
console.warn("\u26A0 Could not spawn craft binary:", binaryErr.message);
|
|
2856
2905
|
}
|
|
2857
2906
|
} else {
|
|
2858
|
-
console.warn("\u26A0
|
|
2859
|
-
console.warn(` (
|
|
2907
|
+
console.warn("\u26A0 craft-native not installed and no craft binary found");
|
|
2908
|
+
console.warn(` (craft-native error: ${tsCraftErr.message})`);
|
|
2860
2909
|
}
|
|
2861
2910
|
if (process3.env.NODE_ENV === "test" || process3.env.BUN_TEST) {
|
|
2862
2911
|
console.log("(Skipping browser fallback in test environment)");
|
|
@@ -2890,7 +2939,7 @@ async function createWindowWithHTML(html, options = {}) {
|
|
|
2890
2939
|
alwaysOnTop = false
|
|
2891
2940
|
} = options;
|
|
2892
2941
|
try {
|
|
2893
|
-
const { createApp } = await import("
|
|
2942
|
+
const { createApp } = await import("craft-native");
|
|
2894
2943
|
const craftPath = getCraftBinaryPath();
|
|
2895
2944
|
const app = createApp({
|
|
2896
2945
|
html,
|
|
@@ -2917,7 +2966,7 @@ async function createWindowWithHTML(html, options = {}) {
|
|
|
2917
2966
|
}
|
|
2918
2967
|
function isWebviewAvailable() {
|
|
2919
2968
|
try {
|
|
2920
|
-
__require.resolve("
|
|
2969
|
+
__require.resolve("craft-native");
|
|
2921
2970
|
return true;
|
|
2922
2971
|
} catch {
|
|
2923
2972
|
return false;
|
|
@@ -2967,6 +3016,8 @@ window.stxWindow = {
|
|
|
2967
3016
|
window.desktop = window.stxWindow;
|
|
2968
3017
|
`;
|
|
2969
3018
|
}
|
|
3019
|
+
// src/packaging.ts
|
|
3020
|
+
import { pack, packageApp } from "craft-native";
|
|
2970
3021
|
// src/power.ts
|
|
2971
3022
|
var currentProcess = null;
|
|
2972
3023
|
var currentInstance = null;
|
|
@@ -3143,7 +3194,7 @@ function formatDuration(minutes) {
|
|
|
3143
3194
|
// src/preferences.ts
|
|
3144
3195
|
import { existsSync as existsSync2, mkdirSync, readFileSync, watch, writeFileSync } from "fs";
|
|
3145
3196
|
import { homedir, platform } from "os";
|
|
3146
|
-
import { dirname, join as join2 } from "path";
|
|
3197
|
+
import { dirname as dirname2, join as join2 } from "path";
|
|
3147
3198
|
function getDefaultPrefsDir(appName) {
|
|
3148
3199
|
const os = platform();
|
|
3149
3200
|
const home = homedir();
|
|
@@ -3168,7 +3219,7 @@ class PreferencesImpl {
|
|
|
3168
3219
|
_writing = false;
|
|
3169
3220
|
constructor(options) {
|
|
3170
3221
|
this._defaults = { ...options.defaults };
|
|
3171
|
-
const dir = options.path ?
|
|
3222
|
+
const dir = options.path ? dirname2(options.path) : getDefaultPrefsDir(options.name);
|
|
3172
3223
|
this._path = options.path || join2(dir, "preferences.json");
|
|
3173
3224
|
if (!existsSync2(dir)) {
|
|
3174
3225
|
mkdirSync(dir, { recursive: true });
|
|
@@ -6264,6 +6315,8 @@ export {
|
|
|
6264
6315
|
permissions,
|
|
6265
6316
|
pdf,
|
|
6266
6317
|
parseShortcut,
|
|
6318
|
+
packageApp,
|
|
6319
|
+
pack,
|
|
6267
6320
|
openDevWindow,
|
|
6268
6321
|
notify,
|
|
6269
6322
|
notifications,
|
|
@@ -6354,6 +6407,7 @@ export {
|
|
|
6354
6407
|
createAutocomplete,
|
|
6355
6408
|
createAccordion,
|
|
6356
6409
|
crashReporter,
|
|
6410
|
+
craftWindowArguments,
|
|
6357
6411
|
coreml,
|
|
6358
6412
|
continuityCamera,
|
|
6359
6413
|
confirm2 as confirm,
|
|
@@ -6376,4 +6430,4 @@ export {
|
|
|
6376
6430
|
AVAILABLE_COMPONENTS
|
|
6377
6431
|
};
|
|
6378
6432
|
|
|
6379
|
-
//# debugId=
|
|
6433
|
+
//# debugId=0C8F609A264ADF9064756E2164756E21
|