@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,136 @@
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 { SIGNAL } from './graph.js';
9
+ /**
10
+ * A custom formatter which renders signals in an easy-to-read format.
11
+ *
12
+ * @see https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html
13
+ */
14
+ const formatter = {
15
+ /**
16
+ * If the function returns `null`, the formatter is not used for this reference
17
+ */
18
+ header: (sig, config) => {
19
+ if (!isSignal(sig) || config?.ngSkipFormatting)
20
+ return null;
21
+ let value;
22
+ try {
23
+ value = sig();
24
+ }
25
+ catch (e) {
26
+ // In case the signal throws, we don't want to break the formatting.
27
+ return ['span', `Signal(⚠️ Error)${e.message ? `: ${e.message}` : ''}`];
28
+ }
29
+ const kind = 'computation' in sig[SIGNAL] ? 'Computed' : 'Signal';
30
+ const isPrimitive = value === null || (!Array.isArray(value) && typeof value !== 'object');
31
+ return [
32
+ 'span',
33
+ {},
34
+ ['span', {}, `${kind}(`],
35
+ (() => {
36
+ if (isSignal(value)) {
37
+ // Recursively call formatter. Could return an `object` to call the formatter through DevTools,
38
+ // but then recursive signals will render multiple expando arrows which is an awkward UX.
39
+ return formatter.header(value, config);
40
+ }
41
+ else if (isPrimitive && value !== undefined && typeof value !== 'function') {
42
+ // Use built-in rendering for primitives which applies standard syntax highlighting / theming.
43
+ // Can't do this for `undefined` however, as the browser thinks we forgot to provide an object.
44
+ // Also don't want to do this for functions which render nested expando arrows.
45
+ return ['object', { object: value }];
46
+ }
47
+ else {
48
+ return prettifyPreview(value);
49
+ }
50
+ })(),
51
+ ['span', {}, `)`],
52
+ ];
53
+ },
54
+ hasBody: (sig, config) => {
55
+ if (!isSignal(sig))
56
+ return false;
57
+ try {
58
+ sig();
59
+ }
60
+ catch {
61
+ return false;
62
+ }
63
+ return !config?.ngSkipFormatting;
64
+ },
65
+ body: (sig, config) => {
66
+ // We can use sys colors to fit the current DevTools theme.
67
+ // Those are unfortunately only available on Chromium-based browsers.
68
+ // On Firefow we fall back to the default color
69
+ const color = 'var(--sys-color-primary)';
70
+ return [
71
+ 'div',
72
+ { style: `background: #FFFFFF10; padding-left: 4px; padding-top: 2px; padding-bottom: 2px;` },
73
+ ['div', { style: `color: ${color}` }, 'Signal value: '],
74
+ ['div', { style: `padding-left: .5rem;` }, ['object', { object: sig(), config }]],
75
+ ['div', { style: `color: ${color}` }, 'Signal function: '],
76
+ [
77
+ 'div',
78
+ { style: `padding-left: .5rem;` },
79
+ ['object', { object: sig, config: { ...config, ngSkipFormatting: true } }],
80
+ ],
81
+ ];
82
+ },
83
+ };
84
+ function prettifyPreview(value) {
85
+ if (value === null)
86
+ return 'null';
87
+ if (Array.isArray(value))
88
+ return `Array(${value.length})`;
89
+ if (value instanceof Element)
90
+ return `<${value.tagName.toLowerCase()}>`;
91
+ if (value instanceof URL)
92
+ return `URL`;
93
+ switch (typeof value) {
94
+ case 'undefined': {
95
+ return 'undefined';
96
+ }
97
+ case 'function': {
98
+ if ('prototype' in value) {
99
+ // This is what Chrome renders, can't use `object` though because it creates a nested expando arrow.
100
+ return 'class';
101
+ }
102
+ else {
103
+ return '() => {…}';
104
+ }
105
+ }
106
+ case 'object': {
107
+ if (value.constructor.name === 'Object') {
108
+ return '{…}';
109
+ }
110
+ else {
111
+ return `${value.constructor.name} {}`;
112
+ }
113
+ }
114
+ default: {
115
+ return ['object', { object: value, config: { ngSkipFormatting: true } }];
116
+ }
117
+ }
118
+ }
119
+ function isSignal(value) {
120
+ return value[SIGNAL] !== undefined;
121
+ }
122
+ /**
123
+ * Installs the custom formatter into custom formatting on Signals in the devtools.
124
+ *
125
+ * Supported by both Chrome and Firefox.
126
+ *
127
+ * @see https://firefox-source-docs.mozilla.org/devtools-user/custom_formatters/index.html
128
+ */
129
+ export function installDevToolsSignalFormatter() {
130
+ globalThis.devtoolsFormatters ??= [];
131
+ if (!globalThis.devtoolsFormatters.some((f) => f === formatter)) {
132
+ globalThis.devtoolsFormatters.push(formatter);
133
+ }
134
+ }
135
+ // This fixes the RollupError: Exported variable "global" is not defined.
136
+ export {};
@@ -1,8 +1,16 @@
1
- import { SIGNAL } from '../symbol.js';
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 { SIGNAL } from '../../symbol.js';
2
9
  export { SIGNAL };
