@beforesemicolon/builder 1.1.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";var l=Object.create;var s=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var d=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of a(t))!f.call(e,o)&&o!==r&&s(e,o,{get:()=>t[o],enumerable:!(n=m(t,o))||n.enumerable});return e};var c=(e,t,r)=>(r=e!=null?l(u(e)):{},d(t||!e||!e.__esModule?s(r,"default",{value:e,enumerable:!0}):r,e));var i=c(require("path"),1),p=c(require("esbuild"),1);const y={name:"empty-parser-Doc-plugin",setup(e){e.onResolve({filter:/Doc$/},t=>{if(t.importer.includes("@beforesemicolon/html-parser"))return{path:t.path,namespace:"empty-Doc"}}),e.onLoad({filter:/.*/,namespace:"empty-Doc"},()=>({contents:""}))}};p.default.build({entryPoints:[i.default.resolve(process.cwd(),"src/client")],outfile:"dist/client",bundle:!0,keepNames:!0,sourcemap:!0,target:"esnext",minify:!0,plugins:[y]}).catch(console.error);
|
1
|
+
"use strict";var l=Object.create;var s=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var d=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of a(t))!f.call(e,o)&&o!==r&&s(e,o,{get:()=>t[o],enumerable:!(n=m(t,o))||n.enumerable});return e};var c=(e,t,r)=>(r=e!=null?l(u(e)):{},d(t||!e||!e.__esModule?s(r,"default",{value:e,enumerable:!0}):r,e));var i=c(require("path"),1),p=c(require("esbuild"),1);const y={name:"empty-parser-Doc-plugin",setup(e){e.onResolve({filter:/Doc$/},t=>{if(t.importer.includes("@beforesemicolon/html-parser"))return{path:t.path,namespace:"empty-Doc"}}),e.onLoad({filter:/.*/,namespace:"empty-Doc"},()=>({contents:""}))}};p.default.build({entryPoints:[i.default.resolve(process.cwd(),"src/client")],outfile:"dist/client.js",bundle:!0,keepNames:!0,sourcemap:!0,target:"esnext",minify:!0,plugins:[y]}).catch(console.error);
|
package/dist/cjs/docs/run.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var
|
1
|
+
"use strict";var E=Object.create;var y=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var z=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty;var P=(s,a)=>y(s,"name",{value:a,configurable:!0});var G=(s,a,t,e)=>{if(a&&typeof a=="object"||typeof a=="function")for(let r of $(a))!B.call(s,r)&&r!==t&&y(s,r,{get:()=>a[r],enumerable:!(e=_(a,r))||e.enumerable});return s};var c=(s,a,t)=>(t=s!=null?E(z(s)):{},G(a||!s||!s.__esModule?y(t,"default",{value:s,enumerable:!0}):t,s));var A=require("marked"),o=require("fs/promises"),i=c(require("path"),1),F=c(require("front-matter"),1),k=c(require("isomorphic-dompurify"),1),O=require("marked-highlight"),M=c(require("highlight.js"),1),x=c(require("./templates/default.template.js"),1),T=c(require("./renderer/index.js"),1),W=c(require("clean-css"),1),L=c(require("html-minifier"),1),H=c(require("@putout/minify"),1);const J=new W.default,g=new Map;g.set("default",x.default);let b;const v=new A.Marked((0,O.markedHighlight)({langPrefix:"hljs language-",highlight(s,a){const t=M.default.getLanguage(a)?a:"plaintext";return M.default.highlight(s,{language:t}).value}}));v.use({renderer:T.default});const n=i.default.resolve(process.cwd(),"docs"),p=i.default.resolve(process.cwd(),"website"),Q=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 a=await(0,o.readdir)(s),t=[];for(const e of a){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:a="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(a)?.({...t,content:s,siteMap:b.siteMap,tableOfContent:e})||s}}}),(async()=>{await(0,o.mkdir)(p,{recursive:!0});try{await(0,o.cp)(D,D.replace(n,p),{recursive:!0})}catch(t){console.warn(t)}try{const t=await f(C);t.length&&await(0,o.mkdir)(C.replace(n,p),{recursive:!0});for(const e of t){const r=await(0,o.readFile)(e,"utf-8");await(0,o.writeFile)(e.replace(n,p),J.minify(r).styles??r)}}catch(t){console.error(t)}try{const t=await f(j);t.length&&await(0,o.mkdir)(j.replace(n,p),{recursive:!0});for(const e of t)try{const r=await(0,o.readFile)(e,"utf-8");await(0,o.writeFile)(e.replace(n,p),H.minify(r))}catch(r){console.error(r)}}catch(t){console.warn(t)}try{const t=await f(Q);for(const e of t)if(/\.(j|t)s$/.test(e)){const r=i.default.basename(e).replace(i.default.extname(e),""),l=await import(e);g.set(r,l.default)}}catch(t){console.error("Template import failed",t)}const s=await f(n),a=new Map;(await Promise.all(s.filter(t=>t.endsWith(".md")).map(async t=>{const e=await(0,o.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 l=r.replace(n,"").replace(/\.md/,".html"),m=r.replace(n,p).replace(".md",".html"),h=m.replace(i.default.basename(m),""),d=i.default.basename(l)||"/",N=l.replace(d,"").replace(/\/$/,"");let u=a;N.split("/").filter(Boolean).forEach(w=>{u.has(w)||u.set(w,new Map),u=u.get(w)});const S={...t,path:l};return u.has(d)||u.set(d,S),{attributes:S,fileWebsitePath:m,fileDirWebsitePath:h,body:e,siteMap:a}}).forEach(async({attributes:t,body:e,fileDirWebsitePath:r,fileWebsitePath:l,siteMap:m})=>{b={attributes:t,siteMap:m};const h=await v.parse(e);await(0,o.mkdir)(r,{recursive:!0}),await(0,o.writeFile)(l,L.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}))})})();
|
File without changes
|
@@ -1 +1 @@
|
|
1
|
-
import r from"path";import o from"esbuild";const n={name:"empty-parser-Doc-plugin",setup(e){e.onResolve({filter:/Doc$/},t=>{if(t.importer.includes("@beforesemicolon/html-parser"))return{path:t.path,namespace:"empty-Doc"}}),e.onLoad({filter:/.*/,namespace:"empty-Doc"},()=>({contents:""}))}};o.build({entryPoints:[r.resolve(process.cwd(),"src/client")],outfile:"dist/client",bundle:!0,keepNames:!0,sourcemap:!0,target:"esnext",minify:!0,plugins:[n]}).catch(console.error);
|
1
|
+
import r from"path";import o from"esbuild";const n={name:"empty-parser-Doc-plugin",setup(e){e.onResolve({filter:/Doc$/},t=>{if(t.importer.includes("@beforesemicolon/html-parser"))return{path:t.path,namespace:"empty-Doc"}}),e.onLoad({filter:/.*/,namespace:"empty-Doc"},()=>({contents:""}))}};o.build({entryPoints:[r.resolve(process.cwd(),"src/client")],outfile:"dist/client.js",bundle:!0,keepNames:!0,sourcemap:!0,target:"esnext",minify:!0,plugins:[n]}).catch(console.error);
|
package/dist/esm/docs/run.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var
|
1
|
+
var F=Object.defineProperty;var S=(r,o)=>F(r,"name",{value:o,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 a from"path";import T from"front-matter";import W from"isomorphic-dompurify";import{markedHighlight as L}from"marked-highlight";import P from"highlight.js";import N from"./templates/default.template.js";import E from"./renderer/index.js";import _ from"clean-css";import $ from"html-minifier";import*as z from"@putout/minify";const B=new _,g=new Map;g.set("default",N);let b;const v=new k(L({langPrefix:"hljs language-",highlight(r,o){const t=P.getLanguage(o)?o:"plaintext";return P.highlight(r,{language:t}).value}}));v.use({renderer:E});const i=a.resolve(process.cwd(),"docs"),n=a.resolve(process.cwd(),"website"),G=a.resolve(process.cwd(),"docs/_layouts"),D=a.resolve(process.cwd(),"docs/assets"),C=a.resolve(process.cwd(),"docs/stylesheets"),j=a.resolve(process.cwd(),"docs/scripts"),u=S(async r=>{const o=await x(r),t=[];for(const e of o){const s=a.extname(e);/^[._]/.test(e)||(s?t.push(a.join(r,e)):/(stylesheets|assets|scripts)/.test(e)||t.push(...await u(a.join(r,e))))}return t},"traverseDirectory");v.use({hooks:{postprocess(r){const{layout:o="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(o)?.({...t,content:r,siteMap:b.siteMap,tableOfContent:e})||r}}}),(async()=>{await m(n,{recursive:!0});try{await O(D,D.replace(i,n),{recursive:!0})}catch(t){console.warn(t)}try{const t=await u(C);t.length&&await m(C.replace(i,n),{recursive:!0});for(const e of t){const s=await w(e,"utf-8");await y(e.replace(i,n),B.minify(s).styles??s)}}catch(t){console.error(t)}try{const t=await u(j);t.length&&await m(j.replace(i,n),{recursive:!0});for(const e of t)try{const s=await w(e,"utf-8");await y(e.replace(i,n),z.minify(s))}catch(s){console.error(s)}}catch(t){console.warn(t)}try{const t=await u(G);for(const e of t)if(/\.(j|t)s$/.test(e)){const s=a.basename(e).replace(a.extname(e),""),c=await import(e);g.set(s,c.default)}}catch(t){console.error("Template import failed",t)}const r=await u(i),o=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 c=s.replace(i,"").replace(/\.md/,".html"),p=s.replace(i,n).replace(".md",".html"),f=p.replace(a.basename(p),""),h=a.basename(c)||"/",A=c.replace(h,"").replace(/\/$/,"");let l=o;A.split("/").filter(Boolean).forEach(d=>{l.has(d)||l.set(d,new Map),l=l.get(d)});const M={...t,path:c};return l.has(h)||l.set(h,M),{attributes:M,fileWebsitePath:p,fileDirWebsitePath:f,body:e,siteMap:o}}).forEach(async({attributes:t,body:e,fileDirWebsitePath:s,fileWebsitePath:c,siteMap:p})=>{b={attributes:t,siteMap:p};const f=await v.parse(e);await m(s,{recursive:!0}),await y(c,$.minify(f,{includeAutoGeneratedTags:!0,removeAttributeQuotes:!0,removeComments:!0,removeRedundantAttributes:!0,removeScriptTypeAttributes:!0,removeStyleLinkTypeAttributes:!0,sortClassName:!0,useShortDoctype:!0,collapseWhitespace:!0,minifyJS:!0,minifyCSS:!0}))})})();
|
package/dist/types/index.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
export * from
|
2
|
-
export * from
|
3
|
-
export * from
|
1
|
+
export * from './build-modules.ts';
|
2
|
+
export * from './build-browser.ts';
|
3
|
+
export * from './docs/run.ts';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@beforesemicolon/builder",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.2.0",
|
4
4
|
"description": "Utilities to build npm packages and documentation website",
|
5
5
|
"engines": {
|
6
6
|
"node": ">=18.16.0"
|
@@ -29,18 +29,23 @@
|
|
29
29
|
},
|
30
30
|
"dependencies": {
|
31
31
|
"@gjsify/esbuild-plugin-transform-ext": "0.0.4",
|
32
|
+
"@putout/minify": "^4.7.2",
|
33
|
+
"clean-css": "^5.3.3",
|
32
34
|
"core-js": "^3.34.0",
|
33
35
|
"esbuild": "^0.19.10",
|
34
36
|
"esbuild-plugin-text-replace": "^1.3.0",
|
35
37
|
"front-matter": "^4.0.2",
|
36
38
|
"global-jsdom": "^9.2.0",
|
37
39
|
"highlight.js": "^11.10.0",
|
40
|
+
"html-minifier": "^4.0.0",
|
38
41
|
"isomorphic-dompurify": "^2.16.0",
|
39
42
|
"jsdom": "^23.0.1",
|
40
43
|
"marked": "^14.1.2",
|
41
44
|
"marked-highlight": "^2.1.4"
|
42
45
|
},
|
43
46
|
"devDependencies": {
|
47
|
+
"@types/clean-css": "^4.2.11",
|
48
|
+
"@types/html-minifier": "^4.0.5",
|
44
49
|
"@types/jest": "^29.5.11",
|
45
50
|
"@types/jsdom": "^21.1.6",
|
46
51
|
"@types/jsdom-global": "^3.0.7",
|
@@ -55,9 +60,9 @@
|
|
55
60
|
"eslint-plugin-n": "^16.5.0",
|
56
61
|
"eslint-plugin-prettier": "^5.1.2",
|
57
62
|
"eslint-plugin-promise": "^6.1.1",
|
63
|
+
"nodemon": "^3.1.7",
|
58
64
|
"npm-run-all": "^4.1.5",
|
59
65
|
"prettier": "3.1.1",
|
60
|
-
"nodemon": "^3.1.7",
|
61
66
|
"tinybench": "^2.8.0",
|
62
67
|
"ts-jest": "^29.1.1",
|
63
68
|
"tsx": "^4.7.0",
|