@localess/react 3.0.1-dev.20260411012947 → 3.0.1-dev.20260413071348
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/console.d.ts +2 -0
- package/dist/console.js +1 -0
- package/dist/console.mjs +4 -0
- package/dist/core/components/index.d.ts +8 -0
- package/dist/{localess-component-DikkO35Z.d.ts → core/components/localess-component.d.ts} +3 -7
- package/dist/core/components/localess-component.js +1 -0
- package/dist/core/components/localess-component.mjs +39 -0
- package/dist/{rsc.d.ts → core/components/localess-document.d.ts} +3 -11
- package/dist/core/components/localess-document.js +1 -0
- package/dist/core/components/localess-document.mjs +26 -0
- package/dist/core/hooks/index.d.ts +9 -0
- package/dist/core/hooks/use-localess.d.ts +45 -0
- package/dist/core/hooks/use-localess.js +1 -0
- package/dist/core/hooks/use-localess.mjs +25 -0
- package/dist/core/models/client.d.ts +43 -0
- package/dist/core/models/content.d.ts +1 -0
- package/dist/core/models/index.d.ts +33 -0
- package/dist/core/models/sync.d.ts +1 -0
- package/dist/core/models/translation.d.ts +1 -0
- package/dist/core/richtext.d.ts +26 -0
- package/dist/core/richtext.js +1 -0
- package/dist/core/richtext.mjs +48 -0
- package/dist/core/state.d.ts +127 -0
- package/dist/core/state.js +1 -0
- package/dist/core/state.mjs +43 -0
- package/dist/core/utils/index.d.ts +19 -0
- package/dist/core/utils/index.mjs +3 -0
- package/dist/core/utils/link.util.d.ts +24 -0
- package/dist/core/utils/link.util.js +1 -0
- package/dist/core/utils/link.util.mjs +15 -0
- package/dist/index.d.ts +19 -97
- package/dist/index.js +1 -284
- package/dist/index.mjs +8 -100
- package/dist/rsc/index.d.ts +30 -0
- package/dist/rsc/index.js +1 -0
- package/dist/rsc/index.mjs +9 -0
- package/dist/{rsc.d.mts → rsc/localess-document.d.ts} +3 -11
- package/dist/rsc/localess-document.js +1 -0
- package/dist/rsc/localess-document.mjs +23 -0
- package/dist/rsc/localess-sync.d.ts +7 -0
- package/dist/rsc/localess-sync.js +1 -0
- package/dist/rsc/localess-sync.mjs +15 -0
- package/dist/ssr/index.d.ts +33 -0
- package/dist/ssr/index.js +1 -0
- package/dist/ssr/index.mjs +7 -0
- package/dist/ssr/localess-component.d.ts +48 -0
- package/dist/ssr/localess-component.js +1 -0
- package/dist/ssr/localess-component.mjs +37 -0
- package/dist/ssr/localess-document.d.ts +42 -0
- package/dist/ssr/localess-document.js +1 -0
- package/dist/ssr/localess-document.mjs +17 -0
- package/package.json +32 -24
- package/dist/chunk-DD2NUMQJ.mjs +0 -56
- package/dist/chunk-ETSLIILF.mjs +0 -149
- package/dist/chunk-UW7OWE53.mjs +0 -45
- package/dist/index.d.mts +0 -104
- package/dist/localess-component-DikkO35Z.d.mts +0 -58
- package/dist/richtext-D6tBmv-7.d.mts +0 -218
- package/dist/richtext-D6tBmv-7.d.ts +0 -218
- package/dist/rsc.js +0 -280
- package/dist/rsc.mjs +0 -62
- package/dist/ssr.d.mts +0 -96
- package/dist/ssr.d.ts +0 -96
- package/dist/ssr.js +0 -223
- package/dist/ssr.mjs +0 -38
package/dist/ssr.js
DELETED
|
@@ -1,223 +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/ssr/index.ts
|
|
21
|
-
var ssr_exports = {};
|
|
22
|
-
__export(ssr_exports, {
|
|
23
|
-
LocalessServerComponent: () => LocalessServerComponent,
|
|
24
|
-
LocalessServerDocument: () => LocalessServerDocument,
|
|
25
|
-
findLink: () => findLink,
|
|
26
|
-
getComponent: () => getComponent,
|
|
27
|
-
getFallbackComponent: () => getFallbackComponent,
|
|
28
|
-
getLocalessClient: () => getLocalessClient,
|
|
29
|
-
isBrowser: () => import_client2.isBrowser,
|
|
30
|
-
isIframe: () => import_client2.isIframe,
|
|
31
|
-
isServer: () => import_client2.isServer,
|
|
32
|
-
localessEditable: () => import_client2.localessEditable,
|
|
33
|
-
localessEditableField: () => import_client2.localessEditableField,
|
|
34
|
-
localessInit: () => localessInit,
|
|
35
|
-
registerComponent: () => registerComponent,
|
|
36
|
-
renderRichTextToReact: () => renderRichTextToReact,
|
|
37
|
-
resolveAsset: () => resolveAsset,
|
|
38
|
-
unregisterComponent: () => unregisterComponent
|
|
39
|
-
});
|
|
40
|
-
module.exports = __toCommonJS(ssr_exports);
|
|
41
|
-
|
|
42
|
-
// src/core/state.ts
|
|
43
|
-
var import_client = require("@localess/client");
|
|
44
|
-
|
|
45
|
-
// src/console.ts
|
|
46
|
-
var FONT_BOLD = "font-weight: bold";
|
|
47
|
-
var FONT_NORMAL = "font-weight: normal";
|
|
48
|
-
|
|
49
|
-
// src/core/state.ts
|
|
50
|
-
var _client = void 0;
|
|
51
|
-
var _components = {};
|
|
52
|
-
var _fallbackComponent = void 0;
|
|
53
|
-
var _enableSync = false;
|
|
54
|
-
var _assetPathPrefix = "";
|
|
55
|
-
function localessInit(options) {
|
|
56
|
-
console.log("localessInit", options);
|
|
57
|
-
const { components, fallbackComponent, enableSync, ...restOptions } = options;
|
|
58
|
-
_client = (0, import_client.localessClient)(restOptions);
|
|
59
|
-
_assetPathPrefix = `${options.origin}/api/v1/spaces/${options.spaceId}/assets/`;
|
|
60
|
-
_components = components || {};
|
|
61
|
-
_fallbackComponent = fallbackComponent;
|
|
62
|
-
if (enableSync) {
|
|
63
|
-
_enableSync = true;
|
|
64
|
-
(0, import_client.loadLocalessSync)(restOptions.origin);
|
|
65
|
-
}
|
|
66
|
-
return _client;
|
|
67
|
-
}
|
|
68
|
-
function getLocalessClient() {
|
|
69
|
-
if (!_client) {
|
|
70
|
-
console.error("[Localess] No client found. Please check if the Localess is initialized.");
|
|
71
|
-
throw new Error("[Localess] No client found.");
|
|
72
|
-
}
|
|
73
|
-
return _client;
|
|
74
|
-
}
|
|
75
|
-
function registerComponent(key, component) {
|
|
76
|
-
_components[key] = component;
|
|
77
|
-
}
|
|
78
|
-
function unregisterComponent(key) {
|
|
79
|
-
delete _components[key];
|
|
80
|
-
}
|
|
81
|
-
function getComponent(key) {
|
|
82
|
-
if (Object.hasOwn(_components, key)) {
|
|
83
|
-
return _components[key];
|
|
84
|
-
}
|
|
85
|
-
console.error(`[Localess] component %c${key}%c can't be found.`, FONT_BOLD, FONT_NORMAL);
|
|
86
|
-
return void 0;
|
|
87
|
-
}
|
|
88
|
-
function getFallbackComponent() {
|
|
89
|
-
return _fallbackComponent;
|
|
90
|
-
}
|
|
91
|
-
function resolveAsset(asset) {
|
|
92
|
-
return `${_assetPathPrefix}${asset.uri}`;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// src/ssr/localess-component.tsx
|
|
96
|
-
var import_react = require("react");
|
|
97
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
98
|
-
var LocalessServerComponent = (0, import_react.forwardRef)(({ data, links, references, ...restProps }, ref) => {
|
|
99
|
-
if (!data) {
|
|
100
|
-
console.error("LocalessServerComponent property %cdata%c is not provided.", FONT_BOLD, FONT_NORMAL);
|
|
101
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
102
|
-
"LocalessServerComponent property ",
|
|
103
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: "data" }),
|
|
104
|
-
" is not provided."
|
|
105
|
-
] });
|
|
106
|
-
}
|
|
107
|
-
const Comp = getComponent(data._schema);
|
|
108
|
-
if (Comp) {
|
|
109
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Comp, { ref, data, links, references, ...restProps });
|
|
110
|
-
}
|
|
111
|
-
const FallbackComponent = getFallbackComponent();
|
|
112
|
-
if (FallbackComponent) {
|
|
113
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FallbackComponent, { ref, data, links, references, ...restProps });
|
|
114
|
-
}
|
|
115
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
|
|
116
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: "LocalessServerComponent" }),
|
|
117
|
-
" could not found component with key ",
|
|
118
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("b", { children: data._schema }),
|
|
119
|
-
". ",
|
|
120
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}),
|
|
121
|
-
"Please check if your configuration is correct."
|
|
122
|
-
] });
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
// src/ssr/localess-document.tsx
|
|
126
|
-
var import_react2 = require("react");
|
|
127
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
128
|
-
var LocalessServerDocument = (0, import_react2.forwardRef)(({ document }, ref) => {
|
|
129
|
-
if (!document.data) {
|
|
130
|
-
console.error("LocalessServerDocument property %cdocument.data%c is not provided.", FONT_BOLD, FONT_NORMAL);
|
|
131
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
132
|
-
"LocalessServerDocument property ",
|
|
133
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("b", { children: "document.data" }),
|
|
134
|
-
" is not provided."
|
|
135
|
-
] });
|
|
136
|
-
}
|
|
137
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LocalessServerComponent, { ref, data: document.data, links: document.links, references: document.references });
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
// src/core/richtext.ts
|
|
141
|
-
var import_react3 = require("@tiptap/static-renderer/pm/react");
|
|
142
|
-
var import_extension_document = require("@tiptap/extension-document");
|
|
143
|
-
var import_extension_text = require("@tiptap/extension-text");
|
|
144
|
-
var import_extension_paragraph = require("@tiptap/extension-paragraph");
|
|
145
|
-
var import_extension_heading = require("@tiptap/extension-heading");
|
|
146
|
-
var import_extension_bold = require("@tiptap/extension-bold");
|
|
147
|
-
var import_extension_italic = require("@tiptap/extension-italic");
|
|
148
|
-
var import_extension_strike = require("@tiptap/extension-strike");
|
|
149
|
-
var import_extension_underline = require("@tiptap/extension-underline");
|
|
150
|
-
var import_extension_history = require("@tiptap/extension-history");
|
|
151
|
-
var import_extension_list_item = require("@tiptap/extension-list-item");
|
|
152
|
-
var import_extension_ordered_list = require("@tiptap/extension-ordered-list");
|
|
153
|
-
var import_extension_bullet_list = require("@tiptap/extension-bullet-list");
|
|
154
|
-
var import_extension_code = require("@tiptap/extension-code");
|
|
155
|
-
var import_extension_code_block_lowlight = require("@tiptap/extension-code-block-lowlight");
|
|
156
|
-
var import_extension_link = require("@tiptap/extension-link");
|
|
157
|
-
function renderRichTextToReact(content) {
|
|
158
|
-
return (0, import_react3.renderToReactElement)({
|
|
159
|
-
content,
|
|
160
|
-
extensions: [
|
|
161
|
-
import_extension_document.Document,
|
|
162
|
-
import_extension_text.Text,
|
|
163
|
-
import_extension_paragraph.Paragraph,
|
|
164
|
-
import_extension_heading.Heading.configure({
|
|
165
|
-
levels: [1, 2, 3, 4, 5, 6]
|
|
166
|
-
}),
|
|
167
|
-
import_extension_bold.Bold,
|
|
168
|
-
import_extension_italic.Italic,
|
|
169
|
-
import_extension_strike.Strike,
|
|
170
|
-
import_extension_underline.Underline,
|
|
171
|
-
import_extension_history.History,
|
|
172
|
-
import_extension_list_item.ListItem,
|
|
173
|
-
import_extension_ordered_list.OrderedList,
|
|
174
|
-
import_extension_bullet_list.BulletList,
|
|
175
|
-
import_extension_code.Code,
|
|
176
|
-
import_extension_code_block_lowlight.CodeBlockLowlight,
|
|
177
|
-
import_extension_link.Link
|
|
178
|
-
]
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// src/core/utils/index.ts
|
|
183
|
-
var import_client2 = require("@localess/client");
|
|
184
|
-
|
|
185
|
-
// src/core/utils/link.util.ts
|
|
186
|
-
function findLink(links, link) {
|
|
187
|
-
switch (link.type) {
|
|
188
|
-
case "content": {
|
|
189
|
-
if (links) {
|
|
190
|
-
const path = links[link.uri];
|
|
191
|
-
if (path) {
|
|
192
|
-
return "/" + path.fullSlug;
|
|
193
|
-
} else {
|
|
194
|
-
return "/not-found";
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
return "/not-found";
|
|
198
|
-
}
|
|
199
|
-
case "url":
|
|
200
|
-
return link.uri;
|
|
201
|
-
default:
|
|
202
|
-
return "no-type";
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
206
|
-
0 && (module.exports = {
|
|
207
|
-
LocalessServerComponent,
|
|
208
|
-
LocalessServerDocument,
|
|
209
|
-
findLink,
|
|
210
|
-
getComponent,
|
|
211
|
-
getFallbackComponent,
|
|
212
|
-
getLocalessClient,
|
|
213
|
-
isBrowser,
|
|
214
|
-
isIframe,
|
|
215
|
-
isServer,
|
|
216
|
-
localessEditable,
|
|
217
|
-
localessEditableField,
|
|
218
|
-
localessInit,
|
|
219
|
-
registerComponent,
|
|
220
|
-
renderRichTextToReact,
|
|
221
|
-
resolveAsset,
|
|
222
|
-
unregisterComponent
|
|
223
|
-
});
|
package/dist/ssr.mjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
LocalessServerComponent,
|
|
3
|
-
LocalessServerDocument
|
|
4
|
-
} from "./chunk-DD2NUMQJ.mjs";
|
|
5
|
-
import {
|
|
6
|
-
findLink,
|
|
7
|
-
getComponent,
|
|
8
|
-
getFallbackComponent,
|
|
9
|
-
getLocalessClient,
|
|
10
|
-
isBrowser,
|
|
11
|
-
isIframe,
|
|
12
|
-
isServer,
|
|
13
|
-
localessEditable,
|
|
14
|
-
localessEditableField,
|
|
15
|
-
localessInit,
|
|
16
|
-
registerComponent,
|
|
17
|
-
renderRichTextToReact,
|
|
18
|
-
resolveAsset,
|
|
19
|
-
unregisterComponent
|
|
20
|
-
} from "./chunk-ETSLIILF.mjs";
|
|
21
|
-
export {
|
|
22
|
-
LocalessServerComponent,
|
|
23
|
-
LocalessServerDocument,
|
|
24
|
-
findLink,
|
|
25
|
-
getComponent,
|
|
26
|
-
getFallbackComponent,
|
|
27
|
-
getLocalessClient,
|
|
28
|
-
isBrowser,
|
|
29
|
-
isIframe,
|
|
30
|
-
isServer,
|
|
31
|
-
localessEditable,
|
|
32
|
-
localessEditableField,
|
|
33
|
-
localessInit,
|
|
34
|
-
registerComponent,
|
|
35
|
-
renderRichTextToReact,
|
|
36
|
-
resolveAsset,
|
|
37
|
-
unregisterComponent
|
|
38
|
-
};
|