hart-estate-widget 4.8.21 → 4.8.22

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 CHANGED
@@ -381,19 +381,10 @@ Here you can see a list of accessible options and examples of usage. There are a
381
381
 
382
382
  // Use comma decimal separator in meters
383
383
  "isMetersUseComma": false,
384
- // Meters area template, example: "{area} m²"
385
- "metersAreaTemplate": "{area} m²",
386
384
  // Meters area fixed precision, example: 1 -> 0.2 ; 2 -> 0.25 ...
387
385
  "metersAreaPrecision": 1,
388
- // Meters size template, example: "{width} x {length} m"
389
- "metersSizeTemplate": "{width} x {length} m",
390
386
  // Meters size fixed precision, example: 1 -> 0.2 ; 2 -> 0.25 ...
391
387
  "metersSizePrecision": 1,
392
-
393
- // Feet area template, example: "{area}"
394
- "feetAreaTemplate": "{area}",
395
- // Feet size template, example: "{width} x {length}"
396
- "feetSizeTemplate": "{width} x {length}"
397
388
  },
398
389
 
399
390
  // Ruler info settings
@@ -413,11 +404,9 @@ Here you can see a list of accessible options and examples of usage. There are a
413
404
  "hoverColor": "#fffa",
414
405
  "feetsPositionY": 100,
415
406
  "feetsPrecision": 2,
416
- "feetsFormat": "$0 ft",
417
407
  "useFeetsComma": true,
418
408
  "metersPositionY": 50,
419
- "metersPrecision": 2,
420
- "metersFormat": "$0 m",
409
+ "metersPrecision": 2
421
410
  },
422
411
 
423
412
  // MultiFloorMap settings
@@ -625,6 +614,13 @@ Here you can see a list of accessible options and examples of usage. There are a
625
614
  "feets": "Feets",
626
615
  "meters": "Meters",
627
616
 
617
+ "metersAreaTemplate": "$0 m²",
618
+ "metersSizeTemplate": "$0 x $1 m",
619
+ "feetAreaTemplate": "$0",
620
+ "feetSizeTemplate": "$0 x $1",
621
+ "metersFormat": "$0 m",
622
+ "feetsFormat": "$0 ft",
623
+
628
624
  "made-by-template": "$0 $1",
629
625
  "made-by-prefix": "made by",
630
626
  "made-by-link": "https://getfloorplan.com/",
