@vesk/compiler 0.0.1

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.
Files changed (84) hide show
  1. package/README.md +23 -0
  2. package/dist/acorn-ts-plugin/index.d.ts +482 -0
  3. package/dist/acorn-ts-plugin/index.d.ts.map +1 -0
  4. package/dist/acorn-ts-plugin/index.js +5028 -0
  5. package/dist/actions.d.ts +22 -0
  6. package/dist/actions.d.ts.map +1 -0
  7. package/dist/actions.js +167 -0
  8. package/dist/api-routes.d.ts +30 -0
  9. package/dist/api-routes.d.ts.map +1 -0
  10. package/dist/api-routes.js +350 -0
  11. package/dist/client-codegen.d.ts +19 -0
  12. package/dist/client-codegen.d.ts.map +1 -0
  13. package/dist/client-codegen.js +1523 -0
  14. package/dist/config.d.ts +6 -0
  15. package/dist/config.d.ts.map +1 -0
  16. package/dist/config.js +106 -0
  17. package/dist/errors.d.ts +33 -0
  18. package/dist/errors.d.ts.map +1 -0
  19. package/dist/errors.js +210 -0
  20. package/dist/index.d.ts +16 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +8 -0
  23. package/dist/ir-generator.d.ts +10 -0
  24. package/dist/ir-generator.d.ts.map +1 -0
  25. package/dist/ir-generator.js +1062 -0
  26. package/dist/ir.d.ts +160 -0
  27. package/dist/ir.d.ts.map +1 -0
  28. package/dist/ir.js +219 -0
  29. package/dist/middleware.d.ts +15 -0
  30. package/dist/middleware.d.ts.map +1 -0
  31. package/dist/middleware.js +183 -0
  32. package/dist/package.json +15 -0
  33. package/dist/parser.d.ts +38 -0
  34. package/dist/parser.d.ts.map +1 -0
  35. package/dist/parser.js +242 -0
  36. package/dist/router.d.ts +31 -0
  37. package/dist/router.d.ts.map +1 -0
  38. package/dist/router.js +451 -0
  39. package/dist/scan.d.ts +106 -0
  40. package/dist/scan.d.ts.map +1 -0
  41. package/dist/scan.js +438 -0
  42. package/dist/server-codegen.d.ts +5 -0
  43. package/dist/server-codegen.d.ts.map +1 -0
  44. package/dist/server-codegen.js +4 -0
  45. package/dist/server-cookies.d.ts +2 -0
  46. package/dist/server-cookies.d.ts.map +1 -0
  47. package/dist/server-cookies.js +15 -0
  48. package/dist/server-head.d.ts +10 -0
  49. package/dist/server-head.d.ts.map +1 -0
  50. package/dist/server-head.js +289 -0
  51. package/dist/server-jsgen.d.ts +6 -0
  52. package/dist/server-jsgen.d.ts.map +1 -0
  53. package/dist/server-jsgen.js +446 -0
  54. package/dist/server-render.d.ts +16 -0
  55. package/dist/server-render.d.ts.map +1 -0
  56. package/dist/server-render.js +397 -0
  57. package/dist/server-utils.d.ts +93 -0
  58. package/dist/server-utils.d.ts.map +1 -0
  59. package/dist/server-utils.js +747 -0
  60. package/dist/ssr-store.d.ts +4 -0
  61. package/dist/ssr-store.d.ts.map +1 -0
  62. package/dist/ssr-store.js +29 -0
  63. package/dist/strip-ts.d.ts +25 -0
  64. package/dist/strip-ts.d.ts.map +1 -0
  65. package/dist/strip-ts.js +171 -0
  66. package/dist/tokens.d.ts +50 -0
  67. package/dist/tokens.d.ts.map +1 -0
  68. package/dist/tokens.js +334 -0
  69. package/dist/typecheck.d.ts +19 -0
  70. package/dist/typecheck.d.ts.map +1 -0
  71. package/dist/typecheck.js +365 -0
  72. package/dist/types.d.ts +147 -0
  73. package/dist/types.d.ts.map +1 -0
  74. package/dist/types.js +13 -0
  75. package/dist/vesk-plugin.d.ts +53 -0
  76. package/dist/vesk-plugin.d.ts.map +1 -0
  77. package/dist/vesk-plugin.js +413 -0
  78. package/dist/vsk-imports.d.ts +30 -0
  79. package/dist/vsk-imports.d.ts.map +1 -0
  80. package/dist/vsk-imports.js +141 -0
  81. package/dist/vsk-tsx.d.ts +3 -0
  82. package/dist/vsk-tsx.d.ts.map +1 -0
  83. package/dist/vsk-tsx.js +604 -0
  84. package/package.json +52 -0
