@powerhousedao/builder-tools 6.2.3-dev.71 → 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.d.mts +15 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +250 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Alias, CommonServerOptions, HtmlTagDescriptor, InlineConfig, Plugin, PluginOption } from "vite";
|
|
1
|
+
import { Alias, CommonServerOptions, ErrorPayload, HtmlTagDescriptor, InlineConfig, Plugin, PluginOption } from "vite";
|
|
2
2
|
import { GeneratorPlugin } from "@tanstack/router-generator";
|
|
3
3
|
import { DYNAMIC_BASE_PLACEHOLDER } from "@powerhousedao/shared/connect";
|
|
4
4
|
import { PHConnectBranding, PHConnectLoader, PHConnectRuntimeConfig, PowerhouseConfig } from "@powerhousedao/shared/clis";
|
|
@@ -89,6 +89,11 @@ export type ConnectAppShellOptions = {
|
|
|
89
89
|
/** The host's stylesheet, which the page's build adds to the project's. */
|
|
90
90
|
hostStylesheet?: string;
|
|
91
91
|
};
|
|
92
|
+
/** The prerender's error with each `(at <component> (<file>:<line>:<col>))` in
|
|
93
|
+
* its message mapped back to the source, as React reports the transformed code. */
|
|
94
|
+
export declare function withSourceLocations(error: unknown, rewrite: (stack: string) => string): unknown;
|
|
95
|
+
/** Vite's error overlay over the page, for a failure no module request reports. */
|
|
96
|
+
export declare function withErrorOverlay(html: string, err: ErrorPayload["err"], base: string): string;
|
|
92
97
|
/** Build: the composition's shell in #root and every variant in the dist, from
|
|
93
98
|
* the project's routes when it has them. Dev: the shell from the project's routes
|
|
94
99
|
* when it has them, else core's for a core composition. */
|
|
@@ -160,6 +165,9 @@ export declare function resolveConnectRoutesDir(projectRoot: string, routes?: st
|
|
|
160
165
|
/** The tree generated from `routesDir`: `.ph/connect-routes.gen.ts` for
|
|
161
166
|
* `hosts/connect/routes/`, else `.ph/<folder>.gen.ts`. */
|
|
162
167
|
export declare function connectRoutesTreeOf(projectRoot: string, routesDir: string): string;
|
|
168
|
+
/** The dev watcher's filter for `.ph/`, which holds build output: ignored but
|
|
169
|
+
* for the host's route tree, rewritten as route files come and go. */
|
|
170
|
+
export declare function ignoreDotPhButRouteTree(projectRoot: string, routesDir?: string | false): (file: string) => boolean;
|
|
163
171
|
/** Connect's pathless sidebar layout; a project's routes in `_app/` render in it. */
|
|
164
172
|
export declare const APP_LAYOUT = "_app";
|
|
165
173
|
/** Whether the project's `_app` replaces Connect's layout (and its chrome). */
|
|
@@ -260,12 +268,14 @@ export declare function generateConnectRoutes(projectRoot: string, routesDir: st
|
|
|
260
268
|
plugins?: GeneratorPlugin[] | undefined;
|
|
261
269
|
tmpDir: string;
|
|
262
270
|
importRoutesUsingAbsolutePaths: boolean;
|
|
263
|
-
}): Promise<void>;
|
|
271
|
+
}, warn?: (message: string) => void): Promise<void>;
|
|
264
272
|
/** Connect's route files, as the generated tree imports them: by Connect's
|
|
265
273
|
* package name, which a project depends on. */
|
|
266
274
|
export declare const CONNECT_ROUTES_SPECIFIER = "@powerhousedao/connect/routes";
|
|
267
275
|
/** Generates the tree when the project has routes, else drops a stale one. */
|
|
268
276
|
export declare function syncConnectRoutes(projectRoot: string, routesDir?: string | undefined): Promise<void>;
|
|
277
|
+
/** What Connect's route files import, besides each other. */
|
|
278
|
+
export declare const CONNECT_ROUTE_FILE_DEPS: string[];
|
|
269
279
|
/**
|
|
270
280
|
* The `optimizeDeps.include` entries an installed Connect's route files need.
|
|
271
281
|
*
|
|
@@ -669,6 +679,9 @@ export type IConnectOptions = {
|
|
|
669
679
|
/** The routes folder, relative to the project (a host's `runner.routes`);
|
|
670
680
|
* `false` for none. Default: `hosts/connect/routes/` when it exists. */
|
|
671
681
|
routes?: string | false;
|
|
682
|
+
/** Vite's cache folder. Default: Vite's, `node_modules/.vite`; a host's own
|
|
683
|
+
* keeps dev servers running side by side from rewriting each other's deps. */
|
|
684
|
+
cacheDir?: string;
|
|
672
685
|
/**
|
|
673
686
|
* Production vendor: the prebuilt shared-dependency bundle's import map and
|
|
674
687
|
* version table (from `prebuildConnectVendor`). When set on a production
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../connect-utils/constants.ts","../connect-utils/vite-plugins/project-brand.ts","../connect-utils/vite-plugins/app-shell.ts","../connect-utils/vite-plugins/build-hash.ts","../connect-utils/vite-plugins/connect-routes.ts","../connect-utils/vite-plugins/host-stylesheet.ts","../connect-utils/externalize-vendor.ts","../connect-utils/reactor-worker-build.ts","../connect-utils/worker-packages-build.ts","../connect-utils/types.ts","../connect-utils/helpers.ts","../connect-utils/runtime-config-schema.ts","../connect-utils/vite-config.ts","../connect-utils/vite-plugins/dynamic-base.ts","../connect-utils/vite-plugins/ph-config.ts","../connect-utils/vite-plugins/theme-boot.ts","../connect-utils/vite-plugins/vendor-import-map.ts"],"mappings":";;;;;;qBAAa;qBACA;qBACA;qBACA;;;KC4QD;;EAEV;;EAEA;EACA;;KAGU,gBAAgB;EAC1B,WAAW,YAAY;EACvB;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../connect-utils/constants.ts","../connect-utils/vite-plugins/project-brand.ts","../connect-utils/vite-plugins/app-shell.ts","../connect-utils/vite-plugins/build-hash.ts","../connect-utils/vite-plugins/connect-routes.ts","../connect-utils/vite-plugins/host-stylesheet.ts","../connect-utils/externalize-vendor.ts","../connect-utils/reactor-worker-build.ts","../connect-utils/worker-packages-build.ts","../connect-utils/types.ts","../connect-utils/helpers.ts","../connect-utils/runtime-config-schema.ts","../connect-utils/vite-config.ts","../connect-utils/vite-plugins/dynamic-base.ts","../connect-utils/vite-plugins/ph-config.ts","../connect-utils/vite-plugins/theme-boot.ts","../connect-utils/vite-plugins/vendor-import-map.ts"],"mappings":";;;;;;qBAAa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;;wBAsDc,kBAAkB;wBAclB,qBACd,oBACA,sBACC;;;;wBAwCmB,iBAAiB,oBAAoB,mBAAgB;;;;wBAYrD,kBAAkB,oBAAoB,mBAAgB;wBAS5D,OAAO;wBAMP,wBAAwB;;;qBC5Q3B;qBAOA;qBAGA;WACX;WACA;WACA;WACA;WAEA;WACA;WACA;WACA;aACE;eACE;eACA;;aAGF;eACE;eACA;;aAGF;eACE;eACA;eAEA;;;;;;;;;;;;;;;;;;;;;;;;;aAEF;eACE;eACA;;aAGF;eACE;eAEA;iBACI;;iBAEA;iBACA;iBACA;iBACA;mBACE;qBAAQ;;mBACR;qBAAW;;;;;aAKnB,iDAAO;;;;;wBCFK,mBACd;EACE;EACA,WAAW;;WAMJ;;aAEH;aACA;;;;WAKG;;aAEH;aACA;;;;WAKG;;aAEH;aACA;;;;WAKG;;aAEH;aACA;;;;WAKG;;aAEH;aACA;;;;WAMG;;aAEH;aACA;;;;WAMG;;aAEH;aACA;;;;WAKG;;aAEH;aACA;;;;WAMG;;aAEH;aACA;;;;WAKG;;aAEH;aACA;;;;wBA6DQ,yBAAyB,SAAS,kBAAe;;;;wBC3JjD,gBAAgB,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAuC7B,yBACd;EAAW;EAAqB;IAC/B;wBA4Da,gBAAgB;;;YClJpB;EACV,UAAU;EACV;EACA,UAAU;;EAEV,YAAY;;;;;;;EAOZ;;;;;;EAMA,qBAAqB;;;;;;EAMrB,WAAW;;;wBAuBG,aAAa,cAAc;KAYtC;EAAgB,SAAS;EAAwB;;;;wBAItC,eACd,SAAS,wBACR,OAAO;EAAiB,KAAK;;;;;;;;;qBC3EnB;;;;;;wBA4BG,0BAA0B;;;YCxB9B;;EAEV,SAAS;;wBA4BK,sBAAsB,SAAS,yBAAyB"}
|
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ 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
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";
|
|
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
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";
|
|
14
14
|
import { createHash, randomUUID } from "node:crypto";
|
|
15
15
|
import MagicString from "magic-string";
|
|
@@ -238,6 +238,16 @@ function connectRoutesTreeOf(projectRoot, routesDir) {
|
|
|
238
238
|
if (isDefaultRoutesDir(projectRoot, routesDir)) return join(projectRoot, CONNECT_ROUTES_GEN);
|
|
239
239
|
return join(projectRoot, ".ph", `${relative(projectRoot, routesDir)}.gen.ts`);
|
|
240
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
|
+
}
|
|
241
251
|
/** Connect's pathless sidebar layout; a project's routes in `_app/` render in it. */
|
|
242
252
|
const APP_LAYOUT = "_app";
|
|
243
253
|
function findRouteFile(dir, name) {
|
|
@@ -355,6 +365,13 @@ function writePackageRoutesModule(projectRoot, projectRoutes, routeNodes, option
|
|
|
355
365
|
const text = lines.join("\n");
|
|
356
366
|
if (!existsSync(module) || readFileSync(module, "utf8") !== text) writeFileSync(module, text);
|
|
357
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
|
+
}
|
|
358
375
|
/** The router plugin's config: Connect's root and routes, and the project's. */
|
|
359
376
|
function connectRoutesGeneratorConfig(connectDir, projectRoot, projectRoutes) {
|
|
360
377
|
const routesDirectory = connectRoutesDirOf(connectDir);
|
|
@@ -386,7 +403,7 @@ function connectRoutesGeneratorConfig(connectDir, projectRoot, projectRoutes) {
|
|
|
386
403
|
onRouteTreeChanged: ({ routeNodes }) => {
|
|
387
404
|
writePackageRoutesModule(projectRoot, projectRoutes, routeNodes, {
|
|
388
405
|
routesDirectory,
|
|
389
|
-
connectAppIds: new Set(routeFilesIn(join(routesDirectory, APP_LAYOUT)).map(routeIdOf))
|
|
406
|
+
connectAppIds: /* @__PURE__ */ new Set([...routeFilesIn(join(routesDirectory, APP_LAYOUT)).map(routeIdOf), ...genericAppRouteIds(connectDir)])
|
|
390
407
|
});
|
|
391
408
|
}
|
|
392
409
|
}] : [overrides],
|
|
@@ -406,17 +423,42 @@ function connectRoutesGeneratorConfig(connectDir, projectRoot, projectRoutes) {
|
|
|
406
423
|
]
|
|
407
424
|
}, projectRoot);
|
|
408
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
|
+
}
|
|
409
433
|
/** Writes the route tree of Connect's and the project's routes; throws on a
|
|
410
434
|
* collision that is not an override, which the router plugin would only log. */
|
|
411
|
-
async function generateConnectRoutes(projectRoot, routesDir, config = connectRoutesGeneratorConfig(connectDirOf(projectRoot), projectRoot, routesDir)) {
|
|
435
|
+
async function generateConnectRoutes(projectRoot, routesDir, config = connectRoutesGeneratorConfig(connectDirOf(projectRoot), projectRoot, routesDir), warn) {
|
|
412
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
|
+
};
|
|
413
444
|
try {
|
|
414
445
|
await new Generator({
|
|
415
|
-
config
|
|
446
|
+
config: {
|
|
447
|
+
...config,
|
|
448
|
+
plugins: [...config.plugins ?? [], collect]
|
|
449
|
+
},
|
|
416
450
|
root: projectRoot
|
|
417
451
|
}).run();
|
|
452
|
+
assertNoSharedUrls(routeNodes);
|
|
418
453
|
assertNoDuplicateRoutes(config.generatedRouteTree);
|
|
419
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
|
+
}
|
|
420
462
|
} catch (error) {
|
|
421
463
|
const message = (Array.isArray(error) ? error : [error]).map((e) => e instanceof Error ? e.message : String(e)).join("\n");
|
|
422
464
|
const shown = relative(projectRoot, routesDir).split(sep).join("/");
|
|
@@ -440,6 +482,72 @@ function assertNoDuplicateRoutes(treeFile) {
|
|
|
440
482
|
if (conflicts.length === 0) return;
|
|
441
483
|
throw new Error(`Conflicting configuration paths were found for a layout route.\nConflicting files: \n ${conflicts.flat().join("\n ")}\n`);
|
|
442
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
|
+
}
|
|
443
551
|
function escapeRegExp(text) {
|
|
444
552
|
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
445
553
|
}
|
|
@@ -455,7 +563,11 @@ function connectDirOf(projectRoot) {
|
|
|
455
563
|
return dirname(resolvePackage("@powerhousedao/connect/package.json", projectRoot));
|
|
456
564
|
}
|
|
457
565
|
/** What Connect's route files import, besides each other. */
|
|
458
|
-
const CONNECT_ROUTE_FILE_DEPS = [
|
|
566
|
+
const CONNECT_ROUTE_FILE_DEPS = [
|
|
567
|
+
"@tanstack/react-router",
|
|
568
|
+
"@powerhousedao/connect-core/router",
|
|
569
|
+
"@powerhousedao/connect/route-views"
|
|
570
|
+
];
|
|
459
571
|
const IN_NODE_MODULES = /[\\/]node_modules[\\/]/;
|
|
460
572
|
/**
|
|
461
573
|
* The `optimizeDeps.include` entries an installed Connect's route files need.
|
|
@@ -505,7 +617,10 @@ function connectRoutes(projectRoot, routesDir = resolveConnectRoutesDir(projectR
|
|
|
505
617
|
plugins: [{
|
|
506
618
|
name: "ph-connect-routes-check",
|
|
507
619
|
buildStart: () => generateConnectRoutes(projectRoot, routesDir, config)
|
|
508
|
-
}, tanstackRouter(
|
|
620
|
+
}, tanstackRouter({
|
|
621
|
+
...config,
|
|
622
|
+
plugins: [...config.plugins ?? [], dropsPlugin(projectRoot, routesDir, config.routesDirectory)]
|
|
623
|
+
})],
|
|
509
624
|
dedupe: ["@tanstack/react-router"],
|
|
510
625
|
include
|
|
511
626
|
};
|
|
@@ -886,7 +1001,7 @@ function resolveProjectPwaBrand(projectRoot, branding, warn) {
|
|
|
886
1001
|
* `branding.icon` (an SVG master is one scalable favicon). They replace
|
|
887
1002
|
* Connect's static icon.ico link in index.html; none keeps it. A favicon
|
|
888
1003
|
* named outright (`faviconPath`: `branding.favicon` or `--favicon`) wins: it
|
|
889
|
-
* is built as icon.ico, so the icon's siblings stand aside.
|
|
1004
|
+
* is built as icon.ico (or icon.svg, icon.png), so the icon's siblings stand aside.
|
|
890
1005
|
*/
|
|
891
1006
|
function resolveProjectFavicons(projectRoot, branding, warn, faviconPath) {
|
|
892
1007
|
const app = branding?.icon;
|
|
@@ -1170,12 +1285,37 @@ async function renderProjectAppShells(projectRoot, config, routeAliases, hostSty
|
|
|
1170
1285
|
const renderer = await server.ssrLoadModule("@powerhousedao/connect/prerender");
|
|
1171
1286
|
const stylesheet = join(projectRoot, "style.css");
|
|
1172
1287
|
const css = withHostStylesheet(readFileSync(stylesheet, "utf8"), stylesheet, hostStylesheet);
|
|
1173
|
-
|
|
1288
|
+
try {
|
|
1289
|
+
return await renderer.renderProjectShells(stylesheet, css);
|
|
1290
|
+
} catch (error) {
|
|
1291
|
+
throw withSourceLocations(error, (stack) => server.ssrRewriteStacktrace(stack));
|
|
1292
|
+
}
|
|
1174
1293
|
});
|
|
1175
1294
|
} finally {
|
|
1176
1295
|
await server.close();
|
|
1177
1296
|
}
|
|
1178
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
|
+
}
|
|
1179
1319
|
const sourceText = (source) => typeof source === "string" ? source : new TextDecoder().decode(source);
|
|
1180
1320
|
/** Build: the composition's shell in #root and every variant in the dist, from
|
|
1181
1321
|
* the project's routes when it has them. Dev: the shell from the project's routes
|
|
@@ -1203,11 +1343,27 @@ function connectAppShellPlugin(projectRoot, { composition, appName, routeAliases
|
|
|
1203
1343
|
};
|
|
1204
1344
|
let devShells;
|
|
1205
1345
|
let devRender;
|
|
1346
|
+
let devShellError;
|
|
1347
|
+
let devServer;
|
|
1206
1348
|
const renderDevShells = () => {
|
|
1207
1349
|
if (!config || !routeAliases) return;
|
|
1208
1350
|
const logger = config.logger;
|
|
1209
|
-
|
|
1210
|
-
|
|
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
|
+
});
|
|
1211
1367
|
return {};
|
|
1212
1368
|
});
|
|
1213
1369
|
};
|
|
@@ -1227,6 +1383,7 @@ function connectAppShellPlugin(projectRoot, { composition, appName, routeAliases
|
|
|
1227
1383
|
name: "ph-connect-app-shell",
|
|
1228
1384
|
configureServer(server) {
|
|
1229
1385
|
if (!routeAliases) return;
|
|
1386
|
+
devServer = server;
|
|
1230
1387
|
renderDevShells();
|
|
1231
1388
|
const stylesheet = join(projectRoot, "style.css");
|
|
1232
1389
|
const rerender = (file) => {
|
|
@@ -1250,10 +1407,11 @@ function connectAppShellPlugin(projectRoot, { composition, appName, routeAliases
|
|
|
1250
1407
|
order: "post",
|
|
1251
1408
|
handler: async (html) => {
|
|
1252
1409
|
const current = !isBuild && routeAliases ? await devShell() : shell();
|
|
1253
|
-
|
|
1410
|
+
const page = current ? injectAppShell(html, current, base, {
|
|
1254
1411
|
deferStyles: isBuild,
|
|
1255
1412
|
appName
|
|
1256
1413
|
}) : html;
|
|
1414
|
+
return devShellError ? withErrorOverlay(page, devShellError, base) : page;
|
|
1257
1415
|
}
|
|
1258
1416
|
},
|
|
1259
1417
|
generateBundle: {
|
|
@@ -2941,6 +3099,25 @@ const runtimeConfigSchema = {
|
|
|
2941
3099
|
connect: phConnectRuntimeConfigSchema
|
|
2942
3100
|
}
|
|
2943
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
|
+
}
|
|
2944
3121
|
const RESOLVED_VIRTUAL_ID = "\0virtual:ph-bundled-packages-virtual";
|
|
2945
3122
|
const BUNDLED_PACKAGES_DEV_URL = "@id/" + RESOLVED_VIRTUAL_ID.replace("\0", "__x00__");
|
|
2946
3123
|
function readBundledPackageVersion(projectRoot, name) {
|
|
@@ -3005,7 +3182,13 @@ const REACT_DEPS = [
|
|
|
3005
3182
|
"react-dom/client"
|
|
3006
3183
|
];
|
|
3007
3184
|
const SHIM_PATH = "__ph/dev-react-shim/";
|
|
3008
|
-
const
|
|
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
|
+
}
|
|
3009
3192
|
const VENDOR_MIME = {
|
|
3010
3193
|
".css": "text/css",
|
|
3011
3194
|
".map": "application/json",
|
|
@@ -3026,6 +3209,19 @@ const VENDOR_MODE = process.env.PH_CONNECT_EXTERNALIZE_VENDOR === "1";
|
|
|
3026
3209
|
const VENDOR_EXTRA = (process.env.PH_CONNECT_VENDOR_EXTRA ?? "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
3027
3210
|
const HEAVY_LIBS = [...DEFAULT_VENDOR_INCLUDE, ...VENDOR_EXTRA];
|
|
3028
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
|
+
}
|
|
3029
3225
|
function withBase$1(base, p) {
|
|
3030
3226
|
return `${base}${p}`.replace(/\/{2,}/g, "/");
|
|
3031
3227
|
}
|
|
@@ -3064,6 +3260,7 @@ function externalizePlugin(externals) {
|
|
|
3064
3260
|
async function devReactImportmapPlugin(projectRoot = process.cwd(), routesDir = resolveConnectRoutesDir(projectRoot)) {
|
|
3065
3261
|
let namedExports = /* @__PURE__ */ new Map();
|
|
3066
3262
|
let base = "/";
|
|
3263
|
+
let root = projectRoot;
|
|
3067
3264
|
let vendor = null;
|
|
3068
3265
|
const heavyLibs = heavyLibsFor(routesDir);
|
|
3069
3266
|
if (VENDOR_MODE) {
|
|
@@ -3084,6 +3281,16 @@ async function devReactImportmapPlugin(projectRoot = process.cwd(), routesDir =
|
|
|
3084
3281
|
const main = {
|
|
3085
3282
|
name: "ph-dev-react-importmap",
|
|
3086
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
|
+
},
|
|
3087
3294
|
config(cfg) {
|
|
3088
3295
|
cfg.optimizeDeps ??= {};
|
|
3089
3296
|
const include = new Set(cfg.optimizeDeps.include ?? []);
|
|
@@ -3096,6 +3303,7 @@ async function devReactImportmapPlugin(projectRoot = process.cwd(), routesDir =
|
|
|
3096
3303
|
},
|
|
3097
3304
|
configResolved(config) {
|
|
3098
3305
|
base = config.base;
|
|
3306
|
+
root = config.root;
|
|
3099
3307
|
},
|
|
3100
3308
|
configureServer(server) {
|
|
3101
3309
|
const requireFromRoot = createRequire(path.join(server.config.root, "package.json"));
|
|
@@ -3145,7 +3353,7 @@ async function devReactImportmapPlugin(projectRoot = process.cwd(), routesDir =
|
|
|
3145
3353
|
return;
|
|
3146
3354
|
}
|
|
3147
3355
|
const browserHash = info.browserHash ?? optimizer.metadata.browserHash;
|
|
3148
|
-
const depUrl = `${withBase$1(base,
|
|
3356
|
+
const depUrl = `${withBase$1(base, devUrlOf(root, info.file))}?v=${browserHash}`;
|
|
3149
3357
|
const names = namedExports.get(id) ?? [];
|
|
3150
3358
|
res.setHeader("Content-Type", "application/javascript");
|
|
3151
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` : ""));
|
|
@@ -3158,6 +3366,7 @@ async function devReactImportmapPlugin(projectRoot = process.cwd(), routesDir =
|
|
|
3158
3366
|
if (!browserHash) return;
|
|
3159
3367
|
const shimPrefix = withBase$1(base, SHIM_PATH);
|
|
3160
3368
|
const imports = Object.fromEntries(REACT_DEPS.map((id) => [id, `${shimPrefix}${id}.js?v=${browserHash}`]));
|
|
3369
|
+
Object.assign(imports, sharedDepImports(base));
|
|
3161
3370
|
let dynamicBaseScript = "";
|
|
3162
3371
|
if (vendorActive) {
|
|
3163
3372
|
for (const [spec, url] of Object.entries(vendor.imports)) imports[spec] = withBase$1(base, url);
|
|
@@ -3180,16 +3389,20 @@ const CONTENT_TYPE_BY_EXT = {
|
|
|
3180
3389
|
/**
|
|
3181
3390
|
* Vite plugin to serve the Connect favicon (icon.ico) from the connect package,
|
|
3182
3391
|
* or from a caller-supplied file when `faviconPath` is set (e.g. `ph connect
|
|
3183
|
-
* build --favicon`).
|
|
3184
|
-
* `<link rel="icon"
|
|
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.
|
|
3185
3395
|
*/
|
|
3186
3396
|
function connectFaviconPlugin(opts = {}) {
|
|
3187
3397
|
const customPath = opts.faviconPath ? isAbsolute(opts.faviconPath) ? opts.faviconPath : resolve(process.cwd(), opts.faviconPath) : void 0;
|
|
3188
|
-
const
|
|
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";
|
|
3189
3401
|
return {
|
|
3190
3402
|
name: "copy-connect-favicon",
|
|
3191
3403
|
configureServer(server) {
|
|
3192
|
-
const
|
|
3404
|
+
const base = server.config.base;
|
|
3405
|
+
const route = (name) => `${base}${name}`.replace(/\/{2,}/g, "/");
|
|
3193
3406
|
const handler = (_req, res, next) => {
|
|
3194
3407
|
if (customPath) {
|
|
3195
3408
|
try {
|
|
@@ -3206,12 +3419,21 @@ function connectFaviconPlugin(opts = {}) {
|
|
|
3206
3419
|
res.end(readFileSync(resolved.id));
|
|
3207
3420
|
}).catch(() => next());
|
|
3208
3421
|
};
|
|
3209
|
-
const paths = /* @__PURE__ */ new Set([
|
|
3422
|
+
const paths = /* @__PURE__ */ new Set([
|
|
3423
|
+
route(fileName),
|
|
3424
|
+
`/${fileName}`,
|
|
3425
|
+
route("icon.ico"),
|
|
3426
|
+
"/icon.ico"
|
|
3427
|
+
]);
|
|
3210
3428
|
for (const path of paths) server.middlewares.use(path, handler);
|
|
3211
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
|
+
},
|
|
3212
3434
|
async generateBundle(_options, bundle) {
|
|
3213
3435
|
try {
|
|
3214
|
-
if (
|
|
3436
|
+
if (fileName in bundle) return;
|
|
3215
3437
|
let source;
|
|
3216
3438
|
if (customPath) source = readFileSync(customPath);
|
|
3217
3439
|
else {
|
|
@@ -3221,7 +3443,7 @@ function connectFaviconPlugin(opts = {}) {
|
|
|
3221
3443
|
if (!source) return;
|
|
3222
3444
|
this.emitFile({
|
|
3223
3445
|
type: "asset",
|
|
3224
|
-
fileName
|
|
3446
|
+
fileName,
|
|
3225
3447
|
source
|
|
3226
3448
|
});
|
|
3227
3449
|
} catch {}
|
|
@@ -4333,9 +4555,14 @@ function getConnectBaseViteConfig(options) {
|
|
|
4333
4555
|
return {
|
|
4334
4556
|
configFile: false,
|
|
4335
4557
|
mode,
|
|
4558
|
+
cacheDir: options.cacheDir,
|
|
4336
4559
|
base: options.dynamicBase ? DYNAMIC_BASE_PLACEHOLDER : connectBasePath ? normalizeBasePath(connectBasePath) : void 0,
|
|
4337
4560
|
server: {
|
|
4338
|
-
watch: { ignored: [
|
|
4561
|
+
watch: { ignored: [
|
|
4562
|
+
"**/backup-documents/**",
|
|
4563
|
+
"**/coverage/**",
|
|
4564
|
+
ignoreDotPhButRouteTree(options.dirname, routesDir)
|
|
4565
|
+
] },
|
|
4339
4566
|
fs: { allow: [searchForWorkspaceRoot(options.dirname), ...linkedRoots] }
|
|
4340
4567
|
},
|
|
4341
4568
|
resolve: {
|
|
@@ -4355,17 +4582,7 @@ function getConnectBaseViteConfig(options) {
|
|
|
4355
4582
|
},
|
|
4356
4583
|
customLogger,
|
|
4357
4584
|
envPrefix: ["PH_CONNECT_"],
|
|
4358
|
-
optimizeDeps:
|
|
4359
|
-
include: [
|
|
4360
|
-
"document-model",
|
|
4361
|
-
"zod",
|
|
4362
|
-
"@powerhousedao/design-system/connect",
|
|
4363
|
-
"@powerhousedao/reactor-browser",
|
|
4364
|
-
"@powerhousedao/document-engineering",
|
|
4365
|
-
...routes.include
|
|
4366
|
-
],
|
|
4367
|
-
exclude: ["@electric-sql/pglite", "@electric-sql/pglite-tools"]
|
|
4368
|
-
},
|
|
4585
|
+
optimizeDeps: connectOptimizeDeps(options.dirname, routesDir, routes.include),
|
|
4369
4586
|
plugins: [
|
|
4370
4587
|
configPlugin,
|
|
4371
4588
|
hostStylesheetPlugin(options.dirname, hostStylesheet),
|
|
@@ -4417,6 +4634,6 @@ function getConnectBaseViteConfig(options) {
|
|
|
4417
4634
|
};
|
|
4418
4635
|
}
|
|
4419
4636
|
//#endregion
|
|
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 };
|
|
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 };
|
|
4421
4638
|
|
|
4422
4639
|
//# sourceMappingURL=index.mjs.map
|