elit 2.0.1 → 3.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 +275 -128
- package/dist/build.d.mts +10 -1
- package/dist/build.d.ts +10 -1
- package/dist/build.js +670 -1
- package/dist/build.mjs +641 -1
- package/dist/chokidar.d.mts +134 -0
- package/dist/chokidar.d.ts +134 -0
- package/dist/chokidar.js +240 -0
- package/dist/chokidar.mjs +221 -0
- package/dist/cli.js +2792 -495
- package/dist/dom.d.mts +10 -3
- package/dist/dom.d.ts +10 -3
- package/dist/dom.js +676 -1
- package/dist/dom.mjs +647 -1
- package/dist/el.d.mts +16 -36
- package/dist/el.d.ts +16 -36
- package/dist/el.js +789 -1
- package/dist/el.mjs +583 -1
- package/dist/fs.d.mts +255 -0
- package/dist/fs.d.ts +255 -0
- package/dist/fs.js +513 -0
- package/dist/fs.mjs +469 -0
- package/dist/hmr.js +112 -1
- package/dist/hmr.mjs +91 -1
- package/dist/http.d.mts +163 -0
- package/dist/http.d.ts +163 -0
- package/dist/http.js +632 -0
- package/dist/http.mjs +605 -0
- package/dist/https.d.mts +108 -0
- package/dist/https.d.ts +108 -0
- package/dist/https.js +907 -0
- package/dist/https.mjs +901 -0
- package/dist/index.d.mts +613 -33
- package/dist/index.d.ts +613 -33
- package/dist/index.js +2589 -1
- package/dist/index.mjs +2312 -1
- package/dist/mime-types.d.mts +48 -0
- package/dist/mime-types.d.ts +48 -0
- package/dist/mime-types.js +197 -0
- package/dist/mime-types.mjs +166 -0
- package/dist/path.d.mts +163 -0
- package/dist/path.d.ts +163 -0
- package/dist/path.js +350 -0
- package/dist/path.mjs +310 -0
- package/dist/router.d.mts +3 -1
- package/dist/router.d.ts +3 -1
- package/dist/router.js +830 -1
- package/dist/router.mjs +801 -1
- package/dist/runtime.d.mts +97 -0
- package/dist/runtime.d.ts +97 -0
- package/dist/runtime.js +43 -0
- package/dist/runtime.mjs +15 -0
- package/dist/server.d.mts +5 -1
- package/dist/server.d.ts +5 -1
- package/dist/server.js +3267 -1
- package/dist/server.mjs +3241 -1
- package/dist/state.d.mts +3 -1
- package/dist/state.d.ts +3 -1
- package/dist/state.js +1036 -1
- package/dist/state.mjs +992 -1
- package/dist/style.d.mts +47 -1
- package/dist/style.d.ts +47 -1
- package/dist/style.js +551 -1
- package/dist/style.mjs +483 -1
- package/dist/{types-DOAdFFJB.d.ts → types-C0nGi6MX.d.mts} +29 -13
- package/dist/{types-DOAdFFJB.d.mts → types-Du6kfwTm.d.ts} +29 -13
- package/dist/types.d.mts +452 -3
- package/dist/types.d.ts +452 -3
- package/dist/types.js +18 -1
- package/dist/ws.d.mts +195 -0
- package/dist/ws.d.ts +195 -0
- package/dist/ws.js +380 -0
- package/dist/ws.mjs +358 -0
- package/dist/wss.d.mts +108 -0
- package/dist/wss.d.ts +108 -0
- package/dist/wss.js +1306 -0
- package/dist/wss.mjs +1300 -0
- package/package.json +53 -6
- package/dist/client.d.mts +0 -9
- package/dist/client.d.ts +0 -9
- package/dist/client.js +0 -1
- package/dist/client.mjs +0 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIME Types module with unified API across runtimes
|
|
3
|
+
* Pure implementation without external dependencies
|
|
4
|
+
* Compatible with 'mime-types' package API
|
|
5
|
+
* Works on Node.js, Bun, and Deno
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Lookup MIME type from file path or extension
|
|
9
|
+
*/
|
|
10
|
+
declare function lookup(path: string): string | false;
|
|
11
|
+
/**
|
|
12
|
+
* Get the default extension for a MIME type
|
|
13
|
+
*/
|
|
14
|
+
declare function extension(type: string): string | false;
|
|
15
|
+
/**
|
|
16
|
+
* Get all extensions for a MIME type
|
|
17
|
+
*/
|
|
18
|
+
declare function extensions(type: string): string[] | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Get the default charset for a MIME type
|
|
21
|
+
*/
|
|
22
|
+
declare function charset(type: string): string | false;
|
|
23
|
+
/**
|
|
24
|
+
* Create a full Content-Type header value
|
|
25
|
+
*/
|
|
26
|
+
declare function contentType(typeOrExt: string): string | false;
|
|
27
|
+
/**
|
|
28
|
+
* Get all MIME types
|
|
29
|
+
*/
|
|
30
|
+
declare const types: Record<string, string>;
|
|
31
|
+
/**
|
|
32
|
+
* Get current runtime
|
|
33
|
+
*/
|
|
34
|
+
declare function getRuntime(): 'node' | 'bun' | 'deno';
|
|
35
|
+
/**
|
|
36
|
+
* Default export
|
|
37
|
+
*/
|
|
38
|
+
declare const _default: {
|
|
39
|
+
lookup: typeof lookup;
|
|
40
|
+
extension: typeof extension;
|
|
41
|
+
extensions: typeof extensions;
|
|
42
|
+
charset: typeof charset;
|
|
43
|
+
contentType: typeof contentType;
|
|
44
|
+
types: Record<string, string>;
|
|
45
|
+
getRuntime: typeof getRuntime;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { charset, contentType, _default as default, extension, extensions, getRuntime, lookup, types };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIME Types module with unified API across runtimes
|
|
3
|
+
* Pure implementation without external dependencies
|
|
4
|
+
* Compatible with 'mime-types' package API
|
|
5
|
+
* Works on Node.js, Bun, and Deno
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Lookup MIME type from file path or extension
|
|
9
|
+
*/
|
|
10
|
+
declare function lookup(path: string): string | false;
|
|
11
|
+
/**
|
|
12
|
+
* Get the default extension for a MIME type
|
|
13
|
+
*/
|
|
14
|
+
declare function extension(type: string): string | false;
|
|
15
|
+
/**
|
|
16
|
+
* Get all extensions for a MIME type
|
|
17
|
+
*/
|
|
18
|
+
declare function extensions(type: string): string[] | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Get the default charset for a MIME type
|
|
21
|
+
*/
|
|
22
|
+
declare function charset(type: string): string | false;
|
|
23
|
+
/**
|
|
24
|
+
* Create a full Content-Type header value
|
|
25
|
+
*/
|
|
26
|
+
declare function contentType(typeOrExt: string): string | false;
|
|
27
|
+
/**
|
|
28
|
+
* Get all MIME types
|
|
29
|
+
*/
|
|
30
|
+
declare const types: Record<string, string>;
|
|
31
|
+
/**
|
|
32
|
+
* Get current runtime
|
|
33
|
+
*/
|
|
34
|
+
declare function getRuntime(): 'node' | 'bun' | 'deno';
|
|
35
|
+
/**
|
|
36
|
+
* Default export
|
|
37
|
+
*/
|
|
38
|
+
declare const _default: {
|
|
39
|
+
lookup: typeof lookup;
|
|
40
|
+
extension: typeof extension;
|
|
41
|
+
extensions: typeof extensions;
|
|
42
|
+
charset: typeof charset;
|
|
43
|
+
contentType: typeof contentType;
|
|
44
|
+
types: Record<string, string>;
|
|
45
|
+
getRuntime: typeof getRuntime;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { charset, contentType, _default as default, extension, extensions, getRuntime, lookup, types };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/mime-types.ts
|
|
21
|
+
var mime_types_exports = {};
|
|
22
|
+
__export(mime_types_exports, {
|
|
23
|
+
charset: () => charset,
|
|
24
|
+
contentType: () => contentType,
|
|
25
|
+
default: () => mime_types_default,
|
|
26
|
+
extension: () => extension,
|
|
27
|
+
extensions: () => extensions,
|
|
28
|
+
getRuntime: () => getRuntime,
|
|
29
|
+
lookup: () => lookup,
|
|
30
|
+
types: () => types
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(mime_types_exports);
|
|
33
|
+
|
|
34
|
+
// src/runtime.ts
|
|
35
|
+
var runtime = (() => {
|
|
36
|
+
if (typeof Deno !== "undefined") return "deno";
|
|
37
|
+
if (typeof Bun !== "undefined") return "bun";
|
|
38
|
+
return "node";
|
|
39
|
+
})();
|
|
40
|
+
|
|
41
|
+
// src/mime-types.ts
|
|
42
|
+
var MIME_TYPES = {
|
|
43
|
+
// Text
|
|
44
|
+
"txt": "text/plain",
|
|
45
|
+
"html": "text/html",
|
|
46
|
+
"htm": "text/html",
|
|
47
|
+
"css": "text/css",
|
|
48
|
+
"js": "text/javascript",
|
|
49
|
+
"mjs": "text/javascript",
|
|
50
|
+
"json": "application/json",
|
|
51
|
+
"xml": "application/xml",
|
|
52
|
+
"csv": "text/csv",
|
|
53
|
+
"md": "text/markdown",
|
|
54
|
+
"markdown": "text/x-markdown",
|
|
55
|
+
// Images
|
|
56
|
+
"png": "image/png",
|
|
57
|
+
"jpg": "image/jpeg",
|
|
58
|
+
"jpeg": "image/jpeg",
|
|
59
|
+
"gif": "image/gif",
|
|
60
|
+
"svg": "image/svg+xml",
|
|
61
|
+
"webp": "image/webp",
|
|
62
|
+
"ico": "image/x-icon",
|
|
63
|
+
"bmp": "image/bmp",
|
|
64
|
+
"tiff": "image/tiff",
|
|
65
|
+
"tif": "image/tiff",
|
|
66
|
+
// Audio
|
|
67
|
+
"mp3": "audio/mpeg",
|
|
68
|
+
"wav": "audio/wav",
|
|
69
|
+
"ogg": "audio/ogg",
|
|
70
|
+
"aac": "audio/aac",
|
|
71
|
+
"m4a": "audio/mp4",
|
|
72
|
+
"flac": "audio/flac",
|
|
73
|
+
// Video
|
|
74
|
+
"mp4": "video/mp4",
|
|
75
|
+
"webm": "video/webm",
|
|
76
|
+
"avi": "video/x-msvideo",
|
|
77
|
+
"mov": "video/quicktime",
|
|
78
|
+
"mkv": "video/x-matroska",
|
|
79
|
+
"flv": "video/x-flv",
|
|
80
|
+
// Application
|
|
81
|
+
"pdf": "application/pdf",
|
|
82
|
+
"zip": "application/zip",
|
|
83
|
+
"gz": "application/gzip",
|
|
84
|
+
"tar": "application/x-tar",
|
|
85
|
+
"rar": "application/x-rar-compressed",
|
|
86
|
+
"7z": "application/x-7z-compressed",
|
|
87
|
+
// Documents
|
|
88
|
+
"doc": "application/msword",
|
|
89
|
+
"docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
90
|
+
"xls": "application/vnd.ms-excel",
|
|
91
|
+
"xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
92
|
+
"ppt": "application/vnd.ms-powerpoint",
|
|
93
|
+
"pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
94
|
+
// Fonts
|
|
95
|
+
"woff": "font/woff",
|
|
96
|
+
"woff2": "font/woff2",
|
|
97
|
+
"ttf": "font/ttf",
|
|
98
|
+
"otf": "font/otf",
|
|
99
|
+
"eot": "application/vnd.ms-fontobject",
|
|
100
|
+
// Web
|
|
101
|
+
"wasm": "application/wasm",
|
|
102
|
+
"manifest": "application/manifest+json",
|
|
103
|
+
// Binary
|
|
104
|
+
"bin": "application/octet-stream",
|
|
105
|
+
"exe": "application/x-msdownload",
|
|
106
|
+
"dll": "application/x-msdownload",
|
|
107
|
+
// TypeScript/Modern JS
|
|
108
|
+
"ts": "text/typescript",
|
|
109
|
+
"tsx": "text/tsx",
|
|
110
|
+
"jsx": "text/jsx"
|
|
111
|
+
};
|
|
112
|
+
var TYPE_TO_EXTENSIONS = {};
|
|
113
|
+
for (const ext in MIME_TYPES) {
|
|
114
|
+
const type = MIME_TYPES[ext];
|
|
115
|
+
if (!TYPE_TO_EXTENSIONS[type]) {
|
|
116
|
+
TYPE_TO_EXTENSIONS[type] = [];
|
|
117
|
+
}
|
|
118
|
+
TYPE_TO_EXTENSIONS[type].push(ext);
|
|
119
|
+
}
|
|
120
|
+
var CHARSETS = {
|
|
121
|
+
"text/plain": "UTF-8",
|
|
122
|
+
"text/html": "UTF-8",
|
|
123
|
+
"text/css": "UTF-8",
|
|
124
|
+
"text/javascript": "UTF-8",
|
|
125
|
+
"application/json": "UTF-8",
|
|
126
|
+
"application/xml": "UTF-8",
|
|
127
|
+
"text/csv": "UTF-8",
|
|
128
|
+
"text/markdown": "UTF-8",
|
|
129
|
+
"text/x-markdown": "UTF-8",
|
|
130
|
+
"text/typescript": "UTF-8",
|
|
131
|
+
"text/tsx": "UTF-8",
|
|
132
|
+
"text/jsx": "UTF-8",
|
|
133
|
+
"application/javascript": "UTF-8"
|
|
134
|
+
};
|
|
135
|
+
function getExtension(path) {
|
|
136
|
+
const match = /\.([^./\\]+)$/.exec(path);
|
|
137
|
+
return match ? match[1].toLowerCase() : "";
|
|
138
|
+
}
|
|
139
|
+
function normalizeMimeType(type) {
|
|
140
|
+
const match = /^([^;\s]+)/.exec(type);
|
|
141
|
+
return match ? match[1].toLowerCase() : "";
|
|
142
|
+
}
|
|
143
|
+
function lookup(path) {
|
|
144
|
+
const ext = getExtension(path) || path.toLowerCase();
|
|
145
|
+
return MIME_TYPES[ext] || false;
|
|
146
|
+
}
|
|
147
|
+
function extension(type) {
|
|
148
|
+
const normalized = normalizeMimeType(type);
|
|
149
|
+
const exts = TYPE_TO_EXTENSIONS[normalized];
|
|
150
|
+
return exts && exts.length > 0 ? exts[0] : false;
|
|
151
|
+
}
|
|
152
|
+
function extensions(type) {
|
|
153
|
+
const normalized = normalizeMimeType(type);
|
|
154
|
+
return TYPE_TO_EXTENSIONS[normalized];
|
|
155
|
+
}
|
|
156
|
+
function charset(type) {
|
|
157
|
+
const normalized = normalizeMimeType(type);
|
|
158
|
+
return CHARSETS[normalized] || false;
|
|
159
|
+
}
|
|
160
|
+
function contentType(typeOrExt) {
|
|
161
|
+
let type;
|
|
162
|
+
if (typeOrExt.includes("/")) {
|
|
163
|
+
type = typeOrExt;
|
|
164
|
+
} else {
|
|
165
|
+
type = lookup(typeOrExt);
|
|
166
|
+
if (!type) return false;
|
|
167
|
+
}
|
|
168
|
+
const normalized = normalizeMimeType(type);
|
|
169
|
+
const charsetValue = CHARSETS[normalized];
|
|
170
|
+
if (charsetValue) {
|
|
171
|
+
return `${normalized}; charset=${charsetValue.toLowerCase()}`;
|
|
172
|
+
}
|
|
173
|
+
return normalized;
|
|
174
|
+
}
|
|
175
|
+
var types = MIME_TYPES;
|
|
176
|
+
function getRuntime() {
|
|
177
|
+
return runtime;
|
|
178
|
+
}
|
|
179
|
+
var mime_types_default = {
|
|
180
|
+
lookup,
|
|
181
|
+
extension,
|
|
182
|
+
extensions,
|
|
183
|
+
charset,
|
|
184
|
+
contentType,
|
|
185
|
+
types,
|
|
186
|
+
getRuntime
|
|
187
|
+
};
|
|
188
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
189
|
+
0 && (module.exports = {
|
|
190
|
+
charset,
|
|
191
|
+
contentType,
|
|
192
|
+
extension,
|
|
193
|
+
extensions,
|
|
194
|
+
getRuntime,
|
|
195
|
+
lookup,
|
|
196
|
+
types
|
|
197
|
+
});
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import {createRequire as __createRequire} from 'module';const require = __createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/runtime.ts
|
|
4
|
+
var runtime = (() => {
|
|
5
|
+
if (typeof Deno !== "undefined") return "deno";
|
|
6
|
+
if (typeof Bun !== "undefined") return "bun";
|
|
7
|
+
return "node";
|
|
8
|
+
})();
|
|
9
|
+
|
|
10
|
+
// src/mime-types.ts
|
|
11
|
+
var MIME_TYPES = {
|
|
12
|
+
// Text
|
|
13
|
+
"txt": "text/plain",
|
|
14
|
+
"html": "text/html",
|
|
15
|
+
"htm": "text/html",
|
|
16
|
+
"css": "text/css",
|
|
17
|
+
"js": "text/javascript",
|
|
18
|
+
"mjs": "text/javascript",
|
|
19
|
+
"json": "application/json",
|
|
20
|
+
"xml": "application/xml",
|
|
21
|
+
"csv": "text/csv",
|
|
22
|
+
"md": "text/markdown",
|
|
23
|
+
"markdown": "text/x-markdown",
|
|
24
|
+
// Images
|
|
25
|
+
"png": "image/png",
|
|
26
|
+
"jpg": "image/jpeg",
|
|
27
|
+
"jpeg": "image/jpeg",
|
|
28
|
+
"gif": "image/gif",
|
|
29
|
+
"svg": "image/svg+xml",
|
|
30
|
+
"webp": "image/webp",
|
|
31
|
+
"ico": "image/x-icon",
|
|
32
|
+
"bmp": "image/bmp",
|
|
33
|
+
"tiff": "image/tiff",
|
|
34
|
+
"tif": "image/tiff",
|
|
35
|
+
// Audio
|
|
36
|
+
"mp3": "audio/mpeg",
|
|
37
|
+
"wav": "audio/wav",
|
|
38
|
+
"ogg": "audio/ogg",
|
|
39
|
+
"aac": "audio/aac",
|
|
40
|
+
"m4a": "audio/mp4",
|
|
41
|
+
"flac": "audio/flac",
|
|
42
|
+
// Video
|
|
43
|
+
"mp4": "video/mp4",
|
|
44
|
+
"webm": "video/webm",
|
|
45
|
+
"avi": "video/x-msvideo",
|
|
46
|
+
"mov": "video/quicktime",
|
|
47
|
+
"mkv": "video/x-matroska",
|
|
48
|
+
"flv": "video/x-flv",
|
|
49
|
+
// Application
|
|
50
|
+
"pdf": "application/pdf",
|
|
51
|
+
"zip": "application/zip",
|
|
52
|
+
"gz": "application/gzip",
|
|
53
|
+
"tar": "application/x-tar",
|
|
54
|
+
"rar": "application/x-rar-compressed",
|
|
55
|
+
"7z": "application/x-7z-compressed",
|
|
56
|
+
// Documents
|
|
57
|
+
"doc": "application/msword",
|
|
58
|
+
"docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
59
|
+
"xls": "application/vnd.ms-excel",
|
|
60
|
+
"xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
61
|
+
"ppt": "application/vnd.ms-powerpoint",
|
|
62
|
+
"pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
63
|
+
// Fonts
|
|
64
|
+
"woff": "font/woff",
|
|
65
|
+
"woff2": "font/woff2",
|
|
66
|
+
"ttf": "font/ttf",
|
|
67
|
+
"otf": "font/otf",
|
|
68
|
+
"eot": "application/vnd.ms-fontobject",
|
|
69
|
+
// Web
|
|
70
|
+
"wasm": "application/wasm",
|
|
71
|
+
"manifest": "application/manifest+json",
|
|
72
|
+
// Binary
|
|
73
|
+
"bin": "application/octet-stream",
|
|
74
|
+
"exe": "application/x-msdownload",
|
|
75
|
+
"dll": "application/x-msdownload",
|
|
76
|
+
// TypeScript/Modern JS
|
|
77
|
+
"ts": "text/typescript",
|
|
78
|
+
"tsx": "text/tsx",
|
|
79
|
+
"jsx": "text/jsx"
|
|
80
|
+
};
|
|
81
|
+
var TYPE_TO_EXTENSIONS = {};
|
|
82
|
+
for (const ext in MIME_TYPES) {
|
|
83
|
+
const type = MIME_TYPES[ext];
|
|
84
|
+
if (!TYPE_TO_EXTENSIONS[type]) {
|
|
85
|
+
TYPE_TO_EXTENSIONS[type] = [];
|
|
86
|
+
}
|
|
87
|
+
TYPE_TO_EXTENSIONS[type].push(ext);
|
|
88
|
+
}
|
|
89
|
+
var CHARSETS = {
|
|
90
|
+
"text/plain": "UTF-8",
|
|
91
|
+
"text/html": "UTF-8",
|
|
92
|
+
"text/css": "UTF-8",
|
|
93
|
+
"text/javascript": "UTF-8",
|
|
94
|
+
"application/json": "UTF-8",
|
|
95
|
+
"application/xml": "UTF-8",
|
|
96
|
+
"text/csv": "UTF-8",
|
|
97
|
+
"text/markdown": "UTF-8",
|
|
98
|
+
"text/x-markdown": "UTF-8",
|
|
99
|
+
"text/typescript": "UTF-8",
|
|
100
|
+
"text/tsx": "UTF-8",
|
|
101
|
+
"text/jsx": "UTF-8",
|
|
102
|
+
"application/javascript": "UTF-8"
|
|
103
|
+
};
|
|
104
|
+
function getExtension(path) {
|
|
105
|
+
const match = /\.([^./\\]+)$/.exec(path);
|
|
106
|
+
return match ? match[1].toLowerCase() : "";
|
|
107
|
+
}
|
|
108
|
+
function normalizeMimeType(type) {
|
|
109
|
+
const match = /^([^;\s]+)/.exec(type);
|
|
110
|
+
return match ? match[1].toLowerCase() : "";
|
|
111
|
+
}
|
|
112
|
+
function lookup(path) {
|
|
113
|
+
const ext = getExtension(path) || path.toLowerCase();
|
|
114
|
+
return MIME_TYPES[ext] || false;
|
|
115
|
+
}
|
|
116
|
+
function extension(type) {
|
|
117
|
+
const normalized = normalizeMimeType(type);
|
|
118
|
+
const exts = TYPE_TO_EXTENSIONS[normalized];
|
|
119
|
+
return exts && exts.length > 0 ? exts[0] : false;
|
|
120
|
+
}
|
|
121
|
+
function extensions(type) {
|
|
122
|
+
const normalized = normalizeMimeType(type);
|
|
123
|
+
return TYPE_TO_EXTENSIONS[normalized];
|
|
124
|
+
}
|
|
125
|
+
function charset(type) {
|
|
126
|
+
const normalized = normalizeMimeType(type);
|
|
127
|
+
return CHARSETS[normalized] || false;
|
|
128
|
+
}
|
|
129
|
+
function contentType(typeOrExt) {
|
|
130
|
+
let type;
|
|
131
|
+
if (typeOrExt.includes("/")) {
|
|
132
|
+
type = typeOrExt;
|
|
133
|
+
} else {
|
|
134
|
+
type = lookup(typeOrExt);
|
|
135
|
+
if (!type) return false;
|
|
136
|
+
}
|
|
137
|
+
const normalized = normalizeMimeType(type);
|
|
138
|
+
const charsetValue = CHARSETS[normalized];
|
|
139
|
+
if (charsetValue) {
|
|
140
|
+
return `${normalized}; charset=${charsetValue.toLowerCase()}`;
|
|
141
|
+
}
|
|
142
|
+
return normalized;
|
|
143
|
+
}
|
|
144
|
+
var types = MIME_TYPES;
|
|
145
|
+
function getRuntime() {
|
|
146
|
+
return runtime;
|
|
147
|
+
}
|
|
148
|
+
var mime_types_default = {
|
|
149
|
+
lookup,
|
|
150
|
+
extension,
|
|
151
|
+
extensions,
|
|
152
|
+
charset,
|
|
153
|
+
contentType,
|
|
154
|
+
types,
|
|
155
|
+
getRuntime
|
|
156
|
+
};
|
|
157
|
+
export {
|
|
158
|
+
charset,
|
|
159
|
+
contentType,
|
|
160
|
+
mime_types_default as default,
|
|
161
|
+
extension,
|
|
162
|
+
extensions,
|
|
163
|
+
getRuntime,
|
|
164
|
+
lookup,
|
|
165
|
+
types
|
|
166
|
+
};
|
package/dist/path.d.mts
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path module with unified API across runtimes
|
|
3
|
+
* Pure implementation without external dependencies
|
|
4
|
+
* Compatible with Node.js 'path' module API
|
|
5
|
+
* Works on Node.js, Bun, and Deno
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Path separator
|
|
9
|
+
*/
|
|
10
|
+
declare const sep: string;
|
|
11
|
+
/**
|
|
12
|
+
* Path delimiter
|
|
13
|
+
*/
|
|
14
|
+
declare const delimiter: string;
|
|
15
|
+
/**
|
|
16
|
+
* POSIX path operations
|
|
17
|
+
*/
|
|
18
|
+
declare const posix: {
|
|
19
|
+
sep: string;
|
|
20
|
+
delimiter: string;
|
|
21
|
+
normalize: (path: string) => string;
|
|
22
|
+
join: (...paths: string[]) => string;
|
|
23
|
+
resolve: (...paths: string[]) => string;
|
|
24
|
+
isAbsolute: (path: string) => boolean;
|
|
25
|
+
relative: (from: string, to: string) => string;
|
|
26
|
+
dirname: (path: string) => string;
|
|
27
|
+
basename: (path: string, ext?: string) => string;
|
|
28
|
+
extname: (path: string) => string;
|
|
29
|
+
parse: (path: string) => ParsedPath;
|
|
30
|
+
format: (pathObject: FormatInputPathObject) => string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Windows path operations
|
|
34
|
+
*/
|
|
35
|
+
declare const win32: {
|
|
36
|
+
sep: string;
|
|
37
|
+
delimiter: string;
|
|
38
|
+
normalize: (path: string) => string;
|
|
39
|
+
join: (...paths: string[]) => string;
|
|
40
|
+
resolve: (...paths: string[]) => string;
|
|
41
|
+
isAbsolute: (path: string) => boolean;
|
|
42
|
+
relative: (from: string, to: string) => string;
|
|
43
|
+
dirname: (path: string) => string;
|
|
44
|
+
basename: (path: string, ext?: string) => string;
|
|
45
|
+
extname: (path: string) => string;
|
|
46
|
+
parse: (path: string) => ParsedPath;
|
|
47
|
+
format: (pathObject: FormatInputPathObject) => string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Path object interface
|
|
51
|
+
*/
|
|
52
|
+
interface ParsedPath {
|
|
53
|
+
root: string;
|
|
54
|
+
dir: string;
|
|
55
|
+
base: string;
|
|
56
|
+
ext: string;
|
|
57
|
+
name: string;
|
|
58
|
+
}
|
|
59
|
+
interface FormatInputPathObject {
|
|
60
|
+
root?: string;
|
|
61
|
+
dir?: string;
|
|
62
|
+
base?: string;
|
|
63
|
+
ext?: string;
|
|
64
|
+
name?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Normalize a path (platform-specific)
|
|
68
|
+
*/
|
|
69
|
+
declare function normalize(path: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Join paths (platform-specific)
|
|
72
|
+
*/
|
|
73
|
+
declare function join(...paths: string[]): string;
|
|
74
|
+
/**
|
|
75
|
+
* Resolve paths to absolute path (platform-specific)
|
|
76
|
+
*/
|
|
77
|
+
declare function resolve(...paths: string[]): string;
|
|
78
|
+
/**
|
|
79
|
+
* Check if path is absolute (platform-specific)
|
|
80
|
+
*/
|
|
81
|
+
declare function isAbsolute(path: string): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Get relative path (platform-specific)
|
|
84
|
+
*/
|
|
85
|
+
declare function relative(from: string, to: string): string;
|
|
86
|
+
/**
|
|
87
|
+
* Get directory name (platform-specific)
|
|
88
|
+
*/
|
|
89
|
+
declare function dirname(path: string): string;
|
|
90
|
+
/**
|
|
91
|
+
* Get base name (platform-specific)
|
|
92
|
+
*/
|
|
93
|
+
declare function basename(path: string, ext?: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* Get extension name
|
|
96
|
+
*/
|
|
97
|
+
declare function extname(path: string): string;
|
|
98
|
+
/**
|
|
99
|
+
* Parse path into components (platform-specific)
|
|
100
|
+
*/
|
|
101
|
+
declare function parse(path: string): ParsedPath;
|
|
102
|
+
/**
|
|
103
|
+
* Format path from components (platform-specific)
|
|
104
|
+
*/
|
|
105
|
+
declare function format(pathObject: FormatInputPathObject): string;
|
|
106
|
+
/**
|
|
107
|
+
* Convert to namespaced path (Windows only)
|
|
108
|
+
*/
|
|
109
|
+
declare function toNamespacedPath(path: string): string;
|
|
110
|
+
/**
|
|
111
|
+
* Get current runtime
|
|
112
|
+
*/
|
|
113
|
+
declare function getRuntime(): 'node' | 'bun' | 'deno';
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Default export
|
|
117
|
+
*/
|
|
118
|
+
declare const _default: {
|
|
119
|
+
sep: string;
|
|
120
|
+
delimiter: string;
|
|
121
|
+
normalize: typeof normalize;
|
|
122
|
+
join: typeof join;
|
|
123
|
+
resolve: typeof resolve;
|
|
124
|
+
isAbsolute: typeof isAbsolute;
|
|
125
|
+
relative: typeof relative;
|
|
126
|
+
dirname: typeof dirname;
|
|
127
|
+
basename: typeof basename;
|
|
128
|
+
extname: typeof extname;
|
|
129
|
+
parse: typeof parse;
|
|
130
|
+
format: typeof format;
|
|
131
|
+
toNamespacedPath: typeof toNamespacedPath;
|
|
132
|
+
posix: {
|
|
133
|
+
sep: string;
|
|
134
|
+
delimiter: string;
|
|
135
|
+
normalize: (path: string) => string;
|
|
136
|
+
join: (...paths: string[]) => string;
|
|
137
|
+
resolve: (...paths: string[]) => string;
|
|
138
|
+
isAbsolute: (path: string) => boolean;
|
|
139
|
+
relative: (from: string, to: string) => string;
|
|
140
|
+
dirname: (path: string) => string;
|
|
141
|
+
basename: (path: string, ext?: string) => string;
|
|
142
|
+
extname: (path: string) => string;
|
|
143
|
+
parse: (path: string) => ParsedPath;
|
|
144
|
+
format: (pathObject: FormatInputPathObject) => string;
|
|
145
|
+
};
|
|
146
|
+
win32: {
|
|
147
|
+
sep: string;
|
|
148
|
+
delimiter: string;
|
|
149
|
+
normalize: (path: string) => string;
|
|
150
|
+
join: (...paths: string[]) => string;
|
|
151
|
+
resolve: (...paths: string[]) => string;
|
|
152
|
+
isAbsolute: (path: string) => boolean;
|
|
153
|
+
relative: (from: string, to: string) => string;
|
|
154
|
+
dirname: (path: string) => string;
|
|
155
|
+
basename: (path: string, ext?: string) => string;
|
|
156
|
+
extname: (path: string) => string;
|
|
157
|
+
parse: (path: string) => ParsedPath;
|
|
158
|
+
format: (pathObject: FormatInputPathObject) => string;
|
|
159
|
+
};
|
|
160
|
+
getRuntime: typeof getRuntime;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export { type FormatInputPathObject, type ParsedPath, basename, _default as default, delimiter, dirname, extname, format, getRuntime, isAbsolute, join, normalize, parse, posix, relative, resolve, sep, toNamespacedPath, win32 };
|