@praxisjs/decorators 1.7.0 → 2.0.0

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 (266) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/component/component.d.ts +1 -1
  3. package/dist/component/component.d.ts.map +1 -1
  4. package/dist/component/component.js +8 -15
  5. package/dist/component/component.js.map +1 -1
  6. package/dist/component/lazy.d.ts +1 -1
  7. package/dist/component/lazy.d.ts.map +1 -1
  8. package/dist/component/lazy.js +44 -36
  9. package/dist/component/lazy.js.map +1 -1
  10. package/dist/create-class-decorator.d.ts +27 -5
  11. package/dist/create-class-decorator.d.ts.map +1 -1
  12. package/dist/create-class-decorator.js +53 -18
  13. package/dist/create-class-decorator.js.map +1 -1
  14. package/dist/create-field-decorator.d.ts +42 -3
  15. package/dist/create-field-decorator.d.ts.map +1 -1
  16. package/dist/create-field-decorator.js +63 -27
  17. package/dist/create-field-decorator.js.map +1 -1
  18. package/dist/create-getter-decorator.d.ts +81 -16
  19. package/dist/create-getter-decorator.d.ts.map +1 -1
  20. package/dist/create-getter-decorator.js +127 -15
  21. package/dist/create-getter-decorator.js.map +1 -1
  22. package/dist/create-lifecycle-method-decorator.d.ts +21 -3
  23. package/dist/create-lifecycle-method-decorator.d.ts.map +1 -1
  24. package/dist/create-lifecycle-method-decorator.js +25 -18
  25. package/dist/create-lifecycle-method-decorator.js.map +1 -1
  26. package/dist/create-method-decorator.d.ts +43 -3
  27. package/dist/create-method-decorator.d.ts.map +1 -1
  28. package/dist/create-method-decorator.js +49 -8
  29. package/dist/create-method-decorator.js.map +1 -1
  30. package/dist/events/command.d.ts +2 -1
  31. package/dist/events/command.d.ts.map +1 -1
  32. package/dist/events/command.js +10 -8
  33. package/dist/events/command.js.map +1 -1
  34. package/dist/events/emit.d.ts +2 -2
  35. package/dist/events/emit.d.ts.map +1 -1
  36. package/dist/events/emit.js +18 -24
  37. package/dist/events/emit.js.map +1 -1
  38. package/dist/events/on-command.d.ts +2 -1
  39. package/dist/events/on-command.d.ts.map +1 -1
  40. package/dist/events/on-command.js +12 -14
  41. package/dist/events/on-command.js.map +1 -1
  42. package/dist/field.d.ts +51 -0
  43. package/dist/field.d.ts.map +1 -0
  44. package/dist/field.js +82 -0
  45. package/dist/field.js.map +1 -0
  46. package/dist/functions/bind.d.ts +2 -1
  47. package/dist/functions/bind.d.ts.map +1 -1
  48. package/dist/functions/bind.js +4 -4
  49. package/dist/functions/bind.js.map +1 -1
  50. package/dist/functions/debounce.d.ts +2 -2
  51. package/dist/functions/debounce.d.ts.map +1 -1
  52. package/dist/functions/debounce.js +25 -23
  53. package/dist/functions/debounce.js.map +1 -1
  54. package/dist/functions/log.d.ts +2 -1
  55. package/dist/functions/log.d.ts.map +1 -1
  56. package/dist/functions/log.js +38 -40
  57. package/dist/functions/log.js.map +1 -1
  58. package/dist/functions/memo.d.ts +2 -1
  59. package/dist/functions/memo.d.ts.map +1 -1
  60. package/dist/functions/memo.js +41 -40
  61. package/dist/functions/memo.js.map +1 -1
  62. package/dist/functions/once.d.ts +2 -1
  63. package/dist/functions/once.d.ts.map +1 -1
  64. package/dist/functions/once.js +10 -14
  65. package/dist/functions/once.js.map +1 -1
  66. package/dist/functions/retry.d.ts +2 -1
  67. package/dist/functions/retry.d.ts.map +1 -1
  68. package/dist/functions/retry.js +21 -23
  69. package/dist/functions/retry.js.map +1 -1
  70. package/dist/functions/throttle.d.ts +2 -1
  71. package/dist/functions/throttle.d.ts.map +1 -1
  72. package/dist/functions/throttle.js +12 -14
  73. package/dist/functions/throttle.js.map +1 -1
  74. package/dist/functions/until.d.ts +2 -1
  75. package/dist/functions/until.d.ts.map +1 -1
  76. package/dist/functions/until.js +13 -14
  77. package/dist/functions/until.js.map +1 -1
  78. package/dist/functions/watch.d.ts +1 -1
  79. package/dist/functions/watch.d.ts.map +1 -1
  80. package/dist/functions/watch.js +36 -34
  81. package/dist/functions/watch.js.map +1 -1
  82. package/dist/functions/when.d.ts +1 -1
  83. package/dist/functions/when.d.ts.map +1 -1
  84. package/dist/functions/when.js +19 -21
  85. package/dist/functions/when.js.map +1 -1
  86. package/dist/index.d.ts +5 -5
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +2 -2
  89. package/dist/index.js.map +1 -1
  90. package/dist/lifecycle.d.ts +24 -0
  91. package/dist/lifecycle.d.ts.map +1 -0
  92. package/dist/lifecycle.js +55 -0
  93. package/dist/lifecycle.js.map +1 -0
  94. package/dist/properties/compose.d.ts +3 -2
  95. package/dist/properties/compose.d.ts.map +1 -1
  96. package/dist/properties/compose.js +33 -19
  97. package/dist/properties/compose.js.map +1 -1
  98. package/dist/properties/computed.d.ts +12 -10
  99. package/dist/properties/computed.d.ts.map +1 -1
  100. package/dist/properties/computed.js +26 -21
  101. package/dist/properties/computed.js.map +1 -1
  102. package/dist/properties/deep-state.d.ts +2 -1
  103. package/dist/properties/deep-state.d.ts.map +1 -1
  104. package/dist/properties/deep-state.js +66 -60
  105. package/dist/properties/deep-state.js.map +1 -1
  106. package/dist/properties/function-prop.d.ts +2 -1
  107. package/dist/properties/function-prop.d.ts.map +1 -1
  108. package/dist/properties/function-prop.js +20 -22
  109. package/dist/properties/function-prop.js.map +1 -1
  110. package/dist/properties/history.d.ts +2 -2
  111. package/dist/properties/history.d.ts.map +1 -1
  112. package/dist/properties/history.js +34 -33
  113. package/dist/properties/history.js.map +1 -1
  114. package/dist/properties/index.d.ts +1 -0
  115. package/dist/properties/index.d.ts.map +1 -1
  116. package/dist/properties/index.js +1 -0
  117. package/dist/properties/index.js.map +1 -1
  118. package/dist/properties/persisted.d.ts +2 -1
  119. package/dist/properties/persisted.d.ts.map +1 -1
  120. package/dist/properties/persisted.js +24 -18
  121. package/dist/properties/persisted.js.map +1 -1
  122. package/dist/properties/prop.d.ts +2 -1
  123. package/dist/properties/prop.d.ts.map +1 -1
  124. package/dist/properties/prop.js +26 -22
  125. package/dist/properties/prop.js.map +1 -1
  126. package/dist/properties/ref.d.ts +2 -1
  127. package/dist/properties/ref.d.ts.map +1 -1
  128. package/dist/properties/ref.js +11 -8
  129. package/dist/properties/ref.js.map +1 -1
  130. package/dist/properties/resource.d.ts.map +1 -1
  131. package/dist/properties/resource.js +21 -16
  132. package/dist/properties/resource.js.map +1 -1
  133. package/dist/properties/selector.d.ts +12 -0
  134. package/dist/properties/selector.d.ts.map +1 -0
  135. package/dist/properties/selector.js +25 -0
  136. package/dist/properties/selector.js.map +1 -0
  137. package/dist/properties/slot.d.ts +2 -1
  138. package/dist/properties/slot.d.ts.map +1 -1
  139. package/dist/properties/slot.js +22 -20
  140. package/dist/properties/slot.js.map +1 -1
  141. package/dist/properties/state.d.ts.map +1 -1
  142. package/dist/properties/state.js +27 -16
  143. package/dist/properties/state.js.map +1 -1
  144. package/dist/properties/synced.d.ts +2 -1
  145. package/dist/properties/synced.d.ts.map +1 -1
  146. package/dist/properties/synced.js +27 -19
  147. package/dist/properties/synced.js.map +1 -1
  148. package/dist/shared-method.d.ts +14 -0
  149. package/dist/shared-method.d.ts.map +1 -0
  150. package/dist/shared-method.js +87 -0
  151. package/dist/shared-method.js.map +1 -0
  152. package/package.json +14 -5
  153. package/src/component/component.ts +8 -27
  154. package/src/component/lazy.ts +51 -41
  155. package/src/create-class-decorator.ts +90 -31
  156. package/src/create-field-decorator.ts +120 -43
  157. package/src/create-getter-decorator.ts +263 -66
  158. package/src/create-lifecycle-method-decorator.ts +50 -28
  159. package/src/create-method-decorator.ts +119 -13
  160. package/src/events/command.ts +11 -9
  161. package/src/events/emit.ts +16 -22
  162. package/src/events/on-command.ts +17 -18
  163. package/src/field.ts +116 -0
  164. package/src/functions/bind.ts +4 -4
  165. package/src/functions/debounce.ts +25 -23
  166. package/src/functions/log.ts +44 -46
  167. package/src/functions/memo.ts +39 -37
  168. package/src/functions/once.ts +10 -13
  169. package/src/functions/retry.ts +19 -21
  170. package/src/functions/throttle.ts +12 -13
  171. package/src/functions/until.ts +14 -14
  172. package/src/functions/watch.ts +37 -36
  173. package/src/functions/when.ts +18 -20
  174. package/src/index.ts +12 -5
  175. package/src/lifecycle.ts +74 -0
  176. package/src/properties/compose.ts +33 -20
  177. package/src/properties/computed.ts +35 -45
  178. package/src/properties/deep-state.ts +66 -64
  179. package/src/properties/function-prop.ts +25 -27
  180. package/src/properties/history.ts +34 -35
  181. package/src/properties/index.ts +1 -0
  182. package/src/properties/persisted.ts +30 -20
  183. package/src/properties/prop.ts +30 -22
  184. package/src/properties/ref.ts +12 -10
  185. package/src/properties/resource.ts +22 -17
  186. package/src/properties/selector.ts +45 -0
  187. package/src/properties/slot.ts +28 -22
  188. package/src/properties/state.ts +32 -16
  189. package/src/properties/synced.ts +31 -19
  190. package/src/shared-method.ts +101 -0
  191. package/dist/__tests__/component.test.d.ts +0 -2
  192. package/dist/__tests__/component.test.d.ts.map +0 -1
  193. package/dist/__tests__/component.test.js +0 -147
  194. package/dist/__tests__/component.test.js.map +0 -1
  195. package/dist/__tests__/compose.test.d.ts +0 -2
  196. package/dist/__tests__/compose.test.d.ts.map +0 -1
  197. package/dist/__tests__/compose.test.js +0 -164
  198. package/dist/__tests__/compose.test.js.map +0 -1
  199. package/dist/__tests__/deep-state.test.d.ts +0 -2
  200. package/dist/__tests__/deep-state.test.d.ts.map +0 -1
  201. package/dist/__tests__/deep-state.test.js +0 -221
  202. package/dist/__tests__/deep-state.test.js.map +0 -1
  203. package/dist/__tests__/events.test.d.ts +0 -2
  204. package/dist/__tests__/events.test.d.ts.map +0 -1
  205. package/dist/__tests__/events.test.js +0 -295
  206. package/dist/__tests__/events.test.js.map +0 -1
  207. package/dist/__tests__/functions.test.d.ts +0 -2
  208. package/dist/__tests__/functions.test.d.ts.map +0 -1
  209. package/dist/__tests__/functions.test.js +0 -618
  210. package/dist/__tests__/functions.test.js.map +0 -1
  211. package/dist/__tests__/lazy.test.d.ts +0 -2
  212. package/dist/__tests__/lazy.test.d.ts.map +0 -1
  213. package/dist/__tests__/lazy.test.js +0 -227
  214. package/dist/__tests__/lazy.test.js.map +0 -1
  215. package/dist/__tests__/memo.test.d.ts +0 -2
  216. package/dist/__tests__/memo.test.d.ts.map +0 -1
  217. package/dist/__tests__/memo.test.js +0 -249
  218. package/dist/__tests__/memo.test.js.map +0 -1
  219. package/dist/__tests__/properties-browser.test.d.ts +0 -2
  220. package/dist/__tests__/properties-browser.test.d.ts.map +0 -1
  221. package/dist/__tests__/properties-browser.test.js +0 -227
  222. package/dist/__tests__/properties-browser.test.js.map +0 -1
  223. package/dist/__tests__/properties.test.d.ts +0 -2
  224. package/dist/__tests__/properties.test.d.ts.map +0 -1
  225. package/dist/__tests__/properties.test.js +0 -1253
  226. package/dist/__tests__/properties.test.js.map +0 -1
  227. package/dist/__tests__/ref.test.d.ts +0 -2
  228. package/dist/__tests__/ref.test.d.ts.map +0 -1
  229. package/dist/__tests__/ref.test.js +0 -106
  230. package/dist/__tests__/ref.test.js.map +0 -1
  231. package/dist/__tests__/resource.test.d.ts +0 -2
  232. package/dist/__tests__/resource.test.d.ts.map +0 -1
  233. package/dist/__tests__/resource.test.js +0 -217
  234. package/dist/__tests__/resource.test.js.map +0 -1
  235. package/dist/__tests__/slot.test.d.ts +0 -2
  236. package/dist/__tests__/slot.test.d.ts.map +0 -1
  237. package/dist/__tests__/slot.test.js +0 -147
  238. package/dist/__tests__/slot.test.js.map +0 -1
  239. package/dist/__tests__/synced.test.d.ts +0 -2
  240. package/dist/__tests__/synced.test.d.ts.map +0 -1
  241. package/dist/__tests__/synced.test.js +0 -161
  242. package/dist/__tests__/synced.test.js.map +0 -1
  243. package/dist/__tests__/until.test.d.ts +0 -2
  244. package/dist/__tests__/until.test.d.ts.map +0 -1
  245. package/dist/__tests__/until.test.js +0 -88
  246. package/dist/__tests__/until.test.js.map +0 -1
  247. package/dist/create-accessor-decorator.d.ts +0 -14
  248. package/dist/create-accessor-decorator.d.ts.map +0 -1
  249. package/dist/create-accessor-decorator.js +0 -27
  250. package/dist/create-accessor-decorator.js.map +0 -1
  251. package/src/__tests__/component.test.ts +0 -167
  252. package/src/__tests__/compose.test.ts +0 -202
  253. package/src/__tests__/deep-state.test.ts +0 -265
  254. package/src/__tests__/events.test.ts +0 -366
  255. package/src/__tests__/functions.test.ts +0 -803
  256. package/src/__tests__/lazy.test.ts +0 -296
  257. package/src/__tests__/memo.test.ts +0 -293
  258. package/src/__tests__/properties-browser.test.ts +0 -288
  259. package/src/__tests__/properties.test.ts +0 -1556
  260. package/src/__tests__/ref.test.ts +0 -131
  261. package/src/__tests__/resource.test.ts +0 -246
  262. package/src/__tests__/slot.test.ts +0 -179
  263. package/src/__tests__/synced.test.ts +0 -193
  264. package/src/__tests__/until.test.ts +0 -113
  265. package/src/create-accessor-decorator.ts +0 -45
  266. package/tsconfig.json +0 -9
