From c79d8cd4319eb6fbe9b270fafadd125c77a7bd05 Mon Sep 17 00:00:00 2001 From: callumalpass Date: Thu, 12 Nov 2026 01:08:37 +1100 Subject: [PATCH] Allow building the plugin against a staging SDK package The SDK can be packaged for staging as well as LAB and production, but the plugin's build only knew `--lab`. `--staging` now selects the staging environment the same way. The packer still refuses a package that was not made for the environment being built, so a LAB or production package cannot be used for a staging build. The production build is unchanged. --- docs/sdk-sync.md | 5 +++-- scripts/native-assets.mjs | 2 +- src/sync/native/page.ts | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/sdk-sync.md b/docs/sdk-sync.md index d25d1bb..07474c1 100644 --- a/docs/sdk-sync.md +++ b/docs/sdk-sync.md @@ -153,14 +153,15 @@ checks every embedded SDK asset against the SDK's own pins. The SDK pins the official OPFS proxy but never loads it, and the published package leaves it out; the packer embeds it only when the supplied package has it. -To build against an authenticated LAB SDK package: +To build against an authenticated LAB or staging SDK package: ```sh npm ci node esbuild.config.mjs production --lab --native-sdk /absolute/path/to/sdk/package +node esbuild.config.mjs production --staging --native-sdk /absolute/path/to/sdk/package ``` -Do not publish a LAB build. +Do not publish a LAB or staging build. Unit tests exercise real vault IO for concurrent edits, renames, deletes, conflict-publication recovery, upload recovery, ownership transitions and fixed diff --git a/scripts/native-assets.mjs b/scripts/native-assets.mjs index 53c1a81..09537be 100644 --- a/scripts/native-assets.mjs +++ b/scripts/native-assets.mjs @@ -8,7 +8,7 @@ import { createHash } from "node:crypto"; export async function nativeAssets() { const index = process.argv.indexOf("--native-sdk"); const sdk = resolve(index < 0 ? "node_modules/@mdbase-dev/sdk" : process.argv[index + 1]); - const environment = process.argv.includes("--lab") ? "lab" : "production"; + const environment = process.argv.includes("--lab") ? "lab" : process.argv.includes("--staging") ? "staging" : "production"; const trust = readFileSync(resolve(sdk, "dist/application/packaged-trust.js"), "utf8"); if (!trust.includes(`"environment":"${environment}"`)) throw new Error(`Native SDK must be authentically packaged for ${environment}; no environment retargeting`); const declaration = readFileSync(resolve(sdk, "dist/application/declaration.js"), "utf8"); diff --git a/src/sync/native/page.ts b/src/sync/native/page.ts index ae2c2c5..f445de7 100644 --- a/src/sync/native/page.ts +++ b/src/sync/native/page.ts @@ -15,7 +15,7 @@ const manifest = { ...template, homepage: `${location.origin}/`, redirect_uris: const namespace = new URL(location.href).searchParams.get("vault"); if (!namespace) throw new Error("Missing stable vault storage namespace"); -declare const __MDBASE_ENVIRONMENT__: "lab" | "production"; +declare const __MDBASE_ENVIRONMENT__: "lab" | "staging" | "production"; let bridge: MessagePort | null = null; const queued: any[] = []; if (parent === window) throw new Error("Native SDK must run inside its owning vault");