@powerhousedao/builder-tools 6.2.0-dev.3 → 6.2.0-dev.31

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
@@ -8,6 +8,47 @@ declare const IMPORT_SCRIPT_FILE = "external-packages.js";
8
8
  declare const LOCAL_PACKAGE_ID = "ph:local-package";
9
9
  declare const PH_DIR_NAME = ".ph";
10
10
  //#endregion
11
+ //#region connect-utils/externalize-vendor.d.ts
12
+ interface VendorPrebuildOptions {
13
+ /** Project root (the reactor-project dir). */
14
+ dirname: string;
15
+ /** Bare specifiers to bundle into the vendor (defaults to the heavy libs). */
16
+ include?: string[];
17
+ /** Specifiers left external to the build (defaults to the React family). */
18
+ external?: string[];
19
+ /** Directory to hold the static vendor bundle + import map. */
20
+ vendorDir?: string;
21
+ /** Filled with the failure cause when the prebuild returns null. */
22
+ errorRef?: {
23
+ message?: string;
24
+ };
25
+ }
26
+ /**
27
+ * The stable Connect libraries worth prebuilding. The React family is NOT here —
28
+ * it's externalized from the build (see `VENDOR_EXTERNAL`) so the vendor shares
29
+ * the dev server's single React instance via the import map.
30
+ */
31
+ declare const DEFAULT_VENDOR_INCLUDE: string[];
32
+ /**
33
+ * React-family specifiers kept external to the vendor build. The vendor's chunks
34
+ * emit bare imports for these; `devReactImportmapPlugin`'s import map resolves
35
+ * them to Vite's pre-bundled React, so there is exactly one React instance.
36
+ */
37
+ declare const VENDOR_EXTERNAL: string[];
38
+ interface PrebuiltVendor {
39
+ vendorDir: string;
40
+ /** import map: bare specifier -> "/__vendor__/<entry>.js". */
41
+ imports: Record<string, string>;
42
+ }
43
+ /** URL prefix the vendor bundle is served under by the dev middleware. */
44
+ declare const VENDOR_URL_PREFIX = "/__vendor__/";
45
+ /**
46
+ * Build the prebuilt vendor (once, in a throwaway subprocess) and return its dir
47
+ * + import map. Idempotent: reuses a cached vendor built for the same dep set.
48
+ * Returns null on any failure (caller falls back to a normal dev server).
49
+ */
50
+ declare function prebuildConnectVendor(options: VendorPrebuildOptions): Promise<PrebuiltVendor | null>;
51
+ //#endregion
11
52
  //#region connect-utils/types.d.ts
