2020-08-10 11:07:20 +02:00
|
|
|
import { BridgeIDBFactory, DatabaseList } from "./BridgeIDBFactory";
|
2019-07-31 01:33:23 +02:00
|
|
|
import { BridgeIDBCursor } from "./BridgeIDBCursor";
|
|
|
|
import { BridgeIDBIndex } from "./BridgeIDBIndex";
|
2020-08-03 09:30:48 +02:00
|
|
|
import { BridgeIDBDatabase } from "./BridgeIDBDatabase";
|
|
|
|
import { BridgeIDBKeyRange } from "./BridgeIDBKeyRange";
|
|
|
|
import { BridgeIDBObjectStore } from "./BridgeIDBObjectStore";
|
|
|
|
import { BridgeIDBOpenDBRequest } from "./BridgeIDBOpenDBRequest";
|
|
|
|
import { BridgeIDBRequest } from "./BridgeIDBRequest";
|
|
|
|
import { BridgeIDBTransaction } from "./BridgeIDBTransaction";
|
|
|
|
import { BridgeIDBVersionChangeEvent } from "./BridgeIDBVersionChangeEvent";
|
2020-08-10 11:07:20 +02:00
|
|
|
import {
|
|
|
|
Value,
|
|
|
|
CursorSource,
|
|
|
|
CursorRange,
|
|
|
|
BridgeIDBCursorDirection,
|
|
|
|
Key,
|
|
|
|
KeyPath,
|
|
|
|
TransactionMode,
|
|
|
|
FakeDOMStringList,
|
|
|
|
RequestObj,
|
|
|
|
BridgeIDBDatabaseInfo,
|
|
|
|
EventType,
|
|
|
|
} from "./util/types";
|
|
|
|
import {
|
|
|
|
DatabaseTransaction,
|
|
|
|
RecordGetResponse,
|
|
|
|
RecordGetRequest,
|
|
|
|
Schema,
|
|
|
|
Backend,
|
|
|
|
RecordStoreRequest,
|
|
|
|
RecordStoreResponse,
|
|
|
|
DatabaseConnection,
|
|
|
|
ObjectStoreProperties,
|
|
|
|
StoreLevel,
|
|
|
|
ResultLevel,
|
|
|
|
IndexProperties,
|
|
|
|
} from "./backend-interface";
|
|
|
|
import FakeEventTarget, { Listener } from "./util/FakeEventTarget";
|
2020-08-12 09:11:00 +02:00
|
|
|
import {
|
|
|
|
DatabaseDump,
|
|
|
|
ObjectStoreDump,
|
|
|
|
IndexDump,
|
|
|
|
IndexRecord,
|
|
|
|
ObjectStoreRecord,
|
|
|
|
MemoryBackendDump,
|
|
|
|
} from "./MemoryBackend";
|
2020-08-10 11:07:20 +02:00
|
|
|
import { Event } from "./idbtypes";
|
2019-07-31 01:33:23 +02:00
|
|
|
|
2020-08-10 11:07:20 +02:00
|
|
|
export {
|
|
|
|
BridgeIDBCursor,
|
|
|
|
BridgeIDBCursorDirection,
|
|
|
|
BridgeIDBDatabase,
|
|
|
|
BridgeIDBDatabaseInfo,
|
|
|
|
BridgeIDBFactory,
|
|
|
|
BridgeIDBIndex,
|
|
|
|
BridgeIDBKeyRange,
|
|
|
|
BridgeIDBObjectStore,
|
|
|
|
BridgeIDBOpenDBRequest,
|
|
|
|
BridgeIDBRequest,
|
|
|
|
BridgeIDBTransaction,
|
|
|
|
Value,
|
|
|
|
CursorSource,
|
|
|
|
CursorRange,
|
|
|
|
Key,
|
|
|
|
DatabaseTransaction,
|
|
|
|
RecordGetRequest,
|
|
|
|
RecordGetResponse,
|
|
|
|
KeyPath,
|
|
|
|
Schema,
|
|
|
|
Backend,
|
|
|
|
TransactionMode,
|
|
|
|
DatabaseList,
|
|
|
|
RecordStoreRequest,
|
|
|
|
RecordStoreResponse,
|
|
|
|
FakeEventTarget,
|
|
|
|
DatabaseConnection,
|
|
|
|
FakeDOMStringList,
|
|
|
|
ObjectStoreProperties,
|
|
|
|
RequestObj,
|
|
|
|
StoreLevel,
|
|
|
|
ResultLevel,
|
|
|
|
DatabaseDump,
|
|
|
|
ObjectStoreDump,
|
|
|
|
IndexDump,
|
|
|
|
IndexRecord,
|
|
|
|
ObjectStoreRecord,
|
|
|
|
EventType,
|
|
|
|
IndexProperties,
|
|
|
|
MemoryBackendDump,
|
|
|
|
Event,
|
|
|
|
Listener,
|
|
|
|
};
|
2019-07-31 01:33:23 +02:00
|
|
|
|
|
|
|
export { MemoryBackend } from "./MemoryBackend";
|
|
|
|
|
|
|
|
// globalThis polyfill, see https://mathiasbynens.be/notes/globalthis
|
2020-08-03 09:30:48 +02:00
|
|
|
(function () {
|
2019-07-31 01:33:23 +02:00
|
|
|
if (typeof globalThis === "object") return;
|
|
|
|
Object.defineProperty(Object.prototype, "__magic__", {
|
2020-08-03 09:30:48 +02:00
|
|
|
get: function () {
|
2019-07-31 01:33:23 +02:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
configurable: true, // This makes it possible to `delete` the getter later.
|
|
|
|
});
|
|
|
|
// @ts-ignore: polyfill magic
|
|
|
|
__magic__.globalThis = __magic__; // lolwat
|
|
|
|
// @ts-ignore: polyfill magic
|
|
|
|
delete Object.prototype.__magic__;
|
|
|
|
})();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Populate the global name space such that the given IndexedDB factory is made
|
|
|
|
* available globally.
|
2020-08-10 11:07:20 +02:00
|
|
|
*
|
|
|
|
* @public
|
2019-07-31 01:33:23 +02:00
|
|
|
*/
|
|
|
|
export function shimIndexedDB(factory: BridgeIDBFactory): void {
|
|
|
|
// @ts-ignore: shimming
|
|
|
|
globalThis.indexedDB = factory;
|
|
|
|
// @ts-ignore: shimming
|
|
|
|
globalThis.IDBCursor = BridgeIDBCursor;
|
|
|
|
// @ts-ignore: shimming
|
|
|
|
globalThis.IDBKeyRange = BridgeIDBKeyRange;
|
|
|
|
// @ts-ignore: shimming
|
|
|
|
globalThis.IDBDatabase = BridgeIDBDatabase;
|
|
|
|
// @ts-ignore: shimming
|
|
|
|
globalThis.IDBFactory = BridgeIDBFactory;
|
|
|
|
// @ts-ignore: shimming
|
|
|
|
globalThis.IDBIndex = BridgeIDBIndex;
|
|
|
|
// @ts-ignore: shimming
|
|
|
|
globalThis.IDBKeyRange = BridgeIDBKeyRange;
|
|
|
|
// @ts-ignore: shimming
|
|
|
|
globalThis.IDBObjectStore = BridgeIDBObjectStore;
|
|
|
|
// @ts-ignore: shimming
|
|
|
|
globalThis.IDBOpenDBRequest = BridgeIDBOpenDBRequest;
|
|
|
|
// @ts-ignore: shimming
|
|
|
|
globalThis.IDBRequest = BridgeIDBRequest;
|
|
|
|
// @ts-ignore: shimming
|
|
|
|
globalThis.IDBTransaction = BridgeIDBTransaction;
|
|
|
|
// @ts-ignore: shimming
|
|
|
|
globalThis.IDBVersionChangeEvent = BridgeIDBVersionChangeEvent;
|
|
|
|
}
|
2020-08-03 09:30:48 +02:00
|
|
|
|
2020-08-10 11:07:20 +02:00
|
|
|
export * from "./idbtypes";
|