@easy-web/content-blocks 1.3.3 → 1.4.1

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.
Files changed (54) hide show
  1. package/README.md +10 -395
  2. package/dist/schemas/galleries.d.ts +3 -316
  3. package/dist/schemas/galleries.d.ts.map +1 -1
  4. package/dist/schemas/galleries.js +3 -133
  5. package/dist/schemas/galleries.js.map +1 -1
  6. package/dist/schemas/notFound.d.ts +3 -32
  7. package/dist/schemas/notFound.d.ts.map +1 -1
  8. package/dist/schemas/notFound.js +3 -27
  9. package/dist/schemas/notFound.js.map +1 -1
  10. package/package.json +3 -4
  11. package/src/components/BlogPostCard.astro +8 -74
  12. package/src/components/Card.astro +8 -65
  13. package/src/components/CardGrid.astro +8 -24
  14. package/src/components/ContactSection.astro +8 -68
  15. package/src/components/CtaSection.astro +8 -77
  16. package/src/components/DraftBanner.astro +8 -28
  17. package/src/components/Footer.astro +8 -76
  18. package/src/components/GalleryCarousel.astro +9 -292
  19. package/src/components/GalleryFeatureHighlight.astro +9 -149
  20. package/src/components/GalleryHeroSlider.astro +9 -358
  21. package/src/components/GalleryImageGrid.astro +9 -139
  22. package/src/components/GalleryLightboxGrid.astro +9 -349
  23. package/src/components/GalleryMasonryGrid.astro +9 -123
  24. package/src/components/GallerySection.astro +9 -65
  25. package/src/components/Header.astro +13 -217
  26. package/src/components/HeaderCentered.astro +17 -242
  27. package/src/components/HeaderFlyout.astro +13 -380
  28. package/src/components/HeaderHideOnScroll.astro +17 -248
  29. package/src/components/Hero.astro +8 -73
  30. package/src/components/LanguageNotice.astro +8 -27
  31. package/src/components/LanguageSwitch.astro +7 -65
  32. package/src/components/LegalLayout.astro +8 -57
  33. package/src/components/NotFound.astro +7 -118
  34. package/src/components/PageShell.astro +7 -79
  35. package/src/components/Prose.astro +10 -153
  36. package/src/components/Section.astro +8 -32
  37. package/src/components/ThemeToggle.astro +8 -77
  38. package/src/components/UniversalMedia.astro +7 -96
  39. package/src/schemas/galleries.ts +3 -150
  40. package/src/schemas/notFound.ts +3 -31
  41. package/dist/__tests__/exports-resolution.test.d.ts +0 -2
  42. package/dist/__tests__/exports-resolution.test.d.ts.map +0 -1
  43. package/dist/__tests__/exports-resolution.test.js +0 -83
  44. package/dist/__tests__/exports-resolution.test.js.map +0 -1
  45. package/dist/components/__tests__/UniversalMedia.test.d.ts +0 -2
  46. package/dist/components/__tests__/UniversalMedia.test.d.ts.map +0 -1
  47. package/dist/components/__tests__/UniversalMedia.test.js +0 -46
  48. package/dist/components/__tests__/UniversalMedia.test.js.map +0 -1
  49. package/dist/schemas/__tests__/notFound.test.d.ts +0 -2
  50. package/dist/schemas/__tests__/notFound.test.d.ts.map +0 -1
  51. package/dist/schemas/__tests__/notFound.test.js +0 -29
  52. package/dist/schemas/__tests__/notFound.test.js.map +0 -1
  53. package/src/components/__tests__/UniversalMedia.test.ts +0 -65
  54. package/src/schemas/__tests__/notFound.test.ts +0 -32
@@ -1,37 +1,13 @@
1
1
  ---
2
2
  /**
3
- * Section – semantic wrapper with optional heading, constrained width, and slot.
4
- * Pure Astro component using --ew-* design tokens.
3
+ * @deprecated Import `@easy-web/core/components/Section.astro` instead.
4
+ * Compatibility wrapper: renders the core component with the same props and slots.
5
5
  */
6
- interface Props {
7
- title?: string;
8
- id?: string;
9
- }
6
+ import type { ComponentProps } from 'astro/types';
7
+ import Section from '@easy-web/core/components/Section.astro';
10
8
 
