harperdb 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (578) hide show
  1. package/README.md +20 -11
  2. package/bin/BinObjects.jsc +0 -0
  3. package/bin/harperdb.jsc +0 -0
  4. package/bin/install.jsc +0 -0
  5. package/bin/register.jsc +0 -0
  6. package/bin/run.jsc +0 -0
  7. package/bin/stop.jsc +0 -0
  8. package/bin/upgrade.jsc +0 -0
  9. package/bin/utility.jsc +0 -0
  10. package/bin/version.jsc +0 -0
  11. package/coverage/lcov.info +6624 -6141
  12. package/data_layer/CreateAttributeObject.jsc +0 -0
  13. package/data_layer/CreateTableObject.jsc +0 -0
  14. package/data_layer/DataLayerObjects.jsc +0 -0
  15. package/data_layer/DeleteBeforeObject.jsc +0 -0
  16. package/data_layer/DeleteObject.jsc +0 -0
  17. package/data_layer/DropAttributeObject.jsc +0 -0
  18. package/data_layer/InsertObject.jsc +0 -0
  19. package/data_layer/ReadTransactionLogObject.jsc +0 -0
  20. package/data_layer/SQLSearch.jsc +0 -0
  21. package/data_layer/SearchByConditionsObject.jsc +0 -0
  22. package/data_layer/SearchByHashObject.jsc +0 -0
  23. package/data_layer/SearchObject.jsc +0 -0
  24. package/data_layer/SqlSearchObject.jsc +0 -0
  25. package/data_layer/UpdateObject.jsc +0 -0
  26. package/data_layer/UpsertObject.jsc +0 -0
  27. package/data_layer/bulkLoad.jsc +0 -0
  28. package/data_layer/data_objects/BulkLoadObjects.jsc +0 -0
  29. package/data_layer/data_objects/UpsertObject.jsc +0 -0
  30. package/data_layer/delete.jsc +0 -0
  31. package/data_layer/export.jsc +0 -0
  32. package/data_layer/harperBridge/BridgeMethods.jsc +0 -0
  33. package/data_layer/harperBridge/bridgeUtility/checkForNewAttr.jsc +0 -0
  34. package/data_layer/harperBridge/bridgeUtility/convertOperationToTransaction.jsc +0 -0
  35. package/data_layer/harperBridge/bridgeUtility/evaluateTableGetAttributes.jsc +0 -0
  36. package/data_layer/harperBridge/bridgeUtility/insertUpdateReturnObj.jsc +0 -0
  37. package/data_layer/harperBridge/bridgeUtility/insertUpdateValidate.jsc +0 -0
  38. package/data_layer/harperBridge/harperBridge.jsc +0 -0
  39. package/data_layer/harperBridge/lmdbBridge/LMDBBridge.jsc +0 -0
  40. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/DeleteTransactionsBeforeResults.jsc +0 -0
  41. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateAttribute.jsc +0 -0
  42. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateRecords.jsc +0 -0
  43. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateSchema.jsc +0 -0
  44. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbCreateTable.jsc +0 -0
  45. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteRecords.jsc +0 -0
  46. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteRecordsBefore.jsc +0 -0
  47. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbDeleteTransactionLogsBefore.jsc +0 -0
  48. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropAttribute.jsc +0 -0
  49. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropSchema.jsc +0 -0
  50. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbDropTable.jsc +0 -0
  51. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetDataByHash.jsc +0 -0
  52. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbGetDataByValue.jsc +0 -0
  53. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbReadTransactionLog.jsc +0 -0
  54. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByConditions.jsc +0 -0
  55. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByHash.jsc +0 -0
  56. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbSearchByValue.jsc +0 -0
  57. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpdateRecords.jsc +0 -0
  58. package/data_layer/harperBridge/lmdbBridge/lmdbMethods/lmdbUpsertRecords.jsc +0 -0
  59. package/data_layer/harperBridge/lmdbBridge/lmdbUtility/LMDBCreateAttributeObject.jsc +0 -0
  60. package/data_layer/harperBridge/lmdbBridge/lmdbUtility/LMDBDeleteTransactionObject.jsc +0 -0
  61. package/data_layer/harperBridge/lmdbBridge/lmdbUtility/LMDBInsertTransactionObject.jsc +0 -0
  62. package/data_layer/harperBridge/lmdbBridge/lmdbUtility/LMDBTransactionObject.jsc +0 -0
  63. package/data_layer/harperBridge/lmdbBridge/lmdbUtility/LMDBUpdateTransactionObject.jsc +0 -0
  64. package/data_layer/harperBridge/lmdbBridge/lmdbUtility/LMDBUpsertTransactionObject.jsc +0 -0
  65. package/data_layer/harperBridge/lmdbBridge/lmdbUtility/TableSizeObject.jsc +0 -0
  66. package/data_layer/harperBridge/lmdbBridge/lmdbUtility/ThreadSearchObject.jsc +0 -0
  67. package/data_layer/harperBridge/lmdbBridge/lmdbUtility/initializeHashSearch.jsc +0 -0
  68. package/data_layer/harperBridge/lmdbBridge/lmdbUtility/initializePaths.jsc +0 -0
  69. package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbCheckForNewAttributes.jsc +0 -0
  70. package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbCreateTransactionsEnvironment.jsc +0 -0
  71. package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbDropAllAttributes.jsc +0 -0
  72. package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.jsc +0 -0
  73. package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbProcessRows.jsc +0 -0
  74. package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbSearch.jsc +0 -0
  75. package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbThreadSearch.jsc +0 -0
  76. package/data_layer/harperBridge/lmdbBridge/lmdbUtility/lmdbWriteTransaction.jsc +0 -0
  77. package/data_layer/hdbInfoController.jsc +0 -0
  78. package/data_layer/insert.jsc +0 -0
  79. package/data_layer/readTransactionLog.jsc +0 -0
  80. package/data_layer/schema.jsc +0 -0
  81. package/data_layer/schemaDescribe.jsc +0 -0
  82. package/data_layer/search.jsc +0 -0
  83. package/data_layer/update.jsc +0 -0
  84. package/events/ClusterStatusEmitter.jsc +0 -0
  85. package/events/SioServerStoppedEvent.jsc +0 -0
  86. package/events/SocketClusterStatusEmitter.jsc +0 -0
  87. package/license/LICENSE +91 -1
  88. package/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/README.md +1 -0
  89. package/node_modules/{node-addon-api/src/nothing.c → @msgpackr-extract/msgpackr-extract-linux-x64/index.js} +0 -0
  90. package/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.abi93.glibc.node +0 -0
  91. package/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.abi93.musl.node +0 -0
  92. package/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.napi.glibc.node +0 -0
  93. package/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/node.napi.musl.node +0 -0
  94. package/node_modules/@msgpackr-extract/msgpackr-extract-linux-x64/package.json +53 -0
  95. package/node_modules/{msgpackr-extract → lmdb-store}/.github/workflows/prebuild.yml +9 -10
  96. package/node_modules/lmdb-store/.idea/lmdb-store.iml +12 -0
  97. package/node_modules/lmdb-store/.idea/misc.xml +6 -0
  98. package/node_modules/lmdb-store/.idea/modules.xml +8 -0
  99. package/node_modules/lmdb-store/.idea/workspace.xml +4 -0
  100. package/node_modules/lmdb-store/README.md +393 -388
  101. package/node_modules/lmdb-store/benchmark/index.js +162 -162
  102. package/node_modules/lmdb-store/binding.gyp +79 -88
  103. package/node_modules/lmdb-store/caching.js +113 -113
  104. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/COPYRIGHT +20 -20
  105. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/Doxyfile +1631 -1631
  106. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/LICENSE +47 -47
  107. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/chacha8.c +183 -183
  108. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/chacha8.h +14 -14
  109. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/crypto.c +121 -121
  110. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/intro.doc +192 -192
  111. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb.c +12125 -12125
  112. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_copy.1 +74 -74
  113. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_copy.c +106 -106
  114. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_drop.1 +53 -53
  115. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_drop.c +154 -154
  116. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_dump.1 +94 -94
  117. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_dump.c +333 -333
  118. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_load.1 +97 -97
  119. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_load.c +530 -530
  120. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_stat.1 +83 -83
  121. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb_stat.c +276 -276
  122. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/midl.c +452 -452
  123. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/midl.h +208 -208
  124. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/module.c +101 -101
  125. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/module.h +16 -16
  126. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest.c +178 -178
  127. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest2.c +124 -124
  128. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest3.c +133 -133
  129. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest4.c +168 -168
  130. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest5.c +135 -135
  131. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest6.c +141 -141
  132. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest_enc.c +190 -190
  133. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest_enc2.c +189 -189
  134. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/mtest_remap.c +177 -177
  135. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/sample-bdb.txt +73 -73
  136. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/sample-mdb.txt +62 -62
  137. package/node_modules/lmdb-store/dependencies/lmdb/libraries/liblmdb/tooltag +27 -27
  138. package/node_modules/lmdb-store/dependencies/lz4/LICENSE +11 -11
  139. package/node_modules/lmdb-store/dependencies/lz4/lib/README.md +137 -137
  140. package/node_modules/lmdb-store/dependencies/lz4/lib/dll/example/README.md +69 -69
  141. package/node_modules/lmdb-store/dependencies/lz4/lib/lz4frame.c +1899 -1899
  142. package/node_modules/lmdb-store/dependencies/lz4/lib/xxhash.c +1030 -1030
  143. package/node_modules/lmdb-store/dependencies/lz4/lib/xxhash.h +328 -328
  144. package/node_modules/lmdb-store/dist/index.cjs +2591 -0
  145. package/node_modules/lmdb-store/dist/index.cjs.map +1 -0
  146. package/node_modules/lmdb-store/index.d.ts +323 -323
  147. package/node_modules/lmdb-store/index.js +1274 -1274
  148. package/node_modules/lmdb-store/index.mjs +3 -3
  149. package/node_modules/lmdb-store/package.json +16 -11
  150. package/node_modules/lmdb-store/prebuilds/darwin-arm64/electron.abi98.node +0 -0
  151. package/node_modules/lmdb-store/prebuilds/darwin-arm64/node.abi83.node +0 -0
  152. package/node_modules/lmdb-store/prebuilds/darwin-arm64/node.abi93.node +0 -0
  153. package/node_modules/lmdb-store/prebuilds/darwin-x64/electron.abi98.node +0 -0
  154. package/node_modules/lmdb-store/prebuilds/darwin-x64/node.abi83.node +0 -0
  155. package/node_modules/lmdb-store/prebuilds/darwin-x64/node.abi93.node +0 -0
  156. package/node_modules/lmdb-store/prebuilds/linux-arm64/electron.abi98.node +0 -0
  157. package/node_modules/lmdb-store/prebuilds/linux-arm64/node.abi83.node +0 -0
  158. package/node_modules/lmdb-store/prebuilds/linux-arm64/node.abi93.node +0 -0
  159. package/node_modules/lmdb-store/prebuilds/linux-x64/electron.abi98.node +0 -0
  160. package/node_modules/lmdb-store/prebuilds/linux-x64/node.abi83.musl.node +0 -0
  161. package/node_modules/lmdb-store/prebuilds/linux-x64/node.abi83.node +0 -0
  162. package/node_modules/lmdb-store/prebuilds/linux-x64/node.abi93.musl.node +0 -0
  163. package/node_modules/lmdb-store/prebuilds/linux-x64/node.abi93.node +0 -0
  164. package/node_modules/lmdb-store/prebuilds/win32-x64/electron.abi98.node +0 -0
  165. package/node_modules/lmdb-store/prebuilds/win32-x64/node.abi83.node +0 -0
  166. package/node_modules/lmdb-store/prebuilds/win32-x64/node.abi93.node +0 -0
  167. package/node_modules/lmdb-store/src/compression.cpp +181 -181
  168. package/node_modules/lmdb-store/src/cursor.cpp +407 -407
  169. package/node_modules/lmdb-store/src/dbi.cpp +354 -354
  170. package/node_modules/lmdb-store/src/env.cpp +1134 -1134
  171. package/node_modules/lmdb-store/src/misc.cpp +528 -528
  172. package/node_modules/lmdb-store/src/node-lmdb.cpp +44 -44
  173. package/node_modules/lmdb-store/src/node-lmdb.h +965 -965
  174. package/node_modules/lmdb-store/src/ordered-binary.cpp +337 -337
  175. package/node_modules/lmdb-store/src/txn.cpp +513 -513
  176. package/node_modules/lmdb-store/src/v8-fast-api-calls.h +419 -419
  177. package/node_modules/lmdb-store/src/windows.c +30 -30
  178. package/node_modules/lmdb-store/test/index.test.js +584 -584
  179. package/node_modules/lmdb-store/test/node-lmdb.test.js +1525 -1525
  180. package/node_modules/lmdb-store/test/threads.js +100 -100
  181. package/node_modules/lmdb-store/util/ArrayLikeIterable.js +136 -136
  182. package/node_modules/lmdb-store/util/WeakValueMap.js +40 -40
  183. package/node_modules/lmdb-store/util/upgrade-lmdb.js +46 -46
  184. package/node_modules/lmdb-store/util/when.js +8 -8
  185. package/node_modules/microtime/.github/workflows/release.yml +76 -0
  186. package/node_modules/microtime/.github/workflows/test.yml +46 -0
  187. package/node_modules/microtime/README.md +0 -2
  188. package/node_modules/microtime/binding.gyp +28 -10
  189. package/node_modules/microtime/package.json +25 -20
  190. package/node_modules/microtime/prebuilds/darwin-x64+arm64/electron.napi.node +0 -0
  191. package/node_modules/microtime/prebuilds/darwin-x64+arm64/node.napi.node +0 -0
  192. package/node_modules/microtime/prebuilds/linux-arm/node.napi.armv7.node +0 -0
  193. package/node_modules/microtime/prebuilds/linux-arm64/node.napi.armv8.node +0 -0
  194. package/node_modules/microtime/prebuilds/linux-x64/electron.napi.node +0 -0
  195. package/node_modules/microtime/prebuilds/linux-x64/node.napi.node +0 -0
  196. package/node_modules/microtime/prebuilds/win32-ia32/electron.napi.node +0 -0
  197. package/node_modules/microtime/prebuilds/win32-ia32/node.napi.node +0 -0
  198. package/node_modules/microtime/prebuilds/win32-x64/electron.napi.node +0 -0
  199. package/node_modules/microtime/prebuilds/win32-x64/node.napi.node +0 -0
  200. package/node_modules/msgpackr/dist/index.js +1929 -1917
  201. package/node_modules/msgpackr/dist/index.min.js +67 -68
  202. package/node_modules/msgpackr/dist/node.cjs +1994 -1980
  203. package/node_modules/msgpackr/dist/test.js +683 -1235
  204. package/node_modules/msgpackr/index.d.ts +23 -12
  205. package/node_modules/msgpackr/node-index.js +23 -21
  206. package/node_modules/msgpackr/pack.js +935 -931
  207. package/node_modules/msgpackr/package.json +24 -12
  208. package/node_modules/msgpackr/unpack.d.ts +52 -50
  209. package/node_modules/msgpackr/unpack.js +1061 -1053
  210. package/node_modules/msgpackr-extract/bin/download-prebuilds.js +11 -0
  211. package/node_modules/msgpackr-extract/binding.gyp +22 -5
  212. package/node_modules/msgpackr-extract/index.js +1 -1
  213. package/node_modules/msgpackr-extract/package.json +46 -21
  214. package/node_modules/msgpackr-extract/src/.vs/ProjectSettings.json +3 -0
  215. package/node_modules/msgpackr-extract/src/.vs/VSWorkspaceState.json +7 -0
  216. package/node_modules/msgpackr-extract/src/.vs/slnx.sqlite +0 -0
  217. package/node_modules/msgpackr-extract/src/.vs/src/v16/.suo +0 -0
  218. package/node_modules/msgpackr-extract/src/.vs/src/v16/Browse.VC.db +0 -0
  219. package/node_modules/msgpackr-extract/{prebuilds/darwin-x64/node.abi72.node → src/.vs/src/v16/Browse.VC.db-shm} +0 -0
  220. package/node_modules/msgpackr-extract/src/.vs/src/v16/Browse.VC.db-wal +0 -0
  221. package/node_modules/msgpackr-extract/src/extract.cpp +272 -269
  222. package/node_modules/nan/package.json +0 -1
  223. package/node_modules/node-addon-api/README.md +146 -53
  224. package/node_modules/node-addon-api/common.gypi +21 -0
  225. package/node_modules/node-addon-api/except.gypi +25 -0
  226. package/node_modules/node-addon-api/index.js +7 -41
  227. package/node_modules/node-addon-api/napi-inl.deprecated.h +8 -8
  228. package/node_modules/node-addon-api/napi-inl.h +2795 -633
  229. package/node_modules/node-addon-api/napi.h +1547 -597
  230. package/node_modules/node-addon-api/node_api.gyp +9 -0
  231. package/node_modules/node-addon-api/noexcept.gypi +26 -0
  232. package/node_modules/node-addon-api/nothing.c +0 -0
  233. package/node_modules/node-addon-api/package-support.json +21 -0
  234. package/node_modules/node-addon-api/package.json +203 -13
  235. package/node_modules/node-addon-api/tools/README.md +12 -6
  236. package/node_modules/node-addon-api/tools/clang-format.js +71 -0
  237. package/node_modules/node-addon-api/tools/conversion.js +4 -8
  238. package/node_modules/node-addon-api/tools/eslint-format.js +71 -0
  239. package/node_modules/node-gyp-build/README.md +17 -14
  240. package/node_modules/node-gyp-build/bin.js +28 -15
  241. package/node_modules/node-gyp-build/index.js +145 -34
  242. package/node_modules/node-gyp-build/package.json +18 -15
  243. package/node_modules/{lmdb-store/node_modules/node-gyp-build → node-gyp-build-optional-packages}/LICENSE +0 -0
  244. package/node_modules/{lmdb-store/node_modules/node-gyp-build → node-gyp-build-optional-packages}/README.md +0 -0
  245. package/node_modules/{lmdb-store/node_modules/node-gyp-build → node-gyp-build-optional-packages}/bin.js +1 -1
  246. package/node_modules/{lmdb-store/node_modules/node-gyp-build → node-gyp-build-optional-packages}/build-test.js +0 -0
  247. package/node_modules/{lmdb-store/node_modules/node-gyp-build → node-gyp-build-optional-packages}/index.js +17 -11
  248. package/node_modules/{lmdb-store/node_modules/node-gyp-build → node-gyp-build-optional-packages}/optional.js +0 -0
  249. package/node_modules/{msgpackr-extract/node_modules/node-gyp-build → node-gyp-build-optional-packages}/package.json +17 -17
  250. package/package.json +12 -11
  251. package/security/JWTObjects.jsc +0 -0
  252. package/security/auth.jsc +0 -0
  253. package/security/cryptoHash.jsc +0 -0
  254. package/security/data_objects/PermissionAttributeResponseObject.jsc +0 -0
  255. package/security/data_objects/PermissionResponseObject.jsc +0 -0
  256. package/security/data_objects/PermissionTableResponseObject.jsc +0 -0
  257. package/security/permissionsTranslator.jsc +0 -0
  258. package/security/role.jsc +0 -0
  259. package/security/tokenAuthentication.jsc +0 -0
  260. package/security/user.jsc +0 -0
  261. package/server/ClusteringOriginObject.jsc +0 -0
  262. package/server/JobObject.jsc +0 -0
  263. package/server/clustering/ClusterStatusObject.jsc +0 -0
  264. package/server/clustering/NodeObject.jsc +0 -0
  265. package/server/clustering/clusterUtilities.jsc +0 -0
  266. package/server/configuration.jsc +0 -0
  267. package/server/customFunctions/customFunctionsServer.jsc +0 -0
  268. package/server/customFunctions/helpers/getCORSOptions.jsc +0 -0
  269. package/server/customFunctions/helpers/getHeaderTimeoutConfig.jsc +0 -0
  270. package/server/customFunctions/helpers/getServerOptions.jsc +0 -0
  271. package/server/customFunctions/operations.jsc +0 -0
  272. package/server/customFunctions/operationsValidation.jsc +0 -0
  273. package/server/harperdb/hdbServer.jsc +0 -0
  274. package/server/ipc/IPCClient.jsc +0 -0
  275. package/server/ipc/hdbIpcServer.jsc +0 -0
  276. package/server/ipc/serverHandlers.jsc +0 -0
  277. package/server/ipc/utility/IPCEventObject.jsc +0 -0
  278. package/server/ipc/utility/ipcUtils.jsc +0 -0
  279. package/server/jobRunner.jsc +0 -0
  280. package/server/jobThread.jsc +0 -0
  281. package/server/jobs.jsc +0 -0
  282. package/server/serverHelpers/OperationFunctionObject.jsc +0 -0
  283. package/server/serverHelpers/requestTimePlugin.jsc +0 -0
  284. package/server/serverHelpers/serverHandlers.jsc +0 -0
  285. package/server/serverHelpers/serverUtilities.jsc +0 -0
  286. package/server/socketcluster/Server.jsc +0 -0
  287. package/server/socketcluster/broker.jsc +0 -0
  288. package/server/socketcluster/connector/HDBSocketConnector.jsc +0 -0
  289. package/server/socketcluster/connector/InterNodeSocketConnector.jsc +0 -0
  290. package/server/socketcluster/connector/SocketConnector.jsc +0 -0
  291. package/server/socketcluster/connector/spawnSCConnection.jsc +0 -0
  292. package/server/socketcluster/decisionMatrix/CoreDecisionMatrix.jsc +0 -0
  293. package/server/socketcluster/decisionMatrix/DecisionMatrixIF.jsc +0 -0
  294. package/server/socketcluster/decisionMatrix/rules/AssignToHdbChildWorkerRule.jsc +0 -0
  295. package/server/socketcluster/decisionMatrix/rules/CallRoomMsgHandlerRule.jsc +0 -0
  296. package/server/socketcluster/decisionMatrix/rules/CleanDataObjectRule.jsc +0 -0
  297. package/server/socketcluster/decisionMatrix/rules/CommandCollection.jsc +0 -0
  298. package/server/socketcluster/decisionMatrix/rules/DummyRule.jsc +0 -0
  299. package/server/socketcluster/decisionMatrix/rules/RulesIF.jsc +0 -0
  300. package/server/socketcluster/decisionMatrix/rules/StripHdbHeaderRule.jsc +0 -0
  301. package/server/socketcluster/decisionMatrix/rules/TestRule.jsc +0 -0
  302. package/server/socketcluster/handlers/NodeConnectionsHandler.jsc +0 -0
  303. package/server/socketcluster/handlers/SCServer.jsc +0 -0
  304. package/server/socketcluster/handlers/ServerSocket.jsc +0 -0
  305. package/server/socketcluster/interNodeConnectionLauncher.jsc +0 -0
  306. package/server/socketcluster/messageQueue/MessageQueueIF.jsc +0 -0
  307. package/server/socketcluster/middleware/AuthMiddleware.jsc +0 -0
  308. package/server/socketcluster/middleware/ConnectionNameCheckMiddleware.jsc +0 -0
  309. package/server/socketcluster/middleware/GenericMiddleware.jsc +0 -0
  310. package/server/socketcluster/middleware/MessagePrepMiddleware.jsc +0 -0
  311. package/server/socketcluster/middleware/MiddlewareFactory.jsc +0 -0
  312. package/server/socketcluster/middleware/MiddlewareIF.jsc +0 -0
  313. package/server/socketcluster/middleware/OriginatorCheckMiddleware.jsc +0 -0
  314. package/server/socketcluster/middleware/RequestDataValidMiddleware.jsc +0 -0
  315. package/server/socketcluster/middleware/StampOriginatorMiddleware.jsc +0 -0
  316. package/server/socketcluster/middleware/StampRequestMiddleware.jsc +0 -0
  317. package/server/socketcluster/observer/EventableIF.jsc +0 -0
  318. package/server/socketcluster/room/AddUserRoom.jsc +0 -0
  319. package/server/socketcluster/room/AlterUserRoom.jsc +0 -0
  320. package/server/socketcluster/room/CoreRoom.jsc +0 -0
  321. package/server/socketcluster/room/CreateAttributeRoom.jsc +0 -0
  322. package/server/socketcluster/room/CreateSchemaRoom.jsc +0 -0
  323. package/server/socketcluster/room/CreateTableRoom.jsc +0 -0
  324. package/server/socketcluster/room/DropUserRoom.jsc +0 -0
  325. package/server/socketcluster/room/HDBNodeRoom.jsc +0 -0
  326. package/server/socketcluster/room/RoomIF.jsc +0 -0
  327. package/server/socketcluster/room/RoomMessageObjects.jsc +0 -0
  328. package/server/socketcluster/room/UsersRoom.jsc +0 -0
  329. package/server/socketcluster/room/WatchHDBWorkersRoom.jsc +0 -0
  330. package/server/socketcluster/room/WorkerRoom.jsc +0 -0
  331. package/server/socketcluster/room/roomFactory.jsc +0 -0
  332. package/server/socketcluster/socketClusterObjects.jsc +0 -0
  333. package/server/socketcluster/types.jsc +0 -0
  334. package/server/socketcluster/util/clusterData.jsc +0 -0
  335. package/server/socketcluster/util/socketClusterUtils.jsc +0 -0
  336. package/server/socketcluster/worker/ClusterWorker.jsc +0 -0
  337. package/server/socketcluster/worker/WorkerIF.jsc +0 -0
  338. package/server/socketcluster/worker/WorkerObjects.jsc +0 -0
  339. package/server/transactToClusteringUtilities.jsc +0 -0
  340. package/sqlTranslator/SelectValidator.jsc +0 -0
  341. package/sqlTranslator/alasqlFunctionImporter.jsc +0 -0
  342. package/sqlTranslator/conditionPatterns.jsc +0 -0
  343. package/sqlTranslator/deleteTranslator.jsc +0 -0
  344. package/sqlTranslator/index.jsc +0 -0
  345. package/sqlTranslator/sql_statement_bucket.jsc +0 -0
  346. package/upgrade/EnvironmentVariable.jsc +0 -0
  347. package/upgrade/UpgradeDirective.jsc +0 -0
  348. package/upgrade/UpgradeObjects.jsc +0 -0
  349. package/upgrade/directives/3-0-0.jsc +0 -0
  350. package/upgrade/directives/3-1-0.jsc +0 -0
  351. package/upgrade/directives/directivesController.jsc +0 -0
  352. package/upgrade/directives/upgrade_scripts/3_0_0_reindex_script.jsc +0 -0
  353. package/upgrade/directivesManager.jsc +0 -0
  354. package/upgrade/lmdb/nodeLMDB/DBIDefinition.jsc +0 -0
  355. package/upgrade/lmdb/nodeLMDB/OpenDBIObject.jsc +0 -0
  356. package/upgrade/lmdb/nodeLMDB/OpenEnvironmentObject.jsc +0 -0
  357. package/upgrade/lmdb/nodeLMDB/commonErrors.jsc +0 -0
  358. package/upgrade/lmdb/nodeLMDB/commonUtility.jsc +0 -0
  359. package/upgrade/lmdb/nodeLMDB/environmentUtility.jsc +0 -0
  360. package/upgrade/lmdb/nodeLMDB/terms.jsc +0 -0
  361. package/upgrade/upgradePrompt.jsc +0 -0
  362. package/upgrade/upgradeUtilities.jsc +0 -0
  363. package/utility/AWS/AWSConnector.jsc +0 -0
  364. package/utility/OperationFunctionCaller.jsc +0 -0
  365. package/utility/common_utils.jsc +0 -0
  366. package/utility/environment/SystemInformationObject.jsc +0 -0
  367. package/utility/environment/SystemInformationOperation.jsc +0 -0
  368. package/utility/environment/environmentManager.jsc +0 -0
  369. package/utility/environment/systemInformation.jsc +0 -0
  370. package/utility/errors/commonErrors.jsc +0 -0
  371. package/utility/errors/hdbError.jsc +0 -0
  372. package/utility/functions/date/dateFunctions.jsc +0 -0
  373. package/utility/functions/geo.jsc +0 -0
  374. package/utility/functions/math/avg.jsc +0 -0
  375. package/utility/functions/math/count.jsc +0 -0
  376. package/utility/functions/sql/alaSQLExtension.jsc +0 -0
  377. package/utility/functions/string/compare.jsc +0 -0
  378. package/utility/globalSchema.jsc +0 -0
  379. package/utility/hdbTerms.jsc +0 -0
  380. package/utility/install/checkJWTTokensExist.jsc +0 -0
  381. package/utility/install/installer.jsc +0 -0
  382. package/utility/install_user_permission.jsc +0 -0
  383. package/utility/lmdb/DBIDefinition.jsc +0 -0
  384. package/utility/lmdb/DeleteRecordsResponseObject.jsc +0 -0
  385. package/utility/lmdb/InsertRecordsResponseObject.jsc +0 -0
  386. package/utility/lmdb/OpenDBIObject.jsc +0 -0
  387. package/utility/lmdb/OpenEnvironmentObject.jsc +0 -0
  388. package/utility/lmdb/UpdateRecordsResponseObject.jsc +0 -0
  389. package/utility/lmdb/UpsertRecordsResponseObject.jsc +0 -0
  390. package/utility/lmdb/cleanLMDBMap.jsc +0 -0
  391. package/utility/lmdb/commonUtility.jsc +0 -0
  392. package/utility/lmdb/deleteUtility.jsc +0 -0
  393. package/utility/lmdb/environmentUtility.jsc +0 -0
  394. package/utility/lmdb/searchCursorFunctions.jsc +0 -0
  395. package/utility/lmdb/searchUtility.jsc +0 -0
  396. package/utility/lmdb/terms.jsc +0 -0
  397. package/utility/lmdb/writeUtility.jsc +0 -0
  398. package/utility/logging/harper_logger.jsc +0 -0
  399. package/utility/mount_hdb.jsc +0 -0
  400. package/utility/npmUtilities.jsc +0 -0
  401. package/utility/operation_authorization.jsc +0 -0
  402. package/utility/password.jsc +0 -0
  403. package/utility/pm2/servicesConfig.jsc +0 -0
  404. package/utility/pm2/utilityFunctions.jsc +0 -0
  405. package/utility/psList.jsc +0 -0
  406. package/utility/registration/hdb_license.jsc +0 -0
  407. package/utility/registration/licenseObjects.jsc +0 -0
  408. package/utility/registration/registrationHandler.jsc +0 -0
  409. package/utility/scripts/restartHdb.jsc +0 -0
  410. package/utility/signalling.jsc +0 -0
  411. package/utility/system_info.jsc +0 -0
  412. package/validation/bulkDeleteValidator.jsc +0 -0
  413. package/validation/check_permissions.jsc +0 -0
  414. package/validation/clustering/configureValidator.jsc +0 -0
  415. package/validation/common_validators.jsc +0 -0
  416. package/validation/conditionalDeleteValidator.jsc +0 -0
  417. package/validation/deleteValidator.jsc +0 -0
  418. package/validation/fileLoadValidator.jsc +0 -0
  419. package/validation/insertValidator.jsc +0 -0
  420. package/validation/nodeSubscriptionValidator.jsc +0 -0
  421. package/validation/nodeValidator.jsc +0 -0
  422. package/validation/readLogValidator.jsc +0 -0
  423. package/validation/registration/license_key_object.jsc +0 -0
  424. package/validation/role_validation.jsc +0 -0
  425. package/validation/schemaMetadataValidator.jsc +0 -0
  426. package/validation/schema_validator.jsc +0 -0
  427. package/validation/searchValidator.jsc +0 -0
  428. package/validation/user_validation.jsc +0 -0
  429. package/validation/validationWrapper.jsc +0 -0
  430. package/node_modules/lmdb-store/build/Makefile +0 -324
  431. package/node_modules/lmdb-store/build/Release/.deps/Release/lmdb-store.node.d +0 -1
  432. package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/dependencies/lmdb/libraries/liblmdb/chacha8.o.d +0 -6
  433. package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb.o.d +0 -8
  434. package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/dependencies/lmdb/libraries/liblmdb/midl.o.d +0 -8
  435. package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/dependencies/lz4/lib/lz4.o.d +0 -5
  436. package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/compression.o.d +0 -72
  437. package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/cursor.o.d +0 -73
  438. package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/dbi.o.d +0 -73
  439. package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/env.o.d +0 -73
  440. package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/misc.o.d +0 -73
  441. package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/node-lmdb.o.d +0 -73
  442. package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/ordered-binary.o.d +0 -73
  443. package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/txn.o.d +0 -73
  444. package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store/src/windows.o.d +0 -3
  445. package/node_modules/lmdb-store/build/Release/.deps/Release/obj.target/lmdb-store.node.d +0 -1
  446. package/node_modules/lmdb-store/build/Release/lmdb-store.node +0 -0
  447. package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/dependencies/lmdb/libraries/liblmdb/chacha8.o +0 -0
  448. package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/dependencies/lmdb/libraries/liblmdb/mdb.o +0 -0
  449. package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/dependencies/lmdb/libraries/liblmdb/midl.o +0 -0
  450. package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/dependencies/lz4/lib/lz4.o +0 -0
  451. package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/compression.o +0 -0
  452. package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/cursor.o +0 -0
  453. package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/dbi.o +0 -0
  454. package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/env.o +0 -0
  455. package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/misc.o +0 -0
  456. package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/node-lmdb.o +0 -0
  457. package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/ordered-binary.o +0 -0
  458. package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/txn.o +0 -0
  459. package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store/src/windows.o +0 -0
  460. package/node_modules/lmdb-store/build/Release/obj.target/lmdb-store.node +0 -0
  461. package/node_modules/lmdb-store/build/binding.Makefile +0 -6
  462. package/node_modules/lmdb-store/build/config.gypi +0 -426
  463. package/node_modules/lmdb-store/build/lmdb-store.target.mk +0 -206
  464. package/node_modules/lmdb-store/node_modules/node-gyp-build/package.json +0 -60
  465. package/node_modules/lmdb-store/prebuilds/darwin-x64/electron.abi87.node +0 -0
  466. package/node_modules/lmdb-store/prebuilds/darwin-x64/node.abi72.node +0 -0
  467. package/node_modules/lmdb-store/prebuilds/darwin-x64/node.abi88.node +0 -0
  468. package/node_modules/lmdb-store/prebuilds/win32-x64/electron.abi87.node +0 -0
  469. package/node_modules/lmdb-store/prebuilds/win32-x64/node.abi72.node +0 -0
  470. package/node_modules/lmdb-store/prebuilds/win32-x64/node.abi88.node +0 -0
  471. package/node_modules/microtime/prebuilds/darwin-x64/electron-napi.node +0 -0
  472. package/node_modules/microtime/prebuilds/darwin-x64/node-napi.node +0 -0
  473. package/node_modules/microtime/prebuilds/linux-arm/electron-napi.node +0 -0
  474. package/node_modules/microtime/prebuilds/linux-arm/node-napi.node +0 -0
  475. package/node_modules/microtime/prebuilds/linux-x64/electron-napi.node +0 -0
  476. package/node_modules/microtime/prebuilds/linux-x64/node-napi.node +0 -0
  477. package/node_modules/microtime/prebuilds/win32-x64/electron-napi.node +0 -0
  478. package/node_modules/microtime/prebuilds/win32-x64/node-napi.node +0 -0
  479. package/node_modules/msgpackr-extract/.circleci/config.yml +0 -19
  480. package/node_modules/msgpackr-extract/.travis.yml +0 -30
  481. package/node_modules/msgpackr-extract/node_modules/node-gyp-build/LICENSE +0 -21
  482. package/node_modules/msgpackr-extract/node_modules/node-gyp-build/README.md +0 -58
  483. package/node_modules/msgpackr-extract/node_modules/node-gyp-build/bin.js +0 -77
  484. package/node_modules/msgpackr-extract/node_modules/node-gyp-build/build-test.js +0 -19
  485. package/node_modules/msgpackr-extract/node_modules/node-gyp-build/index.js +0 -202
  486. package/node_modules/msgpackr-extract/node_modules/node-gyp-build/optional.js +0 -7
  487. package/node_modules/msgpackr-extract/prebuilds/darwin-arm64/electron.abi98.node +0 -0
  488. package/node_modules/msgpackr-extract/prebuilds/darwin-arm64/node.abi102.node +0 -0
  489. package/node_modules/msgpackr-extract/prebuilds/darwin-arm64/node.abi83.node +0 -0
  490. package/node_modules/msgpackr-extract/prebuilds/darwin-arm64/node.abi93.node +0 -0
  491. package/node_modules/msgpackr-extract/prebuilds/darwin-x64/electron.abi98.node +0 -0
  492. package/node_modules/msgpackr-extract/prebuilds/darwin-x64/node.abi102.node +0 -0
  493. package/node_modules/msgpackr-extract/prebuilds/darwin-x64/node.abi83.node +0 -0
  494. package/node_modules/msgpackr-extract/prebuilds/darwin-x64/node.abi88.node +0 -0
  495. package/node_modules/msgpackr-extract/prebuilds/darwin-x64/node.abi93.node +0 -0
  496. package/node_modules/msgpackr-extract/prebuilds/linux-arm64/electron.abi98.node +0 -0
  497. package/node_modules/msgpackr-extract/prebuilds/linux-arm64/node.abi102.node +0 -0
  498. package/node_modules/msgpackr-extract/prebuilds/linux-arm64/node.abi83.node +0 -0
  499. package/node_modules/msgpackr-extract/prebuilds/linux-arm64/node.abi93.node +0 -0
  500. package/node_modules/msgpackr-extract/prebuilds/linux-x64/electron.abi98.node +0 -0
  501. package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi102.musl.node +0 -0
  502. package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi102.node +0 -0
  503. package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi72.musl.node +0 -0
  504. package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi72.node +0 -0
  505. package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi83.musl.node +0 -0
  506. package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi83.node +0 -0
  507. package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi88.node +0 -0
  508. package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi93.musl.node +0 -0
  509. package/node_modules/msgpackr-extract/prebuilds/linux-x64/node.abi93.node +0 -0
  510. package/node_modules/msgpackr-extract/prebuilds/win32-x64/electron.abi98.node +0 -0
  511. package/node_modules/msgpackr-extract/prebuilds/win32-x64/node.abi102.node +0 -0
  512. package/node_modules/msgpackr-extract/prebuilds/win32-x64/node.abi72.node +0 -0
  513. package/node_modules/msgpackr-extract/prebuilds/win32-x64/node.abi83.node +0 -0
  514. package/node_modules/msgpackr-extract/prebuilds/win32-x64/node.abi88.node +0 -0
  515. package/node_modules/msgpackr-extract/prebuilds/win32-x64/node.abi93.node +0 -0
  516. package/node_modules/node-addon-api/.editorconfig +0 -8
  517. package/node_modules/node-addon-api/.travis.yml +0 -65
  518. package/node_modules/node-addon-api/CHANGELOG.md +0 -325
  519. package/node_modules/node-addon-api/CODE_OF_CONDUCT.md +0 -4
  520. package/node_modules/node-addon-api/CONTRIBUTING.md +0 -66
  521. package/node_modules/node-addon-api/appveyor.yml +0 -48
  522. package/node_modules/node-addon-api/doc/Doxyfile +0 -2450
  523. package/node_modules/node-addon-api/doc/array_buffer.md +0 -129
  524. package/node_modules/node-addon-api/doc/async_context.md +0 -76
  525. package/node_modules/node-addon-api/doc/async_operations.md +0 -31
  526. package/node_modules/node-addon-api/doc/async_worker.md +0 -397
  527. package/node_modules/node-addon-api/doc/basic_types.md +0 -415
  528. package/node_modules/node-addon-api/doc/bigint.md +0 -92
  529. package/node_modules/node-addon-api/doc/boolean.md +0 -64
  530. package/node_modules/node-addon-api/doc/buffer.md +0 -140
  531. package/node_modules/node-addon-api/doc/callback_scope.md +0 -54
  532. package/node_modules/node-addon-api/doc/callbackinfo.md +0 -97
  533. package/node_modules/node-addon-api/doc/checker-tool.md +0 -32
  534. package/node_modules/node-addon-api/doc/class_property_descriptor.md +0 -118
  535. package/node_modules/node-addon-api/doc/cmake-js.md +0 -19
  536. package/node_modules/node-addon-api/doc/conversion-tool.md +0 -28
  537. package/node_modules/node-addon-api/doc/creating_a_release.md +0 -62
  538. package/node_modules/node-addon-api/doc/dataview.md +0 -244
  539. package/node_modules/node-addon-api/doc/env.md +0 -63
  540. package/node_modules/node-addon-api/doc/error.md +0 -115
  541. package/node_modules/node-addon-api/doc/error_handling.md +0 -186
  542. package/node_modules/node-addon-api/doc/escapable_handle_scope.md +0 -82
  543. package/node_modules/node-addon-api/doc/external.md +0 -59
  544. package/node_modules/node-addon-api/doc/function.md +0 -294
  545. package/node_modules/node-addon-api/doc/function_reference.md +0 -238
  546. package/node_modules/node-addon-api/doc/generator.md +0 -13
  547. package/node_modules/node-addon-api/doc/handle_scope.md +0 -65
  548. package/node_modules/node-addon-api/doc/memory_management.md +0 -27
  549. package/node_modules/node-addon-api/doc/node-gyp.md +0 -82
  550. package/node_modules/node-addon-api/doc/number.md +0 -163
  551. package/node_modules/node-addon-api/doc/object.md +0 -202
  552. package/node_modules/node-addon-api/doc/object_lifetime_management.md +0 -83
  553. package/node_modules/node-addon-api/doc/object_reference.md +0 -117
  554. package/node_modules/node-addon-api/doc/object_wrap.md +0 -546
  555. package/node_modules/node-addon-api/doc/prebuild_tools.md +0 -16
  556. package/node_modules/node-addon-api/doc/promises.md +0 -74
  557. package/node_modules/node-addon-api/doc/property_descriptor.md +0 -231
  558. package/node_modules/node-addon-api/doc/range_error.md +0 -59
  559. package/node_modules/node-addon-api/doc/reference.md +0 -111
  560. package/node_modules/node-addon-api/doc/setup.md +0 -82
  561. package/node_modules/node-addon-api/doc/string.md +0 -89
  562. package/node_modules/node-addon-api/doc/symbol.md +0 -44
  563. package/node_modules/node-addon-api/doc/threadsafe_function.md +0 -303
  564. package/node_modules/node-addon-api/doc/type_error.md +0 -59
  565. package/node_modules/node-addon-api/doc/typed_array.md +0 -74
  566. package/node_modules/node-addon-api/doc/typed_array_of.md +0 -133
  567. package/node_modules/node-addon-api/doc/value.md +0 -269
  568. package/node_modules/node-addon-api/doc/version_management.md +0 -43
  569. package/node_modules/node-addon-api/doc/working_with_javascript_values.md +0 -14
  570. package/node_modules/node-addon-api/external-napi/node_api.h +0 -7
  571. package/node_modules/node-addon-api/src/node_api.cc +0 -3655
  572. package/node_modules/node-addon-api/src/node_api.gyp +0 -21
  573. package/node_modules/node-addon-api/src/node_api.h +0 -588
  574. package/node_modules/node-addon-api/src/node_api_types.h +0 -115
  575. package/node_modules/node-addon-api/src/node_internals.cc +0 -142
  576. package/node_modules/node-addon-api/src/node_internals.h +0 -157
  577. package/node_modules/node-addon-api/src/util-inl.h +0 -38
  578. package/node_modules/node-addon-api/src/util.h +0 -7
