@cascateer/core 2.3.49 → 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 +14 -25
- 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,7 +8,8 @@ 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
15
|
constructor(private predicate: Enumerator<T> = nthArg(1)) {}
|
|
@@ -20,17 +20,6 @@ class SignalEnumerator<T> {
|
|
|
20
20
|
enumerate = (value: T) => asEnumerable(value).map(this.predicate);
|
|
21
21
|
}
|
|
22
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
|
-
new SignalAdapter((transform) => this.lift(connector(transform)));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
23
|
export class Signal<T> extends ProxyObservable<T> {
|
|
35
24
|
clone(): Signal<T> {
|
|
36
25
|
return this;
|
|
@@ -41,32 +30,32 @@ export class Signal<T> extends ProxyObservable<T> {
|
|
|
41
30
|
}
|
|
42
31
|
|
|
43
32
|
enumerator: SignalEnumerator<T>;
|
|
44
|
-
|
|
33
|
+
pull: TransformOperator<T, unknown>;
|
|
45
34
|
|
|
46
35
|
constructor({
|
|
47
36
|
value,
|
|
48
37
|
enumerator = new SignalEnumerator(),
|
|
49
|
-
|
|
38
|
+
pull = identity,
|
|
50
39
|
}: {
|
|
51
40
|
value: Observable<T>;
|
|
52
41
|
enumerator?: SignalEnumerator<T>;
|
|
53
|
-
|
|
42
|
+
pull?: TransformOperator<T, unknown>;
|
|
54
43
|
}) {
|
|
55
44
|
super(value);
|
|
56
45
|
|
|
57
46
|
this.enumerator = enumerator;
|
|
58
|
-
this.
|
|
47
|
+
this.pull = pull;
|
|
59
48
|
}
|
|
60
49
|
|
|
61
|
-
private
|
|
62
|
-
|
|
63
|
-
|
|
50
|
+
private map<U>(
|
|
51
|
+
project: UnaryFunction<T, U>,
|
|
52
|
+
lift: TransformOperator<U, T>,
|
|
64
53
|
enumerate?: Enumerator<U>,
|
|
65
54
|
): Signal<U> {
|
|
66
55
|
return new Signal({
|
|
67
|
-
value: this.pipe(map(
|
|
56
|
+
value: this.pipe(map(project), distinctUntilChanged()),
|
|
68
57
|
enumerator: new SignalEnumerator(enumerate),
|
|
69
|
-
|
|
58
|
+
pull: (transform) => this.pull(lift(transform)),
|
|
70
59
|
});
|
|
71
60
|
}
|
|
72
61
|
|
|
@@ -76,7 +65,7 @@ export class Signal<T> extends ProxyObservable<T> {
|
|
|
76
65
|
): Signal<T[K]> {
|
|
77
66
|
const findProperty: UnaryFunction<T, T[K]> = property(key);
|
|
78
67
|
|
|
79
|
-
return this.
|
|
68
|
+
return this.map(
|
|
80
69
|
findProperty,
|
|
81
70
|
(transform) => (value) => {
|
|
82
71
|
value = clone(value);
|
|
@@ -97,7 +86,7 @@ export class Signal<T> extends ProxyObservable<T> {
|
|
|
97
86
|
const findItem: UnaryFunction<T, EnumerableItem<T>> = (value) =>
|
|
98
87
|
nonNullable(asEnumerable(value)[findIndex(value)]);
|
|
99
88
|
|
|
100
|
-
return this.
|
|
89
|
+
return this.map(
|
|
101
90
|
findItem,
|
|
102
91
|
(transform) => (value) => {
|
|
103
92
|
if (Array.isArray((value = clone(value)))) {
|
|
@@ -113,7 +102,7 @@ export class Signal<T> extends ProxyObservable<T> {
|
|
|
113
102
|
protected collection<K extends keyof EnumerableItem<T>>(
|
|
114
103
|
key: K,
|
|
115
104
|
): Signal<EnumerableItem<T>[K][]> {
|
|
116
|
-
return this.
|
|
105
|
+
return this.map(
|
|
117
106
|
(value) => asEnumerable(value).map(property(key)),
|
|
118
107
|
(transform) => (value) => {
|
|
119
108
|
if (Array.isArray((value = clone(value)))) {
|
|
@@ -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,
|