@pyreon/zero 0.15.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/lib/{api-routes-DANluJic.js → api-routes-Ci0kVmM4.js} +2 -2
  2. package/lib/client.js +4 -1
  3. package/lib/env.js +6 -6
  4. package/lib/font.js +3 -3
  5. package/lib/{fs-router-ZebyutPa.js → fs-router-MewHc5SB.js} +25 -30
  6. package/lib/i18n-routing.js +112 -1
  7. package/lib/image.js +140 -58
  8. package/lib/index.js +252 -82
  9. package/lib/og-image.js +5 -5
  10. package/lib/rolldown-runtime-CjeV3_4I.js +18 -0
  11. package/lib/script.js +114 -25
  12. package/lib/seo.js +186 -15
  13. package/lib/server.js +274 -564
  14. package/lib/types/config.d.ts +307 -3
  15. package/lib/types/env.d.ts +2 -2
  16. package/lib/types/i18n-routing.d.ts +193 -2
  17. package/lib/types/image.d.ts +105 -5
  18. package/lib/types/index.d.ts +666 -182
  19. package/lib/types/script.d.ts +78 -6
  20. package/lib/types/seo.d.ts +128 -4
  21. package/lib/types/server.d.ts +607 -72
  22. package/lib/vite-plugin-y0NmCLJA.js +2476 -0
  23. package/package.json +11 -10
  24. package/src/adapters/bun.ts +20 -1
  25. package/src/adapters/cloudflare.ts +78 -1
  26. package/src/adapters/index.ts +25 -3
  27. package/src/adapters/netlify.ts +63 -1
  28. package/src/adapters/node.ts +25 -1
  29. package/src/adapters/static.ts +26 -1
  30. package/src/adapters/validate.ts +8 -1
  31. package/src/adapters/vercel.ts +76 -1
  32. package/src/adapters/warn-missing-env.ts +49 -0
  33. package/src/app.ts +14 -0
  34. package/src/client.ts +18 -0
  35. package/src/entry-server.ts +55 -5
  36. package/src/env.ts +7 -7
  37. package/src/font.ts +3 -3
  38. package/src/fs-router.ts +72 -3
  39. package/src/i18n-routing.ts +246 -12
  40. package/src/image.tsx +242 -91
  41. package/src/index.ts +4 -4
  42. package/src/isr.ts +24 -6
  43. package/src/manifest.ts +675 -0
  44. package/src/og-image.ts +5 -5
  45. package/src/script.tsx +159 -36
  46. package/src/seo.ts +346 -15
  47. package/src/server.ts +10 -2
  48. package/src/ssg-plugin.ts +1211 -54
  49. package/src/types.ts +333 -10
  50. package/src/vercel-revalidate-handler.ts +204 -0
  51. package/src/vite-plugin.ts +171 -41
  52. package/lib/vite-plugin-E4BHYvYW.js +0 -855
@@ -1,4 +1,4 @@
1
- import { VNodeChild } from "@pyreon/core";
1
+ import { Ref, VNodeChild } from "@pyreon/core";
2
2
  //#region src/image-plugin.d.ts
3
3
  /** Per-format source set for <picture> <source> elements. */
