@powerhousedao/builder-tools 6.2.3-dev.70 → 6.2.3-dev.72

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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { createRequire } from "node:module";
1
+ import { createRequire, registerHooks } from "node:module";
2
2
  import fs, { chmodSync, cpSync, createReadStream, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, utimesSync, writeFileSync } from "node:fs";
3
3
  import path, { dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
4
4
  import { createLogger, createServer, esmExternalRequirePlugin, loadEnv, normalizePath, searchForWorkspaceRoot } from "vite";
@@ -8,9 +8,10 @@ import { cwd } from "node:process";
8
8
  import { Generator, getConfig } from "@tanstack/router-generator";
9
9
  import { tanstackRouter } from "@tanstack/router-plugin/vite";
10
10
  import { index, layout, physical, rootRoute, route } from "@tanstack/virtual-file-routes";
11
+ import { fileURLToPath, pathToFileURL } from "node:url";
12
+ import { DEFAULT_CONNECT_CONFIG, DYNAMIC_BASE_PLACEHOLDER, EXTERNALIZABLE_SHARED_SPECIFIERS, PWA_FILE_HANDLER_ACTION, buildRuntimeConfig, deepMerge, loadConnectEnv, mapBackgroundImages, mergeManifest, mergePwaConfig, normalizeBasePath, phConnectRuntimeConfigSchema, powerhousePackageSchema, resolveSourceConnect, setConnectEnv, unionStrings, validateBackground, withInferredCategory, workerPackageFileName, workflowsSettingConflict } from "@powerhousedao/shared/connect";
13
+ import { APP_ICON_VARIANT_SIZES, BACKGROUND_MAX_BYTES, PWA_ICON_VARIANT_SIZES, UI_ICON_MAX_BYTES, iconVariantPath, imageMimeType, isPassthroughImageRef, resolveImageRef } from "@powerhousedao/shared/connect/image-ref";
11
14
  import { createHash, randomUUID } from "node:crypto";
12
- import { fileURLToPath } from "node:url";
13
- import { DYNAMIC_BASE_PLACEHOLDER, PWA_FILE_HANDLER_ACTION, buildRuntimeConfig, deepMerge, loadConnectEnv, mergeManifest, mergePwaConfig, normalizeBasePath, phConnectRuntimeConfigSchema, powerhousePackageSchema, resolveSourceConnect, setConnectEnv, unionStrings, withInferredCategory, workerPackageFileName, workflowsSettingConflict } from "@powerhousedao/shared/connect";
14
15
  import MagicString from "magic-string";
15
16
  import { getConfig as getConfig$1 } from "@powerhousedao/config/node";
16
17
  import tailwind from "@tailwindcss/vite";
@@ -237,6 +238,16 @@ function connectRoutesTreeOf(projectRoot, routesDir) {
237
238
  if (isDefaultRoutesDir(projectRoot, routesDir)) return join(projectRoot, CONNECT_ROUTES_GEN);
238
239
  return join(projectRoot, ".ph", `${relative(projectRoot, routesDir)}.gen.ts`);
239
240
  }
241
+ /** The dev watcher's filter for `.ph/`, which holds build output: ignored but
242
+ * for the host's route tree, rewritten as route files come and go. */
243
+ function ignoreDotPhButRouteTree(projectRoot, routesDir) {
244
+ const tree = routesDir && normalizePath(connectRoutesTreeOf(projectRoot, routesDir));
245
+ return (file) => {
246
+ const path = normalizePath(resolve(projectRoot, file));
247
+ if (!path.includes("/.ph/")) return false;
248
+ return !tree || path !== tree && !tree.startsWith(`${path}/`);
249
+ };
250
+ }
240
251
  /** Connect's pathless sidebar layout; a project's routes in `_app/` render in it. */
241
252
  const APP_LAYOUT = "_app";
242
253
  function findRouteFile(dir, name) {
@@ -247,6 +258,10 @@ function findRouteFile(dir, name) {
247
258
  ".js"
248
259
  ].map((ext) => join(dir, `${name}${ext}`)).find((file) => existsSync(file));
249
260
  }
261
+ /** Whether the project's `_app` replaces Connect's layout (and its chrome). */
262
+ function hasProjectAppLayout(routesDir) {
263
+ return !!routesDir && !!findRouteFile(routesDir, "_app");
264
+ }
250
265
  /** Connect's route files: core's routes with Connect's views. */
251
266
  function connectRoutesDirOf(connectDir) {
252
267
  return join(connectDir, "src/routes");
@@ -350,6 +365,13 @@ function writePackageRoutesModule(projectRoot, projectRoutes, routeNodes, option
350
365
  const text = lines.join("\n");
351
366
  if (!existsSync(module) || readFileSync(module, "utf8") !== text) writeFileSync(module, text);
352
367
  }
368
+ /** The `_app/` paths of the generic plugin's code routes, e.g. its settings
369
+ * tabs: a project file at one is an override, never offered. */
370
+ function genericAppRouteIds(connectDir) {
371
+ const file = join(connectDir, "generic-routes.json");
372
+ if (!existsSync(file)) return [];
373
+ return JSON.parse(readFileSync(file, "utf8")).appRoutes ?? [];
374
+ }
353
375
  /** The router plugin's config: Connect's root and routes, and the project's. */
354
376
  function connectRoutesGeneratorConfig(connectDir, projectRoot, projectRoutes) {
355
377
  const routesDirectory = connectRoutesDirOf(connectDir);
@@ -381,7 +403,7 @@ function connectRoutesGeneratorConfig(connectDir, projectRoot, projectRoutes) {
381
403
  onRouteTreeChanged: ({ routeNodes }) => {
382
404
  writePackageRoutesModule(projectRoot, projectRoutes, routeNodes, {
383
405
  routesDirectory,
384
- connectAppIds: new Set(routeFilesIn(join(routesDirectory, APP_LAYOUT)).map(routeIdOf))
406
+ connectAppIds: /* @__PURE__ */ new Set([...routeFilesIn(join(routesDirectory, APP_LAYOUT)).map(routeIdOf), ...genericAppRouteIds(connectDir)])
385
407
  });
386
408
  }
387
409
  }] : [overrides],
@@ -401,17 +423,42 @@ function connectRoutesGeneratorConfig(connectDir, projectRoot, projectRoutes) {
401
423
  ]
402
424
  }, projectRoot);
403
425
  }
426
+ const reported = /* @__PURE__ */ new Map();
427
+ function reportDrops(file, messages) {
428
+ const key = messages.join("\n");
429
+ if (reported.get(file) === key) return;
430
+ reported.set(file, key);
431
+ for (const message of messages) console.warn(`[connect] ${message}`);
432
+ }
404
433
  /** Writes the route tree of Connect's and the project's routes; throws on a
405
434
  * collision that is not an override, which the router plugin would only log. */
