@adobe/data 0.5.3 → 0.5.5

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 (366) hide show
  1. package/dist/ecs/database/create-database.d.ts +2 -2
  2. package/dist/ecs/database/database-schema/create-database-schema-test.d.ts +1 -0
  3. package/dist/ecs/database/database-schema/create-database-schema-test.js +42 -0
  4. package/dist/ecs/database/database-schema/create-database-schema-test.js.map +1 -0
  5. package/dist/ecs/database/database-schema/create-database-schema.d.ts +14 -0
  6. package/dist/ecs/database/database-schema/create-database-schema.js +32 -0
  7. package/dist/ecs/database/database-schema/create-database-schema.js.map +1 -0
  8. package/dist/ecs/database/database-schema/database-schema.d.ts +13 -0
  9. package/dist/ecs/database/database-schema/database-schema.js +23 -0
  10. package/dist/ecs/database/database-schema/database-schema.js.map +1 -0
  11. package/dist/ecs/database/database-schema/index.d.ts +2 -0
  12. package/dist/{services → ecs/database/database-schema}/index.js +2 -3
  13. package/dist/ecs/database/database-schema/index.js.map +1 -0
  14. package/dist/ecs/database/database.d.ts +3 -1
  15. package/dist/ecs/database/index.d.ts +1 -0
  16. package/dist/ecs/database/index.js +1 -0
  17. package/dist/ecs/database/index.js.map +1 -1
  18. package/dist/ecs/index.d.ts +2 -1
  19. package/dist/ecs/index.js +2 -1
  20. package/dist/ecs/index.js.map +1 -1
  21. package/dist/ecs/store/archetype-components.d.ts +3 -1
  22. package/dist/ecs/store/core/core.d.ts +1 -8
  23. package/dist/ecs/store/core/create-core.js +9 -4
  24. package/dist/ecs/store/core/create-core.js.map +1 -1
  25. package/dist/ecs/store/core/create-core.test.js +0 -109
  26. package/dist/ecs/store/core/create-core.test.js.map +1 -1
  27. package/dist/ecs/store/create-store.js +21 -0
  28. package/dist/ecs/store/create-store.js.map +1 -1
  29. package/dist/ecs/store/store-schema/create-store-schema-test.js +4 -7
  30. package/dist/ecs/store/store-schema/create-store-schema-test.js.map +1 -1
  31. package/dist/ecs/store/store-schema/create-store-schema.d.ts +2 -0
  32. package/dist/ecs/store/store-schema/create-store-schema.js +5 -0
  33. package/dist/ecs/store/store-schema/create-store-schema.js.map +1 -1
  34. package/dist/ecs/store/store-schema/index.d.ts +1 -1
  35. package/dist/ecs/store/store-schema/index.js +1 -1
  36. package/dist/ecs/store/store-schema/index.js.map +1 -1
  37. package/dist/ecs/store/store-schema/store-schema.d.ts +1 -1
  38. package/dist/ecs/world/create-world.d.ts +7 -0
  39. package/dist/ecs/world/create-world.js +108 -0
  40. package/dist/ecs/world/create-world.js.map +1 -0
  41. package/dist/ecs/world/create-world.test.d.ts +1 -0
  42. package/dist/ecs/world/create-world.test.js +499 -0
  43. package/dist/ecs/world/create-world.test.js.map +1 -0
  44. package/dist/ecs/world/index.d.ts +4 -0
  45. package/dist/ecs/world/index.js +26 -0
  46. package/dist/ecs/world/index.js.map +1 -0
  47. package/dist/ecs/world/system.d.ts +20 -0
  48. package/dist/ecs/world/system.js +2 -0
  49. package/dist/ecs/world/system.js.map +1 -0
  50. package/dist/ecs/world/world-schema/create-world-schema-test.d.ts +1 -0
  51. package/dist/ecs/world/world-schema/create-world-schema-test.js +55 -0
  52. package/dist/ecs/world/world-schema/create-world-schema-test.js.map +1 -0
  53. package/dist/ecs/world/world-schema/create-world-schema.d.ts +19 -0
  54. package/dist/ecs/world/world-schema/create-world-schema.js +33 -0
  55. package/dist/ecs/world/world-schema/create-world-schema.js.map +1 -0
  56. package/dist/ecs/world/world-schema/index.d.ts +2 -0
  57. package/dist/ecs/world/world-schema/index.js +24 -0
  58. package/dist/ecs/world/world-schema/index.js.map +1 -0
  59. package/dist/ecs/world/world-schema/world-schema.d.ts +18 -0
  60. package/dist/ecs/world/world-schema/world-schema.js +23 -0
  61. package/dist/ecs/world/world-schema/world-schema.js.map +1 -0
  62. package/dist/ecs/world/world.d.ts +9 -0
  63. package/dist/ecs/world/world.js +2 -0
  64. package/dist/ecs/world/world.js.map +1 -0
  65. package/dist/functions/serialization/serialization.test.js +78 -0
  66. package/dist/functions/serialization/serialization.test.js.map +1 -1
  67. package/dist/graphics/camera/camera.d.ts +62 -0
  68. package/dist/graphics/camera/camera.js +17 -0
  69. package/dist/graphics/camera/camera.js.map +1 -0
  70. package/dist/graphics/camera/index.d.ts +4 -0
  71. package/dist/graphics/camera/index.js +5 -0
  72. package/dist/graphics/camera/index.js.map +1 -0
  73. package/dist/graphics/camera/screen-to-world-ray.d.ts +12 -0
  74. package/dist/graphics/camera/screen-to-world-ray.js +49 -0
  75. package/dist/graphics/camera/screen-to-world-ray.js.map +1 -0
  76. package/dist/graphics/camera/screen-to-world-ray.test.d.ts +1 -0
  77. package/dist/graphics/camera/screen-to-world-ray.test.js +171 -0
  78. package/dist/graphics/camera/screen-to-world-ray.test.js.map +1 -0
  79. package/dist/graphics/camera/to-view-projection.d.ts +3 -0
  80. package/dist/graphics/camera/to-view-projection.js +8 -0
  81. package/dist/graphics/camera/to-view-projection.js.map +1 -0
  82. package/dist/graphics/camera/world-to-screen.d.ts +12 -0
  83. package/dist/graphics/camera/world-to-screen.js +38 -0
  84. package/dist/graphics/camera/world-to-screen.js.map +1 -0
  85. package/dist/graphics/camera/world-to-screen.test.d.ts +1 -0
  86. package/dist/graphics/camera/world-to-screen.test.js +124 -0
  87. package/dist/graphics/camera/world-to-screen.test.js.map +1 -0
  88. package/dist/graphics/create-struct-gpu-buffer.d.ts +7 -0
  89. package/dist/graphics/create-struct-gpu-buffer.js +17 -0
  90. package/dist/graphics/create-struct-gpu-buffer.js.map +1 -0
  91. package/dist/graphics/extract-wgsl-bindings.d.ts +5 -0
  92. package/dist/graphics/extract-wgsl-bindings.js +10 -0
  93. package/dist/graphics/extract-wgsl-bindings.js.map +1 -0
  94. package/dist/graphics/frame.d.ts +22 -0
  95. package/dist/graphics/frame.js +12 -0
  96. package/dist/graphics/frame.js.map +1 -0
  97. package/dist/graphics/get-web-gpu-device-and-context.d.ts +2 -0
  98. package/dist/graphics/get-web-gpu-device-and-context.js +21 -0
  99. package/dist/graphics/get-web-gpu-device-and-context.js.map +1 -0
  100. package/dist/graphics/graphics-context.d.ts +5 -0
  101. package/dist/graphics/graphics-context.js +2 -0
  102. package/dist/graphics/graphics-context.js.map +1 -0
  103. package/dist/graphics/index.d.ts +5 -0
  104. package/dist/graphics/index.js +5 -0
  105. package/dist/graphics/index.js.map +1 -0
  106. package/dist/graphics/to-gpu-buffer.d.ts +2 -0
  107. package/dist/graphics/to-gpu-buffer.js +14 -0
  108. package/dist/graphics/to-gpu-buffer.js.map +1 -0
  109. package/dist/internal/array/index.d.ts +1 -0
  110. package/dist/internal/array/index.js +23 -0
  111. package/dist/internal/array/index.js.map +1 -0
  112. package/dist/internal/array/topological-sort.d.ts +26 -0
  113. package/dist/internal/array/topological-sort.js +79 -0
  114. package/dist/internal/array/topological-sort.js.map +1 -0
  115. package/dist/internal/array/topological-sort.test.d.ts +1 -0
  116. package/dist/internal/array/topological-sort.test.js +100 -0
  117. package/dist/internal/array/topological-sort.test.js.map +1 -0
  118. package/dist/internal/function/debounce.d.ts +70 -0
  119. package/dist/internal/function/debounce.js +155 -0
  120. package/dist/internal/function/debounce.js.map +1 -0
  121. package/dist/internal/function/debounce.test.d.ts +1 -0
  122. package/dist/internal/function/debounce.test.js +306 -0
  123. package/dist/internal/function/debounce.test.js.map +1 -0
  124. package/dist/lit/elements/application-element.d.ts +9 -0
  125. package/dist/lit/elements/application-element.js +62 -0
  126. package/dist/lit/elements/application-element.js.map +1 -0
  127. package/dist/lit/elements/application-host.d.ts +16 -0
  128. package/dist/lit/elements/application-host.js +59 -0
  129. package/dist/lit/elements/application-host.js.map +1 -0
  130. package/dist/lit/elements/index.d.ts +2 -0
  131. package/dist/lit/elements/index.js +2 -0
  132. package/dist/lit/elements/index.js.map +1 -1
  133. package/dist/lit/elements/service-application.js +4 -1
  134. package/dist/lit/elements/service-application.js.map +1 -1
  135. package/dist/lit/functions/index.d.ts +1 -0
  136. package/dist/lit/functions/index.js +23 -0
  137. package/dist/lit/functions/index.js.map +1 -0
  138. package/dist/lit/functions/iterate-self-and-ancestors.d.ts +1 -0
  139. package/dist/lit/functions/iterate-self-and-ancestors.js +44 -0
  140. package/dist/lit/functions/iterate-self-and-ancestors.js.map +1 -0
  141. package/dist/lit/hooks/attach-decorator.d.ts +4 -0
  142. package/dist/lit/hooks/attach-decorator.js +46 -0
  143. package/dist/lit/hooks/attach-decorator.js.map +1 -0
  144. package/dist/lit/hooks/index.d.ts +4 -0
  145. package/dist/lit/hooks/index.js +4 -0
  146. package/dist/lit/hooks/index.js.map +1 -1
  147. package/dist/lit/hooks/use-drag-observe.d.ts +22 -0
  148. package/dist/lit/hooks/use-drag-observe.js +55 -0
  149. package/dist/lit/hooks/use-drag-observe.js.map +1 -0
  150. package/dist/lit/hooks/use-drag-transaction.d.ts +7 -0
  151. package/dist/lit/hooks/use-drag-transaction.js +56 -0
  152. package/dist/lit/hooks/use-drag-transaction.js.map +1 -0
  153. package/dist/lit/hooks/use-draggable.d.ts +16 -0
  154. package/dist/lit/hooks/use-draggable.js +122 -0
  155. package/dist/lit/hooks/use-draggable.js.map +1 -0
  156. package/dist/math/aabb/aabb.d.ts +48 -0
  157. package/dist/math/aabb/aabb.js +86 -0
  158. package/dist/math/aabb/aabb.js.map +1 -0
  159. package/dist/math/aabb/line-intersection.test.d.ts +1 -0
  160. package/dist/math/aabb/line-intersection.test.js +210 -0
  161. package/dist/math/aabb/line-intersection.test.js.map +1 -0
  162. package/dist/math/constants.d.ts +4 -0
  163. package/dist/math/constants.js +26 -0
  164. package/dist/math/constants.js.map +1 -0
  165. package/dist/math/index.d.ts +18 -0
  166. package/dist/math/index.js +40 -0
  167. package/dist/math/index.js.map +1 -0
  168. package/dist/math/line2/intersects.test.d.ts +1 -0
  169. package/dist/math/line2/intersects.test.js +104 -0
  170. package/dist/math/line2/intersects.test.js.map +1 -0
  171. package/dist/math/line2/line2.d.ts +42 -0
  172. package/dist/math/line2/line2.js +78 -0
  173. package/dist/math/line2/line2.js.map +1 -0
  174. package/dist/math/line3/closest-point-on-line.test.d.ts +1 -0
  175. package/dist/math/line3/closest-point-on-line.test.js +107 -0
  176. package/dist/math/line3/closest-point-on-line.test.js.map +1 -0
  177. package/dist/math/line3/interpolate.test.d.ts +1 -0
  178. package/dist/math/line3/interpolate.test.js +66 -0
  179. package/dist/math/line3/interpolate.test.js.map +1 -0
  180. package/dist/math/line3/line3.d.ts +49 -0
  181. package/dist/math/line3/line3.js +77 -0
  182. package/dist/math/line3/line3.js.map +1 -0
  183. package/dist/math/line3/sub-line.test.d.ts +1 -0
  184. package/dist/math/line3/sub-line.test.js +70 -0
  185. package/dist/math/line3/sub-line.test.js.map +1 -0
  186. package/dist/math/mat4x4/mat4x4.d.ts +37 -0
  187. package/dist/math/mat4x4/mat4x4.js +246 -0
  188. package/dist/math/mat4x4/mat4x4.js.map +1 -0
  189. package/dist/math/picking/index.d.ts +1 -0
  190. package/dist/math/picking/index.js +23 -0
  191. package/dist/math/picking/index.js.map +1 -0
  192. package/dist/math/picking/pick-from-tables.d.ts +18 -0
  193. package/dist/math/picking/pick-from-tables.js +154 -0
  194. package/dist/math/picking/pick-from-tables.js.map +1 -0
  195. package/dist/math/picking/pick-result.d.ts +7 -0
  196. package/dist/{services/service.js → math/picking/pick-result.js} +1 -1
  197. package/dist/math/picking/pick-result.js.map +1 -0
  198. package/dist/math/quat/quat.d.ts +42 -0
  199. package/dist/math/quat/quat.js +220 -0
  200. package/dist/math/quat/quat.js.map +1 -0
  201. package/dist/math/vec2/vec2.d.ts +63 -0
  202. package/dist/math/vec2/vec2.js +114 -0
  203. package/dist/math/vec2/vec2.js.map +1 -0
  204. package/dist/math/vec3/vec3.d.ts +65 -0
  205. package/dist/math/vec3/vec3.js +154 -0
  206. package/dist/math/vec3/vec3.js.map +1 -0
  207. package/dist/math/vec4/vec4.d.ts +63 -0
  208. package/dist/math/vec4/vec4.js +154 -0
  209. package/dist/math/vec4/vec4.js.map +1 -0
  210. package/dist/observe/to-async-generator.js +4 -0
  211. package/dist/observe/to-async-generator.js.map +1 -1
  212. package/dist/observe/with-filter.d.ts +1 -1
  213. package/dist/observe/with-filter.js.map +1 -1
  214. package/dist/samples/index.d.ts +13 -0
  215. package/dist/samples/index.js +27 -0
  216. package/dist/samples/index.js.map +1 -0
  217. package/dist/samples/todo/elements/todo-list/todo-list-presentation.d.ts +25 -0
  218. package/dist/samples/todo/elements/todo-list/todo-list-presentation.js +12 -0
  219. package/dist/samples/todo/elements/todo-list/todo-list-presentation.js.map +1 -0
  220. package/dist/samples/todo/elements/todo-list/todo-list.css.d.ts +18 -0
  221. package/dist/samples/todo/elements/todo-list/todo-list.css.js +27 -0
  222. package/dist/samples/todo/elements/todo-list/todo-list.css.js.map +1 -0
  223. package/dist/samples/todo/elements/todo-list/todo-list.d.ts +12 -0
  224. package/dist/samples/todo/elements/todo-list/todo-list.js +60 -0
  225. package/dist/samples/todo/elements/todo-list/todo-list.js.map +1 -0
  226. package/dist/samples/todo/elements/todo-row/index.d.ts +18 -0
  227. package/dist/samples/todo/elements/todo-row/index.js +19 -0
  228. package/dist/samples/todo/elements/todo-row/index.js.map +1 -0
  229. package/dist/samples/todo/elements/todo-row/todo-row-presentation.d.ts +18 -0
  230. package/dist/samples/todo/elements/todo-row/todo-row-presentation.js +66 -0
  231. package/dist/samples/todo/elements/todo-row/todo-row-presentation.js.map +1 -0
  232. package/dist/samples/todo/elements/todo-row/todo-row.css.d.ts +1 -0
  233. package/dist/samples/todo/elements/todo-row/todo-row.css.js +65 -0
  234. package/dist/samples/todo/elements/todo-row/todo-row.css.js.map +1 -0
  235. package/dist/samples/todo/elements/todo-row/todo-row.d.ts +14 -0
  236. package/dist/samples/todo/elements/todo-row/todo-row.js +60 -0
  237. package/dist/samples/todo/elements/todo-row/todo-row.js.map +1 -0
  238. package/dist/samples/todo/elements/todo-toolbar/index.d.ts +18 -0
  239. package/dist/samples/todo/elements/todo-toolbar/index.js +19 -0
  240. package/dist/samples/todo/elements/todo-toolbar/index.js.map +1 -0
  241. package/dist/samples/todo/elements/todo-toolbar/todo-toolbar-presentation.d.ts +22 -0
  242. package/dist/samples/todo/elements/todo-toolbar/todo-toolbar-presentation.js +57 -0
  243. package/dist/samples/todo/elements/todo-toolbar/todo-toolbar-presentation.js.map +1 -0
  244. package/dist/samples/todo/elements/todo-toolbar/todo-toolbar.css.d.ts +1 -0
  245. package/dist/samples/todo/elements/todo-toolbar/todo-toolbar.css.js +50 -0
  246. package/dist/samples/todo/elements/todo-toolbar/todo-toolbar.css.js.map +1 -0
  247. package/dist/samples/todo/elements/todo-toolbar/todo-toolbar.d.ts +11 -0
  248. package/dist/samples/todo/elements/todo-toolbar/todo-toolbar.js +77 -0
  249. package/dist/samples/todo/elements/todo-toolbar/todo-toolbar.js.map +1 -0
  250. package/dist/samples/todo/elements/todo-undo-redo/index.d.ts +18 -0
  251. package/dist/samples/todo/elements/todo-undo-redo/index.js +19 -0
  252. package/dist/samples/todo/elements/todo-undo-redo/index.js.map +1 -0
  253. package/dist/samples/todo/elements/todo-undo-redo/todo-undo-redo-presentation.d.ts +17 -0
  254. package/dist/samples/todo/elements/todo-undo-redo/todo-undo-redo-presentation.js +45 -0
  255. package/dist/samples/todo/elements/todo-undo-redo/todo-undo-redo-presentation.js.map +1 -0
  256. package/dist/samples/todo/elements/todo-undo-redo/todo-undo-redo.css.d.ts +1 -0
  257. package/dist/samples/todo/elements/todo-undo-redo/todo-undo-redo.css.js +28 -0
  258. package/dist/samples/todo/elements/todo-undo-redo/todo-undo-redo.css.js.map +1 -0
  259. package/dist/samples/todo/elements/todo-undo-redo/todo-undo-redo.d.ts +11 -0
  260. package/dist/samples/todo/elements/todo-undo-redo/todo-undo-redo.js +52 -0
  261. package/dist/samples/todo/elements/todo-undo-redo/todo-undo-redo.js.map +1 -0
  262. package/dist/samples/todo/services/dependent-state-service/create-dependent-state-service.d.ts +6 -0
  263. package/dist/samples/todo/services/dependent-state-service/create-dependent-state-service.js +21 -0
  264. package/dist/samples/todo/services/dependent-state-service/create-dependent-state-service.js.map +1 -0
  265. package/dist/samples/todo/services/dependent-state-service/dependent-state/all-todos.d.ts +19 -0
  266. package/dist/samples/todo/services/dependent-state-service/dependent-state/all-todos.js +2 -0
  267. package/dist/samples/todo/services/dependent-state-service/dependent-state/all-todos.js.map +1 -0
  268. package/dist/samples/todo/services/dependent-state-service/dependent-state/complete-todos.d.ts +19 -0
  269. package/dist/samples/todo/services/dependent-state-service/dependent-state/complete-todos.js +2 -0
  270. package/dist/samples/todo/services/dependent-state-service/dependent-state/complete-todos.js.map +1 -0
  271. package/dist/samples/todo/services/dependent-state-service/dependent-state/incomplete-todos.d.ts +19 -0
  272. package/dist/samples/todo/services/dependent-state-service/dependent-state/incomplete-todos.js +2 -0
  273. package/dist/samples/todo/services/dependent-state-service/dependent-state/incomplete-todos.js.map +1 -0
  274. package/dist/samples/todo/services/dependent-state-service/dependent-state/index.d.ts +20 -0
  275. package/dist/samples/todo/services/dependent-state-service/dependent-state/index.js +21 -0
  276. package/dist/samples/todo/services/dependent-state-service/dependent-state/index.js.map +1 -0
  277. package/dist/samples/todo/services/dependent-state-service/dependent-state-service.d.ts +19 -0
  278. package/dist/samples/todo/services/dependent-state-service/dependent-state-service.js +2 -0
  279. package/dist/samples/todo/services/dependent-state-service/dependent-state-service.js.map +1 -0
  280. package/dist/samples/todo/services/main-service/create-main-service.d.ts +25 -0
  281. package/dist/samples/todo/services/main-service/create-main-service.js +39 -0
  282. package/dist/samples/todo/services/main-service/create-main-service.js.map +1 -0
  283. package/dist/samples/todo/services/main-service/todo-main-service.d.ts +35 -0
  284. package/dist/samples/todo/services/main-service/todo-main-service.js +2 -0
  285. package/dist/samples/todo/services/main-service/todo-main-service.js.map +1 -0
  286. package/dist/samples/todo/services/state-service/create-todo-database.d.ts +13 -0
  287. package/dist/samples/todo/services/state-service/create-todo-database.js +26 -0
  288. package/dist/samples/todo/services/state-service/create-todo-database.js.map +1 -0
  289. package/dist/samples/todo/services/state-service/create-todo-store.d.ts +13 -0
  290. package/dist/samples/todo/services/state-service/create-todo-store.js +41 -0
  291. package/dist/samples/todo/services/state-service/create-todo-store.js.map +1 -0
  292. package/dist/samples/todo/services/state-service/todo-state-service.d.ts +22 -0
  293. package/dist/samples/todo/services/state-service/todo-state-service.js +2 -0
  294. package/dist/samples/todo/services/state-service/todo-state-service.js.map +1 -0
  295. package/dist/samples/todo/services/state-service/transactions/create-bulk-todos.d.ts +2 -0
  296. package/dist/samples/todo/services/state-service/transactions/create-bulk-todos.js +26 -0
  297. package/dist/samples/todo/services/state-service/transactions/create-bulk-todos.js.map +1 -0
  298. package/dist/samples/todo/services/state-service/transactions/create-todo.d.ts +22 -0
  299. package/dist/samples/todo/services/state-service/transactions/create-todo.js +13 -0
  300. package/dist/samples/todo/services/state-service/transactions/create-todo.js.map +1 -0
  301. package/dist/samples/todo/services/state-service/transactions/create-todo.test.d.ts +1 -0
  302. package/dist/samples/todo/services/state-service/transactions/create-todo.test.js +32 -0
  303. package/dist/samples/todo/services/state-service/transactions/create-todo.test.js.map +1 -0
  304. package/dist/samples/todo/services/state-service/transactions/delete-all-todos.d.ts +19 -0
  305. package/dist/samples/todo/services/state-service/transactions/delete-all-todos.js +16 -0
  306. package/dist/samples/todo/services/state-service/transactions/delete-all-todos.js.map +1 -0
  307. package/dist/samples/todo/services/state-service/transactions/delete-todo.d.ts +3 -0
  308. package/dist/samples/todo/services/state-service/transactions/delete-todo.js +24 -0
  309. package/dist/samples/todo/services/state-service/transactions/delete-todo.js.map +1 -0
  310. package/dist/samples/todo/services/state-service/transactions/delete-todo.test.d.ts +1 -0
  311. package/dist/samples/todo/services/state-service/transactions/delete-todo.test.js +40 -0
  312. package/dist/samples/todo/services/state-service/transactions/delete-todo.test.js.map +1 -0
  313. package/dist/samples/todo/services/state-service/transactions/drag-todo.d.ts +7 -0
  314. package/dist/samples/todo/services/state-service/transactions/drag-todo.js +33 -0
  315. package/dist/samples/todo/services/state-service/transactions/drag-todo.js.map +1 -0
  316. package/dist/samples/todo/services/state-service/transactions/index.d.ts +23 -0
  317. package/dist/samples/todo/services/state-service/transactions/index.js +25 -0
  318. package/dist/samples/todo/services/state-service/transactions/index.js.map +1 -0
  319. package/dist/samples/todo/services/state-service/transactions/reorder-todos.d.ts +23 -0
  320. package/dist/samples/todo/services/state-service/transactions/reorder-todos.js +11 -0
  321. package/dist/samples/todo/services/state-service/transactions/reorder-todos.js.map +1 -0
  322. package/dist/samples/todo/services/state-service/transactions/toggle-complete.d.ts +20 -0
  323. package/dist/samples/todo/services/state-service/transactions/toggle-complete.js +11 -0
  324. package/dist/samples/todo/services/state-service/transactions/toggle-complete.js.map +1 -0
  325. package/dist/samples/todo/services/state-service/transactions/toggle-complete.test.d.ts +1 -0
  326. package/dist/samples/todo/services/state-service/transactions/toggle-complete.test.js +81 -0
  327. package/dist/samples/todo/services/state-service/transactions/toggle-complete.test.js.map +1 -0
  328. package/dist/samples/todo/todo-element.d.ts +21 -0
  329. package/dist/samples/todo/todo-element.js +4 -0
  330. package/dist/samples/todo/todo-element.js.map +1 -0
  331. package/dist/samples/todo/todo-host.d.ts +8 -0
  332. package/dist/samples/todo/todo-host.js +55 -0
  333. package/dist/samples/todo/todo-host.js.map +1 -0
  334. package/dist/samples/todo/todo-main-element.d.ts +27 -0
  335. package/dist/samples/todo/todo-main-element.js +63 -0
  336. package/dist/samples/todo/todo-main-element.js.map +1 -0
  337. package/dist/samples/todo/todo-sample.d.ts +3 -0
  338. package/dist/samples/todo/todo-sample.js +39 -0
  339. package/dist/samples/todo/todo-sample.js.map +1 -0
  340. package/dist/schema/schema.d.ts +7 -6
  341. package/dist/schema/schema.js.map +1 -1
  342. package/dist/service/disposable.d.ts +4 -0
  343. package/dist/{services/is-service.js → service/disposable.js} +3 -3
  344. package/dist/service/disposable.js.map +1 -0
  345. package/dist/service/progressive-result.d.ts +7 -10
  346. package/dist/service/progressive-result.js +0 -6
  347. package/dist/service/progressive-result.js.map +1 -1
  348. package/dist/service/service.d.ts +11 -1
  349. package/dist/tsconfig.tsbuildinfo +1 -1
  350. package/dist/typed-buffer/register-typed-buffer-codecs.js +39 -22
  351. package/dist/typed-buffer/register-typed-buffer-codecs.js.map +1 -1
  352. package/dist/typed-buffer/structs/get-struct-layout.js +3 -0
  353. package/dist/typed-buffer/structs/get-struct-layout.js.map +1 -1
  354. package/package.json +20 -3
  355. package/dist/services/add-observable-actions.d.ts +0 -29
  356. package/dist/services/add-observable-actions.js +0 -108
  357. package/dist/services/add-observable-actions.js.map +0 -1
  358. package/dist/services/index.d.ts +0 -4
  359. package/dist/services/index.js.map +0 -1
  360. package/dist/services/is-service.d.ts +0 -2
  361. package/dist/services/is-service.js.map +0 -1
  362. package/dist/services/progressive-result.d.ts +0 -96
  363. package/dist/services/progressive-result.js +0 -99
  364. package/dist/services/progressive-result.js.map +0 -1
  365. package/dist/services/service.d.ts +0 -4
  366. package/dist/services/service.js.map +0 -1
