@localess/react 3.0.10-dev.20260520210718 → 3.1.0-dev.20260529181548

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.
@@ -1,8 +1,2 @@
1
- /**
2
- * Core components barrel.
3
- *
4
- * LocalessComponent — maps content._schema to a registered React component.
5
- * Server-safe (no 'use client'). Used in SPA and RSC flows.
6
- */
7
1
  export * from './localess-component';
8
2
  export * from './localess-document';
@@ -1,4 +1,4 @@
1
- import { ContentData, Links, References } from '../models';
1
+ import { Assets, ContentData, Links, References } from '../models';
2
2
  /**
3
3
  * Props for {@link LocalessComponent}.
4
4
  *
@@ -20,6 +20,11 @@ export type LocalessComponentProps<T extends ContentData = ContentData> = {
20
20
  * Pass through to child components that consume referenced content.
21
21
  */
22
22
  references?: References;
23
+ /**
24
+ * Optional map of resolved content assets keyed by asset ID.
25
+ * Pass through to child components that consume asset content.
26
+ */
27
+ assets?: Assets;
23
28
  };
24
29
  /**
25
30
  * Dynamic schema-to-component renderer for use in SPA and client-side contexts.
@@ -1 +1 @@
1
- const e=require(`../../console.js`),t=require(`../state.js`);let n=require(`react`),r=require(`react/jsx-runtime`),i=require(`@localess/client`);var a=(0,n.forwardRef)(({data:n,links:a,references:o,...s},c)=>{if(!n)return console.error(`LocalessComponent property %cdata%c is not provided.`,e.FONT_BOLD,e.FONT_NORMAL),(0,r.jsxs)(`div`,{children:[`LocalessComponent property `,(0,r.jsx)(`b`,{children:`data`}),` is not provided.`]});let l=t.getComponent(n._schema);if(l)return(0,r.jsx)(l,{ref:c,data:n,links:a,references:o,...(0,i.localessEditable)(n),...s});let u=t.getFallbackComponent();return u?(0,r.jsx)(u,{ref:c,data:n,links:a,references:o,...s}):(0,r.jsxs)(`p`,{children:[(0,r.jsx)(`b`,{children:`LocalessComponent`}),` could not found component with key `,(0,r.jsx)(`b`,{children:n._schema}),`. `,(0,r.jsx)(`br`,{}),`Please check if your configuration is correct.`]})});exports.LocalessComponent=a;
1
+ const e=require(`../../console.js`),t=require(`../state.js`);let n=require(`react`),r=require(`react/jsx-runtime`),i=require(`@localess/client`);var a=(0,n.forwardRef)(({data:n,links:a,references:o,assets:s,...c},l)=>{if(!n)return console.error(`LocalessComponent property %cdata%c is not provided.`,e.FONT_BOLD,e.FONT_NORMAL),(0,r.jsxs)(`div`,{children:[`LocalessComponent property `,(0,r.jsx)(`b`,{children:`data`}),` is not provided.`]});let u=t.getComponent(n._schema);if(u)return(0,r.jsx)(u,{ref:l,data:n,assets:s,links:a,references:o,...(0,i.localessEditable)(n),...c});let d=t.getFallbackComponent();return d?(0,r.jsx)(d,{ref:l,data:n,assets:s,links:a,references:o,...c}):(0,r.jsxs)(`p`,{children:[(0,r.jsx)(`b`,{children:`LocalessComponent`}),` could not found component with key `,(0,r.jsx)(`b`,{children:n._schema}),`. `,(0,r.jsx)(`br`,{}),`Please check if your configuration is correct.`]})});exports.LocalessComponent=a;
@@ -4,28 +4,30 @@ import { localessEditable as i } from "../utils/index.mjs";
4
4
  import { forwardRef as a } from "react";
5
5
  import { jsx as o, jsxs as s } from "react/jsx-runtime";
6
6
  //#region src/core/components/localess-component.tsx
7
- var c = a(({ data: a, links: c, references: l, ...u }, d) => {
7
+ var c = a(({ data: a, links: c, references: l, assets: u, ...d }, f) => {
8
8
  if (!a) return console.error("LocalessComponent property %cdata%c is not provided.", e, t), /* @__PURE__ */ s("div", { children: [
9
9
  "LocalessComponent property ",
10
10
  /* @__PURE__ */ o("b", { children: "data" }),
11
11
  " is not provided."
12
12
  ] });
