Finish build from yesterday.

This commit is contained in:
Joshua Bemenderfer 2023-01-30 07:56:54 -05:00
parent b87fdfbd83
commit b02e742c89
3 changed files with 38 additions and 22 deletions

View File

@ -19,7 +19,7 @@ export async function parse(lines) {
if (match('version')) structure.version = tail().trim() if (match('version')) structure.version = tail().trim()
if (match('license')) structure.license = tail().trim() if (match('license')) structure.license = tail().trim()
// FIXME: Order of operations causes other parts to break if this doesn't run first?! // FIXME: Order of operations causes other parts to break if this doesn't run first?!
if (match('exports')) structure.exports = await parseObjectKV(null, async () => { if (match('exports')) structure.exports = await buildObject([], async () => {
const section = { import: null, require: null } const section = { import: null, require: null }
await each(() => { await each(() => {

View File

@ -1 +1 @@
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("./parser.cjs");function s(l,a=" "){let r=u.createLineData(null,a);const t={ended:!1,clone(){return s(l.clone(),a)},async next(){if(r.line=await l.next(),r.line===null)return!0;u.parseLine(r)},current(){return t},line(){var e;return(e=r.line)==null?void 0:e.slice(r.offsetHead)},head(){var e;return(e=r.line)==null?void 0:e.slice(r.offsetHead,r.offsetTail)},tail(){var e;return(e=r.line)==null?void 0:e.slice(r.offsetTail)},level(){return r.level},async content(e=-1,n=[]){var i;return e===-1&&(e=r.level+1),await t.next()||r.level<e?n:(n.push(((i=r.line)==null?void 0:i.slice(e))||""),t.content(e,n))},match(e){return e===t.head()},async each(e){const n=t.line()!==void 0?t.level():-1;for(;!(await t.next()||t.level()<=n||await e()););},async seek(e,n=-1){return n===-1&&(n=r.level),await t.next()?!1:t.head()===e?t:r.level<n?!1:t.seek(e,n)}};return t}exports.useDocument=s; "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("./parser.cjs");function c(a,u=" "){let r=s.createLineData(null,u);const t={ended:!1,clone(){return c(a.clone(),u)},async next(){if(r.line=await a.next(),r.line===null)return!0;s.parseLine(r)},current(){return t},line(){var e;return(e=r.line)==null?void 0:e.slice(r.offsetHead)},head(){var e;return(e=r.line)==null?void 0:e.slice(r.offsetHead,r.offsetTail)},tail(){var e;return(e=r.line)==null?void 0:e.slice(r.offsetTail)},level(){return r.level},async content(e=-1,n=[]){var l;return e===-1&&(e=r.level+1),await t.next()||r.level<e?n:(n.push(((l=r.line)==null?void 0:l.slice(e))||""),t.content(e,n))},match(e){return e===t.head()},async each(e){const n=t.line()!==void 0?t.level():-1;for(;!(await t.next()||t.level()<=n||await e()););},async buildObject(e=[],n){n||(n=()=>t.tail().trim());const i={};return await t.each(async()=>{if(!!t.head()){if(!e.length||e.includes(t.head())){i[t.head()]=await n();return}if(e&&!e.includes(t.head())&&e.includes("#text")){i["#text"]=[t.line(),...await t.content(t.level())];return}}}),i},async seek(e,n=-1){return n===-1&&(n=r.level),await t.next()?!1:t.head()===e?t:r.level<n?!1:t.seek(e,n)}};return t}exports.useDocument=c;

View File

@ -1,51 +1,67 @@
import { parseLine as f, createLineData as s } from "./parser.js"; import { parseLine as f, createLineData as s } from "./parser.js";
function c(l, a = " ") { function c(a, u = " ") {
let r = s(null, a); let n = s(null, u);
const n = { const t = {
ended: !1, ended: !1,
clone() { clone() {
return c(l.clone(), a); return c(a.clone(), u);
}, },
async next() { async next() {
if (r.line = await l.next(), r.line === null) if (n.line = await a.next(), n.line === null)
return !0; return !0;
f(r); f(n);
}, },
current() { current() {
return n; return t;
}, },
line() { line() {
var e; var e;
return (e = r.line) == null ? void 0 : e.slice(r.offsetHead); return (e = n.line) == null ? void 0 : e.slice(n.offsetHead);
}, },
head() { head() {
var e; var e;
return (e = r.line) == null ? void 0 : e.slice(r.offsetHead, r.offsetTail); return (e = n.line) == null ? void 0 : e.slice(n.offsetHead, n.offsetTail);
}, },
tail() { tail() {
var e; var e;
return (e = r.line) == null ? void 0 : e.slice(r.offsetTail); return (e = n.line) == null ? void 0 : e.slice(n.offsetTail);
}, },
level() { level() {
return r.level; return n.level;
}, },
async content(e = -1, t = []) { async content(e = -1, r = []) {
var i; var l;
return e === -1 && (e = r.level + 1), await n.next() || r.level < e ? t : (t.push(((i = r.line) == null ? void 0 : i.slice(e)) || ""), n.content(e, t)); return e === -1 && (e = n.level + 1), await t.next() || n.level < e ? r : (r.push(((l = n.line) == null ? void 0 : l.slice(e)) || ""), t.content(e, r));
}, },
match(e) { match(e) {
return e === n.head(); return e === t.head();
}, },
async each(e) { async each(e) {
const t = n.line() !== void 0 ? n.level() : -1; const r = t.line() !== void 0 ? t.level() : -1;
for (; !(await n.next() || n.level() <= t || await e()); ) for (; !(await t.next() || t.level() <= r || await e()); )
; ;
}, },
async seek(e, t = -1) { async buildObject(e = [], r) {
return t === -1 && (t = r.level), await n.next() ? !1 : n.head() === e ? n : r.level < t ? !1 : n.seek(e, t); r || (r = () => t.tail().trim());
const i = {};
return await t.each(async () => {
if (!!t.head()) {
if (!e.length || e.includes(t.head())) {
i[t.head()] = await r();
return;
}
if (e && !e.includes(t.head()) && e.includes("#text")) {
i["#text"] = [t.line(), ...await t.content(t.level())];
return;
}
}
}), i;
},
async seek(e, r = -1) {
return r === -1 && (r = n.level), await t.next() ? !1 : t.head() === e ? t : n.level < r ? !1 : t.seek(e, r);
} }
}; };
return n; return t;
} }
export { export {
c as useDocument c as useDocument