@vesk/compiler 0.2.38 → 0.2.40
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/dist/api-routes.d.ts.map +1 -1
- package/dist/api-routes.js +9 -4
- package/dist/client-codegen.d.ts.map +1 -1
- package/dist/client-codegen.js +6 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +18 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/ir-generator.d.ts.map +1 -1
- package/dist/ir-generator.js +17 -5
- package/dist/ir.d.ts +9 -0
- package/dist/ir.d.ts.map +1 -1
- package/dist/ir.js +9 -0
- package/dist/scan.d.ts.map +1 -1
- package/dist/scan.js +24 -3
- package/dist/server-jsgen.js +1 -1
- package/dist/server-utils.d.ts +13 -1
- package/dist/server-utils.d.ts.map +1 -1
- package/dist/server-utils.js +18 -3
- package/dist/typecheck.d.ts +2 -2
- package/dist/typecheck.d.ts.map +1 -1
- package/dist/typecheck.js +40 -2
- package/dist/vsk-tsx.d.ts.map +1 -1
- package/dist/vsk-tsx.js +122 -9
- package/package.json +2 -2
package/dist/api-routes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-routes.d.ts","sourceRoot":"","sources":["../src/api-routes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAW7D,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,EAAE,CAG5D;AA+ED,wBAAgB,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,IAAI,CA0DjI;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAA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AAC,CAAA;CAAE,CA4C9E;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAIrE;AAED,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACnC,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACpC,QAAQ,CAAC,EAAE,QAAQ,GAClB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CA8J1B"}
|
package/dist/api-routes.js
CHANGED
|
@@ -309,8 +309,14 @@ export async function executeApiRoute(filePath, method, request, params = {}, lo
|
|
|
309
309
|
signal = controller.signal;
|
|
310
310
|
Object.defineProperty(request, 'signal', { value: signal, writable: false });
|
|
311
311
|
}
|
|
312
|
-
|
|
313
|
-
|
|
312
|
+
// A route hook may be exported as a single function (the documented form)
|
|
313
|
+
// or as an array of them. Normalize both instead of assuming an array.
|
|
314
|
+
const toHookList = (v) => {
|
|
315
|
+
if (v == null)
|
|
316
|
+
return [];
|
|
317
|
+
return (Array.isArray(v) ? v : [v]);
|
|
318
|
+
};
|
|
319
|
+
for (const hook of toHookList(mod.beforeRequest)) {
|
|
314
320
|
const hookResult = await hook(request, { params, locals });
|
|
315
321
|
if (hookResult instanceof Response)
|
|
316
322
|
return hookResult;
|
|
@@ -329,8 +335,7 @@ export async function executeApiRoute(filePath, method, request, params = {}, lo
|
|
|
329
335
|
return errorResult;
|
|
330
336
|
throw e;
|
|
331
337
|
}
|
|
332
|
-
const
|
|
333
|
-
for (const hook of afterHooks) {
|
|
338
|
+
for (const hook of toHookList(mod.afterRequest)) {
|
|
334
339
|
const hookResult = await hook(request, response);
|
|
335
340
|
if (hookResult instanceof Response)
|
|
336
341
|
response = hookResult;
|
|
@@ -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":"AAIA,OAAO,KAAK,EAAE,MAAM,EAAuB,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAGL,cAAc,EAQd,gBAAgB,EASjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAA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AE,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
|
@@ -2101,7 +2101,7 @@ function generateComponent(comp, importedNames = new Set(), hydrate = false, asy
|
|
|
2101
2101
|
ctx.push(indent(`const $root = document.createDocumentFragment();`));
|
|
2102
2102
|
}
|
|
2103
2103
|
ctx.push(indent(`let __pendingChild = null;`));
|
|
2104
|
-
const paramInit = buildParamInit(comp.paramNames);
|
|
2104
|
+
const paramInit = buildParamInit(comp.paramNames, comp.propsAlias);
|
|
2105
2105
|
if (paramInit)
|
|
2106
2106
|
ctx.push(indent(paramInit));
|
|
2107
2107
|
// Hoist TrackDecls to top to avoid TDZ when Head/effects reference them before declaration
|
|
@@ -2170,7 +2170,11 @@ function generateComponent(comp, importedNames = new Set(), hydrate = false, asy
|
|
|
2170
2170
|
ctx.push(`}`);
|
|
2171
2171
|
return ctx.getCode();
|
|
2172
2172
|
}
|
|
2173
|
-
function buildParamInit(paramNames) {
|
|
2173
|
+
function buildParamInit(paramNames, propsAlias = null) {
|
|
2174
|
+
// A plain-identifier first parameter is the whole props object under another
|
|
2175
|
+
// name (React-style); anything else came from a destructuring pattern.
|
|
2176
|
+
if (propsAlias)
|
|
2177
|
+
return propsAlias === 'props' ? '' : `const ${propsAlias} = props;`;
|
|
2174
2178
|
if (paramNames.length === 1 && paramNames[0] === 'props')
|
|
2175
2179
|
return '';
|
|
2176
2180
|
if (paramNames.length === 0)
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAgC,MAAM,0BAA0B,CAAC;AAGnH,iFAAiF;AACjF,eAAO,MAAM,qBAAqB,UAIjC,CAAC;AA6CF,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,YAAiB,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAgC,MAAM,0BAA0B,CAAC;AAGnH,iFAAiF;AACjF,eAAO,MAAM,qBAAqB,UAIjC,CAAC;AA6CF,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,YAAiB,GAAG,YAAY,CAgB/E;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,UAAU,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAQ/D;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAkC3D;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAsC7D"}
|
package/dist/config.js
CHANGED
|
@@ -45,10 +45,14 @@ SECURITY_PRESETS['default'] = { ...SECURITY_PRESETS['strict'] };
|
|
|
45
45
|
export function preset(name, overrides = {}) {
|
|
46
46
|
const presets = {
|
|
47
47
|
production: { ...SECURITY_PRESETS['strict'] },
|
|
48
|
+
// `strict` is the real name of the production preset; both resolve to it.
|
|
49
|
+
strict: { ...SECURITY_PRESETS['strict'] },
|
|
48
50
|
development: {
|
|
49
51
|
...SECURITY_PRESETS['strict'],
|
|
50
52
|
contentSecurityPolicy: false,
|
|
51
53
|
},
|
|
54
|
+
// autoEscape only, SAMEORIGIN framing, no CSRF/HSTS/CSP.
|
|
55
|
+
minimal: { ...SECURITY_PRESETS['minimal'] },
|
|
52
56
|
};
|
|
53
57
|
if (!presets[name]) {
|
|
54
58
|
throw VeskError.configError(`Unknown security preset: "${name}".`, Object.keys(presets));
|
|
@@ -65,10 +69,22 @@ export function definePlugin(plugin) {
|
|
|
65
69
|
return plugin;
|
|
66
70
|
}
|
|
67
71
|
export function defineConfig(config) {
|
|
72
|
+
// `security: false` (or 'off') is an explicit opt-out: no CSRF, no CSP, no
|
|
73
|
+
// HSTS, no framing policy, no log redaction. It used to be rewritten to `{}`
|
|
74
|
+
// and then re-filled with the strict defaults below, so a project that asked
|
|
75
|
+
// for no security silently got all of it. `autoEscape` stays on — escaping
|
|
76
|
+
// untrusted text is not an optional header, so 'off' means "no ambient
|
|
77
|
+
// protections", not "render unescaped HTML".
|
|
68
78
|
if (config.security === false || config.security === 'off') {
|
|
69
|
-
config.security = {};
|
|
79
|
+
config.security = { autoEscape: true };
|
|
80
|
+
if (config.routeDataCache === undefined)
|
|
81
|
+
config.routeDataCache = 0;
|
|
82
|
+
const mdOff = normalizeMdConfig(config.md);
|
|
83
|
+
if (mdOff !== undefined)
|
|
84
|
+
config.md = mdOff;
|
|
85
|
+
return config;
|
|
70
86
|
}
|
|
71
|
-
|
|
87
|
+
if (typeof config.security === 'string') {
|
|
72
88
|
const p = SECURITY_PRESETS[config.security];
|
|
73
89
|
if (!p)
|
|
74
90
|
throw VeskError.configError(`Unknown security preset string: "${config.security}".`, Object.keys(SECURITY_PRESETS));
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type { VeskConfig } from '@vesk/compiler/src/types';
|
|
|
12
12
|
export type { VeskSecurity } from '@vesk/compiler/src/types';
|
|
13
13
|
export type { VeskCors } from '@vesk/compiler/src/types';
|
|
14
14
|
export type { VeskRateLimit } from '@vesk/compiler/src/types';
|
|
15
|
-
export { defineConfig, validateConfig, preset, definePlugin } from '@vesk/compiler/src/config';
|
|
15
|
+
export { defineConfig, validateConfig, preset, definePlugin, MD_DEFAULT_ALLOW_TAGS } from '@vesk/compiler/src/config';
|
|
16
16
|
export { scanRoutes, scanComponents, collectSources, matchUrl } from '@vesk/compiler/src/router';
|
|
17
17
|
export { compileVskCodegen } from '@vesk/compiler/src/vsk-tsx';
|
|
18
18
|
export type { CodeInfo, CodeMapping, StyleRegion, VskCodegenError, VskCodegenOptions, VskCodegenResult, } from '@vesk/compiler/src/vsk-tsx';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EACL,MAAM,EACN,WAAW,EACX,UAAU,EACV,QAAQ,EACR,cAAc,EACd,mBAAmB,EACnB,SAAS,EACT,aAAa,EACb,UAAU,GACX,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0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,YAAY,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACtH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,YAAY,EACV,QAAQ,EACR,WAAW,EACX,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,6 @@ export { render } from '@vesk/compiler/src/server-codegen';
|
|
|
5
5
|
export { AMBIENT, RUNTIME_OVERRIDE } from '@vesk/compiler/src/typecheck';
|
|
6
6
|
export { compileClient, compile } from '@vesk/compiler/src/client-codegen';
|
|
7
7
|
export { IRRoot, ComponentIR, StaticNode, TextNode, DynamicBinding, OpaqueDynamicRegion, MapRegion, ComponentCall, Expression, } from '@vesk/compiler/src/ir';
|
|
8
|
-
export { defineConfig, validateConfig, preset, definePlugin } from '@vesk/compiler/src/config';
|
|
8
|
+
export { defineConfig, validateConfig, preset, definePlugin, MD_DEFAULT_ALLOW_TAGS } from '@vesk/compiler/src/config';
|
|
9
9
|
export { scanRoutes, scanComponents, collectSources, matchUrl } from '@vesk/compiler/src/router';
|
|
10
10
|
export { compileVskCodegen } from '@vesk/compiler/src/vsk-tsx';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ir-generator.d.ts","sourceRoot":"","sources":["../src/ir-generator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EAsBP,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"ir-generator.d.ts","sourceRoot":"","sources":["../src/ir-generator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EAsBP,MAAM,uBAAuB,CAAC;AA2T/B,wBAAgB,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,GAAG,CAAC;IAAC,cAAc,CAAC,EAAE,GAAG,CAAC;IAAC,UAAU,CAAC,EAAE,GAAG,EAAE,CAAA;CAAE,CAAC,GAAG,SAAS,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkCnL;AA48BD,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CA6N9E"}
|
package/dist/ir-generator.js
CHANGED
|
@@ -15,6 +15,13 @@ let __vskAnnotations = [];
|
|
|
15
15
|
* slot handed to it by a caller that wrote `name={<div/>}`.
|
|
16
16
|
*/
|
|
17
17
|
let __slotProps = null;
|
|
18
|
+
/**
|
|
19
|
+
* The identifier a component binds its props to (`props` by convention, but
|
|
20
|
+
* any first-parameter name is legal). Slot detection used to hardcode the
|
|
21
|
+
* literal `props`, so a `Component`-typed prop read through a differently
|
|
22
|
+
* named parameter was treated as a plain value and stringified.
|
|
23
|
+
*/
|
|
24
|
+
let __propsParam = null;
|
|
18
25
|
function parseExprNode(text) {
|
|
19
26
|
try {
|
|
20
27
|
const ParserClass = createBaseParser();
|
|
@@ -463,7 +470,7 @@ function containsJSX(node) {
|
|
|
463
470
|
*/
|
|
464
471
|
function slotReadPropName(expr) {
|
|
465
472
|
if (expr.type === 'MemberExpression' && !expr.computed &&
|
|
466
|
-
expr.object.type === 'Identifier' && expr.object.name === 'props' &&
|
|
473
|
+
expr.object.type === 'Identifier' && expr.object.name === (__propsParam || 'props') &&
|
|
467
474
|
expr.property.type === 'Identifier') {
|
|
468
475
|
return expr.property.name;
|
|
469
476
|
}
|
|
@@ -719,7 +726,7 @@ function processJSXChildren(source, children) {
|
|
|
719
726
|
continue;
|
|
720
727
|
}
|
|
721
728
|
if ((expr.type === 'MemberExpression' && !expr.computed &&
|
|
722
|
-
expr.object.type === 'Identifier' && expr.object.name === 'props' &&
|
|
729
|
+
expr.object.type === 'Identifier' && expr.object.name === (__propsParam || 'props') &&
|
|
723
730
|
expr.property.type === 'Identifier' && expr.property.name === 'children')
|
|
724
731
|
|| (expr.type === 'Identifier' && expr.name === 'children')) {
|
|
725
732
|
result.push(new SlotNode());
|
|
@@ -818,7 +825,7 @@ function exprToIR(source, expr) {
|
|
|
818
825
|
// insert the slot nodes — not degrade to a text binding that stringifies
|
|
819
826
|
// the fragment (`String(props.children)` → "[object DocumentFragment]").
|
|
820
827
|
if ((expr.type === 'MemberExpression' && !expr.computed &&
|
|
821
|
-
expr.object.type === 'Identifier' && expr.object.name === 'props' &&
|
|
828
|
+
expr.object.type === 'Identifier' && expr.object.name === (__propsParam || 'props') &&
|
|
822
829
|
expr.property.type === 'Identifier' && expr.property.name === 'children')
|
|
823
830
|
|| (expr.type === 'Identifier' && expr.name === 'children')) {
|
|
824
831
|
return [new SlotNode()];
|
|
@@ -1488,6 +1495,10 @@ export function generateIR(ast, source, filename) {
|
|
|
1488
1495
|
}
|
|
1489
1496
|
const name = inner.id.name;
|
|
1490
1497
|
const paramNames = getParamNames(inner.params, source);
|
|
1498
|
+
// A plain-identifier first parameter receives the whole props object under
|
|
1499
|
+
// its own name (React-style); a destructuring pattern receives the fields.
|
|
1500
|
+
const firstParam = inner.params?.[0];
|
|
1501
|
+
const propsAlias = firstParam && firstParam.type === 'Identifier' ? firstParam.name : null;
|
|
1491
1502
|
const propsType = getPropsType(inner.params, source);
|
|
1492
1503
|
const bodyStmts = inner.body.body;
|
|
1493
1504
|
const isClientComp = !!inner.client;
|
|
@@ -1496,11 +1507,12 @@ export function generateIR(ast, source, filename) {
|
|
|
1496
1507
|
// value bindings for THIS component only.
|
|
1497
1508
|
const prevSlotProps = __slotProps;
|
|
1498
1509
|
__slotProps = slotPropNamesFromType(propsType);
|
|
1510
|
+
__propsParam = propsAlias || null;
|
|
1499
1511
|
if (isStatementMode(bodyStmts)) {
|
|
1500
1512
|
const raw = processStatementModeBody(source, bodyStmts, file);
|
|
1501
1513
|
const { body, css } = extractStyle(raw);
|
|
1502
1514
|
validateBlocks(name, isClientComp, body, file, source);
|
|
1503
|
-
const comp = new ComponentIR(name, paramNames, body, { mode: 'statement', exported, defaultExport, isClient: inner.client, isAsync: inner.async, ssrAwait: componentUsesFetch(body), propsType });
|
|
1515
|
+
const comp = new ComponentIR(name, paramNames, body, { mode: 'statement', exported, defaultExport, isClient: inner.client, isAsync: inner.async, ssrAwait: componentUsesFetch(body), propsType, propsAlias });
|
|
1504
1516
|
comp.style = css;
|
|
1505
1517
|
components.push(comp);
|
|
1506
1518
|
__slotProps = prevSlotProps;
|
|
@@ -1549,7 +1561,7 @@ export function generateIR(ast, source, filename) {
|
|
|
1549
1561
|
const guardBody = buildGuardChain(source, guardClauses, mainReturn);
|
|
1550
1562
|
const { body, css } = extractStyle([...preamble, ...guardBody]);
|
|
1551
1563
|
validateBlocks(name, isClientComp, body, file, source);
|
|
1552
|
-
const comp = new ComponentIR(name, paramNames, body, { exported, defaultExport, isClient: inner.client, isAsync: inner.async, ssrAwait: componentUsesFetch(body), propsType });
|
|
1564
|
+
const comp = new ComponentIR(name, paramNames, body, { exported, defaultExport, isClient: inner.client, isAsync: inner.async, ssrAwait: componentUsesFetch(body), propsType, propsAlias });
|
|
1553
1565
|
comp.style = css;
|
|
1554
1566
|
components.push(comp);
|
|
1555
1567
|
__slotProps = prevSlotProps;
|
package/dist/ir.d.ts
CHANGED
|
@@ -18,6 +18,14 @@ export declare class IRRoot {
|
|
|
18
18
|
export declare class ComponentIR {
|
|
19
19
|
name: string;
|
|
20
20
|
paramNames: string[];
|
|
21
|
+
/**
|
|
22
|
+
* The declared first parameter when it is a plain identifier
|
|
23
|
+
* (`component Card(p)`), i.e. the whole props object bound to another name.
|
|
24
|
+
* `null` for a destructuring pattern (`component Card({ title })`) or when
|
|
25
|
+
* there is no parameter. `paramNames` alone cannot express this: `p` and
|
|
26
|
+
* `{ p }` both flatten to `['p']` but need opposite bindings.
|
|
27
|
+
*/
|
|
28
|
+
propsAlias: string | null;
|
|
21
29
|
propsType: string | null;
|
|
22
30
|
isClient: boolean;
|
|
23
31
|
isAsync: boolean;
|
|
@@ -35,6 +43,7 @@ export declare class ComponentIR {
|
|
|
35
43
|
exported?: boolean;
|
|
36
44
|
defaultExport?: boolean;
|
|
37
45
|
propsType?: string | null;
|
|
46
|
+
propsAlias?: string | null;
|
|
38
47
|
});
|
|
39
48
|
}
|
|
40
49
|
export declare class StaticNode {
|
package/dist/ir.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ir.d.ts","sourceRoot":"","sources":["../src/ir.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEjD,qBAAa,UAAU;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,UAAU,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,EAAE,CAAC;gBAEH,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAO,EAAE,GAAG,GAAE,UAAU,GAAG,IAAW,EAAE,MAAM,GAAE,MAAM,GAAG,IAAW;CAM1G;AAED,qBAAa,MAAM;IACjB,UAAU,EAAE,WAAW,EAAE,CAAC;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,YAAY,EAAE,MAAM,EAAE,CAAC;gBAGrB,UAAU,EAAE,WAAW,EAAE,EACzB,OAAO,GAAE,MAAM,EAAO,EACtB,aAAa,GAAE,GAAG,CAAC,MAAM,CAAa,EACtC,WAAW,GAAE,MAAM,GAAG,IAAW,EACjC,MA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AG,IAAI,CAAC;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;gBAEV,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,UAAU,GAAG,IAAW,EAAE,MAAM,GAAE,MAAM,GAAG,IAAW;CAKrF;AAED,qBAAa,OAAO;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,UAAU,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,IAAI,EAAE,KAAK,GAAG,QAAQ,CAAC;gBAEX,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,IAAI,GAAE,KAAK,GAAG,QAAgB;CAOxH;AAED,qBAAa,WAAW;IACtB,QAAQ,EAAE,MAAM,EAAE,CAAC;gBACP,QAAQ,EAAE,MAAM,EAAE;CAG/B;AAED,qBAAa,WAAW;IACtB,QAAQ,EAAE,MAAM,EAAE,CAAC;gBACP,QAAQ,EAAE,MAAM,EAAE;CAG/B;AAED,qBAAa,SAAS;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;gBACP,QAAQ,EAAE,MAAM,EAAE;CAG/B;AAED,MAAM,MAAM,MAAM,GACd,UAAU,GACV,QAAQ,GACR,cAAc,GACd,mBAAmB,GACnB,SAAS,GACT,SAAS,GACT,WAAW,GACX,QAAQ,GACR,OAAO,GACP,SAAS,GACT,gBAAgB,GAChB,YAAY,GACZ,aAAa,GACb,WAAW,GACX,WAAW,GACX,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,cAAc,CAAC"}
|
package/dist/ir.js
CHANGED
|
@@ -29,6 +29,14 @@ export class IRRoot {
|
|
|
29
29
|
export class ComponentIR {
|
|
30
30
|
name;
|
|
31
31
|
paramNames;
|
|
32
|
+
/**
|
|
33
|
+
* The declared first parameter when it is a plain identifier
|
|
34
|
+
* (`component Card(p)`), i.e. the whole props object bound to another name.
|
|
35
|
+
* `null` for a destructuring pattern (`component Card({ title })`) or when
|
|
36
|
+
* there is no parameter. `paramNames` alone cannot express this: `p` and
|
|
37
|
+
* `{ p }` both flatten to `['p']` but need opposite bindings.
|
|
38
|
+
*/
|
|
39
|
+
propsAlias;
|
|
32
40
|
propsType;
|
|
33
41
|
isClient;
|
|
34
42
|
isAsync;
|
|
@@ -41,6 +49,7 @@ export class ComponentIR {
|
|
|
41
49
|
constructor(name, paramNames, body, opts = {}) {
|
|
42
50
|
this.name = name;
|
|
43
51
|
this.paramNames = paramNames;
|
|
52
|
+
this.propsAlias = opts.propsAlias ?? null;
|
|
44
53
|
this.body = body;
|
|
45
54
|
this.isClient = opts.isClient ?? false;
|
|
46
55
|
this.isAsync = opts.isAsync ?? false;
|
package/dist/scan.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAItD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErD;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAOzE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWrD;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAS5D;AAED,wBAAgB,cAAc,CAAC,IAAI,EAA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AI,CAexD"}
|
package/dist/scan.js
CHANGED
|
@@ -227,10 +227,31 @@ export function blankComments(text) {
|
|
|
227
227
|
continue;
|
|
228
228
|
}
|
|
229
229
|
if (ch === '/' && text[i + 1] === '*') {
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
// Only a line-leading `/*` is blanked, for the same reason as `//`, and
|
|
231
|
+
// only when a terminator actually exists on the way. JSX text legitimately
|
|
232
|
+
// contains `/*`-looking runs — `app/api/**/route.ts` inside <code> is the
|
|
233
|
+
// canonical one — and a scanner that hunts for a missing `*/` would run
|
|
234
|
+
// past the end of the "comment" and blank the rest of the document,
|
|
235
|
+
// producing an unterminated-JSX build error. Mid-line block comments are
|
|
236
|
+
// real comments that acorn already ignores.
|
|
237
|
+
if (!lineStart) {
|
|
238
|
+
i += 2;
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
let j = i + 2;
|
|
242
|
+
let end = -1;
|
|
243
|
+
while (j < n) {
|
|
244
|
+
if (text[j] === '*' && text[j + 1] === '/') {
|
|
245
|
+
end = j + 2;
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
232
248
|
j++;
|
|
233
|
-
|
|
249
|
+
}
|
|
250
|
+
if (end === -1) {
|
|
251
|
+
lineStart = false;
|
|
252
|
+
i += 2;
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
234
255
|
for (let k = i; k < end; k++)
|
|
235
256
|
if (text[k] !== '\n')
|
|
236
257
|
chars[k] = ' ';
|
package/dist/server-jsgen.js
CHANGED
|
@@ -586,7 +586,7 @@ export function buildComponentEntries(irRoot) {
|
|
|
586
586
|
const entries = [];
|
|
587
587
|
for (const comp of irRoot.components) {
|
|
588
588
|
const bodyCode = generateFunctionBody(comp, importedNames);
|
|
589
|
-
const paramInit = buildParamInit(comp.paramNames);
|
|
589
|
+
const paramInit = buildParamInit(comp.paramNames, comp.propsAlias);
|
|
590
590
|
const diag = process.env.VESK_SSR_LOG
|
|
591
591
|
? `console.error('[SSR-CALL]', ${JSON.stringify(comp.name)}, props ? JSON.stringify(props) : String(props));\n`
|
|
592
592
|
: '';
|
package/dist/server-utils.d.ts
CHANGED
|
@@ -116,7 +116,19 @@ export declare function tryEvalExpr(raw: string, props: Record<string, unknown>,
|
|
|
116
116
|
export declare function childrenToHTML(nodes: IRNode[]): string;
|
|
117
117
|
export declare function extractTopLevelNames(topLevelCode: string[]): string[];
|
|
118
118
|
export declare function extractRuntimeNames(importStrs: string[]): string[];
|
|
119
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Emits the statement that binds a component's declared first parameter to
|
|
121
|
+
* the incoming props object.
|
|
122
|
+
*
|
|
123
|
+
* - No parameter, or a parameter already named `props`: nothing to do.
|
|
124
|
+
* - A single identifier with any OTHER name (`component Card(p)`, React-style):
|
|
125
|
+
* alias the whole props object. It used to be treated as a destructuring
|
|
126
|
+
* pattern, so `const { p } = props` bound `p` to `props.p` (undefined) and
|
|
127
|
+
* every `p.x` read threw at runtime.
|
|
128
|
+
* - Two or more names, or a name carrying a default (`title = ''`): those come
|
|
129
|
+
* from a destructuring pattern, so destructure as before.
|
|
130
|
+
*/
|
|
131
|
+
export declare function buildParamInit(paramNames: string[], propsAlias?: string | null): string;
|
|
120
132
|
export declare function resolveComponentName(source: string): string | null;
|
|
121
133
|
export declare function setRuntimeModule(mod: Record<string, unknown>): void;
|
|
122
134
|
export declare function loadRuntimeImports(importStrs: string[]): Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-utils.d.ts","sourceRoot":"","sources":["../src/server-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAapD,eAAO,IAAI,YAAY,SAAQ,CAAC;AAOhC,eAAO,IAAI,eAAe,SAAO,CAAC;AAClC,eAAO,IAAI,OAAO,QAAI,CAAC;AACvB,eAAO,IAAI,eAAe,SAAQ,CAAC;AACnC,eAAO,IAAI,kBAAkB,EAAE,GAAG,CAAC,M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1059
1059
|
return null;
|
|
1060
1060
|
}
|
|
1061
1061
|
}
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1062
|
+
/**
|
|
1063
|
+
* Emits the statement that binds a component's declared first parameter to
|
|
1064
|
+
* the incoming props object.
|
|
1065
|
+
*
|
|
1066
|
+
* - No parameter, or a parameter already named `props`: nothing to do.
|
|
1067
|
+
* - A single identifier with any OTHER name (`component Card(p)`, React-style):
|
|
1068
|
+
* alias the whole props object. It used to be treated as a destructuring
|
|
1069
|
+
* pattern, so `const { p } = props` bound `p` to `props.p` (undefined) and
|
|
1070
|
+
* every `p.x` read threw at runtime.
|
|
1071
|
+
* - Two or more names, or a name carrying a default (`title = ''`): those come
|
|
1072
|
+
* from a destructuring pattern, so destructure as before.
|
|
1073
|
+
*/
|
|
1074
|
+
export function buildParamInit(paramNames, propsAlias = null) {
|
|
1075
|
+
if (propsAlias) {
|
|
1076
|
+
return propsAlias === 'props' ? '' : `const ${propsAlias} = props;`;
|
|
1065
1077
|
}
|
|
1066
1078
|
if (paramNames.length === 0)
|
|
1067
1079
|
return '';
|
|
1080
|
+
if (paramNames.length === 1 && paramNames[0] === 'props') {
|
|
1081
|
+
return '';
|
|
1082
|
+
}
|
|
1068
1083
|
return `const { ${paramNames.join(', ')} } = props;`;
|
|
1069
1084
|
}
|
|
1070
1085
|
export function resolveComponentName(source) {
|
package/dist/typecheck.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export interface TypecheckError {
|
|
|
9
9
|
code: string;
|
|
10
10
|
message: string;
|
|
11
11
|
}
|
|
12
|
-
export declare const AMBIENT = "\ndeclare namespace JSX {\n type VeskEventHandler<E extends Event = Event> = (event: E) => void;\n interface VeskCommonAttributes {\n key?: string | number;\n class?: string;\n id?: string;\n style?: string;\n title?: string;\n hidden?: boolean | string;\n lang?: string;\n dir?: 'ltr' | 'rtl' | 'auto';\n tabIndex?: number;\n role?: string;\n }\n interface VeskEventAttributes {\n onClick?: VeskEventHandler<MouseEvent>;\n onDblClick?: VeskEventHandler<MouseEvent>;\n onMouseDown?: VeskEventHandler<MouseEvent>;\n onMouseUp?: VeskEventHandler<MouseEvent>;\n onMouseEnter?: VeskEventHandler<MouseEvent>;\n onMouseLeave?: VeskEventHandler<MouseEvent>;\n onMouseMove?: VeskEventHandler<MouseEvent>;\n onKeyDown?: VeskEventHandler<KeyboardEvent>;\n onKeyUp?: VeskEventHandler<KeyboardEvent>;\n onFocus?: VeskEventHandler<FocusEvent>;\n onBlur?: VeskEventHandler<FocusEvent>;\n onInput?: VeskEventHandler<InputEvent>;\n onChange?: VeskEventHandler<Event>;\n onSubmit?: VeskEventHandler<SubmitEvent>;\n onScroll?: VeskEventHandler<UIEvent>;\n onWheel?: VeskEventHandler<WheelEvent>;\n // Lowercase aliases \u2014 HTML attribute names are case-insensitive and real\n // code writes onclick=/oninput=. Keep in sync with the camelCase members.\n onclick?: VeskEventHandler<MouseEvent>;\n ondblclick?: VeskEventHandler<MouseEvent>;\n onmousedown?: VeskEventHandler<MouseEvent>;\n onmouseup?: VeskEventHandler<MouseEvent>;\n onmouseenter?: VeskEventHandler<MouseEvent>;\n onmouseleave?: VeskEventHandler<MouseEvent>;\n onmousemove?: VeskEventHandler<MouseEvent>;\n onkeydown?: VeskEventHandler<KeyboardEvent>;\n onkeyup?: VeskEventHandler<KeyboardEvent>;\n onfocus?: VeskEventHandler<FocusEvent>;\n onblur?: VeskEventHandler<FocusEvent>;\n oninput?: VeskEventHandler<InputEvent>;\n onchange?: VeskEventHandler<Event>;\n onsubmit?: VeskEventHandler<SubmitEvent>;\n }\n type Component = string | number | boolean | null | undefined | Component[];\n interface VeskGlobalAttributes extends VeskCommonAttributes, VeskEventAttributes {\n children?: Component;\n }\n interface VeskAnchorAttributes extends VeskGlobalAttributes {\n href?: string;\n target?: string;\n rel?: string;\n download?: string | boolean;\n type?: string;\n hreflang?: string;\n }\n interface VeskMediaAttributes extends VeskGlobalAttributes {\n src?: string;\n width?: string | number;\n height?: string | number;\n }\n interface VeskInputAttributes extends VeskGlobalAttributes {\n type?: string;\n name?: string;\n value?: string | number | readonly string[];\n placeholder?: string;\n checked?: boolean | string;\n disabled?: boolean | string;\n readOnly?: boolean | string;\n required?: boolean | string;\n min?: string | number;\n max?: string | number;\n step?: string | number;\n pattern?: string;\n autoComplete?: string;\n autoFocus?: boolean | string;\n multiple?: boolean | string;\n accept?: string;\n size?: number;\n list?: string;\n }\n interface IntrinsicElements {\n html?: VeskGlobalAttributes & { manifest?: string };\n head?: VeskGlobalAttributes;\n body?: VeskGlobalAttributes;\n div?: VeskGlobalAttributes;\n span?: VeskGlobalAttributes;\n p?: VeskGlobalAttributes;\n h1?: VeskGlobalAttributes;\n h2?: VeskGlobalAttributes;\n h3?: VeskGlobalAttributes;\n h4?: VeskGlobalAttributes;\n h5?: VeskGlobalAttributes;\n h6?: VeskGlobalAttributes;\n a?: VeskAnchorAttributes;\n nav?: VeskGlobalAttributes;\n header?: VeskGlobalAttributes;\n footer?: VeskGlobalAttributes;\n main?: VeskGlobalAttributes;\n section?: VeskGlobalAttributes;\n article?: VeskGlobalAttributes;\n aside?: VeskGlobalAttributes;\n button?: VeskGlobalAttributes & {\n type?: 'button' | 'submit' | 'reset';\n disabled?: boolean | string;\n name?: string;\n value?: string | number;\n };\n form?: VeskGlobalAttributes & {\n action?: string;\n method?: 'get' | 'post';\n target?: string;\n encType?: string;\n noValidate?: boolean | string;\n name?: string;\n autoComplete?: string;\n };\n input?: VeskInputAttributes;\n textarea?: VeskGlobalAttributes & {\n rows?: number;\n cols?: number;\n placeholder?: string;\n value?: string | number;\n disabled?: boolean | string;\n readOnly?: boolean | string;\n required?: boolean | string;\n name?: string;\n };\n select?: VeskGlobalAttributes & {\n name?: string;\n value?: string | number | readonly string[];\n disabled?: boolean | string;\n required?: boolean | string;\n multiple?: boolean | string;\n size?: number;\n autoComplete?: string;\n };\n option?: VeskGlobalAttributes & {\n value?: string | number;\n selected?: boolean | string;\n disabled?: boolean | string;\n label?: string;\n };\n optgroup?: VeskGlobalAttributes & { label?: string; disabled?: boolean | string };\n label?: VeskGlobalAttributes & { htmlFor?: string };\n fieldset?: VeskGlobalAttributes & { disabled?: boolean | string; name?: string; form?: string };\n legend?: VeskGlobalAttributes;\n datalist?: VeskGlobalAttributes;\n img?: VeskGlobalAttributes & {\n src?: string;\n alt?: string;\n width?: string | number;\n height?: string | number;\n srcSet?: string;\n sizes?: string;\n loading?: 'eager' | 'lazy';\n decoding?: 'sync' | 'async' | 'auto';\n };\n picture?: VeskGlobalAttributes;\n source?: VeskGlobalAttributes & { src?: string; srcSet?: string; sizes?: string; media?: string; type?: string };\n video?: VeskMediaAttributes & {\n controls?: boolean | string;\n autoPlay?: boolean | string;\n loop?: boolean | string;\n muted?: boolean | string;\n preload?: 'none' | 'metadata' | 'auto' | '';\n poster?: string;\n playsInline?: boolean | string;\n };\n audio?: VeskGlobalAttributes & {\n src?: string;\n controls?: boolean | string;\n autoPlay?: boolean | string;\n loop?: boolean | string;\n muted?: boolean | string;\n preload?: 'none' | 'metadata' | 'auto' | '';\n };\n track?: VeskGlobalAttributes & {\n src?: string;\n kind?: string;\n srclang?: string;\n label?: string;\n default?: boolean | string;\n };\n canvas?: VeskGlobalAttributes & { width?: number; height?: number };\n iframe?: VeskGlobalAttributes & {\n src?: string;\n srcDoc?: string;\n width?: string | number;\n height?: string | number;\n allow?: string;\n loading?: 'eager' | 'lazy';\n sandbox?: string;\n allowFullScreen?: boolean | string;\n referrerPolicy?: string;\n };\n embed?: VeskGlobalAttributes & { src?: string; type?: string; width?: string | number; height?: string | number };\n object?: VeskGlobalAttributes & { data?: string; type?: string; name?: string; width?: string | number; height?: string | number };\n table?: VeskGlobalAttributes;\n caption?: VeskGlobalAttributes;\n thead?: VeskGlobalAttributes;\n tbody?: VeskGlobalAttributes;\n tfoot?: VeskGlobalAttributes;\n tr?: VeskGlobalAttributes;\n th?: VeskGlobalAttributes & { colSpan?: number; rowSpan?: number; scope?: string; headers?: string };\n td?: VeskGlobalAttributes & { colSpan?: number; rowSpan?: number; headers?: string };\n col?: VeskGlobalAttributes & { span?: number };\n colgroup?: VeskGlobalAttributes & { span?: number };\n ul?: VeskGlobalAttributes;\n ol?: VeskGlobalAttributes & { start?: number; reversed?: boolean | string; type?: string };\n li?: VeskGlobalAttributes & { value?: number };\n dl?: VeskGlobalAttributes;\n dt?: VeskGlobalAttributes;\n dd?: VeskGlobalAttributes;\n br?: VeskGlobalAttributes;\n hr?: VeskGlobalAttributes;\n pre?: VeskGlobalAttributes;\n code?: VeskGlobalAttributes;\n blockquote?: VeskGlobalAttributes & { cite?: string };\n q?: VeskGlobalAttributes & { cite?: string };\n strong?: VeskGlobalAttributes;\n em?: VeskGlobalAttributes;\n small?: VeskGlobalAttributes;\n s?: VeskGlobalAttributes;\n cite?: VeskGlobalAttributes;\n dfn?: VeskGlobalAttributes;\n abbr?: VeskGlobalAttributes & { title?: string };\n time?: VeskGlobalAttributes & { dateTime?: string };\n data?: VeskGlobalAttributes & { value?: string | number };\n mark?: VeskGlobalAttributes;\n del?: VeskGlobalAttributes & { cite?: string; dateTime?: string };\n ins?: VeskGlobalAttributes & { cite?: string; dateTime?: string };\n sub?: VeskGlobalAttributes;\n sup?: VeskGlobalAttributes;\n u?: VeskGlobalAttributes;\n kbd?: VeskGlobalAttributes;\n samp?: VeskGlobalAttributes;\n var?: VeskGlobalAttributes;\n figure?: VeskGlobalAttributes;\n figcaption?: VeskGlobalAttributes;\n details?: VeskGlobalAttributes & { open?: boolean | string };\n summary?: VeskGlobalAttributes;\n dialog?: VeskGlobalAttributes & { open?: boolean | string };\n menu?: VeskGlobalAttributes;\n address?: VeskGlobalAttributes;\n b?: VeskGlobalAttributes;\n i?: VeskGlobalAttributes;\n ruby?: VeskGlobalAttributes;\n rt?: VeskGlobalAttributes;\n rp?: VeskGlobalAttributes;\n bdi?: VeskGlobalAttributes;\n bdo?: VeskGlobalAttributes;\n wbr?: VeskGlobalAttributes;\n area?: VeskGlobalAttributes & {\n coords?: string;\n shape?: string;\n href?: string;\n target?: string;\n alt?: string;\n };\n map?: VeskGlobalAttributes & { name?: string };\n noscript?: VeskGlobalAttributes;\n template?: VeskGlobalAttributes;\n slot?: VeskGlobalAttributes & { name?: string };\n meta?: VeskGlobalAttributes & {\n name?: string;\n content?: string;\n charSet?: string;\n httpEquiv?: string;\n // Lowercase aliases \u2014 HTML attribute names are case-insensitive and\n // real code (and SSR output) writes charset. Keep in sync with the\n // camelCase members.\n charset?: string;\n };\n title?: VeskGlobalAttributes;\n base?: VeskGlobalAttributes & { href?: string; target?: string };\n link?: VeskGlobalAttributes & {\n rel?: string;\n href?: string;\n sizes?: string;\n media?: string;\n as?: string;\n crossOrigin?: string;\n integrity?: string;\n type?: string;\n // Lowercase alias \u2014 see the meta note above.\n crossorigin?: string | boolean;\n };\n style?: VeskGlobalAttributes & { media?: string };\n script?: VeskGlobalAttributes & {\n src?: string;\n async?: boolean | string;\n defer?: boolean | string;\n type?: string;\n crossOrigin?: string;\n integrity?: string;\n nonce?: string;\n noModule?: boolean | string;\n // Lowercase aliases \u2014 see the meta note above.\n crossorigin?: boolean | string;\n };\n svg?: VeskGlobalAttributes & {\n viewBox?: string;\n xmlns?: string;\n width?: string | number;\n height?: string | number;\n fill?: string;\n stroke?: string;\n strokeWidth?: string | number;\n };\n g?: VeskGlobalAttributes & { transform?: string; fill?: string; stroke?: string; strokeWidth?: string | number };\n path?: VeskGlobalAttributes & {\n d?: string;\n fill?: string;\n stroke?: string;\n strokeWidth?: string | number;\n fillRule?: string;\n clipRule?: string;\n };\n circle?: VeskGlobalAttributes & {\n cx?: string | number;\n cy?: string | number;\n r?: string | number;\n fill?: string;\n stroke?: string;\n strokeWidth?: string | number;\n };\n ellipse?: VeskGlobalAttributes & {\n cx?: string | number;\n cy?: string | number;\n rx?: string | number;\n ry?: string | number;\n fill?: string;\n };\n rect?: VeskGlobalAttributes & {\n x?: string | number;\n y?: string | number;\n width?: string | number;\n height?: string | number;\n rx?: string | number;\n ry?: string | number;\n fill?: string;\n };\n line?: VeskGlobalAttributes & {\n x1?: string | number;\n y1?: string | number;\n x2?: string | number;\n y2?: string | number;\n stroke?: string;\n strokeWidth?: string | number;\n };\n polyline?: VeskGlobalAttributes & { points?: string; fill?: string; stroke?: string };\n polygon?: VeskGlobalAttributes & { points?: string; fill?: string; stroke?: string };\n text?: VeskGlobalAttributes & { x?: string | number; y?: string | number; fill?: string; fontSize?: string | number };\n defs?: VeskGlobalAttributes;\n linearGradient?: VeskGlobalAttributes;\n radialGradient?: VeskGlobalAttributes;\n stop?: VeskGlobalAttributes & { offset?: string | number; stopColor?: string; stopOpacity?: string | number };\n\n // Unknown/custom tags stay permissive \u2014 components and web components\n // resolve through the index signature, known tags get the typed members.\n [elemName: string]: unknown;\n }\n type Component = string | number | boolean | null | undefined | Component[];\n}\ndeclare type Component = string | number | boolean | null | undefined | Component[];\ndeclare const Head: (props: { children?: Component }) => Component;\ninterface Tracked<T> {\n get(): T;\n set(value: T): void;\n}\ninterface Derived<T> {\n get(): T;\n set(value: T): void;\n}\ndeclare function track<T>(initialValue: T): Tracked<T>;\ndeclare function track<T>(fn: () => T): Derived<T>;\ndeclare function derived<T>(fn: () => T): Derived<T>;\ndeclare function effect(fn: () => void): unknown;\ndeclare function untrack<T>(fn: () => T): T;\ndeclare function peek<T>(fn: () => T): T;\ndeclare function tick(): Promise<void>;\ndeclare function flushSync(fn: () => void): void;\ndeclare function on_destroy(fn: () => void): void;\ndeclare function createContext<T>(defaultValue?: T): { id: symbol; defaultValue: T | undefined };\n// useFetch returns a THENABLE resource, not the data itself. In async\n// components you must `await` it before reading/iterating the payload;\n// passing `into: <tracked cell>` writes the payload into the cell and makes\n// awaiting unnecessary (the return value can be ignored).\ninterface VeskResource<T> {\n loading: boolean;\n error: unknown;\n data: T | undefined;\n refresh(): void;\n abort(): void;\n then<TResult1 = T, TResult2 = never>(\n onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | undefined | null,\n ): PromiseLike<TResult1 | TResult2>;\n}\ninterface VeskUseFetchOptions<T> {\n /** Cache/SSR key \u2014 defaults to the URL string. */\n key?: string;\n /** Target tracked cell (from track<T>()) \u2014 the payload is written into it, so awaiting is unnecessary. */\n into?: Tracked<T>;\n staleTime?: number;\n keepPreviousData?: boolean;\n retry?: number;\n retryDelay?: number;\n timeout?: number;\n enabled?: boolean;\n dedupe?: boolean;\n method?: string;\n headers?: Record<string, string>;\n body?: unknown;\n credentials?: 'omit' | 'same-origin' | 'include';\n signal?: { readonly aborted: boolean };\n}\ndeclare function useFetch<T = unknown>(\n urlOrFn: string | (() => Promise<T>),\n options?: VeskUseFetchOptions<T>,\n): VeskResource<T>;\ndeclare namespace useFetch {\n function text<T = string>(url: string, options?: Omit<VeskUseFetchOptions<T>, 'body'>): VeskResource<T>;\n function json<T = unknown>(url: string, options?: Omit<VeskUseFetchOptions<T>, 'body'>): VeskResource<T>;\n function arrayBuffer<T = ArrayBuffer>(url: string, options?: Omit<VeskUseFetchOptions<T>, 'body'>): VeskResource<T>;\n}\ndeclare function useRouter(): unknown;\ndeclare function useParams(): Record<string, string>;\ndeclare function usePathname(): string;\ndeclare function useSearchParams(): URLSearchParams;\ndeclare function useNavigate(): (to: string) => void;\ndeclare function defineAction(...args: unknown[]): unknown;\ndeclare const Form: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const Field: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare function required(...args: unknown[]): unknown;\ndeclare function email(...args: unknown[]): unknown;\ndeclare function minLength(...args: unknown[]): unknown;\ndeclare function maxLength(...args: unknown[]): unknown;\ndeclare function pattern(...args: unknown[]): unknown;\ndeclare function custom(...args: unknown[]): unknown;\ndeclare const Link: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const NavLink: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const Outlet: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const Image: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const Portal: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const Experiment: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare function useLoadingIndicator(options?: {\n duration?: number;\n throttle?: number;\n hideDelay?: number;\n resetDelay?: number;\n estimatedProgress?: (duration: number, elapsed: number) => number;\n}): {\n progress: Tracked<number>;\n isLoading: Tracked<boolean>;\n error: Tracked<boolean>;\n start(opts?: { force?: boolean }): void;\n set(value: number, opts?: { force?: boolean }): void;\n finish(opts?: { force?: boolean; error?: boolean }): void;\n clear(): void;\n};\ndeclare const LoadingIndicator: (props: {\n color?: string | false;\n errorColor?: string;\n height?: number | string;\n position?: 'top' | 'bottom';\n zIndex?: number;\n duration?: number;\n throttle?: number;\n hideDelay?: number;\n resetDelay?: number;\n estimatedProgress?: (duration: number, elapsed: number) => number;\n class?: string;\n className?: string;\n style?: string;\n children?: Component;\n [k: string]: unknown;\n}) => Component;\ndeclare const JsonLd: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const ArticleSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const ProductSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const FAQPageSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const BreadcrumbListSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const OrganizationSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const LocalBusinessSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const VideoSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare function redirect(...args: unknown[]): unknown;\ndeclare function permanentRedirect(...args: unknown[]): unknown;\ndeclare function notFound(...args: unknown[]): never;\ndeclare class NotFoundError extends Error {}\ndeclare function createResource(...args: unknown[]): unknown;\ndeclare function getAction(...args: unknown[]): unknown;\ndeclare function validateActionInput(...args: unknown[]): unknown;\ndeclare function issuesToFieldMap(...args: unknown[]): unknown;\ndeclare function isFormAction(...args: unknown[]): unknown;\n";
|
|
13
|
-
export declare const RUNTIME_OVERRIDE = "\nimport '@vesk/runtime';\ndeclare module '@vesk/runtime' {\n export function track<T>(initialValue: T): Tracked<T>;\n export function track<T>(fn: () => T): Derived<T>;\n export function derived<T>(fn: () => T): Derived<T>;\n}\n";
|
|
12
|
+
export declare const AMBIENT = "\ndeclare namespace JSX {\n type VeskEventHandler<E extends Event = Event> = (event: E) => void;\n interface VeskCommonAttributes {\n key?: string | number;\n class?: string;\n id?: string;\n style?: string;\n title?: string;\n hidden?: boolean | string;\n lang?: string;\n dir?: 'ltr' | 'rtl' | 'auto';\n tabIndex?: number;\n role?: string;\n }\n interface VeskEventAttributes {\n onClick?: VeskEventHandler<MouseEvent>;\n onDblClick?: VeskEventHandler<MouseEvent>;\n onMouseDown?: VeskEventHandler<MouseEvent>;\n onMouseUp?: VeskEventHandler<MouseEvent>;\n onMouseEnter?: VeskEventHandler<MouseEvent>;\n onMouseLeave?: VeskEventHandler<MouseEvent>;\n onMouseMove?: VeskEventHandler<MouseEvent>;\n onKeyDown?: VeskEventHandler<KeyboardEvent>;\n onKeyUp?: VeskEventHandler<KeyboardEvent>;\n onFocus?: VeskEventHandler<FocusEvent>;\n onBlur?: VeskEventHandler<FocusEvent>;\n onInput?: VeskEventHandler<InputEvent>;\n onChange?: VeskEventHandler<Event>;\n onSubmit?: VeskEventHandler<SubmitEvent>;\n onScroll?: VeskEventHandler<UIEvent>;\n onWheel?: VeskEventHandler<WheelEvent>;\n // Lowercase aliases \u2014 HTML attribute names are case-insensitive and real\n // code writes onclick=/oninput=. Keep in sync with the camelCase members.\n onclick?: VeskEventHandler<MouseEvent>;\n ondblclick?: VeskEventHandler<MouseEvent>;\n onmousedown?: VeskEventHandler<MouseEvent>;\n onmouseup?: VeskEventHandler<MouseEvent>;\n onmouseenter?: VeskEventHandler<MouseEvent>;\n onmouseleave?: VeskEventHandler<MouseEvent>;\n onmousemove?: VeskEventHandler<MouseEvent>;\n onkeydown?: VeskEventHandler<KeyboardEvent>;\n onkeyup?: VeskEventHandler<KeyboardEvent>;\n onfocus?: VeskEventHandler<FocusEvent>;\n onblur?: VeskEventHandler<FocusEvent>;\n oninput?: VeskEventHandler<InputEvent>;\n onchange?: VeskEventHandler<Event>;\n onsubmit?: VeskEventHandler<SubmitEvent>;\n }\n type Component = string | number | boolean | null | undefined | Component[];\n interface VeskGlobalAttributes extends VeskCommonAttributes, VeskEventAttributes {\n children?: Component;\n }\n interface VeskAnchorAttributes extends VeskGlobalAttributes {\n href?: string;\n target?: string;\n rel?: string;\n download?: string | boolean;\n type?: string;\n hreflang?: string;\n }\n interface VeskMediaAttributes extends VeskGlobalAttributes {\n src?: string;\n width?: string | number;\n height?: string | number;\n }\n interface VeskInputAttributes extends VeskGlobalAttributes {\n type?: string;\n name?: string;\n value?: string | number | readonly string[];\n placeholder?: string;\n checked?: boolean | string;\n disabled?: boolean | string;\n readOnly?: boolean | string;\n required?: boolean | string;\n min?: string | number;\n max?: string | number;\n step?: string | number;\n pattern?: string;\n autoComplete?: string;\n autoFocus?: boolean | string;\n multiple?: boolean | string;\n accept?: string;\n size?: number;\n list?: string;\n }\n interface IntrinsicElements {\n html?: VeskGlobalAttributes & { manifest?: string };\n head?: VeskGlobalAttributes;\n body?: VeskGlobalAttributes;\n div?: VeskGlobalAttributes;\n span?: VeskGlobalAttributes;\n p?: VeskGlobalAttributes;\n h1?: VeskGlobalAttributes;\n h2?: VeskGlobalAttributes;\n h3?: VeskGlobalAttributes;\n h4?: VeskGlobalAttributes;\n h5?: VeskGlobalAttributes;\n h6?: VeskGlobalAttributes;\n a?: VeskAnchorAttributes;\n nav?: VeskGlobalAttributes;\n header?: VeskGlobalAttributes;\n footer?: VeskGlobalAttributes;\n main?: VeskGlobalAttributes;\n section?: VeskGlobalAttributes;\n article?: VeskGlobalAttributes;\n aside?: VeskGlobalAttributes;\n button?: VeskGlobalAttributes & {\n type?: 'button' | 'submit' | 'reset';\n disabled?: boolean | string;\n name?: string;\n value?: string | number;\n };\n form?: VeskGlobalAttributes & {\n action?: string;\n method?: 'get' | 'post';\n target?: string;\n encType?: string;\n noValidate?: boolean | string;\n name?: string;\n autoComplete?: string;\n };\n input?: VeskInputAttributes;\n textarea?: VeskGlobalAttributes & {\n rows?: number;\n cols?: number;\n placeholder?: string;\n value?: string | number;\n disabled?: boolean | string;\n readOnly?: boolean | string;\n required?: boolean | string;\n name?: string;\n };\n select?: VeskGlobalAttributes & {\n name?: string;\n value?: string | number | readonly string[];\n disabled?: boolean | string;\n required?: boolean | string;\n multiple?: boolean | string;\n size?: number;\n autoComplete?: string;\n };\n option?: VeskGlobalAttributes & {\n value?: string | number;\n selected?: boolean | string;\n disabled?: boolean | string;\n label?: string;\n };\n optgroup?: VeskGlobalAttributes & { label?: string; disabled?: boolean | string };\n label?: VeskGlobalAttributes & { htmlFor?: string };\n fieldset?: VeskGlobalAttributes & { disabled?: boolean | string; name?: string; form?: string };\n legend?: VeskGlobalAttributes;\n datalist?: VeskGlobalAttributes;\n img?: VeskGlobalAttributes & {\n src?: string;\n alt?: string;\n width?: string | number;\n height?: string | number;\n srcSet?: string;\n sizes?: string;\n loading?: 'eager' | 'lazy';\n decoding?: 'sync' | 'async' | 'auto';\n };\n picture?: VeskGlobalAttributes;\n source?: VeskGlobalAttributes & { src?: string; srcSet?: string; sizes?: string; media?: string; type?: string };\n video?: VeskMediaAttributes & {\n controls?: boolean | string;\n autoPlay?: boolean | string;\n loop?: boolean | string;\n muted?: boolean | string;\n preload?: 'none' | 'metadata' | 'auto' | '';\n poster?: string;\n playsInline?: boolean | string;\n };\n audio?: VeskGlobalAttributes & {\n src?: string;\n controls?: boolean | string;\n autoPlay?: boolean | string;\n loop?: boolean | string;\n muted?: boolean | string;\n preload?: 'none' | 'metadata' | 'auto' | '';\n };\n track?: VeskGlobalAttributes & {\n src?: string;\n kind?: string;\n srclang?: string;\n label?: string;\n default?: boolean | string;\n };\n canvas?: VeskGlobalAttributes & { width?: number; height?: number };\n iframe?: VeskGlobalAttributes & {\n src?: string;\n srcDoc?: string;\n width?: string | number;\n height?: string | number;\n allow?: string;\n loading?: 'eager' | 'lazy';\n sandbox?: string;\n allowFullScreen?: boolean | string;\n referrerPolicy?: string;\n };\n embed?: VeskGlobalAttributes & { src?: string; type?: string; width?: string | number; height?: string | number };\n object?: VeskGlobalAttributes & { data?: string; type?: string; name?: string; width?: string | number; height?: string | number };\n table?: VeskGlobalAttributes;\n caption?: VeskGlobalAttributes;\n thead?: VeskGlobalAttributes;\n tbody?: VeskGlobalAttributes;\n tfoot?: VeskGlobalAttributes;\n tr?: VeskGlobalAttributes;\n th?: VeskGlobalAttributes & { colSpan?: number; rowSpan?: number; scope?: string; headers?: string };\n td?: VeskGlobalAttributes & { colSpan?: number; rowSpan?: number; headers?: string };\n col?: VeskGlobalAttributes & { span?: number };\n colgroup?: VeskGlobalAttributes & { span?: number };\n ul?: VeskGlobalAttributes;\n ol?: VeskGlobalAttributes & { start?: number; reversed?: boolean | string; type?: string };\n li?: VeskGlobalAttributes & { value?: number };\n dl?: VeskGlobalAttributes;\n dt?: VeskGlobalAttributes;\n dd?: VeskGlobalAttributes;\n br?: VeskGlobalAttributes;\n hr?: VeskGlobalAttributes;\n pre?: VeskGlobalAttributes;\n code?: VeskGlobalAttributes;\n blockquote?: VeskGlobalAttributes & { cite?: string };\n q?: VeskGlobalAttributes & { cite?: string };\n strong?: VeskGlobalAttributes;\n em?: VeskGlobalAttributes;\n small?: VeskGlobalAttributes;\n s?: VeskGlobalAttributes;\n cite?: VeskGlobalAttributes;\n dfn?: VeskGlobalAttributes;\n abbr?: VeskGlobalAttributes & { title?: string };\n time?: VeskGlobalAttributes & { dateTime?: string };\n data?: VeskGlobalAttributes & { value?: string | number };\n mark?: VeskGlobalAttributes;\n del?: VeskGlobalAttributes & { cite?: string; dateTime?: string };\n ins?: VeskGlobalAttributes & { cite?: string; dateTime?: string };\n sub?: VeskGlobalAttributes;\n sup?: VeskGlobalAttributes;\n u?: VeskGlobalAttributes;\n kbd?: VeskGlobalAttributes;\n samp?: VeskGlobalAttributes;\n var?: VeskGlobalAttributes;\n figure?: VeskGlobalAttributes;\n figcaption?: VeskGlobalAttributes;\n details?: VeskGlobalAttributes & { open?: boolean | string };\n summary?: VeskGlobalAttributes;\n dialog?: VeskGlobalAttributes & { open?: boolean | string };\n menu?: VeskGlobalAttributes;\n address?: VeskGlobalAttributes;\n b?: VeskGlobalAttributes;\n i?: VeskGlobalAttributes;\n ruby?: VeskGlobalAttributes;\n rt?: VeskGlobalAttributes;\n rp?: VeskGlobalAttributes;\n bdi?: VeskGlobalAttributes;\n bdo?: VeskGlobalAttributes;\n wbr?: VeskGlobalAttributes;\n area?: VeskGlobalAttributes & {\n coords?: string;\n shape?: string;\n href?: string;\n target?: string;\n alt?: string;\n };\n map?: VeskGlobalAttributes & { name?: string };\n noscript?: VeskGlobalAttributes;\n template?: VeskGlobalAttributes;\n slot?: VeskGlobalAttributes & { name?: string };\n meta?: VeskGlobalAttributes & {\n name?: string;\n content?: string;\n charSet?: string;\n httpEquiv?: string;\n // Lowercase aliases \u2014 HTML attribute names are case-insensitive and\n // real code (and SSR output) writes charset. Keep in sync with the\n // camelCase members.\n charset?: string;\n };\n title?: VeskGlobalAttributes;\n base?: VeskGlobalAttributes & { href?: string; target?: string };\n link?: VeskGlobalAttributes & {\n rel?: string;\n href?: string;\n sizes?: string;\n media?: string;\n as?: string;\n crossOrigin?: string;\n integrity?: string;\n type?: string;\n // Lowercase alias \u2014 see the meta note above.\n crossorigin?: string | boolean;\n };\n style?: VeskGlobalAttributes & { media?: string };\n script?: VeskGlobalAttributes & {\n src?: string;\n async?: boolean | string;\n defer?: boolean | string;\n type?: string;\n crossOrigin?: string;\n integrity?: string;\n nonce?: string;\n noModule?: boolean | string;\n // Lowercase aliases \u2014 see the meta note above.\n crossorigin?: boolean | string;\n };\n svg?: VeskGlobalAttributes & {\n viewBox?: string;\n xmlns?: string;\n width?: string | number;\n height?: string | number;\n fill?: string;\n stroke?: string;\n strokeWidth?: string | number;\n };\n g?: VeskGlobalAttributes & { transform?: string; fill?: string; stroke?: string; strokeWidth?: string | number };\n path?: VeskGlobalAttributes & {\n d?: string;\n fill?: string;\n stroke?: string;\n strokeWidth?: string | number;\n fillRule?: string;\n clipRule?: string;\n };\n circle?: VeskGlobalAttributes & {\n cx?: string | number;\n cy?: string | number;\n r?: string | number;\n fill?: string;\n stroke?: string;\n strokeWidth?: string | number;\n };\n ellipse?: VeskGlobalAttributes & {\n cx?: string | number;\n cy?: string | number;\n rx?: string | number;\n ry?: string | number;\n fill?: string;\n };\n rect?: VeskGlobalAttributes & {\n x?: string | number;\n y?: string | number;\n width?: string | number;\n height?: string | number;\n rx?: string | number;\n ry?: string | number;\n fill?: string;\n };\n line?: VeskGlobalAttributes & {\n x1?: string | number;\n y1?: string | number;\n x2?: string | number;\n y2?: string | number;\n stroke?: string;\n strokeWidth?: string | number;\n };\n polyline?: VeskGlobalAttributes & { points?: string; fill?: string; stroke?: string };\n polygon?: VeskGlobalAttributes & { points?: string; fill?: string; stroke?: string };\n text?: VeskGlobalAttributes & { x?: string | number; y?: string | number; fill?: string; fontSize?: string | number };\n defs?: VeskGlobalAttributes;\n linearGradient?: VeskGlobalAttributes;\n radialGradient?: VeskGlobalAttributes;\n stop?: VeskGlobalAttributes & { offset?: string | number; stopColor?: string; stopOpacity?: string | number };\n\n // Unknown/custom tags stay permissive \u2014 components and web components\n // resolve through the index signature, known tags get the typed members.\n [elemName: string]: unknown;\n }\n type Component = string | number | boolean | null | undefined | Component[];\n}\ndeclare type Component = string | number | boolean | null | undefined | Component[];\ndeclare const Head: (props: { children?: Component }) => Component;\n// Server-side .vsk code reads process.env (NODE_ENV, feature flags, secrets).\n// @types/node is not installed for browser targets, so declare the slice the\n// framework documents rather than failing every project that branches on env.\ndeclare const process: {\n env: Record<string, string | undefined>;\n argv: string[];\n platform: string;\n cwd(): string;\n exit(code?: number): never;\n};\ninterface Tracked<T> {\n get(): T;\n set(value: T): void;\n}\ninterface Derived<T> {\n get(): T;\n set(value: T): void;\n}\ndeclare function track<T>(initialValue: T): Tracked<T>;\ndeclare function track<T>(fn: () => T): Derived<T>;\ndeclare function derived<T>(fn: () => T): Derived<T>;\ndeclare function effect(fn: () => void): unknown;\ndeclare function untrack<T>(fn: () => T): T;\ndeclare function peek<T>(fn: () => T): T;\ndeclare function tick(): Promise<void>;\ndeclare function flushSync(fn: () => void): void;\ndeclare function on_destroy(fn: () => void): void;\n/**\n * A context created by createContext. The value type flows from the default\n * (or an explicit type argument) through set() and every get().\n */\ninterface VeskContext<T> {\n readonly id: symbol;\n get(): T;\n set(value: T): void;\n}\ndeclare function createContext<const T>(defaultValue: T): VeskContext<T>;\n// Typed request-scoped store (middleware locals, event payloads). Declare the\n// shape once and every set/get is checked against it.\ninterface VeskLocals<T extends object> {\n set<K extends keyof T>(key: K, value: T[K]): void;\n get<K extends keyof T>(key: K): T[K];\n has<K extends keyof T>(key: K): boolean;\n delete<K extends keyof T>(key: K): void;\n all(): T;\n}\ndeclare function createLocals<T extends object = Record<string, unknown>>(): VeskLocals<T>;\n// useFetch returns a THENABLE resource, not the data itself. In async\n// components you must `await` it before reading/iterating the payload;\n// passing `into: <tracked cell>` writes the payload into the cell and makes\n// awaiting unnecessary (the return value can be ignored).\ninterface VeskResource<T> {\n loading: boolean;\n error: unknown;\n data: T | undefined;\n refresh(): void;\n abort(): void;\n then<TResult1 = T, TResult2 = never>(\n onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,\n onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | undefined | null,\n ): PromiseLike<TResult1 | TResult2>;\n}\ninterface VeskUseFetchOptions<T> {\n /** Cache/SSR key \u2014 defaults to the URL string. */\n key?: string;\n /** Target tracked cell (from track<T>()) \u2014 the payload is written into it, so awaiting is unnecessary. */\n into?: Tracked<T>;\n staleTime?: number;\n keepPreviousData?: boolean;\n retry?: number;\n retryDelay?: number;\n timeout?: number;\n enabled?: boolean;\n dedupe?: boolean;\n method?: string;\n headers?: Record<string, string>;\n body?: unknown;\n credentials?: 'omit' | 'same-origin' | 'include';\n signal?: { readonly aborted: boolean };\n}\ndeclare function useFetch<T = unknown>(\n urlOrFn: string | (() => Promise<T>),\n options?: VeskUseFetchOptions<T>,\n): VeskResource<T>;\ndeclare namespace useFetch {\n function text<T = string>(url: string, options?: Omit<VeskUseFetchOptions<T>, 'body'>): VeskResource<T>;\n function json<T = unknown>(url: string, options?: Omit<VeskUseFetchOptions<T>, 'body'>): VeskResource<T>;\n function arrayBuffer<T = ArrayBuffer>(url: string, options?: Omit<VeskUseFetchOptions<T>, 'body'>): VeskResource<T>;\n}\ndeclare function useRouter(): unknown;\ndeclare function useParams(): Record<string, string>;\ndeclare function usePathname(): string;\ndeclare function useSearchParams(): URLSearchParams;\ndeclare function useNavigate(): (to: string) => void;\ndeclare function defineAction(...args: unknown[]): unknown;\ndeclare const Form: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const Field: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare function required(...args: unknown[]): unknown;\ndeclare function email(...args: unknown[]): unknown;\ndeclare function minLength(...args: unknown[]): unknown;\ndeclare function maxLength(...args: unknown[]): unknown;\ndeclare function pattern(...args: unknown[]): unknown;\ndeclare function custom(...args: unknown[]): unknown;\ndeclare const Link: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const NavLink: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const Outlet: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const Image: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const Portal: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const Experiment: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare function useLoadingIndicator(options?: {\n duration?: number;\n throttle?: number;\n hideDelay?: number;\n resetDelay?: number;\n estimatedProgress?: (duration: number, elapsed: number) => number;\n}): {\n progress: Tracked<number>;\n isLoading: Tracked<boolean>;\n error: Tracked<boolean>;\n start(opts?: { force?: boolean }): void;\n set(value: number, opts?: { force?: boolean }): void;\n finish(opts?: { force?: boolean; error?: boolean }): void;\n clear(): void;\n};\ndeclare const LoadingIndicator: (props: {\n color?: string | false;\n errorColor?: string;\n height?: number | string;\n position?: 'top' | 'bottom';\n zIndex?: number;\n duration?: number;\n throttle?: number;\n hideDelay?: number;\n resetDelay?: number;\n estimatedProgress?: (duration: number, elapsed: number) => number;\n class?: string;\n className?: string;\n style?: string;\n children?: Component;\n [k: string]: unknown;\n}) => Component;\ndeclare const JsonLd: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const ArticleSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const ProductSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const FAQPageSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const BreadcrumbListSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const OrganizationSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const LocalBusinessSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare const VideoSchema: (props: { [k: string]: unknown; children?: Component }) => Component;\ndeclare function redirect(...args: unknown[]): unknown;\ndeclare function permanentRedirect(...args: unknown[]): unknown;\ndeclare function notFound(...args: unknown[]): never;\ndeclare class NotFoundError extends Error {}\ndeclare function createResource(...args: unknown[]): unknown;\ndeclare function getAction(...args: unknown[]): unknown;\ndeclare function validateActionInput(...args: unknown[]): unknown;\ndeclare function issuesToFieldMap(...args: unknown[]): unknown;\ndeclare function isFormAction(...args: unknown[]): unknown;\n";
|
|
13
|
+
export declare const RUNTIME_OVERRIDE = "\nimport '@vesk/runtime';\ndeclare module '@vesk/runtime' {\n export function track<T>(initialValue: T): Tracked<T>;\n export function track<T>(fn: () => T): Derived<T>;\n export function derived<T>(fn: () => T): Derived<T>;\n export function createContext<const T>(defaultValue: T): VeskContext<T>;\n export function createLocals<T extends object = Record<string, unknown>>(): VeskLocals<T>;\n}\n";
|
|
14
14
|
export interface TypecheckResult {
|
|
15
15
|
errors: TypecheckError[];
|
|
16
16
|
warnings: TypecheckError[];
|
package/dist/typecheck.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typecheck.d.ts","sourceRoot":"","sources":["../src/typecheck.ts"],"names":[],"mappings":"
|
|
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;AAED,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,GAAE,gBAAqB,GAAG,eAAe,CA4FlG;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
|
@@ -3,6 +3,7 @@ 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
5
|
import { vskToTsx, generateVskDts } from '@vesk/compiler/src/vsk-tsx';
|
|
6
|
+
import { resolveAliasModule } from '@vesk/compiler/src/module-imports';
|
|
6
7
|
const SKIP_DIRS = new Set(['node_modules', '.vesk', '.git', 'dist', 'tarballs', '.next']);
|
|
7
8
|
const SKIP_FILES = new Set(['__vesk_ambient.d.ts', '__vesk_runtime_override.d.ts']);
|
|
8
9
|
export const AMBIENT = `
|
|
@@ -377,6 +378,16 @@ declare namespace JSX {
|
|
|
377
378
|
}
|
|
378
379
|
declare type Component = string | number | boolean | null | undefined | Component[];
|
|
379
380
|
declare const Head: (props: { children?: Component }) => Component;
|
|
381
|
+
// Server-side .vsk code reads process.env (NODE_ENV, feature flags, secrets).
|
|
382
|
+
// @types/node is not installed for browser targets, so declare the slice the
|
|
383
|
+
// framework documents rather than failing every project that branches on env.
|
|
384
|
+
declare const process: {
|
|
385
|
+
env: Record<string, string | undefined>;
|
|
386
|
+
argv: string[];
|
|
387
|
+
platform: string;
|
|
388
|
+
cwd(): string;
|
|
389
|
+
exit(code?: number): never;
|
|
390
|
+
};
|
|
380
391
|
interface Tracked<T> {
|
|
381
392
|
get(): T;
|
|
382
393
|
set(value: T): void;
|
|
@@ -394,7 +405,26 @@ declare function peek<T>(fn: () => T): T;
|
|
|
394
405
|
declare function tick(): Promise<void>;
|
|
395
406
|
declare function flushSync(fn: () => void): void;
|
|
396
407
|
declare function on_destroy(fn: () => void): void;
|
|
397
|
-
|
|
408
|
+
/**
|
|
409
|
+
* A context created by createContext. The value type flows from the default
|
|
410
|
+
* (or an explicit type argument) through set() and every get().
|
|
411
|
+
*/
|
|
412
|
+
interface VeskContext<T> {
|
|
413
|
+
readonly id: symbol;
|
|
414
|
+
get(): T;
|
|
415
|
+
set(value: T): void;
|
|
416
|
+
}
|
|
417
|
+
declare function createContext<const T>(defaultValue: T): VeskContext<T>;
|
|
418
|
+
// Typed request-scoped store (middleware locals, event payloads). Declare the
|
|
419
|
+
// shape once and every set/get is checked against it.
|
|
420
|
+
interface VeskLocals<T extends object> {
|
|
421
|
+
set<K extends keyof T>(key: K, value: T[K]): void;
|
|
422
|
+
get<K extends keyof T>(key: K): T[K];
|
|
423
|
+
has<K extends keyof T>(key: K): boolean;
|
|
424
|
+
delete<K extends keyof T>(key: K): void;
|
|
425
|
+
all(): T;
|
|
426
|
+
}
|
|
427
|
+
declare function createLocals<T extends object = Record<string, unknown>>(): VeskLocals<T>;
|
|
398
428
|
// useFetch returns a THENABLE resource, not the data itself. In async
|
|
399
429
|
// components you must \`await\` it before reading/iterating the payload;
|
|
400
430
|
// passing \`into: <tracked cell>\` writes the payload into the cell and makes
|
|
@@ -513,6 +543,8 @@ declare module '@vesk/runtime' {
|
|
|
513
543
|
export function track<T>(initialValue: T): Tracked<T>;
|
|
514
544
|
export function track<T>(fn: () => T): Derived<T>;
|
|
515
545
|
export function derived<T>(fn: () => T): Derived<T>;
|
|
546
|
+
export function createContext<const T>(defaultValue: T): VeskContext<T>;
|
|
547
|
+
export function createLocals<T extends object = Record<string, unknown>>(): VeskLocals<T>;
|
|
516
548
|
}
|
|
517
549
|
`;
|
|
518
550
|
function walkProjectFiles(projectRoot) {
|
|
@@ -675,7 +707,11 @@ function createTypecheckHost(projectRoot, appDir, vskFiles) {
|
|
|
675
707
|
resolveModuleNameLiterals(moduleLiterals, containingFile, redirectedReference, options) {
|
|
676
708
|
return moduleLiterals.map(({ text }) => {
|
|
677
709
|
if (text.endsWith('.vsk')) {
|
|
678
|
-
|
|
710
|
+
// Honor tsconfig `paths` aliases (`@/components/X.vsk`) the same way
|
|
711
|
+
// the build does, instead of treating the specifier as a relative
|
|
712
|
+
// path under the importing file's directory.
|
|
713
|
+
const aliased = text.startsWith('.') ? null : resolveAliasModule(text, dirname(containingFile));
|
|
714
|
+
const abs = normalize(aliased ?? join(dirname(containingFile), text));
|
|
679
715
|
return {
|
|
680
716
|
resolvedModule: {
|
|
681
717
|
resolvedFileName: abs + '.d.ts',
|
|
@@ -759,6 +795,8 @@ export function typecheckProject(projectRoot, opts = {}) {
|
|
|
759
795
|
esModuleInterop: true,
|
|
760
796
|
allowSyntheticDefaultImports: true,
|
|
761
797
|
allowImportingTsExtensions: true,
|
|
798
|
+
// Required so the virtual `.vsk` files are actually pulled into the
|
|
799
|
+
// program (without it tsc silently excludes them and reports nothing).
|
|
762
800
|
allowNonTsExtensions: true,
|
|
763
801
|
resolveJsonModule: true,
|
|
764
802
|
lib: ['lib.es2022.d.ts', 'lib.dom.d.ts', 'lib.dom.iterable.d.ts'],
|
package/dist/vsk-tsx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vsk-tsx.d.ts","sourceRoot":"","sources":["../src/vsk-tsx.ts"],"names":[],"mappings":"AAiBA;;;;;;;;GAQG;AAEH,MAAM,WAAW,QAAQ;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,GAAG;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAClD,QAAQ,CAAC,EAAE,OAAO,GAAG;QAAE,eAAe,CAAC,EAAE,OAAO,CAAC;QAAC,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IAC3E,UAAU,CAAC,EAAE,OAAO,GAAG;QAAE,YAAY,CAAC,EAAE,OAAO,CAAC;QAAC,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAA;KAAE,CAAC;IACtG,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,IAAI,EAAE,QAAQ,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;IAC1B,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,yDAAyD;IACzD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AA6vCD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE,iBAAsB,GAAG,gBAAgB,CAiDhG;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE/C;AAWD,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAmDrD"}
|
package/dist/vsk-tsx.js
CHANGED
|
@@ -255,6 +255,79 @@ function isTrackDeclStatement(stmt) {
|
|
|
255
255
|
return false;
|
|
256
256
|
return (stmt.declarations || []).some((d) => d && d.id && d.id.type === 'ArrayPattern' && d.id.lazy === true && d.init);
|
|
257
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Removes the type-argument list from a leading call expression, so
|
|
260
|
+
* `track<Post[]>([])` becomes `track([])`.
|
|
261
|
+
*
|
|
262
|
+
* `.vsk` files are type-checked as virtual files with a non-standard
|
|
263
|
+
* extension, where TypeScript reads `f<T>(x)` as the JSX element `<T>` rather
|
|
264
|
+
* than a generic call. That mis-parse swallows the rest of the enclosing
|
|
265
|
+
* function body, so every later binding is reported as "Cannot find name".
|
|
266
|
+
* Callers only use this when the type is preserved elsewhere (an explicit
|
|
267
|
+
* annotation on the binding), so nothing is lost.
|
|
268
|
+
*/
|
|
269
|
+
function stripCallTypeArgs(text) {
|
|
270
|
+
let i = 0;
|
|
271
|
+
while (i < text.length && /\s/.test(text[i]))
|
|
272
|
+
i++;
|
|
273
|
+
const nameStart = i;
|
|
274
|
+
while (i < text.length && /[A-Za-z0-9_$]/.test(text[i]))
|
|
275
|
+
i++;
|
|
276
|
+
if (i === nameStart)
|
|
277
|
+
return text;
|
|
278
|
+
// A property/element access chain (`ns.track<T>(x)`) — step over the rest.
|
|
279
|
+
while (i < text.length && (text[i] === '.' || text[i] === '?' || text[i] === '[')) {
|
|
280
|
+
const ch = text[i];
|
|
281
|
+
if (ch === '[') {
|
|
282
|
+
const close = text.indexOf(']', i);
|
|
283
|
+
if (close === -1)
|
|
284
|
+
return text;
|
|
285
|
+
i = close + 1;
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
i++;
|
|
289
|
+
while (i < text.length && /[A-Za-z0-9_$]/.test(text[i]))
|
|
290
|
+
i++;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (text[i] !== '<')
|
|
294
|
+
return text;
|
|
295
|
+
// Match the closing `>` of the type argument list, allowing nested angle
|
|
296
|
+
// brackets and quoted literal types.
|
|
297
|
+
let depth = 0;
|
|
298
|
+
let quote = '';
|
|
299
|
+
for (let j = i; j < text.length; j++) {
|
|
300
|
+
const c = text[j];
|
|
301
|
+
if (quote) {
|
|
302
|
+
if (c === '\\') {
|
|
303
|
+
j++;
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
if (c === quote)
|
|
307
|
+
quote = '';
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
if (c === '"' || c === "'" || c === '`') {
|
|
311
|
+
quote = c;
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
if (c === '<')
|
|
315
|
+
depth++;
|
|
316
|
+
else if (c === '>') {
|
|
317
|
+
depth--;
|
|
318
|
+
if (depth === 0) {
|
|
319
|
+
const after = text.slice(j + 1);
|
|
320
|
+
if (/^\s*\(/.test(after))
|
|
321
|
+
return text.slice(0, i) + after;
|
|
322
|
+
return text;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
else if (c === ';' || c === '\n') {
|
|
326
|
+
return text;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return text;
|
|
330
|
+
}
|
|
258
331
|
/**
|
|
259
332
|
* Emits the rewrite for a `const &[count] = track(0)` declarator. Mirrors
|
|
260
333
|
* the exact text produced by the previous string-level rewrite: the first
|
|
@@ -321,8 +394,18 @@ function emitTrackDeclStatement(g, source, stmt, indent, isLast, opts) {
|
|
|
321
394
|
// Annotating it with the value annotation made `&[v, cell]` emit
|
|
322
395
|
// `cell: T = <Tracked>` (unsound), and broke passing `cell` to APIs
|
|
323
396
|
// expecting `Tracked<unknown>` (e.g. useFetch `into`).
|
|
324
|
-
|
|
325
|
-
|
|
397
|
+
// With an explicit annotation the type argument is redundant, and a
|
|
398
|
+
// leading `f<T>(...)` would be mis-read as JSX on a `.vsk` virtual file.
|
|
399
|
+
if (annotation) {
|
|
400
|
+
g.add(`const ${cellName}: Tracked<`);
|
|
401
|
+
g.add(annotation, annStart, annEnd);
|
|
402
|
+
g.add('> = ');
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
g.add(`const ${cellName} = `);
|
|
406
|
+
}
|
|
407
|
+
const cellInit = annotation ? stripCallTypeArgs(initText) : initText;
|
|
408
|
+
g.add(cellInit, decl.init.start, decl.init.end);
|
|
326
409
|
g.add(';');
|
|
327
410
|
// First binding: the VALUE read from the cell.
|
|
328
411
|
g.add(' let ');
|
|
@@ -348,17 +431,23 @@ function emitTrackDeclStatement(g, source, stmt, indent, isLast, opts) {
|
|
|
348
431
|
g.add(': ');
|
|
349
432
|
g.add(annotation, annStart, annEnd);
|
|
350
433
|
g.add(' = (');
|
|
351
|
-
g.add(initText, decl.init.start, decl.init.end);
|
|
434
|
+
g.add(stripCallTypeArgs(initText), decl.init.start, decl.init.end);
|
|
352
435
|
g.add(' as unknown as ');
|
|
353
436
|
g.add(annotation, annStart, annEnd);
|
|
354
437
|
g.add(');');
|
|
355
438
|
}
|
|
356
439
|
else {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
440
|
+
// No annotation: infer through a cell so the binding keeps its real
|
|
441
|
+
// type. `let items: any = track([...])` used to erase it, and every
|
|
442
|
+
// callback derived from the value (`items.map(n => …)`) then failed
|
|
443
|
+
// under `strict` with "parameter implicitly has an 'any' type".
|
|
444
|
+
const cellName = g.cellCount === 0 ? '__cell' : `__cell${g.cellCount}`;
|
|
445
|
+
g.cellCount++;
|
|
446
|
+
g.add(`const ${cellName} = `);
|
|
360
447
|
g.add(initText, decl.init.start, decl.init.end);
|
|
361
|
-
g.add(';');
|
|
448
|
+
g.add('; let ');
|
|
449
|
+
g.add(first, firstRange[0], firstRange[1], REACTIVE_DATA);
|
|
450
|
+
g.add(` = ${cellName}.get();`);
|
|
362
451
|
}
|
|
363
452
|
for (let n = 1; n < names.length; n++) {
|
|
364
453
|
g.add(' let ');
|
|
@@ -640,10 +729,27 @@ function emitIf(g, source, stmt, indent, opts) {
|
|
|
640
729
|
emitBlock(g, source, stmt.alternate, indent, opts);
|
|
641
730
|
}
|
|
642
731
|
}
|
|
732
|
+
/**
|
|
733
|
+
* Emits a for-of/for-in loop variable.
|
|
734
|
+
*
|
|
735
|
+
* `for (p of items)` declares nothing in TypeScript/JavaScript — `p` there is a
|
|
736
|
+
* reference to an outer binding, so `tsc` reports `Cannot find name 'p'` and
|
|
737
|
+
* `vesk typecheck` fails. In a statement-mode component body a bare loop
|
|
738
|
+
* variable is plainly meant as the loop's own binding, so declare it. An
|
|
739
|
+
* existing `const`/`let`/`var` (or a destructuring pattern) is passed through.
|
|
740
|
+
*/
|
|
741
|
+
function emitLoopVariable(g, source, left) {
|
|
742
|
+
if (left && left.type === 'Identifier') {
|
|
743
|
+
g.addRaw('const ');
|
|
744
|
+
g.add(source.slice(left.start, left.end), left.start, left.end);
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
g.add(source.slice(left.start, left.end), left.start, left.end);
|
|
748
|
+
}
|
|
643
749
|
function emitForOf(g, source, stmt, indent, opts) {
|
|
644
750
|
g.add(indent);
|
|
645
751
|
g.addRaw('for (');
|
|
646
|
-
g
|
|
752
|
+
emitLoopVariable(g, source, stmt.left);
|
|
647
753
|
g.addRaw(' of ');
|
|
648
754
|
g.add(source.slice(stmt.right.start, stmt.right.end), stmt.right.start, stmt.right.end);
|
|
649
755
|
g.addRaw(') ');
|
|
@@ -652,7 +758,7 @@ function emitForOf(g, source, stmt, indent, opts) {
|
|
|
652
758
|
function emitForIn(g, source, stmt, indent, opts) {
|
|
653
759
|
g.add(indent);
|
|
654
760
|
g.addRaw('for (');
|
|
655
|
-
g
|
|
761
|
+
emitLoopVariable(g, source, stmt.left);
|
|
656
762
|
g.addRaw(' in ');
|
|
657
763
|
g.add(source.slice(stmt.right.start, stmt.right.end), stmt.right.start, stmt.right.end);
|
|
658
764
|
g.addRaw(') ');
|
|
@@ -1192,6 +1298,13 @@ export function compileVskCodegen(source, opts = {}) {
|
|
|
1192
1298
|
g.prepend('declare const Head: (props: { children?: Component }) => Component;\n');
|
|
1193
1299
|
code = g.code;
|
|
1194
1300
|
}
|
|
1301
|
+
// A `.vsk` file with no import/export is a *script* to TypeScript, so its
|
|
1302
|
+
// top-level component functions land in the global scope and collide with the
|
|
1303
|
+
// same-named component in another file ("Duplicate function implementation").
|
|
1304
|
+
// Give every generated file module identity.
|
|
1305
|
+
if (!isModuleAst(ast)) {
|
|
1306
|
+
code += '\nexport {};\n';
|
|
1307
|
+
}
|
|
1195
1308
|
return { code, mappings: g.mappings, styleRegions: g.styleRegions, errors: [] };
|
|
1196
1309
|
}
|
|
1197
1310
|
export function vskToTsx(source) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/compiler",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.40",
|
|
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.40",
|
|
24
24
|
"acorn": "^8.15.0",
|
|
25
25
|
"esrap": "^2.3.0",
|
|
26
26
|
"is-reference": "^3.0.0",
|