New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

adaptivecards-templating

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adaptivecards-templating - npm Package Compare versions

Comparing version 0.1.1-alpha.0 to 0.1.2-alpha.0

9

dist/adaptivecards-templating.d.ts

@@ -56,2 +56,11 @@ declare module 'adaptivecards-templating/expression-parser' {

import { EvaluationContext } from 'adaptivecards-templating/expression-parser';
export class TemplatizedString {
private _parts;
static parse(s: string): string | TemplatizedString;
private _shouldDropOwner;
private evalExpression;
private internalEvaluate;
evaluate(context: EvaluationContext): any;
readonly shouldDropOwner: boolean;
}
export class Template {

@@ -58,0 +67,0 @@ private static prepare;

2

dist/adaptivecards-templating.min.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ACData=t():e.ACData=t()}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var i=["/","*","-","+","==","!=","<","<=",">",">="],a=["identifier","string","number","boolean"],s=function(){function e(){}return e.init=function(){e.rules.push({tokenType:void 0,regEx:/^\s/},{tokenType:"{",regEx:/^{/},{tokenType:"?#",regEx:/^\?#/},{tokenType:"}",regEx:/^}/},{tokenType:"[",regEx:/^\[/},{tokenType:"]",regEx:/^\]/},{tokenType:"(",regEx:/^\(/},{tokenType:")",regEx:/^\)/},{tokenType:"boolean",regEx:/^true|^false/},{tokenType:"identifier",regEx:/^[$a-z_]+/i},{tokenType:".",regEx:/^\./},{tokenType:",",regEx:/^,/},{tokenType:"+",regEx:/^\+/},{tokenType:"-",regEx:/^-/},{tokenType:"*",regEx:/^\*/},{tokenType:"/",regEx:/^\//},{tokenType:"==",regEx:/^==/},{tokenType:"!=",regEx:/^!=/},{tokenType:"<=",regEx:/^<=/},{tokenType:"<",regEx:/^</},{tokenType:">=",regEx:/^>=/},{tokenType:">",regEx:/^>/},{tokenType:"string",regEx:/^"([^"]*)"/},{tokenType:"string",regEx:/^'([^']*)'/},{tokenType:"number",regEx:/^\d*\.?\d+/})},e.parse=function(t){for(var n=[],r=0;r<t.length;){for(var o=t.substring(r),i=!1,a=0,s=e.rules;a<s.length;a++){var u=s[a],p=u.regEx.exec(o);if(p){if(p.length>2)throw new Error("A tokenizer rule matched more than one group.");null!=u.tokenType&&n.push({type:u.tokenType,value:p[1==p.length?0:1],originalPosition:r}),r+=p[0].length,i=!0;break}}if(!i)throw new Error("Unexpected character "+o[0]+" at position "+r)}return n},e.rules=[],e}();function u(e){if("number"==typeof e||"string"==typeof e||"boolean"==typeof e)return e;throw new Error("Invalid value type: "+typeof e)}s.init();var p=function(){function e(){this._functions={},this._stateStack=[]}return e.init=function(){e._builtInFunctions.substr=function(e,t,n){return"string"==typeof e&&"number"==typeof t&&"number"==typeof n?e.substr(t,n):""},e._builtInFunctions["JSON.parse"]=function(e){return JSON.parse(e)},e._builtInFunctions.if=function(e,t,n){return e?t:n},e._builtInFunctions.toUpper=function(e){return"string"==typeof e?e.toUpperCase():e},e._builtInFunctions.toLower=function(e){return"string"==typeof e?e.toLowerCase():e},e._builtInFunctions["Date.format"]=function(e,t){var n;if("string"==typeof e)n=Date.parse(e);else{if("number"!=typeof e)return e;n=e}var r=new Date(n),o="compact";return"string"==typeof t&&(o=t.toLowerCase(),["long","short","compact"].indexOf(o)<0&&(o="compact")),"compact"===o?r.toLocaleDateString():r.toLocaleDateString(void 0,{day:"numeric",weekday:o,month:o,year:"numeric"})},e._builtInFunctions["Time.format"]=function(e){var t;if("string"==typeof e)t=Date.parse(e);else{if("number"!=typeof e)return e;t=e}return new Date(t).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}},e.prototype.registerFunction=function(e,t){this._functions[e]=t},e.prototype.unregisterFunction=function(e){delete this._functions[e]},e.prototype.getFunction=function(t){var n=this._functions[t];return null==n&&(n=e._builtInFunctions[t]),n},e.prototype.isReservedField=function(t){return e._reservedFields.indexOf(t)>=0},e.prototype.saveState=function(){this._stateStack.push({$data:this.$data,$index:this.$index})},e.prototype.restoreLastState=function(){if(0==this._stateStack.length)throw new Error("There is no evaluation context state to restore.");var e=this._stateStack.pop();this.$data=e.$data,this.$index=e.$index},Object.defineProperty(e.prototype,"currentDataContext",{get:function(){return null!=this.$data?this.$data:this.$root},enumerable:!0,configurable:!0}),e._reservedFields=["$data","$root","$index"],e._builtInFunctions={},e}();t.EvaluationContext=p,p.init();var c=function(){},f=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.nodes=[],t.allowNull=!0,t}return o(t,e),t.prototype.evaluate=function(e){for(var t=this.nodes,n=0,r=[["/","*"],["-","+"],["==","!=","<","<=",">",">="]];n<r.length;n++)for(var o=r[n],i=0;i<t.length;){var a=t[i];if(a instanceof v&&o.indexOf(a.operator)>=0){var s=u(t[i-1].evaluate(e)),p=u(t[i+1].evaluate(e));if(typeof s!=typeof p)throw new Error("Incompatible operands "+s+" and "+p+" for operator "+a.operator);var c=void 0;if("number"==typeof s&&"number"==typeof p)switch(a.operator){case"/":c=s/p;break;case"*":c=s*p;break;case"-":c=s-p;break;case"+":c=s+p}if("string"==typeof s&&"string"==typeof p)switch(a.operator){case"+":c=s+p}switch(a.operator){case"==":c=s==p;break;case"!=":c=s!=p;break;case"<":c=s<p;break;case"<=":c=s<=p;break;case">":c=s>p;break;case">=":c=s>=p}t.splice(i-1,3,new y(c)),i--}i++}return t[0].evaluate(e)},t}(c),l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.evaluate=function(e){return this.identifier},t}(c),h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.evaluate=function(e){return this.index.evaluate(e)},t}(c),d=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.functionName=null,t.parameters=[],t}return o(t,e),t.prototype.evaluate=function(e){var t=e.getFunction(this.functionName);if(null!=t){for(var n=[],r=0,o=this.parameters;r<o.length;r++){var i=o[r];n.push(i.evaluate(e))}return t.apply(void 0,n)}throw new Error("Undefined function: "+this.functionName)},t}(c),y=function(e){function t(t){var n=e.call(this)||this;return n.value=t,n}return o(t,e),t.prototype.evaluate=function(e){return this.value},t}(c),v=function(e){function t(t){var n=e.call(this)||this;return n.operator=t,n}return o(t,e),t.prototype.evaluate=function(e){throw new Error("An operator cannot be evaluated on its own.")},t}(c),x=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.parts=[],t}return o(t,e),t.prototype.evaluate=function(e){for(var t=void 0,n=0;n<this.parts.length;){var r=this.parts[n];try{if(r instanceof l&&0==n)switch(r.identifier){case"$root":t=e.$root;break;case"$data":t=e.currentDataContext;break;case"$index":t=e.$index;break;default:t=e.currentDataContext[r.identifier]}else{var o=r.evaluate(e);t=0==n?o:"boolean"!=typeof o?t[o]:t[o.toString()]}}catch(e){return}n++}return t},t}(c),g=function(){function e(e){this._index=0,this._tokens=e}return e.prototype.unexpectedToken=function(){throw new Error("Unexpected token "+this.current.value+" at position "+this.current.originalPosition+".")},e.prototype.unexpectedEoe=function(){throw new Error("Unexpected end of expression.")},e.prototype.moveNext=function(){this._index++},e.prototype.parseToken=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.eoe&&this.unexpectedEoe();var n=this.current;return e.indexOf(this.current.type)<0&&this.unexpectedToken(),this.moveNext(),n},e.prototype.parseOptionalToken=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(!this.eoe)return!(e.indexOf(this.current.type)<0)&&(this.moveNext(),!0);this.unexpectedEoe()},e.prototype.parseFunctionCall=function(e){var t=new d;t.functionName=e,this.parseToken("(");var n=this.parseExpression(),r=!1;if(n){t.parameters.push(n);do{if(r=this.parseOptionalToken(",")){var o=this.parseExpression();t.parameters.push(o)}}while(r)}return this.parseToken(")"),t},e.prototype.parseIdentifier=function(){var e=new l;return e.identifier=this.current.value,this.moveNext(),e},e.prototype.parseIndexer=function(){var e=new h;return this.parseToken("["),e.index=this.parseExpression(),this.parseToken("]"),e},e.prototype.parsePath=function(){for(var e=new x,t=["identifier","("];!this.eoe;){if(t.indexOf(this.current.type)<0)return e;switch(this.current.type){case"(":if(0==e.parts.length)this.moveNext(),e.parts.push(this.parseExpression()),this.parseToken(")");else{for(var n="",r=0,o=e.parts;r<o.length;r++){var i=o[r];i instanceof l||this.unexpectedToken(),""!=n&&(n+="."),n+=i.identifier}e.parts=[],e.parts.push(this.parseFunctionCall(n))}t=[".","["];break;case"[":e.parts.push(this.parseIndexer()),t=[".","(","["];break;case"identifier":e.parts.push(this.parseIdentifier()),t=[".","(","["];break;case".":this.moveNext(),t=["identifier"];break;default:t=[]}}},e.prototype.parseExpression=function(){for(var e=new f,t=a.concat("(","+","-");!this.eoe;){if(t.indexOf(this.current.type)<0)return 0==e.nodes.length&&this.unexpectedToken(),e;switch(this.current.type){case"(":case"identifier":e.nodes.push(this.parsePath()),t=i;break;case"string":case"number":case"boolean":"string"==this.current.type?e.nodes.push(new y(this.current.value)):"number"==this.current.type?e.nodes.push(new y(parseFloat(this.current.value))):e.nodes.push(new y("true"===this.current.value)),this.moveNext(),t=i;break;case"-":0==e.nodes.length?(e.nodes.push(new y(-1)),e.nodes.push(new v("*")),t=["identifier","number","("]):(e.nodes.push(new v(this.current.type)),t=a.concat("(")),this.moveNext();break;case"+":0==e.nodes.length?t=a.concat("("):(e.nodes.push(new v(this.current.type)),t=a.concat("(")),this.moveNext();break;case"*":case"/":case"==":case"!=":case"<":case"<=":case">":case">=":e.nodes.push(new v(this.current.type)),this.moveNext(),t=a.concat("(");break;default:t=[]}}},Object.defineProperty(e.prototype,"eoe",{get:function(){return this._index>=this._tokens.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"current",{get:function(){return this._tokens[this._index]},enumerable:!0,configurable:!0}),e.parseBinding=function(t){var n=new e(s.parse(t));n.parseToken("{");var r=!n.parseOptionalToken("?#"),o=n.parseExpression();return n.parseToken("}"),new b(o,r)},e}();t.ExpressionParser=g;var b=function(){function e(e,t){void 0===t&&(t=!0),this.expression=e,this.allowNull=t}return e.prototype.evaluate=function(e){return this.expression.evaluate(e)},e}();t.Binding=b},function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),r(n(0)),r(n(2))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=function(){function e(){this._parts=[],this._shouldDropOwner=!1}return e.parse=function(t){var n=new e,o=0;do{var i=!1,a=o,s=void 0;do{s=!1,(a=t.indexOf("{",a))>=0&&a+1<t.length&&"{"==t[a+1]&&(a+=2,s=!0)}while(s);if(a>=0){var u=t.indexOf("}",a);if(u>=0){i=!0,a>o&&n._parts.push(t.substring(o,a));var p=t.substring(a,u+1),c=void 0;try{c=r.ExpressionParser.parseBinding(p)}catch(e){c=p}n._parts.push(c),o=u+1}}if(!i){n._parts.push(t.substr(o));break}}while(o<t.length);return 1==n._parts.length&&"string"==typeof n._parts[0]?n._parts[0]:n},e.prototype.evalExpression=function(e,t){var n=e.evaluate(t);return null==n&&(this._shouldDropOwner=this._shouldDropOwner||!e.allowNull),n},e.prototype.internalEvaluate=function(e){if(0!=this._parts.length){if(1==this._parts.length)return"string"==typeof this._parts[0]?this._parts[0]:this.evalExpression(this._parts[0],e);for(var t="",n=0,r=this._parts;n<r.length;n++){var o=r[n];t+="string"==typeof o?o:this.evalExpression(o,e)}return t}},e.prototype.evaluate=function(e){return this._shouldDropOwner=!1,this.internalEvaluate(e)},Object.defineProperty(e.prototype,"shouldDropOwner",{get:function(){return this._shouldDropOwner},enumerable:!0,configurable:!0}),e}(),i=function(){function e(t){this.preparedPayload=e.prepare(t)}return e.prepare=function(t){if("string"==typeof t)return o.parse(t);if("object"==typeof t&&null!=t){if(Array.isArray(t)){for(var n=[],r=0,i=t;r<i.length;r++){var a=i[r];n.push(e.prepare(a))}return n}n={};for(var s=0,u=Object.keys(t);s<u.length;s++){var p=u[s];n[p]=e.prepare(t[p])}return n}return t},e.prototype.expandSingleObject=function(e){for(var t={},n=0,r=Object.keys(e);n<r.length;n++){var o=r[n];if(!this._context.isReservedField(o)){var i=this.internalExpand(e[o]);null!=i&&(t[o]=i)}}return t},e.prototype.internalExpand=function(e){var t;if(this._context.saveState(),Array.isArray(e)){for(var n=[],r=0,i=e;r<i.length;r++){var a=i[r],s=this.internalExpand(a);null!=s&&(Array.isArray(s)?n=n.concat(s):n.push(s))}t=n}else if(e instanceof o)t=e.evaluate(this._context),e.shouldDropOwner&&(t=null);else if("object"==typeof e&&null!=e){var u=!1,p=e.$when;if(p instanceof o){var c=p.evaluate(this._context);"boolean"==typeof c&&(u=!c)}if(u)t=null;else{var f=e.$data;if(null!=f)if(f instanceof o&&(f=f.evaluate(this._context)),Array.isArray(f)){t=[];for(var l=0;l<f.length;l++){this._context.$data=f[l],this._context.$index=l;var h=this.expandSingleObject(e);null!=h&&t.push(h)}}else this._context.$data=f,t=this.expandSingleObject(e);else t=this.expandSingleObject(e)}}else t=e;return this._context.restoreLastState(),t},e.prototype.expand=function(e){return this._context=e,this.internalExpand(this.preparedPayload)},e}();t.Template=i}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ACData=t():e.ACData=t()}(this,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){"use strict";var r,o=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var i=["/","*","-","+","==","!=","<","<=",">",">="],a=["identifier","string","number","boolean"],s=function(){function e(){}return e.init=function(){e.rules.push({tokenType:void 0,regEx:/^\s/},{tokenType:"{",regEx:/^{/},{tokenType:"?#",regEx:/^\?#/},{tokenType:"}",regEx:/^}/},{tokenType:"[",regEx:/^\[/},{tokenType:"]",regEx:/^\]/},{tokenType:"(",regEx:/^\(/},{tokenType:")",regEx:/^\)/},{tokenType:"boolean",regEx:/^true|^false/},{tokenType:"identifier",regEx:/^[$a-z_]+/i},{tokenType:".",regEx:/^\./},{tokenType:",",regEx:/^,/},{tokenType:"+",regEx:/^\+/},{tokenType:"-",regEx:/^-/},{tokenType:"*",regEx:/^\*/},{tokenType:"/",regEx:/^\//},{tokenType:"==",regEx:/^==/},{tokenType:"!=",regEx:/^!=/},{tokenType:"<=",regEx:/^<=/},{tokenType:"<",regEx:/^</},{tokenType:">=",regEx:/^>=/},{tokenType:">",regEx:/^>/},{tokenType:"string",regEx:/^"([^"]*)"/},{tokenType:"string",regEx:/^'([^']*)'/},{tokenType:"number",regEx:/^\d*\.?\d+/})},e.parse=function(t){for(var n=[],r=0;r<t.length;){for(var o=t.substring(r),i=!1,a=0,s=e.rules;a<s.length;a++){var u=s[a],p=u.regEx.exec(o);if(p){if(p.length>2)throw new Error("A tokenizer rule matched more than one group.");null!=u.tokenType&&n.push({type:u.tokenType,value:p[1==p.length?0:1],originalPosition:r}),r+=p[0].length,i=!0;break}}if(!i)throw new Error("Unexpected character "+o[0]+" at position "+r)}return n},e.rules=[],e}();function u(e){if("number"==typeof e||"string"==typeof e||"boolean"==typeof e)return e;throw new Error("Invalid value type: "+typeof e)}s.init();var p=function(){function e(){this._functions={},this._stateStack=[]}return e.init=function(){e._builtInFunctions.substr=function(e,t,n){return"string"==typeof e&&"number"==typeof t&&"number"==typeof n?e.substr(t,n):""},e._builtInFunctions["JSON.parse"]=function(e){return JSON.parse(e)},e._builtInFunctions.if=function(e,t,n){return e?t:n},e._builtInFunctions.toUpper=function(e){return"string"==typeof e?e.toUpperCase():e},e._builtInFunctions.toLower=function(e){return"string"==typeof e?e.toLowerCase():e},e._builtInFunctions["Date.format"]=function(e,t){var n;if("string"==typeof e)n=Date.parse(e);else{if("number"!=typeof e)return e;n=e}var r=new Date(n),o="compact";return"string"==typeof t&&(o=t.toLowerCase(),["long","short","compact"].indexOf(o)<0&&(o="compact")),"compact"===o?r.toLocaleDateString():r.toLocaleDateString(void 0,{day:"numeric",weekday:o,month:o,year:"numeric"})},e._builtInFunctions["Time.format"]=function(e){var t;if("string"==typeof e)t=Date.parse(e);else{if("number"!=typeof e)return e;t=e}return new Date(t).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}},e.prototype.registerFunction=function(e,t){this._functions[e]=t},e.prototype.unregisterFunction=function(e){delete this._functions[e]},e.prototype.getFunction=function(t){var n=this._functions[t];return null==n&&(n=e._builtInFunctions[t]),n},e.prototype.isReservedField=function(t){return e._reservedFields.indexOf(t)>=0},e.prototype.saveState=function(){this._stateStack.push({$data:this.$data,$index:this.$index})},e.prototype.restoreLastState=function(){if(0==this._stateStack.length)throw new Error("There is no evaluation context state to restore.");var e=this._stateStack.pop();this.$data=e.$data,this.$index=e.$index},Object.defineProperty(e.prototype,"currentDataContext",{get:function(){return null!=this.$data?this.$data:this.$root},enumerable:!0,configurable:!0}),e._reservedFields=["$data","$root","$index"],e._builtInFunctions={},e}();t.EvaluationContext=p,p.init();var c=function(){},f=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.nodes=[],t.allowNull=!0,t}return o(t,e),t.prototype.evaluate=function(e){for(var t=this.nodes,n=0,r=[["/","*"],["-","+"],["==","!=","<","<=",">",">="]];n<r.length;n++)for(var o=r[n],i=0;i<t.length;){var a=t[i];if(a instanceof v&&o.indexOf(a.operator)>=0){var s=u(t[i-1].evaluate(e)),p=u(t[i+1].evaluate(e));if(typeof s!=typeof p)throw new Error("Incompatible operands "+s+" and "+p+" for operator "+a.operator);var c=void 0;if("number"==typeof s&&"number"==typeof p)switch(a.operator){case"/":c=s/p;break;case"*":c=s*p;break;case"-":c=s-p;break;case"+":c=s+p}if("string"==typeof s&&"string"==typeof p)switch(a.operator){case"+":c=s+p}switch(a.operator){case"==":c=s==p;break;case"!=":c=s!=p;break;case"<":c=s<p;break;case"<=":c=s<=p;break;case">":c=s>p;break;case">=":c=s>=p}t.splice(i-1,3,new y(c)),i--}i++}return t[0].evaluate(e)},t}(c),l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.evaluate=function(e){return this.identifier},t}(c),h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.evaluate=function(e){return this.index.evaluate(e)},t}(c),d=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.functionName=null,t.parameters=[],t}return o(t,e),t.prototype.evaluate=function(e){var t=e.getFunction(this.functionName);if(null!=t){for(var n=[],r=0,o=this.parameters;r<o.length;r++){var i=o[r];n.push(i.evaluate(e))}return t.apply(void 0,n)}throw new Error("Undefined function: "+this.functionName)},t}(c),y=function(e){function t(t){var n=e.call(this)||this;return n.value=t,n}return o(t,e),t.prototype.evaluate=function(e){return this.value},t}(c),v=function(e){function t(t){var n=e.call(this)||this;return n.operator=t,n}return o(t,e),t.prototype.evaluate=function(e){throw new Error("An operator cannot be evaluated on its own.")},t}(c),x=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.parts=[],t}return o(t,e),t.prototype.evaluate=function(e){for(var t=void 0,n=0;n<this.parts.length;){var r=this.parts[n];try{if(r instanceof l&&0==n)switch(r.identifier){case"$root":t=e.$root;break;case"$data":t=e.currentDataContext;break;case"$index":t=e.$index;break;default:t=e.currentDataContext[r.identifier]}else{var o=r.evaluate(e);t=0==n?o:"boolean"!=typeof o?t[o]:t[o.toString()]}}catch(e){return}n++}return t},t}(c),g=function(){function e(e){this._index=0,this._tokens=e}return e.prototype.unexpectedToken=function(){throw new Error("Unexpected token "+this.current.value+" at position "+this.current.originalPosition+".")},e.prototype.unexpectedEoe=function(){throw new Error("Unexpected end of expression.")},e.prototype.moveNext=function(){this._index++},e.prototype.parseToken=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.eoe&&this.unexpectedEoe();var n=this.current;return e.indexOf(this.current.type)<0&&this.unexpectedToken(),this.moveNext(),n},e.prototype.parseOptionalToken=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(!this.eoe)return!(e.indexOf(this.current.type)<0)&&(this.moveNext(),!0);this.unexpectedEoe()},e.prototype.parseFunctionCall=function(e){var t=new d;t.functionName=e,this.parseToken("(");var n=this.parseExpression(),r=!1;if(n){t.parameters.push(n);do{if(r=this.parseOptionalToken(",")){var o=this.parseExpression();t.parameters.push(o)}}while(r)}return this.parseToken(")"),t},e.prototype.parseIdentifier=function(){var e=new l;return e.identifier=this.current.value,this.moveNext(),e},e.prototype.parseIndexer=function(){var e=new h;return this.parseToken("["),e.index=this.parseExpression(),this.parseToken("]"),e},e.prototype.parsePath=function(){for(var e=new x,t=["identifier","("];!this.eoe;){if(t.indexOf(this.current.type)<0)return e;switch(this.current.type){case"(":if(0==e.parts.length)this.moveNext(),e.parts.push(this.parseExpression()),this.parseToken(")");else{for(var n="",r=0,o=e.parts;r<o.length;r++){var i=o[r];i instanceof l||this.unexpectedToken(),""!=n&&(n+="."),n+=i.identifier}e.parts=[],e.parts.push(this.parseFunctionCall(n))}t=[".","["];break;case"[":e.parts.push(this.parseIndexer()),t=[".","(","["];break;case"identifier":e.parts.push(this.parseIdentifier()),t=[".","(","["];break;case".":this.moveNext(),t=["identifier"];break;default:t=[]}}},e.prototype.parseExpression=function(){for(var e=new f,t=a.concat("(","+","-");!this.eoe;){if(t.indexOf(this.current.type)<0)return 0==e.nodes.length&&this.unexpectedToken(),e;switch(this.current.type){case"(":case"identifier":e.nodes.push(this.parsePath()),t=i;break;case"string":case"number":case"boolean":"string"==this.current.type?e.nodes.push(new y(this.current.value)):"number"==this.current.type?e.nodes.push(new y(parseFloat(this.current.value))):e.nodes.push(new y("true"===this.current.value)),this.moveNext(),t=i;break;case"-":0==e.nodes.length?(e.nodes.push(new y(-1)),e.nodes.push(new v("*")),t=["identifier","number","("]):(e.nodes.push(new v(this.current.type)),t=a.concat("(")),this.moveNext();break;case"+":0==e.nodes.length?t=a.concat("("):(e.nodes.push(new v(this.current.type)),t=a.concat("(")),this.moveNext();break;case"*":case"/":case"==":case"!=":case"<":case"<=":case">":case">=":e.nodes.push(new v(this.current.type)),this.moveNext(),t=a.concat("(");break;default:t=[]}}},Object.defineProperty(e.prototype,"eoe",{get:function(){return this._index>=this._tokens.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"current",{get:function(){return this._tokens[this._index]},enumerable:!0,configurable:!0}),e.parseBinding=function(t){var n=new e(s.parse(t));n.parseToken("{");var r=!n.parseOptionalToken("?#"),o=n.parseExpression();return n.parseToken("}"),new b(o,r)},e}();t.ExpressionParser=g;var b=function(){function e(e,t){void 0===t&&(t=!0),this.expression=e,this.allowNull=t}return e.prototype.evaluate=function(e){return this.expression.evaluate(e)},e}();t.Binding=b},function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),r(n(0)),r(n(2))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),o=function(){function e(){this._parts=[],this._shouldDropOwner=!1}return e.parse=function(t){var n=new e,o=0;do{var i=!1,a=o,s=void 0;do{s=!1,(a=t.indexOf("{",a))>=0&&a+1<t.length&&"{"==t[a+1]&&(a+=2,s=!0)}while(s);if(a>=0){var u=t.indexOf("}",a);if(u>=0){i=!0,a>o&&n._parts.push(t.substring(o,a));var p=t.substring(a,u+1),c=void 0;try{c=r.ExpressionParser.parseBinding(p)}catch(e){c=p}n._parts.push(c),o=u+1}}if(!i){n._parts.push(t.substr(o));break}}while(o<t.length);return 1==n._parts.length&&"string"==typeof n._parts[0]?n._parts[0]:n},e.prototype.evalExpression=function(e,t){var n=e.evaluate(t);return null==n&&(this._shouldDropOwner=this._shouldDropOwner||!e.allowNull),n},e.prototype.internalEvaluate=function(e){if(0!=this._parts.length){if(1==this._parts.length)return"string"==typeof this._parts[0]?this._parts[0]:this.evalExpression(this._parts[0],e);for(var t="",n=0,r=this._parts;n<r.length;n++){var o=r[n];t+="string"==typeof o?o:this.evalExpression(o,e)}return t}},e.prototype.evaluate=function(e){return this._shouldDropOwner=!1,this.internalEvaluate(e)},Object.defineProperty(e.prototype,"shouldDropOwner",{get:function(){return this._shouldDropOwner},enumerable:!0,configurable:!0}),e}();t.TemplatizedString=o;var i=function(){function e(t){this.preparedPayload=e.prepare(t)}return e.prepare=function(t){if("string"==typeof t)return o.parse(t);if("object"==typeof t&&null!=t){if(Array.isArray(t)){for(var n=[],r=0,i=t;r<i.length;r++){var a=i[r];n.push(e.prepare(a))}return n}n={};for(var s=0,u=Object.keys(t);s<u.length;s++){var p=u[s];n[p]=e.prepare(t[p])}return n}return t},e.prototype.expandSingleObject=function(e){for(var t={},n=0,r=Object.keys(e);n<r.length;n++){var o=r[n];if(!this._context.isReservedField(o)){var i=this.internalExpand(e[o]);null!=i&&(t[o]=i)}}return t},e.prototype.internalExpand=function(e){var t;if(this._context.saveState(),Array.isArray(e)){for(var n=[],r=0,i=e;r<i.length;r++){var a=i[r],s=this.internalExpand(a);null!=s&&(Array.isArray(s)?n=n.concat(s):n.push(s))}t=n}else if(e instanceof o)t=e.evaluate(this._context),e.shouldDropOwner&&(t=null);else if("object"==typeof e&&null!=e){var u=!1,p=e.$when;if(p instanceof o){var c=p.evaluate(this._context);"boolean"==typeof c&&(u=!c)}if(u)t=null;else{var f=e.$data;if(null!=f)if(f instanceof o&&(f=f.evaluate(this._context)),Array.isArray(f)){t=[];for(var l=0;l<f.length;l++){this._context.$data=f[l],this._context.$index=l;var h=this.expandSingleObject(e);null!=h&&t.push(h)}}else this._context.$data=f,t=this.expandSingleObject(e);else t=this.expandSingleObject(e)}}else t=e;return this._context.restoreLastState(),t},e.prototype.expand=function(e){return this._context=e,this.internalExpand(this.preparedPayload)},e}();t.Template=i}])});
//# sourceMappingURL=adaptivecards-templating.min.js.map
import { EvaluationContext } from "./expression-parser";
export declare class TemplatizedString {
private _parts;
static parse(s: string): string | TemplatizedString;
private _shouldDropOwner;
private evalExpression;
private internalEvaluate;
evaluate(context: EvaluationContext): any;
readonly shouldDropOwner: boolean;
}
export declare class Template {

@@ -3,0 +12,0 @@ private static prepare;

@@ -105,2 +105,3 @@ "use strict";

}());
exports.TemplatizedString = TemplatizedString;
var Template = /** @class */ (function () {

@@ -107,0 +108,0 @@ function Template(payload) {

{
"name": "adaptivecards-templating",
"version": "0.1.1-alpha.0",
"version": "0.1.2-alpha.0",
"description": "Adaptive Card data binding and templating engine for JavaScript",

@@ -31,3 +31,4 @@ "author": "AdaptiveCards",

"webpack-dev-server": "^3.7.2"
}
},
"gitHead": "345a433b9ef6ccc5b4c520433238de3f5d976fae"
}

@@ -37,3 +37,3 @@ # Adaptive Card Data Binding and Templating Engine for JavaScript (Preview)

<!-- Option 2: load a specific version (e.g, 0.1.0-alpha1) -->
<script src="https://unpkg.com/adaptivecards@0.1.0-alpha1/dist/adaptivecards-templating.min.js"></script>
<script src="https://unpkg.com/adaptivecards-templating@0.1.0-alpha1/dist/adaptivecards-templating.min.js"></script>
```

@@ -65,3 +65,3 @@

// Create a Template instamce from the template payload
// Create a Template instance from the template payload
var template = new ACData.Template(templatePayload);

@@ -68,0 +68,0 @@

@@ -5,3 +5,3 @@ // Copyright (c) Microsoft Corporation. All rights reserved.

class TemplatizedString {
export class TemplatizedString {
private _parts: Array<string | Binding> = [];

@@ -17,3 +17,3 @@

let loop;
do {

@@ -273,2 +273,2 @@ loop = false;

}
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc