@warp-drive/core 5.9.0-beta.0 → 5.9.0-beta.1

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 (436) hide show
  1. package/declarations/aliases-BWYW5EhX.d.ts +17 -0
  2. package/declarations/aliases-BWYW5EhX.d.ts.map +1 -0
  3. package/declarations/build-config/babel-macros.d.ts +2 -1
  4. package/declarations/build-config/canary-features.d.ts +1 -1
  5. package/declarations/build-config/debugging.d.ts +1 -1
  6. package/declarations/build-config/deprecations.d.ts +1 -1
  7. package/declarations/build-config/env.d.ts +2 -1
  8. package/declarations/build-config/macros.d.ts +2 -1
  9. package/declarations/build-config.d.ts +2 -18
  10. package/declarations/change-C7kqv2kW.d.ts +41 -0
  11. package/declarations/change-C7kqv2kW.d.ts.map +1 -0
  12. package/declarations/concepts-LHsLJZMl.d.ts +77 -0
  13. package/declarations/concepts-LHsLJZMl.d.ts.map +1 -0
  14. package/declarations/configure-B_F639tN.d.ts +134 -0
  15. package/declarations/configure-B_F639tN.d.ts.map +1 -0
  16. package/declarations/configure.d.ts +2 -7
  17. package/declarations/document-BEn91SwT.d.ts +129 -0
  18. package/declarations/document-BEn91SwT.d.ts.map +1 -0
  19. package/declarations/error-50OSEhsF.d.ts +77 -0
  20. package/declarations/error-50OSEhsF.d.ts.map +1 -0
  21. package/declarations/fields-FM7peCiM.d.ts +2327 -0
  22. package/declarations/fields-FM7peCiM.d.ts.map +1 -0
  23. package/declarations/graph/-private.d.ts +2 -13
  24. package/declarations/graph-DLqYXP2z.d.ts +186 -0
  25. package/declarations/graph-DLqYXP2z.d.ts.map +1 -0
  26. package/declarations/identifier-DQnqOSJK.d.ts +112 -0
  27. package/declarations/identifier-DQnqOSJK.d.ts.map +1 -0
  28. package/declarations/index.d.ts +2 -96
  29. package/declarations/internal-Cz-893zD.d.ts +8690 -0
  30. package/declarations/internal-Cz-893zD.d.ts.map +1 -0
  31. package/declarations/json-api-raw-C5APJHHB.d.ts +378 -0
  32. package/declarations/json-api-raw-C5APJHHB.d.ts.map +1 -0
  33. package/declarations/mutations-CqtoGB4t.d.ts +165 -0
  34. package/declarations/mutations-CqtoGB4t.d.ts.map +1 -0
  35. package/declarations/operations-D1qA6r0_.d.ts +244 -0
  36. package/declarations/operations-D1qA6r0_.d.ts.map +1 -0
  37. package/declarations/params-DrEx3bf8.d.ts +41 -0
  38. package/declarations/params-DrEx3bf8.d.ts.map +1 -0
  39. package/declarations/raw-D5hnjiq7.d.ts +31 -0
  40. package/declarations/raw-D5hnjiq7.d.ts.map +1 -0
  41. package/declarations/reactive/-private.d.ts +2 -2
  42. package/declarations/reactive.d.ts +2 -286
  43. package/declarations/record-D3QQcaIR.d.ts +254 -0
  44. package/declarations/record-D3QQcaIR.d.ts.map +1 -0
  45. package/declarations/relationship-CmHzMPKf.d.ts +65 -0
  46. package/declarations/relationship-CmHzMPKf.d.ts.map +1 -0
  47. package/declarations/request.d.ts +2 -52
  48. package/declarations/signals/-leaked.d.ts +63 -2
  49. package/declarations/signals/-leaked.d.ts.map +1 -0
  50. package/declarations/store/-private.d.ts +2 -24
  51. package/declarations/store.d.ts +8358 -2
  52. package/declarations/store.d.ts.map +1 -0
  53. package/declarations/symbols-DjRDCeX0.d.ts +88 -0
  54. package/declarations/symbols-DjRDCeX0.d.ts.map +1 -0
  55. package/declarations/types/-private.d.ts +71 -17
  56. package/declarations/types/-private.d.ts.map +1 -0
  57. package/declarations/types/cache/aliases.d.ts +2 -1
  58. package/declarations/types/cache/change.d.ts +2 -6
  59. package/declarations/types/cache/mutations.d.ts +2 -38
  60. package/declarations/types/cache/operations.d.ts +2 -168
  61. package/declarations/types/cache/relationship.d.ts +2 -13
  62. package/declarations/types/cache.d.ts +2 -429
  63. package/declarations/types/graph.d.ts +2 -47
  64. package/declarations/types/identifier.d.ts +2 -86
  65. package/declarations/types/json/raw.d.ts +2 -6
  66. package/declarations/types/params.d.ts +2 -8
  67. package/declarations/types/record.d.ts +2 -269
  68. package/declarations/types/request.d.ts +2 -367
  69. package/declarations/types/runtime.d.ts +53 -12
  70. package/declarations/types/runtime.d.ts.map +1 -0
  71. package/declarations/types/schema/concepts.d.ts +2 -23
  72. package/declarations/types/schema/fields.d.ts +2 -2200
  73. package/declarations/types/schema/fields.type-test.d.ts +1 -1
  74. package/declarations/types/schema/schema-service.d.ts +2 -380
  75. package/declarations/types/spec/document.d.ts +2 -67
  76. package/declarations/types/spec/error.d.ts +2 -18
  77. package/declarations/types/spec/json-api-raw.d.ts +2 -139
  78. package/declarations/types/symbols.d.ts +2 -78
  79. package/declarations/types/utils.d.ts +2 -5
  80. package/declarations/types.d.ts +3 -11
  81. package/declarations/utils/string.d.ts +51 -44
  82. package/declarations/utils/string.d.ts.map +1 -0
  83. package/declarations/utils-BtURiy8l.d.ts +24 -0
  84. package/declarations/utils-BtURiy8l.d.ts.map +1 -0
  85. package/dist/-private-DMzvF_Q6.js +120 -0
  86. package/dist/-private-DMzvF_Q6.js.map +1 -0
  87. package/dist/-private-HjaQ1wp1.js +1695 -0
  88. package/dist/-private-HjaQ1wp1.js.map +1 -0
  89. package/dist/-private-b1g4dhl0.js +22 -0
  90. package/dist/-private-b1g4dhl0.js.map +1 -0
  91. package/dist/build-config/babel-macros.js +3 -1
  92. package/dist/build-config/canary-features.js +1 -1
  93. package/dist/build-config/debugging.js +1 -1
  94. package/dist/build-config/deprecations.js +1 -1
  95. package/dist/build-config/env.js +3 -1
  96. package/dist/build-config/macros.js +3 -1
  97. package/dist/build-config.js +3 -1
  98. package/dist/configure.js +3 -2
  99. package/dist/graph/-private.js +2183 -3192
  100. package/dist/graph/-private.js.map +1 -0
  101. package/dist/index.js +3 -8
  102. package/dist/reactive/-private.js +3 -1
  103. package/dist/reactive.js +5 -4
  104. package/dist/request--vRFALbQ.js +766 -0
  105. package/dist/request--vRFALbQ.js.map +1 -0
  106. package/dist/request.js +2 -48
  107. package/dist/signals/-leaked.js +3 -1
  108. package/dist/src-Dex_phWI.js +9088 -0
  109. package/dist/src-Dex_phWI.js.map +1 -0
  110. package/dist/store/-private.js +3 -1
  111. package/dist/store-DNF9Rgoh.js +462 -0
  112. package/dist/store-DNF9Rgoh.js.map +1 -0
  113. package/dist/store.js +3 -1
  114. package/dist/types/-private.js +1 -77
  115. package/dist/types/identifier.js +60 -52
  116. package/dist/types/identifier.js.map +1 -0
  117. package/dist/types/record.js +211 -181
  118. package/dist/types/record.js.map +1 -0
  119. package/dist/types/request.js +138 -69
  120. package/dist/types/request.js.map +1 -0
  121. package/dist/types/runtime.js +54 -26
  122. package/dist/types/runtime.js.map +1 -0
  123. package/dist/types/schema/fields.js +501 -495
  124. package/dist/types/schema/fields.js.map +1 -0
  125. package/dist/types/schema/fields.type-test.js +79 -0
  126. package/dist/types/schema/fields.type-test.js.map +1 -0
  127. package/dist/types/symbols.js +84 -77
  128. package/dist/types/symbols.js.map +1 -0
  129. package/dist/unpkg/dev/-private-2RfQ2761.js +111 -0
  130. package/dist/unpkg/dev/-private-2RfQ2761.js.map +1 -0
  131. package/dist/unpkg/dev/-private-CM1zxNws.js +1684 -0
  132. package/dist/unpkg/dev/-private-CM1zxNws.js.map +1 -0
  133. package/dist/unpkg/dev/-private-DL4tfrv9.js +22 -0
  134. package/dist/unpkg/dev/-private-DL4tfrv9.js.map +1 -0
  135. package/dist/unpkg/dev/build-config/babel-macros.js +3 -1
  136. package/dist/unpkg/dev/build-config/canary-features.js +1 -1
  137. package/dist/unpkg/dev/build-config/debugging.js +1 -1
  138. package/dist/unpkg/dev/build-config/deprecations.js +1 -1
  139. package/dist/unpkg/dev/build-config/env.js +3 -1
  140. package/dist/unpkg/dev/build-config/macros.js +3 -1
  141. package/dist/unpkg/dev/build-config.js +3 -1
  142. package/dist/unpkg/dev/configure.js +3 -1
  143. package/dist/unpkg/dev/graph/-private.js +1941 -2949
  144. package/dist/unpkg/dev/graph/-private.js.map +1 -0
  145. package/dist/unpkg/dev/index.js +3 -6
  146. package/dist/unpkg/dev/reactive/-private.js +3 -1
  147. package/dist/unpkg/dev/reactive.js +5 -3
  148. package/dist/unpkg/dev/request-DAuXbfYi.js +756 -0
  149. package/dist/unpkg/dev/request-DAuXbfYi.js.map +1 -0
  150. package/dist/unpkg/dev/request.js +2 -48
  151. package/dist/unpkg/dev/runtime-EoVKAhTv.js +110 -0
  152. package/dist/unpkg/dev/runtime-EoVKAhTv.js.map +1 -0
  153. package/dist/unpkg/dev/signals/-leaked.js +3 -1
  154. package/dist/unpkg/dev/src-Bxlr_vue.js +8192 -0
  155. package/dist/unpkg/dev/src-Bxlr_vue.js.map +1 -0
  156. package/dist/unpkg/dev/store/-private.js +3 -55
  157. package/dist/unpkg/dev/store-DmiFvT1B.js +427 -0
  158. package/dist/unpkg/dev/store-DmiFvT1B.js.map +1 -0
  159. package/dist/unpkg/dev/store.js +1 -556
  160. package/dist/unpkg/dev/types/-private.js +1 -67
  161. package/dist/unpkg/dev/types/identifier.js +63 -56
  162. package/dist/unpkg/dev/types/identifier.js.map +1 -0
  163. package/dist/unpkg/dev/types/record.js +211 -181
  164. package/dist/unpkg/dev/types/record.js.map +1 -0
  165. package/dist/unpkg/dev/types/request.js +138 -69
  166. package/dist/unpkg/dev/types/request.js.map +1 -0
  167. package/dist/unpkg/dev/types/runtime.js +54 -26
  168. package/dist/unpkg/dev/types/runtime.js.map +1 -0
  169. package/dist/unpkg/dev/types/schema/fields.js +501 -495
  170. package/dist/unpkg/dev/types/schema/fields.js.map +1 -0
  171. package/dist/unpkg/dev/types/schema/fields.type-test.js +79 -0
  172. package/dist/unpkg/dev/types/schema/fields.type-test.js.map +1 -0
  173. package/dist/unpkg/dev/types/symbols.js +84 -77
  174. package/dist/unpkg/dev/types/symbols.js.map +1 -0
  175. package/dist/unpkg/dev/utils/string.js +79 -85
  176. package/dist/unpkg/dev/utils/string.js.map +1 -0
  177. package/dist/unpkg/dev-deprecated/-private-2RfQ2761.js +111 -0
  178. package/dist/unpkg/dev-deprecated/-private-2RfQ2761.js.map +1 -0
  179. package/dist/unpkg/dev-deprecated/-private-CM1zxNws.js +1684 -0
  180. package/dist/unpkg/dev-deprecated/-private-CM1zxNws.js.map +1 -0
  181. package/dist/unpkg/dev-deprecated/-private-DL4tfrv9.js +22 -0
  182. package/dist/unpkg/dev-deprecated/-private-DL4tfrv9.js.map +1 -0
  183. package/dist/unpkg/dev-deprecated/build-config/babel-macros.js +3 -1
  184. package/dist/unpkg/dev-deprecated/build-config/canary-features.js +1 -1
  185. package/dist/unpkg/dev-deprecated/build-config/debugging.js +1 -1
  186. package/dist/unpkg/dev-deprecated/build-config/deprecations.js +1 -1
  187. package/dist/unpkg/dev-deprecated/build-config/env.js +3 -1
  188. package/dist/unpkg/dev-deprecated/build-config/macros.js +3 -1
  189. package/dist/unpkg/dev-deprecated/build-config.js +3 -1
  190. package/dist/unpkg/dev-deprecated/configure.js +3 -1
  191. package/dist/unpkg/dev-deprecated/graph/-private.js +2060 -3143
  192. package/dist/unpkg/dev-deprecated/graph/-private.js.map +1 -0
  193. package/dist/unpkg/dev-deprecated/index.js +3 -5
  194. package/dist/unpkg/dev-deprecated/reactive/-private.js +3 -1
  195. package/dist/unpkg/dev-deprecated/reactive.js +5 -3
  196. package/dist/unpkg/dev-deprecated/request-DAuXbfYi.js +756 -0
  197. package/dist/unpkg/dev-deprecated/request-DAuXbfYi.js.map +1 -0
  198. package/dist/unpkg/dev-deprecated/request.js +2 -48
  199. package/dist/unpkg/dev-deprecated/runtime-BacZMq1r.js +110 -0
  200. package/dist/unpkg/dev-deprecated/runtime-BacZMq1r.js.map +1 -0
  201. package/dist/unpkg/dev-deprecated/signals/-leaked.js +3 -1
  202. package/dist/unpkg/dev-deprecated/src-DEl2Ca3T.js +8745 -0
  203. package/dist/unpkg/dev-deprecated/src-DEl2Ca3T.js.map +1 -0
  204. package/dist/unpkg/dev-deprecated/store/-private.js +3 -1
  205. package/dist/unpkg/dev-deprecated/store-TcP2H4Af.js +427 -0
  206. package/dist/unpkg/dev-deprecated/store-TcP2H4Af.js.map +1 -0
  207. package/dist/unpkg/dev-deprecated/store.js +1 -556
  208. package/dist/unpkg/dev-deprecated/types/-private.js +1 -67
  209. package/dist/unpkg/dev-deprecated/types/identifier.js +63 -56
  210. package/dist/unpkg/dev-deprecated/types/identifier.js.map +1 -0
  211. package/dist/unpkg/dev-deprecated/types/record.js +211 -181
  212. package/dist/unpkg/dev-deprecated/types/record.js.map +1 -0
  213. package/dist/unpkg/dev-deprecated/types/request.js +138 -69
  214. package/dist/unpkg/dev-deprecated/types/request.js.map +1 -0
  215. package/dist/unpkg/dev-deprecated/types/runtime.js +54 -26
  216. package/dist/unpkg/dev-deprecated/types/runtime.js.map +1 -0
  217. package/dist/unpkg/dev-deprecated/types/schema/fields.js +501 -495
  218. package/dist/unpkg/dev-deprecated/types/schema/fields.js.map +1 -0
  219. package/dist/unpkg/dev-deprecated/types/schema/fields.type-test.js +79 -0
  220. package/dist/unpkg/dev-deprecated/types/schema/fields.type-test.js.map +1 -0
  221. package/dist/unpkg/dev-deprecated/types/symbols.js +84 -77
  222. package/dist/unpkg/dev-deprecated/types/symbols.js.map +1 -0
  223. package/dist/unpkg/dev-deprecated/utils/string.js +79 -85
  224. package/dist/unpkg/dev-deprecated/utils/string.js.map +1 -0
  225. package/dist/unpkg/prod/-private-BK71-uXR.js +99 -0
  226. package/dist/unpkg/prod/-private-BK71-uXR.js.map +1 -0
  227. package/dist/unpkg/prod/-private-TNaS5Piv.js +1494 -0
  228. package/dist/unpkg/prod/-private-TNaS5Piv.js.map +1 -0
  229. package/dist/unpkg/prod/-private-Z9i0icpE.js +22 -0
  230. package/dist/unpkg/prod/-private-Z9i0icpE.js.map +1 -0
  231. package/dist/unpkg/prod/build-config/babel-macros.js +3 -1
  232. package/dist/unpkg/prod/build-config/canary-features.js +1 -1
  233. package/dist/unpkg/prod/build-config/debugging.js +1 -1
  234. package/dist/unpkg/prod/build-config/deprecations.js +1 -1
  235. package/dist/unpkg/prod/build-config/env.js +3 -1
  236. package/dist/unpkg/prod/build-config/macros.js +3 -1
  237. package/dist/unpkg/prod/build-config.js +3 -1
  238. package/dist/unpkg/prod/configure.js +3 -2
  239. package/dist/unpkg/prod/graph/-private.js +1475 -2095
  240. package/dist/unpkg/prod/graph/-private.js.map +1 -0
  241. package/dist/unpkg/prod/index.js +2 -482
  242. package/dist/unpkg/prod/reactive/-private.js +3 -1
  243. package/dist/unpkg/prod/reactive.js +5 -30
  244. package/dist/unpkg/prod/request-BcJNzSgv.js +480 -0
  245. package/dist/unpkg/prod/request-BcJNzSgv.js.map +1 -0
  246. package/dist/unpkg/prod/request.js +3 -2
  247. package/dist/unpkg/prod/signals/-leaked.js +3 -1
  248. package/dist/unpkg/prod/src-Dzz-j6pp.js +6799 -0
  249. package/dist/unpkg/prod/src-Dzz-j6pp.js.map +1 -0
  250. package/dist/unpkg/prod/store/-private.js +3 -126
  251. package/dist/unpkg/prod/store-BWhmb7Ob.js +359 -0
  252. package/dist/unpkg/prod/store-BWhmb7Ob.js.map +1 -0
  253. package/dist/unpkg/prod/store.js +1 -435
  254. package/dist/unpkg/prod/types/-private.js +1 -47
  255. package/dist/unpkg/prod/types/identifier.js +63 -56
  256. package/dist/unpkg/prod/types/identifier.js.map +1 -0
  257. package/dist/unpkg/prod/types/record.js +211 -181
  258. package/dist/unpkg/prod/types/record.js.map +1 -0
  259. package/dist/unpkg/prod/types/request.js +138 -69
  260. package/dist/unpkg/prod/types/request.js.map +1 -0
  261. package/dist/unpkg/prod/types/runtime.js +54 -26
  262. package/dist/unpkg/prod/types/runtime.js.map +1 -0
  263. package/dist/unpkg/prod/types/schema/fields.js +501 -495
  264. package/dist/unpkg/prod/types/schema/fields.js.map +1 -0
  265. package/dist/unpkg/prod/types/schema/fields.type-test.js +79 -0
  266. package/dist/unpkg/prod/types/schema/fields.type-test.js.map +1 -0
  267. package/dist/unpkg/prod/types/symbols.js +84 -77
  268. package/dist/unpkg/prod/types/symbols.js.map +1 -0
  269. package/dist/unpkg/prod/utils/string.js +70 -66
  270. package/dist/unpkg/prod/utils/string.js.map +1 -0
  271. package/dist/unpkg/prod-deprecated/-private-BK71-uXR.js +99 -0
  272. package/dist/unpkg/prod-deprecated/-private-BK71-uXR.js.map +1 -0
  273. package/dist/unpkg/prod-deprecated/-private-TNaS5Piv.js +1494 -0
  274. package/dist/unpkg/prod-deprecated/-private-TNaS5Piv.js.map +1 -0
  275. package/dist/unpkg/prod-deprecated/-private-Z9i0icpE.js +22 -0
  276. package/dist/unpkg/prod-deprecated/-private-Z9i0icpE.js.map +1 -0
  277. package/dist/unpkg/prod-deprecated/build-config/babel-macros.js +3 -1
  278. package/dist/unpkg/prod-deprecated/build-config/canary-features.js +1 -1
  279. package/dist/unpkg/prod-deprecated/build-config/debugging.js +1 -1
  280. package/dist/unpkg/prod-deprecated/build-config/deprecations.js +1 -1
  281. package/dist/unpkg/prod-deprecated/build-config/env.js +3 -1
  282. package/dist/unpkg/prod-deprecated/build-config/macros.js +3 -1
  283. package/dist/unpkg/prod-deprecated/build-config.js +3 -1
  284. package/dist/unpkg/prod-deprecated/configure.js +3 -2
  285. package/dist/unpkg/prod-deprecated/graph/-private.js +1586 -2266
  286. package/dist/unpkg/prod-deprecated/graph/-private.js.map +1 -0
  287. package/dist/unpkg/prod-deprecated/index.js +2 -482
  288. package/dist/unpkg/prod-deprecated/reactive/-private.js +3 -1
  289. package/dist/unpkg/prod-deprecated/reactive.js +5 -5
  290. package/dist/unpkg/prod-deprecated/request-BcJNzSgv.js +480 -0
  291. package/dist/unpkg/prod-deprecated/request-BcJNzSgv.js.map +1 -0
  292. package/dist/unpkg/prod-deprecated/request.js +3 -2
  293. package/dist/unpkg/prod-deprecated/signals/-leaked.js +3 -1
  294. package/dist/unpkg/prod-deprecated/src-BOifHFQ5.js +7232 -0
  295. package/dist/unpkg/prod-deprecated/src-BOifHFQ5.js.map +1 -0
  296. package/dist/unpkg/prod-deprecated/store/-private.js +3 -88
  297. package/dist/unpkg/prod-deprecated/store-BWhmb7Ob.js +359 -0
  298. package/dist/unpkg/prod-deprecated/store-BWhmb7Ob.js.map +1 -0
  299. package/dist/unpkg/prod-deprecated/store.js +1 -435
  300. package/dist/unpkg/prod-deprecated/types/-private.js +1 -47
  301. package/dist/unpkg/prod-deprecated/types/identifier.js +63 -56
  302. package/dist/unpkg/prod-deprecated/types/identifier.js.map +1 -0
  303. package/dist/unpkg/prod-deprecated/types/record.js +211 -181
  304. package/dist/unpkg/prod-deprecated/types/record.js.map +1 -0
  305. package/dist/unpkg/prod-deprecated/types/request.js +138 -69
  306. package/dist/unpkg/prod-deprecated/types/request.js.map +1 -0
  307. package/dist/unpkg/prod-deprecated/types/runtime.js +54 -26
  308. package/dist/unpkg/prod-deprecated/types/runtime.js.map +1 -0
  309. package/dist/unpkg/prod-deprecated/types/schema/fields.js +501 -495
  310. package/dist/unpkg/prod-deprecated/types/schema/fields.js.map +1 -0
  311. package/dist/unpkg/prod-deprecated/types/schema/fields.type-test.js +79 -0
  312. package/dist/unpkg/prod-deprecated/types/schema/fields.type-test.js.map +1 -0
  313. package/dist/unpkg/prod-deprecated/types/symbols.js +84 -77
  314. package/dist/unpkg/prod-deprecated/types/symbols.js.map +1 -0
  315. package/dist/unpkg/prod-deprecated/utils/string.js +70 -66
  316. package/dist/unpkg/prod-deprecated/utils/string.js.map +1 -0
  317. package/dist/utils/string.js +84 -85
  318. package/dist/utils/string.js.map +1 -0
  319. package/package.json +9 -9
  320. package/declarations/graph/-private/-diff.d.ts +0 -19
  321. package/declarations/graph/-private/-edge-definition.d.ts +0 -149
  322. package/declarations/graph/-private/-state.d.ts +0 -9
  323. package/declarations/graph/-private/-utils.d.ts +0 -25
  324. package/declarations/graph/-private/coerce-id.d.ts +0 -4
  325. package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +0 -6
  326. package/declarations/graph/-private/edges/collection.d.ts +0 -39
  327. package/declarations/graph/-private/edges/implicit.d.ts +0 -43
  328. package/declarations/graph/-private/edges/resource.d.ts +0 -23
  329. package/declarations/graph/-private/graph.d.ts +0 -56
  330. package/declarations/graph/-private/normalize-link.d.ts +0 -2
  331. package/declarations/graph/-private/operations/add-to-related-records.d.ts +0 -4
  332. package/declarations/graph/-private/operations/merge-identifier.d.ts +0 -3
  333. package/declarations/graph/-private/operations/remove-from-related-records.d.ts +0 -4
  334. package/declarations/graph/-private/operations/replace-related-record.d.ts +0 -3
  335. package/declarations/graph/-private/operations/replace-related-records.d.ts +0 -7
  336. package/declarations/graph/-private/operations/update-relationship.d.ts +0 -9
  337. package/declarations/reactive/-private/default-mode.d.ts +0 -73
  338. package/declarations/reactive/-private/document.d.ts +0 -142
  339. package/declarations/reactive/-private/fields/extension.d.ts +0 -8
  340. package/declarations/reactive/-private/fields/get-field-key.d.ts +0 -8
  341. package/declarations/reactive/-private/fields/managed-array.d.ts +0 -18
  342. package/declarations/reactive/-private/fields/managed-object.d.ts +0 -17
  343. package/declarations/reactive/-private/fields/many-array-manager.d.ts +0 -19
  344. package/declarations/reactive/-private/hooks.d.ts +0 -5
  345. package/declarations/reactive/-private/kind/alias-field.d.ts +0 -4
  346. package/declarations/reactive/-private/kind/array-field.d.ts +0 -4
  347. package/declarations/reactive/-private/kind/attribute-field.d.ts +0 -4
  348. package/declarations/reactive/-private/kind/belongs-to-field.d.ts +0 -4
  349. package/declarations/reactive/-private/kind/collection-field.d.ts +0 -4
  350. package/declarations/reactive/-private/kind/derived-field.d.ts +0 -4
  351. package/declarations/reactive/-private/kind/generic-field.d.ts +0 -4
  352. package/declarations/reactive/-private/kind/has-many-field.d.ts +0 -4
  353. package/declarations/reactive/-private/kind/hash-field.d.ts +0 -4
  354. package/declarations/reactive/-private/kind/identity-field.d.ts +0 -4
  355. package/declarations/reactive/-private/kind/local-field.d.ts +0 -4
  356. package/declarations/reactive/-private/kind/object-field.d.ts +0 -4
  357. package/declarations/reactive/-private/kind/resource-field.d.ts +0 -4
  358. package/declarations/reactive/-private/kind/schema-array-field.d.ts +0 -4
  359. package/declarations/reactive/-private/kind/schema-object-field.d.ts +0 -4
  360. package/declarations/reactive/-private/record.d.ts +0 -83
  361. package/declarations/reactive/-private/schema.d.ts +0 -326
  362. package/declarations/reactive/-private/symbols.d.ts +0 -5
  363. package/declarations/request/-private/context.d.ts +0 -39
  364. package/declarations/request/-private/debug.d.ts +0 -4
  365. package/declarations/request/-private/fetch.d.ts +0 -33
  366. package/declarations/request/-private/future.d.ts +0 -7
  367. package/declarations/request/-private/manager.d.ts +0 -158
  368. package/declarations/request/-private/promise-cache.d.ts +0 -28
  369. package/declarations/request/-private/types.d.ts +0 -234
  370. package/declarations/request/-private/utils.d.ts +0 -57
  371. package/declarations/signals/-private.d.ts +0 -6
  372. package/declarations/signals/promise-state.d.ts +0 -264
  373. package/declarations/signals/reactivity/configure.d.ts +0 -138
  374. package/declarations/signals/reactivity/internal.d.ts +0 -154
  375. package/declarations/signals/reactivity/signal.d.ts +0 -56
  376. package/declarations/signals/request-state.d.ts +0 -372
  377. package/declarations/signals/request-subscription.d.ts +0 -177
  378. package/declarations/store/-private/cache-handler/handler.d.ts +0 -56
  379. package/declarations/store/-private/cache-handler/types.d.ts +0 -84
  380. package/declarations/store/-private/cache-handler/utils.d.ts +0 -31
  381. package/declarations/store/-private/caches/instance-cache.d.ts +0 -58
  382. package/declarations/store/-private/caches/resource-utils.d.ts +0 -9
  383. package/declarations/store/-private/debug/utils.d.ts +0 -7
  384. package/declarations/store/-private/default-cache-policy.d.ts +0 -387
  385. package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +0 -34
  386. package/declarations/store/-private/managers/cache-key-manager.d.ts +0 -304
  387. package/declarations/store/-private/managers/cache-manager.d.ts +0 -367
  388. package/declarations/store/-private/managers/notification-manager.d.ts +0 -83
  389. package/declarations/store/-private/managers/record-array-manager.d.ts +0 -100
  390. package/declarations/store/-private/network/request-cache.d.ts +0 -103
  391. package/declarations/store/-private/record-arrays/-utils.d.ts +0 -80
  392. package/declarations/store/-private/record-arrays/legacy-live-array.d.ts +0 -81
  393. package/declarations/store/-private/record-arrays/legacy-many-array.d.ts +0 -133
  394. package/declarations/store/-private/record-arrays/legacy-query.d.ts +0 -81
  395. package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +0 -3
  396. package/declarations/store/-private/record-arrays/resource-array.d.ts +0 -67
  397. package/declarations/store/-private/store-service.d.ts +0 -874
  398. package/declarations/store/-private/utils/coerce-id.d.ts +0 -4
  399. package/declarations/store/-private/utils/construct-resource.d.ts +0 -6
  400. package/declarations/store/-private/utils/is-non-empty-string.d.ts +0 -1
  401. package/declarations/store/-private/utils/normalize-model-name.d.ts +0 -1
  402. package/declarations/store/-private/utils/uuid-polyfill.d.ts +0 -1
  403. package/declarations/store/-types/q/cache-capabilities-manager.d.ts +0 -90
  404. package/declarations/store/-types/q/identifier.d.ts +0 -23
  405. package/declarations/store/-types/q/record-instance.d.ts +0 -22
  406. package/declarations/store/-types/q/store.d.ts +0 -31
  407. package/declarations/store/deprecated/-private.d.ts +0 -223
  408. package/declarations/store/deprecated/store.d.ts +0 -784
  409. package/dist/configure-DPUFCemT.js +0 -1940
  410. package/dist/default-cache-policy-D7_u4YRH.js +0 -572
  411. package/dist/future-BKkJJkj7.js +0 -678
  412. package/dist/index-CQP2NSqg.js +0 -9982
  413. package/dist/symbols-3C1OkYtZ.js +0 -39
  414. package/dist/unpkg/dev/-leaked-Co0EI6Go.js +0 -1939
  415. package/dist/unpkg/dev/-private-sql1_mdx.js +0 -39
  416. package/dist/unpkg/dev/future-DFfOzSoe.js +0 -672
  417. package/dist/unpkg/dev/index-BzcBOnw9.js +0 -9392
  418. package/dist/unpkg/dev/runtime-E1M51_-O.js +0 -135
  419. package/dist/unpkg/dev-deprecated/-leaked-DjMeRqdU.js +0 -1939
  420. package/dist/unpkg/dev-deprecated/-private-3C1OkYtZ.js +0 -39
  421. package/dist/unpkg/dev-deprecated/future-DFfOzSoe.js +0 -672
  422. package/dist/unpkg/dev-deprecated/index-6TnTv-WG.js +0 -10007
  423. package/dist/unpkg/dev-deprecated/runtime-DAu5b0IR.js +0 -135
  424. package/dist/unpkg/prod/-leaked-DUONXQDB.js +0 -1676
  425. package/dist/unpkg/prod/-private-sql1_mdx.js +0 -39
  426. package/dist/unpkg/prod/handler-EU_8ncB2.js +0 -1619
  427. package/dist/unpkg/prod/promise-cache-DIT8Ypjq.js +0 -19
  428. package/dist/unpkg/prod/request-BrJSCG6r.js +0 -421
  429. package/dist/unpkg/prod/schema-BSkHyoWz.js +0 -5219
  430. package/dist/unpkg/prod-deprecated/-leaked-DRNv9VIX.js +0 -1676
  431. package/dist/unpkg/prod-deprecated/-private-3C1OkYtZ.js +0 -39
  432. package/dist/unpkg/prod-deprecated/handler-CCIu4sQ3.js +0 -334
  433. package/dist/unpkg/prod-deprecated/hooks-Dv4Np0MY.js +0 -26
  434. package/dist/unpkg/prod-deprecated/promise-cache-DIT8Ypjq.js +0 -19
  435. package/dist/unpkg/prod-deprecated/request-BrJSCG6r.js +0 -421
  436. package/dist/unpkg/prod-deprecated/schema-CJcjHv0E.js +0 -6939