13
- let f = n(a._schema);
14
- if (f) return /* @__PURE__ */ o(f, {
15
- ref: d,
13
+ let p = n(a._schema);
14
+ if (p) return /* @__PURE__ */ o(p, {
15
+ ref: f,
16
16
  data: a,
17
+ assets: u,
17
18
  links: c,
18
19
  references: l,
19
20
  ...i(a),
20
- ...u
21
+ ...d
21
22
  });
22
- let p = r();
23
- return p ? /* @__PURE__ */ o(p, {
24
- ref: d,
23
+ let m = r();
24
+ return m ? /* @__PURE__ */ o(m, {
25
+ ref: f,
25
26
  data: a,
27
+ assets: u,
26
28
  links: c,
27
29
  references: l,
28
- ...u
30
+ ...d
29
31
  }) : /* @__PURE__ */ s("p", { children: [
30
32
  /* @__PURE__ */ o("b", { children: "LocalessComponent" }),
31
33
  " could not found component with key ",
@@ -1 +1 @@
1
- const e=require(`../../console.js`),t=require(`../state.js`),n=require(`./localess-component.js`);let r=require(`react`),i=require(`react/jsx-runtime`),a=require(`@localess/client`);var o=(0,r.forwardRef)(({document:o},s)=>{let[c,l]=(0,r.useState)(o.data);return(0,r.useEffect)(()=>{t.isSyncEnabled()&&(0,a.isBrowser)()&&(0,a.isIframe)()&&window.localess?.on([`input`,`change`],e=>{(e.type===`change`||e.type===`input`)&&l(e.data)})},[]),c?(0,i.jsx)(n.LocalessComponent,{ref:s,data:c,links:o.links,references:o.references}):(console.error(`LocalessDocument property %cdocument.data%c is not provided.`,e.FONT_BOLD,e.FONT_NORMAL),(0,i.jsxs)(`div`,{children:[`LocalessDocument property `,(0,i.jsx)(`b`,{children:`document.data`}),` is not provided.`]}))});exports.LocalessDocument=o;
1
+ const e=require(`../../console.js`),t=require(`../state.js`),n=require(`./localess-component.js`);let r=require(`react`),i=require(`react/jsx-runtime`),a=require(`@localess/client`);var o=(0,r.forwardRef)(({document:o},s)=>{let[c,l]=(0,r.useState)(o.data);return(0,r.useEffect)(()=>{t.isSyncEnabled()&&(0,a.isBrowser)()&&(0,a.isIframe)()&&window.localess?.on([`input`,`change`],e=>{(e.type===`change`||e.type===`input`)&&l(e.data)})},[]),c?(0,i.jsx)(n.LocalessComponent,{ref:s,data:c,assets:o.assets,links:o.links,references:o.references}):(console.error(`LocalessDocument property %cdocument.data%c is not provided.`,e.FONT_BOLD,e.FONT_NORMAL),(0,i.jsxs)(`div`,{children:[`LocalessDocument property `,(0,i.jsx)(`b`,{children:`document.data`}),` is not provided.`]}))});exports.LocalessDocument=o;
@@ -14,6 +14,7 @@ var d = o(({ document: o }, d) => {
14
14
  }, []), f ? /* @__PURE__ */ l(a, {
15
15
  ref: d,
16
16
  data: f,
17
+ assets: o.assets,
17
18
  links: o.links,
18
19
  references: o.references
19
20
  }) : (console.error("LocalessDocument property %cdocument.data%c is not provided.", e, t), /* @__PURE__ */ u("div", { children: [
@@ -1,9 +1 @@
1
- /**
2
- * Core hooks barrel.
3
- *
4
- * useLocaless<T>(slug, options?) — fetch content by slug inside a Client Component ('use client').
5
- * Accepts a string or string[] slug (array joined with '/').
6
- * Subscribes to Visual Editor sync events when isSyncEnabled() is true.
7
- * Returns Content<T> | undefined.
8
- */
9
1
  export * from './use-localess';
@@ -1 +1 @@
1
- export type { Content, ContentAsset, ContentData, ContentDataField, ContentDataSchema, ContentLink, ContentMetadata, ContentReference, ContentRichText, Links, References, } from '@localess/client';
1
+ export type { AssetMetadata, Assets, Content, ContentAsset, ContentData, ContentDataField, ContentDataSchema, ContentLink, ContentMetadata, ContentReference, ContentRichText, Links, References, } from '@localess/client';
@@ -1,32 +1,3 @@
1
- /**
2
- * Core models barrel.
3
- *
4
- * Client & init types:
5
- * LocalessClient — the client instance type returned by localessInit / getLocalessClient.
6
- * LocalessOptions — full init options: LocalessClientOptions + components, fallbackComponent, enableSync.
7
- *
8
- * Content types:
9
- * Content<T> — wrapper returned by getContentBySlug / getContentById: { data, links, references }.
10
- * ContentData — base content shape with _id and _schema fields.
11
- * ContentMetadata — content metadata (slug, name, locale, publishedAt, updatedAt, …).
12
- * ContentDataSchema — minimal shape used by localessEditable: { _id, _schema }.
13
- * ContentDataField — base shape for nested content fields.
14
- * ContentAsset — asset reference with uri field; pass to resolveAsset() for a full URL.
15
- * ContentRichText — TipTap document structure; pass to renderRichTextToReact() to render.
16
- * ContentLink — link reference with type ('content' | 'url') and uri; pass to findLink() to resolve.
17
- * ContentReference — resolved content reference.
18
- * Links — Record<string, { fullSlug }> map of content links, keyed by link ID.
19
- * References — Record<string, ContentData> map of resolved references, keyed by reference ID.
20
- *
21
- * Sync / Visual Editor types:
22
- * LocalessSync — type of window.localess (exposes .on() and .onChange()).
23
- * EventToApp — event payload sent from the Visual Editor to the app.
24
- * EventCallback — callback signature for window.localess.on(events, callback).
25
- * EventToAppType — union of Visual Editor event type strings ('input' | 'change' | 'pong' | …).
26
- *
27
- * Translation types:
28
- * Translations — locale-keyed flat translation record.
29
- */
30
1
  export * from './client';
31
2
  export * from './content';
32
3
  export * from './sync';
@@ -117,6 +117,7 @@ export declare function getOrigin(): string;
117
117
  * `{origin}/api/v1/spaces/{spaceId}/assets/{asset.uri}`
118
118
  *
119
119
  * @param asset - The asset reference object containing a `uri` field.
120
+ * @param params
120
121
  * @returns The fully qualified asset URL string.
121
122
  *
122
123
  * @example
@@ -1,19 +1,2 @@
1
- /**
2
- * Core utils barrel.
3
- *
4
- * From @localess/client:
5
- * localessEditable(content) — returns { 'data-ll-id', 'data-ll-schema' } for Visual Editor targeting.
6
- * Spread on a component's root element.
7
- * localessEditableField<T>(fieldName) — returns { 'data-ll-field' } for field-level Visual Editor targeting.
8
- * Generic type T restricts fieldName to valid content keys.
9
- * isBrowser — true when running in a browser (window is defined).
10
- * isServer — true when running in a Node.js / server environment.
11
- * isIframe — true when the page is loaded inside an iframe (i.e. inside the Visual Editor).
12
- *
13
- * Local:
14
- * findLink(links, link) — resolve a ContentLink to a URL string.
15
- * Returns '/' + fullSlug for type:'content', raw uri for type:'url',
16
- * '/not-found' when the link cannot be resolved.
17
- */
18
1
  export * from './link.util';
19
2
  export { AssetTransformParams, isBrowser, isIframe, isServer, localessEditable, localessEditableField } from '@localess/client';
package/dist/index.d.ts CHANGED
@@ -18,9 +18,9 @@
18
18
  * import { localessInit, LocalessComponent, useLocaless, localessEditable } from '@localess/react';
19
19
  * ```
20
20
  */
21
- export * from './core/state';
22
21
  export * from './core/components';
23
22
  export * from './core/hooks';
24
- export * from './core/utils';
25
- export * from './core/richtext';
26
23
  export type * from './core/models';
24
+ export * from './core/richtext';
25
+ export * from './core/state';
26
+ export * from './core/utils';
@@ -1 +1 @@
1
- const e=require(`../console.js`),t=require(`../core/state.js`),n=require(`../core/components/localess-component.js`),r=require(`./localess-sync.js`);let i=require(`react`),a=require(`react/jsx-runtime`);var o=(0,i.forwardRef)(({document:i},o)=>i.data?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.LocalessComponent,{ref:o,data:i.data,links:i.links,references:i.references}),(0,a.jsx)(r.LocalessSync,{document:i,origin:t.getOrigin(),enableSync:t.isSyncEnabled()})]}):(console.error(`LocalessDocument property %cdocument.data%c is not provided.`,e.FONT_BOLD,e.FONT_NORMAL),(0,a.jsxs)(`div`,{children:[`LocalessDocument property `,(0,a.jsx)(`b`,{children:`document.data`}),` is not provided.`]})));exports.LocalessDocument=o;
1
+ const e=require(`../console.js`),t=require(`../core/state.js`),n=require(`../core/components/localess-component.js`),r=require(`./localess-sync.js`);let i=require(`react`),a=require(`react/jsx-runtime`);var o=(0,i.forwardRef)(({document:i},o)=>i.data?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.LocalessComponent,{ref:o,data:i.data,assets:i.assets,links:i.links,references:i.references}),(0,a.jsx)(r.LocalessSync,{document:i,origin:t.getOrigin(),enableSync:t.isSyncEnabled()})]}):(console.error(`LocalessDocument property %cdocument.data%c is not provided.`,e.FONT_BOLD,e.FONT_NORMAL),(0,a.jsxs)(`div`,{children:[`LocalessDocument property `,(0,a.jsx)(`b`,{children:`document.data`}),` is not provided.`]})));exports.LocalessDocument=o;
@@ -8,6 +8,7 @@ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
8
8
  var u = o(({ document: o }, u) => o.data ? /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(i, {
9
9
  ref: u,
10
10
  data: o.data,
11
+ assets: o.assets,
11
12
  links: o.links,
12
13
  references: o.references
13
14
  }), /* @__PURE__ */ c(a, {
@@ -1 +1 @@
1
- "use client";let e=require(`@localess/client`),t=require(`react`);var n=n=>(console.info(`LocalessSync:init`),(0,t.useEffect)(()=>{async function t(){n.enableSync&&(0,e.isBrowser)()&&(0,e.isIframe)()&&(await(0,e.loadLocalessSync)(n.origin),window.localess?.on([`input`,`change`],e=>{console.info(`LocalessSync:change:`,e),(e.type===`change`||e.type===`input`)&&(n.document.data=e.data)}))}t()},[]),null);exports.LocalessSync=n;
1
+ "use client";let e=require(`react`),t=require(`@localess/client`);var n=n=>(console.info(`LocalessSync:init`),(0,e.useEffect)(()=>{async function e(){n.enableSync&&(0,t.isBrowser)()&&(0,t.isIframe)()&&(await(0,t.loadLocalessSync)(n.origin),window.localess?.on([`input`,`change`],e=>{console.info(`LocalessSync:change:`,e),(e.type===`change`||e.type===`input`)&&(n.document.data=e.data)}))}e()},[]),null);exports.LocalessSync=n;
@@ -1,15 +1,15 @@
1
1
  "use client";
2
2
  import { isBrowser as e, isIframe as t } from "../core/utils/index.mjs";
3
- import { loadLocalessSync as n } from "@localess/client";
4
- import { useEffect as r } from "react";
3
+ import { useEffect as n } from "react";
4
+ import { loadLocalessSync as r } from "@localess/client";
5
5
  //#region src/rsc/localess-sync.tsx
6
- var i = (i) => (console.info("LocalessSync:init"), r(() => {
7
- async function r() {
8
- i.enableSync && e() && t() && (await n(i.origin), window.localess?.on(["input", "change"], (e) => {
6
+ var i = (i) => (console.info("LocalessSync:init"), n(() => {
7
+ async function n() {
8
+ i.enableSync && e() && t() && (await r(i.origin), window.localess?.on(["input", "change"], (e) => {
9
9
  console.info("LocalessSync:change:", e), (e.type === "change" || e.type === "input") && (i.document.data = e.data);
10
10
  }));
11
11
  }
12
- r();
12
+ n();
13
13
  }, []), null);
14
14
  //#endregion
15
15
  export { i as LocalessSync };
@@ -1,4 +1,4 @@
1
- import { ContentData, Links, References } from '../core/models';
1
+ import { Assets, ContentData, Links, References } from '../core/models';
2
2
  /**
3
3
  * Props for {@link LocalessServerComponent}.
4
4
  *
@@ -20,6 +20,11 @@ export type LocalessServerComponentProps<T extends ContentData = ContentData> =
20
20
  * Pass through to child components that consume referenced content.
21
21
  */
22
22
  references?: References;
23
+ /**
24
+ * Optional map of resolved content assets keyed by asset ID.
25
+ * Pass through to child components that consume asset content.
26
+ */
27
+ assets?: Assets;
23
28
  };
24
29
  /**
25
30
  * Server-safe dynamic schema-to-component renderer for SSR and static-export environments.
@@ -1 +1 @@
1
- const e=require(`../console.js`),t=require(`../core/state.js`);let n=require(`react`),r=require(`react/jsx-runtime`);var i=(0,n.forwardRef)(({data:n,links:i,references:a,...o},s)=>{if(!n)return console.error(`LocalessServerComponent property %cdata%c is not provided.`,e.FONT_BOLD,e.FONT_NORMAL),(0,r.jsxs)(`div`,{children:[`LocalessServerComponent property `,(0,r.jsx)(`b`,{children:`data`}),` is not provided.`]});let c=t.getComponent(n._schema);if(c)return(0,r.jsx)(c,{ref:s,data:n,links:i,references:a,...o});let l=t.getFallbackComponent();return l?(0,r.jsx)(l,{ref:s,data:n,links:i,references:a,...o}):(0,r.jsxs)(`p`,{children:[(0,r.jsx)(`b`,{children:`LocalessServerComponent`}),` could not found component with key `,(0,r.jsx)(`b`,{children:n._schema}),`. `,(0,r.jsx)(`br`,{}),`Please check if your configuration is correct.`]})});exports.LocalessServerComponent=i;
1
+ const e=require(`../console.js`),t=require(`../core/state.js`);let n=require(`react`),r=require(`react/jsx-runtime`);var i=(0,n.forwardRef)(({data:n,assets:i,links:a,references:o,...s},c)=>{if(!n)return console.error(`LocalessServerComponent property %cdata%c is not provided.`,e.FONT_BOLD,e.FONT_NORMAL),(0,r.jsxs)(`div`,{children:[`LocalessServerComponent property `,(0,r.jsx)(`b`,{children:`data`}),` is not provided.`]});let l=t.getComponent(n._schema);if(l)return(0,r.jsx)(l,{ref:c,data:n,assets:i,links:a,references:o,...s});let u=t.getFallbackComponent();return u?(0,r.jsx)(u,{ref:c,data:n,assets:i,links:a,references:o,...s}):(0,r.jsxs)(`p`,{children:[(0,r.jsx)(`b`,{children:`LocalessServerComponent`}),` could not found component with key `,(0,r.jsx)(`b`,{children:n._schema}),`. `,(0,r.jsx)(`br`,{}),`Please check if your configuration is correct.`]})});exports.LocalessServerComponent=i;
@@ -3,27 +3,29 @@ import { getComponent as n, getFallbackComponent as r } from "../core/state.mjs"
3
3
  import { forwardRef as i } from "react";
4
4
  import { jsx as a, jsxs as o } from "react/jsx-runtime";
5
5
  //#region src/ssr/localess-component.tsx
6
- var s = i(({ data: i, links: s, references: c, ...l }, u) => {
6
+ var s = i(({ data: i, assets: s, links: c, references: l, ...u }, d) => {
7
7
  if (!i) return console.error("LocalessServerComponent property %cdata%c is not provided.", e, t), /* @__PURE__ */ o("div", { children: [
8
8
  "LocalessServerComponent property ",
9
9
  /* @__PURE__ */ a("b", { children: "data" }),
10
10
  " is not provided."
11
11
  ] });
12
- let d = n(i._schema);
13
- if (d) return /* @__PURE__ */ a(d, {
14
- ref: u,
12
+ let f = n(i._schema);
13
+ if (f) return /* @__PURE__ */ a(f, {
14
+ ref: d,
15
15
  data: i,
16
- links: s,
17
- references: c,
18
- ...l
16
+ assets: s,
17
+ links: c,
18
+ references: l,
19
+ ...u
19
20
  });
20
- let f = r();
21
- return f ? /* @__PURE__ */ a(f, {
22
- ref: u,
21
+ let p = r();
22
+ return p ? /* @__PURE__ */ a(p, {
23
+ ref: d,
23
24
  data: i,
24
- links: s,
25
- references: c,
26
- ...l
25
+ assets: s,
26
+ links: c,
27
+ references: l,
28
+ ...u
27
29
  }) : /* @__PURE__ */ o("p", { children: [
28
30
  /* @__PURE__ */ a("b", { children: "LocalessServerComponent" }),
29
31
  " could not found component with key ",
@@ -1 +1 @@
1
- const e=require(`../console.js`),t=require(`./localess-component.js`);let n=require(`react`),r=require(`react/jsx-runtime`);var i=(0,n.forwardRef)(({document:n},i)=>n.data?(0,r.jsx)(t.LocalessServerComponent,{ref:i,data:n.data,links:n.links,references:n.references}):(console.error(`LocalessServerDocument property %cdocument.data%c is not provided.`,e.FONT_BOLD,e.FONT_NORMAL),(0,r.jsxs)(`div`,{children:[`LocalessServerDocument property `,(0,r.jsx)(`b`,{children:`document.data`}),` is not provided.`]})));exports.LocalessServerDocument=i;
1
+ const e=require(`../console.js`),t=require(`./localess-component.js`);let n=require(`react`),r=require(`react/jsx-runtime`);var i=(0,n.forwardRef)(({document:n},i)=>n.data?(0,r.jsx)(t.LocalessServerComponent,{ref:i,data:n.data,assets:n.assets,links:n.links,references:n.references}):(console.error(`LocalessServerDocument property %cdocument.data%c is not provided.`,e.FONT_BOLD,e.FONT_NORMAL),(0,r.jsxs)(`div`,{children:[`LocalessServerDocument property `,(0,r.jsx)(`b`,{children:`document.data`}),` is not provided.`]})));exports.LocalessServerDocument=i;
@@ -6,6 +6,7 @@ import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
6
  var o = r(({ document: r }, o) => r.data ? /* @__PURE__ */ i(n, {
7
7
  ref: o,
8
8
  data: r.data,
9
+ assets: r.assets,
9
10
  links: r.links,
10
11
  references: r.references
11
12
  }) : (console.error("LocalessServerDocument property %cdocument.data%c is not provided.", e, t), /* @__PURE__ */ a("div", { children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localess/react",
3
- "version": "3.0.10-dev.20260520210718",
3
+ "version": "3.1.0-dev.20260529181548",
4
4
  "description": "ReactJS JavaScript/TypeScript SDK for Localess's API.",
5
5
  "keywords": [
6
6
  "localess",
@@ -61,7 +61,7 @@
61
61
  "react-dom": "^17 || ^18 || ^19"
62
62
  },
63
63
  "dependencies": {
64
- "@localess/client": "3.0.10-dev.20260520210718",
64
+ "@localess/client": "3.1.0-dev.20260529181548",
65
65
  "@tiptap/extension-bold": "^3.22.5",
66
66
  "@tiptap/extension-bullet-list": "^3.22.5",
67
67
  "@tiptap/extension-code": "^3.22.5",