@c4a/core 0.6.2 → 0.6.3
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 +2 -1
- package/index.js +176 -422
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -16,7 +16,8 @@ npm install @c4a/core
|
|
|
16
16
|
- **Schema definitions**: Zod-based input/output validation models
|
|
17
17
|
- **Error system**: unified error codes and `C4AError`
|
|
18
18
|
- **Ref utilities**: helpers for parsing and building `ref:*` pointers
|
|
19
|
-
- **Shared constants and helpers**: reusable utilities for
|
|
19
|
+
- **Shared constants and helpers**: reusable utilities for Context extraction
|
|
20
|
+
and CLI packages
|
|
20
21
|
|
|
21
22
|
## Example
|
|
22
23
|
|
package/index.js
CHANGED
|
@@ -319,26 +319,26 @@ var require_directives = __commonJS((exports) => {
|
|
|
319
319
|
return false;
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
|
-
tagName(
|
|
323
|
-
if (
|
|
322
|
+
tagName(source, onError) {
|
|
323
|
+
if (source === "!")
|
|
324
324
|
return "!";
|
|
325
|
-
if (
|
|
326
|
-
onError(`Not a valid tag: ${
|
|
325
|
+
if (source[0] !== "!") {
|
|
326
|
+
onError(`Not a valid tag: ${source}`);
|
|
327
327
|
return null;
|
|
328
328
|
}
|
|
329
|
-
if (
|
|
330
|
-
const verbatim =
|
|
329
|
+
if (source[1] === "<") {
|
|
330
|
+
const verbatim = source.slice(2, -1);
|
|
331
331
|
if (verbatim === "!" || verbatim === "!!") {
|
|
332
|
-
onError(`Verbatim tags aren't resolved, so ${
|
|
332
|
+
onError(`Verbatim tags aren't resolved, so ${source} is invalid.`);
|
|
333
333
|
return null;
|
|
334
334
|
}
|
|
335
|
-
if (
|
|
335
|
+
if (source[source.length - 1] !== ">")
|
|
336
336
|
onError("Verbatim tags must end with a >");
|
|
337
337
|
return verbatim;
|
|
338
338
|
}
|
|
339
|
-
const [, handle, suffix] =
|
|
339
|
+
const [, handle, suffix] = source.match(/^(.*!)([^!]*)$/s);
|
|
340
340
|
if (!suffix)
|
|
341
|
-
onError(`The ${
|
|
341
|
+
onError(`The ${source} tag has no suffix`);
|
|
342
342
|
const prefix = this.tags[handle];
|
|
343
343
|
if (prefix) {
|
|
344
344
|
try {
|
|
@@ -349,8 +349,8 @@ var require_directives = __commonJS((exports) => {
|
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
if (handle === "!")
|
|
352
|
-
return
|
|
353
|
-
onError(`Could not resolve tag: ${
|
|
352
|
+
return source;
|
|
353
|
+
onError(`Could not resolve tag: ${source}`);
|
|
354
354
|
return null;
|
|
355
355
|
}
|
|
356
356
|
tagString(tag) {
|
|
@@ -422,21 +422,21 @@ var require_anchors = __commonJS((exports) => {
|
|
|
422
422
|
const sourceObjects = new Map;
|
|
423
423
|
let prevAnchors = null;
|
|
424
424
|
return {
|
|
425
|
-
onAnchor: (
|
|
426
|
-
aliasObjects.push(
|
|
425
|
+
onAnchor: (source) => {
|
|
426
|
+
aliasObjects.push(source);
|
|
427
427
|
prevAnchors ?? (prevAnchors = anchorNames(doc));
|
|
428
428
|
const anchor = findNewAnchor(prefix, prevAnchors);
|
|
429
429
|
prevAnchors.add(anchor);
|
|
430
430
|
return anchor;
|
|
431
431
|
},
|
|
432
432
|
setAnchors: () => {
|
|
433
|
-
for (const
|
|
434
|
-
const ref = sourceObjects.get(
|
|
433
|
+
for (const source of aliasObjects) {
|
|
434
|
+
const ref = sourceObjects.get(source);
|
|
435
435
|
if (typeof ref === "object" && ref.anchor && (identity.isScalar(ref.node) || identity.isCollection(ref.node))) {
|
|
436
436
|
ref.node.anchor = ref.anchor;
|
|
437
437
|
} else {
|
|
438
438
|
const error = new Error("Failed to resolve repeated object (this should not happen)");
|
|
439
|
-
error.source =
|
|
439
|
+
error.source = source;
|
|
440
440
|
throw error;
|
|
441
441
|
}
|
|
442
442
|
}
|
|
@@ -570,9 +570,9 @@ var require_Alias = __commonJS((exports) => {
|
|
|
570
570
|
var toJS = require_toJS();
|
|
571
571
|
|
|
572
572
|
class Alias extends Node.NodeBase {
|
|
573
|
-
constructor(
|
|
573
|
+
constructor(source) {
|
|
574
574
|
super(identity.ALIAS);
|
|
575
|
-
this.source =
|
|
575
|
+
this.source = source;
|
|
576
576
|
Object.defineProperty(this, "tag", {
|
|
577
577
|
set() {
|
|
578
578
|
throw new Error("Alias nodes cannot have tags");
|
|
@@ -607,15 +607,15 @@ var require_Alias = __commonJS((exports) => {
|
|
|
607
607
|
if (!ctx)
|
|
608
608
|
return { source: this.source };
|
|
609
609
|
const { anchors: anchors2, doc, maxAliasCount } = ctx;
|
|
610
|
-
const
|
|
611
|
-
if (!
|
|
610
|
+
const source = this.resolve(doc, ctx);
|
|
611
|
+
if (!source) {
|
|
612
612
|
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
613
613
|
throw new ReferenceError(msg);
|
|
614
614
|
}
|
|
615
|
-
let data = anchors2.get(
|
|
615
|
+
let data = anchors2.get(source);
|
|
616
616
|
if (!data) {
|
|
617
|
-
toJS.toJS(
|
|
618
|
-
data = anchors2.get(
|
|
617
|
+
toJS.toJS(source, null, ctx);
|
|
618
|
+
data = anchors2.get(source);
|
|
619
619
|
}
|
|
620
620
|
if (data?.res === undefined) {
|
|
621
621
|
const msg = "This should not happen: Alias anchor was not resolved?";
|
|
@@ -624,7 +624,7 @@ var require_Alias = __commonJS((exports) => {
|
|
|
624
624
|
if (maxAliasCount >= 0) {
|
|
625
625
|
data.count += 1;
|
|
626
626
|
if (data.aliasCount === 0)
|
|
627
|
-
data.aliasCount = getAliasCount(doc,
|
|
627
|
+
data.aliasCount = getAliasCount(doc, source, anchors2);
|
|
628
628
|
if (data.count * data.aliasCount > maxAliasCount) {
|
|
629
629
|
const msg = "Excessive alias count indicates a resource exhaustion attack";
|
|
630
630
|
throw new ReferenceError(msg);
|
|
@@ -648,8 +648,8 @@ var require_Alias = __commonJS((exports) => {
|
|
|
648
648
|
}
|
|
649
649
|
function getAliasCount(doc, node2, anchors2) {
|
|
650
650
|
if (identity.isAlias(node2)) {
|
|
651
|
-
const
|
|
652
|
-
const anchor = anchors2 &&
|
|
651
|
+
const source = node2.resolve(doc);
|
|
652
|
+
const anchor = anchors2 && source && anchors2.get(source);
|
|
653
653
|
return anchor ? anchor.count * anchor.aliasCount : 0;
|
|
654
654
|
} else if (identity.isCollection(node2)) {
|
|
655
655
|
let count = 0;
|
|
@@ -1639,10 +1639,10 @@ var require_merge = __commonJS((exports) => {
|
|
|
1639
1639
|
mergeValue(ctx, map, value);
|
|
1640
1640
|
}
|
|
1641
1641
|
function mergeValue(ctx, map, value) {
|
|
1642
|
-
const
|
|
1643
|
-
if (!identity.isMap(
|
|
1642
|
+
const source = ctx && identity.isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
1643
|
+
if (!identity.isMap(source))
|
|
1644
1644
|
throw new Error("Merge sources must be maps or map aliases");
|
|
1645
|
-
const srcMap =
|
|
1645
|
+
const srcMap = source.toJSON(null, ctx, Map);
|
|
1646
1646
|
for (const [key, value2] of srcMap) {
|
|
1647
1647
|
if (map instanceof Map) {
|
|
1648
1648
|
if (!map.has(key))
|
|
@@ -2193,7 +2193,7 @@ var require_null = __commonJS((exports) => {
|
|
|
2193
2193
|
tag: "tag:yaml.org,2002:null",
|
|
2194
2194
|
test: /^(?:~|[Nn]ull|NULL)?$/,
|
|
2195
2195
|
resolve: () => new Scalar.Scalar(null),
|
|
2196
|
-
stringify: ({ source
|
|
2196
|
+
stringify: ({ source }, ctx) => typeof source === "string" && nullTag.test.test(source) ? source : ctx.options.nullStr
|
|
2197
2197
|
};
|
|
2198
2198
|
exports.nullTag = nullTag;
|
|
2199
2199
|
});
|
|
@@ -2207,11 +2207,11 @@ var require_bool = __commonJS((exports) => {
|
|
|
2207
2207
|
tag: "tag:yaml.org,2002:bool",
|
|
2208
2208
|
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
|
2209
2209
|
resolve: (str) => new Scalar.Scalar(str[0] === "t" || str[0] === "T"),
|
|
2210
|
-
stringify({ source
|
|
2211
|
-
if (
|
|
2212
|
-
const sv =
|
|
2210
|
+
stringify({ source, value }, ctx) {
|
|
2211
|
+
if (source && boolTag.test.test(source)) {
|
|
2212
|
+
const sv = source[0] === "t" || source[0] === "T";
|
|
2213
2213
|
if (value === sv)
|
|
2214
|
-
return
|
|
2214
|
+
return source;
|
|
2215
2215
|
}
|
|
2216
2216
|
return value ? ctx.options.trueStr : ctx.options.falseStr;
|
|
2217
2217
|
}
|
|
@@ -2622,10 +2622,10 @@ var require_omap = __commonJS((exports) => {
|
|
|
2622
2622
|
// ../../node_modules/.bun/yaml@2.8.2/node_modules/yaml/dist/schema/yaml-1.1/bool.js
|
|
2623
2623
|
var require_bool2 = __commonJS((exports) => {
|
|
2624
2624
|
var Scalar = require_Scalar();
|
|
2625
|
-
function boolStringify({ value, source
|
|
2625
|
+
function boolStringify({ value, source }, ctx) {
|
|
2626
2626
|
const boolObj = value ? trueTag : falseTag;
|
|
2627
|
-
if (
|
|
2628
|
-
return
|
|
2627
|
+
if (source && boolObj.test.test(source))
|
|
2628
|
+
return source;
|
|
2629
2629
|
return value ? ctx.options.trueStr : ctx.options.falseStr;
|
|
2630
2630
|
}
|
|
2631
2631
|
var trueTag = {
|
|
@@ -3838,7 +3838,7 @@ var require_resolve_end = __commonJS((exports) => {
|
|
|
3838
3838
|
let hasSpace = false;
|
|
3839
3839
|
let sep = "";
|
|
3840
3840
|
for (const token of end) {
|
|
3841
|
-
const { source
|
|
3841
|
+
const { source, type } = token;
|
|
3842
3842
|
switch (type) {
|
|
3843
3843
|
case "space":
|
|
3844
3844
|
hasSpace = true;
|
|
@@ -3846,7 +3846,7 @@ var require_resolve_end = __commonJS((exports) => {
|
|
|
3846
3846
|
case "comment": {
|
|
3847
3847
|
if (reqSpace && !hasSpace)
|
|
3848
3848
|
onError(token, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
|
|
3849
|
-
const cb =
|
|
3849
|
+
const cb = source.substring(1) || " ";
|
|
3850
3850
|
if (!comment)
|
|
3851
3851
|
comment = cb;
|
|
3852
3852
|
else
|
|
@@ -3856,13 +3856,13 @@ var require_resolve_end = __commonJS((exports) => {
|
|
|
3856
3856
|
}
|
|
3857
3857
|
case "newline":
|
|
3858
3858
|
if (comment)
|
|
3859
|
-
sep +=
|
|
3859
|
+
sep += source;
|
|
3860
3860
|
hasSpace = true;
|
|
3861
3861
|
break;
|
|
3862
3862
|
default:
|
|
3863
3863
|
onError(token, "UNEXPECTED_TOKEN", `Unexpected ${type} at node end`);
|
|
3864
3864
|
}
|
|
3865
|
-
offset +=
|
|
3865
|
+
offset += source.length;
|
|
3866
3866
|
}
|
|
3867
3867
|
}
|
|
3868
3868
|
return { comment, offset };
|
|
@@ -4250,13 +4250,13 @@ var require_resolve_block_scalar = __commonJS((exports) => {
|
|
|
4250
4250
|
onError(props[0], "IMPOSSIBLE", "Block scalar header not found");
|
|
4251
4251
|
return null;
|
|
4252
4252
|
}
|
|
4253
|
-
const { source
|
|
4254
|
-
const mode =
|
|
4253
|
+
const { source } = props[0];
|
|
4254
|
+
const mode = source[0];
|
|
4255
4255
|
let indent = 0;
|
|
4256
4256
|
let chomp = "";
|
|
4257
4257
|
let error = -1;
|
|
4258
|
-
for (let i = 1;i <
|
|
4259
|
-
const ch =
|
|
4258
|
+
for (let i = 1;i < source.length; ++i) {
|
|
4259
|
+
const ch = source[i];
|
|
4260
4260
|
if (!chomp && (ch === "-" || ch === "+"))
|
|
4261
4261
|
chomp = ch;
|
|
4262
4262
|
else {
|
|
@@ -4268,10 +4268,10 @@ var require_resolve_block_scalar = __commonJS((exports) => {
|
|
|
4268
4268
|
}
|
|
4269
4269
|
}
|
|
4270
4270
|
if (error !== -1)
|
|
4271
|
-
onError(error, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${
|
|
4271
|
+
onError(error, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${source}`);
|
|
4272
4272
|
let hasSpace = false;
|
|
4273
4273
|
let comment = "";
|
|
4274
|
-
let length =
|
|
4274
|
+
let length = source.length;
|
|
4275
4275
|
for (let i = 1;i < props.length; ++i) {
|
|
4276
4276
|
const token = props[i];
|
|
4277
4277
|
switch (token.type) {
|
|
@@ -4303,8 +4303,8 @@ var require_resolve_block_scalar = __commonJS((exports) => {
|
|
|
4303
4303
|
}
|
|
4304
4304
|
return { mode, indent, chomp, comment, length };
|
|
4305
4305
|
}
|
|
4306
|
-
function splitLines(
|
|
4307
|
-
const split =
|
|
4306
|
+
function splitLines(source) {
|
|
4307
|
+
const split = source.split(/\n( *)/);
|
|
4308
4308
|
const first = split[0];
|
|
4309
4309
|
const m = first.match(/^( *)/);
|
|
4310
4310
|
const line0 = m?.[1] ? [m[1], first.slice(m[1].length)] : ["", first];
|
|
@@ -4321,22 +4321,22 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
4321
4321
|
var Scalar = require_Scalar();
|
|
4322
4322
|
var resolveEnd = require_resolve_end();
|
|
4323
4323
|
function resolveFlowScalar(scalar, strict, onError) {
|
|
4324
|
-
const { offset, type, source
|
|
4324
|
+
const { offset, type, source, end } = scalar;
|
|
4325
4325
|
let _type;
|
|
4326
4326
|
let value;
|
|
4327
4327
|
const _onError = (rel, code, msg) => onError(offset + rel, code, msg);
|
|
4328
4328
|
switch (type) {
|
|
4329
4329
|
case "scalar":
|
|
4330
4330
|
_type = Scalar.Scalar.PLAIN;
|
|
4331
|
-
value = plainValue(
|
|
4331
|
+
value = plainValue(source, _onError);
|
|
4332
4332
|
break;
|
|
4333
4333
|
case "single-quoted-scalar":
|
|
4334
4334
|
_type = Scalar.Scalar.QUOTE_SINGLE;
|
|
4335
|
-
value = singleQuotedValue(
|
|
4335
|
+
value = singleQuotedValue(source, _onError);
|
|
4336
4336
|
break;
|
|
4337
4337
|
case "double-quoted-scalar":
|
|
4338
4338
|
_type = Scalar.Scalar.QUOTE_DOUBLE;
|
|
4339
|
-
value = doubleQuotedValue(
|
|
4339
|
+
value = doubleQuotedValue(source, _onError);
|
|
4340
4340
|
break;
|
|
4341
4341
|
default:
|
|
4342
4342
|
onError(scalar, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${type}`);
|
|
@@ -4344,10 +4344,10 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
4344
4344
|
value: "",
|
|
4345
4345
|
type: null,
|
|
4346
4346
|
comment: "",
|
|
4347
|
-
range: [offset, offset +
|
|
4347
|
+
range: [offset, offset + source.length, offset + source.length]
|
|
4348
4348
|
};
|
|
4349
4349
|
}
|
|
4350
|
-
const valueEnd = offset +
|
|
4350
|
+
const valueEnd = offset + source.length;
|
|
4351
4351
|
const re = resolveEnd.resolveEnd(end, valueEnd, strict, onError);
|
|
4352
4352
|
return {
|
|
4353
4353
|
value,
|
|
@@ -4356,9 +4356,9 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
4356
4356
|
range: [offset, valueEnd, re.offset]
|
|
4357
4357
|
};
|
|
4358
4358
|
}
|
|
4359
|
-
function plainValue(
|
|
4359
|
+
function plainValue(source, onError) {
|
|
4360
4360
|
let badChar = "";
|
|
4361
|
-
switch (
|
|
4361
|
+
switch (source[0]) {
|
|
4362
4362
|
case "\t":
|
|
4363
4363
|
badChar = "a tab character";
|
|
4364
4364
|
break;
|
|
@@ -4370,25 +4370,25 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
4370
4370
|
break;
|
|
4371
4371
|
case "|":
|
|
4372
4372
|
case ">": {
|
|
4373
|
-
badChar = `block scalar indicator ${
|
|
4373
|
+
badChar = `block scalar indicator ${source[0]}`;
|
|
4374
4374
|
break;
|
|
4375
4375
|
}
|
|
4376
4376
|
case "@":
|
|
4377
4377
|
case "`": {
|
|
4378
|
-
badChar = `reserved character ${
|
|
4378
|
+
badChar = `reserved character ${source[0]}`;
|
|
4379
4379
|
break;
|
|
4380
4380
|
}
|
|
4381
4381
|
}
|
|
4382
4382
|
if (badChar)
|
|
4383
4383
|
onError(0, "BAD_SCALAR_START", `Plain value cannot start with ${badChar}`);
|
|
4384
|
-
return foldLines(
|
|
4384
|
+
return foldLines(source);
|
|
4385
4385
|
}
|
|
4386
|
-
function singleQuotedValue(
|
|
4387
|
-
if (
|
|
4388
|
-
onError(
|
|
4389
|
-
return foldLines(
|
|
4386
|
+
function singleQuotedValue(source, onError) {
|
|
4387
|
+
if (source[source.length - 1] !== "'" || source.length === 1)
|
|
4388
|
+
onError(source.length, "MISSING_CHAR", "Missing closing 'quote");
|
|
4389
|
+
return foldLines(source.slice(1, -1)).replace(/''/g, "'");
|
|
4390
4390
|
}
|
|
4391
|
-
function foldLines(
|
|
4391
|
+
function foldLines(source) {
|
|
4392
4392
|
let first, line;
|
|
4393
4393
|
try {
|
|
4394
4394
|
first = new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
@@ -4399,14 +4399,14 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
4399
4399
|
first = /(.*?)[ \t]*\r?\n/sy;
|
|
4400
4400
|
line = /[ \t]*(.*?)[ \t]*\r?\n/sy;
|
|
4401
4401
|
}
|
|
4402
|
-
let match = first.exec(
|
|
4402
|
+
let match = first.exec(source);
|
|
4403
4403
|
if (!match)
|
|
4404
|
-
return
|
|
4404
|
+
return source;
|
|
4405
4405
|
let res = match[1];
|
|
4406
4406
|
let sep = " ";
|
|
4407
4407
|
let pos = first.lastIndex;
|
|
4408
4408
|
line.lastIndex = pos;
|
|
4409
|
-
while (match = line.exec(
|
|
4409
|
+
while (match = line.exec(source)) {
|
|
4410
4410
|
if (match[1] === "") {
|
|
4411
4411
|
if (sep === `
|
|
4412
4412
|
`)
|
|
@@ -4422,68 +4422,68 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
4422
4422
|
}
|
|
4423
4423
|
const last = /[ \t]*(.*)/sy;
|
|
4424
4424
|
last.lastIndex = pos;
|
|
4425
|
-
match = last.exec(
|
|
4425
|
+
match = last.exec(source);
|
|
4426
4426
|
return res + sep + (match?.[1] ?? "");
|
|
4427
4427
|
}
|
|
4428
|
-
function doubleQuotedValue(
|
|
4428
|
+
function doubleQuotedValue(source, onError) {
|
|
4429
4429
|
let res = "";
|
|
4430
|
-
for (let i = 1;i <
|
|
4431
|
-
const ch =
|
|
4432
|
-
if (ch === "\r" &&
|
|
4430
|
+
for (let i = 1;i < source.length - 1; ++i) {
|
|
4431
|
+
const ch = source[i];
|
|
4432
|
+
if (ch === "\r" && source[i + 1] === `
|
|
4433
4433
|
`)
|
|
4434
4434
|
continue;
|
|
4435
4435
|
if (ch === `
|
|
4436
4436
|
`) {
|
|
4437
|
-
const { fold, offset } = foldNewline(
|
|
4437
|
+
const { fold, offset } = foldNewline(source, i);
|
|
4438
4438
|
res += fold;
|
|
4439
4439
|
i = offset;
|
|
4440
4440
|
} else if (ch === "\\") {
|
|
4441
|
-
let next =
|
|
4441
|
+
let next = source[++i];
|
|
4442
4442
|
const cc = escapeCodes[next];
|
|
4443
4443
|
if (cc)
|
|
4444
4444
|
res += cc;
|
|
4445
4445
|
else if (next === `
|
|
4446
4446
|
`) {
|
|
4447
|
-
next =
|
|
4447
|
+
next = source[i + 1];
|
|
4448
4448
|
while (next === " " || next === "\t")
|
|
4449
|
-
next =
|
|
4450
|
-
} else if (next === "\r" &&
|
|
4449
|
+
next = source[++i + 1];
|
|
4450
|
+
} else if (next === "\r" && source[i + 1] === `
|
|
4451
4451
|
`) {
|
|
4452
|
-
next =
|
|
4452
|
+
next = source[++i + 1];
|
|
4453
4453
|
while (next === " " || next === "\t")
|
|
4454
|
-
next =
|
|
4454
|
+
next = source[++i + 1];
|
|
4455
4455
|
} else if (next === "x" || next === "u" || next === "U") {
|
|
4456
4456
|
const length = { x: 2, u: 4, U: 8 }[next];
|
|
4457
|
-
res += parseCharCode(
|
|
4457
|
+
res += parseCharCode(source, i + 1, length, onError);
|
|
4458
4458
|
i += length;
|
|
4459
4459
|
} else {
|
|
4460
|
-
const raw =
|
|
4460
|
+
const raw = source.substr(i - 1, 2);
|
|
4461
4461
|
onError(i - 1, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw}`);
|
|
4462
4462
|
res += raw;
|
|
4463
4463
|
}
|
|
4464
4464
|
} else if (ch === " " || ch === "\t") {
|
|
4465
4465
|
const wsStart = i;
|
|
4466
|
-
let next =
|
|
4466
|
+
let next = source[i + 1];
|
|
4467
4467
|
while (next === " " || next === "\t")
|
|
4468
|
-
next =
|
|
4468
|
+
next = source[++i + 1];
|
|
4469
4469
|
if (next !== `
|
|
4470
|
-
` && !(next === "\r" &&
|
|
4470
|
+
` && !(next === "\r" && source[i + 2] === `
|
|
4471
4471
|
`))
|
|
4472
|
-
res += i > wsStart ?
|
|
4472
|
+
res += i > wsStart ? source.slice(wsStart, i + 1) : ch;
|
|
4473
4473
|
} else {
|
|
4474
4474
|
res += ch;
|
|
4475
4475
|
}
|
|
4476
4476
|
}
|
|
4477
|
-
if (
|
|
4478
|
-
onError(
|
|
4477
|
+
if (source[source.length - 1] !== '"' || source.length === 1)
|
|
4478
|
+
onError(source.length, "MISSING_CHAR", 'Missing closing "quote');
|
|
4479
4479
|
return res;
|
|
4480
4480
|
}
|
|
4481
|
-
function foldNewline(
|
|
4481
|
+
function foldNewline(source, offset) {
|
|
4482
4482
|
let fold = "";
|
|
4483
|
-
let ch =
|
|
4483
|
+
let ch = source[offset + 1];
|
|
4484
4484
|
while (ch === " " || ch === "\t" || ch === `
|
|
4485
4485
|
` || ch === "\r") {
|
|
4486
|
-
if (ch === "\r" &&
|
|
4486
|
+
if (ch === "\r" && source[offset + 2] !== `
|
|
4487
4487
|
`)
|
|
4488
4488
|
break;
|
|
4489
4489
|
if (ch === `
|
|
@@ -4491,7 +4491,7 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
4491
4491
|
fold += `
|
|
4492
4492
|
`;
|
|
4493
4493
|
offset += 1;
|
|
4494
|
-
ch =
|
|
4494
|
+
ch = source[offset + 1];
|
|
4495
4495
|
}
|
|
4496
4496
|
if (!fold)
|
|
4497
4497
|
fold = " ";
|
|
@@ -4518,12 +4518,12 @@ var require_resolve_flow_scalar = __commonJS((exports) => {
|
|
|
4518
4518
|
"\\": "\\",
|
|
4519
4519
|
"\t": "\t"
|
|
4520
4520
|
};
|
|
4521
|
-
function parseCharCode(
|
|
4522
|
-
const cc =
|
|
4521
|
+
function parseCharCode(source, offset, length, onError) {
|
|
4522
|
+
const cc = source.substr(offset, length);
|
|
4523
4523
|
const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
|
|
4524
4524
|
const code = ok ? parseInt(cc, 16) : NaN;
|
|
4525
4525
|
if (isNaN(code)) {
|
|
4526
|
-
const raw =
|
|
4526
|
+
const raw = source.substr(offset - 2, length + 2);
|
|
4527
4527
|
onError(offset - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${raw}`);
|
|
4528
4528
|
return raw;
|
|
4529
4529
|
}
|
|
@@ -4718,13 +4718,13 @@ var require_compose_node = __commonJS((exports) => {
|
|
|
4718
4718
|
}
|
|
4719
4719
|
return node2;
|
|
4720
4720
|
}
|
|
4721
|
-
function composeAlias({ options }, { offset, source
|
|
4722
|
-
const alias = new Alias.Alias(
|
|
4721
|
+
function composeAlias({ options }, { offset, source, end }, onError) {
|
|
4722
|
+
const alias = new Alias.Alias(source.substring(1));
|
|
4723
4723
|
if (alias.source === "")
|
|
4724
4724
|
onError(offset, "BAD_ALIAS", "Alias cannot be an empty string");
|
|
4725
4725
|
if (alias.source.endsWith(":"))
|
|
4726
|
-
onError(offset +
|
|
4727
|
-
const valueEnd = offset +
|
|
4726
|
+
onError(offset + source.length - 1, "BAD_ALIAS", "Alias ending in : is ambiguous", true);
|
|
4727
|
+
const valueEnd = offset + source.length;
|
|
4728
4728
|
const re = resolveEnd.resolveEnd(end, valueEnd, options.strict, onError);
|
|
4729
4729
|
alias.range = [offset, valueEnd, re.offset];
|
|
4730
4730
|
if (re.comment)
|
|
@@ -4789,21 +4789,21 @@ var require_composer = __commonJS((exports) => {
|
|
|
4789
4789
|
return [src, src + 1];
|
|
4790
4790
|
if (Array.isArray(src))
|
|
4791
4791
|
return src.length === 2 ? src : [src[0], src[1]];
|
|
4792
|
-
const { offset, source
|
|
4793
|
-
return [offset, offset + (typeof
|
|
4792
|
+
const { offset, source } = src;
|
|
4793
|
+
return [offset, offset + (typeof source === "string" ? source.length : 1)];
|
|
4794
4794
|
}
|
|
4795
4795
|
function parsePrelude(prelude) {
|
|
4796
4796
|
let comment = "";
|
|
4797
4797
|
let atComment = false;
|
|
4798
4798
|
let afterEmptyLine = false;
|
|
4799
4799
|
for (let i = 0;i < prelude.length; ++i) {
|
|
4800
|
-
const
|
|
4801
|
-
switch (
|
|
4800
|
+
const source = prelude[i];
|
|
4801
|
+
switch (source[0]) {
|
|
4802
4802
|
case "#":
|
|
4803
4803
|
comment += (comment === "" ? "" : afterEmptyLine ? `
|
|
4804
4804
|
|
|
4805
4805
|
` : `
|
|
4806
|
-
`) + (
|
|
4806
|
+
`) + (source.substring(1) || " ");
|
|
4807
4807
|
atComment = true;
|
|
4808
4808
|
afterEmptyLine = false;
|
|
4809
4809
|
break;
|
|
@@ -4828,8 +4828,8 @@ var require_composer = __commonJS((exports) => {
|
|
|
4828
4828
|
this.prelude = [];
|
|
4829
4829
|
this.errors = [];
|
|
4830
4830
|
this.warnings = [];
|
|
4831
|
-
this.onError = (
|
|
4832
|
-
const pos = getErrorPos(
|
|
4831
|
+
this.onError = (source, code, message, warning) => {
|
|
4832
|
+
const pos = getErrorPos(source);
|
|
4833
4833
|
if (warning)
|
|
4834
4834
|
this.warnings.push(new errors2.YAMLWarning(pos, code, message));
|
|
4835
4835
|
else
|
|
@@ -4992,7 +4992,7 @@ var require_cst_scalar = __commonJS((exports) => {
|
|
|
4992
4992
|
}
|
|
4993
4993
|
function createScalarToken(value, context) {
|
|
4994
4994
|
const { implicitKey = false, indent, inFlow = false, offset = -1, type = "PLAIN" } = context;
|
|
4995
|
-
const
|
|
4995
|
+
const source = stringifyString.stringifyString({ type, value }, {
|
|
4996
4996
|
implicitKey,
|
|
4997
4997
|
indent: indent > 0 ? " ".repeat(indent) : "",
|
|
4998
4998
|
inFlow,
|
|
@@ -5002,13 +5002,13 @@ var require_cst_scalar = __commonJS((exports) => {
|
|
|
5002
5002
|
{ type: "newline", offset: -1, indent, source: `
|
|
5003
5003
|
` }
|
|
5004
5004
|
];
|
|
5005
|
-
switch (
|
|
5005
|
+
switch (source[0]) {
|
|
5006
5006
|
case "|":
|
|
5007
5007
|
case ">": {
|
|
5008
|
-
const he =
|
|
5008
|
+
const he = source.indexOf(`
|
|
5009
5009
|
`);
|
|
5010
|
-
const head =
|
|
5011
|
-
const body =
|
|
5010
|
+
const head = source.substring(0, he);
|
|
5011
|
+
const body = source.substring(he + 1) + `
|
|
5012
5012
|
`;
|
|
5013
5013
|
const props = [
|
|
5014
5014
|
{ type: "block-scalar-header", offset, indent, source: head }
|
|
@@ -5019,11 +5019,11 @@ var require_cst_scalar = __commonJS((exports) => {
|
|
|
5019
5019
|
return { type: "block-scalar", offset, indent, props, source: body };
|
|
5020
5020
|
}
|
|
5021
5021
|
case '"':
|
|
5022
|
-
return { type: "double-quoted-scalar", offset, indent, source
|
|
5022
|
+
return { type: "double-quoted-scalar", offset, indent, source, end };
|
|
5023
5023
|
case "'":
|
|
5024
|
-
return { type: "single-quoted-scalar", offset, indent, source
|
|
5024
|
+
return { type: "single-quoted-scalar", offset, indent, source, end };
|
|
5025
5025
|
default:
|
|
5026
|
-
return { type: "scalar", offset, indent, source
|
|
5026
|
+
return { type: "scalar", offset, indent, source, end };
|
|
5027
5027
|
}
|
|
5028
5028
|
}
|
|
5029
5029
|
function setScalarValue(token, value, context = {}) {
|
|
@@ -5049,32 +5049,32 @@ var require_cst_scalar = __commonJS((exports) => {
|
|
|
5049
5049
|
default:
|
|
5050
5050
|
type = "PLAIN";
|
|
5051
5051
|
}
|
|
5052
|
-
const
|
|
5052
|
+
const source = stringifyString.stringifyString({ type, value }, {
|
|
5053
5053
|
implicitKey: implicitKey || indent === null,
|
|
5054
5054
|
indent: indent !== null && indent > 0 ? " ".repeat(indent) : "",
|
|
5055
5055
|
inFlow,
|
|
5056
5056
|
options: { blockQuote: true, lineWidth: -1 }
|
|
5057
5057
|
});
|
|
5058
|
-
switch (
|
|
5058
|
+
switch (source[0]) {
|
|
5059
5059
|
case "|":
|
|
5060
5060
|
case ">":
|
|
5061
|
-
setBlockScalarValue(token,
|
|
5061
|
+
setBlockScalarValue(token, source);
|
|
5062
5062
|
break;
|
|
5063
5063
|
case '"':
|
|
5064
|
-
setFlowScalarValue(token,
|
|
5064
|
+
setFlowScalarValue(token, source, "double-quoted-scalar");
|
|
5065
5065
|
break;
|
|
5066
5066
|
case "'":
|
|
5067
|
-
setFlowScalarValue(token,
|
|
5067
|
+
setFlowScalarValue(token, source, "single-quoted-scalar");
|
|
5068
5068
|
break;
|
|
5069
5069
|
default:
|
|
5070
|
-
setFlowScalarValue(token,
|
|
5070
|
+
setFlowScalarValue(token, source, "scalar");
|
|
5071
5071
|
}
|
|
5072
5072
|
}
|
|
5073
|
-
function setBlockScalarValue(token,
|
|
5074
|
-
const he =
|
|
5073
|
+
function setBlockScalarValue(token, source) {
|
|
5074
|
+
const he = source.indexOf(`
|
|
5075
5075
|
`);
|
|
5076
|
-
const head =
|
|
5077
|
-
const body =
|
|
5076
|
+
const head = source.substring(0, he);
|
|
5077
|
+
const body = source.substring(he + 1) + `
|
|
5078
5078
|
`;
|
|
5079
5079
|
if (token.type === "block-scalar") {
|
|
5080
5080
|
const header = token.props[0];
|
|
@@ -5111,32 +5111,32 @@ var require_cst_scalar = __commonJS((exports) => {
|
|
|
5111
5111
|
}
|
|
5112
5112
|
return false;
|
|
5113
5113
|
}
|
|
5114
|
-
function setFlowScalarValue(token,
|
|
5114
|
+
function setFlowScalarValue(token, source, type) {
|
|
5115
5115
|
switch (token.type) {
|
|
5116
5116
|
case "scalar":
|
|
5117
5117
|
case "double-quoted-scalar":
|
|
5118
5118
|
case "single-quoted-scalar":
|
|
5119
5119
|
token.type = type;
|
|
5120
|
-
token.source =
|
|
5120
|
+
token.source = source;
|
|
5121
5121
|
break;
|
|
5122
5122
|
case "block-scalar": {
|
|
5123
5123
|
const end = token.props.slice(1);
|
|
5124
|
-
let oa =
|
|
5124
|
+
let oa = source.length;
|
|
5125
5125
|
if (token.props[0].type === "block-scalar-header")
|
|
5126
5126
|
oa -= token.props[0].source.length;
|
|
5127
5127
|
for (const tok of end)
|
|
5128
5128
|
tok.offset += oa;
|
|
5129
5129
|
delete token.props;
|
|
5130
|
-
Object.assign(token, { type, source
|
|
5130
|
+
Object.assign(token, { type, source, end });
|
|
5131
5131
|
break;
|
|
5132
5132
|
}
|
|
5133
5133
|
case "block-map":
|
|
5134
5134
|
case "block-seq": {
|
|
5135
|
-
const offset = token.offset +
|
|
5135
|
+
const offset = token.offset + source.length;
|
|
5136
5136
|
const nl = { type: "newline", offset, indent: token.indent, source: `
|
|
5137
5137
|
` };
|
|
5138
5138
|
delete token.items;
|
|
5139
|
-
Object.assign(token, { type, source
|
|
5139
|
+
Object.assign(token, { type, source, end: [nl] });
|
|
5140
5140
|
break;
|
|
5141
5141
|
}
|
|
5142
5142
|
default: {
|
|
@@ -5145,7 +5145,7 @@ var require_cst_scalar = __commonJS((exports) => {
|
|
|
5145
5145
|
for (const key of Object.keys(token))
|
|
5146
5146
|
if (key !== "type" && key !== "offset")
|
|
5147
5147
|
delete token[key];
|
|
5148
|
-
Object.assign(token, { type, indent, source
|
|
5148
|
+
Object.assign(token, { type, indent, source, end });
|
|
5149
5149
|
}
|
|
5150
5150
|
}
|
|
5151
5151
|
}
|
|
@@ -5296,8 +5296,8 @@ var require_cst = __commonJS((exports) => {
|
|
|
5296
5296
|
return JSON.stringify(token);
|
|
5297
5297
|
}
|
|
5298
5298
|
}
|
|
5299
|
-
function tokenType(
|
|
5300
|
-
switch (
|
|
5299
|
+
function tokenType(source) {
|
|
5300
|
+
switch (source) {
|
|
5301
5301
|
case BOM:
|
|
5302
5302
|
return "byte-order-mark";
|
|
5303
5303
|
case DOCUMENT:
|
|
@@ -5333,7 +5333,7 @@ var require_cst = __commonJS((exports) => {
|
|
|
5333
5333
|
case ",":
|
|
5334
5334
|
return "comma";
|
|
5335
5335
|
}
|
|
5336
|
-
switch (
|
|
5336
|
+
switch (source[0]) {
|
|
5337
5337
|
case " ":
|
|
5338
5338
|
case "\t":
|
|
5339
5339
|
return "space";
|
|
@@ -5409,11 +5409,11 @@ var require_lexer = __commonJS((exports) => {
|
|
|
5409
5409
|
this.next = null;
|
|
5410
5410
|
this.pos = 0;
|
|
5411
5411
|
}
|
|
5412
|
-
*lex(
|
|
5413
|
-
if (
|
|
5414
|
-
if (typeof
|
|
5412
|
+
*lex(source, incomplete = false) {
|
|
5413
|
+
if (source) {
|
|
5414
|
+
if (typeof source !== "string")
|
|
5415
5415
|
throw TypeError("source is not a string");
|
|
5416
|
-
this.buffer = this.buffer ? this.buffer +
|
|
5416
|
+
this.buffer = this.buffer ? this.buffer + source : source;
|
|
5417
5417
|
this.lineEndPos = null;
|
|
5418
5418
|
}
|
|
5419
5419
|
this.atEnd = !incomplete;
|
|
@@ -6087,29 +6087,29 @@ var require_parser = __commonJS((exports) => {
|
|
|
6087
6087
|
this.lexer = new lexer.Lexer;
|
|
6088
6088
|
this.onNewLine = onNewLine;
|
|
6089
6089
|
}
|
|
6090
|
-
*parse(
|
|
6090
|
+
*parse(source, incomplete = false) {
|
|
6091
6091
|
if (this.onNewLine && this.offset === 0)
|
|
6092
6092
|
this.onNewLine(0);
|
|
6093
|
-
for (const lexeme of this.lexer.lex(
|
|
6093
|
+
for (const lexeme of this.lexer.lex(source, incomplete))
|
|
6094
6094
|
yield* this.next(lexeme);
|
|
6095
6095
|
if (!incomplete)
|
|
6096
6096
|
yield* this.end();
|
|
6097
6097
|
}
|
|
6098
|
-
*next(
|
|
6099
|
-
this.source =
|
|
6098
|
+
*next(source) {
|
|
6099
|
+
this.source = source;
|
|
6100
6100
|
if (node_process.env.LOG_TOKENS)
|
|
6101
|
-
console.log("|", cst.prettyToken(
|
|
6101
|
+
console.log("|", cst.prettyToken(source));
|
|
6102
6102
|
if (this.atScalar) {
|
|
6103
6103
|
this.atScalar = false;
|
|
6104
6104
|
yield* this.step();
|
|
6105
|
-
this.offset +=
|
|
6105
|
+
this.offset += source.length;
|
|
6106
6106
|
return;
|
|
6107
6107
|
}
|
|
6108
|
-
const type = cst.tokenType(
|
|
6108
|
+
const type = cst.tokenType(source);
|
|
6109
6109
|
if (!type) {
|
|
6110
|
-
const message = `Not a YAML token: ${
|
|
6111
|
-
yield* this.pop({ type: "error", offset: this.offset, message, source
|
|
6112
|
-
this.offset +=
|
|
6110
|
+
const message = `Not a YAML token: ${source}`;
|
|
6111
|
+
yield* this.pop({ type: "error", offset: this.offset, message, source });
|
|
6112
|
+
this.offset += source.length;
|
|
6113
6113
|
} else if (type === "scalar") {
|
|
6114
6114
|
this.atNewLine = false;
|
|
6115
6115
|
this.atScalar = true;
|
|
@@ -6122,17 +6122,17 @@ var require_parser = __commonJS((exports) => {
|
|
|
6122
6122
|
this.atNewLine = true;
|
|
6123
6123
|
this.indent = 0;
|
|
6124
6124
|
if (this.onNewLine)
|
|
6125
|
-
this.onNewLine(this.offset +
|
|
6125
|
+
this.onNewLine(this.offset + source.length);
|
|
6126
6126
|
break;
|
|
6127
6127
|
case "space":
|
|
6128
|
-
if (this.atNewLine &&
|
|
6129
|
-
this.indent +=
|
|
6128
|
+
if (this.atNewLine && source[0] === " ")
|
|
6129
|
+
this.indent += source.length;
|
|
6130
6130
|
break;
|
|
6131
6131
|
case "explicit-key-ind":
|
|
6132
6132
|
case "map-value-ind":
|
|
6133
6133
|
case "seq-item-ind":
|
|
6134
6134
|
if (this.atNewLine)
|
|
6135
|
-
this.indent +=
|
|
6135
|
+
this.indent += source.length;
|
|
6136
6136
|
break;
|
|
6137
6137
|
case "doc-mode":
|
|
6138
6138
|
case "flow-error-end":
|
|
@@ -6140,7 +6140,7 @@ var require_parser = __commonJS((exports) => {
|
|
|
6140
6140
|
default:
|
|
6141
6141
|
this.atNewLine = false;
|
|
6142
6142
|
}
|
|
6143
|
-
this.offset +=
|
|
6143
|
+
this.offset += source.length;
|
|
6144
6144
|
}
|
|
6145
6145
|
}
|
|
6146
6146
|
*end() {
|
|
@@ -6849,26 +6849,26 @@ var require_public_api = __commonJS((exports) => {
|
|
|
6849
6849
|
const lineCounter$1 = options.lineCounter || prettyErrors && new lineCounter.LineCounter || null;
|
|
6850
6850
|
return { lineCounter: lineCounter$1, prettyErrors };
|
|
6851
6851
|
}
|
|
6852
|
-
function parseAllDocuments(
|
|
6852
|
+
function parseAllDocuments(source, options = {}) {
|
|
6853
6853
|
const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
|
|
6854
6854
|
const parser$1 = new parser.Parser(lineCounter2?.addNewLine);
|
|
6855
6855
|
const composer$1 = new composer.Composer(options);
|
|
6856
|
-
const docs = Array.from(composer$1.compose(parser$1.parse(
|
|
6856
|
+
const docs = Array.from(composer$1.compose(parser$1.parse(source)));
|
|
6857
6857
|
if (prettyErrors && lineCounter2)
|
|
6858
6858
|
for (const doc of docs) {
|
|
6859
|
-
doc.errors.forEach(errors2.prettifyError(
|
|
6860
|
-
doc.warnings.forEach(errors2.prettifyError(
|
|
6859
|
+
doc.errors.forEach(errors2.prettifyError(source, lineCounter2));
|
|
6860
|
+
doc.warnings.forEach(errors2.prettifyError(source, lineCounter2));
|
|
6861
6861
|
}
|
|
6862
6862
|
if (docs.length > 0)
|
|
6863
6863
|
return docs;
|
|
6864
6864
|
return Object.assign([], { empty: true }, composer$1.streamInfo());
|
|
6865
6865
|
}
|
|
6866
|
-
function parseDocument(
|
|
6866
|
+
function parseDocument(source, options = {}) {
|
|
6867
6867
|
const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
|
|
6868
6868
|
const parser$1 = new parser.Parser(lineCounter2?.addNewLine);
|
|
6869
6869
|
const composer$1 = new composer.Composer(options);
|
|
6870
6870
|
let doc = null;
|
|
6871
|
-
for (const _doc of composer$1.compose(parser$1.parse(
|
|
6871
|
+
for (const _doc of composer$1.compose(parser$1.parse(source), true, source.length)) {
|
|
6872
6872
|
if (!doc)
|
|
6873
6873
|
doc = _doc;
|
|
6874
6874
|
else if (doc.options.logLevel !== "silent") {
|
|
@@ -6877,8 +6877,8 @@ var require_public_api = __commonJS((exports) => {
|
|
|
6877
6877
|
}
|
|
6878
6878
|
}
|
|
6879
6879
|
if (prettyErrors && lineCounter2) {
|
|
6880
|
-
doc.errors.forEach(errors2.prettifyError(
|
|
6881
|
-
doc.warnings.forEach(errors2.prettifyError(
|
|
6880
|
+
doc.errors.forEach(errors2.prettifyError(source, lineCounter2));
|
|
6881
|
+
doc.warnings.forEach(errors2.prettifyError(source, lineCounter2));
|
|
6882
6882
|
}
|
|
6883
6883
|
return doc;
|
|
6884
6884
|
}
|
|
@@ -7699,8 +7699,8 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
7699
7699
|
if (chars.length < 1) {
|
|
7700
7700
|
return;
|
|
7701
7701
|
}
|
|
7702
|
-
const
|
|
7703
|
-
return `${
|
|
7702
|
+
const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
|
|
7703
|
+
return `${source}*`;
|
|
7704
7704
|
};
|
|
7705
7705
|
var repeatedExtglobRecursion = (pattern) => {
|
|
7706
7706
|
let depth = 0;
|
|
@@ -8486,19 +8486,19 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
8486
8486
|
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
8487
8487
|
if (!match)
|
|
8488
8488
|
return;
|
|
8489
|
-
const
|
|
8490
|
-
if (!
|
|
8489
|
+
const source2 = create(match[1]);
|
|
8490
|
+
if (!source2)
|
|
8491
8491
|
return;
|
|
8492
|
-
return
|
|
8492
|
+
return source2 + DOT_LITERAL + match[2];
|
|
8493
8493
|
}
|
|
8494
8494
|
}
|
|
8495
8495
|
};
|
|
8496
8496
|
const output = utils.removePrefix(input, state);
|
|
8497
|
-
let
|
|
8498
|
-
if (
|
|
8499
|
-
|
|
8497
|
+
let source = create(output);
|
|
8498
|
+
if (source && opts.strictSlashes !== true) {
|
|
8499
|
+
source += `${SLASH_LITERAL}?`;
|
|
8500
8500
|
}
|
|
8501
|
-
return
|
|
8501
|
+
return source;
|
|
8502
8502
|
};
|
|
8503
8503
|
module.exports = parse;
|
|
8504
8504
|
});
|
|
@@ -8606,11 +8606,11 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
8606
8606
|
const opts = options || {};
|
|
8607
8607
|
const prepend = opts.contains ? "" : "^";
|
|
8608
8608
|
const append = opts.contains ? "" : "$";
|
|
8609
|
-
let
|
|
8609
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
8610
8610
|
if (state && state.negated === true) {
|
|
8611
|
-
|
|
8611
|
+
source = `^(?!${source}).*$`;
|
|
8612
8612
|
}
|
|
8613
|
-
const regex = picomatch.toRegex(
|
|
8613
|
+
const regex = picomatch.toRegex(source, options);
|
|
8614
8614
|
if (returnState === true) {
|
|
8615
8615
|
regex.state = state;
|
|
8616
8616
|
}
|
|
@@ -8629,10 +8629,10 @@ var require_picomatch = __commonJS((exports, module) => {
|
|
|
8629
8629
|
}
|
|
8630
8630
|
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
8631
8631
|
};
|
|
8632
|
-
picomatch.toRegex = (
|
|
8632
|
+
picomatch.toRegex = (source, options) => {
|
|
8633
8633
|
try {
|
|
8634
8634
|
const opts = options || {};
|
|
8635
|
-
return new RegExp(
|
|
8635
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
8636
8636
|
} catch (err) {
|
|
8637
8637
|
if (options && options.debug === true)
|
|
8638
8638
|
throw err;
|
|
@@ -8819,210 +8819,6 @@ function extractAllRefs(data) {
|
|
|
8819
8819
|
visit(data, "");
|
|
8820
8820
|
return results;
|
|
8821
8821
|
}
|
|
8822
|
-
// src/types/serverConfig.ts
|
|
8823
|
-
var DEFAULT_SERVER_CONFIG = {
|
|
8824
|
-
server: {
|
|
8825
|
-
port: 5100,
|
|
8826
|
-
host: "::"
|
|
8827
|
-
},
|
|
8828
|
-
git_hosts: [],
|
|
8829
|
-
daemon_scheduler: {
|
|
8830
|
-
enabled: true,
|
|
8831
|
-
host: "localhost",
|
|
8832
|
-
port: 5110,
|
|
8833
|
-
workspace: "./data/daemon-workspace",
|
|
8834
|
-
max_daemons: 20
|
|
8835
|
-
},
|
|
8836
|
-
doc_db: {
|
|
8837
|
-
provider: "sqlite",
|
|
8838
|
-
sqlite: {
|
|
8839
|
-
path: "./data/c4a.db"
|
|
8840
|
-
},
|
|
8841
|
-
mongodb: {
|
|
8842
|
-
uri: "mongodb://localhost:27017/c4a?directConnection=true",
|
|
8843
|
-
database: "c4a"
|
|
8844
|
-
}
|
|
8845
|
-
},
|
|
8846
|
-
graph_db: {
|
|
8847
|
-
provider: "neo4j",
|
|
8848
|
-
neo4j: {
|
|
8849
|
-
uri: "bolt://localhost:7687",
|
|
8850
|
-
username: "neo4j",
|
|
8851
|
-
password: ""
|
|
8852
|
-
},
|
|
8853
|
-
nebulagraph: {
|
|
8854
|
-
uri: "localhost:9669",
|
|
8855
|
-
username: "root",
|
|
8856
|
-
password: "nebula",
|
|
8857
|
-
space: "c4a"
|
|
8858
|
-
},
|
|
8859
|
-
duckdb: {
|
|
8860
|
-
path: "./data/c4a-graph.duckdb"
|
|
8861
|
-
}
|
|
8862
|
-
},
|
|
8863
|
-
vector_db: {
|
|
8864
|
-
provider: "lancedb",
|
|
8865
|
-
collection_prefix: "c4a_",
|
|
8866
|
-
qdrant: {
|
|
8867
|
-
url: "http://localhost:6333",
|
|
8868
|
-
api_key: ""
|
|
8869
|
-
},
|
|
8870
|
-
milvus: {
|
|
8871
|
-
address: "localhost:19530"
|
|
8872
|
-
},
|
|
8873
|
-
lancedb: {
|
|
8874
|
-
path: "./data/lancedb"
|
|
8875
|
-
}
|
|
8876
|
-
},
|
|
8877
|
-
llm: {
|
|
8878
|
-
provider: "openai",
|
|
8879
|
-
openai: {
|
|
8880
|
-
api_key: "",
|
|
8881
|
-
base_url: "",
|
|
8882
|
-
default_model: "gpt-5.3-codex",
|
|
8883
|
-
wire_api: "chat"
|
|
8884
|
-
},
|
|
8885
|
-
anthropic: {
|
|
8886
|
-
api_key: "",
|
|
8887
|
-
base_url: "",
|
|
8888
|
-
default_model: "claude-opus-4-6"
|
|
8889
|
-
},
|
|
8890
|
-
google: {
|
|
8891
|
-
api_key: "",
|
|
8892
|
-
base_url: "",
|
|
8893
|
-
default_model: "gemini-3-pro-preview"
|
|
8894
|
-
}
|
|
8895
|
-
},
|
|
8896
|
-
task: {
|
|
8897
|
-
concurrency: {
|
|
8898
|
-
code_index: 2,
|
|
8899
|
-
doc_index: 2,
|
|
8900
|
-
remote_clone: 2,
|
|
8901
|
-
modeling: 1
|
|
8902
|
-
},
|
|
8903
|
-
default_timeout_ms: 150 * 60 * 1000,
|
|
8904
|
-
memory_ttl_ms: 48 * 60 * 60 * 1000,
|
|
8905
|
-
cleanup_interval_ms: 10 * 60 * 1000,
|
|
8906
|
-
log_max_entries: 500
|
|
8907
|
-
},
|
|
8908
|
-
indexing: {
|
|
8909
|
-
task_timeout_ms: 150 * 60 * 1000,
|
|
8910
|
-
file_timeout_ms: 15 * 60 * 1000
|
|
8911
|
-
},
|
|
8912
|
-
intent_router: {
|
|
8913
|
-
provider: "huggingface",
|
|
8914
|
-
huggingface: {
|
|
8915
|
-
model_id: "context4ai/intent-router-onnx",
|
|
8916
|
-
cache_dir: "./models/intent-router"
|
|
8917
|
-
},
|
|
8918
|
-
xenova: {
|
|
8919
|
-
model_id: "context4ai/intent-router-onnx",
|
|
8920
|
-
cache_dir: "./models/intent-router"
|
|
8921
|
-
}
|
|
8922
|
-
},
|
|
8923
|
-
embedding: {
|
|
8924
|
-
provider: "huggingface",
|
|
8925
|
-
huggingface: {
|
|
8926
|
-
model_id: "Xenova/all-MiniLM-L6-v2",
|
|
8927
|
-
dtype: "q8",
|
|
8928
|
-
cache_dir: "./models/embedding"
|
|
8929
|
-
},
|
|
8930
|
-
xenova: {
|
|
8931
|
-
model_id: "Xenova/bge-m3",
|
|
8932
|
-
dtype: "q8",
|
|
8933
|
-
cache_dir: "./models/embedding"
|
|
8934
|
-
},
|
|
8935
|
-
openai: {
|
|
8936
|
-
api_key: "",
|
|
8937
|
-
base_url: "",
|
|
8938
|
-
model_id: "text-embedding-3-small"
|
|
8939
|
-
},
|
|
8940
|
-
google: {
|
|
8941
|
-
api_key: "",
|
|
8942
|
-
model_id: "text-embedding-004"
|
|
8943
|
-
}
|
|
8944
|
-
},
|
|
8945
|
-
reranker: {
|
|
8946
|
-
enabled: false,
|
|
8947
|
-
provider: "huggingface",
|
|
8948
|
-
huggingface: {
|
|
8949
|
-
model_id: "onnx-community/bge-reranker-v2-m3-ONNX",
|
|
8950
|
-
dtype: "q8",
|
|
8951
|
-
cache_dir: "./models/reranker"
|
|
8952
|
-
},
|
|
8953
|
-
xenova: {
|
|
8954
|
-
model_id: "onnx-community/bge-reranker-v2-m3-ONNX",
|
|
8955
|
-
dtype: "q8",
|
|
8956
|
-
cache_dir: "./models/reranker"
|
|
8957
|
-
},
|
|
8958
|
-
max_rerank: 20
|
|
8959
|
-
}
|
|
8960
|
-
};
|
|
8961
|
-
// src/types/daemon.ts
|
|
8962
|
-
var CODE_PACKAGE_FILES = new Set([
|
|
8963
|
-
"package.json",
|
|
8964
|
-
"pyproject.toml",
|
|
8965
|
-
"setup.py",
|
|
8966
|
-
"go.mod",
|
|
8967
|
-
"cargo.toml",
|
|
8968
|
-
"pom.xml",
|
|
8969
|
-
"build.gradle",
|
|
8970
|
-
"build.gradle.kts"
|
|
8971
|
-
]);
|
|
8972
|
-
var NPM_NAME_RE = /^(@[a-z0-9\-~][a-z0-9\-._~]*\/)?[a-z0-9\-~][a-z0-9\-._~]*$/;
|
|
8973
|
-
var PYPI_NAME_RE = /^[a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?$/;
|
|
8974
|
-
var GO_MODULE_RE = /^[a-zA-Z0-9][a-zA-Z0-9._\-/]*$/;
|
|
8975
|
-
var CARGO_NAME_RE = /^[a-zA-Z][a-zA-Z0-9_-]*$/;
|
|
8976
|
-
var MAVEN_NAME_RE = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
|
|
8977
|
-
var extractName = (fileName, content) => {
|
|
8978
|
-
const lower = fileName.toLowerCase();
|
|
8979
|
-
try {
|
|
8980
|
-
if (lower === "package.json") {
|
|
8981
|
-
const parsed = JSON.parse(content);
|
|
8982
|
-
return typeof parsed.name === "string" ? parsed.name.trim() : null;
|
|
8983
|
-
}
|
|
8984
|
-
if (lower === "pyproject.toml" || lower === "cargo.toml") {
|
|
8985
|
-
const m = content.match(/^\s*name\s*=\s*["']([^"']+)["']/m);
|
|
8986
|
-
return m?.[1] ?? null;
|
|
8987
|
-
}
|
|
8988
|
-
if (lower === "go.mod") {
|
|
8989
|
-
const m = content.match(/^\s*module\s+([^\s]+)\s*$/m);
|
|
8990
|
-
return m?.[1] ?? null;
|
|
8991
|
-
}
|
|
8992
|
-
if (lower === "pom.xml") {
|
|
8993
|
-
const m = content.match(/<artifactId>([^<]+)<\/artifactId>/);
|
|
8994
|
-
return m?.[1]?.trim() ?? null;
|
|
8995
|
-
}
|
|
8996
|
-
if (lower === "build.gradle") {
|
|
8997
|
-
const m = content.match(/rootProject\.name\s*=\s*["']([^"']+)["']/);
|
|
8998
|
-
return m?.[1] ?? null;
|
|
8999
|
-
}
|
|
9000
|
-
} catch {
|
|
9001
|
-
return null;
|
|
9002
|
-
}
|
|
9003
|
-
return null;
|
|
9004
|
-
};
|
|
9005
|
-
var validateName = (fileName, name) => {
|
|
9006
|
-
const lower = fileName.toLowerCase();
|
|
9007
|
-
if (lower === "package.json")
|
|
9008
|
-
return NPM_NAME_RE.test(name);
|
|
9009
|
-
if (lower === "pyproject.toml" || lower === "setup.py")
|
|
9010
|
-
return PYPI_NAME_RE.test(name);
|
|
9011
|
-
if (lower === "go.mod")
|
|
9012
|
-
return GO_MODULE_RE.test(name);
|
|
9013
|
-
if (lower === "cargo.toml")
|
|
9014
|
-
return CARGO_NAME_RE.test(name);
|
|
9015
|
-
if (lower === "pom.xml" || lower === "build.gradle")
|
|
9016
|
-
return MAVEN_NAME_RE.test(name);
|
|
9017
|
-
return true;
|
|
9018
|
-
};
|
|
9019
|
-
var isValidManifest = (filePath, content) => {
|
|
9020
|
-
const fileName = filePath.split("/").pop() ?? "";
|
|
9021
|
-
const name = extractName(fileName, content);
|
|
9022
|
-
if (!name)
|
|
9023
|
-
return true;
|
|
9024
|
-
return validateName(fileName, name);
|
|
9025
|
-
};
|
|
9026
8822
|
// ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/external.js
|
|
9027
8823
|
var exports_external = {};
|
|
9028
8824
|
__export(exports_external, {
|
|
@@ -13815,26 +13611,6 @@ function isIndexableFile(fileName, manifestFiles) {
|
|
|
13815
13611
|
const baseName = fileName.includes("/") ? fileName.split("/").pop() : fileName;
|
|
13816
13612
|
return defaultRegistry.resolve(baseName) !== null;
|
|
13817
13613
|
}
|
|
13818
|
-
// src/wsEvents.ts
|
|
13819
|
-
var WS_SESSION_STATUS = "ws:session:status";
|
|
13820
|
-
var WS_SESSION_PROGRESS = "ws:session:progress";
|
|
13821
|
-
var WS_DAEMON_HANDSHAKE = "ws:daemon:handshake";
|
|
13822
|
-
var WS_DAEMON_HANDSHAKE_ACK = "ws:daemon:handshake_ack";
|
|
13823
|
-
var WS_DAEMON_CONNECTED = "ws:daemon:connected";
|
|
13824
|
-
var WS_DAEMON_STATUS = "ws:daemon:status";
|
|
13825
|
-
var WS_DAEMON_HEARTBEAT = "ws:daemon:heartbeat";
|
|
13826
|
-
var WS_LIBRARY_UPDATED = "ws:library:updated";
|
|
13827
|
-
var WS_INDEX_PROGRESS = "index/progress";
|
|
13828
|
-
var WS_INDEX_DONE = "index/done";
|
|
13829
|
-
var WS_INDEX_ERROR = "index/error";
|
|
13830
|
-
var WS_INDEX_TIMEOUT = "index/timeout";
|
|
13831
|
-
var WS_TASK_QUEUED = "task/queued";
|
|
13832
|
-
var WS_TASK_STARTED = "task/started";
|
|
13833
|
-
var WS_TASK_PROGRESS = "task/progress";
|
|
13834
|
-
var WS_TASK_DONE = "task/done";
|
|
13835
|
-
var WS_TASK_FAILED = "task/failed";
|
|
13836
|
-
var WS_TASK_CANCELLED = "task/cancelled";
|
|
13837
|
-
var WS_TASK_QUEUE_UPDATE = "task/queue_update";
|
|
13838
13614
|
export {
|
|
13839
13615
|
visibilitySchema,
|
|
13840
13616
|
transitionAtomSchema,
|
|
@@ -13864,7 +13640,6 @@ export {
|
|
|
13864
13640
|
matchesPathFilter,
|
|
13865
13641
|
mapErrorCodeToStatus,
|
|
13866
13642
|
isVersionVisible,
|
|
13867
|
-
isValidManifest,
|
|
13868
13643
|
isRefPointer,
|
|
13869
13644
|
isPlainObject,
|
|
13870
13645
|
isPathSafe,
|
|
@@ -13907,25 +13682,6 @@ export {
|
|
|
13907
13682
|
boundaryAtomSchema,
|
|
13908
13683
|
behaviorAtomSchema,
|
|
13909
13684
|
attributeAtomSchema,
|
|
13910
|
-
WS_TASK_STARTED,
|
|
13911
|
-
WS_TASK_QUEUE_UPDATE,
|
|
13912
|
-
WS_TASK_QUEUED,
|
|
13913
|
-
WS_TASK_PROGRESS,
|
|
13914
|
-
WS_TASK_FAILED,
|
|
13915
|
-
WS_TASK_DONE,
|
|
13916
|
-
WS_TASK_CANCELLED,
|
|
13917
|
-
WS_SESSION_STATUS,
|
|
13918
|
-
WS_SESSION_PROGRESS,
|
|
13919
|
-
WS_LIBRARY_UPDATED,
|
|
13920
|
-
WS_INDEX_TIMEOUT,
|
|
13921
|
-
WS_INDEX_PROGRESS,
|
|
13922
|
-
WS_INDEX_ERROR,
|
|
13923
|
-
WS_INDEX_DONE,
|
|
13924
|
-
WS_DAEMON_STATUS,
|
|
13925
|
-
WS_DAEMON_HEARTBEAT,
|
|
13926
|
-
WS_DAEMON_HANDSHAKE_ACK,
|
|
13927
|
-
WS_DAEMON_HANDSHAKE,
|
|
13928
|
-
WS_DAEMON_CONNECTED,
|
|
13929
13685
|
Visibility,
|
|
13930
13686
|
UPLOAD_MAX_FILE_SIZE,
|
|
13931
13687
|
UPLOAD_MAX_FILES,
|
|
@@ -13953,14 +13709,12 @@ export {
|
|
|
13953
13709
|
EdgeType,
|
|
13954
13710
|
EdgeSource,
|
|
13955
13711
|
DEFAULT_WORKSPACE_NAME,
|
|
13956
|
-
DEFAULT_SERVER_CONFIG,
|
|
13957
13712
|
DEFAULT_PATH_FILTER,
|
|
13958
13713
|
DEFAULT_CONTENT_TYPE_DEFINITIONS,
|
|
13959
13714
|
DEFAULT_CLOUD_LIBRARY_NAME,
|
|
13960
13715
|
DAEMON_OFFLINE_THRESHOLD,
|
|
13961
13716
|
DAEMON_HEARTBEAT_INTERVAL,
|
|
13962
13717
|
ContentTypeRegistry,
|
|
13963
|
-
CODE_PACKAGE_FILES,
|
|
13964
13718
|
CODE_DIGEST_TYPE,
|
|
13965
13719
|
CLOUD_DAEMON_IDLE_TIMEOUT,
|
|
13966
13720
|
C4AError
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c4a/core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Shared
|
|
5
|
+
"description": "Shared extraction types, schemas, and utilities for Context",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
"utilities",
|
|
17
17
|
"knowledge-graph"
|
|
18
18
|
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=20"
|
|
21
|
+
},
|
|
19
22
|
"dependencies": {
|
|
20
23
|
"picomatch": "^4.0.4",
|
|
21
24
|
"yaml": "^2.4.5",
|