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
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { test, expect, describe, beforeEach, afterEach, mock, spyOn } from
|
|
2
|
-
import { ScriptExecutor } from
|
|
3
|
-
import { ComponentRegistry } from
|
|
4
|
-
import { ElementRegistry } from
|
|
5
|
-
import type { ComponentDefinition } from
|
|
1
|
+
import { test, expect, describe, beforeEach, afterEach, mock, spyOn } from 'bun:test';
|
|
2
|
+
import { ScriptExecutor } from './ScriptExecutor';
|
|
3
|
+
import { ComponentRegistry } from '../componentRegistry';
|
|
4
|
+
import { ElementRegistry } from '../elementRegistry';
|
|
5
|
+
import type { ComponentDefinition } from '../../shared/types';
|
|
6
6
|
|
|
7
|
-
describe(
|
|
7
|
+
describe('ScriptExecutor', () => {
|
|
8
8
|
let componentRegistry: ComponentRegistry;
|
|
9
9
|
let elementRegistry: ElementRegistry;
|
|
10
10
|
let scriptExecutor: ScriptExecutor;
|
|
@@ -23,7 +23,7 @@ describe("ScriptExecutor", () => {
|
|
|
23
23
|
// Track executed code by intercepting Function constructor
|
|
24
24
|
executedCode = [];
|
|
25
25
|
originalFunction = global.Function;
|
|
26
|
-
functionSpy = spyOn(global,
|
|
26
|
+
functionSpy = spyOn(global, 'Function').mockImplementation(((...args: any[]) => {
|
|
27
27
|
if (args.length > 0 && typeof args[args.length - 1] === 'string') {
|
|
28
28
|
const code = args[args.length - 1];
|
|
29
29
|
// Only track ScriptExecutor calls (they contain "Component:" comment)
|
|
@@ -41,8 +41,8 @@ describe("ScriptExecutor", () => {
|
|
|
41
41
|
executedCode = [];
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
describe(
|
|
45
|
-
test(
|
|
44
|
+
describe('constructor', () => {
|
|
45
|
+
test('should create instance', () => {
|
|
46
46
|
const executor = new ScriptExecutor({
|
|
47
47
|
componentRegistry,
|
|
48
48
|
elementRegistry,
|
|
@@ -51,63 +51,63 @@ describe("ScriptExecutor", () => {
|
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
describe(
|
|
55
|
-
test(
|
|
54
|
+
describe('execute', () => {
|
|
55
|
+
test('should skip components without JavaScript', () => {
|
|
56
56
|
const componentDef: ComponentDefinition = {
|
|
57
|
-
type:
|
|
57
|
+
type: 'component',
|
|
58
58
|
component: {
|
|
59
59
|
interface: {},
|
|
60
|
-
structure: { type:
|
|
60
|
+
structure: { type: 'node', tag: 'div' },
|
|
61
61
|
},
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
componentRegistry.register(
|
|
64
|
+
componentRegistry.register('TestComponent', componentDef);
|
|
65
65
|
|
|
66
66
|
scriptExecutor.execute();
|
|
67
67
|
|
|
68
68
|
expect(executedCode.length).toBe(0);
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
test(
|
|
71
|
+
test('should execute JavaScript without templates once', () => {
|
|
72
72
|
const componentDef: ComponentDefinition = {
|
|
73
|
-
type:
|
|
73
|
+
type: 'component',
|
|
74
74
|
component: {
|
|
75
75
|
interface: {},
|
|
76
|
-
structure: { type:
|
|
76
|
+
structure: { type: 'node', tag: 'div' },
|
|
77
77
|
javascript: "console.log('test');",
|
|
78
78
|
},
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
componentRegistry.register(
|
|
81
|
+
componentRegistry.register('TestComponent', componentDef);
|
|
82
82
|
|
|
83
83
|
scriptExecutor.execute();
|
|
84
84
|
|
|
85
85
|
expect(executedCode.length).toBe(1);
|
|
86
|
-
expect(executedCode[0]).toContain(
|
|
86
|
+
expect(executedCode[0]).toContain('Component: TestComponent');
|
|
87
87
|
expect(executedCode[0]).toContain("console.log('test');");
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
// Template-based tests require full ElementRegistry from @meno/studio
|
|
91
|
-
test.skip(
|
|
91
|
+
test.skip('should execute JavaScript with templates per instance (requires @meno/studio ElementRegistry)', () => {
|
|
92
92
|
const componentDef: ComponentDefinition = {
|
|
93
|
-
type:
|
|
93
|
+
type: 'component',
|
|
94
94
|
component: {
|
|
95
95
|
interface: {},
|
|
96
|
-
structure: { type:
|
|
96
|
+
structure: { type: 'node', tag: 'div' },
|
|
97
97
|
javascript: "console.log('{{name}}');",
|
|
98
98
|
},
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
componentRegistry.register(
|
|
101
|
+
componentRegistry.register('TestComponent', componentDef);
|
|
102
102
|
|
|
103
103
|
// Register component instances with props
|
|
104
|
-
const mockElement1 = document.createElement(
|
|
105
|
-
const mockElement2 = document.createElement(
|
|
106
|
-
elementRegistry.register([0], mockElement1,
|
|
107
|
-
name:
|
|
104
|
+
const mockElement1 = document.createElement('div');
|
|
105
|
+
const mockElement2 = document.createElement('div');
|
|
106
|
+
elementRegistry.register([0], mockElement1, 'TestComponent', true, {
|
|
107
|
+
name: 'Instance1',
|
|
108
108
|
});
|
|
109
|
-
elementRegistry.register([1], mockElement2,
|
|
110
|
-
name:
|
|
109
|
+
elementRegistry.register([1], mockElement2, 'TestComponent', true, {
|
|
110
|
+
name: 'Instance2',
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
scriptExecutor.execute();
|
|
@@ -116,61 +116,61 @@ describe("ScriptExecutor", () => {
|
|
|
116
116
|
expect(executedCode.length).toBe(2);
|
|
117
117
|
});
|
|
118
118
|
|
|
119
|
-
test(
|
|
119
|
+
test('should execute JavaScript without templates only once for multiple instances', () => {
|
|
120
120
|
const componentDef: ComponentDefinition = {
|
|
121
|
-
type:
|
|
121
|
+
type: 'component',
|
|
122
122
|
component: {
|
|
123
123
|
interface: {},
|
|
124
|
-
structure: { type:
|
|
124
|
+
structure: { type: 'node', tag: 'div' },
|
|
125
125
|
javascript: "console.log('test');",
|
|
126
126
|
},
|
|
127
127
|
};
|
|
128
128
|
|
|
129
|
-
componentRegistry.register(
|
|
129
|
+
componentRegistry.register('TestComponent', componentDef);
|
|
130
130
|
|
|
131
131
|
// Register multiple instances
|
|
132
|
-
const mockElement1 = document.createElement(
|
|
133
|
-
const mockElement2 = document.createElement(
|
|
134
|
-
elementRegistry.register([0], mockElement1,
|
|
135
|
-
name:
|
|
132
|
+
const mockElement1 = document.createElement('div');
|
|
133
|
+
const mockElement2 = document.createElement('div');
|
|
134
|
+
elementRegistry.register([0], mockElement1, 'TestComponent', true, {
|
|
135
|
+
name: 'Instance1',
|
|
136
136
|
});
|
|
137
|
-
elementRegistry.register([1], mockElement2,
|
|
138
|
-
name:
|
|
137
|
+
elementRegistry.register([1], mockElement2, 'TestComponent', true, {
|
|
138
|
+
name: 'Instance2',
|
|
139
139
|
});
|
|
140
140
|
|
|
141
141
|
scriptExecutor.execute();
|
|
142
142
|
|
|
143
143
|
// Should only execute once (no templates - executes once per component type)
|
|
144
144
|
expect(executedCode.length).toBe(1);
|
|
145
|
-
expect(executedCode[0]).toContain(
|
|
145
|
+
expect(executedCode[0]).toContain('Component: TestComponent');
|
|
146
146
|
expect(executedCode[0]).toContain("console.log('test');");
|
|
147
147
|
});
|
|
148
148
|
|
|
149
|
-
test.skip(
|
|
149
|
+
test.skip('should handle multiple components with mixed template/non-template JavaScript (requires @meno/studio ElementRegistry)', () => {
|
|
150
150
|
const componentDef1: ComponentDefinition = {
|
|
151
|
-
type:
|
|
151
|
+
type: 'component',
|
|
152
152
|
component: {
|
|
153
153
|
interface: {},
|
|
154
|
-
structure: { type:
|
|
154
|
+
structure: { type: 'node', tag: 'div' },
|
|
155
155
|
javascript: "console.log('Component1');",
|
|
156
156
|
},
|
|
157
157
|
};
|
|
158
158
|
|
|
159
159
|
const componentDef2: ComponentDefinition = {
|
|
160
|
-
type:
|
|
160
|
+
type: 'component',
|
|
161
161
|
component: {
|
|
162
162
|
interface: {},
|
|
163
|
-
structure: { type:
|
|
163
|
+
structure: { type: 'node', tag: 'div' },
|
|
164
164
|
javascript: "console.log('{{name}}');",
|
|
165
165
|
},
|
|
166
166
|
};
|
|
167
167
|
|
|
168
|
-
componentRegistry.register(
|
|
169
|
-
componentRegistry.register(
|
|
168
|
+
componentRegistry.register('Component1', componentDef1);
|
|
169
|
+
componentRegistry.register('Component2', componentDef2);
|
|
170
170
|
|
|
171
|
-
const mockElement = document.createElement(
|
|
172
|
-
elementRegistry.register([0], mockElement,
|
|
173
|
-
name:
|
|
171
|
+
const mockElement = document.createElement('div');
|
|
172
|
+
elementRegistry.register([0], mockElement, 'Component2', true, {
|
|
173
|
+
name: 'Component2Instance',
|
|
174
174
|
});
|
|
175
175
|
|
|
176
176
|
scriptExecutor.execute();
|
|
@@ -180,17 +180,17 @@ describe("ScriptExecutor", () => {
|
|
|
180
180
|
expect(executedCode.length).toBe(2);
|
|
181
181
|
});
|
|
182
182
|
|
|
183
|
-
test(
|
|
183
|
+
test('should handle fallback for components without instances', () => {
|
|
184
184
|
const componentDef: ComponentDefinition = {
|
|
185
|
-
type:
|
|
185
|
+
type: 'component',
|
|
186
186
|
component: {
|
|
187
187
|
interface: {},
|
|
188
|
-
structure: { type:
|
|
188
|
+
structure: { type: 'node', tag: 'div' },
|
|
189
189
|
javascript: "console.log('fallback');",
|
|
190
190
|
},
|
|
191
191
|
};
|
|
192
192
|
|
|
193
|
-
componentRegistry.register(
|
|
193
|
+
componentRegistry.register('TestComponent', componentDef);
|
|
194
194
|
|
|
195
195
|
// No instances registered
|
|
196
196
|
scriptExecutor.execute();
|
|
@@ -201,21 +201,21 @@ describe("ScriptExecutor", () => {
|
|
|
201
201
|
expect(() => scriptExecutor.execute()).not.toThrow();
|
|
202
202
|
});
|
|
203
203
|
|
|
204
|
-
test(
|
|
204
|
+
test('should handle template processing errors gracefully', () => {
|
|
205
205
|
const componentDef: ComponentDefinition = {
|
|
206
|
-
type:
|
|
206
|
+
type: 'component',
|
|
207
207
|
component: {
|
|
208
208
|
interface: {},
|
|
209
|
-
structure: { type:
|
|
209
|
+
structure: { type: 'node', tag: 'div' },
|
|
210
210
|
javascript: "console.log('{{invalid.prop}}');",
|
|
211
211
|
},
|
|
212
212
|
};
|
|
213
213
|
|
|
214
|
-
componentRegistry.register(
|
|
214
|
+
componentRegistry.register('TestComponent', componentDef);
|
|
215
215
|
|
|
216
|
-
const mockElement = document.createElement(
|
|
217
|
-
elementRegistry.register([0], mockElement,
|
|
218
|
-
name:
|
|
216
|
+
const mockElement = document.createElement('div');
|
|
217
|
+
elementRegistry.register([0], mockElement, 'TestComponent', true, {
|
|
218
|
+
name: 'test',
|
|
219
219
|
});
|
|
220
220
|
|
|
221
221
|
const consoleErrorSpy = mock(() => {});
|
|
@@ -229,17 +229,17 @@ describe("ScriptExecutor", () => {
|
|
|
229
229
|
console.error = originalConsoleError;
|
|
230
230
|
});
|
|
231
231
|
|
|
232
|
-
test(
|
|
232
|
+
test('should handle JavaScript execution errors gracefully', () => {
|
|
233
233
|
const componentDef: ComponentDefinition = {
|
|
234
|
-
type:
|
|
234
|
+
type: 'component',
|
|
235
235
|
component: {
|
|
236
236
|
interface: {},
|
|
237
|
-
structure: { type:
|
|
237
|
+
structure: { type: 'node', tag: 'div' },
|
|
238
238
|
javascript: "throw new Error('test error');",
|
|
239
239
|
},
|
|
240
240
|
};
|
|
241
241
|
|
|
242
|
-
componentRegistry.register(
|
|
242
|
+
componentRegistry.register('TestComponent', componentDef);
|
|
243
243
|
|
|
244
244
|
const consoleErrorSpy = mock(() => {});
|
|
245
245
|
const originalConsoleError = console.error;
|
|
@@ -252,21 +252,21 @@ describe("ScriptExecutor", () => {
|
|
|
252
252
|
console.error = originalConsoleError;
|
|
253
253
|
});
|
|
254
254
|
|
|
255
|
-
test(
|
|
255
|
+
test('should handle missing component props gracefully', () => {
|
|
256
256
|
const componentDef: ComponentDefinition = {
|
|
257
|
-
type:
|
|
257
|
+
type: 'component',
|
|
258
258
|
component: {
|
|
259
259
|
interface: {},
|
|
260
|
-
structure: { type:
|
|
260
|
+
structure: { type: 'node', tag: 'div' },
|
|
261
261
|
javascript: "console.log('{{name}}');",
|
|
262
262
|
},
|
|
263
263
|
};
|
|
264
264
|
|
|
265
|
-
componentRegistry.register(
|
|
265
|
+
componentRegistry.register('TestComponent', componentDef);
|
|
266
266
|
|
|
267
267
|
// Register element without props
|
|
268
|
-
const mockElement = document.createElement(
|
|
269
|
-
elementRegistry.register([0], mockElement,
|
|
268
|
+
const mockElement = document.createElement('div');
|
|
269
|
+
elementRegistry.register([0], mockElement, 'TestComponent', true);
|
|
270
270
|
|
|
271
271
|
const consoleErrorSpy = mock(() => {});
|
|
272
272
|
const originalConsoleError = console.error;
|
|
@@ -279,11 +279,11 @@ describe("ScriptExecutor", () => {
|
|
|
279
279
|
console.error = originalConsoleError;
|
|
280
280
|
});
|
|
281
281
|
|
|
282
|
-
test(
|
|
282
|
+
test('should handle errors during execution', () => {
|
|
283
283
|
// Force an error by making getAll throw
|
|
284
284
|
const originalGetAll = componentRegistry.getAll.bind(componentRegistry);
|
|
285
285
|
componentRegistry.getAll = mock(() => {
|
|
286
|
-
throw new Error(
|
|
286
|
+
throw new Error('Test error');
|
|
287
287
|
}) as any;
|
|
288
288
|
|
|
289
289
|
// Should not throw - handles error gracefully
|
|
@@ -293,157 +293,157 @@ describe("ScriptExecutor", () => {
|
|
|
293
293
|
componentRegistry.getAll = originalGetAll;
|
|
294
294
|
});
|
|
295
295
|
|
|
296
|
-
test(
|
|
296
|
+
test('should wrap JavaScript in IIFE for scoping', () => {
|
|
297
297
|
const componentDef: ComponentDefinition = {
|
|
298
|
-
type:
|
|
298
|
+
type: 'component',
|
|
299
299
|
component: {
|
|
300
300
|
interface: {},
|
|
301
|
-
structure: { type:
|
|
302
|
-
javascript:
|
|
301
|
+
structure: { type: 'node', tag: 'div' },
|
|
302
|
+
javascript: 'const x = 1;',
|
|
303
303
|
},
|
|
304
304
|
};
|
|
305
305
|
|
|
306
|
-
componentRegistry.register(
|
|
306
|
+
componentRegistry.register('TestComponent', componentDef);
|
|
307
307
|
|
|
308
308
|
scriptExecutor.execute();
|
|
309
309
|
|
|
310
310
|
expect(executedCode.length).toBe(1);
|
|
311
|
-
expect(executedCode[0]).toContain(
|
|
312
|
-
expect(executedCode[0]).toContain(
|
|
311
|
+
expect(executedCode[0]).toContain('(function()');
|
|
312
|
+
expect(executedCode[0]).toContain('})();');
|
|
313
313
|
});
|
|
314
314
|
});
|
|
315
315
|
|
|
316
|
-
describe(
|
|
317
|
-
test(
|
|
316
|
+
describe('executeForComponent', () => {
|
|
317
|
+
test('should execute JavaScript for specific component', () => {
|
|
318
318
|
const componentDef1: ComponentDefinition = {
|
|
319
|
-
type:
|
|
319
|
+
type: 'component',
|
|
320
320
|
component: {
|
|
321
321
|
interface: {},
|
|
322
|
-
structure: { type:
|
|
322
|
+
structure: { type: 'node', tag: 'div' },
|
|
323
323
|
javascript: "console.log('Component1');",
|
|
324
324
|
},
|
|
325
325
|
};
|
|
326
326
|
|
|
327
327
|
const componentDef2: ComponentDefinition = {
|
|
328
|
-
type:
|
|
328
|
+
type: 'component',
|
|
329
329
|
component: {
|
|
330
330
|
interface: {},
|
|
331
|
-
structure: { type:
|
|
331
|
+
structure: { type: 'node', tag: 'div' },
|
|
332
332
|
javascript: "console.log('Component2');",
|
|
333
333
|
},
|
|
334
334
|
};
|
|
335
335
|
|
|
336
|
-
componentRegistry.register(
|
|
337
|
-
componentRegistry.register(
|
|
336
|
+
componentRegistry.register('Component1', componentDef1);
|
|
337
|
+
componentRegistry.register('Component2', componentDef2);
|
|
338
338
|
|
|
339
|
-
scriptExecutor.executeForComponent(
|
|
339
|
+
scriptExecutor.executeForComponent('Component1');
|
|
340
340
|
|
|
341
341
|
// Only Component1 should be executed
|
|
342
342
|
expect(executedCode.length).toBe(1);
|
|
343
|
-
expect(executedCode[0]).toContain(
|
|
343
|
+
expect(executedCode[0]).toContain('Component: Component1');
|
|
344
344
|
expect(executedCode[0]).toContain("console.log('Component1');");
|
|
345
345
|
});
|
|
346
346
|
|
|
347
|
-
test.skip(
|
|
347
|
+
test.skip('should execute JavaScript with templates for specific component (requires @meno/studio ElementRegistry)', () => {
|
|
348
348
|
const componentDef: ComponentDefinition = {
|
|
349
|
-
type:
|
|
349
|
+
type: 'component',
|
|
350
350
|
component: {
|
|
351
351
|
interface: {},
|
|
352
|
-
structure: { type:
|
|
352
|
+
structure: { type: 'node', tag: 'div' },
|
|
353
353
|
javascript: "console.log('{{name}}');",
|
|
354
354
|
},
|
|
355
355
|
};
|
|
356
356
|
|
|
357
|
-
componentRegistry.register(
|
|
357
|
+
componentRegistry.register('TestComponent', componentDef);
|
|
358
358
|
|
|
359
|
-
const mockElement1 = document.createElement(
|
|
360
|
-
const mockElement2 = document.createElement(
|
|
361
|
-
elementRegistry.register([0], mockElement1,
|
|
362
|
-
name:
|
|
359
|
+
const mockElement1 = document.createElement('div');
|
|
360
|
+
const mockElement2 = document.createElement('div');
|
|
361
|
+
elementRegistry.register([0], mockElement1, 'TestComponent', true, {
|
|
362
|
+
name: 'Instance1',
|
|
363
363
|
});
|
|
364
|
-
elementRegistry.register([1], mockElement2,
|
|
365
|
-
name:
|
|
364
|
+
elementRegistry.register([1], mockElement2, 'TestComponent', true, {
|
|
365
|
+
name: 'Instance2',
|
|
366
366
|
});
|
|
367
367
|
|
|
368
|
-
scriptExecutor.executeForComponent(
|
|
368
|
+
scriptExecutor.executeForComponent('TestComponent');
|
|
369
369
|
|
|
370
370
|
// Each instance gets its own execution
|
|
371
371
|
expect(executedCode.length).toBe(2);
|
|
372
372
|
});
|
|
373
373
|
|
|
374
|
-
test(
|
|
374
|
+
test('should skip if component has no JavaScript', () => {
|
|
375
375
|
const componentDef: ComponentDefinition = {
|
|
376
|
-
type:
|
|
376
|
+
type: 'component',
|
|
377
377
|
component: {
|
|
378
378
|
interface: {},
|
|
379
|
-
structure: { type:
|
|
379
|
+
structure: { type: 'node', tag: 'div' },
|
|
380
380
|
},
|
|
381
381
|
};
|
|
382
382
|
|
|
383
|
-
componentRegistry.register(
|
|
383
|
+
componentRegistry.register('TestComponent', componentDef);
|
|
384
384
|
|
|
385
|
-
scriptExecutor.executeForComponent(
|
|
385
|
+
scriptExecutor.executeForComponent('TestComponent');
|
|
386
386
|
|
|
387
387
|
expect(executedCode.length).toBe(0);
|
|
388
388
|
});
|
|
389
389
|
|
|
390
|
-
test(
|
|
390
|
+
test('should handle non-existent component gracefully', () => {
|
|
391
391
|
const consoleErrorSpy = mock(() => {});
|
|
392
392
|
const originalConsoleError = console.error;
|
|
393
393
|
console.error = consoleErrorSpy as any;
|
|
394
394
|
|
|
395
|
-
expect(() => scriptExecutor.executeForComponent(
|
|
395
|
+
expect(() => scriptExecutor.executeForComponent('NonExistent')).not.toThrow();
|
|
396
396
|
|
|
397
397
|
// Restore
|
|
398
398
|
console.error = originalConsoleError;
|
|
399
399
|
});
|
|
400
400
|
|
|
401
|
-
test(
|
|
401
|
+
test('should handle errors during execution for specific component', () => {
|
|
402
402
|
const componentDef: ComponentDefinition = {
|
|
403
|
-
type:
|
|
403
|
+
type: 'component',
|
|
404
404
|
component: {
|
|
405
405
|
interface: {},
|
|
406
|
-
structure: { type:
|
|
406
|
+
structure: { type: 'node', tag: 'div' },
|
|
407
407
|
javascript: "throw new Error('test');",
|
|
408
408
|
},
|
|
409
409
|
};
|
|
410
410
|
|
|
411
|
-
componentRegistry.register(
|
|
411
|
+
componentRegistry.register('TestComponent', componentDef);
|
|
412
412
|
|
|
413
413
|
const consoleErrorSpy = mock(() => {});
|
|
414
414
|
const originalConsoleError = console.error;
|
|
415
415
|
console.error = consoleErrorSpy as any;
|
|
416
416
|
|
|
417
|
-
expect(() => scriptExecutor.executeForComponent(
|
|
417
|
+
expect(() => scriptExecutor.executeForComponent('TestComponent')).not.toThrow();
|
|
418
418
|
|
|
419
419
|
// Restore
|
|
420
420
|
console.error = originalConsoleError;
|
|
421
421
|
});
|
|
422
422
|
});
|
|
423
423
|
|
|
424
|
-
describe(
|
|
424
|
+
describe('per-element bind dedup (defineVars path)', () => {
|
|
425
425
|
// Helper: counter on window that the executed user JS bumps. Reset between
|
|
426
426
|
// tests so cross-test pollution can't mask a stuck observer / repeated bind.
|
|
427
|
-
const COUNTER_KEY =
|
|
427
|
+
const COUNTER_KEY = '__bindCounter';
|
|
428
428
|
const win = window as unknown as Record<string, unknown>;
|
|
429
429
|
|
|
430
430
|
beforeEach(() => {
|
|
431
431
|
win[COUNTER_KEY] = 0;
|
|
432
|
-
document.body.innerHTML =
|
|
432
|
+
document.body.innerHTML = '';
|
|
433
433
|
});
|
|
434
434
|
|
|
435
435
|
afterEach(() => {
|
|
436
436
|
delete win[COUNTER_KEY];
|
|
437
437
|
delete (window as unknown as { __menoShouldBind?: unknown }).__menoShouldBind;
|
|
438
|
-
document.body.innerHTML =
|
|
438
|
+
document.body.innerHTML = '';
|
|
439
439
|
});
|
|
440
440
|
|
|
441
|
-
const registerCounterComponent = (name =
|
|
441
|
+
const registerCounterComponent = (name = 'BoundComp') => {
|
|
442
442
|
const def: ComponentDefinition = {
|
|
443
|
-
type:
|
|
443
|
+
type: 'component',
|
|
444
444
|
component: {
|
|
445
445
|
interface: {},
|
|
446
|
-
structure: { type:
|
|
446
|
+
structure: { type: 'node', tag: 'div' },
|
|
447
447
|
javascript: `window.${COUNTER_KEY} = (window.${COUNTER_KEY} || 0) + 1;`,
|
|
448
448
|
defineVars: true,
|
|
449
449
|
},
|
|
@@ -453,16 +453,16 @@ describe("ScriptExecutor", () => {
|
|
|
453
453
|
};
|
|
454
454
|
|
|
455
455
|
const mountInstance = (componentName: string, propsByComponent: Record<string, unknown> = {}) => {
|
|
456
|
-
const el = document.createElement(
|
|
457
|
-
el.setAttribute(
|
|
458
|
-
el.setAttribute(
|
|
456
|
+
const el = document.createElement('div');
|
|
457
|
+
el.setAttribute('data-component', componentName);
|
|
458
|
+
el.setAttribute('data-props', JSON.stringify({ [componentName]: propsByComponent }));
|
|
459
459
|
document.body.appendChild(el);
|
|
460
460
|
return el;
|
|
461
461
|
};
|
|
462
462
|
|
|
463
|
-
test(
|
|
463
|
+
test('re-executing execute() does not re-run JS on the same element', () => {
|
|
464
464
|
registerCounterComponent();
|
|
465
|
-
mountInstance(
|
|
465
|
+
mountInstance('BoundComp');
|
|
466
466
|
// ScriptExecutor under test is the one from outer beforeEach — it
|
|
467
467
|
// installed its host hook on window during construction.
|
|
468
468
|
|
|
@@ -475,47 +475,47 @@ describe("ScriptExecutor", () => {
|
|
|
475
475
|
|
|
476
476
|
test("a newly mounted element binds on the next execute(), already-bound ones don't re-run", () => {
|
|
477
477
|
registerCounterComponent();
|
|
478
|
-
mountInstance(
|
|
478
|
+
mountInstance('BoundComp');
|
|
479
479
|
|
|
480
480
|
scriptExecutor.execute();
|
|
481
481
|
expect(win[COUNTER_KEY]).toBe(1);
|
|
482
482
|
|
|
483
483
|
// Simulate a structural commit that added another instance of the same component.
|
|
484
|
-
mountInstance(
|
|
484
|
+
mountInstance('BoundComp');
|
|
485
485
|
scriptExecutor.execute();
|
|
486
486
|
|
|
487
487
|
// Only the new element should have run; the original is already bound.
|
|
488
488
|
expect(win[COUNTER_KEY]).toBe(2);
|
|
489
489
|
});
|
|
490
490
|
|
|
491
|
-
test(
|
|
491
|
+
test('two component names on the same element each bind once independently', () => {
|
|
492
492
|
// Register A and B, each with defineVars and its own counter.
|
|
493
493
|
const defA: ComponentDefinition = {
|
|
494
|
-
type:
|
|
494
|
+
type: 'component',
|
|
495
495
|
component: {
|
|
496
496
|
interface: {},
|
|
497
|
-
structure: { type:
|
|
497
|
+
structure: { type: 'node', tag: 'div' },
|
|
498
498
|
javascript: `window.__counterA = (window.__counterA || 0) + 1;`,
|
|
499
499
|
defineVars: true,
|
|
500
500
|
},
|
|
501
501
|
};
|
|
502
502
|
const defB: ComponentDefinition = {
|
|
503
|
-
type:
|
|
503
|
+
type: 'component',
|
|
504
504
|
component: {
|
|
505
505
|
interface: {},
|
|
506
|
-
structure: { type:
|
|
506
|
+
structure: { type: 'node', tag: 'div' },
|
|
507
507
|
javascript: `window.__counterB = (window.__counterB || 0) + 1;`,
|
|
508
508
|
defineVars: true,
|
|
509
509
|
},
|
|
510
510
|
};
|
|
511
|
-
componentRegistry.register(
|
|
512
|
-
componentRegistry.register(
|
|
511
|
+
componentRegistry.register('A', defA);
|
|
512
|
+
componentRegistry.register('B', defB);
|
|
513
513
|
|
|
514
514
|
// Compose A and B on a single element via the space-separated data-component
|
|
515
515
|
// token list. querySelectorAll('[data-component~="A"]') matches this too.
|
|
516
|
-
const el = document.createElement(
|
|
517
|
-
el.setAttribute(
|
|
518
|
-
el.setAttribute(
|
|
516
|
+
const el = document.createElement('div');
|
|
517
|
+
el.setAttribute('data-component', 'A B');
|
|
518
|
+
el.setAttribute('data-props', JSON.stringify({ A: {}, B: {} }));
|
|
519
519
|
document.body.appendChild(el);
|
|
520
520
|
|
|
521
521
|
scriptExecutor.execute();
|
|
@@ -529,9 +529,9 @@ describe("ScriptExecutor", () => {
|
|
|
529
529
|
delete (window as unknown as { __counterB?: unknown }).__counterB;
|
|
530
530
|
});
|
|
531
531
|
|
|
532
|
-
test(
|
|
532
|
+
test('executeForElement bypasses the bind dedup (prop-edit reactivity must still re-run)', () => {
|
|
533
533
|
registerCounterComponent();
|
|
534
|
-
const el = mountInstance(
|
|
534
|
+
const el = mountInstance('BoundComp');
|
|
535
535
|
|
|
536
536
|
scriptExecutor.execute();
|
|
537
537
|
expect(win[COUNTER_KEY]).toBe(1);
|
|
@@ -539,20 +539,20 @@ describe("ScriptExecutor", () => {
|
|
|
539
539
|
// Prop edit on the same element — the editor calls executeForElement
|
|
540
540
|
// to push fresh props. It MUST run the body again even though
|
|
541
541
|
// boundElements already marks (el, "BoundComp") as bound.
|
|
542
|
-
scriptExecutor.executeForElement(
|
|
542
|
+
scriptExecutor.executeForElement('BoundComp', el, {});
|
|
543
543
|
expect(win[COUNTER_KEY]).toBe(2);
|
|
544
544
|
|
|
545
|
-
scriptExecutor.executeForElement(
|
|
545
|
+
scriptExecutor.executeForElement('BoundComp', el, {});
|
|
546
546
|
expect(win[COUNTER_KEY]).toBe(3);
|
|
547
547
|
});
|
|
548
548
|
|
|
549
|
-
test(
|
|
549
|
+
test('with no host hook installed the wrapper binds on every execute() (legacy fallback)', () => {
|
|
550
550
|
// Tear down the host hook the constructor installed. This is what
|
|
551
551
|
// direct-browser / non-runtime contexts look like — no editor host.
|
|
552
552
|
delete (window as unknown as { __menoShouldBind?: unknown }).__menoShouldBind;
|
|
553
553
|
|
|
554
554
|
registerCounterComponent();
|
|
555
|
-
mountInstance(
|
|
555
|
+
mountInstance('BoundComp');
|
|
556
556
|
|
|
557
557
|
scriptExecutor.execute();
|
|
558
558
|
scriptExecutor.execute();
|
|
@@ -564,37 +564,37 @@ describe("ScriptExecutor", () => {
|
|
|
564
564
|
});
|
|
565
565
|
});
|
|
566
566
|
|
|
567
|
-
describe(
|
|
568
|
-
test.skip(
|
|
567
|
+
describe('integration', () => {
|
|
568
|
+
test.skip('should handle full execution cycle with multiple components and instances (requires @meno/studio ElementRegistry)', () => {
|
|
569
569
|
const componentDef1: ComponentDefinition = {
|
|
570
|
-
type:
|
|
570
|
+
type: 'component',
|
|
571
571
|
component: {
|
|
572
572
|
interface: {},
|
|
573
|
-
structure: { type:
|
|
573
|
+
structure: { type: 'node', tag: 'div' },
|
|
574
574
|
javascript: "console.log('Static1');",
|
|
575
575
|
},
|
|
576
576
|
};
|
|
577
577
|
|
|
578
578
|
const componentDef2: ComponentDefinition = {
|
|
579
|
-
type:
|
|
579
|
+
type: 'component',
|
|
580
580
|
component: {
|
|
581
581
|
interface: {},
|
|
582
|
-
structure: { type:
|
|
582
|
+
structure: { type: 'node', tag: 'div' },
|
|
583
583
|
javascript: "console.log('{{id}}');",
|
|
584
584
|
},
|
|
585
585
|
};
|
|
586
586
|
|
|
587
|
-
componentRegistry.register(
|
|
588
|
-
componentRegistry.register(
|
|
587
|
+
componentRegistry.register('StaticComponent', componentDef1);
|
|
588
|
+
componentRegistry.register('DynamicComponent', componentDef2);
|
|
589
589
|
|
|
590
590
|
// Register multiple instances of dynamic component
|
|
591
|
-
const mockElement1 = document.createElement(
|
|
592
|
-
const mockElement2 = document.createElement(
|
|
593
|
-
elementRegistry.register([0], mockElement1,
|
|
594
|
-
id:
|
|
591
|
+
const mockElement1 = document.createElement('div');
|
|
592
|
+
const mockElement2 = document.createElement('div');
|
|
593
|
+
elementRegistry.register([0], mockElement1, 'DynamicComponent', true, {
|
|
594
|
+
id: '1',
|
|
595
595
|
});
|
|
596
|
-
elementRegistry.register([1], mockElement2,
|
|
597
|
-
id:
|
|
596
|
+
elementRegistry.register([1], mockElement2, 'DynamicComponent', true, {
|
|
597
|
+
id: '2',
|
|
598
598
|
});
|
|
599
599
|
|
|
600
600
|
scriptExecutor.execute();
|
|
@@ -605,4 +605,3 @@ describe("ScriptExecutor", () => {
|
|
|
605
605
|
});
|
|
606
606
|
});
|
|
607
607
|
});
|
|
608
|
-
|