@praxisjs/concurrent 0.2.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,54 @@
1
1
  # @praxisjs/concurrent
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 3372878: Migrate all packages from functional APIs to a decorator-first design.
8
+
9
+ **`@praxisjs/core`**
10
+
11
+ - Added `Composable` abstract base class for building class-based composables
12
+ - Removed `resource`, `createResource`, `Resource`, `ResourceStatus`, `ResourceOptions` from public exports — use `@Resource` from `@praxisjs/decorators` instead
13
+
14
+ **`@praxisjs/motion`**
15
+
16
+ - Replaced `useMotion`, `tween`, `spring`, `createTransition`, `Animate`, `easings`, `resolveEasing` with `@Tween` and `@Spring` decorators
17
+
18
+ **`@praxisjs/di`**
19
+
20
+ - Replaced `useService` and `createScope` with a `@Scope` decorator
21
+ - Renamed exported type `Scope` to `ScopeType` to free the name for the new decorator
22
+
23
+ **`@praxisjs/fsm`**
24
+
25
+ - Removed `createMachine` — use the `@StateMachine` and `@Transition` decorators directly
26
+
27
+ **`@praxisjs/router`**
28
+
29
+ - Removed `createRouter`, `lazy`, `useRouter`, `useParams`, `useQuery`, `useLocation`
30
+ - Added `@RouterConfig`, `@Lazy`, `@InjectRouter`, `@Params`, `@Query`, `@Location` decorators
31
+
32
+ **`@praxisjs/store`**
33
+
34
+ - Removed `createStore` — use the `@Store` and `@UseStore` decorators directly
35
+
36
+ **`@praxisjs/composables`**
37
+
38
+ - Replaced all `use*` composable functions with class-based composables extending `Composable`:
39
+ `WindowSize`, `ScrollPosition`, `ElementSize`, `Intersection`, `Focus`, `MediaQuery`, `ColorScheme`, `Mouse`, `KeyCombo`, `Idle`, `Clipboard`, `Geolocation`, `TimeAgo`, `Pagination`
40
+
41
+ **`@praxisjs/concurrent`**
42
+
43
+ - Removed `task`, `queue`, `pool` and their instance types — use `@Task`, `@Queue`, `@Pool` decorators instead
44
+
45
+ ### Patch Changes
46
+
47
+ - Updated dependencies [3372878]
48
+ - Updated dependencies [feaa478]
49
+ - @praxisjs/core@1.0.0
50
+ - @praxisjs/decorators@0.5.0
51
+
3
52
  ## 0.2.3
4
53
 
5
54
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- export declare function Task(): (value: (...args: unknown[]) => Promise<unknown>, context: ClassMethodDecoratorContext) => void;
2
- export declare function Queue(): (value: (...args: unknown[]) => Promise<unknown>, context: ClassMethodDecoratorContext) => void;
3
- export declare function Pool(concurrency: number): (value: (...args: unknown[]) => Promise<unknown>, context: ClassMethodDecoratorContext) => void;
1
+ export declare function Task(): (value: (...args: unknown[]) => Promise<unknown>, context: ClassMethodDecoratorContext<any>) => void;
2
+ export declare function Queue(): (value: (...args: unknown[]) => Promise<unknown>, context: ClassMethodDecoratorContext<any>) => void;
3
+ export declare function Pool(concurrency: number): (value: (...args: unknown[]) => Promise<unknown>, context: ClassMethodDecoratorContext<any>) => void;
4
4
  //# sourceMappingURL=decorators.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAIA,wBAAgB,IAAI,KAEhB,OAAO,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,EAC/C,SAAS,2BAA2B,KACnC,IAAI,CAYR;AAED,wBAAgB,KAAK,KAEjB,OAAO,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,EAC/C,SAAS,2BAA2B,KACnC,IAAI,CAYR;AAED,wBAAgB,IAAI,CAAC,WAAW,EAAE,MAAM,IAEpC,OAAO,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,EAC/C,SAAS,2BAA2B,KACnC,IAAI,CAaR"}
