@emeryld/rrroutes-contract 2.7.10 → 2.7.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/export/defaultViewerTemplate.d.ts +1 -1
- package/dist/export/flattenSchema.d.ts +1 -0
- package/dist/index.cjs +35 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +35 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/tools/finalized-leaves-viewer.html +435 -141
package/dist/index.mjs
CHANGED
|
@@ -591,6 +591,24 @@ function serializeLeavesContract(leaves, options = {}) {
|
|
|
591
591
|
}
|
|
592
592
|
|
|
593
593
|
// src/export/flattenSchema.ts
|
|
594
|
+
function formatLiteralType(literal) {
|
|
595
|
+
if (typeof literal === "string") return literal;
|
|
596
|
+
if (typeof literal === "number" || typeof literal === "boolean" || typeof literal === "bigint") {
|
|
597
|
+
return String(literal);
|
|
598
|
+
}
|
|
599
|
+
if (literal === null) return "null";
|
|
600
|
+
if (Array.isArray(literal)) {
|
|
601
|
+
return literal.map((item) => formatLiteralType(item)).join("|");
|
|
602
|
+
}
|
|
603
|
+
if (typeof literal === "object") {
|
|
604
|
+
try {
|
|
605
|
+
return JSON.stringify(literal);
|
|
606
|
+
} catch {
|
|
607
|
+
return "object";
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return "unknown";
|
|
611
|
+
}
|
|
594
612
|
function normalizeType(schema) {
|
|
595
613
|
switch (schema.kind) {
|
|
596
614
|
case "string":
|
|
@@ -607,11 +625,7 @@ function normalizeType(schema) {
|
|
|
607
625
|
return "unknown";
|
|
608
626
|
}
|
|
609
627
|
case "literal": {
|
|
610
|
-
|
|
611
|
-
if (typeof lit === "string") return "string";
|
|
612
|
-
if (typeof lit === "number") return "number";
|
|
613
|
-
if (typeof lit === "boolean") return "boolean";
|
|
614
|
-
return "unknown";
|
|
628
|
+
return formatLiteralType(schema.literal);
|
|
615
629
|
}
|
|
616
630
|
default:
|
|
617
631
|
return "unknown";
|
|
@@ -625,7 +639,8 @@ function setNode(out, path4, schema, inherited) {
|
|
|
625
639
|
out[path4] = {
|
|
626
640
|
type: normalizeType(schema),
|
|
627
641
|
nullable: inherited.nullable || Boolean(schema.nullable),
|
|
628
|
-
optional: inherited.optional || Boolean(schema.optional)
|
|
642
|
+
optional: inherited.optional || Boolean(schema.optional),
|
|
643
|
+
literal: schema.kind === "literal" ? schema.literal : void 0
|
|
629
644
|
};
|
|
630
645
|
}
|
|
631
646
|
function flattenInto(out, schema, path4, inherited) {
|
|
@@ -734,8 +749,19 @@ var DEFAULT_VIEWER_TEMPLATE = `<!doctype html>
|
|
|
734
749
|
const toHref = (source) => {
|
|
735
750
|
if (!source || !source.file) return null
|
|
736
751
|
const normalizedPath = String(source.file).replace(/\\\\/g, '/')
|
|
737
|
-
const
|
|
738
|
-
|
|
752
|
+
const platform =
|
|
753
|
+
(navigator.userAgentData && navigator.userAgentData.platform) ||
|
|
754
|
+
navigator.platform ||
|
|
755
|
+
''
|
|
756
|
+
const isWindows = /win/i.test(platform)
|
|
757
|
+
const vscodePath = isWindows
|
|
758
|
+
? normalizedPath.replace(/^\\/+/, '')
|
|
759
|
+
: normalizedPath.startsWith('/')
|
|
760
|
+
? normalizedPath
|
|
761
|
+
: '/' + normalizedPath
|
|
762
|
+
const line = Number.isFinite(source.line) ? source.line : 1
|
|
763
|
+
const column = Number.isFinite(source.column) ? source.column : 1
|
|
764
|
+
return 'vscode://file/' + encodeURI(vscodePath) + ':' + line + ':' + column
|
|
739
765
|
}
|
|
740
766
|
|
|
741
767
|
const sourceDisplay = (source) => {
|
|
@@ -1384,7 +1410,7 @@ function buildMeta(sourceExtraction) {
|
|
|
1384
1410
|
"literal?",
|
|
1385
1411
|
"enumValues?"
|
|
1386
1412
|
],
|
|
1387
|
-
flatSchemaEntry: ["type", "nullable", "optional"]
|
|
1413
|
+
flatSchemaEntry: ["type", "nullable", "optional", "literal?"]
|
|
1388
1414
|
},
|
|
1389
1415
|
flattening: {
|
|
1390
1416
|
notation: "dot+[]",
|