@styleflow.app/flowpress-astro-core 1.0.0-beta.4 → 1.0.0-beta.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +249 -1
- package/README.md +104 -5
- package/dist/accessibility-panel.d.ts +2 -0
- package/dist/accessibility-panel.d.ts.map +1 -0
- package/dist/accessibility-panel.js +81 -0
- package/dist/accessibility-panel.js.map +1 -0
- package/dist/astro/BaseLayout.astro +34 -17
- package/dist/astro/CompositionRenderer.astro +168 -0
- package/dist/astro/DefaultBlockAdapter.astro +37 -0
- package/dist/astro/FontStylesheets.astro +35 -0
- package/dist/astro/GutenbergRenderer.astro +267 -80
- package/dist/astro/Media.astro +27 -0
- package/dist/astro/StyleflowElement.astro +25 -0
- package/dist/astro/ThemeRuntime.astro +26 -0
- package/dist/astro/blocks/CarouselBlock.astro +11 -10
- package/dist/astro/blocks/CarouselItemBlock.astro +4 -4
- package/dist/astro/blocks/ColumnBlock.astro +4 -5
- package/dist/astro/blocks/CoverBlock.astro +158 -0
- package/dist/astro/blocks/FormBlock.astro +23 -20
- package/dist/astro/blocks/GridBlock.astro +5 -4
- package/dist/astro/blocks/HeroBlock.astro +6 -6
- package/dist/astro/blocks/ImageBlock.astro +6 -6
- package/dist/astro/blocks/ListItemFallback.astro +9 -7
- package/dist/astro/blocks/NumberSpinnerBlock.astro +29 -22
- package/dist/astro/blocks/SemanticElement.astro +35 -0
- package/dist/astro/blocks/SiteLogoBlock.astro +54 -0
- package/dist/astro/blocks/TextBlock.astro +33 -28
- package/dist/astro/blocks/ThemeToggleBlock.astro +13 -0
- package/dist/astro/blocks/cover.d.ts +13 -0
- package/dist/astro/blocks/cover.d.ts.map +1 -0
- package/dist/astro/blocks/cover.js +105 -0
- package/dist/astro/blocks/cover.js.map +1 -0
- package/dist/astro/blocks/cover.ts +119 -0
- package/dist/astro/blocks/helpers.d.ts +10 -1
- package/dist/astro/blocks/helpers.d.ts.map +1 -1
- package/dist/astro/blocks/helpers.js +55 -39
- package/dist/astro/blocks/helpers.js.map +1 -1
- package/dist/astro/blocks/helpers.ts +69 -44
- package/dist/astro/motion/AccordionRuntime.astro +9 -0
- package/dist/astro/motion/MotionBoot.astro +21 -0
- package/dist/astro/motion/MotionRuntime.astro +31 -0
- package/dist/astro/motion/accordion.css +163 -0
- package/dist/astro/motion/accordion.d.ts +3 -0
- package/dist/astro/motion/accordion.d.ts.map +1 -0
- package/dist/astro/motion/accordion.js +98 -0
- package/dist/astro/motion/accordion.js.map +1 -0
- package/dist/astro/motion/accordion.ts +109 -0
- package/dist/astro/motion/motion-controller.d.ts +12 -0
- package/dist/astro/motion/motion-controller.d.ts.map +1 -0
- package/dist/astro/motion/motion-controller.js +293 -0
- package/dist/astro/motion/motion-controller.js.map +1 -0
- package/dist/astro/motion/motion-controller.ts +377 -0
- package/dist/astro/motion/motion.css +546 -0
- package/dist/astro/motion/motion.d.ts +127 -0
- package/dist/astro/motion/motion.d.ts.map +1 -0
- package/dist/astro/motion/motion.js +255 -0
- package/dist/astro/motion/motion.js.map +1 -0
- package/dist/astro/motion/motion.ts +419 -0
- package/dist/astro/native/Blob.astro +113 -0
- package/dist/astro/native/BlobBlock.astro +52 -0
- package/dist/astro/native/CustomFieldValue.astro +88 -0
- package/dist/astro/native/LevelTag.astro +20 -0
- package/dist/astro/native/MapBlock.astro +41 -0
- package/dist/astro/native/NativeHtmlBlock.astro +12 -0
- package/dist/astro/native/NativeIconBlock.astro +42 -0
- package/dist/astro/native/ProjectTimelineBlock.astro +34 -0
- package/dist/astro/native/ReservedLogin.astro +107 -0
- package/dist/astro/native/ResolvedBlocks.astro +91 -0
- package/dist/astro/native/SyncedPatternContent.astro +94 -0
- package/dist/astro/native/TermFieldValue.astro +39 -0
- package/dist/astro/native/Timeline.astro +22 -0
- package/dist/astro/native/TimelineCardBlock.astro +7 -0
- package/dist/astro/native/blob/blob-shapes.generated.d.ts +2 -0
- package/dist/astro/native/blob/blob-shapes.generated.d.ts.map +1 -0
- package/dist/astro/native/blob/blob-shapes.generated.js +2 -0
- package/dist/astro/native/blob/blob-shapes.generated.js.map +1 -0
- package/dist/astro/native/blob/blob-shapes.generated.ts +1 -0
- package/dist/astro/native/blob/config.d.ts +49 -0
- package/dist/astro/native/blob/config.d.ts.map +1 -0
- package/dist/astro/native/blob/config.js +86 -0
- package/dist/astro/native/blob/config.js.map +1 -0
- package/dist/astro/native/blob/config.ts +132 -0
- package/dist/astro/native/blob/controller.d.ts +11 -0
- package/dist/astro/native/blob/controller.d.ts.map +1 -0
- package/dist/astro/native/blob/controller.js +240 -0
- package/dist/astro/native/blob/controller.js.map +1 -0
- package/dist/astro/native/blob/controller.ts +248 -0
- package/dist/astro/native/blob/geometry.d.ts +2 -0
- package/dist/astro/native/blob/geometry.d.ts.map +1 -0
- package/dist/astro/native/blob/geometry.js +2 -0
- package/dist/astro/native/blob/geometry.js.map +1 -0
- package/dist/astro/native/blob/geometry.ts +1 -0
- package/dist/astro/native/blob/ids.d.ts +7 -0
- package/dist/astro/native/blob/ids.d.ts.map +1 -0
- package/dist/astro/native/blob/ids.js +11 -0
- package/dist/astro/native/blob/ids.js.map +1 -0
- package/dist/astro/native/blob/ids.ts +11 -0
- package/dist/astro/native/blob.css +83 -0
- package/dist/astro/native/block-sizing.css +34 -0
- package/dist/astro/native/button-template.d.ts +31 -0
- package/dist/astro/native/button-template.d.ts.map +1 -0
- package/dist/astro/native/button-template.js +54 -0
- package/dist/astro/native/button-template.js.map +1 -0
- package/dist/astro/native/button-template.ts +92 -0
- package/dist/astro/native/button.d.ts +13 -0
- package/dist/astro/native/button.d.ts.map +1 -0
- package/dist/astro/native/button.js +26 -0
- package/dist/astro/native/button.js.map +1 -0
- package/dist/astro/native/button.ts +26 -0
- package/dist/astro/native/core-block.astro +18 -0
- package/dist/astro/native/core-button-fallback.astro +43 -0
- package/dist/astro/native/core-button.astro +65 -0
- package/dist/astro/native/core-buttons.astro +14 -0
- package/dist/astro/native/core-group.astro +25 -0
- package/dist/astro/native/core-home-link.astro +12 -0
- package/dist/astro/native/core-html.astro +8 -0
- package/dist/astro/native/core-icon.astro +7 -0
- package/dist/astro/native/core-image.astro +137 -0
- package/dist/astro/native/core-navigation-link.astro +71 -0
- package/dist/astro/native/core-navigation-submenu.astro +33 -0
- package/dist/astro/native/core-navigation.astro +101 -0
- package/dist/astro/native/core-page-list-data-item.astro +19 -0
- package/dist/astro/native/core-page-list-item.astro +8 -0
- package/dist/astro/native/core-page-list.astro +40 -0
- package/dist/astro/native/core-post-date.astro +21 -0
- package/dist/astro/native/core-post-excerpt.astro +26 -0
- package/dist/astro/native/core-post-featured-image.astro +40 -0
- package/dist/astro/native/core-post-template-fallback.astro +30 -0
- package/dist/astro/native/core-post-template.astro +23 -0
- package/dist/astro/native/core-post-terms.astro +47 -0
- package/dist/astro/native/core-post-title.astro +23 -0
- package/dist/astro/native/core-query-no-results.astro +12 -0
- package/dist/astro/native/core-query.astro +22 -0
- package/dist/astro/native/core-separator.astro +18 -0
- package/dist/astro/native/core-site-title.astro +16 -0
- package/dist/astro/native/core-term-description.astro +12 -0
- package/dist/astro/native/core-term-name.astro +21 -0
- package/dist/astro/native/core-term-template.astro +30 -0
- package/dist/astro/native/core-terms-query.astro +19 -0
- package/dist/astro/native/core-transparent.astro +11 -0
- package/dist/astro/native/flowpress-navigation-controller.d.ts +2 -0
- package/dist/astro/native/flowpress-navigation-controller.d.ts.map +1 -0
- package/dist/astro/native/flowpress-navigation-controller.js +217 -0
- package/dist/astro/native/flowpress-navigation-controller.js.map +1 -0
- package/dist/astro/native/flowpress-navigation-controller.ts +215 -0
- package/dist/astro/native/flowpress-navigation.css +17 -0
- package/dist/astro/native/grid-bleed.d.ts +2 -0
- package/dist/astro/native/grid-bleed.d.ts.map +1 -0
- package/dist/astro/native/grid-bleed.js +123 -0
- package/dist/astro/native/grid-bleed.js.map +1 -0
- package/dist/astro/native/grid.css +180 -0
- package/dist/astro/native/grid.d.ts +17 -0
- package/dist/astro/native/grid.d.ts.map +1 -0
- package/dist/astro/native/grid.js +103 -0
- package/dist/astro/native/grid.js.map +1 -0
- package/dist/astro/native/grid.ts +118 -0
- package/dist/astro/native/group.css +36 -0
- package/dist/astro/native/group.d.ts +15 -0
- package/dist/astro/native/group.d.ts.map +1 -0
- package/dist/astro/native/group.js +66 -0
- package/dist/astro/native/group.js.map +1 -0
- package/dist/astro/native/group.ts +61 -0
- package/dist/astro/native/html.d.ts +6 -0
- package/dist/astro/native/html.d.ts.map +1 -0
- package/dist/astro/native/html.js +10 -0
- package/dist/astro/native/html.js.map +1 -0
- package/dist/astro/native/html.ts +9 -0
- package/dist/astro/native/icon.d.ts +3 -0
- package/dist/astro/native/icon.d.ts.map +1 -0
- package/dist/astro/native/icon.js +23 -0
- package/dist/astro/native/icon.js.map +1 -0
- package/dist/astro/native/icon.ts +21 -0
- package/dist/astro/native/image.d.ts +5 -0
- package/dist/astro/native/image.d.ts.map +1 -0
- package/dist/astro/native/image.js +65 -0
- package/dist/astro/native/image.js.map +1 -0
- package/dist/astro/native/image.ts +56 -0
- package/dist/astro/native/inline-text.css +15 -0
- package/dist/astro/native/map.d.ts +14 -0
- package/dist/astro/native/map.d.ts.map +1 -0
- package/dist/astro/native/map.js +60 -0
- package/dist/astro/native/map.js.map +1 -0
- package/dist/astro/native/map.ts +70 -0
- package/dist/astro/native/motion-preference.d.ts +50 -0
- package/dist/astro/native/motion-preference.d.ts.map +1 -0
- package/dist/astro/native/motion-preference.js +132 -0
- package/dist/astro/native/motion-preference.js.map +1 -0
- package/dist/astro/native/motion-preference.ts +158 -0
- package/dist/astro/native/motion.d.ts +101 -0
- package/dist/astro/native/motion.d.ts.map +1 -0
- package/dist/astro/native/motion.js +168 -0
- package/dist/astro/native/motion.js.map +1 -0
- package/dist/astro/native/motion.ts +312 -0
- package/dist/astro/native/query-carousel.d.ts +12 -0
- package/dist/astro/native/query-carousel.d.ts.map +1 -0
- package/dist/astro/native/query-carousel.js +36 -0
- package/dist/astro/native/query-carousel.js.map +1 -0
- package/dist/astro/native/query-carousel.ts +56 -0
- package/dist/astro/native/query-loop.d.ts +38 -0
- package/dist/astro/native/query-loop.d.ts.map +1 -0
- package/dist/astro/native/query-loop.js +20 -0
- package/dist/astro/native/query-loop.js.map +1 -0
- package/dist/astro/native/query-loop.ts +67 -0
- package/dist/astro/native/registry.d.ts +3 -0
- package/dist/astro/native/registry.d.ts.map +1 -0
- package/dist/astro/native/registry.js +81 -0
- package/dist/astro/native/registry.js.map +1 -0
- package/dist/astro/native/registry.ts +82 -0
- package/dist/astro/native/sf-block-binding.astro +20 -0
- package/dist/astro/native/sf-post-field.astro +9 -0
- package/dist/astro/native/sf-term-field.astro +9 -0
- package/dist/astro/native/timeline.css +4 -0
- package/dist/astro/native/timeline.d.ts +28 -0
- package/dist/astro/native/timeline.d.ts.map +1 -0
- package/dist/astro/native/timeline.js +43 -0
- package/dist/astro/native/timeline.js.map +1 -0
- package/dist/astro/native/timeline.ts +79 -0
- package/dist/astro/preferences/AccessibilityPanel.astro +105 -0
- package/dist/astro/preferences/ColorModeToggle.astro +26 -0
- package/dist/astro/preferences/MotionToggle.astro +27 -0
- package/dist/astro/preferences/PreferencesRuntime.astro +9 -0
- package/dist/astro/preferences/ThemeToggle.astro +30 -0
- package/dist/astro/preferences/Toggle.astro +50 -0
- package/dist/astro/preferences/preferences.css +125 -0
- package/dist/block-renderers.d.ts +23 -3
- package/dist/block-renderers.d.ts.map +1 -1
- package/dist/block-renderers.js.map +1 -1
- package/dist/build-cache.d.ts +8 -0
- package/dist/build-cache.d.ts.map +1 -0
- package/dist/build-cache.js +81 -0
- package/dist/build-cache.js.map +1 -0
- package/dist/client.d.ts +23 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +78 -39
- package/dist/client.js.map +1 -1
- package/dist/composition.d.ts +14 -0
- package/dist/composition.d.ts.map +1 -0
- package/dist/composition.js +125 -0
- package/dist/composition.js.map +1 -0
- package/dist/default-blocks.d.ts +9 -0
- package/dist/default-blocks.d.ts.map +1 -0
- package/dist/default-blocks.js +117 -0
- package/dist/default-blocks.js.map +1 -0
- package/dist/env.d.ts +9 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +20 -0
- package/dist/env.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/media.d.ts +20 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +106 -0
- package/dist/media.js.map +1 -0
- package/dist/motion-preference.d.ts +50 -0
- package/dist/motion-preference.d.ts.map +1 -0
- package/dist/motion-preference.js +132 -0
- package/dist/motion-preference.js.map +1 -0
- package/dist/preferences-runtime.d.ts +3 -0
- package/dist/preferences-runtime.d.ts.map +1 -0
- package/dist/preferences-runtime.js +23 -0
- package/dist/preferences-runtime.js.map +1 -0
- package/dist/preferences-styleflow.d.ts +3 -0
- package/dist/preferences-styleflow.d.ts.map +1 -0
- package/dist/preferences-styleflow.js +14 -0
- package/dist/preferences-styleflow.js.map +1 -0
- package/dist/preferences.d.ts +4 -0
- package/dist/preferences.d.ts.map +1 -0
- package/dist/preferences.js +4 -0
- package/dist/preferences.js.map +1 -0
- package/dist/reserved-area.d.ts +10 -0
- package/dist/reserved-area.d.ts.map +1 -0
- package/dist/reserved-area.js +93 -0
- package/dist/reserved-area.js.map +1 -0
- package/dist/styleflow.d.ts +18 -1
- package/dist/styleflow.d.ts.map +1 -1
- package/dist/styleflow.js +82 -11
- package/dist/styleflow.js.map +1 -1
- package/dist/svg-media-runtime.d.ts +3 -0
- package/dist/svg-media-runtime.d.ts.map +1 -0
- package/dist/svg-media-runtime.js +33 -0
- package/dist/svg-media-runtime.js.map +1 -0
- package/dist/svg-media-types.d.ts +11 -0
- package/dist/svg-media-types.d.ts.map +1 -0
- package/dist/svg-media-types.js +2 -0
- package/dist/svg-media-types.js.map +1 -0
- package/dist/svg-media.d.ts +13 -0
- package/dist/svg-media.d.ts.map +1 -0
- package/dist/svg-media.js +47 -0
- package/dist/svg-media.js.map +1 -0
- package/dist/template-hierarchy.d.ts +0 -7
- package/dist/template-hierarchy.d.ts.map +1 -1
- package/dist/template-hierarchy.js +0 -21
- package/dist/template-hierarchy.js.map +1 -1
- package/dist/text.d.ts +3 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +6 -0
- package/dist/text.js.map +1 -0
- package/dist/theme-runtime.d.ts +16 -0
- package/dist/theme-runtime.d.ts.map +1 -0
- package/dist/theme-runtime.js +100 -0
- package/dist/theme-runtime.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +75 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/vivid-colors-preference.d.ts +31 -0
- package/dist/vivid-colors-preference.d.ts.map +1 -0
- package/dist/vivid-colors-preference.js +102 -0
- package/dist/vivid-colors-preference.js.map +1 -0
- package/package.json +58 -7
- package/dist/astro/DefaultTemplate.astro +0 -42
- package/dist/templates.d.ts +0 -19
- package/dist/templates.d.ts.map +0 -1
- package/dist/templates.js +0 -20
- package/dist/templates.js.map +0 -1
package/dist/styleflow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styleflow.js","sourceRoot":"","sources":["../src/styleflow.ts"],"names":[],"mappings":"AA4BA,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC;AAErE,8EAA8E;AAC9E,MAAM,UAAU,4BAA4B,CAC1C,KAA4B,EAC5B,QAA+B,EAC/B,QAA2B,EAC3B,UAA0C,EAAE;IAE5C,MAAM,QAAQ,GAA0B,EAAE,GAAG,QAAQ,EAAE,CAAC;IACxD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,KAAK,KAAK,SAAS,IAAI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sourcesContent":["export interface StyleflowContractAxes {\n color: { tones: string[]; intensitiesByTone: Record<string, string[]>; surfaces: string[]; foregrounds: string[] };\n layout: { roles: string[]; densities: string[]; breakpoints: Array<{ id: string; minWidth: number }> };\n typography: { types: string[]; variantsByType: Record<string, string[]>; weights: string[] };\n interaction: { priorities: string[]; states: string[] };\n}\nexport interface StyleflowContract {\n defaultTheme?: string;\n semantic: {\n themes: string[];\n axes: StyleflowContractAxes;\n agentPolicy: { defaults: { layoutRole: string; density: string; typography: { ty: string; v: string; w: string } } };\n };\n}\nexport type DynamicStyleflowProps = Record<string, unknown>;\nexport interface StyleflowDiagnostic {\n code: \"FP_STYLEFLOW_INVALID\" | \"FP_STYLEFLOW_FALLBACK\";\n prop: string;\n value: unknown;\n fallback?: unknown;\n blocking: boolean;\n message: string;\n}\nexport interface ResolveDynamicStyleflowOptions {\n strict?: boolean;\n onDiagnostic?: (diagnostic: StyleflowDiagnostic) => void;\n}\n\nconst INHERITED_PROPS = new Set([\"tone\", \"intensity\", \"foreground\"]);\n\n/** Validate CMS-authored props against the grouped vNext project contract. */\nexport function resolveDynamicStyleflowProps(\n input: DynamicStyleflowProps,\n defaults: DynamicStyleflowProps,\n contract: StyleflowContract,\n options: ResolveDynamicStyleflowOptions = {}\n): DynamicStyleflowProps {\n const resolved: DynamicStyleflowProps = { ...defaults };\n for (const [key, value] of Object.entries(input)) {\n if (value === undefined || value === null || value === \"\") continue;\n if (INHERITED_PROPS.has(key) && value === \"inherit\") { delete resolved[key]; continue; }\n if (key === \"interactionState\") {\n invalid(key, value, undefined, options); delete resolved[key]; continue;\n }\n const allowed = allowedValues(key, input, defaults, contract);\n if (!allowed) { resolved[key] = value; continue; }\n if (typeof value === \"string\" && allowed.includes(value)) { resolved[key] = value; continue; }\n const fallback = explicitFallback(key, defaults, contract);\n invalid(key, value, fallback, options);\n if (fallback === undefined) delete resolved[key]; else resolved[key] = fallback;\n }\n // Validate dependent defaults too: a default is not permission to emit a\n // coordinate absent from the current project contract.\n for (const key of [\"theme\", \"tone\", \"intensity\", \"surface\", \"foreground\", \"layoutRole\", \"density\", \"ty\", \"v\", \"w\", \"interactivePriority\"]) {\n if (resolved[key] === undefined) continue;\n const allowed = allowedValues(key, resolved, defaults, contract);\n if (allowed && !allowed.includes(String(resolved[key]))) {\n invalid(key, resolved[key], undefined, options); delete resolved[key];\n }\n }\n return resolved;\n}\n\nfunction allowedValues(\n key: string, input: DynamicStyleflowProps, defaults: DynamicStyleflowProps,\n contract: StyleflowContract\n): string[] | undefined {\n const axes = contract.semantic.axes;\n if (key === \"theme\") return contract.semantic.themes;\n if (key === \"tone\") return axes.color.tones;\n if (key === \"intensity\") {\n const tone = String(input.tone ?? defaults.tone ?? \"\");\n return tone ? axes.color.intensitiesByTone[tone] ?? [] : [...new Set(Object.values(axes.color.intensitiesByTone).flat())];\n }\n if (key === \"surface\") return axes.color.surfaces;\n if (key === \"foreground\") return axes.color.foregrounds;\n if (key === \"layoutRole\") return axes.layout.roles;\n if (key === \"density\") return axes.layout.densities;\n if (key === \"ty\") return axes.typography.types;\n if (key === \"v\") {\n const ty = String(input.ty ?? defaults.ty ?? contract.semantic.agentPolicy.defaults.typography.ty);\n return axes.typography.variantsByType[ty] ?? [];\n }\n if (key === \"w\") return axes.typography.weights;\n if (key === \"interactivePriority\") return axes.interaction.priorities;\n return undefined;\n}\n\nfunction explicitFallback(key: string, defaults: DynamicStyleflowProps, contract: StyleflowContract): unknown {\n if (defaults[key] !== undefined) return defaults[key];\n if (key === \"layoutRole\") return contract.semantic.agentPolicy.defaults.layoutRole;\n if (key === \"density\") return contract.semantic.agentPolicy.defaults.density;\n if (key === \"ty\" || key === \"v\" || key === \"w\") return contract.semantic.agentPolicy.defaults.typography[key];\n if (key === \"theme\") return contract.defaultTheme;\n return undefined;\n}\nfunction invalid(key: string, value: unknown, fallback: unknown, options: ResolveDynamicStyleflowOptions): void {\n const diagnostic: StyleflowDiagnostic = {\n code: fallback === undefined ? \"FP_STYLEFLOW_INVALID\" : \"FP_STYLEFLOW_FALLBACK\",\n prop: key, value, ...(fallback !== undefined ? { fallback } : {}),\n blocking: options.strict === true,\n message: fallback === undefined\n ? `Styleflow prop ${key}=${JSON.stringify(value)} is not in the grouped project contract.`\n : `Styleflow prop ${key}=${JSON.stringify(value)} fell back to ${JSON.stringify(fallback)}.`\n };\n (options.onDiagnostic ?? ((item) => console.warn(`[${item.code}] ${item.message}`)))(diagnostic);\n if (options.strict) throw new Error(`${diagnostic.code}: ${diagnostic.message}`);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"styleflow.js","sourceRoot":"","sources":["../src/styleflow.ts"],"names":[],"mappings":"AAmCA,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC;AAC9E,MAAM,qBAAqB,GAAG;IAC5B,OAAO;IACP,MAAM;IACN,WAAW;IACX,SAAS;IACT,YAAY;IACZ,SAAS;IACT,IAAI;IACJ,GAAG;IACH,GAAG;IACH,YAAY;IACZ,qBAAqB;IACrB,cAAc;IACd,UAAU;IACV,WAAW;IACX,OAAO;IACP,UAAU;IACV,cAAc;CACN,CAAC;AAEX,iFAAiF;AACjF,MAAM,UAAU,mCAAmC,CACjD,UAAmC,EACnC,QAA4B,EAC5B,WAAkC,EAAE,EACpC,UAA0C,EAAE;IAE5C,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAC9B,qBAAqB;SAClB,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC;SAC9C,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CACxC,CAAC;IACF,MAAM,aAAa,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;IACtC,IAAI,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,S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I,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,0CAA0C;YAC1F,CAAC,CAAC,kBAAkB,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,iBAAiB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG;KAC/F,CAAC;IACF,CAAC,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;IACjG,IAAI,OAAO,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,UAAU,CAAC,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;AACnF,CAAC","sourcesContent":["export interface StyleflowContractAxes {\n color: { tones: string[]; intensitiesByTone: Record<string, string[]>; surfaces: string[]; foregrounds: string[] };\n layout: { roles: string[]; densities: string[]; breakpoints: Array<{ id: string; minWidth: number }> };\n typography: {\n types: string[];\n variantsByType: Record<string, string[]>;\n weightsByType: Record<string, string[]>;\n tagMappings: Array<{ tag: string; tyId?: string; variantId?: string; weightId?: string }>;\n };\n interaction: { priorities: string[]; states: string[] };\n}\nexport interface StyleflowContract {\n defaultTheme?: string;\n semantic: {\n themes: string[];\n axes: StyleflowContractAxes;\n agentPolicy: { defaults: { layoutRole: string; density: string; typography: { ty: string; v: string; w: string } } };\n };\n}\nexport type DynamicStyleflowProps = Record<string, unknown>;\nexport interface StyleflowDiagnostic {\n code: \"FP_STYLEFLOW_INVALID\" | \"FP_STYLEFLOW_FALLBACK\";\n prop: string;\n value: unknown;\n fallback?: unknown;\n blocking: boolean;\n message: string;\n}\nexport interface ResolveDynamicStyleflowOptions {\n strict?: boolean;\n /** Concrete tone inherited from a rendered ancestor; never emitted as an attribute. */\n effectiveTone?: string | undefined;\n onDiagnostic?: (diagnostic: StyleflowDiagnostic) => void;\n}\n\nconst INHERITED_PROPS = new Set([\"theme\", \"tone\", \"intensity\", \"foreground\"]);\nconst BLOCK_STYLEFLOW_PROPS = [\n \"theme\",\n \"tone\",\n \"intensity\",\n \"surface\",\n \"layoutRole\",\n \"density\",\n \"ty\",\n \"v\",\n \"w\",\n \"foreground\",\n \"interactivePriority\",\n \"noBackground\",\n \"noBorder\",\n \"noPadding\",\n \"noGap\",\n \"noRadius\",\n \"noForeground\"\n] as const;\n\n/** Select and validate the semantic attributes authored on a Gutenberg block. */\nexport function resolveFlowpressBlockStyleflowProps(\n attributes: Record<string, unknown>,\n contract?: StyleflowContract,\n defaults: DynamicStyleflowProps = {},\n options: ResolveDynamicStyleflowOptions = {}\n): DynamicStyleflowProps {\n const input = Object.fromEntries(\n BLOCK_STYLEFLOW_PROPS\n .filter((key) => attributes[key] !== undefined)\n .map((key) => [key, attributes[key]])\n );\n const blockDefaults = { ...defaults };\n if (![\"ty\", \"v\", \"w\", \"variant\", \"weight\"].some((key) => (\n attributes[key] !== undefined && attributes[key] !== null && attributes[key] !== \"\"\n ))) {\n for (const key of [\"ty\", \"v\", \"w\"]) delete blockDefaults[key];\n }\n if (contract) {\n return resolveDynamicStyleflowProps(input, blockDefaults, contract, options);\n }\n\n const resolved = { ...blockDefaults, ...input };\n for (const key of [\"ty\", \"v\", \"w\"]) {\n if (resolved[key] === \"\" || resolved[key] === null) delete resolved[key];\n }\n for (const key of INHERITED_PROPS) {\n if (input[key] === \"inherit\") delete resolved[key];\n }\n return resolved;\n}\n\n/**\n * Resolve a second, namespaced set of Styleflow coordinates stored on a block.\n *\n * A `scrimTone` attribute is therefore validated exactly like `tone`, without\n * leaking the prefixed authoring attribute into the rendered DOM.\n */\nexport function resolvePrefixedFlowpressBlockStyleflowProps(\n attributes: Record<string, unknown>,\n prefix: string,\n contract?: StyleflowContract,\n defaults: DynamicStyleflowProps = {},\n options: ResolveDynamicStyleflowOptions = {}\n): DynamicStyleflowProps {\n const prefixed = Object.fromEntries(BLOCK_STYLEFLOW_PROPS.flatMap((key) => {\n const name = `${prefix}${key.charAt(0).toUpperCase()}${key.slice(1)}`;\n return attributes[name] === undefined ? [] : [[key, attributes[name]]];\n }));\n return resolveFlowpressBlockStyleflowProps(\n prefixed,\n contract,\n defaults,\n options\n );\n}\n\n/** Validate CMS-authored props against the grouped vNext project contract. */\nexport function resolveDynamicStyleflowProps(\n input: DynamicStyleflowProps,\n defaults: DynamicStyleflowProps,\n contract: StyleflowContract,\n options: ResolveDynamicStyleflowOptions = {}\n): DynamicStyleflowProps {\n const resolved: DynamicStyleflowProps = { ...defaults };\n for (const [key, value] of Object.entries(input)) {\n if (value === undefined || value === null || value === \"\") continue;\n if (INHERITED_PROPS.has(key) && value === \"inherit\") { delete resolved[key]; continue; }\n if (key === \"interactionState\") {\n invalid(key, value, undefined, options); delete resolved[key]; continue;\n }\n const allowed = allowedValues(key, input, defaults, contract, options.effectiveTone);\n if (!allowed) { resolved[key] = value; continue; }\n const candidate = typeof value === \"string\"\n ? value\n : typeof value === \"number\" && Number.isFinite(value)\n ? String(value)\n : undefined;\n if (candidate !== undefined && allowed.includes(candidate)) {\n resolved[key] = candidate;\n continue;\n }\n const fallback = explicitFallback(key, defaults, contract);\n invalid(key, value, fallback, options);\n if (fallback === undefined) delete resolved[key]; else resolved[key] = fallback;\n }\n // Validate dependent defaults too: a default is not permission to emit a\n // coordinate absent from the current project contract.\n for (const key of [\"theme\", \"tone\", \"intensity\", \"surface\", \"foreground\", \"layoutRole\", \"density\", \"ty\", \"v\", \"w\", \"interactivePriority\"]) {\n if (resolved[key] === undefined) continue;\n const allowed = allowedValues(key, resolved, defaults, contract, options.effectiveTone);\n if (allowed && !allowed.includes(String(resolved[key]))) {\n invalid(key, resolved[key], undefined, options); delete resolved[key];\n }\n }\n return resolved;\n}\n\nfunction allowedValues(\n key: string, input: DynamicStyleflowProps, defaults: DynamicStyleflowProps,\n contract: StyleflowContract, effectiveTone?: string\n): string[] | undefined {\n const axes = contract.semantic.axes;\n if (key === \"theme\") return contract.semantic.themes;\n if (key === \"tone\") return axes.color.tones;\n if (key === \"intensity\") {\n const authoredTone = input.tone === \"inherit\" ? undefined : input.tone;\n const defaultTone = defaults.tone === \"inherit\" ? undefined : defaults.tone;\n const tone = String(authoredTone ?? effectiveTone ?? defaultTone ?? \"\");\n return tone ? axes.color.intensitiesByTone[tone] ?? [] : [...new Set(Object.values(axes.color.intensitiesByTone).flat())];\n }\n if (key === \"surface\") return axes.color.surfaces;\n if (key === \"foreground\") return axes.color.foregrounds;\n if (key === \"layoutRole\") return axes.layout.roles;\n if (key === \"density\") return axes.layout.densities;\n if (key === \"ty\") return axes.typography.types;\n if (key === \"v\") {\n const authoredType = input.ty ?? defaults.ty;\n if (authoredType !== undefined && authoredType !== null && authoredType !== \"\") {\n return axes.typography.variantsByType[String(authoredType)] ?? [];\n }\n return [...new Set(Object.values(axes.typography.variantsByType).flat())];\n }\n if (key === \"w\") {\n const authoredType = input.ty ?? defaults.ty;\n if (authoredType !== undefined && authoredType !== null && authoredType !== \"\") {\n return axes.typography.weightsByType[String(authoredType)] ?? [];\n }\n return [...new Set(Object.values(axes.typography.weightsByType).flat())];\n }\n if (key === \"interactivePriority\") return axes.interaction.priorities;\n return undefined;\n}\n\nfunction explicitFallback(key: string, defaults: DynamicStyleflowProps, contract: StyleflowContract): unknown {\n if (defaults[key] !== undefined) return defaults[key];\n if (key === \"layoutRole\") return contract.semantic.agentPolicy.defaults.layoutRole;\n if (key === \"density\") return contract.semantic.agentPolicy.defaults.density;\n if (key === \"ty\" || key === \"v\" || key === \"w\") return contract.semantic.agentPolicy.defaults.typography[key];\n if (key === \"theme\") return contract.defaultTheme;\n return undefined;\n}\nfunction invalid(key: string, value: unknown, fallback: unknown, options: ResolveDynamicStyleflowOptions): void {\n const diagnostic: StyleflowDiagnostic = {\n code: fallback === undefined ? \"FP_STYLEFLOW_INVALID\" : \"FP_STYLEFLOW_FALLBACK\",\n prop: key, value, ...(fallback !== undefined ? { fallback } : {}),\n blocking: options.strict === true,\n message: fallback === undefined\n ? `Styleflow prop ${key}=${JSON.stringify(value)} is not in the grouped project contract.`\n : `Styleflow prop ${key}=${JSON.stringify(value)} fell back to ${JSON.stringify(fallback)}.`\n };\n (options.onDiagnostic ?? ((item) => console.warn(`[${item.code}] ${item.message}`)))(diagnostic);\n if (options.strict) throw new Error(`${diagnostic.code}: ${diagnostic.message}`);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-media-runtime.d.ts","sourceRoot":"","sources":["../src/svg-media-runtime.js"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,mEAyBC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Preserve replaced-image fit/focal points without fetching or replacing SVGs. */
|
|
2
|
+
export function initializeFlowpressSvgMedia(root = document) {
|
|
3
|
+
const observer = new ResizeObserver((entries) => {
|
|
4
|
+
for (const { target: svg, contentRect } of entries) {
|
|
5
|
+
const box = svg.dataset.flowpressSvgViewbox?.split(/[ ,]+/).map(Number);
|
|
6
|
+
const width = contentRect.width, height = contentRect.height;
|
|
7
|
+
if (!box || box.length !== 4 || !box.every(Number.isFinite) || !box[2] || !box[3] || !width || !height)
|
|
8
|
+
continue;
|
|
9
|
+
const css = getComputedStyle(svg);
|
|
10
|
+
const naturalWidth = /^[\d.]+(?:px)?$/.test(svg.dataset.flowpressSvgWidth || "") ? parseFloat(svg.dataset.flowpressSvgWidth) : box[2];
|
|
11
|
+
const naturalHeight = /^[\d.]+(?:px)?$/.test(svg.dataset.flowpressSvgHeight || "") ? parseFloat(svg.dataset.flowpressSvgHeight) : box[3];
|
|
12
|
+
const fit = css.objectFit;
|
|
13
|
+
let scale = fit === "cover" ? Math.max(width / naturalWidth, height / naturalHeight) : Math.min(width / naturalWidth, height / naturalHeight);
|
|
14
|
+
if (fit === "none")
|
|
15
|
+
scale = 1;
|
|
16
|
+
if (fit === "scale-down")
|
|
17
|
+
scale = Math.min(1, scale);
|
|
18
|
+
const targetWidth = fit === "fill" ? width : naturalWidth * scale;
|
|
19
|
+
const targetHeight = fit === "fill" ? height : naturalHeight * scale;
|
|
20
|
+
const positions = css.objectPosition.split(/\s+/);
|
|
21
|
+
const offset = (value, free) => value?.endsWith("%") ? free * parseFloat(value) / 100 : parseFloat(value) || 0;
|
|
22
|
+
const x = offset(positions[0] || "50%", width - targetWidth);
|
|
23
|
+
const y = offset(positions[1] || "50%", height - targetHeight);
|
|
24
|
+
svg.setAttribute("viewBox", `${box[0] - x * box[2] / targetWidth} ${box[1] - y * box[3] / targetHeight} ${width * box[2] / targetWidth} ${height * box[3] / targetHeight}`);
|
|
25
|
+
svg.setAttribute("preserveAspectRatio", "none");
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
for (const svg of root.querySelectorAll("svg[data-flowpress-svg-viewbox]"))
|
|
29
|
+
observer.observe(svg);
|
|
30
|
+
document.addEventListener("astro:page-load", () => { observer.disconnect(); for (const svg of document.querySelectorAll("svg[data-flowpress-svg-viewbox]"))
|
|
31
|
+
observer.observe(svg); });
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=svg-media-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-media-runtime.js","sourceRoot":"","sources":["../src/svg-media-runtime.js"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,UAAU,2BAA2B,CAAC,IAAI,GAAG,QAAQ;IACzD,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,CAAC,OAAO,EAAE,EAAE;QAC9C,KAAK,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,OAAO,EAAE,CAAC;YACnD,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,mBAAmB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACxE,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,WA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,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAClG,QAAQ,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,GAAG,EAAE,GAAG,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,KAAK,MAAM,GAAG,IAAI,QAAQ,CAAC,gBAAgB,CAAC,iCAAiC,CAAC;QAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxL,CAAC","sourcesContent":["/** Preserve replaced-image fit/focal points without fetching or replacing SVGs. */\nexport function initializeFlowpressSvgMedia(root = document) {\n const observer = new ResizeObserver((entries) => {\n for (const { target: svg, contentRect } of entries) {\n const box = svg.dataset.flowpressSvgViewbox?.split(/[ ,]+/).map(Number);\n const width = contentRect.width, height = contentRect.height;\n if (!box || box.length !== 4 || !box.every(Number.isFinite) || !box[2] || !box[3] || !width || !height) continue;\n const css = getComputedStyle(svg);\n const naturalWidth = /^[\\d.]+(?:px)?$/.test(svg.dataset.flowpressSvgWidth || \"\") ? parseFloat(svg.dataset.flowpressSvgWidth) : box[2];\n const naturalHeight = /^[\\d.]+(?:px)?$/.test(svg.dataset.flowpressSvgHeight || \"\") ? parseFloat(svg.dataset.flowpressSvgHeight) : box[3];\n const fit = css.objectFit;\n let scale = fit === \"cover\" ? Math.max(width / naturalWidth, height / naturalHeight) : Math.min(width / naturalWidth, height / naturalHeight);\n if (fit === \"none\") scale = 1;\n if (fit === \"scale-down\") scale = Math.min(1, scale);\n const targetWidth = fit === \"fill\" ? width : naturalWidth * scale;\n const targetHeight = fit === \"fill\" ? height : naturalHeight * scale;\n const positions = css.objectPosition.split(/\\s+/);\n const offset = (value, free) => value?.endsWith(\"%\") ? free * parseFloat(value) / 100 : parseFloat(value) || 0;\n const x = offset(positions[0] || \"50%\", width - targetWidth);\n const y = offset(positions[1] || \"50%\", height - targetHeight);\n svg.setAttribute(\"viewBox\", `${box[0] - x * box[2] / targetWidth} ${box[1] - y * box[3] / targetHeight} ${width * box[2] / targetWidth} ${height * box[3] / targetHeight}`);\n svg.setAttribute(\"preserveAspectRatio\", \"none\");\n }\n });\n for (const svg of root.querySelectorAll(\"svg[data-flowpress-svg-viewbox]\")) observer.observe(svg);\n document.addEventListener(\"astro:page-load\", () => { observer.disconnect(); for (const svg of document.querySelectorAll(\"svg[data-flowpress-svg-viewbox]\")) observer.observe(svg); });\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface FlowpressSvgMediaPayload {
|
|
2
|
+
version: "1";
|
|
3
|
+
attributes: Record<string, string>;
|
|
4
|
+
content: string;
|
|
5
|
+
digest: string;
|
|
6
|
+
}
|
|
7
|
+
export interface FlowpressSvgMediaLocals {
|
|
8
|
+
flowpressSvgMedia?: Map<string, FlowpressSvgMediaPayload>;
|
|
9
|
+
flowpressSvgMediaSequence?: number;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=svg-media-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-media-types.d.ts","sourceRoot":"","sources":["../src/svg-media-types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,wBAAwB;IAAE,OAAO,EAAC,GAAG,CAAC;IAAA,UAAU,EAAC,MAAM,CAAC,MAAM,EAAC,MAAM,CAAC,CAAC;IAAA,OAAO,EAAC,MAAM,CAAC;IAAA,MAAM,EAAC,MAAM,CAAC;CAAC;AACtH,MAAM,WAAW,uBAAuB;IAAE,iBAAiB,CAAC,EAAC,GAAG,CAAC,MAAM,EAAC,wBAAwB,CAAC,CAAC;IAAA,yBAAyB,CAAC,EAAC,MAAM,CAAC;CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-media-types.js","sourceRoot":"","sources":["../src/svg-media-types.ts"],"names":[],"mappings":"","sourcesContent":["export interface FlowpressSvgMediaPayload {version:\"1\";attributes:Record<string,string>;content:string;digest:string;}\nexport interface FlowpressSvgMediaLocals {flowpressSvgMedia?:Map<string,FlowpressSvgMediaPayload>;flowpressSvgMediaSequence?:number;}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FlowpressSvgMediaLocals } from "./svg-media-types.js";
|
|
2
|
+
export type { FlowpressSvgMediaPayload, FlowpressSvgMediaLocals } from "./svg-media-types.js";
|
|
3
|
+
export declare const SVG_INSTANCE_PLACEHOLDER = "__SF_SVG_INSTANCE__";
|
|
4
|
+
export declare function flowpressSvgMediaUrl(url: unknown): string;
|
|
5
|
+
/** Explicit registration rescans mutable caller data, as before. */
|
|
6
|
+
export declare function registerFlowpressSvgMedia(value: unknown, locals: FlowpressSvgMediaLocals): void;
|
|
7
|
+
/** Immutable renderer inputs are scanned once per request, including nested passes. */
|
|
8
|
+
export declare function registerFlowpressRenderSvgMedia(value: unknown, locals: FlowpressSvgMediaLocals): void;
|
|
9
|
+
export declare function flowpressSvgMediaProps(src: unknown, props: Record<string, unknown>, locals: FlowpressSvgMediaLocals): {
|
|
10
|
+
attributes: Record<string, unknown>;
|
|
11
|
+
content: string;
|
|
12
|
+
} | null;
|
|
13
|
+
//# sourceMappingURL=svg-media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-media.d.ts","sourceRoot":"","sources":["../src/svg-media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA4B,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC9F,YAAY,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC9F,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAC9D,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAsE;AAkBhI,oEAAoE;AACpE,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,uBAAuB,GAAG,IAAI,CAE/F;AAED,uFAAuF;AACvF,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,uBAAuB,GAAG,IAAI,CAQrG;AACD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,uBAAuB,GAAG;IAAC,UAAU,EAAC,MAAM,CAAC,MAAM,EAAC,OAAO,CAAC,CAAC;IAAA,OAAO,EAAC,MAAM,CAAA;CAAC,GAAC,IAAI,CAS7K"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const SVG_INSTANCE_PLACEHOLDER = "__SF_SVG_INSTANCE__";
|
|
2
|
+
export function flowpressSvgMediaUrl(url) { return typeof url === "string" ? url.replace(/[?#].*$/, "") : ""; }
|
|
3
|
+
const renderScans = new WeakMap();
|
|
4
|
+
function scanSvgMedia(value, registry, seen) {
|
|
5
|
+
function visit(node) {
|
|
6
|
+
if (!node || typeof node !== "object" || seen.has(node))
|
|
7
|
+
return;
|
|
8
|
+
seen.add(node);
|
|
9
|
+
const record = node;
|
|
10
|
+
if (record.svg?.version === "1" && record.svg.attributes && typeof record.svg.content === "string") {
|
|
11
|
+
const url = flowpressSvgMediaUrl(record.url || record.sourceUrl);
|
|
12
|
+
if (url)
|
|
13
|
+
registry.set(url, record.svg);
|
|
14
|
+
}
|
|
15
|
+
for (const [key, child] of Object.entries(record))
|
|
16
|
+
if (key !== "svg")
|
|
17
|
+
visit(child);
|
|
18
|
+
}
|
|
19
|
+
visit(value);
|
|
20
|
+
}
|
|
21
|
+
/** Explicit registration rescans mutable caller data, as before. */
|
|
22
|
+
export function registerFlowpressSvgMedia(value, locals) {
|
|
23
|
+
scanSvgMedia(value, locals.flowpressSvgMedia ??= new Map(), new WeakSet());
|
|
24
|
+
}
|
|
25
|
+
/** Immutable renderer inputs are scanned once per request, including nested passes. */
|
|
26
|
+
export function registerFlowpressRenderSvgMedia(value, locals) {
|
|
27
|
+
const registry = locals.flowpressSvgMedia ??= new Map();
|
|
28
|
+
let state = renderScans.get(locals);
|
|
29
|
+
if (!state || state.registry !== registry) {
|
|
30
|
+
state = { registry, seen: new WeakSet() };
|
|
31
|
+
renderScans.set(locals, state);
|
|
32
|
+
}
|
|
33
|
+
scanSvgMedia(value, registry, state.seen);
|
|
34
|
+
}
|
|
35
|
+
export function flowpressSvgMediaProps(src, props, locals) {
|
|
36
|
+
const payload = locals.flowpressSvgMedia?.get(flowpressSvgMediaUrl(src));
|
|
37
|
+
if (!payload)
|
|
38
|
+
return null;
|
|
39
|
+
const scope = `fp-svg-${locals.flowpressSvgMediaSequence = (locals.flowpressSvgMediaSequence || 0) + 1}`;
|
|
40
|
+
const replace = (v) => String(v).split(SVG_INSTANCE_PLACEHOLDER).join(scope);
|
|
41
|
+
const source = Object.fromEntries(Object.entries(payload.attributes).map(([n, v]) => [n, replace(v)]));
|
|
42
|
+
const { src: _src, srcset: _srcset, sizes: _sizes, loading: _loading, decoding: _decoding, fetchpriority: _priority, alt, ...html } = props;
|
|
43
|
+
const label = typeof html['aria-label'] === 'string' ? html['aria-label'] : String(alt ?? '');
|
|
44
|
+
const decorative = html['aria-hidden'] === 'true' || html['aria-hidden'] === true || !label;
|
|
45
|
+
return { attributes: { ...source, ...html, class: ['flowpress-svg-media', source.class, html.class].filter(Boolean).join(' '), style: [source.style, html.style].filter(Boolean).join(';') || undefined, role: decorative ? 'presentation' : 'img', 'aria-label': decorative ? undefined : label, 'aria-hidden': decorative ? 'true' : undefined, focusable: 'false', 'data-flowpress-svg-viewbox': source.viewBox, 'data-flowpress-svg-width': source.width, 'data-flowpress-svg-height': source.height }, content: replace(payload.content) };
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=svg-media.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-media.js","sourceRoot":"","sources":["../src/svg-media.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,wBAAwB,GAAG,qBAAqB,CAAC;AAC9D,MAAM,UAAU,oBAAoB,CAAC,GAAY,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,MAAM,EAAC,EAAC,OAAO,EAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAC,CAAC;AACte,CAAC","sourcesContent":["import type { FlowpressSvgMediaPayload, FlowpressSvgMediaLocals } from \"./svg-media-types.js\";\nexport type { FlowpressSvgMediaPayload, FlowpressSvgMediaLocals } from \"./svg-media-types.js\";\nexport const SVG_INSTANCE_PLACEHOLDER = \"__SF_SVG_INSTANCE__\";\nexport function flowpressSvgMediaUrl(url: unknown): string { return typeof url === \"string\" ? url.replace(/[?#].*$/, \"\") : \"\"; }\ntype SvgRegistry = NonNullable<FlowpressSvgMediaLocals[\"flowpressSvgMedia\"]>;\nconst renderScans = new WeakMap<FlowpressSvgMediaLocals, { registry: SvgRegistry; seen: WeakSet<object> }>();\n\nfunction scanSvgMedia(value: unknown, registry: SvgRegistry, seen: WeakSet<object>): void {\n function visit(node: unknown): void {\n if (!node || typeof node !== \"object\" || seen.has(node)) return;\n seen.add(node);\n const record = node as Record<string, any>;\n if (record.svg?.version === \"1\" && record.svg.attributes && typeof record.svg.content === \"string\") {\n const url = flowpressSvgMediaUrl(record.url || record.sourceUrl);\n if (url) registry.set(url, record.svg as FlowpressSvgMediaPayload);\n }\n for (const [key,child] of Object.entries(record)) if(key !== \"svg\") visit(child);\n }\n visit(value);\n}\n\n/** Explicit registration rescans mutable caller data, as before. */\nexport function registerFlowpressSvgMedia(value: unknown, locals: FlowpressSvgMediaLocals): void {\n scanSvgMedia(value, locals.flowpressSvgMedia ??= new Map(), new WeakSet<object>());\n}\n\n/** Immutable renderer inputs are scanned once per request, including nested passes. */\nexport function registerFlowpressRenderSvgMedia(value: unknown, locals: FlowpressSvgMediaLocals): void {\n const registry = locals.flowpressSvgMedia ??= new Map();\n let state = renderScans.get(locals);\n if (!state || state.registry !== registry) {\n state = { registry, seen: new WeakSet<object>() };\n renderScans.set(locals, state);\n }\n scanSvgMedia(value, registry, state.seen);\n}\nexport function flowpressSvgMediaProps(src: unknown, props: Record<string, unknown>, locals: FlowpressSvgMediaLocals): {attributes:Record<string,unknown>;content:string}|null {\n const payload=locals.flowpressSvgMedia?.get(flowpressSvgMediaUrl(src));if(!payload)return null;\n const scope=`fp-svg-${locals.flowpressSvgMediaSequence=(locals.flowpressSvgMediaSequence||0)+1}`;\n const replace=(v:unknown)=>String(v).split(SVG_INSTANCE_PLACEHOLDER).join(scope);\n const source=Object.fromEntries(Object.entries(payload.attributes).map(([n,v])=>[n,replace(v)]));\n const {src:_src,srcset:_srcset,sizes:_sizes,loading:_loading,decoding:_decoding,fetchpriority:_priority,alt,...html}=props;\n const label=typeof html['aria-label']==='string'?html['aria-label']:String(alt??'');\n const decorative=html['aria-hidden']==='true'||html['aria-hidden']===true||!label;\n return {attributes:{...source,...html,class:['flowpress-svg-media',source.class,html.class].filter(Boolean).join(' '),style:[source.style,html.style].filter(Boolean).join(';')||undefined,role:decorative?'presentation':'img','aria-label':decorative?undefined:label,'aria-hidden':decorative?'true':undefined,focusable:'false','data-flowpress-svg-viewbox':source.viewBox,'data-flowpress-svg-width':source.width,'data-flowpress-svg-height':source.height},content:replace(payload.content)};\n}\n"]}
|
|
@@ -6,11 +6,4 @@ import type { TemplateContext } from "./types.js";
|
|
|
6
6
|
* scaffolding.
|
|
7
7
|
*/
|
|
8
8
|
export declare function getTemplateCandidates(context: TemplateContext): string[];
|
|
9
|
-
export interface TemplateResolution<T> {
|
|
10
|
-
name: string;
|
|
11
|
-
component: T;
|
|
12
|
-
candidates: string[];
|
|
13
|
-
source: "project" | "core";
|
|
14
|
-
}
|
|
15
|
-
export declare function resolveTemplate<T>(candidates: string[], projectTemplates: Readonly<Record<string, T>>, coreTemplates: Readonly<Record<string, T>>): TemplateResolution<T>;
|
|
16
9
|
//# sourceMappingURL=template-hierarchy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-hierarchy.d.ts","sourceRoot":"","sources":["../src/template-hierarchy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAsDlD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,EAAE,CA8FxE
|
|
1
|
+
{"version":3,"file":"template-hierarchy.d.ts","sourceRoot":"","sources":["../src/template-hierarchy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAsDlD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,EAAE,CA8FxE"}
|
|
@@ -145,25 +145,4 @@ export function getTemplateCandidates(context) {
|
|
|
145
145
|
return ["404", "index"];
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
export function resolveTemplate(candidates, projectTemplates, coreTemplates) {
|
|
149
|
-
for (const candidate of candidates) {
|
|
150
|
-
const project = projectTemplates[candidate];
|
|
151
|
-
if (project) {
|
|
152
|
-
return { name: candidate, component: project, candidates, source: "project" };
|
|
153
|
-
}
|
|
154
|
-
const core = coreTemplates[candidate];
|
|
155
|
-
if (core) {
|
|
156
|
-
return { name: candidate, component: core, candidates, source: "core" };
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
const projectIndex = projectTemplates.index;
|
|
160
|
-
if (projectIndex) {
|
|
161
|
-
return { name: "index", component: projectIndex, candidates, source: "project" };
|
|
162
|
-
}
|
|
163
|
-
const coreIndex = coreTemplates.index;
|
|
164
|
-
if (!coreIndex) {
|
|
165
|
-
throw new Error("FlowPress requires a core index template.");
|
|
166
|
-
}
|
|
167
|
-
return { name: "index", component: coreIndex, candidates, source: "core" };
|
|
168
|
-
}
|
|
169
148
|
//# sourceMappingURL=template-hierarchy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-hierarchy.js","sourceRoot":"","sources":["../src/template-hierarchy.ts"],"names":[],"mappings":"AAEA,SAAS,QAAQ,CAAC,KAAyC;IACzD,OAAO,MAAM,CAA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,MAAM,EAAE,MAAM,EAAE,CAAC;AAC7E,CAAC","sourcesContent":["import type { TemplateContext } from \"./types.js\";\n\nfunction slugPart(value: string | number | null | undefined): string {\n return String(value ?? \"\")\n .trim()\n .toLowerCase()\n .replace(/\\.php$/i, \"\")\n .replace(/[^a-z0-9_%\\-\\u0080-\\uFFFF]+/gu, \"-\")\n .replace(/^-+|-+$/g, \"\");\n}\n\nfunction assignedTemplatePart(value: string | null | undefined): string {\n return String(value ?? \"\")\n .trim()\n .replace(/\\.php$/i, \"\")\n .split(\"/\")\n .map((part) => slugPart(part))\n .filter(Boolean)\n .join(\"/\");\n}\n\nfunction unique(values: Array<string | null | undefined>): string[] {\n return [...new Set(values.filter((value): value is string => Boolean(value)))];\n}\n\nfunction pageCandidates(context: TemplateContext): string[] {\n return unique([\n context.pageTemplate && context.pageTemplate !== \"default\"\n ? assignedTemplatePart(context.pageTemplate)\n : null,\n context.slug ? `page-${slugPart(context.slug)}` : null,\n context.databaseId ? `page-${context.databaseId}` : null,\n \"page\",\n \"singular\",\n \"index\"\n ]);\n}\n\nfunction attachmentMimeCandidates(mimeType?: string | null): string[] {\n const [type = \"\", subtype = \"\"] = String(mimeType ?? \"\")\n .toLowerCase()\n .split(\"/\", 2);\n const normalizedType = slugPart(type);\n const normalizedSubtype = slugPart(subtype);\n\n return unique([\n normalizedType && normalizedSubtype\n ? `${normalizedType}-${normalizedSubtype}`\n : null,\n normalizedSubtype || null,\n normalizedType || null\n ]);\n}\n\n/**\n * Mirrors the WordPress classic template hierarchy, without file extensions.\n * WordPress is still the source of truth at runtime and may filter candidates\n * before returning them to Astro; this pure function powers tests and offline\n * scaffolding.\n */\nexport function getTemplateCandidates(context: TemplateContext): string[] {\n switch (context.queryType) {\n case \"front-page\":\n return unique([\n \"front-page\",\n ...(context.frontPageMode === \"posts\"\n ? [\"home\", \"index\"]\n : pageCandidates(context))\n ]);\n case \"home\":\n return [\"home\", \"index\"];\n case \"privacy-policy\":\n return unique([\"privacy-policy\", ...pageCandidates(context)]);\n case \"page\":\n return pageCandidates(context);\n case \"single\":\n return unique([\n context.postType && context.slug\n ? `single-${slugPart(context.postType)}-${slugPart(context.slug)}`\n : null,\n context.postType ? `single-${slugPart(context.postType)}` : null,\n \"single\",\n \"singular\",\n \"index\"\n ]);\n case \"attachment\":\n return unique([\n ...attachmentMimeCandidates(context.mimeType),\n \"attachment\",\n context.slug ? `single-attachment-${slugPart(context.slug)}` : null,\n \"single-attachment\",\n \"single\",\n \"singular\",\n \"index\"\n ]);\n case \"post-type-archive\":\n return unique([\n context.postType ? `archive-${slugPart(context.postType)}` : null,\n \"archive\",\n \"index\"\n ]);\n case \"category\":\n return unique([\n context.slug ? `category-${slugPart(context.slug)}` : null,\n context.termId ? `category-${context.termId}` : null,\n \"category\",\n \"archive\",\n \"index\"\n ]);\n case \"tag\":\n return unique([\n context.slug ? `tag-${slugPart(context.slug)}` : null,\n context.termId ? `tag-${context.termId}` : null,\n \"tag\",\n \"archive\",\n \"index\"\n ]);\n case \"taxonomy\":\n return unique([\n context.taxonomy && context.term\n ? `taxonomy-${slugPart(context.taxonomy)}-${slugPart(context.term)}`\n : null,\n context.taxonomy ? `taxonomy-${slugPart(context.taxonomy)}` : null,\n \"taxonomy\",\n \"archive\",\n \"index\"\n ]);\n case \"author\":\n return unique([\n context.authorNicename\n ? `author-${slugPart(context.authorNicename)}`\n : null,\n context.authorId ? `author-${context.authorId}` : null,\n \"author\",\n \"archive\",\n \"index\"\n ]);\n case \"date\":\n return [\"date\", \"archive\", \"index\"];\n case \"search\":\n return [\"search\", \"index\"];\n case \"embed\":\n return unique([\n context.postType && context.postFormat\n ? `embed-${slugPart(context.postType)}-${slugPart(context.postFormat)}`\n : null,\n context.postType ? `embed-${slugPart(context.postType)}` : null,\n \"embed\"\n ]);\n case \"archive\":\n return [\"archive\", \"index\"];\n case \"404\":\n return [\"404\", \"index\"];\n }\n}\n\nexport interface TemplateResolution<T> {\n name: string;\n component: T;\n candidates: string[];\n source: \"project\" | \"core\";\n}\n\nexport function resolveTemplate<T>(\n candidates: string[],\n projectTemplates: Readonly<Record<string, T>>,\n coreTemplates: Readonly<Record<string, T>>\n): TemplateResolution<T> {\n for (const candidate of candidates) {\n const project = projectTemplates[candidate];\n if (project) {\n return { name: candidate, component: project, candidates, source: \"project\" };\n }\n\n const core = coreTemplates[candidate];\n if (core) {\n return { name: candidate, component: core, candidates, source: \"core\" };\n }\n }\n\n const projectIndex = projectTemplates.index;\n if (projectIndex) {\n return { name: \"index\", component: projectIndex, candidates, source: \"project\" };\n }\n\n const coreIndex = coreTemplates.index;\n if (!coreIndex) {\n throw new Error(\"FlowPress requires a core index template.\");\n }\n\n return { name: \"index\", component: coreIndex, candidates, source: \"core\" };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"template-hierarchy.js","sourceRoot":"","sources":["../src/template-hierarchy.ts"],"names":[],"mappings":"AAEA,SAAS,QAAQ,CAAC,KAAyC;IACzD,OAAO,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;SACvB,IAAI,EAAE;SACN,WAAW,EAAE;SACb,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;SACtB,OAAO,CAAC,+BAA+B,EAAE,GAAG,CAAC;SAC7C,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAgC;IAC5D,OAAO,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC;SACvB,IAAI,EAAE;SACN,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;SACtB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SAC7B,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED,SAAS,MAAM,CAAC,MAAwC;IACtD,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,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,CAAC,EAAE;oBAC9C,CAAC,CAAC,IAAI;gBACR,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI;gBACtD,QAAQ;gBACR,SAAS;gBACT,OAAO;aACR,CAAC,CAAC;QACL,KAAK,MAAM;YACT,OAAO,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACtC,KAAK,QAAQ;YACX,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC7B,KAAK,OAAO;YACV,OAAO,MAAM,CAAC;gBACZ,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,UAAU;oBACpC,CAAC,CAAC,SAAS,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;oBACvE,CAAC,CAAC,IAAI;gBACR,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI;gBAC/D,OAAO;aACR,CAAC,CAAC;QACL,KAAK,SAAS;YACZ,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC9B,KAAK,KAAK;YACR,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC","sourcesContent":["import type { TemplateContext } from \"./types.js\";\n\nfunction slugPart(value: string | number | null | undefined): string {\n return String(value ?? \"\")\n .trim()\n .toLowerCase()\n .replace(/\\.php$/i, \"\")\n .replace(/[^a-z0-9_%\\-\\u0080-\\uFFFF]+/gu, \"-\")\n .replace(/^-+|-+$/g, \"\");\n}\n\nfunction assignedTemplatePart(value: string | null | undefined): string {\n return String(value ?? \"\")\n .trim()\n .replace(/\\.php$/i, \"\")\n .split(\"/\")\n .map((part) => slugPart(part))\n .filter(Boolean)\n .join(\"/\");\n}\n\nfunction unique(values: Array<string | null | undefined>): string[] {\n return [...new Set(values.filter((value): value is string => Boolean(value)))];\n}\n\nfunction pageCandidates(context: TemplateContext): string[] {\n return unique([\n context.pageTemplate && context.pageTemplate !== \"default\"\n ? assignedTemplatePart(context.pageTemplate)\n : null,\n context.slug ? `page-${slugPart(context.slug)}` : null,\n context.databaseId ? `page-${context.databaseId}` : null,\n \"page\",\n \"singular\",\n \"index\"\n ]);\n}\n\nfunction attachmentMimeCandidates(mimeType?: string | null): string[] {\n const [type = \"\", subtype = \"\"] = String(mimeType ?? \"\")\n .toLowerCase()\n .split(\"/\", 2);\n const normalizedType = slugPart(type);\n const normalizedSubtype = slugPart(subtype);\n\n return unique([\n normalizedType && normalizedSubtype\n ? `${normalizedType}-${normalizedSubtype}`\n : null,\n normalizedSubtype || null,\n normalizedType || null\n ]);\n}\n\n/**\n * Mirrors the WordPress classic template hierarchy, without file extensions.\n * WordPress is still the source of truth at runtime and may filter candidates\n * before returning them to Astro; this pure function powers tests and offline\n * scaffolding.\n */\nexport function getTemplateCandidates(context: TemplateContext): string[] {\n switch (context.queryType) {\n case \"front-page\":\n return unique([\n \"front-page\",\n ...(context.frontPageMode === \"posts\"\n ? [\"home\", \"index\"]\n : pageCandidates(context))\n ]);\n case \"home\":\n return [\"home\", \"index\"];\n case \"privacy-policy\":\n return unique([\"privacy-policy\", ...pageCandidates(context)]);\n case \"page\":\n return pageCandidates(context);\n case \"single\":\n return unique([\n context.postType && context.slug\n ? `single-${slugPart(context.postType)}-${slugPart(context.slug)}`\n : null,\n context.postType ? `single-${slugPart(context.postType)}` : null,\n \"single\",\n \"singular\",\n \"index\"\n ]);\n case \"attachment\":\n return unique([\n ...attachmentMimeCandidates(context.mimeType),\n \"attachment\",\n context.slug ? `single-attachment-${slugPart(context.slug)}` : null,\n \"single-attachment\",\n \"single\",\n \"singular\",\n \"index\"\n ]);\n case \"post-type-archive\":\n return unique([\n context.postType ? `archive-${slugPart(context.postType)}` : null,\n \"archive\",\n \"index\"\n ]);\n case \"category\":\n return unique([\n context.slug ? `category-${slugPart(context.slug)}` : null,\n context.termId ? `category-${context.termId}` : null,\n \"category\",\n \"archive\",\n \"index\"\n ]);\n case \"tag\":\n return unique([\n context.slug ? `tag-${slugPart(context.slug)}` : null,\n context.termId ? `tag-${context.termId}` : null,\n \"tag\",\n \"archive\",\n \"index\"\n ]);\n case \"taxonomy\":\n return unique([\n context.taxonomy && context.term\n ? `taxonomy-${slugPart(context.taxonomy)}-${slugPart(context.term)}`\n : null,\n context.taxonomy ? `taxonomy-${slugPart(context.taxonomy)}` : null,\n \"taxonomy\",\n \"archive\",\n \"index\"\n ]);\n case \"author\":\n return unique([\n context.authorNicename\n ? `author-${slugPart(context.authorNicename)}`\n : null,\n context.authorId ? `author-${context.authorId}` : null,\n \"author\",\n \"archive\",\n \"index\"\n ]);\n case \"date\":\n return [\"date\", \"archive\", \"index\"];\n case \"search\":\n return [\"search\", \"index\"];\n case \"embed\":\n return unique([\n context.postType && context.postFormat\n ? `embed-${slugPart(context.postType)}-${slugPart(context.postFormat)}`\n : null,\n context.postType ? `embed-${slugPart(context.postType)}` : null,\n \"embed\"\n ]);\n case \"archive\":\n return [\"archive\", \"index\"];\n case \"404\":\n return [\"404\", \"index\"];\n }\n}\n"]}
|
package/dist/text.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAEA,qFAAqF;AACrF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE1D"}
|
package/dist/text.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { decodeHTMLStrict } from "entities";
|
|
2
|
+
/** Decode WordPress entities once; render the result as escaped text, never HTML. */
|
|
3
|
+
export function decodeFlowpressText(value) {
|
|
4
|
+
return decodeHTMLStrict(typeof value === "string" ? value : typeof value === "number" ? String(value) : "");
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=text.js.map
|
package/dist/text.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,qFAAqF;AACrF,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,OAAO,gBAAgB,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAC9G,CAAC","sourcesContent":["import { decodeHTMLStrict } from \"entities\";\n\n/** Decode WordPress entities once; render the result as escaped text, never HTML. */\nexport function decodeFlowpressText(value: unknown): string {\n return decodeHTMLStrict(typeof value === \"string\" ? value : typeof value === \"number\" ? String(value) : \"\");\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const STYLEFLOW_THEME_STORAGE_KEY = "styleflow:theme";
|
|
2
|
+
export interface StyleflowThemeRuntimeConfig {
|
|
3
|
+
themes: string[];
|
|
4
|
+
defaultTheme: string;
|
|
5
|
+
}
|
|
6
|
+
declare global {
|
|
7
|
+
interface Window {
|
|
8
|
+
__FLOWPRESS_STYLEFLOW_THEME_RUNTIME__?: StyleflowThemeRuntimeConfig;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export declare function normalizeStyleflowThemes(themes: readonly string[], defaultTheme: string): StyleflowThemeRuntimeConfig;
|
|
12
|
+
export declare function initialStyleflowTheme(themes: readonly string[], defaultTheme: string, storedTheme?: string | null): string;
|
|
13
|
+
export declare function nextStyleflowTheme(themes: readonly string[], currentTheme: string): string;
|
|
14
|
+
export declare function styleflowThemeBootstrapScript(themes: readonly string[], defaultTheme: string): string;
|
|
15
|
+
export declare function initializeStyleflowThemeRuntime(config?: StyleflowThemeRuntimeConfig, documentObject?: Document, storage?: Pick<Storage, "getItem" | "setItem"> | null): () => void;
|
|
16
|
+
//# sourceMappingURL=theme-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-runtime.d.ts","sourceRoot":"","sources":["../src/theme-runtime.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,oBAAoB,CAAC;AAE7D,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,qCAAqC,CAAC,EAAE,2BAA2B,CAAC;KACrE;CACF;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,YAAY,EAAE,MAAM,GACnB,2BAA2B,CAQ7B;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,YAAY,EAAE,MAAM,EACpB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAC1B,MAAM,CAKR;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,YAAY,EAAE,MAAM,GACnB,MAAM,CAIR;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,YAAY,EAAE,MAAM,GACnB,MAAM,CAIR;AAED,wBAAgB,+BAA+B,CAC7C,MAAM,GAAE,2BAC6B,EACrC,cAAc,GAAE,QAAmB,EACnC,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,CAAC,GAAG,IAAI,GACpD,MAAM,IAAI,CAkEZ"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export const STYLEFLOW_THEME_STORAGE_KEY = "styleflow:theme";
|
|
2
|
+
export function normalizeStyleflowThemes(themes, defaultTheme) {
|
|
3
|
+
const normalized = [...new Set(themes.filter((theme) => (typeof theme === "string" && /^[a-zA-Z0-9_-]+$/.test(theme))))];
|
|
4
|
+
const fallback = normalized.includes(defaultTheme)
|
|
5
|
+
? defaultTheme
|
|
6
|
+
: normalized[0] ?? "";
|
|
7
|
+
return { themes: normalized, defaultTheme: fallback };
|
|
8
|
+
}
|
|
9
|
+
export function initialStyleflowTheme(themes, defaultTheme, storedTheme) {
|
|
10
|
+
const config = normalizeStyleflowThemes(themes, defaultTheme);
|
|
11
|
+
return storedTheme && config.themes.includes(storedTheme)
|
|
12
|
+
? storedTheme
|
|
13
|
+
: config.defaultTheme;
|
|
14
|
+
}
|
|
15
|
+
export function nextStyleflowTheme(themes, currentTheme) {
|
|
16
|
+
if (themes.length === 0)
|
|
17
|
+
return "";
|
|
18
|
+
const index = themes.indexOf(currentTheme);
|
|
19
|
+
return themes[(index + 1 + themes.length) % themes.length] ?? themes[0] ?? "";
|
|
20
|
+
}
|
|
21
|
+
export function styleflowThemeBootstrapScript(themes, defaultTheme) {
|
|
22
|
+
const config = normalizeStyleflowThemes(themes, defaultTheme);
|
|
23
|
+
const json = JSON.stringify(config).replaceAll("<", "\\u003c");
|
|
24
|
+
return `(()=>{const c=${json};window.__FLOWPRESS_STYLEFLOW_THEME_RUNTIME__=c;if(!c.themes.length)return;let s=null;try{s=localStorage.getItem(${JSON.stringify(STYLEFLOW_THEME_STORAGE_KEY)})}catch{}const t=c.themes.includes(s)?s:c.defaultTheme;document.documentElement.setAttribute("data-styleflow-theme",t)})()`;
|
|
25
|
+
}
|
|
26
|
+
export function initializeStyleflowThemeRuntime(config = window.__FLOWPRESS_STYLEFLOW_THEME_RUNTIME__
|
|
27
|
+
?? { themes: [], defaultTheme: "" }, documentObject = document, storage) {
|
|
28
|
+
const normalized = normalizeStyleflowThemes(config.themes, config.defaultTheme);
|
|
29
|
+
if (normalized.themes.length === 0)
|
|
30
|
+
return () => undefined;
|
|
31
|
+
let storageObject = storage;
|
|
32
|
+
if (storageObject === undefined) {
|
|
33
|
+
try {
|
|
34
|
+
storageObject = globalThis.localStorage;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
storageObject = null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const root = documentObject.documentElement;
|
|
41
|
+
let current = initialStyleflowTheme(normalized.themes, normalized.defaultTheme, root.getAttribute("data-styleflow-theme"));
|
|
42
|
+
const buttons = [...documentObject.querySelectorAll("[data-styleflow-theme-toggle]")];
|
|
43
|
+
const updateButtons = () => {
|
|
44
|
+
for (const button of buttons) {
|
|
45
|
+
const baseLabel = button.dataset.styleflowThemeToggleLabel
|
|
46
|
+
|| button.getAttribute("aria-label")
|
|
47
|
+
|| "Change color theme";
|
|
48
|
+
button.dataset.styleflowThemeToggleLabel = baseLabel.replace(/: .+$/, "");
|
|
49
|
+
if (button.getAttribute("role") === "switch") {
|
|
50
|
+
button.setAttribute("aria-checked", String(current === (button.dataset.styleflowThemeToggleTarget || "dark")));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
button.setAttribute("aria-label", `${button.dataset.styleflowThemeToggleLabel}: ${current}`);
|
|
54
|
+
}
|
|
55
|
+
const label = button.querySelector("[data-styleflow-theme-label]")
|
|
56
|
+
?? button.closest(".flowpress-theme-control")?.querySelector("[data-styleflow-theme-label]");
|
|
57
|
+
if (label)
|
|
58
|
+
label.textContent = current;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const apply = (theme, persist) => {
|
|
62
|
+
current = theme;
|
|
63
|
+
root.setAttribute("data-styleflow-theme", theme);
|
|
64
|
+
if (persist && storageObject) {
|
|
65
|
+
try {
|
|
66
|
+
storageObject.setItem(STYLEFLOW_THEME_STORAGE_KEY, theme);
|
|
67
|
+
}
|
|
68
|
+
catch { /* noop */ }
|
|
69
|
+
}
|
|
70
|
+
updateButtons();
|
|
71
|
+
documentObject.dispatchEvent(new CustomEvent("styleflow:theme-change", {
|
|
72
|
+
detail: { theme }
|
|
73
|
+
}));
|
|
74
|
+
};
|
|
75
|
+
const listeners = new Map();
|
|
76
|
+
for (const button of buttons) {
|
|
77
|
+
if (button.dataset.styleflowThemeToggleBound === "true")
|
|
78
|
+
continue;
|
|
79
|
+
const listener = () => {
|
|
80
|
+
const target = button.dataset.styleflowThemeToggleTarget;
|
|
81
|
+
const alternative = normalized.defaultTheme !== target
|
|
82
|
+
? normalized.defaultTheme : normalized.themes.find((theme) => theme !== target);
|
|
83
|
+
const theme = target && alternative && normalized.themes.includes(target)
|
|
84
|
+
? (current === target ? alternative : target)
|
|
85
|
+
: nextStyleflowTheme(normalized.themes, current);
|
|
86
|
+
apply(theme, true);
|
|
87
|
+
};
|
|
88
|
+
button.dataset.styleflowThemeToggleBound = "true";
|
|
89
|
+
button.addEventListener("click", listener);
|
|
90
|
+
listeners.set(button, listener);
|
|
91
|
+
}
|
|
92
|
+
updateButtons();
|
|
93
|
+
return () => {
|
|
94
|
+
for (const [button, listener] of listeners) {
|
|
95
|
+
button.removeEventListener("click", listener);
|
|
96
|
+
delete button.dataset.styleflowThemeToggleBound;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=theme-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-runtime.js","sourceRoot":"","sources":["../src/theme-runtime.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,2BAA2B,GAAG,iBAAiB,CAAC;AAa7D,MAAM,UAAU,wBAAwB,CACtC,MAAyB,EACzB,YAAoB;IAEpB,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CACtD,OAAO,KAAK,KAAK,QAAQ,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAC5D,CAAC,CAAC,CAAC,CAAC;IACL,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC;QA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AAU,CAAC,YAAY,KAAK,MAAM;gBACpD,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC;YAClF,MAAM,KAAK,GAAG,MAAM,IAAI,WAAW,IAAI,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;gBACvE,CAAC,CAAC,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC;gBAC7C,CAAC,CAAC,kBAAkB,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACnD,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACrB,CAAC,CAAC;QACF,MAAM,CAAC,OAAO,CAAC,yBAAyB,GAAG,MAAM,CAAC;QAClD,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC3C,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAClC,CAAC;IACD,aAAa,EAAE,CAAC;IAChB,OAAO,GAAG,EAAE;QACV,KAAK,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC;YAC3C,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAC9C,OAAO,MAAM,CAAC,OAAO,CAAC,yBAAyB,CAAC;QAClD,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["export const STYLEFLOW_THEME_STORAGE_KEY = \"styleflow:theme\";\n\nexport interface StyleflowThemeRuntimeConfig {\n themes: string[];\n defaultTheme: string;\n}\n\ndeclare global {\n interface Window {\n __FLOWPRESS_STYLEFLOW_THEME_RUNTIME__?: StyleflowThemeRuntimeConfig;\n }\n}\n\nexport function normalizeStyleflowThemes(\n themes: readonly string[],\n defaultTheme: string\n): StyleflowThemeRuntimeConfig {\n const normalized = [...new Set(themes.filter((theme) => (\n typeof theme === \"string\" && /^[a-zA-Z0-9_-]+$/.test(theme)\n )))];\n const fallback = normalized.includes(defaultTheme)\n ? defaultTheme\n : normalized[0] ?? \"\";\n return { themes: normalized, defaultTheme: fallback };\n}\n\nexport function initialStyleflowTheme(\n themes: readonly string[],\n defaultTheme: string,\n storedTheme?: string | null\n): string {\n const config = normalizeStyleflowThemes(themes, defaultTheme);\n return storedTheme && config.themes.includes(storedTheme)\n ? storedTheme\n : config.defaultTheme;\n}\n\nexport function nextStyleflowTheme(\n themes: readonly string[],\n currentTheme: string\n): string {\n if (themes.length === 0) return \"\";\n const index = themes.indexOf(currentTheme);\n return themes[(index + 1 + themes.length) % themes.length] ?? themes[0] ?? \"\";\n}\n\nexport function styleflowThemeBootstrapScript(\n themes: readonly string[],\n defaultTheme: string\n): string {\n const config = normalizeStyleflowThemes(themes, defaultTheme);\n const json = JSON.stringify(config).replaceAll(\"<\", \"\\\\u003c\");\n return `(()=>{const c=${json};window.__FLOWPRESS_STYLEFLOW_THEME_RUNTIME__=c;if(!c.themes.length)return;let s=null;try{s=localStorage.getItem(${JSON.stringify(STYLEFLOW_THEME_STORAGE_KEY)})}catch{}const t=c.themes.includes(s)?s:c.defaultTheme;document.documentElement.setAttribute(\"data-styleflow-theme\",t)})()`;\n}\n\nexport function initializeStyleflowThemeRuntime(\n config: StyleflowThemeRuntimeConfig = window.__FLOWPRESS_STYLEFLOW_THEME_RUNTIME__\n ?? { themes: [], defaultTheme: \"\" },\n documentObject: Document = document,\n storage?: Pick<Storage, \"getItem\" | \"setItem\"> | null\n): () => void {\n const normalized = normalizeStyleflowThemes(config.themes, config.defaultTheme);\n if (normalized.themes.length === 0) return () => undefined;\n let storageObject = storage;\n if (storageObject === undefined) {\n try { storageObject = globalThis.localStorage; } catch { storageObject = null; }\n }\n const root = documentObject.documentElement;\n let current = initialStyleflowTheme(\n normalized.themes,\n normalized.defaultTheme,\n root.getAttribute(\"data-styleflow-theme\")\n );\n const buttons = [...documentObject.querySelectorAll<HTMLElement>(\n \"[data-styleflow-theme-toggle]\"\n )];\n const updateButtons = () => {\n for (const button of buttons) {\n const baseLabel = button.dataset.styleflowThemeToggleLabel\n || button.getAttribute(\"aria-label\")\n || \"Change color theme\";\n button.dataset.styleflowThemeToggleLabel = baseLabel.replace(/: .+$/, \"\");\n if (button.getAttribute(\"role\") === \"switch\") {\n button.setAttribute(\"aria-checked\", String(current === (button.dataset.styleflowThemeToggleTarget || \"dark\")));\n } else {\n button.setAttribute(\"aria-label\", `${button.dataset.styleflowThemeToggleLabel}: ${current}`);\n }\n const label = button.querySelector<HTMLElement>(\"[data-styleflow-theme-label]\")\n ?? button.closest(\".flowpress-theme-control\")?.querySelector<HTMLElement>(\"[data-styleflow-theme-label]\");\n if (label) label.textContent = current;\n }\n };\n const apply = (theme: string, persist: boolean) => {\n current = theme;\n root.setAttribute(\"data-styleflow-theme\", theme);\n if (persist && storageObject) {\n try { storageObject.setItem(STYLEFLOW_THEME_STORAGE_KEY, theme); } catch { /* noop */ }\n }\n updateButtons();\n documentObject.dispatchEvent(new CustomEvent(\"styleflow:theme-change\", {\n detail: { theme }\n }));\n };\n const listeners = new Map<HTMLElement, EventListener>();\n for (const button of buttons) {\n if (button.dataset.styleflowThemeToggleBound === \"true\") continue;\n const listener = () => {\n const target = button.dataset.styleflowThemeToggleTarget;\n const alternative = normalized.defaultTheme !== target\n ? normalized.defaultTheme : normalized.themes.find((theme) => theme !== target);\n const theme = target && alternative && normalized.themes.includes(target)\n ? (current === target ? alternative : target)\n : nextStyleflowTheme(normalized.themes, current);\n apply(theme, true);\n };\n button.dataset.styleflowThemeToggleBound = \"true\";\n button.addEventListener(\"click\", listener);\n listeners.set(button, listener);\n }\n updateButtons();\n return () => {\n for (const [button, listener] of listeners) {\n button.removeEventListener(\"click\", listener);\n delete button.dataset.styleflowThemeToggleBound;\n }\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/astro.d.ts","../src/block-renderers.ts","../src/carousel.ts","../src/client.ts","../src/env.ts","../src/index.ts","../src/links.ts","../src/number-spinner.ts","../src/style-classes.ts","../src/styleflow.ts","../src/template-hierarchy.ts","../src/
|
|
1
|
+
{"root":["../src/accessibility-panel.ts","../src/astro.d.ts","../src/block-renderers.ts","../src/build-cache.ts","../src/carousel.ts","../src/client.ts","../src/composition.ts","../src/default-blocks.ts","../src/env.ts","../src/index.ts","../src/links.ts","../src/media.ts","../src/motion-preference.ts","../src/number-spinner.ts","../src/preferences-runtime.ts","../src/preferences-styleflow.ts","../src/preferences.ts","../src/reserved-area.ts","../src/style-classes.ts","../src/styleflow.ts","../src/svg-media-types.ts","../src/svg-media.ts","../src/template-hierarchy.ts","../src/text.ts","../src/theme-runtime.ts","../src/types.ts","../src/vivid-colors-preference.ts","../src/astro/blocks/cover.ts","../src/astro/blocks/helpers.ts","../src/astro/motion/accordion.ts","../src/astro/motion/motion-controller.ts","../src/astro/motion/motion.ts","../src/astro/native/button-template.ts","../src/astro/native/button.ts","../src/astro/native/flowpress-navigation-controller.ts","../src/astro/native/grid.ts","../src/astro/native/group.ts","../src/astro/native/html.ts","../src/astro/native/icon.ts","../src/astro/native/image.ts","../src/astro/native/map.ts","../src/astro/native/motion-preference.ts","../src/astro/native/motion.ts","../src/astro/native/query-carousel.ts","../src/astro/native/query-loop.ts","../src/astro/native/registry.ts","../src/astro/native/timeline.ts","../src/astro/native/blob/blob-shapes.generated.ts","../src/astro/native/blob/config.ts","../src/astro/native/blob/controller.ts","../src/astro/native/blob/geometry.ts","../src/astro/native/blob/ids.ts","../src/svg-media-runtime.js","../src/astro/native/grid-bleed.js"],"version":"5.9.3"}
|
package/dist/types.d.ts
CHANGED
|
@@ -94,12 +94,85 @@ export interface FlowpressContent {
|
|
|
94
94
|
projectFields?: Record<string, unknown> | null;
|
|
95
95
|
[key: string]: unknown;
|
|
96
96
|
}
|
|
97
|
+
export interface FlowpressBlockAuthoringAttributes extends Record<string, unknown> {
|
|
98
|
+
anchor?: string;
|
|
99
|
+
className?: string;
|
|
100
|
+
style?: {
|
|
101
|
+
css?: string;
|
|
102
|
+
[key: string]: unknown;
|
|
103
|
+
};
|
|
104
|
+
theme?: string;
|
|
105
|
+
tone?: string;
|
|
106
|
+
intensity?: string;
|
|
107
|
+
surface?: string;
|
|
108
|
+
foreground?: string;
|
|
109
|
+
layoutRole?: string;
|
|
110
|
+
density?: string;
|
|
111
|
+
ty?: string;
|
|
112
|
+
v?: string;
|
|
113
|
+
w?: string;
|
|
114
|
+
interactivePriority?: string;
|
|
115
|
+
noBackground?: boolean;
|
|
116
|
+
noBorder?: boolean;
|
|
117
|
+
noPadding?: boolean;
|
|
118
|
+
noGap?: boolean;
|
|
119
|
+
noRadius?: boolean;
|
|
120
|
+
noForeground?: boolean;
|
|
121
|
+
htmlAttributes?: Record<string, unknown>;
|
|
122
|
+
}
|
|
123
|
+
export interface FlowpressBlockHtmlProps {
|
|
124
|
+
id?: string;
|
|
125
|
+
class?: string;
|
|
126
|
+
[name: string]: string | number | boolean | undefined;
|
|
127
|
+
}
|
|
97
128
|
export interface FlowpressBlock {
|
|
98
129
|
name: string;
|
|
99
|
-
attributes:
|
|
130
|
+
attributes: FlowpressBlockAuthoringAttributes;
|
|
131
|
+
resolvedData?: Record<string, unknown> | null;
|
|
100
132
|
innerHtml?: string | null;
|
|
101
133
|
innerBlocks?: FlowpressBlock[];
|
|
102
134
|
}
|
|
135
|
+
export interface FlowpressCompositionStylesheet {
|
|
136
|
+
id: string;
|
|
137
|
+
css: string;
|
|
138
|
+
}
|
|
139
|
+
export type FlowpressBlockAdapterStatus = "draft" | "ready";
|
|
140
|
+
export type FlowpressBlockClass = "static" | "entity" | "query" | "interactive";
|
|
141
|
+
export interface FlowpressBlockTypeDescriptor {
|
|
142
|
+
blockName: string;
|
|
143
|
+
fingerprint: string;
|
|
144
|
+
apiVersion?: number | null;
|
|
145
|
+
dynamic: boolean;
|
|
146
|
+
}
|
|
147
|
+
export interface FlowpressCompositionDiagnostic {
|
|
148
|
+
code: string;
|
|
149
|
+
message: string;
|
|
150
|
+
blocking: boolean;
|
|
151
|
+
blockName?: string | null;
|
|
152
|
+
path?: string | null;
|
|
153
|
+
command?: string | null;
|
|
154
|
+
}
|
|
155
|
+
export interface FlowpressCompositionTemplate {
|
|
156
|
+
id: string;
|
|
157
|
+
slug: string;
|
|
158
|
+
theme: string;
|
|
159
|
+
type: "wp_template";
|
|
160
|
+
source?: string | null;
|
|
161
|
+
status: string;
|
|
162
|
+
title?: string | null;
|
|
163
|
+
}
|
|
164
|
+
export interface FlowpressCompositionV1 {
|
|
165
|
+
version: "1";
|
|
166
|
+
sourceDigest: string;
|
|
167
|
+
template: FlowpressCompositionTemplate;
|
|
168
|
+
blocks: FlowpressBlock[];
|
|
169
|
+
stylesheets: FlowpressCompositionStylesheet[];
|
|
170
|
+
blockTypes: FlowpressBlockTypeDescriptor[];
|
|
171
|
+
diagnostics: FlowpressCompositionDiagnostic[];
|
|
172
|
+
route: FlowpressRoute;
|
|
173
|
+
locale?: string | null;
|
|
174
|
+
content?: FlowpressContent | null;
|
|
175
|
+
}
|
|
103
176
|
export interface FlowpressTemplateProps {
|
|
104
177
|
route: FlowpressRoute;
|
|
105
178
|
content: FlowpressContent | null;
|
|
@@ -107,6 +180,7 @@ export interface FlowpressTemplateProps {
|
|
|
107
180
|
templateName: string;
|
|
108
181
|
templateCandidates: string[];
|
|
109
182
|
styleflowContract?: import("./styleflow.js").StyleflowContract;
|
|
183
|
+
composition?: FlowpressCompositionV1 | null;
|
|
110
184
|
}
|
|
111
185
|
export interface TemplateContext {
|
|
112
186
|
queryType: FlowpressQueryType;
|