Preparing core package for use by other packages.

This commit is contained in:
Joshua Bemenderfer
2022-11-12 14:31:11 -05:00
parent 0196cd5c87
commit a0791b0c69
16 changed files with 504 additions and 291 deletions

1
packages/js/core/dist/document.cjs vendored Normal file
View File

@@ -0,0 +1 @@
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./parser.cjs");function s(a,i=" "){let e=null,t=l.LineData(),n=!1;async function r(){return e=await a(),e===null?n=!0:l.parseLine(e,t,i),{line:e,lineData:t,ended:n,next:r,current:u}}function u(){return{line:e,lineData:t,ended:n,next:r,current:u}}return{next:r,current:u}}exports.document=s;

14
packages/js/core/dist/document.js vendored Normal file
View File

@@ -0,0 +1,14 @@
import { parseLine as a, LineData as o } from "./parser.js";
function f(u, i = " ") {
let e = null, n = o(), t = !1;
async function r() {
return e = await u(), e === null ? t = !0 : a(e, n, i), { line: e, lineData: n, ended: t, next: r, current: l };
}
function l() {
return { line: e, lineData: n, ended: t, next: r, current: l };
}
return { next: r, current: l };
}
export {
f as document
};

1
packages/js/core/dist/index.cjs vendored Normal file
View File

@@ -0,0 +1 @@
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./parser.cjs"),r=require("./document.cjs");exports.LineData=e.LineData;exports.parseLine=e.parseLine;exports.document=r.document;

7
packages/js/core/dist/index.js vendored Normal file
View File

@@ -0,0 +1,7 @@
import { LineData as r, parseLine as t } from "./parser.js";
import { document as m } from "./document.js";
export {
r as LineData,
m as document,
t as parseLine
};

1
packages/js/core/dist/parser.cjs vendored Normal file
View File

@@ -0,0 +1 @@
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function s(){return{type:0,level:0,offsetHead:0,offsetTail:0}}function p(r,e,f=" "){if(typeof r!="string")throw new Error("'line' must be a string");if(typeof e!="object"||!e||typeof e.type!="number"||typeof e.level!="number")throw new Error("'lineData' must be an object with 'type' and 'level' integer properties");if(typeof f!="string"||f.length===0||f.length>1)throw new Error("'indent' must be a single-character string");let o=0,t=0;if(!r.length)e.type===1&&(t+=1),e.type===0&&(t=e.level),e.type=o,e.level=t,e.offsetHead=0,e.offsetTail=0;else{for(o=1;r[t]===f&&t<=e.level+1;)++t;for(e.type=o,e.level=t,e.offsetHead=t,e.offsetTail=t;r[e.offsetTail]&&r[e.offsetTail]!==" ";)++e.offsetTail}return e}exports.LineData=s;exports.parseLine=p;

25
packages/js/core/dist/parser.js vendored Normal file
View File

@@ -0,0 +1,25 @@
function s() {
return { type: 0, level: 0, offsetHead: 0, offsetTail: 0 };
}
function p(r, e, t = " ") {
if (typeof r != "string")
throw new Error("'line' must be a string");
if (typeof e != "object" || !e || typeof e.type != "number" || typeof e.level != "number")
throw new Error("'lineData' must be an object with 'type' and 'level' integer properties");
if (typeof t != "string" || t.length === 0 || t.length > 1)
throw new Error("'indent' must be a single-character string");
let o = 0, f = 0;
if (!r.length)
e.type === 1 && (f += 1), e.type === 0 && (f = e.level), e.type = o, e.level = f, e.offsetHead = 0, e.offsetTail = 0;
else {
for (o = 1; r[f] === t && f <= e.level + 1; )
++f;
for (e.type = o, e.level = f, e.offsetHead = f, e.offsetTail = f; r[e.offsetTail] && r[e.offsetTail] !== " "; )
++e.offsetTail;
}
return e;
}
export {
s as LineData,
p as parseLine
};