@unicom-cloud/utils 0.1.37 → 0.1.38

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 (338) hide show
  1. package/assert/index.js +1 -1
  2. package/assert.js +1 -1
  3. package/canvas-roundrect-polyfill/LICENSE +21 -0
  4. package/canvas-roundrect-polyfill/index.js +210 -0
  5. package/canvasRoundrectPolyfill.js +2 -0
  6. package/case-name/index.js +1 -1
  7. package/caseName.js +1 -1
  8. package/class-name/index.js +1 -1
  9. package/className.js +1 -1
  10. package/clipboard-copy/index.js +1 -1
  11. package/clipboardCopy.js +1 -1
  12. package/constant/address.js +1 -1
  13. package/constant/chineseCharacters.js +1 -1
  14. package/constant/constellations.js +1 -1
  15. package/constant/domain.js +1 -1
  16. package/constant/identity.js +1 -1
  17. package/constant/index.js +1 -1
  18. package/constant/isMobile.js +1 -1
  19. package/constant/keyboardCode.js +1 -1
  20. package/constant/licensePlate.js +1 -1
  21. package/constant/name.js +1 -1
  22. package/constant/platform.js +1 -1
  23. package/constant/protocol.js +1 -1
  24. package/constant/string.js +1 -1
  25. package/constant/ui.js +1 -1
  26. package/constant.js +1 -1
  27. package/content-disposition/index.js +1 -1
  28. package/contentDisposition.js +1 -1
  29. package/cookie/index.js +1 -1
  30. package/cookie/src/api.js +1 -1
  31. package/cookie/src/assign.js +1 -1
  32. package/cookie/src/converter.js +1 -1
  33. package/cookie.js +1 -1
  34. package/date/convertTime.js +1 -1
  35. package/date/convertToDuration.js +1 -1
  36. package/date/index.js +1 -1
  37. package/date.js +1 -1
  38. package/decimal/decimal.js +1 -1
  39. package/decimal/index.js +1 -1
  40. package/decimal.js +1 -1
  41. package/dom-helpers/activeElement.js +1 -1
  42. package/dom-helpers/addClass.js +1 -1
  43. package/dom-helpers/addEventListener.js +1 -1
  44. package/dom-helpers/animate.js +1 -1
  45. package/dom-helpers/animationFrame.js +1 -1
  46. package/dom-helpers/attribute.js +1 -1
  47. package/dom-helpers/camelize.js +1 -1
  48. package/dom-helpers/camelizeStyle.js +1 -1
  49. package/dom-helpers/canUseDOM.js +1 -1
  50. package/dom-helpers/childElements.js +1 -1
  51. package/dom-helpers/childNodes.js +1 -1
  52. package/dom-helpers/clear.js +1 -1
  53. package/dom-helpers/closest.js +1 -1
  54. package/dom-helpers/collectElements.js +1 -1
  55. package/dom-helpers/collectSiblings.js +1 -1
  56. package/dom-helpers/contains.js +1 -1
  57. package/dom-helpers/css.js +1 -1
  58. package/dom-helpers/filterEventHandler.js +1 -1
  59. package/dom-helpers/getComputedStyle.js +1 -1
  60. package/dom-helpers/getElementCoordinates.js +1 -1
  61. package/dom-helpers/getScrollAccessor.js +1 -1
  62. package/dom-helpers/hasClass.js +1 -1
  63. package/dom-helpers/height.js +1 -1
  64. package/dom-helpers/hyphenate.js +1 -1
  65. package/dom-helpers/hyphenateStyle.js +1 -1
  66. package/dom-helpers/index.js +1 -1
  67. package/dom-helpers/insertAfter.js +1 -1
  68. package/dom-helpers/isDocument.js +1 -1
  69. package/dom-helpers/isInput.js +1 -1
  70. package/dom-helpers/isTransform.js +1 -1
  71. package/dom-helpers/isVisible.js +1 -1
  72. package/dom-helpers/isWindow.js +1 -1
  73. package/dom-helpers/listen.js +1 -1
  74. package/dom-helpers/matches.js +1 -1
  75. package/dom-helpers/nextUntil.js +1 -1
  76. package/dom-helpers/offset.js +1 -1
  77. package/dom-helpers/offsetParent.js +1 -1
  78. package/dom-helpers/ownerDocument.js +1 -1
  79. package/dom-helpers/ownerWindow.js +1 -1
  80. package/dom-helpers/parents.js +1 -1
  81. package/dom-helpers/position.js +1 -1
  82. package/dom-helpers/prepend.js +1 -1
  83. package/dom-helpers/querySelectorAll.js +1 -1
  84. package/dom-helpers/reflow.js +1 -1
  85. package/dom-helpers/remove.js +1 -1
  86. package/dom-helpers/removeClass.js +1 -1
  87. package/dom-helpers/removeEventListener.js +1 -1
  88. package/dom-helpers/scrollLeft.js +1 -1
  89. package/dom-helpers/scrollParent.js +1 -1
  90. package/dom-helpers/scrollTo.js +1 -1
  91. package/dom-helpers/scrollTop.js +1 -1
  92. package/dom-helpers/scrollbarSize.js +1 -1
  93. package/dom-helpers/siblings.js +1 -1
  94. package/dom-helpers/text.js +1 -1
  95. package/dom-helpers/toggleClass.js +1 -1
  96. package/dom-helpers/transitionEnd.js +1 -1
  97. package/dom-helpers/triggerEvent.js +1 -1
  98. package/dom-helpers/types.js +1 -1
  99. package/dom-helpers/width.js +1 -1
  100. package/domHelpers.js +1 -1
  101. package/emitter/index.js +1 -1
  102. package/emitter/src/index.js +53 -40
  103. package/emitter.js +1 -1
  104. package/emoji/emoji.js +1 -1
  105. package/emoji/emojis.js +1 -1
  106. package/emoji/index.js +1 -1
  107. package/emoji.js +1 -1
  108. package/escape/index.js +1 -1
  109. package/escape.js +1 -1
  110. package/file/fileRead.js +1 -1
  111. package/file/fileToDataURL.js +2 -2
  112. package/file/index.js +7 -7
  113. package/file/saveAs.js +2 -2
  114. package/file.js +7 -7
  115. package/function/index.js +1 -1
  116. package/function.js +1 -1
  117. package/idb/LICENSE +6 -0
  118. package/idb/async-iterators.js +35 -0
  119. package/idb/database-extras.js +28 -0
  120. package/idb/entry.js +38 -0
  121. package/idb/index-.js +103 -0
  122. package/idb/index.js +9 -101
  123. package/idb/util.js +5 -0
  124. package/idb/wrap-idb-value.js +89 -0
  125. package/idb.js +9 -3
  126. package/index.js +1 -1
  127. package/invariant/index.js +1 -1
  128. package/invariant.js +1 -1
  129. package/is/index.js +1 -1
  130. package/is/lib/isAscii.js +1 -1
  131. package/is/lib/isBase64.js +1 -1
  132. package/is/lib/isChinese.js +1 -1
  133. package/is/lib/isDataURI.js +1 -1
  134. package/is/lib/isEmail.js +1 -1
  135. package/is/lib/isFQDN.js +1 -1
  136. package/is/lib/isFullWidth.js +1 -1
  137. package/is/lib/isHSL.js +1 -1
  138. package/is/lib/isHalfWidth.js +1 -1
  139. package/is/lib/isHash.js +1 -1
  140. package/is/lib/isHexColor.js +1 -1
  141. package/is/lib/isIMEI.js +1 -1
  142. package/is/lib/isIP.js +1 -1
  143. package/is/lib/isIPRange.js +1 -1
  144. package/is/lib/isIdentityCard.js +1 -1
  145. package/is/lib/isJWT.js +1 -1
  146. package/is/lib/isMACAddress.js +1 -1
  147. package/is/lib/isMD5.js +1 -1
  148. package/is/lib/isMimeType.js +1 -1
  149. package/is/lib/isMobilePhone.js +1 -1
  150. package/is/lib/isPort.js +1 -1
  151. package/is/lib/isRgbColor.js +1 -1
  152. package/is/lib/isSemVer.js +1 -1
  153. package/is/lib/isSlug.js +1 -1
  154. package/is/lib/isStrongPassword.js +1 -1
  155. package/is/lib/isURL.js +1 -1
  156. package/is/lib/isUUID.js +1 -1
  157. package/is/lib/isVariableWidth.js +1 -1
  158. package/is.js +1 -1
  159. package/lunar/index.js +1 -1
  160. package/lunar/lib/Holiday.js +1 -1
  161. package/lunar/lib/HolidayUtil.js +1 -1
  162. package/lunar/lib/I18n.js +1 -1
  163. package/lunar/lib/JieQi.js +1 -1
  164. package/lunar/lib/Lunar.js +1 -1
  165. package/lunar/lib/LunarMonth.js +1 -1
  166. package/lunar/lib/LunarTime.js +1 -1
  167. package/lunar/lib/LunarUtil.js +1 -1
  168. package/lunar/lib/LunarYear.js +1 -1
  169. package/lunar/lib/ShouXingUtil.js +1 -1
  170. package/lunar/lib/Solar.js +1 -1
  171. package/lunar/lib/SolarHalfYear.js +1 -1
  172. package/lunar/lib/SolarMonth.js +1 -1
  173. package/lunar/lib/SolarSeason.js +1 -1
  174. package/lunar/lib/SolarUtil.js +1 -1
  175. package/lunar/lib/SolarWeek.js +1 -1
  176. package/lunar/lib/SolarYear.js +1 -1
  177. package/lunar/lib/index.js +1 -1
  178. package/lunar.js +1 -1
  179. package/math/index.js +1 -1
  180. package/math.js +1 -1
  181. package/md5/index.js +1 -1
  182. package/md5.js +1 -1
  183. package/mock/MockWebSocket.js +1 -1
  184. package/mock/MockXMLHttpRequest.js +1 -1
  185. package/mock/index.js +1 -1
  186. package/mock.js +1 -1
  187. package/normalize-wheel/ExecutionEnvironment.js +1 -1
  188. package/normalize-wheel/UserAgent_DEPRECATED.js +1 -1
  189. package/normalize-wheel/index.js +1 -1
  190. package/normalize-wheel/isEventSupported.js +1 -1
  191. package/normalizeWheel.js +1 -1
  192. package/number-to-chinese/index.js +1 -1
  193. package/numberToChinese.js +1 -1
  194. package/nzh/cn.js +2 -2
  195. package/nzh/hk.js +2 -2
  196. package/nzh/index.js +1 -1
  197. package/nzh/nzh.js +2 -2
  198. package/nzh/src/autoGet.js +1 -1
  199. package/nzh/src/index.js +1 -1
  200. package/nzh/src/langs/cn_b.js +1 -1
  201. package/nzh/src/langs/cn_s.js +1 -1
  202. package/nzh/src/langs/hk_b.js +1 -1
  203. package/nzh/src/langs/hk_s.js +1 -1
  204. package/nzh/src/utils.js +1 -1
  205. package/nzh.js +1 -1
  206. package/object/index.js +1 -1
  207. package/object.js +1 -1
  208. package/package.json +1 -1
  209. package/pinyin/index.js +1 -1
  210. package/pinyin/simplified.js +1 -1
  211. package/pinyin/src/core.js +1 -1
  212. package/pinyin/src/simplified.js +1 -1
  213. package/pinyin/src/simplified_dict.js +1 -2
  214. package/pinyin/src/traditional.js +1 -1
  215. package/pinyin/src/traditional_dict.js +1 -2
  216. package/pinyin/traditional.js +1 -1
  217. package/pinyin.js +1 -1
  218. package/promise-pool/LICENSE +19 -0
  219. package/promise-pool/index.js +116 -0
  220. package/promisePool.js +5 -0
  221. package/query-string/base.js +1 -1
  222. package/query-string/index.js +1 -1
  223. package/query-string/splitOnFirst.js +1 -1
  224. package/queryString.js +1 -1
  225. package/random/address.js +1 -1
  226. package/random/constellation.js +1 -1
  227. package/random/image.js +1 -1
  228. package/random/index.js +1 -1
  229. package/random/licensePlate.js +1 -1
  230. package/random/name.js +1 -1
  231. package/random/number.js +1 -1
  232. package/random/text.js +1 -1
  233. package/random/time.js +1 -1
  234. package/random/web.js +1 -1
  235. package/random.js +1 -1
  236. package/sanitize-url/LICENSE +21 -0
  237. package/sanitize-url/index.js +23 -0
  238. package/sanitizeUrl.js +5 -0
  239. package/screenfull/index.js +1 -1
  240. package/screenfull.js +1 -1
  241. package/sleep/index.js +1 -1
  242. package/sleep.js +1 -1
  243. package/snapdom/index.js +1 -1
  244. package/snapdom/src/api/preCache.js +1 -1
  245. package/snapdom/src/api/snapdom.js +21 -22
  246. package/snapdom/src/core/cache.js +1 -1
  247. package/snapdom/src/core/capture.js +1 -1
  248. package/snapdom/src/core/clone.js +1 -1
  249. package/snapdom/src/core/context.js +1 -1
  250. package/snapdom/src/core/plugins.js +1 -1
  251. package/snapdom/src/core/prepare.js +1 -1
  252. package/snapdom/src/exporters/download.js +10 -12
  253. package/snapdom/src/exporters/toBlob.js +6 -12
  254. package/snapdom/src/exporters/toCanvas.js +1 -1
  255. package/snapdom/src/exporters/toImg.js +1 -1
  256. package/snapdom/src/modules/CSSVar.js +1 -1
  257. package/snapdom/src/modules/background.js +1 -1
  258. package/snapdom/src/modules/changeCSS.js +1 -1
  259. package/snapdom/src/modules/counter.js +1 -1
  260. package/snapdom/src/modules/fonts.js +1 -1
  261. package/snapdom/src/modules/iconFonts.js +1 -1
  262. package/snapdom/src/modules/images.js +1 -1
  263. package/snapdom/src/modules/lineClamp.js +1 -1
  264. package/snapdom/src/modules/pseudo.js +1 -1
  265. package/snapdom/src/modules/rasterize.js +1 -1
  266. package/snapdom/src/modules/snapFetch.js +1 -1
  267. package/snapdom/src/modules/styles.js +1 -1
  268. package/snapdom/src/modules/svgDefs.js +1 -1
  269. package/snapdom/src/utils/browser.js +1 -1
  270. package/snapdom/src/utils/capture.helpers.js +1 -1
  271. package/snapdom/src/utils/clone.helpers.js +1 -1
  272. package/snapdom/src/utils/css.js +1 -1
  273. package/snapdom/src/utils/helpers.js +1 -1
  274. package/snapdom/src/utils/image.js +1 -1
  275. package/snapdom/src/utils/prepare.helpers.js +1 -1
  276. package/snapdom/src/utils/transforms.helpers.js +1 -1
  277. package/snapdom.js +1 -1
  278. package/string/chars.js +1 -1
  279. package/string/index.js +1 -1
  280. package/string.js +1 -1
  281. package/tinycolor/index.js +1 -1
  282. package/tinycolor/src/conversion.js +1 -1
  283. package/tinycolor/src/css-color-names.js +1 -1
  284. package/tinycolor/src/format-input.js +5 -5
  285. package/tinycolor/src/from-ratio.js +1 -1
  286. package/tinycolor/src/index.js +1 -1
  287. package/tinycolor/src/random.js +1 -1
  288. package/tinycolor/src/readability.js +1 -1
  289. package/tinycolor/src/to-ms-filter.js +1 -1
  290. package/tinycolor/src/utils.js +1 -1
  291. package/tinycolor.js +1 -1
  292. package/tree/index.js +1 -1
  293. package/tree/search/index.js +1 -1
  294. package/tree.js +1 -1
  295. package/tween/index.js +1 -1
  296. package/tween/src/easing.js +1 -1
  297. package/tween/src/tween.js +1 -1
  298. package/tween.js +1 -1
  299. package/types/canvas-roundrect-polyfill/index.d.ts +0 -0
  300. package/types/emitter/src/index.d.ts +18 -16
  301. package/types/idb/async-iterators.d.ts +1 -0
  302. package/types/idb/database-extras.d.ts +1 -0
  303. package/types/idb/entry.d.ts +634 -0
  304. package/types/idb/index-.d.ts +21 -0
  305. package/types/idb/index.d.ts +3 -21
  306. package/types/idb/util.d.ts +3 -0
  307. package/types/idb/wrap-idb-value.d.ts +34 -0
  308. package/types/sanitize-url/index.d.ts +2 -0
  309. package/types/xlsx/crc32.d.ts +12 -0
  310. package/ui-color/compareColorByRange.js +1 -1
  311. package/ui-color/index.js +1 -1
  312. package/uiColor.js +1 -1
  313. package/url-toolkit/index.js +1 -1
  314. package/url-toolkit/src/url-toolkit.js +1 -1
  315. package/urlToolkit.js +1 -1
  316. package/validate/index.js +11 -11
  317. package/validate/src/index.js +1 -1
  318. package/validate/src/locale/en-US.js +1 -1
  319. package/validate/src/locale/index.js +1 -1
  320. package/validate/src/locale/zh-CN.js +1 -1
  321. package/validate/src/rules/array.js +1 -1
  322. package/validate/src/rules/base.js +1 -1
  323. package/validate/src/rules/boolean.js +1 -1
  324. package/validate/src/rules/custom.js +1 -1
  325. package/validate/src/rules/number.js +1 -1
  326. package/validate/src/rules/object.js +1 -1
  327. package/validate/src/rules/string.js +1 -1
  328. package/validate/src/rules/type.js +1 -1
  329. package/validate.js +11 -11
  330. package/version/index.js +1 -1
  331. package/version.js +1 -1
  332. package/xlsx/crc32.js +48 -0
  333. package/xlsx/index.d.ts +3 -0
  334. package/xlsx/index.js +1 -1
  335. package/xlsx/xlsx.js +5436 -5479
  336. package/xlsx.js +1 -1
  337. package/types/pinyin/es/main.d.ts +0 -4
  338. package/types/pinyin/es/traditional.d.ts +0 -4