3
- type Version = number & {
10
+ export type Version = number & {
4
11
  __brand: 'Version';
5
12
  };
13
+ export type ReactiveHookFn = (node: ReactiveNode) => void;
6
14
  export declare function setActiveConsumer(consumer: ReactiveNode | null): ReactiveNode | null;
7
15
  export declare function getActiveConsumer(): ReactiveNode | null;
8
16
  export declare function isInNotificationPhase(): boolean;
@@ -11,6 +19,15 @@ export interface Reactive {
11
19
  }
12
20
  export declare function isReactive(value: unknown): value is Reactive;
13
21
  export declare const REACTIVE_NODE: ReactiveNode;
22
+ interface ReactiveLink {
23
+ producer: ReactiveNode;
24
+ consumer: ReactiveNode;
25
+ lastReadVersion: number;
26
+ prevConsumer: ReactiveLink | undefined;
27
+ nextConsumer: ReactiveLink | undefined;
28
+ nextProducer: ReactiveLink | undefined;
29
+ }
30
+ export type ReactiveNodeKind = 'signal' | 'computed' | 'effect' | 'template' | 'linkedSignal' | 'afterRenderEffectPhase' | 'unknown';
14
31
  /**
15
32
  * A producer and/or consumer which participates in the reactive graph.
16
33
  *
@@ -46,47 +63,26 @@ export interface ReactiveNode {
46
63
  */
47
64
  dirty: boolean;
48
65
  /**
49
- * Producers which are dependencies of this consumer.
50
- *
51
- * Uses the same indices as the `producerLastReadVersion` and `producerIndexOfThis` arrays.
52
- */
53
- producerNode: ReactiveNode[] | undefined;
54
- /**
55
- * `Version` of the value last read by a given producer.
56
- *
57
- * Uses the same indices as the `producerNode` and `producerIndexOfThis` arrays.
58
- */
59
- producerLastReadVersion: Version[] | undefined;
60
- /**
61
- * Index of `this` (consumer) in each producer's `liveConsumers` array.
62
- *
63
- * This value is only meaningful if this node is live (`liveConsumers.length > 0`). Otherwise
64
- * these indices are stale.
65
- *
66
- * Uses the same indices as the `producerNode` and `producerLastReadVersion` arrays.
66
+ * Whether this node is currently rebuilding its producer list.
67
67
  */
68
- producerIndexOfThis: number[] | undefined;
68
+ recomputing: boolean;
69
69
  /**
70
- * Index into the producer arrays that the next dependency of this node as a consumer will use.
71
- *
72
- * This index is zeroed before this node as a consumer begins executing. When a producer is read,
73
- * it gets inserted into the producers arrays at this index. There may be an existing dependency
74
- * in this location which may or may not match the incoming producer, depending on whether the
75
- * same producers were read in the same order as the last computation.
70
+ * Producers which are dependencies of this consumer.
76
71
  */
77
- nextProducerIndex: number;
72
+ producers: ReactiveLink | undefined;
78
73
  /**
79
- * Array of consumers of this producer that are "live" (they require push notifications).
74
+ * Points to the last linked list node in the `producers` linked list.
80
75
  *
81
- * `liveConsumerNode.length` is effectively our reference count for this node.
76
+ * When this node is recomputing, this is used to track the producers that we have accessed so far.
82
77
  */
83
- liveConsumerNode: ReactiveNode[] | undefined;
78
+ producersTail: ReactiveLink | undefined;
84
79
  /**
85
- * Index of `this` (producer) in each consumer's `producerNode` array.
80
+ * Linked list of consumers of this producer that are "live" (they require push notifications).
86
81
  *
87
- * Uses the same indices as the `liveConsumerNode` array.
82
+ * The length of this list is effectively our reference count for this node.
88
83
  */
89
- liveConsumerIndexOfThis: number[] | undefined;
84
+ consumers: ReactiveLink | undefined;
85
+ consumersTail: ReactiveLink | undefined;
90
86
  /**
91
87
  * Whether writes to signals are allowed when this consumer is the `activeConsumer`.
92
88
  *
@@ -106,6 +102,19 @@ export interface ReactiveNode {
106
102
  * Called when a signal is read within this consumer.
107
103
  */
108
104
  consumerOnSignalRead(node: unknown): void;
105
+ /**
106
+ * A debug name for the reactive node. Used in Angular DevTools to identify the node.
107
+ */
108
+ debugName?: string;
109
+ /**
110
+ * Kind of node. Example: 'signal', 'computed', 'input', 'effect'.
111
+ *
112
+ * ReactiveNode has this as 'unknown' by default, but derived node types should override this to
113
+ * make available the kind of signal that particular instance of a ReactiveNode represents.
114
+ *
115
+ * Used in Angular DevTools to identify the kind of signal.
116
+ */
117
+ kind: ReactiveNodeKind;
109
118
  }
