@json-to-office/core-docx 1.0.0 → 1.1.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/dist/components/visual.d.ts +6 -6
- package/dist/components/visual.d.ts.map +1 -1
- package/dist/core/desugarExternals.d.ts.map +1 -1
- package/dist/core/flattenVisuals.d.ts.map +1 -1
- package/dist/core/imageResources.d.ts.map +1 -1
- package/dist/core/prerasterizeVisuals.d.ts +10 -4
- package/dist/core/prerasterizeVisuals.d.ts.map +1 -1
- package/dist/index.js +963 -94
- package/dist/index.js.map +1 -1
- package/dist/ir/compiler.d.ts.map +1 -1
- package/dist/ir/features.d.ts +1 -1
- package/dist/ir/features.d.ts.map +1 -1
- package/dist/ir/nativeVisual.d.ts +79 -0
- package/dist/ir/nativeVisual.d.ts.map +1 -0
- package/dist/ir/types.d.ts +110 -1
- package/dist/ir/types.d.ts.map +1 -1
- package/dist/ir/units.d.ts +12 -0
- package/dist/ir/units.d.ts.map +1 -1
- package/dist/ir/validation.d.ts.map +1 -1
- package/dist/plugin/example/index.js +956 -92
- package/dist/plugin/example/index.js.map +1 -1
- package/dist/renderers/docxjs/emit.d.ts.map +1 -1
- package/dist/renderers/docxjs/index.d.ts.map +1 -1
- package/dist/renderers/office-open/emit.d.ts +38 -6
- package/dist/renderers/office-open/emit.d.ts.map +1 -1
- package/dist/renderers/office-open/index.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../src/renderers/docxjs/emit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,aAAa,EAgBb,SAAS,EAMT,KAAK,EAIL,eAAe,EAQf,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAEhB,KAAK,cAAc,EACpB,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EACV,WAAW,E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AAE,cAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/docxjs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAIL,QAAQ,EAUT,MAAM,MAAM,CAAC;AAGd,OAAO,KAAK,EACV,MAAM,EAOP,MAAM,gBAAgB,CAAC;AAOxB,OAAO,KAAK,EAAqB,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,EAKL,KAAK,aAAa,EAEnB,MAAM,QAAQ,CAAC;AAGhB,eAAO,MAAM,kBAAkB,EAAE,cAAyB,CAAC;AAyB3D,wBAAgB,oBAAoB,IAAI,YAAY,CA0BnD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,EAAE,EAAE,MAAM,EACV,SAAS,GAAE,aAAyB,GACnC,QAAQ,CA2CV"}
|
|
@@ -12,17 +12,49 @@
|
|
|
12
12
|
* anything this module cannot express has already been rejected before it is
|
|
13
13
|
* called. Reaching a `throw` here is a bug, not a user error.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
/// <reference types="node" />
|
|
16
|
+
import type { DocxIrBlock, DocxIrFloating, DocxIrInline, DocxIrNumbering, DocxIrParagraph, DocxIrParagraphFormatting, DocxIrRunFormatting, DocxIrSection, DocxIrTable } from '../../ir/types';
|
|
16
17
|
import { emuToPixels } from '../../ir/units';
|
|
17
18
|
type Opts = Record<string, unknown>;
|
|
18
19
|
/**
|
|
19
|
-
* One prepared
|
|
20
|
+
* One prepared image per placement size.
|
|
20
21
|
*
|
|
21
22
|
* A vector image needs a rasterised fallback sized to the placement, and
|
|
22
23
|
* producing it is asynchronous while this layer is not — so the renderer builds
|
|
23
|
-
* the
|
|
24
|
+
* the media first and this only places it.
|
|
25
|
+
*
|
|
26
|
+
* Media rather than a whole picture because the same bytes are placed two
|
|
27
|
+
* different ways: a run-level `picture` states its size as a plain
|
|
28
|
+
* `MediaTransformation`, while a group child states an already-resolved
|
|
29
|
+
* `MediaDataTransformation` with an offset inside the group. Sharing the
|
|
30
|
+
* factory is what keeps a resource embedded once however it is drawn.
|
|
24
31
|
*/
|
|
25
|
-
export
|
|
32
|
+
export interface PreparedImage {
|
|
33
|
+
/** `png`, `jpg`, `svg`, … — the backend's media type tag. */
|
|
34
|
+
type: string;
|
|
35
|
+
data: Buffer;
|
|
36
|
+
/** The raster Word draws when it cannot draw the vector. */
|
|
37
|
+
fallback?: {
|
|
38
|
+
type: string;
|
|
39
|
+
data: Buffer;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The media part name these bytes are stored under.
|
|
43
|
+
*
|
|
44
|
+
* A run-level picture lets the backend allocate one. A *group child* cannot:
|
|
45
|
+
* the backend registers grouped media with a factory that ignores the name
|
|
46
|
+
* it is offered, so an unnamed child ends up referencing `{undefined}` and
|
|
47
|
+
* the package ships a part called `media/undefined`. Deriving the name from
|
|
48
|
+
* the resource and its drawn size keeps it deterministic and keeps two
|
|
49
|
+
* identical placements sharing one part.
|
|
50
|
+
*/
|
|
51
|
+
fileName: string;
|
|
52
|
+
fallbackFileName?: string;
|
|
53
|
+
}
|
|
54
|
+
export type ImageMediaFactory = (placement: {
|
|
55
|
+
widthEmu: number;
|
|
56
|
+
heightEmu: number;
|
|
57
|
+
}) => PreparedImage;
|
|
26
58
|
/**
|
|
27
59
|
* What emitting a document needs beyond the IR itself.
|
|
28
60
|
*
|
|
@@ -34,8 +66,8 @@ export type ImagePictureFactory = (image: DocxIrImageRun, drawingId: number) =>
|
|
|
34
66
|
* is deterministic and cannot leak between documents.
|
|
35
67
|
*/
|
|
36
68
|
export interface EmitContext {
|
|
37
|
-
/** Prepared
|
|
38
|
-
pictures: ReadonlyMap<string,
|
|
69
|
+
/** Prepared image media, keyed by IR resource id. */
|
|
70
|
+
pictures: ReadonlyMap<string, ImageMediaFactory>;
|
|
39
71
|
/** Allocate the next `wp:docPr` id for this document. */
|
|
40
72
|
nextDrawingId: () => number;
|
|
41
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../src/renderers/office-open/emit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG
|
|
1
|
+
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../src/renderers/office-open/emit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;;AAGH,OAAO,KAAK,EACV,WAAW,EAQX,cAAc,EAId,YAAY,EACZ,eAAe,EACf,eAAe,EACf,yBAAyB,EAGzB,mBAAmB,EACnB,aAAa,EAGb,WAAW,EAKZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAe,MAAM,gBAAgB,CAAC;AAE1D,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpC;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,aAAa;IAC5B,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,4DAA4D;IAC5D,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C;;;;;;;;;OASG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,SAAS,EAAE;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,KAAK,aAAa,CAAC;AAEpB;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW;IAC1B,qDAAqD;IACrD,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACjD,yDAAyD;IACzD,aAAa,EAAE,MAAM,MAAM,CAAC;CAC7B;AAED,mEAAmE;AACnE,wBAAgB,YAAY,IAAI,WAAW,CAG1C;AAsBD,wBAAgB,aAAa,CAC3B,UAAU,EAAE,mBAAmB,GAAG,SAAS,GAC1C,IAAI,CAwCN;AAUD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,SAAS,YAAY,EAAE,EACjC,GAAG,GAAE,WAA4B,GAChC,IAAI,EAAE,CA2HR;AA8CD,sDAAsD;AACtD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI,CAsD9D;AA0RD,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,yBAAyB,GAAG,SAAS,GAChD,IAAI,CAgEN;AAOD,wBAAgB,SAAS,CACvB,KAAK,EAAE,eAAe,EACtB,GAAG,GAAE,WAA4B,GAChC,IAAI,CAsBN;AA+CD,iFAAiF;AACjF,wBAAgB,KAAK,CACnB,KAAK,EAAE,WAAW,EAClB,GAAG,GAAE,WAA4B,GAChC,IAAI,CAWN;AA4ED,wBAAgB,KAAK,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI,CAuBhE;AA0HD,wBAAgB,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI,CA0FpE;AA4CD,wBAAgB,eAAe,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI,CAgChE;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/office-open/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EACV,MAAM,EAIP,MAAM,gBAAgB,CAAC;AAMxB,OAAO,KAAK,EAAqB,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/office-open/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EACV,MAAM,EAIP,MAAM,gBAAgB,CAAC;AAMxB,OAAO,KAAK,EAAqB,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAWhF,eAAO,MAAM,4BAA4B,EAAE,cAA8B,CAAC;AAwC1E,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,YAAY,CAAC,CA0C1E;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA2ClC"}
|