@grapesjs/studio-sdk-plugins 1.0.21 → 1.0.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/dist/animationComponent/components/Animation.d.ts +6 -0
- package/dist/animationComponent/components/AnimationGroup.d.ts +4 -0
- package/dist/animationComponent/index.cjs.d.ts +3 -0
- package/dist/animationComponent/index.cjs.js +507 -0
- package/dist/animationComponent/index.d.ts +3 -0
- package/dist/animationComponent/index.es.d.ts +3 -0
- package/dist/animationComponent/index.es.js +1111 -0
- package/dist/animationComponent/index.umd.js +507 -0
- package/dist/animationComponent/shared.d.ts +3 -0
- package/dist/animationComponent/types.d.ts +28 -0
- package/dist/animationComponent/typesSchema.d.ts +48 -0
- package/dist/animationComponent/utils.d.ts +19 -0
- package/dist/dataSourceEjs/EjsExporter.d.ts +13 -0
- package/dist/dataSourceEjs/EjsImporter.d.ts +29 -0
- package/dist/dataSourceEjs/index.cjs.d.ts +2 -2
- package/dist/dataSourceEjs/index.cjs.js +24 -3
- package/dist/dataSourceEjs/index.d.ts +2 -2
- package/dist/dataSourceEjs/index.es.d.ts +2 -2
- package/dist/dataSourceEjs/index.es.js +697 -114
- package/dist/dataSourceEjs/index.umd.js +24 -3
- package/dist/dataSourceEjs/shared.d.ts +3 -0
- package/dist/dataSourceEjs/types.d.ts +2 -2
- package/dist/dataSourceEjs/typesSchema.d.ts +3 -0
- package/dist/dataSourceHandlebars/HandlebarsExporter.d.ts +16 -0
- package/dist/dataSourceHandlebars/HandlebarsImporter.d.ts +20 -0
- package/dist/dataSourceHandlebars/helperImplementations.d.ts +1 -0
- package/dist/dataSourceHandlebars/index.cjs.js +20 -1
- package/dist/dataSourceHandlebars/index.es.js +401 -99
- package/dist/dataSourceHandlebars/index.umd.js +20 -1
- package/dist/dataSourceHandlebars/shared.d.ts +3 -0
- package/dist/dataSourceHandlebars/types.d.ts +2 -2
- package/dist/dataSourceHandlebars/typesSchema.d.ts +3 -0
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +29 -29
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +64 -64
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.d.ts +1 -0
- package/dist/index.cjs.js +587 -51
- package/dist/index.d.ts +1 -0
- package/dist/index.es.d.ts +1 -0
- package/dist/index.es.js +4809 -3046
- package/dist/index.umd.js +584 -48
- package/dist/layoutSidebarButtons/index.cjs.js +1 -1
- package/dist/layoutSidebarButtons/index.es.js +59 -59
- package/dist/layoutSidebarButtons/index.umd.js +1 -1
- package/dist/presetPrintable/index.cjs.js +3 -3
- package/dist/presetPrintable/index.es.js +136 -131
- package/dist/presetPrintable/index.umd.js +4 -4
- package/dist/prosemirror/index.cjs.js +1 -1
- package/dist/prosemirror/index.es.js +1 -1
- package/dist/prosemirror/index.umd.js +1 -1
- package/dist/rteTinyMce/index.cjs.js +2 -2
- package/dist/rteTinyMce/index.es.js +67 -67
- package/dist/rteTinyMce/index.umd.js +2 -2
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +14 -14
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/utilsDataSources.d.ts +28 -0
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +26 -26
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +2 -1
- package/dist/dataSourceEjs/EjsStrategy.d.ts +0 -15
- package/dist/dataSourceHandlebars/HandlebarsStrategy.d.ts +0 -17
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
1
|
+
"use strict";const b="app.grapesjs.com",I="app-stage.grapesjs.com",S=[b,I,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],v="license:check:start",w="license:check:end",P=()=>typeof window<"u",k=({isDev:i,isStage:t})=>`${i?"":`https://${t?I:b}`}/api`,T=()=>{const i=P()&&window.location.hostname;return!!i&&(S.includes(i)||S.some(t=>i.endsWith(t)))};async function M({path:i,baseApiUrl:t,method:e="GET",headers:r={},params:s,body:n}){const o=`${t||k({isDev:!1,isStage:!1})}${i}`,l={method:e,headers:{"Content-Type":"application/json",...r}};n&&(l.body=JSON.stringify(n));const p=s?new URLSearchParams(s).toString():"",c=p?`?${p}`:"",h=await fetch(`${o}${c}`,l);if(!h.ok)throw new Error(`HTTP error! status: ${h.status}`);return h.json()}var d=(i=>(i.free="free",i.startup="startup",i.business="business",i.enterprise="enterprise",i))(d||{});const $={[d.free]:0,[d.startup]:10,[d.business]:20,[d.enterprise]:30};function N(i){const t=i;return t.init=e=>r=>i(r,e),t}const O=i=>N(i);async function _({editor:i,plan:t,pluginName:e,licenseKey:r,cleanup:s}){let n="",a=!1;const o=T(),l=c=>{console.warn("Cleanup plugin:",e,"Reason:",c),s()},p=(c={})=>{var E;const{error:h,sdkLicense:f}=c,u=(E=c.plan)==null?void 0:E.category;if(!(f||c.license)||h)l(h||"Invalid license");else if(u){const C=$[t],L=$[u];C>L&&l({pluginRequiredPlan:t,licensePlan:u})}};i.on(v,c=>{n=c==null?void 0:c.baseApiUrl,a=!0}),i.on(w,c=>{p(c)}),setTimeout(async()=>{if(!a){if(o)return;if(r){const c=await B({licenseKey:r,pluginName:e,baseApiUrl:n});c&&p(c)}else l("The `licenseKey` option not provided")}},2e3)}async function B(i){const{licenseKey:t,pluginName:e,baseApiUrl:r}=i;try{return(await M({baseApiUrl:r,path:`/sdk/${t||"na"}`,method:"POST",params:{d:window.location.hostname,pn:e}})).result||{}}catch(s){return console.error("Error during SDK license check:",s),!1}}var g=(i=>(i.variable="data-variable",i.condition="data-condition",i.conditionTrue="data-condition-true-content",i.conditionFalse="data-condition-false-content",i.collection="data-collection",i.collectionItem="data-collection-item",i))(g||{});class W{constructor(t){this.strategy=t,this.requiredHelpers=new Set,this.helperLibrary={}}registerHelper(t){this.helperLibrary[t]&&this.requiredHelpers.add(t)}generateVariable(t){return this.strategy.getVariableSyntax(t)}generateCollectionStart(t){return this.registerHelper("slice"),this.strategy.getCollectionStartSyntax(t)}generateCollectionEnd(){return this.strategy.getCollectionEndSyntax()}generateConditionalStart(t){return this.strategy.getConditionalStartSyntax(t)}generateConditionElse(){return this.strategy.getConditionElseSyntax()}generateConditionalEnd(){return this.strategy.getConditionalEndSyntax()}reset(){this.requiredHelpers.clear()}}function j(i){return typeof i=="object"&&i.type===g.variable}function m({component:i,value:t,getCustomPath:e}){if(j(t)&&!t.collectionId&&e){const r=t.path??"",s=r.split(".");return{...t,path:e({component:i,path:r,paths:s})}}return t}const A=i=>{y(i,g.variable,{toHTML(t){var a;const e=this.tagName,r=this.__attrToString(t),s=(a=this.getDataResolver)==null?void 0:a.call(this),n=m({component:this,value:s,getCustomPath:t==null?void 0:t.getCustomPath});return`<${e}${r?` ${r}`:""}>${t.exporter.generateVariable(n)}</${e}>`}}),y(i,g.condition,{toHTML(t){var p,c;const e=t.exporter,r=t==null?void 0:t.getCustomPath,s=this.components(),[n,a]=(s==null?void 0:s.models)??[],o=(p=this.getDataResolver)==null?void 0:p.call(this),l=((c=this.resolveCondition)==null?void 0:c.call(this,o==null?void 0:o.condition,r))??{};return`
|
|
2
|
+
${e.generateConditionalStart(l)}
|
|
3
|
+
${(n==null?void 0:n.toHTML(t))??""}
|
|
4
|
+
${e.generateConditionElse()}
|
|
5
|
+
${(a==null?void 0:a.toHTML(t))??""}
|
|
6
|
+
${e.generateConditionalEnd()}
|
|
7
|
+
`},resolveCondition(t,e){var s,n;if(!t)return{};if(t.operator==="and"||t.operator==="or")return{operator:t.operator,statements:((n=(s=t.statements)==null?void 0:s.map)==null?void 0:n.call(s,a=>{var o;return((o=this.resolveCondition)==null?void 0:o.call(this,a,e))??{}}))??[]};const r={component:this,getCustomPath:e};return{...t,left:m({...r,value:t.left}),right:m({...r,value:t.right})}}}),y(i,g.collection,{toHTML(t){const e=t.exporter,r=this.tagName,s=this.__attrToString(t),n=this.getDataResolver(),a={...n,dataSource:m({component:this,value:n==null?void 0:n.dataSource,getCustomPath:t==null?void 0:t.getCustomPath})},o=this.components().at(0);return`
|
|
8
|
+
<${r}${s?` ${s}`:""}>${e.generateCollectionStart(a)}
|
|
9
|
+
${(o==null?void 0:o.toHTML(t))??""}
|
|
10
|
+
${e.generateCollectionEnd()}</${r}>
|
|
11
|
+
`}})},y=(i,t,e)=>{const r=i.Components.getType(t);if(!r){console.warn(`Component type ${t} not found`);return}const{model:s}=r;i.Components.addType(t,{model:{...e,toHTML(n={}){var o;const{exporter:a}=n;return a?a.export?a.export({component:this}):((o=e.toHTML)==null?void 0:o.call(this,n))??"":s.prototype.toHTML.call(this,n)??""}}})},J=i=>{const t=i;return t.logicalOperator==="and"||t.logicalOperator==="or"},H=(i,t)=>(i.config.optsHtml={...i.config.optsHtml,exporter:new W(t)},A(i),()=>{i.config.optsHtml.exporter=void 0}),U=(i,t)=>{const e=s=>{const{input:n}=s,{contains:a}=t;(!a||n.includes(a))&&(s.input=t.importer.import(n))},r=i.Parser.events.htmlBefore;return i.on(r,e),()=>{i.off(r,e)}};class D{getVariableSyntax(t){const{defaultValue:e}=t,r=this.getFullPath(t),s=e?` || \`${e}\``:"";return`<%= ${r}${s} %>`}getCollectionStartSyntax(t){const{collectionId:e,dataSource:r,startIndex:s,endIndex:n}=t,a=(r==null?void 0:r.path)||e||"",o=this._sanitizeVariableName(e);let l="";if(s!==void 0||n!==void 0){const p=s??0,c=n!==void 0?n:"";l=`.slice(${p}${c!==""?`, ${c}`:""})`}return`<% ${a}${l}.forEach(function(currentItem, index, arr) {
|
|
12
|
+
const startIndex = parseInt(${s??0}, 10);
|
|
3
13
|
const endIndex = startIndex + arr.length;
|
|
4
|
-
const ${
|
|
14
|
+
const ${o}={ currentItem, currentIndex: startIndex + index, remainingItems: endIndex - (startIndex + index)} %>`}_sanitizeVariableName(t){return t.replace(/[^a-zA-Z0-9_$]/g,"_")}getCollectionEndSyntax(){return"<% }) %>"}getConditionalStartSyntax(t){return`<% if (${this._parseCondition(t)}) { %>`}getConditionElseSyntax(){return"<% } else { %>"}getConditionalEndSyntax(){return"<% } %>"}getFullPath({collectionId:t,path:e,variableType:r}){return(t?[this._sanitizeVariableName(t),r,e].filter(Boolean).join("."):e)||""}_parseCondition(t){if(!t)return"";if(J(t)){const e=t.statements.map(r=>this._parseCondition(r));return e.length>1?`(${e.join(`) ${t.logicalOperator} (`)})`:e[0]}else{const e=this._parseValue(t.left),r=this._parseValue(t.right);switch(t.operator){case"equals":return`${e} === ${r}`;case">":case"<":case">=":case"<=":case"=":case"!=":return`${e} ${t.operator} ${r}`;case"contains":return`${e}?.includes(${r})`;case"startsWith":return`${e}?.startsWith(${r})`;case"endsWith":return`${e}?.endsWith(${r})`;case"equalsIgnoreCase":return`${e}?.toLowerCase() === ${r}?.toLowerCase()`;case"trimEquals":return`${e}?.trim() === ${r}?.trim()`;case"isTruthy":return`!!${e}`;case"isFalsy":return`!${e}`;case"isDefined":return`${e} !== undefined`;case"isNull":return`${e} === null`;case"isUndefined":return`${e} === undefined`;case"isArray":return`Array.isArray(${e})`;case"isObject":return`typeof ${e} === 'object' && ${e} !== null && !Array.isArray(${e})`;case"isString":return`typeof ${e} === 'string'`;case"isNumber":return`typeof ${e} === 'number' && !isNaN(${e})`;case"isBoolean":return`typeof ${e} === 'boolean'`;default:return`${e} ${t.operator} ${r}`}}}_parseValue(t){return typeof t=="object"?this.getFullPath(t):typeof t=="string"?`'${t.replace(/'/g,"\\'")}'`:String(t)}}const V=["===","==","!==","!=","<=",">=","<",">","&&","||"],q={"===":"=","==":"=","!==":"!=","!=":"!=","<=":"<=",">=":">=","<":"<",">":">","&&":"&&","||":"||"};class F{constructor(){this.messages=[],this.collectionStack=[]}import(t){this.messages=[],this.collectionStack=[];try{const e=this.parseEjsTemplate(t);return this.astToGrapesJS(e)}catch(e){return console.error("Error during import:",e),this.addMessage("error",`Error during import: ${e instanceof Error?e.message:String(e)}`),""}}parseEjsTemplate(t){const e=[];let r=0;for(;r<t.length;){const s=t.indexOf("<%",r);if(s===-1){r<t.length&&e.push(this.createAppendLiteral(t.slice(r)));break}s>r&&e.push(this.createAppendLiteral(t.slice(r,s)));const n=t.indexOf("%>",s);if(n===-1)throw new Error("Unclosed EJS tag");const a=t.slice(s+2,n).trim();if(r=n+2,a.startsWith("=")||a.startsWith("-")){const o=a.slice(1).trim();e.push(this.createAppendExpression(o))}else{if(a.startsWith("#"))continue;if(a.startsWith("if")){const o=this.parseIfStatement(a,t,r);e.push(o),r=o.endPos||r}else if(a.startsWith("for")){const o=this.parseForStatement(a,t,r);e.push(o),r=o.endPos||r}else{if(a.startsWith("}")||a.startsWith("} else"))break;this.addMessage("info",`Unsupported scriptlet content: ${a}`)}}}return{type:"Program",body:e}}createAppendLiteral(t){return{type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"Identifier",name:"__append"},arguments:[{type:"Literal",value:t}]}}}createAppendExpression(t){return{type:"ExpressionStatement",expression:{type:"CallExpression",callee:{type:"Identifier",name:"__append"},arguments:[this.parseJsExpression(t)]}}}findNextElse(t,e){const r=/<%\s*\}\s*else(?:\s+if\s*\([^)]*\))?\s*\{\s*%>/g;r.lastIndex=e;const s=r.exec(t);return s?{start:s.index,end:t.indexOf("%>",s.index)+2}:null}parseIfStatement(t,e,r){const s=t.match(/if\s*\((.*)\)\s*\{?/);if(!s)throw new Error("Invalid if statement syntax");const n=this.parseJsExpression(s[1]),{body:a,endPos:o}=this.parseTemplateBlock(e,r);let l=null,p=o;const c=this.findNextElse(e,o);if(c){const h=e.slice(c.start,c.end);if(/else\s+if/.test(h)){const f=c.end,u=this.parseIfStatement(h,e,f);l={type:"IfStatement",test:u.test,consequent:u.consequent,alternate:u.alternate},p=u.endPos}else{const f=c.end,{body:u,endPos:x}=this.parseTemplateBlock(e,f);l={type:"BlockStatement",body:u},p=x}}return{type:"IfStatement",test:n,consequent:{type:"BlockStatement",body:a},alternate:l,endPos:p}}parseForStatement(t,e,r){const s=t.match(/for\s*\((.*)\)\s*\{?/);if(!s)throw new Error("Invalid for statement syntax");const n=s[1].split("of");if(n.length!==2)throw new Error("Only for...of loops are supported");const a=n[0].trim().replace(/^let\s+|^const\s+|^var\s+/,""),o=n[1].trim(),{body:l,endPos:p}=this.parseTemplateBlock(e,r);return{type:"ForStatement",init:{type:"VariableDeclaration",kind:"let",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:a},init:this.parseJsExpression(o)}]},test:null,update:null,body:{type:"BlockStatement",body:l},endPos:p}}parseTemplateBlock(t,e){const r=[];let s=e,n=1;for(;s<t.length&&n>0;){const a=t.indexOf("<%",s);if(a===-1){s<t.length&&r.push(this.createAppendLiteral(t.slice(s)));break}a>s&&r.push(this.createAppendLiteral(t.slice(s,a)));const o=t.indexOf("%>",a);if(o===-1)throw new Error("Unclosed EJS tag");const l=t.slice(a+2,o).trim();if(s=o+2,l==="}"){if(n--,n===0)break}else(l.startsWith("if")||l.startsWith("for"))&&n++;if(l.startsWith("=")||l.startsWith("-")){const p=l.slice(1).trim();r.push(this.createAppendExpression(p))}else{if(l.startsWith("#"))continue;if(l.startsWith("} else")){s=a;break}}}return{body:r,endPos:s}}parseJsExpression(t){if(/^(['"]).*\1$/.test(t))return{type:"Literal",value:t.slice(1,-1)};if(/^-?\d+$/.test(t))return{type:"Literal",value:parseInt(t,10)};if(/^-?\d+\.\d+$/.test(t))return{type:"Literal",value:parseFloat(t)};if(t==="true"||t==="false")return{type:"Literal",value:t==="true"};for(const s of V){const n=t.indexOf(s);if(n>0)return{type:s==="&&"||s==="||"?"LogicalExpression":"BinaryExpression",operator:q[s],left:this.parseJsExpression(t.slice(0,n).trim()),right:this.parseJsExpression(t.slice(n+s.length).trim())}}const e=t.indexOf("."),r=t.indexOf("[");if(e>0||r>0){const s=e>0&&(r===-1||e<r)?e:r;let n,a,o=!1;if(s===e)n=t.slice(0,e),a=this.parseJsExpression(t.slice(e+1));else{n=t.slice(0,r);const l=t.indexOf("]",r);if(l===-1)throw new Error("Unclosed bracket in expression");a=this.parseJsExpression(t.slice(r+1,l)),o=!0}return{type:"MemberExpression",object:this.parseJsExpression(n),property:a,computed:o}}return{type:"Identifier",name:t}}astToGrapesJS(t){switch(t.type){case"Program":return this.handleProgram(t);case"VariableDeclaration":return this.handleVariableDeclaration(t);case"ExpressionStatement":return this.handleExpressionStatement(t);case"IfStatement":return this.handleIfStatement(t);case"ForStatement":return this.handleForStatement(t);case"BlockStatement":return this.handleBlockStatement(t);case"Literal":return this.handleLiteral(t);case"Identifier":return this.handleIdentifier(t);case"MemberExpression":return this.handleMemberExpression(t);case"BinaryExpression":return this.handleBinaryExpression(t);case"LogicalExpression":return this.handleLogicalExpression(t);case"CallExpression":return this.handleCallExpression(t);default:return this.addMessage("warning",`Unsupported node type: ${t.type}`),""}}handleProgram(t){let e="";for(const r of t.body)e+=this.astToGrapesJS(r);return e}handleVariableDeclaration(t){return""}handleExpressionStatement(t){return t.expression.type==="CallExpression"&&t.expression.callee.type==="Identifier"&&t.expression.callee.name==="__append"&&t.expression.arguments.length>0?this.astToGrapesJS(t.expression.arguments[0]):""}handleIfStatement(t){const e=this.getConditionExpression(t.test),r=this.astToGrapesJS(t.consequent);let s="";return t.alternate&&(s=this.astToGrapesJS(t.alternate)),`
|
|
15
|
+
<data-condition data-gjs-data-resolver='${JSON.stringify({condition:e})}'>
|
|
16
|
+
<data-condition-true-content>${r}</data-condition-true-content>
|
|
17
|
+
<data-condition-false-content>${s}</data-condition-false-content>
|
|
18
|
+
</data-condition>
|
|
19
|
+
`}handleForStatement(t){var a;if(((a=t.init)==null?void 0:a.type)!=="VariableDeclaration"||t.init.declarations.length===0)return this.addMessage("warning","Unsupported for loop init format"),"";const e=t.init.declarations[0];if(e.id.type!=="Identifier")return this.addMessage("warning","Unsupported for loop variable declaration id"),"";let r="";if(e.init)r=this.getExpressionString(e.init);else return this.addMessage("warning","For loop collection is undefined"),"";r.startsWith("data.")||(r=`data.${r}`);const s=`collection-${Math.random().toString(36).substring(2,10)}`;this.collectionStack.push(s);const n=this.astToGrapesJS(t.body);return this.collectionStack.pop(),`
|
|
20
|
+
<data-collection data-gjs-data-resolver='${JSON.stringify({dataSource:{type:"data-variable",path:r},collectionId:s})}'>
|
|
21
|
+
<data-collection-item>
|
|
22
|
+
${n}
|
|
23
|
+
</data-collection-item>
|
|
24
|
+
</data-collection>
|
|
25
|
+
`}handleBlockStatement(t){let e="";for(const r of t.body)e+=this.astToGrapesJS(r);return e}handleLiteral(t){return String(t.value??"")}handleIdentifier(t){let e={path:t.name};if(this.collectionStack.length>0&&t.name==="item"){const r=this.collectionStack[this.collectionStack.length-1];e={path:t.name,collectionId:r,variableType:"currentItem"}}return`<data-variable data-gjs-data-resolver='${JSON.stringify(e)}'></data-variable>`}handleMemberExpression(t,e={}){let s={path:this.getExpressionString(t),...e};if(this.collectionStack.length>0){let n=t;const a=[];let o=!1;for(;n.type==="MemberExpression";)if(n.property.type==="Identifier"?a.unshift(n.property.name):n.property.type==="Literal"&&n.computed&&a.unshift(`[${n.property.value}]`),n=n.object,n.type==="Identifier"&&n.name==="item"){o=!0;break}if(o&&n.type==="Identifier"&&n.name==="item"){const l=this.collectionStack[this.collectionStack.length-1],p=a.join(".").replace(/\.\[/g,"[");s={...s,collectionId:l,variableType:"currentItem",path:p}}}return`<data-variable data-gjs-data-resolver='${JSON.stringify(s)}'></data-variable>`}handleBinaryExpression(t){return`${this.getExpressionString(t.left)} ${t.operator} ${this.getExpressionString(t.right)}`}handleLogicalExpression(t){return t.operator==="||"&&t.right.type==="Literal"?this.handleMemberExpression(t.left,{defaultValue:t.right.value}):`${this.getExpressionString(t.left)} ${t.operator} ${this.getExpressionString(t.right)}`}handleCallExpression(t){var e;if(t.callee.type==="Identifier"&&t.callee.name==="include"){const r=((e=t.arguments[0])==null?void 0:e.type)==="Literal"?String(t.arguments[0].value):"";return this.addMessage("info",`Partial includes are not fully supported: ${r}`),""}return""}getConditionExpression(t){if(t.type==="Identifier")return{logicalOperator:"and",statements:[{left:{type:"data-variable",path:t.name},operator:"isTruthy"}]};if(t.type==="MemberExpression"){let e=this.getExpressionString(t),r="isTruthy";return e.startsWith("!!")?(r="isTruthy",e=e.slice(2)):e.startsWith("!")&&(r="isFalsy",e=e.slice(1)),{logicalOperator:"and",statements:[{left:{type:"data-variable",path:e},operator:r}]}}if(t.type==="BinaryExpression"||t.type==="LogicalExpression"){const e=this.getConditionExpression(t.left),r=this.getConditionExpression(t.right);return`${e} ${t.operator} ${r}`}return t.type==="Literal"?typeof t.value=="string"?`'${t.value}'`:String(t.value??""):this.getExpressionString(t)}getExpressionString(t){switch(t.type){case"Identifier":return t.name;case"Literal":return String(t.value??"");case"MemberExpression":{const e=this.getExpressionString(t.object),r=this.getExpressionString(t.property);return t.computed?`${e}[${r}]`:`${e}.${r}`}case"BinaryExpression":{const e=this.getExpressionString(t.left),r=this.getExpressionString(t.right);return`${e} ${t.operator} ${r}`}case"LogicalExpression":{const e=this.getExpressionString(t.left),r=this.getExpressionString(t.right);return`${e} ${t.operator} ${r}`}default:return this.addMessage("warning",`Unsupported expression type for getExpressionString: ${t.type}`),""}}addMessage(t,e){this.messages.push({type:t,message:e})}}const G="dataSourceEjs",R=d.startup,K=function(i,t={}){const e=H(i,new D),r=U(i,{contains:"<%",importer:new F});_({editor:i,licenseKey:t.licenseKey,plan:R,pluginName:G,cleanup:()=>{e(),r()}})},z=O(K);module.exports=z;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const _default: import('../utils').PluginWithInit<
|
|
1
|
+
import { DataSourceEjsOptions } from './types';
|
|
2
|
+
declare const _default: import('../utils').PluginWithInit<DataSourceEjsOptions>;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
declare const _default: import('../utils').PluginWithInit<
|
|
1
|
+
import { DataSourceEjsOptions } from './types';
|
|
2
|
+
declare const _default: import('../utils').PluginWithInit<DataSourceEjsOptions>;
|
|
3
3
|
export default _default;
|