hyperdb-wasm 0.0.26312-dev.wasm.g57edd738 → 0.0.26313-dev.wasm.g630768ec

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/browser.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { HyperDBEngineClient } from './client.js';
2
- import type { EngineRequest, InstantiationProgress, WorkerTransport } from './protocol.js';
2
+ import type { EngineRequest, SetupProgress, WorkerTransport } from './protocol.js';
3
3
  type BrowserListener = (event: unknown) => void;
4
4
  export interface BrowserWorkerLike {
5
5
  postMessage(message: unknown, transfer: ArrayBuffer[]): void;
@@ -11,7 +11,7 @@ export interface BrowserClientOptions {
11
11
  readonly workerUrl?: string | URL;
12
12
  readonly engineUrl?: string | URL;
13
13
  readonly wasmUrl?: string | URL;
14
- readonly onInitialisationProgress?: (progress: InstantiationProgress) => void;
14
+ readonly onSetupProgress?: (progress: SetupProgress) => void;
15
15
  }
16
16
  export declare class BrowserWorker implements WorkerTransport {
17
17
  private readonly worker;
package/dist/browser.js CHANGED
@@ -68,8 +68,8 @@ var init_client = __esm({
68
68
  "use strict";
69
69
  init_protocol();
70
70
  HyperDBEngineClient = class {
71
- constructor(transport, onInitialisationProgress) {
72
- this.onInitialisationProgress = onInitialisationProgress;
71
+ constructor(transport, onSetupProgress) {
72
+ this.onSetupProgress = onSetupProgress;
73
73
  this.transport = transport;
74
74
  this.readyPromise = new Promise((resolve, reject) => {
75
75
  this.resolveReady = resolve;
@@ -81,7 +81,7 @@ var init_client = __esm({
81
81
  transport.onClose((error) => this.fail(error))
82
82
  ];
83
83
  }
84
- onInitialisationProgress;
84
+ onSetupProgress;
85
85
  transport;
86
86
  pending = /* @__PURE__ */ new Map();
87
87
  readyPromise;
@@ -171,7 +171,7 @@ var init_client = __esm({
171
171
  return;
172
172
  }
173
173
  if (message.type === "progress") {
174
- this.onInitialisationProgress?.({ bytesLoaded: message.bytesLoaded, bytesTotal: message.bytesTotal });
174
+ this.onSetupProgress?.({ bytesLoaded: message.bytesLoaded, bytesTotal: message.bytesTotal });
175
175
  return;
176
176
  }
177
177
  if (message.type === "fatal") {
@@ -214,7 +214,7 @@ function createBrowserClient(options = {}) {
214
214
  const engineUrl = options.engineUrl ?? new URL("./hyperdb-wasm.js", import.meta.url);
215
215
  return new HyperDBEngineClient(
216
216
  new BrowserWorker(new Worker(resolveBrowserWorkerUrl(workerUrl, engineUrl, options.wasmUrl), { type: "classic" })),
217
- options.onInitialisationProgress
217
+ options.onSetupProgress
218
218
  );
219
219
  }
220
220
  var BrowserWorker;
@@ -12092,6 +12092,7 @@ RecordBatchFileWriter["throughDOM"] = recordBatchWriterThroughDOMStream;
12092
12092
  RecordBatchStreamWriter["throughDOM"] = recordBatchWriterThroughDOMStream;
12093
12093
 
12094
12094
  // src/api.ts
12095
+ var maxPersistentDatabaseNameLength = 200;
12095
12096
  function normalizeArrowInsertOptions(options) {
12096
12097
  if (!options.name) throw new Error("Arrow insert table name must not be empty");
12097
12098
  return { name: options.name, schema: options.schema ?? null, create: options.create ?? true };
@@ -12100,6 +12101,18 @@ function validateDatabaseName(databaseName) {
12100
12101
  if (!databaseName) throw new Error("Database name must not be empty");
12101
12102
  if (databaseName.includes("\0")) throw new Error("Database name must not contain NUL");
12102
12103
  }
12104
+ function validatePersistentDatabaseName(databaseName) {
12105
+ validateDatabaseName(databaseName);
12106
+ if (databaseName.length > maxPersistentDatabaseNameLength) {
12107
+ throw new Error(`Persistent database name must be at most ${maxPersistentDatabaseNameLength} characters`);
12108
+ }
12109
+ if (!/^[a-z0-9][a-z0-9_-]*$/.test(databaseName)) {
12110
+ throw new Error("Persistent database name must start with a lowercase ASCII letter or digit and contain only lowercase ASCII letters, digits, hyphens, and underscores");
12111
+ }
12112
+ if (/^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])$/.test(databaseName)) {
12113
+ throw new Error("Persistent database name is reserved by Windows");
12114
+ }
12115
+ }
12103
12116
  function validateDatabaseAlias(alias) {
12104
12117
  if (!alias) throw new Error("Database alias must not be empty");
12105
12118
  if (alias.includes("\0")) throw new Error("Database alias must not contain NUL");
@@ -12212,12 +12225,13 @@ var HyperDB = class _HyperDB {
12212
12225
  if (options.storage !== void 0 && options.storage !== "memory" && options.storage !== "persistent") {
12213
12226
  throw new Error(`Unsupported database storage: ${String(options.storage)}`);
12214
12227
  }
12228
+ if (options.storage === "persistent") validatePersistentDatabaseName(databaseName);
12215
12229
  await this.runDatabaseOperation(async () => {
12216
12230
  expectOk(await this.client.createDatabase(databaseName, options.storage === "persistent"), "create database");
12217
12231
  });
12218
12232
  }
12219
12233
  async openDatabase(databaseName) {
12220
- validateDatabaseName(databaseName);
12234
+ validatePersistentDatabaseName(databaseName);
12221
12235
  await this.runDatabaseOperation(async () => {
12222
12236
  expectOk(await this.client.openDatabase(databaseName), "open database");
12223
12237
  });
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { InstantiationProgress, WasmResult, WorkerTransport } from './protocol.js';
1
+ import type { SetupProgress, WasmResult, WorkerTransport } from './protocol.js';
2
2
  export declare class HyperDBEngineClient {
3
- private readonly onInitialisationProgress?;
3
+ private readonly onSetupProgress?;
4
4
  private readonly transport;
5
5
  private readonly pending;
6
6
  private readonly readyPromise;
@@ -9,7 +9,7 @@ export declare class HyperDBEngineClient {
9
9
  private nextId;
10
10
  private failed;
11
11
  private readonly unsubscribe;
12
- constructor(transport: WorkerTransport, onInitialisationProgress?: ((progress: InstantiationProgress) => void) | undefined);
12
+ constructor(transport: WorkerTransport, onSetupProgress?: ((progress: SetupProgress) => void) | undefined);
13
13
  ready(): Promise<void>;
14
14
  initialize(settings: string): Promise<WasmResult>;
15
15
  connect(): Promise<WasmResult>;