package/build/api.js CHANGED
@@ -1 +1 @@
1
- var t={134:(t,e,n)=>{n.d(e,{A:()=>r});const r={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)}},180:(t,e,n)=>{let r;n.d(e,{A:()=>i});const a=new Uint8Array(16);function i(){if(!r){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");r=crypto.getRandomValues.bind(crypto)}return r(a)}},255:(t,e,n)=>{n.d(e,{A:()=>s});var r=n(134),a=n(180),i=n(296);const s=function(t,e,n){return!r.A.randomUUID||e||t?function(t,e,n){const r=(t=t||{}).random??t.rng?.()??(0,a.A)();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){if((n=n||0)<0||n+16>e.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let t=0;t<16;++t)e[n+t]=r[t];return e}return(0,i.k)(r)}(t,e,n):r.A.randomUUID()}},296:(t,e,n)=>{n.d(e,{k:()=>a});const r=[];for(let t=0;t<256;++t)r.push((t+256).toString(16).slice(1));function a(t,e=0){return(r[t[e+0]]+r[t[e+1]]+r[t[e+2]]+r[t[e+3]]+"-"+r[t[e+4]]+r[t[e+5]]+"-"+r[t[e+6]]+r[t[e+7]]+"-"+r[t[e+8]]+r[t[e+9]]+"-"+r[t[e+10]]+r[t[e+11]]+r[t[e+12]]+r[t[e+13]]+r[t[e+14]]+r[t[e+15]]).toLowerCase()}}},e={};function n(r){var a=e[r];if(void 0!==a)return a.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var r={};n.d(r,{j:()=>i});var a=n(255);class i{backendUrl="";bestRoute;fallbackConfig;needCache;needBranding=!0;constructor(t,e,n){this.backendUrl=t.endsWith("/")?t.slice(0,t.length-1):t,this.bestRoute=e,this.fallbackConfig=n,this.needCache=!(!n||!e)}get headers(){return{Accept:"application/json;widget-version=4.8.21"}}get entropySuffix(){return this.bestRoute?.entropy?`?entropy=${(0,a.A)()}`:""}loadCrmWidgetData=async t=>{if(!t)return this.makeError(404,"No crmPlanId!");if(this.bestRoute&&this.fallbackConfig)try{const e=await this.fetchCdn(`/widgets/crm/${t}/v4/plan.json${this.entropySuffix}`);if(e.ok){const n=await e.json();return this.proceedCrmJson(n,t)}}catch{}try{const e=await this.fetchBackend(`/api/crm/plans/${t}/v4/widget?cache=${this.needCache?1:0}`);if(e.ok){const n=await e.json();return this.proceedCrmJson(n,t)}return this.makeErrorFromResponse(e,"Failed to get CRM Plan widget data!")}catch(t){return this.makeError(520,t.message)}};loadWidgetData=async t=>{if(!t)return this.makeError(404,"No planId!");if(this.bestRoute&&this.fallbackConfig)try{const e=await this.fetchCdn(`/widgets/services/${t}/v4/plan.json${this.entropySuffix}`);if(e.ok){const n=await e.json();return this.proceedServiceJson(n,t)}}catch{}try{const e=await this.fetchBackend(`/api/plans/${t}/v4/widget?cache=${this.needCache?1:0}`);if(e.ok){const n=await e.json();return this.proceedServiceJson(n,t)}return this.makeErrorFromResponse(e,"Failed to get Plan widget data!")}catch(t){return this.makeError(520,t.message)}};proceedCrmJson(t,e){return this.proceedJson({...t,is_crm:!0,crm_plan_id:e})}proceedServiceJson(t,e){return this.proceedJson({...t,is_crm:!1,plan_id:e})}async proceedJson(t){return await this.replaceCdnUrls(t),await this.proceedBranding(t),t}async replaceCdnUrls(t){const{bestRoute:e,fallbackConfig:n}=this;if(!e||!n)return t;const r=t=>{if(!t)return"";const r=(t=>{const e=n.keyExtraction?.patterns??[];for(let n=0,r=e.length;n<r;n++){const r=t.match(e[n].re);if(null!=r)return r[1]}return""})(t);return r?e.template.replace(/\{key\}/,r):t??""};t.variants.forEach((t=>{t.assets_path=r(t.assets_path),t.json=r(t.json),t.floors.forEach((t=>{t.original_plan_img=r(t.original_plan_img),t.miniplan_img=r(t.miniplan_img)}))}))}async proceedBranding(t){if(!this.needBranding)return t;const{primary_widget_branding_id:e}=t;if(null!=e){try{const n=await this.fetchCdn(`/widgets/brandings/id/${e}/branding.json${this.entropySuffix}`);n.ok&&(t.widget_branding=await n.json())}catch{}if(null==t.widget_branding)try{const n=await this.fetchBackend(`/api/plans/widget_branding/${e}`);n.ok&&(t.widget_branding=await n.json())}catch{}}if(null==t.widget_branding){const e=window.location.hostname;try{const n=await this.fetchCdn(`/widgets/brandings/domain/${e}/branding.json${this.entropySuffix}`);n.ok&&(t.widget_branding=await n.json())}catch{}if(null==t.widget_branding)try{const e=await this.fetchBackend("/api/plans/widget_branding");e.ok&&(t.widget_branding=await e.json())}catch{}}}fetchCdn=(t,e={headers:this.headers})=>{let n=this.bestRoute?this.bestRoute.template.replace(/\{key\}/,""):"";return n.endsWith("/")&&(n=n.slice(0,n.length-1)),fetch(`${n}${t}`,e)};fetchBackend=(t,e={headers:this.headers})=>fetch(`${this.backendUrl}${t}`,e);makeError(t,e="Unknown error"){return{error:{status:t,message:e}}}async makeErrorFromResponse(t,e){if("application/json"===t.headers.get("Content-Type")){const e=await t.json();if("message"in e&&"string"==typeof e.message)return this.makeError(t.status,e.message)}return this.makeError(t.status,e)}}const s=r.j;export{s as Api};
1
+ var t={134:(t,e,n)=>{n.d(e,{A:()=>r});const r={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)}},180:(t,e,n)=>{let r;n.d(e,{A:()=>i});const a=new Uint8Array(16);function i(){if(!r){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");r=crypto.getRandomValues.bind(crypto)}return r(a)}},255:(t,e,n)=>{n.d(e,{A:()=>s});var r=n(134),a=n(180),i=n(296);const s=function(t,e,n){return!r.A.randomUUID||e||t?function(t,e,n){const r=(t=t||{}).random??t.rng?.()??(0,a.A)();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){if((n=n||0)<0||n+16>e.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let t=0;t<16;++t)e[n+t]=r[t];return e}return(0,i.k)(r)}(t,e,n):r.A.randomUUID()}},296:(t,e,n)=>{n.d(e,{k:()=>a});const r=[];for(let t=0;t<256;++t)r.push((t+256).toString(16).slice(1));function a(t,e=0){return(r[t[e+0]]+r[t[e+1]]+r[t[e+2]]+r[t[e+3]]+"-"+r[t[e+4]]+r[t[e+5]]+"-"+r[t[e+6]]+r[t[e+7]]+"-"+r[t[e+8]]+r[t[e+9]]+"-"+r[t[e+10]]+r[t[e+11]]+r[t[e+12]]+r[t[e+13]]+r[t[e+14]]+r[t[e+15]]).toLowerCase()}}},e={};function n(r){var a=e[r];if(void 0!==a)return a.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var r={};n.d(r,{j:()=>i});var a=n(255);class i{backendUrl="";bestRoute;fallbackConfig;needCache;needBranding=!0;constructor(t,e,n){this.backendUrl=t.endsWith("/")?t.slice(0,t.length-1):t,this.bestRoute=e,this.fallbackConfig=n,this.needCache=!(!n||!e)}get headers(){return{Accept:"application/json;widget-version=4.8.22"}}get entropySuffix(){return this.bestRoute?.entropy?`?entropy=${(0,a.A)()}`:""}loadCrmWidgetData=async t=>{if(!t)return this.makeError(404,"No crmPlanId!");if(this.bestRoute&&this.fallbackConfig)try{const e=await this.fetchCdn(`/widgets/crm/${t}/v4/plan.json${this.entropySuffix}`);if(e.ok){const n=await e.json();return this.proceedCrmJson(n,t)}}catch{}try{const e=await this.fetchBackend(`/api/crm/plans/${t}/v4/widget?cache=${this.needCache?1:0}`);if(e.ok){const n=await e.json();return this.proceedCrmJson(n,t)}return this.makeErrorFromResponse(e,"Failed to get CRM Plan widget data!")}catch(t){return this.makeError(520,t.message)}};loadWidgetData=async t=>{if(!t)return this.makeError(404,"No planId!");if(this.bestRoute&&this.fallbackConfig)try{const e=await this.fetchCdn(`/widgets/services/${t}/v4/plan.json${this.entropySuffix}`);if(e.ok){const n=await e.json();return this.proceedServiceJson(n,t)}}catch{}try{const e=await this.fetchBackend(`/api/plans/${t}/v4/widget?cache=${this.needCache?1:0}`);if(e.ok){const n=await e.json();return this.proceedServiceJson(n,t)}return this.makeErrorFromResponse(e,"Failed to get Plan widget data!")}catch(t){return this.makeError(520,t.message)}};proceedCrmJson(t,e){return this.proceedJson({...t,is_crm:!0,crm_plan_id:e})}proceedServiceJson(t,e){return this.proceedJson({...t,is_crm:!1,plan_id:e})}async proceedJson(t){return await this.replaceCdnUrls(t),await this.proceedBranding(t),t}async replaceCdnUrls(t){const{bestRoute:e,fallbackConfig:n}=this;if(!e||!n)return t;const r=t=>{if(!t)return"";const r=(t=>{const e=n.keyExtraction?.patterns??[];for(let n=0,r=e.length;n<r;n++){const r=t.match(e[n].re);if(null!=r)return r[1]}return""})(t);return r?e.template.replace(/\{key\}/,r):t??""};t.variants.forEach((t=>{t.assets_path=r(t.assets_path),t.json=r(t.json),t.floors.forEach((t=>{t.original_plan_img=r(t.original_plan_img),t.miniplan_img=r(t.miniplan_img)}))}))}async proceedBranding(t){if(!this.needBranding)return t;const{primary_widget_branding_id:e}=t;if(null!=e){try{const n=await this.fetchCdn(`/widgets/brandings/id/${e}/branding.json${this.entropySuffix}`);n.ok&&(t.widget_branding=await n.json())}catch{}if(null==t.widget_branding)try{const n=await this.fetchBackend(`/api/plans/widget_branding/${e}`);n.ok&&(t.widget_branding=await n.json())}catch{}}if(null==t.widget_branding){const e=window.location.hostname;try{const n=await this.fetchCdn(`/widgets/brandings/domain/${e}/branding.json${this.entropySuffix}`);n.ok&&(t.widget_branding=await n.json())}catch{}if(null==t.widget_branding)try{const e=await this.fetchBackend("/api/plans/widget_branding");e.ok&&(t.widget_branding=await e.json())}catch{}}}fetchCdn=(t,e={headers:this.headers})=>{let n=this.bestRoute?this.bestRoute.template.replace(/\{key\}/,""):"";return n.endsWith("/")&&(n=n.slice(0,n.length-1)),fetch(`${n}${t}`,e)};fetchBackend=(t,e={headers:this.headers})=>fetch(`${this.backendUrl}${t}`,e);makeError(t,e="Unknown error"){return{error:{status:t,message:e}}}async makeErrorFromResponse(t,e){if("application/json"===t.headers.get("Content-Type")){const e=await t.json();if("message"in e&&"string"==typeof e.message)return this.makeError(t.status,e.message)}return this.makeError(t.status,e)}}const s=r.j;export{s as Api};