@nola-lang/compiler 0.1.0-alpha.0
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/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/ambient-stub.d.ts +8 -0
- package/dist/ambient-stub.d.ts.map +1 -0
- package/dist/ambient-stub.js +71 -0
- package/dist/ambient-stub.js.map +1 -0
- package/dist/companion-name.d.ts +22 -0
- package/dist/companion-name.d.ts.map +1 -0
- package/dist/companion-name.js +48 -0
- package/dist/companion-name.js.map +1 -0
- package/dist/companion.d.ts +22 -0
- package/dist/companion.d.ts.map +1 -0
- package/dist/companion.js +90 -0
- package/dist/companion.js.map +1 -0
- package/dist/compile.d.ts +3 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +33 -0
- package/dist/compile.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/lower/Lowerer.d.ts +56 -0
- package/dist/lower/Lowerer.d.ts.map +1 -0
- package/dist/lower/Lowerer.js +353 -0
- package/dist/lower/Lowerer.js.map +1 -0
- package/dist/lower/index.d.ts +8 -0
- package/dist/lower/index.d.ts.map +1 -0
- package/dist/lower/index.js +5 -0
- package/dist/lower/index.js.map +1 -0
- package/dist/lower/lower.d.ts +2 -0
- package/dist/lower/lower.d.ts.map +1 -0
- package/dist/lower/lower.js +319 -0
- package/dist/lower/lower.js.map +1 -0
- package/dist/lower/templates.d.ts +61 -0
- package/dist/lower/templates.d.ts.map +1 -0
- package/dist/lower/templates.js +70 -0
- package/dist/lower/templates.js.map +1 -0
- package/dist/lower.d.ts +4 -0
- package/dist/lower.d.ts.map +1 -0
- package/dist/lower.js +322 -0
- package/dist/lower.js.map +1 -0
- package/dist/path.d.ts +16 -0
- package/dist/path.d.ts.map +1 -0
- package/dist/path.js +28 -0
- package/dist/path.js.map +1 -0
- package/dist/schema-expr.d.ts +61 -0
- package/dist/schema-expr.d.ts.map +1 -0
- package/dist/schema-expr.js +211 -0
- package/dist/schema-expr.js.map +1 -0
- package/dist/schema.d.ts +16 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +152 -0
- package/dist/schema.js.map +1 -0
- package/dist/spans.d.ts +73 -0
- package/dist/spans.d.ts.map +1 -0
- package/dist/spans.js +169 -0
- package/dist/spans.js.map +1 -0
- package/dist/static-config.d.ts +15 -0
- package/dist/static-config.d.ts.map +1 -0
- package/dist/static-config.js +93 -0
- package/dist/static-config.js.map +1 -0
- package/dist/types.d.ts +37 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +45 -0
package/dist/lower.js
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
import { Codes, children, } from "@nola-lang/ast";
|
|
2
|
+
import { NOLA_EMIT } from "@nola-lang/core";
|
|
3
|
+
import { companionSpecifierFor } from "./companion-name.js";
|
|
4
|
+
import { collectTypeRegistry } from "./schema.js";
|
|
5
|
+
import { accessorNameFor, buildAccessorPlan, collectTypeImports, deriveTypeExpr, } from "./schema-expr.js";
|
|
6
|
+
import { SpanRecorder } from "./spans.js";
|
|
7
|
+
/**
|
|
8
|
+
* Appended at EOF so no original line/column shifts: ESM hoists the import, and a
|
|
9
|
+
* `function` declaration hoists with its value. `__nola_file_ctx` must NOT be a
|
|
10
|
+
* `const`/`let` — an infer function called during its own module's evaluation
|
|
11
|
+
* (`const eager = go();`) reads it before the declaration runs and hits the TDZ.
|
|
12
|
+
* It holds no state: `__nola.context.file` is memoized by path in the runtime.
|
|
13
|
+
*/
|
|
14
|
+
const RUNTIME_IMPORT = (displayFile) => `
|
|
15
|
+
import { __nola } from "nola-lang/runtime";
|
|
16
|
+
__nola.useRuntime(${NOLA_EMIT});
|
|
17
|
+
function __nola_file_ctx() { return __nola.context.file(${JSON.stringify(displayFile)}); }
|
|
18
|
+
`;
|
|
19
|
+
export function lower(source, file, ast, displayFile = file) {
|
|
20
|
+
return new Lowerer(source, file, ast, displayFile).run();
|
|
21
|
+
}
|
|
22
|
+
class Lowerer {
|
|
23
|
+
s;
|
|
24
|
+
source;
|
|
25
|
+
/** Absolute on-disk path. Diagnostics and source maps use this. */
|
|
26
|
+
file;
|
|
27
|
+
/** Project-root-relative path. Only this reaches the emitted code. */
|
|
28
|
+
displayFile;
|
|
29
|
+
ast;
|
|
30
|
+
diagnostics = [];
|
|
31
|
+
meta = { nolaFunctions: [] };
|
|
32
|
+
usedRuntime = false;
|
|
33
|
+
/** named types needing a __nola_type_<Name> accessor in the appendix, in first-use order */
|
|
34
|
+
typeAccessors = new Map();
|
|
35
|
+
/** local binding name -> companion import emitted in the appendix */
|
|
36
|
+
companionImports = new Map();
|
|
37
|
+
/** shared derivation context (registry, imports, display file, bare ref names) */
|
|
38
|
+
deriveCtx;
|
|
39
|
+
constructor(source, file, ast, displayFile) {
|
|
40
|
+
this.s = new SpanRecorder(source);
|
|
41
|
+
this.source = source;
|
|
42
|
+
this.file = file;
|
|
43
|
+
this.displayFile = displayFile;
|
|
44
|
+
this.ast = ast;
|
|
45
|
+
this.deriveCtx = {
|
|
46
|
+
source,
|
|
47
|
+
registry: collectTypeRegistry(ast),
|
|
48
|
+
imports: collectTypeImports(ast),
|
|
49
|
+
importerDisplayFile: displayFile,
|
|
50
|
+
refQualifier: "",
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
run() {
|
|
54
|
+
this.visit(this.ast, false, true);
|
|
55
|
+
if (this.usedRuntime) {
|
|
56
|
+
// Accessors are `function` declarations for the same TDZ reason as
|
|
57
|
+
// __nola_file_ctx: a top-level extractor evaluates during module
|
|
58
|
+
// evaluation, before any appendix statement runs.
|
|
59
|
+
let appendix = RUNTIME_IMPORT(this.displayFile);
|
|
60
|
+
for (const [name, expr] of this.typeAccessors) {
|
|
61
|
+
// The explicit return type is required: a self-recursive accessor has no
|
|
62
|
+
// inferable return type (TS7023 under strict). The inline import type is
|
|
63
|
+
// erased by esbuild and resolves against both the stub and the runtime.
|
|
64
|
+
appendix += `function ${accessorNameFor(name)}(): import("nola-lang/runtime").InferType<unknown> { return ${expr}; }\n`;
|
|
65
|
+
}
|
|
66
|
+
// Companion imports hoist like any ESM import; the binding is a companion
|
|
67
|
+
// accessor function, initialized before module evaluation (cycle-safe).
|
|
68
|
+
for (const [local, imp] of this.companionImports) {
|
|
69
|
+
appendix += `import { ${imp.importedName}$type as ${accessorNameFor(local)} } from ${JSON.stringify(companionSpecifierFor(imp.specifier))};\n`;
|
|
70
|
+
}
|
|
71
|
+
this.s.appendix(appendix);
|
|
72
|
+
}
|
|
73
|
+
const map = this.s.generateMap({ source: this.file, hires: true, includeContent: true });
|
|
74
|
+
const spans = this.s.finalize(this.source.length);
|
|
75
|
+
const companions = [
|
|
76
|
+
...new Set([...this.companionImports.values()].map((i) => companionSpecifierFor(i.specifier))),
|
|
77
|
+
].sort();
|
|
78
|
+
return {
|
|
79
|
+
code: this.s.toString(),
|
|
80
|
+
map,
|
|
81
|
+
diagnostics: this.diagnostics,
|
|
82
|
+
meta: { ...this.meta, spans, companions, mode: "lowered" },
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
diag(code, message, node) {
|
|
86
|
+
this.diagnostics.push({ code, message, file: this.file, start: node.start, end: node.end, loc: node.loc });
|
|
87
|
+
}
|
|
88
|
+
/** Fold a derivation's transitive needs (accessors, companion imports) into the state. */
|
|
89
|
+
absorbPlan(companions, plan) {
|
|
90
|
+
for (const [local, imp] of companions)
|
|
91
|
+
this.companionImports.set(local, imp);
|
|
92
|
+
for (const [name, expr] of plan.accessors) {
|
|
93
|
+
if (!this.typeAccessors.has(name))
|
|
94
|
+
this.typeAccessors.set(name, expr);
|
|
95
|
+
}
|
|
96
|
+
for (const [local, imp] of plan.companions)
|
|
97
|
+
this.companionImports.set(local, imp);
|
|
98
|
+
}
|
|
99
|
+
absorbTypeNeeds(refs, companions) {
|
|
100
|
+
const plan = buildAccessorPlan(refs, this.deriveCtx);
|
|
101
|
+
this.absorbPlan(companions, plan);
|
|
102
|
+
for (const e of plan.errors)
|
|
103
|
+
this.diag(Codes.UnsupportedIntentType, e.message, e.node);
|
|
104
|
+
}
|
|
105
|
+
// inNolaFnBody: directly inside a nola function body.
|
|
106
|
+
// topLevel: current node is a direct child of Program (or an export wrapper).
|
|
107
|
+
visit(node, inNolaFnBody, topLevel) {
|
|
108
|
+
switch (node.type) {
|
|
109
|
+
case "NolaExtractExpression": {
|
|
110
|
+
const extract = node;
|
|
111
|
+
// Tolerant-parse placeholder: diagnostic already recorded; leave the
|
|
112
|
+
// span's original bytes untouched.
|
|
113
|
+
if (extract.nolaError || !extract.quasi)
|
|
114
|
+
return;
|
|
115
|
+
this.lowerExtract(extract, inNolaFnBody);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
case "NolaAskExpression": {
|
|
119
|
+
const ask = node;
|
|
120
|
+
if (!inNolaFnBody) {
|
|
121
|
+
this.diag(Codes.AskOutsideNolaFunction, "`ask` is only allowed directly inside an infer function body.", node);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
// Overwriting up to the operand also removes an `with <alias>` span;
|
|
125
|
+
// the alias re-enters as ask's third argument.
|
|
126
|
+
this.s.overwrite(node.start, ask.argument.start, "await __nola.ask(");
|
|
127
|
+
const provider = ask.provider ? `, ${JSON.stringify(ask.provider.name)}` : "";
|
|
128
|
+
// appendRight: extract-lowering suffixes use appendLeft at the same
|
|
129
|
+
// position and must land BEFORE this closing paren.
|
|
130
|
+
this.s.appendRight(node.end, `, __ctx${provider})`);
|
|
131
|
+
this.usedRuntime = true;
|
|
132
|
+
}
|
|
133
|
+
this.visit(ask.argument, inNolaFnBody, false);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
case "FunctionDeclaration": {
|
|
137
|
+
const fn = node;
|
|
138
|
+
if (!fn.nolaInfer) {
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
if (!topLevel) {
|
|
142
|
+
// TODO: to discuss - wew should not have this limitation
|
|
143
|
+
this.diag(Codes.NolaFnNotTopLevel, "infer functions must be declared at module top level.", node);
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
this.lowerInferFunction(fn);
|
|
147
|
+
if (fn.body) {
|
|
148
|
+
for (const child of children(fn.body)) {
|
|
149
|
+
this.visit(child, true, false);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
case "CallExpression": {
|
|
155
|
+
const call = node;
|
|
156
|
+
if (call.callee.type === "TaggedTemplateExpression") {
|
|
157
|
+
this.lowerCallIntent(call, inNolaFnBody);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
default:
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
const isFunctionScope = node.type === "FunctionDeclaration" ||
|
|
166
|
+
node.type === "FunctionExpression" ||
|
|
167
|
+
node.type === "ArrowFunctionExpression" ||
|
|
168
|
+
node.type === "ObjectMethod" ||
|
|
169
|
+
node.type === "ClassMethod";
|
|
170
|
+
const nextTopLevel = node.type === "File" ||
|
|
171
|
+
node.type === "Program" ||
|
|
172
|
+
(topLevel && (node.type === "ExportNamedDeclaration" || node.type === "ExportDefaultDeclaration"));
|
|
173
|
+
for (const child of children(node)) {
|
|
174
|
+
this.visit(child, isFunctionScope ? false : inNolaFnBody, nextTopLevel);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
lowerInferFunction(fn) {
|
|
178
|
+
const infer = fn.nolaInfer;
|
|
179
|
+
if (!infer)
|
|
180
|
+
return;
|
|
181
|
+
const name = fn.id?.name ?? "anonymous";
|
|
182
|
+
// Removes `infer ` including trailing whitespace up to `function`.
|
|
183
|
+
this.s.remove(infer.start, infer.end);
|
|
184
|
+
const instruction = fn.nolaMarker?.instruction ?? "";
|
|
185
|
+
if (fn.nolaMarker)
|
|
186
|
+
this.s.remove(fn.nolaMarker.start, fn.nolaMarker.end);
|
|
187
|
+
const body = fn.body;
|
|
188
|
+
if (!body)
|
|
189
|
+
return;
|
|
190
|
+
// Harvest params into FunctionScopeInit args: every named param contributes
|
|
191
|
+
// name (+ InferType when derivable); only `..`-prefixed params contribute
|
|
192
|
+
// the live value. Underivable/unannotated types are silently omitted — an
|
|
193
|
+
// UnsupportedType here would fail tsc-clean, and a missing arg type must
|
|
194
|
+
// not block compilation the way it deliberately does for extractors.
|
|
195
|
+
const argEntries = [];
|
|
196
|
+
for (const p of (fn.params ?? [])) {
|
|
197
|
+
if (p.nolaContextual)
|
|
198
|
+
this.s.remove(p.nolaContextual.start, p.nolaContextual.end);
|
|
199
|
+
const target = p.type === "AssignmentPattern" ? p.left : p;
|
|
200
|
+
if (target.type !== "Identifier")
|
|
201
|
+
continue; // patterns: parser already diagnosed `..` misuse; nothing to harvest
|
|
202
|
+
const paramName = target.name;
|
|
203
|
+
if (!paramName)
|
|
204
|
+
continue;
|
|
205
|
+
let typeField = "";
|
|
206
|
+
const tsAnn = target.typeAnnotation?.typeAnnotation;
|
|
207
|
+
if (tsAnn) {
|
|
208
|
+
const derived = deriveTypeExpr(tsAnn, this.deriveCtx);
|
|
209
|
+
if (derived.ok) {
|
|
210
|
+
// ref() derivation is lazy — a named type's body only derives inside
|
|
211
|
+
// the accessor plan, so "derivable" is only known once the plan builds
|
|
212
|
+
// cleanly. On any transitive failure, omit like the shallow case:
|
|
213
|
+
// nothing absorbed, no dangling __nola_type_* ref, no diagnostic.
|
|
214
|
+
const plan = buildAccessorPlan(derived.refs, this.deriveCtx);
|
|
215
|
+
if (plan.errors.length === 0) {
|
|
216
|
+
typeField = `, type: ${derived.expr}`;
|
|
217
|
+
this.absorbPlan(derived.companions, plan);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const ctxField = p.nolaContextual ? `, contextual: true, value: ${paramName}` : "";
|
|
222
|
+
argEntries.push(`{ name: ${JSON.stringify(paramName)}${typeField}${ctxField} }`);
|
|
223
|
+
}
|
|
224
|
+
const argsField = argEntries.length > 0 ? `, args: [${argEntries.join(", ")}]` : "";
|
|
225
|
+
this.s.appendRight(body.start + 1, "\n return __nola.intents.Intent(async (__ctx) => {");
|
|
226
|
+
this.s.appendLeft(body.end - 1, ` }, __nola_file_ctx().func({ fn: ${JSON.stringify(name)}, instruction: ${JSON.stringify(instruction)}${argsField} }));\n`);
|
|
227
|
+
this.meta.nolaFunctions.push(name);
|
|
228
|
+
this.usedRuntime = true;
|
|
229
|
+
}
|
|
230
|
+
lowerCallIntent(call, inNolaFnBody) {
|
|
231
|
+
const callee = call.callee;
|
|
232
|
+
const { tag, quasi } = callee;
|
|
233
|
+
if (quasi.expressions.length > 0) {
|
|
234
|
+
this.diag(Codes.SubstitutionInCallMarker,
|
|
235
|
+
// biome-ignore lint/suspicious/noTemplateCurlyInString: literal ${...} in a diagnostic message
|
|
236
|
+
"`${...}` substitutions are not allowed in a call-intent marker.", quasi.expressions[0]);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
for (const arg of call.arguments)
|
|
240
|
+
this.checkCallIntentArg(arg);
|
|
241
|
+
const instruction = quasi.quasis.map((q) => q.value.cooked ?? q.value.raw).join("");
|
|
242
|
+
const tagText = this.source.slice(tag.start, tag.end);
|
|
243
|
+
const simple = tag.type === "Identifier" || tag.type === "MemberExpression";
|
|
244
|
+
const typeText = simple ? `<Awaited<ReturnType<typeof ${tagText}>>>` : "";
|
|
245
|
+
const { line, column } = call.loc.start;
|
|
246
|
+
this.s.appendLeft(call.start, `__nola.intents.FunctionCallingIntent${typeText}({ fn: `);
|
|
247
|
+
const argsStart = call.arguments.length > 0 ? call.arguments[0].start : call.end - 1;
|
|
248
|
+
this.s.overwrite(tag.end, argsStart, `, name: ${JSON.stringify(tagText)}, instruction: ${JSON.stringify(instruction)}, ` +
|
|
249
|
+
`loc: ${JSON.stringify(`${line}:${column + 1}`)}, args: [`);
|
|
250
|
+
this.s.overwrite(call.end - 1, call.end, "] })");
|
|
251
|
+
this.usedRuntime = true;
|
|
252
|
+
for (const arg of call.arguments)
|
|
253
|
+
this.visit(arg, inNolaFnBody, false);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* NOLA2004 for untyped extractors in slot positions: direct args and anywhere
|
|
257
|
+
* inside plain object/array literal nesting (mirrors the runtime slot walk).
|
|
258
|
+
*/
|
|
259
|
+
checkCallIntentArg(arg) {
|
|
260
|
+
if (arg.type === "NolaExtractExpression") {
|
|
261
|
+
if (!arg.typeArgs) {
|
|
262
|
+
this.diag(Codes.UntypedCallIntentArg, "an extractor used as a call-intent argument must have an explicit <T>.", arg);
|
|
263
|
+
}
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (arg.type === "ObjectExpression") {
|
|
267
|
+
for (const prop of arg.properties) {
|
|
268
|
+
if (prop.type === "ObjectProperty")
|
|
269
|
+
this.checkCallIntentArg(prop.value);
|
|
270
|
+
}
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (arg.type === "ArrayExpression") {
|
|
274
|
+
for (const el of arg.elements) {
|
|
275
|
+
if (el)
|
|
276
|
+
this.checkCallIntentArg(el);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
lowerExtract(node, inNolaFnBody) {
|
|
281
|
+
const quasi = node.quasi;
|
|
282
|
+
if (!quasi)
|
|
283
|
+
return;
|
|
284
|
+
let typeExpr = "__nola.types.string()";
|
|
285
|
+
let typeText = "<any>";
|
|
286
|
+
if (node.typeArgs) {
|
|
287
|
+
const t = node.typeArgs.params[0];
|
|
288
|
+
if (t) {
|
|
289
|
+
typeText = `<${this.source.slice(t.start, t.end)}>`;
|
|
290
|
+
const derived = deriveTypeExpr(t, this.deriveCtx);
|
|
291
|
+
if (derived.ok) {
|
|
292
|
+
typeExpr = derived.expr;
|
|
293
|
+
this.absorbTypeNeeds(derived.refs, derived.companions);
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
this.diag(Codes.UnsupportedIntentType, derived.message, derived.node);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
const { line, column } = node.loc.start;
|
|
301
|
+
// Prefix up to (but not including) the template preserves the template's
|
|
302
|
+
// original bytes; each ${expr} gets __nola.fmt(...) wrapped around it.
|
|
303
|
+
this.s.overwrite(node.start, quasi.start, `__nola.intents.ExtractIntent${typeText}({ instruction: `);
|
|
304
|
+
for (const expr of quasi.expressions) {
|
|
305
|
+
this.s.appendLeft(expr.start, "__nola.fmt(");
|
|
306
|
+
this.s.appendLeft(expr.end, ")");
|
|
307
|
+
}
|
|
308
|
+
const suffix = `, type: ${typeExpr}, loc: ${JSON.stringify(`${line}:${column + 1}`)} })`;
|
|
309
|
+
if (node.end > quasi.end) {
|
|
310
|
+
// Replaces the <T> span (which follows the template).
|
|
311
|
+
this.s.overwrite(quasi.end, node.end, suffix);
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
// appendLeft: must precede an enclosing ask's appendRight ")".
|
|
315
|
+
this.s.appendLeft(node.end, suffix);
|
|
316
|
+
}
|
|
317
|
+
this.usedRuntime = true;
|
|
318
|
+
for (const expr of quasi.expressions)
|
|
319
|
+
this.visit(expr, inNolaFnBody, false);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
//# sourceMappingURL=lower.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lower.js","sourceRoot":"","sources":["../src/lower.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,EACL,QAAQ,GAST,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAEL,eAAe,EACf,iBAAiB,EAEj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AAa,CAAC,CAAC;YAC7C,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACnC,CAAC;QACD,MAAM,MAAM,GAAG,WAAW,QAAQ,UAAU,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC;QACzF,IAAI,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;YACzB,sDAAsD;YACtD,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAChD,CAAC;aAAM,CAAC;YACN,+DAA+D;YAC/D,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,WAAW;YAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC;IAC9E,CAAC;CACF"}
|
package/dist/path.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The path baked into lowered output (`file:` fields, `__nola.context.file(...)`).
|
|
3
|
+
*
|
|
4
|
+
* Absolute paths would leak the build machine's layout into `dist/` and make builds
|
|
5
|
+
* non-reproducible across checkouts, so emit a posix-separated path relative to the
|
|
6
|
+
* project root instead. Nothing at run time resolves this string — it is a memo key
|
|
7
|
+
* for `fileContext` and a label in errors, logs, and receipts.
|
|
8
|
+
*
|
|
9
|
+
* Falls back to the input when there is no root, or when the file sits outside it
|
|
10
|
+
* (a `../..` chain is no more portable than the absolute path it came from). Callers
|
|
11
|
+
* derive `file` and `sourceRoot` from the same `resolve()`/`fileURLToPath()` pass, so
|
|
12
|
+
* a plain prefix match is enough — no need for `node:path`, which this package (alone
|
|
13
|
+
* among the build-time ones) does not depend on.
|
|
14
|
+
*/
|
|
15
|
+
export declare function displayPathFor(file: string, sourceRoot?: string): string;
|
|
16
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAMxE"}
|
package/dist/path.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Backslashes → posix, and no trailing slash. */
|
|
2
|
+
function toPosix(p) {
|
|
3
|
+
return p.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The path baked into lowered output (`file:` fields, `__nola.context.file(...)`).
|
|
7
|
+
*
|
|
8
|
+
* Absolute paths would leak the build machine's layout into `dist/` and make builds
|
|
9
|
+
* non-reproducible across checkouts, so emit a posix-separated path relative to the
|
|
10
|
+
* project root instead. Nothing at run time resolves this string — it is a memo key
|
|
11
|
+
* for `fileContext` and a label in errors, logs, and receipts.
|
|
12
|
+
*
|
|
13
|
+
* Falls back to the input when there is no root, or when the file sits outside it
|
|
14
|
+
* (a `../..` chain is no more portable than the absolute path it came from). Callers
|
|
15
|
+
* derive `file` and `sourceRoot` from the same `resolve()`/`fileURLToPath()` pass, so
|
|
16
|
+
* a plain prefix match is enough — no need for `node:path`, which this package (alone
|
|
17
|
+
* among the build-time ones) does not depend on.
|
|
18
|
+
*/
|
|
19
|
+
export function displayPathFor(file, sourceRoot) {
|
|
20
|
+
if (!sourceRoot)
|
|
21
|
+
return file;
|
|
22
|
+
const root = toPosix(sourceRoot);
|
|
23
|
+
if (root === "")
|
|
24
|
+
return file;
|
|
25
|
+
const posix = file.replace(/\\/g, "/");
|
|
26
|
+
return posix.startsWith(`${root}/`) ? posix.slice(root.length + 1) : file;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=path.js.map
|
package/dist/path.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.js","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,SAAS,OAAO,CAAC,CAAS;IACxB,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,UAAmB;IAC9D,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAC7B,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACjC,IAAI,IAAI,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACvC,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type BaseNode } from "@nola-lang/ast";
|
|
2
|
+
export interface CompanionImport {
|
|
3
|
+
specifier: string;
|
|
4
|
+
importedName: string;
|
|
5
|
+
}
|
|
6
|
+
export interface DeriveContext {
|
|
7
|
+
source: string;
|
|
8
|
+
registry: Map<string, BaseNode>;
|
|
9
|
+
/** local name -> named type/value import it came from */
|
|
10
|
+
imports: Map<string, CompanionImport>;
|
|
11
|
+
importerDisplayFile: string;
|
|
12
|
+
/** "" in lowered .tsi files; "<moduleId>#" inside companions */
|
|
13
|
+
refQualifier: string;
|
|
14
|
+
/**
|
|
15
|
+
* Prune mode (harvest seam only): an object member whose type fails to
|
|
16
|
+
* derive is dropped instead of failing the whole object. An object that
|
|
17
|
+
* prunes to empty still fails upward, so its own parent drops it too.
|
|
18
|
+
*/
|
|
19
|
+
lossy?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Named types known to be underivable even lossily. Grown iteratively by the
|
|
22
|
+
* prune loop in the Lowerer: a reference to a dead name fails (and is then
|
|
23
|
+
* pruned by its enclosing object like any other underivable member).
|
|
24
|
+
*/
|
|
25
|
+
deadRefs?: Set<string>;
|
|
26
|
+
}
|
|
27
|
+
export type TypeExprResult = {
|
|
28
|
+
ok: true;
|
|
29
|
+
expr: string;
|
|
30
|
+
refs: Set<string>;
|
|
31
|
+
companions: Map<string, CompanionImport>;
|
|
32
|
+
} | {
|
|
33
|
+
ok: false;
|
|
34
|
+
message: string;
|
|
35
|
+
node: BaseNode;
|
|
36
|
+
};
|
|
37
|
+
export declare function accessorNameFor(typeName: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Emit-5/6 companion of deriveSchema: same supported surface, but produces a
|
|
40
|
+
* `__nola.types.*` combinator expression instead of inline JSON. Named
|
|
41
|
+
* registry references become ref() calls — which is what makes recursion
|
|
42
|
+
* legal (toJsonSchema resolves cycles to $defs/$ref at run time) — and named
|
|
43
|
+
* IMPORTS become module-qualified refs bound to companion accessors.
|
|
44
|
+
*/
|
|
45
|
+
export declare function deriveTypeExpr(t: BaseNode, ctx: DeriveContext): TypeExprResult;
|
|
46
|
+
/** All named ImportSpecifier bindings (type or value; default/namespace skipped). */
|
|
47
|
+
export declare function collectTypeImports(ast: BaseNode): Map<string, CompanionImport>;
|
|
48
|
+
export interface AccessorPlan {
|
|
49
|
+
/** local type name -> body expr, in first-use order */
|
|
50
|
+
accessors: Map<string, string>;
|
|
51
|
+
/** local binding name -> companion import */
|
|
52
|
+
companions: Map<string, CompanionImport>;
|
|
53
|
+
errors: Array<{
|
|
54
|
+
name: string;
|
|
55
|
+
message: string;
|
|
56
|
+
node: BaseNode;
|
|
57
|
+
}>;
|
|
58
|
+
}
|
|
59
|
+
/** Transitively derive accessor bodies for named local types (worklist). */
|
|
60
|
+
export declare function buildAccessorPlan(entryRefs: Set<string>, ctx: DeriveContext): AccessorPlan;
|
|
61
|
+
//# sourceMappingURL=schema-expr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-expr.d.ts","sourceRoot":"","sources":["../src/schema-expr.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EAcd,MAAM,gBAAgB,CAAC;AAIxB,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAChC,yDAAyD;IACzD,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACtC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gEAAgE;IAChE,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACxB;AAED,MAAM,MAAM,cAAc,GACtB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CAAE,GACvF;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEnD,wBAAgB,eAAe,CAAC,QAA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