110
119
  /**
111
120
  * Called by implementations when a producer's signal is read.
@@ -131,20 +140,41 @@ export declare function producerNotifyConsumers(node: ReactiveNode): void;
131
140
  */
132
141
  export declare function producerUpdatesAllowed(): boolean;
133
142
  export declare function consumerMarkDirty(node: ReactiveNode): void;
143
+ export declare function producerMarkClean(node: ReactiveNode): void;
134
144
  /**
135
- * Prepare this consumer to run a computation in its reactive context.
145
+ * Prepare this consumer to run a computation in its reactive context and set
146
+ * it as the active consumer.
136
147
  *
137
148
  * Must be called by subclasses which represent reactive computations, before those computations
138
149
  * begin.
139
150
  */
140
151
  export declare function consumerBeforeComputation(node: ReactiveNode | null): ReactiveNode | null;
141
152
  /**
142
- * Finalize this consumer's state after a reactive computation has run.
153
+ * Prepare this consumer to run a computation in its reactive context.
154
+ *
155
+ * We expose this mainly for code where we manually batch effects into a single
156
+ * consumer. In those cases we may wish to "reopen" a consumer multiple times
157
+ * in initial render before finalizing it. Most code should just call
158
+ * `consumerBeforeComputation` instead of calling this directly.
159
+ */
160
+ export declare function resetConsumerBeforeComputation(node: ReactiveNode): void;
161
+ /**
162
+ * Finalize this consumer's state and set previous consumer as the active consumer after a
163
+ * reactive computation has run.
143
164
  *
144
165
  * Must be called by subclasses which represent reactive computations, after those computations
145
166
  * have finished.
146
167
  */
147
168
  export declare function consumerAfterComputation(node: ReactiveNode | null, prevConsumer: ReactiveNode | null): void;
