@grapesjs/studio-sdk-plugins 1.0.2 → 1.0.3
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/dialogComponent/index.cjs.d.ts +3 -0
- package/dist/dialogComponent/index.cjs.js +59 -0
- package/dist/dialogComponent/index.d.ts +3 -0
- package/dist/dialogComponent/index.es.d.ts +3 -0
- package/dist/dialogComponent/index.es.js +350 -0
- package/dist/dialogComponent/index.umd.js +59 -0
- package/dist/index.cjs.d.ts +1 -2
- package/dist/index.cjs.js +59 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.es.d.ts +1 -2
- package/dist/index.es.js +317 -68
- package/dist/index.umd.js +59 -1
- package/package.json +1 -1
- package/dist/initPluginOne/index.cjs.d.ts +0 -2
- package/dist/initPluginOne/index.cjs.js +0 -1
- package/dist/initPluginOne/index.d.ts +0 -2
- package/dist/initPluginOne/index.es.d.ts +0 -2
- package/dist/initPluginOne/index.es.js +0 -89
- package/dist/initPluginOne/index.umd.js +0 -1
- package/dist/initPluginTwo/index.cjs.d.ts +0 -2
- package/dist/initPluginTwo/index.cjs.js +0 -1
- package/dist/initPluginTwo/index.d.ts +0 -2
- package/dist/initPluginTwo/index.es.d.ts +0 -2
- package/dist/initPluginTwo/index.es.js +0 -89
- package/dist/initPluginTwo/index.umd.js +0 -1
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import "react";
|
|
2
|
-
const r = "app.grapesjs.com", d = "app-stage.grapesjs.com", l = [
|
|
3
|
-
r,
|
|
4
|
-
d,
|
|
5
|
-
"localhost",
|
|
6
|
-
"127.0.0.1",
|
|
7
|
-
".local-credentialless.webcontainer.io",
|
|
8
|
-
// For stackblitz.com demos
|
|
9
|
-
"-sandpack.codesandbox.io"
|
|
10
|
-
// For Sandpack demos
|
|
11
|
-
], p = "license:check:start", h = "license:check:end", u = () => typeof window < "u", f = ({ isDev: n, isStage: t }) => `${n ? "" : `https://${t ? d : r}`}/api`, m = () => {
|
|
12
|
-
const n = u() && window.location.hostname;
|
|
13
|
-
return !!n && (l.includes(n) || l.some((t) => n.endsWith(t)));
|
|
14
|
-
}, E = () => (u() && window.location.hostname) === r;
|
|
15
|
-
var w = { NODE_ENV: "production", NPM_PACKAGE_VERSION: "1.0.2", STUDIO_NPM_PACKAGE_VERSION: "1.0.19-rc.1" };
|
|
16
|
-
const N = w.NODE_ENV !== "production";
|
|
17
|
-
async function _({
|
|
18
|
-
path: n,
|
|
19
|
-
method: t = "GET",
|
|
20
|
-
headers: e = {},
|
|
21
|
-
body: s
|
|
22
|
-
}) {
|
|
23
|
-
const c = `${f({ isDev: N, isStage: !E() })}${n}`, i = {
|
|
24
|
-
method: t,
|
|
25
|
-
headers: {
|
|
26
|
-
"Content-Type": "application/json",
|
|
27
|
-
...e
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
s && (i.body = JSON.stringify(s));
|
|
31
|
-
const a = await fetch(c, i);
|
|
32
|
-
if (!a.ok)
|
|
33
|
-
throw new Error(`HTTP error! status: ${a.status}`);
|
|
34
|
-
return a.json();
|
|
35
|
-
}
|
|
36
|
-
function g(n) {
|
|
37
|
-
const t = n;
|
|
38
|
-
return t.init = (e) => (s) => n(s, e), t;
|
|
39
|
-
}
|
|
40
|
-
const S = (n) => /* @__PURE__ */ g(n);
|
|
41
|
-
async function k({
|
|
42
|
-
editor: n,
|
|
43
|
-
pluginName: t,
|
|
44
|
-
licenseKey: e,
|
|
45
|
-
cleanup: s
|
|
46
|
-
}) {
|
|
47
|
-
let o = !1;
|
|
48
|
-
const c = m();
|
|
49
|
-
n.on(p, () => {
|
|
50
|
-
o = !0;
|
|
51
|
-
}), n.on(h, ({ sdkLicense: i }) => {
|
|
52
|
-
i || s();
|
|
53
|
-
}), setTimeout(async () => {
|
|
54
|
-
if (!o) {
|
|
55
|
-
if (c) return;
|
|
56
|
-
e && await T({ licenseKey: e, pluginName: t }) || s();
|
|
57
|
-
}
|
|
58
|
-
}, 2e3);
|
|
59
|
-
}
|
|
60
|
-
async function T({ licenseKey: n, pluginName: t }) {
|
|
61
|
-
try {
|
|
62
|
-
const e = await _({
|
|
63
|
-
path: `/sdk/${n}`,
|
|
64
|
-
method: "POST",
|
|
65
|
-
body: JSON.stringify({
|
|
66
|
-
d: window.location.hostname,
|
|
67
|
-
pn: t
|
|
68
|
-
})
|
|
69
|
-
}), { license: s } = e.result || {};
|
|
70
|
-
return !!s;
|
|
71
|
-
} catch (e) {
|
|
72
|
-
return console.error("Error during SDK license check:", e), !1;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
const y = "initPluginTwo", C = function(n, t = {}) {
|
|
76
|
-
const { Blocks: e } = n, { licenseKey: s } = t, o = "test-plugin-two";
|
|
77
|
-
e.add(o, {
|
|
78
|
-
label: o,
|
|
79
|
-
content: { type: o, components: `initPluginTwo, licenseKey: ${s}` }
|
|
80
|
-
}), k({
|
|
81
|
-
editor: n,
|
|
82
|
-
licenseKey: s,
|
|
83
|
-
pluginName: y,
|
|
84
|
-
cleanup: () => e.remove(o)
|
|
85
|
-
});
|
|
86
|
-
}, I = S(C);
|
|
87
|
-
export {
|
|
88
|
-
I as default
|
|
89
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(i,c){typeof exports=="object"&&typeof module<"u"?module.exports=c(require("react")):typeof define=="function"&&define.amd?define(["react"],c):(i=typeof globalThis<"u"?globalThis:i||self,i.StudioSdkPlugins_initPluginTwo=c())})(this,function(){"use strict";const i="app.grapesjs.com",c="app-stage.grapesjs.com",l=[i,c,"localhost","127.0.0.1",".local-credentialless.webcontainer.io","-sandpack.codesandbox.io"],p="license:check:start",f="license:check:end",u=()=>typeof window<"u",h=({isDev:n,isStage:e})=>`${n?"":`https://${e?c:i}`}/api`,m=()=>{const n=u()&&window.location.hostname;return!!n&&(l.includes(n)||l.some(e=>n.endsWith(e)))},w=()=>(u()&&window.location.hostname)===i;var E={NODE_ENV:"production",NPM_PACKAGE_VERSION:"1.0.2",STUDIO_NPM_PACKAGE_VERSION:"1.0.19-rc.1"};const g=E.NODE_ENV!=="production";async function N({path:n,method:e="GET",headers:t={},body:s}){const a=`${h({isDev:g,isStage:!w()})}${n}`,r={method:e,headers:{"Content-Type":"application/json",...t}};s&&(r.body=JSON.stringify(s));const d=await fetch(a,r);if(!d.ok)throw new Error(`HTTP error! status: ${d.status}`);return d.json()}function _(n){const e=n;return e.init=t=>s=>n(s,t),e}const S=n=>_(n);async function T({editor:n,pluginName:e,licenseKey:t,cleanup:s}){let o=!1;const a=m();n.on(p,()=>{o=!0}),n.on(f,({sdkLicense:r})=>{r||s()}),setTimeout(async()=>{if(!o){if(a)return;t&&await k({licenseKey:t,pluginName:e})||s()}},2e3)}async function k({licenseKey:n,pluginName:e}){try{const t=await N({path:`/sdk/${n}`,method:"POST",body:JSON.stringify({d:window.location.hostname,pn:e})}),{license:s}=t.result||{};return!!s}catch(t){return console.error("Error during SDK license check:",t),!1}}const y="initPluginTwo";return S(function(n,e={}){const{Blocks:t}=n,{licenseKey:s}=e,o="test-plugin-two";t.add(o,{label:o,content:{type:o,components:`initPluginTwo, licenseKey: ${s}`}}),T({editor:n,licenseKey:s,pluginName:y,cleanup:()=>t.remove(o)})})});
|