elit 3.2.4 → 3.2.5
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/cli.js +1 -1
- package/dist/database.d.mts +1 -0
- package/dist/database.d.ts +1 -0
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +29 -5
- package/dist/database.mjs +29 -5
- package/package.json +1 -1
- package/src/database.ts +35 -6
package/dist/cli.js
CHANGED
|
@@ -1435,7 +1435,7 @@ var require_package = __commonJS({
|
|
|
1435
1435
|
"package.json"(exports2, module2) {
|
|
1436
1436
|
module2.exports = {
|
|
1437
1437
|
name: "elit",
|
|
1438
|
-
version: "3.2.
|
|
1438
|
+
version: "3.2.5",
|
|
1439
1439
|
description: "Optimized lightweight library for creating DOM elements with reactive state",
|
|
1440
1440
|
main: "dist/index.js",
|
|
1441
1441
|
module: "dist/index.mjs",
|
package/dist/database.d.mts
CHANGED
package/dist/database.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class Database {
|
|
|
12
12
|
private _registerModules;
|
|
13
13
|
private _config;
|
|
14
14
|
constructor(config: DatabaseConfig);
|
|
15
|
+
private _initTranspiler;
|
|
15
16
|
set config(config: DatabaseConfig);
|
|
16
17
|
private register;
|
|
17
18
|
plugin(moduleName: string, moduleContent: any): void;
|
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;AAKzB,MAAM,WAAW,cAAc;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,eAAe,CAAC,EAAE;QAAE,CAAC,GAAG,EA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.js
CHANGED
|
@@ -267,7 +267,6 @@ function resolve(...paths) {
|
|
|
267
267
|
// src/database.ts
|
|
268
268
|
var import_node_path = __toESM(require("path"));
|
|
269
269
|
var import_node_fs = __toESM(require("fs"));
|
|
270
|
-
var import_bun = __toESM(require("bun"));
|
|
271
270
|
var Database = class {
|
|
272
271
|
constructor(config) {
|
|
273
272
|
this._config = {
|
|
@@ -276,9 +275,33 @@ var Database = class {
|
|
|
276
275
|
this._config = { ...this._config, ...config };
|
|
277
276
|
this._registerModules = config.registerModules || {};
|
|
278
277
|
this._ctx = import_node_vm.default.createContext(this._registerModules);
|
|
279
|
-
this.
|
|
280
|
-
|
|
281
|
-
|
|
278
|
+
this._initTranspiler();
|
|
279
|
+
}
|
|
280
|
+
async _initTranspiler() {
|
|
281
|
+
if (!this._transpiler) {
|
|
282
|
+
try {
|
|
283
|
+
const BunModule = await import("bun");
|
|
284
|
+
this._transpiler = new BunModule.default.Transpiler({
|
|
285
|
+
loader: this._config.language || "ts"
|
|
286
|
+
});
|
|
287
|
+
} catch {
|
|
288
|
+
const { buildSync } = await import("esbuild");
|
|
289
|
+
this._transpiler = {
|
|
290
|
+
transformSync: (code) => {
|
|
291
|
+
const result = buildSync({
|
|
292
|
+
stdin: { contents: code },
|
|
293
|
+
loader: this._config.language === "ts" ? "ts" : "js",
|
|
294
|
+
format: "esm",
|
|
295
|
+
platform: "node",
|
|
296
|
+
target: "es2020",
|
|
297
|
+
bundle: false
|
|
298
|
+
});
|
|
299
|
+
return result.outputFiles?.[0]?.text || "";
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return this._transpiler;
|
|
282
305
|
}
|
|
283
306
|
set config(config) {
|
|
284
307
|
this._config = { ...this._config, ...config };
|
|
@@ -412,7 +435,8 @@ var Database = class {
|
|
|
412
435
|
} else {
|
|
413
436
|
stringCode = code;
|
|
414
437
|
}
|
|
415
|
-
const
|
|
438
|
+
const transpiler = await this._initTranspiler();
|
|
439
|
+
const js = transpiler.transformSync(stringCode);
|
|
416
440
|
const mod = new import_node_vm.default.SourceTextModule(js, { context: this._ctx, identifier: import_node_path.default.join(this._config.dir || resolve(process.cwd(), "databases"), "virtual-entry.js") });
|
|
417
441
|
await mod.link(this.moduleLinker.bind(this));
|
|
418
442
|
await mod.evaluate();
|
package/dist/database.mjs
CHANGED
|
@@ -232,7 +232,6 @@ function resolve(...paths) {
|
|
|
232
232
|
// src/database.ts
|
|
233
233
|
import path from "path";
|
|
234
234
|
import fs from "fs";
|
|
235
|
-
import Bun2 from "bun";
|
|
236
235
|
var Database = class {
|
|
237
236
|
constructor(config) {
|
|
238
237
|
this._config = {
|
|
@@ -241,9 +240,33 @@ var Database = class {
|
|
|
241
240
|
this._config = { ...this._config, ...config };
|
|
242
241
|
this._registerModules = config.registerModules || {};
|
|
243
242
|
this._ctx = vm.createContext(this._registerModules);
|
|
244
|
-
this.
|
|
245
|
-
|
|
246
|
-
|
|
243
|
+
this._initTranspiler();
|
|
244
|
+
}
|
|
245
|
+
async _initTranspiler() {
|
|
246
|
+
if (!this._transpiler) {
|
|
247
|
+
try {
|
|
248
|
+
const BunModule = await import("bun");
|
|
249
|
+
this._transpiler = new BunModule.default.Transpiler({
|
|
250
|
+
loader: this._config.language || "ts"
|
|
251
|
+
});
|
|
252
|
+
} catch {
|
|
253
|
+
const { buildSync } = await import("esbuild");
|
|
254
|
+
this._transpiler = {
|
|
255
|
+
transformSync: (code) => {
|
|
256
|
+
const result = buildSync({
|
|
257
|
+
stdin: { contents: code },
|
|
258
|
+
loader: this._config.language === "ts" ? "ts" : "js",
|
|
259
|
+
format: "esm",
|
|
260
|
+
platform: "node",
|
|
261
|
+
target: "es2020",
|
|
262
|
+
bundle: false
|
|
263
|
+
});
|
|
264
|
+
return result.outputFiles?.[0]?.text || "";
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return this._transpiler;
|
|
247
270
|
}
|
|
248
271
|
set config(config) {
|
|
249
272
|
this._config = { ...this._config, ...config };
|
|
@@ -377,7 +400,8 @@ var Database = class {
|
|
|
377
400
|
} else {
|
|
378
401
|
stringCode = code;
|
|
379
402
|
}
|
|
380
|
-
const
|
|
403
|
+
const transpiler = await this._initTranspiler();
|
|
404
|
+
const js = transpiler.transformSync(stringCode);
|
|
381
405
|
const mod = new vm.SourceTextModule(js, { context: this._ctx, identifier: path.join(this._config.dir || resolve(process.cwd(), "databases"), "virtual-entry.js") });
|
|
382
406
|
await mod.link(this.moduleLinker.bind(this));
|
|
383
407
|
await mod.evaluate();
|
package/package.json
CHANGED
package/src/database.ts
CHANGED
|
@@ -2,7 +2,6 @@ import vm from "node:vm";
|
|
|
2
2
|
import { resolve } from "./path";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import fs from "node:fs";
|
|
5
|
-
import Bun from "bun";
|
|
6
5
|
|
|
7
6
|
export interface DatabaseConfig {
|
|
8
7
|
dir?: string;
|
|
@@ -11,7 +10,7 @@ export interface DatabaseConfig {
|
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
export class Database {
|
|
14
|
-
private _transpiler:
|
|
13
|
+
private _transpiler: any;
|
|
15
14
|
private _ctx: vm.Context;
|
|
16
15
|
private _registerModules: { [key: string]: any };
|
|
17
16
|
private _config: DatabaseConfig = {
|
|
@@ -22,9 +21,37 @@ export class Database {
|
|
|
22
21
|
this._config = { ...this._config, ...config };
|
|
23
22
|
this._registerModules = config.registerModules || {};
|
|
24
23
|
this._ctx = vm.createContext(this._registerModules);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
// Initialize transpiler lazily
|
|
25
|
+
this._initTranspiler();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private async _initTranspiler() {
|
|
29
|
+
if (!this._transpiler) {
|
|
30
|
+
try {
|
|
31
|
+
// Dynamic import Bun to avoid esbuild bundling issues
|
|
32
|
+
const BunModule = await import('bun');
|
|
33
|
+
this._transpiler = new BunModule.default.Transpiler({
|
|
34
|
+
loader: this._config.language || 'ts',
|
|
35
|
+
});
|
|
36
|
+
} catch {
|
|
37
|
+
// Bun not available, will use esbuild fallback
|
|
38
|
+
const { buildSync } = await import('esbuild');
|
|
39
|
+
this._transpiler = {
|
|
40
|
+
transformSync: (code: string) => {
|
|
41
|
+
const result = buildSync({
|
|
42
|
+
stdin: { contents: code },
|
|
43
|
+
loader: (this._config.language === 'ts' ? 'ts' : 'js') as any,
|
|
44
|
+
format: 'esm',
|
|
45
|
+
platform: 'node',
|
|
46
|
+
target: 'es2020',
|
|
47
|
+
bundle: false,
|
|
48
|
+
});
|
|
49
|
+
return result.outputFiles?.[0]?.text || '';
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return this._transpiler;
|
|
28
55
|
}
|
|
29
56
|
|
|
30
57
|
set config(config: DatabaseConfig) {
|
|
@@ -217,7 +244,9 @@ export class Database {
|
|
|
217
244
|
stringCode = code;
|
|
218
245
|
}
|
|
219
246
|
|
|
220
|
-
|
|
247
|
+
// Ensure transpiler is initialized
|
|
248
|
+
const transpiler = await this._initTranspiler();
|
|
249
|
+
const js = transpiler.transformSync(stringCode);
|
|
221
250
|
|
|
222
251
|
const mod = new vm.SourceTextModule(js, { context: this._ctx, identifier: path.join(this._config.dir || resolve(process.cwd(), 'databases'), 'virtual-entry.js') });
|
|
223
252
|
await mod.link(this.moduleLinker.bind(this));
|