169
+ /**
170
+ * Finalize this consumer's state after a reactive computation has run.
171
+ *
172
+ * We expose this mainly for code where we manually batch effects into a single
173
+ * consumer. In those cases we may wish to "reopen" a consumer multiple times
174
+ * in initial render before finalizing it. Most code should just call
175
+ * `consumerAfterComputation` instead of calling this directly.
176
+ */
177
+ export declare function finalizeConsumerAfterComputation(node: ReactiveNode): void;
148
178
  /**
149
179
  * Determine whether this consumer has any dependencies which have changed since the last time
150
180
  * they were read.
@@ -154,3 +184,5 @@ export declare function consumerPollProducersForChange(node: ReactiveNode): bool
154
184
  * Disconnect this consumer from the graph.
155
185
  */
156
186
  export declare function consumerDestroy(node: ReactiveNode): void;
187
+ export declare function runPostProducerCreatedFn(node: ReactiveNode): void;
188
+ export declare function setPostProducerCreatedFn(fn: ReactiveHookFn | null): ReactiveHookFn | null;
@@ -0,0 +1,386 @@
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
+ export { SIGNAL };
11
+ /**
12
+ * The currently active consumer `ReactiveNode`, if running code in a reactive context.
13
+ *
14
+ * Change this via `setActiveConsumer`.
15
+ */
16
+ let activeConsumer = null;
17
+ let inNotificationPhase = false;
18
+ /**
19
+ * Global epoch counter. Incremented whenever a source signal is set.
20
+ */
21
+ let epoch = 1;
22
+ /**
23
+ * If set, called after a producer `ReactiveNode` is created.
24
+ */
25
+ let postProducerCreatedFn = null;
26
+ export function setActiveConsumer(consumer) {
27
+ const prev = activeConsumer;
28
+ activeConsumer = consumer;
29
+ return prev;
30
+ }
31
+ export function getActiveConsumer() {
32
+ return activeConsumer;
33
+ }
34
+ export function isInNotificationPhase() {
35
+ return inNotificationPhase;
36
+ }
37
+ export function isReactive(value) {
38
+ return value[SIGNAL] !== undefined;
39
+ }
40
+ export const REACTIVE_NODE = {
41
+ version: 0,
42
+ lastCleanEpoch: 0,
43
+ dirty: false,
44
+ producers: undefined,
45
+ producersTail: undefined,
46
+ consumers: undefined,
47
+ consumersTail: undefined,
48
+ recomputing: false,
49
+ consumerAllowSignalWrites: false,
50
+ consumerIsAlwaysLive: false,
51
+ kind: 'unknown',
52
+ producerMustRecompute: () => false,
53
+ producerRecomputeValue: () => { },
54
+ consumerMarkedDirty: () => { },
55
+ consumerOnSignalRead: () => { },
56
+ };
57
+ /**
58
+ * Called by implementations when a producer's signal is read.
59
+ */
60
+ export function producerAccessed(node) {
61
+ if (inNotificationPhase) {
62
+ throw new Error(isDevMode()
63
+ ? `Assertion error: signal read during notification phase`
64
+ : '');
65
+ }
66
+ if (activeConsumer === null) {
67
+ // Accessed outside of a reactive context, so nothing to record.
68
+ return;
69
+ }
70
+ activeConsumer.consumerOnSignalRead(node);
71
+ const prevProducerLink = activeConsumer.producersTail;
72
+ // If the last producer we accessed is the same as the current one, we can skip adding a new
73
+ // link
74
+ if (prevProducerLink !== undefined && prevProducerLink.producer === node) {
75
+ return;
76
+ }
77
+ let nextProducerLink = undefined;
78
+ const isRecomputing = activeConsumer.recomputing;
79
+ if (isRecomputing) {
80
+ // If we're incrementally rebuilding the producers list, we want to check if the next producer
81
+ // in the list is the same as the one we're trying to add.
82
+ // If the previous producer is defined, then the next producer is just the one that follows it.
83
+ // Otherwise, we should check the head of the producers list (the first node that we accessed the last time this consumer was run).
84
+ nextProducerLink =
85
+ prevProducerLink !== undefined ? prevProducerLink.nextProducer : activeConsumer.producers;
86
+ if (nextProducerLink !== undefined && nextProducerLink.producer === node) {
87
+ // If the next producer is the same as the one we're trying to add, we can just update the
88
+ // last read version, update the tail of the producers list of this rerun, and return.
89
+ activeConsumer.producersTail = nextProducerLink;
90
+ nextProducerLink.lastReadVersion = node.version;
91
+ return;
92
+ }
93
+ }
94
+ const prevConsumerLink = node.consumersTail;
95
+ // If the producer we're accessing already has a link to this consumer, we can skip adding a new
96
+ // link. This can short circuit the creation of a new link in the case where the consumer reads alternating ReeactiveNodes
97
+ if (prevConsumerLink !== undefined &&
98
+ prevConsumerLink.consumer === activeConsumer &&
99
+ // However, we have to make sure that the link we've discovered isn't from a node that is incrementally rebuilding its producer list
100
+ (!isRecomputing || isValidLink(prevConsumerLink, activeConsumer))) {
101
+ // If we found an existing link to the consumer we can just return.
102
+ return;
103
+ }
104
+ // If we got here, it means that we need to create a new link between the producer and the consumer.
105
+ const isLive = consumerIsLive(activeConsumer);
106
+ const newLink = {
107
+ producer: node,
108
+ consumer: activeConsumer,
109
+ // instead of eagerly destroying the previous link, we delay until we've finished recomputing
110
+ // the producers list, so that we can destroy all of the old links at once.
111
+ nextProducer: nextProducerLink,
112
+ prevConsumer: prevConsumerLink,
113
+ lastReadVersion: node.version,
114
+ nextConsumer: undefined,
115
+ };
116
+ activeConsumer.producersTail = newLink;
117
+ if (prevProducerLink !== undefined) {
118
+ prevProducerLink.nextProducer = newLink;
119
+ }
120
+ else {
121
+ activeConsumer.producers = newLink;
122
+ }
123
+ if (isLive) {
124
+ producerAddLiveConsumer(node, newLink);
125
+ }
126
+ }
127
+ /**
128
+ * Increment the global epoch counter.
129
+ *
130
+ * Called by source producers (that is, not computeds) whenever their values change.
131
+ */
132
+ export function producerIncrementEpoch() {
133
+ epoch++;
134
+ }
135
+ /**
136
+ * Ensure this producer's `version` is up-to-date.
137
+ */
138
+ export function producerUpdateValueVersion(node) {
139
+ if (consumerIsLive(node) && !node.dirty) {
140
+ // A live consumer will be marked dirty by producers, so a clean state means that its version
141
+ // is guaranteed to be up-to-date.
142
+ return;
143
+ }
144
+ if (!node.dirty && node.lastCleanEpoch === epoch) {
145
+ // Even non-live consumers can skip polling if they previously found themselves to be clean at
146
+ // the current epoch, since their dependencies could not possibly have changed (such a change
147
+ // would've increased the epoch).
148
+ return;
149
+ }
150
+ if (!node.producerMustRecompute(node) && !consumerPollProducersForChange(node)) {
151
+ // None of our producers report a change since the last time they were read, so no
152
+ // recomputation of our value is necessary, and we can consider ourselves clean.
153
+ producerMarkClean(node);
154
+ return;
155
+ }
156
+ node.producerRecomputeValue(node);
157
+ // After recomputing the value, we're no longer dirty.
158
+ producerMarkClean(node);
159
+ }
160
+ /**
161
+ * Propagate a dirty notification to live consumers of this producer.
162
+ */
163
+ export function producerNotifyConsumers(node) {
164
+ if (node.consumers === undefined) {
165
+ return;
166
+ }
167
+ // Prevent signal reads when we're updating the graph
168
+ const prev = inNotificationPhase;
169
+ inNotificationPhase = true;
170
+ try {
171
+ for (let link = node.consumers; link !== undefined; link = link.nextConsumer) {
172
+ const consumer = link.consumer;
173
+ if (!consumer.dirty) {
174
+ consumerMarkDirty(consumer);
175
+ }
176
+ }
177
+ }
178
+ finally {
179
+ inNotificationPhase = prev;
180
+ }
181
+ }
182
+ /**
183
+ * Whether this `ReactiveNode` in its producer capacity is currently allowed to initiate updates,
184
+ * based on the current consumer context.
185
+ */
186
+ export function producerUpdatesAllowed() {
187
+ return activeConsumer?.consumerAllowSignalWrites !== false;
188
+ }
189
+ export function consumerMarkDirty(node) {
190
+ node.dirty = true;
191
+ producerNotifyConsumers(node);
192
+ node.consumerMarkedDirty?.(node);
193
+ }
194
+ export function producerMarkClean(node) {
195
+ node.dirty = false;
196
+ node.lastCleanEpoch = epoch;
197
+ }
198
+ /**
199
+ * Prepare this consumer to run a computation in its reactive context and set
200
+ * it as the active consumer.
201
+ *
202
+ * Must be called by subclasses which represent reactive computations, before those computations
203
+ * begin.
204
+ */
205
+ export function consumerBeforeComputation(node) {
206
+ if (node)
207
+ resetConsumerBeforeComputation(node);
208
+ return setActiveConsumer(node);
209
+ }
210
+ /**
211
+ * Prepare this consumer to run a computation in its reactive context.
212
+ *
213
+ * We expose this mainly for code where we manually batch effects into a single
214
+ * consumer. In those cases we may wish to "reopen" a consumer multiple times
215
+ * in initial render before finalizing it. Most code should just call
216
+ * `consumerBeforeComputation` instead of calling this directly.
217
+ */
218
+ export function resetConsumerBeforeComputation(node) {
219
+ node.producersTail = undefined;
220
+ node.recomputing = true;
221
+ }
222
+ /**
223
+ * Finalize this consumer's state and set previous consumer as the active consumer after a
224
+ * reactive computation has run.
225
+ *
226
+ * Must be called by subclasses which represent reactive computations, after those computations
227
+ * have finished.
228
+ */
229
+ export function consumerAfterComputation(node, prevConsumer) {
230
+ setActiveConsumer(prevConsumer);
231
+ if (node)
232
+ finalizeConsumerAfterComputation(node);
233
+ }
234
+ /**
235
+ * Finalize this consumer's state after a reactive computation has run.
236
+ *
237
+ * We expose this mainly for code where we manually batch effects into a single
238
+ * consumer. In those cases we may wish to "reopen" a consumer multiple times
239
+ * in initial render before finalizing it. Most code should just call
240
+ * `consumerAfterComputation` instead of calling this directly.
241
+ */
242
+ export function finalizeConsumerAfterComputation(node) {
243
+ node.recomputing = false;
244
+ // We've finished incrementally rebuilding the producers list, now if there are any producers
245
+ // that are after producersTail, they are stale and should be removed.
246
+ const producersTail = node.producersTail;
247
+ let toRemove = producersTail !== undefined ? producersTail.nextProducer : node.producers;
248
+ if (toRemove !== undefined) {
249
+ if (consumerIsLive(node)) {
250
+ // For each stale link, we first unlink it from the producers list of consumers
251
+ do {
252
+ toRemove = producerRemoveLiveConsumerLink(toRemove);
253
+ } while (toRemove !== undefined);
254
+ }
255
+ // Now, we can truncate the producers list to remove all stale links.
256
+ if (producersTail !== undefined) {
257
+ producersTail.nextProducer = undefined;
258
+ }
259
+ else {
260
+ node.producers = undefined;
261
+ }
262
+ }
263
+ }
264
+ /**
265
+ * Determine whether this consumer has any dependencies which have changed since the last time
266
+ * they were read.
267
+ */
268
+ export function consumerPollProducersForChange(node) {
269
+ // Poll producers for change.
270
+ for (let link = node.producers; link !== undefined; link = link.nextProducer) {
271
+ const producer = link.producer;
272
+ const seenVersion = link.lastReadVersion;
273
+ // First check the versions. A mismatch means that the producer's value is known to have
274
+ // changed since the last time we read it.
275
+ if (seenVersion !== producer.version) {
276
+ return true;
277
+ }
278
+ // The producer's version is the same as the last time we read it, but it might itself be
279
+ // stale. Force the producer to recompute its version (calculating a new value if necessary).
280
+ producerUpdateValueVersion(producer);
281
+ // Now when we do this check, `producer.version` is guaranteed to be up to date, so if the
282
+ // versions still match then it has not changed since the last time we read it.
283
+ if (seenVersion !== producer.version) {
284
+ return true;
285
+ }
286
+ }
287
+ return false;
288
+ }
289
+ /**
290
+ * Disconnect this consumer from the graph.
291
+ */
292
+ export function consumerDestroy(node) {
293
+ if (consumerIsLive(node)) {
294
+ // Drop all connections from the graph to this node.
295
+ let link = node.producers;
296
+ while (link !== undefined) {
297
+ link = producerRemoveLiveConsumerLink(link);
298
+ }
299
+ }
300
+ // Truncate all the linked lists to drop all connection from this node to the graph.
301
+ node.producers = undefined;
302
+ node.producersTail = undefined;
303
+ node.consumers = undefined;
304
+ node.consumersTail = undefined;
305
+ }
306
+ /**
307
+ * Add `consumer` as a live consumer of this node.
308
+ *
309
+ * Note that this operation is potentially transitive. If this node becomes live, then it becomes
310
+ * a live consumer of all of its current producers.
311
+ */
312
+ function producerAddLiveConsumer(node, link) {
313
+ const consumersTail = node.consumersTail;
314
+ const wasLive = consumerIsLive(node);
315
+ if (consumersTail !== undefined) {
316
+ link.nextConsumer = consumersTail.nextConsumer;
317
+ consumersTail.nextConsumer = link;
318
+ }
319
+ else {
320
+ link.nextConsumer = undefined;
321
+ node.consumers = link;
322
+ }
323
+ link.prevConsumer = consumersTail;
324
+ node.consumersTail = link;
325
+ if (!wasLive) {
326
+ for (let link = node.producers; link !== undefined; link = link.nextProducer) {
327
+ producerAddLiveConsumer(link.producer, link);
328
+ }
329
+ }
330
+ }
331
+ function producerRemoveLiveConsumerLink(link) {
332
+ const producer = link.producer;
333
+ const nextProducer = link.nextProducer;
334
+ const nextConsumer = link.nextConsumer;
335
+ const prevConsumer = link.prevConsumer;
336
+ link.nextConsumer = undefined;
337
+ link.prevConsumer = undefined;
338
+ if (nextConsumer !== undefined) {
339
+ nextConsumer.prevConsumer = prevConsumer;
340
+ }
341
+ else {
342
+ producer.consumersTail = prevConsumer;
343
+ }
344
+ if (prevConsumer !== undefined) {
345
+ prevConsumer.nextConsumer = nextConsumer;
346
+ }
347
+ else {
348
+ producer.consumers = nextConsumer;
349
+ if (!consumerIsLive(producer)) {
350
+ let producerLink = producer.producers;
351
+ while (producerLink !== undefined) {
352
+ producerLink = producerRemoveLiveConsumerLink(producerLink);
353
+ }
354
+ }
355
+ }
356
+ return nextProducer;
357
+ }
358
+ function consumerIsLive(node) {
359
+ return node.consumerIsAlwaysLive || node.consumers !== undefined;
360
+ }
361
+ export function runPostProducerCreatedFn(node) {
362
+ postProducerCreatedFn?.(node);
363
+ }
364
+ export function setPostProducerCreatedFn(fn) {
365
+ const prev = postProducerCreatedFn;
366
+ postProducerCreatedFn = fn;
367
+ return prev;
368
+ }
369
+ // While a ReactiveNode is recomputing, it may not have destroyed previous links
370
+ // This allows us to check if a given link will be destroyed by a reactivenode if it were to finish running immediately without accesing any more producers
371
+ function isValidLink(checkLink, consumer) {
372
+ const producersTail = consumer.producersTail;
373
+ if (producersTail !== undefined) {
374
+ let link = consumer.producers;
375
+ do {
376
+ if (link === checkLink) {
377
+ return true;
378
+ }
379
+ if (link === producersTail) {
380
+ break;
381
+ }
382
+ link = link.nextProducer;
383
+ } while (link !== undefined);
384
+ }
385
+ return false;
386
+ }