2020-08-10 11:07:20 +02:00
|
|
|
import {
|
|
|
|
DatabaseTransaction,
|
|
|
|
RecordGetResponse,
|
|
|
|
RecordGetRequest,
|
|
|
|
Schema,
|
|
|
|
Backend,
|
|
|
|
RecordStoreRequest,
|
|
|
|
RecordStoreResponse,
|
|
|
|
DatabaseConnection,
|
|
|
|
ObjectStoreProperties,
|
|
|
|
StoreLevel,
|
|
|
|
ResultLevel,
|
|
|
|
IndexProperties,
|
|
|
|
} from "./backend-interface";
|
2021-02-18 11:25:23 +01:00
|
|
|
import { Listener } from "./util/FakeEventTarget";
|
2020-08-12 09:11:00 +02:00
|
|
|
import {
|
|
|
|
DatabaseDump,
|
|
|
|
ObjectStoreDump,
|
|
|
|
IndexRecord,
|
|
|
|
ObjectStoreRecord,
|
|
|
|
MemoryBackendDump,
|
|
|
|
} from "./MemoryBackend";
|
2020-08-10 11:07:20 +02:00
|
|
|
import { Event } from "./idbtypes";
|
2021-02-08 15:23:44 +01:00
|
|
|
import {
|
|
|
|
BridgeIDBCursor,
|
|
|
|
BridgeIDBDatabase,
|
|
|
|
BridgeIDBFactory,
|
|
|
|
BridgeIDBIndex,
|
|
|
|
BridgeIDBKeyRange,
|
|
|
|
BridgeIDBObjectStore,
|
|
|
|
BridgeIDBOpenDBRequest,
|
|
|
|
BridgeIDBRequest,
|
|
|
|
BridgeIDBTransaction,
|
2021-02-18 11:25:23 +01:00
|
|
|
BridgeIDBVersionChangeEvent,
|
2021-02-08 15:23:44 +01:00
|
|
|
DatabaseList,
|
|
|
|
RequestObj,
|
|
|
|
} from "./bridge-idb";
|
2019-07-31 01:33:23 +02:00
|
|
|
|
2020-08-10 11:07:20 +02:00
|
|
|
export {
|
|
|
|
BridgeIDBCursor,
|
|
|
|
BridgeIDBDatabase,
|
|
|
|
BridgeIDBFactory,
|
|
|
|
BridgeIDBIndex,
|
|
|
|
BridgeIDBKeyRange,
|
|
|
|
BridgeIDBObjectStore,
|
|
|
|
BridgeIDBOpenDBRequest,
|
|
|
|
BridgeIDBRequest,
|
|
|
|
BridgeIDBTransaction,
|
2021-02-08 15:23:44 +01:00
|
|
|
StoreLevel,
|
|
|
|
ResultLevel,
|
|
|
|
};
|
|
|
|
export type {
|
2020-08-10 11:07:20 +02:00
|
|
|
DatabaseTransaction,
|
|
|
|
RecordGetRequest,
|
|
|
|
RecordGetResponse,
|
|
|
|
Schema,
|
|
|
|
Backend,
|
|
|
|
DatabaseList,
|
|
|
|
RecordStoreRequest,
|
|
|
|
RecordStoreResponse,
|
|
|
|
DatabaseConnection,
|
|
|
|
ObjectStoreProperties,
|
|
|
|
RequestObj,
|
|
|
|
DatabaseDump,
|
|
|
|
ObjectStoreDump,
|
|
|
|
IndexRecord,
|
|
|
|
ObjectStoreRecord,
|
|
|
|
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
|
2021-02-18 11:25:23 +01:00
|
|
|
const g = globalThis as any;
|
|
|
|
|
|
|
|
g.indexedDB = factory;
|
|
|
|
g.IDBCursor = BridgeIDBCursor;
|
|
|
|
g.IDBKeyRange = BridgeIDBKeyRange;
|
|
|
|
g.IDBDatabase = BridgeIDBDatabase;
|
|
|
|
g.IDBFactory = BridgeIDBFactory;
|
|
|
|
g.IDBIndex = BridgeIDBIndex;
|
|
|
|
g.IDBKeyRange = BridgeIDBKeyRange;
|
|
|
|
g.IDBObjectStore = BridgeIDBObjectStore;
|
|
|
|
g.IDBOpenDBRequest = BridgeIDBOpenDBRequest;
|
|
|
|
g.IDBRequest = BridgeIDBRequest;
|
|
|
|
g.IDBTransaction = BridgeIDBTransaction;
|
|
|
|
g.IDBVersionChangeEvent = BridgeIDBVersionChangeEvent;
|
2019-07-31 01:33:23 +02:00
|
|
|
}
|
2020-08-03 09:30:48 +02:00
|
|
|
|
2020-08-10 11:07:20 +02:00
|
|
|
export * from "./idbtypes";
|
2021-02-24 01:28:02 +01:00
|
|
|
|
2021-06-09 15:26:18 +02:00
|
|
|
export * from "./util/structuredClone";
|