@savvy-web/silk 2.1.1 → 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.
@@ -9246,20 +9246,74 @@ declare class VersionFiles {
9246
9246
  */
9247
9247
  static detectIndent(content: string): string;
9248
9248
  /**
9249
- * Update JSON file at specified JSONPath locations.
9249
+ * Update a JSON (or JSONC) file at specified JSONPath locations,
9250
+ * preserving the original formatting byte-for-byte.
9250
9251
  *
9251
9252
  * @remarks
9252
- * Reads the file, detects its indentation style and trailing newline
9253
- * preference, applies all JSONPath updates via {@link jsonPathSet},
9254
- * and writes the result back preserving the original formatting.
9255
- * Returns `undefined` if no JSONPath locations matched (no write occurs).
9253
+ * The write is performed with `jsonc-effect`'s format-preserving
9254
+ * `modify`/`applyEdits` rather than a `JSON.parse`/`JSON.stringify`
9255
+ * round-trip (which always explodes inline arrays one-element-per-line and
9256
+ * drops comments). Each JSONPath expression is resolved to concrete
9257
+ * `(string | number)[]` paths against the parsed document, and each
9258
+ * concrete path becomes a minimal text edit that touches only the target
9259
+ * value's span — so inline arrays, comments,
9260
+ * indentation, and the trailing-newline preference all survive; a one-line
9261
+ * version bump produces a one-line diff.
9262
+ *
9263
+ * Insertion semantics: a concrete, wildcard-free JSONPath whose leaf
9264
+ * property does not exist yet is inserted after the last sibling using the
9265
+ * document's detected indent (the one case where indent detection still
9266
+ * matters). Wildcard expressions only ever update existing matches. Returns
9267
+ * `undefined` (no write) when nothing was updated or inserted.
9256
9268
  *
9257
9269
  * @param filePath - Absolute path to the JSON file
9258
9270
  * @param jsonPaths - JSONPath expressions to update
9259
9271
  * @param version - New version string
9260
9272
  * @returns Update result, or `undefined` if no changes were made
9273
+ *
9274
+ * @see {@link jsonPathResolve} for concrete-path enumeration
9275
+ * @see {@link VersionFiles.applyVersionEdit} for the per-path edit
9261
9276
  */
9262
9277
  static updateFile(filePath: string, jsonPaths: readonly string[], version: string): VersionFileUpdate | undefined;
9278
+ /**
9279
+ * Compute the full update for a document without touching the filesystem:
9280
+ * the edited content, the previous values at every matched path, and how
9281
+ * many locations actually changed.
9282
+ *
9283
+ * @remarks
9284
+ * This is the single decision path shared by {@link VersionFiles.updateFile}
9285
+ * and the dry-run branches of the two process methods, so a preview reports
9286
+ * exactly the files a real run would write — including pending inserts of a
9287
+ * not-yet-existing wildcard-free leaf, and excluding same-value no-ops.
9288
+ *
9289
+ * @param original - Document text as read from disk
9290
+ * @param jsonPaths - JSONPath expressions to update
9291
+ * @param version - New version string
9292
+ * @returns The updated content, previous values, and changed-location count
9293
+ */
9294
+ private static computeUpdate;
9295
+ /**
9296
+ * Compute the format-preserving edit for a single concrete path, returning
9297
+ * the updated document, or `undefined` when nothing changed.
9298
+ *
9299
+ * @remarks
9300
+ * Delegates to `jsonc-effect`'s {@link modify} + {@link applyEdits}
9301
+ * (requires `jsonc-effect >= 0.3.1`, whose edit spans touch only the target
9302
+ * value), so every other byte of the document is preserved. When the leaf
9303
+ * of a wildcard-free path does not exist, `modify` inserts the property
9304
+ * after the last sibling using the supplied formatting options — the only
9305
+ * case where the detected indent matters. A path whose parent is missing or
9306
+ * not an object cannot be navigated; the resulting modification error is
9307
+ * caught and reported as "no change" so the file is left alone.
9308
+ *
9309
+ * @param content - Current document text
9310
+ * @param concretePath - A wildcard-free `(string | number)[]` path
9311
+ * @param version - New version string
9312
+ * @param indentUnit - One indentation level, for inserted text
9313
+ * @param eol - End-of-line sequence, for inserted text
9314
+ * @returns The updated document, or `undefined` if the path was unchanged
9315
+ */
9316
+ private static applyVersionEdit;
9263
9317
  /**
9264
9318
  * Orchestrate the full version file update flow.
9265
9319
  *
@@ -9246,20 +9246,74 @@ declare class VersionFiles {
9246
9246
  */
9247
9247
  static detectIndent(content: string): string;
9248
9248
  /**
9249
- * Update JSON file at specified JSONPath locations.
9249
+ * Update a JSON (or JSONC) file at specified JSONPath locations,
9250
+ * preserving the original formatting byte-for-byte.
9250
9251
  *
9251
9252
  * @remarks
9252
- * Reads the file, detects its indentation style and trailing newline
9253
- * preference, applies all JSONPath updates via {@link jsonPathSet},
9254
- * and writes the result back preserving the original formatting.
9255
- * Returns `undefined` if no JSONPath locations matched (no write occurs).
9253
+ * The write is performed with `jsonc-effect`'s format-preserving
9254
+ * `modify`/`applyEdits` rather than a `JSON.parse`/`JSON.stringify`
9255
+ * round-trip (which always explodes inline arrays one-element-per-line and
9256
+ * drops comments). Each JSONPath expression is resolved to concrete
9257
+ * `(string | number)[]` paths against the parsed document, and each
9258
+ * concrete path becomes a minimal text edit that touches only the target
9259
+ * value's span — so inline arrays, comments,
9260
+ * indentation, and the trailing-newline preference all survive; a one-line
9261
+ * version bump produces a one-line diff.
9262
+ *
9263
+ * Insertion semantics: a concrete, wildcard-free JSONPath whose leaf
9264
+ * property does not exist yet is inserted after the last sibling using the
9265
+ * document's detected indent (the one case where indent detection still
9266
+ * matters). Wildcard expressions only ever update existing matches. Returns
9267
+ * `undefined` (no write) when nothing was updated or inserted.
9256
9268
  *
9257
9269
  * @param filePath - Absolute path to the JSON file
9258
9270
  * @param jsonPaths - JSONPath expressions to update
9259
9271
  * @param version - New version string
9260
9272
  * @returns Update result, or `undefined` if no changes were made
9273
+ *
9274
+ * @see {@link jsonPathResolve} for concrete-path enumeration
9275
+ * @see {@link VersionFiles.applyVersionEdit} for the per-path edit
9261
9276
  */
9262
9277
  static updateFile(filePath: string, jsonPaths: readonly string[], version: string): VersionFileUpdate | undefined;
9278
+ /**
9279
+ * Compute the full update for a document without touching the filesystem:
9280
+ * the edited content, the previous values at every matched path, and how
9281
+ * many locations actually changed.
9282
+ *
9283
+ * @remarks
9284
+ * This is the single decision path shared by {@link VersionFiles.updateFile}
9285
+ * and the dry-run branches of the two process methods, so a preview reports
9286
+ * exactly the files a real run would write — including pending inserts of a
9287
+ * not-yet-existing wildcard-free leaf, and excluding same-value no-ops.
9288
+ *
9289
+ * @param original - Document text as read from disk
9290
+ * @param jsonPaths - JSONPath expressions to update
9291
+ * @param version - New version string
9292
+ * @returns The updated content, previous values, and changed-location count
9293
+ */
9294
+ private static computeUpdate;
9295
+ /**
9296
+ * Compute the format-preserving edit for a single concrete path, returning
9297
+ * the updated document, or `undefined` when nothing changed.
9298
+ *
9299
+ * @remarks
9300
+ * Delegates to `jsonc-effect`'s {@link modify} + {@link applyEdits}
9301
+ * (requires `jsonc-effect >= 0.3.1`, whose edit spans touch only the target
9302
+ * value), so every other byte of the document is preserved. When the leaf
9303
+ * of a wildcard-free path does not exist, `modify` inserts the property
9304
+ * after the last sibling using the supplied formatting options — the only
9305
+ * case where the detected indent matters. A path whose parent is missing or
9306
+ * not an object cannot be navigated; the resulting modification error is
9307
+ * caught and reported as "no change" so the file is left alone.
9308
+ *
9309
+ * @param content - Current document text
9310
+ * @param concretePath - A wildcard-free `(string | number)[]` path
9311
+ * @param version - New version string
9312
+ * @param indentUnit - One indentation level, for inserted text
9313
+ * @param eol - End-of-line sequence, for inserted text
9314
+ * @returns The updated document, or `undefined` if the path was unchanged
9315
+ */
9316
+ private static applyVersionEdit;
9263
9317
  /**
9264
9318
  * Orchestrate the full version file update flow.
9265
9319
  *