@fragments-sdk/cli 0.7.17 → 0.8.1

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 (53) hide show
  1. package/dist/bin.js +227 -53
  2. package/dist/bin.js.map +1 -1
  3. package/dist/{chunk-QLTLLQBI.js → chunk-2JIKCJX3.js} +312 -24
  4. package/dist/chunk-2JIKCJX3.js.map +1 -0
  5. package/dist/{chunk-57OW43NL.js → chunk-CJEGT3WD.js} +2 -2
  6. package/dist/{chunk-7CRC46HV.js → chunk-GOVI6COW.js} +13 -3
  7. package/dist/chunk-GOVI6COW.js.map +1 -0
  8. package/dist/{chunk-WLXFE6XW.js → chunk-NGIMCIK2.js} +60 -2
  9. package/dist/chunk-NGIMCIK2.js.map +1 -0
  10. package/dist/{chunk-M42XIHPV.js → chunk-WI6SLMSO.js} +2 -2
  11. package/dist/core/index.d.ts +110 -3
  12. package/dist/core/index.js +12 -2
  13. package/dist/{defineFragment-BI9KoPrs.d.ts → defineFragment-D0UTve-I.d.ts} +9 -0
  14. package/dist/{generate-ICIPKCKV.js → generate-35OIMW4Y.js} +4 -4
  15. package/dist/index.d.ts +2 -2
  16. package/dist/index.js +4 -4
  17. package/dist/{init-DIZ6UNBL.js → init-KFYN37ZY.js} +4 -4
  18. package/dist/mcp-bin.js +67 -3
  19. package/dist/mcp-bin.js.map +1 -1
  20. package/dist/{scan-X3DI2X5G.js → scan-65RH3QMM.js} +5 -5
  21. package/dist/{service-JEWWTSKI.js → service-A5GIGGGK.js} +3 -3
  22. package/dist/{static-viewer-JIWCYKVK.js → static-viewer-NSODM5VX.js} +3 -3
  23. package/dist/{test-36UELXTE.js → test-RPWZAYSJ.js} +3 -3
  24. package/dist/{tokens-K2AGUUOJ.js → tokens-NIXSZRX7.js} +4 -4
  25. package/dist/{viewer-QKIAPTPG.js → viewer-HZK4BSDK.js} +43 -12
  26. package/dist/viewer-HZK4BSDK.js.map +1 -0
  27. package/package.json +3 -3
  28. package/src/bin.ts +32 -0
  29. package/src/build.ts +47 -0
  30. package/src/commands/perf.ts +249 -0
  31. package/src/core/bundle-measurer.ts +421 -0
  32. package/src/core/index.ts +16 -0
  33. package/src/core/performance-presets.ts +142 -0
  34. package/src/core/schema.ts +10 -0
  35. package/src/core/types.ts +6 -0
  36. package/src/mcp/server.ts +77 -0
  37. package/src/viewer/components/BottomPanel.tsx +8 -0
  38. package/src/viewer/components/PerformancePanel.tsx +301 -0
  39. package/src/viewer/hooks/useAppState.ts +1 -1
  40. package/src/viewer/vite-plugin.ts +36 -0
  41. package/dist/chunk-7CRC46HV.js.map +0 -1
  42. package/dist/chunk-QLTLLQBI.js.map +0 -1
  43. package/dist/chunk-WLXFE6XW.js.map +0 -1
  44. package/dist/viewer-QKIAPTPG.js.map +0 -1
  45. /package/dist/{chunk-57OW43NL.js.map → chunk-CJEGT3WD.js.map} +0 -0
  46. /package/dist/{chunk-M42XIHPV.js.map → chunk-WI6SLMSO.js.map} +0 -0
  47. /package/dist/{generate-ICIPKCKV.js.map → generate-35OIMW4Y.js.map} +0 -0
  48. /package/dist/{init-DIZ6UNBL.js.map → init-KFYN37ZY.js.map} +0 -0
  49. /package/dist/{scan-X3DI2X5G.js.map → scan-65RH3QMM.js.map} +0 -0
  50. /package/dist/{service-JEWWTSKI.js.map → service-A5GIGGGK.js.map} +0 -0
  51. /package/dist/{static-viewer-JIWCYKVK.js.map → static-viewer-NSODM5VX.js.map} +0 -0
  52. /package/dist/{test-36UELXTE.js.map → test-RPWZAYSJ.js.map} +0 -0
  53. /package/dist/{tokens-K2AGUUOJ.js.map → tokens-NIXSZRX7.js.map} +0 -0
@@ -3,12 +3,12 @@ import {
3
3
  generateStaticViewer,
4
4
  generateViewerFromJson
5
5
  } from "./chunk-TOIE7VXF.js";
6
- import "./chunk-WLXFE6XW.js";
7
- import "./chunk-7CRC46HV.js";
6
+ import "./chunk-NGIMCIK2.js";
7
+ import "./chunk-GOVI6COW.js";
8
8
  import "./chunk-EKLMXTWU.js";
