elit 3.1.7 → 3.1.8
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/dist/build.d.mts +1 -1
- package/dist/cli.js +87 -25
- package/dist/database.d.mts +1 -1
- package/dist/database.d.ts +1 -1
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +76 -833
- package/dist/database.mjs +78 -842
- package/dist/http.d.mts +3 -0
- package/dist/http.d.ts +3 -0
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +23 -0
- package/dist/http.mjs +23 -0
- package/dist/https.js +23 -0
- package/dist/https.mjs +23 -0
- package/dist/{server-R_AfcxRw.d.ts → server-BFOHbYb6.d.ts} +19 -14
- package/dist/{server-CRNme9Bc.d.mts → server-BPVoq5Xi.d.mts} +19 -14
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +18 -13
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +89 -50
- package/dist/server.mjs +89 -50
- package/dist/types.d.mts +21 -13
- package/dist/wss.js +23 -0
- package/dist/wss.mjs +23 -0
- package/package.json +1 -1
- package/src/database.ts +93 -24
- package/src/http.ts +26 -0
- package/src/server.ts +32 -47
package/dist/build.d.mts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -1163,6 +1163,29 @@ var init_http = __esm({
|
|
|
1163
1163
|
_setResolver(resolve2) {
|
|
1164
1164
|
this._resolve = resolve2;
|
|
1165
1165
|
}
|
|
1166
|
+
// Express.js-like methods
|
|
1167
|
+
json(data, statusCode = 200) {
|
|
1168
|
+
if (!this.headersSent) {
|
|
1169
|
+
this.setHeader("Content-Type", "application/json");
|
|
1170
|
+
}
|
|
1171
|
+
this.statusCode = statusCode;
|
|
1172
|
+
this.end(JSON.stringify(data));
|
|
1173
|
+
return this;
|
|
1174
|
+
}
|
|
1175
|
+
send(data) {
|
|
1176
|
+
if (typeof data === "object") {
|
|
1177
|
+
return this.json(data);
|
|
1178
|
+
}
|
|
1179
|
+
if (!this.headersSent) {
|
|
1180
|
+
this.setHeader("Content-Type", "text/plain");
|
|
1181
|
+
}
|
|
1182
|
+
this.end(String(data));
|
|
1183
|
+
return this;
|
|
1184
|
+
}
|
|
1185
|
+
status(code) {
|
|
1186
|
+
this.statusCode = code;
|
|
1187
|
+
return this;
|
|
1188
|
+
}
|
|
1166
1189
|
};
|
|
1167
1190
|
Server = class extends import_node_events.EventEmitter {
|
|
1168
1191
|
constructor(requestListener) {
|
|
@@ -1412,7 +1435,7 @@ var require_package = __commonJS({
|
|
|
1412
1435
|
"package.json"(exports2, module2) {
|
|
1413
1436
|
module2.exports = {
|
|
1414
1437
|
name: "elit",
|
|
1415
|
-
version: "3.1.
|
|
1438
|
+
version: "3.1.8",
|
|
1416
1439
|
description: "Optimized lightweight library for creating DOM elements with reactive state",
|
|
1417
1440
|
main: "dist/index.js",
|
|
1418
1441
|
module: "dist/index.mjs",
|
|
@@ -3103,26 +3126,66 @@ var Database = class {
|
|
|
3103
3126
|
let stringCode;
|
|
3104
3127
|
if (typeof code === "function") {
|
|
3105
3128
|
const funcStr = code.toString();
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
const trimmed = importArg.trim();
|
|
3117
|
-
if (trimmed.startsWith("{") && trimmed.endsWith("}")) {
|
|
3118
|
-
const inner = trimmed.slice(1, -1).trim();
|
|
3119
|
-
return `import { ${inner} } from ${quote}${modulePath}${quote}`;
|
|
3120
|
-
} else {
|
|
3121
|
-
return `import ${trimmed} from ${quote}${modulePath}${quote}`;
|
|
3122
|
-
}
|
|
3129
|
+
if (funcStr.includes("=>")) {
|
|
3130
|
+
const arrowIndex = funcStr.indexOf("=>");
|
|
3131
|
+
let start = arrowIndex + 2;
|
|
3132
|
+
while (start < funcStr.length && funcStr[start] === " ") start++;
|
|
3133
|
+
if (funcStr[start] === "{") start++;
|
|
3134
|
+
let end = funcStr.lastIndexOf("}");
|
|
3135
|
+
if (start < end) {
|
|
3136
|
+
stringCode = funcStr.substring(start, end);
|
|
3137
|
+
} else {
|
|
3138
|
+
stringCode = funcStr.substring(start);
|
|
3123
3139
|
}
|
|
3124
|
-
)
|
|
3125
|
-
|
|
3140
|
+
} else if (funcStr.includes("function")) {
|
|
3141
|
+
const funcIndex = funcStr.indexOf("function");
|
|
3142
|
+
let start = funcIndex + 8;
|
|
3143
|
+
while (start < funcStr.length && funcStr[start] === " ") start++;
|
|
3144
|
+
if (funcStr[start] === "(") start++;
|
|
3145
|
+
if (start < funcStr.length && funcStr[start] !== "(") {
|
|
3146
|
+
while (start < funcStr.length && funcStr[start] !== " " && funcStr[start] !== "(") start++;
|
|
3147
|
+
}
|
|
3148
|
+
if (funcStr[start] === "(") start++;
|
|
3149
|
+
while (start < funcStr.length && funcStr[start] === " ") start++;
|
|
3150
|
+
if (funcStr[start] === "{") start++;
|
|
3151
|
+
const end = funcStr.lastIndexOf("}");
|
|
3152
|
+
if (start < end) {
|
|
3153
|
+
stringCode = funcStr.substring(start, end);
|
|
3154
|
+
} else {
|
|
3155
|
+
stringCode = funcStr.substring(start);
|
|
3156
|
+
}
|
|
3157
|
+
} else {
|
|
3158
|
+
stringCode = funcStr;
|
|
3159
|
+
}
|
|
3160
|
+
stringCode = stringCode.trim();
|
|
3161
|
+
let importPos = 0;
|
|
3162
|
+
while ((importPos = stringCode.indexOf("import(", importPos)) !== -1) {
|
|
3163
|
+
const fromPos = stringCode.indexOf(".from(", importPos);
|
|
3164
|
+
if (fromPos === -1) break;
|
|
3165
|
+
const quoteStart = stringCode.indexOf("(", fromPos + 7) + 1;
|
|
3166
|
+
if (quoteStart === -1) break;
|
|
3167
|
+
const quoteChar = stringCode[quoteStart];
|
|
3168
|
+
if (quoteChar !== '"' && quoteChar !== "'") break;
|
|
3169
|
+
const quoteEnd = stringCode.indexOf(quoteChar, quoteStart + 1);
|
|
3170
|
+
if (quoteEnd === -1) break;
|
|
3171
|
+
const modulePath = stringCode.substring(quoteStart + 1, quoteEnd);
|
|
3172
|
+
const importArgEnd = fromPos - 1;
|
|
3173
|
+
const importArgStart = importPos + 7;
|
|
3174
|
+
const trimmed = stringCode.substring(importArgStart, importArgEnd).trim();
|
|
3175
|
+
let replacement;
|
|
3176
|
+
if (trimmed.startsWith("{") && trimmed.endsWith("}")) {
|
|
3177
|
+
const inner = trimmed.slice(1, -1).trim();
|
|
3178
|
+
replacement = `import { ${inner} } from "${modulePath}"`;
|
|
3179
|
+
} else {
|
|
3180
|
+
replacement = `import ${trimmed} from "${modulePath}"`;
|
|
3181
|
+
}
|
|
3182
|
+
const before = stringCode.substring(0, importPos);
|
|
3183
|
+
const after = stringCode.substring(quoteEnd + 2);
|
|
3184
|
+
stringCode = before + replacement + after;
|
|
3185
|
+
}
|
|
3186
|
+
const lines = stringCode.split("\n");
|
|
3187
|
+
const trimmedLines = lines.map((line) => line.trim());
|
|
3188
|
+
stringCode = trimmedLines.join("\n").trim();
|
|
3126
3189
|
} else {
|
|
3127
3190
|
stringCode = code;
|
|
3128
3191
|
}
|
|
@@ -3153,7 +3216,6 @@ var Database = class {
|
|
|
3153
3216
|
return await this.vmRun(code, options);
|
|
3154
3217
|
}
|
|
3155
3218
|
};
|
|
3156
|
-
var database = serverDatabase.database;
|
|
3157
3219
|
|
|
3158
3220
|
// src/server.ts
|
|
3159
3221
|
var ServerDatabase = class {
|
|
@@ -3168,7 +3230,7 @@ var ServerDatabase = class {
|
|
|
3168
3230
|
}
|
|
3169
3231
|
};
|
|
3170
3232
|
var serverDatabase = new ServerDatabase();
|
|
3171
|
-
var
|
|
3233
|
+
var database = serverDatabase.database;
|
|
3172
3234
|
var json = (res, data, status = 200) => (res.writeHead(status, { "Content-Type": "application/json" }), res.end(JSON.stringify(data)));
|
|
3173
3235
|
var sendError = (res, code, msg) => {
|
|
3174
3236
|
res.writeHead(code, { "Content-Type": "text/plain" });
|
|
@@ -3625,9 +3687,9 @@ function createDevServer(options) {
|
|
|
3625
3687
|
if (config.mode === "dev") {
|
|
3626
3688
|
clearImportMapCache();
|
|
3627
3689
|
}
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
}
|
|
3690
|
+
serverDatabase.initialize(config.database ? config.database : {
|
|
3691
|
+
dir: resolve(process.cwd(), "databases")
|
|
3692
|
+
});
|
|
3631
3693
|
const clientsToNormalize = config.clients?.length ? config.clients : config.root ? [{ root: config.root, basePath: config.basePath || "", index: config.index, ssr: config.ssr, api: config.api, proxy: config.proxy, mode: config.mode }] : null;
|
|
3632
3694
|
if (!clientsToNormalize) throw new Error('DevServerOptions must include either "clients" array or "root" directory');
|
|
3633
3695
|
const normalizedClients = clientsToNormalize.map((client) => {
|
package/dist/database.d.mts
CHANGED
package/dist/database.d.ts
CHANGED
package/dist/database.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAMzB,MAAM,WAAW,cAAc;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,eAAe,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;CAC5C;AAED,qBAAa,QAAQ;IACjB,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,gBAAgB,CAAyB;IACjD,OAAO,CAAC,OAAO,CAEb;gBAEU,MAAM,EAAE,cAAc;IAMlC,IAAI,MAAM,CAAC,MAAM,EAAE,cAAc,EAEhC;IAED,OAAO,CAAC,QAAQ;IAMhB,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG;IAI7C,OAAO,CAAC,WAAW;YAwBL,YAAY;YA8BZ,KAAK;IAuInB;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,kBAAkB,GAAG,MAAM;;;;CAIlF;AAID,wBAAgB,QAAQ,aAIvB;AAED,eAAe,QAAQ,CAAC"}
|