ts-d2 0.0.4 → 0.0.20
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/README.md +65 -1
- package/dist/{index.mjs → index.cjs} +268 -153
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.mts → index.d.cts} +53 -28
- package/dist/index.d.ts +53 -28
- package/dist/index.js +242 -154
- package/dist/index.js.map +1 -0
- package/package.json +34 -42
|
@@ -1,18 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
1
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
2
8
|
var __export = (target, all) => {
|
|
3
9
|
for (var name in all)
|
|
4
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
11
|
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
default: () => index_default
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
6
36
|
|
|
7
37
|
// src/Border/index.ts
|
|
8
|
-
|
|
38
|
+
var import_docframe_types = __toESM(require("docframe-types"), 1);
|
|
9
39
|
var Border = class {
|
|
10
40
|
constructor(width, color) {
|
|
11
41
|
this.width = width;
|
|
12
42
|
this.color = color;
|
|
13
43
|
}
|
|
14
44
|
toDocFrame() {
|
|
15
|
-
return new
|
|
45
|
+
return new import_docframe_types.default.ProtoBorder({
|
|
16
46
|
weight: this.width.toDocFrame(),
|
|
17
47
|
color: this.color.toDocFrame()
|
|
18
48
|
});
|
|
@@ -24,7 +54,7 @@ var SideBorders = class {
|
|
|
24
54
|
}
|
|
25
55
|
toDocFrame() {
|
|
26
56
|
var _a, _b, _c, _d;
|
|
27
|
-
return new
|
|
57
|
+
return new import_docframe_types.default.ProtoSideBorders({
|
|
28
58
|
top: (_a = this.value.top) == null ? void 0 : _a.toDocFrame(),
|
|
29
59
|
right: (_b = this.value.right) == null ? void 0 : _b.toDocFrame(),
|
|
30
60
|
bottom: (_c = this.value.bottom) == null ? void 0 : _c.toDocFrame(),
|
|
@@ -34,7 +64,7 @@ var SideBorders = class {
|
|
|
34
64
|
};
|
|
35
65
|
|
|
36
66
|
// src/Color/index.ts
|
|
37
|
-
|
|
67
|
+
var import_docframe_types2 = __toESM(require("docframe-types"), 1);
|
|
38
68
|
var Color = class _Color {
|
|
39
69
|
static rgb(r, g, b) {
|
|
40
70
|
if (r < 0 || r > 255) {
|
|
@@ -46,8 +76,8 @@ var Color = class _Color {
|
|
|
46
76
|
if (b < 0 || b > 255) {
|
|
47
77
|
throw new Error(`Invalid blue value: ${b}`);
|
|
48
78
|
}
|
|
49
|
-
return new _Color(
|
|
50
|
-
type:
|
|
79
|
+
return new _Color(import_docframe_types2.default.ProtoColor.create({
|
|
80
|
+
type: import_docframe_types2.default.ProtoColorType.RGB,
|
|
51
81
|
r,
|
|
52
82
|
g,
|
|
53
83
|
b
|
|
@@ -66,8 +96,8 @@ var Color = class _Color {
|
|
|
66
96
|
if (k < 0 || k > 100) {
|
|
67
97
|
throw new Error(`Invalid black value: ${k}`);
|
|
68
98
|
}
|
|
69
|
-
return new _Color(
|
|
70
|
-
type:
|
|
99
|
+
return new _Color(import_docframe_types2.default.ProtoColor.create({
|
|
100
|
+
type: import_docframe_types2.default.ProtoColorType.CMYK,
|
|
71
101
|
c,
|
|
72
102
|
m,
|
|
73
103
|
y,
|
|
@@ -84,8 +114,8 @@ var Color = class _Color {
|
|
|
84
114
|
const r = parseInt(hex.slice(0, 2), 16);
|
|
85
115
|
const g = parseInt(hex.slice(2, 4), 16);
|
|
86
116
|
const b = parseInt(hex.slice(4, 6), 16);
|
|
87
|
-
return new _Color(
|
|
88
|
-
type:
|
|
117
|
+
return new _Color(import_docframe_types2.default.ProtoColor.create({
|
|
118
|
+
type: import_docframe_types2.default.ProtoColorType.RGB,
|
|
89
119
|
r,
|
|
90
120
|
g,
|
|
91
121
|
b
|
|
@@ -105,21 +135,23 @@ var Colors;
|
|
|
105
135
|
})(Colors || (Colors = {}));
|
|
106
136
|
|
|
107
137
|
// src/Connection/index.ts
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
138
|
+
var import_axios = __toESM(require("axios"), 1);
|
|
139
|
+
var import_form_data = __toESM(require("form-data"), 1);
|
|
140
|
+
var import_dotenv = __toESM(require("dotenv"), 1);
|
|
141
|
+
var import_docframe_types3 = __toESM(require("docframe-types"), 1);
|
|
142
|
+
import_dotenv.default.config();
|
|
111
143
|
var Connection = class {
|
|
112
|
-
constructor(url
|
|
113
|
-
this.url = url;
|
|
114
|
-
this.token = token;
|
|
144
|
+
constructor(url, token) {
|
|
145
|
+
this.url = url || process.env.DOCPIPE_URL || "http://localhost:8080";
|
|
146
|
+
this.token = token || process.env.DOCPIPE_TOKEN || "";
|
|
115
147
|
}
|
|
116
148
|
get docframeCallUrl() {
|
|
117
149
|
return `${this.url}/api/docframe?token=${this.token}`;
|
|
118
150
|
}
|
|
119
|
-
convertTo(format, doc, outputParams) {
|
|
151
|
+
convertTo(format, doc, outputParams, jobParams) {
|
|
120
152
|
const node = doc.toDocFrame();
|
|
121
|
-
const protoData =
|
|
122
|
-
const form = new
|
|
153
|
+
const protoData = import_docframe_types3.default.Node.encode(node).finish();
|
|
154
|
+
const form = new import_form_data.default();
|
|
123
155
|
let meta = {
|
|
124
156
|
format
|
|
125
157
|
};
|
|
@@ -129,6 +161,12 @@ var Connection = class {
|
|
|
129
161
|
...outputParams
|
|
130
162
|
};
|
|
131
163
|
}
|
|
164
|
+
if (jobParams) {
|
|
165
|
+
meta = {
|
|
166
|
+
...meta,
|
|
167
|
+
...jobParams
|
|
168
|
+
};
|
|
169
|
+
}
|
|
132
170
|
form.append("meta", JSON.stringify(meta), {
|
|
133
171
|
contentType: "application/json",
|
|
134
172
|
filename: "meta"
|
|
@@ -138,7 +176,7 @@ var Connection = class {
|
|
|
138
176
|
filename: "data.proto"
|
|
139
177
|
});
|
|
140
178
|
return new Promise((resolve, reject) => {
|
|
141
|
-
|
|
179
|
+
import_axios.default.postForm(this.docframeCallUrl, form, {
|
|
142
180
|
headers: {
|
|
143
181
|
...form.getHeaders()
|
|
144
182
|
},
|
|
@@ -159,7 +197,7 @@ var Connection = class {
|
|
|
159
197
|
var defaultConnection = new Connection();
|
|
160
198
|
|
|
161
199
|
// src/Content/Barcode/index.ts
|
|
162
|
-
|
|
200
|
+
var import_docframe_types6 = __toESM(require("docframe-types"), 1);
|
|
163
201
|
|
|
164
202
|
// src/Content/DocumentElement/index.ts
|
|
165
203
|
var DocumentElement = class {
|
|
@@ -170,11 +208,12 @@ var Measure_exports = {};
|
|
|
170
208
|
__export(Measure_exports, {
|
|
171
209
|
AbsoluteMeasure: () => AbsoluteMeasure,
|
|
172
210
|
Measure: () => Measure,
|
|
173
|
-
SideMeasures: () => SideMeasures
|
|
211
|
+
SideMeasures: () => SideMeasures,
|
|
212
|
+
Sides: () => Sides
|
|
174
213
|
});
|
|
175
214
|
|
|
176
215
|
// src/Measure/Measure.ts
|
|
177
|
-
|
|
216
|
+
var import_docframe_types4 = __toESM(require("docframe-types"), 1);
|
|
178
217
|
var _Measure = class _Measure {
|
|
179
218
|
constructor(value, unit) {
|
|
180
219
|
this.value = value;
|
|
@@ -183,34 +222,34 @@ var _Measure = class _Measure {
|
|
|
183
222
|
toDocFrame() {
|
|
184
223
|
switch (this.unit) {
|
|
185
224
|
case "pt":
|
|
186
|
-
return new
|
|
225
|
+
return new import_docframe_types4.default.ProtoMeasure({
|
|
187
226
|
value: this.value,
|
|
188
|
-
mtype:
|
|
227
|
+
mtype: import_docframe_types4.default.ProtoMeasureType.PT
|
|
189
228
|
});
|
|
190
229
|
case "cm":
|
|
191
|
-
return new
|
|
230
|
+
return new import_docframe_types4.default.ProtoMeasure({
|
|
192
231
|
value: this.value,
|
|
193
|
-
mtype:
|
|
232
|
+
mtype: import_docframe_types4.default.ProtoMeasureType.CM
|
|
194
233
|
});
|
|
195
234
|
case "mm":
|
|
196
|
-
return new
|
|
235
|
+
return new import_docframe_types4.default.ProtoMeasure({
|
|
197
236
|
value: this.value,
|
|
198
|
-
mtype:
|
|
237
|
+
mtype: import_docframe_types4.default.ProtoMeasureType.MM
|
|
199
238
|
});
|
|
200
239
|
case "in":
|
|
201
|
-
return new
|
|
240
|
+
return new import_docframe_types4.default.ProtoMeasure({
|
|
202
241
|
value: this.value,
|
|
203
|
-
mtype:
|
|
242
|
+
mtype: import_docframe_types4.default.ProtoMeasureType.IN
|
|
204
243
|
});
|
|
205
244
|
case "px":
|
|
206
|
-
return new
|
|
245
|
+
return new import_docframe_types4.default.ProtoMeasure({
|
|
207
246
|
value: this.value,
|
|
208
|
-
mtype:
|
|
247
|
+
mtype: import_docframe_types4.default.ProtoMeasureType.PX
|
|
209
248
|
});
|
|
210
249
|
case "%":
|
|
211
|
-
return new
|
|
250
|
+
return new import_docframe_types4.default.ProtoMeasure({
|
|
212
251
|
value: this.value,
|
|
213
|
-
mtype:
|
|
252
|
+
mtype: import_docframe_types4.default.ProtoMeasureType.PERCENT
|
|
214
253
|
});
|
|
215
254
|
default:
|
|
216
255
|
throw new Error(`Unknown measure unit: ${this.unit}`);
|
|
@@ -227,7 +266,7 @@ var SideMeasures = class {
|
|
|
227
266
|
}
|
|
228
267
|
toDocFrame() {
|
|
229
268
|
var _a, _b, _c, _d;
|
|
230
|
-
return new
|
|
269
|
+
return new import_docframe_types4.default.ProtoSideMeasures({
|
|
231
270
|
top: (_a = this.value.top) == null ? void 0 : _a.toDocFrame(),
|
|
232
271
|
right: (_b = this.value.right) == null ? void 0 : _b.toDocFrame(),
|
|
233
272
|
bottom: (_c = this.value.bottom) == null ? void 0 : _c.toDocFrame(),
|
|
@@ -235,21 +274,23 @@ var SideMeasures = class {
|
|
|
235
274
|
});
|
|
236
275
|
}
|
|
237
276
|
};
|
|
277
|
+
var Sides = class {
|
|
278
|
+
};
|
|
238
279
|
|
|
239
280
|
// src/Content/ReferencePoint/index.ts
|
|
240
|
-
|
|
281
|
+
var import_docframe_types5 = __toESM(require("docframe-types"), 1);
|
|
241
282
|
function referencePointToDocFrame(point) {
|
|
242
283
|
switch (point) {
|
|
243
284
|
case "top-left":
|
|
244
|
-
return
|
|
285
|
+
return import_docframe_types5.default.ProtoImageReferencePoint.REF_POINT_TOP_LEFT;
|
|
245
286
|
case "top-right":
|
|
246
|
-
return
|
|
287
|
+
return import_docframe_types5.default.ProtoImageReferencePoint.REF_POINT_TOP_RIGHT;
|
|
247
288
|
case "center":
|
|
248
|
-
return
|
|
289
|
+
return import_docframe_types5.default.ProtoImageReferencePoint.REF_POINT_CENTER;
|
|
249
290
|
case "bottom-left":
|
|
250
|
-
return
|
|
291
|
+
return import_docframe_types5.default.ProtoImageReferencePoint.REF_POINT_BOTTOM_LEFT;
|
|
251
292
|
case "bottom-right":
|
|
252
|
-
return
|
|
293
|
+
return import_docframe_types5.default.ProtoImageReferencePoint.REF_POINT_BOTTOM_RIGHT;
|
|
253
294
|
default:
|
|
254
295
|
throw new Error(`Unknown reference point: ${point}`);
|
|
255
296
|
}
|
|
@@ -262,8 +303,8 @@ var Barcode = class extends DocumentElement {
|
|
|
262
303
|
this.props = props;
|
|
263
304
|
}
|
|
264
305
|
toDocFrame() {
|
|
265
|
-
return
|
|
266
|
-
barcode:
|
|
306
|
+
return import_docframe_types6.default.Node.create({
|
|
307
|
+
barcode: import_docframe_types6.default.ProtoBarcode.create({
|
|
267
308
|
type: this.props.type,
|
|
268
309
|
positionAbsolute: this.props.positionAbsolute,
|
|
269
310
|
referencePoint: referencePointToDocFrame(this.props.referencePoint),
|
|
@@ -280,8 +321,8 @@ var Barcode = class extends DocumentElement {
|
|
|
280
321
|
};
|
|
281
322
|
|
|
282
323
|
// src/Content/ColumnDefinition/index.ts
|
|
283
|
-
|
|
284
|
-
|
|
324
|
+
var import_docframe_types7 = __toESM(require("docframe-types"), 1);
|
|
325
|
+
var import_uuid = require("uuid");
|
|
285
326
|
var ColumnPositionMode = class {
|
|
286
327
|
constructor(value) {
|
|
287
328
|
this.value = value;
|
|
@@ -292,35 +333,35 @@ var ColumnPositionMode = class {
|
|
|
292
333
|
};
|
|
293
334
|
var ColumnPosition;
|
|
294
335
|
((ColumnPosition2) => {
|
|
295
|
-
ColumnPosition2.Center = new ColumnPositionMode(
|
|
296
|
-
ColumnPosition2.Left = new ColumnPositionMode(
|
|
297
|
-
ColumnPosition2.Folio = new ColumnPositionMode(
|
|
298
|
-
ColumnPosition2.Right = new ColumnPositionMode(
|
|
336
|
+
ColumnPosition2.Center = new ColumnPositionMode(import_docframe_types7.default.ProtoPositionMode.CENTER);
|
|
337
|
+
ColumnPosition2.Left = new ColumnPositionMode(import_docframe_types7.default.ProtoPositionMode.LEFT);
|
|
338
|
+
ColumnPosition2.Folio = new ColumnPositionMode(import_docframe_types7.default.ProtoPositionMode.FOLIO);
|
|
339
|
+
ColumnPosition2.Right = new ColumnPositionMode(import_docframe_types7.default.ProtoPositionMode.RIGHT);
|
|
299
340
|
ColumnPosition2.ReverseFolio = new ColumnPositionMode(
|
|
300
|
-
|
|
341
|
+
import_docframe_types7.default.ProtoPositionMode.REVERSE_FOLIO
|
|
301
342
|
);
|
|
302
343
|
})(ColumnPosition || (ColumnPosition = {}));
|
|
303
344
|
var ColumnDefinition = class {
|
|
304
345
|
constructor(props) {
|
|
305
346
|
this.props = props;
|
|
306
|
-
this.uuid =
|
|
347
|
+
this.uuid = (0, import_uuid.v4)();
|
|
307
348
|
}
|
|
308
349
|
toDocFrame(applyImmediate) {
|
|
309
350
|
const result = [
|
|
310
|
-
|
|
311
|
-
cDef:
|
|
351
|
+
import_docframe_types7.default.Node.create({
|
|
352
|
+
cDef: import_docframe_types7.default.ProtoCDef.create({
|
|
312
353
|
Uuid: this.uuid,
|
|
313
|
-
columSettings:
|
|
314
|
-
width:
|
|
354
|
+
columSettings: import_docframe_types7.default.ProtoColumnSettings.create({
|
|
355
|
+
width: import_docframe_types7.default.ProtoBoxedMeasure.create({
|
|
315
356
|
isNull: false,
|
|
316
357
|
value: this.props.width.toDocFrame()
|
|
317
358
|
}),
|
|
318
|
-
positionOffset:
|
|
359
|
+
positionOffset: import_docframe_types7.default.ProtoBoxedMeasure.create({
|
|
319
360
|
isNull: false,
|
|
320
361
|
value: this.props.positionOffset.toDocFrame()
|
|
321
362
|
}),
|
|
322
363
|
positionMode: this.props.position.toDocFrame(),
|
|
323
|
-
interColumnSpace:
|
|
364
|
+
interColumnSpace: import_docframe_types7.default.ProtoBoxedMeasure.create({
|
|
324
365
|
isNull: false,
|
|
325
366
|
value: this.props.interColumnSpace.toDocFrame()
|
|
326
367
|
})
|
|
@@ -330,8 +371,8 @@ var ColumnDefinition = class {
|
|
|
330
371
|
];
|
|
331
372
|
if (applyImmediate) {
|
|
332
373
|
result.push(
|
|
333
|
-
|
|
334
|
-
applyCDef:
|
|
374
|
+
import_docframe_types7.default.Node.create({
|
|
375
|
+
applyCDef: import_docframe_types7.default.ProtoApplyProtoCDef.create({
|
|
335
376
|
cDefUuid: this.uuid
|
|
336
377
|
})
|
|
337
378
|
})
|
|
@@ -357,34 +398,19 @@ var ColumnDefinitions = {
|
|
|
357
398
|
}
|
|
358
399
|
};
|
|
359
400
|
|
|
360
|
-
// src/Content/
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
// src/OutputFormat/index.ts
|
|
364
|
-
var OutputFormat_exports = {};
|
|
365
|
-
__export(OutputFormat_exports, {
|
|
366
|
-
OutputFormat: () => OutputFormat
|
|
367
|
-
});
|
|
368
|
-
var OutputFormat = /* @__PURE__ */ ((OutputFormat2) => {
|
|
369
|
-
OutputFormat2["PDF"] = "pdf";
|
|
370
|
-
OutputFormat2["PNG"] = "png";
|
|
371
|
-
OutputFormat2["JPEG"] = "jpeg";
|
|
372
|
-
OutputFormat2["HTML"] = "html";
|
|
373
|
-
OutputFormat2["PS"] = "ps";
|
|
374
|
-
OutputFormat2["TEXT"] = "text";
|
|
375
|
-
return OutputFormat2;
|
|
376
|
-
})(OutputFormat || {});
|
|
401
|
+
// src/Content/Directory/index.ts
|
|
402
|
+
var import_docframe_types9 = __toESM(require("docframe-types"), 1);
|
|
377
403
|
|
|
378
404
|
// src/Content/Text/index.ts
|
|
379
|
-
|
|
405
|
+
var import_docframe_types8 = __toESM(require("docframe-types"), 1);
|
|
380
406
|
var Text = class extends DocumentElement {
|
|
381
407
|
constructor(content) {
|
|
382
408
|
super();
|
|
383
409
|
this.content = content;
|
|
384
410
|
}
|
|
385
411
|
toDocFrame() {
|
|
386
|
-
return
|
|
387
|
-
text:
|
|
412
|
+
return import_docframe_types8.default.Node.create({
|
|
413
|
+
text: import_docframe_types8.default.ProtoText.create({
|
|
388
414
|
content: this.content
|
|
389
415
|
})
|
|
390
416
|
});
|
|
@@ -435,45 +461,73 @@ function documentElementsFromContent(content) {
|
|
|
435
461
|
}
|
|
436
462
|
}
|
|
437
463
|
|
|
464
|
+
// src/Content/Directory/index.ts
|
|
465
|
+
var Directory = class extends BranchDocumentElement {
|
|
466
|
+
toDocFrame() {
|
|
467
|
+
return import_docframe_types9.default.Node.create({
|
|
468
|
+
directory: import_docframe_types9.default.ProtoDirectory.create({}),
|
|
469
|
+
children: this.childrenToDocFrame()
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
// src/Content/Document/index.ts
|
|
475
|
+
var import_docframe_types16 = __toESM(require("docframe-types"), 1);
|
|
476
|
+
|
|
477
|
+
// src/OutputFormat/index.ts
|
|
478
|
+
var OutputFormat_exports = {};
|
|
479
|
+
__export(OutputFormat_exports, {
|
|
480
|
+
OutputFormat: () => OutputFormat
|
|
481
|
+
});
|
|
482
|
+
var OutputFormat = /* @__PURE__ */ ((OutputFormat2) => {
|
|
483
|
+
OutputFormat2["PDF"] = "pdf";
|
|
484
|
+
OutputFormat2["PNG"] = "png";
|
|
485
|
+
OutputFormat2["JPEG"] = "jpeg";
|
|
486
|
+
OutputFormat2["HTML"] = "html";
|
|
487
|
+
OutputFormat2["PS"] = "ps";
|
|
488
|
+
OutputFormat2["TEXT"] = "text";
|
|
489
|
+
return OutputFormat2;
|
|
490
|
+
})(OutputFormat || {});
|
|
491
|
+
|
|
438
492
|
// src/Content/Footer/index.ts
|
|
439
|
-
|
|
493
|
+
var import_docframe_types10 = __toESM(require("docframe-types"), 1);
|
|
440
494
|
var Footer = class extends BranchDocumentElement {
|
|
441
495
|
toDocFrame() {
|
|
442
|
-
return
|
|
443
|
-
footer:
|
|
496
|
+
return import_docframe_types10.default.Node.create({
|
|
497
|
+
footer: import_docframe_types10.default.ProtoFooter.create(),
|
|
444
498
|
children: this.childrenToDocFrame()
|
|
445
499
|
});
|
|
446
500
|
}
|
|
447
501
|
};
|
|
448
502
|
|
|
449
503
|
// src/Content/Header/index.ts
|
|
450
|
-
|
|
504
|
+
var import_docframe_types11 = __toESM(require("docframe-types"), 1);
|
|
451
505
|
var Header = class extends BranchDocumentElement {
|
|
452
506
|
toDocFrame() {
|
|
453
|
-
return
|
|
454
|
-
header:
|
|
507
|
+
return import_docframe_types11.default.Node.create({
|
|
508
|
+
header: import_docframe_types11.default.ProtoHeader.create(),
|
|
455
509
|
children: this.childrenToDocFrame()
|
|
456
510
|
});
|
|
457
511
|
}
|
|
458
512
|
};
|
|
459
513
|
|
|
460
514
|
// src/Content/PageDefinition/index.ts
|
|
461
|
-
|
|
462
|
-
|
|
515
|
+
var import_docframe_types12 = __toESM(require("docframe-types"), 1);
|
|
516
|
+
var import_uuid2 = require("uuid");
|
|
463
517
|
var PageDefinition = class {
|
|
464
518
|
constructor(width, height) {
|
|
465
519
|
this.width = width;
|
|
466
520
|
this.height = height;
|
|
467
|
-
this.uuid = v4();
|
|
521
|
+
this.uuid = (0, import_uuid2.v4)();
|
|
468
522
|
}
|
|
469
523
|
toDocFrame() {
|
|
470
524
|
var _a, _b;
|
|
471
|
-
return new
|
|
472
|
-
pageDepth: new
|
|
525
|
+
return new import_docframe_types12.default.ProtoPDef({
|
|
526
|
+
pageDepth: new import_docframe_types12.default.ProtoBoxedMeasure({
|
|
473
527
|
isNull: this.height === void 0,
|
|
474
528
|
value: (_a = this.height) == null ? void 0 : _a.toDocFrame()
|
|
475
529
|
}),
|
|
476
|
-
pageWidth: new
|
|
530
|
+
pageWidth: new import_docframe_types12.default.ProtoBoxedMeasure({
|
|
477
531
|
isNull: this.width === void 0,
|
|
478
532
|
value: (_b = this.width) == null ? void 0 : _b.toDocFrame()
|
|
479
533
|
}),
|
|
@@ -498,110 +552,110 @@ var PageDefinitions;
|
|
|
498
552
|
})(PageDefinitions || (PageDefinitions = {}));
|
|
499
553
|
|
|
500
554
|
// src/ParagraphFormat/index.ts
|
|
501
|
-
|
|
502
|
-
|
|
555
|
+
var import_docframe_types13 = __toESM(require("docframe-types"), 1);
|
|
556
|
+
var import_uuid3 = require("uuid");
|
|
503
557
|
var ParagraphFormat = class {
|
|
504
558
|
constructor(props) {
|
|
505
559
|
this.props = props;
|
|
506
|
-
this.props.name = props.name ||
|
|
560
|
+
this.props.name = props.name || (0, import_uuid3.v4)();
|
|
507
561
|
}
|
|
508
562
|
toDocFrame() {
|
|
509
563
|
let format = {
|
|
510
|
-
default:
|
|
564
|
+
default: import_docframe_types13.default.ProtoBoxedBool.create({
|
|
511
565
|
isNull: false,
|
|
512
566
|
value: this.props.default || false
|
|
513
567
|
}),
|
|
514
|
-
name:
|
|
568
|
+
name: import_docframe_types13.default.ProtoBoxedString.create({
|
|
515
569
|
isNull: false,
|
|
516
570
|
value: this.props.name
|
|
517
571
|
})
|
|
518
572
|
};
|
|
519
573
|
if (this.props.alignment) {
|
|
520
|
-
format.alignment =
|
|
574
|
+
format.alignment = import_docframe_types13.default.ProtoBoxedHorizontalAlignment.create({
|
|
521
575
|
isNull: false,
|
|
522
576
|
value: this.props.alignment.toDocFrame()
|
|
523
577
|
});
|
|
524
578
|
}
|
|
525
579
|
if (this.props.font) {
|
|
526
|
-
format.font =
|
|
580
|
+
format.font = import_docframe_types13.default.ProtoBoxedFont.create({
|
|
527
581
|
isNull: false,
|
|
528
582
|
value: this.props.font.toDocFrame()
|
|
529
583
|
});
|
|
530
584
|
}
|
|
531
585
|
if (this.props.fontSize) {
|
|
532
|
-
format.fontSize =
|
|
586
|
+
format.fontSize = import_docframe_types13.default.ProtoBoxedMeasure.create({
|
|
533
587
|
isNull: false,
|
|
534
588
|
value: this.props.fontSize.toDocFrame()
|
|
535
589
|
});
|
|
536
590
|
}
|
|
537
591
|
if (this.props.characterWidth) {
|
|
538
|
-
format.characterWidth =
|
|
592
|
+
format.characterWidth = import_docframe_types13.default.ProtoBoxedMeasure.create({
|
|
539
593
|
isNull: false,
|
|
540
594
|
value: this.props.characterWidth.toDocFrame()
|
|
541
595
|
});
|
|
542
596
|
}
|
|
543
597
|
if (this.props.characterSpacing) {
|
|
544
|
-
format.characterSpacing =
|
|
598
|
+
format.characterSpacing = import_docframe_types13.default.ProtoBoxedMeasure.create({
|
|
545
599
|
isNull: false,
|
|
546
600
|
value: this.props.characterSpacing.toDocFrame()
|
|
547
601
|
});
|
|
548
602
|
}
|
|
549
603
|
if (this.props.lineFeed) {
|
|
550
|
-
format.lineFeed =
|
|
604
|
+
format.lineFeed = import_docframe_types13.default.ProtoBoxedMeasure.create({
|
|
551
605
|
isNull: false,
|
|
552
606
|
value: this.props.lineFeed.toDocFrame()
|
|
553
607
|
});
|
|
554
608
|
}
|
|
555
609
|
if (this.props.indentionLevel !== void 0) {
|
|
556
|
-
format.indentionLevel =
|
|
610
|
+
format.indentionLevel = import_docframe_types13.default.ProtoBoxedInt32.create({
|
|
557
611
|
isNull: false,
|
|
558
612
|
value: this.props.indentionLevel
|
|
559
613
|
});
|
|
560
614
|
}
|
|
561
615
|
if (this.props.indentionWidth) {
|
|
562
|
-
format.indentionWidth =
|
|
616
|
+
format.indentionWidth = import_docframe_types13.default.ProtoBoxedMeasure.create({
|
|
563
617
|
isNull: false,
|
|
564
618
|
value: this.props.indentionWidth.toDocFrame()
|
|
565
619
|
});
|
|
566
620
|
}
|
|
567
621
|
if (this.props.bold !== void 0) {
|
|
568
|
-
format.bold =
|
|
622
|
+
format.bold = import_docframe_types13.default.ProtoBoxedBool.create({
|
|
569
623
|
isNull: false,
|
|
570
624
|
value: !!this.props.bold
|
|
571
625
|
});
|
|
572
626
|
}
|
|
573
627
|
if (this.props.italic !== void 0) {
|
|
574
|
-
format.italic =
|
|
628
|
+
format.italic = import_docframe_types13.default.ProtoBoxedBool.create({
|
|
575
629
|
isNull: false,
|
|
576
630
|
value: !!this.props.italic
|
|
577
631
|
});
|
|
578
632
|
}
|
|
579
633
|
if (this.props.spaceAbove) {
|
|
580
|
-
format.spaceAbove =
|
|
634
|
+
format.spaceAbove = import_docframe_types13.default.ProtoBoxedMeasure.create({
|
|
581
635
|
isNull: false,
|
|
582
636
|
value: this.props.spaceAbove.toDocFrame()
|
|
583
637
|
});
|
|
584
638
|
}
|
|
585
639
|
if (this.props.spaceBelow) {
|
|
586
|
-
format.spaceBelow =
|
|
640
|
+
format.spaceBelow = import_docframe_types13.default.ProtoBoxedMeasure.create({
|
|
587
641
|
isNull: false,
|
|
588
642
|
value: this.props.spaceBelow.toDocFrame()
|
|
589
643
|
});
|
|
590
644
|
}
|
|
591
|
-
return
|
|
645
|
+
return import_docframe_types13.default.ProtoParagraphFormat.create(format);
|
|
592
646
|
}
|
|
593
647
|
};
|
|
594
648
|
|
|
595
649
|
// src/Content/SpaceVertically/index.ts
|
|
596
|
-
|
|
650
|
+
var import_docframe_types14 = __toESM(require("docframe-types"), 1);
|
|
597
651
|
var SpaceVertically = class extends DocumentElement {
|
|
598
652
|
constructor(space) {
|
|
599
653
|
super();
|
|
600
654
|
this.space = space;
|
|
601
655
|
}
|
|
602
656
|
toDocFrame() {
|
|
603
|
-
return
|
|
604
|
-
spaceVertically:
|
|
657
|
+
return import_docframe_types14.default.Node.create({
|
|
658
|
+
spaceVertically: import_docframe_types14.default.ProtoSpaceVertically.create({
|
|
605
659
|
space: this.space.toDocFrame()
|
|
606
660
|
})
|
|
607
661
|
});
|
|
@@ -609,13 +663,13 @@ var SpaceVertically = class extends DocumentElement {
|
|
|
609
663
|
};
|
|
610
664
|
|
|
611
665
|
// src/Font/index.ts
|
|
612
|
-
|
|
666
|
+
var import_docframe_types15 = require("docframe-types");
|
|
613
667
|
var Font = class {
|
|
614
668
|
constructor(name) {
|
|
615
669
|
this.name = name;
|
|
616
670
|
}
|
|
617
671
|
toDocFrame() {
|
|
618
|
-
return ProtoFont.create({
|
|
672
|
+
return import_docframe_types15.ProtoFont.create({
|
|
619
673
|
name: this.name,
|
|
620
674
|
// TODO: suppot font mapping for docframe step
|
|
621
675
|
id: 5
|
|
@@ -688,15 +742,15 @@ var Document = class extends BranchDocumentElement {
|
|
|
688
742
|
toDocFrame() {
|
|
689
743
|
const props = this.props;
|
|
690
744
|
const docSettings = Object.values(this.paragraphFormats).map(
|
|
691
|
-
(pf) =>
|
|
745
|
+
(pf) => import_docframe_types16.default.Node.create({
|
|
692
746
|
paragraphFormat: pf.toDocFrame()
|
|
693
747
|
})
|
|
694
748
|
).concat([
|
|
695
|
-
|
|
749
|
+
import_docframe_types16.default.Node.create({
|
|
696
750
|
pDef: props.pageDefinition.toDocFrame()
|
|
697
751
|
}),
|
|
698
|
-
|
|
699
|
-
applyPDef:
|
|
752
|
+
import_docframe_types16.default.Node.create({
|
|
753
|
+
applyPDef: import_docframe_types16.default.ProtoApplyProtoPDef.create({
|
|
700
754
|
pDefUuid: props.pageDefinition.uuid
|
|
701
755
|
})
|
|
702
756
|
}),
|
|
@@ -711,19 +765,19 @@ var Document = class extends BranchDocumentElement {
|
|
|
711
765
|
const content = this.childrenToDocFrame();
|
|
712
766
|
for (const format of Object.values(this.paragraphFormats)) {
|
|
713
767
|
docSettings.push(
|
|
714
|
-
|
|
768
|
+
import_docframe_types16.default.Node.create({
|
|
715
769
|
paragraphFormat: format.toDocFrame()
|
|
716
770
|
})
|
|
717
771
|
);
|
|
718
772
|
}
|
|
719
|
-
return
|
|
773
|
+
return import_docframe_types16.default.Node.create({
|
|
720
774
|
children: docSettings.concat(...content)
|
|
721
775
|
});
|
|
722
776
|
}
|
|
723
777
|
};
|
|
724
778
|
|
|
725
779
|
// src/Content/Formatted/index.ts
|
|
726
|
-
|
|
780
|
+
var import_docframe_types17 = __toESM(require("docframe-types"), 1);
|
|
727
781
|
var Formatted = class extends DocumentElement {
|
|
728
782
|
constructor(doctypeContent, htmlContent) {
|
|
729
783
|
super();
|
|
@@ -733,8 +787,8 @@ var Formatted = class extends DocumentElement {
|
|
|
733
787
|
};
|
|
734
788
|
}
|
|
735
789
|
toDocFrame() {
|
|
736
|
-
return
|
|
737
|
-
formatted:
|
|
790
|
+
return import_docframe_types17.default.Node.create({
|
|
791
|
+
formatted: import_docframe_types17.default.ProtoFormatted.create({
|
|
738
792
|
doctypeContent: this.content.doctype,
|
|
739
793
|
htmlContent: this.content.html
|
|
740
794
|
})
|
|
@@ -742,18 +796,28 @@ var Formatted = class extends DocumentElement {
|
|
|
742
796
|
}
|
|
743
797
|
};
|
|
744
798
|
|
|
799
|
+
// src/Content/Linebreak/index.ts
|
|
800
|
+
var import_docframe_types18 = __toESM(require("docframe-types"), 1);
|
|
801
|
+
var Linebreak = class extends DocumentElement {
|
|
802
|
+
toDocFrame() {
|
|
803
|
+
return import_docframe_types18.default.Node.create({
|
|
804
|
+
linebreak: import_docframe_types18.default.ProtoLinebreak.create({})
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
|
|
745
809
|
// src/Content/Pagebreak/index.ts
|
|
746
|
-
|
|
810
|
+
var import_docframe_types19 = __toESM(require("docframe-types"), 1);
|
|
747
811
|
var Pagebreak = class extends DocumentElement {
|
|
748
812
|
toDocFrame() {
|
|
749
|
-
return
|
|
750
|
-
newPage:
|
|
813
|
+
return import_docframe_types19.default.Node.create({
|
|
814
|
+
newPage: import_docframe_types19.default.ProtoNewPage.create({})
|
|
751
815
|
});
|
|
752
816
|
}
|
|
753
817
|
};
|
|
754
818
|
|
|
755
819
|
// src/Content/Paragraph/index.ts
|
|
756
|
-
|
|
820
|
+
var import_docframe_types20 = __toESM(require("docframe-types"), 1);
|
|
757
821
|
var Paragraph = class extends BranchDocumentElement {
|
|
758
822
|
constructor(content, paragraphFormatName, overwrite) {
|
|
759
823
|
var _a;
|
|
@@ -768,22 +832,70 @@ var Paragraph = class extends BranchDocumentElement {
|
|
|
768
832
|
par.overwrite = this.props.overwrite.toDocFrame();
|
|
769
833
|
}
|
|
770
834
|
if (this.props.paragraphFormatName) {
|
|
771
|
-
par.format =
|
|
772
|
-
name:
|
|
835
|
+
par.format = import_docframe_types20.default.ProtoParagraphFormat.create({
|
|
836
|
+
name: import_docframe_types20.default.ProtoBoxedString.create({
|
|
773
837
|
isNull: false,
|
|
774
838
|
value: this.props.paragraphFormatName
|
|
775
839
|
})
|
|
776
840
|
});
|
|
777
841
|
}
|
|
778
|
-
return
|
|
779
|
-
paragraph:
|
|
842
|
+
return import_docframe_types20.default.Node.create({
|
|
843
|
+
paragraph: import_docframe_types20.default.ProtoParagraph.create(par),
|
|
844
|
+
children: this.childrenToDocFrame()
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
// src/Content/Span/index.ts
|
|
850
|
+
var import_docframe_types21 = __toESM(require("docframe-types"), 1);
|
|
851
|
+
var Span = class extends BranchDocumentElement {
|
|
852
|
+
constructor(content, props) {
|
|
853
|
+
super(content, props || {});
|
|
854
|
+
}
|
|
855
|
+
toDocFrame() {
|
|
856
|
+
var _a, _b, _c, _d;
|
|
857
|
+
let bold = void 0;
|
|
858
|
+
if (((_a = this.props) == null ? void 0 : _a.bold) !== void 0) {
|
|
859
|
+
bold = import_docframe_types21.default.ProtoBoxedBool.create({
|
|
860
|
+
isNull: false,
|
|
861
|
+
value: this.props.bold
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
let italic = void 0;
|
|
865
|
+
if (((_b = this.props) == null ? void 0 : _b.italic) !== void 0) {
|
|
866
|
+
italic = import_docframe_types21.default.ProtoBoxedBool.create({
|
|
867
|
+
isNull: false,
|
|
868
|
+
value: this.props.italic
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
let underline = void 0;
|
|
872
|
+
if (((_c = this.props) == null ? void 0 : _c.underline) !== void 0) {
|
|
873
|
+
underline = import_docframe_types21.default.ProtoBoxedBool.create({
|
|
874
|
+
isNull: false,
|
|
875
|
+
value: this.props.underline
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
let strikethrough = void 0;
|
|
879
|
+
if (((_d = this.props) == null ? void 0 : _d.strikethrough) !== void 0) {
|
|
880
|
+
strikethrough = import_docframe_types21.default.ProtoBoxedBool.create({
|
|
881
|
+
isNull: false,
|
|
882
|
+
value: this.props.strikethrough
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
return import_docframe_types21.default.Node.create({
|
|
886
|
+
span: import_docframe_types21.default.ProtoSpan.create({
|
|
887
|
+
bold,
|
|
888
|
+
italic,
|
|
889
|
+
underline,
|
|
890
|
+
strikethrough
|
|
891
|
+
}),
|
|
780
892
|
children: this.childrenToDocFrame()
|
|
781
893
|
});
|
|
782
894
|
}
|
|
783
895
|
};
|
|
784
896
|
|
|
785
897
|
// src/Content/Table/index.ts
|
|
786
|
-
|
|
898
|
+
var import_docframe_types22 = __toESM(require("docframe-types"), 1);
|
|
787
899
|
var Table = class extends BranchDocumentElement {
|
|
788
900
|
constructor(content, props) {
|
|
789
901
|
super(content, props || {});
|
|
@@ -794,11 +906,11 @@ var Table = class extends BranchDocumentElement {
|
|
|
794
906
|
toDocFrame() {
|
|
795
907
|
var _a, _b;
|
|
796
908
|
const props = this.props;
|
|
797
|
-
return
|
|
798
|
-
table:
|
|
799
|
-
settings:
|
|
909
|
+
return import_docframe_types22.default.Node.create({
|
|
910
|
+
table: import_docframe_types22.default.ProtoTable.create({
|
|
911
|
+
settings: import_docframe_types22.default.ProtoTableSettings.create({
|
|
800
912
|
width: (_a = props.width) == null ? void 0 : _a.toDocFrame(),
|
|
801
|
-
leftMeasure:
|
|
913
|
+
leftMeasure: import_docframe_types22.default.ProtoBoxedBool.create({
|
|
802
914
|
isNull: false,
|
|
803
915
|
value: false
|
|
804
916
|
}),
|
|
@@ -811,7 +923,7 @@ var Table = class extends BranchDocumentElement {
|
|
|
811
923
|
};
|
|
812
924
|
|
|
813
925
|
// src/Content/TableCell/index.ts
|
|
814
|
-
|
|
926
|
+
var import_docframe_types23 = __toESM(require("docframe-types"), 1);
|
|
815
927
|
var TableCell = class extends BranchDocumentElement {
|
|
816
928
|
constructor(content, props) {
|
|
817
929
|
super(content, props || {});
|
|
@@ -819,20 +931,20 @@ var TableCell = class extends BranchDocumentElement {
|
|
|
819
931
|
toDocFrame() {
|
|
820
932
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
821
933
|
const props = this.props;
|
|
822
|
-
return
|
|
823
|
-
tableCell:
|
|
824
|
-
settings:
|
|
825
|
-
align:
|
|
934
|
+
return import_docframe_types23.default.Node.create({
|
|
935
|
+
tableCell: import_docframe_types23.default.ProtoTableCell.create({
|
|
936
|
+
settings: import_docframe_types23.default.ProtoTableCellSettings.create({
|
|
937
|
+
align: import_docframe_types23.default.ProtoBoxedHorizontalAlignment.create({
|
|
826
938
|
isNull: false,
|
|
827
|
-
value: ((_a = props.alignment) == null ? void 0 : _a.toDocFrame()) ||
|
|
939
|
+
value: ((_a = props.alignment) == null ? void 0 : _a.toDocFrame()) || import_docframe_types23.default.ProtoHorizontalAlignment.ALIGN_LEFT
|
|
828
940
|
}),
|
|
829
941
|
backgroundColor: (_b = props.backgroundColor) == null ? void 0 : _b.toDocFrame(),
|
|
830
942
|
border: (_c = props.border) == null ? void 0 : _c.toDocFrame(),
|
|
831
943
|
margin: (_d = props.margin) == null ? void 0 : _d.toDocFrame(),
|
|
832
944
|
padding: (_e = props.padding) == null ? void 0 : _e.toDocFrame(),
|
|
833
|
-
valign:
|
|
945
|
+
valign: import_docframe_types23.default.ProtoBoxedVerticalAlignment.create({
|
|
834
946
|
isNull: false,
|
|
835
|
-
value: ((_f = props.verticalAlignment) == null ? void 0 : _f.toDocFrame()) ||
|
|
947
|
+
value: ((_f = props.verticalAlignment) == null ? void 0 : _f.toDocFrame()) || import_docframe_types23.default.ProtoVerticalAlignment.TOP
|
|
836
948
|
}),
|
|
837
949
|
width: (_g = props.width) == null ? void 0 : _g.toDocFrame()
|
|
838
950
|
})
|
|
@@ -843,16 +955,16 @@ var TableCell = class extends BranchDocumentElement {
|
|
|
843
955
|
};
|
|
844
956
|
|
|
845
957
|
// src/Content/TableRow/index.ts
|
|
846
|
-
|
|
958
|
+
var import_docframe_types24 = __toESM(require("docframe-types"), 1);
|
|
847
959
|
var TableRow = class extends BranchDocumentElement {
|
|
848
960
|
constructor(content, props) {
|
|
849
961
|
super(content, props || {});
|
|
850
962
|
}
|
|
851
963
|
toDocFrame() {
|
|
852
964
|
var _a;
|
|
853
|
-
return
|
|
854
|
-
tableRow:
|
|
855
|
-
settings:
|
|
965
|
+
return import_docframe_types24.default.Node.create({
|
|
966
|
+
tableRow: import_docframe_types24.default.ProtoTableRow.create({
|
|
967
|
+
settings: import_docframe_types24.default.ProtoTableRowSettings.create({
|
|
856
968
|
minHeight: (_a = this.props.minHeight) == null ? void 0 : _a.toDocFrame()
|
|
857
969
|
})
|
|
858
970
|
}),
|
|
@@ -866,12 +978,17 @@ var Content_default = {
|
|
|
866
978
|
Barcode,
|
|
867
979
|
ColumnDefinition,
|
|
868
980
|
ColumnPosition,
|
|
981
|
+
Directory,
|
|
869
982
|
Document,
|
|
983
|
+
Footer,
|
|
870
984
|
Formatted,
|
|
871
|
-
|
|
985
|
+
Header,
|
|
986
|
+
Linebreak,
|
|
872
987
|
Pagebreak,
|
|
988
|
+
PageDefinition,
|
|
873
989
|
Paragraph,
|
|
874
990
|
SpaceVertically,
|
|
991
|
+
Span,
|
|
875
992
|
Table,
|
|
876
993
|
TableCell,
|
|
877
994
|
TableRow,
|
|
@@ -898,6 +1015,4 @@ var index_default = {
|
|
|
898
1015
|
Output: OutputFormat_exports,
|
|
899
1016
|
ParagraphFormat
|
|
900
1017
|
};
|
|
901
|
-
|
|
902
|
-
index_default as default
|
|
903
|
-
};
|
|
1018
|
+
//# sourceMappingURL=index.cjs.map
|