9
9
  import "./chunk-Z7EY4VHE.js";
10
10
  export {
11
11
  generateStaticViewer,
12
12
  generateViewerFromJson
13
13
  };
14
- //# sourceMappingURL=static-viewer-JIWCYKVK.js.map
14
+ //# sourceMappingURL=static-viewer-NSODM5VX.js.map
@@ -1,11 +1,11 @@
1
1
  import { createRequire as __banner_createRequire } from 'module'; const require = __banner_createRequire(import.meta.url);
2
2
  import {
3
3
  parseFragmentFile
4
- } from "./chunk-57OW43NL.js";
4
+ } from "./chunk-CJEGT3WD.js";
5
5
  import {
6
6
  discoverFragmentFiles
7
7
  } from "./chunk-AWYCDRPG.js";
8
- import "./chunk-7CRC46HV.js";
8
+ import "./chunk-GOVI6COW.js";
9
9
  import "./chunk-EKLMXTWU.js";
10
10
  import "./chunk-Z7EY4VHE.js";
11
11
 
@@ -1072,4 +1072,4 @@ export {
1072
1072
  listTests,
1073
1073
  runTestCommand
1074
1074
  };
1075
- //# sourceMappingURL=test-36UELXTE.js.map
1075
+ //# sourceMappingURL=test-RPWZAYSJ.js.map
@@ -1,13 +1,13 @@
1
1
  import { createRequire as __banner_createRequire } from 'module'; const require = __banner_createRequire(import.meta.url);
2
2
  import {
3
3
  loadConfig
4
- } from "./chunk-57OW43NL.js";
4
+ } from "./chunk-CJEGT3WD.js";
5
5
  import "./chunk-AWYCDRPG.js";
6
6
  import {
7
7
  parseTokenFiles
8
8
  } from "./chunk-YMPGYEWK.js";
9
- import "./chunk-WLXFE6XW.js";
10
- import "./chunk-7CRC46HV.js";
9
+ import "./chunk-NGIMCIK2.js";
10
+ import "./chunk-GOVI6COW.js";
11
11
  import {
12
12
  BRAND
13
13
  } from "./chunk-EKLMXTWU.js";
@@ -173,4 +173,4 @@ export {
173
173
  tokens_default as default,
174
174
  tokens
175
175
  };
176
- //# sourceMappingURL=tokens-K2AGUUOJ.js.map
176
+ //# sourceMappingURL=tokens-NIXSZRX7.js.map
@@ -5,15 +5,15 @@ import {
5
5
  generatePreviewModule,
6
6
  loadConfig,
7
7
  parseFragmentFile
8
- } from "./chunk-57OW43NL.js";
8
+ } from "./chunk-CJEGT3WD.js";
9
9
  import {
10
10
  discoverFragmentFiles,
11
11
  discoverInstalledFragments
12
12
  } from "./chunk-AWYCDRPG.js";
13
13
  import {
14
14
  generateContext
15
- } from "./chunk-WLXFE6XW.js";
16
- import "./chunk-7CRC46HV.js";
15
+ } from "./chunk-NGIMCIK2.js";
16
+ import "./chunk-GOVI6COW.js";
17
17
  import {
18
18
  BRAND
19
19
  } from "./chunk-EKLMXTWU.js";
@@ -361,7 +361,7 @@ var sharedRenderPool = null;
361
361
  var browserPoolModule = null;
362
362
  async function getSharedRenderPool() {
363
363
  if (!browserPoolModule) {
364
- browserPoolModule = await import("./service-JEWWTSKI.js");
364
+ browserPoolModule = await import("./service-A5GIGGGK.js");
365
365
  }
366
366
  if (!sharedRenderPool) {
367
367
  sharedRenderPool = new browserPoolModule.BrowserPool({
@@ -604,7 +604,7 @@ function fragmentsPlugin(options) {
604
604
  const address = _server.httpServer?.address();
605
605
  const port = typeof address === "object" && address ? address.port : 6006;
606
606
  const renderViewport = viewport || { width: 800, height: 600 };
607
- const { FigmaClient, bufferToBase64Url } = await import("./service-JEWWTSKI.js");
607
+ const { FigmaClient, bufferToBase64Url } = await import("./service-A5GIGGGK.js");
608
608
  const figmaClient = new FigmaClient({
609
609
  accessToken: figmaToken
610
610
  });
@@ -695,7 +695,7 @@ function fragmentsPlugin(options) {
695
695
  );
696
696
  return;
697
697
  }
698
- const { FigmaClient } = await import("./service-JEWWTSKI.js");
698
+ const { FigmaClient } = await import("./service-A5GIGGGK.js");
699
699
  const figmaClient = new FigmaClient({ accessToken: figmaToken });
700
700
  const { fileKey, nodeId } = figmaClient.parseUrl(figmaUrl);
701
701
  const figmaDesignProps = await figmaClient.getNodeProperties(
@@ -736,7 +736,7 @@ function fragmentsPlugin(options) {
736
736
  }));
737
737
  return;
738
738
  }
739
- const { getSharedTokenRegistry } = await import("./service-JEWWTSKI.js");
739
+ const { getSharedTokenRegistry } = await import("./service-A5GIGGGK.js");
740
740
  const registry = getSharedTokenRegistry();
741
741
  if (!registry.isInitialized()) {
742
742
  await registry.initialize(config.tokens, projectRoot);
@@ -796,7 +796,7 @@ function fragmentsPlugin(options) {
796
796
  }));
797
797
  return;
798
798
  }
