js-bao 0.2.10 → 0.2.12
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 +174 -0
- package/dist/BaseModel-5YQCROYE.js +17 -0
- package/dist/BaseModel-5YQCROYE.js.map +1 -0
- package/dist/BaseModel-FCNWDJBH.js +17 -0
- package/dist/BaseModel-FCNWDJBH.js.map +1 -0
- package/dist/BrowserDatabaseFactory-PXOTK2DQ.js +119 -0
- package/dist/BrowserDatabaseFactory-PXOTK2DQ.js.map +1 -0
- package/dist/BrowserDatabaseFactory-WD4VX2VZ.js +119 -0
- package/dist/BrowserDatabaseFactory-WD4VX2VZ.js.map +1 -0
- package/dist/IncludeResolver-RCKQGNPZ.js +385 -0
- package/dist/IncludeResolver-RCKQGNPZ.js.map +1 -0
- package/dist/IncludeResolver-WGSQDMS7.js +385 -0
- package/dist/IncludeResolver-WGSQDMS7.js.map +1 -0
- package/dist/NodeDatabaseFactory-J4Z36UF3.js +165 -0
- package/dist/NodeDatabaseFactory-J4Z36UF3.js.map +1 -0
- package/dist/NodeDatabaseFactory-QIEKAXBM.js +10 -0
- package/dist/NodeDatabaseFactory-QIEKAXBM.js.map +1 -0
- package/dist/NodeSqliteEngine-HJSAYE4E.js +383 -0
- package/dist/NodeSqliteEngine-HJSAYE4E.js.map +1 -0
- package/dist/NodeSqliteEngine-I5SLWLME.js +383 -0
- package/dist/NodeSqliteEngine-I5SLWLME.js.map +1 -0
- package/dist/browser.cjs +3779 -3370
- package/dist/browser.d.cts +18 -1
- package/dist/browser.d.ts +18 -1
- package/dist/browser.js +3750 -3341
- package/dist/chunk-3PZWHUZO.js +4153 -0
- package/dist/chunk-3PZWHUZO.js.map +1 -0
- package/dist/chunk-53MS4MN7.js +373 -0
- package/dist/chunk-53MS4MN7.js.map +1 -0
- package/dist/chunk-65G2P4GL.js +709 -0
- package/dist/chunk-65G2P4GL.js.map +1 -0
- package/dist/chunk-6UX3YSCW.js +4151 -0
- package/dist/chunk-6UX3YSCW.js.map +1 -0
- package/dist/chunk-DANSD6BE.js +709 -0
- package/dist/chunk-DANSD6BE.js.map +1 -0
- package/dist/chunk-DF3JEQXA.js +373 -0
- package/dist/chunk-DF3JEQXA.js.map +1 -0
- package/dist/chunk-GO3APTPX.js +61 -0
- package/dist/chunk-GO3APTPX.js.map +1 -0
- package/dist/chunk-ID4U6IQC.js +53 -0
- package/dist/chunk-ID4U6IQC.js.map +1 -0
- package/dist/chunk-RQVS3LVL.js +165 -0
- package/dist/chunk-RQVS3LVL.js.map +1 -0
- package/dist/client.cjs +837 -0
- package/dist/client.d.cts +1101 -0
- package/dist/client.d.ts +1101 -0
- package/dist/client.js +806 -0
- package/dist/cloudflare-do.cjs +3637 -0
- package/dist/cloudflare-do.d.cts +1366 -0
- package/dist/cloudflare-do.d.ts +1366 -0
- package/dist/cloudflare-do.js +3614 -0
- package/dist/cloudflare.cjs +1048 -0
- package/dist/cloudflare.d.cts +1381 -0
- package/dist/cloudflare.d.ts +1381 -0
- package/dist/cloudflare.js +1017 -0
- package/dist/codegen.cjs +259 -18
- package/dist/environment-TOTQICSE.js +17 -0
- package/dist/environment-TOTQICSE.js.map +1 -0
- package/dist/index.cjs +1906 -1493
- package/dist/index.d.cts +19 -2
- package/dist/index.d.ts +19 -2
- package/dist/index.js +1871 -1458
- package/dist/node.cjs +4779 -4366
- package/dist/node.d.cts +18 -1
- package/dist/node.d.ts +18 -1
- package/dist/node.js +4602 -4189
- package/package.json +41 -12
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// src/utils/environment.ts
|
|
2
|
+
function detectEnvironment() {
|
|
3
|
+
if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
|
4
|
+
return "node";
|
|
5
|
+
}
|
|
6
|
+
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
|
7
|
+
return "browser";
|
|
8
|
+
}
|
|
9
|
+
if (typeof self !== "undefined" && typeof self.importScripts === "function") {
|
|
10
|
+
return "browser";
|
|
11
|
+
}
|
|
12
|
+
return "unknown";
|
|
13
|
+
}
|
|
14
|
+
function isNode() {
|
|
15
|
+
return detectEnvironment() === "node";
|
|
16
|
+
}
|
|
17
|
+
function isBrowser() {
|
|
18
|
+
return detectEnvironment() === "browser";
|
|
19
|
+
}
|
|
20
|
+
async function isNodeModuleAvailable(moduleName) {
|
|
21
|
+
if (!isNode()) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
await import(
|
|
26
|
+
/* @vite-ignore */
|
|
27
|
+
moduleName
|
|
28
|
+
);
|
|
29
|
+
return true;
|
|
30
|
+
} catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
var features = {
|
|
35
|
+
get hasWebWorkers() {
|
|
36
|
+
return isBrowser() && typeof Worker !== "undefined";
|
|
37
|
+
},
|
|
38
|
+
get hasFileSystem() {
|
|
39
|
+
return isNode();
|
|
40
|
+
},
|
|
41
|
+
get hasWebAssembly() {
|
|
42
|
+
return typeof WebAssembly !== "undefined";
|
|
43
|
+
},
|
|
44
|
+
async hasBetterSqlite3() {
|
|
45
|
+
return await isNodeModuleAvailable("better-sqlite3");
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
isNode,
|
|
51
|
+
features
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=chunk-ID4U6IQC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/environment.ts"],"sourcesContent":["/**\n * Runtime environment detection utilities\n */\n\nexport type RuntimeEnvironment = \"browser\" | \"node\" | \"unknown\";\n\n/**\n * Detects the current runtime environment\n */\nexport function detectEnvironment(): RuntimeEnvironment {\n // Check for Node.js environment\n if (\n typeof process !== \"undefined\" &&\n process.versions &&\n process.versions.node\n ) {\n return \"node\";\n }\n\n // Check for browser environment\n if (typeof window !== \"undefined\" && typeof document !== \"undefined\") {\n return \"browser\";\n }\n\n // Check for Web Worker environment\n if (\n typeof self !== \"undefined\" &&\n typeof (self as any).importScripts === \"function\"\n ) {\n return \"browser\";\n }\n\n return \"unknown\";\n}\n\n/**\n * Checks if currently running in Node.js\n */\nexport function isNode(): boolean {\n return detectEnvironment() === \"node\";\n}\n\n/**\n * Checks if currently running in browser\n */\nexport function isBrowser(): boolean {\n return detectEnvironment() === \"browser\";\n}\n\n/**\n * Checks if a Node.js module is available\n */\nexport async function isNodeModuleAvailable(\n moduleName: string\n): Promise<boolean> {\n if (!isNode()) {\n return false;\n }\n\n try {\n // @ts-ignore\n await import(/* @vite-ignore */ moduleName);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Environment-specific feature detection\n */\nexport const features = {\n get hasWebWorkers(): boolean {\n return isBrowser() && typeof Worker !== \"undefined\";\n },\n\n get hasFileSystem(): boolean {\n return isNode();\n },\n\n get hasWebAssembly(): boolean {\n return typeof WebAssembly !== \"undefined\";\n },\n\n async hasBetterSqlite3(): Promise<boolean> {\n return await isNodeModuleAvailable(\"better-sqlite3\");\n },\n};\n\n/**\n * Environment-specific constants\n */\nexport const constants = {\n DEFAULT_NODE_SQLITE_PATH: \":memory:\",\n DEFAULT_BROWSER_WASM_PATH: \"/sql-wasm.wasm\",\n};\n"],"mappings":";AASO,SAAS,oBAAwC;AAEtD,MACE,OAAO,YAAY,eACnB,QAAQ,YACR,QAAQ,SAAS,MACjB;AACA,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,WAAW,eAAe,OAAO,aAAa,aAAa;AACpE,WAAO;AAAA,EACT;AAGA,MACE,OAAO,SAAS,eAChB,OAAQ,KAAa,kBAAkB,YACvC;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAKO,SAAS,SAAkB;AAChC,SAAO,kBAAkB,MAAM;AACjC;AAKO,SAAS,YAAqB;AACnC,SAAO,kBAAkB,MAAM;AACjC;AAKA,eAAsB,sBACpB,YACkB;AAClB,MAAI,CAAC,OAAO,GAAG;AACb,WAAO;AAAA,EACT;AAEA,MAAI;AAEF,UAAM;AAAA;AAAA,MAA0B;AAAA;AAChC,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAKO,IAAM,WAAW;AAAA,EACtB,IAAI,gBAAyB;AAC3B,WAAO,UAAU,KAAK,OAAO,WAAW;AAAA,EAC1C;AAAA,EAEA,IAAI,gBAAyB;AAC3B,WAAO,OAAO;AAAA,EAChB;AAAA,EAEA,IAAI,iBAA0B;AAC5B,WAAO,OAAO,gBAAgB;AAAA,EAChC;AAAA,EAEA,MAAM,mBAAqC;AACzC,WAAO,MAAM,sBAAsB,gBAAgB;AAAA,EACrD;AACF;","names":[]}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SqljsEngine
|
|
3
|
+
} from "./chunk-53MS4MN7.js";
|
|
4
|
+
import {
|
|
5
|
+
features
|
|
6
|
+
} from "./chunk-GO3APTPX.js";
|
|
7
|
+
|
|
8
|
+
// src/engines/NodeDatabaseFactory.ts
|
|
9
|
+
var NodeSqliteEngine = null;
|
|
10
|
+
var NodeDatabaseFactory = class {
|
|
11
|
+
static engines = /* @__PURE__ */ new Map();
|
|
12
|
+
/**
|
|
13
|
+
* Dynamically loads Node.js engines
|
|
14
|
+
*/
|
|
15
|
+
static async loadNodeEngines() {
|
|
16
|
+
try {
|
|
17
|
+
const hasBetterSqlite3 = await features.hasBetterSqlite3();
|
|
18
|
+
if (hasBetterSqlite3 && !NodeSqliteEngine) {
|
|
19
|
+
const module = await import("./NodeSqliteEngine-I5SLWLME.js");
|
|
20
|
+
NodeSqliteEngine = module.NodeSqliteEngine;
|
|
21
|
+
console.log(
|
|
22
|
+
"[NodeDatabaseFactory] NodeSqliteEngine loaded successfully"
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.warn(
|
|
27
|
+
"[NodeDatabaseFactory] Failed to load NodeSqliteEngine:",
|
|
28
|
+
error
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Auto-detects the best available engine for Node.js
|
|
34
|
+
*/
|
|
35
|
+
static async getRecommendedEngineType() {
|
|
36
|
+
const hasBetterSqlite3 = await features.hasBetterSqlite3();
|
|
37
|
+
if (hasBetterSqlite3) {
|
|
38
|
+
return "node-sqlite";
|
|
39
|
+
}
|
|
40
|
+
if (features.hasWebAssembly) {
|
|
41
|
+
return "sqljs";
|
|
42
|
+
}
|
|
43
|
+
throw new Error(
|
|
44
|
+
"No compatible database engine found. Please install better-sqlite3."
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates a fallback engine when the requested engine is not available
|
|
49
|
+
*/
|
|
50
|
+
static async createFallbackEngine(requestedType, config) {
|
|
51
|
+
const fallbackType = await this.getRecommendedEngineType();
|
|
52
|
+
console.warn(
|
|
53
|
+
`[NodeDatabaseFactory] Requested engine '${requestedType}' is not available. Falling back to '${fallbackType}'.`
|
|
54
|
+
);
|
|
55
|
+
const fallbackConfig = { ...config, type: fallbackType };
|
|
56
|
+
return this.createEngine(fallbackConfig, false);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Creates the specified database engine (Node.js compatible only)
|
|
60
|
+
*/
|
|
61
|
+
static async createEngine(config, allowFallback = true) {
|
|
62
|
+
const { type, options } = config;
|
|
63
|
+
switch (type) {
|
|
64
|
+
case "sqljs":
|
|
65
|
+
const sqljsEngine = new SqljsEngine(options);
|
|
66
|
+
await sqljsEngine.ensureReady();
|
|
67
|
+
return sqljsEngine;
|
|
68
|
+
case "node-sqlite":
|
|
69
|
+
if (!NodeSqliteEngine) {
|
|
70
|
+
const hasBetterSqlite3 = await features.hasBetterSqlite3();
|
|
71
|
+
if (!hasBetterSqlite3) {
|
|
72
|
+
if (allowFallback) {
|
|
73
|
+
console.warn(
|
|
74
|
+
"[NodeDatabaseFactory] better-sqlite3 not installed, falling back to alternative engine"
|
|
75
|
+
);
|
|
76
|
+
return this.createFallbackEngine(type, config);
|
|
77
|
+
}
|
|
78
|
+
throw new Error(
|
|
79
|
+
"better-sqlite3 package is required for node-sqlite engine. Install it with: npm install better-sqlite3"
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
throw new Error(
|
|
83
|
+
"NodeSqliteEngine not loaded. This should not happen."
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
const nodeSqliteEngine = new NodeSqliteEngine(options);
|
|
87
|
+
await nodeSqliteEngine.ensureReady();
|
|
88
|
+
return nodeSqliteEngine;
|
|
89
|
+
case "alasql":
|
|
90
|
+
throw new Error("AlaSQLEngine not yet implemented.");
|
|
91
|
+
default:
|
|
92
|
+
const typeStr = type;
|
|
93
|
+
if (typeStr === "duckdb") {
|
|
94
|
+
if (allowFallback) {
|
|
95
|
+
console.warn(
|
|
96
|
+
"[NodeDatabaseFactory] DuckDB-WASM not available in Node.js, falling back to alternative engine"
|
|
97
|
+
);
|
|
98
|
+
return this.createFallbackEngine(typeStr, config);
|
|
99
|
+
}
|
|
100
|
+
throw new Error(
|
|
101
|
+
"DuckDB-WASM engine is only available in browser environments"
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
if (typeStr === "node-duckdb") {
|
|
105
|
+
if (allowFallback) {
|
|
106
|
+
console.warn(
|
|
107
|
+
"[NodeDatabaseFactory] Node DuckDB engine is no longer supported, falling back to alternative engine"
|
|
108
|
+
);
|
|
109
|
+
return this.createFallbackEngine(typeStr, config);
|
|
110
|
+
}
|
|
111
|
+
throw new Error("Node DuckDB engine is no longer supported");
|
|
112
|
+
}
|
|
113
|
+
throw new Error(`Unsupported database engine type: ${typeStr}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
static async getEngine(config) {
|
|
117
|
+
await this.loadNodeEngines();
|
|
118
|
+
const configKey = JSON.stringify(config);
|
|
119
|
+
if (this.engines.has(configKey)) {
|
|
120
|
+
console.log(
|
|
121
|
+
`[NodeDatabaseFactory] Returning cached engine for config: ${configKey}`
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
console.log(
|
|
125
|
+
`[NodeDatabaseFactory] Creating engine for type: ${config.type}`
|
|
126
|
+
);
|
|
127
|
+
try {
|
|
128
|
+
const engine = await this.createEngine(config);
|
|
129
|
+
console.log(
|
|
130
|
+
`[NodeDatabaseFactory] Engine for type ${config.type} is ready.`
|
|
131
|
+
);
|
|
132
|
+
return engine;
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.error(
|
|
135
|
+
`[NodeDatabaseFactory] Failed to create engine for type ${config.type}:`,
|
|
136
|
+
error
|
|
137
|
+
);
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Gets information about available engines in Node.js environment
|
|
143
|
+
*/
|
|
144
|
+
static async getAvailableEngines() {
|
|
145
|
+
const hasBetterSqlite3 = await features.hasBetterSqlite3();
|
|
146
|
+
const engines = [
|
|
147
|
+
{
|
|
148
|
+
type: "sqljs",
|
|
149
|
+
available: features.hasWebAssembly,
|
|
150
|
+
reason: !features.hasWebAssembly ? "WebAssembly not supported" : void 0
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
type: "node-sqlite",
|
|
154
|
+
available: hasBetterSqlite3,
|
|
155
|
+
reason: !hasBetterSqlite3 ? "better-sqlite3 package not installed" : void 0
|
|
156
|
+
}
|
|
157
|
+
];
|
|
158
|
+
return engines;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export {
|
|
163
|
+
NodeDatabaseFactory
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=chunk-RQVS3LVL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/engines/NodeDatabaseFactory.ts"],"sourcesContent":["import { DatabaseConfig } from \"../types/databaseTypes\";\nimport { DatabaseEngine } from \"./DatabaseEngine\";\nimport { SqljsEngine } from \"./SqljsEngine\";\nimport { features } from \"../utils/environment\";\n\n// Dynamic imports for Node.js engines only\nlet NodeSqliteEngine: any = null;\n\nexport class NodeDatabaseFactory {\n private static engines: Map<string, DatabaseEngine> = new Map();\n\n /**\n * Dynamically loads Node.js engines\n */\n private static async loadNodeEngines() {\n try {\n // Try to load Node.js SQLite engine\n const hasBetterSqlite3 = await features.hasBetterSqlite3();\n if (hasBetterSqlite3 && !NodeSqliteEngine) {\n const module = await import(\"./node/NodeSqliteEngine\");\n NodeSqliteEngine = module.NodeSqliteEngine;\n console.log(\n \"[NodeDatabaseFactory] NodeSqliteEngine loaded successfully\"\n );\n }\n } catch (error) {\n console.warn(\n \"[NodeDatabaseFactory] Failed to load NodeSqliteEngine:\",\n error\n );\n }\n }\n\n /**\n * Auto-detects the best available engine for Node.js\n */\n private static async getRecommendedEngineType(): Promise<string> {\n // In Node.js, prefer native engines\n const hasBetterSqlite3 = await features.hasBetterSqlite3();\n if (hasBetterSqlite3) {\n return \"node-sqlite\";\n }\n\n // Fallback to WASM engines\n if (features.hasWebAssembly) {\n return \"sqljs\";\n }\n\n throw new Error(\n \"No compatible database engine found. Please install better-sqlite3.\"\n );\n }\n\n /**\n * Creates a fallback engine when the requested engine is not available\n */\n private static async createFallbackEngine(\n requestedType: string,\n config: DatabaseConfig\n ): Promise<DatabaseEngine> {\n const fallbackType = await this.getRecommendedEngineType();\n\n console.warn(\n `[NodeDatabaseFactory] Requested engine '${requestedType}' is not available. ` +\n `Falling back to '${fallbackType}'.`\n );\n\n const fallbackConfig = { ...config, type: fallbackType as any };\n return this.createEngine(fallbackConfig, false); // Prevent infinite recursion\n }\n\n /**\n * Creates the specified database engine (Node.js compatible only)\n */\n private static async createEngine(\n config: DatabaseConfig,\n allowFallback: boolean = true\n ): Promise<DatabaseEngine> {\n const { type, options } = config;\n\n switch (type) {\n case \"sqljs\":\n const sqljsEngine = new SqljsEngine(options as any);\n await sqljsEngine.ensureReady();\n return sqljsEngine;\n\n case \"node-sqlite\":\n if (!NodeSqliteEngine) {\n const hasBetterSqlite3 = await features.hasBetterSqlite3();\n if (!hasBetterSqlite3) {\n if (allowFallback) {\n console.warn(\n \"[NodeDatabaseFactory] better-sqlite3 not installed, falling back to alternative engine\"\n );\n return this.createFallbackEngine(type, config);\n }\n throw new Error(\n \"better-sqlite3 package is required for node-sqlite engine. Install it with: npm install better-sqlite3\"\n );\n }\n throw new Error(\n \"NodeSqliteEngine not loaded. This should not happen.\"\n );\n }\n\n const nodeSqliteEngine = new NodeSqliteEngine(options);\n await nodeSqliteEngine.ensureReady();\n return nodeSqliteEngine;\n\n case \"alasql\":\n throw new Error(\"AlaSQLEngine not yet implemented.\");\n\n default:\n // Handle removed engine types and unsupported types\n const typeStr = type as string;\n\n if (typeStr === \"duckdb\") {\n if (allowFallback) {\n console.warn(\n \"[NodeDatabaseFactory] DuckDB-WASM not available in Node.js, falling back to alternative engine\"\n );\n return this.createFallbackEngine(typeStr, config);\n }\n throw new Error(\n \"DuckDB-WASM engine is only available in browser environments\"\n );\n }\n\n if (typeStr === \"node-duckdb\") {\n if (allowFallback) {\n console.warn(\n \"[NodeDatabaseFactory] Node DuckDB engine is no longer supported, falling back to alternative engine\"\n );\n return this.createFallbackEngine(typeStr, config);\n }\n throw new Error(\"Node DuckDB engine is no longer supported\");\n }\n\n throw new Error(`Unsupported database engine type: ${typeStr}`);\n }\n }\n\n public static async getEngine(\n config: DatabaseConfig\n ): Promise<DatabaseEngine> {\n // Load Node.js engines\n await this.loadNodeEngines();\n\n const configKey = JSON.stringify(config);\n\n // For development, we don't cache engines to avoid issues with hot reloading\n if (this.engines.has(configKey)) {\n console.log(\n `[NodeDatabaseFactory] Returning cached engine for config: ${configKey}`\n );\n // return this.engines.get(configKey)!;\n }\n\n console.log(\n `[NodeDatabaseFactory] Creating engine for type: ${config.type}`\n );\n\n try {\n const engine = await this.createEngine(config);\n\n // Cache the engine (optional)\n // this.engines.set(configKey, engine);\n\n console.log(\n `[NodeDatabaseFactory] Engine for type ${config.type} is ready.`\n );\n return engine;\n } catch (error) {\n console.error(\n `[NodeDatabaseFactory] Failed to create engine for type ${config.type}:`,\n error\n );\n throw error;\n }\n }\n\n /**\n * Gets information about available engines in Node.js environment\n */\n public static async getAvailableEngines(): Promise<\n {\n type: string;\n available: boolean;\n reason?: string;\n }[]\n > {\n const hasBetterSqlite3 = await features.hasBetterSqlite3();\n\n const engines = [\n {\n type: \"sqljs\",\n available: features.hasWebAssembly,\n reason: !features.hasWebAssembly\n ? \"WebAssembly not supported\"\n : undefined,\n },\n {\n type: \"node-sqlite\",\n available: hasBetterSqlite3,\n reason: !hasBetterSqlite3\n ? \"better-sqlite3 package not installed\"\n : undefined,\n },\n ];\n\n return engines;\n }\n}\n"],"mappings":";;;;;;;;AAMA,IAAI,mBAAwB;AAErB,IAAM,sBAAN,MAA0B;AAAA,EAC/B,OAAe,UAAuC,oBAAI,IAAI;AAAA;AAAA;AAAA;AAAA,EAK9D,aAAqB,kBAAkB;AACrC,QAAI;AAEF,YAAM,mBAAmB,MAAM,SAAS,iBAAiB;AACzD,UAAI,oBAAoB,CAAC,kBAAkB;AACzC,cAAM,SAAS,MAAM,OAAO,gCAAyB;AACrD,2BAAmB,OAAO;AAC1B,gBAAQ;AAAA,UACN;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAS,OAAO;AACd,cAAQ;AAAA,QACN;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,aAAqB,2BAA4C;AAE/D,UAAM,mBAAmB,MAAM,SAAS,iBAAiB;AACzD,QAAI,kBAAkB;AACpB,aAAO;AAAA,IACT;AAGA,QAAI,SAAS,gBAAgB;AAC3B,aAAO;AAAA,IACT;AAEA,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,aAAqB,qBACnB,eACA,QACyB;AACzB,UAAM,eAAe,MAAM,KAAK,yBAAyB;AAEzD,YAAQ;AAAA,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