1
+ {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAMA,wBAAgB,IAAI,IAYD,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,2BAA2B,CAAC,GAAG,CAAC,KAAK,IAAI,CACtH;AAED,wBAAgB,KAAK,IAWF,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,2BAA2B,CAAC,GAAG,CAAC,KAAK,IAAI,CACtH;AAED,wBAAgB,IAAI,CAAC,WAAW,EAAE,MAAM,GAYrB,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,2BAA2B,CAAC,GAAG,CAAC,KAAK,IAAI,CACtH"}
@@ -1,44 +1,46 @@
1
+ import { createMethodDecorator } from "@praxisjs/decorators";
1
2
  import { pool } from "./pool";
2
3
  import { queue } from "./queue";
3
4
  import { task } from "./task";
4
5
  export function Task() {
5
- return function (value, context) {
6
- const methodKey = String(context.name);
7
- context.addInitializer(function () {
8
- const self = this;
9
- const t = task(value.bind(this));
10
- self[`${methodKey}_loading`] = t.loading;
11
- self[`${methodKey}_error`] = t.error;
12
- self[`${methodKey}_lastResult`] = t.lastResult;
13
- self[methodKey] = (...args) => t(...args);
14
- });
15
- };
6
+ return createMethodDecorator({
7
+ wrap(original, instance, name) {
8
+ const self = instance;
9
+ const t = task(original.bind(instance));
10
+ self[`${name}_loading`] = t.loading;
11
+ self[`${name}_error`] = t.error;
12
+ self[`${name}_lastResult`] = t.lastResult;
13
+ return (...args) => t(...args);
14
+ },
15
+ // Concurrent decorators work on any class, not just StatefulComponent
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ });
16
18
  }
17
19
  export function Queue() {
18
- return function (value, context) {
19
- const methodKey = String(context.name);
20
- context.addInitializer(function () {
21
- const self = this;
22
- const q = queue(value.bind(this));
23
- self[`${methodKey}_loading`] = q.loading;
24
- self[`${methodKey}_pending`] = q.pending;
25
- self[`${methodKey}_error`] = q.error;
26
- self[methodKey] = (...args) => q(...args);
27
- });
28
- };
20
+ return createMethodDecorator({
21
+ wrap(original, instance, name) {
22
+ const self = instance;
23
+ const q = queue(original.bind(instance));
24
+ self[`${name}_loading`] = q.loading;
25
+ self[`${name}_pending`] = q.pending;
26
+ self[`${name}_error`] = q.error;
27
+ return (...args) => q(...args);
28
+ },
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ });
29
31
  }
30
32
  export function Pool(concurrency) {
31
- return function (value, context) {
32
- const methodKey = String(context.name);
33
- context.addInitializer(function () {
34
- const self = this;
35
- const p = pool(concurrency, value.bind(this));
36
- self[`${methodKey}_loading`] = p.loading;
37
- self[`${methodKey}_active`] = p.active;
38
- self[`${methodKey}_pending`] = p.pending;
39
- self[`${methodKey}_error`] = p.error;
40
- self[methodKey] = (...args) => p(...args);
41
- });
42
- };
33
+ return createMethodDecorator({
34
+ wrap(original, instance, name) {
35
+ const self = instance;
36
+ const p = pool(concurrency, original.bind(instance));
37
+ self[`${name}_loading`] = p.loading;
38
+ self[`${name}_active`] = p.active;
39
+ self[`${name}_pending`] = p.pending;
40
+ self[`${name}_error`] = p.error;
41
+ return (...args) => p(...args);
42
+ },
43
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
+ });
43
45
  }
44
46
  //# sourceMappingURL=decorators.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,UAAU,IAAI;IAClB,OAAO,UACL,KAA+C,EAC/C,OAA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D,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YACnG,IAAI,CAAC,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;YACpC,IAAI,CAAC,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;YAClC,IAAI,CAAC,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC;YACpC,IAAI,CAAC,GAAG,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;YAChC,OAAO,CAAC,GAAG,IAAe,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;QAC5C,CAAC;QACH,8DAA8D;KAC7D,CAAoH,CAAC;AACxH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,8 +1,2 @@
1
- export { task } from "./task";
2
- export type { TaskInstance } from "./task";
3
- export { queue } from "./queue";
4
- export type { QueueInstance } from "./queue";
5
- export { pool } from "./pool";
6
- export type { PoolInstance } from "./pool";
7
1
  export { Task, Queue, Pool } from "./decorators";
8
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE3C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE3C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,2 @@
1
- export { task } from "./task";
2
- export { queue } from "./queue";
3
- export { pool } from "./pool";
4
1
  export { Task, Queue, Pool } from "./decorators";
5
2
  //# 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,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@praxisjs/concurrent",
3
- "version": "0.2.3",
3
+ "version": "1.0.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -14,8 +14,9 @@
14
14
  "typescript": "^5.9.3"
15
15
  },
16
16
  "dependencies": {
17
- "@praxisjs/core": "0.4.2",
18
- "@praxisjs/shared": "0.2.0"
17
+ "@praxisjs/decorators": "0.5.0",
18
+ "@praxisjs/shared": "0.2.0",
19
+ "@praxisjs/core": "1.0.0"
19
20
  },
