@json-to-office/jto 0.29.0 → 0.31.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.
Files changed (24) hide show
  1. package/dist/cli.js +34 -7
  2. package/dist/cli.js.map +1 -1
  3. package/dist/client/assets/HomePage-CbEt-3Dy.js +99 -0
  4. package/dist/client/assets/HomePage-CbEt-3Dy.js.map +1 -0
  5. package/dist/client/assets/{JsonEditorPage-CzMTUrNe.js → JsonEditorPage-CCIK-0Bx.js} +3 -3
  6. package/dist/client/assets/{JsonEditorPage-CzMTUrNe.js.map → JsonEditorPage-CCIK-0Bx.js.map} +1 -1
  7. package/dist/client/assets/{MonacoPluginProvider-CmMAmp3u.js → MonacoPluginProvider-Cl8519IJ.js} +3 -3
  8. package/dist/client/assets/{MonacoPluginProvider-CmMAmp3u.js.map → MonacoPluginProvider-Cl8519IJ.js.map} +1 -1
  9. package/dist/client/assets/{button-BEg2__r6.js → button-B2RU3Sli.js} +2 -2
  10. package/dist/client/assets/{button-BEg2__r6.js.map → button-B2RU3Sli.js.map} +1 -1
  11. package/dist/client/assets/{editor-DPs_adn-.js → editor-BSHD_QLz.js} +2 -2
  12. package/dist/client/assets/{editor-DPs_adn-.js.map → editor-BSHD_QLz.js.map} +1 -1
  13. package/dist/client/assets/{editor-monaco-json-xnoKHnLp.js → editor-monaco-json-DfzITTAd.js} +2 -2
  14. package/dist/client/assets/{editor-monaco-json-xnoKHnLp.js.map → editor-monaco-json-DfzITTAd.js.map} +1 -1
  15. package/dist/client/assets/{index-DgKS-gEZ.js → index-D_mrthjd.js} +3 -3
  16. package/dist/client/assets/{index-DgKS-gEZ.js.map → index-D_mrthjd.js.map} +1 -1
  17. package/dist/client/assets/preview-vfERm2SM.js +3 -0
  18. package/dist/client/assets/preview-vfERm2SM.js.map +1 -0
  19. package/dist/client/index.html +1 -1
  20. package/package.json +3 -3
  21. package/dist/client/assets/HomePage-g8gOpx6G.js +0 -99
  22. package/dist/client/assets/HomePage-g8gOpx6G.js.map +0 -1
  23. package/dist/client/assets/preview-RxIHvUjz.js +0 -3
  24. package/dist/client/assets/preview-RxIHvUjz.js.map +0 -1
package/dist/cli.js CHANGED
@@ -2646,15 +2646,22 @@ function createFormatRouter(adapter) {
2646
2646
  try {
2647
2647
  assertRequestSources(jsonDefinition, "jsonDefinition");
2648
2648
  assertRequestSources(customThemes, "customThemes");
2649
- const config2 = typeof jsonDefinition === "string" ? JSON.parse(jsonDefinition) : jsonDefinition;
2649
+ let config2;
2650
+ try {
2651
+ config2 = typeof jsonDefinition === "string" ? JSON.parse(jsonDefinition) : jsonDefinition;
2652
+ } catch {
2653
+ throw new HTTPException4(400, {
2654
+ message: "jsonDefinition is not valid JSON"
2655
+ });
2656
+ }
2650
2657
  const registry = PluginRegistry2.getInstance();
2651
2658
  if (registry.hasPlugins()) {
2652
2659
  const plugins = registry.getPlugins();
2653
2660
  const generatorResult = await adapter.createGenerator(plugins, {
2654
2661
  theme: customThemes ? Object.values(customThemes)[0] : void 0
2655
2662
  });
2656
- if (generatorResult.getStandardComponentsDefinition) {
2657
- const standardComponents = await generatorResult.getStandardComponentsDefinition(config2);
2663
+ if (generatorResult.getStandardDefinition) {
2664
+ const standardComponents = await generatorResult.getStandardDefinition(config2);
2658
2665
  return c.json({
2659
2666
  success: true,
2660
2667
  data: standardComponents,
@@ -2673,6 +2680,12 @@ function createFormatRouter(adapter) {
2673
2680
  requestId
2674
2681
  });
2675
2682
  if (error instanceof HTTPException4) throw error;
2683
+ if (error instanceof Error) {
2684
+ const msg = error.message.toLowerCase();
2685
+ if (msg.includes("invalid") || msg.includes("validation") || msg.includes("missing required") || msg.includes("unknown component")) {
2686
+ throw new HTTPException4(400, { message: error.message });
2687
+ }
2688
+ }
2676
2689
  throw new HTTPException4(500, {
2677
2690
  message: "Failed to get standard components definition"
2678
2691
  });
@@ -2684,6 +2697,17 @@ function createFormatRouter(adapter) {
2684
2697
  const cacheService = getContainer().get("cacheService");
2685
2698
  const stats = cacheService.getStats();
2686
2699
  const components = await adapter.getComponentCacheStats?.() ?? null;
2700
+ const rasterizer = await (async () => {
2701
+ try {
2702
+ const cli = await import("@json-to-office/jto-cli");
2703
+ const engine = await cli.getRasterizerCacheStats?.();
2704
+ if (!engine) return null;
2705
+ const prepass = await adapter.getVisualPrepassStats?.() ?? null;
2706
+ return { ...engine, ...prepass ? { prepass } : {} };
2707
+ } catch {
2708
+ return null;
2709
+ }
2710
+ })();
2687
2711
  return c.json({
2688
2712
  success: true,
2689
2713
  data: {
@@ -2695,7 +2719,8 @@ function createFormatRouter(adapter) {
2695
2719
  itemCount: stats.itemCount,
2696
2720
  enabled: stats.enabled
2697
2721
  },
2698
- ...components ? { components } : {}
2722
+ ...components ? { components } : {},
2723
+ ...rasterizer ? { rasterizer } : {}
2699
2724
  },
2700
2725
  meta: { timestamp: (/* @__PURE__ */ new Date()).toISOString() }
2701
2726
  });
@@ -2732,8 +2757,10 @@ function createFormatRouter(adapter) {
2732
2757
  try {
2733
2758
  const cacheService = getContainer().get("cacheService");
2734
2759
  cacheService.clear();
2735
- const { invalidateAllCaches } = await import("@json-to-office/jto-cli");
2736
- invalidateAllCaches();
2760
+ const cli = await import("@json-to-office/jto-cli");
2761
+ cli.invalidateAllCaches();
2762
+ await adapter.clearComponentCache?.();
2763
+ await cli.clearRasterizerCache?.();
2737
2764
  return c.json({
2738
2765
  success: true,
2739
2766
  data: { message: "Cache cleared successfully" },
@@ -4425,7 +4452,7 @@ function createDevCommand(adapter) {
4425
4452
  }
4426
4453
 
4427
4454
  // src/cli.ts
4428
- var PACKAGE_VERSION = true ? "0.29.0" : "dev-mode";
4455
+ var PACKAGE_VERSION = true ? "0.31.0" : "dev-mode";
4429
4456
  var program = new Command2();
4430
4457
  program.name("jto").description("JSON to Office CLI - Generate .docx and .pptx from JSON").version(PACKAGE_VERSION);
4431
4458
  registerCoreCommands(program, {