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
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
2
|
var __export = (target, all) => {
|
|
3
3
|
for (var name in all)
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/Border/index.ts
|
|
8
|
-
|
|
8
|
+
import Proto from "docframe-types";
|
|
9
9
|
var Border = class {
|
|
10
10
|
constructor(width, color) {
|
|
11
11
|
this.width = width;
|
|
12
12
|
this.color = color;
|
|
13
13
|
}
|
|
14
14
|
toDocFrame() {
|
|
15
|
-
return new
|
|
15
|
+
return new Proto.ProtoBorder({
|
|
16
16
|
weight: this.width.toDocFrame(),
|
|
17
17
|
color: this.color.toDocFrame()
|
|
18
18
|
});
|
|
@@ -24,7 +24,7 @@ var SideBorders = class {
|
|
|
24
24
|
}
|
|
25
25
|
toDocFrame() {
|
|
26
26
|
var _a, _b, _c, _d;
|
|
27
|
-
return new
|
|
27
|
+
return new Proto.ProtoSideBorders({
|
|
28
28
|
top: (_a = this.value.top) == null ? void 0 : _a.toDocFrame(),
|
|
29
29
|
right: (_b = this.value.right) == null ? void 0 : _b.toDocFrame(),
|
|
30
30
|
bottom: (_c = this.value.bottom) == null ? void 0 : _c.toDocFrame(),
|
|
@@ -34,7 +34,7 @@ var SideBorders = class {
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
// src/Color/index.ts
|
|
37
|
-
|
|
37
|
+
import Proto2 from "docframe-types";
|
|
38
38
|
var Color = class _Color {
|
|
39
39
|
static rgb(r, g, b) {
|
|
40
40
|
if (r < 0 || r > 255) {
|
|
@@ -46,8 +46,8 @@ var Color = class _Color {
|
|
|
46
46
|
if (b < 0 || b > 255) {
|
|
47
47
|
throw new Error(`Invalid blue value: ${b}`);
|
|
48
48
|
}
|
|
49
|
-
return new _Color(
|
|
50
|
-
type:
|
|
49
|
+
return new _Color(Proto2.ProtoColor.create({
|
|
50
|
+
type: Proto2.ProtoColorType.RGB,
|
|
51
51
|
r,
|
|
52
52
|
g,
|
|
53
53
|
b
|
|
@@ -66,8 +66,8 @@ var Color = class _Color {
|
|
|
66
66
|
if (k < 0 || k > 100) {
|
|
67
67
|
throw new Error(`Invalid black value: ${k}`);
|
|
68
68
|
}
|
|
69
|
-
return new _Color(
|
|
70
|
-
type:
|
|
69
|
+
return new _Color(Proto2.ProtoColor.create({
|
|
70
|
+
type: Proto2.ProtoColorType.CMYK,
|
|
71
71
|
c,
|
|
72
72
|
m,
|
|
73
73
|
y,
|
|
@@ -84,8 +84,8 @@ var Color = class _Color {
|
|
|
84
84
|
const r = parseInt(hex.slice(0, 2), 16);
|
|
85
85
|
const g = parseInt(hex.slice(2, 4), 16);
|
|
86
86
|
const b = parseInt(hex.slice(4, 6), 16);
|
|
87
|
-
return new _Color(
|
|
88
|
-
type:
|
|
87
|
+
return new _Color(Proto2.ProtoColor.create({
|
|
88
|
+
type: Proto2.ProtoColorType.RGB,
|
|
89
89
|
r,
|
|
90
90
|
g,
|
|
91
91
|
b
|
|
@@ -105,21 +105,23 @@ var Colors;
|
|
|
105
105
|
})(Colors || (Colors = {}));
|
|
106
106
|
|
|
107
107
|
// src/Connection/index.ts
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
import axios from "axios";
|
|
109
|
+
import FormData from "form-data";
|
|
110
|
+
import dotenv from "dotenv";
|
|
111
|
+
import Proto3 from "docframe-types";
|
|
112
|
+
dotenv.config();
|
|
111
113
|
var Connection = class {
|
|
112
|
-
constructor(url
|
|
113
|
-
this.url = url;
|
|
114
|
-
this.token = token;
|
|
114
|
+
constructor(url, token) {
|
|
115
|
+
this.url = url || process.env.DOCPIPE_URL || "http://localhost:8080";
|
|
116
|
+
this.token = token || process.env.DOCPIPE_TOKEN || "";
|
|
115
117
|
}
|
|
116
118
|
get docframeCallUrl() {
|
|
117
119
|
return `${this.url}/api/docframe?token=${this.token}`;
|
|
118
120
|
}
|
|
119
|
-
convertTo(format, doc, outputParams) {
|
|
121
|
+
convertTo(format, doc, outputParams, jobParams) {
|
|
120
122
|
const node = doc.toDocFrame();
|
|
121
|
-
const protoData =
|
|
122
|
-
const form = new (
|
|
123
|
+
const protoData = Proto3.Node.encode(node).finish();
|
|
124
|
+
const form = new FormData();
|
|
123
125
|
let meta = {
|
|
124
126
|
format
|
|
125
127
|
};
|
|
@@ -129,6 +131,12 @@ var Connection = class {
|
|
|
129
131
|
...outputParams
|
|
130
132
|
};
|
|
131
133
|
}
|
|
134
|
+
if (jobParams) {
|
|
135
|
+
meta = {
|
|
136
|
+
...meta,
|
|
137
|
+
...jobParams
|
|
138
|
+
};
|
|
139
|
+
}
|
|
132
140
|
form.append("meta", JSON.stringify(meta), {
|
|
133
141
|
contentType: "application/json",
|
|
134
142
|
filename: "meta"
|
|
@@ -138,7 +146,7 @@ var Connection = class {
|
|
|
138
146
|
filename: "data.proto"
|
|
139
147
|
});
|
|
140
148
|
return new Promise((resolve, reject) => {
|
|
141
|
-
|
|
149
|
+
axios.postForm(this.docframeCallUrl, form, {
|
|
142
150
|
headers: {
|
|
143
151
|
...form.getHeaders()
|
|
144
152
|
},
|
|
@@ -159,7 +167,7 @@ var Connection = class {
|
|
|
159
167
|
var defaultConnection = new Connection();
|
|
160
168
|
|
|
161
169
|
// src/Content/Barcode/index.ts
|
|
162
|
-
|
|
170
|
+
import Proto6 from "docframe-types";
|
|
163
171
|
|
|
164
172
|
// src/Content/DocumentElement/index.ts
|
|
165
173
|
var DocumentElement = class {
|
|
@@ -170,11 +178,12 @@ var Measure_exports = {};
|
|
|
170
178
|
__export(Measure_exports, {
|
|
171
179
|
AbsoluteMeasure: () => AbsoluteMeasure,
|
|
172
180
|
Measure: () => Measure,
|
|
173
|
-
SideMeasures: () => SideMeasures
|
|
181
|
+
SideMeasures: () => SideMeasures,
|
|
182
|
+
Sides: () => Sides
|
|
174
183
|
});
|
|
175
184
|
|
|
176
185
|
// src/Measure/Measure.ts
|
|
177
|
-
|
|
186
|
+
import Proto4 from "docframe-types";
|
|
178
187
|
var _Measure = class _Measure {
|
|
179
188
|
constructor(value, unit) {
|
|
180
189
|
this.value = value;
|
|
@@ -183,34 +192,34 @@ var _Measure = class _Measure {
|
|
|
183
192
|
toDocFrame() {
|
|
184
193
|
switch (this.unit) {
|
|
185
194
|
case "pt":
|
|
186
|
-
return new
|
|
195
|
+
return new Proto4.ProtoMeasure({
|
|
187
196
|
value: this.value,
|
|
188
|
-
mtype:
|
|
197
|
+
mtype: Proto4.ProtoMeasureType.PT
|
|
189
198
|
});
|
|
190
199
|
case "cm":
|
|
191
|
-
return new
|
|
200
|
+
return new Proto4.ProtoMeasure({
|
|
192
201
|
value: this.value,
|
|
193
|
-
mtype:
|
|
202
|
+
mtype: Proto4.ProtoMeasureType.CM
|
|
194
203
|
});
|
|
195
204
|
case "mm":
|
|
196
|
-
return new
|
|
205
|
+
return new Proto4.ProtoMeasure({
|
|
197
206
|
value: this.value,
|
|
198
|
-
mtype:
|
|
207
|
+
mtype: Proto4.ProtoMeasureType.MM
|
|
199
208
|
});
|
|
200
209
|
case "in":
|
|
201
|
-
return new
|
|
210
|
+
return new Proto4.ProtoMeasure({
|
|
202
211
|
value: this.value,
|
|
203
|
-
mtype:
|
|
212
|
+
mtype: Proto4.ProtoMeasureType.IN
|
|
204
213
|
});
|
|
205
214
|
case "px":
|
|
206
|
-
return new
|
|
215
|
+
return new Proto4.ProtoMeasure({
|
|
207
216
|
value: this.value,
|
|
208
|
-
mtype:
|
|
217
|
+
mtype: Proto4.ProtoMeasureType.PX
|
|
209
218
|
});
|
|
210
219
|
case "%":
|
|
211
|
-
return new
|
|
220
|
+
return new Proto4.ProtoMeasure({
|
|
212
221
|
value: this.value,
|
|
213
|
-
mtype:
|
|
222
|
+
mtype: Proto4.ProtoMeasureType.PERCENT
|
|
214
223
|
});
|
|
215
224
|
default:
|
|
216
225
|
throw new Error(`Unknown measure unit: ${this.unit}`);
|
|
@@ -227,7 +236,7 @@ var SideMeasures = class {
|
|
|
227
236
|
}
|
|
228
237
|
toDocFrame() {
|
|
229
238
|
var _a, _b, _c, _d;
|
|
230
|
-
return new
|
|
239
|
+
return new Proto4.ProtoSideMeasures({
|
|
231
240
|
top: (_a = this.value.top) == null ? void 0 : _a.toDocFrame(),
|
|
232
241
|
right: (_b = this.value.right) == null ? void 0 : _b.toDocFrame(),
|
|
233
242
|
bottom: (_c = this.value.bottom) == null ? void 0 : _c.toDocFrame(),
|
|
@@ -235,21 +244,23 @@ var SideMeasures = class {
|
|
|
235
244
|
});
|
|
236
245
|
}
|
|
237
246
|
};
|
|
247
|
+
var Sides = class {
|
|
248
|
+
};
|
|
238
249
|
|
|
239
250
|
// src/Content/ReferencePoint/index.ts
|
|
240
|
-
|
|
251
|
+
import Proto5 from "docframe-types";
|
|
241
252
|
function referencePointToDocFrame(point) {
|
|
242
253
|
switch (point) {
|
|
243
254
|
case "top-left":
|
|
244
|
-
return
|
|
255
|
+
return Proto5.ProtoImageReferencePoint.REF_POINT_TOP_LEFT;
|
|
245
256
|
case "top-right":
|
|
246
|
-
return
|
|
257
|
+
return Proto5.ProtoImageReferencePoint.REF_POINT_TOP_RIGHT;
|
|
247
258
|
case "center":
|
|
248
|
-
return
|
|
259
|
+
return Proto5.ProtoImageReferencePoint.REF_POINT_CENTER;
|
|
249
260
|
case "bottom-left":
|
|
250
|
-
return
|
|
261
|
+
return Proto5.ProtoImageReferencePoint.REF_POINT_BOTTOM_LEFT;
|
|
251
262
|
case "bottom-right":
|
|
252
|
-
return
|
|
263
|
+
return Proto5.ProtoImageReferencePoint.REF_POINT_BOTTOM_RIGHT;
|
|
253
264
|
default:
|
|
254
265
|
throw new Error(`Unknown reference point: ${point}`);
|
|
255
266
|
}
|
|
@@ -262,8 +273,8 @@ var Barcode = class extends DocumentElement {
|
|
|
262
273
|
this.props = props;
|
|
263
274
|
}
|
|
264
275
|
toDocFrame() {
|
|
265
|
-
return
|
|
266
|
-
barcode:
|
|
276
|
+
return Proto6.Node.create({
|
|
277
|
+
barcode: Proto6.ProtoBarcode.create({
|
|
267
278
|
type: this.props.type,
|
|
268
279
|
positionAbsolute: this.props.positionAbsolute,
|
|
269
280
|
referencePoint: referencePointToDocFrame(this.props.referencePoint),
|
|
@@ -280,8 +291,8 @@ var Barcode = class extends DocumentElement {
|
|
|
280
291
|
};
|
|
281
292
|
|
|
282
293
|
// src/Content/ColumnDefinition/index.ts
|
|
283
|
-
|
|
284
|
-
|
|
294
|
+
import Proto7 from "docframe-types";
|
|
295
|
+
import { v4 as uuidv4 } from "uuid";
|
|
285
296
|
var ColumnPositionMode = class {
|
|
286
297
|
constructor(value) {
|
|
287
298
|
this.value = value;
|
|
@@ -292,35 +303,35 @@ var ColumnPositionMode = class {
|
|
|
292
303
|
};
|
|
293
304
|
var ColumnPosition;
|
|
294
305
|
((ColumnPosition2) => {
|
|
295
|
-
ColumnPosition2.Center = new ColumnPositionMode(
|
|
296
|
-
ColumnPosition2.Left = new ColumnPositionMode(
|
|
297
|
-
ColumnPosition2.Folio = new ColumnPositionMode(
|
|
298
|
-
ColumnPosition2.Right = new ColumnPositionMode(
|
|
306
|
+
ColumnPosition2.Center = new ColumnPositionMode(Proto7.ProtoPositionMode.CENTER);
|
|
307
|
+
ColumnPosition2.Left = new ColumnPositionMode(Proto7.ProtoPositionMode.LEFT);
|
|
308
|
+
ColumnPosition2.Folio = new ColumnPositionMode(Proto7.ProtoPositionMode.FOLIO);
|
|
309
|
+
ColumnPosition2.Right = new ColumnPositionMode(Proto7.ProtoPositionMode.RIGHT);
|
|
299
310
|
ColumnPosition2.ReverseFolio = new ColumnPositionMode(
|
|
300
|
-
|
|
311
|
+
Proto7.ProtoPositionMode.REVERSE_FOLIO
|
|
301
312
|
);
|
|
302
313
|
})(ColumnPosition || (ColumnPosition = {}));
|
|
303
314
|
var ColumnDefinition = class {
|
|
304
315
|
constructor(props) {
|
|
305
316
|
this.props = props;
|
|
306
|
-
this.uuid =
|
|
317
|
+
this.uuid = uuidv4();
|
|
307
318
|
}
|
|
308
319
|
toDocFrame(applyImmediate) {
|
|
309
320
|
const result = [
|
|
310
|
-
|
|
311
|
-
cDef:
|
|
321
|
+
Proto7.Node.create({
|
|
322
|
+
cDef: Proto7.ProtoCDef.create({
|
|
312
323
|
Uuid: this.uuid,
|
|
313
|
-
columSettings:
|
|
314
|
-
width:
|
|
324
|
+
columSettings: Proto7.ProtoColumnSettings.create({
|
|
325
|
+
width: Proto7.ProtoBoxedMeasure.create({
|
|
315
326
|
isNull: false,
|
|
316
327
|
value: this.props.width.toDocFrame()
|
|
317
328
|
}),
|
|
318
|
-
positionOffset:
|
|
329
|
+
positionOffset: Proto7.ProtoBoxedMeasure.create({
|
|
319
330
|
isNull: false,
|
|
320
331
|
value: this.props.positionOffset.toDocFrame()
|
|
321
332
|
}),
|
|
322
333
|
positionMode: this.props.position.toDocFrame(),
|
|
323
|
-
interColumnSpace:
|
|
334
|
+
interColumnSpace: Proto7.ProtoBoxedMeasure.create({
|
|
324
335
|
isNull: false,
|
|
325
336
|
value: this.props.interColumnSpace.toDocFrame()
|
|
326
337
|
})
|
|
@@ -330,8 +341,8 @@ var ColumnDefinition = class {
|
|
|
330
341
|
];
|
|
331
342
|
if (applyImmediate) {
|
|
332
343
|
result.push(
|
|
333
|
-
|
|
334
|
-
applyCDef:
|
|
344
|
+
Proto7.Node.create({
|
|
345
|
+
applyCDef: Proto7.ProtoApplyProtoCDef.create({
|
|
335
346
|
cDefUuid: this.uuid
|
|
336
347
|
})
|
|
337
348
|
})
|
|
@@ -357,34 +368,19 @@ var ColumnDefinitions = {
|
|
|
357
368
|
}
|
|
358
369
|
};
|
|
359
370
|
|
|
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 || {});
|
|
371
|
+
// src/Content/Directory/index.ts
|
|
372
|
+
import Proto9 from "docframe-types";
|
|
377
373
|
|
|
378
374
|
// src/Content/Text/index.ts
|
|
379
|
-
|
|
375
|
+
import Proto8 from "docframe-types";
|
|
380
376
|
var Text = class extends DocumentElement {
|
|
381
377
|
constructor(content) {
|
|
382
378
|
super();
|
|
383
379
|
this.content = content;
|
|
384
380
|
}
|
|
385
381
|
toDocFrame() {
|
|
386
|
-
return
|
|
387
|
-
text:
|
|
382
|
+
return Proto8.Node.create({
|
|
383
|
+
text: Proto8.ProtoText.create({
|
|
388
384
|
content: this.content
|
|
389
385
|
})
|
|
390
386
|
});
|
|
@@ -435,45 +431,73 @@ function documentElementsFromContent(content) {
|
|
|
435
431
|
}
|
|
436
432
|
}
|
|
437
433
|
|
|
438
|
-
// src/Content/
|
|
434
|
+
// src/Content/Directory/index.ts
|
|
435
|
+
var Directory = class extends BranchDocumentElement {
|
|
436
|
+
toDocFrame() {
|
|
437
|
+
return Proto9.Node.create({
|
|
438
|
+
directory: Proto9.ProtoDirectory.create({}),
|
|
439
|
+
children: this.childrenToDocFrame()
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
};
|
|
439
443
|
|
|
444
|
+
// src/Content/Document/index.ts
|
|
445
|
+
import Proto15 from "docframe-types";
|
|
446
|
+
|
|
447
|
+
// src/OutputFormat/index.ts
|
|
448
|
+
var OutputFormat_exports = {};
|
|
449
|
+
__export(OutputFormat_exports, {
|
|
450
|
+
OutputFormat: () => OutputFormat
|
|
451
|
+
});
|
|
452
|
+
var OutputFormat = /* @__PURE__ */ ((OutputFormat2) => {
|
|
453
|
+
OutputFormat2["PDF"] = "pdf";
|
|
454
|
+
OutputFormat2["PNG"] = "png";
|
|
455
|
+
OutputFormat2["JPEG"] = "jpeg";
|
|
456
|
+
OutputFormat2["HTML"] = "html";
|
|
457
|
+
OutputFormat2["PS"] = "ps";
|
|
458
|
+
OutputFormat2["TEXT"] = "text";
|
|
459
|
+
return OutputFormat2;
|
|
460
|
+
})(OutputFormat || {});
|
|
461
|
+
|
|
462
|
+
// src/Content/Footer/index.ts
|
|
463
|
+
import Proto10 from "docframe-types";
|
|
440
464
|
var Footer = class extends BranchDocumentElement {
|
|
441
465
|
toDocFrame() {
|
|
442
|
-
return
|
|
443
|
-
footer:
|
|
466
|
+
return Proto10.Node.create({
|
|
467
|
+
footer: Proto10.ProtoFooter.create(),
|
|
444
468
|
children: this.childrenToDocFrame()
|
|
445
469
|
});
|
|
446
470
|
}
|
|
447
471
|
};
|
|
448
472
|
|
|
449
473
|
// src/Content/Header/index.ts
|
|
450
|
-
|
|
474
|
+
import Proto11 from "docframe-types";
|
|
451
475
|
var Header = class extends BranchDocumentElement {
|
|
452
476
|
toDocFrame() {
|
|
453
|
-
return
|
|
454
|
-
header:
|
|
477
|
+
return Proto11.Node.create({
|
|
478
|
+
header: Proto11.ProtoHeader.create(),
|
|
455
479
|
children: this.childrenToDocFrame()
|
|
456
480
|
});
|
|
457
481
|
}
|
|
458
482
|
};
|
|
459
483
|
|
|
460
484
|
// src/Content/PageDefinition/index.ts
|
|
461
|
-
|
|
462
|
-
|
|
485
|
+
import Proto12 from "docframe-types";
|
|
486
|
+
import { v4 } from "uuid";
|
|
463
487
|
var PageDefinition = class {
|
|
464
488
|
constructor(width, height) {
|
|
465
489
|
this.width = width;
|
|
466
490
|
this.height = height;
|
|
467
|
-
this.uuid =
|
|
491
|
+
this.uuid = v4();
|
|
468
492
|
}
|
|
469
493
|
toDocFrame() {
|
|
470
494
|
var _a, _b;
|
|
471
|
-
return new
|
|
472
|
-
pageDepth: new
|
|
495
|
+
return new Proto12.ProtoPDef({
|
|
496
|
+
pageDepth: new Proto12.ProtoBoxedMeasure({
|
|
473
497
|
isNull: this.height === void 0,
|
|
474
498
|
value: (_a = this.height) == null ? void 0 : _a.toDocFrame()
|
|
475
499
|
}),
|
|
476
|
-
pageWidth: new
|
|
500
|
+
pageWidth: new Proto12.ProtoBoxedMeasure({
|
|
477
501
|
isNull: this.width === void 0,
|
|
478
502
|
value: (_b = this.width) == null ? void 0 : _b.toDocFrame()
|
|
479
503
|
}),
|
|
@@ -498,110 +522,110 @@ var PageDefinitions;
|
|
|
498
522
|
})(PageDefinitions || (PageDefinitions = {}));
|
|
499
523
|
|
|
500
524
|
// src/ParagraphFormat/index.ts
|
|
501
|
-
|
|
502
|
-
|
|
525
|
+
import Proto13 from "docframe-types";
|
|
526
|
+
import { v4 as uuidv42 } from "uuid";
|
|
503
527
|
var ParagraphFormat = class {
|
|
504
528
|
constructor(props) {
|
|
505
529
|
this.props = props;
|
|
506
|
-
this.props.name = props.name ||
|
|
530
|
+
this.props.name = props.name || uuidv42();
|
|
507
531
|
}
|
|
508
532
|
toDocFrame() {
|
|
509
533
|
let format = {
|
|
510
|
-
default:
|
|
534
|
+
default: Proto13.ProtoBoxedBool.create({
|
|
511
535
|
isNull: false,
|
|
512
536
|
value: this.props.default || false
|
|
513
537
|
}),
|
|
514
|
-
name:
|
|
538
|
+
name: Proto13.ProtoBoxedString.create({
|
|
515
539
|
isNull: false,
|
|
516
540
|
value: this.props.name
|
|
517
541
|
})
|
|
518
542
|
};
|
|
519
543
|
if (this.props.alignment) {
|
|
520
|
-
format.alignment =
|
|
544
|
+
format.alignment = Proto13.ProtoBoxedHorizontalAlignment.create({
|
|
521
545
|
isNull: false,
|
|
522
546
|
value: this.props.alignment.toDocFrame()
|
|
523
547
|
});
|
|
524
548
|
}
|
|
525
549
|
if (this.props.font) {
|
|
526
|
-
format.font =
|
|
550
|
+
format.font = Proto13.ProtoBoxedFont.create({
|
|
527
551
|
isNull: false,
|
|
528
552
|
value: this.props.font.toDocFrame()
|
|
529
553
|
});
|
|
530
554
|
}
|
|
531
555
|
if (this.props.fontSize) {
|
|
532
|
-
format.fontSize =
|
|
556
|
+
format.fontSize = Proto13.ProtoBoxedMeasure.create({
|
|
533
557
|
isNull: false,
|
|
534
558
|
value: this.props.fontSize.toDocFrame()
|
|
535
559
|
});
|
|
536
560
|
}
|
|
537
561
|
if (this.props.characterWidth) {
|
|
538
|
-
format.characterWidth =
|
|
562
|
+
format.characterWidth = Proto13.ProtoBoxedMeasure.create({
|
|
539
563
|
isNull: false,
|
|
540
564
|
value: this.props.characterWidth.toDocFrame()
|
|
541
565
|
});
|
|
542
566
|
}
|
|
543
567
|
if (this.props.characterSpacing) {
|
|
544
|
-
format.characterSpacing =
|
|
568
|
+
format.characterSpacing = Proto13.ProtoBoxedMeasure.create({
|
|
545
569
|
isNull: false,
|
|
546
570
|
value: this.props.characterSpacing.toDocFrame()
|
|
547
571
|
});
|
|
548
572
|
}
|
|
549
573
|
if (this.props.lineFeed) {
|
|
550
|
-
format.lineFeed =
|
|
574
|
+
format.lineFeed = Proto13.ProtoBoxedMeasure.create({
|
|
551
575
|
isNull: false,
|
|
552
576
|
value: this.props.lineFeed.toDocFrame()
|
|
553
577
|
});
|
|
554
578
|
}
|
|
555
579
|
if (this.props.indentionLevel !== void 0) {
|
|
556
|
-
format.indentionLevel =
|
|
580
|
+
format.indentionLevel = Proto13.ProtoBoxedInt32.create({
|
|
557
581
|
isNull: false,
|
|
558
582
|
value: this.props.indentionLevel
|
|
559
583
|
});
|
|
560
584
|
}
|
|
561
585
|
if (this.props.indentionWidth) {
|
|
562
|
-
format.indentionWidth =
|
|
586
|
+
format.indentionWidth = Proto13.ProtoBoxedMeasure.create({
|
|
563
587
|
isNull: false,
|
|
564
588
|
value: this.props.indentionWidth.toDocFrame()
|
|
565
589
|
});
|
|
566
590
|
}
|
|
567
591
|
if (this.props.bold !== void 0) {
|
|
568
|
-
format.bold =
|
|
592
|
+
format.bold = Proto13.ProtoBoxedBool.create({
|
|
569
593
|
isNull: false,
|
|
570
594
|
value: !!this.props.bold
|
|
571
595
|
});
|
|
572
596
|
}
|
|
573
597
|
if (this.props.italic !== void 0) {
|
|
574
|
-
format.italic =
|
|
598
|
+
format.italic = Proto13.ProtoBoxedBool.create({
|
|
575
599
|
isNull: false,
|
|
576
600
|
value: !!this.props.italic
|
|
577
601
|
});
|
|
578
602
|
}
|
|
579
603
|
if (this.props.spaceAbove) {
|
|
580
|
-
format.spaceAbove =
|
|
604
|
+
format.spaceAbove = Proto13.ProtoBoxedMeasure.create({
|
|
581
605
|
isNull: false,
|
|
582
606
|
value: this.props.spaceAbove.toDocFrame()
|
|
583
607
|
});
|
|
584
608
|
}
|
|
585
609
|
if (this.props.spaceBelow) {
|
|
586
|
-
format.spaceBelow =
|
|
610
|
+
format.spaceBelow = Proto13.ProtoBoxedMeasure.create({
|
|
587
611
|
isNull: false,
|
|
588
612
|
value: this.props.spaceBelow.toDocFrame()
|
|
589
613
|
});
|
|
590
614
|
}
|
|
591
|
-
return
|
|
615
|
+
return Proto13.ProtoParagraphFormat.create(format);
|
|
592
616
|
}
|
|
593
617
|
};
|
|
594
618
|
|
|
595
619
|
// src/Content/SpaceVertically/index.ts
|
|
596
|
-
|
|
620
|
+
import Proto14 from "docframe-types";
|
|
597
621
|
var SpaceVertically = class extends DocumentElement {
|
|
598
622
|
constructor(space) {
|
|
599
623
|
super();
|
|
600
624
|
this.space = space;
|
|
601
625
|
}
|
|
602
626
|
toDocFrame() {
|
|
603
|
-
return
|
|
604
|
-
spaceVertically:
|
|
627
|
+
return Proto14.Node.create({
|
|
628
|
+
spaceVertically: Proto14.ProtoSpaceVertically.create({
|
|
605
629
|
space: this.space.toDocFrame()
|
|
606
630
|
})
|
|
607
631
|
});
|
|
@@ -609,13 +633,13 @@ var SpaceVertically = class extends DocumentElement {
|
|
|
609
633
|
};
|
|
610
634
|
|
|
611
635
|
// src/Font/index.ts
|
|
612
|
-
|
|
636
|
+
import { ProtoFont } from "docframe-types";
|
|
613
637
|
var Font = class {
|
|
614
638
|
constructor(name) {
|
|
615
639
|
this.name = name;
|
|
616
640
|
}
|
|
617
641
|
toDocFrame() {
|
|
618
|
-
return
|
|
642
|
+
return ProtoFont.create({
|
|
619
643
|
name: this.name,
|
|
620
644
|
// TODO: suppot font mapping for docframe step
|
|
621
645
|
id: 5
|
|
@@ -688,15 +712,15 @@ var Document = class extends BranchDocumentElement {
|
|
|
688
712
|
toDocFrame() {
|
|
689
713
|
const props = this.props;
|
|
690
714
|
const docSettings = Object.values(this.paragraphFormats).map(
|
|
691
|
-
(pf) =>
|
|
715
|
+
(pf) => Proto15.Node.create({
|
|
692
716
|
paragraphFormat: pf.toDocFrame()
|
|
693
717
|
})
|
|
694
718
|
).concat([
|
|
695
|
-
|
|
719
|
+
Proto15.Node.create({
|
|
696
720
|
pDef: props.pageDefinition.toDocFrame()
|
|
697
721
|
}),
|
|
698
|
-
|
|
699
|
-
applyPDef:
|
|
722
|
+
Proto15.Node.create({
|
|
723
|
+
applyPDef: Proto15.ProtoApplyProtoPDef.create({
|
|
700
724
|
pDefUuid: props.pageDefinition.uuid
|
|
701
725
|
})
|
|
702
726
|
}),
|
|
@@ -711,19 +735,19 @@ var Document = class extends BranchDocumentElement {
|
|
|
711
735
|
const content = this.childrenToDocFrame();
|
|
712
736
|
for (const format of Object.values(this.paragraphFormats)) {
|
|
713
737
|
docSettings.push(
|
|
714
|
-
|
|
738
|
+
Proto15.Node.create({
|
|
715
739
|
paragraphFormat: format.toDocFrame()
|
|
716
740
|
})
|
|
717
741
|
);
|
|
718
742
|
}
|
|
719
|
-
return
|
|
743
|
+
return Proto15.Node.create({
|
|
720
744
|
children: docSettings.concat(...content)
|
|
721
745
|
});
|
|
722
746
|
}
|
|
723
747
|
};
|
|
724
748
|
|
|
725
749
|
// src/Content/Formatted/index.ts
|
|
726
|
-
|
|
750
|
+
import Proto16 from "docframe-types";
|
|
727
751
|
var Formatted = class extends DocumentElement {
|
|
728
752
|
constructor(doctypeContent, htmlContent) {
|
|
729
753
|
super();
|
|
@@ -733,8 +757,8 @@ var Formatted = class extends DocumentElement {
|
|
|
733
757
|
};
|
|
734
758
|
}
|
|
735
759
|
toDocFrame() {
|
|
736
|
-
return
|
|
737
|
-
formatted:
|
|
760
|
+
return Proto16.Node.create({
|
|
761
|
+
formatted: Proto16.ProtoFormatted.create({
|
|
738
762
|
doctypeContent: this.content.doctype,
|
|
739
763
|
htmlContent: this.content.html
|
|
740
764
|
})
|
|
@@ -742,18 +766,28 @@ var Formatted = class extends DocumentElement {
|
|
|
742
766
|
}
|
|
743
767
|
};
|
|
744
768
|
|
|
745
|
-
// src/Content/
|
|
769
|
+
// src/Content/Linebreak/index.ts
|
|
770
|
+
import Proto17 from "docframe-types";
|
|
771
|
+
var Linebreak = class extends DocumentElement {
|
|
772
|
+
toDocFrame() {
|
|
773
|
+
return Proto17.Node.create({
|
|
774
|
+
linebreak: Proto17.ProtoLinebreak.create({})
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
};
|
|
746
778
|
|
|
779
|
+
// src/Content/Pagebreak/index.ts
|
|
780
|
+
import Proto18 from "docframe-types";
|
|
747
781
|
var Pagebreak = class extends DocumentElement {
|
|
748
782
|
toDocFrame() {
|
|
749
|
-
return
|
|
750
|
-
newPage:
|
|
783
|
+
return Proto18.Node.create({
|
|
784
|
+
newPage: Proto18.ProtoNewPage.create({})
|
|
751
785
|
});
|
|
752
786
|
}
|
|
753
787
|
};
|
|
754
788
|
|
|
755
789
|
// src/Content/Paragraph/index.ts
|
|
756
|
-
|
|
790
|
+
import Proto19 from "docframe-types";
|
|
757
791
|
var Paragraph = class extends BranchDocumentElement {
|
|
758
792
|
constructor(content, paragraphFormatName, overwrite) {
|
|
759
793
|
var _a;
|
|
@@ -768,22 +802,70 @@ var Paragraph = class extends BranchDocumentElement {
|
|
|
768
802
|
par.overwrite = this.props.overwrite.toDocFrame();
|
|
769
803
|
}
|
|
770
804
|
if (this.props.paragraphFormatName) {
|
|
771
|
-
par.format =
|
|
772
|
-
name:
|
|
805
|
+
par.format = Proto19.ProtoParagraphFormat.create({
|
|
806
|
+
name: Proto19.ProtoBoxedString.create({
|
|
773
807
|
isNull: false,
|
|
774
808
|
value: this.props.paragraphFormatName
|
|
775
809
|
})
|
|
776
810
|
});
|
|
777
811
|
}
|
|
778
|
-
return
|
|
779
|
-
paragraph:
|
|
812
|
+
return Proto19.Node.create({
|
|
813
|
+
paragraph: Proto19.ProtoParagraph.create(par),
|
|
780
814
|
children: this.childrenToDocFrame()
|
|
781
815
|
});
|
|
782
816
|
}
|
|
783
817
|
};
|
|
784
818
|
|
|
785
|
-
// src/Content/
|
|
819
|
+
// src/Content/Span/index.ts
|
|
820
|
+
import Proto20 from "docframe-types";
|
|
821
|
+
var Span = class extends BranchDocumentElement {
|
|
822
|
+
constructor(content, props) {
|
|
823
|
+
super(content, props || {});
|
|
824
|
+
}
|
|
825
|
+
toDocFrame() {
|
|
826
|
+
var _a, _b, _c, _d;
|
|
827
|
+
let bold = void 0;
|
|
828
|
+
if (((_a = this.props) == null ? void 0 : _a.bold) !== void 0) {
|
|
829
|
+
bold = Proto20.ProtoBoxedBool.create({
|
|
830
|
+
isNull: false,
|
|
831
|
+
value: this.props.bold
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
let italic = void 0;
|
|
835
|
+
if (((_b = this.props) == null ? void 0 : _b.italic) !== void 0) {
|
|
836
|
+
italic = Proto20.ProtoBoxedBool.create({
|
|
837
|
+
isNull: false,
|
|
838
|
+
value: this.props.italic
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
let underline = void 0;
|
|
842
|
+
if (((_c = this.props) == null ? void 0 : _c.underline) !== void 0) {
|
|
843
|
+
underline = Proto20.ProtoBoxedBool.create({
|
|
844
|
+
isNull: false,
|
|
845
|
+
value: this.props.underline
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
let strikethrough = void 0;
|
|
849
|
+
if (((_d = this.props) == null ? void 0 : _d.strikethrough) !== void 0) {
|
|
850
|
+
strikethrough = Proto20.ProtoBoxedBool.create({
|
|
851
|
+
isNull: false,
|
|
852
|
+
value: this.props.strikethrough
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
return Proto20.Node.create({
|
|
856
|
+
span: Proto20.ProtoSpan.create({
|
|
857
|
+
bold,
|
|
858
|
+
italic,
|
|
859
|
+
underline,
|
|
860
|
+
strikethrough
|
|
861
|
+
}),
|
|
862
|
+
children: this.childrenToDocFrame()
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
};
|
|
786
866
|
|
|
867
|
+
// src/Content/Table/index.ts
|
|
868
|
+
import Proto21 from "docframe-types";
|
|
787
869
|
var Table = class extends BranchDocumentElement {
|
|
788
870
|
constructor(content, props) {
|
|
789
871
|
super(content, props || {});
|
|
@@ -794,11 +876,11 @@ var Table = class extends BranchDocumentElement {
|
|
|
794
876
|
toDocFrame() {
|
|
795
877
|
var _a, _b;
|
|
796
878
|
const props = this.props;
|
|
797
|
-
return
|
|
798
|
-
table:
|
|
799
|
-
settings:
|
|
879
|
+
return Proto21.Node.create({
|
|
880
|
+
table: Proto21.ProtoTable.create({
|
|
881
|
+
settings: Proto21.ProtoTableSettings.create({
|
|
800
882
|
width: (_a = props.width) == null ? void 0 : _a.toDocFrame(),
|
|
801
|
-
leftMeasure:
|
|
883
|
+
leftMeasure: Proto21.ProtoBoxedBool.create({
|
|
802
884
|
isNull: false,
|
|
803
885
|
value: false
|
|
804
886
|
}),
|
|
@@ -811,7 +893,7 @@ var Table = class extends BranchDocumentElement {
|
|
|
811
893
|
};
|
|
812
894
|
|
|
813
895
|
// src/Content/TableCell/index.ts
|
|
814
|
-
|
|
896
|
+
import Proto22 from "docframe-types";
|
|
815
897
|
var TableCell = class extends BranchDocumentElement {
|
|
816
898
|
constructor(content, props) {
|
|
817
899
|
super(content, props || {});
|
|
@@ -819,20 +901,20 @@ var TableCell = class extends BranchDocumentElement {
|
|
|
819
901
|
toDocFrame() {
|
|
820
902
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
821
903
|
const props = this.props;
|
|
822
|
-
return
|
|
823
|
-
tableCell:
|
|
824
|
-
settings:
|
|
825
|
-
align:
|
|
904
|
+
return Proto22.Node.create({
|
|
905
|
+
tableCell: Proto22.ProtoTableCell.create({
|
|
906
|
+
settings: Proto22.ProtoTableCellSettings.create({
|
|
907
|
+
align: Proto22.ProtoBoxedHorizontalAlignment.create({
|
|
826
908
|
isNull: false,
|
|
827
|
-
value: ((_a = props.alignment) == null ? void 0 : _a.toDocFrame()) ||
|
|
909
|
+
value: ((_a = props.alignment) == null ? void 0 : _a.toDocFrame()) || Proto22.ProtoHorizontalAlignment.ALIGN_LEFT
|
|
828
910
|
}),
|
|
829
911
|
backgroundColor: (_b = props.backgroundColor) == null ? void 0 : _b.toDocFrame(),
|
|
830
912
|
border: (_c = props.border) == null ? void 0 : _c.toDocFrame(),
|
|
831
913
|
margin: (_d = props.margin) == null ? void 0 : _d.toDocFrame(),
|
|
832
914
|
padding: (_e = props.padding) == null ? void 0 : _e.toDocFrame(),
|
|
833
|
-
valign:
|
|
915
|
+
valign: Proto22.ProtoBoxedVerticalAlignment.create({
|
|
834
916
|
isNull: false,
|
|
835
|
-
value: ((_f = props.verticalAlignment) == null ? void 0 : _f.toDocFrame()) ||
|
|
917
|
+
value: ((_f = props.verticalAlignment) == null ? void 0 : _f.toDocFrame()) || Proto22.ProtoVerticalAlignment.TOP
|
|
836
918
|
}),
|
|
837
919
|
width: (_g = props.width) == null ? void 0 : _g.toDocFrame()
|
|
838
920
|
})
|
|
@@ -843,16 +925,16 @@ var TableCell = class extends BranchDocumentElement {
|
|
|
843
925
|
};
|
|
844
926
|
|
|
845
927
|
// src/Content/TableRow/index.ts
|
|
846
|
-
|
|
928
|
+
import Proto23 from "docframe-types";
|
|
847
929
|
var TableRow = class extends BranchDocumentElement {
|
|
848
930
|
constructor(content, props) {
|
|
849
931
|
super(content, props || {});
|
|
850
932
|
}
|
|
851
933
|
toDocFrame() {
|
|
852
934
|
var _a;
|
|
853
|
-
return
|
|
854
|
-
tableRow:
|
|
855
|
-
settings:
|
|
935
|
+
return Proto23.Node.create({
|
|
936
|
+
tableRow: Proto23.ProtoTableRow.create({
|
|
937
|
+
settings: Proto23.ProtoTableRowSettings.create({
|
|
856
938
|
minHeight: (_a = this.props.minHeight) == null ? void 0 : _a.toDocFrame()
|
|
857
939
|
})
|
|
858
940
|
}),
|
|
@@ -866,12 +948,17 @@ var Content_default = {
|
|
|
866
948
|
Barcode,
|
|
867
949
|
ColumnDefinition,
|
|
868
950
|
ColumnPosition,
|
|
951
|
+
Directory,
|
|
869
952
|
Document,
|
|
953
|
+
Footer,
|
|
870
954
|
Formatted,
|
|
871
|
-
|
|
955
|
+
Header,
|
|
956
|
+
Linebreak,
|
|
872
957
|
Pagebreak,
|
|
958
|
+
PageDefinition,
|
|
873
959
|
Paragraph,
|
|
874
960
|
SpaceVertically,
|
|
961
|
+
Span,
|
|
875
962
|
Table,
|
|
876
963
|
TableCell,
|
|
877
964
|
TableRow,
|
|
@@ -898,6 +985,7 @@ var index_default = {
|
|
|
898
985
|
Output: OutputFormat_exports,
|
|
899
986
|
ParagraphFormat
|
|
900
987
|
};
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
988
|
+
export {
|
|
989
|
+
index_default as default
|
|
990
|
+
};
|
|
991
|
+
//# sourceMappingURL=index.js.map
|