@powersync/web 1.31.0 → 1.32.0
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/_journeyapps_wa-sqlite-_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapp-89f0ba.index.umd.js +1867 -0
- package/dist/_journeyapps_wa-sqlite-_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapp-89f0ba.index.umd.js.map +1 -0
- package/dist/_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapps_wa-sqlite_src_example-2530150.index.umd.js +555 -0
- package/dist/_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapps_wa-sqlite_src_example-2530150.index.umd.js.map +1 -0
- package/dist/_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapps_wa-sqlite_src_example-2530151.index.umd.js +555 -0
- package/dist/_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapps_wa-sqlite_src_example-2530151.index.umd.js.map +1 -0
- package/dist/index.umd.js +4575 -43416
- package/dist/index.umd.js.map +1 -1
- package/dist/worker/SharedSyncImplementation.umd.js +402 -2053
- package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
- package/dist/worker/WASQLiteDB.umd.js +449 -2104
- package/dist/worker/WASQLiteDB.umd.js.map +1 -1
- package/dist/worker/{node_modules_bson_lib_bson_mjs.umd.js → node_modules_pnpm_bson_6_10_4_node_modules_bson_lib_bson_mjs.umd.js} +6 -6
- package/dist/worker/node_modules_pnpm_bson_6_10_4_node_modules_bson_lib_bson_mjs.umd.js.map +1 -0
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-3a94cf.umd.js +44 -0
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-3a94cf.umd.js.map +1 -0
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-868779.umd.js +44 -0
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-868779.umd.js.map +1 -0
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_wa-sqli-f60d0d.umd.js +44 -0
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_wa-sqli-f60d0d.umd.js.map +1 -0
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js +44 -0
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js.map +1 -0
- package/dist/worker/{node_modules_journeyapps_wa-sqlite_src_examples_IDBBatchAtomicVFS_js.umd.js → node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_src_examples-0d2437.umd.js} +24 -24
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_src_examples-0d2437.umd.js.map +1 -0
- package/dist/worker/{node_modules_journeyapps_wa-sqlite_src_examples_OPFSCoopSyncVFS_js.umd.js → node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_src_examples-1d4e74.umd.js} +18 -18
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_src_examples-1d4e74.umd.js.map +1 -0
- package/dist/worker/{node_modules_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js.umd.js → node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_src_examples-3622cf.umd.js} +18 -18
- package/dist/worker/node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_src_examples-3622cf.umd.js.map +1 -0
- package/lib/package.json +26 -22
- package/lib/src/db/NavigatorTriggerClaimManager.d.ts +6 -0
- package/lib/src/db/NavigatorTriggerClaimManager.js +20 -0
- package/lib/src/db/PowerSyncDatabase.d.ts +5 -2
- package/lib/src/db/PowerSyncDatabase.js +46 -8
- package/lib/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.d.ts +1 -1
- package/lib/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.js +1 -1
- package/lib/src/db/adapters/AbstractWebSQLOpenFactory.d.ts +2 -2
- package/lib/src/db/adapters/AbstractWebSQLOpenFactory.js +2 -2
- package/lib/src/db/adapters/AsyncDatabaseConnection.d.ts +1 -1
- package/lib/src/db/adapters/LockedAsyncDatabaseAdapter.d.ts +4 -4
- package/lib/src/db/adapters/LockedAsyncDatabaseAdapter.js +8 -4
- package/lib/src/db/adapters/WebDBAdapter.d.ts +5 -2
- package/lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.d.ts +2 -2
- package/lib/src/db/adapters/wa-sqlite/InternalWASQLiteDBAdapter.d.ts +12 -0
- package/lib/src/db/adapters/wa-sqlite/InternalWASQLiteDBAdapter.js +19 -0
- package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.d.ts +2 -2
- package/lib/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.d.ts +4 -4
- package/lib/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.js +6 -6
- package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.d.ts +4 -4
- package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.js +7 -7
- package/lib/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.d.ts +1 -1
- package/lib/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.js +3 -3
- package/lib/src/db/sync/SharedWebStreamingSyncImplementation.d.ts +5 -5
- package/lib/src/db/sync/SharedWebStreamingSyncImplementation.js +5 -5
- package/lib/src/db/sync/WebRemote.js +1 -1
- package/lib/src/db/sync/WebStreamingSyncImplementation.d.ts +1 -1
- package/lib/src/db/sync/WebStreamingSyncImplementation.js +1 -1
- package/lib/src/index.d.ts +12 -12
- package/lib/src/index.js +12 -12
- package/lib/src/worker/db/SharedWASQLiteConnection.d.ts +2 -2
- package/lib/src/worker/db/WASQLiteDB.worker.js +3 -3
- package/lib/src/worker/db/WorkerWASQLiteConnection.d.ts +2 -2
- package/lib/src/worker/db/WorkerWASQLiteConnection.js +1 -1
- package/lib/src/worker/db/open-worker-database.d.ts +2 -2
- package/lib/src/worker/db/open-worker-database.js +1 -1
- package/lib/src/worker/sync/BroadcastLogger.d.ts +1 -1
- package/lib/src/worker/sync/SharedSyncImplementation.d.ts +4 -4
- package/lib/src/worker/sync/SharedSyncImplementation.js +5 -5
- package/lib/src/worker/sync/SharedSyncImplementation.worker.js +2 -2
- package/lib/src/worker/sync/WorkerClient.d.ts +1 -1
- package/lib/src/worker/sync/WorkerClient.js +2 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -17
- package/src/db/NavigatorTriggerClaimManager.ts +23 -0
- package/src/db/PowerSyncDatabase.ts +53 -9
- package/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.ts +1 -1
- package/src/db/adapters/AbstractWebSQLOpenFactory.ts +3 -3
- package/src/db/adapters/AsyncDatabaseConnection.ts +1 -1
- package/src/db/adapters/LockedAsyncDatabaseAdapter.ts +13 -9
- package/src/db/adapters/WebDBAdapter.ts +6 -2
- package/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.ts +2 -2
- package/src/db/adapters/wa-sqlite/InternalWASQLiteDBAdapter.ts +23 -0
- package/src/db/adapters/wa-sqlite/WASQLiteConnection.ts +2 -2
- package/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.ts +8 -8
- package/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.ts +8 -8
- package/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.ts +3 -3
- package/src/db/sync/SharedWebStreamingSyncImplementation.ts +7 -7
- package/src/db/sync/WebRemote.ts +1 -1
- package/src/db/sync/WebStreamingSyncImplementation.ts +2 -2
- package/src/index.ts +12 -12
- package/src/worker/db/SharedWASQLiteConnection.ts +2 -2
- package/src/worker/db/WASQLiteDB.worker.ts +5 -5
- package/src/worker/db/WorkerWASQLiteConnection.ts +2 -2
- package/src/worker/db/open-worker-database.ts +2 -2
- package/src/worker/sync/BroadcastLogger.ts +1 -1
- package/src/worker/sync/SharedSyncImplementation.ts +9 -9
- package/src/worker/sync/SharedSyncImplementation.worker.ts +2 -2
- package/src/worker/sync/WorkerClient.ts +2 -2
- package/dist/worker/node_modules_bson_lib_bson_mjs.umd.js.map +0 -1
- package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_mc-wa-sqlite-async_mjs.umd.js +0 -44
- package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_mc-wa-sqlite-async_mjs.umd.js.map +0 -1
- package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_mc-wa-sqlite_mjs.umd.js +0 -44
- package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_mc-wa-sqlite_mjs.umd.js.map +0 -1
- package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_wa-sqlite-async_mjs.umd.js +0 -44
- package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_wa-sqlite-async_mjs.umd.js.map +0 -1
- package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js +0 -44
- package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js.map +0 -1
- package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js.umd.js.map +0 -1
- package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_IDBBatchAtomicVFS_js.umd.js.map +0 -1
- package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_OPFSCoopSyncVFS_js.umd.js.map +0 -1
- /package/bin/{powersync.js → powersync.cjs} +0 -0
|
@@ -3,10 +3,10 @@ var sdk_web;
|
|
|
3
3
|
/******/ "use strict";
|
|
4
4
|
/******/ var __webpack_modules__ = ({
|
|
5
5
|
|
|
6
|
-
/***/ "../../node_modules/@journeyapps/wa-sqlite/src/sqlite-api.js"
|
|
7
|
-
|
|
8
|
-
!*** ../../node_modules/@journeyapps/wa-sqlite/src/sqlite-api.js ***!
|
|
9
|
-
|
|
6
|
+
/***/ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/src/sqlite-api.js"
|
|
7
|
+
/*!*******************************************************************************************************************!*\
|
|
8
|
+
!*** ../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/src/sqlite-api.js ***!
|
|
9
|
+
\*******************************************************************************************************************/
|
|
10
10
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
11
11
|
|
|
12
12
|
__webpack_require__.r(__webpack_exports__);
|
|
@@ -246,7 +246,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
246
246
|
/* harmony export */ SQLITE_WARNING: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_WARNING),
|
|
247
247
|
/* harmony export */ SQLiteError: () => (/* binding */ SQLiteError)
|
|
248
248
|
/* harmony export */ });
|
|
249
|
-
/* harmony import */ var _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sqlite-constants.js */ "../../node_modules/@journeyapps/wa-sqlite/src/sqlite-constants.js");
|
|
249
|
+
/* harmony import */ var _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sqlite-constants.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/src/sqlite-constants.js");
|
|
250
250
|
// Copyright 2021 Roy T. Hashimoto. All Rights Reserved.
|
|
251
251
|
|
|
252
252
|
|
|
@@ -1198,10 +1198,10 @@ function decl(s) {
|
|
|
1198
1198
|
|
|
1199
1199
|
/***/ },
|
|
1200
1200
|
|
|
1201
|
-
/***/ "../../node_modules/@journeyapps/wa-sqlite/src/sqlite-constants.js"
|
|
1202
|
-
|
|
1203
|
-
!*** ../../node_modules/@journeyapps/wa-sqlite/src/sqlite-constants.js ***!
|
|
1204
|
-
|
|
1201
|
+
/***/ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/src/sqlite-constants.js"
|
|
1202
|
+
/*!*************************************************************************************************************************!*\
|
|
1203
|
+
!*** ../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/src/sqlite-constants.js ***!
|
|
1204
|
+
\*************************************************************************************************************************/
|
|
1205
1205
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
1206
1206
|
|
|
1207
1207
|
__webpack_require__.r(__webpack_exports__);
|
|
@@ -1717,10 +1717,10 @@ const SQLITE_PREPARE_NO_VTAB = 0x04;
|
|
|
1717
1717
|
|
|
1718
1718
|
/***/ },
|
|
1719
1719
|
|
|
1720
|
-
/***/ "../../node_modules/async-mutex/index.mjs"
|
|
1721
|
-
|
|
1722
|
-
!*** ../../node_modules/async-mutex/index.mjs ***!
|
|
1723
|
-
|
|
1720
|
+
/***/ "../../node_modules/.pnpm/async-mutex@0.5.0/node_modules/async-mutex/index.mjs"
|
|
1721
|
+
/*!*************************************************************************************!*\
|
|
1722
|
+
!*** ../../node_modules/.pnpm/async-mutex@0.5.0/node_modules/async-mutex/index.mjs ***!
|
|
1723
|
+
\*************************************************************************************/
|
|
1724
1724
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
1725
1725
|
|
|
1726
1726
|
__webpack_require__.r(__webpack_exports__);
|
|
@@ -2028,10 +2028,10 @@ function tryAcquire(sync, alreadyAcquiredError = E_ALREADY_LOCKED) {
|
|
|
2028
2028
|
|
|
2029
2029
|
/***/ },
|
|
2030
2030
|
|
|
2031
|
-
/***/ "../../node_modules/comlink/dist/esm/comlink.mjs"
|
|
2032
|
-
|
|
2033
|
-
!*** ../../node_modules/comlink/dist/esm/comlink.mjs ***!
|
|
2034
|
-
|
|
2031
|
+
/***/ "../../node_modules/.pnpm/comlink@4.4.2/node_modules/comlink/dist/esm/comlink.mjs"
|
|
2032
|
+
/*!****************************************************************************************!*\
|
|
2033
|
+
!*** ../../node_modules/.pnpm/comlink@4.4.2/node_modules/comlink/dist/esm/comlink.mjs ***!
|
|
2034
|
+
\****************************************************************************************/
|
|
2035
2035
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
2036
2036
|
|
|
2037
2037
|
__webpack_require__.r(__webpack_exports__);
|
|
@@ -2466,12 +2466,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2466
2466
|
/* harmony export */ LogLevel: () => (/* binding */ LogLevel),
|
|
2467
2467
|
/* harmony export */ MAX_AMOUNT_OF_COLUMNS: () => (/* binding */ MAX_AMOUNT_OF_COLUMNS),
|
|
2468
2468
|
/* harmony export */ MAX_OP_ID: () => (/* binding */ MAX_OP_ID),
|
|
2469
|
+
/* harmony export */ MEMORY_TRIGGER_CLAIM_MANAGER: () => (/* binding */ MEMORY_TRIGGER_CLAIM_MANAGER),
|
|
2469
2470
|
/* harmony export */ OnChangeQueryProcessor: () => (/* binding */ OnChangeQueryProcessor),
|
|
2470
2471
|
/* harmony export */ OpType: () => (/* binding */ OpType),
|
|
2471
2472
|
/* harmony export */ OpTypeEnum: () => (/* binding */ OpTypeEnum),
|
|
2472
2473
|
/* harmony export */ OplogEntry: () => (/* binding */ OplogEntry),
|
|
2473
2474
|
/* harmony export */ PSInternalTable: () => (/* binding */ PSInternalTable),
|
|
2474
2475
|
/* harmony export */ PowerSyncControlCommand: () => (/* binding */ PowerSyncControlCommand),
|
|
2476
|
+
/* harmony export */ RawTable: () => (/* binding */ RawTable),
|
|
2475
2477
|
/* harmony export */ RowUpdateType: () => (/* binding */ RowUpdateType),
|
|
2476
2478
|
/* harmony export */ Schema: () => (/* binding */ Schema),
|
|
2477
2479
|
/* harmony export */ SqliteBucketStorage: () => (/* binding */ SqliteBucketStorage),
|
|
@@ -2483,6 +2485,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2483
2485
|
/* harmony export */ SyncStreamConnectionMethod: () => (/* binding */ SyncStreamConnectionMethod),
|
|
2484
2486
|
/* harmony export */ Table: () => (/* binding */ Table),
|
|
2485
2487
|
/* harmony export */ TableV2: () => (/* binding */ TableV2),
|
|
2488
|
+
/* harmony export */ TriggerManagerImpl: () => (/* binding */ TriggerManagerImpl),
|
|
2486
2489
|
/* harmony export */ UpdateType: () => (/* binding */ UpdateType),
|
|
2487
2490
|
/* harmony export */ UploadQueueStats: () => (/* binding */ UploadQueueStats),
|
|
2488
2491
|
/* harmony export */ WatchedQueryListenerEvent: () => (/* binding */ WatchedQueryListenerEvent),
|
|
@@ -2509,7 +2512,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2509
2512
|
/* harmony export */ sanitizeSQL: () => (/* binding */ sanitizeSQL),
|
|
2510
2513
|
/* harmony export */ sanitizeUUID: () => (/* binding */ sanitizeUUID)
|
|
2511
2514
|
/* harmony export */ });
|
|
2512
|
-
/* harmony import */ var async_mutex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! async-mutex */ "../../node_modules/async-mutex/index.mjs");
|
|
2515
|
+
/* harmony import */ var async_mutex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! async-mutex */ "../../node_modules/.pnpm/async-mutex@0.5.0/node_modules/async-mutex/index.mjs");
|
|
2513
2516
|
|
|
2514
2517
|
|
|
2515
2518
|
function getDefaultExportFromCjs (x) {
|
|
@@ -4599,7 +4602,7 @@ class SyncDataBucket {
|
|
|
4599
4602
|
}
|
|
4600
4603
|
}
|
|
4601
4604
|
|
|
4602
|
-
var buffer
|
|
4605
|
+
var buffer = {};
|
|
4603
4606
|
|
|
4604
4607
|
var base64Js = {};
|
|
4605
4608
|
|
|
@@ -4863,11 +4866,11 @@ function requireIeee754 () {
|
|
|
4863
4866
|
* @license MIT
|
|
4864
4867
|
*/
|
|
4865
4868
|
|
|
4866
|
-
var hasRequiredBuffer
|
|
4869
|
+
var hasRequiredBuffer;
|
|
4867
4870
|
|
|
4868
|
-
function requireBuffer
|
|
4869
|
-
if (hasRequiredBuffer
|
|
4870
|
-
hasRequiredBuffer
|
|
4871
|
+
function requireBuffer () {
|
|
4872
|
+
if (hasRequiredBuffer) return buffer;
|
|
4873
|
+
hasRequiredBuffer = 1;
|
|
4871
4874
|
(function (exports$1) {
|
|
4872
4875
|
|
|
4873
4876
|
const base64 = requireBase64Js();
|
|
@@ -6723,1920 +6726,79 @@ function requireBuffer$1 () {
|
|
|
6723
6726
|
let received = input;
|
|
6724
6727
|
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
|
|
6725
6728
|
received = addNumericalSeparator(String(input));
|
|
6726
|
-
} else if (typeof input === 'bigint') {
|
|
6727
|
-
received = String(input);
|
|
6728
|
-
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
|
|
6729
|
-
received = addNumericalSeparator(received);
|
|
6730
|
-
}
|
|
6731
|
-
received += 'n';
|
|
6732
|
-
}
|
|
6733
|
-
msg += ` It must be ${range}. Received ${received}`;
|
|
6734
|
-
return msg
|
|
6735
|
-
}, RangeError);
|
|
6736
|
-
|
|
6737
|
-
function addNumericalSeparator (val) {
|
|
6738
|
-
let res = '';
|
|
6739
|
-
let i = val.length;
|
|
6740
|
-
const start = val[0] === '-' ? 1 : 0;
|
|
6741
|
-
for (; i >= start + 4; i -= 3) {
|
|
6742
|
-
res = `_${val.slice(i - 3, i)}${res}`;
|
|
6743
|
-
}
|
|
6744
|
-
return `${val.slice(0, i)}${res}`
|
|
6745
|
-
}
|
|
6746
|
-
|
|
6747
|
-
// CHECK FUNCTIONS
|
|
6748
|
-
// ===============
|
|
6749
|
-
|
|
6750
|
-
function checkBounds (buf, offset, byteLength) {
|
|
6751
|
-
validateNumber(offset, 'offset');
|
|
6752
|
-
if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
|
|
6753
|
-
boundsError(offset, buf.length - (byteLength + 1));
|
|
6754
|
-
}
|
|
6755
|
-
}
|
|
6756
|
-
|
|
6757
|
-
function checkIntBI (value, min, max, buf, offset, byteLength) {
|
|
6758
|
-
if (value > max || value < min) {
|
|
6759
|
-
const n = typeof min === 'bigint' ? 'n' : '';
|
|
6760
|
-
let range;
|
|
6761
|
-
{
|
|
6762
|
-
if (min === 0 || min === BigInt(0)) {
|
|
6763
|
-
range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
|
|
6764
|
-
} else {
|
|
6765
|
-
range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
|
|
6766
|
-
`${(byteLength + 1) * 8 - 1}${n}`;
|
|
6767
|
-
}
|
|
6768
|
-
}
|
|
6769
|
-
throw new errors.ERR_OUT_OF_RANGE('value', range, value)
|
|
6770
|
-
}
|
|
6771
|
-
checkBounds(buf, offset, byteLength);
|
|
6772
|
-
}
|
|
6773
|
-
|
|
6774
|
-
function validateNumber (value, name) {
|
|
6775
|
-
if (typeof value !== 'number') {
|
|
6776
|
-
throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
|
|
6777
|
-
}
|
|
6778
|
-
}
|
|
6779
|
-
|
|
6780
|
-
function boundsError (value, length, type) {
|
|
6781
|
-
if (Math.floor(value) !== value) {
|
|
6782
|
-
validateNumber(value, type);
|
|
6783
|
-
throw new errors.ERR_OUT_OF_RANGE('offset', 'an integer', value)
|
|
6784
|
-
}
|
|
6785
|
-
|
|
6786
|
-
if (length < 0) {
|
|
6787
|
-
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
|
|
6788
|
-
}
|
|
6789
|
-
|
|
6790
|
-
throw new errors.ERR_OUT_OF_RANGE('offset',
|
|
6791
|
-
`>= ${0} and <= ${length}`,
|
|
6792
|
-
value)
|
|
6793
|
-
}
|
|
6794
|
-
|
|
6795
|
-
// HELPER FUNCTIONS
|
|
6796
|
-
// ================
|
|
6797
|
-
|
|
6798
|
-
const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
|
|
6799
|
-
|
|
6800
|
-
function base64clean (str) {
|
|
6801
|
-
// Node takes equal signs as end of the Base64 encoding
|
|
6802
|
-
str = str.split('=')[0];
|
|
6803
|
-
// Node strips out invalid characters like \n and \t from the string, base64-js does not
|
|
6804
|
-
str = str.trim().replace(INVALID_BASE64_RE, '');
|
|
6805
|
-
// Node converts strings with length < 2 to ''
|
|
6806
|
-
if (str.length < 2) return ''
|
|
6807
|
-
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
|
|
6808
|
-
while (str.length % 4 !== 0) {
|
|
6809
|
-
str = str + '=';
|
|
6810
|
-
}
|
|
6811
|
-
return str
|
|
6812
|
-
}
|
|
6813
|
-
|
|
6814
|
-
function utf8ToBytes (string, units) {
|
|
6815
|
-
units = units || Infinity;
|
|
6816
|
-
let codePoint;
|
|
6817
|
-
const length = string.length;
|
|
6818
|
-
let leadSurrogate = null;
|
|
6819
|
-
const bytes = [];
|
|
6820
|
-
|
|
6821
|
-
for (let i = 0; i < length; ++i) {
|
|
6822
|
-
codePoint = string.charCodeAt(i);
|
|
6823
|
-
|
|
6824
|
-
// is surrogate component
|
|
6825
|
-
if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
|
6826
|
-
// last char was a lead
|
|
6827
|
-
if (!leadSurrogate) {
|
|
6828
|
-
// no lead yet
|
|
6829
|
-
if (codePoint > 0xDBFF) {
|
|
6830
|
-
// unexpected trail
|
|
6831
|
-
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
6832
|
-
continue
|
|
6833
|
-
} else if (i + 1 === length) {
|
|
6834
|
-
// unpaired lead
|
|
6835
|
-
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
6836
|
-
continue
|
|
6837
|
-
}
|
|
6838
|
-
|
|
6839
|
-
// valid lead
|
|
6840
|
-
leadSurrogate = codePoint;
|
|
6841
|
-
|
|
6842
|
-
continue
|
|
6843
|
-
}
|
|
6844
|
-
|
|
6845
|
-
// 2 leads in a row
|
|
6846
|
-
if (codePoint < 0xDC00) {
|
|
6847
|
-
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
6848
|
-
leadSurrogate = codePoint;
|
|
6849
|
-
continue
|
|
6850
|
-
}
|
|
6851
|
-
|
|
6852
|
-
// valid surrogate pair
|
|
6853
|
-
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
|
|
6854
|
-
} else if (leadSurrogate) {
|
|
6855
|
-
// valid bmp char, but last char was a lead
|
|
6856
|
-
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
6857
|
-
}
|
|
6858
|
-
|
|
6859
|
-
leadSurrogate = null;
|
|
6860
|
-
|
|
6861
|
-
// encode utf8
|
|
6862
|
-
if (codePoint < 0x80) {
|
|
6863
|
-
if ((units -= 1) < 0) break
|
|
6864
|
-
bytes.push(codePoint);
|
|
6865
|
-
} else if (codePoint < 0x800) {
|
|
6866
|
-
if ((units -= 2) < 0) break
|
|
6867
|
-
bytes.push(
|
|
6868
|
-
codePoint >> 0x6 | 0xC0,
|
|
6869
|
-
codePoint & 0x3F | 0x80
|
|
6870
|
-
);
|
|
6871
|
-
} else if (codePoint < 0x10000) {
|
|
6872
|
-
if ((units -= 3) < 0) break
|
|
6873
|
-
bytes.push(
|
|
6874
|
-
codePoint >> 0xC | 0xE0,
|
|
6875
|
-
codePoint >> 0x6 & 0x3F | 0x80,
|
|
6876
|
-
codePoint & 0x3F | 0x80
|
|
6877
|
-
);
|
|
6878
|
-
} else if (codePoint < 0x110000) {
|
|
6879
|
-
if ((units -= 4) < 0) break
|
|
6880
|
-
bytes.push(
|
|
6881
|
-
codePoint >> 0x12 | 0xF0,
|
|
6882
|
-
codePoint >> 0xC & 0x3F | 0x80,
|
|
6883
|
-
codePoint >> 0x6 & 0x3F | 0x80,
|
|
6884
|
-
codePoint & 0x3F | 0x80
|
|
6885
|
-
);
|
|
6886
|
-
} else {
|
|
6887
|
-
throw new Error('Invalid code point')
|
|
6888
|
-
}
|
|
6889
|
-
}
|
|
6890
|
-
|
|
6891
|
-
return bytes
|
|
6892
|
-
}
|
|
6893
|
-
|
|
6894
|
-
function asciiToBytes (str) {
|
|
6895
|
-
const byteArray = [];
|
|
6896
|
-
for (let i = 0; i < str.length; ++i) {
|
|
6897
|
-
// Node's code seems to be doing this and not & 0x7F..
|
|
6898
|
-
byteArray.push(str.charCodeAt(i) & 0xFF);
|
|
6899
|
-
}
|
|
6900
|
-
return byteArray
|
|
6901
|
-
}
|
|
6902
|
-
|
|
6903
|
-
function utf16leToBytes (str, units) {
|
|
6904
|
-
let c, hi, lo;
|
|
6905
|
-
const byteArray = [];
|
|
6906
|
-
for (let i = 0; i < str.length; ++i) {
|
|
6907
|
-
if ((units -= 2) < 0) break
|
|
6908
|
-
|
|
6909
|
-
c = str.charCodeAt(i);
|
|
6910
|
-
hi = c >> 8;
|
|
6911
|
-
lo = c % 256;
|
|
6912
|
-
byteArray.push(lo);
|
|
6913
|
-
byteArray.push(hi);
|
|
6914
|
-
}
|
|
6915
|
-
|
|
6916
|
-
return byteArray
|
|
6917
|
-
}
|
|
6918
|
-
|
|
6919
|
-
function base64ToBytes (str) {
|
|
6920
|
-
return base64.toByteArray(base64clean(str))
|
|
6921
|
-
}
|
|
6922
|
-
|
|
6923
|
-
function blitBuffer (src, dst, offset, length) {
|
|
6924
|
-
let i;
|
|
6925
|
-
for (i = 0; i < length; ++i) {
|
|
6926
|
-
if ((i + offset >= dst.length) || (i >= src.length)) break
|
|
6927
|
-
dst[i + offset] = src[i];
|
|
6928
|
-
}
|
|
6929
|
-
return i
|
|
6930
|
-
}
|
|
6931
|
-
|
|
6932
|
-
// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
|
|
6933
|
-
// the `instanceof` check but they should be treated as of that type.
|
|
6934
|
-
// See: https://github.com/feross/buffer/issues/166
|
|
6935
|
-
function isInstance (obj, type) {
|
|
6936
|
-
return obj instanceof type ||
|
|
6937
|
-
(obj != null && obj.constructor != null && obj.constructor.name != null &&
|
|
6938
|
-
obj.constructor.name === type.name)
|
|
6939
|
-
}
|
|
6940
|
-
function numberIsNaN (obj) {
|
|
6941
|
-
// For IE11 support
|
|
6942
|
-
return obj !== obj // eslint-disable-line no-self-compare
|
|
6943
|
-
}
|
|
6944
|
-
|
|
6945
|
-
// Create lookup table for `toString('hex')`
|
|
6946
|
-
// See: https://github.com/feross/buffer/issues/219
|
|
6947
|
-
const hexSliceLookupTable = (function () {
|
|
6948
|
-
const alphabet = '0123456789abcdef';
|
|
6949
|
-
const table = new Array(256);
|
|
6950
|
-
for (let i = 0; i < 16; ++i) {
|
|
6951
|
-
const i16 = i * 16;
|
|
6952
|
-
for (let j = 0; j < 16; ++j) {
|
|
6953
|
-
table[i16 + j] = alphabet[i] + alphabet[j];
|
|
6954
|
-
}
|
|
6955
|
-
}
|
|
6956
|
-
return table
|
|
6957
|
-
})();
|
|
6958
|
-
|
|
6959
|
-
// Return not function with Error if BigInt not supported
|
|
6960
|
-
function defineBigIntMethod (fn) {
|
|
6961
|
-
return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
|
|
6962
|
-
}
|
|
6963
|
-
|
|
6964
|
-
function BufferBigIntNotDefined () {
|
|
6965
|
-
throw new Error('BigInt not supported')
|
|
6966
|
-
}
|
|
6967
|
-
} (buffer$1));
|
|
6968
|
-
return buffer$1;
|
|
6969
|
-
}
|
|
6970
|
-
|
|
6971
|
-
var bufferExports$1 = requireBuffer$1();
|
|
6972
|
-
|
|
6973
|
-
var dist = {};
|
|
6974
|
-
|
|
6975
|
-
var buffer = {};
|
|
6976
|
-
|
|
6977
|
-
/*!
|
|
6978
|
-
* The buffer module from node.js, for the browser.
|
|
6979
|
-
*
|
|
6980
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
6981
|
-
* @license MIT
|
|
6982
|
-
*/
|
|
6983
|
-
|
|
6984
|
-
var hasRequiredBuffer;
|
|
6985
|
-
|
|
6986
|
-
function requireBuffer () {
|
|
6987
|
-
if (hasRequiredBuffer) return buffer;
|
|
6988
|
-
hasRequiredBuffer = 1;
|
|
6989
|
-
(function (exports$1) {
|
|
6990
|
-
|
|
6991
|
-
var base64 = requireBase64Js();
|
|
6992
|
-
var ieee754 = requireIeee754();
|
|
6993
|
-
var customInspectSymbol =
|
|
6994
|
-
(typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
|
|
6995
|
-
? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
|
|
6996
|
-
: null;
|
|
6997
|
-
|
|
6998
|
-
exports$1.Buffer = Buffer;
|
|
6999
|
-
exports$1.SlowBuffer = SlowBuffer;
|
|
7000
|
-
exports$1.INSPECT_MAX_BYTES = 50;
|
|
7001
|
-
|
|
7002
|
-
var K_MAX_LENGTH = 0x7fffffff;
|
|
7003
|
-
exports$1.kMaxLength = K_MAX_LENGTH;
|
|
7004
|
-
|
|
7005
|
-
/**
|
|
7006
|
-
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
7007
|
-
* === true Use Uint8Array implementation (fastest)
|
|
7008
|
-
* === false Print warning and recommend using `buffer` v4.x which has an Object
|
|
7009
|
-
* implementation (most compatible, even IE6)
|
|
7010
|
-
*
|
|
7011
|
-
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
|
|
7012
|
-
* Opera 11.6+, iOS 4.2+.
|
|
7013
|
-
*
|
|
7014
|
-
* We report that the browser does not support typed arrays if the are not subclassable
|
|
7015
|
-
* using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
|
|
7016
|
-
* (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
|
|
7017
|
-
* for __proto__ and has a buggy typed array implementation.
|
|
7018
|
-
*/
|
|
7019
|
-
Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
|
|
7020
|
-
|
|
7021
|
-
if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
|
|
7022
|
-
typeof console.error === 'function') {
|
|
7023
|
-
console.error(
|
|
7024
|
-
'This browser lacks typed array (Uint8Array) support which is required by ' +
|
|
7025
|
-
'`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
|
|
7026
|
-
);
|
|
7027
|
-
}
|
|
7028
|
-
|
|
7029
|
-
function typedArraySupport () {
|
|
7030
|
-
// Can typed array instances can be augmented?
|
|
7031
|
-
try {
|
|
7032
|
-
var arr = new Uint8Array(1);
|
|
7033
|
-
var proto = { foo: function () { return 42 } };
|
|
7034
|
-
Object.setPrototypeOf(proto, Uint8Array.prototype);
|
|
7035
|
-
Object.setPrototypeOf(arr, proto);
|
|
7036
|
-
return arr.foo() === 42
|
|
7037
|
-
} catch (e) {
|
|
7038
|
-
return false
|
|
7039
|
-
}
|
|
7040
|
-
}
|
|
7041
|
-
|
|
7042
|
-
Object.defineProperty(Buffer.prototype, 'parent', {
|
|
7043
|
-
enumerable: true,
|
|
7044
|
-
get: function () {
|
|
7045
|
-
if (!Buffer.isBuffer(this)) return undefined
|
|
7046
|
-
return this.buffer
|
|
7047
|
-
}
|
|
7048
|
-
});
|
|
7049
|
-
|
|
7050
|
-
Object.defineProperty(Buffer.prototype, 'offset', {
|
|
7051
|
-
enumerable: true,
|
|
7052
|
-
get: function () {
|
|
7053
|
-
if (!Buffer.isBuffer(this)) return undefined
|
|
7054
|
-
return this.byteOffset
|
|
7055
|
-
}
|
|
7056
|
-
});
|
|
7057
|
-
|
|
7058
|
-
function createBuffer (length) {
|
|
7059
|
-
if (length > K_MAX_LENGTH) {
|
|
7060
|
-
throw new RangeError('The value "' + length + '" is invalid for option "size"')
|
|
7061
|
-
}
|
|
7062
|
-
// Return an augmented `Uint8Array` instance
|
|
7063
|
-
var buf = new Uint8Array(length);
|
|
7064
|
-
Object.setPrototypeOf(buf, Buffer.prototype);
|
|
7065
|
-
return buf
|
|
7066
|
-
}
|
|
7067
|
-
|
|
7068
|
-
/**
|
|
7069
|
-
* The Buffer constructor returns instances of `Uint8Array` that have their
|
|
7070
|
-
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
|
|
7071
|
-
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
|
|
7072
|
-
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
|
|
7073
|
-
* returns a single octet.
|
|
7074
|
-
*
|
|
7075
|
-
* The `Uint8Array` prototype remains unmodified.
|
|
7076
|
-
*/
|
|
7077
|
-
|
|
7078
|
-
function Buffer (arg, encodingOrOffset, length) {
|
|
7079
|
-
// Common case.
|
|
7080
|
-
if (typeof arg === 'number') {
|
|
7081
|
-
if (typeof encodingOrOffset === 'string') {
|
|
7082
|
-
throw new TypeError(
|
|
7083
|
-
'The "string" argument must be of type string. Received type number'
|
|
7084
|
-
)
|
|
7085
|
-
}
|
|
7086
|
-
return allocUnsafe(arg)
|
|
7087
|
-
}
|
|
7088
|
-
return from(arg, encodingOrOffset, length)
|
|
7089
|
-
}
|
|
7090
|
-
|
|
7091
|
-
Buffer.poolSize = 8192; // not used by this implementation
|
|
7092
|
-
|
|
7093
|
-
function from (value, encodingOrOffset, length) {
|
|
7094
|
-
if (typeof value === 'string') {
|
|
7095
|
-
return fromString(value, encodingOrOffset)
|
|
7096
|
-
}
|
|
7097
|
-
|
|
7098
|
-
if (ArrayBuffer.isView(value)) {
|
|
7099
|
-
return fromArrayView(value)
|
|
7100
|
-
}
|
|
7101
|
-
|
|
7102
|
-
if (value == null) {
|
|
7103
|
-
throw new TypeError(
|
|
7104
|
-
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
|
7105
|
-
'or Array-like Object. Received type ' + (typeof value)
|
|
7106
|
-
)
|
|
7107
|
-
}
|
|
7108
|
-
|
|
7109
|
-
if (isInstance(value, ArrayBuffer) ||
|
|
7110
|
-
(value && isInstance(value.buffer, ArrayBuffer))) {
|
|
7111
|
-
return fromArrayBuffer(value, encodingOrOffset, length)
|
|
7112
|
-
}
|
|
7113
|
-
|
|
7114
|
-
if (typeof SharedArrayBuffer !== 'undefined' &&
|
|
7115
|
-
(isInstance(value, SharedArrayBuffer) ||
|
|
7116
|
-
(value && isInstance(value.buffer, SharedArrayBuffer)))) {
|
|
7117
|
-
return fromArrayBuffer(value, encodingOrOffset, length)
|
|
7118
|
-
}
|
|
7119
|
-
|
|
7120
|
-
if (typeof value === 'number') {
|
|
7121
|
-
throw new TypeError(
|
|
7122
|
-
'The "value" argument must not be of type number. Received type number'
|
|
7123
|
-
)
|
|
7124
|
-
}
|
|
7125
|
-
|
|
7126
|
-
var valueOf = value.valueOf && value.valueOf();
|
|
7127
|
-
if (valueOf != null && valueOf !== value) {
|
|
7128
|
-
return Buffer.from(valueOf, encodingOrOffset, length)
|
|
7129
|
-
}
|
|
7130
|
-
|
|
7131
|
-
var b = fromObject(value);
|
|
7132
|
-
if (b) return b
|
|
7133
|
-
|
|
7134
|
-
if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
|
|
7135
|
-
typeof value[Symbol.toPrimitive] === 'function') {
|
|
7136
|
-
return Buffer.from(
|
|
7137
|
-
value[Symbol.toPrimitive]('string'), encodingOrOffset, length
|
|
7138
|
-
)
|
|
7139
|
-
}
|
|
7140
|
-
|
|
7141
|
-
throw new TypeError(
|
|
7142
|
-
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
|
7143
|
-
'or Array-like Object. Received type ' + (typeof value)
|
|
7144
|
-
)
|
|
7145
|
-
}
|
|
7146
|
-
|
|
7147
|
-
/**
|
|
7148
|
-
* Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
|
|
7149
|
-
* if value is a number.
|
|
7150
|
-
* Buffer.from(str[, encoding])
|
|
7151
|
-
* Buffer.from(array)
|
|
7152
|
-
* Buffer.from(buffer)
|
|
7153
|
-
* Buffer.from(arrayBuffer[, byteOffset[, length]])
|
|
7154
|
-
**/
|
|
7155
|
-
Buffer.from = function (value, encodingOrOffset, length) {
|
|
7156
|
-
return from(value, encodingOrOffset, length)
|
|
7157
|
-
};
|
|
7158
|
-
|
|
7159
|
-
// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
|
|
7160
|
-
// https://github.com/feross/buffer/pull/148
|
|
7161
|
-
Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
|
|
7162
|
-
Object.setPrototypeOf(Buffer, Uint8Array);
|
|
7163
|
-
|
|
7164
|
-
function assertSize (size) {
|
|
7165
|
-
if (typeof size !== 'number') {
|
|
7166
|
-
throw new TypeError('"size" argument must be of type number')
|
|
7167
|
-
} else if (size < 0) {
|
|
7168
|
-
throw new RangeError('The value "' + size + '" is invalid for option "size"')
|
|
7169
|
-
}
|
|
7170
|
-
}
|
|
7171
|
-
|
|
7172
|
-
function alloc (size, fill, encoding) {
|
|
7173
|
-
assertSize(size);
|
|
7174
|
-
if (size <= 0) {
|
|
7175
|
-
return createBuffer(size)
|
|
7176
|
-
}
|
|
7177
|
-
if (fill !== undefined) {
|
|
7178
|
-
// Only pay attention to encoding if it's a string. This
|
|
7179
|
-
// prevents accidentally sending in a number that would
|
|
7180
|
-
// be interpreted as a start offset.
|
|
7181
|
-
return typeof encoding === 'string'
|
|
7182
|
-
? createBuffer(size).fill(fill, encoding)
|
|
7183
|
-
: createBuffer(size).fill(fill)
|
|
7184
|
-
}
|
|
7185
|
-
return createBuffer(size)
|
|
7186
|
-
}
|
|
7187
|
-
|
|
7188
|
-
/**
|
|
7189
|
-
* Creates a new filled Buffer instance.
|
|
7190
|
-
* alloc(size[, fill[, encoding]])
|
|
7191
|
-
**/
|
|
7192
|
-
Buffer.alloc = function (size, fill, encoding) {
|
|
7193
|
-
return alloc(size, fill, encoding)
|
|
7194
|
-
};
|
|
7195
|
-
|
|
7196
|
-
function allocUnsafe (size) {
|
|
7197
|
-
assertSize(size);
|
|
7198
|
-
return createBuffer(size < 0 ? 0 : checked(size) | 0)
|
|
7199
|
-
}
|
|
7200
|
-
|
|
7201
|
-
/**
|
|
7202
|
-
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
|
|
7203
|
-
* */
|
|
7204
|
-
Buffer.allocUnsafe = function (size) {
|
|
7205
|
-
return allocUnsafe(size)
|
|
7206
|
-
};
|
|
7207
|
-
/**
|
|
7208
|
-
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
|
7209
|
-
*/
|
|
7210
|
-
Buffer.allocUnsafeSlow = function (size) {
|
|
7211
|
-
return allocUnsafe(size)
|
|
7212
|
-
};
|
|
7213
|
-
|
|
7214
|
-
function fromString (string, encoding) {
|
|
7215
|
-
if (typeof encoding !== 'string' || encoding === '') {
|
|
7216
|
-
encoding = 'utf8';
|
|
7217
|
-
}
|
|
7218
|
-
|
|
7219
|
-
if (!Buffer.isEncoding(encoding)) {
|
|
7220
|
-
throw new TypeError('Unknown encoding: ' + encoding)
|
|
7221
|
-
}
|
|
7222
|
-
|
|
7223
|
-
var length = byteLength(string, encoding) | 0;
|
|
7224
|
-
var buf = createBuffer(length);
|
|
7225
|
-
|
|
7226
|
-
var actual = buf.write(string, encoding);
|
|
7227
|
-
|
|
7228
|
-
if (actual !== length) {
|
|
7229
|
-
// Writing a hex string, for example, that contains invalid characters will
|
|
7230
|
-
// cause everything after the first invalid character to be ignored. (e.g.
|
|
7231
|
-
// 'abxxcd' will be treated as 'ab')
|
|
7232
|
-
buf = buf.slice(0, actual);
|
|
7233
|
-
}
|
|
7234
|
-
|
|
7235
|
-
return buf
|
|
7236
|
-
}
|
|
7237
|
-
|
|
7238
|
-
function fromArrayLike (array) {
|
|
7239
|
-
var length = array.length < 0 ? 0 : checked(array.length) | 0;
|
|
7240
|
-
var buf = createBuffer(length);
|
|
7241
|
-
for (var i = 0; i < length; i += 1) {
|
|
7242
|
-
buf[i] = array[i] & 255;
|
|
7243
|
-
}
|
|
7244
|
-
return buf
|
|
7245
|
-
}
|
|
7246
|
-
|
|
7247
|
-
function fromArrayView (arrayView) {
|
|
7248
|
-
if (isInstance(arrayView, Uint8Array)) {
|
|
7249
|
-
var copy = new Uint8Array(arrayView);
|
|
7250
|
-
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
|
|
7251
|
-
}
|
|
7252
|
-
return fromArrayLike(arrayView)
|
|
7253
|
-
}
|
|
7254
|
-
|
|
7255
|
-
function fromArrayBuffer (array, byteOffset, length) {
|
|
7256
|
-
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
|
7257
|
-
throw new RangeError('"offset" is outside of buffer bounds')
|
|
7258
|
-
}
|
|
7259
|
-
|
|
7260
|
-
if (array.byteLength < byteOffset + (length || 0)) {
|
|
7261
|
-
throw new RangeError('"length" is outside of buffer bounds')
|
|
7262
|
-
}
|
|
7263
|
-
|
|
7264
|
-
var buf;
|
|
7265
|
-
if (byteOffset === undefined && length === undefined) {
|
|
7266
|
-
buf = new Uint8Array(array);
|
|
7267
|
-
} else if (length === undefined) {
|
|
7268
|
-
buf = new Uint8Array(array, byteOffset);
|
|
7269
|
-
} else {
|
|
7270
|
-
buf = new Uint8Array(array, byteOffset, length);
|
|
7271
|
-
}
|
|
7272
|
-
|
|
7273
|
-
// Return an augmented `Uint8Array` instance
|
|
7274
|
-
Object.setPrototypeOf(buf, Buffer.prototype);
|
|
7275
|
-
|
|
7276
|
-
return buf
|
|
7277
|
-
}
|
|
7278
|
-
|
|
7279
|
-
function fromObject (obj) {
|
|
7280
|
-
if (Buffer.isBuffer(obj)) {
|
|
7281
|
-
var len = checked(obj.length) | 0;
|
|
7282
|
-
var buf = createBuffer(len);
|
|
7283
|
-
|
|
7284
|
-
if (buf.length === 0) {
|
|
7285
|
-
return buf
|
|
7286
|
-
}
|
|
7287
|
-
|
|
7288
|
-
obj.copy(buf, 0, 0, len);
|
|
7289
|
-
return buf
|
|
7290
|
-
}
|
|
7291
|
-
|
|
7292
|
-
if (obj.length !== undefined) {
|
|
7293
|
-
if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
|
|
7294
|
-
return createBuffer(0)
|
|
7295
|
-
}
|
|
7296
|
-
return fromArrayLike(obj)
|
|
7297
|
-
}
|
|
7298
|
-
|
|
7299
|
-
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
|
|
7300
|
-
return fromArrayLike(obj.data)
|
|
7301
|
-
}
|
|
7302
|
-
}
|
|
7303
|
-
|
|
7304
|
-
function checked (length) {
|
|
7305
|
-
// Note: cannot use `length < K_MAX_LENGTH` here because that fails when
|
|
7306
|
-
// length is NaN (which is otherwise coerced to zero.)
|
|
7307
|
-
if (length >= K_MAX_LENGTH) {
|
|
7308
|
-
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
|
7309
|
-
'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
|
|
7310
|
-
}
|
|
7311
|
-
return length | 0
|
|
7312
|
-
}
|
|
7313
|
-
|
|
7314
|
-
function SlowBuffer (length) {
|
|
7315
|
-
if (+length != length) { // eslint-disable-line eqeqeq
|
|
7316
|
-
length = 0;
|
|
7317
|
-
}
|
|
7318
|
-
return Buffer.alloc(+length)
|
|
7319
|
-
}
|
|
7320
|
-
|
|
7321
|
-
Buffer.isBuffer = function isBuffer (b) {
|
|
7322
|
-
return b != null && b._isBuffer === true &&
|
|
7323
|
-
b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
|
|
7324
|
-
};
|
|
7325
|
-
|
|
7326
|
-
Buffer.compare = function compare (a, b) {
|
|
7327
|
-
if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength);
|
|
7328
|
-
if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength);
|
|
7329
|
-
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
|
7330
|
-
throw new TypeError(
|
|
7331
|
-
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
|
7332
|
-
)
|
|
7333
|
-
}
|
|
7334
|
-
|
|
7335
|
-
if (a === b) return 0
|
|
7336
|
-
|
|
7337
|
-
var x = a.length;
|
|
7338
|
-
var y = b.length;
|
|
7339
|
-
|
|
7340
|
-
for (var i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
7341
|
-
if (a[i] !== b[i]) {
|
|
7342
|
-
x = a[i];
|
|
7343
|
-
y = b[i];
|
|
7344
|
-
break
|
|
7345
|
-
}
|
|
7346
|
-
}
|
|
7347
|
-
|
|
7348
|
-
if (x < y) return -1
|
|
7349
|
-
if (y < x) return 1
|
|
7350
|
-
return 0
|
|
7351
|
-
};
|
|
7352
|
-
|
|
7353
|
-
Buffer.isEncoding = function isEncoding (encoding) {
|
|
7354
|
-
switch (String(encoding).toLowerCase()) {
|
|
7355
|
-
case 'hex':
|
|
7356
|
-
case 'utf8':
|
|
7357
|
-
case 'utf-8':
|
|
7358
|
-
case 'ascii':
|
|
7359
|
-
case 'latin1':
|
|
7360
|
-
case 'binary':
|
|
7361
|
-
case 'base64':
|
|
7362
|
-
case 'ucs2':
|
|
7363
|
-
case 'ucs-2':
|
|
7364
|
-
case 'utf16le':
|
|
7365
|
-
case 'utf-16le':
|
|
7366
|
-
return true
|
|
7367
|
-
default:
|
|
7368
|
-
return false
|
|
7369
|
-
}
|
|
7370
|
-
};
|
|
7371
|
-
|
|
7372
|
-
Buffer.concat = function concat (list, length) {
|
|
7373
|
-
if (!Array.isArray(list)) {
|
|
7374
|
-
throw new TypeError('"list" argument must be an Array of Buffers')
|
|
7375
|
-
}
|
|
7376
|
-
|
|
7377
|
-
if (list.length === 0) {
|
|
7378
|
-
return Buffer.alloc(0)
|
|
7379
|
-
}
|
|
7380
|
-
|
|
7381
|
-
var i;
|
|
7382
|
-
if (length === undefined) {
|
|
7383
|
-
length = 0;
|
|
7384
|
-
for (i = 0; i < list.length; ++i) {
|
|
7385
|
-
length += list[i].length;
|
|
7386
|
-
}
|
|
7387
|
-
}
|
|
7388
|
-
|
|
7389
|
-
var buffer = Buffer.allocUnsafe(length);
|
|
7390
|
-
var pos = 0;
|
|
7391
|
-
for (i = 0; i < list.length; ++i) {
|
|
7392
|
-
var buf = list[i];
|
|
7393
|
-
if (isInstance(buf, Uint8Array)) {
|
|
7394
|
-
if (pos + buf.length > buffer.length) {
|
|
7395
|
-
Buffer.from(buf).copy(buffer, pos);
|
|
7396
|
-
} else {
|
|
7397
|
-
Uint8Array.prototype.set.call(
|
|
7398
|
-
buffer,
|
|
7399
|
-
buf,
|
|
7400
|
-
pos
|
|
7401
|
-
);
|
|
7402
|
-
}
|
|
7403
|
-
} else if (!Buffer.isBuffer(buf)) {
|
|
7404
|
-
throw new TypeError('"list" argument must be an Array of Buffers')
|
|
7405
|
-
} else {
|
|
7406
|
-
buf.copy(buffer, pos);
|
|
7407
|
-
}
|
|
7408
|
-
pos += buf.length;
|
|
7409
|
-
}
|
|
7410
|
-
return buffer
|
|
7411
|
-
};
|
|
7412
|
-
|
|
7413
|
-
function byteLength (string, encoding) {
|
|
7414
|
-
if (Buffer.isBuffer(string)) {
|
|
7415
|
-
return string.length
|
|
7416
|
-
}
|
|
7417
|
-
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
|
|
7418
|
-
return string.byteLength
|
|
7419
|
-
}
|
|
7420
|
-
if (typeof string !== 'string') {
|
|
7421
|
-
throw new TypeError(
|
|
7422
|
-
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
|
|
7423
|
-
'Received type ' + typeof string
|
|
7424
|
-
)
|
|
7425
|
-
}
|
|
7426
|
-
|
|
7427
|
-
var len = string.length;
|
|
7428
|
-
var mustMatch = (arguments.length > 2 && arguments[2] === true);
|
|
7429
|
-
if (!mustMatch && len === 0) return 0
|
|
7430
|
-
|
|
7431
|
-
// Use a for loop to avoid recursion
|
|
7432
|
-
var loweredCase = false;
|
|
7433
|
-
for (;;) {
|
|
7434
|
-
switch (encoding) {
|
|
7435
|
-
case 'ascii':
|
|
7436
|
-
case 'latin1':
|
|
7437
|
-
case 'binary':
|
|
7438
|
-
return len
|
|
7439
|
-
case 'utf8':
|
|
7440
|
-
case 'utf-8':
|
|
7441
|
-
return utf8ToBytes(string).length
|
|
7442
|
-
case 'ucs2':
|
|
7443
|
-
case 'ucs-2':
|
|
7444
|
-
case 'utf16le':
|
|
7445
|
-
case 'utf-16le':
|
|
7446
|
-
return len * 2
|
|
7447
|
-
case 'hex':
|
|
7448
|
-
return len >>> 1
|
|
7449
|
-
case 'base64':
|
|
7450
|
-
return base64ToBytes(string).length
|
|
7451
|
-
default:
|
|
7452
|
-
if (loweredCase) {
|
|
7453
|
-
return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
|
|
7454
|
-
}
|
|
7455
|
-
encoding = ('' + encoding).toLowerCase();
|
|
7456
|
-
loweredCase = true;
|
|
7457
|
-
}
|
|
7458
|
-
}
|
|
7459
|
-
}
|
|
7460
|
-
Buffer.byteLength = byteLength;
|
|
7461
|
-
|
|
7462
|
-
function slowToString (encoding, start, end) {
|
|
7463
|
-
var loweredCase = false;
|
|
7464
|
-
|
|
7465
|
-
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
|
|
7466
|
-
// property of a typed array.
|
|
7467
|
-
|
|
7468
|
-
// This behaves neither like String nor Uint8Array in that we set start/end
|
|
7469
|
-
// to their upper/lower bounds if the value passed is out of range.
|
|
7470
|
-
// undefined is handled specially as per ECMA-262 6th Edition,
|
|
7471
|
-
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
|
|
7472
|
-
if (start === undefined || start < 0) {
|
|
7473
|
-
start = 0;
|
|
7474
|
-
}
|
|
7475
|
-
// Return early if start > this.length. Done here to prevent potential uint32
|
|
7476
|
-
// coercion fail below.
|
|
7477
|
-
if (start > this.length) {
|
|
7478
|
-
return ''
|
|
7479
|
-
}
|
|
7480
|
-
|
|
7481
|
-
if (end === undefined || end > this.length) {
|
|
7482
|
-
end = this.length;
|
|
7483
|
-
}
|
|
7484
|
-
|
|
7485
|
-
if (end <= 0) {
|
|
7486
|
-
return ''
|
|
7487
|
-
}
|
|
7488
|
-
|
|
7489
|
-
// Force coercion to uint32. This will also coerce falsey/NaN values to 0.
|
|
7490
|
-
end >>>= 0;
|
|
7491
|
-
start >>>= 0;
|
|
7492
|
-
|
|
7493
|
-
if (end <= start) {
|
|
7494
|
-
return ''
|
|
7495
|
-
}
|
|
7496
|
-
|
|
7497
|
-
if (!encoding) encoding = 'utf8';
|
|
7498
|
-
|
|
7499
|
-
while (true) {
|
|
7500
|
-
switch (encoding) {
|
|
7501
|
-
case 'hex':
|
|
7502
|
-
return hexSlice(this, start, end)
|
|
7503
|
-
|
|
7504
|
-
case 'utf8':
|
|
7505
|
-
case 'utf-8':
|
|
7506
|
-
return utf8Slice(this, start, end)
|
|
7507
|
-
|
|
7508
|
-
case 'ascii':
|
|
7509
|
-
return asciiSlice(this, start, end)
|
|
7510
|
-
|
|
7511
|
-
case 'latin1':
|
|
7512
|
-
case 'binary':
|
|
7513
|
-
return latin1Slice(this, start, end)
|
|
7514
|
-
|
|
7515
|
-
case 'base64':
|
|
7516
|
-
return base64Slice(this, start, end)
|
|
7517
|
-
|
|
7518
|
-
case 'ucs2':
|
|
7519
|
-
case 'ucs-2':
|
|
7520
|
-
case 'utf16le':
|
|
7521
|
-
case 'utf-16le':
|
|
7522
|
-
return utf16leSlice(this, start, end)
|
|
7523
|
-
|
|
7524
|
-
default:
|
|
7525
|
-
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
7526
|
-
encoding = (encoding + '').toLowerCase();
|
|
7527
|
-
loweredCase = true;
|
|
7528
|
-
}
|
|
7529
|
-
}
|
|
7530
|
-
}
|
|
7531
|
-
|
|
7532
|
-
// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
|
|
7533
|
-
// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
|
|
7534
|
-
// reliably in a browserify context because there could be multiple different
|
|
7535
|
-
// copies of the 'buffer' package in use. This method works even for Buffer
|
|
7536
|
-
// instances that were created from another copy of the `buffer` package.
|
|
7537
|
-
// See: https://github.com/feross/buffer/issues/154
|
|
7538
|
-
Buffer.prototype._isBuffer = true;
|
|
7539
|
-
|
|
7540
|
-
function swap (b, n, m) {
|
|
7541
|
-
var i = b[n];
|
|
7542
|
-
b[n] = b[m];
|
|
7543
|
-
b[m] = i;
|
|
7544
|
-
}
|
|
7545
|
-
|
|
7546
|
-
Buffer.prototype.swap16 = function swap16 () {
|
|
7547
|
-
var len = this.length;
|
|
7548
|
-
if (len % 2 !== 0) {
|
|
7549
|
-
throw new RangeError('Buffer size must be a multiple of 16-bits')
|
|
7550
|
-
}
|
|
7551
|
-
for (var i = 0; i < len; i += 2) {
|
|
7552
|
-
swap(this, i, i + 1);
|
|
7553
|
-
}
|
|
7554
|
-
return this
|
|
7555
|
-
};
|
|
7556
|
-
|
|
7557
|
-
Buffer.prototype.swap32 = function swap32 () {
|
|
7558
|
-
var len = this.length;
|
|
7559
|
-
if (len % 4 !== 0) {
|
|
7560
|
-
throw new RangeError('Buffer size must be a multiple of 32-bits')
|
|
7561
|
-
}
|
|
7562
|
-
for (var i = 0; i < len; i += 4) {
|
|
7563
|
-
swap(this, i, i + 3);
|
|
7564
|
-
swap(this, i + 1, i + 2);
|
|
7565
|
-
}
|
|
7566
|
-
return this
|
|
7567
|
-
};
|
|
7568
|
-
|
|
7569
|
-
Buffer.prototype.swap64 = function swap64 () {
|
|
7570
|
-
var len = this.length;
|
|
7571
|
-
if (len % 8 !== 0) {
|
|
7572
|
-
throw new RangeError('Buffer size must be a multiple of 64-bits')
|
|
7573
|
-
}
|
|
7574
|
-
for (var i = 0; i < len; i += 8) {
|
|
7575
|
-
swap(this, i, i + 7);
|
|
7576
|
-
swap(this, i + 1, i + 6);
|
|
7577
|
-
swap(this, i + 2, i + 5);
|
|
7578
|
-
swap(this, i + 3, i + 4);
|
|
7579
|
-
}
|
|
7580
|
-
return this
|
|
7581
|
-
};
|
|
7582
|
-
|
|
7583
|
-
Buffer.prototype.toString = function toString () {
|
|
7584
|
-
var length = this.length;
|
|
7585
|
-
if (length === 0) return ''
|
|
7586
|
-
if (arguments.length === 0) return utf8Slice(this, 0, length)
|
|
7587
|
-
return slowToString.apply(this, arguments)
|
|
7588
|
-
};
|
|
7589
|
-
|
|
7590
|
-
Buffer.prototype.toLocaleString = Buffer.prototype.toString;
|
|
7591
|
-
|
|
7592
|
-
Buffer.prototype.equals = function equals (b) {
|
|
7593
|
-
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
|
7594
|
-
if (this === b) return true
|
|
7595
|
-
return Buffer.compare(this, b) === 0
|
|
7596
|
-
};
|
|
7597
|
-
|
|
7598
|
-
Buffer.prototype.inspect = function inspect () {
|
|
7599
|
-
var str = '';
|
|
7600
|
-
var max = exports$1.INSPECT_MAX_BYTES;
|
|
7601
|
-
str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
|
|
7602
|
-
if (this.length > max) str += ' ... ';
|
|
7603
|
-
return '<Buffer ' + str + '>'
|
|
7604
|
-
};
|
|
7605
|
-
if (customInspectSymbol) {
|
|
7606
|
-
Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
|
|
7607
|
-
}
|
|
7608
|
-
|
|
7609
|
-
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
|
7610
|
-
if (isInstance(target, Uint8Array)) {
|
|
7611
|
-
target = Buffer.from(target, target.offset, target.byteLength);
|
|
7612
|
-
}
|
|
7613
|
-
if (!Buffer.isBuffer(target)) {
|
|
7614
|
-
throw new TypeError(
|
|
7615
|
-
'The "target" argument must be one of type Buffer or Uint8Array. ' +
|
|
7616
|
-
'Received type ' + (typeof target)
|
|
7617
|
-
)
|
|
7618
|
-
}
|
|
7619
|
-
|
|
7620
|
-
if (start === undefined) {
|
|
7621
|
-
start = 0;
|
|
7622
|
-
}
|
|
7623
|
-
if (end === undefined) {
|
|
7624
|
-
end = target ? target.length : 0;
|
|
7625
|
-
}
|
|
7626
|
-
if (thisStart === undefined) {
|
|
7627
|
-
thisStart = 0;
|
|
7628
|
-
}
|
|
7629
|
-
if (thisEnd === undefined) {
|
|
7630
|
-
thisEnd = this.length;
|
|
7631
|
-
}
|
|
7632
|
-
|
|
7633
|
-
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
|
7634
|
-
throw new RangeError('out of range index')
|
|
7635
|
-
}
|
|
7636
|
-
|
|
7637
|
-
if (thisStart >= thisEnd && start >= end) {
|
|
7638
|
-
return 0
|
|
7639
|
-
}
|
|
7640
|
-
if (thisStart >= thisEnd) {
|
|
7641
|
-
return -1
|
|
7642
|
-
}
|
|
7643
|
-
if (start >= end) {
|
|
7644
|
-
return 1
|
|
7645
|
-
}
|
|
7646
|
-
|
|
7647
|
-
start >>>= 0;
|
|
7648
|
-
end >>>= 0;
|
|
7649
|
-
thisStart >>>= 0;
|
|
7650
|
-
thisEnd >>>= 0;
|
|
7651
|
-
|
|
7652
|
-
if (this === target) return 0
|
|
7653
|
-
|
|
7654
|
-
var x = thisEnd - thisStart;
|
|
7655
|
-
var y = end - start;
|
|
7656
|
-
var len = Math.min(x, y);
|
|
7657
|
-
|
|
7658
|
-
var thisCopy = this.slice(thisStart, thisEnd);
|
|
7659
|
-
var targetCopy = target.slice(start, end);
|
|
7660
|
-
|
|
7661
|
-
for (var i = 0; i < len; ++i) {
|
|
7662
|
-
if (thisCopy[i] !== targetCopy[i]) {
|
|
7663
|
-
x = thisCopy[i];
|
|
7664
|
-
y = targetCopy[i];
|
|
7665
|
-
break
|
|
7666
|
-
}
|
|
7667
|
-
}
|
|
7668
|
-
|
|
7669
|
-
if (x < y) return -1
|
|
7670
|
-
if (y < x) return 1
|
|
7671
|
-
return 0
|
|
7672
|
-
};
|
|
7673
|
-
|
|
7674
|
-
// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
|
|
7675
|
-
// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
|
|
7676
|
-
//
|
|
7677
|
-
// Arguments:
|
|
7678
|
-
// - buffer - a Buffer to search
|
|
7679
|
-
// - val - a string, Buffer, or number
|
|
7680
|
-
// - byteOffset - an index into `buffer`; will be clamped to an int32
|
|
7681
|
-
// - encoding - an optional encoding, relevant is val is a string
|
|
7682
|
-
// - dir - true for indexOf, false for lastIndexOf
|
|
7683
|
-
function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
|
7684
|
-
// Empty buffer means no match
|
|
7685
|
-
if (buffer.length === 0) return -1
|
|
7686
|
-
|
|
7687
|
-
// Normalize byteOffset
|
|
7688
|
-
if (typeof byteOffset === 'string') {
|
|
7689
|
-
encoding = byteOffset;
|
|
7690
|
-
byteOffset = 0;
|
|
7691
|
-
} else if (byteOffset > 0x7fffffff) {
|
|
7692
|
-
byteOffset = 0x7fffffff;
|
|
7693
|
-
} else if (byteOffset < -2147483648) {
|
|
7694
|
-
byteOffset = -2147483648;
|
|
7695
|
-
}
|
|
7696
|
-
byteOffset = +byteOffset; // Coerce to Number.
|
|
7697
|
-
if (numberIsNaN(byteOffset)) {
|
|
7698
|
-
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
|
|
7699
|
-
byteOffset = dir ? 0 : (buffer.length - 1);
|
|
7700
|
-
}
|
|
7701
|
-
|
|
7702
|
-
// Normalize byteOffset: negative offsets start from the end of the buffer
|
|
7703
|
-
if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
|
|
7704
|
-
if (byteOffset >= buffer.length) {
|
|
7705
|
-
if (dir) return -1
|
|
7706
|
-
else byteOffset = buffer.length - 1;
|
|
7707
|
-
} else if (byteOffset < 0) {
|
|
7708
|
-
if (dir) byteOffset = 0;
|
|
7709
|
-
else return -1
|
|
7710
|
-
}
|
|
7711
|
-
|
|
7712
|
-
// Normalize val
|
|
7713
|
-
if (typeof val === 'string') {
|
|
7714
|
-
val = Buffer.from(val, encoding);
|
|
7715
|
-
}
|
|
7716
|
-
|
|
7717
|
-
// Finally, search either indexOf (if dir is true) or lastIndexOf
|
|
7718
|
-
if (Buffer.isBuffer(val)) {
|
|
7719
|
-
// Special case: looking for empty string/buffer always fails
|
|
7720
|
-
if (val.length === 0) {
|
|
7721
|
-
return -1
|
|
7722
|
-
}
|
|
7723
|
-
return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
|
|
7724
|
-
} else if (typeof val === 'number') {
|
|
7725
|
-
val = val & 0xFF; // Search for a byte value [0-255]
|
|
7726
|
-
if (typeof Uint8Array.prototype.indexOf === 'function') {
|
|
7727
|
-
if (dir) {
|
|
7728
|
-
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
|
|
7729
|
-
} else {
|
|
7730
|
-
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
|
|
7731
|
-
}
|
|
7732
|
-
}
|
|
7733
|
-
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
|
|
7734
|
-
}
|
|
7735
|
-
|
|
7736
|
-
throw new TypeError('val must be string, number or Buffer')
|
|
7737
|
-
}
|
|
7738
|
-
|
|
7739
|
-
function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
|
7740
|
-
var indexSize = 1;
|
|
7741
|
-
var arrLength = arr.length;
|
|
7742
|
-
var valLength = val.length;
|
|
7743
|
-
|
|
7744
|
-
if (encoding !== undefined) {
|
|
7745
|
-
encoding = String(encoding).toLowerCase();
|
|
7746
|
-
if (encoding === 'ucs2' || encoding === 'ucs-2' ||
|
|
7747
|
-
encoding === 'utf16le' || encoding === 'utf-16le') {
|
|
7748
|
-
if (arr.length < 2 || val.length < 2) {
|
|
7749
|
-
return -1
|
|
7750
|
-
}
|
|
7751
|
-
indexSize = 2;
|
|
7752
|
-
arrLength /= 2;
|
|
7753
|
-
valLength /= 2;
|
|
7754
|
-
byteOffset /= 2;
|
|
7755
|
-
}
|
|
7756
|
-
}
|
|
7757
|
-
|
|
7758
|
-
function read (buf, i) {
|
|
7759
|
-
if (indexSize === 1) {
|
|
7760
|
-
return buf[i]
|
|
7761
|
-
} else {
|
|
7762
|
-
return buf.readUInt16BE(i * indexSize)
|
|
7763
|
-
}
|
|
7764
|
-
}
|
|
7765
|
-
|
|
7766
|
-
var i;
|
|
7767
|
-
if (dir) {
|
|
7768
|
-
var foundIndex = -1;
|
|
7769
|
-
for (i = byteOffset; i < arrLength; i++) {
|
|
7770
|
-
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
7771
|
-
if (foundIndex === -1) foundIndex = i;
|
|
7772
|
-
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
|
|
7773
|
-
} else {
|
|
7774
|
-
if (foundIndex !== -1) i -= i - foundIndex;
|
|
7775
|
-
foundIndex = -1;
|
|
7776
|
-
}
|
|
7777
|
-
}
|
|
7778
|
-
} else {
|
|
7779
|
-
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
|
|
7780
|
-
for (i = byteOffset; i >= 0; i--) {
|
|
7781
|
-
var found = true;
|
|
7782
|
-
for (var j = 0; j < valLength; j++) {
|
|
7783
|
-
if (read(arr, i + j) !== read(val, j)) {
|
|
7784
|
-
found = false;
|
|
7785
|
-
break
|
|
7786
|
-
}
|
|
7787
|
-
}
|
|
7788
|
-
if (found) return i
|
|
7789
|
-
}
|
|
7790
|
-
}
|
|
7791
|
-
|
|
7792
|
-
return -1
|
|
7793
|
-
}
|
|
7794
|
-
|
|
7795
|
-
Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
|
|
7796
|
-
return this.indexOf(val, byteOffset, encoding) !== -1
|
|
7797
|
-
};
|
|
7798
|
-
|
|
7799
|
-
Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
|
|
7800
|
-
return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
|
|
7801
|
-
};
|
|
7802
|
-
|
|
7803
|
-
Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
|
|
7804
|
-
return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
|
|
7805
|
-
};
|
|
7806
|
-
|
|
7807
|
-
function hexWrite (buf, string, offset, length) {
|
|
7808
|
-
offset = Number(offset) || 0;
|
|
7809
|
-
var remaining = buf.length - offset;
|
|
7810
|
-
if (!length) {
|
|
7811
|
-
length = remaining;
|
|
7812
|
-
} else {
|
|
7813
|
-
length = Number(length);
|
|
7814
|
-
if (length > remaining) {
|
|
7815
|
-
length = remaining;
|
|
7816
|
-
}
|
|
7817
|
-
}
|
|
7818
|
-
|
|
7819
|
-
var strLen = string.length;
|
|
7820
|
-
|
|
7821
|
-
if (length > strLen / 2) {
|
|
7822
|
-
length = strLen / 2;
|
|
7823
|
-
}
|
|
7824
|
-
for (var i = 0; i < length; ++i) {
|
|
7825
|
-
var parsed = parseInt(string.substr(i * 2, 2), 16);
|
|
7826
|
-
if (numberIsNaN(parsed)) return i
|
|
7827
|
-
buf[offset + i] = parsed;
|
|
7828
|
-
}
|
|
7829
|
-
return i
|
|
7830
|
-
}
|
|
7831
|
-
|
|
7832
|
-
function utf8Write (buf, string, offset, length) {
|
|
7833
|
-
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
|
7834
|
-
}
|
|
7835
|
-
|
|
7836
|
-
function asciiWrite (buf, string, offset, length) {
|
|
7837
|
-
return blitBuffer(asciiToBytes(string), buf, offset, length)
|
|
7838
|
-
}
|
|
7839
|
-
|
|
7840
|
-
function base64Write (buf, string, offset, length) {
|
|
7841
|
-
return blitBuffer(base64ToBytes(string), buf, offset, length)
|
|
7842
|
-
}
|
|
7843
|
-
|
|
7844
|
-
function ucs2Write (buf, string, offset, length) {
|
|
7845
|
-
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
|
7846
|
-
}
|
|
7847
|
-
|
|
7848
|
-
Buffer.prototype.write = function write (string, offset, length, encoding) {
|
|
7849
|
-
// Buffer#write(string)
|
|
7850
|
-
if (offset === undefined) {
|
|
7851
|
-
encoding = 'utf8';
|
|
7852
|
-
length = this.length;
|
|
7853
|
-
offset = 0;
|
|
7854
|
-
// Buffer#write(string, encoding)
|
|
7855
|
-
} else if (length === undefined && typeof offset === 'string') {
|
|
7856
|
-
encoding = offset;
|
|
7857
|
-
length = this.length;
|
|
7858
|
-
offset = 0;
|
|
7859
|
-
// Buffer#write(string, offset[, length][, encoding])
|
|
7860
|
-
} else if (isFinite(offset)) {
|
|
7861
|
-
offset = offset >>> 0;
|
|
7862
|
-
if (isFinite(length)) {
|
|
7863
|
-
length = length >>> 0;
|
|
7864
|
-
if (encoding === undefined) encoding = 'utf8';
|
|
7865
|
-
} else {
|
|
7866
|
-
encoding = length;
|
|
7867
|
-
length = undefined;
|
|
7868
|
-
}
|
|
7869
|
-
} else {
|
|
7870
|
-
throw new Error(
|
|
7871
|
-
'Buffer.write(string, encoding, offset[, length]) is no longer supported'
|
|
7872
|
-
)
|
|
7873
|
-
}
|
|
7874
|
-
|
|
7875
|
-
var remaining = this.length - offset;
|
|
7876
|
-
if (length === undefined || length > remaining) length = remaining;
|
|
7877
|
-
|
|
7878
|
-
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
|
7879
|
-
throw new RangeError('Attempt to write outside buffer bounds')
|
|
7880
|
-
}
|
|
7881
|
-
|
|
7882
|
-
if (!encoding) encoding = 'utf8';
|
|
7883
|
-
|
|
7884
|
-
var loweredCase = false;
|
|
7885
|
-
for (;;) {
|
|
7886
|
-
switch (encoding) {
|
|
7887
|
-
case 'hex':
|
|
7888
|
-
return hexWrite(this, string, offset, length)
|
|
7889
|
-
|
|
7890
|
-
case 'utf8':
|
|
7891
|
-
case 'utf-8':
|
|
7892
|
-
return utf8Write(this, string, offset, length)
|
|
7893
|
-
|
|
7894
|
-
case 'ascii':
|
|
7895
|
-
case 'latin1':
|
|
7896
|
-
case 'binary':
|
|
7897
|
-
return asciiWrite(this, string, offset, length)
|
|
7898
|
-
|
|
7899
|
-
case 'base64':
|
|
7900
|
-
// Warning: maxLength not taken into account in base64Write
|
|
7901
|
-
return base64Write(this, string, offset, length)
|
|
7902
|
-
|
|
7903
|
-
case 'ucs2':
|
|
7904
|
-
case 'ucs-2':
|
|
7905
|
-
case 'utf16le':
|
|
7906
|
-
case 'utf-16le':
|
|
7907
|
-
return ucs2Write(this, string, offset, length)
|
|
7908
|
-
|
|
7909
|
-
default:
|
|
7910
|
-
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
7911
|
-
encoding = ('' + encoding).toLowerCase();
|
|
7912
|
-
loweredCase = true;
|
|
7913
|
-
}
|
|
7914
|
-
}
|
|
7915
|
-
};
|
|
7916
|
-
|
|
7917
|
-
Buffer.prototype.toJSON = function toJSON () {
|
|
7918
|
-
return {
|
|
7919
|
-
type: 'Buffer',
|
|
7920
|
-
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
7921
|
-
}
|
|
7922
|
-
};
|
|
7923
|
-
|
|
7924
|
-
function base64Slice (buf, start, end) {
|
|
7925
|
-
if (start === 0 && end === buf.length) {
|
|
7926
|
-
return base64.fromByteArray(buf)
|
|
7927
|
-
} else {
|
|
7928
|
-
return base64.fromByteArray(buf.slice(start, end))
|
|
7929
|
-
}
|
|
7930
|
-
}
|
|
7931
|
-
|
|
7932
|
-
function utf8Slice (buf, start, end) {
|
|
7933
|
-
end = Math.min(buf.length, end);
|
|
7934
|
-
var res = [];
|
|
7935
|
-
|
|
7936
|
-
var i = start;
|
|
7937
|
-
while (i < end) {
|
|
7938
|
-
var firstByte = buf[i];
|
|
7939
|
-
var codePoint = null;
|
|
7940
|
-
var bytesPerSequence = (firstByte > 0xEF)
|
|
7941
|
-
? 4
|
|
7942
|
-
: (firstByte > 0xDF)
|
|
7943
|
-
? 3
|
|
7944
|
-
: (firstByte > 0xBF)
|
|
7945
|
-
? 2
|
|
7946
|
-
: 1;
|
|
7947
|
-
|
|
7948
|
-
if (i + bytesPerSequence <= end) {
|
|
7949
|
-
var secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
7950
|
-
|
|
7951
|
-
switch (bytesPerSequence) {
|
|
7952
|
-
case 1:
|
|
7953
|
-
if (firstByte < 0x80) {
|
|
7954
|
-
codePoint = firstByte;
|
|
7955
|
-
}
|
|
7956
|
-
break
|
|
7957
|
-
case 2:
|
|
7958
|
-
secondByte = buf[i + 1];
|
|
7959
|
-
if ((secondByte & 0xC0) === 0x80) {
|
|
7960
|
-
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
|
|
7961
|
-
if (tempCodePoint > 0x7F) {
|
|
7962
|
-
codePoint = tempCodePoint;
|
|
7963
|
-
}
|
|
7964
|
-
}
|
|
7965
|
-
break
|
|
7966
|
-
case 3:
|
|
7967
|
-
secondByte = buf[i + 1];
|
|
7968
|
-
thirdByte = buf[i + 2];
|
|
7969
|
-
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
|
7970
|
-
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
|
|
7971
|
-
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
|
7972
|
-
codePoint = tempCodePoint;
|
|
7973
|
-
}
|
|
7974
|
-
}
|
|
7975
|
-
break
|
|
7976
|
-
case 4:
|
|
7977
|
-
secondByte = buf[i + 1];
|
|
7978
|
-
thirdByte = buf[i + 2];
|
|
7979
|
-
fourthByte = buf[i + 3];
|
|
7980
|
-
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
|
7981
|
-
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
|
|
7982
|
-
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
|
7983
|
-
codePoint = tempCodePoint;
|
|
7984
|
-
}
|
|
7985
|
-
}
|
|
7986
|
-
}
|
|
7987
|
-
}
|
|
7988
|
-
|
|
7989
|
-
if (codePoint === null) {
|
|
7990
|
-
// we did not generate a valid codePoint so insert a
|
|
7991
|
-
// replacement char (U+FFFD) and advance only 1 byte
|
|
7992
|
-
codePoint = 0xFFFD;
|
|
7993
|
-
bytesPerSequence = 1;
|
|
7994
|
-
} else if (codePoint > 0xFFFF) {
|
|
7995
|
-
// encode to utf16 (surrogate pair dance)
|
|
7996
|
-
codePoint -= 0x10000;
|
|
7997
|
-
res.push(codePoint >>> 10 & 0x3FF | 0xD800);
|
|
7998
|
-
codePoint = 0xDC00 | codePoint & 0x3FF;
|
|
7999
|
-
}
|
|
8000
|
-
|
|
8001
|
-
res.push(codePoint);
|
|
8002
|
-
i += bytesPerSequence;
|
|
8003
|
-
}
|
|
8004
|
-
|
|
8005
|
-
return decodeCodePointsArray(res)
|
|
8006
|
-
}
|
|
8007
|
-
|
|
8008
|
-
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
|
|
8009
|
-
// the lowest limit is Chrome, with 0x10000 args.
|
|
8010
|
-
// We go 1 magnitude less, for safety
|
|
8011
|
-
var MAX_ARGUMENTS_LENGTH = 0x1000;
|
|
8012
|
-
|
|
8013
|
-
function decodeCodePointsArray (codePoints) {
|
|
8014
|
-
var len = codePoints.length;
|
|
8015
|
-
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
8016
|
-
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
|
|
8017
|
-
}
|
|
8018
|
-
|
|
8019
|
-
// Decode in chunks to avoid "call stack size exceeded".
|
|
8020
|
-
var res = '';
|
|
8021
|
-
var i = 0;
|
|
8022
|
-
while (i < len) {
|
|
8023
|
-
res += String.fromCharCode.apply(
|
|
8024
|
-
String,
|
|
8025
|
-
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
|
8026
|
-
);
|
|
8027
|
-
}
|
|
8028
|
-
return res
|
|
8029
|
-
}
|
|
8030
|
-
|
|
8031
|
-
function asciiSlice (buf, start, end) {
|
|
8032
|
-
var ret = '';
|
|
8033
|
-
end = Math.min(buf.length, end);
|
|
8034
|
-
|
|
8035
|
-
for (var i = start; i < end; ++i) {
|
|
8036
|
-
ret += String.fromCharCode(buf[i] & 0x7F);
|
|
8037
|
-
}
|
|
8038
|
-
return ret
|
|
8039
|
-
}
|
|
8040
|
-
|
|
8041
|
-
function latin1Slice (buf, start, end) {
|
|
8042
|
-
var ret = '';
|
|
8043
|
-
end = Math.min(buf.length, end);
|
|
8044
|
-
|
|
8045
|
-
for (var i = start; i < end; ++i) {
|
|
8046
|
-
ret += String.fromCharCode(buf[i]);
|
|
8047
|
-
}
|
|
8048
|
-
return ret
|
|
8049
|
-
}
|
|
8050
|
-
|
|
8051
|
-
function hexSlice (buf, start, end) {
|
|
8052
|
-
var len = buf.length;
|
|
8053
|
-
|
|
8054
|
-
if (!start || start < 0) start = 0;
|
|
8055
|
-
if (!end || end < 0 || end > len) end = len;
|
|
8056
|
-
|
|
8057
|
-
var out = '';
|
|
8058
|
-
for (var i = start; i < end; ++i) {
|
|
8059
|
-
out += hexSliceLookupTable[buf[i]];
|
|
8060
|
-
}
|
|
8061
|
-
return out
|
|
8062
|
-
}
|
|
8063
|
-
|
|
8064
|
-
function utf16leSlice (buf, start, end) {
|
|
8065
|
-
var bytes = buf.slice(start, end);
|
|
8066
|
-
var res = '';
|
|
8067
|
-
// If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
|
|
8068
|
-
for (var i = 0; i < bytes.length - 1; i += 2) {
|
|
8069
|
-
res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256));
|
|
8070
|
-
}
|
|
8071
|
-
return res
|
|
8072
|
-
}
|
|
8073
|
-
|
|
8074
|
-
Buffer.prototype.slice = function slice (start, end) {
|
|
8075
|
-
var len = this.length;
|
|
8076
|
-
start = ~~start;
|
|
8077
|
-
end = end === undefined ? len : ~~end;
|
|
8078
|
-
|
|
8079
|
-
if (start < 0) {
|
|
8080
|
-
start += len;
|
|
8081
|
-
if (start < 0) start = 0;
|
|
8082
|
-
} else if (start > len) {
|
|
8083
|
-
start = len;
|
|
8084
|
-
}
|
|
8085
|
-
|
|
8086
|
-
if (end < 0) {
|
|
8087
|
-
end += len;
|
|
8088
|
-
if (end < 0) end = 0;
|
|
8089
|
-
} else if (end > len) {
|
|
8090
|
-
end = len;
|
|
8091
|
-
}
|
|
8092
|
-
|
|
8093
|
-
if (end < start) end = start;
|
|
8094
|
-
|
|
8095
|
-
var newBuf = this.subarray(start, end);
|
|
8096
|
-
// Return an augmented `Uint8Array` instance
|
|
8097
|
-
Object.setPrototypeOf(newBuf, Buffer.prototype);
|
|
8098
|
-
|
|
8099
|
-
return newBuf
|
|
8100
|
-
};
|
|
8101
|
-
|
|
8102
|
-
/*
|
|
8103
|
-
* Need to make sure that buffer isn't trying to write out of bounds.
|
|
8104
|
-
*/
|
|
8105
|
-
function checkOffset (offset, ext, length) {
|
|
8106
|
-
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
|
|
8107
|
-
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
|
8108
|
-
}
|
|
8109
|
-
|
|
8110
|
-
Buffer.prototype.readUintLE =
|
|
8111
|
-
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
|
8112
|
-
offset = offset >>> 0;
|
|
8113
|
-
byteLength = byteLength >>> 0;
|
|
8114
|
-
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
8115
|
-
|
|
8116
|
-
var val = this[offset];
|
|
8117
|
-
var mul = 1;
|
|
8118
|
-
var i = 0;
|
|
8119
|
-
while (++i < byteLength && (mul *= 0x100)) {
|
|
8120
|
-
val += this[offset + i] * mul;
|
|
8121
|
-
}
|
|
8122
|
-
|
|
8123
|
-
return val
|
|
8124
|
-
};
|
|
8125
|
-
|
|
8126
|
-
Buffer.prototype.readUintBE =
|
|
8127
|
-
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
|
8128
|
-
offset = offset >>> 0;
|
|
8129
|
-
byteLength = byteLength >>> 0;
|
|
8130
|
-
if (!noAssert) {
|
|
8131
|
-
checkOffset(offset, byteLength, this.length);
|
|
8132
|
-
}
|
|
8133
|
-
|
|
8134
|
-
var val = this[offset + --byteLength];
|
|
8135
|
-
var mul = 1;
|
|
8136
|
-
while (byteLength > 0 && (mul *= 0x100)) {
|
|
8137
|
-
val += this[offset + --byteLength] * mul;
|
|
8138
|
-
}
|
|
8139
|
-
|
|
8140
|
-
return val
|
|
8141
|
-
};
|
|
8142
|
-
|
|
8143
|
-
Buffer.prototype.readUint8 =
|
|
8144
|
-
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
|
8145
|
-
offset = offset >>> 0;
|
|
8146
|
-
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
8147
|
-
return this[offset]
|
|
8148
|
-
};
|
|
8149
|
-
|
|
8150
|
-
Buffer.prototype.readUint16LE =
|
|
8151
|
-
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
|
8152
|
-
offset = offset >>> 0;
|
|
8153
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
8154
|
-
return this[offset] | (this[offset + 1] << 8)
|
|
8155
|
-
};
|
|
8156
|
-
|
|
8157
|
-
Buffer.prototype.readUint16BE =
|
|
8158
|
-
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
|
8159
|
-
offset = offset >>> 0;
|
|
8160
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
8161
|
-
return (this[offset] << 8) | this[offset + 1]
|
|
8162
|
-
};
|
|
8163
|
-
|
|
8164
|
-
Buffer.prototype.readUint32LE =
|
|
8165
|
-
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
|
8166
|
-
offset = offset >>> 0;
|
|
8167
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
8168
|
-
|
|
8169
|
-
return ((this[offset]) |
|
|
8170
|
-
(this[offset + 1] << 8) |
|
|
8171
|
-
(this[offset + 2] << 16)) +
|
|
8172
|
-
(this[offset + 3] * 0x1000000)
|
|
8173
|
-
};
|
|
8174
|
-
|
|
8175
|
-
Buffer.prototype.readUint32BE =
|
|
8176
|
-
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
|
8177
|
-
offset = offset >>> 0;
|
|
8178
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
8179
|
-
|
|
8180
|
-
return (this[offset] * 0x1000000) +
|
|
8181
|
-
((this[offset + 1] << 16) |
|
|
8182
|
-
(this[offset + 2] << 8) |
|
|
8183
|
-
this[offset + 3])
|
|
8184
|
-
};
|
|
8185
|
-
|
|
8186
|
-
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
|
8187
|
-
offset = offset >>> 0;
|
|
8188
|
-
byteLength = byteLength >>> 0;
|
|
8189
|
-
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
8190
|
-
|
|
8191
|
-
var val = this[offset];
|
|
8192
|
-
var mul = 1;
|
|
8193
|
-
var i = 0;
|
|
8194
|
-
while (++i < byteLength && (mul *= 0x100)) {
|
|
8195
|
-
val += this[offset + i] * mul;
|
|
8196
|
-
}
|
|
8197
|
-
mul *= 0x80;
|
|
8198
|
-
|
|
8199
|
-
if (val >= mul) val -= Math.pow(2, 8 * byteLength);
|
|
8200
|
-
|
|
8201
|
-
return val
|
|
8202
|
-
};
|
|
8203
|
-
|
|
8204
|
-
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
|
8205
|
-
offset = offset >>> 0;
|
|
8206
|
-
byteLength = byteLength >>> 0;
|
|
8207
|
-
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
8208
|
-
|
|
8209
|
-
var i = byteLength;
|
|
8210
|
-
var mul = 1;
|
|
8211
|
-
var val = this[offset + --i];
|
|
8212
|
-
while (i > 0 && (mul *= 0x100)) {
|
|
8213
|
-
val += this[offset + --i] * mul;
|
|
8214
|
-
}
|
|
8215
|
-
mul *= 0x80;
|
|
8216
|
-
|
|
8217
|
-
if (val >= mul) val -= Math.pow(2, 8 * byteLength);
|
|
8218
|
-
|
|
8219
|
-
return val
|
|
8220
|
-
};
|
|
8221
|
-
|
|
8222
|
-
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
|
8223
|
-
offset = offset >>> 0;
|
|
8224
|
-
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
8225
|
-
if (!(this[offset] & 0x80)) return (this[offset])
|
|
8226
|
-
return ((0xff - this[offset] + 1) * -1)
|
|
8227
|
-
};
|
|
8228
|
-
|
|
8229
|
-
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
|
8230
|
-
offset = offset >>> 0;
|
|
8231
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
8232
|
-
var val = this[offset] | (this[offset + 1] << 8);
|
|
8233
|
-
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
8234
|
-
};
|
|
8235
|
-
|
|
8236
|
-
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
|
8237
|
-
offset = offset >>> 0;
|
|
8238
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
8239
|
-
var val = this[offset + 1] | (this[offset] << 8);
|
|
8240
|
-
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
8241
|
-
};
|
|
8242
|
-
|
|
8243
|
-
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
|
8244
|
-
offset = offset >>> 0;
|
|
8245
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
8246
|
-
|
|
8247
|
-
return (this[offset]) |
|
|
8248
|
-
(this[offset + 1] << 8) |
|
|
8249
|
-
(this[offset + 2] << 16) |
|
|
8250
|
-
(this[offset + 3] << 24)
|
|
8251
|
-
};
|
|
8252
|
-
|
|
8253
|
-
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
|
8254
|
-
offset = offset >>> 0;
|
|
8255
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
8256
|
-
|
|
8257
|
-
return (this[offset] << 24) |
|
|
8258
|
-
(this[offset + 1] << 16) |
|
|
8259
|
-
(this[offset + 2] << 8) |
|
|
8260
|
-
(this[offset + 3])
|
|
8261
|
-
};
|
|
8262
|
-
|
|
8263
|
-
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
|
8264
|
-
offset = offset >>> 0;
|
|
8265
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
8266
|
-
return ieee754.read(this, offset, true, 23, 4)
|
|
8267
|
-
};
|
|
8268
|
-
|
|
8269
|
-
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
|
8270
|
-
offset = offset >>> 0;
|
|
8271
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
8272
|
-
return ieee754.read(this, offset, false, 23, 4)
|
|
8273
|
-
};
|
|
8274
|
-
|
|
8275
|
-
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
|
8276
|
-
offset = offset >>> 0;
|
|
8277
|
-
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
8278
|
-
return ieee754.read(this, offset, true, 52, 8)
|
|
8279
|
-
};
|
|
8280
|
-
|
|
8281
|
-
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
|
8282
|
-
offset = offset >>> 0;
|
|
8283
|
-
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
8284
|
-
return ieee754.read(this, offset, false, 52, 8)
|
|
8285
|
-
};
|
|
8286
|
-
|
|
8287
|
-
function checkInt (buf, value, offset, ext, max, min) {
|
|
8288
|
-
if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
|
|
8289
|
-
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
|
|
8290
|
-
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
8291
|
-
}
|
|
8292
|
-
|
|
8293
|
-
Buffer.prototype.writeUintLE =
|
|
8294
|
-
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
|
8295
|
-
value = +value;
|
|
8296
|
-
offset = offset >>> 0;
|
|
8297
|
-
byteLength = byteLength >>> 0;
|
|
8298
|
-
if (!noAssert) {
|
|
8299
|
-
var maxBytes = Math.pow(2, 8 * byteLength) - 1;
|
|
8300
|
-
checkInt(this, value, offset, byteLength, maxBytes, 0);
|
|
8301
|
-
}
|
|
8302
|
-
|
|
8303
|
-
var mul = 1;
|
|
8304
|
-
var i = 0;
|
|
8305
|
-
this[offset] = value & 0xFF;
|
|
8306
|
-
while (++i < byteLength && (mul *= 0x100)) {
|
|
8307
|
-
this[offset + i] = (value / mul) & 0xFF;
|
|
8308
|
-
}
|
|
8309
|
-
|
|
8310
|
-
return offset + byteLength
|
|
8311
|
-
};
|
|
8312
|
-
|
|
8313
|
-
Buffer.prototype.writeUintBE =
|
|
8314
|
-
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
|
8315
|
-
value = +value;
|
|
8316
|
-
offset = offset >>> 0;
|
|
8317
|
-
byteLength = byteLength >>> 0;
|
|
8318
|
-
if (!noAssert) {
|
|
8319
|
-
var maxBytes = Math.pow(2, 8 * byteLength) - 1;
|
|
8320
|
-
checkInt(this, value, offset, byteLength, maxBytes, 0);
|
|
8321
|
-
}
|
|
8322
|
-
|
|
8323
|
-
var i = byteLength - 1;
|
|
8324
|
-
var mul = 1;
|
|
8325
|
-
this[offset + i] = value & 0xFF;
|
|
8326
|
-
while (--i >= 0 && (mul *= 0x100)) {
|
|
8327
|
-
this[offset + i] = (value / mul) & 0xFF;
|
|
8328
|
-
}
|
|
8329
|
-
|
|
8330
|
-
return offset + byteLength
|
|
8331
|
-
};
|
|
8332
|
-
|
|
8333
|
-
Buffer.prototype.writeUint8 =
|
|
8334
|
-
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
|
8335
|
-
value = +value;
|
|
8336
|
-
offset = offset >>> 0;
|
|
8337
|
-
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
|
|
8338
|
-
this[offset] = (value & 0xff);
|
|
8339
|
-
return offset + 1
|
|
8340
|
-
};
|
|
8341
|
-
|
|
8342
|
-
Buffer.prototype.writeUint16LE =
|
|
8343
|
-
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
|
8344
|
-
value = +value;
|
|
8345
|
-
offset = offset >>> 0;
|
|
8346
|
-
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
|
|
8347
|
-
this[offset] = (value & 0xff);
|
|
8348
|
-
this[offset + 1] = (value >>> 8);
|
|
8349
|
-
return offset + 2
|
|
8350
|
-
};
|
|
8351
|
-
|
|
8352
|
-
Buffer.prototype.writeUint16BE =
|
|
8353
|
-
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
|
8354
|
-
value = +value;
|
|
8355
|
-
offset = offset >>> 0;
|
|
8356
|
-
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
|
|
8357
|
-
this[offset] = (value >>> 8);
|
|
8358
|
-
this[offset + 1] = (value & 0xff);
|
|
8359
|
-
return offset + 2
|
|
8360
|
-
};
|
|
8361
|
-
|
|
8362
|
-
Buffer.prototype.writeUint32LE =
|
|
8363
|
-
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
|
8364
|
-
value = +value;
|
|
8365
|
-
offset = offset >>> 0;
|
|
8366
|
-
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
|
|
8367
|
-
this[offset + 3] = (value >>> 24);
|
|
8368
|
-
this[offset + 2] = (value >>> 16);
|
|
8369
|
-
this[offset + 1] = (value >>> 8);
|
|
8370
|
-
this[offset] = (value & 0xff);
|
|
8371
|
-
return offset + 4
|
|
8372
|
-
};
|
|
8373
|
-
|
|
8374
|
-
Buffer.prototype.writeUint32BE =
|
|
8375
|
-
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
|
8376
|
-
value = +value;
|
|
8377
|
-
offset = offset >>> 0;
|
|
8378
|
-
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
|
|
8379
|
-
this[offset] = (value >>> 24);
|
|
8380
|
-
this[offset + 1] = (value >>> 16);
|
|
8381
|
-
this[offset + 2] = (value >>> 8);
|
|
8382
|
-
this[offset + 3] = (value & 0xff);
|
|
8383
|
-
return offset + 4
|
|
8384
|
-
};
|
|
8385
|
-
|
|
8386
|
-
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
|
8387
|
-
value = +value;
|
|
8388
|
-
offset = offset >>> 0;
|
|
8389
|
-
if (!noAssert) {
|
|
8390
|
-
var limit = Math.pow(2, (8 * byteLength) - 1);
|
|
8391
|
-
|
|
8392
|
-
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
8393
|
-
}
|
|
8394
|
-
|
|
8395
|
-
var i = 0;
|
|
8396
|
-
var mul = 1;
|
|
8397
|
-
var sub = 0;
|
|
8398
|
-
this[offset] = value & 0xFF;
|
|
8399
|
-
while (++i < byteLength && (mul *= 0x100)) {
|
|
8400
|
-
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
8401
|
-
sub = 1;
|
|
8402
|
-
}
|
|
8403
|
-
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
|
|
8404
|
-
}
|
|
8405
|
-
|
|
8406
|
-
return offset + byteLength
|
|
8407
|
-
};
|
|
8408
|
-
|
|
8409
|
-
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
|
8410
|
-
value = +value;
|
|
8411
|
-
offset = offset >>> 0;
|
|
8412
|
-
if (!noAssert) {
|
|
8413
|
-
var limit = Math.pow(2, (8 * byteLength) - 1);
|
|
8414
|
-
|
|
8415
|
-
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
8416
|
-
}
|
|
8417
|
-
|
|
8418
|
-
var i = byteLength - 1;
|
|
8419
|
-
var mul = 1;
|
|
8420
|
-
var sub = 0;
|
|
8421
|
-
this[offset + i] = value & 0xFF;
|
|
8422
|
-
while (--i >= 0 && (mul *= 0x100)) {
|
|
8423
|
-
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
8424
|
-
sub = 1;
|
|
8425
|
-
}
|
|
8426
|
-
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
|
|
8427
|
-
}
|
|
8428
|
-
|
|
8429
|
-
return offset + byteLength
|
|
8430
|
-
};
|
|
8431
|
-
|
|
8432
|
-
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
|
8433
|
-
value = +value;
|
|
8434
|
-
offset = offset >>> 0;
|
|
8435
|
-
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -128);
|
|
8436
|
-
if (value < 0) value = 0xff + value + 1;
|
|
8437
|
-
this[offset] = (value & 0xff);
|
|
8438
|
-
return offset + 1
|
|
8439
|
-
};
|
|
8440
|
-
|
|
8441
|
-
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
|
8442
|
-
value = +value;
|
|
8443
|
-
offset = offset >>> 0;
|
|
8444
|
-
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
|
|
8445
|
-
this[offset] = (value & 0xff);
|
|
8446
|
-
this[offset + 1] = (value >>> 8);
|
|
8447
|
-
return offset + 2
|
|
8448
|
-
};
|
|
8449
|
-
|
|
8450
|
-
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
|
8451
|
-
value = +value;
|
|
8452
|
-
offset = offset >>> 0;
|
|
8453
|
-
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
|
|
8454
|
-
this[offset] = (value >>> 8);
|
|
8455
|
-
this[offset + 1] = (value & 0xff);
|
|
8456
|
-
return offset + 2
|
|
8457
|
-
};
|
|
8458
|
-
|
|
8459
|
-
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
|
8460
|
-
value = +value;
|
|
8461
|
-
offset = offset >>> 0;
|
|
8462
|
-
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
|
|
8463
|
-
this[offset] = (value & 0xff);
|
|
8464
|
-
this[offset + 1] = (value >>> 8);
|
|
8465
|
-
this[offset + 2] = (value >>> 16);
|
|
8466
|
-
this[offset + 3] = (value >>> 24);
|
|
8467
|
-
return offset + 4
|
|
8468
|
-
};
|
|
8469
|
-
|
|
8470
|
-
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
|
8471
|
-
value = +value;
|
|
8472
|
-
offset = offset >>> 0;
|
|
8473
|
-
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
|
|
8474
|
-
if (value < 0) value = 0xffffffff + value + 1;
|
|
8475
|
-
this[offset] = (value >>> 24);
|
|
8476
|
-
this[offset + 1] = (value >>> 16);
|
|
8477
|
-
this[offset + 2] = (value >>> 8);
|
|
8478
|
-
this[offset + 3] = (value & 0xff);
|
|
8479
|
-
return offset + 4
|
|
8480
|
-
};
|
|
8481
|
-
|
|
8482
|
-
function checkIEEE754 (buf, value, offset, ext, max, min) {
|
|
8483
|
-
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
8484
|
-
if (offset < 0) throw new RangeError('Index out of range')
|
|
8485
|
-
}
|
|
8486
|
-
|
|
8487
|
-
function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
|
8488
|
-
value = +value;
|
|
8489
|
-
offset = offset >>> 0;
|
|
8490
|
-
if (!noAssert) {
|
|
8491
|
-
checkIEEE754(buf, value, offset, 4);
|
|
8492
|
-
}
|
|
8493
|
-
ieee754.write(buf, value, offset, littleEndian, 23, 4);
|
|
8494
|
-
return offset + 4
|
|
8495
|
-
}
|
|
8496
|
-
|
|
8497
|
-
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
|
8498
|
-
return writeFloat(this, value, offset, true, noAssert)
|
|
8499
|
-
};
|
|
8500
|
-
|
|
8501
|
-
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
|
8502
|
-
return writeFloat(this, value, offset, false, noAssert)
|
|
8503
|
-
};
|
|
8504
|
-
|
|
8505
|
-
function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
|
8506
|
-
value = +value;
|
|
8507
|
-
offset = offset >>> 0;
|
|
8508
|
-
if (!noAssert) {
|
|
8509
|
-
checkIEEE754(buf, value, offset, 8);
|
|
8510
|
-
}
|
|
8511
|
-
ieee754.write(buf, value, offset, littleEndian, 52, 8);
|
|
8512
|
-
return offset + 8
|
|
8513
|
-
}
|
|
8514
|
-
|
|
8515
|
-
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
|
8516
|
-
return writeDouble(this, value, offset, true, noAssert)
|
|
8517
|
-
};
|
|
8518
|
-
|
|
8519
|
-
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
|
8520
|
-
return writeDouble(this, value, offset, false, noAssert)
|
|
8521
|
-
};
|
|
8522
|
-
|
|
8523
|
-
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
|
8524
|
-
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
|
8525
|
-
if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
|
|
8526
|
-
if (!start) start = 0;
|
|
8527
|
-
if (!end && end !== 0) end = this.length;
|
|
8528
|
-
if (targetStart >= target.length) targetStart = target.length;
|
|
8529
|
-
if (!targetStart) targetStart = 0;
|
|
8530
|
-
if (end > 0 && end < start) end = start;
|
|
8531
|
-
|
|
8532
|
-
// Copy 0 bytes; we're done
|
|
8533
|
-
if (end === start) return 0
|
|
8534
|
-
if (target.length === 0 || this.length === 0) return 0
|
|
8535
|
-
|
|
8536
|
-
// Fatal error conditions
|
|
8537
|
-
if (targetStart < 0) {
|
|
8538
|
-
throw new RangeError('targetStart out of bounds')
|
|
8539
|
-
}
|
|
8540
|
-
if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
|
|
8541
|
-
if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
|
6729
|
+
} else if (typeof input === 'bigint') {
|
|
6730
|
+
received = String(input);
|
|
6731
|
+
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
|
|
6732
|
+
received = addNumericalSeparator(received);
|
|
6733
|
+
}
|
|
6734
|
+
received += 'n';
|
|
6735
|
+
}
|
|
6736
|
+
msg += ` It must be ${range}. Received ${received}`;
|
|
6737
|
+
return msg
|
|
6738
|
+
}, RangeError);
|
|
8542
6739
|
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
6740
|
+
function addNumericalSeparator (val) {
|
|
6741
|
+
let res = '';
|
|
6742
|
+
let i = val.length;
|
|
6743
|
+
const start = val[0] === '-' ? 1 : 0;
|
|
6744
|
+
for (; i >= start + 4; i -= 3) {
|
|
6745
|
+
res = `_${val.slice(i - 3, i)}${res}`;
|
|
8547
6746
|
}
|
|
6747
|
+
return `${val.slice(0, i)}${res}`
|
|
6748
|
+
}
|
|
8548
6749
|
|
|
8549
|
-
|
|
6750
|
+
// CHECK FUNCTIONS
|
|
6751
|
+
// ===============
|
|
8550
6752
|
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
Uint8Array.prototype.set.call(
|
|
8556
|
-
target,
|
|
8557
|
-
this.subarray(start, end),
|
|
8558
|
-
targetStart
|
|
8559
|
-
);
|
|
6753
|
+
function checkBounds (buf, offset, byteLength) {
|
|
6754
|
+
validateNumber(offset, 'offset');
|
|
6755
|
+
if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
|
|
6756
|
+
boundsError(offset, buf.length - (byteLength + 1));
|
|
8560
6757
|
}
|
|
6758
|
+
}
|
|
8561
6759
|
|
|
8562
|
-
|
|
8563
|
-
|
|
8564
|
-
|
|
8565
|
-
|
|
8566
|
-
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
|
|
8572
|
-
if (typeof start === 'string') {
|
|
8573
|
-
encoding = start;
|
|
8574
|
-
start = 0;
|
|
8575
|
-
end = this.length;
|
|
8576
|
-
} else if (typeof end === 'string') {
|
|
8577
|
-
encoding = end;
|
|
8578
|
-
end = this.length;
|
|
8579
|
-
}
|
|
8580
|
-
if (encoding !== undefined && typeof encoding !== 'string') {
|
|
8581
|
-
throw new TypeError('encoding must be a string')
|
|
8582
|
-
}
|
|
8583
|
-
if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
|
|
8584
|
-
throw new TypeError('Unknown encoding: ' + encoding)
|
|
8585
|
-
}
|
|
8586
|
-
if (val.length === 1) {
|
|
8587
|
-
var code = val.charCodeAt(0);
|
|
8588
|
-
if ((encoding === 'utf8' && code < 128) ||
|
|
8589
|
-
encoding === 'latin1') {
|
|
8590
|
-
// Fast path: If `val` fits into a single byte, use that numeric value.
|
|
8591
|
-
val = code;
|
|
6760
|
+
function checkIntBI (value, min, max, buf, offset, byteLength) {
|
|
6761
|
+
if (value > max || value < min) {
|
|
6762
|
+
const n = typeof min === 'bigint' ? 'n' : '';
|
|
6763
|
+
let range;
|
|
6764
|
+
{
|
|
6765
|
+
if (min === 0 || min === BigInt(0)) {
|
|
6766
|
+
range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
|
|
6767
|
+
} else {
|
|
6768
|
+
range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
|
|
6769
|
+
`${(byteLength + 1) * 8 - 1}${n}`;
|
|
8592
6770
|
}
|
|
8593
6771
|
}
|
|
8594
|
-
|
|
8595
|
-
val = val & 255;
|
|
8596
|
-
} else if (typeof val === 'boolean') {
|
|
8597
|
-
val = Number(val);
|
|
6772
|
+
throw new errors.ERR_OUT_OF_RANGE('value', range, value)
|
|
8598
6773
|
}
|
|
6774
|
+
checkBounds(buf, offset, byteLength);
|
|
6775
|
+
}
|
|
8599
6776
|
|
|
8600
|
-
|
|
8601
|
-
if (
|
|
8602
|
-
throw new
|
|
6777
|
+
function validateNumber (value, name) {
|
|
6778
|
+
if (typeof value !== 'number') {
|
|
6779
|
+
throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
|
|
8603
6780
|
}
|
|
6781
|
+
}
|
|
8604
6782
|
|
|
8605
|
-
|
|
8606
|
-
|
|
6783
|
+
function boundsError (value, length, type) {
|
|
6784
|
+
if (Math.floor(value) !== value) {
|
|
6785
|
+
validateNumber(value, type);
|
|
6786
|
+
throw new errors.ERR_OUT_OF_RANGE('offset', 'an integer', value)
|
|
8607
6787
|
}
|
|
8608
6788
|
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
if (!val) val = 0;
|
|
8613
|
-
|
|
8614
|
-
var i;
|
|
8615
|
-
if (typeof val === 'number') {
|
|
8616
|
-
for (i = start; i < end; ++i) {
|
|
8617
|
-
this[i] = val;
|
|
8618
|
-
}
|
|
8619
|
-
} else {
|
|
8620
|
-
var bytes = Buffer.isBuffer(val)
|
|
8621
|
-
? val
|
|
8622
|
-
: Buffer.from(val, encoding);
|
|
8623
|
-
var len = bytes.length;
|
|
8624
|
-
if (len === 0) {
|
|
8625
|
-
throw new TypeError('The value "' + val +
|
|
8626
|
-
'" is invalid for argument "value"')
|
|
8627
|
-
}
|
|
8628
|
-
for (i = 0; i < end - start; ++i) {
|
|
8629
|
-
this[i + start] = bytes[i % len];
|
|
8630
|
-
}
|
|
6789
|
+
if (length < 0) {
|
|
6790
|
+
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
|
|
8631
6791
|
}
|
|
8632
6792
|
|
|
8633
|
-
|
|
8634
|
-
|
|
6793
|
+
throw new errors.ERR_OUT_OF_RANGE('offset',
|
|
6794
|
+
`>= ${0} and <= ${length}`,
|
|
6795
|
+
value)
|
|
6796
|
+
}
|
|
8635
6797
|
|
|
8636
6798
|
// HELPER FUNCTIONS
|
|
8637
6799
|
// ================
|
|
8638
6800
|
|
|
8639
|
-
|
|
6801
|
+
const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
|
|
8640
6802
|
|
|
8641
6803
|
function base64clean (str) {
|
|
8642
6804
|
// Node takes equal signs as end of the Base64 encoding
|
|
@@ -8654,12 +6816,12 @@ function requireBuffer () {
|
|
|
8654
6816
|
|
|
8655
6817
|
function utf8ToBytes (string, units) {
|
|
8656
6818
|
units = units || Infinity;
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
|
|
6819
|
+
let codePoint;
|
|
6820
|
+
const length = string.length;
|
|
6821
|
+
let leadSurrogate = null;
|
|
6822
|
+
const bytes = [];
|
|
8661
6823
|
|
|
8662
|
-
for (
|
|
6824
|
+
for (let i = 0; i < length; ++i) {
|
|
8663
6825
|
codePoint = string.charCodeAt(i);
|
|
8664
6826
|
|
|
8665
6827
|
// is surrogate component
|
|
@@ -8733,8 +6895,8 @@ function requireBuffer () {
|
|
|
8733
6895
|
}
|
|
8734
6896
|
|
|
8735
6897
|
function asciiToBytes (str) {
|
|
8736
|
-
|
|
8737
|
-
for (
|
|
6898
|
+
const byteArray = [];
|
|
6899
|
+
for (let i = 0; i < str.length; ++i) {
|
|
8738
6900
|
// Node's code seems to be doing this and not & 0x7F..
|
|
8739
6901
|
byteArray.push(str.charCodeAt(i) & 0xFF);
|
|
8740
6902
|
}
|
|
@@ -8742,9 +6904,9 @@ function requireBuffer () {
|
|
|
8742
6904
|
}
|
|
8743
6905
|
|
|
8744
6906
|
function utf16leToBytes (str, units) {
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
for (
|
|
6907
|
+
let c, hi, lo;
|
|
6908
|
+
const byteArray = [];
|
|
6909
|
+
for (let i = 0; i < str.length; ++i) {
|
|
8748
6910
|
if ((units -= 2) < 0) break
|
|
8749
6911
|
|
|
8750
6912
|
c = str.charCodeAt(i);
|
|
@@ -8762,7 +6924,8 @@ function requireBuffer () {
|
|
|
8762
6924
|
}
|
|
8763
6925
|
|
|
8764
6926
|
function blitBuffer (src, dst, offset, length) {
|
|
8765
|
-
|
|
6927
|
+
let i;
|
|
6928
|
+
for (i = 0; i < length; ++i) {
|
|
8766
6929
|
if ((i + offset >= dst.length) || (i >= src.length)) break
|
|
8767
6930
|
dst[i + offset] = src[i];
|
|
8768
6931
|
}
|
|
@@ -8784,23 +6947,34 @@ function requireBuffer () {
|
|
|
8784
6947
|
|
|
8785
6948
|
// Create lookup table for `toString('hex')`
|
|
8786
6949
|
// See: https://github.com/feross/buffer/issues/219
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
for (
|
|
8791
|
-
|
|
8792
|
-
for (
|
|
6950
|
+
const hexSliceLookupTable = (function () {
|
|
6951
|
+
const alphabet = '0123456789abcdef';
|
|
6952
|
+
const table = new Array(256);
|
|
6953
|
+
for (let i = 0; i < 16; ++i) {
|
|
6954
|
+
const i16 = i * 16;
|
|
6955
|
+
for (let j = 0; j < 16; ++j) {
|
|
8793
6956
|
table[i16 + j] = alphabet[i] + alphabet[j];
|
|
8794
6957
|
}
|
|
8795
6958
|
}
|
|
8796
6959
|
return table
|
|
8797
|
-
})();
|
|
6960
|
+
})();
|
|
6961
|
+
|
|
6962
|
+
// Return not function with Error if BigInt not supported
|
|
6963
|
+
function defineBigIntMethod (fn) {
|
|
6964
|
+
return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
|
|
6965
|
+
}
|
|
6966
|
+
|
|
6967
|
+
function BufferBigIntNotDefined () {
|
|
6968
|
+
throw new Error('BigInt not supported')
|
|
6969
|
+
}
|
|
8798
6970
|
} (buffer));
|
|
8799
6971
|
return buffer;
|
|
8800
6972
|
}
|
|
8801
6973
|
|
|
8802
6974
|
var bufferExports = requireBuffer();
|
|
8803
6975
|
|
|
6976
|
+
var dist = {};
|
|
6977
|
+
|
|
8804
6978
|
var Codecs = {};
|
|
8805
6979
|
|
|
8806
6980
|
var Frames = {};
|
|
@@ -13583,7 +11757,7 @@ function requireDist () {
|
|
|
13583
11757
|
|
|
13584
11758
|
var distExports = requireDist();
|
|
13585
11759
|
|
|
13586
|
-
var version = "1.
|
|
11760
|
+
var version = "1.46.0";
|
|
13587
11761
|
var PACKAGE = {
|
|
13588
11762
|
version: version};
|
|
13589
11763
|
|
|
@@ -13654,6 +11828,16 @@ class DataStream extends BaseObserver {
|
|
|
13654
11828
|
* @returns a Data payload or Null if the stream closed.
|
|
13655
11829
|
*/
|
|
13656
11830
|
async read() {
|
|
11831
|
+
if (this.closed) {
|
|
11832
|
+
return null;
|
|
11833
|
+
}
|
|
11834
|
+
// Wait for any pending processing to complete first.
|
|
11835
|
+
// This ensures we register our listener before calling processQueue(),
|
|
11836
|
+
// avoiding a race where processQueue() sees no reader and returns early.
|
|
11837
|
+
if (this.processingPromise) {
|
|
11838
|
+
await this.processingPromise;
|
|
11839
|
+
}
|
|
11840
|
+
// Re-check after await - stream may have closed while we were waiting
|
|
13657
11841
|
if (this.closed) {
|
|
13658
11842
|
return null;
|
|
13659
11843
|
}
|
|
@@ -13693,7 +11877,7 @@ class DataStream extends BaseObserver {
|
|
|
13693
11877
|
}
|
|
13694
11878
|
const promise = (this.processingPromise = this._processQueue());
|
|
13695
11879
|
promise.finally(() => {
|
|
13696
|
-
|
|
11880
|
+
this.processingPromise = null;
|
|
13697
11881
|
});
|
|
13698
11882
|
return promise;
|
|
13699
11883
|
}
|
|
@@ -13725,7 +11909,6 @@ class DataStream extends BaseObserver {
|
|
|
13725
11909
|
this.notifyDataAdded = null;
|
|
13726
11910
|
}
|
|
13727
11911
|
if (this.dataQueue.length > 0) {
|
|
13728
|
-
// Next tick
|
|
13729
11912
|
setTimeout(() => this.processQueue());
|
|
13730
11913
|
}
|
|
13731
11914
|
}
|
|
@@ -14105,7 +12288,7 @@ class AbstractRemote {
|
|
|
14105
12288
|
else {
|
|
14106
12289
|
contents = JSON.stringify(js);
|
|
14107
12290
|
}
|
|
14108
|
-
return bufferExports
|
|
12291
|
+
return bufferExports.Buffer.from(contents);
|
|
14109
12292
|
}
|
|
14110
12293
|
const syncQueueRequestSize = fetchStrategy == FetchStrategy.Buffered ? 10 : 1;
|
|
14111
12294
|
const request = await this.buildRequest(path);
|
|
@@ -14345,7 +12528,11 @@ class AbstractRemote {
|
|
|
14345
12528
|
};
|
|
14346
12529
|
const stream = new DataStream({
|
|
14347
12530
|
logger: this.logger,
|
|
14348
|
-
mapLine: mapLine
|
|
12531
|
+
mapLine: mapLine,
|
|
12532
|
+
pressure: {
|
|
12533
|
+
highWaterMark: 20,
|
|
12534
|
+
lowWaterMark: 10
|
|
12535
|
+
}
|
|
14349
12536
|
});
|
|
14350
12537
|
abortSignal?.addEventListener('abort', () => {
|
|
14351
12538
|
closeReader();
|
|
@@ -14353,42 +12540,47 @@ class AbstractRemote {
|
|
|
14353
12540
|
});
|
|
14354
12541
|
const decoder = this.createTextDecoder();
|
|
14355
12542
|
let buffer = '';
|
|
14356
|
-
const
|
|
14357
|
-
|
|
14358
|
-
|
|
12543
|
+
const consumeStream = async () => {
|
|
12544
|
+
while (!stream.closed && !abortSignal?.aborted && !readerReleased) {
|
|
12545
|
+
const { done, value } = await reader.read();
|
|
12546
|
+
if (done) {
|
|
12547
|
+
const remaining = buffer.trim();
|
|
12548
|
+
if (remaining.length != 0) {
|
|
12549
|
+
stream.enqueueData(remaining);
|
|
12550
|
+
}
|
|
12551
|
+
stream.close();
|
|
12552
|
+
await closeReader();
|
|
14359
12553
|
return;
|
|
14360
12554
|
}
|
|
14361
|
-
|
|
14362
|
-
|
|
14363
|
-
|
|
14364
|
-
|
|
14365
|
-
|
|
14366
|
-
|
|
14367
|
-
|
|
14368
|
-
stream.enqueueData(remaining);
|
|
14369
|
-
}
|
|
14370
|
-
stream.close();
|
|
14371
|
-
await closeReader();
|
|
14372
|
-
return;
|
|
14373
|
-
}
|
|
14374
|
-
const data = decoder.decode(value, { stream: true });
|
|
14375
|
-
buffer += data;
|
|
14376
|
-
const lines = buffer.split('\n');
|
|
14377
|
-
for (var i = 0; i < lines.length - 1; i++) {
|
|
14378
|
-
var l = lines[i].trim();
|
|
14379
|
-
if (l.length > 0) {
|
|
14380
|
-
stream.enqueueData(l);
|
|
14381
|
-
didCompleteLine = true;
|
|
14382
|
-
}
|
|
14383
|
-
}
|
|
14384
|
-
buffer = lines[lines.length - 1];
|
|
12555
|
+
const data = decoder.decode(value, { stream: true });
|
|
12556
|
+
buffer += data;
|
|
12557
|
+
const lines = buffer.split('\n');
|
|
12558
|
+
for (var i = 0; i < lines.length - 1; i++) {
|
|
12559
|
+
var l = lines[i].trim();
|
|
12560
|
+
if (l.length > 0) {
|
|
12561
|
+
stream.enqueueData(l);
|
|
14385
12562
|
}
|
|
14386
12563
|
}
|
|
14387
|
-
|
|
14388
|
-
|
|
14389
|
-
|
|
12564
|
+
buffer = lines[lines.length - 1];
|
|
12565
|
+
// Implement backpressure by waiting for the low water mark to be reached
|
|
12566
|
+
if (stream.dataQueue.length > stream.highWatermark) {
|
|
12567
|
+
await new Promise((resolve) => {
|
|
12568
|
+
const dispose = stream.registerListener({
|
|
12569
|
+
lowWater: async () => {
|
|
12570
|
+
resolve();
|
|
12571
|
+
dispose();
|
|
12572
|
+
},
|
|
12573
|
+
closed: () => {
|
|
12574
|
+
resolve();
|
|
12575
|
+
dispose();
|
|
12576
|
+
}
|
|
12577
|
+
});
|
|
12578
|
+
});
|
|
14390
12579
|
}
|
|
14391
|
-
}
|
|
12580
|
+
}
|
|
12581
|
+
};
|
|
12582
|
+
consumeStream().catch(ex => this.logger.error('Error consuming stream', ex));
|
|
12583
|
+
const l = stream.registerListener({
|
|
14392
12584
|
closed: () => {
|
|
14393
12585
|
closeReader();
|
|
14394
12586
|
l?.();
|
|
@@ -14467,18 +12659,17 @@ var SyncClientImplementation;
|
|
|
14467
12659
|
*
|
|
14468
12660
|
* This is the default option.
|
|
14469
12661
|
*
|
|
14470
|
-
* @deprecated
|
|
14471
|
-
*
|
|
14472
|
-
*
|
|
12662
|
+
* @deprecated We recommend the {@link RUST} client implementation for all apps. If you have issues with
|
|
12663
|
+
* the Rust client, please file an issue or reach out to us. The JavaScript client will be removed in a future
|
|
12664
|
+
* version of the PowerSync SDK.
|
|
14473
12665
|
*/
|
|
14474
12666
|
SyncClientImplementation["JAVASCRIPT"] = "js";
|
|
14475
12667
|
/**
|
|
14476
12668
|
* This implementation offloads the sync line decoding and handling into the PowerSync
|
|
14477
12669
|
* core extension.
|
|
14478
12670
|
*
|
|
14479
|
-
* @
|
|
14480
|
-
*
|
|
14481
|
-
* it has seen less real-world testing and is marked as __experimental__ at the moment.
|
|
12671
|
+
* This option is more performant than the {@link JAVASCRIPT} client, enabled by default and the
|
|
12672
|
+
* recommended client implementation for all apps.
|
|
14482
12673
|
*
|
|
14483
12674
|
* ## Compatibility warning
|
|
14484
12675
|
*
|
|
@@ -14496,13 +12687,9 @@ var SyncClientImplementation;
|
|
|
14496
12687
|
SyncClientImplementation["RUST"] = "rust";
|
|
14497
12688
|
})(SyncClientImplementation || (SyncClientImplementation = {}));
|
|
14498
12689
|
/**
|
|
14499
|
-
* The default {@link SyncClientImplementation} to use.
|
|
14500
|
-
*
|
|
14501
|
-
* Please use this field instead of {@link SyncClientImplementation.JAVASCRIPT} directly. A future version
|
|
14502
|
-
* of the PowerSync SDK will enable {@link SyncClientImplementation.RUST} by default and remove the JavaScript
|
|
14503
|
-
* option.
|
|
12690
|
+
* The default {@link SyncClientImplementation} to use, {@link SyncClientImplementation.RUST}.
|
|
14504
12691
|
*/
|
|
14505
|
-
const DEFAULT_SYNC_CLIENT_IMPLEMENTATION = SyncClientImplementation.
|
|
12692
|
+
const DEFAULT_SYNC_CLIENT_IMPLEMENTATION = SyncClientImplementation.RUST;
|
|
14506
12693
|
const DEFAULT_CRUD_UPLOAD_THROTTLE_MS = 1000;
|
|
14507
12694
|
const DEFAULT_RETRY_DELAY_MS = 5000;
|
|
14508
12695
|
const DEFAULT_STREAMING_SYNC_OPTIONS = {
|
|
@@ -14912,6 +13099,9 @@ The next upload iteration will be delayed.`);
|
|
|
14912
13099
|
if (rawTables != null && rawTables.length) {
|
|
14913
13100
|
this.logger.warn('Raw tables require the Rust-based sync client. The JS client will ignore them.');
|
|
14914
13101
|
}
|
|
13102
|
+
if (this.activeStreams.length) {
|
|
13103
|
+
this.logger.error('Sync streams require `clientImplementation: SyncClientImplementation.RUST` when connecting.');
|
|
13104
|
+
}
|
|
14915
13105
|
this.logger.debug('Streaming sync iteration started');
|
|
14916
13106
|
this.options.adapter.startSession();
|
|
14917
13107
|
let [req, bucketMap] = await this.collectLocalBucketState();
|
|
@@ -15427,6 +13617,27 @@ The next upload iteration will be delayed.`);
|
|
|
15427
13617
|
}
|
|
15428
13618
|
}
|
|
15429
13619
|
|
|
13620
|
+
const CLAIM_STORE = new Map();
|
|
13621
|
+
/**
|
|
13622
|
+
* @internal
|
|
13623
|
+
* @experimental
|
|
13624
|
+
*/
|
|
13625
|
+
const MEMORY_TRIGGER_CLAIM_MANAGER = {
|
|
13626
|
+
async obtainClaim(identifier) {
|
|
13627
|
+
if (CLAIM_STORE.has(identifier)) {
|
|
13628
|
+
throw new Error(`A claim is already present for ${identifier}`);
|
|
13629
|
+
}
|
|
13630
|
+
const release = async () => {
|
|
13631
|
+
CLAIM_STORE.delete(identifier);
|
|
13632
|
+
};
|
|
13633
|
+
CLAIM_STORE.set(identifier, release);
|
|
13634
|
+
return release;
|
|
13635
|
+
},
|
|
13636
|
+
async checkClaim(identifier) {
|
|
13637
|
+
return CLAIM_STORE.has(identifier);
|
|
13638
|
+
}
|
|
13639
|
+
};
|
|
13640
|
+
|
|
15430
13641
|
/**
|
|
15431
13642
|
* SQLite operations to track changes for with {@link TriggerManager}
|
|
15432
13643
|
* @experimental
|
|
@@ -15438,9 +13649,20 @@ var DiffTriggerOperation;
|
|
|
15438
13649
|
DiffTriggerOperation["DELETE"] = "DELETE";
|
|
15439
13650
|
})(DiffTriggerOperation || (DiffTriggerOperation = {}));
|
|
15440
13651
|
|
|
13652
|
+
const DEFAULT_TRIGGER_MANAGER_CONFIGURATION = {
|
|
13653
|
+
useStorageByDefault: false
|
|
13654
|
+
};
|
|
13655
|
+
const TRIGGER_CLEANUP_INTERVAL_MS = 120_000; // 2 minutes
|
|
13656
|
+
/**
|
|
13657
|
+
* @internal
|
|
13658
|
+
* @experimental
|
|
13659
|
+
*/
|
|
15441
13660
|
class TriggerManagerImpl {
|
|
15442
13661
|
options;
|
|
15443
13662
|
schema;
|
|
13663
|
+
defaultConfig;
|
|
13664
|
+
cleanupTimeout;
|
|
13665
|
+
isDisposed;
|
|
15444
13666
|
constructor(options) {
|
|
15445
13667
|
this.options = options;
|
|
15446
13668
|
this.schema = options.schema;
|
|
@@ -15449,6 +13671,33 @@ class TriggerManagerImpl {
|
|
|
15449
13671
|
this.schema = schema;
|
|
15450
13672
|
}
|
|
15451
13673
|
});
|
|
13674
|
+
this.isDisposed = false;
|
|
13675
|
+
/**
|
|
13676
|
+
* Configure a cleanup to run on an interval.
|
|
13677
|
+
* The interval is configured using setTimeout to take the async
|
|
13678
|
+
* execution time of the callback into account.
|
|
13679
|
+
*/
|
|
13680
|
+
this.defaultConfig = DEFAULT_TRIGGER_MANAGER_CONFIGURATION;
|
|
13681
|
+
const cleanupCallback = async () => {
|
|
13682
|
+
this.cleanupTimeout = null;
|
|
13683
|
+
if (this.isDisposed) {
|
|
13684
|
+
return;
|
|
13685
|
+
}
|
|
13686
|
+
try {
|
|
13687
|
+
await this.cleanupResources();
|
|
13688
|
+
}
|
|
13689
|
+
catch (ex) {
|
|
13690
|
+
this.db.logger.error(`Caught error while attempting to cleanup triggers`, ex);
|
|
13691
|
+
}
|
|
13692
|
+
finally {
|
|
13693
|
+
// if not closed, set another timeout
|
|
13694
|
+
if (this.isDisposed) {
|
|
13695
|
+
return;
|
|
13696
|
+
}
|
|
13697
|
+
this.cleanupTimeout = setTimeout(cleanupCallback, TRIGGER_CLEANUP_INTERVAL_MS);
|
|
13698
|
+
}
|
|
13699
|
+
};
|
|
13700
|
+
this.cleanupTimeout = setTimeout(cleanupCallback, TRIGGER_CLEANUP_INTERVAL_MS);
|
|
15452
13701
|
}
|
|
15453
13702
|
get db() {
|
|
15454
13703
|
return this.options.db;
|
|
@@ -15466,13 +13715,95 @@ class TriggerManagerImpl {
|
|
|
15466
13715
|
await tx.execute(/* sql */ `DROP TRIGGER IF EXISTS ${triggerId}; `);
|
|
15467
13716
|
}
|
|
15468
13717
|
}
|
|
13718
|
+
dispose() {
|
|
13719
|
+
this.isDisposed = true;
|
|
13720
|
+
if (this.cleanupTimeout) {
|
|
13721
|
+
clearTimeout(this.cleanupTimeout);
|
|
13722
|
+
}
|
|
13723
|
+
}
|
|
13724
|
+
/**
|
|
13725
|
+
* Updates default config settings for platform specific use-cases.
|
|
13726
|
+
*/
|
|
13727
|
+
updateDefaults(config) {
|
|
13728
|
+
this.defaultConfig = {
|
|
13729
|
+
...this.defaultConfig,
|
|
13730
|
+
...config
|
|
13731
|
+
};
|
|
13732
|
+
}
|
|
13733
|
+
generateTriggerName(operation, destinationTable, triggerId) {
|
|
13734
|
+
return `__ps_temp_trigger_${operation.toLowerCase()}__${destinationTable}__${triggerId}`;
|
|
13735
|
+
}
|
|
13736
|
+
/**
|
|
13737
|
+
* Cleanup any SQLite triggers or tables that are no longer in use.
|
|
13738
|
+
*/
|
|
13739
|
+
async cleanupResources() {
|
|
13740
|
+
// we use the database here since cleanupResources is called during the PowerSyncDatabase initialization
|
|
13741
|
+
await this.db.database.writeLock(async (ctx) => {
|
|
13742
|
+
/**
|
|
13743
|
+
* Note: We only cleanup persisted triggers. These are tracked in the sqlite_master table.
|
|
13744
|
+
* temporary triggers will not be affected by this.
|
|
13745
|
+
* Query all triggers that match our naming pattern
|
|
13746
|
+
*/
|
|
13747
|
+
const triggers = await ctx.getAll(/* sql */ `
|
|
13748
|
+
SELECT
|
|
13749
|
+
name
|
|
13750
|
+
FROM
|
|
13751
|
+
sqlite_master
|
|
13752
|
+
WHERE
|
|
13753
|
+
type = 'trigger'
|
|
13754
|
+
AND name LIKE '__ps_temp_trigger_%'
|
|
13755
|
+
`);
|
|
13756
|
+
/** Use regex to extract table names and IDs from trigger names
|
|
13757
|
+
* Trigger naming convention: __ps_temp_trigger_<operation>__<destination_table>__<id>
|
|
13758
|
+
*/
|
|
13759
|
+
const triggerPattern = /^__ps_temp_trigger_(?:insert|update|delete)__(.+)__([a-f0-9_]{36})$/i;
|
|
13760
|
+
const trackedItems = new Map();
|
|
13761
|
+
for (const trigger of triggers) {
|
|
13762
|
+
const match = trigger.name.match(triggerPattern);
|
|
13763
|
+
if (match) {
|
|
13764
|
+
const [, table, id] = match;
|
|
13765
|
+
// Collect all trigger names for each id combo
|
|
13766
|
+
const existing = trackedItems.get(id);
|
|
13767
|
+
if (existing) {
|
|
13768
|
+
existing.triggerNames.push(trigger.name);
|
|
13769
|
+
}
|
|
13770
|
+
else {
|
|
13771
|
+
trackedItems.set(id, { table, id, triggerNames: [trigger.name] });
|
|
13772
|
+
}
|
|
13773
|
+
}
|
|
13774
|
+
}
|
|
13775
|
+
for (const trackedItem of trackedItems.values()) {
|
|
13776
|
+
// check if there is anything holding on to this item
|
|
13777
|
+
const hasClaim = await this.options.claimManager.checkClaim(trackedItem.id);
|
|
13778
|
+
if (hasClaim) {
|
|
13779
|
+
// This does not require cleanup
|
|
13780
|
+
continue;
|
|
13781
|
+
}
|
|
13782
|
+
this.db.logger.debug(`Clearing resources for trigger ${trackedItem.id} with table ${trackedItem.table}`);
|
|
13783
|
+
// We need to delete the triggers and table
|
|
13784
|
+
for (const triggerName of trackedItem.triggerNames) {
|
|
13785
|
+
await ctx.execute(`DROP TRIGGER IF EXISTS ${triggerName}`);
|
|
13786
|
+
}
|
|
13787
|
+
await ctx.execute(`DROP TABLE IF EXISTS ${trackedItem.table}`);
|
|
13788
|
+
}
|
|
13789
|
+
});
|
|
13790
|
+
}
|
|
15469
13791
|
async createDiffTrigger(options) {
|
|
15470
13792
|
await this.db.waitForReady();
|
|
15471
|
-
const { source, destination, columns, when, hooks
|
|
13793
|
+
const { source, destination, columns, when, hooks,
|
|
13794
|
+
// Fall back to the provided default if not given on this level
|
|
13795
|
+
useStorage = this.defaultConfig.useStorageByDefault } = options;
|
|
15472
13796
|
const operations = Object.keys(when);
|
|
15473
13797
|
if (operations.length == 0) {
|
|
15474
13798
|
throw new Error('At least one WHEN operation must be specified for the trigger.');
|
|
15475
13799
|
}
|
|
13800
|
+
/**
|
|
13801
|
+
* The clause to use when executing
|
|
13802
|
+
* CREATE ${tableTriggerTypeClause} TABLE
|
|
13803
|
+
* OR
|
|
13804
|
+
* CREATE ${tableTriggerTypeClause} TRIGGER
|
|
13805
|
+
*/
|
|
13806
|
+
const tableTriggerTypeClause = !useStorage ? 'TEMP' : '';
|
|
15476
13807
|
const whenClauses = Object.fromEntries(Object.entries(when).map(([operation, filter]) => [operation, `WHEN ${filter}`]));
|
|
15477
13808
|
/**
|
|
15478
13809
|
* Allow specifying the View name as the source.
|
|
@@ -15486,6 +13817,7 @@ class TriggerManagerImpl {
|
|
|
15486
13817
|
const internalSource = sourceDefinition.internalName;
|
|
15487
13818
|
const triggerIds = [];
|
|
15488
13819
|
const id = await this.getUUID();
|
|
13820
|
+
const releaseStorageClaim = useStorage ? await this.options.claimManager.obtainClaim(id) : null;
|
|
15489
13821
|
/**
|
|
15490
13822
|
* We default to replicating all columns if no columns array is provided.
|
|
15491
13823
|
*/
|
|
@@ -15518,26 +13850,27 @@ class TriggerManagerImpl {
|
|
|
15518
13850
|
return this.db.writeLock(async (tx) => {
|
|
15519
13851
|
await this.removeTriggers(tx, triggerIds);
|
|
15520
13852
|
await tx.execute(/* sql */ `DROP TABLE IF EXISTS ${destination};`);
|
|
13853
|
+
await releaseStorageClaim?.();
|
|
15521
13854
|
});
|
|
15522
13855
|
};
|
|
15523
13856
|
const setup = async (tx) => {
|
|
15524
13857
|
// Allow user code to execute in this lock context before the trigger is created.
|
|
15525
13858
|
await hooks?.beforeCreate?.(tx);
|
|
15526
13859
|
await tx.execute(/* sql */ `
|
|
15527
|
-
CREATE
|
|
13860
|
+
CREATE ${tableTriggerTypeClause} TABLE ${destination} (
|
|
15528
13861
|
operation_id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
15529
13862
|
id TEXT,
|
|
15530
13863
|
operation TEXT,
|
|
15531
13864
|
timestamp TEXT,
|
|
15532
13865
|
value TEXT,
|
|
15533
13866
|
previous_value TEXT
|
|
15534
|
-
)
|
|
13867
|
+
)
|
|
15535
13868
|
`);
|
|
15536
13869
|
if (operations.includes(DiffTriggerOperation.INSERT)) {
|
|
15537
|
-
const insertTriggerId =
|
|
13870
|
+
const insertTriggerId = this.generateTriggerName(DiffTriggerOperation.INSERT, destination, id);
|
|
15538
13871
|
triggerIds.push(insertTriggerId);
|
|
15539
13872
|
await tx.execute(/* sql */ `
|
|
15540
|
-
CREATE
|
|
13873
|
+
CREATE ${tableTriggerTypeClause} TRIGGER ${insertTriggerId} AFTER INSERT ON ${internalSource} ${whenClauses[DiffTriggerOperation.INSERT]} BEGIN
|
|
15541
13874
|
INSERT INTO
|
|
15542
13875
|
${destination} (id, operation, timestamp, value)
|
|
15543
13876
|
VALUES
|
|
@@ -15548,14 +13881,14 @@ class TriggerManagerImpl {
|
|
|
15548
13881
|
${jsonFragment('NEW')}
|
|
15549
13882
|
);
|
|
15550
13883
|
|
|
15551
|
-
END
|
|
13884
|
+
END
|
|
15552
13885
|
`);
|
|
15553
13886
|
}
|
|
15554
13887
|
if (operations.includes(DiffTriggerOperation.UPDATE)) {
|
|
15555
|
-
const updateTriggerId =
|
|
13888
|
+
const updateTriggerId = this.generateTriggerName(DiffTriggerOperation.UPDATE, destination, id);
|
|
15556
13889
|
triggerIds.push(updateTriggerId);
|
|
15557
13890
|
await tx.execute(/* sql */ `
|
|
15558
|
-
CREATE
|
|
13891
|
+
CREATE ${tableTriggerTypeClause} TRIGGER ${updateTriggerId} AFTER
|
|
15559
13892
|
UPDATE ON ${internalSource} ${whenClauses[DiffTriggerOperation.UPDATE]} BEGIN
|
|
15560
13893
|
INSERT INTO
|
|
15561
13894
|
${destination} (id, operation, timestamp, value, previous_value)
|
|
@@ -15572,11 +13905,11 @@ class TriggerManagerImpl {
|
|
|
15572
13905
|
`);
|
|
15573
13906
|
}
|
|
15574
13907
|
if (operations.includes(DiffTriggerOperation.DELETE)) {
|
|
15575
|
-
const deleteTriggerId =
|
|
13908
|
+
const deleteTriggerId = this.generateTriggerName(DiffTriggerOperation.DELETE, destination, id);
|
|
15576
13909
|
triggerIds.push(deleteTriggerId);
|
|
15577
13910
|
// Create delete trigger for basic JSON
|
|
15578
13911
|
await tx.execute(/* sql */ `
|
|
15579
|
-
CREATE
|
|
13912
|
+
CREATE ${tableTriggerTypeClause} TRIGGER ${deleteTriggerId} AFTER DELETE ON ${internalSource} ${whenClauses[DiffTriggerOperation.DELETE]} BEGIN
|
|
15580
13913
|
INSERT INTO
|
|
15581
13914
|
${destination} (id, operation, timestamp, value)
|
|
15582
13915
|
VALUES
|
|
@@ -15620,7 +13953,7 @@ class TriggerManagerImpl {
|
|
|
15620
13953
|
// If no array is provided, we use all columns from the source table.
|
|
15621
13954
|
const contextColumns = columns ?? sourceDefinition.columns.map((col) => col.name);
|
|
15622
13955
|
const id = await this.getUUID();
|
|
15623
|
-
const destination = `
|
|
13956
|
+
const destination = `__ps_temp_track_${source}_${id}`;
|
|
15624
13957
|
// register an onChange before the trigger is created
|
|
15625
13958
|
const abortController = new AbortController();
|
|
15626
13959
|
const abortOnChange = () => abortController.abort();
|
|
@@ -15775,6 +14108,7 @@ class AbstractPowerSyncDatabase extends BaseObserver {
|
|
|
15775
14108
|
* Allows creating SQLite triggers which can be used to track various operations on SQLite tables.
|
|
15776
14109
|
*/
|
|
15777
14110
|
triggers;
|
|
14111
|
+
triggersImpl;
|
|
15778
14112
|
logger;
|
|
15779
14113
|
constructor(options) {
|
|
15780
14114
|
super();
|
|
@@ -15838,9 +14172,10 @@ class AbstractPowerSyncDatabase extends BaseObserver {
|
|
|
15838
14172
|
logger: this.logger
|
|
15839
14173
|
});
|
|
15840
14174
|
this._isReadyPromise = this.initialize();
|
|
15841
|
-
this.triggers = new TriggerManagerImpl({
|
|
14175
|
+
this.triggers = this.triggersImpl = new TriggerManagerImpl({
|
|
15842
14176
|
db: this,
|
|
15843
|
-
schema: this.schema
|
|
14177
|
+
schema: this.schema,
|
|
14178
|
+
...this.generateTriggerManagerConfig()
|
|
15844
14179
|
});
|
|
15845
14180
|
}
|
|
15846
14181
|
/**
|
|
@@ -15866,6 +14201,15 @@ class AbstractPowerSyncDatabase extends BaseObserver {
|
|
|
15866
14201
|
get connecting() {
|
|
15867
14202
|
return this.currentStatus?.connecting || false;
|
|
15868
14203
|
}
|
|
14204
|
+
/**
|
|
14205
|
+
* Generates a base configuration for {@link TriggerManagerImpl}.
|
|
14206
|
+
* Implementations should override this if necessary.
|
|
14207
|
+
*/
|
|
14208
|
+
generateTriggerManagerConfig() {
|
|
14209
|
+
return {
|
|
14210
|
+
claimManager: MEMORY_TRIGGER_CLAIM_MANAGER
|
|
14211
|
+
};
|
|
14212
|
+
}
|
|
15869
14213
|
/**
|
|
15870
14214
|
* @returns A promise which will resolve once initialization is completed.
|
|
15871
14215
|
*/
|
|
@@ -15926,14 +14270,15 @@ class AbstractPowerSyncDatabase extends BaseObserver {
|
|
|
15926
14270
|
async initialize() {
|
|
15927
14271
|
await this._initialize();
|
|
15928
14272
|
await this.bucketStorageAdapter.init();
|
|
15929
|
-
await this.
|
|
14273
|
+
await this.loadVersion();
|
|
15930
14274
|
await this.updateSchema(this.options.schema);
|
|
15931
14275
|
await this.resolveOfflineSyncStatus();
|
|
15932
14276
|
await this.database.execute('PRAGMA RECURSIVE_TRIGGERS=TRUE');
|
|
14277
|
+
await this.triggersImpl.cleanupResources();
|
|
15933
14278
|
this.ready = true;
|
|
15934
14279
|
this.iterateListeners((cb) => cb.initialized?.());
|
|
15935
14280
|
}
|
|
15936
|
-
async
|
|
14281
|
+
async loadVersion() {
|
|
15937
14282
|
try {
|
|
15938
14283
|
const { version } = await this.database.get('SELECT powersync_rs_version() as version');
|
|
15939
14284
|
this.sdkVersion = version;
|
|
@@ -16049,7 +14394,6 @@ class AbstractPowerSyncDatabase extends BaseObserver {
|
|
|
16049
14394
|
await this.disconnect();
|
|
16050
14395
|
await this.waitForReady();
|
|
16051
14396
|
const { clearLocal } = options;
|
|
16052
|
-
// TODO DB name, verify this is necessary with extension
|
|
16053
14397
|
await this.database.writeTransaction(async (tx) => {
|
|
16054
14398
|
await tx.execute('SELECT powersync_clear(?)', [clearLocal ? 1 : 0]);
|
|
16055
14399
|
});
|
|
@@ -16081,6 +14425,7 @@ class AbstractPowerSyncDatabase extends BaseObserver {
|
|
|
16081
14425
|
if (this.closed) {
|
|
16082
14426
|
return;
|
|
16083
14427
|
}
|
|
14428
|
+
this.triggersImpl.dispose();
|
|
16084
14429
|
await this.iterateAsyncListeners(async (cb) => cb.closing?.());
|
|
16085
14430
|
const { disconnect } = options;
|
|
16086
14431
|
if (disconnect) {
|
|
@@ -17657,16 +16002,16 @@ const parseQuery = (query, parameters) => {
|
|
|
17657
16002
|
/*!***********************************************************!*\
|
|
17658
16003
|
!*** ./lib/src/db/adapters/LockedAsyncDatabaseAdapter.js ***!
|
|
17659
16004
|
\***********************************************************/
|
|
17660
|
-
(
|
|
16005
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
17661
16006
|
|
|
17662
16007
|
__webpack_require__.r(__webpack_exports__);
|
|
17663
16008
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
17664
16009
|
/* harmony export */ LockedAsyncDatabaseAdapter: () => (/* binding */ LockedAsyncDatabaseAdapter)
|
|
17665
16010
|
/* harmony export */ });
|
|
17666
16011
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @powersync/common */ "../common/dist/bundle.mjs");
|
|
17667
|
-
/* harmony import */ var
|
|
17668
|
-
/* harmony import */ var
|
|
17669
|
-
/* harmony import */ var
|
|
16012
|
+
/* harmony import */ var _shared_navigator_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../shared/navigator.js */ "./lib/src/shared/navigator.js");
|
|
16013
|
+
/* harmony import */ var _WorkerWrappedAsyncDatabaseConnection_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./WorkerWrappedAsyncDatabaseConnection.js */ "./lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.js");
|
|
16014
|
+
/* harmony import */ var _wa_sqlite_WASQLiteConnection_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./wa-sqlite/WASQLiteConnection.js */ "./lib/src/db/adapters/wa-sqlite/WASQLiteConnection.js");
|
|
17670
16015
|
|
|
17671
16016
|
|
|
17672
16017
|
|
|
@@ -17759,7 +16104,7 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
17759
16104
|
/**
|
|
17760
16105
|
* This is only required for the long-lived shared IndexedDB connections.
|
|
17761
16106
|
*/
|
|
17762
|
-
this.requiresHolds = this._config.vfs ==
|
|
16107
|
+
this.requiresHolds = this._config.vfs == _wa_sqlite_WASQLiteConnection_js__WEBPACK_IMPORTED_MODULE_3__.WASQLiteVFS.IDBBatchAtomicVFS;
|
|
17763
16108
|
});
|
|
17764
16109
|
}
|
|
17765
16110
|
_reOpen() {
|
|
@@ -17806,14 +16151,18 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
17806
16151
|
if (!this._config) {
|
|
17807
16152
|
throw new Error(`Cannot get config before initialization is completed`);
|
|
17808
16153
|
}
|
|
17809
|
-
return
|
|
16154
|
+
return {
|
|
16155
|
+
...this._config,
|
|
16156
|
+
// This can be overridden by the adapter later
|
|
16157
|
+
requiresPersistentTriggers: false
|
|
16158
|
+
};
|
|
17810
16159
|
}
|
|
17811
16160
|
async waitForInitialized() {
|
|
17812
16161
|
// Awaiting this will expose errors on function calls like .execute etc
|
|
17813
16162
|
await this.initPromise;
|
|
17814
16163
|
}
|
|
17815
16164
|
async shareConnection() {
|
|
17816
|
-
if (false == this._db instanceof
|
|
16165
|
+
if (false == this._db instanceof _WorkerWrappedAsyncDatabaseConnection_js__WEBPACK_IMPORTED_MODULE_2__.WorkerWrappedAsyncDatabaseConnection) {
|
|
17817
16166
|
throw new Error(`Only worker connections can be shared`);
|
|
17818
16167
|
}
|
|
17819
16168
|
return this._db.shareConnection();
|
|
@@ -17896,7 +16245,7 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
17896
16245
|
this.pendingAbortControllers.delete(abortController);
|
|
17897
16246
|
}, timeoutMs)
|
|
17898
16247
|
: null;
|
|
17899
|
-
return (0,
|
|
16248
|
+
return (0,_shared_navigator_js__WEBPACK_IMPORTED_MODULE_1__.getNavigatorLocks)().request(`db-lock-${this._dbIdentifier}`, { signal: abortController.signal }, async () => {
|
|
17900
16249
|
this.pendingAbortControllers.delete(abortController);
|
|
17901
16250
|
if (timeoutId) {
|
|
17902
16251
|
clearTimeout(timeoutId);
|
|
@@ -18061,14 +16410,14 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
18061
16410
|
/*!*********************************************************************!*\
|
|
18062
16411
|
!*** ./lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.js ***!
|
|
18063
16412
|
\*********************************************************************/
|
|
18064
|
-
(
|
|
16413
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
18065
16414
|
|
|
18066
16415
|
__webpack_require__.r(__webpack_exports__);
|
|
18067
16416
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
18068
16417
|
/* harmony export */ WorkerWrappedAsyncDatabaseConnection: () => (/* binding */ WorkerWrappedAsyncDatabaseConnection)
|
|
18069
16418
|
/* harmony export */ });
|
|
18070
16419
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @powersync/common */ "../common/dist/bundle.mjs");
|
|
18071
|
-
/* harmony import */ var comlink__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! comlink */ "../../node_modules/comlink/dist/esm/comlink.mjs");
|
|
16420
|
+
/* harmony import */ var comlink__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! comlink */ "../../node_modules/.pnpm/comlink@4.4.2/node_modules/comlink/dist/esm/comlink.mjs");
|
|
18072
16421
|
|
|
18073
16422
|
|
|
18074
16423
|
/**
|
|
@@ -18224,7 +16573,7 @@ class WorkerWrappedAsyncDatabaseConnection extends _powersync_common__WEBPACK_IM
|
|
|
18224
16573
|
/*!*************************************************************!*\
|
|
18225
16574
|
!*** ./lib/src/db/adapters/wa-sqlite/WASQLiteConnection.js ***!
|
|
18226
16575
|
\*************************************************************/
|
|
18227
|
-
(
|
|
16576
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
18228
16577
|
|
|
18229
16578
|
__webpack_require__.r(__webpack_exports__);
|
|
18230
16579
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
@@ -18236,9 +16585,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
18236
16585
|
/* harmony export */ WASQLiteVFS: () => (/* binding */ WASQLiteVFS),
|
|
18237
16586
|
/* harmony export */ WASqliteConnection: () => (/* binding */ WASqliteConnection)
|
|
18238
16587
|
/* harmony export */ });
|
|
18239
|
-
/* harmony import */ var _journeyapps_wa_sqlite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @journeyapps/wa-sqlite */ "../../node_modules/@journeyapps/wa-sqlite/src/sqlite-api.js");
|
|
16588
|
+
/* harmony import */ var _journeyapps_wa_sqlite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @journeyapps/wa-sqlite */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/src/sqlite-api.js");
|
|
18240
16589
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @powersync/common */ "../common/dist/bundle.mjs");
|
|
18241
|
-
/* harmony import */ var async_mutex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! async-mutex */ "../../node_modules/async-mutex/index.mjs");
|
|
16590
|
+
/* harmony import */ var async_mutex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! async-mutex */ "../../node_modules/.pnpm/async-mutex@0.5.0/node_modules/async-mutex/index.mjs");
|
|
18242
16591
|
|
|
18243
16592
|
|
|
18244
16593
|
|
|
@@ -18255,28 +16604,28 @@ var WASQLiteVFS;
|
|
|
18255
16604
|
* @internal
|
|
18256
16605
|
*/
|
|
18257
16606
|
const AsyncWASQLiteModuleFactory = async () => {
|
|
18258
|
-
const { default: factory } = await __webpack_require__.e(/*! import() */ "
|
|
16607
|
+
const { default: factory } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_wa-sqli-f60d0d").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/dist/wa-sqlite-async.mjs */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/dist/wa-sqlite-async.mjs"));
|
|
18259
16608
|
return factory();
|
|
18260
16609
|
};
|
|
18261
16610
|
/**
|
|
18262
16611
|
* @internal
|
|
18263
16612
|
*/
|
|
18264
16613
|
const MultiCipherAsyncWASQLiteModuleFactory = async () => {
|
|
18265
|
-
const { default: factory } = await __webpack_require__.e(/*! import() */ "
|
|
16614
|
+
const { default: factory } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-3a94cf").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/dist/mc-wa-sqlite-async.mjs */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/dist/mc-wa-sqlite-async.mjs"));
|
|
18266
16615
|
return factory();
|
|
18267
16616
|
};
|
|
18268
16617
|
/**
|
|
18269
16618
|
* @internal
|
|
18270
16619
|
*/
|
|
18271
16620
|
const SyncWASQLiteModuleFactory = async () => {
|
|
18272
|
-
const { default: factory } = await __webpack_require__.e(/*! import() */ "
|
|
16621
|
+
const { default: factory } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/dist/wa-sqlite.mjs */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/dist/wa-sqlite.mjs"));
|
|
18273
16622
|
return factory();
|
|
18274
16623
|
};
|
|
18275
16624
|
/**
|
|
18276
16625
|
* @internal
|
|
18277
16626
|
*/
|
|
18278
16627
|
const MultiCipherSyncWASQLiteModuleFactory = async () => {
|
|
18279
|
-
const { default: factory } = await __webpack_require__.e(/*! import() */ "
|
|
16628
|
+
const { default: factory } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_dist_mc-wa-s-868779").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/dist/mc-wa-sqlite.mjs */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/dist/mc-wa-sqlite.mjs"));
|
|
18280
16629
|
return factory();
|
|
18281
16630
|
};
|
|
18282
16631
|
/**
|
|
@@ -18291,7 +16640,7 @@ const DEFAULT_MODULE_FACTORIES = {
|
|
|
18291
16640
|
else {
|
|
18292
16641
|
module = await AsyncWASQLiteModuleFactory();
|
|
18293
16642
|
}
|
|
18294
|
-
const { IDBBatchAtomicVFS } = await __webpack_require__.e(/*! import() */ "
|
|
16643
|
+
const { IDBBatchAtomicVFS } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_src_examples-0d2437").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js"));
|
|
18295
16644
|
return {
|
|
18296
16645
|
module,
|
|
18297
16646
|
// @ts-expect-error The types for this static method are missing upstream
|
|
@@ -18307,7 +16656,7 @@ const DEFAULT_MODULE_FACTORIES = {
|
|
|
18307
16656
|
module = await SyncWASQLiteModuleFactory();
|
|
18308
16657
|
}
|
|
18309
16658
|
// @ts-expect-error The types for this static method are missing upstream
|
|
18310
|
-
const { AccessHandlePoolVFS } = await __webpack_require__.e(/*! import() */ "
|
|
16659
|
+
const { AccessHandlePoolVFS } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_src_examples-3622cf").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/src/examples/AccessHandlePoolVFS.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/src/examples/AccessHandlePoolVFS.js"));
|
|
18311
16660
|
return {
|
|
18312
16661
|
module,
|
|
18313
16662
|
vfs: await AccessHandlePoolVFS.create(options.dbFileName, module)
|
|
@@ -18322,7 +16671,7 @@ const DEFAULT_MODULE_FACTORIES = {
|
|
|
18322
16671
|
module = await SyncWASQLiteModuleFactory();
|
|
18323
16672
|
}
|
|
18324
16673
|
// @ts-expect-error The types for this static method are missing upstream
|
|
18325
|
-
const { OPFSCoopSyncVFS } = await __webpack_require__.e(/*! import() */ "
|
|
16674
|
+
const { OPFSCoopSyncVFS } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_journeyapps_wa-sqlite_1_4_1_node_modules_journeyapps_wa-sqlite_src_examples-1d4e74").then(__webpack_require__.bind(__webpack_require__, /*! @journeyapps/wa-sqlite/src/examples/OPFSCoopSyncVFS.js */ "../../node_modules/.pnpm/@journeyapps+wa-sqlite@1.4.1/node_modules/@journeyapps/wa-sqlite/src/examples/OPFSCoopSyncVFS.js"));
|
|
18326
16675
|
const vfs = await OPFSCoopSyncVFS.create(options.dbFileName, module);
|
|
18327
16676
|
return {
|
|
18328
16677
|
module,
|
|
@@ -18648,14 +16997,14 @@ class WASqliteConnection extends _powersync_common__WEBPACK_IMPORTED_MODULE_1__.
|
|
|
18648
16997
|
/*!**************************************!*\
|
|
18649
16998
|
!*** ./lib/src/db/sync/WebRemote.js ***!
|
|
18650
16999
|
\**************************************/
|
|
18651
|
-
(
|
|
17000
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
18652
17001
|
|
|
18653
17002
|
__webpack_require__.r(__webpack_exports__);
|
|
18654
17003
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
18655
17004
|
/* harmony export */ WebRemote: () => (/* binding */ WebRemote)
|
|
18656
17005
|
/* harmony export */ });
|
|
18657
17006
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @powersync/common */ "../common/dist/bundle.mjs");
|
|
18658
|
-
/* harmony import */ var
|
|
17007
|
+
/* harmony import */ var _userAgent_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./userAgent.js */ "./lib/src/db/sync/userAgent.js");
|
|
18659
17008
|
|
|
18660
17009
|
|
|
18661
17010
|
/*
|
|
@@ -18681,7 +17030,7 @@ class WebRemote extends _powersync_common__WEBPACK_IMPORTED_MODULE_0__.AbstractR
|
|
|
18681
17030
|
getUserAgent() {
|
|
18682
17031
|
let ua = [super.getUserAgent(), `powersync-web`];
|
|
18683
17032
|
try {
|
|
18684
|
-
ua.push(...(0,
|
|
17033
|
+
ua.push(...(0,_userAgent_js__WEBPACK_IMPORTED_MODULE_1__.getUserAgentInfo)());
|
|
18685
17034
|
}
|
|
18686
17035
|
catch (e) {
|
|
18687
17036
|
this.logger.warn('Failed to get user agent info', e);
|
|
@@ -18695,7 +17044,7 @@ class WebRemote extends _powersync_common__WEBPACK_IMPORTED_MODULE_0__.AbstractR
|
|
|
18695
17044
|
/**
|
|
18696
17045
|
* Dynamic import to be used only when needed.
|
|
18697
17046
|
*/
|
|
18698
|
-
const { BSON } = await __webpack_require__.e(/*! import() */ "
|
|
17047
|
+
const { BSON } = await __webpack_require__.e(/*! import() */ "node_modules_pnpm_bson_6_10_4_node_modules_bson_lib_bson_mjs").then(__webpack_require__.bind(__webpack_require__, /*! bson */ "../../node_modules/.pnpm/bson@6.10.4/node_modules/bson/lib/bson.mjs"));
|
|
18699
17048
|
this._bson = BSON;
|
|
18700
17049
|
return this._bson;
|
|
18701
17050
|
}
|
|
@@ -18708,14 +17057,14 @@ class WebRemote extends _powersync_common__WEBPACK_IMPORTED_MODULE_0__.AbstractR
|
|
|
18708
17057
|
/*!***********************************************************!*\
|
|
18709
17058
|
!*** ./lib/src/db/sync/WebStreamingSyncImplementation.js ***!
|
|
18710
17059
|
\***********************************************************/
|
|
18711
|
-
(
|
|
17060
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
18712
17061
|
|
|
18713
17062
|
__webpack_require__.r(__webpack_exports__);
|
|
18714
17063
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
18715
17064
|
/* harmony export */ WebStreamingSyncImplementation: () => (/* binding */ WebStreamingSyncImplementation)
|
|
18716
17065
|
/* harmony export */ });
|
|
18717
17066
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @powersync/common */ "../common/dist/bundle.mjs");
|
|
18718
|
-
/* harmony import */ var
|
|
17067
|
+
/* harmony import */ var _shared_navigator_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../shared/navigator.js */ "./lib/src/shared/navigator.js");
|
|
18719
17068
|
|
|
18720
17069
|
|
|
18721
17070
|
class WebStreamingSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODULE_0__.AbstractStreamingSyncImplementation {
|
|
@@ -18731,7 +17080,7 @@ class WebStreamingSyncImplementation extends _powersync_common__WEBPACK_IMPORTED
|
|
|
18731
17080
|
if (lockOptions.type == _powersync_common__WEBPACK_IMPORTED_MODULE_0__.LockType.SYNC) {
|
|
18732
17081
|
this.logger.debug('requesting lock for ', identifier);
|
|
18733
17082
|
}
|
|
18734
|
-
return (0,
|
|
17083
|
+
return (0,_shared_navigator_js__WEBPACK_IMPORTED_MODULE_1__.getNavigatorLocks)().request(identifier, { signal: lockOptions.signal }, lockOptions.callback);
|
|
18735
17084
|
}
|
|
18736
17085
|
}
|
|
18737
17086
|
|
|
@@ -18742,7 +17091,7 @@ class WebStreamingSyncImplementation extends _powersync_common__WEBPACK_IMPORTED
|
|
|
18742
17091
|
/*!**************************************!*\
|
|
18743
17092
|
!*** ./lib/src/db/sync/userAgent.js ***!
|
|
18744
17093
|
\**************************************/
|
|
18745
|
-
(
|
|
17094
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
18746
17095
|
|
|
18747
17096
|
__webpack_require__.r(__webpack_exports__);
|
|
18748
17097
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
@@ -18820,7 +17169,7 @@ function getOsInfo(nav) {
|
|
|
18820
17169
|
/*!*************************************!*\
|
|
18821
17170
|
!*** ./lib/src/shared/navigator.js ***!
|
|
18822
17171
|
\*************************************/
|
|
18823
|
-
(
|
|
17172
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
18824
17173
|
|
|
18825
17174
|
__webpack_require__.r(__webpack_exports__);
|
|
18826
17175
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
@@ -18840,7 +17189,7 @@ const getNavigatorLocks = () => {
|
|
|
18840
17189
|
/*!************************************************!*\
|
|
18841
17190
|
!*** ./lib/src/worker/sync/BroadcastLogger.js ***!
|
|
18842
17191
|
\************************************************/
|
|
18843
|
-
(
|
|
17192
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
18844
17193
|
|
|
18845
17194
|
__webpack_require__.r(__webpack_exports__);
|
|
18846
17195
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
@@ -18983,7 +17332,7 @@ class BroadcastLogger {
|
|
|
18983
17332
|
/*!*********************************************************!*\
|
|
18984
17333
|
!*** ./lib/src/worker/sync/SharedSyncImplementation.js ***!
|
|
18985
17334
|
\*********************************************************/
|
|
18986
|
-
(
|
|
17335
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
18987
17336
|
|
|
18988
17337
|
__webpack_require__.r(__webpack_exports__);
|
|
18989
17338
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
@@ -18991,13 +17340,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
18991
17340
|
/* harmony export */ SharedSyncImplementation: () => (/* binding */ SharedSyncImplementation)
|
|
18992
17341
|
/* harmony export */ });
|
|
18993
17342
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @powersync/common */ "../common/dist/bundle.mjs");
|
|
18994
|
-
/* harmony import */ var async_mutex__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! async-mutex */ "../../node_modules/async-mutex/index.mjs");
|
|
18995
|
-
/* harmony import */ var comlink__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! comlink */ "../../node_modules/comlink/dist/esm/comlink.mjs");
|
|
18996
|
-
/* harmony import */ var
|
|
18997
|
-
/* harmony import */ var
|
|
18998
|
-
/* harmony import */ var
|
|
18999
|
-
/* harmony import */ var
|
|
19000
|
-
/* harmony import */ var
|
|
17343
|
+
/* harmony import */ var async_mutex__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! async-mutex */ "../../node_modules/.pnpm/async-mutex@0.5.0/node_modules/async-mutex/index.mjs");
|
|
17344
|
+
/* harmony import */ var comlink__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! comlink */ "../../node_modules/.pnpm/comlink@4.4.2/node_modules/comlink/dist/esm/comlink.mjs");
|
|
17345
|
+
/* harmony import */ var _db_sync_WebRemote_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../db/sync/WebRemote.js */ "./lib/src/db/sync/WebRemote.js");
|
|
17346
|
+
/* harmony import */ var _db_sync_WebStreamingSyncImplementation_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../db/sync/WebStreamingSyncImplementation.js */ "./lib/src/db/sync/WebStreamingSyncImplementation.js");
|
|
17347
|
+
/* harmony import */ var _db_adapters_LockedAsyncDatabaseAdapter_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../db/adapters/LockedAsyncDatabaseAdapter.js */ "./lib/src/db/adapters/LockedAsyncDatabaseAdapter.js");
|
|
17348
|
+
/* harmony import */ var _db_adapters_WorkerWrappedAsyncDatabaseConnection_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../db/adapters/WorkerWrappedAsyncDatabaseConnection.js */ "./lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.js");
|
|
17349
|
+
/* harmony import */ var _BroadcastLogger_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./BroadcastLogger.js */ "./lib/src/worker/sync/BroadcastLogger.js");
|
|
19001
17350
|
|
|
19002
17351
|
|
|
19003
17352
|
|
|
@@ -19062,7 +17411,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
19062
17411
|
// Should be configured once we get params
|
|
19063
17412
|
this.distributedDB = null;
|
|
19064
17413
|
this.syncStatus = new _powersync_common__WEBPACK_IMPORTED_MODULE_0__.SyncStatus({});
|
|
19065
|
-
this.broadCastLogger = new
|
|
17414
|
+
this.broadCastLogger = new _BroadcastLogger_js__WEBPACK_IMPORTED_MODULE_7__.BroadcastLogger(this.ports);
|
|
19066
17415
|
this.connectionManager = new _powersync_common__WEBPACK_IMPORTED_MODULE_0__.ConnectionManager({
|
|
19067
17416
|
createSyncImplementation: async () => {
|
|
19068
17417
|
await this.waitForReady();
|
|
@@ -19160,7 +17509,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
19160
17509
|
if (params.streamOptions?.flags?.broadcastLogs) {
|
|
19161
17510
|
this.logger = this.broadCastLogger;
|
|
19162
17511
|
}
|
|
19163
|
-
const lockedAdapter = new
|
|
17512
|
+
const lockedAdapter = new _db_adapters_LockedAsyncDatabaseAdapter_js__WEBPACK_IMPORTED_MODULE_5__.LockedAsyncDatabaseAdapter({
|
|
19164
17513
|
name: params.dbParams.dbFilename,
|
|
19165
17514
|
openConnection: async () => {
|
|
19166
17515
|
// Gets a connection from the clients when a new connection is requested.
|
|
@@ -19307,9 +17656,9 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
19307
17656
|
// This should only be called after initialization has completed
|
|
19308
17657
|
const syncParams = this.syncParams;
|
|
19309
17658
|
// Create a new StreamingSyncImplementation for each connect call. This is usually done is all SDKs.
|
|
19310
|
-
return new
|
|
17659
|
+
return new _db_sync_WebStreamingSyncImplementation_js__WEBPACK_IMPORTED_MODULE_4__.WebStreamingSyncImplementation({
|
|
19311
17660
|
adapter: new _powersync_common__WEBPACK_IMPORTED_MODULE_0__.SqliteBucketStorage(this.distributedDB, this.logger),
|
|
19312
|
-
remote: new
|
|
17661
|
+
remote: new _db_sync_WebRemote_js__WEBPACK_IMPORTED_MODULE_3__.WebRemote({
|
|
19313
17662
|
invalidateCredentials: async () => {
|
|
19314
17663
|
const lastPort = await this.getLastWrappedPort();
|
|
19315
17664
|
if (!lastPort) {
|
|
@@ -19434,7 +17783,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
19434
17783
|
removeCloseListener();
|
|
19435
17784
|
});
|
|
19436
17785
|
clearTimeout(timeout);
|
|
19437
|
-
const wrapped = new
|
|
17786
|
+
const wrapped = new _db_adapters_WorkerWrappedAsyncDatabaseConnection_js__WEBPACK_IMPORTED_MODULE_6__.WorkerWrappedAsyncDatabaseConnection({
|
|
19438
17787
|
remote,
|
|
19439
17788
|
baseConnection: db,
|
|
19440
17789
|
identifier,
|
|
@@ -19501,15 +17850,15 @@ function withAbort(options) {
|
|
|
19501
17850
|
/*!*********************************************!*\
|
|
19502
17851
|
!*** ./lib/src/worker/sync/WorkerClient.js ***!
|
|
19503
17852
|
\*********************************************/
|
|
19504
|
-
(
|
|
17853
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
19505
17854
|
|
|
19506
17855
|
__webpack_require__.r(__webpack_exports__);
|
|
19507
17856
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
19508
17857
|
/* harmony export */ WorkerClient: () => (/* binding */ WorkerClient)
|
|
19509
17858
|
/* harmony export */ });
|
|
19510
|
-
/* harmony import */ var comlink__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! comlink */ "../../node_modules/comlink/dist/esm/comlink.mjs");
|
|
19511
|
-
/* harmony import */ var
|
|
19512
|
-
/* harmony import */ var
|
|
17859
|
+
/* harmony import */ var comlink__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! comlink */ "../../node_modules/.pnpm/comlink@4.4.2/node_modules/comlink/dist/esm/comlink.mjs");
|
|
17860
|
+
/* harmony import */ var _shared_navigator_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../shared/navigator.js */ "./lib/src/shared/navigator.js");
|
|
17861
|
+
/* harmony import */ var _SharedSyncImplementation_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SharedSyncImplementation.js */ "./lib/src/worker/sync/SharedSyncImplementation.js");
|
|
19513
17862
|
|
|
19514
17863
|
|
|
19515
17864
|
|
|
@@ -19534,7 +17883,7 @@ class WorkerClient {
|
|
|
19534
17883
|
*/
|
|
19535
17884
|
this.port.addEventListener('message', async (event) => {
|
|
19536
17885
|
const payload = event.data;
|
|
19537
|
-
if (payload?.event ==
|
|
17886
|
+
if (payload?.event == _SharedSyncImplementation_js__WEBPACK_IMPORTED_MODULE_2__.SharedSyncClientEvent.CLOSE_CLIENT) {
|
|
19538
17887
|
await this.removePort();
|
|
19539
17888
|
}
|
|
19540
17889
|
});
|
|
@@ -19546,7 +17895,7 @@ class WorkerClient {
|
|
|
19546
17895
|
const release = await this.sync.removePort(resolved);
|
|
19547
17896
|
this.resolvedPort = null;
|
|
19548
17897
|
this.port.postMessage({
|
|
19549
|
-
event:
|
|
17898
|
+
event: _SharedSyncImplementation_js__WEBPACK_IMPORTED_MODULE_2__.SharedSyncClientEvent.CLOSE_ACK,
|
|
19550
17899
|
data: {}
|
|
19551
17900
|
});
|
|
19552
17901
|
release?.();
|
|
@@ -19562,7 +17911,7 @@ class WorkerClient {
|
|
|
19562
17911
|
// Only add the port once the lock has been obtained on the client.
|
|
19563
17912
|
this.resolvedPort = await this.sync.addPort(this.port);
|
|
19564
17913
|
// Don't await this lock request
|
|
19565
|
-
(0,
|
|
17914
|
+
(0,_shared_navigator_js__WEBPACK_IMPORTED_MODULE_1__.getNavigatorLocks)().request(name, async () => {
|
|
19566
17915
|
await this.removePort();
|
|
19567
17916
|
});
|
|
19568
17917
|
}
|
|
@@ -19769,18 +18118,18 @@ var __webpack_exports__ = {};
|
|
|
19769
18118
|
\****************************************************************/
|
|
19770
18119
|
__webpack_require__.r(__webpack_exports__);
|
|
19771
18120
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @powersync/common */ "../common/dist/bundle.mjs");
|
|
19772
|
-
/* harmony import */ var
|
|
19773
|
-
/* harmony import */ var
|
|
18121
|
+
/* harmony import */ var _SharedSyncImplementation_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SharedSyncImplementation.js */ "./lib/src/worker/sync/SharedSyncImplementation.js");
|
|
18122
|
+
/* harmony import */ var _WorkerClient_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./WorkerClient.js */ "./lib/src/worker/sync/WorkerClient.js");
|
|
19774
18123
|
|
|
19775
18124
|
|
|
19776
18125
|
|
|
19777
18126
|
const _self = self;
|
|
19778
18127
|
const logger = (0,_powersync_common__WEBPACK_IMPORTED_MODULE_0__.createBaseLogger)();
|
|
19779
18128
|
logger.useDefaults();
|
|
19780
|
-
const sharedSyncImplementation = new
|
|
18129
|
+
const sharedSyncImplementation = new _SharedSyncImplementation_js__WEBPACK_IMPORTED_MODULE_1__.SharedSyncImplementation();
|
|
19781
18130
|
_self.onconnect = async function (event) {
|
|
19782
18131
|
const port = event.ports[0];
|
|
19783
|
-
new
|
|
18132
|
+
new _WorkerClient_js__WEBPACK_IMPORTED_MODULE_2__.WorkerClient(sharedSyncImplementation, port);
|
|
19784
18133
|
};
|
|
19785
18134
|
|
|
19786
18135
|
})();
|