astro-ghostcms/.pnpm-store/v3/files/0d/54557cddc8a6376ec5427107b96...

4 lines
2.0 KiB
Plaintext

"use strict";var l=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var u=(o,e)=>{for(var t in e)l(o,t,{get:e[t],enumerable:!0})},f=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!N.call(o,r)&&r!==t&&l(o,r,{get:()=>e[r],enumerable:!(n=d(e,r))||n.enumerable});return o};var h=o=>f(l({},"__esModule",{value:!0}),o);var k={};u(k,{is:()=>s,serialize:()=>g,walk:()=>y});module.exports=h(k);function i(o){return e=>e.type===o}var s={parent(o){return Array.isArray(o.children)},literal(o){return typeof o.value=="string"},tag(o){return o.type==="element"||o.type==="custom-element"||o.type==="component"||o.type==="fragment"},whitespace(o){return o.type==="text"&&o.value.trim().length===0},root:i("root"),element:i("element"),customElement:i("custom-element"),component:i("component"),fragment:i("fragment"),expression:i("expression"),text:i("text"),doctype:i("doctype"),comment:i("comment"),frontmatter:i("frontmatter")},m=class{constructor(e){this.callback=e}async visit(e,t,n){if(await this.callback(e,t,n),s.parent(e)){let r=[];for(let a=0;a<e.children.length;a++){let c=e.children[a];r.push(this.callback(c,e,a))}await Promise.all(r)}}};function y(o,e){new m(e).visit(o)}function x(o){let e="";for(let t of o.attributes)switch(e+=" ",t.kind){case"empty":{e+=`${t.name}`;break}case"expression":{e+=`${t.name}={${t.value}}`;break}case"quoted":{e+=`${t.name}=${t.raw}`;break}case"template-literal":{e+=`${t.name}=\`${t.value}\``;break}case"shorthand":{e+=`{${t.name}}`;break}case"spread":{e+=`{...${t.name}}`;break}}return e}function g(o,e={selfClose:!0}){let t="";function n(r){s.root(r)?r.children.forEach(a=>n(a)):s.frontmatter(r)?t+=`---${r.value}---
`:s.comment(r)?t+=`<!--${r.value}-->`:s.expression(r)?(t+="{",r.children.forEach(a=>n(a)),t+="}"):s.literal(r)?t+=r.value:s.tag(r)&&(t+=`<${r.name}`,t+=x(r),r.children.length==0&&e.selfClose?t+=" />":(t+=">",r.children.forEach(a=>n(a)),t+=`</${r.name}>`))}return n(o),t}0&&(module.exports={is,serialize,walk});