@powersync/web 0.0.0-dev-20251209082930 → 0.0.0-dev-20260120150240
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/README.md +1 -1
- package/dist/_journeyapps_wa-sqlite-_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js-_journeyapp-89f0ba.index.umd.js +1863 -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 +4554 -38361
- package/dist/index.umd.js.map +1 -1
- package/dist/worker/SharedSyncImplementation.umd.js +490 -2274
- package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
- package/dist/worker/WASQLiteDB.umd.js +436 -2206
- 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} +8 -8
- 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} +32 -32
- 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} +24 -24
- 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} +24 -24
- 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 +29 -23
- package/lib/src/db/PowerSyncDatabase.d.ts +3 -1
- package/lib/src/db/PowerSyncDatabase.js +19 -7
- 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 -9
- package/lib/src/db/adapters/AsyncDatabaseConnection.js +1 -11
- package/lib/src/db/adapters/LockedAsyncDatabaseAdapter.d.ts +3 -3
- package/lib/src/db/adapters/LockedAsyncDatabaseAdapter.js +13 -7
- package/lib/src/db/adapters/WebDBAdapter.d.ts +1 -1
- package/lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.d.ts +2 -2
- package/lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.js +1 -2
- package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.d.ts +2 -2
- package/lib/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.d.ts +3 -3
- package/lib/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.js +5 -5
- package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.d.ts +4 -4
- package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.js +6 -6
- 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 +13 -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 +22 -16
- package/src/db/PowerSyncDatabase.ts +23 -8
- package/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.ts +1 -1
- package/src/db/adapters/AbstractWebSQLOpenFactory.ts +3 -3
- package/src/db/adapters/AsyncDatabaseConnection.ts +1 -13
- package/src/db/adapters/LockedAsyncDatabaseAdapter.ts +17 -9
- package/src/db/adapters/WebDBAdapter.ts +1 -1
- package/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.ts +3 -4
- package/src/db/adapters/wa-sqlite/WASQLiteConnection.ts +2 -2
- package/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.ts +7 -7
- package/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.ts +7 -7
- 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 +17 -8
- 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,11 +3,11 @@ 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
|
-
|
|
10
|
-
|
|
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
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
11
11
|
|
|
12
12
|
__webpack_require__.r(__webpack_exports__);
|
|
13
13
|
/* harmony export */ __webpack_require__.d(__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
|
|
|
@@ -1196,13 +1196,13 @@ function decl(s) {
|
|
|
1196
1196
|
}
|
|
1197
1197
|
|
|
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
|
-
|
|
1205
|
-
|
|
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
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
1206
1206
|
|
|
1207
1207
|
__webpack_require__.r(__webpack_exports__);
|
|
1208
1208
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
@@ -1715,13 +1715,13 @@ const SQLITE_PREPARE_PERSISTENT = 0x01;
|
|
|
1715
1715
|
const SQLITE_PREPARE_NORMALIZED = 0x02;
|
|
1716
1716
|
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
|
-
|
|
1724
|
-
|
|
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
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
1725
1725
|
|
|
1726
1726
|
__webpack_require__.r(__webpack_exports__);
|
|
1727
1727
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
@@ -2026,13 +2026,13 @@ function tryAcquire(sync, alreadyAcquiredError = E_ALREADY_LOCKED) {
|
|
|
2026
2026
|
|
|
2027
2027
|
|
|
2028
2028
|
|
|
2029
|
-
/***/ }
|
|
2029
|
+
/***/ },
|
|
2030
2030
|
|
|
2031
|
-
/***/ "../../node_modules/comlink/dist/esm/comlink.mjs"
|
|
2032
|
-
|
|
2033
|
-
!*** ../../node_modules/comlink/dist/esm/comlink.mjs ***!
|
|
2034
|
-
|
|
2035
|
-
|
|
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
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
2036
2036
|
|
|
2037
2037
|
__webpack_require__.r(__webpack_exports__);
|
|
2038
2038
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
@@ -2407,13 +2407,13 @@ function generateUUID() {
|
|
|
2407
2407
|
//# sourceMappingURL=comlink.mjs.map
|
|
2408
2408
|
|
|
2409
2409
|
|
|
2410
|
-
/***/ }
|
|
2410
|
+
/***/ },
|
|
2411
2411
|
|
|
2412
|
-
/***/ "../common/dist/bundle.mjs"
|
|
2412
|
+
/***/ "../common/dist/bundle.mjs"
|
|
2413
2413
|
/*!*********************************!*\
|
|
2414
2414
|
!*** ../common/dist/bundle.mjs ***!
|
|
2415
2415
|
\*********************************/
|
|
2416
|
-
|
|
2416
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
2417
2417
|
|
|
2418
2418
|
__webpack_require__.r(__webpack_exports__);
|
|
2419
2419
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
@@ -2427,6 +2427,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2427
2427
|
/* harmony export */ BaseObserver: () => (/* binding */ BaseObserver),
|
|
2428
2428
|
/* harmony export */ Column: () => (/* binding */ Column),
|
|
2429
2429
|
/* harmony export */ ColumnType: () => (/* binding */ ColumnType),
|
|
2430
|
+
/* harmony export */ ConnectionClosedError: () => (/* binding */ ConnectionClosedError),
|
|
2430
2431
|
/* harmony export */ ConnectionManager: () => (/* binding */ ConnectionManager),
|
|
2431
2432
|
/* harmony export */ ControlledExecutor: () => (/* binding */ ControlledExecutor),
|
|
2432
2433
|
/* harmony export */ CrudBatch: () => (/* binding */ CrudBatch),
|
|
@@ -2471,6 +2472,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2471
2472
|
/* harmony export */ OplogEntry: () => (/* binding */ OplogEntry),
|
|
2472
2473
|
/* harmony export */ PSInternalTable: () => (/* binding */ PSInternalTable),
|
|
2473
2474
|
/* harmony export */ PowerSyncControlCommand: () => (/* binding */ PowerSyncControlCommand),
|
|
2475
|
+
/* harmony export */ RawTable: () => (/* binding */ RawTable),
|
|
2474
2476
|
/* harmony export */ RowUpdateType: () => (/* binding */ RowUpdateType),
|
|
2475
2477
|
/* harmony export */ Schema: () => (/* binding */ Schema),
|
|
2476
2478
|
/* harmony export */ SqliteBucketStorage: () => (/* binding */ SqliteBucketStorage),
|
|
@@ -2508,7 +2510,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2508
2510
|
/* harmony export */ sanitizeSQL: () => (/* binding */ sanitizeSQL),
|
|
2509
2511
|
/* harmony export */ sanitizeUUID: () => (/* binding */ sanitizeUUID)
|
|
2510
2512
|
/* harmony export */ });
|
|
2511
|
-
/* harmony import */ var async_mutex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! async-mutex */ "../../node_modules/async-mutex/index.mjs");
|
|
2513
|
+
/* 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");
|
|
2512
2514
|
|
|
2513
2515
|
|
|
2514
2516
|
function getDefaultExportFromCjs (x) {
|
|
@@ -3241,6 +3243,10 @@ class SyncStatus {
|
|
|
3241
3243
|
priorityStatusEntries: this.priorityStatusEntries
|
|
3242
3244
|
};
|
|
3243
3245
|
}
|
|
3246
|
+
/**
|
|
3247
|
+
* Not all errors are serializable over a MessagePort. E.g. some `DomExceptions` fail to be passed across workers.
|
|
3248
|
+
* This explicitly serializes errors in the SyncStatus.
|
|
3249
|
+
*/
|
|
3244
3250
|
serializeError(error) {
|
|
3245
3251
|
if (typeof error == 'undefined') {
|
|
3246
3252
|
return undefined;
|
|
@@ -4594,7 +4600,7 @@ class SyncDataBucket {
|
|
|
4594
4600
|
}
|
|
4595
4601
|
}
|
|
4596
4602
|
|
|
4597
|
-
var buffer
|
|
4603
|
+
var buffer = {};
|
|
4598
4604
|
|
|
4599
4605
|
var base64Js = {};
|
|
4600
4606
|
|
|
@@ -4858,12 +4864,12 @@ function requireIeee754 () {
|
|
|
4858
4864
|
* @license MIT
|
|
4859
4865
|
*/
|
|
4860
4866
|
|
|
4861
|
-
var hasRequiredBuffer
|
|
4867
|
+
var hasRequiredBuffer;
|
|
4862
4868
|
|
|
4863
|
-
function requireBuffer
|
|
4864
|
-
if (hasRequiredBuffer
|
|
4865
|
-
hasRequiredBuffer
|
|
4866
|
-
(function (exports) {
|
|
4869
|
+
function requireBuffer () {
|
|
4870
|
+
if (hasRequiredBuffer) return buffer;
|
|
4871
|
+
hasRequiredBuffer = 1;
|
|
4872
|
+
(function (exports$1) {
|
|
4867
4873
|
|
|
4868
4874
|
const base64 = requireBase64Js();
|
|
4869
4875
|
const ieee754 = requireIeee754();
|
|
@@ -4872,12 +4878,12 @@ function requireBuffer$1 () {
|
|
|
4872
4878
|
? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
|
|
4873
4879
|
: null;
|
|
4874
4880
|
|
|
4875
|
-
exports.Buffer = Buffer;
|
|
4876
|
-
exports.SlowBuffer = SlowBuffer;
|
|
4877
|
-
exports.INSPECT_MAX_BYTES = 50;
|
|
4881
|
+
exports$1.Buffer = Buffer;
|
|
4882
|
+
exports$1.SlowBuffer = SlowBuffer;
|
|
4883
|
+
exports$1.INSPECT_MAX_BYTES = 50;
|
|
4878
4884
|
|
|
4879
4885
|
const K_MAX_LENGTH = 0x7fffffff;
|
|
4880
|
-
exports.kMaxLength = K_MAX_LENGTH;
|
|
4886
|
+
exports$1.kMaxLength = K_MAX_LENGTH;
|
|
4881
4887
|
|
|
4882
4888
|
/**
|
|
4883
4889
|
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
@@ -5473,7 +5479,7 @@ function requireBuffer$1 () {
|
|
|
5473
5479
|
|
|
5474
5480
|
Buffer.prototype.inspect = function inspect () {
|
|
5475
5481
|
let str = '';
|
|
5476
|
-
const max = exports.INSPECT_MAX_BYTES;
|
|
5482
|
+
const max = exports$1.INSPECT_MAX_BYTES;
|
|
5477
5483
|
str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
|
|
5478
5484
|
if (this.length > max) str += ' ... ';
|
|
5479
5485
|
return '<Buffer ' + str + '>'
|
|
@@ -6390,2006 +6396,26 @@ function requireBuffer$1 () {
|
|
|
6390
6396
|
return offset + 8
|
|
6391
6397
|
}
|
|
6392
6398
|
|
|
6393
|
-
Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {
|
|
6394
|
-
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
|
|
6395
|
-
});
|
|
6396
|
-
|
|
6397
|
-
Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {
|
|
6398
|
-
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
|
|
6399
|
-
});
|
|
6400
|
-
|
|
6401
|
-
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
|
6402
|
-
value = +value;
|
|
6403
|
-
offset = offset >>> 0;
|
|
6404
|
-
if (!noAssert) {
|
|
6405
|
-
const limit = Math.pow(2, (8 * byteLength) - 1);
|
|
6406
|
-
|
|
6407
|
-
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
6408
|
-
}
|
|
6409
|
-
|
|
6410
|
-
let i = 0;
|
|
6411
|
-
let mul = 1;
|
|
6412
|
-
let sub = 0;
|
|
6413
|
-
this[offset] = value & 0xFF;
|
|
6414
|
-
while (++i < byteLength && (mul *= 0x100)) {
|
|
6415
|
-
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
6416
|
-
sub = 1;
|
|
6417
|
-
}
|
|
6418
|
-
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
|
|
6419
|
-
}
|
|
6420
|
-
|
|
6421
|
-
return offset + byteLength
|
|
6422
|
-
};
|
|
6423
|
-
|
|
6424
|
-
Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
|
|
6425
|
-
value = +value;
|
|
6426
|
-
offset = offset >>> 0;
|
|
6427
|
-
if (!noAssert) {
|
|
6428
|
-
const limit = Math.pow(2, (8 * byteLength) - 1);
|
|
6429
|
-
|
|
6430
|
-
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
6431
|
-
}
|
|
6432
|
-
|
|
6433
|
-
let i = byteLength - 1;
|
|
6434
|
-
let mul = 1;
|
|
6435
|
-
let sub = 0;
|
|
6436
|
-
this[offset + i] = value & 0xFF;
|
|
6437
|
-
while (--i >= 0 && (mul *= 0x100)) {
|
|
6438
|
-
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
6439
|
-
sub = 1;
|
|
6440
|
-
}
|
|
6441
|
-
this[offset + i] = ((value / mul) >> 0) - sub & 0xFF;
|
|
6442
|
-
}
|
|
6443
|
-
|
|
6444
|
-
return offset + byteLength
|
|
6445
|
-
};
|
|
6446
|
-
|
|
6447
|
-
Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
|
|
6448
|
-
value = +value;
|
|
6449
|
-
offset = offset >>> 0;
|
|
6450
|
-
if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -128);
|
|
6451
|
-
if (value < 0) value = 0xff + value + 1;
|
|
6452
|
-
this[offset] = (value & 0xff);
|
|
6453
|
-
return offset + 1
|
|
6454
|
-
};
|
|
6455
|
-
|
|
6456
|
-
Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
|
|
6457
|
-
value = +value;
|
|
6458
|
-
offset = offset >>> 0;
|
|
6459
|
-
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
|
|
6460
|
-
this[offset] = (value & 0xff);
|
|
6461
|
-
this[offset + 1] = (value >>> 8);
|
|
6462
|
-
return offset + 2
|
|
6463
|
-
};
|
|
6464
|
-
|
|
6465
|
-
Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
|
|
6466
|
-
value = +value;
|
|
6467
|
-
offset = offset >>> 0;
|
|
6468
|
-
if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -32768);
|
|
6469
|
-
this[offset] = (value >>> 8);
|
|
6470
|
-
this[offset + 1] = (value & 0xff);
|
|
6471
|
-
return offset + 2
|
|
6472
|
-
};
|
|
6473
|
-
|
|
6474
|
-
Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
|
|
6475
|
-
value = +value;
|
|
6476
|
-
offset = offset >>> 0;
|
|
6477
|
-
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
|
|
6478
|
-
this[offset] = (value & 0xff);
|
|
6479
|
-
this[offset + 1] = (value >>> 8);
|
|
6480
|
-
this[offset + 2] = (value >>> 16);
|
|
6481
|
-
this[offset + 3] = (value >>> 24);
|
|
6482
|
-
return offset + 4
|
|
6483
|
-
};
|
|
6484
|
-
|
|
6485
|
-
Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
|
|
6486
|
-
value = +value;
|
|
6487
|
-
offset = offset >>> 0;
|
|
6488
|
-
if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);
|
|
6489
|
-
if (value < 0) value = 0xffffffff + value + 1;
|
|
6490
|
-
this[offset] = (value >>> 24);
|
|
6491
|
-
this[offset + 1] = (value >>> 16);
|
|
6492
|
-
this[offset + 2] = (value >>> 8);
|
|
6493
|
-
this[offset + 3] = (value & 0xff);
|
|
6494
|
-
return offset + 4
|
|
6495
|
-
};
|
|
6496
|
-
|
|
6497
|
-
Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {
|
|
6498
|
-
return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
|
|
6499
|
-
});
|
|
6500
|
-
|
|
6501
|
-
Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {
|
|
6502
|
-
return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
|
|
6503
|
-
});
|
|
6504
|
-
|
|
6505
|
-
function checkIEEE754 (buf, value, offset, ext, max, min) {
|
|
6506
|
-
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
6507
|
-
if (offset < 0) throw new RangeError('Index out of range')
|
|
6508
|
-
}
|
|
6509
|
-
|
|
6510
|
-
function writeFloat (buf, value, offset, littleEndian, noAssert) {
|
|
6511
|
-
value = +value;
|
|
6512
|
-
offset = offset >>> 0;
|
|
6513
|
-
if (!noAssert) {
|
|
6514
|
-
checkIEEE754(buf, value, offset, 4);
|
|
6515
|
-
}
|
|
6516
|
-
ieee754.write(buf, value, offset, littleEndian, 23, 4);
|
|
6517
|
-
return offset + 4
|
|
6518
|
-
}
|
|
6519
|
-
|
|
6520
|
-
Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
|
|
6521
|
-
return writeFloat(this, value, offset, true, noAssert)
|
|
6522
|
-
};
|
|
6523
|
-
|
|
6524
|
-
Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
|
|
6525
|
-
return writeFloat(this, value, offset, false, noAssert)
|
|
6526
|
-
};
|
|
6527
|
-
|
|
6528
|
-
function writeDouble (buf, value, offset, littleEndian, noAssert) {
|
|
6529
|
-
value = +value;
|
|
6530
|
-
offset = offset >>> 0;
|
|
6531
|
-
if (!noAssert) {
|
|
6532
|
-
checkIEEE754(buf, value, offset, 8);
|
|
6533
|
-
}
|
|
6534
|
-
ieee754.write(buf, value, offset, littleEndian, 52, 8);
|
|
6535
|
-
return offset + 8
|
|
6536
|
-
}
|
|
6537
|
-
|
|
6538
|
-
Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
|
|
6539
|
-
return writeDouble(this, value, offset, true, noAssert)
|
|
6540
|
-
};
|
|
6541
|
-
|
|
6542
|
-
Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
|
|
6543
|
-
return writeDouble(this, value, offset, false, noAssert)
|
|
6544
|
-
};
|
|
6545
|
-
|
|
6546
|
-
// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
|
|
6547
|
-
Buffer.prototype.copy = function copy (target, targetStart, start, end) {
|
|
6548
|
-
if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')
|
|
6549
|
-
if (!start) start = 0;
|
|
6550
|
-
if (!end && end !== 0) end = this.length;
|
|
6551
|
-
if (targetStart >= target.length) targetStart = target.length;
|
|
6552
|
-
if (!targetStart) targetStart = 0;
|
|
6553
|
-
if (end > 0 && end < start) end = start;
|
|
6554
|
-
|
|
6555
|
-
// Copy 0 bytes; we're done
|
|
6556
|
-
if (end === start) return 0
|
|
6557
|
-
if (target.length === 0 || this.length === 0) return 0
|
|
6558
|
-
|
|
6559
|
-
// Fatal error conditions
|
|
6560
|
-
if (targetStart < 0) {
|
|
6561
|
-
throw new RangeError('targetStart out of bounds')
|
|
6562
|
-
}
|
|
6563
|
-
if (start < 0 || start >= this.length) throw new RangeError('Index out of range')
|
|
6564
|
-
if (end < 0) throw new RangeError('sourceEnd out of bounds')
|
|
6565
|
-
|
|
6566
|
-
// Are we oob?
|
|
6567
|
-
if (end > this.length) end = this.length;
|
|
6568
|
-
if (target.length - targetStart < end - start) {
|
|
6569
|
-
end = target.length - targetStart + start;
|
|
6570
|
-
}
|
|
6571
|
-
|
|
6572
|
-
const len = end - start;
|
|
6573
|
-
|
|
6574
|
-
if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
|
|
6575
|
-
// Use built-in when available, missing from IE11
|
|
6576
|
-
this.copyWithin(targetStart, start, end);
|
|
6577
|
-
} else {
|
|
6578
|
-
Uint8Array.prototype.set.call(
|
|
6579
|
-
target,
|
|
6580
|
-
this.subarray(start, end),
|
|
6581
|
-
targetStart
|
|
6582
|
-
);
|
|
6583
|
-
}
|
|
6584
|
-
|
|
6585
|
-
return len
|
|
6586
|
-
};
|
|
6587
|
-
|
|
6588
|
-
// Usage:
|
|
6589
|
-
// buffer.fill(number[, offset[, end]])
|
|
6590
|
-
// buffer.fill(buffer[, offset[, end]])
|
|
6591
|
-
// buffer.fill(string[, offset[, end]][, encoding])
|
|
6592
|
-
Buffer.prototype.fill = function fill (val, start, end, encoding) {
|
|
6593
|
-
// Handle string cases:
|
|
6594
|
-
if (typeof val === 'string') {
|
|
6595
|
-
if (typeof start === 'string') {
|
|
6596
|
-
encoding = start;
|
|
6597
|
-
start = 0;
|
|
6598
|
-
end = this.length;
|
|
6599
|
-
} else if (typeof end === 'string') {
|
|
6600
|
-
encoding = end;
|
|
6601
|
-
end = this.length;
|
|
6602
|
-
}
|
|
6603
|
-
if (encoding !== undefined && typeof encoding !== 'string') {
|
|
6604
|
-
throw new TypeError('encoding must be a string')
|
|
6605
|
-
}
|
|
6606
|
-
if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
|
|
6607
|
-
throw new TypeError('Unknown encoding: ' + encoding)
|
|
6608
|
-
}
|
|
6609
|
-
if (val.length === 1) {
|
|
6610
|
-
const code = val.charCodeAt(0);
|
|
6611
|
-
if ((encoding === 'utf8' && code < 128) ||
|
|
6612
|
-
encoding === 'latin1') {
|
|
6613
|
-
// Fast path: If `val` fits into a single byte, use that numeric value.
|
|
6614
|
-
val = code;
|
|
6615
|
-
}
|
|
6616
|
-
}
|
|
6617
|
-
} else if (typeof val === 'number') {
|
|
6618
|
-
val = val & 255;
|
|
6619
|
-
} else if (typeof val === 'boolean') {
|
|
6620
|
-
val = Number(val);
|
|
6621
|
-
}
|
|
6622
|
-
|
|
6623
|
-
// Invalid ranges are not set to a default, so can range check early.
|
|
6624
|
-
if (start < 0 || this.length < start || this.length < end) {
|
|
6625
|
-
throw new RangeError('Out of range index')
|
|
6626
|
-
}
|
|
6627
|
-
|
|
6628
|
-
if (end <= start) {
|
|
6629
|
-
return this
|
|
6630
|
-
}
|
|
6631
|
-
|
|
6632
|
-
start = start >>> 0;
|
|
6633
|
-
end = end === undefined ? this.length : end >>> 0;
|
|
6634
|
-
|
|
6635
|
-
if (!val) val = 0;
|
|
6636
|
-
|
|
6637
|
-
let i;
|
|
6638
|
-
if (typeof val === 'number') {
|
|
6639
|
-
for (i = start; i < end; ++i) {
|
|
6640
|
-
this[i] = val;
|
|
6641
|
-
}
|
|
6642
|
-
} else {
|
|
6643
|
-
const bytes = Buffer.isBuffer(val)
|
|
6644
|
-
? val
|
|
6645
|
-
: Buffer.from(val, encoding);
|
|
6646
|
-
const len = bytes.length;
|
|
6647
|
-
if (len === 0) {
|
|
6648
|
-
throw new TypeError('The value "' + val +
|
|
6649
|
-
'" is invalid for argument "value"')
|
|
6650
|
-
}
|
|
6651
|
-
for (i = 0; i < end - start; ++i) {
|
|
6652
|
-
this[i + start] = bytes[i % len];
|
|
6653
|
-
}
|
|
6654
|
-
}
|
|
6655
|
-
|
|
6656
|
-
return this
|
|
6657
|
-
};
|
|
6658
|
-
|
|
6659
|
-
// CUSTOM ERRORS
|
|
6660
|
-
// =============
|
|
6661
|
-
|
|
6662
|
-
// Simplified versions from Node, changed for Buffer-only usage
|
|
6663
|
-
const errors = {};
|
|
6664
|
-
function E (sym, getMessage, Base) {
|
|
6665
|
-
errors[sym] = class NodeError extends Base {
|
|
6666
|
-
constructor () {
|
|
6667
|
-
super();
|
|
6668
|
-
|
|
6669
|
-
Object.defineProperty(this, 'message', {
|
|
6670
|
-
value: getMessage.apply(this, arguments),
|
|
6671
|
-
writable: true,
|
|
6672
|
-
configurable: true
|
|
6673
|
-
});
|
|
6674
|
-
|
|
6675
|
-
// Add the error code to the name to include it in the stack trace.
|
|
6676
|
-
this.name = `${this.name} [${sym}]`;
|
|
6677
|
-
// Access the stack to generate the error message including the error code
|
|
6678
|
-
// from the name.
|
|
6679
|
-
this.stack; // eslint-disable-line no-unused-expressions
|
|
6680
|
-
// Reset the name to the actual name.
|
|
6681
|
-
delete this.name;
|
|
6682
|
-
}
|
|
6683
|
-
|
|
6684
|
-
get code () {
|
|
6685
|
-
return sym
|
|
6686
|
-
}
|
|
6687
|
-
|
|
6688
|
-
set code (value) {
|
|
6689
|
-
Object.defineProperty(this, 'code', {
|
|
6690
|
-
configurable: true,
|
|
6691
|
-
enumerable: true,
|
|
6692
|
-
value,
|
|
6693
|
-
writable: true
|
|
6694
|
-
});
|
|
6695
|
-
}
|
|
6696
|
-
|
|
6697
|
-
toString () {
|
|
6698
|
-
return `${this.name} [${sym}]: ${this.message}`
|
|
6699
|
-
}
|
|
6700
|
-
};
|
|
6701
|
-
}
|
|
6702
|
-
|
|
6703
|
-
E('ERR_BUFFER_OUT_OF_BOUNDS',
|
|
6704
|
-
function (name) {
|
|
6705
|
-
if (name) {
|
|
6706
|
-
return `${name} is outside of buffer bounds`
|
|
6707
|
-
}
|
|
6708
|
-
|
|
6709
|
-
return 'Attempt to access memory outside buffer bounds'
|
|
6710
|
-
}, RangeError);
|
|
6711
|
-
E('ERR_INVALID_ARG_TYPE',
|
|
6712
|
-
function (name, actual) {
|
|
6713
|
-
return `The "${name}" argument must be of type number. Received type ${typeof actual}`
|
|
6714
|
-
}, TypeError);
|
|
6715
|
-
E('ERR_OUT_OF_RANGE',
|
|
6716
|
-
function (str, range, input) {
|
|
6717
|
-
let msg = `The value of "${str}" is out of range.`;
|
|
6718
|
-
let received = input;
|
|
6719
|
-
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
|
|
6720
|
-
received = addNumericalSeparator(String(input));
|
|
6721
|
-
} else if (typeof input === 'bigint') {
|
|
6722
|
-
received = String(input);
|
|
6723
|
-
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
|
|
6724
|
-
received = addNumericalSeparator(received);
|
|
6725
|
-
}
|
|
6726
|
-
received += 'n';
|
|
6727
|
-
}
|
|
6728
|
-
msg += ` It must be ${range}. Received ${received}`;
|
|
6729
|
-
return msg
|
|
6730
|
-
}, RangeError);
|
|
6731
|
-
|
|
6732
|
-
function addNumericalSeparator (val) {
|
|
6733
|
-
let res = '';
|
|
6734
|
-
let i = val.length;
|
|
6735
|
-
const start = val[0] === '-' ? 1 : 0;
|
|
6736
|
-
for (; i >= start + 4; i -= 3) {
|
|
6737
|
-
res = `_${val.slice(i - 3, i)}${res}`;
|
|
6738
|
-
}
|
|
6739
|
-
return `${val.slice(0, i)}${res}`
|
|
6740
|
-
}
|
|
6741
|
-
|
|
6742
|
-
// CHECK FUNCTIONS
|
|
6743
|
-
// ===============
|
|
6744
|
-
|
|
6745
|
-
function checkBounds (buf, offset, byteLength) {
|
|
6746
|
-
validateNumber(offset, 'offset');
|
|
6747
|
-
if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
|
|
6748
|
-
boundsError(offset, buf.length - (byteLength + 1));
|
|
6749
|
-
}
|
|
6750
|
-
}
|
|
6751
|
-
|
|
6752
|
-
function checkIntBI (value, min, max, buf, offset, byteLength) {
|
|
6753
|
-
if (value > max || value < min) {
|
|
6754
|
-
const n = typeof min === 'bigint' ? 'n' : '';
|
|
6755
|
-
let range;
|
|
6756
|
-
{
|
|
6757
|
-
if (min === 0 || min === BigInt(0)) {
|
|
6758
|
-
range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
|
|
6759
|
-
} else {
|
|
6760
|
-
range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
|
|
6761
|
-
`${(byteLength + 1) * 8 - 1}${n}`;
|
|
6762
|
-
}
|
|
6763
|
-
}
|
|
6764
|
-
throw new errors.ERR_OUT_OF_RANGE('value', range, value)
|
|
6765
|
-
}
|
|
6766
|
-
checkBounds(buf, offset, byteLength);
|
|
6767
|
-
}
|
|
6768
|
-
|
|
6769
|
-
function validateNumber (value, name) {
|
|
6770
|
-
if (typeof value !== 'number') {
|
|
6771
|
-
throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
|
|
6772
|
-
}
|
|
6773
|
-
}
|
|
6774
|
-
|
|
6775
|
-
function boundsError (value, length, type) {
|
|
6776
|
-
if (Math.floor(value) !== value) {
|
|
6777
|
-
validateNumber(value, type);
|
|
6778
|
-
throw new errors.ERR_OUT_OF_RANGE('offset', 'an integer', value)
|
|
6779
|
-
}
|
|
6780
|
-
|
|
6781
|
-
if (length < 0) {
|
|
6782
|
-
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
|
|
6783
|
-
}
|
|
6784
|
-
|
|
6785
|
-
throw new errors.ERR_OUT_OF_RANGE('offset',
|
|
6786
|
-
`>= ${0} and <= ${length}`,
|
|
6787
|
-
value)
|
|
6788
|
-
}
|
|
6789
|
-
|
|
6790
|
-
// HELPER FUNCTIONS
|
|
6791
|
-
// ================
|
|
6792
|
-
|
|
6793
|
-
const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
|
|
6794
|
-
|
|
6795
|
-
function base64clean (str) {
|
|
6796
|
-
// Node takes equal signs as end of the Base64 encoding
|
|
6797
|
-
str = str.split('=')[0];
|
|
6798
|
-
// Node strips out invalid characters like \n and \t from the string, base64-js does not
|
|
6799
|
-
str = str.trim().replace(INVALID_BASE64_RE, '');
|
|
6800
|
-
// Node converts strings with length < 2 to ''
|
|
6801
|
-
if (str.length < 2) return ''
|
|
6802
|
-
// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
|
|
6803
|
-
while (str.length % 4 !== 0) {
|
|
6804
|
-
str = str + '=';
|
|
6805
|
-
}
|
|
6806
|
-
return str
|
|
6807
|
-
}
|
|
6808
|
-
|
|
6809
|
-
function utf8ToBytes (string, units) {
|
|
6810
|
-
units = units || Infinity;
|
|
6811
|
-
let codePoint;
|
|
6812
|
-
const length = string.length;
|
|
6813
|
-
let leadSurrogate = null;
|
|
6814
|
-
const bytes = [];
|
|
6815
|
-
|
|
6816
|
-
for (let i = 0; i < length; ++i) {
|
|
6817
|
-
codePoint = string.charCodeAt(i);
|
|
6818
|
-
|
|
6819
|
-
// is surrogate component
|
|
6820
|
-
if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
|
6821
|
-
// last char was a lead
|
|
6822
|
-
if (!leadSurrogate) {
|
|
6823
|
-
// no lead yet
|
|
6824
|
-
if (codePoint > 0xDBFF) {
|
|
6825
|
-
// unexpected trail
|
|
6826
|
-
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
6827
|
-
continue
|
|
6828
|
-
} else if (i + 1 === length) {
|
|
6829
|
-
// unpaired lead
|
|
6830
|
-
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
6831
|
-
continue
|
|
6832
|
-
}
|
|
6833
|
-
|
|
6834
|
-
// valid lead
|
|
6835
|
-
leadSurrogate = codePoint;
|
|
6836
|
-
|
|
6837
|
-
continue
|
|
6838
|
-
}
|
|
6839
|
-
|
|
6840
|
-
// 2 leads in a row
|
|
6841
|
-
if (codePoint < 0xDC00) {
|
|
6842
|
-
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
6843
|
-
leadSurrogate = codePoint;
|
|
6844
|
-
continue
|
|
6845
|
-
}
|
|
6846
|
-
|
|
6847
|
-
// valid surrogate pair
|
|
6848
|
-
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
|
|
6849
|
-
} else if (leadSurrogate) {
|
|
6850
|
-
// valid bmp char, but last char was a lead
|
|
6851
|
-
if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);
|
|
6852
|
-
}
|
|
6853
|
-
|
|
6854
|
-
leadSurrogate = null;
|
|
6855
|
-
|
|
6856
|
-
// encode utf8
|
|
6857
|
-
if (codePoint < 0x80) {
|
|
6858
|
-
if ((units -= 1) < 0) break
|
|
6859
|
-
bytes.push(codePoint);
|
|
6860
|
-
} else if (codePoint < 0x800) {
|
|
6861
|
-
if ((units -= 2) < 0) break
|
|
6862
|
-
bytes.push(
|
|
6863
|
-
codePoint >> 0x6 | 0xC0,
|
|
6864
|
-
codePoint & 0x3F | 0x80
|
|
6865
|
-
);
|
|
6866
|
-
} else if (codePoint < 0x10000) {
|
|
6867
|
-
if ((units -= 3) < 0) break
|
|
6868
|
-
bytes.push(
|
|
6869
|
-
codePoint >> 0xC | 0xE0,
|
|
6870
|
-
codePoint >> 0x6 & 0x3F | 0x80,
|
|
6871
|
-
codePoint & 0x3F | 0x80
|
|
6872
|
-
);
|
|
6873
|
-
} else if (codePoint < 0x110000) {
|
|
6874
|
-
if ((units -= 4) < 0) break
|
|
6875
|
-
bytes.push(
|
|
6876
|
-
codePoint >> 0x12 | 0xF0,
|
|
6877
|
-
codePoint >> 0xC & 0x3F | 0x80,
|
|
6878
|
-
codePoint >> 0x6 & 0x3F | 0x80,
|
|
6879
|
-
codePoint & 0x3F | 0x80
|
|
6880
|
-
);
|
|
6881
|
-
} else {
|
|
6882
|
-
throw new Error('Invalid code point')
|
|
6883
|
-
}
|
|
6884
|
-
}
|
|
6885
|
-
|
|
6886
|
-
return bytes
|
|
6887
|
-
}
|
|
6888
|
-
|
|
6889
|
-
function asciiToBytes (str) {
|
|
6890
|
-
const byteArray = [];
|
|
6891
|
-
for (let i = 0; i < str.length; ++i) {
|
|
6892
|
-
// Node's code seems to be doing this and not & 0x7F..
|
|
6893
|
-
byteArray.push(str.charCodeAt(i) & 0xFF);
|
|
6894
|
-
}
|
|
6895
|
-
return byteArray
|
|
6896
|
-
}
|
|
6897
|
-
|
|
6898
|
-
function utf16leToBytes (str, units) {
|
|
6899
|
-
let c, hi, lo;
|
|
6900
|
-
const byteArray = [];
|
|
6901
|
-
for (let i = 0; i < str.length; ++i) {
|
|
6902
|
-
if ((units -= 2) < 0) break
|
|
6903
|
-
|
|
6904
|
-
c = str.charCodeAt(i);
|
|
6905
|
-
hi = c >> 8;
|
|
6906
|
-
lo = c % 256;
|
|
6907
|
-
byteArray.push(lo);
|
|
6908
|
-
byteArray.push(hi);
|
|
6909
|
-
}
|
|
6910
|
-
|
|
6911
|
-
return byteArray
|
|
6912
|
-
}
|
|
6913
|
-
|
|
6914
|
-
function base64ToBytes (str) {
|
|
6915
|
-
return base64.toByteArray(base64clean(str))
|
|
6916
|
-
}
|
|
6917
|
-
|
|
6918
|
-
function blitBuffer (src, dst, offset, length) {
|
|
6919
|
-
let i;
|
|
6920
|
-
for (i = 0; i < length; ++i) {
|
|
6921
|
-
if ((i + offset >= dst.length) || (i >= src.length)) break
|
|
6922
|
-
dst[i + offset] = src[i];
|
|
6923
|
-
}
|
|
6924
|
-
return i
|
|
6925
|
-
}
|
|
6926
|
-
|
|
6927
|
-
// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
|
|
6928
|
-
// the `instanceof` check but they should be treated as of that type.
|
|
6929
|
-
// See: https://github.com/feross/buffer/issues/166
|
|
6930
|
-
function isInstance (obj, type) {
|
|
6931
|
-
return obj instanceof type ||
|
|
6932
|
-
(obj != null && obj.constructor != null && obj.constructor.name != null &&
|
|
6933
|
-
obj.constructor.name === type.name)
|
|
6934
|
-
}
|
|
6935
|
-
function numberIsNaN (obj) {
|
|
6936
|
-
// For IE11 support
|
|
6937
|
-
return obj !== obj // eslint-disable-line no-self-compare
|
|
6938
|
-
}
|
|
6939
|
-
|
|
6940
|
-
// Create lookup table for `toString('hex')`
|
|
6941
|
-
// See: https://github.com/feross/buffer/issues/219
|
|
6942
|
-
const hexSliceLookupTable = (function () {
|
|
6943
|
-
const alphabet = '0123456789abcdef';
|
|
6944
|
-
const table = new Array(256);
|
|
6945
|
-
for (let i = 0; i < 16; ++i) {
|
|
6946
|
-
const i16 = i * 16;
|
|
6947
|
-
for (let j = 0; j < 16; ++j) {
|
|
6948
|
-
table[i16 + j] = alphabet[i] + alphabet[j];
|
|
6949
|
-
}
|
|
6950
|
-
}
|
|
6951
|
-
return table
|
|
6952
|
-
})();
|
|
6953
|
-
|
|
6954
|
-
// Return not function with Error if BigInt not supported
|
|
6955
|
-
function defineBigIntMethod (fn) {
|
|
6956
|
-
return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
|
|
6957
|
-
}
|
|
6958
|
-
|
|
6959
|
-
function BufferBigIntNotDefined () {
|
|
6960
|
-
throw new Error('BigInt not supported')
|
|
6961
|
-
}
|
|
6962
|
-
} (buffer$1));
|
|
6963
|
-
return buffer$1;
|
|
6964
|
-
}
|
|
6965
|
-
|
|
6966
|
-
var bufferExports$1 = requireBuffer$1();
|
|
6967
|
-
|
|
6968
|
-
var dist = {};
|
|
6969
|
-
|
|
6970
|
-
var buffer = {};
|
|
6971
|
-
|
|
6972
|
-
/*!
|
|
6973
|
-
* The buffer module from node.js, for the browser.
|
|
6974
|
-
*
|
|
6975
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
6976
|
-
* @license MIT
|
|
6977
|
-
*/
|
|
6978
|
-
|
|
6979
|
-
var hasRequiredBuffer;
|
|
6980
|
-
|
|
6981
|
-
function requireBuffer () {
|
|
6982
|
-
if (hasRequiredBuffer) return buffer;
|
|
6983
|
-
hasRequiredBuffer = 1;
|
|
6984
|
-
(function (exports) {
|
|
6985
|
-
|
|
6986
|
-
var base64 = requireBase64Js();
|
|
6987
|
-
var ieee754 = requireIeee754();
|
|
6988
|
-
var customInspectSymbol =
|
|
6989
|
-
(typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation
|
|
6990
|
-
? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
|
|
6991
|
-
: null;
|
|
6992
|
-
|
|
6993
|
-
exports.Buffer = Buffer;
|
|
6994
|
-
exports.SlowBuffer = SlowBuffer;
|
|
6995
|
-
exports.INSPECT_MAX_BYTES = 50;
|
|
6996
|
-
|
|
6997
|
-
var K_MAX_LENGTH = 0x7fffffff;
|
|
6998
|
-
exports.kMaxLength = K_MAX_LENGTH;
|
|
6999
|
-
|
|
7000
|
-
/**
|
|
7001
|
-
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
7002
|
-
* === true Use Uint8Array implementation (fastest)
|
|
7003
|
-
* === false Print warning and recommend using `buffer` v4.x which has an Object
|
|
7004
|
-
* implementation (most compatible, even IE6)
|
|
7005
|
-
*
|
|
7006
|
-
* Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
|
|
7007
|
-
* Opera 11.6+, iOS 4.2+.
|
|
7008
|
-
*
|
|
7009
|
-
* We report that the browser does not support typed arrays if the are not subclassable
|
|
7010
|
-
* using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
|
|
7011
|
-
* (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
|
|
7012
|
-
* for __proto__ and has a buggy typed array implementation.
|
|
7013
|
-
*/
|
|
7014
|
-
Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
|
|
7015
|
-
|
|
7016
|
-
if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&
|
|
7017
|
-
typeof console.error === 'function') {
|
|
7018
|
-
console.error(
|
|
7019
|
-
'This browser lacks typed array (Uint8Array) support which is required by ' +
|
|
7020
|
-
'`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
|
|
7021
|
-
);
|
|
7022
|
-
}
|
|
7023
|
-
|
|
7024
|
-
function typedArraySupport () {
|
|
7025
|
-
// Can typed array instances can be augmented?
|
|
7026
|
-
try {
|
|
7027
|
-
var arr = new Uint8Array(1);
|
|
7028
|
-
var proto = { foo: function () { return 42 } };
|
|
7029
|
-
Object.setPrototypeOf(proto, Uint8Array.prototype);
|
|
7030
|
-
Object.setPrototypeOf(arr, proto);
|
|
7031
|
-
return arr.foo() === 42
|
|
7032
|
-
} catch (e) {
|
|
7033
|
-
return false
|
|
7034
|
-
}
|
|
7035
|
-
}
|
|
7036
|
-
|
|
7037
|
-
Object.defineProperty(Buffer.prototype, 'parent', {
|
|
7038
|
-
enumerable: true,
|
|
7039
|
-
get: function () {
|
|
7040
|
-
if (!Buffer.isBuffer(this)) return undefined
|
|
7041
|
-
return this.buffer
|
|
7042
|
-
}
|
|
7043
|
-
});
|
|
7044
|
-
|
|
7045
|
-
Object.defineProperty(Buffer.prototype, 'offset', {
|
|
7046
|
-
enumerable: true,
|
|
7047
|
-
get: function () {
|
|
7048
|
-
if (!Buffer.isBuffer(this)) return undefined
|
|
7049
|
-
return this.byteOffset
|
|
7050
|
-
}
|
|
7051
|
-
});
|
|
7052
|
-
|
|
7053
|
-
function createBuffer (length) {
|
|
7054
|
-
if (length > K_MAX_LENGTH) {
|
|
7055
|
-
throw new RangeError('The value "' + length + '" is invalid for option "size"')
|
|
7056
|
-
}
|
|
7057
|
-
// Return an augmented `Uint8Array` instance
|
|
7058
|
-
var buf = new Uint8Array(length);
|
|
7059
|
-
Object.setPrototypeOf(buf, Buffer.prototype);
|
|
7060
|
-
return buf
|
|
7061
|
-
}
|
|
7062
|
-
|
|
7063
|
-
/**
|
|
7064
|
-
* The Buffer constructor returns instances of `Uint8Array` that have their
|
|
7065
|
-
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
|
|
7066
|
-
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
|
|
7067
|
-
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
|
|
7068
|
-
* returns a single octet.
|
|
7069
|
-
*
|
|
7070
|
-
* The `Uint8Array` prototype remains unmodified.
|
|
7071
|
-
*/
|
|
7072
|
-
|
|
7073
|
-
function Buffer (arg, encodingOrOffset, length) {
|
|
7074
|
-
// Common case.
|
|
7075
|
-
if (typeof arg === 'number') {
|
|
7076
|
-
if (typeof encodingOrOffset === 'string') {
|
|
7077
|
-
throw new TypeError(
|
|
7078
|
-
'The "string" argument must be of type string. Received type number'
|
|
7079
|
-
)
|
|
7080
|
-
}
|
|
7081
|
-
return allocUnsafe(arg)
|
|
7082
|
-
}
|
|
7083
|
-
return from(arg, encodingOrOffset, length)
|
|
7084
|
-
}
|
|
7085
|
-
|
|
7086
|
-
Buffer.poolSize = 8192; // not used by this implementation
|
|
7087
|
-
|
|
7088
|
-
function from (value, encodingOrOffset, length) {
|
|
7089
|
-
if (typeof value === 'string') {
|
|
7090
|
-
return fromString(value, encodingOrOffset)
|
|
7091
|
-
}
|
|
7092
|
-
|
|
7093
|
-
if (ArrayBuffer.isView(value)) {
|
|
7094
|
-
return fromArrayView(value)
|
|
7095
|
-
}
|
|
7096
|
-
|
|
7097
|
-
if (value == null) {
|
|
7098
|
-
throw new TypeError(
|
|
7099
|
-
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
|
7100
|
-
'or Array-like Object. Received type ' + (typeof value)
|
|
7101
|
-
)
|
|
7102
|
-
}
|
|
7103
|
-
|
|
7104
|
-
if (isInstance(value, ArrayBuffer) ||
|
|
7105
|
-
(value && isInstance(value.buffer, ArrayBuffer))) {
|
|
7106
|
-
return fromArrayBuffer(value, encodingOrOffset, length)
|
|
7107
|
-
}
|
|
7108
|
-
|
|
7109
|
-
if (typeof SharedArrayBuffer !== 'undefined' &&
|
|
7110
|
-
(isInstance(value, SharedArrayBuffer) ||
|
|
7111
|
-
(value && isInstance(value.buffer, SharedArrayBuffer)))) {
|
|
7112
|
-
return fromArrayBuffer(value, encodingOrOffset, length)
|
|
7113
|
-
}
|
|
7114
|
-
|
|
7115
|
-
if (typeof value === 'number') {
|
|
7116
|
-
throw new TypeError(
|
|
7117
|
-
'The "value" argument must not be of type number. Received type number'
|
|
7118
|
-
)
|
|
7119
|
-
}
|
|
7120
|
-
|
|
7121
|
-
var valueOf = value.valueOf && value.valueOf();
|
|
7122
|
-
if (valueOf != null && valueOf !== value) {
|
|
7123
|
-
return Buffer.from(valueOf, encodingOrOffset, length)
|
|
7124
|
-
}
|
|
7125
|
-
|
|
7126
|
-
var b = fromObject(value);
|
|
7127
|
-
if (b) return b
|
|
7128
|
-
|
|
7129
|
-
if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&
|
|
7130
|
-
typeof value[Symbol.toPrimitive] === 'function') {
|
|
7131
|
-
return Buffer.from(
|
|
7132
|
-
value[Symbol.toPrimitive]('string'), encodingOrOffset, length
|
|
7133
|
-
)
|
|
7134
|
-
}
|
|
7135
|
-
|
|
7136
|
-
throw new TypeError(
|
|
7137
|
-
'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +
|
|
7138
|
-
'or Array-like Object. Received type ' + (typeof value)
|
|
7139
|
-
)
|
|
7140
|
-
}
|
|
7141
|
-
|
|
7142
|
-
/**
|
|
7143
|
-
* Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
|
|
7144
|
-
* if value is a number.
|
|
7145
|
-
* Buffer.from(str[, encoding])
|
|
7146
|
-
* Buffer.from(array)
|
|
7147
|
-
* Buffer.from(buffer)
|
|
7148
|
-
* Buffer.from(arrayBuffer[, byteOffset[, length]])
|
|
7149
|
-
**/
|
|
7150
|
-
Buffer.from = function (value, encodingOrOffset, length) {
|
|
7151
|
-
return from(value, encodingOrOffset, length)
|
|
7152
|
-
};
|
|
7153
|
-
|
|
7154
|
-
// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
|
|
7155
|
-
// https://github.com/feross/buffer/pull/148
|
|
7156
|
-
Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
|
|
7157
|
-
Object.setPrototypeOf(Buffer, Uint8Array);
|
|
7158
|
-
|
|
7159
|
-
function assertSize (size) {
|
|
7160
|
-
if (typeof size !== 'number') {
|
|
7161
|
-
throw new TypeError('"size" argument must be of type number')
|
|
7162
|
-
} else if (size < 0) {
|
|
7163
|
-
throw new RangeError('The value "' + size + '" is invalid for option "size"')
|
|
7164
|
-
}
|
|
7165
|
-
}
|
|
7166
|
-
|
|
7167
|
-
function alloc (size, fill, encoding) {
|
|
7168
|
-
assertSize(size);
|
|
7169
|
-
if (size <= 0) {
|
|
7170
|
-
return createBuffer(size)
|
|
7171
|
-
}
|
|
7172
|
-
if (fill !== undefined) {
|
|
7173
|
-
// Only pay attention to encoding if it's a string. This
|
|
7174
|
-
// prevents accidentally sending in a number that would
|
|
7175
|
-
// be interpreted as a start offset.
|
|
7176
|
-
return typeof encoding === 'string'
|
|
7177
|
-
? createBuffer(size).fill(fill, encoding)
|
|
7178
|
-
: createBuffer(size).fill(fill)
|
|
7179
|
-
}
|
|
7180
|
-
return createBuffer(size)
|
|
7181
|
-
}
|
|
7182
|
-
|
|
7183
|
-
/**
|
|
7184
|
-
* Creates a new filled Buffer instance.
|
|
7185
|
-
* alloc(size[, fill[, encoding]])
|
|
7186
|
-
**/
|
|
7187
|
-
Buffer.alloc = function (size, fill, encoding) {
|
|
7188
|
-
return alloc(size, fill, encoding)
|
|
7189
|
-
};
|
|
7190
|
-
|
|
7191
|
-
function allocUnsafe (size) {
|
|
7192
|
-
assertSize(size);
|
|
7193
|
-
return createBuffer(size < 0 ? 0 : checked(size) | 0)
|
|
7194
|
-
}
|
|
7195
|
-
|
|
7196
|
-
/**
|
|
7197
|
-
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
|
|
7198
|
-
* */
|
|
7199
|
-
Buffer.allocUnsafe = function (size) {
|
|
7200
|
-
return allocUnsafe(size)
|
|
7201
|
-
};
|
|
7202
|
-
/**
|
|
7203
|
-
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
|
|
7204
|
-
*/
|
|
7205
|
-
Buffer.allocUnsafeSlow = function (size) {
|
|
7206
|
-
return allocUnsafe(size)
|
|
7207
|
-
};
|
|
7208
|
-
|
|
7209
|
-
function fromString (string, encoding) {
|
|
7210
|
-
if (typeof encoding !== 'string' || encoding === '') {
|
|
7211
|
-
encoding = 'utf8';
|
|
7212
|
-
}
|
|
7213
|
-
|
|
7214
|
-
if (!Buffer.isEncoding(encoding)) {
|
|
7215
|
-
throw new TypeError('Unknown encoding: ' + encoding)
|
|
7216
|
-
}
|
|
7217
|
-
|
|
7218
|
-
var length = byteLength(string, encoding) | 0;
|
|
7219
|
-
var buf = createBuffer(length);
|
|
7220
|
-
|
|
7221
|
-
var actual = buf.write(string, encoding);
|
|
7222
|
-
|
|
7223
|
-
if (actual !== length) {
|
|
7224
|
-
// Writing a hex string, for example, that contains invalid characters will
|
|
7225
|
-
// cause everything after the first invalid character to be ignored. (e.g.
|
|
7226
|
-
// 'abxxcd' will be treated as 'ab')
|
|
7227
|
-
buf = buf.slice(0, actual);
|
|
7228
|
-
}
|
|
7229
|
-
|
|
7230
|
-
return buf
|
|
7231
|
-
}
|
|
7232
|
-
|
|
7233
|
-
function fromArrayLike (array) {
|
|
7234
|
-
var length = array.length < 0 ? 0 : checked(array.length) | 0;
|
|
7235
|
-
var buf = createBuffer(length);
|
|
7236
|
-
for (var i = 0; i < length; i += 1) {
|
|
7237
|
-
buf[i] = array[i] & 255;
|
|
7238
|
-
}
|
|
7239
|
-
return buf
|
|
7240
|
-
}
|
|
7241
|
-
|
|
7242
|
-
function fromArrayView (arrayView) {
|
|
7243
|
-
if (isInstance(arrayView, Uint8Array)) {
|
|
7244
|
-
var copy = new Uint8Array(arrayView);
|
|
7245
|
-
return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)
|
|
7246
|
-
}
|
|
7247
|
-
return fromArrayLike(arrayView)
|
|
7248
|
-
}
|
|
7249
|
-
|
|
7250
|
-
function fromArrayBuffer (array, byteOffset, length) {
|
|
7251
|
-
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
|
7252
|
-
throw new RangeError('"offset" is outside of buffer bounds')
|
|
7253
|
-
}
|
|
7254
|
-
|
|
7255
|
-
if (array.byteLength < byteOffset + (length || 0)) {
|
|
7256
|
-
throw new RangeError('"length" is outside of buffer bounds')
|
|
7257
|
-
}
|
|
7258
|
-
|
|
7259
|
-
var buf;
|
|
7260
|
-
if (byteOffset === undefined && length === undefined) {
|
|
7261
|
-
buf = new Uint8Array(array);
|
|
7262
|
-
} else if (length === undefined) {
|
|
7263
|
-
buf = new Uint8Array(array, byteOffset);
|
|
7264
|
-
} else {
|
|
7265
|
-
buf = new Uint8Array(array, byteOffset, length);
|
|
7266
|
-
}
|
|
7267
|
-
|
|
7268
|
-
// Return an augmented `Uint8Array` instance
|
|
7269
|
-
Object.setPrototypeOf(buf, Buffer.prototype);
|
|
7270
|
-
|
|
7271
|
-
return buf
|
|
7272
|
-
}
|
|
7273
|
-
|
|
7274
|
-
function fromObject (obj) {
|
|
7275
|
-
if (Buffer.isBuffer(obj)) {
|
|
7276
|
-
var len = checked(obj.length) | 0;
|
|
7277
|
-
var buf = createBuffer(len);
|
|
7278
|
-
|
|
7279
|
-
if (buf.length === 0) {
|
|
7280
|
-
return buf
|
|
7281
|
-
}
|
|
7282
|
-
|
|
7283
|
-
obj.copy(buf, 0, 0, len);
|
|
7284
|
-
return buf
|
|
7285
|
-
}
|
|
7286
|
-
|
|
7287
|
-
if (obj.length !== undefined) {
|
|
7288
|
-
if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
|
|
7289
|
-
return createBuffer(0)
|
|
7290
|
-
}
|
|
7291
|
-
return fromArrayLike(obj)
|
|
7292
|
-
}
|
|
7293
|
-
|
|
7294
|
-
if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
|
|
7295
|
-
return fromArrayLike(obj.data)
|
|
7296
|
-
}
|
|
7297
|
-
}
|
|
7298
|
-
|
|
7299
|
-
function checked (length) {
|
|
7300
|
-
// Note: cannot use `length < K_MAX_LENGTH` here because that fails when
|
|
7301
|
-
// length is NaN (which is otherwise coerced to zero.)
|
|
7302
|
-
if (length >= K_MAX_LENGTH) {
|
|
7303
|
-
throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
|
|
7304
|
-
'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')
|
|
7305
|
-
}
|
|
7306
|
-
return length | 0
|
|
7307
|
-
}
|
|
7308
|
-
|
|
7309
|
-
function SlowBuffer (length) {
|
|
7310
|
-
if (+length != length) { // eslint-disable-line eqeqeq
|
|
7311
|
-
length = 0;
|
|
7312
|
-
}
|
|
7313
|
-
return Buffer.alloc(+length)
|
|
7314
|
-
}
|
|
7315
|
-
|
|
7316
|
-
Buffer.isBuffer = function isBuffer (b) {
|
|
7317
|
-
return b != null && b._isBuffer === true &&
|
|
7318
|
-
b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false
|
|
7319
|
-
};
|
|
7320
|
-
|
|
7321
|
-
Buffer.compare = function compare (a, b) {
|
|
7322
|
-
if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength);
|
|
7323
|
-
if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength);
|
|
7324
|
-
if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
|
|
7325
|
-
throw new TypeError(
|
|
7326
|
-
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
|
7327
|
-
)
|
|
7328
|
-
}
|
|
7329
|
-
|
|
7330
|
-
if (a === b) return 0
|
|
7331
|
-
|
|
7332
|
-
var x = a.length;
|
|
7333
|
-
var y = b.length;
|
|
7334
|
-
|
|
7335
|
-
for (var i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
7336
|
-
if (a[i] !== b[i]) {
|
|
7337
|
-
x = a[i];
|
|
7338
|
-
y = b[i];
|
|
7339
|
-
break
|
|
7340
|
-
}
|
|
7341
|
-
}
|
|
7342
|
-
|
|
7343
|
-
if (x < y) return -1
|
|
7344
|
-
if (y < x) return 1
|
|
7345
|
-
return 0
|
|
7346
|
-
};
|
|
7347
|
-
|
|
7348
|
-
Buffer.isEncoding = function isEncoding (encoding) {
|
|
7349
|
-
switch (String(encoding).toLowerCase()) {
|
|
7350
|
-
case 'hex':
|
|
7351
|
-
case 'utf8':
|
|
7352
|
-
case 'utf-8':
|
|
7353
|
-
case 'ascii':
|
|
7354
|
-
case 'latin1':
|
|
7355
|
-
case 'binary':
|
|
7356
|
-
case 'base64':
|
|
7357
|
-
case 'ucs2':
|
|
7358
|
-
case 'ucs-2':
|
|
7359
|
-
case 'utf16le':
|
|
7360
|
-
case 'utf-16le':
|
|
7361
|
-
return true
|
|
7362
|
-
default:
|
|
7363
|
-
return false
|
|
7364
|
-
}
|
|
7365
|
-
};
|
|
7366
|
-
|
|
7367
|
-
Buffer.concat = function concat (list, length) {
|
|
7368
|
-
if (!Array.isArray(list)) {
|
|
7369
|
-
throw new TypeError('"list" argument must be an Array of Buffers')
|
|
7370
|
-
}
|
|
7371
|
-
|
|
7372
|
-
if (list.length === 0) {
|
|
7373
|
-
return Buffer.alloc(0)
|
|
7374
|
-
}
|
|
7375
|
-
|
|
7376
|
-
var i;
|
|
7377
|
-
if (length === undefined) {
|
|
7378
|
-
length = 0;
|
|
7379
|
-
for (i = 0; i < list.length; ++i) {
|
|
7380
|
-
length += list[i].length;
|
|
7381
|
-
}
|
|
7382
|
-
}
|
|
7383
|
-
|
|
7384
|
-
var buffer = Buffer.allocUnsafe(length);
|
|
7385
|
-
var pos = 0;
|
|
7386
|
-
for (i = 0; i < list.length; ++i) {
|
|
7387
|
-
var buf = list[i];
|
|
7388
|
-
if (isInstance(buf, Uint8Array)) {
|
|
7389
|
-
if (pos + buf.length > buffer.length) {
|
|
7390
|
-
Buffer.from(buf).copy(buffer, pos);
|
|
7391
|
-
} else {
|
|
7392
|
-
Uint8Array.prototype.set.call(
|
|
7393
|
-
buffer,
|
|
7394
|
-
buf,
|
|
7395
|
-
pos
|
|
7396
|
-
);
|
|
7397
|
-
}
|
|
7398
|
-
} else if (!Buffer.isBuffer(buf)) {
|
|
7399
|
-
throw new TypeError('"list" argument must be an Array of Buffers')
|
|
7400
|
-
} else {
|
|
7401
|
-
buf.copy(buffer, pos);
|
|
7402
|
-
}
|
|
7403
|
-
pos += buf.length;
|
|
7404
|
-
}
|
|
7405
|
-
return buffer
|
|
7406
|
-
};
|
|
7407
|
-
|
|
7408
|
-
function byteLength (string, encoding) {
|
|
7409
|
-
if (Buffer.isBuffer(string)) {
|
|
7410
|
-
return string.length
|
|
7411
|
-
}
|
|
7412
|
-
if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
|
|
7413
|
-
return string.byteLength
|
|
7414
|
-
}
|
|
7415
|
-
if (typeof string !== 'string') {
|
|
7416
|
-
throw new TypeError(
|
|
7417
|
-
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. ' +
|
|
7418
|
-
'Received type ' + typeof string
|
|
7419
|
-
)
|
|
7420
|
-
}
|
|
7421
|
-
|
|
7422
|
-
var len = string.length;
|
|
7423
|
-
var mustMatch = (arguments.length > 2 && arguments[2] === true);
|
|
7424
|
-
if (!mustMatch && len === 0) return 0
|
|
7425
|
-
|
|
7426
|
-
// Use a for loop to avoid recursion
|
|
7427
|
-
var loweredCase = false;
|
|
7428
|
-
for (;;) {
|
|
7429
|
-
switch (encoding) {
|
|
7430
|
-
case 'ascii':
|
|
7431
|
-
case 'latin1':
|
|
7432
|
-
case 'binary':
|
|
7433
|
-
return len
|
|
7434
|
-
case 'utf8':
|
|
7435
|
-
case 'utf-8':
|
|
7436
|
-
return utf8ToBytes(string).length
|
|
7437
|
-
case 'ucs2':
|
|
7438
|
-
case 'ucs-2':
|
|
7439
|
-
case 'utf16le':
|
|
7440
|
-
case 'utf-16le':
|
|
7441
|
-
return len * 2
|
|
7442
|
-
case 'hex':
|
|
7443
|
-
return len >>> 1
|
|
7444
|
-
case 'base64':
|
|
7445
|
-
return base64ToBytes(string).length
|
|
7446
|
-
default:
|
|
7447
|
-
if (loweredCase) {
|
|
7448
|
-
return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8
|
|
7449
|
-
}
|
|
7450
|
-
encoding = ('' + encoding).toLowerCase();
|
|
7451
|
-
loweredCase = true;
|
|
7452
|
-
}
|
|
7453
|
-
}
|
|
7454
|
-
}
|
|
7455
|
-
Buffer.byteLength = byteLength;
|
|
7456
|
-
|
|
7457
|
-
function slowToString (encoding, start, end) {
|
|
7458
|
-
var loweredCase = false;
|
|
7459
|
-
|
|
7460
|
-
// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
|
|
7461
|
-
// property of a typed array.
|
|
7462
|
-
|
|
7463
|
-
// This behaves neither like String nor Uint8Array in that we set start/end
|
|
7464
|
-
// to their upper/lower bounds if the value passed is out of range.
|
|
7465
|
-
// undefined is handled specially as per ECMA-262 6th Edition,
|
|
7466
|
-
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
|
|
7467
|
-
if (start === undefined || start < 0) {
|
|
7468
|
-
start = 0;
|
|
7469
|
-
}
|
|
7470
|
-
// Return early if start > this.length. Done here to prevent potential uint32
|
|
7471
|
-
// coercion fail below.
|
|
7472
|
-
if (start > this.length) {
|
|
7473
|
-
return ''
|
|
7474
|
-
}
|
|
7475
|
-
|
|
7476
|
-
if (end === undefined || end > this.length) {
|
|
7477
|
-
end = this.length;
|
|
7478
|
-
}
|
|
7479
|
-
|
|
7480
|
-
if (end <= 0) {
|
|
7481
|
-
return ''
|
|
7482
|
-
}
|
|
7483
|
-
|
|
7484
|
-
// Force coercion to uint32. This will also coerce falsey/NaN values to 0.
|
|
7485
|
-
end >>>= 0;
|
|
7486
|
-
start >>>= 0;
|
|
7487
|
-
|
|
7488
|
-
if (end <= start) {
|
|
7489
|
-
return ''
|
|
7490
|
-
}
|
|
7491
|
-
|
|
7492
|
-
if (!encoding) encoding = 'utf8';
|
|
7493
|
-
|
|
7494
|
-
while (true) {
|
|
7495
|
-
switch (encoding) {
|
|
7496
|
-
case 'hex':
|
|
7497
|
-
return hexSlice(this, start, end)
|
|
7498
|
-
|
|
7499
|
-
case 'utf8':
|
|
7500
|
-
case 'utf-8':
|
|
7501
|
-
return utf8Slice(this, start, end)
|
|
7502
|
-
|
|
7503
|
-
case 'ascii':
|
|
7504
|
-
return asciiSlice(this, start, end)
|
|
7505
|
-
|
|
7506
|
-
case 'latin1':
|
|
7507
|
-
case 'binary':
|
|
7508
|
-
return latin1Slice(this, start, end)
|
|
7509
|
-
|
|
7510
|
-
case 'base64':
|
|
7511
|
-
return base64Slice(this, start, end)
|
|
7512
|
-
|
|
7513
|
-
case 'ucs2':
|
|
7514
|
-
case 'ucs-2':
|
|
7515
|
-
case 'utf16le':
|
|
7516
|
-
case 'utf-16le':
|
|
7517
|
-
return utf16leSlice(this, start, end)
|
|
7518
|
-
|
|
7519
|
-
default:
|
|
7520
|
-
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
7521
|
-
encoding = (encoding + '').toLowerCase();
|
|
7522
|
-
loweredCase = true;
|
|
7523
|
-
}
|
|
7524
|
-
}
|
|
7525
|
-
}
|
|
7526
|
-
|
|
7527
|
-
// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
|
|
7528
|
-
// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
|
|
7529
|
-
// reliably in a browserify context because there could be multiple different
|
|
7530
|
-
// copies of the 'buffer' package in use. This method works even for Buffer
|
|
7531
|
-
// instances that were created from another copy of the `buffer` package.
|
|
7532
|
-
// See: https://github.com/feross/buffer/issues/154
|
|
7533
|
-
Buffer.prototype._isBuffer = true;
|
|
7534
|
-
|
|
7535
|
-
function swap (b, n, m) {
|
|
7536
|
-
var i = b[n];
|
|
7537
|
-
b[n] = b[m];
|
|
7538
|
-
b[m] = i;
|
|
7539
|
-
}
|
|
7540
|
-
|
|
7541
|
-
Buffer.prototype.swap16 = function swap16 () {
|
|
7542
|
-
var len = this.length;
|
|
7543
|
-
if (len % 2 !== 0) {
|
|
7544
|
-
throw new RangeError('Buffer size must be a multiple of 16-bits')
|
|
7545
|
-
}
|
|
7546
|
-
for (var i = 0; i < len; i += 2) {
|
|
7547
|
-
swap(this, i, i + 1);
|
|
7548
|
-
}
|
|
7549
|
-
return this
|
|
7550
|
-
};
|
|
7551
|
-
|
|
7552
|
-
Buffer.prototype.swap32 = function swap32 () {
|
|
7553
|
-
var len = this.length;
|
|
7554
|
-
if (len % 4 !== 0) {
|
|
7555
|
-
throw new RangeError('Buffer size must be a multiple of 32-bits')
|
|
7556
|
-
}
|
|
7557
|
-
for (var i = 0; i < len; i += 4) {
|
|
7558
|
-
swap(this, i, i + 3);
|
|
7559
|
-
swap(this, i + 1, i + 2);
|
|
7560
|
-
}
|
|
7561
|
-
return this
|
|
7562
|
-
};
|
|
7563
|
-
|
|
7564
|
-
Buffer.prototype.swap64 = function swap64 () {
|
|
7565
|
-
var len = this.length;
|
|
7566
|
-
if (len % 8 !== 0) {
|
|
7567
|
-
throw new RangeError('Buffer size must be a multiple of 64-bits')
|
|
7568
|
-
}
|
|
7569
|
-
for (var i = 0; i < len; i += 8) {
|
|
7570
|
-
swap(this, i, i + 7);
|
|
7571
|
-
swap(this, i + 1, i + 6);
|
|
7572
|
-
swap(this, i + 2, i + 5);
|
|
7573
|
-
swap(this, i + 3, i + 4);
|
|
7574
|
-
}
|
|
7575
|
-
return this
|
|
7576
|
-
};
|
|
7577
|
-
|
|
7578
|
-
Buffer.prototype.toString = function toString () {
|
|
7579
|
-
var length = this.length;
|
|
7580
|
-
if (length === 0) return ''
|
|
7581
|
-
if (arguments.length === 0) return utf8Slice(this, 0, length)
|
|
7582
|
-
return slowToString.apply(this, arguments)
|
|
7583
|
-
};
|
|
7584
|
-
|
|
7585
|
-
Buffer.prototype.toLocaleString = Buffer.prototype.toString;
|
|
7586
|
-
|
|
7587
|
-
Buffer.prototype.equals = function equals (b) {
|
|
7588
|
-
if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
|
|
7589
|
-
if (this === b) return true
|
|
7590
|
-
return Buffer.compare(this, b) === 0
|
|
7591
|
-
};
|
|
7592
|
-
|
|
7593
|
-
Buffer.prototype.inspect = function inspect () {
|
|
7594
|
-
var str = '';
|
|
7595
|
-
var max = exports.INSPECT_MAX_BYTES;
|
|
7596
|
-
str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
|
|
7597
|
-
if (this.length > max) str += ' ... ';
|
|
7598
|
-
return '<Buffer ' + str + '>'
|
|
7599
|
-
};
|
|
7600
|
-
if (customInspectSymbol) {
|
|
7601
|
-
Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
|
|
7602
|
-
}
|
|
7603
|
-
|
|
7604
|
-
Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
|
|
7605
|
-
if (isInstance(target, Uint8Array)) {
|
|
7606
|
-
target = Buffer.from(target, target.offset, target.byteLength);
|
|
7607
|
-
}
|
|
7608
|
-
if (!Buffer.isBuffer(target)) {
|
|
7609
|
-
throw new TypeError(
|
|
7610
|
-
'The "target" argument must be one of type Buffer or Uint8Array. ' +
|
|
7611
|
-
'Received type ' + (typeof target)
|
|
7612
|
-
)
|
|
7613
|
-
}
|
|
7614
|
-
|
|
7615
|
-
if (start === undefined) {
|
|
7616
|
-
start = 0;
|
|
7617
|
-
}
|
|
7618
|
-
if (end === undefined) {
|
|
7619
|
-
end = target ? target.length : 0;
|
|
7620
|
-
}
|
|
7621
|
-
if (thisStart === undefined) {
|
|
7622
|
-
thisStart = 0;
|
|
7623
|
-
}
|
|
7624
|
-
if (thisEnd === undefined) {
|
|
7625
|
-
thisEnd = this.length;
|
|
7626
|
-
}
|
|
7627
|
-
|
|
7628
|
-
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
|
7629
|
-
throw new RangeError('out of range index')
|
|
7630
|
-
}
|
|
7631
|
-
|
|
7632
|
-
if (thisStart >= thisEnd && start >= end) {
|
|
7633
|
-
return 0
|
|
7634
|
-
}
|
|
7635
|
-
if (thisStart >= thisEnd) {
|
|
7636
|
-
return -1
|
|
7637
|
-
}
|
|
7638
|
-
if (start >= end) {
|
|
7639
|
-
return 1
|
|
7640
|
-
}
|
|
7641
|
-
|
|
7642
|
-
start >>>= 0;
|
|
7643
|
-
end >>>= 0;
|
|
7644
|
-
thisStart >>>= 0;
|
|
7645
|
-
thisEnd >>>= 0;
|
|
7646
|
-
|
|
7647
|
-
if (this === target) return 0
|
|
7648
|
-
|
|
7649
|
-
var x = thisEnd - thisStart;
|
|
7650
|
-
var y = end - start;
|
|
7651
|
-
var len = Math.min(x, y);
|
|
7652
|
-
|
|
7653
|
-
var thisCopy = this.slice(thisStart, thisEnd);
|
|
7654
|
-
var targetCopy = target.slice(start, end);
|
|
7655
|
-
|
|
7656
|
-
for (var i = 0; i < len; ++i) {
|
|
7657
|
-
if (thisCopy[i] !== targetCopy[i]) {
|
|
7658
|
-
x = thisCopy[i];
|
|
7659
|
-
y = targetCopy[i];
|
|
7660
|
-
break
|
|
7661
|
-
}
|
|
7662
|
-
}
|
|
7663
|
-
|
|
7664
|
-
if (x < y) return -1
|
|
7665
|
-
if (y < x) return 1
|
|
7666
|
-
return 0
|
|
7667
|
-
};
|
|
7668
|
-
|
|
7669
|
-
// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
|
|
7670
|
-
// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
|
|
7671
|
-
//
|
|
7672
|
-
// Arguments:
|
|
7673
|
-
// - buffer - a Buffer to search
|
|
7674
|
-
// - val - a string, Buffer, or number
|
|
7675
|
-
// - byteOffset - an index into `buffer`; will be clamped to an int32
|
|
7676
|
-
// - encoding - an optional encoding, relevant is val is a string
|
|
7677
|
-
// - dir - true for indexOf, false for lastIndexOf
|
|
7678
|
-
function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
|
|
7679
|
-
// Empty buffer means no match
|
|
7680
|
-
if (buffer.length === 0) return -1
|
|
7681
|
-
|
|
7682
|
-
// Normalize byteOffset
|
|
7683
|
-
if (typeof byteOffset === 'string') {
|
|
7684
|
-
encoding = byteOffset;
|
|
7685
|
-
byteOffset = 0;
|
|
7686
|
-
} else if (byteOffset > 0x7fffffff) {
|
|
7687
|
-
byteOffset = 0x7fffffff;
|
|
7688
|
-
} else if (byteOffset < -2147483648) {
|
|
7689
|
-
byteOffset = -2147483648;
|
|
7690
|
-
}
|
|
7691
|
-
byteOffset = +byteOffset; // Coerce to Number.
|
|
7692
|
-
if (numberIsNaN(byteOffset)) {
|
|
7693
|
-
// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
|
|
7694
|
-
byteOffset = dir ? 0 : (buffer.length - 1);
|
|
7695
|
-
}
|
|
7696
|
-
|
|
7697
|
-
// Normalize byteOffset: negative offsets start from the end of the buffer
|
|
7698
|
-
if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
|
|
7699
|
-
if (byteOffset >= buffer.length) {
|
|
7700
|
-
if (dir) return -1
|
|
7701
|
-
else byteOffset = buffer.length - 1;
|
|
7702
|
-
} else if (byteOffset < 0) {
|
|
7703
|
-
if (dir) byteOffset = 0;
|
|
7704
|
-
else return -1
|
|
7705
|
-
}
|
|
7706
|
-
|
|
7707
|
-
// Normalize val
|
|
7708
|
-
if (typeof val === 'string') {
|
|
7709
|
-
val = Buffer.from(val, encoding);
|
|
7710
|
-
}
|
|
7711
|
-
|
|
7712
|
-
// Finally, search either indexOf (if dir is true) or lastIndexOf
|
|
7713
|
-
if (Buffer.isBuffer(val)) {
|
|
7714
|
-
// Special case: looking for empty string/buffer always fails
|
|
7715
|
-
if (val.length === 0) {
|
|
7716
|
-
return -1
|
|
7717
|
-
}
|
|
7718
|
-
return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
|
|
7719
|
-
} else if (typeof val === 'number') {
|
|
7720
|
-
val = val & 0xFF; // Search for a byte value [0-255]
|
|
7721
|
-
if (typeof Uint8Array.prototype.indexOf === 'function') {
|
|
7722
|
-
if (dir) {
|
|
7723
|
-
return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
|
|
7724
|
-
} else {
|
|
7725
|
-
return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
|
|
7726
|
-
}
|
|
7727
|
-
}
|
|
7728
|
-
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)
|
|
7729
|
-
}
|
|
7730
|
-
|
|
7731
|
-
throw new TypeError('val must be string, number or Buffer')
|
|
7732
|
-
}
|
|
7733
|
-
|
|
7734
|
-
function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
|
|
7735
|
-
var indexSize = 1;
|
|
7736
|
-
var arrLength = arr.length;
|
|
7737
|
-
var valLength = val.length;
|
|
7738
|
-
|
|
7739
|
-
if (encoding !== undefined) {
|
|
7740
|
-
encoding = String(encoding).toLowerCase();
|
|
7741
|
-
if (encoding === 'ucs2' || encoding === 'ucs-2' ||
|
|
7742
|
-
encoding === 'utf16le' || encoding === 'utf-16le') {
|
|
7743
|
-
if (arr.length < 2 || val.length < 2) {
|
|
7744
|
-
return -1
|
|
7745
|
-
}
|
|
7746
|
-
indexSize = 2;
|
|
7747
|
-
arrLength /= 2;
|
|
7748
|
-
valLength /= 2;
|
|
7749
|
-
byteOffset /= 2;
|
|
7750
|
-
}
|
|
7751
|
-
}
|
|
7752
|
-
|
|
7753
|
-
function read (buf, i) {
|
|
7754
|
-
if (indexSize === 1) {
|
|
7755
|
-
return buf[i]
|
|
7756
|
-
} else {
|
|
7757
|
-
return buf.readUInt16BE(i * indexSize)
|
|
7758
|
-
}
|
|
7759
|
-
}
|
|
7760
|
-
|
|
7761
|
-
var i;
|
|
7762
|
-
if (dir) {
|
|
7763
|
-
var foundIndex = -1;
|
|
7764
|
-
for (i = byteOffset; i < arrLength; i++) {
|
|
7765
|
-
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
7766
|
-
if (foundIndex === -1) foundIndex = i;
|
|
7767
|
-
if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
|
|
7768
|
-
} else {
|
|
7769
|
-
if (foundIndex !== -1) i -= i - foundIndex;
|
|
7770
|
-
foundIndex = -1;
|
|
7771
|
-
}
|
|
7772
|
-
}
|
|
7773
|
-
} else {
|
|
7774
|
-
if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
|
|
7775
|
-
for (i = byteOffset; i >= 0; i--) {
|
|
7776
|
-
var found = true;
|
|
7777
|
-
for (var j = 0; j < valLength; j++) {
|
|
7778
|
-
if (read(arr, i + j) !== read(val, j)) {
|
|
7779
|
-
found = false;
|
|
7780
|
-
break
|
|
7781
|
-
}
|
|
7782
|
-
}
|
|
7783
|
-
if (found) return i
|
|
7784
|
-
}
|
|
7785
|
-
}
|
|
7786
|
-
|
|
7787
|
-
return -1
|
|
7788
|
-
}
|
|
7789
|
-
|
|
7790
|
-
Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
|
|
7791
|
-
return this.indexOf(val, byteOffset, encoding) !== -1
|
|
7792
|
-
};
|
|
7793
|
-
|
|
7794
|
-
Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
|
|
7795
|
-
return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
|
|
7796
|
-
};
|
|
7797
|
-
|
|
7798
|
-
Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
|
|
7799
|
-
return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
|
|
7800
|
-
};
|
|
7801
|
-
|
|
7802
|
-
function hexWrite (buf, string, offset, length) {
|
|
7803
|
-
offset = Number(offset) || 0;
|
|
7804
|
-
var remaining = buf.length - offset;
|
|
7805
|
-
if (!length) {
|
|
7806
|
-
length = remaining;
|
|
7807
|
-
} else {
|
|
7808
|
-
length = Number(length);
|
|
7809
|
-
if (length > remaining) {
|
|
7810
|
-
length = remaining;
|
|
7811
|
-
}
|
|
7812
|
-
}
|
|
7813
|
-
|
|
7814
|
-
var strLen = string.length;
|
|
7815
|
-
|
|
7816
|
-
if (length > strLen / 2) {
|
|
7817
|
-
length = strLen / 2;
|
|
7818
|
-
}
|
|
7819
|
-
for (var i = 0; i < length; ++i) {
|
|
7820
|
-
var parsed = parseInt(string.substr(i * 2, 2), 16);
|
|
7821
|
-
if (numberIsNaN(parsed)) return i
|
|
7822
|
-
buf[offset + i] = parsed;
|
|
7823
|
-
}
|
|
7824
|
-
return i
|
|
7825
|
-
}
|
|
7826
|
-
|
|
7827
|
-
function utf8Write (buf, string, offset, length) {
|
|
7828
|
-
return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
|
|
7829
|
-
}
|
|
7830
|
-
|
|
7831
|
-
function asciiWrite (buf, string, offset, length) {
|
|
7832
|
-
return blitBuffer(asciiToBytes(string), buf, offset, length)
|
|
7833
|
-
}
|
|
7834
|
-
|
|
7835
|
-
function base64Write (buf, string, offset, length) {
|
|
7836
|
-
return blitBuffer(base64ToBytes(string), buf, offset, length)
|
|
7837
|
-
}
|
|
7838
|
-
|
|
7839
|
-
function ucs2Write (buf, string, offset, length) {
|
|
7840
|
-
return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
|
|
7841
|
-
}
|
|
7842
|
-
|
|
7843
|
-
Buffer.prototype.write = function write (string, offset, length, encoding) {
|
|
7844
|
-
// Buffer#write(string)
|
|
7845
|
-
if (offset === undefined) {
|
|
7846
|
-
encoding = 'utf8';
|
|
7847
|
-
length = this.length;
|
|
7848
|
-
offset = 0;
|
|
7849
|
-
// Buffer#write(string, encoding)
|
|
7850
|
-
} else if (length === undefined && typeof offset === 'string') {
|
|
7851
|
-
encoding = offset;
|
|
7852
|
-
length = this.length;
|
|
7853
|
-
offset = 0;
|
|
7854
|
-
// Buffer#write(string, offset[, length][, encoding])
|
|
7855
|
-
} else if (isFinite(offset)) {
|
|
7856
|
-
offset = offset >>> 0;
|
|
7857
|
-
if (isFinite(length)) {
|
|
7858
|
-
length = length >>> 0;
|
|
7859
|
-
if (encoding === undefined) encoding = 'utf8';
|
|
7860
|
-
} else {
|
|
7861
|
-
encoding = length;
|
|
7862
|
-
length = undefined;
|
|
7863
|
-
}
|
|
7864
|
-
} else {
|
|
7865
|
-
throw new Error(
|
|
7866
|
-
'Buffer.write(string, encoding, offset[, length]) is no longer supported'
|
|
7867
|
-
)
|
|
7868
|
-
}
|
|
7869
|
-
|
|
7870
|
-
var remaining = this.length - offset;
|
|
7871
|
-
if (length === undefined || length > remaining) length = remaining;
|
|
7872
|
-
|
|
7873
|
-
if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
|
|
7874
|
-
throw new RangeError('Attempt to write outside buffer bounds')
|
|
7875
|
-
}
|
|
7876
|
-
|
|
7877
|
-
if (!encoding) encoding = 'utf8';
|
|
7878
|
-
|
|
7879
|
-
var loweredCase = false;
|
|
7880
|
-
for (;;) {
|
|
7881
|
-
switch (encoding) {
|
|
7882
|
-
case 'hex':
|
|
7883
|
-
return hexWrite(this, string, offset, length)
|
|
7884
|
-
|
|
7885
|
-
case 'utf8':
|
|
7886
|
-
case 'utf-8':
|
|
7887
|
-
return utf8Write(this, string, offset, length)
|
|
7888
|
-
|
|
7889
|
-
case 'ascii':
|
|
7890
|
-
case 'latin1':
|
|
7891
|
-
case 'binary':
|
|
7892
|
-
return asciiWrite(this, string, offset, length)
|
|
7893
|
-
|
|
7894
|
-
case 'base64':
|
|
7895
|
-
// Warning: maxLength not taken into account in base64Write
|
|
7896
|
-
return base64Write(this, string, offset, length)
|
|
7897
|
-
|
|
7898
|
-
case 'ucs2':
|
|
7899
|
-
case 'ucs-2':
|
|
7900
|
-
case 'utf16le':
|
|
7901
|
-
case 'utf-16le':
|
|
7902
|
-
return ucs2Write(this, string, offset, length)
|
|
7903
|
-
|
|
7904
|
-
default:
|
|
7905
|
-
if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
|
|
7906
|
-
encoding = ('' + encoding).toLowerCase();
|
|
7907
|
-
loweredCase = true;
|
|
7908
|
-
}
|
|
7909
|
-
}
|
|
7910
|
-
};
|
|
7911
|
-
|
|
7912
|
-
Buffer.prototype.toJSON = function toJSON () {
|
|
7913
|
-
return {
|
|
7914
|
-
type: 'Buffer',
|
|
7915
|
-
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
7916
|
-
}
|
|
7917
|
-
};
|
|
7918
|
-
|
|
7919
|
-
function base64Slice (buf, start, end) {
|
|
7920
|
-
if (start === 0 && end === buf.length) {
|
|
7921
|
-
return base64.fromByteArray(buf)
|
|
7922
|
-
} else {
|
|
7923
|
-
return base64.fromByteArray(buf.slice(start, end))
|
|
7924
|
-
}
|
|
7925
|
-
}
|
|
7926
|
-
|
|
7927
|
-
function utf8Slice (buf, start, end) {
|
|
7928
|
-
end = Math.min(buf.length, end);
|
|
7929
|
-
var res = [];
|
|
7930
|
-
|
|
7931
|
-
var i = start;
|
|
7932
|
-
while (i < end) {
|
|
7933
|
-
var firstByte = buf[i];
|
|
7934
|
-
var codePoint = null;
|
|
7935
|
-
var bytesPerSequence = (firstByte > 0xEF)
|
|
7936
|
-
? 4
|
|
7937
|
-
: (firstByte > 0xDF)
|
|
7938
|
-
? 3
|
|
7939
|
-
: (firstByte > 0xBF)
|
|
7940
|
-
? 2
|
|
7941
|
-
: 1;
|
|
7942
|
-
|
|
7943
|
-
if (i + bytesPerSequence <= end) {
|
|
7944
|
-
var secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
7945
|
-
|
|
7946
|
-
switch (bytesPerSequence) {
|
|
7947
|
-
case 1:
|
|
7948
|
-
if (firstByte < 0x80) {
|
|
7949
|
-
codePoint = firstByte;
|
|
7950
|
-
}
|
|
7951
|
-
break
|
|
7952
|
-
case 2:
|
|
7953
|
-
secondByte = buf[i + 1];
|
|
7954
|
-
if ((secondByte & 0xC0) === 0x80) {
|
|
7955
|
-
tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
|
|
7956
|
-
if (tempCodePoint > 0x7F) {
|
|
7957
|
-
codePoint = tempCodePoint;
|
|
7958
|
-
}
|
|
7959
|
-
}
|
|
7960
|
-
break
|
|
7961
|
-
case 3:
|
|
7962
|
-
secondByte = buf[i + 1];
|
|
7963
|
-
thirdByte = buf[i + 2];
|
|
7964
|
-
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
|
|
7965
|
-
tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
|
|
7966
|
-
if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
|
|
7967
|
-
codePoint = tempCodePoint;
|
|
7968
|
-
}
|
|
7969
|
-
}
|
|
7970
|
-
break
|
|
7971
|
-
case 4:
|
|
7972
|
-
secondByte = buf[i + 1];
|
|
7973
|
-
thirdByte = buf[i + 2];
|
|
7974
|
-
fourthByte = buf[i + 3];
|
|
7975
|
-
if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
|
|
7976
|
-
tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
|
|
7977
|
-
if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
|
|
7978
|
-
codePoint = tempCodePoint;
|
|
7979
|
-
}
|
|
7980
|
-
}
|
|
7981
|
-
}
|
|
7982
|
-
}
|
|
7983
|
-
|
|
7984
|
-
if (codePoint === null) {
|
|
7985
|
-
// we did not generate a valid codePoint so insert a
|
|
7986
|
-
// replacement char (U+FFFD) and advance only 1 byte
|
|
7987
|
-
codePoint = 0xFFFD;
|
|
7988
|
-
bytesPerSequence = 1;
|
|
7989
|
-
} else if (codePoint > 0xFFFF) {
|
|
7990
|
-
// encode to utf16 (surrogate pair dance)
|
|
7991
|
-
codePoint -= 0x10000;
|
|
7992
|
-
res.push(codePoint >>> 10 & 0x3FF | 0xD800);
|
|
7993
|
-
codePoint = 0xDC00 | codePoint & 0x3FF;
|
|
7994
|
-
}
|
|
7995
|
-
|
|
7996
|
-
res.push(codePoint);
|
|
7997
|
-
i += bytesPerSequence;
|
|
7998
|
-
}
|
|
7999
|
-
|
|
8000
|
-
return decodeCodePointsArray(res)
|
|
8001
|
-
}
|
|
8002
|
-
|
|
8003
|
-
// Based on http://stackoverflow.com/a/22747272/680742, the browser with
|
|
8004
|
-
// the lowest limit is Chrome, with 0x10000 args.
|
|
8005
|
-
// We go 1 magnitude less, for safety
|
|
8006
|
-
var MAX_ARGUMENTS_LENGTH = 0x1000;
|
|
8007
|
-
|
|
8008
|
-
function decodeCodePointsArray (codePoints) {
|
|
8009
|
-
var len = codePoints.length;
|
|
8010
|
-
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
8011
|
-
return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
|
|
8012
|
-
}
|
|
8013
|
-
|
|
8014
|
-
// Decode in chunks to avoid "call stack size exceeded".
|
|
8015
|
-
var res = '';
|
|
8016
|
-
var i = 0;
|
|
8017
|
-
while (i < len) {
|
|
8018
|
-
res += String.fromCharCode.apply(
|
|
8019
|
-
String,
|
|
8020
|
-
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
|
8021
|
-
);
|
|
8022
|
-
}
|
|
8023
|
-
return res
|
|
8024
|
-
}
|
|
8025
|
-
|
|
8026
|
-
function asciiSlice (buf, start, end) {
|
|
8027
|
-
var ret = '';
|
|
8028
|
-
end = Math.min(buf.length, end);
|
|
8029
|
-
|
|
8030
|
-
for (var i = start; i < end; ++i) {
|
|
8031
|
-
ret += String.fromCharCode(buf[i] & 0x7F);
|
|
8032
|
-
}
|
|
8033
|
-
return ret
|
|
8034
|
-
}
|
|
8035
|
-
|
|
8036
|
-
function latin1Slice (buf, start, end) {
|
|
8037
|
-
var ret = '';
|
|
8038
|
-
end = Math.min(buf.length, end);
|
|
8039
|
-
|
|
8040
|
-
for (var i = start; i < end; ++i) {
|
|
8041
|
-
ret += String.fromCharCode(buf[i]);
|
|
8042
|
-
}
|
|
8043
|
-
return ret
|
|
8044
|
-
}
|
|
8045
|
-
|
|
8046
|
-
function hexSlice (buf, start, end) {
|
|
8047
|
-
var len = buf.length;
|
|
8048
|
-
|
|
8049
|
-
if (!start || start < 0) start = 0;
|
|
8050
|
-
if (!end || end < 0 || end > len) end = len;
|
|
8051
|
-
|
|
8052
|
-
var out = '';
|
|
8053
|
-
for (var i = start; i < end; ++i) {
|
|
8054
|
-
out += hexSliceLookupTable[buf[i]];
|
|
8055
|
-
}
|
|
8056
|
-
return out
|
|
8057
|
-
}
|
|
8058
|
-
|
|
8059
|
-
function utf16leSlice (buf, start, end) {
|
|
8060
|
-
var bytes = buf.slice(start, end);
|
|
8061
|
-
var res = '';
|
|
8062
|
-
// If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
|
|
8063
|
-
for (var i = 0; i < bytes.length - 1; i += 2) {
|
|
8064
|
-
res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256));
|
|
8065
|
-
}
|
|
8066
|
-
return res
|
|
8067
|
-
}
|
|
8068
|
-
|
|
8069
|
-
Buffer.prototype.slice = function slice (start, end) {
|
|
8070
|
-
var len = this.length;
|
|
8071
|
-
start = ~~start;
|
|
8072
|
-
end = end === undefined ? len : ~~end;
|
|
8073
|
-
|
|
8074
|
-
if (start < 0) {
|
|
8075
|
-
start += len;
|
|
8076
|
-
if (start < 0) start = 0;
|
|
8077
|
-
} else if (start > len) {
|
|
8078
|
-
start = len;
|
|
8079
|
-
}
|
|
8080
|
-
|
|
8081
|
-
if (end < 0) {
|
|
8082
|
-
end += len;
|
|
8083
|
-
if (end < 0) end = 0;
|
|
8084
|
-
} else if (end > len) {
|
|
8085
|
-
end = len;
|
|
8086
|
-
}
|
|
8087
|
-
|
|
8088
|
-
if (end < start) end = start;
|
|
8089
|
-
|
|
8090
|
-
var newBuf = this.subarray(start, end);
|
|
8091
|
-
// Return an augmented `Uint8Array` instance
|
|
8092
|
-
Object.setPrototypeOf(newBuf, Buffer.prototype);
|
|
8093
|
-
|
|
8094
|
-
return newBuf
|
|
8095
|
-
};
|
|
8096
|
-
|
|
8097
|
-
/*
|
|
8098
|
-
* Need to make sure that buffer isn't trying to write out of bounds.
|
|
8099
|
-
*/
|
|
8100
|
-
function checkOffset (offset, ext, length) {
|
|
8101
|
-
if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
|
|
8102
|
-
if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
|
|
8103
|
-
}
|
|
8104
|
-
|
|
8105
|
-
Buffer.prototype.readUintLE =
|
|
8106
|
-
Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
|
|
8107
|
-
offset = offset >>> 0;
|
|
8108
|
-
byteLength = byteLength >>> 0;
|
|
8109
|
-
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
8110
|
-
|
|
8111
|
-
var val = this[offset];
|
|
8112
|
-
var mul = 1;
|
|
8113
|
-
var i = 0;
|
|
8114
|
-
while (++i < byteLength && (mul *= 0x100)) {
|
|
8115
|
-
val += this[offset + i] * mul;
|
|
8116
|
-
}
|
|
8117
|
-
|
|
8118
|
-
return val
|
|
8119
|
-
};
|
|
8120
|
-
|
|
8121
|
-
Buffer.prototype.readUintBE =
|
|
8122
|
-
Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
|
|
8123
|
-
offset = offset >>> 0;
|
|
8124
|
-
byteLength = byteLength >>> 0;
|
|
8125
|
-
if (!noAssert) {
|
|
8126
|
-
checkOffset(offset, byteLength, this.length);
|
|
8127
|
-
}
|
|
8128
|
-
|
|
8129
|
-
var val = this[offset + --byteLength];
|
|
8130
|
-
var mul = 1;
|
|
8131
|
-
while (byteLength > 0 && (mul *= 0x100)) {
|
|
8132
|
-
val += this[offset + --byteLength] * mul;
|
|
8133
|
-
}
|
|
8134
|
-
|
|
8135
|
-
return val
|
|
8136
|
-
};
|
|
8137
|
-
|
|
8138
|
-
Buffer.prototype.readUint8 =
|
|
8139
|
-
Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
|
|
8140
|
-
offset = offset >>> 0;
|
|
8141
|
-
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
8142
|
-
return this[offset]
|
|
8143
|
-
};
|
|
8144
|
-
|
|
8145
|
-
Buffer.prototype.readUint16LE =
|
|
8146
|
-
Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
|
|
8147
|
-
offset = offset >>> 0;
|
|
8148
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
8149
|
-
return this[offset] | (this[offset + 1] << 8)
|
|
8150
|
-
};
|
|
8151
|
-
|
|
8152
|
-
Buffer.prototype.readUint16BE =
|
|
8153
|
-
Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
|
|
8154
|
-
offset = offset >>> 0;
|
|
8155
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
8156
|
-
return (this[offset] << 8) | this[offset + 1]
|
|
8157
|
-
};
|
|
8158
|
-
|
|
8159
|
-
Buffer.prototype.readUint32LE =
|
|
8160
|
-
Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
|
|
8161
|
-
offset = offset >>> 0;
|
|
8162
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
8163
|
-
|
|
8164
|
-
return ((this[offset]) |
|
|
8165
|
-
(this[offset + 1] << 8) |
|
|
8166
|
-
(this[offset + 2] << 16)) +
|
|
8167
|
-
(this[offset + 3] * 0x1000000)
|
|
8168
|
-
};
|
|
8169
|
-
|
|
8170
|
-
Buffer.prototype.readUint32BE =
|
|
8171
|
-
Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
|
|
8172
|
-
offset = offset >>> 0;
|
|
8173
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
8174
|
-
|
|
8175
|
-
return (this[offset] * 0x1000000) +
|
|
8176
|
-
((this[offset + 1] << 16) |
|
|
8177
|
-
(this[offset + 2] << 8) |
|
|
8178
|
-
this[offset + 3])
|
|
8179
|
-
};
|
|
8180
|
-
|
|
8181
|
-
Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
|
|
8182
|
-
offset = offset >>> 0;
|
|
8183
|
-
byteLength = byteLength >>> 0;
|
|
8184
|
-
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
8185
|
-
|
|
8186
|
-
var val = this[offset];
|
|
8187
|
-
var mul = 1;
|
|
8188
|
-
var i = 0;
|
|
8189
|
-
while (++i < byteLength && (mul *= 0x100)) {
|
|
8190
|
-
val += this[offset + i] * mul;
|
|
8191
|
-
}
|
|
8192
|
-
mul *= 0x80;
|
|
8193
|
-
|
|
8194
|
-
if (val >= mul) val -= Math.pow(2, 8 * byteLength);
|
|
8195
|
-
|
|
8196
|
-
return val
|
|
8197
|
-
};
|
|
8198
|
-
|
|
8199
|
-
Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
|
|
8200
|
-
offset = offset >>> 0;
|
|
8201
|
-
byteLength = byteLength >>> 0;
|
|
8202
|
-
if (!noAssert) checkOffset(offset, byteLength, this.length);
|
|
8203
|
-
|
|
8204
|
-
var i = byteLength;
|
|
8205
|
-
var mul = 1;
|
|
8206
|
-
var val = this[offset + --i];
|
|
8207
|
-
while (i > 0 && (mul *= 0x100)) {
|
|
8208
|
-
val += this[offset + --i] * mul;
|
|
8209
|
-
}
|
|
8210
|
-
mul *= 0x80;
|
|
8211
|
-
|
|
8212
|
-
if (val >= mul) val -= Math.pow(2, 8 * byteLength);
|
|
8213
|
-
|
|
8214
|
-
return val
|
|
8215
|
-
};
|
|
8216
|
-
|
|
8217
|
-
Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
|
|
8218
|
-
offset = offset >>> 0;
|
|
8219
|
-
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
8220
|
-
if (!(this[offset] & 0x80)) return (this[offset])
|
|
8221
|
-
return ((0xff - this[offset] + 1) * -1)
|
|
8222
|
-
};
|
|
8223
|
-
|
|
8224
|
-
Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
|
|
8225
|
-
offset = offset >>> 0;
|
|
8226
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
8227
|
-
var val = this[offset] | (this[offset + 1] << 8);
|
|
8228
|
-
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
8229
|
-
};
|
|
8230
|
-
|
|
8231
|
-
Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
|
|
8232
|
-
offset = offset >>> 0;
|
|
8233
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
8234
|
-
var val = this[offset + 1] | (this[offset] << 8);
|
|
8235
|
-
return (val & 0x8000) ? val | 0xFFFF0000 : val
|
|
8236
|
-
};
|
|
8237
|
-
|
|
8238
|
-
Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
|
|
8239
|
-
offset = offset >>> 0;
|
|
8240
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
8241
|
-
|
|
8242
|
-
return (this[offset]) |
|
|
8243
|
-
(this[offset + 1] << 8) |
|
|
8244
|
-
(this[offset + 2] << 16) |
|
|
8245
|
-
(this[offset + 3] << 24)
|
|
8246
|
-
};
|
|
8247
|
-
|
|
8248
|
-
Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
|
|
8249
|
-
offset = offset >>> 0;
|
|
8250
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
8251
|
-
|
|
8252
|
-
return (this[offset] << 24) |
|
|
8253
|
-
(this[offset + 1] << 16) |
|
|
8254
|
-
(this[offset + 2] << 8) |
|
|
8255
|
-
(this[offset + 3])
|
|
8256
|
-
};
|
|
8257
|
-
|
|
8258
|
-
Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
|
|
8259
|
-
offset = offset >>> 0;
|
|
8260
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
8261
|
-
return ieee754.read(this, offset, true, 23, 4)
|
|
8262
|
-
};
|
|
8263
|
-
|
|
8264
|
-
Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
|
|
8265
|
-
offset = offset >>> 0;
|
|
8266
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
8267
|
-
return ieee754.read(this, offset, false, 23, 4)
|
|
8268
|
-
};
|
|
8269
|
-
|
|
8270
|
-
Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
|
|
8271
|
-
offset = offset >>> 0;
|
|
8272
|
-
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
8273
|
-
return ieee754.read(this, offset, true, 52, 8)
|
|
8274
|
-
};
|
|
8275
|
-
|
|
8276
|
-
Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
|
|
8277
|
-
offset = offset >>> 0;
|
|
8278
|
-
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
8279
|
-
return ieee754.read(this, offset, false, 52, 8)
|
|
8280
|
-
};
|
|
8281
|
-
|
|
8282
|
-
function checkInt (buf, value, offset, ext, max, min) {
|
|
8283
|
-
if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
|
|
8284
|
-
if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
|
|
8285
|
-
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
8286
|
-
}
|
|
8287
|
-
|
|
8288
|
-
Buffer.prototype.writeUintLE =
|
|
8289
|
-
Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
|
|
8290
|
-
value = +value;
|
|
8291
|
-
offset = offset >>> 0;
|
|
8292
|
-
byteLength = byteLength >>> 0;
|
|
8293
|
-
if (!noAssert) {
|
|
8294
|
-
var maxBytes = Math.pow(2, 8 * byteLength) - 1;
|
|
8295
|
-
checkInt(this, value, offset, byteLength, maxBytes, 0);
|
|
8296
|
-
}
|
|
8297
|
-
|
|
8298
|
-
var mul = 1;
|
|
8299
|
-
var i = 0;
|
|
8300
|
-
this[offset] = value & 0xFF;
|
|
8301
|
-
while (++i < byteLength && (mul *= 0x100)) {
|
|
8302
|
-
this[offset + i] = (value / mul) & 0xFF;
|
|
8303
|
-
}
|
|
8304
|
-
|
|
8305
|
-
return offset + byteLength
|
|
8306
|
-
};
|
|
8307
|
-
|
|
8308
|
-
Buffer.prototype.writeUintBE =
|
|
8309
|
-
Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
|
|
8310
|
-
value = +value;
|
|
8311
|
-
offset = offset >>> 0;
|
|
8312
|
-
byteLength = byteLength >>> 0;
|
|
8313
|
-
if (!noAssert) {
|
|
8314
|
-
var maxBytes = Math.pow(2, 8 * byteLength) - 1;
|
|
8315
|
-
checkInt(this, value, offset, byteLength, maxBytes, 0);
|
|
8316
|
-
}
|
|
8317
|
-
|
|
8318
|
-
var i = byteLength - 1;
|
|
8319
|
-
var mul = 1;
|
|
8320
|
-
this[offset + i] = value & 0xFF;
|
|
8321
|
-
while (--i >= 0 && (mul *= 0x100)) {
|
|
8322
|
-
this[offset + i] = (value / mul) & 0xFF;
|
|
8323
|
-
}
|
|
8324
|
-
|
|
8325
|
-
return offset + byteLength
|
|
8326
|
-
};
|
|
8327
|
-
|
|
8328
|
-
Buffer.prototype.writeUint8 =
|
|
8329
|
-
Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
|
|
8330
|
-
value = +value;
|
|
8331
|
-
offset = offset >>> 0;
|
|
8332
|
-
if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0);
|
|
8333
|
-
this[offset] = (value & 0xff);
|
|
8334
|
-
return offset + 1
|
|
8335
|
-
};
|
|
8336
|
-
|
|
8337
|
-
Buffer.prototype.writeUint16LE =
|
|
8338
|
-
Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
|
|
8339
|
-
value = +value;
|
|
8340
|
-
offset = offset >>> 0;
|
|
8341
|
-
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
|
|
8342
|
-
this[offset] = (value & 0xff);
|
|
8343
|
-
this[offset + 1] = (value >>> 8);
|
|
8344
|
-
return offset + 2
|
|
8345
|
-
};
|
|
8346
|
-
|
|
8347
|
-
Buffer.prototype.writeUint16BE =
|
|
8348
|
-
Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
|
|
8349
|
-
value = +value;
|
|
8350
|
-
offset = offset >>> 0;
|
|
8351
|
-
if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0);
|
|
8352
|
-
this[offset] = (value >>> 8);
|
|
8353
|
-
this[offset + 1] = (value & 0xff);
|
|
8354
|
-
return offset + 2
|
|
8355
|
-
};
|
|
8356
|
-
|
|
8357
|
-
Buffer.prototype.writeUint32LE =
|
|
8358
|
-
Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
|
|
8359
|
-
value = +value;
|
|
8360
|
-
offset = offset >>> 0;
|
|
8361
|
-
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
|
|
8362
|
-
this[offset + 3] = (value >>> 24);
|
|
8363
|
-
this[offset + 2] = (value >>> 16);
|
|
8364
|
-
this[offset + 1] = (value >>> 8);
|
|
8365
|
-
this[offset] = (value & 0xff);
|
|
8366
|
-
return offset + 4
|
|
8367
|
-
};
|
|
8368
|
-
|
|
8369
|
-
Buffer.prototype.writeUint32BE =
|
|
8370
|
-
Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
|
|
8371
|
-
value = +value;
|
|
8372
|
-
offset = offset >>> 0;
|
|
8373
|
-
if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0);
|
|
8374
|
-
this[offset] = (value >>> 24);
|
|
8375
|
-
this[offset + 1] = (value >>> 16);
|
|
8376
|
-
this[offset + 2] = (value >>> 8);
|
|
8377
|
-
this[offset + 3] = (value & 0xff);
|
|
8378
|
-
return offset + 4
|
|
8379
|
-
};
|
|
6399
|
+
Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {
|
|
6400
|
+
return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
|
|
6401
|
+
});
|
|
6402
|
+
|
|
6403
|
+
Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {
|
|
6404
|
+
return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))
|
|
6405
|
+
});
|
|
8380
6406
|
|
|
8381
6407
|
Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
|
|
8382
6408
|
value = +value;
|
|
8383
6409
|
offset = offset >>> 0;
|
|
8384
6410
|
if (!noAssert) {
|
|
8385
|
-
|
|
6411
|
+
const limit = Math.pow(2, (8 * byteLength) - 1);
|
|
8386
6412
|
|
|
8387
6413
|
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
8388
6414
|
}
|
|
8389
6415
|
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
6416
|
+
let i = 0;
|
|
6417
|
+
let mul = 1;
|
|
6418
|
+
let sub = 0;
|
|
8393
6419
|
this[offset] = value & 0xFF;
|
|
8394
6420
|
while (++i < byteLength && (mul *= 0x100)) {
|
|
8395
6421
|
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
@@ -8405,14 +6431,14 @@ function requireBuffer () {
|
|
|
8405
6431
|
value = +value;
|
|
8406
6432
|
offset = offset >>> 0;
|
|
8407
6433
|
if (!noAssert) {
|
|
8408
|
-
|
|
6434
|
+
const limit = Math.pow(2, (8 * byteLength) - 1);
|
|
8409
6435
|
|
|
8410
6436
|
checkInt(this, value, offset, byteLength, limit - 1, -limit);
|
|
8411
6437
|
}
|
|
8412
6438
|
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
6439
|
+
let i = byteLength - 1;
|
|
6440
|
+
let mul = 1;
|
|
6441
|
+
let sub = 0;
|
|
8416
6442
|
this[offset + i] = value & 0xFF;
|
|
8417
6443
|
while (--i >= 0 && (mul *= 0x100)) {
|
|
8418
6444
|
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
@@ -8474,6 +6500,14 @@ function requireBuffer () {
|
|
|
8474
6500
|
return offset + 4
|
|
8475
6501
|
};
|
|
8476
6502
|
|
|
6503
|
+
Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {
|
|
6504
|
+
return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
|
|
6505
|
+
});
|
|
6506
|
+
|
|
6507
|
+
Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {
|
|
6508
|
+
return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))
|
|
6509
|
+
});
|
|
6510
|
+
|
|
8477
6511
|
function checkIEEE754 (buf, value, offset, ext, max, min) {
|
|
8478
6512
|
if (offset + ext > buf.length) throw new RangeError('Index out of range')
|
|
8479
6513
|
if (offset < 0) throw new RangeError('Index out of range')
|
|
@@ -8541,7 +6575,7 @@ function requireBuffer () {
|
|
|
8541
6575
|
end = target.length - targetStart + start;
|
|
8542
6576
|
}
|
|
8543
6577
|
|
|
8544
|
-
|
|
6578
|
+
const len = end - start;
|
|
8545
6579
|
|
|
8546
6580
|
if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {
|
|
8547
6581
|
// Use built-in when available, missing from IE11
|
|
@@ -8579,7 +6613,7 @@ function requireBuffer () {
|
|
|
8579
6613
|
throw new TypeError('Unknown encoding: ' + encoding)
|
|
8580
6614
|
}
|
|
8581
6615
|
if (val.length === 1) {
|
|
8582
|
-
|
|
6616
|
+
const code = val.charCodeAt(0);
|
|
8583
6617
|
if ((encoding === 'utf8' && code < 128) ||
|
|
8584
6618
|
encoding === 'latin1') {
|
|
8585
6619
|
// Fast path: If `val` fits into a single byte, use that numeric value.
|
|
@@ -8606,16 +6640,16 @@ function requireBuffer () {
|
|
|
8606
6640
|
|
|
8607
6641
|
if (!val) val = 0;
|
|
8608
6642
|
|
|
8609
|
-
|
|
6643
|
+
let i;
|
|
8610
6644
|
if (typeof val === 'number') {
|
|
8611
6645
|
for (i = start; i < end; ++i) {
|
|
8612
6646
|
this[i] = val;
|
|
8613
6647
|
}
|
|
8614
6648
|
} else {
|
|
8615
|
-
|
|
6649
|
+
const bytes = Buffer.isBuffer(val)
|
|
8616
6650
|
? val
|
|
8617
6651
|
: Buffer.from(val, encoding);
|
|
8618
|
-
|
|
6652
|
+
const len = bytes.length;
|
|
8619
6653
|
if (len === 0) {
|
|
8620
6654
|
throw new TypeError('The value "' + val +
|
|
8621
6655
|
'" is invalid for argument "value"')
|
|
@@ -8628,10 +6662,141 @@ function requireBuffer () {
|
|
|
8628
6662
|
return this
|
|
8629
6663
|
};
|
|
8630
6664
|
|
|
6665
|
+
// CUSTOM ERRORS
|
|
6666
|
+
// =============
|
|
6667
|
+
|
|
6668
|
+
// Simplified versions from Node, changed for Buffer-only usage
|
|
6669
|
+
const errors = {};
|
|
6670
|
+
function E (sym, getMessage, Base) {
|
|
6671
|
+
errors[sym] = class NodeError extends Base {
|
|
6672
|
+
constructor () {
|
|
6673
|
+
super();
|
|
6674
|
+
|
|
6675
|
+
Object.defineProperty(this, 'message', {
|
|
6676
|
+
value: getMessage.apply(this, arguments),
|
|
6677
|
+
writable: true,
|
|
6678
|
+
configurable: true
|
|
6679
|
+
});
|
|
6680
|
+
|
|
6681
|
+
// Add the error code to the name to include it in the stack trace.
|
|
6682
|
+
this.name = `${this.name} [${sym}]`;
|
|
6683
|
+
// Access the stack to generate the error message including the error code
|
|
6684
|
+
// from the name.
|
|
6685
|
+
this.stack; // eslint-disable-line no-unused-expressions
|
|
6686
|
+
// Reset the name to the actual name.
|
|
6687
|
+
delete this.name;
|
|
6688
|
+
}
|
|
6689
|
+
|
|
6690
|
+
get code () {
|
|
6691
|
+
return sym
|
|
6692
|
+
}
|
|
6693
|
+
|
|
6694
|
+
set code (value) {
|
|
6695
|
+
Object.defineProperty(this, 'code', {
|
|
6696
|
+
configurable: true,
|
|
6697
|
+
enumerable: true,
|
|
6698
|
+
value,
|
|
6699
|
+
writable: true
|
|
6700
|
+
});
|
|
6701
|
+
}
|
|
6702
|
+
|
|
6703
|
+
toString () {
|
|
6704
|
+
return `${this.name} [${sym}]: ${this.message}`
|
|
6705
|
+
}
|
|
6706
|
+
};
|
|
6707
|
+
}
|
|
6708
|
+
|
|
6709
|
+
E('ERR_BUFFER_OUT_OF_BOUNDS',
|
|
6710
|
+
function (name) {
|
|
6711
|
+
if (name) {
|
|
6712
|
+
return `${name} is outside of buffer bounds`
|
|
6713
|
+
}
|
|
6714
|
+
|
|
6715
|
+
return 'Attempt to access memory outside buffer bounds'
|
|
6716
|
+
}, RangeError);
|
|
6717
|
+
E('ERR_INVALID_ARG_TYPE',
|
|
6718
|
+
function (name, actual) {
|
|
6719
|
+
return `The "${name}" argument must be of type number. Received type ${typeof actual}`
|
|
6720
|
+
}, TypeError);
|
|
6721
|
+
E('ERR_OUT_OF_RANGE',
|
|
6722
|
+
function (str, range, input) {
|
|
6723
|
+
let msg = `The value of "${str}" is out of range.`;
|
|
6724
|
+
let received = input;
|
|
6725
|
+
if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
|
|
6726
|
+
received = addNumericalSeparator(String(input));
|
|
6727
|
+
} else if (typeof input === 'bigint') {
|
|
6728
|
+
received = String(input);
|
|
6729
|
+
if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
|
|
6730
|
+
received = addNumericalSeparator(received);
|
|
6731
|
+
}
|
|
6732
|
+
received += 'n';
|
|
6733
|
+
}
|
|
6734
|
+
msg += ` It must be ${range}. Received ${received}`;
|
|
6735
|
+
return msg
|
|
6736
|
+
}, RangeError);
|
|
6737
|
+
|
|
6738
|
+
function addNumericalSeparator (val) {
|
|
6739
|
+
let res = '';
|
|
6740
|
+
let i = val.length;
|
|
6741
|
+
const start = val[0] === '-' ? 1 : 0;
|
|
6742
|
+
for (; i >= start + 4; i -= 3) {
|
|
6743
|
+
res = `_${val.slice(i - 3, i)}${res}`;
|
|
6744
|
+
}
|
|
6745
|
+
return `${val.slice(0, i)}${res}`
|
|
6746
|
+
}
|
|
6747
|
+
|
|
6748
|
+
// CHECK FUNCTIONS
|
|
6749
|
+
// ===============
|
|
6750
|
+
|
|
6751
|
+
function checkBounds (buf, offset, byteLength) {
|
|
6752
|
+
validateNumber(offset, 'offset');
|
|
6753
|
+
if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
|
|
6754
|
+
boundsError(offset, buf.length - (byteLength + 1));
|
|
6755
|
+
}
|
|
6756
|
+
}
|
|
6757
|
+
|
|
6758
|
+
function checkIntBI (value, min, max, buf, offset, byteLength) {
|
|
6759
|
+
if (value > max || value < min) {
|
|
6760
|
+
const n = typeof min === 'bigint' ? 'n' : '';
|
|
6761
|
+
let range;
|
|
6762
|
+
{
|
|
6763
|
+
if (min === 0 || min === BigInt(0)) {
|
|
6764
|
+
range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
|
|
6765
|
+
} else {
|
|
6766
|
+
range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +
|
|
6767
|
+
`${(byteLength + 1) * 8 - 1}${n}`;
|
|
6768
|
+
}
|
|
6769
|
+
}
|
|
6770
|
+
throw new errors.ERR_OUT_OF_RANGE('value', range, value)
|
|
6771
|
+
}
|
|
6772
|
+
checkBounds(buf, offset, byteLength);
|
|
6773
|
+
}
|
|
6774
|
+
|
|
6775
|
+
function validateNumber (value, name) {
|
|
6776
|
+
if (typeof value !== 'number') {
|
|
6777
|
+
throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)
|
|
6778
|
+
}
|
|
6779
|
+
}
|
|
6780
|
+
|
|
6781
|
+
function boundsError (value, length, type) {
|
|
6782
|
+
if (Math.floor(value) !== value) {
|
|
6783
|
+
validateNumber(value, type);
|
|
6784
|
+
throw new errors.ERR_OUT_OF_RANGE('offset', 'an integer', value)
|
|
6785
|
+
}
|
|
6786
|
+
|
|
6787
|
+
if (length < 0) {
|
|
6788
|
+
throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()
|
|
6789
|
+
}
|
|
6790
|
+
|
|
6791
|
+
throw new errors.ERR_OUT_OF_RANGE('offset',
|
|
6792
|
+
`>= ${0} and <= ${length}`,
|
|
6793
|
+
value)
|
|
6794
|
+
}
|
|
6795
|
+
|
|
8631
6796
|
// HELPER FUNCTIONS
|
|
8632
6797
|
// ================
|
|
8633
6798
|
|
|
8634
|
-
|
|
6799
|
+
const INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
|
|
8635
6800
|
|
|
8636
6801
|
function base64clean (str) {
|
|
8637
6802
|
// Node takes equal signs as end of the Base64 encoding
|
|
@@ -8649,12 +6814,12 @@ function requireBuffer () {
|
|
|
8649
6814
|
|
|
8650
6815
|
function utf8ToBytes (string, units) {
|
|
8651
6816
|
units = units || Infinity;
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
|
|
6817
|
+
let codePoint;
|
|
6818
|
+
const length = string.length;
|
|
6819
|
+
let leadSurrogate = null;
|
|
6820
|
+
const bytes = [];
|
|
8656
6821
|
|
|
8657
|
-
for (
|
|
6822
|
+
for (let i = 0; i < length; ++i) {
|
|
8658
6823
|
codePoint = string.charCodeAt(i);
|
|
8659
6824
|
|
|
8660
6825
|
// is surrogate component
|
|
@@ -8728,8 +6893,8 @@ function requireBuffer () {
|
|
|
8728
6893
|
}
|
|
8729
6894
|
|
|
8730
6895
|
function asciiToBytes (str) {
|
|
8731
|
-
|
|
8732
|
-
for (
|
|
6896
|
+
const byteArray = [];
|
|
6897
|
+
for (let i = 0; i < str.length; ++i) {
|
|
8733
6898
|
// Node's code seems to be doing this and not & 0x7F..
|
|
8734
6899
|
byteArray.push(str.charCodeAt(i) & 0xFF);
|
|
8735
6900
|
}
|
|
@@ -8737,9 +6902,9 @@ function requireBuffer () {
|
|
|
8737
6902
|
}
|
|
8738
6903
|
|
|
8739
6904
|
function utf16leToBytes (str, units) {
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
for (
|
|
6905
|
+
let c, hi, lo;
|
|
6906
|
+
const byteArray = [];
|
|
6907
|
+
for (let i = 0; i < str.length; ++i) {
|
|
8743
6908
|
if ((units -= 2) < 0) break
|
|
8744
6909
|
|
|
8745
6910
|
c = str.charCodeAt(i);
|
|
@@ -8757,7 +6922,8 @@ function requireBuffer () {
|
|
|
8757
6922
|
}
|
|
8758
6923
|
|
|
8759
6924
|
function blitBuffer (src, dst, offset, length) {
|
|
8760
|
-
|
|
6925
|
+
let i;
|
|
6926
|
+
for (i = 0; i < length; ++i) {
|
|
8761
6927
|
if ((i + offset >= dst.length) || (i >= src.length)) break
|
|
8762
6928
|
dst[i + offset] = src[i];
|
|
8763
6929
|
}
|
|
@@ -8779,23 +6945,34 @@ function requireBuffer () {
|
|
|
8779
6945
|
|
|
8780
6946
|
// Create lookup table for `toString('hex')`
|
|
8781
6947
|
// See: https://github.com/feross/buffer/issues/219
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
for (
|
|
8786
|
-
|
|
8787
|
-
for (
|
|
6948
|
+
const hexSliceLookupTable = (function () {
|
|
6949
|
+
const alphabet = '0123456789abcdef';
|
|
6950
|
+
const table = new Array(256);
|
|
6951
|
+
for (let i = 0; i < 16; ++i) {
|
|
6952
|
+
const i16 = i * 16;
|
|
6953
|
+
for (let j = 0; j < 16; ++j) {
|
|
8788
6954
|
table[i16 + j] = alphabet[i] + alphabet[j];
|
|
8789
6955
|
}
|
|
8790
6956
|
}
|
|
8791
6957
|
return table
|
|
8792
|
-
})();
|
|
6958
|
+
})();
|
|
6959
|
+
|
|
6960
|
+
// Return not function with Error if BigInt not supported
|
|
6961
|
+
function defineBigIntMethod (fn) {
|
|
6962
|
+
return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn
|
|
6963
|
+
}
|
|
6964
|
+
|
|
6965
|
+
function BufferBigIntNotDefined () {
|
|
6966
|
+
throw new Error('BigInt not supported')
|
|
6967
|
+
}
|
|
8793
6968
|
} (buffer));
|
|
8794
6969
|
return buffer;
|
|
8795
6970
|
}
|
|
8796
6971
|
|
|
8797
6972
|
var bufferExports = requireBuffer();
|
|
8798
6973
|
|
|
6974
|
+
var dist = {};
|
|
6975
|
+
|
|
8799
6976
|
var Codecs = {};
|
|
8800
6977
|
|
|
8801
6978
|
var Frames = {};
|
|
@@ -8805,7 +6982,7 @@ var hasRequiredFrames;
|
|
|
8805
6982
|
function requireFrames () {
|
|
8806
6983
|
if (hasRequiredFrames) return Frames;
|
|
8807
6984
|
hasRequiredFrames = 1;
|
|
8808
|
-
(function (exports) {
|
|
6985
|
+
(function (exports$1) {
|
|
8809
6986
|
/*
|
|
8810
6987
|
* Copyright 2021-2022 the original author or authors.
|
|
8811
6988
|
*
|
|
@@ -8821,8 +6998,8 @@ function requireFrames () {
|
|
|
8821
6998
|
* See the License for the specific language governing permissions and
|
|
8822
6999
|
* limitations under the License.
|
|
8823
7000
|
*/
|
|
8824
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8825
|
-
exports.Frame = exports.Lengths = exports.Flags = exports.FrameTypes = void 0;
|
|
7001
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
7002
|
+
exports$1.Frame = exports$1.Lengths = exports$1.Flags = exports$1.FrameTypes = void 0;
|
|
8826
7003
|
var FrameTypes;
|
|
8827
7004
|
(function (FrameTypes) {
|
|
8828
7005
|
FrameTypes[FrameTypes["RESERVED"] = 0] = "RESERVED";
|
|
@@ -8841,7 +7018,7 @@ function requireFrames () {
|
|
|
8841
7018
|
FrameTypes[FrameTypes["RESUME"] = 13] = "RESUME";
|
|
8842
7019
|
FrameTypes[FrameTypes["RESUME_OK"] = 14] = "RESUME_OK";
|
|
8843
7020
|
FrameTypes[FrameTypes["EXT"] = 63] = "EXT";
|
|
8844
|
-
})(FrameTypes = exports.FrameTypes || (exports.FrameTypes = {}));
|
|
7021
|
+
})(FrameTypes = exports$1.FrameTypes || (exports$1.FrameTypes = {}));
|
|
8845
7022
|
(function (Flags) {
|
|
8846
7023
|
Flags[Flags["NONE"] = 0] = "NONE";
|
|
8847
7024
|
Flags[Flags["COMPLETE"] = 64] = "COMPLETE";
|
|
@@ -8852,7 +7029,7 @@ function requireFrames () {
|
|
|
8852
7029
|
Flags[Flags["NEXT"] = 32] = "NEXT";
|
|
8853
7030
|
Flags[Flags["RESPOND"] = 128] = "RESPOND";
|
|
8854
7031
|
Flags[Flags["RESUME_ENABLE"] = 128] = "RESUME_ENABLE";
|
|
8855
|
-
})(exports.Flags || (exports.Flags = {}));
|
|
7032
|
+
})(exports$1.Flags || (exports$1.Flags = {}));
|
|
8856
7033
|
(function (Flags) {
|
|
8857
7034
|
function hasMetadata(flags) {
|
|
8858
7035
|
return (flags & Flags.METADATA) === Flags.METADATA;
|
|
@@ -8886,13 +7063,13 @@ function requireFrames () {
|
|
|
8886
7063
|
return (flags & Flags.RESUME_ENABLE) === Flags.RESUME_ENABLE;
|
|
8887
7064
|
}
|
|
8888
7065
|
Flags.hasResume = hasResume;
|
|
8889
|
-
})(exports.Flags || (exports.Flags = {}));
|
|
7066
|
+
})(exports$1.Flags || (exports$1.Flags = {}));
|
|
8890
7067
|
(function (Lengths) {
|
|
8891
7068
|
Lengths[Lengths["FRAME"] = 3] = "FRAME";
|
|
8892
7069
|
Lengths[Lengths["HEADER"] = 6] = "HEADER";
|
|
8893
7070
|
Lengths[Lengths["METADATA"] = 3] = "METADATA";
|
|
8894
7071
|
Lengths[Lengths["REQUEST"] = 3] = "REQUEST";
|
|
8895
|
-
})(exports.Lengths || (exports.Lengths = {}));
|
|
7072
|
+
})(exports$1.Lengths || (exports$1.Lengths = {}));
|
|
8896
7073
|
(function (Frame) {
|
|
8897
7074
|
function isConnection(frame) {
|
|
8898
7075
|
return frame.streamId === 0;
|
|
@@ -8903,7 +7080,7 @@ function requireFrames () {
|
|
|
8903
7080
|
frame.type <= FrameTypes.REQUEST_CHANNEL);
|
|
8904
7081
|
}
|
|
8905
7082
|
Frame.isRequest = isRequest;
|
|
8906
|
-
})(exports.Frame || (exports.Frame = {}));
|
|
7083
|
+
})(exports$1.Frame || (exports$1.Frame = {}));
|
|
8907
7084
|
|
|
8908
7085
|
} (Frames));
|
|
8909
7086
|
return Frames;
|
|
@@ -8914,7 +7091,7 @@ var hasRequiredCodecs;
|
|
|
8914
7091
|
function requireCodecs () {
|
|
8915
7092
|
if (hasRequiredCodecs) return Codecs;
|
|
8916
7093
|
hasRequiredCodecs = 1;
|
|
8917
|
-
(function (exports) {
|
|
7094
|
+
(function (exports$1) {
|
|
8918
7095
|
var __generator = (Codecs && Codecs.__generator) || function (thisArg, body) {
|
|
8919
7096
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
8920
7097
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
@@ -8942,22 +7119,22 @@ function requireCodecs () {
|
|
|
8942
7119
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
8943
7120
|
}
|
|
8944
7121
|
};
|
|
8945
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8946
|
-
exports.Deserializer = exports.sizeOfFrame = exports.serializeFrame = exports.deserializeFrame = exports.serializeFrameWithLength = exports.deserializeFrames = exports.deserializeFrameWithLength = exports.writeUInt64BE = exports.readUInt64BE = exports.writeUInt24BE = exports.readUInt24BE = exports.MAX_VERSION = exports.MAX_TTL = exports.MAX_STREAM_ID = exports.MAX_RESUME_LENGTH = exports.MAX_REQUEST_N = exports.MAX_REQUEST_COUNT = exports.MAX_MIME_LENGTH = exports.MAX_METADATA_LENGTH = exports.MAX_LIFETIME = exports.MAX_KEEPALIVE = exports.MAX_CODE = exports.FRAME_TYPE_OFFFSET = exports.FLAGS_MASK = void 0;
|
|
7122
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
7123
|
+
exports$1.Deserializer = exports$1.sizeOfFrame = exports$1.serializeFrame = exports$1.deserializeFrame = exports$1.serializeFrameWithLength = exports$1.deserializeFrames = exports$1.deserializeFrameWithLength = exports$1.writeUInt64BE = exports$1.readUInt64BE = exports$1.writeUInt24BE = exports$1.readUInt24BE = exports$1.MAX_VERSION = exports$1.MAX_TTL = exports$1.MAX_STREAM_ID = exports$1.MAX_RESUME_LENGTH = exports$1.MAX_REQUEST_N = exports$1.MAX_REQUEST_COUNT = exports$1.MAX_MIME_LENGTH = exports$1.MAX_METADATA_LENGTH = exports$1.MAX_LIFETIME = exports$1.MAX_KEEPALIVE = exports$1.MAX_CODE = exports$1.FRAME_TYPE_OFFFSET = exports$1.FLAGS_MASK = void 0;
|
|
8947
7124
|
var Frames_1 = requireFrames();
|
|
8948
|
-
exports.FLAGS_MASK = 0x3ff; // low 10 bits
|
|
8949
|
-
exports.FRAME_TYPE_OFFFSET = 10; // frame type is offset 10 bytes within the uint16 containing type + flags
|
|
8950
|
-
exports.MAX_CODE = 0x7fffffff; // uint31
|
|
8951
|
-
exports.MAX_KEEPALIVE = 0x7fffffff; // uint31
|
|
8952
|
-
exports.MAX_LIFETIME = 0x7fffffff; // uint31
|
|
8953
|
-
exports.MAX_METADATA_LENGTH = 0xffffff; // uint24
|
|
8954
|
-
exports.MAX_MIME_LENGTH = 0xff; // int8
|
|
8955
|
-
exports.MAX_REQUEST_COUNT = 0x7fffffff; // uint31
|
|
8956
|
-
exports.MAX_REQUEST_N = 0x7fffffff; // uint31
|
|
8957
|
-
exports.MAX_RESUME_LENGTH = 0xffff; // uint16
|
|
8958
|
-
exports.MAX_STREAM_ID = 0x7fffffff; // uint31
|
|
8959
|
-
exports.MAX_TTL = 0x7fffffff; // uint31
|
|
8960
|
-
exports.MAX_VERSION = 0xffff; // uint16
|
|
7125
|
+
exports$1.FLAGS_MASK = 0x3ff; // low 10 bits
|
|
7126
|
+
exports$1.FRAME_TYPE_OFFFSET = 10; // frame type is offset 10 bytes within the uint16 containing type + flags
|
|
7127
|
+
exports$1.MAX_CODE = 0x7fffffff; // uint31
|
|
7128
|
+
exports$1.MAX_KEEPALIVE = 0x7fffffff; // uint31
|
|
7129
|
+
exports$1.MAX_LIFETIME = 0x7fffffff; // uint31
|
|
7130
|
+
exports$1.MAX_METADATA_LENGTH = 0xffffff; // uint24
|
|
7131
|
+
exports$1.MAX_MIME_LENGTH = 0xff; // int8
|
|
7132
|
+
exports$1.MAX_REQUEST_COUNT = 0x7fffffff; // uint31
|
|
7133
|
+
exports$1.MAX_REQUEST_N = 0x7fffffff; // uint31
|
|
7134
|
+
exports$1.MAX_RESUME_LENGTH = 0xffff; // uint16
|
|
7135
|
+
exports$1.MAX_STREAM_ID = 0x7fffffff; // uint31
|
|
7136
|
+
exports$1.MAX_TTL = 0x7fffffff; // uint31
|
|
7137
|
+
exports$1.MAX_VERSION = 0xffff; // uint16
|
|
8961
7138
|
/**
|
|
8962
7139
|
* Mimimum value that would overflow bitwise operators (2^32).
|
|
8963
7140
|
*/
|
|
@@ -8971,7 +7148,7 @@ function requireCodecs () {
|
|
|
8971
7148
|
var val3 = buffer.readUInt8(offset + 2);
|
|
8972
7149
|
return val1 | val2 | val3;
|
|
8973
7150
|
}
|
|
8974
|
-
exports.readUInt24BE = readUInt24BE;
|
|
7151
|
+
exports$1.readUInt24BE = readUInt24BE;
|
|
8975
7152
|
/**
|
|
8976
7153
|
* Writes a uint24 to a buffer starting at the given offset, returning the
|
|
8977
7154
|
* offset of the next byte.
|
|
@@ -8981,7 +7158,7 @@ function requireCodecs () {
|
|
|
8981
7158
|
offset = buffer.writeUInt8((value >>> 8) & 0xff, offset); // 2nd byte
|
|
8982
7159
|
return buffer.writeUInt8(value & 0xff, offset); // 1st byte
|
|
8983
7160
|
}
|
|
8984
|
-
exports.writeUInt24BE = writeUInt24BE;
|
|
7161
|
+
exports$1.writeUInt24BE = writeUInt24BE;
|
|
8985
7162
|
/**
|
|
8986
7163
|
* Read a uint64 (technically supports up to 53 bits per JS number
|
|
8987
7164
|
* representation).
|
|
@@ -8991,7 +7168,7 @@ function requireCodecs () {
|
|
|
8991
7168
|
var low = buffer.readUInt32BE(offset + 4);
|
|
8992
7169
|
return high * BITWISE_OVERFLOW + low;
|
|
8993
7170
|
}
|
|
8994
|
-
exports.readUInt64BE = readUInt64BE;
|
|
7171
|
+
exports$1.readUInt64BE = readUInt64BE;
|
|
8995
7172
|
/**
|
|
8996
7173
|
* Write a uint64 (technically supports up to 53 bits per JS number
|
|
8997
7174
|
* representation).
|
|
@@ -9002,7 +7179,7 @@ function requireCodecs () {
|
|
|
9002
7179
|
offset = buffer.writeUInt32BE(high, offset); // first half of uint64
|
|
9003
7180
|
return buffer.writeUInt32BE(low, offset); // second half of uint64
|
|
9004
7181
|
}
|
|
9005
|
-
exports.writeUInt64BE = writeUInt64BE;
|
|
7182
|
+
exports$1.writeUInt64BE = writeUInt64BE;
|
|
9006
7183
|
/**
|
|
9007
7184
|
* Frame header is:
|
|
9008
7185
|
* - stream id (uint32 = 4)
|
|
@@ -9020,7 +7197,7 @@ function requireCodecs () {
|
|
|
9020
7197
|
var frameLength = readUInt24BE(buffer, 0);
|
|
9021
7198
|
return deserializeFrame(buffer.slice(UINT24_SIZE, UINT24_SIZE + frameLength));
|
|
9022
7199
|
}
|
|
9023
|
-
exports.deserializeFrameWithLength = deserializeFrameWithLength;
|
|
7200
|
+
exports$1.deserializeFrameWithLength = deserializeFrameWithLength;
|
|
9024
7201
|
/**
|
|
9025
7202
|
* Given a buffer that may contain zero or more length-prefixed frames followed
|
|
9026
7203
|
* by zero or more bytes of a (partial) subsequent frame, returns an array of
|
|
@@ -9053,7 +7230,7 @@ function requireCodecs () {
|
|
|
9053
7230
|
}
|
|
9054
7231
|
});
|
|
9055
7232
|
}
|
|
9056
|
-
exports.deserializeFrames = deserializeFrames;
|
|
7233
|
+
exports$1.deserializeFrames = deserializeFrames;
|
|
9057
7234
|
/**
|
|
9058
7235
|
* Writes a frame to a buffer with a length prefix.
|
|
9059
7236
|
*/
|
|
@@ -9064,7 +7241,7 @@ function requireCodecs () {
|
|
|
9064
7241
|
buffer.copy(lengthPrefixed, UINT24_SIZE);
|
|
9065
7242
|
return lengthPrefixed;
|
|
9066
7243
|
}
|
|
9067
|
-
exports.serializeFrameWithLength = serializeFrameWithLength;
|
|
7244
|
+
exports$1.serializeFrameWithLength = serializeFrameWithLength;
|
|
9068
7245
|
/**
|
|
9069
7246
|
* Read a frame from the buffer.
|
|
9070
7247
|
*/
|
|
@@ -9079,8 +7256,8 @@ function requireCodecs () {
|
|
|
9079
7256
|
// );
|
|
9080
7257
|
var typeAndFlags = buffer.readUInt16BE(offset);
|
|
9081
7258
|
offset += 2;
|
|
9082
|
-
var type = typeAndFlags >>> exports.FRAME_TYPE_OFFFSET; // keep highest 6 bits
|
|
9083
|
-
var flags = typeAndFlags & exports.FLAGS_MASK; // keep lowest 10 bits
|
|
7259
|
+
var type = typeAndFlags >>> exports$1.FRAME_TYPE_OFFFSET; // keep highest 6 bits
|
|
7260
|
+
var flags = typeAndFlags & exports$1.FLAGS_MASK; // keep lowest 10 bits
|
|
9084
7261
|
switch (type) {
|
|
9085
7262
|
case Frames_1.FrameTypes.SETUP:
|
|
9086
7263
|
return deserializeSetupFrame(buffer, streamId, flags);
|
|
@@ -9117,7 +7294,7 @@ function requireCodecs () {
|
|
|
9117
7294
|
// );
|
|
9118
7295
|
}
|
|
9119
7296
|
}
|
|
9120
|
-
exports.deserializeFrame = deserializeFrame;
|
|
7297
|
+
exports$1.deserializeFrame = deserializeFrame;
|
|
9121
7298
|
/**
|
|
9122
7299
|
* Convert the frame to a (binary) buffer.
|
|
9123
7300
|
*/
|
|
@@ -9156,7 +7333,7 @@ function requireCodecs () {
|
|
|
9156
7333
|
// );
|
|
9157
7334
|
}
|
|
9158
7335
|
}
|
|
9159
|
-
exports.serializeFrame = serializeFrame;
|
|
7336
|
+
exports$1.serializeFrame = serializeFrame;
|
|
9160
7337
|
/**
|
|
9161
7338
|
* Byte size of frame without size prefix
|
|
9162
7339
|
*/
|
|
@@ -9195,7 +7372,7 @@ function requireCodecs () {
|
|
|
9195
7372
|
// );
|
|
9196
7373
|
}
|
|
9197
7374
|
}
|
|
9198
|
-
exports.sizeOfFrame = sizeOfFrame;
|
|
7375
|
+
exports$1.sizeOfFrame = sizeOfFrame;
|
|
9199
7376
|
/**
|
|
9200
7377
|
* Writes a SETUP frame into a new buffer and returns it.
|
|
9201
7378
|
*
|
|
@@ -9830,7 +8007,7 @@ function requireCodecs () {
|
|
|
9830
8007
|
function writeHeader(frame, buffer) {
|
|
9831
8008
|
var offset = buffer.writeInt32BE(frame.streamId, 0);
|
|
9832
8009
|
// shift frame to high 6 bits, extract lowest 10 bits from flags
|
|
9833
|
-
return buffer.writeUInt16BE((frame.type << exports.FRAME_TYPE_OFFFSET) | (frame.flags & exports.FLAGS_MASK), offset);
|
|
8010
|
+
return buffer.writeUInt16BE((frame.type << exports$1.FRAME_TYPE_OFFFSET) | (frame.flags & exports$1.FLAGS_MASK), offset);
|
|
9834
8011
|
}
|
|
9835
8012
|
/**
|
|
9836
8013
|
* Determine the length of the payload section of a frame. Only applies to
|
|
@@ -9911,7 +8088,7 @@ function requireCodecs () {
|
|
|
9911
8088
|
};
|
|
9912
8089
|
return Deserializer;
|
|
9913
8090
|
}());
|
|
9914
|
-
exports.Deserializer = Deserializer;
|
|
8091
|
+
exports$1.Deserializer = Deserializer;
|
|
9915
8092
|
|
|
9916
8093
|
} (Codecs));
|
|
9917
8094
|
return Codecs;
|
|
@@ -10057,7 +8234,7 @@ var hasRequiredErrors;
|
|
|
10057
8234
|
function requireErrors () {
|
|
10058
8235
|
if (hasRequiredErrors) return Errors;
|
|
10059
8236
|
hasRequiredErrors = 1;
|
|
10060
|
-
(function (exports) {
|
|
8237
|
+
(function (exports$1) {
|
|
10061
8238
|
/*
|
|
10062
8239
|
* Copyright 2021-2022 the original author or authors.
|
|
10063
8240
|
*
|
|
@@ -10088,8 +8265,8 @@ function requireErrors () {
|
|
|
10088
8265
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
10089
8266
|
};
|
|
10090
8267
|
})();
|
|
10091
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10092
|
-
exports.ErrorCodes = exports.RSocketError = void 0;
|
|
8268
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
8269
|
+
exports$1.ErrorCodes = exports$1.RSocketError = void 0;
|
|
10093
8270
|
var RSocketError = /** @class */ (function (_super) {
|
|
10094
8271
|
__extends(RSocketError, _super);
|
|
10095
8272
|
function RSocketError(code, message) {
|
|
@@ -10099,7 +8276,7 @@ function requireErrors () {
|
|
|
10099
8276
|
}
|
|
10100
8277
|
return RSocketError;
|
|
10101
8278
|
}(Error));
|
|
10102
|
-
exports.RSocketError = RSocketError;
|
|
8279
|
+
exports$1.RSocketError = RSocketError;
|
|
10103
8280
|
(function (ErrorCodes) {
|
|
10104
8281
|
ErrorCodes[ErrorCodes["RESERVED"] = 0] = "RESERVED";
|
|
10105
8282
|
ErrorCodes[ErrorCodes["INVALID_SETUP"] = 1] = "INVALID_SETUP";
|
|
@@ -10113,7 +8290,7 @@ function requireErrors () {
|
|
|
10113
8290
|
ErrorCodes[ErrorCodes["CANCELED"] = 515] = "CANCELED";
|
|
10114
8291
|
ErrorCodes[ErrorCodes["INVALID"] = 516] = "INVALID";
|
|
10115
8292
|
ErrorCodes[ErrorCodes["RESERVED_EXTENSION"] = 4294967295] = "RESERVED_EXTENSION";
|
|
10116
|
-
})(exports.ErrorCodes || (exports.ErrorCodes = {}));
|
|
8293
|
+
})(exports$1.ErrorCodes || (exports$1.ErrorCodes = {}));
|
|
10117
8294
|
|
|
10118
8295
|
} (Errors));
|
|
10119
8296
|
return Errors;
|
|
@@ -10155,7 +8332,7 @@ var hasRequiredClientServerMultiplexerDemultiplexer;
|
|
|
10155
8332
|
function requireClientServerMultiplexerDemultiplexer () {
|
|
10156
8333
|
if (hasRequiredClientServerMultiplexerDemultiplexer) return ClientServerMultiplexerDemultiplexer;
|
|
10157
8334
|
hasRequiredClientServerMultiplexerDemultiplexer = 1;
|
|
10158
|
-
(function (exports) {
|
|
8335
|
+
(function (exports$1) {
|
|
10159
8336
|
/*
|
|
10160
8337
|
* Copyright 2021-2022 the original author or authors.
|
|
10161
8338
|
*
|
|
@@ -10222,8 +8399,8 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
10222
8399
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
10223
8400
|
}
|
|
10224
8401
|
};
|
|
10225
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10226
|
-
exports.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = exports.ResumableClientServerInputMultiplexerDemultiplexer = exports.ClientServerInputMultiplexerDemultiplexer = exports.StreamIdGenerator = void 0;
|
|
8402
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
8403
|
+
exports$1.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = exports$1.ResumableClientServerInputMultiplexerDemultiplexer = exports$1.ClientServerInputMultiplexerDemultiplexer = exports$1.StreamIdGenerator = void 0;
|
|
10227
8404
|
var _1 = requireDist();
|
|
10228
8405
|
var Deferred_1 = requireDeferred();
|
|
10229
8406
|
var Errors_1 = requireErrors();
|
|
@@ -10246,7 +8423,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
10246
8423
|
};
|
|
10247
8424
|
return StreamIdGeneratorImpl;
|
|
10248
8425
|
}());
|
|
10249
|
-
})(exports.StreamIdGenerator || (exports.StreamIdGenerator = {}));
|
|
8426
|
+
})(exports$1.StreamIdGenerator || (exports$1.StreamIdGenerator = {}));
|
|
10250
8427
|
var ClientServerInputMultiplexerDemultiplexer = /** @class */ (function (_super) {
|
|
10251
8428
|
__extends(ClientServerInputMultiplexerDemultiplexer, _super);
|
|
10252
8429
|
function ClientServerInputMultiplexerDemultiplexer(streamIdSupplier, outbound, closeable) {
|
|
@@ -10335,7 +8512,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
10335
8512
|
};
|
|
10336
8513
|
return ClientServerInputMultiplexerDemultiplexer;
|
|
10337
8514
|
}(Deferred_1.Deferred));
|
|
10338
|
-
exports.ClientServerInputMultiplexerDemultiplexer = ClientServerInputMultiplexerDemultiplexer;
|
|
8515
|
+
exports$1.ClientServerInputMultiplexerDemultiplexer = ClientServerInputMultiplexerDemultiplexer;
|
|
10339
8516
|
var ResumableClientServerInputMultiplexerDemultiplexer = /** @class */ (function (_super) {
|
|
10340
8517
|
__extends(ResumableClientServerInputMultiplexerDemultiplexer, _super);
|
|
10341
8518
|
function ResumableClientServerInputMultiplexerDemultiplexer(streamIdSupplier, outbound, closeable, frameStore, token, sessionStoreOrReconnector, sessionTimeout) {
|
|
@@ -10492,7 +8669,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
10492
8669
|
};
|
|
10493
8670
|
return ResumableClientServerInputMultiplexerDemultiplexer;
|
|
10494
8671
|
}(ClientServerInputMultiplexerDemultiplexer));
|
|
10495
|
-
exports.ResumableClientServerInputMultiplexerDemultiplexer = ResumableClientServerInputMultiplexerDemultiplexer;
|
|
8672
|
+
exports$1.ResumableClientServerInputMultiplexerDemultiplexer = ResumableClientServerInputMultiplexerDemultiplexer;
|
|
10496
8673
|
var ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = /** @class */ (function () {
|
|
10497
8674
|
function ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer(outbound, closeable, delegate) {
|
|
10498
8675
|
this.outbound = outbound;
|
|
@@ -10549,7 +8726,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
10549
8726
|
};
|
|
10550
8727
|
return ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer;
|
|
10551
8728
|
}());
|
|
10552
|
-
exports.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer;
|
|
8729
|
+
exports$1.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer;
|
|
10553
8730
|
|
|
10554
8731
|
} (ClientServerMultiplexerDemultiplexer));
|
|
10555
8732
|
return ClientServerMultiplexerDemultiplexer;
|
|
@@ -13535,7 +11712,7 @@ var hasRequiredDist;
|
|
|
13535
11712
|
function requireDist () {
|
|
13536
11713
|
if (hasRequiredDist) return dist;
|
|
13537
11714
|
hasRequiredDist = 1;
|
|
13538
|
-
(function (exports) {
|
|
11715
|
+
(function (exports$1) {
|
|
13539
11716
|
/*
|
|
13540
11717
|
* Copyright 2021-2022 the original author or authors.
|
|
13541
11718
|
*
|
|
@@ -13558,19 +11735,19 @@ function requireDist () {
|
|
|
13558
11735
|
if (k2 === undefined) k2 = k;
|
|
13559
11736
|
o[k2] = m[k];
|
|
13560
11737
|
}));
|
|
13561
|
-
var __exportStar = (dist && dist.__exportStar) || function(m, exports) {
|
|
13562
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11738
|
+
var __exportStar = (dist && dist.__exportStar) || function(m, exports$1) {
|
|
11739
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
13563
11740
|
};
|
|
13564
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13565
|
-
__exportStar(requireCodecs(), exports);
|
|
13566
|
-
__exportStar(requireCommon(), exports);
|
|
13567
|
-
__exportStar(requireDeferred(), exports);
|
|
13568
|
-
__exportStar(requireErrors(), exports);
|
|
13569
|
-
__exportStar(requireFrames(), exports);
|
|
13570
|
-
__exportStar(requireRSocket(), exports);
|
|
13571
|
-
__exportStar(requireRSocketConnector(), exports);
|
|
13572
|
-
__exportStar(requireRSocketServer(), exports);
|
|
13573
|
-
__exportStar(requireTransport(), exports);
|
|
11741
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
11742
|
+
__exportStar(requireCodecs(), exports$1);
|
|
11743
|
+
__exportStar(requireCommon(), exports$1);
|
|
11744
|
+
__exportStar(requireDeferred(), exports$1);
|
|
11745
|
+
__exportStar(requireErrors(), exports$1);
|
|
11746
|
+
__exportStar(requireFrames(), exports$1);
|
|
11747
|
+
__exportStar(requireRSocket(), exports$1);
|
|
11748
|
+
__exportStar(requireRSocketConnector(), exports$1);
|
|
11749
|
+
__exportStar(requireRSocketServer(), exports$1);
|
|
11750
|
+
__exportStar(requireTransport(), exports$1);
|
|
13574
11751
|
|
|
13575
11752
|
} (dist));
|
|
13576
11753
|
return dist;
|
|
@@ -13578,7 +11755,7 @@ function requireDist () {
|
|
|
13578
11755
|
|
|
13579
11756
|
var distExports = requireDist();
|
|
13580
11757
|
|
|
13581
|
-
var version = "1.
|
|
11758
|
+
var version = "1.45.0";
|
|
13582
11759
|
var PACKAGE = {
|
|
13583
11760
|
version: version};
|
|
13584
11761
|
|
|
@@ -13649,6 +11826,16 @@ class DataStream extends BaseObserver {
|
|
|
13649
11826
|
* @returns a Data payload or Null if the stream closed.
|
|
13650
11827
|
*/
|
|
13651
11828
|
async read() {
|
|
11829
|
+
if (this.closed) {
|
|
11830
|
+
return null;
|
|
11831
|
+
}
|
|
11832
|
+
// Wait for any pending processing to complete first.
|
|
11833
|
+
// This ensures we register our listener before calling processQueue(),
|
|
11834
|
+
// avoiding a race where processQueue() sees no reader and returns early.
|
|
11835
|
+
if (this.processingPromise) {
|
|
11836
|
+
await this.processingPromise;
|
|
11837
|
+
}
|
|
11838
|
+
// Re-check after await - stream may have closed while we were waiting
|
|
13652
11839
|
if (this.closed) {
|
|
13653
11840
|
return null;
|
|
13654
11841
|
}
|
|
@@ -13688,7 +11875,7 @@ class DataStream extends BaseObserver {
|
|
|
13688
11875
|
}
|
|
13689
11876
|
const promise = (this.processingPromise = this._processQueue());
|
|
13690
11877
|
promise.finally(() => {
|
|
13691
|
-
|
|
11878
|
+
this.processingPromise = null;
|
|
13692
11879
|
});
|
|
13693
11880
|
return promise;
|
|
13694
11881
|
}
|
|
@@ -13720,7 +11907,6 @@ class DataStream extends BaseObserver {
|
|
|
13720
11907
|
this.notifyDataAdded = null;
|
|
13721
11908
|
}
|
|
13722
11909
|
if (this.dataQueue.length > 0) {
|
|
13723
|
-
// Next tick
|
|
13724
11910
|
setTimeout(() => this.processQueue());
|
|
13725
11911
|
}
|
|
13726
11912
|
}
|
|
@@ -14100,7 +12286,7 @@ class AbstractRemote {
|
|
|
14100
12286
|
else {
|
|
14101
12287
|
contents = JSON.stringify(js);
|
|
14102
12288
|
}
|
|
14103
|
-
return bufferExports
|
|
12289
|
+
return bufferExports.Buffer.from(contents);
|
|
14104
12290
|
}
|
|
14105
12291
|
const syncQueueRequestSize = fetchStrategy == FetchStrategy.Buffered ? 10 : 1;
|
|
14106
12292
|
const request = await this.buildRequest(path);
|
|
@@ -14340,7 +12526,11 @@ class AbstractRemote {
|
|
|
14340
12526
|
};
|
|
14341
12527
|
const stream = new DataStream({
|
|
14342
12528
|
logger: this.logger,
|
|
14343
|
-
mapLine: mapLine
|
|
12529
|
+
mapLine: mapLine,
|
|
12530
|
+
pressure: {
|
|
12531
|
+
highWaterMark: 20,
|
|
12532
|
+
lowWaterMark: 10
|
|
12533
|
+
}
|
|
14344
12534
|
});
|
|
14345
12535
|
abortSignal?.addEventListener('abort', () => {
|
|
14346
12536
|
closeReader();
|
|
@@ -14348,42 +12538,47 @@ class AbstractRemote {
|
|
|
14348
12538
|
});
|
|
14349
12539
|
const decoder = this.createTextDecoder();
|
|
14350
12540
|
let buffer = '';
|
|
14351
|
-
const
|
|
14352
|
-
|
|
14353
|
-
|
|
12541
|
+
const consumeStream = async () => {
|
|
12542
|
+
while (!stream.closed && !abortSignal?.aborted && !readerReleased) {
|
|
12543
|
+
const { done, value } = await reader.read();
|
|
12544
|
+
if (done) {
|
|
12545
|
+
const remaining = buffer.trim();
|
|
12546
|
+
if (remaining.length != 0) {
|
|
12547
|
+
stream.enqueueData(remaining);
|
|
12548
|
+
}
|
|
12549
|
+
stream.close();
|
|
12550
|
+
await closeReader();
|
|
14354
12551
|
return;
|
|
14355
12552
|
}
|
|
14356
|
-
|
|
14357
|
-
|
|
14358
|
-
|
|
14359
|
-
|
|
14360
|
-
|
|
14361
|
-
|
|
14362
|
-
|
|
14363
|
-
stream.enqueueData(remaining);
|
|
14364
|
-
}
|
|
14365
|
-
stream.close();
|
|
14366
|
-
await closeReader();
|
|
14367
|
-
return;
|
|
14368
|
-
}
|
|
14369
|
-
const data = decoder.decode(value, { stream: true });
|
|
14370
|
-
buffer += data;
|
|
14371
|
-
const lines = buffer.split('\n');
|
|
14372
|
-
for (var i = 0; i < lines.length - 1; i++) {
|
|
14373
|
-
var l = lines[i].trim();
|
|
14374
|
-
if (l.length > 0) {
|
|
14375
|
-
stream.enqueueData(l);
|
|
14376
|
-
didCompleteLine = true;
|
|
14377
|
-
}
|
|
14378
|
-
}
|
|
14379
|
-
buffer = lines[lines.length - 1];
|
|
12553
|
+
const data = decoder.decode(value, { stream: true });
|
|
12554
|
+
buffer += data;
|
|
12555
|
+
const lines = buffer.split('\n');
|
|
12556
|
+
for (var i = 0; i < lines.length - 1; i++) {
|
|
12557
|
+
var l = lines[i].trim();
|
|
12558
|
+
if (l.length > 0) {
|
|
12559
|
+
stream.enqueueData(l);
|
|
14380
12560
|
}
|
|
14381
12561
|
}
|
|
14382
|
-
|
|
14383
|
-
|
|
14384
|
-
|
|
12562
|
+
buffer = lines[lines.length - 1];
|
|
12563
|
+
// Implement backpressure by waiting for the low water mark to be reached
|
|
12564
|
+
if (stream.dataQueue.length > stream.highWatermark) {
|
|
12565
|
+
await new Promise((resolve) => {
|
|
12566
|
+
const dispose = stream.registerListener({
|
|
12567
|
+
lowWater: async () => {
|
|
12568
|
+
resolve();
|
|
12569
|
+
dispose();
|
|
12570
|
+
},
|
|
12571
|
+
closed: () => {
|
|
12572
|
+
resolve();
|
|
12573
|
+
dispose();
|
|
12574
|
+
}
|
|
12575
|
+
});
|
|
12576
|
+
});
|
|
14385
12577
|
}
|
|
14386
|
-
}
|
|
12578
|
+
}
|
|
12579
|
+
};
|
|
12580
|
+
consumeStream().catch(ex => this.logger.error('Error consuming stream', ex));
|
|
12581
|
+
const l = stream.registerListener({
|
|
14387
12582
|
closed: () => {
|
|
14388
12583
|
closeReader();
|
|
14389
12584
|
l?.();
|
|
@@ -14505,6 +12700,7 @@ const DEFAULT_STREAMING_SYNC_OPTIONS = {
|
|
|
14505
12700
|
crudUploadThrottleMs: DEFAULT_CRUD_UPLOAD_THROTTLE_MS
|
|
14506
12701
|
};
|
|
14507
12702
|
const DEFAULT_STREAM_CONNECTION_OPTIONS = {
|
|
12703
|
+
appMetadata: {},
|
|
14508
12704
|
connectionMethod: SyncStreamConnectionMethod.WEB_SOCKET,
|
|
14509
12705
|
clientImplementation: DEFAULT_SYNC_CLIENT_IMPLEMENTATION,
|
|
14510
12706
|
fetchStrategy: FetchStrategy.Buffered,
|
|
@@ -14883,6 +13079,11 @@ The next upload iteration will be delayed.`);
|
|
|
14883
13079
|
...DEFAULT_STREAM_CONNECTION_OPTIONS,
|
|
14884
13080
|
...(options ?? {})
|
|
14885
13081
|
};
|
|
13082
|
+
// Validate app metadata
|
|
13083
|
+
const invalidMetadata = Object.entries(resolvedOptions.appMetadata).filter(([_, value]) => typeof value != 'string');
|
|
13084
|
+
if (invalidMetadata.length > 0) {
|
|
13085
|
+
throw new Error(`Invalid appMetadata provided. Only string values are allowed. Invalid values: ${invalidMetadata.map(([key, value]) => `${key}: ${value}`).join(', ')}`);
|
|
13086
|
+
}
|
|
14886
13087
|
const clientImplementation = resolvedOptions.clientImplementation;
|
|
14887
13088
|
this.updateSyncStatus({ clientImplementation });
|
|
14888
13089
|
if (clientImplementation == SyncClientImplementation.JAVASCRIPT) {
|
|
@@ -14918,6 +13119,7 @@ The next upload iteration will be delayed.`);
|
|
|
14918
13119
|
include_checksum: true,
|
|
14919
13120
|
raw_data: true,
|
|
14920
13121
|
parameters: resolvedOptions.params,
|
|
13122
|
+
app_metadata: resolvedOptions.appMetadata,
|
|
14921
13123
|
client_id: clientId
|
|
14922
13124
|
}
|
|
14923
13125
|
};
|
|
@@ -15277,6 +13479,7 @@ The next upload iteration will be delayed.`);
|
|
|
15277
13479
|
try {
|
|
15278
13480
|
const options = {
|
|
15279
13481
|
parameters: resolvedOptions.params,
|
|
13482
|
+
app_metadata: resolvedOptions.appMetadata,
|
|
15280
13483
|
active_streams: this.activeStreams,
|
|
15281
13484
|
include_defaults: resolvedOptions.includeDefaultStreams
|
|
15282
13485
|
};
|
|
@@ -15913,14 +14116,14 @@ class AbstractPowerSyncDatabase extends BaseObserver {
|
|
|
15913
14116
|
async initialize() {
|
|
15914
14117
|
await this._initialize();
|
|
15915
14118
|
await this.bucketStorageAdapter.init();
|
|
15916
|
-
await this.
|
|
14119
|
+
await this.loadVersion();
|
|
15917
14120
|
await this.updateSchema(this.options.schema);
|
|
15918
14121
|
await this.resolveOfflineSyncStatus();
|
|
15919
14122
|
await this.database.execute('PRAGMA RECURSIVE_TRIGGERS=TRUE');
|
|
15920
14123
|
this.ready = true;
|
|
15921
14124
|
this.iterateListeners((cb) => cb.initialized?.());
|
|
15922
14125
|
}
|
|
15923
|
-
async
|
|
14126
|
+
async loadVersion() {
|
|
15924
14127
|
try {
|
|
15925
14128
|
const { version } = await this.database.get('SELECT powersync_rs_version() as version');
|
|
15926
14129
|
this.sdkVersion = version;
|
|
@@ -17059,6 +15262,27 @@ class SyncDataBatch {
|
|
|
17059
15262
|
}
|
|
17060
15263
|
}
|
|
17061
15264
|
|
|
15265
|
+
/**
|
|
15266
|
+
* Thrown when an underlying database connection is closed.
|
|
15267
|
+
* This is particularly relevant when worker connections are marked as closed while
|
|
15268
|
+
* operations are still in progress.
|
|
15269
|
+
*/
|
|
15270
|
+
class ConnectionClosedError extends Error {
|
|
15271
|
+
static NAME = 'ConnectionClosedError';
|
|
15272
|
+
static MATCHES(input) {
|
|
15273
|
+
/**
|
|
15274
|
+
* If there are weird package issues which cause multiple versions of classes to be present, the instanceof
|
|
15275
|
+
* check might fail. This also performs a failsafe check.
|
|
15276
|
+
* This might also happen if the Error is serialized and parsed over a bridging channel like a MessagePort.
|
|
15277
|
+
*/
|
|
15278
|
+
return (input instanceof ConnectionClosedError || (input instanceof Error && input.name == ConnectionClosedError.NAME));
|
|
15279
|
+
}
|
|
15280
|
+
constructor(message) {
|
|
15281
|
+
super(message);
|
|
15282
|
+
this.name = ConnectionClosedError.NAME;
|
|
15283
|
+
}
|
|
15284
|
+
}
|
|
15285
|
+
|
|
17062
15286
|
// https://www.sqlite.org/lang_expr.html#castexpr
|
|
17063
15287
|
var ColumnType;
|
|
17064
15288
|
(function (ColumnType) {
|
|
@@ -17617,49 +15841,22 @@ const parseQuery = (query, parameters) => {
|
|
|
17617
15841
|
//# sourceMappingURL=bundle.mjs.map
|
|
17618
15842
|
|
|
17619
15843
|
|
|
17620
|
-
/***/ }
|
|
17621
|
-
|
|
17622
|
-
/***/ "./lib/src/db/adapters/AsyncDatabaseConnection.js":
|
|
17623
|
-
/*!********************************************************!*\
|
|
17624
|
-
!*** ./lib/src/db/adapters/AsyncDatabaseConnection.js ***!
|
|
17625
|
-
\********************************************************/
|
|
17626
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
17627
|
-
|
|
17628
|
-
__webpack_require__.r(__webpack_exports__);
|
|
17629
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
17630
|
-
/* harmony export */ ConnectionClosedError: () => (/* binding */ ConnectionClosedError)
|
|
17631
|
-
/* harmony export */ });
|
|
17632
|
-
/**
|
|
17633
|
-
* Thrown when an underlying database connection is closed.
|
|
17634
|
-
* This is particularly relevant when worker connections are marked as closed while
|
|
17635
|
-
* operations are still in progress.
|
|
17636
|
-
*/
|
|
17637
|
-
class ConnectionClosedError extends Error {
|
|
17638
|
-
constructor(message) {
|
|
17639
|
-
super(message);
|
|
17640
|
-
this.name = 'ConnectionClosedError';
|
|
17641
|
-
}
|
|
17642
|
-
}
|
|
17643
|
-
|
|
17644
|
-
|
|
17645
|
-
/***/ }),
|
|
15844
|
+
/***/ },
|
|
17646
15845
|
|
|
17647
|
-
/***/ "./lib/src/db/adapters/LockedAsyncDatabaseAdapter.js"
|
|
15846
|
+
/***/ "./lib/src/db/adapters/LockedAsyncDatabaseAdapter.js"
|
|
17648
15847
|
/*!***********************************************************!*\
|
|
17649
15848
|
!*** ./lib/src/db/adapters/LockedAsyncDatabaseAdapter.js ***!
|
|
17650
15849
|
\***********************************************************/
|
|
17651
|
-
|
|
15850
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
17652
15851
|
|
|
17653
15852
|
__webpack_require__.r(__webpack_exports__);
|
|
17654
15853
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
17655
15854
|
/* harmony export */ LockedAsyncDatabaseAdapter: () => (/* binding */ LockedAsyncDatabaseAdapter)
|
|
17656
15855
|
/* harmony export */ });
|
|
17657
15856
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @powersync/common */ "../common/dist/bundle.mjs");
|
|
17658
|
-
/* harmony import */ var
|
|
17659
|
-
/* harmony import */ var
|
|
17660
|
-
/* harmony import */ var
|
|
17661
|
-
/* harmony import */ var _wa_sqlite_WASQLiteConnection__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./wa-sqlite/WASQLiteConnection */ "./lib/src/db/adapters/wa-sqlite/WASQLiteConnection.js");
|
|
17662
|
-
|
|
15857
|
+
/* harmony import */ var _shared_navigator_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../shared/navigator.js */ "./lib/src/shared/navigator.js");
|
|
15858
|
+
/* harmony import */ var _WorkerWrappedAsyncDatabaseConnection_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./WorkerWrappedAsyncDatabaseConnection.js */ "./lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.js");
|
|
15859
|
+
/* 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");
|
|
17663
15860
|
|
|
17664
15861
|
|
|
17665
15862
|
|
|
@@ -17752,7 +15949,7 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
17752
15949
|
/**
|
|
17753
15950
|
* This is only required for the long-lived shared IndexedDB connections.
|
|
17754
15951
|
*/
|
|
17755
|
-
this.requiresHolds = this._config.vfs ==
|
|
15952
|
+
this.requiresHolds = this._config.vfs == _wa_sqlite_WASQLiteConnection_js__WEBPACK_IMPORTED_MODULE_3__.WASQLiteVFS.IDBBatchAtomicVFS;
|
|
17756
15953
|
});
|
|
17757
15954
|
}
|
|
17758
15955
|
_reOpen() {
|
|
@@ -17806,7 +16003,7 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
17806
16003
|
await this.initPromise;
|
|
17807
16004
|
}
|
|
17808
16005
|
async shareConnection() {
|
|
17809
|
-
if (false == this._db instanceof
|
|
16006
|
+
if (false == this._db instanceof _WorkerWrappedAsyncDatabaseConnection_js__WEBPACK_IMPORTED_MODULE_2__.WorkerWrappedAsyncDatabaseConnection) {
|
|
17810
16007
|
throw new Error(`Only worker connections can be shared`);
|
|
17811
16008
|
}
|
|
17812
16009
|
return this._db.shareConnection();
|
|
@@ -17840,7 +16037,14 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
17840
16037
|
*/
|
|
17841
16038
|
async close() {
|
|
17842
16039
|
this.closing = true;
|
|
17843
|
-
|
|
16040
|
+
/**
|
|
16041
|
+
* Note that we obtain a reference to the callback to avoid calling the callback with `this` as the context.
|
|
16042
|
+
* This is to avoid Comlink attempting to clone `this` when calling the method.
|
|
16043
|
+
*/
|
|
16044
|
+
const dispose = this._disposeTableChangeListener;
|
|
16045
|
+
if (dispose) {
|
|
16046
|
+
dispose();
|
|
16047
|
+
}
|
|
17844
16048
|
this.pendingAbortControllers.forEach((controller) => controller.abort('Closed'));
|
|
17845
16049
|
await this.baseDB?.close?.();
|
|
17846
16050
|
this.closed = true;
|
|
@@ -17882,7 +16086,7 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
17882
16086
|
this.pendingAbortControllers.delete(abortController);
|
|
17883
16087
|
}, timeoutMs)
|
|
17884
16088
|
: null;
|
|
17885
|
-
return (0,
|
|
16089
|
+
return (0,_shared_navigator_js__WEBPACK_IMPORTED_MODULE_1__.getNavigatorLocks)().request(`db-lock-${this._dbIdentifier}`, { signal: abortController.signal }, async () => {
|
|
17886
16090
|
this.pendingAbortControllers.delete(abortController);
|
|
17887
16091
|
if (timeoutId) {
|
|
17888
16092
|
clearTimeout(timeoutId);
|
|
@@ -17906,13 +16110,13 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
17906
16110
|
* might have failed. We need to re-open the database.
|
|
17907
16111
|
*/
|
|
17908
16112
|
if (this.databaseOpenPromise || !this._db) {
|
|
17909
|
-
throw new
|
|
16113
|
+
throw new _powersync_common__WEBPACK_IMPORTED_MODULE_0__.ConnectionClosedError('Connection is busy re-opening');
|
|
17910
16114
|
}
|
|
17911
16115
|
holdId = this.requiresHolds ? await this.baseDB.markHold() : null;
|
|
17912
16116
|
return await callback();
|
|
17913
16117
|
}
|
|
17914
16118
|
catch (ex) {
|
|
17915
|
-
if (
|
|
16119
|
+
if (_powersync_common__WEBPACK_IMPORTED_MODULE_0__.ConnectionClosedError.MATCHES(ex)) {
|
|
17916
16120
|
if (this.options.reOpenOnConnectionClosed && !this.databaseOpenPromise && !this.closing) {
|
|
17917
16121
|
// Immediately re-open the database. We need to miss as little table updates as possible.
|
|
17918
16122
|
// Note, don't await this since it uses the same lock as we're in now.
|
|
@@ -18041,22 +16245,20 @@ class LockedAsyncDatabaseAdapter extends _powersync_common__WEBPACK_IMPORTED_MOD
|
|
|
18041
16245
|
}
|
|
18042
16246
|
|
|
18043
16247
|
|
|
18044
|
-
/***/ }
|
|
16248
|
+
/***/ },
|
|
18045
16249
|
|
|
18046
|
-
/***/ "./lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.js"
|
|
16250
|
+
/***/ "./lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.js"
|
|
18047
16251
|
/*!*********************************************************************!*\
|
|
18048
16252
|
!*** ./lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.js ***!
|
|
18049
16253
|
\*********************************************************************/
|
|
18050
|
-
|
|
16254
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
18051
16255
|
|
|
18052
16256
|
__webpack_require__.r(__webpack_exports__);
|
|
18053
16257
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
18054
16258
|
/* harmony export */ WorkerWrappedAsyncDatabaseConnection: () => (/* binding */ WorkerWrappedAsyncDatabaseConnection)
|
|
18055
16259
|
/* harmony export */ });
|
|
18056
16260
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @powersync/common */ "../common/dist/bundle.mjs");
|
|
18057
|
-
/* harmony import */ var
|
|
18058
|
-
/* harmony import */ var _AsyncDatabaseConnection__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./AsyncDatabaseConnection */ "./lib/src/db/adapters/AsyncDatabaseConnection.js");
|
|
18059
|
-
|
|
16261
|
+
/* 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");
|
|
18060
16262
|
|
|
18061
16263
|
|
|
18062
16264
|
/**
|
|
@@ -18106,7 +16308,7 @@ class WorkerWrappedAsyncDatabaseConnection extends _powersync_common__WEBPACK_IM
|
|
|
18106
16308
|
if (controller) {
|
|
18107
16309
|
return new Promise((resolve, reject) => {
|
|
18108
16310
|
if (controller.signal.aborted) {
|
|
18109
|
-
reject(new
|
|
16311
|
+
reject(new _powersync_common__WEBPACK_IMPORTED_MODULE_0__.ConnectionClosedError('Called operation on closed remote'));
|
|
18110
16312
|
if (!fireActionOnAbort) {
|
|
18111
16313
|
// Don't run the operation if we're going to reject
|
|
18112
16314
|
// We might want to fire-and-forget the operation in some cases (like a close operation)
|
|
@@ -18114,7 +16316,7 @@ class WorkerWrappedAsyncDatabaseConnection extends _powersync_common__WEBPACK_IM
|
|
|
18114
16316
|
}
|
|
18115
16317
|
}
|
|
18116
16318
|
function handleAbort() {
|
|
18117
|
-
reject(new
|
|
16319
|
+
reject(new _powersync_common__WEBPACK_IMPORTED_MODULE_0__.ConnectionClosedError('Remote peer closed with request in flight'));
|
|
18118
16320
|
}
|
|
18119
16321
|
function completePromise(action) {
|
|
18120
16322
|
controller.signal.removeEventListener('abort', handleAbort);
|
|
@@ -18168,7 +16370,7 @@ class WorkerWrappedAsyncDatabaseConnection extends _powersync_common__WEBPACK_IM
|
|
|
18168
16370
|
reject(ex);
|
|
18169
16371
|
}
|
|
18170
16372
|
}));
|
|
18171
|
-
const newPort = await remote[
|
|
16373
|
+
const newPort = await remote[comlink__WEBPACK_IMPORTED_MODULE_1__.createEndpoint]();
|
|
18172
16374
|
return { port: newPort, identifier };
|
|
18173
16375
|
}
|
|
18174
16376
|
/**
|
|
@@ -18176,7 +16378,7 @@ class WorkerWrappedAsyncDatabaseConnection extends _powersync_common__WEBPACK_IM
|
|
|
18176
16378
|
* This can be extended by custom implementations in order to handle proxy events.
|
|
18177
16379
|
*/
|
|
18178
16380
|
async registerOnTableChange(callback) {
|
|
18179
|
-
return this.baseConnection.registerOnTableChange(
|
|
16381
|
+
return this.baseConnection.registerOnTableChange(comlink__WEBPACK_IMPORTED_MODULE_1__.proxy(callback));
|
|
18180
16382
|
}
|
|
18181
16383
|
async close() {
|
|
18182
16384
|
// Abort any pending lock requests.
|
|
@@ -18186,7 +16388,7 @@ class WorkerWrappedAsyncDatabaseConnection extends _powersync_common__WEBPACK_IM
|
|
|
18186
16388
|
await this.withRemote(() => this.baseConnection.close(), true);
|
|
18187
16389
|
}
|
|
18188
16390
|
finally {
|
|
18189
|
-
this.options.remote[
|
|
16391
|
+
this.options.remote[comlink__WEBPACK_IMPORTED_MODULE_1__.releaseProxy]();
|
|
18190
16392
|
this.options.onClose?.();
|
|
18191
16393
|
this.iterateListeners((l) => l.closing?.());
|
|
18192
16394
|
}
|
|
@@ -18206,13 +16408,13 @@ class WorkerWrappedAsyncDatabaseConnection extends _powersync_common__WEBPACK_IM
|
|
|
18206
16408
|
}
|
|
18207
16409
|
|
|
18208
16410
|
|
|
18209
|
-
/***/ }
|
|
16411
|
+
/***/ },
|
|
18210
16412
|
|
|
18211
|
-
/***/ "./lib/src/db/adapters/wa-sqlite/WASQLiteConnection.js"
|
|
16413
|
+
/***/ "./lib/src/db/adapters/wa-sqlite/WASQLiteConnection.js"
|
|
18212
16414
|
/*!*************************************************************!*\
|
|
18213
16415
|
!*** ./lib/src/db/adapters/wa-sqlite/WASQLiteConnection.js ***!
|
|
18214
16416
|
\*************************************************************/
|
|
18215
|
-
|
|
16417
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
18216
16418
|
|
|
18217
16419
|
__webpack_require__.r(__webpack_exports__);
|
|
18218
16420
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
@@ -18224,9 +16426,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
18224
16426
|
/* harmony export */ WASQLiteVFS: () => (/* binding */ WASQLiteVFS),
|
|
18225
16427
|
/* harmony export */ WASqliteConnection: () => (/* binding */ WASqliteConnection)
|
|
18226
16428
|
/* harmony export */ });
|
|
18227
|
-
/* harmony import */ var _journeyapps_wa_sqlite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @journeyapps/wa-sqlite */ "../../node_modules/@journeyapps/wa-sqlite/src/sqlite-api.js");
|
|
16429
|
+
/* 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");
|
|
18228
16430
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @powersync/common */ "../common/dist/bundle.mjs");
|
|
18229
|
-
/* harmony import */ var async_mutex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! async-mutex */ "../../node_modules/async-mutex/index.mjs");
|
|
16431
|
+
/* 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");
|
|
18230
16432
|
|
|
18231
16433
|
|
|
18232
16434
|
|
|
@@ -18243,28 +16445,28 @@ var WASQLiteVFS;
|
|
|
18243
16445
|
* @internal
|
|
18244
16446
|
*/
|
|
18245
16447
|
const AsyncWASQLiteModuleFactory = async () => {
|
|
18246
|
-
const { default: factory } = await __webpack_require__.e(/*! import() */ "
|
|
16448
|
+
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"));
|
|
18247
16449
|
return factory();
|
|
18248
16450
|
};
|
|
18249
16451
|
/**
|
|
18250
16452
|
* @internal
|
|
18251
16453
|
*/
|
|
18252
16454
|
const MultiCipherAsyncWASQLiteModuleFactory = async () => {
|
|
18253
|
-
const { default: factory } = await __webpack_require__.e(/*! import() */ "
|
|
16455
|
+
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"));
|
|
18254
16456
|
return factory();
|
|
18255
16457
|
};
|
|
18256
16458
|
/**
|
|
18257
16459
|
* @internal
|
|
18258
16460
|
*/
|
|
18259
16461
|
const SyncWASQLiteModuleFactory = async () => {
|
|
18260
|
-
const { default: factory } = await __webpack_require__.e(/*! import() */ "
|
|
16462
|
+
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"));
|
|
18261
16463
|
return factory();
|
|
18262
16464
|
};
|
|
18263
16465
|
/**
|
|
18264
16466
|
* @internal
|
|
18265
16467
|
*/
|
|
18266
16468
|
const MultiCipherSyncWASQLiteModuleFactory = async () => {
|
|
18267
|
-
const { default: factory } = await __webpack_require__.e(/*! import() */ "
|
|
16469
|
+
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"));
|
|
18268
16470
|
return factory();
|
|
18269
16471
|
};
|
|
18270
16472
|
/**
|
|
@@ -18279,7 +16481,7 @@ const DEFAULT_MODULE_FACTORIES = {
|
|
|
18279
16481
|
else {
|
|
18280
16482
|
module = await AsyncWASQLiteModuleFactory();
|
|
18281
16483
|
}
|
|
18282
|
-
const { IDBBatchAtomicVFS } = await __webpack_require__.e(/*! import() */ "
|
|
16484
|
+
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"));
|
|
18283
16485
|
return {
|
|
18284
16486
|
module,
|
|
18285
16487
|
// @ts-expect-error The types for this static method are missing upstream
|
|
@@ -18295,7 +16497,7 @@ const DEFAULT_MODULE_FACTORIES = {
|
|
|
18295
16497
|
module = await SyncWASQLiteModuleFactory();
|
|
18296
16498
|
}
|
|
18297
16499
|
// @ts-expect-error The types for this static method are missing upstream
|
|
18298
|
-
const { AccessHandlePoolVFS } = await __webpack_require__.e(/*! import() */ "
|
|
16500
|
+
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"));
|
|
18299
16501
|
return {
|
|
18300
16502
|
module,
|
|
18301
16503
|
vfs: await AccessHandlePoolVFS.create(options.dbFileName, module)
|
|
@@ -18310,7 +16512,7 @@ const DEFAULT_MODULE_FACTORIES = {
|
|
|
18310
16512
|
module = await SyncWASQLiteModuleFactory();
|
|
18311
16513
|
}
|
|
18312
16514
|
// @ts-expect-error The types for this static method are missing upstream
|
|
18313
|
-
const { OPFSCoopSyncVFS } = await __webpack_require__.e(/*! import() */ "
|
|
16515
|
+
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"));
|
|
18314
16516
|
const vfs = await OPFSCoopSyncVFS.create(options.dbFileName, module);
|
|
18315
16517
|
return {
|
|
18316
16518
|
module,
|
|
@@ -18630,20 +16832,20 @@ class WASqliteConnection extends _powersync_common__WEBPACK_IMPORTED_MODULE_1__.
|
|
|
18630
16832
|
}
|
|
18631
16833
|
|
|
18632
16834
|
|
|
18633
|
-
/***/ }
|
|
16835
|
+
/***/ },
|
|
18634
16836
|
|
|
18635
|
-
/***/ "./lib/src/db/sync/WebRemote.js"
|
|
16837
|
+
/***/ "./lib/src/db/sync/WebRemote.js"
|
|
18636
16838
|
/*!**************************************!*\
|
|
18637
16839
|
!*** ./lib/src/db/sync/WebRemote.js ***!
|
|
18638
16840
|
\**************************************/
|
|
18639
|
-
|
|
16841
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
18640
16842
|
|
|
18641
16843
|
__webpack_require__.r(__webpack_exports__);
|
|
18642
16844
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
18643
16845
|
/* harmony export */ WebRemote: () => (/* binding */ WebRemote)
|
|
18644
16846
|
/* harmony export */ });
|
|
18645
16847
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @powersync/common */ "../common/dist/bundle.mjs");
|
|
18646
|
-
/* harmony import */ var
|
|
16848
|
+
/* harmony import */ var _userAgent_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./userAgent.js */ "./lib/src/db/sync/userAgent.js");
|
|
18647
16849
|
|
|
18648
16850
|
|
|
18649
16851
|
/*
|
|
@@ -18669,7 +16871,7 @@ class WebRemote extends _powersync_common__WEBPACK_IMPORTED_MODULE_0__.AbstractR
|
|
|
18669
16871
|
getUserAgent() {
|
|
18670
16872
|
let ua = [super.getUserAgent(), `powersync-web`];
|
|
18671
16873
|
try {
|
|
18672
|
-
ua.push(...(0,
|
|
16874
|
+
ua.push(...(0,_userAgent_js__WEBPACK_IMPORTED_MODULE_1__.getUserAgentInfo)());
|
|
18673
16875
|
}
|
|
18674
16876
|
catch (e) {
|
|
18675
16877
|
this.logger.warn('Failed to get user agent info', e);
|
|
@@ -18683,27 +16885,27 @@ class WebRemote extends _powersync_common__WEBPACK_IMPORTED_MODULE_0__.AbstractR
|
|
|
18683
16885
|
/**
|
|
18684
16886
|
* Dynamic import to be used only when needed.
|
|
18685
16887
|
*/
|
|
18686
|
-
const { BSON } = await __webpack_require__.e(/*! import() */ "
|
|
16888
|
+
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"));
|
|
18687
16889
|
this._bson = BSON;
|
|
18688
16890
|
return this._bson;
|
|
18689
16891
|
}
|
|
18690
16892
|
}
|
|
18691
16893
|
|
|
18692
16894
|
|
|
18693
|
-
/***/ }
|
|
16895
|
+
/***/ },
|
|
18694
16896
|
|
|
18695
|
-
/***/ "./lib/src/db/sync/WebStreamingSyncImplementation.js"
|
|
16897
|
+
/***/ "./lib/src/db/sync/WebStreamingSyncImplementation.js"
|
|
18696
16898
|
/*!***********************************************************!*\
|
|
18697
16899
|
!*** ./lib/src/db/sync/WebStreamingSyncImplementation.js ***!
|
|
18698
16900
|
\***********************************************************/
|
|
18699
|
-
|
|
16901
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
18700
16902
|
|
|
18701
16903
|
__webpack_require__.r(__webpack_exports__);
|
|
18702
16904
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
18703
16905
|
/* harmony export */ WebStreamingSyncImplementation: () => (/* binding */ WebStreamingSyncImplementation)
|
|
18704
16906
|
/* harmony export */ });
|
|
18705
16907
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @powersync/common */ "../common/dist/bundle.mjs");
|
|
18706
|
-
/* harmony import */ var
|
|
16908
|
+
/* harmony import */ var _shared_navigator_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../shared/navigator.js */ "./lib/src/shared/navigator.js");
|
|
18707
16909
|
|
|
18708
16910
|
|
|
18709
16911
|
class WebStreamingSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODULE_0__.AbstractStreamingSyncImplementation {
|
|
@@ -18719,18 +16921,18 @@ class WebStreamingSyncImplementation extends _powersync_common__WEBPACK_IMPORTED
|
|
|
18719
16921
|
if (lockOptions.type == _powersync_common__WEBPACK_IMPORTED_MODULE_0__.LockType.SYNC) {
|
|
18720
16922
|
this.logger.debug('requesting lock for ', identifier);
|
|
18721
16923
|
}
|
|
18722
|
-
return (0,
|
|
16924
|
+
return (0,_shared_navigator_js__WEBPACK_IMPORTED_MODULE_1__.getNavigatorLocks)().request(identifier, { signal: lockOptions.signal }, lockOptions.callback);
|
|
18723
16925
|
}
|
|
18724
16926
|
}
|
|
18725
16927
|
|
|
18726
16928
|
|
|
18727
|
-
/***/ }
|
|
16929
|
+
/***/ },
|
|
18728
16930
|
|
|
18729
|
-
/***/ "./lib/src/db/sync/userAgent.js"
|
|
16931
|
+
/***/ "./lib/src/db/sync/userAgent.js"
|
|
18730
16932
|
/*!**************************************!*\
|
|
18731
16933
|
!*** ./lib/src/db/sync/userAgent.js ***!
|
|
18732
16934
|
\**************************************/
|
|
18733
|
-
|
|
16935
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
18734
16936
|
|
|
18735
16937
|
__webpack_require__.r(__webpack_exports__);
|
|
18736
16938
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
@@ -18802,13 +17004,13 @@ function getOsInfo(nav) {
|
|
|
18802
17004
|
}
|
|
18803
17005
|
|
|
18804
17006
|
|
|
18805
|
-
/***/ }
|
|
17007
|
+
/***/ },
|
|
18806
17008
|
|
|
18807
|
-
/***/ "./lib/src/shared/navigator.js"
|
|
17009
|
+
/***/ "./lib/src/shared/navigator.js"
|
|
18808
17010
|
/*!*************************************!*\
|
|
18809
17011
|
!*** ./lib/src/shared/navigator.js ***!
|
|
18810
17012
|
\*************************************/
|
|
18811
|
-
|
|
17013
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
18812
17014
|
|
|
18813
17015
|
__webpack_require__.r(__webpack_exports__);
|
|
18814
17016
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
@@ -18822,13 +17024,13 @@ const getNavigatorLocks = () => {
|
|
|
18822
17024
|
};
|
|
18823
17025
|
|
|
18824
17026
|
|
|
18825
|
-
/***/ }
|
|
17027
|
+
/***/ },
|
|
18826
17028
|
|
|
18827
|
-
/***/ "./lib/src/worker/sync/BroadcastLogger.js"
|
|
17029
|
+
/***/ "./lib/src/worker/sync/BroadcastLogger.js"
|
|
18828
17030
|
/*!************************************************!*\
|
|
18829
17031
|
!*** ./lib/src/worker/sync/BroadcastLogger.js ***!
|
|
18830
17032
|
\************************************************/
|
|
18831
|
-
|
|
17033
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
18832
17034
|
|
|
18833
17035
|
__webpack_require__.r(__webpack_exports__);
|
|
18834
17036
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
@@ -18965,13 +17167,13 @@ class BroadcastLogger {
|
|
|
18965
17167
|
}
|
|
18966
17168
|
|
|
18967
17169
|
|
|
18968
|
-
/***/ }
|
|
17170
|
+
/***/ },
|
|
18969
17171
|
|
|
18970
|
-
/***/ "./lib/src/worker/sync/SharedSyncImplementation.js"
|
|
17172
|
+
/***/ "./lib/src/worker/sync/SharedSyncImplementation.js"
|
|
18971
17173
|
/*!*********************************************************!*\
|
|
18972
17174
|
!*** ./lib/src/worker/sync/SharedSyncImplementation.js ***!
|
|
18973
17175
|
\*********************************************************/
|
|
18974
|
-
|
|
17176
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
18975
17177
|
|
|
18976
17178
|
__webpack_require__.r(__webpack_exports__);
|
|
18977
17179
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
@@ -18979,13 +17181,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
18979
17181
|
/* harmony export */ SharedSyncImplementation: () => (/* binding */ SharedSyncImplementation)
|
|
18980
17182
|
/* harmony export */ });
|
|
18981
17183
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @powersync/common */ "../common/dist/bundle.mjs");
|
|
18982
|
-
/* harmony import */ var async_mutex__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! async-mutex */ "../../node_modules/async-mutex/index.mjs");
|
|
18983
|
-
/* harmony import */ var
|
|
18984
|
-
/* harmony import */ var
|
|
18985
|
-
/* harmony import */ var
|
|
18986
|
-
/* harmony import */ var
|
|
18987
|
-
/* harmony import */ var
|
|
18988
|
-
/* harmony import */ var
|
|
17184
|
+
/* 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");
|
|
17185
|
+
/* 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");
|
|
17186
|
+
/* harmony import */ var _db_sync_WebRemote_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../db/sync/WebRemote.js */ "./lib/src/db/sync/WebRemote.js");
|
|
17187
|
+
/* harmony import */ var _db_sync_WebStreamingSyncImplementation_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../db/sync/WebStreamingSyncImplementation.js */ "./lib/src/db/sync/WebStreamingSyncImplementation.js");
|
|
17188
|
+
/* harmony import */ var _db_adapters_LockedAsyncDatabaseAdapter_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../db/adapters/LockedAsyncDatabaseAdapter.js */ "./lib/src/db/adapters/LockedAsyncDatabaseAdapter.js");
|
|
17189
|
+
/* harmony import */ var _db_adapters_WorkerWrappedAsyncDatabaseConnection_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../db/adapters/WorkerWrappedAsyncDatabaseConnection.js */ "./lib/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.js");
|
|
17190
|
+
/* harmony import */ var _BroadcastLogger_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./BroadcastLogger.js */ "./lib/src/worker/sync/BroadcastLogger.js");
|
|
18989
17191
|
|
|
18990
17192
|
|
|
18991
17193
|
|
|
@@ -19050,7 +17252,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
19050
17252
|
// Should be configured once we get params
|
|
19051
17253
|
this.distributedDB = null;
|
|
19052
17254
|
this.syncStatus = new _powersync_common__WEBPACK_IMPORTED_MODULE_0__.SyncStatus({});
|
|
19053
|
-
this.broadCastLogger = new
|
|
17255
|
+
this.broadCastLogger = new _BroadcastLogger_js__WEBPACK_IMPORTED_MODULE_7__.BroadcastLogger(this.ports);
|
|
19054
17256
|
this.connectionManager = new _powersync_common__WEBPACK_IMPORTED_MODULE_0__.ConnectionManager({
|
|
19055
17257
|
createSyncImplementation: async () => {
|
|
19056
17258
|
await this.waitForReady();
|
|
@@ -19148,7 +17350,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
19148
17350
|
if (params.streamOptions?.flags?.broadcastLogs) {
|
|
19149
17351
|
this.logger = this.broadCastLogger;
|
|
19150
17352
|
}
|
|
19151
|
-
const lockedAdapter = new
|
|
17353
|
+
const lockedAdapter = new _db_adapters_LockedAsyncDatabaseAdapter_js__WEBPACK_IMPORTED_MODULE_5__.LockedAsyncDatabaseAdapter({
|
|
19152
17354
|
name: params.dbParams.dbFilename,
|
|
19153
17355
|
openConnection: async () => {
|
|
19154
17356
|
// Gets a connection from the clients when a new connection is requested.
|
|
@@ -19170,6 +17372,14 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
19170
17372
|
// We may have missed some table updates while the database was closed.
|
|
19171
17373
|
// We can poke the crud in case we missed any updates.
|
|
19172
17374
|
this.connectionManager.syncStreamImplementation?.triggerCrudUpload();
|
|
17375
|
+
/**
|
|
17376
|
+
* FIXME or IMPROVE ME
|
|
17377
|
+
* The Rust client implementation stores sync state on the connection level.
|
|
17378
|
+
* Reopening the database causes a state machine error which should cause the
|
|
17379
|
+
* StreamingSyncImplementation to reconnect. It would be nicer if we could trigger
|
|
17380
|
+
* this reconnect earlier.
|
|
17381
|
+
* This reconnect is not required for IndexedDB.
|
|
17382
|
+
*/
|
|
19173
17383
|
}
|
|
19174
17384
|
});
|
|
19175
17385
|
self.onerror = (event) => {
|
|
@@ -19203,7 +17413,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
19203
17413
|
return await this.portMutex.runExclusive(() => {
|
|
19204
17414
|
const portProvider = {
|
|
19205
17415
|
port,
|
|
19206
|
-
clientProvider:
|
|
17416
|
+
clientProvider: comlink__WEBPACK_IMPORTED_MODULE_2__.wrap(port),
|
|
19207
17417
|
currentSubscriptions: [],
|
|
19208
17418
|
closeListeners: [],
|
|
19209
17419
|
isClosing: false
|
|
@@ -19250,7 +17460,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
19250
17460
|
await closeListener();
|
|
19251
17461
|
}
|
|
19252
17462
|
this.collectActiveSubscriptions();
|
|
19253
|
-
return () => trackedPort.clientProvider[
|
|
17463
|
+
return () => trackedPort.clientProvider[comlink__WEBPACK_IMPORTED_MODULE_2__.releaseProxy]();
|
|
19254
17464
|
});
|
|
19255
17465
|
}
|
|
19256
17466
|
triggerCrudUpload() {
|
|
@@ -19287,9 +17497,9 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
19287
17497
|
// This should only be called after initialization has completed
|
|
19288
17498
|
const syncParams = this.syncParams;
|
|
19289
17499
|
// Create a new StreamingSyncImplementation for each connect call. This is usually done is all SDKs.
|
|
19290
|
-
return new
|
|
17500
|
+
return new _db_sync_WebStreamingSyncImplementation_js__WEBPACK_IMPORTED_MODULE_4__.WebStreamingSyncImplementation({
|
|
19291
17501
|
adapter: new _powersync_common__WEBPACK_IMPORTED_MODULE_0__.SqliteBucketStorage(this.distributedDB, this.logger),
|
|
19292
|
-
remote: new
|
|
17502
|
+
remote: new _db_sync_WebRemote_js__WEBPACK_IMPORTED_MODULE_3__.WebRemote({
|
|
19293
17503
|
invalidateCredentials: async () => {
|
|
19294
17504
|
const lastPort = await this.getLastWrappedPort();
|
|
19295
17505
|
if (!lastPort) {
|
|
@@ -19395,7 +17605,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
19395
17605
|
removeCloseListener();
|
|
19396
17606
|
throw ex;
|
|
19397
17607
|
});
|
|
19398
|
-
const remote =
|
|
17608
|
+
const remote = comlink__WEBPACK_IMPORTED_MODULE_2__.wrap(workerPort);
|
|
19399
17609
|
const identifier = this.syncParams.dbParams.dbFilename;
|
|
19400
17610
|
/**
|
|
19401
17611
|
* The open could fail if the tab is closed while we're busy opening the database.
|
|
@@ -19414,7 +17624,7 @@ class SharedSyncImplementation extends _powersync_common__WEBPACK_IMPORTED_MODUL
|
|
|
19414
17624
|
removeCloseListener();
|
|
19415
17625
|
});
|
|
19416
17626
|
clearTimeout(timeout);
|
|
19417
|
-
const wrapped = new
|
|
17627
|
+
const wrapped = new _db_adapters_WorkerWrappedAsyncDatabaseConnection_js__WEBPACK_IMPORTED_MODULE_6__.WorkerWrappedAsyncDatabaseConnection({
|
|
19418
17628
|
remote,
|
|
19419
17629
|
baseConnection: db,
|
|
19420
17630
|
identifier,
|
|
@@ -19475,21 +17685,21 @@ function withAbort(options) {
|
|
|
19475
17685
|
}
|
|
19476
17686
|
|
|
19477
17687
|
|
|
19478
|
-
/***/ }
|
|
17688
|
+
/***/ },
|
|
19479
17689
|
|
|
19480
|
-
/***/ "./lib/src/worker/sync/WorkerClient.js"
|
|
17690
|
+
/***/ "./lib/src/worker/sync/WorkerClient.js"
|
|
19481
17691
|
/*!*********************************************!*\
|
|
19482
17692
|
!*** ./lib/src/worker/sync/WorkerClient.js ***!
|
|
19483
17693
|
\*********************************************/
|
|
19484
|
-
|
|
17694
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
19485
17695
|
|
|
19486
17696
|
__webpack_require__.r(__webpack_exports__);
|
|
19487
17697
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
19488
17698
|
/* harmony export */ WorkerClient: () => (/* binding */ WorkerClient)
|
|
19489
17699
|
/* harmony export */ });
|
|
19490
|
-
/* harmony import */ var
|
|
19491
|
-
/* harmony import */ var
|
|
19492
|
-
/* harmony import */ var
|
|
17700
|
+
/* 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");
|
|
17701
|
+
/* harmony import */ var _shared_navigator_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../shared/navigator.js */ "./lib/src/shared/navigator.js");
|
|
17702
|
+
/* harmony import */ var _SharedSyncImplementation_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SharedSyncImplementation.js */ "./lib/src/worker/sync/SharedSyncImplementation.js");
|
|
19493
17703
|
|
|
19494
17704
|
|
|
19495
17705
|
|
|
@@ -19507,14 +17717,14 @@ class WorkerClient {
|
|
|
19507
17717
|
constructor(sync, port) {
|
|
19508
17718
|
this.sync = sync;
|
|
19509
17719
|
this.port = port;
|
|
19510
|
-
|
|
17720
|
+
comlink__WEBPACK_IMPORTED_MODULE_0__.expose(this, this.port);
|
|
19511
17721
|
/**
|
|
19512
17722
|
* Adds an extra listener which can remove this port
|
|
19513
17723
|
* from the list of monitored ports.
|
|
19514
17724
|
*/
|
|
19515
17725
|
this.port.addEventListener('message', async (event) => {
|
|
19516
17726
|
const payload = event.data;
|
|
19517
|
-
if (payload?.event ==
|
|
17727
|
+
if (payload?.event == _SharedSyncImplementation_js__WEBPACK_IMPORTED_MODULE_2__.SharedSyncClientEvent.CLOSE_CLIENT) {
|
|
19518
17728
|
await this.removePort();
|
|
19519
17729
|
}
|
|
19520
17730
|
});
|
|
@@ -19526,7 +17736,7 @@ class WorkerClient {
|
|
|
19526
17736
|
const release = await this.sync.removePort(resolved);
|
|
19527
17737
|
this.resolvedPort = null;
|
|
19528
17738
|
this.port.postMessage({
|
|
19529
|
-
event:
|
|
17739
|
+
event: _SharedSyncImplementation_js__WEBPACK_IMPORTED_MODULE_2__.SharedSyncClientEvent.CLOSE_ACK,
|
|
19530
17740
|
data: {}
|
|
19531
17741
|
});
|
|
19532
17742
|
release?.();
|
|
@@ -19542,7 +17752,7 @@ class WorkerClient {
|
|
|
19542
17752
|
// Only add the port once the lock has been obtained on the client.
|
|
19543
17753
|
this.resolvedPort = await this.sync.addPort(this.port);
|
|
19544
17754
|
// Don't await this lock request
|
|
19545
|
-
(0,
|
|
17755
|
+
(0,_shared_navigator_js__WEBPACK_IMPORTED_MODULE_1__.getNavigatorLocks)().request(name, async () => {
|
|
19546
17756
|
await this.removePort();
|
|
19547
17757
|
});
|
|
19548
17758
|
}
|
|
@@ -19576,7 +17786,7 @@ class WorkerClient {
|
|
|
19576
17786
|
}
|
|
19577
17787
|
|
|
19578
17788
|
|
|
19579
|
-
/***/ }
|
|
17789
|
+
/***/ }
|
|
19580
17790
|
|
|
19581
17791
|
/******/ });
|
|
19582
17792
|
/************************************************************************/
|
|
@@ -19590,6 +17800,12 @@ class WorkerClient {
|
|
|
19590
17800
|
/******/ if (cachedModule !== undefined) {
|
|
19591
17801
|
/******/ return cachedModule.exports;
|
|
19592
17802
|
/******/ }
|
|
17803
|
+
/******/ // Check if module exists (development only)
|
|
17804
|
+
/******/ if (__webpack_modules__[moduleId] === undefined) {
|
|
17805
|
+
/******/ var e = new Error("Cannot find module '" + moduleId + "'");
|
|
17806
|
+
/******/ e.code = 'MODULE_NOT_FOUND';
|
|
17807
|
+
/******/ throw e;
|
|
17808
|
+
/******/ }
|
|
19593
17809
|
/******/ // Create a new module (and put it into the cache)
|
|
19594
17810
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
19595
17811
|
/******/ // no module.id needed
|
|
@@ -19743,18 +17959,18 @@ var __webpack_exports__ = {};
|
|
|
19743
17959
|
\****************************************************************/
|
|
19744
17960
|
__webpack_require__.r(__webpack_exports__);
|
|
19745
17961
|
/* harmony import */ var _powersync_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @powersync/common */ "../common/dist/bundle.mjs");
|
|
19746
|
-
/* harmony import */ var
|
|
19747
|
-
/* harmony import */ var
|
|
17962
|
+
/* harmony import */ var _SharedSyncImplementation_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SharedSyncImplementation.js */ "./lib/src/worker/sync/SharedSyncImplementation.js");
|
|
17963
|
+
/* harmony import */ var _WorkerClient_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./WorkerClient.js */ "./lib/src/worker/sync/WorkerClient.js");
|
|
19748
17964
|
|
|
19749
17965
|
|
|
19750
17966
|
|
|
19751
17967
|
const _self = self;
|
|
19752
17968
|
const logger = (0,_powersync_common__WEBPACK_IMPORTED_MODULE_0__.createBaseLogger)();
|
|
19753
17969
|
logger.useDefaults();
|
|
19754
|
-
const sharedSyncImplementation = new
|
|
17970
|
+
const sharedSyncImplementation = new _SharedSyncImplementation_js__WEBPACK_IMPORTED_MODULE_1__.SharedSyncImplementation();
|
|
19755
17971
|
_self.onconnect = async function (event) {
|
|
19756
17972
|
const port = event.ports[0];
|
|
19757
|
-
new
|
|
17973
|
+
new _WorkerClient_js__WEBPACK_IMPORTED_MODULE_2__.WorkerClient(sharedSyncImplementation, port);
|
|
19758
17974
|
};
|
|
19759
17975
|
|
|
19760
17976
|
})();
|