@localess/react 3.0.1-dev.20260410071322 → 3.0.1-dev.20260412201733

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 (64) hide show
  1. package/dist/console.d.ts +2 -0
  2. package/dist/console.js +1 -0
  3. package/dist/console.mjs +4 -0
  4. package/dist/core/components/index.d.ts +8 -0
  5. package/dist/core/components/localess-component.d.ts +54 -0
  6. package/dist/core/components/localess-component.js +1 -0
  7. package/dist/core/components/localess-component.mjs +39 -0
  8. package/dist/{rsc.d.ts → core/components/localess-document.d.ts} +6 -25
  9. package/dist/core/components/localess-document.js +1 -0
  10. package/dist/core/components/localess-document.mjs +26 -0
  11. package/dist/core/hooks/index.d.ts +9 -0
  12. package/dist/core/hooks/use-localess.d.ts +45 -0
  13. package/dist/core/hooks/use-localess.js +1 -0
  14. package/dist/core/hooks/use-localess.mjs +25 -0
  15. package/dist/core/models/client.d.ts +43 -0
  16. package/dist/core/models/content.d.ts +1 -0
  17. package/dist/core/models/index.d.ts +33 -0
  18. package/dist/core/models/sync.d.ts +1 -0
  19. package/dist/core/models/translation.d.ts +1 -0
  20. package/dist/core/richtext.d.ts +26 -0
  21. package/dist/core/richtext.js +1 -0
  22. package/dist/core/richtext.mjs +48 -0
  23. package/dist/core/state.d.ts +127 -0
  24. package/dist/core/state.js +1 -0
  25. package/dist/core/state.mjs +43 -0
  26. package/dist/core/utils/index.d.ts +19 -0
  27. package/dist/core/utils/index.mjs +3 -0
  28. package/dist/core/utils/link.util.d.ts +24 -0
  29. package/dist/core/utils/link.util.js +1 -0
  30. package/dist/core/utils/link.util.mjs +15 -0
  31. package/dist/index.d.ts +19 -97
  32. package/dist/index.js +1 -257
  33. package/dist/index.mjs +8 -44
  34. package/dist/rsc/index.d.ts +30 -0
  35. package/dist/rsc/index.js +1 -0
  36. package/dist/rsc/index.mjs +9 -0
  37. package/dist/{rsc.d.mts → rsc/localess-document.d.ts} +6 -25
  38. package/dist/rsc/localess-document.js +1 -0
  39. package/dist/rsc/localess-document.mjs +23 -0
  40. package/dist/rsc/localess-sync.d.ts +7 -0
  41. package/dist/rsc/localess-sync.js +1 -0
  42. package/dist/rsc/localess-sync.mjs +12 -0
  43. package/dist/ssr/index.d.ts +33 -0
  44. package/dist/ssr/index.js +1 -0
  45. package/dist/ssr/index.mjs +7 -0
  46. package/dist/ssr/localess-component.d.ts +48 -0
  47. package/dist/ssr/localess-component.js +1 -0
  48. package/dist/ssr/localess-component.mjs +37 -0
  49. package/dist/ssr/localess-document.d.ts +42 -0
  50. package/dist/ssr/localess-document.js +1 -0
  51. package/dist/ssr/localess-document.mjs +17 -0
  52. package/package.json +32 -24
  53. package/dist/chunk-AJP75NRT.mjs +0 -56
  54. package/dist/chunk-ETSLIILF.mjs +0 -149
  55. package/dist/chunk-V6JSXN66.mjs +0 -76
  56. package/dist/index.d.mts +0 -104
  57. package/dist/richtext-l2BRZFEP.d.mts +0 -218
  58. package/dist/richtext-l2BRZFEP.d.ts +0 -218
  59. package/dist/rsc.js +0 -322
  60. package/dist/rsc.mjs +0 -73
  61. package/dist/ssr.d.mts +0 -96
  62. package/dist/ssr.d.ts +0 -96
  63. package/dist/ssr.js +0 -223
  64. package/dist/ssr.mjs +0 -38
