meno-core 1.0.53 → 1.1.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/.claude/settings.local.json +1 -3
- package/bin/cli.ts +66 -261
- package/build-astro.ts +150 -128
- package/dist/bin/cli.js +42 -185
- package/dist/bin/cli.js.map +2 -2
- package/dist/chunks/chunk-2AR55GYH.js +42 -0
- package/dist/chunks/chunk-2AR55GYH.js.map +7 -0
- package/dist/chunks/{chunk-JGWFTO6P.js → chunk-2IIQK7T3.js} +2624 -1389
- package/dist/chunks/chunk-2IIQK7T3.js.map +7 -0
- package/dist/chunks/chunk-4ZRU52J2.js +169 -0
- package/dist/chunks/chunk-4ZRU52J2.js.map +7 -0
- package/dist/chunks/{chunk-UB44F4Z2.js → chunk-5X4HCN7J.js} +5 -7
- package/dist/chunks/chunk-5X4HCN7J.js.map +7 -0
- package/dist/chunks/{chunk-WQFG7PAH.js → chunk-7CCVOL5M.js} +15 -19
- package/dist/chunks/chunk-7CCVOL5M.js.map +7 -0
- package/dist/chunks/{chunk-YBLHKYFF.js → chunk-AR7LHIFY.js} +8 -2
- package/dist/chunks/chunk-AR7LHIFY.js.map +7 -0
- package/dist/chunks/{chunk-O3NAGJP4.js → chunk-NUP7H7D3.js} +135 -41
- package/dist/chunks/chunk-NUP7H7D3.js.map +7 -0
- package/dist/chunks/{chunk-X754AHS5.js → chunk-QWTQZHG3.js} +194 -90
- package/dist/chunks/chunk-QWTQZHG3.js.map +7 -0
- package/dist/chunks/{chunk-H3GJ4H2U.js → chunk-XTKNX4FW.js} +216 -87
- package/dist/chunks/chunk-XTKNX4FW.js.map +7 -0
- package/dist/chunks/{fs-JGINUXGL.js → fs-G3ANWEFP.js} +2 -2
- package/dist/lib/client/index.js +1003 -475
- package/dist/lib/client/index.js.map +3 -3
- package/dist/lib/server/index.js +14393 -6371
- package/dist/lib/server/index.js.map +4 -4
- package/dist/lib/shared/index.js +342 -101
- package/dist/lib/shared/index.js.map +4 -4
- package/dist/lib/shared/richtext/index.js +1 -1
- package/dist/lib/test-utils/index.js +64 -80
- package/dist/lib/test-utils/index.js.map +2 -2
- package/entries/client-router.tsx +10 -8
- package/lib/client/ClientInitializer.ts +8 -8
- package/lib/client/ErrorBoundary.test.tsx +246 -186
- package/lib/client/ErrorBoundary.tsx +183 -132
- package/lib/client/componentRegistry.test.ts +96 -108
- package/lib/client/componentRegistry.ts +1 -3
- package/lib/client/contexts/ThemeContext.tsx +3 -2
- package/lib/client/core/ComponentBuilder.test.ts +663 -560
- package/lib/client/core/ComponentBuilder.ts +427 -155
- package/lib/client/core/ComponentRenderer.test.tsx +2 -4
- package/lib/client/core/ComponentRenderer.tsx +46 -33
- package/lib/client/core/builders/embedBuilder.ts +242 -54
- package/lib/client/core/builders/linkBuilder.ts +72 -45
- package/lib/client/core/builders/linkNodeBuilder.ts +79 -54
- package/lib/client/core/builders/listBuilder.ts +155 -89
- package/lib/client/core/builders/localeListBuilder.ts +97 -62
- package/lib/client/core/builders/types.ts +5 -5
- package/lib/client/core/cmsTemplateProcessor.ts +8 -9
- package/lib/client/elementRegistry.ts +3 -3
- package/lib/client/fontFamiliesService.test.ts +2 -10
- package/lib/client/fontFamiliesService.ts +3 -3
- package/lib/client/hmr/HMRManager.tsx +47 -30
- package/lib/client/hmrCssReload.ts +49 -14
- package/lib/client/hmrWebSocket.ts +14 -19
- package/lib/client/hooks/useColorVariables.test.ts +21 -21
- package/lib/client/hooks/useColorVariables.ts +23 -18
- package/lib/client/hooks/usePropertyAutocomplete.ts +4 -6
- package/lib/client/hooks/useVariables.ts +6 -4
- package/lib/client/hydration/HydrationUtils.test.ts +24 -25
- package/lib/client/hydration/HydrationUtils.ts +3 -4
- package/lib/client/i18nConfigService.test.ts +2 -7
- package/lib/client/i18nConfigService.ts +2 -2
- package/lib/client/meno-filter/MenoFilter.test.ts +47 -49
- package/lib/client/meno-filter/MenoFilter.ts +14 -15
- package/lib/client/meno-filter/bindings.ts +18 -43
- package/lib/client/meno-filter/init.ts +4 -4
- package/lib/client/meno-filter/renderer.ts +30 -32
- package/lib/client/meno-filter/script.generated.ts +1 -3
- package/lib/client/meno-filter/ui.ts +4 -6
- package/lib/client/meno-filter/updates.ts +18 -23
- package/lib/client/meno-filter/utils.ts +1 -1
- package/lib/client/navigation.test.ts +174 -178
- package/lib/client/navigation.ts +0 -1
- package/lib/client/responsiveStyleResolver.knownTokens.test.ts +71 -0
- package/lib/client/responsiveStyleResolver.test.ts +234 -232
- package/lib/client/responsiveStyleResolver.ts +74 -20
- package/lib/client/routing/RouteLoader.test.ts +24 -25
- package/lib/client/routing/RouteLoader.ts +27 -35
- package/lib/client/routing/Router.tsx +210 -153
- package/lib/client/scripts/ScriptExecutor.test.ts +157 -158
- package/lib/client/scripts/ScriptExecutor.ts +18 -36
- package/lib/client/services/PrefetchService.test.ts +3 -3
- package/lib/client/services/PrefetchService.ts +23 -29
- package/lib/client/styleProcessor.test.ts +9 -9
- package/lib/client/styleProcessor.ts +24 -15
- package/lib/client/styles/StyleInjector.test.ts +122 -115
- package/lib/client/styles/StyleInjector.ts +10 -7
- package/lib/client/styles/UtilityClassCollector.ts +62 -28
- package/lib/client/styles/cspNonce.test.ts +2 -5
- package/lib/client/templateEngine.test.ts +554 -488
- package/lib/client/templateEngine.ts +203 -73
- package/lib/client/theme.test.ts +1 -1
- package/lib/client/theme.ts +0 -1
- package/lib/client/utils/toast.ts +0 -1
- package/lib/server/__integration__/api-routes.test.ts +8 -4
- package/lib/server/__integration__/cms-integration.test.ts +1 -4
- package/lib/server/__integration__/server-lifecycle.test.ts +4 -5
- package/lib/server/__integration__/ssr-rendering.test.ts +47 -37
- package/lib/server/__integration__/static-assets.test.ts +3 -3
- package/lib/server/__integration__/test-helpers.ts +87 -74
- package/lib/server/ab/generateFunctions.ts +12 -10
- package/lib/server/astro/cmsPageEmitter.ts +26 -42
- package/lib/server/astro/componentEmitter.ts +35 -43
- package/lib/server/astro/cssCollector.ts +10 -26
- package/lib/server/astro/nodeToAstro.test.ts +1754 -34
- package/lib/server/astro/nodeToAstro.ts +232 -216
- package/lib/server/astro/normalizeOrphanTemplateProps.test.ts +115 -119
- package/lib/server/astro/normalizeOrphanTemplateProps.ts +11 -18
- package/lib/server/astro/pageEmitter.ts +9 -13
- package/lib/server/astro/tailwindMapper.test.ts +10 -37
- package/lib/server/astro/tailwindMapper.ts +33 -40
- package/lib/server/astro/templateTransformer.ts +17 -20
- package/lib/server/createServer.ts +7 -19
- package/lib/server/cssGenerator.test.ts +35 -44
- package/lib/server/cssGenerator.ts +8 -19
- package/lib/server/fileWatcher.test.ts +164 -13
- package/lib/server/fileWatcher.ts +209 -124
- package/lib/server/index.ts +14 -17
- package/lib/server/jsonLoader.test.ts +39 -2
- package/lib/server/jsonLoader.ts +39 -34
- package/lib/server/middleware/cors.test.ts +21 -21
- package/lib/server/middleware/cors.ts +28 -4
- package/lib/server/middleware/errorHandler.test.ts +7 -5
- package/lib/server/middleware/errorHandler.ts +3 -8
- package/lib/server/middleware/index.ts +0 -1
- package/lib/server/middleware/logger.test.ts +10 -8
- package/lib/server/middleware/logger.ts +17 -29
- package/lib/server/migrateTemplates.ts +3 -3
- package/lib/server/pageCache.test.ts +76 -77
- package/lib/server/pageCache.ts +0 -1
- package/lib/server/projectContext.ts +5 -4
- package/lib/server/providers/fileSystemCMSProvider.test.ts +142 -99
- package/lib/server/providers/fileSystemCMSProvider.ts +62 -38
- package/lib/server/routes/api/cms.test.ts +26 -14
- package/lib/server/routes/api/cms.ts +9 -14
- package/lib/server/routes/api/colors.test.ts +2 -2
- package/lib/server/routes/api/components.ts +31 -35
- package/lib/server/routes/api/config.ts +3 -4
- package/lib/server/routes/api/core-routes.ts +49 -76
- package/lib/server/routes/api/enums.test.ts +2 -2
- package/lib/server/routes/api/functions.ts +9 -17
- package/lib/server/routes/api/index.ts +3 -6
- package/lib/server/routes/api/pages.ts +8 -11
- package/lib/server/routes/api/shared.test.ts +1 -1
- package/lib/server/routes/api/shared.ts +12 -9
- package/lib/server/routes/api/variables.test.ts +3 -5
- package/lib/server/routes/api/variables.ts +1 -1
- package/lib/server/routes/index.ts +25 -28
- package/lib/server/routes/pages.ts +35 -31
- package/lib/server/routes/static.ts +17 -6
- package/lib/server/runtime/bundler.ts +98 -61
- package/lib/server/runtime/fs.ts +16 -26
- package/lib/server/runtime/httpServer.ts +8 -12
- package/lib/server/services/ColorService.test.ts +3 -3
- package/lib/server/services/ColorService.ts +37 -29
- package/lib/server/services/EnumService.test.ts +4 -8
- package/lib/server/services/EnumService.ts +11 -3
- package/lib/server/services/VariableService.test.ts +8 -12
- package/lib/server/services/VariableService.ts +11 -3
- package/lib/server/services/cmsService.test.ts +158 -120
- package/lib/server/services/cmsService.ts +36 -146
- package/lib/server/services/componentService.test.ts +125 -45
- package/lib/server/services/componentService.ts +70 -46
- package/lib/server/services/configService.test.ts +22 -45
- package/lib/server/services/configService.ts +50 -27
- package/lib/server/services/fileWatcherService.ts +42 -8
- package/lib/server/services/index.ts +0 -1
- package/lib/server/services/pageService.test.ts +8 -10
- package/lib/server/services/pageService.ts +32 -18
- package/lib/server/ssr/attributeBuilder.ts +18 -8
- package/lib/server/ssr/buildErrorOverlay.ts +11 -12
- package/lib/server/ssr/clientDataInjector.ts +7 -21
- package/lib/server/ssr/cmsSSRProcessor.ts +4 -8
- package/lib/server/ssr/cssCollector.ts +1 -1
- package/lib/server/ssr/errorOverlay.test.ts +1 -1
- package/lib/server/ssr/errorOverlay.ts +3 -9
- package/lib/server/ssr/htmlGenerator.nonce.test.ts +9 -14
- package/lib/server/ssr/htmlGenerator.test.ts +120 -44
- package/lib/server/ssr/htmlGenerator.ts +126 -91
- package/lib/server/ssr/imageMetadata.test.ts +3 -1
- package/lib/server/ssr/imageMetadata.ts +27 -21
- package/lib/server/ssr/jsCollector.test.ts +8 -18
- package/lib/server/ssr/jsCollector.ts +3 -8
- package/lib/server/ssr/liveReloadIntegration.test.ts +76 -36
- package/lib/server/ssr/metaTagGenerator.ts +2 -2
- package/lib/server/ssr/ssrRenderer.branches.test.ts +1103 -0
- package/lib/server/ssr/ssrRenderer.test.ts +316 -256
- package/lib/server/ssr/ssrRenderer.ts +795 -243
- package/lib/server/ssrRenderer.test.ts +1048 -954
- package/lib/server/utils/jsonLineMapper.test.ts +28 -28
- package/lib/server/utils/jsonLineMapper.ts +7 -7
- package/lib/server/validateStyleCoverage.ts +18 -21
- package/lib/server/websocketManager.ts +28 -19
- package/lib/shared/attributeNodeUtils.test.ts +15 -15
- package/lib/shared/attributeNodeUtils.ts +5 -12
- package/lib/shared/breakpoints.test.ts +5 -5
- package/lib/shared/breakpoints.ts +4 -11
- package/lib/shared/cmsQuery.test.ts +81 -0
- package/lib/shared/cmsQuery.ts +92 -0
- package/lib/shared/cmsQueryParser.test.ts +50 -42
- package/lib/shared/cmsQueryParser.ts +60 -38
- package/lib/shared/colorConversions.ts +9 -9
- package/lib/shared/colorVariableUtils.test.ts +27 -5
- package/lib/shared/colorVariableUtils.ts +21 -12
- package/lib/shared/componentRefs.ts +1 -5
- package/lib/shared/constants.test.ts +3 -3
- package/lib/shared/constants.ts +8 -8
- package/lib/shared/cssGeneration.test.ts +285 -144
- package/lib/shared/cssGeneration.ts +217 -531
- package/lib/shared/cssNamedColors.ts +152 -30
- package/lib/shared/cssProperties.test.ts +69 -70
- package/lib/shared/cssProperties.ts +298 -114
- package/lib/shared/elementClassName.test.ts +109 -109
- package/lib/shared/elementClassName.ts +3 -3
- package/lib/shared/elementUtils.ts +12 -16
- package/lib/shared/errorLogger.test.ts +12 -12
- package/lib/shared/errorLogger.ts +2 -10
- package/lib/shared/errors.test.ts +2 -13
- package/lib/shared/errors.ts +2 -8
- package/lib/shared/expressionEvaluator.test.ts +145 -0
- package/lib/shared/expressionEvaluator.ts +52 -24
- package/lib/shared/fontLoader.test.ts +32 -18
- package/lib/shared/fontLoader.ts +2 -2
- package/lib/shared/friendlyError.ts +2 -3
- package/lib/shared/gradientUtils.test.ts +3 -7
- package/lib/shared/gradientUtils.ts +17 -14
- package/lib/shared/hrefRefs.test.ts +2 -2
- package/lib/shared/hrefRefs.ts +2 -10
- package/lib/shared/i18n.test.ts +4 -4
- package/lib/shared/i18n.ts +18 -38
- package/lib/shared/index.ts +27 -0
- package/lib/shared/inlineSvgStyleRules.ts +14 -13
- package/lib/shared/interactiveStyleMappings.test.ts +32 -54
- package/lib/shared/interactiveStyleMappings.ts +11 -24
- package/lib/shared/interactiveStyles.test.ts +165 -188
- package/lib/shared/interfaces/contentProvider.ts +1 -1
- package/lib/shared/itemTemplateUtils.test.ts +11 -17
- package/lib/shared/itemTemplateUtils.ts +27 -39
- package/lib/shared/jsonRepair.ts +16 -10
- package/lib/shared/libraryLoader.test.ts +21 -55
- package/lib/shared/libraryLoader.ts +7 -22
- package/lib/shared/linkUtils.ts +1 -1
- package/lib/shared/logger.test.ts +66 -0
- package/lib/shared/logger.ts +94 -0
- package/lib/shared/markdown.ts +25 -0
- package/lib/shared/netlifyLocale404.test.ts +179 -0
- package/lib/shared/netlifyLocale404.ts +110 -0
- package/lib/shared/nodeUtils.test.ts +28 -16
- package/lib/shared/nodeUtils.ts +76 -23
- package/lib/shared/pathArrayUtils.test.ts +1 -2
- package/lib/shared/pathArrayUtils.ts +1 -1
- package/lib/shared/pathSecurity.ts +2 -2
- package/lib/shared/pathUtils.test.ts +4 -6
- package/lib/shared/pathUtils.ts +42 -49
- package/lib/shared/paths/Path.test.ts +2 -2
- package/lib/shared/paths/Path.ts +0 -1
- package/lib/shared/paths/PathConverter.test.ts +1 -1
- package/lib/shared/paths/PathConverter.ts +17 -20
- package/lib/shared/paths/PathUtils.ts +13 -13
- package/lib/shared/paths/PathValidator.test.ts +2 -15
- package/lib/shared/paths/PathValidator.ts +12 -10
- package/lib/shared/paths/index.ts +1 -2
- package/lib/shared/permissions.test.ts +168 -0
- package/lib/shared/permissions.ts +162 -0
- package/lib/shared/propResolver.test.ts +240 -244
- package/lib/shared/propResolver.ts +15 -26
- package/lib/shared/pxToRem.test.ts +7 -6
- package/lib/shared/pxToRem.ts +2 -5
- package/lib/shared/registry/BaseNodeTypeRegistry.test.ts +12 -6
- package/lib/shared/registry/ClientRegistry.ts +0 -2
- package/lib/shared/registry/ComponentRegistry.test.ts +46 -32
- package/lib/shared/registry/ComponentRegistry.ts +12 -9
- package/lib/shared/registry/NodeTypeDefinition.ts +16 -9
- package/lib/shared/registry/RegistryManager.ts +1 -2
- package/lib/shared/registry/SSRRegistry.ts +0 -2
- package/lib/shared/registry/createNodeType.ts +7 -9
- package/lib/shared/registry/defineNodeType.ts +2 -6
- package/lib/shared/registry/fieldPresets.ts +3 -1
- package/lib/shared/registry/index.ts +0 -1
- package/lib/shared/registry/nodeTypes/ComponentInstanceNodeType.ts +14 -15
- package/lib/shared/registry/nodeTypes/CustomNodeType.ts +103 -0
- package/lib/shared/registry/nodeTypes/EmbedNodeType.ts +18 -11
- package/lib/shared/registry/nodeTypes/HtmlNodeType.ts +48 -19
- package/lib/shared/registry/nodeTypes/IslandNodeType.ts +129 -0
- package/lib/shared/registry/nodeTypes/LinkNodeType.ts +21 -19
- package/lib/shared/registry/nodeTypes/ListNodeType.ts +117 -77
- package/lib/shared/registry/nodeTypes/LocaleListNodeType.ts +27 -21
- package/lib/shared/registry/nodeTypes/MarkdownNodeType.ts +78 -0
- package/lib/shared/registry/nodeTypes/SlotMarkerType.ts +12 -8
- package/lib/shared/registry/nodeTypes/index.ts +26 -3
- package/lib/shared/responsiveScaling.test.ts +16 -34
- package/lib/shared/responsiveScaling.ts +61 -42
- package/lib/shared/responsiveStyleUtils.test.ts +0 -1
- package/lib/shared/responsiveStyleUtils.ts +11 -13
- package/lib/shared/richtext/htmlToTiptap.test.ts +139 -130
- package/lib/shared/richtext/htmlToTiptap.ts +2 -4
- package/lib/shared/richtext/tiptapToHtml.test.ts +5 -6
- package/lib/shared/richtext/types.ts +1 -8
- package/lib/shared/slugTranslator.test.ts +13 -13
- package/lib/shared/slugTranslator.ts +12 -16
- package/lib/shared/slugify.ts +9 -15
- package/lib/shared/styleNodeUtils.test.ts +8 -8
- package/lib/shared/styleNodeUtils.ts +18 -20
- package/lib/shared/styleUtils.test.ts +87 -61
- package/lib/shared/styleUtils.ts +5 -6
- package/lib/shared/themeDefaults.test.ts +11 -14
- package/lib/shared/themeDefaults.ts +3 -4
- package/lib/shared/tree/PathBuilder.test.ts +63 -145
- package/lib/shared/tree/PathBuilder.ts +59 -47
- package/lib/shared/treePathUtils.test.ts +51 -12
- package/lib/shared/treePathUtils.ts +91 -60
- package/lib/shared/types/api.ts +105 -8
- package/lib/shared/types/cms.test.ts +34 -0
- package/lib/shared/types/cms.ts +90 -34
- package/lib/shared/types/comment.ts +49 -16
- package/lib/shared/types/components.ts +51 -25
- package/lib/shared/types/errors.test.ts +1 -6
- package/lib/shared/types/errors.ts +3 -7
- package/lib/shared/types/experiments.ts +28 -28
- package/lib/shared/types/index.ts +25 -2
- package/lib/shared/types/permissions.ts +139 -0
- package/lib/shared/types/styles.ts +0 -1
- package/lib/shared/types/variables.test.ts +4 -13
- package/lib/shared/types/variables.ts +51 -30
- package/lib/shared/types.ts +1 -2
- package/lib/shared/utilityClassConfig.ts +751 -321
- package/lib/shared/utilityClassMapper.durability.test.ts +117 -0
- package/lib/shared/utilityClassMapper.test.ts +433 -95
- package/lib/shared/utilityClassMapper.ts +322 -249
- package/lib/shared/utilityClassNames.test.ts +38 -0
- package/lib/shared/utilityClassNames.ts +458 -0
- package/lib/shared/utils.test.ts +2 -10
- package/lib/shared/utils.ts +19 -10
- package/lib/shared/validation/cmsValidators.ts +2 -1
- package/lib/shared/validation/commentValidators.test.ts +53 -0
- package/lib/shared/validation/commentValidators.ts +12 -1
- package/lib/shared/validation/index.ts +1 -0
- package/lib/shared/validation/permissionsValidators.test.ts +49 -0
- package/lib/shared/validation/permissionsValidators.ts +49 -0
- package/lib/shared/validation/propValidator.test.ts +19 -21
- package/lib/shared/validation/propValidator.ts +13 -18
- package/lib/shared/validation/schemas.test.ts +64 -32
- package/lib/shared/validation/schemas.ts +616 -345
- package/lib/shared/validation/validators.test.ts +3 -8
- package/lib/shared/validation/validators.ts +89 -68
- package/lib/shared/viewportUnits.integration.test.ts +14 -10
- package/lib/shared/viewportUnits.test.ts +24 -23
- package/lib/shared/viewportUnits.ts +12 -5
- package/lib/test-utils/dom-setup.ts +1 -1
- package/lib/test-utils/factories/ConsoleMockFactory.ts +10 -14
- package/lib/test-utils/factories/DomMockFactory.ts +17 -23
- package/lib/test-utils/factories/EventMockFactory.ts +7 -13
- package/lib/test-utils/factories/FetchMockFactory.ts +39 -57
- package/lib/test-utils/factories/ServerMockFactory.ts +6 -10
- package/lib/test-utils/factories/StoreMockFactory.ts +18 -29
- package/lib/test-utils/fixtures.ts +45 -45
- package/lib/test-utils/helpers/asyncHelpers.test.ts +15 -18
- package/lib/test-utils/helpers/asyncHelpers.ts +11 -20
- package/lib/test-utils/helpers.ts +1 -5
- package/lib/test-utils/index.ts +0 -4
- package/lib/test-utils/mockFactories.ts +13 -19
- package/lib/test-utils/mocks.ts +6 -4
- package/package.json +3 -5
- package/scripts/build-for-publish.mjs +2 -4
- package/scripts/build-meno-filter.ts +4 -7
- package/tsconfig.json +1 -0
- package/vite.config.ts +4 -4
- package/build-next.ts +0 -1361
- package/build-static.test.ts +0 -424
- package/build-static.ts +0 -1074
- package/dist/build-static.js +0 -36
- package/dist/chunks/chunk-2MHDV5BF.js +0 -251
- package/dist/chunks/chunk-2MHDV5BF.js.map +0 -7
- package/dist/chunks/chunk-AZQYF6KE.js +0 -559
- package/dist/chunks/chunk-AZQYF6KE.js.map +0 -7
- package/dist/chunks/chunk-GZHGVVW3.js +0 -322
- package/dist/chunks/chunk-GZHGVVW3.js.map +0 -7
- package/dist/chunks/chunk-H3GJ4H2U.js.map +0 -7
- package/dist/chunks/chunk-I7YIGZXT.js +0 -467
- package/dist/chunks/chunk-I7YIGZXT.js.map +0 -7
- package/dist/chunks/chunk-IGYR22T6.js +0 -6192
- package/dist/chunks/chunk-IGYR22T6.js.map +0 -7
- package/dist/chunks/chunk-JGP5A3Y5.js +0 -1136
- package/dist/chunks/chunk-JGP5A3Y5.js.map +0 -7
- package/dist/chunks/chunk-JGWFTO6P.js.map +0 -7
- package/dist/chunks/chunk-O3NAGJP4.js.map +0 -7
- package/dist/chunks/chunk-QB2LNO4W.js +0 -77
- package/dist/chunks/chunk-QB2LNO4W.js.map +0 -7
- package/dist/chunks/chunk-R6XHAFBF.js +0 -3821
- package/dist/chunks/chunk-R6XHAFBF.js.map +0 -7
- package/dist/chunks/chunk-UB44F4Z2.js.map +0 -7
- package/dist/chunks/chunk-WQFG7PAH.js.map +0 -7
- package/dist/chunks/chunk-X754AHS5.js.map +0 -7
- package/dist/chunks/chunk-YBLHKYFF.js.map +0 -7
- package/dist/chunks/configService-R3OGU2UD.js +0 -13
- package/dist/chunks/configService-R3OGU2UD.js.map +0 -7
- package/dist/chunks/constants-STK2YBIW.js +0 -46
- package/dist/chunks/constants-STK2YBIW.js.map +0 -7
- package/dist/chunks/fs-JGINUXGL.js.map +0 -7
- package/dist/entries/server-router.js +0 -67
- package/dist/entries/server-router.js.map +0 -7
- package/entries/server-router.tsx +0 -81
- package/lib/server/providers/fileSystemPageProvider.ts +0 -160
- package/lib/server/webflow/buildWebflow.ts +0 -635
- package/lib/server/webflow/index.ts +0 -23
- package/lib/server/webflow/nodeToWebflow.test.ts +0 -3170
- package/lib/server/webflow/nodeToWebflow.ts +0 -2435
- package/lib/server/webflow/styleMapper.test.ts +0 -389
- package/lib/server/webflow/styleMapper.ts +0 -695
- package/lib/server/webflow/templateWrapper.ts +0 -49
- package/lib/server/webflow/types.ts +0 -396
- /package/dist/{build-static.js.map → chunks/fs-G3ANWEFP.js.map} +0 -0
package/lib/shared/nodeUtils.ts
CHANGED
|
@@ -3,11 +3,23 @@
|
|
|
3
3
|
* Provides helper functions for working with ComponentNode types
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type {
|
|
6
|
+
import type {
|
|
7
|
+
ComponentNode,
|
|
8
|
+
ComponentInstanceNode,
|
|
9
|
+
HtmlNode,
|
|
10
|
+
SlotMarker,
|
|
11
|
+
EmbedNode,
|
|
12
|
+
LinkNode,
|
|
13
|
+
LocaleListNode,
|
|
14
|
+
ComponentDefinition,
|
|
15
|
+
StructuredComponentDefinition,
|
|
16
|
+
} from './types';
|
|
7
17
|
import type { ListNode } from './registry/nodeTypes/ListNodeType';
|
|
18
|
+
import type { IslandNode } from './registry/nodeTypes/IslandNodeType';
|
|
19
|
+
import type { CustomNode } from './registry/nodeTypes/CustomNodeType';
|
|
8
20
|
|
|
9
21
|
// For backward compatibility during migration
|
|
10
|
-
type
|
|
22
|
+
type _CMSListNode = ListNode;
|
|
11
23
|
import { NODE_TYPE } from './constants';
|
|
12
24
|
|
|
13
25
|
/**
|
|
@@ -15,8 +27,20 @@ import { NODE_TYPE } from './constants';
|
|
|
15
27
|
* These are self-closing tags like <img />, <br />, <input />, etc.
|
|
16
28
|
*/
|
|
17
29
|
export const VOID_ELEMENTS = new Set([
|
|
18
|
-
'area',
|
|
19
|
-
'
|
|
30
|
+
'area',
|
|
31
|
+
'base',
|
|
32
|
+
'br',
|
|
33
|
+
'col',
|
|
34
|
+
'embed',
|
|
35
|
+
'hr',
|
|
36
|
+
'img',
|
|
37
|
+
'input',
|
|
38
|
+
'link',
|
|
39
|
+
'meta',
|
|
40
|
+
'param',
|
|
41
|
+
'source',
|
|
42
|
+
'track',
|
|
43
|
+
'wbr',
|
|
20
44
|
]);
|
|
21
45
|
|
|
22
46
|
/**
|
|
@@ -112,13 +136,13 @@ export function extractNodeProperties(node: ComponentNode): {
|
|
|
112
136
|
if (isComponentNode(node)) {
|
|
113
137
|
return {
|
|
114
138
|
componentName: node.component,
|
|
115
|
-
props: node.props || {}
|
|
139
|
+
props: node.props || {},
|
|
116
140
|
};
|
|
117
141
|
}
|
|
118
142
|
if (isHtmlNode(node)) {
|
|
119
143
|
return {
|
|
120
144
|
tag: node.tag,
|
|
121
|
-
props: {}
|
|
145
|
+
props: {},
|
|
122
146
|
};
|
|
123
147
|
}
|
|
124
148
|
return { props: {} };
|
|
@@ -129,14 +153,15 @@ export function extractNodeProperties(node: ComponentNode): {
|
|
|
129
153
|
* This is a heuristic based on naming conventions:
|
|
130
154
|
* - Components typically start with uppercase (e.g., "Card", "Button")
|
|
131
155
|
* - HTML elements are lowercase (e.g., "div", "span")
|
|
132
|
-
*
|
|
156
|
+
*
|
|
133
157
|
* Note: This is not foolproof, but works for most cases.
|
|
134
158
|
* For accurate detection, use component registry lookup.
|
|
135
159
|
*/
|
|
136
160
|
export function isLikelyComponentTag(tag: string): boolean {
|
|
137
161
|
if (!tag) return false;
|
|
138
162
|
// Components typically start with uppercase letter
|
|
139
|
-
|
|
163
|
+
const first = tag[0];
|
|
164
|
+
return first !== undefined && first === first.toUpperCase() && first !== first.toLowerCase();
|
|
140
165
|
}
|
|
141
166
|
|
|
142
167
|
/**
|
|
@@ -195,6 +220,21 @@ export function isLocaleListNode(node: ComponentNode | null | undefined): node i
|
|
|
195
220
|
return node?.type === NODE_TYPE.LOCALE_LIST;
|
|
196
221
|
}
|
|
197
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Type guard to check if a node is an island node (BYO framework component)
|
|
225
|
+
*/
|
|
226
|
+
export function isIslandNode(node: ComponentNode | null | undefined): node is IslandNode {
|
|
227
|
+
return node?.type === NODE_TYPE.ISLAND;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Type guard to check if a node is a custom node (opaque hand-authored `.astro`
|
|
232
|
+
* component under `src/custom/` — Meno renders it but doesn't model its internals).
|
|
233
|
+
*/
|
|
234
|
+
export function isCustomNode(node: ComponentNode | null | undefined): node is CustomNode {
|
|
235
|
+
return node?.type === NODE_TYPE.CUSTOM;
|
|
236
|
+
}
|
|
237
|
+
|
|
198
238
|
/**
|
|
199
239
|
* Type guard to check if a node is a CMS list node
|
|
200
240
|
* @deprecated Use isListNode() and check sourceType === 'collection' instead.
|
|
@@ -220,17 +260,29 @@ export function isListNode(node: unknown): node is ListNode {
|
|
|
220
260
|
/**
|
|
221
261
|
* Validate that a node type is valid
|
|
222
262
|
*/
|
|
223
|
-
export function isValidNodeType(type: string): type is typeof NODE_TYPE[keyof typeof NODE_TYPE] {
|
|
224
|
-
return
|
|
225
|
-
type === NODE_TYPE.
|
|
226
|
-
type === NODE_TYPE.
|
|
263
|
+
export function isValidNodeType(type: string): type is (typeof NODE_TYPE)[keyof typeof NODE_TYPE] {
|
|
264
|
+
return (
|
|
265
|
+
type === NODE_TYPE.NODE ||
|
|
266
|
+
type === NODE_TYPE.COMPONENT ||
|
|
267
|
+
type === NODE_TYPE.SLOT ||
|
|
268
|
+
type === NODE_TYPE.EMBED ||
|
|
269
|
+
type === NODE_TYPE.LINK ||
|
|
270
|
+
type === NODE_TYPE.LOCALE_LIST ||
|
|
271
|
+
type === NODE_TYPE.LIST ||
|
|
272
|
+
type === NODE_TYPE.ISLAND ||
|
|
273
|
+
type === NODE_TYPE.CUSTOM ||
|
|
274
|
+
type === NODE_TYPE.MARKDOWN ||
|
|
275
|
+
type === 'cms-list'
|
|
276
|
+
); // 'cms-list' supported for migration
|
|
227
277
|
}
|
|
228
278
|
|
|
229
279
|
/**
|
|
230
|
-
* Check if a node can have children property (excludes SlotMarker)
|
|
280
|
+
* Check if a node can have a children property (excludes SlotMarker and verbatim `{_code}` markers).
|
|
281
|
+
* A `_code` marker is rendered byte-for-byte by the emitter, which ignores any `children` — so
|
|
282
|
+
* letting the tree drop a node "inside" one would silently lose the dropped node on save/build.
|
|
231
283
|
*/
|
|
232
284
|
export function canHaveChildren(node: ComponentNode | null | undefined): node is Exclude<ComponentNode, SlotMarker> {
|
|
233
|
-
return node !== null && node !== undefined && !isSlotMarker(node);
|
|
285
|
+
return node !== null && node !== undefined && !isSlotMarker(node) && (node as { _code?: unknown })._code !== true;
|
|
234
286
|
}
|
|
235
287
|
|
|
236
288
|
/**
|
|
@@ -258,7 +310,12 @@ export function hasIf(node: ComponentNode): node is ComponentNode & { if: IfCond
|
|
|
258
310
|
* Check if a node is marked as slot content
|
|
259
311
|
*/
|
|
260
312
|
export function isSlotContent(node: unknown): boolean {
|
|
261
|
-
return
|
|
313
|
+
return (
|
|
314
|
+
node != null &&
|
|
315
|
+
typeof node === 'object' &&
|
|
316
|
+
'_isSlotContent' in node &&
|
|
317
|
+
(node as Record<string, unknown>)._isSlotContent === true
|
|
318
|
+
);
|
|
262
319
|
}
|
|
263
320
|
|
|
264
321
|
/**
|
|
@@ -389,10 +446,7 @@ export function isBooleanMapping(value: unknown): value is BooleanMapping {
|
|
|
389
446
|
* { visible: 'true' }
|
|
390
447
|
* ) // true
|
|
391
448
|
*/
|
|
392
|
-
export function evaluateNodeIf(
|
|
393
|
-
node: ComponentNode,
|
|
394
|
-
props?: Record<string, unknown>
|
|
395
|
-
): boolean {
|
|
449
|
+
export function evaluateNodeIf(node: ComponentNode, props?: Record<string, unknown>): boolean {
|
|
396
450
|
const ifValue = hasIf(node) ? node.if : undefined;
|
|
397
451
|
|
|
398
452
|
// No if property = render (default true)
|
|
@@ -441,7 +495,7 @@ export function evaluateNodeIf(
|
|
|
441
495
|
* @returns The same node with _isSlotContent: true added to all object nodes
|
|
442
496
|
*/
|
|
443
497
|
export function markAsSlotContent<T extends ComponentNode | ComponentNode[] | string | number | null | undefined>(
|
|
444
|
-
node: T
|
|
498
|
+
node: T,
|
|
445
499
|
): T {
|
|
446
500
|
if (!node || typeof node !== 'object') return node;
|
|
447
501
|
|
|
@@ -455,8 +509,8 @@ export function markAsSlotContent<T extends ComponentNode | ComponentNode[] | st
|
|
|
455
509
|
// Recursively mark children
|
|
456
510
|
if ('children' in node && node.children) {
|
|
457
511
|
if (Array.isArray(node.children)) {
|
|
458
|
-
node.children = node.children.map(child =>
|
|
459
|
-
typeof child === 'object' && child !== null ? markAsSlotContent(child) : child
|
|
512
|
+
node.children = node.children.map((child) =>
|
|
513
|
+
typeof child === 'object' && child !== null ? markAsSlotContent(child) : child,
|
|
460
514
|
) as typeof node.children;
|
|
461
515
|
} else if (typeof node.children === 'object') {
|
|
462
516
|
markAsSlotContent(node.children as ComponentNode);
|
|
@@ -465,4 +519,3 @@ export function markAsSlotContent<T extends ComponentNode | ComponentNode[] | st
|
|
|
465
519
|
|
|
466
520
|
return node;
|
|
467
521
|
}
|
|
468
|
-
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Array-based path utilities
|
|
3
3
|
* Paths are represented as number arrays internally: [0,0,1] instead of "root_0_children_0_children_1"
|
|
4
4
|
* Root is represented as [0] (or empty array [] depending on context)
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
6
|
* This file maintains backward compatibility while using the new modular path system.
|
|
7
7
|
* All path utilities are re-exported from the organized path modules.
|
|
8
8
|
*/
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Provides path traversal protection for file system operations
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { resolve, sep } from 'path';
|
|
6
|
+
import { resolve, sep } from 'node:path';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Error thrown when a path traversal attack is detected
|
|
@@ -11,7 +11,7 @@ import { resolve, sep } from 'path';
|
|
|
11
11
|
export class PathTraversalError extends Error {
|
|
12
12
|
constructor(
|
|
13
13
|
public readonly requestedPath: string,
|
|
14
|
-
public readonly rootPath: string
|
|
14
|
+
public readonly rootPath: string,
|
|
15
15
|
) {
|
|
16
16
|
super(`Path traversal detected: "${requestedPath}" escapes root "${rootPath}"`);
|
|
17
17
|
this.name = 'PathTraversalError';
|
|
@@ -94,7 +94,9 @@ describe('pathUtils', () => {
|
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
test('should handle deeply nested paths', () => {
|
|
97
|
-
expect(domPathToTreePath('root_children_0_children_1_children_2')).toBe(
|
|
97
|
+
expect(domPathToTreePath('root_children_0_children_1_children_2')).toBe(
|
|
98
|
+
'root_0_children_0_children_1_children_2',
|
|
99
|
+
);
|
|
98
100
|
});
|
|
99
101
|
});
|
|
100
102
|
|
|
@@ -115,11 +117,7 @@ describe('pathUtils', () => {
|
|
|
115
117
|
});
|
|
116
118
|
|
|
117
119
|
test('should handle deeply nested paths', () => {
|
|
118
|
-
expect(buildParentPaths([0, 0, 1, 2])).toEqual([
|
|
119
|
-
'root_0',
|
|
120
|
-
'root_0_children_0',
|
|
121
|
-
'root_0_children_0_children_1',
|
|
122
|
-
]);
|
|
120
|
+
expect(buildParentPaths([0, 0, 1, 2])).toEqual(['root_0', 'root_0_children_0', 'root_0_children_0_children_1']);
|
|
123
121
|
});
|
|
124
122
|
});
|
|
125
123
|
|
package/lib/shared/pathUtils.ts
CHANGED
|
@@ -4,69 +4,68 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { Path } from './paths';
|
|
7
|
-
import {
|
|
8
|
-
stringToPath,
|
|
9
|
-
pathToLegacyString,
|
|
7
|
+
import {
|
|
8
|
+
stringToPath,
|
|
9
|
+
pathToLegacyString,
|
|
10
10
|
getParentPath as getParentPathArray,
|
|
11
11
|
buildParentPaths as buildParentPathsArray,
|
|
12
|
-
pathsEqual,
|
|
13
12
|
isRootPath as isRootPathArray,
|
|
14
13
|
ROOT_STRING,
|
|
15
14
|
domPathStringToTreePath,
|
|
16
15
|
treePathToDomPathString,
|
|
17
|
-
isAncestorPath
|
|
16
|
+
isAncestorPath,
|
|
18
17
|
} from './paths';
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
20
|
* Convert a page path to static HTML file path
|
|
22
|
-
*
|
|
21
|
+
*
|
|
23
22
|
* @example
|
|
24
23
|
* getStaticFilePath("/") -> "./dist/index.html"
|
|
25
24
|
* getStaticFilePath("/about") -> "./dist/about.html"
|
|
26
25
|
* getStaticFilePath("/blog/post-1") -> "./dist/blog-post-1.html"
|
|
27
26
|
*/
|
|
28
|
-
export function getStaticFilePath(pagePath: string, distDir: string =
|
|
29
|
-
if (pagePath ===
|
|
27
|
+
export function getStaticFilePath(pagePath: string, distDir: string = './dist'): string {
|
|
28
|
+
if (pagePath === '/') {
|
|
30
29
|
return `${distDir}/index.html`;
|
|
31
30
|
}
|
|
32
|
-
|
|
31
|
+
|
|
33
32
|
// Convert /about -> about.html
|
|
34
33
|
// Convert /blog/post-1 -> blog-post-1.html (flat structure)
|
|
35
|
-
const pathParts = pagePath.substring(1).split(
|
|
36
|
-
const fileName = pathParts.join(
|
|
37
|
-
|
|
34
|
+
const pathParts = pagePath.substring(1).split('/');
|
|
35
|
+
const fileName = `${pathParts.join('-')}.html`;
|
|
36
|
+
|
|
38
37
|
return `${distDir}/${fileName}`;
|
|
39
38
|
}
|
|
40
39
|
|
|
41
40
|
/**
|
|
42
41
|
* Convert a page path to a page name (for file system)
|
|
43
|
-
*
|
|
42
|
+
*
|
|
44
43
|
* @example
|
|
45
44
|
* pathToPageName("/") -> "index"
|
|
46
45
|
* pathToPageName("/about") -> "about"
|
|
47
46
|
*/
|
|
48
47
|
export function pathToPageName(pagePath: string): string {
|
|
49
|
-
return pagePath ===
|
|
48
|
+
return pagePath === '/' ? 'index' : pagePath.substring(1);
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
/**
|
|
53
52
|
* Convert a page name to a page path
|
|
54
|
-
*
|
|
53
|
+
*
|
|
55
54
|
* @example
|
|
56
55
|
* pageNameToPath("index") -> "/"
|
|
57
56
|
* pageNameToPath("about") -> "/about"
|
|
58
57
|
*/
|
|
59
58
|
export function pageNameToPath(pageName: string): string {
|
|
60
|
-
return pageName ===
|
|
59
|
+
return pageName === 'index' ? '/' : `/${pageName}`;
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
/**
|
|
64
63
|
* Convert tree path to DOM path
|
|
65
64
|
* The tree adds a synthetic "root" container, so "root_0" in the tree corresponds to "root" in the DOM
|
|
66
65
|
* Also accepts array paths: [0] -> "root", [0,0] -> "root_children_0"
|
|
67
|
-
*
|
|
66
|
+
*
|
|
68
67
|
* Uses array operations internally for conversion.
|
|
69
|
-
*
|
|
68
|
+
*
|
|
70
69
|
* @example
|
|
71
70
|
* treePathToDomPath("root_0") -> "root"
|
|
72
71
|
* treePathToDomPath("root_0_children_0") -> "root_children_0"
|
|
@@ -83,9 +82,9 @@ export function treePathToDomPath(treePath: Path | string): string {
|
|
|
83
82
|
* Convert DOM path back to tree path
|
|
84
83
|
* The tree adds a synthetic "root" container, so "root" in the DOM corresponds to "root_0" in the tree
|
|
85
84
|
* Returns legacy string format for backward compatibility
|
|
86
|
-
*
|
|
85
|
+
*
|
|
87
86
|
* Uses array operations internally for conversion.
|
|
88
|
-
*
|
|
87
|
+
*
|
|
89
88
|
* @example
|
|
90
89
|
* domPathToTreePath("root") -> "root_0"
|
|
91
90
|
* domPathToTreePath("root_children_0") -> "root_0_children_0"
|
|
@@ -100,18 +99,18 @@ export function domPathToTreePath(domPath: string): string {
|
|
|
100
99
|
* Build parent paths for expanding tree nodes
|
|
101
100
|
* Returns all parent path segments for a given tree path
|
|
102
101
|
* Also accepts array paths
|
|
103
|
-
*
|
|
102
|
+
*
|
|
104
103
|
* @example
|
|
105
104
|
* buildParentPaths("root_0_children_0_children_1") -> ["root_0", "root_0_children_0"]
|
|
106
105
|
* buildParentPaths([0,0,1]) -> ["root_0", "root_0_children_0"]
|
|
107
106
|
*/
|
|
108
107
|
export function buildParentPaths(treePath: Path | string): string[] {
|
|
109
108
|
const pathArray = typeof treePath === 'string' ? stringToPath(treePath) : treePath;
|
|
110
|
-
|
|
109
|
+
|
|
111
110
|
if (isRootPathArray(pathArray)) {
|
|
112
111
|
return [];
|
|
113
112
|
}
|
|
114
|
-
|
|
113
|
+
|
|
115
114
|
const parentArrays = buildParentPathsArray(pathArray);
|
|
116
115
|
return parentArrays.map(pathToLegacyString);
|
|
117
116
|
}
|
|
@@ -134,43 +133,40 @@ export function getParentPathFromChildPath(childPath: Path | string): string {
|
|
|
134
133
|
* Convert component instance path to component structure path
|
|
135
134
|
* When editing a component, elements clicked inside the component instance on the page
|
|
136
135
|
* need to be converted to their paths within the component structure.
|
|
137
|
-
*
|
|
136
|
+
*
|
|
138
137
|
* Uses array operations internally for path manipulation.
|
|
139
|
-
*
|
|
138
|
+
*
|
|
140
139
|
* @example
|
|
141
140
|
* componentInstancePath: "root_children_0" (component instance on page)
|
|
142
141
|
* instancePath: "root_children_0_children_1" (element inside instance)
|
|
143
142
|
* Returns: "root_children_1" (component structure path)
|
|
144
|
-
*
|
|
143
|
+
*
|
|
145
144
|
* @param instancePath - Path of element within component instance on page (DOM path string)
|
|
146
145
|
* @param componentInstancePath - Path of the component instance root on the page (DOM path string)
|
|
147
146
|
* @returns Component structure path (always starts with "root")
|
|
148
147
|
*/
|
|
149
|
-
export function componentInstancePathToStructurePath(
|
|
150
|
-
instancePath: string,
|
|
151
|
-
componentInstancePath: string
|
|
152
|
-
): string {
|
|
148
|
+
export function componentInstancePathToStructurePath(instancePath: string, componentInstancePath: string): string {
|
|
153
149
|
// Convert DOM paths to arrays for manipulation
|
|
154
150
|
const instancePathArray = domPathStringToTreePath(instancePath);
|
|
155
151
|
const componentInstancePathArray = domPathStringToTreePath(componentInstancePath);
|
|
156
|
-
|
|
152
|
+
|
|
157
153
|
// Check if instancePath is inside componentInstancePath using array operations
|
|
158
154
|
if (!isAncestorPath(componentInstancePathArray, instancePathArray)) {
|
|
159
155
|
// Not inside component instance - return as-is (shouldn't happen, but handle gracefully)
|
|
160
156
|
return instancePath;
|
|
161
157
|
}
|
|
162
|
-
|
|
158
|
+
|
|
163
159
|
// Extract relative path using array operations
|
|
164
160
|
// componentInstancePathArray: [0, 0] -> instancePathArray: [0, 0, 1]
|
|
165
161
|
// relative: [1] -> convert to DOM path: "root_children_1"
|
|
166
162
|
const relativePathArray = instancePathArray.slice(componentInstancePathArray.length);
|
|
167
|
-
|
|
163
|
+
|
|
168
164
|
// Convert relative path array back to DOM path string
|
|
169
165
|
// If relative is empty, return root
|
|
170
166
|
if (relativePathArray.length === 0) {
|
|
171
167
|
return ROOT_STRING;
|
|
172
168
|
}
|
|
173
|
-
|
|
169
|
+
|
|
174
170
|
// Build component structure path: root + relative path
|
|
175
171
|
return treePathToDomPathString(relativePathArray);
|
|
176
172
|
}
|
|
@@ -179,34 +175,31 @@ export function componentInstancePathToStructurePath(
|
|
|
179
175
|
* Convert component structure path to component instance path
|
|
180
176
|
* When selecting an element in the component structure tree, convert it to
|
|
181
177
|
* the path within the component instance on the page.
|
|
182
|
-
*
|
|
178
|
+
*
|
|
183
179
|
* Uses array operations internally for path manipulation.
|
|
184
|
-
*
|
|
180
|
+
*
|
|
185
181
|
* @example
|
|
186
182
|
* componentInstancePath: "root_children_0" (component instance on page)
|
|
187
183
|
* structurePath: "root_children_1" (element in component structure)
|
|
188
184
|
* Returns: "root_children_0_children_1" (path within instance on page)
|
|
189
|
-
*
|
|
185
|
+
*
|
|
190
186
|
* @param structurePath - Path within component structure (starts with "root", DOM path string)
|
|
191
187
|
* @param componentInstancePath - Path of the component instance root on the page (DOM path string)
|
|
192
188
|
* @returns Path within component instance on page (DOM path string)
|
|
193
189
|
*/
|
|
194
|
-
export function componentStructurePathToInstancePath(
|
|
195
|
-
structurePath: string,
|
|
196
|
-
componentInstancePath: string
|
|
197
|
-
): string {
|
|
190
|
+
export function componentStructurePathToInstancePath(structurePath: string, componentInstancePath: string): string {
|
|
198
191
|
// Convert DOM paths to arrays for manipulation
|
|
199
192
|
const structurePathArray = domPathStringToTreePath(structurePath);
|
|
200
193
|
const componentInstancePathArray = domPathStringToTreePath(componentInstancePath);
|
|
201
|
-
|
|
194
|
+
|
|
202
195
|
// Extract relative path from structure path (skip root [0])
|
|
203
196
|
// structurePathArray: [0, 1] -> relative: [1]
|
|
204
197
|
const relativePathArray = structurePathArray.slice(1);
|
|
205
|
-
|
|
198
|
+
|
|
206
199
|
// Combine component instance path with relative path using array operations
|
|
207
200
|
// componentInstancePathArray: [0, 0] + relativePathArray: [1] -> [0, 0, 1]
|
|
208
201
|
const instancePathArray: Path = [...componentInstancePathArray, ...relativePathArray];
|
|
209
|
-
|
|
202
|
+
|
|
210
203
|
// Convert back to DOM path string
|
|
211
204
|
return treePathToDomPathString(instancePathArray);
|
|
212
205
|
}
|
|
@@ -214,9 +207,9 @@ export function componentStructurePathToInstancePath(
|
|
|
214
207
|
/**
|
|
215
208
|
* Convert path for component editing context
|
|
216
209
|
* When editing a component, converts component instance paths to component structure paths
|
|
217
|
-
*
|
|
210
|
+
*
|
|
218
211
|
* Uses array operations internally for path manipulation.
|
|
219
|
-
*
|
|
212
|
+
*
|
|
220
213
|
* @param path - Path array from canvas
|
|
221
214
|
* @param isEditingComponent - Whether we're editing a component
|
|
222
215
|
* @param componentInstancePath - Path of component instance on page (if editing component, Path array)
|
|
@@ -225,7 +218,7 @@ export function componentStructurePathToInstancePath(
|
|
|
225
218
|
export function convertPathForComponentContext(
|
|
226
219
|
path: Path,
|
|
227
220
|
isEditingComponent: boolean,
|
|
228
|
-
componentInstancePath: Path | null
|
|
221
|
+
componentInstancePath: Path | null,
|
|
229
222
|
): Path {
|
|
230
223
|
if (isEditingComponent && componentInstancePath) {
|
|
231
224
|
// Check if path is inside componentInstancePath using array operations
|
|
@@ -233,12 +226,12 @@ export function convertPathForComponentContext(
|
|
|
233
226
|
// Extract relative path: componentInstancePath: [0, 0] -> path: [0, 0, 1]
|
|
234
227
|
// relative: [1] -> component structure path: [0, 1]
|
|
235
228
|
const relativePath = path.slice(componentInstancePath.length);
|
|
236
|
-
|
|
229
|
+
|
|
237
230
|
// Build component structure path: [0] + relative path
|
|
238
231
|
return [0, ...relativePath];
|
|
239
232
|
}
|
|
240
233
|
}
|
|
241
|
-
|
|
234
|
+
|
|
242
235
|
// Regular page editing - return path as-is
|
|
243
236
|
return path;
|
|
244
237
|
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
ROOT_PREFIX,
|
|
7
7
|
CHILDREN_TOKEN,
|
|
8
8
|
PATH_SEPARATOR,
|
|
9
|
-
type Path
|
|
9
|
+
type Path,
|
|
10
10
|
} from './Path';
|
|
11
11
|
|
|
12
12
|
describe('Path types and constants', () => {
|
|
@@ -14,7 +14,7 @@ describe('Path types and constants', () => {
|
|
|
14
14
|
test('Path is a number array', () => {
|
|
15
15
|
const path: Path = [0, 1, 2];
|
|
16
16
|
expect(Array.isArray(path)).toBe(true);
|
|
17
|
-
expect(path.every(n => typeof n === 'number')).toBe(true);
|
|
17
|
+
expect(path.every((n) => typeof n === 'number')).toBe(true);
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
test('Root path is [0]', () => {
|
package/lib/shared/paths/Path.ts
CHANGED
|
@@ -43,9 +43,9 @@ export function stringToPath(str: string): Path {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// Parse comma-separated format: "0,0,1" -> [0, 0, 1]
|
|
46
|
-
return str.split(',').map(s => {
|
|
46
|
+
return str.split(',').map((s) => {
|
|
47
47
|
const num = parseInt(s, 10);
|
|
48
|
-
if (isNaN(num)) {
|
|
48
|
+
if (Number.isNaN(num)) {
|
|
49
49
|
throw new PathConversionError(`Invalid numeric index: ${s}`, str);
|
|
50
50
|
}
|
|
51
51
|
return num;
|
|
@@ -55,7 +55,7 @@ export function stringToPath(str: string): Path {
|
|
|
55
55
|
/**
|
|
56
56
|
* Convert array path to legacy string format (for backward compatibility)
|
|
57
57
|
* Converts Path arrays to legacy string format used by TreeNode.path and iframe messages
|
|
58
|
-
*
|
|
58
|
+
*
|
|
59
59
|
* @param path - Path array to convert (e.g., [0,0,1])
|
|
60
60
|
* @returns Legacy string path (e.g., "root_0_children_0_children_1")
|
|
61
61
|
*/
|
|
@@ -63,13 +63,13 @@ export function pathToLegacyString(path: Path): string {
|
|
|
63
63
|
if (path.length === 0 || (path.length === 1 && path[0] === 0)) {
|
|
64
64
|
return ROOT_0_STRING;
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
// Build: root_0_children_0_children_1
|
|
68
68
|
let result = ROOT_0_STRING;
|
|
69
69
|
for (let i = 1; i < path.length; i++) {
|
|
70
70
|
result += `${CHILDREN_SEPARATOR}${path[i]}`;
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
|
|
73
73
|
return result;
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -82,21 +82,19 @@ export function domPathStringToTreePath(domPath: string): Path {
|
|
|
82
82
|
if (domPath === ROOT_STRING || domPath === '') {
|
|
83
83
|
return [0];
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
// Remove "root_" prefix and parse
|
|
87
|
-
const cleanPath = domPath.startsWith(ROOT_PREFIX)
|
|
88
|
-
|
|
89
|
-
: domPath;
|
|
90
|
-
|
|
87
|
+
const cleanPath = domPath.startsWith(ROOT_PREFIX) ? domPath.substring(ROOT_PREFIX.length) : domPath;
|
|
88
|
+
|
|
91
89
|
// Parse "children_0_children_1" -> [0, 1]
|
|
92
90
|
const parts = cleanPath.split(PATH_SEPARATOR);
|
|
93
91
|
const path: Path = [0]; // Tree paths always start with [0]
|
|
94
|
-
|
|
92
|
+
|
|
95
93
|
for (let i = 0; i < parts.length; i++) {
|
|
96
94
|
if (parts[i] === CHILDREN_TOKEN && i + 1 < parts.length) {
|
|
97
|
-
const indexStr = parts[i + 1];
|
|
95
|
+
const indexStr = parts[i + 1] ?? '';
|
|
98
96
|
const index = parseInt(indexStr, 10);
|
|
99
|
-
if (!isNaN(index) && indexStr === String(index)) {
|
|
97
|
+
if (!Number.isNaN(index) && indexStr === String(index)) {
|
|
100
98
|
// Valid numeric index
|
|
101
99
|
path.push(index);
|
|
102
100
|
i++;
|
|
@@ -104,14 +102,14 @@ export function domPathStringToTreePath(domPath: string): Path {
|
|
|
104
102
|
// Invalid index segments are silently skipped
|
|
105
103
|
}
|
|
106
104
|
}
|
|
107
|
-
|
|
105
|
+
|
|
108
106
|
return path;
|
|
109
107
|
}
|
|
110
108
|
|
|
111
109
|
/**
|
|
112
110
|
* Convert tree path array to DOM path string
|
|
113
111
|
* Converts Path arrays to DOM path strings used for element registration and highlighting
|
|
114
|
-
*
|
|
112
|
+
*
|
|
115
113
|
* @param path - Path array or string (e.g., [0,0,1] or "root_0_children_0_children_1")
|
|
116
114
|
* @returns DOM path string (e.g., "root_children_0_children_1")
|
|
117
115
|
* @throws {InvalidPathError} If path contains invalid values
|
|
@@ -122,20 +120,19 @@ export function treePathToDomPathString(path: Path | string): string {
|
|
|
122
120
|
const pathArray = stringToPath(path);
|
|
123
121
|
return treePathToDomPathString(pathArray);
|
|
124
122
|
}
|
|
125
|
-
|
|
123
|
+
|
|
126
124
|
// Validate path before processing
|
|
127
125
|
validatePath(path);
|
|
128
|
-
|
|
126
|
+
|
|
129
127
|
if (path.length === 0 || (path.length === 1 && path[0] === 0)) {
|
|
130
128
|
return ROOT_STRING;
|
|
131
129
|
}
|
|
132
|
-
|
|
130
|
+
|
|
133
131
|
// Build: root_children_0_children_1
|
|
134
132
|
let result = ROOT_STRING;
|
|
135
133
|
for (let i = 1; i < path.length; i++) {
|
|
136
134
|
result += `${CHILDREN_SEPARATOR}${path[i]}`;
|
|
137
135
|
}
|
|
138
|
-
|
|
136
|
+
|
|
139
137
|
return result;
|
|
140
138
|
}
|
|
141
|
-
|