@manyducks.co/dolla 2.0.0-alpha.27 → 2.0.0-alpha.28
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 +6 -93
- package/dist/core/context.d.ts +88 -0
- package/dist/core/dolla.d.ts +30 -12
- package/dist/core/markup.d.ts +1 -23
- package/dist/core/nodes/html.d.ts +2 -1
- package/dist/core/nodes/observer.d.ts +2 -1
- package/dist/core/nodes/portal.d.ts +3 -2
- package/dist/core/nodes/repeat.d.ts +2 -1
- package/dist/core/nodes/view.d.ts +6 -13
- package/dist/core/store.d.ts +44 -0
- package/dist/core/symbols.d.ts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +496 -456
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.js +2 -2
- package/dist/jsx-runtime.js +2 -2
- package/dist/{passthrough-D9NjRov5.js → passthrough-1MySicTa.js} +541 -384
- package/dist/passthrough-1MySicTa.js.map +1 -0
- package/docs/setup.md +2 -1
- package/docs/state.md +133 -0
- package/notes/stores.md +73 -0
- package/package.json +1 -1
- package/dist/passthrough-D9NjRov5.js.map +0 -1
- package/docs/states.md +0 -41
package/README.md
CHANGED
|
@@ -7,102 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
Dolla is a batteries-included JavaScript frontend framework covering the needs of moderate-to-complex single page apps:
|
|
9
9
|
|
|
10
|
-
- ⚡ Reactive DOM updates with [State](). Inspired by Signals, but with more explicit tracking.
|
|
11
|
-
- 📦 Reusable components with [Views](
|
|
12
|
-
- 🔀 Built in [routing]() with nested routes and middleware support (check login status, preload data, etc).
|
|
13
|
-
- 🐕 Built in [HTTP]() client with middleware support (set auth headers, etc).
|
|
14
|
-
- 📍 Built in [localization]() system (store translated strings in JSON files and call the `t` function to get them).
|
|
15
|
-
- 🍳 Build system optional. Write views in JSX or use `html` tagged template literals.
|
|
10
|
+
- ⚡ Reactive DOM updates with [State](./docs/state.md). Inspired by Signals, but with more explicit tracking.
|
|
11
|
+
- 📦 Reusable components with [Views](./docs/views.md).
|
|
12
|
+
- 🔀 Built in [routing](./docs/router.md) with nested routes and middleware support (check login status, preload data, etc).
|
|
13
|
+
- 🐕 Built in [HTTP](./docs/http.md) client with middleware support (set auth headers, etc).
|
|
14
|
+
- 📍 Built in [localization](./docs/i18n.md) system (store translated strings in JSON files and call the `t` function to get them).
|
|
15
|
+
- 🍳 Build system optional. [Write views in JSX](./docs/setup.md) or use `html` tagged template literals.
|
|
16
16
|
|
|
17
17
|
Let's first get into some examples.
|
|
18
18
|
|
|
19
|
-
## State
|
|
20
|
-
|
|
21
|
-
### Basic State API
|
|
22
|
-
|
|
23
|
-
```js
|
|
24
|
-
import { createState, derive } from "@manyducks.co/dolla";
|
|
25
|
-
|
|
26
|
-
const [$count, setCount] = createState(72);
|
|
27
|
-
|
|
28
|
-
// Get value
|
|
29
|
-
$count.get(): // 72
|
|
30
|
-
|
|
31
|
-
// Replace the stored value with something else
|
|
32
|
-
setCount(300);
|
|
33
|
-
$count.get(); // 300
|
|
34
|
-
|
|
35
|
-
// You can also pass a function that takes the current value and returns a new one
|
|
36
|
-
setCount((current) => current + 1);
|
|
37
|
-
$count.get(); // 301
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Now that you have a state you can derive more states from that one. Derived states automatically stay in sync with the values of their dependencies.
|
|
41
|
-
|
|
42
|
-
```js
|
|
43
|
-
// Pass and array of one or more states followed by a function that computes a new value.
|
|
44
|
-
const $doubled = derive([$count], (count) => count * 2);
|
|
45
|
-
|
|
46
|
-
$doubled.get(); // 602
|
|
47
|
-
|
|
48
|
-
setCount(500);
|
|
49
|
-
|
|
50
|
-
$doubled.get(); // 1000
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### In Views
|
|
54
|
-
|
|
55
|
-
```jsx
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
States also come in a settable variety that includes the setter on the same object. Sometimes you want to pass around a two-way binding and this is what SettableState is for.
|
|
60
|
-
|
|
61
|
-
```jsx
|
|
62
|
-
import { createSettableState, fromSettable, toSettable } from "@manyducks.co/dolla";
|
|
63
|
-
|
|
64
|
-
// Settable states can be set by passing a value when they are called.
|
|
65
|
-
const $$value = createSettableState("Test");
|
|
66
|
-
$$value(); // "Test"
|
|
67
|
-
$$value("New Value");
|
|
68
|
-
$$value(); // "New Value"
|
|
69
|
-
|
|
70
|
-
// They can also be split into a State and Setter
|
|
71
|
-
const [$value, setValue] = fromSettableState($$value);
|
|
72
|
-
|
|
73
|
-
// And a State and Setter can be combined into a SettableState.
|
|
74
|
-
const $$otherValue = toSettableState($value, setValue);
|
|
75
|
-
|
|
76
|
-
// Or discard the setter and make it read-only using the good old toState function:
|
|
77
|
-
const $value = toState($$value);
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
You can also do weird proxy things like this:
|
|
81
|
-
|
|
82
|
-
```jsx
|
|
83
|
-
// Create an original place for the state to live
|
|
84
|
-
const [$value, setValue] = createState(5);
|
|
85
|
-
|
|
86
|
-
// Derive a state that doubles the value
|
|
87
|
-
const $doubled = derive([$value], (value) => value * 2);
|
|
88
|
-
|
|
89
|
-
// Create a setter that takes the doubled value and sets the original $value accordingly.
|
|
90
|
-
const setDoubled = createSetter($doubled, (next, current) => {
|
|
91
|
-
setValue(next / 2);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
// Bundle the derived state and setter into a SettableState to pass around.
|
|
95
|
-
const $$doubled = toSettableState($doubled, setDoubled);
|
|
96
|
-
|
|
97
|
-
// Setting the doubled state...
|
|
98
|
-
$$doubled(100);
|
|
99
|
-
|
|
100
|
-
// ... will be reflected everywhere.
|
|
101
|
-
$$doubled(); // 100
|
|
102
|
-
$doubled(); // 100
|
|
103
|
-
$value(); // 50
|
|
104
|
-
```
|
|
105
|
-
|
|
106
19
|
<h2 id="section-views">Views</h2>
|
|
107
20
|
|
|
108
21
|
A basic view:
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Emitter } from "@manyducks.co/emitter";
|
|
2
|
+
import type { Store, StoreFactory } from "./store";
|
|
3
|
+
import type { Dolla } from "./dolla";
|
|
4
|
+
interface ContextEmitterEvents {
|
|
5
|
+
[eventName: string | symbol]: [ContextEvent<any>];
|
|
6
|
+
}
|
|
7
|
+
export interface ElementContext {
|
|
8
|
+
/**
|
|
9
|
+
* The root Dolla instance this element belongs to.
|
|
10
|
+
*/
|
|
11
|
+
root: Dolla;
|
|
12
|
+
/**
|
|
13
|
+
* Storage for context variables.
|
|
14
|
+
*/
|
|
15
|
+
data: Record<string | symbol, unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* Event emitter for this context.
|
|
18
|
+
*/
|
|
19
|
+
emitter: Emitter<ContextEmitterEvents>;
|
|
20
|
+
/**
|
|
21
|
+
* Stores attached to this context.
|
|
22
|
+
*/
|
|
23
|
+
stores: Map<string, Store<any, any>>;
|
|
24
|
+
/**
|
|
25
|
+
* A reference to the parent context.
|
|
26
|
+
*/
|
|
27
|
+
parent?: ElementContext;
|
|
28
|
+
/**
|
|
29
|
+
* Whether to create DOM nodes in the SVG namespace. An `<svg>` element will set this to true and pass it down to children.
|
|
30
|
+
*/
|
|
31
|
+
isSVG?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The name of the nearest parent view.
|
|
34
|
+
*/
|
|
35
|
+
viewName?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ComponentContext {
|
|
38
|
+
/**
|
|
39
|
+
* Sets a context variable and returns its value.
|
|
40
|
+
*/
|
|
41
|
+
set<T>(key: string | symbol, value: T): T;
|
|
42
|
+
/**
|
|
43
|
+
* Gets the value of a context variable. Returns null if the variable is not set.
|
|
44
|
+
*/
|
|
45
|
+
get<T>(key: string | symbol): T | null;
|
|
46
|
+
/**
|
|
47
|
+
* Adds a listener to be called when `eventName` is emitted.
|
|
48
|
+
*/
|
|
49
|
+
on<T = unknown>(eventName: string, listener: (event: ContextEvent<T>) => void): void;
|
|
50
|
+
/**
|
|
51
|
+
* Removes a listener from the list to be called when `eventName` is emitted.
|
|
52
|
+
*/
|
|
53
|
+
off<T = unknown>(eventName: string, listener: (event: ContextEvent<T>) => void): void;
|
|
54
|
+
/**
|
|
55
|
+
* Adds a listener to be called when `eventName` is emitted. The listener is immediately removed after being called once.
|
|
56
|
+
*/
|
|
57
|
+
once<T = unknown>(eventName: string, listener: (event: ContextEvent<T>) => void): void;
|
|
58
|
+
/**
|
|
59
|
+
* Emits a new event to all listeners.
|
|
60
|
+
*/
|
|
61
|
+
emit<T = unknown>(eventName: string, detail: T): boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* A context capable of hosting stores.
|
|
65
|
+
*/
|
|
66
|
+
export interface StorableContext extends ComponentContext {
|
|
67
|
+
/**
|
|
68
|
+
* Attaches a new store to this context.
|
|
69
|
+
*/
|
|
70
|
+
attachStore(store: Store<any, any>): void;
|
|
71
|
+
/**
|
|
72
|
+
* Gets the closest instance of a store. Throws an error if the store isn't provided higher in the tree.
|
|
73
|
+
*/
|
|
74
|
+
useStore<Value>(factory: StoreFactory<any, Value>): Value;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* An event emitted from and received by a Dolla context. These are separate from DOM events.
|
|
78
|
+
*/
|
|
79
|
+
export declare class ContextEvent<T> {
|
|
80
|
+
#private;
|
|
81
|
+
type: string;
|
|
82
|
+
detail: T;
|
|
83
|
+
get propagationStopped(): boolean;
|
|
84
|
+
constructor(type: string, detail: T);
|
|
85
|
+
stopPropagation(): void;
|
|
86
|
+
get [Symbol.toStringTag](): string;
|
|
87
|
+
}
|
|
88
|
+
export {};
|
package/dist/core/dolla.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { HTTP } from "../modules/http.js";
|
|
2
|
+
import { I18n } from "../modules/i18n.js";
|
|
3
|
+
import { Router } from "../modules/router.js";
|
|
1
4
|
import { type CrashViewProps } from "../views/default-crash-view.js";
|
|
2
5
|
import { Batch } from "./batch.js";
|
|
6
|
+
import { ContextEvent, type StorableContext } from "./context.js";
|
|
3
7
|
import { type Markup, type MarkupElement } from "./markup.js";
|
|
4
8
|
import { type ViewElement, type ViewFunction } from "./nodes/view.js";
|
|
5
9
|
import { createRef, isRef } from "./ref.js";
|
|
6
10
|
import { createState, createWatcher, derive, isState, toState, toValue } from "./state.js";
|
|
7
|
-
import {
|
|
8
|
-
import { I18n } from "../modules/i18n.js";
|
|
9
|
-
import { Router } from "../modules/router.js";
|
|
11
|
+
import { type Store, type StoreFactory } from "./store.js";
|
|
10
12
|
export type Environment = "development" | "production";
|
|
11
13
|
/**
|
|
12
14
|
* Log type toggles. Each message category can be turned on or off or enabled only in a specific environment.
|
|
@@ -40,11 +42,7 @@ export type LoggerOptions = {
|
|
|
40
42
|
*/
|
|
41
43
|
uid?: string;
|
|
42
44
|
};
|
|
43
|
-
export
|
|
44
|
-
root: Dolla;
|
|
45
|
-
options: Options;
|
|
46
|
-
}
|
|
47
|
-
export declare class Dolla {
|
|
45
|
+
export declare class Dolla implements StorableContext {
|
|
48
46
|
#private;
|
|
49
47
|
readonly batch: Batch;
|
|
50
48
|
private readonly stats;
|
|
@@ -88,9 +86,6 @@ export declare class Dolla {
|
|
|
88
86
|
* Returns the top level view Dolla is rendering inside the root element. This will return undefined until Dolla.mount() is called.
|
|
89
87
|
*/
|
|
90
88
|
getRootView(): ViewElement | undefined;
|
|
91
|
-
/**
|
|
92
|
-
* Registers a Dolla module.
|
|
93
|
-
*/
|
|
94
89
|
/**
|
|
95
90
|
* Sets a context variable and returns its value. Context variables are accessible on the app and in child views.
|
|
96
91
|
*/
|
|
@@ -102,7 +97,30 @@ export declare class Dolla {
|
|
|
102
97
|
/**
|
|
103
98
|
* Returns an object of all context variables stored at the app level.
|
|
104
99
|
*/
|
|
105
|
-
|
|
100
|
+
/**
|
|
101
|
+
* Adds a listener to be called when `eventName` is emitted.
|
|
102
|
+
*/
|
|
103
|
+
on<T = unknown>(eventName: string, listener: (event: ContextEvent<T>) => void): void;
|
|
104
|
+
/**
|
|
105
|
+
* Removes a listener from the list to be called when `eventName` is emitted.
|
|
106
|
+
*/
|
|
107
|
+
off<T = unknown>(eventName: string, listener: (event: ContextEvent<T>) => void): void;
|
|
108
|
+
/**
|
|
109
|
+
* Adds a listener to be called when `eventName` is emitted. The listener is immediately removed after being called once.
|
|
110
|
+
*/
|
|
111
|
+
once<T = unknown>(eventName: string, listener: (event: ContextEvent<T>) => void): void;
|
|
112
|
+
/**
|
|
113
|
+
* Emits a new event to all listeners.
|
|
114
|
+
*/
|
|
115
|
+
emit<T = unknown>(eventName: string, detail: T): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Attaches a new store to this context.
|
|
118
|
+
*/
|
|
119
|
+
attachStore(store: Store<any, any>): void;
|
|
120
|
+
/**
|
|
121
|
+
* Gets the nearest instance of a store. Throws an error if the store isn't provided higher in the tree.
|
|
122
|
+
*/
|
|
123
|
+
useStore<Value>(factory: StoreFactory<any, Value>): Value;
|
|
106
124
|
mount(selector: string, view?: ViewFunction<any>): Promise<void>;
|
|
107
125
|
mount(element: HTMLElement, view?: ViewFunction<any>): Promise<void>;
|
|
108
126
|
unmount(): Promise<void>;
|
package/dist/core/markup.d.ts
CHANGED
|
@@ -1,29 +1,7 @@
|
|
|
1
1
|
import type { Renderable } from "../types.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ElementContext } from "./context.js";
|
|
3
3
|
import { type ViewContext, type ViewFunction, type ViewResult } from "./nodes/view.js";
|
|
4
4
|
import { type MaybeState, type State } from "./state.js";
|
|
5
|
-
export interface ElementContext {
|
|
6
|
-
/**
|
|
7
|
-
* The root Dolla instance this element belongs to.
|
|
8
|
-
*/
|
|
9
|
-
root: Dolla;
|
|
10
|
-
/**
|
|
11
|
-
* Storage for context variables.
|
|
12
|
-
*/
|
|
13
|
-
data: Record<string | symbol, unknown>;
|
|
14
|
-
/**
|
|
15
|
-
* A reference to the parent context.
|
|
16
|
-
*/
|
|
17
|
-
parent?: ElementContext;
|
|
18
|
-
/**
|
|
19
|
-
* Whether to create DOM nodes in the SVG namespace. An `<svg>` element will set this to true and pass it down to children.
|
|
20
|
-
*/
|
|
21
|
-
isSVG?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* The name of the nearest parent view.
|
|
24
|
-
*/
|
|
25
|
-
viewName?: string;
|
|
26
|
-
}
|
|
27
5
|
/**
|
|
28
6
|
* Markup is a set of element metadata that hasn't been constructed into a MarkupElement yet.
|
|
29
7
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type ElementContext
|
|
1
|
+
import { type ElementContext } from "../context.js";
|
|
2
|
+
import { type Markup, type MarkupElement } from "../markup.js";
|
|
2
3
|
import { type Ref } from "../ref.js";
|
|
3
4
|
import { type State, type StopFunction } from "../state.js";
|
|
4
5
|
import { IS_MARKUP_ELEMENT } from "../symbols.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Renderable } from "../../types.js";
|
|
2
|
-
import {
|
|
2
|
+
import type { ElementContext } from "../context.js";
|
|
3
|
+
import { type MarkupElement } from "../markup.js";
|
|
3
4
|
import { type MaybeState } from "../state.js";
|
|
4
5
|
import { IS_MARKUP_ELEMENT } from "../symbols.js";
|
|
5
6
|
interface ObserverOptions {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Renderable } from "../../types.js";
|
|
2
|
+
import type { ElementContext } from "../context.js";
|
|
3
|
+
import { type MarkupElement } from "../markup.js";
|
|
3
4
|
import { IS_MARKUP_ELEMENT } from "../symbols.js";
|
|
4
5
|
interface PortalConfig {
|
|
5
6
|
content: Renderable;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type ElementContext
|
|
1
|
+
import { type ElementContext } from "../context.js";
|
|
2
|
+
import { type MarkupElement } from "../markup.js";
|
|
2
3
|
import { type Setter, type State, type StopFunction } from "../state.js";
|
|
3
4
|
import { IS_MARKUP_ELEMENT } from "../symbols.js";
|
|
4
5
|
import { type ViewContext, type ViewResult } from "./view.js";
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import { Emitter } from "@manyducks.co/emitter";
|
|
2
|
+
import { type ElementContext, type StorableContext } from "../context.js";
|
|
1
3
|
import type { Logger } from "../dolla.js";
|
|
2
|
-
import { type
|
|
4
|
+
import { type Markup, type MarkupElement } from "../markup.js";
|
|
3
5
|
import { type MaybeState, type State, type StateValues, type StopFunction } from "../state.js";
|
|
4
6
|
import { IS_MARKUP_ELEMENT } from "../symbols.js";
|
|
5
|
-
import { Emitter } from "@manyducks.co/emitter";
|
|
6
7
|
/**
|
|
7
8
|
* Any valid value that a View can return.
|
|
8
9
|
*/
|
|
9
10
|
export type ViewResult = Node | State<any> | Markup | Markup[] | null;
|
|
10
|
-
export type ViewFunction<P> = (props: P, context: ViewContext) => ViewResult;
|
|
11
|
+
export type ViewFunction<P> = (this: ViewContext, props: P, context: ViewContext) => ViewResult;
|
|
11
12
|
/**
|
|
12
13
|
* A view that has been constructed into DOM nodes.
|
|
13
14
|
*/
|
|
@@ -17,23 +18,14 @@ export interface ViewElement extends MarkupElement {
|
|
|
17
18
|
*/
|
|
18
19
|
setChildView(view: ViewFunction<{}>): ViewElement;
|
|
19
20
|
}
|
|
20
|
-
export interface ViewContext extends Logger {
|
|
21
|
+
export interface ViewContext extends Logger, StorableContext {
|
|
21
22
|
/**
|
|
22
23
|
* An ID unique to this view.
|
|
23
24
|
*/
|
|
24
25
|
readonly uid: string;
|
|
25
|
-
/**
|
|
26
|
-
* Sets a context variable and returns its value. Context variables are accessible on the same context and from those of child views.
|
|
27
|
-
*/
|
|
28
|
-
set<T>(key: string | symbol, value: T): T;
|
|
29
|
-
/**
|
|
30
|
-
* Gets the value of a context variable. Returns null if the variable is not set.
|
|
31
|
-
*/
|
|
32
|
-
get<T>(key: string | symbol): T | null;
|
|
33
26
|
/**
|
|
34
27
|
* Returns an object of all variables stored on this context.
|
|
35
28
|
*/
|
|
36
|
-
getAll(): Record<string | symbol, unknown>;
|
|
37
29
|
/**
|
|
38
30
|
* Sets the name of the view's built in logger.
|
|
39
31
|
*/
|
|
@@ -64,6 +56,7 @@ export interface ViewContext extends Logger {
|
|
|
64
56
|
*/
|
|
65
57
|
outlet(): Markup;
|
|
66
58
|
}
|
|
59
|
+
export declare function createView<Props extends Record<string, any> = Record<string, unknown>>(fn: ViewFunction<Props>): ViewFunction<Props>;
|
|
67
60
|
type ViewEvents = {
|
|
68
61
|
beforeMount: [];
|
|
69
62
|
mounted: [];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Emitter } from "@manyducks.co/emitter";
|
|
2
|
+
import { type ComponentContext, type ElementContext } from "./context.js";
|
|
3
|
+
import type { Logger } from "./dolla.js";
|
|
4
|
+
export type StoreFunction<Options, Value> = (this: StoreContext, options: Options, context: StoreContext) => Value;
|
|
5
|
+
export type StoreFactory<Options, Value> = Options extends undefined ? () => Store<Options, Value> : (options: Options) => Store<Options, Value>;
|
|
6
|
+
export interface StoreContext extends Logger, ComponentContext {
|
|
7
|
+
/**
|
|
8
|
+
* Registers a callback to run just after this store is mounted.
|
|
9
|
+
*/
|
|
10
|
+
onMount(callback: () => void): void;
|
|
11
|
+
/**
|
|
12
|
+
* Registers a callback to run just after this store is unmounted.
|
|
13
|
+
*/
|
|
14
|
+
onUnmount(callback: () => void): void;
|
|
15
|
+
}
|
|
16
|
+
type StoreEvents = {
|
|
17
|
+
mounted: [];
|
|
18
|
+
unmounted: [];
|
|
19
|
+
};
|
|
20
|
+
export declare class Store<Options, Value> {
|
|
21
|
+
readonly key: string;
|
|
22
|
+
private _fn;
|
|
23
|
+
private _options;
|
|
24
|
+
/**
|
|
25
|
+
* Value is guaranteed to be set after `attach` is called.
|
|
26
|
+
*/
|
|
27
|
+
value: Value;
|
|
28
|
+
_elementContext: ElementContext;
|
|
29
|
+
_emitter: Emitter<StoreEvents>;
|
|
30
|
+
_logger: Logger;
|
|
31
|
+
constructor(key: string, fn: StoreFunction<Options, Value>, options: Options);
|
|
32
|
+
attach(elementContext: ElementContext): void;
|
|
33
|
+
handleMount(): void;
|
|
34
|
+
handleUnmount(): void;
|
|
35
|
+
}
|
|
36
|
+
export declare function isStoreFactory<Options, Value>(value: any): value is StoreFactory<Options, Value>;
|
|
37
|
+
export declare function isStore<Options, Value>(value: any): value is Store<Options, Value>;
|
|
38
|
+
/**
|
|
39
|
+
* Defines a new store.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createStore<Options = undefined, Value = unknown>(fn: StoreFunction<Options, Value>): StoreFactory<Options, Value>;
|
|
42
|
+
export declare class StoreError extends Error {
|
|
43
|
+
}
|
|
44
|
+
export {};
|
package/dist/core/symbols.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ export declare const IS_STATE: unique symbol;
|
|
|
2
2
|
export declare const IS_REF: unique symbol;
|
|
3
3
|
export declare const IS_MARKUP: unique symbol;
|
|
4
4
|
export declare const IS_MARKUP_ELEMENT: unique symbol;
|
|
5
|
+
export declare const IS_STORE: unique symbol;
|
|
6
|
+
export declare const IS_STORE_FACTORY: unique symbol;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export { createState, derive, isState, toState, toValue } from "./core/state.js";
|
|
2
2
|
export type { MaybeState, Setter, State, StopFunction } from "./core/state.js";
|
|
3
3
|
export { createRef, isRef, type Ref } from "./core/ref.js";
|
|
4
|
+
export { createStore, type Store, type StoreFunction, type StoreFactory } from "./core/store.js";
|
|
4
5
|
export { deepEqual, shallowEqual, strictEqual } from "./utils.js";
|
|
5
6
|
export { cond, createMarkup, html, portal, repeat } from "./core/markup.js";
|
|
6
7
|
export type { Markup, MarkupElement } from "./core/markup.js";
|
|
8
|
+
export { createView } from "./core/nodes/view.js";
|
|
7
9
|
import { Dolla } from "./core/dolla.js";
|
|
8
10
|
declare const dolla: Dolla;
|
|
9
11
|
export default dolla;
|