@localess/js-client 0.8.3-next.20251219-194058.0 → 0.8.4-next.20251222-115502.0
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/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +15 -7
- package/dist/index.mjs +12 -7
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -293,6 +293,10 @@ declare function llEditableField(fieldName: string): {
|
|
|
293
293
|
*/
|
|
294
294
|
declare function loadLocalessSync(origin: string, force?: boolean): void;
|
|
295
295
|
|
|
296
|
+
declare const isBrowser: () => boolean;
|
|
297
|
+
declare const isServer: () => boolean;
|
|
298
|
+
declare const isIframe: () => boolean;
|
|
299
|
+
|
|
296
300
|
type EventToAppType = 'save' | 'publish' | 'pong' | 'input' | 'change' | 'enterSchema' | 'hoverSchema';
|
|
297
301
|
type EventCallback = (event: EventToApp) => void;
|
|
298
302
|
type EventToApp = {
|
|
@@ -316,4 +320,4 @@ declare global {
|
|
|
316
320
|
}
|
|
317
321
|
}
|
|
318
322
|
|
|
319
|
-
export { type Content, type ContentAsset, type ContentData, type ContentDataField, type ContentDataSchema, type ContentFetchParams, type ContentLink, type ContentMetadata, type ContentReference, type ContentRichText, type EventCallback, type EventToApp, type EventToAppType, type Links, type LinksFetchParams, type LocalessClient, type LocalessClientOptions, type LocalessSync, type Translations, llEditable, llEditableField, loadLocalessSync, localessClient, localessEditable, localessEditableField };
|
|
323
|
+
export { type Content, type ContentAsset, type ContentData, type ContentDataField, type ContentDataSchema, type ContentFetchParams, type ContentLink, type ContentMetadata, type ContentReference, type ContentRichText, type EventCallback, type EventToApp, type EventToAppType, type Links, type LinksFetchParams, type LocalessClient, type LocalessClientOptions, type LocalessSync, type Translations, isBrowser, isIframe, isServer, llEditable, llEditableField, loadLocalessSync, localessClient, localessEditable, localessEditableField };
|
package/dist/index.d.ts
CHANGED
|
@@ -293,6 +293,10 @@ declare function llEditableField(fieldName: string): {
|
|
|
293
293
|
*/
|
|
294
294
|
declare function loadLocalessSync(origin: string, force?: boolean): void;
|
|
295
295
|
|
|
296
|
+
declare const isBrowser: () => boolean;
|
|
297
|
+
declare const isServer: () => boolean;
|
|
298
|
+
declare const isIframe: () => boolean;
|
|
299
|
+
|
|
296
300
|
type EventToAppType = 'save' | 'publish' | 'pong' | 'input' | 'change' | 'enterSchema' | 'hoverSchema';
|
|
297
301
|
type EventCallback = (event: EventToApp) => void;
|
|
298
302
|
type EventToApp = {
|
|
@@ -316,4 +320,4 @@ declare global {
|
|
|
316
320
|
}
|
|
317
321
|
}
|
|
318
322
|
|
|
319
|
-
export { type Content, type ContentAsset, type ContentData, type ContentDataField, type ContentDataSchema, type ContentFetchParams, type ContentLink, type ContentMetadata, type ContentReference, type ContentRichText, type EventCallback, type EventToApp, type EventToAppType, type Links, type LinksFetchParams, type LocalessClient, type LocalessClientOptions, type LocalessSync, type Translations, llEditable, llEditableField, loadLocalessSync, localessClient, localessEditable, localessEditableField };
|
|
323
|
+
export { type Content, type ContentAsset, type ContentData, type ContentDataField, type ContentDataSchema, type ContentFetchParams, type ContentLink, type ContentMetadata, type ContentReference, type ContentRichText, type EventCallback, type EventToApp, type EventToAppType, type Links, type LinksFetchParams, type LocalessClient, type LocalessClientOptions, type LocalessSync, type Translations, isBrowser, isIframe, isServer, llEditable, llEditableField, loadLocalessSync, localessClient, localessEditable, localessEditableField };
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
isBrowser: () => isBrowser,
|
|
24
|
+
isIframe: () => isIframe,
|
|
25
|
+
isServer: () => isServer,
|
|
23
26
|
llEditable: () => llEditable,
|
|
24
27
|
llEditableField: () => llEditableField,
|
|
25
28
|
loadLocalessSync: () => loadLocalessSync,
|
|
@@ -32,6 +35,9 @@ module.exports = __toCommonJS(index_exports);
|
|
|
32
35
|
// src/utils.ts
|
|
33
36
|
var RESET = "\x1B[0m";
|
|
34
37
|
var FG_BLUE = "\x1B[34m";
|
|
38
|
+
var isBrowser = () => typeof window !== "undefined";
|
|
39
|
+
var isServer = () => typeof window === "undefined";
|
|
40
|
+
var isIframe = () => isBrowser() && window.self !== window.top;
|
|
35
41
|
|
|
36
42
|
// src/client.ts
|
|
37
43
|
var LOG_GROUP = `${FG_BLUE}[Localess:Client]${RESET}`;
|
|
@@ -45,14 +51,14 @@ function localessClient(options) {
|
|
|
45
51
|
"Content-Type": "application/json",
|
|
46
52
|
"Accept": "application/json",
|
|
47
53
|
"X-Localess-Agent": "Localess-JS-Client",
|
|
48
|
-
"X-Localess-Agent-Version": "0.
|
|
54
|
+
"X-Localess-Agent-Version": "0.8.3"
|
|
49
55
|
}
|
|
50
56
|
};
|
|
51
57
|
const cache = /* @__PURE__ */ new Map();
|
|
52
58
|
return {
|
|
53
59
|
async getLinks(params) {
|
|
54
60
|
if (options.debug) {
|
|
55
|
-
console.log(LOG_GROUP, "getLinks() params : "
|
|
61
|
+
console.log(LOG_GROUP, "getLinks() params : ", JSON.stringify(params));
|
|
56
62
|
}
|
|
57
63
|
let kind = "";
|
|
58
64
|
if (params?.kind) {
|
|
@@ -92,7 +98,7 @@ function localessClient(options) {
|
|
|
92
98
|
async getContentBySlug(slug, params) {
|
|
93
99
|
if (options.debug) {
|
|
94
100
|
console.log(LOG_GROUP, "getContentBySlug() slug : ", slug);
|
|
95
|
-
console.log(LOG_GROUP, "getContentBySlug() params : ", params);
|
|
101
|
+
console.log(LOG_GROUP, "getContentBySlug() params : ", JSON.stringify(params));
|
|
96
102
|
}
|
|
97
103
|
let version = "";
|
|
98
104
|
if (options?.version && options.version == "draft") {
|
|
@@ -128,7 +134,7 @@ function localessClient(options) {
|
|
|
128
134
|
async getContentById(id, params) {
|
|
129
135
|
if (options.debug) {
|
|
130
136
|
console.log(LOG_GROUP, "getContentById() id : ", id);
|
|
131
|
-
console.log(LOG_GROUP, "getContentById() params : ", params);
|
|
137
|
+
console.log(LOG_GROUP, "getContentById() params : ", JSON.stringify(params));
|
|
132
138
|
}
|
|
133
139
|
let version = "";
|
|
134
140
|
if (options?.version && options.version == "draft") {
|
|
@@ -228,9 +234,8 @@ function llEditableField(fieldName) {
|
|
|
228
234
|
// src/sync.ts
|
|
229
235
|
var JS_SYNC_ID = "localess-js-sync";
|
|
230
236
|
function loadLocalessSync(origin, force = false) {
|
|
231
|
-
|
|
232
|
-
if (
|
|
233
|
-
if (window.top === window.self) return;
|
|
237
|
+
if (isServer()) return;
|
|
238
|
+
if (!isIframe()) return;
|
|
234
239
|
const isSyncLoaded = typeof window.localess !== "undefined";
|
|
235
240
|
if (isSyncLoaded) return;
|
|
236
241
|
const scriptEl = document.getElementById(JS_SYNC_ID);
|
|
@@ -246,6 +251,9 @@ function loadLocalessSync(origin, force = false) {
|
|
|
246
251
|
}
|
|
247
252
|
// Annotate the CommonJS export names for ESM import in node:
|
|
248
253
|
0 && (module.exports = {
|
|
254
|
+
isBrowser,
|
|
255
|
+
isIframe,
|
|
256
|
+
isServer,
|
|
249
257
|
llEditable,
|
|
250
258
|
llEditableField,
|
|
251
259
|
loadLocalessSync,
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// src/utils.ts
|
|
2
2
|
var RESET = "\x1B[0m";
|
|
3
3
|
var FG_BLUE = "\x1B[34m";
|
|
4
|
+
var isBrowser = () => typeof window !== "undefined";
|
|
5
|
+
var isServer = () => typeof window === "undefined";
|
|
6
|
+
var isIframe = () => isBrowser() && window.self !== window.top;
|
|
4
7
|
|
|
5
8
|
// src/client.ts
|
|
6
9
|
var LOG_GROUP = `${FG_BLUE}[Localess:Client]${RESET}`;
|
|
@@ -14,14 +17,14 @@ function localessClient(options) {
|
|
|
14
17
|
"Content-Type": "application/json",
|
|
15
18
|
"Accept": "application/json",
|
|
16
19
|
"X-Localess-Agent": "Localess-JS-Client",
|
|
17
|
-
"X-Localess-Agent-Version": "0.
|
|
20
|
+
"X-Localess-Agent-Version": "0.8.3"
|
|
18
21
|
}
|
|
19
22
|
};
|
|
20
23
|
const cache = /* @__PURE__ */ new Map();
|
|
21
24
|
return {
|
|
22
25
|
async getLinks(params) {
|
|
23
26
|
if (options.debug) {
|
|
24
|
-
console.log(LOG_GROUP, "getLinks() params : "
|
|
27
|
+
console.log(LOG_GROUP, "getLinks() params : ", JSON.stringify(params));
|
|
25
28
|
}
|
|
26
29
|
let kind = "";
|
|
27
30
|
if (params?.kind) {
|
|
@@ -61,7 +64,7 @@ function localessClient(options) {
|
|
|
61
64
|
async getContentBySlug(slug, params) {
|
|
62
65
|
if (options.debug) {
|
|
63
66
|
console.log(LOG_GROUP, "getContentBySlug() slug : ", slug);
|
|
64
|
-
console.log(LOG_GROUP, "getContentBySlug() params : ", params);
|
|
67
|
+
console.log(LOG_GROUP, "getContentBySlug() params : ", JSON.stringify(params));
|
|
65
68
|
}
|
|
66
69
|
let version = "";
|
|
67
70
|
if (options?.version && options.version == "draft") {
|
|
@@ -97,7 +100,7 @@ function localessClient(options) {
|
|
|
97
100
|
async getContentById(id, params) {
|
|
98
101
|
if (options.debug) {
|
|
99
102
|
console.log(LOG_GROUP, "getContentById() id : ", id);
|
|
100
|
-
console.log(LOG_GROUP, "getContentById() params : ", params);
|
|
103
|
+
console.log(LOG_GROUP, "getContentById() params : ", JSON.stringify(params));
|
|
101
104
|
}
|
|
102
105
|
let version = "";
|
|
103
106
|
if (options?.version && options.version == "draft") {
|
|
@@ -197,9 +200,8 @@ function llEditableField(fieldName) {
|
|
|
197
200
|
// src/sync.ts
|
|
198
201
|
var JS_SYNC_ID = "localess-js-sync";
|
|
199
202
|
function loadLocalessSync(origin, force = false) {
|
|
200
|
-
|
|
201
|
-
if (
|
|
202
|
-
if (window.top === window.self) return;
|
|
203
|
+
if (isServer()) return;
|
|
204
|
+
if (!isIframe()) return;
|
|
203
205
|
const isSyncLoaded = typeof window.localess !== "undefined";
|
|
204
206
|
if (isSyncLoaded) return;
|
|
205
207
|
const scriptEl = document.getElementById(JS_SYNC_ID);
|
|
@@ -214,6 +216,9 @@ function loadLocalessSync(origin, force = false) {
|
|
|
214
216
|
document.head.appendChild(script);
|
|
215
217
|
}
|
|
216
218
|
export {
|
|
219
|
+
isBrowser,
|
|
220
|
+
isIframe,
|
|
221
|
+
isServer,
|
|
217
222
|
llEditable,
|
|
218
223
|
llEditableField,
|
|
219
224
|
loadLocalessSync,
|