@savvy-web/silk 2.1.0 → 2.1.2
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/changesets-changelog.cjs +1536 -153
- package/changesets-changelog.d.cts +60 -6
- package/changesets-changelog.d.ts +60 -6
- package/changesets-changelog.js +1554 -155
- package/changesets-markdownlint.cjs +1536 -153
- package/changesets-markdownlint.d.cts +60 -6
- package/changesets-markdownlint.d.ts +60 -6
- package/changesets-markdownlint.js +1554 -155
- package/package.json +4 -4
- package/tsconfig/node/dist/tsconfig.tsbuildinfo +1 -1
package/changesets-changelog.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { builtinModules, createRequire } from "node:module";
|
|
2
|
-
import { Cache, Chunk, Context, Data, Duration, Effect, Exit, Layer, Option, Schema, Stream } from "effect";
|
|
2
|
+
import { Cache, Chunk, Context, Data, Duration, Effect, Exit, Function, Layer, Option, Schema, Stream } from "effect";
|
|
3
3
|
import { Command, CommandExecutor, FileSystem, Path } from "@effect/platform";
|
|
4
4
|
import * as path$1 from "node:path";
|
|
5
5
|
import { basename, delimiter, dirname, isAbsolute, join, normalize, relative, resolve } from "node:path";
|
|
@@ -372,7 +372,7 @@ const ChangesetConfigLive = Layer.effect(ChangesetConfig, Effect.gen(function* (
|
|
|
372
372
|
}));
|
|
373
373
|
|
|
374
374
|
//#endregion
|
|
375
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
375
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/errors/CatalogAssemblyError.js
|
|
376
376
|
/**
|
|
377
377
|
* Base constant for {@link CatalogAssemblyError}.
|
|
378
378
|
*
|
|
@@ -400,7 +400,7 @@ var CatalogAssemblyError = class extends CatalogAssemblyErrorBase {
|
|
|
400
400
|
};
|
|
401
401
|
|
|
402
402
|
//#endregion
|
|
403
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
403
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/errors/CatalogResolutionError.js
|
|
404
404
|
/**
|
|
405
405
|
* Base constant for {@link CatalogResolutionError}.
|
|
406
406
|
*
|
|
@@ -427,7 +427,7 @@ var CatalogResolutionError = class extends CatalogResolutionErrorBase {
|
|
|
427
427
|
};
|
|
428
428
|
|
|
429
429
|
//#endregion
|
|
430
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
430
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/errors/GitReadError.js
|
|
431
431
|
/**
|
|
432
432
|
* Base constant for {@link GitReadError}.
|
|
433
433
|
*
|
|
@@ -453,7 +453,7 @@ var GitReadError = class extends GitReadErrorBase {
|
|
|
453
453
|
};
|
|
454
454
|
|
|
455
455
|
//#endregion
|
|
456
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
456
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/errors/PackageNotFoundError.js
|
|
457
457
|
/**
|
|
458
458
|
* Base constant for {@link PackageNotFoundError}.
|
|
459
459
|
*
|
|
@@ -505,7 +505,7 @@ var PackageNotFoundError = class extends PackageNotFoundErrorBase {
|
|
|
505
505
|
};
|
|
506
506
|
|
|
507
507
|
//#endregion
|
|
508
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
508
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/errors/WorkspaceDiscoveryError.js
|
|
509
509
|
/**
|
|
510
510
|
* Base constant for {@link WorkspaceDiscoveryError}.
|
|
511
511
|
*
|
|
@@ -557,7 +557,7 @@ var WorkspaceDiscoveryError = class extends WorkspaceDiscoveryErrorBase {
|
|
|
557
557
|
};
|
|
558
558
|
|
|
559
559
|
//#endregion
|
|
560
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
560
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/errors/WorkspaceRootNotFoundError.js
|
|
561
561
|
/**
|
|
562
562
|
* Base constant for {@link WorkspaceRootNotFoundError}.
|
|
563
563
|
*
|
|
@@ -608,7 +608,7 @@ var WorkspaceRootNotFoundError = class extends WorkspaceRootNotFoundErrorBase {
|
|
|
608
608
|
};
|
|
609
609
|
|
|
610
610
|
//#endregion
|
|
611
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
611
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/services/WorkspaceDiscovery.js
|
|
612
612
|
/**
|
|
613
613
|
* Service for discovering workspace packages in a monorepo.
|
|
614
614
|
*
|
|
@@ -659,7 +659,7 @@ var WorkspaceRootNotFoundError = class extends WorkspaceRootNotFoundErrorBase {
|
|
|
659
659
|
var WorkspaceDiscovery = class extends Context.Tag("@spencerbeggs/workspaces-effect/WorkspaceDiscovery")() {};
|
|
660
660
|
|
|
661
661
|
//#endregion
|
|
662
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
662
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/services/WorkspaceRoot.js
|
|
663
663
|
/**
|
|
664
664
|
* Service for finding the workspace root directory.
|
|
665
665
|
*
|
|
@@ -707,7 +707,7 @@ var WorkspaceDiscovery = class extends Context.Tag("@spencerbeggs/workspaces-eff
|
|
|
707
707
|
var WorkspaceRoot = class extends Context.Tag("@spencerbeggs/workspaces-effect/WorkspaceRoot")() {};
|
|
708
708
|
|
|
709
709
|
//#endregion
|
|
710
|
-
//#region ../../node_modules/.pnpm/yaml-effect@0.7.
|
|
710
|
+
//#region ../../node_modules/.pnpm/yaml-effect@0.7.2_effect@3.21.4/node_modules/yaml-effect/errors/YamlComposerError.js
|
|
711
711
|
/**
|
|
712
712
|
* YAML composer error type.
|
|
713
713
|
*
|
|
@@ -766,7 +766,7 @@ var YamlComposerError = class extends YamlComposerErrorBase {
|
|
|
766
766
|
};
|
|
767
767
|
|
|
768
768
|
//#endregion
|
|
769
|
-
//#region ../../node_modules/.pnpm/yaml-effect@0.7.
|
|
769
|
+
//#region ../../node_modules/.pnpm/yaml-effect@0.7.2_effect@3.21.4/node_modules/yaml-effect/errors/YamlErrorDetail.js
|
|
770
770
|
/**
|
|
771
771
|
* YAML error detail schema and error code types.
|
|
772
772
|
*
|
|
@@ -820,7 +820,7 @@ var YamlErrorDetail = class extends Schema.Class("YamlErrorDetail")({
|
|
|
820
820
|
}) {};
|
|
821
821
|
|
|
822
822
|
//#endregion
|
|
823
|
-
//#region ../../node_modules/.pnpm/yaml-effect@0.7.
|
|
823
|
+
//#region ../../node_modules/.pnpm/yaml-effect@0.7.2_effect@3.21.4/node_modules/yaml-effect/schemas/CstNode.js
|
|
824
824
|
/**
|
|
825
825
|
* YAML CST node schema and node type literal union.
|
|
826
826
|
*
|
|
@@ -857,7 +857,7 @@ var CstNode = class CstNode extends Schema.Class("CstNode")({
|
|
|
857
857
|
}) {};
|
|
858
858
|
|
|
859
859
|
//#endregion
|
|
860
|
-
//#region ../../node_modules/.pnpm/yaml-effect@0.7.
|
|
860
|
+
//#region ../../node_modules/.pnpm/yaml-effect@0.7.2_effect@3.21.4/node_modules/yaml-effect/schemas/YamlShared.js
|
|
861
861
|
/**
|
|
862
862
|
* Shared YAML structural types used across the parse/stringify/format pipeline.
|
|
863
863
|
*
|
|
@@ -932,7 +932,7 @@ var YamlEdit = class extends Schema.Class("YamlEdit")({
|
|
|
932
932
|
}) {};
|
|
933
933
|
|
|
934
934
|
//#endregion
|
|
935
|
-
//#region ../../node_modules/.pnpm/yaml-effect@0.7.
|
|
935
|
+
//#region ../../node_modules/.pnpm/yaml-effect@0.7.2_effect@3.21.4/node_modules/yaml-effect/schemas/YamlAstNodes.js
|
|
936
936
|
/**
|
|
937
937
|
* Internal module defining all mutually-referential YAML AST node schemas in
|
|
938
938
|
* one place to avoid circular import cycles between individual schema files.
|
|
@@ -1144,7 +1144,7 @@ var YamlSeq = class extends Schema.TaggedClass()("YamlSeq", {
|
|
|
1144
1144
|
}) {};
|
|
1145
1145
|
|
|
1146
1146
|
//#endregion
|
|
1147
|
-
//#region ../../node_modules/.pnpm/yaml-effect@0.7.
|
|
1147
|
+
//#region ../../node_modules/.pnpm/yaml-effect@0.7.2_effect@3.21.4/node_modules/yaml-effect/schemas/YamlDocument.js
|
|
1148
1148
|
/**
|
|
1149
1149
|
* YAML document and directive schemas.
|
|
1150
1150
|
*
|
|
@@ -1223,7 +1223,7 @@ var YamlDocument = class extends Schema.Class("YamlDocument")({
|
|
|
1223
1223
|
}) {};
|
|
1224
1224
|
|
|
1225
1225
|
//#endregion
|
|
1226
|
-
//#region ../../node_modules/.pnpm/yaml-effect@0.7.
|
|
1226
|
+
//#region ../../node_modules/.pnpm/yaml-effect@0.7.2_effect@3.21.4/node_modules/yaml-effect/schemas/YamlToken.js
|
|
1227
1227
|
/**
|
|
1228
1228
|
* YAML token schema and token kind literal union.
|
|
1229
1229
|
*
|
|
@@ -1259,7 +1259,7 @@ var YamlToken = class extends Schema.Class("YamlToken")({
|
|
|
1259
1259
|
}) {};
|
|
1260
1260
|
|
|
1261
1261
|
//#endregion
|
|
1262
|
-
//#region ../../node_modules/.pnpm/yaml-effect@0.7.
|
|
1262
|
+
//#region ../../node_modules/.pnpm/yaml-effect@0.7.2_effect@3.21.4/node_modules/yaml-effect/utils/lexer.js
|
|
1263
1263
|
/**
|
|
1264
1264
|
* YAML 1.2 lexer — tokenizes raw YAML text into a stream of {@link YamlToken} values.
|
|
1265
1265
|
*
|
|
@@ -1289,7 +1289,7 @@ var YamlToken = class extends Schema.Class("YamlToken")({
|
|
|
1289
1289
|
*
|
|
1290
1290
|
* @public
|
|
1291
1291
|
*/
|
|
1292
|
-
function createScanner$
|
|
1292
|
+
function createScanner$2(text) {
|
|
1293
1293
|
let pos = 0;
|
|
1294
1294
|
let line = 0;
|
|
1295
1295
|
let col = 0;
|
|
@@ -2240,7 +2240,7 @@ function createScanner$1(text) {
|
|
|
2240
2240
|
* @public
|
|
2241
2241
|
*/
|
|
2242
2242
|
function lex(text) {
|
|
2243
|
-
return Stream.unfold(createScanner$
|
|
2243
|
+
return Stream.unfold(createScanner$2(text), (scanner) => {
|
|
2244
2244
|
const kind = scanner.scan();
|
|
2245
2245
|
if (kind === null) return Option.none();
|
|
2246
2246
|
const token = new YamlToken({
|
|
@@ -2265,7 +2265,7 @@ function lexAll(text) {
|
|
|
2265
2265
|
}
|
|
2266
2266
|
|
|
2267
2267
|
//#endregion
|
|
2268
|
-
//#region ../../node_modules/.pnpm/yaml-effect@0.7.
|
|
2268
|
+
//#region ../../node_modules/.pnpm/yaml-effect@0.7.2_effect@3.21.4/node_modules/yaml-effect/utils/parser.js
|
|
2269
2269
|
/**
|
|
2270
2270
|
* YAML 1.2 CST parser — transforms a token stream into a Concrete Syntax Tree.
|
|
2271
2271
|
*
|
|
@@ -2911,7 +2911,7 @@ function parseCSTAll(text) {
|
|
|
2911
2911
|
}
|
|
2912
2912
|
|
|
2913
2913
|
//#endregion
|
|
2914
|
-
//#region ../../node_modules/.pnpm/yaml-effect@0.7.
|
|
2914
|
+
//#region ../../node_modules/.pnpm/yaml-effect@0.7.2_effect@3.21.4/node_modules/yaml-effect/utils/composer.js
|
|
2915
2915
|
/**
|
|
2916
2916
|
* YAML 1.2 Composer — transforms CST nodes into AST nodes with typed values.
|
|
2917
2917
|
*
|
|
@@ -2920,16 +2920,29 @@ function parseCSTAll(text) {
|
|
|
2920
2920
|
*
|
|
2921
2921
|
* @packageDocumentation
|
|
2922
2922
|
*/
|
|
2923
|
+
let lineStartsText;
|
|
2924
|
+
let lineStartsCache = [];
|
|
2925
|
+
function getLineStarts(text) {
|
|
2926
|
+
if (lineStartsText === text) return lineStartsCache;
|
|
2927
|
+
const starts = [0];
|
|
2928
|
+
for (let i = 0; i < text.length; i++) if (text[i] === "\n") starts.push(i + 1);
|
|
2929
|
+
lineStartsText = text;
|
|
2930
|
+
lineStartsCache = starts;
|
|
2931
|
+
return starts;
|
|
2932
|
+
}
|
|
2923
2933
|
function lineCol(text, offset) {
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2934
|
+
const starts = getLineStarts(text);
|
|
2935
|
+
const pos = Math.min(Math.max(offset, 0), text.length);
|
|
2936
|
+
let lo = 0;
|
|
2937
|
+
let hi = starts.length - 1;
|
|
2938
|
+
while (lo < hi) {
|
|
2939
|
+
const mid = lo + hi + 1 >> 1;
|
|
2940
|
+
if (starts[mid] <= pos) lo = mid;
|
|
2941
|
+
else hi = mid - 1;
|
|
2942
|
+
}
|
|
2930
2943
|
return {
|
|
2931
|
-
line,
|
|
2932
|
-
column
|
|
2944
|
+
line: lo,
|
|
2945
|
+
column: pos - starts[lo]
|
|
2933
2946
|
};
|
|
2934
2947
|
}
|
|
2935
2948
|
const NULL_RE = /^(?:null|Null|NULL|~)$/;
|
|
@@ -6373,7 +6386,7 @@ function parseDocument(text, options) {
|
|
|
6373
6386
|
*
|
|
6374
6387
|
* @public
|
|
6375
6388
|
*/
|
|
6376
|
-
function parse$
|
|
6389
|
+
function parse$3(text, options) {
|
|
6377
6390
|
const uniqueKeys = options?.uniqueKeys ?? true;
|
|
6378
6391
|
return parseDocument(text, options).pipe(Effect.flatMap((doc) => {
|
|
6379
6392
|
if (uniqueKeys) {
|
|
@@ -6389,14 +6402,14 @@ function parse$2(text, options) {
|
|
|
6389
6402
|
}
|
|
6390
6403
|
|
|
6391
6404
|
//#endregion
|
|
6392
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
6405
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/layers/catalog/workspace-manifest.js
|
|
6393
6406
|
/**
|
|
6394
6407
|
* Parse a pnpm-workspace.yaml text into its catalog/config-dependency/packages
|
|
6395
6408
|
* slice. Pure with respect to the filesystem.
|
|
6396
6409
|
*
|
|
6397
6410
|
* @public
|
|
6398
6411
|
*/
|
|
6399
|
-
const workspaceManifestFromYaml = (content) => parse$
|
|
6412
|
+
const workspaceManifestFromYaml = (content) => parse$3(content).pipe(Effect.mapError((e) => new CatalogAssemblyError({
|
|
6400
6413
|
source: "manifest",
|
|
6401
6414
|
reason: `invalid yaml: ${String(e)}`
|
|
6402
6415
|
})), Effect.map((parsed) => {
|
|
@@ -6465,7 +6478,7 @@ function checkDefaultCatalogIsDefinedOnce(manifest) {
|
|
|
6465
6478
|
}
|
|
6466
6479
|
|
|
6467
6480
|
//#endregion
|
|
6468
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
6481
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/layers/catalog/assemble.js
|
|
6469
6482
|
/** Merge catalog sources; later sources win per dependency within a catalog. */
|
|
6470
6483
|
function mergeCatalogs(...sources) {
|
|
6471
6484
|
const result = {};
|
|
@@ -6550,7 +6563,7 @@ function resolveFromCatalog(catalogs, wantedDependency) {
|
|
|
6550
6563
|
}
|
|
6551
6564
|
|
|
6552
6565
|
//#endregion
|
|
6553
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
6566
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/layers/catalog/resolve.js
|
|
6554
6567
|
const DEP_FIELDS = [
|
|
6555
6568
|
"dependencies",
|
|
6556
6569
|
"devDependencies",
|
|
@@ -6621,7 +6634,7 @@ function resolveManifest(catalogs, workspaceVersions, manifest) {
|
|
|
6621
6634
|
}
|
|
6622
6635
|
|
|
6623
6636
|
//#endregion
|
|
6624
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
6637
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/schemas/CatalogSet.js
|
|
6625
6638
|
/**
|
|
6626
6639
|
* An immutable, fully-normalized catalog collection with the one
|
|
6627
6640
|
* resolution semantic shared by live and point-in-time resolution.
|
|
@@ -6712,7 +6725,7 @@ var CatalogSet = class CatalogSet extends Schema.Class("CatalogSet")({ entries:
|
|
|
6712
6725
|
};
|
|
6713
6726
|
|
|
6714
6727
|
//#endregion
|
|
6715
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
6728
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/layers/point-in-time/worktree-catalogs.js
|
|
6716
6729
|
/**
|
|
6717
6730
|
* The ONE code path that reads the working tree's catalog sources
|
|
6718
6731
|
* (`pnpm-workspace.yaml` + `pnpm-lock.yaml`). Consumed by
|
|
@@ -6729,7 +6742,7 @@ var CatalogSet = class CatalogSet extends Schema.Class("CatalogSet")({ entries:
|
|
|
6729
6742
|
*
|
|
6730
6743
|
* @internal
|
|
6731
6744
|
*/
|
|
6732
|
-
const lockfileCatalogsFromText = (text) => parse$
|
|
6745
|
+
const lockfileCatalogsFromText = (text) => parse$3(text).pipe(Effect.map((parsed) => CatalogSet.fromLockfileCatalogs(parsed?.catalogs)), Effect.orElseSucceed(() => CatalogSet.empty()));
|
|
6733
6746
|
/**
|
|
6734
6747
|
* Read the working tree's catalog state at `root`.
|
|
6735
6748
|
*
|
|
@@ -8268,7 +8281,7 @@ minimatch.escape = escape;
|
|
|
8268
8281
|
minimatch.unescape = unescape;
|
|
8269
8282
|
|
|
8270
8283
|
//#endregion
|
|
8271
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
8284
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/schemas/core.js
|
|
8272
8285
|
/**
|
|
8273
8286
|
* Schema for supported package manager identifiers.
|
|
8274
8287
|
*
|
|
@@ -8596,7 +8609,1302 @@ var WorkspaceInfo = class extends Schema.Class("WorkspaceInfo")({
|
|
|
8596
8609
|
}) {};
|
|
8597
8610
|
|
|
8598
8611
|
//#endregion
|
|
8599
|
-
//#region ../../node_modules/.pnpm/
|
|
8612
|
+
//#region ../../node_modules/.pnpm/jsonc-effect@0.3.1_effect@3.21.4/node_modules/jsonc-effect/errors.js
|
|
8613
|
+
/**
|
|
8614
|
+
* JSONC error types using Effect's Data.TaggedError pattern.
|
|
8615
|
+
*
|
|
8616
|
+
* @packageDocumentation
|
|
8617
|
+
*/
|
|
8618
|
+
/**
|
|
8619
|
+
* Error codes representing specific JSONC parse failures.
|
|
8620
|
+
*
|
|
8621
|
+
* @remarks
|
|
8622
|
+
* Each code maps to a distinct syntactic error the parser can encounter,
|
|
8623
|
+
* from invalid symbols and number formats to missing delimiters and
|
|
8624
|
+
* unexpected end-of-input conditions.
|
|
8625
|
+
*
|
|
8626
|
+
* @see {@link JsoncParseErrorDetail} — carries one of these codes alongside
|
|
8627
|
+
* position information
|
|
8628
|
+
*
|
|
8629
|
+
* @public
|
|
8630
|
+
*/
|
|
8631
|
+
const JsoncParseErrorCode = Schema.Literal("InvalidSymbol", "InvalidNumberFormat", "PropertyNameExpected", "ValueExpected", "ColonExpected", "CommaExpected", "CloseBraceExpected", "CloseBracketExpected", "EndOfFileExpected", "InvalidCommentToken", "UnexpectedEndOfComment", "UnexpectedEndOfString", "UnexpectedEndOfNumber", "InvalidUnicode", "InvalidEscapeCharacter", "InvalidCharacter");
|
|
8632
|
+
/**
|
|
8633
|
+
* Detail for a single parse error, including the error code, a human-readable
|
|
8634
|
+
* message, and the exact position within the source document.
|
|
8635
|
+
*
|
|
8636
|
+
* @remarks
|
|
8637
|
+
* - `code` — a {@link (JsoncParseErrorCode:type)} identifying the error kind.
|
|
8638
|
+
* - `message` — a descriptive message suitable for display.
|
|
8639
|
+
* - `offset` — zero-based character offset where the error occurred.
|
|
8640
|
+
* - `length` — character length of the problematic span.
|
|
8641
|
+
* - `startLine` — zero-based line number of the error.
|
|
8642
|
+
* - `startCharacter` — zero-based column within `startLine`.
|
|
8643
|
+
*
|
|
8644
|
+
* @see {@link JsoncParseError} — aggregates an array of these details
|
|
8645
|
+
*
|
|
8646
|
+
* @example
|
|
8647
|
+
* ```ts
|
|
8648
|
+
* import { JsoncParseErrorDetail } from "jsonc-effect";
|
|
8649
|
+
*
|
|
8650
|
+
* const detail = new JsoncParseErrorDetail({
|
|
8651
|
+
* code: "ValueExpected",
|
|
8652
|
+
* message: "Value expected",
|
|
8653
|
+
* offset: 5,
|
|
8654
|
+
* length: 1,
|
|
8655
|
+
* startLine: 0,
|
|
8656
|
+
* startCharacter: 5,
|
|
8657
|
+
* });
|
|
8658
|
+
*
|
|
8659
|
+
* console.log(detail.code); // "ValueExpected"
|
|
8660
|
+
* console.log(detail.offset); // 5
|
|
8661
|
+
* ```
|
|
8662
|
+
*
|
|
8663
|
+
* @public
|
|
8664
|
+
*/
|
|
8665
|
+
var JsoncParseErrorDetail = class extends Schema.Class("JsoncParseErrorDetail")({
|
|
8666
|
+
code: JsoncParseErrorCode,
|
|
8667
|
+
message: Schema.String,
|
|
8668
|
+
offset: Schema.Number,
|
|
8669
|
+
length: Schema.Number,
|
|
8670
|
+
startLine: Schema.Number,
|
|
8671
|
+
startCharacter: Schema.Number
|
|
8672
|
+
}) {};
|
|
8673
|
+
/**
|
|
8674
|
+
* Base class for {@link JsoncParseError}; not intended to be constructed or
|
|
8675
|
+
* caught directly — use `JsoncParseError` instead.
|
|
8676
|
+
*
|
|
8677
|
+
* @privateRemarks
|
|
8678
|
+
* The `*Base` pattern is required because `Data.TaggedError` produces complex
|
|
8679
|
+
* type signatures involving intersection types and branded generics that
|
|
8680
|
+
* api-extractor cannot roll up into a single `.d.ts` bundle. Exporting the
|
|
8681
|
+
* base separately lets the public `JsoncParseError` class extend it with
|
|
8682
|
+
* concrete fields, giving api-extractor a simple class declaration to work
|
|
8683
|
+
* with. It is tagged `@public` (rather than `@internal`) because it appears
|
|
8684
|
+
* in `JsoncParseError`'s heritage clause in the public `.d.ts`, and API
|
|
8685
|
+
* Extractor requires release tags to be compatible across a signature.
|
|
8686
|
+
*
|
|
8687
|
+
* @public
|
|
8688
|
+
*/
|
|
8689
|
+
const JsoncParseErrorBase = Data.TaggedError("JsoncParseError");
|
|
8690
|
+
/**
|
|
8691
|
+
* Error raised when JSONC parsing encounters one or more syntax errors.
|
|
8692
|
+
*
|
|
8693
|
+
* @remarks
|
|
8694
|
+
* Contains the full source `text`, the `options` used for parsing, and an
|
|
8695
|
+
* `errors` array of {@link JsoncParseErrorDetail} instances with precise
|
|
8696
|
+
* position information for each problem found.
|
|
8697
|
+
*
|
|
8698
|
+
* @see {@link parse} — may fail with this error
|
|
8699
|
+
* @see {@link parseTree} — may fail with this error
|
|
8700
|
+
*
|
|
8701
|
+
* @example Catching with `Effect.catchTag`
|
|
8702
|
+
* ```ts
|
|
8703
|
+
* import { Effect } from "effect";
|
|
8704
|
+
* import { parse } from "jsonc-effect";
|
|
8705
|
+
*
|
|
8706
|
+
* const program = parse("{ invalid }").pipe(
|
|
8707
|
+
* Effect.catchTag("JsoncParseError", (e) => {
|
|
8708
|
+
* console.error(e.errors); // Array of JsoncParseErrorDetail
|
|
8709
|
+
* return Effect.succeed({});
|
|
8710
|
+
* }),
|
|
8711
|
+
* );
|
|
8712
|
+
* ```
|
|
8713
|
+
*
|
|
8714
|
+
* @example Inspecting error details
|
|
8715
|
+
* ```ts
|
|
8716
|
+
* import { Effect } from "effect";
|
|
8717
|
+
* import { parse } from "jsonc-effect";
|
|
8718
|
+
*
|
|
8719
|
+
* const program = parse("{ invalid }").pipe(
|
|
8720
|
+
* Effect.catchTag("JsoncParseError", (e) => {
|
|
8721
|
+
* for (const detail of e.errors) {
|
|
8722
|
+
* console.error(
|
|
8723
|
+
* `[${detail.code}] ${detail.message} at line ${detail.startLine}:${detail.startCharacter}`,
|
|
8724
|
+
* );
|
|
8725
|
+
* }
|
|
8726
|
+
* return Effect.succeed({});
|
|
8727
|
+
* }),
|
|
8728
|
+
* );
|
|
8729
|
+
* ```
|
|
8730
|
+
*
|
|
8731
|
+
* @public
|
|
8732
|
+
*/
|
|
8733
|
+
var JsoncParseError = class extends JsoncParseErrorBase {
|
|
8734
|
+
get message() {
|
|
8735
|
+
const count = this.errors.length;
|
|
8736
|
+
return `JSONC parse failed with ${count} error${count !== 1 ? "s" : ""}: ${this.errors.map((e) => e.message).join("; ")}`;
|
|
8737
|
+
}
|
|
8738
|
+
};
|
|
8739
|
+
/**
|
|
8740
|
+
* Base class for {@link JsoncNodeNotFoundError}; not intended to be
|
|
8741
|
+
* constructed or caught directly — use `JsoncNodeNotFoundError` instead.
|
|
8742
|
+
*
|
|
8743
|
+
* @privateRemarks
|
|
8744
|
+
* Uses the same `*Base` pattern as {@link JsoncParseErrorBase} to work
|
|
8745
|
+
* around api-extractor's inability to roll up the complex type produced
|
|
8746
|
+
* by `Data.TaggedError` into a single `.d.ts` declaration. Tagged `@public`
|
|
8747
|
+
* for the same heritage-clause-compatibility reason as `JsoncParseErrorBase`.
|
|
8748
|
+
*
|
|
8749
|
+
* @public
|
|
8750
|
+
*/
|
|
8751
|
+
const JsoncNodeNotFoundErrorBase = Data.TaggedError("JsoncNodeNotFoundError");
|
|
8752
|
+
/**
|
|
8753
|
+
* Base class for {@link JsoncModificationError}; not intended to be
|
|
8754
|
+
* constructed or caught directly — use `JsoncModificationError` instead.
|
|
8755
|
+
*
|
|
8756
|
+
* @privateRemarks
|
|
8757
|
+
* Uses the same `*Base` pattern as {@link JsoncParseErrorBase} to work
|
|
8758
|
+
* around api-extractor's inability to roll up the complex type produced
|
|
8759
|
+
* by `Data.TaggedError` into a single `.d.ts` declaration. Tagged `@public`
|
|
8760
|
+
* for the same heritage-clause-compatibility reason as `JsoncParseErrorBase`.
|
|
8761
|
+
*
|
|
8762
|
+
* @public
|
|
8763
|
+
*/
|
|
8764
|
+
const JsoncModificationErrorBase = Data.TaggedError("JsoncModificationError");
|
|
8765
|
+
/**
|
|
8766
|
+
* Error raised when {@link modify} produces invalid edits or encounters
|
|
8767
|
+
* an unsupported modification scenario.
|
|
8768
|
+
*
|
|
8769
|
+
* @remarks
|
|
8770
|
+
* Contains the `path` where modification was attempted and a `reason`
|
|
8771
|
+
* string explaining why it failed.
|
|
8772
|
+
*
|
|
8773
|
+
* @see {@link modify} — may fail with this error
|
|
8774
|
+
*
|
|
8775
|
+
* @example
|
|
8776
|
+
* ```ts
|
|
8777
|
+
* import { Effect } from "effect";
|
|
8778
|
+
* import { modify } from "jsonc-effect";
|
|
8779
|
+
*
|
|
8780
|
+
* const program = modify("{}", ["deep", "path"], 42).pipe(
|
|
8781
|
+
* Effect.catchTag("JsoncModificationError", (e) => {
|
|
8782
|
+
* console.error(`Failed at [${e.path.join(", ")}]: ${e.reason}`);
|
|
8783
|
+
* return Effect.succeed([]);
|
|
8784
|
+
* }),
|
|
8785
|
+
* );
|
|
8786
|
+
* ```
|
|
8787
|
+
*
|
|
8788
|
+
* @public
|
|
8789
|
+
*/
|
|
8790
|
+
var JsoncModificationError = class extends JsoncModificationErrorBase {
|
|
8791
|
+
get message() {
|
|
8792
|
+
return `Modification failed at path [${this.path.join(", ")}]: ${this.reason}`;
|
|
8793
|
+
}
|
|
8794
|
+
};
|
|
8795
|
+
|
|
8796
|
+
//#endregion
|
|
8797
|
+
//#region ../../node_modules/.pnpm/jsonc-effect@0.3.1_effect@3.21.4/node_modules/jsonc-effect/scanner.js
|
|
8798
|
+
const isWhitespace = (ch) => ch === 32 || ch === 9 || ch === 11 || ch === 12 || ch === 160 || ch === 65279;
|
|
8799
|
+
const isLineBreak$1 = (ch) => ch === 10 || ch === 13 || ch === 8232 || ch === 8233;
|
|
8800
|
+
const isDigit$1 = (ch) => ch >= 48 && ch <= 57;
|
|
8801
|
+
/**
|
|
8802
|
+
* Create a stateful {@link JsoncScanner} for the given JSONC string.
|
|
8803
|
+
*
|
|
8804
|
+
* @param text - JSONC string to tokenize
|
|
8805
|
+
* @param ignoreTrivia - If `true`, the scanner automatically skips whitespace,
|
|
8806
|
+
* line-break, and comment tokens so that only structural tokens are returned
|
|
8807
|
+
* (default: `false`).
|
|
8808
|
+
* @returns A stateful {@link JsoncScanner} positioned before the first token.
|
|
8809
|
+
*
|
|
8810
|
+
* @remarks
|
|
8811
|
+
* When `ignoreTrivia` is `true` the scanner is suitable for building parsers
|
|
8812
|
+
* that only care about structural tokens (`OpenBrace`, `String`, `Number`,
|
|
8813
|
+
* etc.). Set it to `false` (the default) when you need to preserve comments
|
|
8814
|
+
* or whitespace — for example in a formatter or a comment-stripping pass.
|
|
8815
|
+
*
|
|
8816
|
+
* @see {@link JsoncScanner} — the interface returned by this factory
|
|
8817
|
+
* @see {@link parse} — higher-level API that uses a scanner internally
|
|
8818
|
+
*
|
|
8819
|
+
* @example
|
|
8820
|
+
* Tokenizing a JSONC string and printing each token:
|
|
8821
|
+
* ```ts
|
|
8822
|
+
* import type { JsoncSyntaxKind } from "jsonc-effect";
|
|
8823
|
+
* import { createScanner } from "jsonc-effect";
|
|
8824
|
+
*
|
|
8825
|
+
* const scanner = createScanner('{ "name": "jsonc" }', true);
|
|
8826
|
+
* let kind: JsoncSyntaxKind;
|
|
8827
|
+
* do {
|
|
8828
|
+
* kind = scanner.scan();
|
|
8829
|
+
* console.log(kind, scanner.getTokenValue());
|
|
8830
|
+
* } while (kind !== "EOF");
|
|
8831
|
+
* ```
|
|
8832
|
+
*
|
|
8833
|
+
* @privateRemarks
|
|
8834
|
+
* Ported from Microsoft's jsonc-parser (MIT), adapted to use string literal
|
|
8835
|
+
* token types instead of numeric enums.
|
|
8836
|
+
*
|
|
8837
|
+
* @public
|
|
8838
|
+
*/
|
|
8839
|
+
const createScanner$1 = (text, ignoreTrivia = false) => {
|
|
8840
|
+
const len = text.length;
|
|
8841
|
+
let pos = 0;
|
|
8842
|
+
let tokenOffset = 0;
|
|
8843
|
+
let token = "Unknown";
|
|
8844
|
+
let tokenValue = "";
|
|
8845
|
+
let tokenError = "None";
|
|
8846
|
+
let lineNumber = 0;
|
|
8847
|
+
let lineStartOffset = 0;
|
|
8848
|
+
let tokenStartLine = 0;
|
|
8849
|
+
let tokenStartCharacter = 0;
|
|
8850
|
+
const scanHexDigits = (count) => {
|
|
8851
|
+
let value = 0;
|
|
8852
|
+
for (let i = 0; i < count; i++) {
|
|
8853
|
+
if (pos >= len) return -1;
|
|
8854
|
+
const ch = text.charCodeAt(pos);
|
|
8855
|
+
if (ch >= 48 && ch <= 57) value = value * 16 + (ch - 48);
|
|
8856
|
+
else if (ch >= 65 && ch <= 70) value = value * 16 + (ch - 65 + 10);
|
|
8857
|
+
else if (ch >= 97 && ch <= 102) value = value * 16 + (ch - 97 + 10);
|
|
8858
|
+
else return -1;
|
|
8859
|
+
pos++;
|
|
8860
|
+
}
|
|
8861
|
+
return value;
|
|
8862
|
+
};
|
|
8863
|
+
const scanString = () => {
|
|
8864
|
+
let result = "";
|
|
8865
|
+
pos++;
|
|
8866
|
+
let start = pos;
|
|
8867
|
+
while (pos < len) {
|
|
8868
|
+
const ch = text.charCodeAt(pos);
|
|
8869
|
+
if (ch === 34) {
|
|
8870
|
+
result += text.substring(start, pos);
|
|
8871
|
+
pos++;
|
|
8872
|
+
return result;
|
|
8873
|
+
}
|
|
8874
|
+
if (ch === 92) {
|
|
8875
|
+
result += text.substring(start, pos);
|
|
8876
|
+
pos++;
|
|
8877
|
+
if (pos >= len) {
|
|
8878
|
+
tokenError = "UnexpectedEndOfString";
|
|
8879
|
+
return result;
|
|
8880
|
+
}
|
|
8881
|
+
const escaped = text.charCodeAt(pos);
|
|
8882
|
+
pos++;
|
|
8883
|
+
switch (escaped) {
|
|
8884
|
+
case 34:
|
|
8885
|
+
result += "\"";
|
|
8886
|
+
break;
|
|
8887
|
+
case 92:
|
|
8888
|
+
result += "\\";
|
|
8889
|
+
break;
|
|
8890
|
+
case 47:
|
|
8891
|
+
result += "/";
|
|
8892
|
+
break;
|
|
8893
|
+
case 98:
|
|
8894
|
+
result += "\b";
|
|
8895
|
+
break;
|
|
8896
|
+
case 102:
|
|
8897
|
+
result += "\f";
|
|
8898
|
+
break;
|
|
8899
|
+
case 110:
|
|
8900
|
+
result += "\n";
|
|
8901
|
+
break;
|
|
8902
|
+
case 114:
|
|
8903
|
+
result += "\r";
|
|
8904
|
+
break;
|
|
8905
|
+
case 116:
|
|
8906
|
+
result += " ";
|
|
8907
|
+
break;
|
|
8908
|
+
case 117: {
|
|
8909
|
+
const value = scanHexDigits(4);
|
|
8910
|
+
if (value >= 0) result += String.fromCharCode(value);
|
|
8911
|
+
else tokenError = "InvalidUnicode";
|
|
8912
|
+
break;
|
|
8913
|
+
}
|
|
8914
|
+
default:
|
|
8915
|
+
tokenError = "InvalidEscapeCharacter";
|
|
8916
|
+
break;
|
|
8917
|
+
}
|
|
8918
|
+
start = pos;
|
|
8919
|
+
} else if (isLineBreak$1(ch)) {
|
|
8920
|
+
tokenError = "UnexpectedEndOfString";
|
|
8921
|
+
return result + text.substring(start, pos);
|
|
8922
|
+
} else pos++;
|
|
8923
|
+
}
|
|
8924
|
+
tokenError = "UnexpectedEndOfString";
|
|
8925
|
+
return result + text.substring(start, pos);
|
|
8926
|
+
};
|
|
8927
|
+
const scanNumber = () => {
|
|
8928
|
+
const start = pos;
|
|
8929
|
+
if (text.charCodeAt(pos) === 45) pos++;
|
|
8930
|
+
if (text.charCodeAt(pos) === 48) pos++;
|
|
8931
|
+
else {
|
|
8932
|
+
if (!isDigit$1(text.charCodeAt(pos))) {
|
|
8933
|
+
tokenError = "UnexpectedEndOfNumber";
|
|
8934
|
+
return text.substring(start, pos);
|
|
8935
|
+
}
|
|
8936
|
+
pos++;
|
|
8937
|
+
while (pos < len && isDigit$1(text.charCodeAt(pos))) pos++;
|
|
8938
|
+
}
|
|
8939
|
+
if (pos < len && text.charCodeAt(pos) === 46) {
|
|
8940
|
+
pos++;
|
|
8941
|
+
if (!isDigit$1(text.charCodeAt(pos))) {
|
|
8942
|
+
tokenError = "UnexpectedEndOfNumber";
|
|
8943
|
+
return text.substring(start, pos);
|
|
8944
|
+
}
|
|
8945
|
+
pos++;
|
|
8946
|
+
while (pos < len && isDigit$1(text.charCodeAt(pos))) pos++;
|
|
8947
|
+
}
|
|
8948
|
+
if (pos < len && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
|
|
8949
|
+
pos++;
|
|
8950
|
+
if (pos < len && (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45)) pos++;
|
|
8951
|
+
if (!isDigit$1(text.charCodeAt(pos))) {
|
|
8952
|
+
tokenError = "UnexpectedEndOfNumber";
|
|
8953
|
+
return text.substring(start, pos);
|
|
8954
|
+
}
|
|
8955
|
+
pos++;
|
|
8956
|
+
while (pos < len && isDigit$1(text.charCodeAt(pos))) pos++;
|
|
8957
|
+
}
|
|
8958
|
+
return text.substring(start, pos);
|
|
8959
|
+
};
|
|
8960
|
+
const scan = () => {
|
|
8961
|
+
tokenValue = "";
|
|
8962
|
+
tokenError = "None";
|
|
8963
|
+
if (pos >= len) {
|
|
8964
|
+
tokenOffset = len;
|
|
8965
|
+
tokenStartLine = lineNumber;
|
|
8966
|
+
tokenStartCharacter = pos - lineStartOffset;
|
|
8967
|
+
token = "EOF";
|
|
8968
|
+
return token;
|
|
8969
|
+
}
|
|
8970
|
+
let ch = text.charCodeAt(pos);
|
|
8971
|
+
if (isWhitespace(ch)) {
|
|
8972
|
+
tokenOffset = pos;
|
|
8973
|
+
tokenStartLine = lineNumber;
|
|
8974
|
+
tokenStartCharacter = pos - lineStartOffset;
|
|
8975
|
+
do {
|
|
8976
|
+
pos++;
|
|
8977
|
+
ch = pos < len ? text.charCodeAt(pos) : 0;
|
|
8978
|
+
} while (isWhitespace(ch));
|
|
8979
|
+
tokenValue = text.substring(tokenOffset, pos);
|
|
8980
|
+
if (ignoreTrivia) return scan();
|
|
8981
|
+
token = "Trivia";
|
|
8982
|
+
return token;
|
|
8983
|
+
}
|
|
8984
|
+
if (isLineBreak$1(ch)) {
|
|
8985
|
+
tokenOffset = pos;
|
|
8986
|
+
tokenStartLine = lineNumber;
|
|
8987
|
+
tokenStartCharacter = pos - lineStartOffset;
|
|
8988
|
+
pos++;
|
|
8989
|
+
if (ch === 13 && pos < len && text.charCodeAt(pos) === 10) pos++;
|
|
8990
|
+
lineNumber++;
|
|
8991
|
+
lineStartOffset = pos;
|
|
8992
|
+
tokenValue = text.substring(tokenOffset, pos);
|
|
8993
|
+
if (ignoreTrivia) return scan();
|
|
8994
|
+
token = "LineBreak";
|
|
8995
|
+
return token;
|
|
8996
|
+
}
|
|
8997
|
+
tokenOffset = pos;
|
|
8998
|
+
tokenStartLine = lineNumber;
|
|
8999
|
+
tokenStartCharacter = pos - lineStartOffset;
|
|
9000
|
+
switch (ch) {
|
|
9001
|
+
case 123:
|
|
9002
|
+
pos++;
|
|
9003
|
+
tokenValue = "{";
|
|
9004
|
+
token = "OpenBrace";
|
|
9005
|
+
return token;
|
|
9006
|
+
case 125:
|
|
9007
|
+
pos++;
|
|
9008
|
+
tokenValue = "}";
|
|
9009
|
+
token = "CloseBrace";
|
|
9010
|
+
return token;
|
|
9011
|
+
case 91:
|
|
9012
|
+
pos++;
|
|
9013
|
+
tokenValue = "[";
|
|
9014
|
+
token = "OpenBracket";
|
|
9015
|
+
return token;
|
|
9016
|
+
case 93:
|
|
9017
|
+
pos++;
|
|
9018
|
+
tokenValue = "]";
|
|
9019
|
+
token = "CloseBracket";
|
|
9020
|
+
return token;
|
|
9021
|
+
case 58:
|
|
9022
|
+
pos++;
|
|
9023
|
+
tokenValue = ":";
|
|
9024
|
+
token = "Colon";
|
|
9025
|
+
return token;
|
|
9026
|
+
case 44:
|
|
9027
|
+
pos++;
|
|
9028
|
+
tokenValue = ",";
|
|
9029
|
+
token = "Comma";
|
|
9030
|
+
return token;
|
|
9031
|
+
case 34:
|
|
9032
|
+
tokenValue = scanString();
|
|
9033
|
+
token = "String";
|
|
9034
|
+
return token;
|
|
9035
|
+
case 47: {
|
|
9036
|
+
const nextCh = pos + 1 < len ? text.charCodeAt(pos + 1) : 0;
|
|
9037
|
+
if (nextCh === 47) {
|
|
9038
|
+
pos += 2;
|
|
9039
|
+
while (pos < len && !isLineBreak$1(text.charCodeAt(pos))) pos++;
|
|
9040
|
+
tokenValue = text.substring(tokenOffset, pos);
|
|
9041
|
+
if (ignoreTrivia) return scan();
|
|
9042
|
+
token = "LineComment";
|
|
9043
|
+
return token;
|
|
9044
|
+
}
|
|
9045
|
+
if (nextCh === 42) {
|
|
9046
|
+
pos += 2;
|
|
9047
|
+
const safeLen = len - 1;
|
|
9048
|
+
let commentClosed = false;
|
|
9049
|
+
while (pos < safeLen) {
|
|
9050
|
+
const cch = text.charCodeAt(pos);
|
|
9051
|
+
if (isLineBreak$1(cch)) {
|
|
9052
|
+
if (cch === 13 && pos + 1 < len && text.charCodeAt(pos + 1) === 10) pos++;
|
|
9053
|
+
pos++;
|
|
9054
|
+
lineNumber++;
|
|
9055
|
+
lineStartOffset = pos;
|
|
9056
|
+
} else if (cch === 42 && text.charCodeAt(pos + 1) === 47) {
|
|
9057
|
+
pos += 2;
|
|
9058
|
+
commentClosed = true;
|
|
9059
|
+
break;
|
|
9060
|
+
} else pos++;
|
|
9061
|
+
}
|
|
9062
|
+
if (!commentClosed) {
|
|
9063
|
+
pos = len;
|
|
9064
|
+
tokenError = "UnexpectedEndOfComment";
|
|
9065
|
+
}
|
|
9066
|
+
tokenValue = text.substring(tokenOffset, pos);
|
|
9067
|
+
if (ignoreTrivia) return scan();
|
|
9068
|
+
token = "BlockComment";
|
|
9069
|
+
return token;
|
|
9070
|
+
}
|
|
9071
|
+
pos++;
|
|
9072
|
+
tokenValue = text.substring(tokenOffset, pos);
|
|
9073
|
+
token = "Unknown";
|
|
9074
|
+
tokenError = "InvalidCharacter";
|
|
9075
|
+
return token;
|
|
9076
|
+
}
|
|
9077
|
+
case 45:
|
|
9078
|
+
if (pos + 1 < len && isDigit$1(text.charCodeAt(pos + 1))) {
|
|
9079
|
+
tokenValue = scanNumber();
|
|
9080
|
+
token = "Number";
|
|
9081
|
+
return token;
|
|
9082
|
+
}
|
|
9083
|
+
pos++;
|
|
9084
|
+
tokenValue = "-";
|
|
9085
|
+
token = "Unknown";
|
|
9086
|
+
tokenError = "InvalidSymbol";
|
|
9087
|
+
return token;
|
|
9088
|
+
default:
|
|
9089
|
+
if (isDigit$1(ch)) {
|
|
9090
|
+
tokenValue = scanNumber();
|
|
9091
|
+
token = "Number";
|
|
9092
|
+
return token;
|
|
9093
|
+
}
|
|
9094
|
+
if (ch >= 97 && ch <= 122) {
|
|
9095
|
+
const start = pos;
|
|
9096
|
+
pos++;
|
|
9097
|
+
while (pos < len) {
|
|
9098
|
+
const kch = text.charCodeAt(pos);
|
|
9099
|
+
if (kch >= 97 && kch <= 122) pos++;
|
|
9100
|
+
else break;
|
|
9101
|
+
}
|
|
9102
|
+
tokenValue = text.substring(start, pos);
|
|
9103
|
+
switch (tokenValue) {
|
|
9104
|
+
case "true":
|
|
9105
|
+
token = "True";
|
|
9106
|
+
return token;
|
|
9107
|
+
case "false":
|
|
9108
|
+
token = "False";
|
|
9109
|
+
return token;
|
|
9110
|
+
case "null":
|
|
9111
|
+
token = "Null";
|
|
9112
|
+
return token;
|
|
9113
|
+
default:
|
|
9114
|
+
token = "Unknown";
|
|
9115
|
+
tokenError = "InvalidSymbol";
|
|
9116
|
+
return token;
|
|
9117
|
+
}
|
|
9118
|
+
}
|
|
9119
|
+
pos++;
|
|
9120
|
+
tokenValue = text.substring(tokenOffset, pos);
|
|
9121
|
+
token = "Unknown";
|
|
9122
|
+
tokenError = "InvalidCharacter";
|
|
9123
|
+
return token;
|
|
9124
|
+
}
|
|
9125
|
+
};
|
|
9126
|
+
return {
|
|
9127
|
+
scan,
|
|
9128
|
+
getToken: () => token,
|
|
9129
|
+
getTokenValue: () => tokenValue,
|
|
9130
|
+
getTokenOffset: () => tokenOffset,
|
|
9131
|
+
getTokenLength: () => pos - tokenOffset,
|
|
9132
|
+
getTokenStartLine: () => tokenStartLine,
|
|
9133
|
+
getTokenStartCharacter: () => tokenStartCharacter,
|
|
9134
|
+
getTokenError: () => tokenError,
|
|
9135
|
+
getPosition: () => pos,
|
|
9136
|
+
setPosition: (newPos) => {
|
|
9137
|
+
pos = newPos;
|
|
9138
|
+
tokenValue = "";
|
|
9139
|
+
token = "Unknown";
|
|
9140
|
+
tokenError = "None";
|
|
9141
|
+
}
|
|
9142
|
+
};
|
|
9143
|
+
};
|
|
9144
|
+
|
|
9145
|
+
//#endregion
|
|
9146
|
+
//#region ../../node_modules/.pnpm/jsonc-effect@0.3.1_effect@3.21.4/node_modules/jsonc-effect/parse.js
|
|
9147
|
+
/**
|
|
9148
|
+
* JSONC Parser — converts token stream into JavaScript values or AST nodes.
|
|
9149
|
+
*
|
|
9150
|
+
* Pure Effect implementation using recursive descent parsing.
|
|
9151
|
+
* Reference: Microsoft's jsonc-parser parser design (MIT).
|
|
9152
|
+
*
|
|
9153
|
+
* @packageDocumentation
|
|
9154
|
+
*/
|
|
9155
|
+
/**
|
|
9156
|
+
* Parse a JSONC string into a JavaScript value.
|
|
9157
|
+
*
|
|
9158
|
+
* @param text - JSONC string to parse
|
|
9159
|
+
* @param options - Optional {@link JsoncParseOptions} controlling comment and
|
|
9160
|
+
* trailing-comma handling.
|
|
9161
|
+
* @returns `Effect<unknown, JsoncParseError>` — succeeds with the parsed value
|
|
9162
|
+
* or fails with a {@link JsoncParseError} containing every error encountered.
|
|
9163
|
+
*
|
|
9164
|
+
* @remarks
|
|
9165
|
+
* The return type is `unknown` (not `any`) so consumers are forced to narrow
|
|
9166
|
+
* the result, which is safer in Effect pipelines. By default
|
|
9167
|
+
* `allowTrailingComma` is `true`, matching common JSONC conventions used in
|
|
9168
|
+
* VS Code settings and `tsconfig.json`.
|
|
9169
|
+
*
|
|
9170
|
+
* @see {@link parseTree} — parse into an AST instead of a plain value
|
|
9171
|
+
* @see {@link JsoncParseOptions} — available parse options
|
|
9172
|
+
* @see {@link JsoncParseError} — the tagged error type on the failure channel
|
|
9173
|
+
*
|
|
9174
|
+
* @example
|
|
9175
|
+
* Basic parsing:
|
|
9176
|
+
* ```ts
|
|
9177
|
+
* import { Effect } from "effect";
|
|
9178
|
+
* import { parse } from "jsonc-effect";
|
|
9179
|
+
*
|
|
9180
|
+
* const value = Effect.runSync(parse('{ "key": 42 }'));
|
|
9181
|
+
* console.log(value); // { key: 42 }
|
|
9182
|
+
* ```
|
|
9183
|
+
*
|
|
9184
|
+
* @example
|
|
9185
|
+
* Parsing with options:
|
|
9186
|
+
* ```ts
|
|
9187
|
+
* import { Effect } from "effect";
|
|
9188
|
+
* import { parse } from "jsonc-effect";
|
|
9189
|
+
*
|
|
9190
|
+
* const value = Effect.runSync(
|
|
9191
|
+
* parse('{ "key": 42 }', { disallowComments: true }),
|
|
9192
|
+
* );
|
|
9193
|
+
* ```
|
|
9194
|
+
*
|
|
9195
|
+
* @example
|
|
9196
|
+
* Error handling with `catchTag`:
|
|
9197
|
+
* ```ts
|
|
9198
|
+
* import { Effect } from "effect";
|
|
9199
|
+
* import { parse } from "jsonc-effect";
|
|
9200
|
+
*
|
|
9201
|
+
* const program = parse("{ bad }").pipe(
|
|
9202
|
+
* Effect.catchTag("JsoncParseError", (err) =>
|
|
9203
|
+
* Effect.succeed({ fallback: true, errors: err.errors }),
|
|
9204
|
+
* ),
|
|
9205
|
+
* );
|
|
9206
|
+
*
|
|
9207
|
+
* const result = Effect.runSync(program);
|
|
9208
|
+
* console.log(result);
|
|
9209
|
+
* ```
|
|
9210
|
+
*
|
|
9211
|
+
* @example
|
|
9212
|
+
* Using `Effect.gen`:
|
|
9213
|
+
* ```ts
|
|
9214
|
+
* import { Effect } from "effect";
|
|
9215
|
+
* import { parse } from "jsonc-effect";
|
|
9216
|
+
*
|
|
9217
|
+
* const program = Effect.gen(function* () {
|
|
9218
|
+
* const config = yield* parse('{ "port": 3000 }');
|
|
9219
|
+
* return config;
|
|
9220
|
+
* });
|
|
9221
|
+
*
|
|
9222
|
+
* const result = Effect.runSync(program);
|
|
9223
|
+
* console.log(result); // { port: 3000 }
|
|
9224
|
+
* ```
|
|
9225
|
+
*
|
|
9226
|
+
* @privateRemarks
|
|
9227
|
+
* Uses {@link createScanner} internally with a recursive descent parser.
|
|
9228
|
+
* The scanner is created with `ignoreTrivia = false` so the parser can
|
|
9229
|
+
* report comment-related errors when `disallowComments` is set.
|
|
9230
|
+
*
|
|
9231
|
+
* @public
|
|
9232
|
+
*/
|
|
9233
|
+
const parse$2 = (text, options) => Effect.sync(() => parseInternal(text, options ?? {}, false)).pipe(Effect.flatMap(({ value, errors }) => {
|
|
9234
|
+
if (errors.length > 0) return Effect.fail(new JsoncParseError({
|
|
9235
|
+
errors,
|
|
9236
|
+
text,
|
|
9237
|
+
...options !== void 0 ? { options } : {}
|
|
9238
|
+
}));
|
|
9239
|
+
return Effect.succeed(value);
|
|
9240
|
+
}));
|
|
9241
|
+
function parseInternal(text, options, buildTree) {
|
|
9242
|
+
const scanner = createScanner$1(text, false);
|
|
9243
|
+
const errors = [];
|
|
9244
|
+
const disallowComments = options.disallowComments ?? false;
|
|
9245
|
+
const allowTrailingComma = options.allowTrailingComma ?? true;
|
|
9246
|
+
const allowEmptyContent = options.allowEmptyContent ?? false;
|
|
9247
|
+
let currentToken = "Unknown";
|
|
9248
|
+
function token() {
|
|
9249
|
+
return currentToken;
|
|
9250
|
+
}
|
|
9251
|
+
function scanNext() {
|
|
9252
|
+
for (;;) {
|
|
9253
|
+
currentToken = scanner.scan();
|
|
9254
|
+
switch (scanner.getTokenError()) {
|
|
9255
|
+
case "InvalidUnicode":
|
|
9256
|
+
handleError("InvalidUnicode");
|
|
9257
|
+
break;
|
|
9258
|
+
case "InvalidEscapeCharacter":
|
|
9259
|
+
handleError("InvalidEscapeCharacter");
|
|
9260
|
+
break;
|
|
9261
|
+
case "UnexpectedEndOfNumber":
|
|
9262
|
+
handleError("InvalidNumberFormat");
|
|
9263
|
+
break;
|
|
9264
|
+
case "UnexpectedEndOfComment":
|
|
9265
|
+
handleError("UnexpectedEndOfComment");
|
|
9266
|
+
break;
|
|
9267
|
+
case "UnexpectedEndOfString":
|
|
9268
|
+
handleError("UnexpectedEndOfString");
|
|
9269
|
+
break;
|
|
9270
|
+
case "InvalidCharacter":
|
|
9271
|
+
handleError("InvalidCharacter");
|
|
9272
|
+
break;
|
|
9273
|
+
}
|
|
9274
|
+
switch (currentToken) {
|
|
9275
|
+
case "LineComment":
|
|
9276
|
+
case "BlockComment":
|
|
9277
|
+
if (disallowComments) handleError("InvalidCommentToken");
|
|
9278
|
+
break;
|
|
9279
|
+
case "Trivia":
|
|
9280
|
+
case "LineBreak": break;
|
|
9281
|
+
default: return currentToken;
|
|
9282
|
+
}
|
|
9283
|
+
}
|
|
9284
|
+
}
|
|
9285
|
+
function tokenEnd() {
|
|
9286
|
+
return scanner.getTokenOffset() + scanner.getTokenLength();
|
|
9287
|
+
}
|
|
9288
|
+
function handleError(code, skipUntilAfter = [], skipUntil = []) {
|
|
9289
|
+
errors.push(new JsoncParseErrorDetail({
|
|
9290
|
+
code,
|
|
9291
|
+
message: formatError(code, scanner.getTokenOffset()),
|
|
9292
|
+
offset: scanner.getTokenOffset(),
|
|
9293
|
+
length: scanner.getTokenLength(),
|
|
9294
|
+
startLine: scanner.getTokenStartLine(),
|
|
9295
|
+
startCharacter: scanner.getTokenStartCharacter()
|
|
9296
|
+
}));
|
|
9297
|
+
if (skipUntilAfter.length > 0 || skipUntil.length > 0) {
|
|
9298
|
+
let t = token();
|
|
9299
|
+
while (t !== "EOF") {
|
|
9300
|
+
if (skipUntilAfter.includes(t)) {
|
|
9301
|
+
scanNext();
|
|
9302
|
+
break;
|
|
9303
|
+
}
|
|
9304
|
+
if (skipUntil.includes(t)) break;
|
|
9305
|
+
t = scanNext();
|
|
9306
|
+
}
|
|
9307
|
+
}
|
|
9308
|
+
}
|
|
9309
|
+
function parseValue() {
|
|
9310
|
+
switch (token()) {
|
|
9311
|
+
case "OpenBracket": return parseArray();
|
|
9312
|
+
case "OpenBrace": return parseObject();
|
|
9313
|
+
case "String": return parseString();
|
|
9314
|
+
case "Number": return parseNumber();
|
|
9315
|
+
case "True":
|
|
9316
|
+
scanNext();
|
|
9317
|
+
return true;
|
|
9318
|
+
case "False":
|
|
9319
|
+
scanNext();
|
|
9320
|
+
return false;
|
|
9321
|
+
case "Null":
|
|
9322
|
+
scanNext();
|
|
9323
|
+
return null;
|
|
9324
|
+
default: return;
|
|
9325
|
+
}
|
|
9326
|
+
}
|
|
9327
|
+
function parseString() {
|
|
9328
|
+
const value = scanner.getTokenValue();
|
|
9329
|
+
scanNext();
|
|
9330
|
+
return value;
|
|
9331
|
+
}
|
|
9332
|
+
function parseNumber() {
|
|
9333
|
+
const value = Number.parseFloat(scanner.getTokenValue());
|
|
9334
|
+
scanNext();
|
|
9335
|
+
return value;
|
|
9336
|
+
}
|
|
9337
|
+
function parseArray() {
|
|
9338
|
+
scanNext();
|
|
9339
|
+
const arr = [];
|
|
9340
|
+
let needsComma = false;
|
|
9341
|
+
while (token() !== "CloseBracket" && token() !== "EOF") {
|
|
9342
|
+
if (token() === "Comma") {
|
|
9343
|
+
if (!needsComma) handleError("ValueExpected");
|
|
9344
|
+
scanNext();
|
|
9345
|
+
if (token() === "CloseBracket" && allowTrailingComma) break;
|
|
9346
|
+
} else if (needsComma) handleError("CommaExpected");
|
|
9347
|
+
const value = parseValue();
|
|
9348
|
+
if (value === void 0) handleError("ValueExpected", [], ["CloseBracket", "Comma"]);
|
|
9349
|
+
else arr.push(value);
|
|
9350
|
+
needsComma = true;
|
|
9351
|
+
}
|
|
9352
|
+
if (token() !== "CloseBracket") handleError("CloseBracketExpected");
|
|
9353
|
+
else scanNext();
|
|
9354
|
+
return arr;
|
|
9355
|
+
}
|
|
9356
|
+
function parseObject() {
|
|
9357
|
+
scanNext();
|
|
9358
|
+
const obj = {};
|
|
9359
|
+
let needsComma = false;
|
|
9360
|
+
while (token() !== "CloseBrace" && token() !== "EOF") {
|
|
9361
|
+
if (token() === "Comma") {
|
|
9362
|
+
if (!needsComma) handleError("PropertyNameExpected");
|
|
9363
|
+
scanNext();
|
|
9364
|
+
if (token() === "CloseBrace" && allowTrailingComma) break;
|
|
9365
|
+
} else if (needsComma) handleError("CommaExpected");
|
|
9366
|
+
if (token() !== "String") {
|
|
9367
|
+
handleError("PropertyNameExpected", [], ["CloseBrace", "Comma"]);
|
|
9368
|
+
continue;
|
|
9369
|
+
}
|
|
9370
|
+
const key = scanner.getTokenValue();
|
|
9371
|
+
scanNext();
|
|
9372
|
+
if (token() !== "Colon") {
|
|
9373
|
+
handleError("ColonExpected", [], ["CloseBrace", "Comma"]);
|
|
9374
|
+
continue;
|
|
9375
|
+
}
|
|
9376
|
+
scanNext();
|
|
9377
|
+
const value = parseValue();
|
|
9378
|
+
if (value === void 0) handleError("ValueExpected", [], ["CloseBrace", "Comma"]);
|
|
9379
|
+
else obj[key] = value;
|
|
9380
|
+
needsComma = true;
|
|
9381
|
+
}
|
|
9382
|
+
if (token() !== "CloseBrace") handleError("CloseBraceExpected");
|
|
9383
|
+
else scanNext();
|
|
9384
|
+
return obj;
|
|
9385
|
+
}
|
|
9386
|
+
function parseValueTree() {
|
|
9387
|
+
switch (token()) {
|
|
9388
|
+
case "OpenBracket": return parseArrayTree();
|
|
9389
|
+
case "OpenBrace": return parseObjectTree();
|
|
9390
|
+
case "String": {
|
|
9391
|
+
const node = {
|
|
9392
|
+
type: "string",
|
|
9393
|
+
offset: scanner.getTokenOffset(),
|
|
9394
|
+
length: 0,
|
|
9395
|
+
value: scanner.getTokenValue()
|
|
9396
|
+
};
|
|
9397
|
+
const end = tokenEnd();
|
|
9398
|
+
scanNext();
|
|
9399
|
+
node.length = end - node.offset;
|
|
9400
|
+
return node;
|
|
9401
|
+
}
|
|
9402
|
+
case "Number": {
|
|
9403
|
+
const node = {
|
|
9404
|
+
type: "number",
|
|
9405
|
+
offset: scanner.getTokenOffset(),
|
|
9406
|
+
length: 0,
|
|
9407
|
+
value: Number.parseFloat(scanner.getTokenValue())
|
|
9408
|
+
};
|
|
9409
|
+
const end = tokenEnd();
|
|
9410
|
+
scanNext();
|
|
9411
|
+
node.length = end - node.offset;
|
|
9412
|
+
return node;
|
|
9413
|
+
}
|
|
9414
|
+
case "True": {
|
|
9415
|
+
const node = {
|
|
9416
|
+
type: "boolean",
|
|
9417
|
+
offset: scanner.getTokenOffset(),
|
|
9418
|
+
length: 0,
|
|
9419
|
+
value: true
|
|
9420
|
+
};
|
|
9421
|
+
const end = tokenEnd();
|
|
9422
|
+
scanNext();
|
|
9423
|
+
node.length = end - node.offset;
|
|
9424
|
+
return node;
|
|
9425
|
+
}
|
|
9426
|
+
case "False": {
|
|
9427
|
+
const node = {
|
|
9428
|
+
type: "boolean",
|
|
9429
|
+
offset: scanner.getTokenOffset(),
|
|
9430
|
+
length: 0,
|
|
9431
|
+
value: false
|
|
9432
|
+
};
|
|
9433
|
+
const end = tokenEnd();
|
|
9434
|
+
scanNext();
|
|
9435
|
+
node.length = end - node.offset;
|
|
9436
|
+
return node;
|
|
9437
|
+
}
|
|
9438
|
+
case "Null": {
|
|
9439
|
+
const node = {
|
|
9440
|
+
type: "null",
|
|
9441
|
+
offset: scanner.getTokenOffset(),
|
|
9442
|
+
length: 0,
|
|
9443
|
+
value: null
|
|
9444
|
+
};
|
|
9445
|
+
const end = tokenEnd();
|
|
9446
|
+
scanNext();
|
|
9447
|
+
node.length = end - node.offset;
|
|
9448
|
+
return node;
|
|
9449
|
+
}
|
|
9450
|
+
default: return;
|
|
9451
|
+
}
|
|
9452
|
+
}
|
|
9453
|
+
function parseArrayTree() {
|
|
9454
|
+
const node = {
|
|
9455
|
+
type: "array",
|
|
9456
|
+
offset: scanner.getTokenOffset(),
|
|
9457
|
+
length: 0,
|
|
9458
|
+
children: []
|
|
9459
|
+
};
|
|
9460
|
+
scanNext();
|
|
9461
|
+
let needsComma = false;
|
|
9462
|
+
while (token() !== "CloseBracket" && token() !== "EOF") {
|
|
9463
|
+
if (token() === "Comma") {
|
|
9464
|
+
if (!needsComma) handleError("ValueExpected");
|
|
9465
|
+
scanNext();
|
|
9466
|
+
if (token() === "CloseBracket" && allowTrailingComma) break;
|
|
9467
|
+
} else if (needsComma) handleError("CommaExpected");
|
|
9468
|
+
const child = parseValueTree();
|
|
9469
|
+
if (child) node.children.push(child);
|
|
9470
|
+
else handleError("ValueExpected", [], ["CloseBracket", "Comma"]);
|
|
9471
|
+
needsComma = true;
|
|
9472
|
+
}
|
|
9473
|
+
let end;
|
|
9474
|
+
if (token() !== "CloseBracket") {
|
|
9475
|
+
handleError("CloseBracketExpected");
|
|
9476
|
+
end = scanner.getTokenOffset();
|
|
9477
|
+
} else {
|
|
9478
|
+
end = tokenEnd();
|
|
9479
|
+
scanNext();
|
|
9480
|
+
}
|
|
9481
|
+
node.length = end - node.offset;
|
|
9482
|
+
return node;
|
|
9483
|
+
}
|
|
9484
|
+
function parseObjectTree() {
|
|
9485
|
+
const node = {
|
|
9486
|
+
type: "object",
|
|
9487
|
+
offset: scanner.getTokenOffset(),
|
|
9488
|
+
length: 0,
|
|
9489
|
+
children: []
|
|
9490
|
+
};
|
|
9491
|
+
scanNext();
|
|
9492
|
+
let needsComma = false;
|
|
9493
|
+
while (token() !== "CloseBrace" && token() !== "EOF") {
|
|
9494
|
+
if (token() === "Comma") {
|
|
9495
|
+
if (!needsComma) handleError("PropertyNameExpected");
|
|
9496
|
+
scanNext();
|
|
9497
|
+
if (token() === "CloseBrace" && allowTrailingComma) break;
|
|
9498
|
+
} else if (needsComma) handleError("CommaExpected");
|
|
9499
|
+
if (token() !== "String") {
|
|
9500
|
+
handleError("PropertyNameExpected", [], ["CloseBrace", "Comma"]);
|
|
9501
|
+
continue;
|
|
9502
|
+
}
|
|
9503
|
+
const property = {
|
|
9504
|
+
type: "property",
|
|
9505
|
+
offset: scanner.getTokenOffset(),
|
|
9506
|
+
length: 0,
|
|
9507
|
+
children: []
|
|
9508
|
+
};
|
|
9509
|
+
const keyNode = {
|
|
9510
|
+
type: "string",
|
|
9511
|
+
offset: scanner.getTokenOffset(),
|
|
9512
|
+
length: 0,
|
|
9513
|
+
value: scanner.getTokenValue()
|
|
9514
|
+
};
|
|
9515
|
+
const keyEnd = tokenEnd();
|
|
9516
|
+
scanNext();
|
|
9517
|
+
keyNode.length = keyEnd - keyNode.offset;
|
|
9518
|
+
property.children.push(keyNode);
|
|
9519
|
+
if (token() !== "Colon") {
|
|
9520
|
+
handleError("ColonExpected", [], ["CloseBrace", "Comma"]);
|
|
9521
|
+
property.length = scanner.getTokenOffset() - property.offset;
|
|
9522
|
+
node.children.push(property);
|
|
9523
|
+
continue;
|
|
9524
|
+
}
|
|
9525
|
+
property.colonOffset = scanner.getTokenOffset();
|
|
9526
|
+
scanNext();
|
|
9527
|
+
const valueNode = parseValueTree();
|
|
9528
|
+
if (valueNode) {
|
|
9529
|
+
property.children.push(valueNode);
|
|
9530
|
+
property.length = valueNode.offset + valueNode.length - property.offset;
|
|
9531
|
+
} else {
|
|
9532
|
+
handleError("ValueExpected", [], ["CloseBrace", "Comma"]);
|
|
9533
|
+
property.length = scanner.getTokenOffset() - property.offset;
|
|
9534
|
+
}
|
|
9535
|
+
node.children.push(property);
|
|
9536
|
+
needsComma = true;
|
|
9537
|
+
}
|
|
9538
|
+
let end;
|
|
9539
|
+
if (token() !== "CloseBrace") {
|
|
9540
|
+
handleError("CloseBraceExpected");
|
|
9541
|
+
end = scanner.getTokenOffset();
|
|
9542
|
+
} else {
|
|
9543
|
+
end = tokenEnd();
|
|
9544
|
+
scanNext();
|
|
9545
|
+
}
|
|
9546
|
+
node.length = end - node.offset;
|
|
9547
|
+
return node;
|
|
9548
|
+
}
|
|
9549
|
+
scanNext();
|
|
9550
|
+
if (buildTree) {
|
|
9551
|
+
const root = parseValueTree();
|
|
9552
|
+
if (token() !== "EOF") handleError("EndOfFileExpected");
|
|
9553
|
+
if (!root && !allowEmptyContent) handleError("ValueExpected");
|
|
9554
|
+
return {
|
|
9555
|
+
value: void 0,
|
|
9556
|
+
root,
|
|
9557
|
+
errors
|
|
9558
|
+
};
|
|
9559
|
+
}
|
|
9560
|
+
const value = parseValue();
|
|
9561
|
+
if (token() !== "EOF") handleError("EndOfFileExpected");
|
|
9562
|
+
if (value === void 0 && !allowEmptyContent) handleError("ValueExpected");
|
|
9563
|
+
return {
|
|
9564
|
+
value,
|
|
9565
|
+
root: void 0,
|
|
9566
|
+
errors
|
|
9567
|
+
};
|
|
9568
|
+
}
|
|
9569
|
+
function formatError(code, offset) {
|
|
9570
|
+
switch (code) {
|
|
9571
|
+
case "InvalidSymbol": return `Invalid symbol at offset ${offset}`;
|
|
9572
|
+
case "InvalidNumberFormat": return `Invalid number format at offset ${offset}`;
|
|
9573
|
+
case "PropertyNameExpected": return `Property name expected at offset ${offset}`;
|
|
9574
|
+
case "ValueExpected": return `Value expected at offset ${offset}`;
|
|
9575
|
+
case "ColonExpected": return `Colon expected at offset ${offset}`;
|
|
9576
|
+
case "CommaExpected": return `Comma expected at offset ${offset}`;
|
|
9577
|
+
case "CloseBraceExpected": return `Close brace expected at offset ${offset}`;
|
|
9578
|
+
case "CloseBracketExpected": return `Close bracket expected at offset ${offset}`;
|
|
9579
|
+
case "EndOfFileExpected": return `End of file expected at offset ${offset}`;
|
|
9580
|
+
case "InvalidCommentToken": return `Comments not allowed at offset ${offset}`;
|
|
9581
|
+
case "UnexpectedEndOfComment": return `Unexpected end of comment at offset ${offset}`;
|
|
9582
|
+
case "UnexpectedEndOfString": return `Unexpected end of string at offset ${offset}`;
|
|
9583
|
+
case "UnexpectedEndOfNumber": return `Unexpected end of number at offset ${offset}`;
|
|
9584
|
+
case "InvalidUnicode": return `Invalid unicode escape at offset ${offset}`;
|
|
9585
|
+
case "InvalidEscapeCharacter": return `Invalid escape character at offset ${offset}`;
|
|
9586
|
+
case "InvalidCharacter": return `Invalid character at offset ${offset}`;
|
|
9587
|
+
default: return `Parse error at offset ${offset}`;
|
|
9588
|
+
}
|
|
9589
|
+
}
|
|
9590
|
+
|
|
9591
|
+
//#endregion
|
|
9592
|
+
//#region ../../node_modules/.pnpm/jsonc-effect@0.3.1_effect@3.21.4/node_modules/jsonc-effect/format.js
|
|
9593
|
+
/**
|
|
9594
|
+
* Apply an array of text edits to JSONC source text.
|
|
9595
|
+
*
|
|
9596
|
+
* This is a {@link https://effect.website/docs/function-dual | Function.dual}
|
|
9597
|
+
* that supports both data-first and data-last (pipeline) usage.
|
|
9598
|
+
*
|
|
9599
|
+
* @param text - The original JSONC source text.
|
|
9600
|
+
* @param edits - A read-only array of {@link JsoncEdit} objects, typically
|
|
9601
|
+
* produced by {@link format} or {@link modify}.
|
|
9602
|
+
* @returns An `Effect` that succeeds with the edited string.
|
|
9603
|
+
*
|
|
9604
|
+
* @remarks
|
|
9605
|
+
* Edits are sorted in reverse offset order before application so that
|
|
9606
|
+
* earlier edits do not shift the offsets of later ones. The original `edits`
|
|
9607
|
+
* array is not mutated.
|
|
9608
|
+
*
|
|
9609
|
+
* @see {@link format} to compute formatting edits.
|
|
9610
|
+
* @see {@link modify} to compute structural edits (insert, replace, remove).
|
|
9611
|
+
*
|
|
9612
|
+
* @example Data-first usage
|
|
9613
|
+
* ```ts
|
|
9614
|
+
* import { Effect } from "effect";
|
|
9615
|
+
* import { format, applyEdits } from "jsonc-effect";
|
|
9616
|
+
*
|
|
9617
|
+
* const input = '{"a":1}';
|
|
9618
|
+
* const edits = Effect.runSync(format(input));
|
|
9619
|
+
* const result: string = Effect.runSync(applyEdits(input, edits));
|
|
9620
|
+
* ```
|
|
9621
|
+
*
|
|
9622
|
+
* @example Pipeline with modify
|
|
9623
|
+
* ```ts
|
|
9624
|
+
* import { Effect, pipe } from "effect";
|
|
9625
|
+
* import { modify, applyEdits } from "jsonc-effect";
|
|
9626
|
+
*
|
|
9627
|
+
* const input = '{ "a": 1 }';
|
|
9628
|
+
* const result = pipe(
|
|
9629
|
+
* input,
|
|
9630
|
+
* modify(["a"], 42),
|
|
9631
|
+
* Effect.flatMap((edits) => applyEdits(input, edits)),
|
|
9632
|
+
* Effect.runSync,
|
|
9633
|
+
* );
|
|
9634
|
+
* ```
|
|
9635
|
+
*
|
|
9636
|
+
* @public
|
|
9637
|
+
*/
|
|
9638
|
+
const applyEdits$1 = Function.dual(2, (text, edits) => Effect.sync(() => {
|
|
9639
|
+
const sorted = [...edits].sort((a, b) => b.offset - a.offset);
|
|
9640
|
+
let result = text;
|
|
9641
|
+
for (const edit of sorted) result = result.substring(0, edit.offset) + edit.content + result.substring(edit.offset + edit.length);
|
|
9642
|
+
return result;
|
|
9643
|
+
}));
|
|
9644
|
+
/**
|
|
9645
|
+
* Compute edits to insert, replace, or remove a value at a JSON path.
|
|
9646
|
+
*
|
|
9647
|
+
* This is a {@link https://effect.website/docs/function-dual | Function.dual}
|
|
9648
|
+
* that supports both data-first and data-last (pipeline) usage.
|
|
9649
|
+
*
|
|
9650
|
+
* @param text - The JSONC source text to modify.
|
|
9651
|
+
* @param path - A {@link (JsoncPath:type)} (array of string keys and numeric indices)
|
|
9652
|
+
* identifying the target location in the JSON structure.
|
|
9653
|
+
* @param value - The value to set. Pass `undefined` to remove the
|
|
9654
|
+
* property or array element at the given path.
|
|
9655
|
+
* @param options - Optional object with `formattingOptions` controlling
|
|
9656
|
+
* indent size, tabs vs. spaces, and EOL style for generated text.
|
|
9657
|
+
* @returns An `Effect` that succeeds with a read-only array of
|
|
9658
|
+
* {@link JsoncEdit} objects, or fails with a
|
|
9659
|
+
* {@link JsoncModificationError} if the path cannot be navigated.
|
|
9660
|
+
*
|
|
9661
|
+
* @remarks
|
|
9662
|
+
* Setting `value` to `undefined` removes the targeted property or element,
|
|
9663
|
+
* including its surrounding comma. When inserting a new property into an
|
|
9664
|
+
* object, it is appended after the last existing property.
|
|
9665
|
+
*
|
|
9666
|
+
* @see {@link applyEdits} to apply the returned edits to the source text.
|
|
9667
|
+
* @see {@link JsoncModificationError} for the error type on navigation failure.
|
|
9668
|
+
*
|
|
9669
|
+
* @example Update an existing property
|
|
9670
|
+
* ```ts
|
|
9671
|
+
* import { Effect } from "effect";
|
|
9672
|
+
* import { modify, applyEdits } from "jsonc-effect";
|
|
9673
|
+
*
|
|
9674
|
+
* const input = '{ "a": 1 }';
|
|
9675
|
+
* const edits = Effect.runSync(modify(input, ["a"], 2));
|
|
9676
|
+
* const result: string = Effect.runSync(applyEdits(input, edits));
|
|
9677
|
+
* ```
|
|
9678
|
+
*
|
|
9679
|
+
* @example Insert a new property
|
|
9680
|
+
* ```ts
|
|
9681
|
+
* import { Effect } from "effect";
|
|
9682
|
+
* import { modify, applyEdits } from "jsonc-effect";
|
|
9683
|
+
*
|
|
9684
|
+
* const input = '{ "a": 1 }';
|
|
9685
|
+
* const edits = Effect.runSync(modify(input, ["b"], "hello"));
|
|
9686
|
+
* const result: string = Effect.runSync(applyEdits(input, edits));
|
|
9687
|
+
* ```
|
|
9688
|
+
*
|
|
9689
|
+
* @example Remove a property
|
|
9690
|
+
* ```ts
|
|
9691
|
+
* import { Effect } from "effect";
|
|
9692
|
+
* import { modify, applyEdits } from "jsonc-effect";
|
|
9693
|
+
*
|
|
9694
|
+
* const input = '{ "a": 1, "b": 2 }';
|
|
9695
|
+
* const edits = Effect.runSync(modify(input, ["a"], undefined));
|
|
9696
|
+
* const result: string = Effect.runSync(applyEdits(input, edits));
|
|
9697
|
+
* ```
|
|
9698
|
+
*
|
|
9699
|
+
* @example Pipeline (data-last) usage
|
|
9700
|
+
* ```ts
|
|
9701
|
+
* import { Effect, pipe } from "effect";
|
|
9702
|
+
* import { modify, applyEdits } from "jsonc-effect";
|
|
9703
|
+
*
|
|
9704
|
+
* const input = '{ "a": 1 }';
|
|
9705
|
+
* const result = pipe(
|
|
9706
|
+
* input,
|
|
9707
|
+
* modify(["a"], 42),
|
|
9708
|
+
* Effect.flatMap((edits) => applyEdits(input, edits)),
|
|
9709
|
+
* Effect.runSync,
|
|
9710
|
+
* );
|
|
9711
|
+
* ```
|
|
9712
|
+
*
|
|
9713
|
+
* @privateRemarks
|
|
9714
|
+
* Uses its own scanner-based navigation to locate the target path rather
|
|
9715
|
+
* than building a full AST via `parseTree`. This keeps the implementation
|
|
9716
|
+
* lightweight and avoids an intermediate allocation.
|
|
9717
|
+
*
|
|
9718
|
+
* @public
|
|
9719
|
+
*/
|
|
9720
|
+
const modify = Function.dual((args) => typeof args[0] === "string" && Array.isArray(args[1]), (text, path, value, options) => Effect.try({
|
|
9721
|
+
try: () => modifyImpl(text, path, value, options?.formattingOptions),
|
|
9722
|
+
catch: (e) => new JsoncModificationError({
|
|
9723
|
+
path,
|
|
9724
|
+
reason: String(e)
|
|
9725
|
+
})
|
|
9726
|
+
}));
|
|
9727
|
+
function modifyImpl(text, path, value, formattingOptions) {
|
|
9728
|
+
const opts = {
|
|
9729
|
+
tabSize: formattingOptions?.tabSize ?? 2,
|
|
9730
|
+
insertSpaces: formattingOptions?.insertSpaces ?? true,
|
|
9731
|
+
eol: formattingOptions?.eol ?? "\n"
|
|
9732
|
+
};
|
|
9733
|
+
const indentUnit = opts.insertSpaces ? " ".repeat(opts.tabSize) : " ";
|
|
9734
|
+
if (path.length === 0) {
|
|
9735
|
+
const content = value === void 0 ? "" : JSON.stringify(value, null, opts.tabSize);
|
|
9736
|
+
return [{
|
|
9737
|
+
offset: 0,
|
|
9738
|
+
length: text.length,
|
|
9739
|
+
content
|
|
9740
|
+
}];
|
|
9741
|
+
}
|
|
9742
|
+
const scanner = createScanner$1(text, true);
|
|
9743
|
+
let currentToken = scanner.scan();
|
|
9744
|
+
function tokenEnd() {
|
|
9745
|
+
return scanner.getTokenOffset() + scanner.getTokenLength();
|
|
9746
|
+
}
|
|
9747
|
+
function skipValue() {
|
|
9748
|
+
switch (currentToken) {
|
|
9749
|
+
case "OpenBrace": {
|
|
9750
|
+
let end = tokenEnd();
|
|
9751
|
+
currentToken = scanner.scan();
|
|
9752
|
+
let first = true;
|
|
9753
|
+
while (currentToken !== "CloseBrace" && currentToken !== "EOF") {
|
|
9754
|
+
if (!first && currentToken === "Comma") currentToken = scanner.scan();
|
|
9755
|
+
if (currentToken === "String") {
|
|
9756
|
+
currentToken = scanner.scan();
|
|
9757
|
+
if (currentToken === "Colon") {
|
|
9758
|
+
currentToken = scanner.scan();
|
|
9759
|
+
end = skipValue();
|
|
9760
|
+
}
|
|
9761
|
+
} else {
|
|
9762
|
+
end = tokenEnd();
|
|
9763
|
+
currentToken = scanner.scan();
|
|
9764
|
+
}
|
|
9765
|
+
first = false;
|
|
9766
|
+
}
|
|
9767
|
+
if (currentToken === "CloseBrace") {
|
|
9768
|
+
end = tokenEnd();
|
|
9769
|
+
currentToken = scanner.scan();
|
|
9770
|
+
}
|
|
9771
|
+
return end;
|
|
9772
|
+
}
|
|
9773
|
+
case "OpenBracket": {
|
|
9774
|
+
let end = tokenEnd();
|
|
9775
|
+
currentToken = scanner.scan();
|
|
9776
|
+
let first = true;
|
|
9777
|
+
while (currentToken !== "CloseBracket" && currentToken !== "EOF") {
|
|
9778
|
+
if (!first && currentToken === "Comma") currentToken = scanner.scan();
|
|
9779
|
+
end = skipValue();
|
|
9780
|
+
first = false;
|
|
9781
|
+
}
|
|
9782
|
+
if (currentToken === "CloseBracket") {
|
|
9783
|
+
end = tokenEnd();
|
|
9784
|
+
currentToken = scanner.scan();
|
|
9785
|
+
}
|
|
9786
|
+
return end;
|
|
9787
|
+
}
|
|
9788
|
+
default: {
|
|
9789
|
+
const end = tokenEnd();
|
|
9790
|
+
currentToken = scanner.scan();
|
|
9791
|
+
return end;
|
|
9792
|
+
}
|
|
9793
|
+
}
|
|
9794
|
+
}
|
|
9795
|
+
let depth = 0;
|
|
9796
|
+
for (const segment of path) {
|
|
9797
|
+
depth++;
|
|
9798
|
+
if (typeof segment === "string") {
|
|
9799
|
+
if (currentToken !== "OpenBrace") throw new Error(`Expected object at depth ${depth}`);
|
|
9800
|
+
currentToken = scanner.scan();
|
|
9801
|
+
let found = false;
|
|
9802
|
+
let lastValueEnd = scanner.getTokenOffset();
|
|
9803
|
+
let isFirst = true;
|
|
9804
|
+
while (currentToken !== "CloseBrace" && currentToken !== "EOF") {
|
|
9805
|
+
if (!isFirst && currentToken === "Comma") currentToken = scanner.scan();
|
|
9806
|
+
if (currentToken === "String") {
|
|
9807
|
+
const key = scanner.getTokenValue();
|
|
9808
|
+
currentToken = scanner.scan();
|
|
9809
|
+
if (currentToken === "Colon") currentToken = scanner.scan();
|
|
9810
|
+
if (key === segment) {
|
|
9811
|
+
found = true;
|
|
9812
|
+
if (depth === path.length) {
|
|
9813
|
+
const valueStart = scanner.getTokenOffset();
|
|
9814
|
+
const prevEnd = valueStart;
|
|
9815
|
+
const valueEnd = skipValue();
|
|
9816
|
+
if (value === void 0) {
|
|
9817
|
+
let removeStart = valueStart;
|
|
9818
|
+
let removeEnd = valueEnd;
|
|
9819
|
+
const keyStart = text.substring(0, valueStart).lastIndexOf(`"${segment}"`);
|
|
9820
|
+
if (keyStart >= 0) removeStart = keyStart;
|
|
9821
|
+
const commaPosBefore = text.substring(0, removeStart).trimEnd().lastIndexOf(",");
|
|
9822
|
+
if (commaPosBefore >= 0) removeStart = commaPosBefore;
|
|
9823
|
+
else {
|
|
9824
|
+
const trimmedAfter = text.substring(removeEnd).match(/^(\s*,)/);
|
|
9825
|
+
if (trimmedAfter) removeEnd += trimmedAfter[1].length;
|
|
9826
|
+
}
|
|
9827
|
+
return [{
|
|
9828
|
+
offset: removeStart,
|
|
9829
|
+
length: removeEnd - removeStart,
|
|
9830
|
+
content: ""
|
|
9831
|
+
}];
|
|
9832
|
+
}
|
|
9833
|
+
const serialized = JSON.stringify(value, null, opts.tabSize);
|
|
9834
|
+
return [{
|
|
9835
|
+
offset: prevEnd,
|
|
9836
|
+
length: valueEnd - prevEnd,
|
|
9837
|
+
content: serialized
|
|
9838
|
+
}];
|
|
9839
|
+
}
|
|
9840
|
+
break;
|
|
9841
|
+
}
|
|
9842
|
+
lastValueEnd = skipValue();
|
|
9843
|
+
} else {
|
|
9844
|
+
currentToken = scanner.scan();
|
|
9845
|
+
lastValueEnd = scanner.getTokenOffset();
|
|
9846
|
+
}
|
|
9847
|
+
isFirst = false;
|
|
9848
|
+
}
|
|
9849
|
+
if (!found && depth === path.length && value !== void 0) {
|
|
9850
|
+
const indent = indentUnit.repeat(depth);
|
|
9851
|
+
const serialized = JSON.stringify(value, null, opts.tabSize);
|
|
9852
|
+
const insertText = isFirst ? `${opts.eol}${indent}"${segment}": ${serialized}${opts.eol}${indentUnit.repeat(depth - 1)}` : `,${opts.eol}${indent}"${segment}": ${serialized}`;
|
|
9853
|
+
return [{
|
|
9854
|
+
offset: lastValueEnd,
|
|
9855
|
+
length: 0,
|
|
9856
|
+
content: insertText
|
|
9857
|
+
}];
|
|
9858
|
+
}
|
|
9859
|
+
} else {
|
|
9860
|
+
if (currentToken !== "OpenBracket") throw new Error(`Expected array at depth ${depth}`);
|
|
9861
|
+
currentToken = scanner.scan();
|
|
9862
|
+
let idx = 0;
|
|
9863
|
+
let lastEnd = scanner.getTokenOffset();
|
|
9864
|
+
while (currentToken !== "CloseBracket" && currentToken !== "EOF") {
|
|
9865
|
+
if (idx > 0 && currentToken === "Comma") currentToken = scanner.scan();
|
|
9866
|
+
if (idx === segment) {
|
|
9867
|
+
if (depth === path.length) {
|
|
9868
|
+
const valueStart = scanner.getTokenOffset();
|
|
9869
|
+
const valueEnd = skipValue();
|
|
9870
|
+
if (value === void 0) {
|
|
9871
|
+
let removeEnd = valueEnd;
|
|
9872
|
+
if (text.substring(removeEnd).trimStart().startsWith(",")) removeEnd = text.indexOf(",", removeEnd) + 1;
|
|
9873
|
+
return [{
|
|
9874
|
+
offset: valueStart,
|
|
9875
|
+
length: removeEnd - valueStart,
|
|
9876
|
+
content: ""
|
|
9877
|
+
}];
|
|
9878
|
+
}
|
|
9879
|
+
const serialized = JSON.stringify(value, null, opts.tabSize);
|
|
9880
|
+
return [{
|
|
9881
|
+
offset: valueStart,
|
|
9882
|
+
length: valueEnd - valueStart,
|
|
9883
|
+
content: serialized
|
|
9884
|
+
}];
|
|
9885
|
+
}
|
|
9886
|
+
break;
|
|
9887
|
+
}
|
|
9888
|
+
lastEnd = skipValue();
|
|
9889
|
+
idx++;
|
|
9890
|
+
}
|
|
9891
|
+
if (idx <= segment && depth === path.length && value !== void 0) {
|
|
9892
|
+
const indent = indentUnit.repeat(depth);
|
|
9893
|
+
const serialized = JSON.stringify(value, null, opts.tabSize);
|
|
9894
|
+
const insertText = idx === 0 ? `${opts.eol}${indent}${serialized}${opts.eol}${indentUnit.repeat(depth - 1)}` : `,${opts.eol}${indent}${serialized}`;
|
|
9895
|
+
return [{
|
|
9896
|
+
offset: lastEnd,
|
|
9897
|
+
length: 0,
|
|
9898
|
+
content: insertText
|
|
9899
|
+
}];
|
|
9900
|
+
}
|
|
9901
|
+
}
|
|
9902
|
+
}
|
|
9903
|
+
return [];
|
|
9904
|
+
}
|
|
9905
|
+
|
|
9906
|
+
//#endregion
|
|
9907
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/schemas/WorkspaceStateSnapshot.js
|
|
8600
9908
|
const DepRecord = Schema.optionalWith(Schema.Record({
|
|
8601
9909
|
key: Schema.String,
|
|
8602
9910
|
value: Schema.String
|
|
@@ -8666,7 +9974,7 @@ var WorkspaceStateSnapshot = class extends Schema.Class("WorkspaceStateSnapshot"
|
|
|
8666
9974
|
};
|
|
8667
9975
|
|
|
8668
9976
|
//#endregion
|
|
8669
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
9977
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/services/PointInTimeWorkspace.js
|
|
8670
9978
|
/**
|
|
8671
9979
|
* Service for reading a monorepo's workspace state at a specific moment: any
|
|
8672
9980
|
* git ref (via `git show`/`git ls-tree`, without checking the ref out) or the
|
|
@@ -8694,7 +10002,7 @@ var WorkspaceStateSnapshot = class extends Schema.Class("WorkspaceStateSnapshot"
|
|
|
8694
10002
|
var PointInTimeWorkspace = class extends Context.Tag("@spencerbeggs/workspaces-effect/PointInTimeWorkspace")() {};
|
|
8695
10003
|
|
|
8696
10004
|
//#endregion
|
|
8697
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
10005
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/layers/discovery/glob-core.js
|
|
8698
10006
|
const normalize$2 = (pattern) => pattern.replace(/\/\*\*$/, "/*");
|
|
8699
10007
|
const toRegex = (glob) => new RegExp(`^${glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]")}$`);
|
|
8700
10008
|
/**
|
|
@@ -8738,7 +10046,7 @@ const compileWorkspaceGlobs = (patterns) => {
|
|
|
8738
10046
|
};
|
|
8739
10047
|
|
|
8740
10048
|
//#endregion
|
|
8741
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
10049
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/layers/point-in-time/git.js
|
|
8742
10050
|
/**
|
|
8743
10051
|
* Stderr shapes that mean "the path is not present at this ref" rather than
|
|
8744
10052
|
* "the git command failed."
|
|
@@ -8831,7 +10139,7 @@ const makeGitReader = (executor, options) => {
|
|
|
8831
10139
|
};
|
|
8832
10140
|
|
|
8833
10141
|
//#endregion
|
|
8834
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
10142
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/layers/PointInTimeWorkspaceLive.js
|
|
8835
10143
|
/**
|
|
8836
10144
|
* Live layer for the {@link PointInTimeWorkspace} service.
|
|
8837
10145
|
*
|
|
@@ -8886,7 +10194,7 @@ const packageSnapshotFromJson = (text, relativePath) => {
|
|
|
8886
10194
|
*
|
|
8887
10195
|
* @internal
|
|
8888
10196
|
*/
|
|
8889
|
-
const lockfileCatalogsAtRef = (text) => Option.isNone(text) ? Effect.succeed(CatalogSet.empty()) : parse$
|
|
10197
|
+
const lockfileCatalogsAtRef = (text) => Option.isNone(text) ? Effect.succeed(CatalogSet.empty()) : parse$3(text.value).pipe(Effect.map((parsed) => CatalogSet.fromLockfileCatalogs(parsed?.catalogs)), Effect.orElseSucceed(() => CatalogSet.empty()));
|
|
8890
10198
|
/**
|
|
8891
10199
|
* Live layer for the {@link PointInTimeWorkspace} service.
|
|
8892
10200
|
*
|
|
@@ -8973,7 +10281,7 @@ const PointInTimeWorkspaceLive = Layer.effect(PointInTimeWorkspace, Effect.gen(f
|
|
|
8973
10281
|
}));
|
|
8974
10282
|
|
|
8975
10283
|
//#endregion
|
|
8976
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
10284
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/schemas/publish.js
|
|
8977
10285
|
/**
|
|
8978
10286
|
* Schema for package publish targets.
|
|
8979
10287
|
*
|
|
@@ -9017,7 +10325,7 @@ var PublishTarget = class extends Schema.Class("PublishTarget")({
|
|
|
9017
10325
|
}) {};
|
|
9018
10326
|
|
|
9019
10327
|
//#endregion
|
|
9020
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
10328
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/services/PublishabilityDetector.js
|
|
9021
10329
|
/**
|
|
9022
10330
|
* Service for detecting whether a workspace package is publishable and
|
|
9023
10331
|
* identifying its publish targets (npm, GitHub Packages, etc.).
|
|
@@ -9080,7 +10388,7 @@ var PublishTarget = class extends Schema.Class("PublishTarget")({
|
|
|
9080
10388
|
var PublishabilityDetector = class extends Context.Tag("@spencerbeggs/workspaces-effect/PublishabilityDetector")() {};
|
|
9081
10389
|
|
|
9082
10390
|
//#endregion
|
|
9083
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
10391
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/layers/PublishabilityDetectorLive.js
|
|
9084
10392
|
/**
|
|
9085
10393
|
* Default live implementation of the {@link PublishabilityDetector} service.
|
|
9086
10394
|
*
|
|
@@ -9153,7 +10461,7 @@ const PublishabilityDetectorLive = Layer.succeed(PublishabilityDetector, { detec
|
|
|
9153
10461
|
}).pipe(Effect.withSpan("PublishabilityDetector.detect", { attributes: { "workspace.package": pkg.name } })) });
|
|
9154
10462
|
|
|
9155
10463
|
//#endregion
|
|
9156
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
10464
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/layers/WorkspaceDiscoveryLive.js
|
|
9157
10465
|
/**
|
|
9158
10466
|
* Live implementation of the {@link WorkspaceDiscovery} service.
|
|
9159
10467
|
*
|
|
@@ -9441,7 +10749,7 @@ const WorkspaceDiscoveryLive = Layer.effect(WorkspaceDiscovery, Effect.gen(funct
|
|
|
9441
10749
|
}));
|
|
9442
10750
|
|
|
9443
10751
|
//#endregion
|
|
9444
|
-
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.
|
|
10752
|
+
//#region ../../node_modules/.pnpm/workspaces-effect@2.0.2_@effect+platform@0.96.2_effect@3.21.4__effect@3.21.4/node_modules/workspaces-effect/layers/WorkspaceRootLive.js
|
|
9445
10753
|
/**
|
|
9446
10754
|
* Live implementation of the {@link WorkspaceRoot} service.
|
|
9447
10755
|
*
|
|
@@ -34464,7 +35772,7 @@ var ChangelogTransformer = class ChangelogTransformer {
|
|
|
34464
35772
|
};
|
|
34465
35773
|
|
|
34466
35774
|
//#endregion
|
|
34467
|
-
//#region ../../node_modules/.pnpm/fdir@6.5.0_picomatch@4.0.
|
|
35775
|
+
//#region ../../node_modules/.pnpm/fdir@6.5.0_picomatch@4.0.5/node_modules/fdir/dist/index.mjs
|
|
34468
35776
|
var __require = /* @__PURE__ */ createRequire$1(import.meta.url);
|
|
34469
35777
|
function cleanPath(path) {
|
|
34470
35778
|
let normalized = normalize$1(path);
|
|
@@ -34973,7 +36281,7 @@ var Builder = class {
|
|
|
34973
36281
|
};
|
|
34974
36282
|
|
|
34975
36283
|
//#endregion
|
|
34976
|
-
//#region ../../node_modules/.pnpm/picomatch@4.0.
|
|
36284
|
+
//#region ../../node_modules/.pnpm/picomatch@4.0.5/node_modules/picomatch/lib/constants.js
|
|
34977
36285
|
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
34978
36286
|
const WIN_SLASH = "\\\\/";
|
|
34979
36287
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
@@ -35147,7 +36455,7 @@ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35147
36455
|
}));
|
|
35148
36456
|
|
|
35149
36457
|
//#endregion
|
|
35150
|
-
//#region ../../node_modules/.pnpm/picomatch@4.0.
|
|
36458
|
+
//#region ../../node_modules/.pnpm/picomatch@4.0.5/node_modules/picomatch/lib/utils.js
|
|
35151
36459
|
var require_utils$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
35152
36460
|
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants();
|
|
35153
36461
|
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
@@ -35196,7 +36504,7 @@ var require_utils$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
35196
36504
|
}));
|
|
35197
36505
|
|
|
35198
36506
|
//#endregion
|
|
35199
|
-
//#region ../../node_modules/.pnpm/picomatch@4.0.
|
|
36507
|
+
//#region ../../node_modules/.pnpm/picomatch@4.0.5/node_modules/picomatch/lib/scan.js
|
|
35200
36508
|
var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
35201
36509
|
const utils = require_utils$1();
|
|
35202
36510
|
const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = require_constants();
|
|
@@ -35484,7 +36792,7 @@ var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35484
36792
|
}));
|
|
35485
36793
|
|
|
35486
36794
|
//#endregion
|
|
35487
|
-
//#region ../../node_modules/.pnpm/picomatch@4.0.
|
|
36795
|
+
//#region ../../node_modules/.pnpm/picomatch@4.0.5/node_modules/picomatch/lib/parse.js
|
|
35488
36796
|
var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
35489
36797
|
const constants = require_constants();
|
|
35490
36798
|
const utils = require_utils$1();
|
|
@@ -35639,7 +36947,10 @@ var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35639
36947
|
}
|
|
35640
36948
|
}
|
|
35641
36949
|
};
|
|
35642
|
-
const
|
|
36950
|
+
const buildCharClassStar = (chars) => {
|
|
36951
|
+
return `${chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`}*`;
|
|
36952
|
+
};
|
|
36953
|
+
const getStarExtglobSequenceChars = (pattern) => {
|
|
35643
36954
|
let index = 0;
|
|
35644
36955
|
const chars = [];
|
|
35645
36956
|
while (index < pattern.length) {
|
|
@@ -35653,7 +36964,7 @@ var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35653
36964
|
index += match.end + 1;
|
|
35654
36965
|
}
|
|
35655
36966
|
if (chars.length < 1) return;
|
|
35656
|
-
return
|
|
36967
|
+
return chars;
|
|
35657
36968
|
};
|
|
35658
36969
|
const repeatedExtglobRecursion = (pattern) => {
|
|
35659
36970
|
let depth = 0;
|
|
@@ -35673,14 +36984,28 @@ var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35673
36984
|
if (branches.length > 1) {
|
|
35674
36985
|
if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) return { risky: true };
|
|
35675
36986
|
}
|
|
36987
|
+
const safeChars = [];
|
|
36988
|
+
let sawStarSequence = false;
|
|
36989
|
+
let combinable = true;
|
|
35676
36990
|
for (const branch of branches) {
|
|
35677
|
-
const
|
|
35678
|
-
if (
|
|
35679
|
-
|
|
35680
|
-
|
|
35681
|
-
|
|
36991
|
+
const chars = getStarExtglobSequenceChars(branch);
|
|
36992
|
+
if (chars) {
|
|
36993
|
+
sawStarSequence = true;
|
|
36994
|
+
safeChars.push(...chars);
|
|
36995
|
+
continue;
|
|
36996
|
+
}
|
|
36997
|
+
const literal = normalizeSimpleBranch(branch);
|
|
36998
|
+
if (literal && literal.length === 1) {
|
|
36999
|
+
safeChars.push(literal);
|
|
37000
|
+
continue;
|
|
37001
|
+
}
|
|
37002
|
+
combinable = false;
|
|
35682
37003
|
if (repeatedExtglobRecursion(branch) > max) return { risky: true };
|
|
35683
37004
|
}
|
|
37005
|
+
if (sawStarSequence) return combinable ? {
|
|
37006
|
+
risky: true,
|
|
37007
|
+
safeOutput: buildCharClassStar([...new Set(safeChars)])
|
|
37008
|
+
} : { risky: true };
|
|
35684
37009
|
return { risky: false };
|
|
35685
37010
|
};
|
|
35686
37011
|
/**
|
|
@@ -36542,7 +37867,7 @@ var require_parse$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
36542
37867
|
}));
|
|
36543
37868
|
|
|
36544
37869
|
//#endregion
|
|
36545
|
-
//#region ../../node_modules/.pnpm/picomatch@4.0.
|
|
37870
|
+
//#region ../../node_modules/.pnpm/picomatch@4.0.5/node_modules/picomatch/lib/picomatch.js
|
|
36546
37871
|
var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
36547
37872
|
const scan = require_scan();
|
|
36548
37873
|
const parse = require_parse$1();
|
|
@@ -36563,6 +37888,18 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
36563
37888
|
* const isMatch = picomatch('*.!(*a)');
|
|
36564
37889
|
* console.log(isMatch('a.a')); //=> false
|
|
36565
37890
|
* console.log(isMatch('a.b')); //=> true
|
|
37891
|
+
*
|
|
37892
|
+
* // For environments without `node.js`, `picomatch/posix` provides you a dependency-free matcher, without automatic OS detection.
|
|
37893
|
+
* const picomatch = require('picomatch/posix');
|
|
37894
|
+
* // the same API, defaulting to posix paths
|
|
37895
|
+
* const isMatch = picomatch('a/*');
|
|
37896
|
+
* console.log(isMatch('a\\b')); //=> false
|
|
37897
|
+
* console.log(isMatch('a/b')); //=> true
|
|
37898
|
+
*
|
|
37899
|
+
* // you can still configure the matcher function to accept windows paths
|
|
37900
|
+
* const isMatch = picomatch('a/*', { options: windows });
|
|
37901
|
+
* console.log(isMatch('a\\b')); //=> true
|
|
37902
|
+
* console.log(isMatch('a/b')); //=> true
|
|
36566
37903
|
* ```
|
|
36567
37904
|
* @name picomatch
|
|
36568
37905
|
* @param {String|Array} `globs` One or more glob patterns.
|
|
@@ -36681,8 +38018,8 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
36681
38018
|
* @return {Boolean}
|
|
36682
38019
|
* @api public
|
|
36683
38020
|
*/
|
|
36684
|
-
picomatch.matchBase = (input, glob, options) => {
|
|
36685
|
-
return (glob instanceof RegExp ? glob : picomatch.makeRe(glob, options)).test(utils.basename(input));
|
|
38021
|
+
picomatch.matchBase = (input, glob, options, posix = options && options.windows) => {
|
|
38022
|
+
return (glob instanceof RegExp ? glob : picomatch.makeRe(glob, options)).test(utils.basename(input, { windows: posix }));
|
|
36686
38023
|
};
|
|
36687
38024
|
/**
|
|
36688
38025
|
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
|
@@ -36843,7 +38180,7 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
36843
38180
|
}));
|
|
36844
38181
|
|
|
36845
38182
|
//#endregion
|
|
36846
|
-
//#region ../../node_modules/.pnpm/picomatch@4.0.
|
|
38183
|
+
//#region ../../node_modules/.pnpm/picomatch@4.0.5/node_modules/picomatch/index.js
|
|
36847
38184
|
var require_picomatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
36848
38185
|
const pico = require_picomatch$1();
|
|
36849
38186
|
const utils = require_utils$1();
|
|
@@ -38629,23 +39966,46 @@ function parseJsonPath(path) {
|
|
|
38629
39966
|
* @internal
|
|
38630
39967
|
*/
|
|
38631
39968
|
function jsonPathGet(obj, path) {
|
|
39969
|
+
return walkJsonPath(obj, path).map((entry) => entry.node);
|
|
39970
|
+
}
|
|
39971
|
+
/**
|
|
39972
|
+
* Shared breadth-first traversal behind {@link jsonPathGet} and
|
|
39973
|
+
* {@link jsonPathResolve}: each segment fans out the current set of matched
|
|
39974
|
+
* entries, carrying both the node and the concrete path taken to reach it.
|
|
39975
|
+
* The two public functions differ only in which half of the entry they keep.
|
|
39976
|
+
*/
|
|
39977
|
+
function walkJsonPath(obj, path) {
|
|
38632
39978
|
const segments = parseJsonPath(path);
|
|
38633
|
-
let current = [
|
|
39979
|
+
let current = [{
|
|
39980
|
+
node: obj,
|
|
39981
|
+
path: []
|
|
39982
|
+
}];
|
|
38634
39983
|
for (const segment of segments) {
|
|
38635
39984
|
const next = [];
|
|
38636
|
-
for (const node of current) {
|
|
39985
|
+
for (const { node, path: nodePath } of current) {
|
|
38637
39986
|
if (node === null || node === void 0 || typeof node !== "object") continue;
|
|
38638
39987
|
switch (segment.type) {
|
|
38639
39988
|
case "property": {
|
|
38640
39989
|
const value = node[segment.key];
|
|
38641
|
-
if (value !== void 0) next.push(
|
|
39990
|
+
if (value !== void 0) next.push({
|
|
39991
|
+
node: value,
|
|
39992
|
+
path: [...nodePath, segment.key]
|
|
39993
|
+
});
|
|
38642
39994
|
break;
|
|
38643
39995
|
}
|
|
38644
39996
|
case "index":
|
|
38645
|
-
if (Array.isArray(node) && segment.index < node.length) next.push(
|
|
39997
|
+
if (Array.isArray(node) && segment.index < node.length) next.push({
|
|
39998
|
+
node: node[segment.index],
|
|
39999
|
+
path: [...nodePath, segment.index]
|
|
40000
|
+
});
|
|
38646
40001
|
break;
|
|
38647
40002
|
case "wildcard":
|
|
38648
|
-
if (Array.isArray(node))
|
|
40003
|
+
if (Array.isArray(node)) node.forEach((element, index) => {
|
|
40004
|
+
next.push({
|
|
40005
|
+
node: element,
|
|
40006
|
+
path: [...nodePath, index]
|
|
40007
|
+
});
|
|
40008
|
+
});
|
|
38649
40009
|
break;
|
|
38650
40010
|
}
|
|
38651
40011
|
}
|
|
@@ -38654,81 +40014,37 @@ function jsonPathGet(obj, path) {
|
|
|
38654
40014
|
return current;
|
|
38655
40015
|
}
|
|
38656
40016
|
/**
|
|
38657
|
-
*
|
|
40017
|
+
* Resolve a JSONPath expression to the concrete paths of every existing match.
|
|
38658
40018
|
*
|
|
38659
40019
|
* @remarks
|
|
38660
|
-
*
|
|
38661
|
-
*
|
|
38662
|
-
*
|
|
38663
|
-
*
|
|
40020
|
+
* Uses the same breadth-first expansion as {@link jsonPathGet}, but instead of
|
|
40021
|
+
* collecting the matched *values* it records the concrete `(string | number)[]`
|
|
40022
|
+
* path taken to reach each one. Wildcards and indices are materialized into the
|
|
40023
|
+
* numeric array index actually traversed, so the returned paths are directly
|
|
40024
|
+
* consumable by structural editors such as `jsonc-effect`'s `modify`, which
|
|
40025
|
+
* require a fully concrete path (no wildcards).
|
|
38664
40026
|
*
|
|
38665
|
-
*
|
|
40027
|
+
* Only existing locations are returned; nothing is created. A path with no
|
|
40028
|
+
* matches yields an empty array, and the empty path (`"$."`) yields a single
|
|
40029
|
+
* empty concrete path (the document root).
|
|
40030
|
+
*
|
|
40031
|
+
* @param obj - The object to query
|
|
38666
40032
|
* @param path - JSONPath string (e.g., `"$.packages[*].version"`)
|
|
38667
|
-
* @
|
|
38668
|
-
* @returns The number of locations updated (0 if no matches or empty path)
|
|
40033
|
+
* @returns Array of concrete paths, each an array of string keys / numeric indices
|
|
38669
40034
|
*
|
|
38670
40035
|
* @example
|
|
38671
40036
|
* ```typescript
|
|
38672
|
-
* import {
|
|
40037
|
+
* import { jsonPathResolve } from "../utils/jsonpath.js";
|
|
38673
40038
|
*
|
|
38674
|
-
* const obj = { version: "1.0.0" };
|
|
38675
|
-
* const
|
|
38676
|
-
* //
|
|
40039
|
+
* const obj = { packages: [{ version: "1.0.0" }, { version: "2.0.0" }] };
|
|
40040
|
+
* const paths = jsonPathResolve(obj, "$.packages[*].version");
|
|
40041
|
+
* // [["packages", 0, "version"], ["packages", 1, "version"]]
|
|
38677
40042
|
* ```
|
|
38678
40043
|
*
|
|
38679
40044
|
* @internal
|
|
38680
40045
|
*/
|
|
38681
|
-
function
|
|
38682
|
-
|
|
38683
|
-
if (segments.length === 0) return 0;
|
|
38684
|
-
const lastSegment = segments[segments.length - 1];
|
|
38685
|
-
const parentSegments = segments.slice(0, -1);
|
|
38686
|
-
let parents = [obj];
|
|
38687
|
-
for (const segment of parentSegments) {
|
|
38688
|
-
const next = [];
|
|
38689
|
-
for (const node of parents) {
|
|
38690
|
-
if (node === null || node === void 0 || typeof node !== "object") continue;
|
|
38691
|
-
switch (segment.type) {
|
|
38692
|
-
case "property": {
|
|
38693
|
-
const child = node[segment.key];
|
|
38694
|
-
if (child !== void 0) next.push(child);
|
|
38695
|
-
break;
|
|
38696
|
-
}
|
|
38697
|
-
case "index":
|
|
38698
|
-
if (Array.isArray(node) && segment.index < node.length) next.push(node[segment.index]);
|
|
38699
|
-
break;
|
|
38700
|
-
case "wildcard":
|
|
38701
|
-
if (Array.isArray(node)) next.push(...node);
|
|
38702
|
-
break;
|
|
38703
|
-
}
|
|
38704
|
-
}
|
|
38705
|
-
parents = next;
|
|
38706
|
-
}
|
|
38707
|
-
let count = 0;
|
|
38708
|
-
for (const parent of parents) {
|
|
38709
|
-
if (parent === null || parent === void 0 || typeof parent !== "object") continue;
|
|
38710
|
-
switch (lastSegment.type) {
|
|
38711
|
-
case "property":
|
|
38712
|
-
if (lastSegment.key in parent) {
|
|
38713
|
-
parent[lastSegment.key] = value;
|
|
38714
|
-
count++;
|
|
38715
|
-
}
|
|
38716
|
-
break;
|
|
38717
|
-
case "index":
|
|
38718
|
-
if (Array.isArray(parent) && lastSegment.index < parent.length) {
|
|
38719
|
-
parent[lastSegment.index] = value;
|
|
38720
|
-
count++;
|
|
38721
|
-
}
|
|
38722
|
-
break;
|
|
38723
|
-
case "wildcard":
|
|
38724
|
-
if (Array.isArray(parent)) for (let i = 0; i < parent.length; i++) {
|
|
38725
|
-
parent[i] = value;
|
|
38726
|
-
count++;
|
|
38727
|
-
}
|
|
38728
|
-
break;
|
|
38729
|
-
}
|
|
38730
|
-
}
|
|
38731
|
-
return count;
|
|
40046
|
+
function jsonPathResolve(obj, path) {
|
|
40047
|
+
return walkJsonPath(obj, path).map((entry) => entry.path);
|
|
38732
40048
|
}
|
|
38733
40049
|
|
|
38734
40050
|
//#endregion
|
|
@@ -38920,31 +40236,39 @@ var VersionFiles = class VersionFiles {
|
|
|
38920
40236
|
return content.match(/^(\s+)"/m)?.[1] ?? " ";
|
|
38921
40237
|
}
|
|
38922
40238
|
/**
|
|
38923
|
-
* Update JSON file at specified JSONPath locations
|
|
40239
|
+
* Update a JSON (or JSONC) file at specified JSONPath locations,
|
|
40240
|
+
* preserving the original formatting byte-for-byte.
|
|
38924
40241
|
*
|
|
38925
40242
|
* @remarks
|
|
38926
|
-
*
|
|
38927
|
-
*
|
|
38928
|
-
*
|
|
38929
|
-
*
|
|
40243
|
+
* The write is performed with `jsonc-effect`'s format-preserving
|
|
40244
|
+
* `modify`/`applyEdits` rather than a `JSON.parse`/`JSON.stringify`
|
|
40245
|
+
* round-trip (which always explodes inline arrays one-element-per-line and
|
|
40246
|
+
* drops comments). Each JSONPath expression is resolved to concrete
|
|
40247
|
+
* `(string | number)[]` paths against the parsed document, and each
|
|
40248
|
+
* concrete path becomes a minimal text edit that touches only the target
|
|
40249
|
+
* value's span — so inline arrays, comments,
|
|
40250
|
+
* indentation, and the trailing-newline preference all survive; a one-line
|
|
40251
|
+
* version bump produces a one-line diff.
|
|
40252
|
+
*
|
|
40253
|
+
* Insertion semantics: a concrete, wildcard-free JSONPath whose leaf
|
|
40254
|
+
* property does not exist yet is inserted after the last sibling using the
|
|
40255
|
+
* document's detected indent (the one case where indent detection still
|
|
40256
|
+
* matters). Wildcard expressions only ever update existing matches. Returns
|
|
40257
|
+
* `undefined` (no write) when nothing was updated or inserted.
|
|
38930
40258
|
*
|
|
38931
40259
|
* @param filePath - Absolute path to the JSON file
|
|
38932
40260
|
* @param jsonPaths - JSONPath expressions to update
|
|
38933
40261
|
* @param version - New version string
|
|
38934
40262
|
* @returns Update result, or `undefined` if no changes were made
|
|
40263
|
+
*
|
|
40264
|
+
* @see {@link jsonPathResolve} for concrete-path enumeration
|
|
40265
|
+
* @see {@link VersionFiles.applyVersionEdit} for the per-path edit
|
|
38935
40266
|
*/
|
|
38936
40267
|
static updateFile(filePath, jsonPaths, version) {
|
|
38937
|
-
const
|
|
38938
|
-
const
|
|
38939
|
-
|
|
38940
|
-
|
|
38941
|
-
const previousValues = jsonPaths.flatMap((jp) => jsonPathGet(obj, jp));
|
|
38942
|
-
let totalUpdated = 0;
|
|
38943
|
-
for (const jp of jsonPaths) totalUpdated += jsonPathSet(obj, jp, version);
|
|
38944
|
-
if (totalUpdated === 0) return;
|
|
38945
|
-
let output = JSON.stringify(obj, null, indent);
|
|
38946
|
-
if (trailingNewline) output += "\n";
|
|
38947
|
-
writeFileSync(filePath, output, "utf-8");
|
|
40268
|
+
const original = readFileSync(filePath, "utf-8");
|
|
40269
|
+
const { content, previousValues, totalChanged } = VersionFiles.computeUpdate(original, jsonPaths, version);
|
|
40270
|
+
if (totalChanged === 0) return;
|
|
40271
|
+
writeFileSync(filePath, content, "utf-8");
|
|
38948
40272
|
return {
|
|
38949
40273
|
filePath,
|
|
38950
40274
|
jsonPaths,
|
|
@@ -38953,6 +40277,83 @@ var VersionFiles = class VersionFiles {
|
|
|
38953
40277
|
};
|
|
38954
40278
|
}
|
|
38955
40279
|
/**
|
|
40280
|
+
* Compute the full update for a document without touching the filesystem:
|
|
40281
|
+
* the edited content, the previous values at every matched path, and how
|
|
40282
|
+
* many locations actually changed.
|
|
40283
|
+
*
|
|
40284
|
+
* @remarks
|
|
40285
|
+
* This is the single decision path shared by {@link VersionFiles.updateFile}
|
|
40286
|
+
* and the dry-run branches of the two process methods, so a preview reports
|
|
40287
|
+
* exactly the files a real run would write — including pending inserts of a
|
|
40288
|
+
* not-yet-existing wildcard-free leaf, and excluding same-value no-ops.
|
|
40289
|
+
*
|
|
40290
|
+
* @param original - Document text as read from disk
|
|
40291
|
+
* @param jsonPaths - JSONPath expressions to update
|
|
40292
|
+
* @param version - New version string
|
|
40293
|
+
* @returns The updated content, previous values, and changed-location count
|
|
40294
|
+
*/
|
|
40295
|
+
static computeUpdate(original, jsonPaths, version) {
|
|
40296
|
+
let content = original;
|
|
40297
|
+
const obj = Effect.runSync(parse$2(content));
|
|
40298
|
+
const previousValues = jsonPaths.flatMap((jp) => jsonPathGet(obj, jp));
|
|
40299
|
+
const indent = VersionFiles.detectIndent(content);
|
|
40300
|
+
const eol = content.includes("\r\n") ? "\r\n" : "\n";
|
|
40301
|
+
let totalChanged = 0;
|
|
40302
|
+
for (const jp of jsonPaths) {
|
|
40303
|
+
const segments = parseJsonPath(jp);
|
|
40304
|
+
if (segments.length === 0) continue;
|
|
40305
|
+
const hasWildcard = segments.some((segment) => segment.type === "wildcard");
|
|
40306
|
+
let concretePaths;
|
|
40307
|
+
if (hasWildcard) concretePaths = jsonPathResolve(obj, jp);
|
|
40308
|
+
else {
|
|
40309
|
+
const direct = segments.map((segment) => segment.type === "property" ? segment.key : segment.index);
|
|
40310
|
+
concretePaths = jsonPathResolve(obj, jp).length > 0 || typeof direct[direct.length - 1] === "string" ? [direct] : [];
|
|
40311
|
+
}
|
|
40312
|
+
for (const concretePath of concretePaths) {
|
|
40313
|
+
const updated = VersionFiles.applyVersionEdit(content, concretePath, version, indent, eol);
|
|
40314
|
+
if (updated !== void 0) {
|
|
40315
|
+
content = updated;
|
|
40316
|
+
totalChanged += 1;
|
|
40317
|
+
}
|
|
40318
|
+
}
|
|
40319
|
+
}
|
|
40320
|
+
return {
|
|
40321
|
+
content,
|
|
40322
|
+
previousValues,
|
|
40323
|
+
totalChanged
|
|
40324
|
+
};
|
|
40325
|
+
}
|
|
40326
|
+
/**
|
|
40327
|
+
* Compute the format-preserving edit for a single concrete path, returning
|
|
40328
|
+
* the updated document, or `undefined` when nothing changed.
|
|
40329
|
+
*
|
|
40330
|
+
* @remarks
|
|
40331
|
+
* Delegates to `jsonc-effect`'s {@link modify} + {@link applyEdits}
|
|
40332
|
+
* (requires `jsonc-effect >= 0.3.1`, whose edit spans touch only the target
|
|
40333
|
+
* value), so every other byte of the document is preserved. When the leaf
|
|
40334
|
+
* of a wildcard-free path does not exist, `modify` inserts the property
|
|
40335
|
+
* after the last sibling using the supplied formatting options — the only
|
|
40336
|
+
* case where the detected indent matters. A path whose parent is missing or
|
|
40337
|
+
* not an object cannot be navigated; the resulting modification error is
|
|
40338
|
+
* caught and reported as "no change" so the file is left alone.
|
|
40339
|
+
*
|
|
40340
|
+
* @param content - Current document text
|
|
40341
|
+
* @param concretePath - A wildcard-free `(string | number)[]` path
|
|
40342
|
+
* @param version - New version string
|
|
40343
|
+
* @param indentUnit - One indentation level, for inserted text
|
|
40344
|
+
* @param eol - End-of-line sequence, for inserted text
|
|
40345
|
+
* @returns The updated document, or `undefined` if the path was unchanged
|
|
40346
|
+
*/
|
|
40347
|
+
static applyVersionEdit(content, concretePath, version, indentUnit, eol) {
|
|
40348
|
+
const insertSpaces = !indentUnit.includes(" ");
|
|
40349
|
+
const program = modify(content, [...concretePath], version, { formattingOptions: {
|
|
40350
|
+
insertSpaces,
|
|
40351
|
+
tabSize: insertSpaces ? indentUnit.length : 1,
|
|
40352
|
+
eol
|
|
40353
|
+
} }).pipe(Effect.flatMap((edits) => applyEdits$1(content, edits)), Effect.map((updated) => updated === content ? void 0 : updated), Effect.catchTag("JsoncModificationError", () => Effect.succeed(void 0)));
|
|
40354
|
+
return Effect.runSync(program);
|
|
40355
|
+
}
|
|
40356
|
+
/**
|
|
38956
40357
|
* Orchestrate the full version file update flow.
|
|
38957
40358
|
*
|
|
38958
40359
|
* @remarks
|
|
@@ -38978,9 +40379,8 @@ var VersionFiles = class VersionFiles {
|
|
|
38978
40379
|
try {
|
|
38979
40380
|
if (dryRun) {
|
|
38980
40381
|
const content = readFileSync(filePath, "utf-8");
|
|
38981
|
-
const
|
|
38982
|
-
|
|
38983
|
-
if (previousValues.length > 0) updates.push({
|
|
40382
|
+
const { previousValues, totalChanged } = VersionFiles.computeUpdate(content, jsonPaths, version);
|
|
40383
|
+
if (totalChanged > 0) updates.push({
|
|
38984
40384
|
filePath,
|
|
38985
40385
|
jsonPaths,
|
|
38986
40386
|
version,
|
|
@@ -39024,9 +40424,8 @@ var VersionFiles = class VersionFiles {
|
|
|
39024
40424
|
for (const filePath of vf.matchedFiles) try {
|
|
39025
40425
|
if (dryRun) {
|
|
39026
40426
|
const content = readFileSync(filePath, "utf-8");
|
|
39027
|
-
const
|
|
39028
|
-
|
|
39029
|
-
if (previousValues.length > 0) updates.push({
|
|
40427
|
+
const { previousValues, totalChanged } = VersionFiles.computeUpdate(content, jsonPaths, scope.version);
|
|
40428
|
+
if (totalChanged > 0) updates.push({
|
|
39030
40429
|
filePath,
|
|
39031
40430
|
jsonPaths,
|
|
39032
40431
|
version: scope.version,
|