11
- const { title, id } = Astro.props;
12
- ---
13
-
14
- <section class="ew-section" id={id}>
15
- <div class="ew-section__inner">
16
- {title && <h2 class="ew-section__title">{title}</h2>}
17
- <slot />
18
- </div>
19
- </section>
9
+ type Props = ComponentProps<typeof Section>;
20
10
 
21
- <style>
22
- .ew-section {
23
- padding: var(--ew-space-8) var(--ew-space-5);
24
- }
25
- .ew-section__inner {
26
- max-width: 72rem;
27
- margin: 0 auto;
28
- }
29
- .ew-section__title {
30
- font-family: var(--ew-font-sans);
31
- font-size: var(--ew-text-xl);
32
- font-weight: 700;
33
- color: var(--ew-on-surface);
34
- margin: 0 0 var(--ew-space-5);
35
- line-height: var(--ew-leading-tight);
36
- }
37
- </style>
11
+ const props = Astro.props;
12
+ ---
13
+ <Section {...props}><slot /></Section>
@@ -1,82 +1,13 @@
1
1
  ---
2
2
  /**
3
- * ThemeToggle – switches between light and dark themes using @easy-web/theme-core.
4
- * Pure Astro component with inline vanilla JS. No framework dependency.
3
+ * @deprecated Import `@easy-web/core/components/ThemeToggle.astro` instead.
4
+ * Compatibility wrapper: renders the core component with the same props and slots.
5
5
  */
6
- interface Props {
7
- /** Accessible label for the toggle button. */
8
- label?: string;
9
- }
6
+ import type { ComponentProps } from 'astro/types';
7
+ import ThemeToggle from '@easy-web/core/components/ThemeToggle.astro';
10
8
 
11
- const { label = 'Toggle color theme (Darkmode)' } = Astro.props;
12
- ---
13
-
14
- <button
15
- type="button"
16
- class="ew-theme-toggle"
17
- aria-label={label}
18
- title={label}
19
- >
20
- <svg class="ew-theme-toggle__icon ew-theme-toggle__icon--sun" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
21
- <circle cx="12" cy="12" r="5"></circle>
22
- <line x1="12" y1="1" x2="12" y2="3"></line>
23
- <line x1="12" y1="21" x2="12" y2="23"></line>
24
- <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
25
- <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
26
- <line x1="1" y1="12" x2="3" y2="12"></line>
27
- <line x1="21" y1="12" x2="23" y2="12"></line>
28
- <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
29
- <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
30
- </svg>
31
- <svg class="ew-theme-toggle__icon ew-theme-toggle__icon--moon" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
32
- <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
33
- </svg>
34
- </button>
35
-
36
- <style>
37
- .ew-theme-toggle {
38
- display: inline-flex;
39
- align-items: center;
40
- justify-content: center;
41
- box-sizing: border-box;
42
- /* Shared header-control height. Icon-only → same value for width for a square button. */
43
- width: 2.25rem;
44
- height: 2.25rem;
45
- background: transparent;
46
- border: 1px solid var(--ew-border);
47
- border-radius: var(--ew-radius-md);
48
- color: var(--ew-on-surface);
49
- cursor: pointer;
50
- padding: 0;
51
- }
52
- .ew-theme-toggle:hover {
53
- background: var(--ew-surface-muted);
54
- }
55
- .ew-theme-toggle:focus-visible {
56
- outline: 2px solid var(--ew-primary);
57
- outline-offset: 2px;
58
- }
59
-
60
- /* Default: show sun, hide moon (light mode) */
61
- .ew-theme-toggle__icon--moon { display: none; }
62
- .ew-theme-toggle__icon--sun { display: block; }
9
+ type Props = ComponentProps<typeof ThemeToggle>;
63
10
 
