@ansonlai/docx-redline-js 0.7.2 → 0.8.1
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/AGENTS.md +15 -10
- package/ARCHITECTURE.md +30 -10
- package/CHANGELOG.md +539 -431
- package/README.md +331 -309
- package/adapters/xml-adapter.js +84 -56
- package/core/sha256.js +120 -0
- package/dist/docx-redline-js.esm.js +8982 -693
- package/dist/docx-redline-js.esm.js.map +4 -4
- package/dist/docx-redline-js.esm.min.js +102 -89
- package/dist/docx-redline-js.esm.min.js.map +4 -4
- package/dist/docx-redline.bundle.cjs +28305 -0
- package/dist/docx-redline.bundle.cjs.map +7 -0
- package/dist/docx-redline.bundle.js +28296 -0
- package/dist/docx-redline.bundle.js.map +7 -0
- package/docs/AGENT_FAST_START.md +2 -1
- package/docs/AGENT_KNOWLEDGE_BASE.md +480 -393
- package/docs/SKILL_AUTHORING.md +5 -2
- package/docs/TESTING.md +2 -1
- package/docs/schemas/document-operations.schema.json +29 -0
- package/document/docx-document.d.ts +39 -0
- package/document/docx-document.js +1010 -0
- package/document/zip-archive.js +258 -0
- package/engine/reconstruction-writer.js +18 -0
- package/index.d.ts +598 -531
- package/index.js +349 -340
- package/node/cli-help.js +5 -5
- package/node/cli.js +760 -754
- package/node/docx-document.js +11 -355
- package/node/index.d.ts +1 -1
- package/node/zip-archive.js +28 -38
- package/package.json +14 -11
- package/scripts/build.mjs +40 -5
- package/scripts/generate-word-comment-edge-case-fixture.ps1 +58 -0
- package/scripts/generate-word-comment-thread-fixture.ps1 +36 -0
- package/scripts/generate-word-header-footer-fixture.ps1 +32 -0
- package/scripts/generate-word-multi-section-fixture.ps1 +27 -0
- package/scripts/generate-word-package-integrity-cases.mjs +141 -0
- package/scripts/generate-word-thread-state-fixtures.ps1 +50 -0
- package/scripts/word-com-package-integrity.ps1 +98 -0
- package/services/batch-operation-orchestrator.js +262 -259
- package/services/comment-replies.js +96 -95
- package/services/comment-thread-parts.js +280 -0
- package/services/document-inspection.js +366 -365
- package/services/document-operation-applier.js +230 -202
- package/services/document-operation-contract.js +17 -2
- package/services/error-recovery.js +6 -0
- package/services/headers-footers.js +206 -0
- package/services/operation-batch-compiler.js +1 -0
- package/services/operation-preflight.js +231 -218
- package/services/package-parts.js +80 -0
- package/services/revision-token.js +11 -7
- package/services/standalone-docx-plumbing.js +631 -569
- package/services/standalone-operation-runner.d.ts +19 -3
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* revision tokens over package entries or document parts.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { sha256 } from '../core/sha256.js';
|
|
9
|
+
|
|
8
10
|
const textEncoder = new TextEncoder();
|
|
9
11
|
|
|
10
12
|
/**
|
|
@@ -145,6 +147,8 @@ export function buildRevisionTokenFraming({ scope, entries = [] }) {
|
|
|
145
147
|
/**
|
|
146
148
|
* Calculates a SHA-256 revision token asynchronously using Web Crypto or a custom digest function.
|
|
147
149
|
*
|
|
150
|
+
* Defaults to the built-in pure-JS SHA-256 implementation when Web Crypto is unavailable.
|
|
151
|
+
*
|
|
148
152
|
* @param {{ scope: string, entries: Array<any>, digestFn?: (bytes: Uint8Array) => Promise<string> }} options
|
|
149
153
|
* @returns {Promise<{ algorithm: 'sha256', version: number, scope: string, value: string, coveredParts: string[] }>}
|
|
150
154
|
*/
|
|
@@ -159,7 +163,7 @@ export async function computeRevisionToken({ scope, entries = [], digestFn = nul
|
|
|
159
163
|
const hashBytes = new Uint8Array(hashBuf);
|
|
160
164
|
hashHex = Array.from(hashBytes).map(b => b.toString(16).padStart(2, '0')).join('');
|
|
161
165
|
} else {
|
|
162
|
-
|
|
166
|
+
hashHex = sha256(framing);
|
|
163
167
|
}
|
|
164
168
|
|
|
165
169
|
return {
|
|
@@ -172,17 +176,17 @@ export async function computeRevisionToken({ scope, entries = [], digestFn = nul
|
|
|
172
176
|
}
|
|
173
177
|
|
|
174
178
|
/**
|
|
175
|
-
* Calculates a SHA-256 revision token synchronously using a
|
|
179
|
+
* Calculates a SHA-256 revision token synchronously using pure-JS SHA-256 or a custom digest function.
|
|
176
180
|
*
|
|
177
|
-
* @param {{ scope: string, entries: Array<any>, digestFn
|
|
181
|
+
* @param {{ scope: string, entries: Array<any>, digestFn?: (bytes: Uint8Array) => string }} options
|
|
178
182
|
* @returns {{ algorithm: 'sha256', version: number, scope: string, value: string, coveredParts: string[] }}
|
|
179
183
|
*/
|
|
180
|
-
export function computeRevisionTokenSync({ scope, entries = [], digestFn }) {
|
|
181
|
-
if (typeof digestFn !== 'function') {
|
|
182
|
-
throw new TypeError('computeRevisionTokenSync requires a synchronous digestFn.');
|
|
184
|
+
export function computeRevisionTokenSync({ scope, entries = [], digestFn = null }) {
|
|
185
|
+
if (digestFn != null && typeof digestFn !== 'function') {
|
|
186
|
+
throw new TypeError('computeRevisionTokenSync requires a synchronous digestFn when specified.');
|
|
183
187
|
}
|
|
184
188
|
const { framing, coveredParts, version } = buildRevisionTokenFraming({ scope, entries });
|
|
185
|
-
const hashHex = digestFn(framing);
|
|
189
|
+
const hashHex = typeof digestFn === 'function' ? digestFn(framing) : sha256(framing);
|
|
186
190
|
return {
|
|
187
191
|
algorithm: 'sha256',
|
|
188
192
|
version,
|