@lipsjs/lips 0.1.0 → 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.
- package/README.md +119 -85
- package/dist/lips.js +3836 -0
- package/dist/lips.js.map +28 -0
- package/dist/lips.min.js +9 -2
- package/dist/lips.min.js.map +22 -43
- package/dist/precompile.min.js +20 -0
- package/dist/precompile.min.js.map +13 -0
- package/dist/runtime.min.js +4 -0
- package/dist/runtime.min.js.map +19 -0
- package/dist/types/events.d.ts +1 -1
- package/dist/types/ir/compiler.d.ts +153 -0
- package/dist/types/ir/expression.d.ts +120 -0
- package/dist/types/ir/facade.d.ts +94 -0
- package/dist/types/ir/index.d.ts +15 -0
- package/dist/types/ir/parser.d.ts +124 -0
- package/dist/types/ir/router.d.ts +47 -0
- package/dist/types/ir/runtime.d.ts +95 -0
- package/dist/types/ir/signal.d.ts +26 -0
- package/dist/types/ir/swap.d.ts +23 -0
- package/dist/types/lips.d.ts +16 -35
- package/dist/types/precompile.d.ts +60 -0
- package/dist/types/runtime.d.ts +16 -0
- package/dist/types/stylesheet.d.ts +24 -40
- package/dist/types/types.d.ts +49 -185
- package/package.json +29 -10
- package/dist/test.component.min.js +0 -283
- package/dist/test.component.min.js.map +0 -50
- package/dist/test.stress.min.js +0 -476
- package/dist/test.stress.min.js.map +0 -50
- package/dist/types/component.d.ts +0 -107
- package/dist/types/dws.d.ts +0 -14
- package/dist/types/iuc/index.d.ts +0 -25
- package/dist/types/iuc/tick.d.ts +0 -38
- package/dist/types/iuc.d.ts +0 -25
- package/dist/types/metrics.d.ts +0 -50
- package/dist/types/preprocess.d.ts +0 -2
- package/dist/types/signal.d.ts +0 -30
- package/dist/types/syntax/async.d.ts +0 -16
- package/dist/types/syntax/for.d.ts +0 -25
- package/dist/types/syntax/if.d.ts +0 -14
- package/dist/types/syntax/router.d.ts +0 -40
- package/dist/types/syntax/switch.d.ts +0 -16
- package/dist/types/tick.d.ts +0 -38
- package/dist/types/uqs.d.ts +0 -37
- package/dist/types/utils.d.ts +0 -45
|
@@ -1,51 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Component stylesheets — scoped by a `rel` attribute selector,
|
|
3
|
+
* injected once per namespace and reference counted so shared
|
|
4
|
+
* components clean up correctly. Native DOM only (no cash-dom).
|
|
5
|
+
*
|
|
6
|
+
* The CSS preprocessor (Stylis) is INJECTED, not imported, so the
|
|
7
|
+
* precompiled-only `./runtime` build tree-shakes it out entirely.
|
|
8
|
+
* The full `@lipsjs/lips` entry wires it (see src/lips.ts); a build
|
|
9
|
+
* without it warns and skips source stylesheets rather than shipping
|
|
10
|
+
* a preprocessor a precompiled/CSP app never needs.
|
|
11
|
+
*/
|
|
12
|
+
export type StyleSettings = {
|
|
2
13
|
sheet?: string;
|
|
14
|
+
/** Inject globally instead of scoping to `[rel="<nsp>"]` */
|
|
3
15
|
meta?: boolean;
|
|
4
|
-
custom?: {
|
|
5
|
-
enabled: boolean;
|
|
6
|
-
allowedRules: string[];
|
|
7
|
-
allowedProperties: string[];
|
|
8
|
-
};
|
|
9
16
|
};
|
|
17
|
+
type StyleCompiler = (css: string) => string;
|
|
18
|
+
/** Wire the CSS preprocessor (full build only) */
|
|
19
|
+
export declare function setStyleCompiler(fn: StyleCompiler): void;
|
|
10
20
|
export default class Stylesheet {
|
|
11
21
|
private nsp;
|
|
12
22
|
private settings;
|
|
13
|
-
private $head;
|
|
14
23
|
constructor(nsp: string, settings?: StyleSettings);
|
|
24
|
+
private get rel();
|
|
25
|
+
private get styleElement();
|
|
15
26
|
/**
|
|
16
|
-
*
|
|
27
|
+
* Compile and inject. `dindex` counts live instances sharing this
|
|
28
|
+
* namespace: it increases per instance and decreases on clear, so
|
|
29
|
+
* the element is removed only by the last one out.
|
|
17
30
|
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
|
|
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>>;
|
|
31
|
+
load(settings: StyleSettings): HTMLStyleElement | undefined;
|
|
32
|
+
/** Release this instance's reference; removes the element at zero */
|
|
33
|
+
clear(): void;
|
|
50
34
|
}
|
|
51
35
|
export {};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,211 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Public types.
|
|
3
|
+
*
|
|
4
|
+
* Component authoring shape — the same plain object the framework has
|
|
5
|
+
* always taken, and the serializable artifact a generator can emit:
|
|
6
|
+
*
|
|
7
|
+
* { default, state, handler, _static, context, macros, stylesheet }
|
|
8
|
+
*/
|
|
4
9
|
export interface Metavars<Input extends Object = {}, State extends Object = {}, Static extends Object = {}, Context extends Object = {}> {
|
|
5
10
|
Input: Input;
|
|
6
11
|
State: State;
|
|
7
12
|
Static: Static;
|
|
8
13
|
Context: Context;
|
|
9
14
|
}
|
|
10
|
-
export
|
|
11
|
-
|
|
15
|
+
export type LifeCycleEventTypes = 'onCreate' | 'onInput' | 'onMount' | 'onRender' | 'onUpdate' | 'onAttach' | 'onDetach' | 'onContext' | 'onError' | 'onDestroy';
|
|
16
|
+
/**
|
|
17
|
+
* `this` inside a handler: reactive stores plus the component's
|
|
18
|
+
* own API (emit/on/off, setContext).
|
|
19
|
+
*/
|
|
20
|
+
export interface ComponentSelf<MT extends Metavars = Metavars> {
|
|
12
21
|
state: MT['State'];
|
|
22
|
+
input: MT['Input'];
|
|
13
23
|
context: MT['Context'];
|
|
24
|
+
static: MT['Static'];
|
|
25
|
+
emit(event: string, ...args: any[]): void;
|
|
26
|
+
on(event: string, fn: (...args: any[]) => void): ComponentSelf<MT>;
|
|
27
|
+
off(event: string): ComponentSelf<MT>;
|
|
28
|
+
setContext(arg: string | Record<string, any>, value?: any): void;
|
|
29
|
+
[key: string]: any;
|
|
14
30
|
}
|
|
15
|
-
export type Variable = {
|
|
16
|
-
value: any;
|
|
17
|
-
type: 'let' | 'const' | 'arg';
|
|
18
|
-
};
|
|
19
|
-
export type VariableArguments = Record<string, any>;
|
|
20
|
-
export type VariableSet = Record<string, Variable> & {
|
|
21
|
-
__arguments__?: VariableArguments;
|
|
22
|
-
};
|
|
23
|
-
export interface SpreadOpeartor {
|
|
24
|
-
each(key: string, value: any): void;
|
|
25
|
-
nullify?: (attrs: string[]) => void;
|
|
26
|
-
get keystore(): string[];
|
|
27
|
-
set keystore(__: string[]);
|
|
28
|
-
memo: VariableSet;
|
|
29
|
-
}
|
|
30
|
-
export type I18nVariant = Record<string, string>;
|
|
31
|
-
export type I18nFormat = {
|
|
32
|
-
type: string;
|
|
33
|
-
value: string | I18nVariant | Record<string, string | I18nVariant>;
|
|
34
|
-
};
|
|
35
|
-
export type Dictionary = Record<string, string | I18nFormat | I18nVariant>;
|
|
36
|
-
export type DeclarationTagType = 'nexted' | 'child';
|
|
37
|
-
export type DeclarationTag = {
|
|
38
|
-
type: DeclarationTagType;
|
|
39
|
-
many?: boolean;
|
|
40
|
-
alts?: string[];
|
|
41
|
-
optional?: boolean;
|
|
42
|
-
};
|
|
43
|
-
export type Declaration = {
|
|
44
|
-
name: string;
|
|
45
|
-
syntax?: boolean;
|
|
46
|
-
iterator?: boolean;
|
|
47
|
-
contents?: boolean;
|
|
48
|
-
tags?: Record<string, DeclarationTag>;
|
|
49
|
-
};
|
|
50
|
-
export type LifeCycleEventTypes = 'onCreate' | 'onInput' | 'onMount' | 'onRender' | 'onUpdate' | 'onAttach' | 'onDetach' | 'onContext' | 'onDestroy';
|
|
51
31
|
export interface LifecycleEvents<MT extends Metavars> {
|
|
52
|
-
onCreate
|
|
53
|
-
onInput
|
|
54
|
-
onMount
|
|
55
|
-
onRender
|
|
56
|
-
onUpdate
|
|
57
|
-
onAttach
|
|
58
|
-
onDetach
|
|
59
|
-
onContext
|
|
60
|
-
|
|
32
|
+
onCreate(this: ComponentSelf<MT>): void;
|
|
33
|
+
onInput(this: ComponentSelf<MT>): void;
|
|
34
|
+
onMount(this: ComponentSelf<MT>): void;
|
|
35
|
+
onRender(this: ComponentSelf<MT>): void;
|
|
36
|
+
onUpdate(this: ComponentSelf<MT>): void;
|
|
37
|
+
onAttach(this: ComponentSelf<MT>): void;
|
|
38
|
+
onDetach(this: ComponentSelf<MT>): void;
|
|
39
|
+
onContext(this: ComponentSelf<MT>): void;
|
|
40
|
+
onError(this: ComponentSelf<MT>, error: Error): void;
|
|
41
|
+
onDestroy(this: ComponentSelf<MT>): void;
|
|
61
42
|
}
|
|
62
43
|
export type Handler<MT extends Metavars> = Partial<LifecycleEvents<MT>> & {
|
|
63
|
-
[K in string as K extends keyof LifecycleEvents<MT> ? never : K]?: (this:
|
|
44
|
+
[K in string as K extends keyof LifecycleEvents<MT> ? never : K]?: (this: ComponentSelf<MT>, ...args: any[]) => any;
|
|
64
45
|
};
|
|
65
|
-
export type Template<MT extends Metavars> = {
|
|
46
|
+
export type Template<MT extends Metavars = Metavars> = {
|
|
47
|
+
/** Template source — the component's markup */
|
|
66
48
|
default?: string;
|
|
67
49
|
state?: MT['State'];
|
|
68
50
|
_static?: MT['Static'];
|
|
51
|
+
/** Context fields this component subscribes to (drives onContext) */
|
|
69
52
|
context?: string[];
|
|
53
|
+
/** `<macro [argv] name="X">…</macro>` definitions, inlined at compile time */
|
|
70
54
|
macros?: string;
|
|
71
55
|
handler?: Handler<MT>;
|
|
72
56
|
stylesheet?: string;
|
|
73
|
-
declaration?: Declaration;
|
|
74
|
-
};
|
|
75
|
-
export type DynamicTemplate<MT extends Metavars> = {
|
|
76
|
-
name?: string;
|
|
77
|
-
template?: Template<MT>;
|
|
78
|
-
};
|
|
79
|
-
export type ComponentScope<MT extends Metavars> = {
|
|
80
|
-
input?: MT['Input'];
|
|
81
|
-
state?: MT['State'];
|
|
82
|
-
context?: MT['Context'];
|
|
83
|
-
_static?: MT['Static'];
|
|
84
|
-
macros?: string;
|
|
85
|
-
handler?: Handler<MT>;
|
|
86
|
-
stylesheet?: string;
|
|
87
|
-
declaration?: Declaration;
|
|
88
|
-
};
|
|
89
|
-
export type ComponentOptions<Context extends Object> = {
|
|
90
|
-
lips: Lips<Context>;
|
|
91
|
-
debug?: boolean;
|
|
92
|
-
prepath?: string;
|
|
93
|
-
boundaries?: FragmentBoundaries;
|
|
94
57
|
};
|
|
95
|
-
export type LipsConfig<Context extends Object> = {
|
|
58
|
+
export type LipsConfig<Context extends Object = {}> = {
|
|
96
59
|
debug?: boolean;
|
|
97
60
|
context?: Context;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
allowedRules: string[];
|
|
106
|
-
allowedProperties: string[];
|
|
107
|
-
};
|
|
61
|
+
/**
|
|
62
|
+
* Expression execution:
|
|
63
|
+
* - 'compiled' (default) — one cached Function per expression
|
|
64
|
+
* - 'interpreted' — sandboxed AST walker, required under a CSP
|
|
65
|
+
* without `unsafe-eval`
|
|
66
|
+
*/
|
|
67
|
+
mode?: 'compiled' | 'interpreted';
|
|
108
68
|
};
|
|
109
69
|
export type EventListener = (...args: any[]) => void;
|
|
110
|
-
export type
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
export type SyntaxAttributes = {
|
|
115
|
-
literals: Record<string, any>;
|
|
116
|
-
expressions: Record<string, any>;
|
|
117
|
-
map: {
|
|
118
|
-
explicitAttrs: string[];
|
|
119
|
-
spreadAttrs: string[];
|
|
120
|
-
beforeSpreadAttrs: string[];
|
|
121
|
-
afterSpreadAttrs: string[];
|
|
122
|
-
metaAttrs: string[];
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
|
-
export interface VirtualEvent<MT extends Metavars> {
|
|
126
|
-
element: Cash | Component<MT>;
|
|
127
|
-
_event: string;
|
|
128
|
-
instruction: string;
|
|
129
|
-
nodepath: string;
|
|
130
|
-
scope?: Record<string, any>;
|
|
131
|
-
get __dependencies__(): FGUDependencies;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* (FGU) Fine-Grain Update Dependencies
|
|
135
|
-
*/
|
|
136
|
-
export type NodeType = 'component' | 'dynamic' | 'element' | 'event' | 'macro' | 'text' | 'let' | 'log';
|
|
137
|
-
export type FGUDTarget = 'event-handler' | 'spread-attr' | 'meta-attr' | 'argument' | 'value' | 'attr' | 'dtag';
|
|
138
|
-
export interface FGUSync {
|
|
139
|
-
memo?: VariableSet;
|
|
140
|
-
cleanup?: () => void;
|
|
141
|
-
}
|
|
142
|
-
export interface FGUDependency {
|
|
143
|
-
nodetype: NodeType;
|
|
144
|
-
nodepath: string;
|
|
145
|
-
deppath?: string;
|
|
146
|
-
target: FGUDTarget;
|
|
147
|
-
$fragment: Cash | null;
|
|
148
|
-
boundaries?: FragmentBoundaries;
|
|
149
|
-
haslet?: boolean;
|
|
150
|
-
syntax?: boolean;
|
|
151
|
-
partial?: string[];
|
|
152
|
-
priority?: number;
|
|
153
|
-
level?: number;
|
|
154
|
-
garbage?: boolean;
|
|
155
|
-
update: (memo: VariableSet, by?: string) => FGUSync | void;
|
|
156
|
-
}
|
|
157
|
-
export type FGUDependencies = Map<string, Map<string, FGUDependency>>;
|
|
158
|
-
export type FGUDBatchEntry = {
|
|
159
|
-
dep: string;
|
|
160
|
-
deppath: string;
|
|
161
|
-
priority?: number;
|
|
162
|
-
};
|
|
163
|
-
export type FGUDMemorySlot = {
|
|
164
|
-
tracks: Map<string, number>;
|
|
165
|
-
memo: VariableSet;
|
|
166
|
-
};
|
|
167
|
-
export type FGUDMemory = Map<string, FGUDMemorySlot>;
|
|
168
|
-
export interface I18nDependency {
|
|
169
|
-
nodetype: NodeType;
|
|
170
|
-
nodepath: string;
|
|
171
|
-
deppath?: string;
|
|
172
|
-
target: FGUDTarget;
|
|
173
|
-
$fragment: Cash;
|
|
174
|
-
priority?: number;
|
|
175
|
-
update: (memo: VariableSet, by?: string) => FGUSync | void;
|
|
176
|
-
}
|
|
177
|
-
export type RenderedNode<MT extends Metavars> = {
|
|
178
|
-
$log: Cash;
|
|
179
|
-
dependencies: FGUDependencies;
|
|
180
|
-
events?: VirtualEvent<MT>[];
|
|
181
|
-
};
|
|
182
|
-
export type FragmentBoundaries = {
|
|
183
|
-
start: Comment;
|
|
184
|
-
end: Comment;
|
|
185
|
-
};
|
|
186
|
-
export interface MeshRenderer {
|
|
187
|
-
path: string | null;
|
|
188
|
-
argv: string[];
|
|
189
|
-
mesh(argvalues?: VariableSet, scope?: VariableSet, suffix?: string): Cash | null;
|
|
190
|
-
update(deps: string[], argvalues: VariableSet, scope: VariableSet, boundaries?: FragmentBoundaries, suffix?: string): void;
|
|
191
|
-
cleanup(boundaries?: FragmentBoundaries, suffix?: string | true): void;
|
|
192
|
-
demarcate($log: Cash, sufix: string): {
|
|
193
|
-
$partial: Cash;
|
|
194
|
-
boundaries: FragmentBoundaries;
|
|
195
|
-
};
|
|
196
|
-
fill($log: Cash, boundaries?: FragmentBoundaries): void;
|
|
197
|
-
}
|
|
198
|
-
export type MeshTemplate = Record<string, any> & {
|
|
199
|
-
renderer: MeshRenderer;
|
|
70
|
+
export type I18nVariant = Record<string, string>;
|
|
71
|
+
export type I18nFormat = {
|
|
72
|
+
type: string;
|
|
73
|
+
value: string | I18nVariant | Record<string, string | I18nVariant>;
|
|
200
74
|
};
|
|
201
|
-
export
|
|
202
|
-
argv: string[];
|
|
203
|
-
scope: VariableSet;
|
|
204
|
-
declaration?: Declaration;
|
|
205
|
-
useAttributes: boolean;
|
|
206
|
-
xmlns?: boolean;
|
|
207
|
-
$node: Cash;
|
|
208
|
-
meshPath: string | null;
|
|
209
|
-
fragmentPath: string;
|
|
210
|
-
fragmentBoundaries: FragmentBoundaries;
|
|
211
|
-
}
|
|
75
|
+
export type Dictionary = Record<string, string | I18nFormat | I18nVariant>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lipsjs/lips",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Fast, Lightweight Reactive UI Framework",
|
|
5
5
|
"main": "./dist/lips.min.js",
|
|
6
6
|
"types": "./dist/types/lips.d.ts",
|
|
@@ -9,28 +9,47 @@
|
|
|
9
9
|
],
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
+
"types": "./dist/types/lips.d.ts",
|
|
12
13
|
"import": "./dist/lips.min.js",
|
|
13
|
-
"
|
|
14
|
-
|
|
14
|
+
"default": "./dist/lips.min.js"
|
|
15
|
+
},
|
|
16
|
+
"./dev": {
|
|
17
|
+
"types": "./dist/types/lips.d.ts",
|
|
18
|
+
"import": "./dist/lips.js",
|
|
19
|
+
"default": "./dist/lips.js"
|
|
20
|
+
},
|
|
21
|
+
"./runtime": {
|
|
22
|
+
"types": "./dist/types/runtime.d.ts",
|
|
23
|
+
"import": "./dist/runtime.min.js",
|
|
24
|
+
"default": "./dist/runtime.min.js"
|
|
25
|
+
},
|
|
26
|
+
"./precompile": {
|
|
27
|
+
"types": "./dist/types/precompile.d.ts",
|
|
28
|
+
"import": "./dist/precompile.min.js",
|
|
29
|
+
"default": "./dist/precompile.min.js"
|
|
15
30
|
}
|
|
16
31
|
},
|
|
17
32
|
"author": "Fabrice K.E.M",
|
|
18
33
|
"private": false,
|
|
19
34
|
"scripts": {
|
|
20
|
-
"dev": "bun
|
|
21
|
-
"
|
|
35
|
+
"dev": "bun build --entrypoints ./src/lips.ts --entry-naming lips.min.[ext] --minify --outdir ./dist --target browser --format esm --sourcemap=external --watch",
|
|
36
|
+
"build": "bun build --entrypoints ./src/lips.ts --entry-naming lips.min.[ext] --minify --outdir ./dist --target browser --format esm --sourcemap=external && bun build --entrypoints ./src/lips.ts --entry-naming lips.[ext] --outdir ./dist --target browser --format esm --sourcemap=external && bun build --entrypoints ./src/runtime.ts --entry-naming runtime.min.[ext] --minify --outdir ./dist --target browser --format esm --sourcemap=external && bun build --entrypoints ./src/precompile.ts --entry-naming precompile.min.[ext] --minify --outdir ./dist --target browser --format esm --sourcemap=external",
|
|
22
37
|
"build:declaration": "tsc --project tsconfig.types.json",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
38
|
+
"compile": "bun run build",
|
|
39
|
+
"typecheck": "tsc --noEmit",
|
|
40
|
+
"prepack": "bun run build && bun run build:declaration",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"test:watch": "vitest",
|
|
43
|
+
"size": "node scripts/size-check.mjs"
|
|
25
44
|
},
|
|
26
45
|
"dependencies": {
|
|
27
|
-
"cash-dom": "^8.1.5",
|
|
28
46
|
"stylis": "^4.3.4"
|
|
29
47
|
},
|
|
30
48
|
"devDependencies": {
|
|
31
49
|
"@types/stylis": "^4.2.7",
|
|
32
|
-
"
|
|
33
|
-
"typescript": "^5.7.3"
|
|
50
|
+
"jsdom": "^29.1.1",
|
|
51
|
+
"typescript": "^5.7.3",
|
|
52
|
+
"vitest": "^4.1.10"
|
|
34
53
|
},
|
|
35
54
|
"directories": {
|
|
36
55
|
"dist": "dist/",
|