@tstdl/base 0.93.182 → 0.93.183

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 (353) hide show
  1. package/api/server/api-request-token.provider.js +1 -1
  2. package/api/server/gateway.js +6 -1
  3. package/authentication/authentication.api.d.ts +13 -40
  4. package/authentication/authentication.api.js +5 -14
  5. package/authentication/client/authentication.service.d.ts +6 -14
  6. package/authentication/client/authentication.service.js +22 -4
  7. package/authentication/client/module.d.ts +1 -1
  8. package/authentication/client/module.js +4 -4
  9. package/authentication/models/index.d.ts +1 -0
  10. package/authentication/models/index.js +1 -0
  11. package/authentication/models/totp-results.model.d.ts +11 -0
  12. package/authentication/models/totp-results.model.js +37 -0
  13. package/authentication/server/authentication.api-controller.d.ts +3 -3
  14. package/authentication/server/authentication.api-controller.js +31 -4
  15. package/authentication/server/authentication.service.d.ts +5 -14
  16. package/authentication/server/authentication.service.js +6 -4
  17. package/core.d.ts +0 -5
  18. package/core.js +0 -8
  19. package/document-management/api/document-management.api.d.ts +2 -2
  20. package/document-management/service-models/document.service-model.d.ts +1 -1
  21. package/examples/config.d.ts +25 -0
  22. package/examples/config.js +26 -0
  23. package/notification/server/module.d.ts +1 -1
  24. package/notification/server/module.js +1 -1
  25. package/package.json +5 -5
  26. package/signals/api.d.ts +5 -1
  27. package/signals/api.js +3 -1
  28. package/signals/implementation/api.d.ts +13 -5
  29. package/signals/implementation/api.js +7 -1
  30. package/signals/implementation/asserts.d.ts +2 -2
  31. package/signals/implementation/asserts.js +3 -3
  32. package/signals/implementation/computed.d.ts +7 -34
  33. package/signals/implementation/computed.js +14 -83
  34. package/signals/implementation/configure.js +6 -2
  35. package/signals/implementation/effect.d.ts +65 -46
  36. package/signals/implementation/effect.js +97 -62
  37. package/signals/implementation/index.d.ts +2 -4
  38. package/signals/implementation/index.js +2 -4
  39. package/signals/implementation/linked_signal.d.ts +36 -0
  40. package/signals/implementation/linked_signal.js +34 -0
  41. package/signals/implementation/primitive/computed.d.ts +55 -0
  42. package/signals/implementation/primitive/computed.js +107 -0
  43. package/signals/implementation/primitive/effect.d.ts +26 -0
  44. package/signals/implementation/primitive/effect.js +31 -0
  45. package/signals/implementation/{equality.d.ts → primitive/equality.d.ts} +1 -1
  46. package/signals/implementation/{equality.js → primitive/equality.js} +1 -1
  47. package/signals/implementation/primitive/errors.d.ts +10 -0
  48. package/signals/implementation/{errors.js → primitive/errors.js} +3 -4
  49. package/signals/implementation/primitive/formatter.d.ts +19 -0
  50. package/signals/implementation/primitive/formatter.js +136 -0
  51. package/signals/implementation/{graph.d.ts → primitive/graph.d.ts} +68 -36
  52. package/signals/implementation/primitive/graph.js +386 -0
  53. package/signals/implementation/primitive/linked_signal.d.ts +46 -0
  54. package/signals/implementation/primitive/linked_signal.js +110 -0
  55. package/signals/implementation/primitive/signal.d.ts +31 -0
  56. package/signals/implementation/primitive/signal.js +80 -0
  57. package/signals/implementation/primitive/untracked.d.ts +12 -0
  58. package/signals/implementation/primitive/untracked.js +23 -0
  59. package/signals/implementation/{watch.d.ts → primitive/watch.d.ts} +1 -2
  60. package/signals/implementation/{watch.js → primitive/watch.js} +22 -16
  61. package/signals/implementation/resource/api.d.ts +275 -0
  62. package/signals/implementation/resource/api.js +26 -0
  63. package/signals/implementation/resource/debounce.d.ts +13 -0
  64. package/signals/implementation/resource/debounce.js +113 -0
  65. package/signals/implementation/resource/from_snapshots.d.ts +16 -0
  66. package/signals/implementation/resource/from_snapshots.js +44 -0
  67. package/signals/implementation/resource/index.d.ts +11 -0
  68. package/signals/implementation/resource/index.js +11 -0
  69. package/signals/implementation/resource/resource.d.ts +110 -0
  70. package/signals/implementation/resource/resource.js +402 -0
  71. package/signals/implementation/root_effect_scheduler.d.ts +50 -0
  72. package/signals/implementation/root_effect_scheduler.js +66 -0
  73. package/signals/implementation/signal.d.ts +42 -18
  74. package/signals/implementation/signal.js +29 -49
  75. package/signals/implementation/to-observable.d.ts +12 -5
  76. package/signals/implementation/to-observable.js +12 -2
  77. package/signals/implementation/to-signal.d.ts +9 -18
  78. package/signals/implementation/to-signal.js +46 -13
  79. package/signals/implementation/untracked.d.ts +1 -1
  80. package/signals/implementation/untracked.js +3 -11
  81. package/signals/operators/debounce.d.ts +8 -0
  82. package/signals/operators/debounce.js +19 -0
  83. package/signals/operators/derive-async.js +43 -15
  84. package/signals/operators/index.d.ts +2 -0
  85. package/signals/operators/index.js +2 -0
  86. package/signals/operators/throttle.d.ts +8 -0
  87. package/signals/operators/throttle.js +31 -0
  88. package/ai/genkit/tests/multi-region.test.d.ts +0 -2
  89. package/ai/genkit/tests/multi-region.test.js +0 -179
  90. package/ai/genkit/tests/token-limit-fallback.test.d.ts +0 -2
  91. package/ai/genkit/tests/token-limit-fallback.test.js +0 -209
  92. package/ai/prompts/tests/prompt-builder.test.d.ts +0 -1
  93. package/ai/prompts/tests/prompt-builder.test.js +0 -22
  94. package/ai/tests/instructions-formatter.test.d.ts +0 -1
  95. package/ai/tests/instructions-formatter.test.js +0 -116
  96. package/ai/tests/steering.test.d.ts +0 -1
  97. package/ai/tests/steering.test.js +0 -37
  98. package/api/client/tests/api-client.test.d.ts +0 -1
  99. package/api/client/tests/api-client.test.js +0 -194
  100. package/api/server/tests/csrf.middleware.test.d.ts +0 -1
  101. package/api/server/tests/csrf.middleware.test.js +0 -91
  102. package/authentication/tests/authentication-password-requirements.validator.test.d.ts +0 -1
  103. package/authentication/tests/authentication-password-requirements.validator.test.js +0 -29
  104. package/authentication/tests/authentication.api-controller.test.d.ts +0 -1
  105. package/authentication/tests/authentication.api-controller.test.js +0 -156
  106. package/authentication/tests/authentication.api-request-token.provider.test.d.ts +0 -1
  107. package/authentication/tests/authentication.api-request-token.provider.test.js +0 -48
  108. package/authentication/tests/authentication.client-error-handling.test.d.ts +0 -1
  109. package/authentication/tests/authentication.client-error-handling.test.js +0 -123
  110. package/authentication/tests/authentication.client-middleware.test.d.ts +0 -1
  111. package/authentication/tests/authentication.client-middleware.test.js +0 -118
  112. package/authentication/tests/authentication.client-service-methods.test.d.ts +0 -1
  113. package/authentication/tests/authentication.client-service-methods.test.js +0 -177
  114. package/authentication/tests/authentication.client-service-refresh.test.d.ts +0 -1
  115. package/authentication/tests/authentication.client-service-refresh.test.js +0 -153
  116. package/authentication/tests/authentication.client-service.test.d.ts +0 -1
  117. package/authentication/tests/authentication.client-service.test.js +0 -76
  118. package/authentication/tests/authentication.refresh-busy-loop.test.d.ts +0 -1
  119. package/authentication/tests/authentication.refresh-busy-loop.test.js +0 -84
  120. package/authentication/tests/authentication.service.test.d.ts +0 -1
  121. package/authentication/tests/authentication.service.test.js +0 -167
  122. package/authentication/tests/authentication.test-ancillary-service.d.ts +0 -9
  123. package/authentication/tests/authentication.test-ancillary-service.js +0 -27
  124. package/authentication/tests/brute-force-protection.test.d.ts +0 -1
  125. package/authentication/tests/brute-force-protection.test.js +0 -211
  126. package/authentication/tests/helper.test.d.ts +0 -1
  127. package/authentication/tests/helper.test.js +0 -122
  128. package/authentication/tests/password-requirements.error.test.d.ts +0 -1
  129. package/authentication/tests/password-requirements.error.test.js +0 -14
  130. package/authentication/tests/remember.api.test.d.ts +0 -1
  131. package/authentication/tests/remember.api.test.js +0 -117
  132. package/authentication/tests/remember.service.test.d.ts +0 -1
  133. package/authentication/tests/remember.service.test.js +0 -83
  134. package/authentication/tests/subject.service.test.d.ts +0 -1
  135. package/authentication/tests/subject.service.test.js +0 -140
  136. package/authentication/tests/suspended-subject.test.d.ts +0 -1
  137. package/authentication/tests/suspended-subject.test.js +0 -120
  138. package/authentication/tests/totp.enrollment.test.d.ts +0 -1
  139. package/authentication/tests/totp.enrollment.test.js +0 -123
  140. package/authentication/tests/totp.login.test.d.ts +0 -1
  141. package/authentication/tests/totp.login.test.js +0 -213
  142. package/authentication/tests/totp.recovery-codes.test.d.ts +0 -1
  143. package/authentication/tests/totp.recovery-codes.test.js +0 -97
  144. package/authentication/tests/totp.status.test.d.ts +0 -1
  145. package/authentication/tests/totp.status.test.js +0 -72
  146. package/cancellation/tests/coverage.test.d.ts +0 -1
  147. package/cancellation/tests/coverage.test.js +0 -49
  148. package/cancellation/tests/leak.test.d.ts +0 -1
  149. package/cancellation/tests/leak.test.js +0 -35
  150. package/cancellation/tests/token.test.d.ts +0 -1
  151. package/cancellation/tests/token.test.js +0 -136
  152. package/circuit-breaker/tests/circuit-breaker.test.d.ts +0 -1
  153. package/circuit-breaker/tests/circuit-breaker.test.js +0 -116
  154. package/cryptography/tests/cryptography.test.d.ts +0 -1
  155. package/cryptography/tests/cryptography.test.js +0 -175
  156. package/cryptography/tests/jwt.test.d.ts +0 -1
  157. package/cryptography/tests/jwt.test.js +0 -54
  158. package/cryptography/tests/modern.test.d.ts +0 -1
  159. package/cryptography/tests/modern.test.js +0 -105
  160. package/cryptography/tests/module.test.d.ts +0 -1
  161. package/cryptography/tests/module.test.js +0 -100
  162. package/cryptography/tests/totp.test.d.ts +0 -1
  163. package/cryptography/tests/totp.test.js +0 -108
  164. package/document-management/tests/ai-config-hierarchy.test.d.ts +0 -1
  165. package/document-management/tests/ai-config-hierarchy.test.js +0 -59
  166. package/document-management/tests/ai-config-integration.test.d.ts +0 -1
  167. package/document-management/tests/ai-config-integration.test.js +0 -125
  168. package/document-management/tests/ai-config-merge.test.d.ts +0 -1
  169. package/document-management/tests/ai-config-merge.test.js +0 -46
  170. package/document-management/tests/document-management-ai-overrides.test.d.ts +0 -1
  171. package/document-management/tests/document-management-ai-overrides.test.js +0 -63
  172. package/document-management/tests/document-management-core.test.d.ts +0 -1
  173. package/document-management/tests/document-management-core.test.js +0 -157
  174. package/document-management/tests/document-management.api.test.d.ts +0 -1
  175. package/document-management/tests/document-management.api.test.js +0 -101
  176. package/document-management/tests/document-statistics.service.test.d.ts +0 -1
  177. package/document-management/tests/document-statistics.service.test.js +0 -498
  178. package/document-management/tests/document-validation-ai-overrides.test.d.ts +0 -1
  179. package/document-management/tests/document-validation-ai-overrides.test.js +0 -87
  180. package/document-management/tests/document.service.test.d.ts +0 -1
  181. package/document-management/tests/document.service.test.js +0 -143
  182. package/document-management/tests/enum-helpers.test.d.ts +0 -1
  183. package/document-management/tests/enum-helpers.test.js +0 -452
  184. package/document-management/tests/helper.d.ts +0 -24
  185. package/document-management/tests/helper.js +0 -39
  186. package/errors/tests/format.test.d.ts +0 -1
  187. package/errors/tests/format.test.js +0 -84
  188. package/http/tests/server-timing.test.d.ts +0 -1
  189. package/http/tests/server-timing.test.js +0 -42
  190. package/injector/tests/advanced.test.d.ts +0 -1
  191. package/injector/tests/advanced.test.js +0 -116
  192. package/injector/tests/async-init.test.d.ts +0 -1
  193. package/injector/tests/async-init.test.js +0 -77
  194. package/injector/tests/basic.test.d.ts +0 -1
  195. package/injector/tests/basic.test.js +0 -114
  196. package/injector/tests/hierarchical.test.d.ts +0 -1
  197. package/injector/tests/hierarchical.test.js +0 -59
  198. package/injector/tests/leak.test.d.ts +0 -1
  199. package/injector/tests/leak.test.js +0 -45
  200. package/injector/tests/lifecycles.test.d.ts +0 -1
  201. package/injector/tests/lifecycles.test.js +0 -109
  202. package/logger/tests/pretty-print.test.d.ts +0 -1
  203. package/logger/tests/pretty-print.test.js +0 -60
  204. package/notification/tests/notification-api.test.d.ts +0 -1
  205. package/notification/tests/notification-api.test.js +0 -124
  206. package/notification/tests/notification-client.test.d.ts +0 -1
  207. package/notification/tests/notification-client.test.js +0 -101
  208. package/notification/tests/notification-flow.test.d.ts +0 -1
  209. package/notification/tests/notification-flow.test.js +0 -296
  210. package/notification/tests/notification-sse.service.test.d.ts +0 -1
  211. package/notification/tests/notification-sse.service.test.js +0 -43
  212. package/notification/tests/notification-type.service.test.d.ts +0 -1
  213. package/notification/tests/notification-type.service.test.js +0 -41
  214. package/object-storage/s3/tests/s3.object-storage.integration.test.d.ts +0 -1
  215. package/object-storage/s3/tests/s3.object-storage.integration.test.js +0 -303
  216. package/orm/tests/build-jsonb.test.d.ts +0 -1
  217. package/orm/tests/build-jsonb.test.js +0 -39
  218. package/orm/tests/data-types.test.d.ts +0 -1
  219. package/orm/tests/data-types.test.js +0 -39
  220. package/orm/tests/database-extension.test.d.ts +0 -1
  221. package/orm/tests/database-extension.test.js +0 -63
  222. package/orm/tests/database-migration.test.d.ts +0 -1
  223. package/orm/tests/database-migration.test.js +0 -83
  224. package/orm/tests/decorators.test.d.ts +0 -1
  225. package/orm/tests/decorators.test.js +0 -77
  226. package/orm/tests/encryption.test.d.ts +0 -1
  227. package/orm/tests/encryption.test.js +0 -31
  228. package/orm/tests/query-complex.test.d.ts +0 -1
  229. package/orm/tests/query-complex.test.js +0 -172
  230. package/orm/tests/query-converter-complex.test.d.ts +0 -1
  231. package/orm/tests/query-converter-complex.test.js +0 -131
  232. package/orm/tests/query-converter.test.d.ts +0 -1
  233. package/orm/tests/query-converter.test.js +0 -123
  234. package/orm/tests/repository-advanced.test.d.ts +0 -1
  235. package/orm/tests/repository-advanced.test.js +0 -189
  236. package/orm/tests/repository-attributes.test.d.ts +0 -1
  237. package/orm/tests/repository-attributes.test.js +0 -83
  238. package/orm/tests/repository-compound-primary-key.test.d.ts +0 -2
  239. package/orm/tests/repository-compound-primary-key.test.js +0 -226
  240. package/orm/tests/repository-comprehensive.test.d.ts +0 -1
  241. package/orm/tests/repository-comprehensive.test.js +0 -162
  242. package/orm/tests/repository-coverage.test.d.ts +0 -2
  243. package/orm/tests/repository-coverage.test.js +0 -242
  244. package/orm/tests/repository-cti-complex.test.d.ts +0 -1
  245. package/orm/tests/repository-cti-complex.test.js +0 -151
  246. package/orm/tests/repository-cti-embedded.test.d.ts +0 -1
  247. package/orm/tests/repository-cti-embedded.test.js +0 -178
  248. package/orm/tests/repository-cti-extensive.test.d.ts +0 -2
  249. package/orm/tests/repository-cti-extensive.test.js +0 -279
  250. package/orm/tests/repository-cti-mapping.test.d.ts +0 -2
  251. package/orm/tests/repository-cti-mapping.test.js +0 -108
  252. package/orm/tests/repository-cti-search.test.d.ts +0 -1
  253. package/orm/tests/repository-cti-search.test.js +0 -141
  254. package/orm/tests/repository-cti-soft-delete.test.d.ts +0 -2
  255. package/orm/tests/repository-cti-soft-delete.test.js +0 -103
  256. package/orm/tests/repository-cti-transactions.test.d.ts +0 -1
  257. package/orm/tests/repository-cti-transactions.test.js +0 -112
  258. package/orm/tests/repository-cti-upsert-many.test.d.ts +0 -2
  259. package/orm/tests/repository-cti-upsert-many.test.js +0 -115
  260. package/orm/tests/repository-cti.test.d.ts +0 -2
  261. package/orm/tests/repository-cti.test.js +0 -390
  262. package/orm/tests/repository-edge-cases.test.d.ts +0 -1
  263. package/orm/tests/repository-edge-cases.test.js +0 -178
  264. package/orm/tests/repository-expiration.test.d.ts +0 -2
  265. package/orm/tests/repository-expiration.test.js +0 -140
  266. package/orm/tests/repository-extra-coverage.test.d.ts +0 -2
  267. package/orm/tests/repository-extra-coverage.test.js +0 -402
  268. package/orm/tests/repository-mapping.test.d.ts +0 -2
  269. package/orm/tests/repository-mapping.test.js +0 -65
  270. package/orm/tests/repository-regression.test.d.ts +0 -1
  271. package/orm/tests/repository-regression.test.js +0 -288
  272. package/orm/tests/repository-search-coverage.test.d.ts +0 -1
  273. package/orm/tests/repository-search-coverage.test.js +0 -107
  274. package/orm/tests/repository-search.test.d.ts +0 -1
  275. package/orm/tests/repository-search.test.js +0 -105
  276. package/orm/tests/repository-soft-delete.test.d.ts +0 -1
  277. package/orm/tests/repository-soft-delete.test.js +0 -118
  278. package/orm/tests/repository-transactions-nested.test.d.ts +0 -1
  279. package/orm/tests/repository-transactions-nested.test.js +0 -178
  280. package/orm/tests/repository-types.test.d.ts +0 -1
  281. package/orm/tests/repository-types.test.js +0 -184
  282. package/orm/tests/repository-undelete.test.d.ts +0 -2
  283. package/orm/tests/repository-undelete.test.js +0 -201
  284. package/orm/tests/schema-converter.test.d.ts +0 -1
  285. package/orm/tests/schema-converter.test.js +0 -82
  286. package/orm/tests/schema-generation.test.d.ts +0 -2
  287. package/orm/tests/schema-generation.test.js +0 -174
  288. package/orm/tests/sql-helpers.test.d.ts +0 -1
  289. package/orm/tests/sql-helpers.test.js +0 -67
  290. package/orm/tests/transaction-safety.test.d.ts +0 -1
  291. package/orm/tests/transaction-safety.test.js +0 -81
  292. package/orm/tests/transactional.test.d.ts +0 -1
  293. package/orm/tests/transactional.test.js +0 -215
  294. package/orm/tests/utils.test.d.ts +0 -1
  295. package/orm/tests/utils.test.js +0 -70
  296. package/pdf/tests/utils.test.d.ts +0 -1
  297. package/pdf/tests/utils.test.js +0 -187
  298. package/process/tests/spawn.test.d.ts +0 -1
  299. package/process/tests/spawn.test.js +0 -182
  300. package/rate-limit/tests/postgres-rate-limiter.test.d.ts +0 -1
  301. package/rate-limit/tests/postgres-rate-limiter.test.js +0 -84
  302. package/renderer/tests/renderer.test.d.ts +0 -1
  303. package/renderer/tests/renderer.test.js +0 -88
  304. package/rpc/tests/rpc.integration.test.d.ts +0 -1
  305. package/rpc/tests/rpc.integration.test.js +0 -615
  306. package/signals/implementation/errors.d.ts +0 -2
  307. package/signals/implementation/graph.js +0 -312
  308. package/signals/implementation/writable-signal.d.ts +0 -48
  309. package/signals/implementation/writable-signal.js +0 -32
  310. package/task-queue/tests/coverage-branch.test.d.ts +0 -1
  311. package/task-queue/tests/coverage-branch.test.js +0 -395
  312. package/task-queue/tests/coverage-enhancement.test.d.ts +0 -1
  313. package/task-queue/tests/coverage-enhancement.test.js +0 -150
  314. package/task-queue/tests/dag.test.d.ts +0 -1
  315. package/task-queue/tests/dag.test.js +0 -188
  316. package/task-queue/tests/dependencies.test.d.ts +0 -1
  317. package/task-queue/tests/dependencies.test.js +0 -296
  318. package/task-queue/tests/enqueue-batch.test.d.ts +0 -1
  319. package/task-queue/tests/enqueue-batch.test.js +0 -125
  320. package/task-queue/tests/enqueue-item.test.d.ts +0 -1
  321. package/task-queue/tests/enqueue-item.test.js +0 -12
  322. package/task-queue/tests/fan-out-spawning.test.d.ts +0 -1
  323. package/task-queue/tests/fan-out-spawning.test.js +0 -94
  324. package/task-queue/tests/idempotent-replacement.test.d.ts +0 -1
  325. package/task-queue/tests/idempotent-replacement.test.js +0 -114
  326. package/task-queue/tests/missing-idempotent-tasks.test.d.ts +0 -1
  327. package/task-queue/tests/missing-idempotent-tasks.test.js +0 -39
  328. package/task-queue/tests/optimization-edge-cases.test.d.ts +0 -1
  329. package/task-queue/tests/optimization-edge-cases.test.js +0 -124
  330. package/task-queue/tests/queue-generic.test.d.ts +0 -1
  331. package/task-queue/tests/queue-generic.test.js +0 -8
  332. package/task-queue/tests/queue.test.d.ts +0 -1
  333. package/task-queue/tests/queue.test.js +0 -756
  334. package/task-queue/tests/shutdown.test.d.ts +0 -1
  335. package/task-queue/tests/shutdown.test.js +0 -41
  336. package/task-queue/tests/task-context.test.d.ts +0 -1
  337. package/task-queue/tests/task-context.test.js +0 -7
  338. package/task-queue/tests/task-union.test.d.ts +0 -1
  339. package/task-queue/tests/task-union.test.js +0 -18
  340. package/task-queue/tests/transactions.test.d.ts +0 -1
  341. package/task-queue/tests/transactions.test.js +0 -47
  342. package/task-queue/tests/typing.test.d.ts +0 -1
  343. package/task-queue/tests/typing.test.js +0 -9
  344. package/task-queue/tests/worker.test.d.ts +0 -1
  345. package/task-queue/tests/worker.test.js +0 -258
  346. package/task-queue/tests/zombie-parent.test.d.ts +0 -1
  347. package/task-queue/tests/zombie-parent.test.js +0 -45
  348. package/task-queue/tests/zombie-recovery.test.d.ts +0 -1
  349. package/task-queue/tests/zombie-recovery.test.js +0 -51
  350. package/utils/tests/backoff.test.d.ts +0 -1
  351. package/utils/tests/backoff.test.js +0 -41
  352. package/utils/tests/retry-with-backoff.test.d.ts +0 -1
  353. package/utils/tests/retry-with-backoff.test.js +0 -49
