@tstdl/base 0.93.182 → 0.93.184

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 +10 -1
  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
@@ -1,78 +1,113 @@
1
1
  /* eslint-disable */
2
- import { assertNotInReactiveContext } from './asserts.js';
3
- import { createWatch } from './watch.js';
2
+ /** biome-ignore-all lint: <explanation> */
4
3
  /**
5
- * A scheduler which manages the execution of effects.
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
6
9
  */
7
- export class EffectScheduler {
8
- }
9
- export class TstdlEffectScheduler {
10
- queue = new Set();
11
- hasPendingFlush = false;
12
- scheduleEffect(effect) {
13
- if (this.queue.has(effect)) {
14
- return;
15
- }
16
- this.queue.add(effect);
17
- if (!this.hasPendingFlush) {
18
- this.hasPendingFlush = true;
19
- queueMicrotask(() => {
20
- this.hasPendingFlush = false;
21
- this.flush();
22
- });
23
- }
10
+ import { isDevMode } from '../../core.js';
11
+ import { SIGNAL } from '../symbol.js';
12
+ import { assertNotInReactiveContext } from './asserts.js';
13
+ import { BASE_EFFECT_NODE, runEffect } from './primitive/effect.js';
14
+ import { consumerDestroy, isInNotificationPhase, setActiveConsumer } from './primitive/graph.js';
15
+ import { microtaskEffectScheduler } from './root_effect_scheduler.js';
16
+ export class EffectRefImpl {
17
+ [SIGNAL];
18
+ constructor(node) {
19
+ this[SIGNAL] = node;
24
20
  }
25
- flush() {
26
- for (const effect of this.queue) {
27
- this.queue.delete(effect);
28
- effect.run();
29
- }
21
+ destroy() {
22
+ this[SIGNAL].destroy();
30
23
  }
31
24
  }
32
25
  /**
33
- * Core reactive node for an effect.
26
+ * Registers an "effect" that will be scheduled & executed whenever the signals that it reads
27
+ * changes.
28
+ *
29
+ * Angular has two different kinds of effect: component effects and root effects. Component effects
30
+ * are created when `effect()` is called from a component, directive, or within a service of a
31
+ * component/directive. Root effects are created when `effect()` is called from outside the
32
+ * component tree, such as in a root service.
33
+ *
34
+ * The two effect types differ in their timing. Component effects run as a component lifecycle
35
+ * event during Angular's synchronization (change detection) process, and can safely read input
36
+ * signals or create/destroy views that depend on component state. Root effects run as microtasks
37
+ * and have no connection to the component tree or change detection.
34
38
  *
35
- * `EffectHandle` combines the reactive graph's `Watch` base node for effects with the framework's
36
- * scheduling abstraction (`EffectScheduler`) as well as automatic cleanup via `DestroyRef` if
37
- * available/requested.
39
+ * `effect()` must be run in injection context, unless the `injector` option is manually specified.
40
+ *
41
+ * @see [Effects](guide/signals#effects)
42
+ *
43
+ * @publicApi 20.0
38
44
  */
39
- class EffectHandle {
40
- scheduler;
41
- effectFn;
42
- watcher;
43
- constructor(scheduler, effectFn, allowSignalWrites) {
44
- this.scheduler = scheduler;
45
- this.effectFn = effectFn;
46
- this.watcher = createWatch((onCleanup) => this.runEffect(onCleanup), () => this.schedule(), allowSignalWrites);
45
+ export function effect(effectFn, options) {
46
+ isDevMode() &&
47
+ assertNotInReactiveContext(effect, 'Call `effect` outside of a reactive context. For example, schedule the ' +
48
+ 'effect inside the component constructor.');
49
+ if (isDevMode() && options?.allowSignalWrites !== undefined) {
50
+ console.warn(`The 'allowSignalWrites' flag is deprecated and no longer impacts effect() (writes are always allowed)`);
47
51
  }
48
- runEffect(onCleanup) {
52
+ const node = createRootEffect(effectFn, microtaskEffectScheduler);
53
+ return new EffectRefImpl(node);
54
+ }
55
+ export const EFFECT_NODE =
56
+ /* @__PURE__ */ (() => ({
57
+ ...BASE_EFFECT_NODE,
58
+ cleanupFns: undefined,
59
+ onDestroyFns: null,
60
+ run() {
61
+ if (isDevMode() && isInNotificationPhase()) {
62
+ throw new Error(`Schedulers cannot synchronously execute watches while scheduling.`);
63
+ }
64
+ runEffect(this);
65
+ },
66
+ cleanup() {
67
+ if (!this.cleanupFns?.length) {
68
+ return;
69
+ }
70
+ const prevConsumer = setActiveConsumer(null);
49
71
  try {
50
- this.effectFn(onCleanup);
72
+ // Attempt to run the cleanup functions. Regardless of failure or success, we consider
73
+ // cleanup "completed" and clear the list for the next run of the effect. Note that an error
74
+ // from the cleanup function will still crash the current run of the effect.
75
+ while (this.cleanupFns.length) {
76
+ this.cleanupFns.pop()();
77
+ }
51
78
  }
52
- catch (err) {
53
- queueMicrotask(() => { throw err; });
79
+ finally {
80
+ this.cleanupFns = [];
81
+ setActiveConsumer(prevConsumer);
54
82
  }
55
- }
56
- run() {
57
- this.watcher.run();
58
- }
59
- schedule() {
60
- this.scheduler.scheduleEffect(this);
61
- }
83
+ },
84
+ }))();
85
+ export const ROOT_EFFECT_NODE =
86
+ /* @__PURE__ */ (() => ({
87
+ ...EFFECT_NODE,
88
+ consumerMarkedDirty() {
89
+ this.scheduler.schedule(this);
90
+ },
62
91
  destroy() {
63
- this.watcher.destroy();
64
- // Note: if the effect is currently scheduled, it's not un-scheduled, and so the scheduler will
65
- // retain a reference to it. Attempting to execute it will be a no-op.
66
- }
92
+ consumerDestroy(this);
93
+ if (this.onDestroyFns !== null) {
94
+ for (const fn of this.onDestroyFns) {
95
+ fn();
96
+ }
97
+ }
98
+ this.cleanup();
99
+ this.scheduler.remove(this);
100
+ },
101
+ }))();
102
+ export function createRootEffect(fn, scheduler) {
103
+ const node = Object.create(ROOT_EFFECT_NODE);
104
+ node.fn = createEffectFn(node, fn);
105
+ node.scheduler = scheduler;
106
+ node.scheduler.add(node);
107
+ return node;
67
108
  }
68
- const effectScheduler = new TstdlEffectScheduler();
69
- /**
70
- * Create a global `Effect` for the given reactive function.
71
- */
72
- export function effect(effectFn, options) {
73
- assertNotInReactiveContext(effect, 'Call `effect` outside of a reactive context. For example, schedule the ' +
74
- 'effect inside the component constructor.');
75
- const handle = new EffectHandle(effectScheduler, effectFn, options?.allowSignalWrites ?? false);
76
- handle.watcher.notify();
77
- return handle;
109
+ function createEffectFn(node, fn) {
110
+ return () => {
111
+ fn((cleanupFn) => (node.cleanupFns ??= []).push(cleanupFn));
112
+ };
78
113
  }
@@ -3,11 +3,9 @@ export * from './asserts.js';
3
3
  export * from './computed.js';
4
4
  export * from './configure.js';
5
5
  export * from './effect.js';
6
- export * from './equality.js';
7
- export * from './graph.js';
6
+ export * from './linked_signal.js';
7
+ export * from './resource/index.js';
8
8
  export * from './signal.js';
9
9
  export * from './to-observable.js';
10
10
  export * from './to-signal.js';
11
11
  export * from './untracked.js';
12
- export * from './watch.js';
13
- export * from './writable-signal.js';
@@ -3,11 +3,9 @@ export * from './asserts.js';
3
3
  export * from './computed.js';
4
4
  export * from './configure.js';
5
5
  export * from './effect.js';
6
- export * from './equality.js';
7
- export * from './graph.js';
6
+ export * from './linked_signal.js';
7
+ export * from './resource/index.js';
8
8
  export * from './signal.js';
9
9
  export * from './to-observable.js';
10
10
  export * from './to-signal.js';
11
11
  export * from './untracked.js';
12
- export * from './watch.js';
13
- export * from './writable-signal.js';
@@ -0,0 +1,36 @@
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 { ValueEqualityFn } from './primitive/equality.js';
9
+ import { type WritableSignal } from './signal.js';
10
+ /**
11
+ * Creates a writable signal whose value is initialized and reset by the linked, reactive computation.
12
+ *
13
+ * @publicApi 20.0
14
+ */
15
+ export declare function linkedSignal<D>(computation: () => D, options?: {
16
+ equal?: ValueEqualityFn<NoInfer<D>>;
17
+ debugName?: string;
18
+ }): WritableSignal<D>;
19
+ /**
20
+ * Creates a writable signal whose value is initialized and reset by the linked, reactive computation.
21
+ * This is an advanced API form where the computation has access to the previous value of the signal and the computation result.
22
+ *
23
+ * Note: The computation is reactive, meaning the linked signal will automatically update whenever any of the signals used within the computation change.
24
+ *
25
+ * @publicApi 20.0
26
+ * @see [Dependent state with linkedSignal](guide/signals/linked-signal)
27
+ */
28
+ export declare function linkedSignal<S, D>(options: {
29
+ source: () => S;
30
+ computation: (source: NoInfer<S>, previous?: {
31
+ source: NoInfer<S>;
32
+ value: NoInfer<D>;
33
+ }) => D;
34
+ equal?: ValueEqualityFn<NoInfer<D>>;
35
+ debugName?: string;
36
+ }): WritableSignal<D>;
@@ -0,0 +1,34 @@
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 { isDevMode } from '../../core.js';
9
+ import { SIGNAL } from '../symbol.js';
10
+ import { createLinkedSignal, linkedSignalSetFn, linkedSignalUpdateFn } from './primitive/linked_signal.js';
11
+ import { signalAsReadonlyFn } from './signal.js';
12
+ const identityFn = (v) => v;
13
+ export function linkedSignal(optionsOrComputation, options) {
14
+ if (typeof optionsOrComputation === 'function') {
15
+ const getter = createLinkedSignal(optionsOrComputation, (identityFn), options?.equal);
16
+ return upgradeLinkedSignalGetter(getter, options?.debugName);
17
+ }
18
+ else {
19
+ const getter = createLinkedSignal(optionsOrComputation.source, optionsOrComputation.computation, optionsOrComputation.equal);
20
+ return upgradeLinkedSignalGetter(getter, optionsOrComputation.debugName);
21
+ }
22
+ }
23
+ function upgradeLinkedSignalGetter(getter, debugName) {
24
+ if (isDevMode()) {
25
+ getter[SIGNAL].debugName = debugName;
26
+ getter.toString = () => `[LinkedSignal${debugName ? ' (' + debugName + ')' : ''}: ${getter()}]`;
27
+ }
28
+ const node = getter[SIGNAL];
29
+ const upgradedGetter = getter;
30
+ upgradedGetter.set = (newValue) => linkedSignalSetFn(node, newValue);
31
+ upgradedGetter.update = (updateFn) => linkedSignalUpdateFn(node, updateFn);
32
+ upgradedGetter.asReadonly = signalAsReadonlyFn.bind(getter);
33
+ return upgradedGetter;
34
+ }
@@ -0,0 +1,55 @@
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 ValueEqualityFn } from './equality.js';
9
+ import { type ReactiveNode, SIGNAL } from './graph.js';
10
+ /**
11
+ * A computation, which derives a value from a declarative reactive expression.
12
+ *
13
+ * `Computed`s are both producers and consumers of reactivity.
14
+ */
15
+ export interface ComputedNode<T> extends ReactiveNode {
16
+ /**
17
+ * Current value of the computation, or one of the sentinel values above (`UNSET`, `COMPUTING`,
18
+ * `ERROR`).
19
+ */
20
+ value: T;
21
+ /**
22
+ * If `value` is `ERRORED`, the error caught from the last computation attempt which will
23
+ * be re-thrown.
24
+ */
25
+ error: unknown;
26
+ /**
27
+ * The computation function which will produce a new value.
28
+ */
29
+ computation: () => T;
30
+ equal: ValueEqualityFn<T>;
31
+ }
32
+ export type ComputedGetter<T> = (() => T) & {
33
+ [SIGNAL]: ComputedNode<T>;
34
+ };
35
+ /**
36
+ * Create a computed signal which derives a reactive value from an expression.
37
+ */
38
+ export declare function createComputed<T>(computation: () => T, equal?: ValueEqualityFn<T>): ComputedGetter<T>;
39
+ /**
40
+ * A dedicated symbol used before a computed value has been calculated for the first time.
41
+ * Explicitly typed as `any` so we can use it as signal's value.
42
+ */
43
+ export declare const UNSET: any;
44
+ /**
45
+ * A dedicated symbol used in place of a computed signal value to indicate that a given computation
46
+ * is in progress. Used to detect cycles in computation chains.
47
+ * Explicitly typed as `any` so we can use it as signal's value.
48
+ */
49
+ export declare const COMPUTING: any;
50
+ /**
51
+ * A dedicated symbol used in place of a computed signal value to indicate that a given computation
52
+ * failed. The thrown error is cached until the computation gets dirty again.
53
+ * Explicitly typed as `any` so we can use it as signal's value.
54
+ */
55
+ export declare const ERRORED: any;
@@ -0,0 +1,107 @@
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 { isDevMode } from '../../../core.js';
9
+ import { defaultEquals } from './equality.js';
10
+ import { consumerAfterComputation, consumerBeforeComputation, producerAccessed, producerUpdateValueVersion, REACTIVE_NODE, runPostProducerCreatedFn, setActiveConsumer, SIGNAL, } from './graph.js';
11
+ /**
12
+ * Create a computed signal which derives a reactive value from an expression.
13
+ */
14
+ export function createComputed(computation, equal) {
15
+ const node = Object.create(COMPUTED_NODE);
16
+ node.computation = computation;
17
+ if (equal !== undefined) {
18
+ node.equal = equal;
19
+ }
20
+ const computed = () => {
21
+ // Check if the value needs updating before returning it.
22
+ producerUpdateValueVersion(node);
23
+ // Record that someone looked at this signal.
24
+ producerAccessed(node);
25
+ if (node.value === ERRORED) {
26
+ throw node.error;
27
+ }
28
+ return node.value;
29
+ };
30
+ computed[SIGNAL] = node;
31
+ if (isDevMode()) {
32
+ computed.toString = () => `[Computed${node.debugName ? ' (' + node.debugName + ')' : ''}: ${String(node.value)}]`;
33
+ }
34
+ runPostProducerCreatedFn(node);
35
+ return computed;
36
+ }
37
+ /**
38
+ * A dedicated symbol used before a computed value has been calculated for the first time.
39
+ * Explicitly typed as `any` so we can use it as signal's value.
40
+ */
41
+ export const UNSET = /* @__PURE__ */ Symbol('UNSET');
42
+ /**
43
+ * A dedicated symbol used in place of a computed signal value to indicate that a given computation
44
+ * is in progress. Used to detect cycles in computation chains.
45
+ * Explicitly typed as `any` so we can use it as signal's value.
46
+ */
47
+ export const COMPUTING = /* @__PURE__ */ Symbol('COMPUTING');
48
+ /**
49
+ * A dedicated symbol used in place of a computed signal value to indicate that a given computation
50
+ * failed. The thrown error is cached until the computation gets dirty again.
51
+ * Explicitly typed as `any` so we can use it as signal's value.
52
+ */
53
+ export const ERRORED = /* @__PURE__ */ Symbol('ERRORED');
54
+ // Note: Using an IIFE here to ensure that the spread assignment is not considered
55
+ // a side-effect, ending up preserving `COMPUTED_NODE` and `REACTIVE_NODE`.
56
+ const COMPUTED_NODE = /* @__PURE__ */ (() => {
57
+ return {
58
+ ...REACTIVE_NODE,
59
+ value: UNSET,
60
+ dirty: true,
61
+ error: null,
62
+ equal: defaultEquals,
63
+ kind: 'computed',
64
+ producerMustRecompute(node) {
65
+ // Force a recomputation if there's no current value, or if the current value is in the
66
+ // process of being calculated (which should throw an error).
67
+ return node.value === UNSET || node.value === COMPUTING;
68
+ },
69
+ producerRecomputeValue(node) {
70
+ if (node.value === COMPUTING) {
71
+ // Our computation somehow led to a cyclic read of itself.
72
+ throw new Error(isDevMode() ? 'Detected cycle in computations.' : '');
73
+ }
74
+ const oldValue = node.value;
75
+ node.value = COMPUTING;
76
+ const prevConsumer = consumerBeforeComputation(node);
77
+ let newValue;
78
+ let wasEqual = false;
79
+ try {
80
+ newValue = node.computation();
81
+ // We want to mark this node as errored if calling `equal` throws; however, we don't want
82
+ // to track any reactive reads inside `equal`.
83
+ setActiveConsumer(null);
84
+ wasEqual =
85
+ oldValue !== UNSET &&
86
+ oldValue !== ERRORED &&
87
+ newValue !== ERRORED &&
88
+ node.equal(oldValue, newValue);
89
+ }
90
+ catch (err) {
91
+ newValue = ERRORED;
92
+ node.error = err;
93
+ }
94
+ finally {
95
+ consumerAfterComputation(node, prevConsumer);
96
+ }
97
+ if (wasEqual) {
98
+ // No change to `valueVersion` - old and new values are
99
+ // semantically equivalent.
100
+ node.value = oldValue;
101
+ return;
102
+ }
103
+ node.value = newValue;
104
+ node.version++;
105
+ },
106
+ };
107
+ })();
@@ -0,0 +1,26 @@
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 ReactiveNode } from './graph.js';
9
+ /**
10
+ * An effect can, optionally, register a cleanup function. If registered, the cleanup is executed
11
+ * before the next effect run. The cleanup function makes it possible to "cancel" any work that the
12
+ * previous effect run might have started.
13
+ */
14
+ export type EffectCleanupFn = () => void;
15
+ /**
16
+ * A callback passed to the effect function that makes it possible to register cleanup logic.
17
+ */
18
+ export type EffectCleanupRegisterFn = (cleanupFn: EffectCleanupFn) => void;
19
+ export interface BaseEffectNode extends ReactiveNode {
20
+ fn: () => void;
21
+ destroy(): void;
22
+ cleanup(): void;
23
+ run(): void;
24
+ }
25
+ export declare const BASE_EFFECT_NODE: Omit<BaseEffectNode, 'fn' | 'destroy' | 'cleanup' | 'run'>;
26
+ export declare function runEffect(node: BaseEffectNode): void;
@@ -0,0 +1,31 @@
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 { consumerAfterComputation, consumerBeforeComputation, consumerPollProducersForChange, REACTIVE_NODE, } from './graph.js';
9
+ export const BASE_EFFECT_NODE =
10
+ /* @__PURE__ */ (() => ({
11
+ ...REACTIVE_NODE,
12
+ consumerIsAlwaysLive: true,
13
+ consumerAllowSignalWrites: true,
14
+ dirty: true,
15
+ kind: 'effect',
16
+ }))();
17
+ export function runEffect(node) {
18
+ node.dirty = false;
19
+ if (node.version > 0 && !consumerPollProducersForChange(node)) {
20
+ return;
21
+ }
22
+ node.version++;
23
+ const prevNode = consumerBeforeComputation(node);
24
+ try {
25
+ node.cleanup();
26
+ node.fn();
27
+ }
28
+ finally {
29
+ consumerAfterComputation(node, prevNode);
30
+ }
31
+ }
@@ -3,7 +3,7 @@
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  *
5
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.io/license
6
+ * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  /**
9
9
  * A comparison function which can determine if two values are equal.
@@ -3,7 +3,7 @@
3
3
  * Copyright Google LLC All Rights Reserved.
4
4
  *
5
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.io/license
6
+ * found in the LICENSE file at https://angular.dev/license
7
7
  */
8
8
  /**
9
9
  * The default equality function used for `signal` and `computed`, which uses referential equality.
@@ -0,0 +1,10 @@
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 { SignalNode } from './signal.js';
9
+ export declare function throwInvalidWriteToSignalError<T>(node: SignalNode<T>): void;
10
+ export declare function setThrowInvalidWriteToSignalError(fn: <T>(node: SignalNode<T>) => never): void;
@@ -1,17 +1,16 @@
1
- /* eslint-disable */
2
1
  /**
3
2
  * @license
4
3
  * Copyright Google LLC All Rights Reserved.
5
4
  *
6
5
  * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
6
+ * found in the LICENSE file at https://angular.dev/license
8
7
  */
9
8
  function defaultThrowError() {
10
9
  throw new Error();
11
10
  }
12
11
  let throwInvalidWriteToSignalErrorFn = defaultThrowError;
13
- export function throwInvalidWriteToSignalError() {
14
- throwInvalidWriteToSignalErrorFn();
12
+ export function throwInvalidWriteToSignalError(node) {
13
+ throwInvalidWriteToSignalErrorFn(node);
15
14
  }
16
15
  export function setThrowInvalidWriteToSignalError(fn) {
17
16
  throwInvalidWriteToSignalErrorFn = fn;
@@ -0,0 +1,19 @@
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
+ declare global {
9
+ var devtoolsFormatters: any[];
10
+ }
11
+ /**
12
+ * Installs the custom formatter into custom formatting on Signals in the devtools.
13
+ *
14
+ * Supported by both Chrome and Firefox.
15
+ *
16
+ * @see https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html
17
+ */
18
+ export declare function installDevToolsSignalFormatter(): void;
19
+ export {};