799
- const { getSharedTokenRegistry } = await import("./service-JEWWTSKI.js");
799
+ const { getSharedTokenRegistry } = await import("./service-A5GIGGGK.js");
800
800
  const registry = getSharedTokenRegistry();
801
801
  if (!registry.isInitialized()) {
802
802
  await registry.initialize(config.tokens, projectRoot);
@@ -858,7 +858,7 @@ function fragmentsPlugin(options) {
858
858
  res.end(JSON.stringify({ error: "Could not resolve fragment file path" }));
859
859
  return;
860
860
  }
861
- const { getSharedTokenRegistry } = await import("./service-JEWWTSKI.js");
861
+ const { getSharedTokenRegistry } = await import("./service-A5GIGGGK.js");
862
862
  const registry = getSharedTokenRegistry();
863
863
  if (!registry.isInitialized()) {
864
864
  await registry.initialize(config.tokens, projectRoot);
@@ -1073,7 +1073,7 @@ function fragmentsPlugin(options) {
1073
1073
  const {
1074
1074
  getSharedTokenRegistry,
1075
1075
  generateTokenPatches
1076
- } = await import("./service-JEWWTSKI.js");
1076
+ } = await import("./service-A5GIGGGK.js");
1077
1077
  const registry = getSharedTokenRegistry();
1078
1078
  if (!registry.isInitialized()) {
1079
1079
  await registry.initialize(config.tokens, projectRoot);
@@ -1293,6 +1293,37 @@ function fragmentsPlugin(options) {
1293
1293
  }
1294
1294
  return;
1295
1295
  }
1296
+ if (req.url === "/fragments/perf-data" && req.method === "GET") {
1297
+ try {
1298
+ const { readFile: readFileAsync } = await import("fs/promises");
1299
+ const { resolve: resolvePath, join: joinPath } = await import("path");
1300
+ const outFilePath = resolvePath(
1301
+ projectRoot,
1302
+ config.outFile ?? BRAND.outFile
1303
+ );
1304
+ const raw = await readFileAsync(outFilePath, "utf-8");
1305
+ const parsed = JSON.parse(raw);
1306
+ const components = {};
1307
+ for (const [name, frag] of Object.entries(
1308
+ parsed.fragments
1309
+ )) {
1310
+ if (frag.performance) {
1311
+ components[name] = frag.performance;
1312
+ }
1313
+ }
1314
+ res.setHeader("Content-Type", "application/json");
1315
+ res.end(
1316
+ JSON.stringify({
1317
+ summary: parsed.performanceSummary ?? null,
1318
+ components
1319
+ })
1320
+ );
1321
+ } catch {
1322
+ res.setHeader("Content-Type", "application/json");
1323
+ res.end(JSON.stringify({ summary: null, components: {} }));
1324
+ }
1325
+ return;
1326
+ }
1296
1327
  if (req.url?.startsWith("/fragments/preview")) {
1297
1328
  if (req.url === "/fragments/preview") {
1298
1329
  res.writeHead(302, { Location: "/fragments/preview/" });
@@ -2057,7 +2088,7 @@ async function loadFullFragmentForCompare(_server, _fragmentFiles, componentName
2057
2088
  }
2058
2089
  }
2059
2090
  async function compareImages(image1Base64, image2Base64, threshold) {
2060
- const { DiffEngine, base64UrlToBuffer, bufferToBase64Url } = await import("./service-JEWWTSKI.js");
2091
+ const { DiffEngine, base64UrlToBuffer, bufferToBase64Url } = await import("./service-A5GIGGGK.js");
2061
2092
  const { PNG } = await import("pngjs");
2062
2093
  const buffer1 = base64UrlToBuffer(image1Base64);
2063
2094
  const buffer2 = base64UrlToBuffer(image2Base64);
@@ -2450,4 +2481,4 @@ export {
2450
2481
  createDevServer,
2451
2482
  fragmentsPlugin
2452
2483
  };
2453
- //# sourceMappingURL=viewer-QKIAPTPG.js.map
2484
+ //# sourceMappingURL=viewer-HZK4BSDK.js.map