@webhandle/tripartite-renderer 1.0.0 → 1.0.1
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/README.md
CHANGED
|
@@ -18,4 +18,11 @@ Run after express has been configured.
|
|
|
18
18
|
```js
|
|
19
19
|
import setupTripartiteRenderer from '@webhandle/tripartite-renderer/setup-tripartite-renderer.mjs'
|
|
20
20
|
setupTripartiteRenderer(webhandleInstance)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
Also provides the tripartite library.
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
import {tripartite} from "tripartite"
|
|
21
28
|
```
|
|
@@ -1,18 +1,52 @@
|
|
|
1
1
|
import createInitializeWebhandleComponent from "@webhandle/initialize-webhandle-component/create-initialize-webhandle-component.mjs"
|
|
2
2
|
import ComponentManager from "@webhandle/initialize-webhandle-component/component-manager.mjs"
|
|
3
3
|
import setupTripartiteRenderer from "./setup-tripartite-renderer.mjs"
|
|
4
|
+
import path from "node:path"
|
|
4
5
|
|
|
5
6
|
let initializeWebhandleComponent = createInitializeWebhandleComponent()
|
|
6
7
|
|
|
7
8
|
initializeWebhandleComponent.componentName = '@webhandle/tripartite-renderer'
|
|
8
9
|
initializeWebhandleComponent.componentDir = import.meta.dirname
|
|
9
|
-
initializeWebhandleComponent.defaultConfig = {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
initializeWebhandleComponent.defaultConfig = {
|
|
11
|
+
"publicFilesPrefix": "/tripartite/files"
|
|
12
|
+
, "provideResources": true
|
|
13
|
+
}
|
|
12
14
|
|
|
13
15
|
initializeWebhandleComponent.setup = async function(webhandle, config) {
|
|
14
16
|
let manager = new ComponentManager()
|
|
17
|
+
manager.config = config
|
|
18
|
+
|
|
15
19
|
setupTripartiteRenderer(webhandle)
|
|
20
|
+
|
|
21
|
+
manager.provideExternalResources = function(externalResourceManager) {
|
|
22
|
+
|
|
23
|
+
let resource = {
|
|
24
|
+
mimeType: 'application/javascript'
|
|
25
|
+
, url: config.publicFilesPrefix + '/tripartite.js'
|
|
26
|
+
, name: 'tripartite'
|
|
27
|
+
, resourceType: 'module'
|
|
28
|
+
, cachable: webhandle.development ? false : true
|
|
29
|
+
}
|
|
30
|
+
externalResourceManager.provideResource(resource)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if(config.provideResources) {
|
|
34
|
+
webhandle.routers.preDynamic.use((req, res, next) => {
|
|
35
|
+
manager.provideExternalResources(res.locals.externalResourceManager)
|
|
36
|
+
next()
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let dir = 'resources'
|
|
41
|
+
manager.staticPaths.push(
|
|
42
|
+
webhandle.addStaticDir(
|
|
43
|
+
path.join(initializeWebhandleComponent.componentDir, dir),
|
|
44
|
+
{
|
|
45
|
+
urlPrefix: config.publicFilesPrefix
|
|
46
|
+
, fixedSetOfFiles: true
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
)
|
|
16
50
|
return manager
|
|
17
51
|
}
|
|
18
52
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webhandle/tripartite-renderer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "setup-tripartite-renderer.mjs",
|
|
6
6
|
"scripts": {
|
|
@@ -17,10 +17,13 @@
|
|
|
17
17
|
"tripartite": "^1.1.5"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@webhandle/express-5": "^1.0.0"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
"@webhandle/express-5": "^1.0.0",
|
|
21
|
+
"@webhandle/external-resource-manager": "^1.0.2",
|
|
22
|
+
"@webhandle/pages-server": "^1.0.0"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"README.md",
|
|
26
|
+
"*.mjs"
|
|
27
|
+
, "resources"
|
|
25
28
|
]
|
|
26
29
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var t={946(t){t.exports=class{constructor(t,e,n,i){this.conditionalExpression=t,this.dataExpression=e,this.handlingExpression=n||"defaultTemplate",this.tripartite=i}}},600(t){t.exports=function(t,e){if(!t)return e;if(!e)return e;if(0!=e.indexOf("../")&&0!=e.indexOf("./"))return e;for(var n=t.split("/"),i=e.split("/");n.length&&!n[0];)n.shift();for(;i.length&&!i[0];)i.shift();if(0==e.indexOf("../")){for(;i.length&&".."==i[0];)n.pop(),i.shift();for(n.pop();i.length;)n.push(i.shift());return n.join("/")}if(0==e.indexOf("./")){for(i.shift(),n.pop();i.length;)n.push(i.shift());return n.join("/")}return e}},514(t,e,n){const i=n(864);let r=new Function("additionalContexts","with ({\n\t\t'$globals': additionalContexts.globalData\n\t}) {\n\t\twith (additionalContexts.dataFunctions) {\n\t\t\twith (additionalContexts.context) {\n\t\t\t\ttry {\n\t\t\t\t\treturn eval(additionalContexts.expression);\n\t\t\t\t} catch (e) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}");function a(t,e,n,i){return n=n||{},i=i||{},r.call(this,{globalData:i,dataFunctions:n,context:t,expression:e})}t.exports=function(t,e,n,r){if(!e)return null;if("string"==typeof e&&(e=e.trim()),"$this"===e||"this"===e)return t;if("object"==typeof t&&e in t)return t[e];if('""'===e||"''"===e)return"";let s=i(t,e);return null==s&&(s=i({$globals:r},e)),null==s&&(s=a.call(t,t,e,n,r)),s}},909(t,e,n){let i=n(946);var r=n(600);let a=n(514);t.exports=class{constructor(t,e,n={},i="",r={}){this.tripartite=t,this.template=e,this.destination=i,this.initialData=n,this.currentData=[],this.dataFunctions=r,this.continueOnTripartiteError=!0,this.callCount=0,this.callDepthLimit=1e3}run(t){let e;return t&&(e=()=>{t(null,this.destination)}),this._run(this.template,this.initialData,e),this.destination}_resolveHandlingExpression(t,e,n){return e||(e=defaultTemplateName),"$"==e.charAt(0)&&(e=a(n,e.substring(1),this.dataFunctions,this.initialData)),0!=e.indexOf("./")&&0!=e.indexOf("../")||(e=r(t.templateMeta.name,e)),e}_run(t,e,n){let r=[...t.parts].reverse();const s=()=>{if(this.callCount++,this.callCount++>this.callDepthLimit)setTimeout(()=>{this.callCount=0,s()});else if(r.length>0){let l=r.pop();if("string"==typeof l)this.output(l),s();else if(l instanceof i){let i,r=l.conditionalExpression||l.dataExpression,o=!1;if(null==r||null==r||""===r?o=!0:l.conditionalExpression?a(e,l.conditionalExpression,this.dataFunctions,this.initialData)&&(o=!0):(i=a(e,l.dataExpression,this.dataFunctions,this.initialData),null==i?o=!1:("number"==typeof i||Array.isArray(i)&&i.length>0||i)&&(o=!0)),o){l.dataExpression&&void 0===i&&(i=a(e,l.dataExpression,this.dataFunctions,this.initialData)),null!=i||l.dataExpression||(i=e);let r,o=this._resolveHandlingExpression(t,l.handlingExpression,e),p=(Array.isArray(i)?[...i]:[i]).reverse();const u=()=>{if(p.length>0){let t=p.pop();this._run(r,t,()=>{u()})}else s()};o in this.tripartite.templates?(r=this.tripartite.getTemplate(o),r?u():this.continueOnTripartiteError&&s()):this.tripartite.loadTemplate(o,t=>{if(t)r=t,u();else{let t="Could not load template: "+o;if(console.error(t),this.continueOnTripartiteError)s();else{let e=new Error(t);if(!n)throw e;n(e)}}})}else s()}else"function"==typeof l&&(l.write?l.write(e,this.destination,()=>{s()}):(this.output(l(e)),s()))}else n&&n()};s()}output(t){null!=t&&("string"==typeof this.destination?this.destination+=t:this.destination.write&&this.destination.write(t))}}},864(t){t.exports=function(t,e){try{if(null==t)return t;let n;for("string"==typeof e?n=e.trim().split("."):Array.isArray(e)&&(n=e);n.length>0;){let e,i=n.shift();if(i.indexOf(" ")>-1)return null;if("this"===i||"$this"===i?e=t:"object"==typeof t&&i in t&&(e=t[i]),0==n.length)return e;if(null==e)return null;t=e}}catch(t){return null}}},393(t,e,n){function i(t){return null!==t&&"object"==typeof t&&"function"==typeof t.pipe}"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")});let r=n(909),a=n(946);class s{constructor(t={}){this.templates={defaultTemplate:this._makeTemplate(function(t){return""+t})};let{constants:e={templateBoundary:"__",templateNameBoundary:"##"}}=t;this.constants=e,this.secondaryTemplateFunctionObject=t.secondaryTemplateFunctionObject,this.loaders=t.loaders||[],this.dataFunctions=t.dataFunction||{}}_makeTemplate(t){if((e=t)&&"function"==typeof e&&e.write&&e.parts&&e.templateMeta)return t;var e;let n=this,a=function(t){let e=null,n=null,r=null;for(let t=1;t<arguments.length;t++){let a=arguments[t];i(a)?e=a:"function"==typeof a?r=a:"object"==typeof a&&(n=a)}return a.write(t,e,r,n)};return a.write=function(e,i,s,l={}){if(t&&t.write)return t.write.apply(t,arguments);{let t=new r(n,a,e,i||"",n.dataFunctions);return l&&"continueOnTripartiteError"in l&&(t.continueOnTripartiteError=l.continueOnTripartiteError),t.run(s)}},a.run=async function(t){return new Promise((e,n)=>{a(t,(t,i)=>{t?n(t):e(i)})})},a.parts=[],t&&"function"==typeof t&&a.parts.push(t),a.templateMeta={},a}addTemplate(t,e){return"string"==typeof e?e=this.parseTemplate(e):"function"==typeof e&&(e=this._makeTemplate(e)),this.templates[t]=e,e.templateMeta=e.templateMeta||{},e.templateMeta.name=t,e}createBlank(){return new s}getTemplate(t){return this.templates[t]}loadTemplate(t,e){if(t in this.templates)e(this.templates[t]);else{let n=this,i=this.loaders.length,r=!1;0==i?(n.templates[t]=null,e(n.getTemplate(t))):this.loaders.forEach(a=>{r||a(t,a=>{r||(i--,a?(r=!0,n.addTemplate(t,a)):0==i&&(r=!0,n.templates[t]=null),r&&e(n.getTemplate(t)))})})}}parseTemplateScript(t){for(var e=this.tokenizeTemplateScript(t),n=null,i=0;i<e.length;i++){var r=e[i];if(r.active)n=r.content;else if(n){var a=this.addTemplate(n,this.stripTemplateWhitespace(r.content));this.secondaryTemplateFunctionObject&&(this.secondaryTemplateFunctionObject[n]=a),n=null}}}stripTemplateWhitespace(t){var e=t.indexOf("\n");return e>-1&&""==t.substring(0,e).trim()&&(t=t.substring(e+1)),(e=t.lastIndexOf("\n"))>-1&&""==t.substring(e).trim()&&(t=t.substring(0,e)),t}_createActiveElement(t,e,n,i,r){let s=new a(t,e,n,i);return s.templateMeta=r,s}pt(t){return this.parseTemplate(t)}parseTemplate(t){var e=this.tokenizeTemplate(t);let n=this._makeTemplate();var i=n.templateMeta;for(let t of e)t.active?n.parts.push(this.tokenizeActivePart(t.content,i)):t.content&&n.parts.push(t.content);return n}tokenizeActivePart(t,e){var n=null,i=null,r=null,a=t.indexOf("??");a>-1?(n=t.substring(0,a),a+=2):a=0;var s=t.indexOf("::");return s>-1?(i=t.substring(a,s),r=t.substring(s+2)):i=t.substring(a),this._createActiveElement(n,i,r,this,e)}tokenizeTemplate(t){return this.tokenizeActiveAndInactiveBlocks(t,this.constants.templateBoundary)}tokenizeTemplateScript(t){return this.tokenizeActiveAndInactiveBlocks(t,this.constants.templateNameBoundary)}tokenizeActiveAndInactiveBlocks(t,e){let n=t.length,i=0,r=!1,a=[];for(;i<n;){let l=t.indexOf(e,i);-1==l&&(l=n);var s={active:r,content:t.substring(i,l)};a.push(s),i=l+e.length,r=!r}return a}}var l=new s;"undefined"!=typeof window&&(l.secondaryTemplateFunctionObject=window),t.exports=l,void 0!==n.g&&(n.g.Tripartite||(n.g.Tripartite=s),n.g.tripartite||(n.g.tripartite=l))}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var a=e[i]={exports:{}};return t[i](a,a.exports,n),a.exports}n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var i={};n.d(i,{l:()=>r});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IAAV,EAAAE,IACL,EAAAA,EAAO/D,aACX,EAAA+D,EAAO/D,WAAaA,GAEhB,EAAA+D,EAAO/I,aACX,EAAA+I,EAAO/I,WAAa6I,G,GC1UlBG,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqB5F,IAAjB6F,EACH,OAAOA,EAAaxJ,QAGrB,IAAID,EAASsJ,EAAyBE,GAAY,CAGjDvJ,QAAS,CAAC,GAOX,OAHAyJ,EAAoBF,GAAUxJ,EAAQA,EAAOC,QAASsJ,GAG/CvJ,EAAOC,OACf,CCrBAsJ,EAAoBI,EAAI,CAAC1J,EAAS2J,KACjC,IAAI,IAAIC,KAAOD,EACXL,EAAoBO,EAAEF,EAAYC,KAASN,EAAoBO,EAAE7J,EAAS4J,IAC5EE,OAAOC,eAAe/J,EAAS4J,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,MCJ3EN,EAAoBF,EAAI,WACvB,GAA0B,iBAAfc,WAAyB,OAAOA,WAC3C,IACC,OAAO5J,MAAQ,IAAIc,SAAS,cAAb,EAChB,CAAE,MAAOyD,GACR,GAAsB,iBAAXsE,OAAqB,OAAOA,MACxC,CACA,CAPuB,GCAxBG,EAAoBO,EAAI,CAAC5D,EAAKkE,IAAUL,OAAO5E,UAAUkF,eAAe1I,KAAKuE,EAAKkE,G","sources":["webpack://@webhandle/tripartite-renderer/./node_modules/tripartite/active-element.js","webpack://@webhandle/tripartite-renderer/./node_modules/tripartite/calculate-relative-path.js","webpack://@webhandle/tripartite-renderer/./node_modules/tripartite/evaluate-in-context.js","webpack://@webhandle/tripartite-renderer/./node_modules/tripartite/execution-context.js","webpack://@webhandle/tripartite-renderer/./node_modules/tripartite/resolve-data-path.js","webpack://@webhandle/tripartite-renderer/./node_modules/tripartite/tripartite.js","webpack://@webhandle/tripartite-renderer/webpack/bootstrap","webpack://@webhandle/tripartite-renderer/webpack/runtime/define property getters","webpack://@webhandle/tripartite-renderer/webpack/runtime/global","webpack://@webhandle/tripartite-renderer/webpack/runtime/hasOwnProperty shorthand"],"sourcesContent":["\nconst defaultTemplateName = 'defaultTemplate'\n\nclass ActiveElement {\n\tconstructor(conditionalExpression, dataExpression, handlingExpression, tripartite) {\n\t\tthis.conditionalExpression = conditionalExpression\n\t\tthis.dataExpression = dataExpression\n\t\tthis.handlingExpression = handlingExpression || defaultTemplateName\n\t\tthis.tripartite = tripartite\n\t}\n}\n\nmodule.exports = ActiveElement","var calculateRelativePath = function(parentPath, currentPath) {\n\tif(!parentPath) {\n\t\treturn currentPath\n\t}\n\tif(!currentPath) {\n\t\treturn currentPath\n\t}\n\t\n\tif(currentPath.indexOf('../') != 0 && currentPath.indexOf('./') != 0) {\n\t\treturn currentPath\n\t}\n\t\n\tvar pparts = parentPath.split('/')\n\tvar cparts = currentPath.split('/')\n\t\n\t// trim any starting blank sections\n\twhile(pparts.length && !pparts[0]) {\n\t\tpparts.shift()\n\t}\n\twhile(cparts.length && !cparts[0]) {\n\t\tcparts.shift()\n\t}\n\t\n\tif(currentPath.indexOf('../') == 0 ) {\n\t\twhile(cparts.length && cparts[0] == '..') {\n\t\t\tpparts.pop()\n\t\t\tcparts.shift()\n\t\t}\n\t\tpparts.pop()\n\t\t\n\t\twhile(cparts.length) {\n\t\t\tpparts.push(cparts.shift())\n\t\t}\n\t\treturn pparts.join('/')\n\t}\n\tif(currentPath.indexOf('./') == 0 ) {\n\t\tcparts.shift()\n\t\tpparts.pop()\n\t\twhile(cparts.length) {\n\t\t\tpparts.push(cparts.shift())\n\t\t}\n\t\treturn pparts.join('/')\n\t}\n\t\n\treturn currentPath\n}\n\nmodule.exports = calculateRelativePath","\nconst resolveDataPath = require('./resolve-data-path')\nfunction evaluateInContext(context, expression, dataFunctions, globalData) {\n\tif (!expression) {\n\t\treturn null\n\t}\n\tif (typeof expression === 'string') {\n\t\texpression = expression.trim()\n\t}\n\n\tif (expression === '$this' || expression === 'this') {\n\t\treturn context\n\t}\n\tif (typeof context === 'object' && expression in context) {\n\t\treturn context[expression]\n\t}\n\tif (expression === '\"\"' || expression === \"''\") {\n\t\treturn ''\n\t}\n\tlet resolved = resolveDataPath(context, expression)\n\tif (resolved === null || resolved === undefined) {\n\t\tresolved = resolveDataPath({\n\t\t\t'$globals': globalData\n\t\t}, expression)\n\t}\n\tif (resolved === null || resolved === undefined) {\n\t\tresolved = _evaluateInContext.call(context, context, expression, dataFunctions, globalData)\n\t}\n\treturn resolved\n}\n\nlet evalFunction = new Function('additionalContexts',\n\t`with ({\n\t\t'$globals': additionalContexts.globalData\n\t}) {\n\t\twith (additionalContexts.dataFunctions) {\n\t\t\twith (additionalContexts.context) {\n\t\t\t\ttry {\n\t\t\t\t\treturn eval(additionalContexts.expression);\n\t\t\t\t} catch (e) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}`\n)\n\nfunction _evaluateInContext(context, expression, dataFunctions, globalData) {\n\tdataFunctions = dataFunctions || {}\n\tglobalData = globalData || {}\n\n\n\tlet result = evalFunction.call(this, {\n\t\tglobalData: globalData\n\t\t, dataFunctions: dataFunctions\n\t\t, context: context\n\t\t, expression: expression\n\t})\n\treturn result\n}\n\nmodule.exports = evaluateInContext","\nlet ActiveElement = require('./active-element')\nvar calculateRelativePath = require('./calculate-relative-path')\nlet evaluateInContext = require('./evaluate-in-context')\n\nclass ExecutionContext {\n\t/**\n\t * \n\t * @param {Tripartite} tripartite \n\t * @param {function} template \n\t * @param {stream} [destination]\n\t */\n\tconstructor(tripartite, template, data = {}, destination = '', dataFunctions = {}) {\n\t\tthis.tripartite = tripartite\n\t\tthis.template = template\n\t\tthis.destination = destination\n\t\tthis.initialData = data\n\t\tthis.currentData = []\n\t\tthis.dataFunctions = dataFunctions\n\t\tthis.continueOnTripartiteError = true\n\t\t\n\t\t// Sometimes large pages have so many elements that we exceed\n\t\t// the maximum call depth. This happens when we have a lot of elements all being\n\t\t// rendered by the same templates. That is, there's no async callback when a template\n\t\t// is loaded, only instant callbacks.\n\t\t// The downside to doing very frequent async calls is that it takes a lot longer to\n\t\t// to get called from a setTimeout than it does to call directly. We want ot keep\n\t\t// the time between needing to do that reasonably long. Unfortunately, there's no\n\t\t// easy/fast way to detect the call stack depth, so we rely on this proxy.\n\t\tthis.callCount = 0\n\t\tthis.callDepthLimit = 1000\n\t}\n\n\t/**\n\t * \n\t * @param {function} [callback] called when done\n\t * @returns Returns the string of stream as the result of the operation\n\t */\n\trun(callback) {\n\t\tlet ourCallback\n\t\tif (callback) {\n\t\t\tourCallback = () => {\n\t\t\t\tcallback(null, this.destination)\n\t\t\t}\n\t\t}\n\n\t\tthis._run(this.template, this.initialData, ourCallback)\n\n\t\treturn this.destination\n\t}\n\n\t_resolveHandlingExpression(template, handlingExpression, data) {\n\t\tif (!handlingExpression) {\n\t\t\thandlingExpression = defaultTemplateName\n\t\t}\n\t\tif (handlingExpression.charAt(0) == '$') {\n\t\t\t// Indicates the handling espression is not a literal template name but is a string which should\n\t\t\t// be evaluated to determine the template name\n\t\t\thandlingExpression = evaluateInContext(data, handlingExpression.substring(1), this.dataFunctions, this.initialData)\n\t\t}\n\t\t// resolve relative template paths\n\t\tif (handlingExpression.indexOf('./') == 0 || handlingExpression.indexOf('../') == 0) {\n\t\t\thandlingExpression = calculateRelativePath(template.templateMeta.name, handlingExpression)\n\t\t}\n\n\t\treturn handlingExpression\n\t}\n\n\t_run(template, data, callback) {\n\t\tlet parts = [...template.parts].reverse()\n\t\tconst processParts = () => {\n\t\t\t\n\t\t\t// check to see how far down in the call stack we are. If too far down,\n\t\t\t// come back in the next tick.\n\t\t\tthis.callCount++\n\t\t\tif(this.callCount++ > this.callDepthLimit) {\n\t\t\t\tsetTimeout(()=> {\n\t\t\t\t\tthis.callCount = 0\n\t\t\t\t\tprocessParts()\n\t\t\t\t})\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tif (parts.length > 0) {\n\t\t\t\tlet part = parts.pop()\n\t\t\t\tif (typeof part === 'string') {\n\t\t\t\t\tthis.output(part)\n\t\t\t\t\tprocessParts()\n\t\t\t\t}\n\t\t\t\telse if (part instanceof ActiveElement) {\n\t\t\t\t\tlet conditional = part.conditionalExpression || part.dataExpression\n\t\t\t\t\tlet conditionalResult = false\n\t\t\t\t\tlet resultData\n\t\t\t\t\tif (conditional == null || conditional == undefined || conditional === '') {\n\t\t\t\t\t\t// Because if they didn't specify a condition or data, they probably \n\t\t\t\t\t\t// just want the template to be run as is\n\t\t\t\t\t\tconditionalResult = true\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tif(part.conditionalExpression) {\n\t\t\t\t\t\t\tlet result = evaluateInContext(data, part.conditionalExpression, this.dataFunctions, this.initialData)\n\t\t\t\t\t\t\tif (result) {\n\t\t\t\t\t\t\t\tconditionalResult = true\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t// This means we're evaluating the data expression to see if we should run the template\n\t\t\t\t\t\t\tresultData = evaluateInContext(data, part.dataExpression, this.dataFunctions, this.initialData)\n\t\t\t\t\t\t\tif(resultData === null || resultData === undefined) {\n\t\t\t\t\t\t\t\tconditionalResult = false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if (typeof resultData === 'number') {\n\t\t\t\t\t\t\t\t// if the result is a number, any number, we want to output it\n\t\t\t\t\t\t\t\t// unless the number is from the conditional expression, in which\n\t\t\t\t\t\t\t\t// case we want to evaluate it as truthy\n\t\t\t\t\t\t\t\tconditionalResult = true\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if(Array.isArray(resultData) && resultData.length > 0) {\n\t\t\t\t\t\t\t\tconditionalResult = true\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse if(resultData) {\n\t\t\t\t\t\t\t\tconditionalResult = true\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\n\t\t\t\t\tif (conditionalResult) {\n\t\t\t\t\t\tif (part.dataExpression && resultData === undefined) {\n\t\t\t\t\t\t\tresultData = evaluateInContext(data, part.dataExpression, this.dataFunctions, this.initialData)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif((resultData === null || resultData === undefined) && !part.dataExpression) {\n\t\t\t\t\t\t\t// we only want use the context data for the template data if we didn't have a data expression\n\t\t\t\t\t\t\tresultData = data\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet handlingExpression = this._resolveHandlingExpression(template, part.handlingExpression, data)\n\t\t\t\t\t\tlet handlingTemplate\n\t\t\t\t\t\tlet children = (Array.isArray(resultData) ? [...resultData] : [resultData]).reverse()\n\t\t\t\t\t\tconst applyTemplate = () => {\n\t\t\t\t\t\t\tif (children.length > 0) {\n\t\t\t\t\t\t\t\tlet child = children.pop()\n\t\t\t\t\t\t\t\tthis._run(handlingTemplate, child, () => {\n\t\t\t\t\t\t\t\t\tapplyTemplate()\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tprocessParts()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif(handlingExpression in this.tripartite.templates) {\n\t\t\t\t\t\t\thandlingTemplate = this.tripartite.getTemplate(handlingExpression)\n\t\t\t\t\t\t\tif (handlingTemplate) {\n\t\t\t\t\t\t\t\tapplyTemplate()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t// the template has been loaded before but is empty\n\t\t\t\t\t\t\t\tif (this.continueOnTripartiteError) {\n\t\t\t\t\t\t\t\t\tprocessParts()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis.tripartite.loadTemplate(handlingExpression, (template) => {\n\t\t\t\t\t\t\t\tif (!template) {\n\t\t\t\t\t\t\t\t\tlet msg = 'Could not load template: ' + handlingExpression\n\t\t\t\t\t\t\t\t\tconsole.error(msg)\n\t\t\t\t\t\t\t\t\tif (this.continueOnTripartiteError) {\n\t\t\t\t\t\t\t\t\t\tprocessParts()\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\tlet err = new Error(msg)\n\t\t\t\t\t\t\t\t\t\tif (callback) {\n\t\t\t\t\t\t\t\t\t\t\tcallback(err)\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\t\t\tthrow err\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\thandlingTemplate = template\n\t\t\t\t\t\t\t\t\tapplyTemplate()\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tprocessParts()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (typeof part === 'function') {\n\t\t\t\t\tif(part.write) {\n\t\t\t\t\t\tpart.write(data, this.destination, () => {\n\t\t\t\t\t\t\tprocessParts()\n\t\t\t\t\t\t})\n\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis.output(part(data))\n\t\t\t\t\t\tprocessParts()\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (callback) {\n\t\t\t\t\tcallback()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tprocessParts()\n\t}\n\n\t/**\n\t * \n\t * @param {string} value \n\t */\n\toutput(value) {\n\t\tif(value === null || value === undefined) {\n\t\t\treturn\n\t\t}\n\t\tif (typeof this.destination === 'string') {\n\t\t\tthis.destination += value\n\t\t}\n\t\telse if (this.destination.write) {\n\t\t\tthis.destination.write(value)\n\t\t}\n\t}\n}\n\n\nmodule.exports = ExecutionContext","/*\nfunction resolveDataPath(data, path) {\n\tif(data === null || data === undefined) {\n\t\treturn data\n\t}\n\tlet parts\n\tif(typeof path === 'string') {\n\t\tparts = path.trim().split('.')\n\t}\n\telse if(Array.isArray(path)) {\n\t\tparts = path\n\t}\n\t\n\tlet name = parts.shift()\n\tif(name.indexOf(' ') > -1) {\n\t\t// there's a space, which means it's really unlikely it's a property\n\t\treturn null\n\t}\n\tlet child\n\tif(name === 'this' || name === '$this') {\n\t\tchild = data\n\t}\n\telse if(typeof data === 'object') {\n\t\tif(name in data) {\n\t\t\tchild = data[name]\n\t\t}\n\t}\n\tif(parts.length > 0) {\n\t\treturn resolveDataPath(child, parts)\n\t}\n\telse {\n\t\treturn child\n\t}\n} */\nfunction resolveDataPath(data, path) {\n\ttry {\n\t\tif (data === null || data === undefined) {\n\t\t\treturn data\n\t\t}\n\t\tlet parts\n\t\tif (typeof path === 'string') {\n\t\t\tparts = path.trim().split('.')\n\t\t}\n\t\telse if (Array.isArray(path)) {\n\t\t\tparts = path\n\t\t}\n\n\t\twhile (parts.length > 0) {\n\t\t\tlet name = parts.shift()\n\t\t\tif (name.indexOf(' ') > -1) {\n\t\t\t\t// there's a space, which means it's really unlikely it's a property\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tlet child\n\t\t\tif (name === 'this' || name === '$this') {\n\t\t\t\tchild = data\n\t\t\t}\n\t\t\telse if (typeof data === 'object') {\n\t\t\t\tif (name in data) {\n\t\t\t\t\tchild = data[name]\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (parts.length == 0) {\n\t\t\t\treturn child\n\t\t\t}\n\t\t\tif (child === null || child === undefined) {\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tdata = child\n\t\t}\n\t}\n\tcatch (e) {\n\t\treturn null\n\t}\n}\n\nmodule.exports = resolveDataPath","\n\n\nif (typeof String.prototype.trim !== 'function') {\n\tString.prototype.trim = function () {\n\t\treturn this.replace(/^\\s+|\\s+$/g, '');\n\t}\n}\n\n\nfunction isStream(stream) {\n\treturn stream !== null\n\t\t&& typeof stream === 'object'\n\t\t&& typeof stream.pipe === 'function';\n}\n\n\nfunction isTemplate(obj) {\n\tif (!obj) {\n\t\treturn false\n\t}\n\tif (typeof obj !== 'function') {\n\t\treturn false\n\t}\n\tif (!obj.write) {\n\t\treturn false\n\t}\n\tif (!obj.parts) {\n\t\treturn false\n\t}\n\tif (!obj.templateMeta) {\n\t\treturn false\n\t}\n\n\treturn true\n}\n\nlet ExecutionContext = require('./execution-context')\nlet ActiveElement = require('./active-element')\n\n\nclass Tripartite {\n\tconstructor(options = {}) {\n\t\tthis.templates = {\n\t\t\tdefaultTemplate: this._makeTemplate(function (thedata) {\n\t\t\t\treturn '' + thedata;\n\t\t\t})\n\t\t}\n\t\tlet { constants = {\n\t\t\ttemplateBoundary: '__',\n\t\t\ttemplateNameBoundary: '##'\n\t\t} } = options\n\t\tthis.constants = constants\n\n\t\t// This object (if set) will receive the template functions parsed from a script\n\t\t// I want to be able to call my templates as global functions, so I've set it\n\t\t// to be the window object\n\t\tthis.secondaryTemplateFunctionObject = options.secondaryTemplateFunctionObject\n\n\t\tthis.loaders = options.loaders || []\n\n\t\tthis.dataFunctions = options.dataFunction || {}\n\t}\n\n\t_makeTemplate(transformationFunction) {\n\t\tif (isTemplate(transformationFunction)) {\n\t\t\treturn transformationFunction\n\t\t}\n\t\tlet tri = this\n\t\tlet f = function (thedata) {\n\t\t\tlet stream = null\n\t\t\tlet options = null\n\t\t\tlet callback = null\n\t\t\tfor (let i = 1; i < arguments.length; i++) {\n\t\t\t\tlet arg = arguments[i]\n\t\t\t\tif (isStream(arg)) {\n\t\t\t\t\tstream = arg\n\t\t\t\t}\n\t\t\t\telse if(typeof arg === 'function') {\n\t\t\t\t\tcallback = arg\n\t\t\t\t}\n\t\t\t\telse if(typeof arg === 'object') {\n\t\t\t\t\toptions = arg\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn f.write(thedata, stream, callback, options)\n\t\t}\n\t\tf.write = function (thedata, stream, callback, options = {}) {\n\t\t\tif(transformationFunction && transformationFunction.write) {\n\t\t\t\t// if it's not a template, but has a write method, invoke the right method directly\n\t\t\t\treturn transformationFunction.write.apply(transformationFunction, arguments)\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlet dest = stream || ''\n\n\t\t\t\tlet context = new ExecutionContext(tri, f, thedata, dest, tri.dataFunctions)\n\t\t\t\tif (options && 'continueOnTripartiteError' in options) {\n\t\t\t\t\tcontext.continueOnTripartiteError = options.continueOnTripartiteError\n\t\t\t\t}\n\n\t\t\t\treturn context.run(callback)\n\t\t\t}\n\t\t}\n\t\tf.run = async function(data) {\n\t\t\tlet p = new Promise((resolve, reject) => {\n\t\t\t\tf(data, (err, content) => {\n\t\t\t\t\tif(err) {\n\t\t\t\t\t\treject(err)\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tresolve(content)\n\t\t\t\t\t}\n\t\t\t\t})\n\n\t\t\t})\n\t\t\treturn p\n\t\t}\n\t\tf.parts = []\n\t\tif (transformationFunction && typeof transformationFunction === 'function') {\n\t\t\tf.parts.push(transformationFunction)\n\t\t}\n\t\tf.templateMeta = {}\n\t\treturn f\n\t}\n\n\taddTemplate(name, template) {\n\t\tif (typeof template === 'string') {\n\t\t\ttemplate = this.parseTemplate(template);\n\t\t}\n\t\telse if (typeof template === 'function') {\n\t\t\ttemplate = this._makeTemplate(template)\n\t\t}\n\n\t\tthis.templates[name] = template;\n\t\ttemplate.templateMeta = template.templateMeta || {}\n\t\ttemplate.templateMeta.name = name\n\t\treturn template;\n\t}\n\n\tcreateBlank() {\n\t\treturn new Tripartite()\n\t}\n\n\tgetTemplate(name) {\n\t\treturn this.templates[name]\n\t}\n\n\tloadTemplate(name, callback) {\n\t\tif (name in this.templates) {\n\t\t\tcallback(this.templates[name])\n\t\t}\n\t\telse {\n\t\t\tlet tri = this\n\t\t\tlet count = this.loaders.length\n\t\t\tlet done = false\n\n\t\t\tif (count == 0) {\n\t\t\t\ttri.templates[name] = null\n\t\t\t\tcallback(tri.getTemplate(name))\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis.loaders.forEach(loader => {\n\t\t\t\t\tif (done) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tloader(name, template => {\n\t\t\t\t\t\tif (done) {\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcount--\n\t\t\t\t\t\tif (template) {\n\t\t\t\t\t\t\tdone = true\n\t\t\t\t\t\t\ttri.addTemplate(name, template)\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (count == 0) {\n\t\t\t\t\t\t\tdone = true\n\t\t\t\t\t\t\ttri.templates[name] = null\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (done) {\n\t\t\t\t\t\t\tcallback(tri.getTemplate(name))\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t}\n\tparseTemplateScript(tx) {\n\t\tvar tks = this.tokenizeTemplateScript(tx);\n\t\t/* current template name */\n\t\tvar ctn = null;\n\t\tfor (var i = 0; i < tks.length; i++) {\n\t\t\tvar token = tks[i];\n\t\t\tif (token.active) {\n\t\t\t\tctn = token.content;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (ctn) {\n\t\t\t\t\tvar template = this.addTemplate(ctn, this.stripTemplateWhitespace(token.content));\n\t\t\t\t\tif (this.secondaryTemplateFunctionObject) {\n\t\t\t\t\t\tthis.secondaryTemplateFunctionObject[ctn] = template;\n\t\t\t\t\t}\n\t\t\t\t\tctn = null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tstripTemplateWhitespace(txt) {\n\t\tvar i = txt.indexOf('\\n');\n\t\tif (i > -1 && txt.substring(0, i).trim() == '') {\n\t\t\ttxt = txt.substring(i + 1);\n\t\t}\n\t\ti = txt.lastIndexOf('\\n');\n\t\tif (i > -1 && txt.substring(i).trim() == '') {\n\t\t\ttxt = txt.substring(0, i);\n\t\t}\n\t\treturn txt;\n\t}\n\n\t/* simple template */\n\t_createActiveElement(/* conditional expression */ cd, data, /* handling expression */ hd, tripartite, templateMeta) {\n\t\tlet el = new ActiveElement(cd, data, hd, tripartite);\n\t\tel.templateMeta = templateMeta\n\t\treturn el\n\t}\n\tpt(tx) {\n\t\treturn this.parseTemplate(tx)\n\t}\n\t/* parse template */\n\tparseTemplate(tx) {\n\t\tvar tks = this.tokenizeTemplate(tx);\n\t\tlet t = this._makeTemplate()\n\t\tvar templateMeta = t.templateMeta\n\n\t\tfor (let tk of tks) {\n\t\t\tif (tk.active) {\n\t\t\t\tt.parts.push(this.tokenizeActivePart(tk.content, templateMeta));\n\t\t\t}\n\t\t\telse if (tk.content) {\n\t\t\t\tt.parts.push(tk.content);\n\t\t\t}\n\t\t}\n\n\t\treturn t\n\t}\n\n\ttokenizeActivePart(tx, templateMeta) {\n\t\tvar con = null;\n\t\tvar dat = null;\n\t\tvar han = null;\n\n\t\t/* condition index */\n\t\tvar ci = tx.indexOf('??');\n\t\tif (ci > -1) {\n\t\t\tcon = tx.substring(0, ci);\n\t\t\tci += 2;\n\t\t}\n\t\telse {\n\t\t\tci = 0;\n\t\t}\n\n\t\t/* handler index */\n\t\tvar hi = tx.indexOf('::');\n\t\tif (hi > -1) {\n\t\t\tdat = tx.substring(ci, hi);\n\t\t\than = tx.substring(hi + 2);\n\t\t}\n\t\telse {\n\t\t\tdat = tx.substring(ci);\n\t\t}\n\t\treturn this._createActiveElement(con, dat, han, this, templateMeta);\n\t}\n\n\ttokenizeTemplate(tx) {\n\t\treturn this.tokenizeActiveAndInactiveBlocks(tx, this.constants.templateBoundary);\n\t}\n\n\n\t/** tokenize template script */\n\ttokenizeTemplateScript(tx) {\n\t\treturn this.tokenizeActiveAndInactiveBlocks(tx, this.constants.templateNameBoundary);\n\t}\n\n\t/* tokenize active and inactive blocks */\n\ttokenizeActiveAndInactiveBlocks(text, /*Active Region Boundary */ boundary) {\n\t\t/* whole length */\n\t\tlet length = text.length\n\n\t\t/* current position */\n\t\tlet position = 0\n\n\t\t/* are we in an active region */\n\t\tlet act = false\n\n\t\tlet tokens = []\n\n\t\twhile (position < length) {\n\t\t\tlet i = text.indexOf(boundary, position);\n\t\t\tif (i == -1) {\n\t\t\t\ti = length;\n\t\t\t}\n\t\t\tvar tk = { active: act, content: text.substring(position, i) };\n\t\t\ttokens.push(tk);\n\t\t\tposition = i + boundary.length;\n\t\t\tact = !act;\n\t\t}\n\n\t\treturn tokens;\n\t}\n\n}\nvar tripartiteInstance = new Tripartite()\n\nif (typeof window != 'undefined') {\n\ttripartiteInstance.secondaryTemplateFunctionObject = window\n}\n\n\nif (typeof module !== 'undefined') {\n\tmodule.exports = tripartiteInstance\n}\nelse {\n\twindow.Tripartite = tripartiteInstance\n}\n\nif (typeof global != 'undefined') {\n\tif (!global.Tripartite) {\n\t\tglobal.Tripartite = Tripartite\n\t}\n\tif (!global.tripartite) {\n\t\tglobal.tripartite = tripartiteInstance\n\t}\n}\n\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))"],"names":["module","exports","constructor","conditionalExpression","dataExpression","handlingExpression","tripartite","this","parentPath","currentPath","indexOf","pparts","split","cparts","length","shift","pop","push","join","resolveDataPath","evalFunction","Function","_evaluateInContext","context","expression","dataFunctions","globalData","call","trim","resolved","ActiveElement","calculateRelativePath","evaluateInContext","template","data","destination","initialData","currentData","continueOnTripartiteError","callCount","callDepthLimit","run","callback","ourCallback","_run","_resolveHandlingExpression","defaultTemplateName","charAt","substring","templateMeta","name","parts","reverse","processParts","setTimeout","part","output","resultData","conditional","conditionalResult","undefined","Array","isArray","handlingTemplate","children","applyTemplate","child","templates","getTemplate","loadTemplate","msg","console","error","err","Error","write","value","path","e","isStream","stream","pipe","String","prototype","replace","ExecutionContext","Tripartite","options","defaultTemplate","_makeTemplate","thedata","constants","templateBoundary","templateNameBoundary","secondaryTemplateFunctionObject","loaders","dataFunction","transformationFunction","obj","tri","f","i","arguments","arg","apply","async","Promise","resolve","reject","content","addTemplate","parseTemplate","createBlank","count","done","forEach","loader","parseTemplateScript","tx","tks","tokenizeTemplateScript","ctn","token","active","stripTemplateWhitespace","txt","lastIndexOf","_createActiveElement","cd","hd","el","pt","tokenizeTemplate","t","tk","tokenizeActivePart","con","dat","han","ci","hi","tokenizeActiveAndInactiveBlocks","text","boundary","position","act","tokens","tripartiteInstance","window","g","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","globalThis","prop","hasOwnProperty"],"sourceRoot":""}
|