package/dist/rsc.js DELETED
@@ -1,322 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/rsc/index.ts
21
- var rsc_exports = {};
22
- __export(rsc_exports, {
23
- LocalessComponent: () => LocalessComponent,
24
- LocalessDocument: () => LocalessDocument,
25
- LocalessServerComponent: () => LocalessServerComponent,
26
- LocalessServerDocument: () => LocalessServerDocument,
27
- findLink: () => findLink,
28
- getComponent: () => getComponent,
29
- getFallbackComponent: () => getFallbackComponent,
30
- getLocalessClient: () => getLocalessClient,
31
- isBrowser: () => import_client2.isBrowser,
32
- isIframe: () => import_client2.isIframe,
33
- isServer: () => import_client2.isServer,
34
- isSyncEnabled: () => isSyncEnabled,
35
- localessEditable: () => import_client2.localessEditable,
36
- localessEditableField: () => import_client2.localessEditableField,
37
- localessInit: () => localessInit,
38
- registerComponent: () => registerComponent,
39
- renderRichTextToReact: () => renderRichTextToReact,
40
- resolveAsset: () => resolveAsset,
41
- unregisterComponent: () => unregisterComponent,
42
- useLocaless: () => useLocaless
43
- });
44
- module.exports = __toCommonJS(rsc_exports);
45
-
46
- // src/core/state.ts
47
- var import_client = require("@localess/client");
48
-
49
- // src/console.ts
50
- var FONT_BOLD = "font-weight: bold";
51
- var FONT_NORMAL = "font-weight: normal";
52
-
53
- // src/core/state.ts
54
- var _client = void 0;
55
- var _components = {};
56
- var _fallbackComponent = void 0;
57
- var _enableSync = false;
58
- var _assetPathPrefix = "";
59
- function localessInit(options) {
60
- console.log("localessInit", options);
61
- const { components, fallbackComponent, enableSync, ...restOptions } = options;
62
- _client = (0, import_client.localessClient)(restOptions);
63
- _assetPathPrefix = `${options.origin}/api/v1/spaces/${options.spaceId}/assets/`;
64
- _components = components || {};
65
- _fallbackComponent = fallbackComponent;
66
- if (enableSync) {
67
- _enableSync = true;
68
- (0, import_client.loadLocalessSync)(restOptions.origin);
69
- }
70
- return _client;
71
- }
72
- function getLocalessClient() {
73
- if (!_client) {
74
- console.error("[Localess] No client found. Please check if the Localess is initialized.");
75
- throw new Error("[Localess] No client found.");
76
- }
77
- return _client;
78
- }
79
- function registerComponent(key, component) {
80
- _components[key] = component;
81
- }
82
- function unregisterComponent(key) {
83
- delete _components[key];
84
- }
85
- function getComponent(key) {
86
- if (Object.hasOwn(_components, key)) {
87
- return _components[key];
88
- }
89
- console.error(`[Localess] component %c${key}%c can't be found.`, FONT_BOLD, FONT_NORMAL);
90
- return void 0;
91
- }
92
- function getFallbackComponent() {
93
- return _fallbackComponent;
94
- }
95
- function isSyncEnabled() {
96
- return _enableSync;
97
- }
98
- function resolveAsset(asset) {
99
- return `${_assetPathPrefix}${asset.uri}`;
100
- }
101
-
102
- // src/ssr/localess-component.tsx
103
- var import_react = require("react");
104
- var import_jsx_runtime = require("react/jsx-runtime");
105
- var LocalessServerComponent = (0, import_react.forwardRef)(({ data, links, references, ...restProps }, ref) => {
106
- if (!data) {
107
- console.error("LocalessServerComponent property %cdata%c is not provided.", FONT_BOLD, FONT_NORMAL);
108
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
109
- "LocalessServerComponent property ",
110
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: "data" }),
111
- " is not provided."
112
- ] });
113
- }
114
- const Comp = getComponent(data._schema);
115
- if (Comp) {
116
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Comp, { ref, data, links, references, ...restProps });
117
- }
118
- const FallbackComponent = getFallbackComponent();
119
- if (FallbackComponent) {
120
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FallbackComponent, { ref, data, links, references, ...restProps });
121
- }
122
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
123
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: "LocalessServerComponent" }),
124
- " could not found component with key ",
125
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: data._schema }),
126
- ". ",
127
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
128
- "Please check if your configuration is correct."
129
- ] });
130
- });
131
-
132
- // src/ssr/localess-document.tsx
133
- var import_react2 = require("react");
134
- var import_jsx_runtime2 = require("react/jsx-runtime");
135
- var LocalessServerDocument = (0, import_react2.forwardRef)(({ document }, ref) => {
136
- if (!document || !document.data) {
137
- console.error("LocalessServerDocument property %cdocument.data%c is not provided.", FONT_BOLD, FONT_NORMAL);
138
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
139
- "LocalessServerDocument property ",
140
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("b", { children: "document.data" }),
141
- " is not provided."
142
- ] });
143
- }
144
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LocalessServerComponent, { ref, data: document.data, links: document.links, references: document.references });
145
- });
146
-
147
- // src/core/richtext.ts
148
- var import_react3 = require("@tiptap/static-renderer/pm/react");
149
- var import_extension_document = require("@tiptap/extension-document");
150
- var import_extension_text = require("@tiptap/extension-text");
151
- var import_extension_paragraph = require("@tiptap/extension-paragraph");
152
- var import_extension_heading = require("@tiptap/extension-heading");
153
- var import_extension_bold = require("@tiptap/extension-bold");
154
- var import_extension_italic = require("@tiptap/extension-italic");
155
- var import_extension_strike = require("@tiptap/extension-strike");
156
- var import_extension_underline = require("@tiptap/extension-underline");
157
- var import_extension_history = require("@tiptap/extension-history");
158
- var import_extension_list_item = require("@tiptap/extension-list-item");
159
- var import_extension_ordered_list = require("@tiptap/extension-ordered-list");
160
- var import_extension_bullet_list = require("@tiptap/extension-bullet-list");
161
- var import_extension_code = require("@tiptap/extension-code");
162
- var import_extension_code_block_lowlight = require("@tiptap/extension-code-block-lowlight");
163
- var import_extension_link = require("@tiptap/extension-link");
164
- function renderRichTextToReact(content) {
165
- return (0, import_react3.renderToReactElement)({
166
- content,
167
- extensions: [
168
- import_extension_document.Document,
169
- import_extension_text.Text,
170
- import_extension_paragraph.Paragraph,
171
- import_extension_heading.Heading.configure({
172
- levels: [1, 2, 3, 4, 5, 6]
173
- }),
174
- import_extension_bold.Bold,
175
- import_extension_italic.Italic,
176
- import_extension_strike.Strike,
177
- import_extension_underline.Underline,
178
- import_extension_history.History,
179
- import_extension_list_item.ListItem,
180
- import_extension_ordered_list.OrderedList,
181
- import_extension_bullet_list.BulletList,
182
- import_extension_code.Code,
183
- import_extension_code_block_lowlight.CodeBlockLowlight,
184
- import_extension_link.Link
185
- ]
186
- });
187
- }
188
-
189
- // src/core/utils/index.ts
190
- var import_client2 = require("@localess/client");
191
-
192
- // src/core/utils/link.util.ts
193
- function findLink(links, link) {
194
- switch (link.type) {
195
- case "content": {
196
- if (links) {
197
- const path = links[link.uri];
198
- if (path) {
199
- return "/" + path.fullSlug;
200
- } else {
201
- return "/not-found";
202
- }
203
- }
204
- return "/not-found";
205
- }
206
- case "url":
207
- return link.uri;
208
- default:
209
- return "no-type";
210
- }
211
- }
212
-
213
- // src/core/components/localess-component.tsx
214
- var import_react4 = require("react");
215
- var import_jsx_runtime3 = require("react/jsx-runtime");
216
- var LocalessComponent = (0, import_react4.forwardRef)(
217
- ({ data, links, references, ...restProps }, ref) => {
218
- if (!data) {
219
- console.error("LocalessComponent property %cdata%c is not provided.", FONT_BOLD, FONT_NORMAL);
220
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
221
- "LocalessComponent property ",
222
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("b", { children: "data" }),
223
- " is not provided."
224
- ] });
225
- }
226
- const Comp = getComponent(data._schema);
227
- if (Comp) {
228
- const attr = isSyncEnabled() ? (0, import_client2.localessEditable)(data) : {};
229
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Comp, { ref, data, links, references, ...attr, ...restProps });
230
- }
231
- const FallbackComponent = getFallbackComponent();
232
- if (FallbackComponent) {
233
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FallbackComponent, { ref, data, links, references, ...restProps });
234
- }
235
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { children: [
236
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("b", { children: "LocalessComponent" }),
237
- " could not found component with key ",
238
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("b", { children: data._schema }),
239
- ". ",
240
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("br", {}),
241
- "Please check if your configuration is correct."
242
- ] });
243
- }
244
- );
245
-
246
- // src/rsc/localess-document.tsx
247
- var import_react5 = require("react");
248
- var import_jsx_runtime4 = require("react/jsx-runtime");
249
- var LocalessDocument = (0, import_react5.forwardRef)(({
250
- data,
251
- links,
252
- references,
253
- ...restProps
254
- }, ref) => {
255
- const [contentData, setContentData] = (0, import_react5.useState)(data);
256
- (0, import_react5.useEffect)(() => {
257
- console.log("LocalessDocument isSyncEnabled:", isSyncEnabled());
258
- console.log("LocalessDocument isBrowser:", (0, import_client2.isBrowser)());
259
- console.log("LocalessDocument isBrowser:", (0, import_client2.isBrowser)());
260
- if (isSyncEnabled() && (0, import_client2.isBrowser)() && (0, import_client2.isIframe)()) {
261
- window.localess?.on(["input", "change"], (event) => {
262
- console.log("Localess:event", event);
263
- if (event.type === "change" || event.type === "input") {
264
- setContentData(event.data);
265
- }
266
- });
267
- }
268
- }, []);
269
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LocalessComponent, { ref, data: contentData, links, references, ...restProps });
270
- });
271
-
272
- // src/core/hooks/use-localess.ts
273
- var import_react6 = require("react");
274
- var import_client3 = require("@localess/client");
275
- var useLocaless = (slug, options = {}) => {
276
- const [document, setDocument] = (0, import_react6.useState)();
277
- const client = getLocalessClient();
278
- let normalizedSlug;
279
- if (Array.isArray(slug)) {
280
- normalizedSlug = slug.join("/");
281
- } else {
282
- normalizedSlug = slug;
283
- }
284
- (0, import_react6.useEffect)(() => {
285
- async function loadDocument() {
286
- const document2 = await client.getContentBySlug(normalizedSlug, options);
287
- setDocument(document2);
288
- if (isSyncEnabled() && (0, import_client3.isBrowser)()) {
289
- window.localess?.on(["input", "change"], (event) => {
290
- if (event.type === "change" || event.type === "input") {
291
- setDocument({ ...document2, data: event.data });
292
- }
293
- });
294
- }
295
- }
296
- loadDocument();
297
- }, [slug, options, client]);
298
- return document;
299
- };
300
- // Annotate the CommonJS export names for ESM import in node:
301
- 0 && (module.exports = {
302
- LocalessComponent,
303
- LocalessDocument,
304
- LocalessServerComponent,
305
- LocalessServerDocument,
306
- findLink,
307
- getComponent,
308
- getFallbackComponent,
309
- getLocalessClient,
310
- isBrowser,
311
- isIframe,
312
- isServer,
313
- isSyncEnabled,
314
- localessEditable,
315
- localessEditableField,
316
- localessInit,
317
- registerComponent,
318
- renderRichTextToReact,
319
- resolveAsset,
320
- unregisterComponent,
321
- useLocaless
322
- });
package/dist/rsc.mjs DELETED
@@ -1,73 +0,0 @@
1
- import {
2
- LocalessComponent,
3
- useLocaless
4
- } from "./chunk-V6JSXN66.mjs";
5
- import {
6
- LocalessServerComponent,
7
- LocalessServerDocument
8
- } from "./chunk-AJP75NRT.mjs";
9
- import {
10
- findLink,
11
- getComponent,
12
- getFallbackComponent,
13
- getLocalessClient,
14
- isBrowser,
15
- isIframe,
16
- isServer,
17
- isSyncEnabled,
18
- localessEditable,
19
- localessEditableField,
20
- localessInit,
21
- registerComponent,
22
- renderRichTextToReact,
23
- resolveAsset,
24
- unregisterComponent
25
- } from "./chunk-ETSLIILF.mjs";
26
-
27
- // src/rsc/localess-document.tsx
28
- import { forwardRef, useEffect, useState } from "react";
29
- import { jsx } from "react/jsx-runtime";
30
- var LocalessDocument = forwardRef(({
31
- data,
32
- links,
33
- references,
34
- ...restProps
35
- }, ref) => {
36
- const [contentData, setContentData] = useState(data);
37
- useEffect(() => {
38
- console.log("LocalessDocument isSyncEnabled:", isSyncEnabled());
39
- console.log("LocalessDocument isBrowser:", isBrowser());
40
- console.log("LocalessDocument isBrowser:", isBrowser());
41
- if (isSyncEnabled() && isBrowser() && isIframe()) {
42
- window.localess?.on(["input", "change"], (event) => {
43
- console.log("Localess:event", event);
44
- if (event.type === "change" || event.type === "input") {
45
- setContentData(event.data);
46
- }
47
- });
48
- }
49
- }, []);
50
- return /* @__PURE__ */ jsx(LocalessComponent, { ref, data: contentData, links, references, ...restProps });
51
- });
52
- export {
53
- LocalessComponent,
54
- LocalessDocument,
55
- LocalessServerComponent,
56
- LocalessServerDocument,
57
- findLink,
58
- getComponent,
59
- getFallbackComponent,
60
- getLocalessClient,
61
- isBrowser,
62
- isIframe,
63
- isServer,
64
- isSyncEnabled,
65
- localessEditable,
66
- localessEditableField,
67
- localessInit,
68
- registerComponent,
69
- renderRichTextToReact,
70
- resolveAsset,
71
- unregisterComponent,
72
- useLocaless
73
- };
package/dist/ssr.d.mts DELETED
@@ -1,96 +0,0 @@
1
- export { L as LocalessOptions, f as findLink, g as getComponent, a as getFallbackComponent, b as getLocalessClient, l as localessInit, r as registerComponent, c as renderRichTextToReact, d as resolveAsset, u as unregisterComponent } from './richtext-l2BRZFEP.mjs';
2
- import * as React from 'react';
3
- import { ContentData, Links, References, Content } from '@localess/client';
4
- export { Content, ContentAsset, ContentData, ContentDataField, ContentDataSchema, ContentLink, ContentMetadata, ContentReference, ContentRichText, EventCallback, EventToApp, EventToAppType, Links, LocalessClient, LocalessSync, References, Translations, isBrowser, isIframe, isServer, localessEditable, localessEditableField } from '@localess/client';
5
-
6
- /**
7
- * Props for {@link LocalessServerComponent}.
8
- *
9
- * @template T - The content data shape. Defaults to the base {@link ContentData} type.
10
- */
11
- type LocalessServerComponentProps<T extends ContentData = ContentData> = {
12
- /**
13
- * The content data object to render. Must have a `_schema` field that matches a key
14
- * in the component registry configured via `localessInit`.
15
- */
16
- data: T;
17
- /**
18
- * Optional map of content links keyed by link ID.
19
- * Pass through to child components so they can resolve {@link ContentLink} values with `findLink`.
20
- */
21
- links?: Links;
22
- /**
23
- * Optional map of resolved content references keyed by reference ID.
24
- * Pass through to child components that consume referenced content.
25
- */
26
- references?: References;
27
- };
28
- /**
29
- * Server-safe dynamic schema-to-component renderer for SSR and static-export environments.
30
- *
31
- * Equivalent to {@link LocalessComponent} but intentionally omits Visual Editor sync
32
- * attribute injection (`localessEditable`), making it safe for:
33
- * - Next.js static exports (`output: 'export'`)
34
- * - Server-side rendering where live editing is not needed
35
- *
36
- * Looks up `data._schema` in the component registry, renders the matched component,
37
- * falls back to the `fallbackComponent` if registered, or renders an inline error.
38
- *
39
- * **No `'use client'` directive** — safe to render in React Server Components.
40
- * If you need live Visual Editor editing use {@link LocalessComponent} from
41
- * `@localess/react` or `@localess/react/rsc` instead.
42
- *
43
- * @template T - The content data shape. Defaults to {@link ContentData}.
44
- *
45
- * @example
46
- * ```tsx
47
- * import { LocalessServerComponent } from '@localess/react/ssr';
48
- *
49
- * <LocalessServerComponent data={content.data} links={content.links} references={content.references} />
50
- * ```
51
- */
52
- declare const LocalessServerComponent: React.ForwardRefExoticComponent<LocalessServerComponentProps<ContentData> & React.RefAttributes<HTMLElement>>;
53
-
54
- /**
55
- * Props for {@link LocalessServerDocument}.
56
- *
57
- * @template T - The content data shape. Defaults to the base {@link ContentData} type.
58
- */
59
- type LocalessServerDocumentProps<T extends ContentData = ContentData> = {
60
- /**
61
- * The full content response object as returned by `getContentBySlug` or `getContentById`.
62
- * Must contain a `data` field with a valid `_schema` key.
63
- */
64
- document: Content<T>;
65
- };
66
- /**
67
- * Server-safe document renderer for SSR and static-export environments.
68
- *
69
- * Accepts the full {@link Content} wrapper (as returned by `getContentBySlug` /
70
- * `getContentById`) and delegates to {@link LocalessServerComponent}, automatically
71
- * passing `data`, `links`, and `references` through.
72
- *
73
- * This is a convenience wrapper — use it when you want to render a fetched
74
- * `Content<T>` object without manually destructuring it.
75
- *
76
- * **No live editing** — does not subscribe to Visual Editor sync events.
77
- * For live Visual Editor editing use {@link LocalessDocument} from `@localess/react/rsc`.
78
- *
79
- * **No `'use client'` directive** — safe to render in React Server Components
80
- * and Next.js static export pages.
81
- *
82
- * @template T - The content data shape. Defaults to {@link ContentData}.
83
- *
84
- * @example
85
- * ```tsx
86
- * import { LocalessServerDocument } from '@localess/react/ssr';
87
- *
88
- * // Server Component or getServerSideProps
89
- * const content = await getLocalessClient().getContentBySlug<MyPage>('home', { locale: 'en' });
90
- *
91
- * return <LocalessServerDocument document={content} />;
92
- * ```
93
- */
94
- declare const LocalessServerDocument: React.ForwardRefExoticComponent<LocalessServerDocumentProps<ContentData> & React.RefAttributes<HTMLElement>>;
95
-
96
- export { LocalessServerComponent, type LocalessServerComponentProps, LocalessServerDocument, type LocalessServerDocumentProps };
package/dist/ssr.d.ts DELETED
@@ -1,96 +0,0 @@
1
- export { L as LocalessOptions, f as findLink, g as getComponent, a as getFallbackComponent, b as getLocalessClient, l as localessInit, r as registerComponent, c as renderRichTextToReact, d as resolveAsset, u as unregisterComponent } from './richtext-l2BRZFEP.js';
2
- import * as React from 'react';
3
- import { ContentData, Links, References, Content } from '@localess/client';
4
- export { Content, ContentAsset, ContentData, ContentDataField, ContentDataSchema, ContentLink, ContentMetadata, ContentReference, ContentRichText, EventCallback, EventToApp, EventToAppType, Links, LocalessClient, LocalessSync, References, Translations, isBrowser, isIframe, isServer, localessEditable, localessEditableField } from '@localess/client';
5
-
6
- /**
7
- * Props for {@link LocalessServerComponent}.
8
- *
9
- * @template T - The content data shape. Defaults to the base {@link ContentData} type.
10
- */
11
- type LocalessServerComponentProps<T extends ContentData = ContentData> = {
12
- /**
13
- * The content data object to render. Must have a `_schema` field that matches a key
14
- * in the component registry configured via `localessInit`.
15
- */
16
- data: T;
17
- /**
18
- * Optional map of content links keyed by link ID.
19
- * Pass through to child components so they can resolve {@link ContentLink} values with `findLink`.
20
- */
21
- links?: Links;
22
- /**
23
- * Optional map of resolved content references keyed by reference ID.
24
- * Pass through to child components that consume referenced content.
25
- */
26
- references?: References;
27
- };
28
- /**
29
- * Server-safe dynamic schema-to-component renderer for SSR and static-export environments.
30
- *
31
- * Equivalent to {@link LocalessComponent} but intentionally omits Visual Editor sync
32
- * attribute injection (`localessEditable`), making it safe for:
33
- * - Next.js static exports (`output: 'export'`)
34
- * - Server-side rendering where live editing is not needed
35
- *
36
- * Looks up `data._schema` in the component registry, renders the matched component,
37
- * falls back to the `fallbackComponent` if registered, or renders an inline error.
38
- *
39
- * **No `'use client'` directive** — safe to render in React Server Components.
40
- * If you need live Visual Editor editing use {@link LocalessComponent} from
41
- * `@localess/react` or `@localess/react/rsc` instead.
42
- *
43
- * @template T - The content data shape. Defaults to {@link ContentData}.
44
- *
45
- * @example
46
- * ```tsx
47
- * import { LocalessServerComponent } from '@localess/react/ssr';
48
- *
49
- * <LocalessServerComponent data={content.data} links={content.links} references={content.references} />
50
- * ```
51
- */
52
- declare const LocalessServerComponent: React.ForwardRefExoticComponent<LocalessServerComponentProps<ContentData> & React.RefAttributes<HTMLElement>>;
53
-
54
- /**
55
- * Props for {@link LocalessServerDocument}.
56
- *
57
- * @template T - The content data shape. Defaults to the base {@link ContentData} type.
58
- */
59
- type LocalessServerDocumentProps<T extends ContentData = ContentData> = {
60
- /**
61
- * The full content response object as returned by `getContentBySlug` or `getContentById`.
62
- * Must contain a `data` field with a valid `_schema` key.
63
- */
64
- document: Content<T>;
65
- };
66
- /**
67
- * Server-safe document renderer for SSR and static-export environments.
68
- *
69
- * Accepts the full {@link Content} wrapper (as returned by `getContentBySlug` /
70
- * `getContentById`) and delegates to {@link LocalessServerComponent}, automatically
71
- * passing `data`, `links`, and `references` through.
72
- *
73
- * This is a convenience wrapper — use it when you want to render a fetched
74
- * `Content<T>` object without manually destructuring it.
75
- *
76
- * **No live editing** — does not subscribe to Visual Editor sync events.
77
- * For live Visual Editor editing use {@link LocalessDocument} from `@localess/react/rsc`.
78
- *
79
- * **No `'use client'` directive** — safe to render in React Server Components
80
- * and Next.js static export pages.
81
- *
82
- * @template T - The content data shape. Defaults to {@link ContentData}.
83
- *
84
- * @example
85
- * ```tsx
86
- * import { LocalessServerDocument } from '@localess/react/ssr';
87
- *
88
- * // Server Component or getServerSideProps
89
- * const content = await getLocalessClient().getContentBySlug<MyPage>('home', { locale: 'en' });
90
- *
91
- * return <LocalessServerDocument document={content} />;
92
- * ```
93
- */
94
- declare const LocalessServerDocument: React.ForwardRefExoticComponent<LocalessServerDocumentProps<ContentData> & React.RefAttributes<HTMLElement>>;
95
-
96
- export { LocalessServerComponent, type LocalessServerComponentProps, LocalessServerDocument, type LocalessServerDocumentProps };