@mangos/filepath 0.0.8 → 1.0.0
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 +161 -221
- package/dist/ParsedPath.d.ts +9 -0
- package/dist/ParsedPath.js +17 -0
- package/dist/ParsedPathError.d.ts +9 -0
- package/dist/ParsedPathError.js +20 -0
- package/dist/Token.d.ts +17 -0
- package/dist/Token.js +22 -0
- package/dist/absorbSuccessiveValues.d.ts +4 -0
- package/dist/absorbSuccessiveValues.js +21 -0
- package/dist/absorbers/ddp.d.ts +10 -0
- package/dist/absorbers/ddp.js +46 -0
- package/dist/absorbers/posix.d.ts +2 -0
- package/dist/absorbers/posix.js +33 -0
- package/dist/absorbers/tdp.d.ts +3 -0
- package/dist/absorbers/tdp.js +132 -0
- package/dist/absorbers/unc.d.ts +3 -0
- package/dist/absorbers/unc.js +20 -0
- package/dist/constants.d.ts +11 -0
- package/dist/constants.js +17 -0
- package/dist/getCWD.d.ts +1 -0
- package/dist/getCWD.js +12 -0
- package/dist/getDrive.d.ts +1 -0
- package/dist/getDrive.js +7 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -0
- package/dist/parser.d.ts +17 -0
- package/dist/parser.js +161 -0
- package/dist/platform.d.ts +1 -0
- package/dist/platform.js +19 -0
- package/dist/togglePathFragment.d.ts +1 -0
- package/dist/togglePathFragment.js +5 -0
- package/dist/types/TokenValueType.d.ts +2 -0
- package/dist/validSep.d.ts +1 -0
- package/dist/validSep.js +6 -0
- package/package.json +61 -49
- package/.eslintrc.js +0 -17
- package/CHANGELOG.md +0 -59
- package/CODE_OF_CONDUCT.md +0 -69
- package/CONTRIBUTING_GUIDELINES.md +0 -9
- package/index.js +0 -23
- package/lib/parser.js +0 -191
- package/lib/tokenizer.js +0 -397
- package/test.js +0 -5
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import absorbSuccessiveValues from "../absorbSuccessiveValues.js";
|
|
2
|
+
import { TokenEnum } from "../constants.js";
|
|
3
|
+
import { Token } from "../Token.js";
|
|
4
|
+
import { togglePathFragment } from "../togglePathFragment.js";
|
|
5
|
+
function* posixAbsorber(str = "", start = 0, end = str.length - 1) {
|
|
6
|
+
let i = start;
|
|
7
|
+
const root = absorbSuccessiveValues(str, (s) => s === "/", start, end);
|
|
8
|
+
if (root) {
|
|
9
|
+
yield new Token(TokenEnum.ROOT, str.slice(start, root.end + 1), start, root.end);
|
|
10
|
+
i = root.end + 1;
|
|
11
|
+
}
|
|
12
|
+
let toggle = 0;
|
|
13
|
+
while (i <= end) {
|
|
14
|
+
const coalescer = toggle === 0 ? (s) => s !== "/" : (s) => s === "/";
|
|
15
|
+
const result = absorbSuccessiveValues(str, coalescer, i, end);
|
|
16
|
+
if (result) {
|
|
17
|
+
const value = str.slice(i, result.end + 1);
|
|
18
|
+
let token = togglePathFragment[toggle % 2];
|
|
19
|
+
if (value === "..") {
|
|
20
|
+
token = TokenEnum.PARENT;
|
|
21
|
+
}
|
|
22
|
+
if (value === ".") {
|
|
23
|
+
token = TokenEnum.CURRENT;
|
|
24
|
+
}
|
|
25
|
+
yield new Token(token, value, result.start, result.end);
|
|
26
|
+
i = result.end + 1;
|
|
27
|
+
}
|
|
28
|
+
toggle = ++toggle % 2;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
posixAbsorber as default
|
|
33
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import absorbSuccessiveValues from "../absorbSuccessiveValues.js";
|
|
2
|
+
import { TokenEnum } from "../constants.js";
|
|
3
|
+
import getCWD from "../getCWD.js";
|
|
4
|
+
import getDrive from "../getDrive.js";
|
|
5
|
+
import mapPlatformNames from "../platform.js";
|
|
6
|
+
import { Token } from "../Token.js";
|
|
7
|
+
import { togglePathFragment } from "../togglePathFragment.js";
|
|
8
|
+
import validSep from "../validSep.js";
|
|
9
|
+
import { regExpOrderedMapDDP, ddpAbsorber } from "./ddp.js";
|
|
10
|
+
import uncAbsorber, { uncRegExp } from "./unc.js";
|
|
11
|
+
const regexpLD = /(CON|PRN|AUX|NUL|COM[\\d]|LPT[\\d]|PRN)/i;
|
|
12
|
+
const forbiddenRegExp = /[<>:"/|?*<\0}]/;
|
|
13
|
+
function isInValidMSDirecotryName(str = "", start = 0, end = str.length - 1) {
|
|
14
|
+
return forbiddenRegExp.test(str.slice(start, end + 1));
|
|
15
|
+
}
|
|
16
|
+
function tdpRootNeedsCorrection(str) {
|
|
17
|
+
const match = str.match(/^[/\\]+/);
|
|
18
|
+
if (match === null) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (Object.entries({
|
|
22
|
+
...regExpOrderedMapDDP,
|
|
23
|
+
unc: uncRegExp
|
|
24
|
+
}).find(([_, regexp]) => str.match(regexp))) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
return { start: 0, end: match[0].length - 1 };
|
|
28
|
+
}
|
|
29
|
+
function getCWDDOSRoot() {
|
|
30
|
+
const ddpTokens = Array.from(ddpAbsorber(getCWD()));
|
|
31
|
+
if (ddpTokens.length) {
|
|
32
|
+
return ddpTokens[0];
|
|
33
|
+
}
|
|
34
|
+
const uncTokens = Array.from(uncAbsorber(getCWD()));
|
|
35
|
+
if (uncTokens.length) {
|
|
36
|
+
return uncTokens[0];
|
|
37
|
+
}
|
|
38
|
+
const drive = getDrive(getCWD());
|
|
39
|
+
if (drive[0] >= "a" && drive[0] <= "z" && drive[1] === ":") {
|
|
40
|
+
return new Token(TokenEnum.ROOT, `${drive.join("")}`, 0, 1);
|
|
41
|
+
}
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
function tdpFragment(str, start, end) {
|
|
45
|
+
return absorbSuccessiveValues(str, (s) => !validSep(s), start, end);
|
|
46
|
+
}
|
|
47
|
+
function tdpSeperator(str, start, end) {
|
|
48
|
+
return absorbSuccessiveValues(str, (s) => validSep(s), start, end);
|
|
49
|
+
}
|
|
50
|
+
function hasLegacyDeviceName(str) {
|
|
51
|
+
const match = str.match(regexpLD);
|
|
52
|
+
if (Array.isArray(match)) {
|
|
53
|
+
return match[0];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function* tdpAbsorber(str = "") {
|
|
57
|
+
let i = 0;
|
|
58
|
+
let end = str.length - 1;
|
|
59
|
+
const result = tdpRootNeedsCorrection(str.slice(i, str.length));
|
|
60
|
+
if (result) {
|
|
61
|
+
if (mapPlatformNames() === "win32") {
|
|
62
|
+
const winRoot = getCWDDOSRoot();
|
|
63
|
+
if (winRoot) {
|
|
64
|
+
yield winRoot;
|
|
65
|
+
if (result.end >= str.length - 1) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
str = `${winRoot.value}\\${str.slice(result.end + 1)}`;
|
|
69
|
+
end = end + winRoot.value.length - (result.end + 1) + 1;
|
|
70
|
+
i = winRoot.value.length;
|
|
71
|
+
yield* tdpBodyAbsorber(str, i, end);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const value = str.slice(result.start, result.end + 1);
|
|
76
|
+
yield new Token(
|
|
77
|
+
TokenEnum.PATHELT,
|
|
78
|
+
value,
|
|
79
|
+
0,
|
|
80
|
+
result.end,
|
|
81
|
+
`path ${str} contains invalid ${value} as path element`
|
|
82
|
+
);
|
|
83
|
+
i = result.end + 1;
|
|
84
|
+
}
|
|
85
|
+
if (str.slice(i, str.length - 1).match(uncRegExp)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const drive = getDrive(str.slice(i, i + 2).toLowerCase());
|
|
89
|
+
if (drive[0] >= "a" && drive[0] <= "z" && drive[1] === ":") {
|
|
90
|
+
yield new Token(TokenEnum.ROOT, `${drive.join("")}`, i, i + 1);
|
|
91
|
+
i = 2;
|
|
92
|
+
}
|
|
93
|
+
yield* tdpBodyAbsorber(str, i, str.length - 1);
|
|
94
|
+
}
|
|
95
|
+
function* tdpBodyAbsorber(str = "", start, end = str.length - 1) {
|
|
96
|
+
let toggle = 0;
|
|
97
|
+
let i = start;
|
|
98
|
+
while (i <= end) {
|
|
99
|
+
const result = toggle === 0 ? tdpFragment(str, i, end) : tdpSeperator(str, i, end);
|
|
100
|
+
if (result) {
|
|
101
|
+
const value = toggle === 0 ? str.slice(i, result.end + 1) : "\\";
|
|
102
|
+
let token = togglePathFragment[toggle];
|
|
103
|
+
const errors = [];
|
|
104
|
+
if (toggle === 0) {
|
|
105
|
+
switch (value) {
|
|
106
|
+
case "..":
|
|
107
|
+
token = TokenEnum.PARENT;
|
|
108
|
+
break;
|
|
109
|
+
case ".":
|
|
110
|
+
token = TokenEnum.CURRENT;
|
|
111
|
+
break;
|
|
112
|
+
default: {
|
|
113
|
+
const ldn = hasLegacyDeviceName(value);
|
|
114
|
+
if (ldn) {
|
|
115
|
+
errors.push(`contains forbidden DOS legacy device name: ${ldn}`);
|
|
116
|
+
}
|
|
117
|
+
if (isInValidMSDirecotryName(value)) {
|
|
118
|
+
errors.push(`name "${value}" contains invalid characters`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
yield errors?.length ? new Token(token, value, result.start, result.end, errors?.join("|")) : new Token(token, value, result.start, result.end);
|
|
124
|
+
i = result.end + 1;
|
|
125
|
+
}
|
|
126
|
+
toggle = ++toggle % 2;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export {
|
|
130
|
+
tdpAbsorber as default,
|
|
131
|
+
tdpBodyAbsorber
|
|
132
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TokenEnum } from "../constants.js";
|
|
2
|
+
import { Token } from "../Token.js";
|
|
3
|
+
import { tdpBodyAbsorber } from "./tdp.js";
|
|
4
|
+
const uncRegExp = /^(\/\/|\\\\)([^\\/\\?\\.]+)(\/|\\)([^\\/]+)(\/|\\)?/;
|
|
5
|
+
function* uncAbsorber(str = "") {
|
|
6
|
+
const match = str.match(uncRegExp);
|
|
7
|
+
if (match === null) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const server = match[2];
|
|
11
|
+
const share = match[4];
|
|
12
|
+
const value = `\\\\${server}\\${share}`;
|
|
13
|
+
const endUnc = value.length - 1;
|
|
14
|
+
yield new Token(TokenEnum.ROOT, value, 0, endUnc);
|
|
15
|
+
yield* tdpBodyAbsorber(str, endUnc + 1, str.length - 1);
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
uncAbsorber as default,
|
|
19
|
+
uncRegExp
|
|
20
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const TokenEnum: {
|
|
2
|
+
readonly SEP: "\u0001";
|
|
3
|
+
readonly ROOT: "\u0003";
|
|
4
|
+
readonly PATHELT: "\u0006";
|
|
5
|
+
readonly PARENT: "\u0007";
|
|
6
|
+
readonly CURRENT: "\b";
|
|
7
|
+
};
|
|
8
|
+
export type TokenValueEnumType = {
|
|
9
|
+
-readonly [K in keyof typeof TokenEnum as (typeof TokenEnum)[K]]: K;
|
|
10
|
+
};
|
|
11
|
+
export declare const TokenValueEnum: TokenValueEnumType;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const TokenEnum = {
|
|
2
|
+
SEP: "",
|
|
3
|
+
ROOT: "",
|
|
4
|
+
PATHELT: "",
|
|
5
|
+
PARENT: "\x07",
|
|
6
|
+
CURRENT: "\b"
|
|
7
|
+
};
|
|
8
|
+
(() => {
|
|
9
|
+
const entries = Object.entries(TokenEnum);
|
|
10
|
+
return entries.reduce((obj, [prop, value]) => {
|
|
11
|
+
obj[value] = prop;
|
|
12
|
+
return obj;
|
|
13
|
+
}, {});
|
|
14
|
+
})();
|
|
15
|
+
export {
|
|
16
|
+
TokenEnum
|
|
17
|
+
};
|
package/dist/getCWD.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getCWD(): string;
|
package/dist/getCWD.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getDrive(str: string): [string, string];
|
package/dist/getDrive.js
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/parser.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ParsedPath } from './ParsedPath.js';
|
|
2
|
+
import { ParsedPathError } from './ParsedPathError.js';
|
|
3
|
+
import { Token } from './Token.js';
|
|
4
|
+
export type FileSystem = 'devicePath' | 'unc' | 'dos' | 'posix';
|
|
5
|
+
declare function firstPath(path?: string, options?: InferPathOptions): ParsedPath | ParsedPathError | undefined;
|
|
6
|
+
declare function allPath(path?: string, options?: InferPathOptions): (ParsedPath | ParsedPathError)[];
|
|
7
|
+
export type ParsedPathDTO = {
|
|
8
|
+
type: FileSystem;
|
|
9
|
+
path: Token[];
|
|
10
|
+
firstError?: number;
|
|
11
|
+
};
|
|
12
|
+
declare function resolve(fromStr?: string, ...toFragments: string[]): ParsedPath | ParsedPathError;
|
|
13
|
+
declare function resolvePathObject(from: ParsedPath, ...toFragments: string[]): ParsedPath | ParsedPathError;
|
|
14
|
+
type InferPathOptions = {
|
|
15
|
+
[key in FileSystem]+?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export { resolve, type resolvePathObject, firstPath, allPath };
|
package/dist/parser.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { ddpAbsorber } from "./absorbers/ddp.js";
|
|
2
|
+
import posixAbsorber from "./absorbers/posix.js";
|
|
3
|
+
import tdpAbsorber from "./absorbers/tdp.js";
|
|
4
|
+
import uncAbsorber from "./absorbers/unc.js";
|
|
5
|
+
import { TokenEnum } from "./constants.js";
|
|
6
|
+
import getCWD from "./getCWD.js";
|
|
7
|
+
import { ParsedPath } from "./ParsedPath.js";
|
|
8
|
+
import { ParsedPathError } from "./ParsedPathError.js";
|
|
9
|
+
import mapPlatformNames from "./platform.js";
|
|
10
|
+
import { Token } from "./Token.js";
|
|
11
|
+
const absorberMapping = {
|
|
12
|
+
unc: uncAbsorber,
|
|
13
|
+
dos: tdpAbsorber,
|
|
14
|
+
devicePath: ddpAbsorber,
|
|
15
|
+
posix: posixAbsorber
|
|
16
|
+
};
|
|
17
|
+
const allNamespaces = ["devicePath", "unc", "dos", "posix"];
|
|
18
|
+
function firstPath(path = "", options = {}) {
|
|
19
|
+
const iterator = inferPathType(path, options);
|
|
20
|
+
const step = iterator.next();
|
|
21
|
+
if (step.done) {
|
|
22
|
+
return void 0;
|
|
23
|
+
}
|
|
24
|
+
return step.value;
|
|
25
|
+
}
|
|
26
|
+
function allPath(path = "", options = {}) {
|
|
27
|
+
return Array.from(inferPathType(path, options));
|
|
28
|
+
}
|
|
29
|
+
function createPathProcessor(path) {
|
|
30
|
+
return (ns) => {
|
|
31
|
+
const _tokens = Array.from(absorberMapping[ns](path));
|
|
32
|
+
if (_tokens.length === 0) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const rc = { type: ns, path: _tokens };
|
|
36
|
+
const hasError = _tokens.some((t) => !!t.error);
|
|
37
|
+
if (hasError) {
|
|
38
|
+
return new ParsedPathError(rc);
|
|
39
|
+
}
|
|
40
|
+
return new ParsedPath(rc);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function getErrors(parsed) {
|
|
44
|
+
return parsed.path.reduce((errors, token) => {
|
|
45
|
+
if (!token.error) {
|
|
46
|
+
return errors;
|
|
47
|
+
}
|
|
48
|
+
errors.push(token.error);
|
|
49
|
+
return errors;
|
|
50
|
+
}, []).join("|");
|
|
51
|
+
}
|
|
52
|
+
function last(arr) {
|
|
53
|
+
return arr[arr.length - 1];
|
|
54
|
+
}
|
|
55
|
+
function upp(path) {
|
|
56
|
+
let _last;
|
|
57
|
+
for (_last = last(path); _last.token === TokenEnum.SEP; _last = last(path)) {
|
|
58
|
+
path.pop();
|
|
59
|
+
}
|
|
60
|
+
if (_last !== path[0]) {
|
|
61
|
+
path.pop();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function add(_tokens, token) {
|
|
65
|
+
if (token.token === TokenEnum.SEP) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
let _last = last(_tokens);
|
|
69
|
+
for (; _last.token === TokenEnum.SEP; _last = last(_tokens)) {
|
|
70
|
+
_tokens.pop();
|
|
71
|
+
}
|
|
72
|
+
_tokens.push(new Token(TokenEnum.SEP, getSeperator(), _last.end + 1, _last.end + 1));
|
|
73
|
+
_tokens.push(new Token(token.token, token.value, _last.end + 2, _last.end + 2 + token.end));
|
|
74
|
+
}
|
|
75
|
+
function firstPathFromCWD() {
|
|
76
|
+
return firstPath(getCWD());
|
|
77
|
+
}
|
|
78
|
+
function resolve(fromStr = getCWD(), ...toFragments) {
|
|
79
|
+
let firstPathFrom = firstPath(fromStr) ?? firstPathFromCWD();
|
|
80
|
+
if (firstPathFrom instanceof ParsedPathError) {
|
|
81
|
+
throw TypeError(`"from" path contains errors: ${getErrors(firstPathFrom)}`);
|
|
82
|
+
}
|
|
83
|
+
if (firstPathFrom.isRelative()) {
|
|
84
|
+
toFragments.unshift(fromStr);
|
|
85
|
+
firstPathFrom = firstPathFromCWD();
|
|
86
|
+
}
|
|
87
|
+
return resolvePathObject(firstPathFrom, ...toFragments);
|
|
88
|
+
}
|
|
89
|
+
function resolvePathObject(from, ...toFragments) {
|
|
90
|
+
const firstToStr = toFragments.shift();
|
|
91
|
+
if (firstToStr === void 0) {
|
|
92
|
+
return from;
|
|
93
|
+
}
|
|
94
|
+
const firstPathTo = firstPath(firstToStr);
|
|
95
|
+
if (firstPathTo === void 0) {
|
|
96
|
+
return from;
|
|
97
|
+
}
|
|
98
|
+
if (firstPathTo instanceof ParsedPathError) {
|
|
99
|
+
throw TypeError(`"to" path contains errors: ${getErrors(firstPathTo)}`);
|
|
100
|
+
}
|
|
101
|
+
if (!firstPathTo.isRelative()) {
|
|
102
|
+
if (toFragments.length === 0) {
|
|
103
|
+
return firstPathTo;
|
|
104
|
+
}
|
|
105
|
+
return resolvePathObject(firstPathTo, ...toFragments);
|
|
106
|
+
}
|
|
107
|
+
const working = structuredClone(from.path);
|
|
108
|
+
for (const token of firstPathTo.path) {
|
|
109
|
+
switch (token.token) {
|
|
110
|
+
case TokenEnum.SEP:
|
|
111
|
+
case TokenEnum.CURRENT:
|
|
112
|
+
break;
|
|
113
|
+
case TokenEnum.PARENT:
|
|
114
|
+
upp(working);
|
|
115
|
+
break;
|
|
116
|
+
case TokenEnum.PATHELT:
|
|
117
|
+
add(working, token);
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const rc = new ParsedPath({ ...from, path: working });
|
|
122
|
+
if (toFragments.length === 0) {
|
|
123
|
+
return rc;
|
|
124
|
+
}
|
|
125
|
+
return resolvePathObject(rc, ...toFragments);
|
|
126
|
+
}
|
|
127
|
+
function getSeperator() {
|
|
128
|
+
if (mapPlatformNames() === "win32") {
|
|
129
|
+
return "\\";
|
|
130
|
+
}
|
|
131
|
+
return "/";
|
|
132
|
+
}
|
|
133
|
+
function defaultOptions(options = {}) {
|
|
134
|
+
if (allNamespaces.every((fs) => !(fs in options))) {
|
|
135
|
+
const isWindows = mapPlatformNames() === "win32";
|
|
136
|
+
return Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
137
|
+
unc: isWindows,
|
|
138
|
+
dos: isWindows,
|
|
139
|
+
devicePath: isWindows,
|
|
140
|
+
posix: !isWindows
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return options;
|
|
144
|
+
}
|
|
145
|
+
function* inferPathType(path, options = {}) {
|
|
146
|
+
const finalOptions = defaultOptions(options);
|
|
147
|
+
const processor = createPathProcessor(path);
|
|
148
|
+
const filtered = allNamespaces.filter((f) => finalOptions[f]);
|
|
149
|
+
for (const ns of filtered) {
|
|
150
|
+
const result = processor(ns);
|
|
151
|
+
if (result) {
|
|
152
|
+
yield result;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
export {
|
|
158
|
+
allPath,
|
|
159
|
+
firstPath,
|
|
160
|
+
resolve
|
|
161
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function mapPlatformNames(): NodeJS.Platform | undefined;
|
package/dist/platform.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function getPlatform() {
|
|
2
|
+
if ("userAgentData" in navigator) {
|
|
3
|
+
return navigator.userAgentData.platform.toLowerCase();
|
|
4
|
+
}
|
|
5
|
+
if ("platform" in navigator) {
|
|
6
|
+
return navigator.platform.toLowerCase();
|
|
7
|
+
}
|
|
8
|
+
return process?.platform;
|
|
9
|
+
}
|
|
10
|
+
function mapPlatformNames() {
|
|
11
|
+
const platform = getPlatform() ?? "linux";
|
|
12
|
+
if (platform.includes("win")) {
|
|
13
|
+
return "win32";
|
|
14
|
+
}
|
|
15
|
+
return "linux";
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
mapPlatformNames as default
|
|
19
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const togglePathFragment: readonly ["\u0006", "\u0001"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function validSep(s: string | undefined): s is "/" | "\\";
|
package/dist/validSep.js
ADDED
package/package.json
CHANGED
|
@@ -1,49 +1,61 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@mangos/filepath",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"author": "jacob bogers <jkfbogers@gmail.com>",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/R-js/mangos.git",
|
|
8
|
+
"directory": "packages/filepath"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@biomejs/biome": "^2.3.8",
|
|
20
|
+
"@types/node": "^25.0.0",
|
|
21
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
22
|
+
"typescript": "^5.9.3",
|
|
23
|
+
"vite": "^7.2.7",
|
|
24
|
+
"vitest": "^4.0.15"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/R-js/mangos.git",
|
|
28
|
+
"email": "jkfbogers@gmail.com"
|
|
29
|
+
},
|
|
30
|
+
"description": "filepath parses UNC (long and short and cmd aliases) local filesystem path, and unix paths, checks for invalid path characters",
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=v20.8.0"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"README.md",
|
|
37
|
+
"package.json"
|
|
38
|
+
],
|
|
39
|
+
"homepage": "https://github.com/R-js/mangos/blob/master/packages/filepath/README.md",
|
|
40
|
+
"keywords": [
|
|
41
|
+
"file",
|
|
42
|
+
"path",
|
|
43
|
+
"unc",
|
|
44
|
+
"dos",
|
|
45
|
+
"linux",
|
|
46
|
+
"device path",
|
|
47
|
+
"universal naming convention",
|
|
48
|
+
"file system",
|
|
49
|
+
"lfs"
|
|
50
|
+
],
|
|
51
|
+
"license": "MIT",
|
|
52
|
+
"scripts": {
|
|
53
|
+
"prebuild": "npm run lint",
|
|
54
|
+
"build": "vite build && tsc",
|
|
55
|
+
"prepublishOnly": "npm run build",
|
|
56
|
+
"lint": "biome check",
|
|
57
|
+
"test": "vitest run --coverage"
|
|
58
|
+
},
|
|
59
|
+
"sideEffects": false,
|
|
60
|
+
"type": "module"
|
|
61
|
+
}
|
package/.eslintrc.js
DELETED