@powerhousedao/builder-tools 6.2.3-dev.5 → 6.2.3-dev.50

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 CHANGED
@@ -1,17 +1,17 @@
1
+ import { DYNAMIC_BASE_PLACEHOLDER } from "@powerhousedao/shared/connect";
1
2
  import { CommonServerOptions, HtmlTagDescriptor, InlineConfig, Plugin } from "vite";
2
3
  import { PowerhouseConfig, PowerhousePackage } from "@powerhousedao/config";
3
- import { PHConnectRuntimeConfig } from "@powerhousedao/shared/clis";
4
-
4
+ import { PHConnectRuntimeConfig, PowerhouseConfig as PowerhouseConfig$1 } from "@powerhousedao/shared/clis";
5
5
  //#region connect-utils/constants.d.ts
6
- declare const EXTERNAL_PACKAGES_IMPORT = "PH:EXTERNAL_PACKAGES";
7
- declare const IMPORT_SCRIPT_FILE = "external-packages.js";
8
- declare const LOCAL_PACKAGE_ID = "ph:local-package";
9
- declare const PH_DIR_NAME = ".ph";
6
+ export declare const EXTERNAL_PACKAGES_IMPORT = "PH:EXTERNAL_PACKAGES";
7
+ export declare const IMPORT_SCRIPT_FILE = "external-packages.js";
8
+ export declare const LOCAL_PACKAGE_ID = "ph:local-package";
9
+ export declare const PH_DIR_NAME = ".ph";
10
10
  //#endregion
11
11
  //#region connect-utils/vite-plugins/build-hash.d.ts
12
12
  /** Name of the build-identity file emitted into the build output. */
