@json-to-office/jto 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/cli.js +1505 -120
- package/dist/cli.js.map +1 -1
- package/dist/client/assets/HomePage-CtePCdPD.js +99 -0
- package/dist/client/assets/HomePage-CtePCdPD.js.map +1 -0
- package/dist/client/assets/{JsonEditorPage-DCvwatOj.js → JsonEditorPage-Dk_qYbQR.js} +3 -3
- package/dist/client/assets/{JsonEditorPage-DCvwatOj.js.map → JsonEditorPage-Dk_qYbQR.js.map} +1 -1
- package/dist/client/assets/{MonacoPluginProvider-DrTR8ld3.js → MonacoPluginProvider-BmWwTUcW.js} +3 -3
- package/dist/client/assets/{MonacoPluginProvider-DrTR8ld3.js.map → MonacoPluginProvider-BmWwTUcW.js.map} +1 -1
- package/dist/client/assets/{button-D_d9zKq6.js → button-jTamq7gj.js} +2 -2
- package/dist/client/assets/{button-D_d9zKq6.js.map → button-jTamq7gj.js.map} +1 -1
- package/dist/client/assets/{editor-AIcSsY9W.js → editor-QOUTSCme.js} +2 -2
- package/dist/client/assets/{editor-AIcSsY9W.js.map → editor-QOUTSCme.js.map} +1 -1
- package/dist/client/assets/{editor-monaco-json-DHxCqVbk.js → editor-monaco-json-Bi4IKPau.js} +2 -2
- package/dist/client/assets/{editor-monaco-json-DHxCqVbk.js.map → editor-monaco-json-Bi4IKPau.js.map} +1 -1
- package/dist/client/assets/index-CLUTL9ST.js +5 -0
- package/dist/client/assets/index-CLUTL9ST.js.map +1 -0
- package/dist/client/assets/index-DKIIAAih.css +1 -0
- package/dist/client/assets/preview-CtIrY86t.js +3 -0
- package/dist/client/assets/preview-CtIrY86t.js.map +1 -0
- package/dist/client/assets/{radix-ui-BZ5iKMtq.js → radix-ui-BiXCNJNt.js} +2 -2
- package/dist/client/assets/{radix-ui-BZ5iKMtq.js.map → radix-ui-BiXCNJNt.js.map} +1 -1
- package/dist/client/assets/{state-vendor-BDrPu9qj.js → state-vendor-DTum9m7F.js} +2 -2
- package/dist/client/assets/{state-vendor-BDrPu9qj.js.map → state-vendor-DTum9m7F.js.map} +1 -1
- package/dist/client/assets/{ui-vendor-Dyg3GRT-.js → ui-vendor-D3QbouTA.js} +10 -5
- package/dist/client/assets/ui-vendor-D3QbouTA.js.map +1 -0
- package/dist/client/index.html +5 -4
- package/dist/client/templates/Wiseair 16-9.pptx.json +6254 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +30 -12
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
- package/dist/client/assets/HomePage-N11lGfcq.js +0 -99
- package/dist/client/assets/HomePage-N11lGfcq.js.map +0 -1
- package/dist/client/assets/index-B0s8Zyy_.css +0 -1
- package/dist/client/assets/index-DmdAtyxx.js +0 -3
- package/dist/client/assets/index-DmdAtyxx.js.map +0 -1
- package/dist/client/assets/preview-BrqBUZLp.js +0 -3
- package/dist/client/assets/preview-BrqBUZLp.js.map +0 -1
- package/dist/client/assets/ui-vendor-Dyg3GRT-.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FontRuntimeOpts } from '@json-to-office/shared';
|
|
1
2
|
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
2
3
|
import { TSchema, Static } from '@sinclair/typebox';
|
|
3
4
|
|
|
@@ -10,6 +11,7 @@ interface GeneratorOptions {
|
|
|
10
11
|
strict?: boolean;
|
|
11
12
|
allowUnknownFields?: boolean;
|
|
12
13
|
};
|
|
14
|
+
fonts?: FontRuntimeOpts;
|
|
13
15
|
}
|
|
14
16
|
interface GeneratorResult {
|
|
15
17
|
generateBuffer: (document: any) => Promise<Buffer>;
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,10 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
8
8
|
// src/format-adapter.ts
|
|
9
9
|
import * as path from "path";
|
|
10
10
|
import * as fs from "fs";
|
|
11
|
+
var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
12
|
+
function safeThemeKey(name) {
|
|
13
|
+
return name && !UNSAFE_KEYS.has(name) ? name : "custom";
|
|
14
|
+
}
|
|
11
15
|
function buildServicesFromEnv() {
|
|
12
16
|
const serverUrl = process.env.HIGHCHARTS_SERVER_URL;
|
|
13
17
|
const apiKey = process.env.HIGHCHARTS_API_KEY;
|
|
@@ -32,7 +36,8 @@ var DocxFormatAdapter = class {
|
|
|
32
36
|
const services = buildServicesFromEnv();
|
|
33
37
|
return await core.generateBufferFromJson(docDefinition, {
|
|
34
38
|
customThemes,
|
|
35
|
-
services
|
|
39
|
+
services,
|
|
40
|
+
fonts: options.fonts
|
|
36
41
|
});
|
|
37
42
|
}
|
|
38
43
|
async createGenerator(plugins, options) {
|
|
@@ -47,7 +52,8 @@ var DocxFormatAdapter = class {
|
|
|
47
52
|
const customThemes2 = await this.loadCustomThemes(options);
|
|
48
53
|
return await core.generateBufferFromJson(docDefinition, {
|
|
49
54
|
customThemes: customThemes2,
|
|
50
|
-
services
|
|
55
|
+
services,
|
|
56
|
+
fonts: options.fonts
|
|
51
57
|
});
|
|
52
58
|
},
|
|
53
59
|
hasPlugins: false,
|
|
@@ -60,7 +66,8 @@ var DocxFormatAdapter = class {
|
|
|
60
66
|
theme,
|
|
61
67
|
customThemes,
|
|
62
68
|
debug: process.env.DEBUG === "true",
|
|
63
|
-
services
|
|
69
|
+
services,
|
|
70
|
+
fonts: options.fonts
|
|
64
71
|
});
|
|
65
72
|
for (const plugin of plugins) {
|
|
66
73
|
generator = generator.addComponent(plugin);
|
|
@@ -144,16 +151,20 @@ ${errors.map((e) => ` - ${e.path}: ${e.message}`).join("\n")}`
|
|
|
144
151
|
Object.assign(customThemes, options.customThemes);
|
|
145
152
|
}
|
|
146
153
|
if (typeof options.theme === "object" && options.theme !== null) {
|
|
147
|
-
customThemes.
|
|
154
|
+
customThemes[safeThemeKey(options.theme.name)] = options.theme;
|
|
148
155
|
}
|
|
149
156
|
if (options.themePath) {
|
|
150
157
|
try {
|
|
158
|
+
let theme;
|
|
151
159
|
if (options.themePath.endsWith(".json")) {
|
|
152
|
-
|
|
160
|
+
theme = await core.loadThemeFromFile(options.themePath);
|
|
153
161
|
} else {
|
|
154
162
|
const themePath = path.resolve(process.cwd(), options.themePath);
|
|
155
163
|
const themeModule = await import(themePath);
|
|
156
|
-
|
|
164
|
+
theme = themeModule.default || themeModule.theme;
|
|
165
|
+
}
|
|
166
|
+
if (theme) {
|
|
167
|
+
customThemes[safeThemeKey(theme.name)] = theme;
|
|
157
168
|
}
|
|
158
169
|
} catch (error) {
|
|
159
170
|
console.warn(
|
|
@@ -248,7 +259,8 @@ var PptxFormatAdapter = class {
|
|
|
248
259
|
const services = buildServicesFromEnv();
|
|
249
260
|
return await core.generateBufferFromJson(docDefinition, {
|
|
250
261
|
customThemes,
|
|
251
|
-
services
|
|
262
|
+
services,
|
|
263
|
+
fonts: options.fonts
|
|
252
264
|
});
|
|
253
265
|
}
|
|
254
266
|
async createGenerator(plugins, options) {
|
|
@@ -263,7 +275,8 @@ var PptxFormatAdapter = class {
|
|
|
263
275
|
const customThemes2 = await this.loadCustomThemes(options);
|
|
264
276
|
return await core.generateBufferFromJson(docDefinition, {
|
|
265
277
|
customThemes: customThemes2,
|
|
266
|
-
services
|
|
278
|
+
services,
|
|
279
|
+
fonts: options.fonts
|
|
267
280
|
});
|
|
268
281
|
},
|
|
269
282
|
hasPlugins: false,
|
|
@@ -276,7 +289,8 @@ var PptxFormatAdapter = class {
|
|
|
276
289
|
theme,
|
|
277
290
|
customThemes,
|
|
278
291
|
debug: process.env.DEBUG === "true",
|
|
279
|
-
services
|
|
292
|
+
services,
|
|
293
|
+
fonts: options.fonts
|
|
280
294
|
});
|
|
281
295
|
for (const plugin of plugins) {
|
|
282
296
|
generator = generator.addComponent(plugin);
|
|
@@ -363,20 +377,24 @@ ${errors.map((e) => ` - ${e.path}: ${e.message}`).join("\n")}`
|
|
|
363
377
|
Object.assign(customThemes, options.customThemes);
|
|
364
378
|
}
|
|
365
379
|
if (typeof options.theme === "object" && options.theme !== null) {
|
|
366
|
-
customThemes.
|
|
380
|
+
customThemes[safeThemeKey(options.theme.name)] = options.theme;
|
|
367
381
|
}
|
|
368
382
|
if (options.themePath) {
|
|
369
383
|
try {
|
|
384
|
+
let theme;
|
|
370
385
|
if (options.themePath.endsWith(".json")) {
|
|
371
386
|
const content = fs.readFileSync(
|
|
372
387
|
path.resolve(process.cwd(), options.themePath),
|
|
373
388
|
"utf-8"
|
|
374
389
|
);
|
|
375
|
-
|
|
390
|
+
theme = JSON.parse(content);
|
|
376
391
|
} else {
|
|
377
392
|
const themePath = path.resolve(process.cwd(), options.themePath);
|
|
378
393
|
const themeModule = await import(themePath);
|
|
379
|
-
|
|
394
|
+
theme = themeModule.default || themeModule.theme;
|
|
395
|
+
}
|
|
396
|
+
if (theme) {
|
|
397
|
+
customThemes[safeThemeKey(theme.name)] = theme;
|
|
380
398
|
}
|
|
381
399
|
} catch (error) {
|
|
382
400
|
console.warn(
|