storybook-addon-design-system-docs 1.0.1 → 1.0.2
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 +143 -15
- package/dist/components/assets/index.cjs +2 -2
- package/dist/components/assets/index.cjs.map +1 -1
- package/dist/components/assets/index.js +2 -2
- package/dist/components/assets/index.js.map +1 -1
- package/dist/components/primitives/index.cjs +2 -2
- package/dist/components/primitives/index.cjs.map +1 -1
- package/dist/components/primitives/index.js +2 -2
- package/dist/components/primitives/index.js.map +1 -1
- package/dist/index.cjs +29 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -23
- package/dist/index.js.map +1 -1
- package/dist/preset.cjs +215 -81
- package/dist/preset.cjs.map +1 -1
- package/dist/preset.js +215 -81
- package/dist/preset.js.map +1 -1
- package/package.json +141 -141
- package/templates/spacing.mdx +1 -1
package/dist/preset.js
CHANGED
|
@@ -275,10 +275,19 @@ function validateAssetConfig(configs) {
|
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
277
|
function normalizeAssetGroup(config, sidebarGroup = "Assets/", configDir) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
278
|
+
const rawPath = config.path;
|
|
279
|
+
let titlePrefix;
|
|
280
|
+
if (rawPath?.startsWith("/")) {
|
|
281
|
+
titlePrefix = rawPath.slice(1);
|
|
282
|
+
} else if (rawPath) {
|
|
283
|
+
titlePrefix = sidebarGroup ? `${sidebarGroup}/${rawPath}` : rawPath;
|
|
284
|
+
} else {
|
|
285
|
+
titlePrefix = sidebarGroup;
|
|
286
|
+
}
|
|
287
|
+
if (titlePrefix && !titlePrefix.endsWith("/")) {
|
|
288
|
+
titlePrefix += "/";
|
|
281
289
|
}
|
|
290
|
+
const storyPath = titlePrefix ? `${titlePrefix}${config.name}` : config.name;
|
|
282
291
|
const source = path2.isAbsolute(config.source) ? config.source : configDir ? path2.resolve(configDir, config.source) : config.source;
|
|
283
292
|
const variants = {
|
|
284
293
|
...DEFAULT_VARIANT_CONFIG,
|
|
@@ -524,6 +533,11 @@ function generateAssetStories(options) {
|
|
|
524
533
|
if (!assets || !Array.isArray(assets) || assets.length === 0) {
|
|
525
534
|
return [];
|
|
526
535
|
}
|
|
536
|
+
const normalizedAssets = normalizeAssetConfigs(
|
|
537
|
+
assets,
|
|
538
|
+
addonOptions.sidebarGroup,
|
|
539
|
+
configDir
|
|
540
|
+
);
|
|
527
541
|
const assetsDir = path2.resolve(configDir, "design-system/assets");
|
|
528
542
|
if (!fs2__default.existsSync(assetsDir)) {
|
|
529
543
|
fs2__default.mkdirSync(assetsDir, { recursive: true });
|
|
@@ -542,13 +556,36 @@ function generateAssetStories(options) {
|
|
|
542
556
|
return [];
|
|
543
557
|
}
|
|
544
558
|
const validFiles = /* @__PURE__ */ new Set();
|
|
545
|
-
|
|
559
|
+
normalizedAssets.forEach((group) => {
|
|
546
560
|
const groupName = group.name;
|
|
547
561
|
const groupTitle = group.title || groupName;
|
|
548
562
|
const cleanName = groupName.replace(/[^a-zA-Z0-9]/g, "");
|
|
549
563
|
const filename = `${cleanName}.mdx`;
|
|
550
564
|
const filePath = path2.join(assetsDir, filename);
|
|
551
|
-
|
|
565
|
+
let fileContent = templateContent.replace(
|
|
566
|
+
/^\s*<Meta\s+title="[^"]*"\s*\/>/m,
|
|
567
|
+
`<Meta title="${group.path}" />`
|
|
568
|
+
).replace(/\{\{group\.name\}\}/g, groupName).replace(/\{\{group\.title\}\}/g, groupTitle);
|
|
569
|
+
if (!fileContent.match(/^export\s+(const|function|class)/m)) {
|
|
570
|
+
const lines = fileContent.split("\n");
|
|
571
|
+
let lastImportIndex = -1;
|
|
572
|
+
for (let i = 0; i < lines.length; i++) {
|
|
573
|
+
if (lines[i].trim().startsWith("import ")) {
|
|
574
|
+
lastImportIndex = i;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
if (lastImportIndex !== -1) {
|
|
578
|
+
lines.splice(
|
|
579
|
+
lastImportIndex + 1,
|
|
580
|
+
0,
|
|
581
|
+
"",
|
|
582
|
+
"// Required for Storybook indexer",
|
|
583
|
+
"export const __ignore = {};",
|
|
584
|
+
""
|
|
585
|
+
);
|
|
586
|
+
fileContent = lines.join("\n");
|
|
587
|
+
}
|
|
588
|
+
}
|
|
552
589
|
try {
|
|
553
590
|
fs2__default.writeFileSync(filePath, fileContent);
|
|
554
591
|
validFiles.add(filename);
|
|
@@ -628,8 +665,8 @@ function normalizeAddonOptions(options) {
|
|
|
628
665
|
};
|
|
629
666
|
}
|
|
630
667
|
function validateSidebarGroup(sidebarGroup) {
|
|
631
|
-
if (typeof sidebarGroup !== "string"
|
|
632
|
-
throw new Error("sidebarGroup must be a
|
|
668
|
+
if (typeof sidebarGroup !== "string") {
|
|
669
|
+
throw new Error("sidebarGroup must be a string");
|
|
633
670
|
}
|
|
634
671
|
}
|
|
635
672
|
function validateSections(sections) {
|
|
@@ -652,27 +689,24 @@ function isValidSectionName(name) {
|
|
|
652
689
|
return typeof name === "string" && VALID_SECTIONS.includes(name);
|
|
653
690
|
}
|
|
654
691
|
function isValidSectionObject(section) {
|
|
655
|
-
return typeof section === "object" && section !== null && isValidSectionName(section.name) && (section.path === void 0 || typeof section.path === "string"
|
|
692
|
+
return typeof section === "object" && section !== null && isValidSectionName(section.name) && (section.path === void 0 || typeof section.path === "string");
|
|
656
693
|
}
|
|
657
694
|
function normalizeSection(section, sidebarGroup) {
|
|
658
695
|
const name = typeof section === "string" ? section : section.name;
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
if (
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
if (!path8.endsWith("/")) {
|
|
668
|
-
return { name, path: `${path8}/${name}` };
|
|
669
|
-
}
|
|
670
|
-
return { name, path: `${path8}${name}` };
|
|
696
|
+
const rawPath = typeof section === "string" ? void 0 : section.path;
|
|
697
|
+
let titlePrefix;
|
|
698
|
+
if (rawPath?.startsWith("/")) {
|
|
699
|
+
titlePrefix = rawPath.slice(1);
|
|
700
|
+
} else if (rawPath) {
|
|
701
|
+
titlePrefix = sidebarGroup ? `${sidebarGroup}/${rawPath}` : rawPath;
|
|
702
|
+
} else {
|
|
703
|
+
titlePrefix = sidebarGroup;
|
|
671
704
|
}
|
|
672
|
-
if (!
|
|
673
|
-
|
|
705
|
+
if (titlePrefix && !titlePrefix.endsWith("/")) {
|
|
706
|
+
titlePrefix += "/";
|
|
674
707
|
}
|
|
675
|
-
|
|
708
|
+
const path9 = titlePrefix ? `${titlePrefix}${name}` : name;
|
|
709
|
+
return { name, path: path9 };
|
|
676
710
|
}
|
|
677
711
|
function normalizeSections(sections, sidebarGroup) {
|
|
678
712
|
return sections.map((section) => normalizeSection(section, sidebarGroup));
|
|
@@ -1292,6 +1326,71 @@ async function loadTheme(options) {
|
|
|
1292
1326
|
`Could not determine how to load Tailwind config from '${options.tailwindConfig}'. File must be either a Tailwind config file (tailwind.config.{js,cjs,mjs,ts}) or a CSS file containing @theme.`
|
|
1293
1327
|
);
|
|
1294
1328
|
}
|
|
1329
|
+
var logger3 = new Logger("SectionGenerator");
|
|
1330
|
+
function generateSectionStories(options) {
|
|
1331
|
+
const { configDir, sections, addonOptions } = options;
|
|
1332
|
+
const generatedStories = [];
|
|
1333
|
+
const sectionsDir = path2.resolve(configDir, "design-system/sections");
|
|
1334
|
+
if (!fs2__default.existsSync(sectionsDir)) {
|
|
1335
|
+
fs2__default.mkdirSync(sectionsDir, { recursive: true });
|
|
1336
|
+
}
|
|
1337
|
+
const validFiles = /* @__PURE__ */ new Set();
|
|
1338
|
+
sections.forEach((section) => {
|
|
1339
|
+
const templatePath = resolveTemplate(section.name, addonOptions);
|
|
1340
|
+
if (!templatePath || !fs2__default.existsSync(templatePath)) {
|
|
1341
|
+
logger3.warn(`Could not find template for section: ${section.name}`);
|
|
1342
|
+
return;
|
|
1343
|
+
}
|
|
1344
|
+
try {
|
|
1345
|
+
const templateContent = fs2__default.readFileSync(templatePath, "utf-8");
|
|
1346
|
+
let newContent = templateContent.replace(
|
|
1347
|
+
/^\s*<Meta\s+title="[^"]*"\s*\/>/m,
|
|
1348
|
+
`<Meta title="${section.path}" />`
|
|
1349
|
+
);
|
|
1350
|
+
if (!newContent.match(/^export\s+(const|function|class)/m)) {
|
|
1351
|
+
const lines = newContent.split("\n");
|
|
1352
|
+
let lastImportIndex = -1;
|
|
1353
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1354
|
+
if (lines[i].trim().startsWith("import ")) {
|
|
1355
|
+
lastImportIndex = i;
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
if (lastImportIndex !== -1) {
|
|
1359
|
+
lines.splice(
|
|
1360
|
+
lastImportIndex + 1,
|
|
1361
|
+
0,
|
|
1362
|
+
"",
|
|
1363
|
+
"// Required for Storybook indexer",
|
|
1364
|
+
"export const __ignore = {};",
|
|
1365
|
+
""
|
|
1366
|
+
);
|
|
1367
|
+
newContent = lines.join("\n");
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
const cleanName = section.name.replace(/[^a-zA-Z0-9]/g, "");
|
|
1371
|
+
const filename = `${cleanName}.mdx`;
|
|
1372
|
+
const filePath = path2.join(sectionsDir, filename);
|
|
1373
|
+
fs2__default.writeFileSync(filePath, newContent);
|
|
1374
|
+
validFiles.add(filename);
|
|
1375
|
+
generatedStories.push(filePath);
|
|
1376
|
+
} catch (error) {
|
|
1377
|
+
logger3.error(`Failed to generate section MDX for ${section.name}`, error);
|
|
1378
|
+
}
|
|
1379
|
+
});
|
|
1380
|
+
if (fs2__default.existsSync(sectionsDir)) {
|
|
1381
|
+
try {
|
|
1382
|
+
const files = fs2__default.readdirSync(sectionsDir);
|
|
1383
|
+
files.forEach((file) => {
|
|
1384
|
+
if (file.endsWith(".mdx") && !validFiles.has(file)) {
|
|
1385
|
+
fs2__default.unlinkSync(path2.join(sectionsDir, file));
|
|
1386
|
+
}
|
|
1387
|
+
});
|
|
1388
|
+
} catch (e) {
|
|
1389
|
+
logger3.warn("Failed to cleanup orphaned section files", e);
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
return generatedStories;
|
|
1393
|
+
}
|
|
1295
1394
|
|
|
1296
1395
|
// node_modules/glob/node_modules/minimatch/dist/esm/index.js
|
|
1297
1396
|
var import_brace_expansion = __toESM(require_brace_expansion());
|
|
@@ -1964,11 +2063,11 @@ var qmarksTestNoExtDot = ([$0]) => {
|
|
|
1964
2063
|
return (f) => f.length === len && f !== "." && f !== "..";
|
|
1965
2064
|
};
|
|
1966
2065
|
var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
1967
|
-
var
|
|
2066
|
+
var path5 = {
|
|
1968
2067
|
win32: { sep: "\\" },
|
|
1969
2068
|
posix: { sep: "/" }
|
|
1970
2069
|
};
|
|
1971
|
-
var sep = defaultPlatform === "win32" ?
|
|
2070
|
+
var sep = defaultPlatform === "win32" ? path5.win32.sep : path5.posix.sep;
|
|
1972
2071
|
minimatch.sep = sep;
|
|
1973
2072
|
var GLOBSTAR = Symbol("globstar **");
|
|
1974
2073
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
@@ -5127,12 +5226,12 @@ var PathBase = class {
|
|
|
5127
5226
|
/**
|
|
5128
5227
|
* Get the Path object referenced by the string path, resolved from this Path
|
|
5129
5228
|
*/
|
|
5130
|
-
resolve(
|
|
5131
|
-
if (!
|
|
5229
|
+
resolve(path9) {
|
|
5230
|
+
if (!path9) {
|
|
5132
5231
|
return this;
|
|
5133
5232
|
}
|
|
5134
|
-
const rootPath = this.getRootString(
|
|
5135
|
-
const dir =
|
|
5233
|
+
const rootPath = this.getRootString(path9);
|
|
5234
|
+
const dir = path9.substring(rootPath.length);
|
|
5136
5235
|
const dirParts = dir.split(this.splitSep);
|
|
5137
5236
|
const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
|
|
5138
5237
|
return result;
|
|
@@ -5884,8 +5983,8 @@ var PathWin32 = class _PathWin32 extends PathBase {
|
|
|
5884
5983
|
/**
|
|
5885
5984
|
* @internal
|
|
5886
5985
|
*/
|
|
5887
|
-
getRootString(
|
|
5888
|
-
return win32.parse(
|
|
5986
|
+
getRootString(path9) {
|
|
5987
|
+
return win32.parse(path9).root;
|
|
5889
5988
|
}
|
|
5890
5989
|
/**
|
|
5891
5990
|
* @internal
|
|
@@ -5931,8 +6030,8 @@ var PathPosix = class _PathPosix extends PathBase {
|
|
|
5931
6030
|
/**
|
|
5932
6031
|
* @internal
|
|
5933
6032
|
*/
|
|
5934
|
-
getRootString(
|
|
5935
|
-
return
|
|
6033
|
+
getRootString(path9) {
|
|
6034
|
+
return path9.startsWith("/") ? "/" : "";
|
|
5936
6035
|
}
|
|
5937
6036
|
/**
|
|
5938
6037
|
* @internal
|
|
@@ -5981,8 +6080,8 @@ var PathScurryBase = class {
|
|
|
5981
6080
|
*
|
|
5982
6081
|
* @internal
|
|
5983
6082
|
*/
|
|
5984
|
-
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs:
|
|
5985
|
-
this.#fs = fsFromOption(
|
|
6083
|
+
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs4 = defaultFS } = {}) {
|
|
6084
|
+
this.#fs = fsFromOption(fs4);
|
|
5986
6085
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
|
5987
6086
|
cwd = fileURLToPath(cwd);
|
|
5988
6087
|
}
|
|
@@ -6021,11 +6120,11 @@ var PathScurryBase = class {
|
|
|
6021
6120
|
/**
|
|
6022
6121
|
* Get the depth of a provided path, string, or the cwd
|
|
6023
6122
|
*/
|
|
6024
|
-
depth(
|
|
6025
|
-
if (typeof
|
|
6026
|
-
|
|
6123
|
+
depth(path9 = this.cwd) {
|
|
6124
|
+
if (typeof path9 === "string") {
|
|
6125
|
+
path9 = this.cwd.resolve(path9);
|
|
6027
6126
|
}
|
|
6028
|
-
return
|
|
6127
|
+
return path9.depth();
|
|
6029
6128
|
}
|
|
6030
6129
|
/**
|
|
6031
6130
|
* Return the cache of child entries. Exposed so subclasses can create
|
|
@@ -6512,9 +6611,9 @@ var PathScurryBase = class {
|
|
|
6512
6611
|
process2();
|
|
6513
6612
|
return results;
|
|
6514
6613
|
}
|
|
6515
|
-
chdir(
|
|
6614
|
+
chdir(path9 = this.cwd) {
|
|
6516
6615
|
const oldCwd = this.cwd;
|
|
6517
|
-
this.cwd = typeof
|
|
6616
|
+
this.cwd = typeof path9 === "string" ? this.cwd.resolve(path9) : path9;
|
|
6518
6617
|
this.cwd[setAsCwd](oldCwd);
|
|
6519
6618
|
}
|
|
6520
6619
|
};
|
|
@@ -6540,8 +6639,8 @@ var PathScurryWin32 = class extends PathScurryBase {
|
|
|
6540
6639
|
/**
|
|
6541
6640
|
* @internal
|
|
6542
6641
|
*/
|
|
6543
|
-
newRoot(
|
|
6544
|
-
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
6642
|
+
newRoot(fs4) {
|
|
6643
|
+
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs4 });
|
|
6545
6644
|
}
|
|
6546
6645
|
/**
|
|
6547
6646
|
* Return true if the provided path string is an absolute path
|
|
@@ -6569,8 +6668,8 @@ var PathScurryPosix = class extends PathScurryBase {
|
|
|
6569
6668
|
/**
|
|
6570
6669
|
* @internal
|
|
6571
6670
|
*/
|
|
6572
|
-
newRoot(
|
|
6573
|
-
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
6671
|
+
newRoot(fs4) {
|
|
6672
|
+
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs4 });
|
|
6574
6673
|
}
|
|
6575
6674
|
/**
|
|
6576
6675
|
* Return true if the provided path string is an absolute path
|
|
@@ -6870,8 +6969,8 @@ var MatchRecord = class {
|
|
|
6870
6969
|
}
|
|
6871
6970
|
// match, absolute, ifdir
|
|
6872
6971
|
entries() {
|
|
6873
|
-
return [...this.store.entries()].map(([
|
|
6874
|
-
|
|
6972
|
+
return [...this.store.entries()].map(([path9, n]) => [
|
|
6973
|
+
path9,
|
|
6875
6974
|
!!(n & 2),
|
|
6876
6975
|
!!(n & 1)
|
|
6877
6976
|
]);
|
|
@@ -7076,9 +7175,9 @@ var GlobUtil = class {
|
|
|
7076
7175
|
signal;
|
|
7077
7176
|
maxDepth;
|
|
7078
7177
|
includeChildMatches;
|
|
7079
|
-
constructor(patterns,
|
|
7178
|
+
constructor(patterns, path9, opts) {
|
|
7080
7179
|
this.patterns = patterns;
|
|
7081
|
-
this.path =
|
|
7180
|
+
this.path = path9;
|
|
7082
7181
|
this.opts = opts;
|
|
7083
7182
|
this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
|
|
7084
7183
|
this.includeChildMatches = opts.includeChildMatches !== false;
|
|
@@ -7097,11 +7196,11 @@ var GlobUtil = class {
|
|
|
7097
7196
|
});
|
|
7098
7197
|
}
|
|
7099
7198
|
}
|
|
7100
|
-
#ignored(
|
|
7101
|
-
return this.seen.has(
|
|
7199
|
+
#ignored(path9) {
|
|
7200
|
+
return this.seen.has(path9) || !!this.#ignore?.ignored?.(path9);
|
|
7102
7201
|
}
|
|
7103
|
-
#childrenIgnored(
|
|
7104
|
-
return !!this.#ignore?.childrenIgnored?.(
|
|
7202
|
+
#childrenIgnored(path9) {
|
|
7203
|
+
return !!this.#ignore?.childrenIgnored?.(path9);
|
|
7105
7204
|
}
|
|
7106
7205
|
// backpressure mechanism
|
|
7107
7206
|
pause() {
|
|
@@ -7316,8 +7415,8 @@ var GlobUtil = class {
|
|
|
7316
7415
|
};
|
|
7317
7416
|
var GlobWalker = class extends GlobUtil {
|
|
7318
7417
|
matches = /* @__PURE__ */ new Set();
|
|
7319
|
-
constructor(patterns,
|
|
7320
|
-
super(patterns,
|
|
7418
|
+
constructor(patterns, path9, opts) {
|
|
7419
|
+
super(patterns, path9, opts);
|
|
7321
7420
|
}
|
|
7322
7421
|
matchEmit(e) {
|
|
7323
7422
|
this.matches.add(e);
|
|
@@ -7354,8 +7453,8 @@ var GlobWalker = class extends GlobUtil {
|
|
|
7354
7453
|
};
|
|
7355
7454
|
var GlobStream = class extends GlobUtil {
|
|
7356
7455
|
results;
|
|
7357
|
-
constructor(patterns,
|
|
7358
|
-
super(patterns,
|
|
7456
|
+
constructor(patterns, path9, opts) {
|
|
7457
|
+
super(patterns, path9, opts);
|
|
7359
7458
|
this.results = new Minipass({
|
|
7360
7459
|
signal: this.signal,
|
|
7361
7460
|
objectMode: true
|
|
@@ -7844,9 +7943,15 @@ function createAssetManager(groups) {
|
|
|
7844
7943
|
}
|
|
7845
7944
|
|
|
7846
7945
|
// src/addon/unplugin.ts
|
|
7847
|
-
var
|
|
7946
|
+
var logger4 = new Logger("unplugin");
|
|
7848
7947
|
var unplugin = createUnplugin((options) => {
|
|
7849
7948
|
const assetManager = options.assetOptions?.groups && options.assetOptions.groups.length > 0 ? createAssetManager(options.assetOptions.groups) : void 0;
|
|
7949
|
+
const sectionPathMap = /* @__PURE__ */ new Map();
|
|
7950
|
+
if (options.addonOptions?.sections) {
|
|
7951
|
+
options.addonOptions.sections.forEach((section) => {
|
|
7952
|
+
sectionPathMap.set(section.name.toLowerCase(), section.path);
|
|
7953
|
+
});
|
|
7954
|
+
}
|
|
7850
7955
|
return {
|
|
7851
7956
|
name: "unplugin-design-system-docs",
|
|
7852
7957
|
enforce: "pre",
|
|
@@ -7866,12 +7971,15 @@ var unplugin = createUnplugin((options) => {
|
|
|
7866
7971
|
loadInclude(id) {
|
|
7867
7972
|
return id === DESIGN_SYSTEM_DATA_ID || id === ASSET_DATA_ID || id.startsWith(ASSET_GROUP_ID_PREFIX);
|
|
7868
7973
|
},
|
|
7974
|
+
transformInclude(id) {
|
|
7975
|
+
return id.includes("/templates/") && id.endsWith(".mdx");
|
|
7976
|
+
},
|
|
7869
7977
|
async load(id) {
|
|
7870
7978
|
try {
|
|
7871
7979
|
if (id === DESIGN_SYSTEM_DATA_ID) {
|
|
7872
7980
|
if (!options.configPath) {
|
|
7873
7981
|
const errorMsg = "No Tailwind config path found. Cannot load theme data. This is likely a bug in the addon setup.";
|
|
7874
|
-
|
|
7982
|
+
logger4.error(errorMsg);
|
|
7875
7983
|
throw new Error(errorMsg);
|
|
7876
7984
|
}
|
|
7877
7985
|
if (this.addWatchFile && options.configPath) {
|
|
@@ -7900,24 +8008,56 @@ export const borderRadius = ${data.borderRadius ? JSON.stringify(data.borderRadi
|
|
|
7900
8008
|
}
|
|
7901
8009
|
if (id.startsWith(ASSET_GROUP_ID_PREFIX)) {
|
|
7902
8010
|
const groupName = id.slice(ASSET_GROUP_ID_PREFIX.length);
|
|
7903
|
-
|
|
8011
|
+
logger4.info(`Loading asset group data: ${groupName}`);
|
|
7904
8012
|
if (!assetManager) {
|
|
7905
|
-
|
|
8013
|
+
logger4.warn(`No asset manager available for group: ${groupName}`);
|
|
7906
8014
|
return "export default {}";
|
|
7907
8015
|
}
|
|
7908
8016
|
const group = await assetManager.getGroup(groupName);
|
|
7909
8017
|
if (!group) {
|
|
7910
|
-
|
|
8018
|
+
logger4.warn(`Asset group not found: ${groupName}`);
|
|
7911
8019
|
return "export default {}";
|
|
7912
8020
|
}
|
|
7913
8021
|
return `export default ${JSON.stringify(group)}`;
|
|
7914
8022
|
}
|
|
7915
8023
|
} catch (error) {
|
|
7916
8024
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
7917
|
-
|
|
8025
|
+
logger4.error(`Failed to load virtual module: ${id}`, error);
|
|
7918
8026
|
throw new Error(`[storybook-addon-design-system-docs] ${errorMessage}`);
|
|
7919
8027
|
}
|
|
7920
8028
|
},
|
|
8029
|
+
transform(code, id) {
|
|
8030
|
+
if (!id.includes("/templates/") || !id.endsWith(".mdx")) {
|
|
8031
|
+
return null;
|
|
8032
|
+
}
|
|
8033
|
+
logger4.debug(`Transform called for template: ${id}`);
|
|
8034
|
+
const match2 = id.match(/\/templates\/([^/]+)\.mdx$/);
|
|
8035
|
+
if (!match2) {
|
|
8036
|
+
logger4.debug(`No match found for template path pattern in: ${id}`);
|
|
8037
|
+
return null;
|
|
8038
|
+
}
|
|
8039
|
+
const templateName = match2[1];
|
|
8040
|
+
const sectionName = templateName.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
8041
|
+
logger4.debug(`Template: ${templateName}, Section: ${sectionName}`);
|
|
8042
|
+
const configuredPath = sectionPathMap.get(sectionName.toLowerCase());
|
|
8043
|
+
if (!configuredPath) {
|
|
8044
|
+
logger4.debug(
|
|
8045
|
+
`No configured path found for section: ${sectionName.toLowerCase()}`
|
|
8046
|
+
);
|
|
8047
|
+
logger4.debug(
|
|
8048
|
+
`Available sections: ${Array.from(sectionPathMap.keys()).join(", ")}`
|
|
8049
|
+
);
|
|
8050
|
+
return null;
|
|
8051
|
+
}
|
|
8052
|
+
logger4.info(
|
|
8053
|
+
`Replacing Meta title in ${templateName}.mdx with path: ${configuredPath}`
|
|
8054
|
+
);
|
|
8055
|
+
const transformedCode = code.replace(
|
|
8056
|
+
/(<Meta\s+title=")[^"]*(")/,
|
|
8057
|
+
`$1${configuredPath}$2`
|
|
8058
|
+
);
|
|
8059
|
+
return { code: transformedCode };
|
|
8060
|
+
},
|
|
7921
8061
|
vite: {
|
|
7922
8062
|
handleHotUpdate({ file, server }) {
|
|
7923
8063
|
if (isTwConfigPath(file) || isTwCssPath(file)) {
|
|
@@ -7930,7 +8070,7 @@ export const borderRadius = ${data.borderRadius ? JSON.stringify(data.borderRadi
|
|
|
7930
8070
|
if (!assetManager) return;
|
|
7931
8071
|
const matchingGroup = assetManager.findMatchingGroup(filePath);
|
|
7932
8072
|
if (!matchingGroup) return;
|
|
7933
|
-
|
|
8073
|
+
logger4.info(`Asset changed in group ${matchingGroup}: ${filePath}`);
|
|
7934
8074
|
assetManager.invalidateGroup(matchingGroup);
|
|
7935
8075
|
const groupModule = server2.moduleGraph.getModuleById(
|
|
7936
8076
|
ASSET_GROUP_ID_PREFIX + matchingGroup
|
|
@@ -7948,10 +8088,10 @@ export const borderRadius = ${data.borderRadius ? JSON.stringify(data.borderRadi
|
|
|
7948
8088
|
var { vite } = unplugin;
|
|
7949
8089
|
|
|
7950
8090
|
// src/addon/preset.ts
|
|
7951
|
-
var
|
|
8091
|
+
var logger5 = new Logger("Preset");
|
|
7952
8092
|
function createAddonOptions(options) {
|
|
7953
8093
|
if (!options.tailwindConfig) {
|
|
7954
|
-
|
|
8094
|
+
logger5.error("tailwindConfig missing from options:", options);
|
|
7955
8095
|
throw new Error(
|
|
7956
8096
|
'tailwindConfig option is required. Please specify the path to your Tailwind config file. Example: { tailwindConfig: "../tailwind.config.js" }'
|
|
7957
8097
|
);
|
|
@@ -8013,14 +8153,14 @@ var staticDirs = async (existingStaticDirs, options) => {
|
|
|
8013
8153
|
}
|
|
8014
8154
|
});
|
|
8015
8155
|
if (newStaticDirs.length > 0) {
|
|
8016
|
-
|
|
8156
|
+
logger5.debug("Registering asset directories as staticDirs:", {
|
|
8017
8157
|
staticDirs: newStaticDirs
|
|
8018
8158
|
});
|
|
8019
8159
|
return [...existingStaticDirs, ...newStaticDirs];
|
|
8020
8160
|
}
|
|
8021
8161
|
return existingStaticDirs;
|
|
8022
8162
|
} catch (error) {
|
|
8023
|
-
|
|
8163
|
+
logger5.error("Failed to configure static directories", error);
|
|
8024
8164
|
return existingStaticDirs;
|
|
8025
8165
|
}
|
|
8026
8166
|
};
|
|
@@ -8028,18 +8168,12 @@ var stories = async (entry = [], options) => {
|
|
|
8028
8168
|
try {
|
|
8029
8169
|
const addonOptions = createAddonOptions(options);
|
|
8030
8170
|
const newStories = [];
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
} else {
|
|
8038
|
-
addonOptions.sections.forEach((section) => {
|
|
8039
|
-
const templatePath = resolveTemplate(section.name, addonOptions);
|
|
8040
|
-
newStories.push(templatePath);
|
|
8041
|
-
});
|
|
8042
|
-
}
|
|
8171
|
+
const sectionStories = generateSectionStories({
|
|
8172
|
+
configDir: options.configDir,
|
|
8173
|
+
sections: addonOptions.forceSingleDoc ? [addonOptions.forceSingleDoc] : addonOptions.sections,
|
|
8174
|
+
addonOptions
|
|
8175
|
+
});
|
|
8176
|
+
newStories.push(...sectionStories);
|
|
8043
8177
|
const assetStories = generateAssetStories({
|
|
8044
8178
|
configDir: options.configDir,
|
|
8045
8179
|
assets: options.assets,
|
|
@@ -8048,7 +8182,7 @@ var stories = async (entry = [], options) => {
|
|
|
8048
8182
|
newStories.push(...assetStories);
|
|
8049
8183
|
return [...entry, ...newStories];
|
|
8050
8184
|
} catch (error) {
|
|
8051
|
-
|
|
8185
|
+
logger5.error("Failed to inject config into stories", error);
|
|
8052
8186
|
return entry;
|
|
8053
8187
|
}
|
|
8054
8188
|
};
|