@@ -0,0 +1,100 @@
1
+ /*MIT License
2
+
3
+ © Copyright 2025 Adobe. All rights reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.*/
22
+ import { describe, it, expect } from "vitest";
23
+ import { topologicalSort } from "./topological-sort.js";
24
+ describe("topologicalSort", () => {
25
+ it("should sort string nodes in dependency order", () => {
26
+ const nodes = ["a", "b", "c"];
27
+ const edges = [["a", "b"], ["b", "c"]]; // a → b → c
28
+ const result = topologicalSort(nodes, edges);
29
+ expect(result).toEqual(["a", "b", "c"]);
30
+ });
31
+ it("should handle nodes with no dependencies", () => {
32
+ const nodes = ["x", "y", "z"];
33
+ const edges = [];
34
+ const result = topologicalSort(nodes, edges);
35
+ expect(result).toHaveLength(3);
36
+ expect(result).toContain("x");
37
+ expect(result).toContain("y");
38
+ expect(result).toContain("z");
39
+ });
40
+ it("should work with number nodes", () => {
41
+ const nodes = [1, 2, 3, 4];
42
+ const edges = [[1, 2], [2, 3], [1, 4]]; // 1 → 2 → 3, 1 → 4
43
+ const result = topologicalSort(nodes, edges);
44
+ // Verify ordering constraints
45
+ expect(result.indexOf(1)).toBeLessThan(result.indexOf(2));
46
+ expect(result.indexOf(2)).toBeLessThan(result.indexOf(3));
47
+ expect(result.indexOf(1)).toBeLessThan(result.indexOf(4));
48
+ });
49
+ it("should work with object nodes", () => {
50
+ const nodeA = { name: "a" };
51
+ const nodeB = { name: "b" };
52
+ const nodeC = { name: "c" };
53
+ const nodes = [nodeA, nodeB, nodeC];
54
+ const edges = [[nodeA, nodeB], [nodeB, nodeC]];
55
+ const result = topologicalSort(nodes, edges);
56
+ expect(result).toEqual([nodeA, nodeB, nodeC]);
57
+ });
58
+ it("should handle complex dependency graph", () => {
59
+ const nodes = ["input", "physics", "render", "audio"];
60
+ const edges = [
61
+ ["input", "physics"], // input → physics
62
+ ["physics", "render"], // physics → render
63
+ ["input", "audio"], // input → audio
64
+ ];
65
+ const result = topologicalSort(nodes, edges);
66
+ // Verify ordering constraints
67
+ expect(result.indexOf("input")).toBeLessThan(result.indexOf("physics"));
68
+ expect(result.indexOf("physics")).toBeLessThan(result.indexOf("render"));
69
+ expect(result.indexOf("input")).toBeLessThan(result.indexOf("audio"));
70
+ });
71
+ it("should ignore edges for nodes not in the list", () => {
72
+ const nodes = ["a", "b"];
73
+ const edges = [["a", "b"], ["b", "c"], ["c", "d"]]; // c,d not in nodes
74
+ const result = topologicalSort(nodes, edges);
75
+ expect(result).toEqual(["a", "b"]);
76
+ });
77
+ it("should detect circular dependencies", () => {
78
+ const nodes = ["a", "b", "c"];
79
+ const edges = [
80
+ ["a", "b"],
81
+ ["b", "c"],
82
+ ["c", "a"], // creates cycle
83
+ ];
84
+ expect(() => topologicalSort(nodes, edges))
85
+ .toThrow("Circular dependency detected involving node:");
86
+ });
87
+ it("should handle single node", () => {
88
+ const nodes = ["single"];
89
+ const edges = [];
90
+ const result = topologicalSort(nodes, edges);
91
+ expect(result).toEqual(["single"]);
92
+ });
93
+ it("should handle empty input", () => {
94
+ const nodes = [];
95
+ const edges = [];
96
+ const result = topologicalSort(nodes, edges);
97
+ expect(result).toEqual([]);
98
+ });
99
+ });
100
+ //# sourceMappingURL=topological-sort.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"topological-sort.test.js","sourceRoot":"","sources":["../../../src/internal/array/topological-sort.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAEX,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAa,MAAM,uBAAuB,CAAC;AAEnE,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACpD,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAC9B,MAAM,KAAK,GAAmB,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY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AE,KAAK,CAAC,CAAC;aACtC,OAAO,CAAC,8CAA8C,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACjC,MAAM,KAAK,GAAG,CAAC,QAAQ,CAAC,CAAC;QACzB,MAAM,KAAK,GAAmB,EAAE,CAAC;QAEjC,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAE7C,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACjC,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAmB,EAAE,CAAC;QAEjC,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAE7C,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Options for configuring debounce behavior
3
+ */
4
+ export interface DebounceOptions {
5
+ /**
6
+ * If true, the function is called on the leading edge of the timeout.
7
+ * Default: false
8
+ */
9
+ readonly leading?: boolean;
10
+ /**
11
+ * If true, the function is called on the trailing edge of the timeout.
12
+ * Default: true
13
+ */
14
+ readonly trailing?: boolean;
15
+ /**
16
+ * Maximum time function is allowed to be delayed before it's invoked.
17
+ * If specified, the function will be called at most once per maxWait milliseconds.
18
+ */
19
+ readonly maxWait?: number;
20
+ }
21
+ /**
22
+ * A debounced function with additional control methods
23
+ */
24
+ export interface DebouncedFunction<TFunc extends (...args: any[]) => any> {
25
+ /**
26
+ * The debounced function. Preserves original function signature.
27
+ */
28
+ (...args: Parameters<TFunc>): void;
29
+ /**
30
+ * Cancel any pending invocation of the debounced function
31
+ */
32
+ cancel(): void;
33
+ /**
34
+ * Immediately invoke the debounced function and cancel any pending invocation
35
+ */
36
+ flush(): ReturnType<TFunc> | undefined;
37
+ /**
38
+ * Check if there is a pending invocation of the debounced function
39
+ */
40
+ pending(): boolean;
41
+ }
42
+ /**
43
+ * Creates a debounced function that delays invoking `func` until after `wait`
44
+ * milliseconds have elapsed since the last time the debounced function was invoked.
45
+ *
46
+ * The debounced function comes with methods to cancel delayed `func` invocations
47
+ * and to flush them immediately.
48
+ *
49
+ * @param func - The function to debounce
50
+ * @param wait - The number of milliseconds to delay
51
+ * @param options - The options object for customizing behavior
52
+ * @returns A debounced function with control methods
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const saveData = (id: string, data: any) => console.log('Saving', id, data);
57
+ * const debouncedSave = debounce(saveData, 300);
58
+ *
59
+ * // Multiple rapid calls - only the last one executes after 300ms
60
+ * debouncedSave('1', { name: 'test' });
61
+ * debouncedSave('2', { name: 'test2' }); // This will execute
62
+ *
63
+ * // Cancel pending execution
64
+ * debouncedSave.cancel();
65
+ *
66
+ * // Force immediate execution
67
+ * debouncedSave.flush();
68
+ * ```
69
+ */
70
+ export declare const debounce: <TFunc extends (...args: any[]) => any>(func: TFunc, wait: number, options?: DebounceOptions) => DebouncedFunction<TFunc>;
@@ -0,0 +1,155 @@
1
+ /*MIT License
2
+
3
+ © Copyright 2025 Adobe. All rights reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.*/
22
+ /**
23
+ * Creates a debounced function that delays invoking `func` until after `wait`
24
+ * milliseconds have elapsed since the last time the debounced function was invoked.
25
+ *
26
+ * The debounced function comes with methods to cancel delayed `func` invocations
27
+ * and to flush them immediately.
28
+ *
29
+ * @param func - The function to debounce
30
+ * @param wait - The number of milliseconds to delay
31
+ * @param options - The options object for customizing behavior
32
+ * @returns A debounced function with control methods
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * const saveData = (id: string, data: any) => console.log('Saving', id, data);
37
+ * const debouncedSave = debounce(saveData, 300);
38
+ *
39
+ * // Multiple rapid calls - only the last one executes after 300ms
40
+ * debouncedSave('1', { name: 'test' });
41
+ * debouncedSave('2', { name: 'test2' }); // This will execute
42
+ *
43
+ * // Cancel pending execution
44
+ * debouncedSave.cancel();
45
+ *
46
+ * // Force immediate execution
47
+ * debouncedSave.flush();
48
+ * ```
49
+ */
50
+ export const debounce = (func, wait, options = {}) => {
51
+ const { leading = false, trailing = true, maxWait } = options;
52
+ let timeoutId;
53
+ let maxTimeoutId;
54
+ let lastCallTime;
55
+ let lastInvokeTime = 0;
56
+ let lastArgs;
57
+ let result;
58
+ const invokeFunc = (time) => {
59
+ const args = lastArgs;
60
+ console.log('invokeFunc called with lastArgs:', args);
61
+ lastArgs = undefined;
62
+ lastInvokeTime = time;
63
+ result = func(...args);
64
+ return result;
65
+ };
66
+ const leadingEdge = (time) => {
67
+ lastInvokeTime = time;
68
+ timeoutId = setTimeout(timerExpired, wait);
69
+ if (leading) {
70
+ invokeFunc(time);
71
+ }
72
+ };
73
+ const timerExpired = () => {
74
+ const time = Date.now();
75
+ const timeSinceLastCall = time - (lastCallTime ?? 0);
76
+ const timeSinceLastInvoke = time - lastInvokeTime;
77
+ // If we have maxWait active, don't fire the regular timer - let maxWait handle it
78
+ if (maxTimeoutId !== undefined && maxWait !== undefined && timeSinceLastInvoke < maxWait) {
79
+ // Still within maxWait period, don't execute yet
80
+ timeoutId = setTimeout(timerExpired, wait);
81
+ return;
82
+ }
83
+ // Only execute if we've waited long enough
84
+ if (timeSinceLastCall >= wait) {
85
+ trailingEdge(time);
86
+ }
87
+ else {
88
+ timeoutId = setTimeout(timerExpired, wait - timeSinceLastCall);
89
+ }
90
+ };
91
+ const trailingEdge = (time) => {
92
+ timeoutId = undefined;
93
+ if (maxTimeoutId !== undefined) {
94
+ clearTimeout(maxTimeoutId);
95
+ maxTimeoutId = undefined;
96
+ }
97
+ if (trailing && lastArgs !== undefined) {
98
+ invokeFunc(time);
99
+ }
100
+ lastArgs = undefined;
101
+ };
102
+ const cancel = () => {
103
+ if (timeoutId !== undefined) {
104
+ clearTimeout(timeoutId);
105
+ timeoutId = undefined;
106
+ }
107
+ if (maxTimeoutId !== undefined) {
108
+ clearTimeout(maxTimeoutId);
109
+ maxTimeoutId = undefined;
110
+ }
111
+ lastInvokeTime = 0;
112
+ lastCallTime = undefined;
113
+ lastArgs = undefined;
114
+ result = undefined;
115
+ };
116
+ const flush = () => {
117
+ if (timeoutId === undefined)
118
+ return result;
119
+ const time = Date.now();
120
+ trailingEdge(time);
121
+ return result;
122
+ };
123
+ const pending = () => {
124
+ return timeoutId !== undefined;
125
+ };
126
+ const debounced = (...args) => {
127
+ const time = Date.now();
128
+ lastArgs = args;
129
+ lastCallTime = time;
130
+ if (timeoutId === undefined) {
131
+ leadingEdge(time);
132
+ // Start maxWait timer if configured
133
+ if (maxWait !== undefined) {
134
+ maxTimeoutId = setTimeout(() => {
135
+ console.log('maxWait timer fired, lastArgs:', lastArgs);
136
+ maxTimeoutId = undefined;
137
+ if (timeoutId !== undefined) {
138
+ trailingEdge(Date.now());
139
+ }
140
+ }, maxWait);
141
+ }
142
+ }
143
+ else {
144
+ // Timer is already running, just update the regular timer
145
+ clearTimeout(timeoutId);
146
+ timeoutId = setTimeout(timerExpired, wait);
147
+ }
148
+ };
149
+ // Attach utility methods to the debounced function
150
+ debounced.cancel = cancel;
151
+ debounced.flush = flush;
152
+ debounced.pending = pending;
153
+ return debounced;
154
+ };
155
+ //# sourceMappingURL=debounce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce.js","sourceRoot":"","sources":["../../../src/internal/function/debounce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAkDX;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CACpB,IAAW,EACX,IAAY,EACZ,UAA2B,EAAE,EACL,EAAE;IAC1B,MAAM,EAAE,OAAO,GAAG,KAAK,EAAE,QAAQ,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAE9D,IAAI,SAAoD,CAAC;IACzD,IAAI,YAAuD,CAAC;IAC5D,IAAI,YAAgC,CAAC;IACrC,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,QAAuC,CAAC;IAC5C,IAAI,MAAqC,CAAC;IAE1C,MAAM,UAAU,GAAG,CAAC,IAAY,EAAqB,EAAE;QACnD,MAAM,IAAI,GAAG,QAAS,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,kCAAkC,EAAE,IAAI,CAAC,CAAC;QACtD,QAAQ,GAAG,SAAS,CAAC;QACrB,cAAc,GAAG,IAAI,CAAC;QACtB,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QACvB,OAAO,MAA2B,CAAC;IACvC,CAAC,CAAC;IAEF,MAAM,WAAW,GAAG,CAAC,IAAY,EAAQ,EAAE;QACvC,cAAc,GAAG,IAAI,CAAC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,CAAC,EAAE,OAAO,CAAC,CAAC;YAChB,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,0DAA0D;YAC1D,YAAY,CAAC,SAAS,CAAC,CAAC;YACxB,SAAS,GAAG,UAAU,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QAC/C,CAAC;IACL,CAAC,CAAC;IAEF,mDAAmD;IACnD,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC;IAC1B,SAAS,CAAC,KAAK,GAAG,KAAK,CAAC;IACxB,SAAS,CAAC,OAAO,GAAG,OAAO,CAAC;IAE5B,OAAO,SAAqC,CAAC;AACjD,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,306 @@
1
+ /*MIT License
2
+
3
+ © Copyright 2025 Adobe. All rights reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.*/
22
+ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
23
+ import { debounce } from './debounce.js';
24
+ describe('debounce', () => {
25
+ beforeEach(() => {
26
+ vi.useFakeTimers();
27
+ });
28
+ afterEach(() => {
29
+ vi.useRealTimers();
30
+ });
31
+ describe('basic debouncing (trailing edge)', () => {
32
+ it('should delay function execution', () => {
33
+ const fn = vi.fn();
34
+ const debounced = debounce(fn, 100);
35
+ debounced('test');
36
+ expect(fn).not.toHaveBeenCalled();
37
+ vi.advanceTimersByTime(99);
38
+ expect(fn).not.toHaveBeenCalled();
39
+ vi.advanceTimersByTime(1);
40
+ expect(fn).toHaveBeenCalledWith('test');
41
+ expect(fn).toHaveBeenCalledTimes(1);
42
+ });
43
+ it('should only execute the last call when called multiple times rapidly', () => {
44
+ const fn = vi.fn();
45
+ const debounced = debounce(fn, 100);
46
+ debounced('first');
47
+ debounced('second');
48
+ debounced('third');
49
+ vi.advanceTimersByTime(100);
50
+ expect(fn).toHaveBeenCalledWith('third');
51
+ expect(fn).toHaveBeenCalledTimes(1);
52
+ });
53
+ it('should reset timer on each call', () => {
54
+ const fn = vi.fn();
55
+ const debounced = debounce(fn, 100);
56
+ debounced('test1');
57
+ vi.advanceTimersByTime(50);
58
+ debounced('test2');
59
+ vi.advanceTimersByTime(50);
60
+ expect(fn).not.toHaveBeenCalled();
61
+ vi.advanceTimersByTime(50);
62
+ expect(fn).toHaveBeenCalledWith('test2');
63
+ expect(fn).toHaveBeenCalledTimes(1);
64
+ });
65
+ it('should preserve function arguments with complex types', () => {
66
+ const fn = vi.fn();
67
+ const debounced = debounce(fn, 100);
68
+ const complexArg = { id: 1, data: [1, 2, 3], nested: { value: 'test' } };
69
+ debounced('string', 42, complexArg, true);
70
+ vi.advanceTimersByTime(100);
71
+ expect(fn).toHaveBeenCalledWith('string', 42, complexArg, true);
72
+ });
73
+ });
74
+ describe('leading edge execution', () => {
75
+ it('should execute immediately when leading is true', () => {
76
+ const fn = vi.fn();
77
+ const debounced = debounce(fn, 100, { leading: true });
78
+ debounced('test');
79
+ expect(fn).toHaveBeenCalledWith('test');
80
+ expect(fn).toHaveBeenCalledTimes(1);
81
+ });
82
+ it('should not execute again on trailing edge when leading is true and trailing is false', () => {
83
+ const fn = vi.fn();
84
+ const debounced = debounce(fn, 100, { leading: true, trailing: false });
85
+ debounced('test');
86
+ expect(fn).toHaveBeenCalledTimes(1);
87
+ vi.advanceTimersByTime(100);
88
+ expect(fn).toHaveBeenCalledTimes(1);
89
+ });
90
+ it('should execute both leading and trailing when both are true', () => {
91
+ const fn = vi.fn();
92
+ const debounced = debounce(fn, 100, { leading: true, trailing: true });
93
+ debounced('test1');
94
+ expect(fn).toHaveBeenCalledWith('test1');
95
+ debounced('test2');
96
+ vi.advanceTimersByTime(100);
97
+ expect(fn).toHaveBeenCalledWith('test2');
98
+ expect(fn).toHaveBeenCalledTimes(2);
99
+ });
100
+ it('should not execute on leading edge for subsequent rapid calls', () => {
101
+ const fn = vi.fn();
102
+ const debounced = debounce(fn, 100, { leading: true });
103
+ debounced('first');
104
+ expect(fn).toHaveBeenCalledTimes(1);
105
+ debounced('second');
106
+ debounced('third');
107
+ expect(fn).toHaveBeenCalledTimes(1); // Still only the leading call
108
+ vi.advanceTimersByTime(100);
109
+ expect(fn).toHaveBeenCalledTimes(2); // Now trailing edge executes
110
+ expect(fn).toHaveBeenLastCalledWith('third');
111
+ });
112
+ });
113
+ describe('maxWait functionality', () => {
114
+ it('should force execution after maxWait time', () => {
115
+ const fn = vi.fn();
116
+ const debounced = debounce(fn, 100, { maxWait: 200 });
117
+ // Add debug logging
118
+ const originalConsoleLog = console.log;
119
+ const logs = [];
120
+ console.log = (...args) => logs.push(args.join(' '));
121
+ debounced('test1');
122
+ console.log('Called with test1 at 0ms');
123
+ vi.advanceTimersByTime(150);
124
+ console.log('Advanced 150ms');
125
+ debounced('test2');
126
+ console.log('Called with test2 at 150ms');
127
+ vi.advanceTimersByTime(50); // Total 200ms from first call
128
+ console.log('Advanced final 50ms (total 200ms)');
129
+ console.log = originalConsoleLog;
130
+ // Log debug info if test fails
131
+ if (fn.mock.calls.length > 0) {
132
+ console.log('Function was called with:', fn.mock.calls[0]);
133
+ console.log('Debug logs:', logs);
134
+ }
135
+ expect(fn).toHaveBeenCalledWith('test2');
136
+ expect(fn).toHaveBeenCalledTimes(1);
137
+ });
138
+ it('should not exceed maxWait even with continuous calls', () => {
139
+ const fn = vi.fn();
140
+ const debounced = debounce(fn, 100, { maxWait: 250 });
141
+ // Continuous calls every 50ms
142
+ for (let i = 0; i < 10; i++) {
143
+ debounced(`call${i}`);
144
+ vi.advanceTimersByTime(50);
145
+ if (i === 4) { // At 250ms total
146
+ expect(fn).toHaveBeenCalledTimes(1);
147
+ expect(fn).toHaveBeenCalledWith('call4');
148
+ }
149
+ }
150
+ });
151
+ });
152
+ describe('cancel method', () => {
153
+ it('should cancel pending execution', () => {
154
+ const fn = vi.fn();
155
+ const debounced = debounce(fn, 100);
156
+ debounced('test');
157
+ expect(debounced.pending()).toBe(true);
158
+ debounced.cancel();
159
+ expect(debounced.pending()).toBe(false);
160
+ vi.advanceTimersByTime(100);
161
+ expect(fn).not.toHaveBeenCalled();
162
+ });
163
+ it('should reset internal state', () => {
164
+ const fn = vi.fn();
165
+ const debounced = debounce(fn, 100);
166
+ debounced('test1');
167
+ debounced.cancel();
168
+ // After cancel, next call should behave like first call
169
+ debounced('test2');
170
+ vi.advanceTimersByTime(100);
171
+ expect(fn).toHaveBeenCalledWith('test2');
172
+ expect(fn).toHaveBeenCalledTimes(1);
173
+ });
174
+ });
175
+ describe('flush method', () => {
176
+ it('should immediately execute pending function', () => {
177
+ const fn = vi.fn((x) => `result: ${x}`);
178
+ const debounced = debounce(fn, 100);
179
+ debounced('test');
180
+ const result = debounced.flush();
181
+ expect(fn).toHaveBeenCalledWith('test');
182
+ expect(result).toBe('result: test');
183
+ expect(debounced.pending()).toBe(false);
184
+ });
185
+ it('should return undefined if no pending execution', () => {
186
+ const fn = vi.fn((x) => `result: ${x}`);
187
+ const debounced = debounce(fn, 100);
188
+ const result = debounced.flush();
189
+ expect(result).toBeUndefined();
190
+ expect(fn).not.toHaveBeenCalled();
191
+ });
192
+ it('should prevent normal timer execution after flush', () => {
193
+ const fn = vi.fn();
194
+ const debounced = debounce(fn, 100);
195
+ debounced('test');
196
+ debounced.flush();
197
+ vi.advanceTimersByTime(100);
198
+ expect(fn).toHaveBeenCalledTimes(1); // Only from flush, not timer
199
+ });
200
+ });
201
+ describe('pending method', () => {
202
+ it('should return true when execution is pending', () => {
203
+ const fn = vi.fn();
204
+ const debounced = debounce(fn, 100);
205
+ expect(debounced.pending()).toBe(false);
206
+ debounced('test');
207
+ expect(debounced.pending()).toBe(true);
208
+ vi.advanceTimersByTime(100);
209
+ expect(debounced.pending()).toBe(false);
210
+ });
211
+ it('should return false after cancel', () => {
212
+ const fn = vi.fn();
213
+ const debounced = debounce(fn, 100);
214
+ debounced('test');
215
+ expect(debounced.pending()).toBe(true);
216
+ debounced.cancel();
217
+ expect(debounced.pending()).toBe(false);
218
+ });
219
+ it('should return false after flush', () => {
220
+ const fn = vi.fn();
221
+ const debounced = debounce(fn, 100);
222
+ debounced('test');
223
+ expect(debounced.pending()).toBe(true);
224
+ debounced.flush();
225
+ expect(debounced.pending()).toBe(false);
226
+ });
227
+ });
228
+ describe('type safety', () => {
229
+ it('should preserve function signature for simple functions', () => {
230
+ const fn = vi.fn((a, b) => `${a}: ${b}`);
231
+ const debounced = debounce(fn, 100);
232
+ // Type checking happens at compile time, but we can test runtime behavior
233
+ debounced('test', 42);
234
+ vi.advanceTimersByTime(100);
235
+ expect(fn).toHaveBeenCalledWith('test', 42);
236
+ });
237
+ it('should work with functions that return promises', () => {
238
+ const fn = vi.fn(async (x) => `async result: ${x}`);
239
+ const debounced = debounce(fn, 100);
240
+ debounced('test');
241
+ const result = debounced.flush();
242
+ expect(result).toBeInstanceOf(Promise);
243
+ });
244
+ it('should work with void functions', () => {
245
+ const fn = vi.fn((x) => {
246
+ console.log(x);
247
+ });
248
+ const debounced = debounce(fn, 100);
249
+ debounced('test');
250
+ const result = debounced.flush();
251
+ expect(result).toBeUndefined();
252
+ expect(fn).toHaveBeenCalledWith('test');
253
+ });
254
+ });
255
+ describe('edge cases', () => {
256
+ it('should handle zero wait time', () => {
257
+ const fn = vi.fn();
258
+ const debounced = debounce(fn, 0);
259
+ debounced('test');
260
+ vi.advanceTimersByTime(0);
261
+ expect(fn).toHaveBeenCalledWith('test');
262
+ });
263
+ it('should handle very large wait times', () => {
264
+ const fn = vi.fn();
265
+ const debounced = debounce(fn, 1000000);
266
+ debounced('test');
267
+ vi.advanceTimersByTime(999999);
268
+ expect(fn).not.toHaveBeenCalled();
269
+ vi.advanceTimersByTime(1);
270
+ expect(fn).toHaveBeenCalledWith('test');
271
+ });
272
+ it('should handle functions with no arguments', () => {
273
+ const fn = vi.fn(() => 'no args');
274
+ const debounced = debounce(fn, 100);
275
+ debounced();
276
+ vi.advanceTimersByTime(100);
277
+ expect(fn).toHaveBeenCalledWith();
278
+ expect(fn).toHaveBeenCalledTimes(1);
279
+ });
280
+ it('should handle functions that throw errors', () => {
281
+ const fn = vi.fn((arg) => {
282
+ throw new Error('Test error');
283
+ });
284
+ const debounced = debounce(fn, 100);
285
+ debounced('test');
286
+ expect(() => {
287
+ vi.advanceTimersByTime(100);
288
+ }).toThrow('Test error');
289
+ expect(fn).toHaveBeenCalledWith('test');
290
+ });
291
+ it('should handle multiple debounced functions independently', () => {
292
+ const fn1 = vi.fn();
293
+ const fn2 = vi.fn();
294
+ const debounced1 = debounce(fn1, 100);
295
+ const debounced2 = debounce(fn2, 200);
296
+ debounced1('test1');
297
+ debounced2('test2');
298
+ vi.advanceTimersByTime(100);
299
+ expect(fn1).toHaveBeenCalledWith('test1');
300
+ expect(fn2).not.toHaveBeenCalled();
301
+ vi.advanceTimersByTime(100);
302
+ expect(fn2).toHaveBeenCalledWith('test2');
303
+ });
304
+ });
305
+ });
306
+ //# sourceMappingURL=debounce.test.js.map