@vesk/compiler 0.2.40 → 0.2.42
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-codegen.d.ts","sourceRoot":"","sources":["../src/client-codegen.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAuB,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAGL,cAAc,EAQd,gBAAgB,EASjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAyCxD,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,SAAS,GAAG,MAAM,CAAC;CAC1B;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI1D;AAiDD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,gBAAgB,GAAG,cAAc,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,MAAM,CAiHlI;AAID,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAU5E;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,MAAM,CAY5F;AAoBD,qDAAqD;AACrD,MAAM,MAAM,SAAS,GAAG;IAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,SAAS,CAQtE;
|
|
1
|
+
{"version":3,"file":"client-codegen.d.ts","sourceRoot":"","sources":["../src/client-codegen.ts"],"names":[],"mappings":"A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O,CAAC;IAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,aAAa,CAAC,EAAE,SAAS,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,MAAM,CAOpQ;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,GAAG,IAAI,EAC7B,UAAU,CAAC,EAAE,MAAM,EACnB,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CA0BpD;AAED,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/client-codegen.js
CHANGED
|
@@ -1026,7 +1026,14 @@ function emitComponentCall(ctx, node, tracked, effectsVar, parentVar, compPrefix
|
|
|
1026
1026
|
const frag = ctx.n();
|
|
1027
1027
|
const wipeMount = ctx.linkNames.has(node.componentName);
|
|
1028
1028
|
const savedHydrate = ctx.hydrate;
|
|
1029
|
-
|
|
1029
|
+
// Self-claiming runtime components (Form/Field/Link/Md/etc.) claim their
|
|
1030
|
+
// own SSR root before their children are useful. Building their children
|
|
1031
|
+
// through the caller's active walker would let a nested Field consume
|
|
1032
|
+
// the component's preceding static sibling (for example <h1> before
|
|
1033
|
+
// <Form>), leaving the real Form slot misaligned. Their hydrate path
|
|
1034
|
+
// deliberately preserves the SSR interior, so construct the argument
|
|
1035
|
+
// fresh and let the runtime component adopt the existing root.
|
|
1036
|
+
if (wipeMount || ctx.selfClaimNames.has(node.componentName))
|
|
1030
1037
|
ctx.hydrate = false;
|
|
1031
1038
|
ctx.push(`const ${frag} = (() => { const $f = document.createDocumentFragment();`);
|
|
1032
1039
|
const savedEffects = ctx.effects;
|
package/dist/typecheck.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typecheck.d.ts","sourceRoot":"","sources":["../src/typecheck.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAKD,eAAO,MAAM,OAAO,6xoBAkhBnB,CAAC;AAEF,eAAO,MAAM,gBAAgB,uZAS5B,CAAC;AA6LF,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,QAAQ,EAAE,cAAc,EAAE,CAAC;CAC5B;
|
|
1
|
+
{"version":3,"file":"typecheck.d.ts","sourceRoot":"","sources":["../src/typecheck.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAKD,eAAO,MAAM,OAAO,6xoBAkhBnB,CAAC;AAEF,eAAO,MAAM,gBAAgB,uZAS5B,CAAC;AA6LF,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,QAAQ,EAAE,cAAc,EAAE,CAAC;CAC5B;AAuCD,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,GAAE,gBAAqB,GAAG,eAAe,CA2GlG;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAItE;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,MAAM,CAI1E"}
|
package/dist/typecheck.js
CHANGED
|
@@ -2,7 +2,7 @@ import { readFileSync, readdirSync, statSync } from 'node:fs';
|
|
|
2
2
|
import { join, dirname, normalize, relative, resolve, sep } from 'node:path';
|
|
3
3
|
import * as ts from 'typescript';
|
|
4
4
|
import { parse } from '@vesk/compiler/src/parser';
|
|
5
|
-
import {
|
|
5
|
+
import { compileVskCodegen, generateVskDts } from '@vesk/compiler/src/vsk-tsx';
|
|
6
6
|
import { resolveAliasModule } from '@vesk/compiler/src/module-imports';
|
|
7
7
|
const SKIP_DIRS = new Set(['node_modules', '.vesk', '.git', 'dist', 'tarballs', '.next']);
|
|
8
8
|
const SKIP_FILES = new Set(['__vesk_ambient.d.ts', '__vesk_runtime_override.d.ts']);
|
|
@@ -642,7 +642,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
|
|
|
642
642
|
content = '';
|
|
643
643
|
}
|
|
644
644
|
else if (vskFiles.has(file)) {
|
|
645
|
-
content =
|
|
645
|
+
content = compileVskCodegen(vskFiles.get(file)).code;
|
|
646
646
|
}
|
|
647
647
|
else if (ts.sys.fileExists(file)) {
|
|
648
648
|
content = ts.sys.readFile(file);
|
|
@@ -684,7 +684,7 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
|
|
|
684
684
|
if (file.endsWith('.css.d.ts'))
|
|
685
685
|
return '';
|
|
686
686
|
if (vskFiles.has(file))
|
|
687
|
-
return
|
|
687
|
+
return compileVskCodegen(vskFiles.get(file)).code;
|
|
688
688
|
return ts.sys.readFile(file);
|
|
689
689
|
},
|
|
690
690
|
writeFile: () => { },
|
|
@@ -739,6 +739,35 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
|
|
|
739
739
|
};
|
|
740
740
|
return host;
|
|
741
741
|
}
|
|
742
|
+
function mapGeneratedOffset(mappings, generatedOffset) {
|
|
743
|
+
let nearest = null;
|
|
744
|
+
for (const mapping of mappings) {
|
|
745
|
+
for (let i = 0; i < mapping.generatedOffsets.length; i++) {
|
|
746
|
+
const generated = mapping.generatedOffsets[i];
|
|
747
|
+
const length = mapping.lengths[i] ?? 0;
|
|
748
|
+
const source = mapping.sourceOffsets[i];
|
|
749
|
+
if (generated <= generatedOffset && generated + length >= generatedOffset) {
|
|
750
|
+
return source + (generatedOffset - generated);
|
|
751
|
+
}
|
|
752
|
+
if (generated <= generatedOffset && (!nearest || generated > nearest.generated)) {
|
|
753
|
+
nearest = { source, generated, length };
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
return nearest ? nearest.source + Math.min(nearest.length, Math.max(0, generatedOffset - nearest.generated)) : null;
|
|
758
|
+
}
|
|
759
|
+
function sourcePosition(source, offset) {
|
|
760
|
+
const bounded = Math.max(0, Math.min(offset, source.length));
|
|
761
|
+
let line = 1;
|
|
762
|
+
let lineStart = 0;
|
|
763
|
+
for (let i = 0; i < bounded; i++) {
|
|
764
|
+
if (source.charCodeAt(i) === 10) {
|
|
765
|
+
line++;
|
|
766
|
+
lineStart = i + 1;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
return { line, character: bounded - lineStart + 1 };
|
|
770
|
+
}
|
|
742
771
|
export function typecheckProject(projectRoot, opts = {}) {
|
|
743
772
|
const appDir = opts.appDir ?? join(projectRoot, 'app');
|
|
744
773
|
const vskFiles = new Map();
|
|
@@ -820,12 +849,29 @@ export function typecheckProject(projectRoot, opts = {}) {
|
|
|
820
849
|
}
|
|
821
850
|
if (!rootSet.has(filePath) && !vskSet.has(filePath))
|
|
822
851
|
continue;
|
|
823
|
-
|
|
852
|
+
let sourceOffset = diag.start ?? 0;
|
|
853
|
+
let line;
|
|
854
|
+
let column;
|
|
855
|
+
if (vskFiles.has(filePath)) {
|
|
856
|
+
const source = vskFiles.get(filePath);
|
|
857
|
+
const generated = compileVskCodegen(source);
|
|
858
|
+
const mapped = mapGeneratedOffset(generated.mappings, sourceOffset);
|
|
859
|
+
if (mapped !== null)
|
|
860
|
+
sourceOffset = mapped;
|
|
861
|
+
const pos = sourcePosition(source, sourceOffset);
|
|
862
|
+
line = pos.line;
|
|
863
|
+
column = pos.character;
|
|
864
|
+
}
|
|
865
|
+
else {
|
|
866
|
+
const pos = file.getLineAndCharacterOfPosition(diag.start ?? 0);
|
|
867
|
+
line = pos.line + 1;
|
|
868
|
+
column = pos.character + 1;
|
|
869
|
+
}
|
|
824
870
|
const code = typeof diag.code === 'number' ? `TS${diag.code}` : String(diag.code);
|
|
825
871
|
errors.push({
|
|
826
872
|
file: relative(projectRoot, filePath),
|
|
827
|
-
line
|
|
828
|
-
column
|
|
873
|
+
line,
|
|
874
|
+
column,
|
|
829
875
|
code,
|
|
830
876
|
message: ts.flattenDiagnosticMessageText(diag.messageText, '\n'),
|
|
831
877
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/compiler",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.42",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vesk compiler — lexer, parser, semantic analysis, IR, codegen",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@sveltejs/acorn-typescript": "^1.0.0",
|
|
23
|
-
"@vesk/types": "^0.2.
|
|
23
|
+
"@vesk/types": "^0.2.42",
|
|
24
24
|
"acorn": "^8.15.0",
|
|
25
25
|
"esrap": "^2.3.0",
|
|
26
26
|
"is-reference": "^3.0.0",
|