ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
feat(sdk): share i18next with extensions; generate the vendor shims
Juan Deniscff35cc65130
diff --git a/backend/app/api/plugins.py b/backend/app/api/plugins.pyindex 1ce5ff44..695afe5f 100644--- a/backend/app/api/plugins.py+++ b/backend/app/api/plugins.py@@ -456,13 +456,13 @@ def get_manifest_spec():'contributions': {'type': 'object','properties': {- 'nav': {'type': 'array', 'description': 'Sidebar items: {id, label, route, category, icon}.'},+ 'nav': {'type': 'array', 'description': 'Sidebar items: {id, label, route, category, icon, labelKey?}. labelKey is a translation key resolved at render; label is its English default, shown when the active locale has no entry.'},'routes': {'type': 'array','description': 'SPA routes: {path, component, layout?, group?}. component matches a named export of the plugin index module. layout: padded (default) | full | bare | <custom-layout-id>. group nests the route inside that core tab group\'s TabGroupLayout instead (see tabs).'},'tabs': {'type': 'array',- 'description': 'Tabs added to a core-owned tab group: {group, to, label, icon?, end?, order?}. group is the core group id (files | servers | monitoring; == the sidebar item id). Pair with a route contribution carrying the same group. icon is raw inner-SVG markup; order is an optional insertion index (default: appended).'},+ 'description': 'Tabs added to a core-owned tab group: {group, to, label, labelKey?, icon?, end?, order?}. group is the core group id (files | servers | monitoring; == the sidebar item id). Pair with a route contribution carrying the same group. icon is raw inner-SVG markup; order is an optional insertion index (default: appended).'},'page_titles': {'type': 'object', 'description': 'Map of route path → document title.'},- 'command_palette': {'type': 'array', 'description': '{label, path, category, keywords}.'},+ 'command_palette': {'type': 'array', 'description': '{label, path, category, keywords, labelKey?}. labelKey is a translation key resolved at render; label is its English default.'},'widgets': {'type': 'array', 'description': '{slot, component}. slot=global renders globally inside DashboardLayout.'},'dashboard_widgets': {'type': 'array','description': 'Placeable dashboard widget types: {id, name, component, icon?, category?, description?, w?, h?, min?, default_cfg?}. Unlike widgets (fixed host slot), these appear in the dashboard widget library and the user positions, resizes and configures instances of them.'},diff --git a/backend/app/utils/sdk.py b/backend/app/utils/sdk.pyindex 133b2818..ac8d678a 100644--- a/backend/app/utils/sdk.py+++ b/backend/app/utils/sdk.py@@ -30,7 +30,7 @@ from app.utils.version import compare_versions# 1.2.0 — plan 52 Phases 4-5: layout/feedback primitives, ui/* form kit,# common hooks, format utils, and the cross-feature embeds (git repo-connect,# backups ProtectionPanel) the WordPress runtime-ESM extraction needed.-SDK_VERSION = '1.2.0'+SDK_VERSION = '1.3.0'def _version_tuple(v):diff --git a/docs/EXTENSIONS.md b/docs/EXTENSIONS.mdindex 819c73f3..e1d9ae5b 100644--- a/docs/EXTENSIONS.md+++ b/docs/EXTENSIONS.md@@ -525,6 +525,85 @@ def register():return {"connect": on_connect, "subscribe": on_subscribe}```+## Localization++Extensions use the panel's own i18n — not a parallel one. `i18next` and+`react-i18next` are shared singletons (see `vendorManifest.js`), so an+extension's copy follows the user's language, plural rules and live locale+switch with no wiring of its own.++```jsx+import { useTranslation, useFormat } from 'serverkit-sdk';++export function MyPage() {+ const { t } = useTranslation();+ const { formatDate } = useFormat();+ return (+ <>+ <h2>{t('myext.title', 'My Extension')}</h2>+ <p>{t('myext.lastRun', 'Last run {{when}}', { when: formatDate(run.at) })}</p>+ </>+ );+}+```++Three rules, the same ones core follows:++1. **Always pass the English default** — `t('key', 'English')`. It is what+ renders when the active locale has no entry for your key, so a partially+ translated extension degrades to English instead of showing a raw key path.+2. **Namespace your keys under your slug** (`myext.*`). The panel merges+ extension bundles into one resource tree; an unprefixed `title` would+ collide with core's.+3. **Never call `toLocaleDateString()` / `new Intl.*` yourself.** With no+ argument those follow the *browser's* locale, not the panel's, so your dates+ would disagree with every date around them. Use `useFormat()` (or the+ `formatDate`/`formatNumber`/`formatRelative` exports) — they read the panel+ locale and cache their formatters.++For a sentence containing a link or an element, use `<Trans>` rather than+splitting it into prefix/suffix keys — word order around the element differs by+language and split keys cannot be reordered by a translator.++### Declarative labels in the manifest++Manifest contributions are data, so they cannot call `t()` — a label resolved+at module load would translate once, at import, and never follow a switch.+Declare the key beside the English instead, and the panel resolves it at render:++```jsonc+"contributions": {+ "nav": [+ { "id": "myext", "route": "/myext", "labelKey": "myext.nav", "label": "My Extension" }+ ],+ "tabs": [+ { "group": "servers", "to": "/myext/tab", "labelKey": "myext.tab", "label": "My Tab" }+ ],+ "command_palette": [+ { "path": "/myext", "labelKey": "myext.palette", "label": "Open My Extension" }+ ]+}+```++`labelKey` is optional everywhere. Omit it and the panel renders `label`+verbatim, which is exactly what every pre-existing extension does today.++### Shipping translations++Register your bundles against the shared instance at module load:++```js+import i18next from 'i18next';+import es from './locales/es.json';++i18next.addResourceBundle('es', 'translation', { myext: es }, true, true);+```++Because the instance is shared, this must be additive and namespaced — do not+call `i18next.init()` or `changeLanguage()` from an extension: the panel owns+both, and calling them would reconfigure or switch the language for the whole+panel.+## Permissions & compatibility`permissions` is a **consent signal**, and for most capabilities that is all it is.diff --git a/frontend/package.json b/frontend/package.jsonindex de9a577b..4bc94a51 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -7,13 +7,15 @@"dev": "vite","build": "vite build","test": "node --test",- "lint": "eslint . && node scripts/check-settings-index.mjs && node scripts/check-theme-tokens.mjs && node scripts/check-frontend-boundaries.mjs && node scripts/check-style-ownership.mjs && node scripts/check-status-one-door.mjs && node scripts/check-status-scss.mjs && node scripts/check-i18n-literals.mjs && node scripts/check-intl-door.mjs && node scripts/extract-i18n.mjs --check && node scripts/check-i18n.mjs && node scripts/check-logical-properties.mjs && node ../scripts/check-html-sinks.mjs",+ "lint": "eslint . && node scripts/check-settings-index.mjs && node scripts/check-theme-tokens.mjs && node scripts/check-frontend-boundaries.mjs && node scripts/check-style-ownership.mjs && node scripts/check-status-one-door.mjs && node scripts/check-status-scss.mjs && node scripts/check-i18n-literals.mjs && node scripts/check-intl-door.mjs && node scripts/extract-i18n.mjs --check && node scripts/check-i18n.mjs && node scripts/check-logical-properties.mjs && node scripts/generate-vendor-shims.mjs --check && node ../scripts/check-html-sinks.mjs","lint:settings-index": "node scripts/check-settings-index.mjs","lint:status": "node scripts/check-status-one-door.mjs","lint:i18n": "node scripts/check-i18n-literals.mjs","lint:intl": "node scripts/check-intl-door.mjs","lint:locales": "node scripts/check-i18n.mjs","lint:logical": "node scripts/check-logical-properties.mjs",+ "lint:vendor-shims": "node scripts/generate-vendor-shims.mjs --check",+ "vendor:shims": "node scripts/generate-vendor-shims.mjs","i18n:extract": "node scripts/extract-i18n.mjs","lint:html-sinks": "node ../scripts/check-html-sinks.mjs","lint:frontend-boundaries": "node scripts/check-frontend-boundaries.mjs",diff --git a/frontend/public/serverkit-vendor/i18next.mjs b/frontend/public/serverkit-vendor/i18next.mjsnew file mode 100644index 00000000..4c62a800--- /dev/null+++ b/frontend/public/serverkit-vendor/i18next.mjs@@ -0,0 +1,23 @@+// GENERATED by scripts/generate-vendor-shims.mjs — do not edit.+// Runtime-extension shim for `i18next`: re-exports the HOST instance so+// the extension and the panel share one copy (see vendorManifest.js).+const m = (globalThis.__SK_VENDOR__ || {})['i18next'];+if (!m) {+ throw new Error('[serverkit] host i18next unavailable — vendorShare did not run');+}+export default m.default ?? m;+export const changeLanguage = m.changeLanguage;+export const createInstance = m.createInstance;+export const dir = m.dir;+export const exists = m.exists;+export const getFixedT = m.getFixedT;+export const hasLoadedNamespace = m.hasLoadedNamespace;+export const init = m.init;+export const keyFromSelector = m.keyFromSelector;+export const loadLanguages = m.loadLanguages;+export const loadNamespaces = m.loadNamespaces;+export const loadResources = m.loadResources;+export const reloadResources = m.reloadResources;+export const setDefaultNamespace = m.setDefaultNamespace;+export const t = m.t;+export const use = m.use;diff --git a/frontend/public/serverkit-vendor/react-dom-client.mjs b/frontend/public/serverkit-vendor/react-dom-client.mjsindex dea156b1..87402ee8 100644--- a/frontend/public/serverkit-vendor/react-dom-client.mjs+++ b/frontend/public/serverkit-vendor/react-dom-client.mjs@@ -1,4 +1,6 @@-// Runtime-extension shim for `react-dom/client` — re-exports the HOST instance.+// GENERATED by scripts/generate-vendor-shims.mjs — do not edit.+// Runtime-extension shim for `react-dom/client`: re-exports the HOST instance so+// the extension and the panel share one copy (see vendorManifest.js).const m = (globalThis.__SK_VENDOR__ || {})['react-dom/client'];if (!m) {throw new Error('[serverkit] host react-dom/client unavailable — vendorShare did not run');diff --git a/frontend/public/serverkit-vendor/react-dom.mjs b/frontend/public/serverkit-vendor/react-dom.mjsindex e5058d2c..5a0024c4 100644--- a/frontend/public/serverkit-vendor/react-dom.mjs+++ b/frontend/public/serverkit-vendor/react-dom.mjs@@ -1,13 +1,20 @@-// Runtime-extension shim for `react-dom` — re-exports the HOST instance.+// GENERATED by scripts/generate-vendor-shims.mjs — do not edit.+// Runtime-extension shim for `react-dom`: re-exports the HOST instance so+// the extension and the panel share one copy (see vendorManifest.js).const m = (globalThis.__SK_VENDOR__ || {})['react-dom'];if (!m) {throw new Error('[serverkit] host react-dom unavailable — vendorShare did not run');}export default m.default ?? m;+export const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;export const createPortal = m.createPortal;-export const flushSync = m.flushSync;+export const createRoot = m.createRoot;export const findDOMNode = m.findDOMNode;-export const render = m.render;+export const flushSync = m.flushSync;export const hydrate = m.hydrate;+export const hydrateRoot = m.hydrateRoot;+export const render = m.render;export const unmountComponentAtNode = m.unmountComponentAtNode;+export const unstable_batchedUpdates = m.unstable_batchedUpdates;+export const unstable_renderSubtreeIntoContainer = m.unstable_renderSubtreeIntoContainer;export const version = m.version;diff --git a/frontend/public/serverkit-vendor/react-i18next.mjs b/frontend/public/serverkit-vendor/react-i18next.mjsnew file mode 100644index 00000000..eb1398a3--- /dev/null+++ b/frontend/public/serverkit-vendor/react-i18next.mjs@@ -0,0 +1,32 @@+// GENERATED by scripts/generate-vendor-shims.mjs — do not edit.+// Runtime-extension shim for `react-i18next`: re-exports the HOST instance so+// the extension and the panel share one copy (see vendorManifest.js).+const m = (globalThis.__SK_VENDOR__ || {})['react-i18next'];+if (!m) {+ throw new Error('[serverkit] host react-i18next unavailable — vendorShare did not run');+}+export const I18nContext = m.I18nContext;+export const I18nextProvider = m.I18nextProvider;+export const IcuTrans = m.IcuTrans;+export const IcuTransWithoutContext = m.IcuTransWithoutContext;+export const Trans = m.Trans;+export const TransWithoutContext = m.TransWithoutContext;+export const Translation = m.Translation;+export const composeInitialProps = m.composeInitialProps;+export const date = m.date;+export const getDefaults = m.getDefaults;+export const getI18n = m.getI18n;+export const getInitialProps = m.getInitialProps;+export const initReactI18next = m.initReactI18next;+export const nodesToString = m.nodesToString;+export const number = m.number;+export const plural = m.plural;+export const select = m.select;+export const selectOrdinal = m.selectOrdinal;+export const setDefaults = m.setDefaults;+export const setI18n = m.setI18n;+export const time = m.time;+export const useSSR = m.useSSR;+export const useTranslation = m.useTranslation;+export const withSSR = m.withSSR;+export const withTranslation = m.withTranslation;diff --git a/frontend/public/serverkit-vendor/react-jsx-runtime.mjs b/frontend/public/serverkit-vendor/react-jsx-runtime.mjsindex 6c11b145..7f9d2d33 100644--- a/frontend/public/serverkit-vendor/react-jsx-runtime.mjs+++ b/frontend/public/serverkit-vendor/react-jsx-runtime.mjs@@ -1,11 +1,11 @@-// Runtime-extension shim for `react/jsx-runtime` — re-exports the HOST instance.-// Every JSX-automatic-runtime extension bundle imports this; the shim keeps it-// on the panel's single React copy.+// GENERATED by scripts/generate-vendor-shims.mjs — do not edit.+// Runtime-extension shim for `react/jsx-runtime`: re-exports the HOST instance so+// the extension and the panel share one copy (see vendorManifest.js).const m = (globalThis.__SK_VENDOR__ || {})['react/jsx-runtime'];if (!m) {throw new Error('[serverkit] host react/jsx-runtime unavailable — vendorShare did not run');}+export default m.default ?? m;export const Fragment = m.Fragment;export const jsx = m.jsx;export const jsxs = m.jsxs;-export const jsxDEV = m.jsxDEV;diff --git a/frontend/public/serverkit-vendor/react-router-dom.mjs b/frontend/public/serverkit-vendor/react-router-dom.mjsnew file mode 100644index 00000000..15dac367--- /dev/null+++ b/frontend/public/serverkit-vendor/react-router-dom.mjs@@ -0,0 +1,137 @@+// GENERATED by scripts/generate-vendor-shims.mjs — do not edit.+// Runtime-extension shim for `react-router-dom`: re-exports the HOST instance so+// the extension and the panel share one copy (see vendorManifest.js).+const m = (globalThis.__SK_VENDOR__ || {})['react-router-dom'];+if (!m) {+ throw new Error('[serverkit] host react-router-dom unavailable — vendorShare did not run');+}+export const Await = m.Await;+export const BrowserRouter = m.BrowserRouter;+export const Form = m.Form;+export const HashRouter = m.HashRouter;+export const HydratedRouter = m.HydratedRouter;+export const IDLE_BLOCKER = m.IDLE_BLOCKER;+export const IDLE_FETCHER = m.IDLE_FETCHER;+export const IDLE_NAVIGATION = m.IDLE_NAVIGATION;+export const Link = m.Link;+export const Links = m.Links;+export const MemoryRouter = m.MemoryRouter;+export const Meta = m.Meta;+export const NavLink = m.NavLink;+export const Navigate = m.Navigate;+export const NavigationType = m.NavigationType;+export const Outlet = m.Outlet;+export const PrefetchPageLinks = m.PrefetchPageLinks;+export const Route = m.Route;+export const Router = m.Router;+export const RouterContextProvider = m.RouterContextProvider;+export const RouterProvider = m.RouterProvider;+export const Routes = m.Routes;+export const Scripts = m.Scripts;+export const ScrollRestoration = m.ScrollRestoration;+export const ServerRouter = m.ServerRouter;+export const StaticRouter = m.StaticRouter;+export const StaticRouterProvider = m.StaticRouterProvider;+export const UNSAFE_AwaitContextProvider = m.UNSAFE_AwaitContextProvider;+export const UNSAFE_DataRouterContext = m.UNSAFE_DataRouterContext;+export const UNSAFE_DataRouterStateContext = m.UNSAFE_DataRouterStateContext;+export const UNSAFE_ErrorResponseImpl = m.UNSAFE_ErrorResponseImpl;+export const UNSAFE_FetchersContext = m.UNSAFE_FetchersContext;+export const UNSAFE_FrameworkContext = m.UNSAFE_FrameworkContext;+export const UNSAFE_LocationContext = m.UNSAFE_LocationContext;+export const UNSAFE_NavigationContext = m.UNSAFE_NavigationContext;+export const UNSAFE_RSCDefaultRootErrorBoundary = m.UNSAFE_RSCDefaultRootErrorBoundary;+export const UNSAFE_RemixErrorBoundary = m.UNSAFE_RemixErrorBoundary;+export const UNSAFE_RouteContext = m.UNSAFE_RouteContext;+export const UNSAFE_ServerMode = m.UNSAFE_ServerMode;+export const UNSAFE_SingleFetchRedirectSymbol = m.UNSAFE_SingleFetchRedirectSymbol;+export const UNSAFE_ViewTransitionContext = m.UNSAFE_ViewTransitionContext;+export const UNSAFE_WithComponentProps = m.UNSAFE_WithComponentProps;+export const UNSAFE_WithErrorBoundaryProps = m.UNSAFE_WithErrorBoundaryProps;+export const UNSAFE_WithHydrateFallbackProps = m.UNSAFE_WithHydrateFallbackProps;+export const UNSAFE_createBrowserHistory = m.UNSAFE_createBrowserHistory;+export const UNSAFE_createClientRoutes = m.UNSAFE_createClientRoutes;+export const UNSAFE_createClientRoutesWithHMRRevalidationOptOut = m.UNSAFE_createClientRoutesWithHMRRevalidationOptOut;+export const UNSAFE_createHashHistory = m.UNSAFE_createHashHistory;+export const UNSAFE_createMemoryHistory = m.UNSAFE_createMemoryHistory;+export const UNSAFE_createRouter = m.UNSAFE_createRouter;+export const UNSAFE_decodeViaTurboStream = m.UNSAFE_decodeViaTurboStream;+export const UNSAFE_getHydrationData = m.UNSAFE_getHydrationData;+export const UNSAFE_getPatchRoutesOnNavigationFunction = m.UNSAFE_getPatchRoutesOnNavigationFunction;+export const UNSAFE_getTurboStreamSingleFetchDataStrategy = m.UNSAFE_getTurboStreamSingleFetchDataStrategy;+export const UNSAFE_hydrationRouteProperties = m.UNSAFE_hydrationRouteProperties;+export const UNSAFE_invariant = m.UNSAFE_invariant;+export const UNSAFE_mapRouteProperties = m.UNSAFE_mapRouteProperties;+export const UNSAFE_shouldHydrateRouteLoader = m.UNSAFE_shouldHydrateRouteLoader;+export const UNSAFE_useFogOFWarDiscovery = m.UNSAFE_useFogOFWarDiscovery;+export const UNSAFE_useScrollRestoration = m.UNSAFE_useScrollRestoration;+export const UNSAFE_withComponentProps = m.UNSAFE_withComponentProps;+export const UNSAFE_withErrorBoundaryProps = m.UNSAFE_withErrorBoundaryProps;+export const UNSAFE_withHydrateFallbackProps = m.UNSAFE_withHydrateFallbackProps;+export const createBrowserRouter = m.createBrowserRouter;+export const createContext = m.createContext;+export const createCookie = m.createCookie;+export const createCookieSessionStorage = m.createCookieSessionStorage;+export const createHashRouter = m.createHashRouter;+export const createMemoryRouter = m.createMemoryRouter;+export const createMemorySessionStorage = m.createMemorySessionStorage;+export const createPath = m.createPath;+export const createRequestHandler = m.createRequestHandler;+export const createRoutesFromChildren = m.createRoutesFromChildren;+export const createRoutesFromElements = m.createRoutesFromElements;+export const createRoutesStub = m.createRoutesStub;+export const createSearchParams = m.createSearchParams;+export const createSession = m.createSession;+export const createSessionStorage = m.createSessionStorage;+export const createStaticHandler = m.createStaticHandler;+export const createStaticRouter = m.createStaticRouter;+export const data = m.data;+export const generatePath = m.generatePath;+export const href = m.href;+export const isCookie = m.isCookie;+export const isRouteErrorResponse = m.isRouteErrorResponse;+export const isSession = m.isSession;+export const matchPath = m.matchPath;+export const matchRoutes = m.matchRoutes;+export const parsePath = m.parsePath;+export const redirect = m.redirect;+export const redirectDocument = m.redirectDocument;+export const renderMatches = m.renderMatches;+export const replace = m.replace;+export const resolvePath = m.resolvePath;+export const unstable_HistoryRouter = m.unstable_HistoryRouter;+export const unstable_RSCStaticRouter = m.unstable_RSCStaticRouter;+export const unstable_routeRSCServerRequest = m.unstable_routeRSCServerRequest;+export const unstable_setDevServerHooks = m.unstable_setDevServerHooks;+export const unstable_usePrompt = m.unstable_usePrompt;+export const unstable_useRoute = m.unstable_useRoute;+export const unstable_useRouterState = m.unstable_useRouterState;+export const useActionData = m.useActionData;+export const useAsyncError = m.useAsyncError;+export const useAsyncValue = m.useAsyncValue;+export const useBeforeUnload = m.useBeforeUnload;+export const useBlocker = m.useBlocker;+export const useFetcher = m.useFetcher;+export const useFetchers = m.useFetchers;+export const useFormAction = m.useFormAction;+export const useHref = m.useHref;+export const useInRouterContext = m.useInRouterContext;+export const useLinkClickHandler = m.useLinkClickHandler;+export const useLoaderData = m.useLoaderData;+export const useLocation = m.useLocation;+export const useMatch = m.useMatch;+export const useMatches = m.useMatches;+export const useNavigate = m.useNavigate;+export const useNavigation = m.useNavigation;+export const useNavigationType = m.useNavigationType;+export const useOutlet = m.useOutlet;+export const useOutletContext = m.useOutletContext;+export const useParams = m.useParams;+export const useResolvedPath = m.useResolvedPath;+export const useRevalidator = m.useRevalidator;+export const useRouteError = m.useRouteError;+export const useRouteLoaderData = m.useRouteLoaderData;+export const useRoutes = m.useRoutes;+export const useSearchParams = m.useSearchParams;+export const useSubmit = m.useSubmit;+export const useViewTransitionState = m.useViewTransitionState;diff --git a/frontend/public/serverkit-vendor/react.mjs b/frontend/public/serverkit-vendor/react.mjsnew file mode 100644index 00000000..8524604c--- /dev/null+++ b/frontend/public/serverkit-vendor/react.mjs@@ -0,0 +1,44 @@+// GENERATED by scripts/generate-vendor-shims.mjs — do not edit.+// Runtime-extension shim for `react`: re-exports the HOST instance so+// the extension and the panel share one copy (see vendorManifest.js).+const m = (globalThis.__SK_VENDOR__ || {})['react'];+if (!m) {+ throw new Error('[serverkit] host react unavailable — vendorShare did not run');+}+export default m.default ?? m;+export const Children = m.Children;+export const Component = m.Component;+export const Fragment = m.Fragment;+export const Profiler = m.Profiler;+export const PureComponent = m.PureComponent;+export const StrictMode = m.StrictMode;+export const Suspense = m.Suspense;+export const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;+export const act = m.act;+export const cloneElement = m.cloneElement;+export const createContext = m.createContext;+export const createElement = m.createElement;+export const createFactory = m.createFactory;+export const createRef = m.createRef;+export const forwardRef = m.forwardRef;+export const isValidElement = m.isValidElement;+export const lazy = m.lazy;+export const memo = m.memo;+export const startTransition = m.startTransition;+export const unstable_act = m.unstable_act;+export const useCallback = m.useCallback;+export const useContext = m.useContext;+export const useDebugValue = m.useDebugValue;+export const useDeferredValue = m.useDeferredValue;+export const useEffect = m.useEffect;+export const useId = m.useId;+export const useImperativeHandle = m.useImperativeHandle;+export const useInsertionEffect = m.useInsertionEffect;+export const useLayoutEffect = m.useLayoutEffect;+export const useMemo = m.useMemo;+export const useReducer = m.useReducer;+export const useRef = m.useRef;+export const useState = m.useState;+export const useSyncExternalStore = m.useSyncExternalStore;+export const useTransition = m.useTransition;+export const version = m.version;diff --git a/frontend/public/serverkit-vendor/serverkit-sdk.mjs b/frontend/public/serverkit-vendor/serverkit-sdk.mjsindex 11819764..791fadd0 100644--- a/frontend/public/serverkit-vendor/serverkit-sdk.mjs+++ b/frontend/public/serverkit-vendor/serverkit-sdk.mjs@@ -1,40 +1,92 @@-// Runtime-extension shim for `serverkit-sdk` — re-exports the HOST's SDK-// instance (captured in globalThis.__SK_VENDOR__ by vendorShare.js). This IS-// the sanctioned SDK surface; keep it in lock-step with-// src/plugins/sdk/index.js (asserted by the frontend build + backend-// test_sdk_contract). A runtime extension imports everything it needs from-// here, so a host restructure behind the SDK never breaks it.+// GENERATED by scripts/generate-vendor-shims.mjs — do not edit.+// Runtime-extension shim for `serverkit-sdk`: re-exports the HOST instance so+// the extension and the panel share one copy (see vendorManifest.js).const m = (globalThis.__SK_VENDOR__ || {})['serverkit-sdk'];if (!m) {throw new Error('[serverkit] host serverkit-sdk unavailable — vendorShare did not run');}export const SDK_VERSION = m.SDK_VERSION;-// apiexport const api = m.api;export const defaultApi = m.defaultApi;-// design-system primitivesexport const KpiBand = m.KpiBand;export const MetricCard = m.MetricCard;export const Gauge = m.Gauge;export const ScoreGauge = m.ScoreGauge;export const Sparkline = m.Sparkline;export const Pill = m.Pill;+export const EnvTag = m.EnvTag;+export const SegControl = m.SegControl;+export const ServiceTile = m.ServiceTile;export const PageTopbar = m.PageTopbar;export const DataTable = m.DataTable;export const ResourceCard = m.ResourceCard;export const ResourceList = m.ResourceList;export const Drawer = m.Drawer;export const SchedulePicker = m.SchedulePicker;-// contexts / hooksexport const useToast = m.useToast;export const useAuth = m.useAuth;export const useTheme = m.useTheme;export const useServerkitAI = m.useServerkitAI;export const AIContext = m.AIContext;-// routing helpersexport const Link = m.Link;export const NavLink = m.NavLink;export const useNavigate = m.useNavigate;export const useLocation = m.useLocation;export const useParams = m.useParams;export const Outlet = m.Outlet;+export const TabGroupLayout = m.TabGroupLayout;+export const Modal = m.Modal;+export const ConfirmDialog = m.ConfirmDialog;+export const Spinner = m.Spinner;+export const LoadingState = m.LoadingState;+export const EmptyState = m.EmptyState;+export const SkeletonBoundary = m.SkeletonBoundary;+export const Skeleton = m.Skeleton;+export const Button = m.Button;+export const Input = m.Input;+export const Label = m.Label;+export const Switch = m.Switch;+export const Checkbox = m.Checkbox;+export const Textarea = m.Textarea;+export const Badge = m.Badge;+export const Select = m.Select;+export const SelectGroup = m.SelectGroup;+export const SelectValue = m.SelectValue;+export const SelectTrigger = m.SelectTrigger;+export const SelectContent = m.SelectContent;+export const SelectLabel = m.SelectLabel;+export const SelectItem = m.SelectItem;+export const SelectSeparator = m.SelectSeparator;+export const useConfirm = m.useConfirm;+export const useTabParam = m.useTabParam;+export const useTopbarActions = m.useTopbarActions;+export const formatBytes = m.formatBytes;+export const timeAgo = m.timeAgo;+export const formatRelativeTime = m.formatRelativeTime;+export const formatDuration = m.formatDuration;+export const useTranslation = m.useTranslation;+export const Trans = m.Trans;+export const t = m.t;+export const useLocale = m.useLocale;+export const translateLabel = m.translateLabel;+export const useLabel = m.useLabel;+export const useFormat = m.useFormat;+export const formatDate = m.formatDate;+export const formatTime = m.formatTime;+export const formatDateTime = m.formatDateTime;+export const formatRelative = m.formatRelative;+export const formatNumber = m.formatNumber;+export const formatPercent = m.formatPercent;+export const formatList = m.formatList;+export const ErrorBoundary = m.ErrorBoundary;+export const ErrorState = m.ErrorState;+export const DangerZone = m.DangerZone;+export const ResourceAdvisory = m.ResourceAdvisory;+export const PluginSlot = m.PluginSlot;+export const ResourceListPage = m.ResourceListPage;+export const useLogsDrawer = m.useLogsDrawer;+export const RepoConnectForm = m.RepoConnectForm;+export const GIT_PROVIDERS = m.GIT_PROVIDERS;+export const detectProvider = m.detectProvider;+export const RepoProviderStrip = m.RepoProviderStrip;+export const ProtectionPanel = m.ProtectionPanel;diff --git a/frontend/scripts/generate-vendor-shims.mjs b/frontend/scripts/generate-vendor-shims.mjsnew file mode 100644index 00000000..da4310d6--- /dev/null+++ b/frontend/scripts/generate-vendor-shims.mjs@@ -0,0 +1,142 @@+#!/usr/bin/env node+// Generate the runtime-extension vendor shims from one source of truth.+//+// A shim hands a runtime-loaded extension the HOST's instance of a module+// (captured in globalThis.__SK_VENDOR__ by vendorShare.js) instead of letting+// the extension bundle its own — two copies of React means "Invalid hook+// call", and two copies of i18next means an extension whose translations+// silently never load.+//+// Every shim is the same six lines around a list of export names, so the lists+// are DERIVED, never typed: from the real package's namespace for vendored+// modules, and from the SDK entry's own export statements for the SDK. Three+// hand-maintained copies of those lists is what produced the two bugs this+// replaces (see src/plugins/runtime/vendorManifest.js).+//+// Usage (from frontend/):+// node scripts/generate-vendor-shims.mjs # write the shims+// node scripts/generate-vendor-shims.mjs --check # fail if they drift++import { readFileSync, readdirSync, writeFileSync } from 'node:fs';+import { dirname, join, resolve } from 'node:path';+import { fileURLToPath } from 'node:url';+import { parse } from 'espree';+import { VENDOR_MODULES } from '../src/plugins/runtime/vendorManifest.js';++const here = dirname(fileURLToPath(import.meta.url));+const root = resolve(here, '..');+const outDir = resolve(root, 'public', 'serverkit-vendor');+const sdkEntry = resolve(root, 'src', 'plugins', 'sdk', 'index.js');+const vendorShare = resolve(root, 'src', 'plugins', 'runtime', 'vendorShare.js');++/** Export names of the SDK entry, read from its own export statements. */+function sdkExportNames() {+ const ast = parse(readFileSync(sdkEntry, 'utf8'), {+ ecmaVersion: 'latest',+ sourceType: 'module',+ });+ const names = [];+ for (const node of ast.body) {+ if (node.type === 'ExportNamedDeclaration') {+ for (const specifier of node.specifiers || []) {+ names.push(specifier.exported.name);+ }+ const declaration = node.declaration;+ if (declaration?.type === 'VariableDeclaration') {+ for (const d of declaration.declarations) names.push(d.id.name);+ } else if (declaration?.id) {+ names.push(declaration.id.name);+ }+ }+ }+ // `default` cannot be re-exported as a const; the SDK has no default anyway.+ return [...new Set(names)].filter((name) => name !== 'default');+}++/** Export names of a real package, read from its namespace object. */+async function moduleExportNames(specifier) {+ const namespace = await import(specifier);+ return Object.keys(namespace)+ .filter((name) => name !== 'default')+ // Valid identifiers only — a namespace can carry exotic keys that+ // cannot appear on the left of `export const`.+ .filter((name) => /^[A-Za-z_$][\w$]*$/.test(name))+ .sort();+}++function render(specifier, names, hasDefault) {+ const lines = [+ '// GENERATED by scripts/generate-vendor-shims.mjs — do not edit.',+ `// Runtime-extension shim for \`${specifier}\`: re-exports the HOST instance so`,+ '// the extension and the panel share one copy (see vendorManifest.js).',+ `const m = (globalThis.__SK_VENDOR__ || {})['${specifier}'];`,+ 'if (!m) {',+ ` throw new Error('[serverkit] host ${specifier} unavailable — vendorShare did not run');`,+ '}',+ ];+ if (hasDefault) lines.push('export default m.default ?? m;');+ for (const name of names) lines.push(`export const ${name} = m.${name};`);+ return `${lines.join('\n')}\n`;+}++const generated = new Map();+for (const entry of VENDOR_MODULES) {+ let names;+ let hasDefault = false;+ if (entry.exportsFrom === 'sdk') {+ names = sdkExportNames();+ } else {+ const namespace = await import(entry.specifier);+ hasDefault = 'default' in namespace;+ names = await moduleExportNames(entry.specifier);+ }+ generated.set(entry.file, render(entry.specifier, names, hasDefault));+}++// vendorShare.js must capture exactly these specifiers, or a shim resolves to+// undefined at runtime with a misleading "did not run" message.+const shareSource = readFileSync(vendorShare, 'utf8');+const missingShare = VENDOR_MODULES+ .map((entry) => entry.specifier)+ .filter((specifier) => !shareSource.includes(`'${specifier}':`));++const problems = [];+if (missingShare.length) {+ problems.push(`vendorShare.js does not capture: ${missingShare.join(', ')}`);+}++if (process.argv.includes('--check')) {+ const onDisk = new Set(readdirSync(outDir).filter((name) => name.endsWith('.mjs')));+ for (const [file, contents] of generated) {+ if (!onDisk.has(file)) {+ problems.push(`missing shim: ${file}`);+ continue;+ }+ onDisk.delete(file);+ if (readFileSync(join(outDir, file), 'utf8') !== contents) {+ problems.push(`stale shim: ${file}`);+ }+ }+ for (const orphan of onDisk) problems.push(`orphan shim (not in the manifest): ${orphan}`);++ if (problems.length) {+ console.error('\nvendor shim check failed:\n');+ for (const problem of problems) console.error(` ${problem}`);+ console.error('\n node scripts/generate-vendor-shims.mjs\n');+ process.exit(1);+ }+ console.log(`✓ vendor shims: ${generated.size} shims match the manifest.`);+ process.exit(0);+}++if (problems.length) {+ console.error('\nvendor shim generation failed:\n');+ for (const problem of problems) console.error(` ${problem}`);+ console.error('');+ process.exit(1);+}++for (const [file, contents] of generated) {+ writeFileSync(join(outDir, file), contents);+}+console.log(`✓ wrote ${generated.size} vendor shims to public/serverkit-vendor/.`);diff --git a/frontend/src/components/CommandPalette.jsx b/frontend/src/components/CommandPalette.jsxindex b976226a..5a7619af 100644--- a/frontend/src/components/CommandPalette.jsx+++ b/frontend/src/components/CommandPalette.jsx@@ -157,12 +157,12 @@ const CommandPalette = ({ open, onClose }) => {.filter((it) => it && it.label && it.path).map((it) => ({id: `plugin:${it.path}:${it.label}`,- label: it.label,+ label: translateLabel(t, it),keywords: it.keywords || '',path: it.path,category: it.category || 'Extensions',})),- [pluginPaletteItems],+ [pluginPaletteItems, t],);const docItems = useMemo(() => {diff --git a/frontend/src/layouts/TabGroupLayout.jsx b/frontend/src/layouts/TabGroupLayout.jsxindex 6e173edd..1bb987c8 100644--- a/frontend/src/layouts/TabGroupLayout.jsx+++ b/frontend/src/layouts/TabGroupLayout.jsx@@ -1,8 +1,10 @@import { useState, useMemo } from 'react';+import { useTranslation } from 'react-i18next';import { Outlet, useLocation } from 'react-router-dom';import { PageTopbar } from '@/components/ds';import { useContributions } from '@/plugins/contributions';import { sanitizeSvgInner } from '@/utils/sanitizeSvg';+import { translateLabel } from '@/i18n/labels';// Generic shell for a PageTopbar tab group (Servers, Domains, Services, Files,// Monitoring, Marketplace, …). A parent route renders the PageTopbar + routed@@ -50,6 +52,7 @@ function contributedIcon(inner) {}export default function TabGroupLayout({ tabs, groupId }) {+ const { t: translate } = useTranslation();const location = useLocation();const [actions, setActions] = useState(null);// Two slots, not one. `actions` is the page's ("Add domain") and comes up@@ -78,7 +81,9 @@ export default function TabGroupLayout({ tabs, groupId }) {.filter((t) => !tabs.some((core) => core.to === t.to)).map((t) => ({to: t.to,- label: t.label,+ // An extension tab may declare `labelKey` beside `label`;+ // core tabs already do. Same resolver either way.+ label: translateLabel(translate, t),end: !!t.end,icon: contributedIcon(t.icon),order: t.order,@@ -93,7 +98,7 @@ export default function TabGroupLayout({ tabs, groupId }) {merged.splice(idx, 0, tab);}return merged;- }, [tabs, groupId, contributedTabs]);+ }, [tabs, groupId, contributedTabs, translate]);// The group renders no page title: the tab strip IS the heading, so it runs// flush-left in the bar (the active tab already names the section, as doesdiff --git a/frontend/src/plugins/runtime/vendorManifest.js b/frontend/src/plugins/runtime/vendorManifest.jsnew file mode 100644index 00000000..2428ed91--- /dev/null+++ b/frontend/src/plugins/runtime/vendorManifest.js@@ -0,0 +1,46 @@+/**+ * The single list of modules a runtime-loaded extension resolves through the+ * host (plan 25 Decision 2; plan 79 §SDK).+ *+ * Three things used to restate this list independently — the import map in+ * vite.config.js, the namespace capture in vendorShare.js, and one+ * hand-written shim per module under public/serverkit-vendor/. They drifted,+ * exactly as three copies of anything do:+ *+ * * `react.mjs` and `react-router-dom.mjs` were in the import map but had no+ * shim at all, so an extension importing bare `react` 404'd at load;+ * * the `serverkit-sdk` shim re-exported 26 of the SDK's 71 exports, so an+ * extension importing `Button`, `Modal`, `EmptyState` or `formatBytes`+ * from the SDK got `undefined` and crashed.+ *+ * Now this file is the list, the shims are generated from it+ * (`npm run vendor:shims`), and `--check` fails the build on drift.+ *+ * `exportsFrom` says where the generator learns a module's export names:+ * 'module' — import the real package and read its namespace keys;+ * 'sdk' — parse the SDK entry's own export statements.+ * Either way the names are derived, never typed out here.+ */+export const VENDOR_MODULES = [+ { specifier: 'react', file: 'react.mjs', exportsFrom: 'module' },+ { specifier: 'react-dom', file: 'react-dom.mjs', exportsFrom: 'module' },+ { specifier: 'react-dom/client', file: 'react-dom-client.mjs', exportsFrom: 'module' },+ { specifier: 'react/jsx-runtime', file: 'react-jsx-runtime.mjs', exportsFrom: 'module' },+ { specifier: 'react-router-dom', file: 'react-router-dom.mjs', exportsFrom: 'module' },+ // i18next and react-i18next are shared for the same reason React is: an+ // extension bundling its own copy would get a SEPARATE, uninitialised+ // i18next, so every `t()` in that extension would silently render its+ // English default forever — the failure mode plan 79 hit twice in core.+ { specifier: 'i18next', file: 'i18next.mjs', exportsFrom: 'module' },+ { specifier: 'react-i18next', file: 'react-i18next.mjs', exportsFrom: 'module' },+ { specifier: 'serverkit-sdk', file: 'serverkit-sdk.mjs', exportsFrom: 'sdk' },+];++/** `{ specifier: '/serverkit-vendor/<file>' }` — the browser import map. */+export const VENDOR_IMPORTMAP = {+ imports: Object.fromEntries(+ VENDOR_MODULES.map(({ specifier, file }) => [specifier, `/serverkit-vendor/${file}`]),+ ),+};++export default VENDOR_MODULES;diff --git a/frontend/src/plugins/runtime/vendorShare.js b/frontend/src/plugins/runtime/vendorShare.jsindex b0d32ef8..71f7908d 100644--- a/frontend/src/plugins/runtime/vendorShare.js+++ b/frontend/src/plugins/runtime/vendorShare.js@@ -1,8 +1,9 @@/*** Host vendor sharing for runtime-loaded extension bundles (plan 25 Decision 2).*- * A runtime extension bundle externalizes the shared libraries (`react`,- * `react-dom`, `react/jsx-runtime`, `react-router-dom`, `serverkit-sdk`) and+ * A runtime extension bundle externalizes the shared libraries (react,+ * react-dom, react/jsx-runtime, react-router-dom, i18next, react-i18next,+ * serverkit-sdk — the list lives in ./vendorManifest.js) and* resolves them at load time through a static import map injected into* index.html (see vite.config.js `serverkitImportmap`). Each mapped URL points* at a small shim under `/serverkit-vendor/*.mjs` that re-exports from THIS@@ -21,6 +22,8 @@ import * as ReactDOM from 'react-dom';import * as ReactDOMClient from 'react-dom/client';import * as JsxRuntime from 'react/jsx-runtime';import * as ReactRouterDom from 'react-router-dom';+import * as I18next from 'i18next';+import * as ReactI18next from 'react-i18next';import * as ServerkitSdk from 'serverkit-sdk';const vendor = {@@ -29,6 +32,11 @@ const vendor = {'react-dom/client': ReactDOMClient,'react/jsx-runtime': JsxRuntime,'react-router-dom': ReactRouterDom,+ // Shared for the same reason React is: a second i18next instance would be+ // uninitialised, so every t() in that extension would render its English+ // default forever and nothing would report it.+ 'i18next': I18next,+ 'react-i18next': ReactI18next,'serverkit-sdk': ServerkitSdk,};diff --git a/frontend/src/plugins/sdk/index.js b/frontend/src/plugins/sdk/index.jsindex 5058a272..94922e0d 100644--- a/frontend/src/plugins/sdk/index.js+++ b/frontend/src/plugins/sdk/index.js@@ -38,7 +38,7 @@// GET /api/v1/plugins/contributions. The backend mirror lives in// backend/app/utils/sdk.py — keep the two in lock-step (asserted by// backend/tests/test_sdk_contract.py).-export const SDK_VERSION = '1.2.0';+export const SDK_VERSION = '1.3.0';export { api, default as defaultApi } from '../../services/api';@@ -132,6 +132,27 @@ export { useTopbarActions } from '../../hooks/useTopbarActions';export { formatBytes } from '../../utils/formatBytes';export { timeAgo, formatRelativeTime, formatDuration } from '../../utils/time';+// Localization (plan 79). These are the HOST's singletons, not a parallel+// extension i18n: `useTranslation`/`Trans` resolve against the panel's own+// i18next instance (shared via vendorManifest), so an extension's copy follows+// the user's language, plural rules and locale switch with no wiring of its+// own. An extension ships its keys as inline defaults exactly like core —+// `t('myext.title', 'My Extension')` — so a missing bundle renders English+// rather than a raw key path.+export { useTranslation, Trans } from 'react-i18next';+export { t } from '../../i18n/t';+export { useLocale } from '../../contexts/LocaleContext';+export { translateLabel, default as useLabel } from '../../i18n/labels';++// The one locale-aware formatting door. An extension MUST NOT call+// `toLocaleDateString()` itself: with no argument it follows the browser, not+// the panel, so its dates would disagree with every date around them.+export { default as useFormat } from '../../hooks/useFormat';+export {+ formatDate, formatTime, formatDateTime, formatRelative,+ formatNumber, formatPercent, formatList,+} from '../../utils/intl';+// Generic page furniture + cross-feature embeds (plan 52 Phase 5 — the// WordPress runtime-ESM extraction proved these out). Two consumer classes:// - generic primitives any extension page may need (ErrorBoundary,diff --git a/frontend/vite.config.js b/frontend/vite.config.jsindex 1e4b0dbb..87527f35 100644--- a/frontend/vite.config.js+++ b/frontend/vite.config.js@@ -2,6 +2,7 @@import { defineConfig, loadEnv } from 'vite'import react from '@vitejs/plugin-react'import { fileURLToPath } from 'url'+import { VENDOR_IMPORTMAP } from './src/plugins/runtime/vendorManifest.js'// Runtime-extension import map (plan 25 Decision 2). A runtime-loaded extension// bundle externalizes exactly these bare specifiers and resolves them at load@@ -11,16 +12,9 @@ import { fileURLToPath } from 'url'// runtime loading is a production concern (dev uses the build-time glob path).// The map is inert for the host's own code (bundled to hashed relative chunks,// never bare specifiers) — it only affects the extension blobs.-const VENDOR_IMPORTMAP = {- imports: {- 'react': '/serverkit-vendor/react.mjs',- 'react-dom': '/serverkit-vendor/react-dom.mjs',- 'react-dom/client': '/serverkit-vendor/react-dom-client.mjs',- 'react/jsx-runtime': '/serverkit-vendor/react-jsx-runtime.mjs',- 'react-router-dom': '/serverkit-vendor/react-router-dom.mjs',- 'serverkit-sdk': '/serverkit-vendor/serverkit-sdk.mjs',- },-}+// Sourced from the ONE vendor manifest, so the import map, the shims under+// public/serverkit-vendor/ and vendorShare's namespace capture cannot drift+// apart. They previously did: two mapped specifiers had no shim at all.function serverkitImportmap() {return {@@ -74,14 +68,17 @@ export default defineConfig(({ mode }) => {// serves raw ESM, which (combined with pre-bundled// react-dom) recreates the same two-copies problem from the// other direction.- dedupe: ['react', 'react-dom', 'react-router-dom'],+ // i18next/react-i18next join the list for the same reason: two+ // instances means an extension's t() reads an uninitialised store+ // and silently renders English forever (plan 79).+ dedupe: ['react', 'react-dom', 'react-router-dom', 'i18next', 'react-i18next'],},optimizeDeps: {// Pre-bundle the renderer at server start instead of// discovering it lazily. Lazy discovery is what triggers the// mid-session re-bundle that strands the open browser tab// on a stale React URL.- include: ['react', 'react-dom', 'react-router-dom'],+ include: ['react', 'react-dom', 'react-router-dom', 'i18next', 'react-i18next'],},server: {port: frontendPort,