everything-dev 1.14.1 → 1.14.4
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/cli/upgrade.cjs +7 -4
- package/dist/cli/upgrade.cjs.map +1 -1
- package/dist/cli/upgrade.mjs +7 -4
- package/dist/cli/upgrade.mjs.map +1 -1
- package/dist/contract.d.cts +33 -33
- package/dist/contract.d.mts +33 -33
- package/dist/orchestrator.cjs +0 -1
- package/dist/orchestrator.cjs.map +1 -1
- package/dist/plugin.d.cts +33 -33
- package/dist/plugin.d.mts +33 -33
- package/dist/shared.cjs +0 -10
- package/dist/shared.cjs.map +1 -1
- package/dist/shared.mjs +1 -9
- package/dist/shared.mjs.map +1 -1
- package/dist/types.d.cts +2 -2
- package/dist/types.d.mts +2 -2
- package/package.json +4 -30
- package/src/cli/upgrade.ts +8 -5
- package/dist/api.cjs +0 -124
- package/dist/api.cjs.map +0 -1
- package/dist/api.d.cts +0 -36
- package/dist/api.d.cts.map +0 -1
- package/dist/api.d.mts +0 -36
- package/dist/api.d.mts.map +0 -1
- package/dist/api.mjs +0 -119
- package/dist/api.mjs.map +0 -1
- package/dist/federation.server.cjs +0 -27
- package/dist/federation.server.cjs.map +0 -1
- package/dist/federation.server.mjs +0 -27
- package/dist/federation.server.mjs.map +0 -1
- package/dist/host.cjs +0 -402
- package/dist/host.cjs.map +0 -1
- package/dist/host.d.cts +0 -22
- package/dist/host.d.cts.map +0 -1
- package/dist/host.d.mts +0 -22
- package/dist/host.d.mts.map +0 -1
- package/dist/host.mjs +0 -399
- package/dist/host.mjs.map +0 -1
- package/dist/orchestrator.d.cts +0 -44
- package/dist/orchestrator.d.cts.map +0 -1
- package/dist/orchestrator.d.mts +0 -44
- package/dist/orchestrator.d.mts.map +0 -1
- package/dist/service-descriptor.d.cts +0 -137
- package/dist/service-descriptor.d.cts.map +0 -1
- package/dist/service-descriptor.d.mts +0 -137
- package/dist/service-descriptor.d.mts.map +0 -1
- package/dist/shared.d.cts +0 -36
- package/dist/shared.d.cts.map +0 -1
- package/dist/shared.d.mts +0 -36
- package/dist/shared.d.mts.map +0 -1
- package/src/api.ts +0 -181
- package/src/federation.server.ts +0 -43
- package/src/host.ts +0 -573
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.cjs","names":["Effect","DevRuntimeConfig","Deferred","Ref","Command","Stream","Option","ServiceDescriptorMap"],"sources":["../src/orchestrator.ts"],"sourcesContent":["import { Command } from \"@effect/platform\";\nimport type { ExitCode } from \"@effect/platform/CommandExecutor\";\nimport { Deferred, Effect, Option, Ref, Stream } from \"effect\";\nimport { patchManifestFetchForSsrPublicPath } from \"./mf\";\nimport {\n DevRuntimeConfig,\n type ServiceDescriptor,\n ServiceDescriptorMap,\n} from \"./service-descriptor\";\nimport type { RuntimeConfig } from \"./types\";\n\nprocess.on(\"unhandledRejection\", (reason) => {\n console.error(\"[Orchestrator] Unhandled rejection:\", reason);\n});\n\nprocess.on(\"uncaughtException\", (err) => {\n console.error(\"[Orchestrator] Uncaught exception:\", err);\n});\n\nexport interface ProcessCallbacks {\n onStatus: (name: string, status: ProcessStatus, message?: string) => void;\n onLog: (name: string, line: string, isError?: boolean) => void;\n}\n\nexport interface ProcessHandle {\n name: string;\n pid: number | undefined;\n kill: Effect.Effect<void, unknown>;\n waitForReady: Effect.Effect<void, Error>;\n waitForExit: Effect.Effect<ExitCode, unknown>;\n}\n\nexport type ProcessStatus = \"pending\" | \"starting\" | \"ready\" | \"error\";\n\nexport interface ProcessState {\n name: string;\n status: ProcessStatus;\n port: number;\n message?: string;\n source?: \"local\" | \"remote\";\n}\n\nconst stripAnsi = (input: string): string => {\n const ESC = String.fromCharCode(27);\n const BEL = String.fromCharCode(7);\n return input\n .replace(new RegExp(`${ESC}\\\\][^${BEL}]*${BEL}`, \"g\"), \"\")\n .replace(new RegExp(`${ESC}\\\\[[0-?]*[ -/]*[@-~]`, \"g\"), \"\");\n};\n\nconst probeHttpOk = (url: string, timeoutMs = 400) =>\n Effect.tryPromise({\n try: async () => {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n try {\n const res = await fetch(url, { signal: controller.signal });\n return res.ok;\n } catch {\n return false;\n } finally {\n clearTimeout(timer);\n }\n },\n catch: () => false,\n });\n\nconst detectStatus = (\n line: string,\n descriptor: ServiceDescriptor,\n): { status: ProcessStatus; isError: boolean } | null => {\n const cleanLine = stripAnsi(line);\n const errorPatterns = descriptor.errorPatterns ?? [];\n const readyPatterns = descriptor.readyPatterns ?? [];\n for (const pattern of errorPatterns) {\n if (pattern.test(cleanLine)) {\n return { status: \"error\", isError: true };\n }\n }\n for (const pattern of readyPatterns) {\n if (pattern.test(cleanLine)) {\n return { status: \"ready\", isError: false };\n }\n }\n return null;\n};\n\ninterface ServerHandle {\n ready: Promise<void>;\n shutdown: () => Promise<void>;\n}\n\ninterface ServerInput {\n config: RuntimeConfig;\n}\n\nconst patchConsole = (name: string, callbacks: ProcessCallbacks): (() => void) => {\n const originalLog = console.log;\n const originalError = console.error;\n const originalWarn = console.warn;\n const originalInfo = console.info;\n\n const formatArgs = (args: unknown[], isError = false): string => {\n return args\n .map((arg) => {\n if (arg instanceof Error) {\n const parts = [`${arg.name}: ${arg.message}`];\n if (arg.cause instanceof Error)\n parts.push(`(cause: ${arg.cause.name}: ${arg.cause.message})`);\n else if (arg.cause) parts.push(`(cause: ${String(arg.cause)})`);\n if (isError && arg.stack) parts.push(arg.stack);\n return parts.join(\"\\n\");\n }\n return typeof arg === \"object\" ? JSON.stringify(arg, null, 2) : String(arg);\n })\n .join(\" \");\n };\n\n console.log = (...args: unknown[]) => {\n callbacks.onLog(name, formatArgs(args), false);\n };\n console.error = (...args: unknown[]) => {\n callbacks.onLog(name, formatArgs(args, true), true);\n };\n console.warn = (...args: unknown[]) => {\n callbacks.onLog(name, formatArgs(args), false);\n };\n console.info = (...args: unknown[]) => {\n callbacks.onLog(name, formatArgs(args), false);\n };\n\n return () => {\n console.log = originalLog;\n console.error = originalError;\n console.warn = originalWarn;\n console.info = originalInfo;\n };\n};\n\nconst spawnRemoteHost = (descriptor: ServiceDescriptor, callbacks: ProcessCallbacks) =>\n Effect.gen(function* () {\n const runtimeConfig = yield* DevRuntimeConfig;\n const remoteUrl = descriptor.remoteUrl;\n if (!remoteUrl) {\n return yield* Effect.fail(new Error(\"remoteUrl not provided on host descriptor\"));\n }\n\n callbacks.onStatus(descriptor.key, \"starting\");\n callbacks.onLog(descriptor.key, `Remote: ${remoteUrl}`);\n const restoreConsole = patchConsole(descriptor.key, callbacks);\n callbacks.onLog(descriptor.key, \"Loading Module Federation runtime...\");\n\n const mfRuntime = yield* Effect.tryPromise({\n try: () => import(\"@module-federation/enhanced/runtime\"),\n catch: (e) => new Error(`Failed to load MF runtime: ${e}`),\n });\n\n const mfCore = yield* Effect.tryPromise({\n try: () => import(\"@module-federation/runtime-core\"),\n catch: (e) => new Error(`Failed to load MF core: ${e}`),\n });\n\n let mf = mfRuntime.getInstance();\n if (!mf) {\n mf = mfRuntime.createInstance({ name: \"cli-host\", remotes: [] });\n mfCore.setGlobalFederationInstance(mf);\n }\n patchManifestFetchForSsrPublicPath(mf as any);\n\n const baseUrl = remoteUrl\n .replace(/\\/remoteEntry\\.js$/, \"\")\n .replace(/\\/mf-manifest\\.json$/, \"\")\n .replace(/\\/$/, \"\");\n const remoteEntryUrl = `${baseUrl}/remoteEntry.js`;\n const manifestUrl = `${baseUrl}/mf-manifest.json`;\n\n const entryUrl = yield* Effect.tryPromise({\n try: async () => {\n try {\n const res = await fetch(manifestUrl);\n if (!res.ok) return remoteEntryUrl;\n const json = (await res.json()) as Record<string, unknown>;\n if (\n json &&\n typeof json === \"object\" &&\n \"metaData\" in json &&\n \"exposes\" in json &&\n \"shared\" in json\n ) {\n return manifestUrl;\n }\n } catch {}\n return remoteEntryUrl;\n },\n catch: () => remoteEntryUrl,\n });\n\n (mf as any).registerRemotes([{ name: \"host\", entry: entryUrl }]);\n callbacks.onLog(descriptor.key, `Loading host from ${entryUrl}...`);\n\n const hostModule = yield* Effect.tryPromise({\n try: () =>\n (mf as any).loadRemote(\"host/Server\") as Promise<{\n runServer: (input: ServerInput) => ServerHandle;\n }>,\n catch: (e) => new Error(`Failed to load host module: ${e}`),\n });\n\n if (!hostModule?.runServer) {\n return yield* Effect.fail(new Error(\"Host module does not export runServer function\"));\n }\n\n callbacks.onLog(descriptor.key, \"Starting server...\");\n const serverHandle = hostModule.runServer({ config: runtimeConfig });\n yield* Effect.tryPromise({\n try: () => serverHandle.ready,\n catch: (e) => new Error(`Server failed to start: ${e}`),\n });\n\n callbacks.onStatus(descriptor.key, \"ready\");\n\n return {\n name: descriptor.key,\n pid: process.pid,\n kill: Effect.gen(function* () {\n callbacks.onLog(descriptor.key, \"Shutting down remote host...\");\n restoreConsole();\n yield* Effect.tryPromise({\n try: () => serverHandle.shutdown(),\n catch: () => {},\n }).pipe(Effect.ignore);\n }),\n waitForReady: Effect.succeed(undefined),\n waitForExit: Effect.never,\n } satisfies ProcessHandle;\n });\n\nconst spawnDevProcess = (descriptor: ServiceDescriptor, callbacks: ProcessCallbacks) =>\n Effect.gen(function* () {\n const runtimeConfig = yield* DevRuntimeConfig;\n\n if (!descriptor.localPath) {\n return yield* Effect.fail(new Error(`No localPath for local service: ${descriptor.key}`));\n }\n\n const fullCwd = descriptor.localPath;\n const command = descriptor.command ?? \"bun\";\n const args = descriptor.args ?? [\"run\", \"dev\"];\n const port = descriptor.port ?? descriptor.defaultPort;\n const name = descriptor.key;\n\n const readyDeferred = yield* Deferred.make<void, Error>();\n const statusRef = yield* Ref.make<ProcessStatus>(\"starting\");\n\n callbacks.onStatus(name, \"starting\");\n\n const envVars: Record<string, string> = {\n ...(process.env as Record<string, string>),\n FORCE_COLOR: \"1\",\n ...(port > 0 ? { PORT: String(port) } : {}),\n };\n\n if (name === \"host\") {\n envVars.BOS_RUNTIME_CONFIG = JSON.stringify(runtimeConfig);\n }\n\n const cmd = Command.make(command, ...args).pipe(\n Command.workingDirectory(fullCwd),\n Command.env(envVars),\n );\n\n const proc = yield* Command.start(cmd);\n\n const markReady = Effect.gen(function* () {\n const currentStatus = yield* Ref.get(statusRef);\n if (currentStatus === \"ready\" || currentStatus === \"error\") return;\n yield* Ref.set(statusRef, \"ready\");\n callbacks.onStatus(name, \"ready\");\n yield* Deferred.succeed(readyDeferred, undefined).pipe(Effect.ignore);\n });\n\n if (port > 0) {\n const readinessPath = descriptor.readinessPath;\n const url = `http://127.0.0.1:${port}${readinessPath}`;\n\n yield* Effect.forkScoped(\n Effect.gen(function* () {\n const deadline = Date.now() + 90_000;\n while (Date.now() < deadline) {\n const status = yield* Ref.get(statusRef);\n if (status === \"ready\" || status === \"error\") return;\n const ok = yield* probeHttpOk(url);\n if (ok) {\n yield* markReady;\n return;\n }\n yield* Effect.sleep(\"200 millis\");\n }\n }),\n );\n }\n\n const pid = Number(proc.pid);\n\n yield* Effect.forkScoped(\n Effect.gen(function* () {\n const exitCode = yield* proc.exitCode;\n const currentStatus = yield* Ref.get(statusRef);\n if (currentStatus === \"ready\" || currentStatus === \"error\") return;\n callbacks.onLog(name, `Process exited before ready (exit code: ${exitCode})`, true);\n yield* Ref.set(statusRef, \"error\");\n callbacks.onStatus(name, \"error\");\n yield* Deferred.fail(readyDeferred, new Error(`Process exited before ready: ${name}`)).pipe(\n Effect.ignore,\n );\n }),\n );\n\n const handleLine = (line: string, isStderr: boolean) =>\n Effect.gen(function* () {\n if (!line.trim()) return;\n\n const cleanLine = stripAnsi(line);\n const looksLikeError =\n isStderr &&\n /^(error|fail|fatal|exception|unhandled|reject)/i.test(cleanLine) &&\n !/^\\$/.test(cleanLine);\n callbacks.onLog(name, line, looksLikeError);\n\n const currentStatus = yield* Ref.get(statusRef);\n if (currentStatus === \"ready\" || currentStatus === \"error\") return;\n\n const detected = detectStatus(line, descriptor);\n if (detected) {\n yield* Ref.set(statusRef, detected.status);\n callbacks.onStatus(name, detected.status);\n if (detected.status === \"ready\" || detected.status === \"error\") {\n if (detected.status === \"ready\") {\n yield* Deferred.succeed(readyDeferred, undefined).pipe(Effect.ignore);\n } else {\n yield* Deferred.fail(readyDeferred, new Error(`Process failed: ${name}`)).pipe(\n Effect.ignore,\n );\n }\n }\n }\n });\n\n yield* Effect.forkScoped(\n Stream.runForEach((line: string) => handleLine(line, false))(\n Stream.splitLines(Stream.decodeText(proc.stdout, \"utf-8\")),\n ),\n );\n\n yield* Effect.forkScoped(\n Stream.runForEach((line: string) => handleLine(line, true))(\n Stream.splitLines(Stream.decodeText(proc.stderr, \"utf-8\")),\n ),\n );\n\n return {\n name,\n pid,\n kill: Effect.gen(function* () {\n const result = yield* proc.kill(\"SIGTERM\").pipe(Effect.timeout(\"3 seconds\"), Effect.option);\n if (Option.isNone(result)) {\n const pid = Number(proc.pid);\n yield* Effect.try(() => process.kill(-pid, \"SIGKILL\")).pipe(Effect.ignore);\n yield* Effect.sleep(\"250 millis\");\n }\n }).pipe(Effect.ignore),\n waitForReady: Deferred.await(readyDeferred),\n waitForExit: proc.exitCode,\n } satisfies ProcessHandle;\n });\n\nconst spawnRemoteProbe = (\n pkg: string,\n descriptor: ServiceDescriptor,\n callbacks: ProcessCallbacks,\n) =>\n Effect.gen(function* () {\n callbacks.onStatus(pkg, \"starting\");\n const readyDeferred = yield* Deferred.make<void, Error>();\n const statusRef = yield* Ref.make<ProcessStatus>(\"starting\");\n\n const markReady = Effect.gen(function* () {\n yield* Ref.set(statusRef, \"ready\");\n yield* Deferred.succeed(readyDeferred, undefined);\n callbacks.onStatus(pkg, \"ready\", \"loaded\");\n });\n\n const markError = Effect.gen(function* () {\n yield* Ref.set(statusRef, \"error\");\n yield* Deferred.fail(readyDeferred, new Error(`Remote ${pkg} unreachable`));\n callbacks.onStatus(pkg, \"error\", \"unreachable\");\n });\n\n const baseUrl = descriptor.url.replace(/\\/$/, \"\");\n const manifestUrl = `${baseUrl}/mf-manifest.json`;\n const entryUrl = `${baseUrl}${descriptor.readinessPath}`;\n const probeUrl = descriptor.readinessPath === \"/health\" ? `${baseUrl}/health` : manifestUrl;\n\n yield* Effect.forkScoped(\n Effect.gen(function* () {\n const deadline = Date.now() + 60_000;\n while (Date.now() < deadline) {\n const status = yield* Ref.get(statusRef);\n if (status === \"ready\" || status === \"error\") return;\n\n const ok = yield* probeHttpOk(probeUrl, 400);\n\n if (ok) {\n yield* markReady;\n return;\n }\n\n const fallbackOk = yield* probeHttpOk(entryUrl, 400);\n\n if (fallbackOk) {\n yield* markReady;\n return;\n }\n\n yield* Effect.sleep(\"500 millis\");\n }\n\n const status = yield* Ref.get(statusRef);\n if (status !== \"ready\") {\n yield* markError;\n }\n }),\n );\n\n return {\n name: pkg,\n pid: undefined,\n kill: Effect.gen(function* () {\n yield* Ref.set(statusRef, \"error\");\n yield* Deferred.fail(readyDeferred, new Error(\"Killed\")).pipe(Effect.ignore);\n }),\n waitForReady: Deferred.await(readyDeferred),\n waitForExit: Effect.never,\n } satisfies ProcessHandle;\n });\n\nexport const makeDevProcess = (pkg: string, callbacks: ProcessCallbacks, portOverride?: number) =>\n Effect.gen(function* () {\n const services = yield* ServiceDescriptorMap;\n const descriptor = services.get(pkg);\n\n if (!descriptor) {\n callbacks.onStatus(pkg, \"ready\", \"Remote\");\n return {\n name: pkg,\n pid: undefined,\n kill: Effect.void,\n waitForReady: Effect.void,\n waitForExit: Effect.never,\n } satisfies ProcessHandle;\n }\n\n if (pkg === \"host\" && descriptor.source === \"remote\") {\n return yield* spawnRemoteHost(descriptor, callbacks);\n }\n\n if (descriptor.source === \"remote\" || !descriptor.localPath) {\n return yield* spawnRemoteProbe(pkg, descriptor, callbacks);\n }\n\n const resolvedDescriptor = portOverride ? { ...descriptor, port: portOverride } : descriptor;\n\n return yield* spawnDevProcess(resolvedDescriptor, callbacks);\n });\n\nexport function getProcessStates(\n packages: string[],\n services: Map<string, ServiceDescriptor>,\n portOverride?: number,\n): ProcessState[] {\n return packages.map((pkg) => {\n const descriptor = services.get(pkg);\n return {\n name: pkg,\n status: \"pending\" as const,\n port:\n portOverride && pkg === \"host\"\n ? portOverride\n : (descriptor?.port ?? descriptor?.defaultPort ?? 0),\n source: descriptor?.source,\n };\n });\n}\n"],"mappings":";;;;;;;;AAWA,QAAQ,GAAG,uBAAuB,WAAW;AAC3C,SAAQ,MAAM,uCAAuC,OAAO;EAC5D;AAEF,QAAQ,GAAG,sBAAsB,QAAQ;AACvC,SAAQ,MAAM,sCAAsC,IAAI;EACxD;AAyBF,MAAM,aAAa,UAA0B;CAC3C,MAAM,MAAM,OAAO,aAAa,GAAG;CACnC,MAAM,MAAM,OAAO,aAAa,EAAE;AAClC,QAAO,MACJ,QAAQ,IAAI,OAAO,GAAG,IAAI,OAAO,IAAI,IAAI,OAAO,IAAI,EAAE,GAAG,CACzD,QAAQ,IAAI,OAAO,GAAG,IAAI,uBAAuB,IAAI,EAAE,GAAG;;AAG/D,MAAM,eAAe,KAAa,YAAY,QAC5CA,cAAO,WAAW;CAChB,KAAK,YAAY;EACf,MAAM,aAAa,IAAI,iBAAiB;EACxC,MAAM,QAAQ,iBAAiB,WAAW,OAAO,EAAE,UAAU;AAC7D,MAAI;AAEF,WADY,MAAM,MAAM,KAAK,EAAE,QAAQ,WAAW,QAAQ,CAAC,EAChD;UACL;AACN,UAAO;YACC;AACR,gBAAa,MAAM;;;CAGvB,aAAa;CACd,CAAC;AAEJ,MAAM,gBACJ,MACA,eACuD;CACvD,MAAM,YAAY,UAAU,KAAK;CACjC,MAAM,gBAAgB,WAAW,iBAAiB,EAAE;CACpD,MAAM,gBAAgB,WAAW,iBAAiB,EAAE;AACpD,MAAK,MAAM,WAAW,cACpB,KAAI,QAAQ,KAAK,UAAU,CACzB,QAAO;EAAE,QAAQ;EAAS,SAAS;EAAM;AAG7C,MAAK,MAAM,WAAW,cACpB,KAAI,QAAQ,KAAK,UAAU,CACzB,QAAO;EAAE,QAAQ;EAAS,SAAS;EAAO;AAG9C,QAAO;;AAYT,MAAM,gBAAgB,MAAc,cAA8C;CAChF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AO;AACP;;AAGF,UAAOH,cAAO,MAAM,aAAa;;AAInC,OADe,OAAOG,WAAI,IAAI,UAAU,MACzB,QACb,QAAO;GAET,CACH;AAED,QAAO;EACL,MAAM;EACN,KAAK;EACL,MAAMH,cAAO,IAAI,aAAa;AAC5B,UAAOG,WAAI,IAAI,WAAW,QAAQ;AAClC,UAAOD,gBAAS,KAAK,+BAAe,IAAI,MAAM,SAAS,CAAC,CAAC,KAAKF,cAAO,OAAO;IAC5E;EACF,cAAcE,gBAAS,MAAM,cAAc;EAC3C,aAAaF,cAAO;EACrB;EACD;AAEJ,MAAa,kBAAkB,KAAa,WAA6B,iBACvEA,cAAO,IAAI,aAAa;CAEtB,MAAM,cADW,OAAOO,iDACI,IAAI,IAAI;AAEpC,KAAI,CAAC,YAAY;AACf,YAAU,SAAS,KAAK,SAAS,SAAS;AAC1C,SAAO;GACL,MAAM;GACN,KAAK;GACL,MAAMP,cAAO;GACb,cAAcA,cAAO;GACrB,aAAaA,cAAO;GACrB;;AAGH,KAAI,QAAQ,UAAU,WAAW,WAAW,SAC1C,QAAO,OAAO,gBAAgB,YAAY,UAAU;AAGtD,KAAI,WAAW,WAAW,YAAY,CAAC,WAAW,UAChD,QAAO,OAAO,iBAAiB,KAAK,YAAY,UAAU;AAK5D,QAAO,OAAO,gBAFa,eAAe;EAAE,GAAG;EAAY,MAAM;EAAc,GAAG,YAEhC,UAAU;EAC5D;AAEJ,SAAgB,iBACd,UACA,UACA,cACgB;AAChB,QAAO,SAAS,KAAK,QAAQ;EAC3B,MAAM,aAAa,SAAS,IAAI,IAAI;AACpC,SAAO;GACL,MAAM;GACN,QAAQ;GACR,MACE,gBAAgB,QAAQ,SACpB,eACC,YAAY,QAAQ,YAAY,eAAe;GACtD,QAAQ,YAAY;GACrB;GACD"}
|
|
1
|
+
{"version":3,"file":"orchestrator.cjs","names":["Effect","DevRuntimeConfig","Deferred","Ref","Command","Stream","Option","ServiceDescriptorMap"],"sources":["../src/orchestrator.ts"],"sourcesContent":["import { Command } from \"@effect/platform\";\nimport type { ExitCode } from \"@effect/platform/CommandExecutor\";\nimport { Deferred, Effect, Option, Ref, Stream } from \"effect\";\nimport { patchManifestFetchForSsrPublicPath } from \"./mf\";\nimport {\n DevRuntimeConfig,\n type ServiceDescriptor,\n ServiceDescriptorMap,\n} from \"./service-descriptor\";\nimport type { RuntimeConfig } from \"./types\";\n\nprocess.on(\"unhandledRejection\", (reason) => {\n console.error(\"[Orchestrator] Unhandled rejection:\", reason);\n});\n\nprocess.on(\"uncaughtException\", (err) => {\n console.error(\"[Orchestrator] Uncaught exception:\", err);\n});\n\nexport interface ProcessCallbacks {\n onStatus: (name: string, status: ProcessStatus, message?: string) => void;\n onLog: (name: string, line: string, isError?: boolean) => void;\n}\n\nexport interface ProcessHandle {\n name: string;\n pid: number | undefined;\n kill: Effect.Effect<void, unknown>;\n waitForReady: Effect.Effect<void, Error>;\n waitForExit: Effect.Effect<ExitCode, unknown>;\n}\n\nexport type ProcessStatus = \"pending\" | \"starting\" | \"ready\" | \"error\";\n\nexport interface ProcessState {\n name: string;\n status: ProcessStatus;\n port: number;\n message?: string;\n source?: \"local\" | \"remote\";\n}\n\nconst stripAnsi = (input: string): string => {\n const ESC = String.fromCharCode(27);\n const BEL = String.fromCharCode(7);\n return input\n .replace(new RegExp(`${ESC}\\\\][^${BEL}]*${BEL}`, \"g\"), \"\")\n .replace(new RegExp(`${ESC}\\\\[[0-?]*[ -/]*[@-~]`, \"g\"), \"\");\n};\n\nconst probeHttpOk = (url: string, timeoutMs = 400) =>\n Effect.tryPromise({\n try: async () => {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n try {\n const res = await fetch(url, { signal: controller.signal });\n return res.ok;\n } catch {\n return false;\n } finally {\n clearTimeout(timer);\n }\n },\n catch: () => false,\n });\n\nconst detectStatus = (\n line: string,\n descriptor: ServiceDescriptor,\n): { status: ProcessStatus; isError: boolean } | null => {\n const cleanLine = stripAnsi(line);\n const errorPatterns = descriptor.errorPatterns ?? [];\n const readyPatterns = descriptor.readyPatterns ?? [];\n for (const pattern of errorPatterns) {\n if (pattern.test(cleanLine)) {\n return { status: \"error\", isError: true };\n }\n }\n for (const pattern of readyPatterns) {\n if (pattern.test(cleanLine)) {\n return { status: \"ready\", isError: false };\n }\n }\n return null;\n};\n\ninterface ServerHandle {\n ready: Promise<void>;\n shutdown: () => Promise<void>;\n}\n\ninterface ServerInput {\n config: RuntimeConfig;\n}\n\nconst patchConsole = (name: string, callbacks: ProcessCallbacks): (() => void) => {\n const originalLog = console.log;\n const originalError = console.error;\n const originalWarn = console.warn;\n const originalInfo = console.info;\n\n const formatArgs = (args: unknown[], isError = false): string => {\n return args\n .map((arg) => {\n if (arg instanceof Error) {\n const parts = [`${arg.name}: ${arg.message}`];\n if (arg.cause instanceof Error)\n parts.push(`(cause: ${arg.cause.name}: ${arg.cause.message})`);\n else if (arg.cause) parts.push(`(cause: ${String(arg.cause)})`);\n if (isError && arg.stack) parts.push(arg.stack);\n return parts.join(\"\\n\");\n }\n return typeof arg === \"object\" ? JSON.stringify(arg, null, 2) : String(arg);\n })\n .join(\" \");\n };\n\n console.log = (...args: unknown[]) => {\n callbacks.onLog(name, formatArgs(args), false);\n };\n console.error = (...args: unknown[]) => {\n callbacks.onLog(name, formatArgs(args, true), true);\n };\n console.warn = (...args: unknown[]) => {\n callbacks.onLog(name, formatArgs(args), false);\n };\n console.info = (...args: unknown[]) => {\n callbacks.onLog(name, formatArgs(args), false);\n };\n\n return () => {\n console.log = originalLog;\n console.error = originalError;\n console.warn = originalWarn;\n console.info = originalInfo;\n };\n};\n\nconst spawnRemoteHost = (descriptor: ServiceDescriptor, callbacks: ProcessCallbacks) =>\n Effect.gen(function* () {\n const runtimeConfig = yield* DevRuntimeConfig;\n const remoteUrl = descriptor.remoteUrl;\n if (!remoteUrl) {\n return yield* Effect.fail(new Error(\"remoteUrl not provided on host descriptor\"));\n }\n\n callbacks.onStatus(descriptor.key, \"starting\");\n callbacks.onLog(descriptor.key, `Remote: ${remoteUrl}`);\n const restoreConsole = patchConsole(descriptor.key, callbacks);\n callbacks.onLog(descriptor.key, \"Loading Module Federation runtime...\");\n\n const mfRuntime = yield* Effect.tryPromise({\n try: () => import(\"@module-federation/enhanced/runtime\"),\n catch: (e) => new Error(`Failed to load MF runtime: ${e}`),\n });\n\n const mfCore = yield* Effect.tryPromise({\n try: () => import(\"@module-federation/runtime-core\"),\n catch: (e) => new Error(`Failed to load MF core: ${e}`),\n });\n\n let mf = mfRuntime.getInstance();\n if (!mf) {\n mf = mfRuntime.createInstance({ name: \"cli-host\", remotes: [] });\n mfCore.setGlobalFederationInstance(mf);\n }\n patchManifestFetchForSsrPublicPath(mf as any);\n\n const baseUrl = remoteUrl\n .replace(/\\/remoteEntry\\.js$/, \"\")\n .replace(/\\/mf-manifest\\.json$/, \"\")\n .replace(/\\/$/, \"\");\n const remoteEntryUrl = `${baseUrl}/remoteEntry.js`;\n const manifestUrl = `${baseUrl}/mf-manifest.json`;\n\n const entryUrl = yield* Effect.tryPromise({\n try: async () => {\n try {\n const res = await fetch(manifestUrl);\n if (!res.ok) return remoteEntryUrl;\n const json = (await res.json()) as Record<string, unknown>;\n if (\n json &&\n typeof json === \"object\" &&\n \"metaData\" in json &&\n \"exposes\" in json &&\n \"shared\" in json\n ) {\n return manifestUrl;\n }\n } catch {}\n return remoteEntryUrl;\n },\n catch: () => remoteEntryUrl,\n });\n\n (mf as any).registerRemotes([{ name: \"host\", entry: entryUrl }]);\n callbacks.onLog(descriptor.key, `Loading host from ${entryUrl}...`);\n\n const hostModule = yield* Effect.tryPromise({\n try: () =>\n (mf as any).loadRemote(\"host/Server\") as Promise<{\n runServer: (input: ServerInput) => ServerHandle;\n }>,\n catch: (e) => new Error(`Failed to load host module: ${e}`),\n });\n\n if (!hostModule?.runServer) {\n return yield* Effect.fail(new Error(\"Host module does not export runServer function\"));\n }\n\n callbacks.onLog(descriptor.key, \"Starting server...\");\n const serverHandle = hostModule.runServer({ config: runtimeConfig });\n yield* Effect.tryPromise({\n try: () => serverHandle.ready,\n catch: (e) => new Error(`Server failed to start: ${e}`),\n });\n\n callbacks.onStatus(descriptor.key, \"ready\");\n\n return {\n name: descriptor.key,\n pid: process.pid,\n kill: Effect.gen(function* () {\n callbacks.onLog(descriptor.key, \"Shutting down remote host...\");\n restoreConsole();\n yield* Effect.tryPromise({\n try: () => serverHandle.shutdown(),\n catch: () => {},\n }).pipe(Effect.ignore);\n }),\n waitForReady: Effect.succeed(undefined),\n waitForExit: Effect.never,\n } satisfies ProcessHandle;\n });\n\nconst spawnDevProcess = (descriptor: ServiceDescriptor, callbacks: ProcessCallbacks) =>\n Effect.gen(function* () {\n const runtimeConfig = yield* DevRuntimeConfig;\n\n if (!descriptor.localPath) {\n return yield* Effect.fail(new Error(`No localPath for local service: ${descriptor.key}`));\n }\n\n const fullCwd = descriptor.localPath;\n const command = descriptor.command ?? \"bun\";\n const args = descriptor.args ?? [\"run\", \"dev\"];\n const port = descriptor.port ?? descriptor.defaultPort;\n const name = descriptor.key;\n\n const readyDeferred = yield* Deferred.make<void, Error>();\n const statusRef = yield* Ref.make<ProcessStatus>(\"starting\");\n\n callbacks.onStatus(name, \"starting\");\n\n const envVars: Record<string, string> = {\n ...(process.env as Record<string, string>),\n FORCE_COLOR: \"1\",\n ...(port > 0 ? { PORT: String(port) } : {}),\n };\n\n if (name === \"host\") {\n envVars.BOS_RUNTIME_CONFIG = JSON.stringify(runtimeConfig);\n }\n\n const cmd = Command.make(command, ...args).pipe(\n Command.workingDirectory(fullCwd),\n Command.env(envVars),\n );\n\n const proc = yield* Command.start(cmd);\n\n const markReady = Effect.gen(function* () {\n const currentStatus = yield* Ref.get(statusRef);\n if (currentStatus === \"ready\" || currentStatus === \"error\") return;\n yield* Ref.set(statusRef, \"ready\");\n callbacks.onStatus(name, \"ready\");\n yield* Deferred.succeed(readyDeferred, undefined).pipe(Effect.ignore);\n });\n\n if (port > 0) {\n const readinessPath = descriptor.readinessPath;\n const url = `http://127.0.0.1:${port}${readinessPath}`;\n\n yield* Effect.forkScoped(\n Effect.gen(function* () {\n const deadline = Date.now() + 90_000;\n while (Date.now() < deadline) {\n const status = yield* Ref.get(statusRef);\n if (status === \"ready\" || status === \"error\") return;\n const ok = yield* probeHttpOk(url);\n if (ok) {\n yield* markReady;\n return;\n }\n yield* Effect.sleep(\"200 millis\");\n }\n }),\n );\n }\n\n const pid = Number(proc.pid);\n\n yield* Effect.forkScoped(\n Effect.gen(function* () {\n const exitCode = yield* proc.exitCode;\n const currentStatus = yield* Ref.get(statusRef);\n if (currentStatus === \"ready\" || currentStatus === \"error\") return;\n callbacks.onLog(name, `Process exited before ready (exit code: ${exitCode})`, true);\n yield* Ref.set(statusRef, \"error\");\n callbacks.onStatus(name, \"error\");\n yield* Deferred.fail(readyDeferred, new Error(`Process exited before ready: ${name}`)).pipe(\n Effect.ignore,\n );\n }),\n );\n\n const handleLine = (line: string, isStderr: boolean) =>\n Effect.gen(function* () {\n if (!line.trim()) return;\n\n const cleanLine = stripAnsi(line);\n const looksLikeError =\n isStderr &&\n /^(error|fail|fatal|exception|unhandled|reject)/i.test(cleanLine) &&\n !/^\\$/.test(cleanLine);\n callbacks.onLog(name, line, looksLikeError);\n\n const currentStatus = yield* Ref.get(statusRef);\n if (currentStatus === \"ready\" || currentStatus === \"error\") return;\n\n const detected = detectStatus(line, descriptor);\n if (detected) {\n yield* Ref.set(statusRef, detected.status);\n callbacks.onStatus(name, detected.status);\n if (detected.status === \"ready\" || detected.status === \"error\") {\n if (detected.status === \"ready\") {\n yield* Deferred.succeed(readyDeferred, undefined).pipe(Effect.ignore);\n } else {\n yield* Deferred.fail(readyDeferred, new Error(`Process failed: ${name}`)).pipe(\n Effect.ignore,\n );\n }\n }\n }\n });\n\n yield* Effect.forkScoped(\n Stream.runForEach((line: string) => handleLine(line, false))(\n Stream.splitLines(Stream.decodeText(proc.stdout, \"utf-8\")),\n ),\n );\n\n yield* Effect.forkScoped(\n Stream.runForEach((line: string) => handleLine(line, true))(\n Stream.splitLines(Stream.decodeText(proc.stderr, \"utf-8\")),\n ),\n );\n\n return {\n name,\n pid,\n kill: Effect.gen(function* () {\n const result = yield* proc.kill(\"SIGTERM\").pipe(Effect.timeout(\"3 seconds\"), Effect.option);\n if (Option.isNone(result)) {\n const pid = Number(proc.pid);\n yield* Effect.try(() => process.kill(-pid, \"SIGKILL\")).pipe(Effect.ignore);\n yield* Effect.sleep(\"250 millis\");\n }\n }).pipe(Effect.ignore),\n waitForReady: Deferred.await(readyDeferred),\n waitForExit: proc.exitCode,\n } satisfies ProcessHandle;\n });\n\nconst spawnRemoteProbe = (\n pkg: string,\n descriptor: ServiceDescriptor,\n callbacks: ProcessCallbacks,\n) =>\n Effect.gen(function* () {\n callbacks.onStatus(pkg, \"starting\");\n const readyDeferred = yield* Deferred.make<void, Error>();\n const statusRef = yield* Ref.make<ProcessStatus>(\"starting\");\n\n const markReady = Effect.gen(function* () {\n yield* Ref.set(statusRef, \"ready\");\n yield* Deferred.succeed(readyDeferred, undefined);\n callbacks.onStatus(pkg, \"ready\", \"loaded\");\n });\n\n const markError = Effect.gen(function* () {\n yield* Ref.set(statusRef, \"error\");\n yield* Deferred.fail(readyDeferred, new Error(`Remote ${pkg} unreachable`));\n callbacks.onStatus(pkg, \"error\", \"unreachable\");\n });\n\n const baseUrl = descriptor.url.replace(/\\/$/, \"\");\n const manifestUrl = `${baseUrl}/mf-manifest.json`;\n const entryUrl = `${baseUrl}${descriptor.readinessPath}`;\n const probeUrl = descriptor.readinessPath === \"/health\" ? `${baseUrl}/health` : manifestUrl;\n\n yield* Effect.forkScoped(\n Effect.gen(function* () {\n const deadline = Date.now() + 60_000;\n while (Date.now() < deadline) {\n const status = yield* Ref.get(statusRef);\n if (status === \"ready\" || status === \"error\") return;\n\n const ok = yield* probeHttpOk(probeUrl, 400);\n\n if (ok) {\n yield* markReady;\n return;\n }\n\n const fallbackOk = yield* probeHttpOk(entryUrl, 400);\n\n if (fallbackOk) {\n yield* markReady;\n return;\n }\n\n yield* Effect.sleep(\"500 millis\");\n }\n\n const status = yield* Ref.get(statusRef);\n if (status !== \"ready\") {\n yield* markError;\n }\n }),\n );\n\n return {\n name: pkg,\n pid: undefined,\n kill: Effect.gen(function* () {\n yield* Ref.set(statusRef, \"error\");\n yield* Deferred.fail(readyDeferred, new Error(\"Killed\")).pipe(Effect.ignore);\n }),\n waitForReady: Deferred.await(readyDeferred),\n waitForExit: Effect.never,\n } satisfies ProcessHandle;\n });\n\nexport const makeDevProcess = (pkg: string, callbacks: ProcessCallbacks, portOverride?: number) =>\n Effect.gen(function* () {\n const services = yield* ServiceDescriptorMap;\n const descriptor = services.get(pkg);\n\n if (!descriptor) {\n callbacks.onStatus(pkg, \"ready\", \"Remote\");\n return {\n name: pkg,\n pid: undefined,\n kill: Effect.void,\n waitForReady: Effect.void,\n waitForExit: Effect.never,\n } satisfies ProcessHandle;\n }\n\n if (pkg === \"host\" && descriptor.source === \"remote\") {\n return yield* spawnRemoteHost(descriptor, callbacks);\n }\n\n if (descriptor.source === \"remote\" || !descriptor.localPath) {\n return yield* spawnRemoteProbe(pkg, descriptor, callbacks);\n }\n\n const resolvedDescriptor = portOverride ? { ...descriptor, port: portOverride } : descriptor;\n\n return yield* spawnDevProcess(resolvedDescriptor, callbacks);\n });\n\nexport function getProcessStates(\n packages: string[],\n services: Map<string, ServiceDescriptor>,\n portOverride?: number,\n): ProcessState[] {\n return packages.map((pkg) => {\n const descriptor = services.get(pkg);\n return {\n name: pkg,\n status: \"pending\" as const,\n port:\n portOverride && pkg === \"host\"\n ? portOverride\n : (descriptor?.port ?? descriptor?.defaultPort ?? 0),\n source: descriptor?.source,\n };\n });\n}\n"],"mappings":";;;;;;;AAWA,QAAQ,GAAG,uBAAuB,WAAW;AAC3C,SAAQ,MAAM,uCAAuC,OAAO;EAC5D;AAEF,QAAQ,GAAG,sBAAsB,QAAQ;AACvC,SAAQ,MAAM,sCAAsC,IAAI;EACxD;AAyBF,MA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C5E;EACF,cAAcE,gBAAS,MAAM,cAAc;EAC3C,aAAaF,cAAO;EACrB;EACD;AAEJ,MAAa,kBAAkB,KAAa,WAA6B,iBACvEA,cAAO,IAAI,aAAa;CAEtB,MAAM,cADW,OAAOO,iDACI,IAAI,IAAI;AAEpC,KAAI,CAAC,YAAY;AACf,YAAU,SAAS,KAAK,SAAS,SAAS;AAC1C,SAAO;GACL,MAAM;GACN,KAAK;GACL,MAAMP,cAAO;GACb,cAAcA,cAAO;GACrB,aAAaA,cAAO;GACrB;;AAGH,KAAI,QAAQ,UAAU,WAAW,WAAW,SAC1C,QAAO,OAAO,gBAAgB,YAAY,UAAU;AAGtD,KAAI,WAAW,WAAW,YAAY,CAAC,WAAW,UAChD,QAAO,OAAO,iBAAiB,KAAK,YAAY,UAAU;AAK5D,QAAO,OAAO,gBAFa,eAAe;EAAE,GAAG;EAAY,MAAM;EAAc,GAAG,YAEhC,UAAU;EAC5D;AAEJ,SAAgB,iBACd,UACA,UACA,cACgB;AAChB,QAAO,SAAS,KAAK,QAAQ;EAC3B,MAAM,aAAa,SAAS,IAAI,IAAI;AACpC,SAAO;GACL,MAAM;GACN,QAAQ;GACR,MACE,gBAAgB,QAAQ,SACpB,eACC,YAAY,QAAQ,YAAY,eAAe;GACtD,QAAQ,YAAY;GACrB;GACD"}
|
package/dist/plugin.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from "./sdk.cjs";
|
|
2
|
+
import { ContractProcedure, MergedErrorMap, Schema } from "./node_modules/@orpc/contract/dist/shared/contract.TuRtB1Ca.cjs";
|
|
2
3
|
import * as _$every_plugin0 from "every-plugin";
|
|
3
|
-
import * as _$_orpc_contract0 from "@orpc/contract";
|
|
4
4
|
|
|
5
5
|
//#region src/plugin.d.ts
|
|
6
6
|
declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
7
|
-
dev:
|
|
7
|
+
dev: ContractProcedure<z.ZodObject<{
|
|
8
8
|
host: z.ZodDefault<z.ZodEnum<{
|
|
9
9
|
local: "local";
|
|
10
10
|
remote: "remote";
|
|
@@ -32,8 +32,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
32
32
|
}>;
|
|
33
33
|
description: z.ZodString;
|
|
34
34
|
processes: z.ZodArray<z.ZodString>;
|
|
35
|
-
}, z.core.$strip>,
|
|
36
|
-
start:
|
|
35
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
36
|
+
start: ContractProcedure<z.ZodObject<{
|
|
37
37
|
port: z.ZodOptional<z.ZodNumber>;
|
|
38
38
|
interactive: z.ZodOptional<z.ZodBoolean>;
|
|
39
39
|
account: z.ZodOptional<z.ZodString>;
|
|
@@ -49,8 +49,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
49
49
|
}>;
|
|
50
50
|
url: z.ZodString;
|
|
51
51
|
error: z.ZodOptional<z.ZodString>;
|
|
52
|
-
}, z.core.$strip>,
|
|
53
|
-
build:
|
|
52
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
53
|
+
build: ContractProcedure<z.ZodObject<{
|
|
54
54
|
packages: z.ZodDefault<z.ZodString>;
|
|
55
55
|
force: z.ZodDefault<z.ZodBoolean>;
|
|
56
56
|
deploy: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -62,8 +62,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
62
62
|
built: z.ZodArray<z.ZodString>;
|
|
63
63
|
skipped: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
64
64
|
deployed: z.ZodOptional<z.ZodBoolean>;
|
|
65
|
-
}, z.core.$strip>,
|
|
66
|
-
config:
|
|
65
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
66
|
+
config: ContractProcedure<Schema<unknown, unknown>, z.ZodObject<{
|
|
67
67
|
config: z.ZodNullable<z.ZodObject<{
|
|
68
68
|
account: z.ZodString;
|
|
69
69
|
extends: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
@@ -178,8 +178,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
178
178
|
}, z.core.$strip>>;
|
|
179
179
|
packages: z.ZodArray<z.ZodString>;
|
|
180
180
|
remotes: z.ZodArray<z.ZodString>;
|
|
181
|
-
}, z.core.$strip>,
|
|
182
|
-
pluginAdd:
|
|
181
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
182
|
+
pluginAdd: ContractProcedure<z.ZodObject<{
|
|
183
183
|
source: z.ZodString;
|
|
184
184
|
as: z.ZodOptional<z.ZodString>;
|
|
185
185
|
production: z.ZodOptional<z.ZodString>;
|
|
@@ -194,8 +194,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
194
194
|
integrity: z.ZodOptional<z.ZodString>;
|
|
195
195
|
version: z.ZodOptional<z.ZodString>;
|
|
196
196
|
error: z.ZodOptional<z.ZodString>;
|
|
197
|
-
}, z.core.$strip>,
|
|
198
|
-
pluginRemove:
|
|
197
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
198
|
+
pluginRemove: ContractProcedure<z.ZodObject<{
|
|
199
199
|
key: z.ZodString;
|
|
200
200
|
}, z.core.$strip>, z.ZodObject<{
|
|
201
201
|
status: z.ZodEnum<{
|
|
@@ -204,8 +204,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
204
204
|
}>;
|
|
205
205
|
key: z.ZodString;
|
|
206
206
|
error: z.ZodOptional<z.ZodString>;
|
|
207
|
-
}, z.core.$strip>,
|
|
208
|
-
pluginList:
|
|
207
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
208
|
+
pluginList: ContractProcedure<Schema<unknown, unknown>, z.ZodObject<{
|
|
209
209
|
status: z.ZodEnum<{
|
|
210
210
|
error: "error";
|
|
211
211
|
listed: "listed";
|
|
@@ -224,8 +224,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
224
224
|
name: z.ZodOptional<z.ZodString>;
|
|
225
225
|
}, z.core.$strip>>;
|
|
226
226
|
error: z.ZodOptional<z.ZodString>;
|
|
227
|
-
}, z.core.$strip>,
|
|
228
|
-
pluginPublish:
|
|
227
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
228
|
+
pluginPublish: ContractProcedure<z.ZodObject<{
|
|
229
229
|
key: z.ZodString;
|
|
230
230
|
}, z.core.$strip>, z.ZodObject<{
|
|
231
231
|
status: z.ZodEnum<{
|
|
@@ -239,8 +239,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
239
239
|
integrity: z.ZodOptional<z.ZodString>;
|
|
240
240
|
version: z.ZodOptional<z.ZodString>;
|
|
241
241
|
error: z.ZodOptional<z.ZodString>;
|
|
242
|
-
}, z.core.$strip>,
|
|
243
|
-
publish:
|
|
242
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
243
|
+
publish: ContractProcedure<z.ZodObject<{
|
|
244
244
|
deploy: z.ZodDefault<z.ZodBoolean>;
|
|
245
245
|
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
246
246
|
packages: z.ZodDefault<z.ZodString>;
|
|
@@ -260,8 +260,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
260
260
|
error: z.ZodOptional<z.ZodString>;
|
|
261
261
|
built: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
262
262
|
skipped: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
263
|
-
}, z.core.$strip>,
|
|
264
|
-
keyPublish:
|
|
263
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
264
|
+
keyPublish: ContractProcedure<z.ZodObject<{
|
|
265
265
|
allowance: z.ZodDefault<z.ZodString>;
|
|
266
266
|
}, z.core.$strip>, z.ZodObject<{
|
|
267
267
|
status: z.ZodEnum<{
|
|
@@ -279,8 +279,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
279
279
|
publicKey: z.ZodOptional<z.ZodString>;
|
|
280
280
|
privateKey: z.ZodOptional<z.ZodString>;
|
|
281
281
|
error: z.ZodOptional<z.ZodString>;
|
|
282
|
-
}, z.core.$strip>,
|
|
283
|
-
init:
|
|
282
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
283
|
+
init: ContractProcedure<z.ZodObject<{
|
|
284
284
|
extends: z.ZodOptional<z.ZodString>;
|
|
285
285
|
extendsAccount: z.ZodOptional<z.ZodString>;
|
|
286
286
|
extendsGateway: z.ZodOptional<z.ZodString>;
|
|
@@ -306,8 +306,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
306
306
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
307
307
|
filesCopied: z.ZodNumber;
|
|
308
308
|
error: z.ZodOptional<z.ZodString>;
|
|
309
|
-
}, z.core.$strip>,
|
|
310
|
-
sync:
|
|
309
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
310
|
+
sync: ContractProcedure<z.ZodObject<{
|
|
311
311
|
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
312
312
|
force: z.ZodDefault<z.ZodBoolean>;
|
|
313
313
|
noInstall: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -321,8 +321,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
321
321
|
skipped: z.ZodArray<z.ZodString>;
|
|
322
322
|
added: z.ZodArray<z.ZodString>;
|
|
323
323
|
error: z.ZodOptional<z.ZodString>;
|
|
324
|
-
}, z.core.$strip>,
|
|
325
|
-
upgrade:
|
|
324
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
325
|
+
upgrade: ContractProcedure<z.ZodObject<{
|
|
326
326
|
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
327
327
|
force: z.ZodDefault<z.ZodBoolean>;
|
|
328
328
|
noInstall: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -352,8 +352,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
352
352
|
migrated: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
353
353
|
changelogUrl: z.ZodOptional<z.ZodString>;
|
|
354
354
|
error: z.ZodOptional<z.ZodString>;
|
|
355
|
-
}, z.core.$strip>,
|
|
356
|
-
status:
|
|
355
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
356
|
+
status: ContractProcedure<Schema<unknown, unknown>, z.ZodObject<{
|
|
357
357
|
status: z.ZodEnum<{
|
|
358
358
|
error: "error";
|
|
359
359
|
ok: "ok";
|
|
@@ -374,11 +374,11 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
374
374
|
}>;
|
|
375
375
|
parentReachable: z.ZodOptional<z.ZodBoolean>;
|
|
376
376
|
error: z.ZodOptional<z.ZodString>;
|
|
377
|
-
}, z.core.$strip>,
|
|
378
|
-
typesGen:
|
|
377
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
378
|
+
typesGen: ContractProcedure<z.ZodObject<{
|
|
379
379
|
env: z.ZodOptional<z.ZodEnum<{
|
|
380
|
-
production: "production";
|
|
381
380
|
development: "development";
|
|
381
|
+
production: "production";
|
|
382
382
|
}>>;
|
|
383
383
|
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
384
384
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -395,7 +395,7 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
395
395
|
remote: "remote";
|
|
396
396
|
}>>;
|
|
397
397
|
error: z.ZodOptional<z.ZodString>;
|
|
398
|
-
}, z.core.$strip>,
|
|
398
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
399
399
|
}, z.ZodObject<{
|
|
400
400
|
configPath: z.ZodOptional<z.ZodString>;
|
|
401
401
|
}, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, undefined, {
|
|
@@ -500,7 +500,7 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
500
500
|
}> | undefined;
|
|
501
501
|
} | null;
|
|
502
502
|
runtimeConfig: {
|
|
503
|
-
env: "
|
|
503
|
+
env: "development" | "production" | "staging";
|
|
504
504
|
account: string;
|
|
505
505
|
networkId: "testnet" | "mainnet";
|
|
506
506
|
host: {
|
package/dist/plugin.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from "./sdk.mjs";
|
|
2
|
+
import { ContractProcedure, MergedErrorMap, Schema } from "./node_modules/@orpc/contract/dist/shared/contract.TuRtB1Ca.mjs";
|
|
2
3
|
import * as _$every_plugin0 from "every-plugin";
|
|
3
|
-
import * as _$_orpc_contract0 from "@orpc/contract";
|
|
4
4
|
|
|
5
5
|
//#region src/plugin.d.ts
|
|
6
6
|
declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
7
|
-
dev:
|
|
7
|
+
dev: ContractProcedure<z.ZodObject<{
|
|
8
8
|
host: z.ZodDefault<z.ZodEnum<{
|
|
9
9
|
local: "local";
|
|
10
10
|
remote: "remote";
|
|
@@ -32,8 +32,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
32
32
|
}>;
|
|
33
33
|
description: z.ZodString;
|
|
34
34
|
processes: z.ZodArray<z.ZodString>;
|
|
35
|
-
}, z.core.$strip>,
|
|
36
|
-
start:
|
|
35
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
36
|
+
start: ContractProcedure<z.ZodObject<{
|
|
37
37
|
port: z.ZodOptional<z.ZodNumber>;
|
|
38
38
|
interactive: z.ZodOptional<z.ZodBoolean>;
|
|
39
39
|
account: z.ZodOptional<z.ZodString>;
|
|
@@ -49,8 +49,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
49
49
|
}>;
|
|
50
50
|
url: z.ZodString;
|
|
51
51
|
error: z.ZodOptional<z.ZodString>;
|
|
52
|
-
}, z.core.$strip>,
|
|
53
|
-
build:
|
|
52
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
53
|
+
build: ContractProcedure<z.ZodObject<{
|
|
54
54
|
packages: z.ZodDefault<z.ZodString>;
|
|
55
55
|
force: z.ZodDefault<z.ZodBoolean>;
|
|
56
56
|
deploy: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -62,8 +62,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
62
62
|
built: z.ZodArray<z.ZodString>;
|
|
63
63
|
skipped: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
64
64
|
deployed: z.ZodOptional<z.ZodBoolean>;
|
|
65
|
-
}, z.core.$strip>,
|
|
66
|
-
config:
|
|
65
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
66
|
+
config: ContractProcedure<Schema<unknown, unknown>, z.ZodObject<{
|
|
67
67
|
config: z.ZodNullable<z.ZodObject<{
|
|
68
68
|
account: z.ZodString;
|
|
69
69
|
extends: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
@@ -178,8 +178,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
178
178
|
}, z.core.$strip>>;
|
|
179
179
|
packages: z.ZodArray<z.ZodString>;
|
|
180
180
|
remotes: z.ZodArray<z.ZodString>;
|
|
181
|
-
}, z.core.$strip>,
|
|
182
|
-
pluginAdd:
|
|
181
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
182
|
+
pluginAdd: ContractProcedure<z.ZodObject<{
|
|
183
183
|
source: z.ZodString;
|
|
184
184
|
as: z.ZodOptional<z.ZodString>;
|
|
185
185
|
production: z.ZodOptional<z.ZodString>;
|
|
@@ -194,8 +194,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
194
194
|
integrity: z.ZodOptional<z.ZodString>;
|
|
195
195
|
version: z.ZodOptional<z.ZodString>;
|
|
196
196
|
error: z.ZodOptional<z.ZodString>;
|
|
197
|
-
}, z.core.$strip>,
|
|
198
|
-
pluginRemove:
|
|
197
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
198
|
+
pluginRemove: ContractProcedure<z.ZodObject<{
|
|
199
199
|
key: z.ZodString;
|
|
200
200
|
}, z.core.$strip>, z.ZodObject<{
|
|
201
201
|
status: z.ZodEnum<{
|
|
@@ -204,8 +204,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
204
204
|
}>;
|
|
205
205
|
key: z.ZodString;
|
|
206
206
|
error: z.ZodOptional<z.ZodString>;
|
|
207
|
-
}, z.core.$strip>,
|
|
208
|
-
pluginList:
|
|
207
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
208
|
+
pluginList: ContractProcedure<Schema<unknown, unknown>, z.ZodObject<{
|
|
209
209
|
status: z.ZodEnum<{
|
|
210
210
|
error: "error";
|
|
211
211
|
listed: "listed";
|
|
@@ -224,8 +224,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
224
224
|
name: z.ZodOptional<z.ZodString>;
|
|
225
225
|
}, z.core.$strip>>;
|
|
226
226
|
error: z.ZodOptional<z.ZodString>;
|
|
227
|
-
}, z.core.$strip>,
|
|
228
|
-
pluginPublish:
|
|
227
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
228
|
+
pluginPublish: ContractProcedure<z.ZodObject<{
|
|
229
229
|
key: z.ZodString;
|
|
230
230
|
}, z.core.$strip>, z.ZodObject<{
|
|
231
231
|
status: z.ZodEnum<{
|
|
@@ -239,8 +239,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
239
239
|
integrity: z.ZodOptional<z.ZodString>;
|
|
240
240
|
version: z.ZodOptional<z.ZodString>;
|
|
241
241
|
error: z.ZodOptional<z.ZodString>;
|
|
242
|
-
}, z.core.$strip>,
|
|
243
|
-
publish:
|
|
242
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
243
|
+
publish: ContractProcedure<z.ZodObject<{
|
|
244
244
|
deploy: z.ZodDefault<z.ZodBoolean>;
|
|
245
245
|
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
246
246
|
packages: z.ZodDefault<z.ZodString>;
|
|
@@ -260,8 +260,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
260
260
|
error: z.ZodOptional<z.ZodString>;
|
|
261
261
|
built: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
262
262
|
skipped: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
263
|
-
}, z.core.$strip>,
|
|
264
|
-
keyPublish:
|
|
263
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
264
|
+
keyPublish: ContractProcedure<z.ZodObject<{
|
|
265
265
|
allowance: z.ZodDefault<z.ZodString>;
|
|
266
266
|
}, z.core.$strip>, z.ZodObject<{
|
|
267
267
|
status: z.ZodEnum<{
|
|
@@ -279,8 +279,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
279
279
|
publicKey: z.ZodOptional<z.ZodString>;
|
|
280
280
|
privateKey: z.ZodOptional<z.ZodString>;
|
|
281
281
|
error: z.ZodOptional<z.ZodString>;
|
|
282
|
-
}, z.core.$strip>,
|
|
283
|
-
init:
|
|
282
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
283
|
+
init: ContractProcedure<z.ZodObject<{
|
|
284
284
|
extends: z.ZodOptional<z.ZodString>;
|
|
285
285
|
extendsAccount: z.ZodOptional<z.ZodString>;
|
|
286
286
|
extendsGateway: z.ZodOptional<z.ZodString>;
|
|
@@ -306,8 +306,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
306
306
|
plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
307
307
|
filesCopied: z.ZodNumber;
|
|
308
308
|
error: z.ZodOptional<z.ZodString>;
|
|
309
|
-
}, z.core.$strip>,
|
|
310
|
-
sync:
|
|
309
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
310
|
+
sync: ContractProcedure<z.ZodObject<{
|
|
311
311
|
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
312
312
|
force: z.ZodDefault<z.ZodBoolean>;
|
|
313
313
|
noInstall: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -321,8 +321,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
321
321
|
skipped: z.ZodArray<z.ZodString>;
|
|
322
322
|
added: z.ZodArray<z.ZodString>;
|
|
323
323
|
error: z.ZodOptional<z.ZodString>;
|
|
324
|
-
}, z.core.$strip>,
|
|
325
|
-
upgrade:
|
|
324
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
325
|
+
upgrade: ContractProcedure<z.ZodObject<{
|
|
326
326
|
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
327
327
|
force: z.ZodDefault<z.ZodBoolean>;
|
|
328
328
|
noInstall: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -352,8 +352,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
352
352
|
migrated: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
353
353
|
changelogUrl: z.ZodOptional<z.ZodString>;
|
|
354
354
|
error: z.ZodOptional<z.ZodString>;
|
|
355
|
-
}, z.core.$strip>,
|
|
356
|
-
status:
|
|
355
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
356
|
+
status: ContractProcedure<Schema<unknown, unknown>, z.ZodObject<{
|
|
357
357
|
status: z.ZodEnum<{
|
|
358
358
|
error: "error";
|
|
359
359
|
ok: "ok";
|
|
@@ -374,11 +374,11 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
374
374
|
}>;
|
|
375
375
|
parentReachable: z.ZodOptional<z.ZodBoolean>;
|
|
376
376
|
error: z.ZodOptional<z.ZodString>;
|
|
377
|
-
}, z.core.$strip>,
|
|
378
|
-
typesGen:
|
|
377
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
378
|
+
typesGen: ContractProcedure<z.ZodObject<{
|
|
379
379
|
env: z.ZodOptional<z.ZodEnum<{
|
|
380
|
-
production: "production";
|
|
381
380
|
development: "development";
|
|
381
|
+
production: "production";
|
|
382
382
|
}>>;
|
|
383
383
|
dryRun: z.ZodDefault<z.ZodBoolean>;
|
|
384
384
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -395,7 +395,7 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
395
395
|
remote: "remote";
|
|
396
396
|
}>>;
|
|
397
397
|
error: z.ZodOptional<z.ZodString>;
|
|
398
|
-
}, z.core.$strip>,
|
|
398
|
+
}, z.core.$strip>, MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
399
399
|
}, z.ZodObject<{
|
|
400
400
|
configPath: z.ZodOptional<z.ZodString>;
|
|
401
401
|
}, z.core.$strip>, z.ZodObject<{}, z.core.$strip>, undefined, {
|
|
@@ -500,7 +500,7 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
|
|
|
500
500
|
}> | undefined;
|
|
501
501
|
} | null;
|
|
502
502
|
runtimeConfig: {
|
|
503
|
-
env: "
|
|
503
|
+
env: "development" | "production" | "staging";
|
|
504
504
|
account: string;
|
|
505
505
|
networkId: "testnet" | "mainnet";
|
|
506
506
|
host: {
|
package/dist/shared.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
1
|
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_merge = require('./merge.cjs');
|
|
4
3
|
const require_types = require('./types.cjs');
|
|
@@ -150,16 +149,7 @@ async function syncAndGenerateSharedUi(opts) {
|
|
|
150
149
|
resolved
|
|
151
150
|
};
|
|
152
151
|
}
|
|
153
|
-
function loadGeneratedSharedUi(configDir) {
|
|
154
|
-
const generatedPath = (0, node_path.join)(configDir, ".bos", "generated", "shared-ui.json");
|
|
155
|
-
try {
|
|
156
|
-
return JSON.parse((0, node_fs.readFileSync)(generatedPath, "utf-8"))?.ui ?? null;
|
|
157
|
-
} catch {
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
152
|
|
|
162
153
|
//#endregion
|
|
163
|
-
exports.loadGeneratedSharedUi = loadGeneratedSharedUi;
|
|
164
154
|
exports.syncAndGenerateSharedUi = syncAndGenerateSharedUi;
|
|
165
155
|
//# sourceMappingURL=shared.cjs.map
|
package/dist/shared.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.cjs","names":["BosConfigSchema","rebuildOrderedConfig"],"sources":["../src/shared.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { type BosEnv, type ResolvedConfigMeta, rebuildOrderedConfig } from \"./merge\";\nimport type { BosConfig, SharedDepConfig } from \"./types\";\nimport { BosConfigSchema } from \"./types\";\n\ninterface PackageJson {\n name?: string;\n private?: boolean;\n version?: string;\n workspaces?: {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n scripts?: Record<string, string>;\n}\n\nexport interface SharedUiResolvedDep {\n name: string;\n version: string;\n requiredVersion: string;\n shareScope: string;\n singleton: boolean;\n eager: boolean;\n strictVersion: boolean;\n}\n\nexport interface SharedUiResolved {\n deps: Record<string, SharedUiResolvedDep>;\n fingerprintSha256: string;\n}\n\nexport interface SharedSyncResult {\n mode: \"catalog->bos\" | \"bos->catalog\";\n hostMode: \"local\" | \"remote\";\n bosConfigChanged: boolean;\n catalogChanged: boolean;\n generatedChanged: boolean;\n resolved: SharedUiResolved;\n}\n\nfunction sha256(input: string): string {\n return createHash(\"sha256\").update(input).digest(\"hex\");\n}\n\nfunction extractSemverExact(input: unknown): string | null {\n if (typeof input !== \"string\") return null;\n const match = input.match(/\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?/);\n return match ? match[0] : null;\n}\n\nfunction caretRange(version: string): string {\n return `^${version}`;\n}\n\nfunction stableDepsObject(\n deps: Record<string, SharedUiResolvedDep>,\n): Record<string, SharedUiResolvedDep> {\n const keys = Object.keys(deps).sort((a, b) => a.localeCompare(b));\n const out: Record<string, SharedUiResolvedDep> = {};\n for (const k of keys) out[k] = deps[k]!;\n return out;\n}\n\nfunction writeFileIfChanged(filePath: string, nextContent: string): boolean {\n try {\n const current = readFileSync(filePath, \"utf-8\");\n if (current === nextContent) return false;\n } catch {\n // ignore\n }\n\n writeFileSync(filePath, nextContent);\n return true;\n}\n\nfunction fingerprintResolved(deps: Record<string, SharedUiResolvedDep>): string {\n const stable = stableDepsObject(deps);\n return sha256(JSON.stringify(stable));\n}\n\nfunction getSharedUiDeps(bosConfig: BosConfig): Record<string, SharedDepConfig> {\n const shared = bosConfig.shared ?? {};\n const ui = shared.ui ?? {};\n return ui;\n}\n\nexport async function syncAndGenerateSharedUi(opts: {\n configDir: string;\n hostMode: \"local\" | \"remote\";\n bosConfig?: BosConfig;\n env?: BosEnv;\n extendsChain?: string[];\n}): Promise<SharedSyncResult> {\n const bosConfigPath = join(opts.configDir, \"bos.config.json\");\n const resolvedConfigPath = join(opts.configDir, \".bos\", \"bos.resolved-config.json\");\n const packageJsonPath = join(opts.configDir, \"package.json\");\n const generatedPath = join(opts.configDir, \".bos\", \"generated\", \"shared-ui.json\");\n\n let bosConfig: BosConfig;\n if (opts.bosConfig) {\n bosConfig = opts.bosConfig;\n } else {\n const raw = JSON.parse(readFileSync(bosConfigPath, \"utf-8\")) as Record<string, unknown>;\n bosConfig = BosConfigSchema.parse(raw);\n }\n let pkgJson: PackageJson = {};\n try {\n pkgJson = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as PackageJson;\n } catch {\n // package.json might not exist\n }\n\n const originalBos = JSON.stringify(bosConfig);\n const originalPkg = JSON.stringify(pkgJson);\n\n const catalog = pkgJson?.workspaces?.catalog ?? {};\n const sharedUi = getSharedUiDeps(bosConfig);\n\n const mode = opts.hostMode === \"local\" ? \"catalog->bos\" : \"bos->catalog\";\n\n if (mode === \"catalog->bos\") {\n for (const [name, cfg] of Object.entries(sharedUi)) {\n const dep = cfg as SharedDepConfig;\n const version =\n catalog[name] ?? extractSemverExact(dep.version) ?? extractSemverExact(dep.requiredVersion);\n if (!version) continue;\n dep.version = version;\n dep.requiredVersion = caretRange(version);\n dep.shareScope = dep.shareScope ?? \"default\";\n }\n } else {\n for (const [name, cfg] of Object.entries(sharedUi)) {\n const dep = cfg as SharedDepConfig;\n const version = extractSemverExact(dep.version) ?? extractSemverExact(dep.requiredVersion);\n if (!version) continue;\n dep.version = version;\n dep.requiredVersion = caretRange(version);\n dep.shareScope = dep.shareScope ?? \"default\";\n if (catalog[name] !== version) {\n catalog[name] = version;\n }\n }\n if (!pkgJson.workspaces) pkgJson.workspaces = { packages: [], catalog: {} };\n pkgJson.workspaces.catalog = catalog;\n }\n\n const nextBos = JSON.stringify(bosConfig);\n const nextPkg = JSON.stringify(pkgJson);\n const bosConfigChanged = nextBos !== originalBos;\n const catalogChanged = nextPkg !== originalPkg;\n\n if (bosConfigChanged) {\n if (mode === \"catalog->bos\") {\n const resolvedDir = dirname(resolvedConfigPath);\n if (!existsSync(resolvedDir)) {\n mkdirSync(resolvedDir, { recursive: true });\n }\n const ordered = rebuildOrderedConfig(bosConfig);\n const meta: ResolvedConfigMeta = {\n env: opts.env ?? \"development\",\n resolvedAt: new Date().toISOString(),\n extendsChain: opts.extendsChain ?? [],\n source: \"shared-sync\",\n };\n const resolvedOutput = {\n _resolved: meta,\n ...ordered,\n };\n writeFileIfChanged(resolvedConfigPath, `${JSON.stringify(resolvedOutput, null, 2)}\\n`);\n } else {\n writeFileIfChanged(bosConfigPath, `${JSON.stringify(bosConfig, null, 2)}\\n`);\n }\n }\n if (catalogChanged) {\n writeFileIfChanged(packageJsonPath, `${JSON.stringify(pkgJson, null, 2)}\\n`);\n }\n\n const resolvedDeps: Record<string, SharedUiResolvedDep> = {};\n for (const [name, cfg] of Object.entries(getSharedUiDeps(bosConfig))) {\n const version =\n catalog[name] ?? extractSemverExact(cfg.version) ?? extractSemverExact(cfg.requiredVersion);\n if (!version) continue;\n resolvedDeps[name] = {\n name,\n version,\n requiredVersion: caretRange(version),\n shareScope: cfg.shareScope ?? \"default\",\n singleton: cfg.singleton ?? false,\n eager: cfg.eager ?? false,\n strictVersion: cfg.strictVersion ?? false,\n };\n }\n\n const stableResolvedDeps = stableDepsObject(resolvedDeps);\n const resolved: SharedUiResolved = {\n deps: stableResolvedDeps,\n fingerprintSha256: fingerprintResolved(stableResolvedDeps),\n };\n\n const nextGenerated = {\n schemaVersion: 1,\n kind: \"everything-dev/shared-ui\",\n generatedAt: new Date().toISOString(),\n ui: {\n deps: stableResolvedDeps,\n fingerprintSha256: resolved.fingerprintSha256,\n },\n inputs: {\n mode,\n hostMode: opts.hostMode,\n },\n };\n\n let prevFingerprint: string | null = null;\n try {\n const prev = JSON.parse(readFileSync(generatedPath, \"utf-8\"));\n prevFingerprint = prev?.ui?.fingerprintSha256 ?? null;\n } catch {\n // ignore\n }\n\n mkdirSync(dirname(generatedPath), { recursive: true });\n writeFileIfChanged(generatedPath, `${JSON.stringify(nextGenerated, null, 2)}\\n`);\n\n const generatedChanged = prevFingerprint !== nextGenerated.ui.fingerprintSha256;\n\n return {\n mode,\n hostMode: opts.hostMode,\n bosConfigChanged,\n catalogChanged,\n generatedChanged,\n resolved,\n };\n}\n\nexport function loadGeneratedSharedUi(configDir: string): SharedUiResolved | null {\n const generatedPath = join(configDir, \".bos\", \"generated\", \"shared-ui.json\");\n try {\n const content = JSON.parse(readFileSync(generatedPath, \"utf-8\"));\n return content?.ui ?? null;\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;;;;AA4CA,SAAS,OAAO,OAAuB;AACrC,oCAAkB,SAAS,CAAC,OAAO,MAAM,CAAC,OAAO,MAAM;;AAGzD,SAAS,mBAAmB,OAA+B;AACzD,KAAI,OAAO,UAAU,SAAU,QAAO;CACtC,MAAM,QAAQ,MAAM,MAAM,oCAAoC;AAC9D,QAAO,QAAQ,MAAM,KAAK;;AAG5B,SAAS,WAAW,SAAyB;AAC3C,QAAO,IAAI;;AAGb,SAAS,iBACP,MACqC;CACrC,MAAM,OAAO,OAAO,KAAK,KAAK,CAAC,MAAM,GAAG,MAAM,EAAE,cAAc,EAAE,CAAC;CACjE,MAAM,MAA2C,EAAE;AACnD,MAAK,MAAM,KAAK,KAAM,KAAI,KAAK,KAAK;AACpC,QAAO;;AAGT,SAAS,mBAAmB,UAAkB,aAA8B;AAC1E,KAAI;AAEF,gCAD6B,UAAU,QAAQ,KAC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IAAI,gBAAgB;AAC7F,MAAI,CAAC,QAAS;AACd,eAAa,QAAQ;GACnB;GACA;GACA,iBAAiB,WAAW,QAAQ;GACpC,YAAY,IAAI,cAAc;GAC9B,WAAW,IAAI,aAAa;GAC5B,OAAO,IAAI,SAAS;GACpB,eAAe,IAAI,iBAAiB;GACrC;;CAGH,MAAM,qBAAqB,iBAAiB,aAAa;CACzD,MAAM,WAA6B;EACjC,MAAM;EACN,mBAAmB,oBAAoB,mBAAmB;EAC3D;CAED,MAAM,gBAAgB;EACpB,eAAe;EACf,MAAM;EACN,8BAAa,IAAI,MAAM,EAAC,aAAa;EACrC,IAAI;GACF,MAAM;GACN,mBAAmB,SAAS;GAC7B;EACD,QAAQ;GACN;GACA,UAAU,KAAK;GAChB;EACF;CAED,IAAI,kBAAiC;AACrC,KAAI;AAEF,oBADa,KAAK,gCAAmB,eAAe,QAAQ,CAAC,EACrC,IAAI,qBAAqB;SAC3C;AAIR,+CAAkB,cAAc,EAAE,EAAE,WAAW,MAAM,CAAC;AACtD,oBAAmB,eAAe,GAAG,KAAK,UAAU,eAAe,MAAM,EAAE,CAAC,IAAI;CAEhF,MAAM,mBAAmB,oBAAoB,cAAc,GAAG;AAE9D,QAAO;EACL;EACA,UAAU,KAAK;EACf;EACA;EACA;EACA;EACD;;AAGH,SAAgB,sBAAsB,WAA4C;CAChF,MAAM,oCAAqB,WAAW,QAAQ,aAAa,iBAAiB;AAC5E,KAAI;AAEF,SADgB,KAAK,gCAAmB,eAAe,QAAQ,CAAC,EAChD,MAAM;SAChB;AACN,SAAO"}
|
|
1
|
+
{"version":3,"file":"shared.cjs","names":["BosConfigSchema","rebuildOrderedConfig"],"sources":["../src/shared.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { type BosEnv, type ResolvedConfigMeta, rebuildOrderedConfig } from \"./merge\";\nimport type { BosConfig, SharedDepConfig } from \"./types\";\nimport { BosConfigSchema } from \"./types\";\n\ninterface PackageJson {\n name?: string;\n private?: boolean;\n version?: string;\n workspaces?: {\n packages?: string[];\n catalog?: Record<string, string>;\n };\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n scripts?: Record<string, string>;\n}\n\nexport interface SharedUiResolvedDep {\n name: string;\n version: string;\n requiredVersion: string;\n shareScope: string;\n singleton: boolean;\n eager: boolean;\n strictVersion: boolean;\n}\n\nexport interface SharedUiResolved {\n deps: Record<string, SharedUiResolvedDep>;\n fingerprintSha256: string;\n}\n\nexport interface SharedSyncResult {\n mode: \"catalog->bos\" | \"bos->catalog\";\n hostMode: \"local\" | \"remote\";\n bosConfigChanged: boolean;\n catalogChanged: boolean;\n generatedChanged: boolean;\n resolved: SharedUiResolved;\n}\n\nfunction sha256(input: string): string {\n return createHash(\"sha256\").update(input).digest(\"hex\");\n}\n\nfunction extractSemverExact(input: unknown): string | null {\n if (typeof input !== \"string\") return null;\n const match = input.match(/\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?/);\n return match ? match[0] : null;\n}\n\nfunction caretRange(version: string): string {\n return `^${version}`;\n}\n\nfunction stableDepsObject(\n deps: Record<string, SharedUiResolvedDep>,\n): Record<string, SharedUiResolvedDep> {\n const keys = Object.keys(deps).sort((a, b) => a.localeCompare(b));\n const out: Record<string, SharedUiResolvedDep> = {};\n for (const k of keys) out[k] = deps[k]!;\n return out;\n}\n\nfunction writeFileIfChanged(filePath: string, nextContent: string): boolean {\n try {\n const current = readFileSync(filePath, \"utf-8\");\n if (current === nextContent) return false;\n } catch {\n // ignore\n }\n\n writeFileSync(filePath, nextContent);\n return true;\n}\n\nfunction fingerprintResolved(deps: Record<string, SharedUiResolvedDep>): string {\n const stable = stableDepsObject(deps);\n return sha256(JSON.stringify(stable));\n}\n\nfunction getSharedUiDeps(bosConfig: BosConfig): Record<string, SharedDepConfig> {\n const shared = bosConfig.shared ?? {};\n const ui = shared.ui ?? {};\n return ui;\n}\n\nexport async function syncAndGenerateSharedUi(opts: {\n configDir: string;\n hostMode: \"local\" | \"remote\";\n bosConfig?: BosConfig;\n env?: BosEnv;\n extendsChain?: string[];\n}): Promise<SharedSyncResult> {\n const bosConfigPath = join(opts.configDir, \"bos.config.json\");\n const resolvedConfigPath = join(opts.configDir, \".bos\", \"bos.resolved-config.json\");\n const packageJsonPath = join(opts.configDir, \"package.json\");\n const generatedPath = join(opts.configDir, \".bos\", \"generated\", \"shared-ui.json\");\n\n let bosConfig: BosConfig;\n if (opts.bosConfig) {\n bosConfig = opts.bosConfig;\n } else {\n const raw = JSON.parse(readFileSync(bosConfigPath, \"utf-8\")) as Record<string, unknown>;\n bosConfig = BosConfigSchema.parse(raw);\n }\n let pkgJson: PackageJson = {};\n try {\n pkgJson = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as PackageJson;\n } catch {\n // package.json might not exist\n }\n\n const originalBos = JSON.stringify(bosConfig);\n const originalPkg = JSON.stringify(pkgJson);\n\n const catalog = pkgJson?.workspaces?.catalog ?? {};\n const sharedUi = getSharedUiDeps(bosConfig);\n\n const mode = opts.hostMode === \"local\" ? \"catalog->bos\" : \"bos->catalog\";\n\n if (mode === \"catalog->bos\") {\n for (const [name, cfg] of Object.entries(sharedUi)) {\n const dep = cfg as SharedDepConfig;\n const version =\n catalog[name] ?? extractSemverExact(dep.version) ?? extractSemverExact(dep.requiredVersion);\n if (!version) continue;\n dep.version = version;\n dep.requiredVersion = caretRange(version);\n dep.shareScope = dep.shareScope ?? \"default\";\n }\n } else {\n for (const [name, cfg] of Object.entries(sharedUi)) {\n const dep = cfg as SharedDepConfig;\n const version = extractSemverExact(dep.version) ?? extractSemverExact(dep.requiredVersion);\n if (!version) continue;\n dep.version = version;\n dep.requiredVersion = caretRange(version);\n dep.shareScope = dep.shareScope ?? \"default\";\n if (catalog[name] !== version) {\n catalog[name] = version;\n }\n }\n if (!pkgJson.workspaces) pkgJson.workspaces = { packages: [], catalog: {} };\n pkgJson.workspaces.catalog = catalog;\n }\n\n const nextBos = JSON.stringify(bosConfig);\n const nextPkg = JSON.stringify(pkgJson);\n const bosConfigChanged = nextBos !== originalBos;\n const catalogChanged = nextPkg !== originalPkg;\n\n if (bosConfigChanged) {\n if (mode === \"catalog->bos\") {\n const resolvedDir = dirname(resolvedConfigPath);\n if (!existsSync(resolvedDir)) {\n mkdirSync(resolvedDir, { recursive: true });\n }\n const ordered = rebuildOrderedConfig(bosConfig);\n const meta: ResolvedConfigMeta = {\n env: opts.env ?? \"development\",\n resolvedAt: new Date().toISOString(),\n extendsChain: opts.extendsChain ?? [],\n source: \"shared-sync\",\n };\n const resolvedOutput = {\n _resolved: meta,\n ...ordered,\n };\n writeFileIfChanged(resolvedConfigPath, `${JSON.stringify(resolvedOutput, null, 2)}\\n`);\n } else {\n writeFileIfChanged(bosConfigPath, `${JSON.stringify(bosConfig, null, 2)}\\n`);\n }\n }\n if (catalogChanged) {\n writeFileIfChanged(packageJsonPath, `${JSON.stringify(pkgJson, null, 2)}\\n`);\n }\n\n const resolvedDeps: Record<string, SharedUiResolvedDep> = {};\n for (const [name, cfg] of Object.entries(getSharedUiDeps(bosConfig))) {\n const version =\n catalog[name] ?? extractSemverExact(cfg.version) ?? extractSemverExact(cfg.requiredVersion);\n if (!version) continue;\n resolvedDeps[name] = {\n name,\n version,\n requiredVersion: caretRange(version),\n shareScope: cfg.shareScope ?? \"default\",\n singleton: cfg.singleton ?? false,\n eager: cfg.eager ?? false,\n strictVersion: cfg.strictVersion ?? false,\n };\n }\n\n const stableResolvedDeps = stableDepsObject(resolvedDeps);\n const resolved: SharedUiResolved = {\n deps: stableResolvedDeps,\n fingerprintSha256: fingerprintResolved(stableResolvedDeps),\n };\n\n const nextGenerated = {\n schemaVersion: 1,\n kind: \"everything-dev/shared-ui\",\n generatedAt: new Date().toISOString(),\n ui: {\n deps: stableResolvedDeps,\n fingerprintSha256: resolved.fingerprintSha256,\n },\n inputs: {\n mode,\n hostMode: opts.hostMode,\n },\n };\n\n let prevFingerprint: string | null = null;\n try {\n const prev = JSON.parse(readFileSync(generatedPath, \"utf-8\"));\n prevFingerprint = prev?.ui?.fingerprintSha256 ?? null;\n } catch {\n // ignore\n }\n\n mkdirSync(dirname(generatedPath), { recursive: true });\n writeFileIfChanged(generatedPath, `${JSON.stringify(nextGenerated, null, 2)}\\n`);\n\n const generatedChanged = prevFingerprint !== nextGenerated.ui.fingerprintSha256;\n\n return {\n mode,\n hostMode: opts.hostMode,\n bosConfigChanged,\n catalogChanged,\n generatedChanged,\n resolved,\n };\n}\n\nexport function loadGeneratedSharedUi(configDir: string): SharedUiResolved | null {\n const generatedPath = join(configDir, \".bos\", \"generated\", \"shared-ui.json\");\n try {\n const content = JSON.parse(readFileSync(generatedPath, \"utf-8\"));\n return content?.ui ?? null;\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;;;AA4CA,SAAS,OAAO,OAAuB;AACrC,oCAAkB,SAAS,CAAC,OAAO,MAAM,CAAC,OAAO,MAAM;;AAGzD,SAAS,mBAAmB,OAA+B;AACzD,KAAI,OAAO,UAAU,SAAU,QAAO;CACtC,MAAM,QAAQ,MAAM,MAAM,oCAAoC;AAC9D,QAAO,QAAQ,MAAM,KAAK;;AAG5B,SAAS,WAAW,SAAyB;AAC3C,QAAO,IAAI;;AAGb,SAAS,iBACP,MACqC;CACrC,MAAM,OAAO,OAAO,KAAK,KAAK,CAAC,MAAM,GAAG,MAAM,EAAE,cAAc,EAAE,CAAC;CACjE,MAAM,MAA2C,EAAE;AACnD,MAAK,MAAM,KAAK,KAAM,KAAI,KAAK,KAAK;AACpC,QAAO;;AAGT,SAAS,mBAAmB,UAAkB,aAA8B;AAC1E,KAAI;AAEF,gCAD6B,UAAU,QAAQ,KAC/B,YAAa,QAAO;SAC9B;AAIR,4BAAc,UAAU,YAAY;AACpC,QAAO;;AAGT,SAAS,oBAAoB,MAAmD;CAC9E,MAAM,SAAS,iBAAiB,KAAK;AACrC,QAAO,OAAO,KAAK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AC5B,OAAO,IAAI,SAAS;GACpB,eAAe,IAAI,iBAAiB;GACrC;;CAGH,MAAM,qBAAqB,iBAAiB,aAAa;CACzD,MAAM,WAA6B;EACjC,MAAM;EACN,mBAAmB,oBAAoB,mBAAmB;EAC3D;CAED,MAAM,gBAAgB;EACpB,eAAe;EACf,MAAM;EACN,8BAAa,IAAI,MAAM,EAAC,aAAa;EACrC,IAAI;GACF,MAAM;GACN,mBAAmB,SAAS;GAC7B;EACD,QAAQ;GACN;GACA,UAAU,KAAK;GAChB;EACF;CAED,IAAI,kBAAiC;AACrC,KAAI;AAEF,oBADa,KAAK,gCAAmB,eAAe,QAAQ,CAAC,EACrC,IAAI,qBAAqB;SAC3C;AAIR,+CAAkB,cAAc,EAAE,EAAE,WAAW,MAAM,CAAC;AACtD,oBAAmB,eAAe,GAAG,KAAK,UAAU,eAAe,MAAM,EAAE,CAAC,IAAI;CAEhF,MAAM,mBAAmB,oBAAoB,cAAc,GAAG;AAE9D,QAAO;EACL;EACA,UAAU,KAAK;EACf;EACA;EACA;EACA;EACD"}
|
package/dist/shared.mjs
CHANGED
|
@@ -148,15 +148,7 @@ async function syncAndGenerateSharedUi(opts) {
|
|
|
148
148
|
resolved
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
|
-
function loadGeneratedSharedUi(configDir) {
|
|
152
|
-
const generatedPath = join(configDir, ".bos", "generated", "shared-ui.json");
|
|
153
|
-
try {
|
|
154
|
-
return JSON.parse(readFileSync(generatedPath, "utf-8"))?.ui ?? null;
|
|
155
|
-
} catch {
|
|
156
|
-
return null;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
151
|
|
|
160
152
|
//#endregion
|
|
161
|
-
export {
|
|
153
|
+
export { syncAndGenerateSharedUi };
|
|
162
154
|
//# sourceMappingURL=shared.mjs.map
|