ui-strings 0.1.3 → 0.1.4
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/cli.js +30 -11
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -503,17 +503,30 @@ var surfaceFor = (classified, file) => {
|
|
|
503
503
|
}
|
|
504
504
|
return "visible";
|
|
505
505
|
};
|
|
506
|
-
var
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
506
|
+
var sharedPrefixLength = (files) => {
|
|
507
|
+
const first = files[0];
|
|
508
|
+
if (first === undefined) {
|
|
509
|
+
return 0;
|
|
510
|
+
}
|
|
511
|
+
let shared = first.length - 1;
|
|
512
|
+
for (const parts of files) {
|
|
513
|
+
const limit = Math.min(shared, parts.length - 1);
|
|
514
|
+
let i = 0;
|
|
515
|
+
while (i < limit && parts[i] === first[i]) {
|
|
516
|
+
i += 1;
|
|
517
|
+
}
|
|
518
|
+
shared = i;
|
|
512
519
|
}
|
|
513
|
-
const
|
|
514
|
-
|
|
515
|
-
|
|
520
|
+
const boundary = first.slice(0, shared).findIndex((segment) => segment === "src" || segment === "app");
|
|
521
|
+
return boundary === -1 ? shared : boundary;
|
|
522
|
+
};
|
|
523
|
+
var groupFor = (parts, hasAppDir) => {
|
|
524
|
+
const rest = parts[0] === "src" ? parts.slice(1) : parts;
|
|
525
|
+
if (hasAppDir && rest[0] === "app") {
|
|
526
|
+
const segments = rest.slice(1, -1).filter((segment) => segment !== "_dependencies" && !(segment.startsWith("(") && segment.endsWith(")")));
|
|
527
|
+
return `/${segments.slice(0, 2).join("/")}`;
|
|
516
528
|
}
|
|
529
|
+
const dirs = rest.slice(0, -1);
|
|
517
530
|
return dirs.slice(0, 2).join("/") || "(root)";
|
|
518
531
|
};
|
|
519
532
|
var DEFAULT_EXCLUDES = [
|
|
@@ -536,7 +549,13 @@ var scanProject = (options) => {
|
|
|
536
549
|
`${projectDir}/${srcGlob}`,
|
|
537
550
|
...excludes.map((glob) => `!${projectDir}/${glob}`)
|
|
538
551
|
]);
|
|
539
|
-
const
|
|
552
|
+
const relativeParts = sourceFiles.map((file) => relative(projectDir, file.getFilePath()).split(sep));
|
|
553
|
+
const prefixLength = sharedPrefixLength(relativeParts);
|
|
554
|
+
const hasAppDir = relativeParts.some((parts) => {
|
|
555
|
+
const stripped = parts.slice(prefixLength);
|
|
556
|
+
const rest = stripped[0] === "src" ? stripped.slice(1) : stripped;
|
|
557
|
+
return rest[0] === "app" && rest.length > 1;
|
|
558
|
+
});
|
|
540
559
|
const renderSites = new Map;
|
|
541
560
|
for (const sourceFile of sourceFiles) {
|
|
542
561
|
const relativeFile = relative(projectDir, sourceFile.getFilePath());
|
|
@@ -572,7 +591,7 @@ var scanProject = (options) => {
|
|
|
572
591
|
const entries = [];
|
|
573
592
|
for (const sourceFile of sourceFiles) {
|
|
574
593
|
const relativeFile = relative(projectDir, sourceFile.getFilePath());
|
|
575
|
-
const group = groupFor(relativeFile, hasAppDir);
|
|
594
|
+
const group = groupFor(relativeFile.split(sep).slice(prefixLength), hasAppDir);
|
|
576
595
|
const consumed = new Set;
|
|
577
596
|
const nodeKey = (node) => `${node.getPos()}:${node.getEnd()}`;
|
|
578
597
|
const push = (text, node, classified) => {
|