ripple 0.2.91 → 0.2.92

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.
@@ -1,5 +1,301 @@
1
-
1
+ // Ripple augmentation for ESTree function nodes
2
+ declare module 'estree' {
3
+ interface FunctionDeclaration {
4
+ metadata?: any;
5
+ }
6
+ interface FunctionExpression {
7
+ metadata?: any;
8
+ }
9
+ interface ArrowFunctionExpression {
10
+ metadata?: any;
11
+ }
12
+ interface Identifier {
13
+ tracked?: boolean;
14
+ }
15
+ }
16
+ import type { Comment, Position } from 'acorn';
17
+ import type {
18
+ Program,
19
+ Node,
20
+ Identifier,
21
+ VariableDeclarator,
22
+ FunctionDeclaration,
23
+ FunctionExpression,
24
+ ArrowFunctionExpression,
25
+ ClassDeclaration,
26
+ ImportDeclaration,
27
+ ArrayExpression,
28
+ ObjectExpression,
29
+ Expression,
30
+ Property,
31
+ SpreadElement,
32
+ Pattern,
33
+ } from 'estree';
2
34
 
3
35
  export interface CompileResult {
4
- // TODO
5
- }
36
+ // TODO
37
+ }
38
+
39
+ /**
40
+ * Parse error information
41
+ */
42
+ export interface ParseError {
43
+ message: string;
44
+ pos: number;
45
+ loc: Position;
46
+ }
47
+
48
+ /**
49
+ * Result of parsing operation
50
+ */
51
+ export interface ParseResult {
52
+ ast: Program;
53
+ errors: ParseError[];
54
+ }
55
+
56
+ /**
57
+ * Comment with location information
58
+ */
59
+ export interface CommentWithLocation extends Comment {
60
+ start: number;
61
+ end: number;
62
+ }
63
+
64
+ /**
65
+ * Tracked array expression node
66
+ */
67
+ export interface TrackedArrayExpression extends Omit<ArrayExpression, 'type'> {
68
+ type: 'TrackedArrayExpression';
69
+ elements: (Expression | null)[];
70
+ }
71
+
72
+ /**
73
+ * Tracked object expression node
74
+ */
75
+ export interface TrackedObjectExpression extends Omit<ObjectExpression, 'type'> {
76
+ type: 'TrackedObjectExpression';
77
+ properties: (Property | SpreadElement)[];
78
+ }
79
+
80
+ /**
81
+ * Ripple component node
82
+ */
83
+ export interface Component extends Omit<Node, 'type'> {
84
+ type: 'Component';
85
+ id: Identifier;
86
+ params: Pattern[];
87
+ body: Node[];
88
+ css: any;
89
+ start?: number;
90
+ end?: number;
91
+ loc?: any;
92
+ }
93
+
94
+ /**
95
+ * Ripple element node
96
+ */
97
+ export interface Element extends Omit<Node, 'type'> {
98
+ type: 'Element';
99
+ id: Identifier;
100
+ attributes: Array<Attribute | SpreadAttribute>;
101
+ children: Node[];
102
+ metadata: any;
103
+ }
104
+
105
+ /**
106
+ * Ripple attribute node
107
+ */
108
+ export interface Attribute {
109
+ type: 'Attribute';
110
+ name: Identifier;
111
+ value: Expression | null;
112
+ start?: number;
113
+ end?: number;
114
+ loc?: any;
115
+ }
116
+
117
+ /**
118
+ * Ripple spread attribute node
119
+ */
120
+ export interface SpreadAttribute {
121
+ type: 'SpreadAttribute';
122
+ argument: Expression;
123
+ start?: number;
124
+ end?: number;
125
+ loc?: any;
126
+ }
127
+
128
+ /**
129
+ * Configuration for Ripple parser plugin
130
+ */
131
+ export interface RipplePluginConfig {
132
+ allowSatisfies?: boolean;
133
+ }
134
+
135
+ /**
136
+ * Types of declarations in scope
137
+ */
138
+ export type DeclarationKind =
139
+ | 'var'
140
+ | 'let'
141
+ | 'const'
142
+ | 'function'
143
+ | 'param'
144
+ | 'rest_param'
145
+ | 'component'
146
+ | 'import'
147
+ | 'using'
148
+ | 'await using';
149
+
150
+ /**
151
+ * Binding kinds
152
+ */
153
+ export type BindingKind = 'normal' | 'each' | 'rest_prop' | 'prop' | 'prop_fallback';
154
+
155
+ /**
156
+ * A variable binding in a scope
157
+ */
158
+ export interface Binding {
159
+ /** The identifier node that declares this binding */
160
+ node: Identifier;
161
+ /** References to this binding */
162
+ references: Array<{ node: Identifier; path: Node[] }>;
163
+ /** Initial value/declaration */
164
+ initial: null | Expression | FunctionDeclaration | ClassDeclaration | ImportDeclaration;
165
+ /** Whether this binding has been reassigned */
166
+ reassigned: boolean;
167
+ /** Whether this binding has been mutated (property access) */
168
+ mutated: boolean;
169
+ /** Whether this binding has been updated (reassigned or mutated) */
170
+ updated: boolean;
171
+ /** Whether this binding represents a called function */
172
+ is_called: boolean;
173
+ /** Additional metadata for this binding */
174
+ metadata?: any;
175
+ /** Kind of binding */
176
+ kind: BindingKind;
177
+ /** Declaration kind */
178
+ declaration_kind?: DeclarationKind;
179
+ /** The scope that contains this binding */
180
+ scope?: any;
181
+ }
182
+
183
+ /**
184
+ * Root scope manager
185
+ */
186
+ export interface ScopeRoot {
187
+ /** Set of conflicting/reserved names */
188
+ conflicts: Set<string>;
189
+ /** Generate unique identifier name */
190
+ unique(preferred_name: string): Identifier;
191
+ }
192
+
193
+ /**
194
+ * Lexical scope for variable bindings
195
+ */
196
+ export interface ScopeInterface {
197
+ /** Root scope manager */
198
+ root: ScopeRoot;
199
+ /** Parent scope */
200
+ parent: ScopeInterface | null;
201
+ /** Map of declared bindings */
202
+ declarations: Map<string, Binding>;
203
+ /** Map of declarators to their bindings */
204
+ declarators: Map<VariableDeclarator, Binding[]>;
205
+ /** Map of references in this scope */
206
+ references: Map<string, Array<{ node: Identifier; path: Node[] }>>;
207
+ /** Function nesting depth */
208
+ function_depth: number;
209
+ /** Whether reactive tracing is enabled */
210
+ tracing: null | Expression;
211
+
212
+ /** Create child scope */
213
+ child(porous?: boolean): ScopeInterface;
214
+ /** Declare a binding */
215
+ declare(
216
+ node: Identifier,
217
+ kind: BindingKind,
218
+ declaration_kind: DeclarationKind,
219
+ initial?: null | Expression | FunctionDeclaration | ClassDeclaration | ImportDeclaration,
220
+ ): Binding;
221
+ /** Get binding by name */
222
+ get(name: string): Binding | null;
223
+ /** Get bindings for a declarator */
224
+ get_bindings(node: VariableDeclarator): Binding[];
225
+ /** Find the scope that owns a name */
226
+ owner(name: string): ScopeInterface | null;
227
+ /** Add a reference */
228
+ reference(node: Identifier, path: Node[]): void;
229
+ /** Generate unique identifier name */
230
+ generate(preferred_name: string): string;
231
+ }
232
+
233
+ /**
234
+ * Text node interface
235
+ */
236
+ export interface TextNode {
237
+ type: 'Text';
238
+ expression: Expression;
239
+ start?: number;
240
+ end?: number;
241
+ loc?: any;
242
+ }
243
+
244
+ /**
245
+ * Union type for all Ripple AST nodes
246
+ */
247
+ export type RippleNode = Node | Component | Element | TextNode;
248
+
249
+ /**
250
+ * Compiler state object
251
+ */
252
+ export interface CompilerState {
253
+ /** Current scope */
254
+ scope: ScopeInterface;
255
+ /** Analysis data */
256
+ analysis?: {
257
+ /** Module analysis */
258
+ module?: {
259
+ /** Module scope */
260
+ scope?: {
261
+ /** Module references */
262
+ references?: Set<string>;
263
+ };
264
+ };
265
+ /** Exported identifiers */
266
+ exports?: Array<{ name: string }>;
267
+ };
268
+ /** Scopes map */
269
+ scopes?: Map<RippleNode, ScopeInterface>;
270
+ /** Whether inside head element */
271
+ inside_head?: boolean;
272
+ /** Transform metadata */
273
+ metadata?: {
274
+ spread?: boolean;
275
+ [key: string]: any;
276
+ };
277
+ }
278
+
279
+ /**
280
+ * Transform context object
281
+ */
282
+ export interface TransformContext {
283
+ /** Compiler state */
284
+ state: CompilerState;
285
+ /** AST path */
286
+ path?: RippleNode[];
287
+ /** Visit function */
288
+ visit?: (node: any, state?: any) => any;
289
+ /** Transform metadata */
290
+ metadata?: any;
291
+ }
292
+
293
+ /**
294
+ * Delegated event result
295
+ */
296
+ export interface DelegatedEventResult {
297
+ /** Whether event was hoisted */
298
+ hoisted: boolean;
299
+ /** The hoisted function */
300
+ function?: FunctionExpression | FunctionDeclaration | ArrowFunctionExpression;
301
+ }