@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.
@@ -6,30 +6,6 @@ on:
6
6
  - "v*"
7
7
 
8
8
  jobs:
9
- publish:
10
- runs-on: ubuntu-latest
11
- permissions:
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cascateer/core",
3
- "version": "2.3.50",
3
+ "version": "2.3.55",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/cascateer/core.git"
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 "./observable";
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
- Deps extends Dictionary<Effect<any, any> | Action<any, any>>,
21
+ Context extends Dictionary<Effect<any, any> | Action<any, any>>,
22
22
  Props extends JSX.Props,
23
23
  >(
24
24
  constructor: (
25
- deps: Deps,
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(deps: Deps) {
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(deps, ...cssModules)(props);
37
+ const element = constructor(ctx, ...cssModules)(props);
38
38
 
39
39
  return customElement != null
40
40
  ? new (defineCustomElement(
package/src/lib/index.ts CHANGED
@@ -22,7 +22,7 @@ export const asObservable = <T>(value: MaybeObservable<T>): Observable<T> =>
22
22
 
23
23
  export const nonNullable = <T>(value: T): NonNullable<T> => {
24
24
  if (value == null) {
25
- throw new Error(`${value} is nil`);
25
+ throw null;
26
26
  }
27
27
 
28
28
  return value;
@@ -1,3 +1,2 @@
1
1
  export { ProxyObservable } from "./ProxyObservable";
2
2
  export { ProxySubject } from "./ProxySubject";
3
- export { ComputedSignal, Signal } from "./Signal";
@@ -1,7 +1,7 @@
1
1
  import { concatMap, shareReplay, startWith, UnaryFunction } from "rxjs";
2
2
  import { v4 } from "uuid";
3
- import { ComputedSignal, ProxySubject } from "../observable";
4
- import { Transform } from "../types";
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 "../types";
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.adapter.lift((number) => number + 1));
34
- transforms.next(signal.adapter.lift((number) => number + 2));
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 { Transform } from "../types";
11
+ import { ProxyObservable } from "../observable";
12
+ import { TransformOperator } from "../signal";
13
13
 
14
14
  class SignalEnumerator<T> {
15
- constructor(private enumerator: Enumerator<T> = nthArg(1)) {}
15
+ constructor(private predicate: Enumerator<T> = nthArg(1)) {}
16
16
 
17
17
  findIndex = (key: PropertyKey) => (value: T) =>
18
- asEnumerable(value).map(this.enumerator).indexOf(key);
18
+ asEnumerable(value).map(this.predicate).indexOf(key);
19
19
 
20
- enumerate = (value: T) => asEnumerable(value).map(this.enumerator);
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
- adapter: SignalAdapter<T>;
33
+ pull: TransformOperator<T, unknown>;
46
34
 
47
35
  constructor({
48
36
  value,
49
37
  enumerator = new SignalEnumerator(),
50
- adapter = new SignalAdapter(),
38
+ pull = identity,
51
39
  }: {
52
40
  value: Observable<T>;
53
41
  enumerator?: SignalEnumerator<T>;
54
- adapter?: SignalAdapter<T>;
42
+ pull?: TransformOperator<T, unknown>;
55
43
  }) {
56
44
  super(value);
57
45
 
58
46
  this.enumerator = enumerator;
59
- this.adapter = adapter;
47
+ this.pull = pull;
60
48
  }
61
49
 
62
- private project<U>(
63
- projector: UnaryFunction<T, U>,
64
- connector: UnaryFunction<Transform<U>, Transform<T>>,
65
- enumerator?: Enumerator<U>,
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(projector), distinctUntilChanged()),
69
- enumerator: new SignalEnumerator(enumerator),
70
- adapter: this.adapter.connect(connector),
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
- enumerator?: Enumerator<T[K]>,
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.project(
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
- enumerator,
77
+ enumerate,
90
78
  );
91
79
  }
92
80
 
93
81
  protected item(
94
82
  key: PropertyKey,
95
- enumerator?: Enumerator<EnumerableItem<T>>,
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.project(
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
- enumerator,
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.project(
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
- enumerator?: Enumerator<T[K]>,
141
+ enumerate?: Enumerator<T[K]>,
154
142
  ): ComputedSignal<T[K]> {
155
- return new ComputedSignal(super.property(key, enumerator));
143
+ return new ComputedSignal(super.property(key, enumerate));
156
144
  }
157
145
 
158
146
  item(
159
147
  key: PropertyKey,
160
- enumerator?: Enumerator<EnumerableItem<T>>,
148
+ enumerate?: Enumerator<EnumerableItem<T>>,
161
149
  ): ComputedSignal<EnumerableItem<T>> {
162
- return new ComputedSignal(super.item(key, enumerator));
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 { Action, Transform } from "./types";
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.adapter.lift(predicate(args)),
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 "./observable";
5
+ import { ComputedSignal } from "./signal";
6
6
  import { asStoreEffects, StoreAdapter, StoreEffects } from "./store";
7
7
  import {
8
8
  Action,
package/src/types.ts CHANGED
@@ -75,5 +75,3 @@ export type MaybeObservableInput<T> = T | ObservableInput<T>;
75
75
  export type MaybeObservableInputTuple<T> = {
76
76
  [K in keyof T]: MaybeObservableInput<T[K]>;
77
77
  };
78
-
79
- export type Transform<T> = UnaryFunction<T, T>;