polotno 3.5.2 → 3.7.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/LICENSE.md +22 -7
- package/README.md +1 -1
- package/blueprint/toolbar/image-toolbar.d.ts +2 -2
- package/blueprint/toolbar/sketch.js +1 -1
- package/blueprint.polotno.css +116 -116
- package/canvas/apply-filters.d.ts +1 -1
- package/canvas/audio.js +1 -1
- package/canvas/context-menu/context-menu.d.ts +2 -2
- package/canvas/figure-element.js +1 -1
- package/canvas/gif-element.js +1 -1
- package/canvas/html-element.js +1 -1
- package/canvas/image-element.d.ts +11 -0
- package/canvas/image-element.js +1 -1
- package/canvas/page-controls.d.ts +1 -1
- package/canvas/page.js +1 -1
- package/canvas/render-tag-element.js +1 -1
- package/canvas/rich-editor.d.ts +0 -4
- package/canvas/rich-editor.js +2 -2
- package/canvas/rules.d.ts +1 -1
- package/canvas/text-element.js +1 -1
- package/canvas/tooltip.d.ts +2 -2
- package/canvas/use-mediabunny-video.js +1 -1
- package/canvas/video-element.js +1 -1
- package/hooks/use-event.js +1 -1
- package/icons/meronex.js +1 -1
- package/icons/registry.d.ts +1 -0
- package/icons/registry.js +1 -1
- package/model/audio-model.d.ts +2 -0
- package/model/audio-model.js +1 -1
- package/model/image-model.js +1 -1
- package/model/store.d.ts +3 -0
- package/model/store.js +1 -1
- package/package.json +30 -30
- package/pages-timeline/audio-track.d.ts +3 -2
- package/pages-timeline/audio-track.js +1 -1
- package/pages-timeline/audios.js +1 -1
- package/pages-timeline/current-time.js +1 -1
- package/pages-timeline/element-track.js +1 -1
- package/pages-timeline/index.d.ts +1 -1
- package/pages-timeline/index.js +1 -1
- package/pages-timeline/page-preview.js +1 -1
- package/pages-timeline/pages-timeline.js +1 -1
- package/pages-timeline/pages.js +1 -1
- package/pages-timeline/play-button.d.ts +1 -1
- package/pages-timeline/play-button.js +1 -1
- package/pages-timeline/time-ruler.js +1 -1
- package/pages-timeline/track-styles.d.ts +9 -0
- package/pages-timeline/track-styles.js +1 -1
- package/polotno.bundle.js +200 -201
- package/primitives/button-group.d.ts +2 -2
- package/primitives/button.d.ts +2 -2
- package/primitives/dialog.d.ts +2 -2
- package/primitives/dropdown-menu.d.ts +2 -2
- package/primitives/field-group.d.ts +1 -1
- package/primitives/field-row.d.ts +1 -1
- package/primitives/floating-control.js +2 -2
- package/primitives/index.d.ts +27 -27
- package/primitives/input-group.d.ts +2 -2
- package/primitives/input.d.ts +1 -1
- package/primitives/navbar.d.ts +5 -5
- package/primitives/numeric-input.d.ts +1 -1
- package/primitives/overflow-list.d.ts +1 -1
- package/primitives/panel-header.d.ts +1 -1
- package/primitives/popover.d.ts +2 -2
- package/primitives/portal-scope.d.ts +3 -3
- package/primitives/search-input.d.ts +1 -1
- package/primitives/select.d.ts +3 -3
- package/primitives/separator.d.ts +1 -1
- package/primitives/slider-field.d.ts +1 -1
- package/primitives/slider.d.ts +2 -2
- package/primitives/spinner.d.ts +1 -1
- package/primitives/switch.d.ts +1 -1
- package/primitives/tabs.d.ts +2 -2
- package/primitives/textarea.d.ts +1 -1
- package/primitives/toggle-group.d.ts +4 -4
- package/primitives/toggle.d.ts +3 -3
- package/primitives/tooltip-icon-button.d.ts +4 -4
- package/primitives/tooltip.d.ts +2 -2
- package/side-panel/background-panel.d.ts +2 -2
- package/side-panel/draw-panel.d.ts +2 -2
- package/side-panel/elements-panel.d.ts +2 -2
- package/side-panel/images-grid.js +1 -1
- package/side-panel/index.d.ts +35 -35
- package/side-panel/photos-panel.d.ts +1 -1
- package/side-panel/select-gif.d.ts +1 -1
- package/side-panel/side-panel.d.ts +5 -5
- package/side-panel/size-panel.d.ts +3 -3
- package/side-panel/tab-button.d.ts +1 -1
- package/side-panel/tab-button.js +2 -2
- package/side-panel/templates-panel.d.ts +2 -2
- package/side-panel/unsplash-credit.d.ts +1 -1
- package/side-panel/upload-panel.d.ts +3 -3
- package/side-panel/upload-panel.js +1 -1
- package/side-panel/videos-grid.js +1 -1
- package/themes/blueprint.css +1 -1
- package/themes/carbon.css +127 -128
- package/toolbar/download-button.d.ts +2 -2
- package/toolbar/element-container.d.ts +1 -1
- package/toolbar/filters-picker.d.ts +1 -1
- package/toolbar/group-toolbar.d.ts +2 -2
- package/toolbar/history-buttons.d.ts +1 -1
- package/toolbar/image-remove-background-button.d.ts +1 -1
- package/toolbar/image-toolbar.d.ts +1 -1
- package/toolbar/index.d.ts +34 -34
- package/toolbar/many-toolbar.d.ts +2 -2
- package/toolbar/opacity-picker.d.ts +1 -1
- package/toolbar/page-toolbar.d.ts +3 -3
- package/toolbar/toolbar.d.ts +3 -3
- package/toolbar/video-toolbar.js +1 -1
- package/toolbar/zoom-buttons.d.ts +1 -1
- package/ui-types.d.ts +8 -8
- package/ui.css +2 -2
- package/utils/array.js +1 -1
- package/utils/file.d.ts +3 -0
- package/utils/file.js +1 -1
- package/utils/html-to-svg/svg-builder.d.ts +1 -1
- package/utils/insert-file.d.ts +3 -2
- package/utils/insert-file.js +1 -1
- package/utils/l10n.d.ts +4 -0
- package/utils/l10n.js +1 -1
- package/utils/media.d.ts +6 -0
- package/utils/media.js +1 -0
- package/utils/pointer-drag.d.ts +13 -0
- package/utils/pointer-drag.js +1 -0
- package/utils/px.d.ts +2 -0
- package/utils/px.js +1 -1
- package/utils/text-format-state.js +1 -1
- package/utils/validate-key.js +1 -1
package/utils/px.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=this&&this.__rest||function(t,o){var e={};for(var r in t){Object.prototype.hasOwnProperty.call(t,r)&&o.indexOf(r)<0&&(e[r]=t[r])}if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var
|
|
1
|
+
var t=this&&this.__rest||function(t,o){var e={};for(var r in t){Object.prototype.hasOwnProperty.call(t,r)&&o.indexOf(r)<0&&(e[r]=t[r])}if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++){o.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(e[r[n]]=t[r[n]])}}return e};import{htmlInflatesMinContentWidth as o}from"./rich-text-html.js";export const roundEnabledPx=t=>t>0?Math.max(1,Math.round(t)):0;export const activeAnchorOf=t=>{var o,e;const r=null===(o=t.getStage())||void 0===o?void 0:o.findOne("Transformer");return null!==(e=null==r?void 0:r.getActiveAnchor())&&void 0!==e?e:""};export const isCornerAnchor=t=>!(t.includes("middle")||t.includes("center"));export const textMinResizeWidth=(t,o)=>t<o?1:o;export const textMinWidthIsMeasured=t=>{var e;return!!t.curveEnabled||(null!==(e=t.letterSpacing)&&void 0!==e?e:0)>0||o(t.text)};export const scaledBoxStyleAttrs=(t,o)=>{var e;return{cornerRadius:(null!==(e=t.cornerRadius)&&void 0!==e?e:0)*o,shadowBlur:t.shadowBlur*o,shadowOffsetX:t.shadowOffsetX*o,shadowOffsetY:t.shadowOffsetY*o}};export const roundedBoxStyleAttrs=t=>{var o;return{cornerRadius:roundEnabledPx(null!==(o=t.cornerRadius)&&void 0!==o?o:0),shadowBlur:Math.round(t.shadowBlur),shadowOffsetX:Math.round(t.shadowOffsetX),shadowOffsetY:Math.round(t.shadowOffsetY)}};export const scaledFontSizeAttrs=(t,o)=>{const e=t.fontSize>0?o/t.fontSize:1;return{fontSize:o,strokeWidth:t.strokeWidth*e,shadowBlur:t.shadowBlur*e,shadowOffsetX:t.shadowOffsetX*e,shadowOffsetY:t.shadowOffsetY*e}};export const roundedFontSizeAttrs=(t,o)=>{const e=scaledFontSizeAttrs(t,o);return{fontSize:Math.round(e.fontSize),strokeWidth:roundEnabledPx(e.strokeWidth),shadowBlur:Math.round(e.shadowBlur),shadowOffsetX:Math.round(e.shadowOffsetX),shadowOffsetY:Math.round(e.shadowOffsetY)}};export const roundedTextDecorationAttrs=o=>{const e=roundedFontSizeAttrs(o,o.fontSize),{fontSize:r}=e;return t(e,["fontSize"])};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as t from"react";import*as e from"mobx";import{parsePrimaryFontFamily as o,parseFontSizeToPx as n,toNumericWeight as i}from"@polotno/core/rich-text-html";import{isGradient as r}from"@polotno/core/gradient";import{getTextFormat as l,applyTextFormat as c,FORMAT_KEYS as a,DECORATION_TOKENS as s,decorationTokensOf as f,decorationTokensToString as u,decorationToQuillKey as d}from"./text-format.js";const m=e.observable({active:null},{},{deep:!1});export function getActiveTextEditor(){return m.active}export function setActiveTextEditor(t){e.runInAction(()=>{m.active=Object.assign(Object.assign({},t),{currentFormat:{},mixedFormats:{},lastSelection:null})})}export function updateActiveTextFormat(t,o,n){e.runInAction(()=>{m.active&&(m.active=Object.assign(Object.assign({},m.active),{currentFormat:t,mixedFormats:o,lastSelection:n||m.active.lastSelection}))})}export function clearActiveTextEditor(t){e.runInAction(()=>{var e;t&&(null===(e=m.active)||void 0===e?void 0:e.instance)!==t||(m.active=null)})}const p={fontSize:["size"],fontFamily:["font"],fill:["color","gradient"],fontWeight:["font-weight"],fontStyle:["italic"],textDecoration:["underline","strike"]};export const ALL_QUILL_MIXED_KEYS=Array.from(new Set(a.flatMap(t=>p[t])));function x(t,e,r){var l,c;switch(t){case"fontSize":return null!==(l=n(e.size,r.fontSize))&&void 0!==l?l:r.fontSize;case"fontFamily":return e.font&&o(String(e.font))||r.fontFamily;case"fill":return e.gradient||(null!==(c=e.color)&&void 0!==c?c:r.fill);case"fontWeight":return null!=e["font-weight"]?i(e["font-weight"]):i(r.fontWeight);case"fontStyle":return e.italic?"italic":r.fontStyle;case"textDecoration":return u(f(r.textDecoration))}}function v(t,e,o){const n=f(o.textDecoration),i=(o,i)=>n.has(o)?"on":e[i]?"mixed":t[i]?"on":"off",r=function(t,e){const o=t=>"on"===t?[!0]:"off"===t?[!1]:[!0,!1],n=[];for(const i of o(t)){for(const t of o(e)){const e=new Set;i&&e.add("underline"),t&&e.add("line-through"),n.push(u(e))}}return n}(i("underline","underline"),i("line-through","strike"));return{value:1===r.length?r[0]:void 0,mixed:r.length>1,values:r}}export function quillToTextFormat(t,e,o){const n={};for(const i of a){if("textDecoration"!==i){if(p[i].some(t=>!0===e[t])){n[i]={value:void 0,mixed:!0,values:[]}}else{const e=x(i,t,o);n[i]={value:e,mixed:!1,values:[e]}}}else{n.textDecoration=v(t,e,o)}}return n}export function attrsToQuillOps(t,e){var o;const n=[];if(void 0!==t.fontFamily&&n.push(["font",t.fontFamily]),void 0!==t.fontSize&&n.push(["size",`${t.fontSize}px`]),void 0!==t.fill&&(r(String(t.fill))?n.push(["color",!1],["gradient",t.fill]):n.push(["gradient",!1],["color",t.fill])),void 0!==t.fontWeight&&n.push(["font-weight",String(i(t.fontWeight))]),void 0!==t.fontStyle&&n.push(["italic","italic"===t.fontStyle]),void 0!==t.textDecoration){const i=null!==(o=null==e?void 0:e.decorationTokens)&&void 0!==o?o:s,r=f(t.textDecoration);for(const t of s){i.includes(t)&&n.push([d(t),r.has(t)])}}return n}function g(t){return((null==t?void 0:t.selectedElements)||[]).filter(t=>"text"===t.type)}function h(t){const e=getActiveTextEditor();return e&&e.instance&&e.store===t?e:null}export function resolveSelectionScope(t,e){const o=t.getSelection()||e||{index:0,length:0},n="function"==typeof t.getLength?t.getLength():0,i=n<=1;return o.length<=0?{scope:"collapsed",sel:o,isEmpty:i}:{scope:o.length>=n-1?"full":"partial",sel:o,isEmpty:i}}export function applyToLiveEditor(t,e,o,n){const i=attrsToQuillOps(e,n);if(!i.length){return}const{scope:r,sel:l}=resolveSelectionScope(t,null!=o?o:null);for(const[c,a]of i){"collapsed"===r?t.format(c,a,"user"):t.formatText(l.index,l.length,c,a,"user")}}function S(t,e){const o="function"==typeof t.getLength?t.getLength():0;t.formatText(0,o,e,!0,"api")}export function getTextFormatState(t){const e=h(t),o=g(t),n=!!e||o.length>0;var i;return{format:e?quillToTextFormat(e.currentFormat||{},e.mixedFormats||{},{fontSize:(i=e.element).fontSize,fontFamily:i.fontFamily,fill:i.fill,fontWeight:i.fontWeight,fontStyle:i.fontStyle,textDecoration:i.textDecoration}):l(o),enabled:n,applyTextFormat:(e,o)=>function(t,e,o){const n=h(t);if(!n){return void c(g(t),e,o)}const{scope:i,sel:r,isEmpty:l}=resolveSelectionScope(n.instance,n.lastSelection);"full"===i||"collapsed"===i&&!l?c([n.element],e,o):function(t,e,o,n){var i,r;const l=t.instance,c=t.element;let a=!1;if(n.length>0){if(void 0!==e.fontStyle&&"italic"!==e.fontStyle&&"italic"===c.fontStyle&&(S(l,"italic"),c.set({fontStyle:"normal"}),a=!0),void 0!==e.textDecoration){const t=null!==(i=null==o?void 0:o.decorationTokens)&&void 0!==i?i:s,n=f(e.textDecoration),r=f(c.textDecoration),m=t.filter(t=>!n.has(t)&&r.has(t));for(const e of m){S(l,d(e)),r.delete(e)}m.length&&(c.set({textDecoration:u(r)}),a=!0)}a&&"function"==typeof(null===(r=l.history)||void 0===r?void 0:r.clear)&&l.history.clear()}applyToLiveEditor(l,e,n,o)}(n,e,o,r)}(t,e,o)}}export function observeTextFormatState(t,o){return e.reaction(()=>getTextFormatState(t),t=>o(t),{fireImmediately:!0})}export function useTextFormat(e){const[o,n]=t.useState(()=>getTextFormatState(e));return t.useEffect(()=>observeTextFormatState(e,n),[e]),o}
|
|
1
|
+
import*as t from"react";import*as e from"mobx";import{parsePrimaryFontFamily as o,parseFontSizeToPx as n,toNumericWeight as i}from"@polotno/core/rich-text-html";import{isGradient as r}from"@polotno/core/gradient";import{getTextFormat as l,applyTextFormat as c,FORMAT_KEYS as a,DECORATION_TOKENS as s,decorationTokensOf as f,decorationTokensToString as u,decorationToQuillKey as d}from"./text-format.js";const m=e.observable({active:null},{},{deep:!1});export function getActiveTextEditor(){return m.active}export function setActiveTextEditor(t){e.runInAction(()=>{m.active=Object.assign(Object.assign({},t),{currentFormat:{},mixedFormats:{},lastSelection:null})})}export function updateActiveTextFormat(t,o,n){e.runInAction(()=>{m.active&&(m.active=Object.assign(Object.assign({},m.active),{currentFormat:t,mixedFormats:o,lastSelection:n||m.active.lastSelection}))})}export function clearActiveTextEditor(t){e.runInAction(()=>{var e;t&&(null===(e=m.active)||void 0===e?void 0:e.instance)!==t||(m.active=null)})}const p={fontSize:["size"],fontFamily:["font"],fill:["color","gradient"],fontWeight:["font-weight"],fontStyle:["italic"],textDecoration:["underline","strike"]};export const ALL_QUILL_MIXED_KEYS=Array.from(new Set(a.flatMap(t=>p[t])));function x(t,e,r){var l,c;switch(t){case"fontSize":return null!==(l=n(e.size,r.fontSize))&&void 0!==l?l:r.fontSize;case"fontFamily":return e.font&&o(String(e.font))||r.fontFamily;case"fill":return e.gradient||(null!==(c=e.color)&&void 0!==c?c:r.fill);case"fontWeight":return null!=e["font-weight"]?i(e["font-weight"]):i(r.fontWeight);case"fontStyle":return e.italic?"italic":r.fontStyle;case"textDecoration":return u(f(r.textDecoration))}}function v(t,e,o){const n=f(o.textDecoration),i=(o,i)=>n.has(o)?"on":e[i]?"mixed":t[i]?"on":"off",r=function(t,e){const o=t=>"on"===t?[!0]:"off"===t?[!1]:[!0,!1],n=[];for(const i of o(t)){for(const t of o(e)){const e=new Set;i&&e.add("underline"),t&&e.add("line-through"),n.push(u(e))}}return n}(i("underline","underline"),i("line-through","strike"));return{value:1===r.length?r[0]:void 0,mixed:r.length>1,values:r}}export function quillToTextFormat(t,e,o){const n={};for(const i of a){if("textDecoration"!==i){if(p[i].some(t=>!0===e[t])){n[i]={value:void 0,mixed:!0,values:[]}}else{const e=x(i,t,o);n[i]={value:e,mixed:!1,values:[e]}}}else{n.textDecoration=v(t,e,o)}}return n}export function attrsToQuillOps(t,e){var o;const n=[];if(void 0!==t.fontFamily&&n.push(["font",t.fontFamily]),void 0!==t.fontSize&&n.push(["size",`${t.fontSize}px`]),void 0!==t.fill&&(r(String(t.fill))?n.push(["color",!1],["gradient",t.fill]):n.push(["gradient",!1],["color",t.fill])),void 0!==t.fontWeight&&n.push(["font-weight",String(i(t.fontWeight))]),void 0!==t.fontStyle&&n.push(["italic","italic"===t.fontStyle]),void 0!==t.textDecoration){const i=null!==(o=null==e?void 0:e.decorationTokens)&&void 0!==o?o:s,r=f(t.textDecoration);for(const t of s){i.includes(t)&&n.push([d(t),r.has(t)])}}return n}function g(t){return((null==t?void 0:t.selectedElements)||[]).filter(t=>"text"===t.type)}function h(t){const e=getActiveTextEditor();return e&&e.instance&&e.store===t?e:null}export function resolveSelectionScope(t,e){const o=t.getSelection()||e||{index:0,length:0},n="function"==typeof t.getLength?t.getLength():0,i=n<=1;return o.length<=0?{scope:"collapsed",sel:o,isEmpty:i}:{scope:o.length>=n-1?"full":"partial",sel:o,isEmpty:i}}export function applyToLiveEditor(t,e,o,n){const i=attrsToQuillOps(e,n);if(!i.length){return}const{scope:r,sel:l}=resolveSelectionScope(t,null!=o?o:null);for(const[c,a]of i){"collapsed"===r?t.format(c,a,"user"):t.formatText(l.index,l.length,c,a,"user")}"collapsed"===r&&updateActiveTextFormat(t.getFormat(l.index,0),{},l)}function S(t,e){const o="function"==typeof t.getLength?t.getLength():0;t.formatText(0,o,e,!0,"api")}export function getTextFormatState(t){const e=h(t),o=g(t),n=!!e||o.length>0;var i;return{format:e?quillToTextFormat(e.currentFormat||{},e.mixedFormats||{},{fontSize:(i=e.element).fontSize,fontFamily:i.fontFamily,fill:i.fill,fontWeight:i.fontWeight,fontStyle:i.fontStyle,textDecoration:i.textDecoration}):l(o),enabled:n,applyTextFormat:(e,o)=>function(t,e,o){const n=h(t);if(!n){return void c(g(t),e,o)}const{scope:i,sel:r,isEmpty:l}=resolveSelectionScope(n.instance,n.lastSelection);"full"===i||"collapsed"===i&&!l?c([n.element],e,o):function(t,e,o,n){var i,r;const l=t.instance,c=t.element;let a=!1;if(n.length>0){if(void 0!==e.fontStyle&&"italic"!==e.fontStyle&&"italic"===c.fontStyle&&(S(l,"italic"),c.set({fontStyle:"normal"}),a=!0),void 0!==e.textDecoration){const t=null!==(i=null==o?void 0:o.decorationTokens)&&void 0!==i?i:s,n=f(e.textDecoration),r=f(c.textDecoration),m=t.filter(t=>!n.has(t)&&r.has(t));for(const e of m){S(l,d(e)),r.delete(e)}m.length&&(c.set({textDecoration:u(r)}),a=!0)}a&&"function"==typeof(null===(r=l.history)||void 0===r?void 0:r.clear)&&l.history.clear()}applyToLiveEditor(l,e,n,o)}(n,e,o,r)}(t,e,o)}}export function observeTextFormatState(t,o){return e.reaction(()=>getTextFormatState(t),t=>o(t),{fireImmediately:!0})}export function useTextFormat(e){const[o,n]=t.useState(()=>getTextFormatState(e));return t.useEffect(()=>observeTextFormatState(e,n),[e]),o}
|
package/utils/validate-key.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"mobx";import{getAPI as o}from"./api.js";import{setRemoveBackgroundEnabled as t}from"./flags.js";const n=e.observable({value:!1}),a=e.observable({value:"v1"});export const ___=()=>a.value;const i=e.observable({value:0});export const ____=()=>i.value;export const isCreditVisible=()=>n.value;const r=e.action(()=>{n.value=!0});let s="";export const getKey=()=>s||"";export const setKey=e=>{s=e||""};let l="undefined"!=typeof window?window.location.origin:"";const c="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Headless")>-1,d="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Electron")>-1;"file://"===l&&c&&(l="headless"),"file://"===l&&d&&(l="electron");const p=`%cPolotno error! Current domain is not allowed. It may lead to unexpected behavior and stop working. Please add "${l}" here: https://polotno.com/cabinet`;let u=fetch;export const __=e=>{u=e};export async function isKeyPaid(n){for(let s=0;s<5;s++){try{const r=await u(o()+"/validate-key",{method:"POST",body:JSON.stringify({key:n,site:location.host,skdVersion:"3.
|
|
1
|
+
import*as e from"mobx";import{getAPI as o}from"./api.js";import{setRemoveBackgroundEnabled as t}from"./flags.js";const n=e.observable({value:!1}),a=e.observable({value:"v1"});export const ___=()=>a.value;const i=e.observable({value:0});export const ____=()=>i.value;export const isCreditVisible=()=>n.value;const r=e.action(()=>{n.value=!0});let s="";export const getKey=()=>s||"";export const setKey=e=>{s=e||""};let l="undefined"!=typeof window?window.location.origin:"";const c="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Headless")>-1,d="undefined"!=typeof navigator&&navigator.userAgent.indexOf("Electron")>-1;"file://"===l&&c&&(l="headless"),"file://"===l&&d&&(l="electron");const p=`%cPolotno error! Current domain is not allowed. It may lead to unexpected behavior and stop working. Please add "${l}" here: https://polotno.com/cabinet`;let u=fetch;export const __=e=>{u=e};export async function isKeyPaid(n){for(let s=0;s<5;s++){try{const r=await u(o()+"/validate-key",{method:"POST",body:JSON.stringify({key:n,site:location.host,skdVersion:"3.7.0"})});if(e.runInAction(()=>{a.value=r.headers.get("x-api-version")||""}),!n){return console.error("Polotno API is initialized without API key. It may lead to unexpected behavior and stop working. Please create API key here: https://polotno.com/cabinet"),e.runInAction(()=>{i.value=1}),!1}if(200!==r.status){await new Promise(e=>setTimeout(e,3e3));continue}const s=await r.json();return s.is_valid||(console.error("Polotno API key is not valid. Please get new API key here: https://polotno.com/cabinet"),e.runInAction(()=>{i.value=1})),s.is_paid||(console.log("%cPolotno Free Version. For development usage only. https://polotno.com/","background: rgb(0, 161, 255); color: white; padding: 5px; margin: 5px;"),e.runInAction(()=>{0===i.value&&(i.value=2)})),s.is_domain_valid||console.log(p,"background: rgba(247, 101, 68, 1); color: white; padding: 5px; margin: 5px;"),t(s.remove_background_enabled),s.is_paid||!1}catch(r){await new Promise(e=>setTimeout(e,3e3))}}return console.error("Can not validate Polotno API key. Please report to anton@polotno.com immediately."),!0}export async function validateKey(e){await isKeyPaid(s)&&!e||r()}
|