@@ -1,1053 +1,1061 @@
1
- "use strict"
2
- var decoder
3
- try {
4
- decoder = new TextDecoder()
5
- } catch(error) {}
6
- var src
7
- var srcEnd
8
- var position = 0
9
- var alreadySet
10
- const EMPTY_ARRAY = []
11
- var strings = EMPTY_ARRAY
12
- var stringPosition = 0
13
- var currentUnpackr = {}
14
- var currentStructures
15
- var srcString
16
- var srcStringStart = 0
17
- var srcStringEnd = 0
18
- var bundledStrings
19
- var referenceMap
20
- var currentExtensions = []
21
- var dataView
22
- var defaultOptions = {
23
- useRecords: false,
24
- mapsAsObjects: true
25
- }
26
- export class C1Type {}
27
- export const C1 = new C1Type()
28
- C1.name = 'MessagePack 0xC1'
29
- var sequentialMode = false
30
- var inlineObjectReadThreshold = 2
31
- try {
32
- new Function('')
33
- } catch(error) {
34
- // if eval variants are not supported, do not create inline object readers ever
35
- inlineObjectReadThreshold = Infinity
36
- }
37
-
38
- export class Unpackr {
39
- constructor(options) {
40
- if (options) {
41
- if (options.useRecords === false && options.mapsAsObjects === undefined)
42
- options.mapsAsObjects = true
43
- if (options.structures)
44
- options.structures.sharedLength = options.structures.length
45
- else if (options.getStructures) {
46
- (options.structures = []).uninitialized = true // this is what we use to denote an uninitialized structures
47
- options.structures.sharedLength = 0
48
- }
49
- }
50
- Object.assign(this, options)
51
- }
52
- unpack(source, end) {
53
- if (src) {
54
- // re-entrant execution, save the state and restore it after we do this unpack
55
- return saveState(() => {
56
- clearSource()
57
- return this ? this.unpack(source, end) : Unpackr.prototype.unpack.call(defaultOptions, source, end)
58
- })
59
- }
60
- srcEnd = end > -1 ? end : source.length
61
- position = 0
62
- stringPosition = 0
63
- srcStringEnd = 0
64
- srcString = null
65
- strings = EMPTY_ARRAY
66
- bundledStrings = null
67
- src = source
68
- // this provides cached access to the data view for a buffer if it is getting reused, which is a recommend
69
- // technique for getting data from a database where it can be copied into an existing buffer instead of creating
70
- // new ones
71
- try {
72
- dataView = source.dataView || (source.dataView = new DataView(source.buffer, source.byteOffset, source.byteLength))
73
- } catch(error) {
74
- // if it doesn't have a buffer, maybe it is the wrong type of object
75
- src = null
76
- if (source instanceof Uint8Array)
77
- throw error
78
- throw new Error('Source must be a Uint8Array or Buffer but was a ' + ((source && typeof source == 'object') ? source.constructor.name : typeof source))
79
- }
80
- if (this instanceof Unpackr) {
81
- currentUnpackr = this
82
- if (this.structures) {
83
- currentStructures = this.structures
84
- return checkedRead()
85
- } else if (!currentStructures || currentStructures.length > 0) {
86
- currentStructures = []
87
- }
88
- } else {
89
- currentUnpackr = defaultOptions
90
- if (!currentStructures || currentStructures.length > 0)
91
- currentStructures = []
92
- }
93
- return checkedRead()
94
- }
95
- unpackMultiple(source, forEach) {
96
- let values, lastPosition = 0
97
- try {
98
- sequentialMode = true
99
- let size = source.length
100
- let value = this ? this.unpack(source, size) : defaultUnpackr.unpack(source, size)
101
- if (forEach) {
102
- forEach(value)
103
- while(position < size) {
104
- lastPosition = position
105
- if (forEach(checkedRead()) === false) {
106
- return
107
- }
108
- }
109
- }
110
- else {
111
- values = [ value ]
112
- while(position < size) {
113
- lastPosition = position
114
- values.push(checkedRead())
115
- }
116
- return values
117
- }
118
- } catch(error) {
119
- error.lastPosition = lastPosition
120
- error.values = values
121
- throw error
122
- } finally {
123
- sequentialMode = false
124
- clearSource()
125
- }
126
- }
127
- _mergeStructures(loadedStructures, existingStructures) {
128
- loadedStructures = loadedStructures || []
129
- for (let i = 0, l = loadedStructures.length; i < l; i++) {
130
- let structure = loadedStructures[i]
131
- if (structure) {
132
- structure.isShared = true
133
- if (i >= 32)
134
- structure.highByte = (i - 32) >> 5
135
- }
136
- }
137
- loadedStructures.sharedLength = loadedStructures.length
138
- for (let id in existingStructures || []) {
139
- if (id >= 0) {
140
- let structure = loadedStructures[id]
141
- let existing = existingStructures[id]
142
- if (existing) {
143
- if (structure)
144
- (loadedStructures.restoreStructures || (loadedStructures.restoreStructures = []))[id] = structure
145
- loadedStructures[id] = existing
146
- }
147
- }
148
- }
149
- return this.structures = loadedStructures
150
- }
151
- decode(source, end) {
152
- return this.unpack(source, end)
153
- }
154
- }
155
- export function getPosition() {
156
- return position
157
- }
158
- export function checkedRead() {
159
- try {
160
- if (!currentUnpackr.trusted && !sequentialMode) {
161
- let sharedLength = currentStructures.sharedLength || 0
162
- if (sharedLength < currentStructures.length)
163
- currentStructures.length = sharedLength
164
- }
165
- let result = read()
166
- if (bundledStrings) // bundled strings to skip past
167
- position = bundledStrings.postBundlePosition
168
-
169
- if (position == srcEnd) {
170
- // finished reading this source, cleanup references
171
- if (currentStructures.restoreStructures)
172
- restoreStructures()
173
- currentStructures = null
174
- src = null
175
- if (referenceMap)
176
- referenceMap = null
177
- } else if (position > srcEnd) {
178
- // over read
179
- let error = new Error('Unexpected end of MessagePack data')
180
- error.incomplete = true
181
- throw error
182
- } else if (!sequentialMode) {
183
- throw new Error('Data read, but end of buffer not reached')
184
- }
185
- // else more to read, but we are reading sequentially, so don't clear source yet
186
- return result
187
- } catch(error) {
188
- if (currentStructures.restoreStructures)
189
- restoreStructures()
190
- clearSource()
191
- if (error instanceof RangeError || error.message.startsWith('Unexpected end of buffer')) {
192
- error.incomplete = true
193
- }
194
- throw error
195
- }
196
- }
197
-
198
- function restoreStructures() {
199
- for (let id in currentStructures.restoreStructures) {
200
- currentStructures[id] = currentStructures.restoreStructures[id]
201
- }
202
- currentStructures.restoreStructures = null
203
- }
204
-
205
- export function read() {
206
- let token = src[position++]
207
- if (token < 0xa0) {
208
- if (token < 0x80) {
209
- if (token < 0x40)
210
- return token
211
- else {
212
- let structure = currentStructures[token & 0x3f] ||
213
- currentUnpackr.getStructures && loadStructures()[token & 0x3f]
214
- if (structure) {
215
- if (!structure.read) {
216
- structure.read = createStructureReader(structure, token & 0x3f)
217
- }
218
- return structure.read()
219
- } else
220
- return token
221
- }
222
- } else if (token < 0x90) {
223
- // map
224
- token -= 0x80
225
- if (currentUnpackr.mapsAsObjects) {
226
- let object = {}
227
- for (let i = 0; i < token; i++) {
228
- object[readKey()] = read()
229
- }
230
- return object
231
- } else {
232
- let map = new Map()
233
- for (let i = 0; i < token; i++) {
234
- map.set(read(), read())
235
- }
236
- return map
237
- }
238
- } else {
239
- token -= 0x90
240
- let array = new Array(token)
241
- for (let i = 0; i < token; i++) {
242
- array[i] = read()
243
- }
244
- return array
245
- }
246
- } else if (token < 0xc0) {
247
- // fixstr
248
- let length = token - 0xa0
249
- if (srcStringEnd >= position) {
250
- return srcString.slice(position - srcStringStart, (position += length) - srcStringStart)
251
- }
252
- if (srcStringEnd == 0 && srcEnd < 140) {
253
- // for small blocks, avoiding the overhead of the extract call is helpful
254
- let string = length < 16 ? shortStringInJS(length) : longStringInJS(length)
255
- if (string != null)
256
- return string
257
- }
258
- return readFixedString(length)
259
- } else {
260
- let value
261
- switch (token) {
262
- case 0xc0: return null
263
- case 0xc1:
264
- if (bundledStrings) {
265
- value = read() // followed by the length of the string in characters (not bytes!)
266
- if (value > 0)
267
- return bundledStrings[1].slice(bundledStrings.position1, bundledStrings.position1 += value)
268
- else
269
- return bundledStrings[0].slice(bundledStrings.position0, bundledStrings.position0 -= value)
270
- }
271
- return C1; // "never-used", return special object to denote that
272
- case 0xc2: return false
273
- case 0xc3: return true
274
- case 0xc4:
275
- // bin 8
276
- return readBin(src[position++])
277
- case 0xc5:
278
- // bin 16
279
- value = dataView.getUint16(position)
280
- position += 2
281
- return readBin(value)
282
- case 0xc6:
283
- // bin 32
284
- value = dataView.getUint32(position)
285
- position += 4
286
- return readBin(value)
287
- case 0xc7:
288
- // ext 8
289
- return readExt(src[position++])
290
- case 0xc8:
291
- // ext 16
292
- value = dataView.getUint16(position)
293
- position += 2
294
- return readExt(value)
295
- case 0xc9:
296
- // ext 32
297
- value = dataView.getUint32(position)
298
- position += 4
299
- return readExt(value)
300
- case 0xca:
301
- value = dataView.getFloat32(position)
302
- if (currentUnpackr.useFloat32 > 2) {
303
- // this does rounding of numbers that were encoded in 32-bit float to nearest significant decimal digit that could be preserved
304
- let multiplier = mult10[((src[position] & 0x7f) << 1) | (src[position + 1] >> 7)]
305
- position += 4
306
- return ((multiplier * value + (value > 0 ? 0.5 : -0.5)) >> 0) / multiplier
307
- }
308
- position += 4
309
- return value
310
- case 0xcb:
311
- value = dataView.getFloat64(position)
312
- position += 8
313
- return value
314
- // uint handlers
315
- case 0xcc:
316
- return src[position++]
317
- case 0xcd:
318
- value = dataView.getUint16(position)
319
- position += 2
320
- return value
321
- case 0xce:
322
- value = dataView.getUint32(position)
323
- position += 4
324
- return value
325
- case 0xcf:
326
- if (currentUnpackr.int64AsNumber) {
327
- value = dataView.getUint32(position) * 0x100000000
328
- value += dataView.getUint32(position + 4)
329
- } else
330
- value = dataView.getBigUint64(position)
331
- position += 8
332
- return value
333
-
334
- // int handlers
335
- case 0xd0:
336
- return dataView.getInt8(position++)
337
- case 0xd1:
338
- value = dataView.getInt16(position)
339
- position += 2
340
- return value
341
- case 0xd2:
342
- value = dataView.getInt32(position)
343
- position += 4
344
- return value
345
- case 0xd3:
346
- if (currentUnpackr.int64AsNumber) {
347
- value = dataView.getInt32(position) * 0x100000000
348
- value += dataView.getUint32(position + 4)
349
- } else
350
- value = dataView.getBigInt64(position)
351
- position += 8
352
- return value
353
-
354
- case 0xd4:
355
- // fixext 1
356
- value = src[position++]
357
- if (value == 0x72) {
358
- return recordDefinition(src[position++] & 0x3f)
359
- } else {
360
- let extension = currentExtensions[value]
361
- if (extension) {
362
- if (extension.read) {
363
- position++ // skip filler byte
364
- return extension.read(read())
365
- } else if (extension.noBuffer) {
366
- position++ // skip filler byte
367
- return extension()
368
- } else
369
- return extension(src.subarray(position, ++position))
370
- } else
371
- throw new Error('Unknown extension ' + value)
372
- }
373
- case 0xd5:
374
- // fixext 2
375
- value = src[position]
376
- if (value == 0x72) {
377
- position++
378
- return recordDefinition(src[position++] & 0x3f, src[position++])
379
- } else
380
- return readExt(2)
381
- case 0xd6:
382
- // fixext 4
383
- return readExt(4)
384
- case 0xd7:
385
- // fixext 8
386
- return readExt(8)
387
- case 0xd8:
388
- // fixext 16
389
- return readExt(16)
390
- case 0xd9:
391
- // str 8
392
- value = src[position++]
393
- if (srcStringEnd >= position) {
394
- return srcString.slice(position - srcStringStart, (position += value) - srcStringStart)
395
- }
396
- return readString8(value)
397
- case 0xda:
398
- // str 16
399
- value = dataView.getUint16(position)
400
- position += 2
401
- if (srcStringEnd >= position) {
402
- return srcString.slice(position - srcStringStart, (position += value) - srcStringStart)
403
- }
404
- return readString16(value)
405
- case 0xdb:
406
- // str 32
407
- value = dataView.getUint32(position)
408
- position += 4
409
- if (srcStringEnd >= position) {
410
- return srcString.slice(position - srcStringStart, (position += value) - srcStringStart)
411
- }
412
- return readString32(value)
413
- case 0xdc:
414
- // array 16
415
- value = dataView.getUint16(position)
416
- position += 2
417
- return readArray(value)
418
- case 0xdd:
419
- // array 32
420
- value = dataView.getUint32(position)
421
- position += 4
422
- return readArray(value)
423
- case 0xde:
424
- // map 16
425
- value = dataView.getUint16(position)
426
- position += 2
427
- return readMap(value)
428
- case 0xdf:
429
- // map 32
430
- value = dataView.getUint32(position)
431
- position += 4
432
- return readMap(value)
433
- default: // negative int
434
- if (token >= 0xe0)
435
- return token - 0x100
436
- if (token === undefined) {
437
- let error = new Error('Unexpected end of MessagePack data')
438
- error.incomplete = true
439
- throw error
440
- }
441
- throw new Error('Unknown MessagePack token ' + token)
442
-
443
- }
444
- }
445
- }
446
- const validName = /^[a-zA-Z_$][a-zA-Z\d_$]*$/
447
- function createStructureReader(structure, firstId) {
448
- function readObject() {
449
- // This initial function is quick to instantiate, but runs slower. After several iterations pay the cost to build the faster function
450
- if (readObject.count++ > inlineObjectReadThreshold) {
451
- let readObject = structure.read = (new Function('r', 'return function(){return {' + structure.map(key => validName.test(key) ? key + ':r()' : ('[' + JSON.stringify(key) + ']:r()')).join(',') + '}}'))(read)
452
- if (structure.highByte === 0)
453
- structure.read = createSecondByteReader(firstId, structure.read)
454
- return readObject() // second byte is already read, if there is one so immediately read object
455
- }
456
- let object = {}
457
- for (let i = 0, l = structure.length; i < l; i++) {
458
- let key = structure[i]
459
- object[key] = read()
460
- }
461
- return object
462
- }
463
- readObject.count = 0
464
- if (structure.highByte === 0) {
465
- return createSecondByteReader(firstId, readObject)
466
- }
467
- return readObject
468
- }
469
-
470
- const createSecondByteReader = (firstId, read0) => {
471
- return function() {
472
- let highByte = src[position++]
473
- if (highByte === 0)
474
- return read0()
475
- let id = firstId < 32 ? -(firstId + (highByte << 5)) : firstId + (highByte << 5)
476
- let structure = currentStructures[id] || loadStructures()[id]
477
- if (!structure) {
478
- throw new Error('Record id is not defined for ' + id)
479
- }
480
- if (!structure.read)
481
- structure.read = createStructureReader(structure, firstId)
482
- return structure.read()
483
- }
484
- }
485
-
486
- function loadStructures() {
487
- let loadedStructures = saveState(() => {
488
- // save the state in case getStructures modifies our buffer
489
- src = null
490
- return currentUnpackr.getStructures()
491
- })
492
- return currentStructures = currentUnpackr._mergeStructures(loadedStructures, currentStructures)
493
- }
494
-
495
- var readFixedString = readStringJS
496
- var readString8 = readStringJS
497
- var readString16 = readStringJS
498
- var readString32 = readStringJS
499
- export let isNativeAccelerationEnabled = false
500
-
501
- export function setExtractor(extractStrings) {
502
- isNativeAccelerationEnabled = true
503
- readFixedString = readString(1)
504
- readString8 = readString(2)
505
- readString16 = readString(3)
506
- readString32 = readString(5)
507
- function readString(headerLength) {
508
- return function readString(length) {
509
- let string = strings[stringPosition++]
510
- if (string == null) {
511
- if (bundledStrings)
512
- return readStringJS(length)
513
- let extraction = extractStrings(position - headerLength, srcEnd, src)
514
- if (typeof extraction == 'string') {
515
- string = extraction
516
- strings = EMPTY_ARRAY
517
- } else {
518
- strings = extraction
519
- stringPosition = 1
520
- srcStringEnd = 1 // even if a utf-8 string was decoded, must indicate we are in the midst of extracted strings and can't skip strings
521
- string = strings[0]
522
- if (string === undefined)
523
- throw new Error('Unexpected end of buffer')
524
- }
525
- }
526
- let srcStringLength = string.length
527
- if (srcStringLength <= length) {
528
- position += length
529
- return string
530
- }
531
- srcString = string
532
- srcStringStart = position
533
- srcStringEnd = position + srcStringLength
534
- position += length
535
- return string.slice(0, length) // we know we just want the beginning
536
- }
537
- }
538
- }
539
- function readStringJS(length) {
540
- let result
541
- if (length < 16) {
542
- if (result = shortStringInJS(length))
543
- return result
544
- }
545
- if (length > 64 && decoder)
546
- return decoder.decode(src.subarray(position, position += length))
547
- const end = position + length
548
- const units = []
549
- result = ''
550
- while (position < end) {
551
- const byte1 = src[position++]
552
- if ((byte1 & 0x80) === 0) {
553
- // 1 byte
554
- units.push(byte1)
555
- } else if ((byte1 & 0xe0) === 0xc0) {
556
- // 2 bytes
557
- const byte2 = src[position++] & 0x3f
558
- units.push(((byte1 & 0x1f) << 6) | byte2)
559
- } else if ((byte1 & 0xf0) === 0xe0) {
560
- // 3 bytes
561
- const byte2 = src[position++] & 0x3f
562
- const byte3 = src[position++] & 0x3f
563
- units.push(((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3)
564
- } else if ((byte1 & 0xf8) === 0xf0) {
565
- // 4 bytes
566
- const byte2 = src[position++] & 0x3f
567
- const byte3 = src[position++] & 0x3f
568
- const byte4 = src[position++] & 0x3f
569
- let unit = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4
570
- if (unit > 0xffff) {
571
- unit -= 0x10000
572
- units.push(((unit >>> 10) & 0x3ff) | 0xd800)
573
- unit = 0xdc00 | (unit & 0x3ff)
574
- }
575
- units.push(unit)
576
- } else {
577
- units.push(byte1)
578
- }
579
-
580
- if (units.length >= 0x1000) {
581
- result += fromCharCode.apply(String, units)
582
- units.length = 0
583
- }
584
- }
585
-
586
- if (units.length > 0) {
587
- result += fromCharCode.apply(String, units)
588
- }
589
-
590
- return result
591
- }
592
-
593
- function readArray(length) {
594
- let array = new Array(length)
595
- for (let i = 0; i < length; i++) {
596
- array[i] = read()
597
- }
598
- return array
599
- }
600
-
601
- function readMap(length) {
602
- if (currentUnpackr.mapsAsObjects) {
603
- let object = {}
604
- for (let i = 0; i < length; i++) {
605
- object[readKey()] = read()
606
- }
607
- return object
608
- } else {
609
- let map = new Map()
610
- for (let i = 0; i < length; i++) {
611
- map.set(read(), read())
612
- }
613
- return map
614
- }
615
- }
616
-
617
- var fromCharCode = String.fromCharCode
618
- function longStringInJS(length) {
619
- let start = position
620
- let bytes = new Array(length)
621
- for (let i = 0; i < length; i++) {
622
- const byte = src[position++];
623
- if ((byte & 0x80) > 0) {
624
- position = start
625
- return
626
- }
627
- bytes[i] = byte
628
- }
629
- return fromCharCode.apply(String, bytes)
630
- }
631
- function shortStringInJS(length) {
632
- if (length < 4) {
633
- if (length < 2) {
634
- if (length === 0)
635
- return ''
636
- else {
637
- let a = src[position++]
638
- if ((a & 0x80) > 1) {
639
- position -= 1
640
- return
641
- }
642
- return fromCharCode(a)
643
- }
644
- } else {
645
- let a = src[position++]
646
- let b = src[position++]
647
- if ((a & 0x80) > 0 || (b & 0x80) > 0) {
648
- position -= 2
649
- return
650
- }
651
- if (length < 3)
652
- return fromCharCode(a, b)
653
- let c = src[position++]
654
- if ((c & 0x80) > 0) {
655
- position -= 3
656
- return
657
- }
658
- return fromCharCode(a, b, c)
659
- }
660
- } else {
661
- let a = src[position++]
662
- let b = src[position++]
663
- let c = src[position++]
664
- let d = src[position++]
665
- if ((a & 0x80) > 0 || (b & 0x80) > 0 || (c & 0x80) > 0 || (d & 0x80) > 0) {
666
- position -= 4
667
- return
668
- }
669
- if (length < 6) {
670
- if (length === 4)
671
- return fromCharCode(a, b, c, d)
672
- else {
673
- let e = src[position++]
674
- if ((e & 0x80) > 0) {
675
- position -= 5
676
- return
677
- }
678
- return fromCharCode(a, b, c, d, e)
679
- }
680
- } else if (length < 8) {
681
- let e = src[position++]
682
- let f = src[position++]
683
- if ((e & 0x80) > 0 || (f & 0x80) > 0) {
684
- position -= 6
685
- return
686
- }
687
- if (length < 7)
688
- return fromCharCode(a, b, c, d, e, f)
689
- let g = src[position++]
690
- if ((g & 0x80) > 0) {
691
- position -= 7
692
- return
693
- }
694
- return fromCharCode(a, b, c, d, e, f, g)
695
- } else {
696
- let e = src[position++]
697
- let f = src[position++]
698
- let g = src[position++]
699
- let h = src[position++]
700
- if ((e & 0x80) > 0 || (f & 0x80) > 0 || (g & 0x80) > 0 || (h & 0x80) > 0) {
701
- position -= 8
702
- return
703
- }
704
- if (length < 10) {
705
- if (length === 8)
706
- return fromCharCode(a, b, c, d, e, f, g, h)
707
- else {
708
- let i = src[position++]
709
- if ((i & 0x80) > 0) {
710
- position -= 9
711
- return
712
- }
713
- return fromCharCode(a, b, c, d, e, f, g, h, i)
714
- }
715
- } else if (length < 12) {
716
- let i = src[position++]
717
- let j = src[position++]
718
- if ((i & 0x80) > 0 || (j & 0x80) > 0) {
719
- position -= 10
720
- return
721
- }
722
- if (length < 11)
723
- return fromCharCode(a, b, c, d, e, f, g, h, i, j)
724
- let k = src[position++]
725
- if ((k & 0x80) > 0) {
726
- position -= 11
727
- return
728
- }
729
- return fromCharCode(a, b, c, d, e, f, g, h, i, j, k)
730
- } else {
731
- let i = src[position++]
732
- let j = src[position++]
733
- let k = src[position++]
734
- let l = src[position++]
735
- if ((i & 0x80) > 0 || (j & 0x80) > 0 || (k & 0x80) > 0 || (l & 0x80) > 0) {
736
- position -= 12
737
- return
738
- }
739
- if (length < 14) {
740
- if (length === 12)
741
- return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l)
742
- else {
743
- let m = src[position++]
744
- if ((m & 0x80) > 0) {
745
- position -= 13
746
- return
747
- }
748
- return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m)
749
- }
750
- } else {
751
- let m = src[position++]
752
- let n = src[position++]
753
- if ((m & 0x80) > 0 || (n & 0x80) > 0) {
754
- position -= 14
755
- return
756
- }
757
- if (length < 15)
758
- return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m, n)
759
- let o = src[position++]
760
- if ((o & 0x80) > 0) {
761
- position -= 15
762
- return
763
- }
764
- return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
765
- }
766
- }
767
- }
768
- }
769
- }
770
-
771
- function readOnlyJSString() {
772
- let token = src[position++]
773
- let length
774
- if (token < 0xc0) {
775
- // fixstr
776
- length = token - 0xa0
777
- } else {
778
- switch(token) {
779
- case 0xd9:
780
- // str 8
781
- length = src[position++]
782
- break
783
- case 0xda:
784
- // str 16
785
- length = dataView.getUint16(position)
786
- position += 2
787
- break
788
- case 0xdb:
789
- // str 32
790
- length = dataView.getUint32(position)
791
- position += 4
792
- break
793
- default:
794
- throw new Error('Expected string')
795
- }
796
- }
797
- return readStringJS(length)
798
- }
799
-
800
-
801
- function readBin(length) {
802
- return currentUnpackr.copyBuffers ?
803
- // specifically use the copying slice (not the node one)
804
- Uint8Array.prototype.slice.call(src, position, position += length) :
805
- src.subarray(position, position += length)
806
- }
807
- function readExt(length) {
808
- let type = src[position++]
809
- if (currentExtensions[type]) {
810
- return currentExtensions[type](src.subarray(position, position += length))
811
- }
812
- else
813
- throw new Error('Unknown extension type ' + type)
814
- }
815
-
816
- var keyCache = new Array(4096)
817
- function readKey() {
818
- let length = src[position++]
819
- if (length >= 0xa0 && length < 0xc0) {
820
- // fixstr, potentially use key cache
821
- length = length - 0xa0
822
- if (srcStringEnd >= position) // if it has been extracted, must use it (and faster anyway)
823
- return srcString.slice(position - srcStringStart, (position += length) - srcStringStart)
824
- else if (!(srcStringEnd == 0 && srcEnd < 180))
825
- return readFixedString(length)
826
- } else { // not cacheable, go back and do a standard read
827
- position--
828
- return read()
829
- }
830
- let key = ((length << 5) ^ (length > 1 ? dataView.getUint16(position) : length > 0 ? src[position] : 0)) & 0xfff
831
- let entry = keyCache[key]
832
- let checkPosition = position
833
- let end = position + length - 3
834
- let chunk
835
- let i = 0
836
- if (entry && entry.bytes == length) {
837
- while (checkPosition < end) {
838
- chunk = dataView.getUint32(checkPosition)
839
- if (chunk != entry[i++]) {
840
- checkPosition = 0x70000000
841
- break
842
- }
843
- checkPosition += 4
844
- }
845
- end += 3
846
- while (checkPosition < end) {
847
- chunk = src[checkPosition++]
848
- if (chunk != entry[i++]) {
849
- checkPosition = 0x70000000
850
- break
851
- }
852
- }
853
- if (checkPosition === end) {
854
- position = checkPosition
855
- return entry.string
856
- }
857
- end -= 3
858
- checkPosition = position
859
- }
860
- entry = []
861
- keyCache[key] = entry
862
- entry.bytes = length
863
- while (checkPosition < end) {
864
- chunk = dataView.getUint32(checkPosition)
865
- entry.push(chunk)
866
- checkPosition += 4
867
- }
868
- end += 3
869
- while (checkPosition < end) {
870
- chunk = src[checkPosition++]
871
- entry.push(chunk)
872
- }
873
- // for small blocks, avoiding the overhead of the extract call is helpful
874
- let string = length < 16 ? shortStringInJS(length) : longStringInJS(length)
875
- if (string != null)
876
- return entry.string = string
877
- return entry.string = readFixedString(length)
878
- }
879
-
880
- // the registration of the record definition extension (as "r")
881
- const recordDefinition = (id, highByte) => {
882
- var structure = read()
883
- let firstByte = id
884
- if (highByte !== undefined) {
885
- id = id < 32 ? -((highByte << 5) + id) : ((highByte << 5) + id)
886
- structure.highByte = highByte
887
- }
888
- let existingStructure = currentStructures[id]
889
- if (existingStructure && existingStructure.isShared) {
890
- (currentStructures.restoreStructures || (currentStructures.restoreStructures = []))[id] = existingStructure
891
- }
892
- currentStructures[id] = structure
893
- structure.read = createStructureReader(structure, firstByte)
894
- return structure.read()
895
- }
896
- var glbl = typeof self == 'object' ? self : global
897
- currentExtensions[0] = () => {} // notepack defines extension 0 to mean undefined, so use that as the default here
898
- currentExtensions[0].noBuffer = true
899
-
900
- currentExtensions[0x65] = () => {
901
- let data = read()
902
- return (glbl[data[0]] || Error)(data[1])
903
- }
904
-
905
- currentExtensions[0x69] = (data) => {
906
- // id extension (for structured clones)
907
- let id = dataView.getUint32(position - 4)
908
- if (!referenceMap)
909
- referenceMap = new Map()
910
- let token = src[position]
911
- let target
912
- // TODO: handle Maps, Sets, and other types that can cycle; this is complicated, because you potentially need to read
913
- // ahead past references to record structure definitions
914
- if (token >= 0x90 && token < 0xa0 || token == 0xdc || token == 0xdd)
915
- target = []
916
- else
917
- target = {}
918
-
919
- let refEntry = { target } // a placeholder object
920
- referenceMap.set(id, refEntry)
921
- let targetProperties = read() // read the next value as the target object to id
922
- if (refEntry.used) // there is a cycle, so we have to assign properties to original target
923
- return Object.assign(target, targetProperties)
924
- refEntry.target = targetProperties // the placeholder wasn't used, replace with the deserialized one
925
- return targetProperties // no cycle, can just use the returned read object
926
- }
927
-
928
- currentExtensions[0x70] = (data) => {
929
- // pointer extension (for structured clones)
930
- let id = dataView.getUint32(position - 4)
931
- let refEntry = referenceMap.get(id)
932
- refEntry.used = true
933
- return refEntry.target
934
- }
935
-
936
- currentExtensions[0x73] = () => new Set(read())
937
-
938
- export const typedArrays = ['Int8','Uint8','Uint8Clamped','Int16','Uint16','Int32','Uint32','Float32','Float64','BigInt64','BigUint64'].map(type => type + 'Array')
939
-
940
- currentExtensions[0x74] = (data) => {
941
- let typeCode = data[0]
942
- let typedArrayName = typedArrays[typeCode]
943
- if (!typedArrayName)
944
- throw new Error('Could not find typed array for code ' + typeCode)
945
- // we have to always slice/copy here to get a new ArrayBuffer that is word/byte aligned
946
- return new glbl[typedArrayName](Uint8Array.prototype.slice.call(data, 1).buffer)
947
- }
948
- currentExtensions[0x78] = () => {
949
- let data = read()
950
- return new RegExp(data[0], data[1])
951
- }
952
- const TEMP_BUNDLE = []
953
- currentExtensions[0x62] = (data) => {
954
- let dataSize = (data[0] << 24) + (data[1] << 16) + (data[2] << 8) + data[3]
955
- let dataPosition = position
956
- position += dataSize - data.length
957
- bundledStrings = TEMP_BUNDLE
958
- bundledStrings = [readOnlyJSString(), readOnlyJSString()]
959
- bundledStrings.position0 = 0
960
- bundledStrings.position1 = 0
961
- bundledStrings.postBundlePosition = position
962
- position = dataPosition
963
- return read()
964
- }
965
-
966
- currentExtensions[0xff] = (data) => {
967
- // 32-bit date extension
968
- if (data.length == 4)
969
- return new Date((data[0] * 0x1000000 + (data[1] << 16) + (data[2] << 8) + data[3]) * 1000)
970
- else if (data.length == 8)
971
- return new Date(
972
- ((data[0] << 22) + (data[1] << 14) + (data[2] << 6) + (data[3] >> 2)) / 1000000 +
973
- ((data[3] & 0x3) * 0x100000000 + data[4] * 0x1000000 + (data[5] << 16) + (data[6] << 8) + data[7]) * 1000)
974
- else if (data.length == 12)// TODO: Implement support for negative
975
- return new Date(
976
- ((data[0] << 24) + (data[1] << 16) + (data[2] << 8) + data[3]) / 1000000 +
977
- (((data[4] & 0x80) ? -0x1000000000000 : 0) + data[6] * 0x10000000000 + data[7] * 0x100000000 + data[8] * 0x1000000 + (data[9] << 16) + (data[10] << 8) + data[11]) * 1000)
978
- else
979
- return new Date('invalid')
980
- } // notepack defines extension 0 to mean undefined, so use that as the default here
981
- // registration of bulk record definition?
982
- // currentExtensions[0x52] = () =>
983
-
984
- function saveState(callback) {
985
- let savedSrcEnd = srcEnd
986
- let savedPosition = position
987
- let savedStringPosition = stringPosition
988
- let savedSrcStringStart = srcStringStart
989
- let savedSrcStringEnd = srcStringEnd
990
- let savedSrcString = srcString
991
- let savedStrings = strings
992
- let savedReferenceMap = referenceMap
993
- let savedBundledStrings = bundledStrings
994
-
995
- // TODO: We may need to revisit this if we do more external calls to user code (since it could be slow)
996
- let savedSrc = new Uint8Array(src.slice(0, srcEnd)) // we copy the data in case it changes while external data is processed
997
- let savedStructures = currentStructures
998
- let savedStructuresContents = currentStructures.slice(0, currentStructures.length)
999
- let savedPackr = currentUnpackr
1000
- let savedSequentialMode = sequentialMode
1001
- let value = callback()
1002
- srcEnd = savedSrcEnd
1003
- position = savedPosition
1004
- stringPosition = savedStringPosition
1005
- srcStringStart = savedSrcStringStart
1006
- srcStringEnd = savedSrcStringEnd
1007
- srcString = savedSrcString
1008
- strings = savedStrings
1009
- referenceMap = savedReferenceMap
1010
- bundledStrings = savedBundledStrings
1011
- src = savedSrc
1012
- sequentialMode = savedSequentialMode
1013
- currentStructures = savedStructures
1014
- currentStructures.splice(0, currentStructures.length, ...savedStructuresContents)
1015
- currentUnpackr = savedPackr
1016
- dataView = new DataView(src.buffer, src.byteOffset, src.byteLength)
1017
- return value
1018
- }
1019
- export function clearSource() {
1020
- src = null
1021
- referenceMap = null
1022
- currentStructures = null
1023
- }
1024
-
1025
- export function addExtension(extension) {
1026
- if (extension.unpack)
1027
- currentExtensions[extension.type] = extension.unpack
1028
- else
1029
- currentExtensions[extension.type] = extension
1030
- }
1031
-
1032
- export const mult10 = new Array(147) // this is a table matching binary exponents to the multiplier to determine significant digit rounding
1033
- for (let i = 0; i < 256; i++) {
1034
- mult10[i] = +('1e' + Math.floor(45.15 - i * 0.30103))
1035
- }
1036
- export const Decoder = Unpackr
1037
- var defaultUnpackr = new Unpackr({ useRecords: false })
1038
- export const unpack = defaultUnpackr.unpack
1039
- export const unpackMultiple = defaultUnpackr.unpackMultiple
1040
- export const decode = defaultUnpackr.unpack
1041
- export const FLOAT32_OPTIONS = {
1042
- NEVER: 0,
1043
- ALWAYS: 1,
1044
- DECIMAL_ROUND: 3,
1045
- DECIMAL_FIT: 4
1046
- }
1047
- let f32Array = new Float32Array(1)
1048
- let u8Array = new Uint8Array(f32Array.buffer, 0, 4)
1049
- export function roundFloat32(float32Number) {
1050
- f32Array[0] = float32Number
1051
- let multiplier = mult10[((u8Array[3] & 0x7f) << 1) | (u8Array[2] >> 7)]
1052
- return ((multiplier * float32Number + (float32Number > 0 ? 0.5 : -0.5)) >> 0) / multiplier
1053
- }
1
+ "use strict"
2
+ var decoder
3
+ try {
4
+ decoder = new TextDecoder()
5
+ } catch(error) {}
6
+ var src
7
+ var srcEnd
8
+ var position = 0
9
+ var alreadySet
10
+ const EMPTY_ARRAY = []
11
+ var strings = EMPTY_ARRAY
12
+ var stringPosition = 0
13
+ var currentUnpackr = {}
14
+ var currentStructures
15
+ var srcString
16
+ var srcStringStart = 0
17
+ var srcStringEnd = 0
18
+ var bundledStrings
19
+ var referenceMap
20
+ var currentExtensions = []
21
+ var dataView
22
+ var defaultOptions = {
23
+ useRecords: false,
24
+ mapsAsObjects: true
25
+ }
26
+ export class C1Type {}
27
+ export const C1 = new C1Type()
28
+ C1.name = 'MessagePack 0xC1'
29
+ var sequentialMode = false
30
+ var inlineObjectReadThreshold = 2
31
+ try {
32
+ new Function('')
33
+ } catch(error) {
34
+ // if eval variants are not supported, do not create inline object readers ever
35
+ inlineObjectReadThreshold = Infinity
36
+ }
37
+
38
+ export class Unpackr {
39
+ constructor(options) {
40
+ if (options) {
41
+ if (options.useRecords === false && options.mapsAsObjects === undefined)
42
+ options.mapsAsObjects = true
43
+ if (options.sequential && options.trusted !== false) {
44
+ options.trusted = true;
45
+ if (!options.structures && options.useRecords != false) {
46
+ options.structures = []
47
+ if (!options.maxSharedStructures)
48
+ options.maxSharedStructures = 0
49
+ }
50
+ }
51
+ if (options.structures)
52
+ options.structures.sharedLength = options.structures.length
53
+ else if (options.getStructures) {
54
+ (options.structures = []).uninitialized = true // this is what we use to denote an uninitialized structures
55
+ options.structures.sharedLength = 0
56
+ }
57
+ }
58
+ Object.assign(this, options)
59
+ }
60
+ unpack(source, end) {
61
+ if (src) {
62
+ // re-entrant execution, save the state and restore it after we do this unpack
63
+ return saveState(() => {
64
+ clearSource()
65
+ return this ? this.unpack(source, end) : Unpackr.prototype.unpack.call(defaultOptions, source, end)
66
+ })
67
+ }
68
+ srcEnd = end > -1 ? end : source.length
69
+ position = 0
70
+ stringPosition = 0
71
+ srcStringEnd = 0
72
+ srcString = null
73
+ strings = EMPTY_ARRAY
74
+ bundledStrings = null
75
+ src = source
76
+ // this provides cached access to the data view for a buffer if it is getting reused, which is a recommend
77
+ // technique for getting data from a database where it can be copied into an existing buffer instead of creating
78
+ // new ones
79
+ try {
80
+ dataView = source.dataView || (source.dataView = new DataView(source.buffer, source.byteOffset, source.byteLength))
81
+ } catch(error) {
82
+ // if it doesn't have a buffer, maybe it is the wrong type of object
83
+ src = null
84
+ if (source instanceof Uint8Array)
85
+ throw error
86
+ throw new Error('Source must be a Uint8Array or Buffer but was a ' + ((source && typeof source == 'object') ? source.constructor.name : typeof source))
87
+ }
88
+ if (this instanceof Unpackr) {
89
+ currentUnpackr = this
90
+ if (this.structures) {
91
+ currentStructures = this.structures
92
+ return checkedRead()
93
+ } else if (!currentStructures || currentStructures.length > 0) {
94
+ currentStructures = []
95
+ }
96
+ } else {
97
+ currentUnpackr = defaultOptions
98
+ if (!currentStructures || currentStructures.length > 0)
99
+ currentStructures = []
100
+ }
101
+ return checkedRead()
102
+ }
103
+ unpackMultiple(source, forEach) {
104
+ let values, lastPosition = 0
105
+ try {
106
+ sequentialMode = true
107
+ let size = source.length
108
+ let value = this ? this.unpack(source, size) : defaultUnpackr.unpack(source, size)
109
+ if (forEach) {
110
+ forEach(value)
111
+ while(position < size) {
112
+ lastPosition = position
113
+ if (forEach(checkedRead()) === false) {
114
+ return
115
+ }
116
+ }
117
+ }
118
+ else {
119
+ values = [ value ]
120
+ while(position < size) {
121
+ lastPosition = position
122
+ values.push(checkedRead())
123
+ }
124
+ return values
125
+ }
126
+ } catch(error) {
127
+ error.lastPosition = lastPosition
128
+ error.values = values
129
+ throw error
130
+ } finally {
131
+ sequentialMode = false
132
+ clearSource()
133
+ }
134
+ }
135
+ _mergeStructures(loadedStructures, existingStructures) {
136
+ loadedStructures = loadedStructures || []
137
+ for (let i = 0, l = loadedStructures.length; i < l; i++) {
138
+ let structure = loadedStructures[i]
139
+ if (structure) {
140
+ structure.isShared = true
141
+ if (i >= 32)
142
+ structure.highByte = (i - 32) >> 5
143
+ }
144
+ }
145
+ loadedStructures.sharedLength = loadedStructures.length
146
+ for (let id in existingStructures || []) {
147
+ if (id >= 0) {
148
+ let structure = loadedStructures[id]
149
+ let existing = existingStructures[id]
150
+ if (existing) {
151
+ if (structure)
152
+ (loadedStructures.restoreStructures || (loadedStructures.restoreStructures = []))[id] = structure
153
+ loadedStructures[id] = existing
154
+ }
155
+ }
156
+ }
157
+ return this.structures = loadedStructures
158
+ }
159
+ decode(source, end) {
160
+ return this.unpack(source, end)
161
+ }
162
+ }
163
+ export function getPosition() {
164
+ return position
165
+ }
166
+ export function checkedRead() {
167
+ try {
168
+ if (!currentUnpackr.trusted && !sequentialMode) {
169
+ let sharedLength = currentStructures.sharedLength || 0
170
+ if (sharedLength < currentStructures.length)
171
+ currentStructures.length = sharedLength
172
+ }
173
+ let result = read()
174
+ if (bundledStrings) // bundled strings to skip past
175
+ position = bundledStrings.postBundlePosition
176
+
177
+ if (position == srcEnd) {
178
+ // finished reading this source, cleanup references
179
+ if (currentStructures.restoreStructures)
180
+ restoreStructures()
181
+ currentStructures = null
182
+ src = null
183
+ if (referenceMap)
184
+ referenceMap = null
185
+ } else if (position > srcEnd) {
186
+ // over read
187
+ throw new Error('Unexpected end of MessagePack data')
188
+ } else if (!sequentialMode) {
189
+ throw new Error('Data read, but end of buffer not reached ' + JSON.stringify(result).slice(0, 100))
190
+ }
191
+ // else more to read, but we are reading sequentially, so don't clear source yet
192
+ return result
193
+ } catch(error) {
194
+ if (currentStructures.restoreStructures)
195
+ restoreStructures()
196
+ clearSource()
197
+ if (error instanceof RangeError || error.message.startsWith('Unexpected end of buffer') || position > srcEnd) {
198
+ error.incomplete = true
199
+ }
200
+ throw error
201
+ }
202
+ }
203
+
204
+ function restoreStructures() {
205
+ for (let id in currentStructures.restoreStructures) {
206
+ currentStructures[id] = currentStructures.restoreStructures[id]
207
+ }
208
+ currentStructures.restoreStructures = null
209
+ }
210
+
211
+ export function read() {
212
+ let token = src[position++]
213
+ if (token < 0xa0) {
214
+ if (token < 0x80) {
215
+ if (token < 0x40)
216
+ return token
217
+ else {
218
+ let structure = currentStructures[token & 0x3f] ||
219
+ currentUnpackr.getStructures && loadStructures()[token & 0x3f]
220
+ if (structure) {
221
+ if (!structure.read) {
222
+ structure.read = createStructureReader(structure, token & 0x3f)
223
+ }
224
+ return structure.read()
225
+ } else
226
+ return token
227
+ }
228
+ } else if (token < 0x90) {
229
+ // map
230
+ token -= 0x80
231
+ if (currentUnpackr.mapsAsObjects) {
232
+ let object = {}
233
+ for (let i = 0; i < token; i++) {
234
+ object[readKey()] = read()
235
+ }
236
+ return object
237
+ } else {
238
+ let map = new Map()
239
+ for (let i = 0; i < token; i++) {
240
+ map.set(read(), read())
241
+ }
242
+ return map
243
+ }
244
+ } else {
245
+ token -= 0x90
246
+ let array = new Array(token)
247
+ for (let i = 0; i < token; i++) {
248
+ array[i] = read()
249
+ }
250
+ return array
251
+ }
252
+ } else if (token < 0xc0) {
253
+ // fixstr
254
+ let length = token - 0xa0
255
+ if (srcStringEnd >= position) {
256
+ return srcString.slice(position - srcStringStart, (position += length) - srcStringStart)
257
+ }
258
+ if (srcStringEnd == 0 && srcEnd < 140) {
259
+ // for small blocks, avoiding the overhead of the extract call is helpful
260
+ let string = length < 16 ? shortStringInJS(length) : longStringInJS(length)
261
+ if (string != null)
262
+ return string
263
+ }
264
+ return readFixedString(length)
265
+ } else {
266
+ let value
267
+ switch (token) {
268
+ case 0xc0: return null
269
+ case 0xc1:
270
+ if (bundledStrings) {
271
+ value = read() // followed by the length of the string in characters (not bytes!)
272
+ if (value > 0)
273
+ return bundledStrings[1].slice(bundledStrings.position1, bundledStrings.position1 += value)
274
+ else
275
+ return bundledStrings[0].slice(bundledStrings.position0, bundledStrings.position0 -= value)
276
+ }
277
+ return C1; // "never-used", return special object to denote that
278
+ case 0xc2: return false
279
+ case 0xc3: return true
280
+ case 0xc4:
281
+ // bin 8
282
+ value = src[position++]
283
+ if (value === undefined)
284
+ throw new Error('Unexpected end of buffer')
285
+ return readBin(value)
286
+ case 0xc5:
287
+ // bin 16
288
+ value = dataView.getUint16(position)
289
+ position += 2
290
+ return readBin(value)
291
+ case 0xc6:
292
+ // bin 32
293
+ value = dataView.getUint32(position)
294
+ position += 4
295
+ return readBin(value)
296
+ case 0xc7:
297
+ // ext 8
298
+ return readExt(src[position++])
299
+ case 0xc8:
300
+ // ext 16
301
+ value = dataView.getUint16(position)
302
+ position += 2
303
+ return readExt(value)
304
+ case 0xc9:
305
+ // ext 32
306
+ value = dataView.getUint32(position)
307
+ position += 4
308
+ return readExt(value)
309
+ case 0xca:
310
+ value = dataView.getFloat32(position)
311
+ if (currentUnpackr.useFloat32 > 2) {
312
+ // this does rounding of numbers that were encoded in 32-bit float to nearest significant decimal digit that could be preserved
313
+ let multiplier = mult10[((src[position] & 0x7f) << 1) | (src[position + 1] >> 7)]
314
+ position += 4
315
+ return ((multiplier * value + (value > 0 ? 0.5 : -0.5)) >> 0) / multiplier
316
+ }
317
+ position += 4
318
+ return value
319
+ case 0xcb:
320
+ value = dataView.getFloat64(position)
321
+ position += 8
322
+ return value
323
+ // uint handlers
324
+ case 0xcc:
325
+ return src[position++]
326
+ case 0xcd:
327
+ value = dataView.getUint16(position)
328
+ position += 2
329
+ return value
330
+ case 0xce:
331
+ value = dataView.getUint32(position)
332
+ position += 4
333
+ return value
334
+ case 0xcf:
335
+ if (currentUnpackr.int64AsNumber) {
336
+ value = dataView.getUint32(position) * 0x100000000
337
+ value += dataView.getUint32(position + 4)
338
+ } else
339
+ value = dataView.getBigUint64(position)
340
+ position += 8
341
+ return value
342
+
343
+ // int handlers
344
+ case 0xd0:
345
+ return dataView.getInt8(position++)
346
+ case 0xd1:
347
+ value = dataView.getInt16(position)
348
+ position += 2
349
+ return value
350
+ case 0xd2:
351
+ value = dataView.getInt32(position)
352
+ position += 4
353
+ return value
354
+ case 0xd3:
355
+ if (currentUnpackr.int64AsNumber) {
356
+ value = dataView.getInt32(position) * 0x100000000
357
+ value += dataView.getUint32(position + 4)
358
+ } else
359
+ value = dataView.getBigInt64(position)
360
+ position += 8
361
+ return value
362
+
363
+ case 0xd4:
364
+ // fixext 1
365
+ value = src[position++]
366
+ if (value == 0x72) {
367
+ return recordDefinition(src[position++] & 0x3f)
368
+ } else {
369
+ let extension = currentExtensions[value]
370
+ if (extension) {
371
+ if (extension.read) {
372
+ position++ // skip filler byte
373
+ return extension.read(read())
374
+ } else if (extension.noBuffer) {
375
+ position++ // skip filler byte
376
+ return extension()
377
+ } else
378
+ return extension(src.subarray(position, ++position))
379
+ } else
380
+ throw new Error('Unknown extension ' + value)
381
+ }
382
+ case 0xd5:
383
+ // fixext 2
384
+ value = src[position]
385
+ if (value == 0x72) {
386
+ position++
387
+ return recordDefinition(src[position++] & 0x3f, src[position++])
388
+ } else
389
+ return readExt(2)
390
+ case 0xd6:
391
+ // fixext 4
392
+ return readExt(4)
393
+ case 0xd7:
394
+ // fixext 8
395
+ return readExt(8)
396
+ case 0xd8:
397
+ // fixext 16
398
+ return readExt(16)
399
+ case 0xd9:
400
+ // str 8
401
+ value = src[position++]
402
+ if (srcStringEnd >= position) {
403
+ return srcString.slice(position - srcStringStart, (position += value) - srcStringStart)
404
+ }
405
+ return readString8(value)
406
+ case 0xda:
407
+ // str 16
408
+ value = dataView.getUint16(position)
409
+ position += 2
410
+ if (srcStringEnd >= position) {
411
+ return srcString.slice(position - srcStringStart, (position += value) - srcStringStart)
412
+ }
413
+ return readString16(value)
414
+ case 0xdb:
415
+ // str 32
416
+ value = dataView.getUint32(position)
417
+ position += 4
418
+ if (srcStringEnd >= position) {
419
+ return srcString.slice(position - srcStringStart, (position += value) - srcStringStart)
420
+ }
421
+ return readString32(value)
422
+ case 0xdc:
423
+ // array 16
424
+ value = dataView.getUint16(position)
425
+ position += 2
426
+ return readArray(value)
427
+ case 0xdd:
428
+ // array 32
429
+ value = dataView.getUint32(position)
430
+ position += 4
431
+ return readArray(value)
432
+ case 0xde:
433
+ // map 16
434
+ value = dataView.getUint16(position)
435
+ position += 2
436
+ return readMap(value)
437
+ case 0xdf:
438
+ // map 32
439
+ value = dataView.getUint32(position)
440
+ position += 4
441
+ return readMap(value)
442
+ default: // negative int
443
+ if (token >= 0xe0)
444
+ return token - 0x100
445
+ if (token === undefined) {
446
+ let error = new Error('Unexpected end of MessagePack data')
447
+ error.incomplete = true
448
+ throw error
449
+ }
450
+ throw new Error('Unknown MessagePack token ' + token)
451
+
452
+ }
453
+ }
454
+ }
455
+ const validName = /^[a-zA-Z_$][a-zA-Z\d_$]*$/
456
+ function createStructureReader(structure, firstId) {
457
+ function readObject() {
458
+ // This initial function is quick to instantiate, but runs slower. After several iterations pay the cost to build the faster function
459
+ if (readObject.count++ > inlineObjectReadThreshold) {
460
+ let readObject = structure.read = (new Function('r', 'return function(){return {' + structure.map(key => validName.test(key) ? key + ':r()' : ('[' + JSON.stringify(key) + ']:r()')).join(',') + '}}'))(read)
461
+ if (structure.highByte === 0)
462
+ structure.read = createSecondByteReader(firstId, structure.read)
463
+ return readObject() // second byte is already read, if there is one so immediately read object
464
+ }
465
+ let object = {}
466
+ for (let i = 0, l = structure.length; i < l; i++) {
467
+ let key = structure[i]
468
+ object[key] = read()
469
+ }
470
+ return object
471
+ }
472
+ readObject.count = 0
473
+ if (structure.highByte === 0) {
474
+ return createSecondByteReader(firstId, readObject)
475
+ }
476
+ return readObject
477
+ }
478
+
479
+ const createSecondByteReader = (firstId, read0) => {
480
+ return function() {
481
+ let highByte = src[position++]
482
+ if (highByte === 0)
483
+ return read0()
484
+ let id = firstId < 32 ? -(firstId + (highByte << 5)) : firstId + (highByte << 5)
485
+ let structure = currentStructures[id] || loadStructures()[id]
486
+ if (!structure) {
487
+ throw new Error('Record id is not defined for ' + id)
488
+ }
489
+ if (!structure.read)
490
+ structure.read = createStructureReader(structure, firstId)
491
+ return structure.read()
492
+ }
493
+ }
494
+
495
+ function loadStructures() {
496
+ let loadedStructures = saveState(() => {
497
+ // save the state in case getStructures modifies our buffer
498
+ src = null
499
+ return currentUnpackr.getStructures()
500
+ })
501
+ return currentStructures = currentUnpackr._mergeStructures(loadedStructures, currentStructures)
502
+ }
503
+
504
+ var readFixedString = readStringJS
505
+ var readString8 = readStringJS
506
+ var readString16 = readStringJS
507
+ var readString32 = readStringJS
508
+ export let isNativeAccelerationEnabled = false
509
+
510
+ export function setExtractor(extractStrings) {
511
+ isNativeAccelerationEnabled = true
512
+ readFixedString = readString(1)
513
+ readString8 = readString(2)
514
+ readString16 = readString(3)
515
+ readString32 = readString(5)
516
+ function readString(headerLength) {
517
+ return function readString(length) {
518
+ let string = strings[stringPosition++]
519
+ if (string == null) {
520
+ if (bundledStrings)
521
+ return readStringJS(length)
522
+ let extraction = extractStrings(position - headerLength, srcEnd, src)
523
+ if (typeof extraction == 'string') {
524
+ string = extraction
525
+ strings = EMPTY_ARRAY
526
+ } else {
527
+ strings = extraction
528
+ stringPosition = 1
529
+ srcStringEnd = 1 // even if a utf-8 string was decoded, must indicate we are in the midst of extracted strings and can't skip strings
530
+ string = strings[0]
531
+ if (string === undefined)
532
+ throw new Error('Unexpected end of buffer')
533
+ }
534
+ }
535
+ let srcStringLength = string.length
536
+ if (srcStringLength <= length) {
537
+ position += length
538
+ return string
539
+ }
540
+ srcString = string
541
+ srcStringStart = position
542
+ srcStringEnd = position + srcStringLength
543
+ position += length
544
+ return string.slice(0, length) // we know we just want the beginning
545
+ }
546
+ }
547
+ }
548
+ function readStringJS(length) {
549
+ let result
550
+ if (length < 16) {
551
+ if (result = shortStringInJS(length))
552
+ return result
553
+ }
554
+ if (length > 64 && decoder)
555
+ return decoder.decode(src.subarray(position, position += length))
556
+ const end = position + length
557
+ const units = []
558
+ result = ''
559
+ while (position < end) {
560
+ const byte1 = src[position++]
561
+ if ((byte1 & 0x80) === 0) {
562
+ // 1 byte
563
+ units.push(byte1)
564
+ } else if ((byte1 & 0xe0) === 0xc0) {
565
+ // 2 bytes
566
+ const byte2 = src[position++] & 0x3f
567
+ units.push(((byte1 & 0x1f) << 6) | byte2)
568
+ } else if ((byte1 & 0xf0) === 0xe0) {
569
+ // 3 bytes
570
+ const byte2 = src[position++] & 0x3f
571
+ const byte3 = src[position++] & 0x3f
572
+ units.push(((byte1 & 0x1f) << 12) | (byte2 << 6) | byte3)
573
+ } else if ((byte1 & 0xf8) === 0xf0) {
574
+ // 4 bytes
575
+ const byte2 = src[position++] & 0x3f
576
+ const byte3 = src[position++] & 0x3f
577
+ const byte4 = src[position++] & 0x3f
578
+ let unit = ((byte1 & 0x07) << 0x12) | (byte2 << 0x0c) | (byte3 << 0x06) | byte4
579
+ if (unit > 0xffff) {
580
+ unit -= 0x10000
581
+ units.push(((unit >>> 10) & 0x3ff) | 0xd800)
582
+ unit = 0xdc00 | (unit & 0x3ff)
583
+ }
584
+ units.push(unit)
585
+ } else {
586
+ units.push(byte1)
587
+ }
588
+
589
+ if (units.length >= 0x1000) {
590
+ result += fromCharCode.apply(String, units)
591
+ units.length = 0
592
+ }
593
+ }
594
+
595
+ if (units.length > 0) {
596
+ result += fromCharCode.apply(String, units)
597
+ }
598
+
599
+ return result
600
+ }
601
+
602
+ function readArray(length) {
603
+ let array = new Array(length)
604
+ for (let i = 0; i < length; i++) {
605
+ array[i] = read()
606
+ }
607
+ return array
608
+ }
609
+
610
+ function readMap(length) {
611
+ if (currentUnpackr.mapsAsObjects) {
612
+ let object = {}
613
+ for (let i = 0; i < length; i++) {
614
+ object[readKey()] = read()
615
+ }
616
+ return object
617
+ } else {
618
+ let map = new Map()
619
+ for (let i = 0; i < length; i++) {
620
+ map.set(read(), read())
621
+ }
622
+ return map
623
+ }
624
+ }
625
+
626
+ var fromCharCode = String.fromCharCode
627
+ function longStringInJS(length) {
628
+ let start = position
629
+ let bytes = new Array(length)
630
+ for (let i = 0; i < length; i++) {
631
+ const byte = src[position++];
632
+ if ((byte & 0x80) > 0) {
633
+ position = start
634
+ return
635
+ }
636
+ bytes[i] = byte
637
+ }
638
+ return fromCharCode.apply(String, bytes)
639
+ }
640
+ function shortStringInJS(length) {
641
+ if (length < 4) {
642
+ if (length < 2) {
643
+ if (length === 0)
644
+ return ''
645
+ else {
646
+ let a = src[position++]
647
+ if ((a & 0x80) > 1) {
648
+ position -= 1
649
+ return
650
+ }
651
+ return fromCharCode(a)
652
+ }
653
+ } else {
654
+ let a = src[position++]
655
+ let b = src[position++]
656
+ if ((a & 0x80) > 0 || (b & 0x80) > 0) {
657
+ position -= 2
658
+ return
659
+ }
660
+ if (length < 3)
661
+ return fromCharCode(a, b)
662
+ let c = src[position++]
663
+ if ((c & 0x80) > 0) {
664
+ position -= 3
665
+ return
666
+ }
667
+ return fromCharCode(a, b, c)
668
+ }
669
+ } else {
670
+ let a = src[position++]
671
+ let b = src[position++]
672
+ let c = src[position++]
673
+ let d = src[position++]
674
+ if ((a & 0x80) > 0 || (b & 0x80) > 0 || (c & 0x80) > 0 || (d & 0x80) > 0) {
675
+ position -= 4
676
+ return
677
+ }
678
+ if (length < 6) {
679
+ if (length === 4)
680
+ return fromCharCode(a, b, c, d)
681
+ else {
682
+ let e = src[position++]
683
+ if ((e & 0x80) > 0) {
684
+ position -= 5
685
+ return
686
+ }
687
+ return fromCharCode(a, b, c, d, e)
688
+ }
689
+ } else if (length < 8) {
690
+ let e = src[position++]
691
+ let f = src[position++]
692
+ if ((e & 0x80) > 0 || (f & 0x80) > 0) {
693
+ position -= 6
694
+ return
695
+ }
696
+ if (length < 7)
697
+ return fromCharCode(a, b, c, d, e, f)
698
+ let g = src[position++]
699
+ if ((g & 0x80) > 0) {
700
+ position -= 7
701
+ return
702
+ }
703
+ return fromCharCode(a, b, c, d, e, f, g)
704
+ } else {
705
+ let e = src[position++]
706
+ let f = src[position++]
707
+ let g = src[position++]
708
+ let h = src[position++]
709
+ if ((e & 0x80) > 0 || (f & 0x80) > 0 || (g & 0x80) > 0 || (h & 0x80) > 0) {
710
+ position -= 8
711
+ return
712
+ }
713
+ if (length < 10) {
714
+ if (length === 8)
715
+ return fromCharCode(a, b, c, d, e, f, g, h)
716
+ else {
717
+ let i = src[position++]
718
+ if ((i & 0x80) > 0) {
719
+ position -= 9
720
+ return
721
+ }
722
+ return fromCharCode(a, b, c, d, e, f, g, h, i)
723
+ }
724
+ } else if (length < 12) {
725
+ let i = src[position++]
726
+ let j = src[position++]
727
+ if ((i & 0x80) > 0 || (j & 0x80) > 0) {
728
+ position -= 10
729
+ return
730
+ }
731
+ if (length < 11)
732
+ return fromCharCode(a, b, c, d, e, f, g, h, i, j)
733
+ let k = src[position++]
734
+ if ((k & 0x80) > 0) {
735
+ position -= 11
736
+ return
737
+ }
738
+ return fromCharCode(a, b, c, d, e, f, g, h, i, j, k)
739
+ } else {
740
+ let i = src[position++]
741
+ let j = src[position++]
742
+ let k = src[position++]
743
+ let l = src[position++]
744
+ if ((i & 0x80) > 0 || (j & 0x80) > 0 || (k & 0x80) > 0 || (l & 0x80) > 0) {
745
+ position -= 12
746
+ return
747
+ }
748
+ if (length < 14) {
749
+ if (length === 12)
750
+ return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l)
751
+ else {
752
+ let m = src[position++]
753
+ if ((m & 0x80) > 0) {
754
+ position -= 13
755
+ return
756
+ }
757
+ return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m)
758
+ }
759
+ } else {
760
+ let m = src[position++]
761
+ let n = src[position++]
762
+ if ((m & 0x80) > 0 || (n & 0x80) > 0) {
763
+ position -= 14
764
+ return
765
+ }
766
+ if (length < 15)
767
+ return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m, n)
768
+ let o = src[position++]
769
+ if ((o & 0x80) > 0) {
770
+ position -= 15
771
+ return
772
+ }
773
+ return fromCharCode(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
774
+ }
775
+ }
776
+ }
777
+ }
778
+ }
779
+
780
+ function readOnlyJSString() {
781
+ let token = src[position++]
782
+ let length
783
+ if (token < 0xc0) {
784
+ // fixstr
785
+ length = token - 0xa0
786
+ } else {
787
+ switch(token) {
788
+ case 0xd9:
789
+ // str 8
790
+ length = src[position++]
791
+ break
792
+ case 0xda:
793
+ // str 16
794
+ length = dataView.getUint16(position)
795
+ position += 2
796
+ break
797
+ case 0xdb:
798
+ // str 32
799
+ length = dataView.getUint32(position)
800
+ position += 4
801
+ break
802
+ default:
803
+ throw new Error('Expected string')
804
+ }
805
+ }
806
+ return readStringJS(length)
807
+ }
808
+
809
+
810
+ function readBin(length) {
811
+ return currentUnpackr.copyBuffers ?
812
+ // specifically use the copying slice (not the node one)
813
+ Uint8Array.prototype.slice.call(src, position, position += length) :
814
+ src.subarray(position, position += length)
815
+ }
816
+ function readExt(length) {
817
+ let type = src[position++]
818
+ if (currentExtensions[type]) {
819
+ return currentExtensions[type](src.subarray(position, position += length))
820
+ }
821
+ else
822
+ throw new Error('Unknown extension type ' + type)
823
+ }
824
+
825
+ var keyCache = new Array(4096)
826
+ function readKey() {
827
+ let length = src[position++]
828
+ if (length >= 0xa0 && length < 0xc0) {
829
+ // fixstr, potentially use key cache
830
+ length = length - 0xa0
831
+ if (srcStringEnd >= position) // if it has been extracted, must use it (and faster anyway)
832
+ return srcString.slice(position - srcStringStart, (position += length) - srcStringStart)
833
+ else if (!(srcStringEnd == 0 && srcEnd < 180))
834
+ return readFixedString(length)
835
+ } else { // not cacheable, go back and do a standard read
836
+ position--
837
+ return read()
838
+ }
839
+ let key = ((length << 5) ^ (length > 1 ? dataView.getUint16(position) : length > 0 ? src[position] : 0)) & 0xfff
840
+ let entry = keyCache[key]
841
+ let checkPosition = position
842
+ let end = position + length - 3
843
+ let chunk
844
+ let i = 0
845
+ if (entry && entry.bytes == length) {
846
+ while (checkPosition < end) {
847
+ chunk = dataView.getUint32(checkPosition)
848
+ if (chunk != entry[i++]) {
849
+ checkPosition = 0x70000000
850
+ break
851
+ }
852
+ checkPosition += 4
853
+ }
854
+ end += 3
855
+ while (checkPosition < end) {
856
+ chunk = src[checkPosition++]
857
+ if (chunk != entry[i++]) {
858
+ checkPosition = 0x70000000
859
+ break
860
+ }
861
+ }
862
+ if (checkPosition === end) {
863
+ position = checkPosition
864
+ return entry.string
865
+ }
866
+ end -= 3
867
+ checkPosition = position
868
+ }
869
+ entry = []
870
+ keyCache[key] = entry
871
+ entry.bytes = length
872
+ while (checkPosition < end) {
873
+ chunk = dataView.getUint32(checkPosition)
874
+ entry.push(chunk)
875
+ checkPosition += 4
876
+ }
877
+ end += 3
878
+ while (checkPosition < end) {
879
+ chunk = src[checkPosition++]
880
+ entry.push(chunk)
881
+ }
882
+ // for small blocks, avoiding the overhead of the extract call is helpful
883
+ let string = length < 16 ? shortStringInJS(length) : longStringInJS(length)
884
+ if (string != null)
885
+ return entry.string = string
886
+ return entry.string = readFixedString(length)
887
+ }
888
+
889
+ // the registration of the record definition extension (as "r")
890
+ const recordDefinition = (id, highByte) => {
891
+ var structure = read()
892
+ let firstByte = id
893
+ if (highByte !== undefined) {
894
+ id = id < 32 ? -((highByte << 5) + id) : ((highByte << 5) + id)
895
+ structure.highByte = highByte
896
+ }
897
+ let existingStructure = currentStructures[id]
898
+ if (existingStructure && existingStructure.isShared) {
899
+ (currentStructures.restoreStructures || (currentStructures.restoreStructures = []))[id] = existingStructure
900
+ }
901
+ currentStructures[id] = structure
902
+ structure.read = createStructureReader(structure, firstByte)
903
+ return structure.read()
904
+ }
905
+ currentExtensions[0] = () => {} // notepack defines extension 0 to mean undefined, so use that as the default here
906
+ currentExtensions[0].noBuffer = true
907
+
908
+ currentExtensions[0x65] = () => {
909
+ let data = read()
910
+ return (globalThis[data[0]] || Error)(data[1])
911
+ }
912
+
913
+ currentExtensions[0x69] = (data) => {
914
+ // id extension (for structured clones)
915
+ let id = dataView.getUint32(position - 4)
916
+ if (!referenceMap)
917
+ referenceMap = new Map()
918
+ let token = src[position]
919
+ let target
920
+ // TODO: handle Maps, Sets, and other types that can cycle; this is complicated, because you potentially need to read
921
+ // ahead past references to record structure definitions
922
+ if (token >= 0x90 && token < 0xa0 || token == 0xdc || token == 0xdd)
923
+ target = []
924
+ else
925
+ target = {}
926
+
927
+ let refEntry = { target } // a placeholder object
928
+ referenceMap.set(id, refEntry)
929
+ let targetProperties = read() // read the next value as the target object to id
930
+ if (refEntry.used) // there is a cycle, so we have to assign properties to original target
931
+ return Object.assign(target, targetProperties)
932
+ refEntry.target = targetProperties // the placeholder wasn't used, replace with the deserialized one
933
+ return targetProperties // no cycle, can just use the returned read object
934
+ }
935
+
936
+ currentExtensions[0x70] = (data) => {
937
+ // pointer extension (for structured clones)
938
+ let id = dataView.getUint32(position - 4)
939
+ let refEntry = referenceMap.get(id)
940
+ refEntry.used = true
941
+ return refEntry.target
942
+ }
943
+
944
+ currentExtensions[0x73] = () => new Set(read())
945
+
946
+ export const typedArrays = ['Int8','Uint8','Uint8Clamped','Int16','Uint16','Int32','Uint32','Float32','Float64','BigInt64','BigUint64'].map(type => type + 'Array')
947
+
948
+ currentExtensions[0x74] = (data) => {
949
+ let typeCode = data[0]
950
+ let typedArrayName = typedArrays[typeCode]
951
+ if (!typedArrayName)
952
+ throw new Error('Could not find typed array for code ' + typeCode)
953
+ // we have to always slice/copy here to get a new ArrayBuffer that is word/byte aligned
954
+ return new globalThis[typedArrayName](Uint8Array.prototype.slice.call(data, 1).buffer)
955
+ }
956
+ currentExtensions[0x78] = () => {
957
+ let data = read()
958
+ return new RegExp(data[0], data[1])
959
+ }
960
+ const TEMP_BUNDLE = []
961
+ currentExtensions[0x62] = (data) => {
962
+ let dataSize = (data[0] << 24) + (data[1] << 16) + (data[2] << 8) + data[3]
963
+ let dataPosition = position
964
+ position += dataSize - data.length
965
+ bundledStrings = TEMP_BUNDLE
966
+ bundledStrings = [readOnlyJSString(), readOnlyJSString()]
967
+ bundledStrings.position0 = 0
968
+ bundledStrings.position1 = 0
969
+ bundledStrings.postBundlePosition = position
970
+ position = dataPosition
971
+ return read()
972
+ }
973
+
974
+ currentExtensions[0xff] = (data) => {
975
+ // 32-bit date extension
976
+ if (data.length == 4)
977
+ return new Date((data[0] * 0x1000000 + (data[1] << 16) + (data[2] << 8) + data[3]) * 1000)
978
+ else if (data.length == 8)
979
+ return new Date(
980
+ ((data[0] << 22) + (data[1] << 14) + (data[2] << 6) + (data[3] >> 2)) / 1000000 +
981
+ ((data[3] & 0x3) * 0x100000000 + data[4] * 0x1000000 + (data[5] << 16) + (data[6] << 8) + data[7]) * 1000)
982
+ else if (data.length == 12)// TODO: Implement support for negative
983
+ return new Date(
984
+ ((data[0] << 24) + (data[1] << 16) + (data[2] << 8) + data[3]) / 1000000 +
985
+ (((data[4] & 0x80) ? -0x1000000000000 : 0) + data[6] * 0x10000000000 + data[7] * 0x100000000 + data[8] * 0x1000000 + (data[9] << 16) + (data[10] << 8) + data[11]) * 1000)
986
+ else
987
+ return new Date('invalid')
988
+ } // notepack defines extension 0 to mean undefined, so use that as the default here
989
+ // registration of bulk record definition?
990
+ // currentExtensions[0x52] = () =>
991
+
992
+ function saveState(callback) {
993
+ let savedSrcEnd = srcEnd
994
+ let savedPosition = position
995
+ let savedStringPosition = stringPosition
996
+ let savedSrcStringStart = srcStringStart
997
+ let savedSrcStringEnd = srcStringEnd
998
+ let savedSrcString = srcString
999
+ let savedStrings = strings
1000
+ let savedReferenceMap = referenceMap
1001
+ let savedBundledStrings = bundledStrings
1002
+
1003
+ // TODO: We may need to revisit this if we do more external calls to user code (since it could be slow)
1004
+ let savedSrc = new Uint8Array(src.slice(0, srcEnd)) // we copy the data in case it changes while external data is processed
1005
+ let savedStructures = currentStructures
1006
+ let savedStructuresContents = currentStructures.slice(0, currentStructures.length)
1007
+ let savedPackr = currentUnpackr
1008
+ let savedSequentialMode = sequentialMode
1009
+ let value = callback()
1010
+ srcEnd = savedSrcEnd
1011
+ position = savedPosition
1012
+ stringPosition = savedStringPosition
1013
+ srcStringStart = savedSrcStringStart
1014
+ srcStringEnd = savedSrcStringEnd
1015
+ srcString = savedSrcString
1016
+ strings = savedStrings
1017
+ referenceMap = savedReferenceMap
1018
+ bundledStrings = savedBundledStrings
1019
+ src = savedSrc
1020
+ sequentialMode = savedSequentialMode
1021
+ currentStructures = savedStructures
1022
+ currentStructures.splice(0, currentStructures.length, ...savedStructuresContents)
1023
+ currentUnpackr = savedPackr
1024
+ dataView = new DataView(src.buffer, src.byteOffset, src.byteLength)
1025
+ return value
1026
+ }
1027
+ export function clearSource() {
1028
+ src = null
1029
+ referenceMap = null
1030
+ currentStructures = null
1031
+ }
1032
+
1033
+ export function addExtension(extension) {
1034
+ if (extension.unpack)
1035
+ currentExtensions[extension.type] = extension.unpack
1036
+ else
1037
+ currentExtensions[extension.type] = extension
1038
+ }
1039
+
1040
+ export const mult10 = new Array(147) // this is a table matching binary exponents to the multiplier to determine significant digit rounding
1041
+ for (let i = 0; i < 256; i++) {
1042
+ mult10[i] = +('1e' + Math.floor(45.15 - i * 0.30103))
1043
+ }
1044
+ export const Decoder = Unpackr
1045
+ var defaultUnpackr = new Unpackr({ useRecords: false })
1046
+ export const unpack = defaultUnpackr.unpack
1047
+ export const unpackMultiple = defaultUnpackr.unpackMultiple
1048
+ export const decode = defaultUnpackr.unpack
1049
+ export const FLOAT32_OPTIONS = {
1050
+ NEVER: 0,
1051
+ ALWAYS: 1,
1052
+ DECIMAL_ROUND: 3,
1053
+ DECIMAL_FIT: 4
1054
+ }
1055
+ let f32Array = new Float32Array(1)
1056
+ let u8Array = new Uint8Array(f32Array.buffer, 0, 4)
1057
+ export function roundFloat32(float32Number) {
1058
+ f32Array[0] = float32Number
1059
+ let multiplier = mult10[((u8Array[3] & 0x7f) << 1) | (u8Array[2] >> 7)]
1060
+ return ((multiplier * float32Number + (float32Number > 0 ? 0.5 : -0.5)) >> 0) / multiplier
1061
+ }