pi-hashline-edit-pro 0.11.1 → 0.11.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/package.json +1 -1
- package/src/replace-normalize.ts +15 -0
- package/src/replace.ts +1 -1
package/package.json
CHANGED
package/src/replace-normalize.ts
CHANGED
|
@@ -12,6 +12,16 @@ function coerceEditsArray(edits: unknown): unknown {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
function normalizeEditItem(item: unknown): unknown {
|
|
16
|
+
if (!isRec(item)) return item;
|
|
17
|
+
const record: Record<string, unknown> = { ...item };
|
|
18
|
+
// Rename old_range to hash_range_incl for backward compatibility
|
|
19
|
+
if (has(record, "old_range") && !has(record, "hash_range_incl")) {
|
|
20
|
+
record.hash_range_incl = record.old_range;
|
|
21
|
+
delete record.old_range;
|
|
22
|
+
}
|
|
23
|
+
return record;
|
|
24
|
+
}
|
|
15
25
|
|
|
16
26
|
export function normReq(input: unknown): unknown {
|
|
17
27
|
if (!isRec(input)) {
|
|
@@ -31,5 +41,10 @@ export function normReq(input: unknown): unknown {
|
|
|
31
41
|
record.edits = coerceEditsArray(record.edits);
|
|
32
42
|
}
|
|
33
43
|
|
|
44
|
+
// Normalize each edit item: rename old_range to hash_range_incl
|
|
45
|
+
if (Array.isArray(record.edits)) {
|
|
46
|
+
record.edits = record.edits.map(normalizeEditItem);
|
|
47
|
+
}
|
|
48
|
+
|
|
34
49
|
return record;
|
|
35
50
|
}
|
package/src/replace.ts
CHANGED
|
@@ -99,7 +99,7 @@ export function assertReq(
|
|
|
99
99
|
throw new Error("[E_BAD_SHAPE] Edit request must be an object.");
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
for (const legacyKey of ["oldText", "newText", "old_text", "new_text", "start", "end", "lines"
|
|
102
|
+
for (const legacyKey of ["oldText", "newText", "old_text", "new_text", "start", "end", "lines"]) {
|
|
103
103
|
if (has(request, legacyKey)) {
|
|
104
104
|
throw new Error(
|
|
105
105
|
`[E_LEGACY_SHAPE] "${legacyKey}" is not supported. Use {hash_range_incl: ["<START>", "<END>"], new_lines: [...]}.`
|