@anvia/studio 0.2.6 → 0.2.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/index.js CHANGED
@@ -794,9 +794,7 @@ import { join } from "path";
794
794
  import { mkdirSync } from "fs";
795
795
  import { createRequire } from "module";
796
796
  import { dirname, resolve } from "path";
797
- var { DatabaseSync } = createRequire(import.meta.url)(
798
- "node:sqlite"
799
- );
797
+ var DatabaseSync;
800
798
  function createSqliteSessionStore(options = {}) {
801
799
  return new SqliteSessionStore(options.path ?? ":memory:");
802
800
  }
@@ -1396,7 +1394,7 @@ var SqliteSessionStore = class {
1396
1394
  if (this.path !== ":memory:") {
1397
1395
  mkdirSync(dirname(resolve(this.path)), { recursive: true });
1398
1396
  }
1399
- const db = new DatabaseSync(this.path, {
1397
+ const db = new (loadDatabaseSync())(this.path, {
1400
1398
  allowUnknownNamedParameters: true,
1401
1399
  timeout: 5e3
1402
1400
  });
@@ -1752,6 +1750,22 @@ function guardAgainstLegacySessionSchema(db) {
1752
1750
  );
1753
1751
  }
1754
1752
  }
1753
+ function loadDatabaseSync() {
1754
+ if (DatabaseSync !== void 0) {
1755
+ return DatabaseSync;
1756
+ }
1757
+ try {
1758
+ ({ DatabaseSync } = createRequire(import.meta.url)(
1759
+ "node:sqlite"
1760
+ ));
1761
+ return DatabaseSync;
1762
+ } catch (error) {
1763
+ throw new Error(
1764
+ "The default Studio SQLite store requires Node.js with node:sqlite support. Provide custom Studio stores or disable persisted stores when running Studio in a runtime without node:sqlite.",
1765
+ { cause: error }
1766
+ );
1767
+ }
1768
+ }
1755
1769
  function toTrace(row) {
1756
1770
  const trace = parseJsonValue(row.trace_json);
1757
1771
  const input = parseJsonValue(row.input_json);