@epoch32/visage 1.0.0 → 1.1.1
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/api/client.d.ts +5 -0
- package/dist/api/file-router.d.ts +29 -0
- package/dist/api/handler.d.ts +15 -0
- package/dist/api/index.d.ts +12 -0
- package/dist/{src/api → api}/index.js +87 -2
- package/dist/api/middleware.d.ts +11 -0
- package/dist/api/pragma.d.ts +21 -0
- package/dist/api/procedure.d.ts +66 -0
- package/dist/api/types.d.ts +181 -0
- package/dist/charts/Area.d.ts +18 -0
- package/dist/charts/Axis.d.ts +21 -0
- package/dist/charts/Bar.d.ts +10 -0
- package/dist/charts/CartesianGrid.d.ts +10 -0
- package/dist/charts/Chart.d.ts +16 -0
- package/dist/charts/Cursor.d.ts +8 -0
- package/dist/charts/Legend.d.ts +9 -0
- package/dist/charts/Line.d.ts +18 -0
- package/dist/charts/Pie.d.ts +12 -0
- package/dist/charts/Tooltip.d.ts +12 -0
- package/dist/charts/context.d.ts +20 -0
- package/dist/charts/index.d.ts +14 -0
- package/dist/{src/charts → charts}/index.js +87 -2
- package/dist/charts/path.d.ts +27 -0
- package/dist/charts/scale.d.ts +23 -0
- package/dist/charts/types.d.ts +43 -0
- package/dist/devtools/DomTab.d.ts +6 -0
- package/dist/devtools/GraphInspector.d.ts +11 -0
- package/dist/devtools/GraphTab.d.ts +10 -0
- package/dist/devtools/QueryTab.d.ts +10 -0
- package/dist/devtools/RpcTab.d.ts +10 -0
- package/dist/devtools/SignalsTab.d.ts +10 -0
- package/dist/devtools/component.d.ts +2 -0
- package/dist/devtools/highlighter.d.ts +2 -0
- package/dist/devtools/hub.d.ts +41 -0
- package/dist/devtools/index.d.ts +9 -0
- package/dist/{src/devtools → devtools}/index.js +87 -2
- package/dist/devtools/styles.d.ts +1 -0
- package/dist/devtools/types.d.ts +44 -0
- package/dist/dom/async.d.ts +41 -0
- package/dist/dom/control-flow.d.ts +53 -0
- package/dist/dom/index.d.ts +3 -0
- package/dist/{src/dom → dom}/index.js +87 -2
- package/dist/dom/lazy.d.ts +30 -0
- package/dist/dom/render.d.ts +23 -0
- package/dist/dom/resource.d.ts +34 -0
- package/dist/form/form.d.ts +41 -0
- package/dist/form/index.d.ts +2 -0
- package/dist/{src/form → form}/index.js +87 -2
- package/dist/form/schema.d.ts +96 -0
- package/dist/index.d.ts +15 -0
- package/dist/{src/index.js → index.js} +87 -2
- package/dist/jsx-dev-runtime/index.d.ts +1 -0
- package/dist/jsx-runtime/index.d.ts +8 -0
- package/dist/{src/jsx-runtime → jsx-runtime}/index.js +87 -2
- package/dist/jsx-runtime/jsx.d.ts +278 -0
- package/dist/query/create-mutation.d.ts +3 -0
- package/dist/query/create-query.d.ts +4 -0
- package/dist/query/focus-manager.d.ts +14 -0
- package/dist/query/index.d.ts +9 -0
- package/dist/{src/query → query}/index.js +87 -2
- package/dist/query/mutation-cache.d.ts +24 -0
- package/dist/query/online-manager.d.ts +14 -0
- package/dist/query/query-cache.d.ts +69 -0
- package/dist/query/query-client.d.ts +46 -0
- package/dist/query/types.d.ts +131 -0
- package/dist/query/utils.d.ts +16 -0
- package/dist/router/index.d.ts +1 -0
- package/dist/{src/router → router}/index.js +87 -2
- package/dist/router/router.d.ts +91 -0
- package/dist/rpc/client.d.ts +2 -0
- package/dist/rpc/error.d.ts +16 -0
- package/dist/rpc/index.d.ts +7 -0
- package/dist/{src/rpc → rpc}/index.js +87 -2
- package/dist/rpc/procedure.d.ts +8 -0
- package/dist/rpc/router.d.ts +19 -0
- package/dist/rpc/server.d.ts +3 -0
- package/dist/rpc/types.d.ts +200 -0
- package/dist/server/hydrate.d.ts +5 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/{src/server → server}/index.js +87 -2
- package/dist/server/render-to-stream.d.ts +9 -0
- package/dist/server/render-to-string.d.ts +6 -0
- package/dist/signals/computed.d.ts +61 -0
- package/dist/signals/context.d.ts +44 -0
- package/dist/signals/effect.d.ts +56 -0
- package/dist/signals/index.d.ts +8 -0
- package/dist/{src/signals → signals}/index.js +87 -2
- package/dist/signals/scope.d.ts +61 -0
- package/dist/signals/signal.d.ts +40 -0
- package/dist/signals/store.d.ts +45 -0
- package/dist/signals/system.d.ts +56 -0
- package/dist/signals/types.d.ts +58 -0
- package/dist/style/component.d.ts +49 -0
- package/dist/style/create-style.d.ts +63 -0
- package/dist/style/cx.d.ts +18 -0
- package/dist/style/hash.d.ts +8 -0
- package/dist/style/index.d.ts +8 -0
- package/dist/{src/style → style}/index.js +87 -2
- package/dist/style/layout.d.ts +129 -0
- package/dist/style/manager.d.ts +31 -0
- package/dist/style/parser.d.ts +12 -0
- package/dist/style/scale.d.ts +82 -0
- package/dist/template/index.d.ts +1 -0
- package/dist/{src/template → template}/index.js +87 -2
- package/dist/template/template.d.ts +8 -0
- package/dist/ui/accordion.d.ts +81 -0
- package/dist/ui/command-dialog.d.ts +10 -0
- package/dist/ui/command.d.ts +103 -0
- package/dist/ui/data-table.d.ts +38 -0
- package/dist/ui/dialog.d.ts +102 -0
- package/dist/ui/dropdown-menu.d.ts +92 -0
- package/dist/ui/icon.d.ts +18 -0
- package/dist/ui/index.d.ts +14 -0
- package/dist/{src/ui → ui}/index.js +87 -2
- package/dist/ui/layout.d.ts +1 -0
- package/dist/ui/popover.d.ts +68 -0
- package/dist/ui/switch.d.ts +31 -0
- package/dist/ui/tabs.d.ts +71 -0
- package/dist/ui/toast.d.ts +91 -0
- package/dist/ui/tooltip.d.ts +64 -0
- package/dist/ui/utils.d.ts +21 -0
- package/dist/virtual/index.d.ts +2 -0
- package/dist/{src/virtual → virtual}/index.js +87 -2
- package/dist/virtual/virtual-list.d.ts +21 -0
- package/dist/virtual/virtualizer.d.ts +31 -0
- package/dist/vite/hmr.d.ts +7 -0
- package/dist/vite/index.d.ts +3 -0
- package/dist/{src/vite → vite}/index.js +4 -0
- package/dist/vite/lucide.d.ts +27 -0
- package/dist/vite/plugin.d.ts +3 -0
- package/dist/vite/rpc-middleware.d.ts +5 -0
- package/dist/vite/types.d.ts +59 -0
- package/package.json +40 -40
- package/src/signals/index.ts +1 -0
- package/src/signals/signal.ts +110 -2
- package/src/signals/types.ts +9 -0
- package/src/vite/plugin.ts +4 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { CleanupFn, ISubscriber } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Reactive Scope for lifecycle and automatic memory management
|
|
4
|
+
*/
|
|
5
|
+
export declare class Scope {
|
|
6
|
+
subscribers: Set<ISubscriber>;
|
|
7
|
+
cleanups: CleanupFn[];
|
|
8
|
+
parent: Scope | null;
|
|
9
|
+
isDisposed: boolean;
|
|
10
|
+
context?: Map<symbol, any>;
|
|
11
|
+
constructor(parent?: Scope | null);
|
|
12
|
+
addSubscriber(sub: ISubscriber): void;
|
|
13
|
+
addCleanup(fn: CleanupFn): void;
|
|
14
|
+
dispose(): void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Register a cleanup callback for the current running effect or active scope.
|
|
18
|
+
*
|
|
19
|
+
* Runs automatically when the enclosing component/scope unmounts or before
|
|
20
|
+
* the effect re-executes.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* function TimerComponent() {
|
|
25
|
+
* const id = setInterval(() => console.log("tick"), 1000);
|
|
26
|
+
* onCleanup(() => clearInterval(id));
|
|
27
|
+
* return <div>Timer running</div>;
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function onCleanup(fn: CleanupFn): void;
|
|
32
|
+
/**
|
|
33
|
+
* Create an isolated reactive root scope that outlives the current execution context.
|
|
34
|
+
*
|
|
35
|
+
* Computations and signals created inside `fn` will not be tied to any parent scope
|
|
36
|
+
* and will persist until the provided `dispose` callback is invoked.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* const dispose = createRoot((dispose) => {
|
|
41
|
+
* const count = signal(0);
|
|
42
|
+
* effect(() => console.log(count()));
|
|
43
|
+
* return dispose;
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* // Later, dispose of all memory & subscribers
|
|
47
|
+
* dispose();
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @param fn - A factory function receiving the `dispose` callback
|
|
51
|
+
* @returns The return value of `fn`
|
|
52
|
+
*/
|
|
53
|
+
export declare function createRoot<T>(fn: (dispose: () => void) => T): T;
|
|
54
|
+
/**
|
|
55
|
+
* Run a function with a specified reactive scope active.
|
|
56
|
+
*/
|
|
57
|
+
export declare function runInScope<T>(scope: Scope | null, fn: () => T): T;
|
|
58
|
+
/**
|
|
59
|
+
* Get the currently active reactive scope.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getActiveScope(): Scope | null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type IDependency, type ISubscriber, type ReadonlySignal, SIGNAL_BRAND, type SignalOptions, type WritableSignal } from "./types";
|
|
2
|
+
export type { SignalOptions };
|
|
3
|
+
/**
|
|
4
|
+
* Core Writable Signal implementation
|
|
5
|
+
*/
|
|
6
|
+
export declare class Signal<T> implements IDependency {
|
|
7
|
+
[SIGNAL_BRAND]: true;
|
|
8
|
+
private _value;
|
|
9
|
+
private _subscribers;
|
|
10
|
+
private _equals;
|
|
11
|
+
private _onSet?;
|
|
12
|
+
version: number;
|
|
13
|
+
constructor(initialValue: T, equals?: (a: T, b: T) => boolean, onSet?: (val: T) => void);
|
|
14
|
+
get(): T;
|
|
15
|
+
set(newValue: T): void;
|
|
16
|
+
update(fn: (prev: T) => T): void;
|
|
17
|
+
get value(): T;
|
|
18
|
+
set value(val: T);
|
|
19
|
+
removeSubscriber(sub: ISubscriber): void;
|
|
20
|
+
private notify;
|
|
21
|
+
}
|
|
22
|
+
export declare function signal<T>(initialValue: T, optionsOrEquals?: ((a: T, b: T) => boolean) | SignalOptions<T>): WritableSignal<T>;
|
|
23
|
+
/**
|
|
24
|
+
* Tuple-based signal constructor returning `[getter, setter]` (Solid / Preact Signals convention).
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* const [count, setCount] = createSignal(0);
|
|
29
|
+
*
|
|
30
|
+
* setCount(5);
|
|
31
|
+
* setCount(prev => prev + 1);
|
|
32
|
+
*
|
|
33
|
+
* <div>Count: {count}</div>
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @param initialValue - The initial value stored in the signal
|
|
37
|
+
* @param optionsOrEquals - Custom equality comparison function or SignalOptions
|
|
38
|
+
* @returns A tuple containing `[ReadonlySignal<T>, (value: T | ((prev: T) => T)) => void]`
|
|
39
|
+
*/
|
|
40
|
+
export declare function createSignal<T>(initialValue: T, optionsOrEquals?: ((a: T, b: T) => boolean) | SignalOptions<T>): [ReadonlySignal<T>, (value: T | ((prev: T) => T)) => void];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type Store<T> = T;
|
|
2
|
+
/**
|
|
3
|
+
* Create a deep reactive proxy store with per-property fine-grained signal tracking.
|
|
4
|
+
*
|
|
5
|
+
* Nested objects and arrays are lazily wrapped in reactive proxies. Reading a property
|
|
6
|
+
* tracks that exact key, and updating a property only notifies computations observing that key.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const state = createStore({
|
|
11
|
+
* user: { name: "Alice", role: "admin" },
|
|
12
|
+
* items: ["Apple", "Banana"]
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* // Fine-grained read
|
|
16
|
+
* <div>User: {() => state.user.name}</div>
|
|
17
|
+
*
|
|
18
|
+
* // Fine-grained write (mutates only user.name subscribers)
|
|
19
|
+
* state.user.name = "Bob";
|
|
20
|
+
* state.items.push("Cherry");
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param initialState - An object or array representing the initial state tree
|
|
24
|
+
* @returns A deeply reactive proxy store
|
|
25
|
+
*/
|
|
26
|
+
export declare function createStore<T extends object>(initialState: T): Store<T>;
|
|
27
|
+
/**
|
|
28
|
+
* Mutate a store inside a synchronous batch operation.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* mutateStore(state, (draft) => {
|
|
33
|
+
* draft.user.name = "Charlie";
|
|
34
|
+
* draft.user.role = "user";
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function mutateStore<T extends object>(store: Store<T>, mutator: (draft: T) => void): void;
|
|
39
|
+
/**
|
|
40
|
+
* Unwrap a reactive proxy store to get the underlying raw, un-proxied JavaScript object.
|
|
41
|
+
*
|
|
42
|
+
* @param store - The reactive store proxy
|
|
43
|
+
* @returns The raw underlying object
|
|
44
|
+
*/
|
|
45
|
+
export declare function unwrapStore<T>(store: T): T;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visage Reactivity System Execution Context & Scheduler
|
|
3
|
+
*/
|
|
4
|
+
import { type ISubscriber } from "./types";
|
|
5
|
+
export declare let currentSubscriber: ISubscriber | null;
|
|
6
|
+
export declare let currentScope: any;
|
|
7
|
+
export declare let batchDepth: number;
|
|
8
|
+
export declare const pendingEffects: Set<any>;
|
|
9
|
+
export declare const warnedCyclicSubscribers: WeakSet<ISubscriber>;
|
|
10
|
+
export declare let isFlushing: boolean;
|
|
11
|
+
export declare function setCurrentSubscriber(sub: ISubscriber | null): void;
|
|
12
|
+
export declare function getCurrentSubscriber(): ISubscriber | null;
|
|
13
|
+
export declare function setCurrentScope(scope: any): void;
|
|
14
|
+
export declare function getCurrentScope(): any;
|
|
15
|
+
export declare function addPendingEffect(eff: any): void;
|
|
16
|
+
export declare function removePendingEffect(eff: any): void;
|
|
17
|
+
export declare function flushEffects(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Batch multiple signal mutations so downstreams and effects update synchronously once at completion.
|
|
20
|
+
*
|
|
21
|
+
* Prevents intermediate flicker, wasted recomputations, and glitch states.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* const firstName = signal("Jane");
|
|
26
|
+
* const lastName = signal("Doe");
|
|
27
|
+
*
|
|
28
|
+
* batch(() => {
|
|
29
|
+
* firstName.set("John");
|
|
30
|
+
* lastName.set("Smith");
|
|
31
|
+
* // Downstream computed and effects run only ONCE here
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @param fn - A function performing multiple signal updates
|
|
36
|
+
* @returns The return value of `fn`
|
|
37
|
+
*/
|
|
38
|
+
export declare function batch<T>(fn: () => T): T;
|
|
39
|
+
/**
|
|
40
|
+
* Read reactive state without subscribing the current active effect or computed computation.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* effect(() => {
|
|
45
|
+
* const id = currentId(); // Subscribed: effect re-runs when currentId changes
|
|
46
|
+
*
|
|
47
|
+
* // Not subscribed: effect does NOT re-run when analyticsCounter changes
|
|
48
|
+
* const count = untrack(() => analyticsCounter());
|
|
49
|
+
* sendMetric(id, count);
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @param fn - A function reading reactive signals without tracking
|
|
54
|
+
* @returns The return value of `fn`
|
|
55
|
+
*/
|
|
56
|
+
export declare function untrack<T>(fn: () => T): T;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visage Fine-Grained Reactive Engine Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
export type CleanupFn = () => void;
|
|
5
|
+
export declare enum SubscriberState {
|
|
6
|
+
CLEAN = 0,
|
|
7
|
+
CHECK_DIRTY = 1,
|
|
8
|
+
DIRTY = 2,
|
|
9
|
+
DISPOSED = 3
|
|
10
|
+
}
|
|
11
|
+
export declare const SIGNAL_BRAND: unique symbol;
|
|
12
|
+
export declare const COMPUTED_BRAND: unique symbol;
|
|
13
|
+
export interface ReadonlySignal<T> {
|
|
14
|
+
get(): T;
|
|
15
|
+
readonly value: T;
|
|
16
|
+
(): T;
|
|
17
|
+
readonly [SIGNAL_BRAND]: true;
|
|
18
|
+
}
|
|
19
|
+
export interface WritableSignal<T> extends ReadonlySignal<T> {
|
|
20
|
+
set(value: T): void;
|
|
21
|
+
update(fn: (prev: T) => T): void;
|
|
22
|
+
(value?: T): T;
|
|
23
|
+
value: T;
|
|
24
|
+
}
|
|
25
|
+
export interface PersistOptions<T> {
|
|
26
|
+
key: string;
|
|
27
|
+
storage?: "local" | "session" | Storage;
|
|
28
|
+
serialize?: (value: T) => string;
|
|
29
|
+
deserialize?: (raw: string) => T;
|
|
30
|
+
syncTabs?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface SignalOptions<T> {
|
|
33
|
+
name?: string;
|
|
34
|
+
equals?: (a: T, b: T) => boolean;
|
|
35
|
+
internal?: boolean;
|
|
36
|
+
persist?: string | PersistOptions<T>;
|
|
37
|
+
}
|
|
38
|
+
export interface ComputedOptions {
|
|
39
|
+
name?: string;
|
|
40
|
+
internal?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Check if a value is a Visage signal or computed
|
|
44
|
+
*/
|
|
45
|
+
export declare function isSignal<T = unknown>(value: unknown): value is ReadonlySignal<T>;
|
|
46
|
+
export interface ISubscriber {
|
|
47
|
+
state: SubscriberState;
|
|
48
|
+
sources: Set<IDependency>;
|
|
49
|
+
sourceVersions: Map<IDependency, number>;
|
|
50
|
+
markDirty(targetState?: SubscriberState): void;
|
|
51
|
+
dispose(): void;
|
|
52
|
+
}
|
|
53
|
+
export interface IDependency {
|
|
54
|
+
version: number;
|
|
55
|
+
removeSubscriber(sub: ISubscriber): void;
|
|
56
|
+
}
|
|
57
|
+
export type Subscriber = ISubscriber;
|
|
58
|
+
export type Dependency = IDependency;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Child } from "../dom/render";
|
|
2
|
+
import { type StyleDefinition } from "./create-style";
|
|
3
|
+
export interface StyleProps {
|
|
4
|
+
children?: string | StyleDefinition | (() => string | StyleDefinition);
|
|
5
|
+
classes?: StyleDefinition | (() => StyleDefinition);
|
|
6
|
+
passToChildren?: boolean;
|
|
7
|
+
id?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Scoped Component Style Block
|
|
11
|
+
*
|
|
12
|
+
* Automatically hashes and scopes CSS rules to the parent component/container,
|
|
13
|
+
* preventing style leaks and collisions. Supports CSS strings or JavaScript style objects.
|
|
14
|
+
*
|
|
15
|
+
* Examples:
|
|
16
|
+
*
|
|
17
|
+
* 1. Object syntax:
|
|
18
|
+
* ```tsx
|
|
19
|
+
* export function Card(props) {
|
|
20
|
+
* return (
|
|
21
|
+
* <div class="card">
|
|
22
|
+
* <h2>{props.title}</h2>
|
|
23
|
+
* <Style classes={{
|
|
24
|
+
* card: { background: "var(--card-bg)", padding: "20px", borderRadius: "8px" },
|
|
25
|
+
* "& h2": { fontSize: "1.2rem", color: "var(--text)" }
|
|
26
|
+
* }} />
|
|
27
|
+
* </div>
|
|
28
|
+
* );
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* 2. Component Scoped CSS string:
|
|
33
|
+
* ```tsx
|
|
34
|
+
* export function StepItem(props) {
|
|
35
|
+
* return (
|
|
36
|
+
* <div class="step-node">
|
|
37
|
+
* <span class="step-num">{props.step}</span>
|
|
38
|
+
* <span>{props.title}</span>
|
|
39
|
+
*
|
|
40
|
+
* <Style>{`
|
|
41
|
+
* .step-node { display: flex; align-items: center; gap: 8px; }
|
|
42
|
+
* .step-num { font-weight: 600; color: var(--primary); }
|
|
43
|
+
* `}</Style>
|
|
44
|
+
* </div>
|
|
45
|
+
* );
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function Style(props: StyleProps): Child;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type * as CSS from "csstype";
|
|
2
|
+
import { type ClassValue } from "./cx";
|
|
3
|
+
/**
|
|
4
|
+
* Standard CSS Properties interface with full TypeScript & VS Code IntelliSense,
|
|
5
|
+
* supporting nested pseudo-classes, descendant selectors, and custom CSS variables.
|
|
6
|
+
*/
|
|
7
|
+
export type CSSProperties = CSS.Properties<string | number> & {
|
|
8
|
+
[key: `&${string}`]: CSSProperties | undefined;
|
|
9
|
+
[key: `.${string}`]: CSSProperties | undefined;
|
|
10
|
+
[key: `:${string}`]: CSSProperties | undefined;
|
|
11
|
+
[key: `@media${string}`]: CSSProperties | undefined;
|
|
12
|
+
[key: `@keyframes${string}`]: Record<string, CSSProperties> | undefined;
|
|
13
|
+
[key: `${number}%`]: CSSProperties | undefined;
|
|
14
|
+
from?: CSSProperties;
|
|
15
|
+
to?: CSSProperties;
|
|
16
|
+
[customProp: `--${string}`]: string | number | undefined;
|
|
17
|
+
};
|
|
18
|
+
export type StyleDefinition = Record<string, CSSProperties>;
|
|
19
|
+
export type StyleClasses<T extends string = string> = {
|
|
20
|
+
[K in T]: string;
|
|
21
|
+
} & Record<string, any> & {
|
|
22
|
+
scope: string;
|
|
23
|
+
scopeAttr: string;
|
|
24
|
+
css: string;
|
|
25
|
+
cx: (...args: ClassValue[]) => string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Convert a JavaScript object style dictionary into standard CSS
|
|
29
|
+
*/
|
|
30
|
+
export declare function objectToCSS(classes: Record<string, any>): string;
|
|
31
|
+
/**
|
|
32
|
+
* Define scoped CSS styles with type-safe class name mappings
|
|
33
|
+
*
|
|
34
|
+
* Supports tagged template literals, string CSS, or JavaScript style objects:
|
|
35
|
+
*
|
|
36
|
+
* 1. Object syntax with full VS Code CSS IntelliSense:
|
|
37
|
+
* ```tsx
|
|
38
|
+
* const styles = createStyle({
|
|
39
|
+
* card: { background: "var(--card-bg)", padding: "16px", display: "flex" },
|
|
40
|
+
* button: { background: "var(--primary)", "&:hover": { background: "var(--primary-hover)" } }
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* 2. Tagged template literal syntax:
|
|
45
|
+
* ```tsx
|
|
46
|
+
* const styles = createStyle`
|
|
47
|
+
* .card { padding: 16px; border-radius: 8px; }
|
|
48
|
+
* .active { color: var(--primary); }
|
|
49
|
+
* `;
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function createStyle<T extends string = string>(templateOrObject: string | TemplateStringsArray | StyleDefinition, ...valuesOrOptions: any[]): StyleClasses<T>;
|
|
53
|
+
/**
|
|
54
|
+
* Tagged template for defining a single scoped CSS class
|
|
55
|
+
*/
|
|
56
|
+
export declare function css(strings: TemplateStringsArray, ...values: any[]): string;
|
|
57
|
+
/**
|
|
58
|
+
* Hook to inject dynamic or component-level CSS with automatic cleanup
|
|
59
|
+
*/
|
|
60
|
+
export declare function useStyle(cssInput: string | StyleDefinition | (() => string | StyleDefinition), options?: {
|
|
61
|
+
passToChildren?: boolean;
|
|
62
|
+
id?: string;
|
|
63
|
+
}): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type ClassValue = string | number | boolean | null | undefined | (() => any) | ClassValue[] | Record<string, any>;
|
|
2
|
+
/**
|
|
3
|
+
* Check if a class value tree contains any reactive signal or function getters
|
|
4
|
+
*/
|
|
5
|
+
export declare function hasReactiveClass(val: any): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Normalize dynamic classes from strings, numbers, arrays, and objects
|
|
8
|
+
*/
|
|
9
|
+
export declare function normalizeClass(val: any): string;
|
|
10
|
+
/**
|
|
11
|
+
* Flexible classnames utility for combining conditional classes
|
|
12
|
+
*
|
|
13
|
+
* Example:
|
|
14
|
+
* ```ts
|
|
15
|
+
* cx("btn", { active: isActive(), disabled: !isEnabled() }, ["extra-1", extraClass])
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function cx(...args: ClassValue[]): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fast 32-bit FNV-1a deterministic string hashing algorithm
|
|
3
|
+
*/
|
|
4
|
+
export declare function hashString(str: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Generate a deterministic scope identifier for CSS blocks
|
|
7
|
+
*/
|
|
8
|
+
export declare function getScopeId(css: string, prefix?: string): string;
|
|
@@ -848,10 +848,12 @@ class Signal {
|
|
|
848
848
|
_value;
|
|
849
849
|
_subscribers = new Set;
|
|
850
850
|
_equals;
|
|
851
|
+
_onSet;
|
|
851
852
|
version = 0;
|
|
852
|
-
constructor(initialValue, equals) {
|
|
853
|
+
constructor(initialValue, equals, onSet) {
|
|
853
854
|
this._value = initialValue;
|
|
854
855
|
this._equals = equals ?? Object.is;
|
|
856
|
+
this._onSet = onSet;
|
|
855
857
|
}
|
|
856
858
|
get() {
|
|
857
859
|
if (currentSubscriber !== null && currentSubscriber.state !== 3 /* DISPOSED */) {
|
|
@@ -876,6 +878,9 @@ class Signal {
|
|
|
876
878
|
}
|
|
877
879
|
this._value = newValue;
|
|
878
880
|
this.version++;
|
|
881
|
+
if (this._onSet) {
|
|
882
|
+
this._onSet(newValue);
|
|
883
|
+
}
|
|
879
884
|
batch(() => {
|
|
880
885
|
this.notify();
|
|
881
886
|
});
|
|
@@ -901,11 +906,91 @@ class Signal {
|
|
|
901
906
|
}
|
|
902
907
|
}
|
|
903
908
|
}
|
|
909
|
+
function resolveStorage(storageOption) {
|
|
910
|
+
if (storageOption && typeof storageOption === "object") {
|
|
911
|
+
return storageOption;
|
|
912
|
+
}
|
|
913
|
+
if (storageOption === "session") {
|
|
914
|
+
try {
|
|
915
|
+
if (typeof sessionStorage !== "undefined")
|
|
916
|
+
return sessionStorage;
|
|
917
|
+
} catch {}
|
|
918
|
+
try {
|
|
919
|
+
if (typeof window !== "undefined" && window.sessionStorage) {
|
|
920
|
+
return window.sessionStorage;
|
|
921
|
+
}
|
|
922
|
+
} catch {}
|
|
923
|
+
try {
|
|
924
|
+
if (typeof globalThis !== "undefined" && globalThis.sessionStorage) {
|
|
925
|
+
return globalThis.sessionStorage;
|
|
926
|
+
}
|
|
927
|
+
} catch {}
|
|
928
|
+
return null;
|
|
929
|
+
}
|
|
930
|
+
try {
|
|
931
|
+
if (typeof localStorage !== "undefined")
|
|
932
|
+
return localStorage;
|
|
933
|
+
} catch {}
|
|
934
|
+
try {
|
|
935
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
936
|
+
return window.localStorage;
|
|
937
|
+
}
|
|
938
|
+
} catch {}
|
|
939
|
+
try {
|
|
940
|
+
if (typeof globalThis !== "undefined" && globalThis.localStorage) {
|
|
941
|
+
return globalThis.localStorage;
|
|
942
|
+
}
|
|
943
|
+
} catch {}
|
|
944
|
+
return null;
|
|
945
|
+
}
|
|
904
946
|
function signal(initialValue, optionsOrEquals) {
|
|
905
947
|
const equals = typeof optionsOrEquals === "function" ? optionsOrEquals : optionsOrEquals?.equals;
|
|
906
948
|
const isInternal = typeof optionsOrEquals === "object" ? optionsOrEquals?.internal : false;
|
|
907
949
|
const customName = typeof optionsOrEquals === "object" ? optionsOrEquals?.name : undefined;
|
|
908
|
-
const
|
|
950
|
+
const persistOption = typeof optionsOrEquals === "object" ? optionsOrEquals?.persist : undefined;
|
|
951
|
+
const persistConfig = persistOption ? typeof persistOption === "string" ? { key: persistOption } : persistOption : undefined;
|
|
952
|
+
let effectiveInitial = initialValue;
|
|
953
|
+
const storage = persistConfig ? resolveStorage(persistConfig.storage) : null;
|
|
954
|
+
const serialize = persistConfig?.serialize ?? JSON.stringify;
|
|
955
|
+
const deserialize = persistConfig?.deserialize ?? JSON.parse;
|
|
956
|
+
if (persistConfig && storage) {
|
|
957
|
+
try {
|
|
958
|
+
const stored = storage.getItem(persistConfig.key);
|
|
959
|
+
if (stored !== null) {
|
|
960
|
+
effectiveInitial = deserialize(stored);
|
|
961
|
+
}
|
|
962
|
+
} catch {}
|
|
963
|
+
}
|
|
964
|
+
let isSyncing = false;
|
|
965
|
+
const onSet = persistConfig && storage ? (val) => {
|
|
966
|
+
if (isSyncing)
|
|
967
|
+
return;
|
|
968
|
+
try {
|
|
969
|
+
storage.setItem(persistConfig.key, serialize(val));
|
|
970
|
+
} catch {}
|
|
971
|
+
} : undefined;
|
|
972
|
+
const s = new Signal(effectiveInitial, equals, onSet);
|
|
973
|
+
if (persistConfig && storage && (persistConfig.syncTabs ?? true) && typeof window !== "undefined" && typeof window.addEventListener === "function") {
|
|
974
|
+
const onStorage = (e) => {
|
|
975
|
+
if (e.key === persistConfig.key) {
|
|
976
|
+
try {
|
|
977
|
+
const nextVal = e.newValue !== null ? deserialize(e.newValue) : initialValue;
|
|
978
|
+
isSyncing = true;
|
|
979
|
+
try {
|
|
980
|
+
s.set(nextVal);
|
|
981
|
+
} finally {
|
|
982
|
+
isSyncing = false;
|
|
983
|
+
}
|
|
984
|
+
} catch {}
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
window.addEventListener("storage", onStorage);
|
|
988
|
+
if (currentScope) {
|
|
989
|
+
currentScope.addCleanup(() => {
|
|
990
|
+
window.removeEventListener("storage", onStorage);
|
|
991
|
+
});
|
|
992
|
+
}
|
|
993
|
+
}
|
|
909
994
|
const accessor = (...args) => {
|
|
910
995
|
if (args.length === 0) {
|
|
911
996
|
return s.get();
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { Child } from "../dom";
|
|
2
|
+
import type { ClassProp, HTMLAttributes } from "../jsx-runtime/jsx";
|
|
3
|
+
export interface BaseLayoutProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
as?: string;
|
|
5
|
+
gap?: number | string;
|
|
6
|
+
p?: number | string;
|
|
7
|
+
px?: number | string;
|
|
8
|
+
py?: number | string;
|
|
9
|
+
pt?: number | string;
|
|
10
|
+
pb?: number | string;
|
|
11
|
+
pl?: number | string;
|
|
12
|
+
pr?: number | string;
|
|
13
|
+
m?: number | string;
|
|
14
|
+
mx?: number | string;
|
|
15
|
+
my?: number | string;
|
|
16
|
+
mt?: number | string;
|
|
17
|
+
mb?: number | string;
|
|
18
|
+
ml?: number | string;
|
|
19
|
+
mr?: number | string;
|
|
20
|
+
w?: number | string;
|
|
21
|
+
h?: number | string;
|
|
22
|
+
minW?: number | string;
|
|
23
|
+
maxW?: number | string;
|
|
24
|
+
minH?: number | string;
|
|
25
|
+
maxH?: number | string;
|
|
26
|
+
class?: ClassProp;
|
|
27
|
+
className?: ClassProp;
|
|
28
|
+
style?: any;
|
|
29
|
+
children?: Child;
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
}
|
|
32
|
+
export interface StackProps extends BaseLayoutProps {
|
|
33
|
+
align?: "start" | "center" | "end" | "stretch" | "baseline";
|
|
34
|
+
justify?: "start" | "center" | "end" | "between" | "around" | "evenly";
|
|
35
|
+
direction?: "vertical" | "horizontal";
|
|
36
|
+
reversed?: boolean;
|
|
37
|
+
wrap?: boolean | "wrap" | "nowrap" | "wrap-reverse";
|
|
38
|
+
inline?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* <Stack> Layout Primitive
|
|
42
|
+
*
|
|
43
|
+
* Vertical (column) layout by default. Provides zero margin collapse,
|
|
44
|
+
* built-in spatial scale gap, and automatic flex overflow containment.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* <Stack gap={4} align="center">
|
|
48
|
+
* <Header />
|
|
49
|
+
* <Content />
|
|
50
|
+
* </Stack>
|
|
51
|
+
*/
|
|
52
|
+
export declare function Stack(props: StackProps): Child;
|
|
53
|
+
export interface RowProps extends BaseLayoutProps {
|
|
54
|
+
align?: "start" | "center" | "end" | "stretch" | "baseline";
|
|
55
|
+
justify?: "start" | "center" | "end" | "between" | "around" | "evenly";
|
|
56
|
+
reversed?: boolean;
|
|
57
|
+
wrap?: boolean | "wrap" | "nowrap" | "wrap-reverse";
|
|
58
|
+
inline?: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* <Row> Layout Primitive
|
|
62
|
+
*
|
|
63
|
+
* Horizontal row layout with sensible vertical centering (align="center") by default.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* <Row gap={3} justify="between">
|
|
67
|
+
* <Avatar />
|
|
68
|
+
* <Typography>Online</Typography>
|
|
69
|
+
* </Row>
|
|
70
|
+
*/
|
|
71
|
+
export declare function Row(props: RowProps): Child;
|
|
72
|
+
export interface CenterProps extends BaseLayoutProps {
|
|
73
|
+
inline?: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* <Center> Layout Primitive
|
|
77
|
+
*
|
|
78
|
+
* Centers child content horizontally and vertically without CSS boilerplate.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* <Center h="screen">
|
|
82
|
+
* <Spinner />
|
|
83
|
+
* </Center>
|
|
84
|
+
*/
|
|
85
|
+
export declare function Center(props: CenterProps): Child;
|
|
86
|
+
export interface GridProps extends BaseLayoutProps {
|
|
87
|
+
columns?: number | string;
|
|
88
|
+
minChildWidth?: number | string;
|
|
89
|
+
rows?: number | string;
|
|
90
|
+
rowGap?: number | string;
|
|
91
|
+
colGap?: number | string;
|
|
92
|
+
align?: "start" | "center" | "end" | "stretch";
|
|
93
|
+
justify?: "start" | "center" | "end" | "stretch";
|
|
94
|
+
inline?: boolean;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* <Grid> Layout Primitive
|
|
98
|
+
*
|
|
99
|
+
* Effortless CSS Grid. Specify fixed columns or a responsive minChildWidth
|
|
100
|
+
* to achieve fluid wrapping grids without writing complex media queries.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* // Responsive auto-wrapping grid
|
|
104
|
+
* <Grid minChildWidth={260} gap={4}>
|
|
105
|
+
* <Card />
|
|
106
|
+
* <Card />
|
|
107
|
+
* </Grid>
|
|
108
|
+
*/
|
|
109
|
+
export declare function Grid(props: GridProps): Child;
|
|
110
|
+
export interface SpacerProps extends BaseLayoutProps {
|
|
111
|
+
size?: number | string;
|
|
112
|
+
x?: number | string;
|
|
113
|
+
y?: number | string;
|
|
114
|
+
flex?: boolean | number;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* <Spacer> Layout Primitive
|
|
118
|
+
*
|
|
119
|
+
* Creates flexible pushing space in Rows/Stacks (defaults to flex: 1)
|
|
120
|
+
* or creates a dedicated spatial gap block when given size.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* <Row>
|
|
124
|
+
* <Logo />
|
|
125
|
+
* <Spacer />
|
|
126
|
+
* <UserProfile />
|
|
127
|
+
* </Row>
|
|
128
|
+
*/
|
|
129
|
+
export declare function Spacer(props: SpacerProps): Child;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface InjectedStyle {
|
|
2
|
+
id: string;
|
|
3
|
+
css: string;
|
|
4
|
+
count: number;
|
|
5
|
+
element?: HTMLStyleElement;
|
|
6
|
+
}
|
|
7
|
+
export declare class StyleManager {
|
|
8
|
+
private _styles;
|
|
9
|
+
private _ssrStyles;
|
|
10
|
+
/**
|
|
11
|
+
* Inject CSS into the document head or SSR registry
|
|
12
|
+
*/
|
|
13
|
+
inject(id: string, css: string): () => void;
|
|
14
|
+
/**
|
|
15
|
+
* Check if a style scope is currently registered
|
|
16
|
+
*/
|
|
17
|
+
has(id: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Extract all styles collected during Server-Side Rendering (SSR)
|
|
20
|
+
*/
|
|
21
|
+
extractSSRStyles(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Clear all registered and SSR styles
|
|
24
|
+
*/
|
|
25
|
+
clear(): void;
|
|
26
|
+
}
|
|
27
|
+
export declare const styleManager: StyleManager;
|
|
28
|
+
/**
|
|
29
|
+
* Helper to get SSR style tag HTML
|
|
30
|
+
*/
|
|
31
|
+
export declare function extractStyleTags(): string;
|