@longform/longform 0.0.4 → 0.0.5

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.
Binary file
Binary file
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../lib/longform.ts"],
4
- "sourcesContent": ["import type { FragmentType, ParsedResult, WorkingElement, WorkingFragment, Fragment } from \"./types.ts\";\n\nexport type {\n FragmentType,\n Fragment,\n ParsedResult\n};\n\nconst sniffTestRe = /^(?:(?:(--).*)|(?: *(@|#).*)|(?: *[\\w\\-]+(?::[\\w\\-]+)?(?:[#.[][^\\n]+)?(::).*)|(?: +([\\[\"]).*)|(\\ \\ .*))$/gmi\n , element1 = /((?:\\ \\ )+)? ?([\\w\\-]+(?::[\\w\\-]+)?)([#\\.\\[][^\\n]*)?::(?: ({{?|[^\\n]+))?/gmi\n , directive1 = /((?:\\ \\ )+)? ?@([\\w][\\w\\-]+)(?::: ?([^\\n]+)?)?/gmi\n , attribute1 = /((?:\\ \\ )+)\\[(\\w[\\w-]*(?::\\w[\\w-]*)?)(?:=([^\\n]+))?\\]/\n , preformattedClose = /[ \\t]*}}?[ \\t]*/\n , id1 = /((?:\\ \\ )+)?#(#)?([\\w\\-]+)(?: ([\\[\"]))?/gmi\n , idnt1 = /^(\\ \\ )+/\n , text1 = /^((?:\\ \\ )+)([^ \\n][^\\n]*)$/i\n , paramsRe = /(?:(#|\\.)([^#.\\[\\n]+)|(?:\\[(\\w[\\w\\-]*(?::\\w[\\w\\-]*)?)(?:=([^\\n\\]]+))?\\]))/g\n , refRe = /#\\[([\\w\\-]+)\\]/g\n , escapeRe = /([&<>\"'#\\[\\]{}])/g\n , templateLinesRe = /^(\\ \\ )?([^\\n]+)$/gmi\n , voids = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wrb']);\n\nlet m1: RegExpExecArray | null\n , m2: RegExpExecArray | null\n , m3: RegExpExecArray | null;\n\nconst entities = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n \"'\": '&apos;',\n// '#': '&num;',\n// '[': '&lbrak;',\n// ']': '&rbrak;',\n// '{': '&rbrace;',\n// '}': '&lbrace;',\n};\n\nfunction escape(value: string): string {\n return value.replace(escapeRe, (match) => {\n return entities[match] ?? match;\n });\n}\n\nfunction makeElement(indent: number = 0): WorkingElement {\n return {\n indent,\n html: '',\n attrs: {},\n };\n}\n\nfunction makeFragment(type: FragmentType = 'bare'): WorkingFragment {\n return {\n type,\n html: '',\n template: false,\n mountable: false,\n els: [],\n refs: [],\n mountPoints: [],\n };\n}\n\n/**\n * Parses a longform document into a object containing the root and fragments\n * in the output format.\n *\n * @param {string} doc - The longform document to parse.\n * @returns {ParsedResult}\n */\nexport function longform(doc: string, debug: (...d: unknown[]) => void = () => {}): ParsedResult {\n let skipping: boolean = false\n , textIndent: number | null = null\n , verbatimSerialize: boolean = true\n , verbatimIndent: number | null = null\n , verbatimFirst: boolean = false\n , element: WorkingElement = makeElement()\n , fragment: WorkingFragment = makeFragment()\n // the root fragment\n , root: WorkingFragment | null = null\n // ids of claimed fragments\n const claimed: Set<string> = new Set()\n // parsed fragments\n , parsed: Map<string, WorkingFragment> = new Map()\n , output: ParsedResult = Object.create(null);\n\n output.fragments = Object.create(null);\n output.templates = Object.create(null);\n \n \n /**\n * Closes any current in progress element definition\n * and creates a new working element.\n */\n function applyIndent(targetIndent: number) {\n if (element.tag != null) {\n const root = fragment.type === 'range'\n ? targetIndent < 2\n : fragment.html === ''\n ;\n\n fragment.html += `<${element.tag}`\n\n if (root) {\n if (fragment.type === 'root') {\n fragment.html += ` data-lf-root`;\n } else if (fragment.type === 'bare' || fragment.type === 'range') {\n fragment.html += ` data-lf=\"${fragment.id}\"`;\n }\n }\n\n if (element.mount != null) {\n fragment.html += ` data-lf-mount=\"${element.mount}\"`;\n }\n\n if (element.id != null) {\n fragment.html += ' id=\"' + element.id + '\"';\n }\n\n if (element.class != null) {\n fragment.html += ' class=\"' + element.class + '\"';\n }\n\n for (const attr of Object.entries(element.attrs)) {\n if (attr[1] == null) {\n fragment.html += ' ' + attr[0]\n } else {\n fragment.html += ` ${attr[0]}=\"${attr[1]}\"`;\n }\n }\n\n fragment.html += '>';\n\n if (!voids.has(element.tag as string) && element.text != null) {\n fragment.html += element.text;\n }\n\n if (\n !voids.has(element.tag as string)\n ) {\n fragment.els.push(element);\n }\n }\n\n if (targetIndent <= element.indent) {\n element = makeElement(targetIndent);\n\n while (\n fragment.els.length !== 0 && (\n targetIndent == null ||\n fragment.els[fragment.els.length - 1].indent !== targetIndent - 1\n )\n ) {\n const element = fragment.els.pop();\n\n fragment.html += `</${element?.tag}>`;\n }\n\n if (targetIndent === 0) {\n debug(0, '<', fragment.type, fragment.id);\n if (fragment.template) {\n output.templates[fragment.id] = fragment.html;\n } else if (fragment.type === 'root') {\n root = fragment;\n } else {\n parsed.set(fragment.id, fragment);\n }\n\n fragment = makeFragment();\n }\n } else {\n element = makeElement(targetIndent)\n }\n }\n\n while ((m1 = sniffTestRe.exec(doc))) {\n if (m1[1] === '--') {\n continue;\n } else if (fragment.template) {\n fragment.html += m1[0];\n }\n\n // If this is a script tag or preformatted block\n // we want to retain the intended formatting less\n // the indent. Preformatting can apply to any element\n // by ending the declaration with `:: {`.\n if (verbatimIndent != null) {\n // inside a script or preformatted block\n idnt1.lastIndex = 0;\n m2 = idnt1.exec(m1[0]);\n const indent = m2 == null\n ? null\n : m2[0].length / 2;\n\n if (m2 == null || indent as number <= verbatimIndent) {\n fragment.html += '\\n';\n debug(indent, '}', m2?.[0]);\n\n applyIndent(indent);\n verbatimIndent = null;\n verbatimFirst = false;\n textIndent = indent;\n\n if (preformattedClose.test(m1[0])) {\n continue;\n }\n } else {\n const line = m1[0].replace(' '.repeat(verbatimIndent + 1), '');\n debug(indent, '{', line);\n\n if (element.tag != null) {\n applyIndent(indent as number);\n }\n\n if (verbatimFirst) {\n verbatimFirst = false;\n } else {\n fragment.html += '\\n';\n }\n \n if (verbatimSerialize) {\n fragment.html += escape(line);\n } else {\n fragment.html += line;\n }\n\n continue;\n }\n }\n\n if (m1[0].trim() === '') {\n continue;\n }\n\n switch (m1[2] ?? m1[3] ?? m1[4]) {\n // deno-lint-ignore no-fallthrough\n case '#': {\n id1.lastIndex = 0;\n m2 = id1.exec(m1[0]);\n\n if (m2 != null) {\n const indent = (m2[1]?.length ?? 0) / 2;\n\n if (element.tag != null || textIndent != null) {\n applyIndent(indent);\n textIndent = null;\n }\n\n debug(indent, 'id', m2[2], m2[3], m2[4]);\n\n fragment.id = m2[3];\n\n if (indent === 0) {\n if (m2[4] == '[') {\n fragment.type = 'range';\n } else if (m2[4] === '\"') {\n fragment.type = 'text';\n } else if (m2[2] != null) {\n fragment.type = 'bare';\n } else {\n fragment.type = 'embed';\n element.id = fragment.id;\n }\n }\n\n break;\n }\n }\n case '@':\n case '[':\n // deno-lint-ignore no-fallthrough\n case '::': {\n element1.lastIndex = 0;\n // fall through if m1[3] is a # or @\n m2 = m1[2] ?? m1[4] != null\n ? null\n : element1.exec(m1[0]);\n\n // if null then invalid element selector\n // allow the default text case to handle\n if (m2 != null) {\n const indent = (m2[1]?.length ?? 0) / 2\n , tg = m2[2]\n , ar = m2[3]\n , pr = m2[4] === '{' || m2[4] === '{{'\n const tx = pr ? null : m2[4]\n\n debug(indent, 'e', tg, pr, tx);\n\n if (\n element.tag != null ||\n element.indent > indent\n ) {\n applyIndent(indent);\n }\n\n element.indent = indent;\n element.tag = tg;\n\n textIndent = null;\n \n if (indent === 0 && fragment.id == null) {\n if (root != null) {\n skipping = true;\n } else {\n fragment.type = 'root';\n root = fragment;\n }\n }\n \n if (ar != null) {\n debug(indent, 'a', ar);\n while ((m2 = paramsRe.exec(ar))) {\n if (m2[1] === '#') {\n element.id = m2[2];\n } else if (m2[1] === '.') {\n if (element.class == null) {\n element.class = m2[2];\n } else {\n element.class += ' ' + m2[2];\n }\n } else {\n if (m2[3] === 'id') {\n if (element.id == null) {\n element.id = m2[4];\n }\n } else if (m2[3] === 'class') {\n if (element.class == null) {\n element.class = m2[4]\n } else {\n element.class += ' ' + m2[4]\n }\n } else {\n element.attrs[m2[3]] = m2[4];\n }\n }\n }\n }\n\n // this is a hack to get temp support of mounting\n // working. In the future it will be moved to a \n // server specific process.\n if (element.mount != null) {\n const id = element.mount;\n applyIndent(indent + 1);\n fragment.mountPoints.push({\n id,\n part: fragment.html,\n });\n fragment.html = '';\n applyIndent(indent);\n break;\n }\n\n if (!pr && tx != null) {\n element.text = tx;\n } else if (pr) {\n verbatimFirst = true;\n verbatimIndent = indent;\n verbatimSerialize = m2[4] === '{';\n }\n\n break;\n }\n\n attribute1.lastIndex = 0;\n m2 = m1[2] != null\n ? null\n : attribute1.exec(m1[0]);\n\n if (m2 != null && element.tag != null) {\n debug('a', m2[2], m2[3]);\n\n if (m2[2] === 'id') {\n if (element.id == null) {\n element.id = m2[3].trim();\n }\n } else if (m2[2] === 'class') {\n if (element.class != null) {\n element.class += ' ' + m2[3].trim();\n } else {\n element.class = m2[3].trim();\n }\n } else if (element.attrs[m2[2]] != null) {\n element.attrs[m2[2]] += m2[3];\n } else {\n element.attrs[m2[2]] = m2[3];\n }\n\n break;\n }\n\n directive1.lastIndex = 0;\n m2 = m1[3] != null\n ? null \n : directive1.exec(m1[0]);\n\n if (m2 != null) {\n const indent = (m2[1]?.length ?? 0) / 2;\n\n if (element.tag != null || textIndent != null) {\n applyIndent(indent);\n }\n\n debug(indent, 'd', m2[2], m2[3]);\n\n switch (m2[2]) {\n case 'doctype': {\n fragment.html += `<!doctype ${m2[3] ?? 'html'}>`;\n break;\n }\n case 'xml': {\n fragment.html += `<?xml ${m2[3] ?? 'version=\"1.0\" encoding=\"UTF-8\"'}?>`;\n break;\n }\n case 'template': {\n let indented = false;\n fragment.template = indent === 0;\n\n templateLinesRe.lastIndex = sniffTestRe.lastIndex;\n while ((m2 = templateLinesRe.exec(doc))) {\n if (m2[1] == null && !indented && fragment.id == null) {\n id1.lastIndex = 0;\n m3 = id1.exec(m2[0]);\n\n if (m3 != null) fragment.id = m3[3];\n\n fragment.html += m2[0];\n } else if (m2[1] == null && indented) {\n sniffTestRe.lastIndex = templateLinesRe.lastIndex - m2[0].length;\n break;\n } else {\n fragment.html += '\\n' + m2[0];\n if (m2[1] != null) indented = true;\n }\n }\n\n applyIndent(0);\n break;\n }\n case 'mount': {\n if (m2[3] == null) {\n throw new Error('Mount points must have a name');\n } else if (fragment.type !== 'root') {\n throw new Error('Mounting is only allowed on a root element');\n }\n\n fragment.mountable = true;\n element.mount = m2[3].trim();\n break;\n }\n }\n\n break;\n }\n\n }\n default: {\n m2 = text1.exec(m1[0]) as RegExpExecArray;\n\n if (m2 == null) {\n break;\n }\n const indent = m2[1].length / 2;\n const tx = m2[2].trim();\n\n debug(indent, 't', m2[2]);\n\n if (element.tag != null) {\n applyIndent(indent);\n\n fragment.html += tx;\n } else if (fragment.type === 'text' && fragment.html === '') {\n fragment.html += tx;\n } else {\n fragment.html += ' ' + tx;\n }\n\n textIndent = indent;\n\n while ((m2 = refRe.exec(tx))) {\n const start = fragment.html.length + m2.index - tx.length;\n\n fragment.refs.push({\n id: m2[1],\n start,\n end: start + m2[0].length,\n });\n }\n\n break;\n }\n }\n }\n\n applyIndent(0);\n\n const arr = Array.from(parsed.values());\n\n function flatten(fragment: WorkingFragment): WorkingFragment {\n // work backwards so we don't change the html string length\n // for the later replacements\n for (let j = fragment.refs.length - 1; j >= 0; j--) {\n const ref = fragment.refs[j];\n\n if (claimed.has(ref.id) || !parsed.has(ref.id)) {\n fragment.html = fragment.html.slice(0, ref.start)\n + fragment.html.slice(ref.end)\n } else {\n const child = flatten(parsed.get(ref.id));\n\n fragment.html = fragment.html.slice(0, ref.start)\n + child.html\n + fragment.html.slice(ref.end);\n\n if (child.type === 'embed') {\n claimed.add(child.id)\n }\n }\n }\n\n fragment.refs = [];\n\n return fragment;\n }\n\n if (root?.mountable) {\n output.mountable = true;\n output.tail = root.html;\n output.mountPoints = root.mountPoints;\n\n return output;\n }\n\n for (let i = 0; i < parsed.size + 1; i++) {\n let fragment: WorkingFragment;\n \n if (i === 0 && root == null) {\n continue;\n } else if (i === 0) {\n fragment = root;\n } else {\n fragment = arr[i - 1];\n }\n\n if (fragment.refs.length === 0) {\n continue;\n }\n\n flatten(fragment)\n }\n\n if (root?.html != null) {\n output.root = root.html;\n output.selector = `[data-lf-root]`;\n }\n\n for (let i = 0; i < arr.length; i++) {\n let selector: string;\n const fragment = arr[i];\n\n if (fragment == null || claimed.has(fragment.id)) {\n continue;\n }\n\n if (fragment.type === 'embed') {\n selector = `[id=${fragment.id}]`;\n } else if (fragment.type === 'bare') {\n selector = `[data-lf=${fragment.id}]`;\n } else if (fragment.type === 'range') {\n selector = `[data-lf=${fragment.id}]`;\n }\n\n output.fragments[fragment.id] = {\n id: fragment.id,\n selector,\n type: fragment.type as 'embed' | 'bare' | 'range',\n html: fragment.html,\n };\n }\n\n return output;\n}\n\n\nconst templateRe = /(?:#{([\\w][\\w\\-_]*)})|(?:#\\[([\\w][\\w\\-_]+)\\])/g;\n\n/**\n * Processes a client side Longform template to HTML fragment string.\n *\n * @param fragment - The fragment identifier.\n * @param args - A record of template arguments.\n * @param getFragment - A function which returns an already processed fragment's HTML string.\n * @returns The processed template.\n */\nexport function processTemplate(\n template: string,\n args: Record<string, string | number>,\n getFragment: (fragment: string) => string | undefined,\n): string | undefined {\n const lf = template.replace(templateRe, (_match, param, ref) => {\n if (ref != null) {\n const fragment = getFragment(ref);\n\n if (fragment == null) return '';\n\n return fragment;\n }\n \n return args[param] != null ? escape(args[param].toString()) : '';\n });\n\n return Object.values(longform(lf).fragments)[0]?.html ?? null;\n}\n"],
5
- "mappings": "AAQA,MAAM,cAAc,gHAChB,WAAW,+EACX,aAAa,qDACb,aAAa,yDACb,oBAAoB,mBACpB,MAAM,8CACN,QAAQ,YACR,QAAQ,gCACR,WAAW,8EACX,QAAQ,mBACR,WAAW,qBAC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EAAE,IAAI;AAAA,MAC9B,IAAIA,UAAS;AAAA,MACb;AAAA,MACA,MAAMA,UAAS;AAAA,MACf,MAAMA,UAAS;AAAA,IACjB;AAAA,EACF;AAEA,SAAO;AACT;AAGA,MAAM,aAAa;AAUZ,gBAAS,gBACd,UACA,MACA,aACoB;AAzlBtB;AA0lBE,QAAM,KAAK,SAAS,QAAQ,YAAY,CAAC,QAAQ,OAAO,QAAQ;AAC9D,QAAI,OAAO,MAAM;AACf,YAAM,WAAW,YAAY,GAAG;AAEhC,UAAI,YAAY,KAAM,QAAO;AAE7B,aAAO;AAAA,IACT;AAEA,WAAO,KAAK,KAAK,KAAK,OAAO,OAAO,KAAK,KAAK,EAAE,SAAS,CAAC,IAAI;AAAA,EAChE,CAAC;AAED,UAAO,kBAAO,OAAO,SAAS,EAAE,EAAE,SAAS,EAAE,CAAC,MAAvC,mBAA0C,SAA1C,YAAkD;AAC3D;",
6
- "names": ["root", "element", "fragment"]
7
- }
1
+ {"version":3,"file":"longform.js","sources":["../lib/lib/mod.js/longform.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA,MAAM,WAAW,GAAG,8GAA8G,EAC9H,QAAQ,GAAG,6EAA6E,EACxF,UAAU,GAAG,mDAAmD,EAChE,UAAU,GAAG,uDAAuD,EACpE,iBAAiB,GAAG,iBAAiB,EACrC,GAAG,GAAG,4CAA4C,EAClD,KAAK,GAAG,UAAU,EAClB,KAAK,GAAG,8BAA8B,EACtC,QAAQ,GAAG,4EAA4E,EACvF,KAAK,GAAG,iBAAiB,EACzB,QAAQ,GAAG,mBAAmB,EAC9B,eAAe,GAAG,sBAAsB,EACxC,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAEp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))$/gmi,C=/((?:\ \ )+)? ?([\w\-]+(?::[\w\-]+)?)([#\.\[][^\n]*)?::(?: ({{?|[^\n]+))?/gmi,L=/((?:\ \ )+)? ?@([\w][\w\-]+)(?::: ?([^\n]+)?)?/gmi,U=/((?:\ \ )+)\[(\w[\w-]*(?::\w[\w-]*)?)(?:=([^\n]+))?\]/,K=/[ \t]*}}?[ \t]*/,w=/((?:\ \ )+)?#(#)?([\w\-]+)(?: ([\["]))?/gmi,B=/^(\ \ )+/,N=/^((?:\ \ )+)([^ \n][^\n]*)$/i,Q=/(?:(#|\.)([^#.\[\n]+)|(?:\[(\w[\w\-]*(?::\w[\w\-]*)?)(?:=([^\n\]]+))?\]))/g,V=/#\[([\w\-]+)\]/g,X=/([&<>"'#\[\]{}])/g,E=/^(\ \ )?([^\n]+)$/gmi,D=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wrb"]);let r,e,$;const Y={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&apos;"};function G(o){return o.replace(X,u=>{var g;return(g=Y[u])!=null?g:u})}function W(o=0){return{indent:o,html:"",attrs:{}}}function H(o="bare"){return{type:o,html:"",template:!1,mountable:!1,els:[],refs:[],mountPoints:[]}}export function longform(o,u=()=>{}){var P,I,j,T,A,O,S,M,_,z,q;let g=!1,c=null,p=!0,d=null,x=!1,n=W(),t=H(),a=null;const y=new Set,b=new Map,m=Object.create(null);m.fragments=Object.create(null),m.templates=Object.create(null);function f(l){if(n.tag!=null){const i=t.type==="range"?l<2:t.html==="";t.html+=`<${n.tag}`,i&&(t.type==="root"?t.html+=" data-lf-root":(t.type==="bare"||t.type==="range")&&(t.html+=` data-lf="${t.id}"`)),n.mount!=null&&(t.html+=` data-lf-mount="${n.mount}"`),n.id!=null&&(t.html+=' id="'+n.id+'"'),n.class!=null&&(t.html+=' class="'+n.class+'"');for(const s of Object.entries(n.attrs))s[1]==null?t.html+=" "+s[0]:t.html+=` ${s[0]}="${s[1]}"`;t.html+=">",!D.has(n.tag)&&n.text!=null&&(t.html+=n.text),D.has(n.tag)||t.els.push(n)}if(l<=n.indent){for(n=W(l);t.els.length!==0&&(l==null||t.els[t.els.length-1].indent!==l-1);){const i=t.els.pop();t.html+=`</${i==null?void 0:i.tag}>`}l===0&&(u(0,"<",t.type,t.id),t.template?m.templates[t.id]=t.html:t.type==="root"?a=t:b.set(t.id,t),t=H())}else n=W(l)}for(;r=R.exec(o);)if(r[1]!=="--"){if(t.template&&(t.html+=r[0]),d!=null){B.lastIndex=0,e=B.exec(r[0]);const l=e==null?null:e[0].length/2;if(e==null||l<=d){if(t.html+=`
2
- `,u(l,"}",e==null?void 0:e[0]),f(l),d=null,x=!1,c=l,K.test(r[0]))continue}else{const i=r[0].replace(" ".repeat(d+1),"");u(l,"{",i),n.tag!=null&&f(l),x?x=!1:t.html+=`
3
- `,p?t.html+=G(i):t.html+=i;continue}}if(r[0].trim()!=="")switch((I=(P=r[2])!=null?P:r[3])!=null?I:r[4]){case"#":if(w.lastIndex=0,e=w.exec(r[0]),e!=null){const l=((T=(j=e[1])==null?void 0:j.length)!=null?T:0)/2;(n.tag!=null||c!=null)&&(f(l),c=null),u(l,"id",e[2],e[3],e[4]),t.id=e[3],l===0&&(e[4]=="["?t.type="range":e[4]==='"'?t.type="text":e[2]!=null?t.type="bare":(t.type="embed",n.id=t.id));break}case"@":case"[":case"::":{if(C.lastIndex=0,e=((A=r[2])!=null?A:r[4]!=null)?null:C.exec(r[0]),e!=null){const l=((S=(O=e[1])==null?void 0:O.length)!=null?S:0)/2,i=e[2],s=e[3],h=e[4]==="{"||e[4]==="{{",F=h?null:e[4];if(u(l,"e",i,h,F),(n.tag!=null||n.indent>l)&&f(l),n.indent=l,n.tag=i,c=null,l===0&&t.id==null&&(a!=null?g=!0:(t.type="root",a=t)),s!=null)for(u(l,"a",s);e=Q.exec(s);)e[1]==="#"?n.id=e[2]:e[1]==="."?n.class==null?n.class=e[2]:n.class+=" "+e[2]:e[3]==="id"?n.id==null&&(n.id=e[4]):e[3]==="class"?n.class==null?n.class=e[4]:n.class+=" "+e[4]:n.attrs[e[3]]=e[4];if(n.mount!=null){const J=n.mount;f(l+1),t.mountPoints.push({id:J,part:t.html}),t.html="",f(l);break}!h&&F!=null?n.text=F:h&&(x=!0,d=l,p=e[4]==="{");break}if(U.lastIndex=0,e=r[2]!=null?null:U.exec(r[0]),e!=null&&n.tag!=null){u("a",e[2],e[3]),e[2]==="id"?n.id==null&&(n.id=e[3].trim()):e[2]==="class"?n.class!=null?n.class+=" "+e[3].trim():n.class=e[3].trim():n.attrs[e[2]]!=null?n.attrs[e[2]]+=e[3]:n.attrs[e[2]]=e[3];break}if(L.lastIndex=0,e=r[3]!=null?null:L.exec(r[0]),e!=null){const l=((_=(M=e[1])==null?void 0:M.length)!=null?_:0)/2;switch((n.tag!=null||c!=null)&&f(l),u(l,"d",e[2],e[3]),e[2]){case"doctype":{t.html+=`<!doctype ${(z=e[3])!=null?z:"html"}>`;break}case"xml":{t.html+=`<?xml ${(q=e[3])!=null?q:'version="1.0" encoding="UTF-8"'}?>`;break}case"template":{let i=!1;for(t.template=l===0,E.lastIndex=R.lastIndex;e=E.exec(o);)if(e[1]==null&&!i&&t.id==null)w.lastIndex=0,$=w.exec(e[0]),$!=null&&(t.id=$[3]),t.html+=e[0];else if(e[1]==null&&i){R.lastIndex=E.lastIndex-e[0].length;break}else t.html+=`
4
- `+e[0],e[1]!=null&&(i=!0);f(0);break}case"mount":{if(e[3]==null)throw new Error("Mount points must have a name");if(t.type!=="root")throw new Error("Mounting is only allowed on a root element");t.mountable=!0,n.mount=e[3].trim();break}}break}}default:{if(e=N.exec(r[0]),e==null)break;const l=e[1].length/2,i=e[2].trim();for(u(l,"t",e[2]),n.tag!=null?(f(l),t.html+=i):t.type==="text"&&t.html===""?t.html+=i:t.html+=" "+i,c=l;e=V.exec(i);){const s=t.html.length+e.index-i.length;t.refs.push({id:e[1],start:s,end:s+e[0].length})}break}}}f(0);const k=Array.from(b.values());function v(l){for(let i=l.refs.length-1;i>=0;i--){const s=l.refs[i];if(y.has(s.id)||!b.has(s.id))l.html=l.html.slice(0,s.start)+l.html.slice(s.end);else{const h=v(b.get(s.id));l.html=l.html.slice(0,s.start)+h.html+l.html.slice(s.end),h.type==="embed"&&y.add(h.id)}}return l.refs=[],l}if(a!=null&&a.mountable)return m.mountable=!0,m.tail=a.html,m.mountPoints=a.mountPoints,m;for(let l=0;l<b.size+1;l++){let i;l===0&&a==null||(l===0?i=a:i=k[l-1],i.refs.length!==0&&v(i))}(a==null?void 0:a.html)!=null&&(m.root=a.html,m.selector="[data-lf-root]");for(let l=0;l<k.length;l++){let i;const s=k[l];s==null||y.has(s.id)||(s.type==="embed"?i=`[id=${s.id}]`:s.type==="bare"?i=`[data-lf=${s.id}]`:s.type==="range"&&(i=`[data-lf=${s.id}]`),m.fragments[s.id]={id:s.id,selector:i,type:s.type,html:s.html})}return m}const Z=/(?:#{([\w][\w\-_]*)})|(?:#\[([\w][\w\-_]+)\])/g;export function processTemplate(o,u,g){var p,d;const c=o.replace(Z,(x,n,t)=>{if(t!=null){const a=g(t);return a==null?"":a}return u[n]!=null?G(u[n].toString()):""});return(d=(p=Object.values(longform(c).fragments)[0])==null?void 0:p.html)!=null?d:null}
1
+ const sniffTestRe = /^(?:(?:(--).*)|(?: *(@|#).*)|(?: *[\w\-]+(?::[\w\-]+)?(?:[#.[][^\n]+)?(::).*)|(?: +([\["]).*)|(\ \ .*))$/gmi, element1 = /((?:\ \ )+)? ?([\w\-]+(?::[\w\-]+)?)([#\.\[][^\n]*)?::(?: ({{?|[^\n]+))?/gmi, directive1 = /((?:\ \ )+)? ?@([\w][\w\-]+)(?::: ?([^\n]+)?)?/gmi, attribute1 = /((?:\ \ )+)\[(\w[\w-]*(?::\w[\w-]*)?)(?:=([^\n]+))?\]/, preformattedClose = /[ \t]*}}?[ \t]*/, id1 = /((?:\ \ )+)?#(#)?([\w\-]+)(?: ([\["]))?/gmi, idnt1 = /^(\ \ )+/, text1 = /^((?:\ \ )+)([^ \n][^\n]*)$/i, paramsRe = /(?:(#|\.)([^#.\[\n]+)|(?:\[(\w[\w\-]*(?::\w[\w\-]*)?)(?:=([^\n\]]+))?\]))/g, refRe = /#\[([\w\-]+)\]/g, escapeRe = /([&<>"'#\[\]{}])/g, templateLinesRe = /^(\ \ )?([^\n]+)$/gmi, voids = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wrb']);
2
+ let m1, m2, m3;
3
+ const entities = {
4
+ '&': '&amp;',
5
+ '<': '&lt;',
6
+ '>': '&gt;',
7
+ '"': '&quot;',
8
+ "'": '&apos;',
9
+ // '#': '&num;',
10
+ // '[': '&lbrak;',
11
+ // ']': '&rbrak;',
12
+ // '{': '&rbrace;',
13
+ // '}': '&lbrace;',
14
+ };
15
+ function escape(value) {
16
+ return value.replace(escapeRe, (match) => {
17
+ return entities[match] ?? match;
18
+ });
19
+ }
20
+ function makeElement(indent = 0) {
21
+ return {
22
+ indent,
23
+ html: '',
24
+ attrs: {},
25
+ };
26
+ }
27
+ function makeFragment(type = 'bare') {
28
+ return {
29
+ type,
30
+ html: '',
31
+ template: false,
32
+ mountable: false,
33
+ els: [],
34
+ refs: [],
35
+ mountPoints: [],
36
+ };
37
+ }
38
+ /**
39
+ * Parses a longform document into a object containing the root and fragments
40
+ * in the output format.
41
+ *
42
+ * @param {string} doc - The longform document to parse.
43
+ * @returns {ParsedResult}
44
+ */
45
+ function longform(doc, debug = () => { }) {
46
+ let textIndent = null, verbatimSerialize = true, verbatimIndent = null, verbatimFirst = false, element = makeElement(), fragment = makeFragment()
47
+ // the root fragment
48
+ , root = null;
49
+ // ids of claimed fragments
50
+ const claimed = new Set()
51
+ // parsed fragments
52
+ , parsed = new Map(), output = Object.create(null);
53
+ output.fragments = Object.create(null);
54
+ output.templates = Object.create(null);
55
+ /**
56
+ * Closes any current in progress element definition
57
+ * and creates a new working element.
58
+ */
59
+ function applyIndent(targetIndent) {
60
+ if (element.tag != null) {
61
+ const root = fragment.type === 'range'
62
+ ? targetIndent < 2
63
+ : fragment.html === '';
64
+ fragment.html += `<${element.tag}`;
65
+ if (root) {
66
+ if (fragment.type === 'root') {
67
+ fragment.html += ` data-lf-root`;
68
+ }
69
+ else if (fragment.type === 'bare' || fragment.type === 'range') {
70
+ fragment.html += ` data-lf="${fragment.id}"`;
71
+ }
72
+ }
73
+ if (element.mount != null) {
74
+ fragment.html += ` data-lf-mount="${element.mount}"`;
75
+ }
76
+ if (element.id != null) {
77
+ fragment.html += ' id="' + element.id + '"';
78
+ }
79
+ if (element.class != null) {
80
+ fragment.html += ' class="' + element.class + '"';
81
+ }
82
+ for (const attr of Object.entries(element.attrs)) {
83
+ if (attr[1] == null) {
84
+ fragment.html += ' ' + attr[0];
85
+ }
86
+ else {
87
+ fragment.html += ` ${attr[0]}="${attr[1]}"`;
88
+ }
89
+ }
90
+ fragment.html += '>';
91
+ if (!voids.has(element.tag) && element.text != null) {
92
+ fragment.html += element.text;
93
+ }
94
+ if (!voids.has(element.tag)) {
95
+ fragment.els.push(element);
96
+ }
97
+ }
98
+ if (targetIndent <= element.indent) {
99
+ element = makeElement(targetIndent);
100
+ while (fragment.els.length !== 0 && (targetIndent == null ||
101
+ fragment.els[fragment.els.length - 1].indent !== targetIndent - 1)) {
102
+ const element = fragment.els.pop();
103
+ fragment.html += `</${element?.tag}>`;
104
+ }
105
+ if (targetIndent === 0) {
106
+ debug(0, '<', fragment.type, fragment.id);
107
+ if (fragment.template) {
108
+ output.templates[fragment.id] = fragment.html;
109
+ }
110
+ else if (fragment.type === 'root') {
111
+ root = fragment;
112
+ }
113
+ else {
114
+ parsed.set(fragment.id, fragment);
115
+ }
116
+ fragment = makeFragment();
117
+ }
118
+ }
119
+ else {
120
+ element = makeElement(targetIndent);
121
+ }
122
+ }
123
+ while ((m1 = sniffTestRe.exec(doc))) {
124
+ if (m1[1] === '--') {
125
+ continue;
126
+ }
127
+ else if (fragment.template) {
128
+ fragment.html += m1[0];
129
+ }
130
+ // If this is a script tag or preformatted block
131
+ // we want to retain the intended formatting less
132
+ // the indent. Preformatting can apply to any element
133
+ // by ending the declaration with `:: {`.
134
+ if (verbatimIndent != null) {
135
+ // inside a script or preformatted block
136
+ idnt1.lastIndex = 0;
137
+ m2 = idnt1.exec(m1[0]);
138
+ const indent = m2 == null
139
+ ? null
140
+ : m2[0].length / 2;
141
+ if (m2 == null || indent <= verbatimIndent) {
142
+ fragment.html += '\n';
143
+ debug(indent, '}', m2?.[0]);
144
+ applyIndent(indent);
145
+ verbatimIndent = null;
146
+ verbatimFirst = false;
147
+ textIndent = indent;
148
+ if (preformattedClose.test(m1[0])) {
149
+ continue;
150
+ }
151
+ }
152
+ else {
153
+ const line = m1[0].replace(' '.repeat(verbatimIndent + 1), '');
154
+ debug(indent, '{', line);
155
+ if (element.tag != null) {
156
+ applyIndent(indent);
157
+ }
158
+ if (verbatimFirst) {
159
+ verbatimFirst = false;
160
+ }
161
+ else {
162
+ fragment.html += '\n';
163
+ }
164
+ if (verbatimSerialize) {
165
+ fragment.html += escape(line);
166
+ }
167
+ else {
168
+ fragment.html += line;
169
+ }
170
+ continue;
171
+ }
172
+ }
173
+ if (m1[0].trim() === '') {
174
+ continue;
175
+ }
176
+ switch (m1[2] ?? m1[3] ?? m1[4]) {
177
+ // deno-lint-ignore no-fallthrough
178
+ case '#': {
179
+ id1.lastIndex = 0;
180
+ m2 = id1.exec(m1[0]);
181
+ if (m2 != null) {
182
+ const indent = (m2[1]?.length ?? 0) / 2;
183
+ if (element.tag != null || textIndent != null) {
184
+ applyIndent(indent);
185
+ textIndent = null;
186
+ }
187
+ debug(indent, 'id', m2[2], m2[3], m2[4]);
188
+ fragment.id = m2[3];
189
+ if (indent === 0) {
190
+ if (m2[4] == '[') {
191
+ fragment.type = 'range';
192
+ }
193
+ else if (m2[4] === '"') {
194
+ fragment.type = 'text';
195
+ }
196
+ else if (m2[2] != null) {
197
+ fragment.type = 'bare';
198
+ }
199
+ else {
200
+ fragment.type = 'embed';
201
+ element.id = fragment.id;
202
+ }
203
+ }
204
+ break;
205
+ }
206
+ }
207
+ case '@':
208
+ case '[':
209
+ // deno-lint-ignore no-fallthrough
210
+ case '::': {
211
+ element1.lastIndex = 0;
212
+ // fall through if m1[3] is a # or @
213
+ m2 = m1[2] ?? m1[4] != null
214
+ ? null
215
+ : element1.exec(m1[0]);
216
+ // if null then invalid element selector
217
+ // allow the default text case to handle
218
+ if (m2 != null) {
219
+ const indent = (m2[1]?.length ?? 0) / 2, tg = m2[2], ar = m2[3], pr = m2[4] === '{' || m2[4] === '{{';
220
+ const tx = pr ? null : m2[4];
221
+ debug(indent, 'e', tg, pr, tx);
222
+ if (element.tag != null ||
223
+ element.indent > indent) {
224
+ applyIndent(indent);
225
+ }
226
+ element.indent = indent;
227
+ element.tag = tg;
228
+ textIndent = null;
229
+ if (indent === 0 && fragment.id == null) {
230
+ if (root != null) ;
231
+ else {
232
+ fragment.type = 'root';
233
+ root = fragment;
234
+ }
235
+ }
236
+ if (ar != null) {
237
+ debug(indent, 'a', ar);
238
+ while ((m2 = paramsRe.exec(ar))) {
239
+ if (m2[1] === '#') {
240
+ element.id = m2[2];
241
+ }
242
+ else if (m2[1] === '.') {
243
+ if (element.class == null) {
244
+ element.class = m2[2];
245
+ }
246
+ else {
247
+ element.class += ' ' + m2[2];
248
+ }
249
+ }
250
+ else {
251
+ if (m2[3] === 'id') {
252
+ if (element.id == null) {
253
+ element.id = m2[4];
254
+ }
255
+ }
256
+ else if (m2[3] === 'class') {
257
+ if (element.class == null) {
258
+ element.class = m2[4];
259
+ }
260
+ else {
261
+ element.class += ' ' + m2[4];
262
+ }
263
+ }
264
+ else {
265
+ element.attrs[m2[3]] = m2[4];
266
+ }
267
+ }
268
+ }
269
+ }
270
+ // this is a hack to get temp support of mounting
271
+ // working. In the future it will be moved to a
272
+ // server specific process.
273
+ if (element.mount != null) {
274
+ const id = element.mount;
275
+ applyIndent(indent + 1);
276
+ fragment.mountPoints.push({
277
+ id,
278
+ part: fragment.html,
279
+ });
280
+ fragment.html = '';
281
+ applyIndent(indent);
282
+ break;
283
+ }
284
+ if (!pr && tx != null) {
285
+ element.text = tx;
286
+ }
287
+ else if (pr) {
288
+ verbatimFirst = true;
289
+ verbatimIndent = indent;
290
+ verbatimSerialize = m2[4] === '{';
291
+ }
292
+ break;
293
+ }
294
+ attribute1.lastIndex = 0;
295
+ m2 = m1[2] != null
296
+ ? null
297
+ : attribute1.exec(m1[0]);
298
+ if (m2 != null && element.tag != null) {
299
+ debug('a', m2[2], m2[3]);
300
+ if (m2[2] === 'id') {
301
+ if (element.id == null) {
302
+ element.id = m2[3].trim();
303
+ }
304
+ }
305
+ else if (m2[2] === 'class') {
306
+ if (element.class != null) {
307
+ element.class += ' ' + m2[3].trim();
308
+ }
309
+ else {
310
+ element.class = m2[3].trim();
311
+ }
312
+ }
313
+ else if (element.attrs[m2[2]] != null) {
314
+ element.attrs[m2[2]] += m2[3];
315
+ }
316
+ else {
317
+ element.attrs[m2[2]] = m2[3];
318
+ }
319
+ break;
320
+ }
321
+ directive1.lastIndex = 0;
322
+ m2 = m1[3] != null
323
+ ? null
324
+ : directive1.exec(m1[0]);
325
+ if (m2 != null) {
326
+ const indent = (m2[1]?.length ?? 0) / 2;
327
+ if (element.tag != null || textIndent != null) {
328
+ applyIndent(indent);
329
+ }
330
+ debug(indent, 'd', m2[2], m2[3]);
331
+ switch (m2[2]) {
332
+ case 'doctype': {
333
+ fragment.html += `<!doctype ${m2[3] ?? 'html'}>`;
334
+ break;
335
+ }
336
+ case 'xml': {
337
+ fragment.html += `<?xml ${m2[3] ?? 'version="1.0" encoding="UTF-8"'}?>`;
338
+ break;
339
+ }
340
+ case 'template': {
341
+ let indented = false;
342
+ fragment.template = indent === 0;
343
+ templateLinesRe.lastIndex = sniffTestRe.lastIndex;
344
+ while ((m2 = templateLinesRe.exec(doc))) {
345
+ if (m2[1] == null && !indented && fragment.id == null) {
346
+ id1.lastIndex = 0;
347
+ m3 = id1.exec(m2[0]);
348
+ if (m3 != null)
349
+ fragment.id = m3[3];
350
+ fragment.html += m2[0];
351
+ }
352
+ else if (m2[1] == null && indented) {
353
+ sniffTestRe.lastIndex = templateLinesRe.lastIndex - m2[0].length;
354
+ break;
355
+ }
356
+ else {
357
+ fragment.html += '\n' + m2[0];
358
+ if (m2[1] != null)
359
+ indented = true;
360
+ }
361
+ }
362
+ applyIndent(0);
363
+ break;
364
+ }
365
+ case 'mount': {
366
+ if (m2[3] == null) {
367
+ throw new Error('Mount points must have a name');
368
+ }
369
+ else if (fragment.type !== 'root') {
370
+ throw new Error('Mounting is only allowed on a root element');
371
+ }
372
+ fragment.mountable = true;
373
+ element.mount = m2[3].trim();
374
+ break;
375
+ }
376
+ }
377
+ break;
378
+ }
379
+ }
380
+ default: {
381
+ m2 = text1.exec(m1[0]);
382
+ if (m2 == null) {
383
+ break;
384
+ }
385
+ const indent = m2[1].length / 2;
386
+ const tx = m2[2].trim();
387
+ debug(indent, 't', m2[2]);
388
+ if (element.tag != null) {
389
+ applyIndent(indent);
390
+ fragment.html += tx;
391
+ }
392
+ else if (fragment.type === 'text' && fragment.html === '') {
393
+ fragment.html += tx;
394
+ }
395
+ else {
396
+ fragment.html += ' ' + tx;
397
+ }
398
+ textIndent = indent;
399
+ while ((m2 = refRe.exec(tx))) {
400
+ const start = fragment.html.length + m2.index - tx.length;
401
+ fragment.refs.push({
402
+ id: m2[1],
403
+ start,
404
+ end: start + m2[0].length,
405
+ });
406
+ }
407
+ break;
408
+ }
409
+ }
410
+ }
411
+ applyIndent(0);
412
+ const arr = Array.from(parsed.values());
413
+ function flatten(fragment) {
414
+ // work backwards so we don't change the html string length
415
+ // for the later replacements
416
+ for (let j = fragment.refs.length - 1; j >= 0; j--) {
417
+ const ref = fragment.refs[j];
418
+ if (claimed.has(ref.id) || !parsed.has(ref.id)) {
419
+ fragment.html = fragment.html.slice(0, ref.start)
420
+ + fragment.html.slice(ref.end);
421
+ }
422
+ else {
423
+ const child = flatten(parsed.get(ref.id));
424
+ fragment.html = fragment.html.slice(0, ref.start)
425
+ + child.html
426
+ + fragment.html.slice(ref.end);
427
+ if (child.type === 'embed') {
428
+ claimed.add(child.id);
429
+ }
430
+ }
431
+ }
432
+ fragment.refs = [];
433
+ return fragment;
434
+ }
435
+ if (root?.mountable) {
436
+ output.mountable = true;
437
+ output.tail = root.html;
438
+ output.mountPoints = root.mountPoints;
439
+ return output;
440
+ }
441
+ for (let i = 0; i < parsed.size + 1; i++) {
442
+ let fragment;
443
+ if (i === 0 && root == null) {
444
+ continue;
445
+ }
446
+ else if (i === 0) {
447
+ fragment = root;
448
+ }
449
+ else {
450
+ fragment = arr[i - 1];
451
+ }
452
+ if (fragment.refs.length === 0) {
453
+ continue;
454
+ }
455
+ flatten(fragment);
456
+ }
457
+ if (root?.html != null) {
458
+ output.root = root.html;
459
+ output.selector = `[data-lf-root]`;
460
+ }
461
+ for (let i = 0; i < arr.length; i++) {
462
+ let selector;
463
+ const fragment = arr[i];
464
+ if (fragment == null || claimed.has(fragment.id)) {
465
+ continue;
466
+ }
467
+ if (fragment.type === 'embed') {
468
+ selector = `[id=${fragment.id}]`;
469
+ }
470
+ else if (fragment.type === 'bare') {
471
+ selector = `[data-lf=${fragment.id}]`;
472
+ }
473
+ else if (fragment.type === 'range') {
474
+ selector = `[data-lf=${fragment.id}]`;
475
+ }
476
+ output.fragments[fragment.id] = {
477
+ id: fragment.id,
478
+ selector,
479
+ type: fragment.type,
480
+ html: fragment.html,
481
+ };
482
+ }
483
+ return output;
484
+ }
485
+ const templateRe = /(?:#{([\w][\w\-_]*)})|(?:#\[([\w][\w\-_]+)\])/g;
486
+ /**
487
+ * Processes a client side Longform template to HTML fragment string.
488
+ *
489
+ * @param fragment - The fragment identifier.
490
+ * @param args - A record of template arguments.
491
+ * @param getFragment - A function which returns an already processed fragment's HTML string.
492
+ * @returns The processed template.
493
+ */
494
+ function processTemplate(template, args, getFragment) {
495
+ const lf = template.replace(templateRe, (_match, param, ref) => {
496
+ if (ref != null) {
497
+ const fragment = getFragment(ref);
498
+ if (fragment == null)
499
+ return '';
500
+ return fragment;
501
+ }
502
+ return args[param] != null ? escape(args[param].toString()) : '';
503
+ });
504
+ return Object.values(longform(lf).fragments)[0]?.html ?? null;
505
+ }
506
+
507
+ export { longform, processTemplate };
5
508
  //# sourceMappingURL=longform.min.js.map
Binary file
Binary file