20
21
  "scripts": {
21
22
  "build": "tsc",
package/src/decorators.ts CHANGED
@@ -1,58 +1,49 @@
1
+ import { createMethodDecorator } from "@praxisjs/decorators";
2
+
1
3
  import { pool } from "./pool";
2
4
  import { queue } from "./queue";
3
5
  import { task } from "./task";
4
6
 
5
7
  export function Task() {
6
- return function (
7
- value: (...args: unknown[]) => Promise<unknown>,
8
- context: ClassMethodDecoratorContext,
9
- ): void {
10
- const methodKey = String(context.name);
11
-
12
- context.addInitializer(function (this: unknown) {
13
- const self = this as Record<string, unknown>;
14
- const t = task(value.bind(this));
15
- self[`${methodKey}_loading`] = t.loading;
16
- self[`${methodKey}_error`] = t.error;
17
- self[`${methodKey}_lastResult`] = t.lastResult;
18
- self[methodKey] = (...args: unknown[]) => t(...args);
19
- });
20
- };
8
+ return createMethodDecorator({
9
+ wrap(original, instance, name) {
10
+ const self = instance as Record<string, unknown>;
11
+ const t = task((original as (...args: unknown[]) => Promise<unknown>).bind(instance));
12
+ self[`${name}_loading`] = t.loading;
13
+ self[`${name}_error`] = t.error;
14
+ self[`${name}_lastResult`] = t.lastResult;
15
+ return (...args: unknown[]) => t(...args);
16
+ },
17
+ // Concurrent decorators work on any class, not just StatefulComponent
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ }) as unknown as (value: (...args: unknown[]) => Promise<unknown>, context: ClassMethodDecoratorContext<any>) => void;
21
20
  }
22
21
 
23
22
  export function Queue() {
24
- return function (
25
- value: (...args: unknown[]) => Promise<unknown>,
26
- context: ClassMethodDecoratorContext,
27
- ): void {
28
- const methodKey = String(context.name);
29
-
30
- context.addInitializer(function (this: unknown) {
31
- const self = this as Record<string, unknown>;
32
- const q = queue(value.bind(this));
33
- self[`${methodKey}_loading`] = q.loading;
34
- self[`${methodKey}_pending`] = q.pending;
35
- self[`${methodKey}_error`] = q.error;
36
- self[methodKey] = (...args: unknown[]) => q(...args);
37
- });
38
- };
23
+ return createMethodDecorator({
24
+ wrap(original, instance, name) {
25
+ const self = instance as Record<string, unknown>;
26
+ const q = queue((original as (...args: unknown[]) => Promise<unknown>).bind(instance));
27
+ self[`${name}_loading`] = q.loading;
28
+ self[`${name}_pending`] = q.pending;
29
+ self[`${name}_error`] = q.error;
30
+ return (...args: unknown[]) => q(...args);
31
+ },
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
+ }) as unknown as (value: (...args: unknown[]) => Promise<unknown>, context: ClassMethodDecoratorContext<any>) => void;
39
34
  }
40
35
 
41
36
  export function Pool(concurrency: number) {
42
- return function (
43
- value: (...args: unknown[]) => Promise<unknown>,
44
- context: ClassMethodDecoratorContext,
45
- ): void {
46
- const methodKey = String(context.name);
47
-
48
- context.addInitializer(function (this: unknown) {
49
- const self = this as Record<string, unknown>;
50
- const p = pool(concurrency, value.bind(this));
51
- self[`${methodKey}_loading`] = p.loading;
52
- self[`${methodKey}_active`] = p.active;
53
- self[`${methodKey}_pending`] = p.pending;
54
- self[`${methodKey}_error`] = p.error;
55
- self[methodKey] = (...args: unknown[]) => p(...args);
56
- });
57
- };
37
+ return createMethodDecorator({
38
+ wrap(original, instance, name) {
39
+ const self = instance as Record<string, unknown>;
40
+ const p = pool(concurrency, (original as (...args: unknown[]) => Promise<unknown>).bind(instance));
41
+ self[`${name}_loading`] = p.loading;
42
+ self[`${name}_active`] = p.active;
43
+ self[`${name}_pending`] = p.pending;
44
+ self[`${name}_error`] = p.error;
45
+ return (...args: unknown[]) => p(...args);
46
+ },
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+ }) as unknown as (value: (...args: unknown[]) => Promise<unknown>, context: ClassMethodDecoratorContext<any>) => void;
58
49
  }
package/src/index.ts CHANGED
@@ -1,10 +1 @@
1
- export { task } from "./task";
2
- export type { TaskInstance } from "./task";
3
-
4
- export { queue } from "./queue";
5
- export type { QueueInstance } from "./queue";
6
-
7
- export { pool } from "./pool";
8
- export type { PoolInstance } from "./pool";
9
-
10
1
  export { Task, Queue, Pool } from "./decorators";