4
4
  interface FormatSource {
@@ -42,6 +42,9 @@ interface ImageProps {
42
42
  * Raw mode — renders a plain `<img>` without the container div,
43
43
  * aspect-ratio, max-width, or lazy loading wrapper.
44
44
  * Use when the Image is inside a custom layout (absolute positioning, etc.).
45
+ *
46
+ * Note: `raw` skips the three-layer API entirely. `useImage` / `createImage`
47
+ * do not apply when `raw: true` — the component returns a bare `<img>`.
45
48
  */
46
49
  raw?: boolean;
47
50
  }
@@ -49,9 +52,106 @@ interface ImageSource {
49
52
  src: string;
50
53
  width: number;
51
54
  }
55
+ /** Return type of {@link useImage}. */
56
+ interface UseImageReturn {
57
+ /** Ref — attach to the container element for IntersectionObserver. */
58
+ containerRef: Ref<HTMLElement>;
59
+ /** Whether the image has entered the viewport (and started loading). */
60
+ inView: () => boolean;
61
+ /** Whether the `<img>` onLoad has fired. */
62
+ loaded: () => boolean;
63
+ /** Resolved `src` accessor — empty string until inView, then `props.src`. */
64
+ src: () => string;
65
+ /** Resolved srcSet accessor — empty until inView; empty when `formats` is set (srcset moves to `<source>` elements). */
66
+ srcSet: () => string;
67
+ /** `sizes` attribute or undefined when no srcset. */
68
+ sizes: string | undefined;
69
+ /** `aspect-ratio` CSS value (`"${width} / ${height}"`). */
70
+ aspectRatio: string;
71
+ /** Resolved CSS for the container — position + overflow + aspect-ratio + max-width + caller's `style`. */
72
+ containerStyle: string;
73
+ /** Resolved CSS accessor for the `<img>` — fit + transition + opacity (placeholder fade). */
74
+ imageStyle: () => string;
75
+ /** Resolved CSS accessor for the placeholder `<img>` (only meaningful when `placeholder` is set). */
76
+ placeholderStyle: () => string;
77
+ /** `loading` attribute — eager when priority/eager, else lazy. */
78
+ loading: 'lazy' | 'eager';
79
+ /** `fetchPriority` — 'high' when priority, else undefined. */
80
+ fetchPriority: 'high' | undefined;
81
+ /** onLoad handler — sets the loaded signal. Wire into the rendered `<img>`. */
82
+ handleLoad: () => void;
83
+ /** Resolved per-format <source> descriptors (or undefined when no formats). */
84
+ formats: FormatSource[] | undefined;
85
+ /** Whether `formats` is non-empty (i.e. consumer should render a `<picture>` wrapper). */
86
+ hasFormats: boolean;
87
+ }
88
+ /** Props passed to a custom component via {@link createImage}. */
89
+ interface ImageRenderProps {
90
+ /** Container ref. */
91
+ containerRef: Ref<HTMLElement>;
92
+ /** CSS class for the container. */
93
+ class: string | undefined;
94
+ /** Resolved container `style` string. */
95
+ containerStyle: string;
96
+ /** Pre-rendered placeholder `<img>` (or `null` when `placeholder` is unset). */
97
+ placeholder: VNodeChild;
98
+ /** Pre-rendered image — either a bare `<img>` or a `<picture>` tree when `formats` is set. */
99
+ image: VNodeChild;
100
+ }
101
+ /**
102
+ * Composable that provides all image optimization behavior — lazy loading,
103
+ * srcset/sizes resolution, format selection, blur-placeholder state,
104
+ * load tracking.
105
+ *
106
+ * Use this for full control when `createImage` is too opinionated about
107
+ * the surrounding markup (e.g. custom container layouts, non-`<div>`
108
+ * wrappers, additional overlay elements).
109
+ *
110
+ * @example
111
+ * function MyImage(props: ImageProps) {
112
+ * const img = useImage(props)
113
+ * return (
114
+ * <figure ref={img.containerRef} style={img.containerStyle}>
115
+ * <img
116
+ * src={img.src}
117
+ * srcSet={img.srcSet}
118
+ * sizes={img.sizes}
119
+ * alt={props.alt}
120
+ * loading={img.loading}
121
+ * onLoad={img.handleLoad}
122
+ * style={img.imageStyle}
123
+ * />
124
+ * <figcaption>{props.alt}</figcaption>
125
+ * </figure>
126
+ * )
127
+ * }
128
+ */
129
+ declare function useImage(props: ImageProps): UseImageReturn;
130
+ /**
131
+ * Higher-order component that wraps any component with image optimization.
132
+ *
133
+ * The wrapped component receives {@link ImageRenderProps} with the pre-rendered
134
+ * `image` JSX (bare `<img>` OR `<picture>` tree depending on formats), the
135
+ * pre-rendered `placeholder` JSX, and the container ref + styles. Consumers
136
+ * compose those pieces with whatever wrapper element / layout they want.
137
+ *
138
+ * @example
139
+ * // Custom figure-based image with caption
140
+ * const FigureImage = createImage((props) => (
141
+ * <figure ref={props.containerRef} class={props.class} style={props.containerStyle}>
142
+ * {props.placeholder}
143
+ * {props.image}
144
+ * <figcaption>Caption goes here</figcaption>
145
+ * </figure>
146
+ * ))
147
+ *
148
+ * // Usage — identical to default <Image>
149
+ * <FigureImage src="/hero.jpg" alt="Hero" width={1200} height={630} />
150
+ */
151
+ declare function createImage(Component: (p: ImageRenderProps) => any): (props: ImageProps) => any;
52
152
  /**
53
- * Optimized image component with lazy loading, responsive images,
54
- * multi-format <picture> support, and blur-up placeholders.
153
+ * Default optimized image component with lazy loading, responsive srcset,
154
+ * `<picture>` multi-format support, and blur-up placeholders.
55
155
  *
56
156
  * @example
57
157
  * // With imagePlugin — spread the import directly
@@ -62,7 +162,7 @@ interface ImageSource {
62
162
  * // Manual usage
63
163
  * <Image src="/hero.jpg" alt="Hero" width={1200} height={630} />
64
164
  */
65
- declare function Image(props: ImageProps): VNodeChild;
165
+ declare const Image: (props: ImageProps) => any;
66
166
  //#endregion
67
- export { Image, ImageProps, ImageSource };
167
+ export { Image, ImageProps, ImageRenderProps, ImageSource, UseImageReturn, createImage, useImage };
68
168
  //# sourceMappingURL=image2.d.ts.map