MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / previewSourceModule

Function previewSourceModule

scripts/experimental/swiftui-preview.mjs:450–482  ·  view source on GitHub ↗
(context, sanitizedSource, args, xcode)

Source from the content-addressed store, hash-verified

448}
449
450function previewSourceModule(context, sanitizedSource, args, xcode) {
451 const extraSwift = arrayArg(args.extraSwift);
452 if (extraSwift.length > 0) {
453 console.warn(
454 "[simdeck-preview] warning: --split-compile currently falls back when --extra-swift is used.",
455 );
456 return null;
457 }
458 const swiftcArgs = [...xcodeSwiftcArgs(xcode), ...arrayArg(args.swiftcArg)];
459 const hash = crypto
460 .createHash("sha256")
461 .update(context.target)
462 .update("\0")
463 .update(context.sdkPath)
464 .update("\0")
465 .update(xcode?.moduleName ?? "")
466 .update("\0")
467 .update(swiftcArgs.join("\0"))
468 .update("\0")
469 .update(sanitizedSource)
470 .digest("hex")
471 .slice(0, 16);
472 const directory = path.join(context.buildRoot, "source-cache", hash);
473 return {
474 directory,
475 moduleName: `SimDeckPreviewSource_${hash}`,
476 modulePath: path.join(
477 directory,
478 `SimDeckPreviewSource_${hash}.swiftmodule`,
479 ),
480 objectPath: path.join(directory, `SimDeckPreviewSource_${hash}.o`),
481 };
482}
483
484function compilePreviewSourceModule(
485 context,

Callers 1

reloadPreviewFunction · 0.85

Calls 4

arrayArgFunction · 0.85
xcodeSwiftcArgsFunction · 0.85
warnMethod · 0.80
updateMethod · 0.65

Tested by

no test coverage detected