@cascateer/core 2.0.13 → 2.0.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cascateer/core",
3
- "version": "2.0.13",
3
+ "version": "2.0.15",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/cascateer/core.git"
package/src/api.ts CHANGED
@@ -38,7 +38,7 @@ interface TagsConstructor<Args, Result> {
38
38
 
39
39
  interface MemoizableConfig<Args, Result> {
40
40
  predicate: UnaryFunction<Args, MaybeObservable<{ data: Result }>>;
41
- tags: TagsConstructor<Args, Result> | MaybeArray<string>;
41
+ tags?: TagsConstructor<Args, Result> | MaybeArray<string>;
42
42
  }
43
43
 
44
44
  class Memoizable<Args, Result> {
@@ -52,7 +52,7 @@ class Memoizable<Args, Result> {
52
52
  constructor({ predicate, tags }: MemoizableConfig<Args, Result>) {
53
53
  this.predicate = (args) =>
54
54
  asObservable(predicate(args)).pipe(map(property("data")));
55
- this.tags = isFunction(tags) ? tags : constant([tags].flat());
55
+ this.tags = isFunction(tags) ? tags : constant([tags ?? []].flat());
56
56
 
57
57
  this.subscribe = (invalidatedTags) => {
58
58
  const loading = new BehaviorSubject(false);
package/src/component.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Dictionary, kebabCase } from "lodash";
2
2
  import { defer, share, UnaryFunction } from "rxjs";
3
3
  import { createFragment } from ".";
4
+ import { ApiAdapter, ApiEffect } from "./api";
4
5
  import { cssStyleSheets } from "./css";
5
6
  import { defineCustomElement } from "./dom";
6
7
  import { ExtendableDictionary } from "./lib";
@@ -67,6 +68,8 @@ export class ComponentsAdapter<
67
68
  export class ExtendableComponentsAdapter<
68
69
  StoreSignals extends Dictionary<ComputedSignal<any>>,
69
70
  StoreActions extends Dictionary<Action<any, any>>,
71
+ ApiEffects extends Dictionary<ApiEffect<any, any>>,
72
+ ApiActions extends Dictionary<Action<any, any>>,
70
73
  TerminalEffects extends Dictionary<TerminalEffect<any, any>>,
71
74
  TerminalActions extends Dictionary<Action<any, any>>,
72
75
  Components extends Dictionary<ComponentConstructor<any>>,
@@ -78,6 +81,7 @@ export class ExtendableComponentsAdapter<
78
81
  constructor(
79
82
  public context: {
80
83
  store: StoreAdapter<StoreSignals, StoreActions>;
84
+ api: ApiAdapter<ApiEffects, ApiActions>;
81
85
  terminal: TerminalAdapter<TerminalEffects, TerminalActions>;
82
86
  },
83
87
  private extendableComponents: ExtendableDictionary<
@@ -98,6 +102,10 @@ export class ExtendableComponentsAdapter<
98
102
  effects: StoreEffects<StoreSignals>;
99
103
  actions: StoreActions;
100
104
  };
105
+ api: {
106
+ effects: ApiEffects;
107
+ actions: ApiActions;
108
+ };
101
109
  terminal: {
102
110
  effects: TerminalEffects;
103
111
  actions: TerminalActions;
@@ -121,6 +129,10 @@ export class ExtendableComponentsAdapter<
121
129
  effects: asStoreEffects(this.context.store.signals),
122
130
  actions: this.context.store.actions,
123
131
  },
132
+ api: {
133
+ effects: this.context.api.effects,
134
+ actions: this.context.api.actions,
135
+ },
124
136
  terminal: {
125
137
  effects: this.context.terminal.effects,
126
138
  actions: this.context.terminal.actions,
@@ -135,17 +147,22 @@ export class ExtendableComponentsAdapter<
135
147
  export class ComponentsProvider<
136
148
  StoreSignals extends Dictionary<ComputedSignal<any>>,
137
149
  StoreActions extends Dictionary<Action<any, any>>,
150
+ ApiEffects extends Dictionary<ApiEffect<any, any>>,
151
+ ApiActions extends Dictionary<Action<any, any>>,
138
152
  TerminalEffects extends Dictionary<TerminalEffect<any, any>>,
139
153
  TerminalActions extends Dictionary<Action<any, any>>,
140
154
  > extends ExtendableComponentsAdapter<
141
155
  StoreSignals,
142
156
  StoreActions,
157
+ ApiEffects,
158
+ ApiActions,
143
159
  TerminalEffects,
144
160
  TerminalActions,
145
161
  {}
146
162
  > {
147
163
  constructor(context: {
148
164
  store: StoreAdapter<StoreSignals, StoreActions>;
165
+ api: ApiAdapter<ApiEffects, ApiActions>;
149
166
  terminal: TerminalAdapter<TerminalEffects, TerminalActions>;
150
167
  }) {
151
168
  super(context, new ExtendableDictionary({}));
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { ApiProvider } from "./api";
1
+ export { ApiProvider, type ApiEffect } from "./api";
2
2
  export { App } from "./app";
3
3
  export { createComponent } from "./component";
4
4
  export { defineCustomProperties } from "./dom";
@@ -6,4 +6,4 @@ export { createElement, createFragment } from "./jsx-runtime";
6
6
  export { createSlice } from "./slice";
7
7
  export { type StoreEffect } from "./store";
8
8
  export { type TerminalEffect } from "./terminal";
9
- export { type Action, type MaybeObservable } from "./types";
9
+ export { type Action, type Effect, type MaybeObservable } from "./types";
package/src/slice.ts CHANGED
@@ -54,6 +54,8 @@ interface SliceConfig<
54
54
  new (): ComponentsProvider<
55
55
  StoreSignals,
56
56
  StoreActions,
57
+ ApiEffects,
58
+ ApiActions,
57
59
  TerminalEffects,
58
60
  TerminalActions
59
61
  >;
@@ -171,13 +173,15 @@ export class Slice<
171
173
  class extends ComponentsProvider<
172
174
  StoreSignals,
173
175
  StoreActions,
176
+ ApiEffects,
177
+ ApiActions,
174
178
  TerminalEffects,
175
179
  TerminalActions
176
180
  > {
177
181
  constructor() {
178
182
  super(context);
179
183
  }
180
- })({ store: this.store, terminal: this.terminal }),
184
+ })({ store: this.store, api, terminal: this.terminal }),
181
185
  }).components,
182
186
  (componentConstructor) =>
183
187
  componentConstructor.predicate(key),