@manyducks.co/dolla 2.0.0-alpha.64 → 2.0.0-alpha.66
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/dist/core/app.d.ts +24 -0
- package/dist/core/index.d.ts +3 -2
- package/dist/core/markup.d.ts +9 -1
- package/dist/core/nodes/element.d.ts +1 -0
- package/dist/core/scheduler.d.ts +12 -4
- package/dist/core/signals.d.ts +10 -9
- package/dist/core/views/portal.d.ts +17 -0
- package/dist/hooks/index.d.ts +21 -5
- package/dist/hooks.js +27 -21
- package/dist/hooks.js.map +1 -1
- package/dist/http.js +1 -1
- package/dist/i18n.js +3 -3
- package/dist/index-BEDDzyd9.js +556 -0
- package/dist/index-BEDDzyd9.js.map +1 -0
- package/dist/index.js +125 -70
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.js +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/dist/{logger-B7RBYtzP.js → logger-CmXtRdEI.js} +7 -7
- package/dist/{logger-B7RBYtzP.js.map → logger-CmXtRdEI.js.map} +1 -1
- package/dist/markup-DjDexAN5.js +1179 -0
- package/dist/markup-DjDexAN5.js.map +1 -0
- package/dist/router/hooks.d.ts +2 -0
- package/dist/router/index.d.ts +1 -0
- package/dist/router/router.d.ts +1 -0
- package/dist/router.js +3 -5
- package/dist/router.js.map +1 -1
- package/dist/{signals-DbDmN2gr.js → signals-CkfFHd0d.js} +264 -255
- package/dist/signals-CkfFHd0d.js.map +1 -0
- package/dist/typeChecking-_dGK_0uR.js +62 -0
- package/dist/{typeChecking-CbltMOUt.js.map → typeChecking-_dGK_0uR.js.map} +1 -1
- package/dist/utils.d.ts +5 -0
- package/docs/components.md +21 -0
- package/docs/hooks.md +3 -3
- package/docs/signals.md +67 -53
- package/docs/stores.md +13 -4
- package/package.json +4 -4
- package/dist/core/mount.d.ts +0 -15
- package/dist/core/mount.test.d.ts +0 -0
- package/dist/markup-DeZDwQ9F.js +0 -1117
- package/dist/markup-DeZDwQ9F.js.map +0 -1
- package/dist/router-C35XmU3k.js +0 -543
- package/dist/router-C35XmU3k.js.map +0 -1
- package/dist/signals-DbDmN2gr.js.map +0 -1
- package/dist/typeChecking-CbltMOUt.js +0 -71
- package/docs/state.md +0 -141
- package/examples/webcomponent/index.html +0 -14
- package/examples/webcomponent/main.js +0 -165
- package/notes/TODO.md +0 -6
- package/notes/context-routes.md +0 -61
- package/notes/custom-nodes.md +0 -17
- package/notes/effection-idea.md +0 -34
- package/notes/mixins.md +0 -22
- package/notes/molecule.md +0 -35
- package/notes/readme-scratch.md +0 -260
- package/notes/route-middleware.md +0 -42
- package/notes/stores.md +0 -79
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Router, RouterOptions } from "../router/router";
|
|
2
|
+
import { View } from "../types";
|
|
3
|
+
import { Context } from "./context";
|
|
4
|
+
import { LoggerCrashProps } from "./logger";
|
|
5
|
+
interface AppOptions {
|
|
6
|
+
view?: View<{}>;
|
|
7
|
+
router?: Router;
|
|
8
|
+
context?: Context;
|
|
9
|
+
}
|
|
10
|
+
declare class App {
|
|
11
|
+
#private;
|
|
12
|
+
get context(): Context;
|
|
13
|
+
constructor(options: AppOptions);
|
|
14
|
+
setCrashView(view: View<LoggerCrashProps>): this;
|
|
15
|
+
mount(element: string | Element): Promise<void>;
|
|
16
|
+
unmount(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export interface CreateAppOptions {
|
|
19
|
+
context?: Context;
|
|
20
|
+
}
|
|
21
|
+
export declare function createApp(view: View<{}>, options?: CreateAppOptions): App;
|
|
22
|
+
export declare function createApp(routerOptions: RouterOptions, options?: CreateAppOptions): App;
|
|
23
|
+
export declare function createApp(router: Router, options?: CreateAppOptions): App;
|
|
24
|
+
export {};
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createApp } from "./app.js";
|
|
2
|
+
export { $, batch, effect, get, memo as memo, writable, untracked } from "./signals.js";
|
|
2
3
|
export type { MaybeSignal, Writable, Signal } from "./signals.js";
|
|
3
4
|
export { createContext } from "./context.js";
|
|
4
5
|
export type { Context } from "./context.js";
|
|
@@ -6,7 +7,7 @@ export { m, Markup, MarkupNode, portal, render, repeat, unless, when } from "./m
|
|
|
6
7
|
export { ref, type Ref } from "./ref.js";
|
|
7
8
|
export { For, type ForProps } from "./views/for.js";
|
|
8
9
|
export { Show, type ShowProps } from "./views/show.js";
|
|
9
|
-
export {
|
|
10
|
+
export { Portal, type PortalProps } from "./views/portal.js";
|
|
10
11
|
export { deepEqual, shallowEqual, strictEqual } from "../utils.js";
|
|
11
12
|
export { getEnv, setEnv } from "./env.js";
|
|
12
13
|
export { createLogger, onLoggerCrash, setLogFilter, setLogLevels } from "./logger.js";
|
package/dist/core/markup.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { IntrinsicElements, Renderable, View } from "../types.js";
|
|
|
2
2
|
import { Context } from "./context.js";
|
|
3
3
|
import { MarkupNode } from "./nodes/_markup.js";
|
|
4
4
|
import { KeyFn, RenderFn } from "./nodes/repeat.js";
|
|
5
|
-
import { type
|
|
5
|
+
import { type MaybeSignal, type Signal } from "./signals.js";
|
|
6
6
|
export { MarkupNode };
|
|
7
7
|
type PropsOf<V extends string | View<any>> = V extends View<infer U> ? U : any;
|
|
8
8
|
/**
|
|
@@ -74,19 +74,27 @@ export declare function m<P extends {}>(type: View<P>, props?: P): Markup;
|
|
|
74
74
|
export declare function m<P>(type: View<P>, props: P): Markup;
|
|
75
75
|
/**
|
|
76
76
|
* If `condition` is truthy, displays `thenContent`, otherwise `elseContent`.
|
|
77
|
+
*
|
|
78
|
+
* @deprecated use `Show` view with `when` prop.
|
|
77
79
|
*/
|
|
78
80
|
export declare function when(condition: MaybeSignal<any>, thenContent?: Renderable, elseContent?: Renderable): Markup;
|
|
79
81
|
/**
|
|
80
82
|
* Inverted `when`. If `condition` is falsy, displays `thenContent`, otherwise `elseContent`.
|
|
83
|
+
*
|
|
84
|
+
* @deprecated use `Show` view with `unless` prop.
|
|
81
85
|
*/
|
|
82
86
|
export declare function unless(condition: MaybeSignal<any>, thenContent?: Renderable, elseContent?: Renderable): Markup;
|
|
83
87
|
/**
|
|
84
88
|
* Calls `render` for each item in `items`. Dynamically adds and removes views as items change.
|
|
85
89
|
* The result of `key` is used to compare items and decide if item was added, removed or updated.
|
|
90
|
+
*
|
|
91
|
+
* @deprecated use `For` view
|
|
86
92
|
*/
|
|
87
93
|
export declare function repeat<T>(items: MaybeSignal<T[]>, key: KeyFn<T>, render: RenderFn<T>): Markup;
|
|
88
94
|
/**
|
|
89
95
|
* Renders `content` into a `parent` node anywhere in the page, rather than its usual position in the view.
|
|
96
|
+
*
|
|
97
|
+
* @deprecated use `Portal` view
|
|
90
98
|
*/
|
|
91
99
|
export declare function portal(parent: Element, content: Renderable): Markup;
|
|
92
100
|
/**
|
|
@@ -19,6 +19,7 @@ export declare class ElementNode extends MarkupNode {
|
|
|
19
19
|
mount(parent: Node, after?: Node): void;
|
|
20
20
|
unmount(skipDOM?: boolean): void;
|
|
21
21
|
move(parent: Element, after?: Node): void;
|
|
22
|
+
private update;
|
|
22
23
|
private attachProp;
|
|
23
24
|
private getKey;
|
|
24
25
|
private applyProps;
|
package/dist/core/scheduler.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
export type Callback = () => void;
|
|
2
|
+
export interface Task {
|
|
3
|
+
id: number;
|
|
4
|
+
fn: ((didTimeout: boolean) => void) | null;
|
|
5
|
+
startTime: number;
|
|
6
|
+
expirationTime: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function requestCallback(fn: () => void, options?: {
|
|
9
|
+
timeout: number;
|
|
10
|
+
}): Task;
|
|
11
|
+
export declare function cancelCallback(task: Task): void;
|
|
2
12
|
/**
|
|
3
13
|
* Centralized scheduling for DOM updates.
|
|
4
14
|
*/
|
|
5
15
|
declare class Scheduler {
|
|
6
16
|
#private;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/
|
|
10
|
-
scheduleUpdate(update: Callback, key?: string): void;
|
|
17
|
+
scheduleNodeUpdate(nodeId: number, fn: Callback): void;
|
|
18
|
+
cancelNodeUpdates(nodeId: number): void;
|
|
11
19
|
/**
|
|
12
20
|
* Registers a callback to run after all processing has finished in the next tick.
|
|
13
21
|
*/
|
package/dist/core/signals.d.ts
CHANGED
|
@@ -12,8 +12,7 @@ export interface Signal<T> {
|
|
|
12
12
|
* A function that sets the value of the signal.
|
|
13
13
|
*/
|
|
14
14
|
export interface Setter<T> {
|
|
15
|
-
(value: T): void;
|
|
16
|
-
(update: (current: T) => T): void;
|
|
15
|
+
(value: T | ((previousValue: T) => T)): void;
|
|
17
16
|
}
|
|
18
17
|
/**
|
|
19
18
|
* A getter and setter in a single object. Callable like a getter, but includes a `set` method for updating the signal's value.
|
|
@@ -26,7 +25,7 @@ export interface Writable<T> extends Signal<T> {
|
|
|
26
25
|
* This value can be unwrapped to a plain value with `get` or `untracked` (depending on whether you're in a tracking context and need to track it).
|
|
27
26
|
*/
|
|
28
27
|
export type MaybeSignal<T> = Signal<T> | T;
|
|
29
|
-
export type EqualityFn<T> = (
|
|
28
|
+
export type EqualityFn<T> = (previousValue: T, nextValue: T) => boolean;
|
|
30
29
|
export interface SignalOptions<T> {
|
|
31
30
|
/**
|
|
32
31
|
* A function to compare the current and next values. Returning `true` means the value has changed.
|
|
@@ -35,11 +34,12 @@ export interface SignalOptions<T> {
|
|
|
35
34
|
}
|
|
36
35
|
export declare function $<T>(compute: (previousValue?: T) => MaybeSignal<T>, options?: MemoOptions<T>): Signal<T>;
|
|
37
36
|
export declare function $<T>(): Writable<T | undefined>;
|
|
38
|
-
export declare function $<T>(
|
|
39
|
-
export declare function $<T>(
|
|
37
|
+
export declare function $<T>(initialValue: undefined, options: SignalOptions<T | undefined>): Writable<T | undefined>;
|
|
38
|
+
export declare function $<T>(initialValue: T, options?: SignalOptions<T>): Writable<T>;
|
|
40
39
|
export declare function writable<T>(): Writable<T | undefined>;
|
|
41
|
-
export declare function writable<T>(
|
|
42
|
-
export declare function writable<T>(
|
|
40
|
+
export declare function writable<T>(initialValue: undefined, options: SignalOptions<T | undefined>): Writable<T | undefined>;
|
|
41
|
+
export declare function writable<T>(initialValue: T, options?: SignalOptions<T>): Writable<T>;
|
|
42
|
+
export declare function readable<T>(signal: MaybeSignal<T>): Signal<T>;
|
|
43
43
|
export interface MemoOptions<T> extends SignalOptions<T> {
|
|
44
44
|
/**
|
|
45
45
|
* An array of signals this `memo` depends on. If this is passed, calls to signals within `fn` will NOT be tracked.
|
|
@@ -48,11 +48,12 @@ export interface MemoOptions<T> extends SignalOptions<T> {
|
|
|
48
48
|
deps?: Signal<any>[];
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
|
-
* Creates a derived
|
|
51
|
+
* Creates a derived signal that recomputes its value only when its dependencies change.
|
|
52
|
+
* Subsequent calls will return a cached value.
|
|
52
53
|
* Dependencies are tracked when called inside `fn` by default,
|
|
53
54
|
* but can be overridden by passing a `deps` array in the options object.
|
|
54
55
|
*/
|
|
55
|
-
export declare function memo<T>(
|
|
56
|
+
export declare function memo<T>(compute: (previousValue?: T) => MaybeSignal<T>, options?: MemoOptions<T>): Signal<T>;
|
|
56
57
|
/**
|
|
57
58
|
* Suspends effects during `fn`. Effects for all updated Signal values are called at the end of the batch.
|
|
58
59
|
*/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Renderable } from "../../types";
|
|
2
|
+
import type { Context } from "../context";
|
|
3
|
+
import { Markup, MarkupType } from "../markup";
|
|
4
|
+
export interface PortalProps {
|
|
5
|
+
/**
|
|
6
|
+
* The parent element or a selector that will match it.
|
|
7
|
+
*/
|
|
8
|
+
into: Element | string;
|
|
9
|
+
/**
|
|
10
|
+
* Content to render inside the `into` element.
|
|
11
|
+
*/
|
|
12
|
+
children: Renderable;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Render content into any element on the page.
|
|
16
|
+
*/
|
|
17
|
+
export declare function Portal(props: PortalProps, ctx: Context): Markup<MarkupType.Portal>;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Context, Logger, type Ref, type Store } from "../core";
|
|
2
|
-
import { type EffectFn,
|
|
1
|
+
import { type Context, type Logger, type Ref, type Store } from "../core";
|
|
2
|
+
import { type EffectFn, type MaybeSignal, type Setter, type Signal, type SignalOptions } from "../core/signals";
|
|
3
3
|
/**
|
|
4
4
|
* Returns the Context object of the View, Store or Mixin this hook is called in.
|
|
5
5
|
*/
|
|
@@ -11,31 +11,47 @@ export declare function useContext(): Context;
|
|
|
11
11
|
export declare function useLogger(name?: MaybeSignal<string>): Logger;
|
|
12
12
|
/**
|
|
13
13
|
* Creates a new read-only Getter and a bound Setter function.
|
|
14
|
+
* @deprecated prefer useSignal
|
|
14
15
|
*/
|
|
15
16
|
export declare function useState<T>(value: T, options?: SignalOptions<T>): [Signal<T>, Setter<T>];
|
|
16
17
|
/**
|
|
17
18
|
* Creates a new read-only Signal and a bound Setter function.
|
|
19
|
+
* @deprecated prefer useSignal
|
|
18
20
|
*/
|
|
19
21
|
export declare function useState<T>(value: undefined, options: SignalOptions<T>): [Signal<T | undefined>, Setter<T | undefined>];
|
|
20
22
|
/**
|
|
21
23
|
* Creates a new read-only Signal and a bound Setter function.
|
|
24
|
+
* @deprecated prefer useSignal
|
|
22
25
|
*/
|
|
23
26
|
export declare function useState<T>(): [Signal<T | undefined>, Setter<T | undefined>];
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new read-only Signal. Returns bound Getter and Setter functions.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* const [$count, setCount] = useSignal(5);
|
|
32
|
+
* $count(); // 5
|
|
33
|
+
* setCount(6);
|
|
34
|
+
* setCount((current) => current + 1);
|
|
35
|
+
* $count(); // 7
|
|
36
|
+
*/
|
|
37
|
+
export declare function useSignal<T>(value: T, options?: SignalOptions<T>): [Signal<T>, Setter<T>];
|
|
38
|
+
export declare function useSignal<T>(value: undefined, options: SignalOptions<T>): [Signal<T | undefined>, Setter<T | undefined>];
|
|
39
|
+
export declare function useSignal<T>(): [Signal<T | undefined>, Setter<T | undefined>];
|
|
24
40
|
export declare function useMemo<T>(compute: (current?: T) => MaybeSignal<T>, deps?: Signal<any>[], options?: SignalOptions<T>): Signal<T>;
|
|
25
41
|
export declare function useEffect(fn: EffectFn, deps?: Signal<any>[]): void;
|
|
26
42
|
/**
|
|
27
43
|
* Takes the current state and a dispatched action. Returns a new state based on the action.
|
|
28
44
|
* Typically the body of this function will be a large switch statement.
|
|
29
45
|
*/
|
|
30
|
-
export type
|
|
46
|
+
export type Reducer<State, Action> = (state: State, action: Action) => State;
|
|
31
47
|
/**
|
|
32
48
|
* Dispatches an action to this reducer, causing the state to update.
|
|
33
49
|
*/
|
|
34
|
-
export type
|
|
50
|
+
export type Dispatcher<Action> = (action: Action) => void;
|
|
35
51
|
/**
|
|
36
52
|
*
|
|
37
53
|
*/
|
|
38
|
-
export declare function useReducer<State, Action>(reducer:
|
|
54
|
+
export declare function useReducer<State, Action>(reducer: Reducer<State, Action>, initialState: State): [Signal<State>, Dispatcher<Action>];
|
|
39
55
|
/**
|
|
40
56
|
* Uses a previously added Store. Takes the Store function itself and returns the nearest instance.
|
|
41
57
|
*/
|
package/dist/hooks.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { w as
|
|
1
|
+
import { w as c, m as f, g as i, u as a, h as x } from "./signals-CkfFHd0d.js";
|
|
2
2
|
import { r as m } from "./ref-BD79iqlg.js";
|
|
3
3
|
function o() {
|
|
4
4
|
const t = x();
|
|
@@ -10,55 +10,61 @@ function p(t) {
|
|
|
10
10
|
const e = o();
|
|
11
11
|
return t && e.setName(t), e;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function S(t, e) {
|
|
14
14
|
o();
|
|
15
|
-
const n =
|
|
15
|
+
const n = c(t, e);
|
|
16
|
+
return [() => n(), n.set];
|
|
17
|
+
}
|
|
18
|
+
function g(t, e) {
|
|
19
|
+
o();
|
|
20
|
+
const n = c(t, e);
|
|
16
21
|
return [() => n(), n.set];
|
|
17
22
|
}
|
|
18
23
|
function w(t, e, n) {
|
|
19
24
|
return o(), f(t, { ...n, deps: e });
|
|
20
25
|
}
|
|
21
|
-
function
|
|
26
|
+
function b(t, e) {
|
|
22
27
|
const n = o();
|
|
23
28
|
e ? n.effect(() => {
|
|
24
|
-
for (const
|
|
25
|
-
a(t);
|
|
29
|
+
for (const r of e) i(r);
|
|
30
|
+
return a(t);
|
|
26
31
|
}) : n.effect(t);
|
|
27
32
|
}
|
|
28
|
-
function
|
|
29
|
-
const [n,
|
|
30
|
-
return [n, (
|
|
31
|
-
|
|
33
|
+
function M(t, e) {
|
|
34
|
+
const [n, r] = g(e);
|
|
35
|
+
return [n, (u) => {
|
|
36
|
+
r((s) => t(s, u));
|
|
32
37
|
}];
|
|
33
38
|
}
|
|
34
|
-
function
|
|
39
|
+
function y(t) {
|
|
35
40
|
return o().getStore(t);
|
|
36
41
|
}
|
|
37
|
-
function
|
|
42
|
+
function C(...t) {
|
|
38
43
|
o();
|
|
39
44
|
const e = m(...t);
|
|
40
45
|
return Object.defineProperty(e, "current", { get: e, set: e }), e;
|
|
41
46
|
}
|
|
42
|
-
function
|
|
47
|
+
function R(t) {
|
|
43
48
|
const e = o();
|
|
44
49
|
e.onMount(() => {
|
|
45
50
|
const n = t();
|
|
46
51
|
n && e.onUnmount(n);
|
|
47
52
|
});
|
|
48
53
|
}
|
|
49
|
-
function
|
|
54
|
+
function U(t) {
|
|
50
55
|
o().onUnmount(t);
|
|
51
56
|
}
|
|
52
57
|
export {
|
|
53
58
|
o as useContext,
|
|
54
|
-
|
|
59
|
+
b as useEffect,
|
|
55
60
|
p as useLogger,
|
|
56
61
|
w as useMemo,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
R as useMount,
|
|
63
|
+
M as useReducer,
|
|
64
|
+
C as useRef,
|
|
65
|
+
g as useSignal,
|
|
66
|
+
S as useState,
|
|
67
|
+
y as useStore,
|
|
68
|
+
U as useUnmount
|
|
63
69
|
};
|
|
64
70
|
//# sourceMappingURL=hooks.js.map
|
package/dist/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sources":["../src/hooks/index.ts"],"sourcesContent":["import { Context, Logger, ref, type Ref, type Store } from \"../core\";\nimport {\n type EffectFn,\n get,\n getCurrentContext,\n
|
|
1
|
+
{"version":3,"file":"hooks.js","sources":["../src/hooks/index.ts"],"sourcesContent":["import { type Context, type Logger, ref, type Ref, type Store } from \"../core\";\nimport {\n type EffectFn,\n get,\n getCurrentContext,\n type MaybeSignal,\n memo,\n type Setter,\n type Signal,\n type SignalOptions,\n untracked,\n writable,\n} from \"../core/signals\";\n\n/**\n * Returns the Context object of the View, Store or Mixin this hook is called in.\n */\nexport function useContext(): Context {\n const context = getCurrentContext();\n if (!context) {\n throw new Error(`No context found; hooks can only be called in the body of a View, Store or Mixin.`);\n }\n return context;\n}\n\n/**\n * Returns a logger. If a name is passed it will be used as a prefix for all console messages.\n * Otherwise the default name of the context will be used.\n */\nexport function useLogger(name?: MaybeSignal<string>): Logger {\n const context = useContext();\n if (name) context.setName(name);\n return context;\n}\n\n/**\n * Creates a new read-only Getter and a bound Setter function.\n * @deprecated prefer useSignal\n */\nexport function useState<T>(value: T, options?: SignalOptions<T>): [Signal<T>, Setter<T>];\n\n/**\n * Creates a new read-only Signal and a bound Setter function.\n * @deprecated prefer useSignal\n */\nexport function useState<T>(\n value: undefined,\n options: SignalOptions<T>,\n): [Signal<T | undefined>, Setter<T | undefined>];\n\n/**\n * Creates a new read-only Signal and a bound Setter function.\n * @deprecated prefer useSignal\n */\nexport function useState<T>(): [Signal<T | undefined>, Setter<T | undefined>];\n\nexport function useState<T>(value?: T, options?: SignalOptions<T>): [Signal<T>, Setter<T>] {\n useContext(); // assert that we're in a valid context\n const state = writable(value as T, options);\n return [() => state(), state.set];\n}\n\n/**\n * Creates a new read-only Signal. Returns bound Getter and Setter functions.\n *\n * @example\n * const [$count, setCount] = useSignal(5);\n * $count(); // 5\n * setCount(6);\n * setCount((current) => current + 1);\n * $count(); // 7\n */\nexport function useSignal<T>(value: T, options?: SignalOptions<T>): [Signal<T>, Setter<T>];\n\nexport function useSignal<T>(\n value: undefined,\n options: SignalOptions<T>,\n): [Signal<T | undefined>, Setter<T | undefined>];\n\nexport function useSignal<T>(): [Signal<T | undefined>, Setter<T | undefined>];\n\nexport function useSignal<T>(value?: T, options?: SignalOptions<T>): [Signal<T>, Setter<T>] {\n useContext(); // assert that we're in a valid context\n const signal = writable(value as T, options);\n return [() => signal(), signal.set];\n}\n\nexport function useMemo<T>(\n compute: (current?: T) => MaybeSignal<T>,\n deps?: Signal<any>[],\n options?: SignalOptions<T>,\n): Signal<T> {\n useContext(); // assert that we're in a valid context\n return memo(compute, { ...options, deps });\n}\n\nexport function useEffect(fn: EffectFn, deps?: Signal<any>[]): void {\n const context = useContext();\n if (deps) {\n context.effect(() => {\n for (const dep of deps) get(dep);\n return untracked(fn);\n });\n } else {\n context.effect(fn);\n }\n}\n\n/**\n * Takes the current state and a dispatched action. Returns a new state based on the action.\n * Typically the body of this function will be a large switch statement.\n */\nexport type Reducer<State, Action> = (state: State, action: Action) => State;\n\n/**\n * Dispatches an action to this reducer, causing the state to update.\n */\nexport type Dispatcher<Action> = (action: Action) => void;\n\n/**\n *\n */\nexport function useReducer<State, Action>(\n reducer: Reducer<State, Action>,\n initialState: State,\n): [Signal<State>, Dispatcher<Action>] {\n const [$state, setState] = useSignal(initialState);\n const dispatch = (action: Action) => {\n setState((current) => reducer(current, action));\n };\n return [$state, dispatch];\n}\n\n/**\n * Uses a previously added Store. Takes the Store function itself and returns the nearest instance.\n */\nexport function useStore<T>(store: Store<any, T>): T {\n const context = useContext();\n return context.getStore(store);\n}\n\n/**\n * A hybrid Ref which is both a function ref and a React-style object ref with a `current` property.\n * Both the `current` property and the function syntax access the same value.\n */\nexport interface HybridRef<T> extends Ref<T> {\n current: T;\n}\n\n/**\n * Creates a Ref. Useful for getting references to DOM nodes.\n */\nexport function useRef<T>(initialValue?: T): HybridRef<T>;\n\nexport function useRef<T>(...value: [T]): HybridRef<T> {\n useContext(); // assert that we're in a valid context\n const valueRef = ref(...value);\n Object.defineProperty(valueRef, \"current\", { get: valueRef, set: valueRef });\n return valueRef as HybridRef<T>;\n}\n\n/**\n * Calls `callback` when the context is mounted. If `callback` returns a function, that function is called when the context is unmounted.\n */\nexport function useMount(callback: () => void | (() => void)): void {\n const context = useContext();\n context.onMount(() => {\n const result = callback();\n if (result) context.onUnmount(result);\n });\n}\n\n/**\n * Calls `callback` when the context is unmounted.\n */\nexport function useUnmount(callback: () => void): void {\n const context = useContext();\n context.onUnmount(callback);\n}\n"],"names":["useContext","context","getCurrentContext","useLogger","name","useState","value","options","state","writable","useSignal","signal","useMemo","compute","deps","memo","useEffect","fn","dep","get","untracked","useReducer","reducer","initialState","$state","setState","action","current","useStore","store","useRef","valueRef","ref","useMount","callback","result","useUnmount"],"mappings":";;AAiBO,SAASA,IAAsB;AACpC,QAAMC,IAAUC,EAAkB;AAClC,MAAI,CAACD;AACG,UAAA,IAAI,MAAM,mFAAmF;AAE9F,SAAAA;AACT;AAMO,SAASE,EAAUC,GAAoC;AAC5D,QAAMH,IAAUD,EAAW;AACvB,SAAAI,KAAcH,EAAA,QAAQG,CAAI,GACvBH;AACT;AAuBgB,SAAAI,EAAYC,GAAWC,GAAoD;AAC9E,EAAAP,EAAA;AACL,QAAAQ,IAAQC,EAASH,GAAYC,CAAO;AAC1C,SAAO,CAAC,MAAMC,KAASA,EAAM,GAAG;AAClC;AAqBgB,SAAAE,EAAaJ,GAAWC,GAAoD;AAC/E,EAAAP,EAAA;AACL,QAAAW,IAASF,EAASH,GAAYC,CAAO;AAC3C,SAAO,CAAC,MAAMI,KAAUA,EAAO,GAAG;AACpC;AAEgB,SAAAC,EACdC,GACAC,GACAP,GACW;AACA,SAAAP,EAAA,GACJe,EAAKF,GAAS,EAAE,GAAGN,GAAS,MAAAO,GAAM;AAC3C;AAEgB,SAAAE,EAAUC,GAAcH,GAA4B;AAClE,QAAMb,IAAUD,EAAW;AAC3B,EAAIc,IACFb,EAAQ,OAAO,MAAM;AACR,eAAAiB,KAAOJ,EAAM,CAAAK,EAAID,CAAG;AAC/B,WAAOE,EAAUH,CAAE;AAAA,EAAA,CACpB,IAEDhB,EAAQ,OAAOgB,CAAE;AAErB;AAgBgB,SAAAI,EACdC,GACAC,GACqC;AACrC,QAAM,CAACC,GAAQC,CAAQ,IAAIf,EAAUa,CAAY;AAI1C,SAAA,CAACC,GAHS,CAACE,MAAmB;AACnC,IAAAD,EAAS,CAACE,MAAYL,EAAQK,GAASD,CAAM,CAAC;AAAA,EAChD,CACwB;AAC1B;AAKO,SAASE,EAAYC,GAAyB;AAE5C,SADS7B,EAAW,EACZ,SAAS6B,CAAK;AAC/B;AAeO,SAASC,KAAaxB,GAA0B;AAC1C,EAAAN,EAAA;AACL,QAAA+B,IAAWC,EAAI,GAAG1B,CAAK;AACtB,gBAAA,eAAeyB,GAAU,WAAW,EAAE,KAAKA,GAAU,KAAKA,GAAU,GACpEA;AACT;AAKO,SAASE,EAASC,GAA2C;AAClE,QAAMjC,IAAUD,EAAW;AAC3B,EAAAC,EAAQ,QAAQ,MAAM;AACpB,UAAMkC,IAASD,EAAS;AACpB,IAAAC,KAAgBlC,EAAA,UAAUkC,CAAM;AAAA,EAAA,CACrC;AACH;AAKO,SAASC,EAAWF,GAA4B;AAErD,EADgBlC,EAAW,EACnB,UAAUkC,CAAQ;AAC5B;"}
|
package/dist/http.js
CHANGED
|
@@ -6,7 +6,7 @@ var g = (r, e, t) => e in r ? b(r, e, { enumerable: !0, configurable: !0, writab
|
|
|
6
6
|
var a = (r, e, t) => g(r, typeof e != "symbol" ? e + "" : e, t), m = (r, e, t) => e.has(r) || f("Cannot " + t);
|
|
7
7
|
var d = (r, e, t) => (m(r, e, "read from private field"), t ? t.call(r) : e.get(r)), c = (r, e, t) => e.has(r) ? f("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t);
|
|
8
8
|
var o = (r, e, t) => (m(r, e, "access private method"), t);
|
|
9
|
-
import {
|
|
9
|
+
import { a as w } from "./typeChecking-_dGK_0uR.js";
|
|
10
10
|
var l, p, i, h;
|
|
11
11
|
class O {
|
|
12
12
|
constructor() {
|
package/dist/i18n.js
CHANGED
|
@@ -5,9 +5,9 @@ var D = (o) => {
|
|
|
5
5
|
var J = (o, t, e) => t in o ? B(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
6
6
|
var O = (o, t, e) => J(o, typeof t != "symbol" ? t + "" : t, e), _ = (o, t, e) => t.has(o) || D("Cannot " + e);
|
|
7
7
|
var r = (o, t, e) => (_(o, t, "read from private field"), e ? e.call(o) : t.get(o)), m = (o, t, e) => t.has(o) ? D("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(o) : t.set(o, e), N = (o, t, e, n) => (_(o, t, "write to private field"), n ? n.call(o, e) : t.set(o, e), e), g = (o, t, e) => (_(o, t, "access private method"), e);
|
|
8
|
-
import { c as K } from "./logger-
|
|
9
|
-
import { w as Q, m as k, d as U, g as x } from "./signals-
|
|
10
|
-
import {
|
|
8
|
+
import { c as K } from "./logger-CmXtRdEI.js";
|
|
9
|
+
import { w as Q, m as k, d as U, g as x } from "./signals-CkfFHd0d.js";
|
|
10
|
+
import { i as C, a as j, b as W, t as P } from "./typeChecking-_dGK_0uR.js";
|
|
11
11
|
var I, F, p, S, G;
|
|
12
12
|
class X {
|
|
13
13
|
constructor(t) {
|