@lipsjs/lips 0.1.1 → 0.2.0

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.
Files changed (47) hide show
  1. package/README.md +119 -85
  2. package/dist/lips.js +3836 -0
  3. package/dist/lips.js.map +28 -0
  4. package/dist/lips.min.js +9 -2
  5. package/dist/lips.min.js.map +22 -43
  6. package/dist/precompile.min.js +20 -0
  7. package/dist/precompile.min.js.map +13 -0
  8. package/dist/runtime.min.js +4 -0
  9. package/dist/runtime.min.js.map +19 -0
  10. package/dist/types/events.d.ts +1 -1
  11. package/dist/types/ir/compiler.d.ts +153 -0
  12. package/dist/types/ir/expression.d.ts +120 -0
  13. package/dist/types/ir/facade.d.ts +94 -0
  14. package/dist/types/ir/index.d.ts +15 -0
  15. package/dist/types/ir/parser.d.ts +124 -0
  16. package/dist/types/ir/router.d.ts +47 -0
  17. package/dist/types/ir/runtime.d.ts +95 -0
  18. package/dist/types/ir/signal.d.ts +26 -0
  19. package/dist/types/ir/swap.d.ts +23 -0
  20. package/dist/types/lips.d.ts +16 -37
  21. package/dist/types/precompile.d.ts +60 -0
  22. package/dist/types/runtime.d.ts +16 -0
  23. package/dist/types/stylesheet.d.ts +24 -40
  24. package/dist/types/types.d.ts +49 -185
  25. package/package.json +29 -10
  26. package/dist/test.component.min.js +0 -3
  27. package/dist/test.component.min.js.map +0 -50
  28. package/dist/test.stress.min.js +0 -476
  29. package/dist/test.stress.min.js.map +0 -50
  30. package/dist/types/component.d.ts +0 -107
  31. package/dist/types/constants.d.ts +0 -23
  32. package/dist/types/dws.d.ts +0 -14
  33. package/dist/types/iuc/index.d.ts +0 -25
  34. package/dist/types/iuc/tick.d.ts +0 -38
  35. package/dist/types/iuc.d.ts +0 -25
  36. package/dist/types/metrics.d.ts +0 -50
  37. package/dist/types/preprocess.d.ts +0 -2
  38. package/dist/types/signal.d.ts +0 -30
  39. package/dist/types/syntax/async.d.ts +0 -16
  40. package/dist/types/syntax/for.d.ts +0 -25
  41. package/dist/types/syntax/if.d.ts +0 -14
  42. package/dist/types/syntax/router.d.ts +0 -40
  43. package/dist/types/syntax/switch.d.ts +0 -16
  44. package/dist/types/tick.d.ts +0 -38
  45. package/dist/types/tps.d.ts +0 -11
  46. package/dist/types/uqs.d.ts +0 -37
  47. package/dist/types/utils.d.ts +0 -25
