@fynixorg/ui 1.0.21 → 1.0.22

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,1044 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+ import * as ts from "typescript/lib/tsserverlibrary";
4
+ import fs from "fs";
5
+ import path from "path";
6
+ import {
7
+ transformToTsx,
8
+ getLineAndCharacterOfPosition,
9
+ getPositionOfLineAndCharacter,
10
+ mapTransformedToOriginal,
11
+ mapOriginalToTransformed
12
+ } from "../../core/parser/fnx-parser";
13
+ function init(modules) {
14
+ const tsx = modules.typescript;
15
+ function create(info) {
16
+ const config = info.config || {};
17
+ const log = config.debug ? info.project.projectService.logger : { info() {
18
+ }, msg() {
19
+ } };
20
+ log.info?.("[Fynix TS Engine] Loaded with full TypeScript support");
21
+ const fnxCache = /* @__PURE__ */ new Map();
22
+ function transformFnx(source) {
23
+ return transformToTsx(source, {
24
+ debug: config.debug,
25
+ logger: /* @__PURE__ */ __name((message) => log.info?.(message), "logger")
26
+ });
27
+ }
28
+ __name(transformFnx, "transformFnx");
29
+ function mapTransformedToOriginalWithCache(position, cache) {
30
+ return mapTransformedToOriginal(
31
+ position,
32
+ cache.code,
33
+ cache.originalContent,
34
+ cache.lineMap,
35
+ cache.sourceMap
36
+ );
37
+ }
38
+ __name(mapTransformedToOriginalWithCache, "mapTransformedToOriginalWithCache");
39
+ function mapOriginalToTransformedWithCache(position, cache) {
40
+ return mapOriginalToTransformed(
41
+ position,
42
+ cache.code,
43
+ cache.originalContent,
44
+ cache.lineMap,
45
+ cache.sourceMap
46
+ );
47
+ }
48
+ __name(mapOriginalToTransformedWithCache, "mapOriginalToTransformedWithCache");
49
+ const host = info.languageServiceHost;
50
+ const oldGetScriptSnapshot = host.getScriptSnapshot.bind(host);
51
+ const oldGetScriptKind = host.getScriptKind?.bind(host);
52
+ const oldGetScriptVersion = host.getScriptVersion.bind(host);
53
+ const oldResolveModuleNames = host.resolveModuleNames?.bind(host);
54
+ if (oldResolveModuleNames) {
55
+ host.resolveModuleNames = (moduleNames, containingFile, reusedNames, redirectedReference, options) => {
56
+ const resolved = oldResolveModuleNames(
57
+ moduleNames,
58
+ containingFile,
59
+ reusedNames,
60
+ redirectedReference,
61
+ options
62
+ );
63
+ return resolved.map((resolvedModule, index) => {
64
+ const moduleName = moduleNames[index];
65
+ if (config.debug) {
66
+ log.info?.(
67
+ `[Fynix Plugin] Processing module: ${moduleName}, resolved: ${!!resolvedModule}`
68
+ );
69
+ }
70
+ if (!resolvedModule && moduleName.endsWith(".fnx")) {
71
+ let fnxFilePath;
72
+ if (path.isAbsolute(moduleName)) {
73
+ fnxFilePath = moduleName;
74
+ } else {
75
+ const containingDir = path.dirname(containingFile);
76
+ fnxFilePath = path.resolve(containingDir, moduleName);
77
+ }
78
+ if (config.debug) {
79
+ log.info?.(
80
+ `[Fynix Plugin] Trying to resolve .fnx file: ${fnxFilePath}`
81
+ );
82
+ }
83
+ if (fs.existsSync(fnxFilePath)) {
84
+ if (config.debug) {
85
+ log.info?.(`[Fynix Plugin] Found .fnx file: ${fnxFilePath}`);
86
+ }
87
+ return {
88
+ resolvedFileName: fnxFilePath,
89
+ extension: tsx.Extension.Tsx,
90
+ isExternalLibraryImport: false
91
+ };
92
+ }
93
+ const resolvedFnx = tsx.resolveModuleName(
94
+ moduleName,
95
+ containingFile,
96
+ options,
97
+ host
98
+ );
99
+ if (resolvedFnx.resolvedModule) {
100
+ if (config.debug) {
101
+ log.info?.(
102
+ `[Fynix Plugin] Resolved with TS: ${resolvedFnx.resolvedModule.resolvedFileName}`
103
+ );
104
+ }
105
+ return {
106
+ ...resolvedFnx.resolvedModule,
107
+ extension: tsx.Extension.Tsx
108
+ };
109
+ }
110
+ }
111
+ if (!resolvedModule && !moduleName.endsWith(".fnx")) {
112
+ const isRelativeOrLocal = moduleName.startsWith(".") || !moduleName.startsWith("@") && !moduleName.includes("/") && !moduleName.includes("://");
113
+ if (isRelativeOrLocal) {
114
+ const fnxPath = moduleName + ".fnx";
115
+ let fnxFilePath;
116
+ if (path.isAbsolute(fnxPath)) {
117
+ fnxFilePath = fnxPath;
118
+ } else {
119
+ const containingDir = path.dirname(containingFile);
120
+ fnxFilePath = path.resolve(containingDir, fnxPath);
121
+ }
122
+ if (config.debug) {
123
+ log.info?.(
124
+ `[Fynix Plugin] Trying to resolve with .fnx extension: ${fnxFilePath}`
125
+ );
126
+ }
127
+ if (fs.existsSync(fnxFilePath)) {
128
+ if (config.debug) {
129
+ log.info?.(
130
+ `[Fynix Plugin] Found file with .fnx extension: ${fnxFilePath}`
131
+ );
132
+ }
133
+ return {
134
+ resolvedFileName: fnxFilePath,
135
+ extension: tsx.Extension.Tsx,
136
+ isExternalLibraryImport: false
137
+ };
138
+ }
139
+ const resolvedFnx = tsx.resolveModuleName(
140
+ fnxPath,
141
+ containingFile,
142
+ options,
143
+ host
144
+ );
145
+ if (resolvedFnx.resolvedModule) {
146
+ if (config.debug) {
147
+ log.info?.(
148
+ `[Fynix Plugin] Resolved .fnx with TS: ${resolvedFnx.resolvedModule.resolvedFileName}`
149
+ );
150
+ }
151
+ return {
152
+ ...resolvedFnx.resolvedModule,
153
+ extension: tsx.Extension.Tsx
154
+ };
155
+ }
156
+ }
157
+ }
158
+ if (resolvedModule?.resolvedFileName?.endsWith(".fnx")) {
159
+ if (config.debug) {
160
+ log.info?.(
161
+ `[Fynix Plugin] Marking .fnx file as TSX: ${resolvedModule.resolvedFileName}`
162
+ );
163
+ }
164
+ return {
165
+ ...resolvedModule,
166
+ extension: tsx.Extension.Tsx
167
+ };
168
+ }
169
+ return resolvedModule;
170
+ });
171
+ };
172
+ } else {
173
+ host.resolveModuleNames = (moduleNames, containingFile, reusedNames, redirectedReference, options) => {
174
+ return moduleNames.map((moduleName) => {
175
+ if (moduleName.endsWith(".fnx")) {
176
+ let fnxFilePath;
177
+ if (path.isAbsolute(moduleName)) {
178
+ fnxFilePath = moduleName;
179
+ } else {
180
+ const containingDir = path.dirname(containingFile);
181
+ fnxFilePath = path.resolve(containingDir, moduleName);
182
+ }
183
+ if (fs.existsSync(fnxFilePath)) {
184
+ return {
185
+ resolvedFileName: fnxFilePath,
186
+ extension: tsx.Extension.Tsx,
187
+ isExternalLibraryImport: false
188
+ };
189
+ }
190
+ }
191
+ const isRelativeOrLocal = moduleName.startsWith(".") || !moduleName.startsWith("@") && !moduleName.includes("/") && !moduleName.includes("://");
192
+ if (isRelativeOrLocal && !moduleName.endsWith(".fnx")) {
193
+ const fnxPath = moduleName + ".fnx";
194
+ let fnxFilePath;
195
+ if (path.isAbsolute(fnxPath)) {
196
+ fnxFilePath = fnxPath;
197
+ } else {
198
+ const containingDir = path.dirname(containingFile);
199
+ fnxFilePath = path.resolve(containingDir, fnxPath);
200
+ }
201
+ if (fs.existsSync(fnxFilePath)) {
202
+ return {
203
+ resolvedFileName: fnxFilePath,
204
+ extension: tsx.Extension.Tsx,
205
+ isExternalLibraryImport: false
206
+ };
207
+ }
208
+ }
209
+ const resolved = tsx.resolveModuleName(
210
+ moduleName,
211
+ containingFile,
212
+ options,
213
+ host
214
+ );
215
+ return resolved.resolvedModule;
216
+ });
217
+ };
218
+ }
219
+ host.getScriptKind = (fileName) => {
220
+ if (fileName.endsWith(".fnx")) return tsx.ScriptKind.TSX;
221
+ return oldGetScriptKind?.(fileName) ?? tsx.ScriptKind.Unknown;
222
+ };
223
+ const oldFileExists = host.fileExists?.bind(host);
224
+ if (oldFileExists) {
225
+ host.fileExists = (fileName) => {
226
+ if (oldFileExists(fileName)) {
227
+ return true;
228
+ }
229
+ if (fileName.endsWith(".fnx")) {
230
+ try {
231
+ return fs.existsSync(fileName);
232
+ } catch {
233
+ return false;
234
+ }
235
+ }
236
+ return false;
237
+ };
238
+ }
239
+ const oldReadFile = host.readFile?.bind(host);
240
+ if (oldReadFile) {
241
+ host.readFile = (fileName) => {
242
+ const content = oldReadFile(fileName);
243
+ if (content !== void 0) {
244
+ return content;
245
+ }
246
+ if (fileName.endsWith(".fnx")) {
247
+ try {
248
+ return fs.readFileSync(fileName, "utf8");
249
+ } catch {
250
+ return void 0;
251
+ }
252
+ }
253
+ return void 0;
254
+ };
255
+ }
256
+ host.getScriptSnapshot = (fileName) => {
257
+ if (!fileName.endsWith(".fnx")) return oldGetScriptSnapshot(fileName);
258
+ const version = oldGetScriptVersion(fileName);
259
+ const cached = fnxCache.get(fileName);
260
+ if (cached && cached.version === version) {
261
+ return tsx.ScriptSnapshot.fromString(cached.code);
262
+ }
263
+ const snap = oldGetScriptSnapshot(fileName);
264
+ if (!snap) return snap;
265
+ try {
266
+ const content = snap.getText(0, snap.getLength());
267
+ const parsed = transformFnx(content);
268
+ fnxCache.set(fileName, {
269
+ code: parsed.code,
270
+ lineMap: parsed.lineMap,
271
+ sourceMap: parsed.sourceMap,
272
+ version,
273
+ originalContent: content
274
+ });
275
+ log.info?.(
276
+ `[Fynix] Transformed ${fileName} (${content.length} \u2192 ${parsed.code.length} bytes)`
277
+ );
278
+ return tsx.ScriptSnapshot.fromString(parsed.code);
279
+ } catch (error) {
280
+ log.info?.(`[Fynix] Transform error in ${fileName}: ${error}`);
281
+ return snap;
282
+ }
283
+ };
284
+ function remapDiagnostics(diags, fileName) {
285
+ if (!fileName.endsWith(".fnx")) {
286
+ return diags;
287
+ }
288
+ const cache = fnxCache.get(fileName);
289
+ if (!cache) {
290
+ return diags;
291
+ }
292
+ const remapped = [];
293
+ for (const d of diags) {
294
+ if (!d.file || d.start === void 0) {
295
+ remapped.push(d);
296
+ continue;
297
+ }
298
+ const { line: transformedLine } = getLineAndCharacterOfPosition(
299
+ cache.code,
300
+ d.start
301
+ );
302
+ const originalLine = cache.lineMap[transformedLine];
303
+ if (originalLine < 0) {
304
+ const messageText = typeof d.messageText === "string" ? d.messageText : d.messageText.messageText;
305
+ const isModuleResolutionError = messageText.includes("Cannot find module") || messageText.includes("Module not found") || d.code === 2307;
306
+ if (!isModuleResolutionError) {
307
+ if (config.debug) {
308
+ log.info?.(
309
+ `[Fynix] Skipping diagnostic on injected line ${transformedLine}: ${messageText}`
310
+ );
311
+ }
312
+ continue;
313
+ }
314
+ let mappedLine = 0;
315
+ let mappedChar = 0;
316
+ const lines = cache.originalContent.split("\n");
317
+ for (let i = 0; i < lines.length; i++) {
318
+ if (lines[i].includes("@fynixorg/ui")) {
319
+ mappedLine = i;
320
+ mappedChar = lines[i].indexOf("@fynixorg/ui");
321
+ break;
322
+ }
323
+ }
324
+ if (mappedLine === 0 && mappedChar === 0) {
325
+ const logicMatch = cache.originalContent.match(
326
+ /<logic\s+setup\s*=\s*["']?(ts|js)["']?\s*>/i
327
+ );
328
+ if (logicMatch) {
329
+ const before = cache.originalContent.slice(
330
+ 0,
331
+ logicMatch.index + logicMatch[0].length
332
+ );
333
+ mappedLine = before.split("\n").length - 1;
334
+ mappedChar = 0;
335
+ }
336
+ }
337
+ const mappedStart = getPositionOfLineAndCharacter(
338
+ cache.originalContent,
339
+ mappedLine,
340
+ mappedChar
341
+ );
342
+ const remappedDiag2 = {
343
+ ...d,
344
+ file: {
345
+ ...d.file,
346
+ fileName,
347
+ text: cache.originalContent,
348
+ getLineAndCharacterOfPosition: /* @__PURE__ */ __name((pos) => getLineAndCharacterOfPosition(cache.originalContent, pos), "getLineAndCharacterOfPosition"),
349
+ getPositionOfLineAndCharacter: /* @__PURE__ */ __name((line, character) => getPositionOfLineAndCharacter(
350
+ cache.originalContent,
351
+ line,
352
+ character
353
+ ), "getPositionOfLineAndCharacter")
354
+ },
355
+ start: mappedStart,
356
+ length: "@fynixorg/ui".length
357
+ };
358
+ remapped.push(remappedDiag2);
359
+ continue;
360
+ }
361
+ const originalStart = mapTransformedToOriginalWithCache(d.start, cache);
362
+ let originalLength = d.length || 1;
363
+ if (d.length) {
364
+ const transformedEnd = d.start + d.length;
365
+ const originalEnd = mapTransformedToOriginalWithCache(
366
+ transformedEnd,
367
+ cache
368
+ );
369
+ originalLength = Math.max(1, originalEnd - originalStart);
370
+ }
371
+ const originalSnapshot = tsx.ScriptSnapshot.fromString(
372
+ cache.originalContent
373
+ );
374
+ const remappedDiag = {
375
+ ...d,
376
+ file: {
377
+ ...d.file,
378
+ fileName,
379
+ text: cache.originalContent,
380
+ getLineAndCharacterOfPosition: /* @__PURE__ */ __name((pos) => getLineAndCharacterOfPosition(cache.originalContent, pos), "getLineAndCharacterOfPosition"),
381
+ getPositionOfLineAndCharacter: /* @__PURE__ */ __name((line, character) => getPositionOfLineAndCharacter(
382
+ cache.originalContent,
383
+ line,
384
+ character
385
+ ), "getPositionOfLineAndCharacter")
386
+ },
387
+ start: originalStart,
388
+ length: originalLength
389
+ };
390
+ log.info?.(
391
+ `[Fynix] Remapped diagnostic: ${typeof d.messageText === "string" ? d.messageText : d.messageText.messageText} at original pos ${originalStart} (line ${originalLine})`
392
+ );
393
+ remapped.push(remappedDiag);
394
+ }
395
+ return remapped;
396
+ }
397
+ __name(remapDiagnostics, "remapDiagnostics");
398
+ function remapDiagnosticsWithLocation(diags, fileName) {
399
+ if (!fileName.endsWith(".fnx")) {
400
+ return diags;
401
+ }
402
+ const cache = fnxCache.get(fileName);
403
+ if (!cache) {
404
+ return diags;
405
+ }
406
+ const remapped = [];
407
+ for (const d of diags) {
408
+ const { line: transformedLine } = getLineAndCharacterOfPosition(
409
+ cache.code,
410
+ d.start
411
+ );
412
+ const originalLine = cache.lineMap[transformedLine];
413
+ if (originalLine < 0) {
414
+ let nearestLineIndex = transformedLine;
415
+ let nearestOriginalLine = -1;
416
+ for (let i = transformedLine; i < cache.lineMap.length; i++) {
417
+ if (cache.lineMap[i] >= 0) {
418
+ nearestLineIndex = i;
419
+ nearestOriginalLine = cache.lineMap[i];
420
+ break;
421
+ }
422
+ }
423
+ if (nearestOriginalLine < 0) {
424
+ for (let i = transformedLine - 1; i >= 0; i--) {
425
+ if (cache.lineMap[i] >= 0) {
426
+ nearestLineIndex = i;
427
+ nearestOriginalLine = cache.lineMap[i];
428
+ break;
429
+ }
430
+ }
431
+ }
432
+ if (nearestOriginalLine < 0) {
433
+ log.info?.(
434
+ `[Fynix] No valid line mapping found for diagnostic: ${typeof d.messageText === "string" ? d.messageText : d.messageText.messageText}`
435
+ );
436
+ continue;
437
+ }
438
+ const nearestOriginalPos = getPositionOfLineAndCharacter(
439
+ cache.originalContent,
440
+ nearestOriginalLine,
441
+ 0
442
+ );
443
+ const remappedDiag2 = {
444
+ ...d,
445
+ file: {
446
+ ...d.file,
447
+ fileName,
448
+ text: cache.originalContent,
449
+ getLineAndCharacterOfPosition: /* @__PURE__ */ __name((pos) => getLineAndCharacterOfPosition(cache.originalContent, pos), "getLineAndCharacterOfPosition"),
450
+ getPositionOfLineAndCharacter: /* @__PURE__ */ __name((line, character) => getPositionOfLineAndCharacter(
451
+ cache.originalContent,
452
+ line,
453
+ character
454
+ ), "getPositionOfLineAndCharacter")
455
+ },
456
+ start: nearestOriginalPos,
457
+ length: d.length || 1
458
+ };
459
+ log.info?.(
460
+ `[Fynix] Remapped injected line diagnostic to nearest line ${nearestOriginalLine}: ${typeof d.messageText === "string" ? d.messageText : d.messageText.messageText}`
461
+ );
462
+ remapped.push(remappedDiag2);
463
+ continue;
464
+ }
465
+ const originalStart = mapTransformedToOriginalWithCache(d.start, cache);
466
+ let originalLength = d.length || 1;
467
+ if (d.length) {
468
+ const transformedEnd = d.start + d.length;
469
+ const originalEnd = mapTransformedToOriginalWithCache(
470
+ transformedEnd,
471
+ cache
472
+ );
473
+ originalLength = Math.max(1, originalEnd - originalStart);
474
+ }
475
+ const remappedDiag = {
476
+ ...d,
477
+ file: {
478
+ ...d.file,
479
+ fileName,
480
+ text: cache.originalContent,
481
+ getLineAndCharacterOfPosition: /* @__PURE__ */ __name((pos) => getLineAndCharacterOfPosition(cache.originalContent, pos), "getLineAndCharacterOfPosition"),
482
+ getPositionOfLineAndCharacter: /* @__PURE__ */ __name((line, character) => getPositionOfLineAndCharacter(
483
+ cache.originalContent,
484
+ line,
485
+ character
486
+ ), "getPositionOfLineAndCharacter")
487
+ },
488
+ start: originalStart,
489
+ length: originalLength
490
+ };
491
+ log.info?.(
492
+ `[Fynix] Remapped diagnostic: ${typeof d.messageText === "string" ? d.messageText : d.messageText.messageText} at original pos ${originalStart} (line ${originalLine})`
493
+ );
494
+ remapped.push(remappedDiag);
495
+ }
496
+ return remapped;
497
+ }
498
+ __name(remapDiagnosticsWithLocation, "remapDiagnosticsWithLocation");
499
+ const proxy = /* @__PURE__ */ Object.create(null);
500
+ for (const k of Object.keys(
501
+ info.languageService
502
+ )) {
503
+ proxy[k] = (...args) => info.languageService[k].apply(info.languageService, args);
504
+ }
505
+ proxy.getSemanticDiagnostics = (fileName) => {
506
+ const diags = info.languageService.getSemanticDiagnostics(fileName);
507
+ return remapDiagnostics(diags, fileName);
508
+ };
509
+ proxy.getSyntacticDiagnostics = (fileName) => {
510
+ const diags = info.languageService.getSyntacticDiagnostics(fileName);
511
+ return remapDiagnosticsWithLocation(diags, fileName);
512
+ };
513
+ proxy.getSuggestionDiagnostics = (fileName) => {
514
+ const diags = info.languageService.getSuggestionDiagnostics(fileName);
515
+ return remapDiagnosticsWithLocation(diags, fileName);
516
+ };
517
+ proxy.getCompletionsAtPosition = (fileName, position, opts) => {
518
+ let mappedPosition = position;
519
+ if (fileName.endsWith(".fnx")) {
520
+ const cache = fnxCache.get(fileName);
521
+ if (cache) {
522
+ mappedPosition = mapOriginalToTransformedWithCache(position, cache);
523
+ }
524
+ }
525
+ const prior = info.languageService.getCompletionsAtPosition(
526
+ fileName,
527
+ mappedPosition,
528
+ opts
529
+ );
530
+ if (!fileName.endsWith(".fnx")) return prior;
531
+ const fynixCompletions = [
532
+ // Fynix hooks
533
+ {
534
+ name: "nixState",
535
+ kind: tsx.ScriptElementKind.functionElement,
536
+ sortText: "0_nixState",
537
+ labelDetails: { description: "Fynix reactive state" }
538
+ },
539
+ {
540
+ name: "nixStore",
541
+ kind: tsx.ScriptElementKind.functionElement,
542
+ sortText: "0_nixStore",
543
+ labelDetails: { description: "Fynix global store" }
544
+ },
545
+ {
546
+ name: "nixAsync",
547
+ kind: tsx.ScriptElementKind.functionElement,
548
+ sortText: "0_nixAsync",
549
+ labelDetails: { description: "Fynix async state" }
550
+ },
551
+ {
552
+ name: "nixEffect",
553
+ kind: tsx.ScriptElementKind.functionElement,
554
+ sortText: "0_nixEffect",
555
+ labelDetails: { description: "Fynix side effect" }
556
+ },
557
+ {
558
+ name: "nixComputed",
559
+ kind: tsx.ScriptElementKind.functionElement,
560
+ sortText: "0_nixComputed",
561
+ labelDetails: { description: "Fynix computed value" }
562
+ },
563
+ {
564
+ name: "nixForm",
565
+ kind: tsx.ScriptElementKind.functionElement,
566
+ sortText: "0_nixForm",
567
+ labelDetails: { description: "Fynix form handler" }
568
+ },
569
+ {
570
+ name: "nixRef",
571
+ kind: tsx.ScriptElementKind.functionElement,
572
+ sortText: "0_nixRef",
573
+ labelDetails: { description: "Fynix DOM reference" }
574
+ },
575
+ {
576
+ name: "nixCallback",
577
+ kind: tsx.ScriptElementKind.functionElement,
578
+ sortText: "0_nixCallback",
579
+ labelDetails: { description: "Fynix memoized callback" }
580
+ },
581
+ {
582
+ name: "nixMemo",
583
+ kind: tsx.ScriptElementKind.functionElement,
584
+ sortText: "0_nixMemo",
585
+ labelDetails: { description: "Fynix memoized value" }
586
+ },
587
+ {
588
+ name: "nixDebounce",
589
+ kind: tsx.ScriptElementKind.functionElement,
590
+ sortText: "0_nixDebounce",
591
+ labelDetails: { description: "Fynix debounced callback" }
592
+ },
593
+ {
594
+ name: "nixLocalStorage",
595
+ kind: tsx.ScriptElementKind.functionElement,
596
+ sortText: "0_nixLocalStorage",
597
+ labelDetails: { description: "Fynix localStorage state" }
598
+ },
599
+ // Fynix reactive event handlers (r-* attributes)
600
+ {
601
+ name: "r-click",
602
+ kind: tsx.ScriptElementKind.jsxAttribute,
603
+ sortText: "1_r-click",
604
+ labelDetails: { description: "Reactive click handler" },
605
+ insertText: "r-click={($event) => {}}"
606
+ },
607
+ {
608
+ name: "r-dblclick",
609
+ kind: tsx.ScriptElementKind.jsxAttribute,
610
+ sortText: "1_r-dblclick",
611
+ labelDetails: { description: "Reactive double-click handler" },
612
+ insertText: "r-dblclick={($event) => {}}"
613
+ },
614
+ {
615
+ name: "r-submit",
616
+ kind: tsx.ScriptElementKind.jsxAttribute,
617
+ sortText: "1_r-submit",
618
+ labelDetails: { description: "Reactive form submit handler" },
619
+ insertText: "r-submit={($event) => { $event.preventDefault(); }}"
620
+ },
621
+ {
622
+ name: "r-input",
623
+ kind: tsx.ScriptElementKind.jsxAttribute,
624
+ sortText: "1_r-input",
625
+ labelDetails: { description: "Reactive input handler" },
626
+ insertText: "r-input={($event) => {}}"
627
+ },
628
+ {
629
+ name: "r-change",
630
+ kind: tsx.ScriptElementKind.jsxAttribute,
631
+ sortText: "1_r-change",
632
+ labelDetails: { description: "Reactive change handler" },
633
+ insertText: "r-change={($event) => {}}"
634
+ },
635
+ {
636
+ name: "r-focus",
637
+ kind: tsx.ScriptElementKind.jsxAttribute,
638
+ sortText: "1_r-focus",
639
+ labelDetails: { description: "Reactive focus handler" },
640
+ insertText: "r-focus={($event) => {}}"
641
+ },
642
+ {
643
+ name: "r-blur",
644
+ kind: tsx.ScriptElementKind.jsxAttribute,
645
+ sortText: "1_r-blur",
646
+ labelDetails: { description: "Reactive blur handler" },
647
+ insertText: "r-blur={($event) => {}}"
648
+ },
649
+ {
650
+ name: "r-keydown",
651
+ kind: tsx.ScriptElementKind.jsxAttribute,
652
+ sortText: "1_r-keydown",
653
+ labelDetails: { description: "Reactive keydown handler" },
654
+ insertText: "r-keydown={($event) => {}}"
655
+ },
656
+ {
657
+ name: "r-keyup",
658
+ kind: tsx.ScriptElementKind.jsxAttribute,
659
+ sortText: "1_r-keyup",
660
+ labelDetails: { description: "Reactive keyup handler" },
661
+ insertText: "r-keyup={($event) => {}}"
662
+ },
663
+ {
664
+ name: "r-keypress",
665
+ kind: tsx.ScriptElementKind.jsxAttribute,
666
+ sortText: "1_r-keypress",
667
+ labelDetails: { description: "Reactive keypress handler" },
668
+ insertText: "r-keypress={($event) => {}}"
669
+ },
670
+ {
671
+ name: "r-mouseenter",
672
+ kind: tsx.ScriptElementKind.jsxAttribute,
673
+ sortText: "1_r-mouseenter",
674
+ labelDetails: { description: "Reactive mouseenter handler" },
675
+ insertText: "r-mouseenter={($event) => {}}"
676
+ },
677
+ {
678
+ name: "r-mouseleave",
679
+ kind: tsx.ScriptElementKind.jsxAttribute,
680
+ sortText: "1_r-mouseleave",
681
+ labelDetails: { description: "Reactive mouseleave handler" },
682
+ insertText: "r-mouseleave={($event) => {}}"
683
+ },
684
+ {
685
+ name: "r-mouseover",
686
+ kind: tsx.ScriptElementKind.jsxAttribute,
687
+ sortText: "1_r-mouseover",
688
+ labelDetails: { description: "Reactive mouseover handler" },
689
+ insertText: "r-mouseover={($event) => {}}"
690
+ },
691
+ {
692
+ name: "r-mouseout",
693
+ kind: tsx.ScriptElementKind.jsxAttribute,
694
+ sortText: "1_r-mouseout",
695
+ labelDetails: { description: "Reactive mouseout handler" },
696
+ insertText: "r-mouseout={($event) => {}}"
697
+ },
698
+ {
699
+ name: "r-mousemove",
700
+ kind: tsx.ScriptElementKind.jsxAttribute,
701
+ sortText: "1_r-mousemove",
702
+ labelDetails: { description: "Reactive mousemove handler" },
703
+ insertText: "r-mousemove={($event) => {}}"
704
+ },
705
+ {
706
+ name: "r-mousedown",
707
+ kind: tsx.ScriptElementKind.jsxAttribute,
708
+ sortText: "1_r-mousedown",
709
+ labelDetails: { description: "Reactive mousedown handler" },
710
+ insertText: "r-mousedown={($event) => {}}"
711
+ },
712
+ {
713
+ name: "r-mouseup",
714
+ kind: tsx.ScriptElementKind.jsxAttribute,
715
+ sortText: "1_r-mouseup",
716
+ labelDetails: { description: "Reactive mouseup handler" },
717
+ insertText: "r-mouseup={($event) => {}}"
718
+ },
719
+ {
720
+ name: "r-scroll",
721
+ kind: tsx.ScriptElementKind.jsxAttribute,
722
+ sortText: "1_r-scroll",
723
+ labelDetails: { description: "Reactive scroll handler" },
724
+ insertText: "r-scroll={($event) => {}}"
725
+ },
726
+ {
727
+ name: "r-wheel",
728
+ kind: tsx.ScriptElementKind.jsxAttribute,
729
+ sortText: "1_r-wheel",
730
+ labelDetails: { description: "Reactive wheel handler" },
731
+ insertText: "r-wheel={($event) => {}}"
732
+ },
733
+ {
734
+ name: "r-touchstart",
735
+ kind: tsx.ScriptElementKind.jsxAttribute,
736
+ sortText: "1_r-touchstart",
737
+ labelDetails: { description: "Reactive touchstart handler" },
738
+ insertText: "r-touchstart={($event) => {}}"
739
+ },
740
+ {
741
+ name: "r-touchend",
742
+ kind: tsx.ScriptElementKind.jsxAttribute,
743
+ sortText: "1_r-touchend",
744
+ labelDetails: { description: "Reactive touchend handler" },
745
+ insertText: "r-touchend={($event) => {}}"
746
+ },
747
+ {
748
+ name: "r-touchmove",
749
+ kind: tsx.ScriptElementKind.jsxAttribute,
750
+ sortText: "1_r-touchmove",
751
+ labelDetails: { description: "Reactive touchmove handler" },
752
+ insertText: "r-touchmove={($event) => {}}"
753
+ },
754
+ {
755
+ name: "r-drag",
756
+ kind: tsx.ScriptElementKind.jsxAttribute,
757
+ sortText: "1_r-drag",
758
+ labelDetails: { description: "Reactive drag handler" },
759
+ insertText: "r-drag={($event) => {}}"
760
+ },
761
+ {
762
+ name: "r-dragstart",
763
+ kind: tsx.ScriptElementKind.jsxAttribute,
764
+ sortText: "1_r-dragstart",
765
+ labelDetails: { description: "Reactive dragstart handler" },
766
+ insertText: "r-dragstart={($event) => {}}"
767
+ },
768
+ {
769
+ name: "r-dragend",
770
+ kind: tsx.ScriptElementKind.jsxAttribute,
771
+ sortText: "1_r-dragend",
772
+ labelDetails: { description: "Reactive dragend handler" },
773
+ insertText: "r-dragend={($event) => {}}"
774
+ },
775
+ {
776
+ name: "r-dragover",
777
+ kind: tsx.ScriptElementKind.jsxAttribute,
778
+ sortText: "1_r-dragover",
779
+ labelDetails: { description: "Reactive dragover handler" },
780
+ insertText: "r-dragover={($event) => {}}"
781
+ },
782
+ {
783
+ name: "r-drop",
784
+ kind: tsx.ScriptElementKind.jsxAttribute,
785
+ sortText: "1_r-drop",
786
+ labelDetails: { description: "Reactive drop handler" },
787
+ insertText: "r-drop={($event) => {}}"
788
+ },
789
+ {
790
+ name: "r-load",
791
+ kind: tsx.ScriptElementKind.jsxAttribute,
792
+ sortText: "1_r-load",
793
+ labelDetails: { description: "Reactive load handler" },
794
+ insertText: "r-load={($event) => {}}"
795
+ },
796
+ {
797
+ name: "r-error",
798
+ kind: tsx.ScriptElementKind.jsxAttribute,
799
+ sortText: "1_r-error",
800
+ labelDetails: { description: "Reactive error handler" },
801
+ insertText: "r-error={($event) => {}}"
802
+ }
803
+ ];
804
+ if (!prior) {
805
+ return {
806
+ isGlobalCompletion: false,
807
+ isMemberCompletion: false,
808
+ isNewIdentifierLocation: false,
809
+ entries: fynixCompletions
810
+ };
811
+ }
812
+ return {
813
+ ...prior,
814
+ entries: [...fynixCompletions, ...prior.entries]
815
+ };
816
+ };
817
+ const FYNIX_HOVER_INFO = {
818
+ nixState: {
819
+ kind: tsx.ScriptElementKind.functionElement,
820
+ kindModifiers: "declare",
821
+ displayParts: [
822
+ {
823
+ text: "function nixState<T>(initialValue: T): NixState<T>",
824
+ kind: "text"
825
+ }
826
+ ],
827
+ documentation: [
828
+ {
829
+ text: "Creates a reactive state primitive. The value can be accessed via .value and will trigger re-renders when updated.",
830
+ kind: "text"
831
+ }
832
+ ]
833
+ },
834
+ nixStore: {
835
+ kind: tsx.ScriptElementKind.functionElement,
836
+ kindModifiers: "declare",
837
+ displayParts: [
838
+ {
839
+ text: "function nixStore<T>(initialValue: T): NixStore<T>",
840
+ kind: "text"
841
+ }
842
+ ],
843
+ documentation: [
844
+ {
845
+ text: "Creates a global reactive store that persists across component instances.",
846
+ kind: "text"
847
+ }
848
+ ]
849
+ },
850
+ nixAsync: {
851
+ kind: tsx.ScriptElementKind.functionElement,
852
+ kindModifiers: "declare",
853
+ displayParts: [
854
+ {
855
+ text: "function nixAsync<T>(asyncFn: () => Promise<T>): NixAsync<T>",
856
+ kind: "text"
857
+ }
858
+ ],
859
+ documentation: [
860
+ {
861
+ text: "Handles async operations with loading, error, and data states.",
862
+ kind: "text"
863
+ }
864
+ ]
865
+ },
866
+ nixEffect: {
867
+ kind: tsx.ScriptElementKind.functionElement,
868
+ kindModifiers: "declare",
869
+ displayParts: [
870
+ {
871
+ text: "function nixEffect(fn: () => void | (() => void), deps?: any[]): void",
872
+ kind: "text"
873
+ }
874
+ ],
875
+ documentation: [
876
+ {
877
+ text: "Runs side effects when dependencies change. Returns cleanup function.",
878
+ kind: "text"
879
+ }
880
+ ]
881
+ },
882
+ nixComputed: {
883
+ kind: tsx.ScriptElementKind.functionElement,
884
+ kindModifiers: "declare",
885
+ displayParts: [
886
+ {
887
+ text: "function nixComputed<T>(fn: () => T, deps: any[]): NixComputed<T>",
888
+ kind: "text"
889
+ }
890
+ ],
891
+ documentation: [
892
+ {
893
+ text: "Creates a computed value that automatically updates when dependencies change.",
894
+ kind: "text"
895
+ }
896
+ ]
897
+ },
898
+ nixForm: {
899
+ kind: tsx.ScriptElementKind.functionElement,
900
+ kindModifiers: "declare",
901
+ displayParts: [
902
+ {
903
+ text: "function nixForm<T>(config: NixFormConfig<T>): NixForm<T>",
904
+ kind: "text"
905
+ }
906
+ ],
907
+ documentation: [
908
+ {
909
+ text: "Creates a form handler with validation and state management.",
910
+ kind: "text"
911
+ }
912
+ ]
913
+ }
914
+ };
915
+ proxy.getQuickInfoAtPosition = (fileName, position) => {
916
+ let mappedPosition = position;
917
+ if (fileName.endsWith(".fnx")) {
918
+ const cache = fnxCache.get(fileName);
919
+ if (cache) {
920
+ mappedPosition = mapOriginalToTransformedWithCache(position, cache);
921
+ }
922
+ }
923
+ const program = info.languageService.getProgram();
924
+ const sf = program?.getSourceFile(fileName);
925
+ if (!sf || !fileName.endsWith(".fnx")) {
926
+ return info.languageService.getQuickInfoAtPosition(
927
+ fileName,
928
+ mappedPosition
929
+ );
930
+ }
931
+ const node = findNode(sf, mappedPosition);
932
+ if (!node) {
933
+ return info.languageService.getQuickInfoAtPosition(
934
+ fileName,
935
+ mappedPosition
936
+ );
937
+ }
938
+ const text = node.getText(sf);
939
+ if (text in FYNIX_HOVER_INFO) {
940
+ return {
941
+ ...FYNIX_HOVER_INFO[text],
942
+ textSpan: { start: node.getStart(), length: node.getWidth() }
943
+ };
944
+ }
945
+ return info.languageService.getQuickInfoAtPosition(
946
+ fileName,
947
+ mappedPosition
948
+ );
949
+ };
950
+ proxy.getDefinitionAtPosition = (fileName, position) => {
951
+ let mappedPosition = position;
952
+ if (fileName.endsWith(".fnx")) {
953
+ const cache2 = fnxCache.get(fileName);
954
+ if (cache2) {
955
+ mappedPosition = mapOriginalToTransformedWithCache(position, cache2);
956
+ }
957
+ }
958
+ const defs = info.languageService.getDefinitionAtPosition(
959
+ fileName,
960
+ mappedPosition
961
+ );
962
+ if (!defs || !fileName.endsWith(".fnx")) return defs;
963
+ const cache = fnxCache.get(fileName);
964
+ if (!cache) return defs;
965
+ return defs.map((def) => {
966
+ if (def.fileName === fileName) {
967
+ const originalStart = mapTransformedToOriginalWithCache(
968
+ def.textSpan.start,
969
+ cache
970
+ );
971
+ return {
972
+ ...def,
973
+ textSpan: {
974
+ start: originalStart,
975
+ length: def.textSpan.length
976
+ }
977
+ };
978
+ }
979
+ return def;
980
+ });
981
+ };
982
+ proxy.getReferencesAtPosition = (fileName, position) => {
983
+ let mappedPosition = position;
984
+ if (fileName.endsWith(".fnx")) {
985
+ const cache2 = fnxCache.get(fileName);
986
+ if (cache2) {
987
+ mappedPosition = mapOriginalToTransformedWithCache(position, cache2);
988
+ }
989
+ }
990
+ const refs = info.languageService.getReferencesAtPosition(
991
+ fileName,
992
+ mappedPosition
993
+ );
994
+ if (!refs || !fileName.endsWith(".fnx")) return refs;
995
+ const cache = fnxCache.get(fileName);
996
+ if (!cache) return refs;
997
+ return refs.map((ref) => {
998
+ if (ref.fileName === fileName) {
999
+ const originalStart = mapTransformedToOriginalWithCache(
1000
+ ref.textSpan.start,
1001
+ cache
1002
+ );
1003
+ return {
1004
+ ...ref,
1005
+ textSpan: {
1006
+ start: originalStart,
1007
+ length: ref.textSpan.length
1008
+ }
1009
+ };
1010
+ }
1011
+ return ref;
1012
+ });
1013
+ };
1014
+ proxy.getRenameInfo = (fileName, position) => {
1015
+ let mappedPosition = position;
1016
+ if (fileName.endsWith(".fnx")) {
1017
+ const cache = fnxCache.get(fileName);
1018
+ if (cache) {
1019
+ mappedPosition = mapOriginalToTransformedWithCache(position, cache);
1020
+ }
1021
+ }
1022
+ return info.languageService.getRenameInfo(fileName, mappedPosition);
1023
+ };
1024
+ return proxy;
1025
+ }
1026
+ __name(create, "create");
1027
+ return { create };
1028
+ }
1029
+ __name(init, "init");
1030
+ function findNode(sf, pos) {
1031
+ function walk(node) {
1032
+ if (pos >= node.getStart() && pos < node.getEnd()) {
1033
+ return ts.forEachChild(node, walk) || node;
1034
+ }
1035
+ return void 0;
1036
+ }
1037
+ __name(walk, "walk");
1038
+ return walk(sf);
1039
+ }
1040
+ __name(findNode, "findNode");
1041
+ export {
1042
+ init as default
1043
+ };
1044
+ //# sourceMappingURL=index.js.map