@json-to-office/core-docx 0.13.0 → 0.14.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.
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Revision (tracked-change) rendering utilities
3
+ *
4
+ * Turns `revision.segments` from the JSON definition into native Word
5
+ * revision runs (w:ins / w:del) via docx.js InsertedTextRun / DeletedTextRun.
6
+ */
7
+ import { TextRun, InsertedTextRun, DeletedTextRun } from 'docx';
8
+ import type { IRunOptions, ParagraphChild } from 'docx';
9
+ import type { Revision } from '@json-to-office/shared-docx';
10
+ export declare const DEFAULT_REVISION_AUTHOR = "json-to-office";
11
+ export declare const DEFAULT_REVISION_DATE = "1970-01-01T00:00:00Z";
12
+ /**
13
+ * OOXML requires a numeric id on every w:ins / w:del element, unique within
14
+ * one document. The counter is process-wide and never reset between renders:
15
+ * concurrent renderDocument calls then draw from disjoint id sets, so
16
+ * intra-document uniqueness holds even when renders interleave (a per-render
17
+ * reset would let one render clear the counter mid-flight for another).
18
+ */
19
+ declare class RevisionIdRegistry {
20
+ private counter;
21
+ next(): number;
22
+ /** Test-only: deterministic ids for snapshot assertions. */
23
+ clear(): void;
24
+ }
25
+ export declare const globalRevisionIdRegistry: RevisionIdRegistry;
26
+ export type RevisionRun = TextRun | InsertedTextRun | DeletedTextRun;
27
+ type RevisionBaseStyle = Omit<IRunOptions, 'text' | 'children'>;
28
+ /**
29
+ * Build paragraph children from revision segments.
30
+ *
31
+ * Segment text is rendered literally (no markdown parsing): a `**` opened in
32
+ * one segment could close in another, so decorator parsing cannot work
33
+ * per-segment. The diff engine strips markdown before diffing for this
34
+ * reason. Placeholders ({DATE}, {PAGE}, ...) are resolved for unchanged
35
+ * segments; inside inserted/deleted text they render literally (the diff
36
+ * summary reports those).
37
+ */
38
+ export declare function createRevisionRuns(revision: Revision, baseStyle: RevisionBaseStyle): ParagraphChild[];
39
+ /**
40
+ * True when a component carries revision data anywhere in its subtree
41
+ * (own props, list items, or any descendant), meaning its render output
42
+ * embeds document-scoped revision ids and must not be served from the
43
+ * cross-document component cache.
44
+ */
45
+ export declare function componentHasRevision(component: {
46
+ props?: unknown;
47
+ children?: unknown[];
48
+ }): boolean;
49
+ export {};
50
+ //# sourceMappingURL=revisionUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revisionUtils.d.ts","sourceRoot":"","sources":["../../src/utils/revisionUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAK5D,eAAO,MAAM,uBAAuB,mBAAmB,CAAC;AAExD,eAAO,MAAM,qBAAqB,yBAAyB,CAAC;AAE5D;;;;;;GAMG;AACH,cAAM,kBAAkB;IACtB,OAAO,CAAC,OAAO,CAAK;IAEpB,IAAI,IAAI,MAAM;IAKd,4DAA4D;IAC5D,KAAK,IAAI,IAAI;CAGd;AAED,eAAO,MAAM,wBAAwB,oBAA2B,CAAC;AAEjE,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,eAAe,GAAG,cAAc,CAAC;AAIrE,KAAK,iBAAiB,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC;AAgBhE;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,iBAAiB,GAC3B,cAAc,EAAE,CAoDlB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE;IAC9C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB,GAAG,OAAO,CA6BV"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@json-to-office/core-docx",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Core DOCX document generation engine",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,8 +22,8 @@
22
22
  "adm-zip": "0.5.16",
23
23
  "date-fns": "3.6.0",
24
24
  "probe-image-size": "7.2.3",
25
- "@json-to-office/shared": "^0.13.0",
26
- "@json-to-office/shared-docx": "^0.13.0"
25
+ "@json-to-office/shared": "^0.13.2",
26
+ "@json-to-office/shared-docx": "^0.14.0"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "docx": "9.5.1"