@tailwindcss/oxide-wasm32-wasi 4.3.0 → 4.3.1
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/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js +164 -2
- package/node_modules/@tybys/wasm-util/dist/wasm-util.esm.js +164 -2
- package/node_modules/@tybys/wasm-util/dist/wasm-util.esm.min.js +1 -1
- package/node_modules/@tybys/wasm-util/dist/wasm-util.js +164 -2
- package/node_modules/@tybys/wasm-util/dist/wasm-util.min.js +1 -1
- package/node_modules/@tybys/wasm-util/lib/cjs/wasi/path.js +142 -0
- package/node_modules/@tybys/wasm-util/lib/cjs/wasi/preview1.js +22 -2
- package/node_modules/@tybys/wasm-util/lib/mjs/wasi/path.mjs +142 -0
- package/node_modules/@tybys/wasm-util/lib/mjs/wasi/preview1.mjs +22 -2
- package/node_modules/@tybys/wasm-util/package.json +1 -1
- package/package.json +2 -2
- package/tailwindcss-oxide.wasm32-wasi.wasm +0 -0
- package/wasi-worker-browser.mjs +0 -2
|
@@ -1,6 +1,141 @@
|
|
|
1
1
|
import { validateString } from "./util.mjs";
|
|
2
2
|
const CHAR_DOT = 46; /* . */
|
|
3
3
|
const CHAR_FORWARD_SLASH = 47; /* / */
|
|
4
|
+
const CHAR_BACKWARD_SLASH = 92; /* \ */
|
|
5
|
+
const CHAR_COLON = 58; /* : */
|
|
6
|
+
const CHAR_UPPERCASE_A = 65; /* A */
|
|
7
|
+
const CHAR_UPPERCASE_Z = 90; /* Z */
|
|
8
|
+
const CHAR_LOWERCASE_A = 97; /* a */
|
|
9
|
+
const CHAR_LOWERCASE_Z = 122; /* z */
|
|
10
|
+
function isPathSeparatorWin(code) {
|
|
11
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
12
|
+
}
|
|
13
|
+
function isWindowsDeviceRoot(code) {
|
|
14
|
+
return (code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z) ||
|
|
15
|
+
(code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z);
|
|
16
|
+
}
|
|
17
|
+
const _isWin32 = typeof process !== 'undefined' && process.platform === 'win32';
|
|
18
|
+
/**
|
|
19
|
+
* Windows variant of `resolve()`. Mirrors Node's `path.win32.resolve`
|
|
20
|
+
* semantics enough for the WASI shim's needs (drive-letter absolutes
|
|
21
|
+
* + UNC paths + per-drive cwd lookups via `process.env`/`process.cwd`).
|
|
22
|
+
*
|
|
23
|
+
* Why this is needed: on Windows, `FileDescriptor.realPath` is the
|
|
24
|
+
* host realpath returned by `fs.realpathSync(realPath, 'utf8')` — the
|
|
25
|
+
* backslash form `D:\…`. The POSIX-only `resolveImpl` below only
|
|
26
|
+
* treats `/` as a separator, reads `D` as non-`/`, decides realPath
|
|
27
|
+
* is "relative", and produces a garbage joined path. Downstream
|
|
28
|
+
* `fs.openSync(garbage)` then returns `EINVAL` and the WASI caller
|
|
29
|
+
* sees a permanent failure. This function gives us the correct
|
|
30
|
+
* Windows-style resolution without taking a Node-only `path` import
|
|
31
|
+
* (which would break browser bundles of this package).
|
|
32
|
+
*
|
|
33
|
+
* Cribbed from Node's `lib/path.js` `win32.resolve()` (MIT-licensed),
|
|
34
|
+
* trimmed to what WASI realpath resolution actually exercises.
|
|
35
|
+
*/
|
|
36
|
+
function resolveWin32(args) {
|
|
37
|
+
let resolvedDevice = '';
|
|
38
|
+
let resolvedTail = '';
|
|
39
|
+
let resolvedAbsolute = false;
|
|
40
|
+
for (let i = args.length - 1; i >= -1; i--) {
|
|
41
|
+
let path;
|
|
42
|
+
if (i >= 0) {
|
|
43
|
+
path = args[i];
|
|
44
|
+
validateString(path, 'path');
|
|
45
|
+
if (path.length === 0)
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
else if (resolvedDevice.length === 0) {
|
|
49
|
+
path = (typeof process !== 'undefined' && typeof process.cwd === 'function')
|
|
50
|
+
? process.cwd()
|
|
51
|
+
: '';
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// Look up per-drive cwd via the `=X:` env var convention; fall back
|
|
55
|
+
// to the global cwd if absent.
|
|
56
|
+
const envKey = `=${resolvedDevice}`;
|
|
57
|
+
const env = (typeof process !== 'undefined') ? process.env : undefined;
|
|
58
|
+
path = (env && typeof env[envKey] === 'string')
|
|
59
|
+
? env[envKey]
|
|
60
|
+
: (typeof process !== 'undefined' && typeof process.cwd === 'function')
|
|
61
|
+
? process.cwd()
|
|
62
|
+
: '';
|
|
63
|
+
if (path === undefined ||
|
|
64
|
+
(path.slice(0, 2).toLowerCase() !== resolvedDevice.toLowerCase() &&
|
|
65
|
+
path.charCodeAt(2) === CHAR_BACKWARD_SLASH)) {
|
|
66
|
+
path = `${resolvedDevice}\\`;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const len = path.length;
|
|
70
|
+
let rootEnd = 0;
|
|
71
|
+
let device = '';
|
|
72
|
+
let isAbsolute = false;
|
|
73
|
+
const code = path.charCodeAt(0);
|
|
74
|
+
if (len === 1) {
|
|
75
|
+
if (isPathSeparatorWin(code)) {
|
|
76
|
+
rootEnd = 1;
|
|
77
|
+
isAbsolute = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else if (isPathSeparatorWin(code)) {
|
|
81
|
+
isAbsolute = true;
|
|
82
|
+
if (isPathSeparatorWin(path.charCodeAt(1))) {
|
|
83
|
+
// UNC path: `\\server\share\…`
|
|
84
|
+
let j = 2;
|
|
85
|
+
let last = j;
|
|
86
|
+
while (j < len && !isPathSeparatorWin(path.charCodeAt(j)))
|
|
87
|
+
j++;
|
|
88
|
+
if (j < len && j !== last) {
|
|
89
|
+
const firstPart = path.slice(last, j);
|
|
90
|
+
last = j;
|
|
91
|
+
while (j < len && isPathSeparatorWin(path.charCodeAt(j)))
|
|
92
|
+
j++;
|
|
93
|
+
if (j < len && j !== last) {
|
|
94
|
+
last = j;
|
|
95
|
+
while (j < len && !isPathSeparatorWin(path.charCodeAt(j)))
|
|
96
|
+
j++;
|
|
97
|
+
if (j === len || j !== last) {
|
|
98
|
+
device = `\\\\${firstPart}\\${path.slice(last, j)}`;
|
|
99
|
+
rootEnd = j;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
rootEnd = 1;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else if (isWindowsDeviceRoot(code) && path.charCodeAt(1) === CHAR_COLON) {
|
|
109
|
+
device = path.slice(0, 2);
|
|
110
|
+
rootEnd = 2;
|
|
111
|
+
if (len > 2 && isPathSeparatorWin(path.charCodeAt(2))) {
|
|
112
|
+
isAbsolute = true;
|
|
113
|
+
rootEnd = 3;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (device.length > 0) {
|
|
117
|
+
if (resolvedDevice.length > 0) {
|
|
118
|
+
if (device.toLowerCase() !== resolvedDevice.toLowerCase())
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
resolvedDevice = device;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (resolvedAbsolute) {
|
|
126
|
+
if (resolvedDevice.length > 0)
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
resolvedTail = `${path.slice(rootEnd)}\\${resolvedTail}`;
|
|
131
|
+
resolvedAbsolute = isAbsolute;
|
|
132
|
+
if (isAbsolute && resolvedDevice.length > 0)
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, '\\', isPathSeparatorWin);
|
|
137
|
+
return resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail || '.';
|
|
138
|
+
}
|
|
4
139
|
function isPosixPathSeparator(code) {
|
|
5
140
|
return code === CHAR_FORWARD_SLASH;
|
|
6
141
|
}
|
|
@@ -78,6 +213,13 @@ function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
|
|
|
78
213
|
return res;
|
|
79
214
|
}
|
|
80
215
|
export function resolve(...args) {
|
|
216
|
+
// On Windows, host paths are `D:\…` style. The POSIX-only resolver
|
|
217
|
+
// below treats `D` as a non-`/` character and produces garbage; route
|
|
218
|
+
// to the Windows-aware variant. POSIX hosts (Linux/macOS/browser)
|
|
219
|
+
// run the original code path unchanged — `_isWin32` is constant-folded
|
|
220
|
+
// away on those targets.
|
|
221
|
+
if (_isWin32)
|
|
222
|
+
return resolveWin32(args);
|
|
81
223
|
let resolvedPath = '';
|
|
82
224
|
let resolvedAbsolute = false;
|
|
83
225
|
for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
import { _WebAssembly } from "../webassembly.mjs";
|
|
2
2
|
import { resolve } from "./path.mjs";
|
|
3
|
+
// Linux fcntl flag bits ↔ Windows libuv flag bits. `pathOpen()` builds
|
|
4
|
+
// `flagsRes` using Linux constants (O_CREAT=0x40, O_EXCL=0x80,
|
|
5
|
+
// O_APPEND=0x400). Windows libuv expects different bits (O_CREAT=0x100,
|
|
6
|
+
// O_EXCL=0x400, O_APPEND=0x8). Without translation,
|
|
7
|
+
// `fs.openSync(path, 0x241 /* L:WRONLY|CREAT|TRUNC */)` is rejected
|
|
8
|
+
// with EINVAL because Linux's 0x40 happens to mean O_TEMPORARY on
|
|
9
|
+
// Windows — and O_TEMPORARY without O_CREAT is invalid.
|
|
10
|
+
const _isWin32Flags = typeof process !== 'undefined' && process.platform === 'win32';
|
|
11
|
+
function _toWinOpenFlags(f) {
|
|
12
|
+
let r = f & 3; // RDONLY/WRONLY/RDWR — same on both
|
|
13
|
+
if ((f & 0x40) !== 0)
|
|
14
|
+
r |= 0x100; // O_CREAT: Linux 0x40 -> Windows 0x100
|
|
15
|
+
if ((f & 0x80) !== 0)
|
|
16
|
+
r |= 0x400; // O_EXCL: Linux 0x80 -> Windows 0x400
|
|
17
|
+
if ((f & 0x200) !== 0)
|
|
18
|
+
r |= 0x200; // O_TRUNC: same value on both
|
|
19
|
+
if ((f & 0x400) !== 0)
|
|
20
|
+
r |= 0x8; // O_APPEND: Linux 0x400 -> Windows 0x8
|
|
21
|
+
return r;
|
|
22
|
+
}
|
|
3
23
|
import { WasiErrno, WasiRights, FileControlFlag, WasiFileControlFlag, WasiFdFlag, WasiFileType, WasiClockid, WasiFstFlag, WasiEventType, WasiSubclockflags } from "./types.mjs";
|
|
4
24
|
import { concatBuffer, toFileStat, AsyncTable, SyncTable } from "./fd.mjs";
|
|
5
25
|
import { WasiError } from "./error.mjs";
|
|
@@ -1263,7 +1283,7 @@ export class WASI {
|
|
|
1263
1283
|
const pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
1264
1284
|
const fs = getFs(this);
|
|
1265
1285
|
const resolved_path = resolvePathSync(fs, fileDescriptor, pathString, dirflags);
|
|
1266
|
-
const r = fs.openSync(resolved_path, flagsRes, 0o666);
|
|
1286
|
+
const r = fs.openSync(resolved_path, _isWin32Flags ? _toWinOpenFlags(flagsRes) : flagsRes, 0o666);
|
|
1267
1287
|
const filetype = wasi.fds.getFileTypeByFd(r);
|
|
1268
1288
|
if ((filetype !== WasiFileType.DIRECTORY) &&
|
|
1269
1289
|
((o_flags & WasiFileControlFlag.O_DIRECTORY) !== 0 ||
|
|
@@ -1299,7 +1319,7 @@ export class WASI {
|
|
|
1299
1319
|
const pathString = decoder.decode(unsharedSlice(HEAPU8, path, path + path_len));
|
|
1300
1320
|
const fs = getFs(this);
|
|
1301
1321
|
const resolved_path = await resolvePathAsync(fs, fileDescriptor, pathString, dirflags);
|
|
1302
|
-
const r = await fs.promises.open(resolved_path, flagsRes, 0o666);
|
|
1322
|
+
const r = await fs.promises.open(resolved_path, _isWin32Flags ? _toWinOpenFlags(flagsRes) : flagsRes, 0o666);
|
|
1303
1323
|
const filetype = await wasi.fds.getFileTypeByFd(r);
|
|
1304
1324
|
if ((o_flags & WasiFileControlFlag.O_DIRECTORY) !== 0 && filetype !== WasiFileType.DIRECTORY) {
|
|
1305
1325
|
return WasiErrno.ENOTDIR;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailwindcss/oxide-wasm32-wasi",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.1",
|
|
4
4
|
"cpu": [
|
|
5
5
|
"wasm32"
|
|
6
6
|
],
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@napi-rs/wasm-runtime": "^1.1.4",
|
|
31
31
|
"@emnapi/core": "^1.10.0",
|
|
32
32
|
"@emnapi/runtime": "^1.10.0",
|
|
33
|
-
"@tybys/wasm-util": "^0.10.
|
|
33
|
+
"@tybys/wasm-util": "^0.10.2",
|
|
34
34
|
"@emnapi/wasi-threads": "^1.2.1",
|
|
35
35
|
"tslib": "^2.8.1"
|
|
36
36
|
},
|
|
Binary file
|
package/wasi-worker-browser.mjs
CHANGED