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/i18n.ts
CHANGED
|
@@ -10,9 +10,7 @@ import type { I18nValue, I18nConfig, LocaleConfig } from './types/components';
|
|
|
10
10
|
*/
|
|
11
11
|
export const DEFAULT_I18N_CONFIG: I18nConfig = {
|
|
12
12
|
defaultLocale: 'en',
|
|
13
|
-
locales: [
|
|
14
|
-
{ code: 'en', name: 'English', nativeName: 'English', langTag: 'en-US' }
|
|
15
|
-
],
|
|
13
|
+
locales: [{ code: 'en', name: 'English', nativeName: 'English', langTag: 'en-US' }],
|
|
16
14
|
};
|
|
17
15
|
|
|
18
16
|
// ============================================
|
|
@@ -23,21 +21,21 @@ export const DEFAULT_I18N_CONFIG: I18nConfig = {
|
|
|
23
21
|
* Get array of locale codes from config
|
|
24
22
|
*/
|
|
25
23
|
export function getLocaleCodes(config: I18nConfig): string[] {
|
|
26
|
-
return config.locales.map(loc => loc.code);
|
|
24
|
+
return config.locales.map((loc) => loc.code);
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
/**
|
|
30
28
|
* Find a locale config by its code
|
|
31
29
|
*/
|
|
32
30
|
export function findLocaleByCode(config: I18nConfig, code: string): LocaleConfig | undefined {
|
|
33
|
-
return config.locales.find(loc => loc.code === code);
|
|
31
|
+
return config.locales.find((loc) => loc.code === code);
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
/**
|
|
37
35
|
* Check if a locale code is valid/exists in config
|
|
38
36
|
*/
|
|
39
37
|
export function isValidLocaleCode(config: I18nConfig, code: string): boolean {
|
|
40
|
-
return config.locales.some(loc => loc.code === code);
|
|
38
|
+
return config.locales.some((loc) => loc.code === code);
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
// ============================================
|
|
@@ -112,11 +110,7 @@ export function isI18nValue(value: unknown): value is I18nValue {
|
|
|
112
110
|
* Fallback order: exact locale -> default locale -> first available -> empty
|
|
113
111
|
* Works with any value type (strings, arrays for list props, etc.)
|
|
114
112
|
*/
|
|
115
|
-
export function resolveTranslation(
|
|
116
|
-
value: I18nValue,
|
|
117
|
-
locale: string,
|
|
118
|
-
config: I18nConfig
|
|
119
|
-
): unknown {
|
|
113
|
+
export function resolveTranslation(value: I18nValue, locale: string, config: I18nConfig): unknown {
|
|
120
114
|
// Try exact locale match (any type - string, array, etc.)
|
|
121
115
|
if (locale in value && value[locale] !== undefined && locale !== '_i18n') {
|
|
122
116
|
return value[locale];
|
|
@@ -136,9 +130,7 @@ export function resolveTranslation(
|
|
|
136
130
|
|
|
137
131
|
// Return empty string for string i18n, empty array for list i18n
|
|
138
132
|
// Check if any value is an array to determine the type
|
|
139
|
-
const hasArrayValue = Object.entries(value).some(
|
|
140
|
-
([k, v]) => k !== '_i18n' && Array.isArray(v)
|
|
141
|
-
);
|
|
133
|
+
const hasArrayValue = Object.entries(value).some(([k, v]) => k !== '_i18n' && Array.isArray(v));
|
|
142
134
|
return hasArrayValue ? [] : '';
|
|
143
135
|
}
|
|
144
136
|
|
|
@@ -146,11 +138,7 @@ export function resolveTranslation(
|
|
|
146
138
|
* Resolve a value that might be an I18nValue or a regular value
|
|
147
139
|
* Returns the original value if not an I18nValue
|
|
148
140
|
*/
|
|
149
|
-
export function resolveI18nValue(
|
|
150
|
-
value: unknown,
|
|
151
|
-
locale: string,
|
|
152
|
-
config: I18nConfig
|
|
153
|
-
): unknown {
|
|
141
|
+
export function resolveI18nValue(value: unknown, locale: string, config: I18nConfig): unknown {
|
|
154
142
|
if (isI18nValue(value)) {
|
|
155
143
|
return resolveTranslation(value, locale, config);
|
|
156
144
|
}
|
|
@@ -163,7 +151,7 @@ export function resolveI18nValue(
|
|
|
163
151
|
export function resolveI18nInProps(
|
|
164
152
|
props: Record<string, unknown>,
|
|
165
153
|
locale: string,
|
|
166
|
-
config: I18nConfig
|
|
154
|
+
config: I18nConfig,
|
|
167
155
|
): Record<string, unknown> {
|
|
168
156
|
const resolved: Record<string, unknown> = {};
|
|
169
157
|
|
|
@@ -171,16 +159,10 @@ export function resolveI18nInProps(
|
|
|
171
159
|
if (isI18nValue(value)) {
|
|
172
160
|
resolved[key] = resolveTranslation(value, locale, config);
|
|
173
161
|
} else if (Array.isArray(value)) {
|
|
174
|
-
resolved[key] = value.map((item) =>
|
|
175
|
-
isI18nValue(item) ? resolveTranslation(item, locale, config) : item
|
|
176
|
-
);
|
|
162
|
+
resolved[key] = value.map((item) => (isI18nValue(item) ? resolveTranslation(item, locale, config) : item));
|
|
177
163
|
} else if (typeof value === 'object' && value !== null) {
|
|
178
164
|
// Recursively resolve nested objects (but not I18nValue which is already handled)
|
|
179
|
-
resolved[key] = resolveI18nInProps(
|
|
180
|
-
value as Record<string, unknown>,
|
|
181
|
-
locale,
|
|
182
|
-
config
|
|
183
|
-
);
|
|
165
|
+
resolved[key] = resolveI18nInProps(value as Record<string, unknown>, locale, config);
|
|
184
166
|
} else {
|
|
185
167
|
resolved[key] = value;
|
|
186
168
|
}
|
|
@@ -195,15 +177,16 @@ export function resolveI18nInProps(
|
|
|
195
177
|
*/
|
|
196
178
|
export function extractLocaleFromPath(
|
|
197
179
|
path: string,
|
|
198
|
-
config: I18nConfig
|
|
180
|
+
config: I18nConfig,
|
|
199
181
|
): { locale: string | null; pathWithoutLocale: string } {
|
|
200
182
|
// Remove leading slash and split
|
|
201
183
|
const cleanPath = path.startsWith('/') ? path.slice(1) : path;
|
|
202
184
|
const segments = cleanPath.split('/');
|
|
203
185
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const
|
|
186
|
+
const firstSegment = segments[0];
|
|
187
|
+
if (firstSegment !== undefined && isValidLocaleCode(config, firstSegment)) {
|
|
188
|
+
const locale = firstSegment;
|
|
189
|
+
const pathWithoutLocale = `/${segments.slice(1).join('/')}`;
|
|
207
190
|
return { locale, pathWithoutLocale: pathWithoutLocale || '/' };
|
|
208
191
|
}
|
|
209
192
|
|
|
@@ -215,7 +198,7 @@ export function extractLocaleFromPath(
|
|
|
215
198
|
* e.g., ('/about', 'pl') -> '/pl/about'
|
|
216
199
|
*/
|
|
217
200
|
export function buildLocalizedPath(path: string, locale: string): string {
|
|
218
|
-
const cleanPath = path.startsWith('/') ? path :
|
|
201
|
+
const cleanPath = path.startsWith('/') ? path : `/${path}`;
|
|
219
202
|
return `/${locale}${cleanPath === '/' ? '' : cleanPath}`;
|
|
220
203
|
}
|
|
221
204
|
|
|
@@ -235,17 +218,14 @@ export interface LocaleContext {
|
|
|
235
218
|
* Parse locale from path and return full context with effective locale
|
|
236
219
|
* Combines extractLocaleFromPath + defaultLocale resolution in one call
|
|
237
220
|
*/
|
|
238
|
-
export function parseLocaleFromPath(
|
|
239
|
-
path: string,
|
|
240
|
-
config: I18nConfig
|
|
241
|
-
): LocaleContext {
|
|
221
|
+
export function parseLocaleFromPath(path: string, config: I18nConfig): LocaleContext {
|
|
242
222
|
const { locale, pathWithoutLocale } = extractLocaleFromPath(path, config);
|
|
243
223
|
const effectiveLocale = locale || config.defaultLocale;
|
|
244
224
|
|
|
245
225
|
return {
|
|
246
226
|
locale: effectiveLocale,
|
|
247
227
|
pathWithoutLocale,
|
|
248
|
-
isDefaultLocale: effectiveLocale === config.defaultLocale
|
|
228
|
+
isDefaultLocale: effectiveLocale === config.defaultLocale,
|
|
249
229
|
};
|
|
250
230
|
}
|
|
251
231
|
|
package/lib/shared/index.ts
CHANGED
|
@@ -26,6 +26,10 @@ export * from './viewportUnits';
|
|
|
26
26
|
export * from './colorProperties';
|
|
27
27
|
export * from './cssNamedColors';
|
|
28
28
|
export * from './utilityClassMapper';
|
|
29
|
+
export { splitVariantPrefix, normalizeBreakpointVariant } from './utilityClassNames';
|
|
30
|
+
// Utility-class catalog pieces — the seed for the Styles panel's class-bar autocomplete (§13 Phase 5).
|
|
31
|
+
// Selective (not `export *`) to keep the barrel collision-free.
|
|
32
|
+
export { propertyMap, staticUtilityReverse, keywordValues, presetClassReverse } from './utilityClassConfig';
|
|
29
33
|
export * from './elementClassName';
|
|
30
34
|
export * from './styleValueRegistry';
|
|
31
35
|
|
|
@@ -86,8 +90,17 @@ export {
|
|
|
86
90
|
CommentThreadEntrySchema,
|
|
87
91
|
CommentNodeIdentitySchema,
|
|
88
92
|
validateComment,
|
|
93
|
+
// Permissions validators
|
|
94
|
+
PermissionRoleSchema,
|
|
95
|
+
PermissionRuleSchema,
|
|
96
|
+
PermissionGrantSchema,
|
|
97
|
+
PermissionsPolicySchema,
|
|
98
|
+
validatePermissionsPolicy,
|
|
89
99
|
} from './validation';
|
|
90
100
|
|
|
101
|
+
// Permission resolver (pure)
|
|
102
|
+
export * from './permissions';
|
|
103
|
+
|
|
91
104
|
// Utils
|
|
92
105
|
export * from './utils';
|
|
93
106
|
|
|
@@ -116,6 +129,10 @@ export { isSupportedTemplateExpression } from './expressionEvaluator';
|
|
|
116
129
|
// Path security utilities
|
|
117
130
|
export * from './pathSecurity';
|
|
118
131
|
|
|
132
|
+
// Netlify locale-scoped 404 rules + the managed netlify.toml block (shared by
|
|
133
|
+
// every netlify.toml producer and the studio save-config sync)
|
|
134
|
+
export * from './netlifyLocale404';
|
|
135
|
+
|
|
119
136
|
// Interactive style mapping utilities
|
|
120
137
|
export * from './interactiveStyleMappings';
|
|
121
138
|
|
|
@@ -126,6 +143,16 @@ export * from './richtext';
|
|
|
126
143
|
export * from './errors';
|
|
127
144
|
export * from './friendlyError';
|
|
128
145
|
export { logRuntimeError, logNetworkError, setErrorHandler } from './errorLogger';
|
|
146
|
+
export {
|
|
147
|
+
createLogger,
|
|
148
|
+
logger,
|
|
149
|
+
setLogLevel,
|
|
150
|
+
getLogLevel,
|
|
151
|
+
setLogSink,
|
|
152
|
+
type Logger,
|
|
153
|
+
type LogLevel,
|
|
154
|
+
type LogRecord,
|
|
155
|
+
} from './logger';
|
|
129
156
|
|
|
130
157
|
// Global template context
|
|
131
158
|
export * from './globalTemplateContext';
|
|
@@ -53,29 +53,30 @@ function rewriteSvgBlock(svgBlock: string): string {
|
|
|
53
53
|
const classDeclarations = new Map<string, string>();
|
|
54
54
|
const styleBlocksHandled: string[] = [];
|
|
55
55
|
|
|
56
|
-
let m: RegExpExecArray | null;
|
|
57
|
-
while (
|
|
56
|
+
let m: RegExpExecArray | null = styleBlockRe.exec(svgBlock);
|
|
57
|
+
while (m !== null) {
|
|
58
58
|
const fullStyleTag = m[0];
|
|
59
|
-
const rawContent = m[1];
|
|
59
|
+
const rawContent = m[1] ?? '';
|
|
60
|
+
m = styleBlockRe.exec(svgBlock);
|
|
60
61
|
// Strip CDATA wrapper if present (DOMPurify already unwraps it, but the
|
|
61
62
|
// pre-sanitize call path may see one).
|
|
62
|
-
const content = stripCssComments(
|
|
63
|
-
rawContent.replace(/^\s*<!\[CDATA\[/, '').replace(/\]\]>\s*$/, '')
|
|
64
|
-
);
|
|
63
|
+
const content = stripCssComments(rawContent.replace(/^\s*<!\[CDATA\[/, '').replace(/\]\]>\s*$/, ''));
|
|
65
64
|
|
|
66
65
|
// Pull out every simple `.cls { ... }` rule we can match.
|
|
67
66
|
const localClasses = new Map<string, string>();
|
|
68
67
|
let remaining = content;
|
|
69
|
-
let ruleMatch: RegExpExecArray | null;
|
|
70
68
|
const ruleRe = new RegExp(RULE_RE.source, 'g');
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const
|
|
69
|
+
let ruleMatch: RegExpExecArray | null = ruleRe.exec(content);
|
|
70
|
+
while (ruleMatch !== null) {
|
|
71
|
+
const className = ruleMatch[1] ?? '';
|
|
72
|
+
const body = (ruleMatch[2] ?? '').trim().replace(/;\s*$/, '');
|
|
73
|
+
const matchedRule = ruleMatch[0];
|
|
74
|
+
ruleMatch = ruleRe.exec(content);
|
|
74
75
|
// Skip rules whose body contains a `{` — that means we mis-bracketed.
|
|
75
76
|
if (body.includes('{')) continue;
|
|
76
77
|
const prev = localClasses.get(className);
|
|
77
78
|
localClasses.set(className, prev ? mergeIntoStyleAttr(prev, body) : body);
|
|
78
|
-
remaining = remaining.replace(
|
|
79
|
+
remaining = remaining.replace(matchedRule, '');
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
// If anything non-trivial is left in the <style> body, leave the block
|
|
@@ -99,12 +100,12 @@ function rewriteSvgBlock(svgBlock: string): string {
|
|
|
99
100
|
for (const [className, decls] of classDeclarations) {
|
|
100
101
|
const elementRe = new RegExp(
|
|
101
102
|
`(<[A-Za-z][\\w-]*\\b[^>]*?\\sclass="[^"]*\\b${escapeForRegex(className)}\\b[^"]*"[^>]*?)(/?>)`,
|
|
102
|
-
'g'
|
|
103
|
+
'g',
|
|
103
104
|
);
|
|
104
105
|
out = out.replace(elementRe, (_full, openHead: string, closing: string) => {
|
|
105
106
|
const styleAttrMatch = openHead.match(/\sstyle="([^"]*)"/);
|
|
106
107
|
if (styleAttrMatch) {
|
|
107
|
-
const merged = mergeIntoStyleAttr(styleAttrMatch[1], decls);
|
|
108
|
+
const merged = mergeIntoStyleAttr(styleAttrMatch[1] ?? '', decls);
|
|
108
109
|
return openHead.replace(/\sstyle="[^"]*"/, ` style="${merged}"`) + closing;
|
|
109
110
|
}
|
|
110
111
|
return `${openHead} style="${decls}"${closing}`;
|
|
@@ -46,9 +46,7 @@ describe('interactiveStyleMappings', () => {
|
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
it('returns false when no mappings present', () => {
|
|
49
|
-
const styles: InteractiveStyles = [
|
|
50
|
-
{ postfix: ':hover', style: { base: { backgroundColor: '#0070f3' } } },
|
|
51
|
-
];
|
|
49
|
+
const styles: InteractiveStyles = [{ postfix: ':hover', style: { base: { backgroundColor: '#0070f3' } } }];
|
|
52
50
|
expect(hasInteractiveStyleMappings(styles)).toBe(false);
|
|
53
51
|
});
|
|
54
52
|
|
|
@@ -89,9 +87,7 @@ describe('interactiveStyleMappings', () => {
|
|
|
89
87
|
|
|
90
88
|
describe('extractInteractiveStyleMappings', () => {
|
|
91
89
|
it('returns unchanged styles when no mappings', () => {
|
|
92
|
-
const styles: InteractiveStyles = [
|
|
93
|
-
{ postfix: ':hover', style: { base: { backgroundColor: '#0070f3' } } },
|
|
94
|
-
];
|
|
90
|
+
const styles: InteractiveStyles = [{ postfix: ':hover', style: { base: { backgroundColor: '#0070f3' } } }];
|
|
95
91
|
|
|
96
92
|
const { resolvedStyles, mappings } = extractInteractiveStyleMappings(styles);
|
|
97
93
|
|
|
@@ -106,9 +102,7 @@ describe('interactiveStyleMappings', () => {
|
|
|
106
102
|
values: { primary: '#0070f3', secondary: '#gray' },
|
|
107
103
|
};
|
|
108
104
|
|
|
109
|
-
const styles: InteractiveStyles = [
|
|
110
|
-
{ postfix: ':hover', style: { backgroundColor: mapping } },
|
|
111
|
-
];
|
|
105
|
+
const styles: InteractiveStyles = [{ postfix: ':hover', style: { backgroundColor: mapping } }];
|
|
112
106
|
|
|
113
107
|
const { resolvedStyles, mappings } = extractInteractiveStyleMappings(styles);
|
|
114
108
|
|
|
@@ -121,7 +115,7 @@ describe('interactiveStyleMappings', () => {
|
|
|
121
115
|
variableIndex: 0,
|
|
122
116
|
});
|
|
123
117
|
|
|
124
|
-
expect(resolvedStyles[0]
|
|
118
|
+
expect(resolvedStyles[0]!.style).toEqual({
|
|
125
119
|
backgroundColor: 'var(--is-0)',
|
|
126
120
|
});
|
|
127
121
|
});
|
|
@@ -133,17 +127,15 @@ describe('interactiveStyleMappings', () => {
|
|
|
133
127
|
values: { primary: '#0070f3' },
|
|
134
128
|
};
|
|
135
129
|
|
|
136
|
-
const styles: InteractiveStyles = [
|
|
137
|
-
{ postfix: ':hover', style: { base: { backgroundColor: mapping } } },
|
|
138
|
-
];
|
|
130
|
+
const styles: InteractiveStyles = [{ postfix: ':hover', style: { base: { backgroundColor: mapping } } }];
|
|
139
131
|
|
|
140
132
|
const { resolvedStyles, mappings } = extractInteractiveStyleMappings(styles);
|
|
141
133
|
|
|
142
134
|
expect(mappings).toHaveLength(1);
|
|
143
|
-
expect(mappings[0]
|
|
144
|
-
expect(mappings[0]
|
|
135
|
+
expect(mappings[0]!.breakpoint).toBe('base');
|
|
136
|
+
expect(mappings[0]!.variableIndex).toBe(0);
|
|
145
137
|
|
|
146
|
-
expect((resolvedStyles[0]
|
|
138
|
+
expect((resolvedStyles[0]!.style as any).base).toEqual({
|
|
147
139
|
backgroundColor: 'var(--is-0)',
|
|
148
140
|
});
|
|
149
141
|
});
|
|
@@ -179,14 +171,14 @@ describe('interactiveStyleMappings', () => {
|
|
|
179
171
|
const { resolvedStyles, mappings } = extractInteractiveStyleMappings(styles);
|
|
180
172
|
|
|
181
173
|
expect(mappings).toHaveLength(3);
|
|
182
|
-
expect(mappings[0]
|
|
183
|
-
expect(mappings[0]
|
|
184
|
-
expect(mappings[1]
|
|
185
|
-
expect(mappings[1]
|
|
186
|
-
expect(mappings[2]
|
|
187
|
-
expect(mappings[2]
|
|
188
|
-
|
|
189
|
-
const resolved = resolvedStyles[0]
|
|
174
|
+
expect(mappings[0]!.breakpoint).toBe('base');
|
|
175
|
+
expect(mappings[0]!.variableIndex).toBe(0);
|
|
176
|
+
expect(mappings[1]!.breakpoint).toBe('tablet');
|
|
177
|
+
expect(mappings[1]!.variableIndex).toBe(1);
|
|
178
|
+
expect(mappings[2]!.breakpoint).toBe('mobile');
|
|
179
|
+
expect(mappings[2]!.variableIndex).toBe(2);
|
|
180
|
+
|
|
181
|
+
const resolved = resolvedStyles[0]!.style as any;
|
|
190
182
|
expect(resolved.base.backgroundColor).toBe('var(--is-0)');
|
|
191
183
|
expect(resolved.tablet.backgroundColor).toBe('var(--is-1)');
|
|
192
184
|
expect(resolved.mobile.backgroundColor).toBe('var(--is-2)');
|
|
@@ -216,7 +208,7 @@ describe('interactiveStyleMappings', () => {
|
|
|
216
208
|
expect(mappings).toHaveLength(2);
|
|
217
209
|
// Note: order depends on Object.entries iteration order
|
|
218
210
|
|
|
219
|
-
const resolved = resolvedStyles[0]
|
|
211
|
+
const resolved = resolvedStyles[0]!.style as any;
|
|
220
212
|
expect(resolved.base.backgroundColor).toMatch(/var\(--is-\d+\)/);
|
|
221
213
|
expect(resolved.base.color).toMatch(/var\(--is-\d+\)/);
|
|
222
214
|
});
|
|
@@ -245,7 +237,7 @@ describe('interactiveStyleMappings', () => {
|
|
|
245
237
|
|
|
246
238
|
expect(mappings).toHaveLength(1);
|
|
247
239
|
|
|
248
|
-
const resolved = resolvedStyles[0]
|
|
240
|
+
const resolved = resolvedStyles[0]!.style as any;
|
|
249
241
|
expect(resolved.base.backgroundColor).toBe('var(--is-0)');
|
|
250
242
|
expect(resolved.base.transform).toBe('scale(1.05)');
|
|
251
243
|
expect(resolved.base.opacity).toBe('0.9');
|
|
@@ -271,13 +263,13 @@ describe('interactiveStyleMappings', () => {
|
|
|
271
263
|
const { resolvedStyles, mappings } = extractInteractiveStyleMappings(styles);
|
|
272
264
|
|
|
273
265
|
expect(mappings).toHaveLength(2);
|
|
274
|
-
expect(mappings[0]
|
|
275
|
-
expect(mappings[0]
|
|
276
|
-
expect(mappings[1]
|
|
277
|
-
expect(mappings[1]
|
|
266
|
+
expect(mappings[0]!.ruleIndex).toBe(0);
|
|
267
|
+
expect(mappings[0]!.variableIndex).toBe(0);
|
|
268
|
+
expect(mappings[1]!.ruleIndex).toBe(1);
|
|
269
|
+
expect(mappings[1]!.variableIndex).toBe(1);
|
|
278
270
|
|
|
279
|
-
expect((resolvedStyles[0]
|
|
280
|
-
expect((resolvedStyles[1]
|
|
271
|
+
expect((resolvedStyles[0]!.style as any).base.backgroundColor).toBe('var(--is-0)');
|
|
272
|
+
expect((resolvedStyles[1]!.style as any).base.backgroundColor).toBe('var(--is-1)');
|
|
281
273
|
});
|
|
282
274
|
|
|
283
275
|
it('preserves postfix in resolved styles', () => {
|
|
@@ -287,13 +279,11 @@ describe('interactiveStyleMappings', () => {
|
|
|
287
279
|
values: { primary: '#0070f3' },
|
|
288
280
|
};
|
|
289
281
|
|
|
290
|
-
const styles: InteractiveStyles = [
|
|
291
|
-
{ postfix: ':hover', style: { base: { backgroundColor: mapping } } },
|
|
292
|
-
];
|
|
282
|
+
const styles: InteractiveStyles = [{ postfix: ':hover', style: { base: { backgroundColor: mapping } } }];
|
|
293
283
|
|
|
294
284
|
const { resolvedStyles } = extractInteractiveStyleMappings(styles);
|
|
295
285
|
|
|
296
|
-
expect(resolvedStyles[0]
|
|
286
|
+
expect(resolvedStyles[0]!.postfix).toBe(':hover');
|
|
297
287
|
});
|
|
298
288
|
});
|
|
299
289
|
|
|
@@ -305,9 +295,7 @@ describe('interactiveStyleMappings', () => {
|
|
|
305
295
|
values: { primary: '#0070f3', secondary: '#gray' },
|
|
306
296
|
};
|
|
307
297
|
|
|
308
|
-
const styles: InteractiveStyles = [
|
|
309
|
-
{ postfix: ':hover', style: { base: { backgroundColor: mapping } } },
|
|
310
|
-
];
|
|
298
|
+
const styles: InteractiveStyles = [{ postfix: ':hover', style: { base: { backgroundColor: mapping } } }];
|
|
311
299
|
|
|
312
300
|
const { mappings } = extractInteractiveStyleMappings(styles);
|
|
313
301
|
const cssVariables = resolveExtractedMappings(mappings, { variant: 'primary' });
|
|
@@ -351,9 +339,7 @@ describe('interactiveStyleMappings', () => {
|
|
|
351
339
|
values: { primary: '#0070f3', secondary: '#gray' },
|
|
352
340
|
};
|
|
353
341
|
|
|
354
|
-
const styles: InteractiveStyles = [
|
|
355
|
-
{ postfix: ':hover', style: { base: { backgroundColor: mapping } } },
|
|
356
|
-
];
|
|
342
|
+
const styles: InteractiveStyles = [{ postfix: ':hover', style: { base: { backgroundColor: mapping } } }];
|
|
357
343
|
|
|
358
344
|
const { mappings } = extractInteractiveStyleMappings(styles);
|
|
359
345
|
const cssVariables = resolveExtractedMappings(mappings, { variant: 'purple' });
|
|
@@ -368,9 +354,7 @@ describe('interactiveStyleMappings', () => {
|
|
|
368
354
|
values: { primary: '#0070f3' },
|
|
369
355
|
};
|
|
370
356
|
|
|
371
|
-
const styles: InteractiveStyles = [
|
|
372
|
-
{ postfix: ':hover', style: { base: { backgroundColor: mapping } } },
|
|
373
|
-
];
|
|
357
|
+
const styles: InteractiveStyles = [{ postfix: ':hover', style: { base: { backgroundColor: mapping } } }];
|
|
374
358
|
|
|
375
359
|
const { mappings } = extractInteractiveStyleMappings(styles);
|
|
376
360
|
const cssVariables = resolveExtractedMappings(mappings, {});
|
|
@@ -385,9 +369,7 @@ describe('interactiveStyleMappings', () => {
|
|
|
385
369
|
values: { primary: '#0070f3' },
|
|
386
370
|
};
|
|
387
371
|
|
|
388
|
-
const styles: InteractiveStyles = [
|
|
389
|
-
{ postfix: ':hover', style: { base: { backgroundColor: mapping } } },
|
|
390
|
-
];
|
|
372
|
+
const styles: InteractiveStyles = [{ postfix: ':hover', style: { base: { backgroundColor: mapping } } }];
|
|
391
373
|
|
|
392
374
|
const { mappings } = extractInteractiveStyleMappings(styles);
|
|
393
375
|
const cssVariables = resolveExtractedMappings(mappings, { variant: null });
|
|
@@ -402,9 +384,7 @@ describe('interactiveStyleMappings', () => {
|
|
|
402
384
|
values: { true: '0.5', false: '1' },
|
|
403
385
|
};
|
|
404
386
|
|
|
405
|
-
const styles: InteractiveStyles = [
|
|
406
|
-
{ postfix: ':hover', style: { base: { opacity: mapping } } },
|
|
407
|
-
];
|
|
387
|
+
const styles: InteractiveStyles = [{ postfix: ':hover', style: { base: { opacity: mapping } } }];
|
|
408
388
|
|
|
409
389
|
const { mappings } = extractInteractiveStyleMappings(styles);
|
|
410
390
|
const cssVariables = resolveExtractedMappings(mappings, { disabled: true });
|
|
@@ -419,9 +399,7 @@ describe('interactiveStyleMappings', () => {
|
|
|
419
399
|
values: { '1': '10px', '2': '20px', '3': '30px' },
|
|
420
400
|
};
|
|
421
401
|
|
|
422
|
-
const styles: InteractiveStyles = [
|
|
423
|
-
{ postfix: ':hover', style: { base: { padding: mapping } } },
|
|
424
|
-
];
|
|
402
|
+
const styles: InteractiveStyles = [{ postfix: ':hover', style: { base: { padding: mapping } } }];
|
|
425
403
|
|
|
426
404
|
const { mappings } = extractInteractiveStyleMappings(styles);
|
|
427
405
|
const cssVariables = resolveExtractedMappings(mappings, { size: 2 });
|
|
@@ -12,13 +12,7 @@
|
|
|
12
12
|
* // resolvedStyles[0].style.base.backgroundColor === 'var(--is-0)'
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import type {
|
|
16
|
-
InteractiveStyles,
|
|
17
|
-
InteractiveStyleRule,
|
|
18
|
-
StyleMapping,
|
|
19
|
-
StyleObject,
|
|
20
|
-
ResponsiveStyleObject,
|
|
21
|
-
} from './types/styles';
|
|
15
|
+
import type { InteractiveStyles, StyleMapping, StyleObject, ResponsiveStyleObject } from './types/styles';
|
|
22
16
|
import type { PropDefinition } from './types/components';
|
|
23
17
|
|
|
24
18
|
/**
|
|
@@ -26,10 +20,7 @@ import type { PropDefinition } from './types/components';
|
|
|
26
20
|
*/
|
|
27
21
|
export function isStyleMapping(value: unknown): value is StyleMapping {
|
|
28
22
|
return (
|
|
29
|
-
typeof value === 'object' &&
|
|
30
|
-
value !== null &&
|
|
31
|
-
'_mapping' in value &&
|
|
32
|
-
(value as StyleMapping)._mapping === true
|
|
23
|
+
typeof value === 'object' && value !== null && '_mapping' in value && (value as StyleMapping)._mapping === true
|
|
33
24
|
);
|
|
34
25
|
}
|
|
35
26
|
|
|
@@ -72,9 +63,8 @@ export function getVariableName(index: number): string {
|
|
|
72
63
|
*/
|
|
73
64
|
function hasAnyMappings(style: StyleObject | ResponsiveStyleObject): boolean {
|
|
74
65
|
// Check if it's a responsive style (has 'base' or known breakpoint keys)
|
|
75
|
-
const isResponsive =
|
|
76
|
-
key === 'base' || key === 'tablet' || key === 'mobile'
|
|
77
|
-
);
|
|
66
|
+
const isResponsive =
|
|
67
|
+
'base' in style || Object.keys(style).some((key) => key === 'base' || key === 'tablet' || key === 'mobile');
|
|
78
68
|
|
|
79
69
|
if (isResponsive) {
|
|
80
70
|
const responsive = style as ResponsiveStyleObject;
|
|
@@ -111,9 +101,7 @@ export function hasInteractiveStyleMappings(interactiveStyles: InteractiveStyles
|
|
|
111
101
|
* @param interactiveStyles - Array of interactive style rules
|
|
112
102
|
* @returns Object with resolved styles (var() references) and extracted mappings
|
|
113
103
|
*/
|
|
114
|
-
export function extractInteractiveStyleMappings(
|
|
115
|
-
interactiveStyles: InteractiveStyles
|
|
116
|
-
): ExtractionResult {
|
|
104
|
+
export function extractInteractiveStyleMappings(interactiveStyles: InteractiveStyles): ExtractionResult {
|
|
117
105
|
const mappings: ExtractedMapping[] = [];
|
|
118
106
|
let variableIndex = 0;
|
|
119
107
|
|
|
@@ -121,9 +109,8 @@ export function extractInteractiveStyleMappings(
|
|
|
121
109
|
const style = rule.style;
|
|
122
110
|
|
|
123
111
|
// Check if it's a responsive style
|
|
124
|
-
const isResponsive =
|
|
125
|
-
key === 'base' || key === 'tablet' || key === 'mobile'
|
|
126
|
-
);
|
|
112
|
+
const isResponsive =
|
|
113
|
+
'base' in style || Object.keys(style).some((key) => key === 'base' || key === 'tablet' || key === 'mobile');
|
|
127
114
|
|
|
128
115
|
if (isResponsive) {
|
|
129
116
|
const responsive = style as ResponsiveStyleObject;
|
|
@@ -203,7 +190,7 @@ export function extractInteractiveStyleMappings(
|
|
|
203
190
|
*/
|
|
204
191
|
export function resolveExtractedMappings(
|
|
205
192
|
mappings: ExtractedMapping[],
|
|
206
|
-
props: Record<string, unknown
|
|
193
|
+
props: Record<string, unknown>,
|
|
207
194
|
): Record<string, string> {
|
|
208
195
|
const cssVariables: Record<string, string> = {};
|
|
209
196
|
|
|
@@ -250,7 +237,7 @@ export function resolveExtractedMappings(
|
|
|
250
237
|
*/
|
|
251
238
|
export function createStyleMappingFromProps(
|
|
252
239
|
componentPropDefs: Record<string, PropDefinition>,
|
|
253
|
-
currentValue: string | number
|
|
240
|
+
currentValue: string | number,
|
|
254
241
|
): StyleMapping | null {
|
|
255
242
|
// Find a prop to map to (prefer 'variant' if it exists, otherwise use first prop)
|
|
256
243
|
const propToMap = componentPropDefs.variant ? 'variant' : Object.keys(componentPropDefs)[0];
|
|
@@ -273,12 +260,12 @@ export function createStyleMappingFromProps(
|
|
|
273
260
|
});
|
|
274
261
|
} else {
|
|
275
262
|
// No options, create a default mapping
|
|
276
|
-
mappingValues
|
|
263
|
+
mappingValues.default = currentValue;
|
|
277
264
|
}
|
|
278
265
|
|
|
279
266
|
return {
|
|
280
267
|
_mapping: true,
|
|
281
268
|
prop: propToMap,
|
|
282
|
-
values: mappingValues
|
|
269
|
+
values: mappingValues,
|
|
283
270
|
};
|
|
284
271
|
}
|