@fragments-sdk/cli 0.7.9 → 0.7.11
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/bin.js +13 -13
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-CWKQQR6C.js → chunk-57OW43NL.js} +3 -3
- package/dist/chunk-57OW43NL.js.map +1 -0
- package/dist/{chunk-AA6CAHCZ.js → chunk-7CRC46HV.js} +2 -2
- package/dist/chunk-7CRC46HV.js.map +1 -0
- package/dist/{chunk-3JPJTU25.js → chunk-CRTN6BIW.js} +5 -5
- package/dist/chunk-CRTN6BIW.js.map +1 -0
- package/dist/{chunk-LHIIBI6F.js → chunk-M42XIHPV.js} +2 -2
- package/dist/{chunk-2EFVPE5Q.js → chunk-TQOGBAOZ.js} +2 -2
- package/dist/chunk-TQOGBAOZ.js.map +1 -0
- package/dist/core/index.d.ts +1944 -0
- package/dist/{core-YAPWXDZW.js → core/index.js} +5 -5
- package/dist/defineFragment-C6PFzZyo.d.ts +656 -0
- package/dist/{generate-LEBVZCCH.js → generate-ZPERYZLF.js} +4 -4
- package/dist/index.d.ts +4 -159
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/{init-4VXL3Q6N.js → init-GID2DXB3.js} +69 -7
- package/dist/init-GID2DXB3.js.map +1 -0
- package/dist/mcp-bin.js +3 -3
- package/dist/{scan-3NYSRF6G.js → scan-BSMLGBX4.js} +5 -5
- package/dist/{service-HL6TMP3B.js → service-QACVPR37.js} +3 -3
- package/dist/{static-viewer-KLD24I4R.js → static-viewer-2RQD5QLR.js} +3 -3
- package/dist/{test-Y7YZOJLE.js → test-36UELXTE.js} +3 -3
- package/dist/{tokens-M4FCJKBK.js → tokens-A3BZIQPB.js} +4 -4
- package/dist/{viewer-ZWQQ74FV.js → viewer-CNLZQUFO.js} +156 -32
- package/dist/viewer-CNLZQUFO.js.map +1 -0
- package/package.json +8 -2
- package/src/commands/add.ts +1 -1
- package/src/commands/init.ts +84 -4
- package/src/core/defineFragment.ts +1 -1
- package/src/core/figma.ts +1 -1
- package/src/core/index.ts +2 -2
- package/src/core/loader.ts +3 -3
- package/src/core/schema.ts +1 -1
- package/src/index.ts +6 -0
- package/src/migrate/converter.ts +1 -1
- package/src/service/snippet-validation.test.ts +5 -5
- package/src/service/snippet-validation.ts +0 -1
- package/src/viewer/__tests__/viewer-integration.test.ts +16 -23
- package/src/viewer/components/AccessibilityPanel.tsx +1 -1
- package/src/viewer/components/ActionsPanel.tsx +1 -1
- package/src/viewer/components/App.tsx +563 -166
- package/src/viewer/components/BottomPanel.tsx +1 -1
- package/src/viewer/components/CodePanel.naming.test.tsx +1 -2
- package/src/viewer/components/CodePanel.tsx +1 -2
- package/src/viewer/components/CommandPalette.tsx +1 -1
- package/src/viewer/components/ComponentGraph.tsx +1 -1
- package/src/viewer/components/ComponentHeader.tsx +1 -1
- package/src/viewer/components/ContractPanel.tsx +1 -1
- package/src/viewer/components/ErrorBoundary.tsx +1 -1
- package/src/viewer/components/HealthDashboard.tsx +1 -1
- package/src/viewer/components/HmrStatusIndicator.tsx +1 -1
- package/src/viewer/components/InteractionsPanel.tsx +1 -1
- package/src/viewer/components/IsolatedRender.tsx +1 -1
- package/src/viewer/components/KeyboardShortcutsHelp.tsx +1 -1
- package/src/viewer/components/LandingPage.tsx +1 -1
- package/src/viewer/components/Layout.tsx +16 -13
- package/src/viewer/components/LeftSidebar.tsx +105 -18
- package/src/viewer/components/MultiViewportPreview.tsx +1 -1
- package/src/viewer/components/PreviewArea.tsx +22 -13
- package/src/viewer/components/PreviewFrameHost.tsx +0 -4
- package/src/viewer/components/PreviewToolbar.tsx +1 -1
- package/src/viewer/components/PropsEditor.tsx +1 -1
- package/src/viewer/components/PropsTable.tsx +1 -1
- package/src/viewer/components/RightSidebar.tsx +1 -1
- package/src/viewer/components/ScreenshotButton.tsx +1 -1
- package/src/viewer/components/SkeletonLoader.tsx +1 -1
- package/src/viewer/components/Toast.tsx +2 -2
- package/src/viewer/components/TokenStylePanel.tsx +1 -1
- package/src/viewer/components/VariantMatrix.tsx +1 -1
- package/src/viewer/components/VariantTabs.tsx +1 -1
- package/src/viewer/components/ViewportSelector.tsx +1 -1
- package/src/viewer/constants/ui.ts +14 -0
- package/src/viewer/entry.tsx +3 -4
- package/src/viewer/hooks/useKeyboardShortcuts.ts +65 -17
- package/src/viewer/hooks/useViewSettings.ts +1 -2
- package/src/viewer/index.ts +1 -1
- package/src/viewer/preview-frame.html +6 -9
- package/src/viewer/server.ts +106 -9
- package/src/viewer/styles/globals.css +12 -51
- package/src/viewer/vendor/shared/src/DocsHeaderBar.tsx +110 -0
- package/src/viewer/vendor/shared/src/DocsPageAsideHost.tsx +89 -0
- package/src/viewer/vendor/shared/src/DocsPageShell.tsx +119 -0
- package/src/viewer/vendor/shared/src/DocsSearchCommand.tsx +134 -0
- package/src/viewer/vendor/shared/src/DocsSidebarNav.tsx +66 -0
- package/src/viewer/vendor/shared/src/docs-layout.scss +28 -0
- package/src/viewer/vendor/shared/src/docs-layout.scss.d.ts +2 -0
- package/src/viewer/vendor/shared/src/index.ts +26 -0
- package/src/viewer/vendor/shared/src/types.ts +41 -0
- package/src/viewer/vite-plugin.ts +70 -9
- package/dist/chunk-2EFVPE5Q.js.map +0 -1
- package/dist/chunk-3JPJTU25.js.map +0 -1
- package/dist/chunk-AA6CAHCZ.js.map +0 -1
- package/dist/chunk-CWKQQR6C.js.map +0 -1
- package/dist/init-4VXL3Q6N.js.map +0 -1
- package/dist/viewer-ZWQQ74FV.js.map +0 -1
- /package/dist/{chunk-LHIIBI6F.js.map → chunk-M42XIHPV.js.map} +0 -0
- /package/dist/{core-YAPWXDZW.js.map → core/index.js.map} +0 -0
- /package/dist/{generate-LEBVZCCH.js.map → generate-ZPERYZLF.js.map} +0 -0
- /package/dist/{scan-3NYSRF6G.js.map → scan-BSMLGBX4.js.map} +0 -0
- /package/dist/{service-HL6TMP3B.js.map → service-QACVPR37.js.map} +0 -0
- /package/dist/{static-viewer-KLD24I4R.js.map → static-viewer-2RQD5QLR.js.map} +0 -0
- /package/dist/{test-Y7YZOJLE.js.map → test-36UELXTE.js.map} +0 -0
- /package/dist/{tokens-M4FCJKBK.js.map → tokens-A3BZIQPB.js.map} +0 -0
|
@@ -4,15 +4,15 @@ import {
|
|
|
4
4
|
findStorybookDir,
|
|
5
5
|
generatePreviewModule,
|
|
6
6
|
loadConfig
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-57OW43NL.js";
|
|
8
8
|
import {
|
|
9
9
|
discoverFragmentFiles,
|
|
10
10
|
discoverInstalledFragments
|
|
11
11
|
} from "./chunk-AWYCDRPG.js";
|
|
12
12
|
import {
|
|
13
13
|
generateContext
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
} from "./chunk-TQOGBAOZ.js";
|
|
15
|
+
import "./chunk-7CRC46HV.js";
|
|
16
16
|
import {
|
|
17
17
|
BRAND
|
|
18
18
|
} from "./chunk-EKLMXTWU.js";
|
|
@@ -360,7 +360,7 @@ var sharedRenderPool = null;
|
|
|
360
360
|
var browserPoolModule = null;
|
|
361
361
|
async function getSharedRenderPool() {
|
|
362
362
|
if (!browserPoolModule) {
|
|
363
|
-
browserPoolModule = await import("./service-
|
|
363
|
+
browserPoolModule = await import("./service-QACVPR37.js");
|
|
364
364
|
}
|
|
365
365
|
if (!sharedRenderPool) {
|
|
366
366
|
sharedRenderPool = new browserPoolModule.BrowserPool({
|
|
@@ -603,7 +603,7 @@ function fragmentsPlugin(options) {
|
|
|
603
603
|
const address = _server.httpServer?.address();
|
|
604
604
|
const port = typeof address === "object" && address ? address.port : 6006;
|
|
605
605
|
const renderViewport = viewport || { width: 800, height: 600 };
|
|
606
|
-
const { FigmaClient, bufferToBase64Url } = await import("./service-
|
|
606
|
+
const { FigmaClient, bufferToBase64Url } = await import("./service-QACVPR37.js");
|
|
607
607
|
const figmaClient = new FigmaClient({
|
|
608
608
|
accessToken: figmaToken
|
|
609
609
|
});
|
|
@@ -694,7 +694,7 @@ function fragmentsPlugin(options) {
|
|
|
694
694
|
);
|
|
695
695
|
return;
|
|
696
696
|
}
|
|
697
|
-
const { FigmaClient } = await import("./service-
|
|
697
|
+
const { FigmaClient } = await import("./service-QACVPR37.js");
|
|
698
698
|
const figmaClient = new FigmaClient({ accessToken: figmaToken });
|
|
699
699
|
const { fileKey, nodeId } = figmaClient.parseUrl(figmaUrl);
|
|
700
700
|
const figmaDesignProps = await figmaClient.getNodeProperties(
|
|
@@ -735,7 +735,7 @@ function fragmentsPlugin(options) {
|
|
|
735
735
|
}));
|
|
736
736
|
return;
|
|
737
737
|
}
|
|
738
|
-
const { getSharedTokenRegistry } = await import("./service-
|
|
738
|
+
const { getSharedTokenRegistry } = await import("./service-QACVPR37.js");
|
|
739
739
|
const registry = getSharedTokenRegistry();
|
|
740
740
|
if (!registry.isInitialized()) {
|
|
741
741
|
await registry.initialize(config.tokens, projectRoot);
|
|
@@ -795,7 +795,7 @@ function fragmentsPlugin(options) {
|
|
|
795
795
|
}));
|
|
796
796
|
return;
|
|
797
797
|
}
|
|
798
|
-
const { getSharedTokenRegistry } = await import("./service-
|
|
798
|
+
const { getSharedTokenRegistry } = await import("./service-QACVPR37.js");
|
|
799
799
|
const registry = getSharedTokenRegistry();
|
|
800
800
|
if (!registry.isInitialized()) {
|
|
801
801
|
await registry.initialize(config.tokens, projectRoot);
|
|
@@ -857,7 +857,7 @@ function fragmentsPlugin(options) {
|
|
|
857
857
|
res.end(JSON.stringify({ error: "Could not resolve fragment file path" }));
|
|
858
858
|
return;
|
|
859
859
|
}
|
|
860
|
-
const { getSharedTokenRegistry } = await import("./service-
|
|
860
|
+
const { getSharedTokenRegistry } = await import("./service-QACVPR37.js");
|
|
861
861
|
const registry = getSharedTokenRegistry();
|
|
862
862
|
if (!registry.isInitialized()) {
|
|
863
863
|
await registry.initialize(config.tokens, projectRoot);
|
|
@@ -983,7 +983,7 @@ function fragmentsPlugin(options) {
|
|
|
983
983
|
}
|
|
984
984
|
const { writeFile, mkdir } = await import("fs/promises");
|
|
985
985
|
const { join: join2 } = await import("path");
|
|
986
|
-
const { BRAND: BRAND2 } = await import("./core
|
|
986
|
+
const { BRAND: BRAND2 } = await import("./core/index.js");
|
|
987
987
|
const fragmentsDir = join2(projectRoot, BRAND2.dataDir, BRAND2.componentsDir);
|
|
988
988
|
await mkdir(fragmentsDir, { recursive: true });
|
|
989
989
|
const fragmentPath = join2(
|
|
@@ -1056,7 +1056,7 @@ function fragmentsPlugin(options) {
|
|
|
1056
1056
|
const {
|
|
1057
1057
|
getSharedTokenRegistry,
|
|
1058
1058
|
generateTokenPatches
|
|
1059
|
-
} = await import("./service-
|
|
1059
|
+
} = await import("./service-QACVPR37.js");
|
|
1060
1060
|
const registry = getSharedTokenRegistry();
|
|
1061
1061
|
if (!registry.isInitialized()) {
|
|
1062
1062
|
await registry.initialize(config.tokens, projectRoot);
|
|
@@ -1403,7 +1403,27 @@ function isStoryFile(filePath) {
|
|
|
1403
1403
|
function getBaseComponentPath(filePath) {
|
|
1404
1404
|
return filePath.replace(/\.(fragment|stories)\.(tsx?|jsx?)$/, "");
|
|
1405
1405
|
}
|
|
1406
|
-
function
|
|
1406
|
+
function extractComponentName(filePath) {
|
|
1407
|
+
const match = filePath.match(/([^/\\]+)\.(fragment|stories)\.(tsx?|jsx?)$/);
|
|
1408
|
+
return match ? match[1] : filePath.split("/").pop() || filePath;
|
|
1409
|
+
}
|
|
1410
|
+
async function extractDependenciesFromSource(absolutePath) {
|
|
1411
|
+
try {
|
|
1412
|
+
const source = await readFile(absolutePath, "utf-8");
|
|
1413
|
+
const depsMatch = source.match(/dependencies:\s*\[([\s\S]*?)\]/);
|
|
1414
|
+
if (!depsMatch) return [];
|
|
1415
|
+
const names = [];
|
|
1416
|
+
const nameRegex = /name:\s*['"]([^'"]+)['"]/g;
|
|
1417
|
+
let match;
|
|
1418
|
+
while ((match = nameRegex.exec(depsMatch[1])) !== null) {
|
|
1419
|
+
names.push(match[1]);
|
|
1420
|
+
}
|
|
1421
|
+
return names;
|
|
1422
|
+
} catch {
|
|
1423
|
+
return [];
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
async function generateFragmentsModule(fragmentFiles, config, previewConfigPath) {
|
|
1407
1427
|
const filesByBasePath = /* @__PURE__ */ new Map();
|
|
1408
1428
|
for (const file of fragmentFiles) {
|
|
1409
1429
|
const basePath = getBaseComponentPath(file.relativePath);
|
|
@@ -1416,18 +1436,26 @@ function generateFragmentsModule(fragmentFiles, config, previewConfigPath) {
|
|
|
1416
1436
|
}
|
|
1417
1437
|
filesByBasePath.set(basePath, existing);
|
|
1418
1438
|
}
|
|
1419
|
-
const
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1439
|
+
const loaderEntries = await Promise.all(
|
|
1440
|
+
Array.from(filesByBasePath.values()).map(async (files) => {
|
|
1441
|
+
const primaryFile = files.storyFile || files.fragmentFile;
|
|
1442
|
+
if (!primaryFile) return null;
|
|
1443
|
+
const isStory = !!files.storyFile;
|
|
1444
|
+
const metadataPath = files.storyFile && files.fragmentFile ? files.fragmentFile.absolutePath : null;
|
|
1445
|
+
const componentName = extractComponentName(primaryFile.relativePath);
|
|
1446
|
+
const fragmentSource = files.fragmentFile || primaryFile;
|
|
1447
|
+
const dependencies = await extractDependenciesFromSource(fragmentSource.absolutePath);
|
|
1448
|
+
return ` {
|
|
1425
1449
|
path: "${primaryFile.relativePath}",
|
|
1426
1450
|
isStory: ${isStory},
|
|
1451
|
+
componentName: ${JSON.stringify(componentName)},
|
|
1452
|
+
dependencies: ${JSON.stringify(dependencies)},
|
|
1427
1453
|
loader: () => import("${primaryFile.absolutePath}"),
|
|
1428
1454
|
metadataLoader: ${metadataPath ? `() => import("${metadataPath}")` : "null"}
|
|
1429
1455
|
}`;
|
|
1430
|
-
|
|
1456
|
+
})
|
|
1457
|
+
);
|
|
1458
|
+
const loaders = loaderEntries.filter(Boolean).join(",\n");
|
|
1431
1459
|
const previewImport = previewConfigPath ? `import * as previewConfig from "virtual:fragments-preview";` : "";
|
|
1432
1460
|
const previewSetup = previewConfigPath ? `
|
|
1433
1461
|
// Set global preview config before loading fragments
|
|
@@ -1441,7 +1469,7 @@ setPreviewConfig({
|
|
|
1441
1469
|
});
|
|
1442
1470
|
` : "";
|
|
1443
1471
|
return `
|
|
1444
|
-
import { storyModuleToFragment, setPreviewConfig } from "@fragments/core";
|
|
1472
|
+
import { storyModuleToFragment, setPreviewConfig } from "@fragments-sdk/cli/core";
|
|
1445
1473
|
${previewImport}
|
|
1446
1474
|
${previewSetup}
|
|
1447
1475
|
// Lazy fragment loaders (supports both .fragment.tsx and .stories.tsx)
|
|
@@ -1533,11 +1561,27 @@ export async function loadAllFragments() {
|
|
|
1533
1561
|
return { path: loader.path, fragment };
|
|
1534
1562
|
} catch (error) {
|
|
1535
1563
|
console.warn("[Fragments] Failed to load " + loader.path + ":", error.message);
|
|
1536
|
-
|
|
1564
|
+
// Create an error stub so the component still appears in the sidebar
|
|
1565
|
+
// with a helpful message about what went wrong
|
|
1566
|
+
return {
|
|
1567
|
+
path: loader.path,
|
|
1568
|
+
fragment: {
|
|
1569
|
+
meta: {
|
|
1570
|
+
name: loader.componentName || loader.path,
|
|
1571
|
+
description: 'Failed to load',
|
|
1572
|
+
category: '',
|
|
1573
|
+
},
|
|
1574
|
+
variants: [],
|
|
1575
|
+
_loadError: {
|
|
1576
|
+
message: error.message,
|
|
1577
|
+
dependencies: loader.dependencies || [],
|
|
1578
|
+
},
|
|
1579
|
+
},
|
|
1580
|
+
};
|
|
1537
1581
|
}
|
|
1538
1582
|
})
|
|
1539
1583
|
);
|
|
1540
|
-
// Filter out
|
|
1584
|
+
// Filter out nulls (fragments that had no component)
|
|
1541
1585
|
return results.filter(r => r !== null);
|
|
1542
1586
|
}
|
|
1543
1587
|
|
|
@@ -1951,7 +1995,7 @@ async function loadFullFragmentForCompare(_server, _fragmentFiles, componentName
|
|
|
1951
1995
|
}
|
|
1952
1996
|
}
|
|
1953
1997
|
async function compareImages(image1Base64, image2Base64, threshold) {
|
|
1954
|
-
const { DiffEngine, base64UrlToBuffer, bufferToBase64Url } = await import("./service-
|
|
1998
|
+
const { DiffEngine, base64UrlToBuffer, bufferToBase64Url } = await import("./service-QACVPR37.js");
|
|
1955
1999
|
const { PNG } = await import("pngjs");
|
|
1956
2000
|
const buffer1 = base64UrlToBuffer(image1Base64);
|
|
1957
2001
|
const buffer2 = base64UrlToBuffer(image2Base64);
|
|
@@ -2052,7 +2096,13 @@ var cliPackageRoot = resolve2(__dirname2, "..");
|
|
|
2052
2096
|
var viewerRoot = resolve2(cliPackageRoot, "src/viewer");
|
|
2053
2097
|
var packagesRoot = resolve2(cliPackageRoot, "..");
|
|
2054
2098
|
var localUiLibRoot = resolve2(packagesRoot, "../libs/ui/src");
|
|
2099
|
+
var localSharedLibRoot = resolve2(packagesRoot, "../libs/shared/src");
|
|
2100
|
+
var vendoredSharedLibRoot = resolve2(viewerRoot, "vendor/shared/src");
|
|
2055
2101
|
function resolveUiLib(nodeModulesDir) {
|
|
2102
|
+
const localIndex = join(localUiLibRoot, "index.ts");
|
|
2103
|
+
if (existsSync(localIndex)) {
|
|
2104
|
+
return localUiLibRoot;
|
|
2105
|
+
}
|
|
2056
2106
|
const installedUi = join(nodeModulesDir, "@fragments-sdk/ui/src/index.ts");
|
|
2057
2107
|
if (existsSync(installedUi)) {
|
|
2058
2108
|
return resolve2(dirname2(installedUi));
|
|
@@ -2063,6 +2113,76 @@ function resolveUiLib(nodeModulesDir) {
|
|
|
2063
2113
|
}
|
|
2064
2114
|
return localUiLibRoot;
|
|
2065
2115
|
}
|
|
2116
|
+
function resolveSharedLib() {
|
|
2117
|
+
const localIndex = join(localSharedLibRoot, "index.ts");
|
|
2118
|
+
if (existsSync(localIndex)) {
|
|
2119
|
+
return localSharedLibRoot;
|
|
2120
|
+
}
|
|
2121
|
+
const vendoredIndex = join(vendoredSharedLibRoot, "index.ts");
|
|
2122
|
+
if (existsSync(vendoredIndex)) {
|
|
2123
|
+
return vendoredSharedLibRoot;
|
|
2124
|
+
}
|
|
2125
|
+
return localSharedLibRoot;
|
|
2126
|
+
}
|
|
2127
|
+
function cjsInteropPlugin(nodeModulesPath) {
|
|
2128
|
+
const virtualModules = {
|
|
2129
|
+
// use-sync-external-store/shim is CJS-only, used by @base-ui/react.
|
|
2130
|
+
// Since React 18+, useSyncExternalStore is built-in — redirect to React's native export.
|
|
2131
|
+
"use-sync-external-store/shim": `export { useSyncExternalStore } from 'react';`,
|
|
2132
|
+
// use-sync-external-store/shim/with-selector is CJS-only, used by @base-ui/utils.
|
|
2133
|
+
// Provides useSyncExternalStoreWithSelector — a selector wrapper around useSyncExternalStore.
|
|
2134
|
+
"use-sync-external-store/shim/with-selector": `
|
|
2135
|
+
import { useSyncExternalStore, useRef, useEffect, useMemo, useDebugValue } from 'react';
|
|
2136
|
+
export function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
2137
|
+
var instRef = useRef(null);
|
|
2138
|
+
if (instRef.current === null) instRef.current = { hasValue: false, value: null };
|
|
2139
|
+
var inst = instRef.current;
|
|
2140
|
+
var _useMemo = useMemo(function () {
|
|
2141
|
+
var hasMemo = false, memoizedSnapshot, memoizedSelection;
|
|
2142
|
+
function memoizedSelector(nextSnapshot) {
|
|
2143
|
+
if (!hasMemo) {
|
|
2144
|
+
hasMemo = true;
|
|
2145
|
+
memoizedSnapshot = nextSnapshot;
|
|
2146
|
+
var nextSelection = selector(nextSnapshot);
|
|
2147
|
+
if (isEqual !== undefined && inst.hasValue && isEqual(inst.value, nextSelection))
|
|
2148
|
+
return memoizedSelection = inst.value;
|
|
2149
|
+
return memoizedSelection = nextSelection;
|
|
2150
|
+
}
|
|
2151
|
+
if (Object.is(memoizedSnapshot, nextSnapshot)) return memoizedSelection;
|
|
2152
|
+
var nextSelection = selector(nextSnapshot);
|
|
2153
|
+
if (isEqual !== undefined && isEqual(memoizedSelection, nextSelection)) {
|
|
2154
|
+
memoizedSnapshot = nextSnapshot;
|
|
2155
|
+
return memoizedSelection;
|
|
2156
|
+
}
|
|
2157
|
+
memoizedSnapshot = nextSnapshot;
|
|
2158
|
+
return memoizedSelection = nextSelection;
|
|
2159
|
+
}
|
|
2160
|
+
var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;
|
|
2161
|
+
return [function () { return memoizedSelector(getSnapshot()); },
|
|
2162
|
+
maybeGetServerSnapshot === null ? undefined : function () { return memoizedSelector(maybeGetServerSnapshot()); }];
|
|
2163
|
+
}, [getSnapshot, getServerSnapshot, selector, isEqual]);
|
|
2164
|
+
var value = useSyncExternalStore(subscribe, _useMemo[0], _useMemo[1]);
|
|
2165
|
+
useEffect(function () { inst.hasValue = true; inst.value = value; }, [value]);
|
|
2166
|
+
useDebugValue(value);
|
|
2167
|
+
return value;
|
|
2168
|
+
}`
|
|
2169
|
+
};
|
|
2170
|
+
return {
|
|
2171
|
+
name: "fragments-cjs-interop",
|
|
2172
|
+
enforce: "pre",
|
|
2173
|
+
resolveId(source) {
|
|
2174
|
+
if (source in virtualModules) {
|
|
2175
|
+
return `\0cjs-interop:${source}`;
|
|
2176
|
+
}
|
|
2177
|
+
return void 0;
|
|
2178
|
+
},
|
|
2179
|
+
load(id) {
|
|
2180
|
+
if (!id.startsWith("\0cjs-interop:")) return void 0;
|
|
2181
|
+
const pkg = id.slice("\0cjs-interop:".length);
|
|
2182
|
+
return virtualModules[pkg];
|
|
2183
|
+
}
|
|
2184
|
+
};
|
|
2185
|
+
}
|
|
2066
2186
|
async function createDevServer(options = {}) {
|
|
2067
2187
|
const startTime = performance.now();
|
|
2068
2188
|
const {
|
|
@@ -2097,6 +2217,8 @@ async function createDevServer(options = {}) {
|
|
|
2097
2217
|
console.log("\u2139\uFE0F No project Vite config found, using defaults");
|
|
2098
2218
|
}
|
|
2099
2219
|
const nodeModulesPath = findNodeModules(projectRoot);
|
|
2220
|
+
const uiLibRoot = resolveUiLib(nodeModulesPath);
|
|
2221
|
+
const sharedLibRoot = resolveSharedLib();
|
|
2100
2222
|
console.log(`\u{1F4C1} Using node_modules: ${nodeModulesPath}`);
|
|
2101
2223
|
const installedPkgRoots = [...new Set(
|
|
2102
2224
|
installedFiles.map((f) => {
|
|
@@ -2117,13 +2239,15 @@ async function createDevServer(options = {}) {
|
|
|
2117
2239
|
port,
|
|
2118
2240
|
open: open ? "/fragments/" : false,
|
|
2119
2241
|
fs: {
|
|
2120
|
-
// Allow serving files from viewer package, project,
|
|
2121
|
-
allow: [viewerRoot,
|
|
2242
|
+
// Allow serving files from viewer package, project, shared libs, and node_modules root
|
|
2243
|
+
allow: [viewerRoot, uiLibRoot, sharedLibRoot, projectRoot, configDir, dirname2(nodeModulesPath), ...installedPkgRoots]
|
|
2122
2244
|
}
|
|
2123
2245
|
},
|
|
2124
2246
|
plugins: [
|
|
2125
2247
|
// React support (if not already in project config)
|
|
2126
2248
|
...hasReactPlugin(projectViteConfig) ? [] : [react()],
|
|
2249
|
+
// CJS interop for packages imported from within node_modules
|
|
2250
|
+
cjsInteropPlugin(nodeModulesPath),
|
|
2127
2251
|
// Fragments plugins (array including SVGR)
|
|
2128
2252
|
...fragmentsPlugin({
|
|
2129
2253
|
fragmentFiles: allFragmentFiles,
|
|
@@ -2142,12 +2266,12 @@ async function createDevServer(options = {}) {
|
|
|
2142
2266
|
// Dedupe ensures all imports of these packages resolve to the same copy
|
|
2143
2267
|
dedupe: ["react", "react-dom"],
|
|
2144
2268
|
alias: {
|
|
2145
|
-
//
|
|
2146
|
-
"@fragments/
|
|
2147
|
-
// Resolve @fragments/
|
|
2148
|
-
"@fragments/
|
|
2149
|
-
// Resolve @fragments/core to the
|
|
2150
|
-
"@fragments/core": resolve2(cliPackageRoot, "src/core/index.ts"),
|
|
2269
|
+
// Resolve @fragments-sdk/ui to local source or installed package
|
|
2270
|
+
"@fragments-sdk/ui": uiLibRoot,
|
|
2271
|
+
// Resolve @fragments-sdk/shared to monorepo source or vendored fallback
|
|
2272
|
+
"@fragments-sdk/shared": sharedLibRoot,
|
|
2273
|
+
// Resolve @fragments-sdk/cli/core to the CLI's own core source
|
|
2274
|
+
"@fragments-sdk/cli/core": resolve2(cliPackageRoot, "src/core/index.ts"),
|
|
2151
2275
|
// Ensure ALL react imports resolve to project's node_modules
|
|
2152
2276
|
// This is critical for viewer files loaded from outside project root
|
|
2153
2277
|
"react": safeRealpath(join(nodeModulesPath, "react")),
|
|
@@ -2215,4 +2339,4 @@ export {
|
|
|
2215
2339
|
createDevServer,
|
|
2216
2340
|
fragmentsPlugin
|
|
2217
2341
|
};
|
|
2218
|
-
//# sourceMappingURL=viewer-
|
|
2342
|
+
//# sourceMappingURL=viewer-CNLZQUFO.js.map
|