@@ -0,0 +1,634 @@
1
+ export interface OpenDBCallbacks<DBTypes extends DBSchema | unknown> {
2
+ /**
3
+ * Called if this version of the database has never been opened before. Use it to specify the
4
+ * schema for the database.
5
+ *
6
+ * @param database A database instance that you can use to add/remove stores and indexes.
7
+ * @param oldVersion Last version of the database opened by the user.
8
+ * @param newVersion Whatever new version you provided.
9
+ * @param transaction The transaction for this upgrade.
10
+ * This is useful if you need to get data from other stores as part of a migration.
11
+ * @param event The event object for the associated 'upgradeneeded' event.
12
+ */
13
+ upgrade?(database: IDBPDatabase<DBTypes>, oldVersion: number, newVersion: number | null, transaction: IDBPTransaction<DBTypes, StoreNames<DBTypes>[], 'versionchange'>, event: IDBVersionChangeEvent): void;
14
+ /**
15
+ * Called if there are older versions of the database open on the origin, so this version cannot
16
+ * open.
17
+ *
18
+ * @param currentVersion Version of the database that's blocking this one.
19
+ * @param blockedVersion The version of the database being blocked (whatever version you provided to `openDB`).
20
+ * @param event The event object for the associated `blocked` event.
21
+ */
22
+ blocked?(currentVersion: number, blockedVersion: number | null, event: IDBVersionChangeEvent): void;
23
+ /**
24
+ * Called if this connection is blocking a future version of the database from opening.
25
+ *
26
+ * @param currentVersion Version of the open database (whatever version you provided to `openDB`).
27
+ * @param blockedVersion The version of the database that's being blocked.
28
+ * @param event The event object for the associated `versionchange` event.
29
+ */
30
+ blocking?(currentVersion: number, blockedVersion: number | null, event: IDBVersionChangeEvent): void;
31
+ /**
32
+ * Called if the browser abnormally terminates the connection.
33
+ * This is not called when `db.close()` is called.
34
+ */
35
+ terminated?(): void;
36
+ }
37
+ /**
38
+ * Open a database.
39
+ *
40
+ * @param name Name of the database.
41
+ * @param version Schema version.
42
+ * @param callbacks Additional callbacks.
43
+ */
44
+ export declare function openDB<DBTypes extends DBSchema | unknown = unknown>(name: string, version?: number, { blocked, upgrade, blocking, terminated }?: OpenDBCallbacks<DBTypes>): Promise<IDBPDatabase<DBTypes>>;
45
+ export interface DeleteDBCallbacks {
46
+ /**
47
+ * Called if there are connections to this database open, so it cannot be deleted.
48
+ *
49
+ * @param currentVersion Version of the database that's blocking the delete operation.
50
+ * @param event The event object for the associated `blocked` event.
51
+ */
52
+ blocked?(currentVersion: number, event: IDBVersionChangeEvent): void;
53
+ }
54
+ /**
55
+ * Delete a database.
56
+ *
57
+ * @param name Name of the database.
58
+ */
59
+ export declare function deleteDB(name: string, { blocked }?: DeleteDBCallbacks): Promise<void>;
60
+ export { unwrap, wrap } from './wrap-idb-value.js';
61
+ type KeyToKeyNoIndex<T> = {
62
+ [K in keyof T]: string extends K ? never : number extends K ? never : K;
63
+ };
64
+ type ValuesOf<T> = T extends {
65
+ [K in keyof T]: infer U;
66
+ } ? U : never;
67
+ type KnownKeys<T> = ValuesOf<KeyToKeyNoIndex<T>>;
68
+ type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
69
+ export interface DBSchema {
70
+ [s: string]: DBSchemaValue;
71
+ }
72
+ interface IndexKeys {
73
+ [s: string]: IDBValidKey;
74
+ }
75
+ interface DBSchemaValue {
76
+ key: IDBValidKey;
77
+ value: any;
78
+ indexes?: IndexKeys;
79
+ }
80
+ /**
81
+ * Extract known object store names from the DB schema type.
82
+ *
83
+ * @template DBTypes DB schema type, or unknown if the DB isn't typed.
84
+ */
85
+ export type StoreNames<DBTypes extends DBSchema | unknown> = DBTypes extends DBSchema ? KnownKeys<DBTypes> : string;
86
+ /**
87
+ * Extract database value types from the DB schema type.
88
+ *
89
+ * @template DBTypes DB schema type, or unknown if the DB isn't typed.
90
+ * @template StoreName Names of the object stores to get the types of.
91
+ */
92
+ export type StoreValue<DBTypes extends DBSchema | unknown, StoreName extends StoreNames<DBTypes>> = DBTypes extends DBSchema ? DBTypes[StoreName]['value'] : any;
93
+ /**
94
+ * Extract database key types from the DB schema type.
95
+ *
96
+ * @template DBTypes DB schema type, or unknown if the DB isn't typed.
97
+ * @template StoreName Names of the object stores to get the types of.
98
+ */
99
+ export type StoreKey<DBTypes extends DBSchema | unknown, StoreName extends StoreNames<DBTypes>> = DBTypes extends DBSchema ? DBTypes[StoreName]['key'] : IDBValidKey;
100
+ /**
101
+ * Extract the names of indexes in certain object stores from the DB schema type.
102
+ *
103
+ * @template DBTypes DB schema type, or unknown if the DB isn't typed.
104
+ * @template StoreName Names of the object stores to get the types of.
105
+ */
106
+ export type IndexNames<DBTypes extends DBSchema | unknown, StoreName extends StoreNames<DBTypes>> = DBTypes extends DBSchema ? keyof DBTypes[StoreName]['indexes'] & string : string;
107
+ /**
108
+ * Extract the types of indexes in certain object stores from the DB schema type.
109
+ *
110
+ * @template DBTypes DB schema type, or unknown if the DB isn't typed.
111
+ * @template StoreName Names of the object stores to get the types of.
112
+ * @template IndexName Names of the indexes to get the types of.
113
+ */
114
+ export type IndexKey<DBTypes extends DBSchema | unknown, StoreName extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, StoreName>> = DBTypes extends DBSchema ? IndexName extends keyof DBTypes[StoreName]['indexes'] ? DBTypes[StoreName]['indexes'][IndexName] : IDBValidKey : IDBValidKey;
115
+ type CursorSource<DBTypes extends DBSchema | unknown, TxStores extends ArrayLike<StoreNames<DBTypes>>, StoreName extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, StoreName> | unknown, Mode extends IDBTransactionMode = 'readonly'> = IndexName extends IndexNames<DBTypes, StoreName> ? IDBPIndex<DBTypes, TxStores, StoreName, IndexName, Mode> : IDBPObjectStore<DBTypes, TxStores, StoreName, Mode>;
116
+ type CursorKey<DBTypes extends DBSchema | unknown, StoreName extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, StoreName> | unknown> = IndexName extends IndexNames<DBTypes, StoreName> ? IndexKey<DBTypes, StoreName, IndexName> : StoreKey<DBTypes, StoreName>;
117
+ type IDBPDatabaseExtends = Omit<IDBDatabase, 'createObjectStore' | 'deleteObjectStore' | 'transaction' | 'objectStoreNames'>;
118
+ export type DOMStringListSymbolIteratorType = DOMStringList extends {
119
+ [Symbol.iterator](): infer R;
120
+ } ? R : IterableIterator<string>;
121
+ /**
122
+ * A variation of DOMStringList with precise string types
123
+ */
124
+ export interface TypedDOMStringList<T extends string> extends DOMStringList {
125
+ contains(string: T): boolean;
126
+ item(index: number): T | null;
127
+ [index: number]: T;
128
+ /**
129
+ * To resolve https://github.com/jakearchibald/idb/issues/327,
130
+ * and for compatibility with TypeScript >= 5.6 with ArrayIterator.
131
+ */
132
+ [Symbol.iterator](): IterableIterator<string> extends DOMStringListSymbolIteratorType ? IterableIterator<T> : DOMStringListSymbolIteratorType & Iterator<T>;
133
+ }
134
+ interface IDBTransactionOptions {
135
+ /**
136
+ * The durability of the transaction.
137
+ *
138
+ * The default is "default". Using "relaxed" provides better performance, but with fewer
139
+ * guarantees. Web applications are encouraged to use "relaxed" for ephemeral data such as caches
140
+ * or quickly changing records, and "strict" in cases where reducing the risk of data loss
141
+ * outweighs the impact to performance and power.
142
+ */
143
+ durability?: 'default' | 'strict' | 'relaxed';
144
+ }
145
+ export interface IDBPDatabase<DBTypes extends DBSchema | unknown = unknown> extends IDBPDatabaseExtends {
146
+ /**
147
+ * The names of stores in the database.
148
+ */
149
+ readonly objectStoreNames: TypedDOMStringList<StoreNames<DBTypes>>;
150
+ /**
151
+ * Creates a new object store.
152
+ *
153
+ * Throws a "InvalidStateError" DOMException if not called within an upgrade transaction.
154
+ */
155
+ createObjectStore<Name extends StoreNames<DBTypes>>(name: Name, optionalParameters?: IDBObjectStoreParameters): IDBPObjectStore<DBTypes, ArrayLike<StoreNames<DBTypes>>, Name, 'versionchange'>;
156
+ /**
157
+ * Deletes the object store with the given name.
158
+ *
159
+ * Throws a "InvalidStateError" DOMException if not called within an upgrade transaction.
160
+ */
161
+ deleteObjectStore(name: StoreNames<DBTypes>): void;
162
+ /**
163
+ * Start a new transaction.
164
+ *
165
+ * @param storeNames The object store(s) this transaction needs.
166
+ * @param mode
167
+ * @param options
168
+ */
169
+ transaction<Name extends StoreNames<DBTypes>, Mode extends IDBTransactionMode = 'readonly'>(storeNames: Name, mode?: Mode, options?: IDBTransactionOptions): IDBPTransaction<DBTypes, [Name], Mode>;
170
+ transaction<Names extends ArrayLike<StoreNames<DBTypes>>, Mode extends IDBTransactionMode = 'readonly'>(storeNames: Names, mode?: Mode, options?: IDBTransactionOptions): IDBPTransaction<DBTypes, Names, Mode>;
171
+ /**
172
+ * Add a value to a store.
173
+ *
174
+ * Rejects if an item of a given key already exists in the store.
175
+ *
176
+ * This is a shortcut that creates a transaction for this single action. If you need to do more
177
+ * than one action, create a transaction instead.
178
+ *
179
+ * @param storeName Name of the store.
180
+ * @param value
181
+ * @param key
182
+ */
183
+ add<Name extends StoreNames<DBTypes>>(storeName: Name, value: StoreValue<DBTypes, Name>, key?: StoreKey<DBTypes, Name> | IDBKeyRange): Promise<StoreKey<DBTypes, Name>>;
184
+ /**
185
+ * Deletes all records in a store.
186
+ *
187
+ * This is a shortcut that creates a transaction for this single action. If you need to do more
188
+ * than one action, create a transaction instead.
189
+ *
190
+ * @param storeName Name of the store.
191
+ */
192
+ clear(name: StoreNames<DBTypes>): Promise<void>;
193
+ /**
194
+ * Retrieves the number of records matching the given query in a store.
195
+ *
196
+ * This is a shortcut that creates a transaction for this single action. If you need to do more
197
+ * than one action, create a transaction instead.
198
+ *
199
+ * @param storeName Name of the store.
200
+ * @param key
201
+ */
202
+ count<Name extends StoreNames<DBTypes>>(storeName: Name, key?: StoreKey<DBTypes, Name> | IDBKeyRange | null): Promise<number>;
203
+ /**
204
+ * Retrieves the number of records matching the given query in an index.
205
+ *
206
+ * This is a shortcut that creates a transaction for this single action. If you need to do more
207
+ * than one action, create a transaction instead.
208
+ *
209
+ * @param storeName Name of the store.
210
+ * @param indexName Name of the index within the store.
211
+ * @param key
212
+ */
213
+ countFromIndex<Name extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, Name>>(storeName: Name, indexName: IndexName, key?: IndexKey<DBTypes, Name, IndexName> | IDBKeyRange | null): Promise<number>;
214
+ /**
215
+ * Deletes records in a store matching the given query.
216
+ *
217
+ * This is a shortcut that creates a transaction for this single action. If you need to do more
218
+ * than one action, create a transaction instead.
219
+ *
220
+ * @param storeName Name of the store.
221
+ * @param key
222
+ */
223
+ delete<Name extends StoreNames<DBTypes>>(storeName: Name, key: StoreKey<DBTypes, Name> | IDBKeyRange): Promise<void>;
224
+ /**
225
+ * Retrieves the value of the first record in a store matching the query.
226
+ *
227
+ * Resolves with undefined if no match is found.
228
+ *
229
+ * This is a shortcut that creates a transaction for this single action. If you need to do more
230
+ * than one action, create a transaction instead.
231
+ *
232
+ * @param storeName Name of the store.
233
+ * @param query
234
+ */
235
+ get<Name extends StoreNames<DBTypes>>(storeName: Name, query: StoreKey<DBTypes, Name> | IDBKeyRange): Promise<StoreValue<DBTypes, Name> | undefined>;
236
+ /**
237
+ * Retrieves the value of the first record in an index matching the query.
238
+ *
239
+ * Resolves with undefined if no match is found.
240
+ *
241
+ * This is a shortcut that creates a transaction for this single action. If you need to do more
242
+ * than one action, create a transaction instead.
243
+ *
244
+ * @param storeName Name of the store.
245
+ * @param indexName Name of the index within the store.
246
+ * @param query
247
+ */
248
+ getFromIndex<Name extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, Name>>(storeName: Name, indexName: IndexName, query: IndexKey<DBTypes, Name, IndexName> | IDBKeyRange): Promise<StoreValue<DBTypes, Name> | undefined>;
249
+ /**
250
+ * Retrieves all values in a store that match the query.
251
+ *
252
+ * This is a shortcut that creates a transaction for this single action. If you need to do more
253
+ * than one action, create a transaction instead.
254
+ *
255
+ * @param storeName Name of the store.
256
+ * @param query
257
+ * @param count Maximum number of values to return.
258
+ */
259
+ getAll<Name extends StoreNames<DBTypes>>(storeName: Name, query?: StoreKey<DBTypes, Name> | IDBKeyRange | null, count?: number): Promise<StoreValue<DBTypes, Name>[]>;
260
+ /**
261
+ * Retrieves all values in an index that match the query.
262
+ *
263
+ * This is a shortcut that creates a transaction for this single action. If you need to do more
264
+ * than one action, create a transaction instead.
265
+ *
266
+ * @param storeName Name of the store.
267
+ * @param indexName Name of the index within the store.
268
+ * @param query
269
+ * @param count Maximum number of values to return.
270
+ */
271
+ getAllFromIndex<Name extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, Name>>(storeName: Name, indexName: IndexName, query?: IndexKey<DBTypes, Name, IndexName> | IDBKeyRange | null, count?: number): Promise<StoreValue<DBTypes, Name>[]>;
272
+ /**
273
+ * Retrieves the keys of records in a store matching the query.
274
+ *
275
+ * This is a shortcut that creates a transaction for this single action. If you need to do more
276
+ * than one action, create a transaction instead.
277
+ *
278
+ * @param storeName Name of the store.
279
+ * @param query
280
+ * @param count Maximum number of keys to return.
281
+ */
282
+ getAllKeys<Name extends StoreNames<DBTypes>>(storeName: Name, query?: StoreKey<DBTypes, Name> | IDBKeyRange | null, count?: number): Promise<StoreKey<DBTypes, Name>[]>;
283
+ /**
284
+ * Retrieves the keys of records in an index matching the query.
285
+ *
286
+ * This is a shortcut that creates a transaction for this single action. If you need to do more
287
+ * than one action, create a transaction instead.
288
+ *
289
+ * @param storeName Name of the store.
290
+ * @param indexName Name of the index within the store.
291
+ * @param query
292
+ * @param count Maximum number of keys to return.
293
+ */
294
+ getAllKeysFromIndex<Name extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, Name>>(storeName: Name, indexName: IndexName, query?: IndexKey<DBTypes, Name, IndexName> | IDBKeyRange | null, count?: number): Promise<StoreKey<DBTypes, Name>[]>;
295
+ /**
296
+ * Retrieves the key of the first record in a store that matches the query.
297
+ *
298
+ * Resolves with undefined if no match is found.
299
+ *
300
+ * This is a shortcut that creates a transaction for this single action. If you need to do more
301
+ * than one action, create a transaction instead.
302
+ *
303
+ * @param storeName Name of the store.
304
+ * @param query
305
+ */
306
+ getKey<Name extends StoreNames<DBTypes>>(storeName: Name, query: StoreKey<DBTypes, Name> | IDBKeyRange): Promise<StoreKey<DBTypes, Name> | undefined>;
307
+ /**
308
+ * Retrieves the key of the first record in an index that matches the query.
309
+ *
310
+ * Resolves with undefined if no match is found.
311
+ *
312
+ * This is a shortcut that creates a transaction for this single action. If you need to do more
313
+ * than one action, create a transaction instead.
314
+ *
315
+ * @param storeName Name of the store.
316
+ * @param indexName Name of the index within the store.
317
+ * @param query
318
+ */
319
+ getKeyFromIndex<Name extends StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, Name>>(storeName: Name, indexName: IndexName, query: IndexKey<DBTypes, Name, IndexName> | IDBKeyRange): Promise<StoreKey<DBTypes, Name> | undefined>;
320
+ /**
321
+ * Put an item in the database.
322
+ *
323
+ * Replaces any item with the same key.
324
+ *
325
+ * This is a shortcut that creates a transaction for this single action. If you need to do more
326
+ * than one action, create a transaction instead.
327
+ *
328
+ * @param storeName Name of the store.
329
+ * @param value
330
+ * @param key
331
+ */
332
+ put<Name extends StoreNames<DBTypes>>(storeName: Name, value: StoreValue<DBTypes, Name>, key?: StoreKey<DBTypes, Name> | IDBKeyRange): Promise<StoreKey<DBTypes, Name>>;
333
+ }
334
+ type IDBPTransactionExtends = Omit<IDBTransaction, 'db' | 'objectStore' | 'objectStoreNames'>;
335
+ export interface IDBPTransaction<DBTypes extends DBSchema | unknown = unknown, TxStores extends ArrayLike<StoreNames<DBTypes>> = ArrayLike<StoreNames<DBTypes>>, Mode extends IDBTransactionMode = 'readonly'> extends IDBPTransactionExtends {
336
+ /**
337
+ * The transaction's mode.
338
+ */
339
+ readonly mode: Mode;
340
+ /**
341
+ * The names of stores in scope for this transaction.
342
+ */
343
+ readonly objectStoreNames: TypedDOMStringList<TxStores[number]>;
344
+ /**
345
+ * The transaction's connection.
346
+ */
347
+ readonly db: IDBPDatabase<DBTypes>;
348
+ /**
349
+ * Promise for the completion of this transaction.
350
+ */
351
+ readonly done: Promise<void>;
352
+ /**
353
+ * The associated object store, if the transaction covers a single store, otherwise undefined.
354
+ */
355
+ readonly store: TxStores[1] extends undefined ? IDBPObjectStore<DBTypes, TxStores, TxStores[0], Mode> : undefined;
356
+ /**
357
+ * Returns an IDBObjectStore in the transaction's scope.
358
+ */
359
+ objectStore<StoreName extends TxStores[number]>(name: StoreName): IDBPObjectStore<DBTypes, TxStores, StoreName, Mode>;
360
+ }
361
+ type IDBPObjectStoreExtends = Omit<IDBObjectStore, 'transaction' | 'add' | 'clear' | 'count' | 'createIndex' | 'delete' | 'get' | 'getAll' | 'getAllKeys' | 'getKey' | 'index' | 'openCursor' | 'openKeyCursor' | 'put' | 'indexNames'>;
362
+ export interface IDBPObjectStore<DBTypes extends DBSchema | unknown = unknown, TxStores extends ArrayLike<StoreNames<DBTypes>> = ArrayLike<StoreNames<DBTypes>>, StoreName extends StoreNames<DBTypes> = StoreNames<DBTypes>, Mode extends IDBTransactionMode = 'readonly'> extends IDBPObjectStoreExtends {
363
+ /**
364
+ * The names of indexes in the store.
365
+ */
366
+ readonly indexNames: TypedDOMStringList<IndexNames<DBTypes, StoreName>>;
367
+ /**
368
+ * The associated transaction.
369
+ */
370
+ readonly transaction: IDBPTransaction<DBTypes, TxStores, Mode>;
371
+ /**
372
+ * Add a value to the store.
373
+ *
374
+ * Rejects if an item of a given key already exists in the store.
375
+ */
376
+ add: Mode extends 'readonly' ? undefined : (value: StoreValue<DBTypes, StoreName>, key?: StoreKey<DBTypes, StoreName> | IDBKeyRange) => Promise<StoreKey<DBTypes, StoreName>>;
377
+ /**
378
+ * Deletes all records in store.
379
+ */
380
+ clear: Mode extends 'readonly' ? undefined : () => Promise<void>;
381
+ /**
382
+ * Retrieves the number of records matching the given query.
383
+ */
384
+ count(key?: StoreKey<DBTypes, StoreName> | IDBKeyRange | null): Promise<number>;
385
+ /**
386
+ * Creates a new index in store.
387
+ *
388
+ * Throws an "InvalidStateError" DOMException if not called within an upgrade transaction.
389
+ */
390
+ createIndex: Mode extends 'versionchange' ? <IndexName extends IndexNames<DBTypes, StoreName>>(name: IndexName, keyPath: string | string[], options?: IDBIndexParameters) => IDBPIndex<DBTypes, TxStores, StoreName, IndexName, Mode> : undefined;
391
+ /**
392
+ * Deletes records in store matching the given query.
393
+ */
394
+ delete: Mode extends 'readonly' ? undefined : (key: StoreKey<DBTypes, StoreName> | IDBKeyRange) => Promise<void>;
395
+ /**
396
+ * Retrieves the value of the first record matching the query.
397
+ *
398
+ * Resolves with undefined if no match is found.
399
+ */
400
+ get(query: StoreKey<DBTypes, StoreName> | IDBKeyRange): Promise<StoreValue<DBTypes, StoreName> | undefined>;
401
+ /**
402
+ * Retrieves all values that match the query.
403
+ *
404
+ * @param query
405
+ * @param count Maximum number of values to return.
406
+ */
407
+ getAll(query?: StoreKey<DBTypes, StoreName> | IDBKeyRange | null, count?: number): Promise<StoreValue<DBTypes, StoreName>[]>;
408
+ /**
409
+ * Retrieves the keys of records matching the query.
410
+ *
411
+ * @param query
412
+ * @param count Maximum number of keys to return.
413
+ */
414
+ getAllKeys(query?: StoreKey<DBTypes, StoreName> | IDBKeyRange | null, count?: number): Promise<StoreKey<DBTypes, StoreName>[]>;
415
+ /**
416
+ * Retrieves the key of the first record that matches the query.
417
+ *
418
+ * Resolves with undefined if no match is found.
419
+ */
420
+ getKey(query: StoreKey<DBTypes, StoreName> | IDBKeyRange): Promise<StoreKey<DBTypes, StoreName> | undefined>;
421
+ /**
422
+ * Get a query of a given name.
423
+ */
424
+ index<IndexName extends IndexNames<DBTypes, StoreName>>(name: IndexName): IDBPIndex<DBTypes, TxStores, StoreName, IndexName, Mode>;
425
+ /**
426
+ * Opens a cursor over the records matching the query.
427
+ *
428
+ * Resolves with null if no matches are found.
429
+ *
430
+ * @param query If null, all records match.
431
+ * @param direction
432
+ */
433
+ openCursor(query?: StoreKey<DBTypes, StoreName> | IDBKeyRange | null, direction?: IDBCursorDirection): Promise<IDBPCursorWithValue<DBTypes, TxStores, StoreName, unknown, Mode> | null>;
434
+ /**
435
+ * Opens a cursor over the keys matching the query.
436
+ *
437
+ * Resolves with null if no matches are found.
438
+ *
439
+ * @param query If null, all records match.
440
+ * @param direction
441
+ */
442
+ openKeyCursor(query?: StoreKey<DBTypes, StoreName> | IDBKeyRange | null, direction?: IDBCursorDirection): Promise<IDBPCursor<DBTypes, TxStores, StoreName, unknown, Mode> | null>;
443
+ /**
444
+ * Put an item in the store.
445
+ *
446
+ * Replaces any item with the same key.
447
+ */
448
+ put: Mode extends 'readonly' ? undefined : (value: StoreValue<DBTypes, StoreName>, key?: StoreKey<DBTypes, StoreName> | IDBKeyRange) => Promise<StoreKey<DBTypes, StoreName>>;
449
+ /**
450
+ * Iterate over the store.
451
+ */
452
+ [Symbol.asyncIterator](): AsyncIterableIterator<IDBPCursorWithValueIteratorValue<DBTypes, TxStores, StoreName, unknown, Mode>>;
453
+ /**
454
+ * Iterate over the records matching the query.
455
+ *
456
+ * @param query If null, all records match.
457
+ * @param direction
458
+ */
459
+ iterate(query?: StoreKey<DBTypes, StoreName> | IDBKeyRange | null, direction?: IDBCursorDirection): AsyncIterableIterator<IDBPCursorWithValueIteratorValue<DBTypes, TxStores, StoreName, unknown, Mode>>;
460
+ }
461
+ type IDBPIndexExtends = Omit<IDBIndex, 'objectStore' | 'count' | 'get' | 'getAll' | 'getAllKeys' | 'getKey' | 'openCursor' | 'openKeyCursor'>;
462
+ export interface IDBPIndex<DBTypes extends DBSchema | unknown = unknown, TxStores extends ArrayLike<StoreNames<DBTypes>> = ArrayLike<StoreNames<DBTypes>>, StoreName extends StoreNames<DBTypes> = StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, StoreName> = IndexNames<DBTypes, StoreName>, Mode extends IDBTransactionMode = 'readonly'> extends IDBPIndexExtends {
463
+ /**
464
+ * The IDBObjectStore the index belongs to.
465
+ */
466
+ readonly objectStore: IDBPObjectStore<DBTypes, TxStores, StoreName, Mode>;
467
+ /**
468
+ * Retrieves the number of records matching the given query.
469
+ */
470
+ count(key?: IndexKey<DBTypes, StoreName, IndexName> | IDBKeyRange | null): Promise<number>;
471
+ /**
472
+ * Retrieves the value of the first record matching the query.
473
+ *
474
+ * Resolves with undefined if no match is found.
475
+ */
476
+ get(query: IndexKey<DBTypes, StoreName, IndexName> | IDBKeyRange): Promise<StoreValue<DBTypes, StoreName> | undefined>;
477
+ /**
478
+ * Retrieves all values that match the query.
479
+ *
480
+ * @param query
481
+ * @param count Maximum number of values to return.
482
+ */
483
+ getAll(query?: IndexKey<DBTypes, StoreName, IndexName> | IDBKeyRange | null, count?: number): Promise<StoreValue<DBTypes, StoreName>[]>;
484
+ /**
485
+ * Retrieves the keys of records matching the query.
486
+ *
487
+ * @param query
488
+ * @param count Maximum number of keys to return.
489
+ */
490
+ getAllKeys(query?: IndexKey<DBTypes, StoreName, IndexName> | IDBKeyRange | null, count?: number): Promise<StoreKey<DBTypes, StoreName>[]>;
491
+ /**
492
+ * Retrieves the key of the first record that matches the query.
493
+ *
494
+ * Resolves with undefined if no match is found.
495
+ */
496
+ getKey(query: IndexKey<DBTypes, StoreName, IndexName> | IDBKeyRange): Promise<StoreKey<DBTypes, StoreName> | undefined>;
497
+ /**
498
+ * Opens a cursor over the records matching the query.
499
+ *
500
+ * Resolves with null if no matches are found.
501
+ *
502
+ * @param query If null, all records match.
503
+ * @param direction
504
+ */
505
+ openCursor(query?: IndexKey<DBTypes, StoreName, IndexName> | IDBKeyRange | null, direction?: IDBCursorDirection): Promise<IDBPCursorWithValue<DBTypes, TxStores, StoreName, IndexName, Mode> | null>;
506
+ /**
507
+ * Opens a cursor over the keys matching the query.
508
+ *
509
+ * Resolves with null if no matches are found.
510
+ *
511
+ * @param query If null, all records match.
512
+ * @param direction
513
+ */
514
+ openKeyCursor(query?: IndexKey<DBTypes, StoreName, IndexName> | IDBKeyRange | null, direction?: IDBCursorDirection): Promise<IDBPCursor<DBTypes, TxStores, StoreName, IndexName, Mode> | null>;
515
+ /**
516
+ * Iterate over the index.
517
+ */
518
+ [Symbol.asyncIterator](): AsyncIterableIterator<IDBPCursorWithValueIteratorValue<DBTypes, TxStores, StoreName, IndexName, Mode>>;
519
+ /**
520
+ * Iterate over the records matching the query.
521
+ *
522
+ * Resolves with null if no matches are found.
523
+ *
524
+ * @param query If null, all records match.
525
+ * @param direction
526
+ */
527
+ iterate(query?: IndexKey<DBTypes, StoreName, IndexName> | IDBKeyRange | null, direction?: IDBCursorDirection): AsyncIterableIterator<IDBPCursorWithValueIteratorValue<DBTypes, TxStores, StoreName, IndexName, Mode>>;
528
+ }
529
+ type IDBPCursorExtends = Omit<IDBCursor, 'key' | 'primaryKey' | 'source' | 'advance' | 'continue' | 'continuePrimaryKey' | 'delete' | 'update'>;
530
+ export interface IDBPCursor<DBTypes extends DBSchema | unknown = unknown, TxStores extends ArrayLike<StoreNames<DBTypes>> = ArrayLike<StoreNames<DBTypes>>, StoreName extends StoreNames<DBTypes> = StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, StoreName> | unknown = unknown, Mode extends IDBTransactionMode = 'readonly'> extends IDBPCursorExtends {
531
+ /**
532
+ * The key of the current index or object store item.
533
+ */
534
+ readonly key: CursorKey<DBTypes, StoreName, IndexName>;
535
+ /**
536
+ * The key of the current object store item.
537
+ */
538
+ readonly primaryKey: StoreKey<DBTypes, StoreName>;
539
+ /**
540
+ * Returns the IDBObjectStore or IDBIndex the cursor was opened from.
541
+ */
542
+ readonly source: CursorSource<DBTypes, TxStores, StoreName, IndexName, Mode>;
543
+ /**
544
+ * Advances the cursor a given number of records.
545
+ *
546
+ * Resolves to null if no matching records remain.
547
+ */
548
+ advance<T>(this: T, count: number): Promise<T | null>;
549
+ /**
550
+ * Advance the cursor by one record (unless 'key' is provided).
551
+ *
552
+ * Resolves to null if no matching records remain.
553
+ *
554
+ * @param key Advance to the index or object store with a key equal to or greater than this value.
555
+ */
556
+ continue<T>(this: T, key?: CursorKey<DBTypes, StoreName, IndexName>): Promise<T | null>;
557
+ /**
558
+ * Advance the cursor by given keys.
559
+ *
560
+ * The operation is 'and' – both keys must be satisfied.
561
+ *
562
+ * Resolves to null if no matching records remain.
563
+ *
564
+ * @param key Advance to the index or object store with a key equal to or greater than this value.
565
+ * @param primaryKey and where the object store has a key equal to or greater than this value.
566
+ */
567
+ continuePrimaryKey<T>(this: T, key: CursorKey<DBTypes, StoreName, IndexName>, primaryKey: StoreKey<DBTypes, StoreName>): Promise<T | null>;
568
+ /**
569
+ * Delete the current record.
570
+ */
571
+ delete: Mode extends 'readonly' ? undefined : () => Promise<void>;
572
+ /**
573
+ * Updated the current record.
574
+ */
575
+ update: Mode extends 'readonly' ? undefined : (value: StoreValue<DBTypes, StoreName>) => Promise<StoreKey<DBTypes, StoreName>>;
576
+ /**
577
+ * Iterate over the cursor.
578
+ */
579
+ [Symbol.asyncIterator](): AsyncIterableIterator<IDBPCursorIteratorValue<DBTypes, TxStores, StoreName, IndexName, Mode>>;
580
+ }
581
+ type IDBPCursorIteratorValueExtends<DBTypes extends DBSchema | unknown = unknown, TxStores extends ArrayLike<StoreNames<DBTypes>> = ArrayLike<StoreNames<DBTypes>>, StoreName extends StoreNames<DBTypes> = StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, StoreName> | unknown = unknown, Mode extends IDBTransactionMode = 'readonly'> = Omit<IDBPCursor<DBTypes, TxStores, StoreName, IndexName, Mode>, 'advance' | 'continue' | 'continuePrimaryKey'>;
582
+ export interface IDBPCursorIteratorValue<DBTypes extends DBSchema | unknown = unknown, TxStores extends ArrayLike<StoreNames<DBTypes>> = ArrayLike<StoreNames<DBTypes>>, StoreName extends StoreNames<DBTypes> = StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, StoreName> | unknown = unknown, Mode extends IDBTransactionMode = 'readonly'> extends IDBPCursorIteratorValueExtends<DBTypes, TxStores, StoreName, IndexName, Mode> {
583
+ /**
584
+ * Advances the cursor a given number of records.
585
+ */
586
+ advance<T>(this: T, count: number): void;
587
+ /**
588
+ * Advance the cursor by one record (unless 'key' is provided).
589
+ *
590
+ * @param key Advance to the index or object store with a key equal to or greater than this value.
591
+ */
592
+ continue<T>(this: T, key?: CursorKey<DBTypes, StoreName, IndexName>): void;
593
+ /**
594
+ * Advance the cursor by given keys.
595
+ *
596
+ * The operation is 'and' – both keys must be satisfied.
597
+ *
598
+ * @param key Advance to the index or object store with a key equal to or greater than this value.
599
+ * @param primaryKey and where the object store has a key equal to or greater than this value.
600
+ */
601
+ continuePrimaryKey<T>(this: T, key: CursorKey<DBTypes, StoreName, IndexName>, primaryKey: StoreKey<DBTypes, StoreName>): void;
602
+ }
603
+ export interface IDBPCursorWithValue<DBTypes extends DBSchema | unknown = unknown, TxStores extends ArrayLike<StoreNames<DBTypes>> = ArrayLike<StoreNames<DBTypes>>, StoreName extends StoreNames<DBTypes> = StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, StoreName> | unknown = unknown, Mode extends IDBTransactionMode = 'readonly'> extends IDBPCursor<DBTypes, TxStores, StoreName, IndexName, Mode> {
604
+ /**
605
+ * The value of the current item.
606
+ */
607
+ readonly value: StoreValue<DBTypes, StoreName>;
608
+ /**
609
+ * Iterate over the cursor.
610
+ */
611
+ [Symbol.asyncIterator](): AsyncIterableIterator<IDBPCursorWithValueIteratorValue<DBTypes, TxStores, StoreName, IndexName, Mode>>;
612
+ }
613
+ type IDBPCursorWithValueIteratorValueExtends<DBTypes extends DBSchema | unknown = unknown, TxStores extends ArrayLike<StoreNames<DBTypes>> = ArrayLike<StoreNames<DBTypes>>, StoreName extends StoreNames<DBTypes> = StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, StoreName> | unknown = unknown, Mode extends IDBTransactionMode = 'readonly'> = Omit<IDBPCursorWithValue<DBTypes, TxStores, StoreName, IndexName, Mode>, 'advance' | 'continue' | 'continuePrimaryKey'>;
614
+ export interface IDBPCursorWithValueIteratorValue<DBTypes extends DBSchema | unknown = unknown, TxStores extends ArrayLike<StoreNames<DBTypes>> = ArrayLike<StoreNames<DBTypes>>, StoreName extends StoreNames<DBTypes> = StoreNames<DBTypes>, IndexName extends IndexNames<DBTypes, StoreName> | unknown = unknown, Mode extends IDBTransactionMode = 'readonly'> extends IDBPCursorWithValueIteratorValueExtends<DBTypes, TxStores, StoreName, IndexName, Mode> {
615
+ /**
616
+ * Advances the cursor a given number of records.
617
+ */
618
+ advance<T>(this: T, count: number): void;
619
+ /**
620
+ * Advance the cursor by one record (unless 'key' is provided).
621
+ *
622
+ * @param key Advance to the index or object store with a key equal to or greater than this value.
623
+ */
624
+ continue<T>(this: T, key?: CursorKey<DBTypes, StoreName, IndexName>): void;
625
+ /**
626
+ * Advance the cursor by given keys.
627
+ *
628
+ * The operation is 'and' – both keys must be satisfied.
629
+ *
630
+ * @param key Advance to the index or object store with a key equal to or greater than this value.
631
+ * @param primaryKey and where the object store has a key equal to or greater than this value.
632
+ */
633
+ continuePrimaryKey<T>(this: T, key: CursorKey<DBTypes, StoreName, IndexName>, primaryKey: StoreKey<DBTypes, StoreName>): void;
634
+ }
@@ -0,0 +1,21 @@
1
+ declare class IDB {
2
+ constructor(indexedDBName?: string, objectStoreName?: string);
3
+ static deleteDatabase(name: string): void;
4
+ deleteObjectStore(name: string): void;
5
+ private indexedDBName;
6
+ private objectStoreName;
7
+ private idbOpenDBRequestPromise;
8
+ private getObjectStore;
9
+ add(key: IDBValidKey, value: unknown): Promise<any>;
10
+ get(query: IDBValidKey | IDBKeyRange): Promise<any>;
11
+ getAll(query: IDBValidKey | IDBKeyRange | null, count?: number): Promise<any>;
12
+ getKey(query: IDBValidKey | IDBKeyRange): Promise<any>;
13
+ getAllKeys(query?: IDBValidKey | IDBKeyRange | null, count?: number): Promise<any>;
14
+ getMany(querys: (IDBValidKey | IDBKeyRange)[]): Promise<any>;
15
+ put(key: IDBValidKey, value: unknown): Promise<any>;
16
+ putMany(entries: [unknown, string][]): Promise<any>;
17
+ delete(key: IDBValidKey | IDBKeyRange): Promise<any>;
18
+ deleteMany(keys: string[]): Promise<any>;
19
+ clear(): Promise<any>;
20
+ }
21
+ export default IDB;