ts-d2 0.0.3 → 0.0.5
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 +1 -1
- package/dist/index.d.mts +55 -15
- package/dist/index.d.ts +55 -15
- package/dist/index.js +152 -69
- package/dist/index.mjs +253 -170
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -104,8 +104,62 @@ var Colors;
|
|
|
104
104
|
Colors2.black = Color.cmyk(0, 0, 0, 100);
|
|
105
105
|
})(Colors || (Colors = {}));
|
|
106
106
|
|
|
107
|
+
// src/Connection/index.ts
|
|
108
|
+
import axios from "axios";
|
|
109
|
+
import FormData from "form-data";
|
|
110
|
+
import Proto3 from "docframe-types";
|
|
111
|
+
var Connection = class {
|
|
112
|
+
constructor(url = "http://localhost:8080", token = "") {
|
|
113
|
+
this.url = url;
|
|
114
|
+
this.token = token;
|
|
115
|
+
}
|
|
116
|
+
get docframeCallUrl() {
|
|
117
|
+
return `${this.url}/api/docframe?token=${this.token}`;
|
|
118
|
+
}
|
|
119
|
+
convertTo(format, doc, outputParams) {
|
|
120
|
+
const node = doc.toDocFrame();
|
|
121
|
+
const protoData = Proto3.Node.encode(node).finish();
|
|
122
|
+
const form = new FormData();
|
|
123
|
+
let meta = {
|
|
124
|
+
format
|
|
125
|
+
};
|
|
126
|
+
if (outputParams) {
|
|
127
|
+
meta = {
|
|
128
|
+
...meta,
|
|
129
|
+
...outputParams
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
form.append("meta", JSON.stringify(meta), {
|
|
133
|
+
contentType: "application/json",
|
|
134
|
+
filename: "meta"
|
|
135
|
+
});
|
|
136
|
+
form.append("proto-data", protoData, {
|
|
137
|
+
contentType: "application/protobuf",
|
|
138
|
+
filename: "data.proto"
|
|
139
|
+
});
|
|
140
|
+
return new Promise((resolve, reject) => {
|
|
141
|
+
axios.postForm(this.docframeCallUrl, form, {
|
|
142
|
+
headers: {
|
|
143
|
+
...form.getHeaders()
|
|
144
|
+
},
|
|
145
|
+
responseType: "arraybuffer"
|
|
146
|
+
}).then(async (res) => {
|
|
147
|
+
const blob = await new Response(res.data, {
|
|
148
|
+
headers: {
|
|
149
|
+
"Content-Type": res.headers["content-type"]
|
|
150
|
+
}
|
|
151
|
+
}).blob();
|
|
152
|
+
resolve(blob);
|
|
153
|
+
}).catch((err) => {
|
|
154
|
+
reject(err);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
var defaultConnection = new Connection();
|
|
160
|
+
|
|
107
161
|
// src/Content/Barcode/index.ts
|
|
108
|
-
import
|
|
162
|
+
import Proto6 from "docframe-types";
|
|
109
163
|
|
|
110
164
|
// src/Content/DocumentElement/index.ts
|
|
111
165
|
var DocumentElement = class {
|
|
@@ -120,7 +174,7 @@ __export(Measure_exports, {
|
|
|
120
174
|
});
|
|
121
175
|
|
|
122
176
|
// src/Measure/Measure.ts
|
|
123
|
-
import
|
|
177
|
+
import Proto4 from "docframe-types";
|
|
124
178
|
var _Measure = class _Measure {
|
|
125
179
|
constructor(value, unit) {
|
|
126
180
|
this.value = value;
|
|
@@ -129,34 +183,34 @@ var _Measure = class _Measure {
|
|
|
129
183
|
toDocFrame() {
|
|
130
184
|
switch (this.unit) {
|
|
131
185
|
case "pt":
|
|
132
|
-
return new
|
|
186
|
+
return new Proto4.ProtoMeasure({
|
|
133
187
|
value: this.value,
|
|
134
|
-
mtype:
|
|
188
|
+
mtype: Proto4.ProtoMeasureType.PT
|
|
135
189
|
});
|
|
136
190
|
case "cm":
|
|
137
|
-
return new
|
|
191
|
+
return new Proto4.ProtoMeasure({
|
|
138
192
|
value: this.value,
|
|
139
|
-
mtype:
|
|
193
|
+
mtype: Proto4.ProtoMeasureType.CM
|
|
140
194
|
});
|
|
141
195
|
case "mm":
|
|
142
|
-
return new
|
|
196
|
+
return new Proto4.ProtoMeasure({
|
|
143
197
|
value: this.value,
|
|
144
|
-
mtype:
|
|
198
|
+
mtype: Proto4.ProtoMeasureType.MM
|
|
145
199
|
});
|
|
146
200
|
case "in":
|
|
147
|
-
return new
|
|
201
|
+
return new Proto4.ProtoMeasure({
|
|
148
202
|
value: this.value,
|
|
149
|
-
mtype:
|
|
203
|
+
mtype: Proto4.ProtoMeasureType.IN
|
|
150
204
|
});
|
|
151
205
|
case "px":
|
|
152
|
-
return new
|
|
206
|
+
return new Proto4.ProtoMeasure({
|
|
153
207
|
value: this.value,
|
|
154
|
-
mtype:
|
|
208
|
+
mtype: Proto4.ProtoMeasureType.PX
|
|
155
209
|
});
|
|
156
210
|
case "%":
|
|
157
|
-
return new
|
|
211
|
+
return new Proto4.ProtoMeasure({
|
|
158
212
|
value: this.value,
|
|
159
|
-
mtype:
|
|
213
|
+
mtype: Proto4.ProtoMeasureType.PERCENT
|
|
160
214
|
});
|
|
161
215
|
default:
|
|
162
216
|
throw new Error(`Unknown measure unit: ${this.unit}`);
|
|
@@ -173,7 +227,7 @@ var SideMeasures = class {
|
|
|
173
227
|
}
|
|
174
228
|
toDocFrame() {
|
|
175
229
|
var _a, _b, _c, _d;
|
|
176
|
-
return new
|
|
230
|
+
return new Proto4.ProtoSideMeasures({
|
|
177
231
|
top: (_a = this.value.top) == null ? void 0 : _a.toDocFrame(),
|
|
178
232
|
right: (_b = this.value.right) == null ? void 0 : _b.toDocFrame(),
|
|
179
233
|
bottom: (_c = this.value.bottom) == null ? void 0 : _c.toDocFrame(),
|
|
@@ -183,19 +237,19 @@ var SideMeasures = class {
|
|
|
183
237
|
};
|
|
184
238
|
|
|
185
239
|
// src/Content/ReferencePoint/index.ts
|
|
186
|
-
import
|
|
240
|
+
import Proto5 from "docframe-types";
|
|
187
241
|
function referencePointToDocFrame(point) {
|
|
188
242
|
switch (point) {
|
|
189
243
|
case "top-left":
|
|
190
|
-
return
|
|
244
|
+
return Proto5.ProtoImageReferencePoint.REF_POINT_TOP_LEFT;
|
|
191
245
|
case "top-right":
|
|
192
|
-
return
|
|
246
|
+
return Proto5.ProtoImageReferencePoint.REF_POINT_TOP_RIGHT;
|
|
193
247
|
case "center":
|
|
194
|
-
return
|
|
248
|
+
return Proto5.ProtoImageReferencePoint.REF_POINT_CENTER;
|
|
195
249
|
case "bottom-left":
|
|
196
|
-
return
|
|
250
|
+
return Proto5.ProtoImageReferencePoint.REF_POINT_BOTTOM_LEFT;
|
|
197
251
|
case "bottom-right":
|
|
198
|
-
return
|
|
252
|
+
return Proto5.ProtoImageReferencePoint.REF_POINT_BOTTOM_RIGHT;
|
|
199
253
|
default:
|
|
200
254
|
throw new Error(`Unknown reference point: ${point}`);
|
|
201
255
|
}
|
|
@@ -208,8 +262,8 @@ var Barcode = class extends DocumentElement {
|
|
|
208
262
|
this.props = props;
|
|
209
263
|
}
|
|
210
264
|
toDocFrame() {
|
|
211
|
-
return
|
|
212
|
-
barcode:
|
|
265
|
+
return Proto6.Node.create({
|
|
266
|
+
barcode: Proto6.ProtoBarcode.create({
|
|
213
267
|
type: this.props.type,
|
|
214
268
|
positionAbsolute: this.props.positionAbsolute,
|
|
215
269
|
referencePoint: referencePointToDocFrame(this.props.referencePoint),
|
|
@@ -226,7 +280,7 @@ var Barcode = class extends DocumentElement {
|
|
|
226
280
|
};
|
|
227
281
|
|
|
228
282
|
// src/Content/ColumnDefinition/index.ts
|
|
229
|
-
import
|
|
283
|
+
import Proto7 from "docframe-types";
|
|
230
284
|
import { v4 as uuidv4 } from "uuid";
|
|
231
285
|
var ColumnPositionMode = class {
|
|
232
286
|
constructor(value) {
|
|
@@ -238,12 +292,12 @@ var ColumnPositionMode = class {
|
|
|
238
292
|
};
|
|
239
293
|
var ColumnPosition;
|
|
240
294
|
((ColumnPosition2) => {
|
|
241
|
-
ColumnPosition2.Center = new ColumnPositionMode(
|
|
242
|
-
ColumnPosition2.Left = new ColumnPositionMode(
|
|
243
|
-
ColumnPosition2.Folio = new ColumnPositionMode(
|
|
244
|
-
ColumnPosition2.Right = new ColumnPositionMode(
|
|
295
|
+
ColumnPosition2.Center = new ColumnPositionMode(Proto7.ProtoPositionMode.CENTER);
|
|
296
|
+
ColumnPosition2.Left = new ColumnPositionMode(Proto7.ProtoPositionMode.LEFT);
|
|
297
|
+
ColumnPosition2.Folio = new ColumnPositionMode(Proto7.ProtoPositionMode.FOLIO);
|
|
298
|
+
ColumnPosition2.Right = new ColumnPositionMode(Proto7.ProtoPositionMode.RIGHT);
|
|
245
299
|
ColumnPosition2.ReverseFolio = new ColumnPositionMode(
|
|
246
|
-
|
|
300
|
+
Proto7.ProtoPositionMode.REVERSE_FOLIO
|
|
247
301
|
);
|
|
248
302
|
})(ColumnPosition || (ColumnPosition = {}));
|
|
249
303
|
var ColumnDefinition = class {
|
|
@@ -253,20 +307,20 @@ var ColumnDefinition = class {
|
|
|
253
307
|
}
|
|
254
308
|
toDocFrame(applyImmediate) {
|
|
255
309
|
const result = [
|
|
256
|
-
|
|
257
|
-
cDef:
|
|
310
|
+
Proto7.Node.create({
|
|
311
|
+
cDef: Proto7.ProtoCDef.create({
|
|
258
312
|
Uuid: this.uuid,
|
|
259
|
-
columSettings:
|
|
260
|
-
width:
|
|
313
|
+
columSettings: Proto7.ProtoColumnSettings.create({
|
|
314
|
+
width: Proto7.ProtoBoxedMeasure.create({
|
|
261
315
|
isNull: false,
|
|
262
316
|
value: this.props.width.toDocFrame()
|
|
263
317
|
}),
|
|
264
|
-
positionOffset:
|
|
318
|
+
positionOffset: Proto7.ProtoBoxedMeasure.create({
|
|
265
319
|
isNull: false,
|
|
266
320
|
value: this.props.positionOffset.toDocFrame()
|
|
267
321
|
}),
|
|
268
322
|
positionMode: this.props.position.toDocFrame(),
|
|
269
|
-
interColumnSpace:
|
|
323
|
+
interColumnSpace: Proto7.ProtoBoxedMeasure.create({
|
|
270
324
|
isNull: false,
|
|
271
325
|
value: this.props.interColumnSpace.toDocFrame()
|
|
272
326
|
})
|
|
@@ -276,8 +330,8 @@ var ColumnDefinition = class {
|
|
|
276
330
|
];
|
|
277
331
|
if (applyImmediate) {
|
|
278
332
|
result.push(
|
|
279
|
-
|
|
280
|
-
applyCDef:
|
|
333
|
+
Proto7.Node.create({
|
|
334
|
+
applyCDef: Proto7.ProtoApplyProtoCDef.create({
|
|
281
335
|
cDefUuid: this.uuid
|
|
282
336
|
})
|
|
283
337
|
})
|
|
@@ -303,73 +357,8 @@ var ColumnDefinitions = {
|
|
|
303
357
|
}
|
|
304
358
|
};
|
|
305
359
|
|
|
306
|
-
// src/Content/
|
|
307
|
-
import
|
|
308
|
-
|
|
309
|
-
// src/Connection/index.ts
|
|
310
|
-
import axios from "axios";
|
|
311
|
-
import FormData from "form-data";
|
|
312
|
-
import Proto7 from "docframe-types";
|
|
313
|
-
var Connection = class {
|
|
314
|
-
constructor(url = "http://localhost:8080", token = "") {
|
|
315
|
-
this.url = url;
|
|
316
|
-
this.token = token;
|
|
317
|
-
}
|
|
318
|
-
get docframeCallUrl() {
|
|
319
|
-
return `${this.url}/api/docframe?token=${this.token}`;
|
|
320
|
-
}
|
|
321
|
-
convertTo(format, doc, outputParams) {
|
|
322
|
-
const node = doc.toDocFrame();
|
|
323
|
-
const protoData = Proto7.Node.encode(node).finish();
|
|
324
|
-
const form = new FormData();
|
|
325
|
-
let meta = {
|
|
326
|
-
format
|
|
327
|
-
};
|
|
328
|
-
if (outputParams) {
|
|
329
|
-
meta = {
|
|
330
|
-
...meta,
|
|
331
|
-
...outputParams
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
form.append("meta", JSON.stringify(meta), {
|
|
335
|
-
contentType: "application/json",
|
|
336
|
-
filename: "meta"
|
|
337
|
-
});
|
|
338
|
-
form.append("proto-data", protoData, {
|
|
339
|
-
contentType: "application/protobuf",
|
|
340
|
-
filename: "data.proto"
|
|
341
|
-
});
|
|
342
|
-
return new Promise((resolve, reject) => {
|
|
343
|
-
axios.postForm(this.docframeCallUrl, form, {
|
|
344
|
-
headers: {
|
|
345
|
-
...form.getHeaders()
|
|
346
|
-
},
|
|
347
|
-
responseType: "arraybuffer"
|
|
348
|
-
}).then(async (res) => {
|
|
349
|
-
const blob = await new Response(res.data, {
|
|
350
|
-
headers: {
|
|
351
|
-
"Content-Type": res.headers["content-type"]
|
|
352
|
-
}
|
|
353
|
-
}).blob();
|
|
354
|
-
resolve(blob);
|
|
355
|
-
}).catch((err) => {
|
|
356
|
-
reject(err);
|
|
357
|
-
});
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
};
|
|
361
|
-
var defaultConnection = new Connection();
|
|
362
|
-
|
|
363
|
-
// src/OutputFormat/index.ts
|
|
364
|
-
var OutputFormat = /* @__PURE__ */ ((OutputFormat2) => {
|
|
365
|
-
OutputFormat2["PDF"] = "pdf";
|
|
366
|
-
OutputFormat2["PNG"] = "png";
|
|
367
|
-
OutputFormat2["JPEG"] = "jpeg";
|
|
368
|
-
OutputFormat2["HTML"] = "html";
|
|
369
|
-
OutputFormat2["PS"] = "ps";
|
|
370
|
-
OutputFormat2["TEXT"] = "text";
|
|
371
|
-
return OutputFormat2;
|
|
372
|
-
})(OutputFormat || {});
|
|
360
|
+
// src/Content/Directory/index.ts
|
|
361
|
+
import Proto9 from "docframe-types";
|
|
373
362
|
|
|
374
363
|
// src/Content/Text/index.ts
|
|
375
364
|
import Proto8 from "docframe-types";
|
|
@@ -431,30 +420,58 @@ function documentElementsFromContent(content) {
|
|
|
431
420
|
}
|
|
432
421
|
}
|
|
433
422
|
|
|
423
|
+
// src/Content/Directory/index.ts
|
|
424
|
+
var Directory = class extends BranchDocumentElement {
|
|
425
|
+
toDocFrame() {
|
|
426
|
+
return Proto9.Node.create({
|
|
427
|
+
directory: Proto9.ProtoDirectory.create({}),
|
|
428
|
+
children: this.childrenToDocFrame()
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
// src/Content/Document/index.ts
|
|
434
|
+
import Proto15 from "docframe-types";
|
|
435
|
+
|
|
436
|
+
// src/OutputFormat/index.ts
|
|
437
|
+
var OutputFormat_exports = {};
|
|
438
|
+
__export(OutputFormat_exports, {
|
|
439
|
+
OutputFormat: () => OutputFormat
|
|
440
|
+
});
|
|
441
|
+
var OutputFormat = /* @__PURE__ */ ((OutputFormat2) => {
|
|
442
|
+
OutputFormat2["PDF"] = "pdf";
|
|
443
|
+
OutputFormat2["PNG"] = "png";
|
|
444
|
+
OutputFormat2["JPEG"] = "jpeg";
|
|
445
|
+
OutputFormat2["HTML"] = "html";
|
|
446
|
+
OutputFormat2["PS"] = "ps";
|
|
447
|
+
OutputFormat2["TEXT"] = "text";
|
|
448
|
+
return OutputFormat2;
|
|
449
|
+
})(OutputFormat || {});
|
|
450
|
+
|
|
434
451
|
// src/Content/Footer/index.ts
|
|
435
|
-
import
|
|
452
|
+
import Proto10 from "docframe-types";
|
|
436
453
|
var Footer = class extends BranchDocumentElement {
|
|
437
454
|
toDocFrame() {
|
|
438
|
-
return
|
|
439
|
-
footer:
|
|
455
|
+
return Proto10.Node.create({
|
|
456
|
+
footer: Proto10.ProtoFooter.create(),
|
|
440
457
|
children: this.childrenToDocFrame()
|
|
441
458
|
});
|
|
442
459
|
}
|
|
443
460
|
};
|
|
444
461
|
|
|
445
462
|
// src/Content/Header/index.ts
|
|
446
|
-
import
|
|
463
|
+
import Proto11 from "docframe-types";
|
|
447
464
|
var Header = class extends BranchDocumentElement {
|
|
448
465
|
toDocFrame() {
|
|
449
|
-
return
|
|
450
|
-
header:
|
|
466
|
+
return Proto11.Node.create({
|
|
467
|
+
header: Proto11.ProtoHeader.create(),
|
|
451
468
|
children: this.childrenToDocFrame()
|
|
452
469
|
});
|
|
453
470
|
}
|
|
454
471
|
};
|
|
455
472
|
|
|
456
473
|
// src/Content/PageDefinition/index.ts
|
|
457
|
-
import
|
|
474
|
+
import Proto12 from "docframe-types";
|
|
458
475
|
import { v4 } from "uuid";
|
|
459
476
|
var PageDefinition = class {
|
|
460
477
|
constructor(width, height) {
|
|
@@ -464,12 +481,12 @@ var PageDefinition = class {
|
|
|
464
481
|
}
|
|
465
482
|
toDocFrame() {
|
|
466
483
|
var _a, _b;
|
|
467
|
-
return new
|
|
468
|
-
pageDepth: new
|
|
484
|
+
return new Proto12.ProtoPDef({
|
|
485
|
+
pageDepth: new Proto12.ProtoBoxedMeasure({
|
|
469
486
|
isNull: this.height === void 0,
|
|
470
487
|
value: (_a = this.height) == null ? void 0 : _a.toDocFrame()
|
|
471
488
|
}),
|
|
472
|
-
pageWidth: new
|
|
489
|
+
pageWidth: new Proto12.ProtoBoxedMeasure({
|
|
473
490
|
isNull: this.width === void 0,
|
|
474
491
|
value: (_b = this.width) == null ? void 0 : _b.toDocFrame()
|
|
475
492
|
}),
|
|
@@ -494,7 +511,7 @@ var PageDefinitions;
|
|
|
494
511
|
})(PageDefinitions || (PageDefinitions = {}));
|
|
495
512
|
|
|
496
513
|
// src/ParagraphFormat/index.ts
|
|
497
|
-
import
|
|
514
|
+
import Proto13 from "docframe-types";
|
|
498
515
|
import { v4 as uuidv42 } from "uuid";
|
|
499
516
|
var ParagraphFormat = class {
|
|
500
517
|
constructor(props) {
|
|
@@ -503,101 +520,101 @@ var ParagraphFormat = class {
|
|
|
503
520
|
}
|
|
504
521
|
toDocFrame() {
|
|
505
522
|
let format = {
|
|
506
|
-
default:
|
|
523
|
+
default: Proto13.ProtoBoxedBool.create({
|
|
507
524
|
isNull: false,
|
|
508
525
|
value: this.props.default || false
|
|
509
526
|
}),
|
|
510
|
-
name:
|
|
527
|
+
name: Proto13.ProtoBoxedString.create({
|
|
511
528
|
isNull: false,
|
|
512
529
|
value: this.props.name
|
|
513
530
|
})
|
|
514
531
|
};
|
|
515
532
|
if (this.props.alignment) {
|
|
516
|
-
format.alignment =
|
|
533
|
+
format.alignment = Proto13.ProtoBoxedHorizontalAlignment.create({
|
|
517
534
|
isNull: false,
|
|
518
535
|
value: this.props.alignment.toDocFrame()
|
|
519
536
|
});
|
|
520
537
|
}
|
|
521
538
|
if (this.props.font) {
|
|
522
|
-
format.font =
|
|
539
|
+
format.font = Proto13.ProtoBoxedFont.create({
|
|
523
540
|
isNull: false,
|
|
524
541
|
value: this.props.font.toDocFrame()
|
|
525
542
|
});
|
|
526
543
|
}
|
|
527
544
|
if (this.props.fontSize) {
|
|
528
|
-
format.fontSize =
|
|
545
|
+
format.fontSize = Proto13.ProtoBoxedMeasure.create({
|
|
529
546
|
isNull: false,
|
|
530
547
|
value: this.props.fontSize.toDocFrame()
|
|
531
548
|
});
|
|
532
549
|
}
|
|
533
550
|
if (this.props.characterWidth) {
|
|
534
|
-
format.characterWidth =
|
|
551
|
+
format.characterWidth = Proto13.ProtoBoxedMeasure.create({
|
|
535
552
|
isNull: false,
|
|
536
553
|
value: this.props.characterWidth.toDocFrame()
|
|
537
554
|
});
|
|
538
555
|
}
|
|
539
556
|
if (this.props.characterSpacing) {
|
|
540
|
-
format.characterSpacing =
|
|
557
|
+
format.characterSpacing = Proto13.ProtoBoxedMeasure.create({
|
|
541
558
|
isNull: false,
|
|
542
559
|
value: this.props.characterSpacing.toDocFrame()
|
|
543
560
|
});
|
|
544
561
|
}
|
|
545
562
|
if (this.props.lineFeed) {
|
|
546
|
-
format.lineFeed =
|
|
563
|
+
format.lineFeed = Proto13.ProtoBoxedMeasure.create({
|
|
547
564
|
isNull: false,
|
|
548
565
|
value: this.props.lineFeed.toDocFrame()
|
|
549
566
|
});
|
|
550
567
|
}
|
|
551
568
|
if (this.props.indentionLevel !== void 0) {
|
|
552
|
-
format.indentionLevel =
|
|
569
|
+
format.indentionLevel = Proto13.ProtoBoxedInt32.create({
|
|
553
570
|
isNull: false,
|
|
554
571
|
value: this.props.indentionLevel
|
|
555
572
|
});
|
|
556
573
|
}
|
|
557
574
|
if (this.props.indentionWidth) {
|
|
558
|
-
format.indentionWidth =
|
|
575
|
+
format.indentionWidth = Proto13.ProtoBoxedMeasure.create({
|
|
559
576
|
isNull: false,
|
|
560
577
|
value: this.props.indentionWidth.toDocFrame()
|
|
561
578
|
});
|
|
562
579
|
}
|
|
563
580
|
if (this.props.bold !== void 0) {
|
|
564
|
-
format.bold =
|
|
581
|
+
format.bold = Proto13.ProtoBoxedBool.create({
|
|
565
582
|
isNull: false,
|
|
566
583
|
value: !!this.props.bold
|
|
567
584
|
});
|
|
568
585
|
}
|
|
569
586
|
if (this.props.italic !== void 0) {
|
|
570
|
-
format.italic =
|
|
587
|
+
format.italic = Proto13.ProtoBoxedBool.create({
|
|
571
588
|
isNull: false,
|
|
572
589
|
value: !!this.props.italic
|
|
573
590
|
});
|
|
574
591
|
}
|
|
575
592
|
if (this.props.spaceAbove) {
|
|
576
|
-
format.spaceAbove =
|
|
593
|
+
format.spaceAbove = Proto13.ProtoBoxedMeasure.create({
|
|
577
594
|
isNull: false,
|
|
578
595
|
value: this.props.spaceAbove.toDocFrame()
|
|
579
596
|
});
|
|
580
597
|
}
|
|
581
598
|
if (this.props.spaceBelow) {
|
|
582
|
-
format.spaceBelow =
|
|
599
|
+
format.spaceBelow = Proto13.ProtoBoxedMeasure.create({
|
|
583
600
|
isNull: false,
|
|
584
601
|
value: this.props.spaceBelow.toDocFrame()
|
|
585
602
|
});
|
|
586
603
|
}
|
|
587
|
-
return
|
|
604
|
+
return Proto13.ProtoParagraphFormat.create(format);
|
|
588
605
|
}
|
|
589
606
|
};
|
|
590
607
|
|
|
591
608
|
// src/Content/SpaceVertically/index.ts
|
|
592
|
-
import
|
|
609
|
+
import Proto14 from "docframe-types";
|
|
593
610
|
var SpaceVertically = class extends DocumentElement {
|
|
594
611
|
constructor(space) {
|
|
595
612
|
super();
|
|
596
613
|
this.space = space;
|
|
597
614
|
}
|
|
598
615
|
toDocFrame() {
|
|
599
|
-
return
|
|
600
|
-
spaceVertically:
|
|
616
|
+
return Proto14.Node.create({
|
|
617
|
+
spaceVertically: Proto14.ProtoSpaceVertically.create({
|
|
601
618
|
space: this.space.toDocFrame()
|
|
602
619
|
})
|
|
603
620
|
});
|
|
@@ -612,7 +629,9 @@ var Font = class {
|
|
|
612
629
|
}
|
|
613
630
|
toDocFrame() {
|
|
614
631
|
return ProtoFont.create({
|
|
615
|
-
name: this.name
|
|
632
|
+
name: this.name,
|
|
633
|
+
// TODO: suppot font mapping for docframe step
|
|
634
|
+
id: 5
|
|
616
635
|
});
|
|
617
636
|
}
|
|
618
637
|
};
|
|
@@ -682,15 +701,15 @@ var Document = class extends BranchDocumentElement {
|
|
|
682
701
|
toDocFrame() {
|
|
683
702
|
const props = this.props;
|
|
684
703
|
const docSettings = Object.values(this.paragraphFormats).map(
|
|
685
|
-
(pf) =>
|
|
704
|
+
(pf) => Proto15.Node.create({
|
|
686
705
|
paragraphFormat: pf.toDocFrame()
|
|
687
706
|
})
|
|
688
707
|
).concat([
|
|
689
|
-
|
|
708
|
+
Proto15.Node.create({
|
|
690
709
|
pDef: props.pageDefinition.toDocFrame()
|
|
691
710
|
}),
|
|
692
|
-
|
|
693
|
-
applyPDef:
|
|
711
|
+
Proto15.Node.create({
|
|
712
|
+
applyPDef: Proto15.ProtoApplyProtoPDef.create({
|
|
694
713
|
pDefUuid: props.pageDefinition.uuid
|
|
695
714
|
})
|
|
696
715
|
}),
|
|
@@ -705,19 +724,19 @@ var Document = class extends BranchDocumentElement {
|
|
|
705
724
|
const content = this.childrenToDocFrame();
|
|
706
725
|
for (const format of Object.values(this.paragraphFormats)) {
|
|
707
726
|
docSettings.push(
|
|
708
|
-
|
|
727
|
+
Proto15.Node.create({
|
|
709
728
|
paragraphFormat: format.toDocFrame()
|
|
710
729
|
})
|
|
711
730
|
);
|
|
712
731
|
}
|
|
713
|
-
return
|
|
732
|
+
return Proto15.Node.create({
|
|
714
733
|
children: docSettings.concat(...content)
|
|
715
734
|
});
|
|
716
735
|
}
|
|
717
736
|
};
|
|
718
737
|
|
|
719
738
|
// src/Content/Formatted/index.ts
|
|
720
|
-
import
|
|
739
|
+
import Proto16 from "docframe-types";
|
|
721
740
|
var Formatted = class extends DocumentElement {
|
|
722
741
|
constructor(doctypeContent, htmlContent) {
|
|
723
742
|
super();
|
|
@@ -727,8 +746,8 @@ var Formatted = class extends DocumentElement {
|
|
|
727
746
|
};
|
|
728
747
|
}
|
|
729
748
|
toDocFrame() {
|
|
730
|
-
return
|
|
731
|
-
formatted:
|
|
749
|
+
return Proto16.Node.create({
|
|
750
|
+
formatted: Proto16.ProtoFormatted.create({
|
|
732
751
|
doctypeContent: this.content.doctype,
|
|
733
752
|
htmlContent: this.content.html
|
|
734
753
|
})
|
|
@@ -736,18 +755,28 @@ var Formatted = class extends DocumentElement {
|
|
|
736
755
|
}
|
|
737
756
|
};
|
|
738
757
|
|
|
758
|
+
// src/Content/Linebreak/index.ts
|
|
759
|
+
import Proto17 from "docframe-types";
|
|
760
|
+
var Linebreak = class extends DocumentElement {
|
|
761
|
+
toDocFrame() {
|
|
762
|
+
return Proto17.Node.create({
|
|
763
|
+
linebreak: Proto17.ProtoLinebreak.create({})
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
};
|
|
767
|
+
|
|
739
768
|
// src/Content/Pagebreak/index.ts
|
|
740
|
-
import
|
|
769
|
+
import Proto18 from "docframe-types";
|
|
741
770
|
var Pagebreak = class extends DocumentElement {
|
|
742
771
|
toDocFrame() {
|
|
743
|
-
return
|
|
744
|
-
newPage:
|
|
772
|
+
return Proto18.Node.create({
|
|
773
|
+
newPage: Proto18.ProtoNewPage.create({})
|
|
745
774
|
});
|
|
746
775
|
}
|
|
747
776
|
};
|
|
748
777
|
|
|
749
778
|
// src/Content/Paragraph/index.ts
|
|
750
|
-
import
|
|
779
|
+
import Proto19 from "docframe-types";
|
|
751
780
|
var Paragraph = class extends BranchDocumentElement {
|
|
752
781
|
constructor(content, paragraphFormatName, overwrite) {
|
|
753
782
|
var _a;
|
|
@@ -762,22 +791,70 @@ var Paragraph = class extends BranchDocumentElement {
|
|
|
762
791
|
par.overwrite = this.props.overwrite.toDocFrame();
|
|
763
792
|
}
|
|
764
793
|
if (this.props.paragraphFormatName) {
|
|
765
|
-
par.format =
|
|
766
|
-
name:
|
|
794
|
+
par.format = Proto19.ProtoParagraphFormat.create({
|
|
795
|
+
name: Proto19.ProtoBoxedString.create({
|
|
767
796
|
isNull: false,
|
|
768
797
|
value: this.props.paragraphFormatName
|
|
769
798
|
})
|
|
770
799
|
});
|
|
771
800
|
}
|
|
772
|
-
return
|
|
773
|
-
paragraph:
|
|
801
|
+
return Proto19.Node.create({
|
|
802
|
+
paragraph: Proto19.ProtoParagraph.create(par),
|
|
803
|
+
children: this.childrenToDocFrame()
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
};
|
|
807
|
+
|
|
808
|
+
// src/Content/Span/index.ts
|
|
809
|
+
import Proto20 from "docframe-types";
|
|
810
|
+
var Span = class extends BranchDocumentElement {
|
|
811
|
+
constructor(content, props) {
|
|
812
|
+
super(content, props || {});
|
|
813
|
+
}
|
|
814
|
+
toDocFrame() {
|
|
815
|
+
var _a, _b, _c, _d;
|
|
816
|
+
let bold = void 0;
|
|
817
|
+
if (((_a = this.props) == null ? void 0 : _a.bold) !== void 0) {
|
|
818
|
+
bold = Proto20.ProtoBoxedBool.create({
|
|
819
|
+
isNull: false,
|
|
820
|
+
value: this.props.bold
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
let italic = void 0;
|
|
824
|
+
if (((_b = this.props) == null ? void 0 : _b.italic) !== void 0) {
|
|
825
|
+
italic = Proto20.ProtoBoxedBool.create({
|
|
826
|
+
isNull: false,
|
|
827
|
+
value: this.props.italic
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
let underline = void 0;
|
|
831
|
+
if (((_c = this.props) == null ? void 0 : _c.underline) !== void 0) {
|
|
832
|
+
underline = Proto20.ProtoBoxedBool.create({
|
|
833
|
+
isNull: false,
|
|
834
|
+
value: this.props.underline
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
let strikethrough = void 0;
|
|
838
|
+
if (((_d = this.props) == null ? void 0 : _d.strikethrough) !== void 0) {
|
|
839
|
+
strikethrough = Proto20.ProtoBoxedBool.create({
|
|
840
|
+
isNull: false,
|
|
841
|
+
value: this.props.strikethrough
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
return Proto20.Node.create({
|
|
845
|
+
span: Proto20.ProtoSpan.create({
|
|
846
|
+
bold,
|
|
847
|
+
italic,
|
|
848
|
+
underline,
|
|
849
|
+
strikethrough
|
|
850
|
+
}),
|
|
774
851
|
children: this.childrenToDocFrame()
|
|
775
852
|
});
|
|
776
853
|
}
|
|
777
854
|
};
|
|
778
855
|
|
|
779
856
|
// src/Content/Table/index.ts
|
|
780
|
-
import
|
|
857
|
+
import Proto21 from "docframe-types";
|
|
781
858
|
var Table = class extends BranchDocumentElement {
|
|
782
859
|
constructor(content, props) {
|
|
783
860
|
super(content, props || {});
|
|
@@ -788,11 +865,11 @@ var Table = class extends BranchDocumentElement {
|
|
|
788
865
|
toDocFrame() {
|
|
789
866
|
var _a, _b;
|
|
790
867
|
const props = this.props;
|
|
791
|
-
return
|
|
792
|
-
table:
|
|
793
|
-
settings:
|
|
868
|
+
return Proto21.Node.create({
|
|
869
|
+
table: Proto21.ProtoTable.create({
|
|
870
|
+
settings: Proto21.ProtoTableSettings.create({
|
|
794
871
|
width: (_a = props.width) == null ? void 0 : _a.toDocFrame(),
|
|
795
|
-
leftMeasure:
|
|
872
|
+
leftMeasure: Proto21.ProtoBoxedBool.create({
|
|
796
873
|
isNull: false,
|
|
797
874
|
value: false
|
|
798
875
|
}),
|
|
@@ -805,7 +882,7 @@ var Table = class extends BranchDocumentElement {
|
|
|
805
882
|
};
|
|
806
883
|
|
|
807
884
|
// src/Content/TableCell/index.ts
|
|
808
|
-
import
|
|
885
|
+
import Proto22 from "docframe-types";
|
|
809
886
|
var TableCell = class extends BranchDocumentElement {
|
|
810
887
|
constructor(content, props) {
|
|
811
888
|
super(content, props || {});
|
|
@@ -813,20 +890,20 @@ var TableCell = class extends BranchDocumentElement {
|
|
|
813
890
|
toDocFrame() {
|
|
814
891
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
815
892
|
const props = this.props;
|
|
816
|
-
return
|
|
817
|
-
tableCell:
|
|
818
|
-
settings:
|
|
819
|
-
align:
|
|
893
|
+
return Proto22.Node.create({
|
|
894
|
+
tableCell: Proto22.ProtoTableCell.create({
|
|
895
|
+
settings: Proto22.ProtoTableCellSettings.create({
|
|
896
|
+
align: Proto22.ProtoBoxedHorizontalAlignment.create({
|
|
820
897
|
isNull: false,
|
|
821
|
-
value: ((_a = props.alignment) == null ? void 0 : _a.toDocFrame()) ||
|
|
898
|
+
value: ((_a = props.alignment) == null ? void 0 : _a.toDocFrame()) || Proto22.ProtoHorizontalAlignment.ALIGN_LEFT
|
|
822
899
|
}),
|
|
823
900
|
backgroundColor: (_b = props.backgroundColor) == null ? void 0 : _b.toDocFrame(),
|
|
824
901
|
border: (_c = props.border) == null ? void 0 : _c.toDocFrame(),
|
|
825
902
|
margin: (_d = props.margin) == null ? void 0 : _d.toDocFrame(),
|
|
826
903
|
padding: (_e = props.padding) == null ? void 0 : _e.toDocFrame(),
|
|
827
|
-
valign:
|
|
904
|
+
valign: Proto22.ProtoBoxedVerticalAlignment.create({
|
|
828
905
|
isNull: false,
|
|
829
|
-
value: ((_f = props.verticalAlignment) == null ? void 0 : _f.toDocFrame()) ||
|
|
906
|
+
value: ((_f = props.verticalAlignment) == null ? void 0 : _f.toDocFrame()) || Proto22.ProtoVerticalAlignment.TOP
|
|
830
907
|
}),
|
|
831
908
|
width: (_g = props.width) == null ? void 0 : _g.toDocFrame()
|
|
832
909
|
})
|
|
@@ -837,16 +914,16 @@ var TableCell = class extends BranchDocumentElement {
|
|
|
837
914
|
};
|
|
838
915
|
|
|
839
916
|
// src/Content/TableRow/index.ts
|
|
840
|
-
import
|
|
917
|
+
import Proto23 from "docframe-types";
|
|
841
918
|
var TableRow = class extends BranchDocumentElement {
|
|
842
919
|
constructor(content, props) {
|
|
843
920
|
super(content, props || {});
|
|
844
921
|
}
|
|
845
922
|
toDocFrame() {
|
|
846
923
|
var _a;
|
|
847
|
-
return
|
|
848
|
-
tableRow:
|
|
849
|
-
settings:
|
|
924
|
+
return Proto23.Node.create({
|
|
925
|
+
tableRow: Proto23.ProtoTableRow.create({
|
|
926
|
+
settings: Proto23.ProtoTableRowSettings.create({
|
|
850
927
|
minHeight: (_a = this.props.minHeight) == null ? void 0 : _a.toDocFrame()
|
|
851
928
|
})
|
|
852
929
|
}),
|
|
@@ -860,12 +937,17 @@ var Content_default = {
|
|
|
860
937
|
Barcode,
|
|
861
938
|
ColumnDefinition,
|
|
862
939
|
ColumnPosition,
|
|
940
|
+
Directory,
|
|
863
941
|
Document,
|
|
942
|
+
Footer,
|
|
864
943
|
Formatted,
|
|
865
|
-
|
|
944
|
+
Header,
|
|
945
|
+
Linebreak,
|
|
866
946
|
Pagebreak,
|
|
947
|
+
PageDefinition,
|
|
867
948
|
Paragraph,
|
|
868
949
|
SpaceVertically,
|
|
950
|
+
Span,
|
|
869
951
|
Table,
|
|
870
952
|
TableCell,
|
|
871
953
|
TableRow,
|
|
@@ -882,13 +964,14 @@ var index_default = {
|
|
|
882
964
|
Color,
|
|
883
965
|
Colors
|
|
884
966
|
},
|
|
967
|
+
Connection,
|
|
885
968
|
Content: Content_default,
|
|
886
969
|
Font: {
|
|
887
970
|
Font,
|
|
888
971
|
StandardFonts
|
|
889
972
|
},
|
|
890
973
|
Measure: Measure_exports,
|
|
891
|
-
|
|
974
|
+
Output: OutputFormat_exports,
|
|
892
975
|
ParagraphFormat
|
|
893
976
|
};
|
|
894
977
|
export {
|