@bemedev/app-bemedev-plugins 0.0.1 → 3.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/README.md +2 -2
- package/lib/plugin.d.ts +3 -3
- package/lib/plugin.js +3 -3
- package/lib/plugin.js.map +1 -1
- package/lib/swap.d.ts +2 -0
- package/lib/swap.d.ts.map +1 -1
- package/lib/swap.js +3 -1
- package/lib/swap.js.map +1 -1
- package/package.json +4 -7
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ other location accepting a selector.
|
|
|
20
20
|
|
|
21
21
|
```ts
|
|
22
22
|
import { createOptions } from '@bemedev/app-options';
|
|
23
|
-
import { swapPlugin } from '@bemedev/app-bemedev-plugins';
|
|
23
|
+
import { plugin as swapPlugin } from '@bemedev/app-bemedev-plugins';
|
|
24
24
|
|
|
25
25
|
const options = createOptions(contract).use(swapPlugin)(({ swap, assign }) => ({
|
|
26
26
|
actions: {
|
|
@@ -39,7 +39,7 @@ On a machine, attach the plugin through its types:
|
|
|
39
39
|
|
|
40
40
|
```ts
|
|
41
41
|
import { createMachine } from '@bemedev/app';
|
|
42
|
-
import { swapPlugin } from '@bemedev/app-bemedev-plugins';
|
|
42
|
+
import { plugin as swapPlugin } from '@bemedev/app-bemedev-plugins';
|
|
43
43
|
|
|
44
44
|
const machine = createMachine(
|
|
45
45
|
config,
|
package/lib/plugin.d.ts
CHANGED
|
@@ -3,15 +3,15 @@ import { Swap_F } from "./swap.js";
|
|
|
3
3
|
* Options plugin adding the `swap` helper to the options surface.
|
|
4
4
|
*
|
|
5
5
|
* The helper left the default helpers, so it is opted in through the plugin
|
|
6
|
-
* system, either with `createOptions(contract).use(
|
|
6
|
+
* system, either with `createOptions(contract).use(plugin)` or with the
|
|
7
7
|
* `plugins` entry of the machine types.
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```ts
|
|
11
11
|
* import { createOptions } from '@bemedev/app-options';
|
|
12
|
-
* import {
|
|
12
|
+
* import { plugin } from '@bemedev/app-bemedev-plugins';
|
|
13
13
|
*
|
|
14
|
-
* const options = createOptions(contract).use(
|
|
14
|
+
* const options = createOptions(contract).use(plugin)(({ swap }) => ({
|
|
15
15
|
* actions: {
|
|
16
16
|
* increment: swap((value: number) => value + 1)({
|
|
17
17
|
* '[0]': '[0].context',
|
package/lib/plugin.js
CHANGED
|
@@ -5,15 +5,15 @@ import { createUtilities, same } from "@bemedev/app-plugins";
|
|
|
5
5
|
* Options plugin adding the `swap` helper to the options surface.
|
|
6
6
|
*
|
|
7
7
|
* The helper left the default helpers, so it is opted in through the plugin
|
|
8
|
-
* system, either with `createOptions(contract).use(
|
|
8
|
+
* system, either with `createOptions(contract).use(plugin)` or with the
|
|
9
9
|
* `plugins` entry of the machine types.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* ```ts
|
|
13
13
|
* import { createOptions } from '@bemedev/app-options';
|
|
14
|
-
* import {
|
|
14
|
+
* import { plugin } from '@bemedev/app-bemedev-plugins';
|
|
15
15
|
*
|
|
16
|
-
* const options = createOptions(contract).use(
|
|
16
|
+
* const options = createOptions(contract).use(plugin)(({ swap }) => ({
|
|
17
17
|
* actions: {
|
|
18
18
|
* increment: swap((value: number) => value + 1)({
|
|
19
19
|
* '[0]': '[0].context',
|
package/lib/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import { createUtilities, same } from '@bemedev/app-plugins';\nimport { swap } from './swap';\nexport type { Swap_F } from './swap';\n\n/**\n * Options plugin adding the `swap` helper to the options surface.\n *\n * The helper left the default helpers, so it is opted in through the plugin\n * system, either with `createOptions(contract).use(
|
|
1
|
+
{"version":3,"file":"plugin.js","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import { createUtilities, same } from '@bemedev/app-plugins';\nimport { swap } from './swap';\nexport type { Swap_F } from './swap';\n\n/**\n * Options plugin adding the `swap` helper to the options surface.\n *\n * The helper left the default helpers, so it is opted in through the plugin\n * system, either with `createOptions(contract).use(plugin)` or with the\n * `plugins` entry of the machine types.\n *\n * @example\n * ```ts\n * import { createOptions } from '@bemedev/app-options';\n * import { plugin } from '@bemedev/app-bemedev-plugins';\n *\n * const options = createOptions(contract).use(plugin)(({ swap }) => ({\n * actions: {\n * increment: swap((value: number) => value + 1)({\n * '[0]': '[0].context',\n * }),\n * },\n * }));\n * ```\n */\nexport const plugin = createUtilities({}, () => ({ swap: same(swap) }));\n\n/** Type of the plugin returned by {@linkcode plugin}. */\nexport type Plugin = typeof plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,SAAS,gBAAgB,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,EAAE,EAAE"}
|
package/lib/swap.d.ts
CHANGED
package/lib/swap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swap.d.ts","names":[],"sources":["../src/swap.ts"],"mappings":";;;;;;;;;;;;;;YAiBY,OAAO,WAAW,WAAW,aACvC,cAAc,qBACd,4BAEA,IAAI,GACJ,QAAQ,QACJ,eAAe,IAAI,IAAI,WAAW
|
|
1
|
+
{"version":3,"file":"swap.d.ts","names":[],"sources":["../src/swap.ts"],"mappings":";;;;;;;;;;;;;;YAiBY,OAAO,WAAW,WAAW,aACvC,cAAc,qBACd,4BAEA,IAAI,GACJ,QAAQ,QACJ,eAAe,IAAI,IAAI,WAAW;;;;;;;;;;;;;;;;;;;;;;;;qBAyB3B,MAAM"}
|
package/lib/swap.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { swap as swap$1 } from "@bemedev/function-swap";
|
|
2
1
|
import { reduceFnMap } from "@bemedev/app-plugins/internal";
|
|
2
|
+
import { swap as swap$1 } from "@bemedev/function-swap";
|
|
3
3
|
// src/swap.ts
|
|
4
4
|
/**
|
|
5
5
|
* Remaps the arguments of a function from decomposed state paths.
|
|
@@ -21,6 +21,8 @@ import { reduceFnMap } from "@bemedev/app-plugins/internal";
|
|
|
21
21
|
* '[0]': '[0].context',
|
|
22
22
|
* });
|
|
23
23
|
* ```
|
|
24
|
+
*
|
|
25
|
+
* @see -- type {@linkcode Swap_F}
|
|
24
26
|
*/
|
|
25
27
|
const swap = (fn, event) => (types) => {
|
|
26
28
|
const swapped = swap$1(fn).constraint()(types);
|
package/lib/swap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swap.js","names":["_swap"],"sources":["../src/swap.ts"],"sourcesContent":["import type { Contract, FnR } from '@bemedev/app-contract';\nimport {
|
|
1
|
+
{"version":3,"file":"swap.js","names":["_swap"],"sources":["../src/swap.ts"],"sourcesContent":["import type { Contract, FnR } from '@bemedev/app-contract';\nimport { reduceFnMap } from '@bemedev/app-plugins/internal';\nimport { swap as _swap } from '@bemedev/function-swap';\n\n/**\n * Signature of the {@linkcode swap} helper.\n *\n * The mapping keys are passed as decomposed paths, so the returned function\n * stays a standard machine selector of type {@linkcode FnR}.\n *\n * @remarks\n * The plugin surface is not parameterized by the consumer contract, so the\n * mapping keys are untyped. Annotate a value with `Swap<MyContract>` to keep\n * the returned selector typed against a specific contract.\n *\n * @template | {@linkcode Contract} `Ct` - Contract of the machine.\n */\nexport type Swap_F<Ct extends Contract = Contract> = <\n F extends (...args: any[]) => any,\n Ev extends string = string,\n>(\n fn: F,\n event?: Ev,\n) => (types: any) => FnR<Ct, ReturnType<F>>;\n\n/**\n * Remaps the arguments of a function from decomposed state paths.\n *\n * Unlike the former default helper, this function does not need the machine\n * contract: an event name scopes the swap to that event, and any other event\n * falls back to the no-op value.\n *\n * @param fn - Function to swap.\n * @param event - Optional event name scoping the swap.\n *\n * @returns A function mapping decomposed paths to the swapped function.\n *\n * @example\n * ```ts\n * import { swap } from '@bemedev/app-bemedev-plugins';\n *\n * const inc = swap((value: number) => value + 1)({\n * '[0]': '[0].context',\n * });\n * ```\n *\n * @see -- type {@linkcode Swap_F}\n */\nexport const swap: Swap_F = (fn, event) => types => {\n const swapped = _swap(fn).constraint()(types);\n return event ? reduceFnMap({ [event]: swapped }, event) : swapped;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAa,QAAgB,IAAI,WAAU,UAAS;CAClD,MAAM,UAAUA,OAAM,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,KAAK;CAC5C,OAAO,QAAQ,YAAY,GAAG,QAAQ,QAAQ,GAAG,KAAK,IAAI;AAC5D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemedev/app-bemedev-plugins",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Optional composable utilities for @bemedev/app, delivered as options plugins",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"state machines",
|
|
@@ -44,12 +44,10 @@
|
|
|
44
44
|
"exports": {
|
|
45
45
|
".": {
|
|
46
46
|
"import": "./lib/index.js",
|
|
47
|
-
"require": "./lib/index.cjs",
|
|
48
47
|
"types": "./lib/index.d.ts"
|
|
49
48
|
},
|
|
50
49
|
"./swap": {
|
|
51
50
|
"import": "./lib/swap.js",
|
|
52
|
-
"require": "./lib/swap.cjs",
|
|
53
51
|
"types": "./lib/swap.d.ts"
|
|
54
52
|
}
|
|
55
53
|
},
|
|
@@ -57,19 +55,18 @@
|
|
|
57
55
|
"access": "public"
|
|
58
56
|
},
|
|
59
57
|
"dependencies": {
|
|
60
|
-
"@bemedev/app-plugins": "^
|
|
58
|
+
"@bemedev/app-plugins": "^3.3.0",
|
|
61
59
|
"@bemedev/function-swap": "^0.2.5"
|
|
62
60
|
},
|
|
63
61
|
"peerDependencies": {
|
|
64
|
-
"@bemedev/app-utils-bemedev": "^0.2.0",
|
|
65
62
|
"@bemedev/typings": "^1.5.0",
|
|
66
|
-
"@bemedev/app-contract": "^3.
|
|
63
|
+
"@bemedev/app-contract": "^3.3.0",
|
|
67
64
|
"@bemedev/decompose": "^2.3.0"
|
|
68
65
|
},
|
|
69
66
|
"devDependencies": {
|
|
70
67
|
"@bemedev/dev-utils": "^1.6.2",
|
|
71
68
|
"@size-limit/file": "^14.3.0",
|
|
72
|
-
"@types/node": "^26.6.
|
|
69
|
+
"@types/node": "^26.6.10",
|
|
73
70
|
"@vitest/coverage-v8": "5.1.1",
|
|
74
71
|
"pretty-quick": "^4.2.2",
|
|
75
72
|
"rimraf": "^6.1.4",
|