craft-native 0.0.348 → 0.0.351

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.
@@ -29,7 +29,7 @@
29
29
  * @returns The string to pass to `spawn(...)`. Either `explicit`,
30
30
  * `process.env.CRAFT_BIN`, or the bare `'craft'` for PATH lookup.
31
31
  */
32
- export declare function resolveCraftBinary(explicit?: string): string;
32
+ export declare function resolveCraftBinary(explicit?: string, profile?: 'full' | 'webview'): string;
33
33
  /**
34
34
  * Set on the child environment whenever the CLI spawns what it believes is
35
35
  * the native binary.
package/dist/cli.js CHANGED
@@ -242,7 +242,9 @@ async function packageApp(config) {
242
242
  return results;
243
243
  }
244
244
  function macOSAppStoreRuntimePath(providerPath) {
245
- const runtime = basename(providerPath) === "craft-app-store" ? providerPath : join2(dirname(providerPath), "craft-app-store");
245
+ const providerName = basename(providerPath);
246
+ const storeName = providerName.startsWith("craft-webview") ? "craft-webview-app-store" : "craft-app-store";
247
+ const runtime = providerName === storeName ? providerPath : join2(dirname(providerPath), storeName);
246
248
  if (!existsSync4(runtime))
247
249
  throw new Error("App Store packaging requires Pantry\u2019s craft-app-store runtime. Upgrade Craft with Pantry before building.");
248
250
  const bytes = readFileSync2(runtime);
@@ -299,6 +301,17 @@ async function packageMacOS(config, outDir) {
299
301
  }
300
302
  try {
301
303
  const contents = join2(appBundlePath, "Contents");
304
+ if (opts.appStore && opts.appBundlePath && existsSync4(join2(contents, "Resources", "craft.json"))) {
305
+ if (!nativeRuntimePath)
306
+ throw new Error("App Store packaging of a prebuilt Craft bundle requires macos.nativeRuntimePath from Pantry.");
307
+ const plist = join2(contents, "Info.plist");
308
+ const executable = spawnSync("plutil", ["-extract", "CFBundleExecutable", "raw", "-o", "-", plist], { encoding: "utf8" });
309
+ const name = executable.stdout.trim();
310
+ if (executable.status !== 0 || !name || basename(name) !== name || name === "." || name === "..")
311
+ throw new Error("Prebuilt Craft bundle has an invalid CFBundleExecutable");
312
+ copyFileSync(nativeRuntimePath, join2(contents, "MacOS", name));
313
+ chmodSync(join2(contents, "MacOS", name), 493);
314
+ }
302
315
  if (opts.provisioningProfile) {
303
316
  const profile = join2(contents, "embedded.provisionprofile");
304
317
  copyFileSync(opts.provisioningProfile, profile);
@@ -343,7 +356,19 @@ async function packageMacOS(config, outDir) {
343
356
  results.push({ success: true, platform: "macos", format: "app", outputPath: appBundlePath });
344
357
  if (opts.dmg !== false) {
345
358
  const outputPath = join2(outDir, `${name}-${version}.dmg`);
346
- const dmgResult = await createDMG({ appBundlePath, outputPath, volumeName: name });
359
+ let dmgResult = await createDMG({ appBundlePath, outputPath, volumeName: name });
360
+ if (dmgResult.success && opts.signIdentity) {
361
+ const signed = await runTool("codesign", codesignArguments({
362
+ path: outputPath,
363
+ identity: opts.signIdentity,
364
+ keychain: opts.signingKeychain,
365
+ hardenedRuntime: false,
366
+ deep: false
367
+ }));
368
+ const verified = signed.success ? await runTool("codesign", ["--verify", "--strict", outputPath]) : signed;
369
+ if (!verified.success)
370
+ dmgResult = { success: false, error: verified.error };
371
+ }
347
372
  results.push({
348
373
  success: dmgResult.success,
349
374
  platform: "macos",
@@ -2947,7 +2972,7 @@ import process6 from "process";
2947
2972
 
2948
2973
  // src/binary-resolver.ts
2949
2974
  import { existsSync as existsSync2 } from "fs";
2950
- function resolveCraftBinary(explicit) {
2975
+ function resolveCraftBinary(explicit, profile = "full") {
2951
2976
  if (explicit) {
2952
2977
  if (!existsSync2(explicit)) {
2953
2978
  throw new Error(`Custom Craft binary path not found: ${explicit}`);
@@ -2961,7 +2986,7 @@ function resolveCraftBinary(explicit) {
2961
2986
  }
2962
2987
  return fromEnv;
2963
2988
  }
2964
- return "craft";
2989
+ return profile === "webview" ? "craft-webview" : "craft";
2965
2990
  }
2966
2991
  var CRAFT_CLI_SPAWN_MARKER = "CRAFT_CLI_SPAWNED_FROM";
2967
2992
  function craftBinaryIsCliShimMessage(spawnedFrom) {
@@ -3022,7 +3047,7 @@ function pinCraftNativeDependency(packagePath, craftVersion) {
3022
3047
  `);
3023
3048
  }
3024
3049
  // package.json
3025
- var version = "0.0.348";
3050
+ var version = "0.0.351";
3026
3051
 
3027
3052
  // bin/cli.ts
3028
3053
  var spawnedFrom = process6.env[CRAFT_CLI_SPAWN_MARKER];
package/dist/index.cjs CHANGED
@@ -341,7 +341,7 @@ var import_node_util = require("node:util");
341
341
 
342
342
  // src/binary-resolver.ts
343
343
  var import_node_fs = require("node:fs");
344
- function resolveCraftBinary(explicit) {
344
+ function resolveCraftBinary(explicit, profile = "full") {
345
345
  if (explicit) {
346
346
  if (!import_node_fs.existsSync(explicit)) {
347
347
  throw new Error(`Custom Craft binary path not found: ${explicit}`);
@@ -355,7 +355,7 @@ function resolveCraftBinary(explicit) {
355
355
  }
356
356
  return fromEnv;
357
357
  }
358
- return "craft";
358
+ return profile === "webview" ? "craft-webview" : "craft";
359
359
  }
360
360
  var CRAFT_CLI_SPAWN_MARKER = "CRAFT_CLI_SPAWNED_FROM";
361
361
  function craftBinaryNotFoundMessage(triedPath) {
@@ -375,7 +375,7 @@ function craftBinaryNotFoundMessage(triedPath) {
375
375
  `);
376
376
  }
377
377
  // package.json
378
- var version = "0.0.348";
378
+ var version = "0.0.351";
379
379
 
380
380
  // src/sdk-version.ts
381
381
  var SDK_VERSION = version;
@@ -608,7 +608,9 @@ async function packageApp(config) {
608
608
  return results;
609
609
  }
610
610
  function macOSAppStoreRuntimePath(providerPath) {
611
- const runtime = import_path.basename(providerPath) === "craft-app-store" ? providerPath : import_path.join(import_path.dirname(providerPath), "craft-app-store");
611
+ const providerName = import_path.basename(providerPath);
612
+ const storeName = providerName.startsWith("craft-webview") ? "craft-webview-app-store" : "craft-app-store";
613
+ const runtime = providerName === storeName ? providerPath : import_path.join(import_path.dirname(providerPath), storeName);
612
614
  if (!import_fs.existsSync(runtime))
613
615
  throw new Error("App Store packaging requires Pantry’s craft-app-store runtime. Upgrade Craft with Pantry before building.");
614
616
  const bytes = import_fs.readFileSync(runtime);
@@ -665,6 +667,17 @@ async function packageMacOS(config, outDir) {
665
667
  }
666
668
  try {
667
669
  const contents = import_path.join(appBundlePath, "Contents");
670
+ if (opts.appStore && opts.appBundlePath && import_fs.existsSync(import_path.join(contents, "Resources", "craft.json"))) {
671
+ if (!nativeRuntimePath)
672
+ throw new Error("App Store packaging of a prebuilt Craft bundle requires macos.nativeRuntimePath from Pantry.");
673
+ const plist = import_path.join(contents, "Info.plist");
674
+ const executable = import_child_process.spawnSync("plutil", ["-extract", "CFBundleExecutable", "raw", "-o", "-", plist], { encoding: "utf8" });
675
+ const name = executable.stdout.trim();
676
+ if (executable.status !== 0 || !name || import_path.basename(name) !== name || name === "." || name === "..")
677
+ throw new Error("Prebuilt Craft bundle has an invalid CFBundleExecutable");
678
+ import_fs.copyFileSync(nativeRuntimePath, import_path.join(contents, "MacOS", name));
679
+ import_fs.chmodSync(import_path.join(contents, "MacOS", name), 493);
680
+ }
668
681
  if (opts.provisioningProfile) {
669
682
  const profile = import_path.join(contents, "embedded.provisionprofile");
670
683
  import_fs.copyFileSync(opts.provisioningProfile, profile);
@@ -709,7 +722,19 @@ async function packageMacOS(config, outDir) {
709
722
  results.push({ success: true, platform: "macos", format: "app", outputPath: appBundlePath });
710
723
  if (opts.dmg !== false) {
711
724
  const outputPath = import_path.join(outDir, `${name}-${version}.dmg`);
712
- const dmgResult = await createDMG({ appBundlePath, outputPath, volumeName: name });
725
+ let dmgResult = await createDMG({ appBundlePath, outputPath, volumeName: name });
726
+ if (dmgResult.success && opts.signIdentity) {
727
+ const signed = await runTool("codesign", codesignArguments({
728
+ path: outputPath,
729
+ identity: opts.signIdentity,
730
+ keychain: opts.signingKeychain,
731
+ hardenedRuntime: false,
732
+ deep: false
733
+ }));
734
+ const verified = signed.success ? await runTool("codesign", ["--verify", "--strict", outputPath]) : signed;
735
+ if (!verified.success)
736
+ dmgResult = { success: false, error: verified.error };
737
+ }
713
738
  results.push({
714
739
  success: dmgResult.success,
715
740
  platform: "macos",
@@ -11785,7 +11810,7 @@ class CraftApp {
11785
11810
  return args;
11786
11811
  }
11787
11812
  async findCraftBinary() {
11788
- return resolveCraftBinary(this.config.craftPath);
11813
+ return resolveCraftBinary(this.config.craftPath, this.config.runtimeProfile);
11789
11814
  }
11790
11815
  }
11791
11816
  function createApp(config) {
package/dist/index.js CHANGED
@@ -83,7 +83,7 @@ import { promisify as promisify2 } from "util";
83
83
 
84
84
  // src/binary-resolver.ts
85
85
  import { existsSync } from "fs";
86
- function resolveCraftBinary(explicit) {
86
+ function resolveCraftBinary(explicit, profile = "full") {
87
87
  if (explicit) {
88
88
  if (!existsSync(explicit)) {
89
89
  throw new Error(`Custom Craft binary path not found: ${explicit}`);
@@ -97,7 +97,7 @@ function resolveCraftBinary(explicit) {
97
97
  }
98
98
  return fromEnv;
99
99
  }
100
- return "craft";
100
+ return profile === "webview" ? "craft-webview" : "craft";
101
101
  }
102
102
  var CRAFT_CLI_SPAWN_MARKER = "CRAFT_CLI_SPAWNED_FROM";
103
103
  function craftBinaryNotFoundMessage(triedPath) {
@@ -117,7 +117,7 @@ function craftBinaryNotFoundMessage(triedPath) {
117
117
  `);
118
118
  }
119
119
  // package.json
120
- var version = "0.0.348";
120
+ var version = "0.0.351";
121
121
 
122
122
  // src/sdk-version.ts
123
123
  var SDK_VERSION = version;
@@ -364,7 +364,9 @@ async function packageApp(config) {
364
364
  return results;
365
365
  }
366
366
  function macOSAppStoreRuntimePath(providerPath) {
367
- const runtime = basename(providerPath) === "craft-app-store" ? providerPath : join2(dirname(providerPath), "craft-app-store");
367
+ const providerName = basename(providerPath);
368
+ const storeName = providerName.startsWith("craft-webview") ? "craft-webview-app-store" : "craft-app-store";
369
+ const runtime = providerName === storeName ? providerPath : join2(dirname(providerPath), storeName);
368
370
  if (!existsSync3(runtime))
369
371
  throw new Error("App Store packaging requires Pantry\u2019s craft-app-store runtime. Upgrade Craft with Pantry before building.");
370
372
  const bytes = readFileSync(runtime);
@@ -421,6 +423,17 @@ async function packageMacOS(config, outDir) {
421
423
  }
422
424
  try {
423
425
  const contents = join2(appBundlePath, "Contents");
426
+ if (opts.appStore && opts.appBundlePath && existsSync3(join2(contents, "Resources", "craft.json"))) {
427
+ if (!nativeRuntimePath)
428
+ throw new Error("App Store packaging of a prebuilt Craft bundle requires macos.nativeRuntimePath from Pantry.");
429
+ const plist = join2(contents, "Info.plist");
430
+ const executable = spawnSync("plutil", ["-extract", "CFBundleExecutable", "raw", "-o", "-", plist], { encoding: "utf8" });
431
+ const name = executable.stdout.trim();
432
+ if (executable.status !== 0 || !name || basename(name) !== name || name === "." || name === "..")
433
+ throw new Error("Prebuilt Craft bundle has an invalid CFBundleExecutable");
434
+ copyFileSync(nativeRuntimePath, join2(contents, "MacOS", name));
435
+ chmodSync(join2(contents, "MacOS", name), 493);
436
+ }
424
437
  if (opts.provisioningProfile) {
425
438
  const profile = join2(contents, "embedded.provisionprofile");
426
439
  copyFileSync(opts.provisioningProfile, profile);
@@ -465,7 +478,19 @@ async function packageMacOS(config, outDir) {
465
478
  results.push({ success: true, platform: "macos", format: "app", outputPath: appBundlePath });
466
479
  if (opts.dmg !== false) {
467
480
  const outputPath = join2(outDir, `${name}-${version}.dmg`);
468
- const dmgResult = await createDMG({ appBundlePath, outputPath, volumeName: name });
481
+ let dmgResult = await createDMG({ appBundlePath, outputPath, volumeName: name });
482
+ if (dmgResult.success && opts.signIdentity) {
483
+ const signed = await runTool("codesign", codesignArguments({
484
+ path: outputPath,
485
+ identity: opts.signIdentity,
486
+ keychain: opts.signingKeychain,
487
+ hardenedRuntime: false,
488
+ deep: false
489
+ }));
490
+ const verified = signed.success ? await runTool("codesign", ["--verify", "--strict", outputPath]) : signed;
491
+ if (!verified.success)
492
+ dmgResult = { success: false, error: verified.error };
493
+ }
469
494
  results.push({
470
495
  success: dmgResult.success,
471
496
  platform: "macos",
@@ -11541,7 +11566,7 @@ class CraftApp {
11541
11566
  return args;
11542
11567
  }
11543
11568
  async findCraftBinary() {
11544
- return resolveCraftBinary(this.config.craftPath);
11569
+ return resolveCraftBinary(this.config.craftPath, this.config.runtimeProfile);
11545
11570
  }
11546
11571
  }
11547
11572
  function createApp(config) {
package/dist/types.d.ts CHANGED
@@ -558,6 +558,8 @@ export interface AppConfig {
558
558
  * Path to Craft binary (auto-detected if not provided)
559
559
  */
560
560
  craftPath?: string;
561
+ /** macOS webview apps may omit the separate headless scripting engine. */
562
+ runtimeProfile?: 'full' | 'webview';
561
563
  /**
562
564
  * Suppress all non-error output from the native binary.
563
565
  * When true, the binary runs with --quiet and stdio is piped.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "craft-native",
3
- "version": "0.0.348",
3
+ "version": "0.0.351",
4
4
  "type": "module",
5
5
  "description": "Build desktop apps with web languages - TypeScript SDK for Craft",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",