12
53
  type IConnectOptions = {
13
54
  mode: string;
@@ -21,8 +62,10 @@ type IConnectOptions = {
21
62
  * from `ph connect build`'s `--json` + individual `--flag` parsing.
22
63
  *
23
64
  * Order: DEFAULT_CONNECT_CONFIG < source.connect < cliConnectOverride.
24
- * Env vars are NOT part of this merge; they only seed the dist file at
25
- * container start (set-if-absent) via the Docker entrypoint.
65
+ * Env vars are NOT part of this merge; PH_CONNECT_CONFIG_JSON is applied
66
+ * to the dist file at container start by the Docker entrypoint
67
+ * (operator-wins: concrete values override the baked file, null/omitted
68
+ * keep it; connect.app.basePath excluded).
26
69
  */
27
70
  cliConnectOverride?: PHConnectRuntimeConfig;
28
71
  /**
@@ -31,6 +74,7 @@ type IConnectOptions = {
31
74
  * value in the emitted runtime config.
32
75
  */
33
76
  cliPackageRegistryUrl?: string;
77
+ dynamicBase?: boolean;
34
78
  };
35
79
  type ConnectCommonOptions = {
36
80
  base?: string;
@@ -374,7 +418,7 @@ declare function getConnectHtmlTags(options?: {
374
418
  readonly tag: "meta";
375
419
  readonly attrs: {
376
420
  readonly "http-equiv": "Content-Security-Policy";
377
- readonly content: `script-src 'self' 'unsafe-inline' 'unsafe-eval' https://esm.sh${string}; worker-src 'self' blob:; object-src 'none'; base-uri 'self';`;
421
+ readonly content: `script-src 'self' 'unsafe-inline' 'unsafe-eval'${string}; worker-src 'self' blob:; object-src 'none'; base-uri 'self';`;
378
422
  };
379
423
  readonly injectTo: "head" | "body" | "head-prepend" | "body-prepend";
380
424
  }, {
@@ -443,6 +487,50 @@ declare function getConnectHtmlTags(options?: {
443
487
  }];
444
488
  declare function getConnectBaseViteConfig(options: IConnectOptions): InlineConfig;
445
489
  //#endregion
490
+ //#region connect-utils/vite-plugins/dynamic-base.d.ts
491
+ /**
492
+ * Placeholder base used when Connect is built in dynamic-base mode. The Vite
493
+ * `base` option is set to this token; this plugin rewrites it in the emitted
494
+ * output so the effective base is resolved at serve time from a global instead
495
+ * of being baked at build time.
496
+ *
497
+ * Trailing slash matches `normalizeBasePath` output, so the token sits in the
498
+ * same syntactic position as a concrete base would.
499
+ */
500
+ declare const DYNAMIC_BASE_PLACEHOLDER = "/__PH_DYNAMIC_BASE__/";
501
+ /**
502
+ * Rewrites the placeholder base in emitted JS chunks to a runtime expression so
503
+ * one built `dist/connect` serves under any subpath. Rolldown-native: per-match
504
+ * MagicString edits in `renderChunk`, no AST splicing (the SWC byte-offset
505
+ * splicing in vite-plugin-dynamic-base corrupts Rolldown chunks). Each edited
506
+ * chunk returns a hires sourcemap that the bundler composes into the chunk's
507
+ * map chain, so the emitted `.map` files track the rewrite (and the worker
508
+ * prelude's line shift).
509
+ *
510
+ * What gets rewritten in JS, all of which emit the base as a quoted string
511
+ * literal beginning with the placeholder:
512
+ * - asset URLs (`new URL("/__PH_DYNAMIC_BASE__/assets/x.png", ...)`)
513
+ * - dynamic-import / lazy-chunk preload URLs
514
+ * - the inlined `import.meta.env.BASE_URL` (drives Connect's router basename
515
+ * and BASE_URL-relative fetches such as `${BASE_URL}ph-packages.json`)
516
+ *
517
+ * A literal `"/__PH_DYNAMIC_BASE__/foo"` becomes `((globalThis.__PH_DYNAMIC_BASE__||"/")+"foo")`;
518
+ * a bare `"/__PH_DYNAMIC_BASE__/"` (the BASE_URL value) becomes `(globalThis.__PH_DYNAMIC_BASE__||"/")`.
519
+ *
520
+ * HTML is left untouched: the entry `<script>`/`<link>` tags keep the literal
521
+ * placeholder so the proxy substitutes it with the concrete base at serve time
522
+ * (the same proxy also sets the runtime global for the JS rewrite). See the
523
+ * plugin's module doc / report for the exact serve-time contract.
524
+ *
525
+ * CSS `url(...)` references resolve relative to the stylesheet's own URL, so
526
+ * they need no rewrite once the stylesheet itself is loaded from the right
527
+ * prefix (which the HTML substitution handles).
528
+ */
529
+ declare function connectDynamicBasePlugin(options?: {
530
+ forWorker?: boolean;
531
+ workerStripPrefix?: string;
532
+ }): Plugin;
533
+ //#endregion
446
534
  //#region connect-utils/vite-plugins/ph-config.d.ts
447
535
  type PhConfigPluginOptions = {
448
536
  packages: PowerhousePackage[];
@@ -464,5 +552,5 @@ type PhConfigPluginOptions = {
464
552
  };
465
553
  declare function phConfigPlugin(options: PhConfigPluginOptions): Plugin;
466
554
  //#endregion
467
- export { ConnectBuildOptions, ConnectCommonOptions, ConnectPreviewOptions, ConnectStudioOptions, DEFAULT_CONNECT_OUTDIR, EXTERNAL_PACKAGES_IMPORT, IConnectOptions, IMPORT_SCRIPT_FILE, LOCAL_PACKAGE_ID, PH_DIR_NAME, PhConfigPluginOptions, RUNTIME_CONFIG_SCHEMA_ID, RUNTIME_CONFIG_SCHEMA_URL, ViteDevOptions, appendToHtmlHead, backupIndexHtml, copyConnect, ensureNodeVersion, getConnectBaseViteConfig, getConnectHtmlTags, makeImportScriptFromPackages, phConfigPlugin, prependToHtmlHead, readJsonFile, removeBase64EnvValues, resolveConnectBundle, resolveConnectPackageJson, resolveConnectPublicDir, resolvePackage, resolveViteConfigPath, runShellScriptPlugin, runTsc, runtimeConfigSchema, stripVersionFromPackage };
555
+ export { 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, VENDOR_EXTERNAL, VENDOR_URL_PREFIX, VendorPrebuildOptions, ViteDevOptions, appendToHtmlHead, backupIndexHtml, connectDynamicBasePlugin, copyConnect, ensureNodeVersion, getConnectBaseViteConfig, getConnectHtmlTags, makeImportScriptFromPackages, phConfigPlugin, prebuildConnectVendor, prependToHtmlHead, readJsonFile, removeBase64EnvValues, resolveConnectBundle, resolveConnectPackageJson, resolveConnectPublicDir, resolvePackage, resolveViteConfigPath, runShellScriptPlugin, runTsc, runtimeConfigSchema, stripVersionFromPackage };
468
556
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../connect-utils/constants.ts","../connect-utils/types.ts","../connect-utils/helpers.ts","../connect-utils/runtime-config-schema.ts","../connect-utils/vite-config.ts","../connect-utils/vite-plugins/ph-config.ts"],"mappings":";;;;;cAAa,wBAAA;AAAA,cACA,kBAAA;AAAA,cACA,gBAAA;AAAA,cACA,WAAA;;;KCCD,eAAA;EACV,IAAA;EACA,OAAA;EACA,MAAA;EACA,gBAAA,GAAmB,gBAAA;EACnB,YAAA;EDTmC;AACrC;;;;;AACA;;;ECiBE,kBAAA,GAAqB,sBAAA;EDjBM;AAC7B;;;;ECsBE,qBAAA;AAAA;AAAA,KAGU,oBAAA;EAEV,IAAA;EAEA,IAAA;EAEA,UAAA;EAEA,WAAA;EAEA,cAAA;EAEA,mBAAA;EAEA,gBAAA;EAEA,sBAAA;AAAA;AAAA,KAGU,cAAA,GAAiB,IAAA,CAC3B,mBAAA;EAEI,KAAA;AAAA;AAAA,KAEM,oBAAA,GAAuB,oBAAA;EACjC,gBAAA,GAAmB,cAAA;EACnB,SAAA;EACA,gBAAA;AAAA;AAAA,KAGU,mBAAA,GAAsB,oBAAA;EAEhC,MAAA;AAAA;AAAA,KAGU,qBAAA,GAAwB,oBAAA,GAClC,IAAA,CAAK,cAAA;EAEH,MAAA;EACA,SAAA;EACA,gBAAA;AAAA;;;cCzDS,sBAAA;AAAA,iBAEG,qBAAA,CACd,OAAA,EAAS,IAAA,CAAK,oBAAA;AAAA,iBAMA,cAAA,CAAe,WAAA,UAAqB,IAAA;AAAA,iBAMpC,yBAAA,CAA0B,IAAA,YAAoB,IAAA;;;;iBAiB9C,oBAAA,CAAqB,IAAA;AAAA,iBASr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;;EKqBE,kBAAA;ELrB6B;AAC/B;;;;EK0BE,kBAAA,GAAqB,sBAAA;AAAA;AAAA,iBAsBP,cAAA,CAAe,OAAA,EAAS,qBAAA,GAAwB,MAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../connect-utils/constants.ts","../connect-utils/externalize-vendor.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"],"mappings":";;;;;cAAa,wBAAA;AAAA,cACA,kBAAA;AAAA,cACA,gBAAA;AAAA,cACA,WAAA;;;UC6CI,qBAAA;;EAEf,OAAA;;EAEA,OAAA;EDpDW;ECsDX,QAAA;;EAEA,SAAA;EDxDmC;EC0DnC,QAAA;IAAa,OAAA;EAAA;AAAA;;ADxDf;;;;cCgEa,sBAAA;AD/Db;;;;;AAAA,cC6Ea,eAAA;AAAA,UAYI,cAAA;EACf,SAAA;EA7Ce;EA+Cf,OAAA,EAAS,MAAA;AAAA;;cAIE,iBAAA;;;;;;iBAWS,qBAAA,CACpB,OAAA,EAAS,qBAAA,GACR,OAAA,CAAQ,cAAA;;;KC5GC,eAAA;EACV,IAAA;EACA,OAAA;EACA,MAAA;EACA,gBAAA,GAAmB,gBAAA;EACnB,YAAA;EFTmC;AACrC;;;;;AACA;;;;;EEmBE,kBAAA,GAAqB,sBAAA;EFlBC;;;;;EEwBtB,qBAAA;EAGA,WAAA;AAAA;AAAA,KAGU,oBAAA;EAEV,IAAA;EAEA,IAAA;EAEA,UAAA;EAEA,WAAA;EAEA,cAAA;EAEA,mBAAA;EAEA,gBAAA;EAEA,sBAAA;AAAA;AAAA,KAGU,cAAA,GAAiB,IAAA,CAC3B,mBAAA;EAEI,KAAA;AAAA;AAAA,KAEM,oBAAA,GAAuB,oBAAA;EACjC,gBAAA,GAAmB,cAAA;EACnB,SAAA;EACA,gBAAA;AAAA;AAAA,KAGU,mB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