@warp-drive-mirror/core 5.9.0-alpha.2 → 5.9.0-alpha.21

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