@localess/client 3.2.1-dev.20260609134220 → 3.2.1
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.js +1 -1
- package/dist/index.mjs +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=class{cache=new Map;set(e,t){this.cache.set(e,t)}get(e){return this.cache.get(e)}has(e){return this.cache.has(e)}},t=class{set(e,t){}get(e){}has(e){return!1}},n=class{cache=new Map;constructor(e=3e5){this.ttlMs=e}set(e,t){this.cache.set(e,{value:t,expiresAt:Date.now()+this.ttlMs})}get(e){let t=this.cache.get(e);if(t){if(Date.now()>t.expiresAt){this.cache.delete(e);return}return t.value}}has(e){return this.get(e)!==void 0}},r=`\x1B[0m`,i=`\x1B[34m`,a=()=>typeof window<`u`,o=()=>typeof window>`u`,s=()=>a()&&window.self!==window.top;function c(e){if(!e)return``;let t=[];return e.w!==void 0&&t.push(`w=${e.w}`),e.h!==void 0&&t.push(`h=${e.h}`),e.q!==void 0&&t.push(`q=${e.q}`),e.f!==void 0&&t.push(`f=${e.f}`),e.download&&t.push(`download`),e.thumbnail&&t.push(`thumbnail`),t.join(`&`)}var l=`${i}[Localess:Client]${r}`;function u(e){e.debug&&console.log(l,`Client Options : `,e);let r=e.origin.replace(/\/+$/,``),i={redirect:`follow`,headers:{"Content-Type":`application/json`,Accept:`application/json`,"X-Localess-Agent":`Localess-JS-Client`,"X-Localess-Agent-Version":`0.9.0`}},a=typeof e.cacheTTL==`number`?e.cacheTTL*1e3:void 0,o=e.cacheTTL===!1?new t:new n(a);return{async getLinks(t){e.debug&&console.log(l,`getLinks() params : `,JSON.stringify(t));let n=``;t?.kind&&(n=`&kind=${t.kind}`);let a=``;t?.parentSlug&&(a=`&parentSlug=${t.parentSlug}`);let s=``;t?.excludeChildren&&(s=`&excludeChildren=${t.excludeChildren}`);let c=`${r}/api/v1/spaces/${e.spaceId}/links?token=${e.token}${n}${a}${s}`;if(e.debug&&console.log(l,`getLinks fetch url : `,c),o.has(c))return e.debug&&console.log(l,`getLinks cache hit`),o.get(c);try{let t=await fetch(c,i);e.debug&&console.log(l,`getLinks status : `,t.status);let n=await t.json();return o.set(c,n),n}catch(e){return console.error(l,`getLinks error : `,e),{}}},async getContentBySlug(t,n){e.debug&&(console.log(l,`getContentBySlug() slug : `,t),console.log(l,`getContentBySlug() params : `,JSON.stringify(n)));let a=``;e?.version&&e.version==`draft`&&(a=`&version=${e.version}`),n?.version&&n.version==`draft`&&(a=`&version=${n.version}`);let s=n?.locale?`&locale=${n.locale}`:``,c=n?.resolveReference?`&resolveReference=${n.resolveReference}`:``,u=n?.resolveLink?`&resolveLink=${n.resolveLink}`:``,d=`${r}/api/v1/spaces/${e.spaceId}/contents/slugs/${t}?token=${e.token}${a}${s}${c}${u}`;if(e.debug&&console.log(l,`getContentBySlug fetch url : `,d),o.has(d))return e.debug&&console.log(l,`getContentBySlug cache hit`),o.get(d);try{let t=await fetch(d,i);e.debug&&console.log(l,`getContentBySlug status : `,t.status);let n=await t.json();return o.set(d,n),n}catch(e){return console.error(l,`getContentBySlug error : `,e),{}}},async getContentById(t,n){e.debug&&(console.log(l,`getContentById() id : `,t),console.log(l,`getContentById() params : `,JSON.stringify(n)));let a=``;e?.version&&e.version==`draft`&&(a=`&version=${e.version}`),n?.version&&n.version==`draft`&&(a=`&version=${n.version}`);let s=n?.locale?`&locale=${n.locale}`:``,c=n?.resolveReference?`&resolveReference=${n.resolveReference}`:``,u=n?.resolveLink?`&resolveLink=${n.resolveLink}`:``,d=`${r}/api/v1/spaces/${e.spaceId}/contents/${t}?token=${e.token}${a}${s}${c}${u}`;if(e.debug&&console.log(l,`getContentById fetch url : `,d),o.has(d))return e.debug&&console.log(l,`getContentById cache hit`),o.get(d);try{let t=await fetch(d,i);e.debug&&console.log(l,`getContentById status : `,t.status);let n=await t.json();return o.set(d,n),n}catch(e){return console.error(l,`getContentById error : `,e),{}}},async getTranslations(t){e.debug&&console.log(l,`getTranslations() locale : `,t);let n=`${r}/api/v1/spaces/${e.spaceId}/translations/${t}?token=${e.token}`;if(e.debug&&console.log(l,`getTranslations fetch url : `,n),o.has(n))return e.debug&&console.log(l,`getTranslations cache hit`),o.get(n);try{let t=await fetch(n,i);e.debug&&console.log(l,`getTranslations status : `,t.status);let r=await t.json();return o.set(n,r),r}catch(e){return console.error(l,`getTranslations error : `,e),{}}},syncScriptUrl(){return`${r}/scripts/sync-v1.js`},assetLink(t,n){let i=typeof t==`string`?t:t.uri,a=`${r}/api/v1/spaces/${e.spaceId}/assets/${i}`,o=c(n);return o?`${a}?${o}`:a}}}function d(e){return{"data-ll-id":e._id,"data-ll-schema":e._schema}}function f(e){return{"data-ll-field":e}}var p=`localess-js-sync`;async function m(e,t=!1){return new Promise((t,n)=>{if(o()){
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=class{cache=new Map;set(e,t){this.cache.set(e,t)}get(e){return this.cache.get(e)}has(e){return this.cache.has(e)}},t=class{set(e,t){}get(e){}has(e){return!1}},n=class{cache=new Map;constructor(e=3e5){this.ttlMs=e}set(e,t){this.cache.set(e,{value:t,expiresAt:Date.now()+this.ttlMs})}get(e){let t=this.cache.get(e);if(t){if(Date.now()>t.expiresAt){this.cache.delete(e);return}return t.value}}has(e){return this.get(e)!==void 0}},r=`\x1B[0m`,i=`\x1B[34m`,a=()=>typeof window<`u`,o=()=>typeof window>`u`,s=()=>a()&&window.self!==window.top;function c(e){if(!e)return``;let t=[];return e.w!==void 0&&t.push(`w=${e.w}`),e.h!==void 0&&t.push(`h=${e.h}`),e.q!==void 0&&t.push(`q=${e.q}`),e.f!==void 0&&t.push(`f=${e.f}`),e.download&&t.push(`download`),e.thumbnail&&t.push(`thumbnail`),t.join(`&`)}var l=`${i}[Localess:Client]${r}`;function u(e){e.debug&&console.log(l,`Client Options : `,e);let r=e.origin.replace(/\/+$/,``),i={redirect:`follow`,headers:{"Content-Type":`application/json`,Accept:`application/json`,"X-Localess-Agent":`Localess-JS-Client`,"X-Localess-Agent-Version":`0.9.0`}},a=typeof e.cacheTTL==`number`?e.cacheTTL*1e3:void 0,o=e.cacheTTL===!1?new t:new n(a);return{async getLinks(t){e.debug&&console.log(l,`getLinks() params : `,JSON.stringify(t));let n=``;t?.kind&&(n=`&kind=${t.kind}`);let a=``;t?.parentSlug&&(a=`&parentSlug=${t.parentSlug}`);let s=``;t?.excludeChildren&&(s=`&excludeChildren=${t.excludeChildren}`);let c=`${r}/api/v1/spaces/${e.spaceId}/links?token=${e.token}${n}${a}${s}`;if(e.debug&&console.log(l,`getLinks fetch url : `,c),o.has(c))return e.debug&&console.log(l,`getLinks cache hit`),o.get(c);try{let t=await fetch(c,i);e.debug&&console.log(l,`getLinks status : `,t.status);let n=await t.json();return o.set(c,n),n}catch(e){return console.error(l,`getLinks error : `,e),{}}},async getContentBySlug(t,n){e.debug&&(console.log(l,`getContentBySlug() slug : `,t),console.log(l,`getContentBySlug() params : `,JSON.stringify(n)));let a=``;e?.version&&e.version==`draft`&&(a=`&version=${e.version}`),n?.version&&n.version==`draft`&&(a=`&version=${n.version}`);let s=n?.locale?`&locale=${n.locale}`:``,c=n?.resolveReference?`&resolveReference=${n.resolveReference}`:``,u=n?.resolveLink?`&resolveLink=${n.resolveLink}`:``,d=`${r}/api/v1/spaces/${e.spaceId}/contents/slugs/${t}?token=${e.token}${a}${s}${c}${u}`;if(e.debug&&console.log(l,`getContentBySlug fetch url : `,d),o.has(d))return e.debug&&console.log(l,`getContentBySlug cache hit`),o.get(d);try{let t=await fetch(d,i);e.debug&&console.log(l,`getContentBySlug status : `,t.status);let n=await t.json();return o.set(d,n),n}catch(e){return console.error(l,`getContentBySlug error : `,e),{}}},async getContentById(t,n){e.debug&&(console.log(l,`getContentById() id : `,t),console.log(l,`getContentById() params : `,JSON.stringify(n)));let a=``;e?.version&&e.version==`draft`&&(a=`&version=${e.version}`),n?.version&&n.version==`draft`&&(a=`&version=${n.version}`);let s=n?.locale?`&locale=${n.locale}`:``,c=n?.resolveReference?`&resolveReference=${n.resolveReference}`:``,u=n?.resolveLink?`&resolveLink=${n.resolveLink}`:``,d=`${r}/api/v1/spaces/${e.spaceId}/contents/${t}?token=${e.token}${a}${s}${c}${u}`;if(e.debug&&console.log(l,`getContentById fetch url : `,d),o.has(d))return e.debug&&console.log(l,`getContentById cache hit`),o.get(d);try{let t=await fetch(d,i);e.debug&&console.log(l,`getContentById status : `,t.status);let n=await t.json();return o.set(d,n),n}catch(e){return console.error(l,`getContentById error : `,e),{}}},async getTranslations(t){e.debug&&console.log(l,`getTranslations() locale : `,t);let n=`${r}/api/v1/spaces/${e.spaceId}/translations/${t}?token=${e.token}`;if(e.debug&&console.log(l,`getTranslations fetch url : `,n),o.has(n))return e.debug&&console.log(l,`getTranslations cache hit`),o.get(n);try{let t=await fetch(n,i);e.debug&&console.log(l,`getTranslations status : `,t.status);let r=await t.json();return o.set(n,r),r}catch(e){return console.error(l,`getTranslations error : `,e),{}}},syncScriptUrl(){return`${r}/scripts/sync-v1.js`},assetLink(t,n){let i=typeof t==`string`?t:t.uri,a=`${r}/api/v1/spaces/${e.spaceId}/assets/${i}`,o=c(n);return o?`${a}?${o}`:a}}}function d(e){return{"data-ll-id":e._id,"data-ll-schema":e._schema}}function f(e){return{"data-ll-field":e}}var p=`localess-js-sync`;async function m(e,t=!1){return new Promise((t,n)=>{if(o()){t();return}if(!s()){console.warn(`Localess Sync is loaded only in Visual Editor.`),t();return}if(window.localess!==void 0){t();return}if(document.getElementById(p)){t();return}let r=document.createElement(`script`);r.id=p,r.type=`text/javascript`,r.src=`${e}/scripts/sync-v1.js`,r.async=!0,r.onerror=e=>n(e),r.onload=e=>{console.info(`Localess Sync Script loaded`),t()},document.head.appendChild(r)})}exports.Cache=e,exports.NoCache=t,exports.TTLCache=n,exports.buildAssetQueryString=c,exports.isBrowser=a,exports.isIframe=s,exports.isServer=o,exports.loadLocalessSync=m,exports.localessClient=u,exports.localessEditable=d,exports.localessEditableField=f;
|
package/dist/index.mjs
CHANGED
|
@@ -149,19 +149,19 @@ var p = "localess-js-sync";
|
|
|
149
149
|
async function m(e, t = !1) {
|
|
150
150
|
return new Promise((t, n) => {
|
|
151
151
|
if (o()) {
|
|
152
|
-
|
|
152
|
+
t();
|
|
153
153
|
return;
|
|
154
154
|
}
|
|
155
155
|
if (!s()) {
|
|
156
|
-
console.warn("Localess Sync is loaded only in Visual Editor."),
|
|
156
|
+
console.warn("Localess Sync is loaded only in Visual Editor."), t();
|
|
157
157
|
return;
|
|
158
158
|
}
|
|
159
159
|
if (window.localess !== void 0) {
|
|
160
|
-
|
|
160
|
+
t();
|
|
161
161
|
return;
|
|
162
162
|
}
|
|
163
163
|
if (document.getElementById(p)) {
|
|
164
|
-
|
|
164
|
+
t();
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
167
|
let r = document.createElement("script");
|