@beforesemicolon/builder 1.2.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var o=(e,t)=>n(e,"name",{value:t,configurable:!0});var p=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,r,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of k(t))!m.call(e,a)&&a!==r&&n(e,a,{get:()=>t[a],enumerable:!(l=i(t,a))||l.enumerable});return e};var f=e=>c(n({},"__esModule",{value:!0}),e);var h={};p(h,{default:()=>s});module.exports=f(h);function s({href:e,text:t}){return`<a target="${e.startsWith("https://")?"_blank":"_self"}" href="${e.replace(/\.md/,".html").replace(/index\.html/,"")}">${t}</a>`}o(s,"link");
|
package/dist/cjs/docs/run.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var N=Object.create;var y=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var P=(s,o)=>y(s,"name",{value:o,configurable:!0});var B=(s,o,t,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of _(o))!z.call(s,r)&&r!==t&&y(s,r,{get:()=>o[r],enumerable:!(e=R(o,r))||e.enumerable});return s};var n=(s,o,t)=>(t=s!=null?N($(s)):{},B(o||!s||!s.__esModule?y(t,"default",{value:s,enumerable:!0}):t,s));var A=require("marked"),a=require("fs/promises"),i=n(require("path"),1),F=n(require("front-matter"),1),k=n(require("isomorphic-dompurify"),1),O=require("marked-highlight"),M=n(require("highlight.js"),1),x=n(require("./templates/default.template.js"),1),T=n(require("./renderer/index.js"),1),W=n(require("clean-css"),1),E=n(require("html-minifier"),1),G=n(require("@putout/minify"),1);const H=new W.default({inline:["none"]}),g=new Map;g.set("default",x.default);let b;const v=new A.Marked((0,O.markedHighlight)({langPrefix:"hljs language-",highlight(s,o){const t=M.default.getLanguage(o)?o:"plaintext";return M.default.highlight(s,{language:t}).value}}));v.use({renderer:T.default});const l=i.default.resolve(process.cwd(),"docs"),p=i.default.resolve(process.cwd(),"website"),J=i.default.resolve(process.cwd(),"docs/_layouts"),D=i.default.resolve(process.cwd(),"docs/assets"),C=i.default.resolve(process.cwd(),"docs/stylesheets"),j=i.default.resolve(process.cwd(),"docs/scripts"),f=P(async s=>{const o=await(0,a.readdir)(s),t=[];for(const e of o){const r=i.default.extname(e);/^[._]/.test(e)||(r?t.push(i.default.join(s,e)):/(stylesheets|assets|scripts)/.test(e)||t.push(...await f(i.default.join(s,e))))}return t},"traverseDirectory");v.use({hooks:{postprocess(s){const{layout:o="default",...t}=b.attributes;s=k.default.sanitize(s);const e=[...s.matchAll(/<h([0-6])\sid="[^"]+".*?>.*?<a\s+href="([^"]+)".*?>([^<]+)<\/a>/gm)].map(r=>({path:r[2],label:r[3],level:r[1]}));return g.get(o)?.({...t,content:s,siteMap:b.siteMap,tableOfContent:e})||s}}}),(async()=>{await(0,a.mkdir)(p,{recursive:!0});try{await(0,a.cp)(D,D.replace(l,p),{recursive:!0})}catch(t){console.warn(t)}try{const t=await f(C);t.length&&await(0,a.mkdir)(C.replace(l,p),{recursive:!0});for(const e of t){const r=await(0,a.readFile)(e,"utf-8"),c=H.minify(r);c.errors.length&&c.errors.forEach(console.error),await(0,a.writeFile)(e.replace(l,p),c.styles??r)}}catch(t){console.error(t)}try{const t=await f(j);t.length&&await(0,a.mkdir)(j.replace(l,p),{recursive:!0});for(const e of t)try{const r=await(0,a.readFile)(e,"utf-8");await(0,a.writeFile)(e.replace(l,p),G.minify(r))}catch(r){console.error(r)}}catch(t){console.warn(t)}try{const t=await f(J);for(const e of t)if(/\.(j|t)s$/.test(e)){const r=i.default.basename(e).replace(i.default.extname(e),""),c=await import(e);g.set(r,c.default)}}catch(t){console.error("Template import failed",t)}const s=await f(l),o=new Map;(await Promise.all(s.filter(t=>t.endsWith(".md")).map(async t=>{const e=await(0,a.readFile)(t,"utf-8");return{filePath:t,...(0,F.default)(e)}}))).sort((t,e)=>t.attributes.order-e.attributes.order).map(({attributes:t,body:e,filePath:r})=>{const c=r.replace(l,"").replace(/\.md/,".html"),m=r.replace(l,p).replace(".md",".html"),h=m.replace(i.default.basename(m),""),d=i.default.basename(c)||"/",L=c.replace(d,"").replace(/\/$/,"");let u=o;L.split("/").filter(Boolean).forEach(w=>{u.has(w)||u.set(w,new Map),u=u.get(w)});const S={...t,path:c};return u.has(d)||u.set(d,S),{attributes:S,fileWebsitePath:m,fileDirWebsitePath:h,body:e,siteMap:o}}).forEach(async({attributes:t,body:e,fileDirWebsitePath:r,fileWebsitePath:c,siteMap:m})=>{b={attributes:t,siteMap:m};const h=await v.parse(e);await(0,a.mkdir)(r,{recursive:!0}),await(0,a.writeFile)(c,E.default.minify(h,{includeAutoGeneratedTags:!0,removeAttributeQuotes:!0,removeComments:!0,removeRedundantAttributes:!0,removeScriptTypeAttributes:!0,removeStyleLinkTypeAttributes:!0,sortClassName:!0,useShortDoctype:!0,collapseWhitespace:!0,minifyJS:!0,minifyCSS:!0}))})})();
|
@@ -1 +1 @@
|
|
1
|
-
var
|
1
|
+
var a=Object.defineProperty;var r=(t,e)=>a(t,"name",{value:e,configurable:!0});function n({href:t,text:e}){return`<a target="${t.startsWith("https://")?"_blank":"_self"}" href="${t.replace(/\.md/,".html").replace(/index\.html/,"")}">${e}</a>`}r(n,"link");export{n as default};
|
package/dist/esm/docs/run.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var F=Object.defineProperty;var S=(r,
|
1
|
+
var F=Object.defineProperty;var S=(r,a)=>F(r,"name",{value:a,configurable:!0});import{Marked as k}from"marked";import{cp as O,mkdir as m,readdir as x,readFile as w,writeFile as y}from"fs/promises";import o from"path";import T from"front-matter";import W from"isomorphic-dompurify";import{markedHighlight as E}from"marked-highlight";import P from"highlight.js";import L from"./templates/default.template.js";import N from"./renderer/index.js";import R from"clean-css";import _ from"html-minifier";import*as $ from"@putout/minify";const z=new R({inline:["none"]}),g=new Map;g.set("default",L);let b;const v=new k(E({langPrefix:"hljs language-",highlight(r,a){const t=P.getLanguage(a)?a:"plaintext";return P.highlight(r,{language:t}).value}}));v.use({renderer:N});const c=o.resolve(process.cwd(),"docs"),n=o.resolve(process.cwd(),"website"),B=o.resolve(process.cwd(),"docs/_layouts"),D=o.resolve(process.cwd(),"docs/assets"),C=o.resolve(process.cwd(),"docs/stylesheets"),j=o.resolve(process.cwd(),"docs/scripts"),u=S(async r=>{const a=await x(r),t=[];for(const e of a){const s=o.extname(e);/^[._]/.test(e)||(s?t.push(o.join(r,e)):/(stylesheets|assets|scripts)/.test(e)||t.push(...await u(o.join(r,e))))}return t},"traverseDirectory");v.use({hooks:{postprocess(r){const{layout:a="default",...t}=b.attributes;r=W.sanitize(r);const e=[...r.matchAll(/<h([0-6])\sid="[^"]+".*?>.*?<a\s+href="([^"]+)".*?>([^<]+)<\/a>/gm)].map(s=>({path:s[2],label:s[3],level:s[1]}));return g.get(a)?.({...t,content:r,siteMap:b.siteMap,tableOfContent:e})||r}}}),(async()=>{await m(n,{recursive:!0});try{await O(D,D.replace(c,n),{recursive:!0})}catch(t){console.warn(t)}try{const t=await u(C);t.length&&await m(C.replace(c,n),{recursive:!0});for(const e of t){const s=await w(e,"utf-8"),i=z.minify(s);i.errors.length&&i.errors.forEach(console.error),await y(e.replace(c,n),i.styles??s)}}catch(t){console.error(t)}try{const t=await u(j);t.length&&await m(j.replace(c,n),{recursive:!0});for(const e of t)try{const s=await w(e,"utf-8");await y(e.replace(c,n),$.minify(s))}catch(s){console.error(s)}}catch(t){console.warn(t)}try{const t=await u(B);for(const e of t)if(/\.(j|t)s$/.test(e)){const s=o.basename(e).replace(o.extname(e),""),i=await import(e);g.set(s,i.default)}}catch(t){console.error("Template import failed",t)}const r=await u(c),a=new Map;(await Promise.all(r.filter(t=>t.endsWith(".md")).map(async t=>{const e=await w(t,"utf-8");return{filePath:t,...T(e)}}))).sort((t,e)=>t.attributes.order-e.attributes.order).map(({attributes:t,body:e,filePath:s})=>{const i=s.replace(c,"").replace(/\.md/,".html"),p=s.replace(c,n).replace(".md",".html"),f=p.replace(o.basename(p),""),h=o.basename(i)||"/",A=i.replace(h,"").replace(/\/$/,"");let l=a;A.split("/").filter(Boolean).forEach(d=>{l.has(d)||l.set(d,new Map),l=l.get(d)});const M={...t,path:i};return l.has(h)||l.set(h,M),{attributes:M,fileWebsitePath:p,fileDirWebsitePath:f,body:e,siteMap:a}}).forEach(async({attributes:t,body:e,fileDirWebsitePath:s,fileWebsitePath:i,siteMap:p})=>{b={attributes:t,siteMap:p};const f=await v.parse(e);await m(s,{recursive:!0}),await y(i,_.minify(f,{includeAutoGeneratedTags:!0,removeAttributeQuotes:!0,removeComments:!0,removeRedundantAttributes:!0,removeScriptTypeAttributes:!0,removeStyleLinkTypeAttributes:!0,sortClassName:!0,useShortDoctype:!0,collapseWhitespace:!0,minifyJS:!0,minifyCSS:!0}))})})();
|