@praxisjs/decorators 0.1.0 → 0.3.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.
- package/CHANGELOG.md +37 -0
- package/dist/component/component.d.ts +2 -2
- package/dist/component/component.d.ts.map +1 -1
- package/dist/component/component.js +5 -2
- package/dist/component/component.js.map +1 -1
- package/dist/component/index.d.ts +0 -1
- package/dist/component/index.d.ts.map +1 -1
- package/dist/component/index.js +0 -1
- package/dist/component/index.js.map +1 -1
- package/dist/component/lazy.d.ts +2 -2
- package/dist/component/lazy.d.ts.map +1 -1
- package/dist/component/lazy.js +8 -8
- package/dist/component/lazy.js.map +1 -1
- package/dist/component/virtual.d.ts +2 -2
- package/dist/component/virtual.d.ts.map +1 -1
- package/dist/component/virtual.js +45 -14
- package/dist/component/virtual.js.map +1 -1
- package/dist/events/emit.d.ts +2 -1
- package/dist/events/emit.d.ts.map +1 -1
- package/dist/events/emit.js +11 -16
- package/dist/events/emit.js.map +1 -1
- package/dist/events/helper.d.ts +2 -2
- package/dist/events/helper.d.ts.map +1 -1
- package/dist/events/helper.js.map +1 -1
- package/dist/events/on-command.d.ts +2 -1
- package/dist/events/on-command.d.ts.map +1 -1
- package/dist/events/on-command.js +30 -27
- package/dist/events/on-command.js.map +1 -1
- package/dist/functions/bind.d.ts +2 -1
- package/dist/functions/bind.d.ts.map +1 -1
- package/dist/functions/bind.js +10 -15
- package/dist/functions/bind.js.map +1 -1
- package/dist/functions/debounce.d.ts +2 -1
- package/dist/functions/debounce.d.ts.map +1 -1
- package/dist/functions/debounce.js +20 -24
- package/dist/functions/debounce.js.map +1 -1
- package/dist/functions/log.d.ts +2 -1
- package/dist/functions/log.d.ts.map +1 -1
- package/dist/functions/log.js +5 -6
- package/dist/functions/log.js.map +1 -1
- package/dist/functions/memo.d.ts +2 -1
- package/dist/functions/memo.d.ts.map +1 -1
- package/dist/functions/memo.js +5 -6
- package/dist/functions/memo.js.map +1 -1
- package/dist/functions/once.d.ts +2 -1
- package/dist/functions/once.d.ts.map +1 -1
- package/dist/functions/once.js +3 -5
- package/dist/functions/once.js.map +1 -1
- package/dist/functions/retry.d.ts +2 -1
- package/dist/functions/retry.d.ts.map +1 -1
- package/dist/functions/retry.js +3 -5
- package/dist/functions/retry.js.map +1 -1
- package/dist/functions/throttle.d.ts +2 -1
- package/dist/functions/throttle.d.ts.map +1 -1
- package/dist/functions/throttle.js +18 -22
- package/dist/functions/throttle.js.map +1 -1
- package/dist/functions/watch.d.ts +7 -7
- package/dist/functions/watch.d.ts.map +1 -1
- package/dist/functions/watch.js +31 -35
- package/dist/functions/watch.js.map +1 -1
- package/dist/functions/when.d.ts +2 -1
- package/dist/functions/when.d.ts.map +1 -1
- package/dist/functions/when.js +24 -24
- package/dist/functions/when.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/properties/history.d.ts +4 -1
- package/dist/properties/history.d.ts.map +1 -1
- package/dist/properties/history.js +35 -33
- package/dist/properties/history.js.map +1 -1
- package/dist/properties/index.d.ts +1 -1
- package/dist/properties/index.d.ts.map +1 -1
- package/dist/properties/index.js.map +1 -1
- package/dist/properties/persisted.d.ts +3 -2
- package/dist/properties/persisted.d.ts.map +1 -1
- package/dist/properties/persisted.js +20 -23
- package/dist/properties/persisted.js.map +1 -1
- package/dist/properties/prop.d.ts +2 -1
- package/dist/properties/prop.d.ts.map +1 -1
- package/dist/properties/prop.js +24 -13
- package/dist/properties/prop.js.map +1 -1
- package/dist/properties/slot.d.ts +4 -8
- package/dist/properties/slot.d.ts.map +1 -1
- package/dist/properties/slot.js +34 -24
- package/dist/properties/slot.js.map +1 -1
- package/dist/properties/state.d.ts +2 -1
- package/dist/properties/state.d.ts.map +1 -1
- package/dist/properties/state.js +19 -19
- package/dist/properties/state.js.map +1 -1
- package/package.json +3 -4
- package/src/component/component.ts +9 -2
- package/src/component/index.ts +0 -1
- package/src/component/lazy.ts +10 -8
- package/src/component/virtual.tsx +71 -28
- package/src/events/emit.ts +15 -22
- package/src/events/helper.ts +5 -2
- package/src/events/on-command.ts +43 -44
- package/src/functions/bind.ts +14 -18
- package/src/functions/debounce.ts +23 -26
- package/src/functions/log.ts +11 -11
- package/src/functions/memo.ts +8 -9
- package/src/functions/once.ts +7 -10
- package/src/functions/retry.ts +7 -12
- package/src/functions/throttle.ts +21 -24
- package/src/functions/watch.ts +44 -48
- package/src/functions/when.ts +30 -32
- package/src/index.ts +10 -2
- package/src/properties/history.ts +50 -55
- package/src/properties/index.ts +1 -1
- package/src/properties/persisted.ts +40 -31
- package/src/properties/prop.ts +30 -13
- package/src/properties/slot.ts +46 -50
- package/src/properties/state.ts +24 -18
- package/dist/component/lifecycle.d.ts +0 -3
- package/dist/component/lifecycle.d.ts.map +0 -1
- package/dist/component/lifecycle.js +0 -35
- package/dist/component/lifecycle.js.map +0 -1
- package/dist/component/memoize.d.ts +0 -5
- package/dist/component/memoize.d.ts.map +0 -1
- package/dist/component/memoize.js +0 -23
- package/dist/component/memoize.js.map +0 -1
- package/src/component/lifecycle.ts +0 -47
- package/src/component/memoize.ts +0 -31
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @praxisjs/decorators
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- bb0d4f8: **Refactor decorator system and component architecture across PraxisJS packages**
|
|
8
|
+
|
|
9
|
+
- Replaced legacy decorator signatures (`constructor`, `target`, `propertyKey`, method descriptor) with the standard TC39 decorator context API (`ClassDecoratorContext`, `ClassFieldDecoratorContext`, `ClassMethodDecoratorContext`) across `@praxisjs/decorators`, `@praxisjs/store`, `@praxisjs/concurrent`, `@praxisjs/router`, `@praxisjs/motion`, `@praxisjs/di`, and `@praxisjs/fsm`.
|
|
10
|
+
- Introduced `StatefulComponent` and `StatelessComponent` as the new base classes, replacing the deprecated `BaseComponent`/`Function Component` pattern, across `@praxisjs/core`, `@praxisjs/runtime`, `@praxisjs/devtools`, and templates.
|
|
11
|
+
- Implemented core rendering functionality in `@praxisjs/runtime` (`mountChildren`, `mountComponent`, reactive scope management) and removed the deprecated `renderer.ts`.
|
|
12
|
+
- Refactored `@praxisjs/jsx` to delegate rendering to `@praxisjs/runtime` and improved type safety with `flattenChildren` and `isComponent` utilities.
|
|
13
|
+
- Updated internal module structure with new `internal` exports in `package.json` files for shared utilities and types.
|
|
14
|
+
- Removed `experimentalDecorators`/`emitDecoratorMetadata` from `tsconfig.json` in favor of native decorator support.
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [bb0d4f8]
|
|
19
|
+
- @praxisjs/core@0.3.0
|
|
20
|
+
- @praxisjs/shared@0.2.0
|
|
21
|
+
|
|
22
|
+
## 0.2.0
|
|
23
|
+
|
|
24
|
+
### Minor Changes
|
|
25
|
+
|
|
26
|
+
- f48dbc4: Introduce WithHistory<T, K> utility type for better TypeScript inference when using the @History decorator, and fix performance issues in the history() primitive.
|
|
27
|
+
|
|
28
|
+
Changes:
|
|
29
|
+
|
|
30
|
+
@praxisjs/decorators: Added WithHistory<T, K> type that maps a property key to its corresponding \*History accessor type, enabling proper type-checking on decorated classes.
|
|
31
|
+
@praxisjs/decorators: Simplified @History decorator internals — replaced verbose getOwnPropertyDescriptor lookups with direct property access (this[propertyKey]), reducing complexity.
|
|
32
|
+
@praxisjs/core: Fixed history() to use peek() when reading \_past and \_current inside the tracking effect, preventing unnecessary re-runs caused by reactive reads during history recording.
|
|
33
|
+
@praxisjs/core: Added an \_initialized guard so the first value is captured without pushing an empty entry into the past stack.
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [f48dbc4]
|
|
38
|
+
- @praxisjs/core@0.2.0
|
|
39
|
+
|
|
3
40
|
## 0.1.0
|
|
4
41
|
|
|
5
42
|
### Minor Changes
|
|
@@ -1,3 +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;
|
|
1
|
+
import type { ComponentConstructor, ComponentInstance } from "@praxisjs/shared/internal";
|
|
2
|
+
export declare function Component(): <T extends new (...args: any[]) => ComponentInstance>(constructor: T, _context: ClassDecoratorContext) => T & ComponentConstructor;
|
|
3
3
|
//# sourceMappingURL=component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/component/component.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/component/component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAEnC,wBAAgB,SAAS,KAEN,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,iBAAiB,EAClE,aAAa,CAAC,EACd,UAAU,qBAAqB,KAC9B,CAAC,GAAG,oBAAoB,CAa5B"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { StatelessComponent } from "@praxisjs/core";
|
|
1
2
|
export function Component() {
|
|
2
3
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3
|
-
return function (constructor) {
|
|
4
|
+
return function (constructor, _context) {
|
|
5
|
+
const isStateless = constructor.prototype instanceof StatelessComponent;
|
|
4
6
|
const Enhanced = class extends constructor {
|
|
5
|
-
static
|
|
7
|
+
static __isComponent = true;
|
|
8
|
+
static __isStateless = isStateless;
|
|
6
9
|
};
|
|
7
10
|
Object.defineProperty(Enhanced, "name", {
|
|
8
11
|
value: constructor.name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/component/component.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/component/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAMpD,MAAM,UAAU,SAAS;IACvB,8DAA8D;IAC9D,OAAO,UACL,WAAc,EACd,QAA+B;QAE/B,MAAM,WAAW,GAAG,WAAW,CAAC,SAAS,YAAY,kBAAkB,CAAC;QACxE,MAAM,QAAQ,GAAG,KAAM,SAAQ,WAAW;YACxC,MAAM,CAAC,aAAa,GAAG,IAAa,CAAC;YACrC,MAAM,CAAC,aAAa,GAAG,WAAW,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"}
|
|
@@ -1 +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,
|
|
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,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/component/index.js
CHANGED
|
@@ -1 +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,
|
|
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,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/component/lazy.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare function Lazy(placeholder?: number): <T extends new (...args: any[]) =>
|
|
1
|
+
import { type RootComponent } from "@praxisjs/core/internal";
|
|
2
|
+
export declare function Lazy(placeholder?: number): <T extends new (...args: any[]) => RootComponent>(constructor: T, _context: ClassDecoratorContext) => T;
|
|
3
3
|
//# sourceMappingURL=lazy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/component/lazy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/component/lazy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAU,MAAM,yBAAyB,CAAC;AAErE,wBAAgB,IAAI,CAAC,WAAW,SAAM,IAEnB,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,aAAa,EAC9D,aAAa,CAAC,EACd,UAAU,qBAAqB,KAC9B,CAAC,CAkDL"}
|
package/dist/component/lazy.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { signal } from "@praxisjs/core";
|
|
1
|
+
import { signal } from "@praxisjs/core/internal";
|
|
2
2
|
export function Lazy(placeholder = 200) {
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
-
return function (constructor) {
|
|
4
|
+
return function (constructor, _context) {
|
|
5
5
|
return class LazyWrapper extends constructor {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this._originalRender = this.render.bind(this);
|
|
10
|
-
}
|
|
6
|
+
_lazyVisible = signal(false);
|
|
7
|
+
_observer;
|
|
8
|
+
_originalRender = this.render.bind(this);
|
|
11
9
|
onMount() {
|
|
12
10
|
super.onMount?.();
|
|
13
|
-
|
|
11
|
+
// Use the end anchor to find the parent element
|
|
12
|
+
const el = this._anchor
|
|
13
|
+
?.parentElement ?? null;
|
|
14
14
|
if (!el)
|
|
15
15
|
return;
|
|
16
16
|
if (!("IntersectionObserver" in window)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazy.js","sourceRoot":"","sources":["../../src/component/lazy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"lazy.js","sourceRoot":"","sources":["../../src/component/lazy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAErE,MAAM,UAAU,IAAI,CAAC,WAAW,GAAG,GAAG;IACpC,8DAA8D;IAC9D,OAAO,UACL,WAAc,EACd,QAA+B;QAE/B,OAAO,MAAM,WAAY,SAAQ,WAAW;YACzB,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;YACtC,SAAS,CAAwB;YACxB,eAAe,GAC9B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEzB,OAAO;gBACL,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;gBAElB,gDAAgD;gBAChD,MAAM,EAAE,GACL,IAAyC,CAAC,OAAO;oBAChD,EAAE,aAAa,IAAI,IAAI,CAAC;gBAC5B,IAAI,CAAC,EAAE;oBAAE,OAAO;gBAEhB,IAAI,CAAC,CAAC,sBAAsB,IAAI,MAAM,CAAC,EAAE,CAAC;oBACxC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;oBAC5B,OAAO;gBACT,CAAC;gBAED,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,CAAC;oBACzB,EAAE,CAAC,KAAK,CAAC,SAAS,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;gBAClD,CAAC;gBAED,IAAI,CAAC,SAAS,GAAG,IAAI,oBAAoB,CACvC,CAAC,OAAO,EAAE,EAAE;oBACV,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC;wBAC/B,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;wBAC5B,EAAE,CAAC,KAAK,CAAC,SAAS,GAAG,EAAE,CAAC;wBACxB,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,CAAC;oBAC/B,CAAC;gBACH,CAAC,EACD,EAAE,UAAU,EAAE,OAAO,EAAE,CACxB,CAAC;gBAEF,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAC7B,CAAC;YAED,SAAS;gBACP,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;gBACpB,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,CAAC;YAC/B,CAAC;YAED,MAAM;gBACJ,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;oBAAE,OAAO,IAAI,CAAC;gBACtC,OAAO,IAAI,CAAC,eAAe,EAAE,CAAC;YAChC,CAAC;SACc,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
export declare function Virtual(itemHeight: number, buffer?: number): <T extends new (...args: any[]) =>
|
|
1
|
+
import { type RootComponent } from "@praxisjs/core/internal";
|
|
2
|
+
export declare function Virtual(itemHeight: number, buffer?: number): <T extends new (...args: any[]) => RootComponent>(constructor: T, _context: ClassDecoratorContext) => T;
|
|
3
3
|
//# sourceMappingURL=virtual.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual.d.ts","sourceRoot":"","sources":["../../src/component/virtual.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"virtual.d.ts","sourceRoot":"","sources":["../../src/component/virtual.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,aAAa,EAAU,MAAM,yBAAyB,CAAC;AAQvF,wBAAgB,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,SAAI,IAEnC,CAAC,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,aAAa,EAC9D,aAAa,CAAC,EACd,UAAU,qBAAqB,KAC9B,CAAC,CAqIL"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { computed, signal } from "@praxisjs/core";
|
|
1
|
+
import { computed, effect, signal } from "@praxisjs/core/internal";
|
|
3
2
|
export function Virtual(itemHeight, buffer = 3) {
|
|
4
3
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
-
return function (constructor) {
|
|
4
|
+
return function (constructor, _context) {
|
|
6
5
|
return class VirtualWrapper extends constructor {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
_scrollTop = signal(0);
|
|
7
|
+
_viewHeight = signal(600);
|
|
8
|
+
_container;
|
|
9
|
+
_scrollHandler;
|
|
10
|
+
_cleanups = [];
|
|
12
11
|
onMount() {
|
|
13
12
|
super.onMount?.();
|
|
13
|
+
// Use the end anchor set by the runtime to locate the parent element
|
|
14
14
|
this._container =
|
|
15
|
-
|
|
15
|
+
this._anchor?.parentElement ?? undefined;
|
|
16
16
|
if (!this._container)
|
|
17
17
|
return;
|
|
18
18
|
this._container.style.overflowY = "auto";
|
|
@@ -29,17 +29,19 @@ export function Virtual(itemHeight, buffer = 3) {
|
|
|
29
29
|
if (this._container && this._scrollHandler) {
|
|
30
30
|
this._container.removeEventListener("scroll", this._scrollHandler);
|
|
31
31
|
}
|
|
32
|
+
this._cleanups.forEach((c) => { c(); });
|
|
33
|
+
this._cleanups = [];
|
|
32
34
|
}
|
|
33
35
|
render() {
|
|
34
|
-
const
|
|
35
|
-
const items =
|
|
36
|
+
const host = this;
|
|
37
|
+
const items = host.items ?? [];
|
|
36
38
|
const total = items.length;
|
|
37
39
|
const totalH = total * itemHeight;
|
|
38
|
-
|
|
39
|
-
if (!renderItem) {
|
|
40
|
+
if (typeof host.renderItem !== "function") {
|
|
40
41
|
console.warn(`[Virtual] ${constructor.name} must implement renderItem(item, index)`);
|
|
41
42
|
return null;
|
|
42
43
|
}
|
|
44
|
+
const renderItem = host.renderItem.bind(host);
|
|
43
45
|
const startIdx = computed(() => {
|
|
44
46
|
const start = Math.floor(this._scrollTop() / itemHeight) - buffer;
|
|
45
47
|
return Math.max(0, start);
|
|
@@ -58,7 +60,36 @@ export function Virtual(itemHeight, buffer = 3) {
|
|
|
58
60
|
});
|
|
59
61
|
const offsetTop = computed(() => startIdx() * itemHeight);
|
|
60
62
|
const offsetBottom = computed(() => (total - 1 - endIdx()) * itemHeight);
|
|
61
|
-
|
|
63
|
+
const outer = document.createElement("div");
|
|
64
|
+
outer.setAttribute("style", `height:${String(totalH)}px; position:relative;`);
|
|
65
|
+
const spacerTop = document.createElement("div");
|
|
66
|
+
this._cleanups.push(effect(() => {
|
|
67
|
+
spacerTop.setAttribute("style", `height:${String(offsetTop())}px;`);
|
|
68
|
+
}));
|
|
69
|
+
const itemsSlot = document.createElement("div");
|
|
70
|
+
this._cleanups.push(effect(() => {
|
|
71
|
+
while (itemsSlot.firstChild) {
|
|
72
|
+
itemsSlot.removeChild(itemsSlot.firstChild);
|
|
73
|
+
}
|
|
74
|
+
visibleItems().forEach(({ item, index }) => {
|
|
75
|
+
const wrapper = document.createElement("div");
|
|
76
|
+
wrapper.setAttribute("style", `height:${String(itemHeight)}px; overflow:hidden;`);
|
|
77
|
+
const rendered = renderItem(item, index);
|
|
78
|
+
if (rendered) {
|
|
79
|
+
const nodes = (Array.isArray(rendered) ? rendered.flat() : [rendered]);
|
|
80
|
+
nodes.forEach((n) => wrapper.appendChild(n));
|
|
81
|
+
}
|
|
82
|
+
itemsSlot.appendChild(wrapper);
|
|
83
|
+
});
|
|
84
|
+
}));
|
|
85
|
+
const spacerBottom = document.createElement("div");
|
|
86
|
+
this._cleanups.push(effect(() => {
|
|
87
|
+
spacerBottom.setAttribute("style", `height:${String(offsetBottom())}px;`);
|
|
88
|
+
}));
|
|
89
|
+
outer.appendChild(spacerTop);
|
|
90
|
+
outer.appendChild(itemsSlot);
|
|
91
|
+
outer.appendChild(spacerBottom);
|
|
92
|
+
return outer;
|
|
62
93
|
}
|
|
63
94
|
};
|
|
64
95
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual.js","sourceRoot":"","sources":["../../src/component/virtual.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"virtual.js","sourceRoot":"","sources":["../../src/component/virtual.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAsB,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAQvF,MAAM,UAAU,OAAO,CAAC,UAAkB,EAAE,MAAM,GAAG,CAAC;IACpD,8DAA8D;IAC9D,OAAO,UACL,WAAc,EACd,QAA+B;QAE/B,OAAO,MAAM,cAAe,SAAQ,WAAW;YAC5B,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACvB,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YACnC,UAAU,CAAe;YACzB,cAAc,CAAc;YAC5B,SAAS,GAAsB,EAAE,CAAC;YAE1C,OAAO;gBACL,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;gBAElB,qEAAqE;gBACrE,IAAI,CAAC,UAAU;oBACZ,IAA+B,CAAC,OAAO,EAAE,aAAa,IAAI,SAAS,CAAC;gBAEvE,IAAI,CAAC,IAAI,CAAC,UAAU;oBAAE,OAAO;gBAE7B,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC;gBAC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,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;wBAC/C,CAAC;wBACD,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;oBACjC,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CACH,CAAC;gBAEF,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBACnD,IAAI,CAAC,SAAS,CAAC,IAAI,CACjB,MAAM,CAAC,GAAG,EAAE;oBACV,YAAY,CAAC,YAAY,CACvB,OAAO,EACP,UAAU,MAAM,CAAC,YAAY,EAAE,CAAC,KAAK,CACtC,CAAC;gBACJ,CAAC,CAAC,CACH,CAAC;gBAEF,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;gBAC7B,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;gBAC7B,KAAK,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;gBAEhC,OAAO,KAAK,CAAC;YACf,CAAC;SACc,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/events/emit.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { StatefulComponent } from "@praxisjs/core";
|
|
2
|
+
export declare function Emit(propName: string): (value: (this: StatefulComponent, ...args: unknown[]) => unknown, context: ClassMethodDecoratorContext<StatefulComponent>) => void;
|
|
2
3
|
//# sourceMappingURL=emit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../src/events/emit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../src/events/emit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,wBAAgB,IAAI,CAAC,QAAQ,EAAE,MAAM,IAEjC,OAAO,CAAC,IAAI,EAAE,iBAAiB,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,EAC/D,SAAS,2BAA2B,CAAC,iBAAiB,CAAC,KACtD,IAAI,CA+BR"}
|
package/dist/events/emit.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { readProp } from "./helper";
|
|
2
2
|
export function Emit(propName) {
|
|
3
|
-
return function (
|
|
4
|
-
const originalMethod = descriptor.value;
|
|
3
|
+
return function (value, context) {
|
|
5
4
|
const wrapped = function (...args) {
|
|
6
|
-
const result =
|
|
5
|
+
const result = value.apply(this, args);
|
|
7
6
|
const callback = readProp(this, propName);
|
|
8
7
|
if (typeof callback !== "function")
|
|
9
8
|
return result;
|
|
@@ -18,19 +17,15 @@ export function Emit(propName) {
|
|
|
18
17
|
}
|
|
19
18
|
return result;
|
|
20
19
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
return bound;
|
|
32
|
-
},
|
|
33
|
-
};
|
|
20
|
+
context.addInitializer(function () {
|
|
21
|
+
const name = context.name;
|
|
22
|
+
const bound = wrapped.bind(this);
|
|
23
|
+
Object.defineProperty(this, name, {
|
|
24
|
+
value: bound,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
});
|
|
28
|
+
});
|
|
34
29
|
};
|
|
35
30
|
}
|
|
36
31
|
//# sourceMappingURL=emit.js.map
|
package/dist/events/emit.js.map
CHANGED
|
@@ -1 +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,
|
|
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,KAA+D,EAC/D,OAAuD;QAEvD,MAAM,OAAO,GAAG,UAEd,GAAG,IAAe;YAElB,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAEvC,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,CAAC,cAAc,CAAC;YACrB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAc,CAAC;YACpC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,IAAyB,CAAC,CAAC;YACtD,MAAM,CAAC,cAAc,CAAC,IAAc,EAAE,IAAI,EAAE;gBAC1C,KAAK,EAAE,KAAK;gBACZ,YAAY,EAAE,IAAI;gBAClB,QAAQ,EAAE,IAAI;aACf,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/events/helper.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function readProp(instance:
|
|
1
|
+
import type { StatefulComponent } from "@praxisjs/core";
|
|
2
|
+
export declare function readProp(instance: StatefulComponent, propName: string): unknown;
|
|
3
3
|
//# sourceMappingURL=helper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/events/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/events/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,iBAAiB,EAC3B,QAAQ,EAAE,MAAM,GACf,OAAO,CAIT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../src/events/helper.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,QAAQ,
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../src/events/helper.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,QAAQ,CACtB,QAA2B,EAC3B,QAAgB;IAEhB,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"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { StatefulComponent } from "@praxisjs/core";
|
|
2
|
+
export declare function OnCommand(propName: string): (value: (this: StatefulComponent, ...args: unknown[]) => void, context: ClassMethodDecoratorContext<StatefulComponent>) => void;
|
|
2
3
|
//# sourceMappingURL=on-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"on-command.d.ts","sourceRoot":"","sources":["../../src/events/on-command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"on-command.d.ts","sourceRoot":"","sources":["../../src/events/on-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAMxD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,IAEtC,OAAO,CAAC,IAAI,EAAE,iBAAiB,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,EAC5D,SAAS,2BAA2B,CAAC,iBAAiB,CAAC,KACtD,IAAI,CA2CR"}
|
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
import { readProp } from "./helper";
|
|
2
2
|
export function OnCommand(propName) {
|
|
3
|
-
return function (
|
|
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;
|
|
3
|
+
return function (value, context) {
|
|
9
4
|
const cleanups = new WeakMap();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
5
|
+
context.addInitializer(function () {
|
|
6
|
+
const instance = this;
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
8
|
+
const originalOnMount = instance.onMount;
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
10
|
+
const originalOnUnmount = instance.onUnmount;
|
|
11
|
+
instance.onMount = function () {
|
|
12
|
+
originalOnMount?.call(this);
|
|
13
|
+
const command = readProp(this, propName);
|
|
14
|
+
if (!command) {
|
|
15
|
+
console.warn(`[OnCommand] prop "${propName}" was not provided to ${this.constructor.name}`);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (typeof command.subscribe !== "function") {
|
|
19
|
+
console.warn(`[OnCommand] prop "${propName}" is not a valid Command in ${this.constructor.name}`);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const bound = value.bind(this);
|
|
23
|
+
const unsub = command.subscribe((...args) => {
|
|
24
|
+
bound(...args);
|
|
25
|
+
});
|
|
26
|
+
cleanups.set(this, unsub);
|
|
27
|
+
};
|
|
28
|
+
instance.onUnmount = function () {
|
|
29
|
+
originalOnUnmount?.call(this);
|
|
30
|
+
cleanups.get(this)?.();
|
|
31
|
+
cleanups.delete(this);
|
|
32
|
+
};
|
|
33
|
+
});
|
|
31
34
|
};
|
|
32
35
|
}
|
|
33
36
|
//# sourceMappingURL=on-command.js.map
|
|
@@ -1 +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,
|
|
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,KAA4D,EAC5D,OAAuD;QAEvD,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAsB,CAAC;QAEnD,OAAO,CAAC,cAAc,CAAC;YACrB,MAAM,QAAQ,GAAG,IAAyB,CAAC;YAC3C,6DAA6D;YAC7D,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC;YACzC,6DAA6D;YAC7D,MAAM,iBAAiB,GAAG,QAAQ,CAAC,SAAS,CAAC;YAE7C,QAAQ,CAAC,OAAO,GAAG;gBACjB,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;gBAE5B,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAiC,CAAC;gBAEzE,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,OAAO,CAAC,IAAI,CACV,qBAAqB,QAAQ,yBAAyB,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAC9E,CAAC;oBACF,OAAO;gBACT,CAAC;gBAED,IAAI,OAAO,OAAO,CAAC,SAAS,KAAK,UAAU,EAAE,CAAC;oBAC5C,OAAO,CAAC,IAAI,CACV,qBAAqB,QAAQ,+BAA+B,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CACpF,CAAC;oBACF,OAAO;gBACT,CAAC;gBAED,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC/B,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,IAAe,EAAE,EAAE;oBACrD,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;gBACjB,CAAC,CAAC,CAAC;gBACH,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC5B,CAAC,CAAC;YAEF,QAAQ,CAAC,SAAS,GAAG;gBACnB,iBAAiB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC9B,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;gBACvB,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACxB,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/functions/bind.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { StatefulComponent } from "@praxisjs/core";
|
|
2
|
+
export declare function Bind(): (value: (this: object, ...args: unknown[]) => unknown, context: ClassMethodDecoratorContext<StatefulComponent>) => void;
|
|
2
3
|
//# sourceMappingURL=bind.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../../src/functions/bind.ts"],"names":[],"mappings":"AAAA,wBAAgB,IAAI,KAEhB,
|
|
1
|
+
{"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../../src/functions/bind.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,wBAAgB,IAAI,KAEhB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,EACpD,SAAS,2BAA2B,CAAC,iBAAiB,CAAC,KACtD,IAAI,CAWR"}
|
package/dist/functions/bind.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
export function Bind() {
|
|
2
|
-
return function (
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
writable: true,
|
|
13
|
-
});
|
|
14
|
-
return bound;
|
|
15
|
-
},
|
|
16
|
-
};
|
|
2
|
+
return function (value, context) {
|
|
3
|
+
context.addInitializer(function () {
|
|
4
|
+
const name = context.name;
|
|
5
|
+
const bound = value.bind(this);
|
|
6
|
+
Object.defineProperty(this, name, {
|
|
7
|
+
value: bound,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
});
|
|
11
|
+
});
|
|
17
12
|
};
|
|
18
13
|
}
|
|
19
14
|
//# sourceMappingURL=bind.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bind.js","sourceRoot":"","sources":["../../src/functions/bind.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bind.js","sourceRoot":"","sources":["../../src/functions/bind.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,IAAI;IAClB,OAAO,UACL,KAAoD,EACpD,OAAuD;QAEvD,OAAO,CAAC,cAAc,CAAC;YACrB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAc,CAAC;YACpC,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAc,CAAC,CAAC;YACzC,MAAM,CAAC,cAAc,CAAC,IAAc,EAAE,IAAI,EAAE;gBAC1C,KAAK,EAAE,KAAK;gBACZ,YAAY,EAAE,IAAI;gBAClB,QAAQ,EAAE,IAAI;aACf,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { StatefulComponent } from "@praxisjs/core";
|
|
2
|
+
export declare function Debounce(ms: number): (value: (this: object, ...args: unknown[]) => unknown, context: ClassMethodDecoratorContext<StatefulComponent>) => void;
|
|
2
3
|
//# sourceMappingURL=debounce.d.ts.map
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../src/functions/debounce.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,IAI/B,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,EACpD,SAAS,2BAA2B,CAAC,iBAAiB,CAAC,KACtD,IAAI,CAsBR"}
|
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
export function Debounce(ms) {
|
|
2
2
|
const timers = new WeakMap();
|
|
3
|
-
return function (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
return bound;
|
|
25
|
-
},
|
|
26
|
-
};
|
|
3
|
+
return function (value, context) {
|
|
4
|
+
context.addInitializer(function () {
|
|
5
|
+
const instance = this;
|
|
6
|
+
const name = context.name;
|
|
7
|
+
const bound = (...args) => {
|
|
8
|
+
const existing = timers.get(instance);
|
|
9
|
+
if (existing !== undefined)
|
|
10
|
+
clearTimeout(existing);
|
|
11
|
+
const timer = setTimeout(() => {
|
|
12
|
+
timers.delete(instance);
|
|
13
|
+
value.apply(instance, args);
|
|
14
|
+
}, ms);
|
|
15
|
+
timers.set(instance, timer);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(instance, name, {
|
|
18
|
+
value: bound,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
});
|
|
22
|
+
});
|
|
27
23
|
};
|
|
28
24
|
}
|
|
29
25
|
//# sourceMappingURL=debounce.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debounce.js","sourceRoot":"","sources":["../../src/functions/debounce.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"debounce.js","sourceRoot":"","sources":["../../src/functions/debounce.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,QAAQ,CAAC,EAAU;IACjC,MAAM,MAAM,GAAG,IAAI,OAAO,EAAyC,CAAC;IAEpE,OAAO,UACL,KAAoD,EACpD,OAAuD;QAEvD,OAAO,CAAC,cAAc,CAAC;YACrB,MAAM,QAAQ,GAAG,IAAc,CAAC;YAChC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAc,CAAC;YACpC,MAAM,KAAK,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE;gBACnC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBACtC,IAAI,QAAQ,KAAK,SAAS;oBAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;gBAEnD,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;oBAC5B,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;oBACxB,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;gBAC9B,CAAC,EAAE,EAAE,CAAC,CAAC;gBAEP,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YAC9B,CAAC,CAAC;YACF,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE;gBACpC,KAAK,EAAE,KAAK;gBACZ,YAAY,EAAE,IAAI;gBAClB,QAAQ,EAAE,IAAI;aACf,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/functions/log.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StatefulComponent } from "@praxisjs/core";
|
|
1
2
|
export interface LogOptions {
|
|
2
3
|
level?: "log" | "warn" | "error" | "debug";
|
|
3
4
|
args?: boolean;
|
|
@@ -5,5 +6,5 @@ export interface LogOptions {
|
|
|
5
6
|
time?: boolean;
|
|
6
7
|
devOnly?: boolean;
|
|
7
8
|
}
|
|
8
|
-
export declare function Log(options?: LogOptions): (
|
|
9
|
+
export declare function Log(options?: LogOptions): (value: (this: object, ...args: unknown[]) => unknown, context: ClassMethodDecoratorContext<StatefulComponent>) => (this: object, ...args: unknown[]) => unknown;
|
|
9
10
|
//# sourceMappingURL=log.d.ts.map
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/functions/log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,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,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,EACpD,SAAS,2BAA2B,CAAC,iBAAiB,CAAC,KACtD,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CA6CjD"}
|