@cascateer/core 2.3.50 → 2.3.55
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/.github/workflows/publish.yml +3 -27
- package/package.json +1 -1
- package/src/component.ts +5 -5
- package/src/lib/index.ts +1 -1
- package/src/observable/index.ts +0 -1
- package/src/operators/multicast.ts +2 -2
- package/src/{observable → signal}/Signal.test.ts +3 -4
- package/src/{observable → signal}/Signal.ts +27 -39
- package/src/signal/index.ts +10 -0
- package/src/slice.ts +1 -1
- package/src/store.ts +3 -3
- package/src/terminal.ts +1 -1
- package/src/types.ts +0 -2
|
@@ -6,30 +6,6 @@ on:
|
|
|
6
6
|
- "v*"
|
|
7
7
|
|
|
8
8
|
jobs:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
contents: write
|
|
13
|
-
id-token: write
|
|
14
|
-
|
|
15
|
-
steps:
|
|
16
|
-
- uses: actions/checkout@v6
|
|
17
|
-
- uses: actions/setup-node@v6
|
|
18
|
-
with:
|
|
19
|
-
node-version: "24"
|
|
20
|
-
registry-url: "https://registry.npmjs.org"
|
|
21
|
-
|
|
22
|
-
- name: Verify version matches tag
|
|
23
|
-
run: |
|
|
24
|
-
TAG="${GITHUB_REF#refs/tags/}"
|
|
25
|
-
VERSION="${TAG#v}"
|
|
26
|
-
FILE_VERSION=$(node -p "require('./package.json').version")
|
|
27
|
-
if [ "$VERSION" != "$FILE_VERSION" ]; then
|
|
28
|
-
echo "Version mismatch: tag=$VERSION, package.json=$FILE_VERSION"
|
|
29
|
-
exit 1
|
|
30
|
-
fi
|
|
31
|
-
|
|
32
|
-
- name: Publish to NPM
|
|
33
|
-
env:
|
|
34
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
35
|
-
run: npm publish --access public --provenance
|
|
9
|
+
call-workflow:
|
|
10
|
+
uses: cascateer/lib/.github/workflows/publish.yml@main
|
|
11
|
+
secrets: inherit
|
package/package.json
CHANGED
package/src/component.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { ApiAdapter, ApiEffect } from "./api";
|
|
|
5
5
|
import { cssStyleSheets } from "./css";
|
|
6
6
|
import { defineCustomElement } from "./dom";
|
|
7
7
|
import { ExtendableDictionary } from "./lib";
|
|
8
|
-
import { ComputedSignal } from "./
|
|
8
|
+
import { ComputedSignal } from "./signal";
|
|
9
9
|
import { asStoreEffects, StoreAdapter, StoreEffects } from "./store";
|
|
10
10
|
import { TerminalAdapter, TerminalEffect } from "./terminal";
|
|
11
11
|
import { Action, Effect } from "./types";
|
|
@@ -18,23 +18,23 @@ export function createComponent(customElement?: string) {
|
|
|
18
18
|
const withTemplate =
|
|
19
19
|
<Styles extends Promise<unknown>[]>(...styles: Styles) =>
|
|
20
20
|
<
|
|
21
|
-
|
|
21
|
+
Context extends Dictionary<Effect<any, any> | Action<any, any>>,
|
|
22
22
|
Props extends JSX.Props,
|
|
23
23
|
>(
|
|
24
24
|
constructor: (
|
|
25
|
-
|
|
25
|
+
ctx: Context,
|
|
26
26
|
...classNamesList: { -readonly [K in keyof Styles]: Awaited<Styles[K]> }
|
|
27
27
|
) => JSX.Component<Props>,
|
|
28
28
|
) =>
|
|
29
29
|
class extends ComponentConstructor<Props> {
|
|
30
|
-
constructor(
|
|
30
|
+
constructor(ctx: Context) {
|
|
31
31
|
super(
|
|
32
32
|
(key) => (props) =>
|
|
33
33
|
createFragment({
|
|
34
34
|
children: defer(() =>
|
|
35
35
|
Promise.all(styles).then((cssModules) =>
|
|
36
36
|
cssStyleSheets(cssModules).then(async (cssStyleSheets) => {
|
|
37
|
-
const element = constructor(
|
|
37
|
+
const element = constructor(ctx, ...cssModules)(props);
|
|
38
38
|
|
|
39
39
|
return customElement != null
|
|
40
40
|
? new (defineCustomElement(
|
package/src/lib/index.ts
CHANGED
package/src/observable/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { concatMap, shareReplay, startWith, UnaryFunction } from "rxjs";
|
|
2
2
|
import { v4 } from "uuid";
|
|
3
|
-
import {
|
|
4
|
-
import { Transform } from "../
|
|
3
|
+
import { ProxySubject } from "../observable";
|
|
4
|
+
import { ComputedSignal, Transform } from "../signal";
|
|
5
5
|
import { exchangeWith } from "./exchangeWith";
|
|
6
6
|
import { proxyReplaySubject } from "./proxyReplaySubject";
|
|
7
7
|
|
|
@@ -8,8 +8,7 @@ import {
|
|
|
8
8
|
toArray,
|
|
9
9
|
} from "rxjs";
|
|
10
10
|
import { expect, test } from "vitest";
|
|
11
|
-
import { Transform } from "
|
|
12
|
-
import { ComputedSignal } from "./Signal";
|
|
11
|
+
import { ComputedSignal, Transform } from ".";
|
|
13
12
|
|
|
14
13
|
test("projection", () => {
|
|
15
14
|
const signal = new ComputedSignal({
|
|
@@ -30,8 +29,8 @@ test("transformation", () => {
|
|
|
30
29
|
),
|
|
31
30
|
}).property("number");
|
|
32
31
|
|
|
33
|
-
transforms.next(signal.
|
|
34
|
-
transforms.next(signal.
|
|
32
|
+
transforms.next(signal.pull((number) => number + 1));
|
|
33
|
+
transforms.next(signal.pull((number) => number + 2));
|
|
35
34
|
transforms.complete();
|
|
36
35
|
|
|
37
36
|
return lastValueFrom(signal.pipe(toArray())).then((numbers) =>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { clone, identity, isEqual, memoize } from "lodash";
|
|
2
2
|
import { distinctUntilChanged, map, Observable, UnaryFunction } from "rxjs";
|
|
3
|
-
import { ProxyObservable } from ".";
|
|
4
3
|
import {
|
|
5
4
|
asEnumerable,
|
|
6
5
|
EnumerableItem,
|
|
@@ -9,27 +8,16 @@ import {
|
|
|
9
8
|
nthArg,
|
|
10
9
|
property,
|
|
11
10
|
} from "../lib";
|
|
12
|
-
import {
|
|
11
|
+
import { ProxyObservable } from "../observable";
|
|
12
|
+
import { TransformOperator } from "../signal";
|
|
13
13
|
|
|
14
14
|
class SignalEnumerator<T> {
|
|
15
|
-
constructor(private
|
|
15
|
+
constructor(private predicate: Enumerator<T> = nthArg(1)) {}
|
|
16
16
|
|
|
17
17
|
findIndex = (key: PropertyKey) => (value: T) =>
|
|
18
|
-
asEnumerable(value).map(this.
|
|
18
|
+
asEnumerable(value).map(this.predicate).indexOf(key);
|
|
19
19
|
|
|
20
|
-
enumerate = (value: T) => asEnumerable(value).map(this.
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
class SignalAdapter<T> {
|
|
24
|
-
constructor(
|
|
25
|
-
public lift: (transform: Transform<T>) => Transform<unknown> = identity,
|
|
26
|
-
) {}
|
|
27
|
-
|
|
28
|
-
connect<U>(
|
|
29
|
-
connector: UnaryFunction<Transform<U>, Transform<T>>,
|
|
30
|
-
): SignalAdapter<U> {
|
|
31
|
-
return new SignalAdapter((transform) => this.lift(connector(transform)));
|
|
32
|
-
}
|
|
20
|
+
enumerate = (value: T) => asEnumerable(value).map(this.predicate);
|
|
33
21
|
}
|
|
34
22
|
|
|
35
23
|
export class Signal<T> extends ProxyObservable<T> {
|
|
@@ -42,42 +30,42 @@ export class Signal<T> extends ProxyObservable<T> {
|
|
|
42
30
|
}
|
|
43
31
|
|
|
44
32
|
enumerator: SignalEnumerator<T>;
|
|
45
|
-
|
|
33
|
+
pull: TransformOperator<T, unknown>;
|
|
46
34
|
|
|
47
35
|
constructor({
|
|
48
36
|
value,
|
|
49
37
|
enumerator = new SignalEnumerator(),
|
|
50
|
-
|
|
38
|
+
pull = identity,
|
|
51
39
|
}: {
|
|
52
40
|
value: Observable<T>;
|
|
53
41
|
enumerator?: SignalEnumerator<T>;
|
|
54
|
-
|
|
42
|
+
pull?: TransformOperator<T, unknown>;
|
|
55
43
|
}) {
|
|
56
44
|
super(value);
|
|
57
45
|
|
|
58
46
|
this.enumerator = enumerator;
|
|
59
|
-
this.
|
|
47
|
+
this.pull = pull;
|
|
60
48
|
}
|
|
61
49
|
|
|
62
|
-
private
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
50
|
+
private map<U>(
|
|
51
|
+
project: UnaryFunction<T, U>,
|
|
52
|
+
lift: TransformOperator<U, T>,
|
|
53
|
+
enumerate?: Enumerator<U>,
|
|
66
54
|
): Signal<U> {
|
|
67
55
|
return new Signal({
|
|
68
|
-
value: this.pipe(map(
|
|
69
|
-
enumerator: new SignalEnumerator(
|
|
70
|
-
|
|
56
|
+
value: this.pipe(map(project), distinctUntilChanged()),
|
|
57
|
+
enumerator: new SignalEnumerator(enumerate),
|
|
58
|
+
pull: (transform) => this.pull(lift(transform)),
|
|
71
59
|
});
|
|
72
60
|
}
|
|
73
61
|
|
|
74
62
|
protected property<K extends keyof T>(
|
|
75
63
|
key: K,
|
|
76
|
-
|
|
64
|
+
enumerate?: Enumerator<T[K]>,
|
|
77
65
|
): Signal<T[K]> {
|
|
78
66
|
const findProperty: UnaryFunction<T, T[K]> = property(key);
|
|
79
67
|
|
|
80
|
-
return this.
|
|
68
|
+
return this.map(
|
|
81
69
|
findProperty,
|
|
82
70
|
(transform) => (value) => {
|
|
83
71
|
value = clone(value);
|
|
@@ -86,19 +74,19 @@ export class Signal<T> extends ProxyObservable<T> {
|
|
|
86
74
|
|
|
87
75
|
return value;
|
|
88
76
|
},
|
|
89
|
-
|
|
77
|
+
enumerate,
|
|
90
78
|
);
|
|
91
79
|
}
|
|
92
80
|
|
|
93
81
|
protected item(
|
|
94
82
|
key: PropertyKey,
|
|
95
|
-
|
|
83
|
+
enumerate?: Enumerator<EnumerableItem<T>>,
|
|
96
84
|
): Signal<EnumerableItem<T>> {
|
|
97
85
|
const findIndex = this.enumerator.findIndex(key);
|
|
98
86
|
const findItem: UnaryFunction<T, EnumerableItem<T>> = (value) =>
|
|
99
87
|
nonNullable(asEnumerable(value)[findIndex(value)]);
|
|
100
88
|
|
|
101
|
-
return this.
|
|
89
|
+
return this.map(
|
|
102
90
|
findItem,
|
|
103
91
|
(transform) => (value) => {
|
|
104
92
|
if (Array.isArray((value = clone(value)))) {
|
|
@@ -107,14 +95,14 @@ export class Signal<T> extends ProxyObservable<T> {
|
|
|
107
95
|
|
|
108
96
|
return value;
|
|
109
97
|
},
|
|
110
|
-
|
|
98
|
+
enumerate,
|
|
111
99
|
);
|
|
112
100
|
}
|
|
113
101
|
|
|
114
102
|
protected collection<K extends keyof EnumerableItem<T>>(
|
|
115
103
|
key: K,
|
|
116
104
|
): Signal<EnumerableItem<T>[K][]> {
|
|
117
|
-
return this.
|
|
105
|
+
return this.map(
|
|
118
106
|
(value) => asEnumerable(value).map(property(key)),
|
|
119
107
|
(transform) => (value) => {
|
|
120
108
|
if (Array.isArray((value = clone(value)))) {
|
|
@@ -150,16 +138,16 @@ export class Signal<T> extends ProxyObservable<T> {
|
|
|
150
138
|
export class ComputedSignal<T> extends Signal<T> {
|
|
151
139
|
property<K extends keyof T>(
|
|
152
140
|
key: K,
|
|
153
|
-
|
|
141
|
+
enumerate?: Enumerator<T[K]>,
|
|
154
142
|
): ComputedSignal<T[K]> {
|
|
155
|
-
return new ComputedSignal(super.property(key,
|
|
143
|
+
return new ComputedSignal(super.property(key, enumerate));
|
|
156
144
|
}
|
|
157
145
|
|
|
158
146
|
item(
|
|
159
147
|
key: PropertyKey,
|
|
160
|
-
|
|
148
|
+
enumerate?: Enumerator<EnumerableItem<T>>,
|
|
161
149
|
): ComputedSignal<EnumerableItem<T>> {
|
|
162
|
-
return new ComputedSignal(super.item(key,
|
|
150
|
+
return new ComputedSignal(super.item(key, enumerate));
|
|
163
151
|
}
|
|
164
152
|
|
|
165
153
|
collection<K extends keyof EnumerableItem<T>>(
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UnaryFunction } from "rxjs";
|
|
2
|
+
|
|
3
|
+
export { ComputedSignal, Signal } from "./Signal";
|
|
4
|
+
|
|
5
|
+
export interface Transform<T> extends UnaryFunction<T, T> {}
|
|
6
|
+
|
|
7
|
+
export interface TransformOperator<T, U> extends UnaryFunction<
|
|
8
|
+
Transform<T>,
|
|
9
|
+
Transform<U>
|
|
10
|
+
> {}
|
package/src/slice.ts
CHANGED
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
} from "./component";
|
|
10
10
|
import { defineCustomElement } from "./dom";
|
|
11
11
|
import { ExtendableDictionary } from "./lib";
|
|
12
|
-
import { ComputedSignal } from "./observable";
|
|
13
12
|
import { multicast, MulticastSubject } from "./operators";
|
|
13
|
+
import { ComputedSignal } from "./signal";
|
|
14
14
|
import { StoreAdapter, StoreProvider } from "./store";
|
|
15
15
|
import { TerminalAdapter, TerminalEffect, TerminalProvider } from "./terminal";
|
|
16
16
|
import { Action } from "./types";
|
package/src/store.ts
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
UnaryFunction,
|
|
10
10
|
} from "rxjs";
|
|
11
11
|
import { ExtendableDictionary } from "./lib";
|
|
12
|
-
import { ComputedSignal, Signal } from "./observable";
|
|
13
12
|
import {
|
|
14
13
|
flatMap,
|
|
15
14
|
MulticastAction,
|
|
@@ -17,7 +16,8 @@ import {
|
|
|
17
16
|
sequence,
|
|
18
17
|
} from "./operators";
|
|
19
18
|
import { Serializable } from "./serializable";
|
|
20
|
-
import {
|
|
19
|
+
import { ComputedSignal, Signal, Transform } from "./signal";
|
|
20
|
+
import { Action } from "./types";
|
|
21
21
|
|
|
22
22
|
export type StoreEffect<Result> = () => Signal<Result>;
|
|
23
23
|
|
|
@@ -143,7 +143,7 @@ export class ExtendableStoreAdapter<
|
|
|
143
143
|
update: (predicate, config = {}) =>
|
|
144
144
|
thru(this.context.transform(key), (transform) => {
|
|
145
145
|
transform.register((args) =>
|
|
146
|
-
signal.
|
|
146
|
+
signal.pull(predicate(args)),
|
|
147
147
|
);
|
|
148
148
|
|
|
149
149
|
return (args) =>
|
package/src/terminal.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Dictionary } from "lodash";
|
|
|
2
2
|
import { UnaryFunction } from "rxjs";
|
|
3
3
|
import { ApiAdapter, ApiEffect } from "./api";
|
|
4
4
|
import { ExtendableDictionary } from "./lib";
|
|
5
|
-
import { ComputedSignal } from "./
|
|
5
|
+
import { ComputedSignal } from "./signal";
|
|
6
6
|
import { asStoreEffects, StoreAdapter, StoreEffects } from "./store";
|
|
7
7
|
import {
|
|
8
8
|
Action,
|