@@ -0,0 +1,1494 @@
1
+ import { a as setTransient, r as peekTransient, t as getOrSetGlobal } from "./-private-BK71-uXR.js";
2
+ import { f as setPromiseResult, o as DOMError, u as getPromiseResult } from "./request-BcJNzSgv.js";
3
+
4
+ //#region src/signals/reactivity/configure.ts
5
+ const ARRAY_SIGNAL = getOrSetGlobal("#[]", Symbol("#[]"));
6
+ const OBJECT_SIGNAL = getOrSetGlobal("#{}", Symbol("#{}"));
7
+ /**
8
+ * An Opaque type that represents a framework specific or TC39 signal.
9
+ *
10
+ * It may be an array of signals or a single signal.
11
+ *
12
+ * @private
13
+ */
14
+ /**
15
+ * The hooks which MUST be configured in order to use reactive arrays,
16
+ * resources and documents with framework specfic signals or TC39 signals.
17
+ *
18
+ * Support for multiple frameworks simultaneously can be done via
19
+ * this abstraction by returning multiple signals from the `createSignal`
20
+ * method, and consuming the correct one via the correct framework via
21
+ * the `consumeSignal` and `notifySignal` methods.
22
+ *
23
+ * Unlike many signals implementations, WarpDrive does not wrap values as
24
+ * signals directly, but instead uses signals to alert the reactive layer
25
+ * to changes in the underlying cache. E.g. a signal is associated to a value,
26
+ * but does not serve as the cache for that value directly. We refer to this as
27
+ * a "gate", the pattern has also been called "side-signals".
28
+ *
29
+ * A no-op implementation is allowed, though it may lead to performance issues
30
+ * in locations that use createMemo as no memoization would be done. This is
31
+ * typically desirable only when integrating with a framework that does its own
32
+ * memoization and does not integrate with any signals-like primitive. For these
33
+ * scenarios you may also be interested in integrating with the {@link NotificationManager}
34
+ * more directly.
35
+ *
36
+ * @public
37
+ */
38
+ /**
39
+ * Contains information a {@link SignalHooks} implementation may want
40
+ * to use, such as the specialized key used for the signal
41
+ * representing an array's contents / length.
42
+ *
43
+ * ```ts
44
+ * interface HooksOptions {
45
+ * wellknown: {
46
+ * Array: symbol | string;
47
+ * }
48
+ * }
49
+ * ```
50
+ *
51
+ * @public
52
+ */
53
+ /**
54
+ * Configures the signals implementation to use. Supports multiple
55
+ * implementations simultaneously.
56
+ *
57
+ * See {@link HooksOptions} for the options passed to the provided function
58
+ * when called.
59
+ *
60
+ * See {@link SignalHooks} for the implementation the callback function should
61
+ * return.
62
+ *
63
+ * @public
64
+ * @param buildConfig - a function that takes options and returns a configuration object
65
+ */
66
+ function setupSignals(buildConfig) {
67
+ const hooks = buildConfig({ wellknown: { Array: ARRAY_SIGNAL } });
68
+ setTransient("signalHooks", hooks);
69
+ }
70
+ /**
71
+ * Internal method for consuming the configured `createSignal` hook
72
+ *
73
+ * @private
74
+ */
75
+ function createSignal(obj, key) {
76
+ return peekTransient("signalHooks").createSignal(obj, key);
77
+ }
78
+ /**
79
+ * Internal method for consuming the configured `consumeSignal` hook
80
+ *
81
+ * @private
82
+ */
83
+ function consumeSignal(signal) {
84
+ return peekTransient("signalHooks").consumeSignal(signal);
85
+ }
86
+ /**
87
+ * Internal method for consuming the configured `notifySignal` hook
88
+ *
89
+ * @private
90
+ */
91
+ function notifySignal(signal) {
92
+ return peekTransient("signalHooks").notifySignal(signal);
93
+ }
94
+ function createMemo(object, key, fn) {
95
+ return peekTransient("signalHooks").createMemo(object, key, fn);
96
+ }
97
+ function willSyncFlushWatchers() {
98
+ return peekTransient("signalHooks").willSyncFlushWatchers();
99
+ }
100
+ /**
101
+ * Wraps `promise` using the configured {@link SignalHooks.waitFor}, if any,
102
+ * for things like test-waiters. Returns `promise` unchanged if no
103
+ * `waitFor` hook is configured.
104
+ */
105
+ function waitFor(promise) {
106
+ const signalHooks = peekTransient("signalHooks");
107
+ if (signalHooks?.waitFor) return signalHooks.waitFor(promise);
108
+ return promise;
109
+ }
110
+
111
+ //#endregion
112
+ //#region src/signals/reactivity/internal.ts
113
+ const INITIALIZER_PROTO = { isInitializer: true };
114
+ /**
115
+ * Wraps `fn` so that a signal can recognize it as a lazy initializer
116
+ * for its value rather than the value itself, deferring the call to
117
+ * `fn` until the signal is first accessed.
118
+ */
119
+ function makeInitializer(fn) {
120
+ return Object.assign(Object.create(INITIALIZER_PROTO), { value: fn });
121
+ }
122
+ function isInitializer(obj) {
123
+ return typeof obj === "object" && obj !== null && Object.getPrototypeOf(obj) === INITIALIZER_PROTO;
124
+ }
125
+ /**
126
+ * A WarpDriveSignal is a wrapper around a framework specific or TC39 signal
127
+ * that enables us to store and manage the signal in a universal way.
128
+ *
129
+ * WarpDrive uses signals to manage three separate concepts:
130
+ *
131
+ * - as a `storage` for a value local to the object that we want to be reactive
132
+ * (see `@local` schema field for an example)
133
+ * - as a `gate` for a memoized getter that we want to act as a reactive property
134
+ * but whose value is computed/pulled from a non-reactive source elsewhere
135
+ * and whose latest value is stored in the signal
136
+ * (see `field` schema field for an example)
137
+ * - as a `gate` with a manually managed value updated on pull when `isStale` is true
138
+ *
139
+ *
140
+ * It offers
141
+ *
142
+ * - a non-reactive way to access/update the current value
143
+ * - a non-reactive way to mark the signal as dirtied
144
+ * - a non-reactive way to store content for why the signal was dirtied
145
+ * - access to the underlying Signal(s) in-use
146
+ *
147
+ * For debugging:
148
+ * - the "key" or "name" of the signal
149
+ * - the "object identity" or "context" to which the signal is attached
150
+ *
151
+ * @private
152
+ */
153
+ /**
154
+ * We attach signals to their context object via
155
+ * a Map attached to the object via this symbol.
156
+ *
157
+ * This allows us to store multiple signals
158
+ * on the same object with smaller memory
159
+ * overhead and no WeakMap lookups.
160
+ *
161
+ * Performance sensitive objects should
162
+ * pre-warm their shape by assigning this
163
+ * during initialization.
164
+ *
165
+ * ```ts
166
+ * initializeSignalStore(obj);
167
+ * ```
168
+ *
169
+ * @private
170
+ */
171
+ const Signals = getOrSetGlobal("Signals", Symbol("Signals"));
172
+ /**
173
+ * A type util to recast the object as having a signal store.
174
+ *
175
+ * @private
176
+ */
177
+ function upgradeWithSignals(obj) {}
178
+ /**
179
+ * A util that will create a signal store on the object
180
+ * if it does not already exist and returns the associated
181
+ * signal store.
182
+ *
183
+ * @private
184
+ */
185
+ function withSignalStore(obj) {
186
+ /* @__PURE__ */ upgradeWithSignals(obj);
187
+ if (!obj[Signals]) initializeSignalStore(obj);
188
+ return obj[Signals];
189
+ }
190
+ /**
191
+ * A util that will create a signal store on the object
192
+ * if it does not already exist.
193
+ *
194
+ * Useful for pre-warming the shape of an object to ensure
195
+ * a key-transition to add it is not required later.
196
+ *
197
+ * @private
198
+ */
199
+ function initializeSignalStore(obj) {
200
+ /* @__PURE__ */ upgradeWithSignals(obj);
201
+ obj[Signals] = /* @__PURE__ */ new Map();
202
+ }
203
+ function createInternalSignal(signals, obj, key, initialValue) {
204
+ const warpDriveSignal = {
205
+ key,
206
+ context: obj,
207
+ signal: createSignal(obj, key),
208
+ value: isInitializer(initialValue) ? initialValue.value.call(obj) : initialValue,
209
+ isStale: false
210
+ };
211
+ signals.set(key, warpDriveSignal);
212
+ return warpDriveSignal;
213
+ }
214
+ function getOrCreateInternalSignal(signals, obj, key, initialValue) {
215
+ let signal = peekInternalSignal(signals, key);
216
+ if (!signal) signal = createInternalSignal(signals, obj, key, initialValue);
217
+ return signal;
218
+ }
219
+ function createInternalMemo(signals, object, key, fn) {
220
+ {
221
+ const memo = createMemo(object, key, fn);
222
+ signals.set(key, memo);
223
+ return memo;
224
+ }
225
+ }
226
+ /**
227
+ * Looks up the {@link WarpDriveSignal} stored for `key` in `signals`,
228
+ * if one has already been created, without creating or consuming it.
229
+ */
230
+ function peekInternalSignal(signals, key) {
231
+ return signals?.get(key);
232
+ }
233
+ function consumeInternalSignal(signal) {
234
+ TrackingFrame?.signals.add(signal);
235
+ consumeSignal(signal.signal);
236
+ }
237
+ /**
238
+ * Marks `signal` as stale and notifies its underlying framework/TC39
239
+ * signal, scheduling any of its consumers for re-render/re-computation.
240
+ */
241
+ function notifyInternalSignal(signal) {
242
+ if (signal) {
243
+ signal.isStale = true;
244
+ notifySignal(signal.signal);
245
+ }
246
+ }
247
+ let TrackingFrame = null;
248
+
249
+ //#endregion
250
+ //#region src/signals/reactivity/signal.ts
251
+ /**
252
+ * Creates a signal for the key/object pairing and subscribes to the signal.
253
+ *
254
+ * Use when you need to ensure a signal exists and is subscribed to.
255
+ *
256
+ * @private
257
+ */
258
+ function entangleSignal(signals, obj, key, initialValue) {
259
+ let internalSignal = peekInternalSignal(signals, key);
260
+ if (!internalSignal) internalSignal = createInternalSignal(signals, obj, key, initialValue);
261
+ consumeInternalSignal(internalSignal);
262
+ return internalSignal;
263
+ }
264
+ function entangleInitiallyStaleSignal(signals, obj, key, initialValue) {
265
+ let internalSignal = peekInternalSignal(signals, key);
266
+ if (!internalSignal) {
267
+ internalSignal = createInternalSignal(signals, obj, key, initialValue);
268
+ internalSignal.isStale = true;
269
+ }
270
+ consumeInternalSignal(internalSignal);
271
+ return internalSignal;
272
+ }
273
+ function createSignalDescriptor(key, intialValue) {
274
+ return {
275
+ enumerable: true,
276
+ configurable: false,
277
+ get() {
278
+ const internalSignal = entangleSignal(withSignalStore(this), this, key, intialValue);
279
+ internalSignal.isStale = false;
280
+ return internalSignal.value;
281
+ },
282
+ set(value) {
283
+ const signals = withSignalStore(this);
284
+ const internalSignal = getOrCreateInternalSignal(signals, this, key, intialValue);
285
+ if (internalSignal.value !== value) {
286
+ internalSignal.value = value;
287
+ notifyInternalSignal(internalSignal);
288
+ }
289
+ }
290
+ };
291
+ }
292
+ /**
293
+ * define an enumerable signal property.
294
+ *
295
+ * Akin to Object.defineProperty.
296
+ *
297
+ * The signal will be lazily created when accessed and scoped to the
298
+ * instance of the object.
299
+ *
300
+ * @private
301
+ */
302
+ function defineSignal(obj, key, v) {
303
+ Object.defineProperty(obj, key, createSignalDescriptor(key, v));
304
+ }
305
+ /**
306
+ * Define a non-enumerable signal property.
307
+ *
308
+ * @private
309
+ */
310
+ function defineNonEnumerableSignal(obj, key, v) {
311
+ const desc = createSignalDescriptor(key, v);
312
+ desc.enumerable = false;
313
+ Object.defineProperty(obj, key, desc);
314
+ }
315
+ /**
316
+ * Decorator version of creating a signal.
317
+ */
318
+ function signal(target, key, descriptor) {
319
+ return createSignalDescriptor(key, descriptor.initializer ? makeInitializer(descriptor.initializer) : null);
320
+ }
321
+ /**
322
+ * Decorator version of creating a memoized getter
323
+ */
324
+ function memoized(target, key, descriptor) {
325
+ const getter = descriptor.get;
326
+ descriptor.get = function() {
327
+ const signals = withSignalStore(this);
328
+ let memoSignal = signals.get(key);
329
+ if (!memoSignal) memoSignal = createInternalMemo(signals, this, key, getter.bind(this));
330
+ return memoSignal();
331
+ };
332
+ return descriptor;
333
+ }
334
+ /**
335
+ * Decorator version of creating a gate.
336
+ *
337
+ * @private
338
+ */
339
+ function gate(_target, key, desc) {
340
+ const getter = desc.get;
341
+ const setter = desc.set;
342
+ const isLocal = desc.isLocal;
343
+ desc.get = function() {
344
+ const signals = withSignalStore(this);
345
+ let internalSignal = peekInternalSignal(signals, key);
346
+ if (!internalSignal) internalSignal = createInternalSignal(signals, this, key, getter.call(this));
347
+ else if (internalSignal.isStale) {
348
+ internalSignal.isStale = false;
349
+ internalSignal.value = getter.call(this);
350
+ }
351
+ consumeInternalSignal(internalSignal);
352
+ return internalSignal.value;
353
+ };
354
+ if (setter) desc.set = function(v) {
355
+ const signals = withSignalStore(this);
356
+ let internalSignal = peekInternalSignal(signals, key);
357
+ if (!internalSignal) {
358
+ internalSignal = createInternalSignal(signals, this, key, void 0);
359
+ internalSignal.isStale = true;
360
+ }
361
+ setter.call(this, v);
362
+ if (isLocal) {
363
+ internalSignal.isStale = true;
364
+ notifyInternalSignal(internalSignal);
365
+ }
366
+ };
367
+ return desc;
368
+ }
369
+ /**
370
+ * Defines a reactive "gated" property on `obj` using `desc` as its
371
+ * getter/setter descriptor.
372
+ *
373
+ * Unlike a signal defined with {@link defineSignal}, a gated property's
374
+ * consumers are not notified when the property is set, since its update
375
+ * is expected to be controlled externally (for instance, by a signal it
376
+ * derives its value from) unless the descriptor opts into being locally
377
+ * managed.
378
+ *
379
+ * Akin to `Object.defineProperty`.
380
+ *
381
+ * @private
382
+ */
383
+ function defineGate(obj, key, desc) {
384
+ const options = Object.assign({
385
+ enumerable: true,
386
+ configurable: false
387
+ }, gate(obj, key, desc));
388
+ Object.defineProperty(obj, key, options);
389
+ }
390
+
391
+ //#endregion
392
+ //#region src/signals/request-state.ts
393
+ const RequestCache = /* @__PURE__ */ new WeakMap();
394
+ function isAbortError(error) {
395
+ return error instanceof DOMError && error.name === "AbortError";
396
+ }
397
+ function upgradeLoadingState(state) {
398
+ return state;
399
+ }
400
+ async function watchStream(stream, loadingState) {
401
+ const state = upgradeLoadingState(loadingState);
402
+ const reader = stream.getReader();
403
+ let bytesLoaded = 0;
404
+ let shouldForward = state._stream !== null && state._stream.readable.locked;
405
+ let isForwarding = shouldForward;
406
+ let writer = state._stream?.writable.getWriter();
407
+ const buffer = [];
408
+ state._isPending = false;
409
+ state._isStarted = true;
410
+ state._startTime = performance.now();
411
+ while (true) {
412
+ const { value, done } = await reader.read();
413
+ if (done) break;
414
+ bytesLoaded += value.byteLength;
415
+ state._bytesLoaded = bytesLoaded;
416
+ state._lastPacketTime = performance.now();
417
+ shouldForward = shouldForward || state._stream !== null && state._stream.readable.locked;
418
+ if (shouldForward) {
419
+ if (!isForwarding) {
420
+ isForwarding = true;
421
+ writer = state._stream.writable.getWriter();
422
+ for (const item of buffer) {
423
+ await writer.ready;
424
+ await writer.write(item);
425
+ }
426
+ buffer.length = 0;
427
+ }
428
+ await writer.ready;
429
+ await writer.write(value);
430
+ } else buffer.push(value);
431
+ }
432
+ if (isForwarding) {
433
+ await writer.ready;
434
+ await writer.close();
435
+ } else if (state._stream) {
436
+ await state._stream.readable.cancel("The Stream Has Already Ended");
437
+ state._stream = null;
438
+ }
439
+ state._endTime = performance.now();
440
+ state._isComplete = true;
441
+ state._isStarted = false;
442
+ }
443
+ /**
444
+ * Lazily consumes the stream of a request, providing a number of
445
+ * reactive properties that can be used to build UIs that respond
446
+ * to the progress of a request.
447
+ *
448
+ * @hideconstructor
449
+ */
450
+ var RequestLoadingState = class {
451
+ /** @internal */
452
+ /** @internal */
453
+ /** @internal */
454
+ /** @internal */
455
+ /** @internal */
456
+ /** @internal */
457
+ /** @internal */
458
+ /** @internal */
459
+ /** @internal */
460
+ /** @internal */
461
+ /** @internal */
462
+ /** @internal */
463
+ _stream = null;
464
+ /** @internal */
465
+ _future;
466
+ /** @internal */
467
+ _triggered = false;
468
+ /** @internal */
469
+ _trigger() {
470
+ if (this._triggered) return;
471
+ this._triggered = true;
472
+ const promise = this._future.getStream();
473
+ if (promise.sizeHint) this._sizeHint = promise.sizeHint;
474
+ this.promise = promise.then((stream) => {
475
+ if (!stream) {
476
+ this._isPending = false;
477
+ this._isComplete = true;
478
+ return;
479
+ }
480
+ return watchStream(stream, this);
481
+ }, (error) => {
482
+ this._isPending = false;
483
+ this._isStarted = false;
484
+ if (isAbortError(error)) {
485
+ this._isCancelled = true;
486
+ this._isComplete = true;
487
+ }
488
+ this._isErrored = true;
489
+ this._error = error;
490
+ });
491
+ }
492
+ /**
493
+ * Resolves once the stream has finished being consumed, or rejects
494
+ * if the request errors. `null` until first accessed.
495
+ */
496
+ promise = null;
497
+ /**
498
+ * Whether the stream has not yet started being consumed.
499
+ */
500
+ get isPending() {
501
+ this._trigger();
502
+ return this._isPending;
503
+ }
504
+ /**
505
+ * The total size of the response in bytes, if known ahead of time
506
+ * (via a `Content-Length` header or similar).
507
+ */
508
+ get sizeHint() {
509
+ this._trigger();
510
+ return this._sizeHint;
511
+ }
512
+ /**
513
+ * A readable stream of the response content. Accessing this property
514
+ * begins consumption of the underlying request stream.
515
+ */
516
+ get stream() {
517
+ this._trigger();
518
+ if (!this._stream) {
519
+ if (this._isComplete || this._isCancelled || this._isErrored) return null;
520
+ this._stream = new TransformStream();
521
+ }
522
+ return this._stream.readable;
523
+ }
524
+ /**
525
+ * Whether the stream has started being consumed but has not yet completed.
526
+ */
527
+ get isStarted() {
528
+ this._trigger();
529
+ return this._isStarted;
530
+ }
531
+ /**
532
+ * The number of bytes loaded so far.
533
+ */
534
+ get bytesLoaded() {
535
+ this._trigger();
536
+ return this._bytesLoaded;
537
+ }
538
+ /**
539
+ * The `performance.now()` timestamp at which the stream started being consumed.
540
+ */
541
+ get startTime() {
542
+ this._trigger();
543
+ return this._startTime;
544
+ }
545
+ /**
546
+ * The `performance.now()` timestamp at which the stream finished being consumed.
547
+ */
548
+ get endTime() {
549
+ this._trigger();
550
+ return this._endTime;
551
+ }
552
+ /**
553
+ * The `performance.now()` timestamp at which the last chunk of data was received.
554
+ */
555
+ get lastPacketTime() {
556
+ this._trigger();
557
+ return this._lastPacketTime;
558
+ }
559
+ /**
560
+ * Whether the stream has finished being consumed.
561
+ */
562
+ get isComplete() {
563
+ this._trigger();
564
+ return this._isComplete;
565
+ }
566
+ /**
567
+ * Whether the request was aborted before the stream finished being consumed.
568
+ */
569
+ get isCancelled() {
570
+ this._trigger();
571
+ return this._isCancelled;
572
+ }
573
+ /**
574
+ * Whether an error occurred while consuming the stream.
575
+ */
576
+ get isErrored() {
577
+ this._trigger();
578
+ return this._isErrored;
579
+ }
580
+ /**
581
+ * The error that occurred while consuming the stream, if any.
582
+ */
583
+ get error() {
584
+ this._trigger();
585
+ return this._error;
586
+ }
587
+ /**
588
+ * The number of milliseconds elapsed since the stream started being
589
+ * consumed, using the last packet time (or end time, once complete)
590
+ * as the endpoint.
591
+ */
592
+ get elapsedTime() {
593
+ return (this.endTime || this.lastPacketTime) - this.startTime;
594
+ }
595
+ /**
596
+ * The ratio (0 to 1) of {@link RequestLoadingState.bytesLoaded | bytesLoaded}
597
+ * to {@link RequestLoadingState.sizeHint | sizeHint}, or `0` if no size hint is available.
598
+ */
599
+ get completedRatio() {
600
+ return this.sizeHint ? this.bytesLoaded / this.sizeHint : 0;
601
+ }
602
+ /**
603
+ * The inverse of {@link RequestLoadingState.completedRatio | completedRatio}.
604
+ */
605
+ get remainingRatio() {
606
+ return 1 - this.completedRatio;
607
+ }
608
+ /**
609
+ * The total number of milliseconds elapsed between
610
+ * {@link RequestLoadingState.startTime | startTime} and {@link RequestLoadingState.endTime | endTime}.
611
+ */
612
+ get duration() {
613
+ return this.endTime - this.startTime;
614
+ }
615
+ /**
616
+ * The average download speed in bytes per second.
617
+ */
618
+ get speed() {
619
+ return this.bytesLoaded / (this.elapsedTime / 1e3);
620
+ }
621
+ constructor(future) {
622
+ this._future = future;
623
+ }
624
+ /**
625
+ * Aborts the underlying request.
626
+ */
627
+ abort = () => {
628
+ this._future.abort();
629
+ };
630
+ };
631
+ defineNonEnumerableSignal(RequestLoadingState.prototype, "_isPending", true);
632
+ defineNonEnumerableSignal(RequestLoadingState.prototype, "_isStarted", false);
633
+ defineNonEnumerableSignal(RequestLoadingState.prototype, "_isComplete", false);
634
+ defineNonEnumerableSignal(RequestLoadingState.prototype, "_isCancelled", false);
635
+ defineNonEnumerableSignal(RequestLoadingState.prototype, "_isErrored", false);
636
+ defineNonEnumerableSignal(RequestLoadingState.prototype, "_error", null);
637
+ defineNonEnumerableSignal(RequestLoadingState.prototype, "_sizeHint", 0);
638
+ defineNonEnumerableSignal(RequestLoadingState.prototype, "_bytesLoaded", 0);
639
+ defineNonEnumerableSignal(RequestLoadingState.prototype, "_startTime", 0);
640
+ defineNonEnumerableSignal(RequestLoadingState.prototype, "_endTime", 0);
641
+ defineNonEnumerableSignal(RequestLoadingState.prototype, "_lastPacketTime", 0);
642
+ /**
643
+ * The state of a request in the "pending"
644
+ * state. This is the default initial state.
645
+ *
646
+ * Extends the {@link PendingPromise} interface.
647
+ *
648
+ */
649
+ /**
650
+ * The state of a request in the "fulfilled" state.
651
+ * This is the state of a request that has resolved
652
+ * successfully.
653
+ *
654
+ * Extends the {@link ResolvedPromise} interface.
655
+ *
656
+ */
657
+ /**
658
+ * The state of a request in the "rejected" state.
659
+ * This is the state of a request that has rejected
660
+ * with an error.
661
+ *
662
+ * Extends the {@link RejectedPromise} interface.
663
+ *
664
+ */
665
+ /**
666
+ * The state of a request in the "cancelled" state.
667
+ * This is the state of a promise that has been
668
+ * cancelled.
669
+ *
670
+ */
671
+ /**
672
+ * RequestState extends the concept of {@link PromiseState} to provide a reactive
673
+ * wrapper for a request {@link Future} which allows you write declarative code
674
+ * around a Future's control flow.
675
+ *
676
+ * It is useful in both Template and JavaScript contexts, allowing you
677
+ * to quickly derive behaviors and data from pending, error and success
678
+ * states.
679
+ *
680
+ * The key difference between a {@link Promise} and a Future is that Futures provide
681
+ * access to a {@link ReadableStream | stream} of their content, the {@link RequestKey} of the request (if any)
682
+ * as well as the ability to attempt to {@link Future.abort | abort} the request.
683
+ *
684
+ * ```ts
685
+ * interface Future<T> extends Promise<T>> {
686
+ * getStream(): Promise<ReadableStream>;
687
+ * abort(): void;
688
+ * lid: RequestKey | null;
689
+ * }
690
+ * ```
691
+ *
692
+ * These additional APIs allow us to craft even richer state experiences.
693
+ *
694
+ * To get the state of a request, use {@link getRequestState}.
695
+ *
696
+ * See also:
697
+ * - {@link PendingRequest}
698
+ * - {@link ResolvedRequest}
699
+ * - {@link RejectedRequest}
700
+ * - {@link CancelledRequest}
701
+ *
702
+ */
703
+ const RequestStateProto = {};
704
+ function performRefresh(requester, request, isReload) {
705
+ const req = Object.assign({}, request);
706
+ const cacheOptions = Object.assign({}, req.cacheOptions);
707
+ if (isReload) cacheOptions.reload = true;
708
+ else if (isReload === false) {
709
+ delete cacheOptions.reload;
710
+ cacheOptions.backgroundReload = true;
711
+ } else {
712
+ delete cacheOptions.backgroundReload;
713
+ delete cacheOptions.reload;
714
+ }
715
+ req.cacheOptions = cacheOptions;
716
+ return requester.request(req);
717
+ }
718
+ defineSignal(RequestStateProto, "reason", null);
719
+ defineSignal(RequestStateProto, "value", null);
720
+ defineSignal(RequestStateProto, "result", null);
721
+ defineSignal(RequestStateProto, "error", null);
722
+ defineSignal(RequestStateProto, "status", "pending");
723
+ defineSignal(RequestStateProto, "isPending", true);
724
+ defineSignal(RequestStateProto, "isLoading", true);
725
+ defineSignal(RequestStateProto, "isSuccess", false);
726
+ defineSignal(RequestStateProto, "isError", false);
727
+ defineSignal(RequestStateProto, "request", null);
728
+ defineSignal(RequestStateProto, "response", null);
729
+ Object.defineProperty(RequestStateProto, "isCancelled", { get() {
730
+ return this.isError && isAbortError(this.reason);
731
+ } });
732
+ Object.defineProperty(RequestStateProto, "loadingState", { get() {
733
+ if (!this._loadingState) this._loadingState = new RequestLoadingState(this._request);
734
+ return this._loadingState;
735
+ } });
736
+ function createRequestState(future) {
737
+ const state = getPromiseResult(future);
738
+ const promiseState = Object.create(RequestStateProto);
739
+ promiseState._request = future;
740
+ promiseState.reload = () => {
741
+ return performRefresh(future.requester, promiseState.request, true);
742
+ };
743
+ promiseState.refresh = (usePolicy = false) => {
744
+ return performRefresh(future.requester, promiseState.request, usePolicy === true ? null : false);
745
+ };
746
+ if (state) {
747
+ if (state.isError) {
748
+ promiseState.error = state.result;
749
+ promiseState.reason = state.result;
750
+ promiseState.status = "rejected";
751
+ promiseState.isError = true;
752
+ promiseState.isPending = false;
753
+ promiseState.isLoading = false;
754
+ promiseState.request = state.result.request;
755
+ promiseState.response = state.result.response;
756
+ } else {
757
+ promiseState.result = state.result.content;
758
+ promiseState.value = state.result.content;
759
+ promiseState.status = "fulfilled";
760
+ promiseState.isSuccess = true;
761
+ promiseState.isPending = false;
762
+ promiseState.isLoading = false;
763
+ promiseState.request = state.result.request;
764
+ promiseState.response = state.result.response;
765
+ }
766
+ } else future.then((result) => {
767
+ setPromiseResult(future, {
768
+ isError: false,
769
+ result
770
+ });
771
+ promiseState.result = result.content;
772
+ promiseState.value = result.content;
773
+ promiseState.status = "fulfilled";
774
+ promiseState.isSuccess = true;
775
+ promiseState.isPending = false;
776
+ promiseState.isLoading = false;
777
+ promiseState.request = result.request;
778
+ promiseState.response = result.response;
779
+ }, (error) => {
780
+ setPromiseResult(future, {
781
+ isError: true,
782
+ result: error
783
+ });
784
+ promiseState.error = error;
785
+ promiseState.reason = error;
786
+ promiseState.status = "rejected";
787
+ promiseState.isError = true;
788
+ promiseState.isPending = false;
789
+ promiseState.isLoading = false;
790
+ promiseState.request = error.request;
791
+ promiseState.response = error.response;
792
+ });
793
+ return promiseState;
794
+ }
795
+ /**
796
+ * `getRequestState` can be used in both JavaScript and Template contexts.
797
+ *
798
+ * ```ts
799
+ * import { getRequestState } from '@warp-drive/ember';
800
+ *
801
+ * const state = getRequestState(future);
802
+ * ```
803
+ *
804
+ * For instance, we could write a getter on a component that updates whenever
805
+ * the request state advances or the future changes, by combining the function
806
+ * with the use of `@cached`
807
+ *
808
+ * ```ts
809
+ * class Component {
810
+ * @cached
811
+ * get title() {
812
+ * const state = getRequestState(this.args.request);
813
+ * if (state.isPending) {
814
+ * return 'loading...';
815
+ * }
816
+ * if (state.isError) { return null; }
817
+ * return state.result.title;
818
+ * }
819
+ * }
820
+ * ```
821
+ *
822
+ * Or in a template as a helper:
823
+ *
824
+ * ```gjs
825
+ * import { getRequestState } from '@warp-drive/ember';
826
+ *
827
+ * <template>
828
+ * {{#let (getRequestState @request) as |state|}}
829
+ * {{#if state.isPending}}
830
+ * <Spinner />
831
+ * {{else if state.isError}}
832
+ * <ErrorForm @error={{state.error}} />
833
+ * {{else}}
834
+ * <h1>{{state.result.title}}</h1>
835
+ * {{/if}}
836
+ * {{/let}}
837
+ * </template>
838
+ * ```
839
+ *
840
+ * If looking to use in a template, consider also the `<Request />` component
841
+ * which offers a number of additional capabilities for requests *beyond* what
842
+ * `RequestState` provides.
843
+ *
844
+ */
845
+ function getRequestState(future) {
846
+ let state = RequestCache.get(future);
847
+ if (!state) {
848
+ state = createRequestState(future);
849
+ RequestCache.set(future, state);
850
+ }
851
+ return state;
852
+ }
853
+
854
+ //#endregion
855
+ //#region ../../node_modules/.pnpm/decorat_5005bbc272376d25df08203abab44e2f/node_modules/decorator-transforms/dist/runtime-BPCpkOf1.js
856
+ function decorateMethodV2(prototype, prop, decorators) {
857
+ let desc = { ...Object.getOwnPropertyDescriptor(prototype, prop) };
858
+ for (let decorator of decorators) desc = decorator(prototype, prop, desc) || desc;
859
+ if (desc.initializer !== void 0) {
860
+ desc.value = desc.initializer ? desc.initializer.call(prototype) : void 0;
861
+ desc.initializer = void 0;
862
+ }
863
+ Object.defineProperty(prototype, prop, desc);
864
+ }
865
+
866
+ //#endregion
867
+ //#region src/signals/request-subscription.ts
868
+ const DEFAULT_DEADLINE = 3e4;
869
+ /**
870
+ * A symbol used to dispose of a {@link RequestSubscription} when the
871
+ * component or context using it is torn down.
872
+ */
873
+ const DISPOSE = Symbol.dispose || Symbol.for("dispose");
874
+ /**
875
+ * The individual autorefresh strategies a {@link RequestSubscription}
876
+ * may combine, see {@link AutorefreshBehaviorCombos}.
877
+ */
878
+ /**
879
+ * The value accepted by {@link SubscriptionArgs.autorefresh}: either a
880
+ * boolean, a single {@link AutorefreshBehaviorType}, or a comma-separated
881
+ * combination of up to three of them.
882
+ */
883
+ /**
884
+ * Utilities to assist in recovering from the error.
885
+ */
886
+ /** @deprecated use {@link RecoveryFeatures} */
887
+ /**
888
+ * Utilities for keeping the request fresh
889
+ */
890
+ /**
891
+ * The args accepted by the `<Request />` component.
892
+ */
893
+ /**
894
+ * The args accepted by a {@link RequestSubscription}.
895
+ */
896
+ /**
897
+ * A reactive class
898
+ *
899
+ * @hideconstructor
900
+ */
901
+ var RequestSubscription = class {
902
+ /**
903
+ * Whether the browser reports that the network is online.
904
+ */
905
+ /**
906
+ * Whether the browser reports that the tab is hidden.
907
+ */
908
+ /**
909
+ * Whether the component is currently refreshing the request.
910
+ */
911
+ /**
912
+ * The most recent blocking request that was made, typically
913
+ * the result of a reload.
914
+ *
915
+ * This will never be the original request passed as an arg to
916
+ * the component.
917
+ *
918
+ * @internal
919
+ */
920
+ /**
921
+ * The most recent request that was made, typically due to either a
922
+ * reload or a refresh.
923
+ *
924
+ * This will never be the original request passed as an arg to
925
+ * the component.
926
+ *
927
+ * @internal
928
+ */
929
+ /**
930
+ * The time at which the network was reported as offline.
931
+ *
932
+ * @internal
933
+ */
934
+ /** @internal */
935
+ /** @internal */
936
+ /** @internal */
937
+ /** @internal */
938
+ /** @internal */
939
+ /**
940
+ * The event listener for network status changes,
941
+ * cached to use the reference for removal.
942
+ *
943
+ * @internal
944
+ */
945
+ /**
946
+ * The event listener for visibility status changes,
947
+ * cached to use the reference for removal.
948
+ *
949
+ * @internal
950
+ */
951
+ /**
952
+ * The last request passed as an arg to the component,
953
+ * cached for comparison.
954
+ *
955
+ * @internal
956
+ */
957
+ /**
958
+ * The last query passed as an arg to the component,
959
+ * cached for comparison.
960
+ *
961
+ * @internal
962
+ */
963
+ /** @internal */
964
+ /** @internal */
965
+ /** @internal */
966
+ /**
967
+ * The Store this subscription subscribes to or the RequestManager
968
+ * which issues this request.
969
+ */
970
+ /**
971
+ * The Store or RequestManager that the last subscription is attached to.
972
+ *
973
+ * This differs from 'store' because a <Request /> may be passed a
974
+ * request originating from a different store than the <Request />
975
+ * component would use if it were to issue the request itself.
976
+ *
977
+ * @internal
978
+ */
979
+ _requester;
980
+ constructor(store, args) {
981
+ this._args = args;
982
+ this.store = store;
983
+ this._subscribedTo = null;
984
+ this._subscription = null;
985
+ this._intervalStart = null;
986
+ this._invalidated = false;
987
+ this._nextInterval = null;
988
+ this._requester = null;
989
+ this.isDestroyed = false;
990
+ this[DISPOSE] = _DISPOSE;
991
+ this._installListeners();
992
+ this._beginPolling();
993
+ }
994
+ /**
995
+ * @internal
996
+ */
997
+ async _beginPolling() {
998
+ try {
999
+ if (!this.isIdle) await this.request;
1000
+ } catch {} finally {
1001
+ if (!this.isDestroyed) this._scheduleInterval();
1002
+ }
1003
+ }
1004
+ /**
1005
+ * Whether neither a `request` nor a `query` arg was provided, and so
1006
+ * this subscription has nothing to fetch or monitor.
1007
+ */
1008
+ get isIdle() {
1009
+ const { request, query } = this._args;
1010
+ return Boolean(!request && !query);
1011
+ }
1012
+ /**
1013
+ * The set of {@link AutorefreshBehaviorType}s this subscription is
1014
+ * configured to autorefresh for, derived from {@link SubscriptionArgs.autorefresh}.
1015
+ */
1016
+ static {
1017
+ decorateMethodV2(this.prototype, "isIdle", [memoized]);
1018
+ }
1019
+ get autorefreshTypes() {
1020
+ const { autorefresh } = this._args;
1021
+ let types;
1022
+ if (autorefresh === true) types = ["online", "invalid"];
1023
+ else if (typeof autorefresh === "string") types = autorefresh.split(",");
1024
+ else types = [];
1025
+ return new Set(types);
1026
+ }
1027
+ /** @internal */
1028
+ static {
1029
+ decorateMethodV2(this.prototype, "autorefreshTypes", [memoized]);
1030
+ }
1031
+ async _scheduleInterval() {
1032
+ const { autorefreshThreshold } = this._args;
1033
+ if (typeof window === "undefined" || !(typeof autorefreshThreshold === "number" && autorefreshThreshold > 0) || !this.autorefreshTypes.has("interval") || this._intervalStart !== null) return;
1034
+ if (this._latestRequest) {
1035
+ try {
1036
+ await this._latestRequest;
1037
+ } catch {}
1038
+ if (this.isDestroyed) return;
1039
+ }
1040
+ this._intervalStart = Date.now();
1041
+ this._nextInterval = setTimeout(() => {
1042
+ this._maybeUpdate();
1043
+ }, autorefreshThreshold);
1044
+ }
1045
+ /** @internal */
1046
+ _clearInterval() {
1047
+ if (this._nextInterval) {
1048
+ clearTimeout(this._nextInterval);
1049
+ this._intervalStart = null;
1050
+ }
1051
+ }
1052
+ /**
1053
+ * @internal
1054
+ */
1055
+ _updateSubscriptions() {
1056
+ if (this.isIdle) return;
1057
+ const requestId = this._request.lid;
1058
+ if (this._subscribedTo === requestId) return;
1059
+ this._removeSubscriptions();
1060
+ const store = this._getRequester();
1061
+ this._requester = store;
1062
+ if (requestId && isStore(store)) {
1063
+ this._subscribedTo = requestId;
1064
+ this._subscription = store.notifications.subscribe(requestId, (_id, op) => {
1065
+ if (this._isUpdating) return;
1066
+ switch (op) {
1067
+ case "invalidated":
1068
+ if (this.autorefreshTypes.has("invalid")) {
1069
+ this._invalidated = true;
1070
+ this._maybeUpdate();
1071
+ }
1072
+ break;
1073
+ case "state": {
1074
+ const priority = store.requestManager._deduped.get(requestId)?.priority;
1075
+ const state = this.reqState;
1076
+ if (!priority) this.isRefreshing = false;
1077
+ else if (priority.blocking && !state.isLoading) {
1078
+ this.isRefreshing = false;
1079
+ this._maybeUpdate("policy", true);
1080
+ } else this.isRefreshing = true;
1081
+ }
1082
+ }
1083
+ });
1084
+ }
1085
+ }
1086
+ /**
1087
+ * @internal
1088
+ */
1089
+ _removeSubscriptions() {
1090
+ const store = this._requester;
1091
+ if (this._subscription && store && isStore(store)) {
1092
+ store.notifications.unsubscribe(this._subscription);
1093
+ this._subscribedTo = null;
1094
+ this._subscription = null;
1095
+ this._requester = null;
1096
+ }
1097
+ }
1098
+ /**
1099
+ * Install the event listeners for network and visibility changes.
1100
+ *
1101
+ * This is only done in environments that provide a fully-featured global
1102
+ * `window` and/or `document`. Some non-DOM environments (e.g. React Native,
1103
+ * SSR/Node, workers) may provide a `window` global without the APIs we
1104
+ * rely on here (or no `window`/`document` at all), in which case we skip
1105
+ * attaching the corresponding listeners rather than throwing.
1106
+ *
1107
+ * @internal
1108
+ */
1109
+ _installListeners() {
1110
+ const hasWindow = typeof window !== "undefined";
1111
+ const hasDocument = typeof document !== "undefined";
1112
+ const hasWindowEvents = hasWindow && typeof window.addEventListener === "function";
1113
+ const hasDocumentEvents = hasDocument && typeof document.addEventListener === "function";
1114
+ this.isOnline = hasWindow && typeof window.navigator?.onLine === "boolean" ? window.navigator.onLine : true;
1115
+ this._unavailableStart = this.isOnline ? null : Date.now();
1116
+ this.isHidden = hasDocument && typeof document.visibilityState === "string" && document.visibilityState === "hidden";
1117
+ if (hasWindowEvents) {
1118
+ this._onlineChanged = (event) => {
1119
+ this.isOnline = event.type === "online";
1120
+ if (event.type === "offline" && this._unavailableStart === null) this._unavailableStart = Date.now();
1121
+ this._maybeUpdate();
1122
+ };
1123
+ window.addEventListener("online", this._onlineChanged, {
1124
+ passive: true,
1125
+ capture: true
1126
+ });
1127
+ window.addEventListener("offline", this._onlineChanged, {
1128
+ passive: true,
1129
+ capture: true
1130
+ });
1131
+ }
1132
+ if (hasDocumentEvents) {
1133
+ this._backgroundChanged = () => {
1134
+ const isHidden = document.visibilityState === "hidden";
1135
+ this.isHidden = isHidden;
1136
+ if (isHidden && this._unavailableStart === null) this._unavailableStart = Date.now();
1137
+ this._maybeUpdate();
1138
+ };
1139
+ document.addEventListener("visibilitychange", this._backgroundChanged, {
1140
+ passive: true,
1141
+ capture: true
1142
+ });
1143
+ }
1144
+ }
1145
+ /**
1146
+ * If the network is online and the tab is visible, either reload or refresh the request
1147
+ * based on the component's configuration and the requested update mode.
1148
+ *
1149
+ * Valid modes are:
1150
+ *
1151
+ * - `'reload'`: Force a reload of the request.
1152
+ * - `'refresh'`: Refresh the request in the background.
1153
+ * - `'policy'`: Make the request, letting the store's configured CachePolicy decide whether to reload, refresh, or do nothing.
1154
+ * - `undefined`: Make the request using the component's autorefreshBehavior setting if the autorefreshThreshold has passed.
1155
+ *
1156
+ * @internal
1157
+ */
1158
+ _maybeUpdate(mode, silent) {
1159
+ if (this.isIdle) return;
1160
+ const { reqState } = this;
1161
+ if (reqState.isPending) return;
1162
+ if (!Boolean(this.isOnline && !this.isHidden && (mode || this.autorefreshTypes.size))) {
1163
+ if (!silent && mode && mode !== "_invalidated") throw new Error(`Reload not available: the network is not online or the tab is hidden`);
1164
+ return;
1165
+ }
1166
+ const { autorefreshTypes } = this;
1167
+ let shouldAttempt = this._invalidated || Boolean(mode);
1168
+ if (!shouldAttempt && autorefreshTypes.has("online")) {
1169
+ const { _unavailableStart } = this;
1170
+ const { autorefreshThreshold } = this._args;
1171
+ const deadline = typeof autorefreshThreshold === "number" ? autorefreshThreshold : DEFAULT_DEADLINE;
1172
+ shouldAttempt = Boolean(_unavailableStart && Date.now() - _unavailableStart > deadline);
1173
+ }
1174
+ if (!shouldAttempt && autorefreshTypes.has("interval")) {
1175
+ const { _intervalStart } = this;
1176
+ const { autorefreshThreshold } = this._args;
1177
+ if (_intervalStart && typeof autorefreshThreshold === "number" && autorefreshThreshold > 0) shouldAttempt = Boolean(Date.now() - _intervalStart >= autorefreshThreshold);
1178
+ }
1179
+ this._unavailableStart = null;
1180
+ this._invalidated = false;
1181
+ if (shouldAttempt) {
1182
+ this._clearInterval();
1183
+ this._isUpdating = true;
1184
+ const val = (mode === "_invalidated" ? null : mode) ?? this._args.autorefreshBehavior ?? "policy";
1185
+ const requester = this._getRequester();
1186
+ if (!reqState._request.requester) reqState._request.requester = requester;
1187
+ switch (val) {
1188
+ case "reload":
1189
+ this._latestRequest = reqState.reload();
1190
+ break;
1191
+ case "refresh":
1192
+ this._latestRequest = reqState.refresh();
1193
+ break;
1194
+ case "policy": this._latestRequest = reqState.refresh(true);
1195
+ }
1196
+ if (val !== "refresh") this._localRequest = this._latestRequest;
1197
+ this._scheduleInterval();
1198
+ this._latestRequest.finally(() => {
1199
+ this._isUpdating = false;
1200
+ });
1201
+ }
1202
+ }
1203
+ /**
1204
+ * @internal
1205
+ */
1206
+ _getRequester() {
1207
+ if (this._args.request?.requester) return this._args.request.requester;
1208
+ return this.store;
1209
+ }
1210
+ /**
1211
+ * Retry the request, reloading it from the server.
1212
+ */
1213
+ retry = async () => {
1214
+ this._maybeUpdate("reload");
1215
+ await this._localRequest;
1216
+ };
1217
+ /**
1218
+ * Refresh the request, updating it in the background.
1219
+ */
1220
+ refresh = async () => {
1221
+ this._maybeUpdate("refresh");
1222
+ await this._latestRequest;
1223
+ };
1224
+ /**
1225
+ * features to yield to the error slot of a component
1226
+ */
1227
+ get errorFeatures() {
1228
+ return {
1229
+ isHidden: this.isHidden,
1230
+ isOnline: this.isOnline,
1231
+ retry: this.retry
1232
+ };
1233
+ }
1234
+ /**
1235
+ * features to yield to the content slot of a component
1236
+ */
1237
+ static {
1238
+ decorateMethodV2(this.prototype, "errorFeatures", [memoized]);
1239
+ }
1240
+ get contentFeatures() {
1241
+ const feat = {
1242
+ isHidden: this.isHidden,
1243
+ isOnline: this.isOnline,
1244
+ reload: this.retry,
1245
+ refresh: this.refresh,
1246
+ isRefreshing: this.isRefreshing,
1247
+ latestRequest: this._latestRequest
1248
+ };
1249
+ if (feat.isRefreshing) feat.abort = () => {
1250
+ this._latestRequest?.abort();
1251
+ };
1252
+ return feat;
1253
+ }
1254
+ /**
1255
+ * @internal
1256
+ */
1257
+ static {
1258
+ decorateMethodV2(this.prototype, "contentFeatures", [memoized]);
1259
+ }
1260
+ get _request() {
1261
+ const { request, query } = this._args;
1262
+ const { _localRequest, _originalRequest, _originalQuery } = this;
1263
+ if (_localRequest && request === _originalRequest && query === _originalQuery) return _localRequest;
1264
+ this._originalQuery = query;
1265
+ this._originalRequest = request;
1266
+ if (request) return request;
1267
+ return this.store.request(query);
1268
+ }
1269
+ /**
1270
+ * The {@link Future} this subscription is currently monitoring, and
1271
+ * (re-)subscribes to notifications for as a side effect of access.
1272
+ */
1273
+ static {
1274
+ decorateMethodV2(this.prototype, "_request", [memoized]);
1275
+ }
1276
+ get request() {
1277
+ {
1278
+ const request = this._request;
1279
+ this._updateSubscriptions();
1280
+ return request;
1281
+ }
1282
+ }
1283
+ /**
1284
+ * The {@link RequestState} for {@link RequestSubscription.request | request}.
1285
+ */
1286
+ static {
1287
+ decorateMethodV2(this.prototype, "request", [memoized]);
1288
+ }
1289
+ get reqState() {
1290
+ return getRequestState(this.request);
1291
+ }
1292
+ /**
1293
+ * The resolved content of the request, once it has succeeded.
1294
+ */
1295
+ get result() {
1296
+ return this.reqState.result;
1297
+ }
1298
+ };
1299
+ defineSignal(RequestSubscription.prototype, "isOnline", true);
1300
+ defineSignal(RequestSubscription.prototype, "isHidden", false);
1301
+ defineSignal(RequestSubscription.prototype, "isRefreshing", false);
1302
+ defineSignal(RequestSubscription.prototype, "_localRequest", void 0);
1303
+ defineSignal(RequestSubscription.prototype, "_latestRequest", void 0);
1304
+ function isStore(store) {
1305
+ return "requestManager" in store;
1306
+ }
1307
+ /**
1308
+ * Creates a {@link RequestSubscription}, the reactive class powering the
1309
+ * `<Request />` component's autorefresh, retry, and refresh behaviors.
1310
+ */
1311
+ function createRequestSubscription(store, args) {
1312
+ return new RequestSubscription(store, args);
1313
+ }
1314
+ function upgradeSubscription(sub) {
1315
+ return sub;
1316
+ }
1317
+ function _DISPOSE() {
1318
+ const self = upgradeSubscription(this);
1319
+ self.isDestroyed = true;
1320
+ self._removeSubscriptions();
1321
+ self._clearInterval();
1322
+ if (self._onlineChanged && typeof window !== "undefined" && typeof window.removeEventListener === "function") {
1323
+ window.removeEventListener("online", self._onlineChanged, {
1324
+ passive: true,
1325
+ capture: true
1326
+ });
1327
+ window.removeEventListener("offline", self._onlineChanged, {
1328
+ passive: true,
1329
+ capture: true
1330
+ });
1331
+ }
1332
+ if (self._backgroundChanged && typeof document !== "undefined" && typeof document.removeEventListener === "function") document.removeEventListener("visibilitychange", self._backgroundChanged, {
1333
+ passive: true,
1334
+ capture: true
1335
+ });
1336
+ }
1337
+
1338
+ //#endregion
1339
+ //#region src/signals/promise-state.ts
1340
+ const PromiseCache = /* @__PURE__ */ new WeakMap();
1341
+ /**
1342
+ * The state of a promise in the "pending"
1343
+ * state. This is the default initial state.
1344
+ *
1345
+ */
1346
+ /**
1347
+ * The state of a promise in the "fulfilled" state.
1348
+ * This is the state of a promise that has resolved
1349
+ * successfully.
1350
+ *
1351
+ */
1352
+ /**
1353
+ * The state of a promise in the "rejected" state.
1354
+ * This is the state of a promise that has rejected
1355
+ * with an error.
1356
+ *
1357
+ */
1358
+ /**
1359
+ * The state of a promise. This is the type that is returned
1360
+ * from `getPromiseState`.
1361
+ *
1362
+ * See also:
1363
+ * - {@link PendingPromise}
1364
+ * - {@link ResolvedPromise}
1365
+ * - {@link RejectedPromise}
1366
+ *
1367
+ */
1368
+ const PromiseStateProto = {};
1369
+ defineSignal(PromiseStateProto, "reason", null);
1370
+ defineSignal(PromiseStateProto, "value", null);
1371
+ defineSignal(PromiseStateProto, "result", null);
1372
+ defineSignal(PromiseStateProto, "error", null);
1373
+ defineSignal(PromiseStateProto, "status", "pending");
1374
+ defineSignal(PromiseStateProto, "isPending", true);
1375
+ defineSignal(PromiseStateProto, "isLoading", true);
1376
+ defineSignal(PromiseStateProto, "isSuccess", false);
1377
+ defineSignal(PromiseStateProto, "isError", false);
1378
+ function createPromiseState(promise) {
1379
+ const state = getPromiseResult(promise);
1380
+ const promiseState = Object.create(PromiseStateProto);
1381
+ if (state) {
1382
+ if (state.isError) {
1383
+ promiseState.error = state.result;
1384
+ promiseState.reason = state.result;
1385
+ promiseState.status = "rejected";
1386
+ promiseState.isError = true;
1387
+ promiseState.isPending = false;
1388
+ promiseState.isLoading = false;
1389
+ } else {
1390
+ promiseState.result = state.result;
1391
+ promiseState.value = state.result;
1392
+ promiseState.status = "fulfilled";
1393
+ promiseState.isSuccess = true;
1394
+ promiseState.isPending = false;
1395
+ promiseState.isLoading = false;
1396
+ }
1397
+ } else promise.then((result) => {
1398
+ setPromiseResult(promise, {
1399
+ isError: false,
1400
+ result
1401
+ });
1402
+ promiseState.result = result;
1403
+ promiseState.value = result;
1404
+ promiseState.status = "fulfilled";
1405
+ promiseState.isSuccess = true;
1406
+ promiseState.isPending = false;
1407
+ promiseState.isLoading = false;
1408
+ }, (error) => {
1409
+ setPromiseResult(promise, {
1410
+ isError: true,
1411
+ result: error
1412
+ });
1413
+ promiseState.error = error;
1414
+ promiseState.reason = error;
1415
+ promiseState.status = "rejected";
1416
+ promiseState.isError = true;
1417
+ promiseState.isPending = false;
1418
+ promiseState.isLoading = false;
1419
+ });
1420
+ return promiseState;
1421
+ }
1422
+ const LegacyPromiseProxy = Symbol.for("LegacyPromiseProxy");
1423
+ function isLegacyAwaitable(promise) {
1424
+ return LegacyPromiseProxy in promise && "promise" in promise && promise[LegacyPromiseProxy] === true;
1425
+ }
1426
+ function getPromise(promise) {
1427
+ return isLegacyAwaitable(promise) ? promise.promise : promise;
1428
+ }
1429
+ /**
1430
+ * Returns a reactive state-machine for the provided promise or awaitable.
1431
+ *
1432
+ * Repeat calls to `getPromiseState` with the same promise will return the same state object
1433
+ * making is safe and easy to use in templates and JavaScript code to produce reactive
1434
+ * behaviors around promises.
1435
+ *
1436
+ * `getPromiseState` can be used in both JavaScript and Template contexts.
1437
+ *
1438
+ * ```ts
1439
+ * import { getPromiseState } from '@warp-drive/ember';
1440
+ *
1441
+ * const state = getPromiseState(promise);
1442
+ * ```
1443
+ *
1444
+ * For instance, we could write a getter on a component that updates whenever
1445
+ * the promise state advances or the promise changes, by combining the function
1446
+ * with the use of `@cached`
1447
+ *
1448
+ * ```ts
1449
+ * class Component {
1450
+ * @cached
1451
+ * get title() {
1452
+ * const state = getPromiseState(this.args.request);
1453
+ * if (state.isPending) {
1454
+ * return 'loading...';
1455
+ * }
1456
+ * if (state.isError) { return null; }
1457
+ * return state.result.title;
1458
+ * }
1459
+ * }
1460
+ * ```
1461
+ *
1462
+ * Or in a template as a helper:
1463
+ *
1464
+ * ```gjs
1465
+ * import { getPromiseState } from '@warp-drive/ember';
1466
+ *
1467
+ * <template>
1468
+ * {{#let (getPromiseState @request) as |state|}}
1469
+ * {{#if state.isPending}} <Spinner />
1470
+ * {{else if state.isError}} <ErrorForm @error={{state.error}} />
1471
+ * {{else}}
1472
+ * <h1>{{state.result.title}}</h1>
1473
+ * {{/if}}
1474
+ * {{/let}}
1475
+ * </template>
1476
+ * ```
1477
+ *
1478
+ * If looking to use in a template, consider also the `<Await />` component.
1479
+ *
1480
+ * See also {@link PromiseState}
1481
+ */
1482
+ function getPromiseState(promise) {
1483
+ const _promise = getPromise(promise);
1484
+ let state = PromiseCache.get(_promise);
1485
+ if (!state) {
1486
+ state = createPromiseState(_promise);
1487
+ PromiseCache.set(_promise, state);
1488
+ }
1489
+ return state;
1490
+ }
1491
+
1492
+ //#endregion
1493
+ export { ARRAY_SIGNAL as C, willSyncFlushWatchers as D, waitFor as E, withSignalStore as S, setupSignals as T, createInternalSignal as _, createSignalDescriptor as a, notifyInternalSignal as b, defineSignal as c, gate as d, memoized as f, createInternalMemo as g, consumeInternalSignal as h, getRequestState as i, entangleInitiallyStaleSignal as l, Signals as m, DISPOSE as n, defineGate as o, signal as p, createRequestSubscription as r, defineNonEnumerableSignal as s, getPromiseState as t, entangleSignal as u, getOrCreateInternalSignal as v, OBJECT_SIGNAL as w, peekInternalSignal as x, makeInitializer as y };
1494
+ //# sourceMappingURL=-private-TNaS5Piv.js.map