@praxisjs/decorators 0.4.3 → 0.6.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 +39 -0
- package/dist/__tests__/component.test.js +10 -1
- package/dist/__tests__/component.test.js.map +1 -1
- package/dist/__tests__/compose.test.d.ts +2 -0
- package/dist/__tests__/compose.test.d.ts.map +1 -0
- package/dist/__tests__/compose.test.js +171 -0
- package/dist/__tests__/compose.test.js.map +1 -0
- package/dist/__tests__/events.test.js +26 -0
- package/dist/__tests__/events.test.js.map +1 -1
- package/dist/__tests__/functions.test.js +205 -47
- package/dist/__tests__/functions.test.js.map +1 -1
- package/dist/__tests__/lazy.test.js +5 -7
- package/dist/__tests__/lazy.test.js.map +1 -1
- package/dist/__tests__/memo.test.js +114 -25
- package/dist/__tests__/memo.test.js.map +1 -1
- package/dist/__tests__/properties.test.js +193 -0
- package/dist/__tests__/properties.test.js.map +1 -1
- package/dist/__tests__/resource.test.d.ts +2 -0
- package/dist/__tests__/resource.test.d.ts.map +1 -0
- package/dist/__tests__/resource.test.js +127 -0
- package/dist/__tests__/resource.test.js.map +1 -0
- package/dist/__tests__/slot.test.js +32 -0
- package/dist/__tests__/slot.test.js.map +1 -1
- package/dist/__tests__/until.test.d.ts +2 -0
- package/dist/__tests__/until.test.d.ts.map +1 -0
- package/dist/__tests__/until.test.js +88 -0
- package/dist/__tests__/until.test.js.map +1 -0
- package/dist/__tests__/virtual.test.js +164 -15
- package/dist/__tests__/virtual.test.js.map +1 -1
- package/dist/component/component.d.ts +1 -1
- package/dist/component/component.d.ts.map +1 -1
- package/dist/component/component.js +15 -10
- package/dist/component/component.js.map +1 -1
- package/dist/component/lazy.d.ts.map +1 -1
- package/dist/component/lazy.js +29 -30
- package/dist/component/lazy.js.map +1 -1
- package/dist/component/virtual.d.ts.map +1 -1
- package/dist/component/virtual.js +49 -50
- package/dist/component/virtual.js.map +1 -1
- package/dist/create-class-decorator.d.ts +16 -0
- package/dist/create-class-decorator.d.ts.map +1 -0
- package/dist/create-class-decorator.js +35 -0
- package/dist/create-class-decorator.js.map +1 -0
- package/dist/create-field-decorator.d.ts +14 -0
- package/dist/create-field-decorator.d.ts.map +1 -0
- package/dist/create-field-decorator.js +37 -0
- package/dist/create-field-decorator.js.map +1 -0
- package/dist/create-getter-decorator.d.ts +18 -0
- package/dist/create-getter-decorator.d.ts.map +1 -0
- package/dist/create-getter-decorator.js +15 -0
- package/dist/create-getter-decorator.js.map +1 -0
- package/dist/create-lifecycle-method-decorator.d.ts +6 -0
- package/dist/create-lifecycle-method-decorator.d.ts.map +1 -0
- package/dist/create-lifecycle-method-decorator.js +22 -0
- package/dist/create-lifecycle-method-decorator.js.map +1 -0
- package/dist/create-method-decorator.d.ts +6 -0
- package/dist/create-method-decorator.d.ts.map +1 -0
- package/dist/create-method-decorator.js +14 -0
- package/dist/create-method-decorator.js.map +1 -0
- package/dist/events/emit.d.ts +1 -1
- package/dist/events/emit.d.ts.map +1 -1
- package/dist/events/emit.js +24 -29
- package/dist/events/emit.js.map +1 -1
- package/dist/events/on-command.d.ts +1 -2
- package/dist/events/on-command.d.ts.map +1 -1
- package/dist/events/on-command.js +15 -32
- package/dist/events/on-command.js.map +1 -1
- package/dist/functions/bind.d.ts +1 -2
- package/dist/functions/bind.d.ts.map +1 -1
- package/dist/functions/bind.js +4 -11
- package/dist/functions/bind.js.map +1 -1
- package/dist/functions/debounce.d.ts.map +1 -1
- package/dist/functions/debounce.js +21 -20
- package/dist/functions/debounce.js.map +1 -1
- package/dist/functions/index.d.ts +1 -0
- package/dist/functions/index.d.ts.map +1 -1
- package/dist/functions/index.js +1 -0
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/log.d.ts +1 -2
- package/dist/functions/log.d.ts.map +1 -1
- package/dist/functions/log.js +40 -38
- package/dist/functions/log.js.map +1 -1
- package/dist/functions/memo.d.ts +1 -2
- package/dist/functions/memo.d.ts.map +1 -1
- package/dist/functions/memo.js +29 -27
- package/dist/functions/memo.js.map +1 -1
- package/dist/functions/once.d.ts +1 -2
- package/dist/functions/once.d.ts.map +1 -1
- package/dist/functions/once.js +14 -12
- package/dist/functions/once.js.map +1 -1
- package/dist/functions/retry.d.ts +1 -2
- package/dist/functions/retry.d.ts.map +1 -1
- package/dist/functions/retry.js +23 -20
- package/dist/functions/retry.js.map +1 -1
- package/dist/functions/throttle.d.ts +1 -2
- package/dist/functions/throttle.d.ts.map +1 -1
- package/dist/functions/throttle.js +11 -17
- package/dist/functions/throttle.js.map +1 -1
- package/dist/functions/until.d.ts +2 -0
- package/dist/functions/until.d.ts.map +1 -0
- package/dist/functions/until.js +17 -0
- package/dist/functions/until.js.map +1 -0
- package/dist/functions/watch.d.ts +1 -1
- package/dist/functions/watch.d.ts.map +1 -1
- package/dist/functions/watch.js +25 -39
- package/dist/functions/watch.js.map +1 -1
- package/dist/functions/when.d.ts +1 -2
- package/dist/functions/when.d.ts.map +1 -1
- package/dist/functions/when.js +10 -26
- package/dist/functions/when.js.map +1 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -2
- package/dist/index.js.map +1 -1
- package/dist/properties/compose.d.ts +3 -0
- package/dist/properties/compose.d.ts.map +1 -0
- package/dist/properties/compose.js +40 -0
- package/dist/properties/compose.js.map +1 -0
- package/dist/properties/computed.d.ts +1 -2
- package/dist/properties/computed.d.ts.map +1 -1
- package/dist/properties/computed.js +10 -9
- package/dist/properties/computed.js.map +1 -1
- package/dist/properties/history.d.ts.map +1 -1
- package/dist/properties/history.js +37 -32
- package/dist/properties/history.js.map +1 -1
- package/dist/properties/index.d.ts +2 -0
- package/dist/properties/index.d.ts.map +1 -1
- package/dist/properties/index.js +2 -0
- package/dist/properties/index.js.map +1 -1
- package/dist/properties/persisted.d.ts +1 -2
- package/dist/properties/persisted.d.ts.map +1 -1
- package/dist/properties/persisted.js +13 -29
- package/dist/properties/persisted.js.map +1 -1
- package/dist/properties/prop.d.ts +1 -2
- package/dist/properties/prop.d.ts.map +1 -1
- package/dist/properties/prop.js +21 -25
- package/dist/properties/prop.js.map +1 -1
- package/dist/properties/resource.d.ts +14 -0
- package/dist/properties/resource.d.ts.map +1 -0
- package/dist/properties/resource.js +27 -0
- package/dist/properties/resource.js.map +1 -0
- package/dist/properties/slot.d.ts +1 -2
- package/dist/properties/slot.d.ts.map +1 -1
- package/dist/properties/slot.js +15 -20
- package/dist/properties/slot.js.map +1 -1
- package/dist/properties/state.d.ts +1 -2
- package/dist/properties/state.d.ts.map +1 -1
- package/dist/properties/state.js +13 -18
- package/dist/properties/state.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/component.test.ts +10 -0
- package/src/__tests__/compose.test.ts +202 -0
- package/src/__tests__/events.test.ts +32 -0
- package/src/__tests__/functions.test.ts +257 -46
- package/src/__tests__/lazy.test.ts +3 -5
- package/src/__tests__/memo.test.ts +143 -25
- package/src/__tests__/properties.test.ts +233 -0
- package/src/__tests__/resource.test.ts +141 -0
- package/src/__tests__/slot.test.ts +38 -0
- package/src/__tests__/until.test.ts +113 -0
- package/src/__tests__/virtual.test.ts +135 -7
- package/src/component/component.ts +27 -12
- package/src/component/lazy.ts +33 -37
- package/src/component/virtual.tsx +67 -75
- package/src/create-class-decorator.ts +61 -0
- package/src/create-field-decorator.ts +66 -0
- package/src/create-getter-decorator.ts +52 -0
- package/src/create-lifecycle-method-decorator.ts +38 -0
- package/src/create-method-decorator.ts +26 -0
- package/src/events/emit.ts +22 -33
- package/src/events/on-command.ts +22 -47
- package/src/functions/bind.ts +4 -15
- package/src/functions/debounce.ts +21 -23
- package/src/functions/index.ts +1 -0
- package/src/functions/log.ts +40 -43
- package/src/functions/memo.ts +28 -42
- package/src/functions/once.ts +13 -16
- package/src/functions/retry.ts +21 -22
- package/src/functions/throttle.ts +11 -24
- package/src/functions/until.ts +19 -0
- package/src/functions/watch.ts +27 -43
- package/src/functions/when.ts +11 -36
- package/src/index.ts +29 -0
- package/src/properties/compose.ts +53 -0
- package/src/properties/computed.ts +11 -13
- package/src/properties/history.ts +42 -41
- package/src/properties/index.ts +2 -0
- package/src/properties/persisted.ts +17 -58
- package/src/properties/prop.ts +21 -31
- package/src/properties/resource.ts +34 -0
- package/src/properties/slot.ts +17 -30
- package/src/properties/state.ts +14 -24
package/dist/functions/retry.js
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
+
import { createMethodDecorator } from "../create-method-decorator";
|
|
1
2
|
export function Retry(maxAttempts, options = {}) {
|
|
2
3
|
const { delay = 0, backoff = 1, onRetry } = options;
|
|
3
|
-
return
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
return createMethodDecorator({
|
|
5
|
+
wrap(original, instance) {
|
|
6
|
+
return async (...args) => {
|
|
7
|
+
let lastError = new Error("Unknown error");
|
|
8
|
+
let currentDelay = delay;
|
|
9
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
10
|
+
try {
|
|
11
|
+
return await original.apply(instance, args);
|
|
12
|
+
}
|
|
13
|
+
catch (e) {
|
|
14
|
+
lastError = e instanceof Error ? e : new Error(String(e));
|
|
15
|
+
if (attempt === maxAttempts)
|
|
16
|
+
break;
|
|
17
|
+
onRetry?.(lastError, attempt);
|
|
18
|
+
if (currentDelay > 0) {
|
|
19
|
+
await new Promise((res) => setTimeout(res, currentDelay));
|
|
20
|
+
currentDelay = Math.round(currentDelay * backoff);
|
|
21
|
+
}
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
};
|
|
24
|
+
throw lastError;
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
});
|
|
25
28
|
}
|
|
26
29
|
//# sourceMappingURL=retry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/functions/retry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/functions/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAQnE,MAAM,UAAU,KAAK,CAAC,WAAmB,EAAE,UAAwB,EAAE;IACnE,MAAM,EAAE,KAAK,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEpD,OAAO,qBAAqB,CAAC;QAC3B,IAAI,CAAC,QAAQ,EAAE,QAAQ;YACrB,OAAO,KAAK,EAAE,GAAG,IAAe,EAAE,EAAE;gBAClC,IAAI,SAAS,GAAU,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;gBAClD,IAAI,YAAY,GAAG,KAAK,CAAC;gBAEzB,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,WAAW,EAAE,OAAO,EAAE,EAAE,CAAC;oBACxD,IAAI,CAAC;wBACH,OAAO,MAAO,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAsB,CAAC;oBACpE,CAAC;oBAAC,OAAO,CAAU,EAAE,CAAC;wBACpB,SAAS,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;wBAC1D,IAAI,OAAO,KAAK,WAAW;4BAAE,MAAM;wBACnC,OAAO,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;wBAE9B,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;4BACrB,MAAM,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;4BAC1D,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,OAAO,CAAC,CAAC;wBACpD,CAAC;oBACH,CAAC;gBACH,CAAC;gBAED,MAAM,SAAS,CAAC;YAClB,CAAC,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function Throttle(ms: number): (value: (this: object, ...args: unknown[]) => unknown, context: ClassMethodDecoratorContext<StatefulComponent>) => void;
|
|
1
|
+
export declare function Throttle(ms: number): (value: (this: object, ...args: unknown[]) => unknown, context: ClassMethodDecoratorContext<import("@praxisjs/core").StatefulComponent>) => void;
|
|
3
2
|
//# sourceMappingURL=throttle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../src/functions/throttle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"throttle.d.ts","sourceRoot":"","sources":["../../src/functions/throttle.ts"],"names":[],"mappings":"AAEA,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,0BAOC,GAAG,uHAMtC"}
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
+
import { createMethodDecorator } from "../create-method-decorator";
|
|
1
2
|
export function Throttle(ms) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const bound = (...args) => {
|
|
3
|
+
return createMethodDecorator({
|
|
4
|
+
wrap(original, instance) {
|
|
5
|
+
const clampedMs = Math.max(0, ms);
|
|
6
|
+
let last = 0;
|
|
7
|
+
return (...args) => {
|
|
8
8
|
const now = Date.now();
|
|
9
|
-
|
|
10
|
-
if (now - last < ms)
|
|
9
|
+
if (now - last < clampedMs)
|
|
11
10
|
return;
|
|
12
|
-
|
|
13
|
-
return
|
|
11
|
+
last = now;
|
|
12
|
+
return original.apply(instance, args);
|
|
14
13
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
configurable: true,
|
|
18
|
-
writable: true,
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
};
|
|
14
|
+
},
|
|
15
|
+
});
|
|
22
16
|
}
|
|
23
17
|
//# sourceMappingURL=throttle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throttle.js","sourceRoot":"","sources":["../../src/functions/throttle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"throttle.js","sourceRoot":"","sources":["../../src/functions/throttle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,UAAU,QAAQ,CAAC,EAAU;IACjC,OAAO,qBAAqB,CAAC;QAC3B,IAAI,CAAC,QAAQ,EAAE,QAAQ;YACrB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAClC,IAAI,IAAI,GAAG,CAAC,CAAC;YACb,OAAO,CAAC,GAAG,IAAe,EAAE,EAAE;gBAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;gBACvB,IAAI,GAAG,GAAG,IAAI,GAAG,SAAS;oBAAE,OAAO;gBACnC,IAAI,GAAG,GAAG,CAAC;gBACX,OAAO,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YACxC,CAAC,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"until.d.ts","sourceRoot":"","sources":["../../src/functions/until.ts"],"names":[],"mappings":"AAMA,wBAAgB,KAAK,CAAC,QAAQ,EAAE,MAAM,0BAGhC,GAAH,uHASF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { until } from "@praxisjs/core/internal";
|
|
2
|
+
import { isComputed } from "@praxisjs/shared/internal";
|
|
3
|
+
import { createMethodDecorator } from "../create-method-decorator";
|
|
4
|
+
export function Until(propName) {
|
|
5
|
+
return createMethodDecorator({
|
|
6
|
+
wrap(_original, instance) {
|
|
7
|
+
return () => {
|
|
8
|
+
const raw = instance[propName];
|
|
9
|
+
const source = isComputed(raw)
|
|
10
|
+
? raw
|
|
11
|
+
: raw;
|
|
12
|
+
return until(source);
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=until.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"until.js","sourceRoot":"","sources":["../../src/functions/until.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,UAAU,KAAK,CAAC,QAAgB;IACpC,OAAO,qBAAqB,CAAC;QAC3B,IAAI,CAAC,SAAS,EAAE,QAAQ;YACtB,OAAO,GAAG,EAAE;gBACV,MAAM,GAAG,GAAI,QAAoC,CAAC,QAAQ,CAAC,CAAC;gBAC5D,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC;oBAC5B,CAAC,CAAE,GAAyB;oBAC5B,CAAC,CAAE,GAAuB,CAAC;gBAC7B,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;YACvB,CAAC,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -14,6 +14,6 @@ export type WatchVal<T extends StatefulComponent, K extends keyof T> = Unwrap<T[
|
|
|
14
14
|
export type WatchVals<T extends StatefulComponent, K extends keyof T> = {
|
|
15
15
|
[P in K]: Unwrap<T[P]>;
|
|
16
16
|
};
|
|
17
|
-
export declare function Watch<T extends StatefulComponent, const Keys extends ReadonlyArray<WatchableKeys<T>>>(...propNames: ValidateKeys<T, Keys>): (value: (this: T, ...args: unknown[]) => void,
|
|
17
|
+
export declare function Watch<T extends StatefulComponent, const Keys extends ReadonlyArray<WatchableKeys<T>>>(...propNames: ValidateKeys<T, Keys>): (value: (this: T, ...args: unknown[]) => void, _context: ClassMethodDecoratorContext<T, (this: T, ...args: any) => any>) => void;
|
|
18
18
|
export {};
|
|
19
19
|
//# sourceMappingURL=watch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/functions/watch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/functions/watch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAKjD,KAAK,iBAAiB,GAAG,MAAM,iBAAiB,CAAC;AAEjD,KAAK,aAAa,CAAC,CAAC,IAAI;KACrB,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CACvD,GAAG,IAAI,EAAE,MAAM,CAAC,KACb,OAAO,GACR,CAAC,SAAS,EAAE,GACV,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,CAAC,OAAO,CAAC,GAC5B,CAAC,GACD,KAAK,GACP,KAAK,GACP,CAAC;CACN,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC,CAAC,GACpC,MAAM,CAAC;AAET,KAAK,YAAY,CACf,IAAI,SAAS,SAAS,MAAM,EAAE,EAC9B,IAAI,SAAS,MAAM,GAAG,KAAK,IACzB,IAAI,SAAS,SAAS;IACxB,MAAM,IAAI,SAAS,MAAM;IACzB,GAAG,MAAM,IAAI,SAAS,MAAM,EAAE;CAC/B,GACG,IAAI,SAAS,IAAI,GACf,CAAC,gBAAgB,IAAI,iBAAiB,EAAE,GAAG,IAAI,CAAC,GAChD,CAAC,IAAI,EAAE,GAAG,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC,GAC5C,IAAI,CAAC;AAET,KAAK,YAAY,CACf,CAAC,SAAS,iBAAiB,EAC3B,IAAI,SAAS,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAC1C,YAAY,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,GAAG,YAAY,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AAE1E,KAAK,MAAM,CAAC,CAAC,IACX,CAAC,SAAS,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,MAAM,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEpE,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,iBAAiB,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,MAAM,CAC3E,CAAC,CAAC,CAAC,CAAC,CACL,CAAC;AACF,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,iBAAiB,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI;KACrE,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACvB,CAAC;AAOF,wBAAgB,KAAK,CACnB,CAAC,SAAS,iBAAiB,EAC3B,KAAK,CAAC,IAAI,SAAS,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAClD,GAAG,SAAS,EAAE,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,oIA8BpC"}
|
package/dist/functions/watch.js
CHANGED
|
@@ -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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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;
|
|
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;AAEvD,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AA4CtF,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,MAAM,KAAK,GAAG,SAAgC,CAAC;IAE/C,OAAO,8BAA8B,CAAI;QACvC,QAAQ,CAAC,QAAQ,EAAE,QAAQ;YACzB,MAAM,IAAI,GAAG,QAAuC,CAAC;YAErD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACvB,IAAI,MAAM,GAAG,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBACvC,OAAO,MAAM,CAAC,GAAG,EAAE;oBACjB,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;oBACzC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;wBAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;wBACzB,MAAM,GAAG,MAAM,CAAC;oBAClB,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;YAED,MAAM,IAAI,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"}
|
package/dist/functions/when.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
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":"
|
|
1
|
+
{"version":3,"file":"when.d.ts","sourceRoot":"","sources":["../../src/functions/when.ts"],"names":[],"mappings":"AAMA,wBAAgB,IAAI,CAAC,QAAQ,EAAE,MAAM,+PAUpC"}
|
package/dist/functions/when.js
CHANGED
|
@@ -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
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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":"
|
|
1
|
+
{"version":3,"file":"when.js","sourceRoot":"","sources":["../../src/functions/when.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AAEtF,MAAM,UAAU,IAAI,CAAC,QAAgB;IACnC,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
|
-
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";
|
|
2
|
+
export { Memo, Bind, Log, Once, Retry, Debounce, Throttle, When, Until, Watch, type WatchVal, type WatchVals, } from "./functions";
|
|
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
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,GAAG,EACH,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,KAAK,QAAQ,EACb,KAAK,SAAS,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,SAAS,EACT,OAAO,EACP,KAAK,WAAW,
|
|
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,GAAG,EACH,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,KAAK,EACL,KAAK,QAAQ,EACb,KAAK,SAAS,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,SAAS,EACT,OAAO,EACP,KAAK,WAAW,EAChB,OAAO,EACP,QAAQ,EACR,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,EACL,oBAAoB,EACpB,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,KAAK,gBAAgB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,qBAAqB,EACrB,KAAK,cAAc,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,8BAA8B,EAC9B,KAAK,uBAAuB,GAC7B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,qBAAqB,EACrB,KAAK,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
|
-
export { Memo, Bind, Log, Once, Retry, Debounce, Throttle, When, Watch, } from "./functions";
|
|
3
|
-
export { Prop, State, Computed, Persisted, Slot, initSlots, History, } from "./properties";
|
|
2
|
+
export { Memo, Bind, Log, Once, Retry, Debounce, Throttle, When, Until, Watch, } from "./functions";
|
|
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,
|
|
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,EACL,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
|
-
|
|
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":"
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
let c =
|
|
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(() =>
|
|
9
|
-
|
|
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":"
|
|
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;
|
|
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
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
32
|
-
|
|
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;
|
|
1
|
+
{"version":3,"file":"history.js","sourceRoot":"","sources":["../../src/properties/history.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAOjE,MAAM,UAAU,OAAO,CAAC,KAAK,GAAG,EAAE;IAChC,OAAO,oBAAoB,CAAC;QAC1B,IAAI,CAAC,QAA2B,EAAE,IAAY,EAAE,aAAsB;YACpE,MAAM,UAAU,GAAG,GAAG,IAAI,SAAS,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"}
|
package/dist/properties/index.js
CHANGED
|
@@ -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
|