ts-d2 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +18 -2
- package/dist/index.d.ts +18 -2
- package/dist/index.js +63 -56
- package/dist/index.mjs +100 -93
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -196,7 +196,7 @@ declare enum OutputFormat {
|
|
|
196
196
|
PS = "ps",
|
|
197
197
|
TEXT = "text"
|
|
198
198
|
}
|
|
199
|
-
|
|
199
|
+
type OutputParams = {
|
|
200
200
|
[OutputFormat.HTML]: {};
|
|
201
201
|
[OutputFormat.PDF]: {};
|
|
202
202
|
[OutputFormat.JPEG]: {};
|
|
@@ -219,6 +219,13 @@ interface OutputParams {
|
|
|
219
219
|
*/
|
|
220
220
|
dpi?: number;
|
|
221
221
|
};
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
type Output_OutputFormat = OutputFormat;
|
|
225
|
+
declare const Output_OutputFormat: typeof OutputFormat;
|
|
226
|
+
type Output_OutputParams = OutputParams;
|
|
227
|
+
declare namespace Output {
|
|
228
|
+
export { Output_OutputFormat as OutputFormat, type Output_OutputParams as OutputParams };
|
|
222
229
|
}
|
|
223
230
|
|
|
224
231
|
declare class ColumnPositionMode {
|
|
@@ -300,6 +307,14 @@ declare class Barcode extends DocumentElement {
|
|
|
300
307
|
toDocFrame(): Proto.Node;
|
|
301
308
|
}
|
|
302
309
|
|
|
310
|
+
declare class Connection {
|
|
311
|
+
url: string;
|
|
312
|
+
token: string;
|
|
313
|
+
constructor(url?: string, token?: string);
|
|
314
|
+
get docframeCallUrl(): string;
|
|
315
|
+
convertTo<K extends keyof OutputParams>(format: K, doc: Document, outputParams?: OutputParams[K]): Promise<Blob>;
|
|
316
|
+
}
|
|
317
|
+
|
|
303
318
|
declare const _default: {
|
|
304
319
|
Border: {
|
|
305
320
|
Border: typeof Border;
|
|
@@ -309,6 +324,7 @@ declare const _default: {
|
|
|
309
324
|
Color: typeof Color;
|
|
310
325
|
Colors: typeof Colors;
|
|
311
326
|
};
|
|
327
|
+
Connection: typeof Connection;
|
|
312
328
|
Content: {
|
|
313
329
|
Barcode: typeof Barcode;
|
|
314
330
|
ColumnDefinition: typeof ColumnDefinition;
|
|
@@ -331,7 +347,7 @@ declare const _default: {
|
|
|
331
347
|
};
|
|
332
348
|
};
|
|
333
349
|
Measure: typeof Measure;
|
|
334
|
-
|
|
350
|
+
Output: typeof Output;
|
|
335
351
|
ParagraphFormat: typeof ParagraphFormat;
|
|
336
352
|
};
|
|
337
353
|
|
package/dist/index.d.ts
CHANGED
|
@@ -196,7 +196,7 @@ declare enum OutputFormat {
|
|
|
196
196
|
PS = "ps",
|
|
197
197
|
TEXT = "text"
|
|
198
198
|
}
|
|
199
|
-
|
|
199
|
+
type OutputParams = {
|
|
200
200
|
[OutputFormat.HTML]: {};
|
|
201
201
|
[OutputFormat.PDF]: {};
|
|
202
202
|
[OutputFormat.JPEG]: {};
|
|
@@ -219,6 +219,13 @@ interface OutputParams {
|
|
|
219
219
|
*/
|
|
220
220
|
dpi?: number;
|
|
221
221
|
};
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
type Output_OutputFormat = OutputFormat;
|
|
225
|
+
declare const Output_OutputFormat: typeof OutputFormat;
|
|
226
|
+
type Output_OutputParams = OutputParams;
|
|
227
|
+
declare namespace Output {
|
|
228
|
+
export { Output_OutputFormat as OutputFormat, type Output_OutputParams as OutputParams };
|
|
222
229
|
}
|
|
223
230
|
|
|
224
231
|
declare class ColumnPositionMode {
|
|
@@ -300,6 +307,14 @@ declare class Barcode extends DocumentElement {
|
|
|
300
307
|
toDocFrame(): Proto.Node;
|
|
301
308
|
}
|
|
302
309
|
|
|
310
|
+
declare class Connection {
|
|
311
|
+
url: string;
|
|
312
|
+
token: string;
|
|
313
|
+
constructor(url?: string, token?: string);
|
|
314
|
+
get docframeCallUrl(): string;
|
|
315
|
+
convertTo<K extends keyof OutputParams>(format: K, doc: Document, outputParams?: OutputParams[K]): Promise<Blob>;
|
|
316
|
+
}
|
|
317
|
+
|
|
303
318
|
declare const _default: {
|
|
304
319
|
Border: {
|
|
305
320
|
Border: typeof Border;
|
|
@@ -309,6 +324,7 @@ declare const _default: {
|
|
|
309
324
|
Color: typeof Color;
|
|
310
325
|
Colors: typeof Colors;
|
|
311
326
|
};
|
|
327
|
+
Connection: typeof Connection;
|
|
312
328
|
Content: {
|
|
313
329
|
Barcode: typeof Barcode;
|
|
314
330
|
ColumnDefinition: typeof ColumnDefinition;
|
|
@@ -331,7 +347,7 @@ declare const _default: {
|
|
|
331
347
|
};
|
|
332
348
|
};
|
|
333
349
|
Measure: typeof Measure;
|
|
334
|
-
|
|
350
|
+
Output: typeof Output;
|
|
335
351
|
ParagraphFormat: typeof ParagraphFormat;
|
|
336
352
|
};
|
|
337
353
|
|
package/dist/index.js
CHANGED
|
@@ -104,6 +104,60 @@ var Colors;
|
|
|
104
104
|
Colors2.black = Color.cmyk(0, 0, 0, 100);
|
|
105
105
|
})(Colors || (Colors = {}));
|
|
106
106
|
|
|
107
|
+
// src/Connection/index.ts
|
|
108
|
+
var _axios = require('axios'); var _axios2 = _interopRequireDefault(_axios);
|
|
109
|
+
var _formdata = require('form-data'); var _formdata2 = _interopRequireDefault(_formdata);
|
|
110
|
+
|
|
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 = _docframetypes2.default.Node.encode(node).finish();
|
|
122
|
+
const form = new (0, _formdata2.default)();
|
|
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
|
+
_axios2.default.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
162
|
|
|
109
163
|
|
|
@@ -306,61 +360,11 @@ var ColumnDefinitions = {
|
|
|
306
360
|
// src/Content/Document/index.ts
|
|
307
361
|
|
|
308
362
|
|
|
309
|
-
// src/Connection/index.ts
|
|
310
|
-
var _axios = require('axios'); var _axios2 = _interopRequireDefault(_axios);
|
|
311
|
-
var _formdata = require('form-data'); var _formdata2 = _interopRequireDefault(_formdata);
|
|
312
|
-
|
|
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 = _docframetypes2.default.Node.encode(node).finish();
|
|
324
|
-
const form = new (0, _formdata2.default)();
|
|
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
|
-
_axios2.default.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
363
|
// src/OutputFormat/index.ts
|
|
364
|
+
var OutputFormat_exports = {};
|
|
365
|
+
__export(OutputFormat_exports, {
|
|
366
|
+
OutputFormat: () => OutputFormat
|
|
367
|
+
});
|
|
364
368
|
var OutputFormat = /* @__PURE__ */ ((OutputFormat2) => {
|
|
365
369
|
OutputFormat2["PDF"] = "pdf";
|
|
366
370
|
OutputFormat2["PNG"] = "png";
|
|
@@ -612,7 +616,9 @@ var Font = class {
|
|
|
612
616
|
}
|
|
613
617
|
toDocFrame() {
|
|
614
618
|
return _docframetypes.ProtoFont.create({
|
|
615
|
-
name: this.name
|
|
619
|
+
name: this.name,
|
|
620
|
+
// TODO: suppot font mapping for docframe step
|
|
621
|
+
id: 5
|
|
616
622
|
});
|
|
617
623
|
}
|
|
618
624
|
};
|
|
@@ -882,13 +888,14 @@ var index_default = {
|
|
|
882
888
|
Color,
|
|
883
889
|
Colors
|
|
884
890
|
},
|
|
891
|
+
Connection,
|
|
885
892
|
Content: Content_default,
|
|
886
893
|
Font: {
|
|
887
894
|
Font,
|
|
888
895
|
StandardFonts
|
|
889
896
|
},
|
|
890
897
|
Measure: Measure_exports,
|
|
891
|
-
|
|
898
|
+
Output: OutputFormat_exports,
|
|
892
899
|
ParagraphFormat
|
|
893
900
|
};
|
|
894
901
|
|
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
|
})
|
|
@@ -306,61 +360,11 @@ var ColumnDefinitions = {
|
|
|
306
360
|
// src/Content/Document/index.ts
|
|
307
361
|
import Proto14 from "docframe-types";
|
|
308
362
|
|
|
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
363
|
// src/OutputFormat/index.ts
|
|
364
|
+
var OutputFormat_exports = {};
|
|
365
|
+
__export(OutputFormat_exports, {
|
|
366
|
+
OutputFormat: () => OutputFormat
|
|
367
|
+
});
|
|
364
368
|
var OutputFormat = /* @__PURE__ */ ((OutputFormat2) => {
|
|
365
369
|
OutputFormat2["PDF"] = "pdf";
|
|
366
370
|
OutputFormat2["PNG"] = "png";
|
|
@@ -612,7 +616,9 @@ var Font = class {
|
|
|
612
616
|
}
|
|
613
617
|
toDocFrame() {
|
|
614
618
|
return ProtoFont.create({
|
|
615
|
-
name: this.name
|
|
619
|
+
name: this.name,
|
|
620
|
+
// TODO: suppot font mapping for docframe step
|
|
621
|
+
id: 5
|
|
616
622
|
});
|
|
617
623
|
}
|
|
618
624
|
};
|
|
@@ -882,13 +888,14 @@ var index_default = {
|
|
|
882
888
|
Color,
|
|
883
889
|
Colors
|
|
884
890
|
},
|
|
891
|
+
Connection,
|
|
885
892
|
Content: Content_default,
|
|
886
893
|
Font: {
|
|
887
894
|
Font,
|
|
888
895
|
StandardFonts
|
|
889
896
|
},
|
|
890
897
|
Measure: Measure_exports,
|
|
891
|
-
|
|
898
|
+
Output: OutputFormat_exports,
|
|
892
899
|
ParagraphFormat
|
|
893
900
|
};
|
|
894
901
|
export {
|