@plitzi/sdk-server 0.32.25 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +326 -162
- package/dist/adapters/authAdapters.d.ts +21 -0
- package/dist/adapters/authAdapters.js +12 -0
- package/dist/adapters/jsonAdapters.d.ts +15 -0
- package/dist/adapters/jsonAdapters.js +9 -4
- package/dist/core/auth/api.d.ts +148 -0
- package/dist/core/auth/api.js +286 -0
- package/dist/core/auth/authorize.d.ts +96 -0
- package/dist/core/auth/authorize.js +92 -0
- package/dist/core/auth/createAuth.d.ts +165 -0
- package/dist/core/auth/createAuth.js +105 -0
- package/dist/core/auth/credentials.d.ts +29 -0
- package/dist/core/auth/credentials.js +48 -0
- package/dist/core/auth/domains.d.ts +41 -0
- package/dist/core/auth/domains.js +78 -0
- package/dist/core/auth/identity.d.ts +108 -0
- package/dist/core/auth/identity.js +164 -0
- package/dist/core/auth/oauth/client.d.ts +5 -0
- package/dist/core/auth/oauth/client.js +47 -0
- package/dist/core/auth/oauth/index.d.ts +78 -0
- package/dist/core/auth/oauth/index.js +113 -0
- package/dist/core/auth/oauth/providers/github.d.ts +2 -0
- package/dist/core/auth/oauth/providers/github.js +48 -0
- package/dist/core/auth/oauth/providers/google.d.ts +2 -0
- package/dist/core/auth/oauth/providers/google.js +30 -0
- package/dist/core/auth/oauth/state.d.ts +23 -0
- package/dist/core/auth/oauth/state.js +55 -0
- package/dist/core/auth/oauth/types.d.ts +51 -0
- package/dist/core/auth/oauth/types.js +13 -0
- package/dist/core/auth/routes.d.ts +50 -0
- package/dist/core/auth/routes.js +129 -0
- package/dist/core/auth/session.d.ts +128 -0
- package/dist/core/auth/session.js +165 -0
- package/dist/core/auth/spaceTokens.d.ts +137 -0
- package/dist/core/auth/spaceTokens.js +212 -0
- package/dist/core/auth/tokens.d.ts +151 -0
- package/dist/core/auth/tokens.js +221 -0
- package/dist/core/createServer.d.ts +29 -0
- package/dist/core/createServer.js +28 -14
- package/dist/core/handlers/authMiddleware.d.ts +27 -0
- package/dist/core/handlers/authMiddleware.js +38 -0
- package/dist/core/handlers/authRouteHandlers.d.ts +46 -0
- package/dist/core/handlers/authRouteHandlers.js +75 -0
- package/dist/core/handlers/types.d.ts +37 -0
- package/dist/{src/core → core}/http/dispatcher.d.ts +2 -2
- package/dist/core/http/dispatcher.js +8 -6
- package/dist/core/http/navigation.d.ts +11 -0
- package/dist/core/http/navigation.js +16 -0
- package/dist/core/http/securityHeaders.js +6 -4
- package/dist/core/http/stages/authApi.d.ts +17 -0
- package/dist/core/http/stages/authApi.js +66 -0
- package/dist/core/http/stages/authRoutes.js +40 -11
- package/dist/core/http/stages/exchangeRoute.d.ts +15 -0
- package/dist/core/http/stages/exchangeRoute.js +67 -0
- package/dist/core/http/stages/health.d.ts +11 -0
- package/dist/core/http/stages/health.js +25 -3
- package/dist/core/http/stages/middlewares.d.ts +2 -0
- package/dist/core/http/stages/static.d.ts +13 -0
- package/dist/core/http/stages/static.js +21 -6
- package/dist/core/http/types.d.ts +35 -0
- package/dist/{modules/mcp/constants.js → core/previewToken.js} +1 -1
- package/dist/core/sdkAssets.d.ts +16 -0
- package/dist/core/sdkAssets.js +46 -0
- package/dist/core/server/baseServer.js +40 -5
- package/dist/core/server/pageServer.d.ts +7 -0
- package/dist/core/server/pageServer.js +13 -17
- package/dist/core/services/action.d.ts +9 -0
- package/dist/core/services/action.js +21 -0
- package/dist/core/services/registry.d.ts +3 -0
- package/dist/core/services/registry.js +9 -19
- package/dist/{src/core → core}/services/resolve.d.ts +1 -0
- package/dist/core/services/resolve.js +6 -4
- package/dist/core/services/rsc.js +3 -2
- package/dist/core/staticFiles.js +1 -1
- package/dist/{src/core → core}/transports.d.ts +3 -0
- package/dist/core/transports.js +7 -6
- package/dist/handlers.d.ts +58 -0
- package/dist/handlers.js +3 -0
- package/dist/{src/helpers → helpers}/buildResponseHelpers.d.ts +2 -1
- package/dist/helpers/buildResponseHelpers.js +13 -4
- package/dist/helpers/buildServerInfo.d.ts +3 -0
- package/dist/helpers/buildServerInfo.js +25 -3
- package/dist/{src/helpers → helpers}/cache/keys.d.ts +5 -1
- package/dist/helpers/cache/keys.js +1 -1
- package/dist/helpers/compress.d.ts +18 -0
- package/dist/helpers/compress.js +47 -11
- package/dist/helpers/offlineDataLoader.d.ts +11 -0
- package/dist/helpers/offlineDataLoader.js +15 -0
- package/dist/helpers/resolveDebugMode.d.ts +10 -0
- package/dist/helpers/resolveDebugMode.js +13 -0
- package/dist/index.d.ts +16 -2
- package/dist/index.js +9 -20
- package/dist/kernel.d.ts +41 -0
- package/dist/kernel.js +22 -0
- package/dist/middlewares/spaceDeployment.d.ts +2 -0
- package/dist/middlewares/spaceDeployment.js +2 -1
- package/dist/modules/actions/handler.d.ts +11 -0
- package/dist/modules/actions/handler.js +77 -0
- package/dist/modules/connectors/engine.d.ts +42 -0
- package/dist/modules/connectors/engine.js +221 -0
- package/dist/modules/connectors/getByPath.d.ts +8 -0
- package/dist/modules/connectors/getByPath.js +21 -0
- package/dist/modules/connectors/index.d.ts +7 -0
- package/dist/modules/connectors/projection.d.ts +18 -0
- package/dist/modules/connectors/projection.js +108 -0
- package/dist/modules/connectors/resolver.d.ts +18 -0
- package/dist/modules/connectors/resolver.js +68 -0
- package/dist/modules/connectors/types.d.ts +19 -0
- package/dist/{src/modules → modules}/rsc/handler.d.ts +2 -2
- package/dist/modules/rsc/handler.js +54 -2
- package/dist/modules/rsc/resolveRscData.d.ts +35 -0
- package/dist/modules/rsc/resolveRscData.js +74 -0
- package/dist/{src/modules → modules}/ssr/Component.d.ts +4 -1
- package/dist/modules/ssr/Component.js +10 -3
- package/dist/modules/ssr/buildBody.d.ts +9 -0
- package/dist/modules/ssr/handler.d.ts +4 -0
- package/dist/modules/ssr/handler.js +18 -1
- package/dist/{src/modules → modules}/ssr/loadPluginComponents.d.ts +5 -2
- package/dist/modules/ssr/loadPluginComponents.js +20 -2
- package/dist/{src/modules → modules}/ssr/prepareRender.d.ts +2 -2
- package/dist/modules/ssr/prepareRender.js +24 -7
- package/dist/modules/ssr/preview.d.ts +10 -0
- package/dist/modules/ssr/preview.js +5 -78
- package/dist/modules/ssr/registerExternalPlugins.js +1 -1
- package/dist/modules/ssr/streamBody.d.ts +5 -0
- package/dist/modules/ssr/streamBody.js +1 -1
- package/dist/modules/ssr/template.d.ts +2 -0
- package/dist/modules/ssr/template.js +1 -1
- package/dist/plugins/compile.js +1 -1
- package/dist/plugins/manager.js +12 -8
- package/dist/ssr.d.ts +15 -0
- package/dist/ssr.js +4 -0
- package/package.json +29 -25
- package/dist/.gitkeep +0 -0
- package/dist/core/server/mcpServer.js +0 -29
- package/dist/core/services/mcp.js +0 -27
- package/dist/core/services/oauth.js +0 -116
- package/dist/core/services/preview.js +0 -37
- package/dist/core/services/proxy.js +0 -12
- package/dist/mcp.d.ts +0 -2
- package/dist/mcp.js +0 -7
- package/dist/modules/ai/AIEngine.js +0 -120
- package/dist/modules/ai/toolkit.js +0 -59
- package/dist/modules/mcp/apps/example/view/index.tsx +0 -70
- package/dist/modules/mcp/apps/index.js +0 -16
- package/dist/modules/mcp/apps/render/index.js +0 -17
- package/dist/modules/mcp/apps/render/styles.js +0 -54
- package/dist/modules/mcp/apps/render/view/heldBatch.ts +0 -107
- package/dist/modules/mcp/apps/render/view/index.tsx +0 -314
- package/dist/modules/mcp/apps/render/view/streamProgress.ts +0 -137
- package/dist/modules/mcp/apps/shared/assets.js +0 -10
- package/dist/modules/mcp/apps/shared/bundle.js +0 -23
- package/dist/modules/mcp/apps/shared/page.js +0 -34
- package/dist/modules/mcp/apps/shared/registerApp.js +0 -43
- package/dist/modules/mcp/apps/shared/resolve.js +0 -5
- package/dist/modules/mcp/apps/shared/shell.ejs +0 -59
- package/dist/modules/mcp/apps/shared/zodEnglishOnly.js +0 -23
- package/dist/modules/mcp/catalogs/builtinCallbacks.js +0 -204
- package/dist/modules/mcp/catalogs/builtinComponents.js +0 -170
- package/dist/modules/mcp/catalogs/builtinElementCallbacks.js +0 -50
- package/dist/modules/mcp/catalogs/builtinTransformers.js +0 -148
- package/dist/modules/mcp/catalogs/builtinUtilities.js +0 -90
- package/dist/modules/mcp/catalogs/cssCatalog/border.js +0 -30
- package/dist/modules/mcp/catalogs/cssCatalog/box.js +0 -31
- package/dist/modules/mcp/catalogs/cssCatalog/helpers.js +0 -185
- package/dist/modules/mcp/catalogs/cssCatalog/index.js +0 -131
- package/dist/modules/mcp/catalogs/cssCatalog/layout.js +0 -98
- package/dist/modules/mcp/catalogs/cssCatalog/visual.js +0 -144
- package/dist/modules/mcp/catalogs/observed.js +0 -90
- package/dist/modules/mcp/catalogs/paramSpec.js +0 -69
- package/dist/modules/mcp/catalogs/registry.js +0 -89
- package/dist/modules/mcp/handler.js +0 -83
- package/dist/modules/mcp/helpers/agentPrompt.js +0 -104
- package/dist/modules/mcp/helpers/computeVersion.js +0 -16
- package/dist/modules/mcp/helpers/guide.js +0 -467
- package/dist/modules/mcp/helpers/interactions.js +0 -123
- package/dist/modules/mcp/helpers/log.js +0 -64
- package/dist/modules/mcp/helpers/opResult.js +0 -18
- package/dist/modules/mcp/helpers/space.js +0 -300
- package/dist/modules/mcp/helpers/uris.js +0 -44
- package/dist/modules/mcp/previewClient.js +0 -31
- package/dist/modules/mcp/proxy/config.js +0 -63
- package/dist/modules/mcp/proxy/fetch.js +0 -91
- package/dist/modules/mcp/proxy/grant.js +0 -67
- package/dist/modules/mcp/proxy/guard.js +0 -38
- package/dist/modules/mcp/proxy/handler.js +0 -99
- package/dist/modules/mcp/proxy/payload.js +0 -29
- package/dist/modules/mcp/proxy/rewrite.js +0 -138
- package/dist/modules/mcp/proxy/sign.js +0 -15
- package/dist/modules/mcp/proxy/types.js +0 -9
- package/dist/modules/mcp/resources/canonical.js +0 -30
- package/dist/modules/mcp/resources/core.js +0 -18
- package/dist/modules/mcp/resources/envelope.js +0 -14
- package/dist/modules/mcp/resources/primer.js +0 -31
- package/dist/modules/mcp/resources/register.js +0 -190
- package/dist/modules/mcp/resources/renderGuide.js +0 -451
- package/dist/modules/mcp/resources/router.js +0 -37
- package/dist/modules/mcp/resources/schema.js +0 -43
- package/dist/modules/mcp/resources/style.js +0 -34
- package/dist/modules/mcp/screenshotClient.js +0 -47
- package/dist/modules/mcp/server.js +0 -113
- package/dist/modules/mcp/tools/apply/dispatch.js +0 -105
- package/dist/modules/mcp/tools/apply/index.js +0 -150
- package/dist/modules/mcp/tools/apply/writeResult.js +0 -37
- package/dist/modules/mcp/tools/index.js +0 -24
- package/dist/modules/mcp/tools/operations/index.js +0 -45
- package/dist/modules/mcp/tools/operations/schema/bindings/deleteBinding.js +0 -32
- package/dist/modules/mcp/tools/operations/schema/bindings/patchBinding.js +0 -36
- package/dist/modules/mcp/tools/operations/schema/bindings/upsertBinding.js +0 -47
- package/dist/modules/mcp/tools/operations/schema/elements/deleteElement.js +0 -29
- package/dist/modules/mcp/tools/operations/schema/elements/moveElement.js +0 -41
- package/dist/modules/mcp/tools/operations/schema/elements/patchElement.js +0 -58
- package/dist/modules/mcp/tools/operations/schema/elements/repeatElement.js +0 -148
- package/dist/modules/mcp/tools/operations/schema/elements/upsertElement.js +0 -65
- package/dist/modules/mcp/tools/operations/schema/folders/deleteFolder.js +0 -30
- package/dist/modules/mcp/tools/operations/schema/folders/upsertFolder.js +0 -49
- package/dist/modules/mcp/tools/operations/schema/interactions/deleteInteraction.js +0 -52
- package/dist/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.js +0 -47
- package/dist/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.js +0 -44
- package/dist/modules/mcp/tools/operations/schema/operations.js +0 -41
- package/dist/modules/mcp/tools/operations/schema/pages/deletePage.js +0 -25
- package/dist/modules/mcp/tools/operations/schema/pages/upsertPage.js +0 -75
- package/dist/modules/mcp/tools/operations/schema/settings/patchSettings.js +0 -45
- package/dist/modules/mcp/tools/operations/schema/shared.js +0 -122
- package/dist/modules/mcp/tools/operations/schema/translator.js +0 -215
- package/dist/modules/mcp/tools/operations/schema/variables/deleteVariable.js +0 -18
- package/dist/modules/mcp/tools/operations/schema/variables/upsertVariable.js +0 -42
- package/dist/modules/mcp/tools/operations/schema/write.js +0 -109
- package/dist/modules/mcp/tools/operations/schemaIds.js +0 -54
- package/dist/modules/mcp/tools/operations/style/definitions/deleteDefinition.js +0 -21
- package/dist/modules/mcp/tools/operations/style/definitions/patchDefinition.js +0 -28
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinition.js +0 -24
- package/dist/modules/mcp/tools/operations/style/definitions/upsertDefinitions.js +0 -40
- package/dist/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.js +0 -21
- package/dist/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.js +0 -28
- package/dist/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.js +0 -24
- package/dist/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.js +0 -21
- package/dist/modules/mcp/tools/operations/style/idStyles/patchIdStyle.js +0 -28
- package/dist/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.js +0 -24
- package/dist/modules/mcp/tools/operations/style/operations.js +0 -29
- package/dist/modules/mcp/tools/operations/style/shared.js +0 -59
- package/dist/modules/mcp/tools/operations/style/translator.js +0 -101
- package/dist/modules/mcp/tools/operations/style/variables/deleteStyleVariable.js +0 -21
- package/dist/modules/mcp/tools/operations/style/variables/upsertStyleVariable.js +0 -22
- package/dist/modules/mcp/tools/operations/style/write.js +0 -108
- package/dist/modules/mcp/tools/preview.js +0 -37
- package/dist/modules/mcp/tools/read.js +0 -51
- package/dist/modules/mcp/tools/render.js +0 -184
- package/dist/modules/mcp/tools/screenshot.js +0 -83
- package/dist/modules/mcp/tools/search.js +0 -115
- package/dist/modules/mcp/tools/shared/expandOperations.js +0 -44
- package/dist/modules/mcp/tools/shared/tool.js +0 -33
- package/dist/modules/mcp/tools/shared/validator/audit.js +0 -124
- package/dist/modules/mcp/tools/shared/validator/batch.js +0 -39
- package/dist/modules/mcp/tools/shared/validator/bindings.js +0 -70
- package/dist/modules/mcp/tools/shared/validator/context.js +0 -35
- package/dist/modules/mcp/tools/shared/validator/css.js +0 -39
- package/dist/modules/mcp/tools/shared/validator/elements.js +0 -68
- package/dist/modules/mcp/tools/shared/validator/index.js +0 -246
- package/dist/modules/mcp/tools/shared/validator/interactions.js +0 -103
- package/dist/modules/mcp/tools/shared/validator/refs.js +0 -28
- package/dist/modules/mcp/tools/validate.js +0 -47
- package/dist/modules/oauth/authorize.js +0 -177
- package/dist/modules/oauth/challenge.js +0 -33
- package/dist/modules/oauth/consentPage.js +0 -118
- package/dist/modules/oauth/metadata.js +0 -69
- package/dist/modules/oauth/params.js +0 -5
- package/dist/modules/oauth/pkce.js +0 -15
- package/dist/modules/oauth/records.js +0 -46
- package/dist/modules/oauth/register.js +0 -55
- package/dist/modules/oauth/respond.js +0 -44
- package/dist/modules/oauth/token.js +0 -100
- package/dist/public/.gitkeep +0 -0
- package/dist/src/adapters/jsonAdapters.d.ts +0 -7
- package/dist/src/core/createServer.d.ts +0 -14
- package/dist/src/core/http/stages/health.d.ts +0 -2
- package/dist/src/core/http/stages/middlewares.d.ts +0 -2
- package/dist/src/core/http/stages/static.d.ts +0 -5
- package/dist/src/core/http/types.d.ts +0 -22
- package/dist/src/core/server/mcpServer.d.ts +0 -2
- package/dist/src/core/server/pageServer.d.ts +0 -10
- package/dist/src/core/services/mcp.d.ts +0 -3
- package/dist/src/core/services/oauth.d.ts +0 -18
- package/dist/src/core/services/preview.d.ts +0 -2
- package/dist/src/core/services/proxy.d.ts +0 -2
- package/dist/src/core/services/registry.d.ts +0 -4
- package/dist/src/helpers/buildServerInfo.d.ts +0 -2
- package/dist/src/helpers/compress.d.ts +0 -3
- package/dist/src/index.d.ts +0 -15
- package/dist/src/mcp.d.ts +0 -14
- package/dist/src/middlewares/spaceDeployment.d.ts +0 -2
- package/dist/src/modules/ai/AIEngine.d.ts +0 -20
- package/dist/src/modules/ai/index.d.ts +0 -4
- package/dist/src/modules/ai/toolkit.d.ts +0 -17
- package/dist/src/modules/mcp/apps/example/index.d.ts +0 -8
- package/dist/src/modules/mcp/apps/index.d.ts +0 -11
- package/dist/src/modules/mcp/apps/render/index.d.ts +0 -4
- package/dist/src/modules/mcp/apps/render/styles.d.ts +0 -10
- package/dist/src/modules/mcp/apps/shared/assets.d.ts +0 -10
- package/dist/src/modules/mcp/apps/shared/bundle.d.ts +0 -4
- package/dist/src/modules/mcp/apps/shared/index.d.ts +0 -3
- package/dist/src/modules/mcp/apps/shared/page.d.ts +0 -2
- package/dist/src/modules/mcp/apps/shared/registerApp.d.ts +0 -5
- package/dist/src/modules/mcp/apps/shared/resolve.d.ts +0 -1
- package/dist/src/modules/mcp/apps/shared/zodEnglishOnly.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/builtinCallbacks.d.ts +0 -23
- package/dist/src/modules/mcp/catalogs/builtinComponents.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/builtinElementCallbacks.d.ts +0 -20
- package/dist/src/modules/mcp/catalogs/builtinTransformers.d.ts +0 -28
- package/dist/src/modules/mcp/catalogs/builtinUtilities.d.ts +0 -18
- package/dist/src/modules/mcp/catalogs/cssCatalog/border.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/cssCatalog/box.d.ts +0 -4
- package/dist/src/modules/mcp/catalogs/cssCatalog/helpers.d.ts +0 -34
- package/dist/src/modules/mcp/catalogs/cssCatalog/index.d.ts +0 -19
- package/dist/src/modules/mcp/catalogs/cssCatalog/layout.d.ts +0 -9
- package/dist/src/modules/mcp/catalogs/cssCatalog/visual.d.ts +0 -8
- package/dist/src/modules/mcp/catalogs/index.d.ts +0 -9
- package/dist/src/modules/mcp/catalogs/observed.d.ts +0 -48
- package/dist/src/modules/mcp/catalogs/paramSpec.d.ts +0 -42
- package/dist/src/modules/mcp/catalogs/registry.d.ts +0 -35
- package/dist/src/modules/mcp/e2e/index.d.ts +0 -6
- package/dist/src/modules/mcp/e2e/mcpEndpoint.d.ts +0 -27
- package/dist/src/modules/mcp/e2e/postMessageChannel.d.ts +0 -22
- package/dist/src/modules/mcp/e2e/renderingHost.d.ts +0 -34
- package/dist/src/modules/mcp/handler.d.ts +0 -22
- package/dist/src/modules/mcp/helpers/agentPrompt.d.ts +0 -4
- package/dist/src/modules/mcp/helpers/computeVersion.d.ts +0 -1
- package/dist/src/modules/mcp/helpers/guide.d.ts +0 -4
- package/dist/src/modules/mcp/helpers/index.d.ts +0 -8
- package/dist/src/modules/mcp/helpers/interactions.d.ts +0 -30
- package/dist/src/modules/mcp/helpers/log.d.ts +0 -8
- package/dist/src/modules/mcp/helpers/opResult.d.ts +0 -13
- package/dist/src/modules/mcp/helpers/space.d.ts +0 -115
- package/dist/src/modules/mcp/helpers/uris.d.ts +0 -28
- package/dist/src/modules/mcp/index.d.ts +0 -13
- package/dist/src/modules/mcp/previewClient.d.ts +0 -13
- package/dist/src/modules/mcp/proxy/config.d.ts +0 -19
- package/dist/src/modules/mcp/proxy/fetch.d.ts +0 -18
- package/dist/src/modules/mcp/proxy/grant.d.ts +0 -25
- package/dist/src/modules/mcp/proxy/guard.d.ts +0 -6
- package/dist/src/modules/mcp/proxy/handler.d.ts +0 -8
- package/dist/src/modules/mcp/proxy/index.d.ts +0 -8
- package/dist/src/modules/mcp/proxy/payload.d.ts +0 -8
- package/dist/src/modules/mcp/proxy/rewrite.d.ts +0 -18
- package/dist/src/modules/mcp/proxy/sign.d.ts +0 -6
- package/dist/src/modules/mcp/proxy/types.d.ts +0 -45
- package/dist/src/modules/mcp/resources/canonical.d.ts +0 -6
- package/dist/src/modules/mcp/resources/core.d.ts +0 -5
- package/dist/src/modules/mcp/resources/envelope.d.ts +0 -10
- package/dist/src/modules/mcp/resources/index.d.ts +0 -8
- package/dist/src/modules/mcp/resources/primer.d.ts +0 -7
- package/dist/src/modules/mcp/resources/register.d.ts +0 -10
- package/dist/src/modules/mcp/resources/renderGuide.d.ts +0 -10
- package/dist/src/modules/mcp/resources/router.d.ts +0 -10
- package/dist/src/modules/mcp/resources/schema.d.ts +0 -5
- package/dist/src/modules/mcp/resources/style.d.ts +0 -5
- package/dist/src/modules/mcp/screenshotClient.d.ts +0 -13
- package/dist/src/modules/mcp/server.d.ts +0 -31
- package/dist/src/modules/mcp/tests/helpers.d.ts +0 -13
- package/dist/src/modules/mcp/tools/apply/dispatch.d.ts +0 -6
- package/dist/src/modules/mcp/tools/apply/index.d.ts +0 -470
- package/dist/src/modules/mcp/tools/apply/writeResult.d.ts +0 -8
- package/dist/src/modules/mcp/tools/index.d.ts +0 -18
- package/dist/src/modules/mcp/tools/operations/index.d.ts +0 -928
- package/dist/src/modules/mcp/tools/operations/schema/bindings/deleteBinding.d.ts +0 -17
- package/dist/src/modules/mcp/tools/operations/schema/bindings/patchBinding.d.ts +0 -25
- package/dist/src/modules/mcp/tools/operations/schema/bindings/upsertBinding.d.ts +0 -27
- package/dist/src/modules/mcp/tools/operations/schema/elements/deleteElement.d.ts +0 -10
- package/dist/src/modules/mcp/tools/operations/schema/elements/moveElement.d.ts +0 -16
- package/dist/src/modules/mcp/tools/operations/schema/elements/patchElement.d.ts +0 -22
- package/dist/src/modules/mcp/tools/operations/schema/elements/repeatElement.d.ts +0 -55
- package/dist/src/modules/mcp/tools/operations/schema/elements/upsertElement.d.ts +0 -16
- package/dist/src/modules/mcp/tools/operations/schema/folders/deleteFolder.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/schema/folders/upsertFolder.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/schema/index.d.ts +0 -21
- package/dist/src/modules/mcp/tools/operations/schema/interactions/deleteInteraction.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/schema/interactions/patchInteractionNode.d.ts +0 -18
- package/dist/src/modules/mcp/tools/operations/schema/interactions/upsertInteractionFlow.d.ts +0 -27
- package/dist/src/modules/mcp/tools/operations/schema/operations.d.ts +0 -229
- package/dist/src/modules/mcp/tools/operations/schema/pages/deletePage.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/schema/pages/upsertPage.d.ts +0 -14
- package/dist/src/modules/mcp/tools/operations/schema/settings/patchSettings.d.ts +0 -34
- package/dist/src/modules/mcp/tools/operations/schema/shared.d.ts +0 -92
- package/dist/src/modules/mcp/tools/operations/schema/translator.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/schema/variables/deleteVariable.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/schema/variables/upsertVariable.d.ts +0 -16
- package/dist/src/modules/mcp/tools/operations/schema/write.d.ts +0 -42
- package/dist/src/modules/mcp/tools/operations/schemaIds.d.ts +0 -6
- package/dist/src/modules/mcp/tools/operations/style/definitions/deleteDefinition.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/style/definitions/patchDefinition.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinition.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/definitions/upsertDefinitions.d.ts +0 -41
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/deleteGlobalStyle.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/patchGlobalStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/globalStyles/upsertGlobalStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/idStyles/deleteIdStyle.d.ts +0 -9
- package/dist/src/modules/mcp/tools/operations/style/idStyles/patchIdStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/idStyles/upsertIdStyle.d.ts +0 -37
- package/dist/src/modules/mcp/tools/operations/style/index.d.ts +0 -15
- package/dist/src/modules/mcp/tools/operations/style/operations.d.ts +0 -264
- package/dist/src/modules/mcp/tools/operations/style/shared.d.ts +0 -116
- package/dist/src/modules/mcp/tools/operations/style/translator.d.ts +0 -12
- package/dist/src/modules/mcp/tools/operations/style/variables/deleteStyleVariable.d.ts +0 -15
- package/dist/src/modules/mcp/tools/operations/style/variables/upsertStyleVariable.d.ts +0 -20
- package/dist/src/modules/mcp/tools/operations/style/write.d.ts +0 -12
- package/dist/src/modules/mcp/tools/preview.d.ts +0 -465
- package/dist/src/modules/mcp/tools/read.d.ts +0 -9
- package/dist/src/modules/mcp/tools/render.d.ts +0 -499
- package/dist/src/modules/mcp/tools/render.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/screenshot.d.ts +0 -470
- package/dist/src/modules/mcp/tools/search.d.ts +0 -15
- package/dist/src/modules/mcp/tools/shared/expandOperations.d.ts +0 -13
- package/dist/src/modules/mcp/tools/shared/tool.d.ts +0 -72
- package/dist/src/modules/mcp/tools/shared/validator/audit.d.ts +0 -4
- package/dist/src/modules/mcp/tools/shared/validator/batch.d.ts +0 -5
- package/dist/src/modules/mcp/tools/shared/validator/bindings.d.ts +0 -6
- package/dist/src/modules/mcp/tools/shared/validator/context.d.ts +0 -38
- package/dist/src/modules/mcp/tools/shared/validator/css.d.ts +0 -4
- package/dist/src/modules/mcp/tools/shared/validator/elements.d.ts +0 -7
- package/dist/src/modules/mcp/tools/shared/validator/index.d.ts +0 -8
- package/dist/src/modules/mcp/tools/shared/validator/interactions.d.ts +0 -3
- package/dist/src/modules/mcp/tools/shared/validator/refs.d.ts +0 -4
- package/dist/src/modules/mcp/tools/validate.d.ts +0 -467
- package/dist/src/modules/mcp/types/aiSchema.d.ts +0 -218
- package/dist/src/modules/mcp/types/appTypes.d.ts +0 -26
- package/dist/src/modules/mcp/types/index.d.ts +0 -5
- package/dist/src/modules/mcp/types/previewTypes.d.ts +0 -25
- package/dist/src/modules/mcp/types/screenshotTypes.d.ts +0 -29
- package/dist/src/modules/mcp/types/toolTypes.d.ts +0 -138
- package/dist/src/modules/oauth/authorize.d.ts +0 -7
- package/dist/src/modules/oauth/challenge.d.ts +0 -11
- package/dist/src/modules/oauth/consentPage.d.ts +0 -7
- package/dist/src/modules/oauth/metadata.d.ts +0 -40
- package/dist/src/modules/oauth/params.d.ts +0 -5
- package/dist/src/modules/oauth/pkce.d.ts +0 -6
- package/dist/src/modules/oauth/records.d.ts +0 -71
- package/dist/src/modules/oauth/register.d.ts +0 -5
- package/dist/src/modules/oauth/respond.d.ts +0 -13
- package/dist/src/modules/oauth/token.d.ts +0 -5
- package/dist/src/modules/ssr/buildBody.d.ts +0 -9
- package/dist/src/modules/ssr/handler.d.ts +0 -4
- package/dist/src/modules/ssr/preview.d.ts +0 -16
- package/dist/src/modules/ssr/streamBody.d.ts +0 -5
- package/dist/src/modules/ssr/template.d.ts +0 -6
- package/dist/src/standalone/alias-loader.d.mts +0 -2
- package/dist/src/standalone/plugins/ClientInfo.d.ts +0 -2
- package/dist/src/standalone/plugins/ServerInfo.d.ts +0 -2
- package/dist/src/standalone/plugins/SharedInfo.d.ts +0 -2
- package/dist/src/standalone/plugins/styles.d.ts +0 -5
- package/dist/src/standalone/register-alias.d.mts +0 -1
- package/dist/src/standalone/server.d.ts +0 -1
- package/dist/src/standalone/stubs/react-syntax-highlighter.d.mts +0 -31
- package/skills/plitzi-render/SKILL.md +0 -174
- /package/dist/{src/core/http/dispatcher.test.d.ts → core/auth/api.test.d.ts} +0 -0
- /package/dist/{src/core/server/mcpServer.test.d.ts → core/auth/authorize.test.d.ts} +0 -0
- /package/dist/{src/modules/ai/toolkit.test.d.ts → core/auth/createAuth.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/apps/apps.test.d.ts → core/auth/domains.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/apps/render/styles.test.d.ts → core/auth/identity.test.d.ts} +0 -0
- /package/dist/{src/modules → core/auth}/oauth/oauth.test.d.ts +0 -0
- /package/dist/{src/modules/mcp/catalogs/builtinTransformers.test.d.ts → core/auth/routes.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/catalogs/cssCatalog/cssCatalog.test.d.ts → core/auth/session.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/e2e/connector.test.d.ts → core/auth/spaceTokens.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/e2e/host.test.d.ts → core/auth/tokens.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/e2e/oauthConnector.test.d.ts → core/createServer.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/helpers/log.test.d.ts → core/handlers/handlers.test.d.ts} +0 -0
- /package/dist/{src/core → core}/health.d.ts +0 -0
- /package/dist/{src/modules/mcp/mcp.bench.d.ts → core/http/dispatcher.test.d.ts} +0 -0
- /package/dist/{src/core → core}/http/securityHeaders.d.ts +0 -0
- /package/dist/{src/core → core}/http/stages/authRoutes.d.ts +0 -0
- /package/dist/{src/core → core}/http/stages/pluginAssets.d.ts +0 -0
- /package/dist/{src/core → core}/mimeTypes.d.ts +0 -0
- /package/dist/{src/modules/mcp/constants.d.ts → core/previewToken.d.ts} +0 -0
- /package/dist/{src/core → core}/requestParser.d.ts +0 -0
- /package/dist/{src/core → core}/server/baseServer.d.ts +0 -0
- /package/dist/{src/modules/mcp/proxy/endpoint.test.d.ts → core/server/baseServer.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/proxy/proxy.test.d.ts → core/services/resolve.test.d.ts} +0 -0
- /package/dist/{src/core → core}/services/rsc.d.ts +0 -0
- /package/dist/{src/core → core}/services/ssr.d.ts +0 -0
- /package/dist/{src/core → core}/staticFiles.d.ts +0 -0
- /package/dist/{src/modules/mcp/proxy/wiring.test.d.ts → helpers/buildResponseHelpers.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/cache/TtlCache.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/cache/cacheManager.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/cache/defaults.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/cache/index.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/apply.test.d.ts → helpers/cache/keys.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/cache/serverCaches.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/bindings.test.d.ts → helpers/compress.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/escapeJson.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/metrics.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/normalizePlugins.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/css.test.d.ts → helpers/offlineDataLoader.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/readCookie.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/interactions.test.d.ts → helpers/resolveDebugMode.test.d.ts} +0 -0
- /package/dist/{src/helpers → helpers}/runMiddlewares.d.ts +0 -0
- /package/dist/{src/helpers → helpers}/serverLog.d.ts +0 -0
- /package/dist/{src/middlewares → middlewares}/auth.d.ts +0 -0
- /package/dist/{src/middlewares → middlewares}/basicAuth.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/pages.test.d.ts → middlewares/spaceDeployment.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/reads.test.d.ts → modules/actions/handler.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/schemaIds.test.d.ts → modules/connectors/engine.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/search.test.d.ts → modules/connectors/projection.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/skill.test.d.ts → modules/connectors/resolver.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/styles.test.d.ts → modules/rsc/resolveRscData.test.d.ts} +0 -0
- /package/dist/{src/modules → modules}/ssr/applySSRResult.d.ts +0 -0
- /package/dist/{src/modules/mcp/tests/tools.test.d.ts → modules/ssr/loadPluginComponents.test.d.ts} +0 -0
- /package/dist/{src/modules/mcp/tests/validation.test.d.ts → modules/ssr/metering.test.d.ts} +0 -0
- /package/dist/{src/modules → modules}/ssr/registerExternalPlugins.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/compile.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/copy.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/detect.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/manager.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/validate.d.ts +0 -0
- /package/dist/{src/plugins → plugins}/validate.test.d.ts +0 -0
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { cssProperties, cssShorthands } from "../catalogs/cssCatalog/index.js";
|
|
2
|
-
import { guideText } from "../helpers/guide.js";
|
|
3
|
-
import { resourceErrorMessage } from "./canonical.js";
|
|
4
|
-
import { envelope, jsonContents } from "./envelope.js";
|
|
5
|
-
import { registerRenderResources } from "./renderGuide.js";
|
|
6
|
-
import { readResource } from "./router.js";
|
|
7
|
-
import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
-
//#region src/modules/mcp/resources/register.ts
|
|
9
|
-
/** Register every resource on the MCP server: fixed listings plus templated per-item reads. The space is
|
|
10
|
-
* loaded lazily via getSpace, so listing resources never touches the store — only reading one does.
|
|
11
|
-
*
|
|
12
|
-
* `hasSpace` is false when the connection reaches no space (a guest / widgets-only grant): the space-dependent
|
|
13
|
-
* families are then not registered at all, so the catalog the agent browses holds only what it can actually
|
|
14
|
-
* open — no listing that answers every read with the same refusal. */
|
|
15
|
-
var registerResources = (server, getSpace, env, log, hasSpace) => {
|
|
16
|
-
const emit = async (uri) => {
|
|
17
|
-
const start = performance.now();
|
|
18
|
-
try {
|
|
19
|
-
const result = readResource(await getSpace(), env, uri);
|
|
20
|
-
if (!result) throw new Error(resourceErrorMessage(env, uri));
|
|
21
|
-
log.resourceRead(uri, performance.now() - start);
|
|
22
|
-
return jsonContents(uri, result);
|
|
23
|
-
} catch (error) {
|
|
24
|
-
log.resourceRead(uri, performance.now() - start, error);
|
|
25
|
-
throw error;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
const emitStatic = (uri, read) => {
|
|
29
|
-
const start = performance.now();
|
|
30
|
-
const result = read();
|
|
31
|
-
log.resourceRead(uri, performance.now() - start);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
server.registerResource("Guide", "plitzi://guide", {
|
|
35
|
-
description: "How to read and write this space with mcp-ai",
|
|
36
|
-
mimeType: "text/markdown"
|
|
37
|
-
}, () => emitStatic("plitzi://guide", () => ({ contents: [{
|
|
38
|
-
uri: "plitzi://guide",
|
|
39
|
-
mimeType: "text/markdown",
|
|
40
|
-
text: guideText
|
|
41
|
-
}] })));
|
|
42
|
-
server.registerResource("CSS properties", "plitzi://css-properties", {
|
|
43
|
-
description: "Valid kebab-case CSS property keys, plus the shorthands that are accepted and auto-expanded",
|
|
44
|
-
mimeType: "application/json"
|
|
45
|
-
}, () => emitStatic("plitzi://css-properties", () => jsonContents("plitzi://css-properties", envelope({
|
|
46
|
-
properties: cssProperties,
|
|
47
|
-
shorthands: cssShorthands
|
|
48
|
-
}))));
|
|
49
|
-
registerRenderResources(server, log);
|
|
50
|
-
if (!hasSpace) return;
|
|
51
|
-
const fixed = [
|
|
52
|
-
[
|
|
53
|
-
"Primer",
|
|
54
|
-
`plitzi://primer/${env}`,
|
|
55
|
-
"Read this FIRST. Cold-start bundle in one call: guide, types, css-properties and SUMMARIES of pages, definitions and variables — summaries only, never full page/element trees, so it stays small even on a large space. Open a page or element on demand afterwards."
|
|
56
|
-
],
|
|
57
|
-
[
|
|
58
|
-
"Element types",
|
|
59
|
-
"plitzi://types",
|
|
60
|
-
"Observed element types with props, slots and subTypes"
|
|
61
|
-
],
|
|
62
|
-
[
|
|
63
|
-
"Pages",
|
|
64
|
-
`plitzi://schema/${env}/pages`,
|
|
65
|
-
"Page summaries (ref, label, elementCount) — no element trees"
|
|
66
|
-
],
|
|
67
|
-
[
|
|
68
|
-
"Folders",
|
|
69
|
-
`plitzi://folders/${env}`,
|
|
70
|
-
"Page folders (the sidebar tree): ref, name, slug, parentId"
|
|
71
|
-
],
|
|
72
|
-
[
|
|
73
|
-
"Style definitions",
|
|
74
|
-
`plitzi://definitions/${env}`,
|
|
75
|
-
"Style definition refs (names)"
|
|
76
|
-
],
|
|
77
|
-
[
|
|
78
|
-
"Global styles",
|
|
79
|
-
`plitzi://global-styles/${env}`,
|
|
80
|
-
"Element types that have a site-wide global style"
|
|
81
|
-
],
|
|
82
|
-
[
|
|
83
|
-
"Id styles",
|
|
84
|
-
`plitzi://id-styles/${env}`,
|
|
85
|
-
"DOM ids that have an id rule (#id) targeting a single element"
|
|
86
|
-
],
|
|
87
|
-
[
|
|
88
|
-
"Style variables",
|
|
89
|
-
`plitzi://style-variables/${env}`,
|
|
90
|
-
"Design tokens by category"
|
|
91
|
-
],
|
|
92
|
-
[
|
|
93
|
-
"Schema variables",
|
|
94
|
-
`plitzi://schema-variables/${env}`,
|
|
95
|
-
"Space-level values referenced via {{name}}"
|
|
96
|
-
],
|
|
97
|
-
[
|
|
98
|
-
"Settings",
|
|
99
|
-
`plitzi://settings/${env}`,
|
|
100
|
-
"Space-level settings: global customCss and state/auth configuration"
|
|
101
|
-
],
|
|
102
|
-
[
|
|
103
|
-
"Interactions catalog",
|
|
104
|
-
`plitzi://interactions/${env}`,
|
|
105
|
-
"Interaction actions (observed, grouped by node type) plus the built-in vocabularies — globalCallbacks (with their source module), element callbacks and utilities — each with its full param schema, the vocabulary for upsertInteractionFlow"
|
|
106
|
-
],
|
|
107
|
-
[
|
|
108
|
-
"Data sources catalog",
|
|
109
|
-
`plitzi://data-sources/${env}`,
|
|
110
|
-
"Data-source paths and binding targets observed in this space — the vocabulary for upsertBinding"
|
|
111
|
-
],
|
|
112
|
-
[
|
|
113
|
-
"Style definitions (schema alias)",
|
|
114
|
-
`plitzi://schema/${env}/definitions`,
|
|
115
|
-
"Alias of plitzi://definitions/{env}"
|
|
116
|
-
],
|
|
117
|
-
[
|
|
118
|
-
"Style variables (schema alias)",
|
|
119
|
-
`plitzi://schema/${env}/style-variables`,
|
|
120
|
-
"Alias of plitzi://style-variables/{env}"
|
|
121
|
-
],
|
|
122
|
-
[
|
|
123
|
-
"Schema variables (schema alias)",
|
|
124
|
-
`plitzi://schema/${env}/schema-variables`,
|
|
125
|
-
"Alias of plitzi://schema-variables/{env}"
|
|
126
|
-
]
|
|
127
|
-
];
|
|
128
|
-
for (const [name, uri, description] of fixed) server.registerResource(name, uri, {
|
|
129
|
-
description,
|
|
130
|
-
mimeType: "application/json"
|
|
131
|
-
}, () => emit(uri));
|
|
132
|
-
const templates = [
|
|
133
|
-
[
|
|
134
|
-
"Page",
|
|
135
|
-
`plitzi://schema/${env}/pages/{ref}`,
|
|
136
|
-
"One page as a skeleton tree (ref/type/label/children), no props"
|
|
137
|
-
],
|
|
138
|
-
[
|
|
139
|
-
"Page styles",
|
|
140
|
-
`plitzi://schema/${env}/pages/{ref}/styles`,
|
|
141
|
-
"Every style a page uses in one read: class definitions its elements attach (with CSS) + global styles"
|
|
142
|
-
],
|
|
143
|
-
[
|
|
144
|
-
"Element",
|
|
145
|
-
`plitzi://schema/${env}/elements/{ref}`,
|
|
146
|
-
"One element in full detail (props, style) by ref or id"
|
|
147
|
-
],
|
|
148
|
-
[
|
|
149
|
-
"Folder",
|
|
150
|
-
`plitzi://folders/${env}/{ref}`,
|
|
151
|
-
"One page folder (name, slug, parentId) by folder id"
|
|
152
|
-
],
|
|
153
|
-
[
|
|
154
|
-
"Style definition",
|
|
155
|
-
`plitzi://definitions/${env}/{ref}`,
|
|
156
|
-
"One style definition (CSS) by class ref"
|
|
157
|
-
],
|
|
158
|
-
[
|
|
159
|
-
"Global style",
|
|
160
|
-
`plitzi://global-styles/${env}/{componentType}`,
|
|
161
|
-
"The site-wide CSS applied to every element of one type"
|
|
162
|
-
],
|
|
163
|
-
[
|
|
164
|
-
"Id style",
|
|
165
|
-
`plitzi://id-styles/${env}/{targetId}`,
|
|
166
|
-
"The CSS of an id rule (#id) targeting a single element"
|
|
167
|
-
],
|
|
168
|
-
[
|
|
169
|
-
"Style variables by category",
|
|
170
|
-
`plitzi://style-variables/${env}/{category}`,
|
|
171
|
-
"Design tokens for one category"
|
|
172
|
-
],
|
|
173
|
-
[
|
|
174
|
-
"Style definition (schema alias)",
|
|
175
|
-
`plitzi://schema/${env}/definitions/{ref}`,
|
|
176
|
-
"Alias of plitzi://definitions/{env}/{ref}"
|
|
177
|
-
],
|
|
178
|
-
[
|
|
179
|
-
"Style variables by category (schema alias)",
|
|
180
|
-
`plitzi://schema/${env}/style-variables/{category}`,
|
|
181
|
-
"Alias of plitzi://style-variables/{env}/{category}"
|
|
182
|
-
]
|
|
183
|
-
];
|
|
184
|
-
for (const [name, tpl, description] of templates) server.registerResource(name, new ResourceTemplate(tpl, { list: void 0 }), {
|
|
185
|
-
description,
|
|
186
|
-
mimeType: "application/json"
|
|
187
|
-
}, (uri) => emit(uri.href));
|
|
188
|
-
};
|
|
189
|
-
//#endregion
|
|
190
|
-
export { registerResources };
|
|
@@ -1,451 +0,0 @@
|
|
|
1
|
-
import { BUILTIN_COMPONENTS } from "../catalogs/builtinComponents.js";
|
|
2
|
-
import { envelope, jsonContents } from "./envelope.js";
|
|
3
|
-
//#region src/modules/mcp/resources/renderGuide.ts
|
|
4
|
-
var RENDER_GUIDE_URI = "plitzi://render/guide";
|
|
5
|
-
var RENDER_TYPES_URI = "plitzi://render/types";
|
|
6
|
-
var RENDER_TYPE_CATEGORIES = /* @__PURE__ */ new Set([
|
|
7
|
-
"structure",
|
|
8
|
-
"basic",
|
|
9
|
-
"media",
|
|
10
|
-
"form",
|
|
11
|
-
"provider"
|
|
12
|
-
]);
|
|
13
|
-
var RENDER_RAW_HTML_TYPE = "blockHtml";
|
|
14
|
-
var rawHtmlDescription = "Renders a raw HTML string (props.content) — in a widget, the way to draw an inline <svg>: a logo, an icon, a sparkline, a decorative shape. Use fill/stroke \"currentColor\" so it takes the host theme. Markup only: <script>, javascript: URLs and inline on* handlers are rejected.";
|
|
15
|
-
var renderTypesNote = "The built-in element types you can put in a plitzi_render widget, grouped by category. Pick by `description`. For the props of each type and the full authoring model, read plitzi://render/guide. Types that need a backend (providers) or a plugin are omitted because the widget renders offline.";
|
|
16
|
-
var renderTypes = () => {
|
|
17
|
-
const types = {};
|
|
18
|
-
for (const [name, info] of Object.entries(BUILTIN_COMPONENTS)) if (info && info.category && RENDER_TYPE_CATEGORIES.has(info.category)) types[name] = {
|
|
19
|
-
label: info.label,
|
|
20
|
-
category: info.category,
|
|
21
|
-
description: info.description
|
|
22
|
-
};
|
|
23
|
-
const rawHtml = BUILTIN_COMPONENTS[RENDER_RAW_HTML_TYPE];
|
|
24
|
-
if (rawHtml) types[RENDER_RAW_HTML_TYPE] = {
|
|
25
|
-
label: rawHtml.label,
|
|
26
|
-
category: rawHtml.category,
|
|
27
|
-
description: rawHtmlDescription
|
|
28
|
-
};
|
|
29
|
-
return {
|
|
30
|
-
note: renderTypesNote,
|
|
31
|
-
types
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
var renderGuideText = `# plitzi_render — authoring guide
|
|
35
|
-
|
|
36
|
-
\`plitzi_render\` shows the user a live UI widget. You build it as a list of \`operations\` (applied IN ORDER) that
|
|
37
|
-
assemble an element tree under one pre-seeded root page whose ref is **"render"**. It renders fully offline — no
|
|
38
|
-
space, no backend, no account. Same operation vocabulary as the editing tool plitzi_apply, aimed at one page.
|
|
39
|
-
|
|
40
|
-
Most widgets are **presentation only** — the structure + styling below is all you need, so start there. The widget
|
|
41
|
-
runs the live Plitzi SDK though, so it can also **fetch data** (an \`apiContainer\`) and **react to events**
|
|
42
|
-
(interaction flows); see "Data & interactivity" at the end when a widget needs them.
|
|
43
|
-
|
|
44
|
-
Each call renders a **fresh** widget: send **every** operation it needs in the one call.
|
|
45
|
-
|
|
46
|
-
**To CHANGE a widget you already rendered, do not rebuild it** — every render answers with a \`renderId\`; call
|
|
47
|
-
again with that id, \`patch: true\` and only the operations that differ:
|
|
48
|
-
|
|
49
|
-
\`\`\`json
|
|
50
|
-
{ "patch": true, "renderId": "r7f3a2c", "operations": [
|
|
51
|
-
{ "type": "patchDefinition", "ref": "tl-card", "desktop": { "border-radius": "20px" } },
|
|
52
|
-
{ "type": "patchElement", "pageRef": "render", "ref": "title-2", "props": { "content": "EPCOT (día largo)" } }
|
|
53
|
-
] }
|
|
54
|
-
\`\`\`
|
|
55
|
-
The widget merges the delta into the batch it was built from and reports back what it applied — including the
|
|
56
|
-
errors, if a ref does not exist. Address rows by the refs you already know (\`card-1\`, \`blk-2-3\`). If it reports
|
|
57
|
-
that the widget could not be recovered (a surface that renders none, a host that keeps no storage, a conversation
|
|
58
|
-
resumed elsewhere), send the whole batch again without \`patch\`.
|
|
59
|
-
|
|
60
|
-
**Patch only to modify what is on screen.** A different subject, or a different kind of widget, is a FRESH render
|
|
61
|
-
with no \`patch\` — the delta is merged into the previous widget, so patching a new idea leaves the user looking at
|
|
62
|
-
both at once. Rebuilding when you could have patched only costs tokens; patching when you should have rebuilt costs
|
|
63
|
-
the user a wrong widget.
|
|
64
|
-
|
|
65
|
-
## Build the whole widget in ONE upsertElement (nest with \`children\`)
|
|
66
|
-
|
|
67
|
-
The simplest, least error-prone path: a single \`upsertElement\` whose \`element\` carries a nested \`children\` tree —
|
|
68
|
-
so you describe the layout the way it renders, no ref-juggling. \`pageRef: "render"\` is required; each element in the
|
|
69
|
-
tree needs a unique \`ref\` — a name you choose from letters, digits, \`-\` and \`_\`, **starting with a letter and with
|
|
70
|
-
no dots** (e.g. \`price-row\`, \`cta_button\`).
|
|
71
|
-
|
|
72
|
-
\`\`\`json
|
|
73
|
-
{ "type": "upsertElement", "pageRef": "render", "element": {
|
|
74
|
-
"ref": "card", "type": "container", "style": { "base": ["card"] },
|
|
75
|
-
"children": [
|
|
76
|
-
{ "ref": "plan", "type": "heading", "subType": "h3", "props": { "content": "Pro" } },
|
|
77
|
-
{ "ref": "amount", "type": "text", "props": { "content": "$29/mo" }, "style": { "base": ["price"] } },
|
|
78
|
-
{ "ref": "buy", "type": "button", "props": { "content": "Start free trial" }, "style": { "base": ["cta"] } }
|
|
79
|
-
]
|
|
80
|
-
} }
|
|
81
|
-
\`\`\`
|
|
82
|
-
|
|
83
|
-
An element is \`{ ref, type, subType?, props?, style?, children? }\`. Children render in array order. (You *can* also
|
|
84
|
-
add elements one-by-one with a top-level \`parentRef: "<existing ref>"\` and optional \`position\` — useful to append to
|
|
85
|
-
or restructure something you already created — but for a fresh widget the inline \`children\` tree is easier.)
|
|
86
|
-
|
|
87
|
-
## Repeating rows — repeatElement, never copy-paste
|
|
88
|
-
|
|
89
|
-
The moment two siblings have the same shape and different data — a list, steps, cards, a table, a timeline —
|
|
90
|
-
**write the shape once** and hand over the rows. \`repeatElement\` creates the wrapper (style it with the row/grid
|
|
91
|
-
class) and renders the template once per entry of \`items\`:
|
|
92
|
-
|
|
93
|
-
\`\`\`json
|
|
94
|
-
{ "type": "repeatElement", "pageRef": "render", "ref": "steps", "style": { "base": ["list"] },
|
|
95
|
-
"template": {
|
|
96
|
-
"ref": "step", "type": "container", "style": { "base": ["row"] },
|
|
97
|
-
"children": [
|
|
98
|
-
{ "ref": "at", "type": "paragraph", "style": { "base": ["time"] }, "props": { "content": "{{item.time}}" } },
|
|
99
|
-
{ "ref": "what", "type": "paragraph", "style": { "base": ["txt"] }, "props": { "content": "{{item.text}}" } }
|
|
100
|
-
]
|
|
101
|
-
},
|
|
102
|
-
"items": [
|
|
103
|
-
{ "time": "08:00", "text": "Doors open, head straight to the main hall." },
|
|
104
|
-
{ "time": "10:30", "text": "Workshops in the east wing." },
|
|
105
|
-
{ "time": "13:00", "text": "Lunch, then the keynote." }
|
|
106
|
-
]
|
|
107
|
-
}
|
|
108
|
-
\`\`\`
|
|
109
|
-
- \`{{item.<field>}}\` is replaced by that row's field, anywhere in the template (props, a style ref, a param).
|
|
110
|
-
A placeholder that is the WHOLE value keeps the field's type (\`"{{item.count}}"\` with \`count: 3\` stays the
|
|
111
|
-
number 3); mixed with text it interpolates. Dotted paths work: \`{{item.author.name}}\`.
|
|
112
|
-
- Every ref in the template gets the row number appended — \`step\` becomes \`step-1\`, \`step-2\`… — so rows never
|
|
113
|
-
collide and you can address one later without reading anything back.
|
|
114
|
-
- Other \`{{…}}\` names are left untouched, so schema variables keep working inside a template.
|
|
115
|
-
- A row missing a field the template reads fails the batch and names the row and the fields it does carry.
|
|
116
|
-
- Up to 100 rows per op. Rows that differ in SHAPE (not just data) are not rows — write those as plain elements.
|
|
117
|
-
|
|
118
|
-
**A list inside each row** — a timeline of days each with its own steps, a menu of sections each with its dishes —
|
|
119
|
-
is one op too: give the node that should wrap the sub-list a \`repeat\`, and put the sub-rows in the row's data.
|
|
120
|
-
|
|
121
|
-
\`\`\`json
|
|
122
|
-
{ "type": "repeatElement", "pageRef": "render", "ref": "timeline", "style": { "base": ["tl"] },
|
|
123
|
-
"template": {
|
|
124
|
-
"ref": "day", "type": "container", "style": { "base": ["day"] },
|
|
125
|
-
"children": [
|
|
126
|
-
{ "ref": "title", "type": "heading", "subType": "h3", "props": { "content": "{{item.park}}" } },
|
|
127
|
-
{ "ref": "body", "type": "container", "style": { "base": ["body"] },
|
|
128
|
-
"repeat": { "items": "{{item.blocks}}", "template": {
|
|
129
|
-
"ref": "blk", "type": "container", "style": { "base": ["blk"] },
|
|
130
|
-
"children": [
|
|
131
|
-
{ "ref": "at", "type": "paragraph", "props": { "content": "{{item.time}}" } },
|
|
132
|
-
{ "ref": "what", "type": "paragraph", "props": { "content": "{{item.text}}" } }
|
|
133
|
-
]
|
|
134
|
-
} } }
|
|
135
|
-
]
|
|
136
|
-
},
|
|
137
|
-
"items": [
|
|
138
|
-
{ "park": "Magic Kingdom", "blocks": [ { "time": "08:00", "text": "Rope drop." }, { "time": "10:30", "text": "Space Mountain." } ] },
|
|
139
|
-
{ "park": "EPCOT", "blocks": [ { "time": "08:30", "text": "Cosmic Rewind." } ] }
|
|
140
|
-
]
|
|
141
|
-
}
|
|
142
|
-
\`\`\`
|
|
143
|
-
- The node carrying \`repeat\` becomes the WRAPPER of its sub-list (its own \`children\` are ignored), so put the
|
|
144
|
-
sub-list's layout class on it.
|
|
145
|
-
- Inside the sub-template \`{{item.…}}\` reads the SUB-row; a field of the outer row is not reachable from there,
|
|
146
|
-
so repeat it in each sub-row if you need it.
|
|
147
|
-
- Refs number both levels, outer first: \`blk-2-3\` is the third block of the second day.
|
|
148
|
-
- **One level of nesting**: the sub-template is a plain element tree, so it cannot carry another \`repeat\`.
|
|
149
|
-
- The whole op is capped at 500 rows across both levels.
|
|
150
|
-
|
|
151
|
-
## Style with reusable classes — upsertDefinitions
|
|
152
|
-
|
|
153
|
-
Styling is separate from structure: declare the classes, then attach them by ref. **Declare them all in ONE
|
|
154
|
-
\`upsertDefinitions\`**, keyed by class name — a widget usually needs a dozen classes, and one op per class spends a
|
|
155
|
-
noticeable slice of the call on repeated \`{"type":"upsertDefinition","ref":…}\` envelopes.
|
|
156
|
-
|
|
157
|
-
\`\`\`json
|
|
158
|
-
{ "type": "upsertDefinitions", "definitions": {
|
|
159
|
-
"card": { "desktop": { "display": "flex", "flex-direction": "column", "gap": "8px", "padding": "16px", "border-radius": "12px" } },
|
|
160
|
-
"title": { "desktop": { "font-size": "16px", "font-weight": "600", "margin-top": "0", "margin-bottom": "0" } }
|
|
161
|
-
} }
|
|
162
|
-
\`\`\`
|
|
163
|
-
Each value is exactly what \`upsertDefinition\` takes minus \`type\`/\`ref\` (\`desktop\`/\`tablet\`/\`mobile\`, \`states\`,
|
|
164
|
-
\`variants\`, \`slots\`), and the result is identical. The single \`upsertDefinition\` still exists for a one-off class,
|
|
165
|
-
and \`patchDefinition\` still changes only some CSS of one class.
|
|
166
|
-
- CSS properties in **kebab-case** (\`background-color\`, \`font-size\`, \`border-radius\`), values as plain strings.
|
|
167
|
-
- Attach to an element via \`style: { "base": ["card"] }\`. Stack classes: \`"base": ["card", "shadow"]\`.
|
|
168
|
-
- One \`ref\` can name both an element and its class (as above) — they live in different namespaces.
|
|
169
|
-
- Lay containers out with flexbox or grid — pick the direction on purpose, see **Fit the panel** below.
|
|
170
|
-
- **You are not styling from zero.** Each type lands on the page with CSS you did not write, and it is the usual
|
|
171
|
-
reason a widget does not look like the definitions say:
|
|
172
|
-
- The per-type CSS the SDK ships imposes **no minimum size**: a rail, a divider, a dot or a narrow cell is
|
|
173
|
-
exactly as small as you make it, and no \`"min-width": "0"\` escape hatch is needed. The flip side is that an
|
|
174
|
-
element with no content and no size takes no space at all — give a spacer its own \`height\`. (The 50px box
|
|
175
|
-
empty containers show on the builder canvas is a drop target, scoped to it; it never reaches a widget.)
|
|
176
|
-
- The BROWSER's own defaults for the rest: \`heading\` keeps its UA font-size and ~0.67em top/bottom margins,
|
|
177
|
-
\`paragraph\` ~1em margins, \`list\` a 40px \`padding-left\`, \`button\` its native chrome, \`image\` its intrinsic
|
|
178
|
-
size, \`link\` its own colour and underline. In a compact widget set these explicitly — usually
|
|
179
|
-
\`"margin-top": "0"\`, \`"margin-bottom": "0"\` — and space things with the parent's \`gap\` instead.
|
|
180
|
-
- Borders start at \`0 solid\`, so \`border-color\` alone paints nothing: give \`border-width\` (and the colour).
|
|
181
|
-
- The \`defaultStyle\` a type reports in the EDITING catalog (\`plitzi://types\`) is authoring metadata for the
|
|
182
|
-
builder — it does not paint here, so do not count on it in a widget.
|
|
183
|
-
- **Mind the intrinsic display.** Some types start non-block: \`text\` is \`display: inline\`, so to stack or size it,
|
|
184
|
-
wrap it in a \`container\` (or set \`display: block\`). \`heading\` and \`paragraph\` are already block.
|
|
185
|
-
- **Shorthands are welcome** and cheaper to write: \`padding: 8px 16px\`, \`border: 1px solid #ddd\`,
|
|
186
|
-
\`font: bold 16px/1.5 Arial\`, \`flex: 1 1 auto\`, \`transition: opacity 200ms ease\`. They are stored expanded to
|
|
187
|
-
their longhands, so a breakpoint, state or variant can override each property on its own — and a read-back shows
|
|
188
|
-
the longhands, not what you wrote. An unknown property errors with the correct kebab-case key suggested.
|
|
189
|
-
- **Responsive:** add \`tablet\` and/or \`mobile\` blocks next to \`desktop\` (same shape); they override desktop on
|
|
190
|
-
smaller screens — \`{ "desktop": { "font-size": "36px" }, "mobile": { "font-size": "24px" } }\`.
|
|
191
|
-
- **Interactive states:** nest under \`states\` keyed by pseudo-class, each with its own breakpoint block —
|
|
192
|
-
\`{ "desktop": { "background-color": "#3b82f6" }, "states": { "hover": { "desktop": { "background-color": "#2563eb" } } } }\`
|
|
193
|
-
(\`hover\`, \`active\`, \`focus\`).
|
|
194
|
-
|
|
195
|
-
## Fit the panel — go wide, stay short
|
|
196
|
-
|
|
197
|
-
The widget renders in a **side panel** (Claude Desktop, ChatGPT, the Plitzi builder), so it gets a usable width but
|
|
198
|
-
very little height: everything past the first screenful costs the user a scroll. Height is the scarce resource —
|
|
199
|
-
spend width instead.
|
|
200
|
-
|
|
201
|
-
Plain containers are blocks, so doing nothing stacks children **vertically** and produces exactly the tall,
|
|
202
|
-
half-empty widget to avoid. Choose the axis every time:
|
|
203
|
-
|
|
204
|
-
- **Peers side by side** — metrics, plans, options, a comparison, an image next to its text: a row, wrapping when
|
|
205
|
-
it runs out of width, children sharing it (no fixed widths).
|
|
206
|
-
\`\`\`json
|
|
207
|
-
{ "type": "upsertDefinitions", "definitions": {
|
|
208
|
-
"row": { "desktop": { "display": "flex", "flex-direction": "row", "flex-wrap": "wrap", "gap": "12px", "align-items": "stretch" } },
|
|
209
|
-
"col": { "desktop": { "flex-grow": "1", "flex-basis": "0%", "min-width": "150px" } }
|
|
210
|
-
} }
|
|
211
|
-
\`\`\`
|
|
212
|
-
\`flex-grow: 1\` + \`flex-basis: 0%\` splits the row evenly; \`min-width\` is the wrap threshold — under it the item
|
|
213
|
-
drops to the next line by itself, so a narrow panel degrades gracefully with no breakpoints.
|
|
214
|
-
- **Many uniform items** — cards, tiles, a gallery: one grid line does it all.
|
|
215
|
-
\`\`\`json
|
|
216
|
-
{ "type": "upsertDefinitions", "definitions": { "grid": { "desktop": { "display": "grid", "grid-template-columns": "repeat(auto-fit, minmax(160px, 1fr))", "gap": "12px" } } } }
|
|
217
|
-
\`\`\`
|
|
218
|
-
- **Label + value pairs** stay on one line (\`display: flex\`, \`justify-content: space-between\`) instead of two.
|
|
219
|
-
- **Vertical is right** for reading order: a heading over its paragraph, a form, a step list, long prose.
|
|
220
|
-
- Force a stack on tiny screens with the \`mobile\` block: \`"mobile": { "flex-direction": "column" }\`.
|
|
221
|
-
|
|
222
|
-
Keep it compact, and the numbers low: \`padding\` 12–16px (24+ only on a single hero card), \`gap\` 8–12px,
|
|
223
|
-
\`font-size\` 13–15px for body and 16–20px for headings. Let the outer container **fill** the panel — no \`width\` on
|
|
224
|
-
it — and reach for \`max-width\` only to stop one lone card from stretching across the whole panel.
|
|
225
|
-
|
|
226
|
-
## Match the host theme — never hardcode a light palette
|
|
227
|
-
|
|
228
|
-
The widget is embedded in the host's own UI (Claude Desktop, ChatGPT, the builder), and that UI **may be in dark
|
|
229
|
-
mode**. A widget painted with fixed light colours is the most common way to ship something unusable: a white card
|
|
230
|
-
in a dark chat glares, and — worse — text left at a dark default disappears against the host's dark background.
|
|
231
|
-
|
|
232
|
-
The host publishes its palette as CSS variables on the page, so use them for every colour, with a
|
|
233
|
-
\`light-dark(<light>, <dark>)\` fallback for hosts that send none:
|
|
234
|
-
|
|
235
|
-
\`\`\`json
|
|
236
|
-
{ "type": "upsertDefinitions", "definitions": { "card": { "desktop": {
|
|
237
|
-
"background-color": "var(--color-background-secondary, light-dark(#ffffff, #1f2430))",
|
|
238
|
-
"color": "var(--color-text-primary, light-dark(#0f172a, #e8eaed))",
|
|
239
|
-
"border-width": "1px", "border-style": "solid",
|
|
240
|
-
"border-color": "var(--color-border-primary, light-dark(#e2e8f0, #333a48))"
|
|
241
|
-
} } } }
|
|
242
|
-
\`\`\`
|
|
243
|
-
|
|
244
|
-
- Surfaces: \`--color-background-primary\` (the page), \`--color-background-secondary\` / \`--color-background-tertiary\`
|
|
245
|
-
(cards, raised areas). Text: \`--color-text-primary\`, \`--color-text-secondary\`, \`--color-text-tertiary\` (muted).
|
|
246
|
-
Borders: \`--color-border-primary\` / \`--color-border-secondary\`. Status pairs: \`--color-background-danger\` |
|
|
247
|
-
\`success\` | \`warning\` | \`info\` with the matching \`--color-text-…\`. Also \`--font-sans\`, \`--border-radius-md\` /
|
|
248
|
-
\`lg\` / \`full\`, \`--shadow-sm\` / \`md\`.
|
|
249
|
-
- **Set \`color\` wherever you set \`background-color\`** — the pair is what stays legible, either one alone is a
|
|
250
|
-
gamble. Same rule for a brand accent: a CTA on your own blue must state its own text colour (\`#ffffff\`).
|
|
251
|
-
- Prefer a border to a drop shadow for separation: shadows all but vanish on a dark surface.
|
|
252
|
-
|
|
253
|
-
## Element types (type → what to set)
|
|
254
|
-
|
|
255
|
-
| type | renders | set |
|
|
256
|
-
|---|---|---|
|
|
257
|
-
| \`container\` | layout box (a div) | nothing — style it with flex/grid |
|
|
258
|
-
| \`heading\` | h1–h6 title | \`props.content\`, element \`subType\`: "h1"…"h6" |
|
|
259
|
-
| \`paragraph\` | body text block (\`<p>\`) | \`props.content\` |
|
|
260
|
-
| \`text\` | inline text | \`props.content\` |
|
|
261
|
-
| \`button\` | clickable button | \`props.content\` |
|
|
262
|
-
| \`link\` | anchor | \`props.content\` (label), \`props.href\`, \`props.target\`: "self" \\| "blank" |
|
|
263
|
-
| \`image\` | \`<img>\` | \`props.src\`, \`props.alt\` |
|
|
264
|
-
| \`video\` | embedded video | \`props.src\` |
|
|
265
|
-
| \`list\` / \`listItem\` | \`<ul>\` / \`<li>\` | nesting only |
|
|
266
|
-
| \`markdown\` | rendered markdown | \`props.content\` |
|
|
267
|
-
| \`blockHtml\` | a raw HTML string, as written | \`props.content\` — how you draw an inline \`<svg>\`, see below |
|
|
268
|
-
|
|
269
|
-
\`subType\` is an element-level field (not a prop). Guessing is safe: an unknown prop for a type comes back as a
|
|
270
|
-
**warning naming the right one**, not an error. This table covers the everyday types; the resource
|
|
271
|
-
**plitzi://render/types** lists every built-in type you can use (with descriptions) — read it when you need one
|
|
272
|
-
that is not here (lists, tabs, dialogs, forms, icons…).
|
|
273
|
-
|
|
274
|
-
\`image\`/\`video\` \`src\` accepts any \`https\` URL, or a \`data:\`/\`blob:\` URI for a fully self-contained graphic (a
|
|
275
|
-
base64 raster) — both render with no extra setup. For a **vector** graphic do not encode a \`data:\` URI: draw it
|
|
276
|
-
inline, as below.
|
|
277
|
-
|
|
278
|
-
**Anything loaded from the internet.** Write the real URL and nothing else: images, video, fonts and the endpoint
|
|
279
|
-
an \`apiContainer\` reads are re-pointed at the render server after the widget is built, and it fetches them for
|
|
280
|
-
the widget. That is invisible to you and there is nothing to opt into — it is what settles the redirects, the
|
|
281
|
-
hotlink rules and the missing CORS headers that a widget, running in the surface's sandbox, cannot settle itself.
|
|
282
|
-
What it cannot do is guess:
|
|
283
|
-
|
|
284
|
-
- **Use URLs you have actually seen work.** A direct file URL, not a page about the picture, not a search result,
|
|
285
|
-
not a pattern you assembled from memory. A URL that 404s or answers with HTML instead of an image leaves a grey
|
|
286
|
-
placeholder box in the middle of an otherwise finished layout.
|
|
287
|
-
- **With no URL you trust, do not invent one.** Draw that block instead: a \`linear-gradient\`, a flat colour, an
|
|
288
|
-
inline \`<svg>\` or a \`data:\` URI — none touch the network and all of them always render.
|
|
289
|
-
- **A plain GET is the request that always works.** An \`apiContainer\` with a custom \`method\`, \`headers\` or
|
|
290
|
-
\`accessToken\` is called directly by the widget instead, so it is then subject to the surface's own network
|
|
291
|
-
policy and the API's CORS headers — the render warns you when that happens. \`{{tokens}}\` in the URL are fine.
|
|
292
|
-
When you are showing a shape rather than live data, \`mockData\` needs no network at all.
|
|
293
|
-
|
|
294
|
-
## Draw with inline SVG
|
|
295
|
-
|
|
296
|
-
A widget can draw its own graphics, and it is often the difference between a plain block of text and something
|
|
297
|
-
worth showing: a brand mark, a sparkline or donut, a badge, an empty-state glyph, a wave or blob behind a header,
|
|
298
|
-
an arrow between two steps. Put the SVG **inline** in a \`blockHtml\` element — its \`props.content\` is rendered as
|
|
299
|
-
written, so the markup needs no escaping, and the element is styled and laid out like any other box.
|
|
300
|
-
|
|
301
|
-
\`\`\`json
|
|
302
|
-
{
|
|
303
|
-
"operations": [
|
|
304
|
-
{ "type": "upsertDefinitions", "definitions": {
|
|
305
|
-
"mark": { "desktop": { "display": "flex", "width": "32px", "height": "32px", "color": "var(--color-text-primary, light-dark(#0f172a, #e8eaed))" } }
|
|
306
|
-
} },
|
|
307
|
-
{ "type": "upsertElement", "pageRef": "render", "element": {
|
|
308
|
-
"ref": "trend", "type": "blockHtml", "style": { "base": ["mark"] },
|
|
309
|
-
"props": { "content": "<svg viewBox='0 0 24 24' width='100%' height='100%' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round'><path d='M3 17l6-6 4 4 8-8'/><path d='M21 7v6h-6'/></svg>" }
|
|
310
|
-
} }
|
|
311
|
-
]
|
|
312
|
-
}
|
|
313
|
-
\`\`\`
|
|
314
|
-
- **Size from the class, not the drawing**: keep a \`viewBox\` and set \`width\`/\`height\` to \`100%\`, then the
|
|
315
|
-
\`blockHtml\`'s own \`width\`/\`height\` decide how big it renders — one drawing, any size.
|
|
316
|
-
- **Colour with \`currentColor\`** (\`fill\` and/or \`stroke\`) and set \`color\` on the class from a host variable. A hex
|
|
317
|
-
buried inside the path is the same mistake as a hardcoded light palette: it cannot follow the theme.
|
|
318
|
-
- **Single quotes inside the markup** keep the JSON free of \`\\"\` escapes, as above.
|
|
319
|
-
- **Markup only.** \`<script>\`, \`javascript:\` URLs and inline \`on*\` handlers are rejected with an error — a widget
|
|
320
|
-
runs inside the host's UI. Animate with CSS (a \`states\` block, a \`transition\`) and wire behaviour with
|
|
321
|
-
interaction flows.
|
|
322
|
-
|
|
323
|
-
**The budget.** Every path is text you write, so an SVG earns its place only while it stays small: a handful of
|
|
324
|
-
paths, a few hundred characters, drawn ONCE and reused (same class, same content, or a \`repeatElement\` row) rather
|
|
325
|
-
than redrawn per card. Skip it entirely when something cheaper does the job — a \`fontAwesome\` icon, an emoji in a
|
|
326
|
-
\`text\`, an \`https\` image the user gave you, a CSS gradient or a \`border-radius\` shape. And a full illustration or
|
|
327
|
-
a photo-real scene (a castle, a skyline, a detailed mascot) is still the wrong trade: it costs more than the entire
|
|
328
|
-
rest of the widget and renders worse than the image it is imitating.
|
|
329
|
-
|
|
330
|
-
## Keep the call small
|
|
331
|
-
|
|
332
|
-
Everything in \`operations\` is text you write, and a widget that takes two calls because the first ran long is a
|
|
333
|
-
widget the user waits twice for. Two habits pay for themselves:
|
|
334
|
-
|
|
335
|
-
- **Keep a drawing to a drawing.** Inline SVG is allowed and often worth it (see above), but a graphic that runs
|
|
336
|
-
longer than the widget around it has stopped paying for itself: a handful of paths, drawn once and reused rather
|
|
337
|
-
than redrawn per card, and an \`https\` image, a flat colour or a two-stop \`linear-gradient\` for anything bigger.
|
|
338
|
-
- **One class per look, not per property.** Classes like \`tone-blue\` + \`tone-blue-text\` + \`tone-blue-bg\` for the
|
|
339
|
-
same card triple the declarations and the attachments. Put everything the look needs in one class, add a second
|
|
340
|
-
only for the part that genuinely varies between siblings (a colour), and reuse it — the whole point of a class.
|
|
341
|
-
|
|
342
|
-
## Full worked example — two plans side by side
|
|
343
|
-
|
|
344
|
-
The cards sit in a wrapping row and split it evenly, so the widget uses the panel's width and stays short; on a
|
|
345
|
-
narrow panel \`min-width\` drops the second card under the first on its own.
|
|
346
|
-
|
|
347
|
-
\`\`\`json
|
|
348
|
-
{
|
|
349
|
-
"operations": [
|
|
350
|
-
{ "type": "upsertDefinitions", "definitions": {
|
|
351
|
-
"plans": { "desktop": { "display": "flex", "flex-direction": "row", "flex-wrap": "wrap", "gap": "12px", "align-items": "stretch" } },
|
|
352
|
-
"card": { "desktop": { "display": "flex", "flex-direction": "column", "gap": "6px", "flex-grow": "1", "flex-basis": "0%", "min-width": "150px", "padding": "16px", "background-color": "var(--color-background-secondary, light-dark(#ffffff, #1f2430))", "color": "var(--color-text-primary, light-dark(#0f172a, #e8eaed))", "border-width": "1px", "border-style": "solid", "border-color": "var(--color-border-primary, light-dark(#e2e8f0, #333a48))", "border-radius": "var(--border-radius-lg, 12px)", "text-align": "center" } },
|
|
353
|
-
"price": { "desktop": { "font-size": "28px", "font-weight": "800", "color": "#3b82f6" } },
|
|
354
|
-
"cta": { "desktop": { "background-color": "#3b82f6", "color": "#ffffff", "padding": "10px 16px", "border-radius": "8px", "font-weight": "600" }, "states": { "hover": { "desktop": { "background-color": "#2563eb" } } } }
|
|
355
|
-
} },
|
|
356
|
-
{ "type": "upsertElement", "pageRef": "render", "element": {
|
|
357
|
-
"ref": "plans", "type": "container", "style": { "base": ["plans"] },
|
|
358
|
-
"children": [
|
|
359
|
-
{ "ref": "free", "type": "container", "style": { "base": ["card"] }, "children": [
|
|
360
|
-
{ "ref": "free-plan", "type": "heading", "subType": "h3", "props": { "content": "Starter" } },
|
|
361
|
-
{ "ref": "free-amount", "type": "text", "props": { "content": "$0" }, "style": { "base": ["price"] } },
|
|
362
|
-
{ "ref": "free-buy", "type": "button", "props": { "content": "Start free" }, "style": { "base": ["cta"] } }
|
|
363
|
-
] },
|
|
364
|
-
{ "ref": "pro", "type": "container", "style": { "base": ["card"] }, "children": [
|
|
365
|
-
{ "ref": "pro-plan", "type": "heading", "subType": "h3", "props": { "content": "Pro" } },
|
|
366
|
-
{ "ref": "pro-amount", "type": "text", "props": { "content": "$29/mo" }, "style": { "base": ["price"] } },
|
|
367
|
-
{ "ref": "pro-buy", "type": "button", "props": { "content": "Start free trial" }, "style": { "base": ["cta"] } }
|
|
368
|
-
] }
|
|
369
|
-
]
|
|
370
|
-
} }
|
|
371
|
-
]
|
|
372
|
-
}
|
|
373
|
-
\`\`\`
|
|
374
|
-
|
|
375
|
-
## Data & interactivity (optional)
|
|
376
|
-
|
|
377
|
-
The widget runs the live SDK, so beyond static layout it can fetch data and respond to events. Both are wired by
|
|
378
|
-
\`ref\`, just like styling. (Full reference: **plitzi://guide** — sections Data bindings and Interactions.)
|
|
379
|
-
|
|
380
|
-
### Fetch data — a provider + a binding
|
|
381
|
-
An \`apiContainer\` fetches at runtime and exposes the result as the source **\`apiContainer_<idRef>.data\`**, visible
|
|
382
|
-
to its **DESCENDANTS only** — the bound element must live inside the container's subtree. \`upsertBinding\` then
|
|
383
|
-
connects that source to a descendant's field.
|
|
384
|
-
|
|
385
|
-
\`\`\`json
|
|
386
|
-
{
|
|
387
|
-
"operations": [
|
|
388
|
-
{ "type": "upsertElement", "pageRef": "render", "element": {
|
|
389
|
-
"ref": "products", "type": "apiContainer", "props": { "query": "<your data query — see plitzi://guide>" },
|
|
390
|
-
"children": [ { "ref": "title", "type": "heading", "subType": "h3", "props": { "content": "…" } } ]
|
|
391
|
-
} },
|
|
392
|
-
{ "type": "upsertBinding", "pageRef": "render", "ref": "title", "category": "attributes", "binding": { "to": "content", "source": "apiContainer_products.data.0.name" } }
|
|
393
|
-
]
|
|
394
|
-
}
|
|
395
|
-
\`\`\`
|
|
396
|
-
- \`category\`: \`"attributes"\` (a prop such as \`content\`/\`src\`), \`"style"\` (a CSS value) or \`"initialState"\`.
|
|
397
|
-
- \`binding.to\` is the target field; \`binding.source\` is the \`<type>_<idRef>.path\` into the provider's data.
|
|
398
|
-
- \`mockData\` on the provider is builder-only — set a real \`query\` for the widget to actually fetch.
|
|
399
|
-
|
|
400
|
-
### React to events — an interaction flow
|
|
401
|
-
\`upsertInteractionFlow\` attaches an ordered \`nodes\` list to an element; the FIRST node is a \`trigger\` (e.g.
|
|
402
|
-
\`onClick\`), the rest run after it. Each following step is one of:
|
|
403
|
-
- **\`globalCallback\`** (OMIT \`elementId\`) — a built-in app action: \`addNotification\` (\`params.content\`),
|
|
404
|
-
\`navigate\`, \`setState\` (\`key\`/\`type\`/\`value\`), \`authLogin\`/\`authLogout\`…
|
|
405
|
-
- **\`callback\`** (\`elementId\` = an element, defaults to the trigger's) — that ELEMENT's OWN callback: e.g. an
|
|
406
|
-
\`apiContainer\` re-fetches, a \`form\` submits. Each type's own callback action names are in plitzi://guide.
|
|
407
|
-
|
|
408
|
-
\`\`\`json
|
|
409
|
-
{ "type": "upsertInteractionFlow", "pageRef": "render", "ref": "buy", "nodes": [
|
|
410
|
-
{ "title": "On click", "nodeType": "trigger", "action": "onClick" },
|
|
411
|
-
{ "title": "Toast", "nodeType": "globalCallback", "action": "addNotification", "params": { "content": "Added to cart" } }
|
|
412
|
-
] }
|
|
413
|
-
\`\`\`
|
|
414
|
-
|
|
415
|
-
## When it fails
|
|
416
|
-
The tool returns \`rendered: false\` with \`errors: [{ path, message, hint }]\`. Read the hint, fix that one op, and
|
|
417
|
-
retry — you never lose the rest of the batch.
|
|
418
|
-
`;
|
|
419
|
-
/** The same two documents through the READ path (the router, hence plitzi_read), not only as MCP resources: an
|
|
420
|
-
* agent that reaches for the batch-read tool — the reflex the guide itself teaches — must not be told its own
|
|
421
|
-
* authoring guide does not exist. Space-independent, like the core singletons. */
|
|
422
|
-
var readRenderResource = (uri) => {
|
|
423
|
-
if (uri === "plitzi://render/guide") return envelope(renderGuideText);
|
|
424
|
-
if (uri === "plitzi://render/types") return envelope(renderTypes());
|
|
425
|
-
};
|
|
426
|
-
var registerRenderResources = (server, log) => {
|
|
427
|
-
server.registerResource("Render guide", RENDER_GUIDE_URI, {
|
|
428
|
-
description: "How to author a plitzi_render widget: operations, element types, styling, examples.",
|
|
429
|
-
mimeType: "text/markdown"
|
|
430
|
-
}, () => {
|
|
431
|
-
const start = performance.now();
|
|
432
|
-
const contents = { contents: [{
|
|
433
|
-
uri: RENDER_GUIDE_URI,
|
|
434
|
-
mimeType: "text/markdown",
|
|
435
|
-
text: renderGuideText
|
|
436
|
-
}] };
|
|
437
|
-
log.resourceRead(RENDER_GUIDE_URI, performance.now() - start);
|
|
438
|
-
return contents;
|
|
439
|
-
});
|
|
440
|
-
server.registerResource("Render element types", RENDER_TYPES_URI, {
|
|
441
|
-
description: "Built-in element types a plitzi_render widget can use, with descriptions.",
|
|
442
|
-
mimeType: "application/json"
|
|
443
|
-
}, () => {
|
|
444
|
-
const start = performance.now();
|
|
445
|
-
const contents = jsonContents(RENDER_TYPES_URI, envelope(renderTypes()));
|
|
446
|
-
log.resourceRead(RENDER_TYPES_URI, performance.now() - start);
|
|
447
|
-
return contents;
|
|
448
|
-
});
|
|
449
|
-
};
|
|
450
|
-
//#endregion
|
|
451
|
-
export { RENDER_GUIDE_URI, RENDER_TYPES_URI, readRenderResource, registerRenderResources };
|