@@ -1,2 +1,3 @@
1
- export declare function Once(): (value: (this: object, ...args: any[]) => any, context: ClassMethodDecoratorContext<import("@praxisjs/core").StatefulComponent>) => void;
1
+ import { type AnyMethod, type MethodContext } from "../shared-method";
2
+ export declare function Once(): (value: AnyMethod, context: MethodContext) => AnyMethod;
2
3
  //# sourceMappingURL=once.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"once.d.ts","sourceRoot":"","sources":["../../src/functions/once.ts"],"names":[],"mappings":"AAEA,wBAAgB,IAAI,2BAcoG,GAAI,+GAD3H"}
1
+ {"version":3,"file":"once.d.ts","sourceRoot":"","sources":["../../src/functions/once.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAgB,MAAM,kBAAkB,CAAC;AAEpF,wBAAgB,IAAI,KACD,OAAO,SAAS,EAAE,SAAS,aAAa,KAAG,SAAS,CAStE"}
@@ -1,17 +1,13 @@
1
- import { createMethodDecorator } from "../create-method-decorator";
1
+ import { sharedMethod } from "../shared-method";
2
2
  export function Once() {
3
- return createMethodDecorator({
4
- wrap(original, instance) {
5
- let called = false;
6
- let result;
7
- return (...args) => {
8
- if (called)
9
- return result;
10
- result = original.apply(instance, args);
11
- called = true;
12
- return result;
13
- };
14
- },
15
- });
3
+ return function (value, context) {
4
+ const result = Symbol(`praxis.once.${String(context.name)}`);
5
+ return sharedMethod(context, value, function (...args) {
6
+ if (result in this)
7
+ return this[result];
8
+ // Stored only once the call returns, so a call that throws can be retried.
9
+ return (this[result] = value.apply(this, args));
10
+ });
11
+ };
16
12
  }
17
13
  //# sourceMappingURL=once.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"once.js","sourceRoot":"","sources":["../../src/functions/once.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,UAAU,IAAI;IAClB,OAAO,qBAAqB,CAAC;QAC3B,IAAI,CAAC,QAAQ,EAAE,QAAQ;YACrB,IAAI,MAAM,GAAG,KAAK,CAAC;YACnB,IAAI,MAAe,CAAC;YACpB,OAAO,CAAC,GAAG,IAAe,EAAE,EAAE;gBAC5B,IAAI,MAAM;oBAAE,OAAO,MAAM,CAAC;gBAC1B,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;gBACxC,MAAM,GAAG,IAAI,CAAC;gBACd,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"once.js","sourceRoot":"","sources":["../../src/functions/once.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEpF,MAAM,UAAU,IAAI;IAClB,OAAO,UAAU,KAAgB,EAAE,OAAsB;QACvD,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAE7D,OAAO,YAAY,CAAC,OAAO,EAAE,KAAK,EAAE,UAAsB,GAAG,IAAe;YAC1E,IAAI,MAAM,IAAI,IAAI;gBAAE,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;YACxC,2EAA2E;YAC3E,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -1,7 +1,8 @@
1
+ import { type AnyMethod, type MethodContext } from "../shared-method";
1
2
  export interface RetryOptions {
2
3
  delay?: number;
3
4
  backoff?: number;
4
5
  onRetry?: (error: Error, attempt: number) => void;
5
6
  }
6
- export declare function Retry(maxAttempts: number, options?: RetryOptions): (value: (this: object, ...args: any[]) => any, context: ClassMethodDecoratorContext<import("@praxisjs/core").StatefulComponent>) => void;
7
+ export declare function Retry(maxAttempts: number, options?: RetryOptions): (value: AnyMethod, context: MethodContext) => AnyMethod;
7
8
  //# sourceMappingURL=retry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/functions/retry.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACnD;AAED,wBAAgB,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,0BAOrC,GAE/B,+GAmBA"}
1
+ {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/functions/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAgB,MAAM,kBAAkB,CAAC;AAEpF,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACnD;AAED,wBAAgB,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,IAGlD,OAAO,SAAS,EAAE,SAAS,aAAa,KAAG,SAAS,CAuBtE"}
@@ -1,29 +1,27 @@
1
- import { createMethodDecorator } from "../create-method-decorator";
1
+ import { sharedMethod } from "../shared-method";
2
2
  export function Retry(maxAttempts, options = {}) {
3
3
  const { delay = 0, backoff = 1, onRetry } = options;
4
- return createMethodDecorator({
5
- wrap(original, instance) {
6
- return async (...args) => {
7
- let lastError = new Error("Unknown error");
8
- let currentDelay = delay;
9
- for (let attempt = 1; attempt <= maxAttempts; attempt++) {
10
- try {
11
- return await original.apply(instance, args);
12
- }
13
- catch (e) {
14
- lastError = e instanceof Error ? e : new Error(String(e));
15
- if (attempt === maxAttempts)
16
- break;
17
- onRetry?.(lastError, attempt);
18
- if (currentDelay > 0) {
19
- await new Promise((res) => setTimeout(res, currentDelay));
20
- currentDelay = Math.round(currentDelay * backoff);
21
- }
4
+ return function (value, context) {
5
+ return sharedMethod(context, value, async function (...args) {
6
+ let lastError = new Error("Unknown error");
7
+ let currentDelay = delay;
8
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
9
+ try {
10
+ return await value.apply(this, args);
11
+ }
12
+ catch (e) {
13
+ lastError = e instanceof Error ? e : new Error(String(e));
14
+ if (attempt === maxAttempts)
15
+ break;
16
+ onRetry?.(lastError, attempt);
17
+ if (currentDelay > 0) {
18
+ await new Promise((res) => setTimeout(res, currentDelay));
19
+ currentDelay = Math.round(currentDelay * backoff);
22
20
  }
23
21
  }
24
- throw lastError;
25
- };
26
- },
27
- });
22
+ }
23
+ throw lastError;
24
+ });
25
+ };
28
26
  }
29
27
  //# sourceMappingURL=retry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/functions/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC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ACJ,CAAC"}
@@ -1,2 +1,3 @@
1
- export declare function Throttle(ms: number): (value: (this: object, ...args: any[]) => any, context: ClassMethodDecoratorContext<import("@praxisjs/core").StatefulComponent>) => void;
1
+ import { type AnyMethod, type MethodContext } from "../shared-method";
2
+ export declare function Throttle(ms: number): (value: AnyMethod, context: MethodContext) => AnyMethod;
2
3
  //# sourceMappingURL=throttle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../src/functions/throttle.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,0BAcuC,GAAI,+GAD7E"}
1
+ {"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../src/functions/throttle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAgB,MAAM,kBAAkB,CAAC;AAEpF,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,IAEhB,OAAO,SAAS,EAAE,SAAS,aAAa,KAAG,SAAS,CAUtE"}
@@ -1,17 +1,15 @@
1
- import { createMethodDecorator } from "../create-method-decorator";
1
+ import { sharedMethod } from "../shared-method";
2
2
  export function Throttle(ms) {
3
- return createMethodDecorator({
4
- wrap(original, instance) {
5
- const clampedMs = Math.max(0, ms);
6
- let last = 0;
7
- return (...args) => {
8
- const now = Date.now();
9
- if (now - last < clampedMs)
10
- return;
11
- last = now;
12
- return original.apply(instance, args);
13
- };
14
- },
15
- });
3
+ const clampedMs = Math.max(0, ms);
4
+ return function (value, context) {
5
+ const last = Symbol(`praxis.throttle.${String(context.name)}`);
6
+ return sharedMethod(context, value, function (...args) {
7
+ const now = Date.now();
8
+ if (now - (this[last] ?? 0) < clampedMs)
9
+ return;
10
+ this[last] = now;
11
+ return value.apply(this, args);
12
+ });
13
+ };
16
14
  }
17
15
  //# sourceMappingURL=throttle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"throttle.js","sourceRoot":"","sources":["../../src/functions/throttle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,UAAU,QAAQ,CAAC,EAAU;IACjC,OAAO,qBAAqB,CAAC;QAC3B,IAAI,CAAC,QAAQ,EAAE,QAAQ;YACrB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAClC,IAAI,IAAI,GAAG,CAAC,CAAC;YACb,OAAO,CAAC,GAAG,IAAe,EAAE,EAAE;gBAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;gBACvB,IAAI,GAAG,GAAG,IAAI,GAAG,SAAS;oBAAE,OAAO;gBACnC,IAAI,GAAG,GAAG,CAAC;gBACX,OAAO,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAY,CAAC;YACnD,CAAC,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"throttle.js","sourceRoot":"","sources":["../../src/functions/throttle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsC,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEpF,MAAM,UAAU,QAAQ,CAAC,EAAU;IACjC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAClC,OAAO,UAAU,KAAgB,EAAE,OAAsB;QACvD,MAAM,IAAI,GAAG,MAAM,CAAC,mBAAmB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAE/D,OAAO,YAAY,CAAC,OAAO,EAAE,KAAK,EAAE,UAAsB,GAAG,IAAe;YAC1E,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACvB,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS;gBAAE,OAAO;YAChD,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;YACjB,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -1,2 +1,3 @@
1
- export declare function Until(propName: string): (value: (this: object, ...args: any[]) => any, context: ClassMethodDecoratorContext<import("@praxisjs/core").StatefulComponent>) => void;
1
+ import { type AnyMethod, type MethodContext } from "../shared-method";
2
+ export declare function Until(propName: string): (value: AnyMethod, context: MethodContext) => AnyMethod;
2
3
  //# sourceMappingURL=until.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"until.d.ts","sourceRoot":"","sources":["../../src/functions/until.ts"],"names":[],"mappings":"AAMA,wBAAgB,KAAK,CAAC,QAAQ,EAAE,MAAM,0BAOrB,GAAG,+GAKnB"}
1
+ {"version":3,"file":"until.d.ts","sourceRoot":"","sources":["../../src/functions/until.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAgB,MAAM,kBAAkB,CAAC;AAEpF,wBAAgB,KAAK,CAAC,QAAQ,EAAE,MAAM,IACnB,OAAO,SAAS,EAAE,SAAS,aAAa,KAAG,SAAS,CAWtE"}
@@ -1,17 +1,16 @@
1
- import { until } from "@praxisjs/core/internal";
2
- import { isComputed } from "@praxisjs/shared/internal";
3
- import { createMethodDecorator } from "../create-method-decorator";
1
+ import { computed, until } from "@praxisjs/core/internal";
2
+ import { isReactive } from "@praxisjs/shared/internal";
3
+ import { sharedMethod } from "../shared-method";
4
4
  export function Until(propName) {
5
- return createMethodDecorator({
6
- wrap(_original, instance) {
7
- return () => {
8
- const raw = instance[propName];
9
- const source = isComputed(raw)
10
- ? raw
11
- : raw;
12
- return until(source);
13
- };
14
- },
15
- });
5
+ return function (value, context) {
6
+ return sharedMethod(context, value, function () {
7
+ const raw = this[propName];
8
+ // A @State/@Prop field reads as its plain value; reading it inside a computed tracks its signal.
9
+ const source = isReactive(raw)
10
+ ? raw
11
+ : computed(() => this[propName]);
12
+ return until(source);
13
+ });
14
+ };
16
15
  }
17
16
  //# sourceMappingURL=until.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"until.js","sourceRoot":"","sources":["../../src/functions/until.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,UAAU,KAAK,CAAC,QAAgB;IACpC,OAAO,qBAAqB,CAAC;QAC3B,IAAI,CAAC,SAAS,EAAE,QAAQ;YACtB,OAAO,GAAG,EAAE;gBACV,MAAM,GAAG,GAAI,QAAoC,CAAC,QAAQ,CAAC,CAAC;gBAC5D,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC;oBAC5B,CAAC,CAAE,GAAyB;oBAC5B,CAAC,CAAE,GAAuB,CAAC;gBAC7B,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;YACvB,CAAC,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"until.js","sourceRoot":"","sources":["../../src/functions/until.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAsC,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEpF,MAAM,UAAU,KAAK,CAAC,QAAgB;IACpC,OAAO,UAAU,KAAgB,EAAE,OAAsB;QACvD,OAAO,YAAY,CAAC,OAAO,EAAE,KAAK,EAAE;YAClC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC3B,iGAAiG;YACjG,MAAM,MAAM,GACV,UAAU,CAAC,GAAG,CAAC;gBACb,CAAC,CAAE,GAA2C;gBAC9C,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YACrC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -14,6 +14,6 @@ export type WatchVal<T extends StatefulComponent, K extends keyof T> = Unwrap<T[
14
14
  export type WatchVals<T extends StatefulComponent, K extends keyof T> = {
15
15
  [P in K]: Unwrap<T[P]>;
16
16
  };
17
- export declare function Watch<T extends StatefulComponent, const Keys extends ReadonlyArray<WatchableKeys<T>>>(...propNames: ValidateKeys<T, Keys>): (value: (this: T, ...args: any[]) => void, _context: ClassMethodDecoratorContext<T, (this: T, ...args: any) => any>) => void;
17
+ export declare function Watch<T extends StatefulComponent, const Keys extends ReadonlyArray<WatchableKeys<T>>>(...propNames: ValidateKeys<T, Keys>): (value: (this: T, ...args: any[]) => void, context: ClassMethodDecoratorContext<T, (this: T, ...args: any) => any>) => void;
18
18
  export {};
19
19
  //# sourceMappingURL=watch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/functions/watch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAKjD,KAAK,iBAAiB,GAAG,MAAM,iBAAiB,CAAC;AAEjD,KAAK,aAAa,CAAC,CAAC,IAAI;KACrB,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CACvD,GAAG,IAAI,EAAE,MAAM,CAAC,KACb,OAAO,GACR,CAAC,SAAS,EAAE,GACV,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,CAAC,OAAO,CAAC,GAC5B,CAAC,GACD,KAA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CAAC,CAAC,IAC1C,YAAY,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,GAAG,YAAY,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AAE1E,KAAK,MAAM,CAAC,CAAC,IACX,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,MAAM,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEpE,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,iBAAiB,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,MAAM,CAC3E,CAAC,CAAC,CAAC,CAAC,CACL,CAAC;AACF,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,iBAAiB,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI;KACrE,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACvB,CAAC;AAOF,wBAAgB,KAAK,CACnB,CAAC,SAAS,iBAAiB,EAC3B,KAAK,CAAC,IAAI,SAAS,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAClD,GAAG,SAAS,EAAE,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,+HA2CpC"}
@@ -1,47 +1,49 @@
1
- import { effect, batch } from "@praxisjs/core/internal";
1
+ import { batch, createEffect } from "@praxisjs/core/internal";
2
2
  import { isComputed } from "@praxisjs/shared/internal";
3
- import { createLifecycleMethodDecorator } from "../create-lifecycle-method-decorator";
3
+ import { lifecycleMethodDecorator } from "../create-lifecycle-method-decorator";
4
4
  function readValue(instance, key) {
5
5
  const raw = instance[key];
6
6
  return isComputed(raw) ? raw() : raw;
7
7
  }
8
8
  export function Watch(...propNames) {
9
9
  const props = propNames;
10
- return createLifecycleMethodDecorator({
11
- register(callback, instance) {
10
+ if (props.length === 1) {
11
+ const key = props[0];
12
+ return lifecycleMethodDecorator((instance, method) => {
12
13
  const inst = instance;
13
- if (props.length === 1) {
14
- let oldVal = readValue(inst, props[0]);
15
- return effect(() => {
16
- const newVal = readValue(inst, props[0]);
17
- if (!Object.is(newVal, oldVal)) {
18
- callback(newVal, oldVal);
19
- oldVal = newVal;
20
- }
21
- });
22
- }
23
- const read = () => Object.fromEntries(props.map((p) => [p, readValue(inst, p)]));
24
- let oldVals = read();
25
- let latestVals = oldVals;
26
- let scheduled = false;
27
- return effect(() => {
28
- const newVals = read();
29
- if (props.some((p) => !Object.is(newVals[p], oldVals[p]))) {
30
- latestVals = newVals;
31
- if (!scheduled) {
32
- scheduled = true;
33
- const prevVals = oldVals;
34
- queueMicrotask(() => {
35
- scheduled = false;
36
- oldVals = latestVals;
37
- batch(() => {
38
- callback(latestVals, prevVals);
39
- });
40
- });
41
- }
14
+ let oldVal = readValue(inst, key);
15
+ return createEffect(() => {
16
+ const newVal = readValue(inst, key);
17
+ if (!Object.is(newVal, oldVal)) {
18
+ method.call(inst, newVal, oldVal);
19
+ oldVal = newVal;
42
20
  }
43
21
  });
44
- },
22
+ });
23
+ }
24
+ return lifecycleMethodDecorator((instance, method) => {
25
+ const inst = instance;
26
+ const read = () => Object.fromEntries(props.map((p) => [p, readValue(inst, p)]));
27
+ let oldVals = read();
28
+ let latestVals = oldVals;
29
+ let scheduled = false;
30
+ return createEffect(() => {
31
+ const newVals = read();
32
+ if (props.some((p) => !Object.is(newVals[p], oldVals[p]))) {
33
+ latestVals = newVals;
34
+ if (!scheduled) {
35
+ scheduled = true;
36
+ const prevVals = oldVals;
37
+ queueMicrotask(() => {
38
+ scheduled = false;
39
+ oldVals = latestVals;
40
+ batch(() => {
41
+ method.call(inst, latestVals, prevVals);
42
+ });
43
+ });
44
+ }
45
+ }
46
+ });
45
47
  });
46
48
  }
47
49
  //# sourceMappingURL=watch.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/functions/watch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,K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AAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC1D,UAAU,GAAG,OAAO,CAAC;gBACrB,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,SAAS,GAAG,IAAI,CAAC;oBACjB,MAAM,QAAQ,GAAG,OAAO,CAAC;oBACzB,cAAc,CAAC,GAAG,EAAE;wBAClB,SAAS,GAAG,KAAK,CAAC;wBAClB,OAAO,GAAG,UAAU,CAAC;wBACrB,KAAK,CAAC,GAAG,EAAE;4BACT,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;wBAC1C,CAAC,CAAC,CAAC;oBACL,CAAC,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare function When<T = unknown>(propName: string, condition?: (value: NonNullable<T>) => boolean): (value: (this: import("@praxisjs/core").StatefulComponent, ...args: any[]) => void, _context: ClassMethodDecoratorContext<import("@praxisjs/core").StatefulComponent, (this: import("@praxisjs/core").StatefulComponent, ...args: any) => any>) => void;
1
+ export declare function When<T = unknown>(propName: string, condition?: (value: NonNullable<T>) => boolean): (value: (this: object, ...args: any[]) => void, context: ClassMethodDecoratorContext<object, (this: object, ...args: any) => any>) => void;
2
2
  //# sourceMappingURL=when.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"when.d.ts","sourceRoot":"","sources":["../../src/functions/when.ts"],"names":[],"mappings":"AAcA,wBAAgB,IAAI,CAAC,CAAC,GAAG,OAAO,EAC9B,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,OAAO,2PAwB/C"}
1
+ {"version":3,"file":"when.d.ts","sourceRoot":"","sources":["../../src/functions/when.ts"],"names":[],"mappings":"AAcA,wBAAgB,IAAI,CAAC,CAAC,GAAG,OAAO,EAC9B,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,OAAO,8IAsB/C"}
@@ -1,6 +1,6 @@
1
- import { effect } from "@praxisjs/core/internal";
1
+ import { createEffect } from "@praxisjs/core/internal";
2
2
  import { isComputed, isSignal } from "@praxisjs/shared/internal";
3
- import { createLifecycleMethodDecorator } from "../create-lifecycle-method-decorator";
3
+ import { lifecycleMethodDecorator } from "../create-lifecycle-method-decorator";
4
4
  /** Read the current value of a property, unwrapping Signal or Computed if needed. */
5
5
  function readProp(instance, key) {
6
6
  const raw = instance[key];
@@ -11,25 +11,23 @@ function readProp(instance, key) {
11
11
  return raw;
12
12
  }
13
13
  export function When(propName, condition) {
14
- return createLifecycleMethodDecorator({
15
- register(callback, instance) {
16
- const inst = instance;
17
- let fired = false;
18
- return effect(() => {
19
- if (fired)
20
- return;
21
- // Reading via readProp subscribes this effect to the underlying signal,
22
- // whether the property is a raw Signal/Computed or an @State getter.
23
- const val = readProp(inst, propName);
24
- const meetsCondition = condition
25
- ? val != null && condition(val)
26
- : val != null && Boolean(val);
27
- if (meetsCondition) {
28
- fired = true;
29
- callback(val);
30
- }
31
- });
32
- },
14
+ return lifecycleMethodDecorator((instance, method) => {
15
+ const inst = instance;
16
+ let fired = false;
17
+ return createEffect(() => {
18
+ if (fired)
19
+ return;
20
+ // Reading via readProp subscribes this effect to the underlying signal,
21
+ // whether the property is a raw Signal/Computed or an @State getter.
22
+ const val = readProp(inst, propName);
23
+ const meetsCondition = condition
24
+ ? val != null && condition(val)
25
+ : val != null && Boolean(val);
26
+ if (meetsCondition) {
27
+ fired = true;
28
+ method.call(inst, val);
29
+ }
30
+ });
33
31
  });
34
32
  }
35
33
  //# sourceMappingURL=when.js.map
@@ -1 +1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L,CAAC,CAAC,CAAC;AACL,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export { Component, Lazy } from "./component";
2
2
  export { Memo, type MemoOptions, Bind, Log, Once, Retry, Debounce, Throttle, When, Until, Watch, type WatchVal, type WatchVals, } from "./functions";
3
- export { Prop, FunctionProp, State, Computed, Persisted, Slot, initSlots, History, type HistoryOf, Compose, getter, Resource, invalidateResource, type ResourceInstance, type ResourceOptions, Synced, DeepState, Ref, createRef, } from "./properties";
3
+ export { Prop, FunctionProp, State, Computed, Persisted, Slot, initSlots, History, type HistoryOf, Compose, getter, Resource, invalidateResource, type ResourceInstance, type ResourceOptions, Synced, DeepState, Ref, createRef, Selector, type SelectorOptions, } from "./properties";
4
4
  export { Command, createCommand, Emit, OnCommand } from "./events";
5
- export { createFieldDecorator, type FieldBehavior, type FieldBinding, } from "./create-field-decorator";
5
+ export { addClaimableInitializer, assertFieldContext, type FieldDecorator } from "./field";
6
+ export { createFieldDecorator, type FieldBehavior, type FieldBinding, type FieldSetup, type SharedFieldBehavior, } from "./create-field-decorator";
6
7
  export { reactiveHostType, type ReactiveHost } from "./reactive-host";
7
8
  export { createClassDecorator, ClassBehavior, type ClassEnhancement, } from "./create-class-decorator";
8
- export { createMethodDecorator, type MethodBehavior, } from "./create-method-decorator";
9
+ export { createMethodDecorator, type MethodBehavior, type MethodDecorator, type MethodSetup, type SharedMethodBehavior, } from "./create-method-decorator";
9
10
  export { createLifecycleMethodDecorator, type LifecycleMethodBehavior, } from "./create-lifecycle-method-decorator";
10
- export { createGetterDecorator, type GetterBehavior, createWritableGetterDecorator, type WritableGetterBehavior, type WritableGetterBinding, createGetterObserverDecorator, type GetterObserverBehavior, } from "./create-getter-decorator";
11
- export { createAccessorDecorator, type AccessorBehavior, type AccessorBinding, } from "./create-accessor-decorator";
11
+ export { createGetterDecorator, type GetterBehavior, type GetterDecorator, type GetterSetup, type SharedGetterBehavior, createWritableGetterDecorator, type WritableGetterBehavior, type WritableGetterBinding, type SharedWritableGetterBehavior, createGetterObserverDecorator, type GetterObserverBehavior, } from "./create-getter-decorator";
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EACL,IAAI,EACJ,KAAK,WAAW,EAChB,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,KAAK,EACL,KAAK,QAAQ,EACb,KAAK,SAAS,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,SAAS,EACT,OAAO,EACP,KAAK,SAAS,EACd,OAAO,EACP,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,MAAM,EACN,SAAS,EACT,GAAG,EACH,SAAS,GACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EACL,oBAAoB,EACpB,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,KAAK,gBAAgB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,qBAAqB,EACrB,KAAK,cAAc,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,8BAA8B,EAC9B,KAAK,uBAAuB,GAC7B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,qBAAqB,EACrB,KAAK,cAA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oBAAoB,EACpB,aAAa,EACb,KAAK,gBAAgB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,qBAAqB,EACrB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,oBAAoB,GAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,8BAA8B,EAC9B,KAAK,uBAAuB,GAC7B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,qBAAqB,EACrB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,6BAA6B,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,6BAA6B,EAC7B,KAAK,sBAAsB,GAC5B,MAAM,2BAA2B,CAAC"}
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  export { Component, Lazy } from "./component";
2
2
  export { Memo, Bind, Log, Once, Retry, Debounce, Throttle, When, Until, Watch, } from "./functions";
3
- export { Prop, FunctionProp, State, Computed, Persisted, Slot, initSlots, History, Compose, getter, Resource, invalidateResource, Synced, DeepState, Ref, createRef, } from "./properties";
3
+ export { Prop, FunctionProp, State, Computed, Persisted, Slot, initSlots, History, Compose, getter, Resource, invalidateResource, Synced, DeepState, Ref, createRef, Selector, } from "./properties";
4
4
  export { Command, createCommand, Emit, OnCommand } from "./events";
5
+ export { addClaimableInitializer, assertFieldContext } from "./field";
5
6
  export { createFieldDecorator, } from "./create-field-decorator";
6
7
  export { reactiveHostType } from "./reactive-host";
7
8
  export { createClassDecorator, ClassBehavior, } from "./create-class-decorator";
8
9
  export { createMethodDecorator, } from "./create-method-decorator";
9
10
  export { createLifecycleMethodDecorator, } from "./create-lifecycle-method-decorator";
10
11
  export { createGetterDecorator, createWritableGetterDecorator, createGetterObserverDecorator, } from "./create-getter-decorator";
11
- export { createAccessorDecorator, } from "./create-accessor-decorator";
12
12
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EACL,IAAI,EAEJ,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,KAAK,GAGN,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,SAAS,EACT,OAAO,EAEP,OAAO,EACP,MAAM,EACN,QAAQ,EACR,kBAAkB,EAGlB,MAAM,EACN,SAAS,EACT,GAAG,EACH,SAAS,GACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EACL,oBAAoB,GAGrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAqB,MAAM,iBAAiB,CAAC;AACtE,OAAO,EACL,oBAAoB,EACpB,aAAa,GAEd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,qBAAqB,GAEtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,8BAA8B,GAE/B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,qBAAqB,EAErB,6BAA6B,EAG7B,6BAA6B,GAE9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,uBAAuB,GAGxB,MAAM,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EACL,IAAI,EAEJ,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,KAAK,GAGN,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,SAAS,EACT,OAAO,EAEP,OAAO,EACP,MAAM,EACN,QAAQ,EACR,kBAAkB,EAGlB,MAAM,EACN,SAAS,EACT,GAAG,EACH,SAAS,EACT,QAAQ,GAET,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAuB,MAAM,SAAS,CAAC;AAC3F,OAAO,EACL,oBAAoB,GAKrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAqB,MAAM,iBAAiB,CAAC;AACtE,OAAO,EACL,oBAAoB,EACpB,aAAa,GAEd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,qBAAqB,GAKtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,8BAA8B,GAE/B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,qBAAqB,EAKrB,6BAA6B,EAI7B,6BAA6B,GAE9B,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { type EffectNode } from "@praxisjs/core/internal";
2
+ export type LifecycleHook = (instance: object) => void;
3
+ export interface LifecycleHost {
4
+ onMount?: ((this: object) => void) | undefined;
5
+ onUnmount?: ((this: object) => void) | undefined;
6
+ }
7
+ /** What a mount registration leaves to undo on unmount: a stop function or an effect to dispose. */
8
+ export type LifecycleCleanup = (() => void) | EffectNode | undefined | void;
9
+ /**
10
+ * Runs `mount` / `unmount` (called with the instance) after the instance's current `onMount` /
11
+ * `onUnmount`, and so after the hooks added before them. Calling `instance.onMount()` by hand runs
12
+ * them too.
13
+ *
14
+ * The previous hooks are called with `this` rather than bound to the instance: two closures per
15
+ * hook pair are all this allocates.
16
+ */
17
+ export declare function addLifecycleHooks(object: object, mount: LifecycleHook | undefined, unmount: LifecycleHook | undefined): void;
18
+ /**
19
+ * Calls `start(instance, arg)` on every mount and undoes what it returned on unmount. Like
20
+ * `addLifecycleHooks`, it chains onto the instance's hooks with two closures and no bound
21
+ * functions; the cleanup lives in their shared scope.
22
+ */
23
+ export declare function addMountRegistration<T extends object, A>(object: T, start: (instance: T, arg: A) => LifecycleCleanup, arg: A): void;
24
+ //# sourceMappingURL=lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAEzE,MAAM,MAAM,aAAa,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;AAEvD,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC/C,SAAS,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAClD;AAED,oGAAoG;AAEpG,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,UAAU,GAAG,SAAS,GAAG,IAAI,CAAC;AAE5E;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,aAAa,GAAG,SAAS,EAChC,OAAO,EAAE,aAAa,GAAG,SAAS,GACjC,IAAI,CAYN;AAOD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EACtD,MAAM,EAAE,CAAC,EACT,KAAK,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,gBAAgB,EAChD,GAAG,EAAE,CAAC,GACL,IAAI,CAoBN"}
@@ -0,0 +1,55 @@
1
+ import { disposeEffect } from "@praxisjs/core/internal";
2
+ /**
3
+ * Runs `mount` / `unmount` (called with the instance) after the instance's current `onMount` /
4
+ * `onUnmount`, and so after the hooks added before them. Calling `instance.onMount()` by hand runs
5
+ * them too.
6
+ *
7
+ * The previous hooks are called with `this` rather than bound to the instance: two closures per
8
+ * hook pair are all this allocates.
9
+ */
10
+ export function addLifecycleHooks(object, mount, unmount) {
11
+ const instance = object;
12
+ const prevMount = instance.onMount;
13
+ const prevUnmount = instance.onUnmount;
14
+ instance.onMount = function () {
15
+ prevMount?.call(this);
16
+ mount?.(this);
17
+ };
18
+ instance.onUnmount = function () {
19
+ prevUnmount?.call(this);
20
+ unmount?.(this);
21
+ };
22
+ }
23
+ function stop(cleanup) {
24
+ if (typeof cleanup === "function")
25
+ cleanup();
26
+ else if (cleanup != null)
27
+ disposeEffect(cleanup);
28
+ }
29
+ /**
30
+ * Calls `start(instance, arg)` on every mount and undoes what it returned on unmount. Like
31
+ * `addLifecycleHooks`, it chains onto the instance's hooks with two closures and no bound
32
+ * functions; the cleanup lives in their shared scope.
33
+ */
34
+ export function addMountRegistration(object, start, arg) {
35
+ const instance = object;
36
+ const prevMount = instance.onMount;
37
+ const prevUnmount = instance.onUnmount;
38
+ let cleanup;
39
+ instance.onMount = function () {
40
+ prevMount?.call(this);
41
+ // A second onMount() without an onUnmount() in between would otherwise leak the first
42
+ // registration, which nothing could stop anymore.
43
+ const previous = cleanup;
44
+ cleanup = undefined;
45
+ stop(previous);
46
+ cleanup = start(this, arg);
47
+ };
48
+ instance.onUnmount = function () {
49
+ prevUnmount?.call(this);
50
+ const previous = cleanup;
51
+ cleanup = undefined;
52
+ stop(previous);
53
+ };
54
+ }
55
+ //# sourceMappingURL=lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"A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C,CAAC;IAClC,CAAC,CAAC;IACF,QAAQ,CAAC,SAAS,GAAG;QACnB,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACxB,MAAM,QAAQ,GAAG,OAAO,CAAC;QACzB,OAAO,GAAG,SAAS,CAAC;QACpB,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC"}
@@ -1,10 +1,11 @@
1
- import type { StatefulComponent, Composable } from "@praxisjs/core";
1
+ import type { Composable } from "@praxisjs/core";
2
+ import { type FieldDecorator } from "../field";
2
3
  interface ComposeFactory {
3
4
  __isComposeFactory: true;
4
5
  resolve: (instance: object) => unknown;
5
6
  }
6
7
  /** Wraps a property as a live getter — passes `() => instance[propName]` to the composable. */
7
8
  export declare function getter(propName: string): ComposeFactory;
8
- export declare function Compose(ComposableClass: new (...args: any[]) => Composable, ...ctorArgs: unknown[]): <This extends StatefulComponent, Value = unknown>(_value: undefined, context: ClassFieldDecoratorContext<This, Value>) => void;
9
+ export declare function Compose(ComposableClass: new (...args: any[]) => Composable, ...ctorArgs: unknown[]): FieldDecorator;
9
10
  export {};
10
11
  //# sourceMappingURL=compose.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/properties/compose.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAIpE,UAAU,cAAc;IAAG,kBAAkB,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAA;CAAE;AAE7F,+FAA+F;AAC/F,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,CAKvD;AA6BD,wBAAgB,OAAO,CAErB,eAAe,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,UAAU,EACnD,GAAG,QAAQ,EAAE,OAAO,EAAE,kIAqBvB"}
1
+ {"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/properties/compose.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,KAAK,cAAc,EAA+B,MAAM,UAAU,CAAC;AAG5E,UAAU,cAAc;IAAG,kBAAkB,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAA;CAAE;AAE7F,+FAA+F;AAC/F,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,CAKvD;AA6BD,wBAAgB,OAAO,CAErB,eAAe,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,UAAU,EACnD,GAAG,QAAQ,EAAE,OAAO,EAAE,GACrB,cAAc,CAgChB"}