64
- :global([data-theme="dark"]) .ew-theme-toggle__icon--sun { display: none; }
65
- :global([data-theme="dark"]) .ew-theme-toggle__icon--moon { display: block; }
66
-
67
- @media (prefers-color-scheme: dark) {
68
- :global(:root:not([data-theme="light"])) .ew-theme-toggle__icon--sun { display: none; }
69
- :global(:root:not([data-theme="light"])) .ew-theme-toggle__icon--moon { display: block; }
70
- }
71
- </style>
72
-
73
- <script>
74
- import { applyTheme, getPreferredTheme } from '@easy-web/theme-core';
75
-
76
- const btn = document.querySelector('.ew-theme-toggle') as HTMLButtonElement | null;
77
- btn?.addEventListener('click', () => {
78
- const current = getPreferredTheme();
79
- const next = current === 'dark' ? 'light' : 'dark';
80
- applyTheme(next);
81
- });
82
- </script>
11
+ const props = Astro.props;
12
+ ---
13
+ <ThemeToggle {...props} />
@@ -1,102 +1,13 @@
1
1
  ---
2
2
  /**
3
- * UniversalMedia — renders an image from any source type.
4
- *
5
- * @remarks
6
- * Supported image formats: JPEG, PNG, WebP, AVIF, SVG, GIF.
7
- * Unsupported formats (upload rejected at CMS level): HEIC, JXL.
8
- *
9
- * 4-case dispatch:
10
- * 1. ImageMetadata object → <Image> (Astro-optimised, with srcset)
11
- * 2. "/src/assets/..." string → glob lookup via `images` prop → <Image> (fallback to fallbackSrc)
12
- * 3. External URL ("http..." or "https...") → <Image inferSize>
13
- * 4. Everything else (public-folder path "/foo/bar.png") → plain <img>
3
+ * @deprecated Import `@easy-web/core/components/UniversalMedia.astro` instead.
4
+ * Compatibility wrapper: renders the core component with the same props and slots.
14
5
  */
15
- import { Image } from 'astro:assets';
16
- import type { ImageMetadata } from 'astro';
6
+ import type { ComponentProps } from 'astro/types';
7
+ import UniversalMedia from '@easy-web/core/components/UniversalMedia.astro';
17
8
 
18
- interface Props {
19
- /** The image source: an Astro ImageMetadata object or a URL/path string. */
20
- src: ImageMetadata | string;
21
- /** Alt text for the image (required). */
22
- alt: string;
23
- /**
24
- * Consumer-supplied glob result mapping paths to lazy image loaders.
25
- * Consumer generates this via Vite's glob-import helper (see Astro/Vite docs)
26
- * matching `/src/assets/**` with `{ import: 'default' }` so entries yield
27
- * `() => Promise<{ default: ImageMetadata }>`.
28
- * The component does NOT resolve the glob itself.
29
- */
30
- images: Record<string, () => Promise<{ default: ImageMetadata }>>;
31
- /** Fallback image path to use when a /src/assets/... glob lookup misses. Defaults to empty (renders nothing gracefully). */
32
- fallbackSrc?: string;
33
- /** Fallback alt text used when fallbackSrc is rendered. Defaults to alt. */
34
- fallbackAlt?: string;
35
- width?: number;
36
- height?: number;
37
- class?: string;
38
- decoding?: 'async' | 'auto' | 'sync';
39
- }
9
+ type Props = ComponentProps<typeof UniversalMedia>;
40
10
 
41
- const {
42
- src,
43
- alt,
44
- images,
45
- fallbackSrc,
46
- fallbackAlt,
47
- width = 800,
48
- height = 600,
49
- class: cssClass = '',
50
- decoding = 'async',
51
- } = Astro.props;
52
-
53
- // Case 1: already a resolved ImageMetadata object
54
- const isImageMetadata = typeof src !== 'string';
55
-
56
- // Normalise string to check against known patterns
57
- const srcStr = isImageMetadata ? '' : (src as string);
58
-
59
- // Case 2: /src/assets/... path — must be resolved via consumer-supplied glob
60
- const isInternalSrcAssets = srcStr.startsWith('/src/assets/');
61
-
62
- // Case 3: external URL
63
- const isExternalUrl = srcStr.startsWith('http://') || srcStr.startsWith('https://');
64
-
65
- // Resolve ImageMetadata for cases 1 & 2
66
- let resolvedSrc: ImageMetadata | null = null;
67
- let resolvedAlt = alt;
68
-
69
- if (isImageMetadata) {
70
- resolvedSrc = src as ImageMetadata;
71
- } else if (isInternalSrcAssets) {
72
- const loader = images[srcStr];
73
- if (typeof loader === 'function') {
74
- const mod = await loader();
75
- resolvedSrc = mod.default ?? (mod as unknown as ImageMetadata);
76
- }
77
- if (!resolvedSrc && fallbackSrc) {
78
- const fallbackLoader = images[fallbackSrc];
79
- if (typeof fallbackLoader === 'function') {
80
- const mod = await fallbackLoader();
81
- resolvedSrc = mod.default ?? (mod as unknown as ImageMetadata);
82
- resolvedAlt = fallbackAlt ?? alt;
83
- } else {
84
- console.warn(
85
- `UniversalMedia: "${srcStr}" not found in glob, and fallbackSrc "${fallbackSrc}" is also missing. Rendering as plain <img>.`
86
- );
87
- }
88
- }
89
- }
11
+ const props = Astro.props;
90
12
  ---
