@tailwindcss/oxide-wasm32-wasi 0.0.0-insiders.00ef99d
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 +3 -0
- package/node_modules/@emnapi/core/LICENSE +21 -0
- package/node_modules/@emnapi/core/README.md +1 -0
- package/node_modules/@emnapi/core/dist/emnapi-core.cjs.js +7746 -0
- package/node_modules/@emnapi/core/dist/emnapi-core.cjs.min.d.ts +428 -0
- package/node_modules/@emnapi/core/dist/emnapi-core.cjs.min.js +1 -0
- package/node_modules/@emnapi/core/dist/emnapi-core.d.mts +428 -0
- package/node_modules/@emnapi/core/dist/emnapi-core.d.ts +430 -0
- package/node_modules/@emnapi/core/dist/emnapi-core.esm-bundler.js +8741 -0
- package/node_modules/@emnapi/core/dist/emnapi-core.js +9777 -0
- package/node_modules/@emnapi/core/dist/emnapi-core.min.d.mts +428 -0
- package/node_modules/@emnapi/core/dist/emnapi-core.min.js +1 -0
- package/node_modules/@emnapi/core/dist/emnapi-core.min.mjs +1 -0
- package/node_modules/@emnapi/core/dist/emnapi-core.mjs +7735 -0
- package/node_modules/@emnapi/core/index.js +5 -0
- package/node_modules/@emnapi/core/package.json +49 -0
- package/node_modules/@emnapi/runtime/LICENSE +21 -0
- package/node_modules/@emnapi/runtime/README.md +1 -0
- package/node_modules/@emnapi/runtime/dist/emnapi.cjs.js +1398 -0
- package/node_modules/@emnapi/runtime/dist/emnapi.cjs.min.d.ts +671 -0
- package/node_modules/@emnapi/runtime/dist/emnapi.cjs.min.js +1 -0
- package/node_modules/@emnapi/runtime/dist/emnapi.d.mts +671 -0
- package/node_modules/@emnapi/runtime/dist/emnapi.d.ts +673 -0
- package/node_modules/@emnapi/runtime/dist/emnapi.esm-bundler.js +1457 -0
- package/node_modules/@emnapi/runtime/dist/emnapi.iife.d.ts +426 -0
- package/node_modules/@emnapi/runtime/dist/emnapi.iife.js +1528 -0
- package/node_modules/@emnapi/runtime/dist/emnapi.js +1529 -0
- package/node_modules/@emnapi/runtime/dist/emnapi.min.d.mts +671 -0
- package/node_modules/@emnapi/runtime/dist/emnapi.min.js +1 -0
- package/node_modules/@emnapi/runtime/dist/emnapi.min.mjs +1 -0
- package/node_modules/@emnapi/runtime/dist/emnapi.mjs +1367 -0
- package/node_modules/@emnapi/runtime/index.js +5 -0
- package/node_modules/@emnapi/runtime/package.json +48 -0
- package/node_modules/@emnapi/wasi-threads/LICENSE +21 -0
- package/node_modules/@emnapi/wasi-threads/README.md +203 -0
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.js +915 -0
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.min.d.ts +271 -0
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.min.js +1 -0
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.mts +271 -0
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +273 -0
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.esm-bundler.js +975 -0
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +987 -0
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.d.mts +271 -0
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.js +1 -0
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.mjs +1 -0
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.mjs +910 -0
- package/node_modules/@emnapi/wasi-threads/index.js +5 -0
- package/node_modules/@emnapi/wasi-threads/package.json +50 -0
- package/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.cjs +1826 -0
- package/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.js +1823 -0
- package/node_modules/@napi-rs/wasm-runtime/dist/fs-proxy.cjs +321 -0
- package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +25524 -0
- package/node_modules/@napi-rs/wasm-runtime/fs-proxy.js +316 -0
- package/node_modules/@napi-rs/wasm-runtime/package.json +74 -0
- package/node_modules/@napi-rs/wasm-runtime/runtime.cjs +39 -0
- package/node_modules/@napi-rs/wasm-runtime/runtime.js +36 -0
- package/node_modules/@tybys/wasm-util/README.md +193 -0
- package/node_modules/@tybys/wasm-util/dist/tsdoc-metadata.json +11 -0
- package/node_modules/@tybys/wasm-util/dist/wasm-util.d.ts +423 -0
- package/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js +2932 -0
- package/node_modules/@tybys/wasm-util/dist/wasm-util.esm.js +2932 -0
- package/node_modules/@tybys/wasm-util/dist/wasm-util.esm.min.js +1 -0
- package/node_modules/@tybys/wasm-util/dist/wasm-util.js +2954 -0
- package/node_modules/@tybys/wasm-util/dist/wasm-util.min.js +1 -0
- package/node_modules/@tybys/wasm-util/lib/cjs/asyncify.js +158 -0
- package/node_modules/@tybys/wasm-util/lib/cjs/index.js +13 -0
- package/node_modules/@tybys/wasm-util/lib/cjs/jspi.js +46 -0
- package/node_modules/@tybys/wasm-util/lib/cjs/load.js +97 -0
- package/node_modules/@tybys/wasm-util/lib/cjs/memory.js +35 -0
- package/node_modules/@tybys/wasm-util/lib/cjs/wasi/error.js +103 -0
- package/node_modules/@tybys/wasm-util/lib/cjs/wasi/fd.js +268 -0
- package/node_modules/@tybys/wasm-util/lib/cjs/wasi/fs.js +3 -0
- package/node_modules/@tybys/wasm-util/lib/cjs/wasi/index.js +192 -0
- package/node_modules/@tybys/wasm-util/lib/cjs/wasi/path.js +316 -0
- package/node_modules/@tybys/wasm-util/lib/cjs/wasi/preview1.js +1599 -0
- package/node_modules/@tybys/wasm-util/lib/cjs/wasi/rights.js +141 -0
- package/node_modules/@tybys/wasm-util/lib/cjs/wasi/types.js +220 -0
- package/node_modules/@tybys/wasm-util/lib/cjs/wasi/util.js +128 -0
- package/node_modules/@tybys/wasm-util/lib/cjs/webassembly.js +13 -0
- package/node_modules/@tybys/wasm-util/lib/mjs/asyncify.mjs +153 -0
- package/node_modules/@tybys/wasm-util/lib/mjs/index.mjs +9 -0
- package/node_modules/@tybys/wasm-util/lib/mjs/jspi.mjs +39 -0
- package/node_modules/@tybys/wasm-util/lib/mjs/load.mjs +89 -0
- package/node_modules/@tybys/wasm-util/lib/mjs/memory.mjs +28 -0
- package/node_modules/@tybys/wasm-util/lib/mjs/wasi/error.mjs +97 -0
- package/node_modules/@tybys/wasm-util/lib/mjs/wasi/fd.mjs +256 -0
- package/node_modules/@tybys/wasm-util/lib/mjs/wasi/fs.mjs +1 -0
- package/node_modules/@tybys/wasm-util/lib/mjs/wasi/index.mjs +186 -0
- package/node_modules/@tybys/wasm-util/lib/mjs/wasi/path.mjs +310 -0
- package/node_modules/@tybys/wasm-util/lib/mjs/wasi/preview1.mjs +1593 -0
- package/node_modules/@tybys/wasm-util/lib/mjs/wasi/rights.mjs +135 -0
- package/node_modules/@tybys/wasm-util/lib/mjs/wasi/types.mjs +216 -0
- package/node_modules/@tybys/wasm-util/lib/mjs/wasi/util.mjs +113 -0
- package/node_modules/@tybys/wasm-util/lib/mjs/webassembly.mjs +9 -0
- package/node_modules/@tybys/wasm-util/package.json +58 -0
- package/node_modules/tslib/CopyrightNotice.txt +15 -0
- package/node_modules/tslib/LICENSE.txt +12 -0
- package/node_modules/tslib/README.md +164 -0
- package/node_modules/tslib/SECURITY.md +41 -0
- package/node_modules/tslib/modules/index.d.ts +38 -0
- package/node_modules/tslib/modules/index.js +70 -0
- package/node_modules/tslib/modules/package.json +3 -0
- package/node_modules/tslib/package.json +47 -0
- package/node_modules/tslib/tslib.d.ts +460 -0
- package/node_modules/tslib/tslib.es6.html +1 -0
- package/node_modules/tslib/tslib.es6.js +402 -0
- package/node_modules/tslib/tslib.es6.mjs +401 -0
- package/node_modules/tslib/tslib.html +1 -0
- package/node_modules/tslib/tslib.js +484 -0
- package/package.json +42 -0
- package/tailwindcss-oxide.wasi-browser.js +67 -0
- package/tailwindcss-oxide.wasi.cjs +123 -0
- package/tailwindcss-oxide.wasm32-wasi.wasm +0 -0
- package/wasi-worker-browser.mjs +41 -0
- package/wasi-worker.mjs +72 -0
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.relative = exports.resolve = void 0;
|
|
4
|
+
const util_1 = require("./util");
|
|
5
|
+
const CHAR_DOT = 46; /* . */
|
|
6
|
+
const CHAR_FORWARD_SLASH = 47; /* / */
|
|
7
|
+
const CHAR_BACKWARD_SLASH = 92; /* \ */
|
|
8
|
+
const CHAR_COLON = 58; /* : */
|
|
9
|
+
const CHAR_UPPERCASE_A = 65; /* A */
|
|
10
|
+
const CHAR_UPPERCASE_Z = 90; /* Z */
|
|
11
|
+
const CHAR_LOWERCASE_A = 97; /* a */
|
|
12
|
+
const CHAR_LOWERCASE_Z = 122; /* z */
|
|
13
|
+
function isPathSeparatorWin(code) {
|
|
14
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
15
|
+
}
|
|
16
|
+
function isWindowsDeviceRoot(code) {
|
|
17
|
+
return (code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z) ||
|
|
18
|
+
(code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z);
|
|
19
|
+
}
|
|
20
|
+
const _isWin32 = typeof process !== 'undefined' && process.platform === 'win32';
|
|
21
|
+
/**
|
|
22
|
+
* Windows variant of `resolve()`. Mirrors Node's `path.win32.resolve`
|
|
23
|
+
* semantics enough for the WASI shim's needs (drive-letter absolutes
|
|
24
|
+
* + UNC paths + per-drive cwd lookups via `process.env`/`process.cwd`).
|
|
25
|
+
*
|
|
26
|
+
* Why this is needed: on Windows, `FileDescriptor.realPath` is the
|
|
27
|
+
* host realpath returned by `fs.realpathSync(realPath, 'utf8')` — the
|
|
28
|
+
* backslash form `D:\…`. The POSIX-only `resolveImpl` below only
|
|
29
|
+
* treats `/` as a separator, reads `D` as non-`/`, decides realPath
|
|
30
|
+
* is "relative", and produces a garbage joined path. Downstream
|
|
31
|
+
* `fs.openSync(garbage)` then returns `EINVAL` and the WASI caller
|
|
32
|
+
* sees a permanent failure. This function gives us the correct
|
|
33
|
+
* Windows-style resolution without taking a Node-only `path` import
|
|
34
|
+
* (which would break browser bundles of this package).
|
|
35
|
+
*
|
|
36
|
+
* Cribbed from Node's `lib/path.js` `win32.resolve()` (MIT-licensed),
|
|
37
|
+
* trimmed to what WASI realpath resolution actually exercises.
|
|
38
|
+
*/
|
|
39
|
+
function resolveWin32(args) {
|
|
40
|
+
let resolvedDevice = '';
|
|
41
|
+
let resolvedTail = '';
|
|
42
|
+
let resolvedAbsolute = false;
|
|
43
|
+
for (let i = args.length - 1; i >= -1; i--) {
|
|
44
|
+
let path;
|
|
45
|
+
if (i >= 0) {
|
|
46
|
+
path = args[i];
|
|
47
|
+
(0, util_1.validateString)(path, 'path');
|
|
48
|
+
if (path.length === 0)
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
else if (resolvedDevice.length === 0) {
|
|
52
|
+
path = (typeof process !== 'undefined' && typeof process.cwd === 'function')
|
|
53
|
+
? process.cwd()
|
|
54
|
+
: '';
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
// Look up per-drive cwd via the `=X:` env var convention; fall back
|
|
58
|
+
// to the global cwd if absent.
|
|
59
|
+
const envKey = `=${resolvedDevice}`;
|
|
60
|
+
const env = (typeof process !== 'undefined') ? process.env : undefined;
|
|
61
|
+
path = (env && typeof env[envKey] === 'string')
|
|
62
|
+
? env[envKey]
|
|
63
|
+
: (typeof process !== 'undefined' && typeof process.cwd === 'function')
|
|
64
|
+
? process.cwd()
|
|
65
|
+
: '';
|
|
66
|
+
if (path === undefined ||
|
|
67
|
+
(path.slice(0, 2).toLowerCase() !== resolvedDevice.toLowerCase() &&
|
|
68
|
+
path.charCodeAt(2) === CHAR_BACKWARD_SLASH)) {
|
|
69
|
+
path = `${resolvedDevice}\\`;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const len = path.length;
|
|
73
|
+
let rootEnd = 0;
|
|
74
|
+
let device = '';
|
|
75
|
+
let isAbsolute = false;
|
|
76
|
+
const code = path.charCodeAt(0);
|
|
77
|
+
if (len === 1) {
|
|
78
|
+
if (isPathSeparatorWin(code)) {
|
|
79
|
+
rootEnd = 1;
|
|
80
|
+
isAbsolute = true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else if (isPathSeparatorWin(code)) {
|
|
84
|
+
isAbsolute = true;
|
|
85
|
+
if (isPathSeparatorWin(path.charCodeAt(1))) {
|
|
86
|
+
// UNC path: `\\server\share\…`
|
|
87
|
+
let j = 2;
|
|
88
|
+
let last = j;
|
|
89
|
+
while (j < len && !isPathSeparatorWin(path.charCodeAt(j)))
|
|
90
|
+
j++;
|
|
91
|
+
if (j < len && j !== last) {
|
|
92
|
+
const firstPart = path.slice(last, j);
|
|
93
|
+
last = j;
|
|
94
|
+
while (j < len && isPathSeparatorWin(path.charCodeAt(j)))
|
|
95
|
+
j++;
|
|
96
|
+
if (j < len && j !== last) {
|
|
97
|
+
last = j;
|
|
98
|
+
while (j < len && !isPathSeparatorWin(path.charCodeAt(j)))
|
|
99
|
+
j++;
|
|
100
|
+
if (j === len || j !== last) {
|
|
101
|
+
device = `\\\\${firstPart}\\${path.slice(last, j)}`;
|
|
102
|
+
rootEnd = j;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
rootEnd = 1;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
|
|
112
|
+
device = path.slice(0, 2);
|
|
113
|
+
rootEnd = 2;
|
|
114
|
+
if (len > 2 && isPathSeparatorWin(path.charCodeAt(2))) {
|
|
115
|
+
isAbsolute = true;
|
|
116
|
+
rootEnd = 3;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (device.length > 0) {
|
|
120
|
+
if (resolvedDevice.length > 0) {
|
|
121
|
+
if (device.toLowerCase() !== resolvedDevice.toLowerCase())
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
resolvedDevice = device;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (resolvedAbsolute) {
|
|
129
|
+
if (resolvedDevice.length > 0)
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
resolvedTail = `${path.slice(rootEnd)}\\${resolvedTail}`;
|
|
134
|
+
resolvedAbsolute = isAbsolute;
|
|
135
|
+
if (isAbsolute && resolvedDevice.length > 0)
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, '\\', isPathSeparatorWin);
|
|
140
|
+
return resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail || '.';
|
|
141
|
+
}
|
|
142
|
+
function isPosixPathSeparator(code) {
|
|
143
|
+
return code === CHAR_FORWARD_SLASH;
|
|
144
|
+
}
|
|
145
|
+
function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
|
|
146
|
+
let res = '';
|
|
147
|
+
let lastSegmentLength = 0;
|
|
148
|
+
let lastSlash = -1;
|
|
149
|
+
let dots = 0;
|
|
150
|
+
let code = 0;
|
|
151
|
+
for (let i = 0; i <= path.length; ++i) {
|
|
152
|
+
if (i < path.length) {
|
|
153
|
+
code = path.charCodeAt(i);
|
|
154
|
+
}
|
|
155
|
+
else if (isPathSeparator(code)) {
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
code = CHAR_FORWARD_SLASH;
|
|
160
|
+
}
|
|
161
|
+
if (isPathSeparator(code)) {
|
|
162
|
+
if (lastSlash === i - 1 || dots === 1) {
|
|
163
|
+
// NOOP
|
|
164
|
+
}
|
|
165
|
+
else if (dots === 2) {
|
|
166
|
+
if (res.length < 2 || lastSegmentLength !== 2 ||
|
|
167
|
+
res.charCodeAt(res.length - 1) !== CHAR_DOT ||
|
|
168
|
+
res.charCodeAt(res.length - 2) !== CHAR_DOT) {
|
|
169
|
+
if (res.length > 2) {
|
|
170
|
+
const lastSlashIndex = res.indexOf(separator);
|
|
171
|
+
if (lastSlashIndex === -1) {
|
|
172
|
+
res = '';
|
|
173
|
+
lastSegmentLength = 0;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
res = res.slice(0, lastSlashIndex);
|
|
177
|
+
lastSegmentLength =
|
|
178
|
+
res.length - 1 - res.indexOf(separator);
|
|
179
|
+
}
|
|
180
|
+
lastSlash = i;
|
|
181
|
+
dots = 0;
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
else if (res.length !== 0) {
|
|
185
|
+
res = '';
|
|
186
|
+
lastSegmentLength = 0;
|
|
187
|
+
lastSlash = i;
|
|
188
|
+
dots = 0;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (allowAboveRoot) {
|
|
193
|
+
res += res.length > 0 ? `${separator}..` : '..';
|
|
194
|
+
lastSegmentLength = 2;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
if (res.length > 0) {
|
|
199
|
+
res += `${separator}${path.slice(lastSlash + 1, i)}`;
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
res = path.slice(lastSlash + 1, i);
|
|
203
|
+
}
|
|
204
|
+
lastSegmentLength = i - lastSlash - 1;
|
|
205
|
+
}
|
|
206
|
+
lastSlash = i;
|
|
207
|
+
dots = 0;
|
|
208
|
+
}
|
|
209
|
+
else if (code === CHAR_DOT && dots !== -1) {
|
|
210
|
+
++dots;
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
dots = -1;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return res;
|
|
217
|
+
}
|
|
218
|
+
function resolve(...args) {
|
|
219
|
+
// On Windows, host paths are `D:\…` style. The POSIX-only resolver
|
|
220
|
+
// below treats `D` as a non-`/` character and produces garbage; route
|
|
221
|
+
// to the Windows-aware variant. POSIX hosts (Linux/macOS/browser)
|
|
222
|
+
// run the original code path unchanged — `_isWin32` is constant-folded
|
|
223
|
+
// away on those targets.
|
|
224
|
+
if (_isWin32)
|
|
225
|
+
return resolveWin32(args);
|
|
226
|
+
let resolvedPath = '';
|
|
227
|
+
let resolvedAbsolute = false;
|
|
228
|
+
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
229
|
+
const path = i >= 0 ? args[i] : '/';
|
|
230
|
+
(0, util_1.validateString)(path, 'path');
|
|
231
|
+
// Skip empty entries
|
|
232
|
+
if (path.length === 0) {
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
236
|
+
resolvedAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
|
|
237
|
+
}
|
|
238
|
+
// At this point the path should be resolved to a full absolute path, but
|
|
239
|
+
// handle relative paths to be safe (might happen when process.cwd() fails)
|
|
240
|
+
// Normalize the path
|
|
241
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute, '/', isPosixPathSeparator);
|
|
242
|
+
if (resolvedAbsolute) {
|
|
243
|
+
return `/${resolvedPath}`;
|
|
244
|
+
}
|
|
245
|
+
return resolvedPath.length > 0 ? resolvedPath : '.';
|
|
246
|
+
}
|
|
247
|
+
exports.resolve = resolve;
|
|
248
|
+
function relative(from, to) {
|
|
249
|
+
(0, util_1.validateString)(from, 'from');
|
|
250
|
+
(0, util_1.validateString)(to, 'to');
|
|
251
|
+
if (from === to)
|
|
252
|
+
return '';
|
|
253
|
+
// Trim leading forward slashes.
|
|
254
|
+
from = resolve(from);
|
|
255
|
+
to = resolve(to);
|
|
256
|
+
if (from === to)
|
|
257
|
+
return '';
|
|
258
|
+
const fromStart = 1;
|
|
259
|
+
const fromEnd = from.length;
|
|
260
|
+
const fromLen = fromEnd - fromStart;
|
|
261
|
+
const toStart = 1;
|
|
262
|
+
const toLen = to.length - toStart;
|
|
263
|
+
// Compare paths to find the longest common path from root
|
|
264
|
+
const length = (fromLen < toLen ? fromLen : toLen);
|
|
265
|
+
let lastCommonSep = -1;
|
|
266
|
+
let i = 0;
|
|
267
|
+
for (; i < length; i++) {
|
|
268
|
+
const fromCode = from.charCodeAt(fromStart + i);
|
|
269
|
+
if (fromCode !== to.charCodeAt(toStart + i)) {
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
else if (fromCode === CHAR_FORWARD_SLASH) {
|
|
273
|
+
lastCommonSep = i;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (i === length) {
|
|
277
|
+
if (toLen > length) {
|
|
278
|
+
if (to.charCodeAt(toStart + i) === CHAR_FORWARD_SLASH) {
|
|
279
|
+
// We get here if `from` is the exact base path for `to`.
|
|
280
|
+
// For example: from='/foo/bar'; to='/foo/bar/baz'
|
|
281
|
+
return to.slice(toStart + i + 1);
|
|
282
|
+
}
|
|
283
|
+
if (i === 0) {
|
|
284
|
+
// We get here if `from` is the root
|
|
285
|
+
// For example: from='/'; to='/foo'
|
|
286
|
+
return to.slice(toStart + i);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
else if (fromLen > length) {
|
|
290
|
+
if (from.charCodeAt(fromStart + i) === CHAR_FORWARD_SLASH) {
|
|
291
|
+
// We get here if `to` is the exact base path for `from`.
|
|
292
|
+
// For example: from='/foo/bar/baz'; to='/foo/bar'
|
|
293
|
+
lastCommonSep = i;
|
|
294
|
+
}
|
|
295
|
+
else if (i === 0) {
|
|
296
|
+
// We get here if `to` is the root.
|
|
297
|
+
// For example: from='/foo/bar'; to='/'
|
|
298
|
+
lastCommonSep = 0;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
let out = '';
|
|
303
|
+
// Generate the relative path based on the path difference between `to`
|
|
304
|
+
// and `from`.
|
|
305
|
+
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
|
|
306
|
+
if (i === fromEnd ||
|
|
307
|
+
from.charCodeAt(i) === CHAR_FORWARD_SLASH) {
|
|
308
|
+
out += out.length === 0 ? '..' : '/..';
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
// Lastly, append the rest of the destination (`to`) path that comes after
|
|
312
|
+
// the common path parts.
|
|
313
|
+
return `${out}${to.slice(toStart + lastCommonSep)}`;
|
|
314
|
+
}
|
|
315
|
+
exports.relative = relative;
|
|
316
|
+
//# sourceMappingURL=path.js.map
|