@@ -0,0 +1,6 @@
1
+ import type { VeskConfig, VeskPlugin, VeskSecurity } from '@vesk/compiler/src/types';
2
+ export declare function preset(name: string, overrides?: VeskSecurity): VeskSecurity;
3
+ export declare function definePlugin<P extends VeskPlugin>(plugin: P): P;
4
+ export declare function defineConfig(config: VeskConfig): VeskConfig;
5
+ export declare function validateConfig(config: VeskConfig): VeskConfig;
6
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAsB,MAAM,0BAA0B,CAAC;AA0BzG,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,YAAiB,GAAG,YAAY,CAY/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,CAqB3D;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAkC7D"}
package/dist/config.js ADDED
@@ -0,0 +1,106 @@
1
+ import { VeskError } from '@vesk/compiler/src/errors';
2
+ const SECURITY_PRESETS = {
3
+ strict: {
4
+ autoEscape: true,
5
+ csrf: true,
6
+ xFrameOptions: 'DENY',
7
+ hsts: 'max-age=31536000; includeSubDomains',
8
+ referrerPolicy: 'strict-origin-when-cross-origin',
9
+ contentSecurityPolicy: "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; frame-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'",
10
+ redactLogs: true,
11
+ },
12
+ minimal: {
13
+ autoEscape: true,
14
+ csrf: false,
15
+ xFrameOptions: 'SAMEORIGIN',
16
+ hsts: false,
17
+ referrerPolicy: false,
18
+ contentSecurityPolicy: false,
19
+ redactLogs: false,
20
+ },
21
+ };
22
+ SECURITY_PRESETS['default'] = { ...SECURITY_PRESETS['strict'] };
23
+ export function preset(name, overrides = {}) {
24
+ const presets = {
25
+ production: { ...SECURITY_PRESETS['strict'] },
26
+ development: {
27
+ ...SECURITY_PRESETS['strict'],
28
+ contentSecurityPolicy: false,
29
+ },
30
+ };
31
+ if (!presets[name]) {
32
+ throw VeskError.configError(`Unknown security preset: "${name}".`, Object.keys(presets));
33
+ }
34
+ return { ...presets[name], ...overrides };
35
+ }
36
+ export function definePlugin(plugin) {
37
+ if (!plugin || typeof plugin !== 'object') {
38
+ throw new Error('[vesk] definePlugin() requires a plugin object.');
39
+ }
40
+ if (typeof plugin.name !== 'string' || !plugin.name) {
41
+ throw new Error('[vesk] definePlugin() requires a `name` property.');
42
+ }
43
+ return plugin;
44
+ }
45
+ export function defineConfig(config) {
46
+ if (config.security === false || config.security === 'off') {
47
+ config.security = {};
48
+ }
49
+ else if (typeof config.security === 'string') {
50
+ const p = SECURITY_PRESETS[config.security];
51
+ if (!p)
52
+ throw VeskError.configError(`Unknown security preset string: "${config.security}".`, Object.keys(SECURITY_PRESETS));
53
+ config.security = { ...p };
54
+ }
55
+ else if (typeof config.security === 'function') {
56
+ config.security = config.security(preset);
57
+ }
58
+ if (!config.security)
59
+ config.security = {};
60
+ const sec = config.security;
61
+ if (sec.autoEscape !== false)
62
+ sec.autoEscape = true;
63
+ if (sec.csrf !== false)
64
+ sec.csrf = true;
65
+ if (sec.xFrameOptions === undefined)
66
+ sec.xFrameOptions = 'DENY';
67
+ if (sec.contentSecurityPolicy === undefined)
68
+ sec.contentSecurityPolicy =
69
+ "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; frame-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'";
70
+ if (sec.redactLogs !== false)
71
+ sec.redactLogs = true;
72
+ if (config.routeDataCache === undefined)
73
+ config.routeDataCache = 0;
74
+ return config;
75
+ }
76
+ export function validateConfig(config) {
77
+ if (!config.plugins)
78
+ return config;
79
+ if (!Array.isArray(config.plugins)) {
80
+ throw new Error('[vesk] config.plugins must be an array.');
81
+ }
82
+ for (const plugin of config.plugins) {
83
+ if (!plugin || typeof plugin !== 'object') {
84
+ throw new Error('[vesk] Each plugin must be an object returned by a plugin factory (e.g. tailwindcss()).');
85
+ }
86
+ if (typeof plugin.name !== 'string' || !plugin.name) {
87
+ throw new Error('[vesk] A plugin is missing a `name` property. Use a Vesk-native ' +
88
+ 'plugin factory (e.g. tailwindcss({...}) from @vesk/plugin-tailwind) ' +
89
+ 'that returns a plugin object with the correct shape.');
90
+ }
91
+ const hasKnownHook = typeof plugin.onCSS === 'function' ||
92
+ typeof plugin.onFileWatch === 'function' ||
93
+ typeof plugin.onTransformJS === 'function' ||
94
+ typeof plugin.onBuildStart === 'function' ||
95
+ typeof plugin.onBuildEnd === 'function' ||
96
+ typeof plugin.onRequest === 'function' ||
97
+ (plugin.provides && typeof plugin.provides === 'object' && Object.keys(plugin.provides).length > 0);
98
+ if (!hasKnownHook) {
99
+ throw new Error(`[vesk] Plugin "${plugin.name}" implements none of the recognized ` +
100
+ 'hooks (onCSS, onFileWatch, onTransformJS, onBuildStart, onBuildEnd, onRequest) ' +
101
+ 'or provides — it will never be called. Check the plugin package version, or see ' +
102
+ '/docu/cli/plugin-api.md for the current hook contract.');
103
+ }
104
+ }
105
+ return config;
106
+ }
@@ -0,0 +1,33 @@
1
+ export declare function levenshtein(a: string, b: string): number;
2
+ export declare function didYouMean(name: string, candidates: string[], maxDistance?: number): string | null;
3
+ export interface VeskErrorOptions {
4
+ file?: string;
5
+ line?: number;
6
+ column?: number;
7
+ suggestions?: string[];
8
+ nextSteps?: string[];
9
+ tip?: string;
10
+ code?: string;
11
+ [key: string]: unknown;
12
+ }
13
+ export declare class VeskError extends Error {
14
+ name: string;
15
+ file: string;
16
+ line: number;
17
+ column: number;
18
+ suggestions: string[];
19
+ nextSteps: string[];
20
+ tip: string;
21
+ code?: string;
22
+ constructor(message: string, opts?: VeskErrorOptions);
23
+ static notFound(name: string, candidates?: string[], context?: VeskErrorOptions): VeskError;
24
+ static classDecl(context?: VeskErrorOptions): VeskError;
25
+ static serverBlockInClient(compName: string, context?: VeskErrorOptions): VeskError;
26
+ static clientBlockInServer(compName: string, context?: VeskErrorOptions): VeskError;
27
+ static componentNotFound(name: string, available?: string[], context?: VeskErrorOptions): VeskError;
28
+ static configError(msg: string, validOptions?: string[], context?: VeskErrorOptions): VeskError;
29
+ static asyncChildInSyncParent(parentName: string, childName: string, context?: VeskErrorOptions): VeskError;
30
+ toString(): string;
31
+ toJSON(): Record<string, unknown>;
32
+ }
33
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAoBxD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,WAAW,GAAE,MAAU,GAAG,MAAM,GAAG,IAAI,CAWrG;AAWD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAeD,qBAAa,SAAU,SAAQ,KAAK;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;gBAEF,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,gBAAqB;IAYxD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,GAAE,MAAM,EAAO,EAAE,OAAO,GAAE,gBAAqB,GAAG,SAAS;IA6BnG,MAAM,CAAC,SAAS,CAAC,OAAO,GAAE,gBAAqB,GAAG,SAAS;IAmB3D,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,SAAS;IAkBvF,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,SAAS;IAkBvF,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,MAAM,EAAO,EAAE,OAAO,GAAE,gBAAqB,GAAG,SAAS;IAO3G,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,GAAE,MAAM,EAAO,EAAE,OAAO,GAAE,gBAAqB,GAAG,SAAS;IAWvG,MAAM,CAAC,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,SAAS;IAkB/G,QAAQ,IAAI,MAAM;IAgBlB,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAclC"}
package/dist/errors.js ADDED
@@ -0,0 +1,210 @@
1
+ export function levenshtein(a, b) {
2
+ const an = a.length;
3
+ const bn = b.length;
4
+ const matrix = [];
5
+ for (let i = 0; i <= bn; i++)
6
+ matrix[i] = [i];
7
+ for (let j = 0; j <= an; j++)
8
+ matrix[0][j] = j;
9
+ for (let i = 1; i <= bn; i++) {
10
+ for (let j = 1; j <= an; j++) {
11
+ if (b[i - 1] === a[j - 1]) {
12
+ matrix[i][j] = matrix[i - 1][j - 1];
13
+ }
14
+ else {
15
+ matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, matrix[i][j - 1] + 1, matrix[i - 1][j] + 1);
16
+ }
17
+ }
18
+ }
19
+ return matrix[bn][an];
20
+ }
21
+ export function didYouMean(name, candidates, maxDistance = 3) {
22
+ let best = null;
23
+ let bestDist = Infinity;
24
+ for (const c of candidates) {
25
+ const dist = levenshtein(name.toLowerCase(), c.toLowerCase());
26
+ if (dist < bestDist && dist <= maxDistance) {
27
+ best = c;
28
+ bestDist = dist;
29
+ }
30
+ }
31
+ return best;
32
+ }
33
+ function extractLineColumn(message) {
34
+ const lineMatch = message.match(/(?:line|at\s+line)\s*(\d+)/i);
35
+ const colMatch = message.match(/(?:column|col)\s*(\d+)/i);
36
+ return {
37
+ line: lineMatch ? parseInt(lineMatch[1]) : 0,
38
+ column: colMatch ? parseInt(colMatch[1]) : 0,
39
+ };
40
+ }
41
+ const VESK_BUILTINS = [
42
+ 'useFetch', 'useRouter', 'useParams', 'usePathname', 'useSearchParams',
43
+ 'useNavigate', 'useHead', 'useTitle',
44
+ 'Form', 'Field', 'Link', 'NavLink', 'Outlet',
45
+ 'Image', 'Portal',
46
+ 'Experiment',
47
+ 'required', 'email', 'minLength', 'maxLength', 'pattern', 'custom',
48
+ 'track', 'get', 'set', 'derived', 'effect', 'batch', 'untrack',
49
+ 'cookies', 'headers', 'locals',
50
+ 'VeskResponse', 'VeskRequest', 'ServerRequest', 'ServerResponse',
51
+ 'redirect', 'permanentRedirect', 'notFound',
52
+ ];
53
+ export class VeskError extends Error {
54
+ name;
55
+ file;
56
+ line;
57
+ column;
58
+ suggestions;
59
+ nextSteps;
60
+ tip;
61
+ code;
62
+ constructor(message, opts = {}) {
63
+ super(message);
64
+ this.name = 'VeskError';
65
+ this.file = opts.file || '';
66
+ this.line = opts.line || 0;
67
+ this.column = opts.column || 0;
68
+ this.suggestions = opts.suggestions || [];
69
+ this.nextSteps = opts.nextSteps || [];
70
+ this.tip = opts.tip || '';
71
+ if (opts.code !== undefined)
72
+ this.code = opts.code;
73
+ }
74
+ static notFound(name, candidates = [], context = {}) {
75
+ const allCandidates = [...new Set([...candidates, ...VESK_BUILTINS])];
76
+ const suggestion = didYouMean(name, allCandidates);
77
+ const isBuiltin = VESK_BUILTINS.includes(name);
78
+ const msg = suggestion
79
+ ? `"${name}" is not defined. Did you mean "${suggestion}"?`
80
+ : `"${name}" is not defined.`;
81
+ const nextSteps = [];
82
+ if (suggestion && suggestion !== name) {
83
+ nextSteps.push(`Replace "${name}" with "${suggestion}".`);
84
+ }
85
+ if (isBuiltin) {
86
+ nextSteps.push(`"${name}" is a Vesk built-in — it is auto-imported when you use it as a component tag (<${name}>) or call it as a function (${name}()). If you are using it in an unusual way, add an explicit import: import { ${name} } from "@vesk/runtime".`);
87
+ }
88
+ else {
89
+ nextSteps.push('Check that the name is spelled correctly, imported, or declared in this file.');
90
+ if (suggestion && suggestion !== name) {
91
+ nextSteps.push(`If you meant "${suggestion}", fix the spelling.`);
92
+ }
93
+ }
94
+ return new VeskError(msg, {
95
+ ...context,
96
+ suggestions: [name, ...allCandidates.slice(0, 8)],
97
+ nextSteps,
98
+ tip: isBuiltin
99
+ ? `"${name}" is a Vesk built-in. Use it directly — no manual import needed.`
100
+ : '',
101
+ });
102
+ }
103
+ static classDecl(context = {}) {
104
+ return new VeskError('class declarations are not supported inside Vesk components.', {
105
+ ...context,
106
+ suggestions: [
107
+ 'Use a plain object: const obj = { ... };',
108
+ 'Use a factory function: function create() { return { ... }; }',
109
+ 'Import from an external module: import { Klass } from "./lib.js";',
110
+ ],
111
+ nextSteps: [
112
+ 'Replace the class with a plain object, factory function, or import from a .ts/.js file.',
113
+ 'Vesk components compile to reactive blocks — classes cannot participate in signal tracking.',
114
+ ],
115
+ tip: 'Use plain objects for data and factory functions for constructors inside .vsk files.',
116
+ });
117
+ }
118
+ static serverBlockInClient(compName, context = {}) {
119
+ return new VeskError(`{#server} block found in client island "${compName}". Client islands render on both server and client, so {#server} blocks have no effect.`, {
120
+ ...context,
121
+ suggestions: [
122
+ `Remove the {#server} block from "${compName}".`,
123
+ `Or remove the \`client\` keyword from "${compName}" declaration.`,
124
+ ],
125
+ nextSteps: [
126
+ `Remove {#server}...{/server} from component "${compName}".`,
127
+ `Or change \`component ${compName} client\` to \`component ${compName}\` (no client), then wrap interactive parts in {#client} blocks.`,
128
+ ],
129
+ tip: 'A `client` component renders everywhere — {#server} would never execute. Either drop `client` or drop the {#server} block.',
130
+ });
131
+ }
132
+ static clientBlockInServer(compName, context = {}) {
133
+ return new VeskError(`{#client} block found in component "${compName}", but this component is not a client island. {#client} blocks are only allowed inside components declared with the \`client\` keyword.`, {
134
+ ...context,
135
+ suggestions: [
136
+ `Add \`client\`: \`component ${compName} client { ... }\``,
137
+ `Or remove the {#client}...{/client} block.`,
138
+ ],
139
+ nextSteps: [
140
+ `Add the \`client\` keyword: \`component ${compName} client { ... }\``,
141
+ `Or remove the {#client} block if the content can be server-rendered.`,
142
+ ],
143
+ tip: '{#client} blocks mark interactive content that needs JavaScript. Without `client`, the component is server-only and {#client} blocks are meaningless.',
144
+ });
145
+ }
146
+ static componentNotFound(name, available = [], context = {}) {
147
+ return VeskError.notFound(name, available, {
148
+ ...context,
149
+ tip: `Components in Vesk must be declared with the \`component\` keyword. If "${name}" is defined in another file, import it: \`import { ${name} } from "./path";\``,
150
+ });
151
+ }
152
+ static configError(msg, validOptions = [], context = {}) {
153
+ return new VeskError(msg, {
154
+ ...context,
155
+ suggestions: validOptions.length ? [`Valid options: ${validOptions.join(', ')}`] : [],
156
+ nextSteps: [
157
+ 'Check your vesk.config file for typos.',
158
+ ...(validOptions.length ? [`Use one of: ${validOptions.join(', ')}`] : []),
159
+ ],
160
+ });
161
+ }
162
+ static asyncChildInSyncParent(parentName, childName, context = {}) {
163
+ return new VeskError(`Component "${parentName}" renders "<${childName} />", but "<${childName} />" is async and "${parentName}" is not declared async.`, {
164
+ ...context,
165
+ suggestions: [
166
+ `Declare the parent async: \`async component ${parentName} ...\``,
167
+ ],
168
+ nextSteps: [
169
+ `Change \`component ${parentName} ...\` to \`async component ${parentName} ...\`.`,
170
+ `Every component that renders "<${childName} />" (directly or transitively) must itself be \`async component\`.`,
171
+ `Layouts are exempt — a layout that renders {props.children} does not need \`async\`.`,
172
+ ],
173
+ tip: `A component that renders an async component must itself be async so the renderer can await it before serializing the HTML. Async components also include components that call \`useFetch\`.`,
174
+ });
175
+ }
176
+ toString() {
177
+ let out = `[vesk] ${this.message}`;
178
+ if (this.file)
179
+ out += `\n File: ${this.file}${this.line ? `:${this.line}` : ''}`;
180
+ if (this.code)
181
+ out += `\n\n${this.code}`;
182
+ if (this.suggestions.length) {
183
+ out += '\n\n Suggestions:';
184
+ for (const s of this.suggestions.slice(0, 4))
185
+ out += `\n • ${s}`;
186
+ }
187
+ if (this.nextSteps.length) {
188
+ out += '\n\n Next steps:';
189
+ for (const s of this.nextSteps.slice(0, 4))
190
+ out += `\n • ${s}`;
191
+ }
192
+ if (this.tip)
193
+ out += `\n\n Tip: ${this.tip}`;
194
+ return out;
195
+ }
196
+ toJSON() {
197
+ return {
198
+ name: this.name,
199
+ message: this.message,
200
+ file: this.file,
201
+ line: this.line,
202
+ column: this.column,
203
+ code: this.code,
204
+ suggestions: this.suggestions,
205
+ nextSteps: this.nextSteps,
206
+ tip: this.tip,
207
+ stack: this.stack,
208
+ };
209
+ }
210
+ }
@@ -0,0 +1,16 @@
1
+ export { parse, createBaseParser } from '@vesk/compiler/src/parser';
2
+ export { VeskParserPlugin } from '@vesk/compiler/src/vesk-plugin';
3
+ export { generateIR } from '@vesk/compiler/src/ir-generator';
4
+ export { render } from '@vesk/compiler/src/server-codegen';
5
+ export { compileClient, compile } from '@vesk/compiler/src/client-codegen';
6
+ export { IRRoot, ComponentIR, StaticNode, TextNode, DynamicBinding, OpaqueDynamicRegion, MapRegion, ComponentCall, Expression, } from '@vesk/compiler/src/ir';
7
+ export type { IRNode } from '@vesk/compiler/src/ir';
8
+ export type { VeskPlugin } from '@vesk/compiler/src/types';
9
+ export type { MiddlewareContext } from '@vesk/compiler/src/types';
10
+ export type { VeskConfig } from '@vesk/compiler/src/types';
11
+ export type { VeskSecurity } from '@vesk/compiler/src/types';
12
+ export type { VeskCors } from '@vesk/compiler/src/types';
13
+ export type { VeskRateLimit } from '@vesk/compiler/src/types';
14
+ export { defineConfig, validateConfig, preset, definePlugin } from '@vesk/compiler/src/config';
15
+ export { scanRoutes, scanComponents, collectSources, matchUrl } from '@vesk/compiler/src/router';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,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,0BAA0B,CAAC;AAC3D,YAAY,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,YAAY,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export { parse, createBaseParser } from '@vesk/compiler/src/parser';
2
+ export { VeskParserPlugin } from '@vesk/compiler/src/vesk-plugin';
3
+ export { generateIR } from '@vesk/compiler/src/ir-generator';
4
+ export { render } from '@vesk/compiler/src/server-codegen';
5
+ export { compileClient, compile } from '@vesk/compiler/src/client-codegen';
6
+ export { IRRoot, ComponentIR, StaticNode, TextNode, DynamicBinding, OpaqueDynamicRegion, MapRegion, ComponentCall, Expression, } from '@vesk/compiler/src/ir';
7
+ export { defineConfig, validateConfig, preset, definePlugin } from '@vesk/compiler/src/config';
8
+ export { scanRoutes, scanComponents, collectSources, matchUrl } from '@vesk/compiler/src/router';
@@ -0,0 +1,10 @@
1
+ import { IRRoot } from '@vesk/compiler/src/ir';
2
+ export declare function getPropsType(params: Array<{
3
+ type: string;
4
+ name?: string;
5
+ left?: any;
6
+ typeAnnotation?: any;
7
+ properties?: any[];
8
+ }> | undefined | null, source: string): string | null;
9
+ export declare function generateIR(ast: any, source: string): IRRoot;
10
+ //# sourceMappingURL=ir-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ir-generator.d.ts","sourceRoot":"","sources":["../src/ir-generator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EAoBP,MAAM,uBAAuB,CAAC;AA+I/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;AAylBD,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAwN3D"}