@praxisjs/decorators 0.4.3 → 0.5.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 (175) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/__tests__/component.test.js +10 -1
  3. package/dist/__tests__/component.test.js.map +1 -1
  4. package/dist/__tests__/compose.test.d.ts +2 -0
  5. package/dist/__tests__/compose.test.d.ts.map +1 -0
  6. package/dist/__tests__/compose.test.js +171 -0
  7. package/dist/__tests__/compose.test.js.map +1 -0
  8. package/dist/__tests__/events.test.js +26 -0
  9. package/dist/__tests__/events.test.js.map +1 -1
  10. package/dist/__tests__/functions.test.js +142 -47
  11. package/dist/__tests__/functions.test.js.map +1 -1
  12. package/dist/__tests__/lazy.test.js +5 -7
  13. package/dist/__tests__/lazy.test.js.map +1 -1
  14. package/dist/__tests__/memo.test.js +61 -25
  15. package/dist/__tests__/memo.test.js.map +1 -1
  16. package/dist/__tests__/resource.test.d.ts +2 -0
  17. package/dist/__tests__/resource.test.d.ts.map +1 -0
  18. package/dist/__tests__/resource.test.js +103 -0
  19. package/dist/__tests__/resource.test.js.map +1 -0
  20. package/dist/__tests__/slot.test.js +32 -0
  21. package/dist/__tests__/slot.test.js.map +1 -1
  22. package/dist/__tests__/virtual.test.js +56 -15
  23. package/dist/__tests__/virtual.test.js.map +1 -1
  24. package/dist/component/component.d.ts +1 -1
  25. package/dist/component/component.d.ts.map +1 -1
  26. package/dist/component/component.js +15 -10
  27. package/dist/component/component.js.map +1 -1
  28. package/dist/component/lazy.d.ts.map +1 -1
  29. package/dist/component/lazy.js +29 -30
  30. package/dist/component/lazy.js.map +1 -1
  31. package/dist/component/virtual.d.ts.map +1 -1
  32. package/dist/component/virtual.js +46 -50
  33. package/dist/component/virtual.js.map +1 -1
  34. package/dist/create-class-decorator.d.ts +16 -0
  35. package/dist/create-class-decorator.d.ts.map +1 -0
  36. package/dist/create-class-decorator.js +35 -0
  37. package/dist/create-class-decorator.js.map +1 -0
  38. package/dist/create-field-decorator.d.ts +14 -0
  39. package/dist/create-field-decorator.d.ts.map +1 -0
  40. package/dist/create-field-decorator.js +37 -0
  41. package/dist/create-field-decorator.js.map +1 -0
  42. package/dist/create-getter-decorator.d.ts +18 -0
  43. package/dist/create-getter-decorator.d.ts.map +1 -0
  44. package/dist/create-getter-decorator.js +15 -0
  45. package/dist/create-getter-decorator.js.map +1 -0
  46. package/dist/create-lifecycle-method-decorator.d.ts +6 -0
  47. package/dist/create-lifecycle-method-decorator.d.ts.map +1 -0
  48. package/dist/create-lifecycle-method-decorator.js +22 -0
  49. package/dist/create-lifecycle-method-decorator.js.map +1 -0
  50. package/dist/create-method-decorator.d.ts +6 -0
  51. package/dist/create-method-decorator.d.ts.map +1 -0
  52. package/dist/create-method-decorator.js +14 -0
  53. package/dist/create-method-decorator.js.map +1 -0
  54. package/dist/events/emit.d.ts +1 -1
  55. package/dist/events/emit.d.ts.map +1 -1
  56. package/dist/events/emit.js +24 -29
  57. package/dist/events/emit.js.map +1 -1
  58. package/dist/events/on-command.d.ts +1 -2
  59. package/dist/events/on-command.d.ts.map +1 -1
  60. package/dist/events/on-command.js +15 -32
  61. package/dist/events/on-command.js.map +1 -1
  62. package/dist/functions/bind.d.ts +1 -2
  63. package/dist/functions/bind.d.ts.map +1 -1
  64. package/dist/functions/bind.js +4 -11
  65. package/dist/functions/bind.js.map +1 -1
  66. package/dist/functions/debounce.d.ts +1 -2
  67. package/dist/functions/debounce.d.ts.map +1 -1
  68. package/dist/functions/debounce.js +12 -20
  69. package/dist/functions/debounce.js.map +1 -1
  70. package/dist/functions/log.d.ts +1 -2
  71. package/dist/functions/log.d.ts.map +1 -1
  72. package/dist/functions/log.js +40 -38
  73. package/dist/functions/log.js.map +1 -1
  74. package/dist/functions/memo.d.ts +1 -2
  75. package/dist/functions/memo.d.ts.map +1 -1
  76. package/dist/functions/memo.js +15 -27
  77. package/dist/functions/memo.js.map +1 -1
  78. package/dist/functions/once.d.ts +1 -2
  79. package/dist/functions/once.d.ts.map +1 -1
  80. package/dist/functions/once.js +14 -12
  81. package/dist/functions/once.js.map +1 -1
  82. package/dist/functions/retry.d.ts +1 -2
  83. package/dist/functions/retry.d.ts.map +1 -1
  84. package/dist/functions/retry.js +23 -20
  85. package/dist/functions/retry.js.map +1 -1
  86. package/dist/functions/throttle.d.ts +1 -2
  87. package/dist/functions/throttle.d.ts.map +1 -1
  88. package/dist/functions/throttle.js +9 -16
  89. package/dist/functions/throttle.js.map +1 -1
  90. package/dist/functions/watch.d.ts +1 -1
  91. package/dist/functions/watch.d.ts.map +1 -1
  92. package/dist/functions/watch.js +25 -39
  93. package/dist/functions/watch.js.map +1 -1
  94. package/dist/functions/when.d.ts +1 -2
  95. package/dist/functions/when.d.ts.map +1 -1
  96. package/dist/functions/when.js +10 -26
  97. package/dist/functions/when.js.map +1 -1
  98. package/dist/index.d.ts +6 -1
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/index.js +6 -1
  101. package/dist/index.js.map +1 -1
  102. package/dist/properties/compose.d.ts +3 -0
  103. package/dist/properties/compose.d.ts.map +1 -0
  104. package/dist/properties/compose.js +40 -0
  105. package/dist/properties/compose.js.map +1 -0
  106. package/dist/properties/computed.d.ts +1 -2
  107. package/dist/properties/computed.d.ts.map +1 -1
  108. package/dist/properties/computed.js +10 -9
  109. package/dist/properties/computed.js.map +1 -1
  110. package/dist/properties/history.d.ts.map +1 -1
  111. package/dist/properties/history.js +37 -32
  112. package/dist/properties/history.js.map +1 -1
  113. package/dist/properties/index.d.ts +2 -0
  114. package/dist/properties/index.d.ts.map +1 -1
  115. package/dist/properties/index.js +2 -0
  116. package/dist/properties/index.js.map +1 -1
  117. package/dist/properties/persisted.d.ts +1 -2
  118. package/dist/properties/persisted.d.ts.map +1 -1
  119. package/dist/properties/persisted.js +13 -29
  120. package/dist/properties/persisted.js.map +1 -1
  121. package/dist/properties/prop.d.ts +1 -2
  122. package/dist/properties/prop.d.ts.map +1 -1
  123. package/dist/properties/prop.js +21 -25
  124. package/dist/properties/prop.js.map +1 -1
  125. package/dist/properties/resource.d.ts +14 -0
  126. package/dist/properties/resource.d.ts.map +1 -0
  127. package/dist/properties/resource.js +27 -0
  128. package/dist/properties/resource.js.map +1 -0
  129. package/dist/properties/slot.d.ts +1 -2
  130. package/dist/properties/slot.d.ts.map +1 -1
  131. package/dist/properties/slot.js +15 -20
  132. package/dist/properties/slot.js.map +1 -1
  133. package/dist/properties/state.d.ts +1 -2
  134. package/dist/properties/state.d.ts.map +1 -1
  135. package/dist/properties/state.js +13 -18
  136. package/dist/properties/state.js.map +1 -1
  137. package/package.json +2 -2
  138. package/src/__tests__/component.test.ts +10 -0
  139. package/src/__tests__/compose.test.ts +202 -0
  140. package/src/__tests__/events.test.ts +32 -0
  141. package/src/__tests__/functions.test.ts +177 -46
  142. package/src/__tests__/lazy.test.ts +3 -5
  143. package/src/__tests__/memo.test.ts +76 -25
  144. package/src/__tests__/resource.test.ts +113 -0
  145. package/src/__tests__/slot.test.ts +38 -0
  146. package/src/__tests__/virtual.test.ts +26 -7
  147. package/src/component/component.ts +27 -12
  148. package/src/component/lazy.ts +33 -37
  149. package/src/component/virtual.tsx +62 -75
  150. package/src/create-class-decorator.ts +61 -0
  151. package/src/create-field-decorator.ts +66 -0
  152. package/src/create-getter-decorator.ts +52 -0
  153. package/src/create-lifecycle-method-decorator.ts +38 -0
  154. package/src/create-method-decorator.ts +26 -0
  155. package/src/events/emit.ts +22 -33
  156. package/src/events/on-command.ts +22 -47
  157. package/src/functions/bind.ts +4 -15
  158. package/src/functions/debounce.ts +11 -26
  159. package/src/functions/log.ts +40 -43
  160. package/src/functions/memo.ts +15 -45
  161. package/src/functions/once.ts +13 -16
  162. package/src/functions/retry.ts +21 -22
  163. package/src/functions/throttle.ts +9 -23
  164. package/src/functions/watch.ts +27 -43
  165. package/src/functions/when.ts +11 -36
  166. package/src/index.ts +28 -0
  167. package/src/properties/compose.ts +53 -0
  168. package/src/properties/computed.ts +11 -13
  169. package/src/properties/history.ts +42 -41
  170. package/src/properties/index.ts +2 -0
  171. package/src/properties/persisted.ts +17 -58
  172. package/src/properties/prop.ts +21 -31
  173. package/src/properties/resource.ts +34 -0
  174. package/src/properties/slot.ts +17 -30
  175. package/src/properties/state.ts +14 -24
