modality-kit 0.17.0 → 0.17.3
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/index.js +19 -343
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __returnValue = (v) => v;
|
|
3
4
|
function __exportSetter(name, newValue) {
|
|
@@ -12,13 +13,7 @@ var __export = (target, all) => {
|
|
|
12
13
|
set: __exportSetter.bind(all, name)
|
|
13
14
|
});
|
|
14
15
|
};
|
|
15
|
-
var __require = /* @__PURE__ */ (
|
|
16
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
17
|
-
}) : x)(function(x) {
|
|
18
|
-
if (typeof require !== "undefined")
|
|
19
|
-
return require.apply(this, arguments);
|
|
20
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
21
|
-
});
|
|
16
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
22
17
|
|
|
23
18
|
// src/ErrorCode.ts
|
|
24
19
|
class ErrorCode extends Error {
|
|
@@ -15598,329 +15593,8 @@ class SimpleCache {
|
|
|
15598
15593
|
// src/isTestEnvironment.ts
|
|
15599
15594
|
var isTestEnvironment = globalThis.Bun?.main?.includes?.("test");
|
|
15600
15595
|
// src/recursiveScanForFiles.ts
|
|
15601
|
-
|
|
15602
|
-
|
|
15603
|
-
// node:path
|
|
15604
|
-
function assertPath(path) {
|
|
15605
|
-
if (typeof path !== "string")
|
|
15606
|
-
throw TypeError("Path must be a string. Received " + JSON.stringify(path));
|
|
15607
|
-
}
|
|
15608
|
-
function normalizeStringPosix(path, allowAboveRoot) {
|
|
15609
|
-
var res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, code;
|
|
15610
|
-
for (var i = 0;i <= path.length; ++i) {
|
|
15611
|
-
if (i < path.length)
|
|
15612
|
-
code = path.charCodeAt(i);
|
|
15613
|
-
else if (code === 47)
|
|
15614
|
-
break;
|
|
15615
|
-
else
|
|
15616
|
-
code = 47;
|
|
15617
|
-
if (code === 47) {
|
|
15618
|
-
if (lastSlash === i - 1 || dots === 1)
|
|
15619
|
-
;
|
|
15620
|
-
else if (lastSlash !== i - 1 && dots === 2) {
|
|
15621
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 || res.charCodeAt(res.length - 2) !== 46) {
|
|
15622
|
-
if (res.length > 2) {
|
|
15623
|
-
var lastSlashIndex = res.lastIndexOf("/");
|
|
15624
|
-
if (lastSlashIndex !== res.length - 1) {
|
|
15625
|
-
if (lastSlashIndex === -1)
|
|
15626
|
-
res = "", lastSegmentLength = 0;
|
|
15627
|
-
else
|
|
15628
|
-
res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
15629
|
-
lastSlash = i, dots = 0;
|
|
15630
|
-
continue;
|
|
15631
|
-
}
|
|
15632
|
-
} else if (res.length === 2 || res.length === 1) {
|
|
15633
|
-
res = "", lastSegmentLength = 0, lastSlash = i, dots = 0;
|
|
15634
|
-
continue;
|
|
15635
|
-
}
|
|
15636
|
-
}
|
|
15637
|
-
if (allowAboveRoot) {
|
|
15638
|
-
if (res.length > 0)
|
|
15639
|
-
res += "/..";
|
|
15640
|
-
else
|
|
15641
|
-
res = "..";
|
|
15642
|
-
lastSegmentLength = 2;
|
|
15643
|
-
}
|
|
15644
|
-
} else {
|
|
15645
|
-
if (res.length > 0)
|
|
15646
|
-
res += "/" + path.slice(lastSlash + 1, i);
|
|
15647
|
-
else
|
|
15648
|
-
res = path.slice(lastSlash + 1, i);
|
|
15649
|
-
lastSegmentLength = i - lastSlash - 1;
|
|
15650
|
-
}
|
|
15651
|
-
lastSlash = i, dots = 0;
|
|
15652
|
-
} else if (code === 46 && dots !== -1)
|
|
15653
|
-
++dots;
|
|
15654
|
-
else
|
|
15655
|
-
dots = -1;
|
|
15656
|
-
}
|
|
15657
|
-
return res;
|
|
15658
|
-
}
|
|
15659
|
-
function _format(sep, pathObject) {
|
|
15660
|
-
var dir = pathObject.dir || pathObject.root, base = pathObject.base || (pathObject.name || "") + (pathObject.ext || "");
|
|
15661
|
-
if (!dir)
|
|
15662
|
-
return base;
|
|
15663
|
-
if (dir === pathObject.root)
|
|
15664
|
-
return dir + base;
|
|
15665
|
-
return dir + sep + base;
|
|
15666
|
-
}
|
|
15667
|
-
function resolve() {
|
|
15668
|
-
var resolvedPath = "", resolvedAbsolute = false, cwd;
|
|
15669
|
-
for (var i = arguments.length - 1;i >= -1 && !resolvedAbsolute; i--) {
|
|
15670
|
-
var path;
|
|
15671
|
-
if (i >= 0)
|
|
15672
|
-
path = arguments[i];
|
|
15673
|
-
else {
|
|
15674
|
-
if (cwd === undefined)
|
|
15675
|
-
cwd = process.cwd();
|
|
15676
|
-
path = cwd;
|
|
15677
|
-
}
|
|
15678
|
-
if (assertPath(path), path.length === 0)
|
|
15679
|
-
continue;
|
|
15680
|
-
resolvedPath = path + "/" + resolvedPath, resolvedAbsolute = path.charCodeAt(0) === 47;
|
|
15681
|
-
}
|
|
15682
|
-
if (resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute), resolvedAbsolute)
|
|
15683
|
-
if (resolvedPath.length > 0)
|
|
15684
|
-
return "/" + resolvedPath;
|
|
15685
|
-
else
|
|
15686
|
-
return "/";
|
|
15687
|
-
else if (resolvedPath.length > 0)
|
|
15688
|
-
return resolvedPath;
|
|
15689
|
-
else
|
|
15690
|
-
return ".";
|
|
15691
|
-
}
|
|
15692
|
-
function normalize(path) {
|
|
15693
|
-
if (assertPath(path), path.length === 0)
|
|
15694
|
-
return ".";
|
|
15695
|
-
var isAbsolute = path.charCodeAt(0) === 47, trailingSeparator = path.charCodeAt(path.length - 1) === 47;
|
|
15696
|
-
if (path = normalizeStringPosix(path, !isAbsolute), path.length === 0 && !isAbsolute)
|
|
15697
|
-
path = ".";
|
|
15698
|
-
if (path.length > 0 && trailingSeparator)
|
|
15699
|
-
path += "/";
|
|
15700
|
-
if (isAbsolute)
|
|
15701
|
-
return "/" + path;
|
|
15702
|
-
return path;
|
|
15703
|
-
}
|
|
15704
|
-
function isAbsolute(path) {
|
|
15705
|
-
return assertPath(path), path.length > 0 && path.charCodeAt(0) === 47;
|
|
15706
|
-
}
|
|
15707
|
-
function join() {
|
|
15708
|
-
if (arguments.length === 0)
|
|
15709
|
-
return ".";
|
|
15710
|
-
var joined;
|
|
15711
|
-
for (var i = 0;i < arguments.length; ++i) {
|
|
15712
|
-
var arg = arguments[i];
|
|
15713
|
-
if (assertPath(arg), arg.length > 0)
|
|
15714
|
-
if (joined === undefined)
|
|
15715
|
-
joined = arg;
|
|
15716
|
-
else
|
|
15717
|
-
joined += "/" + arg;
|
|
15718
|
-
}
|
|
15719
|
-
if (joined === undefined)
|
|
15720
|
-
return ".";
|
|
15721
|
-
return normalize(joined);
|
|
15722
|
-
}
|
|
15723
|
-
function relative(from, to) {
|
|
15724
|
-
if (assertPath(from), assertPath(to), from === to)
|
|
15725
|
-
return "";
|
|
15726
|
-
if (from = resolve(from), to = resolve(to), from === to)
|
|
15727
|
-
return "";
|
|
15728
|
-
var fromStart = 1;
|
|
15729
|
-
for (;fromStart < from.length; ++fromStart)
|
|
15730
|
-
if (from.charCodeAt(fromStart) !== 47)
|
|
15731
|
-
break;
|
|
15732
|
-
var fromEnd = from.length, fromLen = fromEnd - fromStart, toStart = 1;
|
|
15733
|
-
for (;toStart < to.length; ++toStart)
|
|
15734
|
-
if (to.charCodeAt(toStart) !== 47)
|
|
15735
|
-
break;
|
|
15736
|
-
var toEnd = to.length, toLen = toEnd - toStart, length = fromLen < toLen ? fromLen : toLen, lastCommonSep = -1, i = 0;
|
|
15737
|
-
for (;i <= length; ++i) {
|
|
15738
|
-
if (i === length) {
|
|
15739
|
-
if (toLen > length) {
|
|
15740
|
-
if (to.charCodeAt(toStart + i) === 47)
|
|
15741
|
-
return to.slice(toStart + i + 1);
|
|
15742
|
-
else if (i === 0)
|
|
15743
|
-
return to.slice(toStart + i);
|
|
15744
|
-
} else if (fromLen > length) {
|
|
15745
|
-
if (from.charCodeAt(fromStart + i) === 47)
|
|
15746
|
-
lastCommonSep = i;
|
|
15747
|
-
else if (i === 0)
|
|
15748
|
-
lastCommonSep = 0;
|
|
15749
|
-
}
|
|
15750
|
-
break;
|
|
15751
|
-
}
|
|
15752
|
-
var fromCode = from.charCodeAt(fromStart + i), toCode = to.charCodeAt(toStart + i);
|
|
15753
|
-
if (fromCode !== toCode)
|
|
15754
|
-
break;
|
|
15755
|
-
else if (fromCode === 47)
|
|
15756
|
-
lastCommonSep = i;
|
|
15757
|
-
}
|
|
15758
|
-
var out = "";
|
|
15759
|
-
for (i = fromStart + lastCommonSep + 1;i <= fromEnd; ++i)
|
|
15760
|
-
if (i === fromEnd || from.charCodeAt(i) === 47)
|
|
15761
|
-
if (out.length === 0)
|
|
15762
|
-
out += "..";
|
|
15763
|
-
else
|
|
15764
|
-
out += "/..";
|
|
15765
|
-
if (out.length > 0)
|
|
15766
|
-
return out + to.slice(toStart + lastCommonSep);
|
|
15767
|
-
else {
|
|
15768
|
-
if (toStart += lastCommonSep, to.charCodeAt(toStart) === 47)
|
|
15769
|
-
++toStart;
|
|
15770
|
-
return to.slice(toStart);
|
|
15771
|
-
}
|
|
15772
|
-
}
|
|
15773
|
-
function _makeLong(path) {
|
|
15774
|
-
return path;
|
|
15775
|
-
}
|
|
15776
|
-
function dirname(path) {
|
|
15777
|
-
if (assertPath(path), path.length === 0)
|
|
15778
|
-
return ".";
|
|
15779
|
-
var code = path.charCodeAt(0), hasRoot = code === 47, end = -1, matchedSlash = true;
|
|
15780
|
-
for (var i = path.length - 1;i >= 1; --i)
|
|
15781
|
-
if (code = path.charCodeAt(i), code === 47) {
|
|
15782
|
-
if (!matchedSlash) {
|
|
15783
|
-
end = i;
|
|
15784
|
-
break;
|
|
15785
|
-
}
|
|
15786
|
-
} else
|
|
15787
|
-
matchedSlash = false;
|
|
15788
|
-
if (end === -1)
|
|
15789
|
-
return hasRoot ? "/" : ".";
|
|
15790
|
-
if (hasRoot && end === 1)
|
|
15791
|
-
return "//";
|
|
15792
|
-
return path.slice(0, end);
|
|
15793
|
-
}
|
|
15794
|
-
function basename(path, ext) {
|
|
15795
|
-
if (ext !== undefined && typeof ext !== "string")
|
|
15796
|
-
throw TypeError('"ext" argument must be a string');
|
|
15797
|
-
assertPath(path);
|
|
15798
|
-
var start = 0, end = -1, matchedSlash = true, i;
|
|
15799
|
-
if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
|
|
15800
|
-
if (ext.length === path.length && ext === path)
|
|
15801
|
-
return "";
|
|
15802
|
-
var extIdx = ext.length - 1, firstNonSlashEnd = -1;
|
|
15803
|
-
for (i = path.length - 1;i >= 0; --i) {
|
|
15804
|
-
var code = path.charCodeAt(i);
|
|
15805
|
-
if (code === 47) {
|
|
15806
|
-
if (!matchedSlash) {
|
|
15807
|
-
start = i + 1;
|
|
15808
|
-
break;
|
|
15809
|
-
}
|
|
15810
|
-
} else {
|
|
15811
|
-
if (firstNonSlashEnd === -1)
|
|
15812
|
-
matchedSlash = false, firstNonSlashEnd = i + 1;
|
|
15813
|
-
if (extIdx >= 0)
|
|
15814
|
-
if (code === ext.charCodeAt(extIdx)) {
|
|
15815
|
-
if (--extIdx === -1)
|
|
15816
|
-
end = i;
|
|
15817
|
-
} else
|
|
15818
|
-
extIdx = -1, end = firstNonSlashEnd;
|
|
15819
|
-
}
|
|
15820
|
-
}
|
|
15821
|
-
if (start === end)
|
|
15822
|
-
end = firstNonSlashEnd;
|
|
15823
|
-
else if (end === -1)
|
|
15824
|
-
end = path.length;
|
|
15825
|
-
return path.slice(start, end);
|
|
15826
|
-
} else {
|
|
15827
|
-
for (i = path.length - 1;i >= 0; --i)
|
|
15828
|
-
if (path.charCodeAt(i) === 47) {
|
|
15829
|
-
if (!matchedSlash) {
|
|
15830
|
-
start = i + 1;
|
|
15831
|
-
break;
|
|
15832
|
-
}
|
|
15833
|
-
} else if (end === -1)
|
|
15834
|
-
matchedSlash = false, end = i + 1;
|
|
15835
|
-
if (end === -1)
|
|
15836
|
-
return "";
|
|
15837
|
-
return path.slice(start, end);
|
|
15838
|
-
}
|
|
15839
|
-
}
|
|
15840
|
-
function extname(path) {
|
|
15841
|
-
assertPath(path);
|
|
15842
|
-
var startDot = -1, startPart = 0, end = -1, matchedSlash = true, preDotState = 0;
|
|
15843
|
-
for (var i = path.length - 1;i >= 0; --i) {
|
|
15844
|
-
var code = path.charCodeAt(i);
|
|
15845
|
-
if (code === 47) {
|
|
15846
|
-
if (!matchedSlash) {
|
|
15847
|
-
startPart = i + 1;
|
|
15848
|
-
break;
|
|
15849
|
-
}
|
|
15850
|
-
continue;
|
|
15851
|
-
}
|
|
15852
|
-
if (end === -1)
|
|
15853
|
-
matchedSlash = false, end = i + 1;
|
|
15854
|
-
if (code === 46) {
|
|
15855
|
-
if (startDot === -1)
|
|
15856
|
-
startDot = i;
|
|
15857
|
-
else if (preDotState !== 1)
|
|
15858
|
-
preDotState = 1;
|
|
15859
|
-
} else if (startDot !== -1)
|
|
15860
|
-
preDotState = -1;
|
|
15861
|
-
}
|
|
15862
|
-
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)
|
|
15863
|
-
return "";
|
|
15864
|
-
return path.slice(startDot, end);
|
|
15865
|
-
}
|
|
15866
|
-
function format(pathObject) {
|
|
15867
|
-
if (pathObject === null || typeof pathObject !== "object")
|
|
15868
|
-
throw TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
|
|
15869
|
-
return _format("/", pathObject);
|
|
15870
|
-
}
|
|
15871
|
-
function parse5(path) {
|
|
15872
|
-
assertPath(path);
|
|
15873
|
-
var ret = { root: "", dir: "", base: "", ext: "", name: "" };
|
|
15874
|
-
if (path.length === 0)
|
|
15875
|
-
return ret;
|
|
15876
|
-
var code = path.charCodeAt(0), isAbsolute2 = code === 47, start;
|
|
15877
|
-
if (isAbsolute2)
|
|
15878
|
-
ret.root = "/", start = 1;
|
|
15879
|
-
else
|
|
15880
|
-
start = 0;
|
|
15881
|
-
var startDot = -1, startPart = 0, end = -1, matchedSlash = true, i = path.length - 1, preDotState = 0;
|
|
15882
|
-
for (;i >= start; --i) {
|
|
15883
|
-
if (code = path.charCodeAt(i), code === 47) {
|
|
15884
|
-
if (!matchedSlash) {
|
|
15885
|
-
startPart = i + 1;
|
|
15886
|
-
break;
|
|
15887
|
-
}
|
|
15888
|
-
continue;
|
|
15889
|
-
}
|
|
15890
|
-
if (end === -1)
|
|
15891
|
-
matchedSlash = false, end = i + 1;
|
|
15892
|
-
if (code === 46) {
|
|
15893
|
-
if (startDot === -1)
|
|
15894
|
-
startDot = i;
|
|
15895
|
-
else if (preDotState !== 1)
|
|
15896
|
-
preDotState = 1;
|
|
15897
|
-
} else if (startDot !== -1)
|
|
15898
|
-
preDotState = -1;
|
|
15899
|
-
}
|
|
15900
|
-
if (startDot === -1 || end === -1 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
15901
|
-
if (end !== -1)
|
|
15902
|
-
if (startPart === 0 && isAbsolute2)
|
|
15903
|
-
ret.base = ret.name = path.slice(1, end);
|
|
15904
|
-
else
|
|
15905
|
-
ret.base = ret.name = path.slice(startPart, end);
|
|
15906
|
-
} else {
|
|
15907
|
-
if (startPart === 0 && isAbsolute2)
|
|
15908
|
-
ret.name = path.slice(1, startDot), ret.base = path.slice(1, end);
|
|
15909
|
-
else
|
|
15910
|
-
ret.name = path.slice(startPart, startDot), ret.base = path.slice(startPart, end);
|
|
15911
|
-
ret.ext = path.slice(startDot, end);
|
|
15912
|
-
}
|
|
15913
|
-
if (startPart > 0)
|
|
15914
|
-
ret.dir = path.slice(0, startPart - 1);
|
|
15915
|
-
else if (isAbsolute2)
|
|
15916
|
-
ret.dir = "/";
|
|
15917
|
-
return ret;
|
|
15918
|
-
}
|
|
15919
|
-
var sep = "/";
|
|
15920
|
-
var delimiter = ":";
|
|
15921
|
-
var posix = ((p) => (p.posix = p, p))({ resolve, normalize, isAbsolute, join, relative, _makeLong, dirname, basename, extname, format, parse: parse5, sep, delimiter, win32: null, posix: null });
|
|
15922
|
-
|
|
15923
|
-
// src/recursiveScanForFiles.ts
|
|
15596
|
+
import { readdirSync, statSync } from "fs";
|
|
15597
|
+
import { join, extname } from "path";
|
|
15924
15598
|
function recursiveScanForFiles(baseDir, options) {
|
|
15925
15599
|
const files = [];
|
|
15926
15600
|
const {
|
|
@@ -15940,22 +15614,24 @@ function recursiveScanForFiles(baseDir, options) {
|
|
|
15940
15614
|
}
|
|
15941
15615
|
const fullPath = join(dir, entry);
|
|
15942
15616
|
const relPath = relativePath ? `${relativePath}/${entry}` : entry;
|
|
15943
|
-
|
|
15944
|
-
|
|
15945
|
-
if (
|
|
15946
|
-
|
|
15947
|
-
|
|
15948
|
-
|
|
15949
|
-
|
|
15950
|
-
|
|
15951
|
-
|
|
15952
|
-
|
|
15953
|
-
|
|
15617
|
+
const isDirectory = statSync(fullPath).isDirectory();
|
|
15618
|
+
if (isSearchingForTarget) {
|
|
15619
|
+
if (isDirectory) {
|
|
15620
|
+
scanDirectory(fullPath, relPath, entry !== targetFolderName);
|
|
15621
|
+
}
|
|
15622
|
+
} else if (isDirectory) {
|
|
15623
|
+
if (searchInSubfolders) {
|
|
15624
|
+
scanDirectory(fullPath, relPath, false);
|
|
15625
|
+
}
|
|
15626
|
+
} else if ((!fileExtensions || extensionSet.has(extname(entry))) && fileNameFilter(entry)) {
|
|
15627
|
+
if (statSync(fullPath).isFile()) {
|
|
15954
15628
|
files.push({ filename: relPath, fullPath });
|
|
15955
15629
|
}
|
|
15956
|
-
}
|
|
15630
|
+
}
|
|
15957
15631
|
}
|
|
15958
|
-
} catch (e) {
|
|
15632
|
+
} catch (e) {
|
|
15633
|
+
console.error(e);
|
|
15634
|
+
}
|
|
15959
15635
|
}
|
|
15960
15636
|
scanDirectory(baseDir, "", true);
|
|
15961
15637
|
return files.sort((a, b) => a.filename.localeCompare(b.filename));
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.17.
|
|
2
|
+
"version": "0.17.3",
|
|
3
3
|
"name": "modality-kit",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build:clean": "find ./dist -name '*.*' | xargs rm -rf",
|
|
30
30
|
"build:types": "bun tsc -p ./",
|
|
31
|
-
"build:src": "bun build src/index.ts --outdir dist",
|
|
31
|
+
"build:src": "bun build src/index.ts --outdir dist --target=node",
|
|
32
32
|
"build": "bun run build:clean && bun run build:types && bun run build:src",
|
|
33
33
|
"dev": "bunx concurrently 'bun --watch tsc -p ./' 'bun build:src -- --watch --sourcemap=inline'",
|
|
34
34
|
"test": "npm run build && bun test",
|