Files
zpan/server/runtime-platform.ts
T
saltbo 53ca110218 feat(about): split runtime into runtime engine + deployment platform
Flatten the instance `runtime` object into two fields: `runtime` (the JS engine,
node | workerd) and `platform` (the deployment host). The About page shows each
as its own row with friendly labels (e.g. "workerd" + "Cloudflare Workers",
"Node.js" + "Docker").

- Detect the platform from the entry file (entry === target): each serverless
  entry declares it; entry-node sniffs Cloud Run (K_SERVICE) / Docker
  (ZPAN_RUNTIME, set in the Dockerfile) / bare node. Cloudflare is detected from
  the D1 binding.
- Decouple the cloud payload: zpan-cloud-sdk fixes runtime { provider, target },
  so CloudInstanceInfo keeps that shape and buildCloudInstanceInfo maps to it;
  buildInstanceInfo serves the richer flat shape to the About API.
- Migrate PostHog instance telemetry to the runtime/platform shape and merge the
  duplicate runtimeInfo in licensing-admin into the shared one.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 14:56:29 -04:00

19 lines
665 B
TypeScript

import type { InstanceInfo } from '../shared/types/instance'
export type DeployPlatform = NonNullable<InstanceInfo['platform']>
declare global {
var __ZPAN_PLATFORM__: DeployPlatform | undefined
}
// A deployment entry declares its platform at startup — the entry file IS the
// target, the most reliable signal. entry-node additionally sniffs Cloud Run /
// Docker, which share the Node entry. Cloudflare is detected from the D1 binding.
export function setDeployPlatform(platform: DeployPlatform): void {
globalThis.__ZPAN_PLATFORM__ = platform
}
export function getDeployPlatform(): DeployPlatform | undefined {
return globalThis.__ZPAN_PLATFORM__
}