Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22,494 changes: 11,247 additions & 11,247 deletions dist/browser.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/browser.min.js

Large diffs are not rendered by default.

1,374 changes: 1 addition & 1,373 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"lint:fix": "eslint . --fix",
"build": "npm run build:clean && npm run build:esm && npm run build:cjs && npm run build:packages && npm run browserify && echo Done!",
"build:clean": "(rm -r ./dist/esm || true) && (rm -r ./dist/cjs || true) && (rm -r ./dist/types || true)",
"build:esm": "tsc -p tsconfig.json && npx tsc-esm-fix ---target='dist/esm'",
"build:esm": "tsc -p tsconfig.json && node scripts/esm-fix-dirname.mjs",
"build:cjs": "tsc -p tsconfig-cjs.json",
"build:packages": "bash ./create-package-files",
"browserify": "browserify ./dist/cjs/browser.js -o ./dist/browser.js --standalone acebase --ignore buffer --ignore rxjs && terser ./dist/browser.js -o ./dist/browser.min.js",
Expand Down Expand Up @@ -106,7 +106,6 @@
"eslint-plugin-jasmine": "^4.1.3",
"jasmine": "^3.7.0",
"terser": "^5.15.0",
"tsc-esm-fix": "^2.20.5",
"typescript": "^5.0.4"
},
"funding": [
Expand Down
25 changes: 25 additions & 0 deletions scripts/esm-fix-dirname.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Injects ESM-compatible __dirname shim into compiled ESM output files.
// TypeScript's @types/node declares __dirname globally so it type-checks fine,
// but Node.js does not provide it in ES modules at runtime.
import { readdir, readFile, writeFile } from 'fs/promises';
import { join } from 'path';

// Uses the global URL constructor (no import needed) to derive the directory.
// new URL('.', import.meta.url) => file:///path/to/dir/ (trailing slash)
const SHIM = 'const __dirname = new URL(\'.\', import.meta.url).pathname.slice(0, -1);\n';

async function fix(dir) {
for (const entry of await readdir(dir, { withFileTypes: true })) {
const fullPath = join(dir, entry.name);
if (entry.isDirectory()) {
await fix(fullPath);
} else if (entry.name.endsWith('.js')) {
const src = await readFile(fullPath, 'utf8');
if (src.includes('__dirname')) {
await writeFile(fullPath, SHIM + src);
}
}
}
}

fix('./dist/esm').catch(err => { console.error(err); process.exit(1); });
6 changes: 3 additions & 3 deletions src/acebase-browser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AceBase, AceBaseLocalSettings } from './acebase-local';
import { createIndexedDBInstance } from './storage/custom/indexed-db';
import { IndexedDBStorageSettings } from './storage/custom/indexed-db/settings';
import { AceBase, AceBaseLocalSettings } from './acebase-local.js';
import { createIndexedDBInstance } from './storage/custom/indexed-db/index.js';
import { IndexedDBStorageSettings } from './storage/custom/indexed-db/settings.js';

