@praxisjs/decorators 0.1.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 (144) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LICENSE +21 -0
  3. package/dist/component/component.d.ts +3 -0
  4. package/dist/component/component.d.ts.map +1 -0
  5. package/dist/component/component.js +13 -0
  6. package/dist/component/component.js.map +1 -0
  7. package/dist/component/index.d.ts +5 -0
  8. package/dist/component/index.d.ts.map +1 -0
  9. package/dist/component/index.js +5 -0
  10. package/dist/component/index.js.map +1 -0
  11. package/dist/component/lazy.d.ts +3 -0
  12. package/dist/component/lazy.d.ts.map +1 -0
  13. package/dist/component/lazy.js +44 -0
  14. package/dist/component/lazy.js.map +1 -0
  15. package/dist/component/lifecycle.d.ts +3 -0
  16. package/dist/component/lifecycle.d.ts.map +1 -0
  17. package/dist/component/lifecycle.js +35 -0
  18. package/dist/component/lifecycle.js.map +1 -0
  19. package/dist/component/memoize.d.ts +5 -0
  20. package/dist/component/memoize.d.ts.map +1 -0
  21. package/dist/component/memoize.js +23 -0
  22. package/dist/component/memoize.js.map +1 -0
  23. package/dist/component/virtual.d.ts +3 -0
  24. package/dist/component/virtual.d.ts.map +1 -0
  25. package/dist/component/virtual.js +66 -0
  26. package/dist/component/virtual.js.map +1 -0
  27. package/dist/events/command.d.ts +6 -0
  28. package/dist/events/command.d.ts.map +1 -0
  29. package/dist/events/command.js +13 -0
  30. package/dist/events/command.js.map +1 -0
  31. package/dist/events/emit.d.ts +2 -0
  32. package/dist/events/emit.d.ts.map +1 -0
  33. package/dist/events/emit.js +36 -0
  34. package/dist/events/emit.js.map +1 -0
  35. package/dist/events/helper.d.ts +3 -0
  36. package/dist/events/helper.d.ts.map +1 -0
  37. package/dist/events/helper.js +7 -0
  38. package/dist/events/helper.js.map +1 -0
  39. package/dist/events/index.d.ts +4 -0
  40. package/dist/events/index.d.ts.map +1 -0
  41. package/dist/events/index.js +4 -0
  42. package/dist/events/index.js.map +1 -0
  43. package/dist/events/on-command.d.ts +2 -0
  44. package/dist/events/on-command.d.ts.map +1 -0
  45. package/dist/events/on-command.js +33 -0
  46. package/dist/events/on-command.js.map +1 -0
  47. package/dist/functions/bind.d.ts +2 -0
  48. package/dist/functions/bind.d.ts.map +1 -0
  49. package/dist/functions/bind.js +19 -0
  50. package/dist/functions/bind.js.map +1 -0
  51. package/dist/functions/debounce.d.ts +2 -0
  52. package/dist/functions/debounce.d.ts.map +1 -0
  53. package/dist/functions/debounce.js +29 -0
  54. package/dist/functions/debounce.js.map +1 -0
  55. package/dist/functions/index.d.ts +10 -0
  56. package/dist/functions/index.d.ts.map +1 -0
  57. package/dist/functions/index.js +10 -0
  58. package/dist/functions/index.js.map +1 -0
  59. package/dist/functions/log.d.ts +9 -0
  60. package/dist/functions/log.d.ts.map +1 -0
  61. package/dist/functions/log.js +43 -0
  62. package/dist/functions/log.js.map +1 -0
  63. package/dist/functions/memo.d.ts +2 -0
  64. package/dist/functions/memo.d.ts.map +1 -0
  65. package/dist/functions/memo.js +45 -0
  66. package/dist/functions/memo.js.map +1 -0
  67. package/dist/functions/once.d.ts +2 -0
  68. package/dist/functions/once.d.ts.map +1 -0
  69. package/dist/functions/once.js +17 -0
  70. package/dist/functions/once.js.map +1 -0
  71. package/dist/functions/retry.d.ts +7 -0
  72. package/dist/functions/retry.d.ts.map +1 -0
  73. package/dist/functions/retry.js +28 -0
  74. package/dist/functions/retry.js.map +1 -0
  75. package/dist/functions/throttle.d.ts +2 -0
  76. package/dist/functions/throttle.d.ts.map +1 -0
  77. package/dist/functions/throttle.js +27 -0
  78. package/dist/functions/throttle.js.map +1 -0
  79. package/dist/functions/watch.d.ts +19 -0
  80. package/dist/functions/watch.d.ts.map +1 -0
  81. package/dist/functions/watch.js +45 -0
  82. package/dist/functions/watch.js.map +1 -0
  83. package/dist/functions/when.d.ts +2 -0
  84. package/dist/functions/when.d.ts.map +1 -0
  85. package/dist/functions/when.js +31 -0
  86. package/dist/functions/when.js.map +1 -0
  87. package/dist/index.d.ts +5 -0
  88. package/dist/index.d.ts.map +1 -0
  89. package/dist/index.js +5 -0
  90. package/dist/index.js.map +1 -0
  91. package/dist/properties/history.d.ts +2 -0
  92. package/dist/properties/history.d.ts.map +1 -0
  93. package/dist/properties/history.js +39 -0
  94. package/dist/properties/history.js.map +1 -0
  95. package/dist/properties/index.d.ts +6 -0
  96. package/dist/properties/index.d.ts.map +1 -0
  97. package/dist/properties/index.js +6 -0
  98. package/dist/properties/index.js.map +1 -0
  99. package/dist/properties/persisted.d.ts +3 -0
  100. package/dist/properties/persisted.d.ts.map +1 -0
  101. package/dist/properties/persisted.js +46 -0
  102. package/dist/properties/persisted.js.map +1 -0
  103. package/dist/properties/prop.d.ts +2 -0
  104. package/dist/properties/prop.d.ts.map +1 -0
  105. package/dist/properties/prop.js +18 -0
  106. package/dist/properties/prop.js.map +1 -0
  107. package/dist/properties/slot.d.ts +9 -0
  108. package/dist/properties/slot.d.ts.map +1 -0
  109. package/dist/properties/slot.js +46 -0
  110. package/dist/properties/slot.js.map +1 -0
  111. package/dist/properties/state.d.ts +2 -0
  112. package/dist/properties/state.d.ts.map +1 -0
  113. package/dist/properties/state.js +24 -0
  114. package/dist/properties/state.js.map +1 -0
  115. package/package.json +26 -0
  116. package/src/component/component.ts +18 -0
  117. package/src/component/index.ts +4 -0
  118. package/src/component/lazy.ts +56 -0
  119. package/src/component/lifecycle.ts +47 -0
  120. package/src/component/memoize.ts +31 -0
  121. package/src/component/virtual.tsx +104 -0
  122. package/src/events/command.ts +17 -0
  123. package/src/events/emit.ts +47 -0
  124. package/src/events/helper.ts +7 -0
  125. package/src/events/index.ts +3 -0
  126. package/src/events/on-command.ts +55 -0
  127. package/src/functions/bind.ts +22 -0
  128. package/src/functions/debounce.ts +34 -0
  129. package/src/functions/index.ts +9 -0
  130. package/src/functions/log.ts +68 -0
  131. package/src/functions/memo.ts +63 -0
  132. package/src/functions/once.ts +22 -0
  133. package/src/functions/retry.ts +43 -0
  134. package/src/functions/throttle.ts +32 -0
  135. package/src/functions/watch.ts +99 -0
  136. package/src/functions/when.ts +44 -0
  137. package/src/index.ts +16 -0
  138. package/src/properties/history.ts +62 -0
  139. package/src/properties/index.ts +5 -0
  140. package/src/properties/persisted.ts +75 -0
  141. package/src/properties/prop.ts +18 -0
  142. package/src/properties/slot.ts +75 -0
  143. package/src/properties/state.ts +24 -0
  144. package/tsconfig.json +8 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # @praxisjs/decorators
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - aaf7dab: Initial beta release
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [aaf7dab]
12
+ - @praxisjs/core@0.1.0
13
+ - @praxisjs/jsx@0.1.0
14
+ - @praxisjs/shared@0.1.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026-present Mateus Martins
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.
@@ -0,0 +1,3 @@
1
+ import type { ComponentConstructor, ComponentInstance } from "@praxisjs/shared";
2
+ export declare function Component(): <T extends new (...args: any[]) => ComponentInstance>(constructor: T) => T & ComponentConstructor;
3
+ //# sourceMappingURL=component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/component/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,wBAAgB,SAAS,KAEN,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,iBAAiB,EAClE,aAAa,CAAC,KACb,CAAC,GAAG,oBAAoB,CAW5B"}
@@ -0,0 +1,13 @@
1
+ export function Component() {
2
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
+ return function (constructor) {
4
+ const Enhanced = class extends constructor {
5
+ static { this.isComponent = true; }
6
+ };
7
+ Object.defineProperty(Enhanced, "name", {
8
+ value: constructor.name,
9
+ });
10
+ return Enhanced;
11
+ };
12
+ }
13
+ //# sourceMappingURL=component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/component/component.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,SAAS;IACvB,8DAA8D;IAC9D,OAAO,UACL,WAAc;QAEd,MAAM,QAAQ,GAAG,KAAM,SAAQ,WAAW;qBACjC,gBAAW,GAAG,IAAa,CAAC;SACG,CAAC;QAEzC,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE;YACtC,KAAK,EAAE,WAAW,CAAC,IAAI;SACxB,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { Component } from "./component";
2
+ export { Memoize } from "./memoize";
3
+ export { Lazy } from "./lazy";
4
+ export { Virtual } from "./virtual";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/component/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { Component } from "./component";
2
+ export { Memoize } from "./memoize";
3
+ export { Lazy } from "./lazy";
4
+ export { Virtual } from "./virtual";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/component/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type BaseComponent } from "@praxisjs/core";
2
+ export declare function Lazy(placeholder?: number): <T extends new (...args: any[]) => BaseComponent>(constructor: T) => T;
3
+ //# sourceMappingURL=lazy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/component/lazy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAU,MAAM,gBAAgB,CAAC;AAG5D,wBAAgB,IAAI,CAAC,WAAW,SAAM,IAEnB,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,aAAa,EAC9D,aAAa,CAAC,KACb,CAAC,CAgDL"}
@@ -0,0 +1,44 @@
1
+ import { signal } from "@praxisjs/core";
2
+ export function Lazy(placeholder = 200) {
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ return function (constructor) {
5
+ return class LazyWrapper extends constructor {
6
+ constructor() {
7
+ super(...arguments);
8
+ this._lazyVisible = signal(false);
9
+ this._originalRender = this.render.bind(this);
10
+ }
11
+ onMount() {
12
+ super.onMount?.();
13
+ const el = document.querySelector(`[data-component="${constructor.name}"]`);
14
+ if (!el)
15
+ return;
16
+ if (!("IntersectionObserver" in window)) {
17
+ this._lazyVisible.set(true);
18
+ return;
19
+ }
20
+ if (!this._lazyVisible()) {
21
+ el.style.minHeight = `${String(placeholder)}px`;
22
+ }
23
+ this._observer = new IntersectionObserver((entries) => {
24
+ if (entries[0]?.isIntersecting) {
25
+ this._lazyVisible.set(true);
26
+ el.style.minHeight = "";
27
+ this._observer?.disconnect();
28
+ }
29
+ }, { rootMargin: "100px" });
30
+ this._observer.observe(el);
31
+ }
32
+ onUnmount() {
33
+ super.onUnmount?.();
34
+ this._observer?.disconnect();
35
+ }
36
+ render() {
37
+ if (!this._lazyVisible())
38
+ return null;
39
+ return this._originalRender();
40
+ }
41
+ };
42
+ };
43
+ }
44
+ //# sourceMappingURL=lazy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazy.js","sourceRoot":"","sources":["../../src/component/lazy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAG5D,MAAM,UAAU,IAAI,CAAC,WAAW,GAAG,GAAG;IACpC,8DAA8D;IAC9D,OAAO,UACL,WAAc;QAEd,OAAO,MAAM,WAAY,SAAQ,WAAW;YAArC;;gBACY,iBAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;gBAE7B,oBAAe,GAAuB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YA0ChF,CAAC;YAxCC,OAAO;gBACL,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;gBAElB,MAAM,EAAE,GAA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ends new (...args: any[]) => BaseComponent>(constructor: T): T;
3
+ //# sourceMappingURL=lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/component/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAmC,MAAM,gBAAgB,CAAC;AAuBrF,wBAAgB,SAAS,CAAC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,aAAa,EACvE,WAAW,EAAE,CAAC,GACb,CAAC,CAqBH"}
@@ -0,0 +1,35 @@
1
+ import { VALID_LIFECYCLE_HOOK_SIGNATURES } from "@praxisjs/core";
2
+ function getAllMethods(proto) {
3
+ const methods = [];
4
+ let current = proto;
5
+ while (current !== null && current !== Object.prototype) {
6
+ const names = Object.getOwnPropertyNames(current);
7
+ for (const name of names) {
8
+ if (name !== "constructor" &&
9
+ typeof current[name] === "function") {
10
+ if (!methods.includes(name))
11
+ methods.push(name);
12
+ }
13
+ }
14
+ current = Object.getPrototypeOf(current);
15
+ }
16
+ return methods;
17
+ }
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ export function LifeCycle(constructor) {
20
+ if (process.env.NODE_ENV === "production")
21
+ return constructor;
22
+ const validHooks = new Set(Object.keys(VALID_LIFECYCLE_HOOK_SIGNATURES));
23
+ const proto = constructor.prototype;
24
+ const allMethods = getAllMethods(proto);
25
+ for (const method of allMethods) {
26
+ if (!method.startsWith("on"))
27
+ continue;
28
+ if (!validHooks.has(method)) {
29
+ console.warn(`[LifeCycle] "${constructor.name}.${method}" appears to be a lifecycle hook but is not recognized.\n` +
30
+ `Valid hooks: ${[...validHooks].join(", ")}`);
31
+ }
32
+ }
33
+ return constructor;
34
+ }
35
+ //# sourceMappingURL=lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/component/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EA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AI,IAAI,MAAM,2DAA2D;gBACnG,gBAAgB,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC/C,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { ComponentInstance } from "@praxisjs/shared";
2
+ type PropsRecord = Record<string, unknown>;
3
+ export declare function Memoize(areEqual?: (prev: PropsRecord, next: PropsRecord) => boolean): <T extends new (...args: any[]) => ComponentInstance>(constructor: T) => T;
4
+ export {};
5
+ //# sourceMappingURL=memoize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoize.d.ts","sourceRoot":"","sources":["../../src/component/memoize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAiB3C,wBAAgB,OAAO,CACrB,QAAQ,GAAE,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,KAAK,OAAsB,IAGzD,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,iBAAiB,EAClE,aAAa,CAAC,KACb,CAAC,CAKL"}
@@ -0,0 +1,23 @@
1
+ function shallowEqual(a, b) {
2
+ const keysA = Object.keys(a);
3
+ const keysB = Object.keys(b);
4
+ if (keysA.length !== keysB.length)
5
+ return false;
6
+ const bHasOwnProperty = Object.prototype.hasOwnProperty.bind(b);
7
+ for (const aKey of keysA) {
8
+ if (!bHasOwnProperty(aKey))
9
+ return false;
10
+ if (!Object.is(a[aKey], b[aKey]))
11
+ return false;
12
+ }
13
+ return true;
14
+ }
15
+ export function Memoize(areEqual = shallowEqual) {
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ return function (constructor) {
18
+ constructor._isMemorized = true;
19
+ constructor._arePropsEqual = areEqual;
20
+ return constructor;
21
+ };
22
+ }
23
+ //# sourceMappingURL=memoize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoize.js","sourceRoot":"","sources":["../../src/component/memoize.ts"],"names":[],"mappings":"AAIA,SAAS,YAAY,CAAC,CAAc,EAAE,CAAc;IAClD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE7B,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAEhD,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAEhE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;YAAE,OAAO,KAAK,CAAC;QACzC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;IACjD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,OAAO,CACrB,WAA8D,YAAY;IAE1E,8DAA8D;IAC9D,OAAO,UACL,WAAc;QAEb,WAA4C,CAAC,YAAY,GAAG,IAAI,CAAC;QACjE,WAA4C,CAAC,cAAc,GAAG,QAAQ,CAAC;QACxE,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type BaseComponent } from "@praxisjs/core";
2
+ export declare function Virtual(itemHeight: number, buffer?: number): <T extends new (...args: any[]) => BaseComponent>(constructor: T) => T;
3
+ //# sourceMappingURL=virtual.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"virtual.d.ts","sourceRoot":"","sources":["../../src/component/virtual.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAoB,MAAM,gBAAgB,CAAC;AAGtE,wBAAgB,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,SAAI,IAEnC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,aAAa,EAC9D,aAAa,CAAC,KACb,CAAC,CAgGL"}
@@ -0,0 +1,66 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@praxisjs/jsx/jsx-runtime";
2
+ import { computed, signal } from "@praxisjs/core";
3
+ export function Virtual(itemHeight, buffer = 3) {
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+ return function (constructor) {
6
+ return class VirtualWrapper extends constructor {
7
+ constructor() {
8
+ super(...arguments);
9
+ this._scrollTop = signal(0);
10
+ this._viewHeight = signal(600);
11
+ }
12
+ onMount() {
13
+ super.onMount?.();
14
+ this._container =
15
+ document.querySelector(`[data-component="${constructor.name}"]`) ?? undefined;
16
+ if (!this._container)
17
+ return;
18
+ this._container.style.overflowY = "auto";
19
+ this._container.style.position = "relative";
20
+ this._viewHeight.set(this._container.clientHeight || 600);
21
+ this._scrollHandler = () => {
22
+ if (this._container)
23
+ this._scrollTop.set(this._container.scrollTop);
24
+ };
25
+ this._container.addEventListener("scroll", this._scrollHandler);
26
+ }
27
+ onUnmount() {
28
+ super.onUnmount?.();
29
+ if (this._container && this._scrollHandler) {
30
+ this._container.removeEventListener("scroll", this._scrollHandler);
31
+ }
32
+ }
33
+ render() {
34
+ const instance = this;
35
+ const items = instance.items ?? [];
36
+ const total = items.length;
37
+ const totalH = total * itemHeight;
38
+ const renderItem = instance.renderItem;
39
+ if (!renderItem) {
40
+ console.warn(`[Virtual] ${constructor.name} must implement renderItem(item, index)`);
41
+ return null;
42
+ }
43
+ const startIdx = computed(() => {
44
+ const start = Math.floor(this._scrollTop() / itemHeight) - buffer;
45
+ return Math.max(0, start);
46
+ });
47
+ const endIdx = computed(() => {
48
+ const end = Math.ceil((this._scrollTop() + this._viewHeight()) / itemHeight) +
49
+ buffer;
50
+ return Math.min(total - 1, end);
51
+ });
52
+ const visibleItems = computed(() => {
53
+ const result = [];
54
+ for (let i = startIdx(); i <= endIdx(); i++) {
55
+ result.push({ item: items[i], index: i });
56
+ }
57
+ return result;
58
+ });
59
+ const offsetTop = computed(() => startIdx() * itemHeight);
60
+ const offsetBottom = computed(() => (total - 1 - endIdx()) * itemHeight);
61
+ return (_jsxs("div", { style: `height:${String(totalH)}px; position:relative;`, children: [_jsx("div", { style: () => `height:${String(offsetTop())}px;` }), () => visibleItems().map(({ item, index }) => (_jsx("div", { style: `height:${String(itemHeight)}px; overflow:hidden;`, children: renderItem.call(this, item, index) }, String(index)))), _jsx("div", { style: () => `height:${String(offsetBottom())}px;` })] }));
62
+ }
63
+ };
64
+ };
65
+ }
66
+ //# sourceMappingURL=virtual.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"virtual.js","sourceRoot":"","sources":["../../src/component/virtual.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAsB,QAAQ,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGtE,MAAM,UAAU,OAAO,CAAC,UAAkB,EAAE,MAAM,GAAG,CAAC;IACpD,8DAA8D;IAC9D,OAAO,UACL,WAAc;QAEd,OAAO,MAAM,cAAe,SAAQ,WAAW;YAAxC;;gBACY,eAAU,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;gBACvB,gBAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YA2F7C,CAAC;YAvFC,OAAO;gBACL,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;gBAElB,IAAI,CAAC,UAAU;oBACb,QAAQ,CAAC,aAAa,CACpB,oBAAoB,WAAW,CAAC,IAAI,IAAI,CACzC,IAAI,SAAS,CAAC;gBAEjB,IAAI,CAAC,IAAI,CAAC,UAAU;oBAAE,OAAO;gBAE7B,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,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E,CACJ,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CACtC,cAEE,KAAK,EAAE,UAAU,MAAM,CAAC,UAAU,CAAC,sBAAsB,YAExD,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAH9B,MAAM,CAAC,KAAK,CAAC,CAId,CACP,CAAC,EAEJ,cAAK,KAAK,EAAE,GAAG,EAAE,CAAC,UAAU,MAAM,CAAC,YAAY,EAAE,CAAC,KAAK,GAAI,IACvD,CACa,CAAC;YACxB,CAAC;SACc,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ export interface Command<T = void> {
2
+ trigger(arg: T): void;
3
+ subscribe(handler: (arg: T) => void): () => void;
4
+ }
5
+ export declare function createCommand<T = void>(): Command<T>;
6
+ //# sourceMappingURL=command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/events/command.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO,CAAC,CAAC,GAAG,IAAI;IAC/B,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC;IACtB,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CAClD;AAED,wBAAgB,aAAa,CAAC,CAAC,GAAG,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,CAWpD"}
@@ -0,0 +1,13 @@
1
+ export function createCommand() {
2
+ const handlers = new Set();
3
+ return {
4
+ trigger(arg) {
5
+ handlers.forEach((h) => { h(arg); });
6
+ },
7
+ subscribe(handler) {
8
+ handlers.add(handler);
9
+ return () => handlers.delete(handler);
10
+ },
11
+ };
12
+ }
13
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/events/command.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,aAAa;IAC3B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC7C,OAAO;QACL,OAAO,CAAC,GAAM;YACZ,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACvC,CAAC;QACD,SAAS,CAAC,OAAO;YACf,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACtB,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function Emit(propName: string): (_target: object, methodKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
2
+ //# sourceMappingURL=emit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../src/events/emit.ts"],"names":[],"mappings":"AAIA,wBAAgB,IAAI,CAAC,QAAQ,EAAE,MAAM,IAEjC,SAAS,MAAM,EACf,WAAW,MAAM,EACjB,YAAY,kBAAkB,KAC7B,kBAAkB,CAqCtB"}
@@ -0,0 +1,36 @@
1
+ import { readProp } from "./helper";
2
+ export function Emit(propName) {
3
+ return function (_target, methodKey, descriptor) {
4
+ const originalMethod = descriptor.value;
5
+ const wrapped = function (...args) {
6
+ const result = originalMethod.apply(this, args);
7
+ const callback = readProp(this, propName);
8
+ if (typeof callback !== "function")
9
+ return result;
10
+ if (result !== undefined) {
11
+ callback(result);
12
+ }
13
+ else if (args.length > 0) {
14
+ callback(...args);
15
+ }
16
+ else {
17
+ callback();
18
+ }
19
+ return result;
20
+ };
21
+ return {
22
+ configurable: true,
23
+ enumerable: false,
24
+ get() {
25
+ const bound = wrapped.bind(this);
26
+ Object.defineProperty(this, methodKey, {
27
+ value: bound,
28
+ configurable: true,
29
+ writable: true,
30
+ });
31
+ return bound;
32
+ },
33
+ };
34
+ };
35
+ }
36
+ //# sourceMappingURL=emit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit.js","sourceRoot":"","sources":["../../src/events/emit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,MAAM,UAAU,IAAI,CAAC,QAAgB;IACnC,OAAO,UACL,OAAe,EACf,SAAiB,EACjB,UAA8B;QAE9B,MAAM,cAAc,GAAG,UAAU,CAAC,KAAwC,CAAC;QAE3E,MAAM,OAAO,GAAG,UAEd,GAAG,IAAe;YAElB,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAEhD,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAC1C,IAAI,OAAO,QAAQ,KAAK,UAAU;gBAAE,OAAO,MAAM,CAAC;YAElD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACxB,QAAiC,CAAC,MAAM,CAAC,CAAC;YAC7C,CAAC;iBAAM,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC1B,QAAsC,CAAC,GAAG,IAAI,CAAC,CAAC;YACnD,CAAC;iBAAM,CAAC;gBACL,QAAuB,EAAE,CAAC;YAC7B,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;QAEF,OAAO;YACL,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,KAAK;YACjB,GAAG;gBACD,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACjC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE;oBACrC,KAAK,EAAE,KAAK;oBACZ,YAAY,EAAE,IAAI;oBAClB,QAAQ,EAAE,IAAI;iBACf,CAAC,CAAC;gBACH,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { BaseComponent } from "@praxisjs/core";
2
+ export declare function readProp(instance: BaseComponent, propName: string): unknown;
3
+ //# sourceMappingURL=helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/events/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAI3E"}
@@ -0,0 +1,7 @@
1
+ export function readProp(instance, propName) {
2
+ const fromParent = instance._rawProps[propName];
3
+ if (fromParent !== undefined)
4
+ return fromParent;
5
+ return instance._defaults[propName];
6
+ }
7
+ //# sourceMappingURL=helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.js","sourceRoot":"","sources":["../../src/events/helper.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,QAAQ,CAAC,QAAuB,EAAE,QAAgB;IAChE,MAAM,UAAU,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAChD,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,UAAU,CAAC;IAChD,OAAO,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { type Command, createCommand } from "./command";
2
+ export { Emit } from "./emit";
3
+ export { OnCommand } from "./on-command";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { createCommand } from "./command";
2
+ export { Emit } from "./emit";
3
+ export { OnCommand } from "./on-command";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,aAAa,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function OnCommand(propName: string): (target: object, _methodKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
2
+ //# sourceMappingURL=on-command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"on-command.d.ts","sourceRoot":"","sources":["../../src/events/on-command.ts"],"names":[],"mappings":"AAMA,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,IAEtC,QAAQ,MAAM,EACd,YAAY,MAAM,EAClB,YAAY,kBAAkB,KAC7B,kBAAkB,CA2CtB"}
@@ -0,0 +1,33 @@
1
+ import { readProp } from "./helper";
2
+ export function OnCommand(propName) {
3
+ return function (target, _methodKey, descriptor) {
4
+ // eslint-disable-next-line @typescript-eslint/unbound-method
5
+ const originalOnMount = target.onMount;
6
+ // eslint-disable-next-line @typescript-eslint/unbound-method
7
+ const originalOnUnmount = target.onUnmount;
8
+ const method = descriptor.value;
9
+ const cleanups = new WeakMap();
10
+ target.onMount = function () {
11
+ originalOnMount?.call(this);
12
+ const command = readProp(this, propName);
13
+ if (!command) {
14
+ console.warn(`[OnCommand] prop "${propName}" was not provided to ${this.constructor.name}`);
15
+ return;
16
+ }
17
+ if (typeof command.subscribe !== "function") {
18
+ console.warn(`[OnCommand] prop "${propName}" is not a valid Command in ${this.constructor.name}`);
19
+ return;
20
+ }
21
+ const bound = method.bind(this);
22
+ const unsub = command.subscribe((...args) => { bound(...args); });
23
+ cleanups.set(this, unsub);
24
+ };
25
+ target.onUnmount = function () {
26
+ originalOnUnmount?.call(this);
27
+ cleanups.get(this)?.();
28
+ cleanups.delete(this);
29
+ };
30
+ return descriptor;
31
+ };
32
+ }
33
+ //# sourceMappingURL=on-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"on-command.js","sourceRoot":"","sources":["../../src/events/on-command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAIpC,MAAM,UAAU,SAAS,CAAC,QAAgB;IACxC,OAAO,UACL,MAAc,EACd,UAAkB,EAClB,UAA8B;QAE9B,6DAA6D;QAC7D,MAAM,eAAe,GAAI,MAA+B,CAAC,OAAO,CAAC;QACjE,6DAA6D;QAC7D,MAAM,iBAAiB,GAAI,MAAiC,CAAC,SAAS,CAAC;QAEvE,MAAM,MAAM,GAAG,UAAU,CAAC,KAAqC,CAAC;QAChE,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAsB,CAAC;QAElD,MAA+B,CAAC,OAAO,GAAG;YACzC,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAE5B,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAiC,CAAC;YAEzE,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,CAAC,IAAI,CACV,qBAAqB,QAAQ,yBAAyB,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAC9E,CAAC;gBACF,OAAO;YACT,CAAC;YAED,IAAI,OAAO,OAAO,CAAC,SAAS,KAAK,UAAU,EAAE,CAAC;gBAC5C,OAAO,CAAC,IAAI,CACV,qBAAqB,QAAQ,+BAA+B,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CACpF,CAAC;gBACF,OAAO;YACT,CAAC;YAED,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAChC,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,IAAe,EAAE,EAAE,GAAG,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7E,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC5B,CAAC,CAAC;QAED,MAAiC,CAAC,SAAS,GAAG;YAG7C,iBAAiB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAC9B,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;YACvB,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function Bind(): (_target: object, methodKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
2
+ //# sourceMappingURL=bind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../../src/functions/bind.ts"],"names":[],"mappings":"AAAA,wBAAgB,IAAI,KAEhB,SAAS,MAAM,EACf,WAAW,MAAM,EACjB,YAAY,kBAAkB,KAC7B,kBAAkB,CAgBtB"}
@@ -0,0 +1,19 @@
1
+ export function Bind() {
2
+ return function (_target, methodKey, descriptor) {
3
+ const originalMethod = descriptor.value;
4
+ return {
5
+ enumerable: false,
6
+ configurable: true,
7
+ get() {
8
+ const bound = originalMethod.bind(this);
9
+ Object.defineProperty(this, methodKey, {
10
+ value: bound,
11
+ configurable: true,
12
+ writable: true,
13
+ });
14
+ return bound;
15
+ },
16
+ };
17
+ };
18
+ }
19
+ //# sourceMappingURL=bind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bind.js","sourceRoot":"","sources":["../../src/functions/bind.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,IAAI;IAClB,OAAO,UACL,OAAe,EACf,SAAiB,EACjB,UAA8B;QAE9B,MAAM,cAAc,GAAG,UAAU,CAAC,KAAwC,CAAC;QAC3E,OAAO;YACL,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,IAAI;YAClB,GAAG;gBACD,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACxC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE;oBACrC,KAAK,EAAE,KAAK;oBACZ,YAAY,EAAE,IAAI;oBAClB,QAAQ,EAAE,IAAI;iBACf,CAAC,CAAC;gBACH,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function Debounce(ms: number): (_target: object, methodKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
2
+ //# sourceMappingURL=debounce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../src/functions/debounce.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,IAI/B,SAAS,MAAM,EACf,WAAW,MAAM,EACjB,YAAY,kBAAkB,KAC7B,kBAAkB,CA0BtB"}
@@ -0,0 +1,29 @@
1
+ export function Debounce(ms) {
2
+ const timers = new WeakMap();
3
+ return function (_target, methodKey, descriptor) {
4
+ const originalMethod = descriptor.value;
5
+ return {
6
+ enumerable: false,
7
+ configurable: true,
8
+ get() {
9
+ const bound = (...args) => {
10
+ const existing = timers.get(this);
11
+ if (existing !== undefined)
12
+ clearTimeout(existing);
13
+ const timer = setTimeout(() => {
14
+ timers.delete(this);
15
+ originalMethod.apply(this, args);
16
+ }, ms);
17
+ timers.set(this, timer);
18
+ };
19
+ Object.defineProperty(this, methodKey, {
20
+ value: bound,
21
+ configurable: true,
22
+ writable: true,
23
+ });
24
+ return bound;
25
+ },
26
+ };
27
+ };
28
+ }
29
+ //# sourceMappingURL=debounce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce.js","sourceRoot":"","sources":["../../src/functions/debounce.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,EAAU;IACjC,MAAM,MAAM,GAAG,IAAI,OAAO,EAAyC,CAAC;IAEpE,OAAO,UACL,OAAe,EACf,SAAiB,EACjB,UAA8B;QAE9B,MAAM,cAAc,GAAG,UAAU,CAAC,KAAwC,CAAC;QAC3E,OAAO;YACL,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,IAAI;YAClB,GAAG;gBACD,MAAM,KAAK,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE;oBACnC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;oBAClC,IAAI,QAAQ,KAAK,SAAS;wBAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;oBAEnD,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;wBAC5B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;wBACpB,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;oBACnC,CAAC,EAAE,EAAE,CAAC,CAAC;oBAEP,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;gBAC1B,CAAC,CAAC;gBACF,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE;oBACrC,KAAK,EAAE,KAAK;oBACZ,YAAY,EAAE,IAAI;oBAClB,QAAQ,EAAE,IAAI;iBACf,CAAC,CAAC;gBACH,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ export { Memo } from "./memo";
2
+ export { Bind } from "./bind";
3
+ export { Log } from "./log";
4
+ export { Once } from "./once";
5
+ export { Retry } from "./retry";
6
+ export { Debounce } from "./debounce";
7
+ export { Throttle } from "./throttle";
8
+ export { When } from "./when";
9
+ export { Watch, type WatchVal, type WatchVals } from "./watch";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,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,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,10 @@
1
+ export { Memo } from "./memo";
2
+ export { Bind } from "./bind";
3
+ export { Log } from "./log";
4
+ export { Once } from "./once";
5
+ export { Retry } from "./retry";
6
+ export { Debounce } from "./debounce";
7
+ export { Throttle } from "./throttle";
8
+ export { When } from "./when";
9
+ export { Watch } from "./watch";
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,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,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAiC,MAAM,SAAS,CAAC"}
@@ -0,0 +1,9 @@
1
+ export interface LogOptions {
2
+ level?: "log" | "warn" | "error" | "debug";
3
+ args?: boolean;
4
+ result?: boolean;
5
+ time?: boolean;
6
+ devOnly?: boolean;
7
+ }
8
+ export declare function Log(options?: LogOptions): (_target: object, methodKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
9
+ //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/functions/log.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;IAC3C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,wBAAgB,GAAG,CAAC,OAAO,GAAE,UAAe,IAUxC,SAAS,MAAM,EACf,WAAW,MAAM,EACjB,YAAY,kBAAkB,KAC7B,kBAAkB,CA8CtB"}