halfcode-compiler.xnl 0.1.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.
- package/README.md +19 -0
- package/dist/application-assembly.d.ts +2 -0
- package/dist/application-assembly.js +2 -0
- package/dist/authoring-runtime.d.ts +2 -0
- package/dist/authoring-runtime.js +2 -0
- package/dist/contract-schema.d.ts +45 -0
- package/dist/contract-schema.js +297 -0
- package/dist/dist-Bkv7YeVi.js +491 -0
- package/dist/index-Ba5Gt9iW.d.ts +67 -0
- package/dist/index-D-cBhQVw.d.ts +38 -0
- package/dist/index-Dg0imcjf.d.ts +31 -0
- package/dist/index-DuRG4TQo.d.ts +12 -0
- package/dist/index-FdimP_SL.d.ts +236 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/kind-definition.d.ts +14 -0
- package/dist/kind-definition.js +8 -0
- package/dist/resource-core.d.ts +2 -0
- package/dist/resource-core.js +2 -0
- package/dist/resource-mapping.d.ts +43 -0
- package/dist/resource-mapping.js +2 -0
- package/dist/resource-projection.d.ts +2 -0
- package/dist/resource-projection.js +8 -0
- package/dist/skill-capsule.d.ts +2 -0
- package/dist/skill-capsule.js +2 -0
- package/dist/src-B87eJQat.js +39 -0
- package/dist/src-BlKlpg0J.js +180 -0
- package/dist/src-COEMEqZw.js +431 -0
- package/dist/src-DEuFHizY.js +561 -0
- package/dist/src-Dv8bfFUo.js +607 -0
- package/dist/testing.d.ts +30 -0
- package/dist/testing.js +57 -0
- package/package.json +74 -0
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
//#region ../../node_modules/.bun/xnl-core@0.1.12/node_modules/xnl-core/dist/index.js
|
|
2
|
+
function positionToLineColumn(input, index) {
|
|
3
|
+
let line = 1;
|
|
4
|
+
let column = 1;
|
|
5
|
+
for (let i = 0; i < index && i < input.length; i++) if (input[i] === "\n") {
|
|
6
|
+
line += 1;
|
|
7
|
+
column = 1;
|
|
8
|
+
} else column += 1;
|
|
9
|
+
return {
|
|
10
|
+
line,
|
|
11
|
+
column
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
var XnlParseError = class extends Error {
|
|
15
|
+
constructor(code, message, input, position) {
|
|
16
|
+
const { line, column } = positionToLineColumn(input, position);
|
|
17
|
+
super(`${message} (at ${line}:${column})`);
|
|
18
|
+
this.code = code;
|
|
19
|
+
this.position = position;
|
|
20
|
+
this.line = line;
|
|
21
|
+
this.column = column;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
function parseXnl(input, options = {}) {
|
|
25
|
+
const warnings = [];
|
|
26
|
+
return {
|
|
27
|
+
nodes: parseNodesFromString(input, warnings, options),
|
|
28
|
+
warnings
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function parseNodesFromString(input, warnings, options = {}) {
|
|
32
|
+
const state = {
|
|
33
|
+
input,
|
|
34
|
+
pos: 0,
|
|
35
|
+
length: input.length,
|
|
36
|
+
warnings,
|
|
37
|
+
textBlockStyle: options.textBlockStyle ?? false
|
|
38
|
+
};
|
|
39
|
+
const nodes = [];
|
|
40
|
+
skipWhitespaceAndComments(state);
|
|
41
|
+
while (!eof(state)) {
|
|
42
|
+
nodes.push(parseNode(state));
|
|
43
|
+
skipWhitespaceAndComments(state);
|
|
44
|
+
}
|
|
45
|
+
return nodes;
|
|
46
|
+
}
|
|
47
|
+
function parseNode(state) {
|
|
48
|
+
consumeChar(state, "<", "UNEXPECTED_TOKEN", "Expected '<' to start a node");
|
|
49
|
+
const tag = readTagName(state);
|
|
50
|
+
skipWhitespaceAndComments(state);
|
|
51
|
+
const id = parseOptionalId(state);
|
|
52
|
+
const metadata = parseMetadata(state);
|
|
53
|
+
let attributes;
|
|
54
|
+
let body;
|
|
55
|
+
let extend;
|
|
56
|
+
let text;
|
|
57
|
+
let textMarker;
|
|
58
|
+
skipWhitespaceAndComments(state);
|
|
59
|
+
if (consumeIf(state, "?")) {
|
|
60
|
+
({text, textMarker} = parseTextBody(state, tag));
|
|
61
|
+
return {
|
|
62
|
+
kind: "TextElement",
|
|
63
|
+
tag,
|
|
64
|
+
id,
|
|
65
|
+
metadata,
|
|
66
|
+
attributes,
|
|
67
|
+
text,
|
|
68
|
+
textMarker
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
while (true) {
|
|
72
|
+
if (lookAhead(state, ">")) {
|
|
73
|
+
state.pos += 1;
|
|
74
|
+
return {
|
|
75
|
+
kind: "DataElement",
|
|
76
|
+
tag,
|
|
77
|
+
id,
|
|
78
|
+
metadata,
|
|
79
|
+
attributes,
|
|
80
|
+
body,
|
|
81
|
+
extend
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (lookAhead(state, "?")) {
|
|
85
|
+
state.pos += 1;
|
|
86
|
+
if (body || extend) throw error(state, "INVALID_CONTENT", `Text block not allowed with array/extend sections in <${tag}>`);
|
|
87
|
+
({text, textMarker} = parseTextBody(state, tag));
|
|
88
|
+
return {
|
|
89
|
+
kind: "TextElement",
|
|
90
|
+
tag,
|
|
91
|
+
id,
|
|
92
|
+
metadata,
|
|
93
|
+
attributes,
|
|
94
|
+
text,
|
|
95
|
+
textMarker
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (lookAhead(state, "{")) {
|
|
99
|
+
if (attributes) throw error(state, "INVALID_CONTENT", "Multiple attribute blocks are not allowed");
|
|
100
|
+
attributes = parseAttributeBlock(state, tag);
|
|
101
|
+
skipWhitespaceAndComments(state);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
if (lookAhead(state, "[")) {
|
|
105
|
+
if (text) throw error(state, "INVALID_CONTENT", `Text block cannot include array block in <${tag}>`);
|
|
106
|
+
if (body) throw error(state, "INVALID_CONTENT", "Multiple array blocks are not allowed");
|
|
107
|
+
body = parseArrayBody(state, tag);
|
|
108
|
+
skipWhitespaceAndComments(state);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (lookAhead(state, "(")) {
|
|
112
|
+
if (text) throw error(state, "INVALID_CONTENT", `Text block cannot include extend block in <${tag}>`);
|
|
113
|
+
if (extend) throw error(state, "INVALID_CONTENT", "Multiple extend blocks are not allowed");
|
|
114
|
+
extend = parseExtendBody(state, tag);
|
|
115
|
+
skipWhitespaceAndComments(state);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (eof(state)) throw error(state, "UNEXPECTED_EOF", "Unexpected end of input");
|
|
119
|
+
throw error(state, "UNEXPECTED_TOKEN", `Unexpected token '${peek(state)}' while parsing node <${tag}>`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function parseMetadata(state) {
|
|
123
|
+
const attrs = {};
|
|
124
|
+
while (true) {
|
|
125
|
+
skipWhitespaceAndComments(state);
|
|
126
|
+
if (lookAhead(state, "{") || lookAhead(state, "[") || lookAhead(state, "(") || lookAhead(state, "?") || lookAhead(state, ">")) break;
|
|
127
|
+
if (eof(state)) throw error(state, "UNEXPECTED_EOF", "Unexpected end while reading metadata");
|
|
128
|
+
const key = readKey(state, "Expected metadata key");
|
|
129
|
+
skipWhitespaceAndComments(state);
|
|
130
|
+
consumeChar(state, "=", "UNEXPECTED_TOKEN", "Expected '=' after metadata key");
|
|
131
|
+
skipWhitespaceAndComments(state);
|
|
132
|
+
attrs[key] = parseValueNode(state);
|
|
133
|
+
}
|
|
134
|
+
return attrs;
|
|
135
|
+
}
|
|
136
|
+
function parseAttributeBlock(state, name) {
|
|
137
|
+
consumeChar(state, "{", "UNEXPECTED_TOKEN", "Expected '{' to start attribute block");
|
|
138
|
+
const attrs = {};
|
|
139
|
+
while (true) {
|
|
140
|
+
skipWhitespaceAndComments(state);
|
|
141
|
+
if (consumeIf(state, "}")) return attrs;
|
|
142
|
+
if (eof(state)) throw error(state, "UNEXPECTED_EOF", `Missing closing '}' for attributes in <${name}>`);
|
|
143
|
+
const key = readKey(state, "Expected key in attribute block");
|
|
144
|
+
skipWhitespaceAndComments(state);
|
|
145
|
+
consumeChar(state, "=", "UNEXPECTED_TOKEN", "Expected '=' after key in attribute block");
|
|
146
|
+
skipWhitespaceAndComments(state);
|
|
147
|
+
attrs[key] = parseValueNode(state);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function parseArrayBody(state, name) {
|
|
151
|
+
consumeChar(state, "[", "UNEXPECTED_TOKEN", "Expected '[' to start array block");
|
|
152
|
+
const items = [];
|
|
153
|
+
while (true) {
|
|
154
|
+
skipWhitespaceAndComments(state);
|
|
155
|
+
if (consumeIf(state, "]")) return items;
|
|
156
|
+
if (eof(state)) throw error(state, "UNEXPECTED_EOF", `Missing closing ']' for array in <${name}>`);
|
|
157
|
+
if (lookAhead(state, "<")) items.push(parseNode(state));
|
|
158
|
+
else items.push(parseValueNode(state));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function parseExtendBody(state, name) {
|
|
162
|
+
consumeChar(state, "(", "UNEXPECTED_TOKEN", "Expected '(' to start extend block");
|
|
163
|
+
const children = {};
|
|
164
|
+
const order = [];
|
|
165
|
+
while (true) {
|
|
166
|
+
skipWhitespaceAndComments(state);
|
|
167
|
+
if (consumeIf(state, ")")) return {
|
|
168
|
+
children,
|
|
169
|
+
order
|
|
170
|
+
};
|
|
171
|
+
if (eof(state)) throw error(state, "UNEXPECTED_EOF", `Missing closing ')' for extend in <${name}>`);
|
|
172
|
+
if (!lookAhead(state, "<")) throw error(state, "INVALID_CONTENT", `Extend block inside <${name}> must contain child nodes`);
|
|
173
|
+
mergeChild(children, order, parseNode(state), name, state.warnings);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function parseOptionalId(state) {
|
|
177
|
+
if (!consumeIf(state, "#")) return void 0;
|
|
178
|
+
const word = parseWordLiteral(state);
|
|
179
|
+
skipWhitespaceAndComments(state);
|
|
180
|
+
return word;
|
|
181
|
+
}
|
|
182
|
+
function parseTextBody(state, name) {
|
|
183
|
+
const marker = readOptionalMarker(state);
|
|
184
|
+
consumeChar(state, ">", "UNEXPECTED_TOKEN", "Expected '>' after text marker");
|
|
185
|
+
const start = state.pos;
|
|
186
|
+
const expectedMarker = marker ?? "";
|
|
187
|
+
let searchPos = start;
|
|
188
|
+
let firstMismatchedCloser;
|
|
189
|
+
let firstMalformedCloser;
|
|
190
|
+
while (true) {
|
|
191
|
+
const idx = state.input.indexOf("</?", searchPos);
|
|
192
|
+
if (idx === -1) {
|
|
193
|
+
if (firstMismatchedCloser) {
|
|
194
|
+
state.pos = firstMismatchedCloser.pos;
|
|
195
|
+
throw error(state, "MISMATCHED_TAG", `Mismatched text marker for <${name}>: expected '${expectedMarker}' but found '${firstMismatchedCloser.foundMarker}'`);
|
|
196
|
+
}
|
|
197
|
+
if (firstMalformedCloser) {
|
|
198
|
+
state.pos = firstMalformedCloser.pos;
|
|
199
|
+
throw error(state, "UNEXPECTED_TOKEN", `Invalid closing text tag for <${name}>; expected '>' after marker '${firstMalformedCloser.foundMarker}'`);
|
|
200
|
+
}
|
|
201
|
+
throw error(state, "MISMATCHED_TAG", `Missing closing text tag </?${expectedMarker}> for <${name}>`);
|
|
202
|
+
}
|
|
203
|
+
const markerStart = idx + 3;
|
|
204
|
+
let i = markerStart;
|
|
205
|
+
while (i < state.length && isIdentifierChar(state.input[i])) i++;
|
|
206
|
+
const foundMarker = state.input.slice(markerStart, i);
|
|
207
|
+
if (state.input[i] !== ">") {
|
|
208
|
+
firstMalformedCloser ?? (firstMalformedCloser = {
|
|
209
|
+
pos: idx,
|
|
210
|
+
foundMarker
|
|
211
|
+
});
|
|
212
|
+
searchPos = markerStart;
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
if (expectedMarker !== foundMarker) {
|
|
216
|
+
firstMismatchedCloser ?? (firstMismatchedCloser = {
|
|
217
|
+
pos: idx,
|
|
218
|
+
foundMarker
|
|
219
|
+
});
|
|
220
|
+
searchPos = i + 1;
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
const closingIndent = indentationBefore(state.input, idx);
|
|
224
|
+
let content = stripComments(dedentContent(state.input.slice(start, idx), closingIndent));
|
|
225
|
+
if (state.textBlockStyle && content.endsWith("\n")) content = content.slice(0, -1);
|
|
226
|
+
state.pos = i + 1;
|
|
227
|
+
return {
|
|
228
|
+
text: content,
|
|
229
|
+
textMarker: marker ?? void 0
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
function mergeChild(children, order, node, parentName, warnings) {
|
|
234
|
+
if (children[node.tag]) {
|
|
235
|
+
warnings.push({
|
|
236
|
+
code: "DUPLICATE_CHILD",
|
|
237
|
+
message: `Duplicate child '${node.tag}' inside <${parentName} ( ... )> (later node overwrote earlier)`,
|
|
238
|
+
parentName,
|
|
239
|
+
childName: node.tag
|
|
240
|
+
});
|
|
241
|
+
const idx = order.indexOf(node.tag);
|
|
242
|
+
if (idx !== -1) order.splice(idx, 1);
|
|
243
|
+
}
|
|
244
|
+
children[node.tag] = node;
|
|
245
|
+
order.push(node.tag);
|
|
246
|
+
}
|
|
247
|
+
function parseValueNode(state) {
|
|
248
|
+
const ch = state.input[state.pos];
|
|
249
|
+
if (ch === "<") return parseNode(state);
|
|
250
|
+
if (ch === "{") return parseObjectLiteral(state);
|
|
251
|
+
if (ch === "[") return parseArrayLiteral(state);
|
|
252
|
+
if (ch === "'" || ch === "\"") return parseStringLiteral(state);
|
|
253
|
+
if (startsWithNumber(state)) return parseNumberLiteral(state);
|
|
254
|
+
if (startsWithBoolean(state)) return parseBooleanLiteral(state);
|
|
255
|
+
if (startsWithNull(state)) return parseNullLiteral(state);
|
|
256
|
+
if (isIdentifierStart(ch)) return parseWordLiteral(state);
|
|
257
|
+
throw error(state, "INVALID_LITERAL", `Unexpected literal starting with '${ch}'`);
|
|
258
|
+
}
|
|
259
|
+
function parseObjectLiteral(state) {
|
|
260
|
+
consumeChar(state, "{", "UNEXPECTED_TOKEN", "Expected '{' to start object literal");
|
|
261
|
+
const entries = {};
|
|
262
|
+
while (true) {
|
|
263
|
+
skipWhitespaceAndComments(state);
|
|
264
|
+
if (consumeIf(state, "}")) break;
|
|
265
|
+
const key = readKey(state, "Expected key in object literal");
|
|
266
|
+
skipWhitespaceAndComments(state);
|
|
267
|
+
consumeChar(state, "=", "UNEXPECTED_TOKEN", "Expected '=' after key in object literal");
|
|
268
|
+
skipWhitespaceAndComments(state);
|
|
269
|
+
entries[key] = parseValueNode(state);
|
|
270
|
+
skipWhitespaceAndComments(state);
|
|
271
|
+
}
|
|
272
|
+
return entries;
|
|
273
|
+
}
|
|
274
|
+
function parseArrayLiteral(state) {
|
|
275
|
+
consumeChar(state, "[", "UNEXPECTED_TOKEN", "Expected '[' to start array literal");
|
|
276
|
+
const items = [];
|
|
277
|
+
while (true) {
|
|
278
|
+
skipWhitespaceAndComments(state);
|
|
279
|
+
if (consumeIf(state, "]")) break;
|
|
280
|
+
items.push(parseValueNode(state));
|
|
281
|
+
skipWhitespaceAndComments(state);
|
|
282
|
+
}
|
|
283
|
+
return items;
|
|
284
|
+
}
|
|
285
|
+
function parseStringLiteral(state) {
|
|
286
|
+
const quote = consume(state);
|
|
287
|
+
let value = "";
|
|
288
|
+
while (!eof(state)) {
|
|
289
|
+
const ch = consume(state);
|
|
290
|
+
if (ch === quote) return value;
|
|
291
|
+
if (ch === "\\") {
|
|
292
|
+
const next = consume(state);
|
|
293
|
+
if (next === "n") value += "\n";
|
|
294
|
+
else if (next === "t") value += " ";
|
|
295
|
+
else if (next === "\"") value += "\"";
|
|
296
|
+
else if (next === "'") value += "'";
|
|
297
|
+
else value += next;
|
|
298
|
+
} else value += ch;
|
|
299
|
+
}
|
|
300
|
+
throw error(state, "UNEXPECTED_EOF", "Unterminated string literal");
|
|
301
|
+
}
|
|
302
|
+
function parseNumberLiteral(state) {
|
|
303
|
+
const start = state.pos;
|
|
304
|
+
if (state.input[state.pos] === "+" || state.input[state.pos] === "-") state.pos++;
|
|
305
|
+
while (isDigit(peek(state))) state.pos++;
|
|
306
|
+
if (peek(state) === ".") {
|
|
307
|
+
state.pos++;
|
|
308
|
+
if (!isDigit(peek(state))) throw error(state, "INVALID_LITERAL", "Invalid float literal");
|
|
309
|
+
while (isDigit(peek(state))) state.pos++;
|
|
310
|
+
}
|
|
311
|
+
if (peek(state) && (peek(state) === "e" || peek(state) === "E")) {
|
|
312
|
+
state.pos++;
|
|
313
|
+
if (peek(state) === "+" || peek(state) === "-") state.pos++;
|
|
314
|
+
if (!isDigit(peek(state))) throw error(state, "INVALID_LITERAL", "Invalid exponent in number");
|
|
315
|
+
while (isDigit(peek(state))) state.pos++;
|
|
316
|
+
}
|
|
317
|
+
const raw = state.input.slice(start, state.pos);
|
|
318
|
+
const value = Number(raw);
|
|
319
|
+
if (Number.isNaN(value)) throw error(state, "INVALID_LITERAL", "Invalid number literal");
|
|
320
|
+
return value;
|
|
321
|
+
}
|
|
322
|
+
function parseBooleanLiteral(state) {
|
|
323
|
+
if (lookAhead(state, "true")) {
|
|
324
|
+
state.pos += 4;
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
if (lookAhead(state, "false")) {
|
|
328
|
+
state.pos += 5;
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
throw error(state, "INVALID_LITERAL", "Invalid boolean literal");
|
|
332
|
+
}
|
|
333
|
+
function parseNullLiteral(state) {
|
|
334
|
+
consumeString(state, "null", "INVALID_LITERAL", "Invalid null literal");
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
function parseWordLiteral(state) {
|
|
338
|
+
const parts = [readIdentifier(state, "Expected identifier literal")];
|
|
339
|
+
while (lookAhead(state, ".")) {
|
|
340
|
+
state.pos += 1;
|
|
341
|
+
const next = readIdentifier(state, "Expected identifier segment after '.'");
|
|
342
|
+
parts.push(next);
|
|
343
|
+
}
|
|
344
|
+
return {
|
|
345
|
+
kind: "Word",
|
|
346
|
+
namespace: parts,
|
|
347
|
+
name: parts.pop()
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function readOptionalMarker(state) {
|
|
351
|
+
if (!isMarkerStart(peek(state))) return void 0;
|
|
352
|
+
return readMarker(state);
|
|
353
|
+
}
|
|
354
|
+
function readMarker(state) {
|
|
355
|
+
const start = state.pos;
|
|
356
|
+
while (!eof(state) && isIdentifierChar(state.input[state.pos])) state.pos++;
|
|
357
|
+
return state.input.slice(start, state.pos);
|
|
358
|
+
}
|
|
359
|
+
function readKey(state, message) {
|
|
360
|
+
const ch = peek(state);
|
|
361
|
+
if (ch === "\"" || ch === "'") return parseStringLiteral(state);
|
|
362
|
+
return readIdentifier(state, message);
|
|
363
|
+
}
|
|
364
|
+
function readTagName(state) {
|
|
365
|
+
const parts = [readIdentifier(state, "Expected node name")];
|
|
366
|
+
while (lookAhead(state, ".")) {
|
|
367
|
+
state.pos += 1;
|
|
368
|
+
parts.push(readIdentifier(state, "Expected tag segment after '.'"));
|
|
369
|
+
}
|
|
370
|
+
return parts.join(".");
|
|
371
|
+
}
|
|
372
|
+
function readIdentifier(state, message) {
|
|
373
|
+
const start = state.pos;
|
|
374
|
+
const first = state.input[state.pos];
|
|
375
|
+
if (!isIdentifierStart(first)) throw error(state, "UNEXPECTED_TOKEN", message);
|
|
376
|
+
state.pos++;
|
|
377
|
+
while (!eof(state) && isIdentifierChar(state.input[state.pos])) state.pos++;
|
|
378
|
+
return state.input.slice(start, state.pos);
|
|
379
|
+
}
|
|
380
|
+
function startsWithNumber(state) {
|
|
381
|
+
const ch = state.input[state.pos];
|
|
382
|
+
if (ch === "+" || ch === "-") {
|
|
383
|
+
const next = peek(state, 1);
|
|
384
|
+
return next !== void 0 && isDigit(next);
|
|
385
|
+
}
|
|
386
|
+
return isDigit(ch);
|
|
387
|
+
}
|
|
388
|
+
function startsWithBoolean(state) {
|
|
389
|
+
return lookAhead(state, "true") || lookAhead(state, "false");
|
|
390
|
+
}
|
|
391
|
+
function startsWithNull(state) {
|
|
392
|
+
return lookAhead(state, "null");
|
|
393
|
+
}
|
|
394
|
+
function consumeIf(state, token) {
|
|
395
|
+
if (lookAhead(state, token)) {
|
|
396
|
+
state.pos += token.length;
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
return false;
|
|
400
|
+
}
|
|
401
|
+
function consumeString(state, token, code, message) {
|
|
402
|
+
if (!lookAhead(state, token)) throw error(state, code, message);
|
|
403
|
+
state.pos += token.length;
|
|
404
|
+
}
|
|
405
|
+
function lookAhead(state, token) {
|
|
406
|
+
return state.input.startsWith(token, state.pos);
|
|
407
|
+
}
|
|
408
|
+
function consumeChar(state, expected, code, message) {
|
|
409
|
+
const ch = consume(state);
|
|
410
|
+
if (ch !== expected) throw error(state, code, message);
|
|
411
|
+
return ch;
|
|
412
|
+
}
|
|
413
|
+
function consume(state) {
|
|
414
|
+
if (eof(state)) throw error(state, "UNEXPECTED_EOF", "Unexpected end of input");
|
|
415
|
+
const ch = state.input[state.pos];
|
|
416
|
+
state.pos += 1;
|
|
417
|
+
return ch;
|
|
418
|
+
}
|
|
419
|
+
function skipWhitespaceAndComments(state) {
|
|
420
|
+
while (!eof(state)) {
|
|
421
|
+
const ch = state.input[state.pos];
|
|
422
|
+
if (isWhitespace(ch)) {
|
|
423
|
+
state.pos++;
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
if (lookAhead(state, "<!--")) {
|
|
427
|
+
skipComment(state);
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
function indentationBefore(input, index) {
|
|
434
|
+
const lastNewline = input.lastIndexOf("\n", index - 1);
|
|
435
|
+
if (lastNewline === -1) return "";
|
|
436
|
+
const indent = input.slice(lastNewline + 1, index);
|
|
437
|
+
return /^[ \t]*$/.test(indent) ? indent : "";
|
|
438
|
+
}
|
|
439
|
+
function dedentContent(content, indent) {
|
|
440
|
+
if (!content.includes("\n") || indent === "") return content;
|
|
441
|
+
const lines = content.split("\n");
|
|
442
|
+
const startIndex = lines[0].length === 0 ? 1 : 0;
|
|
443
|
+
return lines.slice(startIndex).map((line) => {
|
|
444
|
+
let remove = 0;
|
|
445
|
+
while (remove < indent.length && remove < line.length && line[remove] === indent[remove] && (indent[remove] === " " || indent[remove] === " ")) remove++;
|
|
446
|
+
return line.slice(remove);
|
|
447
|
+
}).join("\n");
|
|
448
|
+
}
|
|
449
|
+
function stripComments(content) {
|
|
450
|
+
return content.replace(/<!--[\\s\\S]*?-->/g, "");
|
|
451
|
+
}
|
|
452
|
+
function eof(state) {
|
|
453
|
+
return state.pos >= state.length;
|
|
454
|
+
}
|
|
455
|
+
function peek(state, offset = 0) {
|
|
456
|
+
const idx = state.pos + offset;
|
|
457
|
+
return idx < state.length ? state.input[idx] : void 0;
|
|
458
|
+
}
|
|
459
|
+
function isIdentifierStart(ch) {
|
|
460
|
+
if (!ch) return false;
|
|
461
|
+
return /[A-Za-z_]/.test(ch);
|
|
462
|
+
}
|
|
463
|
+
function isIdentifierChar(ch) {
|
|
464
|
+
if (!ch) return false;
|
|
465
|
+
return /[A-Za-z0-9_-]/.test(ch);
|
|
466
|
+
}
|
|
467
|
+
function isMarkerStart(ch) {
|
|
468
|
+
return isIdentifierStart(ch) || isDigit(ch);
|
|
469
|
+
}
|
|
470
|
+
function isWhitespace(ch) {
|
|
471
|
+
return ch === " " || ch === " " || ch === "\n" || ch === "\r";
|
|
472
|
+
}
|
|
473
|
+
function isDigit(ch) {
|
|
474
|
+
return ch !== void 0 && ch >= "0" && ch <= "9";
|
|
475
|
+
}
|
|
476
|
+
function error(state, code, message) {
|
|
477
|
+
return new XnlParseError(code, message, state.input, state.pos);
|
|
478
|
+
}
|
|
479
|
+
function skipComment(state) {
|
|
480
|
+
if (!lookAhead(state, "<!--")) return;
|
|
481
|
+
const end = state.input.indexOf("-->", state.pos + 4);
|
|
482
|
+
if (end === -1) throw error(state, "UNEXPECTED_EOF", "Unterminated comment");
|
|
483
|
+
state.pos = end + 3;
|
|
484
|
+
}
|
|
485
|
+
function wordToString(word) {
|
|
486
|
+
if (!word) return void 0;
|
|
487
|
+
const str = [...(word.namespace ?? []).filter(Boolean), word.name].filter((p) => p !== void 0 && p !== null).join(".");
|
|
488
|
+
return str.length ? str : void 0;
|
|
489
|
+
}
|
|
490
|
+
//#endregion
|
|
491
|
+
export { wordToString as n, parseXnl as t };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
//#region ../resource-core/src/index.d.ts
|
|
2
|
+
type SourceShape = "single-file" | "directory" | "manifest";
|
|
3
|
+
interface ResourceIdentity {
|
|
4
|
+
kind: string;
|
|
5
|
+
fqn?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
}
|
|
8
|
+
interface ResourceDescriptor extends ResourceIdentity {
|
|
9
|
+
description?: string;
|
|
10
|
+
}
|
|
11
|
+
interface ResourceMetadata {
|
|
12
|
+
apiVersion: string;
|
|
13
|
+
lifecycle?: string;
|
|
14
|
+
version?: string;
|
|
15
|
+
}
|
|
16
|
+
type ResourceScalar = string | number | boolean | null;
|
|
17
|
+
interface ResourceValueList extends ReadonlyArray<ResourceValue> {}
|
|
18
|
+
interface ResourceValueMap extends Readonly<Record<string, ResourceValue>> {}
|
|
19
|
+
type ResourceValue = ResourceScalar | ResourceNode | ResourceValueList | ResourceValueMap;
|
|
20
|
+
interface ResourceNode {
|
|
21
|
+
readonly tag: string;
|
|
22
|
+
readonly resourceId?: string;
|
|
23
|
+
readonly metadata: Readonly<Record<string, ResourceValue>>;
|
|
24
|
+
readonly properties: Readonly<Record<string, ResourceValue>>;
|
|
25
|
+
readonly body: readonly ResourceValue[];
|
|
26
|
+
readonly subdomains: Readonly<Record<string, ResourceNode>>;
|
|
27
|
+
readonly text?: string;
|
|
28
|
+
}
|
|
29
|
+
interface ResourceRecord extends ResourceDescriptor {
|
|
30
|
+
resourceId: string;
|
|
31
|
+
metadata: ResourceMetadata;
|
|
32
|
+
sourceShape: SourceShape;
|
|
33
|
+
logicalPath: string;
|
|
34
|
+
documentUri: string;
|
|
35
|
+
format: "xnl";
|
|
36
|
+
node: ResourceNode;
|
|
37
|
+
}
|
|
38
|
+
interface ResourceRegistry {
|
|
39
|
+
readonly byKind: ReadonlyMap<string, readonly ResourceRecord[]>;
|
|
40
|
+
}
|
|
41
|
+
interface ResourceTree {
|
|
42
|
+
manifest: ResourceRecord;
|
|
43
|
+
registry: ResourceRegistry;
|
|
44
|
+
diagnostics: readonly ResourceDiagnostic[];
|
|
45
|
+
}
|
|
46
|
+
interface ResourceDiagnostic {
|
|
47
|
+
code: string;
|
|
48
|
+
location: string;
|
|
49
|
+
message: string;
|
|
50
|
+
hint?: string;
|
|
51
|
+
}
|
|
52
|
+
interface LoadResourceTreeOptions {
|
|
53
|
+
rootDir: string;
|
|
54
|
+
manifestPath?: string;
|
|
55
|
+
}
|
|
56
|
+
interface ResourceTreeBuildResult {
|
|
57
|
+
diagnostics: ResourceDiagnostic[];
|
|
58
|
+
tree?: ResourceTree;
|
|
59
|
+
}
|
|
60
|
+
declare class ResourceValidationError extends Error {
|
|
61
|
+
readonly diagnostics: readonly ResourceDiagnostic[];
|
|
62
|
+
constructor(diagnostics: readonly ResourceDiagnostic[]);
|
|
63
|
+
}
|
|
64
|
+
declare function loadResourceTree(options: LoadResourceTreeOptions): Promise<ResourceTree>;
|
|
65
|
+
declare function validateResourceTree(options: LoadResourceTreeOptions): Promise<ResourceDiagnostic[]>;
|
|
66
|
+
//#endregion
|
|
67
|
+
export { loadResourceTree as _, ResourceMetadata as a, ResourceRegistry as c, ResourceTreeBuildResult as d, ResourceValidationError as f, SourceShape as g, ResourceValueMap as h, ResourceIdentity as i, ResourceScalar as l, ResourceValueList as m, ResourceDescriptor as n, ResourceNode as o, ResourceValue as p, ResourceDiagnostic as r, ResourceRecord as s, LoadResourceTreeOptions as t, ResourceTree as u, validateResourceTree as v };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { t as ApplicationAssembly } from "./index-FdimP_SL.js";
|
|
2
|
+
import { t as ResourceRegistry } from "./index-DuRG4TQo.js";
|
|
3
|
+
//#region ../compiler-skill/src/index.d.ts
|
|
4
|
+
interface SkillDescriptor {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
instructions?: string;
|
|
8
|
+
}
|
|
9
|
+
interface SkillReference {
|
|
10
|
+
path: string;
|
|
11
|
+
content: string;
|
|
12
|
+
}
|
|
13
|
+
interface CompileSkillCapsuleInput {
|
|
14
|
+
skill: SkillDescriptor;
|
|
15
|
+
registry?: ResourceRegistry;
|
|
16
|
+
references?: readonly SkillReference[];
|
|
17
|
+
outputDir: string;
|
|
18
|
+
}
|
|
19
|
+
interface SkillCapsulePlan {
|
|
20
|
+
skillName: string;
|
|
21
|
+
outputRoot: string;
|
|
22
|
+
files: readonly string[];
|
|
23
|
+
}
|
|
24
|
+
interface CompileResourceSkillCapsuleInput {
|
|
25
|
+
assembly: ApplicationAssembly;
|
|
26
|
+
skillFqn: string;
|
|
27
|
+
outputDir: string;
|
|
28
|
+
schemas?: ReadonlyMap<string, unknown> | Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
declare function compileSkillCapsule(input: CompileSkillCapsuleInput): Promise<SkillCapsulePlan>;
|
|
31
|
+
declare function compileResourceSkillCapsule(input: CompileResourceSkillCapsuleInput): Promise<SkillCapsulePlan>;
|
|
32
|
+
declare const compilerSkillPackage: {
|
|
33
|
+
readonly role: "framework";
|
|
34
|
+
readonly area: "compiler-skill";
|
|
35
|
+
readonly owns: "standard Skill capsule projection";
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { SkillReference as a, compilerSkillPackage as c, SkillDescriptor as i, CompileSkillCapsuleInput as n, compileResourceSkillCapsule as o, SkillCapsulePlan as r, compileSkillCapsule as s, CompileResourceSkillCapsuleInput as t };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region ../runtime-authoring/src/index.d.ts
|
|
2
|
+
interface Logger {
|
|
3
|
+
info(message: string, fields?: Readonly<Record<string, unknown>>): void;
|
|
4
|
+
warn(message: string, fields?: Readonly<Record<string, unknown>>): void;
|
|
5
|
+
error(message: string, fields?: Readonly<Record<string, unknown>>): void;
|
|
6
|
+
}
|
|
7
|
+
interface RuntimeEffects {
|
|
8
|
+
logger: Logger;
|
|
9
|
+
invoke<TResult = unknown>(effectFqn: string, input: unknown): Promise<TResult>;
|
|
10
|
+
}
|
|
11
|
+
interface AuthoringRuntime<TContext extends Readonly<Record<string, unknown>> = Readonly<Record<string, unknown>>> {
|
|
12
|
+
context: TContext;
|
|
13
|
+
effects: RuntimeEffects;
|
|
14
|
+
}
|
|
15
|
+
interface AuthoringBindings {
|
|
16
|
+
readonly runtime: AuthoringRuntime;
|
|
17
|
+
readonly logger: Logger;
|
|
18
|
+
invokeEffect<TResult = unknown>(effectFqn: string, input: unknown): Promise<TResult>;
|
|
19
|
+
}
|
|
20
|
+
declare function runWithRuntime<T>(runtime: AuthoringRuntime, callback: () => T): T;
|
|
21
|
+
declare function currentRuntime(): AuthoringRuntime;
|
|
22
|
+
declare function createAuthoringBindings(runtime?: AuthoringRuntime<Readonly<Record<string, unknown>>>): AuthoringBindings;
|
|
23
|
+
declare const logger: Logger;
|
|
24
|
+
declare function invokeEffect<TResult = unknown>(effectFqn: string, input: unknown): Promise<TResult>;
|
|
25
|
+
declare const runtimeAuthoringPackage: {
|
|
26
|
+
readonly role: "framework";
|
|
27
|
+
readonly area: "runtime-authoring";
|
|
28
|
+
readonly owns: "target-neutral deterministic-code runtime and effect boundary";
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { createAuthoringBindings as a, logger as c, RuntimeEffects as i, runWithRuntime as l, AuthoringRuntime as n, currentRuntime as o, Logger as r, invokeEffect as s, AuthoringBindings as t, runtimeAuthoringPackage as u };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { n as ResourceDescriptor } from "./index-Ba5Gt9iW.js";
|
|
2
|
+
//#region ../resource-projection/src/index.d.ts
|
|
3
|
+
interface ResourceRegistry {
|
|
4
|
+
readonly byKind: ReadonlyMap<string, readonly ResourceDescriptor[]>;
|
|
5
|
+
}
|
|
6
|
+
declare const resourceProjectionPackage: {
|
|
7
|
+
readonly role: "framework";
|
|
8
|
+
readonly area: "resource-projection";
|
|
9
|
+
readonly owns: "validated registry facts and target projection inputs";
|
|
10
|
+
};
|
|
11
|
+
//#endregion
|
|
12
|
+
export { resourceProjectionPackage as n, ResourceRegistry as t };
|