91
-
92
- {isImageMetadata || isInternalSrcAssets ? (
93
- resolvedSrc ? (
94
- <Image class={cssClass} src={resolvedSrc} alt={resolvedAlt} width={width} height={height} decoding={decoding} />
95
- ) : (
96
- <img class={cssClass} src={srcStr} alt={alt} width={width} height={height} decoding={decoding} />
97
- )
98
- ) : isExternalUrl ? (
99
- <Image class={cssClass} src={srcStr} alt={alt} inferSize decoding={decoding} />
100
- ) : (
101
- <img class={cssClass} src={srcStr} alt={alt} width={width} height={height} decoding={decoding} />
102
- )}
13
+ <UniversalMedia {...props} />
@@ -1,152 +1,5 @@
1
1
  /**
2
- * Gallery content collection schema — discriminated union over supported variants.
3
- *
4
- * Each entry under a consuming site's `src/content/galleries/` selects a `kind`
5
- * that determines which Astro component renders it. Pages decide which entry
6
- * to load and where to place it; the entry decides what to show and how it is
7
- * laid out.
8
- *
9
- * Supported kinds: `image-grid`, `hero-slider`, `carousel`, `masonry-grid`,
10
- * `feature-highlight`, `lightbox-grid`. Adding a new kind requires updating
11
- * this union AND adding the matching component in `../components/`. Authoring
12
- * an unsupported `kind` fails Zod validation at build time.
13
- *
14
- * Usage:
15
- *
16
- * ```ts
17
- * import { defineCollection } from 'astro:content';
18
- * import { glob } from 'astro/loaders';
19
- * import { gallerySchema } from '@easy-web/content-blocks/schemas/galleries';
20
- *
21
- * const galleries = defineCollection({
22
- * loader: glob({ pattern: '**\/*.{yml,yaml}', base: './src/content/galleries' }),
23
- * schema: gallerySchema,
24
- * });
25
- * ```
2
+ * @deprecated Import from `@easy-web/core/schemas/galleries` instead.
3
+ * Compatibility re-export of the core schema module.
26
4
  */
