everything-dev 1.51.2 → 1.51.3

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.
@@ -36,8 +36,8 @@ declare const DevOptionsSchema: z.ZodObject<{
36
36
  }, z.core.$strip>;
37
37
  declare const DevResultSchema: z.ZodObject<{
38
38
  status: z.ZodEnum<{
39
- started: "started";
40
39
  error: "error";
40
+ started: "started";
41
41
  }>;
42
42
  description: z.ZodString;
43
43
  processes: z.ZodArray<z.ZodString>;
@@ -377,20 +377,20 @@ declare const KeyPublishResultSchema: z.ZodObject<{
377
377
  error: z.ZodOptional<z.ZodString>;
378
378
  }, z.core.$strip>;
379
379
  declare const OverrideSectionSchema: z.ZodEnum<{
380
- host: "host";
380
+ plugins: "plugins";
381
381
  ui: "ui";
382
+ host: "host";
382
383
  api: "api";
383
- plugins: "plugins";
384
384
  }>;
385
385
  declare const RuntimeOverrideTargetBaseSchema: z.ZodEnum<{
386
+ plugins: "plugins";
386
387
  ui: "ui";
387
388
  api: "api";
388
- plugins: "plugins";
389
389
  }>;
390
390
  declare const RuntimeOverrideTargetSchema: z.ZodUnion<readonly [z.ZodEnum<{
391
+ plugins: "plugins";
391
392
  ui: "ui";
392
393
  api: "api";
393
- plugins: "plugins";
394
394
  }>, z.ZodString]>;
395
395
  declare const InitOptionsSchema: z.ZodObject<{
396
396
  extends: z.ZodOptional<z.ZodString>;
@@ -400,10 +400,10 @@ declare const InitOptionsSchema: z.ZodObject<{
400
400
  source: z.ZodOptional<z.ZodString>;
401
401
  plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
402
402
  overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
403
- host: "host";
403
+ plugins: "plugins";
404
404
  ui: "ui";
405
+ host: "host";
405
406
  api: "api";
406
- plugins: "plugins";
407
407
  }>>>;
408
408
  noInteractive: z.ZodDefault<z.ZodBoolean>;
409
409
  noInstall: z.ZodDefault<z.ZodBoolean>;
@@ -420,10 +420,10 @@ declare const InitResultSchema: z.ZodObject<{
420
420
  extends: z.ZodString;
421
421
  plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
422
422
  overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
423
- host: "host";
423
+ plugins: "plugins";
424
424
  ui: "ui";
425
+ host: "host";
425
426
  api: "api";
426
- plugins: "plugins";
427
427
  }>>>;
428
428
  filesCopied: z.ZodNumber;
429
429
  timings: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -511,8 +511,8 @@ declare const StatusResultSchema: z.ZodObject<{
511
511
  }, z.core.$strip>;
512
512
  declare const TypesGenOptionsSchema: z.ZodObject<{
513
513
  env: z.ZodOptional<z.ZodEnum<{
514
- production: "production";
515
514
  development: "development";
515
+ production: "production";
516
516
  }>>;
517
517
  dryRun: z.ZodDefault<z.ZodBoolean>;
518
518
  }, z.core.$strip>;
@@ -698,8 +698,8 @@ declare const bosContract: {
698
698
  interactive: z.ZodOptional<z.ZodBoolean>;
699
699
  }, z.core.$strip>, z.ZodObject<{
700
700
  status: z.ZodEnum<{
701
- started: "started";
702
701
  error: "error";
702
+ started: "started";
703
703
  }>;
704
704
  description: z.ZodString;
705
705
  processes: z.ZodArray<z.ZodString>;
@@ -1024,10 +1024,10 @@ declare const bosContract: {
1024
1024
  source: z.ZodOptional<z.ZodString>;
1025
1025
  plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
1026
1026
  overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
1027
- host: "host";
1027
+ plugins: "plugins";
1028
1028
  ui: "ui";
1029
+ host: "host";
1029
1030
  api: "api";
1030
- plugins: "plugins";
1031
1031
  }>>>;
1032
1032
  noInteractive: z.ZodDefault<z.ZodBoolean>;
1033
1033
  noInstall: z.ZodDefault<z.ZodBoolean>;
@@ -1043,10 +1043,10 @@ declare const bosContract: {
1043
1043
  extends: z.ZodString;
1044
1044
  plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
1045
1045
  overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
1046
- host: "host";
1046
+ plugins: "plugins";
1047
1047
  ui: "ui";
1048
+ host: "host";
1048
1049
  api: "api";
1049
- plugins: "plugins";
1050
1050
  }>>>;
1051
1051
  filesCopied: z.ZodNumber;
1052
1052
  timings: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -1132,8 +1132,8 @@ declare const bosContract: {
1132
1132
  }, z.core.$strip>, _$_orpc_contract0.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
1133
1133
  typesGen: _$_orpc_contract0.ContractProcedure<z.ZodObject<{
1134
1134
  env: z.ZodOptional<z.ZodEnum<{
1135
- production: "production";
1136
1135
  development: "development";
1136
+ production: "production";
1137
1137
  }>>;
1138
1138
  dryRun: z.ZodDefault<z.ZodBoolean>;
1139
1139
  }, z.core.$strip>, z.ZodObject<{
@@ -36,8 +36,8 @@ declare const DevOptionsSchema: z.ZodObject<{
36
36
  }, z.core.$strip>;
37
37
  declare const DevResultSchema: z.ZodObject<{
38
38
  status: z.ZodEnum<{
39
- started: "started";
40
39
  error: "error";
40
+ started: "started";
41
41
  }>;
42
42
  description: z.ZodString;
43
43
  processes: z.ZodArray<z.ZodString>;
@@ -377,20 +377,20 @@ declare const KeyPublishResultSchema: z.ZodObject<{
377
377
  error: z.ZodOptional<z.ZodString>;
378
378
  }, z.core.$strip>;
379
379
  declare const OverrideSectionSchema: z.ZodEnum<{
380
- host: "host";
380
+ plugins: "plugins";
381
381
  ui: "ui";
382
+ host: "host";
382
383
  api: "api";
383
- plugins: "plugins";
384
384
  }>;
385
385
  declare const RuntimeOverrideTargetBaseSchema: z.ZodEnum<{
386
+ plugins: "plugins";
386
387
  ui: "ui";
387
388
  api: "api";
388
- plugins: "plugins";
389
389
  }>;
390
390
  declare const RuntimeOverrideTargetSchema: z.ZodUnion<readonly [z.ZodEnum<{
391
+ plugins: "plugins";
391
392
  ui: "ui";
392
393
  api: "api";
393
- plugins: "plugins";
394
394
  }>, z.ZodString]>;
395
395
  declare const InitOptionsSchema: z.ZodObject<{
396
396
  extends: z.ZodOptional<z.ZodString>;
@@ -400,10 +400,10 @@ declare const InitOptionsSchema: z.ZodObject<{
400
400
  source: z.ZodOptional<z.ZodString>;
401
401
  plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
402
402
  overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
403
- host: "host";
403
+ plugins: "plugins";
404
404
  ui: "ui";
405
+ host: "host";
405
406
  api: "api";
406
- plugins: "plugins";
407
407
  }>>>;
408
408
  noInteractive: z.ZodDefault<z.ZodBoolean>;
409
409
  noInstall: z.ZodDefault<z.ZodBoolean>;
@@ -420,10 +420,10 @@ declare const InitResultSchema: z.ZodObject<{
420
420
  extends: z.ZodString;
421
421
  plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
422
422
  overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
423
- host: "host";
423
+ plugins: "plugins";
424
424
  ui: "ui";
425
+ host: "host";
425
426
  api: "api";
426
- plugins: "plugins";
427
427
  }>>>;
428
428
  filesCopied: z.ZodNumber;
429
429
  timings: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -511,8 +511,8 @@ declare const StatusResultSchema: z.ZodObject<{
511
511
  }, z.core.$strip>;
512
512
  declare const TypesGenOptionsSchema: z.ZodObject<{
513
513
  env: z.ZodOptional<z.ZodEnum<{
514
- production: "production";
515
514
  development: "development";
515
+ production: "production";
516
516
  }>>;
517
517
  dryRun: z.ZodDefault<z.ZodBoolean>;
518
518
  }, z.core.$strip>;
@@ -698,8 +698,8 @@ declare const bosContract: {
698
698
  interactive: z.ZodOptional<z.ZodBoolean>;
699
699
  }, z.core.$strip>, z.ZodObject<{
700
700
  status: z.ZodEnum<{
701
- started: "started";
702
701
  error: "error";
702
+ started: "started";
703
703
  }>;
704
704
  description: z.ZodString;
705
705
  processes: z.ZodArray<z.ZodString>;
@@ -1024,10 +1024,10 @@ declare const bosContract: {
1024
1024
  source: z.ZodOptional<z.ZodString>;
1025
1025
  plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
1026
1026
  overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
1027
- host: "host";
1027
+ plugins: "plugins";
1028
1028
  ui: "ui";
1029
+ host: "host";
1029
1030
  api: "api";
1030
- plugins: "plugins";
1031
1031
  }>>>;
1032
1032
  noInteractive: z.ZodDefault<z.ZodBoolean>;
1033
1033
  noInstall: z.ZodDefault<z.ZodBoolean>;
@@ -1043,10 +1043,10 @@ declare const bosContract: {
1043
1043
  extends: z.ZodString;
1044
1044
  plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
1045
1045
  overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
1046
- host: "host";
1046
+ plugins: "plugins";
1047
1047
  ui: "ui";
1048
+ host: "host";
1048
1049
  api: "api";
1049
- plugins: "plugins";
1050
1050
  }>>>;
1051
1051
  filesCopied: z.ZodNumber;
1052
1052
  timings: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -1132,8 +1132,8 @@ declare const bosContract: {
1132
1132
  }, z.core.$strip>, _$_orpc_contract0.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
1133
1133
  typesGen: _$_orpc_contract0.ContractProcedure<z.ZodObject<{
1134
1134
  env: z.ZodOptional<z.ZodEnum<{
1135
- production: "production";
1136
1135
  development: "development";
1136
+ production: "production";
1137
1137
  }>>;
1138
1138
  dryRun: z.ZodDefault<z.ZodBoolean>;
1139
1139
  }, z.core.$strip>, z.ZodObject<{
@@ -268,7 +268,7 @@ function planInfra(input) {
268
268
  postgres: pgPorts,
269
269
  redis: rdPorts
270
270
  };
271
- require_infra.savePortState(input.configDir, {
271
+ if (process.env.BOS_NO_PERSIST_PORTS !== "1") require_infra.savePortState(input.configDir, {
272
272
  postgresPorts: pgPorts,
273
273
  redisPorts: rdPorts,
274
274
  devPorts: devPortsState
@@ -1 +1 @@
1
- {"version":3,"file":"planner.cjs","names":["Effect","loadPortState","PortAllocator","InfraError","getSecretGroups","buildOriginMap","buildDatabaseConfigs","buildRedisConfigs","buildDescription"],"sources":["../../src/infra/planner.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { resolve } from \"node:path\";\nimport { Effect } from \"effect\";\nimport { PortAllocator } from \"../app\";\nimport {\n buildDatabaseConfigs,\n buildOriginMap,\n buildRedisConfigs,\n type DatabaseSecretConfig,\n getSecretGroups,\n loadPortState,\n type RedisSecretConfig,\n savePortState,\n} from \"../cli/infra\";\nimport { buildDescription } from \"../service-descriptor\";\nimport type { RuntimeConfig } from \"../types\";\nimport type {\n ClaimRecord,\n CliPorts,\n ComposeModelPlan,\n DatabasePlan,\n InfraInput,\n InfraPlan,\n RedisPlan,\n ResolvedPorts,\n RuntimeLaunchSpec,\n ServiceDescriptorPlan,\n} from \"./types\";\nimport { InfraError } from \"./types\";\n\nconst DEFAULT_HOST_PORT = 3000;\nconst DEFAULT_API_PORT = 3001;\nconst DEFAULT_AUTH_PORT = 3002;\nconst DEFAULT_UI_PORT = 3003;\nconst DEFAULT_PLUGIN_PORT_START = 3010;\nconst POSTGRES_USER = \"everythingdev\";\nconst POSTGRES_PASSWORD = \"everythingdev\";\n\nexport function workspaceKey(configDir: string): string {\n const hash = createHash(\"sha256\").update(resolve(configDir)).digest(\"hex\");\n return hash.slice(0, 12);\n}\n\nfunction normalizeCliPorts(input: InfraInput[\"cli\"]): CliPorts {\n return {\n host: input.port,\n api: input.apiPort,\n auth: input.authPort,\n ui: input.uiPort,\n uiSsr: undefined,\n pluginsStart: input.pluginPortStart,\n plugins: input.plugins,\n };\n}\n\ninterface AllocateServicesResult {\n ports: ResolvedPorts;\n claims: ClaimRecord[];\n devPortsState: { host: number; api: number; auth: number; ui: number; pluginPortStart: number };\n}\n\nfunction allocateServices(\n cliPorts: CliPorts,\n plugins: Record<\n string,\n { source: string; localPath?: string; ui?: { source: string; localPath?: string } }\n >,\n configDir: string,\n): Effect.Effect<AllocateServicesResult, InfraError, PortAllocator> {\n return Effect.gen(function* () {\n const wKey = workspaceKey(configDir);\n const persisted = loadPortState(configDir).devPorts;\n const allocator = yield* PortAllocator;\n\n const hostPort = yield* allocator.pickAvailable(\n cliPorts.host ?? persisted?.host ?? DEFAULT_HOST_PORT,\n );\n\n const apiPort = yield* allocator.pickAvailable(\n cliPorts.api ?? persisted?.api ?? DEFAULT_API_PORT,\n );\n\n const authPort = yield* allocator.pickAvailable(\n cliPorts.auth ?? persisted?.auth ?? DEFAULT_AUTH_PORT,\n );\n\n const uiPort = yield* allocator.pickAvailable(cliPorts.ui ?? persisted?.ui ?? DEFAULT_UI_PORT);\n\n const uiSsrPort = yield* allocator.pickAvailable(cliPorts.uiSsr ?? uiPort + 1);\n\n const pluginApiPorts: Record<string, number> = {};\n const pluginUiPorts: Record<string, number> = {};\n\n const pluginKeys = Object.keys(plugins).sort();\n const pluginStart =\n cliPorts.pluginsStart ?? persisted?.pluginPortStart ?? DEFAULT_PLUGIN_PORT_START;\n let nextPluginPort = pluginStart;\n for (const pluginId of pluginKeys) {\n const pluginCfg = plugins[pluginId];\n const preferred = cliPorts.plugins?.[pluginId]?.api ?? nextPluginPort;\n const pluginPort = yield* allocator.pickAvailable(preferred);\n pluginApiPorts[pluginId] = pluginPort;\n nextPluginPort = pluginPort + 1;\n\n if (\n pluginCfg?.source === \"local\" &&\n pluginCfg?.localPath &&\n pluginCfg?.ui?.source === \"local\"\n ) {\n const uiPreferred = cliPorts.plugins?.[pluginId]?.ui ?? nextPluginPort;\n const pluginUiPort = yield* allocator.pickAvailable(uiPreferred);\n pluginUiPorts[pluginId] = pluginUiPort;\n nextPluginPort = pluginUiPort + 1;\n }\n }\n\n const resolved: ResolvedPorts = {\n host: hostPort,\n api: apiPort,\n auth: authPort,\n ui: uiPort,\n uiSsr: uiSsrPort,\n plugins: Object.fromEntries(\n Object.entries(pluginApiPorts).map(([k, v]) => [k, { api: v, ui: pluginUiPorts[k] }]),\n ),\n postgres: {},\n redis: {},\n };\n\n const devPortsState = {\n host: hostPort,\n api: apiPort,\n auth: authPort,\n ui: uiPort,\n pluginPortStart: pluginStart,\n };\n\n const claimPorts: Record<string, number> = {\n host: hostPort,\n api: apiPort,\n auth: authPort,\n ui: uiPort,\n uiSsr: uiSsrPort,\n };\n for (const [id, port] of Object.entries(pluginApiPorts)) {\n claimPorts[`plugin:${id}`] = port;\n }\n for (const [id, port] of Object.entries(pluginUiPorts)) {\n claimPorts[`plugin-ui:${id}`] = port;\n }\n\n const claim: ClaimRecord = {\n resourceKey: `workspace:${wKey}`,\n pid: process.pid,\n configDir,\n ports: claimPorts,\n startedAt: Date.now(),\n };\n\n return { ports: resolved, claims: [claim], devPortsState };\n }).pipe(\n Effect.mapError(\n (portErr) =>\n new InfraError({\n phase: \"allocate-services\",\n message: `Port allocation failed: ${String(portErr)}`,\n cause: portErr,\n }),\n ),\n );\n}\n\nfunction allocateDatabases(\n runtimeConfig: RuntimeConfig,\n configDir: string,\n): Effect.Effect<\n {\n postgres: Record<string, number>;\n redis: Record<string, number>;\n dbs: DatabasePlan[];\n redisPlans: RedisPlan[];\n },\n InfraError,\n PortAllocator\n> {\n return Effect.gen(function* () {\n const persisted = loadPortState(configDir);\n const groups = getSecretGroups(runtimeConfig);\n const allSecrets = groups.flatMap((group) => group.secrets);\n const originMap = buildOriginMap(configDir, runtimeConfig);\n const allocator = yield* PortAllocator;\n\n const infraDatabases: DatabaseSecretConfig[] = yield* Effect.sync(() =>\n buildDatabaseConfigs(allSecrets, originMap, { ...persisted.postgresPorts }),\n );\n const infraRedis: RedisSecretConfig[] = yield* Effect.sync(() =>\n buildRedisConfigs(allSecrets, originMap, { ...persisted.redisPorts }),\n );\n\n const postgres: Record<string, number> = {};\n const dbs: DatabasePlan[] = [];\n for (const db of infraDatabases) {\n const port = yield* allocator.pickAvailable(db.port);\n postgres[db.slug] = port;\n dbs.push({\n secret: db.secret,\n slug: db.slug,\n port,\n dbName: db.databaseName,\n containerName: db.containerName,\n volumeName: db.volumeName,\n url: `postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:${port}/${db.slug}_db`,\n });\n }\n\n const redis: Record<string, number> = {};\n const redisPlans: RedisPlan[] = [];\n for (const r of infraRedis) {\n const port = yield* allocator.pickAvailable(r.port);\n redis[r.slug] = port;\n redisPlans.push({\n secret: r.secret,\n slug: r.slug,\n port,\n containerName: r.containerName,\n volumeName: r.volumeName,\n url: `redis://localhost:${port}`,\n });\n }\n\n return { postgres, redis, dbs, redisPlans };\n }).pipe(\n Effect.mapError(\n (portErr) =>\n new InfraError({\n phase: \"allocate-databases\",\n message: `Database port allocation failed: ${String(portErr)}`,\n cause: portErr,\n }),\n ),\n );\n}\n\nexport function buildServiceDescriptors(\n runtimeConfig: RuntimeConfig,\n resolvedPorts: ResolvedPorts,\n): ServiceDescriptorPlan[] {\n const descriptors: ServiceDescriptorPlan[] = [];\n\n if (runtimeConfig.host) {\n const isLocal = runtimeConfig.host.source === \"local\";\n descriptors.push({\n key: \"host\",\n source: runtimeConfig.host.source,\n url: isLocal ? `http://localhost:${resolvedPorts.host}` : runtimeConfig.host.url,\n port: isLocal ? resolvedPorts.host : undefined,\n localPath: isLocal ? runtimeConfig.host.localPath : undefined,\n });\n }\n\n if (runtimeConfig.api) {\n const isLocal = runtimeConfig.api.source === \"local\";\n descriptors.push({\n key: \"api\",\n source: runtimeConfig.api.source,\n url: isLocal ? `http://localhost:${resolvedPorts.api}` : runtimeConfig.api.url,\n port: isLocal ? resolvedPorts.api : undefined,\n localPath: isLocal ? runtimeConfig.api.localPath : undefined,\n });\n }\n\n if (runtimeConfig.auth) {\n const isLocal = runtimeConfig.auth.source === \"local\";\n descriptors.push({\n key: \"auth\",\n source: runtimeConfig.auth.source,\n url: isLocal ? `http://localhost:${resolvedPorts.auth}` : runtimeConfig.auth.url,\n port: isLocal ? resolvedPorts.auth : undefined,\n localPath: isLocal ? runtimeConfig.auth.localPath : undefined,\n });\n }\n\n if (runtimeConfig.ui) {\n const isLocal = runtimeConfig.ui.source === \"local\";\n descriptors.push({\n key: \"ui\",\n source: runtimeConfig.ui.source,\n url: isLocal ? `http://localhost:${resolvedPorts.ui}` : runtimeConfig.ui.url,\n port: isLocal ? resolvedPorts.ui : undefined,\n localPath: isLocal ? runtimeConfig.ui.localPath : undefined,\n });\n if (isLocal && resolvedPorts.uiSsr) {\n descriptors.push({\n key: \"ui-ssr\",\n source: \"local\",\n url: `http://localhost:${resolvedPorts.uiSsr}`,\n port: resolvedPorts.uiSsr,\n localPath: runtimeConfig.ui.localPath,\n });\n }\n }\n\n if (runtimeConfig.plugins) {\n for (const [pluginId, pluginCfg] of Object.entries(runtimeConfig.plugins)) {\n const pluginIsLocal = pluginCfg.source === \"local\";\n const p = resolvedPorts.plugins[pluginId];\n if (pluginIsLocal && p?.api) {\n descriptors.push({\n key: `plugin:${pluginId}`,\n source: \"local\",\n url: `http://localhost:${p.api}`,\n port: p.api,\n localPath: pluginCfg.localPath,\n });\n }\n if (!pluginIsLocal && pluginCfg.url) {\n descriptors.push({\n key: `plugin:${pluginId}`,\n source: \"remote\",\n url: pluginCfg.url,\n port: undefined,\n localPath: undefined,\n });\n }\n if (pluginIsLocal && p?.ui && pluginCfg.ui?.source === \"local\") {\n descriptors.push({\n key: `plugin-ui:${pluginId}`,\n source: \"local\",\n url: `http://localhost:${p.ui}`,\n port: p.ui,\n localPath: pluginCfg.ui?.localPath,\n });\n }\n }\n }\n\n return descriptors;\n}\n\nexport function buildLaunchSpec(\n runtimeConfig: RuntimeConfig,\n resolvedPorts: ResolvedPorts,\n): RuntimeLaunchSpec {\n const hostPort =\n runtimeConfig.host?.source === \"local\" ? resolvedPorts.host : runtimeConfig.host?.port;\n const corsOrigin = hostPort ? `http://localhost:${hostPort}` : `http://localhost:3000`;\n\n return {\n port: resolvedPorts.host,\n hostUrl: runtimeConfig.host?.url,\n corsOrigin,\n env: {\n ...(resolvedPorts.host ? { PORT: String(resolvedPorts.host) } : {}),\n ...(resolvedPorts.api ? { API_PORT: String(resolvedPorts.api) } : {}),\n ...(resolvedPorts.ui ? { UI_PORT: String(resolvedPorts.ui) } : {}),\n ...(resolvedPorts.auth ? { AUTH_PORT: String(resolvedPorts.auth) } : {}),\n },\n runtimeConfig,\n };\n}\n\nexport function buildComposeModel(dbs: DatabasePlan[], redisPlans: RedisPlan[]): ComposeModelPlan {\n return { databases: dbs, redis: redisPlans };\n}\n\nexport function buildEnvGenerated(\n resolvedPorts: ResolvedPorts,\n dbs: DatabasePlan[],\n redisPlans: RedisPlan[],\n): Record<string, string> {\n const env: Record<string, string> = {};\n\n if (resolvedPorts.host) {\n env.CORS_ORIGIN = `http://localhost:${resolvedPorts.host}`;\n }\n\n for (const db of dbs) {\n env[db.secret] = db.url;\n }\n for (const r of redisPlans) {\n env[r.secret] = r.url;\n }\n\n return env;\n}\n\nexport function planInfra(input: InfraInput): Effect.Effect<InfraPlan, InfraError, PortAllocator> {\n return Effect.gen(function* () {\n const cliPorts = normalizeCliPorts(input.cli);\n const wKey = workspaceKey(input.configDir);\n\n const plugins = (input.bosConfig.plugins ?? {}) as Record<\n string,\n { source: string; localPath?: string; ui?: { source: string; localPath?: string } }\n >;\n\n const {\n ports: svcPorts,\n claims,\n devPortsState,\n } = yield* allocateServices(cliPorts, plugins, input.configDir);\n\n const {\n dbs,\n redisPlans,\n postgres: pgPorts,\n redis: rdPorts,\n } = yield* allocateDatabases(input.bosConfig, input.configDir);\n\n const resolvedPorts: ResolvedPorts = {\n ...svcPorts,\n postgres: pgPorts,\n redis: rdPorts,\n };\n\n // Write merged state once after all allocations succeed\n savePortState(input.configDir, {\n postgresPorts: pgPorts,\n redisPorts: rdPorts,\n devPorts: devPortsState,\n });\n\n const hostIsLocal = input.bosConfig.host?.source === \"local\";\n const apiIsLocal = input.bosConfig.api?.source === \"local\";\n const uiIsLocal = input.bosConfig.ui?.source === \"local\";\n const authIsLocal = input.bosConfig.auth?.source === \"local\";\n const assignedRuntimeConfig: RuntimeConfig = {\n ...input.bosConfig,\n host: resolvedPorts.host\n ? {\n ...input.bosConfig.host,\n port: resolvedPorts.host,\n url: `http://localhost:${resolvedPorts.host}`,\n remoteUrl: !hostIsLocal\n ? (input.bosConfig.host.remoteUrl ?? input.bosConfig.host.url)\n : undefined,\n }\n : input.bosConfig.host,\n api:\n apiIsLocal && resolvedPorts.api\n ? {\n ...input.bosConfig.api,\n port: resolvedPorts.api,\n url: `http://localhost:${resolvedPorts.api}`,\n }\n : input.bosConfig.api,\n ui:\n uiIsLocal && resolvedPorts.ui\n ? {\n ...input.bosConfig.ui,\n port: resolvedPorts.ui,\n url: `http://localhost:${resolvedPorts.ui}`,\n }\n : input.bosConfig.ui,\n auth:\n authIsLocal && resolvedPorts.auth && input.bosConfig.auth\n ? {\n ...input.bosConfig.auth,\n port: resolvedPorts.auth,\n url: `http://localhost:${resolvedPorts.auth}`,\n }\n : input.bosConfig.auth,\n plugins: input.bosConfig.plugins\n ? Object.fromEntries(\n Object.entries(input.bosConfig.plugins).map(([id, p]) => {\n const pluginPort = resolvedPorts.plugins[id];\n if (p.source === \"local\" && pluginPort?.api) {\n return [\n id,\n { ...p, port: pluginPort.api, url: `http://localhost:${pluginPort.api}` },\n ];\n }\n return [id, p];\n }),\n )\n : undefined,\n };\n\n const serviceDescriptors = buildServiceDescriptors(input.bosConfig, resolvedPorts);\n\n const launch = buildLaunchSpec(input.bosConfig, resolvedPorts);\n const composeModel = buildComposeModel(dbs, redisPlans);\n const envGenerated = buildEnvGenerated(resolvedPorts, dbs, redisPlans);\n\n const packages = serviceDescriptors.map((d) => d.key);\n const descriptionMap = new Map(serviceDescriptors.map((d) => [d.key, d]));\n const description = buildDescription(descriptionMap);\n\n const orchestrator = {\n packages,\n env: {},\n description,\n port: resolvedPorts.host,\n interactive: input.cli.interactive,\n };\n\n return {\n workspaceKey: wKey,\n cliPorts,\n resolvedPorts,\n runtimeConfig: assignedRuntimeConfig,\n launch,\n description,\n serviceDescriptors: new Map(serviceDescriptors.map((d) => [d.key, d])),\n envGenerated,\n composeModel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AAM,UAAU;IACnB,MAAM,cAAc;IACpB,KAAK,oBAAoB,cAAc;IACxC,GACD,MAAM,UAAU;GACtB,SAAS,MAAM,UAAU,UACrB,OAAO,YACL,OAAO,QAAQ,MAAM,UAAU,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO;IACvD,MAAM,aAAa,cAAc,QAAQ;AACzC,QAAI,EAAE,WAAW,WAAW,YAAY,IACtC,QAAO,CACL,IACA;KAAE,GAAG;KAAG,MAAM,WAAW;KAAK,KAAK,oBAAoB,WAAW;KAAO,CAC1E;AAEH,WAAO,CAAC,IAAI,EAAE;KACd,CACH,GACD;GACL;EAED,MAAM,qBAAqB,wBAAwB,MAAM,WAAW,cAAc;EAElF,MAAM,SAAS,gBAAgB,MAAM,WAAW,cAAc;EAC9D,MAAM,eAAe,kBAAkB,KAAK,WAAW;EACvD,MAAM,eAAe,kBAAkB,eAAe,KAAK,WAAW;EAEtE,MAAM,WAAW,mBAAmB,KAAK,MAAM,EAAE,IAAI;EAErD,MAAM,cAAcQ,4CAAiB,IADV,IAAI,mBAAmB,KAAK,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CACrB,CAAC;EAEpD,MAAM,eAAe;GACnB;GACA,KAAK,EAAE;GACP;GACA,MAAM,cAAc;GACpB,aAAa,MAAM,IAAI;GACxB;AAED,SAAO;GACL,cAAc;GACd;GACA;GACA,eAAe;GACf;GACA;GACA,oBAAoB,IAAI,IAAI,mBAAmB,KAAK,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;GACtE;GACA;GACA;GACA;GACD;GACD"}
1
+ {"version":3,"file":"planner.cjs","names":["Effect","loadPortState","PortAllocator","InfraError","getSecretGroups","buildOriginMap","buildDatabaseConfigs","buildRedisConfigs","buildDescription"],"sources":["../../src/infra/planner.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { resolve } from \"node:path\";\nimport { Effect } from \"effect\";\nimport { PortAllocator } from \"../app\";\nimport {\n buildDatabaseConfigs,\n buildOriginMap,\n buildRedisConfigs,\n type DatabaseSecretConfig,\n getSecretGroups,\n loadPortState,\n type RedisSecretConfig,\n savePortState,\n} from \"../cli/infra\";\nimport { buildDescription } from \"../service-descriptor\";\nimport type { RuntimeConfig } from \"../types\";\nimport type {\n ClaimRecord,\n CliPorts,\n ComposeModelPlan,\n DatabasePlan,\n InfraInput,\n InfraPlan,\n RedisPlan,\n ResolvedPorts,\n RuntimeLaunchSpec,\n ServiceDescriptorPlan,\n} from \"./types\";\nimport { InfraError } from \"./types\";\n\nconst DEFAULT_HOST_PORT = 3000;\nconst DEFAULT_API_PORT = 3001;\nconst DEFAULT_AUTH_PORT = 3002;\nconst DEFAULT_UI_PORT = 3003;\nconst DEFAULT_PLUGIN_PORT_START = 3010;\nconst POSTGRES_USER = \"everythingdev\";\nconst POSTGRES_PASSWORD = \"everythingdev\";\n\nexport function workspaceKey(configDir: string): string {\n const hash = createHash(\"sha256\").update(resolve(configDir)).digest(\"hex\");\n return hash.slice(0, 12);\n}\n\nfunction normalizeCliPorts(input: InfraInput[\"cli\"]): CliPorts {\n return {\n host: input.port,\n api: input.apiPort,\n auth: input.authPort,\n ui: input.uiPort,\n uiSsr: undefined,\n pluginsStart: input.pluginPortStart,\n plugins: input.plugins,\n };\n}\n\ninterface AllocateServicesResult {\n ports: ResolvedPorts;\n claims: ClaimRecord[];\n devPortsState: { host: number; api: number; auth: number; ui: number; pluginPortStart: number };\n}\n\nfunction allocateServices(\n cliPorts: CliPorts,\n plugins: Record<\n string,\n { source: string; localPath?: string; ui?: { source: string; localPath?: string } }\n >,\n configDir: string,\n): Effect.Effect<AllocateServicesResult, InfraError, PortAllocator> {\n return Effect.gen(function* () {\n const wKey = workspaceKey(configDir);\n const persisted = loadPortState(configDir).devPorts;\n const allocator = yield* PortAllocator;\n\n const hostPort = yield* allocator.pickAvailable(\n cliPorts.host ?? persisted?.host ?? DEFAULT_HOST_PORT,\n );\n\n const apiPort = yield* allocator.pickAvailable(\n cliPorts.api ?? persisted?.api ?? DEFAULT_API_PORT,\n );\n\n const authPort = yield* allocator.pickAvailable(\n cliPorts.auth ?? persisted?.auth ?? DEFAULT_AUTH_PORT,\n );\n\n const uiPort = yield* allocator.pickAvailable(cliPorts.ui ?? persisted?.ui ?? DEFAULT_UI_PORT);\n\n const uiSsrPort = yield* allocator.pickAvailable(cliPorts.uiSsr ?? uiPort + 1);\n\n const pluginApiPorts: Record<string, number> = {};\n const pluginUiPorts: Record<string, number> = {};\n\n const pluginKeys = Object.keys(plugins).sort();\n const pluginStart =\n cliPorts.pluginsStart ?? persisted?.pluginPortStart ?? DEFAULT_PLUGIN_PORT_START;\n let nextPluginPort = pluginStart;\n for (const pluginId of pluginKeys) {\n const pluginCfg = plugins[pluginId];\n const preferred = cliPorts.plugins?.[pluginId]?.api ?? nextPluginPort;\n const pluginPort = yield* allocator.pickAvailable(preferred);\n pluginApiPorts[pluginId] = pluginPort;\n nextPluginPort = pluginPort + 1;\n\n if (\n pluginCfg?.source === \"local\" &&\n pluginCfg?.localPath &&\n pluginCfg?.ui?.source === \"local\"\n ) {\n const uiPreferred = cliPorts.plugins?.[pluginId]?.ui ?? nextPluginPort;\n const pluginUiPort = yield* allocator.pickAvailable(uiPreferred);\n pluginUiPorts[pluginId] = pluginUiPort;\n nextPluginPort = pluginUiPort + 1;\n }\n }\n\n const resolved: ResolvedPorts = {\n host: hostPort,\n api: apiPort,\n auth: authPort,\n ui: uiPort,\n uiSsr: uiSsrPort,\n plugins: Object.fromEntries(\n Object.entries(pluginApiPorts).map(([k, v]) => [k, { api: v, ui: pluginUiPorts[k] }]),\n ),\n postgres: {},\n redis: {},\n };\n\n const devPortsState = {\n host: hostPort,\n api: apiPort,\n auth: authPort,\n ui: uiPort,\n pluginPortStart: pluginStart,\n };\n\n const claimPorts: Record<string, number> = {\n host: hostPort,\n api: apiPort,\n auth: authPort,\n ui: uiPort,\n uiSsr: uiSsrPort,\n };\n for (const [id, port] of Object.entries(pluginApiPorts)) {\n claimPorts[`plugin:${id}`] = port;\n }\n for (const [id, port] of Object.entries(pluginUiPorts)) {\n claimPorts[`plugin-ui:${id}`] = port;\n }\n\n const claim: ClaimRecord = {\n resourceKey: `workspace:${wKey}`,\n pid: process.pid,\n configDir,\n ports: claimPorts,\n startedAt: Date.now(),\n };\n\n return { ports: resolved, claims: [claim], devPortsState };\n }).pipe(\n Effect.mapError(\n (portErr) =>\n new InfraError({\n phase: \"allocate-services\",\n message: `Port allocation failed: ${String(portErr)}`,\n cause: portErr,\n }),\n ),\n );\n}\n\nfunction allocateDatabases(\n runtimeConfig: RuntimeConfig,\n configDir: string,\n): Effect.Effect<\n {\n postgres: Record<string, number>;\n redis: Record<string, number>;\n dbs: DatabasePlan[];\n redisPlans: RedisPlan[];\n },\n InfraError,\n PortAllocator\n> {\n return Effect.gen(function* () {\n const persisted = loadPortState(configDir);\n const groups = getSecretGroups(runtimeConfig);\n const allSecrets = groups.flatMap((group) => group.secrets);\n const originMap = buildOriginMap(configDir, runtimeConfig);\n const allocator = yield* PortAllocator;\n\n const infraDatabases: DatabaseSecretConfig[] = yield* Effect.sync(() =>\n buildDatabaseConfigs(allSecrets, originMap, { ...persisted.postgresPorts }),\n );\n const infraRedis: RedisSecretConfig[] = yield* Effect.sync(() =>\n buildRedisConfigs(allSecrets, originMap, { ...persisted.redisPorts }),\n );\n\n const postgres: Record<string, number> = {};\n const dbs: DatabasePlan[] = [];\n for (const db of infraDatabases) {\n const port = yield* allocator.pickAvailable(db.port);\n postgres[db.slug] = port;\n dbs.push({\n secret: db.secret,\n slug: db.slug,\n port,\n dbName: db.databaseName,\n containerName: db.containerName,\n volumeName: db.volumeName,\n url: `postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:${port}/${db.slug}_db`,\n });\n }\n\n const redis: Record<string, number> = {};\n const redisPlans: RedisPlan[] = [];\n for (const r of infraRedis) {\n const port = yield* allocator.pickAvailable(r.port);\n redis[r.slug] = port;\n redisPlans.push({\n secret: r.secret,\n slug: r.slug,\n port,\n containerName: r.containerName,\n volumeName: r.volumeName,\n url: `redis://localhost:${port}`,\n });\n }\n\n return { postgres, redis, dbs, redisPlans };\n }).pipe(\n Effect.mapError(\n (portErr) =>\n new InfraError({\n phase: \"allocate-databases\",\n message: `Database port allocation failed: ${String(portErr)}`,\n cause: portErr,\n }),\n ),\n );\n}\n\nexport function buildServiceDescriptors(\n runtimeConfig: RuntimeConfig,\n resolvedPorts: ResolvedPorts,\n): ServiceDescriptorPlan[] {\n const descriptors: ServiceDescriptorPlan[] = [];\n\n if (runtimeConfig.host) {\n const isLocal = runtimeConfig.host.source === \"local\";\n descriptors.push({\n key: \"host\",\n source: runtimeConfig.host.source,\n url: isLocal ? `http://localhost:${resolvedPorts.host}` : runtimeConfig.host.url,\n port: isLocal ? resolvedPorts.host : undefined,\n localPath: isLocal ? runtimeConfig.host.localPath : undefined,\n });\n }\n\n if (runtimeConfig.api) {\n const isLocal = runtimeConfig.api.source === \"local\";\n descriptors.push({\n key: \"api\",\n source: runtimeConfig.api.source,\n url: isLocal ? `http://localhost:${resolvedPorts.api}` : runtimeConfig.api.url,\n port: isLocal ? resolvedPorts.api : undefined,\n localPath: isLocal ? runtimeConfig.api.localPath : undefined,\n });\n }\n\n if (runtimeConfig.auth) {\n const isLocal = runtimeConfig.auth.source === \"local\";\n descriptors.push({\n key: \"auth\",\n source: runtimeConfig.auth.source,\n url: isLocal ? `http://localhost:${resolvedPorts.auth}` : runtimeConfig.auth.url,\n port: isLocal ? resolvedPorts.auth : undefined,\n localPath: isLocal ? runtimeConfig.auth.localPath : undefined,\n });\n }\n\n if (runtimeConfig.ui) {\n const isLocal = runtimeConfig.ui.source === \"local\";\n descriptors.push({\n key: \"ui\",\n source: runtimeConfig.ui.source,\n url: isLocal ? `http://localhost:${resolvedPorts.ui}` : runtimeConfig.ui.url,\n port: isLocal ? resolvedPorts.ui : undefined,\n localPath: isLocal ? runtimeConfig.ui.localPath : undefined,\n });\n if (isLocal && resolvedPorts.uiSsr) {\n descriptors.push({\n key: \"ui-ssr\",\n source: \"local\",\n url: `http://localhost:${resolvedPorts.uiSsr}`,\n port: resolvedPorts.uiSsr,\n localPath: runtimeConfig.ui.localPath,\n });\n }\n }\n\n if (runtimeConfig.plugins) {\n for (const [pluginId, pluginCfg] of Object.entries(runtimeConfig.plugins)) {\n const pluginIsLocal = pluginCfg.source === \"local\";\n const p = resolvedPorts.plugins[pluginId];\n if (pluginIsLocal && p?.api) {\n descriptors.push({\n key: `plugin:${pluginId}`,\n source: \"local\",\n url: `http://localhost:${p.api}`,\n port: p.api,\n localPath: pluginCfg.localPath,\n });\n }\n if (!pluginIsLocal && pluginCfg.url) {\n descriptors.push({\n key: `plugin:${pluginId}`,\n source: \"remote\",\n url: pluginCfg.url,\n port: undefined,\n localPath: undefined,\n });\n }\n if (pluginIsLocal && p?.ui && pluginCfg.ui?.source === \"local\") {\n descriptors.push({\n key: `plugin-ui:${pluginId}`,\n source: \"local\",\n url: `http://localhost:${p.ui}`,\n port: p.ui,\n localPath: pluginCfg.ui?.localPath,\n });\n }\n }\n }\n\n return descriptors;\n}\n\nexport function buildLaunchSpec(\n runtimeConfig: RuntimeConfig,\n resolvedPorts: ResolvedPorts,\n): RuntimeLaunchSpec {\n const hostPort =\n runtimeConfig.host?.source === \"local\" ? resolvedPorts.host : runtimeConfig.host?.port;\n const corsOrigin = hostPort ? `http://localhost:${hostPort}` : `http://localhost:3000`;\n\n return {\n port: resolvedPorts.host,\n hostUrl: runtimeConfig.host?.url,\n corsOrigin,\n env: {\n ...(resolvedPorts.host ? { PORT: String(resolvedPorts.host) } : {}),\n ...(resolvedPorts.api ? { API_PORT: String(resolvedPorts.api) } : {}),\n ...(resolvedPorts.ui ? { UI_PORT: String(resolvedPorts.ui) } : {}),\n ...(resolvedPorts.auth ? { AUTH_PORT: String(resolvedPorts.auth) } : {}),\n },\n runtimeConfig,\n };\n}\n\nexport function buildComposeModel(dbs: DatabasePlan[], redisPlans: RedisPlan[]): ComposeModelPlan {\n return { databases: dbs, redis: redisPlans };\n}\n\nexport function buildEnvGenerated(\n resolvedPorts: ResolvedPorts,\n dbs: DatabasePlan[],\n redisPlans: RedisPlan[],\n): Record<string, string> {\n const env: Record<string, string> = {};\n\n if (resolvedPorts.host) {\n env.CORS_ORIGIN = `http://localhost:${resolvedPorts.host}`;\n }\n\n for (const db of dbs) {\n env[db.secret] = db.url;\n }\n for (const r of redisPlans) {\n env[r.secret] = r.url;\n }\n\n return env;\n}\n\nexport function planInfra(input: InfraInput): Effect.Effect<InfraPlan, InfraError, PortAllocator> {\n return Effect.gen(function* () {\n const cliPorts = normalizeCliPorts(input.cli);\n const wKey = workspaceKey(input.configDir);\n\n const plugins = (input.bosConfig.plugins ?? {}) as Record<\n string,\n { source: string; localPath?: string; ui?: { source: string; localPath?: string } }\n >;\n\n const {\n ports: svcPorts,\n claims,\n devPortsState,\n } = yield* allocateServices(cliPorts, plugins, input.configDir);\n\n const {\n dbs,\n redisPlans,\n postgres: pgPorts,\n redis: rdPorts,\n } = yield* allocateDatabases(input.bosConfig, input.configDir);\n\n const resolvedPorts: ResolvedPorts = {\n ...svcPorts,\n postgres: pgPorts,\n redis: rdPorts,\n };\n\n // Write merged state once after all allocations succeed\n // Skip persistence for regression tests / ephemeral runs\n if (process.env.BOS_NO_PERSIST_PORTS !== \"1\") {\n savePortState(input.configDir, {\n postgresPorts: pgPorts,\n redisPorts: rdPorts,\n devPorts: devPortsState,\n });\n }\n\n const hostIsLocal = input.bosConfig.host?.source === \"local\";\n const apiIsLocal = input.bosConfig.api?.source === \"local\";\n const uiIsLocal = input.bosConfig.ui?.source === \"local\";\n const authIsLocal = input.bosConfig.auth?.source === \"local\";\n const assignedRuntimeConfig: RuntimeConfig = {\n ...input.bosConfig,\n host: resolvedPorts.host\n ? {\n ...input.bosConfig.host,\n port: resolvedPorts.host,\n url: `http://localhost:${resolvedPorts.host}`,\n remoteUrl: !hostIsLocal\n ? (input.bosConfig.host.remoteUrl ?? input.bosConfig.host.url)\n : undefined,\n }\n : input.bosConfig.host,\n api:\n apiIsLocal && resolvedPorts.api\n ? {\n ...input.bosConfig.api,\n port: resolvedPorts.api,\n url: `http://localhost:${resolvedPorts.api}`,\n }\n : input.bosConfig.api,\n ui:\n uiIsLocal && resolvedPorts.ui\n ? {\n ...input.bosConfig.ui,\n port: resolvedPorts.ui,\n url: `http://localhost:${resolvedPorts.ui}`,\n }\n : input.bosConfig.ui,\n auth:\n authIsLocal && resolvedPorts.auth && input.bosConfig.auth\n ? {\n ...input.bosConfig.auth,\n port: resolvedPorts.auth,\n url: `http://localhost:${resolvedPorts.auth}`,\n }\n : input.bosConfig.auth,\n plugins: input.bosConfig.plugins\n ? Object.fromEntries(\n Object.entries(input.bosConfig.plugins).map(([id, p]) => {\n const pluginPort = resolvedPorts.plugins[id];\n if (p.source === \"local\" && pluginPort?.api) {\n return [\n id,\n { ...p, port: pluginPort.api, url: `http://localhost:${pluginPort.api}` },\n ];\n }\n return [id, p];\n }),\n )\n : undefined,\n };\n\n const serviceDescriptors = buildServiceDescriptors(input.bosConfig, resolvedPorts);\n\n const launch = buildLaunchSpec(input.bosConfig, resolvedPorts);\n const composeModel = buildComposeModel(dbs, redisPlans);\n const envGenerated = buildEnvGenerated(resolvedPorts, dbs, redisPlans);\n\n const packages = serviceDescriptors.map((d) => d.key);\n const descriptionMap = new Map(serviceDescriptors.map((d) => [d.key, d]));\n const description = buildDescription(descriptionMap);\n\n const orchestrator = {\n packages,\n env: {},\n description,\n port: resolvedPorts.host,\n interactive: input.cli.interactive,\n };\n\n return {\n workspaceKey: wKey,\n cliPorts,\n resolvedPorts,\n runtimeConfig: assignedRuntimeConfig,\n launch,\n description,\n serviceDescriptors: new Map(serviceDescriptors.map((d) => [d.key, d])),\n envGenerated,\n composeModel,\n claims,\n orchestrator,\n };\n });\n}\n"],"mappings":";;;;;;;;;;AA8BA,MAAM,oBAAoB;AAC1B,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAC1B,MAAM,kBAAkB;AACx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B,OAAO,YACL,OAAO,QAAQ,MAAM,UAAU,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO;IACvD,MAAM,aAAa,cAAc,QAAQ;AACzC,QAAI,EAAE,WAAW,WAAW,YAAY,IACtC,QAAO,CACL,IACA;KAAE,GAAG;KAAG,MAAM,WAAW;KAAK,KAAK,oBAAoB,WAAW;KAAO,CAC1E;AAEH,WAAO,CAAC,IAAI,EAAE;KACd,CACH,GACD;GACL;EAED,MAAM,qBAAqB,wBAAwB,MAAM,WAAW,cAAc;EAElF,MAAM,SAAS,gBAAgB,MAAM,WAAW,cAAc;EAC9D,MAAM,eAAe,kBAAkB,KAAK,WAAW;EACvD,MAAM,eAAe,kBAAkB,eAAe,KAAK,WAAW;EAEtE,MAAM,WAAW,mBAAmB,KAAK,MAAM,EAAE,IAAI;EAErD,MAAM,cAAcQ,4CAAiB,IADV,IAAI,mBAAmB,KAAK,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CACrB,CAAC;EAEpD,MAAM,eAAe;GACnB;GACA,KAAK,EAAE;GACP;GACA,MAAM,cAAc;GACpB,aAAa,MAAM,IAAI;GACxB;AAED,SAAO;GACL,cAAc;GACd;GACA;GACA,eAAe;GACf;GACA;GACA,oBAAoB,IAAI,IAAI,mBAAmB,KAAK,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;GACtE;GACA;GACA;GACA;GACD;GACD"}
@@ -267,7 +267,7 @@ function planInfra(input) {
267
267
  postgres: pgPorts,
268
268
  redis: rdPorts
269
269
  };
270
- savePortState(input.configDir, {
270
+ if (process.env.BOS_NO_PERSIST_PORTS !== "1") savePortState(input.configDir, {
271
271
  postgresPorts: pgPorts,
272
272
  redisPorts: rdPorts,
273
273
  devPorts: devPortsState
@@ -1 +1 @@
1
- {"version":3,"file":"planner.mjs","names":[],"sources":["../../src/infra/planner.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { resolve } from \"node:path\";\nimport { Effect } from \"effect\";\nimport { PortAllocator } from \"../app\";\nimport {\n buildDatabaseConfigs,\n buildOriginMap,\n buildRedisConfigs,\n type DatabaseSecretConfig,\n getSecretGroups,\n loadPortState,\n type RedisSecretConfig,\n savePortState,\n} from \"../cli/infra\";\nimport { buildDescription } from \"../service-descriptor\";\nimport type { RuntimeConfig } from \"../types\";\nimport type {\n ClaimRecord,\n CliPorts,\n ComposeModelPlan,\n DatabasePlan,\n InfraInput,\n InfraPlan,\n RedisPlan,\n ResolvedPorts,\n RuntimeLaunchSpec,\n ServiceDescriptorPlan,\n} from \"./types\";\nimport { InfraError } from \"./types\";\n\nconst DEFAULT_HOST_PORT = 3000;\nconst DEFAULT_API_PORT = 3001;\nconst DEFAULT_AUTH_PORT = 3002;\nconst DEFAULT_UI_PORT = 3003;\nconst DEFAULT_PLUGIN_PORT_START = 3010;\nconst POSTGRES_USER = \"everythingdev\";\nconst POSTGRES_PASSWORD = \"everythingdev\";\n\nexport function workspaceKey(configDir: string): string {\n const hash = createHash(\"sha256\").update(resolve(configDir)).digest(\"hex\");\n return hash.slice(0, 12);\n}\n\nfunction normalizeCliPorts(input: InfraInput[\"cli\"]): CliPorts {\n return {\n host: input.port,\n api: input.apiPort,\n auth: input.authPort,\n ui: input.uiPort,\n uiSsr: undefined,\n pluginsStart: input.pluginPortStart,\n plugins: input.plugins,\n };\n}\n\ninterface AllocateServicesResult {\n ports: ResolvedPorts;\n claims: ClaimRecord[];\n devPortsState: { host: number; api: number; auth: number; ui: number; pluginPortStart: number };\n}\n\nfunction allocateServices(\n cliPorts: CliPorts,\n plugins: Record<\n string,\n { source: string; localPath?: string; ui?: { source: string; localPath?: string } }\n >,\n configDir: string,\n): Effect.Effect<AllocateServicesResult, InfraError, PortAllocator> {\n return Effect.gen(function* () {\n const wKey = workspaceKey(configDir);\n const persisted = loadPortState(configDir).devPorts;\n const allocator = yield* PortAllocator;\n\n const hostPort = yield* allocator.pickAvailable(\n cliPorts.host ?? persisted?.host ?? DEFAULT_HOST_PORT,\n );\n\n const apiPort = yield* allocator.pickAvailable(\n cliPorts.api ?? persisted?.api ?? DEFAULT_API_PORT,\n );\n\n const authPort = yield* allocator.pickAvailable(\n cliPorts.auth ?? persisted?.auth ?? DEFAULT_AUTH_PORT,\n );\n\n const uiPort = yield* allocator.pickAvailable(cliPorts.ui ?? persisted?.ui ?? DEFAULT_UI_PORT);\n\n const uiSsrPort = yield* allocator.pickAvailable(cliPorts.uiSsr ?? uiPort + 1);\n\n const pluginApiPorts: Record<string, number> = {};\n const pluginUiPorts: Record<string, number> = {};\n\n const pluginKeys = Object.keys(plugins).sort();\n const pluginStart =\n cliPorts.pluginsStart ?? persisted?.pluginPortStart ?? DEFAULT_PLUGIN_PORT_START;\n let nextPluginPort = pluginStart;\n for (const pluginId of pluginKeys) {\n const pluginCfg = plugins[pluginId];\n const preferred = cliPorts.plugins?.[pluginId]?.api ?? nextPluginPort;\n const pluginPort = yield* allocator.pickAvailable(preferred);\n pluginApiPorts[pluginId] = pluginPort;\n nextPluginPort = pluginPort + 1;\n\n if (\n pluginCfg?.source === \"local\" &&\n pluginCfg?.localPath &&\n pluginCfg?.ui?.source === \"local\"\n ) {\n const uiPreferred = cliPorts.plugins?.[pluginId]?.ui ?? nextPluginPort;\n const pluginUiPort = yield* allocator.pickAvailable(uiPreferred);\n pluginUiPorts[pluginId] = pluginUiPort;\n nextPluginPort = pluginUiPort + 1;\n }\n }\n\n const resolved: ResolvedPorts = {\n host: hostPort,\n api: apiPort,\n auth: authPort,\n ui: uiPort,\n uiSsr: uiSsrPort,\n plugins: Object.fromEntries(\n Object.entries(pluginApiPorts).map(([k, v]) => [k, { api: v, ui: pluginUiPorts[k] }]),\n ),\n postgres: {},\n redis: {},\n };\n\n const devPortsState = {\n host: hostPort,\n api: apiPort,\n auth: authPort,\n ui: uiPort,\n pluginPortStart: pluginStart,\n };\n\n const claimPorts: Record<string, number> = {\n host: hostPort,\n api: apiPort,\n auth: authPort,\n ui: uiPort,\n uiSsr: uiSsrPort,\n };\n for (const [id, port] of Object.entries(pluginApiPorts)) {\n claimPorts[`plugin:${id}`] = port;\n }\n for (const [id, port] of Object.entries(pluginUiPorts)) {\n claimPorts[`plugin-ui:${id}`] = port;\n }\n\n const claim: ClaimRecord = {\n resourceKey: `workspace:${wKey}`,\n pid: process.pid,\n configDir,\n ports: claimPorts,\n startedAt: Date.now(),\n };\n\n return { ports: resolved, claims: [claim], devPortsState };\n }).pipe(\n Effect.mapError(\n (portErr) =>\n new InfraError({\n phase: \"allocate-services\",\n message: `Port allocation failed: ${String(portErr)}`,\n cause: portErr,\n }),\n ),\n );\n}\n\nfunction allocateDatabases(\n runtimeConfig: RuntimeConfig,\n configDir: string,\n): Effect.Effect<\n {\n postgres: Record<string, number>;\n redis: Record<string, number>;\n dbs: DatabasePlan[];\n redisPlans: RedisPlan[];\n },\n InfraError,\n PortAllocator\n> {\n return Effect.gen(function* () {\n const persisted = loadPortState(configDir);\n const groups = getSecretGroups(runtimeConfig);\n const allSecrets = groups.flatMap((group) => group.secrets);\n const originMap = buildOriginMap(configDir, runtimeConfig);\n const allocator = yield* PortAllocator;\n\n const infraDatabases: DatabaseSecretConfig[] = yield* Effect.sync(() =>\n buildDatabaseConfigs(allSecrets, originMap, { ...persisted.postgresPorts }),\n );\n const infraRedis: RedisSecretConfig[] = yield* Effect.sync(() =>\n buildRedisConfigs(allSecrets, originMap, { ...persisted.redisPorts }),\n );\n\n const postgres: Record<string, number> = {};\n const dbs: DatabasePlan[] = [];\n for (const db of infraDatabases) {\n const port = yield* allocator.pickAvailable(db.port);\n postgres[db.slug] = port;\n dbs.push({\n secret: db.secret,\n slug: db.slug,\n port,\n dbName: db.databaseName,\n containerName: db.containerName,\n volumeName: db.volumeName,\n url: `postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:${port}/${db.slug}_db`,\n });\n }\n\n const redis: Record<string, number> = {};\n const redisPlans: RedisPlan[] = [];\n for (const r of infraRedis) {\n const port = yield* allocator.pickAvailable(r.port);\n redis[r.slug] = port;\n redisPlans.push({\n secret: r.secret,\n slug: r.slug,\n port,\n containerName: r.containerName,\n volumeName: r.volumeName,\n url: `redis://localhost:${port}`,\n });\n }\n\n return { postgres, redis, dbs, redisPlans };\n }).pipe(\n Effect.mapError(\n (portErr) =>\n new InfraError({\n phase: \"allocate-databases\",\n message: `Database port allocation failed: ${String(portErr)}`,\n cause: portErr,\n }),\n ),\n );\n}\n\nexport function buildServiceDescriptors(\n runtimeConfig: RuntimeConfig,\n resolvedPorts: ResolvedPorts,\n): ServiceDescriptorPlan[] {\n const descriptors: ServiceDescriptorPlan[] = [];\n\n if (runtimeConfig.host) {\n const isLocal = runtimeConfig.host.source === \"local\";\n descriptors.push({\n key: \"host\",\n source: runtimeConfig.host.source,\n url: isLocal ? `http://localhost:${resolvedPorts.host}` : runtimeConfig.host.url,\n port: isLocal ? resolvedPorts.host : undefined,\n localPath: isLocal ? runtimeConfig.host.localPath : undefined,\n });\n }\n\n if (runtimeConfig.api) {\n const isLocal = runtimeConfig.api.source === \"local\";\n descriptors.push({\n key: \"api\",\n source: runtimeConfig.api.source,\n url: isLocal ? `http://localhost:${resolvedPorts.api}` : runtimeConfig.api.url,\n port: isLocal ? resolvedPorts.api : undefined,\n localPath: isLocal ? runtimeConfig.api.localPath : undefined,\n });\n }\n\n if (runtimeConfig.auth) {\n const isLocal = runtimeConfig.auth.source === \"local\";\n descriptors.push({\n key: \"auth\",\n source: runtimeConfig.auth.source,\n url: isLocal ? `http://localhost:${resolvedPorts.auth}` : runtimeConfig.auth.url,\n port: isLocal ? resolvedPorts.auth : undefined,\n localPath: isLocal ? runtimeConfig.auth.localPath : undefined,\n });\n }\n\n if (runtimeConfig.ui) {\n const isLocal = runtimeConfig.ui.source === \"local\";\n descriptors.push({\n key: \"ui\",\n source: runtimeConfig.ui.source,\n url: isLocal ? `http://localhost:${resolvedPorts.ui}` : runtimeConfig.ui.url,\n port: isLocal ? resolvedPorts.ui : undefined,\n localPath: isLocal ? runtimeConfig.ui.localPath : undefined,\n });\n if (isLocal && resolvedPorts.uiSsr) {\n descriptors.push({\n key: \"ui-ssr\",\n source: \"local\",\n url: `http://localhost:${resolvedPorts.uiSsr}`,\n port: resolvedPorts.uiSsr,\n localPath: runtimeConfig.ui.localPath,\n });\n }\n }\n\n if (runtimeConfig.plugins) {\n for (const [pluginId, pluginCfg] of Object.entries(runtimeConfig.plugins)) {\n const pluginIsLocal = pluginCfg.source === \"local\";\n const p = resolvedPorts.plugins[pluginId];\n if (pluginIsLocal && p?.api) {\n descriptors.push({\n key: `plugin:${pluginId}`,\n source: \"local\",\n url: `http://localhost:${p.api}`,\n port: p.api,\n localPath: pluginCfg.localPath,\n });\n }\n if (!pluginIsLocal && pluginCfg.url) {\n descriptors.push({\n key: `plugin:${pluginId}`,\n source: \"remote\",\n url: pluginCfg.url,\n port: undefined,\n localPath: undefined,\n });\n }\n if (pluginIsLocal && p?.ui && pluginCfg.ui?.source === \"local\") {\n descriptors.push({\n key: `plugin-ui:${pluginId}`,\n source: \"local\",\n url: `http://localhost:${p.ui}`,\n port: p.ui,\n localPath: pluginCfg.ui?.localPath,\n });\n }\n }\n }\n\n return descriptors;\n}\n\nexport function buildLaunchSpec(\n runtimeConfig: RuntimeConfig,\n resolvedPorts: ResolvedPorts,\n): RuntimeLaunchSpec {\n const hostPort =\n runtimeConfig.host?.source === \"local\" ? resolvedPorts.host : runtimeConfig.host?.port;\n const corsOrigin = hostPort ? `http://localhost:${hostPort}` : `http://localhost:3000`;\n\n return {\n port: resolvedPorts.host,\n hostUrl: runtimeConfig.host?.url,\n corsOrigin,\n env: {\n ...(resolvedPorts.host ? { PORT: String(resolvedPorts.host) } : {}),\n ...(resolvedPorts.api ? { API_PORT: String(resolvedPorts.api) } : {}),\n ...(resolvedPorts.ui ? { UI_PORT: String(resolvedPorts.ui) } : {}),\n ...(resolvedPorts.auth ? { AUTH_PORT: String(resolvedPorts.auth) } : {}),\n },\n runtimeConfig,\n };\n}\n\nexport function buildComposeModel(dbs: DatabasePlan[], redisPlans: RedisPlan[]): ComposeModelPlan {\n return { databases: dbs, redis: redisPlans };\n}\n\nexport function buildEnvGenerated(\n resolvedPorts: ResolvedPorts,\n dbs: DatabasePlan[],\n redisPlans: RedisPlan[],\n): Record<string, string> {\n const env: Record<string, string> = {};\n\n if (resolvedPorts.host) {\n env.CORS_ORIGIN = `http://localhost:${resolvedPorts.host}`;\n }\n\n for (const db of dbs) {\n env[db.secret] = db.url;\n }\n for (const r of redisPlans) {\n env[r.secret] = r.url;\n }\n\n return env;\n}\n\nexport function planInfra(input: InfraInput): Effect.Effect<InfraPlan, InfraError, PortAllocator> {\n return Effect.gen(function* () {\n const cliPorts = normalizeCliPorts(input.cli);\n const wKey = workspaceKey(input.configDir);\n\n const plugins = (input.bosConfig.plugins ?? {}) as Record<\n string,\n { source: string; localPath?: string; ui?: { source: string; localPath?: string } }\n >;\n\n const {\n ports: svcPorts,\n claims,\n devPortsState,\n } = yield* allocateServices(cliPorts, plugins, input.configDir);\n\n const {\n dbs,\n redisPlans,\n postgres: pgPorts,\n redis: rdPorts,\n } = yield* allocateDatabases(input.bosConfig, input.configDir);\n\n const resolvedPorts: ResolvedPorts = {\n ...svcPorts,\n postgres: pgPorts,\n redis: rdPorts,\n };\n\n // Write merged state once after all allocations succeed\n savePortState(input.configDir, {\n postgresPorts: pgPorts,\n redisPorts: rdPorts,\n devPorts: devPortsState,\n });\n\n const hostIsLocal = input.bosConfig.host?.source === \"local\";\n const apiIsLocal = input.bosConfig.api?.source === \"local\";\n const uiIsLocal = input.bosConfig.ui?.source === \"local\";\n const authIsLocal = input.bosConfig.auth?.source === \"local\";\n const assignedRuntimeConfig: RuntimeConfig = {\n ...input.bosConfig,\n host: resolvedPorts.host\n ? {\n ...input.bosConfig.host,\n port: resolvedPorts.host,\n url: `http://localhost:${resolvedPorts.host}`,\n remoteUrl: !hostIsLocal\n ? (input.bosConfig.host.remoteUrl ?? input.bosConfig.host.url)\n : undefined,\n }\n : input.bosConfig.host,\n api:\n apiIsLocal && resolvedPorts.api\n ? {\n ...input.bosConfig.api,\n port: resolvedPorts.api,\n url: `http://localhost:${resolvedPorts.api}`,\n }\n : input.bosConfig.api,\n ui:\n uiIsLocal && resolvedPorts.ui\n ? {\n ...input.bosConfig.ui,\n port: resolvedPorts.ui,\n url: `http://localhost:${resolvedPorts.ui}`,\n }\n : input.bosConfig.ui,\n auth:\n authIsLocal && resolvedPorts.auth && input.bosConfig.auth\n ? {\n ...input.bosConfig.auth,\n port: resolvedPorts.auth,\n url: `http://localhost:${resolvedPorts.auth}`,\n }\n : input.bosConfig.auth,\n plugins: input.bosConfig.plugins\n ? Object.fromEntries(\n Object.entries(input.bosConfig.plugins).map(([id, p]) => {\n const pluginPort = resolvedPorts.plugins[id];\n if (p.source === \"local\" && pluginPort?.api) {\n return [\n id,\n { ...p, port: pluginPort.api, url: `http://localhost:${pluginPort.api}` },\n ];\n }\n return [id, p];\n }),\n )\n : undefined,\n };\n\n const serviceDescriptors = buildServiceDescriptors(input.bosConfig, resolvedPorts);\n\n const launch = buildLaunchSpec(input.bosConfig, resolvedPorts);\n const composeModel = buildComposeModel(dbs, redisPlans);\n const envGenerated = buildEnvGenerated(resolvedPorts, dbs, redisPlans);\n\n const packages = serviceDescriptors.map((d) => d.key);\n const descriptionMap = new Map(serviceDescriptors.map((d) => [d.key, d]));\n const description = buildDescription(descriptionMap);\n\n const orchestrator = {\n packages,\n env: {},\n description,\n port: resolvedPorts.host,\n interactive: input.cli.interactive,\n };\n\n return {\n workspaceKey: wKey,\n cliPorts,\n resolvedPorts,\n runtimeConfig: assignedRuntimeConfig,\n launch,\n description,\n serviceDescriptors: new Map(serviceDescriptors.map((d) => [d.key, d])),\n envGenerated,\n composeModel,\n claims,\n orchestrator,\n };\n });\n}\n"],"mappings":";;;;;;;;;AA8BA,MAAM,oBAAoB;AAC1B,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAC1B,MAAM,kBAAkB;AACxB,MAAM,4BAA4B;AAClC,MAAM,g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D,MAAM,aAAa,cAAc,QAAQ;AACzC,QAAI,EAAE,WAAW,WAAW,YAAY,IACtC,QAAO,CACL,IACA;KAAE,GAAG;KAAG,MAAM,WAAW;KAAK,KAAK,oBAAoB,WAAW;KAAO,CAC1E;AAEH,WAAO,CAAC,IAAI,EAAE;KACd,CACH,GACD;GACL;EAED,MAAM,qBAAqB,wBAAwB,MAAM,WAAW,cAAc;EAElF,MAAM,SAAS,gBAAgB,MAAM,WAAW,cAAc;EAC9D,MAAM,eAAe,kBAAkB,KAAK,WAAW;EACvD,MAAM,eAAe,kBAAkB,eAAe,KAAK,WAAW;EAEtE,MAAM,WAAW,mBAAmB,KAAK,MAAM,EAAE,IAAI;EAErD,MAAM,cAAc,iBAAiB,IADV,IAAI,mBAAmB,KAAK,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CACrB,CAAC;EAEpD,MAAM,eAAe;GACnB;GACA,KAAK,EAAE;GACP;GACA,MAAM,cAAc;GACpB,aAAa,MAAM,IAAI;GACxB;AAED,SAAO;GACL,cAAc;GACd;GACA;GACA,eAAe;GACf;GACA;GACA,oBAAoB,IAAI,IAAI,mBAAmB,KAAK,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;GACtE;GACA;GACA;GACA;GACD;GACD"}
1
+ {"version":3,"file":"planner.mjs","names":[],"sources":["../../src/infra/planner.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { resolve } from \"node:path\";\nimport { Effect } from \"effect\";\nimport { PortAllocator } from \"../app\";\nimport {\n buildDatabaseConfigs,\n buildOriginMap,\n buildRedisConfigs,\n type DatabaseSecretConfig,\n getSecretGroups,\n loadPortState,\n type RedisSecretConfig,\n savePortState,\n} from \"../cli/infra\";\nimport { buildDescription } from \"../service-descriptor\";\nimport type { RuntimeConfig } from \"../types\";\nimport type {\n ClaimRecord,\n CliPorts,\n ComposeModelPlan,\n DatabasePlan,\n InfraInput,\n InfraPlan,\n RedisPlan,\n ResolvedPorts,\n RuntimeLaunchSpec,\n ServiceDescriptorPlan,\n} from \"./types\";\nimport { InfraError } from \"./types\";\n\nconst DEFAULT_HOST_PORT = 3000;\nconst DEFAULT_API_PORT = 3001;\nconst DEFAULT_AUTH_PORT = 3002;\nconst DEFAULT_UI_PORT = 3003;\nconst DEFAULT_PLUGIN_PORT_START = 3010;\nconst POSTGRES_USER = \"everythingdev\";\nconst POSTGRES_PASSWORD = \"everythingdev\";\n\nexport function workspaceKey(configDir: string): string {\n const hash = createHash(\"sha256\").update(resolve(configDir)).digest(\"hex\");\n return hash.slice(0, 12);\n}\n\nfunction normalizeCliPorts(input: InfraInput[\"cli\"]): CliPorts {\n return {\n host: input.port,\n api: input.apiPort,\n auth: input.authPort,\n ui: input.uiPort,\n uiSsr: undefined,\n pluginsStart: input.pluginPortStart,\n plugins: input.plugins,\n };\n}\n\ninterface AllocateServicesResult {\n ports: ResolvedPorts;\n claims: ClaimRecord[];\n devPortsState: { host: number; api: number; auth: number; ui: number; pluginPortStart: number };\n}\n\nfunction allocateServices(\n cliPorts: CliPorts,\n plugins: Record<\n string,\n { source: string; localPath?: string; ui?: { source: string; localPath?: string } }\n >,\n configDir: string,\n): Effect.Effect<AllocateServicesResult, InfraError, PortAllocator> {\n return Effect.gen(function* () {\n const wKey = workspaceKey(configDir);\n const persisted = loadPortState(configDir).devPorts;\n const allocator = yield* PortAllocator;\n\n const hostPort = yield* allocator.pickAvailable(\n cliPorts.host ?? persisted?.host ?? DEFAULT_HOST_PORT,\n );\n\n const apiPort = yield* allocator.pickAvailable(\n cliPorts.api ?? persisted?.api ?? DEFAULT_API_PORT,\n );\n\n const authPort = yield* allocator.pickAvailable(\n cliPorts.auth ?? persisted?.auth ?? DEFAULT_AUTH_PORT,\n );\n\n const uiPort = yield* allocator.pickAvailable(cliPorts.ui ?? persisted?.ui ?? DEFAULT_UI_PORT);\n\n const uiSsrPort = yield* allocator.pickAvailable(cliPorts.uiSsr ?? uiPort + 1);\n\n const pluginApiPorts: Record<string, number> = {};\n const pluginUiPorts: Record<string, number> = {};\n\n const pluginKeys = Object.keys(plugins).sort();\n const pluginStart =\n cliPorts.pluginsStart ?? persisted?.pluginPortStart ?? DEFAULT_PLUGIN_PORT_START;\n let nextPluginPort = pluginStart;\n for (const pluginId of pluginKeys) {\n const pluginCfg = plugins[pluginId];\n const preferred = cliPorts.plugins?.[pluginId]?.api ?? nextPluginPort;\n const pluginPort = yield* allocator.pickAvailable(preferred);\n pluginApiPorts[pluginId] = pluginPort;\n nextPluginPort = pluginPort + 1;\n\n if (\n pluginCfg?.source === \"local\" &&\n pluginCfg?.localPath &&\n pluginCfg?.ui?.source === \"local\"\n ) {\n const uiPreferred = cliPorts.plugins?.[pluginId]?.ui ?? nextPluginPort;\n const pluginUiPort = yield* allocator.pickAvailable(uiPreferred);\n pluginUiPorts[pluginId] = pluginUiPort;\n nextPluginPort = pluginUiPort + 1;\n }\n }\n\n const resolved: ResolvedPorts = {\n host: hostPort,\n api: apiPort,\n auth: authPort,\n ui: uiPort,\n uiSsr: uiSsrPort,\n plugins: Object.fromEntries(\n Object.entries(pluginApiPorts).map(([k, v]) => [k, { api: v, ui: pluginUiPorts[k] }]),\n ),\n postgres: {},\n redis: {},\n };\n\n const devPortsState = {\n host: hostPort,\n api: apiPort,\n auth: authPort,\n ui: uiPort,\n pluginPortStart: pluginStart,\n };\n\n const claimPorts: Record<string, number> = {\n host: hostPort,\n api: apiPort,\n auth: authPort,\n ui: uiPort,\n uiSsr: uiSsrPort,\n };\n for (const [id, port] of Object.entries(pluginApiPorts)) {\n claimPorts[`plugin:${id}`] = port;\n }\n for (const [id, port] of Object.entries(pluginUiPorts)) {\n claimPorts[`plugin-ui:${id}`] = port;\n }\n\n const claim: ClaimRecord = {\n resourceKey: `workspace:${wKey}`,\n pid: process.pid,\n configDir,\n ports: claimPorts,\n startedAt: Date.now(),\n };\n\n return { ports: resolved, claims: [claim], devPortsState };\n }).pipe(\n Effect.mapError(\n (portErr) =>\n new InfraError({\n phase: \"allocate-services\",\n message: `Port allocation failed: ${String(portErr)}`,\n cause: portErr,\n }),\n ),\n );\n}\n\nfunction allocateDatabases(\n runtimeConfig: RuntimeConfig,\n configDir: string,\n): Effect.Effect<\n {\n postgres: Record<string, number>;\n redis: Record<string, number>;\n dbs: DatabasePlan[];\n redisPlans: RedisPlan[];\n },\n InfraError,\n PortAllocator\n> {\n return Effect.gen(function* () {\n const persisted = loadPortState(configDir);\n const groups = getSecretGroups(runtimeConfig);\n const allSecrets = groups.flatMap((group) => group.secrets);\n const originMap = buildOriginMap(configDir, runtimeConfig);\n const allocator = yield* PortAllocator;\n\n const infraDatabases: DatabaseSecretConfig[] = yield* Effect.sync(() =>\n buildDatabaseConfigs(allSecrets, originMap, { ...persisted.postgresPorts }),\n );\n const infraRedis: RedisSecretConfig[] = yield* Effect.sync(() =>\n buildRedisConfigs(allSecrets, originMap, { ...persisted.redisPorts }),\n );\n\n const postgres: Record<string, number> = {};\n const dbs: DatabasePlan[] = [];\n for (const db of infraDatabases) {\n const port = yield* allocator.pickAvailable(db.port);\n postgres[db.slug] = port;\n dbs.push({\n secret: db.secret,\n slug: db.slug,\n port,\n dbName: db.databaseName,\n containerName: db.containerName,\n volumeName: db.volumeName,\n url: `postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:${port}/${db.slug}_db`,\n });\n }\n\n const redis: Record<string, number> = {};\n const redisPlans: RedisPlan[] = [];\n for (const r of infraRedis) {\n const port = yield* allocator.pickAvailable(r.port);\n redis[r.slug] = port;\n redisPlans.push({\n secret: r.secret,\n slug: r.slug,\n port,\n containerName: r.containerName,\n volumeName: r.volumeName,\n url: `redis://localhost:${port}`,\n });\n }\n\n return { postgres, redis, dbs, redisPlans };\n }).pipe(\n Effect.mapError(\n (portErr) =>\n new InfraError({\n phase: \"allocate-databases\",\n message: `Database port allocation failed: ${String(portErr)}`,\n cause: portErr,\n }),\n ),\n );\n}\n\nexport function buildServiceDescriptors(\n runtimeConfig: RuntimeConfig,\n resolvedPorts: ResolvedPorts,\n): ServiceDescriptorPlan[] {\n const descriptors: ServiceDescriptorPlan[] = [];\n\n if (runtimeConfig.host) {\n const isLocal = runtimeConfig.host.source === \"local\";\n descriptors.push({\n key: \"host\",\n source: runtimeConfig.host.source,\n url: isLocal ? `http://localhost:${resolvedPorts.host}` : runtimeConfig.host.url,\n port: isLocal ? resolvedPorts.host : undefined,\n localPath: isLocal ? runtimeConfig.host.localPath : undefined,\n });\n }\n\n if (runtimeConfig.api) {\n const isLocal = runtimeConfig.api.source === \"local\";\n descriptors.push({\n key: \"api\",\n source: runtimeConfig.api.source,\n url: isLocal ? `http://localhost:${resolvedPorts.api}` : runtimeConfig.api.url,\n port: isLocal ? resolvedPorts.api : undefined,\n localPath: isLocal ? runtimeConfig.api.localPath : undefined,\n });\n }\n\n if (runtimeConfig.auth) {\n const isLocal = runtimeConfig.auth.source === \"local\";\n descriptors.push({\n key: \"auth\",\n source: runtimeConfig.auth.source,\n url: isLocal ? `http://localhost:${resolvedPorts.auth}` : runtimeConfig.auth.url,\n port: isLocal ? resolvedPorts.auth : undefined,\n localPath: isLocal ? runtimeConfig.auth.localPath : undefined,\n });\n }\n\n if (runtimeConfig.ui) {\n const isLocal = runtimeConfig.ui.source === \"local\";\n descriptors.push({\n key: \"ui\",\n source: runtimeConfig.ui.source,\n url: isLocal ? `http://localhost:${resolvedPorts.ui}` : runtimeConfig.ui.url,\n port: isLocal ? resolvedPorts.ui : undefined,\n localPath: isLocal ? runtimeConfig.ui.localPath : undefined,\n });\n if (isLocal && resolvedPorts.uiSsr) {\n descriptors.push({\n key: \"ui-ssr\",\n source: \"local\",\n url: `http://localhost:${resolvedPorts.uiSsr}`,\n port: resolvedPorts.uiSsr,\n localPath: runtimeConfig.ui.localPath,\n });\n }\n }\n\n if (runtimeConfig.plugins) {\n for (const [pluginId, pluginCfg] of Object.entries(runtimeConfig.plugins)) {\n const pluginIsLocal = pluginCfg.source === \"local\";\n const p = resolvedPorts.plugins[pluginId];\n if (pluginIsLocal && p?.api) {\n descriptors.push({\n key: `plugin:${pluginId}`,\n source: \"local\",\n url: `http://localhost:${p.api}`,\n port: p.api,\n localPath: pluginCfg.localPath,\n });\n }\n if (!pluginIsLocal && pluginCfg.url) {\n descriptors.push({\n key: `plugin:${pluginId}`,\n source: \"remote\",\n url: pluginCfg.url,\n port: undefined,\n localPath: undefined,\n });\n }\n if (pluginIsLocal && p?.ui && pluginCfg.ui?.source === \"local\") {\n descriptors.push({\n key: `plugin-ui:${pluginId}`,\n source: \"local\",\n url: `http://localhost:${p.ui}`,\n port: p.ui,\n localPath: pluginCfg.ui?.localPath,\n });\n }\n }\n }\n\n return descriptors;\n}\n\nexport function buildLaunchSpec(\n runtimeConfig: RuntimeConfig,\n resolvedPorts: ResolvedPorts,\n): RuntimeLaunchSpec {\n const hostPort =\n runtimeConfig.host?.source === \"local\" ? resolvedPorts.host : runtimeConfig.host?.port;\n const corsOrigin = hostPort ? `http://localhost:${hostPort}` : `http://localhost:3000`;\n\n return {\n port: resolvedPorts.host,\n hostUrl: runtimeConfig.host?.url,\n corsOrigin,\n env: {\n ...(resolvedPorts.host ? { PORT: String(resolvedPorts.host) } : {}),\n ...(resolvedPorts.api ? { API_PORT: String(resolvedPorts.api) } : {}),\n ...(resolvedPorts.ui ? { UI_PORT: String(resolvedPorts.ui) } : {}),\n ...(resolvedPorts.auth ? { AUTH_PORT: String(resolvedPorts.auth) } : {}),\n },\n runtimeConfig,\n };\n}\n\nexport function buildComposeModel(dbs: DatabasePlan[], redisPlans: RedisPlan[]): ComposeModelPlan {\n return { databases: dbs, redis: redisPlans };\n}\n\nexport function buildEnvGenerated(\n resolvedPorts: ResolvedPorts,\n dbs: DatabasePlan[],\n redisPlans: RedisPlan[],\n): Record<string, string> {\n const env: Record<string, string> = {};\n\n if (resolvedPorts.host) {\n env.CORS_ORIGIN = `http://localhost:${resolvedPorts.host}`;\n }\n\n for (const db of dbs) {\n env[db.secret] = db.url;\n }\n for (const r of redisPlans) {\n env[r.secret] = r.url;\n }\n\n return env;\n}\n\nexport function planInfra(input: InfraInput): Effect.Effect<InfraPlan, InfraError, PortAllocator> {\n return Effect.gen(function* () {\n const cliPorts = normalizeCliPorts(input.cli);\n const wKey = workspaceKey(input.configDir);\n\n const plugins = (input.bosConfig.plugins ?? {}) as Record<\n string,\n { source: string; localPath?: string; ui?: { source: string; localPath?: string } }\n >;\n\n const {\n ports: svcPorts,\n claims,\n devPortsState,\n } = yield* allocateServices(cliPorts, plugins, input.configDir);\n\n const {\n dbs,\n redisPlans,\n postgres: pgPorts,\n redis: rdPorts,\n } = yield* allocateDatabases(input.bosConfig, input.configDir);\n\n const resolvedPorts: ResolvedPorts = {\n ...svcPorts,\n postgres: pgPorts,\n redis: rdPorts,\n };\n\n // Write merged state once after all allocations succeed\n // Skip persistence for regression tests / ephemeral runs\n if (process.env.BOS_NO_PERSIST_PORTS !== \"1\") {\n savePortState(input.configDir, {\n postgresPorts: pgPorts,\n redisPorts: rdPorts,\n devPorts: devPortsState,\n });\n }\n\n const hostIsLocal = input.bosConfig.host?.source === \"local\";\n const apiIsLocal = input.bosConfig.api?.source === \"local\";\n const uiIsLocal = input.bosConfig.ui?.source === \"local\";\n const authIsLocal = input.bosConfig.auth?.source === \"local\";\n const assignedRuntimeConfig: RuntimeConfig = {\n ...input.bosConfig,\n host: resolvedPorts.host\n ? {\n ...input.bosConfig.host,\n port: resolvedPorts.host,\n url: `http://localhost:${resolvedPorts.host}`,\n remoteUrl: !hostIsLocal\n ? (input.bosConfig.host.remoteUrl ?? input.bosConfig.host.url)\n : undefined,\n }\n : input.bosConfig.host,\n api:\n apiIsLocal && resolvedPorts.api\n ? {\n ...input.bosConfig.api,\n port: resolvedPorts.api,\n url: `http://localhost:${resolvedPorts.api}`,\n }\n : input.bosConfig.api,\n ui:\n uiIsLocal && resolvedPorts.ui\n ? {\n ...input.bosConfig.ui,\n port: resolvedPorts.ui,\n url: `http://localhost:${resolvedPorts.ui}`,\n }\n : input.bosConfig.ui,\n auth:\n authIsLocal && resolvedPorts.auth && input.bosConfig.auth\n ? {\n ...input.bosConfig.auth,\n port: resolvedPorts.auth,\n url: `http://localhost:${resolvedPorts.auth}`,\n }\n : input.bosConfig.auth,\n plugins: input.bosConfig.plugins\n ? Object.fromEntries(\n Object.entries(input.bosConfig.plugins).map(([id, p]) => {\n const pluginPort = resolvedPorts.plugins[id];\n if (p.source === \"local\" && pluginPort?.api) {\n return [\n id,\n { ...p, port: pluginPort.api, url: `http://localhost:${pluginPort.api}` },\n ];\n }\n return [id, p];\n }),\n )\n : undefined,\n };\n\n const serviceDescriptors = buildServiceDescriptors(input.bosConfig, resolvedPorts);\n\n const launch = buildLaunchSpec(input.bosConfig, resolvedPorts);\n const composeModel = buildComposeModel(dbs, redisPlans);\n const envGenerated = buildEnvGenerated(resolvedPorts, dbs, redisPlans);\n\n const packages = serviceDescriptors.map((d) => d.key);\n const descriptionMap = new Map(serviceDescriptors.map((d) => [d.key, d]));\n const description = buildDescription(descriptionMap);\n\n const orchestrator = {\n packages,\n env: {},\n description,\n port: resolvedPorts.host,\n interactive: input.cli.interactive,\n };\n\n return {\n workspaceKey: wKey,\n cliPorts,\n resolvedPorts,\n runtimeConfig: assignedRuntimeConfig,\n launch,\n description,\n serviceDescriptors: new Map(serviceDescriptors.map((d) => [d.key, d])),\n envGenerated,\n composeModel,\n claims,\n orchestrator,\n };\n });\n}\n"],"mappings":";;;;;;;;;AA8BA,MAAM,oBAAoB;AAC1B,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAC1B,MAAM,kBAAkB;AACxB,MAAM,4BAA4B;AAClC,MAAM,gBAAgB;AACtB,MAAM,oBAAoB;AAE1B,SAAgB,aAAa,WAA2B;AAEtD,QADa,WAAW,SAAS,CAAC,OAAO,QAAQ,UAAU,CAAC,CAAC,OAAO,MACzD,CAAC,MAAM,GAAG,GAAG;;AAG1B,SAAS,kBAAkB,OAAoC;AAC7D,QAAO;EACL,MAAM,MAAM;EACZ,KAAK,MAAM;EACX,MA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AED,MAAM,qBAAqB,wBAAwB,MAAM,WAAW,cAAc;EAElF,MAAM,SAAS,gBAAgB,MAAM,WAAW,cAAc;EAC9D,MAAM,eAAe,kBAAkB,KAAK,WAAW;EACvD,MAAM,eAAe,kBAAkB,eAAe,KAAK,WAAW;EAEtE,MAAM,WAAW,mBAAmB,KAAK,MAAM,EAAE,IAAI;EAErD,MAAM,cAAc,iBAAiB,IADV,IAAI,mBAAmB,KAAK,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CACrB,CAAC;EAEpD,MAAM,eAAe;GACnB;GACA,KAAK,EAAE;GACP;GACA,MAAM,cAAc;GACpB,aAAa,MAAM,IAAI;GACxB;AAED,SAAO;GACL,cAAc;GACd;GACA;GACA,eAAe;GACf;GACA;GACA,oBAAoB,IAAI,IAAI,mBAAmB,KAAK,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;GACtE;GACA;GACA;GACA;GACD;GACD"}
package/dist/plugin.d.cts CHANGED
@@ -64,8 +64,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
64
64
  interactive: z.ZodOptional<z.ZodBoolean>;
65
65
  }, z.core.$strip>, z.ZodObject<{
66
66
  status: z.ZodEnum<{
67
- started: "started";
68
67
  error: "error";
68
+ started: "started";
69
69
  }>;
70
70
  description: z.ZodString;
71
71
  processes: z.ZodArray<z.ZodString>;
@@ -390,10 +390,10 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
390
390
  source: z.ZodOptional<z.ZodString>;
391
391
  plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
392
392
  overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
393
- host: "host";
393
+ plugins: "plugins";
394
394
  ui: "ui";
395
+ host: "host";
395
396
  api: "api";
396
- plugins: "plugins";
397
397
  }>>>;
398
398
  noInteractive: z.ZodDefault<z.ZodBoolean>;
399
399
  noInstall: z.ZodDefault<z.ZodBoolean>;
@@ -409,10 +409,10 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
409
409
  extends: z.ZodString;
410
410
  plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
411
411
  overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
412
- host: "host";
412
+ plugins: "plugins";
413
413
  ui: "ui";
414
+ host: "host";
414
415
  api: "api";
415
- plugins: "plugins";
416
416
  }>>>;
417
417
  filesCopied: z.ZodNumber;
418
418
  timings: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -498,8 +498,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
498
498
  }, z.core.$strip>, _$_orpc_contract0.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
499
499
  typesGen: _$_orpc_contract0.ContractProcedure<z.ZodObject<{
500
500
  env: z.ZodOptional<z.ZodEnum<{
501
- production: "production";
502
501
  development: "development";
502
+ production: "production";
503
503
  }>>;
504
504
  dryRun: z.ZodDefault<z.ZodBoolean>;
505
505
  }, z.core.$strip>, z.ZodObject<{
@@ -737,7 +737,7 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
737
737
  }> | undefined;
738
738
  } | null;
739
739
  runtimeConfig: {
740
- env: "production" | "staging" | "development";
740
+ env: "development" | "production" | "staging";
741
741
  account: string;
742
742
  networkId: "testnet" | "mainnet";
743
743
  host: {
package/dist/plugin.d.mts CHANGED
@@ -64,8 +64,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
64
64
  interactive: z.ZodOptional<z.ZodBoolean>;
65
65
  }, z.core.$strip>, z.ZodObject<{
66
66
  status: z.ZodEnum<{
67
- started: "started";
68
67
  error: "error";
68
+ started: "started";
69
69
  }>;
70
70
  description: z.ZodString;
71
71
  processes: z.ZodArray<z.ZodString>;
@@ -390,10 +390,10 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
390
390
  source: z.ZodOptional<z.ZodString>;
391
391
  plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
392
392
  overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
393
- host: "host";
393
+ plugins: "plugins";
394
394
  ui: "ui";
395
+ host: "host";
395
396
  api: "api";
396
- plugins: "plugins";
397
397
  }>>>;
398
398
  noInteractive: z.ZodDefault<z.ZodBoolean>;
399
399
  noInstall: z.ZodDefault<z.ZodBoolean>;
@@ -409,10 +409,10 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
409
409
  extends: z.ZodString;
410
410
  plugins: z.ZodOptional<z.ZodArray<z.ZodString>>;
411
411
  overrides: z.ZodOptional<z.ZodArray<z.ZodEnum<{
412
- host: "host";
412
+ plugins: "plugins";
413
413
  ui: "ui";
414
+ host: "host";
414
415
  api: "api";
415
- plugins: "plugins";
416
416
  }>>>;
417
417
  filesCopied: z.ZodNumber;
418
418
  timings: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -498,8 +498,8 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
498
498
  }, z.core.$strip>, _$_orpc_contract0.MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
499
499
  typesGen: _$_orpc_contract0.ContractProcedure<z.ZodObject<{
500
500
  env: z.ZodOptional<z.ZodEnum<{
501
- production: "production";
502
501
  development: "development";
502
+ production: "production";
503
503
  }>>;
504
504
  dryRun: z.ZodDefault<z.ZodBoolean>;
505
505
  }, z.core.$strip>, z.ZodObject<{
@@ -737,7 +737,7 @@ declare const _default: _$every_plugin0.LoadedPluginWithBinding<{
737
737
  }> | undefined;
738
738
  } | null;
739
739
  runtimeConfig: {
740
- env: "production" | "staging" | "development";
740
+ env: "development" | "production" | "staging";
741
741
  account: string;
742
742
  networkId: "testnet" | "mainnet";
743
743
  host: {
package/dist/types.d.cts CHANGED
@@ -379,9 +379,9 @@ declare const BosConfigSchema: z.ZodObject<{
379
379
  type BosConfig = z.infer<typeof BosConfigSchema>;
380
380
  declare const RuntimeConfigSchema: z.ZodObject<{
381
381
  env: z.ZodEnum<{
382
+ development: "development";
382
383
  production: "production";
383
384
  staging: "staging";
384
- development: "development";
385
385
  }>;
386
386
  account: z.ZodString;
387
387
  domain: z.ZodOptional<z.ZodString>;
@@ -508,9 +508,9 @@ declare const RuntimeConfigSchema: z.ZodObject<{
508
508
  type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;
509
509
  declare const ClientRuntimeConfigSchema: z.ZodObject<{
510
510
  env: z.ZodEnum<{
511
+ development: "development";
511
512
  production: "production";
512
513
  staging: "staging";
513
- development: "development";
514
514
  }>;
515
515
  account: z.ZodString;
516
516
  networkId: z.ZodEnum<{
package/dist/types.d.mts CHANGED
@@ -379,9 +379,9 @@ declare const BosConfigSchema: z.ZodObject<{
379
379
  type BosConfig = z.infer<typeof BosConfigSchema>;
380
380
  declare const RuntimeConfigSchema: z.ZodObject<{
381
381
  env: z.ZodEnum<{
382
+ development: "development";
382
383
  production: "production";
383
384
  staging: "staging";
384
- development: "development";
385
385
  }>;
386
386
  account: z.ZodString;
387
387
  domain: z.ZodOptional<z.ZodString>;
@@ -508,9 +508,9 @@ declare const RuntimeConfigSchema: z.ZodObject<{
508
508
  type RuntimeConfig = z.infer<typeof RuntimeConfigSchema>;
509
509
  declare const ClientRuntimeConfigSchema: z.ZodObject<{
510
510
  env: z.ZodEnum<{
511
+ development: "development";
511
512
  production: "production";
512
513
  staging: "staging";
513
- development: "development";
514
514
  }>;
515
515
  account: z.ZodString;
516
516
  networkId: z.ZodEnum<{
package/dist/ui/head.cjs CHANGED
@@ -4,14 +4,18 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
  function getThemeInitScript() {
5
5
  return { children: "(function(){var t=localStorage.getItem('theme');if(t==='dark'||(!t&&window.matchMedia('(prefers-color-scheme: dark)').matches)){document.documentElement.classList.add('dark');}})();" };
6
6
  }
7
+ function escapeJsonForScript(value) {
8
+ return JSON.stringify(value).replace(/<\/script/gi, "<\\/script").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
9
+ }
7
10
  function getHydrateScript(runtimeConfig, containerName = "ui", hydratePath = "./Hydrate", cspNonce) {
8
11
  return { children: `
9
- window.__CSP_NONCE__=${JSON.stringify(cspNonce)};
10
- window.__RUNTIME_CONFIG__=${JSON.stringify(runtimeConfig)};
11
- function __hydrate(){
12
- if (window.__EVERYTHING_DEV_HYDRATE_PROMISE__) {
13
- return;
14
- }
12
+ window.__CSP_NONCE__=${cspNonce != null ? escapeJsonForScript(cspNonce) : null};
13
+ window.__RUNTIME_CONFIG__=${escapeJsonForScript(runtimeConfig)};
14
+ function __hydrate(){
15
+ if (window.__EVERYTHING_DEV_HYDRATE_PROMISE__) {
16
+ console.warn('[Hydrate] Already in progress, skipping duplicate call');
17
+ return;
18
+ }
15
19
  var container = window['${containerName}'];
16
20
  if (!container) {
17
21
  console.warn('[Hydrate] Container not ready yet, waiting...');
@@ -31,8 +35,9 @@ function getHydrateScript(runtimeConfig, containerName = "ui", hydratePath = "./
31
35
  return mod().hydrate();
32
36
  }).catch(function(e){
33
37
  console.error('[Hydrate] Failed:', e);
38
+ window.__EVERYTHING_DEV_HYDRATE_PROMISE__ = undefined;
34
39
  });
35
- }
40
+ }
36
41
  if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',__hydrate);}else{__hydrate();}
37
42
  `.trim() };
38
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"head.cjs","names":[],"sources":["../../src/ui/head.ts"],"sourcesContent":["import type { ClientRuntimeConfig } from \"../types\";\nimport type { HeadScript } from \"./types\";\n\nexport interface RemoteScriptsOptions {\n runtimeConfig?: Partial<ClientRuntimeConfig>;\n containerName?: string;\n hydratePath?: string;\n integrity?: string;\n cspNonce?: string;\n}\n\nexport function getThemeInitScript(): HeadScript {\n return {\n children:\n \"(function(){var t=localStorage.getItem('theme');if(t==='dark'||(!t&&window.matchMedia('(prefers-color-scheme: dark)').matches)){document.documentElement.classList.add('dark');}})();\",\n };\n}\n\nexport function getHydrateScript(\n runtimeConfig: Partial<ClientRuntimeConfig> | undefined,\n containerName = \"ui\",\n hydratePath = \"./Hydrate\",\n cspNonce?: string,\n): HeadScript {\n return {\n children: `\n window.__CSP_NONCE__=${JSON.stringify(cspNonce)};\n window.__RUNTIME_CONFIG__=${JSON.stringify(runtimeConfig)};\n function __hydrate(){\n if (window.__EVERYTHING_DEV_HYDRATE_PROMISE__) {\n return;\n }\n var container = window['${containerName}'];\n if (!container) {\n console.warn('[Hydrate] Container not ready yet, waiting...');\n window.__hydrateRetry = window.__hydrateRetry || 0;\n if (window.__hydrateRetry < 10) {\n window.__hydrateRetry++;\n setTimeout(__hydrate, 100);\n return;\n }\n console.error('[Hydrate] Container not found after 10 retries');\n return;\n }\n console.log('[Hydrate] Container available, starting init...');\n container.init({}).then(function(){\n return container.get('${hydratePath}');\n }).then(function(mod){\n return mod().hydrate();\n }).catch(function(e){\n console.error('[Hydrate] Failed:', e);\n });\n }\n if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',__hydrate);}else{__hydrate();}\n \t\t`.trim(),\n };\n}\n\nexport function getRemoteScripts(options: RemoteScriptsOptions): HeadScript[] {\n const { runtimeConfig, containerName, hydratePath, integrity, cspNonce } = options;\n const assetsUrl = runtimeConfig?.assetsUrl?.replace(/\\/$/, \"\");\n const entryScript: HeadScript = {\n src: `${assetsUrl ?? \"\"}/remoteEntry.js${integrity ? `?v=${encodeURIComponent(integrity)}` : \"\"}`,\n };\n if (integrity) {\n entryScript.integrity = integrity;\n entryScript.crossOrigin = \"anonymous\";\n }\n return [entryScript, getHydrateScript(runtimeConfig, containerName, hydratePath, cspNonce)];\n}\n\nexport function getBaseStyles(): string {\n return `\n*, *::before, *::after { box-sizing: border-box; }\nhtml { height: 100%; height: 100dvh; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; color-scheme: light dark; }\nbody { min-height: 100%; min-height: 100dvh; margin: 0; background-color: var(--background); color: var(--foreground); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }\n#root { min-height: 100vh; }\n@supports (min-height: 100dvh) { #root { min-height: 100dvh; } }\n `.trim();\n}\n"],"mappings":";;;AAWA,SAAgB,qBAAiC;AAC/C,QAAO,EACL,UACE,yLACH;;AAGH,SAAgB,iBACd,eACA,gBAAgB,MAChB,cAAc,aACd,UACY;AACZ,QAAO,EACL,UAAU;wBACU,KAAK,UAAU,SAAS,CAAC;6BACpB,KAAK,UAAU,cAAc,CAAC;;;;;6BAK9B,cAAc;;;;;;;;;;;;;;4BAcf,YAAY;;;;;;;;KAQnC,MAAM,EACR;;AAGH,SAAgB,iBAAiB,SAA6C;CAC5E,MAAM,EAAE,eAAe,eAAe,aAAa,WAAW,aAAa;CAE3E,MAAM,cAA0B,EAC9B,KAAK,GAFW,eAAe,WAAW,QAAQ,OAAO,GAAG,IAEvC,GAAG,iBAAiB,YAAY,MAAM,mBAAmB,UAAU,KAAK,MAC9F;AACD,KAAI,WAAW;AACb,cAAY,YAAY;AACxB,cAAY,cAAc;;AAE5B,QAAO,CAAC,aAAa,iBAAiB,eAAe,eAAe,aAAa,SAAS,CAAC;;AAG7F,SAAgB,gBAAwB;AACtC,QAAO;;;;;;IAML,MAAM"}
1
+ {"version":3,"file":"head.cjs","names":[],"sources":["../../src/ui/head.ts"],"sourcesContent":["import type { ClientRuntimeConfig } from \"../types\";\nimport type { HeadScript } from \"./types\";\n\nexport interface RemoteScriptsOptions {\n runtimeConfig?: Partial<ClientRuntimeConfig>;\n containerName?: string;\n hydratePath?: string;\n integrity?: string;\n cspNonce?: string;\n}\n\nexport function getThemeInitScript(): HeadScript {\n return {\n children:\n \"(function(){var t=localStorage.getItem('theme');if(t==='dark'||(!t&&window.matchMedia('(prefers-color-scheme: dark)').matches)){document.documentElement.classList.add('dark');}})();\",\n };\n}\n\nfunction escapeJsonForScript(value: unknown): string {\n return JSON.stringify(value)\n .replace(/<\\/script/gi, \"<\\\\/script\")\n .replace(/\\u2028/g, \"\\\\u2028\")\n .replace(/\\u2029/g, \"\\\\u2029\");\n}\n\nexport function getHydrateScript(\n runtimeConfig: Partial<ClientRuntimeConfig> | undefined,\n containerName = \"ui\",\n hydratePath = \"./Hydrate\",\n cspNonce?: string,\n): HeadScript {\n return {\n children: `\n window.__CSP_NONCE__=${cspNonce != null ? escapeJsonForScript(cspNonce) : null};\n window.__RUNTIME_CONFIG__=${escapeJsonForScript(runtimeConfig)};\n function __hydrate(){\n if (window.__EVERYTHING_DEV_HYDRATE_PROMISE__) {\n console.warn('[Hydrate] Already in progress, skipping duplicate call');\n return;\n }\n var container = window['${containerName}'];\n if (!container) {\n console.warn('[Hydrate] Container not ready yet, waiting...');\n window.__hydrateRetry = window.__hydrateRetry || 0;\n if (window.__hydrateRetry < 10) {\n window.__hydrateRetry++;\n setTimeout(__hydrate, 100);\n return;\n }\n console.error('[Hydrate] Container not found after 10 retries');\n return;\n }\n console.log('[Hydrate] Container available, starting init...');\n container.init({}).then(function(){\n return container.get('${hydratePath}');\n }).then(function(mod){\n return mod().hydrate();\n }).catch(function(e){\n console.error('[Hydrate] Failed:', e);\n window.__EVERYTHING_DEV_HYDRATE_PROMISE__ = undefined;\n });\n }\n if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',__hydrate);}else{__hydrate();}\n \t\t`.trim(),\n };\n}\n\nexport function getRemoteScripts(options: RemoteScriptsOptions): HeadScript[] {\n const { runtimeConfig, containerName, hydratePath, integrity, cspNonce } = options;\n const assetsUrl = runtimeConfig?.assetsUrl?.replace(/\\/$/, \"\");\n const entryScript: HeadScript = {\n src: `${assetsUrl ?? \"\"}/remoteEntry.js${integrity ? `?v=${encodeURIComponent(integrity)}` : \"\"}`,\n };\n if (integrity) {\n entryScript.integrity = integrity;\n entryScript.crossOrigin = \"anonymous\";\n }\n return [entryScript, getHydrateScript(runtimeConfig, containerName, hydratePath, cspNonce)];\n}\n\nexport function getBaseStyles(): string {\n return `\n*, *::before, *::after { box-sizing: border-box; }\nhtml { height: 100%; height: 100dvh; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; color-scheme: light dark; }\nbody { min-height: 100%; min-height: 100dvh; margin: 0; background-color: var(--background); color: var(--foreground); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }\n#root { min-height: 100vh; }\n@supports (min-height: 100dvh) { #root { min-height: 100dvh; } }\n `.trim();\n}\n"],"mappings":";;;AAWA,SAAgB,qBAAiC;AAC/C,QAAO,EACL,UACE,yLACH;;AAGH,SAAS,oBAAoB,OAAwB;AACnD,QAAO,KAAK,UAAU,MAAM,CACzB,QAAQ,eAAe,aAAa,CACpC,QAAQ,WAAW,UAAU,CAC7B,QAAQ,WAAW,UAAU;;AAGlC,SAAgB,iBACd,eACA,gBAAgB,MAChB,cAAc,aACd,UACY;AACZ,QAAO,EACL,UAAU;wBACU,YAAY,OAAO,oBAAoB,SAAS,GAAG,KAAK;6BACnD,oBAAoB,cAAc,CAAC;;;;;;6BAMnC,cAAc;;;;;;;;;;;;;;4BAcf,YAAY;;;;;;;;;KASnC,MAAM,EACR;;AAGH,SAAgB,iBAAiB,SAA6C;CAC5E,MAAM,EAAE,eAAe,eAAe,aAAa,WAAW,aAAa;CAE3E,MAAM,cAA0B,EAC9B,KAAK,GAFW,eAAe,WAAW,QAAQ,OAAO,GAAG,IAEvC,GAAG,iBAAiB,YAAY,MAAM,mBAAmB,UAAU,KAAK,MAC9F;AACD,KAAI,WAAW;AACb,cAAY,YAAY;AACxB,cAAY,cAAc;;AAE5B,QAAO,CAAC,aAAa,iBAAiB,eAAe,eAAe,aAAa,SAAS,CAAC;;AAG7F,SAAgB,gBAAwB;AACtC,QAAO;;;;;;IAML,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"head.d.cts","names":[],"sources":["../../src/ui/head.ts"],"mappings":";;;;UAGiB,oBAAA;EACf,aAAA,GAAgB,OAAA,CAAQ,mBAAA;EACxB,aAAA;EACA,WAAA;EACA,SAAA;EACA,QAAA;AAAA;AAAA,iBAGc,kBAAA,CAAA,GAAsB,UAAA;AAAA,iBAOtB,gBAAA,CACd,aAAA,EAAe,OAAA,CAAQ,mBAAA,eACvB,aAAA,WACA,WAAA,WACA,QAAA,YACC,UAAA;AAAA,iBAmCa,gBAAA,CAAiB,OAAA,EAAS,oBAAA,GAAuB,UAAA;AAAA,iBAajD,aAAA,CAAA"}
1
+ {"version":3,"file":"head.d.cts","names":[],"sources":["../../src/ui/head.ts"],"mappings":";;;;UAGiB,oBAAA;EACf,aAAA,GAAgB,OAAA,CAAQ,mBAAA;EACxB,aAAA;EACA,WAAA;EACA,SAAA;EACA,QAAA;AAAA;AAAA,iBAGc,kBAAA,CAAA,GAAsB,UAAA;AAAA,iBActB,gBAAA,CACd,aAAA,EAAe,OAAA,CAAQ,mBAAA,eACvB,aAAA,WACA,WAAA,WACA,QAAA,YACC,UAAA;AAAA,iBAqCa,gBAAA,CAAiB,OAAA,EAAS,oBAAA,GAAuB,UAAA;AAAA,iBAajD,aAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"head.d.mts","names":[],"sources":["../../src/ui/head.ts"],"mappings":";;;;UAGiB,oBAAA;EACf,aAAA,GAAgB,OAAA,CAAQ,mBAAA;EACxB,aAAA;EACA,WAAA;EACA,SAAA;EACA,QAAA;AAAA;AAAA,iBAGc,kBAAA,CAAA,GAAsB,UAAA;AAAA,iBAOtB,gBAAA,CACd,aAAA,EAAe,OAAA,CAAQ,mBAAA,eACvB,aAAA,WACA,WAAA,WACA,QAAA,YACC,UAAA;AAAA,iBAmCa,gBAAA,CAAiB,OAAA,EAAS,oBAAA,GAAuB,UAAA;AAAA,iBAajD,aAAA,CAAA"}
1
+ {"version":3,"file":"head.d.mts","names":[],"sources":["../../src/ui/head.ts"],"mappings":";;;;UAGiB,oBAAA;EACf,aAAA,GAAgB,OAAA,CAAQ,mBAAA;EACxB,aAAA;EACA,WAAA;EACA,SAAA;EACA,QAAA;AAAA;AAAA,iBAGc,kBAAA,CAAA,GAAsB,UAAA;AAAA,iBActB,gBAAA,CACd,aAAA,EAAe,OAAA,CAAQ,mBAAA,eACvB,aAAA,WACA,WAAA,WACA,QAAA,YACC,UAAA;AAAA,iBAqCa,gBAAA,CAAiB,OAAA,EAAS,oBAAA,GAAuB,UAAA;AAAA,iBAajD,aAAA,CAAA"}
package/dist/ui/head.mjs CHANGED
@@ -2,14 +2,18 @@
2
2
  function getThemeInitScript() {
3
3
  return { children: "(function(){var t=localStorage.getItem('theme');if(t==='dark'||(!t&&window.matchMedia('(prefers-color-scheme: dark)').matches)){document.documentElement.classList.add('dark');}})();" };
4
4
  }
5
+ function escapeJsonForScript(value) {
6
+ return JSON.stringify(value).replace(/<\/script/gi, "<\\/script").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
7
+ }
5
8
  function getHydrateScript(runtimeConfig, containerName = "ui", hydratePath = "./Hydrate", cspNonce) {
6
9
  return { children: `
7
- window.__CSP_NONCE__=${JSON.stringify(cspNonce)};
8
- window.__RUNTIME_CONFIG__=${JSON.stringify(runtimeConfig)};
9
- function __hydrate(){
10
- if (window.__EVERYTHING_DEV_HYDRATE_PROMISE__) {
11
- return;
12
- }
10
+ window.__CSP_NONCE__=${cspNonce != null ? escapeJsonForScript(cspNonce) : null};
11
+ window.__RUNTIME_CONFIG__=${escapeJsonForScript(runtimeConfig)};
12
+ function __hydrate(){
13
+ if (window.__EVERYTHING_DEV_HYDRATE_PROMISE__) {
14
+ console.warn('[Hydrate] Already in progress, skipping duplicate call');
15
+ return;
16
+ }
13
17
  var container = window['${containerName}'];
14
18
  if (!container) {
15
19
  console.warn('[Hydrate] Container not ready yet, waiting...');
@@ -29,8 +33,9 @@ function getHydrateScript(runtimeConfig, containerName = "ui", hydratePath = "./
29
33
  return mod().hydrate();
30
34
  }).catch(function(e){
31
35
  console.error('[Hydrate] Failed:', e);
36
+ window.__EVERYTHING_DEV_HYDRATE_PROMISE__ = undefined;
32
37
  });
33
- }
38
+ }
34
39
  if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',__hydrate);}else{__hydrate();}
35
40
  `.trim() };
36
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"head.mjs","names":[],"sources":["../../src/ui/head.ts"],"sourcesContent":["import type { ClientRuntimeConfig } from \"../types\";\nimport type { HeadScript } from \"./types\";\n\nexport interface RemoteScriptsOptions {\n runtimeConfig?: Partial<ClientRuntimeConfig>;\n containerName?: string;\n hydratePath?: string;\n integrity?: string;\n cspNonce?: string;\n}\n\nexport function getThemeInitScript(): HeadScript {\n return {\n children:\n \"(function(){var t=localStorage.getItem('theme');if(t==='dark'||(!t&&window.matchMedia('(prefers-color-scheme: dark)').matches)){document.documentElement.classList.add('dark');}})();\",\n };\n}\n\nexport function getHydrateScript(\n runtimeConfig: Partial<ClientRuntimeConfig> | undefined,\n containerName = \"ui\",\n hydratePath = \"./Hydrate\",\n cspNonce?: string,\n): HeadScript {\n return {\n children: `\n window.__CSP_NONCE__=${JSON.stringify(cspNonce)};\n window.__RUNTIME_CONFIG__=${JSON.stringify(runtimeConfig)};\n function __hydrate(){\n if (window.__EVERYTHING_DEV_HYDRATE_PROMISE__) {\n return;\n }\n var container = window['${containerName}'];\n if (!container) {\n console.warn('[Hydrate] Container not ready yet, waiting...');\n window.__hydrateRetry = window.__hydrateRetry || 0;\n if (window.__hydrateRetry < 10) {\n window.__hydrateRetry++;\n setTimeout(__hydrate, 100);\n return;\n }\n console.error('[Hydrate] Container not found after 10 retries');\n return;\n }\n console.log('[Hydrate] Container available, starting init...');\n container.init({}).then(function(){\n return container.get('${hydratePath}');\n }).then(function(mod){\n return mod().hydrate();\n }).catch(function(e){\n console.error('[Hydrate] Failed:', e);\n });\n }\n if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',__hydrate);}else{__hydrate();}\n \t\t`.trim(),\n };\n}\n\nexport function getRemoteScripts(options: RemoteScriptsOptions): HeadScript[] {\n const { runtimeConfig, containerName, hydratePath, integrity, cspNonce } = options;\n const assetsUrl = runtimeConfig?.assetsUrl?.replace(/\\/$/, \"\");\n const entryScript: HeadScript = {\n src: `${assetsUrl ?? \"\"}/remoteEntry.js${integrity ? `?v=${encodeURIComponent(integrity)}` : \"\"}`,\n };\n if (integrity) {\n entryScript.integrity = integrity;\n entryScript.crossOrigin = \"anonymous\";\n }\n return [entryScript, getHydrateScript(runtimeConfig, containerName, hydratePath, cspNonce)];\n}\n\nexport function getBaseStyles(): string {\n return `\n*, *::before, *::after { box-sizing: border-box; }\nhtml { height: 100%; height: 100dvh; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; color-scheme: light dark; }\nbody { min-height: 100%; min-height: 100dvh; margin: 0; background-color: var(--background); color: var(--foreground); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }\n#root { min-height: 100vh; }\n@supports (min-height: 100dvh) { #root { min-height: 100dvh; } }\n `.trim();\n}\n"],"mappings":";AAWA,SAAgB,qBAAiC;AAC/C,QAAO,EACL,UACE,yLACH;;AAGH,SAAgB,iBACd,eACA,gBAAgB,MAChB,cAAc,aACd,UACY;AACZ,QAAO,EACL,UAAU;wBACU,KAAK,UAAU,SAAS,CAAC;6BACpB,KAAK,UAAU,cAAc,CAAC;;;;;6BAK9B,cAAc;;;;;;;;;;;;;;4BAcf,YAAY;;;;;;;;KAQnC,MAAM,EACR;;AAGH,SAAgB,iBAAiB,SAA6C;CAC5E,MAAM,EAAE,eAAe,eAAe,aAAa,WAAW,aAAa;CAE3E,MAAM,cAA0B,EAC9B,KAAK,GAFW,eAAe,WAAW,QAAQ,OAAO,GAAG,IAEvC,GAAG,iBAAiB,YAAY,MAAM,mBAAmB,UAAU,KAAK,MAC9F;AACD,KAAI,WAAW;AACb,cAAY,YAAY;AACxB,cAAY,cAAc;;AAE5B,QAAO,CAAC,aAAa,iBAAiB,eAAe,eAAe,aAAa,SAAS,CAAC;;AAG7F,SAAgB,gBAAwB;AACtC,QAAO;;;;;;IAML,MAAM"}
1
+ {"version":3,"file":"head.mjs","names":[],"sources":["../../src/ui/head.ts"],"sourcesContent":["import type { ClientRuntimeConfig } from \"../types\";\nimport type { HeadScript } from \"./types\";\n\nexport interface RemoteScriptsOptions {\n runtimeConfig?: Partial<ClientRuntimeConfig>;\n containerName?: string;\n hydratePath?: string;\n integrity?: string;\n cspNonce?: string;\n}\n\nexport function getThemeInitScript(): HeadScript {\n return {\n children:\n \"(function(){var t=localStorage.getItem('theme');if(t==='dark'||(!t&&window.matchMedia('(prefers-color-scheme: dark)').matches)){document.documentElement.classList.add('dark');}})();\",\n };\n}\n\nfunction escapeJsonForScript(value: unknown): string {\n return JSON.stringify(value)\n .replace(/<\\/script/gi, \"<\\\\/script\")\n .replace(/\\u2028/g, \"\\\\u2028\")\n .replace(/\\u2029/g, \"\\\\u2029\");\n}\n\nexport function getHydrateScript(\n runtimeConfig: Partial<ClientRuntimeConfig> | undefined,\n containerName = \"ui\",\n hydratePath = \"./Hydrate\",\n cspNonce?: string,\n): HeadScript {\n return {\n children: `\n window.__CSP_NONCE__=${cspNonce != null ? escapeJsonForScript(cspNonce) : null};\n window.__RUNTIME_CONFIG__=${escapeJsonForScript(runtimeConfig)};\n function __hydrate(){\n if (window.__EVERYTHING_DEV_HYDRATE_PROMISE__) {\n console.warn('[Hydrate] Already in progress, skipping duplicate call');\n return;\n }\n var container = window['${containerName}'];\n if (!container) {\n console.warn('[Hydrate] Container not ready yet, waiting...');\n window.__hydrateRetry = window.__hydrateRetry || 0;\n if (window.__hydrateRetry < 10) {\n window.__hydrateRetry++;\n setTimeout(__hydrate, 100);\n return;\n }\n console.error('[Hydrate] Container not found after 10 retries');\n return;\n }\n console.log('[Hydrate] Container available, starting init...');\n container.init({}).then(function(){\n return container.get('${hydratePath}');\n }).then(function(mod){\n return mod().hydrate();\n }).catch(function(e){\n console.error('[Hydrate] Failed:', e);\n window.__EVERYTHING_DEV_HYDRATE_PROMISE__ = undefined;\n });\n }\n if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',__hydrate);}else{__hydrate();}\n \t\t`.trim(),\n };\n}\n\nexport function getRemoteScripts(options: RemoteScriptsOptions): HeadScript[] {\n const { runtimeConfig, containerName, hydratePath, integrity, cspNonce } = options;\n const assetsUrl = runtimeConfig?.assetsUrl?.replace(/\\/$/, \"\");\n const entryScript: HeadScript = {\n src: `${assetsUrl ?? \"\"}/remoteEntry.js${integrity ? `?v=${encodeURIComponent(integrity)}` : \"\"}`,\n };\n if (integrity) {\n entryScript.integrity = integrity;\n entryScript.crossOrigin = \"anonymous\";\n }\n return [entryScript, getHydrateScript(runtimeConfig, containerName, hydratePath, cspNonce)];\n}\n\nexport function getBaseStyles(): string {\n return `\n*, *::before, *::after { box-sizing: border-box; }\nhtml { height: 100%; height: 100dvh; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; color-scheme: light dark; }\nbody { min-height: 100%; min-height: 100dvh; margin: 0; background-color: var(--background); color: var(--foreground); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }\n#root { min-height: 100vh; }\n@supports (min-height: 100dvh) { #root { min-height: 100dvh; } }\n `.trim();\n}\n"],"mappings":";AAWA,SAAgB,qBAAiC;AAC/C,QAAO,EACL,UACE,yLACH;;AAGH,SAAS,oBAAoB,OAAwB;AACnD,QAAO,KAAK,UAAU,MAAM,CACzB,QAAQ,eAAe,aAAa,CACpC,QAAQ,WAAW,UAAU,CAC7B,QAAQ,WAAW,UAAU;;AAGlC,SAAgB,iBACd,eACA,gBAAgB,MAChB,cAAc,aACd,UACY;AACZ,QAAO,EACL,UAAU;wBACU,YAAY,OAAO,oBAAoB,SAAS,GAAG,KAAK;6BACnD,oBAAoB,cAAc,CAAC;;;;;;6BAMnC,cAAc;;;;;;;;;;;;;;4BAcf,YAAY;;;;;;;;;KASnC,MAAM,EACR;;AAGH,SAAgB,iBAAiB,SAA6C;CAC5E,MAAM,EAAE,eAAe,eAAe,aAAa,WAAW,aAAa;CAE3E,MAAM,cAA0B,EAC9B,KAAK,GAFW,eAAe,WAAW,QAAQ,OAAO,GAAG,IAEvC,GAAG,iBAAiB,YAAY,MAAM,mBAAmB,UAAU,KAAK,MAC9F;AACD,KAAI,WAAW;AACb,cAAY,YAAY;AACxB,cAAY,cAAc;;AAE5B,QAAO,CAAC,aAAa,iBAAiB,eAAe,eAAe,aAAa,SAAS,CAAC;;AAG7F,SAAgB,gBAAwB;AACtC,QAAO;;;;;;IAML,MAAM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "everything-dev",
3
- "version": "1.51.2",
3
+ "version": "1.51.3",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20.11"
@@ -140,7 +140,7 @@
140
140
  "dotenv": "^17.3.1",
141
141
  "effect": "^3.21.0",
142
142
  "execa": "^9.5.2",
143
- "every-plugin": "^2.9.4",
143
+ "every-plugin": "^2.9.5",
144
144
  "glob": "^13.0.6",
145
145
  "gradient-string": "^3.0.0",
146
146
  "ink": "^6.8.0",