@@ -1,49 +1,35 @@
1
1
  import { effect } from "@praxisjs/core/internal";
2
2
  import { isComputed } from "@praxisjs/shared/internal";
3
+ import { createLifecycleMethodDecorator } from "../create-lifecycle-method-decorator";
3
4
  function readValue(instance, key) {
4
5
  const raw = instance[key];
5
6
  return isComputed(raw) ? raw() : raw;
6
7
  }
7
8
  export function Watch(...propNames) {
8
- return function (value, context) {
9
- const props = propNames;
10
- context.addInitializer(function () {
11
- const instance = this;
12
- // eslint-disable-next-line @typescript-eslint/unbound-method
13
- const originalOnMount = instance.onMount;
14
- // eslint-disable-next-line @typescript-eslint/unbound-method
15
- const originalOnUnmount = instance.onUnmount;
16
- let stopEffect;
17
- instance.onMount = function () {
18
- originalOnMount?.call(this);
19
- if (props.length === 1) {
20
- let oldVal = readValue(this, props[0]);
21
- stopEffect = effect(() => {
22
- const newVal = readValue(this, props[0]);
23
- if (!Object.is(newVal, oldVal)) {
24
- value.call(this, newVal, oldVal);
25
- oldVal = newVal;
26
- }
27
- });
9
+ const props = propNames;
10
+ return createLifecycleMethodDecorator({
11
+ register(callback, instance) {
12
+ 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
+ return effect(() => {
26
+ const newVals = read();
27
+ if (props.some((p) => !Object.is(newVals[p], oldVals[p]))) {
28
+ callback(newVals, oldVals);
29
+ oldVals = newVals;
28
30
  }
29
- else {
30
- const read = () => Object.fromEntries(props.map((p) => [p, readValue(this, p)]));
31
- let oldVals = read();
32
- stopEffect = effect(() => {
33
- const newVals = read();
34
- if (props.some((p) => !Object.is(newVals[p], oldVals[p]))) {
35
- value.call(this, newVals, oldVals);
36
- oldVals = newVals;
37
- }
38
- });
39
- }
40
- };
41
- instance.onUnmount = function () {
42
- originalOnUnmount?.call(this);
43
- stopEffect?.();
44
- stopEffect = undefined;
45
- };
46
- });
47
- };
31
+ });
32
+ },
33
+ });
48
34
  }
49
35
  //# 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,MAAM,yBAAyB,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AA4CvD,SAAS,SAAS,CAAC,QAAiC,EAAE,GAAW;IAC/D,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,GAAyB,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,KAAK,CAGnB,GAAG,SAAgC;IACnC,OAAO,UACL,KAA4C,EAC5C,OAAuC;QAEvC,MAAM,KAAK,GAAG,SAAgC,CAAC;QAE/C,OAAO,CAAC,cAAc,CAAC;YACrB,MAAM,QAAQ,GAAG,IAAmC,CAAC;YACrD,6DAA6D;YAC7D,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC;YACzC,6DAA6D;YAC7D,MAAM,iBAAiB,GAAG,QAAQ,CAAC,SAAS,CAAC;YAC7C,IAAI,UAAoC,CAAC;YAEzC,QAAQ,CAAC,OAAO,GAAG;gBACjB,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;gBAE5B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;o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AAI,GAAG,GAAG,EAAE,CAChB,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAChE,IAAI,OAAO,GAAG,IAAI,EAAE,CAAC;YACrB,OAAO,MAAM,CAAC,GAAG,EAAE;gBACjB,MAAM,OAAO,GAAG,IAAI,EAAE,CAAC;gBACvB,IAAI,KAAK,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;oBAC1D,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;oBAC3B,OAAO,GAAG,OAAO,CAAC;gBACpB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -1,3 +1,2 @@
1
- import type { StatefulComponent } from "@praxisjs/core";
2
- export declare function When(propName: string): (value: (this: StatefulComponent, val: unknown) => void, context: ClassMethodDecoratorContext<StatefulComponent>) => void;
1
+ export declare function When(propName: string): (value: (this: import("@praxisjs/core").StatefulComponent, ...args: unknown[]) => void, _context: ClassMethodDecoratorContext<import("@praxisjs/core").StatefulComponent, (this: import("@praxisjs/core").StatefulComponent, ...args: any) => any>) => void;
3
2
  //# sourceMappingURL=when.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"when.d.ts","sourceRoot":"","sources":["../../src/functions/when.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAKxD,wBAAgB,IAAI,CAAC,QAAQ,EAAE,MAAM,IAEjC,OAAO,CAAC,IAAI,EAAE,iBAAiB,EAAE,GAAG,EAAE,OAAO,KAAK,IAAI,EACtD,SAAS,2BAA2B,CAAC,iBAAiB,CAAC,KACtD,IAAI,CAgCR"}
1
+ {"version":3,"file":"when.d.ts","sourceRoot":"","sources":["../../src/functions/when.ts"],"names":[],"mappings":"AAMA,wBAAgB,IAAI,CAAC,QAAQ,EAAE,MAAM,+PAUpC"}
@@ -1,31 +1,15 @@
1
1
  import { when } from "@praxisjs/core/internal";
2
2
  import { isComputed } from "@praxisjs/shared/internal";
3
+ import { createLifecycleMethodDecorator } from "../create-lifecycle-method-decorator";
3
4
  export function When(propName) {
4
- return function (value, context) {
5
- const cancels = new WeakMap();
6
- context.addInitializer(function () {
7
- const instance = this;
8
- // eslint-disable-next-line @typescript-eslint/unbound-method
9
- const originalOnMount = instance.onMount;
10
- // eslint-disable-next-line @typescript-eslint/unbound-method
11
- const originalOnUnmount = instance.onUnmount;
12
- instance.onMount = function () {
13
- originalOnMount?.call(this);
14
- const raw = this[propName];
15
- const source = isComputed(raw)
16
- ? raw
17
- : raw;
18
- const cancel = when(source, (val) => {
19
- value.call(this, val);
20
- });
21
- cancels.set(this, cancel);
22
- };
23
- instance.onUnmount = function () {
24
- originalOnUnmount?.call(this);
25
- cancels.get(this)?.();
26
- cancels.delete(this);
27
- };
28
- });
29
- };
5
+ return createLifecycleMethodDecorator({
6
+ register(callback, instance) {
7
+ const raw = instance[propName];
8
+ const source = isComputed(raw)
9
+ ? raw
10
+ : raw;
11
+ return when(source, (val) => { callback(val); });
12
+ },
13
+ });
30
14
  }
31
15
  //# sourceMappingURL=when.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"when.js","sourceRoot":"","sources":["../../src/functions/when.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,MAAM,UAAU,IAAI,CAAC,QAAgB;IACnC,OAAO,UACL,KAAsD,EACtD,OAAuD;QAEvD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAsB,CAA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,OAAO,8BAA8B,CAAC;QACpC,QAAQ,CAAC,QAAQ,EAAE,QAAQ;YACzB,MAAM,GAAG,GAAI,QAA+C,CAAC,QAAQ,CAAC,CAAC;YACvE,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC;gBAC5B,CAAC,CAAE,GAAyB;gBAC5B,CAAC,CAAE,GAAuB,CAAC;YAC7B,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  export { Component, Lazy, Virtual } from "./component";
2
2
  export { Memo, Bind, Log, Once, Retry, Debounce, Throttle, When, Watch, type WatchVal, type WatchVals, } from "./functions";
3
- export { Prop, State, Computed, Persisted, Slot, initSlots, History, type WithHistory, } from "./properties";
3
+ export { Prop, State, Computed, Persisted, Slot, initSlots, History, type WithHistory, Compose, Resource, type ResourceInstance, type ResourceOptions, } from "./properties";
4
4
  export { type Command, createCommand, Emit, OnCommand } from "./events";
5
+ export { createFieldDecorator, type FieldBehavior, type FieldBinding, } from "./create-field-decorator";
6
+ export { createClassDecorator, ClassBehavior, type ClassEnhancement, } from "./create-class-decorator";
7
+ export { createMethodDecorator, type MethodBehavior, } from "./create-method-decorator";
8
+ export { createLifecycleMethodDecorator, type LifecycleMethodBehavior, } from "./create-lifecycle-method-decorator";
9
+ export { createGetterDecorator, type GetterBehavior, createGetterObserverDecorator, type GetterObserverBehavior, } from "./create-getter-decorator";
5
10
  //# 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,OAAO,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EACL,IAAI,EACJ,IAAI,EACJ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K,uBAAuB,GAC7B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,qBAAqB,EACrB,KAAK,cAAc,EACnB,6BAA6B,EAC7B,KAAK,sBAAsB,GAC5B,MAAM,2BAA2B,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,10 @@
1
1
  export { Component, Lazy, Virtual } from "./component";
2
2
  export { Memo, Bind, Log, Once, Retry, Debounce, Throttle, When, Watch, } from "./functions";
3
- export { Prop, State, Computed, Persisted, Slot, initSlots, History, } from "./properties";
3
+ export { Prop, State, Computed, Persisted, Slot, initSlots, History, Compose, Resource, } from "./properties";
4
4
  export { createCommand, Emit, OnCommand } from "./events";
5
+ export { createFieldDecorator, } from "./create-field-decorator";
6
+ export { createClassDecorator, ClassBehavior, } from "./create-class-decorator";
7
+ export { createMethodDecorator, } from "./create-method-decorator";
8
+ export { createLifecycleMethodDecorator, } from "./create-lifecycle-method-decorator";
9
+ export { createGetterDecorator, createGetterObserverDecorator, } from "./create-getter-decorator";
5
10
  //# 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,OAAO,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,KAAK,GAGN,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,SAAS,EACT,OAAO,GAER,MAAM,cAAc,CAAC;AACtB,OAAO,EAAgB,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EACL,IAAI,EACJ,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,KAAK,GAGN,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,SAAS,EACT,OAAO,EAEP,OAAO,EACP,QAAQ,GAGT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAgB,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EACL,oBAAoB,GAGrB,MAAM,0BAA0B,CAAC;AAClC,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,GAE9B,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { StatefulComponent, Composable } from "@praxisjs/core";
2
+ export declare function Compose(ComposableClass: new (...args: any[]) => Composable, ...ctorArgs: unknown[]): (_value: undefined, context: ClassFieldDecoratorContext<StatefulComponent>) => void;
3
+ //# sourceMappingURL=compose.d.ts.map
@@ -0,0 +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;AA6BpE,wBAAgB,OAAO,CAErB,eAAe,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,UAAU,EACnD,GAAG,QAAQ,EAAE,OAAO,EAAE,uFAoBvB"}
@@ -0,0 +1,40 @@
1
+ import { createFieldDecorator } from "../create-field-decorator";
2
+ function isReactive(value) {
3
+ return (typeof value === "function" &&
4
+ ("__isSignal" in value || "__isComputed" in value));
5
+ }
6
+ function buildView(bindings) {
7
+ const view = {};
8
+ for (const [key, value] of Object.entries(bindings)) {
9
+ if (isReactive(value)) {
10
+ Object.defineProperty(view, key, {
11
+ get: () => value(),
12
+ enumerable: true,
13
+ configurable: true,
14
+ });
15
+ }
16
+ else {
17
+ view[key] = value;
18
+ }
19
+ }
20
+ return view;
21
+ }
22
+ export function Compose(
23
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
+ ComposableClass, ...ctorArgs) {
25
+ return createFieldDecorator({
26
+ bind(instance, _name, _initialValue) {
27
+ const resolvedArgs = ctorArgs.map((arg) => typeof arg === "string"
28
+ ? instance[arg]
29
+ : arg);
30
+ const composable = new ComposableClass(...resolvedArgs);
31
+ const view = buildView(composable.setup());
32
+ return {
33
+ descriptor: { get: () => view },
34
+ onMount: composable.onMount?.bind(composable),
35
+ onUnmount: composable.onUnmount?.bind(composable),
36
+ };
37
+ },
38
+ });
39
+ }
40
+ //# sourceMappingURL=compose.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose.js","sourceRoot":"","sources":["../../src/properties/compose.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,SAAS,UAAU,CACjB,KAAc;IAEd,OAAO,CACL,OAAO,KAAK,KAAK,UAAU;QAC3B,CAAC,YAAY,IAAK,KAAgB,IAAI,cAAc,IAAK,KAAgB,CAAC,CAC3E,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,QAAiC;IAClD,MAAM,IAAI,GAA4B,EAAE,CAAC;IACzC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpD,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YACtB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE;gBAC/B,GAAG,EAAE,GAAG,EAAE,CAAE,KAAuB,EAAE;gBACrC,UAAU,EAAE,IAAI;gBAChB,YAAY,EAAE,IAAI;aACnB,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,OAAO;AACrB,8DAA8D;AAC9D,eAAmD,EACnD,GAAG,QAAmB;IAEtB,OAAO,oBAAoB,CAAC;QAC1B,IAAI,CAAC,QAA2B,EAAE,KAAa,EAAE,aAAsB;YACrE,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CACxC,OAAO,GAAG,KAAK,QAAQ;gBACrB,CAAC,CAAE,QAA+C,CAAC,GAAG,CAAC;gBACvD,CAAC,CAAC,GAAG,CACR,CAAC;YAEF,MAAM,UAAU,GAAG,IAAI,eAAe,CAAC,GAAG,YAAY,CAAC,CAAC;YACxD,MAAM,IAAI,GAAG,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC;YAE3C,OAAO;gBACL,UAAU,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE;gBAC/B,OAAO,EAAE,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;gBAC7C,SAAS,EAAE,UAAU,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC;aAClD,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -1,3 +1,2 @@
1
- import type { StatefulComponent } from "@praxisjs/core";
2
- export declare function Computed(): <This extends StatefulComponent, T>(target: (this: This) => T, _context: ClassGetterDecoratorContext<This, T>) => (this: This) => T;
1
+ export declare function Computed(): <This, T>(target: (this: This) => T, _context: ClassGetterDecoratorContext<This, T>) => (this: This) => T;
3
2
  //# sourceMappingURL=computed.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"computed.d.ts","sourceRoot":"","sources":["../../src/properties/computed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxD,wBAAgB,QAAQ,KACL,IAAI,SAAS,iBAAiB,EAAE,CAAC,EAChD,QAAQ,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,EACzB,UAAU,2BAA2B,CAAC,IAAI,EAAE,CAAC,CAAC,KAC7C,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,CAYrB"}
1
+ {"version":3,"file":"computed.d.ts","sourceRoot":"","sources":["../../src/properties/computed.ts"],"names":[],"mappings":"AAIA,wBAAgB,QAAQ,8GAavB"}
@@ -1,15 +1,16 @@
1
1
  import { computed } from "@praxisjs/core/internal";
2
+ import { createGetterDecorator } from "../create-getter-decorator";
2
3
  export function Computed() {
3
- return function (target, _context) {
4
- const computedMap = new WeakMap();
5
- return function () {
6
- let c = computedMap.get(this);
4
+ const cache = new WeakMap();
5
+ return createGetterDecorator({
6
+ wrap(original, instance) {
7
+ let c = cache.get(instance);
7
8
  if (!c) {
8
- c = computed(() => target.call(this));
9
- computedMap.set(this, c);
9
+ c = computed(() => original.call(instance));
10
+ cache.set(instance, c);
10
11
  }
11
- return c();
12
- };
13
- };
12
+ return c;
13
+ },
14
+ });
14
15
  }
15
16
  //# sourceMappingURL=computed.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"computed.js","sourceRoot":"","sources":["../../src/properties/computed.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,MAAM,UAAU,QAAQ;IACtB,OAAO,UACL,MAAyB,EACzB,QAA8C;QAE9C,MAAM,WAAW,GAAG,IAAI,OAAO,EAAmB,CAAC;QAEnD,OAAO;YACL,IAAI,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC9B,IAAI,CAAC,CAAC,EAAE,CAAC;gBACP,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;gBACtC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YAC3B,CAAC;YACD,OAAO,CAAC,EAAE,CAAC;QACb,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"computed.js","sourceRoot":"","sources":["../../src/properties/computed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,UAAU,QAAQ;IACtB,MAAM,KAAK,GAAG,IAAI,OAAO,EAAyB,CAAC;IAEnD,OAAO,qBAAqB,CAAC;QAC3B,IAAI,CAAC,QAAQ,EAAE,QAAQ;YACrB,IAAI,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC5B,IAAI,CAAC,CAAC,EAAE,CAAC;gBACP,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAC5C,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;YACzB,CAAC;YACD,OAAO,CAAC,CAAC;QACX,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/properties/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,KAAK,cAAc,EAAW,MAAM,yBAAyB,CAAC;AAGvE,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,MAAM,CACpD,GAAG,MAAM,GAAG,CAAC,SAAS,EACtB,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACrB,CAAC;AAEF,wBAAgB,OAAO,CAAC,KAAK,SAAK,IAE9B,QAAQ,SAAS,EACjB,SAAS,0BAA0B,CAAC,iBAAiB,CAAC,KACrD,IAAI,CAuCR"}
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/properties/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,KAAK,cAAc,EAAW,MAAM,yBAAyB,CAAC;AAKvE,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,MAAM,CACpD,GAAG,MAAM,GAAG,CAAC,SAAS,EACtB,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACrB,CAAC;AAEF,wBAAgB,OAAO,CAAC,KAAK,SAAK,uFA0CjC"}
@@ -1,37 +1,42 @@
1
1
  import { history } from "@praxisjs/core/internal";
2
+ import { createFieldDecorator } from "../create-field-decorator";
2
3
  export function History(limit = 50) {
3
- return function (_value, context) {
4
- const histories = new WeakMap();
5
- context.addInitializer(function () {
6
- const instance = this;
7
- const propertyKey = context.name;
8
- const historyKey = `${propertyKey}History`;
9
- Object.defineProperty(instance, historyKey, {
10
- get() {
11
- if (!histories.has(this)) {
12
- const source = () => this[propertyKey];
13
- const h = history(source, limit);
14
- const _undo = h.undo.bind(h);
15
- const _redo = h.redo.bind(h);
16
- h.undo = () => {
17
- const prev = h.values()[h.values().length - 2];
18
- if (prev === undefined)
19
- return;
20
- _undo();
21
- this[propertyKey] = prev;
22
- };
23
- h.redo = () => {
24
- _redo();
25
- this[propertyKey] = h.current();
26
- };
27
- histories.set(this, h);
28
- }
29
- return histories.get(this);
4
+ return createFieldDecorator({
5
+ bind(instance, name, _initialValue) {
6
+ const historyKey = `${name}History`;
7
+ const inst = instance;
8
+ let h;
9
+ return {
10
+ // descriptor omitted — @History does not replace the original field
11
+ additional: {
12
+ [historyKey]: {
13
+ get() {
14
+ if (!h) {
15
+ const source = () => inst[name];
16
+ const hInst = history(source, limit);
17
+ const _undo = hInst.undo.bind(hInst);
18
+ const _redo = hInst.redo.bind(hInst);
19
+ hInst.undo = () => {
20
+ const prev = hInst.values()[hInst.values().length - 2];
21
+ if (prev === undefined)
22
+ return;
23
+ _undo();
24
+ inst[name] = prev;
25
+ };
26
+ hInst.redo = () => {
27
+ _redo();
28
+ inst[name] = hInst.current();
29
+ };
30
+ h = hInst;
31
+ }
32
+ return h;
33
+ },
34
+ enumerable: false,
35
+ configurable: true,
36
+ },
30
37
  },
31
- enumerable: false,
32
- configurable: true,
33
- });
34
- });
35
- };
38
+ };
39
+ },
40
+ });
36
41
  }
37
42
  //# sourceMappingURL=history.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/properties/history.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAQvE,MAAM,UAAU,OAAO,CAAC,KAAK,GAAG,EAAE;IAChC,OAAO,UACL,MAAiB,EACjB,OAAsD;QAEtD,MAAM,SAAS,GAAG,IAAI,OAAO,EAAmC,CAAC;QAEjE,OAAO,CAAC,cAAc,CAAC;YACrB,MAAM,QAAQ,GAAG,IAA+B,CAAC;YACjD,MAAM,WAAW,GAAG,OAAO,CAAC,IAAc,CAAC;YAC3C,MAAM,UAAU,GAAG,GAAG,WAAW,SAAS,CAAC;YAE3C,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,UAAU,EAAE;gBAC1C,GAAG;oBACD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;wBACzB,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;wBAEvC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAyB,EAAE,KAAK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S,CAAC;YACpC,MAAM,IAAI,GAAG,QAA8C,CAAC;YAC5D,IAAI,CAAsC,CAAC;YAE3C,OAAO;gBACL,oEAAoE;gBACpE,UAAU,EAAE;oBACV,CAAC,UAAU,CAAC,EAAE;wBACZ,GAAG;4BACD,IAAI,CAAC,CAAC,EAAE,CAAC;gCACP,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gCAChC,MAAM,KAAK,GAAG,OAAO,CAAC,MAAyB,EAAE,KAAK,CAAC,CAAC;gCAExD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gCACrC,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gCAErC,KAAK,CAAC,IAAI,GAAG,GAAG,EAAE;oCAChB,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;oCACvD,IAAI,IAAI,KAAK,SAAS;wCAAE,OAAO;oCAC/B,KAAK,EAAE,CAAC;oCACR,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;gCACpB,CAAC,CAAC;gCAEF,KAAK,CAAC,IAAI,GAAG,GAAG,EAAE;oCAChB,KAAK,EAAE,CAAC;oCACR,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;gCAC/B,CAAC,CAAC;gCAEF,CAAC,GAAG,KAAK,CAAC;4BACZ,CAAC;4BACD,OAAO,CAAC,CAAC;wBACX,CAAC;wBACD,UAAU,EAAE,KAAK;wBACjB,YAAY,EAAE,IAAI;qBACnB;iBACF;aACF,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -4,4 +4,6 @@ export { Computed } from "./computed";
4
4
  export { Persisted } from "./persisted";
5
5
  export { Slot, initSlots } from "./slot";
6
6
  export { History, type WithHistory } from "./history";
7
+ export { Compose } from "./compose";
8
+ export { Resource, type ResourceInstance, type ResourceOptions } from "./resource";
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/properties/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/properties/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC"}
@@ -4,4 +4,6 @@ export { Computed } from "./computed";
4
4
  export { Persisted } from "./persisted";
5
5
  export { Slot, initSlots } from "./slot";
6
6
  export { History } from "./history";
7
+ export { Compose } from "./compose";
8
+ export { Resource } from "./resource";
7
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/properties/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,OAAO,EAAoB,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/properties/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,OAAO,EAAoB,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAA+C,MAAM,YAAY,CAAC"}
@@ -1,4 +1,3 @@
1
- import type { StatefulComponent } from "@praxisjs/core";
2
1
  import { type PersistedSignalOptions } from "@praxisjs/core/internal";
3
- export declare function Persisted<T>(key?: string, options?: PersistedSignalOptions<T>): (_value: undefined, context: ClassFieldDecoratorContext<StatefulComponent>) => void;
2
+ export declare function Persisted<T>(key?: string, options?: PersistedSignalOptions<T>): (_value: undefined, context: ClassFieldDecoratorContext<import("@praxisjs/core").StatefulComponent>) => void;
4
3
  //# sourceMappingURL=persisted.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"persisted.d.ts","sourceRoot":"","sources":["../../src/properties/persisted.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,yBAAyB,CAAC;AAkCjC,wBAAgB,SAAS,CAAC,CAAC,EACzB,GAAG,CAAC,EAAE,MAAM,EACZ,OAAO,GAAE,sBAAsB,CAAC,CAAC,CAAM,IAGrC,QAAQ,SAAS,EACjB,SAAS,0BAA0B,CAAC,iBAAiB,CAAC,KACrD,IAAI,CAsCR"}
1
+ {"version":3,"file":"persisted.d.ts","sourceRoot":"","sources":["../../src/properties/persisted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAwBvF,wBAAgB,SAAS,CAAC,CAAC,EACzB,GAAG,CAAC,EAAE,MAAM,EACZ,OAAO,GAAE,sBAAsB,CAAC,CAAC,CAAM,gHAgBxC"}
@@ -1,16 +1,9 @@
1
- import { persistedSignal, } from "@praxisjs/core/internal";
1
+ import { persistedSignal } from "@praxisjs/core/internal";
2
+ import { createFieldDecorator } from "../create-field-decorator";
2
3
  const signalMap = new WeakMap();
3
- const initMap = new WeakMap();
4
- function markInitialized(instance, propKey) {
5
- if (!initMap.has(instance)) {
6
- initMap.set(instance, new Set());
7
- }
8
- initMap.get(instance).add(propKey);
9
- }
10
4
  function getOrCreateSignal(instance, storageKey, initialValue, options) {
11
- if (!signalMap.has(instance)) {
5
+ if (!signalMap.has(instance))
12
6
  signalMap.set(instance, new Map());
13
- }
14
7
  const map = signalMap.get(instance);
15
8
  if (!map.has(storageKey)) {
16
9
  map.set(storageKey, persistedSignal(storageKey, initialValue, options));
@@ -18,26 +11,17 @@ function getOrCreateSignal(instance, storageKey, initialValue, options) {
18
11
  return map.get(storageKey);
19
12
  }
20
13
  export function Persisted(key, options = {}) {
21
- return function (_value, context) {
22
- context.addInitializer(function () {
23
- const instance = this;
24
- const propertyKey = context.name;
25
- const storageKey = key ?? propertyKey;
26
- const initialValue = instance[propertyKey];
27
- Reflect.deleteProperty(instance, propertyKey);
28
- markInitialized(instance, propertyKey);
14
+ return createFieldDecorator({
15
+ bind(instance, name, initialValue) {
16
+ const storageKey = key ?? name;
29
17
  getOrCreateSignal(instance, storageKey, initialValue, options);
30
- Object.defineProperty(instance, propertyKey, {
31
- get() {
32
- return getOrCreateSignal(instance, storageKey, undefined, options)();
33
- },
34
- set(value) {
35
- getOrCreateSignal(instance, storageKey, undefined, options).set(value);
18
+ return {
19
+ descriptor: {
20
+ get: () => getOrCreateSignal(instance, storageKey, undefined, options)(),
21
+ set: (value) => { getOrCreateSignal(instance, storageKey, undefined, options).set(value); },
36
22
  },
37
- enumerable: true,
38
- configurable: true,
39
- });
40
- });
41
- };
23
+ };
24
+ },
25
+ });
42
26
  }
43
27
  //# sourceMappingURL=persisted.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"persisted.js","sourceRoot":"","sources":["../../src/properties/persisted.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,GAEhB,MAAM,yBAAyB,CAAC;AAGjC,MAAM,SAAS,GAAG,IAAI,OAAO,EAAwC,CAAC;AACtE,MAAM,OAAO,GAAG,IAAI,OAAO,EAAuB,CAAC;AAEnD,SAAS,eAAe,CAAC,QAAgB,EAAE,OAAe;IACxD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;IACnC,CAAC;IACA,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAiB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,iBAAiB,CACxB,QAAgB,EAChB,UAAkB,EAClB,YAAe,EACf,OAAkC;IAElC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,SAAS,CAA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,CAAC,KAAQ,EAAE,EAAE,GACd,iBAAiB,CAAI,QAAQ,EAAE,UAAU,EAAE,SAAc,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;iBACtF;aACF,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -1,3 +1,2 @@
1
- import type { StatefulComponent } from "@praxisjs/core";
2
- export declare function Prop(): (_value: undefined, context: ClassFieldDecoratorContext<StatefulComponent>) => void;
1
+ export declare function Prop(): (_value: undefined, context: ClassFieldDecoratorContext<import("@praxisjs/core").StatefulComponent>) => void;
3
2
  //# sourceMappingURL=prop.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prop.d.ts","sourceRoot":"","sources":["../../src/properties/prop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,wBAAgB,IAAI,KAEhB,QAAQ,SAAS,EACjB,SAAS,0BAA0B,CAAC,iBAAiB,CAAC,KACrD,IAAI,CA4BR"}
1
+ {"version":3,"file":"prop.d.ts","sourceRoot":"","sources":["../../src/properties/prop.ts"],"names":[],"mappings":"AAEA,wBAAgB,IAAI,iHAsBnB"}
@@ -1,29 +1,25 @@
1
+ import { createFieldDecorator } from "../create-field-decorator";
1
2
  export function Prop() {
2
- return function (_value, context) {
3
- context.addInitializer(function () {
4
- const instance = this;
5
- const name = context.name;
6
- const raw = instance;
7
- const defaultValue = raw[name];
8
- Reflect.deleteProperty(raw, name);
9
- instance._defaults[name] = defaultValue;
10
- Object.defineProperty(instance, name, {
11
- get() {
12
- const fromParent = this._rawProps[name];
13
- if (fromParent !== undefined) {
14
- return typeof fromParent === "function"
15
- ? fromParent()
16
- : fromParent;
17
- }
18
- return this._defaults[name];
3
+ return createFieldDecorator({
4
+ bind(instance, name, initialValue) {
5
+ instance._defaults[name] = initialValue;
6
+ return {
7
+ descriptor: {
8
+ get() {
9
+ const fromParent = (instance._rawProps)[name];
10
+ if (fromParent !== undefined) {
11
+ return typeof fromParent === "function"
12
+ ? fromParent()
13
+ : fromParent;
14
+ }
15
+ return instance._defaults[name];
16
+ },
17
+ set(value) {
18
+ instance._defaults[name] = value;
19
+ },
19
20
  },
20
- set(value) {
21
- this._defaults[name] = value;
22
- },
23
- enumerable: true,
24
- configurable: true,
25
- });
26
- });
27
- };
21
+ };
22
+ },
23
+ });
28
24
  }
29
25
  //# sourceMappingURL=prop.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prop.js","sourceRoot":"","sources":["../../src/properties/prop.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,IAAI;IAClB,OAAO,UACL,MAAiB,EACjB,OAAsD;QAEtD,OAAO,CAAC,cAAc,CAAC;YACrB,MAAM,QAAQ,GAAG,IAAyB,CAAC;YAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,IAAc,CAAC;YACpC,MAAM,GAAG,GAAG,QAA8C,CAAC;YAC3D,MAAM,YAAY,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;YAC/B,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAElC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC;YAExC,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE;gBACpC,GAAG;oBACD,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;oBACxC,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;wBAC7B,OAAO,OAAO,UAAU,KAAK,UAAU;4BACrC,CAAC,CAAE,UAA4B,EAAE;4BACjC,CAAC,CAAC,UAAU,CAAC;oBACjB,CAAC;oBACD,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBAC9B,CAAC;gBACD,GAAG,CAA0B,KAAc;oBACzC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;gBAC/B,CAAC;gBACD,UAAU,EAAE,IAAI;gBAChB,YAAY,EAAE,IAAI;aACnB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"prop.js","sourceRoot":"","sources":["../../src/properties/prop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,UAAU,IAAI;IAClB,OAAO,oBAAoB,CAAC;QAC1B,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,YAAY;YAC/B,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC;YACxC,OAAO;gBACL,UAAU,EAAE;oBACV,GAAG;wBACD,MAAM,UAAU,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC;wBAC9C,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;4BAC7B,OAAO,OAAO,UAAU,KAAK,UAAU;gCACrC,CAAC,CAAE,UAA4B,EAAE;gCACjC,CAAC,CAAC,UAAU,CAAC;wBACjB,CAAC;wBACD,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;oBAClC,CAAC;oBACD,GAAG,CAAC,KAAc;wBAChB,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;oBACnC,CAAC;iBACF;aACF,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type Resource as ResourceInstance, type ResourceOptions } from "@praxisjs/core/internal";
2
+ export type { ResourceInstance, ResourceOptions };
3
+ /**
4
+ * Binds an async resource to the field. The field holds a Resource<T> object
5
+ * with reactive data, pending, error, and status signals, plus refetch/cancel/mutate methods.
6
+ *
7
+ * class MyComponent extends StatefulComponent {
8
+ * @Resource(() => api.getUsers())
9
+ * users!: ResourceInstance<User[]>;
10
+ * // access: this.users.data(), this.users.pending(), this.users.refetch()
11
+ * }
12
+ */
13
+ export declare function Resource<T>(fetcher: () => Promise<T>, options?: ResourceOptions<T>): (_value: undefined, context: ClassFieldDecoratorContext<import("@praxisjs/core").StatefulComponent>) => void;
14
+ //# sourceMappingURL=resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../src/properties/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,IAAI,gBAAgB,EACjC,KAAK,eAAe,EACrB,MAAM,yBAAyB,CAAC;AAIjC,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC;AAElD;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,GAAE,eAAe,CAAC,CAAC,CAAM,gHAatF"}