27
- import { z } from 'zod';
28
-
29
- const galleryImageGridSchema = z.object({
30
- kind: z.literal('image-grid'),
31
- title: z.string().optional(),
32
- locale: z.enum(['de', 'en']),
33
- translationKey: z.string(),
34
- columns: z.union([z.literal(2), z.literal(3), z.literal(4), z.literal(6)]).default(3),
35
- gap: z.enum(['sm', 'md', 'lg']).default('md'),
36
- aspectRatio: z.enum(['square', '4/3', '16/9', 'auto']).default('square'),
37
- items: z.array(z.object({
38
- src: z.string().min(1),
39
- alt: z.string(),
40
- caption: z.string().optional(),
41
- href: z.string().optional(),
42
- })).min(1),
43
- });
44
-
45
- const galleryHeroSliderSchema = z.object({
46
- kind: z.literal('hero-slider'),
47
- title: z.string().optional(),
48
- locale: z.enum(['de', 'en']),
49
- translationKey: z.string(),
50
- autoplay: z.boolean().default(true),
51
- interval: z.number().int().positive().default(5000),
52
- height: z.enum(['sm', 'md', 'lg', 'full']).default('lg'),
53
- slides: z.array(z.object({
54
- src: z.string().min(1),
55
- alt: z.string(),
56
- title: z.string(),
57
- subtitle: z.string().optional(),
58
- href: z.string().optional(),
59
- cta: z.string().optional(),
60
- })).min(1),
61
- });
62
-
63
- const galleryCarouselSchema = z.object({
64
- kind: z.literal('carousel'),
65
- title: z.string().optional(),
66
- locale: z.enum(['de', 'en']),
67
- translationKey: z.string(),
68
- autoplay: z.boolean().default(false),
69
- interval: z.number().int().positive().default(4000),
70
- showDots: z.boolean().default(true),
71
- showArrows: z.boolean().default(true),
72
- slides: z.array(z.object({
73
- src: z.string().min(1),
74
- alt: z.string(),
75
- caption: z.string().optional(),
76
- })).min(1),
77
- });
78
-
79
- const galleryMasonryGridSchema = z.object({
80
- kind: z.literal('masonry-grid'),
81
- title: z.string().optional(),
82
- locale: z.enum(['de', 'en']),
83
- translationKey: z.string(),
84
- columns: z.union([z.literal(2), z.literal(3), z.literal(4)]).default(3),
85
- gap: z.enum(['sm', 'md', 'lg']).default('md'),
86
- items: z.array(z.object({
87
- src: z.string().min(1),
88
- alt: z.string(),
89
- caption: z.string().optional(),
90
- href: z.string().optional(),
91
- })).min(1),
92
- });
93
-
94
- const galleryFeatureHighlightSchema = z.object({
95
- kind: z.literal('feature-highlight'),
96
- title: z.string().optional(),
97
- locale: z.enum(['de', 'en']),
98
- translationKey: z.string(),
99
- gap: z.enum(['sm', 'md', 'lg']).default('lg'),
100
- items: z.array(z.object({
101
- src: z.string().min(1),
102
- alt: z.string(),
103
- title: z.string(),
104
- description: z.string(),
105
- href: z.string().optional(),
106
- cta: z.string().optional(),
107
- imagePosition: z.enum(['left', 'right']).optional(),
108
- })).min(1),
109
- });
110
-
111
- const galleryLightboxGridSchema = z.object({
112
- kind: z.literal('lightbox-grid'),
113
- title: z.string().optional(),
114
- locale: z.enum(['de', 'en']),
115
- translationKey: z.string(),
116
- columns: z.union([z.literal(2), z.literal(3), z.literal(4)]).default(3),
117
- gap: z.enum(['sm', 'md', 'lg']).default('md'),
118
- aspectRatio: z.enum(['square', '4/3', 'auto']).default('square'),
119
- items: z.array(z.object({
120
- src: z.string().min(1),
121
- alt: z.string(),
122
- title: z.string().optional(),
123
- description: z.string().optional(),
124
- })).min(1),
125
- });
126
-
127
- export const gallerySchema = z.discriminatedUnion('kind', [
128
- galleryImageGridSchema,
129
- galleryHeroSliderSchema,
130
- galleryCarouselSchema,
131
- galleryMasonryGridSchema,
132
- galleryFeatureHighlightSchema,
133
- galleryLightboxGridSchema,
134
- ]);
135
-
136
- export type GalleryEntry = z.infer<typeof gallerySchema>;
137
- export type GalleryImageGridData = z.infer<typeof galleryImageGridSchema>;
138
- export type GalleryHeroSliderData = z.infer<typeof galleryHeroSliderSchema>;
139
- export type GalleryCarouselData = z.infer<typeof galleryCarouselSchema>;
140
- export type GalleryMasonryGridData = z.infer<typeof galleryMasonryGridSchema>;
141
- export type GalleryFeatureHighlightData = z.infer<typeof galleryFeatureHighlightSchema>;
142
- export type GalleryLightboxGridData = z.infer<typeof galleryLightboxGridSchema>;
143
-
144
- export const GALLERY_KINDS = [
145
- 'image-grid',
146
- 'hero-slider',
147
- 'carousel',
148
- 'masonry-grid',
149
- 'feature-highlight',
150
- 'lightbox-grid',
151
- ] as const;
152
- export type GalleryKind = typeof GALLERY_KINDS[number];
5
+ export * from '@easy-web/core/schemas/galleries';
@@ -1,33 +1,5 @@
1
1
  /**
2
- * Not-found (404) singleton schema — locale-keyed CMS-editable content.
3
- *
4
- * Each locale key maps to an optional set of fields rendered by the site's
5
- * 404 page. All fields are optional so partial translations are valid; a
6
- * consuming page falls back to defaults when a field is absent.
7
- *
8
- * The record key is an open `z.string()` so any IETF locale tag (e.g. `de`,
9
- * `en`, `fr`, `sq`, `de-AT`) is accepted without schema changes. Do NOT add
10
- * SEO metadata (title, canonical) here — those belong to the page layer.
11
- *
12
- * Usage:
13
- *
14
- * ```ts
15
- * import { notFoundSchema } from '@easy-web/content-blocks/schemas/notFound';
16
- *
17
- * const data = notFoundSchema.parse(await import('../content/not-found.json'));
18
- * ```
19
- *
20
- * @see docs/decisions/0011-content-architecture-strategy.md
21
- * @see docs/decisions/0013-shared-not-found-primitives.md
2
+ * @deprecated Import from `@easy-web/core/schemas/notFound` instead.
3
+ * Compatibility re-export of the core schema module.
22
4
  */
