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,221 @@
|
|
|
1
|
+
import {createRequire as __createRequire} from 'module';const require = __createRequire(import.meta.url);
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
+
}) : x)(function(x) {
|
|
5
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// src/chokidar.ts
|
|
10
|
+
import { EventEmitter } from "events";
|
|
11
|
+
|
|
12
|
+
// src/runtime.ts
|
|
13
|
+
var runtime = (() => {
|
|
14
|
+
if (typeof Deno !== "undefined") return "deno";
|
|
15
|
+
if (typeof Bun !== "undefined") return "bun";
|
|
16
|
+
return "node";
|
|
17
|
+
})();
|
|
18
|
+
|
|
19
|
+
// src/chokidar.ts
|
|
20
|
+
function normalizePath(path) {
|
|
21
|
+
return path.replace(/\\/g, "/");
|
|
22
|
+
}
|
|
23
|
+
function emitEvent(watcher, eventType, path) {
|
|
24
|
+
watcher.emit(eventType, path);
|
|
25
|
+
watcher.emit("all", eventType, path);
|
|
26
|
+
}
|
|
27
|
+
function matchesAnyPattern(path, patterns) {
|
|
28
|
+
return patterns.some((pattern) => matchesPattern(path, pattern));
|
|
29
|
+
}
|
|
30
|
+
function handleRenameEvent(watcher, fullPath, fs) {
|
|
31
|
+
try {
|
|
32
|
+
fs.statSync(fullPath);
|
|
33
|
+
emitEvent(watcher, "add", fullPath);
|
|
34
|
+
} catch {
|
|
35
|
+
emitEvent(watcher, "unlink", fullPath);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function setupFsWatch(watcher, baseDir, patterns, fs) {
|
|
39
|
+
try {
|
|
40
|
+
const nativeWatcher = fs.watch(baseDir, { recursive: true }, (eventType, filename) => {
|
|
41
|
+
if (!filename) return;
|
|
42
|
+
const fullPath = normalizePath(`${baseDir}/${filename}`);
|
|
43
|
+
if (!matchesAnyPattern(fullPath, patterns)) return;
|
|
44
|
+
if (eventType === "rename") {
|
|
45
|
+
handleRenameEvent(watcher, fullPath, fs);
|
|
46
|
+
} else if (eventType === "change") {
|
|
47
|
+
emitEvent(watcher, "change", fullPath);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
watcher._setWatcher(nativeWatcher);
|
|
51
|
+
watcher["_watched"].add(baseDir);
|
|
52
|
+
queueMicrotask(() => watcher.emit("ready"));
|
|
53
|
+
} catch (error) {
|
|
54
|
+
watcher.emit("error", error);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
var FSWatcher = class extends EventEmitter {
|
|
58
|
+
constructor(options) {
|
|
59
|
+
super();
|
|
60
|
+
this._closed = false;
|
|
61
|
+
this._watched = /* @__PURE__ */ new Set();
|
|
62
|
+
this.options = options || {};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Add paths to be watched
|
|
66
|
+
*/
|
|
67
|
+
add(paths) {
|
|
68
|
+
if (this._closed) {
|
|
69
|
+
throw new Error("Watcher has been closed");
|
|
70
|
+
}
|
|
71
|
+
const pathArray = Array.isArray(paths) ? paths : [paths];
|
|
72
|
+
if (runtime === "node") {
|
|
73
|
+
if (this._watcher) {
|
|
74
|
+
this._watcher.add(pathArray);
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
pathArray.forEach((path) => this._watched.add(path));
|
|
78
|
+
}
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Stop watching paths
|
|
83
|
+
*/
|
|
84
|
+
unwatch(paths) {
|
|
85
|
+
if (this._closed) {
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
const pathArray = Array.isArray(paths) ? paths : [paths];
|
|
89
|
+
if (runtime === "node") {
|
|
90
|
+
if (this._watcher) {
|
|
91
|
+
this._watcher.unwatch(pathArray);
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
pathArray.forEach((path) => this._watched.delete(path));
|
|
95
|
+
}
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Close the watcher
|
|
100
|
+
*/
|
|
101
|
+
async close() {
|
|
102
|
+
if (this._closed) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
this._closed = true;
|
|
106
|
+
if (runtime === "node") {
|
|
107
|
+
if (this._watcher) {
|
|
108
|
+
await this._watcher.close();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
this.removeAllListeners();
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get watched paths
|
|
115
|
+
*/
|
|
116
|
+
getWatched() {
|
|
117
|
+
if (runtime === "node" && this._watcher) {
|
|
118
|
+
return this._watcher.getWatched();
|
|
119
|
+
}
|
|
120
|
+
const result = {};
|
|
121
|
+
this._watched.forEach((path) => {
|
|
122
|
+
const dir = path.substring(0, path.lastIndexOf("/")) || ".";
|
|
123
|
+
const file = path.substring(path.lastIndexOf("/") + 1);
|
|
124
|
+
if (!result[dir]) {
|
|
125
|
+
result[dir] = [];
|
|
126
|
+
}
|
|
127
|
+
result[dir].push(file);
|
|
128
|
+
});
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Internal method to set native watcher
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
_setWatcher(watcher) {
|
|
136
|
+
this._watcher = watcher;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
function getBaseDirectory(pattern) {
|
|
140
|
+
const parts = pattern.split(/[\\\/]/);
|
|
141
|
+
let baseDir = "";
|
|
142
|
+
for (const part of parts) {
|
|
143
|
+
if (part.includes("*") || part.includes("?")) {
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
baseDir = baseDir ? `${baseDir}/${part}` : part;
|
|
147
|
+
}
|
|
148
|
+
return baseDir || ".";
|
|
149
|
+
}
|
|
150
|
+
function matchesPattern(filePath, pattern) {
|
|
151
|
+
const regexPattern = normalizePath(pattern).replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*").replace(/\?/g, ".");
|
|
152
|
+
const regex = new RegExp(`^${regexPattern}$`);
|
|
153
|
+
const normalizedPath = normalizePath(filePath);
|
|
154
|
+
return regex.test(normalizedPath);
|
|
155
|
+
}
|
|
156
|
+
function watch(paths, options) {
|
|
157
|
+
const watcher = new FSWatcher(options);
|
|
158
|
+
const pathArray = Array.isArray(paths) ? paths : [paths];
|
|
159
|
+
const watchMap = /* @__PURE__ */ new Map();
|
|
160
|
+
pathArray.forEach((path) => {
|
|
161
|
+
const baseDir = getBaseDirectory(path);
|
|
162
|
+
if (!watchMap.has(baseDir)) {
|
|
163
|
+
watchMap.set(baseDir, []);
|
|
164
|
+
}
|
|
165
|
+
watchMap.get(baseDir).push(path);
|
|
166
|
+
});
|
|
167
|
+
if (runtime === "node") {
|
|
168
|
+
const fs = __require("fs");
|
|
169
|
+
watchMap.forEach((patterns, baseDir) => setupFsWatch(watcher, baseDir, patterns, fs));
|
|
170
|
+
} else if (runtime === "bun") {
|
|
171
|
+
const fs = __require("fs");
|
|
172
|
+
watchMap.forEach((patterns, baseDir) => setupFsWatch(watcher, baseDir, patterns, fs));
|
|
173
|
+
} else if (runtime === "deno") {
|
|
174
|
+
const baseDirs = Array.from(watchMap.keys());
|
|
175
|
+
const allPatterns = Array.from(watchMap.values()).flat();
|
|
176
|
+
(async () => {
|
|
177
|
+
try {
|
|
178
|
+
const denoWatcher = Deno.watchFs(baseDirs);
|
|
179
|
+
for await (const event of denoWatcher) {
|
|
180
|
+
if (watcher["_closed"]) break;
|
|
181
|
+
for (const path of event.paths) {
|
|
182
|
+
const normalizedPath = normalizePath(path);
|
|
183
|
+
if (!matchesAnyPattern(normalizedPath, allPatterns)) continue;
|
|
184
|
+
switch (event.kind) {
|
|
185
|
+
case "create":
|
|
186
|
+
emitEvent(watcher, "add", path);
|
|
187
|
+
break;
|
|
188
|
+
case "modify":
|
|
189
|
+
emitEvent(watcher, "change", path);
|
|
190
|
+
break;
|
|
191
|
+
case "remove":
|
|
192
|
+
emitEvent(watcher, "unlink", path);
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
} catch (error) {
|
|
198
|
+
if (!watcher["_closed"]) {
|
|
199
|
+
watcher.emit("error", error);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
})();
|
|
203
|
+
pathArray.forEach((path) => watcher.add(path));
|
|
204
|
+
queueMicrotask(() => watcher.emit("ready"));
|
|
205
|
+
}
|
|
206
|
+
return watcher;
|
|
207
|
+
}
|
|
208
|
+
function getRuntime() {
|
|
209
|
+
return runtime;
|
|
210
|
+
}
|
|
211
|
+
var chokidar_default = {
|
|
212
|
+
watch,
|
|
213
|
+
FSWatcher,
|
|
214
|
+
getRuntime
|
|
215
|
+
};
|
|
216
|
+
export {
|
|
217
|
+
FSWatcher,
|
|
218
|
+
chokidar_default as default,
|
|
219
|
+
getRuntime,
|
|
220
|
+
watch
|
|
221
|
+
};
|