@elytracms/next 0.0.91 → 0.0.93
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/dist/host-image.d.ts +14 -18
- package/dist/host-image.js.map +1 -1
- package/dist/index.d.ts +385 -233
- package/dist/index.js +291 -314
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/host-image.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { ResolvedAsset } from '@elytracms/core/cms-core';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* `@elytracms/next/host-image` — the host image-delivery seam for DUAL-RENDERED
|
|
@@ -37,26 +38,21 @@ import { ReactNode } from 'react';
|
|
|
37
38
|
* second singleton instance into the server entry, disconnecting
|
|
38
39
|
* `setHostImage` from `getHostImage` — pinned by `package-build.test.ts`).
|
|
39
40
|
*/
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
x: number;
|
|
48
|
-
y: number;
|
|
49
|
-
} | null;
|
|
50
|
-
/**
|
|
51
|
-
* LQIP blur-placeholder data URI (EC-420) → next/image blurDataURL. Optional so a
|
|
52
|
-
* consumer mapping a `ResolvedAsset` in stays source-compatible; when present the
|
|
53
|
-
* delivered image blurs up while the optimized bytes load.
|
|
54
|
-
*/
|
|
55
|
-
lqip?: string | null;
|
|
56
|
-
}
|
|
41
|
+
/**
|
|
42
|
+
* The resolved-asset slice a host image renderer needs — DERIVED from `ResolvedAsset`
|
|
43
|
+
* (EC-587; it used to mirror it by hand). `lqip` (EC-420 → next/image blurDataURL) is
|
|
44
|
+
* optional so a caller handing a partial asset stays source-compatible; when present
|
|
45
|
+
* the delivered image blurs up while the optimized bytes load.
|
|
46
|
+
*/
|
|
47
|
+
type HostImageAsset = Pick<ResolvedAsset, 'url' | 'width' | 'height' | 'alt' | 'focalPoint'> & Partial<Pick<ResolvedAsset, 'lqip'>>;
|
|
57
48
|
interface HostImageProps {
|
|
58
49
|
asset: HostImageAsset;
|
|
59
|
-
|
|
50
|
+
/**
|
|
51
|
+
* The image's alt text. Omitted → the ASSET's alt (EC-587: an asset's alt has one
|
|
52
|
+
* home and one reader). Pass it only to override deliberately — e.g. `''` for a
|
|
53
|
+
* decorative image.
|
|
54
|
+
*/
|
|
55
|
+
alt?: string;
|
|
60
56
|
className?: string;
|
|
61
57
|
loading?: 'eager' | 'lazy';
|
|
62
58
|
/** Above-the-fold opt-out of lazy-loading (the hero image). */
|
package/dist/host-image.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/host-image.ts"],"names":[],"mappings":";AAoEA,IAAI,SAAA,GAAsC,IAAA;AAGnC,SAAS,aAAa,QAAA,EAA0C;AACrE,EAAA,SAAA,GAAY,QAAA;AACd;AAGO,SAAS,YAAA,GAAyC;AACvD,EAAA,OAAO,SAAA;AACT;AAiBO,IAAM,yBAAA,GAAgF;AAAA,EAC3F,EAAE,QAAA,EAAU,OAAA,EAAS,QAAA,EAAU,gBAAA;AACjC","file":"host-image.js","sourcesContent":["import type { ReactNode } from 'react'\n\n/**\n * `@elytracms/next/host-image` — the host image-delivery seam for DUAL-RENDERED\n * project components (EC-368, from the consumer-proven EC-271 pattern).\n *\n * The `project.*` page-builder components are dual-rendered: the SAME module\n * renders in the Vite studio canvas AND the Next host (AD-2/AD-11), so it may\n * not statically import `next/image` — that would break the Vite build. And in\n * the Next host these components render as Server Components, where React\n * context is unavailable, so an optimized `<Image>` can't be threaded through a\n * provider either.\n *\n * The seam that satisfies both: a tiny module singleton the host sets once at\n * boot. The studio never sets it (it renders the components via the root\n * `elytra.config`, which never imports the Next host), so the canvas keeps a\n * plain-`<img>` fallback; the Next host injects the `ElytraImage`-backed\n * renderer so content images go through `next/image`'s optimizer:\n *\n * ```ts\n * // frontend/lib/host.ts — imported once by the catch-all route at boot\n * import { elytraHostImage } from '@elytracms/next'\n * import { setHostImage } from '@elytracms/next/host-image'\n *\n * setHostImage(elytraHostImage())\n * ```\n *\n * WHEN (and whether) to register stays consumer-owned — legacy-interop windows\n * are real: a host whose global `next/image` config is still owned by a\n * previous stack (e.g. a Sanity-era custom loader) deliberately skips\n * registration until the conflict clears, and its components keep the honest\n * plain-`<img>` fallback.\n *\n * This module is deliberately its OWN subpath entry importing nothing but React\n * types — safe in Vite, in RSC, and in `next.config.*`. The main\n * `@elytracms/next` entry never imports it at runtime (that would bundle a\n * second singleton instance into the server entry, disconnecting\n * `setHostImage` from `getHostImage` — pinned by `package-build.test.ts`).\n */\n\n
|
|
1
|
+
{"version":3,"sources":["../src/host-image.ts"],"names":[],"mappings":";AAoEA,IAAI,SAAA,GAAsC,IAAA;AAGnC,SAAS,aAAa,QAAA,EAA0C;AACrE,EAAA,SAAA,GAAY,QAAA;AACd;AAGO,SAAS,YAAA,GAAyC;AACvD,EAAA,OAAO,SAAA;AACT;AAiBO,IAAM,yBAAA,GAAgF;AAAA,EAC3F,EAAE,QAAA,EAAU,OAAA,EAAS,QAAA,EAAU,gBAAA;AACjC","file":"host-image.js","sourcesContent":["import type { ReactNode } from 'react'\nimport type { ResolvedAsset } from '@elytracms/core/cms-core'\n\n/**\n * `@elytracms/next/host-image` — the host image-delivery seam for DUAL-RENDERED\n * project components (EC-368, from the consumer-proven EC-271 pattern).\n *\n * The `project.*` page-builder components are dual-rendered: the SAME module\n * renders in the Vite studio canvas AND the Next host (AD-2/AD-11), so it may\n * not statically import `next/image` — that would break the Vite build. And in\n * the Next host these components render as Server Components, where React\n * context is unavailable, so an optimized `<Image>` can't be threaded through a\n * provider either.\n *\n * The seam that satisfies both: a tiny module singleton the host sets once at\n * boot. The studio never sets it (it renders the components via the root\n * `elytra.config`, which never imports the Next host), so the canvas keeps a\n * plain-`<img>` fallback; the Next host injects the `ElytraImage`-backed\n * renderer so content images go through `next/image`'s optimizer:\n *\n * ```ts\n * // frontend/lib/host.ts — imported once by the catch-all route at boot\n * import { elytraHostImage } from '@elytracms/next'\n * import { setHostImage } from '@elytracms/next/host-image'\n *\n * setHostImage(elytraHostImage())\n * ```\n *\n * WHEN (and whether) to register stays consumer-owned — legacy-interop windows\n * are real: a host whose global `next/image` config is still owned by a\n * previous stack (e.g. a Sanity-era custom loader) deliberately skips\n * registration until the conflict clears, and its components keep the honest\n * plain-`<img>` fallback.\n *\n * This module is deliberately its OWN subpath entry importing nothing but React\n * types — safe in Vite, in RSC, and in `next.config.*`. The main\n * `@elytracms/next` entry never imports it at runtime (that would bundle a\n * second singleton instance into the server entry, disconnecting\n * `setHostImage` from `getHostImage` — pinned by `package-build.test.ts`).\n */\n\n/**\n * The resolved-asset slice a host image renderer needs — DERIVED from `ResolvedAsset`\n * (EC-587; it used to mirror it by hand). `lqip` (EC-420 → next/image blurDataURL) is\n * optional so a caller handing a partial asset stays source-compatible; when present\n * the delivered image blurs up while the optimized bytes load.\n */\nexport type HostImageAsset = Pick<ResolvedAsset, 'url' | 'width' | 'height' | 'alt' | 'focalPoint'> &\n Partial<Pick<ResolvedAsset, 'lqip'>>\n\nexport interface HostImageProps {\n asset: HostImageAsset\n /**\n * The image's alt text. Omitted → the ASSET's alt (EC-587: an asset's alt has one\n * home and one reader). Pass it only to override deliberately — e.g. `''` for a\n * decorative image.\n */\n alt?: string\n className?: string\n loading?: 'eager' | 'lazy'\n /** Above-the-fold opt-out of lazy-loading (the hero image). */\n priority?: boolean\n /** Responsive `sizes` hint so the optimizer serves a column-sized variant. */\n sizes?: string\n}\n\nexport type HostImageRenderer = (props: HostImageProps) => ReactNode\n\nlet hostImage: HostImageRenderer | null = null\n\n/** Host-only: register the optimized image renderer (called once at host boot). */\nexport function setHostImage(renderer: HostImageRenderer | null): void {\n hostImage = renderer\n}\n\n/** The registered host renderer, or `null` in the studio canvas (plain-`<img>` fallback). */\nexport function getHostImage(): HostImageRenderer | null {\n return hostImage\n}\n\n/**\n * The `next.config.*` `images.remotePatterns` preset for Elytra asset delivery\n * (EC-368 image defaults): Convex file-storage serve URLs, where uploaded\n * assets live in connected mode. Without it `next/image` refuses the remote\n * origin and delivery images 400 — spread it into your config:\n *\n * ```js\n * // next.config.mjs\n * import { convexAssetRemotePatterns } from '@elytracms/next/host-image'\n *\n * const nextConfig = {\n * images: { remotePatterns: [...convexAssetRemotePatterns] },\n * }\n * ```\n */\nexport const convexAssetRemotePatterns: readonly { protocol: 'https'; hostname: string }[] = [\n { protocol: 'https', hostname: '*.convex.cloud' },\n]\n"]}
|