406
- async function generateConnectRoutes(projectRoot, routesDir, config = connectRoutesGeneratorConfig(connectDirOf(projectRoot), projectRoot, routesDir)) {
435
+ async function generateConnectRoutes(projectRoot, routesDir, config = connectRoutesGeneratorConfig(connectDirOf(projectRoot), projectRoot, routesDir), warn) {
407
436
  mkdirSync(dirname(config.generatedRouteTree), { recursive: true });
437
+ let routeNodes = [];
438
+ const collect = {
439
+ name: "ph-connect-route-urls",
440
+ onRouteTreeChanged: (tree) => {
441
+ routeNodes = tree.routeNodes;
442
+ }
443
+ };
408
444
  try {
409
445
  await new Generator({
410
- config,
446
+ config: {
447
+ ...config,
448
+ plugins: [...config.plugins ?? [], collect]
449
+ },
411
450
  root: projectRoot
412
451
  }).run();
452
+ assertNoSharedUrls(routeNodes);
413
453
  assertNoDuplicateRoutes(config.generatedRouteTree);
414
454
  importConnectRoutesByPackage(config.generatedRouteTree, config.routesDirectory);
455
+ const drops = dropsContext(projectRoot, routesDir, config.routesDirectory);
456
+ for (const node of routeNodes) {
457
+ const found = dropsOf(node, drops);
458
+ if (!found) continue;
459
+ if (warn) found.messages.forEach(warn);
460
+ else reportDrops(found.file, found.messages);
461
+ }
415
462
  } catch (error) {
416
463
  const message = (Array.isArray(error) ? error : [error]).map((e) => e instanceof Error ? e.message : String(e)).join("\n");
417
464
  const shown = relative(projectRoot, routesDir).split(sep).join("/");
@@ -435,6 +482,72 @@ function assertNoDuplicateRoutes(treeFile) {
435
482
  if (conflicts.length === 0) return;
436
483
  throw new Error(`Conflicting configuration paths were found for a layout route.\nConflicting files: \n ${conflicts.flat().join("\n ")}\n`);
437
484
  }
485
+ const urlOf = (routePath) => `/${routePath.split("/").filter((segment) => segment && !segment.startsWith("_")).join("/")}`;
486
+ function assertNoSharedUrls(routeNodes) {
487
+ const byUrl = /* @__PURE__ */ new Map();
488
+ for (const node of routeNodes) {
489
+ if (node._fsRouteType === "pathless_layout" || !node.routePath) continue;
490
+ const url = urlOf(node.routePath);
491
+ byUrl.set(url, [...byUrl.get(url) ?? [], node.fullPath]);
492
+ }
493
+ const shared = [...byUrl].filter(([, files]) => files.length > 1);
494
+ if (shared.length === 0) return;
495
+ throw new Error(shared.map(([url, files]) => `More than one route serves ${url}; override Connect's in _app/ instead:\n ${files.join("\n ")}`).join("\n"));
496
+ }
497
+ /** The object literal after `key:` in `source`, braces balanced; strings aren't parsed. */
498
+ function objectAfter(source, key) {
499
+ const start = source.search(new RegExp(`\\b${key}\\s*:\\s*\\{`));
500
+ if (start < 0) return void 0;
501
+ const open = source.indexOf("{", start);
502
+ let depth = 0;
503
+ for (let i = open; i < source.length; i++) if (source[i] === "{") depth++;
504
+ else if (source[i] === "}" && --depth === 0) return source.slice(open, i + 1);
505
+ }
506
+ function dropsContext(projectRoot, routesDir, routesDirectory) {
507
+ return {
508
+ projectRoot,
509
+ routesDir,
510
+ routesDirectory,
511
+ connectAppIds: new Set(routeFilesIn(join(routesDirectory, APP_LAYOUT)).map(routeIdOf)),
512
+ genericAppIds: new Set(genericAppRouteIds(dirname(dirname(routesDirectory))))
513
+ };
514
+ }
515
+ /** What the router drops from a project route file without a word: a nav item
516
+ * it can't link, and an override without the options of the route it replaces. */
517
+ function dropsOf(node, context) {
518
+ const file = join(context.routesDirectory, node.filePath);
519
+ if (!file.startsWith(`${context.routesDir}${sep}`) || !existsSync(file)) return;
520
+ const shown = relative(context.projectRoot, file).split(sep).join("/");
521
+ const source = readFileSync(file, "utf8");
522
+ const messages = [];
523
+ const staticData = objectAfter(source, "staticData");
524
+ if (node.routePath?.includes("$") && staticData?.match(/\bnav\s*:/)) messages.push(`${shown}: staticData.nav is ignored on ${node.routePath}, whose params the sidebar can't fill in.`);
525
+ const appDir = join(context.routesDir, APP_LAYOUT);
526
+ if (file.startsWith(`${appDir}${sep}`)) {
527
+ const id = routeIdOf(relative(appDir, file).split(sep).join("/"));
528
+ const connectFile = `@powerhousedao/connect/routes/${APP_LAYOUT}/${id}`;
529
+ if (context.connectAppIds.has(id) && !source.includes(`"${connectFile}"`)) messages.push(`${shown} replaces Connect's route without its options, so what Connect sets on it (loader, search params, pending view, title) is dropped; spread them: import { options } from "${connectFile}".`);
530
+ if (context.genericAppIds.has(id) && !source.includes("genericSettingsTabs")) {
531
+ const tab = id.split("/").at(-1);
532
+ messages.push(`${shown} replaces a settings tab without its options, so the tab isn't listed; spread genericSettingsTabs["${tab}"] from "@powerhousedao/connect/generic".`);
533
+ }
534
+ }
535
+ return {
536
+ file,
537
+ messages
538
+ };
539
+ }
540
+ /** Warns, as Studio regenerates the tree, about each route file it rewrites. */
541
+ function dropsPlugin(projectRoot, routesDir, routesDirectory) {
542
+ const context = dropsContext(projectRoot, routesDir, routesDirectory);
543
+ return {
544
+ name: "ph-connect-silent-drops",
545
+ afterTransform: ({ node }) => {
546
+ const found = dropsOf(node, context);
547
+ if (found) reportDrops(found.file, found.messages);
548
+ }
549
+ };
550
+ }
438
551
  function escapeRegExp(text) {
439
552
  return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
440
553
  }
@@ -449,11 +562,36 @@ async function syncConnectRoutes(projectRoot, routesDir = resolveConnectRoutesDi
449
562
  function connectDirOf(projectRoot) {
450
563
  return dirname(resolvePackage("@powerhousedao/connect/package.json", projectRoot));
451
564
  }
565
+ /** What Connect's route files import, besides each other. */
566
+ const CONNECT_ROUTE_FILE_DEPS = [
567
+ "@tanstack/react-router",
568
+ "@powerhousedao/connect-core/router",
569
+ "@powerhousedao/connect/route-views"
570
+ ];
571
+ const IN_NODE_MODULES = /[\\/]node_modules[\\/]/;
572
+ /**
573
+ * The `optimizeDeps.include` entries an installed Connect's route files need.
574
+ *
575
+ * Connect and core ship their route files as `.tsx`, which Vite never
576
+ * pre-bundles, so the dev server serves them as they are. Vite also discovers
577
+ * no dependency for a module inside node_modules, so their bare imports load
578
+ * unbundled too, and the CommonJS packages under the router
579
+ * (use-sync-external-store, safe-stable-stringify) then fail in the browser.
580
+ * Pre-bundling these by Connect's name gives the route files the copies they
581
+ * resolve to; core need not be resolvable from the project. A Connect outside
582
+ * node_modules (the monorepo, a linked checkout) is source to Vite, so its
583
+ * imports are discovered and pre-bundled anyway.
584
+ */
585
+ function connectRouteFileDeps(connectDir) {
586
+ if (!IN_NODE_MODULES.test(connectDir)) return [];
587
+ return CONNECT_ROUTE_FILE_DEPS.map((dep) => `@powerhousedao/connect > ${dep}`);
588
+ }
452
589
  /** Mounts a project's routes folder over Connect's routes; without one,
453
590
  * Connect keeps its prebuilt tree and no router plugin runs. */
454
591
  function connectRoutes(projectRoot, routesDir = resolveConnectRoutesDir(projectRoot)) {
455
592
  const connectDir = connectDirOf(projectRoot);
456
593
  const find = ROUTE_TREE_FIND;
594
+ const include = connectRouteFileDeps(connectDir);
457
595
  if (!routesDir) {
458
596
  if (!resolveConnectRoutesDir(projectRoot)) rmSync(join(projectRoot, CONNECT_ROUTES_GEN), { force: true });
459
597
  return {
@@ -462,7 +600,8 @@ function connectRoutes(projectRoot, routesDir = resolveConnectRoutesDir(projectR
462
600
  replacement: join(connectDir, "dist/route-tree.js")
463
601
  }],
464
602
  plugins: [],
465
- dedupe: []
603
+ dedupe: [],
604
+ include
466
605
  };
467
606
  }
468
607
  const config = connectRoutesGeneratorConfig(connectDir, projectRoot, routesDir);
@@ -478,8 +617,12 @@ function connectRoutes(projectRoot, routesDir = resolveConnectRoutesDir(projectR
478
617
  plugins: [{
479
618
  name: "ph-connect-routes-check",
480
619
  buildStart: () => generateConnectRoutes(projectRoot, routesDir, config)
481
- }, tanstackRouter(config)],
482
- dedupe: ["@tanstack/react-router"]
620
+ }, tanstackRouter({
621
+ ...config,
622
+ plugins: [...config.plugins ?? [], dropsPlugin(projectRoot, routesDir, config.routesDirectory)]
623
+ })],
624
+ dedupe: ["@tanstack/react-router"],
625
+ include
483
626
  };
484
627
  }
485
628
  const ROUTER_PACKAGES = /[\\/]node_modules[\\/]@tanstack[\\/](react-router|router-core|history|react-store|store)[\\/]/;
@@ -550,6 +693,438 @@ function hostStylesheetPlugin(projectRoot, hostStylesheet) {
550
693
  };
551
694
  }
552
695
  //#endregion
696
+ //#region connect-utils/vite-plugins/node-dedupe.ts
697
+ /** `pkg` is installed for `root`: in a node_modules at or above it. */
698
+ function installedFor(root, pkg) {
699
+ for (let dir = root;; dir = dirname(dir)) {
700
+ if (existsSync(join(dir, "node_modules", pkg, "package.json"))) return true;
701
+ if (dirname(dir) === dir) return false;
702
+ }
703
+ }
704
+ /** `specifier` names `pkg` or one of its subpaths. */
705
+ function names(specifier, pkg) {
706
+ return specifier === pkg || specifier.startsWith(`${pkg}/`);
707
+ }
708
+ /**
709
+ * Runs `fn` with Node's resolution of `packages` (and subpaths) pinned to
710
+ * `root`'s copy. Vite's `resolve.dedupe` reaches only what Vite resolves; an
711
+ * SSR-externalized dependency is loaded by Node from its real path, which for
712
+ * a linked checkout is the checkout's node_modules: two Reacts, and the first
713
+ * hook fails with "reading 'useMemo'". A package `root` lacks keeps its usual
714
+ * resolution.
715
+ */
716
+ async function withNodeDedupe(root, packages, fn) {
717
+ const pinned = packages.filter((pkg) => installedFor(root, pkg));
718
+ if (pinned.length === 0) return fn();
719
+ const rootManifest = join(root, "package.json");
720
+ const parentURL = pathToFileURL(rootManifest).href;
721
+ const rootRequire = createRequire(rootManifest);
722
+ const hooks = registerHooks({ resolve(specifier, context, nextResolve) {
723
+ if (!(context.parentURL !== parentURL && pinned.some((pkg) => names(specifier, pkg)))) return nextResolve(specifier, context);
724
+ if (context.conditions.includes("require")) return {
725
+ url: pathToFileURL(rootRequire.resolve(specifier)).href,
726
+ shortCircuit: true
727
+ };
728
+ return nextResolve(specifier, {
729
+ ...context,
730
+ parentURL
731
+ });
732
+ } });
733
+ try {
734
+ return await fn();
735
+ } finally {
736
+ hooks.deregister();
737
+ }
738
+ }
739
+ //#endregion
740
+ //#region connect-utils/vite-plugins/project-brand.ts
741
+ /** `<meta name>` that tells Connect's loaders which image replaces the logo. */
742
+ const LOADER_META = "ph-loader";
743
+ /** `<meta name>` set when the project's `_app` replaces Connect's layout. */
744
+ const CUSTOM_SHELL_META = "ph-custom-shell";
745
+ const DEFAULT_LOADER_SIZE = 96;
746
+ const DEFAULT_BRANDING = DEFAULT_CONNECT_CONFIG.branding ?? {};
747
+ /**
748
+ * The branding in effect: defaults < source powerhouse.config.json <
749
+ * CLI / host override, applied in that order. In every layer `undefined`
750
+ * leaves the field alone and `null` resets it to the default, so a null in a
751
+ * later layer beats a value in an earlier one. Keys branding does not have
752
+ * (a `homeBackground` from before it moved to `connect.home`) are dropped.
753
+ */
754
+ function effectiveBranding(...layers) {
755
+ const out = { ...DEFAULT_BRANDING };
756
+ const defaults = DEFAULT_BRANDING;
757
+ for (const layer of layers) {
758
+ if (!layer) continue;
759
+ const entries = Object.entries(layer);
760
+ for (const [key, value] of entries) {
761
+ if (value === void 0 || !(key in defaults)) continue;
762
+ out[key] = value === null ? defaults[key] ?? null : value;
763
+ }
764
+ }
765
+ out.appName = (typeof out.appName === "string" ? out.appName.trim() : void 0) || DEFAULT_BRANDING.appName;
766
+ return out;
767
+ }
768
+ /**
769
+ * The `branding` block Connect reads at boot: the app icon reduced to its
770
+ * 64 px variant as a data URI (the in-app logo; a master would be ~1 MB of
771
+ * base64), the loader left out (it is served as a file and declared in
772
+ * index.html). Fields without a usable image end up null.
773
+ */
774
+ function resolveRuntimeBranding(projectRoot, branding, warn) {
775
+ const out = {
776
+ appName: branding.appName ?? DEFAULT_BRANDING.appName,
777
+ icon: null,
778
+ loader: null
779
+ };
780
+ if (branding.icon) {
781
+ const logo = iconVariantPath(projectRoot, branding.icon, 64);
782
+ out.icon = resolveImageRef(projectRoot, logo ?? branding.icon, {
783
+ maxBytes: UI_ICON_MAX_BYTES,
784
+ warn
785
+ }) ?? null;
786
+ }
787
+ return out;
788
+ }
789
+ /**
790
+ * A pane's background with every image, in both colour schemes, resolved to
791
+ * a data URI: a single image stays a single image, layers stay layers (a
792
+ * layer without a usable image is dropped). Problems the renderer cannot
793
+ * fix are warned about: a layer pinned to both edges of an axis, an SVG
794
+ * without a viewBox (its aspect is unknown, so it needs both dimensions).
795
+ */
796
+ function resolveBackground(projectRoot, background, warn) {
797
+ if (!background) return null;
798
+ for (const problem of validateBackground(background, "homeBackground")) warn?.(`[branding] ${problem}`);
799
+ const resolveOne = (ref) => {
800
+ if (!isPassthroughImageRef(ref) && extname(ref).toLowerCase() === ".svg") warnWithoutViewBox(projectRoot, ref, warn);
801
+ return resolveImageRef(projectRoot, ref, {
802
+ maxBytes: BACKGROUND_MAX_BYTES,
803
+ warn
804
+ });
805
+ };
806
+ if (typeof background === "string") return resolveOne(background) ?? null;
807
+ return mapBackgroundImages(background, resolveOne);
808
+ }
809
+ function warnWithoutViewBox(projectRoot, ref, warn) {
810
+ const file = resolve(projectRoot, ref);
811
+ if (!existsSync(file)) return;
812
+ const head = readFileSync(file, "utf8").slice(0, 4096);
813
+ if (!/<svg[^>]*\sviewBox\s*=/i.test(head)) warn?.(`[branding] ${ref} has no viewBox, so its aspect is unknown: give the layer both width and height.`);
814
+ }
815
+ const EXPLORER_ICON_KEYS = [
816
+ "localDrive",
817
+ "remoteDrive",
818
+ "folder",
819
+ "document"
820
+ ];
821
+ /**
822
+ * The drive explorer's icons with every path resolved to a data URI; a key
823
+ * without a usable image is dropped (the built-in icon), an empty or null
824
+ * set is null.
825
+ */
826
+ function resolveExplorerIcons(projectRoot, icons, warn) {
827
+ if (!icons) return null;
828
+ const ui = {
829
+ maxBytes: UI_ICON_MAX_BYTES,
830
+ warn
831
+ };
832
+ const out = {};
833
+ for (const key of EXPLORER_ICON_KEYS) {
834
+ const src = resolveImageRef(projectRoot, icons[key], ui);
835
+ if (src) out[key] = src;
836
+ }
837
+ if (icons.documents) {
838
+ const documents = {};
839
+ for (const [type, ref] of Object.entries(icons.documents)) {
840
+ const src = resolveImageRef(projectRoot, ref, ui);
841
+ if (src) documents[type] = src;
842
+ }
843
+ if (Object.keys(documents).length > 0) out.documents = documents;
844
+ }
845
+ return Object.keys(out).length > 0 ? out : null;
846
+ }
847
+ /** A generic plugin entry whose config carries images to resolve. */
848
+ function hasGenericImages(entry) {
849
+ return entry.module === "@powerhousedao/connect/plugins/generic" && entry.config !== void 0 && ("icons" in entry.config || "homeBackground" in entry.config);
850
+ }
851
+ /**
852
+ * A connect block with the generic plugin's images resolved, wherever they
853
+ * are declared: `drives.icons` and `home.background` (the classic source
854
+ * values) and the generic plugin entry's `icons` / `homeBackground` in a
855
+ * served composition (the owner under uniform runners). Unchanged when none
856
+ * is present.
857
+ */
858
+ function withResolvedGenericImages(projectRoot, connect, warn) {
859
+ if (!connect) return connect;
860
+ let out = connect;
861
+ if (connect.drives && "icons" in connect.drives) out = {
862
+ ...out,
863
+ drives: {
864
+ ...out.drives,
865
+ icons: resolveExplorerIcons(projectRoot, connect.drives.icons, warn)
866
+ }
867
+ };
868
+ if (connect.home && "background" in connect.home) out = {
869
+ ...out,
870
+ home: {
871
+ ...out.home,
872
+ background: resolveBackground(projectRoot, connect.home.background, warn)
873
+ }
874
+ };
875
+ if (connect.composition?.some(hasGenericImages)) out = {
876
+ ...out,
877
+ composition: connect.composition.map((entry) => {
878
+ if (!hasGenericImages(entry)) return entry;
879
+ const config = { ...entry.config };
880
+ if ("icons" in config) config.icons = resolveExplorerIcons(projectRoot, config.icons, warn);
881
+ if ("homeBackground" in config) config.homeBackground = resolveBackground(projectRoot, config.homeBackground, warn);
882
+ return {
883
+ ...entry,
884
+ config
885
+ };
886
+ })
887
+ };
888
+ return out;
889
+ }
890
+ const IMAGE_TYPES = {
891
+ ".png": "image/png",
892
+ ".svg": "image/svg+xml",
893
+ ".webp": "image/webp",
894
+ ".gif": "image/gif",
895
+ ".jpg": "image/jpeg",
896
+ ".jpeg": "image/jpeg"
897
+ };
898
+ function projectFile(projectRoot, ref) {
899
+ return isAbsolute(ref) ? ref : resolve(projectRoot, ref);
900
+ }
901
+ function asset(projectRoot, ref, fileName, warn) {
902
+ if (isPassthroughImageRef(ref)) {
903
+ warn?.(`[branding] ${ref}: use a project file path here, not a URL. Skipped.`);
904
+ return;
905
+ }
906
+ const file = projectFile(projectRoot, ref);
907
+ const ext = extname(file).toLowerCase();
908
+ const contentType = IMAGE_TYPES[ext];
909
+ if (!contentType) {
910
+ warn?.(`[branding] ${ref}: unsupported image type. Skipped.`);
911
+ return;
912
+ }
913
+ if (!existsSync(file)) {
914
+ warn?.(`[branding] ${ref}: file not found. Skipped.`);
915
+ return;
916
+ }
917
+ return {
918
+ fileName: fileName(ext),
919
+ file,
920
+ contentType
921
+ };
922
+ }
923
+ /** `branding.loader` as the build emits it; undefined keeps Connect's logo. */
924
+ function resolveProjectLoader(projectRoot, branding, warn) {
925
+ const loader = branding?.loader;
926
+ if (!loader) return void 0;
927
+ const spec = typeof loader === "string" ? { src: loader } : loader;
928
+ const found = asset(projectRoot, spec.src, (ext) => `ph-loader${ext}`, warn);
929
+ if (!found) return void 0;
930
+ return {
931
+ ...found,
932
+ animation: spec.animation ?? "pulse",
933
+ size: spec.size ?? DEFAULT_LOADER_SIZE
934
+ };
935
+ }
936
+ /** Width and height from a PNG's IHDR chunk. */
937
+ function pngSize(bytes) {
938
+ if (bytes.length < 24 || [
939
+ 137,
940
+ 80,
941
+ 78,
942
+ 71,
943
+ 13,
944
+ 10,
945
+ 26,
946
+ 10
947
+ ].some((b, i) => bytes[i] !== b)) return;
948
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
949
+ return [view.getUint32(16), view.getUint32(20)];
950
+ }
951
+ /** The installed app's name and icons, from `branding.appName` and
952
+ * `branding.icon`. Undefined members keep Connect's own. */
953
+ function resolveProjectPwaBrand(projectRoot, branding, warn) {
954
+ const brand = {};
955
+ const name = branding?.appName?.trim();
956
+ if (name && name !== DEFAULT_BRANDING.appName) brand.name = name;
957
+ const app = branding?.icon;
958
+ if (!app) return brand;
959
+ const ext = extname(app).toLowerCase();
960
+ if (ext === ".svg") {
961
+ const svg = asset(projectRoot, app, () => "pwa-app.svg", warn);
962
+ if (svg) brand.icons = [{
963
+ ...svg,
964
+ sizes: "any"
965
+ }];
966
+ return brand;
967
+ }
968
+ if (ext !== ".png") {
969
+ warn?.(`[branding] icon ${app}: the installed-app icon needs a PNG or SVG. Connect's icon stays.`);
970
+ return brand;
971
+ }
972
+ const icons = [];
973
+ const seen = /* @__PURE__ */ new Set();
974
+ const add = (ref) => {
975
+ const file = projectFile(projectRoot, ref);
976
+ if (!existsSync(file)) return;
977
+ const size = pngSize(readFileSync(file));
978
+ if (!size) return;
979
+ const sizes = `${size[0]}x${size[1]}`;
980
+ if (seen.has(sizes)) return;
981
+ seen.add(sizes);
982
+ icons.push({
983
+ fileName: `pwa-app-${sizes}.png`,
984
+ file,
985
+ contentType: "image/png",
986
+ sizes
987
+ });
988
+ };
989
+ const stem = app.slice(0, app.length - ext.length);
990
+ for (const size of PWA_ICON_VARIANT_SIZES) add(`${stem}_${size}x${size}${ext}`);
991
+ add(app);
992
+ if (icons.length === 0) {
993
+ warn?.(`[branding] icon ${app}: not a readable PNG. Connect's icon stays.`);
994
+ return brand;
995
+ }
996
+ brand.icons = icons;
997
+ return brand;
998
+ }
999
+ /**
1000
+ * The favicons: the `_16x16` / `_32x32` / `_64x64` siblings of
1001
+ * `branding.icon` (an SVG master is one scalable favicon). They replace
1002
+ * Connect's static icon.ico link in index.html; none keeps it. A favicon
1003
+ * named outright (`faviconPath`: `branding.favicon` or `--favicon`) wins: it
1004
+ * is built as icon.ico (or icon.svg, icon.png), so the icon's siblings stand aside.
1005
+ */
1006
+ function resolveProjectFavicons(projectRoot, branding, warn, faviconPath) {
1007
+ const app = branding?.icon;
1008
+ if (!app || faviconPath) return [];
1009
+ if (isPassthroughImageRef(app)) {
1010
+ warn?.(`[branding] icon ${app}: use a project file path here, not a URL. Connect's favicon stays.`);
1011
+ return [];
1012
+ }
1013
+ const ext = extname(app).toLowerCase();
1014
+ if (ext === ".svg") {
1015
+ const svg = asset(projectRoot, app, () => "favicon.svg", warn);
1016
+ return svg ? [{
1017
+ ...svg,
1018
+ sizes: "any"
1019
+ }] : [];
1020
+ }
1021
+ const out = [];
1022
+ for (const size of APP_ICON_VARIANT_SIZES) {
1023
+ const variant = iconVariantPath(projectRoot, app, size);
1024
+ if (!variant) continue;
1025
+ const file = projectFile(projectRoot, variant);
1026
+ const contentType = imageMimeType(file);
1027
+ if (!contentType) continue;
1028
+ out.push({
1029
+ fileName: `favicon-${size}x${size}${ext}`,
1030
+ file,
1031
+ contentType,
1032
+ sizes: `${size}x${size}`
1033
+ });
1034
+ }
1035
+ if (out.length === 0) warn?.(`[branding] icon ${app}: no _16x16 / _32x32 / _64x64 siblings found. Connect's favicon stays.`);
1036
+ return out;
1037
+ }
1038
+ function escapeAttr(value) {
1039
+ return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
1040
+ }
1041
+ /** The `<meta>` tags Connect's loaders read. */
1042
+ function brandMetaTags(options) {
1043
+ const tags = [];
1044
+ const { loader } = options;
1045
+ if (loader) tags.push(`<meta name="${LOADER_META}" content="${escapeAttr(loader.fileName)}" data-animation="${loader.animation}" data-size="${loader.size}">`);
1046
+ if (options.customShell) tags.push(`<meta name="${CUSTOM_SHELL_META}" content="true">`);
1047
+ return tags.join("");
1048
+ }
1049
+ const ICON_LINK = /<link\b[^>]*\brel=["']?(?:shortcut )?icon["']?[^>]*>\s*/gi;
1050
+ /** index.html with Connect's icon links replaced by the project's favicons
1051
+ * (one sized link per variant, under `base`); unchanged without any. */
1052
+ function withProjectFavicons(html, favicons, base = "/") {
1053
+ if (favicons.length === 0) return html;
1054
+ const prefix = base.endsWith("/") ? base : `${base}/`;
1055
+ const links = favicons.map((icon) => `<link rel="icon" type="${icon.contentType}" sizes="${icon.sizes}" href="${escapeAttr(prefix + icon.fileName)}" />`).join("");
1056
+ return html.replace(ICON_LINK, "").replace("</head>", `${links}</head>`);
1057
+ }
1058
+ /** Keyframes for the loader motions; shared by the shell and the app. */
1059
+ const LOADER_KEYFRAMES = "@keyframes ph-loader-pulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.6;transform:scale(.94)}}@keyframes ph-loader-spin{to{transform:rotate(360deg)}}";
1060
+ const LOADER_ANIMATION = {
1061
+ pulse: "ph-loader-pulse 1.6s ease-in-out infinite",
1062
+ spin: "ph-loader-spin 1.4s linear infinite",
1063
+ none: "none"
1064
+ };
1065
+ /** The loader as static markup, for the prerendered shell's first paint. */
1066
+ function loaderMarkup(loader, base = "/") {
1067
+ const prefix = base.endsWith("/") ? base : `${base}/`;
1068
+ const motion = LOADER_ANIMATION[loader.animation];
1069
+ return `<style>${LOADER_KEYFRAMES}@media (prefers-reduced-motion:reduce){[data-ph-loader-img]{animation:none!important}}</style><img data-ph-loader-img src="${escapeAttr(prefix + loader.fileName)}" alt="" width="${loader.size}" style="width:${loader.size}px;height:auto;animation:${motion}">`;
1070
+ }
1071
+ /** The marked slot in Connect's prerendered shell that holds its logo. */
1072
+ const LOADER_SLOT = /<div\b[^>]*\bdata-ph-loader-slot\b[^>]*>[\s\S]*?<\/div>/;
1073
+ /** Swaps the shell's logo slot for the project's loader. */
1074
+ function replaceShellLoader(shellBody, loader, base = "/") {
1075
+ return shellBody.replace(LOADER_SLOT, () => loaderMarkup(loader, base));
1076
+ }
1077
+ /**
1078
+ * Serves (dev) and emits (build) the branding files, and adds the tags
1079
+ * index.html carries before any JavaScript: the loader and custom-shell
1080
+ * meta tags, and the favicon links.
1081
+ */
1082
+ function connectProjectBrandPlugin(options) {
1083
+ const favicons = options.favicons ?? [];
1084
+ const files = [
1085
+ ...options.loader ? [options.loader] : [],
1086
+ ...options.pwaIcons ?? [],
1087
+ ...favicons
1088
+ ];
1089
+ const meta = brandMetaTags(options);
1090
+ let base = "/";
1091
+ return {
1092
+ name: "ph-connect-project-brand",
1093
+ configResolved(config) {
1094
+ base = config.base;
1095
+ },
1096
+ configureServer(server) {
1097
+ for (const file of files) {
1098
+ const handler = (_req, res, next) => {
1099
+ try {
1100
+ res.setHeader("Content-Type", file.contentType);
1101
+ res.end(readFileSync(file.file));
1102
+ } catch {
1103
+ next();
1104
+ }
1105
+ };
1106
+ const paths = /* @__PURE__ */ new Set([`${server.config.base}${file.fileName}`.replace(/\/{2,}/g, "/"), `/${file.fileName}`]);
1107
+ for (const path of paths) server.middlewares.use(path, handler);
1108
+ }
1109
+ },
1110
+ transformIndexHtml(html) {
1111
+ return withProjectFavicons(meta ? html.replace("</head>", `${meta}</head>`) : html, favicons, base);
1112
+ },
1113
+ generateBundle(_options, bundle) {
1114
+ for (const file of files) {
1115
+ if (file.fileName in bundle) continue;
1116
+ try {
1117
+ this.emitFile({
1118
+ type: "asset",
1119
+ fileName: file.fileName,
1120
+ source: readFileSync(file.file)
1121
+ });
1122
+ } catch {}
1123
+ }
1124
+ }
1125
+ };
1126
+ }
1127
+ //#endregion
553
1128
  //#region connect-utils/vite-plugins/app-shell.ts
554
1129
  /** On the prerendered shell's elements; marks an index.html that has it. */
555
1130
  const APP_SHELL_MARKER = "data-ph-shell";
@@ -672,6 +1247,7 @@ function swapAppShell(html, shell, base = "/", appName) {
672
1247
  return html.replace(REGION("head"), () => region("head", shell.head)).replace(REGION("body"), () => region("body", body));
673
1248
  }
674
1249
  const DEV_SHELL_WAIT_MS = 1e4;
1250
+ const CONNECT_PACKAGES = ["@powerhousedao/connect", "@powerhousedao/connect-core"];
675
1251
  async function renderProjectAppShells(projectRoot, config, routeAliases, hostStylesheet) {
676
1252
  const server = await createServer({
677
1253
  configFile: false,
@@ -696,31 +1272,70 @@ async function renderProjectAppShells(projectRoot, config, routeAliases, hostSty
696
1272
  include: [],
697
1273
  entries: []
698
1274
  },
699
- ssr: { optimizeDeps: {
700
- noDiscovery: true,
701
- include: []
702
- } }
1275
+ ssr: {
1276
+ optimizeDeps: {
1277
+ noDiscovery: true,
1278
+ include: []
1279
+ },
1280
+ noExternal: CONNECT_PACKAGES
1281
+ }
703
1282
  });
704
1283
  try {
705
- const renderer = await server.ssrLoadModule("@powerhousedao/connect/prerender");
706
- const stylesheet = join(projectRoot, "style.css");
707
- const css = withHostStylesheet(readFileSync(stylesheet, "utf8"), stylesheet, hostStylesheet);
708
- return await renderer.renderProjectShells(stylesheet, css);
1284
+ return await withNodeDedupe(projectRoot, config.resolve.dedupe, async () => {
1285
+ const renderer = await server.ssrLoadModule("@powerhousedao/connect/prerender");
1286
+ const stylesheet = join(projectRoot, "style.css");
1287
+ const css = withHostStylesheet(readFileSync(stylesheet, "utf8"), stylesheet, hostStylesheet);
1288
+ try {
1289
+ return await renderer.renderProjectShells(stylesheet, css);
1290
+ } catch (error) {
1291
+ throw withSourceLocations(error, (stack) => server.ssrRewriteStacktrace(stack));
1292
+ }
1293
+ });
709
1294
  } finally {
710
1295
  await server.close();
711
1296
  }
712
1297
  }
1298
+ const RENDER_LOCATION = /\(at (\S+) \((.+?):(\d+):(\d+)\)\)/g;
1299
+ /** The prerender's error with each `(at <component> (<file>:<line>:<col>))` in
1300
+ * its message mapped back to the source, as React reports the transformed code. */
1301
+ function withSourceLocations(error, rewrite) {
1302
+ if (!(error instanceof Error)) return error;
1303
+ const before = error.message;
1304
+ const after = before.replace(RENDER_LOCATION, (found, name, file, line, column) => {
1305
+ const frame = /^ {4}at .*?\(?(\S+?):(\d+):(\d+)\)?$/.exec(rewrite(` at ${name} (${file}:${line}:${column})`));
1306
+ return frame ? `(at ${name} (${frame[1]}:${frame[2]}:${frame[3]}))` : found;
1307
+ });
1308
+ if (after !== before) {
1309
+ error.message = after;
1310
+ if (error.stack) error.stack = error.stack.replace(before, after);
1311
+ }
1312
+ return error;
1313
+ }
1314
+ /** Vite's error overlay over the page, for a failure no module request reports. */
1315
+ function withErrorOverlay(html, err, base) {
1316
+ const script = `<script type="module">import { ErrorOverlay } from "${base}@vite/client";document.body.appendChild(new ErrorOverlay(${JSON.stringify(err).replaceAll("<", "\\u003c")}));<\/script>`;
1317
+ return html.replace("</body>", `${script}</body>`);
1318
+ }
713
1319
  const sourceText = (source) => typeof source === "string" ? source : new TextDecoder().decode(source);
714
1320
  /** Build: the composition's shell in #root and every variant in the dist, from
715
1321
  * the project's routes when it has them. Dev: the shell from the project's routes
716
1322
  * when it has them, else core's for a core composition. */
717
- function connectAppShellPlugin(projectRoot, { composition, appName, routeAliases, routesDir, hostStylesheet } = {}) {
1323
+ function connectAppShellPlugin(projectRoot, { composition, appName, routeAliases, routesDir, loader, hostStylesheet } = {}) {
718
1324
  let variant = "generic";
719
1325
  let shells = {};
720
1326
  let shellPlugins;
721
1327
  let base = "/";
722
1328
  let isBuild = true;
723
1329
  let config;
1330
+ const withLoader = (from) => {
1331
+ if (!loader) return from;
1332
+ const out = {};
1333
+ for (const [name, shell] of Object.entries(from)) out[name] = {
1334
+ ...shell,
1335
+ body: replaceShellLoader(shell.body, loader, base)
1336
+ };
1337
+ return out;
1338
+ };
724
1339
  const fromRoutes = () => isBuild && !!routeAliases;
725
1340
  const shell = () => {
726
1341
  if (fromRoutes()) return void 0;
@@ -728,11 +1343,27 @@ function connectAppShellPlugin(projectRoot, { composition, appName, routeAliases
728
1343
  };
729
1344
  let devShells;
730
1345
  let devRender;
1346
+ let devShellError;
1347
+ let devServer;
731
1348
  const renderDevShells = () => {
732
1349
  if (!config || !routeAliases) return;
733
1350
  const logger = config.logger;
734
- devShells = renderProjectAppShells(projectRoot, config, routeAliases, hostStylesheet).catch((error) => {
735
- logger.warn(`[connect] the loading shell failed to render from the project's routes: ${String(error)}`);
1351
+ devShellError = void 0;
1352
+ devShells = renderProjectAppShells(projectRoot, config, routeAliases, hostStylesheet).then((rendered) => {
1353
+ devShellError = void 0;
1354
+ return withLoader(rendered);
1355
+ }, (error) => {
1356
+ const cause = error instanceof Error ? error : new Error(String(error));
1357
+ devShellError = {
1358
+ message: `The loading shell failed to render from the project's routes, and the build will fail on it:\n${cause.message}`,
1359
+ stack: cause.stack ?? "",
1360
+ plugin: "ph-connect-app-shell"
1361
+ };
1362
+ logger.error(`[connect] ${devShellError.message}`, { timestamp: true });
1363
+ devServer?.ws.send({
1364
+ type: "error",
1365
+ err: devShellError
1366
+ });
736
1367
  return {};
737
1368
  });
738
1369
  };
@@ -752,6 +1383,7 @@ function connectAppShellPlugin(projectRoot, { composition, appName, routeAliases
752
1383
  name: "ph-connect-app-shell",
753
1384
  configureServer(server) {
754
1385
  if (!routeAliases) return;
1386
+ devServer = server;
755
1387
  renderDevShells();
756
1388
  const stylesheet = join(projectRoot, "style.css");
757
1389
  const rerender = (file) => {
@@ -767,7 +1399,7 @@ function connectAppShellPlugin(projectRoot, { composition, appName, routeAliases
767
1399
  config = resolved;
768
1400
  base = resolved.base;
769
1401
  isBuild = resolved.command === "build";
770
- shells = readAppShells(projectRoot);
1402
+ shells = withLoader(readAppShells(projectRoot));
771
1403
  shellPlugins = readShellPlugins(projectRoot);
772
1404
  variant = appShellVariant(composition, shellPlugins);
773
1405
  },
@@ -775,10 +1407,11 @@ function connectAppShellPlugin(projectRoot, { composition, appName, routeAliases
775
1407
  order: "post",
776
1408
  handler: async (html) => {
777
1409
  const current = !isBuild && routeAliases ? await devShell() : shell();
778
- return current ? injectAppShell(html, current, base, {
1410
+ const page = current ? injectAppShell(html, current, base, {
779
1411
  deferStyles: isBuild,
780
1412
  appName
781
1413
  }) : html;
1414
+ return devShellError ? withErrorOverlay(page, devShellError, base) : page;
782
1415
  }
783
1416
  },
784
1417
  generateBundle: {
@@ -786,7 +1419,7 @@ function connectAppShellPlugin(projectRoot, { composition, appName, routeAliases
786
1419
  async handler(_options, bundle) {
787
1420
  if (!isBuild) return;
788
1421
  if (fromRoutes() && config && routeAliases) {
789
- shells = await renderProjectAppShells(projectRoot, config, routeAliases, hostStylesheet);
1422
+ shells = withLoader(await renderProjectAppShells(projectRoot, config, routeAliases, hostStylesheet));
790
1423
  const index = bundle["index.html"];
791
1424
  const current = shells[variant];
792
1425
  if (index?.type === "asset" && current) index.source = injectAppShell(sourceText(index.source), current, base, { appName });
@@ -2466,6 +3099,25 @@ const runtimeConfigSchema = {
2466
3099
  connect: phConnectRuntimeConfigSchema
2467
3100
  }
2468
3101
  };
3102
+ //#endregion
3103
+ //#region connect-utils/dev-deps.ts
3104
+ /** Pre-bundled deps for Connect's dev server, scanning the project's routes. */
3105
+ function connectOptimizeDeps(projectRoot, routesDir, routeFileDeps) {
3106
+ const routes = routesDir && relative(projectRoot, routesDir).replaceAll("\\", "/");
3107
+ return {
3108
+ ...routes ? { entries: ["index.html", `${routes}/**/*.{js,jsx,ts,tsx}`] } : {},
3109
+ include: [
3110
+ "document-model",
3111
+ "zod",
3112
+ "@powerhousedao/design-system/connect",
3113
+ "@powerhousedao/reactor-browser",
3114
+ "@powerhousedao/document-engineering",
3115
+ ...routeFileDeps
3116
+ ],
3117
+ exclude: ["@electric-sql/pglite", "@electric-sql/pglite-tools"],
3118
+ rolldownOptions: { external: [ROUTE_TREE_SPECIFIER, CORE_ROUTE_TREE_SPECIFIER] }
3119
+ };
3120
+ }
2469
3121
  const RESOLVED_VIRTUAL_ID = "\0virtual:ph-bundled-packages-virtual";
2470
3122
  const BUNDLED_PACKAGES_DEV_URL = "@id/" + RESOLVED_VIRTUAL_ID.replace("\0", "__x00__");
2471
3123
  function readBundledPackageVersion(projectRoot, name) {
@@ -2530,7 +3182,13 @@ const REACT_DEPS = [
2530
3182
  "react-dom/client"
2531
3183
  ];
2532
3184
  const SHIM_PATH = "__ph/dev-react-shim/";
2533
- const VITE_DEPS_PATH = "node_modules/.vite/deps";
3185
+ const SHARED_SHIM = "ph-shared:";
3186
+ const SHARED_DEPS = EXTERNALIZABLE_SHARED_SPECIFIERS.filter((spec) => !REACT_DEPS.includes(spec));
3187
+ /** The page's import map entries for the shared deps: each root and its subpaths. */
3188
+ function sharedDepImports(base) {
3189
+ const url = (spec) => withBase$1(base, `@id/__x00__${SHARED_SHIM}${spec}`);
3190
+ return Object.fromEntries(SHARED_DEPS.flatMap((spec) => [[spec, url(spec)], [`${spec}/`, `${url(spec)}/`]]));
3191
+ }
2534
3192
  const VENDOR_MIME = {
2535
3193
  ".css": "text/css",
2536
3194
  ".map": "application/json",
@@ -2551,6 +3209,19 @@ const VENDOR_MODE = process.env.PH_CONNECT_EXTERNALIZE_VENDOR === "1";
2551
3209
  const VENDOR_EXTRA = (process.env.PH_CONNECT_VENDOR_EXTRA ?? "").split(",").map((s) => s.trim()).filter(Boolean);
2552
3210
  const HEAVY_LIBS = [...DEFAULT_VENDOR_INCLUDE, ...VENDOR_EXTRA];
2553
3211
  const heavyLibsFor = (routesDir) => routesDir ? HEAVY_LIBS.filter((lib) => lib !== "@powerhousedao/connect") : HEAVY_LIBS;
3212
+ /** The dev server's URL for a file: under the root, else through `/@fs/`. */
3213
+ function devUrlOf(root, file) {
3214
+ const relativePath = path.relative(root, file);
3215
+ return relativePath.startsWith("..") || path.isAbsolute(relativePath) ? `/@fs/${file.split(path.sep).join("/").replace(/^\/+/, "")}` : relativePath.split(path.sep).join("/");
3216
+ }
3217
+ /** A file of Connect's package, else the root: where Connect's own imports resolve from. */
3218
+ function connectImporter(root) {
3219
+ try {
3220
+ return createRequire(path.join(root, "package.json")).resolve("@powerhousedao/connect/package.json");
3221
+ } catch {
3222
+ return path.join(root, "index.html");
3223
+ }
3224
+ }
2554
3225
  function withBase$1(base, p) {
2555
3226
  return `${base}${p}`.replace(/\/{2,}/g, "/");
2556
3227
  }
@@ -2589,6 +3260,7 @@ function externalizePlugin(externals) {
2589
3260
  async function devReactImportmapPlugin(projectRoot = process.cwd(), routesDir = resolveConnectRoutesDir(projectRoot)) {
2590
3261
  let namedExports = /* @__PURE__ */ new Map();
2591
3262
  let base = "/";
3263
+ let root = projectRoot;
2592
3264
  let vendor = null;
2593
3265
  const heavyLibs = heavyLibsFor(routesDir);
2594
3266
  if (VENDOR_MODE) {
@@ -2609,6 +3281,16 @@ async function devReactImportmapPlugin(projectRoot = process.cwd(), routesDir =
2609
3281
  const main = {
2610
3282
  name: "ph-dev-react-importmap",
2611
3283
  apply: "serve",
3284
+ async resolveId(source, importer) {
3285
+ if (source.startsWith(SHARED_SHIM)) return `\0${source}`;
3286
+ if (source.startsWith(`\0${SHARED_SHIM}`)) return source;
3287
+ if (importer?.startsWith(`\0${SHARED_SHIM}`)) return this.resolve(source, connectImporter(root), { skipSelf: true });
3288
+ },
3289
+ load(id) {
3290
+ if (!id.startsWith(`\0${SHARED_SHIM}`)) return void 0;
3291
+ const spec = JSON.stringify(id.slice(11));
3292
+ return `export * from ${spec};\nimport * as M from ${spec};\nexport default M.default;\n`;
3293
+ },
2612
3294
  config(cfg) {
2613
3295
  cfg.optimizeDeps ??= {};
2614
3296
  const include = new Set(cfg.optimizeDeps.include ?? []);
@@ -2621,6 +3303,7 @@ async function devReactImportmapPlugin(projectRoot = process.cwd(), routesDir =
2621
3303
  },
2622
3304
  configResolved(config) {
2623
3305
  base = config.base;
3306
+ root = config.root;
2624
3307
  },
2625
3308
  configureServer(server) {
2626
3309
  const requireFromRoot = createRequire(path.join(server.config.root, "package.json"));
@@ -2670,7 +3353,7 @@ async function devReactImportmapPlugin(projectRoot = process.cwd(), routesDir =
2670
3353
  return;
2671
3354
  }
2672
3355
  const browserHash = info.browserHash ?? optimizer.metadata.browserHash;
2673
- const depUrl = `${withBase$1(base, VITE_DEPS_PATH)}/${path.basename(info.file)}?v=${browserHash}`;
3356
+ const depUrl = `${withBase$1(base, devUrlOf(root, info.file))}?v=${browserHash}`;
2674
3357
  const names = namedExports.get(id) ?? [];
2675
3358
  res.setHeader("Content-Type", "application/javascript");
2676
3359
  res.end(`import * as M from ${JSON.stringify(depUrl)};\nconst ns = M.default ?? M;\nexport default ns;\n` + (names.length ? `export const { ${names.join(", ")} } = ns;\n` : ""));
@@ -2683,6 +3366,7 @@ async function devReactImportmapPlugin(projectRoot = process.cwd(), routesDir =
2683
3366
  if (!browserHash) return;
2684
3367
  const shimPrefix = withBase$1(base, SHIM_PATH);
2685
3368
  const imports = Object.fromEntries(REACT_DEPS.map((id) => [id, `${shimPrefix}${id}.js?v=${browserHash}`]));
3369
+ Object.assign(imports, sharedDepImports(base));
2686
3370
  let dynamicBaseScript = "";
2687
3371
  if (vendorActive) {
2688
3372
  for (const [spec, url] of Object.entries(vendor.imports)) imports[spec] = withBase$1(base, url);
@@ -2705,16 +3389,20 @@ const CONTENT_TYPE_BY_EXT = {
2705
3389
  /**
2706
3390
  * Vite plugin to serve the Connect favicon (icon.ico) from the connect package,
2707
3391
  * or from a caller-supplied file when `faviconPath` is set (e.g. `ph connect
2708
- * build --favicon`). The served/emitted name is always `icon.ico` so the static
2709
- * `<link rel="icon" href="%BASE_URL%icon.ico">` in index.html stays valid.
3392
+ * build --favicon`). An .svg or .png keeps its type as icon.svg or icon.png,
3393
+ * and index.html's `<link rel="icon">` is rewritten to it; browsers decode a
3394
+ * file named icon.ico as an ICO.
2710
3395
  */
2711
3396
  function connectFaviconPlugin(opts = {}) {
2712
3397
  const customPath = opts.faviconPath ? isAbsolute(opts.faviconPath) ? opts.faviconPath : resolve(process.cwd(), opts.faviconPath) : void 0;
2713
- const customContentType = customPath ? CONTENT_TYPE_BY_EXT[extname(customPath).toLowerCase()] ?? "image/x-icon" : "image/x-icon";
3398
+ const ext = customPath ? extname(customPath).toLowerCase() : ".ico";
3399
+ const customContentType = CONTENT_TYPE_BY_EXT[ext] ?? "image/x-icon";
3400
+ const fileName = ext === ".svg" || ext === ".png" ? `icon${ext}` : "icon.ico";
2714
3401
  return {
2715
3402
  name: "copy-connect-favicon",
2716
3403
  configureServer(server) {
2717
- const faviconRoute = `${server.config.base}icon.ico`.replace(/\/{2,}/g, "/");
3404
+ const base = server.config.base;
3405
+ const route = (name) => `${base}${name}`.replace(/\/{2,}/g, "/");
2718
3406
  const handler = (_req, res, next) => {
2719
3407
  if (customPath) {
2720
3408
  try {
@@ -2731,12 +3419,21 @@ function connectFaviconPlugin(opts = {}) {
2731
3419
  res.end(readFileSync(resolved.id));
2732
3420
  }).catch(() => next());
2733
3421
  };
2734
- const paths = /* @__PURE__ */ new Set([faviconRoute, "/icon.ico"]);
3422
+ const paths = /* @__PURE__ */ new Set([
3423
+ route(fileName),
3424
+ `/${fileName}`,
3425
+ route("icon.ico"),
3426
+ "/icon.ico"
3427
+ ]);
2735
3428
  for (const path of paths) server.middlewares.use(path, handler);
2736
3429
  },
3430
+ transformIndexHtml(html) {
3431
+ if (fileName === "icon.ico") return html;
3432
+ return html.replace(/<link rel="icon" href="([^"]*)icon\.ico"\s*\/?>/, `<link rel="icon" type="${customContentType}" href="$1${fileName}" />`);
3433
+ },
2737
3434
  async generateBundle(_options, bundle) {
2738
3435
  try {
2739
- if ("icon.ico" in bundle) return;
3436
+ if (fileName in bundle) return;
2740
3437
  let source;
2741
3438
  if (customPath) source = readFileSync(customPath);
2742
3439
  else {
@@ -2746,7 +3443,7 @@ function connectFaviconPlugin(opts = {}) {
2746
3443
  if (!source) return;
2747
3444
  this.emitFile({
2748
3445
  type: "asset",
2749
- fileName: "icon.ico",
3446
+ fileName,
2750
3447
  source
2751
3448
  });
2752
3449
  } catch {}
@@ -2791,7 +3488,10 @@ function phConfigPlugin(options) {
2791
3488
  const source = {
2792
3489
  packages: options.packages,
2793
3490
  packageRegistryUrl: options.packageRegistryUrl,
2794
- connect: mergedConnect.branding ? {
3491
+ connect: options.branding ? {
3492
+ ...mergedConnect,
3493
+ branding: options.branding
3494
+ } : mergedConnect.branding ? {
2795
3495
  ...mergedConnect,
2796
3496
  branding
2797
3497
  } : mergedConnect
@@ -2828,7 +3528,7 @@ function phConfigPlugin(options) {
2828
3528
  }
2829
3529
  },
2830
3530
  transformIndexHtml(html) {
2831
- return withAppTitle(html, runtimeConfig.connect.branding?.appName);
3531
+ return withAppTitle(html, runtimeConfig.connect.branding?.appName ?? void 0);
2832
3532
  },
2833
3533
  generateBundle() {
2834
3534
  this.emitFile({
@@ -3103,6 +3803,28 @@ const BASE_MANIFEST = {
3103
3803
  launch_handler: { client_mode: "focus-existing" }
3104
3804
  };
3105
3805
  /**
3806
+ * The base manifest under the project's own name and icons (from
3807
+ * `connect.branding.appName` / `icons.app`), so an installed app is not
3808
+ * "Powerhouse Connect". Connect's description goes with its name; a project
3809
+ * that wants one sets `connect.pwa.manifest.description`, which — like the
3810
+ * rest of `connect.pwa` — is laid on top of this.
3811
+ */
3812
+ function brandManifest(base, brand) {
3813
+ if (!brand) return base;
3814
+ const manifest = { ...base };
3815
+ if (brand.name) {
3816
+ manifest.name = brand.name;
3817
+ manifest.short_name = brand.name;
3818
+ delete manifest.description;
3819
+ }
3820
+ if (brand.icons?.length) manifest.icons = brand.icons.map((icon) => ({
3821
+ src: icon.fileName,
3822
+ sizes: icon.sizes,
3823
+ type: icon.contentType
3824
+ }));
3825
+ return manifest;
3826
+ }
3827
+ /**
3106
3828
  * Connect's hardcoded precache config — the base layer for the `injectManifest`
3107
3829
  * precache. Overridable additively (extra globs) or by raising the size ceiling
3108
3830
  * via package/project `pwa` config. The rest of the old Workbox config
@@ -3177,7 +3899,7 @@ function phSwConfigPlugin(data) {
3177
3899
  * clears its caches on the browser's next service-worker update check.
3178
3900
  */
3179
3901
  function connectPwaPlugins(options) {
3180
- const { offlineEnabled, pwa } = options;
3902
+ const { offlineEnabled, pwa, brand } = options;
3181
3903
  if (!offlineEnabled) return [VitePWA({
3182
3904
  selfDestroying: true,
3183
3905
  strategies: "generateSW",
@@ -3186,7 +3908,7 @@ function connectPwaPlugins(options) {
3186
3908
  devOptions: { enabled: false }
3187
3909
  })];
3188
3910
  const { manifest, precache } = applyPwaOverrides({
3189
- manifest: BASE_MANIFEST,
3911
+ manifest: brandManifest(BASE_MANIFEST, brand),
3190
3912
  precache: BASE_PRECACHE
3191
3913
  }, pwa ?? {});
3192
3914
  const swConfig = {
@@ -3725,15 +4447,6 @@ function getConnectBaseViteConfig(options) {
3725
4447
  const phPackages = (phPackagesStr ? parsePackagesEnvOverride(phPackagesStr) : void 0) ?? packagesFromConfig;
3726
4448
  const phPackageRegistryUrl = options.cliPackageRegistryUrl ?? phConfig.packageRegistryUrl ?? null;
3727
4449
  const connectBasePath = options.cliConnectOverride?.app?.basePath ?? phConfig.connect?.app?.basePath;
3728
- const configPlugin = phConfigPlugin({
3729
- packages: phPackages,
3730
- projectRoot: options.dirname,
3731
- connect: phConfig.connect,
3732
- workflows: phConfig.workflows,
3733
- packageRegistryUrl: phPackageRegistryUrl ?? void 0,
3734
- cliConnectOverride: options.cliConnectOverride
3735
- });
3736
- const servedConnect = configPlugin.api.connect;
3737
4450
  const offlineEnabled = options.cliConnectOverride?.app?.offline ?? phConfig.connect?.app?.offline ?? true;
3738
4451
  const authToken = env.PH_SENTRY_AUTH_TOKEN;
3739
4452
  const org = env.PH_SENTRY_ORG;
@@ -3782,6 +4495,25 @@ function getConnectBaseViteConfig(options) {
3782
4495
  const projectPwa = validateProjectPwaConfig(deepMerge(phConfig.connect?.pwa ?? {}, options.cliConnectOverride?.pwa ?? {}), phConfigPath);
3783
4496
  const pwaWarn = (msg) => (customLogger ?? console).warn(msg);
3784
4497
  const pwaPackagesForFragments = mode === "production" ? phPackages : phPackages.filter((p) => p.provider === "local");
4498
+ const brandWarn = (msg) => (customLogger ?? console).warn(msg);
4499
+ const branding = effectiveBranding(phConfig.connect?.branding, options.cliConnectOverride?.branding);
4500
+ const projectLoader = resolveProjectLoader(options.dirname, branding, brandWarn);
4501
+ const projectBrand = resolveProjectPwaBrand(options.dirname, branding, brandWarn);
4502
+ const runtimeBranding = resolveRuntimeBranding(options.dirname, branding, brandWarn);
4503
+ const sourceConnect = withResolvedGenericImages(options.dirname, phConfig.connect, brandWarn);
4504
+ const connectOverride = withResolvedGenericImages(options.dirname, options.cliConnectOverride, brandWarn);
4505
+ const configPlugin = phConfigPlugin({
4506
+ packages: phPackages,
4507
+ projectRoot: options.dirname,
4508
+ connect: sourceConnect,
4509
+ workflows: phConfig.workflows,
4510
+ packageRegistryUrl: phPackageRegistryUrl ?? void 0,
4511
+ cliConnectOverride: connectOverride,
4512
+ branding: runtimeBranding
4513
+ });
4514
+ const servedConnect = configPlugin.api.connect;
4515
+ const faviconPath = options.favicon ?? configPlugin.api.favicon;
4516
+ const projectFavicons = resolveProjectFavicons(options.dirname, branding, brandWarn, faviconPath);
3785
4517
  const pwaPlugins = (async () => {
3786
4518
  if (!offlineEnabled) return connectPwaPlugins({ offlineEnabled });
3787
4519
  const contributions = await collectPackagePwaContributions({
@@ -3795,7 +4527,8 @@ function getConnectBaseViteConfig(options) {
3795
4527
  const mergedPwa = mergePwaConfig(contributions, projectPwa, pwaWarn);
3796
4528
  return connectPwaPlugins({
3797
4529
  offlineEnabled,
3798
- pwa: mergedPwa
4530
+ pwa: mergedPwa,
4531
+ brand: projectBrand
3799
4532
  });
3800
4533
  })();
3801
4534
  const reactExternal = [
@@ -3817,13 +4550,19 @@ function getConnectBaseViteConfig(options) {
3817
4550
  }).filter((p) => p !== null);
3818
4551
  const routesDir = resolveConnectRoutesDir(options.dirname, options.routes) ?? false;
3819
4552
  const routes = connectRoutes(options.dirname, routesDir);
4553
+ const customShell = hasProjectAppLayout(routesDir || void 0);
3820
4554
  const hostStylesheet = hostStylesheetPath(options.dirname, routesDir);
3821
4555
  return {
3822
4556
  configFile: false,
3823
4557
  mode,
4558
+ cacheDir: options.cacheDir,
3824
4559
  base: options.dynamicBase ? DYNAMIC_BASE_PLACEHOLDER : connectBasePath ? normalizeBasePath(connectBasePath) : void 0,
3825
4560
  server: {
3826
- watch: { ignored: ["**/backup-documents/**", "**/.ph/**"] },
4561
+ watch: { ignored: [
4562
+ "**/backup-documents/**",
4563
+ "**/coverage/**",
4564
+ ignoreDotPhButRouteTree(options.dirname, routesDir)
4565
+ ] },
3827
4566
  fs: { allow: [searchForWorkspaceRoot(options.dirname), ...linkedRoots] }
3828
4567
  },
3829
4568
  resolve: {
@@ -3843,16 +4582,7 @@ function getConnectBaseViteConfig(options) {
3843
4582
  },
3844
4583
  customLogger,
3845
4584
  envPrefix: ["PH_CONNECT_"],
3846
- optimizeDeps: {
3847
- include: [
3848
- "document-model",
3849
- "zod",
3850
- "@powerhousedao/design-system/connect",
3851
- "@powerhousedao/reactor-browser",
3852
- "@powerhousedao/document-engineering"
3853
- ],
3854
- exclude: ["@electric-sql/pglite", "@electric-sql/pglite-tools"]
3855
- },
4585
+ optimizeDeps: connectOptimizeDeps(options.dirname, routesDir, routes.include),
3856
4586
  plugins: [
3857
4587
  configPlugin,
3858
4588
  hostStylesheetPlugin(options.dirname, hostStylesheet),
@@ -3870,15 +4600,22 @@ function getConnectBaseViteConfig(options) {
3870
4600
  dev: mode !== "production" || isDebug
3871
4601
  }),
3872
4602
  ...options.vendor && mode === "production" ? [vendorImportMapPlugin({ imports: options.vendor.imports })] : [],
3873
- connectFaviconPlugin({ faviconPath: options.favicon ?? configPlugin.api.favicon }),
4603
+ connectFaviconPlugin({ faviconPath }),
3874
4604
  connectThemeBootPlugin(),
3875
4605
  connectAppShellPlugin(options.dirname, {
3876
4606
  composition: servedConnect.composition,
3877
- appName: servedConnect.branding?.appName,
4607
+ appName: servedConnect.branding?.appName ?? void 0,
3878
4608
  routeAliases: routesDir ? routes.aliases : void 0,
3879
4609
  routesDir: routesDir || void 0,
4610
+ loader: projectLoader,
3880
4611
  hostStylesheet
3881
4612
  }),
4613
+ connectProjectBrandPlugin({
4614
+ loader: projectLoader,
4615
+ pwaIcons: offlineEnabled ? projectBrand.icons : void 0,
4616
+ favicons: projectFavicons,
4617
+ customShell
4618
+ }),
3882
4619
  connectBuildHashPlugin(buildHash),
3883
4620
  ...options.dynamicBase ? [connectDynamicBasePlugin()] : [],
3884
4621
  pwaPlugins
@@ -3897,6 +4634,6 @@ function getConnectBaseViteConfig(options) {
3897
4634
  };
3898
4635
  }
3899
4636
  //#endregion
3900
- export { APP_LAYOUT, APP_SHELLS_FILE, APP_SHELL_MARKER, BOOT_RECOVER_KEY, BOOT_RECOVER_MARKER, BOOT_RECOVER_SCRIPT, BUILDER_TOOLS_VERSION, BUILD_HASH_FILE, CONNECT_ROUTES_GEN, CONNECT_ROUTES_SPECIFIER, CORE_ROUTE_TREE_SPECIFIER, DEFAULT_APP_NAME, DEFAULT_CONNECT_OUTDIR, DEFAULT_VENDOR_INCLUDE, DYNAMIC_BASE_PLACEHOLDER, EXTERNAL_PACKAGES_IMPORT, HOST_ROUTES_DIR, IMPORT_SCRIPT_FILE, LOCAL_PACKAGE_ID, LOCK_STALE_MS, PACKAGE_ROUTES_MODULE, PH_DIR_NAME, REACTOR_WORKER_ENTRY, REACTOR_WORKER_MIME, REACTOR_WORKER_URL_PREFIX, ROUTE_TREE_SPECIFIER, RUNTIME_CONFIG_SCHEMA_ID, RUNTIME_CONFIG_SCHEMA_URL, SHELL_PLUGINS_FILE, THEME_BOOT_MARKER, VENDOR_EXTERNAL, VENDOR_SKIP_SUBPATHS, VENDOR_URL_PREFIX, WORKER_PACKAGES_MANIFEST, acquireLock, appShellVariant, appShellVariantOf, appendToHtmlHead, backupIndexHtml, buildHashFromBuildOptions, computeBuildHash, computeSourceDigest, connectAppShellPlugin, connectBuildHashPlugin, connectDynamicBasePlugin, connectRouterChunkGroups, connectRoutes, connectRoutesDirOf, connectRoutesGeneratorConfig, connectRoutesTreeOf, connectThemeBootPlugin, copyConnect, directoryContentDigest, distDirFingerprint, ensureNodeVersion, escapeForRegExp, findBundleSpecifierOffenders, findDisallowedSpecifiers, findPackageRoot, findWorkerUnsafeMarkers, generateConnectRoutes, getConnectBaseViteConfig, getConnectHtmlTags, hostStylesheetPath, hostStylesheetPlugin, injectAppShell, linkedBuildStamp, makeImportScriptFromPackages, missingVendorEntries, overriddenConnectRoutes, ownProjectPackage, phConfigPlugin, prebuildConnectVendor, prebuildReactorWorker, prebuildWorkerPackages, prependToHtmlHead, publishDirAtomic, readAppShell, readAppShells, readJsonFile, readShellPlugins, readShellPluginsIn, rebaseShellLinks, relativeCssUrls, releaseLock, removeBase64EnvValues, resolveConnectBundle, resolveConnectPackageJson, resolveConnectPublicDir, resolveConnectRoutesDir, resolveOwnDeps, resolveOwnPackageVersion, resolvePackage, resolveReactorWorkerSource, resolveVersionDigest, resolveViteConfigPath, resolveWorkspacePackageDir, routeIdOf, runShellScriptPlugin, runTsc, runWorkerBuildEntries, runtimeConfigSchema, stripVersionFromPackage, swapAppShell, syncConnectRoutes, upstreamWorkerPackages, vendorImportMapPlugin, vendorRelativePath, withAppTitle, withHostStylesheet, withShellAppName, withVendorBase, workerSafeVendorImports };
4637
+ export { APP_LAYOUT, APP_SHELLS_FILE, APP_SHELL_MARKER, BOOT_RECOVER_KEY, BOOT_RECOVER_MARKER, BOOT_RECOVER_SCRIPT, BUILDER_TOOLS_VERSION, BUILD_HASH_FILE, CONNECT_ROUTES_GEN, CONNECT_ROUTES_SPECIFIER, CONNECT_ROUTE_FILE_DEPS, CORE_ROUTE_TREE_SPECIFIER, DEFAULT_APP_NAME, DEFAULT_CONNECT_OUTDIR, DEFAULT_VENDOR_INCLUDE, DYNAMIC_BASE_PLACEHOLDER, EXTERNAL_PACKAGES_IMPORT, HOST_ROUTES_DIR, IMPORT_SCRIPT_FILE, LOCAL_PACKAGE_ID, LOCK_STALE_MS, PACKAGE_ROUTES_MODULE, PH_DIR_NAME, REACTOR_WORKER_ENTRY, REACTOR_WORKER_MIME, REACTOR_WORKER_URL_PREFIX, ROUTE_TREE_SPECIFIER, RUNTIME_CONFIG_SCHEMA_ID, RUNTIME_CONFIG_SCHEMA_URL, SHELL_PLUGINS_FILE, THEME_BOOT_MARKER, VENDOR_EXTERNAL, VENDOR_SKIP_SUBPATHS, VENDOR_URL_PREFIX, WORKER_PACKAGES_MANIFEST, acquireLock, appShellVariant, appShellVariantOf, appendToHtmlHead, backupIndexHtml, buildHashFromBuildOptions, computeBuildHash, computeSourceDigest, connectAppShellPlugin, connectBuildHashPlugin, connectDynamicBasePlugin, connectRouteFileDeps, connectRouterChunkGroups, connectRoutes, connectRoutesDirOf, connectRoutesGeneratorConfig, connectRoutesTreeOf, connectThemeBootPlugin, copyConnect, directoryContentDigest, distDirFingerprint, ensureNodeVersion, escapeForRegExp, findBundleSpecifierOffenders, findDisallowedSpecifiers, findPackageRoot, findWorkerUnsafeMarkers, generateConnectRoutes, getConnectBaseViteConfig, getConnectHtmlTags, hasProjectAppLayout, hostStylesheetPath, hostStylesheetPlugin, ignoreDotPhButRouteTree, injectAppShell, linkedBuildStamp, makeImportScriptFromPackages, missingVendorEntries, overriddenConnectRoutes, ownProjectPackage, phConfigPlugin, prebuildConnectVendor, prebuildReactorWorker, prebuildWorkerPackages, prependToHtmlHead, publishDirAtomic, readAppShell, readAppShells, readJsonFile, readShellPlugins, readShellPluginsIn, rebaseShellLinks, relativeCssUrls, releaseLock, removeBase64EnvValues, resolveConnectBundle, resolveConnectPackageJson, resolveConnectPublicDir, resolveConnectRoutesDir, resolveOwnDeps, resolveOwnPackageVersion, resolvePackage, resolveReactorWorkerSource, resolveVersionDigest, resolveViteConfigPath, resolveWorkspacePackageDir, routeIdOf, runShellScriptPlugin, runTsc, runWorkerBuildEntries, runtimeConfigSchema, stripVersionFromPackage, swapAppShell, syncConnectRoutes, upstreamWorkerPackages, vendorImportMapPlugin, vendorRelativePath, withAppTitle, withErrorOverlay, withHostStylesheet, withShellAppName, withSourceLocations, withVendorBase, workerSafeVendorImports };
3901
4638
 
3902
4639
  //# sourceMappingURL=index.mjs.map