pulse-js-framework 1.4.3 → 1.4.5

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.
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Pulse Framework - Type Definitions
3
+ * @module pulse-js-framework
4
+ */
5
+
6
+ // Core Reactivity
7
+ export {
8
+ Pulse,
9
+ PulseOptions,
10
+ ComputedOptions,
11
+ MemoOptions,
12
+ MemoComputedOptions,
13
+ EqualsFn,
14
+ ReactiveState,
15
+ PromiseState,
16
+ pulse,
17
+ computed,
18
+ effect,
19
+ batch,
20
+ watch,
21
+ createState,
22
+ memo,
23
+ memoComputed,
24
+ fromPromise,
25
+ untrack,
26
+ onCleanup
27
+ } from './pulse';
28
+
29
+ // DOM Helpers
30
+ export {
31
+ MaybeGetter,
32
+ Reactive,
33
+ Child,
34
+ ParsedSelector,
35
+ EventOptions,
36
+ KeyFn,
37
+ ListTemplate,
38
+ ConditionTemplate,
39
+ MatchCases,
40
+ ComponentContext,
41
+ ComponentSetup,
42
+ ComponentFactory,
43
+ ErrorFallback,
44
+ TransitionOptions,
45
+ TransitionElement,
46
+ WhenTransitionOptions,
47
+ parseSelector,
48
+ el,
49
+ text,
50
+ bind,
51
+ prop,
52
+ cls,
53
+ style,
54
+ on,
55
+ list,
56
+ when,
57
+ match,
58
+ model,
59
+ mount,
60
+ component,
61
+ onMount,
62
+ onUnmount,
63
+ show,
64
+ portal,
65
+ errorBoundary,
66
+ transition,
67
+ whenTransition
68
+ } from './dom';
69
+
70
+ // Router
71
+ export {
72
+ RouteParams,
73
+ QueryParams,
74
+ RouteMeta,
75
+ NavigationTarget,
76
+ NavigationGuardReturn,
77
+ NavigationGuard,
78
+ AfterNavigationHook,
79
+ ScrollPosition,
80
+ ScrollBehaviorFn,
81
+ RouteHandler,
82
+ RouteDefinition,
83
+ Routes,
84
+ RouterOptions,
85
+ NavigateOptions,
86
+ LinkOptions,
87
+ MatchedRoute,
88
+ Router,
89
+ createRouter,
90
+ simpleRouter
91
+ } from './router';
92
+
93
+ // Store
94
+ export {
95
+ StoreOptions,
96
+ StoreState,
97
+ StoreMethods,
98
+ Store,
99
+ ActionFn,
100
+ ActionsDef,
101
+ BoundActions,
102
+ GetterFn,
103
+ GettersDef,
104
+ ComputedGetters,
105
+ CombinedStores,
106
+ ModuleDef,
107
+ ModulesDef,
108
+ ModuleStore,
109
+ RootModuleStore,
110
+ StorePlugin,
111
+ HistoryStore,
112
+ createStore,
113
+ createActions,
114
+ createGetters,
115
+ combineStores,
116
+ createModuleStore,
117
+ usePlugin,
118
+ loggerPlugin,
119
+ historyPlugin
120
+ } from './store';
121
+
122
+ // Logger
123
+ export {
124
+ LogLevel,
125
+ LogLevelValue,
126
+ LogFormatter,
127
+ LoggerOptions,
128
+ Logger,
129
+ setLogLevel,
130
+ getLogLevel,
131
+ setFormatter,
132
+ createLogger,
133
+ logger,
134
+ loggers
135
+ } from './logger';
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Pulse Logger - Type Definitions
3
+ * @module pulse-js-framework/runtime/logger
4
+ */
5
+
6
+ /**
7
+ * Log level constants
8
+ */
9
+ export declare const LogLevel: {
10
+ readonly SILENT: 0;
11
+ readonly ERROR: 1;
12
+ readonly WARN: 2;
13
+ readonly INFO: 3;
14
+ readonly DEBUG: 4;
15
+ };
16
+
17
+ export type LogLevelValue = 0 | 1 | 2 | 3 | 4;
18
+
19
+ /**
20
+ * Custom formatter function type
21
+ */
22
+ export type LogFormatter = (
23
+ level: 'error' | 'warn' | 'info' | 'debug',
24
+ namespace: string | null,
25
+ args: unknown[]
26
+ ) => string;
27
+
28
+ /**
29
+ * Logger options
30
+ */
31
+ export interface LoggerOptions {
32
+ /** Override global level for this logger */
33
+ level?: LogLevelValue;
34
+ }
35
+
36
+ /**
37
+ * Logger instance interface
38
+ */
39
+ export interface Logger {
40
+ /**
41
+ * Log error message (always shown unless SILENT)
42
+ */
43
+ error(...args: unknown[]): void;
44
+
45
+ /**
46
+ * Log warning message
47
+ */
48
+ warn(...args: unknown[]): void;
49
+
50
+ /**
51
+ * Log info message (general output)
52
+ */
53
+ info(...args: unknown[]): void;
54
+
55
+ /**
56
+ * Log debug message (verbose output)
57
+ */
58
+ debug(...args: unknown[]): void;
59
+
60
+ /**
61
+ * Create a log group (for debug mode)
62
+ */
63
+ group(label: string): void;
64
+
65
+ /**
66
+ * End a log group
67
+ */
68
+ groupEnd(): void;
69
+
70
+ /**
71
+ * Log with custom level
72
+ */
73
+ log(level: LogLevelValue, ...args: unknown[]): void;
74
+
75
+ /**
76
+ * Create a child logger with additional namespace
77
+ */
78
+ child(childNamespace: string): Logger;
79
+ }
80
+
81
+ /**
82
+ * Set global log level
83
+ */
84
+ export declare function setLogLevel(level: LogLevelValue): void;
85
+
86
+ /**
87
+ * Get current global log level
88
+ */
89
+ export declare function getLogLevel(): LogLevelValue;
90
+
91
+ /**
92
+ * Set custom formatter for all loggers
93
+ */
94
+ export declare function setFormatter(formatter: LogFormatter | null): void;
95
+
96
+ /**
97
+ * Create a logger instance with optional namespace
98
+ */
99
+ export declare function createLogger(
100
+ namespace?: string | null,
101
+ options?: LoggerOptions
102
+ ): Logger;
103
+
104
+ /**
105
+ * Default logger instance (no namespace)
106
+ */
107
+ export declare const logger: Logger;
108
+
109
+ /**
110
+ * Pre-configured loggers for common subsystems
111
+ */
112
+ export declare const loggers: {
113
+ readonly pulse: Logger;
114
+ readonly dom: Logger;
115
+ readonly router: Logger;
116
+ readonly store: Logger;
117
+ readonly native: Logger;
118
+ readonly hmr: Logger;
119
+ readonly cli: Logger;
120
+ };
121
+
122
+ export default logger;
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Pulse Framework - Core Reactivity Type Definitions
3
+ * @module pulse-js-framework/runtime
4
+ */
5
+
6
+ /** Equality function for comparing values */
7
+ export type EqualsFn<T> = (a: T, b: T) => boolean;
8
+
9
+ /** Pulse options */
10
+ export interface PulseOptions<T> {
11
+ equals?: EqualsFn<T>;
12
+ }
13
+
14
+ /** Computed options */
15
+ export interface ComputedOptions {
16
+ lazy?: boolean;
17
+ }
18
+
19
+ /** Memo options */
20
+ export interface MemoOptions<T> {
21
+ equals?: EqualsFn<T>;
22
+ }
23
+
24
+ /** MemoComputed options */
25
+ export interface MemoComputedOptions<T> {
26
+ deps?: unknown[];
27
+ equals?: EqualsFn<T>;
28
+ }
29
+
30
+ /**
31
+ * Reactive value container (signal)
32
+ */
33
+ export declare class Pulse<T = unknown> {
34
+ constructor(value: T, options?: PulseOptions<T>);
35
+
36
+ /** Read value and track dependency */
37
+ get(): T;
38
+
39
+ /** Read value without tracking dependency */
40
+ peek(): T;
41
+
42
+ /** Set new value and notify subscribers */
43
+ set(newValue: T): void;
44
+
45
+ /** Update value using function */
46
+ update(fn: (value: T) => T): void;
47
+
48
+ /** Subscribe to changes, returns unsubscribe function */
49
+ subscribe(fn: (value: T) => void): () => void;
50
+
51
+ /** Create derived pulse */
52
+ derive<U>(fn: (value: T) => U): Pulse<U>;
53
+
54
+ /** Cleanup (for computed pulses) */
55
+ dispose(): void;
56
+ }
57
+
58
+ /**
59
+ * Create a reactive value
60
+ */
61
+ export declare function pulse<T>(value: T, options?: PulseOptions<T>): Pulse<T>;
62
+
63
+ /**
64
+ * Create a computed (derived) reactive value
65
+ */
66
+ export declare function computed<T>(fn: () => T, options?: ComputedOptions): Pulse<T>;
67
+
68
+ /**
69
+ * Create a side effect that runs when dependencies change
70
+ * @returns Cleanup function
71
+ */
72
+ export declare function effect(fn: () => void | (() => void)): () => void;
73
+
74
+ /**
75
+ * Batch multiple updates into a single effect run
76
+ */
77
+ export declare function batch(fn: () => void): void;
78
+
79
+ /**
80
+ * Watch specific pulses and run callback on change
81
+ * @returns Cleanup function
82
+ */
83
+ export declare function watch<T>(
84
+ source: Pulse<T>,
85
+ callback: (newValue: T, oldValue: T) => void
86
+ ): () => void;
87
+ export declare function watch<T extends readonly Pulse<unknown>[]>(
88
+ sources: T,
89
+ callback: (
90
+ newValues: { [K in keyof T]: T[K] extends Pulse<infer U> ? U : never },
91
+ oldValues: { [K in keyof T]: T[K] extends Pulse<infer U> ? U : never }
92
+ ) => void
93
+ ): () => void;
94
+
95
+ /** State object with reactive properties */
96
+ export interface ReactiveState<T extends Record<string, unknown>> {
97
+ /** Access raw pulses */
98
+ $pulses: { [K in keyof T]: Pulse<T[K]> };
99
+ /** Get pulse by key */
100
+ $pulse<K extends keyof T>(key: K): Pulse<T[K]>;
101
+ }
102
+
103
+ /**
104
+ * Create reactive state object from plain object
105
+ */
106
+ export declare function createState<T extends Record<string, unknown>>(
107
+ obj: T
108
+ ): T & ReactiveState<T>;
109
+
110
+ /**
111
+ * Memoize a function based on arguments
112
+ */
113
+ export declare function memo<T extends (...args: unknown[]) => unknown>(
114
+ fn: T,
115
+ options?: MemoOptions<ReturnType<T>>
116
+ ): T;
117
+
118
+ /**
119
+ * Create memoized computed value
120
+ */
121
+ export declare function memoComputed<T>(
122
+ fn: () => T,
123
+ options?: MemoComputedOptions<T>
124
+ ): Pulse<T>;
125
+
126
+ /** Promise result state */
127
+ export interface PromiseState<T> {
128
+ value: Pulse<T | undefined>;
129
+ loading: Pulse<boolean>;
130
+ error: Pulse<Error | null>;
131
+ }
132
+
133
+ /**
134
+ * Create reactive values from a promise
135
+ */
136
+ export declare function fromPromise<T>(
137
+ promise: Promise<T>,
138
+ initialValue?: T
139
+ ): PromiseState<T>;
140
+
141
+ /**
142
+ * Read pulses without creating dependencies
143
+ */
144
+ export declare function untrack<T>(fn: () => T): T;
145
+
146
+ /**
147
+ * Register cleanup function for current effect
148
+ */
149
+ export declare function onCleanup(fn: () => void): void;
@@ -0,0 +1,197 @@
1
+ /**
2
+ * Pulse Framework - Router Type Definitions
3
+ * @module pulse-js-framework/runtime/router
4
+ */
5
+
6
+ import { Pulse } from './pulse';
7
+
8
+ /** Route parameters object */
9
+ export type RouteParams = Record<string, string>;
10
+
11
+ /** Query parameters object */
12
+ export type QueryParams = Record<string, string | string[]>;
13
+
14
+ /** Route meta information */
15
+ export type RouteMeta = Record<string, unknown>;
16
+
17
+ /** Navigation target (to/from) */
18
+ export interface NavigationTarget {
19
+ path: string;
20
+ params: RouteParams;
21
+ query: QueryParams;
22
+ meta: RouteMeta;
23
+ matched?: RouteDefinition[];
24
+ }
25
+
26
+ /** Navigation guard return type */
27
+ export type NavigationGuardReturn = boolean | string | void | Promise<boolean | string | void>;
28
+
29
+ /** Navigation guard function */
30
+ export type NavigationGuard = (
31
+ to: NavigationTarget,
32
+ from: NavigationTarget
33
+ ) => NavigationGuardReturn;
34
+
35
+ /** After navigation hook */
36
+ export type AfterNavigationHook = (to: NavigationTarget) => void | Promise<void>;
37
+
38
+ /** Scroll position */
39
+ export interface ScrollPosition {
40
+ x?: number;
41
+ y?: number;
42
+ selector?: string;
43
+ behavior?: ScrollBehavior;
44
+ }
45
+
46
+ /** Scroll behavior function */
47
+ export type ScrollBehaviorFn = (
48
+ to: NavigationTarget,
49
+ from: NavigationTarget,
50
+ savedPosition: ScrollPosition | null
51
+ ) => ScrollPosition | null | void;
52
+
53
+ /** Route handler (component) */
54
+ export type RouteHandler =
55
+ | (() => Node)
56
+ | (() => Promise<{ default: () => Node }>)
57
+ | { render: () => Node };
58
+
59
+ /** Route definition */
60
+ export interface RouteDefinition {
61
+ handler?: RouteHandler;
62
+ meta?: RouteMeta;
63
+ beforeEnter?: NavigationGuard;
64
+ children?: Routes;
65
+ }
66
+
67
+ /** Routes configuration object */
68
+ export interface Routes {
69
+ [path: string]: RouteHandler | RouteDefinition;
70
+ }
71
+
72
+ /** Router options */
73
+ export interface RouterOptions {
74
+ routes?: Routes;
75
+ mode?: 'history' | 'hash';
76
+ base?: string;
77
+ scrollBehavior?: ScrollBehaviorFn;
78
+ }
79
+
80
+ /** Navigation options */
81
+ export interface NavigateOptions {
82
+ replace?: boolean;
83
+ query?: Record<string, string | number>;
84
+ state?: unknown;
85
+ }
86
+
87
+ /** Link options */
88
+ export interface LinkOptions {
89
+ exact?: boolean;
90
+ activeClass?: string;
91
+ }
92
+
93
+ /** Matched route */
94
+ export interface MatchedRoute {
95
+ route: RouteDefinition;
96
+ params: RouteParams;
97
+ }
98
+
99
+ /** Router instance */
100
+ export interface Router {
101
+ /** Current path (reactive) */
102
+ path: Pulse<string>;
103
+
104
+ /** Current route object (reactive) */
105
+ route: Pulse<NavigationTarget | null>;
106
+
107
+ /** Current route parameters (reactive) */
108
+ params: Pulse<RouteParams>;
109
+
110
+ /** Current query parameters (reactive) */
111
+ query: Pulse<QueryParams>;
112
+
113
+ /** Current route meta (reactive) */
114
+ meta: Pulse<RouteMeta>;
115
+
116
+ /** Loading state for async components (reactive) */
117
+ loading: Pulse<boolean>;
118
+
119
+ /**
120
+ * Navigate to path
121
+ * @returns Promise resolving to navigation success
122
+ */
123
+ navigate(path: string, options?: NavigateOptions): Promise<boolean>;
124
+
125
+ /**
126
+ * Create router link element
127
+ */
128
+ link(path: string, content: Node | string, options?: LinkOptions): HTMLAnchorElement;
129
+
130
+ /**
131
+ * Render current route component
132
+ */
133
+ outlet(container: string | HTMLElement): HTMLElement;
134
+
135
+ /** Navigate back in history */
136
+ back(): void;
137
+
138
+ /** Navigate forward in history */
139
+ forward(): void;
140
+
141
+ /** Go to specific history entry */
142
+ go(delta: number): void;
143
+
144
+ /**
145
+ * Add global before-navigation guard
146
+ * @returns Unregister function
147
+ */
148
+ beforeEach(hook: NavigationGuard): () => void;
149
+
150
+ /**
151
+ * Add before-resolve hook (after per-route guards)
152
+ * @returns Unregister function
153
+ */
154
+ beforeResolve(hook: NavigationGuard): () => void;
155
+
156
+ /**
157
+ * Add after-navigation hook
158
+ * @returns Unregister function
159
+ */
160
+ afterEach(hook: AfterNavigationHook): () => void;
161
+
162
+ /**
163
+ * Check if route matches
164
+ */
165
+ isActive(path: string, exact?: boolean): boolean;
166
+
167
+ /**
168
+ * Get all matched routes (for nested routes)
169
+ */
170
+ getMatchedRoutes(path: string): MatchedRoute[];
171
+
172
+ /**
173
+ * Start listening to navigation events
174
+ * @returns Stop function
175
+ */
176
+ start(): () => void;
177
+
178
+ /**
179
+ * Match path against pattern
180
+ */
181
+ matchRoute(pattern: string, path: string): RouteParams | null;
182
+
183
+ /**
184
+ * Parse query string to object
185
+ */
186
+ parseQuery(search: string): QueryParams;
187
+ }
188
+
189
+ /**
190
+ * Create router instance
191
+ */
192
+ export declare function createRouter(options?: RouterOptions): Router;
193
+
194
+ /**
195
+ * Quick router setup (creates, starts, and mounts)
196
+ */
197
+ export declare function simpleRouter(routes: Routes, target?: string): Router;