@fynixorg/ui 1.0.21 → 1.0.24

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