const deprecatedConstructorError = `Using AceBase constructor in the browser to use localStorage is deprecated!
Switch to:
Expand Down
10 changes: 5 additions & 5 deletions src/acebase-local.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AceBaseBase, AceBaseBaseSettings } from 'acebase-core';
import { AceBaseStorage } from './storage/binary';
import { LocalApi } from './api-local';
import { IPCClientSettings, StorageSettings, TransactionLogSettings } from './storage';
import { createLocalStorageInstance, LocalStorageSettings } from './storage/custom/local-storage';
import { IndexedDBStorageSettings } from './storage/custom/indexed-db/settings';
import { AceBaseStorage } from './storage/binary/index.js';
import { LocalApi } from './api-local.js';
import { IPCClientSettings, StorageSettings, TransactionLogSettings } from './storage/index.js';
import { createLocalStorageInstance, LocalStorageSettings } from './storage/custom/local-storage/index.js';
import { IndexedDBStorageSettings } from './storage/custom/indexed-db/settings.js';

export { LocalStorageSettings, IndexedDBStorageSettings };

Expand Down
22 changes: 11 additions & 11 deletions src/api-local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { AceBaseBase, IStreamLike, Api, EventSubscriptionCallback,
ReflectionType, IReflectionNodeInfo, IReflectionChildrenInfo,
StreamReadFunction, StreamWriteFunction, TransactionLogFilter,
LoggingLevel, Query, QueryOptions, LoggerPlugin } from 'acebase-core';
import { AceBaseStorage, AceBaseStorageSettings } from './storage/binary';
import { SQLiteStorage, SQLiteStorageSettings } from './storage/sqlite';
import { MSSQLStorage, MSSQLStorageSettings } from './storage/mssql';
import { CustomStorage, CustomStorageSettings } from './storage/custom';
import { VALUE_TYPES } from './node-value-types';
import { executeQuery } from './query';
import { Storage, StorageEnv } from './storage';
import { CreateIndexOptions } from './storage/indexes';
import type { BinaryNodeAddress } from './storage/binary/node-address';
import { AceBaseLocalSettings } from '.';
import { NodeNotFoundError } from './node-errors';
import { AceBaseStorage, AceBaseStorageSettings } from './storage/binary/index.js';
import { SQLiteStorage, SQLiteStorageSettings } from './storage/sqlite/index.js';
import { MSSQLStorage, MSSQLStorageSettings } from './storage/mssql/index.js';
import { CustomStorage, CustomStorageSettings } from './storage/custom/index.js';
import { VALUE_TYPES } from './node-value-types.js';
import { executeQuery } from './query.js';
import { Storage, StorageEnv } from './storage/index.js';
import { CreateIndexOptions } from './storage/indexes.js';
import type { BinaryNodeAddress } from './storage/binary/node-address.js';
import { AceBaseLocalSettings } from './acebase-local.js';
import { NodeNotFoundError } from './node-errors.js';

export class LocalApi extends Api {
// All api methods for local database instance
Expand Down
2 changes: 1 addition & 1 deletion src/async-task-batch.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AsyncTaskBatch } from './async-task-batch';
import { AsyncTaskBatch } from './async-task-batch.js';

describe('Async task batches', () => {
it('works', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/binary.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Uint8ArrayBuilder } from './binary';
import { Uint8ArrayBuilder } from './binary.js';

describe('Uint8ArrayBuilder', () => {
it('write grows the buffer', () => {
Expand Down
18 changes: 9 additions & 9 deletions src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import { DataReference, DataSnapshot, EventSubscription, PathReference, TypeMapp
DataSnapshotsArray, ObjectCollection, DataReferencesArray, EventStream, TypeMappingOptions,
IReflectionNodeInfo, IReflectionChildrenInfo, IStreamLike, ILiveDataProxy, ILiveDataProxyValue,
IObjectCollection, PartialArray } from 'acebase-core';
import { AceBaseLocalSettings } from './acebase-local';
import { BrowserAceBase } from './acebase-browser';
import { CustomStorageSettings, CustomStorageTransaction, CustomStorageHelpers } from './storage/custom';
import { AceBaseLocalSettings } from './acebase-local.js';
import { BrowserAceBase } from './acebase-browser.js';
import { CustomStorageSettings, CustomStorageTransaction, CustomStorageHelpers } from './storage/custom/index.js';

const acebase = {
AceBase: BrowserAceBase,
Expand Down Expand Up @@ -83,23 +83,23 @@ export {
AceBaseLocalSettings,
LocalStorageSettings,
IndexedDBStorageSettings,
} from './acebase-local';
} from './acebase-local.js';

export { AceBaseStorageSettings } from './storage/binary';
export { SQLiteStorageSettings } from './storage/sqlite';
export { MSSQLStorageSettings } from './storage/mssql';
export { AceBaseStorageSettings } from './storage/binary/index.js';
export { SQLiteStorageSettings } from './storage/sqlite/index.js';
export { MSSQLStorageSettings } from './storage/mssql/index.js';

export {
CustomStorageTransaction,
CustomStorageSettings,
CustomStorageHelpers,
ICustomStorageNode,
ICustomStorageNodeMetaData,
} from './storage/custom';
} from './storage/custom/index.js';

export {
StorageSettings,
TransactionLogSettings,
IPCClientSettings,
SchemaValidationError,
} from './storage';
} from './storage/index.js';
2 changes: 1 addition & 1 deletion src/btree/binary-pointer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BPlusTreeLeaf } from './tree-leaf';
import { BPlusTreeLeaf } from './tree-leaf.js';

export type BinaryPointer = {
name: string;
Expand Down
10 changes: 5 additions & 5 deletions src/btree/binary-reader.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Utils } from 'acebase-core';
import { readByteLength, readSignedNumber } from '../binary';
import { DetailedError } from '../detailed-error';
import { pfs } from '../promise-fs';
import { assert } from '../assert';
import { BPlusTree } from './tree';
import { readByteLength, readSignedNumber } from '../binary.js';
import { DetailedError } from '../detailed-error.js';
import { pfs } from '../promise-fs/index.js';
import { assert } from '../assert.js';
import { BPlusTree } from './tree.js';
const { bytesToNumber } = Utils;

export type ReadFunction = (index: number, length: number) => Promise<Buffer>;
Expand Down
4 changes: 2 additions & 2 deletions src/btree/binary-reference.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BPlusTreeLeaf } from './tree-leaf';
import { BPlusTreeNode } from './tree-node';
import { BPlusTreeLeaf } from './tree-leaf.js';
import { BPlusTreeNode } from './tree-node.js';

export type BinaryReference = {
name: string;
Expand Down
20 changes: 10 additions & 10 deletions src/btree/binary-tree-builder.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Uint8ArrayBuilder, writeByteLength, writeSignedOffset } from '../binary';
import { DetailedError } from '../detailed-error';
import { MAX_SMALL_LEAF_VALUE_LENGTH, WRITE_SMALL_LEAFS } from './config';
import { BPlusTree } from './tree';
import { BPlusTreeLeafEntryValue } from './tree-leaf-entry-value';
import { BinaryBPlusTreeLeafEntry } from './binary-tree-leaf-entry';
import { Uint8ArrayBuilder, writeByteLength, writeSignedOffset } from '../binary.js';
import { DetailedError } from '../detailed-error.js';
import { MAX_SMALL_LEAF_VALUE_LENGTH, WRITE_SMALL_LEAFS } from './config.js';
import { BPlusTree } from './tree.js';
import { BPlusTreeLeafEntryValue } from './tree-leaf-entry-value.js';
import { BinaryBPlusTreeLeafEntry } from './binary-tree-leaf-entry.js';
import { Utils } from 'acebase-core';
import { LeafEntryRecordPointer } from './leaf-entry-recordpointer';
import { LeafEntryMetaData } from './leaf-entry-metadata';
import { NodeEntryKeyType } from './entry-key-type';
import { assert } from '../assert';
import { LeafEntryRecordPointer } from './leaf-entry-recordpointer.js';
import { LeafEntryMetaData } from './leaf-entry-metadata.js';
import { NodeEntryKeyType } from './entry-key-type.js';
import { assert } from '../assert.js';

const { bigintToBytes, encodeString, numberToBytes } = Utils;

Expand Down
8 changes: 4 additions & 4 deletions src/btree/binary-tree-leaf-entry-extdata.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ThreadSafeLock } from '../thread-safe';
import { BinaryBPlusTreeLeafEntryValue } from './binary-tree-leaf-entry-value';
import { LeafEntryMetaData } from './leaf-entry-metadata';
import { LeafEntryRecordPointer } from './leaf-entry-recordpointer';
import { ThreadSafeLock } from '../thread-safe.js';
import { BinaryBPlusTreeLeafEntryValue } from './binary-tree-leaf-entry-value.js';
import { LeafEntryMetaData } from './leaf-entry-metadata.js';
import { LeafEntryRecordPointer } from './leaf-entry-recordpointer.js';

export interface IBinaryBPlusTreeLeafEntryExtData {
length: number;
Expand Down
4 changes: 2 additions & 2 deletions src/btree/binary-tree-leaf-entry-value.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LeafEntryMetaData } from './leaf-entry-metadata';
import { LeafEntryRecordPointer } from './leaf-entry-recordpointer';
import { LeafEntryMetaData } from './leaf-entry-metadata.js';
import { LeafEntryRecordPointer } from './leaf-entry-recordpointer.js';

export class BinaryBPlusTreeLeafEntryValue {
/**
Expand Down
6 changes: 3 additions & 3 deletions src/btree/binary-tree-leaf-entry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IBinaryBPlusTreeLeafEntryExtData } from './binary-tree-leaf-entry-extdata';
import { BinaryBPlusTreeLeafEntryValue } from './binary-tree-leaf-entry-value';
import { NodeEntryKeyType } from './entry-key-type';
import { IBinaryBPlusTreeLeafEntryExtData } from './binary-tree-leaf-entry-extdata.js';
import { BinaryBPlusTreeLeafEntryValue } from './binary-tree-leaf-entry-value.js';
import { NodeEntryKeyType } from './entry-key-type.js';

export class BinaryBPlusTreeLeafEntry {

Expand Down
12 changes: 6 additions & 6 deletions src/btree/binary-tree-leaf.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { assert } from '../assert';
import { DetailedError } from '../detailed-error';
import { BinaryBPlusTreeLeafEntry } from './binary-tree-leaf-entry';
import { BinaryBPlusTreeNodeInfo } from './binary-tree-node-info';
import { NodeEntryKeyType } from './entry-key-type';
import { _isEqual } from './typesafe-compare';
import { assert } from '../assert.js';
import { DetailedError } from '../detailed-error.js';
import { BinaryBPlusTreeLeafEntry } from './binary-tree-leaf-entry.js';
import { BinaryBPlusTreeNodeInfo } from './binary-tree-node-info.js';
import { NodeEntryKeyType } from './entry-key-type.js';
import { _isEqual } from './typesafe-compare.js';

export class BinaryBPlusTreeLeaf extends BinaryBPlusTreeNodeInfo {

Expand Down
6 changes: 3 additions & 3 deletions src/btree/binary-tree-node-entry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DetailedError } from '../detailed-error';
import { BinaryBPlusTreeNodeInfo } from './binary-tree-node-info';
import { NodeEntryKeyType } from './entry-key-type';
import { DetailedError } from '../detailed-error.js';
import { BinaryBPlusTreeNodeInfo } from './binary-tree-node-info.js';
import { NodeEntryKeyType } from './entry-key-type.js';

export class BinaryBPlusTreeNodeEntry {
ltChildOffset: number = null;
Expand Down
6 changes: 3 additions & 3 deletions src/btree/binary-tree-node-info.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BinaryBPlusTree } from './binary-tree';
import { BinaryBPlusTreeNode } from './binary-tree-node';
import { BinaryBPlusTreeNodeEntry } from './binary-tree-node-entry';
import { BinaryBPlusTree } from './binary-tree.js';
import { BinaryBPlusTreeNode } from './binary-tree-node.js';
import { BinaryBPlusTreeNodeEntry } from './binary-tree-node-entry.js';

export class BinaryBPlusTreeNodeInfo {
tree?: BinaryBPlusTree;
Expand Down
6 changes: 3 additions & 3 deletions src/btree/binary-tree-node.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DetailedError } from '../detailed-error';
import { BinaryBPlusTreeNodeEntry } from './binary-tree-node-entry';
import { BinaryBPlusTreeNodeInfo } from './binary-tree-node-info';
import { DetailedError } from '../detailed-error.js';
import { BinaryBPlusTreeNodeEntry } from './binary-tree-node-entry.js';
import { BinaryBPlusTreeNodeInfo } from './binary-tree-node-info.js';

export class BinaryBPlusTreeNode extends BinaryBPlusTreeNodeInfo {

Expand Down
8 changes: 4 additions & 4 deletions src/btree/binary-tree-transaction-operation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BinaryBPlusTreeLeafEntryValue } from './binary-tree-leaf-entry-value';
import { NodeEntryKeyType } from './entry-key-type';
import { LeafEntryMetaData } from './leaf-entry-metadata';
import { LeafEntryRecordPointer } from './leaf-entry-recordpointer';
import { BinaryBPlusTreeLeafEntryValue } from './binary-tree-leaf-entry-value.js';
import { NodeEntryKeyType } from './entry-key-type.js';
import { LeafEntryMetaData } from './leaf-entry-metadata.js';
import { LeafEntryRecordPointer } from './leaf-entry-recordpointer.js';

export class BinaryBPlusTreeTransactionOperation {
static add(key: NodeEntryKeyType, recordPointer: LeafEntryRecordPointer, metadata?: LeafEntryMetaData) {
Expand Down
Loading