routie dev init since i didn't adhere to any proper guidance up until now

This commit is contained in:
2026-04-29 22:27:29 -06:00
commit e1dabb71e2
15301 changed files with 3562618 additions and 0 deletions
@@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = descriptionTokenizer;
exports.getJoiner = getJoiner;
const primitives_js_1 = require("../../primitives.cjs");
/**
* Makes no changes to `spec.lines[].tokens` but joins them into `spec.description`
* following given spacing srtategy
* @param {Spacing} spacing tells how to handle the whitespace
* @param {BlockMarkers} markers tells how to handle comment block delimitation
*/
function descriptionTokenizer(spacing = 'compact', markers = primitives_js_1.Markers) {
const join = getJoiner(spacing);
return spec => {
spec.description = join(spec.source, markers);
return spec;
};
}
function getJoiner(spacing) {
if (spacing === 'compact') return compactJoiner;
if (spacing === 'preserve') return preserveJoiner;
return spacing;
}
function compactJoiner(lines, markers = primitives_js_1.Markers) {
return lines.map(({
tokens: {
description
}
}) => description.trim()).filter(description => description !== '').join(' ');
}
const lineNo = (num, {
tokens
}, i) => tokens.type === '' ? num : i;
const getDescription = ({
tokens
}) => (tokens.delimiter === '' ? tokens.start : tokens.postDelimiter.slice(1)) + tokens.description;
function preserveJoiner(lines, markers = primitives_js_1.Markers) {
if (lines.length === 0) return '';
// skip the opening line with no description
if (lines[0].tokens.description === '' && lines[0].tokens.delimiter === markers.start) lines = lines.slice(1);
// skip the closing line with no description
const lastLine = lines[lines.length - 1];
if (lastLine !== undefined && lastLine.tokens.description === '' && lastLine.tokens.end.endsWith(markers.end)) lines = lines.slice(0, -1);
// description starts at the last line of type definition
lines = lines.slice(lines.reduce(lineNo, 0));
return lines.map(getDescription).join('\n');
}
//# sourceMappingURL=description.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"description.cjs","names":["Object","defineProperty","exports","value","default","descriptionTokenizer","getJoiner","primitives_js_1","require","spacing","markers","Markers","join","spec","description","source","compactJoiner","preserveJoiner","lines","map","tokens","trim","filter","lineNo","num","i","type","getDescription","delimiter","start","postDelimiter","slice","length","lastLine","undefined","end","endsWith","reduce"],"sources":["description.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.default = descriptionTokenizer;\nexports.getJoiner = getJoiner;\nconst primitives_js_1 = require(\"../../primitives.js\");\n/**\n * Makes no changes to `spec.lines[].tokens` but joins them into `spec.description`\n * following given spacing srtategy\n * @param {Spacing} spacing tells how to handle the whitespace\n * @param {BlockMarkers} markers tells how to handle comment block delimitation\n */\nfunction descriptionTokenizer(spacing = 'compact', markers = primitives_js_1.Markers) {\n const join = getJoiner(spacing);\n return (spec) => {\n spec.description = join(spec.source, markers);\n return spec;\n };\n}\nfunction getJoiner(spacing) {\n if (spacing === 'compact')\n return compactJoiner;\n if (spacing === 'preserve')\n return preserveJoiner;\n return spacing;\n}\nfunction compactJoiner(lines, markers = primitives_js_1.Markers) {\n return lines\n .map(({ tokens: { description } }) => description.trim())\n .filter((description) => description !== '')\n .join(' ');\n}\nconst lineNo = (num, { tokens }, i) => tokens.type === '' ? num : i;\nconst getDescription = ({ tokens }) => (tokens.delimiter === '' ? tokens.start : tokens.postDelimiter.slice(1)) +\n tokens.description;\nfunction preserveJoiner(lines, markers = primitives_js_1.Markers) {\n if (lines.length === 0)\n return '';\n // skip the opening line with no description\n if (lines[0].tokens.description === '' &&\n lines[0].tokens.delimiter === markers.start)\n lines = lines.slice(1);\n // skip the closing line with no description\n const lastLine = lines[lines.length - 1];\n if (lastLine !== undefined &&\n lastLine.tokens.description === '' &&\n lastLine.tokens.end.endsWith(markers.end))\n lines = lines.slice(0, -1);\n // description starts at the last line of type definition\n lines = lines.slice(lines.reduce(lineNo, 0));\n return lines.map(getDescription).join('\\n');\n}\n"],"mappings":"AAAA,YAAY;;AACZA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,OAAO,GAAGC,oBAAoB;AACtCH,OAAO,CAACI,SA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,CAACI,OAAO,EAAE;EAC9D,IAAIO,KAAK,CAACc,MAAM,KAAK,CAAC,EAClB,OAAO,EAAE;EACb;EACA,IAAId,KAAK,CAAC,CAAC,CAAC,CAACE,MAAM,CAACN,WAAW,KAAK,EAAE,IAClCI,KAAK,CAAC,CAAC,CAAC,CAACE,MAAM,CAACQ,SAAS,KAAKlB,OAAO,CAACmB,KAAK,EAC3CX,KAAK,GAAGA,KAAK,CAACa,KAAK,CAAC,CAAC,CAAC;EAC1B;EACA,MAAME,QAAQ,GAAGf,KAAK,CAACA,KAAK,CAACc,MAAM,GAAG,CAAC,CAAC;EACxC,IAAIC,QAAQ,KAAKC,SAAS,IACtBD,QAAQ,CAACb,MAAM,CAACN,WAAW,KAAK,EAAE,IAClCmB,QAAQ,CAACb,MAAM,CAACe,GAAG,CAACC,QAAQ,CAAC1B,OAAO,CAACyB,GAAG,CAAC,EACzCjB,KAAK,GAAGA,KAAK,CAACa,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EAC9B;EACAb,KAAK,GAAGA,KAAK,CAACa,KAAK,CAACb,KAAK,CAACmB,MAAM,CAACd,MAAM,EAAE,CAAC,CAAC,CAAC;EAC5C,OAAOL,KAAK,CAACC,GAAG,CAACQ,cAAc,CAAC,CAACf,IAAI,CAAC,IAAI,CAAC;AAC/C","ignoreList":[]}
@@ -0,0 +1,20 @@
import { Line, BlockMarkers, Markers } from '../../primitives.js';
import { Tokenizer } from './index.js';
/**
* Walks over provided lines joining description token into a single string.
* */
export type Joiner = (lines: Line[], markers?: BlockMarkers) => string;
/**
* Shortcut for standard Joiners
* compact - strip surrounding whitespace and concat lines using a single string
* preserve - preserves original whitespace and line breaks as is
*/
export type Spacing = 'compact' | 'preserve' | Joiner;
/**
* Makes no changes to `spec.lines[].tokens` but joins them into `spec.description`
* following given spacing srtategy
* @param {Spacing} spacing tells how to handle the whitespace
* @param {BlockMarkers} markers tells how to handle comment block delimitation
*/
export default function descriptionTokenizer(spacing?: Spacing, markers?: typeof Markers): Tokenizer;
export declare function getJoiner(spacing: Spacing): Joiner;
+6
View File
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"index.cjs","names":["Object","defineProperty","exports","value"],"sources":["index.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n"],"mappings":"AAAA,YAAY;;AACZA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,7 @@
import { Spec } from '../../primitives.js';
/**
* Splits `spect.lines[].token.description` into other tokens,
* and populates the spec.{tag, name, type, description}. Invoked in a chaing
* with other tokens, operations listed above can be moved to separate tokenizers
*/
export type Tokenizer = (spec: Spec) => Spec;
+143
View File
@@ -0,0 +1,143 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = nameTokenizer;
const util_js_1 = require("../../util.cjs");
const isQuoted = s => s && s.startsWith('"') && s.endsWith('"');
/**
* Splits remaining `spec.lines[].tokens.description` into `name` and `descriptions` tokens,
* and populates the `spec.name`
*/
function nameTokenizer() {
const typeEnd = (num, {
tokens
}, i) => tokens.type === '' ? num : i;
return spec => {
// look for the name starting in the line where {type} ends
let finalTypeLine = spec.source.reduce(typeEnd, 0);
let tokens;
if (spec.type) {
do {
({
tokens
} = spec.source[finalTypeLine]);
if (tokens.description.trim()) {
break;
}
finalTypeLine++;
} while (spec.source[finalTypeLine]);
} else {
({
tokens
} = spec.source[finalTypeLine]);
}
const source = tokens.description.trimStart();
const quotedGroups = source.split('"');
// if it starts with quoted group, assume it is a literal
if (quotedGroups.length > 1 && quotedGroups[0] === '' && quotedGroups.length % 2 === 1) {
spec.name = quotedGroups[1];
tokens.name = `"${quotedGroups[1]}"`;
[tokens.postName, tokens.description] = (0, util_js_1.splitSpace)(source.slice(tokens.name.length));
return spec;
}
let brackets = 0;
let name = '';
let optional = false;
let defaultValue;
// assume name is non-space string or anything wrapped into brackets
for (const ch of source) {
if (brackets === 0 && (0, util_js_1.isSpace)(ch)) break;
if (ch === '[') brackets++;
if (ch === ']') brackets--;
name += ch;
}
if (brackets !== 0) {
spec.problems.push({
code: 'spec:name:unpaired-brackets',
message: 'unpaired brackets',
line: spec.source[0].number,
critical: true
});
return spec;
}
const nameToken = name;
if (name[0] === '[' && name[name.length - 1] === ']') {
optional = true;
name = name.slice(1, -1);
const parts = name.split('=');
name = parts[0].trim();
if (parts[1] !== undefined) defaultValue = parts.slice(1).join('=').trim();
if (name === '') {
spec.problems.push({
code: 'spec:name:empty-name',
message: 'empty name',
line: spec.source[0].number,
critical: true
});
return spec;
}
if (defaultValue === '') {
spec.problems.push({
code: 'spec:name:empty-default',
message: 'empty default value',
line: spec.source[0].number,
critical: true
});
return spec;
}
// has "=" and is not a string, except for "=>"
if (!isQuoted(defaultValue) && /=(?!>)/.test(defaultValue)) {
spec.problems.push({
code: 'spec:name:invalid-default',
message: 'invalid default value syntax',
line: spec.source[0].number,
critical: true
});
return spec;
}
}
if (!optional) {
const eqIndex = name.search(/=(?!>)/);
if (eqIndex !== -1) {
defaultValue = name.slice(eqIndex + 1).trim();
name = name.slice(0, eqIndex).trim();
if (name === '') {
spec.problems.push({
code: 'spec:name:empty-name',
message: 'empty name',
line: spec.source[0].number,
critical: true
});
return spec;
}
if (defaultValue === '') {
spec.problems.push({
code: 'spec:name:empty-default',
message: 'empty default value',
line: spec.source[0].number,
critical: true
});
return spec;
}
if (!isQuoted(defaultValue) && /=(?!>)/.test(defaultValue)) {
spec.problems.push({
code: 'spec:name:invalid-default',
message: 'invalid default value syntax',
line: spec.source[0].number,
critical: true
});
return spec;
}
}
}
spec.optional = optional;
spec.name = name;
tokens.name = nameToken;
if (defaultValue !== undefined) spec.default = defaultValue;
[tokens.postName, tokens.description] = (0, util_js_1.splitSpace)(source.slice(tokens.name.length));
return spec;
};
}
//# sourceMappingURL=name.cjs.map
File diff suppressed because one or more lines are too long
+6
View File
@@ -0,0 +1,6 @@
import { Tokenizer } from './index.js';
/**
* Splits remaining `spec.lines[].tokens.description` into `name` and `descriptions` tokens,
* and populates the `spec.name`
*/
export default function nameTokenizer(): Tokenizer;
+36
View File
@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = tagTokenizer;
/**
* Splits the `@prefix` from remaining `Spec.lines[].token.description` into the `tag` token,
* and populates `spec.tag`
*/
function tagTokenizer() {
return spec => {
const {
tokens
} = spec.source[0];
const match = tokens.description.match(/\s*(@(\S+))(\s*)/);
if (match === null) {
spec.problems.push({
code: 'spec:tag:prefix',
message: 'tag should start with "@" symbol',
line: spec.source[0].number,
critical: true
});
return spec;
}
if (match[1].includes('/')) {
return spec;
}
tokens.tag = match[1];
tokens.postTag = match[3];
tokens.description = tokens.description.slice(match[0].length);
spec.tag = match[2];
return spec;
};
}
//# sourceMappingURL=tag.cjs.map
@@ -0,0 +1 @@
{"version":3,"file":"tag.cjs","names":["Object","defineProperty","exports","value","default","tagTokenizer","spec","tokens","source","match","description","problems","push","code","message","line","number","critical","includes","tag","postTag","slice","length"],"sources":["tag.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.default = tagTokenizer;\n/**\n * Splits the `@prefix` from remaining `Spec.lines[].token.description` into the `tag` token,\n * and populates `spec.tag`\n */\nfunction tagTokenizer() {\n return (spec) => {\n const { tokens } = spec.source[0];\n const match = tokens.description.match(/\\s*(@(\\S+))(\\s*)/);\n if (match === null) {\n spec.problems.push({\n code: 'spec:tag:prefix',\n message: 'tag should start with \"@\" symbol',\n line: spec.source[0].number,\n critical: true,\n });\n return spec;\n }\n if (match[1].includes('/')) {\n return spec;\n }\n tokens.tag = match[1];\n tokens.postTag = match[3];\n tokens.description = tokens.description.slice(match[0].length);\n spec.tag = match[2];\n return spec;\n };\n}\n"],"mappings":"AAAA,YAAY;;AACZA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,OAAO,GAAGC,YAAY;AAC9B;AACA;AACA;AACA;AACA,SAASA,YAAYA,CAAA,EAAG;EACpB,OAAQC,IAAI,IAAK;IACb,MAAM;MAAEC;IAAO,CAAC,GAAGD,IAAI,CAACE,MAAM,CAAC,CAAC,CAAC;IACjC,MAAMC,KAAK,GAAGF,MAAM,CAACG,WAAW,CAACD,KAAK,CAAC,kBAAkB,CAAC;IAC1D,IAAIA,KAAK,KAAK,IAAI,EAAE;MAChBH,IAAI,CAACK,QAAQ,CAACC,IAAI,CAAC;QACfC,IAAI,EAAE,iBAAiB;QACvBC,OAAO,EAAE,kCAAkC;QAC3CC,IAAI,EAAET,IAAI,CAACE,MAAM,CAAC,CAAC,CAAC,CAACQ,MAAM;QAC3BC,QAAQ,EAAE;MACd,CAAC,CAAC;MACF,OAAOX,IAAI;IACf;IACA,IAAIG,KAAK,CAAC,CAAC,CAAC,CAACS,QAAQ,CAAC,GAAG,CAAC,EAAE;MACxB,OAAOZ,IAAI;IACf;IACAC,MAAM,CAACY,GAAG,GAAGV,KAAK,CAAC,CAAC,CAAC;IACrBF,MAAM,CAACa,OAAO,GAAGX,KAAK,CAAC,CAAC,CAAC;IACzBF,MAAM,CAACG,WAAW,GAAGH,MAAM,CAACG,WAAW,CAACW,KAAK,CAACZ,KAAK,CAAC,CAAC,CAAC,CAACa,MAAM,CAAC;IAC9DhB,IAAI,CAACa,GAAG,GAAGV,KAAK,CAAC,CAAC,CAAC;IACnB,OAAOH,IAAI;EACf,CAAC;AACL","ignoreList":[]}
+6
View File
@@ -0,0 +1,6 @@
import { Tokenizer } from './index.js';
/**
* Splits the `@prefix` from remaining `Spec.lines[].token.description` into the `tag` token,
* and populates `spec.tag`
*/
export default function tagTokenizer(): Tokenizer;
+75
View File
@@ -0,0 +1,75 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = typeTokenizer;
const util_js_1 = require("../../util.cjs");
/**
* Sets splits remaining `Spec.lines[].tokens.description` into `type` and `description`
* tokens and populates Spec.type`
*
* @param {Spacing} spacing tells how to deal with a whitespace
* for type values going over multiple lines
*/
function typeTokenizer(spacing = 'compact') {
const join = getJoiner(spacing);
return spec => {
let curlies = 0;
let lines = [];
let descriptionBegun = false;
let firstTypeIteration = true;
for (const {
tokens
} of spec.source.values()) {
let type = '';
if (!descriptionBegun && tokens.description.trim()) {
descriptionBegun = true;
} else if (!descriptionBegun) {
continue;
}
if (firstTypeIteration && tokens.description[0] !== '{') return spec;
firstTypeIteration = false;
for (const ch of tokens.description) {
if (ch === '{') curlies++;
if (ch === '}') curlies--;
type += ch;
if (curlies === 0) break;
}
lines.push([tokens, type]);
if (curlies === 0) break;
}
if (!descriptionBegun) {
return spec;
}
if (curlies !== 0) {
spec.problems.push({
code: 'spec:type:unpaired-curlies',
message: 'unpaired curlies',
line: spec.source[0].number,
critical: true
});
return spec;
}
const parts = [];
const offset = lines[0][0].postDelimiter.length;
for (const [i, [tokens, type]] of lines.entries()) {
tokens.type = type;
if (i > 0) {
tokens.type = tokens.postDelimiter.slice(offset) + type;
tokens.postDelimiter = tokens.postDelimiter.slice(0, offset);
}
[tokens.postType, tokens.description] = (0, util_js_1.splitSpace)(tokens.description.slice(type.length));
parts.push(tokens.type);
}
parts[0] = parts[0].slice(1);
parts[parts.length - 1] = parts[parts.length - 1].slice(0, -1);
spec.type = join(parts);
return spec;
};
}
const trim = x => x.trim();
function getJoiner(spacing) {
if (spacing === 'compact') return t => t.map(trim).join('');else if (spacing === 'preserve') return t => t.join('\n');else return spacing;
}
//# sourceMappingURL=type.cjs.map
File diff suppressed because one or more lines are too long
+27
View File
@@ -0,0 +1,27 @@
import { Tokenizer } from './index.js';
/**
* Joiner is a function taking collected type token string parts,
* and joining them together. In most of the cases this will be
* a single piece like {type-name}, but type may go over multipe line
* ```
* @tag {function(
* number,
* string
* )}
* ```
*/
export type Joiner = (parts: string[]) => string;
/**
* Shortcut for standard Joiners
* compact - trim surrounding space, replace line breaks with a single space
* preserve - concat as is
*/
export type Spacing = 'compact' | 'preserve' | Joiner;
/**
* Sets splits remaining `Spec.lines[].tokens.description` into `type` and `description`
* tokens and populates Spec.type`
*
* @param {Spacing} spacing tells how to deal with a whitespace
* for type values going over multiple lines
*/
export default function typeTokenizer(spacing?: Spacing): Tokenizer;