@powerhousedao/shared 6.2.3-dev.50 → 6.2.3-dev.52
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/clis/args/common-BXabdhiO.mjs.map +1 -1
- package/dist/clis/{build-config-CR5lvv_A.mjs → build-config-HbYUSZS1.mjs} +26 -5
- package/dist/clis/build-config-HbYUSZS1.mjs.map +1 -0
- package/dist/clis/build-config.d.mts +6 -0
- package/dist/clis/build-config.d.mts.map +1 -1
- package/dist/clis/build-config.mjs +1 -1
- package/dist/clis/build-pieces.d.mts +62 -2
- package/dist/clis/build-pieces.d.mts.map +1 -1
- package/dist/clis/build-pieces.mjs +189 -11
- package/dist/clis/build-pieces.mjs.map +1 -1
- package/dist/clis/constants.d.mts +2 -2
- package/dist/clis/constants.mjs +13 -2
- package/dist/clis/constants.mjs.map +1 -1
- package/dist/clis/index.d.mts +20 -1
- package/dist/clis/index.d.mts.map +1 -1
- package/dist/clis/index.mjs +355 -288
- package/dist/clis/index.mjs.map +1 -1
- package/dist/clis/{types-Cc_rB0Yx.d.mts → types-BZBiwi6I.d.mts} +17 -3
- package/dist/clis/types-BZBiwi6I.d.mts.map +1 -0
- package/dist/{config-loader-CXhzL512.js → config-loader-DpeoExZO.js} +3 -2
- package/dist/config-loader-DpeoExZO.js.map +1 -0
- package/dist/connect/config-loader.d.ts +1 -1
- package/dist/connect/config-loader.js +1 -1
- package/dist/connect/index.d.ts +6 -1
- package/dist/connect/index.d.ts.map +1 -1
- package/dist/connect/index.js +6 -1
- package/dist/connect/index.js.map +1 -1
- package/dist/{constants-C2K-m7pp.d.ts → constants-C6ket9Bn.d.ts} +2 -2
- package/dist/constants-C6ket9Bn.d.ts.map +1 -0
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/document-drive/index.d.ts +3 -3
- package/dist/document-model/errors.d.ts +1 -1
- package/dist/document-model/index.d.ts +1 -1
- package/dist/document-model/index.js +1 -0
- package/dist/document-model/index.js.map +1 -1
- package/dist/{index-BhqNGLu9.d.ts → index-C3fD6cad.d.ts} +2 -2
- package/dist/{index-BhqNGLu9.d.ts.map → index-C3fD6cad.d.ts.map} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/processors/index.d.ts +1 -1
- package/dist/registry/index.d.ts +2 -2
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/manifest-slim.d.ts +2 -2
- package/dist/{types-BTfv_ZzS.d.ts → types-CywupGpk.d.ts} +2 -2
- package/dist/{types-BTfv_ZzS.d.ts.map → types-CywupGpk.d.ts.map} +1 -1
- package/dist/{types-BRJfX8ck.d.ts → types-DDH6v2BE.d.ts} +8 -1
- package/dist/{types-BRJfX8ck.d.ts.map → types-DDH6v2BE.d.ts.map} +1 -1
- package/package.json +1 -1
- package/dist/clis/build-config-CR5lvv_A.mjs.map +0 -1
- package/dist/clis/types-Cc_rB0Yx.d.mts.map +0 -1
- package/dist/config-loader-CXhzL512.js.map +0 -1
- package/dist/constants-C2K-m7pp.d.ts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-config-CR5lvv_A.mjs","names":[],"sources":["../../connect/shared-deps.ts","../../clis/build-config.mts"],"sourcesContent":["import { satisfies, validRange } from \"semver\";\n\nexport type SharedDep = { specifier: string; package: string };\n\n/**\n * The dependency set Connect and loaded packages share via the import map.\n * `@powerhousedao/connect` is deliberately absent: it is the Connect app\n * itself (no importable exports), so there is nothing to share.\n */\nexport const SHARED_DEPS: readonly SharedDep[] = [\n { specifier: \"document-model\", package: \"document-model\" },\n {\n specifier: \"@powerhousedao/document-engineering\",\n package: \"@powerhousedao/document-engineering\",\n },\n { specifier: \"@powerhousedao/shared\", package: \"@powerhousedao/shared\" },\n {\n specifier: \"@powerhousedao/shared/registry/urls\",\n package: \"@powerhousedao/shared\",\n },\n {\n specifier: \"@powerhousedao/design-system/connect\",\n package: \"@powerhousedao/design-system\",\n },\n {\n specifier: \"@powerhousedao/reactor-browser\",\n package: \"@powerhousedao/reactor-browser\",\n },\n // Connect already vendors zod (it is in DEFAULT_VENDOR_INCLUDE, so the\n // import map publishes an entry for it) and every generated project already\n // declares it as a peerDependency -- yet it was missing from this set, so\n // each package inlined a private copy anyway. It is the single biggest\n // dependency left in a minimal package.\n { specifier: \"zod\", package: \"zod\" },\n];\n\nexport const SHARED_DEP_SPECIFIERS: readonly string[] = SHARED_DEPS.map(\n (d) => d.specifier,\n);\n\n/**\n * The `@powerhousedao/shared` subpaths the production vendor bundles. The\n * bare root is deliberately absent: its type barrel references node-only\n * modules (`clis/`), which the current vite/rolldown cannot bundle for the\n * browser — vendoring the root fails the build (a pre-existing latent\n * issue). A package that imports the bare root is simply not shared; it\n * bundles its own copy.\n */\nexport const SHARED_SUBPATHS: readonly string[] = [\n \"connect\",\n \"document-model\",\n \"processors\",\n \"document-drive\",\n \"registry\",\n \"registry/urls\",\n \"registry/manifest-slim\",\n];\n\n/**\n * The specifiers a package build may safely externalize onto the host's\n * import map — i.e. the ones the vendor actually publishes an entry for.\n *\n * `@powerhousedao/shared` is narrowed to SHARED_SUBPATHS rather than taken as\n * a prefix: the bare root is never vendored (see SHARED_SUBPATHS), and\n * neither are its other subpaths (`analytics`, `constants`, `clis`, ...).\n * Externalizing those would leave a bare specifier in the package's output\n * that nothing in the import map resolves, so the package would fail to load\n * at runtime instead of simply bundling its own copy.\n */\nexport const EXTERNALIZABLE_SHARED_SPECIFIERS: readonly string[] = [\n ...new Set([\n ...SHARED_DEP_SPECIFIERS.filter((s) => s !== \"@powerhousedao/shared\"),\n ...SHARED_SUBPATHS.map((s) => `@powerhousedao/shared/${s}`),\n ]),\n];\n\n/** Split a specifier into its package name and subpath (\"\" for a root). */\nexport function parseDepSpec(spec: string): { pkg: string; sub: string } {\n if (spec.startsWith(\"@\")) {\n const parts = spec.split(\"/\");\n return { pkg: parts.slice(0, 2).join(\"/\"), sub: parts.slice(2).join(\"/\") };\n }\n const i = spec.indexOf(\"/\");\n return i === -1\n ? { pkg: spec, sub: \"\" }\n : { pkg: spec.slice(0, i), sub: spec.slice(i + 1) };\n}\n\nfunction isSharedSpecifier(spec: string, specs: readonly string[]): boolean {\n return specs.some((s) => spec === s || spec.startsWith(s + \"/\"));\n}\n\n/**\n * Return the import/export specifiers in `source` that are a shared\n * specifier (or a subpath of one), sorted. Heuristic: only statement\n * positions are scanned (`from \"x\"`, `import \"x\"`, `import(\"x\")`;\n * `export … from \"x\"` is covered by the `from` pattern), so import-like\n * text inside comments or strings can be reported too. That errs toward\n * over-reporting, which is the safe direction for the advisory build\n * warning.\n */\nexport function findSharedImports(\n source: string,\n specs: readonly string[] = SHARED_DEP_SPECIFIERS,\n): string[] {\n const found = new Set<string>();\n const patterns = [\n /\\bfrom\\s+[\"']([^\"'\\\\]+)[\"']/g,\n /\\bimport\\s+[\"']([^\"'\\\\]+)[\"']/g,\n /\\bimport\\s*\\(\\s*[\"']([^\"'\\\\]+)[\"']\\s*\\)/g,\n ];\n for (const re of patterns) {\n for (const m of source.matchAll(re)) {\n const spec = m[1];\n if (isSharedSpecifier(spec, specs)) found.add(spec);\n }\n }\n return [...found].sort();\n}\n\n/**\n * Rewrite a package source for blob import in a worker context (import maps\n * don't apply there): shared specifiers become their mapped URLs, and\n * relative (`./`, `../`) specifiers become absolute against `sourceUrl`\n * (a blob URL has no directory to resolve against). `#` subpath imports are\n * deliberately left alone: they resolve via the package's own\n * `package.json` \"imports\" field, which the rewrite cannot reproduce.\n * Returns the input unchanged when nothing matched.\n */\nexport function rewritePackageSource(\n source: string,\n sourceUrl: string,\n imports: Record<string, string>,\n): string {\n if (!Object.keys(imports).length) return source;\n const base = new URL(sourceUrl);\n const map = (spec: string): string | null => {\n const mapped = imports[spec];\n if (mapped) return mapped;\n if (spec.startsWith(\"./\") || spec.startsWith(\"../\")) {\n return new URL(spec, base).href;\n }\n return null;\n };\n let out = source;\n // The quote character is captured and reused: a source that quotes its\n // specifiers with ' would otherwise never match the replacement and be\n // left un-rewritten — silently, since the specifier still maps.\n for (const re of [\n /\\bfrom\\s+([\"'])([^\"'\\\\]+)\\1/g,\n /\\bimport\\s+([\"'])([^\"'\\\\]+)\\1/g,\n /\\bimport\\s*\\(\\s*([\"'])([^\"'\\\\]+)\\1\\s*\\)/g,\n ]) {\n out = out.replace(re, (match, quote: string, spec: string) => {\n // The match contains the quoted specifier exactly once and the\n // captured group has no quotes/backslashes ([^\"'\\\\]), so a literal\n // replace is safe.\n const mapped = map(spec);\n return mapped\n ? match.replace(`${quote}${spec}${quote}`, `${quote}${mapped}${quote}`)\n : match;\n });\n }\n return out;\n}\n\nexport type SharedDepMismatch = {\n package: string;\n required: string;\n provided: string;\n};\n\nexport type PackageDeps = {\n dependencies?: Record<string, unknown>;\n peerDependencies?: Record<string, unknown>;\n};\n\n/**\n * Compare a package's declared ranges against the host's version table.\n * `hostVersions` defines the checked set (only deps present in it are\n * checked). `*`, non-semver protocols (workspace:, file:, git:, npm:, URLs)\n * and unparseable ranges never mismatch.\n */\nexport function checkSharedDeps(\n pkgJson: PackageDeps,\n hostVersions: Record<string, string>,\n): SharedDepMismatch[] {\n const out: SharedDepMismatch[] = [];\n const entries = [\n ...Object.entries(pkgJson.dependencies ?? {}),\n ...Object.entries(pkgJson.peerDependencies ?? {}),\n ];\n for (const [dep, range] of entries) {\n const provided = hostVersions[dep];\n if (provided === undefined || typeof range !== \"string\") continue;\n if (range === \"*\" || /^[a-z]+:/i.test(range)) continue;\n if (!validRange(range)) continue;\n if (!satisfies(provided, range, { includePrerelease: true })) {\n out.push({ package: dep, required: range, provided });\n }\n }\n return out;\n}\n\nexport function formatSharedDepWarnings(\n mismatches: SharedDepMismatch[],\n): string[] {\n return mismatches.map(\n (m) =>\n `${m.package}: requires ${m.required}, Connect provides ${m.provided}`,\n );\n}\n\n/**\n * Stable filename for a local package's worker model bundle under\n * `__reactor_worker__/packages/`. Shared by the tab (URL computation via the\n * manifest) and the production prebuild (emitted entry names), so the two can\n * never drift. Scoped names flatten (`@scope/name` -> `scope__name`).\n */\nexport function workerPackageFileName(packageName: string): string {\n return `${packageName.replace(/^@/, \"\").replace(/[^\\w.-]+/g, \"__\")}.js`;\n}\n","import { esmExternalRequirePlugin } from \"rolldown/plugins\";\nimport type { InlineConfig } from \"tsdown\";\nimport {\n EXTERNALIZABLE_SHARED_SPECIFIERS,\n findSharedImports,\n} from \"../connect/shared-deps.js\";\n\nconst entry = [\n \"index.ts\",\n \"document-models/index.ts\",\n \"document-models/*/index.ts\",\n \"document-models/*/module.ts\",\n \"editors/index.ts\",\n \"editors/*/index.ts\",\n \"editors/*/module.ts\",\n \"subgraphs/index.ts\",\n \"subgraphs/*/index.ts\",\n \"processors/index.ts\",\n \"processors/*/index.ts\",\n];\n\n// ./pieces is node-only for the same reason ./reactor is browser-only: a piece\n// is loaded and run by a host process, never by the browser. Only the list of\n// pieces builds here; each piece is its own build (buildPieceBuildConfig), so\n// two pieces never share a chunk and each ships as one self-contained module.\nconst nodeEntry = [...entry, \"pieces/index.ts\"];\n\n// Where a package's pieces live, one directory per piece, as the node entry\n// glob spells it; `ph build` expands it against the project to find them.\nexport const PIECE_ENTRY_GLOB = \"pieces/*/index.ts\";\n\n// ./reactor is browser-only: the SharedWorker needs it, the node build does not.\nexport const browserEntry = [...entry, \"reactor/index.ts\"];\n\nconst alwaysBundle = [\"**\"];\n\n// React must be external so `import ... from \"react\"` stays a bare import and\n// resolves to the host's React at runtime; bundled, a chunk would carry a second\n// React. In the browser build the externals below belong to esmExternalRequirePlugin\n// alone: rolldown converts a CommonJS `require(\"react\")` into an import only for\n// externals the plugin owns, and listed in neverBundle too the top-level external\n// wins, leaving a browser bundle with a require it cannot serve. use-sync-external-store\n// under zustand, and so under @xyflow/react, is the case that found this.\nconst reactExternals = [\n \"react\",\n \"react-dom\",\n \"react/jsx-runtime\",\n \"react-dom/client\",\n];\n\nconst nodeNeverBundle = [\n // we know that we don't want connect inside connect\n \"@powerhousedao/connect\",\n // published code would never need the cli\n \"@powerhousedao/ph-cli\",\n // the reactor-api host must provide a single class identity for\n // BaseSubgraph/BaseProcessor — inlining a copy here breaks the\n // prototype-chain check the package loader uses to detect subgraphs.\n \"@powerhousedao/reactor-api\",\n // react is resolved from esm.sh\n \"react\",\n \"react-dom\",\n \"react/jsx-runtime\",\n \"react-dom/client\",\n // build tools\n \"tailwindcss\",\n \"vitest\",\n \"tsdown\",\n \"@tailwindcss/cli\",\n \"@vitejs/plugin-react\",\n // testing tools\n \"@testing-library/jest-dom\",\n \"@testing-library/react\",\n \"@testing-library/user-event\",\n // types\n \"@types/node\",\n \"@types/react\",\n \"@types/react-dom\",\n // exclude pglite wasm/data chunks\n \"@electric-sql/pglite\",\n \"@electric-sql/pglite-tools\",\n];\n\n// The node build keeps React in neverBundle: node has createRequire, so a\n// CommonJS require of an external resolves there without the plugin.\nconst browserNeverBundle = nodeNeverBundle.filter(\n (spec) => typeof spec !== \"string\" || !reactExternals.includes(spec),\n);\n\nconst copy = [{ from: \"powerhouse.manifest.json\", to: \"dist\" }];\n\nconst config = false;\nconst clean = true;\n// types are emitted via a separate tsc command\nconst dts = false;\nconst sourcemap = true;\n\n// Shared deps are externalized from every package build: the host (Connect)\n// resolves them to one bundled copy via the import map, so a package must\n// not inline its own copy (two instances of the same dep break identity\n// checks and double the download). One regexp per specifier covers the root\n// and every subpath (rolldown `external` accepts strings and regexps, not\n// function matchers, in this toolchain).\n//\n// Only the specifiers the vendor publishes are externalized — see\n// EXTERNALIZABLE_SHARED_SPECIFIERS. Externalizing one the import map has no\n// entry for would leave an unresolvable bare specifier in the output.\nconst sharedNeverBundle = EXTERNALIZABLE_SHARED_SPECIFIERS.map(\n (s) => new RegExp(`^${s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")}(/.*)?$`),\n);\n\nconst baseBrowserConfig = {\n entry: browserEntry,\n platform: \"browser\" as const,\n copy,\n config,\n clean,\n dts,\n sourcemap,\n plugins: [\n esmExternalRequirePlugin({\n external: reactExternals,\n skipDuplicateCheck: true,\n }),\n ],\n inputOptions: {\n experimental: { resolveNewUrlToAsset: true },\n },\n};\n\nexport type BrowserBuildConfigOptions = {\n /** Externalize the shared dependency set (default: true). */\n sharedDeps?: boolean;\n};\n\nexport function buildBrowserBuildConfig(\n options: BrowserBuildConfigOptions = {},\n): InlineConfig {\n const sharedDeps = options.sharedDeps ?? true;\n return {\n ...baseBrowserConfig,\n deps: {\n alwaysBundle,\n neverBundle: [\n ...browserNeverBundle,\n ...(sharedDeps ? sharedNeverBundle : []),\n ],\n },\n };\n}\n\n// Kept for existing callers: the default (shared deps externalized).\nexport const browserBuildConfig = buildBrowserBuildConfig();\n\n/**\n * Shared specs a source imports but the built output no longer references as\n * bare imports — the bundler inlined them, which is exactly what the\n * external set is meant to prevent.\n */\nexport function findBundledSharedDeps(\n importedSpecs: string[],\n outputs: readonly { path: string; content: string }[],\n): string[] {\n return importedSpecs.filter(\n (spec) =>\n !outputs.some((f) => findSharedImports(f.content, [spec]).includes(spec)),\n );\n}\n\nexport type NodeBuildConfigOptions = {\n /** Externalize the shared dependency set (default: true). */\n sharedDeps?: boolean;\n};\n\n/**\n * The node build externalizes the same shared set as the browser build, for\n * the same reason the `@powerhousedao/reactor-api` entry in `nodeNeverBundle`\n * already gives: the host provides these, and a package carrying its own copy\n * is a second class identity as well as dead weight. What differs is only how\n * the import is resolved at runtime -- Connect's import map in the browser,\n * ordinary node resolution here, which works because these are declared for\n * the consumer to provide (`document-model`, `@powerhousedao/reactor-browser`\n * and `zod` are peerDependencies of every generated project).\n */\nexport function buildNodeBuildConfig(\n options: NodeBuildConfigOptions = {},\n): InlineConfig {\n const sharedDeps = options.sharedDeps ?? true;\n return {\n entry: nodeEntry,\n deps: {\n alwaysBundle,\n neverBundle: [\n ...nodeNeverBundle,\n ...(sharedDeps ? sharedNeverBundle : []),\n ],\n },\n platform: \"node\",\n config,\n clean,\n dts,\n sourcemap,\n };\n}\n\n// Kept for existing callers: the default (shared deps externalized).\nexport const nodeBuildConfig: InlineConfig = buildNodeBuildConfig();\n\nexport type PieceBuildConfigOptions = {\n /** The piece's source entry, relative to the project: `pieces/<dir>/index.ts`. */\n entry: string;\n /** Where the piece lands: `<outDir>/node/pieces/<dir>`. */\n outDir: string;\n};\n\n/**\n * One piece, bundled whole. A piece runs in a forked worker with no\n * node_modules beside it, so nothing the piece imports can be left to the\n * host: the framework, its dependencies and the shared set that every other\n * module kind externalizes are all inlined here, and only node built-ins stay\n * external. Code splitting is off for the same reason, so a dynamic import is\n * inlined too and the piece directory holds exactly one module.\n */\nexport function buildPieceBuildConfig(\n options: PieceBuildConfigOptions,\n): InlineConfig {\n return {\n entry: { index: options.entry },\n outDir: options.outDir,\n platform: \"node\",\n deps: {\n alwaysBundle,\n neverBundle: [],\n // Inlining dependencies is the point here, so tsdown's hint about it\n // would only be noise on every piece.\n onlyBundle: false,\n },\n outputOptions: { codeSplitting: false },\n // The worker runs without source maps, so a map would only be shipped twice\n minify: true,\n config,\n clean,\n dts,\n sourcemap: false,\n };\n}\n"],"mappings":";;AAoCA,MAAa,wBAA2C;CA1BtD;EAAE,WAAW;EAAkB,SAAS;CAAiB;CACzD;EACE,WAAW;EACX,SAAS;CACX;CACA;EAAE,WAAW;EAAyB,SAAS;CAAwB;CACvE;EACE,WAAW;EACX,SAAS;CACX;CACA;EACE,WAAW;EACX,SAAS;CACX;CACA;EACE,WAAW;EACX,SAAS;CACX;CAMA;EAAE,WAAW;EAAO,SAAS;CAAM;AAGmB,CAAA,CAAY,KACjE,MAAM,EAAE,SACX;;;;;;;;;AAUA,MAAa,kBAAqC;CAChD;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;;;;;AAaA,MAAa,mCAAsD,CACjE,mBAAG,IAAI,IAAI,CACT,GAAG,sBAAsB,QAAQ,MAAM,MAAM,uBAAuB,GACpE,GAAG,gBAAgB,KAAK,MAAM,yBAAyB,GAAG,CAC5D,CAAC,CACH;AAcA,SAAS,kBAAkB,MAAc,OAAmC;C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;EACV,oBAAoB;CACtB,CAAC,CACH;CACA,cAAc,EACZ,cAAc,EAAE,sBAAsB,KAAK,EAC7C;AACF;AAOA,SAAgB,wBACd,UAAqC,CAAC,GACxB;CACd,MAAM,aAAa,QAAQ,cAAc;CACzC,OAAO;EACL,GAAG;EACH,MAAM;GACJ;GACA,aAAa,CACX,GAAG,oBACH,GAAI,aAAa,oBAAoB,CAAC,CACxC;EACF;CACF;AACF;AAGA,MAAa,qBAAqB,wBAAwB;;;;;;AAO1D,SAAgB,sBACd,eACA,SACU;CACV,OAAO,cAAc,QAClB,SACC,CAAC,QAAQ,MAAM,MAAM,kBAAkB,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,CAC5E;AACF;;;;;;;;;;;AAiBA,SAAgB,qBACd,UAAkC,CAAC,GACrB;CACd,MAAM,aAAa,QAAQ,cAAc;CACzC,OAAO;EACL,OAAO;EACP,MAAM;GACJ;GACA,aAAa,CACX,GAAG,iBACH,GAAI,aAAa,oBAAoB,CAAC,CACxC;EACF;EACA,UAAU;EACV;EACA;EACA;EACA;CACF;AACF;AAGA,MAAa,kBAAgC,qBAAqB;;;;;;;;;AAiBlE,SAAgB,sBACd,SACc;CACd,OAAO;EACL,OAAO,EAAE,OAAO,QAAQ,MAAM;EAC9B,QAAQ,QAAQ;EAChB,UAAU;EACV,MAAM;GACJ;GACA,aAAa,CAAC;GAGd,YAAY;EACd;EACA,eAAe,EAAE,eAAe,MAAM;EAEtC,QAAQ;EACR;EACA;EACA;EACA,WAAW;CACb;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types-Cc_rB0Yx.d.mts","names":[],"sources":["../../clis/constants.ts","../../clis/types.ts","../../document-model/schemas.ts","../../document-model/types.ts"],"mappings":";;;;;;;cAKa;cAQA;cACA;cACA;cAEA;cAKA;cAQA;cAEA;cAEA;cAEA;cAEA;cAEA;cAEA;cAEA;cAqBA;cACA;cACA;cACA;cAEA;cAEA;cACA;cACA;cACA;cAEA;cAEA;cAEA;cAGA;cAOA;cACA;cAEA;cACA;cACA;cAQA;;aACU;aAAa;;;aACT;aAAY;;;aAC5B;aAAa;;;aACP;aAAa;;;aACrB;aAAY;;;cAKR;;aAET;aACA;aACA;;;aAKA;aACA;aACA;;;cAWS;cAUA;cAiBA;WACC;WACN;WACI;;cAGC;cAQA;WACX;aACE;aACA;aACA;;WAEF;aACE;aACA;;WAEF;aACE;aACA;aACA;;WAEF;aACE;aACA;aACA;;WAEF;aACE;aACA;aACA;;WAEF;aACE;aACA;aACA;;WAEF;aACE;aACA;aACA;;WAEF;aACE;aACA;aACA;;WAKF;aACE;aACA;;WAEF;aACE;aACA;;WAEF;WACA;;cAGW;WACX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WAEA;;cAIW;cAIA;cAcA;cAwBA;WACX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;cAGW,iBAAiB;cAuBjB,gBAAgB;;;KCxUjB,iCAAiC;KACjC,wBAAwB;KACxB,mBAAmB;KACnB,WAAW;KAOX;KAGA;EACV;EACA;EACA,WAAW;EACX;;KAGU;EACV;EACA;;KAGU;EACV;EACA;EACA;;KAGU;;EAEV;;EAEA;EACA;EACA;;EAEA;;KAGU,wBACR,8BACA;KAEQ;EACV;EACA;EACA;;KAGU;EACV,SAAS;EACT,QAAQ;;KAGE;EACV;EACA,gBAAgB;EAChB,mBAAmB;EACnB,WAAW;;KAGD;EACV;EACA;EACA;EAGA;EAKA;;KAGU;;EAEV;;KAGU;EACV;;EAEA;;KAGU;;EAEV;;EAEA;;KAGU;;EAEV;;EAEA;;EAEA;;KAGU;EACV,UAAU;EACV,QAAQ;;KAGE;EACV;EACA;EACA;;EAEA;;EAEA;;EAEA,WAAW;;KAGD;;EAEV;;EAEA;;EAEA;;KAGU;;EAEV;;EAEA;;EAEA;;EAEA;;KAGU;EACV;EACA;;;;KAKU;;EAEV;;EAEA;;EAEA;;EAEA;;KAGU;EACV,eAAe;;EAEf;;EAEA;;;;;;;;;;KAWU;EAEN;EAAgB;;KAEV;;KAQA;EACV,YAAY;EACZ,SAAS;EACT;EACA;IACE;;;IAGA;IACA;MAAe;MAAqB;;IACpC;MACE;MACA,UAAU;;;;KAKJ;EACV;EACA;EACA;EACA;;;;;;;;;KAUU;;EAEV,QAAQ;;EAER,QAAQ;EACR;;;KAIU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,QAAQ;;EAER,gBAAgB;;EAEhB;IACE;;;;;EASF;;;;;;;;;;;;KAaU;EACV,WAAW;;EAEX;;EAEA;;EAEA;;EAEA,iBAAiB;;EAEjB,2BAA2B;;KAGjB;EACV,WAAW;EACX,MAAM;EACN,KAAK;EACL,WAAW;EACX,SAAS;EACT,SAAS;EACT,SAAS;EACT,YAAY;EACZ,WAAW;EACX,UAAU;EACV,MAAM;;;KAII;;;EAGV;;EAEA;;EAEA;;KAGU;EAEV,UAAU;EACV;EACA;EACA;EACA;EACA;EACA;EAGA;EACA;EACA;IACE;IACA;MAIM;MACA;;IAEN;MACE;MACA;MACA;;;EAGJ;IACE;IACA;IACA,SAAS;;EAEX;IACE;MACE;;IAEF;;EAEF;IACE;IACA;IACA;IACA;;EAEF,WAAW;EACX;IACE;IACA;IACA;;EAIF;IACE;;EAEF;EACA,UAAU;;;;cC6eC,gBAAc,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiBzB,EAAA,KAAA;;;KC+0BU,WAAW,EAAE,aAAa"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader-CXhzL512.js","names":[],"sources":["../connect/runtime-config.ts","../connect/config-loader.ts"],"sourcesContent":["import type {\n PHConnectRuntimeConfig,\n PowerhouseConfig,\n PowerhousePackage,\n} from \"../clis/types.js\";\n\nexport type RuntimePowerhouseConfig = {\n schemaVersion: 2;\n packages: PowerhousePackage[];\n packageRegistryUrl?: string;\n localPackage: { name: string; version: string } | null;\n connect: PHConnectRuntimeConfig;\n};\n\n/** Defaults for every field Connect reads at runtime, merged into the\n * `connect.*` block at boot; also the dist emitter's and the scaffold's base. */\nexport const DEFAULT_CONNECT_CONFIG: PHConnectRuntimeConfig = {\n branding: {\n appName: \"Powerhouse Connect\",\n homeBackground: null,\n },\n app: {\n logLevel: \"info\",\n basePath: \"/\",\n offline: true,\n studioMode: false,\n },\n ai: {\n assistantEnabled: false,\n },\n packages: {\n externalEnabled: true,\n liveReload: false,\n },\n drives: {\n allowAddDrive: true,\n defaultDrives: [],\n sections: {\n remote: { enabled: true, allowAdd: true, allowDelete: true },\n local: { enabled: true, allowAdd: true, allowDelete: true },\n },\n },\n renown: {\n url: \"https://www.renown.id\",\n networkId: \"eip155\",\n chainId: 1,\n },\n sentry: {\n // `dsn: null` is the disabled-Sentry state — the SPA never loads the\n // Sentry SDK chunk. Override via `ph connect config --sentry-dsn ...`\n // or by including `connect.sentry.dsn` in PH_CONNECT_CONFIG_JSON.\n dsn: null,\n env: \"dev\",\n tracing: false,\n },\n openPanel: {\n // An empty `clientId` keeps OpenPanel disabled. Enable it per deploy by\n // including `connect.openPanel.clientId` in PH_CONNECT_CONFIG_JSON.\n // `apiUrl` has no default: unset means OpenPanel's hosted API.\n clientId: \"\",\n trackUiEvents: true,\n trackOperations: true,\n },\n instance: {\n namespace: null,\n reactorWorker: false,\n },\n reactor: {\n featureFlags: {\n documentDecisions: false,\n authEnforcement: false,\n authGroups: false,\n authConditions: false,\n },\n createSignaturePolicy: \"v2-required\",\n unsupportedStoredDocuments: \"refuse\",\n },\n};\n\nexport function buildRuntimeConfig(\n source: Pick<PowerhouseConfig, \"packages\" | \"connect\" | \"packageRegistryUrl\">,\n projectInfo: { name: string; version: string } | null,\n): RuntimePowerhouseConfig {\n const result: RuntimePowerhouseConfig = {\n schemaVersion: 2,\n packages: source.packages ?? [],\n localPackage: projectInfo,\n connect: source.connect ?? {},\n };\n if (\n typeof source.packageRegistryUrl === \"string\" &&\n source.packageRegistryUrl !== \"\"\n ) {\n result.packageRegistryUrl = source.packageRegistryUrl;\n }\n return result;\n}\n","// Environment-neutral config loader. Wraps a `ConfigAdapter` (the IO layer)\n// with in-process caching and deep-merge-with-defaults reads.\n//\n// No validation. The loader trusts that whatever bytes the adapter returns\n// can be merged into the default Connect config; missing or partial fields\n// fall back to DEFAULT_CONNECT_CONFIG, so the SPA always sees a complete\n// `connect.*` block.\n//\n// Top-level fields outside `connect.*` (e.g. `studio.port` in the source\n// powerhouse.config.json) pass through untouched on both read and write.\n// They're not Connect's concern, but a write-back round-trip preserves\n// them so editing tools don't accidentally drop them.\n\nimport { isPlainObject } from \"remeda\";\nimport type {\n PHConnectRuntimeConfig,\n PowerhouseConfig,\n} from \"../clis/types.js\";\nimport { DEFAULT_CONNECT_CONFIG } from \"./runtime-config.js\";\n\n/** Recursive Partial. Arrays are leaves — `write({ packages: [...] })`\n * replaces the array, it doesn't merge. */\nexport type DeepPartial<T> =\n T extends Array<infer U>\n ? Array<U>\n : T extends object\n ? { [K in keyof T]?: DeepPartial<T[K]> }\n : T;\n\n/**\n * Shape returned by `ConfigLoader.read()`. The loader is Connect-scoped:\n * it guarantees `connect` is present and fully populated from\n * DEFAULT_CONNECT_CONFIG, but lets any other top-level fields pass\n * through unchanged so source-config-only fields (studio, reactor, auth,\n * documentModelsDir, etc.) survive a read+write round-trip.\n */\nexport type ConfigShape = Record<string, unknown> & {\n connect: PHConnectRuntimeConfig;\n};\n\n/**\n * Abstract IO layer for `powerhouse.config.json`.\n *\n * Implementations decide where bytes come from and go to. The shipped\n * adapter is `JsonConfigAdapter` (reads via fetch in the browser, fs in\n * Node; writes via fs in Node, throws in the browser). Future adapters\n * (remote-JSON, GraphQL) plug in without changing the loader or any\n * consumer.\n */\nexport interface ConfigAdapter {\n /** Read raw JSON-parsed payload from the backing store. */\n read(): Promise<unknown>;\n /** Persist a fully-formed config. */\n write(next: ConfigShape): Promise<void>;\n /** Human-readable description used in errors and logs. */\n readonly source: string;\n}\n\n/**\n * Deep-merge `patch` into `base`. Object fields recurse; arrays and\n * primitives replace. `undefined` in patch leaves the base value\n * untouched (no unset). `null` in patch overwrites with null.\n *\n * Exported for unit tests; consumers use ConfigLoader.write() which\n * applies this internally.\n */\nexport function deepMerge<T>(base: T, patch: DeepPartial<T>): T {\n if (!isPlainObject(base) || !isPlainObject(patch)) {\n return patch as T;\n }\n const result: Record<string, unknown> = { ...base };\n for (const [key, patchValue] of Object.entries(patch)) {\n if (patchValue === undefined) continue;\n const baseValue = result[key];\n if (isPlainObject(baseValue) && isPlainObject(patchValue)) {\n result[key] = deepMerge(\n baseValue,\n patchValue as DeepPartial<typeof baseValue>,\n );\n } else {\n result[key] = patchValue;\n }\n }\n return result as T;\n}\n\n/**\n * The effective `connect.*` block of a source `powerhouse.config.json`:\n * defaults < project-wide settings Connect follows < `connect.*`. So\n * `connect.app.workflowsEnabled` falls back to `workflows.enabled`, and\n * wins when set.\n */\nexport function resolveSourceConnect(\n source: Pick<PowerhouseConfig, \"connect\" | \"workflows\">,\n defaults: PHConnectRuntimeConfig = DEFAULT_CONNECT_CONFIG,\n): PHConnectRuntimeConfig {\n const projectWide = deepMerge(defaults, {\n app: { workflowsEnabled: source.workflows?.enabled },\n });\n return deepMerge(projectWide, source.connect ?? {});\n}\n\n// Projects scaffolded before workflows.enabled reached Connect carry an explicit\n// `false` from the old defaults, which then keeps Workflow Studio off\nexport function workflowsSettingConflict(\n source: Pick<PowerhouseConfig, \"connect\" | \"workflows\">,\n): string | undefined {\n if (source.workflows?.enabled !== true) return undefined;\n if (source.connect?.app?.workflowsEnabled !== false) return undefined;\n return 'powerhouse.config.json sets workflows.enabled but also connect.app.workflowsEnabled: false, so Workflow Studio stays off in Connect. Remove \"workflowsEnabled\" from connect.app to follow workflows.enabled.';\n}\n\n/**\n * Pluggable loader on top of a `ConfigAdapter`.\n *\n * Responsibilities:\n * - merge-with-defaults on read (so consumers never see a partial connect block)\n * - in-process caching (call `invalidate()` to force re-read)\n * - deep-merge for partial writes; writes the merged whole back through the adapter\n *\n * The cache is module-instance scoped — every `new ConfigLoader(...)` has\n * its own cache. The browser SPA constructs the loader once at boot; the\n * CLI typically constructs a fresh loader per command.\n */\nexport class ConfigLoader {\n private cache: ConfigShape | undefined;\n\n constructor(\n private readonly adapter: ConfigAdapter,\n private readonly defaults: PHConnectRuntimeConfig = DEFAULT_CONNECT_CONFIG,\n ) {}\n\n /** Returns the config with the default connect block merged in.\n * Cached after the first successful call. */\n async read(): Promise<ConfigShape> {\n if (this.cache) return this.cache;\n const raw = await this.adapter.read();\n const obj = isPlainObject(raw) ? raw : {};\n const connectRaw = isPlainObject(obj.connect) ? obj.connect : {};\n this.cache = {\n ...obj,\n connect: deepMerge(\n this.defaults,\n connectRaw as DeepPartial<PHConnectRuntimeConfig>,\n ),\n };\n return this.cache;\n }\n\n /**\n * Returns the cached config synchronously. Throws if `read()` has not\n * resolved yet — matches Connect's `getRuntimeConfig()` shape.\n */\n getCached(): ConfigShape {\n if (!this.cache) {\n throw new Error(\n `ConfigLoader (${this.adapter.source}): cache empty; call read() first.`,\n );\n }\n return this.cache;\n }\n\n /** Drop the in-memory cache. Next `read()` re-fetches from the adapter. */\n invalidate(): void {\n this.cache = undefined;\n }\n\n /**\n * Deep-merge `patch` into the current config and persist via the adapter.\n * Returns the new full config (also updates the cache). Arrays in `patch`\n * replace — they do NOT append.\n */\n async write(patch: DeepPartial<ConfigShape>): Promise<ConfigShape> {\n const current = await this.read();\n const next = deepMerge(current, patch);\n await this.adapter.write(next);\n this.cache = next;\n return next;\n }\n}\n"],"mappings":";;;;AAgBA,MAAa,yBAAiD;CAC5D,UAAU;EACR,SAAS;EACT,gBAAgB;CAClB;CACA,KAAK;EACH,UAAU;EACV,UAAU;EACV,SAAS;EACT,YAAY;CACd;CACA,IAAI,EACF,kBAAkB,MACpB;CACA,UAAU;EACR,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