@ansonlai/docx-redline-js 0.7.2 → 0.8.0
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 +58 -3
- package/adapters/xml-adapter.js +84 -56
- package/core/sha256.js +120 -0
- package/dist/docx-redline-js.esm.js +7969 -600
- package/dist/docx-redline-js.esm.js.map +4 -4
- package/dist/docx-redline-js.esm.min.js +115 -102
- package/dist/docx-redline-js.esm.min.js.map +4 -4
- package/dist/docx-redline.bundle.cjs +27385 -0
- package/dist/docx-redline.bundle.cjs.map +7 -0
- package/dist/docx-redline.bundle.js +27376 -0
- package/dist/docx-redline.bundle.js.map +7 -0
- package/docs/AGENT_FAST_START.md +2 -1
- package/docs/AGENT_KNOWLEDGE_BASE.md +412 -386
- package/docs/SKILL_AUTHORING.md +5 -2
- package/docs/TESTING.md +2 -1
- package/document/docx-document.d.ts +39 -0
- package/document/docx-document.js +616 -0
- package/document/zip-archive.js +258 -0
- package/index.d.ts +45 -1
- package/index.js +8 -0
- package/node/docx-document.js +11 -355
- package/node/zip-archive.js +28 -38
- package/package.json +13 -11
- package/scripts/build.mjs +40 -5
- package/services/revision-token.js +11 -7
package/docs/SKILL_AUTHORING.md
CHANGED
|
@@ -78,8 +78,11 @@ node emit-operations.mjs | docx-redline apply input.docx --operations - --profil
|
|
|
78
78
|
```
|
|
79
79
|
|
|
80
80
|
Use `JSON.stringify` or a structured tool API. Never demonstrate `echo`, a
|
|
81
|
-
heredoc, or shell-interpolated document text.
|
|
82
|
-
|
|
81
|
+
heredoc, or shell-interpolated document text. In JavaScript/TypeScript runtimes
|
|
82
|
+
(Node.js, browsers, Cloudflare Workers, Deno, Bun, or sandboxed environments like
|
|
83
|
+
n8n), an in-process wrapper should call `openDocx(uint8Array)` directly from
|
|
84
|
+
`@ansonlai/docx-redline-js` (or `@ansonlai/docx-redline-js/bundle` for zero-dependency
|
|
85
|
+
standalone sandboxes) and return the structured result instead of recreating CLI
|
|
83
86
|
serialization, ZIP handling, targeting, validation, or rollback.
|
|
84
87
|
|
|
85
88
|
## Ordinary generated workflow
|
package/docs/TESTING.md
CHANGED
|
@@ -31,7 +31,8 @@ fixtures rarely contain.
|
|
|
31
31
|
| Live-session accuracy and instrumentation | `node tests/performance_phase1_session_tests.mjs` | One full parse/serialization, sequential semantic equivalence, exact accepted/rejected text, valid revisions, list/table/comment/highlight preservation, savepoint no-ops, and zero-serialization rollback | Desktop Word rendering |
|
|
32
32
|
| Target hot-path parity | `node tests/performance_phase3_target_hot_paths_tests.mjs` | Cached and uncached resolution metadata parity, duplicate safety, snapshots, session invalidation, and pointer-based revision-ID seeding | Machine-independent latency thresholds |
|
|
33
33
|
| List and text-walker parity | `node tests/performance_phase4_list_and_text_parity_tests.mjs` | One shared marker vocabulary and canonical/specialized visible-text agreement across structural characters and revision views | That all specialized mappings are interchangeable |
|
|
34
|
-
|
|
|
34
|
+
| Universal document facade & ZIP | `node tests/universal_docx_document_tests.mjs`, `node tests/universal_zip_archive_tests.mjs`, `node tests/universal_facade_edge_cases_tests.mjs` | Universal `Uint8Array` binary handling, `fflate` compression/decompression, optimistic concurrency, and complete-DOCX operations without Node built-ins | Desktop Word rendering |
|
|
35
|
+
| Sandbox bundle isolation | `node tests/sandbox_bundle_isolation_tests.mjs` | Zero-dependency standalone ESM/CJS bundles execute in restricted VM sandboxes without `process`, `Buffer`, or `require`, with zero Node built-in imports | Web Worker latency |
|
|
35
36
|
| Cross-author revision slicing | `node tests/cross_author_slicing_fixtures_tests.mjs`, `node tests/cross_author_carrier_splitting_tests.mjs`, `node tests/cross_author_slicing_synthetic_tests.mjs`, `node tests/cross_author_slicing_real_tests.mjs`, `node tests/cross_author_slicing_hyperlink_roundtrip_tests.mjs`, `node tests/cross_author_slicing_insertion_stress_tests.mjs` | Word-native `<w:ins>` splitting, `<w:del>` nesting, multi-author stacking, straddle boundaries, synthetic matrix (SYN-01..12d), strict package differential replay (PKG-01..06), exact hyperlink/NBSP round trips, and 76 insertion stress scenarios | Non-Word consumers beyond OpenXML XSD validation |
|
|
36
37
|
|
|
37
38
|
The package-facade regression opens a real ZIP buffer, adds a comment beside an
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { DocumentOperation, DocumentOperationBatchResult, OperationPreflightResult, StandaloneRunnerOptions } from '../services/standalone-operation-runner.js';
|
|
2
|
+
import type { DocumentInspectionOptions, DocumentInspectionResult, RevisionToken } from '../index.js';
|
|
3
|
+
|
|
4
|
+
export interface DocxApplyOptions extends StandaloneRunnerOptions {
|
|
5
|
+
author?: string;
|
|
6
|
+
validate?: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface DocxApplyResult extends DocumentOperationBatchResult {
|
|
10
|
+
written: boolean;
|
|
11
|
+
uint8Array: Uint8Array;
|
|
12
|
+
buffer: Uint8Array;
|
|
13
|
+
inspection?: DocumentInspectionResult;
|
|
14
|
+
artifactsChanged?: string[];
|
|
15
|
+
validation?: { originalIssues: unknown[]; generatedIssues: unknown[] };
|
|
16
|
+
issues?: unknown[];
|
|
17
|
+
toUint8Array(): Uint8Array;
|
|
18
|
+
toBuffer(): Uint8Array;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class DocxDocument {
|
|
22
|
+
constructor(input: Uint8Array | ArrayBuffer | string);
|
|
23
|
+
readonly originalBytes: Uint8Array;
|
|
24
|
+
readonly originalBuffer: Uint8Array;
|
|
25
|
+
readonly entries: Map<string, Uint8Array>;
|
|
26
|
+
inspect(options?: DocumentInspectionOptions): DocumentInspectionResult;
|
|
27
|
+
getRevisionToken(): RevisionToken;
|
|
28
|
+
readonly revisionToken: RevisionToken;
|
|
29
|
+
preflight(operations: DocumentOperation[], author?: string, options?: StandaloneRunnerOptions): OperationPreflightResult;
|
|
30
|
+
applyOperations(operations: DocumentOperation[], options?: DocxApplyOptions): Promise<DocxApplyResult>;
|
|
31
|
+
resolveRevisions(action: 'accept' | 'reject', options?: { author?: string; allAuthors?: boolean; validate?: boolean }): Promise<DocxApplyResult>;
|
|
32
|
+
deleteComments(options?: { author?: string; allAuthors?: boolean; validate?: boolean }): Promise<DocxApplyResult>;
|
|
33
|
+
toUint8Array(): Uint8Array;
|
|
34
|
+
toBuffer(): Uint8Array;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function computePackageRevisionToken(input: unknown): RevisionToken;
|
|
38
|
+
|
|
39
|
+
export function openDocx(input: Uint8Array | ArrayBuffer | string): DocxDocument;
|