@powerhousedao/builder-tools 6.2.0-dev.5 → 6.2.0-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 +110 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +879 -78
- package/dist/index.mjs.map +1 -1
- package/package.json +28 -7
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;
|
|
25
|
-
* container start
|
|
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;
|
|
@@ -361,6 +405,24 @@ declare const runtimeConfigSchema: {
|
|
|
361
405
|
};
|
|
362
406
|
};
|
|
363
407
|
};
|
|
408
|
+
readonly instance: {
|
|
409
|
+
readonly type: "object";
|
|
410
|
+
readonly additionalProperties: false;
|
|
411
|
+
readonly required: readonly ["namespace", "reactorWorker"];
|
|
412
|
+
readonly description: "Per-instance identity. Lets one origin host multiple isolated Connect instances, each with its own storage + SharedWorker namespace.";
|
|
413
|
+
readonly properties: {
|
|
414
|
+
readonly namespace: {
|
|
415
|
+
readonly type: readonly ["string", "null"];
|
|
416
|
+
readonly description: "Explicit storage/SharedWorker namespace for this instance. `null` derives it from the base path (and, later, the configured endpoint), so root deployments stay byte-identical.";
|
|
417
|
+
readonly default: null;
|
|
418
|
+
};
|
|
419
|
+
readonly reactorWorker: {
|
|
420
|
+
readonly type: "boolean";
|
|
421
|
+
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.";
|
|
422
|
+
readonly default: false;
|
|
423
|
+
};
|
|
424
|
+
};
|
|
425
|
+
};
|
|
364
426
|
};
|
|
365
427
|
};
|
|
366
428
|
};
|
|
@@ -374,7 +436,7 @@ declare function getConnectHtmlTags(options?: {
|
|
|
374
436
|
readonly tag: "meta";
|
|
375
437
|
readonly attrs: {
|
|
376
438
|
readonly "http-equiv": "Content-Security-Policy";
|
|
377
|
-
readonly content: `script-src 'self' 'unsafe-inline' 'unsafe-eval'
|
|
439
|
+
readonly content: `script-src 'self' 'unsafe-inline' 'unsafe-eval'${string}; worker-src 'self' blob:; object-src 'none'; base-uri 'self';`;
|
|
378
440
|
};
|
|
379
441
|
readonly injectTo: "head" | "body" | "head-prepend" | "body-prepend";
|
|
380
442
|
}, {
|
|
@@ -443,6 +505,50 @@ declare function getConnectHtmlTags(options?: {
|
|
|
443
505
|
}];
|
|
444
506
|
declare function getConnectBaseViteConfig(options: IConnectOptions): InlineConfig;
|
|
445
507
|
//#endregion
|
|
508
|
+
//#region connect-utils/vite-plugins/dynamic-base.d.ts
|
|
509
|
+
/**
|
|
510
|
+
* Placeholder base used when Connect is built in dynamic-base mode. The Vite
|
|
511
|
+
* `base` option is set to this token; this plugin rewrites it in the emitted
|
|
512
|
+
* output so the effective base is resolved at serve time from a global instead
|
|
513
|
+
* of being baked at build time.
|
|
514
|
+
*
|
|
515
|
+
* Trailing slash matches `normalizeBasePath` output, so the token sits in the
|
|
516
|
+
* same syntactic position as a concrete base would.
|
|
517
|
+
*/
|
|
518
|
+
declare const DYNAMIC_BASE_PLACEHOLDER = "/__PH_DYNAMIC_BASE__/";
|
|
519
|
+
/**
|
|
520
|
+
* Rewrites the placeholder base in emitted JS chunks to a runtime expression so
|
|
521
|
+
* one built `dist/connect` serves under any subpath. Rolldown-native: per-match
|
|
522
|
+
* MagicString edits in `renderChunk`, no AST splicing (the SWC byte-offset
|
|
523
|
+
* splicing in vite-plugin-dynamic-base corrupts Rolldown chunks). Each edited
|
|
524
|
+
* chunk returns a hires sourcemap that the bundler composes into the chunk's
|
|
525
|
+
* map chain, so the emitted `.map` files track the rewrite (and the worker
|
|
526
|
+
* prelude's line shift).
|
|
527
|
+
*
|
|
528
|
+
* What gets rewritten in JS, all of which emit the base as a quoted string
|
|
529
|
+
* literal beginning with the placeholder:
|
|
530
|
+
* - asset URLs (`new URL("/__PH_DYNAMIC_BASE__/assets/x.png", ...)`)
|
|
531
|
+
* - dynamic-import / lazy-chunk preload URLs
|
|
532
|
+
* - the inlined `import.meta.env.BASE_URL` (drives Connect's router basename
|
|
533
|
+
* and BASE_URL-relative fetches such as `${BASE_URL}ph-packages.json`)
|
|
534
|
+
*
|
|
535
|
+
* A literal `"/__PH_DYNAMIC_BASE__/foo"` becomes `((globalThis.__PH_DYNAMIC_BASE__||"/")+"foo")`;
|
|
536
|
+
* a bare `"/__PH_DYNAMIC_BASE__/"` (the BASE_URL value) becomes `(globalThis.__PH_DYNAMIC_BASE__||"/")`.
|
|
537
|
+
*
|
|
538
|
+
* HTML is left untouched: the entry `<script>`/`<link>` tags keep the literal
|
|
539
|
+
* placeholder so the proxy substitutes it with the concrete base at serve time
|
|
540
|
+
* (the same proxy also sets the runtime global for the JS rewrite). See the
|
|
541
|
+
* plugin's module doc / report for the exact serve-time contract.
|
|
542
|
+
*
|
|
543
|
+
* CSS `url(...)` references resolve relative to the stylesheet's own URL, so
|
|
544
|
+
* they need no rewrite once the stylesheet itself is loaded from the right
|
|
545
|
+
* prefix (which the HTML substitution handles).
|
|
546
|
+
*/
|
|
547
|
+
declare function connectDynamicBasePlugin(options?: {
|
|
548
|
+
forWorker?: boolean;
|
|
549
|
+
workerStripPrefix?: string;
|
|
550
|
+
}): Plugin;
|
|
551
|
+
//#endregion
|
|
446
552
|
//#region connect-utils/vite-plugins/ph-config.d.ts
|
|
447
553
|
type PhConfigPluginOptions = {
|
|
448
554
|
packages: PowerhousePackage[];
|
|
@@ -464,5 +570,5 @@ type PhConfigPluginOptions = {
|
|
|
464
570
|
};
|
|
465
571
|
declare function phConfigPlugin(options: PhConfigPluginOptions): Plugin;
|
|
466
572
|
//#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 };
|
|
573
|
+
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
574
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -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;;;
|
|
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,OAA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