@localess/react 3.0.6-dev.20260502214443 → 3.0.6-dev.20260512074100
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/README.md +62 -61
- package/SKILL.md +8 -7
- package/dist/core/models/client.d.ts +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -38,11 +38,11 @@ pnpm add @localess/react
|
|
|
38
38
|
|
|
39
39
|
`@localess/react` provides three different exports to suit different rendering strategies:
|
|
40
40
|
|
|
41
|
-
| Export
|
|
42
|
-
|
|
43
|
-
| `@localess/react`
|
|
44
|
-
| `@localess/react/ssr` | SSR without live editing, Next.js static exports
|
|
45
|
-
| `@localess/react/rsc` | React Server Components with live editing
|
|
41
|
+
| Export | Use Case | Live Editing | Static Export |
|
|
42
|
+
|-----------------------|-------------------------------------------------------|--------------|---------------|
|
|
43
|
+
| `@localess/react` | Single Page Applications (SPA), client-side rendering | ✅ | ✅ |
|
|
44
|
+
| `@localess/react/ssr` | SSR without live editing, Next.js static exports | ❌ | ✅ |
|
|
45
|
+
| `@localess/react/rsc` | React Server Components with live editing | ✅ | ❌ |
|
|
46
46
|
|
|
47
47
|
### When to Use Each Export
|
|
48
48
|
|
|
@@ -105,17 +105,18 @@ localessInit({
|
|
|
105
105
|
|
|
106
106
|
### Initialization Options
|
|
107
107
|
|
|
108
|
-
| Option
|
|
109
|
-
|
|
110
|
-
| `origin`
|
|
111
|
-
| `spaceId`
|
|
112
|
-
| `token`
|
|
113
|
-
| `version`
|
|
114
|
-
| `debug`
|
|
115
|
-
| `cacheTTL`
|
|
116
|
-
| `
|
|
117
|
-
| `
|
|
118
|
-
| `
|
|
108
|
+
| Option | Type | Required | Default | Description |
|
|
109
|
+
|---------------------|-------------------------------------|----------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
110
|
+
| `origin` | `string` | ✅ | — | Fully qualified domain with protocol (e.g., `https://my-localess.web.app`) |
|
|
111
|
+
| `spaceId` | `string` | ✅ | — | Localess Space ID, found in Space settings |
|
|
112
|
+
| `token` | `string` | ✅ | — | Localess API token (keep secret — server-side only) |
|
|
113
|
+
| `version` | `'draft' \| string` | ❌ | `'published'` | Default content version |
|
|
114
|
+
| `debug` | `boolean` | ❌ | `false` | Enable debug logging |
|
|
115
|
+
| `cacheTTL` | `number \| false` | ❌ | `300` | Cache TTL in **seconds** (default: 5 minutes). Set `false` to disable caching entirely — takes precedence over `fileSystemCache` |
|
|
116
|
+
| `fileSystemCache` | `boolean` | ❌ | `false` | Use a file-system cache instead of the default in-memory cache. Shared across all processes pointing to the same working directory (e.g. Next.js parallel build workers). Respects `cacheTTL` for TTL value |
|
|
117
|
+
| `components` | `Record<string, React.ElementType>` | ❌ | `{}` | Map of schema keys to React components |
|
|
118
|
+
| `fallbackComponent` | `React.ElementType` | ❌ | — | Component rendered when a schema key has no registered component |
|
|
119
|
+
| `enableSync` | `boolean` | ❌ | `false` | Load the Visual Editor sync script for live-editing support |
|
|
119
120
|
|
|
120
121
|
---
|
|
121
122
|
|
|
@@ -142,13 +143,13 @@ import { LocalessComponent } from "@localess/react";
|
|
|
142
143
|
|
|
143
144
|
### Props
|
|
144
145
|
|
|
145
|
-
| Prop
|
|
146
|
-
|
|
147
|
-
| `data`
|
|
148
|
-
| `links`
|
|
149
|
-
| `references` | `References`
|
|
150
|
-
| `ref`
|
|
151
|
-
| `...rest`
|
|
146
|
+
| Prop | Type | Required | Description |
|
|
147
|
+
|--------------|--------------------------|----------|----------------------------------------------------------------------------------------------------|
|
|
148
|
+
| `data` | `ContentData` | ✅ | Content data object from Localess. The component looks up `data._schema` in the component registry |
|
|
149
|
+
| `links` | `Links` | ❌ | Resolved content links map, forwarded to the rendered component |
|
|
150
|
+
| `references` | `References` | ❌ | Resolved references map, forwarded to the rendered component |
|
|
151
|
+
| `ref` | `React.Ref<HTMLElement>` | ❌ | Ref forwarded to the rendered component's root element |
|
|
152
|
+
| `...rest` | `any` | ❌ | Any additional props are forwarded to the rendered component |
|
|
152
153
|
|
|
153
154
|
> If a schema key is not registered and no `fallbackComponent` is configured, `LocalessComponent` renders an error message in the DOM.
|
|
154
155
|
|
|
@@ -321,10 +322,10 @@ export function PageView({ slug }: { slug: string }) {
|
|
|
321
322
|
|
|
322
323
|
### Parameters
|
|
323
324
|
|
|
324
|
-
| Parameter | Type
|
|
325
|
-
|
|
326
|
-
| `slug`
|
|
327
|
-
| `options` | `ContentFetchParams` | ❌
|
|
325
|
+
| Parameter | Type | Required | Description |
|
|
326
|
+
|-----------|----------------------|----------|-------------------------------------------------------------------------------------------|
|
|
327
|
+
| `slug` | `string \| string[]` | ✅ | Content slug. Arrays are joined with `/` — e.g. `['blog', 'post']` → `'blog/post'` |
|
|
328
|
+
| `options` | `ContentFetchParams` | ❌ | Same fetch options as `getContentBySlug` (locale, version, resolveReference, resolveLink) |
|
|
328
329
|
|
|
329
330
|
Returns `Content<T> | undefined` — `undefined` while the initial fetch is in progress.
|
|
330
331
|
|
|
@@ -405,13 +406,13 @@ export default async function HomePage({ params }: { params: Promise<{ locale?:
|
|
|
405
406
|
|
|
406
407
|
**Props:**
|
|
407
408
|
|
|
408
|
-
| Prop
|
|
409
|
-
|
|
410
|
-
| `data`
|
|
411
|
-
| `links`
|
|
412
|
-
| `references` | `References`
|
|
413
|
-
| `ref`
|
|
414
|
-
| `...rest`
|
|
409
|
+
| Prop | Type | Required | Description |
|
|
410
|
+
|--------------|--------------------------|----------|---------------------------------------------------------------------|
|
|
411
|
+
| `data` | `ContentData` | ✅ | Initial content data (typically server-fetched) |
|
|
412
|
+
| `links` | `Links` | ❌ | Resolved links map, forwarded to the inner `LocalessComponent` |
|
|
413
|
+
| `references` | `References` | ❌ | Resolved references map, forwarded to the inner `LocalessComponent` |
|
|
414
|
+
| `ref` | `React.Ref<HTMLElement>` | ❌ | Forwarded to the rendered root element |
|
|
415
|
+
| `...rest` | `any` | ❌ | Any additional props are forwarded |
|
|
415
416
|
|
|
416
417
|
> `LocalessDocument` subscribes to `input` / `change` editor events automatically when `enableSync` is active. It is a Client Component internally — no `'use client'` directive needed at the call site in Server Components.
|
|
417
418
|
|
|
@@ -452,15 +453,15 @@ export function PageClient({ initialContent }: { initialContent: Content<Page> }
|
|
|
452
453
|
|
|
453
454
|
**Available events via `window.localess.on()`:**
|
|
454
455
|
|
|
455
|
-
| Event
|
|
456
|
-
|
|
457
|
-
| `input`
|
|
458
|
-
| `change`
|
|
459
|
-
| `save`
|
|
460
|
-
| `publish`
|
|
461
|
-
| `pong`
|
|
462
|
-
| `enterSchema` | Editor cursor enters a schema block
|
|
463
|
-
| `hoverSchema` | Editor cursor hovers over a schema block
|
|
456
|
+
| Event | When |
|
|
457
|
+
|---------------|-----------------------------------------------|
|
|
458
|
+
| `input` | User is typing in a field (real-time preview) |
|
|
459
|
+
| `change` | Field value confirmed |
|
|
460
|
+
| `save` | Content saved |
|
|
461
|
+
| `publish` | Content published |
|
|
462
|
+
| `pong` | Editor heartbeat response |
|
|
463
|
+
| `enterSchema` | Editor cursor enters a schema block |
|
|
464
|
+
| `hoverSchema` | Editor cursor hovers over a schema block |
|
|
464
465
|
|
|
465
466
|
> `window.localess` only exposes `.on()` and `.onChange()` — there is no `.off()` method.
|
|
466
467
|
|
|
@@ -743,24 +744,24 @@ export default function PageClient({ initialContent, locale }) {
|
|
|
743
744
|
|
|
744
745
|
The table below shows which symbols are available in each export.
|
|
745
746
|
|
|
746
|
-
| Symbol
|
|
747
|
-
|
|
748
|
-
| `localessInit`
|
|
749
|
-
| `getLocalessClient`
|
|
750
|
-
| `registerComponent` / `setComponents` / `getComponent` |
|
|
751
|
-
| `setFallbackComponent` / `getFallbackComponent`
|
|
752
|
-
| `resolveAsset`
|
|
753
|
-
| `LocalessComponent`
|
|
754
|
-
| `renderRichTextToReact`
|
|
755
|
-
| `findLink`
|
|
756
|
-
| `isServer`
|
|
757
|
-
| All content types
|
|
758
|
-
| `LocalessDocument`
|
|
759
|
-
| `useLocaless`
|
|
760
|
-
| `localessEditable` / `localessEditableField`
|
|
761
|
-
| `isBrowser` / `isIframe`
|
|
762
|
-
| `isSyncEnabled`
|
|
763
|
-
| Sync event types (`LocalessSync`, `EventToApp`, …)
|
|
747
|
+
| Symbol | `@localess/react` | `@localess/react/ssr` | `@localess/react/rsc` |
|
|
748
|
+
|--------------------------------------------------------|:-----------------:|:---------------------:|:---------------------:|
|
|
749
|
+
| `localessInit` | ✅ | ✅ | ✅ |
|
|
750
|
+
| `getLocalessClient` | ✅ | ✅ | ✅ |
|
|
751
|
+
| `registerComponent` / `setComponents` / `getComponent` | ✅ | ✅ | ✅ |
|
|
752
|
+
| `setFallbackComponent` / `getFallbackComponent` | ✅ | ✅ | ✅ |
|
|
753
|
+
| `resolveAsset` | ✅ | ✅ | ✅ |
|
|
754
|
+
| `LocalessComponent` | ✅ | ✅ | ✅ |
|
|
755
|
+
| `renderRichTextToReact` | ✅ | ✅ | ✅ |
|
|
756
|
+
| `findLink` | ✅ | ✅ | ✅ |
|
|
757
|
+
| `isServer` | ✅ | ✅ | ✅ |
|
|
758
|
+
| All content types | ✅ | ✅ | ✅ |
|
|
759
|
+
| `LocalessDocument` | ✅ | ❌ | ✅ |
|
|
760
|
+
| `useLocaless` | ✅ | ❌ | ✅ |
|
|
761
|
+
| `localessEditable` / `localessEditableField` | ✅ | ❌ | ✅ |
|
|
762
|
+
| `isBrowser` / `isIframe` | ✅ | ❌ | ✅ |
|
|
763
|
+
| `isSyncEnabled` | ✅ | ❌ | ✅ |
|
|
764
|
+
| Sync event types (`LocalessSync`, `EventToApp`, …) | ✅ | ❌ | ✅ |
|
|
764
765
|
|
|
765
766
|
---
|
|
766
767
|
|
package/SKILL.md
CHANGED
|
@@ -37,7 +37,8 @@ localessInit({
|
|
|
37
37
|
|
|
38
38
|
// Optional client settings
|
|
39
39
|
version: 'draft', // undefined = published (default), 'draft' for preview
|
|
40
|
-
cacheTTL:
|
|
40
|
+
cacheTTL: 300, // Cache TTL in seconds; false to disable; default: 300 (5 min)
|
|
41
|
+
fileSystemCache: false, // true = share cache across processes (e.g. Next.js build workers)
|
|
41
42
|
debug: false,
|
|
42
43
|
|
|
43
44
|
// React-specific options
|
|
@@ -228,12 +229,12 @@ export default async function HomePage({ params }: { params: Promise<{ locale?:
|
|
|
228
229
|
|
|
229
230
|
**Props** (same shape as `LocalessComponent`):
|
|
230
231
|
|
|
231
|
-
| Prop
|
|
232
|
-
|
|
233
|
-
| `data`
|
|
234
|
-
| `links`
|
|
235
|
-
| `references` | `References`
|
|
236
|
-
| `ref`
|
|
232
|
+
| Prop | Type | Required | Description |
|
|
233
|
+
|--------------|--------------------------|----------|----------------------------------------|
|
|
234
|
+
| `data` | `ContentData` | ✅ | Initial content data |
|
|
235
|
+
| `links` | `Links` | ❌ | Resolved links map |
|
|
236
|
+
| `references` | `References` | ❌ | Resolved references map |
|
|
237
|
+
| `ref` | `React.Ref<HTMLElement>` | ❌ | Forwarded to the rendered root element |
|
|
237
238
|
|
|
238
239
|
> Subscribes to `input` / `change` events automatically when `enableSync` is active. Unlike `useLocaless`, it does not fetch content — it only handles live sync for data passed in as props.
|
|
239
240
|
|
|
@@ -4,7 +4,7 @@ export type { LocalessClient } from '@localess/client';
|
|
|
4
4
|
/**
|
|
5
5
|
* Initialization options for {@link localessInit}.
|
|
6
6
|
*
|
|
7
|
-
* Extends {@link LocalessClientOptions} (origin, spaceId, token, version, debug, cacheTTL)
|
|
7
|
+
* Extends {@link LocalessClientOptions} (origin, spaceId, token, version, debug, cacheTTL, fileSystemCache)
|
|
8
8
|
* with React-specific settings for component mapping and Visual Editor sync.
|
|
9
9
|
*/
|
|
10
10
|
export type LocalessOptions = LocalessClientOptions & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@localess/react",
|
|
3
|
-
"version": "3.0.6-dev.
|
|
3
|
+
"version": "3.0.6-dev.20260512074100",
|
|
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.6-dev.
|
|
64
|
+
"@localess/client": "3.0.6-dev.20260512074100",
|
|
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",
|