@vertesia/jst 1.3.0-dev.20260620.061059Z → 1.3.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/lib/vertesia-jst.js +1 -1
- package/lib/vertesia-jst.js.map +1 -1
- package/package.json +4 -4
package/lib/vertesia-jst.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"handlebars";import{parse as r}from"acorn";import{recursive as t,base as n}from"acorn-walk";import o from"dayjs";import s from"papaparse";function i(r,t){return e.compile(r)(t)}e.registerHelper("_now",()=>(new Date).toISOString()),e.registerHelper("stringify",r=>null==r?"":"string"==typeof r?r:new e.SafeString(JSON.stringify(r)));const a=n,p={line:0,column:0};class l extends Error{node;constructor(e,r){super(e),this.node=r,this.name="ValidationError"}get range(){const e=this.node.loc;return e?[e.start,e.end]:[p,p]}get start(){return this.node.loc?.start||p}get end(){return this.node.loc?.end||p}get location(){return this.node.loc?`${this.node.loc.start.line}:${this.node.loc.start.column}`:`${this.node.range}`}}class c{name;node;parent;errors;children=[];locals=new Set;constructor(e,r,t){this.name=e,this.node=r,this.parent=t,t?.children.push(this),this.errors=t?t.errors:[],r.$scope=this}define(e){this.locals.add(e)}isDefined(e){return!!this.locals.has(e)||!!this.parent&&this.parent.isDefined(e)}pushError(e,r){this.errors.push(new l(e,r))}hasErrors(){return this.errors.length>0}get ok(){return 0===this.errors.length}print(){console.log(this.name,"=>",this.locals);for(const e of this.children)e.print()}}function d(e){e.___safe_identifier=!0}function u(e){return!!e.___safe_identifier}const f={ecmaVersion:2020,sourceType:"script"};function m(e,n){const o=n.acorn?{...f,...n.acorn}:f,s=r(e,o),i=new c("#root",s,null);if(n.globals){for(const e of n.globals)i.locals.add(e);s.$scope=i}const p=new Set(n.propsBlacklist?n.propsBlacklist:["constructor","prototype","__proto__"]);return t(s,i,{WithStatement(e,r,t){r.pushError('"with" keyword is not supported',e),a.WithStatement(e,r,t)},ForStatement(e,r,t){r.pushError('"for" keyword is not supported',e),a.ForStatement(e,r,t)},WhileStatement(e,r,t){r.pushError('"while" keyword is not supported',e),a.WhileStatement(e,r,t)},ImportExpression(e,r,t){r.pushError('"import" keyword is not supported',e),a.ImportExpression(e,r,t)},ImportDeclaration(e,r,t){r.pushError('"import" keyword is not supported',e),a.ImportDeclaration(e,r,t)},Class(e,r,t){r.pushError("Classes are not supported",e),a.Class(e,r,t)},ThisExpression(e,r,t){n.allowThis||r.pushError('"this" keyword is not supported',e),a.ThisExpression(e,r,t)},ObjectPattern(e,r,t){for(const t of e.properties)"Property"===t.type?"Identifier"===t.key.type&&(d(t.key),"init"===t.kind&&p.has(t.key.name)&&r.pushError(`Property "${t.key.name}" is not allowed`,t.key)):"RestElement"===t.type&&"Identifier"===t.argument.type&&d(t.argument);a.ObjectPattern(e,r,t)},ArrayPattern(e,r,t){for(const r of e.elements)r&&("Identifier"===r.type?d(r):"RestElement"===r.type&&"Identifier"===r.argument.type&&d(r.argument));a.ArrayPattern(e,r,t)},MemberExpression(e,r,t){const n=e.property;"Identifier"===n.type?(d(n),p.has(n.name)&&r.pushError(`Property "${n.name}" is not allowed`,n)):"Literal"===n.type?p.has(String(n.value))&&r.pushError(`Property "${n.value}" is not allowed`,n):r.pushError("Dynamic property lookup is not supported",n),a.MemberExpression(e,r,t)},Function(e,r,t){const n=e.id?.name;n&&r.define(n);const o=new c(n||"#anonymous",e,r);!function(e,r){for(const t of e.params)"Identifier"===t.type?(r.locals.add(t.name),d(t)):"AssignmentPattern"===t.type?"Identifier"===t.left.type&&(r.locals.add(t.left.name),d(t.left)):"RestElement"===t.type&&"Identifier"===t.argument.type&&(r.locals.add(t.argument.name),d(t.argument))}(e,o),a.Function(e,o,t)},VariableDeclaration(e,r,t){for(const t of e.declarations)if("Identifier"===t.id.type)d(t.id),r.define(t.id.name);else if("ObjectPattern"===t.id.type)for(const e of t.id.properties)"Property"===e.type?"Identifier"===e.value.type&&r.define(e.value.name):"RestElement"===e.type&&"Identifier"===e.argument.type&&r.define(e.argument.name);else if("ArrayPattern"===t.id.type)for(const e of t.id.elements)"Identifier"===e.type?r.define(e.name):"RestElement"===e.type&&"Identifier"===e.argument.type&&r.define(e.argument.name);a.VariableDeclaration(e,r,t)}}),{root:i,program:s}}function h(e,r={}){const{root:n,program:o}=m(e,r);return t(o,n,{Function(e,r,t){a.Function(e,e.$scope||r,t)},Identifier(e,r,t){const n=e;u(e)||r.isDefined(n.name)||r.pushError(`Unknown identifier "${n.name}"`,e),a.Identifier(e,r,t)}}),n}function y(e,r={}){const{root:n,program:o}=m(e,r),s=new Set;return t(o,n,{Function(e,r,t){a.Function(e,e.$scope||r,t)},Identifier(e,r,t){const n=e;u(e)||r.isDefined(n.name)||s.add(n.name),a.Identifier(e,r,t)}}),{vars:s,errors:n.errors}}class g extends Error{errors;constructor(e,r){super(`${r||"Composite Error"}\n${e.map(e=>e.message).join("\n* ")}`),this.errors=e,this.errors=e,this.name="CompositeError"}}class E{code;globals;fn;constructor(e,r){this.code=e,this.globals=r;const t=r&&r.length>0?`{${r.join(",")}}`:"";this.fn=new Function(t,`return (function(){"use strict";${e}})()`)}validate(e={}){return h(this.code,Object.assign({globals:this.globals},e))}run(e){return this.fn(e)}}function w(e){const r=e.split("\n"),t=Math.ceil(Math.log10(r.length));return r.map((e,r)=>`{% ${(r+1).toString().padStart(t," ")} %} ${e}`).join("\n")}function I(e,r={}){return s.parse(e,r)}function S(e,r={}){return s.unparse(e,r)}class k extends E{constructor(e,r){super(e,r.concat("_","Array","Set"))}validate(){return super.validate({acorn:{allowReturnOutsideFunction:!0,locations:!0}})}run(e){return super.run({...e,Set:Set,Array:Array})}}function $(e,r,t){const n=new k(e,r),s=n.validate();if(s.hasErrors())throw new g(s.errors,"Validation errors");return n.run({...t,_:{loadCsv:I,jsonToCsv:S,stringify:JSON.stringify,addLineNumbers:w,dayjs:o}})}export{k as CompiledTemplate,g as CompositeError,c as Scope,E as Script,l as ValidationError,y as getFreeVariables,i as renderHandlebarsTemplate,$ as renderJsTemplate,h as validate};
|
|
1
|
+
import e from"handlebars";import{parse as r}from"acorn";import{recursive as t,base as n}from"acorn-walk";import o from"dayjs";import s from"papaparse";function i(r,t){return e.compile(r)(t)}e.registerHelper("_now",(()=>(new Date).toISOString())),e.registerHelper("stringify",(r=>null==r?"":"string"==typeof r?r:new e.SafeString(JSON.stringify(r))));const a=n,p={line:0,column:0};class l extends Error{node;constructor(e,r){super(e),this.node=r,this.name="ValidationError"}get range(){const e=this.node.loc;return e?[e.start,e.end]:[p,p]}get start(){return this.node.loc?.start||p}get end(){return this.node.loc?.end||p}get location(){return this.node.loc?`${this.node.loc.start.line}:${this.node.loc.start.column}`:`${this.node.range}`}}class c{name;node;parent;errors;children=[];locals=new Set;constructor(e,r,t){this.name=e,this.node=r,this.parent=t,t?.children.push(this),this.errors=t?t.errors:[],r.$scope=this}define(e){this.locals.add(e)}isDefined(e){return!!this.locals.has(e)||!!this.parent&&this.parent.isDefined(e)}pushError(e,r){this.errors.push(new l(e,r))}hasErrors(){return this.errors.length>0}get ok(){return 0===this.errors.length}print(){console.log(this.name,"=>",this.locals);for(const e of this.children)e.print()}}function d(e){e.___safe_identifier=!0}function u(e){return!!e.___safe_identifier}const f={ecmaVersion:2020,sourceType:"script"};function m(e,n){const o=n.acorn?{...f,...n.acorn}:f,s=r(e,o),i=new c("#root",s,null);if(n.globals){for(const e of n.globals)i.locals.add(e);s.$scope=i}const p=new Set(n.propsBlacklist?n.propsBlacklist:["constructor","prototype","__proto__"]);return t(s,i,{WithStatement(e,r,t){r.pushError('"with" keyword is not supported',e),a.WithStatement(e,r,t)},ForStatement(e,r,t){r.pushError('"for" keyword is not supported',e),a.ForStatement(e,r,t)},WhileStatement(e,r,t){r.pushError('"while" keyword is not supported',e),a.WhileStatement(e,r,t)},ImportExpression(e,r,t){r.pushError('"import" keyword is not supported',e),a.ImportExpression(e,r,t)},ImportDeclaration(e,r,t){r.pushError('"import" keyword is not supported',e),a.ImportDeclaration(e,r,t)},Class(e,r,t){r.pushError("Classes are not supported",e),a.Class(e,r,t)},ThisExpression(e,r,t){n.allowThis||r.pushError('"this" keyword is not supported',e),a.ThisExpression(e,r,t)},ObjectPattern(e,r,t){for(const t of e.properties)"Property"===t.type?"Identifier"===t.key.type&&(d(t.key),"init"===t.kind&&p.has(t.key.name)&&r.pushError(`Property "${t.key.name}" is not allowed`,t.key)):"RestElement"===t.type&&"Identifier"===t.argument.type&&d(t.argument);a.ObjectPattern(e,r,t)},ArrayPattern(e,r,t){for(const r of e.elements)r&&("Identifier"===r.type?d(r):"RestElement"===r.type&&"Identifier"===r.argument.type&&d(r.argument));a.ArrayPattern(e,r,t)},MemberExpression(e,r,t){const n=e.property;"Identifier"===n.type?(d(n),p.has(n.name)&&r.pushError(`Property "${n.name}" is not allowed`,n)):"Literal"===n.type?p.has(String(n.value))&&r.pushError(`Property "${n.value}" is not allowed`,n):r.pushError("Dynamic property lookup is not supported",n),a.MemberExpression(e,r,t)},Function(e,r,t){const n=e.id?.name;n&&r.define(n);const o=new c(n||"#anonymous",e,r);!function(e,r){for(const t of e.params)"Identifier"===t.type?(r.locals.add(t.name),d(t)):"AssignmentPattern"===t.type?"Identifier"===t.left.type&&(r.locals.add(t.left.name),d(t.left)):"RestElement"===t.type&&"Identifier"===t.argument.type&&(r.locals.add(t.argument.name),d(t.argument))}(e,o),a.Function(e,o,t)},VariableDeclaration(e,r,t){for(const t of e.declarations)if("Identifier"===t.id.type)d(t.id),r.define(t.id.name);else if("ObjectPattern"===t.id.type)for(const e of t.id.properties)"Property"===e.type?"Identifier"===e.value.type&&r.define(e.value.name):"RestElement"===e.type&&"Identifier"===e.argument.type&&r.define(e.argument.name);else if("ArrayPattern"===t.id.type)for(const e of t.id.elements)"Identifier"===e.type?r.define(e.name):"RestElement"===e.type&&"Identifier"===e.argument.type&&r.define(e.argument.name);a.VariableDeclaration(e,r,t)}}),{root:i,program:s}}function h(e,r={}){const{root:n,program:o}=m(e,r);return t(o,n,{Function(e,r,t){a.Function(e,e.$scope||r,t)},Identifier(e,r,t){const n=e;u(e)||r.isDefined(n.name)||r.pushError(`Unknown identifier "${n.name}"`,e),a.Identifier(e,r,t)}}),n}function y(e,r={}){const{root:n,program:o}=m(e,r),s=new Set;return t(o,n,{Function(e,r,t){a.Function(e,e.$scope||r,t)},Identifier(e,r,t){const n=e;u(e)||r.isDefined(n.name)||s.add(n.name),a.Identifier(e,r,t)}}),{vars:s,errors:n.errors}}class g extends Error{errors;constructor(e,r){super(`${r||"Composite Error"}\n${e.map((e=>e.message)).join("\n* ")}`),this.errors=e,this.errors=e,this.name="CompositeError"}}class E{code;globals;fn;constructor(e,r){this.code=e,this.globals=r;const t=r&&r.length>0?`{${r.join(",")}}`:"";this.fn=new Function(t,`return (function(){"use strict";${e}})()`)}validate(e={}){return h(this.code,Object.assign({globals:this.globals},e))}run(e){return this.fn(e)}}function w(e){const r=e.split("\n"),t=Math.ceil(Math.log10(r.length));return r.map(((e,r)=>`{% ${(r+1).toString().padStart(t," ")} %} ${e}`)).join("\n")}function I(e,r={}){return s.parse(e,r)}function S(e,r={}){return s.unparse(e,r)}class k extends E{constructor(e,r){super(e,r.concat("_","Array","Set"))}validate(){return super.validate({acorn:{allowReturnOutsideFunction:!0,locations:!0}})}run(e){return super.run({...e,Set:Set,Array:Array})}}function $(e,r,t){const n=new k(e,r),s=n.validate();if(s.hasErrors())throw new g(s.errors,"Validation errors");return n.run({...t,_:{loadCsv:I,jsonToCsv:S,stringify:JSON.stringify,addLineNumbers:w,dayjs:o}})}export{k as CompiledTemplate,g as CompositeError,c as Scope,E as Script,l as ValidationError,y as getFreeVariables,i as renderHandlebarsTemplate,$ as renderJsTemplate,h as validate};
|
|
2
2
|
//# sourceMappingURL=vertesia-jst.js.map
|
package/lib/vertesia-jst.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vertesia-jst.js","sources":["handlebars/index.js","validation.js","script.js","functions/addLineNumbers.js","functions/csv.js","template.js"],"sourcesContent":["import Handlebars from 'handlebars';\nHandlebars.registerHelper('_now', () => new Date().toISOString());\nHandlebars.registerHelper('stringify', (value) => {\n if (value === null || value === undefined)\n return '';\n if (typeof value === 'string')\n return value;\n return new Handlebars.SafeString(JSON.stringify(value));\n});\nexport function renderHandlebarsTemplate(template, input) {\n // lazy load handlebars to speed up initial loading\n const compiled = Handlebars.compile(template);\n return compiled(input);\n}\n//# sourceMappingURL=index.js.map","import { parse, } from 'acorn';\nimport { base as baseV, recursive as recursiveWalk } from 'acorn-walk';\nconst baseVisitor = baseV;\nconst UnknownPosition = {\n line: 0,\n column: 0,\n};\nexport class ValidationError extends Error {\n node;\n constructor(message, node) {\n super(message);\n this.node = node;\n this.name = 'ValidationError';\n }\n get range() {\n const loc = this.node.loc;\n return loc ? [loc.start, loc.end] : [UnknownPosition, UnknownPosition];\n }\n get start() {\n return this.node.loc?.start || UnknownPosition;\n }\n get end() {\n return this.node.loc?.end || UnknownPosition;\n }\n get location() {\n if (this.node.loc) {\n return `${this.node.loc.start.line}:${this.node.loc.start.column}`;\n }\n else {\n return `${this.node.range}`;\n }\n }\n}\nexport class Scope {\n name;\n node;\n parent;\n errors;\n children = [];\n locals = new Set();\n constructor(name, node, parent) {\n this.name = name;\n this.node = node;\n this.parent = parent;\n parent?.children.push(this);\n this.errors = parent ? parent.errors : [];\n node.$scope = this;\n }\n define(name) {\n this.locals.add(name);\n }\n isDefined(name) {\n if (this.locals.has(name)) {\n return true;\n }\n if (this.parent) {\n return this.parent.isDefined(name);\n }\n return false;\n }\n pushError(message, node) {\n this.errors.push(new ValidationError(message, node));\n }\n hasErrors() {\n return this.errors.length > 0;\n }\n get ok() {\n return this.errors.length === 0;\n }\n print() {\n console.log(this.name, '=>', this.locals);\n for (const child of this.children) {\n child.print();\n }\n }\n}\nfunction addFunctionParams(node, scope) {\n for (const param of node.params) {\n if (param.type === 'Identifier') {\n scope.locals.add(param.name);\n markSafeIdentifier(param);\n }\n else if (param.type === 'AssignmentPattern') {\n if (param.left.type === 'Identifier') {\n scope.locals.add(param.left.name);\n markSafeIdentifier(param.left);\n }\n }\n else if (param.type === 'RestElement') {\n if (param.argument.type === 'Identifier') {\n scope.locals.add(param.argument.name);\n markSafeIdentifier(param.argument);\n }\n }\n }\n}\nfunction markSafeIdentifier(node) {\n node.___safe_identifier = true;\n}\nfunction isSafeIdentifier(node) {\n return !!node.___safe_identifier;\n}\nconst defaultAcornOpts = {\n ecmaVersion: 2020,\n sourceType: 'script',\n};\n/**\n * Parse `code` and build the scope tree (one full AST walk). The returned root scope\n * has `locals` populated for every nested function/block and has unsafe-construct\n * errors accumulated in `root.errors`. Identifier resolution (the \"Unknown identifier\"\n * check) is a separate second walk done by `validate` / `getFreeVariables`.\n */\nfunction buildScopeTree(code, opts) {\n const acornOpts = opts.acorn ? { ...defaultAcornOpts, ...opts.acorn } : defaultAcornOpts;\n const program = parse(code, acornOpts);\n const root = new Scope('#root', program, null);\n if (opts.globals) {\n for (const identifier of opts.globals) {\n root.locals.add(identifier);\n }\n program.$scope = root;\n }\n const propsBlacklist = new Set(opts.propsBlacklist ? opts.propsBlacklist : ['constructor', 'prototype', '__proto__']);\n recursiveWalk(program, root, {\n WithStatement(node, state, c) {\n state.pushError('\"with\" keyword is not supported', node);\n baseVisitor.WithStatement(node, state, c);\n },\n ForStatement(node, state, c) {\n state.pushError('\"for\" keyword is not supported', node);\n baseVisitor.ForStatement(node, state, c);\n },\n WhileStatement(node, state, c) {\n state.pushError('\"while\" keyword is not supported', node);\n baseVisitor.WhileStatement(node, state, c);\n },\n ImportExpression(node, state, c) {\n state.pushError('\"import\" keyword is not supported', node);\n baseVisitor.ImportExpression(node, state, c);\n },\n ImportDeclaration(node, state, c) {\n state.pushError('\"import\" keyword is not supported', node);\n baseVisitor.ImportDeclaration(node, state, c);\n },\n Class(node, state, c) {\n state.pushError('Classes are not supported', node);\n baseVisitor.Class(node, state, c);\n },\n ThisExpression(node, state, c) {\n if (!opts.allowThis) {\n state.pushError('\"this\" keyword is not supported', node);\n }\n baseVisitor.ThisExpression(node, state, c);\n },\n ObjectPattern(node, state, c) {\n for (const prop of node.properties) {\n if (prop.type === 'Property') {\n if (prop.key.type === 'Identifier') {\n markSafeIdentifier(prop.key);\n if (prop.kind === 'init' && propsBlacklist.has(prop.key.name)) {\n state.pushError(`Property \"${prop.key.name}\" is not allowed`, prop.key);\n }\n }\n }\n else if (prop.type === 'RestElement') {\n if (prop.argument.type === 'Identifier') {\n markSafeIdentifier(prop.argument);\n }\n }\n }\n baseVisitor.ObjectPattern(node, state, c);\n },\n ArrayPattern(node, state, c) {\n for (const prop of node.elements) {\n if (prop) {\n if (prop.type === 'Identifier') {\n markSafeIdentifier(prop);\n //TODO is this really needed?\n // if (propBlacklist.has(prop.name)) {\n // state.pushError(`Property \"${prop.name}\" is not allowed`, prop);\n // }\n }\n else if (prop.type === 'RestElement') {\n if (prop.argument.type === 'Identifier') {\n markSafeIdentifier(prop.argument);\n }\n }\n }\n }\n baseVisitor.ArrayPattern(node, state, c);\n },\n MemberExpression(node, state, c) {\n const prop = node.property;\n if (prop.type === 'Identifier') {\n markSafeIdentifier(prop);\n if (propsBlacklist.has(prop.name)) {\n state.pushError(`Property \"${prop.name}\" is not allowed`, prop);\n }\n }\n else if (prop.type === 'Literal') {\n if (propsBlacklist.has(String(prop.value))) {\n state.pushError(`Property \"${prop.value}\" is not allowed`, prop);\n }\n }\n else {\n state.pushError('Dynamic property lookup is not supported', prop);\n }\n baseVisitor.MemberExpression(node, state, c);\n },\n Function(node, state, c) {\n const name = node.id?.name;\n if (name) {\n // arrow functions have no name\n state.define(name);\n }\n const scope = new Scope(name || '#anonymous', node, state);\n addFunctionParams(node, scope);\n baseVisitor.Function(node, scope, c);\n },\n VariableDeclaration(node, state, c) {\n for (const decl of node.declarations) {\n if (decl.id.type === 'Identifier') {\n markSafeIdentifier(decl.id);\n state.define(decl.id.name);\n }\n else if (decl.id.type === 'ObjectPattern') {\n //the ObjectPattern rule will call markSafeIdentifier\n for (const prop of decl.id.properties) {\n if (prop.type === 'Property') {\n if (prop.value.type === 'Identifier')\n state.define(prop.value.name);\n }\n else if (prop.type === 'RestElement') {\n if (prop.argument.type === 'Identifier')\n state.define(prop.argument.name);\n }\n }\n }\n else if (decl.id.type === 'ArrayPattern') {\n //the ArrayPattern rule will call markSafeIdentifier\n for (const prop of decl.id.elements) {\n if (prop.type === 'Identifier') {\n state.define(prop.name);\n }\n else if (prop.type === 'RestElement') {\n if (prop.argument.type === 'Identifier')\n state.define(prop.argument.name);\n }\n }\n }\n }\n baseVisitor.VariableDeclaration(node, state, c);\n },\n });\n return { root, program };\n}\nexport function validate(code, opts = {}) {\n const { root, program } = buildScopeTree(code, opts);\n recursiveWalk(program, root, {\n Function(node, state, c) {\n baseVisitor.Function(node, node.$scope || state, c);\n },\n Identifier(node, state, c) {\n const identifier = node;\n if (!isSafeIdentifier(node) && !state.isDefined(identifier.name)) {\n state.pushError(`Unknown identifier \"${identifier.name}\"`, node);\n }\n baseVisitor.Identifier(node, state, c);\n },\n });\n return root;\n}\n/**\n * Walk `code` and return every identifier that is referenced but not bound by any\n * enclosing function/variable declaration and not listed in `opts.globals`. Pass\n * known runtime-injected names (e.g. JST's `_`, `Array`, `Set`) in `opts.globals`\n * so they don't appear as free vars. Also surfaces unsafe-construct errors from\n * the same parse pass.\n */\nexport function getFreeVariables(code, opts = {}) {\n const { root, program } = buildScopeTree(code, opts);\n const vars = new Set();\n recursiveWalk(program, root, {\n Function(node, state, c) {\n baseVisitor.Function(node, node.$scope || state, c);\n },\n Identifier(node, state, c) {\n const identifier = node;\n if (!isSafeIdentifier(node) && !state.isDefined(identifier.name)) {\n vars.add(identifier.name);\n }\n baseVisitor.Identifier(node, state, c);\n },\n });\n return { vars, errors: root.errors };\n}\nexport class CompositeError extends Error {\n errors;\n constructor(errors, message) {\n super(`${message || 'Composite Error'}\\n${errors.map((err) => err.message).join('\\n* ')}`);\n this.errors = errors;\n this.errors = errors;\n this.name = 'CompositeError';\n }\n}\n//# sourceMappingURL=validation.js.map","import { validate } from './validation.js';\nexport class Script {\n code;\n globals;\n fn;\n constructor(code, globals) {\n this.code = code;\n this.globals = globals;\n const args = globals && globals.length > 0 ? `{${globals.join(',')}}` : '';\n this.fn = new Function(args, `return (function(){\"use strict\";${code}})()`);\n }\n validate(opts = {}) {\n return validate(this.code, Object.assign({ globals: this.globals }, opts));\n }\n run(context) {\n return this.fn(context);\n }\n}\n//# sourceMappingURL=script.js.map","//add line numbers with {% addLineNumbers(content) %}\nexport function addLineNumbers(content) {\n const lines = content.split('\\n');\n const width = Math.ceil(Math.log10(lines.length));\n return lines\n .map((line, index) => {\n const number = (index + 1).toString().padStart(width, ' ');\n return `{% ${number} %} ${line}`;\n })\n .join('\\n');\n}\n//# sourceMappingURL=addLineNumbers.js.map","import Papa from 'papaparse';\nexport function loadCsv(content, options = {}) {\n return Papa.parse(content, options);\n}\nexport function jsonToCsv(obj, options = {}) {\n return Papa.unparse(obj, options);\n}\n//# sourceMappingURL=csv.js.map","import dayjs from 'dayjs';\nimport { addLineNumbers } from './functions/addLineNumbers.js';\nimport { jsonToCsv, loadCsv } from './functions/csv.js';\nimport { Script } from './script.js';\nimport { CompositeError } from './validation.js';\nexport class CompiledTemplate extends Script {\n constructor(code, globals) {\n super(code, globals.concat('_', 'Array', 'Set'));\n }\n validate() {\n return super.validate({\n acorn: {\n allowReturnOutsideFunction: true,\n locations: true,\n },\n });\n }\n run(context) {\n return super.run({ ...context, Set: Set, Array: Array });\n }\n}\nexport function renderJsTemplate(code, globals, data) {\n const script = new CompiledTemplate(code, globals);\n const state = script.validate();\n if (state.hasErrors()) {\n throw new CompositeError(state.errors, 'Validation errors');\n }\n const content = script.run({\n ...data,\n _: {\n loadCsv,\n jsonToCsv,\n stringify: JSON.stringify,\n addLineNumbers: addLineNumbers,\n dayjs: dayjs,\n },\n });\n return content;\n}\n//# sourceMappingURL=template.js.map"],"names":["renderHandlebarsTemplate","template","input","Handlebars","compile","compiled","registerHelper","Date","toISOString","value","SafeString","JSON","stringify","baseVisitor","baseV","UnknownPosition","line","column","ValidationError","Error","node","constructor","message","super","this","name","range","loc","start","end","location","Scope","parent","errors","children","locals","Set","push","$scope","define","add","isDefined","has","pushError","hasErrors","length","ok","print","console","log","child","markSafeIdentifier","___safe_identifier","isSafeIdentifier","defaultAcornOpts","ecmaVersion","sourceType","buildScopeTree","code","opts","acornOpts","acorn","program","parse","root","globals","identifier","propsBlacklist","recursiveWalk","WithStatement","state","c","ForStatement","WhileStatement","ImportExpression","ImportDeclaration","Class","ThisExpression","allowThis","ObjectPattern","prop","properties","type","key","kind","argument","ArrayPattern","elements","MemberExpression","property","String","Function","id","scope","param","params","left","addFunctionParams","VariableDeclaration","decl","declarations","validate","Identifier","getFreeVariables","vars","CompositeError","map","err","join","Script","fn","args","Object","assign","run","context","addLineNumbers","content","lines","split","width","Math","ceil","log10","index","toString","padStart","loadCsv","options","Papa","jsonToCsv","obj","unparse","CompiledTemplate","concat","allowReturnOutsideFunction","locations","Array","renderJsTemplate","data","script","_","dayjs"],"mappings":"uJASO,SAASA,EAAyBC,EAAUC,GAG/C,OADiBC,EAAWC,QAAQH,EAC7BI,CAASH,EACpB,CAZAC,EAAWG,eAAe,OAAQ,KAAM,IAAIC,MAAOC,eACnDL,EAAWG,eAAe,YAAcG,GAChCA,QACO,GACU,iBAAVA,EACAA,EACJ,IAAIN,EAAWO,WAAWC,KAAKC,UAAUH,KCLpD,MAAMI,EAAcC,EACdC,EAAkB,CACpBC,KAAM,EACNC,OAAQ,GAEL,MAAMC,UAAwBC,MACjCC,KACA,WAAAC,CAAYC,EAASF,GACjBG,MAAMD,GACNE,KAAKJ,KAAOA,EACZI,KAAKC,KAAO,iBAChB,CACA,SAAIC,GACA,MAAMC,EAAMH,KAAKJ,KAAKO,IACtB,OAAOA,EAAM,CAACA,EAAIC,MAAOD,EAAIE,KAAO,CAACd,EAAiBA,EAC1D,CACA,SAAIa,GACA,OAAOJ,KAAKJ,KAAKO,KAAKC,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KkC,KAAMsD,OAAOC,OAAO,CAAEhD,QAASzC,KAAKyC,SAAWN,GACxE,CACA,GAAAuD,CAAIC,GACA,OAAO3F,KAAKsF,GAAGK,EACnB,ECfG,SAASC,EAAeC,GAC3B,MAAMC,EAAQD,EAAQE,MAAM,MACtBC,EAAQC,KAAKC,KAAKD,KAAKE,MAAML,EAAMzE,SACzC,OAAOyE,EACFZ,IAAI,CAAC1F,EAAM4G,IAEL,OADSA,EAAQ,GAAGC,WAAWC,SAASN,EAAO,WAC5BxG,KAEzB4F,KAAK,KACd,CCTO,SAASmB,EAAQV,EAASW,EAAU,IACvC,OAAOC,EAAKlE,MAAMsD,EAASW,EAC/B,CACO,SAASE,EAAUC,EAAKH,EAAU,IACrC,OAAOC,EAAKG,QAAQD,EAAKH,EAC7B,CCDO,MAAMK,UAAyBxB,EAClC,WAAAxF,CAAYqC,EAAMO,GACd1C,MAAMmC,EAAMO,EAAQqE,OAAO,IAAK,QAAS,OAC7C,CACA,QAAAjC,GACI,OAAO9E,MAAM8E,SAAS,CAClBxC,MAAO,CACH0E,4BAA4B,EAC5BC,WAAW,IAGvB,CACA,GAAAtB,CAAIC,GACA,OAAO5F,MAAM2F,IAAI,IAAKC,EAAS/E,IAAKA,IAAKqG,MAAOA,OACpD,EAEG,SAASC,EAAiBhF,EAAMO,EAAS0E,GAC5C,MAAMC,EAAS,IAAIP,EAAiB3E,EAAMO,GACpCK,EAAQsE,EAAOvC,WACrB,GAAI/B,EAAM1B,YACN,MAAM,IAAI6D,EAAenC,EAAMrC,OAAQ,qBAY3C,OAVgB2G,EAAO1B,IAAI,IACpByB,EACHE,EAAG,CACCd,UACAG,YACAtH,UAAWD,KAAKC,UAChBwG,eAAgBA,EAChB0B,MAAOA,IAInB"}
|
|
1
|
+
{"version":3,"file":"vertesia-jst.js","sources":["handlebars/index.js","validation.js","script.js","functions/addLineNumbers.js","functions/csv.js","template.js"],"sourcesContent":["import Handlebars from 'handlebars';\nHandlebars.registerHelper('_now', () => new Date().toISOString());\nHandlebars.registerHelper('stringify', (value) => {\n if (value === null || value === undefined)\n return '';\n if (typeof value === 'string')\n return value;\n return new Handlebars.SafeString(JSON.stringify(value));\n});\nexport function renderHandlebarsTemplate(template, input) {\n // lazy load handlebars to speed up initial loading\n const compiled = Handlebars.compile(template);\n return compiled(input);\n}\n//# sourceMappingURL=index.js.map","import { parse, } from 'acorn';\nimport { base as baseV, recursive as recursiveWalk } from 'acorn-walk';\nconst baseVisitor = baseV;\nconst UnknownPosition = {\n line: 0,\n column: 0,\n};\nexport class ValidationError extends Error {\n node;\n constructor(message, node) {\n super(message);\n this.node = node;\n this.name = 'ValidationError';\n }\n get range() {\n const loc = this.node.loc;\n return loc ? [loc.start, loc.end] : [UnknownPosition, UnknownPosition];\n }\n get start() {\n return this.node.loc?.start || UnknownPosition;\n }\n get end() {\n return this.node.loc?.end || UnknownPosition;\n }\n get location() {\n if (this.node.loc) {\n return `${this.node.loc.start.line}:${this.node.loc.start.column}`;\n }\n else {\n return `${this.node.range}`;\n }\n }\n}\nexport class Scope {\n name;\n node;\n parent;\n errors;\n children = [];\n locals = new Set();\n constructor(name, node, parent) {\n this.name = name;\n this.node = node;\n this.parent = parent;\n parent?.children.push(this);\n this.errors = parent ? parent.errors : [];\n node.$scope = this;\n }\n define(name) {\n this.locals.add(name);\n }\n isDefined(name) {\n if (this.locals.has(name)) {\n return true;\n }\n if (this.parent) {\n return this.parent.isDefined(name);\n }\n return false;\n }\n pushError(message, node) {\n this.errors.push(new ValidationError(message, node));\n }\n hasErrors() {\n return this.errors.length > 0;\n }\n get ok() {\n return this.errors.length === 0;\n }\n print() {\n console.log(this.name, '=>', this.locals);\n for (const child of this.children) {\n child.print();\n }\n }\n}\nfunction addFunctionParams(node, scope) {\n for (const param of node.params) {\n if (param.type === 'Identifier') {\n scope.locals.add(param.name);\n markSafeIdentifier(param);\n }\n else if (param.type === 'AssignmentPattern') {\n if (param.left.type === 'Identifier') {\n scope.locals.add(param.left.name);\n markSafeIdentifier(param.left);\n }\n }\n else if (param.type === 'RestElement') {\n if (param.argument.type === 'Identifier') {\n scope.locals.add(param.argument.name);\n markSafeIdentifier(param.argument);\n }\n }\n }\n}\nfunction markSafeIdentifier(node) {\n node.___safe_identifier = true;\n}\nfunction isSafeIdentifier(node) {\n return !!node.___safe_identifier;\n}\nconst defaultAcornOpts = {\n ecmaVersion: 2020,\n sourceType: 'script',\n};\n/**\n * Parse `code` and build the scope tree (one full AST walk). The returned root scope\n * has `locals` populated for every nested function/block and has unsafe-construct\n * errors accumulated in `root.errors`. Identifier resolution (the \"Unknown identifier\"\n * check) is a separate second walk done by `validate` / `getFreeVariables`.\n */\nfunction buildScopeTree(code, opts) {\n const acornOpts = opts.acorn ? { ...defaultAcornOpts, ...opts.acorn } : defaultAcornOpts;\n const program = parse(code, acornOpts);\n const root = new Scope('#root', program, null);\n if (opts.globals) {\n for (const identifier of opts.globals) {\n root.locals.add(identifier);\n }\n program.$scope = root;\n }\n const propsBlacklist = new Set(opts.propsBlacklist ? opts.propsBlacklist : ['constructor', 'prototype', '__proto__']);\n recursiveWalk(program, root, {\n WithStatement(node, state, c) {\n state.pushError('\"with\" keyword is not supported', node);\n baseVisitor.WithStatement(node, state, c);\n },\n ForStatement(node, state, c) {\n state.pushError('\"for\" keyword is not supported', node);\n baseVisitor.ForStatement(node, state, c);\n },\n WhileStatement(node, state, c) {\n state.pushError('\"while\" keyword is not supported', node);\n baseVisitor.WhileStatement(node, state, c);\n },\n ImportExpression(node, state, c) {\n state.pushError('\"import\" keyword is not supported', node);\n baseVisitor.ImportExpression(node, state, c);\n },\n ImportDeclaration(node, state, c) {\n state.pushError('\"import\" keyword is not supported', node);\n baseVisitor.ImportDeclaration(node, state, c);\n },\n Class(node, state, c) {\n state.pushError('Classes are not supported', node);\n baseVisitor.Class(node, state, c);\n },\n ThisExpression(node, state, c) {\n if (!opts.allowThis) {\n state.pushError('\"this\" keyword is not supported', node);\n }\n baseVisitor.ThisExpression(node, state, c);\n },\n ObjectPattern(node, state, c) {\n for (const prop of node.properties) {\n if (prop.type === 'Property') {\n if (prop.key.type === 'Identifier') {\n markSafeIdentifier(prop.key);\n if (prop.kind === 'init' && propsBlacklist.has(prop.key.name)) {\n state.pushError(`Property \"${prop.key.name}\" is not allowed`, prop.key);\n }\n }\n }\n else if (prop.type === 'RestElement') {\n if (prop.argument.type === 'Identifier') {\n markSafeIdentifier(prop.argument);\n }\n }\n }\n baseVisitor.ObjectPattern(node, state, c);\n },\n ArrayPattern(node, state, c) {\n for (const prop of node.elements) {\n if (prop) {\n if (prop.type === 'Identifier') {\n markSafeIdentifier(prop);\n //TODO is this really needed?\n // if (propBlacklist.has(prop.name)) {\n // state.pushError(`Property \"${prop.name}\" is not allowed`, prop);\n // }\n }\n else if (prop.type === 'RestElement') {\n if (prop.argument.type === 'Identifier') {\n markSafeIdentifier(prop.argument);\n }\n }\n }\n }\n baseVisitor.ArrayPattern(node, state, c);\n },\n MemberExpression(node, state, c) {\n const prop = node.property;\n if (prop.type === 'Identifier') {\n markSafeIdentifier(prop);\n if (propsBlacklist.has(prop.name)) {\n state.pushError(`Property \"${prop.name}\" is not allowed`, prop);\n }\n }\n else if (prop.type === 'Literal') {\n if (propsBlacklist.has(String(prop.value))) {\n state.pushError(`Property \"${prop.value}\" is not allowed`, prop);\n }\n }\n else {\n state.pushError('Dynamic property lookup is not supported', prop);\n }\n baseVisitor.MemberExpression(node, state, c);\n },\n Function(node, state, c) {\n const name = node.id?.name;\n if (name) {\n // arrow functions have no name\n state.define(name);\n }\n const scope = new Scope(name || '#anonymous', node, state);\n addFunctionParams(node, scope);\n baseVisitor.Function(node, scope, c);\n },\n VariableDeclaration(node, state, c) {\n for (const decl of node.declarations) {\n if (decl.id.type === 'Identifier') {\n markSafeIdentifier(decl.id);\n state.define(decl.id.name);\n }\n else if (decl.id.type === 'ObjectPattern') {\n //the ObjectPattern rule will call markSafeIdentifier\n for (const prop of decl.id.properties) {\n if (prop.type === 'Property') {\n if (prop.value.type === 'Identifier')\n state.define(prop.value.name);\n }\n else if (prop.type === 'RestElement') {\n if (prop.argument.type === 'Identifier')\n state.define(prop.argument.name);\n }\n }\n }\n else if (decl.id.type === 'ArrayPattern') {\n //the ArrayPattern rule will call markSafeIdentifier\n for (const prop of decl.id.elements) {\n if (prop.type === 'Identifier') {\n state.define(prop.name);\n }\n else if (prop.type === 'RestElement') {\n if (prop.argument.type === 'Identifier')\n state.define(prop.argument.name);\n }\n }\n }\n }\n baseVisitor.VariableDeclaration(node, state, c);\n },\n });\n return { root, program };\n}\nexport function validate(code, opts = {}) {\n const { root, program } = buildScopeTree(code, opts);\n recursiveWalk(program, root, {\n Function(node, state, c) {\n baseVisitor.Function(node, node.$scope || state, c);\n },\n Identifier(node, state, c) {\n const identifier = node;\n if (!isSafeIdentifier(node) && !state.isDefined(identifier.name)) {\n state.pushError(`Unknown identifier \"${identifier.name}\"`, node);\n }\n baseVisitor.Identifier(node, state, c);\n },\n });\n return root;\n}\n/**\n * Walk `code` and return every identifier that is referenced but not bound by any\n * enclosing function/variable declaration and not listed in `opts.globals`. Pass\n * known runtime-injected names (e.g. JST's `_`, `Array`, `Set`) in `opts.globals`\n * so they don't appear as free vars. Also surfaces unsafe-construct errors from\n * the same parse pass.\n */\nexport function getFreeVariables(code, opts = {}) {\n const { root, program } = buildScopeTree(code, opts);\n const vars = new Set();\n recursiveWalk(program, root, {\n Function(node, state, c) {\n baseVisitor.Function(node, node.$scope || state, c);\n },\n Identifier(node, state, c) {\n const identifier = node;\n if (!isSafeIdentifier(node) && !state.isDefined(identifier.name)) {\n vars.add(identifier.name);\n }\n baseVisitor.Identifier(node, state, c);\n },\n });\n return { vars, errors: root.errors };\n}\nexport class CompositeError extends Error {\n errors;\n constructor(errors, message) {\n super(`${message || 'Composite Error'}\\n${errors.map((err) => err.message).join('\\n* ')}`);\n this.errors = errors;\n this.errors = errors;\n this.name = 'CompositeError';\n }\n}\n//# sourceMappingURL=validation.js.map","import { validate } from './validation.js';\nexport class Script {\n code;\n globals;\n fn;\n constructor(code, globals) {\n this.code = code;\n this.globals = globals;\n const args = globals && globals.length > 0 ? `{${globals.join(',')}}` : '';\n this.fn = new Function(args, `return (function(){\"use strict\";${code}})()`);\n }\n validate(opts = {}) {\n return validate(this.code, Object.assign({ globals: this.globals }, opts));\n }\n run(context) {\n return this.fn(context);\n }\n}\n//# sourceMappingURL=script.js.map","//add line numbers with {% addLineNumbers(content) %}\nexport function addLineNumbers(content) {\n const lines = content.split('\\n');\n const width = Math.ceil(Math.log10(lines.length));\n return lines\n .map((line, index) => {\n const number = (index + 1).toString().padStart(width, ' ');\n return `{% ${number} %} ${line}`;\n })\n .join('\\n');\n}\n//# sourceMappingURL=addLineNumbers.js.map","import Papa from 'papaparse';\nexport function loadCsv(content, options = {}) {\n return Papa.parse(content, options);\n}\nexport function jsonToCsv(obj, options = {}) {\n return Papa.unparse(obj, options);\n}\n//# sourceMappingURL=csv.js.map","import dayjs from 'dayjs';\nimport { addLineNumbers } from './functions/addLineNumbers.js';\nimport { jsonToCsv, loadCsv } from './functions/csv.js';\nimport { Script } from './script.js';\nimport { CompositeError } from './validation.js';\nexport class CompiledTemplate extends Script {\n constructor(code, globals) {\n super(code, globals.concat('_', 'Array', 'Set'));\n }\n validate() {\n return super.validate({\n acorn: {\n allowReturnOutsideFunction: true,\n locations: true,\n },\n });\n }\n run(context) {\n return super.run({ ...context, Set: Set, Array: Array });\n }\n}\nexport function renderJsTemplate(code, globals, data) {\n const script = new CompiledTemplate(code, globals);\n const state = script.validate();\n if (state.hasErrors()) {\n throw new CompositeError(state.errors, 'Validation errors');\n }\n const content = script.run({\n ...data,\n _: {\n loadCsv,\n jsonToCsv,\n stringify: JSON.stringify,\n addLineNumbers: addLineNumbers,\n dayjs: dayjs,\n },\n });\n return content;\n}\n//# sourceMappingURL=template.js.map"],"names":["renderHandlebarsTemplate","template","input","Handlebars","compile","compiled","registerHelper","Date","toISOString","value","SafeString","JSON","stringify","baseVisitor","baseV","UnknownPosition","line","column","ValidationError","Error","node","constructor","message","super","this","name","range","loc","start","end","location","Scope","parent","errors","children","locals","Set","push","$scope","define","add","isDefined","has","pushError","hasErrors","length","ok","print","console","log","child","markSafeIdentifier","___safe_identifier","isSafeIdentifier","defaultAcornOpts","ecmaVersion","sourceType","buildScopeTree","code","opts","acornOpts","acorn","program","parse","root","globals","identifier","propsBlacklist","recursiveWalk","WithStatement","state","c","ForStatement","WhileStatement","ImportExpression","ImportDeclaration","Class","ThisExpression","allowThis","ObjectPattern","prop","properties","type","key","kind","argument","ArrayPattern","elements","MemberExpression","property","String","Function","id","scope","param","params","left","addFunctionParams","VariableDeclaration","decl","declarations","validate","Identifier","getFreeVariables","vars","CompositeError","map","err","join","Script","fn","args","Object","assign","run","context","addLineNumbers","content","lines","split","width","Math","ceil","log10","index","toString","padStart","loadCsv","options","Papa","jsonToCsv","obj","unparse","CompiledTemplate","concat","allowReturnOutsideFunction","locations","Array","renderJsTemplate","data","script","_","dayjs"],"mappings":"uJASO,SAASA,EAAyBC,EAAUC,GAG/C,OADiBC,EAAWC,QAAQH,EAC7BI,CAASH,EACpB,CAZAC,EAAWG,eAAe,QAAQ,KAAM,IAAIC,MAAOC,gBACnDL,EAAWG,eAAe,aAAcG,GAChCA,QACO,GACU,iBAAVA,EACAA,EACJ,IAAIN,EAAWO,WAAWC,KAAKC,UAAUH,MCLpD,MAAMI,EAAcC,EACdC,EAAkB,CACpBC,KAAM,EACNC,OAAQ,GAEL,MAAMC,UAAwBC,MACjCC,KACA,WAAAC,CAAYC,EAASF,GACjBG,MAAMD,GACNE,KAAKJ,KAAOA,EACZI,KAAKC,KAAO,iBAChB,CACA,SAAIC,GACA,MAAMC,EAAMH,KAAKJ,KAAKO,IACtB,OAAOA,EAAM,CAACA,EAAIC,MAAOD,EAAIE,KAAO,CAACd,EAAiBA,EAC1D,CACA,SAAIa,GACA,OAAOJ,KAAKJ,KAAKO,KAAKC,OAASb,CACnC,CACA,OAAIc,GACA,OAAOL,KAAKJ,K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KyC,SAAWN,GACxE,CACA,GAAAuD,CAAIC,GACA,OAAO3F,KAAKsF,GAAGK,EACnB,ECfG,SAASC,EAAeC,GAC3B,MAAMC,EAAQD,EAAQE,MAAM,MACtBC,EAAQC,KAAKC,KAAKD,KAAKE,MAAML,EAAMzE,SACzC,OAAOyE,EACFZ,KAAI,CAAC1F,EAAM4G,IAEL,OADSA,EAAQ,GAAGC,WAAWC,SAASN,EAAO,WAC5BxG,MAEzB4F,KAAK,KACd,CCTO,SAASmB,EAAQV,EAASW,EAAU,IACvC,OAAOC,EAAKlE,MAAMsD,EAASW,EAC/B,CACO,SAASE,EAAUC,EAAKH,EAAU,IACrC,OAAOC,EAAKG,QAAQD,EAAKH,EAC7B,CCDO,MAAMK,UAAyBxB,EAClC,WAAAxF,CAAYqC,EAAMO,GACd1C,MAAMmC,EAAMO,EAAQqE,OAAO,IAAK,QAAS,OAC7C,CACA,QAAAjC,GACI,OAAO9E,MAAM8E,SAAS,CAClBxC,MAAO,CACH0E,4BAA4B,EAC5BC,WAAW,IAGvB,CACA,GAAAtB,CAAIC,GACA,OAAO5F,MAAM2F,IAAI,IAAKC,EAAS/E,IAAKA,IAAKqG,MAAOA,OACpD,EAEG,SAASC,EAAiBhF,EAAMO,EAAS0E,GAC5C,MAAMC,EAAS,IAAIP,EAAiB3E,EAAMO,GACpCK,EAAQsE,EAAOvC,WACrB,GAAI/B,EAAM1B,YACN,MAAM,IAAI6D,EAAenC,EAAMrC,OAAQ,qBAY3C,OAVgB2G,EAAO1B,IAAI,IACpByB,EACHE,EAAG,CACCd,UACAG,YACAtH,UAAWD,KAAKC,UAChBwG,eAAgBA,EAChB0B,MAAOA,IAInB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vertesia/jst",
|
|
3
|
-
"version": "1.3.0
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Javascript text template",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"@rollup/plugin-terser": "^1.0.0",
|
|
32
32
|
"@types/estree": "^1.0.9",
|
|
33
33
|
"@types/papaparse": "^5.5.2",
|
|
34
|
-
"rollup": "^4.61.
|
|
34
|
+
"rollup": "^4.61.0",
|
|
35
35
|
"typescript": "^6.0.3",
|
|
36
36
|
"vitest": "^4.1.8",
|
|
37
37
|
"@vertesia/tsconfig": "0.1.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@types/node": "^24.
|
|
40
|
+
"@types/node": "^24.12.4",
|
|
41
41
|
"acorn": "8.16.0",
|
|
42
42
|
"acorn-walk": "8.3.5",
|
|
43
43
|
"dayjs": "^1.11.21",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"scripts": {
|
|
55
55
|
"lint": "biome lint src",
|
|
56
56
|
"test": "vitest run",
|
|
57
|
-
"build": "tsc
|
|
57
|
+
"build": "tsc && pnpm exec rollup -c",
|
|
58
58
|
"clean": "rm -rf ./lib tsconfig.tsbuildinfo",
|
|
59
59
|
"typecheck": "tsc --noEmit",
|
|
60
60
|
"typecheck:test": "tsc -p tsconfig.test.json --noEmit"
|