@plitzi/sdk-server 0.32.4 → 0.32.5
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 +9 -0
- package/dist/adapters/jsonAdapters.js +6 -1
- package/dist/core/createServer.js +8 -44
- package/dist/core/health.js +15 -0
- package/dist/core/http/dispatcher.js +29 -0
- package/dist/core/http/securityHeaders.js +15 -0
- package/dist/core/http/stages/authRoutes.js +41 -0
- package/dist/core/http/stages/health.js +12 -0
- package/dist/core/http/stages/middlewares.js +16 -0
- package/dist/core/http/stages/pluginAssets.js +20 -0
- package/dist/core/http/stages/static.js +30 -0
- package/dist/core/server/baseServer.js +29 -0
- package/dist/core/server/mcpServer.js +29 -0
- package/dist/core/server/ssrServer.js +54 -0
- package/dist/core/services/mcp.js +22 -0
- package/dist/core/services/preview.js +37 -0
- package/dist/core/services/registry.js +30 -0
- package/dist/core/services/resolve.js +12 -0
- package/dist/core/services/rsc.js +11 -0
- package/dist/core/services/ssr.js +13 -0
- package/dist/core/transports.js +9 -9
- package/dist/index.js +19 -6
- package/dist/modules/ai/AIEngine.js +4 -4
- package/dist/modules/ai/toolkit.js +58 -0
- package/dist/modules/mcp/constants.js +4 -0
- package/dist/modules/mcp/handler.js +15 -21
- package/dist/modules/mcp/helpers/computeVersion.js +16 -0
- package/dist/modules/mcp/helpers/guide.js +130 -0
- package/dist/modules/mcp/helpers/opResult.js +18 -0
- package/dist/modules/mcp/helpers/space.js +137 -0
- package/dist/modules/mcp/previewClient.js +31 -0
- package/dist/modules/mcp/resources/canonical.js +45 -0
- package/dist/modules/mcp/resources/core.js +14 -0
- package/dist/modules/mcp/resources/envelope.js +14 -0
- package/dist/modules/mcp/resources/primer.js +25 -0
- package/dist/modules/mcp/resources/register.js +142 -0
- package/dist/modules/mcp/resources/router.js +25 -0
- package/dist/modules/mcp/resources/schema.js +33 -0
- package/dist/modules/mcp/resources/style.js +27 -0
- package/dist/modules/mcp/screenshotClient.js +47 -0
- package/dist/modules/mcp/server.js +52 -20
- package/dist/modules/mcp/tools/apply/dispatch.js +83 -0
- package/dist/modules/mcp/tools/apply/index.js +121 -0
- package/dist/modules/mcp/tools/apply/writeResult.js +36 -0
- package/dist/modules/mcp/tools/index.js +20 -148
- package/dist/modules/mcp/tools/operations/index.js +30 -0
- package/dist/modules/mcp/tools/operations/schema/deleteElement.js +25 -0
- package/dist/modules/mcp/tools/operations/schema/deleteFolder.js +30 -0
- package/dist/modules/mcp/tools/operations/schema/deletePage.js +22 -0
- package/dist/modules/mcp/tools/operations/schema/deleteVariable.js +18 -0
- package/dist/modules/mcp/tools/operations/schema/moveElement.js +39 -0
- package/dist/modules/mcp/tools/operations/schema/operations.js +25 -0
- package/dist/modules/mcp/tools/operations/schema/patchElement.js +46 -0
- package/dist/modules/mcp/tools/operations/schema/registry.js +55 -0
- package/dist/modules/mcp/tools/operations/schema/shared.js +27 -0
- package/dist/modules/mcp/tools/operations/schema/translator.js +148 -0
- package/dist/modules/mcp/tools/operations/schema/upsertElement.js +59 -0
- package/dist/modules/mcp/tools/operations/schema/upsertFolder.js +49 -0
- package/dist/modules/mcp/tools/operations/schema/upsertPage.js +64 -0
- package/dist/modules/mcp/tools/operations/schema/upsertVariable.js +42 -0
- package/dist/modules/mcp/tools/operations/schema/write.js +44 -0
- package/dist/modules/mcp/tools/operations/style/cssCatalog.js +132 -0
- package/dist/modules/mcp/tools/operations/style/deleteDefinition.js +20 -0
- package/dist/modules/mcp/tools/operations/style/deleteGlobalStyle.js +20 -0
- package/dist/modules/mcp/tools/operations/style/deleteStyleVariable.js +21 -0
- package/dist/modules/mcp/tools/operations/style/operations.js +21 -0
- package/dist/modules/mcp/tools/operations/style/patchDefinition.js +27 -0
- package/dist/modules/mcp/tools/operations/style/patchGlobalStyle.js +27 -0
- package/dist/modules/mcp/tools/operations/style/shared.js +59 -0
- package/dist/modules/mcp/tools/operations/style/translator.js +77 -0
- package/dist/modules/mcp/tools/operations/style/upsertDefinition.js +23 -0
- package/dist/modules/mcp/tools/operations/style/upsertGlobalStyle.js +23 -0
- package/dist/modules/mcp/tools/operations/style/upsertStyleVariable.js +22 -0
- package/dist/modules/mcp/tools/operations/style/write.js +100 -0
- package/dist/modules/mcp/tools/preview.js +37 -0
- package/dist/modules/mcp/tools/read.js +33 -0
- package/dist/modules/mcp/tools/screenshot.js +83 -0
- package/dist/modules/mcp/tools/search.js +108 -0
- package/dist/modules/mcp/tools/shared/tool.js +26 -0
- package/dist/modules/mcp/tools/shared/validator.js +262 -0
- package/dist/modules/mcp/tools/validate.js +19 -0
- package/dist/modules/ssr/buildBody.js +2 -2
- package/dist/modules/ssr/handler.js +6 -4
- package/dist/modules/ssr/prepareRender.js +5 -5
- package/dist/modules/ssr/preview.js +106 -0
- package/dist/modules/ssr/registerExternalPlugins.js +1 -1
- package/dist/modules/ssr/streamBody.js +3 -3
- package/dist/modules/ssr/template.js +1 -1
- package/dist/plugins/compile.js +1 -1
- package/dist/plugins/copy.js +1 -1
- package/dist/plugins/manager.js +1 -1
- package/dist/server.js +34 -9
- package/dist/src/core/createServer.d.ts +5 -1
- package/dist/src/core/health.d.ts +10 -0
- package/dist/src/core/http/dispatcher.d.ts +7 -0
- package/dist/src/core/http/securityHeaders.d.ts +2 -0
- package/dist/src/core/http/stages/authRoutes.d.ts +4 -0
- package/dist/src/core/http/stages/health.d.ts +2 -0
- package/dist/src/core/http/stages/middlewares.d.ts +2 -0
- package/dist/src/core/http/stages/pluginAssets.d.ts +2 -0
- package/dist/src/core/http/stages/static.d.ts +5 -0
- package/dist/src/core/http/types.d.ts +19 -0
- package/dist/src/core/server/baseServer.d.ts +9 -0
- package/dist/src/core/server/mcpServer.d.ts +2 -0
- package/dist/src/core/server/ssrServer.d.ts +2 -0
- package/dist/src/core/services/mcp.d.ts +3 -0
- package/dist/src/core/services/preview.d.ts +2 -0
- package/dist/src/core/services/registry.d.ts +4 -0
- package/dist/src/core/services/resolve.d.ts +3 -0
- package/dist/src/core/services/rsc.d.ts +2 -0
- package/dist/src/core/services/ssr.d.ts +3 -0
- package/dist/src/core/transports.d.ts +2 -2
- package/dist/src/index.d.ts +12 -3
- package/dist/src/modules/ai/index.d.ts +1 -0
- package/dist/src/modules/ai/toolkit.d.ts +17 -0
- package/dist/src/modules/mcp/constants.d.ts +1 -0
- package/dist/src/modules/mcp/handler.d.ts +6 -3
- package/dist/src/modules/mcp/helpers/computeVersion.d.ts +1 -0
- package/dist/src/modules/mcp/helpers/guide.d.ts +2 -0
- package/dist/src/modules/mcp/helpers/index.d.ts +4 -0
- package/dist/src/modules/mcp/helpers/opResult.d.ts +13 -0
- package/dist/src/modules/mcp/helpers/space.d.ts +49 -0
- package/dist/src/modules/mcp/index.d.ts +12 -5
- package/dist/src/modules/mcp/previewClient.d.ts +13 -0
- package/dist/src/modules/mcp/resources/canonical.d.ts +7 -0
- package/dist/src/modules/mcp/resources/core.d.ts +5 -0
- package/dist/src/modules/mcp/resources/envelope.d.ts +10 -0
- package/dist/src/modules/mcp/resources/index.d.ts +8 -10
- package/dist/src/modules/mcp/resources/primer.d.ts +6 -0
- package/dist/src/modules/mcp/resources/register.d.ts +6 -0
- package/dist/src/modules/mcp/resources/router.d.ts +6 -0
- package/dist/src/modules/mcp/resources/schema.d.ts +5 -0
- package/dist/src/modules/mcp/resources/style.d.ts +5 -0
- package/dist/src/modules/mcp/screenshotClient.d.ts +13 -0
- package/dist/src/modules/mcp/server.d.ts +18 -3
- package/dist/src/modules/mcp/tools/apply/dispatch.d.ts +6 -0
- package/dist/src/modules/mcp/tools/apply/index.d.ts +231 -0
- package/dist/src/modules/mcp/tools/apply/writeResult.d.ts +8 -0
- package/dist/src/modules/mcp/tools/index.d.ts +17 -6
- package/dist/src/modules/mcp/tools/operations/index.d.ts +449 -0
- package/dist/src/modules/mcp/tools/operations/schema/deleteElement.d.ts +10 -0
- package/dist/src/modules/mcp/tools/operations/schema/deleteFolder.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/schema/deletePage.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/schema/deleteVariable.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/schema/index.d.ts +14 -0
- package/dist/src/modules/mcp/tools/operations/schema/moveElement.d.ts +16 -0
- package/dist/src/modules/mcp/tools/operations/schema/operations.d.ts +79 -0
- package/dist/src/modules/mcp/tools/operations/schema/patchElement.d.ts +17 -0
- package/dist/src/modules/mcp/tools/operations/schema/registry.d.ts +22 -0
- package/dist/src/modules/mcp/tools/operations/schema/shared.d.ts +24 -0
- package/dist/src/modules/mcp/tools/operations/schema/translator.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/schema/upsertElement.d.ts +16 -0
- package/dist/src/modules/mcp/tools/operations/schema/upsertFolder.d.ts +12 -0
- package/dist/src/modules/mcp/tools/operations/schema/upsertPage.d.ts +13 -0
- package/dist/src/modules/mcp/tools/operations/schema/upsertVariable.d.ts +16 -0
- package/dist/src/modules/mcp/tools/operations/schema/write.d.ts +12 -0
- package/dist/src/modules/mcp/tools/operations/style/cssCatalog.d.ts +10 -0
- package/dist/src/modules/mcp/tools/operations/style/deleteDefinition.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/style/deleteGlobalStyle.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/style/deleteStyleVariable.d.ts +15 -0
- package/dist/src/modules/mcp/tools/operations/style/index.d.ts +12 -0
- package/dist/src/modules/mcp/tools/operations/style/operations.d.ts +163 -0
- package/dist/src/modules/mcp/tools/operations/style/patchDefinition.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/patchGlobalStyle.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/shared.d.ts +115 -0
- package/dist/src/modules/mcp/tools/operations/style/translator.d.ts +9 -0
- package/dist/src/modules/mcp/tools/operations/style/upsertDefinition.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/upsertGlobalStyle.d.ts +37 -0
- package/dist/src/modules/mcp/tools/operations/style/upsertStyleVariable.d.ts +20 -0
- package/dist/src/modules/mcp/tools/operations/style/write.d.ts +17 -0
- package/dist/src/modules/mcp/tools/preview.d.ts +226 -0
- package/dist/src/modules/mcp/tools/read.d.ts +8 -0
- package/dist/src/modules/mcp/tools/screenshot.d.ts +231 -0
- package/dist/src/modules/mcp/tools/search.d.ts +15 -0
- package/dist/src/modules/mcp/tools/shared/tool.d.ts +50 -0
- package/dist/src/modules/mcp/tools/shared/validator.d.ts +4 -0
- package/dist/src/modules/mcp/tools/validate.d.ts +228 -0
- package/dist/src/modules/mcp/types/aiSchema.d.ts +126 -0
- package/dist/src/modules/mcp/types/index.d.ts +4 -0
- package/dist/src/modules/mcp/types/previewTypes.d.ts +25 -0
- package/dist/src/modules/mcp/types/screenshotTypes.d.ts +29 -0
- package/dist/src/modules/mcp/types/toolTypes.d.ts +138 -0
- package/dist/src/modules/ssr/buildBody.d.ts +2 -2
- package/dist/src/modules/ssr/prepareRender.d.ts +2 -2
- package/dist/src/modules/ssr/preview.d.ts +16 -0
- package/dist/src/modules/ssr/streamBody.d.ts +2 -2
- package/package.json +10 -10
- package/dist/_virtual/_rolldown/runtime.js +0 -13
- package/dist/core/requestHandler.js +0 -126
- package/dist/modules/mcp/helpers.js +0 -75
- package/dist/modules/mcp/resources/glossary/binding.js +0 -73
- package/dist/modules/mcp/resources/glossary/collection.js +0 -76
- package/dist/modules/mcp/resources/glossary/displayMode.js +0 -50
- package/dist/modules/mcp/resources/glossary/element.js +0 -68
- package/dist/modules/mcp/resources/glossary/environment.js +0 -48
- package/dist/modules/mcp/resources/glossary/interaction.js +0 -62
- package/dist/modules/mcp/resources/glossary/page.js +0 -70
- package/dist/modules/mcp/resources/glossary/plugin.js +0 -96
- package/dist/modules/mcp/resources/glossary/resource.js +0 -75
- package/dist/modules/mcp/resources/glossary/schema.js +0 -69
- package/dist/modules/mcp/resources/glossary/schemaVariable.js +0 -60
- package/dist/modules/mcp/resources/glossary/segment.js +0 -59
- package/dist/modules/mcp/resources/glossary/space.js +0 -73
- package/dist/modules/mcp/resources/glossary/style.js +0 -81
- package/dist/modules/mcp/resources/glossary/styleSelector.js +0 -77
- package/dist/modules/mcp/resources/glossary/styleVariable.js +0 -72
- package/dist/modules/mcp/resources/index.js +0 -71
- package/dist/modules/mcp/resources/workflows/data.js +0 -49
- package/dist/modules/mcp/resources/workflows/elements.js +0 -53
- package/dist/modules/mcp/resources/workflows/segments.js +0 -55
- package/dist/modules/mcp/resources/workflows/styles.js +0 -91
- package/dist/modules/mcp/tools/collections/createCollection.js +0 -25
- package/dist/modules/mcp/tools/collections/createCollectionRecord.js +0 -27
- package/dist/modules/mcp/tools/collections/deleteCollection.js +0 -16
- package/dist/modules/mcp/tools/collections/deleteCollectionRecord.js +0 -16
- package/dist/modules/mcp/tools/collections/getCollection.js +0 -21
- package/dist/modules/mcp/tools/collections/getCollectionRecord.js +0 -25
- package/dist/modules/mcp/tools/collections/getCollectionRecords.js +0 -29
- package/dist/modules/mcp/tools/collections/getCollections.js +0 -19
- package/dist/modules/mcp/tools/collections/updateCollection.js +0 -28
- package/dist/modules/mcp/tools/collections/updateCollectionRecord.js +0 -31
- package/dist/modules/mcp/tools/docs/listResources.js +0 -16
- package/dist/modules/mcp/tools/docs/readResource.js +0 -23
- package/dist/modules/mcp/tools/plugins/addPlugin.js +0 -24
- package/dist/modules/mcp/tools/plugins/listPlugins.js +0 -20
- package/dist/modules/mcp/tools/plugins/removePlugin.js +0 -16
- package/dist/modules/mcp/tools/plugins/updatePlugin.js +0 -23
- package/dist/modules/mcp/tools/resources/addResource.js +0 -33
- package/dist/modules/mcp/tools/resources/getResource.js +0 -29
- package/dist/modules/mcp/tools/resources/getResources.js +0 -27
- package/dist/modules/mcp/tools/resources/moveResource.js +0 -30
- package/dist/modules/mcp/tools/resources/removeResource.js +0 -19
- package/dist/modules/mcp/tools/segment/createSegment.js +0 -27
- package/dist/modules/mcp/tools/segment/deleteSegment.js +0 -16
- package/dist/modules/mcp/tools/segment/getSegment.js +0 -19
- package/dist/modules/mcp/tools/segment/getSegments.js +0 -27
- package/dist/modules/mcp/tools/segment/schema/elements/createSegmentElement.js +0 -24
- package/dist/modules/mcp/tools/segment/schema/elements/deleteSegmentElement.js +0 -19
- package/dist/modules/mcp/tools/segment/schema/elements/moveSegmentElement.js +0 -28
- package/dist/modules/mcp/tools/segment/schema/elements/updateSegmentElement.js +0 -23
- package/dist/modules/mcp/tools/segment/schema/variables/createSegmentVariable.js +0 -41
- package/dist/modules/mcp/tools/segment/schema/variables/deleteSegmentVariable.js +0 -19
- package/dist/modules/mcp/tools/segment/schema/variables/updateSegmentVariable.js +0 -41
- package/dist/modules/mcp/tools/segment/style/variables/createSegmentStyleVariable.js +0 -34
- package/dist/modules/mcp/tools/segment/style/variables/deleteSegmentStyleVariable.js +0 -21
- package/dist/modules/mcp/tools/segment/style/variables/updateSegmentStyleVariable.js +0 -34
- package/dist/modules/mcp/tools/segment/updateSegment.js +0 -30
- package/dist/modules/mcp/tools/space/schema/applyPreview.js +0 -33
- package/dist/modules/mcp/tools/space/schema/elements/cloneElement.js +0 -34
- package/dist/modules/mcp/tools/space/schema/elements/createElement.js +0 -50
- package/dist/modules/mcp/tools/space/schema/elements/deleteElement.js +0 -16
- package/dist/modules/mcp/tools/space/schema/elements/getElement.js +0 -17
- package/dist/modules/mcp/tools/space/schema/elements/getElements.js +0 -21
- package/dist/modules/mcp/tools/space/schema/elements/listElements.js +0 -28
- package/dist/modules/mcp/tools/space/schema/elements/moveElement.js +0 -27
- package/dist/modules/mcp/tools/space/schema/elements/updateElement.js +0 -49
- package/dist/modules/mcp/tools/space/schema/getSpaceSettings.js +0 -46
- package/dist/modules/mcp/tools/space/schema/pageFolders/createPageFolder.js +0 -24
- package/dist/modules/mcp/tools/space/schema/pageFolders/deletePageFolder.js +0 -16
- package/dist/modules/mcp/tools/space/schema/pageFolders/getPageFolder.js +0 -17
- package/dist/modules/mcp/tools/space/schema/pageFolders/getPageFolders.js +0 -17
- package/dist/modules/mcp/tools/space/schema/pageFolders/updatePageFolder.js +0 -28
- package/dist/modules/mcp/tools/space/schema/pages/createPage.js +0 -37
- package/dist/modules/mcp/tools/space/schema/pages/deletePage.js +0 -16
- package/dist/modules/mcp/tools/space/schema/pages/getPage.js +0 -28
- package/dist/modules/mcp/tools/space/schema/pages/getPageBySlug.js +0 -17
- package/dist/modules/mcp/tools/space/schema/pages/getPages.js +0 -17
- package/dist/modules/mcp/tools/space/schema/pages/updatePage.js +0 -25
- package/dist/modules/mcp/tools/space/schema/schemas.js +0 -53
- package/dist/modules/mcp/tools/space/schema/updateSpaceSettings.js +0 -23
- package/dist/modules/mcp/tools/space/schema/variables/createVariable.js +0 -38
- package/dist/modules/mcp/tools/space/schema/variables/deleteVariable.js +0 -16
- package/dist/modules/mcp/tools/space/schema/variables/getVariable.js +0 -17
- package/dist/modules/mcp/tools/space/schema/variables/getVariables.js +0 -17
- package/dist/modules/mcp/tools/space/schema/variables/updateVariable.js +0 -38
- package/dist/modules/mcp/tools/space/style/selectors/createStyleSelector.js +0 -37
- package/dist/modules/mcp/tools/space/style/selectors/deleteStyleSelector.js +0 -24
- package/dist/modules/mcp/tools/space/style/selectors/getStyleSelectors.js +0 -20
- package/dist/modules/mcp/tools/space/style/selectors/updateStyleSelector.js +0 -37
- package/dist/modules/mcp/tools/space/style/variables/createStyleVariable.js +0 -33
- package/dist/modules/mcp/tools/space/style/variables/deleteStyleVariable.js +0 -20
- package/dist/modules/mcp/tools/space/style/variables/getStyleVariable.js +0 -19
- package/dist/modules/mcp/tools/space/style/variables/getStyleVariables.js +0 -16
- package/dist/modules/mcp/tools/space/style/variables/updateStyleVariable.js +0 -33
- package/dist/package.js +0 -77
- package/dist/package.json.d.ts +0 -67
- package/dist/src/core/requestHandler.d.ts +0 -5
- package/dist/src/modules/mcp/helpers.d.ts +0 -9
- package/dist/src/modules/mcp/resources/glossary/binding.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/collection.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/displayMode.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/element.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/environment.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/interaction.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/page.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/plugin.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/resource.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/schema.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/schemaVariable.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/segment.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/space.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/style.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/styleSelector.d.ts +0 -7
- package/dist/src/modules/mcp/resources/glossary/styleVariable.d.ts +0 -7
- package/dist/src/modules/mcp/resources/workflows/data.d.ts +0 -7
- package/dist/src/modules/mcp/resources/workflows/elements.d.ts +0 -7
- package/dist/src/modules/mcp/resources/workflows/segments.d.ts +0 -7
- package/dist/src/modules/mcp/resources/workflows/styles.d.ts +0 -7
- package/dist/src/modules/mcp/tools/collections/createCollection.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/createCollectionRecord.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/deleteCollection.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/deleteCollectionRecord.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/getCollection.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/getCollectionRecord.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/getCollectionRecords.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/getCollections.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/index.d.ts +0 -10
- package/dist/src/modules/mcp/tools/collections/updateCollection.d.ts +0 -3
- package/dist/src/modules/mcp/tools/collections/updateCollectionRecord.d.ts +0 -3
- package/dist/src/modules/mcp/tools/docs/index.d.ts +0 -2
- package/dist/src/modules/mcp/tools/docs/listResources.d.ts +0 -3
- package/dist/src/modules/mcp/tools/docs/readResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/plugins/addPlugin.d.ts +0 -3
- package/dist/src/modules/mcp/tools/plugins/index.d.ts +0 -5
- package/dist/src/modules/mcp/tools/plugins/listPlugins.d.ts +0 -3
- package/dist/src/modules/mcp/tools/plugins/removePlugin.d.ts +0 -3
- package/dist/src/modules/mcp/tools/plugins/updatePlugin.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/addResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/getResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/getResources.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/index.d.ts +0 -6
- package/dist/src/modules/mcp/tools/resources/moveResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/removeResource.d.ts +0 -3
- package/dist/src/modules/mcp/tools/resources/resources.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/segment/createSegment.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/deleteSegment.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/getSegment.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/getSegments.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/index.d.ts +0 -8
- package/dist/src/modules/mcp/tools/segment/schema/elements/createSegmentElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/elements/deleteSegmentElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/elements/index.d.ts +0 -5
- package/dist/src/modules/mcp/tools/segment/schema/elements/moveSegmentElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/elements/segmentElements.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/segment/schema/elements/updateSegmentElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/index.d.ts +0 -2
- package/dist/src/modules/mcp/tools/segment/schema/variables/createSegmentVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/variables/deleteSegmentVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/schema/variables/index.d.ts +0 -4
- package/dist/src/modules/mcp/tools/segment/schema/variables/segmentVariables.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/segment/schema/variables/updateSegmentVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/segment.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/segment/style/index.d.ts +0 -1
- package/dist/src/modules/mcp/tools/segment/style/variables/createSegmentStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/style/variables/deleteSegmentStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/style/variables/index.d.ts +0 -4
- package/dist/src/modules/mcp/tools/segment/style/variables/segmentStyleVariables.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/segment/style/variables/updateSegmentStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/segment/updateSegment.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/index.d.ts +0 -2
- package/dist/src/modules/mcp/tools/space/schema/applyPreview.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/cloneElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/createElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/deleteElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/elements.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/schema/elements/getElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/getElements.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/index.d.ts +0 -9
- package/dist/src/modules/mcp/tools/space/schema/elements/listElements.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/moveElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/elements/updateElement.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/getSpaceSettings.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/index.d.ts +0 -8
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/createPageFolder.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/deletePageFolder.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/getPageFolder.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/getPageFolders.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/index.d.ts +0 -6
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/pageFolders.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/schema/pageFolders/updatePageFolder.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/createPage.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/deletePage.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/getPage.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/getPageBySlug.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/getPages.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/pages/index.d.ts +0 -7
- package/dist/src/modules/mcp/tools/space/schema/pages/pages.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/schema/pages/updatePage.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/schemas.d.ts +0 -66
- package/dist/src/modules/mcp/tools/space/schema/updateSpaceSettings.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/createVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/deleteVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/getVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/getVariables.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/index.d.ts +0 -6
- package/dist/src/modules/mcp/tools/space/schema/variables/updateVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/schema/variables/variables.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/space.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/style/index.d.ts +0 -2
- package/dist/src/modules/mcp/tools/space/style/selectors/createStyleSelector.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/selectors/deleteStyleSelector.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/selectors/getStyleSelectors.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/selectors/index.d.ts +0 -5
- package/dist/src/modules/mcp/tools/space/style/selectors/styleSelectors.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/style/selectors/updateStyleSelector.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/createStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/deleteStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/getStyleVariable.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/getStyleVariables.d.ts +0 -3
- package/dist/src/modules/mcp/tools/space/style/variables/index.d.ts +0 -6
- package/dist/src/modules/mcp/tools/space/style/variables/styleVariables.test.d.ts +0 -1
- package/dist/src/modules/mcp/tools/space/style/variables/updateStyleVariable.d.ts +0 -3
- /package/dist/src/{modules/mcp/helpers.test.d.ts → core/server/mcpServer.test.d.ts} +0 -0
- /package/dist/src/modules/{mcp/tools/collections/collections.test.d.ts → ai/toolkit.test.d.ts} +0 -0
- /package/dist/src/modules/mcp/{tools/plugins/plugins.test.d.ts → mcp.test.d.ts} +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { findPageByRef, resolveRef } from "../../../helpers/space.js";
|
|
2
|
+
import { empty, fail } from "../../../helpers/opResult.js";
|
|
3
|
+
import { createElement, pageUri } from "./write.js";
|
|
4
|
+
import { elementInput, position } from "./shared.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
//#region src/modules/mcp/tools/operations/schema/upsertElement.ts
|
|
7
|
+
var upsertElementOp = z.object({
|
|
8
|
+
type: z.literal("upsertElement"),
|
|
9
|
+
pageRef: z.string().describe("Page ref or id"),
|
|
10
|
+
element: elementInput,
|
|
11
|
+
parentRef: z.string().optional().describe("Anchor ref/id; defaults to page root"),
|
|
12
|
+
position: position.optional()
|
|
13
|
+
}).describe("Add an element to a page, or fully update it when element.ref already exists (props and style are REPLACED, not merged). To change only some fields of an existing element, use patchElement instead.");
|
|
14
|
+
var upsertElement = (space, env, op) => {
|
|
15
|
+
const page = findPageByRef(space.schema, op.pageRef);
|
|
16
|
+
if (!page) return fail("pageRef", `Page "${op.pageRef}" not found`, "Read plitzi://schema/" + env + "/pages for valid refs");
|
|
17
|
+
const existing = resolveRef(space.schema, page, op.element.ref);
|
|
18
|
+
if (existing && existing.id !== page.id) {
|
|
19
|
+
if (op.element.label !== void 0) existing.definition.label = op.element.label;
|
|
20
|
+
if (op.element.props !== void 0 || op.element.subType !== void 0) {
|
|
21
|
+
const subType = op.element.subType ?? existing.attributes.subType;
|
|
22
|
+
existing.attributes = subType === void 0 ? { ...op.element.props } : {
|
|
23
|
+
subType,
|
|
24
|
+
...op.element.props
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (op.element.style !== void 0) {
|
|
28
|
+
const selectors = { base: (op.element.style.base ?? []).join(" ") };
|
|
29
|
+
for (const [slot, classes] of Object.entries(op.element.style.slots ?? {})) selectors[slot] = classes.join(" ");
|
|
30
|
+
existing.definition.styleSelectors = selectors;
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
...empty(),
|
|
34
|
+
updated: 1,
|
|
35
|
+
staleResources: [pageUri(env, op.pageRef)],
|
|
36
|
+
elementRefs: [op.element.ref]
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
let parent = page;
|
|
40
|
+
let index;
|
|
41
|
+
if (op.parentRef) {
|
|
42
|
+
const anchor = resolveRef(space.schema, page, op.parentRef);
|
|
43
|
+
if (!anchor) return fail("parentRef", `Parent "${op.parentRef}" not found in page "${op.pageRef}"`, "Use an existing ref");
|
|
44
|
+
if (op.position === "before" || op.position === "after") {
|
|
45
|
+
parent = anchor.definition.parentId ? space.schema.flat[anchor.definition.parentId] : page;
|
|
46
|
+
const at = (parent.definition.items ?? []).indexOf(anchor.id);
|
|
47
|
+
index = at < 0 ? void 0 : op.position === "after" ? at + 1 : at;
|
|
48
|
+
} else parent = anchor;
|
|
49
|
+
}
|
|
50
|
+
createElement(space, page, op.element, parent, index);
|
|
51
|
+
return {
|
|
52
|
+
...empty(),
|
|
53
|
+
created: 1,
|
|
54
|
+
staleResources: [pageUri(env, op.pageRef)],
|
|
55
|
+
elementRefs: [op.element.ref]
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
//#endregion
|
|
59
|
+
export { upsertElement, upsertElementOp };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { findFolderByRef, pageFoldersOf, slugify, sortFolders } from "../../../helpers/space.js";
|
|
2
|
+
import { empty, fail } from "../../../helpers/opResult.js";
|
|
3
|
+
import { folderUri, foldersUri } from "./write.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/modules/mcp/tools/operations/schema/upsertFolder.ts
|
|
6
|
+
var upsertFolderOp = z.object({
|
|
7
|
+
type: z.literal("upsertFolder"),
|
|
8
|
+
ref: z.string().describe("Folder ref: an existing folder id/name/slug to update, or a new id you choose"),
|
|
9
|
+
name: z.string().optional(),
|
|
10
|
+
slug: z.string().optional(),
|
|
11
|
+
parentId: z.string().nullable().optional().describe("Ref of the parent folder for nesting; null keeps it at root")
|
|
12
|
+
}).describe("Create a sidebar page-folder, or update it when ref already exists. Nest it under another via parentId.");
|
|
13
|
+
var upsertFolder = (space, env, op) => {
|
|
14
|
+
const folders = pageFoldersOf(space.schema);
|
|
15
|
+
let parentId;
|
|
16
|
+
if (op.parentId !== void 0 && op.parentId !== null) {
|
|
17
|
+
const parent = findFolderByRef(space.schema, op.parentId);
|
|
18
|
+
if (!parent) return fail("parentId", `Parent folder "${op.parentId}" not found`, "Create it with upsertFolder first");
|
|
19
|
+
parentId = parent.id;
|
|
20
|
+
}
|
|
21
|
+
const existing = findFolderByRef(space.schema, op.ref);
|
|
22
|
+
if (existing) {
|
|
23
|
+
if (op.name !== void 0) existing.name = op.name;
|
|
24
|
+
if (op.slug !== void 0) existing.slug = op.slug;
|
|
25
|
+
if (op.parentId === null) Reflect.deleteProperty(existing, "parentId");
|
|
26
|
+
else if (op.parentId !== void 0) existing.parentId = parentId;
|
|
27
|
+
space.schema.pageFolders = sortFolders(folders);
|
|
28
|
+
return {
|
|
29
|
+
...empty(),
|
|
30
|
+
updated: 1,
|
|
31
|
+
staleResources: [folderUri(env, existing.id), foldersUri(env)]
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const folder = {
|
|
35
|
+
id: op.ref,
|
|
36
|
+
name: op.name ?? op.ref,
|
|
37
|
+
slug: op.slug ?? slugify(op.ref)
|
|
38
|
+
};
|
|
39
|
+
if (parentId !== void 0) folder.parentId = parentId;
|
|
40
|
+
folders.push(folder);
|
|
41
|
+
space.schema.pageFolders = sortFolders(folders);
|
|
42
|
+
return {
|
|
43
|
+
...empty(),
|
|
44
|
+
created: 1,
|
|
45
|
+
staleResources: [folderUri(env, folder.id), foldersUri(env)]
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { upsertFolder, upsertFolderOp };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { findFolderByRef, findPageByRef, generateObjectId } from "../../../helpers/space.js";
|
|
2
|
+
import { empty, fail } from "../../../helpers/opResult.js";
|
|
3
|
+
import { pageUri, pagesUri } from "./write.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/modules/mcp/tools/operations/schema/upsertPage.ts
|
|
6
|
+
var upsertPageOp = z.object({
|
|
7
|
+
type: z.literal("upsertPage"),
|
|
8
|
+
ref: z.string().describe("Page id/slug to update, or a new id you choose to create one"),
|
|
9
|
+
label: z.string().optional(),
|
|
10
|
+
slug: z.string().optional(),
|
|
11
|
+
folder: z.string().nullable().optional().describe("Ref of an existing folder to place this page in; \"\" or null moves it to the root. Unknown → error"),
|
|
12
|
+
default: z.boolean().optional()
|
|
13
|
+
}).describe("Create a page, or update it when ref already exists (only the fields you pass change).");
|
|
14
|
+
var upsertPage = (space, env, op) => {
|
|
15
|
+
let folderValue;
|
|
16
|
+
if (op.folder !== void 0) if (op.folder === null || op.folder === "") folderValue = "";
|
|
17
|
+
else {
|
|
18
|
+
const resolved = findFolderByRef(space.schema, op.folder);
|
|
19
|
+
if (!resolved) return fail("folder", `Folder "${op.folder}" not found`, "Create it with upsertFolder, or read plitzi://folders");
|
|
20
|
+
folderValue = resolved.id;
|
|
21
|
+
}
|
|
22
|
+
const existing = findPageByRef(space.schema, op.ref);
|
|
23
|
+
if (existing) {
|
|
24
|
+
existing.attributes = {
|
|
25
|
+
...existing.attributes,
|
|
26
|
+
...op.slug !== void 0 ? { slug: op.slug } : {},
|
|
27
|
+
...op.label !== void 0 ? { name: op.label } : {},
|
|
28
|
+
...op.default !== void 0 ? { default: op.default } : {},
|
|
29
|
+
...folderValue !== void 0 ? { folder: folderValue } : {}
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
...empty(),
|
|
33
|
+
updated: 1,
|
|
34
|
+
staleResources: [pageUri(env, op.ref), pagesUri(env)]
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const id = generateObjectId();
|
|
38
|
+
const attributes = {
|
|
39
|
+
slug: op.slug ?? "",
|
|
40
|
+
name: op.label ?? op.ref,
|
|
41
|
+
default: op.default ?? false,
|
|
42
|
+
folder: folderValue ?? ""
|
|
43
|
+
};
|
|
44
|
+
space.schema.flat[id] = {
|
|
45
|
+
id,
|
|
46
|
+
attributes,
|
|
47
|
+
definition: {
|
|
48
|
+
rootId: id,
|
|
49
|
+
label: op.label ?? op.ref,
|
|
50
|
+
type: "page",
|
|
51
|
+
items: [],
|
|
52
|
+
styleSelectors: { base: "" },
|
|
53
|
+
aiRef: op.ref
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
space.schema.pages.push(id);
|
|
57
|
+
return {
|
|
58
|
+
...empty(),
|
|
59
|
+
created: 1,
|
|
60
|
+
staleResources: [pageUri(env, op.ref), pagesUri(env)]
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
export { upsertPage, upsertPageOp };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { empty } from "../../../helpers/opResult.js";
|
|
2
|
+
import { schemaVarsUri } from "./write.js";
|
|
3
|
+
import { scalar } from "./shared.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/modules/mcp/tools/operations/schema/upsertVariable.ts
|
|
6
|
+
var upsertVariableOp = z.object({
|
|
7
|
+
type: z.literal("upsertVariable"),
|
|
8
|
+
name: z.string().describe("Variable name; referenced in content as {{name}}"),
|
|
9
|
+
variableType: z.string().describe("Runtime type (text|number|...); NOT the `type` discriminator"),
|
|
10
|
+
value: scalar,
|
|
11
|
+
category: z.string().optional(),
|
|
12
|
+
subValues: z.array(z.object({
|
|
13
|
+
when: z.unknown(),
|
|
14
|
+
value: scalar
|
|
15
|
+
})).optional()
|
|
16
|
+
}).describe("Create or update a space-level schema variable (a {{name}} value shared across the space).");
|
|
17
|
+
var upsertVariable = (space, env, op) => {
|
|
18
|
+
const variable = {
|
|
19
|
+
name: op.name,
|
|
20
|
+
category: op.category ?? "general",
|
|
21
|
+
type: op.variableType,
|
|
22
|
+
value: op.value,
|
|
23
|
+
subValues: op.subValues ?? []
|
|
24
|
+
};
|
|
25
|
+
const idx = space.schema.variables.findIndex((v) => v.name === op.name);
|
|
26
|
+
if (idx >= 0) {
|
|
27
|
+
space.schema.variables[idx] = variable;
|
|
28
|
+
return {
|
|
29
|
+
...empty(),
|
|
30
|
+
updated: 1,
|
|
31
|
+
staleResources: [schemaVarsUri(env)]
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
space.schema.variables.push(variable);
|
|
35
|
+
return {
|
|
36
|
+
...empty(),
|
|
37
|
+
created: 1,
|
|
38
|
+
staleResources: [schemaVarsUri(env)]
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { upsertVariable, upsertVariableOp };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { generateObjectId } from "../../../helpers/space.js";
|
|
2
|
+
//#region src/modules/mcp/tools/operations/schema/write.ts
|
|
3
|
+
var pageUri = (env, ref) => `plitzi://schema/${env}/pages/${ref}`;
|
|
4
|
+
var pagesUri = (env) => `plitzi://schema/${env}/pages`;
|
|
5
|
+
var foldersUri = (env) => `plitzi://folders/${env}`;
|
|
6
|
+
var folderUri = (env, ref) => `plitzi://folders/${env}/${ref}`;
|
|
7
|
+
var schemaVarsUri = (env) => `plitzi://schema-variables/${env}`;
|
|
8
|
+
var removeFromParent = (space, childId) => {
|
|
9
|
+
for (const el of Object.values(space.schema.flat)) if (el.definition.items?.includes(childId)) el.definition.items = el.definition.items.filter((id) => id !== childId);
|
|
10
|
+
};
|
|
11
|
+
var placeChild = (parent, childId, index) => {
|
|
12
|
+
const items = parent.definition.items ?? (parent.definition.items = []);
|
|
13
|
+
if (index === void 0 || index < 0 || index >= items.length) items.push(childId);
|
|
14
|
+
else items.splice(index, 0, childId);
|
|
15
|
+
};
|
|
16
|
+
var createElement = (space, page, input, parent, index) => {
|
|
17
|
+
const id = generateObjectId();
|
|
18
|
+
const { subType, ...props } = {
|
|
19
|
+
subType: input.subType,
|
|
20
|
+
...input.props
|
|
21
|
+
};
|
|
22
|
+
const styleSelectors = { base: (input.style?.base ?? []).join(" ") };
|
|
23
|
+
for (const [slot, classes] of Object.entries(input.style?.slots ?? {})) styleSelectors[slot] = classes.join(" ");
|
|
24
|
+
space.schema.flat[id] = {
|
|
25
|
+
id,
|
|
26
|
+
attributes: subType === void 0 ? props : {
|
|
27
|
+
subType,
|
|
28
|
+
...props
|
|
29
|
+
},
|
|
30
|
+
definition: {
|
|
31
|
+
rootId: page.id,
|
|
32
|
+
parentId: parent.id,
|
|
33
|
+
label: input.label ?? input.ref,
|
|
34
|
+
type: input.type,
|
|
35
|
+
items: [],
|
|
36
|
+
styleSelectors,
|
|
37
|
+
aiRef: input.ref
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
placeChild(parent, id, index);
|
|
41
|
+
for (const child of input.children ?? []) createElement(space, page, child, space.schema.flat[id], void 0);
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { createElement, folderUri, foldersUri, pageUri, pagesUri, placeChild, removeFromParent, schemaVarsUri };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import styleConstants from "@plitzi/sdk-shared/style/styleConstants";
|
|
2
|
+
//#region src/modules/mcp/tools/operations/style/cssCatalog.ts
|
|
3
|
+
/** Every kebab-case CSS property Plitzi's style engine understands. Values written to a definition
|
|
4
|
+
* must use these exact keys — camelCase or unknown keys are rejected by the validator. */
|
|
5
|
+
var cssProperties = Array.from(new Set(Object.values(styleConstants))).sort();
|
|
6
|
+
var cssPropertySet = new Set(cssProperties);
|
|
7
|
+
var isCssProperty = (key) => cssPropertySet.has(key);
|
|
8
|
+
var toKebab = (key) => key.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
9
|
+
/** If a camelCase key maps to a known kebab-case property, return it — used to teach the agent the correct key. */
|
|
10
|
+
var suggestCssProperty = (key) => {
|
|
11
|
+
const kebab = toKebab(key);
|
|
12
|
+
return cssPropertySet.has(kebab) ? kebab : void 0;
|
|
13
|
+
};
|
|
14
|
+
var splitTokens = (value) => {
|
|
15
|
+
const tokens = [];
|
|
16
|
+
let depth = 0;
|
|
17
|
+
let current = "";
|
|
18
|
+
for (const ch of value.trim()) {
|
|
19
|
+
if (ch === "(") depth += 1;
|
|
20
|
+
else if (ch === ")") depth = Math.max(0, depth - 1);
|
|
21
|
+
if (/\s/.test(ch) && depth === 0) {
|
|
22
|
+
if (current) {
|
|
23
|
+
tokens.push(current);
|
|
24
|
+
current = "";
|
|
25
|
+
}
|
|
26
|
+
} else current += ch;
|
|
27
|
+
}
|
|
28
|
+
if (current) tokens.push(current);
|
|
29
|
+
return tokens;
|
|
30
|
+
};
|
|
31
|
+
var SIDES = [
|
|
32
|
+
"top",
|
|
33
|
+
"right",
|
|
34
|
+
"bottom",
|
|
35
|
+
"left"
|
|
36
|
+
];
|
|
37
|
+
var box4 = (tokens) => {
|
|
38
|
+
const [a, b = a, c = a, d = b] = tokens;
|
|
39
|
+
return [
|
|
40
|
+
a,
|
|
41
|
+
b,
|
|
42
|
+
c,
|
|
43
|
+
d
|
|
44
|
+
];
|
|
45
|
+
};
|
|
46
|
+
var radius4 = (tokens) => {
|
|
47
|
+
const [a, b = a, c = a, d = b] = tokens;
|
|
48
|
+
return [
|
|
49
|
+
a,
|
|
50
|
+
b,
|
|
51
|
+
c,
|
|
52
|
+
d
|
|
53
|
+
];
|
|
54
|
+
};
|
|
55
|
+
var BORDER_STYLES = /* @__PURE__ */ new Set([
|
|
56
|
+
"none",
|
|
57
|
+
"hidden",
|
|
58
|
+
"dotted",
|
|
59
|
+
"dashed",
|
|
60
|
+
"solid",
|
|
61
|
+
"double",
|
|
62
|
+
"groove",
|
|
63
|
+
"ridge",
|
|
64
|
+
"inset",
|
|
65
|
+
"outset"
|
|
66
|
+
]);
|
|
67
|
+
var BORDER_WIDTH_KEYWORDS = /* @__PURE__ */ new Set([
|
|
68
|
+
"thin",
|
|
69
|
+
"medium",
|
|
70
|
+
"thick"
|
|
71
|
+
]);
|
|
72
|
+
var LENGTH_RE = /^-?[\d.]+([a-z%]*)$/;
|
|
73
|
+
var classifyBorderToken = (token) => {
|
|
74
|
+
if (BORDER_STYLES.has(token)) return "style";
|
|
75
|
+
if (BORDER_WIDTH_KEYWORDS.has(token) || LENGTH_RE.test(token)) return "width";
|
|
76
|
+
return "color";
|
|
77
|
+
};
|
|
78
|
+
var expandBorder = (key, value, out) => {
|
|
79
|
+
const sides = key === "border" ? SIDES : [key.slice(7)];
|
|
80
|
+
for (const token of splitTokens(value)) {
|
|
81
|
+
const kind = classifyBorderToken(token);
|
|
82
|
+
for (const side of sides) out[`border-${side}-${kind}`] = token;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var BORDER_SIDE_KEYS = new Set(SIDES.map((s) => `border-${s}`));
|
|
86
|
+
var expandOne = (key, raw, out) => {
|
|
87
|
+
const value = String(raw);
|
|
88
|
+
if (key === "padding" || key === "margin" || key === "inset") {
|
|
89
|
+
const [t, r, b, l] = box4(splitTokens(value));
|
|
90
|
+
const prefix = key === "inset" ? "" : `${key}-`;
|
|
91
|
+
out[`${prefix}top`] = t;
|
|
92
|
+
out[`${prefix}right`] = r;
|
|
93
|
+
out[`${prefix}bottom`] = b;
|
|
94
|
+
out[`${prefix}left`] = l;
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
if (key === "border-radius" && !value.includes("/")) {
|
|
98
|
+
const [tl, tr, br, bl] = radius4(splitTokens(value));
|
|
99
|
+
const corners = [
|
|
100
|
+
["top-left", tl],
|
|
101
|
+
["top-right", tr],
|
|
102
|
+
["bottom-right", br],
|
|
103
|
+
["bottom-left", bl]
|
|
104
|
+
];
|
|
105
|
+
for (const [corner, v] of corners) out[`border-${corner}-radius`] = v;
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
if (key === "gap") {
|
|
109
|
+
const [row, col = row] = splitTokens(value);
|
|
110
|
+
out["row-gap"] = row;
|
|
111
|
+
out["column-gap"] = col;
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
if (key === "border" || BORDER_SIDE_KEYS.has(key)) {
|
|
115
|
+
expandBorder(key, value, out);
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
return false;
|
|
119
|
+
};
|
|
120
|
+
/** Expand supported CSS shorthands to their longhand keys. Explicit longhands in the same map win over any
|
|
121
|
+
* expansion (so `{ padding: 8, padding-left: 0 }` keeps padding-left: 0). Unrecognized keys pass through. */
|
|
122
|
+
var expandShorthand = (css) => {
|
|
123
|
+
const expanded = {};
|
|
124
|
+
const direct = {};
|
|
125
|
+
for (const [key, value] of Object.entries(css)) if (!expandOne(key, value, expanded)) direct[key] = value;
|
|
126
|
+
return {
|
|
127
|
+
...expanded,
|
|
128
|
+
...direct
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
//#endregion
|
|
132
|
+
export { cssProperties, expandShorthand, isCssProperty, suggestCssProperty };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { empty } from "../../../helpers/opResult.js";
|
|
2
|
+
import { MODES, defUri, defsUri, guardKind } from "./write.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/modules/mcp/tools/operations/style/deleteDefinition.ts
|
|
5
|
+
var deleteDefinitionOp = z.object({
|
|
6
|
+
type: z.literal("deleteDefinition"),
|
|
7
|
+
ref: z.string().describe("Class ref of the definition to delete")
|
|
8
|
+
}).describe("Delete a style class definition by ref (does not detach it from elements that still list it).");
|
|
9
|
+
var deleteDefinition = (space, env, op) => {
|
|
10
|
+
const guard = guardKind(space.style, op.ref, "class");
|
|
11
|
+
if (guard) return guard;
|
|
12
|
+
for (const mode of MODES) Reflect.deleteProperty(space.style.platform[mode], op.ref);
|
|
13
|
+
return {
|
|
14
|
+
...empty(),
|
|
15
|
+
deleted: 1,
|
|
16
|
+
staleResources: [defUri(env, op.ref), defsUri(env)]
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { deleteDefinition, deleteDefinitionOp };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { empty } from "../../../helpers/opResult.js";
|
|
2
|
+
import { MODES, globalUri, globalsUri, guardKind } from "./write.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/modules/mcp/tools/operations/style/deleteGlobalStyle.ts
|
|
5
|
+
var deleteGlobalStyleOp = z.object({
|
|
6
|
+
type: z.literal("deleteGlobalStyle"),
|
|
7
|
+
componentType: z.string().describe("Element type whose site-wide style to remove")
|
|
8
|
+
}).describe("Remove the site-wide style for an element type (elements of that type keep their own classes).");
|
|
9
|
+
var deleteGlobalStyle = (space, env, op) => {
|
|
10
|
+
const guard = guardKind(space.style, op.componentType, "element");
|
|
11
|
+
if (guard) return guard;
|
|
12
|
+
for (const mode of MODES) Reflect.deleteProperty(space.style.platform[mode], op.componentType);
|
|
13
|
+
return {
|
|
14
|
+
...empty(),
|
|
15
|
+
deleted: 1,
|
|
16
|
+
staleResources: [globalUri(env, op.componentType), globalsUri(env)]
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { deleteGlobalStyle, deleteGlobalStyleOp };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { empty } from "../../../helpers/opResult.js";
|
|
2
|
+
import { styleVarUri, styleVarsUri } from "./write.js";
|
|
3
|
+
import { styleCategory } from "./shared.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
//#region src/modules/mcp/tools/operations/style/deleteStyleVariable.ts
|
|
6
|
+
var deleteStyleVariableOp = z.object({
|
|
7
|
+
type: z.literal("deleteStyleVariable"),
|
|
8
|
+
category: styleCategory,
|
|
9
|
+
name: z.string().describe("Token name without the -- prefix")
|
|
10
|
+
}).describe("Delete a design token by category + name.");
|
|
11
|
+
var deleteStyleVariable = (space, env, op) => {
|
|
12
|
+
const group = space.style.variables[op.category];
|
|
13
|
+
if (group) Reflect.deleteProperty(group, op.name);
|
|
14
|
+
return {
|
|
15
|
+
...empty(),
|
|
16
|
+
deleted: 1,
|
|
17
|
+
staleResources: [styleVarUri(env, op.category), styleVarsUri(env)]
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { deleteStyleVariable, deleteStyleVariableOp };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { deleteDefinitionOp } from "./deleteDefinition.js";
|
|
2
|
+
import { deleteGlobalStyleOp } from "./deleteGlobalStyle.js";
|
|
3
|
+
import { deleteStyleVariableOp } from "./deleteStyleVariable.js";
|
|
4
|
+
import { patchDefinitionOp } from "./patchDefinition.js";
|
|
5
|
+
import { patchGlobalStyleOp } from "./patchGlobalStyle.js";
|
|
6
|
+
import { upsertDefinitionOp } from "./upsertDefinition.js";
|
|
7
|
+
import { upsertGlobalStyleOp } from "./upsertGlobalStyle.js";
|
|
8
|
+
import { upsertStyleVariableOp } from "./upsertStyleVariable.js";
|
|
9
|
+
//#region src/modules/mcp/tools/operations/style/operations.ts
|
|
10
|
+
var styleOps = {
|
|
11
|
+
upsertDefinition: upsertDefinitionOp,
|
|
12
|
+
patchDefinition: patchDefinitionOp,
|
|
13
|
+
deleteDefinition: deleteDefinitionOp,
|
|
14
|
+
upsertGlobalStyle: upsertGlobalStyleOp,
|
|
15
|
+
patchGlobalStyle: patchGlobalStyleOp,
|
|
16
|
+
deleteGlobalStyle: deleteGlobalStyleOp,
|
|
17
|
+
upsertStyleVariable: upsertStyleVariableOp,
|
|
18
|
+
deleteStyleVariable: deleteStyleVariableOp
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { styleOps };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { empty, fail } from "../../../helpers/opResult.js";
|
|
2
|
+
import { definitionToAI } from "./translator.js";
|
|
3
|
+
import { defUri, defsUri, guardKind, mergePatch, writeStyleItem } from "./write.js";
|
|
4
|
+
import { patchCssShape } from "./shared.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
//#region src/modules/mcp/tools/operations/style/patchDefinition.ts
|
|
7
|
+
var patchDefinitionOp = z.object({
|
|
8
|
+
type: z.literal("patchDefinition"),
|
|
9
|
+
ref: z.string().describe("Existing class ref to patch"),
|
|
10
|
+
...patchCssShape
|
|
11
|
+
}).describe("Partially update an existing style class: the CSS you pass is merged (a null value removes that property, others are kept). Never creates — use upsertDefinition for that.");
|
|
12
|
+
var patchDefinition = (space, env, op) => {
|
|
13
|
+
const guard = guardKind(space.style, op.ref, "class");
|
|
14
|
+
if (guard) return guard;
|
|
15
|
+
const existing = definitionToAI(space.style, op.ref);
|
|
16
|
+
if (!existing) return fail("ref", `Definition "${op.ref}" not found`, "patchDefinition only updates an existing definition; use upsertDefinition to create one");
|
|
17
|
+
const { type, ref, slots: slotsPatch, ...basePatch } = op;
|
|
18
|
+
const { base, slots } = mergePatch(existing, basePatch, slotsPatch);
|
|
19
|
+
writeStyleItem(space.style, ref, base, slots, "class", void 0);
|
|
20
|
+
return {
|
|
21
|
+
...empty(),
|
|
22
|
+
updated: 1,
|
|
23
|
+
staleResources: [defUri(env, ref), defsUri(env)]
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { patchDefinition, patchDefinitionOp };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { empty, fail } from "../../../helpers/opResult.js";
|
|
2
|
+
import { globalStyleToAI } from "./translator.js";
|
|
3
|
+
import { globalUri, globalsUri, guardKind, mergePatch, writeStyleItem } from "./write.js";
|
|
4
|
+
import { patchCssShape } from "./shared.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
//#region src/modules/mcp/tools/operations/style/patchGlobalStyle.ts
|
|
7
|
+
var patchGlobalStyleOp = z.object({
|
|
8
|
+
type: z.literal("patchGlobalStyle"),
|
|
9
|
+
componentType: z.string().describe("Element type whose global style to merge into; affects ALL of that type"),
|
|
10
|
+
...patchCssShape
|
|
11
|
+
}).describe("Partially update the site-wide style for an element type: CSS is merged (a null value removes a property). Never creates — use upsertGlobalStyle for that.");
|
|
12
|
+
var patchGlobalStyle = (space, env, op) => {
|
|
13
|
+
const guard = guardKind(space.style, op.componentType, "element");
|
|
14
|
+
if (guard) return guard;
|
|
15
|
+
const existing = globalStyleToAI(space.style, op.componentType);
|
|
16
|
+
if (!existing) return fail("componentType", `No global style for "${op.componentType}"`, "patchGlobalStyle only updates an existing global; use upsertGlobalStyle to create one");
|
|
17
|
+
const { type, componentType, slots: slotsPatch, ...basePatch } = op;
|
|
18
|
+
const { base, slots } = mergePatch(existing, basePatch, slotsPatch);
|
|
19
|
+
writeStyleItem(space.style, componentType, base, slots, "element", componentType);
|
|
20
|
+
return {
|
|
21
|
+
...empty(),
|
|
22
|
+
updated: 1,
|
|
23
|
+
staleResources: [globalUri(env, componentType), globalsUri(env)]
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { patchGlobalStyle, patchGlobalStyleOp };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//#region src/modules/mcp/tools/operations/style/shared.ts
|
|
3
|
+
var cssMap = z.record(z.string(), z.union([z.string(), z.number()])).describe("kebab-case CSS props; use var(--name) for tokens and {{name}} for schema vars");
|
|
4
|
+
var displayModeCss = z.object({
|
|
5
|
+
desktop: cssMap.optional(),
|
|
6
|
+
tablet: cssMap.optional(),
|
|
7
|
+
mobile: cssMap.optional()
|
|
8
|
+
});
|
|
9
|
+
var definitionSlot = displayModeCss.extend({
|
|
10
|
+
states: z.record(z.string(), displayModeCss).optional(),
|
|
11
|
+
variants: z.record(z.string(), displayModeCss).optional()
|
|
12
|
+
});
|
|
13
|
+
var cssPatchMap = z.record(z.string(), z.union([
|
|
14
|
+
z.string(),
|
|
15
|
+
z.number(),
|
|
16
|
+
z.null()
|
|
17
|
+
])).describe("kebab-case CSS props; a value of null removes the property, others are merged onto the existing CSS");
|
|
18
|
+
var displayModeCssPatch = z.object({
|
|
19
|
+
desktop: cssPatchMap.optional(),
|
|
20
|
+
tablet: cssPatchMap.optional(),
|
|
21
|
+
mobile: cssPatchMap.optional()
|
|
22
|
+
});
|
|
23
|
+
var definitionSlotPatch = displayModeCssPatch.extend({
|
|
24
|
+
states: z.record(z.string(), displayModeCssPatch).optional(),
|
|
25
|
+
variants: z.record(z.string(), displayModeCssPatch).optional()
|
|
26
|
+
});
|
|
27
|
+
var styleCategory = z.enum([
|
|
28
|
+
"color",
|
|
29
|
+
"spacing",
|
|
30
|
+
"shadow",
|
|
31
|
+
"custom"
|
|
32
|
+
]);
|
|
33
|
+
var themeValue = z.union([
|
|
34
|
+
z.string(),
|
|
35
|
+
z.number(),
|
|
36
|
+
z.object({
|
|
37
|
+
light: z.string().optional(),
|
|
38
|
+
dark: z.string().optional(),
|
|
39
|
+
default: z.string().optional()
|
|
40
|
+
})
|
|
41
|
+
]);
|
|
42
|
+
var upsertCssShape = {
|
|
43
|
+
desktop: cssMap.optional(),
|
|
44
|
+
tablet: cssMap.optional(),
|
|
45
|
+
mobile: cssMap.optional(),
|
|
46
|
+
states: z.record(z.string(), displayModeCss).optional(),
|
|
47
|
+
variants: z.record(z.string(), displayModeCss).optional(),
|
|
48
|
+
slots: z.record(z.string(), definitionSlot).optional()
|
|
49
|
+
};
|
|
50
|
+
var patchCssShape = {
|
|
51
|
+
desktop: cssPatchMap.optional(),
|
|
52
|
+
tablet: cssPatchMap.optional(),
|
|
53
|
+
mobile: cssPatchMap.optional(),
|
|
54
|
+
states: z.record(z.string(), displayModeCssPatch).optional(),
|
|
55
|
+
variants: z.record(z.string(), displayModeCssPatch).optional(),
|
|
56
|
+
slots: z.record(z.string(), definitionSlotPatch).optional()
|
|
57
|
+
};
|
|
58
|
+
//#endregion
|
|
59
|
+
export { displayModeCss, displayModeCssPatch, patchCssShape, styleCategory, themeValue, upsertCssShape };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
//#region src/modules/mcp/tools/operations/style/translator.ts
|
|
2
|
+
var DISPLAY_MODES = [
|
|
3
|
+
"desktop",
|
|
4
|
+
"tablet",
|
|
5
|
+
"mobile"
|
|
6
|
+
];
|
|
7
|
+
var isClassDefinition = (item) => item.type === "class";
|
|
8
|
+
var definitionRefs = (style) => {
|
|
9
|
+
const refs = /* @__PURE__ */ new Set();
|
|
10
|
+
for (const mode of DISPLAY_MODES) for (const [name, item] of Object.entries(style.platform[mode])) if (isClassDefinition(item)) refs.add(name);
|
|
11
|
+
return Array.from(refs).sort();
|
|
12
|
+
};
|
|
13
|
+
var fillSlot = (target, mode, block) => {
|
|
14
|
+
if (block.default && Object.keys(block.default).length > 0) target[mode] = block.default;
|
|
15
|
+
if (block.states) {
|
|
16
|
+
for (const [state, obj] of Object.entries(block.states)) if (Object.keys(obj).length > 0) {
|
|
17
|
+
(target.states ??= {})[state] ??= {};
|
|
18
|
+
target.states[state][mode] = obj;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (block.variants) {
|
|
22
|
+
for (const [name, variant] of Object.entries(block.variants)) if (variant.default && Object.keys(variant.default).length > 0) {
|
|
23
|
+
(target.variants ??= {})[name] ??= {};
|
|
24
|
+
target.variants[name][mode] = variant.default;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var projectItem = (style, ref, accept) => {
|
|
29
|
+
const def = { ref };
|
|
30
|
+
let found = false;
|
|
31
|
+
for (const mode of DISPLAY_MODES) {
|
|
32
|
+
const item = style.platform[mode][ref];
|
|
33
|
+
if (!item || !accept(item)) continue;
|
|
34
|
+
found = true;
|
|
35
|
+
for (const [slot, block] of Object.entries(item.attributes)) if (slot === "base") fillSlot(def, mode, block);
|
|
36
|
+
else fillSlot((def.slots ??= {})[slot] ??= {}, mode, block);
|
|
37
|
+
}
|
|
38
|
+
return found ? def : void 0;
|
|
39
|
+
};
|
|
40
|
+
var definitionToAI = (style, ref) => projectItem(style, ref, isClassDefinition);
|
|
41
|
+
var globalStylesForType = (style, componentType) => {
|
|
42
|
+
const isGlobal = (item) => item.type === "element" && item.componentType === componentType;
|
|
43
|
+
const refs = /* @__PURE__ */ new Set();
|
|
44
|
+
for (const mode of DISPLAY_MODES) for (const [name, item] of Object.entries(style.platform[mode])) if (isGlobal(item)) refs.add(name);
|
|
45
|
+
const globals = [];
|
|
46
|
+
for (const ref of Array.from(refs).sort()) {
|
|
47
|
+
const def = projectItem(style, ref, isGlobal);
|
|
48
|
+
if (def) globals.push({
|
|
49
|
+
...def,
|
|
50
|
+
appliesToType: componentType
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return globals;
|
|
54
|
+
};
|
|
55
|
+
var globalStyleToAI = (style, componentType) => {
|
|
56
|
+
const def = projectItem(style, componentType, (item) => item.type === "element" && item.componentType === componentType);
|
|
57
|
+
return def ? {
|
|
58
|
+
...def,
|
|
59
|
+
appliesToType: componentType
|
|
60
|
+
} : void 0;
|
|
61
|
+
};
|
|
62
|
+
var globalStyleTypes = (style) => {
|
|
63
|
+
const types = /* @__PURE__ */ new Set();
|
|
64
|
+
for (const mode of DISPLAY_MODES) for (const item of Object.values(style.platform[mode])) if (item.type === "element" && item.componentType) types.add(item.componentType);
|
|
65
|
+
return Array.from(types).sort();
|
|
66
|
+
};
|
|
67
|
+
var styleVariablesToAI = (style) => {
|
|
68
|
+
const data = {};
|
|
69
|
+
for (const [category, group] of Object.entries(style.variables)) data[category] = Object.entries(group).map(([name, value]) => ({
|
|
70
|
+
name,
|
|
71
|
+
reference: `var(--${name})`,
|
|
72
|
+
value
|
|
73
|
+
}));
|
|
74
|
+
return data;
|
|
75
|
+
};
|
|
76
|
+
//#endregion
|
|
77
|
+
export { definitionRefs, definitionToAI, globalStyleToAI, globalStyleTypes, globalStylesForType, isClassDefinition, styleVariablesToAI };
|