@vesk/compiler 0.2.63 → 0.2.65
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 +59 -7
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +26 -1
- package/dist/server-utils.d.ts +17 -0
- package/dist/server-utils.d.ts.map +1 -1
- package/dist/server-utils.js +50 -14
- 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;
|
|
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;AAsGD,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,CAkFjI;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAWhE;AAED,MAAM,WAAW,QAAS,SAAQ,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;CAAG;AAExD,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;IACjE,MAAM,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,qBAAqB,CAAC,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC,CAAC;CAC/E,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,oBAAoB,EAC7B,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,QAAQ,GAAG,IAAI,EACtB,OAAO,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GAClC,OAAO,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,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
|
@@ -96,6 +96,31 @@ function scanApiDir(rootDir, dir, parentPath) {
|
|
|
96
96
|
}
|
|
97
97
|
return nodes;
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Sibling precedence: root > static > dynamic > catch-all. A literal segment
|
|
101
|
+
* must win over a `[param]` that would otherwise swallow it, so `/users/me`
|
|
102
|
+
* resolves to the static `me` route and not to `/users/:id`. Children arrive
|
|
103
|
+
* in `readdirSync` order (alphabetical, which puts `[id]` before `me`), so the
|
|
104
|
+
* precedence has to be stated here instead of being left to the filesystem.
|
|
105
|
+
* Ties keep their original order.
|
|
106
|
+
*/
|
|
107
|
+
function specificityRank(node) {
|
|
108
|
+
if (node.fullPath === '/')
|
|
109
|
+
return 0;
|
|
110
|
+
if (node.isCatchAll)
|
|
111
|
+
return 3;
|
|
112
|
+
if (node.isDynamic)
|
|
113
|
+
return 2;
|
|
114
|
+
return 1;
|
|
115
|
+
}
|
|
116
|
+
function bySpecificity(nodes) {
|
|
117
|
+
if (nodes.length < 2)
|
|
118
|
+
return nodes;
|
|
119
|
+
return nodes
|
|
120
|
+
.map((node, index) => ({ node, index, rank: specificityRank(node) }))
|
|
121
|
+
.sort((a, b) => (a.rank - b.rank) || (a.index - b.index))
|
|
122
|
+
.map(entry => entry.node);
|
|
123
|
+
}
|
|
99
124
|
export function matchApiUrl(tree, pathname) {
|
|
100
125
|
let normalized = pathname.split('?')[0].split('#')[0];
|
|
101
126
|
// strip a leading /api segment (exact or followed by /) without regex
|
|
@@ -107,31 +132,50 @@ export function matchApiUrl(tree, pathname) {
|
|
|
107
132
|
}
|
|
108
133
|
const parts = normalized.split('/').filter(Boolean);
|
|
109
134
|
const params = {};
|
|
135
|
+
/** Undo params captured by a branch that matched nothing downstream. */
|
|
136
|
+
function restoreParams(snapshot) {
|
|
137
|
+
for (const key of Object.keys(params)) {
|
|
138
|
+
if (!(key in snapshot))
|
|
139
|
+
delete params[key];
|
|
140
|
+
}
|
|
141
|
+
for (const key of Object.keys(snapshot))
|
|
142
|
+
params[key] = snapshot[key];
|
|
143
|
+
}
|
|
110
144
|
function matchNodes(nodes, partIndex) {
|
|
111
|
-
for (const node of nodes) {
|
|
145
|
+
for (const node of bySpecificity(nodes)) {
|
|
146
|
+
// The root node owns no segment of its own, so it is transparent: the
|
|
147
|
+
// same position is matched against its children.
|
|
112
148
|
if (node.fullPath === '/') {
|
|
113
149
|
if (partIndex >= parts.length && node.filePath)
|
|
114
150
|
return node;
|
|
115
151
|
return matchNodes(node.children, partIndex);
|
|
116
152
|
}
|
|
117
|
-
|
|
118
|
-
if (node.filePath)
|
|
119
|
-
return node;
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
const part = parts[partIndex];
|
|
153
|
+
const part = partIndex < parts.length ? parts[partIndex] : undefined;
|
|
123
154
|
if (node.isCatchAll) {
|
|
155
|
+
// `[...rest]` absorbs every remaining segment, including none at all.
|
|
156
|
+
// It only counts as a match when it has a handler to run.
|
|
157
|
+
if (!node.filePath)
|
|
158
|
+
continue;
|
|
124
159
|
const paramName = node.path.startsWith(':') ? node.path.slice(1) : node.path;
|
|
125
160
|
params[paramName] = parts.slice(partIndex).map(decodeURIComponent).join('/');
|
|
126
161
|
return node;
|
|
127
162
|
}
|
|
163
|
+
// Every other node owns exactly one segment, which has to be consumed by
|
|
164
|
+
// the URL. Once the URL is exhausted the node's own segment never
|
|
165
|
+
// matched, so it cannot be the handler — keep looking. Matching here
|
|
166
|
+
// anyway is what let `/api/users` resolve to `/api/users/:id`, handing a
|
|
167
|
+
// directory's collection URL to its dynamic child with no params at all.
|
|
168
|
+
if (part === undefined)
|
|
169
|
+
continue;
|
|
128
170
|
if (node.isDynamic) {
|
|
129
171
|
const paramName = node.path.startsWith(':') ? node.path.slice(1) : node.path;
|
|
130
172
|
params[paramName] = decodeURIComponent(part);
|
|
131
173
|
if (node.children.length > 0) {
|
|
174
|
+
const snapshot = { ...params };
|
|
132
175
|
const result = matchNodes(node.children, partIndex + 1);
|
|
133
176
|
if (result)
|
|
134
177
|
return result;
|
|
178
|
+
restoreParams(snapshot);
|
|
135
179
|
}
|
|
136
180
|
if (node.filePath)
|
|
137
181
|
return node;
|
|
@@ -139,10 +183,18 @@ export function matchApiUrl(tree, pathname) {
|
|
|
139
183
|
continue;
|
|
140
184
|
}
|
|
141
185
|
if (node.path === part) {
|
|
186
|
+
// The URL ends here, so this node is the match: return its own handler
|
|
187
|
+
// instead of descending. Descending first let a `[param]` child swallow
|
|
188
|
+
// a directory's collection URL even though that directory had a
|
|
189
|
+
// `route.ts` of its own.
|
|
190
|
+
if (partIndex + 1 >= parts.length && node.filePath)
|
|
191
|
+
return node;
|
|
142
192
|
if (node.children.length > 0) {
|
|
193
|
+
const snapshot = { ...params };
|
|
143
194
|
const result = matchNodes(node.children, partIndex + 1);
|
|
144
195
|
if (result)
|
|
145
196
|
return result;
|
|
197
|
+
restoreParams(snapshot);
|
|
146
198
|
}
|
|
147
199
|
if (node.filePath)
|
|
148
200
|
return node;
|
package/dist/router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAM1D,MAAM,WAAW,WAAW;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED;;;;;;GAMG;AACH,4DAA4D;AAC5D,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAajD;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAqB3F;AAkDD,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUnE;AAwED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,SAAS,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GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CA2BzE;AA6HD,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBrE;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,GAAE,oBAAyB,GAAG,MAAM,CAoCnG;AA2CD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CA0HhF"}
|
package/dist/router.js
CHANGED
|
@@ -498,6 +498,31 @@ function flattenSources(tree) {
|
|
|
498
498
|
walk(tree);
|
|
499
499
|
return map;
|
|
500
500
|
}
|
|
501
|
+
/**
|
|
502
|
+
* Sibling precedence: groups/root > static > dynamic > catch-all. A literal
|
|
503
|
+
* segment must win over a `[param]` that would otherwise swallow it, so
|
|
504
|
+
* `/users/me` resolves to the static `me` page and not to `/users/:id`. Child
|
|
505
|
+
* order comes from a `localeCompare` of directory names, which puts `[id]`
|
|
506
|
+
* ahead of `me`, so precedence has to be stated here rather than left to the
|
|
507
|
+
* filesystem. Ties keep their original order.
|
|
508
|
+
*/
|
|
509
|
+
function segmentRank(node) {
|
|
510
|
+
if (node.isGroup || node.fullPath === '/')
|
|
511
|
+
return 0;
|
|
512
|
+
if (node.isCatchAll)
|
|
513
|
+
return 3;
|
|
514
|
+
if (node.isDynamic)
|
|
515
|
+
return 2;
|
|
516
|
+
return 1;
|
|
517
|
+
}
|
|
518
|
+
function bySegmentPrecedence(nodes) {
|
|
519
|
+
if (nodes.length < 2)
|
|
520
|
+
return nodes;
|
|
521
|
+
return nodes
|
|
522
|
+
.map((node, index) => ({ node, index, rank: segmentRank(node) }))
|
|
523
|
+
.sort((a, b) => (a.rank - b.rank) || (a.index - b.index))
|
|
524
|
+
.map(entry => entry.node);
|
|
525
|
+
}
|
|
501
526
|
export function matchUrl(tree, pathname) {
|
|
502
527
|
const parts = pathname.split('/').filter(Boolean);
|
|
503
528
|
const chain = [];
|
|
@@ -513,7 +538,7 @@ export function matchUrl(tree, pathname) {
|
|
|
513
538
|
chain.push(node);
|
|
514
539
|
}
|
|
515
540
|
function matchNodes(nodes, partIndex) {
|
|
516
|
-
for (const node of nodes) {
|
|
541
|
+
for (const node of bySegmentPrecedence(nodes)) {
|
|
517
542
|
if (node.isGroup) {
|
|
518
543
|
// The group goes into the chain BEFORE its matched child, so the chain
|
|
519
544
|
// reads root -> group -> page, exactly like the client's
|
package/dist/server-utils.d.ts
CHANGED
|
@@ -116,6 +116,23 @@ export declare function indent(code: string, level?: number): string;
|
|
|
116
116
|
export declare function tryEvalExpr(raw: string, props: Record<string, unknown>, locals?: Record<string, unknown>): unknown;
|
|
117
117
|
export declare function childrenToHTML(nodes: IRNode[]): string;
|
|
118
118
|
export declare function extractTopLevelNames(topLevelCode: string[]): string[];
|
|
119
|
+
/**
|
|
120
|
+
* Every value binding a file pulls from the runtime, as `{ imported, local }`
|
|
121
|
+
* pairs.
|
|
122
|
+
*
|
|
123
|
+
* `local` is what the compiled body references; `imported` is what the runtime
|
|
124
|
+
* module actually exports. They differ whenever the import is aliased
|
|
125
|
+
* (`import { createStore as makeStore }`), and conflating the two is why an
|
|
126
|
+
* aliased runtime import silently became `undefined` during SSR: the binding
|
|
127
|
+
* was looked up on the runtime module by its LOCAL name.
|
|
128
|
+
*
|
|
129
|
+
* Default/namespace imports have no exported name of their own, so they are
|
|
130
|
+
* reported with `imported: '*'` for the caller to handle.
|
|
131
|
+
*/
|
|
132
|
+
export declare function extractRuntimeBindingPairs(importStrs: string[]): Array<{
|
|
133
|
+
imported: string;
|
|
134
|
+
local: string;
|
|
135
|
+
}>;
|
|
119
136
|
export declare function extractRuntimeNames(importStrs: string[]): string[];
|
|
120
137
|
/**
|
|
121
138
|
* Emits the statement that binds a component's decl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E,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAuBhF;AAWD,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CA2D9F;AAED,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CASxE;AAED,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAgBjJ"}
|
package/dist/server-utils.js
CHANGED
|
@@ -1016,40 +1016,69 @@ function tryParseTopLevel(code) {
|
|
|
1016
1016
|
return null;
|
|
1017
1017
|
}
|
|
1018
1018
|
}
|
|
1019
|
-
|
|
1020
|
-
|
|
1019
|
+
/**
|
|
1020
|
+
* Every value binding a file pulls from the runtime, as `{ imported, local }`
|
|
1021
|
+
* pairs.
|
|
1022
|
+
*
|
|
1023
|
+
* `local` is what the compiled body references; `imported` is what the runtime
|
|
1024
|
+
* module actually exports. They differ whenever the import is aliased
|
|
1025
|
+
* (`import { createStore as makeStore }`), and conflating the two is why an
|
|
1026
|
+
* aliased runtime import silently became `undefined` during SSR: the binding
|
|
1027
|
+
* was looked up on the runtime module by its LOCAL name.
|
|
1028
|
+
*
|
|
1029
|
+
* Default/namespace imports have no exported name of their own, so they are
|
|
1030
|
+
* reported with `imported: '*'` for the caller to handle.
|
|
1031
|
+
*/
|
|
1032
|
+
export function extractRuntimeBindingPairs(importStrs) {
|
|
1033
|
+
const pairs = [];
|
|
1034
|
+
const isRuntimeTarget = (src) => src === '@vesk/runtime' || src === '@vesk/reactivity' || src.startsWith('@vesk/runtime/');
|
|
1021
1035
|
for (const imp of importStrs) {
|
|
1022
1036
|
const ast = tryParseImport(imp);
|
|
1023
1037
|
if (ast) {
|
|
1024
1038
|
for (const stmt of ast.body) {
|
|
1025
1039
|
if (stmt.type !== 'ImportDeclaration')
|
|
1026
1040
|
continue;
|
|
1041
|
+
// `import type { X } from '...'` marks the STATEMENT, not its
|
|
1042
|
+
// specifiers, so filtering on `spec.importKind` alone let every
|
|
1043
|
+
// type-only import leak a live runtime binding.
|
|
1044
|
+
if (stmt.importKind === 'type')
|
|
1045
|
+
continue;
|
|
1027
1046
|
const src = stmt.source?.value;
|
|
1028
|
-
|
|
1047
|
+
// Subpaths (`@vesk/runtime/store`) are real imports too. They were
|
|
1048
|
+
// skipped here, so nothing a `.vsk` file pulled from a subpath ever
|
|
1049
|
+
// reached the SSR scope — while the CLIENT collector
|
|
1050
|
+
// (`extractRuntimeImportNames` in client-bundle.ts) has always accepted
|
|
1051
|
+
// them. That mismatch is why a store-importing page rendered on the
|
|
1052
|
+
// server with `createStore` undefined.
|
|
1053
|
+
if (typeof src !== 'string' || !isRuntimeTarget(src))
|
|
1029
1054
|
continue;
|
|
1030
1055
|
for (const spec of stmt.specifiers || []) {
|
|
1031
1056
|
if (spec.importKind === 'type')
|
|
1032
1057
|
continue;
|
|
1033
1058
|
if (spec.type === 'ImportSpecifier') {
|
|
1034
|
-
const
|
|
1035
|
-
|
|
1036
|
-
|
|
1059
|
+
const local = spec.local?.name;
|
|
1060
|
+
const imported = spec.imported?.name;
|
|
1061
|
+
if (local)
|
|
1062
|
+
pairs.push({ imported: imported || local, local });
|
|
1037
1063
|
}
|
|
1038
1064
|
else if (spec.type === 'ImportDefaultSpecifier' || spec.type === 'ImportNamespaceSpecifier') {
|
|
1039
1065
|
if (spec.local?.name)
|
|
1040
|
-
|
|
1066
|
+
pairs.push({ imported: '*', local: spec.local.name });
|
|
1041
1067
|
}
|
|
1042
1068
|
}
|
|
1043
1069
|
}
|
|
1044
1070
|
continue;
|
|
1045
1071
|
}
|
|
1046
1072
|
const target = importModuleTarget(imp);
|
|
1047
|
-
if (target
|
|
1073
|
+
if (target && isRuntimeTarget(target)) {
|
|
1048
1074
|
for (const name of extractImportNames(imp))
|
|
1049
|
-
|
|
1075
|
+
pairs.push({ imported: name, local: name });
|
|
1050
1076
|
}
|
|
1051
1077
|
}
|
|
1052
|
-
return
|
|
1078
|
+
return pairs;
|
|
1079
|
+
}
|
|
1080
|
+
export function extractRuntimeNames(importStrs) {
|
|
1081
|
+
return extractRuntimeBindingPairs(importStrs).map(p => p.local);
|
|
1053
1082
|
}
|
|
1054
1083
|
function tryParseImport(code) {
|
|
1055
1084
|
try {
|
|
@@ -1118,7 +1147,7 @@ export function setRuntimeModule(mod) {
|
|
|
1118
1147
|
__cachedRuntimeModule = mod;
|
|
1119
1148
|
}
|
|
1120
1149
|
export function loadRuntimeImports(importStrs) {
|
|
1121
|
-
const
|
|
1150
|
+
const pairs = extractRuntimeBindingPairs(importStrs);
|
|
1122
1151
|
const mod = __cachedRuntimeModule || __defaultRuntimeModule;
|
|
1123
1152
|
if (mod) {
|
|
1124
1153
|
const result = {};
|
|
@@ -1130,9 +1159,16 @@ export function loadRuntimeImports(importStrs) {
|
|
|
1130
1159
|
if (name in mod)
|
|
1131
1160
|
result[name] = mod[name];
|
|
1132
1161
|
}
|
|
1133
|
-
for (const
|
|
1134
|
-
|
|
1135
|
-
|
|
1162
|
+
for (const { imported, local } of pairs) {
|
|
1163
|
+
// Bind the LOCAL name to the value the runtime exports under the
|
|
1164
|
+
// IMPORTED name. Keying by local name alone silently produced
|
|
1165
|
+
// `undefined` for every aliased import.
|
|
1166
|
+
if (imported === '*') {
|
|
1167
|
+
result[local] = mod;
|
|
1168
|
+
}
|
|
1169
|
+
else if (imported in mod) {
|
|
1170
|
+
result[local] = mod[imported];
|
|
1171
|
+
}
|
|
1136
1172
|
}
|
|
1137
1173
|
return result;
|
|
1138
1174
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vesk/compiler",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.65",
|
|
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.65",
|
|
24
24
|
"acorn": "^8.15.0",
|
|
25
25
|
"esrap": "^2.3.0",
|
|
26
26
|
"is-reference": "^3.0.0",
|