@@ -0,0 +1,13 @@
1
+ /** biome-ignore-all lint: <explanation> */
2
+ import type { DebouncedOptions, DebounceTimer, Resource } from './api.js';
3
+ /**
4
+ * Creates a resource representing a debounced version of the source signal.
5
+ *
6
+ * @param source The source signal to debounce.
7
+ * @param wait The amount of time to wait before calling the source signal, or a function that
8
+ * returns a promise that resolves when the debounced value should be updated.
9
+ * @param options The options to use for the debounced signal.
10
+ * @returns A resource representing the debounced signal.
11
+ * @experimental 22.0
12
+ */
13
+ export declare function debounced<T>(source: () => T, wait: NoInfer<DebounceTimer<T>>, options?: NoInfer<DebouncedOptions<T>>): Resource<T>;
@@ -0,0 +1,113 @@
1
+ /* eslint-disable */
2
+ /** biome-ignore-all lint: <explanation> */
3
+ /**
4
+ * @license
5
+ * Copyright Google LLC All Rights Reserved.
6
+ *
7
+ * Use of this source code is governed by an MIT-style license that can be
8
+ * found in the LICENSE file at https://angular.dev/license
9
+ */
10
+ import { effect } from '../effect.js';
11
+ import { linkedSignal } from '../linked_signal.js';
12
+ import { untracked } from '../untracked.js';
13
+ import { resourceFromSnapshots } from './from_snapshots.js';
14
+ import { invalidResourceCreationInParams, isInParamsFunction, rethrowFatalErrors, setInParamsFunction } from './resource.js';
15
+ /**
16
+ * Creates a resource representing a debounced version of the source signal.
17
+ *
18
+ * @param source The source signal to debounce.
19
+ * @param wait The amount of time to wait before calling the source signal, or a function that
20
+ * returns a promise that resolves when the debounced value should be updated.
21
+ * @param options The options to use for the debounced signal.
22
+ * @returns A resource representing the debounced signal.
23
+ * @experimental 22.0
24
+ */
25
+ export function debounced(source, wait, options) {
26
+ if (isInParamsFunction()) {
27
+ throw invalidResourceCreationInParams();
28
+ }
29
+ let active;
30
+ let pendingValue;
31
+ const state = linkedSignal({
32
+ source: () => {
33
+ try {
34
+ setInParamsFunction(true);
35
+ return { value: source(), thrown: false };
36
+ }
37
+ catch (err) {
38
+ rethrowFatalErrors(err);
39
+ return { error: err, thrown: true };
40
+ }
41
+ finally {
42
+ setInParamsFunction(false);
43
+ }
44
+ },
45
+ computation: (res, previous) => {
46
+ // If we already have a state from the effect or a previous read, keep it!
47
+ // The effect is responsible for timing and state transitions.
48
+ if (previous !== undefined) {
49
+ return previous.value;
50
+ }
51
+ // On the very first evaluation, determine the initial state synchronously.
52
+ if (res.thrown) {
53
+ return { status: 'error', error: res.error };
54
+ }
55
+ return { status: 'resolved', value: res.value };
56
+ },
57
+ });
58
+ effect(() => {
59
+ // Enter error state if the source throws.
60
+ let value;
61
+ try {
62
+ setInParamsFunction(true);
63
+ value = source();
64
+ }
65
+ catch (err) {
66
+ rethrowFatalErrors(err);
67
+ state.set({ status: 'error', error: err });
68
+ active = pendingValue = undefined;
69
+ return;
70
+ }
71
+ finally {
72
+ setInParamsFunction(false);
73
+ }
74
+ const currentState = untracked(state);
75
+ // Check if the value is the same as the previous one.
76
+ const equal = options?.equal ?? Object.is;
77
+ if (currentState.status === 'reloading' || currentState.status === 'loading') {
78
+ if (equal(value, pendingValue))
79
+ return;
80
+ }
81
+ else if (currentState.status === 'resolved') {
82
+ if (equal(value, currentState.value))
83
+ return;
84
+ }
85
+ const waitFn = typeof wait === 'number'
86
+ ? () => new Promise((resolve) => setTimeout(resolve, wait))
87
+ : wait;
88
+ const result = waitFn(value, currentState);
89
+ if (result === undefined) {
90
+ // Synchronous case, go straight to resolved.
91
+ state.set({ status: 'resolved', value });
92
+ active = pendingValue = undefined;
93
+ }
94
+ else {
95
+ // Asynchronous case:
96
+ // If we're in error state or loading state, remain in that state.
97
+ // Otherwise, change to loading state but keep the current value until the new one loads.
98
+ if (currentState.status !== 'loading' && currentState.status !== 'error') {
99
+ state.set({ status: 'loading', value: currentState.value });
100
+ }
101
+ active = result;
102
+ pendingValue = value;
103
+ // Once the promise resolves, update the state to resolved.
104
+ result.then(() => {
105
+ if (active === result) {
106
+ state.set({ status: 'resolved', value });
107
+ active = pendingValue = undefined;
108
+ }
109
+ });
110
+ }
111
+ }, { injector: options?.injector });
112
+ return resourceFromSnapshots(state);
113
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ import type { Resource, ResourceSnapshot } from './api.js';
9
+ /**
10
+ * Creates a `Resource` driven by a source of `ResourceSnapshot`s.
11
+ *
12
+ * @see [Resource composition with snapshots](guide/signals/resource#resource-composition-with-snapshots)
13
+ *
14
+ * @experimental
15
+ */
16
+ export declare function resourceFromSnapshots<T>(source: () => ResourceSnapshot<T>): Resource<T>;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ /* eslint-disable */
9
+ /** biome-ignore-all lint: <explanation> */
10
+ import { isSignal } from '../api.js';
11
+ import { computed } from '../computed.js';
12
+ import { ResourceValueError } from './resource.js';
13
+ /**
14
+ * Creates a `Resource` driven by a source of `ResourceSnapshot`s.
15
+ *
16
+ * @see [Resource composition with snapshots](guide/signals/resource#resource-composition-with-snapshots)
17
+ *
18
+ * @experimental
19
+ */
20
+ export function resourceFromSnapshots(source) {
21
+ return new SnapshotResource(isSignal(source) ? source : computed(source));
22
+ }
23
+ class SnapshotResource {
24
+ snapshot;
25
+ constructor(snapshot) {
26
+ this.snapshot = snapshot;
27
+ }
28
+ get state() {
29
+ return this.snapshot();
30
+ }
31
+ value = computed(() => {
32
+ if (this.state.status === 'error') {
33
+ throw new ResourceValueError(this.state.error);
34
+ }
35
+ return this.state.value;
36
+ });
37
+ status = computed(() => this.state.status);
38
+ error = computed(() => (this.state.status === 'error' ? this.state.error : undefined));
39
+ isLoading = computed(() => this.state.status === 'loading' || this.state.status === 'reloading');
40
+ isValueDefined = computed(() => this.state.status !== 'error' && this.state.value !== undefined);
41
+ hasValue() {
42
+ return this.isValueDefined();
43
+ }
44
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ export * from './api.js';
9
+ export { debounced } from './debounce.js';
10
+ export { resourceFromSnapshots } from './from_snapshots.js';
11
+ export { resource } from './resource.js';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ export * from './api.js';
9
+ export { debounced } from './debounce.js';
10
+ export { resourceFromSnapshots } from './from_snapshots.js';
11
+ export { resource } from './resource.js';
@@ -0,0 +1,110 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC All Rights Reserved.
4
+ *
5
+ * Use of this source code is governed by an MIT-style license that can be
6
+ * found in the LICENSE file at https://angular.dev/license
7
+ */
8
+ import type { SignalsInjector } from '../../../signals/api.js';
9
+ import type { Signal, ValueEqualityFn } from '../api.js';
10
+ import { type WritableSignal } from '../signal.js';
11
+ import { type Resource, type ResourceOptions, type ResourceParamsContext, type ResourceRef, type ResourceSnapshot, type ResourceStatus, type ResourceStreamingLoader, type ResourceStreamItem, type WritableResource } from './api.js';
12
+ /**
13
+ * Constructs a `Resource` that projects a reactive request to an asynchronous operation defined by
14
+ * a loader function, which exposes the result of the loading operation via signals.
15
+ *
16
+ * Note that `resource` is intended for _read_ operations, not operations which perform mutations.
17
+ * `resource` will cancel in-progress loads via the `AbortSignal` when destroyed or when a new
18
+ * request object becomes available, which could prematurely abort mutations.
19
+ */
20
+ export declare function resource<T, R>(options: ResourceOptions<T, R> & {
21
+ defaultValue: NoInfer<T>;
22
+ }): ResourceRef<T>;
23
+ /**
24
+ * Constructs a `Resource` that projects a reactive request to an asynchronous operation defined by
25
+ * a loader function, which exposes the result of the loading operation via signals.
26
+ *
27
+ * Note that `resource` is intended for _read_ operations, not operations which perform mutations.
28
+ * `resource` will cancel in-progress loads via the `AbortSignal` when destroyed or when a new
29
+ * request object becomes available, which could prematurely abort mutations.
30
+ *
31
+ * @experimental 19.0
32
+ * @see [Async reactivity with resources](guide/signals/resource)
33
+ */
34
+ export declare function resource<T, R>(options: ResourceOptions<T, R>): ResourceRef<T | undefined>;
35
+ type ResourceInternalStatus = 'idle' | 'loading' | 'resolved' | 'local';
36
+ type WrappedRequest = {
37
+ request?: unknown;
38
+ reload: number;
39
+ status?: ResourceInternalStatus;
40
+ error?: Error;
41
+ };
42
+ /**
43
+ * Base class which implements `.value` as a `WritableSignal` by delegating `.set` and `.update`.
44
+ */
45
+ declare abstract class BaseWritableResource<T> implements WritableResource<T> {
46
+ readonly value: WritableSignal<T>;
47
+ abstract readonly status: Signal<ResourceStatus>;
48
+ abstract readonly error: Signal<Error | undefined>;
49
+ abstract reload(): boolean;
50
+ readonly isLoading: Signal<boolean>;
51
+ constructor(value: Signal<T>, debugName: string | undefined);
52
+ abstract set(value: T): void;
53
+ private readonly isError;
54
+ update(updateFn: (value: T) => T): void;
55
+ private readonly isValueDefined;
56
+ private _snapshot;
57
+ get snapshot(): Signal<ResourceSnapshot<T>>;
58
+ hasValue(): this is ResourceRef<Exclude<T, undefined>>;
59
+ asReadonly(): Resource<T>;
60
+ }
61
+ /**
62
+ * Implementation for `resource()` which uses a `linkedSignal` to manage the resource's state.
63
+ */
64
+ export declare class ResourceImpl<T, R> extends BaseWritableResource<T> implements ResourceRef<T> {
65
+ /**
66
+ * The current state of the resource. Status, value, and error are derived from this.
67
+ */
68
+ private readonly state;
69
+ /**
70
+ * Combines the current request with a reload counter which allows the resource to be reloaded on
71
+ * imperative command.
72
+ */
73
+ protected readonly extRequest: WritableSignal<WrappedRequest>;
74
+ private readonly effectRef;
75
+ private readonly loaderFn;
76
+ defaultValue: T;
77
+ private readonly equal;
78
+ private readonly debugName;
79
+ private pendingController;
80
+ private resolvePendingTask;
81
+ private destroyed;
82
+ private unregisterOnDestroy;
83
+ readonly status: Signal<ResourceStatus>;
84
+ readonly error: Signal<Error | undefined>;
85
+ constructor(request: (ctx: ResourceParamsContext) => R, loaderFn: ResourceStreamingLoader<T, R>, defaultValue: T, equal: ValueEqualityFn<T> | undefined, debugName: string | undefined, injector?: SignalsInjector, getInitialStream?: (request: R) => Signal<ResourceStreamItem<T>> | undefined);
86
+ /**
87
+ * Called either directly via `WritableResource.set` or via `.value.set()`.
88
+ */
89
+ set(value: T): void;
90
+ reload(): boolean;
91
+ destroy(): void;
92
+ private loadEffect;
93
+ private abortInProgressLoad;
94
+ }
95
+ export declare function encapsulateResourceError(error: unknown): Error;
96
+ export declare function isErrorLike(error: unknown): error is Error;
97
+ export declare class ResourceValueError extends Error {
98
+ constructor(error: Error);
99
+ }
100
+ /**
101
+ * Chains the value of another resource into the params of the current resource, returning the value
102
+ * of the other resource if it is available, or propagating the status to the current resource if it
103
+ * is not.
104
+ */
105
+ export declare const paramsContext: ResourceParamsContext;
106
+ export declare function isInParamsFunction(): boolean;
107
+ export declare function setInParamsFunction(value: boolean): void;
108
+ export declare function invalidResourceCreationInParams(): Error;
109
+ export declare function rethrowFatalErrors(error: unknown): void;
110
+ export {};