mirror of
https://github.com/penpot/penpot.git
synced 2026-11-18 08:01:21 +00:00
* 🐛 Keep app booting when SES bootstrap fails Wrap repairIntrinsics in a guarded bootstrap so a SES Temporal check failure no longer aborts bundle evaluation and blanks the whole app. When it fails, plugins and MCP stay unavailable for that session, a telemetry event reports the error, and trying to open a plugin shows an environment warning. Add vitest coverage for both bootstrap paths and a CLJS regression test for the runtime-unavailable toast. Closes #12924 AI-assisted-by: hy4-flash-free * 🐛 Fix CI format check and plugin test entry point Wrap the long Prettier line in bootstrap.spec.ts so `pnpm run format:check` passes again in the plugins module, and document that the duplicated SES options are an intentional contract snapshot. Switch the runtime-unavailable CLJS test to the public open-plugin! entry point instead of the private load-plugin! function. The M2 test for signal-runtime-ready was dropped: loading app.plugins in the Node test runner needs packaging and DOM shim changes outside this fix. Closes #12924 AI-assisted-by: hy4-flash-free
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
import 'ses';
|
|
import './lib/modal/plugin-modal';
|
|
|
|
import { bootstrapSES } from './lib/bootstrap.js';
|
|
import {
|
|
ɵloadPlugin,
|
|
setContextBuilder,
|
|
ɵloadPluginByUrl,
|
|
ɵunloadPlugin,
|
|
} from './lib/load-plugin.js';
|
|
|
|
// Export the plugin error checker so the frontend can identify plugin errors
|
|
export { isPluginError } from './lib/create-sandbox.js';
|
|
|
|
import type { Context } from '@penpot/plugin-types';
|
|
|
|
console.log('%c[PLUGINS] Loading plugin system', 'color: #008d7c');
|
|
|
|
const sesError = bootstrapSES();
|
|
|
|
if (sesError) {
|
|
console.error(
|
|
'[PLUGINS] SES bootstrap failed; plugins disabled in this environment.',
|
|
sesError,
|
|
);
|
|
}
|
|
|
|
/** Returns the SES bootstrap error, or null when the runtime can be used. */
|
|
export const getPluginsRuntimeError = (): Error | null => sesError;
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
const globalThisAny$ = globalThis as any;
|
|
|
|
export const initPluginsRuntime = (contextBuilder: (id: string) => Context) => {
|
|
if (sesError) {
|
|
console.error('[PLUGINS] Skipping plugin runtime initialization.');
|
|
return;
|
|
}
|
|
|
|
try {
|
|
console.log('%c[PLUGINS] Initialize runtime', 'color: #008d7c');
|
|
setContextBuilder(contextBuilder);
|
|
globalThisAny$.ɵcontext = contextBuilder(
|
|
'00000000-0000-0000-0000-000000000000',
|
|
);
|
|
globalThis.ɵloadPlugin = ɵloadPlugin;
|
|
globalThis.ɵloadPluginByUrl = ɵloadPluginByUrl;
|
|
globalThis.ɵunloadPlugin = ɵunloadPlugin;
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|
|
};
|