@judo/codegen 0.1.0 → 0.2.0
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/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as generate, t as extractModel } from "./model-reader-
|
|
2
|
+
import { n as generate, t as extractModel } from "./model-reader-DZ5wLHJt.js";
|
|
3
3
|
import { existsSync, mkdirSync, readFileSync, unwatchFile, watchFile, writeFileSync } from "node:fs";
|
|
4
4
|
import { dirname, join, relative, resolve } from "node:path";
|
|
5
5
|
function parseArgs(e) {
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as generate, t as extractModel } from "./model-reader-
|
|
1
|
+
import { n as generate, t as extractModel } from "./model-reader-DZ5wLHJt.js";
|
|
2
2
|
export { extractModel, generate };
|
|
@@ -790,7 +790,7 @@ function validateAttributeString(l, R) {
|
|
|
790
790
|
if (z[l][3] === void 0 && !R.allowBooleanAttributes) return getErrorObject("InvalidAttr", "boolean attribute '" + z[l][2] + "' is not allowed.", getPositionFromMatch(z[l]));
|
|
791
791
|
let V = z[l][2];
|
|
792
792
|
if (!validateAttrName(V)) return getErrorObject("InvalidAttr", "Attribute '" + V + "' is an invalid name.", getPositionFromMatch(z[l]));
|
|
793
|
-
if (!
|
|
793
|
+
if (!Object.prototype.hasOwnProperty.call(B, V)) B[V] = 1;
|
|
794
794
|
else return getErrorObject("InvalidAttr", "Attribute '" + V + "' is repeated.", getPositionFromMatch(z[l]));
|
|
795
795
|
}
|
|
796
796
|
return !0;
|
|
@@ -874,7 +874,9 @@ const defaultOptions = {
|
|
|
874
874
|
updateTag: function(l, R, z) {
|
|
875
875
|
return l;
|
|
876
876
|
},
|
|
877
|
-
captureMetaData: !1
|
|
877
|
+
captureMetaData: !1,
|
|
878
|
+
maxNestedTags: 100,
|
|
879
|
+
strictReservedNames: !0
|
|
878
880
|
};
|
|
879
881
|
function normalizeProcessEntities(l) {
|
|
880
882
|
return typeof l == "boolean" ? {
|
|
@@ -901,7 +903,7 @@ const buildOptions = function(l) {
|
|
|
901
903
|
};
|
|
902
904
|
var METADATA_SYMBOL$1 = typeof Symbol == "function" ? Symbol("XML Node Metadata") : "@@xmlMetadata", XmlNode = class {
|
|
903
905
|
constructor(l) {
|
|
904
|
-
this.tagname = l, this.child = [], this[":@"] =
|
|
906
|
+
this.tagname = l, this.child = [], this[":@"] = Object.create(null);
|
|
905
907
|
}
|
|
906
908
|
add(l, R) {
|
|
907
909
|
l === "__proto__" && (l = "#__proto__"), this.child.push({ [l]: R });
|
|
@@ -920,7 +922,7 @@ var METADATA_SYMBOL$1 = typeof Symbol == "function" ? Symbol("XML Node Metadata"
|
|
|
920
922
|
this.suppressValidationErr = !l, this.options = l;
|
|
921
923
|
}
|
|
922
924
|
readDocType(l, R) {
|
|
923
|
-
let z =
|
|
925
|
+
let z = Object.create(null);
|
|
924
926
|
if (l[R + 3] === "O" && l[R + 4] === "C" && l[R + 5] === "T" && l[R + 6] === "Y" && l[R + 7] === "P" && l[R + 8] === "E") {
|
|
925
927
|
R += 9;
|
|
926
928
|
let B = 1, V = !1, H = !1, U = "";
|
|
@@ -1078,7 +1080,8 @@ var hexRegex = /^[-+]?0x[a-fA-F0-9]+$/, numRegex = /^([\-\+])?(0*)([0-9]*(\.[0-9
|
|
|
1078
1080
|
hex: !0,
|
|
1079
1081
|
leadingZeros: !0,
|
|
1080
1082
|
decimalPoint: ".",
|
|
1081
|
-
eNotation: !0
|
|
1083
|
+
eNotation: !0,
|
|
1084
|
+
infinity: "original"
|
|
1082
1085
|
};
|
|
1083
1086
|
function toNumber(l, R = {}) {
|
|
1084
1087
|
if (R = Object.assign({}, consider, R), !l || typeof l != "string") return l;
|
|
@@ -1086,22 +1089,24 @@ function toNumber(l, R = {}) {
|
|
|
1086
1089
|
if (R.skipLike !== void 0 && R.skipLike.test(z)) return l;
|
|
1087
1090
|
if (l === "0") return 0;
|
|
1088
1091
|
if (R.hex && hexRegex.test(z)) return parse_int(z, 16);
|
|
1089
|
-
if (
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1092
|
+
if (isFinite(z)) {
|
|
1093
|
+
if (z.includes("e") || z.includes("E")) return resolveEnotation(l, z, R);
|
|
1094
|
+
{
|
|
1095
|
+
let B = numRegex.exec(z);
|
|
1096
|
+
if (B) {
|
|
1097
|
+
let V = B[1] || "", H = B[2], U = trimZeros(B[3]), W = V ? l[H.length + 1] === "." : l[H.length] === ".";
|
|
1098
|
+
if (!R.leadingZeros && (H.length > 1 || H.length === 1 && !W)) return l;
|
|
1099
|
+
{
|
|
1100
|
+
let B = Number(z), W = String(B);
|
|
1101
|
+
if (B === 0) return B;
|
|
1102
|
+
if (W.search(/[eE]/) !== -1) return R.eNotation ? B : l;
|
|
1103
|
+
if (z.indexOf(".") !== -1) return W === "0" || W === U || W === `${V}${U}` ? B : l;
|
|
1104
|
+
let G = H ? U : z;
|
|
1105
|
+
return H ? G === W || V + G === W ? B : l : G === W || G === V + W ? B : l;
|
|
1106
|
+
}
|
|
1107
|
+
} else return l;
|
|
1108
|
+
}
|
|
1109
|
+
} else return handleInfinity(l, Number(z), R);
|
|
1105
1110
|
}
|
|
1106
1111
|
var eNotationRegx = /^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;
|
|
1107
1112
|
function resolveEnotation(l, R, z) {
|
|
@@ -1121,6 +1126,16 @@ function parse_int(l, R) {
|
|
|
1121
1126
|
if (window && window.parseInt) return window.parseInt(l, R);
|
|
1122
1127
|
throw Error("parseInt, Number.parseInt, window.parseInt are not supported");
|
|
1123
1128
|
}
|
|
1129
|
+
function handleInfinity(l, R, z) {
|
|
1130
|
+
let B = R === Infinity;
|
|
1131
|
+
switch (z.infinity.toLowerCase()) {
|
|
1132
|
+
case "null": return null;
|
|
1133
|
+
case "infinity": return R;
|
|
1134
|
+
case "string": return B ? "Infinity" : "-Infinity";
|
|
1135
|
+
case "original":
|
|
1136
|
+
default: return l;
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1124
1139
|
function getIgnoreAttributesFn(l) {
|
|
1125
1140
|
return typeof l == "function" ? l : Array.isArray(l) ? (R) => {
|
|
1126
1141
|
for (let z of l) if (typeof z == "string" && R === z || z instanceof RegExp && z.test(R)) return !0;
|
|
@@ -1290,6 +1305,7 @@ var parseXml = function(l) {
|
|
|
1290
1305
|
let l = this.options.transformTagName(W);
|
|
1291
1306
|
K === W && (K = l), W = l;
|
|
1292
1307
|
}
|
|
1308
|
+
if (this.options.strictReservedNames && (W === this.options.commentPropName || W === this.options.cdataPropName)) throw Error(`Invalid tag name: ${W}`);
|
|
1293
1309
|
z && B && z.tagname !== "!xml" && (B = this.saveTextToParentTag(B, z, V, !1));
|
|
1294
1310
|
let Y = z;
|
|
1295
1311
|
Y && this.options.unpairedTags.indexOf(Y.tagname) !== -1 && (z = this.tagsNodeStack.pop(), V = V.substring(0, V.lastIndexOf("."))), W !== R.tagname && (V += V ? "." + W : W);
|
|
@@ -1313,8 +1329,13 @@ var parseXml = function(l) {
|
|
|
1313
1329
|
}
|
|
1314
1330
|
let l = new XmlNode(W);
|
|
1315
1331
|
W !== K && q && (l[":@"] = this.buildAttributesMap(K, V, W)), this.addChild(z, l, V, X), V = V.substr(0, V.lastIndexOf("."));
|
|
1332
|
+
} else if (this.options.unpairedTags.indexOf(W) !== -1) {
|
|
1333
|
+
let l = new XmlNode(W);
|
|
1334
|
+
W !== K && q && (l[":@"] = this.buildAttributesMap(K, V)), this.addChild(z, l, V, X), V = V.substr(0, V.lastIndexOf(".")), U = H.closeIndex;
|
|
1335
|
+
continue;
|
|
1316
1336
|
} else {
|
|
1317
1337
|
let l = new XmlNode(W);
|
|
1338
|
+
if (this.tagsNodeStack.length > this.options.maxNestedTags) throw Error("Maximum nested tags exceeded");
|
|
1318
1339
|
this.tagsNodeStack.push(z), W !== K && q && (l[":@"] = this.buildAttributesMap(K, V, W)), this.addChild(z, l, V, X), z = l;
|
|
1319
1340
|
}
|
|
1320
1341
|
B = "", U = J;
|
|
@@ -1440,7 +1461,7 @@ function compress(l, R, z) {
|
|
|
1440
1461
|
else if (W === void 0) continue;
|
|
1441
1462
|
else if (U[W]) {
|
|
1442
1463
|
let l = compress(U[W], R, G), z = isLeafTag(l, R);
|
|
1443
|
-
U[
|
|
1464
|
+
U[":@"] ? assignAttributes(l, U[":@"], G, R) : Object.keys(l).length === 1 && l[R.textNodeName] !== void 0 && !R.alwaysCreateTextNode ? l = l[R.textNodeName] : Object.keys(l).length === 0 && (R.alwaysCreateTextNode ? l[R.textNodeName] = "" : l = ""), U[METADATA_SYMBOL] !== void 0 && typeof l == "object" && l && (l[METADATA_SYMBOL] = U[METADATA_SYMBOL]), V[W] !== void 0 && Object.prototype.hasOwnProperty.call(V, W) ? (Array.isArray(V[W]) || (V[W] = [V[W]]), V[W].push(l)) : R.isArray(W, G, z) ? V[W] = [l] : V[W] = l;
|
|
1444
1465
|
}
|
|
1445
1466
|
}
|
|
1446
1467
|
return typeof B == "string" ? B.length > 0 && (V[R.textNodeName] = B) : B !== void 0 && (V[R.textNodeName] = B), V;
|