@@ -1,107 +0,0 @@
1
- import type Lips from './lips';
2
- import type { Handler, Metavars, ComponentScope, ComponentOptions, VariableSet, RenderedNode, FGUDependencies, FragmentBoundaries, FGUDMemory } from './types';
3
- import Events from './events';
4
- import Metrics from './metrics';
5
- import { Cash } from 'cash-dom';
6
- import Stylesheet from './stylesheet';
7
- export default class Component<MT extends Metavars> extends Events {
8
- private declaration;
9
- private $?;
10
- input: MT['Input'];
11
- state: MT['State'] & {
12
- toJSON(): MT['State'];
13
- reset(): void;
14
- };
15
- static: MT['Static'];
16
- context: MT['Context'];
17
- __name__: string;
18
- __path__: string;
19
- private __lang__;
20
- private __template__;
21
- private __previous;
22
- private __macros;
23
- private __i18nDeps;
24
- FGUD: FGUDependencies;
25
- FGUDMemory: FGUDMemory;
26
- private PCC;
27
- private VER;
28
- private prepath;
29
- private debug;
30
- private isRendered;
31
- private __setInput;
32
- private __setState;
33
- private __getState;
34
- private UQS;
35
- private ICE;
36
- lips: Lips;
37
- metrics: Metrics;
38
- stylesheet?: Stylesheet;
39
- private __inpath__;
40
- private __inpathCounter__;
41
- private __renderDepth__;
42
- private __boundaries__;
43
- [key: string]: any;
44
- constructor(name: string, template: string, { input, state, context, _static, handler, stylesheet, macros, declaration }: ComponentScope<MT>, options: ComponentOptions<any>);
45
- setContext(arg: Partial<Record<string, any>> | string, value?: any): void;
46
- setInput(input: MT['Input'], memo?: VariableSet): void;
47
- /**
48
- * Inject grain/partial input to current component
49
- * instead of sending a whole updated input
50
- */
51
- subInput(data: Record<string, any>, memo?: VariableSet): this;
52
- setMacros(template: string): void;
53
- setHandler(list: Handler<MT>): void;
54
- setStylesheet(sheet?: string): void;
55
- get node(): Cash | null | undefined;
56
- get boundaries(): FragmentBoundaries | undefined;
57
- render(inpath: string, $nodes?: Cash, scope?: VariableSet, sharedDeps?: FGUDependencies, xmlns?: boolean): RenderedNode<MT>;
58
- destroy(): void;
59
- private __meshwire__;
60
- private __getBoundaries__;
61
- private __emptyBoundaries__;
62
- private __fillBoundaries__;
63
- private __getAttributes__;
64
- private __withPath__;
65
- private __getPathParent__;
66
- private __hasSamePathParent__;
67
- private __evaluate__;
68
- private __evaluateFunction__;
69
- private __evaluateSpreadAttr__;
70
- private __interpolate__;
71
- private __attachEvent__;
72
- private __detachEvent__;
73
- private __extractTextDeps__;
74
- private __extractExpressionDeps__;
75
- private __isReactive__;
76
- /**
77
- * Store dependencies memory separately:
78
- *
79
- * IMPORTANT: Every node's tracked deps share
80
- * the same memo reference by the path
81
- * of that node.
82
- *
83
- * Example 1: `<div id=state.item.id style="padding: {input.size/2}">...</div>`
84
- * The dependencies tracking `id` and `style` attributes
85
- * will respectively share the memo that is referenced by
86
- * the `div` element's path
87
- * Example 2. `<span>{state.label} - {count}</span>`
88
- * The `state.label` and `count` dependencies will be
89
- * each tracked using the `span` text content element's
90
- * memo.
91
- *
92
- * Same procedure for `event-handlers`
93
- */
94
- private __bindMemo__;
95
- private __unbindMemo__;
96
- private __trackDep__;
97
- private __trackTranslationDep__;
98
- private __valueDep__;
99
- private __shouldUpdate__;
100
- private __updateDepNodes__;
101
- private __updateVarDepNodes__;
102
- private __updateArgumentsDepNodes__;
103
- private __updateI18nDepNodes__;
104
- appendTo(arg: Cash | string): this;
105
- prependTo(arg: Cash | string): this;
106
- replaceWith(arg: Cash | string): this;
107
- }
@@ -1,23 +0,0 @@
1
- export declare const ROOT_PATH = "#0";
2
- export declare const I18N_ATTR_FLAG = "i18n";
3
- export declare const SYNCTAX_VAR_FLAG = "syn:";
4
- export declare const FUNCTION_ATTR_FLAG = "fn:";
5
- export declare const EVENT_LISTENER_FLAG = "on-";
6
- export declare const SPREAD_VAR_PATTERN: RegExp;
7
- export declare const ARGUMENT_VAR_PATTERN: RegExp;
8
- export declare const INTERPOLATE_PATTERN: RegExp;
9
- export declare const META_ATTRIBUTES: string[];
10
- export declare const NATIVE_SYNTAX_TAGS: string[];
11
- export declare const LAYOUT_AFFECTING_ATTRS: string[];
12
- export declare const NODE_PREFIX = ":n";
13
- export declare const PARTIAL_ROOT_PREFIX = ":pr";
14
- export declare const MACRO_PREFIX = "m";
15
- export declare const COMPONENT_PREFIX = "c";
16
- export declare const SYNTAX_COMPONENT_PREFIX = "x";
17
- export declare const DEFAULT_PARTIAL_PATH_SLOT = "*";
18
- export declare const GENERIC_TAGNAME_ATTR = ":xtag";
19
- export declare const DYNAMIC_TAGNAME_ATTR = ":dtag";
20
- /**
21
- * Constant for max update type priorities
22
- */
23
- export declare const MAX_PRIORITY_TYPES = 100;
@@ -1,14 +0,0 @@
1
- import { Metavars } from './types';
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
- }
@@ -1,25 +0,0 @@
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
- }
@@ -1,38 +0,0 @@
1
- /**
2
- * A more efficient scheduler using microtasks
3
- * for component updates
4
- */
5
- export default class NextTick {
6
- private pendingComponents;
7
- private isPending;
8
- private callbacks;
9
- /**
10
- * Register a component update callback
11
- */
12
- register(ref: string, callback: Function): void;
13
- /**
14
- * Unregister a component
15
- */
16
- unregister(ref: string): void;
17
- /**
18
- * Queue a component update to be processed
19
- * in the next tick of the event loop
20
- */
21
- queue(ref: string): void;
22
- /**
23
- * Schedule update using microtasks
24
- */
25
- private schedule;
26
- /**
27
- * Process all pending component updates
28
- */
29
- private process;
30
- /**
31
- * Clear all pending updates and reset state
32
- */
33
- clear(): void;
34
- /**
35
- * Complete disposal of all resources
36
- */
37
- dispose(): void;
38
- }
@@ -1,25 +0,0 @@
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
- }
@@ -1,50 +0,0 @@
1
- export interface MetricStats {
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
- i18nTrackCount: number;
17
- i18nUpdateCount: number;
18
- dependencyTrackCount: number;
19
- dependencyUpdateCount: number;
20
- batchSize: number;
21
- batchCount: number;
22
- errorCount: number;
23
- }
24
- export default class Metrics {
25
- private debug;
26
- private initialStats;
27
- stats: MetricStats;
28
- private renderStartTime;
29
- private renderTimes;
30
- private measurementCount;
31
- private maxMeasurements;
32
- private loggingInterval;
33
- private autoSaveInterval?;
34
- constructor(debug?: boolean);
35
- private storeMetrics;
36
- startRender(): void;
37
- endRender(): void;
38
- inc(metric: keyof MetricStats): void;
39
- dec(metric: keyof MetricStats): void;
40
- record(metric: keyof MetricStats, value: number): void;
41
- add(metric: keyof MetricStats, value: number): void;
42
- reset(): any;
43
- log(): void;
44
- trackMemory(): void;
45
- trackBatch(size: number): void;
46
- trackError(error: Error): void;
47
- setLoggingInterval(interval: number): void;
48
- getSnapshot(): MetricStats;
49
- dispose(): void;
50
- }
@@ -1,2 +0,0 @@
1
- export declare function isExpression(value: string): boolean;
2
- export declare function preprocessor(str: string): string;
@@ -1,30 +0,0 @@
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 {};
@@ -1,16 +0,0 @@
1
- import type { Declaration, Handler, Metavars, MeshRenderer, MeshTemplate } from '../types';
2
- export interface Input {
3
- await: Promise<any>;
4
- then: MeshTemplate;
5
- catch?: MeshTemplate;
6
- loading?: MeshTemplate;
7
- renderer: MeshRenderer;
8
- }
9
- export interface Static {
10
- initialized: boolean;
11
- finalized: boolean;
12
- prevRenderer: MeshRenderer | null;
13
- }
14
- export declare const declaration: Declaration;
15
- export declare const _static: Static;
16
- export declare const handler: Handler<Metavars<Input, {}, Static>>;
@@ -1,25 +0,0 @@
1
- import type { Declaration, Handler, Metavars, MeshRenderer, VariableSet, FragmentBoundaries } from '../types';
2
- type ArgvTrack = {
3
- argvalues: VariableSet;
4
- boundaries: FragmentBoundaries;
5
- };
6
- export interface Input {
7
- in: Record<string, any> | any[];
8
- from?: number;
9
- to?: number;
10
- renderer?: MeshRenderer;
11
- }
12
- export interface State {
13
- argvlist: Record<string, any>[] | null;
14
- }
15
- export interface Static {
16
- lastIn: any;
17
- argvlist: ArgvTrack[] | null;
18
- initialized: boolean;
19
- prevRenderer: MeshRenderer | null;
20
- processingBatch: boolean;
21
- }
22
- export declare const declaration: Declaration;
23
- export declare const _static: Static;
24
- export declare const handler: Handler<Metavars<Input, State, Static>>;
25
- export {};
@@ -1,14 +0,0 @@
1
- import type { Declaration, Handler, Metavars, MeshRenderer, MeshTemplate } from '../types';
2
- export interface Input {
3
- by: boolean;
4
- renderer?: MeshRenderer;
5
- 'else-if'?: MeshTemplate[];
6
- 'else'?: MeshTemplate;
7
- }
8
- export interface Static {
9
- initialized: boolean;
10
- prevRenderer: MeshRenderer | null;
11
- }
12
- export declare const declaration: Declaration;
13
- export declare const _static: Static;
14
- export declare const handler: Handler<Metavars<Input, {}, Static>>;
@@ -1,40 +0,0 @@
1
- import type { Handler, Metavars, Template } from '../types';
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;
@@ -1,16 +0,0 @@
1
- import type { Declaration, Handler, Metavars, MeshRenderer, MeshTemplate } from '../types';
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 Static {
11
- initialized: boolean;
12
- prevRenderer: MeshRenderer | null;
13
- }
14
- export declare const declaration: Declaration;
15
- export declare const _static: Static;
16
- export declare const handler: Handler<Metavars<Input, {}, Static>>;
@@ -1,38 +0,0 @@
1
- /**
2
- * A more efficient scheduler using microtasks
3
- * for component updates
4
- */
5
- export default class NextTick {
6
- private pendingComponents;
7
- private isPending;
8
- private callbacks;
9
- /**
10
- * Register a component update callback
11
- */
12
- register(ref: string, callback: Function): void;
13
- /**
14
- * Unregister a component
15
- */
16
- unregister(ref: string): void;
17
- /**
18
- * Queue a component update to be processed
19
- * in the next tick of the event loop
20
- */
21
- queue(ref: string): void;
22
- /**
23
- * Schedule update using microtasks
24
- */
25
- private schedule;
26
- /**
27
- * Process all pending component updates
28
- */
29
- private process;
30
- /**
31
- * Clear all pending updates and reset state
32
- */
33
- clear(): void;
34
- /**
35
- * Complete disposal of all resources
36
- */
37
- dispose(): void;
38
- }
@@ -1,11 +0,0 @@
1
- import { Macro, Template } from './lips';
2
- export default class TPS {
3
- private templateStore;
4
- constructor(lipstore: Map<string, Template<any>>);
5
- parse(str: string, altStore?: Map<string, Template<any> | Macro>): any;
6
- isExpression(value: string): boolean;
7
- private matchEventHandlers;
8
- private markExpressionAttributes;
9
- private processAttributes;
10
- private processAttribute;
11
- }
@@ -1,37 +0,0 @@
1
- import type { FGUDBatchEntry, Metavars } from './types';
2
- import type Component from './component';
3
- /**
4
- * Update Queue System for high-frequency DOM updates
5
- */
6
- export default class UpdateQueue<MT extends Metavars> {
7
- private pending;
8
- private isPending;
9
- private component;
10
- private metrics;
11
- constructor(component: Component<MT>);
12
- /**
13
- * Queue updates to be processed in the next tick
14
- */
15
- queue(entry: FGUDBatchEntry): void;
16
- /**
17
- * Apply updates
18
- */
19
- apply({ dep, deppath }: FGUDBatchEntry, by?: string): void;
20
- /**
21
- * Schedule processing using microtasks for better performance
22
- */
23
- private scheduleProcessing;
24
- /**
25
- * Process all queued updates in a batch
26
- */
27
- private processQueue;
28
- /**
29
- * Get current metrics
30
- */
31
- getMetrics(): {
32
- batchCount: number;
33
- lastBatchSize: number;
34
- avgBatchSize: string;
35
- totalUpdates: number;
36
- };
37
- }
@@ -1,25 +0,0 @@
1
- /**
2
- * Deep difference checker with support for Map, Set,
3
- * and various JS built-in types
4
- */
5
- export declare function isDiff(a: any, b: any): boolean;
6
- export declare function isEqual(a: any, b: any): boolean;
7
- /**
8
- * Helper to check if Set contains only
9
- * primitives
10
- */
11
- export declare function isPrimitiveSet(set: Set<any>): boolean;
12
- /**
13
- * Helper to check if Map contains only
14
- * primitives for both keys and values
15
- */
16
- export declare function isPrimitiveMap(map: Map<any, any>): boolean;
17
- export declare function deepClone(obj: any, seen?: WeakMap<object, any>): any;
18
- /**
19
- * Deep assign values to an object using dot notation paths
20
- * @param original The source object to modify
21
- * @param toSet Object containing path-value pairs to set
22
- * @returns A new object with the assigned values
23
- */
24
- export declare function deepAssign<T>(original: T, toSet: Record<string, any>): T;
25
- export declare function sterilize(obj: Record<string, any>): any;