@grapesjs/studio-sdk-plugins 1.0.2-rc.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/api.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export declare function api({ path, method, headers, body }: {
2
+ path: string;
3
+ method: RequestInit['method'];
4
+ headers?: RequestInit['headers'];
5
+ body?: RequestInit['body'];
6
+ }): Promise<Record<string, any>>;
@@ -0,0 +1,2 @@
1
+ export { default as initPluginOne } from './initPluginOne';
2
+ export { default as initPluginTwo } from './initPluginTwo';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react");const r="app.grapesjs.com",u="app-stage.grapesjs.com",l=[r,u,"localhost","127.0.0.1",".local-credentialless.webcontainer.io","-sandpack.codesandbox.io"],m="license:check:start",f="license:check:end",d=()=>typeof window<"u",g=({isDev:n,isStage:o})=>`${n?"":`https://${o?u:r}`}/api`,E=()=>{const n=d()&&window.location.hostname;return!!n&&(l.includes(n)||l.some(o=>n.endsWith(o)))},N=()=>(d()&&window.location.hostname)===r;var w={NODE_ENV:"production",NPM_PACKAGE_VERSION:"1.0.2-rc.0",STUDIO_NPM_PACKAGE_VERSION:"1.0.19-rc.1"};const _=w.NODE_ENV!=="production";async function y({path:n,method:o="GET",headers:t={},body:e}){const c=`${g({isDev:_,isStage:!N()})}${n}`,i={method:o,headers:{"Content-Type":"application/json",...t}};e&&(i.body=JSON.stringify(e));const a=await fetch(c,i);if(!a.ok)throw new Error(`HTTP error! status: ${a.status}`);return a.json()}function P(n){const o=n;return o.init=t=>e=>n(e,t),o}const p=n=>P(n);async function h({editor:n,pluginName:o,licenseKey:t,cleanup:e}){let s=!1;const c=E();n.on(m,()=>{s=!0}),n.on(f,({sdkLicense:i})=>{i||e()}),setTimeout(async()=>{if(!s){if(c)return;t&&await S({licenseKey:t,pluginName:o})||e()}},2e3)}async function S({licenseKey:n,pluginName:o}){try{const t=await y({path:`/sdk/${n}`,method:"POST",body:JSON.stringify({d:window.location.hostname,pn:o})}),{license:e}=t.result||{};return!!e}catch(t){return console.error("Error during SDK license check:",t),!1}}const O="initPluginOne",T=function(n,o={}){const{Blocks:t}=n,{licenseKey:e}=o,s="test-plugin-one";t.add(s,{label:s,content:{type:s,components:`initPluginOne, licenseKey: ${e}`}}),h({editor:n,licenseKey:e,pluginName:O,cleanup:()=>t.remove(s)})},k=p(T),I="initPluginTwo",b=function(n,o={}){const{Blocks:t}=n,{licenseKey:e}=o,s="test-plugin-two";t.add(s,{label:s,content:{type:s,components:`initPluginTwo, licenseKey: ${e}`}}),h({editor:n,licenseKey:e,pluginName:I,cleanup:()=>t.remove(s)})},C=p(b);exports.initPluginOne=k;exports.initPluginTwo=C;
@@ -0,0 +1,2 @@
1
+ export { default as initPluginOne } from './initPluginOne';
2
+ export { default as initPluginTwo } from './initPluginTwo';
@@ -0,0 +1,2 @@
1
+ export { default as initPluginOne } from './initPluginOne';
2
+ export { default as initPluginTwo } from './initPluginTwo';
@@ -0,0 +1,101 @@
1
+ import "react";
2
+ const r = "app.grapesjs.com", u = "app-stage.grapesjs.com", l = [
3
+ r,
4
+ u,
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
+ ], m = "license:check:start", f = "license:check:end", d = () => typeof window < "u", g = ({ isDev: n, isStage: o }) => `${n ? "" : `https://${o ? u : r}`}/api`, E = () => {
12
+ const n = d() && window.location.hostname;
13
+ return !!n && (l.includes(n) || l.some((o) => n.endsWith(o)));
14
+ }, N = () => (d() && window.location.hostname) === r;
15
+ var w = { NODE_ENV: "production", NPM_PACKAGE_VERSION: "1.0.2-rc.0", STUDIO_NPM_PACKAGE_VERSION: "1.0.19-rc.1" };
16
+ const _ = w.NODE_ENV !== "production";
17
+ async function P({
18
+ path: n,
19
+ method: o = "GET",
20
+ headers: t = {},
21
+ body: e
22
+ }) {
23
+ const c = `${g({ isDev: _, isStage: !N() })}${n}`, i = {
24
+ method: o,
25
+ headers: {
26
+ "Content-Type": "application/json",
27
+ ...t
28
+ }
29
+ };
30
+ e && (i.body = JSON.stringify(e));
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 y(n) {
37
+ const o = n;
38
+ return o.init = (t) => (e) => n(e, t), o;
39
+ }
40
+ const p = (n) => /* @__PURE__ */ y(n);
41
+ async function h({
42
+ editor: n,
43
+ pluginName: o,
44
+ licenseKey: t,
45
+ cleanup: e
46
+ }) {
47
+ let s = !1;
48
+ const c = E();
49
+ n.on(m, () => {
50
+ s = !0;
51
+ }), n.on(f, ({ sdkLicense: i }) => {
52
+ i || e();
53
+ }), setTimeout(async () => {
54
+ if (!s) {
55
+ if (c) return;
56
+ t && await S({ licenseKey: t, pluginName: o }) || e();
57
+ }
58
+ }, 2e3);
59
+ }
60
+ async function S({ licenseKey: n, pluginName: o }) {
61
+ try {
62
+ const t = await P({
63
+ path: `/sdk/${n}`,
64
+ method: "POST",
65
+ body: JSON.stringify({
66
+ d: window.location.hostname,
67
+ pn: o
68
+ })
69
+ }), { license: e } = t.result || {};
70
+ return !!e;
71
+ } catch (t) {
72
+ return console.error("Error during SDK license check:", t), !1;
73
+ }
74
+ }
75
+ const k = "initPluginOne", I = function(n, o = {}) {
76
+ const { Blocks: t } = n, { licenseKey: e } = o, s = "test-plugin-one";
77
+ t.add(s, {
78
+ label: s,
79
+ content: { type: s, components: `initPluginOne, licenseKey: ${e}` }
80
+ }), h({
81
+ editor: n,
82
+ licenseKey: e,
83
+ pluginName: k,
84
+ cleanup: () => t.remove(s)
85
+ });
86
+ }, D = p(I), O = "initPluginTwo", T = function(n, o = {}) {
87
+ const { Blocks: t } = n, { licenseKey: e } = o, s = "test-plugin-two";
88
+ t.add(s, {
89
+ label: s,
90
+ content: { type: s, components: `initPluginTwo, licenseKey: ${e}` }
91
+ }), h({
92
+ editor: n,
93
+ licenseKey: e,
94
+ pluginName: O,
95
+ cleanup: () => t.remove(s)
96
+ });
97
+ }, b = p(T);
98
+ export {
99
+ D as initPluginOne,
100
+ b as initPluginTwo
101
+ };
@@ -0,0 +1 @@
1
+ (function(s,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],c):(s=typeof globalThis<"u"?globalThis:s||self,c(s.StudioSdkPlugins={}))})(this,function(s){"use strict";const c="app.grapesjs.com",u="app-stage.grapesjs.com",d=[c,u,"localhost","127.0.0.1",".local-credentialless.webcontainer.io","-sandpack.codesandbox.io"],m="license:check:start",g="license:check:end",p=()=>typeof window<"u",E=({isDev:n,isStage:o})=>`${n?"":`https://${o?u:c}`}/api`,N=()=>{const n=p()&&window.location.hostname;return!!n&&(d.includes(n)||d.some(o=>n.endsWith(o)))},w=()=>(p()&&window.location.hostname)===c;var y={NODE_ENV:"production",NPM_PACKAGE_VERSION:"1.0.2-rc.0",STUDIO_NPM_PACKAGE_VERSION:"1.0.19-rc.1"};const S=y.NODE_ENV!=="production";async function P({path:n,method:o="GET",headers:e={},body:t}){const r=`${E({isDev:S,isStage:!w()})}${n}`,a={method:o,headers:{"Content-Type":"application/json",...e}};t&&(a.body=JSON.stringify(t));const l=await fetch(r,a);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return l.json()}function _(n){const o=n;return o.init=e=>t=>n(t,e),o}const f=n=>_(n);async function h({editor:n,pluginName:o,licenseKey:e,cleanup:t}){let i=!1;const r=N();n.on(m,()=>{i=!0}),n.on(g,({sdkLicense:a})=>{a||t()}),setTimeout(async()=>{if(!i){if(r)return;e&&await T({licenseKey:e,pluginName:o})||t()}},2e3)}async function T({licenseKey:n,pluginName:o}){try{const e=await P({path:`/sdk/${n}`,method:"POST",body:JSON.stringify({d:window.location.hostname,pn:o})}),{license:t}=e.result||{};return!!t}catch(e){return console.error("Error during SDK license check:",e),!1}}const k="initPluginOne",O=f(function(n,o={}){const{Blocks:e}=n,{licenseKey:t}=o,i="test-plugin-one";e.add(i,{label:i,content:{type:i,components:`initPluginOne, licenseKey: ${t}`}}),h({editor:n,licenseKey:t,pluginName:k,cleanup:()=>e.remove(i)})}),b="initPluginTwo",I=f(function(n,o={}){const{Blocks:e}=n,{licenseKey:t}=o,i="test-plugin-two";e.add(i,{label:i,content:{type:i,components:`initPluginTwo, licenseKey: ${t}`}}),h({editor:n,licenseKey:t,pluginName:b,cleanup:()=>e.remove(i)})});s.initPluginOne=O,s.initPluginTwo=I,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,2 @@
1
+ declare const _default: import('../utils').PluginWithInit<import('../utils').PluginOptions>;
2
+ export default _default;
@@ -0,0 +1 @@
1
+ "use strict";require("react");const a="app.grapesjs.com",d="app-stage.grapesjs.com",l=[a,d,"localhost","127.0.0.1",".local-credentialless.webcontainer.io","-sandpack.codesandbox.io"],p="license:check:start",h="license:check:end",u=()=>typeof window<"u",f=({isDev:n,isStage:t})=>`${n?"":`https://${t?d:a}`}/api`,m=()=>{const n=u()&&window.location.hostname;return!!n&&(l.includes(n)||l.some(t=>n.endsWith(t)))},E=()=>(u()&&window.location.hostname)===a;var N={NODE_ENV:"production",NPM_PACKAGE_VERSION:"1.0.2-rc.0",STUDIO_NPM_PACKAGE_VERSION:"1.0.19-rc.1"};const _=N.NODE_ENV!=="production";async function w({path:n,method:t="GET",headers:e={},body:s}){const c=`${f({isDev:_,isStage:!E()})}${n}`,i={method:t,headers:{"Content-Type":"application/json",...e}};s&&(i.body=JSON.stringify(s));const r=await fetch(c,i);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r.json()}function g(n){const t=n;return t.init=e=>s=>n(s,e),t}const S=n=>g(n);async function k({editor:n,pluginName:t,licenseKey:e,cleanup:s}){let o=!1;const c=m();n.on(p,()=>{o=!0}),n.on(h,({sdkLicense:i})=>{i||s()}),setTimeout(async()=>{if(!o){if(c)return;e&&await O({licenseKey:e,pluginName:t})||s()}},2e3)}async function O({licenseKey:n,pluginName:t}){try{const e=await w({path:`/sdk/${n}`,method:"POST",body:JSON.stringify({d:window.location.hostname,pn:t})}),{license:s}=e.result||{};return!!s}catch(e){return console.error("Error during SDK license check:",e),!1}}const y="initPluginOne",C=function(n,t={}){const{Blocks:e}=n,{licenseKey:s}=t,o="test-plugin-one";e.add(o,{label:o,content:{type:o,components:`initPluginOne, licenseKey: ${s}`}}),k({editor:n,licenseKey:s,pluginName:y,cleanup:()=>e.remove(o)})},D=S(C);module.exports=D;
@@ -0,0 +1,2 @@
1
+ declare const _default: import('../utils').PluginWithInit<import('../utils').PluginOptions>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import('../utils').PluginWithInit<import('../utils').PluginOptions>;
2
+ export default _default;
@@ -0,0 +1,89 @@
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 N = { NODE_ENV: "production", NPM_PACKAGE_VERSION: "1.0.2-rc.0", STUDIO_NPM_PACKAGE_VERSION: "1.0.19-rc.1" };
16
+ const _ = N.NODE_ENV !== "production";
17
+ async function w({
18
+ path: n,
19
+ method: t = "GET",
20
+ headers: e = {},
21
+ body: s
22
+ }) {
23
+ const c = `${f({ isDev: _, 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 O({ licenseKey: e, pluginName: t }) || s();
57
+ }
58
+ }, 2e3);
59
+ }
60
+ async function O({ licenseKey: n, pluginName: t }) {
61
+ try {
62
+ const e = await w({
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 = "initPluginOne", C = function(n, t = {}) {
76
+ const { Blocks: e } = n, { licenseKey: s } = t, o = "test-plugin-one";
77
+ e.add(o, {
78
+ label: o,
79
+ content: { type: o, components: `initPluginOne, 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
+ };
@@ -0,0 +1 @@
1
+ (function(o,c){typeof exports=="object"&&typeof module<"u"?module.exports=c(require("react")):typeof define=="function"&&define.amd?define(["react"],c):(o=typeof globalThis<"u"?globalThis:o||self,o.StudioSdkPlugins_initPluginOne=c())})(this,function(){"use strict";const o="app.grapesjs.com",c="app-stage.grapesjs.com",l=[o,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:o}`}/api`,m=()=>{const n=u()&&window.location.hostname;return!!n&&(l.includes(n)||l.some(e=>n.endsWith(e)))},E=()=>(u()&&window.location.hostname)===o;var g={NODE_ENV:"production",NPM_PACKAGE_VERSION:"1.0.2-rc.0",STUDIO_NPM_PACKAGE_VERSION:"1.0.19-rc.1"};const N=g.NODE_ENV!=="production";async function _({path:n,method:e="GET",headers:t={},body:s}){const a=`${h({isDev:N,isStage:!E()})}${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 S(n){const e=n;return e.init=t=>s=>n(s,t),e}const w=n=>S(n);async function k({editor:n,pluginName:e,licenseKey:t,cleanup:s}){let i=!1;const a=m();n.on(p,()=>{i=!0}),n.on(f,({sdkLicense:r})=>{r||s()}),setTimeout(async()=>{if(!i){if(a)return;t&&await y({licenseKey:t,pluginName:e})||s()}},2e3)}async function y({licenseKey:n,pluginName:e}){try{const t=await _({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 O="initPluginOne";return w(function(n,e={}){const{Blocks:t}=n,{licenseKey:s}=e,i="test-plugin-one";t.add(i,{label:i,content:{type:i,components:`initPluginOne, licenseKey: ${s}`}}),k({editor:n,licenseKey:s,pluginName:O,cleanup:()=>t.remove(i)})})});
@@ -0,0 +1,2 @@
1
+ declare const _default: import('../utils').PluginWithInit<import('../utils').PluginOptions>;
2
+ export default _default;
@@ -0,0 +1 @@
1
+ "use strict";require("react");const a="app.grapesjs.com",d="app-stage.grapesjs.com",l=[a,d,"localhost","127.0.0.1",".local-credentialless.webcontainer.io","-sandpack.codesandbox.io"],p="license:check:start",h="license:check:end",u=()=>typeof window<"u",f=({isDev:n,isStage:t})=>`${n?"":`https://${t?d:a}`}/api`,m=()=>{const n=u()&&window.location.hostname;return!!n&&(l.includes(n)||l.some(t=>n.endsWith(t)))},E=()=>(u()&&window.location.hostname)===a;var w={NODE_ENV:"production",NPM_PACKAGE_VERSION:"1.0.2-rc.0",STUDIO_NPM_PACKAGE_VERSION:"1.0.19-rc.1"};const N=w.NODE_ENV!=="production";async function _({path:n,method:t="GET",headers:e={},body:s}){const c=`${f({isDev:N,isStage:!E()})}${n}`,i={method:t,headers:{"Content-Type":"application/json",...e}};s&&(i.body=JSON.stringify(s));const r=await fetch(c,i);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);return r.json()}function g(n){const t=n;return t.init=e=>s=>n(s,e),t}const S=n=>g(n);async function k({editor:n,pluginName:t,licenseKey:e,cleanup:s}){let o=!1;const c=m();n.on(p,()=>{o=!0}),n.on(h,({sdkLicense:i})=>{i||s()}),setTimeout(async()=>{if(!o){if(c)return;e&&await T({licenseKey:e,pluginName:t})||s()}},2e3)}async function T({licenseKey:n,pluginName:t}){try{const e=await _({path:`/sdk/${n}`,method:"POST",body:JSON.stringify({d:window.location.hostname,pn:t})}),{license:s}=e.result||{};return!!s}catch(e){return console.error("Error during SDK license check:",e),!1}}const y="initPluginTwo",C=function(n,t={}){const{Blocks:e}=n,{licenseKey:s}=t,o="test-plugin-two";e.add(o,{label:o,content:{type:o,components:`initPluginTwo, licenseKey: ${s}`}}),k({editor:n,licenseKey:s,pluginName:y,cleanup:()=>e.remove(o)})},D=S(C);module.exports=D;
@@ -0,0 +1,2 @@
1
+ declare const _default: import('../utils').PluginWithInit<import('../utils').PluginOptions>;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import('../utils').PluginWithInit<import('../utils').PluginOptions>;
2
+ export default _default;
@@ -0,0 +1,89 @@
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-rc.0", 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
+ };
@@ -0,0 +1 @@
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-rc.0",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)})})});
@@ -0,0 +1,16 @@
1
+ import { Editor, Plugin } from 'grapesjs';
2
+ export interface PluginOptions {
3
+ licenseKey?: string;
4
+ }
5
+ export interface SDKPlugin<T extends PluginOptions = PluginOptions> extends Plugin<T> {
6
+ }
7
+ export interface PluginWithInit<T extends PluginOptions = PluginOptions> extends Plugin<T> {
8
+ init: (opts: T) => (editor: Editor) => void;
9
+ }
10
+ export declare const pluginWithInit: (plugin: SDKPlugin<PluginOptions>) => PluginWithInit<PluginOptions>;
11
+ export declare function subscribeToLicenseCheck({ editor, pluginName, licenseKey, cleanup }: {
12
+ editor: Editor;
13
+ pluginName: string;
14
+ licenseKey?: string;
15
+ cleanup: () => void;
16
+ }): Promise<void>;
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@grapesjs/studio-sdk-plugins",
3
+ "version": "1.0.2-rc.0",
4
+ "publishConfig": {
5
+ "registry": "https://registry.npmjs.org"
6
+ },
7
+ "files": [
8
+ "dist",
9
+ "*.js",
10
+ "*.d.ts"
11
+ ],
12
+ "main": "dist/index.cjs.js",
13
+ "module": "dist/index.es.js",
14
+ "types": "dist/index.d.ts",
15
+ "license": "MIT",
16
+ "sideEffects": false,
17
+ "scripts": {
18
+ "build": "tsx build"
19
+ },
20
+ "devDependencies": {
21
+ "grapesjs": "^0.21.12",
22
+ "tsx": "^4.19.1",
23
+ "typescript": "^5.6.2",
24
+ "vite": "^5.4.8",
25
+ "vite-plugin-dts": "^4.2.2"
26
+ },
27
+ "exports": {
28
+ ".": {
29
+ "require": "./dist/index.cjs.js",
30
+ "import": "./dist/index.es.js",
31
+ "types": "./dist/index.d.ts",
32
+ "umd": "./dist/index.umd.js"
33
+ },
34
+ "./*": "./*"
35
+ }
36
+ }