@powerhousedao/builder-tools 6.1.0 → 6.2.0-dev.1
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 +300 -8
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +114 -39
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CommonServerOptions, HtmlTagDescriptor, InlineConfig, Plugin } from "vite";
|
|
2
|
-
import { PowerhouseConfig } from "@powerhousedao/config";
|
|
2
|
+
import { PowerhouseConfig, PowerhousePackage } from "@powerhousedao/config";
|
|
3
|
+
import { PHConnectRuntimeConfig } from "@powerhousedao/shared/clis";
|
|
3
4
|
|
|
4
5
|
//#region connect-utils/constants.d.ts
|
|
5
6
|
declare const EXTERNAL_PACKAGES_IMPORT = "PH:EXTERNAL_PACKAGES";
|
|
@@ -14,6 +15,22 @@ type IConnectOptions = {
|
|
|
14
15
|
envDir?: string;
|
|
15
16
|
powerhouseConfig?: PowerhouseConfig;
|
|
16
17
|
watchTimeout?: number;
|
|
18
|
+
/**
|
|
19
|
+
* CLI-supplied connect override. Final (highest precedence) layer of the
|
|
20
|
+
* runtime-config deep-merge ladder applied by `phConfigPlugin`. Forwarded
|
|
21
|
+
* from `ph connect build`'s `--json` + individual `--flag` parsing.
|
|
22
|
+
*
|
|
23
|
+
* 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.
|
|
26
|
+
*/
|
|
27
|
+
cliConnectOverride?: PHConnectRuntimeConfig;
|
|
28
|
+
/**
|
|
29
|
+
* CLI override for the top-level `packageRegistryUrl`. Set when the user
|
|
30
|
+
* passes `--packages-registry` to `ph connect build`; wins over the source
|
|
31
|
+
* value in the emitted runtime config.
|
|
32
|
+
*/
|
|
33
|
+
cliPackageRegistryUrl?: string;
|
|
17
34
|
};
|
|
18
35
|
type ConnectCommonOptions = {
|
|
19
36
|
base?: string;
|
|
@@ -44,7 +61,6 @@ type ConnectPreviewOptions = ConnectCommonOptions & Omit<ViteDevOptions, "cors">
|
|
|
44
61
|
//#endregion
|
|
45
62
|
//#region connect-utils/helpers.d.ts
|
|
46
63
|
declare const DEFAULT_CONNECT_OUTDIR: ".ph/connect-build/dist/";
|
|
47
|
-
declare function commonConnectOptionsToEnv(options: ConnectCommonOptions): void;
|
|
48
64
|
declare function resolveViteConfigPath(options: Pick<ConnectCommonOptions, "projectRoot" | "viteConfigFile">): string;
|
|
49
65
|
declare function resolvePackage(packageName: string, root?: string): string;
|
|
50
66
|
declare function resolveConnectPackageJson(root?: string): JSON | null;
|
|
@@ -87,6 +103,269 @@ declare function prependToHtmlHead(pathToHtml: string, contents: string): Promis
|
|
|
87
103
|
declare function runTsc(outDir: string): void;
|
|
88
104
|
declare function stripVersionFromPackage(packageName: string): string;
|
|
89
105
|
//#endregion
|
|
106
|
+
//#region connect-utils/runtime-config-schema.d.ts
|
|
107
|
+
declare const RUNTIME_CONFIG_SCHEMA_ID = "https://powerhouse.inc/schemas/powerhouse.config.json";
|
|
108
|
+
declare const RUNTIME_CONFIG_SCHEMA_URL = "https://raw.githubusercontent.com/powerhouse-inc/powerhouse/main/packages/builder-tools/connect-utils/runtime-config.schema.json";
|
|
109
|
+
declare const runtimeConfigSchema: {
|
|
110
|
+
readonly $schema: "http://json-schema.org/draft-07/schema#";
|
|
111
|
+
readonly $id: "https://powerhouse.inc/schemas/powerhouse.config.json";
|
|
112
|
+
readonly title: "Powerhouse Connect runtime configuration";
|
|
113
|
+
readonly description: "Runtime configuration loaded by Connect at boot from /powerhouse.config.json.";
|
|
114
|
+
readonly type: "object";
|
|
115
|
+
readonly additionalProperties: false;
|
|
116
|
+
readonly required: readonly ["schemaVersion", "packages", "localPackage"];
|
|
117
|
+
readonly properties: {
|
|
118
|
+
readonly $schema: {
|
|
119
|
+
readonly type: "string";
|
|
120
|
+
readonly description: "Optional JSON Schema reference for editor autocomplete. Set to the GitHub-hosted schema URL.";
|
|
121
|
+
};
|
|
122
|
+
readonly schemaVersion: {
|
|
123
|
+
readonly const: 2;
|
|
124
|
+
readonly description: "Schema version. Must match the SPA bundle that ships with this dist. The SPA throws on mismatch to prevent SPA/config skew.";
|
|
125
|
+
};
|
|
126
|
+
readonly packages: {
|
|
127
|
+
readonly type: "array";
|
|
128
|
+
readonly description: "Powerhouse packages this Connect instance loads at runtime.";
|
|
129
|
+
readonly items: {
|
|
130
|
+
readonly type: "object";
|
|
131
|
+
readonly additionalProperties: false;
|
|
132
|
+
readonly required: readonly ["packageName"];
|
|
133
|
+
readonly properties: {
|
|
134
|
+
readonly packageName: {
|
|
135
|
+
readonly type: "string";
|
|
136
|
+
readonly description: "Fully qualified npm package name (e.g. @scope/name).";
|
|
137
|
+
};
|
|
138
|
+
readonly version: {
|
|
139
|
+
readonly type: "string";
|
|
140
|
+
readonly description: "Exact version (registry providers) or omit to take latest.";
|
|
141
|
+
};
|
|
142
|
+
readonly provider: {
|
|
143
|
+
readonly type: "string";
|
|
144
|
+
readonly enum: readonly ["npm", "github", "local", "registry"];
|
|
145
|
+
readonly description: "Where Connect should resolve the package from at runtime.";
|
|
146
|
+
};
|
|
147
|
+
readonly url: {
|
|
148
|
+
readonly type: "string";
|
|
149
|
+
readonly description: "Override URL for non-registry providers (e.g. github tarball).";
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
readonly packageRegistryUrl: {
|
|
155
|
+
readonly type: "string";
|
|
156
|
+
readonly description: "Project-wide package registry endpoint. Copied verbatim from the source `powerhouse.config.json` top-level field — the SPA's Package Manager UI reads this directly.";
|
|
157
|
+
};
|
|
158
|
+
readonly localPackage: {
|
|
159
|
+
readonly description: "Identity of the consumer project itself, captured at build time. null for Docker images and other generic deploys with no host project.";
|
|
160
|
+
readonly oneOf: readonly [{
|
|
161
|
+
readonly type: "null";
|
|
162
|
+
}, {
|
|
163
|
+
readonly type: "object";
|
|
164
|
+
readonly additionalProperties: false;
|
|
165
|
+
readonly required: readonly ["name", "version"];
|
|
166
|
+
readonly properties: {
|
|
167
|
+
readonly name: {
|
|
168
|
+
readonly type: "string";
|
|
169
|
+
};
|
|
170
|
+
readonly version: {
|
|
171
|
+
readonly type: "string";
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
}];
|
|
175
|
+
};
|
|
176
|
+
readonly connect: {
|
|
177
|
+
readonly type: "object";
|
|
178
|
+
readonly additionalProperties: false;
|
|
179
|
+
readonly description: "Connect-specific UI customisations. All fields optional; omit the section entirely for default behaviour.";
|
|
180
|
+
readonly properties: {
|
|
181
|
+
readonly branding: {
|
|
182
|
+
readonly type: "object";
|
|
183
|
+
readonly additionalProperties: false;
|
|
184
|
+
readonly description: "App identity and visual branding.";
|
|
185
|
+
readonly properties: {
|
|
186
|
+
readonly appName: {
|
|
187
|
+
readonly type: "string";
|
|
188
|
+
readonly description: "Browser tab title and any in-app brand text. Defaults to 'Powerhouse Connect'.";
|
|
189
|
+
};
|
|
190
|
+
readonly homeBackground: {
|
|
191
|
+
readonly type: readonly ["string", "null"];
|
|
192
|
+
readonly description: "Hero image on the empty home screen. URL or path to override; null or omitted uses the bundled default image.";
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
readonly app: {
|
|
197
|
+
readonly type: "object";
|
|
198
|
+
readonly additionalProperties: false;
|
|
199
|
+
readonly description: "Top-level Connect application behaviour.";
|
|
200
|
+
readonly properties: {
|
|
201
|
+
readonly logLevel: {
|
|
202
|
+
readonly type: "string";
|
|
203
|
+
readonly enum: readonly ["debug", "info", "warn", "error"];
|
|
204
|
+
readonly description: "Log level applied by Connect's logger at boot. Affects browser-side output only.";
|
|
205
|
+
readonly default: "info";
|
|
206
|
+
};
|
|
207
|
+
readonly basePath: {
|
|
208
|
+
readonly type: "string";
|
|
209
|
+
readonly description: "Base path Connect is mounted under (e.g. '/connect' for subpath deploys). Normalised at runtime to start and end with '/'. Defaults to the build-time BASE_URL.";
|
|
210
|
+
readonly default: "/";
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
readonly packages: {
|
|
215
|
+
readonly type: "object";
|
|
216
|
+
readonly additionalProperties: false;
|
|
217
|
+
readonly description: "Runtime behaviour for the Connect package manager (separate from top-level `packages[]`, which lists which packages to load).";
|
|
218
|
+
readonly properties: {
|
|
219
|
+
readonly externalEnabled: {
|
|
220
|
+
readonly type: "boolean";
|
|
221
|
+
readonly description: "When false, Connect refuses to load any package that wasn't bundled at build time. Affirmative replacement for the legacy PH_CONNECT_EXTERNAL_PACKAGES_DISABLED env var.";
|
|
222
|
+
readonly default: true;
|
|
223
|
+
};
|
|
224
|
+
readonly liveReload: {
|
|
225
|
+
readonly type: "boolean";
|
|
226
|
+
readonly description: "When true, Connect subscribes to the static-mode `/__packages` SSE channel so live publishes flow into the running tab without a page reload. Only works under hosting that serves this channel (e.g. ph-clint static mode).";
|
|
227
|
+
readonly default: false;
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
readonly drives: {
|
|
232
|
+
readonly type: "object";
|
|
233
|
+
readonly additionalProperties: false;
|
|
234
|
+
readonly description: "Default-drive and add-drive UI behaviour.";
|
|
235
|
+
readonly properties: {
|
|
236
|
+
readonly allowAddDrive: {
|
|
237
|
+
readonly type: "boolean";
|
|
238
|
+
readonly description: "When false, the SPA hides the 'add drive' affordance entirely (top-level). Per-section overrides live in `sections.{remote,local}.allowAdd`.";
|
|
239
|
+
readonly default: true;
|
|
240
|
+
};
|
|
241
|
+
readonly defaultDrives: {
|
|
242
|
+
readonly type: "array";
|
|
243
|
+
readonly description: "Drives the SPA auto-connects to on first load. Each must specify a URL; name and icon are optional overrides.";
|
|
244
|
+
readonly default: readonly [];
|
|
245
|
+
readonly items: {
|
|
246
|
+
readonly type: "object";
|
|
247
|
+
readonly additionalProperties: false;
|
|
248
|
+
readonly required: readonly ["url"];
|
|
249
|
+
readonly properties: {
|
|
250
|
+
readonly url: {
|
|
251
|
+
readonly type: "string";
|
|
252
|
+
};
|
|
253
|
+
readonly name: {
|
|
254
|
+
readonly type: readonly ["string", "null"];
|
|
255
|
+
};
|
|
256
|
+
readonly icon: {
|
|
257
|
+
readonly type: readonly ["string", "null"];
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
readonly preserveStrategy: {
|
|
263
|
+
readonly type: "string";
|
|
264
|
+
readonly enum: readonly ["preserve-all", "preserve-by-url-and-detach"];
|
|
265
|
+
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.";
|
|
266
|
+
};
|
|
267
|
+
readonly sections: {
|
|
268
|
+
readonly type: "object";
|
|
269
|
+
readonly additionalProperties: false;
|
|
270
|
+
readonly description: "Per-section visibility and affordance toggles. `remote` covers what was historically split into 'public' + 'cloud'; `local` is browser-local drives.";
|
|
271
|
+
readonly properties: {
|
|
272
|
+
readonly remote: {
|
|
273
|
+
readonly type: "object";
|
|
274
|
+
readonly additionalProperties: false;
|
|
275
|
+
readonly description: "Visibility and add/delete affordances for a drive section in the sidebar.";
|
|
276
|
+
readonly properties: {
|
|
277
|
+
readonly enabled: {
|
|
278
|
+
readonly type: "boolean";
|
|
279
|
+
readonly description: "When false, the section is hidden in the sidebar.";
|
|
280
|
+
readonly default: true;
|
|
281
|
+
};
|
|
282
|
+
readonly allowAdd: {
|
|
283
|
+
readonly type: "boolean";
|
|
284
|
+
readonly description: "When false, the section's 'add drive' affordance is hidden.";
|
|
285
|
+
readonly default: true;
|
|
286
|
+
};
|
|
287
|
+
readonly allowDelete: {
|
|
288
|
+
readonly type: "boolean";
|
|
289
|
+
readonly description: "When false, drives in this section cannot be deleted from the UI.";
|
|
290
|
+
readonly default: true;
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
};
|
|
294
|
+
readonly local: {
|
|
295
|
+
readonly type: "object";
|
|
296
|
+
readonly additionalProperties: false;
|
|
297
|
+
readonly description: "Visibility and add/delete affordances for a drive section in the sidebar.";
|
|
298
|
+
readonly properties: {
|
|
299
|
+
readonly enabled: {
|
|
300
|
+
readonly type: "boolean";
|
|
301
|
+
readonly description: "When false, the section is hidden in the sidebar.";
|
|
302
|
+
readonly default: true;
|
|
303
|
+
};
|
|
304
|
+
readonly allowAdd: {
|
|
305
|
+
readonly type: "boolean";
|
|
306
|
+
readonly description: "When false, the section's 'add drive' affordance is hidden.";
|
|
307
|
+
readonly default: true;
|
|
308
|
+
};
|
|
309
|
+
readonly allowDelete: {
|
|
310
|
+
readonly type: "boolean";
|
|
311
|
+
readonly description: "When false, drives in this section cannot be deleted from the UI.";
|
|
312
|
+
readonly default: true;
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
readonly renown: {
|
|
321
|
+
readonly type: "object";
|
|
322
|
+
readonly additionalProperties: false;
|
|
323
|
+
readonly description: "Renown identity / authentication coordinates.";
|
|
324
|
+
readonly properties: {
|
|
325
|
+
readonly url: {
|
|
326
|
+
readonly type: "string";
|
|
327
|
+
readonly description: "Renown auth service URL.";
|
|
328
|
+
readonly default: "https://www.renown.id";
|
|
329
|
+
};
|
|
330
|
+
readonly networkId: {
|
|
331
|
+
readonly type: "string";
|
|
332
|
+
readonly description: "CAIP-2 network namespace (e.g. 'eip155').";
|
|
333
|
+
readonly default: "eip155";
|
|
334
|
+
};
|
|
335
|
+
readonly chainId: {
|
|
336
|
+
readonly type: "number";
|
|
337
|
+
readonly description: "CAIP-2 chain reference within the network namespace.";
|
|
338
|
+
readonly default: 1;
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
readonly sentry: {
|
|
343
|
+
readonly type: "object";
|
|
344
|
+
readonly additionalProperties: false;
|
|
345
|
+
readonly description: "Sentry error-tracking coordinates. Set `dsn` to enable Sentry; leave `dsn` null to disable. The Sentry release tag stays build-time (stamped via Vite's `define` from WORKSPACE_VERSION) so it always matches the sourcemaps uploaded by CI.";
|
|
346
|
+
readonly properties: {
|
|
347
|
+
readonly dsn: {
|
|
348
|
+
readonly type: readonly ["string", "null"];
|
|
349
|
+
readonly description: "Sentry DSN URL. `null` disables Sentry entirely; the SPA never loads the Sentry SDK chunk.";
|
|
350
|
+
readonly default: null;
|
|
351
|
+
};
|
|
352
|
+
readonly env: {
|
|
353
|
+
readonly type: "string";
|
|
354
|
+
readonly description: "Sentry environment label, surfaced as the `environment` tag on every event.";
|
|
355
|
+
readonly default: "dev";
|
|
356
|
+
};
|
|
357
|
+
readonly tracing: {
|
|
358
|
+
readonly type: "boolean";
|
|
359
|
+
readonly description: "Enable Sentry performance tracing.";
|
|
360
|
+
readonly default: false;
|
|
361
|
+
};
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
};
|
|
367
|
+
};
|
|
368
|
+
//#endregion
|
|
90
369
|
//#region connect-utils/vite-config.d.ts
|
|
91
370
|
declare function getConnectHtmlTags(options?: {
|
|
92
371
|
registryUrl?: string | null;
|
|
@@ -164,13 +443,26 @@ declare function getConnectHtmlTags(options?: {
|
|
|
164
443
|
}];
|
|
165
444
|
declare function getConnectBaseViteConfig(options: IConnectOptions): InlineConfig;
|
|
166
445
|
//#endregion
|
|
167
|
-
//#region connect-utils/vite-plugins/ph-
|
|
168
|
-
type
|
|
169
|
-
packages:
|
|
446
|
+
//#region connect-utils/vite-plugins/ph-config.d.ts
|
|
447
|
+
type PhConfigPluginOptions = {
|
|
448
|
+
packages: PowerhousePackage[];
|
|
170
449
|
projectRoot?: string;
|
|
171
|
-
|
|
450
|
+
connect?: PHConnectRuntimeConfig;
|
|
451
|
+
/**
|
|
452
|
+
* Project-wide package registry URL — the effective value (CLI override
|
|
453
|
+
* `??` source) the caller has already resolved. Copied verbatim into the
|
|
454
|
+
* emitted runtime config (no namespace change); the SPA reads
|
|
455
|
+
* `runtimeConfig.packageRegistryUrl` directly.
|
|
456
|
+
*/
|
|
457
|
+
packageRegistryUrl?: string;
|
|
458
|
+
/**
|
|
459
|
+
* CLI-supplied connect override (final merge layer, beats source).
|
|
460
|
+
* Forwarded from `ph connect build`'s `--json` + individual `--flag` parsing.
|
|
461
|
+
* See clis/ph-cli/src/utils/cli-connect-override.ts.
|
|
462
|
+
*/
|
|
463
|
+
cliConnectOverride?: PHConnectRuntimeConfig;
|
|
172
464
|
};
|
|
173
|
-
declare function
|
|
465
|
+
declare function phConfigPlugin(options: PhConfigPluginOptions): Plugin;
|
|
174
466
|
//#endregion
|
|
175
|
-
export { ConnectBuildOptions, ConnectCommonOptions, ConnectPreviewOptions, ConnectStudioOptions, DEFAULT_CONNECT_OUTDIR, EXTERNAL_PACKAGES_IMPORT, IConnectOptions, IMPORT_SCRIPT_FILE, LOCAL_PACKAGE_ID, PH_DIR_NAME,
|
|
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 };
|
|
176
468
|
//# 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/vite-config.ts","../connect-utils/vite-plugins/ph-
|
|
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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sBAAA;;;;ALdZ;;;EKqBE,kBAAA;ELrB6B;AAC/B;;;;EK0BE,kBAAA,GAAqB,sBAAA;AAAA;AAAA,iBAsBP,cAAA,CAAe,OAAA,EAAS,qBAAA,GAAwB,MAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import fs, { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
|
4
4
|
import { readFile, writeFile } from "node:fs/promises";
|
|
5
5
|
import path, { join, resolve } from "node:path";
|
|
6
6
|
import { cwd } from "node:process";
|
|
7
|
-
import { loadConnectEnv, normalizeBasePath, setConnectEnv } from "@powerhousedao/shared/connect";
|
|
7
|
+
import { DEFAULT_CONNECT_CONFIG, buildRuntimeConfig, deepMerge, loadConnectEnv, normalizeBasePath, phConnectRuntimeConfigSchema, powerhousePackageSchema, setConnectEnv } from "@powerhousedao/shared/connect";
|
|
8
8
|
import { getConfig } from "@powerhousedao/config/node";
|
|
9
9
|
import tailwind from "@tailwindcss/vite";
|
|
10
10
|
import react from "@vitejs/plugin-react";
|
|
@@ -18,14 +18,6 @@ const PH_DIR_NAME = ".ph";
|
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region connect-utils/helpers.ts
|
|
20
20
|
const DEFAULT_CONNECT_OUTDIR = ".ph/connect-build/dist/";
|
|
21
|
-
function commonConnectOptionsToEnv(options) {
|
|
22
|
-
const { base, configFile, defaultDrivesUrl, drivesPreserveStrategy, disableLocalPackage } = options;
|
|
23
|
-
if (base) setConnectEnv({ PH_CONNECT_BASE_PATH: base });
|
|
24
|
-
if (configFile) setConnectEnv({ PH_CONFIG_PATH: configFile });
|
|
25
|
-
if (defaultDrivesUrl) setConnectEnv({ PH_CONNECT_DEFAULT_DRIVES_URL: defaultDrivesUrl.join(",") });
|
|
26
|
-
if (drivesPreserveStrategy) setConnectEnv({ PH_CONNECT_DRIVES_PRESERVE_STRATEGY: drivesPreserveStrategy });
|
|
27
|
-
if (disableLocalPackage) setConnectEnv({ PH_DISABLE_LOCAL_PACKAGE: true });
|
|
28
|
-
}
|
|
29
21
|
function resolveViteConfigPath(options) {
|
|
30
22
|
const { projectRoot = cwd(), viteConfigFile } = options;
|
|
31
23
|
return viteConfigFile || join(projectRoot, "vite.config.ts");
|
|
@@ -206,6 +198,55 @@ function stripVersionFromPackage(packageName) {
|
|
|
206
198
|
return trimmed;
|
|
207
199
|
}
|
|
208
200
|
//#endregion
|
|
201
|
+
//#region connect-utils/runtime-config-schema.ts
|
|
202
|
+
const RUNTIME_CONFIG_SCHEMA_ID = "https://powerhouse.inc/schemas/powerhouse.config.json";
|
|
203
|
+
const RUNTIME_CONFIG_SCHEMA_URL = "https://raw.githubusercontent.com/powerhouse-inc/powerhouse/main/packages/builder-tools/connect-utils/runtime-config.schema.json";
|
|
204
|
+
const runtimeConfigSchema = {
|
|
205
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
206
|
+
$id: RUNTIME_CONFIG_SCHEMA_ID,
|
|
207
|
+
title: "Powerhouse Connect runtime configuration",
|
|
208
|
+
description: "Runtime configuration loaded by Connect at boot from /powerhouse.config.json.",
|
|
209
|
+
type: "object",
|
|
210
|
+
additionalProperties: false,
|
|
211
|
+
required: [
|
|
212
|
+
"schemaVersion",
|
|
213
|
+
"packages",
|
|
214
|
+
"localPackage"
|
|
215
|
+
],
|
|
216
|
+
properties: {
|
|
217
|
+
$schema: {
|
|
218
|
+
type: "string",
|
|
219
|
+
description: "Optional JSON Schema reference for editor autocomplete. Set to the GitHub-hosted schema URL."
|
|
220
|
+
},
|
|
221
|
+
schemaVersion: {
|
|
222
|
+
const: 2,
|
|
223
|
+
description: "Schema version. Must match the SPA bundle that ships with this dist. The SPA throws on mismatch to prevent SPA/config skew."
|
|
224
|
+
},
|
|
225
|
+
packages: {
|
|
226
|
+
type: "array",
|
|
227
|
+
description: "Powerhouse packages this Connect instance loads at runtime.",
|
|
228
|
+
items: powerhousePackageSchema
|
|
229
|
+
},
|
|
230
|
+
packageRegistryUrl: {
|
|
231
|
+
type: "string",
|
|
232
|
+
description: "Project-wide package registry endpoint. Copied verbatim from the source `powerhouse.config.json` top-level field — the SPA's Package Manager UI reads this directly."
|
|
233
|
+
},
|
|
234
|
+
localPackage: {
|
|
235
|
+
description: "Identity of the consumer project itself, captured at build time. null for Docker images and other generic deploys with no host project.",
|
|
236
|
+
oneOf: [{ type: "null" }, {
|
|
237
|
+
type: "object",
|
|
238
|
+
additionalProperties: false,
|
|
239
|
+
required: ["name", "version"],
|
|
240
|
+
properties: {
|
|
241
|
+
name: { type: "string" },
|
|
242
|
+
version: { type: "string" }
|
|
243
|
+
}
|
|
244
|
+
}]
|
|
245
|
+
},
|
|
246
|
+
connect: phConnectRuntimeConfigSchema
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
//#endregion
|
|
209
250
|
//#region connect-utils/vite-plugins/dev-external-react.ts
|
|
210
251
|
const REACT_DEPS = [
|
|
211
252
|
"react",
|
|
@@ -214,8 +255,11 @@ const REACT_DEPS = [
|
|
|
214
255
|
"react/jsx-dev-runtime",
|
|
215
256
|
"react-dom/client"
|
|
216
257
|
];
|
|
217
|
-
const
|
|
218
|
-
const
|
|
258
|
+
const SHIM_PATH = "__ph/dev-react-shim/";
|
|
259
|
+
const VITE_DEPS_PATH = "node_modules/.vite/deps";
|
|
260
|
+
function withBase(base, p) {
|
|
261
|
+
return `${base}${p}`.replace(/\/{2,}/g, "/");
|
|
262
|
+
}
|
|
219
263
|
/**
|
|
220
264
|
* Dev-only sibling of `esmExternalRequirePlugin`. The build path externalizes
|
|
221
265
|
* React via Rolldown so an importmap hands the same React instance to both
|
|
@@ -235,10 +279,14 @@ const VITE_DEPS_PREFIX = "/node_modules/.vite/deps";
|
|
|
235
279
|
*/
|
|
236
280
|
function devReactImportmapPlugin() {
|
|
237
281
|
let namedExports = /* @__PURE__ */ new Map();
|
|
282
|
+
let base = "/";
|
|
238
283
|
return {
|
|
239
284
|
name: "ph-dev-react-importmap",
|
|
240
285
|
apply: "serve",
|
|
241
286
|
config: () => ({ optimizeDeps: { include: REACT_DEPS } }),
|
|
287
|
+
configResolved(config) {
|
|
288
|
+
base = config.base;
|
|
289
|
+
},
|
|
242
290
|
configureServer(server) {
|
|
243
291
|
const requireFromRoot = createRequire(path.join(server.config.root, "package.json"));
|
|
244
292
|
namedExports = new Map(REACT_DEPS.map((id) => {
|
|
@@ -249,9 +297,11 @@ function devReactImportmapPlugin() {
|
|
|
249
297
|
return [id, []];
|
|
250
298
|
}
|
|
251
299
|
}));
|
|
300
|
+
const shimPrefixes = [withBase(base, SHIM_PATH), `/${SHIM_PATH}`];
|
|
252
301
|
server.middlewares.use((req, res, next) => {
|
|
253
|
-
|
|
254
|
-
|
|
302
|
+
const prefix = shimPrefixes.find((p) => req.url?.startsWith(p));
|
|
303
|
+
if (!prefix) return next();
|
|
304
|
+
const id = req.url.slice(prefix.length).replace(/\.js(\?.*)?$/, "");
|
|
255
305
|
if (!REACT_DEPS.includes(id)) return next();
|
|
256
306
|
const optimizer = server.environments.client.depsOptimizer;
|
|
257
307
|
const info = optimizer?.metadata.optimized[id] ?? optimizer?.metadata.discovered[id];
|
|
@@ -261,7 +311,7 @@ function devReactImportmapPlugin() {
|
|
|
261
311
|
return;
|
|
262
312
|
}
|
|
263
313
|
const browserHash = info.browserHash ?? optimizer.metadata.browserHash;
|
|
264
|
-
const depUrl = `${
|
|
314
|
+
const depUrl = `${withBase(base, VITE_DEPS_PATH)}/${path.basename(info.file)}?v=${browserHash}`;
|
|
265
315
|
const names = namedExports.get(id) ?? [];
|
|
266
316
|
res.setHeader("Content-Type", "application/javascript");
|
|
267
317
|
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` : ""));
|
|
@@ -272,7 +322,8 @@ function devReactImportmapPlugin() {
|
|
|
272
322
|
handler(html, ctx) {
|
|
273
323
|
const browserHash = ctx.server?.environments.client.depsOptimizer?.metadata.browserHash;
|
|
274
324
|
if (!browserHash) return;
|
|
275
|
-
const
|
|
325
|
+
const shimPrefix = withBase(base, SHIM_PATH);
|
|
326
|
+
const imports = Object.fromEntries(REACT_DEPS.map((id) => [id, `${shimPrefix}${id}.js?v=${browserHash}`]));
|
|
276
327
|
return html.replace(/<script type="importmap">[\s\S]*?<\/script>/, `<script type="importmap">${JSON.stringify({ imports }, null, 2)}<\/script>`);
|
|
277
328
|
}
|
|
278
329
|
}
|
|
@@ -288,13 +339,16 @@ function connectFaviconPlugin() {
|
|
|
288
339
|
return {
|
|
289
340
|
name: "copy-connect-favicon",
|
|
290
341
|
configureServer(server) {
|
|
291
|
-
server.
|
|
342
|
+
const faviconPath = `${server.config.base}icon.ico`.replace(/\/{2,}/g, "/");
|
|
343
|
+
const handler = (_req, res, next) => {
|
|
292
344
|
server.pluginContainer.resolveId("@powerhousedao/connect/assets/icon.ico").then((resolved) => {
|
|
293
345
|
if (!resolved) return next();
|
|
294
346
|
res.setHeader("Content-Type", "image/x-icon");
|
|
295
347
|
res.end(readFileSync(resolved.id));
|
|
296
348
|
}).catch(() => next());
|
|
297
|
-
}
|
|
349
|
+
};
|
|
350
|
+
const paths = new Set([faviconPath, "/icon.ico"]);
|
|
351
|
+
for (const path of paths) server.middlewares.use(path, handler);
|
|
298
352
|
},
|
|
299
353
|
async generateBundle(_options, bundle) {
|
|
300
354
|
try {
|
|
@@ -361,7 +415,7 @@ function phBundledPackagesPlugin(options) {
|
|
|
361
415
|
};
|
|
362
416
|
}
|
|
363
417
|
//#endregion
|
|
364
|
-
//#region connect-utils/vite-plugins/ph-
|
|
418
|
+
//#region connect-utils/vite-plugins/ph-config.ts
|
|
365
419
|
function readProjectPackageInfo(projectRoot) {
|
|
366
420
|
if (!projectRoot) return null;
|
|
367
421
|
try {
|
|
@@ -376,19 +430,26 @@ function readProjectPackageInfo(projectRoot) {
|
|
|
376
430
|
return null;
|
|
377
431
|
}
|
|
378
432
|
}
|
|
379
|
-
function
|
|
433
|
+
function phConfigPlugin(options) {
|
|
380
434
|
const localPackage = readProjectPackageInfo(options.projectRoot ?? process.cwd());
|
|
381
|
-
const
|
|
435
|
+
const withDefaults = deepMerge(DEFAULT_CONNECT_CONFIG, options.connect ?? {});
|
|
436
|
+
const mergedConnect = options.cliConnectOverride ? deepMerge(withDefaults, options.cliConnectOverride) : withDefaults;
|
|
437
|
+
const runtimeConfig = buildRuntimeConfig({
|
|
382
438
|
packages: options.packages,
|
|
383
|
-
|
|
384
|
-
|
|
439
|
+
packageRegistryUrl: options.packageRegistryUrl,
|
|
440
|
+
connect: mergedConnect
|
|
441
|
+
}, localPackage);
|
|
442
|
+
const content = JSON.stringify({
|
|
443
|
+
$schema: RUNTIME_CONFIG_SCHEMA_URL,
|
|
444
|
+
...runtimeConfig
|
|
385
445
|
}, null, 2);
|
|
386
446
|
return {
|
|
387
|
-
name: "vite-plugin-ph-
|
|
447
|
+
name: "vite-plugin-ph-config",
|
|
388
448
|
configureServer(server) {
|
|
389
449
|
server.middlewares.use((req, res, next) => {
|
|
390
|
-
if (req.url?.endsWith("/
|
|
450
|
+
if (req.url?.endsWith("/powerhouse.config.json")) {
|
|
391
451
|
res.setHeader("Content-Type", "application/json");
|
|
452
|
+
res.setHeader("Cache-Control", "no-cache");
|
|
392
453
|
res.end(content);
|
|
393
454
|
return;
|
|
394
455
|
}
|
|
@@ -407,7 +468,7 @@ function phPackagesPlugin(options) {
|
|
|
407
468
|
generateBundle() {
|
|
408
469
|
this.emitFile({
|
|
409
470
|
type: "asset",
|
|
410
|
-
fileName: "
|
|
471
|
+
fileName: "powerhouse.config.json",
|
|
411
472
|
source: content
|
|
412
473
|
});
|
|
413
474
|
}
|
|
@@ -521,9 +582,19 @@ function viteLogger({ silence }) {
|
|
|
521
582
|
};
|
|
522
583
|
return logger;
|
|
523
584
|
}
|
|
524
|
-
function
|
|
525
|
-
|
|
526
|
-
|
|
585
|
+
function parsePackagesEnvOverride(phPackagesStr) {
|
|
586
|
+
return phPackagesStr.split(",").map((s) => s.trim()).filter(Boolean).map((entry) => {
|
|
587
|
+
const lastAt = entry.lastIndexOf("@");
|
|
588
|
+
if (lastAt > 0) return {
|
|
589
|
+
packageName: entry.slice(0, lastAt),
|
|
590
|
+
version: entry.slice(lastAt + 1),
|
|
591
|
+
provider: "registry"
|
|
592
|
+
};
|
|
593
|
+
return {
|
|
594
|
+
packageName: entry,
|
|
595
|
+
provider: "registry"
|
|
596
|
+
};
|
|
597
|
+
});
|
|
527
598
|
}
|
|
528
599
|
function getLocalPackageNamesFromPowerhouseConfig({ packages }) {
|
|
529
600
|
if (!packages) return [];
|
|
@@ -537,16 +608,18 @@ function getConnectBaseViteConfig(options) {
|
|
|
537
608
|
fileEnv
|
|
538
609
|
});
|
|
539
610
|
setConnectEnv(env);
|
|
540
|
-
const phConfigPath =
|
|
611
|
+
const phConfigPath = join(options.dirname, "powerhouse.config.json");
|
|
541
612
|
const phConfig = options.powerhouseConfig ?? getConfig(phConfigPath);
|
|
542
|
-
const packagesFromConfig =
|
|
613
|
+
const packagesFromConfig = phConfig.packages ?? [];
|
|
543
614
|
const localPackagesFromConfig = getLocalPackageNamesFromPowerhouseConfig(phConfig);
|
|
544
|
-
const
|
|
545
|
-
const
|
|
615
|
+
const phPackagesStr = env.PH_PACKAGES;
|
|
616
|
+
const phPackages = (phPackagesStr ? parsePackagesEnvOverride(phPackagesStr) : void 0) ?? packagesFromConfig;
|
|
617
|
+
const phPackageRegistryUrl = options.cliPackageRegistryUrl ?? phConfig.packageRegistryUrl ?? null;
|
|
618
|
+
const connectBasePath = options.cliConnectOverride?.app?.basePath ?? phConfig.connect?.app?.basePath;
|
|
546
619
|
const authToken = env.PH_SENTRY_AUTH_TOKEN;
|
|
547
620
|
const org = env.PH_SENTRY_ORG;
|
|
548
621
|
const project = env.PH_SENTRY_PROJECT;
|
|
549
|
-
const release = env.
|
|
622
|
+
const release = process.env.WORKSPACE_VERSION ?? process.env.npm_package_version ?? env.PH_CONNECT_VERSION;
|
|
550
623
|
const uploadSentrySourcemaps = authToken && org && project;
|
|
551
624
|
const connectHtmlTags = getConnectHtmlTags({ registryUrl: phPackageRegistryUrl });
|
|
552
625
|
const plugins = [
|
|
@@ -573,7 +646,7 @@ function getConnectBaseViteConfig(options) {
|
|
|
573
646
|
bundleSizeOptimizations: { excludeDebugStatements: true },
|
|
574
647
|
reactComponentAnnotation: { enabled: true }
|
|
575
648
|
})));
|
|
576
|
-
const customLogger = process.env.LOG_LEVEL === "debug" ||
|
|
649
|
+
const customLogger = process.env.LOG_LEVEL === "debug" || phConfig.connect?.app?.logLevel === "debug" ? void 0 : viteLogger({ silence: {
|
|
577
650
|
warnings: ["@import must precede all other statements (besides @charset or empty @layer)"],
|
|
578
651
|
errors: ["Unterminated string literal"]
|
|
579
652
|
} });
|
|
@@ -597,7 +670,7 @@ function getConnectBaseViteConfig(options) {
|
|
|
597
670
|
return {
|
|
598
671
|
configFile: false,
|
|
599
672
|
mode,
|
|
600
|
-
base:
|
|
673
|
+
base: connectBasePath ? normalizeBasePath(connectBasePath) : void 0,
|
|
601
674
|
server: {
|
|
602
675
|
watch: { ignored: ["**/backup-documents/**", "**/.ph/**"] },
|
|
603
676
|
fs: { allow: [searchForWorkspaceRoot(options.dirname), ...linkedRoots] }
|
|
@@ -606,7 +679,7 @@ function getConnectBaseViteConfig(options) {
|
|
|
606
679
|
dedupe: ["react", "react-dom"],
|
|
607
680
|
tsconfigPaths: true
|
|
608
681
|
},
|
|
609
|
-
define: {},
|
|
682
|
+
define: { PH_CONNECT_SENTRY_RELEASE: JSON.stringify(release || "unknown") },
|
|
610
683
|
customLogger,
|
|
611
684
|
envPrefix: ["PH_CONNECT_"],
|
|
612
685
|
optimizeDeps: {
|
|
@@ -620,10 +693,12 @@ function getConnectBaseViteConfig(options) {
|
|
|
620
693
|
exclude: ["@electric-sql/pglite", "@electric-sql/pglite-tools"]
|
|
621
694
|
},
|
|
622
695
|
plugins: [
|
|
623
|
-
|
|
696
|
+
phConfigPlugin({
|
|
624
697
|
packages: phPackages,
|
|
625
698
|
projectRoot: options.dirname,
|
|
626
|
-
|
|
699
|
+
connect: phConfig.connect,
|
|
700
|
+
packageRegistryUrl: phPackageRegistryUrl ?? void 0,
|
|
701
|
+
cliConnectOverride: options.cliConnectOverride
|
|
627
702
|
}),
|
|
628
703
|
phBundledPackagesPlugin({
|
|
629
704
|
packages: localPackagesFromConfig,
|
|
@@ -639,6 +714,6 @@ function getConnectBaseViteConfig(options) {
|
|
|
639
714
|
};
|
|
640
715
|
}
|
|
641
716
|
//#endregion
|
|
642
|
-
export { DEFAULT_CONNECT_OUTDIR, EXTERNAL_PACKAGES_IMPORT, IMPORT_SCRIPT_FILE, LOCAL_PACKAGE_ID, PH_DIR_NAME, appendToHtmlHead, backupIndexHtml,
|
|
717
|
+
export { DEFAULT_CONNECT_OUTDIR, EXTERNAL_PACKAGES_IMPORT, IMPORT_SCRIPT_FILE, LOCAL_PACKAGE_ID, PH_DIR_NAME, RUNTIME_CONFIG_SCHEMA_ID, RUNTIME_CONFIG_SCHEMA_URL, appendToHtmlHead, backupIndexHtml, copyConnect, ensureNodeVersion, getConnectBaseViteConfig, getConnectHtmlTags, makeImportScriptFromPackages, phConfigPlugin, prependToHtmlHead, readJsonFile, removeBase64EnvValues, resolveConnectBundle, resolveConnectPackageJson, resolveConnectPublicDir, resolvePackage, resolveViteConfigPath, runShellScriptPlugin, runTsc, runtimeConfigSchema, stripVersionFromPackage };
|
|
643
718
|
|
|
644
719
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../connect-utils/constants.ts","../connect-utils/helpers.ts","../connect-utils/vite-plugins/dev-external-react.ts","../connect-utils/vite-plugins/favicon.ts","../connect-utils/vite-plugins/ph-bundled-packages.ts","../connect-utils/vite-plugins/ph-packages.ts","../connect-utils/vite-config.ts"],"sourcesContent":["export const EXTERNAL_PACKAGES_IMPORT = \"PH:EXTERNAL_PACKAGES\";\nexport const IMPORT_SCRIPT_FILE = \"external-packages.js\";\nexport const LOCAL_PACKAGE_ID = \"ph:local-package\";\nexport const PH_DIR_NAME = \".ph\";\n","import type { PowerhouseConfig } from \"@powerhousedao/config\";\nimport { exec, execSync } from \"node:child_process\";\nimport fs, { existsSync } from \"node:fs\";\nimport { readFile, writeFile } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport path, { join, resolve } from \"node:path\";\nimport { cwd } from \"node:process\";\nimport type { Plugin } from \"vite\";\nimport { LOCAL_PACKAGE_ID } from \"./constants.js\";\nimport { setConnectEnv } from \"@powerhousedao/shared/connect\";\nimport type { ConnectCommonOptions } from \"./types.js\";\n\nexport const DEFAULT_CONNECT_OUTDIR = \".ph/connect-build/dist/\" as const;\n\nexport function commonConnectOptionsToEnv(options: ConnectCommonOptions) {\n const {\n base,\n configFile,\n defaultDrivesUrl,\n drivesPreserveStrategy,\n disableLocalPackage,\n } = options;\n\n if (base) {\n setConnectEnv({\n PH_CONNECT_BASE_PATH: base,\n });\n }\n\n if (configFile) {\n setConnectEnv({\n PH_CONFIG_PATH: configFile,\n });\n }\n if (defaultDrivesUrl) {\n setConnectEnv({\n PH_CONNECT_DEFAULT_DRIVES_URL: defaultDrivesUrl.join(\",\"),\n });\n }\n if (drivesPreserveStrategy) {\n setConnectEnv({\n PH_CONNECT_DRIVES_PRESERVE_STRATEGY: drivesPreserveStrategy,\n });\n }\n if (disableLocalPackage) {\n setConnectEnv({\n PH_DISABLE_LOCAL_PACKAGE: true,\n });\n }\n}\n\nexport function resolveViteConfigPath(\n options: Pick<ConnectCommonOptions, \"projectRoot\" | \"viteConfigFile\">,\n) {\n const { projectRoot = cwd(), viteConfigFile } = options;\n return viteConfigFile || join(projectRoot, \"vite.config.ts\");\n}\n\nexport function resolvePackage(packageName: string, root = process.cwd()) {\n // find connect installation\n const require = createRequire(root);\n return require.resolve(packageName, { paths: [root] });\n}\n\nexport function resolveConnectPackageJson(root = process.cwd()) {\n try {\n const connectPackageJsonPath = resolvePackage(\n \"@powerhousedao/connect/package.json\",\n root,\n );\n const fileContents = fs.readFileSync(connectPackageJsonPath, \"utf-8\");\n return JSON.parse(fileContents) as JSON;\n } catch (error) {\n console.error(`Error reading Connect package.json:`, error);\n return null;\n }\n}\n\n/**\n * Finds the dist dir of Connect on the local machine\n */\nexport function resolveConnectBundle(root = process.cwd()) {\n const connectIndexPath = resolvePackage(\"@powerhousedao/connect\", root);\n const connectRootPath = connectIndexPath.substring(\n 0,\n connectIndexPath.indexOf(\"connect\") + \"connect\".length,\n );\n return join(connectRootPath, \"dist/\");\n}\n\nexport function resolveConnectPublicDir(root = process.cwd()) {\n const connectIconPath = resolvePackage(\n \"@powerhousedao/connect/public/icon.ico\",\n root,\n );\n return path.join(connectIconPath, \"../\");\n}\n\n/**\n * Copies the Connect dist dir to the target path\n */\nexport function copyConnect(sourcePath: string, targetPath: string) {\n try {\n // Ensure targetPath is removed before copying\n fs.rmSync(targetPath, { recursive: true, force: true });\n\n // Copy everything from sourcePath to targetPath\n fs.cpSync(sourcePath, targetPath, { recursive: true });\n } catch (error) {\n console.error(`❌ Error copying ${sourcePath} to ${targetPath}:`, error);\n }\n}\n\n/**\n * Backs up the index.html file\n *\n * Needed when running the Connect Studio dev server on Windows\n */\nexport function backupIndexHtml(appPath: string, restore = false) {\n const filePath = join(appPath, \"index.html\");\n const backupPath = join(appPath, \"index.html.bak\");\n\n const paths = restore ? [backupPath, filePath] : [filePath, backupPath];\n\n if (fs.existsSync(paths[0])) {\n fs.copyFileSync(paths[0], paths[1]);\n }\n}\n\nexport function removeBase64EnvValues(appPath: string) {\n backupIndexHtml(appPath);\n\n const filePath = join(appPath, \"index.html\");\n\n // Read the HTML file\n fs.readFile(filePath, \"utf-8\", (err, data) => {\n if (err) {\n console.error(\"Error reading file:\", err);\n return;\n }\n\n // Use regex to replace the dynamic Base64 values with empty strings\n // TODO is this needed?\n const modifiedData = data\n .replace(\n /\"LOCAL_DOCUMENT_MODELS\":\\s*\".*?\",/,\n `\"LOCAL_DOCUMENT_MODELS\": \"\",`,\n )\n .replace(\n /\"LOCAL_DOCUMENT_EDITORS\":\\s*\".*?\"/,\n `\"LOCAL_DOCUMENT_EDITORS\": \"\"`,\n );\n\n console.log(\"Modified data:\", modifiedData);\n // Write the modified content back to the file\n fs.writeFile(filePath, modifiedData, \"utf-8\", (err) => {\n if (err) {\n console.error(\"Error writing file:\", err);\n return;\n }\n });\n });\n}\n\nexport function readJsonFile(filePath: string): PowerhouseConfig | null {\n try {\n const absolutePath = resolve(filePath);\n const fileContents = fs.readFileSync(absolutePath, \"utf-8\");\n return JSON.parse(fileContents) as PowerhouseConfig;\n } catch (_error) {\n console.error(`Error reading file: ${filePath}`);\n return null;\n }\n}\n\n/**\n * 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.\n */\nexport function makeImportScriptFromPackages(args: {\n packages: string[];\n importStyles?: boolean;\n localJsPath?: string;\n localCssPath?: string;\n}) {\n const { packages, localJsPath, localCssPath, importStyles = true } = args;\n const imports: string[] = [];\n const moduleNames: string[] = [];\n let counter = 0;\n\n for (const packageName of packages) {\n const moduleName = `module${counter}`;\n moduleNames.push(moduleName);\n imports.push(`import * as ${moduleName} from '${packageName}';`);\n if (importStyles) {\n imports.push(`import '${packageName}/style.css';`);\n }\n counter++;\n }\n\n const exports = moduleNames.map(\n (name, index) => `{\n id: \"${packages[index]}\",\n ...${name},\n }`,\n );\n\n const hasModule = localJsPath !== undefined;\n const hasStyles = importStyles && localCssPath !== undefined;\n const hasLocalPackage = hasModule || hasStyles;\n\n if (hasLocalPackage) {\n if (hasStyles) {\n imports.push(`import '${localCssPath}';`);\n }\n if (hasModule) {\n const moduleName = `module${counter}`;\n imports.push(`import * as ${moduleName} from '${localJsPath}';`);\n exports.push(`{\n id: \"${LOCAL_PACKAGE_ID}\",\n ...${moduleName},\n }`);\n }\n }\n const exportsString = exports.length\n ? `\n ${exports.join(\",\\n\")}\n `\n : \"\";\n\n const exportStatement = `export default [${exportsString}];`;\n\n const fileContent = `${imports.join(\"\\n\")}\\n\\n${exportStatement}`;\n\n return fileContent;\n}\n\nexport function ensureNodeVersion(minVersion = \"24\") {\n const version = process.versions.node;\n if (!version) {\n return;\n }\n\n if (version < minVersion) {\n console.error(\n `Node version ${minVersion} or higher is required. Current version: ${version}`,\n );\n process.exit(1);\n }\n}\n\nexport function runShellScriptPlugin(\n scriptName: string,\n connectPath: string,\n): Plugin {\n return {\n name: \"vite-plugin-run-shell-script\",\n buildStart() {\n const scriptPath = join(connectPath, scriptName);\n if (fs.existsSync(scriptPath)) {\n exec(`sh ${scriptPath}`, (error, stdout, stderr) => {\n if (error) {\n console.error(`Error executing the script: ${error.message}`);\n removeBase64EnvValues(connectPath);\n return;\n }\n if (stderr) {\n console.error(stderr);\n }\n });\n }\n },\n };\n}\n\n/**\n * Shared helper to modify the <head> tag of an HTML file by transforming its contents.\n */\nasync function modifyHtmlHead(\n pathToHtml: string,\n contents: string,\n transform: (html: string, contents: string) => string,\n) {\n if (!existsSync(pathToHtml)) {\n throw new Error(`File ${pathToHtml} does not exist.`);\n }\n let html = await readFile(pathToHtml, \"utf8\");\n html = transform(html, contents);\n await writeFile(pathToHtml, html, \"utf8\");\n}\n\n/**\n * Appends the contents to the <head> tag of the index.html file\n */\nexport async function appendToHtmlHead(pathToHtml: string, contents: string) {\n return modifyHtmlHead(pathToHtml, contents, (html, contents) => {\n if (!html.includes(\"</head>\")) {\n throw new Error(\"No </head> tag found in the HTML file.\");\n }\n return html.replace(\"</head>\", `\\n${contents}\\n</head>`);\n });\n}\n\n/**\n * Prepends the contents to the <head> tag of the index.html file\n */\nexport async function prependToHtmlHead(pathToHtml: string, contents: string) {\n return modifyHtmlHead(pathToHtml, contents, (html, contents) => {\n if (!html.includes(\"</head>\")) {\n throw new Error(\"No </head> tag found in the HTML file.\");\n }\n return html.replace(\"<head>\", `<head>\\n${contents}\\n`);\n });\n}\n\nexport function runTsc(outDir: string) {\n execSync(`npx tsc --outDir ${outDir}`, { stdio: \"inherit\" });\n}\n\n// Helper function to remove version suffix from package name\n// Handles formats like: @scope/package@version -> @scope/package\nexport function stripVersionFromPackage(packageName: string): string {\n const trimmed = packageName.trim();\n if (!trimmed) return \"\";\n const lastAtIndex = trimmed.lastIndexOf(\"@\");\n if (lastAtIndex > 0) {\n return trimmed.substring(0, lastAtIndex);\n }\n\n return trimmed;\n}\n","import { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\n\nconst REACT_DEPS = [\n \"react\",\n \"react-dom\",\n \"react/jsx-runtime\",\n \"react/jsx-dev-runtime\",\n \"react-dom/client\",\n];\n\nconst SHIM_PREFIX = \"/__ph/dev-react-shim/\";\nconst VITE_DEPS_PREFIX = \"/node_modules/.vite/deps\";\n\n/**\n * Dev-only sibling of `esmExternalRequirePlugin`. The build path externalizes\n * React via Rolldown so an importmap hands the same React instance to both\n * Connect and CDN-served editor packages. Rolldown plugins don't run in\n * `vite createServer`, and Vite's pre-bundled CJS deps only expose a `default`\n * export — so a CDN editor that does `import { lazy } from \"react\"` would\n * fail with \"no named export 'lazy'\".\n *\n * This plugin:\n * 1. Forces React into `optimizeDeps.include` so the optimizer always knows\n * about it.\n * 2. Serves a shim per React module at a stable URL. Each shim imports\n * from Vite's live pre-bundled URL (sharing Connect's React instance)\n * and re-exports React's named members so editors importing\n * `{ lazy }`, `{ jsx }`, etc. work.\n * 3. Rewrites the page importmap to point at those shim URLs.\n */\nexport function devReactImportmapPlugin(): Plugin {\n let namedExports = new Map<string, string[]>();\n\n return {\n name: \"ph-dev-react-importmap\",\n apply: \"serve\",\n config: () => ({ optimizeDeps: { include: REACT_DEPS } }),\n configureServer(server) {\n // Resolve React's named exports from the consumer project so we don't\n // hardcode lists that drift across React versions.\n const requireFromRoot = createRequire(\n path.join(server.config.root, \"package.json\"),\n );\n namedExports = new Map(\n REACT_DEPS.map((id) => {\n try {\n const mod = requireFromRoot(id) as Record<string, unknown>;\n return [id, Object.keys(mod).filter((k) => k !== \"default\")];\n } catch {\n return [id, []];\n }\n }),\n );\n\n server.middlewares.use((req, res, next) => {\n if (!req.url?.startsWith(SHIM_PREFIX)) return next();\n const id = req.url\n .slice(SHIM_PREFIX.length)\n .replace(/\\.js(\\?.*)?$/, \"\");\n if (!REACT_DEPS.includes(id)) return next();\n\n const optimizer = server.environments.client.depsOptimizer;\n const info =\n optimizer?.metadata.optimized[id] ??\n optimizer?.metadata.discovered[id];\n if (!optimizer || !info) {\n res.statusCode = 404;\n res.end();\n return;\n }\n\n const browserHash = info.browserHash ?? optimizer.metadata.browserHash;\n const depUrl = `${VITE_DEPS_PREFIX}/${path.basename(info.file)}?v=${browserHash}`;\n const names = namedExports.get(id) ?? [];\n\n res.setHeader(\"Content-Type\", \"application/javascript\");\n res.end(\n `import * as M from ${JSON.stringify(depUrl)};\\n` +\n `const ns = M.default ?? M;\\n` +\n `export default ns;\\n` +\n (names.length\n ? `export const { ${names.join(\", \")} } = ns;\\n`\n : \"\"),\n );\n });\n },\n transformIndexHtml: {\n order: \"post\",\n handler(html, ctx) {\n const browserHash =\n ctx.server?.environments.client.depsOptimizer?.metadata.browserHash;\n if (!browserHash) return;\n const imports = Object.fromEntries(\n REACT_DEPS.map((id) => [\n id,\n `${SHIM_PREFIX}${id}.js?v=${browserHash}`,\n ]),\n );\n return html.replace(\n /<script type=\"importmap\">[\\s\\S]*?<\\/script>/,\n `<script type=\"importmap\">${JSON.stringify({ imports }, null, 2)}</script>`,\n );\n },\n },\n };\n}\n","import { readFileSync } from \"node:fs\";\nimport type { Plugin } from \"vite\";\n\n/**\n * Vite plugin to serve the Connect favicon (icon.ico) from the connect package.\n * This ensures the favicon is available in development and included in the production build.\n */\nexport function connectFaviconPlugin(): Plugin {\n return {\n name: \"copy-connect-favicon\",\n configureServer(server) {\n // Serve icon.ico before Vite's static middleware so it acts as a fallback\n server.middlewares.use(\"/icon.ico\", (_req, res, next) => {\n server.pluginContainer\n .resolveId(\"@powerhousedao/connect/assets/icon.ico\")\n .then((resolved) => {\n if (!resolved) return next();\n res.setHeader(\"Content-Type\", \"image/x-icon\");\n res.end(readFileSync(resolved.id));\n })\n .catch(() => next());\n });\n },\n async generateBundle(_options, bundle) {\n try {\n if (\"icon.ico\" in bundle) return;\n const resolved = await this.resolve(\n \"@powerhousedao/connect/assets/icon.ico\",\n );\n if (!resolved) return;\n this.emitFile({\n type: \"asset\",\n fileName: \"icon.ico\",\n source: readFileSync(resolved.id),\n });\n } catch {\n // connect package not found, skip favicon\n }\n },\n };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\n\nexport type PhBundledPackagesPluginOptions = {\n /**\n * Package names (with `provider: \"local\"` in powerhouse.config.json)\n * that should be bundled into Connect at build time. Each must be\n * resolvable from node_modules.\n */\n packages: string[];\n /** Project root used to read each bundled package's package.json version. */\n projectRoot?: string;\n};\n\nconst VIRTUAL_ID = \"ph-bundled-packages-virtual\";\nconst RESOLVED_VIRTUAL_ID = \"\\0virtual:\" + VIRTUAL_ID;\n\nfunction readBundledPackageVersion(\n projectRoot: string,\n name: string,\n): string | undefined {\n try {\n const raw = fs.readFileSync(\n path.join(projectRoot, \"node_modules\", name, \"package.json\"),\n \"utf-8\",\n );\n const pkg = JSON.parse(raw) as { version?: unknown };\n return typeof pkg.version === \"string\" ? pkg.version : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction makeRegisterModule(packages: string[], projectRoot: string): string {\n if (packages.length === 0) {\n return \"export default () => {};\\n\";\n }\n const imports: string[] = [];\n const calls: string[] = [];\n\n packages.forEach((name, i) => {\n const moduleName = `pkg${i}`;\n const version = readBundledPackageVersion(projectRoot, name);\n imports.push(`import * as ${moduleName} from ${JSON.stringify(name)};`);\n imports.push(`import ${JSON.stringify(`${name}/style.css`)};`);\n calls.push(\n ` pm.addLocalPackage(${JSON.stringify(name)}, ${moduleName}, ${JSON.stringify(version)});`,\n );\n });\n\n return `${imports.join(\"\\n\")}\\n\\nexport default function register(pm) {\\n${calls.join(\"\\n\")}\\n};\\n`;\n}\n\n/**\n * Emits a virtual module `ph-bundled-packages-virtual` whose default export\n * is a `register(packageManager)` function. When called at runtime (from\n * Connect's bootstrap), it registers each bundled package with the package\n * manager the same way Common/Vetra are registered — meaning they work\n * offline without the registry being reachable.\n *\n * When the list is empty, the module exports a no-op function so Connect's\n * bootstrap code can always import it unconditionally.\n */\nexport function phBundledPackagesPlugin(\n options: PhBundledPackagesPluginOptions,\n): Plugin {\n const projectRoot = options.projectRoot ?? process.cwd();\n const moduleSource = makeRegisterModule(options.packages, projectRoot);\n\n return {\n name: \"vite-plugin-ph-bundled-packages\",\n enforce: \"pre\",\n resolveId(id) {\n if (id === VIRTUAL_ID) return RESOLVED_VIRTUAL_ID;\n },\n load(id) {\n if (id === RESOLVED_VIRTUAL_ID) return moduleSource;\n },\n };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\n\nexport type PhPackagesPluginOptions = {\n packages: string[];\n projectRoot?: string;\n registryUrl?: string | null;\n};\n\nfunction readProjectPackageInfo(\n projectRoot: string | undefined,\n): { name: string; version: string } | null {\n if (!projectRoot) return null;\n try {\n const raw = fs.readFileSync(\n path.join(projectRoot, \"package.json\"),\n \"utf-8\",\n );\n const pkg = JSON.parse(raw) as { name?: unknown; version?: unknown };\n if (typeof pkg.name !== \"string\" || typeof pkg.version !== \"string\") {\n return null;\n }\n return { name: pkg.name, version: pkg.version };\n } catch {\n return null;\n }\n}\n\nexport function phPackagesPlugin(options: PhPackagesPluginOptions): Plugin {\n const projectRoot = options.projectRoot ?? process.cwd();\n const localPackage = readProjectPackageInfo(projectRoot);\n const content = JSON.stringify(\n {\n packages: options.packages,\n localPackage,\n registryUrl: options.registryUrl ?? null,\n },\n null,\n 2,\n );\n\n return {\n name: \"vite-plugin-ph-packages\",\n configureServer(server) {\n server.middlewares.use((req, res, next) => {\n if (req.url?.endsWith(\"/ph-packages.json\")) {\n res.setHeader(\"Content-Type\", \"application/json\");\n res.end(content);\n return;\n }\n next();\n });\n },\n hotUpdate: {\n order: \"pre\",\n handler(ctx) {\n // filter out modules only imported by \"style.css\"\n // to avoid page reloads triggered by tailwind\n return ctx.modules.filter((mod) => {\n if (mod.importers.size > 1) {\n return true;\n }\n const importer = mod.importers.values().next();\n return !importer.value?.file?.endsWith(\".css\");\n });\n },\n },\n generateBundle() {\n this.emitFile({\n type: \"asset\",\n fileName: \"ph-packages.json\",\n source: content,\n });\n },\n };\n}\n","import type { PowerhouseConfig } from \"@powerhousedao/config\";\nimport { getConfig } from \"@powerhousedao/config/node\";\nimport {\n loadConnectEnv,\n normalizeBasePath,\n setConnectEnv,\n} from \"@powerhousedao/shared/connect\";\nimport tailwind from \"@tailwindcss/vite\";\nimport react from \"@vitejs/plugin-react\";\nimport { realpathSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport {\n createLogger,\n esmExternalRequirePlugin,\n loadEnv,\n searchForWorkspaceRoot,\n type HtmlTagDescriptor,\n type InlineConfig,\n type PluginOption,\n} from \"vite\";\nimport { createHtmlPlugin } from \"vite-plugin-html\";\nimport type { IConnectOptions } from \"./types.js\";\nimport { devReactImportmapPlugin } from \"./vite-plugins/dev-external-react.js\";\nimport { connectFaviconPlugin } from \"./vite-plugins/favicon.js\";\nimport { phBundledPackagesPlugin } from \"./vite-plugins/ph-bundled-packages.js\";\nimport { phPackagesPlugin } from \"./vite-plugins/ph-packages.js\";\n\nconst REACT_VERSION = \"19.2.0\";\n\n// Importmap injected into Connect's HTML in production builds. The build\n// pipeline externalizes react/react-dom via Rolldown's\n// `esmExternalRequirePlugin` (see below), so the browser resolves bare\n// `react` imports through this map → CDN editor packages and Connect share\n// the same React instance via esm.sh. In dev, `devReactImportmapPlugin`\n// rewrites this map to point at Vite's pre-bundled React instead.\nconst REACT_IMPORTMAP_IMPORTS: Record<string, string> = {\n react: `https://esm.sh/react@${REACT_VERSION}`,\n \"react/\": `https://esm.sh/react@${REACT_VERSION}/`,\n \"react-dom\": `https://esm.sh/react-dom@${REACT_VERSION}`,\n \"react-dom/\": `https://esm.sh/react-dom@${REACT_VERSION}/`,\n};\n\nexport function getConnectHtmlTags(\n options: {\n registryUrl?: string | null;\n injectTo?: HtmlTagDescriptor[\"injectTo\"];\n } = {},\n) {\n const { registryUrl, injectTo = \"head\" } = options;\n return [\n {\n tag: \"meta\",\n attrs: {\n \"http-equiv\": \"Content-Security-Policy\",\n content: `script-src 'self' 'unsafe-inline' 'unsafe-eval' https://esm.sh${registryUrl ? \" \" + registryUrl : \"\"}; worker-src 'self' blob:; object-src 'none'; base-uri 'self';`,\n },\n injectTo,\n },\n {\n tag: \"meta\",\n attrs: {\n property: \"og:title\",\n content: \"Connect\",\n },\n injectTo,\n },\n {\n tag: \"meta\",\n attrs: {\n property: \"og:type\",\n content: \"website\",\n },\n injectTo,\n },\n {\n tag: \"meta\",\n attrs: {\n property: \"og:url\",\n content: \"https://apps.powerhouse.io/powerhouse/connect/\",\n },\n injectTo,\n },\n {\n tag: \"meta\",\n attrs: {\n property: \"og:description\",\n content:\n \"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.\",\n },\n injectTo,\n },\n {\n tag: \"meta\",\n attrs: {\n property: \"og:image\",\n content:\n \"https://cf-ipfs.com/ipfs/bafkreigrmclndf2jpbolaq22535q2sw5t44uad3az3dpvkzrnt4lpjt63e\",\n },\n injectTo,\n },\n {\n tag: \"meta\",\n attrs: {\n name: \"twitter:card\",\n content: \"summary_large_image\",\n },\n injectTo,\n },\n {\n tag: \"meta\",\n attrs: {\n name: \"twitter:image\",\n content:\n \"https://cf-ipfs.com/ipfs/bafkreigrmclndf2jpbolaq22535q2sw5t44uad3az3dpvkzrnt4lpjt63e\",\n },\n injectTo,\n },\n {\n tag: \"meta\",\n attrs: {\n name: \"twitter:title\",\n content: \"Connect\",\n },\n injectTo,\n },\n {\n tag: \"meta\",\n attrs: {\n name: \"twitter:description\",\n content:\n \"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.\",\n },\n injectTo,\n },\n ] as const satisfies HtmlTagDescriptor[];\n}\n\nfunction viteLogger({\n silence,\n}: {\n silence?: { warnings?: string[]; errors?: string[] };\n}) {\n const logger = createLogger();\n const loggerWarn = logger.warn.bind(logger);\n const loggerError = logger.error.bind(logger);\n\n logger.warn = (msg, options) => {\n if (silence?.warnings?.some((warning) => msg.includes(warning))) {\n return;\n }\n loggerWarn(msg, options);\n };\n\n logger.error = (msg, options) => {\n if (silence?.errors?.some((error) => msg.includes(error))) {\n return;\n }\n loggerError(msg, options);\n };\n\n return logger;\n}\n\nfunction getPackageNamesFromPowerhouseConfig({ packages }: PowerhouseConfig) {\n if (!packages) return [];\n // Preserve the version/tag from powerhouse.config.json so Connect's runtime\n // resolver sees it when building the registry CDN URL. Without this the\n // registry falls back to its `latest` dist-tag, which may point to a\n // different release stream than what the project asked for (e.g. latest\n // vs. dev). Local packages resolve from node_modules and don't need a\n // version here.\n return packages.map((p) =>\n p.version && p.provider !== \"local\"\n ? `${p.packageName}@${p.version}`\n : p.packageName,\n );\n}\n\nfunction getLocalPackageNamesFromPowerhouseConfig({\n packages,\n}: PowerhouseConfig) {\n if (!packages) return [];\n return packages\n .filter((p) => p.provider === \"local\")\n .map((p) => p.packageName);\n}\n\nexport function getConnectBaseViteConfig(options: IConnectOptions) {\n const mode = options.mode;\n const envDir = options.envDir ?? options.dirname;\n const fileEnv = loadEnv(mode, envDir, \"PH_\");\n\n // Load and validate environment with priority: process.env > options > fileEnv > defaults\n const env = loadConnectEnv({\n processEnv: process.env,\n fileEnv,\n });\n\n // set the resolved env to process.env so it's loaded by vite\n setConnectEnv(env);\n\n // load powerhouse config\n const phConfigPath =\n env.PH_CONFIG_PATH ?? join(options.dirname, \"powerhouse.config.json\");\n\n const phConfig = options.powerhouseConfig ?? getConfig(phConfigPath);\n\n const packagesFromConfig = getPackageNamesFromPowerhouseConfig(phConfig);\n const localPackagesFromConfig =\n getLocalPackageNamesFromPowerhouseConfig(phConfig);\n const phPackagesStr = env.PH_PACKAGES;\n const envPhPackages = phPackagesStr?.split(\",\");\n\n const phPackages = envPhPackages ?? packagesFromConfig;\n\n const phPackageRegistryUrl =\n env.PH_CONNECT_PACKAGES_REGISTRY ?? phConfig.packageRegistryUrl ?? null;\n\n const authToken = env.PH_SENTRY_AUTH_TOKEN;\n const org = env.PH_SENTRY_ORG;\n const project = env.PH_SENTRY_PROJECT;\n const release = env.PH_CONNECT_SENTRY_RELEASE || env.PH_CONNECT_VERSION;\n const uploadSentrySourcemaps = authToken && org && project;\n\n const connectHtmlTags = getConnectHtmlTags({\n registryUrl: phPackageRegistryUrl,\n });\n\n const plugins: PluginOption[] = [\n tailwind(),\n react(),\n createHtmlPlugin({\n minify: false,\n inject: {\n tags: [\n ...connectHtmlTags,\n {\n tag: \"script\",\n attrs: { type: \"importmap\" },\n children: JSON.stringify(\n { imports: REACT_IMPORTMAP_IMPORTS },\n null,\n 2,\n ),\n injectTo: \"head-prepend\",\n },\n ],\n },\n }),\n ] as const;\n\n if (uploadSentrySourcemaps) {\n plugins.push(\n import(\"@sentry/vite-plugin\").then(({ sentryVitePlugin }) =>\n sentryVitePlugin({\n release: {\n name: release ?? \"unknown\",\n inject: false, // prevent it from injecting the release id in the service worker code, this is done in 'src/app/sentry.ts' instead\n },\n authToken,\n org,\n project,\n bundleSizeOptimizations: {\n excludeDebugStatements: true,\n },\n reactComponentAnnotation: {\n enabled: true,\n },\n }),\n ) as PluginOption,\n );\n }\n\n // hide warnings unless LOG_LEVEL is set to debug\n const isDebug =\n process.env.LOG_LEVEL === \"debug\" || env.PH_CONNECT_LOG_LEVEL === \"debug\";\n const customLogger = isDebug\n ? undefined\n : viteLogger({\n silence: {\n warnings: [\n \"@import must precede all other statements (besides @charset or empty @layer)\", // tailwindcss error when importing font file\n ],\n errors: [\"Unterminated string literal\"],\n },\n });\n\n const reactExternal = [\n \"react\",\n \"react-dom\",\n \"react/jsx-runtime\",\n \"react-dom/client\",\n ];\n\n // pnpm `link:` deps (e.g. a downstream project linking @powerhousedao/*\n // packages from a sibling monorepo checkout) live outside Vite's\n // auto-detected workspace root. Their `node_modules/.pnpm/...` assets\n // then 403 through `/@fs/`, returning a 760-byte HTML body where the\n // binary should be — which breaks PGlite at startup with \"Invalid FS\n // bundle size: 760 !== 4939170\". Resolve key linked packages back to\n // their real workspace roots and allow Vite to serve from there.\n const linkedRoots = [\n \"@powerhousedao/reactor-browser\",\n \"@powerhousedao/connect\",\n \"@electric-sql/pglite\",\n ]\n .map((pkg) => {\n try {\n return searchForWorkspaceRoot(\n realpathSync(join(options.dirname, \"node_modules\", pkg)),\n );\n } catch {\n return null;\n }\n })\n .filter((p): p is string => p !== null);\n\n const config: InlineConfig = {\n configFile: false,\n mode,\n // Prefix served/built asset URLs so Connect can run under a path prefix\n // (reverse proxy). Mirrors the client router basename; normalize so a bare\n // `app` or `/app` becomes `/app/` and matches the router.\n base: env.PH_CONNECT_BASE_PATH\n ? normalizeBasePath(env.PH_CONNECT_BASE_PATH)\n : undefined,\n server: {\n watch: {\n ignored: [\"**/backup-documents/**\", \"**/.ph/**\"],\n },\n fs: {\n allow: [searchForWorkspaceRoot(options.dirname), ...linkedRoots],\n },\n },\n resolve: {\n dedupe: [\"react\", \"react-dom\"],\n tsconfigPaths: true,\n },\n define: {},\n customLogger,\n envPrefix: [\"PH_CONNECT_\"],\n optimizeDeps: {\n include: [\n \"document-model\",\n \"zod\",\n \"@powerhousedao/design-system/connect\",\n \"@powerhousedao/reactor-browser\",\n \"@powerhousedao/document-engineering\",\n ],\n exclude: [\"@electric-sql/pglite\", \"@electric-sql/pglite-tools\"],\n },\n plugins: [\n // phPackagesPlugin must be registered before tailwind so its hotUpdate\n // hook runs first and can suppress HMR updates for codegen-generated\n // files, preventing tailwind from triggering full page reloads.\n phPackagesPlugin({\n packages: phPackages,\n projectRoot: options.dirname,\n registryUrl: phPackageRegistryUrl,\n }),\n phBundledPackagesPlugin({\n packages: localPackagesFromConfig,\n projectRoot: options.dirname,\n }),\n // Dev-only: rewrite the importmap so it points at Vite's pre-bundled\n // React (the same URL Connect's own modules resolve to). Without this,\n // CDN editors load React from esm.sh while Connect uses Vite's local\n // copy → two React instances → useSyncExternalStore crash. The build\n // path stays untouched; `esmExternalRequirePlugin` below still owns it.\n devReactImportmapPlugin(),\n ...plugins,\n // Externalize React so both Connect and dynamically loaded registry\n // packages share the same React instance via the import map in index.html.\n // Without this, Vite bundles React into Connect's chunks while registry\n // packages resolve React from the import map (esm.sh), creating two\n // separate React instances that don't share context/state.\n //\n // In Vite 8 (Rolldown), require() calls for external modules are preserved\n // as-is, which fails in browsers. esmExternalRequirePlugin handles both\n // externalization AND converting require() to import statements.\n // NOTE: Do NOT also list these in build.rolldownOptions.external — overlapping\n // entries prevent the plugin from transforming require() calls.\n esmExternalRequirePlugin({ external: reactExternal }),\n connectFaviconPlugin(),\n ],\n worker: {\n format: \"es\",\n },\n build: {\n sourcemap: true,\n },\n };\n return config;\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,MAAa,2BAA2B;AACxC,MAAa,qBAAqB;AAClC,MAAa,mBAAmB;AAChC,MAAa,cAAc;;;ACS3B,MAAa,yBAAyB;AAEtC,SAAgB,0BAA0B,SAA+B;CACvE,MAAM,EACJ,MACA,YACA,kBACA,wBACA,wBACE;AAEJ,KAAI,KACF,eAAc,EACZ,sBAAsB,MACvB,CAAC;AAGJ,KAAI,WACF,eAAc,EACZ,gBAAgB,YACjB,CAAC;AAEJ,KAAI,iBACF,eAAc,EACZ,+BAA+B,iBAAiB,KAAK,IAAI,EAC1D,CAAC;AAEJ,KAAI,uBACF,eAAc,EACZ,qCAAqC,wBACtC,CAAC;AAEJ,KAAI,oBACF,eAAc,EACZ,0BAA0B,MAC3B,CAAC;;AAIN,SAAgB,sBACd,SACA;CACA,MAAM,EAAE,cAAc,K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BAAwB,MACzB;EACD,0BAA0B,EACxB,SAAS,MACV;EACF,CAAC,CACH,CACF;CAMH,MAAM,eADJ,QAAQ,IAAI,cAAc,WAAW,IAAI,yBAAyB,UAEhE,KAAA,IACA,WAAW,EACT,SAAS;EACP,UAAU,CACR,+EACD;EACD,QAAQ,CAAC,8BAA8B;EACxC,EACF,CAAC;CAEN,MAAM,gBAAgB;EACpB;EACA;EACA;EACA;EACD;CASD,MAAM,cAAc;EAClB;EACA;EACA;EACD,CACE,KAAK,QAAQ;AACZ,MAAI;AACF,UAAO,uBACL,aAAa,KAAK,QAAQ,SAAS,gBAAgB,IAAI,CAAC,CACzD;UACK;AACN,UAAO;;GAET,CACD,QAAQ,MAAmB,MAAM,KAAK;AA6EzC,QA3E6B;EAC3B,YAAY;EACZ;EAIA,MAAM,IAAI,uBACN,kBAAkB,IAAI,qBAAqB,GAC3C,KAAA;EACJ,QAAQ;GACN,OAAO,EACL,SAAS,CAAC,0BAA0B,YAAY,EACjD;GACD,IAAI,EACF,OAAO,CAAC,uBAAuB,QAAQ,QAAQ,EAAE,GAAG,YAAY,EACjE;GACF;EACD,SAAS;GACP,QAAQ,CAAC,SAAS,YAAY;GAC9B,eAAe;GAChB;EACD,QAAQ,EAAE;EACV;EACA,WAAW,CAAC,cAAc;EAC1B,cAAc;GACZ,SAAS;IACP;IACA;IACA;IACA;IACA;IACD;GACD,SAAS,CAAC,wBAAwB,6BAA6B;GAChE;EACD,SAAS;GAIP,iBAAiB;IACf,UAAU;IACV,aAAa,QAAQ;IACrB,aAAa;IACd,CAAC;GACF,wBAAwB;IACtB,UAAU;IACV,aAAa,QAAQ;IACtB,CAAC;GAMF,yBAAyB;GACzB,GAAG;GAYH,yBAAyB,EAAE,UAAU,eAAe,CAAC;GACrD,sBAAsB;GACvB;EACD,QAAQ,EACN,QAAQ,MACT;EACD,OAAO,EACL,WAAW,MACZ;EACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../connect-utils/constants.ts","../connect-utils/helpers.ts","../connect-utils/runtime-config-schema.ts","../connect-utils/vite-plugins/dev-external-react.ts","../connect-utils/vite-plugins/favicon.ts","../connect-utils/vite-plugins/ph-bundled-packages.ts","../connect-utils/vite-plugins/ph-config.ts","../connect-utils/vite-config.ts"],"sourcesContent":["export const EXTERNAL_PACKAGES_IMPORT = \"PH:EXTERNAL_PACKAGES\";\nexport const IMPORT_SCRIPT_FILE = \"external-packages.js\";\nexport const LOCAL_PACKAGE_ID = \"ph:local-package\";\nexport const PH_DIR_NAME = \".ph\";\n","import type { PowerhouseConfig } from \"@powerhousedao/config\";\nimport { exec, execSync } from \"node:child_process\";\nimport fs, { existsSync } from \"node:fs\";\nimport { readFile, writeFile } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\nimport path, { join, resolve } from \"node:path\";\nimport { cwd } from \"node:process\";\nimport type { Plugin } from \"vite\";\nimport { LOCAL_PACKAGE_ID } from \"./constants.js\";\nimport type { ConnectCommonOptions } from \"./types.js\";\n\nexport const DEFAULT_CONNECT_OUTDIR = \".ph/connect-build/dist/\" as const;\n\nexport function resolveViteConfigPath(\n options: Pick<ConnectCommonOptions, \"projectRoot\" | \"viteConfigFile\">,\n) {\n const { projectRoot = cwd(), viteConfigFile } = options;\n return viteConfigFile || join(projectRoot, \"vite.config.ts\");\n}\n\nexport function resolvePackage(packageName: string, root = process.cwd()) {\n // find connect installation\n const require = createRequire(root);\n return require.resolve(packageName, { paths: [root] });\n}\n\nexport function resolveConnectPackageJson(root = process.cwd()) {\n try {\n const connectPackageJsonPath = resolvePackage(\n \"@powerhousedao/connect/package.json\",\n root,\n );\n const fileContents = fs.readFileSync(connectPackageJsonPath, \"utf-8\");\n return JSON.parse(fileContents) as JSON;\n } catch (error) {\n console.error(`Error reading Connect package.json:`, error);\n return null;\n }\n}\n\n/**\n * Finds the dist dir of Connect on the local machine\n */\nexport function resolveConnectBundle(root = process.cwd()) {\n const connectIndexPath = resolvePackage(\"@powerhousedao/connect\", root);\n const connectRootPath = connectIndexPath.substring(\n 0,\n connectIndexPath.indexOf(\"connect\") + \"connect\".length,\n );\n return join(connectRootPath, \"dist/\");\n}\n\nexport function resolveConnectPublicDir(root = process.cwd()) {\n const connectIconPath = resolvePackage(\n \"@powerhousedao/connect/public/icon.ico\",\n root,\n );\n return path.join(connectIconPath, \"../\");\n}\n\n/**\n * Copies the Connect dist dir to the target path\n */\nexport function copyConnect(sourcePath: string, targetPath: string) {\n try {\n // Ensure targetPath is removed before copying\n fs.rmSync(targetPath, { recursive: true, force: true });\n\n // Copy everything from sourcePath to targetPath\n fs.cpSync(sourcePath, targetPath, { recursive: true });\n } catch (error) {\n console.error(`❌ Error copying ${sourcePath} to ${targetPath}:`, error);\n }\n}\n\n/**\n * Backs up the index.html file\n *\n * Needed when running the Connect Studio dev server on Windows\n */\nexport function backupIndexHtml(appPath: string, restore = false) {\n const filePath = join(appPath, \"index.html\");\n const backupPath = join(appPath, \"index.html.bak\");\n\n const paths = restore ? [backupPath, filePath] : [filePath, backupPath];\n\n if (fs.existsSync(paths[0])) {\n fs.copyFileSync(paths[0], paths[1]);\n }\n}\n\nexport function removeBase64EnvValues(appPath: string) {\n backupIndexHtml(appPath);\n\n const filePath = join(appPath, \"index.html\");\n\n // Read the HTML file\n fs.readFile(filePath, \"utf-8\", (err, data) => {\n if (err) {\n console.error(\"Error reading file:\", err);\n return;\n }\n\n // Use regex to replace the dynamic Base64 values with empty strings\n // TODO is this needed?\n const modifiedData = data\n .replace(\n /\"LOCAL_DOCUMENT_MODELS\":\\s*\".*?\",/,\n `\"LOCAL_DOCUMENT_MODELS\": \"\",`,\n )\n .replace(\n /\"LOCAL_DOCUMENT_EDITORS\":\\s*\".*?\"/,\n `\"LOCAL_DOCUMENT_EDITORS\": \"\"`,\n );\n\n console.log(\"Modified data:\", modifiedData);\n // Write the modified content back to the file\n fs.writeFile(filePath, modifiedData, \"utf-8\", (err) => {\n if (err) {\n console.error(\"Error writing file:\", err);\n return;\n }\n });\n });\n}\n\nexport function readJsonFile(filePath: string): PowerhouseConfig | null {\n try {\n const absolutePath = resolve(filePath);\n const fileContents = fs.readFileSync(absolutePath, \"utf-8\");\n return JSON.parse(fileContents) as PowerhouseConfig;\n } catch (_error) {\n console.error(`Error reading file: ${filePath}`);\n return null;\n }\n}\n\n/**\n * 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.\n */\nexport function makeImportScriptFromPackages(args: {\n packages: string[];\n importStyles?: boolean;\n localJsPath?: string;\n localCssPath?: string;\n}) {\n const { packages, localJsPath, localCssPath, importStyles = true } = args;\n const imports: string[] = [];\n const moduleNames: string[] = [];\n let counter = 0;\n\n for (const packageName of packages) {\n const moduleName = `module${counter}`;\n moduleNames.push(moduleName);\n imports.push(`import * as ${moduleName} from '${packageName}';`);\n if (importStyles) {\n imports.push(`import '${packageName}/style.css';`);\n }\n counter++;\n }\n\n const exports = moduleNames.map(\n (name, index) => `{\n id: \"${packages[index]}\",\n ...${name},\n }`,\n );\n\n const hasModule = localJsPath !== undefined;\n const hasStyles = importStyles && localCssPath !== undefined;\n const hasLocalPackage = hasModule || hasStyles;\n\n if (hasLocalPackage) {\n if (hasStyles) {\n imports.push(`import '${localCssPath}';`);\n }\n if (hasModule) {\n const moduleName = `module${counter}`;\n imports.push(`import * as ${moduleName} from '${localJsPath}';`);\n exports.push(`{\n id: \"${LOCAL_PACKAGE_ID}\",\n ...${moduleName},\n }`);\n }\n }\n const exportsString = exports.length\n ? `\n ${exports.join(\",\\n\")}\n `\n : \"\";\n\n const exportStatement = `export default [${exportsString}];`;\n\n const fileContent = `${imports.join(\"\\n\")}\\n\\n${exportStatement}`;\n\n return fileContent;\n}\n\nexport function ensureNodeVersion(minVersion = \"24\") {\n const version = process.versions.node;\n if (!version) {\n return;\n }\n\n if (version < minVersion) {\n console.error(\n `Node version ${minVersion} or higher is required. Current version: ${version}`,\n );\n process.exit(1);\n }\n}\n\nexport function runShellScriptPlugin(\n scriptName: string,\n connectPath: string,\n): Plugin {\n return {\n name: \"vite-plugin-run-shell-script\",\n buildStart() {\n const scriptPath = join(connectPath, scriptName);\n if (fs.existsSync(scriptPath)) {\n exec(`sh ${scriptPath}`, (error, stdout, stderr) => {\n if (error) {\n console.error(`Error executing the script: ${error.message}`);\n removeBase64EnvValues(connectPath);\n return;\n }\n if (stderr) {\n console.error(stderr);\n }\n });\n }\n },\n };\n}\n\n/**\n * Shared helper to modify the <head> tag of an HTML file by transforming its contents.\n */\nasync function modifyHtmlHead(\n pathToHtml: string,\n contents: string,\n transform: (html: string, contents: string) => string,\n) {\n if (!existsSync(pathToHtml)) {\n throw new Error(`File ${pathToHtml} does not exist.`);\n }\n let html = await readFile(pathToHtml, \"utf8\");\n html = transform(html, contents);\n await writeFile(pathToHtml, html, \"utf8\");\n}\n\n/**\n * Appends the contents to the <head> tag of the index.html file\n */\nexport async function appendToHtmlHead(pathToHtml: string, contents: string) {\n return modifyHtmlHead(pathToHtml, contents, (html, contents) => {\n if (!html.includes(\"</head>\")) {\n throw new Error(\"No </head> tag found in the HTML file.\");\n }\n return html.replace(\"</head>\", `\\n${contents}\\n</head>`);\n });\n}\n\n/**\n * Prepends the contents to the <head> tag of the index.html file\n */\nexport async function prependToHtmlHead(pathToHtml: string, contents: string) {\n return modifyHtmlHead(pathToHtml, contents, (html, contents) => {\n if (!html.includes(\"</head>\")) {\n throw new Error(\"No </head> tag found in the HTML file.\");\n }\n return html.replace(\"<head>\", `<head>\\n${contents}\\n`);\n });\n}\n\nexport function runTsc(outDir: string) {\n execSync(`npx tsc --outDir ${outDir}`, { stdio: \"inherit\" });\n}\n\n// Helper function to remove version suffix from package name\n// Handles formats like: @scope/package@version -> @scope/package\nexport function stripVersionFromPackage(packageName: string): string {\n const trimmed = packageName.trim();\n if (!trimmed) return \"\";\n const lastAtIndex = trimmed.lastIndexOf(\"@\");\n if (lastAtIndex > 0) {\n return trimmed.substring(0, lastAtIndex);\n }\n\n return trimmed;\n}\n","// JSON Schema (draft-07) for dist/powerhouse.config.json — the runtime\n// artifact emitted into the build output and fetched by the Connect SPA at\n// boot.\n//\n// A strict SUBSET of the source PowerhouseConfig schema plus two runtime-only\n// fields (schemaVersion, localPackage). Field shapes shared with the source\n// schema (PowerhousePackage, PHConnectRuntimeConfig) are imported from the\n// shared fragments module so the two schemas stay in sync by construction.\n\nimport {\n phConnectRuntimeConfigSchema,\n powerhousePackageSchema,\n} from \"@powerhousedao/shared/connect\";\n\nexport const RUNTIME_CONFIG_SCHEMA_ID =\n \"https://powerhouse.inc/schemas/powerhouse.config.json\";\n\n// GitHub-hosted schema URL. Points at the JSON artifact committed alongside\n// this TS module. Currently tracks the `main` branch — schema edits go live\n// for editors as soon as they merge. Migrate to a `schema-v<N>` tag pinned\n// to schemaVersion if/when stability across edits becomes a concern.\nexport const RUNTIME_CONFIG_SCHEMA_URL =\n \"https://raw.githubusercontent.com/powerhouse-inc/powerhouse/main/packages/builder-tools/connect-utils/runtime-config.schema.json\";\n\nexport const runtimeConfigSchema = {\n $schema: \"http://json-schema.org/draft-07/schema#\",\n $id: RUNTIME_CONFIG_SCHEMA_ID,\n title: \"Powerhouse Connect runtime configuration\",\n description:\n \"Runtime configuration loaded by Connect at boot from /powerhouse.config.json.\",\n type: \"object\",\n additionalProperties: false,\n required: [\"schemaVersion\", \"packages\", \"localPackage\"],\n properties: {\n $schema: {\n type: \"string\",\n description:\n \"Optional JSON Schema reference for editor autocomplete. Set to the GitHub-hosted schema URL.\",\n },\n schemaVersion: {\n const: 2,\n description:\n \"Schema version. Must match the SPA bundle that ships with this dist. The SPA throws on mismatch to prevent SPA/config skew.\",\n },\n packages: {\n type: \"array\",\n description:\n \"Powerhouse packages this Connect instance loads at runtime.\",\n items: powerhousePackageSchema,\n },\n packageRegistryUrl: {\n type: \"string\",\n description:\n \"Project-wide package registry endpoint. Copied verbatim from the source `powerhouse.config.json` top-level field — the SPA's Package Manager UI reads this directly.\",\n },\n localPackage: {\n description:\n \"Identity of the consumer project itself, captured at build time. null for Docker images and other generic deploys with no host project.\",\n oneOf: [\n { type: \"null\" },\n {\n type: \"object\",\n additionalProperties: false,\n required: [\"name\", \"version\"],\n properties: {\n name: { type: \"string\" },\n version: { type: \"string\" },\n },\n },\n ],\n },\n connect: phConnectRuntimeConfigSchema,\n },\n} as const;\n","import { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\n\nconst REACT_DEPS = [\n \"react\",\n \"react-dom\",\n \"react/jsx-runtime\",\n \"react/jsx-dev-runtime\",\n \"react-dom/client\",\n];\n\nconst SHIM_PATH = \"__ph/dev-react-shim/\";\nconst VITE_DEPS_PATH = \"node_modules/.vite/deps\";\n\n// Vite serves dev module URLs under the resolved `base`. Join base + path\n// while collapsing the double slash so `base: \"/\"` stays byte-identical.\nfunction withBase(base: string, p: string): string {\n return `${base}${p}`.replace(/\\/{2,}/g, \"/\");\n}\n\n/**\n * Dev-only sibling of `esmExternalRequirePlugin`. The build path externalizes\n * React via Rolldown so an importmap hands the same React instance to both\n * Connect and CDN-served editor packages. Rolldown plugins don't run in\n * `vite createServer`, and Vite's pre-bundled CJS deps only expose a `default`\n * export — so a CDN editor that does `import { lazy } from \"react\"` would\n * fail with \"no named export 'lazy'\".\n *\n * This plugin:\n * 1. Forces React into `optimizeDeps.include` so the optimizer always knows\n * about it.\n * 2. Serves a shim per React module at a stable URL. Each shim imports\n * from Vite's live pre-bundled URL (sharing Connect's React instance)\n * and re-exports React's named members so editors importing\n * `{ lazy }`, `{ jsx }`, etc. work.\n * 3. Rewrites the page importmap to point at those shim URLs.\n */\nexport function devReactImportmapPlugin(): Plugin {\n let namedExports = new Map<string, string[]>();\n let base = \"/\";\n\n return {\n name: \"ph-dev-react-importmap\",\n apply: \"serve\",\n config: () => ({ optimizeDeps: { include: REACT_DEPS } }),\n configResolved(config) {\n base = config.base;\n },\n configureServer(server) {\n // Resolve React's named exports from the consumer project so we don't\n // hardcode lists that drift across React versions.\n const requireFromRoot = createRequire(\n path.join(server.config.root, \"package.json\"),\n );\n namedExports = new Map(\n REACT_DEPS.map((id) => {\n try {\n const mod = requireFromRoot(id) as Record<string, unknown>;\n return [id, Object.keys(mod).filter((k) => k !== \"default\")];\n } catch {\n return [id, []];\n }\n }),\n );\n\n // Match the base-prefixed shim URL, and the bare path for robustness.\n const shimPrefixes = [withBase(base, SHIM_PATH), `/${SHIM_PATH}`];\n server.middlewares.use((req, res, next) => {\n const prefix = shimPrefixes.find((p) => req.url?.startsWith(p));\n if (!prefix) return next();\n const id = req.url!.slice(prefix.length).replace(/\\.js(\\?.*)?$/, \"\");\n if (!REACT_DEPS.includes(id)) return next();\n\n const optimizer = server.environments.client.depsOptimizer;\n const info =\n optimizer?.metadata.optimized[id] ??\n optimizer?.metadata.discovered[id];\n if (!optimizer || !info) {\n res.statusCode = 404;\n res.end();\n return;\n }\n\n const browserHash = info.browserHash ?? optimizer.metadata.browserHash;\n const depUrl = `${withBase(base, VITE_DEPS_PATH)}/${path.basename(info.file)}?v=${browserHash}`;\n const names = namedExports.get(id) ?? [];\n\n res.setHeader(\"Content-Type\", \"application/javascript\");\n res.end(\n `import * as M from ${JSON.stringify(depUrl)};\\n` +\n `const ns = M.default ?? M;\\n` +\n `export default ns;\\n` +\n (names.length\n ? `export const { ${names.join(\", \")} } = ns;\\n`\n : \"\"),\n );\n });\n },\n transformIndexHtml: {\n order: \"post\",\n handler(html, ctx) {\n const browserHash =\n ctx.server?.environments.client.depsOptimizer?.metadata.browserHash;\n if (!browserHash) return;\n const shimPrefix = withBase(base, SHIM_PATH);\n const imports = Object.fromEntries(\n REACT_DEPS.map((id) => [\n id,\n `${shimPrefix}${id}.js?v=${browserHash}`,\n ]),\n );\n return html.replace(\n /<script type=\"importmap\">[\\s\\S]*?<\\/script>/,\n `<script type=\"importmap\">${JSON.stringify({ imports }, null, 2)}</script>`,\n );\n },\n },\n };\n}\n","import { readFileSync } from \"node:fs\";\nimport type { Connect, Plugin } from \"vite\";\n\n/**\n * Vite plugin to serve the Connect favicon (icon.ico) from the connect package.\n * This ensures the favicon is available in development and included in the production build.\n */\nexport function connectFaviconPlugin(): Plugin {\n return {\n name: \"copy-connect-favicon\",\n configureServer(server) {\n // Vite rewrites the favicon link against `base`, so serve the\n // base-prefixed path. Keep the bare path for robustness.\n const base = server.config.base;\n const faviconPath = `${base}icon.ico`.replace(/\\/{2,}/g, \"/\");\n const handler: Connect.NextHandleFunction = (_req, res, next) => {\n server.pluginContainer\n .resolveId(\"@powerhousedao/connect/assets/icon.ico\")\n .then((resolved) => {\n if (!resolved) return next();\n res.setHeader(\"Content-Type\", \"image/x-icon\");\n res.end(readFileSync(resolved.id));\n })\n .catch(() => next());\n };\n // Mount on the exact route(s) so the handler only runs for icon.ico.\n // Connect strips the mount prefix before matching, so mounting on\n // \"/icon.ico\" matches that path exactly.\n const paths = new Set([faviconPath, \"/icon.ico\"]);\n for (const path of paths) {\n server.middlewares.use(path, handler);\n }\n },\n async generateBundle(_options, bundle) {\n try {\n if (\"icon.ico\" in bundle) return;\n const resolved = await this.resolve(\n \"@powerhousedao/connect/assets/icon.ico\",\n );\n if (!resolved) return;\n this.emitFile({\n type: \"asset\",\n fileName: \"icon.ico\",\n source: readFileSync(resolved.id),\n });\n } catch {\n // connect package not found, skip favicon\n }\n },\n };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\n\nexport type PhBundledPackagesPluginOptions = {\n /**\n * Package names (with `provider: \"local\"` in powerhouse.config.json)\n * that should be bundled into Connect at build time. Each must be\n * resolvable from node_modules.\n */\n packages: string[];\n /** Project root used to read each bundled package's package.json version. */\n projectRoot?: string;\n};\n\nconst VIRTUAL_ID = \"ph-bundled-packages-virtual\";\nconst RESOLVED_VIRTUAL_ID = \"\\0virtual:\" + VIRTUAL_ID;\n\nfunction readBundledPackageVersion(\n projectRoot: string,\n name: string,\n): string | undefined {\n try {\n const raw = fs.readFileSync(\n path.join(projectRoot, \"node_modules\", name, \"package.json\"),\n \"utf-8\",\n );\n const pkg = JSON.parse(raw) as { version?: unknown };\n return typeof pkg.version === \"string\" ? pkg.version : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction makeRegisterModule(packages: string[], projectRoot: string): string {\n if (packages.length === 0) {\n return \"export default () => {};\\n\";\n }\n const imports: string[] = [];\n const calls: string[] = [];\n\n packages.forEach((name, i) => {\n const moduleName = `pkg${i}`;\n const version = readBundledPackageVersion(projectRoot, name);\n imports.push(`import * as ${moduleName} from ${JSON.stringify(name)};`);\n imports.push(`import ${JSON.stringify(`${name}/style.css`)};`);\n calls.push(\n ` pm.addLocalPackage(${JSON.stringify(name)}, ${moduleName}, ${JSON.stringify(version)});`,\n );\n });\n\n return `${imports.join(\"\\n\")}\\n\\nexport default function register(pm) {\\n${calls.join(\"\\n\")}\\n};\\n`;\n}\n\n/**\n * Emits a virtual module `ph-bundled-packages-virtual` whose default export\n * is a `register(packageManager)` function. When called at runtime (from\n * Connect's bootstrap), it registers each bundled package with the package\n * manager the same way Common/Vetra are registered — meaning they work\n * offline without the registry being reachable.\n *\n * When the list is empty, the module exports a no-op function so Connect's\n * bootstrap code can always import it unconditionally.\n */\nexport function phBundledPackagesPlugin(\n options: PhBundledPackagesPluginOptions,\n): Plugin {\n const projectRoot = options.projectRoot ?? process.cwd();\n const moduleSource = makeRegisterModule(options.packages, projectRoot);\n\n return {\n name: \"vite-plugin-ph-bundled-packages\",\n enforce: \"pre\",\n resolveId(id) {\n if (id === VIRTUAL_ID) return RESOLVED_VIRTUAL_ID;\n },\n load(id) {\n if (id === RESOLVED_VIRTUAL_ID) return moduleSource;\n },\n };\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { Plugin } from \"vite\";\nimport type { PowerhousePackage } from \"@powerhousedao/config\";\nimport type { PHConnectRuntimeConfig } from \"@powerhousedao/shared/clis\";\nimport {\n buildRuntimeConfig,\n DEFAULT_CONNECT_CONFIG,\n deepMerge,\n} from \"@powerhousedao/shared/connect\";\nimport { RUNTIME_CONFIG_SCHEMA_URL } from \"../runtime-config-schema.js\";\n\nexport type PhConfigPluginOptions = {\n packages: PowerhousePackage[];\n projectRoot?: string;\n connect?: PHConnectRuntimeConfig;\n /**\n * Project-wide package registry URL — the effective value (CLI override\n * `??` source) the caller has already resolved. Copied verbatim into the\n * emitted runtime config (no namespace change); the SPA reads\n * `runtimeConfig.packageRegistryUrl` directly.\n */\n packageRegistryUrl?: string;\n /**\n * CLI-supplied connect override (final merge layer, beats source).\n * Forwarded from `ph connect build`'s `--json` + individual `--flag` parsing.\n * See clis/ph-cli/src/utils/cli-connect-override.ts.\n */\n cliConnectOverride?: PHConnectRuntimeConfig;\n};\n\nfunction readProjectPackageInfo(\n projectRoot: string | undefined,\n): { name: string; version: string } | null {\n if (!projectRoot) return null;\n try {\n const raw = fs.readFileSync(\n path.join(projectRoot, \"package.json\"),\n \"utf-8\",\n );\n const pkg = JSON.parse(raw) as { name?: unknown; version?: unknown };\n if (typeof pkg.name !== \"string\" || typeof pkg.version !== \"string\") {\n return null;\n }\n return { name: pkg.name, version: pkg.version };\n } catch {\n return null;\n }\n}\n\nexport function phConfigPlugin(options: PhConfigPluginOptions): Plugin {\n const projectRoot = options.projectRoot ?? process.cwd();\n const localPackage = readProjectPackageInfo(projectRoot);\n\n // Precedence ladder (lowest → highest) for the emitted connect.* block:\n // DEFAULT_CONNECT_CONFIG (base — fills in any field nothing else supplied)\n // < source.connect (user's hand-edited powerhouse.config.json)\n // < cliConnectOverride (`ph connect build --json` + individual flags)\n //\n // Env vars are NOT a layer in this ladder. The Connect SPA's runtime\n // configuration is exclusively set via `powerhouse.config.json` or CLI\n // overrides (`ph connect build --<field>` / `ph connect config --<field>`).\n const sourceConnect = options.connect ?? {};\n const withDefaults = deepMerge(DEFAULT_CONNECT_CONFIG, sourceConnect);\n const mergedConnect = options.cliConnectOverride\n ? deepMerge(withDefaults, options.cliConnectOverride)\n : withDefaults;\n const source = {\n packages: options.packages,\n packageRegistryUrl: options.packageRegistryUrl,\n connect: mergedConnect,\n };\n\n const runtimeConfig = buildRuntimeConfig(source, localPackage);\n const content = JSON.stringify(\n { $schema: RUNTIME_CONFIG_SCHEMA_URL, ...runtimeConfig },\n null,\n 2,\n );\n\n return {\n name: \"vite-plugin-ph-config\",\n configureServer(server) {\n server.middlewares.use((req, res, next) => {\n if (req.url?.endsWith(\"/powerhouse.config.json\")) {\n res.setHeader(\"Content-Type\", \"application/json\");\n res.setHeader(\"Cache-Control\", \"no-cache\");\n res.end(content);\n return;\n }\n next();\n });\n },\n hotUpdate: {\n order: \"pre\",\n handler(ctx) {\n return ctx.modules.filter((mod) => {\n if (mod.importers.size > 1) {\n return true;\n }\n const importer = mod.importers.values().next();\n return !importer.value?.file?.endsWith(\".css\");\n });\n },\n },\n generateBundle() {\n this.emitFile({\n type: \"asset\",\n fileName: \"powerhouse.config.json\",\n source: content,\n });\n },\n };\n}\n","import type { PowerhouseConfig } from \"@powerhousedao/config\";\nimport { getConfig } from \"@powerhousedao/config/node\";\nimport {\n loadConnectEnv,\n normalizeBasePath,\n setConnectEnv,\n} from \"@powerhousedao/shared/connect\";\nimport tailwind from \"@tailwindcss/vite\";\nimport react from \"@vitejs/plugin-react\";\nimport { realpathSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport {\n createLogger,\n esmExternalRequirePlugin,\n loadEnv,\n searchForWorkspaceRoot,\n type HtmlTagDescriptor,\n type InlineConfig,\n type PluginOption,\n} from \"vite\";\nimport { createHtmlPlugin } from \"vite-plugin-html\";\nimport type { IConnectOptions } from \"./types.js\";\nimport { devReactImportmapPlugin } from \"./vite-plugins/dev-external-react.js\";\nimport { connectFaviconPlugin } from \"./vite-plugins/favicon.js\";\nimport { phBundledPackagesPlugin } from \"./vite-plugins/ph-bundled-packages.js\";\nimport { phConfigPlugin } from \"./vite-plugins/ph-config.js\";\n\nconst REACT_VERSION = \"19.2.0\";\n\n// Importmap injected into Connect's HTML in production builds. The build\n// pipeline externalizes react/react-dom via Rolldown's\n// `esmExternalRequirePlugin` (see below), so the browser resolves bare\n// `react` imports through this map → CDN editor packages and Connect share\n// the same React instance via esm.sh. In dev, `devReactImportmapPlugin`\n// rewrites this map to point at Vite's pre-bundled React instead.\nconst REACT_IMPORTMAP_IMPORTS: Record<string, string> = {\n react: `https://esm.sh/react@${REACT_VERSION}`,\n \"react/\": `https://esm.sh/react@${REACT_VERSION}/`,\n \"react-dom\": `https://esm.sh/react-dom@${REACT_VERSION}`,\n \"react-dom/\": `https://esm.sh/react-dom@${REACT_VERSION}/`,\n};\n\nexport function getConnectHtmlTags(\n options: {\n registryUrl?: string | null;\n injectTo?: HtmlTagDescriptor[\"injectTo\"];\n } = {},\n) {\n const { registryUrl, injectTo = \"head\" } = options;\n return [\n {\n tag: \"meta\",\n attrs: {\n \"http-equiv\": \"Content-Security-Policy\",\n content: `script-src 'self' 'unsafe-inline' 'unsafe-eval' https://esm.sh${registryUrl ? \" \" + registryUrl : \"\"}; worker-src 'self' blob:; object-src 'none'; base-uri 'self';`,\n },\n injectTo,\n },\n {\n tag: \"meta\",\n attrs: {\n property: \"og:title\",\n content: \"Connect\",\n },\n injectTo,\n },\n {\n tag: \"meta\",\n attrs: {\n property: \"og:type\",\n content: \"website\",\n },\n injectTo,\n },\n {\n tag: \"meta\",\n attrs: {\n property: \"og:url\",\n content: \"https://apps.powerhouse.io/powerhouse/connect/\",\n },\n injectTo,\n },\n {\n tag: \"meta\",\n attrs: {\n property: \"og:description\",\n content:\n \"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.\",\n },\n injectTo,\n },\n {\n tag: \"meta\",\n attrs: {\n property: \"og:image\",\n content:\n \"https://cf-ipfs.com/ipfs/bafkreigrmclndf2jpbolaq22535q2sw5t44uad3az3dpvkzrnt4lpjt63e\",\n },\n injectTo,\n },\n {\n tag: \"meta\",\n attrs: {\n name: \"twitter:card\",\n content: \"summary_large_image\",\n },\n injectTo,\n },\n {\n tag: \"meta\",\n attrs: {\n name: \"twitter:image\",\n content:\n \"https://cf-ipfs.com/ipfs/bafkreigrmclndf2jpbolaq22535q2sw5t44uad3az3dpvkzrnt4lpjt63e\",\n },\n injectTo,\n },\n {\n tag: \"meta\",\n attrs: {\n name: \"twitter:title\",\n content: \"Connect\",\n },\n injectTo,\n },\n {\n tag: \"meta\",\n attrs: {\n name: \"twitter:description\",\n content:\n \"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.\",\n },\n injectTo,\n },\n ] as const satisfies HtmlTagDescriptor[];\n}\n\nfunction viteLogger({\n silence,\n}: {\n silence?: { warnings?: string[]; errors?: string[] };\n}) {\n const logger = createLogger();\n const loggerWarn = logger.warn.bind(logger);\n const loggerError = logger.error.bind(logger);\n\n logger.warn = (msg, options) => {\n if (silence?.warnings?.some((warning) => msg.includes(warning))) {\n return;\n }\n loggerWarn(msg, options);\n };\n\n logger.error = (msg, options) => {\n if (silence?.errors?.some((error) => msg.includes(error))) {\n return;\n }\n loggerError(msg, options);\n };\n\n return logger;\n}\n\nfunction parsePackagesEnvOverride(phPackagesStr: string) {\n return phPackagesStr\n .split(\",\")\n .map((s) => s.trim())\n .filter(Boolean)\n .map((entry) => {\n const lastAt = entry.lastIndexOf(\"@\");\n if (lastAt > 0) {\n return {\n packageName: entry.slice(0, lastAt),\n version: entry.slice(lastAt + 1),\n provider: \"registry\" as const,\n };\n }\n return { packageName: entry, provider: \"registry\" as const };\n });\n}\n\nfunction getLocalPackageNamesFromPowerhouseConfig({\n packages,\n}: PowerhouseConfig) {\n if (!packages) return [];\n return packages\n .filter((p) => p.provider === \"local\")\n .map((p) => p.packageName);\n}\n\nexport function getConnectBaseViteConfig(options: IConnectOptions) {\n const mode = options.mode;\n const envDir = options.envDir ?? options.dirname;\n const fileEnv = loadEnv(mode, envDir, \"PH_\");\n\n // Load and validate environment with priority: process.env > fileEnv > defaults\n const env = loadConnectEnv({\n processEnv: process.env,\n fileEnv,\n });\n\n // set the resolved env to process.env so it's loaded by vite\n setConnectEnv(env);\n\n // Source config is always the project-root powerhouse.config.json.\n const phConfigPath = join(options.dirname, \"powerhouse.config.json\");\n\n const phConfig = options.powerhouseConfig ?? getConfig(phConfigPath);\n\n const packagesFromConfig = phConfig.packages ?? [];\n const localPackagesFromConfig =\n getLocalPackageNamesFromPowerhouseConfig(phConfig);\n const phPackagesStr = env.PH_PACKAGES;\n const envPhPackages = phPackagesStr\n ? parsePackagesEnvOverride(phPackagesStr)\n : undefined;\n\n const phPackages = envPhPackages ?? packagesFromConfig;\n\n // Precedence (highest → lowest): `ph connect build --packages-registry`\n // CLI override > source-config `packageRegistryUrl`. The resolved value\n // flows both into the CSP header (script-src allowance for the registry\n // CDN) and into the emitted runtime config so the SPA reads the same\n // value.\n const phPackageRegistryUrl =\n options.cliPackageRegistryUrl ?? phConfig.packageRegistryUrl ?? null;\n\n // Base path is a runtime-config field (connect.app.basePath), not an env\n // var. Resolve it with the same precedence as the rest of the connect\n // config: CLI override > source powerhouse.config.json.\n const connectBasePath =\n options.cliConnectOverride?.app?.basePath ??\n phConfig.connect?.app?.basePath;\n\n const authToken = env.PH_SENTRY_AUTH_TOKEN;\n const org = env.PH_SENTRY_ORG;\n const project = env.PH_SENTRY_PROJECT;\n // Release tag derived from the workspace version so it matches the\n // sourcemap upload tag CI uses.\n const release =\n process.env.WORKSPACE_VERSION ??\n process.env.npm_package_version ??\n env.PH_CONNECT_VERSION;\n const uploadSentrySourcemaps = authToken && org && project;\n\n const connectHtmlTags = getConnectHtmlTags({\n registryUrl: phPackageRegistryUrl,\n });\n\n const plugins: PluginOption[] = [\n tailwind(),\n react(),\n createHtmlPlugin({\n minify: false,\n inject: {\n tags: [\n ...connectHtmlTags,\n {\n tag: \"script\",\n attrs: { type: \"importmap\" },\n children: JSON.stringify(\n { imports: REACT_IMPORTMAP_IMPORTS },\n null,\n 2,\n ),\n injectTo: \"head-prepend\",\n },\n ],\n },\n }),\n ] as const;\n\n if (uploadSentrySourcemaps) {\n plugins.push(\n import(\"@sentry/vite-plugin\").then(({ sentryVitePlugin }) =>\n sentryVitePlugin({\n release: {\n name: release ?? \"unknown\",\n inject: false, // prevent it from injecting the release id in the service worker code, this is done in 'src/app/sentry.ts' instead\n },\n authToken,\n org,\n project,\n bundleSizeOptimizations: {\n excludeDebugStatements: true,\n },\n reactComponentAnnotation: {\n enabled: true,\n },\n }),\n ) as PluginOption,\n );\n }\n\n // hide warnings unless LOG_LEVEL is set to debug, or the source config\n // declares connect.app.logLevel = \"debug\"\n const isDebug =\n process.env.LOG_LEVEL === \"debug\" ||\n phConfig.connect?.app?.logLevel === \"debug\";\n const customLogger = isDebug\n ? undefined\n : viteLogger({\n silence: {\n warnings: [\n \"@import must precede all other statements (besides @charset or empty @layer)\", // tailwindcss error when importing font file\n ],\n errors: [\"Unterminated string literal\"],\n },\n });\n\n const reactExternal = [\n \"react\",\n \"react-dom\",\n \"react/jsx-runtime\",\n \"react-dom/client\",\n ];\n\n // pnpm `link:` deps (e.g. a downstream project linking @powerhousedao/*\n // packages from a sibling monorepo checkout) live outside Vite's\n // auto-detected workspace root. Their `node_modules/.pnpm/...` assets\n // then 403 through `/@fs/`, returning a 760-byte HTML body where the\n // binary should be — which breaks PGlite at startup with \"Invalid FS\n // bundle size: 760 !== 4939170\". Resolve key linked packages back to\n // their real workspace roots and allow Vite to serve from there.\n const linkedRoots = [\n \"@powerhousedao/reactor-browser\",\n \"@powerhousedao/connect\",\n \"@electric-sql/pglite\",\n ]\n .map((pkg) => {\n try {\n return searchForWorkspaceRoot(\n realpathSync(join(options.dirname, \"node_modules\", pkg)),\n );\n } catch {\n return null;\n }\n })\n .filter((p): p is string => p !== null);\n\n const config: InlineConfig = {\n configFile: false,\n mode,\n // Prefix served/built asset URLs so Connect can run under a path prefix\n // (reverse proxy). Mirrors the client router basename; normalize so a bare\n // `app` or `/app` becomes `/app/` and matches the router.\n base: connectBasePath ? normalizeBasePath(connectBasePath) : undefined,\n server: {\n watch: {\n ignored: [\"**/backup-documents/**\", \"**/.ph/**\"],\n },\n fs: {\n allow: [searchForWorkspaceRoot(options.dirname), ...linkedRoots],\n },\n },\n resolve: {\n dedupe: [\"react\", \"react-dom\"],\n tsconfigPaths: true,\n },\n define: {\n PH_CONNECT_SENTRY_RELEASE: JSON.stringify(release || \"unknown\"),\n },\n customLogger,\n envPrefix: [\"PH_CONNECT_\"],\n optimizeDeps: {\n include: [\n \"document-model\",\n \"zod\",\n \"@powerhousedao/design-system/connect\",\n \"@powerhousedao/reactor-browser\",\n \"@powerhousedao/document-engineering\",\n ],\n exclude: [\"@electric-sql/pglite\", \"@electric-sql/pglite-tools\"],\n },\n plugins: [\n // phConfigPlugin must be registered before tailwind so its hotUpdate\n // hook runs first and can suppress HMR updates for codegen-generated\n // files, preventing tailwind from triggering full page reloads.\n phConfigPlugin({\n packages: phPackages,\n projectRoot: options.dirname,\n connect: phConfig.connect,\n packageRegistryUrl: phPackageRegistryUrl ?? undefined,\n cliConnectOverride: options.cliConnectOverride,\n }),\n phBundledPackagesPlugin({\n packages: localPackagesFromConfig,\n projectRoot: options.dirname,\n }),\n // Dev-only: rewrite the importmap so it points at Vite's pre-bundled\n // React (the same URL Connect's own modules resolve to). Without this,\n // CDN editors load React from esm.sh while Connect uses Vite's local\n // copy → two React instances → useSyncExternalStore crash. The build\n // path stays untouched; `esmExternalRequirePlugin` below still owns it.\n devReactImportmapPlugin(),\n ...plugins,\n // Externalize React so both Connect and dynamically loaded registry\n // packages share the same React instance via the import map in index.html.\n // Without this, Vite bundles React into Connect's chunks while registry\n // packages resolve React from the import map (esm.sh), creating two\n // separate React instances that don't share context/state.\n //\n // In Vite 8 (Rolldown), require() calls for external modules are preserved\n // as-is, which fails in browsers. esmExternalRequirePlugin handles both\n // externalization AND converting require() to import statements.\n // NOTE: Do NOT also list these in build.rolldownOptions.external — overlapping\n // entries prevent the plugin from transforming require() calls.\n esmExternalRequirePlugin({ external: reactExternal }),\n connectFaviconPlugin(),\n ],\n wor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EACjE;GACF;EACD,SAAS;GACP,QAAQ,CAAC,SAAS,YAAY;GAC9B,eAAe;GAChB;EACD,QAAQ,EACN,2BAA2B,KAAK,UAAU,WAAW,UAAU,EAChE;EACD;EACA,WAAW,CAAC,cAAc;EAC1B,cAAc;GACZ,SAAS;IACP;IACA;IACA;IACA;IACA;IACD;GACD,SAAS,CAAC,wBAAwB,6BAA6B;GAChE;EACD,SAAS;GAIP,eAAe;IACb,UAAU;IACV,aAAa,QAAQ;IACrB,SAAS,SAAS;IAClB,oBAAoB,wBAAwB,KAAA;IAC5C,oBAAoB,QAAQ;IAC7B,CAAC;GACF,wBAAwB;IACtB,UAAU;IACV,aAAa,QAAQ;IACtB,CAAC;GAMF,yBAAyB;GACzB,GAAG;GAYH,yBAAyB,EAAE,UAAU,eAAe,CAAC;GACrD,sBAAsB;GACvB;EACD,QAAQ,EACN,QAAQ,MACT;EACD,OAAO,EACL,WAAW,MACZ;EACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/builder-tools",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0-dev.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"publishConfig": {
|
|
@@ -26,14 +26,15 @@
|
|
|
26
26
|
"@vitejs/plugin-react": "6.0.1",
|
|
27
27
|
"vite": "8.0.8",
|
|
28
28
|
"vite-plugin-html": "3.2.2",
|
|
29
|
-
"@powerhousedao/config": "6.
|
|
30
|
-
"@powerhousedao/shared": "6.
|
|
31
|
-
"document-model": "6.
|
|
29
|
+
"@powerhousedao/config": "6.2.0-dev.1",
|
|
30
|
+
"@powerhousedao/shared": "6.2.0-dev.1",
|
|
31
|
+
"document-model": "6.2.0-dev.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@sentry/vite-plugin": "^4.3.0",
|
|
35
35
|
"tsdown": "0.21.1",
|
|
36
36
|
"tsx": "4.21.0",
|
|
37
|
+
"vitest": "4.1.1",
|
|
37
38
|
"zod": "4.3.6"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
"scripts": {
|
|
48
49
|
"tsc": "tsc",
|
|
49
50
|
"lint": "eslint",
|
|
50
|
-
"build": "tsdown"
|
|
51
|
+
"build": "tsdown",
|
|
52
|
+
"test": "vitest --run"
|
|
51
53
|
}
|
|
52
54
|
}
|