23
- import { z } from 'zod';
24
-
25
- export const localizedNotFoundSchema = z.object({
26
- image: z.string().optional(),
27
- heading: z.string().optional(),
28
- message: z.string().optional(),
29
- });
30
-
31
- export const notFoundSchema = z.record(z.string(), localizedNotFoundSchema);
32
-
33
- export type NotFoundData = z.infer<typeof notFoundSchema>;
5
+ export * from '@easy-web/core/schemas/notFound';
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=exports-resolution.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exports-resolution.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/exports-resolution.test.ts"],"names":[],"mappings":""}
@@ -1,83 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { readdirSync, readFileSync } from 'node:fs';
3
- import { createRequire } from 'node:module';
4
- import path from 'node:path';
5
- import { fileURLToPath, pathToFileURL } from 'node:url';
6
- /**
7
- * Export-resolution smoke test.
8
- *
9
- * Every subpath export this package declares is resolved through Node's real
10
- * package-exports algorithm — not a regex, not a simulation. `createRequire()`
11
- * is anchored on this package's own `package.json`, so Node self-resolves the
12
- * `@easy-web/content-blocks/...` specifiers against the very `exports` block
13
- * under test.
14
- *
15
- * Fixtures are the package's own real components and schemas, discovered on
16
- * disk, so the probe list grows automatically with the package.
17
- *
18
- * Regression gate for issue #17: `"./components/*"` maps onto
19
- * `"./src/components/*.astro"`, which appends the extension to the capture.
20
- * The `.astro`-suffixed specifier the README documents therefore resolved to
21
- * `*.astro.astro` and threw `ERR_PACKAGE_PATH_NOT_EXPORTED`. Deleting the
22
- * `"./components/*.astro"` key must make this file fail.
23
- */
24
- const packageRoot = fileURLToPath(new URL('../../', import.meta.url));
25
- const packageJsonPath = path.join(packageRoot, 'package.json');
26
- const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
27
- const requireFromPackage = createRequire(pathToFileURL(packageJsonPath));
28
- /** Every `exports` key except the package root, which needs a build to exist. */
29
- const subpathEntries = Object.entries(pkg.exports).filter(([key]) => key !== '.');
30
- /**
31
- * Expand one `exports` entry into concrete probes, substituting the `*`
32
- * wildcard with every real file the target pattern matches on disk.
33
- */
34
- function expandProbes(key, target) {
35
- if (!key.includes('*')) {
36
- return [
37
- {
38
- key,
39
- specifier: `${pkg.name}${key.slice(1)}`,
40
- expectedFile: path.resolve(packageRoot, target),
41
- },
42
- ];
43
- }
44
- const [keyPrefix, keySuffix] = key.split('*');
45
- const [targetPrefix, targetSuffix] = target.split('*');
46
- const targetDir = path.resolve(packageRoot, targetPrefix);
47
- const captures = readdirSync(targetDir, { withFileTypes: true })
48
- .filter((entry) => entry.isFile() && entry.name.endsWith(targetSuffix))
49
- .map((entry) => (targetSuffix ? entry.name.slice(0, -targetSuffix.length) : entry.name))
50
- .sort();
51
- return captures.map((capture) => ({
52
- key,
53
- specifier: `${pkg.name}${keyPrefix.slice(1)}${capture}${keySuffix}`,
54
- expectedFile: path.resolve(packageRoot, `${targetPrefix}${capture}${targetSuffix}`),
55
- }));
56
- }
57
- const probes = subpathEntries.flatMap(([key, target]) => typeof target === 'string' ? expandProbes(key, target) : []);
58
- describe('@easy-web/content-blocks subpath exports', () => {
59
- it('declares the subpath exports its README documents', () => {
60
- expect(Object.keys(pkg.exports)).toEqual(expect.arrayContaining(['./components/*', './components/*.astro', './schemas/*']));
61
- });
62
- it('expands every declared subpath key into at least one real probe', () => {
63
- for (const [key, target] of subpathEntries) {
64
- expect(typeof target, `export key "${key}" has a conditional target; teach expandProbes() about it`).toBe('string');
65
- expect(probes.filter((probe) => probe.key === key).length, `export key "${key}" expanded to no probes — no fixture file matched its target`).toBeGreaterThan(0);
66
- }
67
- });
68
- it.each(probes.map((probe) => [probe.specifier, probe.expectedFile]))('resolves %s', (specifier, expectedFile) => {
69
- expect(requireFromPackage.resolve(specifier)).toBe(expectedFile);
70
- });
71
- });
72
- describe('@easy-web/content-blocks documented import forms (issue #17 regression gate)', () => {
73
- it('resolves Hero through both the extensionless and the .astro-suffixed form', () => {
74
- const extensionless = requireFromPackage.resolve('@easy-web/content-blocks/components/Hero');
75
- const withExtension = requireFromPackage.resolve('@easy-web/content-blocks/components/Hero.astro');
76
- expect(extensionless).toBe(path.resolve(packageRoot, 'src/components/Hero.astro'));
77
- expect(withExtension).toBe(extensionless);
78
- });
79
- it('resolves the galleries schema through the ./schemas/* wildcard', () => {
80
- expect(requireFromPackage.resolve('@easy-web/content-blocks/schemas/galleries')).toBe(path.resolve(packageRoot, 'src/schemas/galleries.ts'));
81
- });
82
- });
83
- //# sourceMappingURL=exports-resolution.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exports-resolution.test.js","sourceRoot":"","sources":["../../src/__tests__/exports-resolution.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAExD;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACtE,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;AAO/D,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAoB,CAAC;AACjF,MAAM,kBAAkB,GAAG,aAAa,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC;AAEzE,iFAAiF;AACjF,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,MAA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AG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,YAAY,CAAU,CAAC,CAAC,CAC5E,aAAa,EACb,CAAC,SAAS,EAAE,YAAY,EAAE,EAAE;QAC1B,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACnE,CAAC,CACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,8EAA8E,EAAE,GAAG,EAAE;IAC5F,EAAE,CAAC,2EAA2E,EAAE,GAAG,EAAE;QACnF,MAAM,aAAa,GAAG,kBAAkB,CAAC,OAAO,CAAC,0CAA0C,CAAC,CAAC;QAC7F,MAAM,aAAa,GAAG,kBAAkB,CAAC,OAAO,CAC9C,gDAAgD,CACjD,CAAC;QAEF,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,2BAA2B,CAAC,CAAC,CAAC;QACnF,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QACxE,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,4CAA4C,CAAC,CAAC,CAAC,IAAI,CACnF,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,0BAA0B,CAAC,CACtD,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=UniversalMedia.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UniversalMedia.test.d.ts","sourceRoot":"","sources":["../../../src/components/__tests__/UniversalMedia.test.ts"],"names":[],"mappings":""}
@@ -1,46 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- function classifySource(src) {
3
- if (typeof src !== 'string')
4
- return 'image-metadata';
5
- if (src.startsWith('/src/assets/'))
6
- return 'internal-src-assets';
7
- if (src.startsWith('http://') || src.startsWith('https://'))
8
- return 'external-url';
9
- return 'public-path';
10
- }
11
- // Minimal ImageMetadata stub for test case 1
12
- const mockImageMetadata = {
13
- src: '/src/assets/images/test.png',
14
- width: 100,
15
- height: 100,
16
- format: 'png',
17
- };
18
- describe('<UniversalMedia> dispatch logic', () => {
19
- it('case 1: ImageMetadata object → image-metadata', () => {
20
- expect(classifySource(mockImageMetadata)).toBe('image-metadata');
21
- });
22
- it('case 2: /src/assets/ string → internal-src-assets (glob lookup path)', () => {
23
- expect(classifySource('/src/assets/images/photo.jpg')).toBe('internal-src-assets');
24
- });
25
- it('case 3: https:// URL → external-url (inferSize path)', () => {
26
- expect(classifySource('https://example.com/photo.jpg')).toBe('external-url');
27
- });
28
- it('case 4: public path /foo/bar.png → public-path (plain img)', () => {
29
- expect(classifySource('/uploads/photo.jpg')).toBe('public-path');
30
- });
31
- it('case 5: glob miss + fallbackSrc → fallback branch applies when resolvedSrc is null', () => {
32
- // Simulate glob miss: empty images map for a /src/assets/ URL
33
- const images = {};
34
- const src = '/src/assets/images/missing.png';
35
- const fallbackSrc = '/src/assets/images/default.png';
36
- const dispatch = classifySource(src);
37
- expect(dispatch).toBe('internal-src-assets');
38
- // Verify fallback key lookup works
39
- const hasMainImage = src in images;
40
- const hasFallback = fallbackSrc in images;
41
- expect(hasMainImage).toBe(false); // glob miss
42
- expect(hasFallback).toBe(false); // fallback also missing → plain img fallback
43
- // The component would render plain <img> when both are missing (documented in UniversalMedia)
44
- });
45
- });
46
- //# sourceMappingURL=UniversalMedia.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UniversalMedia.test.js","sourceRoot":"","sources":["../../../src/components/__tests__/UniversalMedia.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAe9C,S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AAC;QAC7E,MAAM,GAAG,GAAG,gCAAgC,CAAC;QAC7C,MAAM,WAAW,GAAG,gCAAgC,CAAC;QAErD,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;QACrC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAE7C,mCAAmC;QACnC,MAAM,YAAY,GAAG,GAAG,IAAI,MAAM,CAAC;QACnC,MAAM,WAAW,GAAG,WAAW,IAAI,MAAM,CAAC;QAC1C,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY;QAC9C,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,6CAA6C;QAE9E,8FAA8F;IAChG,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=notFound.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notFound.test.d.ts","sourceRoot":"","sources":["../../../src/schemas/__tests__/notFound.test.ts"],"names":[],"mappings":""}
@@ -1,29 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { notFoundSchema } from '../notFound.js';
3
- describe('notFoundSchema', () => {
4
- it('parses a multi-locale object with partial fields', () => {
5
- const input = {
6
- de: { heading: 'Seite nicht gefunden', message: 'Existiert nicht.' },
7
- en: { heading: 'Not found' },
8
- };
9
- expect(() => notFoundSchema.parse(input)).not.toThrow();
10
- const result = notFoundSchema.parse(input);
11
- expect(result.de.heading).toBe('Seite nicht gefunden');
12
- expect(result.en.heading).toBe('Not found');
13
- });
14
- it('parses an empty object (all fields optional)', () => {
15
- expect(() => notFoundSchema.parse({})).not.toThrow();
16
- expect(notFoundSchema.parse({})).toEqual({});
17
- });
18
- it('parses arbitrary locale keys (open record)', () => {
19
- const input = { de: {}, fr: {}, sq: {} };
20
- expect(() => notFoundSchema.parse(input)).not.toThrow();
21
- const result = notFoundSchema.parse(input);
22
- expect(Object.keys(result)).toEqual(expect.arrayContaining(['de', 'fr', 'sq']));
23
- });
24
- it('rejects a record where image is not a string', () => {
25
- const input = { de: { image: 42 } };
26
- expect(() => notFoundSchema.parse(input)).toThrow();
27
- });
28
- });
29
- //# sourceMappingURL=notFound.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"notFound.test.js","sourceRoot":"","sources":["../../../src/schemas/__tests__/notFound.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,MAAM,KAAK,GAAG;YACZ,EAAE,EAAE,EAAE,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,kBAAkB,EAAE;YACpE,EAAE,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE;SAC7B,CAAC;QACF,MAAM,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACxD,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACvD,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,MAAM,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,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