@lipsjs/lips 0.0.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.
@@ -0,0 +1,48 @@
1
+ export interface BenchmarkMetrics {
2
+ renderCount: number;
3
+ elementCount: number;
4
+ renderTime: number;
5
+ avgRenderTime: number;
6
+ maxRenderTime: number;
7
+ componentCount: number;
8
+ componentUpdateCount: number;
9
+ partialCount: number;
10
+ partialUpdateCount: number;
11
+ memoryUsage?: number;
12
+ domOperations: number;
13
+ domInsertsCount: number;
14
+ domUpdatesCount: number;
15
+ domRemovalsCount: number;
16
+ dependencyTrackCount: number;
17
+ dependencyUpdateCount: number;
18
+ batchSize: number;
19
+ batchCount: number;
20
+ errorCount: number;
21
+ }
22
+ export default class Benchmark {
23
+ private debug;
24
+ private initialStats;
25
+ stats: BenchmarkMetrics;
26
+ private renderStartTime;
27
+ private renderTimes;
28
+ private measurementCount;
29
+ private maxMeasurements;
30
+ private loggingInterval;
31
+ private autoSaveInterval?;
32
+ constructor(debug?: boolean);
33
+ private storeMetrics;
34
+ startRender(): void;
35
+ endRender(): void;
36
+ inc(metric: keyof BenchmarkMetrics): void;
37
+ dec(metric: keyof BenchmarkMetrics): void;
38
+ record(metric: keyof BenchmarkMetrics, value: number): void;
39
+ add(metric: keyof BenchmarkMetrics, value: number): void;
40
+ reset(): any;
41
+ log(): void;
42
+ trackMemory(): void;
43
+ trackBatch(size: number): void;
44
+ trackError(error: Error): void;
45
+ setLoggingInterval(interval: number): void;
46
+ getSnapshot(): BenchmarkMetrics;
47
+ dispose(): void;
48
+ }
@@ -0,0 +1,77 @@
1
+ import type Lips from './lips';
2
+ import type { Handler, Metavars, ComponentScope, ComponentOptions, VariableSet, RenderedNode, FGUDependencies } from '.';
3
+ import Events from './events';
4
+ import { Cash } from 'cash-dom';
5
+ import Benchmark from './benchmark';
6
+ export default class Component<MT extends Metavars> extends Events {
7
+ private declaration;
8
+ private $?;
9
+ input: MT['Input'];
10
+ state: MT['State'] & {
11
+ toJSON(): MT['State'];
12
+ reset(): void;
13
+ };
14
+ static: MT['Static'];
15
+ context: MT['Context'];
16
+ __name__: string;
17
+ __path__: string;
18
+ private __template__;
19
+ private __previous;
20
+ private __stylesheet?;
21
+ private __macros;
22
+ private __renderCache;
23
+ FGUD: FGUDependencies;
24
+ private PCC;
25
+ private VER;
26
+ private prepath;
27
+ private debug;
28
+ private isRendered;
29
+ private __setInput;
30
+ private __setState;
31
+ private __getState;
32
+ private UQS;
33
+ private ICE;
34
+ lips: Lips;
35
+ benchmark: Benchmark;
36
+ private __path;
37
+ private __pathCounter;
38
+ private __renderDepth;
39
+ [key: string]: any;
40
+ constructor(name: string, template: string, { input, state, context, _static, handler, stylesheet, macros, declaration }: ComponentScope<MT>, options: ComponentOptions);
41
+ setContext(arg: Partial<Record<string, any>> | string, value?: any): void;
42
+ setInput(input: MT['Input']): void;
43
+ /**
44
+ * Inject grain/partial input to current component
45
+ * instead of sending a whole updated input
46
+ */
47
+ subInput(data: Record<string, any>): this;
48
+ setMacros(template: string): void;
49
+ setHandler(list: Handler<MT>): void;
50
+ setStylesheet(sheet?: string): void;
51
+ get node(): Cash;
52
+ find(selector: string): Cash | undefined;
53
+ render(inpath: string, $nodes?: Cash, scope?: VariableSet, sharedDeps?: FGUDependencies, xmlns?: boolean): RenderedNode;
54
+ destroy(): void;
55
+ private __meshwire__;
56
+ private __getBoundaries__;
57
+ private __getAttributes__;
58
+ private __withPath__;
59
+ private __getPathParent__;
60
+ private __hasSamePathParent__;
61
+ private __evaluate__;
62
+ private __evaluateFunction__;
63
+ private __interpolate__;
64
+ private __attachEvent__;
65
+ private __detachEvent__;
66
+ private __extractTextDeps__;
67
+ private __extractExpressionDeps__;
68
+ private __isReactive__;
69
+ private __trackDep__;
70
+ private __valueDep__;
71
+ private __shouldUpdate__;
72
+ private __updateDepNodes__;
73
+ private __updateVarDepNodes__;
74
+ appendTo(arg: Cash | string): this;
75
+ prependTo(arg: Cash | string): this;
76
+ replaceWith(arg: Cash | string): this;
77
+ }
@@ -0,0 +1,14 @@
1
+ import { Metavars } from '.';
2
+ import type Component from './component';
3
+ /**
4
+ * DOM Watch Service
5
+ */
6
+ export default class DWS<MT extends Metavars> {
7
+ private domObserver;
8
+ private observedComponents;
9
+ private readonly TIMEOUT;
10
+ constructor();
11
+ watch(component: Component<MT>, type?: 'attach' | 'detach'): void;
12
+ unwatch(component: Component<MT>): void;
13
+ dispose(): void;
14
+ }
@@ -0,0 +1,14 @@
1
+ import type { EventListener } from '.';
2
+ export type EventOptions = {
3
+ emit?: boolean;
4
+ };
5
+ export default class Events {
6
+ private options;
7
+ private __events;
8
+ private __once_events;
9
+ constructor(options?: EventOptions);
10
+ on(_event: string, fn: EventListener): this;
11
+ once(_event: string, fn: EventListener): this;
12
+ off(_event: string): this;
13
+ emit(_event: string, ...params: any[]): void;
14
+ }
@@ -0,0 +1,16 @@
1
+ import { type Cash } from 'cash-dom';
2
+ import type { LanguageDictionary } from '.';
3
+ export default class I18N {
4
+ private default;
5
+ private LANGUAGE_DICTIONARIES;
6
+ setLang(lang: string): boolean;
7
+ setDictionary(id: string, dico: LanguageDictionary): void;
8
+ /**
9
+ *
10
+ */
11
+ translate(text: string, lang?: string): {
12
+ text: string;
13
+ lang: string;
14
+ };
15
+ propagate($node: Cash): Cash;
16
+ }
@@ -0,0 +1,173 @@
1
+ import type Lips from '.'
2
+ import type Component from './component'
3
+
4
+ export interface Metavars<Input extends Object = {}, State extends Object = {}, Static extends Object = {}, Context extends Object = {}> {
5
+ Input: Input
6
+ State: State
7
+ Static: Static
8
+ Context: Context
9
+ }
10
+ export interface InteractiveMetavars<MT extends Metavars = Metavars> {
11
+ input: MT['Input']
12
+ state: MT['State']
13
+ context: MT['Context']
14
+ }
15
+ export type Variable = {
16
+ value: any
17
+ type: 'let' | 'const' | 'arg'
18
+ }
19
+ export type VariableSet = Record<string, Variable>
20
+
21
+ export type LanguageDictionary = Record<string, Record<string, string> | string>
22
+
23
+ export type DeclarationTagType = 'nexted' | 'child'
24
+ export type DeclarationTag = {
25
+ type: DeclarationTagType
26
+ many?: boolean
27
+ optional?: boolean
28
+ }
29
+ export type Declaration = {
30
+ name: string
31
+ syntax?: boolean
32
+ iterator?: boolean
33
+ contents?: boolean
34
+ tags?: Record<string, DeclarationTag>
35
+ }
36
+
37
+ export interface Handler<MT extends Metavars> {
38
+ onCreate?: ( this: Component<MT> ) => void
39
+ onInput?: ( this: Component<MT>, input: MT['Input'] ) => void
40
+ onMount?: ( this: Component<MT> ) => void
41
+ onRender?: ( this: Component<MT> ) => void
42
+ onUpdate?: ( this: Component<MT> ) => void
43
+ onAttach?: ( this: Component<MT> ) => void
44
+ onDetach?: ( this: Component<MT> ) => void
45
+ onContext?: ( this: Component<MT> ) => void
46
+
47
+ [method: string]: ( this: Component<MT>, ...args: any[] ) => void
48
+ }
49
+ export type Template<MT extends Metavars> = {
50
+ default?: string
51
+ state?: MT['State']
52
+ _static?: MT['Static']
53
+ context?: string[]
54
+ macros?: string
55
+ handler?: Handler<MT>
56
+ stylesheet?: string
57
+ declaration?: Declaration
58
+ }
59
+ export type DynamicTemplate<MT extends Metavars> = {
60
+ name?: string,
61
+ template?: Template<MT>
62
+ }
63
+ export type ComponentScope<MT extends Metavars> = {
64
+ input?: MT['Input']
65
+ state?: MT['State']
66
+ context?: MT['Context']
67
+ _static?: MT['Static']
68
+ macros?: string
69
+ handler?: Handler<MT>
70
+ stylesheet?: string
71
+ declaration?: Declaration
72
+ }
73
+ export type ComponentOptions = {
74
+ lips: Lips
75
+ debug?: boolean
76
+ prepath?: string
77
+ enableTemplateCache?: boolean
78
+ enableSmartDiff?: boolean
79
+ }
80
+ export type LipsConfig = {
81
+ context?: any
82
+ debug?: boolean
83
+ }
84
+ export type StyleSettings = {
85
+ sheet?: string
86
+ meta?: boolean
87
+ custom?: {
88
+ enabled: boolean
89
+ allowedRules: string[]
90
+ allowedProperties: string[]
91
+ }
92
+ }
93
+ export type EventListener = ( ...args: any[] ) => void
94
+
95
+ export type Macro = {
96
+ argv: string[]
97
+ $node: Cash
98
+ }
99
+
100
+ export type SyntaxAttributes = {
101
+ literals: Record<string, any>
102
+ functions: Record<string, any>
103
+ expressions: Record<string, any>
104
+ }
105
+
106
+ export type VirtualEvent = {
107
+ $fragment: Cash
108
+ _event: string
109
+ instruction: string
110
+ scope?: Record<string, any>
111
+ }
112
+ export type VirtualEventsRegistry<T> = {
113
+ element: Cash | T
114
+ _event: string
115
+ }
116
+
117
+ /**
118
+ * (FGU) Fine-Grain Update Dependencies
119
+ */
120
+ export interface FGUSync {
121
+ // $fragment?: Cash
122
+ memo?: VariableSet
123
+ cleanup?: () => void
124
+ }
125
+ export interface FGUDependency {
126
+ path: string
127
+ $fragment: Cash | null
128
+ boundaries?: FragmentBoundaries
129
+ haslet?: boolean
130
+ batch?: boolean
131
+ syntax?: boolean
132
+ partial?: string[]
133
+ memo: VariableSet
134
+ update: ( memo: VariableSet, by?: string ) => FGUSync | void
135
+ }
136
+ export type FGUDependencies = Map<string, Map<string, FGUDependency>>
137
+ export type FGUDBatchEntry = {
138
+ dep: string
139
+ dependent: FGUDependency
140
+ }
141
+
142
+ export type RenderedNode = {
143
+ $log: Cash
144
+ dependencies: FGUDependencies
145
+ events?: VirtualEvent[]
146
+ }
147
+ export type FragmentBoundaries = {
148
+ start: Comment
149
+ end: Comment
150
+ }
151
+
152
+ export interface MeshRenderer {
153
+ path: string | null
154
+ argv: string[]
155
+ mesh( argvalues?: VariableSet ): Cash
156
+ update( deps: string[], argvalues: VariableSet, boundaries?: FragmentBoundaries ): Cash
157
+ }
158
+ export type MeshTemplate = Record<string, any> & {
159
+ renderer: MeshRenderer
160
+ }
161
+ export interface MeshWireSetup {
162
+ argv: string[] = []
163
+ scope: VariableSet = {}
164
+ declaration?: Declaration
165
+ useAttributes: boolean
166
+ xmlns?: boolean
167
+
168
+ $node: Cash
169
+ meshPath: string | null
170
+
171
+ fragmentPath: string
172
+ fragmentBoundaries: FragmentBoundaries
173
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Internal Update Cycle
3
+ */
4
+ export default class IUC {
5
+ private subscriptions;
6
+ private tick;
7
+ /**
8
+ * Register component update function
9
+ */
10
+ register(ref: string, ticker: () => void): void;
11
+ /**
12
+ * Unregister component
13
+ */
14
+ unregister(ref: string): void;
15
+ /**
16
+ * Queue an immediate update for next tick
17
+ */
18
+ queueUpdate(ref: string): void;
19
+ dispose(): void;
20
+ prepareForPotentialUnload(): void;
21
+ /**
22
+ * Create a state proxy handler to detect mutations
23
+ */
24
+ proxyState<State extends Object>(componentRef: string, state: State): any;
25
+ }
@@ -0,0 +1,27 @@
1
+ import type { LipsConfig, Template, Metavars } from '.';
2
+ import I18N from './i18n';
3
+ import IUC from './iuc';
4
+ import DWS from './dws';
5
+ import Component from './component';
6
+ export default class Lips<Context = any> {
7
+ private debug;
8
+ private store;
9
+ private __root?;
10
+ i18n: I18N;
11
+ watcher: DWS<any>;
12
+ IUC: IUC;
13
+ private __setContext;
14
+ private __getContext;
15
+ constructor(config?: LipsConfig);
16
+ register<MT extends Metavars>(name: string, template: Template<MT>): this;
17
+ unregister(name: string): this;
18
+ has(name: string): boolean;
19
+ import<MT extends Metavars>(pathname: string): Template<MT>;
20
+ render<MT extends Metavars>(name: string, template: Template<MT>, input?: MT['Input']): Component<MT>;
21
+ root<MT extends Metavars>(template: Template<MT>, selector: string): Component<any>;
22
+ language(lang: string): void;
23
+ setContext(arg: Context | string, value?: any): void;
24
+ getContext(): Context;
25
+ useContext<P extends Context>(fields: (keyof Context)[], fn: (context: P) => void): void;
26
+ dispose(): void;
27
+ }
@@ -0,0 +1,2 @@
1
+ export declare function isExpression(value: string): boolean;
2
+ export declare function preprocessor(str: string): string;
@@ -0,0 +1,30 @@
1
+ type Listener = () => unknown;
2
+ type HistoryEntry<T> = {
3
+ value: T;
4
+ timestamp: number;
5
+ metadata?: Record<string, unknown>;
6
+ };
7
+ type Signal<T> = [
8
+ read: () => T,
9
+ write: (nextValue: T, metadata?: Record<string, unknown>) => void,
10
+ history: {
11
+ undo: () => void;
12
+ redo: () => void;
13
+ jumpTo: (index: number) => void;
14
+ getHistory: () => HistoryEntry<T>[];
15
+ getCurrentIndex: () => number;
16
+ canUndo: () => boolean;
17
+ canRedo: () => boolean;
18
+ clear: () => void;
19
+ }
20
+ ];
21
+ export interface EffectControl {
22
+ dispose(): void;
23
+ }
24
+ export declare function batch<T>(fn: () => T): T;
25
+ export declare function signal<T>(value: T, options?: {
26
+ maxSize: number;
27
+ }): Signal<T>;
28
+ export declare function effect(fn: Listener): EffectControl;
29
+ export declare function memo(fn: Listener): (() => void)[];
30
+ export {};
@@ -0,0 +1,51 @@
1
+ type StyleSettings = {
2
+ sheet?: string;
3
+ meta?: boolean;
4
+ custom?: {
5
+ enabled: boolean;
6
+ allowedRules: string[];
7
+ allowedProperties: string[];
8
+ };
9
+ };
10
+ export default class Stylesheet {
11
+ private nsp;
12
+ private settings;
13
+ private $head;
14
+ constructor(nsp: string, settings?: StyleSettings);
15
+ /**
16
+ * Process sheet string using Stylis
17
+ */
18
+ compile(str: string): string;
19
+ /**
20
+ * Wait for styles to be applied
21
+ */
22
+ private waitForStyles;
23
+ /**
24
+ * Compile and inject a style chunk in the DOM
25
+ * using `<style mv-style="*">...</style>` tag
26
+ */
27
+ private inject;
28
+ /**
29
+ * Load/inject predefined sheet to the document
30
+ */
31
+ load(settings: StyleSettings): Promise<void>;
32
+ /**
33
+ * Retreive this view's main node styles including natively
34
+ * defined ones.
35
+ */
36
+ get(): void;
37
+ /**
38
+ * Remove all injected styles from the DOM
39
+ */
40
+ clear(): Promise<void>;
41
+ /**
42
+ * Return css custom properties
43
+ */
44
+ custom(): Promise<Record<string, string>>;
45
+ /**
46
+ * Overridable function to return an element
47
+ * style attribute value as JSON object.
48
+ */
49
+ style(): Promise<Record<string, string>>;
50
+ }
51
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { Declaration, Handler, Metavars, MeshRenderer, MeshTemplate, VariableSet } from '..';
2
+ export interface Input {
3
+ await: Promise<any>;
4
+ then: MeshTemplate;
5
+ catch?: MeshTemplate;
6
+ loading?: MeshTemplate;
7
+ renderer: MeshRenderer;
8
+ }
9
+ export interface State {
10
+ renderer: MeshRenderer | null;
11
+ props: VariableSet;
12
+ }
13
+ export declare const declaration: Declaration;
14
+ export declare const state: State;
15
+ export declare const handler: Handler<Metavars<Input, State>>;
16
+ declare const _default: "<{state.renderer} #=state.props/>";
17
+ export default _default;
@@ -0,0 +1,20 @@
1
+ import type { Declaration, Handler, Metavars, MeshRenderer } from '..';
2
+ export interface Input {
3
+ in: Record<string, any> | any[];
4
+ from?: number;
5
+ to?: number;
6
+ renderer?: MeshRenderer;
7
+ }
8
+ export interface State {
9
+ argvlist: Record<string, any>[] | null;
10
+ }
11
+ export interface Static {
12
+ lastInput: any;
13
+ processingBatch: boolean;
14
+ }
15
+ export declare const declaration: Declaration;
16
+ export declare const state: State;
17
+ export declare const _static: Static;
18
+ export declare const handler: Handler<Metavars<Input, State, Static>>;
19
+ declare const _default: "<{input.renderer} #=state.argvlist/>";
20
+ export default _default;
@@ -0,0 +1,15 @@
1
+ import type { Declaration, Handler, Metavars, MeshRenderer, MeshTemplate } from '..';
2
+ export interface Input {
3
+ by: boolean;
4
+ renderer?: MeshRenderer;
5
+ 'else-if'?: MeshTemplate[];
6
+ 'else'?: MeshTemplate;
7
+ }
8
+ export interface State {
9
+ renderer: MeshRenderer | null;
10
+ }
11
+ export declare const declaration: Declaration;
12
+ export declare const state: State;
13
+ export declare const handler: Handler<Metavars<Input, State>>;
14
+ declare const _default: "<{state.renderer}/>";
15
+ export default _default;
@@ -0,0 +1,31 @@
1
+ import type { Handler, Metavars } from '..';
2
+ /**
3
+ * Performance Dashboard
4
+ */
5
+ export interface Input {
6
+ }
7
+ export interface State {
8
+ metricsHistory: Array<{
9
+ timestamp: number;
10
+ metrics: any;
11
+ }>;
12
+ activeTab: string;
13
+ isVisible: boolean;
14
+ }
15
+ export interface Static {
16
+ refreshInterval: number;
17
+ keyboardShortcut: string;
18
+ }
19
+ export declare const state: {
20
+ metricsHistory: never[];
21
+ activeTab: string;
22
+ isVisible: boolean;
23
+ };
24
+ export declare const _static: {
25
+ refreshInterval: number;
26
+ keyboardShortcut: string;
27
+ };
28
+ export declare const handler: Handler<Metavars<Input, State, Static>>;
29
+ declare const _default: "\n <div class=\"perf-dashboard\" style=\"{ display: state.isVisible ? 'block' : 'none' }\">\n <div class=\"perf-dashboard-header\">\n <h3 class=\"perf-dashboard-title\">Lips Performance Dashboard</h3>\n <div class=\"perf-dashboard-controls\">\n <button class=\"clear\" on-click(clearMetrics)>Clear</button>\n <button on-click(toggleVisibility)>Close</button>\n </div>\n </div>\n \n <div class=\"perf-dashboard-tabs\">\n <button class=\"perf-dashboard-tab {state.activeTab === 'rendering' ? 'active' : ''}\" \n on-click(setActiveTab, 'rendering')>Rendering</button>\n <button class=\"perf-dashboard-tab {state.activeTab === 'components' ? 'active' : ''}\" \n on-click(setActiveTab, 'components')>Components</button>\n <button class=\"perf-dashboard-tab {state.activeTab === 'dom' ? 'active' : ''}\" \n on-click(setActiveTab, 'dom')>DOM</button>\n <button class=\"perf-dashboard-tab {state.activeTab === 'memory' ? 'active' : ''}\" \n on-click(setActiveTab, 'memory')>Memory</button>\n </div>\n \n <!-- Rendering Tab -->\n <div style=\"{ display: state.activeTab === 'rendering' ? 'block' : 'none' }\">\n <div class=\"perf-dashboard-chart\">\n <for [point, i] in=state.metricsHistory.slice(-30)>\n <div class=\"perf-dashboard-chart-bar render-avg\" \n style=\"{ height: (point.metrics.avgRenderTime * 2)+'px', left: (i * (100/30))+'%' }\"></div>\n <div class=\"perf-dashboard-chart-bar render-max\" \n style=\"{ height: (point.metrics.maxRenderTime * 2)+'px', left: (i * (100/30))+'%' }\"></div>\n </for>\n <div class=\"perf-dashboard-legend\">Render Time (ms): Avg (green), Max (orange)</div>\n </div>\n \n <table class=\"perf-dashboard-metrics\">\n <tr>\n <th>Metric</th>\n <th>Value</th>\n </tr>\n\n <if( state.metricsHistory.length > 0 )>\n <let latest=self.getLatestMetrics()/>\n\n <tr>\n <td>Avg Render Time</td>\n <td>{self.getLatestMetrics()?.avgRenderTime.toFixed(2)} ms</td>\n </tr>\n <tr>\n <td>Max Render Time</td>\n <td>{self.getLatestMetrics()?.maxRenderTime.toFixed(2)} ms</td>\n </tr>\n <tr>\n <td>Render Count</td>\n <td>{self.getLatestMetrics()?.renderCount}</td>\n </tr>\n <tr>\n <td>Element Count</td>\n <td>{self.getLatestMetrics()?.elementCount}</td>\n </tr>\n </if>\n </table>\n </div>\n \n <!-- Components Tab -->\n <div style=\"{ display: state.activeTab === 'components' ? 'block' : 'none' }\">\n <div class=\"perf-dashboard-chart\">\n <for [point, i] in=state.metricsHistory.slice(-30)>\n <div class=\"perf-dashboard-chart-bar component-updates\" \n style=\"{ height: (point.metrics.componentUpdateCount)+'px', left: (i * (100/30))+'%' }\"></div>\n </for>\n <div class=\"perf-dashboard-legend\">Component Updates</div>\n </div>\n \n <table class=\"perf-dashboard-metrics\">\n <tr>\n <th>Metric</th>\n <th>Value</th>\n </tr>\n\n <if( state.metricsHistory.length > 0 )>\n <let latest=self.getLatestMetrics()/>\n <tr>\n <td>Component Count</td>\n <td>{latest?.componentCount}</td>\n </tr>\n <tr>\n <td>Component Updates</td>\n <td>{latest?.componentUpdateCount}</td>\n </tr>\n <tr>\n <td>Dependency Tracks</td>\n <td>{latest?.dependencyTrackCount}</td>\n </tr>\n <tr>\n <td>Dependency Updates</td>\n <td>{latest?.dependencyUpdateCount}</td>\n </tr>\n </if>\n </table>\n </div>\n \n <!-- DOM Tab -->\n <div style=\"{ display: state.activeTab === 'dom' ? 'block' : 'none' }\">\n <div class=\"perf-dashboard-chart\">\n <for [point, i] in=state.metricsHistory.slice(-30)>\n <div class=\"perf-dashboard-chart-bar dom-ops\" \n style=\"{ height: (point.metrics.domOperations / 5)+'px', left: (i * (100/30))+'%' }\"></div>\n </for>\n <div class=\"perf-dashboard-legend\">DOM Operations</div>\n </div>\n \n <table class=\"perf-dashboard-metrics\">\n <tr>\n <th>Metric</th>\n <th>Value</th>\n </tr>\n\n <if( state.metricsHistory.length > 0 )>\n <let latest=\"self.getLatestMetrics()\"/>\n <tr>\n <td>DOM Operations</td>\n <td>{latest?.domOperations}</td>\n </tr>\n <tr>\n <td>DOM Inserts</td>\n <td>{latest?.domInsertsCount}</td>\n </tr>\n <tr>\n <td>DOM Updates</td>\n <td>{latest?.domUpdatesCount}</td>\n </tr>\n <tr>\n <td>DOM Removals</td>\n <td>{latest?.domRemovalsCount}</td>\n </tr>\n </if>\n </table>\n </div>\n \n <!-- Memory Tab -->\n <div style=\"{ display: state.activeTab === 'memory' ? 'block' : 'none' }\">\n <div class=\"perf-dashboard-chart\">\n <for [point, i] in=state.metricsHistory.slice(-30)>\n <div class=\"perf-dashboard-chart-bar memory\" \n style=\"{ height: (point.metrics.memoryUsage ? point.metrics.memoryUsage * 2 : 0)+'px', left: (i * (100/30))+'%' }\"></div>\n </for>\n <div class=\"perf-dashboard-legend\">Memory Usage (MB)</div>\n </div>\n \n <table class=\"perf-dashboard-metrics\">\n <tr>\n <th>Metric</th>\n <th>Value</th>\n </tr>\n\n <if( state.metricsHistory.length > 0 )>\n <let latest=\"self.getLatestMetrics()\"/>\n <tr>\n <td>Memory Usage</td>\n <td>{latest?.memoryUsage ? latest.memoryUsage.toFixed(2) + ' MB' : 'N/A'}</td>\n </tr>\n <tr>\n <td>Batch Count</td>\n <td>{latest?.batchCount}</td>\n </tr>\n <tr>\n <td>Average Batch Size</td>\n <td>{latest?.batchCount > 0 ? (latest.batchSize / latest.batchCount).toFixed(2) : '0'}</td>\n </tr>\n <tr>\n <td>Error Count</td>\n <td>{latest?.errorCount}</td>\n </tr>\n </if>\n </table>\n </div>\n \n <div class=\"perf-dashboard-footer\">\n Press Ctrl+Shift+{static.keyboardShortcut} to toggle dashboard\n </div>\n </div>\n";
30
+ export default _default;
31
+ export declare const stylesheet = "\n .perf-dashboard {\n position: fixed;\n bottom: 0;\n right: 0;\n width: 400px;\n max-height: 400px;\n background: rgba(0, 0, 0, 0.85);\n color: white;\n padding: 10px;\n border-top-left-radius: 8px;\n z-index: 9999;\n font-family: monospace;\n overflow: auto;\n box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);\n }\n \n .perf-dashboard-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 10px;\n border-bottom: 1px solid #444;\n padding-bottom: 5px;\n }\n \n .perf-dashboard-title {\n margin: 0; \n font-size: 14px;\n font-weight: bold;\n }\n \n .perf-dashboard-controls button {\n background: #555;\n color: white;\n border: none;\n border-radius: 3px;\n padding: 3px 8px;\n font-size: 10px;\n cursor: pointer;\n margin-left: 5px;\n }\n \n .perf-dashboard-controls button.clear {\n background: #f44336;\n }\n \n .perf-dashboard-tabs {\n display: flex;\n margin-bottom: 10px;\n }\n \n .perf-dashboard-tab {\n flex: 1;\n border: none;\n padding: 5px;\n font-size: 12px;\n cursor: pointer;\n border-radius: 0;\n background: #555;\n color: white;\n }\n \n .perf-dashboard-tab.active {\n background: #4CAF50;\n }\n \n .perf-dashboard-tab:first-child {\n border-radius: 3px 0 0 3px;\n }\n \n .perf-dashboard-tab:last-child {\n border-radius: 0 3px 3px 0;\n }\n \n .perf-dashboard-chart {\n height: 150px;\n background: #222;\n margin-bottom: 10px;\n position: relative;\n border: 1px solid #444;\n }\n \n .perf-dashboard-chart-bar {\n position: absolute;\n width: 2px;\n bottom: 0;\n transform: translateX(-50%);\n }\n \n .perf-dashboard-chart-bar.render-avg {\n background: #4CAF50;\n }\n \n .perf-dashboard-chart-bar.render-max {\n background: #FF5722;\n }\n \n .perf-dashboard-chart-bar.component-updates {\n background: #2196F3;\n }\n \n .perf-dashboard-chart-bar.dom-ops {\n background: #9C27B0;\n }\n \n .perf-dashboard-chart-bar.memory {\n background: #FFC107;\n }\n \n .perf-dashboard-legend {\n position: absolute;\n bottom: 5px;\n left: 5px;\n font-size: 10px;\n color: #aaa;\n }\n \n .perf-dashboard-metrics {\n width: 100%;\n border-collapse: collapse;\n font-size: 12px;\n }\n \n .perf-dashboard-metrics th {\n text-align: left;\n padding: 4px;\n border-bottom: 1px solid #444;\n }\n \n .perf-dashboard-metrics td {\n padding: 3px;\n border-bottom: 1px solid #333;\n }\n \n .perf-dashboard-metrics td:last-child {\n text-align: right;\n }\n \n .perf-dashboard-footer {\n font-size: 10px;\n margin-top: 10px;\n text-align: center;\n color: #888;\n }\n";
@@ -0,0 +1,40 @@
1
+ import type { Handler, Metavars, Template } from '..';
2
+ type RouteDef<MT extends Metavars> = {
3
+ path: string;
4
+ template: Template<MT>;
5
+ default?: boolean;
6
+ };
7
+ export type Input<RouteInput extends Object> = {
8
+ global?: boolean;
9
+ routes: RouteDef<Metavars<RouteInput>>[];
10
+ };
11
+ type Route = RouteDef<any> & {
12
+ pathVars: string[];
13
+ pathRegex: RegExp;
14
+ };
15
+ type State = {
16
+ page: Template<any> | null;
17
+ params: Record<string, any>;
18
+ query: Record<string, any>;
19
+ };
20
+ type Static = {
21
+ global: boolean;
22
+ routes: Route[];
23
+ defaultPath: string | null;
24
+ currentPath: string | null;
25
+ currentRoute: Route | null;
26
+ };
27
+ type Context = {
28
+ navigate: (path: string, back?: boolean) => void;
29
+ };
30
+ export declare const state: State;
31
+ export declare const _static: Static;
32
+ export declare const context: string[];
33
+ declare global {
34
+ interface Window {
35
+ navigate: (path: string, back?: boolean) => void;
36
+ }
37
+ }
38
+ export declare const handler: Handler<Metavars<Input<any>, State, Static, Context>>;
39
+ declare const _default_1: "<{state.page} params=state.params query=state.query/>";
40
+ export default _default_1;
@@ -0,0 +1,17 @@
1
+ import type { Declaration, Handler, Metavars, MeshRenderer, MeshTemplate } from '..';
2
+ export interface Input {
3
+ by: string;
4
+ case: (MeshTemplate & {
5
+ is: string | string[];
6
+ })[];
7
+ renderer: MeshRenderer;
8
+ default?: MeshTemplate;
9
+ }
10
+ export interface State {
11
+ renderer: MeshRenderer | null;
12
+ }
13
+ export declare const declaration: Declaration;
14
+ export declare const state: State;
15
+ export declare const handler: Handler<Metavars<Input, State>>;
16
+ declare const _default: "<{state.renderer}/>";
17
+ export default _default;