13
- declare const BUILD_HASH_FILE: "build-hash.json";
14
- interface BuildHashInput {
13
+ export declare const BUILD_HASH_FILE: "build-hash.json";
14
+ export interface BuildHashInput {
15
15
  /** Monorepo workspace git SHA (CI/dev builds); empty outside the monorepo. */
16
16
  workspaceGitSha: string;
17
17
  /** Monorepo workspace version (CI/dev builds); empty outside it. */
@@ -38,8 +38,8 @@ interface BuildHashInput {
38
38
  * (define `PH_CONNECT_BUILD_HASH`) to `build-hash.json`, which the build
39
39
  * emits alongside the app and the server must serve no-cache.
40
40
  */
41
- declare function computeBuildHash(input: BuildHashInput): string;
42
- declare function buildHashFromBuildOptions(options: {
41
+ export declare function computeBuildHash(input: BuildHashInput): string;
42
+ export declare function buildHashFromBuildOptions(options: {
43
43
  dirname: string;
44
44
  phConfig: unknown;
45
45
  packages: ReadonlyArray<{
@@ -57,13 +57,13 @@ declare function buildHashFromBuildOptions(options: {
57
57
  * Build-only: dev (studio) never runs generateBundle, and the SPA check
58
58
  * treats a missing file as "nothing to compare" and stays silent.
59
59
  */
60
- declare function connectBuildHashPlugin(buildHash: string): Plugin;
60
+ export declare function connectBuildHashPlugin(buildHash: string): Plugin;
61
61
  //#endregion
62
62
  //#region connect-utils/externalize-vendor.d.ts
63
- interface VendorPrebuildOptions {
64
- /** Project root (the reactor-project dir). */
63
+ export interface VendorPrebuildOptions {
64
+ /** Project root the vendor deps resolve from. */
65
65
  dirname: string;
66
- /** Bare specifiers to bundle into the vendor (defaults to the heavy libs). */
66
+ /** Specifiers to prebuild into the vendor (defaults to the dev set). */
67
67
  include?: string[];
68
68
  /** Specifiers left external to the build (defaults to the React family). */
69
69
  external?: string[];
@@ -73,35 +73,305 @@ interface VendorPrebuildOptions {
73
73
  errorRef?: {
74
74
  message?: string;
75
75
  };
76
+ /**
77
+ * The APP's base — the same string the app build uses (the dynamic-base
78
+ * placeholder, or a normalized deploy base like "/app/"). The vendor's own
79
+ * build base is this plus the vendor segment, so emitted asset URLs land
80
+ * under <app-base>__vendor__/. Default: the dynamic placeholder + segment
81
+ * (dev behavior). Import-map values stay base-relative; the production
82
+ * build strips the leading slash (values then resolve against the page URL
83
+ * under any deploy base), the dev flow prefixes its own base.
84
+ */
85
+ base?: string;
86
+ /** NODE_ENV define for the vendor build (default "development"). */
87
+ nodeEnv?: "development" | "production";
76
88
  }
77
89
  /**
78
90
  * The stable Connect libraries worth prebuilding. The React family is NOT here —
79
91
  * it's externalized from the build (see `VENDOR_EXTERNAL`) so the vendor shares
80
92
  * the dev server's single React instance via the import map.
81
93
  */
82
- declare const DEFAULT_VENDOR_INCLUDE: string[];
94
+ export declare const DEFAULT_VENDOR_INCLUDE: string[];
83
95
  /**
84
96
  * React-family specifiers kept external to the vendor build. The vendor's chunks
85
97
  * emit bare imports for these; `devReactImportmapPlugin`'s import map resolves
86
98
  * them to Vite's pre-bundled React, so there is exactly one React instance.
87
99
  */
88
- declare const VENDOR_EXTERNAL: string[];
89
- interface PrebuiltVendor {
100
+ export declare const VENDOR_EXTERNAL: string[];
101
+ export interface PrebuiltVendor {
90
102
  vendorDir: string;
91
- /** import map: bare specifier -> "/__vendor__/<entry>.js". */
103
+ /** import map: bare specifier -> "/__vendor__/<entry>.js" (base-relative). */
92
104
  imports: Record<string, string>;
105
+ /** Resolved versions of every included + external package. */
106
+ versions: Record<string, string>;
93
107
  }
94
108
  /** URL prefix the vendor bundle is served under by the dev middleware. */
95
- declare const VENDOR_URL_PREFIX = "/__vendor__/";
109
+ export declare const VENDOR_URL_PREFIX = "/__vendor__/";
96
110
  /**
97
111
  * Build the prebuilt vendor (once, in a throwaway subprocess) and return its dir
98
112
  * + import map. Idempotent: reuses a cached vendor built for the same dep set.
99
113
  * Returns null on any failure (caller falls back to a normal dev server).
100
114
  */
101
- declare function prebuildConnectVendor(options: VendorPrebuildOptions): Promise<PrebuiltVendor | null>;
115
+ export declare function prebuildConnectVendor(options: VendorPrebuildOptions): Promise<PrebuiltVendor | null>;
116
+ export declare const LOCK_STALE_MS: number;
117
+ export interface VendorLock {
118
+ dir: string;
119
+ token: string;
120
+ timer: ReturnType<typeof setInterval>;
121
+ }
122
+ export declare function acquireLock(lockDir: string): VendorLock | null;
123
+ export declare function releaseLock(lock: VendorLock): void;
124
+ /**
125
+ * The published specifiers whose entry file the vendor build never emitted.
126
+ * URLs are base-less (`/__vendor__/x.js`) and resolve inside `vendorDir`.
127
+ */
128
+ export declare function missingVendorEntries(vendorDir: string, imports: Record<string, string>): {
129
+ spec: string;
130
+ url: string;
131
+ }[];
132
+ /**
133
+ * Rebase the vendor's base-less entry URLs (`/__vendor__/x.js`) onto the
134
+ * deploy base, so a consumer that resolves them against the page origin lands
135
+ * under that base rather than the server root. A dynamic-base build keeps its
136
+ * placeholder, which the runtime substitutes.
137
+ *
138
+ * `base` is the app base from `prebuildConnectVendor` callers, but the
139
+ * VENDOR_DYNAMIC_BASE default already carries the vendor segment — that
140
+ * trailing segment is dropped first so it is never doubled.
141
+ */
142
+ export declare function withVendorBase(imports: Record<string, string>, base: string): Record<string, string>;
143
+ //#endregion
144
+ //#region connect-utils/reactor-worker-build.d.ts
145
+ /** URL prefix the worker bundle is served under, next to `__vendor__/`. */
146
+ export declare const REACTOR_WORKER_URL_PREFIX = "/__reactor_worker__/";
147
+ /** Entry filename of the bundle; the tab constructs its SharedWorker from it. */
148
+ export declare const REACTOR_WORKER_ENTRY = "reactor.worker.js";
149
+ /** Content-Type for the extensions the worker build emits; JS is the default. */
150
+ export declare const REACTOR_WORKER_MIME: Record<string, string>;
151
+ export interface ReactorWorkerVendorOptions {
152
+ /** The vendor's import map (`spec -> /__vendor__/<entry>.js`). */
153
+ imports: Record<string, string>;
154
+ /** The built vendor dir, needed to verify which entries are worker-safe. */
155
+ dir: string;
156
+ }
157
+ export interface ReactorWorkerBuildOptions {
158
+ /** Project root the worker's dependencies resolve from. */
159
+ dirname: string;
160
+ /** Directory to hold the bundle (e.g. `<dist>/__reactor_worker__`). */
161
+ outDir: string;
162
+ /**
163
+ * The prebuilt vendor to share dependencies with. Only the worker-safe
164
+ * subset of its entries is externalized (see
165
+ * {@link workerSafeVendorImports}); omit to bundle everything.
166
+ */
167
+ vendor?: ReactorWorkerVendorOptions;
168
+ /**
169
+ * Worker entry to build. Defaults to the installed Connect dist's
170
+ * `reactor.worker.js`; tests inject a fixture entry here.
171
+ */
172
+ entryPath?: string;
173
+ /** NODE_ENV define for the build (default "development"). */
174
+ nodeEnv?: "development" | "production";
175
+ /** Filled with the failure cause when the prebuild returns null. */
176
+ errorRef?: {
177
+ message?: string;
178
+ };
179
+ }
180
+ export interface PrebuiltReactorWorker {
181
+ outDir: string;
182
+ /** Entry filename inside outDir ({@link REACTOR_WORKER_ENTRY}). */
183
+ entry: string;
184
+ /**
185
+ * Digest of everything that shaped this bundle's output (see
186
+ * {@link computeSourceDigest}); identical for a cache hit and a fresh
187
+ * build. The dev plugin serves it in `worker-meta.json` next to the
188
+ * bundle; `apps/connect/src/utils/reactor-worker-url.ts` fetches it to
189
+ * fold the actual built worker code into the tab's version fingerprint
190
+ * (W0.6).
191
+ */
192
+ sourceDigest: string;
193
+ /**
194
+ * The worker-safe vendor subset this bundle externalizes (see
195
+ * {@link workerSafeVendorImports}); empty without a vendor.
196
+ */
197
+ vendorImports: Record<string, string>;
198
+ }
199
+ /**
200
+ * The installed Connect dist's worker entry, or null when the installed
201
+ * version predates the worker (the feature is then unavailable, not broken).
202
+ */
203
+ export declare function resolveReactorWorkerSource(dirname: string): string | null;
204
+ /** `/__vendor__/<entry>.js` -> `../__vendor__/<entry>.js` (sibling dirs). */
205
+ export declare function vendorRelativePath(vendorUrl: string): string;
206
+ /**
207
+ * Module specifiers a worker cannot resolve: anything that is not relative,
208
+ * root-relative, or an http(s)/data/blob URL. Used as a post-build guard so a
209
+ * leftover bare (or `node:`) import fails the build with a name instead of
210
+ * shipping a worker that dies on its first import statement.
211
+ *
212
+ * Expects minified (comment-free) output: a raw-text scan cannot tell a real
213
+ * import from a JSDoc code sample, and unminified kysely/viem are full of the
214
+ * latter. The build below always minifies for exactly this reason.
215
+ */
216
+ export declare function findDisallowedSpecifiers(code: string): string[];
217
+ /**
218
+ * Packages whose BUILT dist shapes the worker bundle's output even when
219
+ * connect's own dist/reactor.worker.js entry file did not change.
220
+ *
221
+ * That entry is a library artifact whose bare imports this build resolves
222
+ * through node_modules at BUILD time, so a rebuilt dist anywhere in its
223
+ * closure changes the bundle output without touching the entry file's own
224
+ * size/mtime. The list is DERIVED from the installed Connect's own
225
+ * dependencies rather than hardcoded: the bundle pulls `@renown/sdk`,
226
+ * `@powerhousedao/powerhouse-vetra-packages` and `@powerhousedao/shared` out
227
+ * of node_modules too, and a hardcoded pair left every one of those able to be
228
+ * rebuilt behind a cache hit. Connect's dependency list is the cheap stand-in
229
+ * for the resolved bundle graph: every workspace package the worker can reach
230
+ * is reachable through it, and a package not in the bundle only costs a readdir.
231
+ */
232
+ export declare function upstreamWorkerPackages(dirname: string): string[];
233
+ /**
234
+ * This module's own installed version, read by walking up from its file to
235
+ * the nearest `package.json` named "@powerhousedao/builder-tools" (same
236
+ * technique as `build-hash.ts`'s `readConnectVersion`: builder-tools'
237
+ * `exports` map has no `./package.json` subpath, so node resolution can't
238
+ * get there). Works whether this runs from source (tests, this monorepo) or
239
+ * the built dist.
240
+ */
241
+ export declare function resolveOwnPackageVersion(): string;
242
+ /**
243
+ * This package's own version, computed once. Folded into the worker bundle
244
+ * cache key so a builder-tools release — which can change how the bundle is
245
+ * built (anything in this module beyond {@link WORKER_BUILD_WORKER} itself,
246
+ * e.g. `workerSafeVendorImports`, the resolve plugin) — invalidates bundles
247
+ * a prior builder-tools version cached.
248
+ */
249
+ export declare const BUILDER_TOOLS_VERSION: string;
250
+ /**
251
+ * A workspace package's real directory, resolved the way Node's resolver
252
+ * would (through `node_modules`), or null when it is not installed (e.g. a
253
+ * non-monorepo consumer project — graceful, not an error). pnpm's
254
+ * node_modules symlinks resolve to the real package directory, so this
255
+ * reflects the monorepo's actual dist state, not a stale symlink target.
256
+ */
257
+ export declare function resolveWorkspacePackageDir(dirname: string, pkgName: string): string | null;
258
+ /**
259
+ * Cheap content fingerprint of a directory's immediate files: no file bytes
260
+ * are read, just each entry's name/size/mtime, so it stays fast even for a
261
+ * large dist. Sensitive to a rebuild in the common cases: Vite's
262
+ * content-hashed chunk filenames change the name itself; a stable-named file
263
+ * (an entry point) changes size or mtime. Bounded (`maxFiles`) so a
264
+ * pathological directory cannot make this slow — deliberately not a
265
+ * full-tree hash.
266
+ *
267
+ * The names are sorted BEFORE the bound is applied, so the subset the bound
268
+ * keeps is the same subset on every run: readdir order is unspecified, and
269
+ * truncating it first made the fingerprint of a directory past the bound a
270
+ * function of whatever order the filesystem happened to report.
271
+ */
272
+ export declare function distDirFingerprint(dir: string, maxFiles?: number): string;
273
+ export declare function computeSourceDigest(dirname: string, entryPath: string, vendorDir?: string, builderToolsVersion?: string): string;
274
+ /**
275
+ * Build the worker bundle (once, in a throwaway subprocess) into `outDir`.
276
+ * Idempotent: reuses a cached bundle built from the same connect dist, vendor
277
+ * mapping, and builder logic. Returns null on failure (`errorRef` carries the
278
+ * cause) or when the installed Connect has no worker entry.
279
+ */
280
+ export declare function prebuildReactorWorker(options: ReactorWorkerBuildOptions): Promise<PrebuiltReactorWorker | null>;
281
+ /** Replace `outDir` with the finished `tmpDir`, old contents removed last. */
282
+ export declare function publishDirAtomic(tmpDir: string, outDir: string): void;
283
+ /**
284
+ * Scan the emitted JS files REACHABLE from the entry via import statements
285
+ * for specifiers a worker cannot resolve. Vendor externals were rewritten to
286
+ * ../__vendor__/ relative paths, so anything bare that survives in the graph
287
+ * is a real defect.
288
+ *
289
+ * Deliberately a graph walk, not a directory walk: the bundled reactor code
290
+ * carries `new URL(..., import.meta.url)` references to its node
291
+ * worker-thread entries (executor/projection workers), which Vite emits as
292
+ * stray assets full of node-only imports. They are unreachable dead weight in
293
+ * a browser bundle — the production vendor output tolerates the same files —
294
+ * and must not fail the build.
295
+ */
296
+ export declare function findBundleSpecifierOffenders(bundleDir: string, entry?: string): {
297
+ file: string;
298
+ specs: string[];
299
+ }[];
300
+ /** The page-only markers present in `code`, in a fixed order. */
301
+ export declare function findWorkerUnsafeMarkers(code: string): string[];
302
+ /**
303
+ * The subset of the vendor's entries a worker may import.
304
+ *
305
+ * The vendor build keeps the React family external: its chunks carry bare
306
+ * `import "react"` statements that the PAGE resolves through its import map.
307
+ * A worker resolves no import map, so externalizing a vendor spec whose chunk
308
+ * closure reaches such an import would kill the worker on its first load —
309
+ * and the chunk graph is shared across vendor entries, so even a React-free
310
+ * module (e.g. an rpc subpath) can be entangled with React through a shared
311
+ * chunk. The vendor is also built for the page: a dynamic-base build rewrites
312
+ * its asset URLs onto a global only the page sets, and its dynamic imports go
313
+ * through Vite's preload helper, which needs `document`. Each entry's own
314
+ * closure inside the vendor dir decides: clean closure, worker-safe; anything
315
+ * bare or page-only in it (see {@link findWorkerUnsafeMarkers}), or a missing
316
+ * entry file, bundled into the worker instead.
317
+ */
318
+ export declare function workerSafeVendorImports(vendorDir: string, vendorImports: Record<string, string>): Record<string, string>;
319
+ /**
320
+ * Builds arbitrary worker-loadable entries with the worker build config.
321
+ * Exported for the local-package bundles, which need the same self-contained
322
+ * output and vendor externalization at a different depth.
323
+ */
324
+ export declare function runWorkerBuildEntries(dirname: string, outDir: string, entries: Record<string, string>, vendorImports: Record<string, string>, nodeEnv: "development" | "production", vendorPrefix?: string): Promise<{
325
+ ok: boolean;
326
+ stderr: string;
327
+ }>;
328
+ //#endregion
329
+ //#region connect-utils/worker-packages-build.d.ts
330
+ /** Served under `<base>__reactor_worker__/packages/`. */
331
+ export declare const WORKER_PACKAGES_MANIFEST = "manifest.json";
332
+ export interface WorkerPackagesBuildOptions {
333
+ /** Project root the packages resolve from. */
334
+ dirname: string;
335
+ /** Local package names (`provider: "local"` in powerhouse.config.json). */
336
+ packages: string[];
337
+ /** Directory to hold the bundles (`<dist>/__reactor_worker__/packages`). */
338
+ outDir: string;
339
+ /** The prebuilt vendor to share dependencies with, when one was built. */
340
+ vendor?: ReactorWorkerVendorOptions;
341
+ /**
342
+ * The vendor's worker-safe subset, when the caller already computed it
343
+ * (`PrebuiltReactorWorker.vendorImports`); skips walking the vendor again.
344
+ */
345
+ safeVendorImports?: Record<string, string>;
346
+ nodeEnv?: "development" | "production";
347
+ errorRef?: {
348
+ message?: string;
349
+ };
350
+ }
351
+ export interface WorkerPackageManifestEntry {
352
+ name: string;
353
+ version?: string;
354
+ /** Filename inside outDir, as {@link workerPackageFileName} spells it. */
355
+ file: string;
356
+ }
357
+ /**
358
+ * The project's own package name when it ships a models bundle, so a caller
359
+ * can include it beside the configured `provider: "local"` packages. A vetra
360
+ * project declares no package entry for itself, yet its models are exactly
361
+ * the ones the worker is missing.
362
+ */
363
+ export declare function ownProjectPackage(dirname: string): string | undefined;
364
+ /**
365
+ * Build each local package's models entry into `outDir` and write the
366
+ * manifest the tab reads. Returns the manifest entries (empty when no local
367
+ * package ships a models bundle), or null when the build itself failed -
368
+ * `errorRef` then carries the cause. Both of those remove `outDir`, so a
369
+ * previous build's bundles never outlive the packages they came from.
370
+ */
371
+ export declare function prebuildWorkerPackages(options: WorkerPackagesBuildOptions): Promise<WorkerPackageManifestEntry[] | null>;
102
372
  //#endregion
103
373
  //#region connect-utils/types.d.ts
104
- type IConnectOptions = {
374
+ export type IConnectOptions = {
105
375
  mode: string;
106
376
  dirname: string;
107
377
  envDir?: string;
@@ -127,8 +397,18 @@ type IConnectOptions = {
127
397
  cliPackageRegistryUrl?: string;
128
398
  dynamicBase?: boolean;
129
399
  favicon?: string;
400
+ /**
401
+ * Production vendor: the prebuilt shared-dependency bundle's import map and
402
+ * version table (from `prebuildConnectVendor`). When set on a production
403
+ * build, the shared specifiers are externalized from the app bundle and
404
+ * merged into the page import map. Build input only.
405
+ */
406
+ vendor?: {
407
+ imports: Record<string, string>;
408
+ versions: Record<string, string>;
409
+ };
130
410
  };
131
- type ConnectCommonOptions = {
411
+ export type ConnectCommonOptions = {
132
412
  base?: string;
133
413
  mode?: string;
134
414
  configFile?: string;
@@ -138,71 +418,71 @@ type ConnectCommonOptions = {
138
418
  defaultDrivesUrl?: string[];
139
419
  drivesPreserveStrategy?: "preserve-all" | "preserve-by-url-and-detach";
140
420
  };
141
- type ViteDevOptions = Pick<CommonServerOptions, "port" | "host" | "open" | "cors" | "strictPort"> & {
421
+ export type ViteDevOptions = Pick<CommonServerOptions, "port" | "host" | "open" | "cors" | "strictPort"> & {
142
422
  force?: boolean;
143
423
  };
144
- type ConnectStudioOptions = ConnectCommonOptions & {
424
+ export type ConnectStudioOptions = ConnectCommonOptions & {
145
425
  devServerOptions?: ViteDevOptions;
146
426
  printUrls?: boolean;
147
427
  bindCLIShortcuts?: boolean;
148
428
  };
149
- type ConnectBuildOptions = ConnectCommonOptions & {
429
+ export type ConnectBuildOptions = ConnectCommonOptions & {
150
430
  outDir?: string;
151
431
  };
152
- type ConnectPreviewOptions = ConnectCommonOptions & Omit<ViteDevOptions, "cors"> & {
432
+ export type ConnectPreviewOptions = ConnectCommonOptions & Omit<ViteDevOptions, "cors"> & {
153
433
  outDir?: string;
154
434
  printUrls?: boolean;
155
435
  bindCLIShortcuts?: boolean;
156
436
  };
157
437
  //#endregion
158
438
  //#region connect-utils/helpers.d.ts
159
- declare const DEFAULT_CONNECT_OUTDIR: ".ph/connect-build/dist/";
160
- declare function resolveViteConfigPath(options: Pick<ConnectCommonOptions, "projectRoot" | "viteConfigFile">): string;
161
- declare function resolvePackage(packageName: string, root?: string): string;
162
- declare function resolveConnectPackageJson(root?: string): JSON | null;
439
+ export declare const DEFAULT_CONNECT_OUTDIR: ".ph/connect-build/dist/";
440
+ export declare function resolveViteConfigPath(options: Pick<ConnectCommonOptions, "projectRoot" | "viteConfigFile">): string;
441
+ export declare function resolvePackage(packageName: string, root?: string): string;
442
+ export declare function resolveConnectPackageJson(root?: string): JSON | null;
163
443
  /**
164
444
  * Finds the dist dir of Connect on the local machine
165
445
  */
166
- declare function resolveConnectBundle(root?: string): string;
167
- declare function resolveConnectPublicDir(root?: string): string;
446
+ export declare function resolveConnectBundle(root?: string): string;
447
+ export declare function resolveConnectPublicDir(root?: string): string;
168
448
  /**
169
449
  * Copies the Connect dist dir to the target path
170
450
  */
171
- declare function copyConnect(sourcePath: string, targetPath: string): void;
451
+ export declare function copyConnect(sourcePath: string, targetPath: string): void;
172
452
  /**
173
453
  * Backs up the index.html file
174
454
  *
175
455
  * Needed when running the Connect Studio dev server on Windows
176
456
  */
177
- declare function backupIndexHtml(appPath: string, restore?: boolean): void;
178
- declare function removeBase64EnvValues(appPath: string): void;
179
- declare function readJsonFile(filePath: string): PowerhouseConfig | null;
457
+ export declare function backupIndexHtml(appPath: string, restore?: boolean): void;
458
+ export declare function removeBase64EnvValues(appPath: string): void;
459
+ export declare function readJsonFile(filePath: string): PowerhouseConfig | null;
180
460
  /**
181
461
  * Takes a list of Powerhouse project packages and optionally local Powerhouse packages and outputs a js file which exports those packages for use in Connect Studio.
182
462
  */
183
- declare function makeImportScriptFromPackages(args: {
463
+ export declare function makeImportScriptFromPackages(args: {
184
464
  packages: string[];
185
465
  importStyles?: boolean;
186
466
  localJsPath?: string;
187
467
  localCssPath?: string;
188
468
  }): string;
189
- declare function ensureNodeVersion(minVersion?: string): void;
190
- declare function runShellScriptPlugin(scriptName: string, connectPath: string): Plugin;
469
+ export declare function ensureNodeVersion(minVersion?: string): void;
470
+ export declare function runShellScriptPlugin(scriptName: string, connectPath: string): Plugin;
191
471
  /**
192
472
  * Appends the contents to the <head> tag of the index.html file
193
473
  */
194
- declare function appendToHtmlHead(pathToHtml: string, contents: string): Promise<void>;
474
+ export declare function appendToHtmlHead(pathToHtml: string, contents: string): Promise<void>;
195
475
  /**
196
476
  * Prepends the contents to the <head> tag of the index.html file
197
477
  */
198
- declare function prependToHtmlHead(pathToHtml: string, contents: string): Promise<void>;
199
- declare function runTsc(outDir: string): void;
200
- declare function stripVersionFromPackage(packageName: string): string;
478
+ export declare function prependToHtmlHead(pathToHtml: string, contents: string): Promise<void>;
479
+ export declare function runTsc(outDir: string): void;
480
+ export declare function stripVersionFromPackage(packageName: string): string;
201
481
  //#endregion
202
482
  //#region connect-utils/runtime-config-schema.d.ts
203
- declare const RUNTIME_CONFIG_SCHEMA_ID = "https://powerhouse.inc/schemas/powerhouse.config.json";
204
- declare const RUNTIME_CONFIG_SCHEMA_URL = "https://raw.githubusercontent.com/powerhouse-inc/powerhouse/main/packages/builder-tools/connect-utils/runtime-config.schema.json";
205
- declare const runtimeConfigSchema: {
483
+ export declare const RUNTIME_CONFIG_SCHEMA_ID = "https://powerhouse.inc/schemas/powerhouse.config.json";
484
+ export declare const RUNTIME_CONFIG_SCHEMA_URL = "https://raw.githubusercontent.com/powerhouse-inc/powerhouse/main/packages/builder-tools/connect-utils/runtime-config.schema.json";
485
+ export declare const runtimeConfigSchema: {
206
486
  readonly $schema: "http://json-schema.org/draft-07/schema#";
207
487
  readonly $id: "https://powerhouse.inc/schemas/powerhouse.config.json";
208
488
  readonly title: "Powerhouse Connect runtime configuration";
@@ -315,6 +595,10 @@ declare const runtimeConfigSchema: {
315
595
  readonly description: "Studio mode. Enables builder-only capabilities: Connect loads the vetra package and exposes DocumentModel (and vetra spec types) as creatable documents. Forced on by `ph vetra` / `ph connect studio`; false by default.";
316
596
  readonly default: false;
317
597
  };
598
+ readonly workflowsEnabled: {
599
+ readonly type: "boolean";
600
+ readonly description: "Powerhouse workflows in Connect. When true the tab loads the @powerhousedao/workflow package (workflow + connection documents, their editors and Workflow Studio) and the reactor worker registers its document models. Falls back to the top-level `workflows.enabled`; set it to override that for Connect. Independent of studioMode. False when neither is set.";
601
+ };
318
602
  };
319
603
  };
320
604
  readonly ai: {
@@ -406,7 +690,7 @@ declare const runtimeConfigSchema: {
406
690
  readonly preserveStrategy: {
407
691
  readonly type: "string";
408
692
  readonly enum: readonly ["preserve-all", "preserve-by-url-and-detach"];
409
- readonly description: "Strategy applied when defaultDrives change between deploys. 'preserve-all' keeps user-added drives untouched; 'preserve-by-url-and-detach' detaches removed default drives. No schema default \u2014 opt-in only.";
693
+ readonly description: "Strategy applied when defaultDrives change between deploys. 'preserve-all' keeps user-added drives untouched; 'preserve-by-url-and-detach' detaches removed default drives. No schema default — opt-in only.";
410
694
  };
411
695
  readonly sections: {
412
696
  readonly type: "object";
@@ -557,6 +841,32 @@ declare const runtimeConfigSchema: {
557
841
  };
558
842
  };
559
843
  };
844
+ readonly openPanel: {
845
+ readonly type: "object";
846
+ readonly additionalProperties: false;
847
+ readonly description: "OpenPanel product analytics. Set `clientId` to enable; an empty `clientId` disables it. Events are only sent after the user accepts analytics cookies. Takes precedence over the build-time PH_CONNECT_OPENPANEL_* env vars.";
848
+ readonly properties: {
849
+ readonly clientId: {
850
+ readonly type: "string";
851
+ readonly description: "OpenPanel client id. Empty string disables OpenPanel entirely.";
852
+ readonly default: "";
853
+ };
854
+ readonly apiUrl: {
855
+ readonly type: "string";
856
+ readonly description: "OpenPanel API URL for self-hosted instances (e.g. 'https://openpanel.example/api'). Omit to use OpenPanel's hosted API.";
857
+ };
858
+ readonly trackUiEvents: {
859
+ readonly type: "boolean";
860
+ readonly description: "Track UI events.";
861
+ readonly default: true;
862
+ };
863
+ readonly trackOperations: {
864
+ readonly type: "boolean";
865
+ readonly description: "Track document operations.";
866
+ readonly default: true;
867
+ };
868
+ };
869
+ };
560
870
  readonly instance: {
561
871
  readonly type: "object";
562
872
  readonly additionalProperties: false;
@@ -570,7 +880,7 @@ declare const runtimeConfigSchema: {
570
880
  };
571
881
  readonly reactorWorker: {
572
882
  readonly type: "boolean";
573
- readonly description: "Host the reactor in a shared worker instead of on the main thread. Off by default; the main-thread reactor stays the proven path until cutover is verified.";
883
+ readonly description: "Host the reactor in a shared worker instead of on the main thread. Off by default; the main-thread reactor stays the proven path until cutover is verified. Packaged deployments load the worker from the prebuilt bundle `ph connect build` emits under __reactor_worker__/ (the dev server builds it lazily at the same path); when that bundle is absent the feature reports itself unavailable instead of starting a worker that cannot load.";
574
884
  readonly default: false;
575
885
  };
576
886
  };
@@ -607,12 +917,24 @@ declare const runtimeConfigSchema: {
607
917
  };
608
918
  };
609
919
  };
920
+ readonly createSignaturePolicy: {
921
+ readonly type: "string";
922
+ readonly enum: readonly ["legacy", "v2-required"];
923
+ readonly description: "What new documents are created as. `v2-required` documents accept only v2 action signatures and take content-addressed ids; set `legacy` while any peer Connect syncs with predates them. Existing documents keep their policy.";
924
+ readonly default: "v2-required";
925
+ };
926
+ readonly unsupportedStoredDocuments: {
927
+ readonly type: "string";
928
+ readonly enum: readonly ["refuse", "read-only"];
929
+ readonly description: "What the reactor does when this browser's store holds documents at protocol versions this build does not run. `refuse` fails the boot and names the versions; `read-only` boots and keeps those documents read-only.";
930
+ readonly default: "refuse";
931
+ };
610
932
  };
611
933
  };
612
934
  readonly pwa: {
613
935
  readonly type: "object";
614
936
  readonly additionalProperties: false;
615
- readonly description: "Progressive-web-app / service-worker overrides, layered on Connect's built-in PWA defaults at build time. Scalar fields deep-merge (this layer wins); the array members (icons, file_handlers, globs, runtimeCaching and denylist patterns) are additive; maximumFileSizeToCacheInBytes takes the max across contributors. (categories is not set here \u2014 it is derived from the manifest's category field.) Only applied when connect.app.offline is true.";
937
+ readonly description: "Progressive-web-app / service-worker overrides, layered on Connect's built-in PWA defaults at build time. Scalar fields deep-merge (this layer wins); the array members (icons, file_handlers, globs, runtimeCaching and denylist patterns) are additive; maximumFileSizeToCacheInBytes takes the max across contributors. (categories is not set here — it is derived from the manifest's category field.) Only applied when connect.app.offline is true.";
616
938
  readonly properties: {
617
939
  readonly manifest: {
618
940
  readonly type: "object";
@@ -677,7 +999,7 @@ declare const runtimeConfigSchema: {
677
999
  readonly properties: {
678
1000
  readonly accept: {
679
1001
  readonly type: "object";
680
- readonly description: "MIME type \u2192 file extensions. Each extension must start with '.'; browsers ignore entries without it.";
1002
+ readonly description: "MIME type → file extensions. Each extension must start with '.'; browsers ignore entries without it.";
681
1003
  readonly additionalProperties: {
682
1004
  readonly type: "array";
683
1005
  readonly items: {
@@ -862,7 +1184,7 @@ declare const runtimeConfigSchema: {
862
1184
  };
863
1185
  //#endregion
864
1186
  //#region connect-utils/vite-config.d.ts
865
- declare function getConnectHtmlTags(options?: {
1187
+ export declare function getConnectHtmlTags(options?: {
866
1188
  registryUrl?: string | null;
867
1189
  injectTo?: HtmlTagDescriptor["injectTo"];
868
1190
  }): [{
@@ -871,84 +1193,74 @@ declare function getConnectHtmlTags(options?: {
871
1193
  readonly "http-equiv": "Content-Security-Policy";
872
1194
  readonly content: `script-src 'self' 'unsafe-inline' 'unsafe-eval'${string}; worker-src 'self' blob:; object-src 'none'; base-uri 'self';`;
873
1195
  };
874
- readonly injectTo: "head" | "body" | "head-prepend" | "body-prepend";
1196
+ readonly injectTo: "body" | "body-prepend" | "head" | "head-prepend";
875
1197
  }, {
876
1198
  readonly tag: "meta";
877
1199
  readonly attrs: {
878
1200
  readonly property: "og:title";
879
1201
  readonly content: "Connect";
880
1202
  };
881
- readonly injectTo: "head" | "body" | "head-prepend" | "body-prepend";
1203
+ readonly injectTo: "body" | "body-prepend" | "head" | "head-prepend";
882
1204
  }, {
883
1205
  readonly tag: "meta";
884
1206
  readonly attrs: {
885
1207
  readonly property: "og:type";
886
1208
  readonly content: "website";
887
1209
  };
888
- readonly injectTo: "head" | "body" | "head-prepend" | "body-prepend";
1210
+ readonly injectTo: "body" | "body-prepend" | "head" | "head-prepend";
889
1211
  }, {
890
1212
  readonly tag: "meta";
891
1213
  readonly attrs: {
892
1214
  readonly property: "og:url";
893
1215
  readonly content: "https://apps.powerhouse.io/powerhouse/connect/";
894
1216
  };
895
- readonly injectTo: "head" | "body" | "head-prepend" | "body-prepend";
1217
+ readonly injectTo: "body" | "body-prepend" | "head" | "head-prepend";
896
1218
  }, {
897
1219
  readonly tag: "meta";
898
1220
  readonly attrs: {
899
1221
  readonly property: "og:description";
900
1222
  readonly content: "Navigate your organisation’s toughest operational challenges and steer your contributors to success with Connect. A navigation, collaboration and reporting tool for decentralised and open organisation.";
901
1223
  };
902
- readonly injectTo: "head" | "body" | "head-prepend" | "body-prepend";
1224
+ readonly injectTo: "body" | "body-prepend" | "head" | "head-prepend";
903
1225
  }, {
904
1226
  readonly tag: "meta";
905
1227
  readonly attrs: {
906
1228
  readonly property: "og:image";
907
1229
  readonly content: "https://cf-ipfs.com/ipfs/bafkreigrmclndf2jpbolaq22535q2sw5t44uad3az3dpvkzrnt4lpjt63e";
908
1230
  };
909
- readonly injectTo: "head" | "body" | "head-prepend" | "body-prepend";
1231
+ readonly injectTo: "body" | "body-prepend" | "head" | "head-prepend";
910
1232
  }, {
911
1233
  readonly tag: "meta";
912
1234
  readonly attrs: {
913
1235
  readonly name: "twitter:card";
914
1236
  readonly content: "summary_large_image";
915
1237
  };
916
- readonly injectTo: "head" | "body" | "head-prepend" | "body-prepend";
1238
+ readonly injectTo: "body" | "body-prepend" | "head" | "head-prepend";
917
1239
  }, {
918
1240
  readonly tag: "meta";
919
1241
  readonly attrs: {
920
1242
  readonly name: "twitter:image";
921
1243
  readonly content: "https://cf-ipfs.com/ipfs/bafkreigrmclndf2jpbolaq22535q2sw5t44uad3az3dpvkzrnt4lpjt63e";
922
1244
  };
923
- readonly injectTo: "head" | "body" | "head-prepend" | "body-prepend";
1245
+ readonly injectTo: "body" | "body-prepend" | "head" | "head-prepend";
924
1246
  }, {
925
1247
  readonly tag: "meta";
926
1248
  readonly attrs: {
927
1249
  readonly name: "twitter:title";
928
1250
  readonly content: "Connect";
929
1251
  };
930
- readonly injectTo: "head" | "body" | "head-prepend" | "body-prepend";
1252
+ readonly injectTo: "body" | "body-prepend" | "head" | "head-prepend";
931
1253
  }, {
932
1254
  readonly tag: "meta";
933
1255
  readonly attrs: {
934
1256
  readonly name: "twitter:description";
935
1257
  readonly content: "Navigate your organisation’s toughest operational challenges and steer your contributors to success with Connect. A navigation, collaboration and reporting tool for decentralised and open organisation.";
936
1258
  };
937
- readonly injectTo: "head" | "body" | "head-prepend" | "body-prepend";
1259
+ readonly injectTo: "body" | "body-prepend" | "head" | "head-prepend";
938
1260
  }];
939
- declare function getConnectBaseViteConfig(options: IConnectOptions): InlineConfig;
1261
+ export declare function getConnectBaseViteConfig(options: IConnectOptions): InlineConfig;
940
1262
  //#endregion
941
1263
  //#region connect-utils/vite-plugins/dynamic-base.d.ts
942
- /**
943
- * Placeholder base used when Connect is built in dynamic-base mode. The Vite
944
- * `base` option is set to this token; this plugin rewrites it in the emitted
945
- * output so the effective base is resolved at serve time from a global instead
946
- * of being baked at build time.
947
- *
948
- * Trailing slash matches `normalizeBasePath` output, so the token sits in the
949
- * same syntactic position as a concrete base would.
950
- */
951
- declare const DYNAMIC_BASE_PLACEHOLDER = "/__PH_DYNAMIC_BASE__/";
952
1264
  /**
953
1265
  * Rewrites the placeholder base in emitted JS chunks to a runtime expression so
954
1266
  * one built `dist/connect` serves under any subpath. Rolldown-native: per-match
@@ -977,17 +1289,19 @@ declare const DYNAMIC_BASE_PLACEHOLDER = "/__PH_DYNAMIC_BASE__/";
977
1289
  * they need no rewrite once the stylesheet itself is loaded from the right
978
1290
  * prefix (which the HTML substitution handles).
979
1291
  */
980
- declare function connectDynamicBasePlugin(options?: {
1292
+ export declare function connectDynamicBasePlugin(options?: {
981
1293
  forWorker?: boolean;
982
1294
  workerStripPrefix?: string;
983
1295
  }): Plugin;
984
- declare function escapeForRegExp(s: string): string;
1296
+ export declare function escapeForRegExp(s: string): string;
985
1297
  //#endregion
986
1298
  //#region connect-utils/vite-plugins/ph-config.d.ts
987
- type PhConfigPluginOptions = {
1299
+ export type PhConfigPluginOptions = {
988
1300
  packages: PowerhousePackage[];
989
1301
  projectRoot?: string;
990
1302
  connect?: PHConnectRuntimeConfig;
1303
+ /** The source's top-level `workflows` block; `connect.app.workflowsEnabled` falls back to it. */
1304
+ workflows?: PowerhouseConfig$1["workflows"];
991
1305
  /**
992
1306
  * Project-wide package registry URL — the effective value (CLI override
993
1307
  * `??` source) the caller has already resolved. Copied verbatim into the
@@ -1002,7 +1316,7 @@ type PhConfigPluginOptions = {
1002
1316
  */
1003
1317
  cliConnectOverride?: PHConnectRuntimeConfig;
1004
1318
  };
1005
- declare function phConfigPlugin(options: PhConfigPluginOptions): Plugin;
1319
+ export declare function phConfigPlugin(options: PhConfigPluginOptions): Plugin;
1006
1320
  //#endregion
1007
1321
  //#region connect-utils/vite-plugins/theme-boot.d.ts
1008
1322
  /**
@@ -1010,13 +1324,21 @@ declare function phConfigPlugin(options: PhConfigPluginOptions): Plugin;
1010
1324
  * ph-clint connect proxy) and this plugin both check it, so the script is
1011
1325
  * applied exactly once no matter which layer runs first.
1012
1326
  */
1013
- declare const THEME_BOOT_MARKER = "data-ph-theme-boot";
1327
+ export declare const THEME_BOOT_MARKER = "data-ph-theme-boot";
1014
1328
  /**
1015
1329
  * Injects the theme boot script at the top of `<head>` of every emitted
1016
1330
  * index.html, so built Connect apps render the stored theme from first paint
1017
1331
  * without depending on a serve-time injector.
1018
1332
  */
1019
- declare function connectThemeBootPlugin(): Plugin;
1333
+ export declare function connectThemeBootPlugin(): Plugin;
1334
+ //#endregion
1335
+ //#region connect-utils/vite-plugins/vendor-import-map.d.ts
1336
+ export type VendorImportMapOptions = {
1337
+ /** bare specifier -> URL (already base-prefixed by the caller). */
1338
+ imports: Record<string, string>;
1339
+ };
1340
+ export declare function vendorImportMapPlugin(options: VendorImportMapOptions): Plugin;
1020
1341
  //#endregion
1021
- export { BUILD_HASH_FILE, BuildHashInput, ConnectBuildOptions, ConnectCommonOptions, ConnectPreviewOptions, ConnectStudioOptions, DEFAULT_CONNECT_OUTDIR, DEFAULT_VENDOR_INCLUDE, DYNAMIC_BASE_PLACEHOLDER, EXTERNAL_PACKAGES_IMPORT, IConnectOptions, IMPORT_SCRIPT_FILE, LOCAL_PACKAGE_ID, PH_DIR_NAME, PhConfigPluginOptions, PrebuiltVendor, RUNTIME_CONFIG_SCHEMA_ID, RUNTIME_CONFIG_SCHEMA_URL, THEME_BOOT_MARKER, VENDOR_EXTERNAL, VENDOR_URL_PREFIX, VendorPrebuildOptions, ViteDevOptions, appendToHtmlHead, backupIndexHtml, buildHashFromBuildOptions, computeBuildHash, connectBuildHashPlugin, connectDynamicBasePlugin, connectThemeBootPlugin, copyConnect, ensureNodeVersion, escapeForRegExp, getConnectBaseViteConfig, getConnectHtmlTags, makeImportScriptFromPackages, phConfigPlugin, prebuildConnectVendor, prependToHtmlHead, readJsonFile, removeBase64EnvValues, resolveConnectBundle, resolveConnectPackageJson, resolveConnectPublicDir, resolvePackage, resolveViteConfigPath, runShellScriptPlugin, runTsc, runtimeConfigSchema, stripVersionFromPackage };
1342
+ export { DYNAMIC_BASE_PLACEHOLDER };
1343
+ export {};
1022
1344
  //# sourceMappingURL=index.d.mts.map