@powerhousedao/builder-tools 6.2.3-dev.70 → 6.2.3-dev.71
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.mts +46 -646
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +555 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
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, 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";
|
|
@@ -247,6 +248,10 @@ function findRouteFile(dir, name) {
|
|
|
247
248
|
".js"
|
|
248
249
|
].map((ext) => join(dir, `${name}${ext}`)).find((file) => existsSync(file));
|
|
249
250
|
}
|
|
251
|
+
/** Whether the project's `_app` replaces Connect's layout (and its chrome). */
|
|
252
|
+
function hasProjectAppLayout(routesDir) {
|
|
253
|
+
return !!routesDir && !!findRouteFile(routesDir, "_app");
|
|
254
|
+
}
|
|
250
255
|
/** Connect's route files: core's routes with Connect's views. */
|
|
251
256
|
function connectRoutesDirOf(connectDir) {
|
|
252
257
|
return join(connectDir, "src/routes");
|
|
@@ -449,11 +454,32 @@ async function syncConnectRoutes(projectRoot, routesDir = resolveConnectRoutesDi
|
|
|
449
454
|
function connectDirOf(projectRoot) {
|
|
450
455
|
return dirname(resolvePackage("@powerhousedao/connect/package.json", projectRoot));
|
|
451
456
|
}
|
|
457
|
+
/** What Connect's route files import, besides each other. */
|
|
458
|
+
const CONNECT_ROUTE_FILE_DEPS = ["@tanstack/react-router", "@powerhousedao/connect-core/router"];
|
|
459
|
+
const IN_NODE_MODULES = /[\\/]node_modules[\\/]/;
|
|
460
|
+
/**
|
|
461
|
+
* The `optimizeDeps.include` entries an installed Connect's route files need.
|
|
462
|
+
*
|
|
463
|
+
* Connect and core ship their route files as `.tsx`, which Vite never
|
|
464
|
+
* pre-bundles, so the dev server serves them as they are. Vite also discovers
|
|
465
|
+
* no dependency for a module inside node_modules, so their bare imports load
|
|
466
|
+
* unbundled too, and the CommonJS packages under the router
|
|
467
|
+
* (use-sync-external-store, safe-stable-stringify) then fail in the browser.
|
|
468
|
+
* Pre-bundling these by Connect's name gives the route files the copies they
|
|
469
|
+
* resolve to; core need not be resolvable from the project. A Connect outside
|
|
470
|
+
* node_modules (the monorepo, a linked checkout) is source to Vite, so its
|
|
471
|
+
* imports are discovered and pre-bundled anyway.
|
|
472
|
+
*/
|
|
473
|
+
function connectRouteFileDeps(connectDir) {
|
|
474
|
+
if (!IN_NODE_MODULES.test(connectDir)) return [];
|
|
475
|
+
return CONNECT_ROUTE_FILE_DEPS.map((dep) => `@powerhousedao/connect > ${dep}`);
|
|
476
|
+
}
|
|
452
477
|
/** Mounts a project's routes folder over Connect's routes; without one,
|
|
453
478
|
* Connect keeps its prebuilt tree and no router plugin runs. */
|
|
454
479
|
function connectRoutes(projectRoot, routesDir = resolveConnectRoutesDir(projectRoot)) {
|
|
455
480
|
const connectDir = connectDirOf(projectRoot);
|
|
456
481
|
const find = ROUTE_TREE_FIND;
|
|
482
|
+
const include = connectRouteFileDeps(connectDir);
|
|
457
483
|
if (!routesDir) {
|
|
458
484
|
if (!resolveConnectRoutesDir(projectRoot)) rmSync(join(projectRoot, CONNECT_ROUTES_GEN), { force: true });
|
|
459
485
|
return {
|
|
@@ -462,7 +488,8 @@ function connectRoutes(projectRoot, routesDir = resolveConnectRoutesDir(projectR
|
|
|
462
488
|
replacement: join(connectDir, "dist/route-tree.js")
|
|
463
489
|
}],
|
|
464
490
|
plugins: [],
|
|
465
|
-
dedupe: []
|
|
491
|
+
dedupe: [],
|
|
492
|
+
include
|
|
466
493
|
};
|
|
467
494
|
}
|
|
468
495
|
const config = connectRoutesGeneratorConfig(connectDir, projectRoot, routesDir);
|
|
@@ -479,7 +506,8 @@ function connectRoutes(projectRoot, routesDir = resolveConnectRoutesDir(projectR
|
|
|
479
506
|
name: "ph-connect-routes-check",
|
|
480
507
|
buildStart: () => generateConnectRoutes(projectRoot, routesDir, config)
|
|
481
508
|
}, tanstackRouter(config)],
|
|
482
|
-
dedupe: ["@tanstack/react-router"]
|
|
509
|
+
dedupe: ["@tanstack/react-router"],
|
|
510
|
+
include
|
|
483
511
|
};
|
|
484
512
|
}
|
|
485
513
|
const ROUTER_PACKAGES = /[\\/]node_modules[\\/]@tanstack[\\/](react-router|router-core|history|react-store|store)[\\/]/;
|
|
@@ -550,6 +578,438 @@ function hostStylesheetPlugin(projectRoot, hostStylesheet) {
|
|
|
550
578
|
};
|
|
551
579
|
}
|
|
552
580
|
//#endregion
|
|
581
|
+
//#region connect-utils/vite-plugins/node-dedupe.ts
|
|
582
|
+
/** `pkg` is installed for `root`: in a node_modules at or above it. */
|
|
583
|
+
function installedFor(root, pkg) {
|
|
584
|
+
for (let dir = root;; dir = dirname(dir)) {
|
|
585
|
+
if (existsSync(join(dir, "node_modules", pkg, "package.json"))) return true;
|
|
586
|
+
if (dirname(dir) === dir) return false;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
/** `specifier` names `pkg` or one of its subpaths. */
|
|
590
|
+
function names(specifier, pkg) {
|
|
591
|
+
return specifier === pkg || specifier.startsWith(`${pkg}/`);
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Runs `fn` with Node's resolution of `packages` (and subpaths) pinned to
|
|
595
|
+
* `root`'s copy. Vite's `resolve.dedupe` reaches only what Vite resolves; an
|
|
596
|
+
* SSR-externalized dependency is loaded by Node from its real path, which for
|
|
597
|
+
* a linked checkout is the checkout's node_modules: two Reacts, and the first
|
|
598
|
+
* hook fails with "reading 'useMemo'". A package `root` lacks keeps its usual
|
|
599
|
+
* resolution.
|
|
600
|
+
*/
|
|
601
|
+
async function withNodeDedupe(root, packages, fn) {
|
|
602
|
+
const pinned = packages.filter((pkg) => installedFor(root, pkg));
|
|
603
|
+
if (pinned.length === 0) return fn();
|
|
604
|
+
const rootManifest = join(root, "package.json");
|
|
605
|
+
const parentURL = pathToFileURL(rootManifest).href;
|
|
606
|
+
const rootRequire = createRequire(rootManifest);
|
|
607
|
+
const hooks = registerHooks({ resolve(specifier, context, nextResolve) {
|
|
608
|
+
if (!(context.parentURL !== parentURL && pinned.some((pkg) => names(specifier, pkg)))) return nextResolve(specifier, context);
|
|
609
|
+
if (context.conditions.includes("require")) return {
|
|
610
|
+
url: pathToFileURL(rootRequire.resolve(specifier)).href,
|
|
611
|
+
shortCircuit: true
|
|
612
|
+
};
|
|
613
|
+
return nextResolve(specifier, {
|
|
614
|
+
...context,
|
|
615
|
+
parentURL
|
|
616
|
+
});
|
|
617
|
+
} });
|
|
618
|
+
try {
|
|
619
|
+
return await fn();
|
|
620
|
+
} finally {
|
|
621
|
+
hooks.deregister();
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
//#endregion
|
|
625
|
+
//#region connect-utils/vite-plugins/project-brand.ts
|
|
626
|
+
/** `<meta name>` that tells Connect's loaders which image replaces the logo. */
|
|
627
|
+
const LOADER_META = "ph-loader";
|
|
628
|
+
/** `<meta name>` set when the project's `_app` replaces Connect's layout. */
|
|
629
|
+
const CUSTOM_SHELL_META = "ph-custom-shell";
|
|
630
|
+
const DEFAULT_LOADER_SIZE = 96;
|
|
631
|
+
const DEFAULT_BRANDING = DEFAULT_CONNECT_CONFIG.branding ?? {};
|
|
632
|
+
/**
|
|
633
|
+
* The branding in effect: defaults < source powerhouse.config.json <
|
|
634
|
+
* CLI / host override, applied in that order. In every layer `undefined`
|
|
635
|
+
* leaves the field alone and `null` resets it to the default, so a null in a
|
|
636
|
+
* later layer beats a value in an earlier one. Keys branding does not have
|
|
637
|
+
* (a `homeBackground` from before it moved to `connect.home`) are dropped.
|
|
638
|
+
*/
|
|
639
|
+
function effectiveBranding(...layers) {
|
|
640
|
+
const out = { ...DEFAULT_BRANDING };
|
|
641
|
+
const defaults = DEFAULT_BRANDING;
|
|
642
|
+
for (const layer of layers) {
|
|
643
|
+
if (!layer) continue;
|
|
644
|
+
const entries = Object.entries(layer);
|
|
645
|
+
for (const [key, value] of entries) {
|
|
646
|
+
if (value === void 0 || !(key in defaults)) continue;
|
|
647
|
+
out[key] = value === null ? defaults[key] ?? null : value;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
out.appName = (typeof out.appName === "string" ? out.appName.trim() : void 0) || DEFAULT_BRANDING.appName;
|
|
651
|
+
return out;
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* The `branding` block Connect reads at boot: the app icon reduced to its
|
|
655
|
+
* 64 px variant as a data URI (the in-app logo; a master would be ~1 MB of
|
|
656
|
+
* base64), the loader left out (it is served as a file and declared in
|
|
657
|
+
* index.html). Fields without a usable image end up null.
|
|
658
|
+
*/
|
|
659
|
+
function resolveRuntimeBranding(projectRoot, branding, warn) {
|
|
660
|
+
const out = {
|
|
661
|
+
appName: branding.appName ?? DEFAULT_BRANDING.appName,
|
|
662
|
+
icon: null,
|
|
663
|
+
loader: null
|
|
664
|
+
};
|
|
665
|
+
if (branding.icon) {
|
|
666
|
+
const logo = iconVariantPath(projectRoot, branding.icon, 64);
|
|
667
|
+
out.icon = resolveImageRef(projectRoot, logo ?? branding.icon, {
|
|
668
|
+
maxBytes: UI_ICON_MAX_BYTES,
|
|
669
|
+
warn
|
|
670
|
+
}) ?? null;
|
|
671
|
+
}
|
|
672
|
+
return out;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* A pane's background with every image, in both colour schemes, resolved to
|
|
676
|
+
* a data URI: a single image stays a single image, layers stay layers (a
|
|
677
|
+
* layer without a usable image is dropped). Problems the renderer cannot
|
|
678
|
+
* fix are warned about: a layer pinned to both edges of an axis, an SVG
|
|
679
|
+
* without a viewBox (its aspect is unknown, so it needs both dimensions).
|
|
680
|
+
*/
|
|
681
|
+
function resolveBackground(projectRoot, background, warn) {
|
|
682
|
+
if (!background) return null;
|
|
683
|
+
for (const problem of validateBackground(background, "homeBackground")) warn?.(`[branding] ${problem}`);
|
|
684
|
+
const resolveOne = (ref) => {
|
|
685
|
+
if (!isPassthroughImageRef(ref) && extname(ref).toLowerCase() === ".svg") warnWithoutViewBox(projectRoot, ref, warn);
|
|
686
|
+
return resolveImageRef(projectRoot, ref, {
|
|
687
|
+
maxBytes: BACKGROUND_MAX_BYTES,
|
|
688
|
+
warn
|
|
689
|
+
});
|
|
690
|
+
};
|
|
691
|
+
if (typeof background === "string") return resolveOne(background) ?? null;
|
|
692
|
+
return mapBackgroundImages(background, resolveOne);
|
|
693
|
+
}
|
|
694
|
+
function warnWithoutViewBox(projectRoot, ref, warn) {
|
|
695
|
+
const file = resolve(projectRoot, ref);
|
|
696
|
+
if (!existsSync(file)) return;
|
|
697
|
+
const head = readFileSync(file, "utf8").slice(0, 4096);
|
|
698
|
+
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.`);
|
|
699
|
+
}
|
|
700
|
+
const EXPLORER_ICON_KEYS = [
|
|
701
|
+
"localDrive",
|
|
702
|
+
"remoteDrive",
|
|
703
|
+
"folder",
|
|
704
|
+
"document"
|
|
705
|
+
];
|
|
706
|
+
/**
|
|
707
|
+
* The drive explorer's icons with every path resolved to a data URI; a key
|
|
708
|
+
* without a usable image is dropped (the built-in icon), an empty or null
|
|
709
|
+
* set is null.
|
|
710
|
+
*/
|
|
711
|
+
function resolveExplorerIcons(projectRoot, icons, warn) {
|
|
712
|
+
if (!icons) return null;
|
|
713
|
+
const ui = {
|
|
714
|
+
maxBytes: UI_ICON_MAX_BYTES,
|
|
715
|
+
warn
|
|
716
|
+
};
|
|
717
|
+
const out = {};
|
|
718
|
+
for (const key of EXPLORER_ICON_KEYS) {
|
|
719
|
+
const src = resolveImageRef(projectRoot, icons[key], ui);
|
|
720
|
+
if (src) out[key] = src;
|
|
721
|
+
}
|
|
722
|
+
if (icons.documents) {
|
|
723
|
+
const documents = {};
|
|
724
|
+
for (const [type, ref] of Object.entries(icons.documents)) {
|
|
725
|
+
const src = resolveImageRef(projectRoot, ref, ui);
|
|
726
|
+
if (src) documents[type] = src;
|
|
727
|
+
}
|
|
728
|
+
if (Object.keys(documents).length > 0) out.documents = documents;
|
|
729
|
+
}
|
|
730
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
731
|
+
}
|
|
732
|
+
/** A generic plugin entry whose config carries images to resolve. */
|
|
733
|
+
function hasGenericImages(entry) {
|
|
734
|
+
return entry.module === "@powerhousedao/connect/plugins/generic" && entry.config !== void 0 && ("icons" in entry.config || "homeBackground" in entry.config);
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* A connect block with the generic plugin's images resolved, wherever they
|
|
738
|
+
* are declared: `drives.icons` and `home.background` (the classic source
|
|
739
|
+
* values) and the generic plugin entry's `icons` / `homeBackground` in a
|
|
740
|
+
* served composition (the owner under uniform runners). Unchanged when none
|
|
741
|
+
* is present.
|
|
742
|
+
*/
|
|
743
|
+
function withResolvedGenericImages(projectRoot, connect, warn) {
|
|
744
|
+
if (!connect) return connect;
|
|
745
|
+
let out = connect;
|
|
746
|
+
if (connect.drives && "icons" in connect.drives) out = {
|
|
747
|
+
...out,
|
|
748
|
+
drives: {
|
|
749
|
+
...out.drives,
|
|
750
|
+
icons: resolveExplorerIcons(projectRoot, connect.drives.icons, warn)
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
if (connect.home && "background" in connect.home) out = {
|
|
754
|
+
...out,
|
|
755
|
+
home: {
|
|
756
|
+
...out.home,
|
|
757
|
+
background: resolveBackground(projectRoot, connect.home.background, warn)
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
if (connect.composition?.some(hasGenericImages)) out = {
|
|
761
|
+
...out,
|
|
762
|
+
composition: connect.composition.map((entry) => {
|
|
763
|
+
if (!hasGenericImages(entry)) return entry;
|
|
764
|
+
const config = { ...entry.config };
|
|
765
|
+
if ("icons" in config) config.icons = resolveExplorerIcons(projectRoot, config.icons, warn);
|
|
766
|
+
if ("homeBackground" in config) config.homeBackground = resolveBackground(projectRoot, config.homeBackground, warn);
|
|
767
|
+
return {
|
|
768
|
+
...entry,
|
|
769
|
+
config
|
|
770
|
+
};
|
|
771
|
+
})
|
|
772
|
+
};
|
|
773
|
+
return out;
|
|
774
|
+
}
|
|
775
|
+
const IMAGE_TYPES = {
|
|
776
|
+
".png": "image/png",
|
|
777
|
+
".svg": "image/svg+xml",
|
|
778
|
+
".webp": "image/webp",
|
|
779
|
+
".gif": "image/gif",
|
|
780
|
+
".jpg": "image/jpeg",
|
|
781
|
+
".jpeg": "image/jpeg"
|
|
782
|
+
};
|
|
783
|
+
function projectFile(projectRoot, ref) {
|
|
784
|
+
return isAbsolute(ref) ? ref : resolve(projectRoot, ref);
|
|
785
|
+
}
|
|
786
|
+
function asset(projectRoot, ref, fileName, warn) {
|
|
787
|
+
if (isPassthroughImageRef(ref)) {
|
|
788
|
+
warn?.(`[branding] ${ref}: use a project file path here, not a URL. Skipped.`);
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
const file = projectFile(projectRoot, ref);
|
|
792
|
+
const ext = extname(file).toLowerCase();
|
|
793
|
+
const contentType = IMAGE_TYPES[ext];
|
|
794
|
+
if (!contentType) {
|
|
795
|
+
warn?.(`[branding] ${ref}: unsupported image type. Skipped.`);
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
if (!existsSync(file)) {
|
|
799
|
+
warn?.(`[branding] ${ref}: file not found. Skipped.`);
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
return {
|
|
803
|
+
fileName: fileName(ext),
|
|
804
|
+
file,
|
|
805
|
+
contentType
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
/** `branding.loader` as the build emits it; undefined keeps Connect's logo. */
|
|
809
|
+
function resolveProjectLoader(projectRoot, branding, warn) {
|
|
810
|
+
const loader = branding?.loader;
|
|
811
|
+
if (!loader) return void 0;
|
|
812
|
+
const spec = typeof loader === "string" ? { src: loader } : loader;
|
|
813
|
+
const found = asset(projectRoot, spec.src, (ext) => `ph-loader${ext}`, warn);
|
|
814
|
+
if (!found) return void 0;
|
|
815
|
+
return {
|
|
816
|
+
...found,
|
|
817
|
+
animation: spec.animation ?? "pulse",
|
|
818
|
+
size: spec.size ?? DEFAULT_LOADER_SIZE
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
/** Width and height from a PNG's IHDR chunk. */
|
|
822
|
+
function pngSize(bytes) {
|
|
823
|
+
if (bytes.length < 24 || [
|
|
824
|
+
137,
|
|
825
|
+
80,
|
|
826
|
+
78,
|
|
827
|
+
71,
|
|
828
|
+
13,
|
|
829
|
+
10,
|
|
830
|
+
26,
|
|
831
|
+
10
|
|
832
|
+
].some((b, i) => bytes[i] !== b)) return;
|
|
833
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
834
|
+
return [view.getUint32(16), view.getUint32(20)];
|
|
835
|
+
}
|
|
836
|
+
/** The installed app's name and icons, from `branding.appName` and
|
|
837
|
+
* `branding.icon`. Undefined members keep Connect's own. */
|
|
838
|
+
function resolveProjectPwaBrand(projectRoot, branding, warn) {
|
|
839
|
+
const brand = {};
|
|
840
|
+
const name = branding?.appName?.trim();
|
|
841
|
+
if (name && name !== DEFAULT_BRANDING.appName) brand.name = name;
|
|
842
|
+
const app = branding?.icon;
|
|
843
|
+
if (!app) return brand;
|
|
844
|
+
const ext = extname(app).toLowerCase();
|
|
845
|
+
if (ext === ".svg") {
|
|
846
|
+
const svg = asset(projectRoot, app, () => "pwa-app.svg", warn);
|
|
847
|
+
if (svg) brand.icons = [{
|
|
848
|
+
...svg,
|
|
849
|
+
sizes: "any"
|
|
850
|
+
}];
|
|
851
|
+
return brand;
|
|
852
|
+
}
|
|
853
|
+
if (ext !== ".png") {
|
|
854
|
+
warn?.(`[branding] icon ${app}: the installed-app icon needs a PNG or SVG. Connect's icon stays.`);
|
|
855
|
+
return brand;
|
|
856
|
+
}
|
|
857
|
+
const icons = [];
|
|
858
|
+
const seen = /* @__PURE__ */ new Set();
|
|
859
|
+
const add = (ref) => {
|
|
860
|
+
const file = projectFile(projectRoot, ref);
|
|
861
|
+
if (!existsSync(file)) return;
|
|
862
|
+
const size = pngSize(readFileSync(file));
|
|
863
|
+
if (!size) return;
|
|
864
|
+
const sizes = `${size[0]}x${size[1]}`;
|
|
865
|
+
if (seen.has(sizes)) return;
|
|
866
|
+
seen.add(sizes);
|
|
867
|
+
icons.push({
|
|
868
|
+
fileName: `pwa-app-${sizes}.png`,
|
|
869
|
+
file,
|
|
870
|
+
contentType: "image/png",
|
|
871
|
+
sizes
|
|
872
|
+
});
|
|
873
|
+
};
|
|
874
|
+
const stem = app.slice(0, app.length - ext.length);
|
|
875
|
+
for (const size of PWA_ICON_VARIANT_SIZES) add(`${stem}_${size}x${size}${ext}`);
|
|
876
|
+
add(app);
|
|
877
|
+
if (icons.length === 0) {
|
|
878
|
+
warn?.(`[branding] icon ${app}: not a readable PNG. Connect's icon stays.`);
|
|
879
|
+
return brand;
|
|
880
|
+
}
|
|
881
|
+
brand.icons = icons;
|
|
882
|
+
return brand;
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* The favicons: the `_16x16` / `_32x32` / `_64x64` siblings of
|
|
886
|
+
* `branding.icon` (an SVG master is one scalable favicon). They replace
|
|
887
|
+
* Connect's static icon.ico link in index.html; none keeps it. A favicon
|
|
888
|
+
* named outright (`faviconPath`: `branding.favicon` or `--favicon`) wins: it
|
|
889
|
+
* is built as icon.ico, so the icon's siblings stand aside.
|
|
890
|
+
*/
|
|
891
|
+
function resolveProjectFavicons(projectRoot, branding, warn, faviconPath) {
|
|
892
|
+
const app = branding?.icon;
|
|
893
|
+
if (!app || faviconPath) return [];
|
|
894
|
+
if (isPassthroughImageRef(app)) {
|
|
895
|
+
warn?.(`[branding] icon ${app}: use a project file path here, not a URL. Connect's favicon stays.`);
|
|
896
|
+
return [];
|
|
897
|
+
}
|
|
898
|
+
const ext = extname(app).toLowerCase();
|
|
899
|
+
if (ext === ".svg") {
|
|
900
|
+
const svg = asset(projectRoot, app, () => "favicon.svg", warn);
|
|
901
|
+
return svg ? [{
|
|
902
|
+
...svg,
|
|
903
|
+
sizes: "any"
|
|
904
|
+
}] : [];
|
|
905
|
+
}
|
|
906
|
+
const out = [];
|
|
907
|
+
for (const size of APP_ICON_VARIANT_SIZES) {
|
|
908
|
+
const variant = iconVariantPath(projectRoot, app, size);
|
|
909
|
+
if (!variant) continue;
|
|
910
|
+
const file = projectFile(projectRoot, variant);
|
|
911
|
+
const contentType = imageMimeType(file);
|
|
912
|
+
if (!contentType) continue;
|
|
913
|
+
out.push({
|
|
914
|
+
fileName: `favicon-${size}x${size}${ext}`,
|
|
915
|
+
file,
|
|
916
|
+
contentType,
|
|
917
|
+
sizes: `${size}x${size}`
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
if (out.length === 0) warn?.(`[branding] icon ${app}: no _16x16 / _32x32 / _64x64 siblings found. Connect's favicon stays.`);
|
|
921
|
+
return out;
|
|
922
|
+
}
|
|
923
|
+
function escapeAttr(value) {
|
|
924
|
+
return value.replace(/&/g, "&").replace(/"/g, """);
|
|
925
|
+
}
|
|
926
|
+
/** The `<meta>` tags Connect's loaders read. */
|
|
927
|
+
function brandMetaTags(options) {
|
|
928
|
+
const tags = [];
|
|
929
|
+
const { loader } = options;
|
|
930
|
+
if (loader) tags.push(`<meta name="${LOADER_META}" content="${escapeAttr(loader.fileName)}" data-animation="${loader.animation}" data-size="${loader.size}">`);
|
|
931
|
+
if (options.customShell) tags.push(`<meta name="${CUSTOM_SHELL_META}" content="true">`);
|
|
932
|
+
return tags.join("");
|
|
933
|
+
}
|
|
934
|
+
const ICON_LINK = /<link\b[^>]*\brel=["']?(?:shortcut )?icon["']?[^>]*>\s*/gi;
|
|
935
|
+
/** index.html with Connect's icon links replaced by the project's favicons
|
|
936
|
+
* (one sized link per variant, under `base`); unchanged without any. */
|
|
937
|
+
function withProjectFavicons(html, favicons, base = "/") {
|
|
938
|
+
if (favicons.length === 0) return html;
|
|
939
|
+
const prefix = base.endsWith("/") ? base : `${base}/`;
|
|
940
|
+
const links = favicons.map((icon) => `<link rel="icon" type="${icon.contentType}" sizes="${icon.sizes}" href="${escapeAttr(prefix + icon.fileName)}" />`).join("");
|
|
941
|
+
return html.replace(ICON_LINK, "").replace("</head>", `${links}</head>`);
|
|
942
|
+
}
|
|
943
|
+
/** Keyframes for the loader motions; shared by the shell and the app. */
|
|
944
|
+
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)}}";
|
|
945
|
+
const LOADER_ANIMATION = {
|
|
946
|
+
pulse: "ph-loader-pulse 1.6s ease-in-out infinite",
|
|
947
|
+
spin: "ph-loader-spin 1.4s linear infinite",
|
|
948
|
+
none: "none"
|
|
949
|
+
};
|
|
950
|
+
/** The loader as static markup, for the prerendered shell's first paint. */
|
|
951
|
+
function loaderMarkup(loader, base = "/") {
|
|
952
|
+
const prefix = base.endsWith("/") ? base : `${base}/`;
|
|
953
|
+
const motion = LOADER_ANIMATION[loader.animation];
|
|
954
|
+
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}">`;
|
|
955
|
+
}
|
|
956
|
+
/** The marked slot in Connect's prerendered shell that holds its logo. */
|
|
957
|
+
const LOADER_SLOT = /<div\b[^>]*\bdata-ph-loader-slot\b[^>]*>[\s\S]*?<\/div>/;
|
|
958
|
+
/** Swaps the shell's logo slot for the project's loader. */
|
|
959
|
+
function replaceShellLoader(shellBody, loader, base = "/") {
|
|
960
|
+
return shellBody.replace(LOADER_SLOT, () => loaderMarkup(loader, base));
|
|
961
|
+
}
|
|
962
|
+
/**
|
|
963
|
+
* Serves (dev) and emits (build) the branding files, and adds the tags
|
|
964
|
+
* index.html carries before any JavaScript: the loader and custom-shell
|
|
965
|
+
* meta tags, and the favicon links.
|
|
966
|
+
*/
|
|
967
|
+
function connectProjectBrandPlugin(options) {
|
|
968
|
+
const favicons = options.favicons ?? [];
|
|
969
|
+
const files = [
|
|
970
|
+
...options.loader ? [options.loader] : [],
|
|
971
|
+
...options.pwaIcons ?? [],
|
|
972
|
+
...favicons
|
|
973
|
+
];
|
|
974
|
+
const meta = brandMetaTags(options);
|
|
975
|
+
let base = "/";
|
|
976
|
+
return {
|
|
977
|
+
name: "ph-connect-project-brand",
|
|
978
|
+
configResolved(config) {
|
|
979
|
+
base = config.base;
|
|
980
|
+
},
|
|
981
|
+
configureServer(server) {
|
|
982
|
+
for (const file of files) {
|
|
983
|
+
const handler = (_req, res, next) => {
|
|
984
|
+
try {
|
|
985
|
+
res.setHeader("Content-Type", file.contentType);
|
|
986
|
+
res.end(readFileSync(file.file));
|
|
987
|
+
} catch {
|
|
988
|
+
next();
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
const paths = /* @__PURE__ */ new Set([`${server.config.base}${file.fileName}`.replace(/\/{2,}/g, "/"), `/${file.fileName}`]);
|
|
992
|
+
for (const path of paths) server.middlewares.use(path, handler);
|
|
993
|
+
}
|
|
994
|
+
},
|
|
995
|
+
transformIndexHtml(html) {
|
|
996
|
+
return withProjectFavicons(meta ? html.replace("</head>", `${meta}</head>`) : html, favicons, base);
|
|
997
|
+
},
|
|
998
|
+
generateBundle(_options, bundle) {
|
|
999
|
+
for (const file of files) {
|
|
1000
|
+
if (file.fileName in bundle) continue;
|
|
1001
|
+
try {
|
|
1002
|
+
this.emitFile({
|
|
1003
|
+
type: "asset",
|
|
1004
|
+
fileName: file.fileName,
|
|
1005
|
+
source: readFileSync(file.file)
|
|
1006
|
+
});
|
|
1007
|
+
} catch {}
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
//#endregion
|
|
553
1013
|
//#region connect-utils/vite-plugins/app-shell.ts
|
|
554
1014
|
/** On the prerendered shell's elements; marks an index.html that has it. */
|
|
555
1015
|
const APP_SHELL_MARKER = "data-ph-shell";
|
|
@@ -672,6 +1132,7 @@ function swapAppShell(html, shell, base = "/", appName) {
|
|
|
672
1132
|
return html.replace(REGION("head"), () => region("head", shell.head)).replace(REGION("body"), () => region("body", body));
|
|
673
1133
|
}
|
|
674
1134
|
const DEV_SHELL_WAIT_MS = 1e4;
|
|
1135
|
+
const CONNECT_PACKAGES = ["@powerhousedao/connect", "@powerhousedao/connect-core"];
|
|
675
1136
|
async function renderProjectAppShells(projectRoot, config, routeAliases, hostStylesheet) {
|
|
676
1137
|
const server = await createServer({
|
|
677
1138
|
configFile: false,
|
|
@@ -696,16 +1157,21 @@ async function renderProjectAppShells(projectRoot, config, routeAliases, hostSty
|
|
|
696
1157
|
include: [],
|
|
697
1158
|
entries: []
|
|
698
1159
|
},
|
|
699
|
-
ssr: {
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
1160
|
+
ssr: {
|
|
1161
|
+
optimizeDeps: {
|
|
1162
|
+
noDiscovery: true,
|
|
1163
|
+
include: []
|
|
1164
|
+
},
|
|
1165
|
+
noExternal: CONNECT_PACKAGES
|
|
1166
|
+
}
|
|
703
1167
|
});
|
|
704
1168
|
try {
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
1169
|
+
return await withNodeDedupe(projectRoot, config.resolve.dedupe, async () => {
|
|
1170
|
+
const renderer = await server.ssrLoadModule("@powerhousedao/connect/prerender");
|
|
1171
|
+
const stylesheet = join(projectRoot, "style.css");
|
|
1172
|
+
const css = withHostStylesheet(readFileSync(stylesheet, "utf8"), stylesheet, hostStylesheet);
|
|
1173
|
+
return renderer.renderProjectShells(stylesheet, css);
|
|
1174
|
+
});
|
|
709
1175
|
} finally {
|
|
710
1176
|
await server.close();
|
|
711
1177
|
}
|
|
@@ -714,13 +1180,22 @@ const sourceText = (source) => typeof source === "string" ? source : new TextDec
|
|
|
714
1180
|
/** Build: the composition's shell in #root and every variant in the dist, from
|
|
715
1181
|
* the project's routes when it has them. Dev: the shell from the project's routes
|
|
716
1182
|
* when it has them, else core's for a core composition. */
|
|
717
|
-
function connectAppShellPlugin(projectRoot, { composition, appName, routeAliases, routesDir, hostStylesheet } = {}) {
|
|
1183
|
+
function connectAppShellPlugin(projectRoot, { composition, appName, routeAliases, routesDir, loader, hostStylesheet } = {}) {
|
|
718
1184
|
let variant = "generic";
|
|
719
1185
|
let shells = {};
|
|
720
1186
|
let shellPlugins;
|
|
721
1187
|
let base = "/";
|
|
722
1188
|
let isBuild = true;
|
|
723
1189
|
let config;
|
|
1190
|
+
const withLoader = (from) => {
|
|
1191
|
+
if (!loader) return from;
|
|
1192
|
+
const out = {};
|
|
1193
|
+
for (const [name, shell] of Object.entries(from)) out[name] = {
|
|
1194
|
+
...shell,
|
|
1195
|
+
body: replaceShellLoader(shell.body, loader, base)
|
|
1196
|
+
};
|
|
1197
|
+
return out;
|
|
1198
|
+
};
|
|
724
1199
|
const fromRoutes = () => isBuild && !!routeAliases;
|
|
725
1200
|
const shell = () => {
|
|
726
1201
|
if (fromRoutes()) return void 0;
|
|
@@ -731,7 +1206,7 @@ function connectAppShellPlugin(projectRoot, { composition, appName, routeAliases
|
|
|
731
1206
|
const renderDevShells = () => {
|
|
732
1207
|
if (!config || !routeAliases) return;
|
|
733
1208
|
const logger = config.logger;
|
|
734
|
-
devShells = renderProjectAppShells(projectRoot, config, routeAliases, hostStylesheet).catch((error) => {
|
|
1209
|
+
devShells = renderProjectAppShells(projectRoot, config, routeAliases, hostStylesheet).then(withLoader).catch((error) => {
|
|
735
1210
|
logger.warn(`[connect] the loading shell failed to render from the project's routes: ${String(error)}`);
|
|
736
1211
|
return {};
|
|
737
1212
|
});
|
|
@@ -767,7 +1242,7 @@ function connectAppShellPlugin(projectRoot, { composition, appName, routeAliases
|
|
|
767
1242
|
config = resolved;
|
|
768
1243
|
base = resolved.base;
|
|
769
1244
|
isBuild = resolved.command === "build";
|
|
770
|
-
shells = readAppShells(projectRoot);
|
|
1245
|
+
shells = withLoader(readAppShells(projectRoot));
|
|
771
1246
|
shellPlugins = readShellPlugins(projectRoot);
|
|
772
1247
|
variant = appShellVariant(composition, shellPlugins);
|
|
773
1248
|
},
|
|
@@ -786,7 +1261,7 @@ function connectAppShellPlugin(projectRoot, { composition, appName, routeAliases
|
|
|
786
1261
|
async handler(_options, bundle) {
|
|
787
1262
|
if (!isBuild) return;
|
|
788
1263
|
if (fromRoutes() && config && routeAliases) {
|
|
789
|
-
shells = await renderProjectAppShells(projectRoot, config, routeAliases, hostStylesheet);
|
|
1264
|
+
shells = withLoader(await renderProjectAppShells(projectRoot, config, routeAliases, hostStylesheet));
|
|
790
1265
|
const index = bundle["index.html"];
|
|
791
1266
|
const current = shells[variant];
|
|
792
1267
|
if (index?.type === "asset" && current) index.source = injectAppShell(sourceText(index.source), current, base, { appName });
|
|
@@ -2791,7 +3266,10 @@ function phConfigPlugin(options) {
|
|
|
2791
3266
|
const source = {
|
|
2792
3267
|
packages: options.packages,
|
|
2793
3268
|
packageRegistryUrl: options.packageRegistryUrl,
|
|
2794
|
-
connect:
|
|
3269
|
+
connect: options.branding ? {
|
|
3270
|
+
...mergedConnect,
|
|
3271
|
+
branding: options.branding
|
|
3272
|
+
} : mergedConnect.branding ? {
|
|
2795
3273
|
...mergedConnect,
|
|
2796
3274
|
branding
|
|
2797
3275
|
} : mergedConnect
|
|
@@ -2828,7 +3306,7 @@ function phConfigPlugin(options) {
|
|
|
2828
3306
|
}
|
|
2829
3307
|
},
|
|
2830
3308
|
transformIndexHtml(html) {
|
|
2831
|
-
return withAppTitle(html, runtimeConfig.connect.branding?.appName);
|
|
3309
|
+
return withAppTitle(html, runtimeConfig.connect.branding?.appName ?? void 0);
|
|
2832
3310
|
},
|
|
2833
3311
|
generateBundle() {
|
|
2834
3312
|
this.emitFile({
|
|
@@ -3103,6 +3581,28 @@ const BASE_MANIFEST = {
|
|
|
3103
3581
|
launch_handler: { client_mode: "focus-existing" }
|
|
3104
3582
|
};
|
|
3105
3583
|
/**
|
|
3584
|
+
* The base manifest under the project's own name and icons (from
|
|
3585
|
+
* `connect.branding.appName` / `icons.app`), so an installed app is not
|
|
3586
|
+
* "Powerhouse Connect". Connect's description goes with its name; a project
|
|
3587
|
+
* that wants one sets `connect.pwa.manifest.description`, which — like the
|
|
3588
|
+
* rest of `connect.pwa` — is laid on top of this.
|
|
3589
|
+
*/
|
|
3590
|
+
function brandManifest(base, brand) {
|
|
3591
|
+
if (!brand) return base;
|
|
3592
|
+
const manifest = { ...base };
|
|
3593
|
+
if (brand.name) {
|
|
3594
|
+
manifest.name = brand.name;
|
|
3595
|
+
manifest.short_name = brand.name;
|
|
3596
|
+
delete manifest.description;
|
|
3597
|
+
}
|
|
3598
|
+
if (brand.icons?.length) manifest.icons = brand.icons.map((icon) => ({
|
|
3599
|
+
src: icon.fileName,
|
|
3600
|
+
sizes: icon.sizes,
|
|
3601
|
+
type: icon.contentType
|
|
3602
|
+
}));
|
|
3603
|
+
return manifest;
|
|
3604
|
+
}
|
|
3605
|
+
/**
|
|
3106
3606
|
* Connect's hardcoded precache config — the base layer for the `injectManifest`
|
|
3107
3607
|
* precache. Overridable additively (extra globs) or by raising the size ceiling
|
|
3108
3608
|
* via package/project `pwa` config. The rest of the old Workbox config
|
|
@@ -3177,7 +3677,7 @@ function phSwConfigPlugin(data) {
|
|
|
3177
3677
|
* clears its caches on the browser's next service-worker update check.
|
|
3178
3678
|
*/
|
|
3179
3679
|
function connectPwaPlugins(options) {
|
|
3180
|
-
const { offlineEnabled, pwa } = options;
|
|
3680
|
+
const { offlineEnabled, pwa, brand } = options;
|
|
3181
3681
|
if (!offlineEnabled) return [VitePWA({
|
|
3182
3682
|
selfDestroying: true,
|
|
3183
3683
|
strategies: "generateSW",
|
|
@@ -3186,7 +3686,7 @@ function connectPwaPlugins(options) {
|
|
|
3186
3686
|
devOptions: { enabled: false }
|
|
3187
3687
|
})];
|
|
3188
3688
|
const { manifest, precache } = applyPwaOverrides({
|
|
3189
|
-
manifest: BASE_MANIFEST,
|
|
3689
|
+
manifest: brandManifest(BASE_MANIFEST, brand),
|
|
3190
3690
|
precache: BASE_PRECACHE
|
|
3191
3691
|
}, pwa ?? {});
|
|
3192
3692
|
const swConfig = {
|
|
@@ -3725,15 +4225,6 @@ function getConnectBaseViteConfig(options) {
|
|
|
3725
4225
|
const phPackages = (phPackagesStr ? parsePackagesEnvOverride(phPackagesStr) : void 0) ?? packagesFromConfig;
|
|
3726
4226
|
const phPackageRegistryUrl = options.cliPackageRegistryUrl ?? phConfig.packageRegistryUrl ?? null;
|
|
3727
4227
|
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
4228
|
const offlineEnabled = options.cliConnectOverride?.app?.offline ?? phConfig.connect?.app?.offline ?? true;
|
|
3738
4229
|
const authToken = env.PH_SENTRY_AUTH_TOKEN;
|
|
3739
4230
|
const org = env.PH_SENTRY_ORG;
|
|
@@ -3782,6 +4273,25 @@ function getConnectBaseViteConfig(options) {
|
|
|
3782
4273
|
const projectPwa = validateProjectPwaConfig(deepMerge(phConfig.connect?.pwa ?? {}, options.cliConnectOverride?.pwa ?? {}), phConfigPath);
|
|
3783
4274
|
const pwaWarn = (msg) => (customLogger ?? console).warn(msg);
|
|
3784
4275
|
const pwaPackagesForFragments = mode === "production" ? phPackages : phPackages.filter((p) => p.provider === "local");
|
|
4276
|
+
const brandWarn = (msg) => (customLogger ?? console).warn(msg);
|
|
4277
|
+
const branding = effectiveBranding(phConfig.connect?.branding, options.cliConnectOverride?.branding);
|
|
4278
|
+
const projectLoader = resolveProjectLoader(options.dirname, branding, brandWarn);
|
|
4279
|
+
const projectBrand = resolveProjectPwaBrand(options.dirname, branding, brandWarn);
|
|
4280
|
+
const runtimeBranding = resolveRuntimeBranding(options.dirname, branding, brandWarn);
|
|
4281
|
+
const sourceConnect = withResolvedGenericImages(options.dirname, phConfig.connect, brandWarn);
|
|
4282
|
+
const connectOverride = withResolvedGenericImages(options.dirname, options.cliConnectOverride, brandWarn);
|
|
4283
|
+
const configPlugin = phConfigPlugin({
|
|
4284
|
+
packages: phPackages,
|
|
4285
|
+
projectRoot: options.dirname,
|
|
4286
|
+
connect: sourceConnect,
|
|
4287
|
+
workflows: phConfig.workflows,
|
|
4288
|
+
packageRegistryUrl: phPackageRegistryUrl ?? void 0,
|
|
4289
|
+
cliConnectOverride: connectOverride,
|
|
4290
|
+
branding: runtimeBranding
|
|
4291
|
+
});
|
|
4292
|
+
const servedConnect = configPlugin.api.connect;
|
|
4293
|
+
const faviconPath = options.favicon ?? configPlugin.api.favicon;
|
|
4294
|
+
const projectFavicons = resolveProjectFavicons(options.dirname, branding, brandWarn, faviconPath);
|
|
3785
4295
|
const pwaPlugins = (async () => {
|
|
3786
4296
|
if (!offlineEnabled) return connectPwaPlugins({ offlineEnabled });
|
|
3787
4297
|
const contributions = await collectPackagePwaContributions({
|
|
@@ -3795,7 +4305,8 @@ function getConnectBaseViteConfig(options) {
|
|
|
3795
4305
|
const mergedPwa = mergePwaConfig(contributions, projectPwa, pwaWarn);
|
|
3796
4306
|
return connectPwaPlugins({
|
|
3797
4307
|
offlineEnabled,
|
|
3798
|
-
pwa: mergedPwa
|
|
4308
|
+
pwa: mergedPwa,
|
|
4309
|
+
brand: projectBrand
|
|
3799
4310
|
});
|
|
3800
4311
|
})();
|
|
3801
4312
|
const reactExternal = [
|
|
@@ -3817,6 +4328,7 @@ function getConnectBaseViteConfig(options) {
|
|
|
3817
4328
|
}).filter((p) => p !== null);
|
|
3818
4329
|
const routesDir = resolveConnectRoutesDir(options.dirname, options.routes) ?? false;
|
|
3819
4330
|
const routes = connectRoutes(options.dirname, routesDir);
|
|
4331
|
+
const customShell = hasProjectAppLayout(routesDir || void 0);
|
|
3820
4332
|
const hostStylesheet = hostStylesheetPath(options.dirname, routesDir);
|
|
3821
4333
|
return {
|
|
3822
4334
|
configFile: false,
|
|
@@ -3849,7 +4361,8 @@ function getConnectBaseViteConfig(options) {
|
|
|
3849
4361
|
"zod",
|
|
3850
4362
|
"@powerhousedao/design-system/connect",
|
|
3851
4363
|
"@powerhousedao/reactor-browser",
|
|
3852
|
-
"@powerhousedao/document-engineering"
|
|
4364
|
+
"@powerhousedao/document-engineering",
|
|
4365
|
+
...routes.include
|
|
3853
4366
|
],
|
|
3854
4367
|
exclude: ["@electric-sql/pglite", "@electric-sql/pglite-tools"]
|
|
3855
4368
|
},
|
|
@@ -3870,15 +4383,22 @@ function getConnectBaseViteConfig(options) {
|
|
|
3870
4383
|
dev: mode !== "production" || isDebug
|
|
3871
4384
|
}),
|
|
3872
4385
|
...options.vendor && mode === "production" ? [vendorImportMapPlugin({ imports: options.vendor.imports })] : [],
|
|
3873
|
-
connectFaviconPlugin({ faviconPath
|
|
4386
|
+
connectFaviconPlugin({ faviconPath }),
|
|
3874
4387
|
connectThemeBootPlugin(),
|
|
3875
4388
|
connectAppShellPlugin(options.dirname, {
|
|
3876
4389
|
composition: servedConnect.composition,
|
|
3877
|
-
appName: servedConnect.branding?.appName,
|
|
4390
|
+
appName: servedConnect.branding?.appName ?? void 0,
|
|
3878
4391
|
routeAliases: routesDir ? routes.aliases : void 0,
|
|
3879
4392
|
routesDir: routesDir || void 0,
|
|
4393
|
+
loader: projectLoader,
|
|
3880
4394
|
hostStylesheet
|
|
3881
4395
|
}),
|
|
4396
|
+
connectProjectBrandPlugin({
|
|
4397
|
+
loader: projectLoader,
|
|
4398
|
+
pwaIcons: offlineEnabled ? projectBrand.icons : void 0,
|
|
4399
|
+
favicons: projectFavicons,
|
|
4400
|
+
customShell
|
|
4401
|
+
}),
|
|
3882
4402
|
connectBuildHashPlugin(buildHash),
|
|
3883
4403
|
...options.dynamicBase ? [connectDynamicBasePlugin()] : [],
|
|
3884
4404
|
pwaPlugins
|
|
@@ -3897,6 +4417,6 @@ function getConnectBaseViteConfig(options) {
|
|
|
3897
4417
|
};
|
|
3898
4418
|
}
|
|
3899
4419
|
//#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 };
|
|
4420
|
+
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, connectRouteFileDeps, connectRouterChunkGroups, connectRoutes, connectRoutesDirOf, connectRoutesGeneratorConfig, connectRoutesTreeOf, connectThemeBootPlugin, copyConnect, directoryContentDigest, distDirFingerprint, ensureNodeVersion, escapeForRegExp, findBundleSpecifierOffenders, findDisallowedSpecifiers, findPackageRoot, findWorkerUnsafeMarkers, generateConnectRoutes, getConnectBaseViteConfig, getConnectHtmlTags, hasProjectAppLayout, 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 };
|
|
3901
4421
|
|
|
3902
4422
|
//# sourceMappingURL=index.mjs.map
|