From 8ac8a812f6e6c1727a193a950263305a28778d1c Mon Sep 17 00:00:00 2001 From: anikitenko Date: Sun, 19 Apr 2026 00:44:23 +0300 Subject: [PATCH 1/2] fix(examples): fix 2 test --- Assistant.md | 485 +++ CHANGELOG.md | 46 + README.md | 179 +- bin/fdo-sdk.js | 37 + docs/API_STABILITY.md | 32 + docs/ARCHITECTURE.md | 7 +- docs/EXAMPLES_AND_FIXTURES.md | 26 + docs/EXTENSION_POINTS.md | 8 + docs/HOST_PRIVILEGED_ACTIONS_CONTRACT.md | 70 +- docs/INJECTED_LIBRARIES.md | 18 + docs/OPERATOR_PLUGIN_PATTERNS.md | 26 +- docs/QUICK_REFERENCE.md | 8 + docs/RENDER_RUNTIME_CONTRACT.md | 77 +- docs/SAFE_PLUGIN_AUTHORING.md | 134 +- docs/SHAREPOINT_PROVIDER_HOST_CONTRACT.md | 92 + examples/03-persistence-plugin.ts | 6 +- examples/07-injected-libraries-demo.ts | 46 +- examples/08-privileged-actions-plugin.ts | 17 +- examples/09-operator-plugin.ts | 15 +- examples/10-system-file-plugin.ts | 28 +- .../11-hosts-manager-plugin/HostsLogic.ts | 47 + examples/11-hosts-manager-plugin/index.ts | 447 ++ .../11-hosts-manager-plugin/styles/style.css | 341 ++ examples/12-git-operations-plugin.ts | 3792 +++++++++++++++++ examples/13-service-content-hub-plugin.ts | 2509 +++++++++++ examples/README.md | 92 +- .../operator-custom-tool-plugin.fixture.ts | 22 +- .../operator-kubernetes-plugin.fixture.ts | 22 +- .../operator-terraform-plugin.fixture.ts | 22 +- examples/fixtures/storage-plugin.fixture.ts | 6 +- package.json | 6 + scripts/fdo-sdk-migrate.mjs | 236 + scripts/verify-docs.mjs | 183 +- src/DOMButton.ts | 23 +- src/FDOInterface.ts | 12 +- src/PluginRegistry.ts | 47 +- src/index.ts | 77 +- src/types.ts | 329 ++ src/utils/aiTooling.ts | 41 + src/utils/capabilities.ts | 386 +- src/utils/contracts.ts | 22 + src/utils/diagnosticTemplates.ts | 157 + src/utils/editorSupport.ts | 126 + src/utils/fixtureRuntimeMatrix.ts | 183 + src/utils/handshake.ts | 169 + src/utils/migrationCodemod.ts | 133 + src/utils/pluginDoctor.ts | 338 ++ src/utils/privilegedResponses.ts | 93 +- src/utils/privilegedTransport.ts | 79 + src/utils/renderOnLoad.ts | 399 ++ src/utils/storageTooling.ts | 38 + src/version.ts | 20 + tests/DOMButton.test.ts | 15 + tests/PluginRegistry.test.ts | 21 +- tests/contracts.test.ts | 38 +- tests/examples.service-content-hub.test.ts | 359 ++ tests/examples.system-file.test.ts | 26 + tests/index.test.ts | 72 +- tests/utils/capabilities.test.ts | 144 +- tests/utils/editorSupport.test.ts | 86 + tests/utils/fixtureRuntimeMatrix.test.ts | 49 + tests/utils/handshake.test.ts | 97 + tests/utils/migrationCodemod.test.ts | 57 + tests/utils/pluginDoctor.test.ts | 168 + tests/utils/pluginDoctorPanel.test.ts | 98 + tests/utils/privilegedResponses.test.ts | 46 + tests/utils/privilegedTransport.test.ts | 95 + tests/utils/renderOnLoad.test.ts | 199 + tests/utils/storageTooling.test.ts | 25 + webpack.config.cjs | 5 + 70 files changed, 13258 insertions(+), 96 deletions(-) create mode 100644 Assistant.md create mode 100755 bin/fdo-sdk.js create mode 100644 docs/SHAREPOINT_PROVIDER_HOST_CONTRACT.md create mode 100644 examples/11-hosts-manager-plugin/HostsLogic.ts create mode 100644 examples/11-hosts-manager-plugin/index.ts create mode 100644 examples/11-hosts-manager-plugin/styles/style.css create mode 100644 examples/12-git-operations-plugin.ts create mode 100644 examples/13-service-content-hub-plugin.ts create mode 100644 scripts/fdo-sdk-migrate.mjs create mode 100644 src/utils/aiTooling.ts create mode 100644 src/utils/diagnosticTemplates.ts create mode 100644 src/utils/editorSupport.ts create mode 100644 src/utils/fixtureRuntimeMatrix.ts create mode 100644 src/utils/handshake.ts create mode 100644 src/utils/migrationCodemod.ts create mode 100644 src/utils/pluginDoctor.ts create mode 100644 src/utils/renderOnLoad.ts create mode 100644 src/utils/storageTooling.ts create mode 100644 src/version.ts create mode 100644 tests/examples.service-content-hub.test.ts create mode 100644 tests/examples.system-file.test.ts create mode 100644 tests/utils/editorSupport.test.ts create mode 100644 tests/utils/fixtureRuntimeMatrix.test.ts create mode 100644 tests/utils/handshake.test.ts create mode 100644 tests/utils/migrationCodemod.test.ts create mode 100644 tests/utils/pluginDoctor.test.ts create mode 100644 tests/utils/pluginDoctorPanel.test.ts create mode 100644 tests/utils/renderOnLoad.test.ts create mode 100644 tests/utils/storageTooling.test.ts diff --git a/Assistant.md b/Assistant.md new file mode 100644 index 0000000..15ce2bb --- /dev/null +++ b/Assistant.md @@ -0,0 +1,485 @@ +# Assistant Guide + +This file is a concise, assistant-facing guide for working with `@anikitenko/fdo-sdk`. +It is intended for Mintlify or other docs surfaces that need one high-signal overview instead of many separate internal documents. + +## What This SDK Is + +`@anikitenko/fdo-sdk` is an SDK for building FDO desktop application plugins. + +The SDK spans two runtimes: + +- Backend/plugin runtime + - plugin class lifecycle + - handler registration + - storage + - logging + - host IPC +- Iframe UI runtime + - UI returned by `render()` + - browser DOM access + - host-injected helpers and UI libraries + - sandboxed iframe execution managed by FDO + +The most important rule is: plugin backend logic and plugin UI logic do not run in the same environment. + +## Core Mental Model + +Treat `render()` output as UI source for the FDO iframe render pipeline, not as arbitrary raw HTML inserted directly into the host page. + +That means: + +- `render()` must synchronously return a string +- `renderOnLoad()` may synchronously return: + - a string + - a function + - a `defineRenderOnLoad(...)` payload +- FDO serializes and transports these pieces separately +- UI code runs later inside a sandboxed iframe + +If you are generating UI with SDK DOM helpers and expect helper-generated styles to work, you must wrap the final helper output with `renderHTML(...)`. + +## Start Here + +Recommended order for understanding and building plugins: + +1. Read `README.md` +2. Read `docs/RENDER_RUNTIME_CONTRACT.md` +3. Read `docs/SAFE_PLUGIN_AUTHORING.md` +4. Read `docs/EXTENSION_POINTS.md` +5. Study `examples/fixtures/minimal-plugin.fixture.ts` +6. Then move to numbered examples in `examples/` + +## Minimal Plugin Shape + +Every plugin should provide: + +- `metadata` +- `init()` +- `render()` + +Typical shape: + +```ts +import { FDO_SDK, FDOInterface, PluginMetadata } from "@anikitenko/fdo-sdk"; + +export default class MyPlugin extends FDO_SDK implements FDOInterface { + private readonly _metadata: PluginMetadata = { + name: "My Plugin", + version: "1.0.0", + author: "Your Name", + description: "Plugin description", + icon: "cog", + }; + + get metadata(): PluginMetadata { + return this._metadata; + } + + init(): void { + this.info("plugin initialized"); + } + + render(): string { + return `
Hello World
`; + } +} +``` + +## Metadata Rules + +Plugin metadata is part of the host contract. + +Rules: + +- define full metadata: `name`, `version`, `author`, `description`, `icon` +- prefer a stable `metadata.id` if your host/plugin flow supports it +- `metadata.icon` must be a valid BlueprintJS v6 icon name + +## Backend Runtime Rules + +Use backend runtime for: + +- `init()` +- registering handlers +- stores +- logging +- diagnostics +- host-mediated privileged actions + +Do not assume browser-only globals or injected UI libraries exist here. + +Do not use iframe-specific APIs in backend/bootstrap paths. + +## Iframe UI Runtime Rules + +Use iframe runtime for: + +- DOM access +- event binding +- `window.createBackendReq(...)` +- host-injected helpers +- UI libraries injected by FDO + +Common helpers available in iframe runtime: + +- `window.createBackendReq(...)` +- `window.waitForElement(...)` +- `window.executeInjectedScript(...)` +- `window.addGlobalEventListener(...)` +- `window.removeGlobalEventListener(...)` +- `window.applyClassToSelector(...)` + +Common injected libraries: + +- Notyf +- Highlight.js +- ACE +- Split Grid +- FontAwesome +- Pure CSS + +Do not assume these libraries exist in backend runtime or failure/bootstrap paths. + +## Safe Markup Rules + +The iframe render pipeline is JSX-like and stricter than “whatever a browser would parse.” + +Important rules: + +- prefer JSX-safe void tags like `
` +- avoid inline `