@pipelex/mthds-ui 0.23.0 → 0.25.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/README.md +42 -11
- package/dist/{chunk-RJVEDP7M.js → chunk-F3GBNU2I.js} +3 -2
- package/dist/{chunk-RJVEDP7M.js.map → chunk-F3GBNU2I.js.map} +1 -1
- package/dist/{chunk-FD4PKRGZ.js → chunk-LMGMRLIK.js} +2 -2
- package/dist/{chunk-HASMGCVK.js → chunk-MQ33HVWG.js} +2 -2
- package/dist/form/react/RunPanel.css +5 -4
- package/dist/form/react/index.d.ts +1 -1
- package/dist/form/react/index.js +2 -3
- package/dist/form/react/index.js.map +1 -1
- package/dist/graph/index.d.ts +2 -2
- package/dist/graph/index.js +3 -3
- package/dist/graph/react/index.css +2 -1
- package/dist/graph/react/index.css.map +1 -1
- package/dist/graph/react/index.d.ts +11 -14
- package/dist/graph/react/index.js +27 -4
- package/dist/graph/react/index.js.map +1 -1
- package/dist/graph/react/viewer/GraphToolbar.css +5 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/standalone/graph-standalone.html +146 -85
- package/dist/standalone/graph-viewer.css +6 -2
- package/dist/standalone/graph-viewer.js +140 -83
- package/dist/static-graph/index.d.ts +111 -3
- package/dist/static-graph/index.js +154 -17
- package/dist/static-graph/index.js.map +1 -1
- package/dist/styles/form-kernel.css +38 -34
- package/dist/styles/tailwind.css +51 -0
- package/dist/{types-Cn2FttBC.d.ts → types-Bcsh7Z0U.d.ts} +4 -0
- package/package.json +7 -5
- /package/dist/{chunk-FD4PKRGZ.js.map → chunk-LMGMRLIK.js.map} +0 -0
- /package/dist/{chunk-HASMGCVK.js.map → chunk-MQ33HVWG.js.map} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as ConceptInfo, P as PipeBlueprintUnion, a as PresenceMarker, b as GraphSpec, V as ValidationIssue } from '../types-
|
|
1
|
+
import { C as ConceptInfo, P as PipeBlueprintUnion, a as PresenceMarker, b as GraphSpec, V as ValidationIssue } from '../types-Bcsh7Z0U.js';
|
|
2
2
|
export { P as ParsedPipeRef, m as makePipeRef, p as parsePipeRef } from '../pipeRefs-BQJO5nh5.js';
|
|
3
3
|
|
|
4
4
|
type DiagnosticSeverity = "error" | "warning";
|
|
5
|
-
type DiagnosticCode = "toml-parse-error" | "missing-domain" | "invalid-bundle-shape" | "invalid-concept-entry" | "invalid-pipe-entry" | "unknown-pipe-type" | "retired-signature-tag" | "invalid-concept-ref" | "missing-pipe-output" | "invalid-sub-pipe" | "incomplete-batch-spec" | "duplicate-concept" | "duplicate-pipe" | "signature-type-mismatch" | "unresolved-pipe-ref" | "cyclic-pipe-ref" | "missing-main-pipe" | "no-entry-pipe" | "conflicting-input-concept";
|
|
5
|
+
type DiagnosticCode = "toml-parse-error" | "missing-domain" | "invalid-bundle-shape" | "invalid-concept-entry" | "invalid-pipe-entry" | "unknown-pipe-type" | "retired-signature-tag" | "invalid-concept-ref" | "unknown-input-slot-key" | "missing-pipe-output" | "invalid-sub-pipe" | "incomplete-batch-spec" | "duplicate-concept" | "duplicate-pipe" | "signature-type-mismatch" | "unresolved-pipe-ref" | "cyclic-pipe-ref" | "missing-main-pipe" | "no-entry-pipe" | "conflicting-input-concept";
|
|
6
6
|
/**
|
|
7
7
|
* A non-fatal note collected while parsing or merging. `error` means a whole
|
|
8
8
|
* unit could not be interpreted (unparseable TOML, a skipped pipe); `warning`
|
|
@@ -85,6 +85,36 @@ interface ConceptRefParts {
|
|
|
85
85
|
}
|
|
86
86
|
/** Parse a concept ref string into its parts. Returns null when the ref is not interpretable. */
|
|
87
87
|
declare function parseConceptRef(raw: unknown): ConceptRefParts | null;
|
|
88
|
+
interface InputSlotParts {
|
|
89
|
+
/** The slot's concept ref parts, or null when the slot is not interpretable. */
|
|
90
|
+
ref: ConceptRefParts | null;
|
|
91
|
+
/**
|
|
92
|
+
* True when an expanded slot table declares no `concept` at all. The key is
|
|
93
|
+
* required, so there is no ref for a diagnostic to be about — the caller says
|
|
94
|
+
* the key is missing rather than blaming a ref the author never wrote.
|
|
95
|
+
*/
|
|
96
|
+
missingConcept: boolean;
|
|
97
|
+
/** Keys of an expanded slot table this version of the standard does not define. */
|
|
98
|
+
unknownKeys: string[];
|
|
99
|
+
/**
|
|
100
|
+
* True when the table is not a slot table at all but the wreckage of an
|
|
101
|
+
* unquoted dotted input name — see {@link looksLikeUnquotedDottedName}.
|
|
102
|
+
*/
|
|
103
|
+
dottedName: boolean;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Read one `inputs` value, whichever form authored it.
|
|
107
|
+
*
|
|
108
|
+
* `hints` is parsed as a known key and then dropped: intent hints are
|
|
109
|
+
* presentational, and the standard routes them to renderers through the
|
|
110
|
+
* input-form descriptor, not the GraphSpec (see `docs/static-graph.md`).
|
|
111
|
+
* Their shape is not checked here for the same reason — a malformed `hints`
|
|
112
|
+
* table is content this module never reads, so it is the validator's to
|
|
113
|
+
* report, not the renderer's. An unknown key is different: it may well be
|
|
114
|
+
* where a future standard puts something that changes the slot, so it is
|
|
115
|
+
* named rather than passed over.
|
|
116
|
+
*/
|
|
117
|
+
declare function parseInputSlot(raw: unknown): InputSlotParts;
|
|
88
118
|
|
|
89
119
|
/**
|
|
90
120
|
* Parse one `.mthds` TOML string. Returns whatever could be interpreted plus
|
|
@@ -134,4 +164,82 @@ declare function buildStaticGraphSpecFromToml(tomlTexts: string | string[], opti
|
|
|
134
164
|
*/
|
|
135
165
|
declare function staticDiagnosticsToValidationIssues(diagnostics: Diagnostic[]): ValidationIssue[];
|
|
136
166
|
|
|
137
|
-
|
|
167
|
+
/**
|
|
168
|
+
* One `.mthds` file of a method: the name it goes by and its TOML text. The
|
|
169
|
+
* same shape as an `mthds_sources[]` entry on the hosted API, so a host holding
|
|
170
|
+
* one can pass it straight through.
|
|
171
|
+
*/
|
|
172
|
+
interface MthdsSource {
|
|
173
|
+
/**
|
|
174
|
+
* File name, or a path ending in one. The whole string is the file's
|
|
175
|
+
* identity: a `preferred` file is matched against it exactly, and an embed
|
|
176
|
+
* lists each name once. Only the `bundle.mthds` tie-break reads the last
|
|
177
|
+
* segment alone.
|
|
178
|
+
*/
|
|
179
|
+
name: string;
|
|
180
|
+
/** The file's `.mthds` TOML text. */
|
|
181
|
+
content: string;
|
|
182
|
+
}
|
|
183
|
+
/** The file name that breaks a tie when several files declare `main_pipe`. */
|
|
184
|
+
declare const DEFAULT_BUNDLE_FILE_NAME = "bundle.mthds";
|
|
185
|
+
/**
|
|
186
|
+
* Whether a file declares `main_pipe` at the top level, before its first table.
|
|
187
|
+
*
|
|
188
|
+
* A line scan rather than a TOML parse, on purpose: an editor asks this about
|
|
189
|
+
* a file the author is in the middle of writing, and a syntax error further
|
|
190
|
+
* down must not demote the file that plainly declares the entry point. The
|
|
191
|
+
* scan stops at the first table header, because a `main_pipe` key inside a
|
|
192
|
+
* table is not the bundle's.
|
|
193
|
+
*/
|
|
194
|
+
declare function hasTopLevelMainPipe(content: string): boolean;
|
|
195
|
+
/**
|
|
196
|
+
* The file a method's graph is anchored on.
|
|
197
|
+
*
|
|
198
|
+
* `preferred` is the file the host is looking at, such as the one open in an
|
|
199
|
+
* editor; it leads whenever it declares `main_pipe` itself. Otherwise the file
|
|
200
|
+
* declaring a top-level `main_pipe` leads, `bundle.mthds` when several do and
|
|
201
|
+
* the first of them in the given order when none is named so. When no file
|
|
202
|
+
* declares one, `preferred` leads, or else the first file. Returns `undefined`
|
|
203
|
+
* only for an empty list.
|
|
204
|
+
*
|
|
205
|
+
* `preferred` is matched against `sources` by `name`, and the listed entry is
|
|
206
|
+
* what is read and returned, so a host may pass its own object for the open
|
|
207
|
+
* file rather than the list's: the result is always a member of `sources`,
|
|
208
|
+
* because the merge reads the list and not `preferred`. That is also why
|
|
209
|
+
* `preferred` is a plain `MthdsSource`: it cannot narrow the result's type and
|
|
210
|
+
* strip the fields a host's own list entries carry. A `preferred` whose
|
|
211
|
+
* name is not listed is ignored: it cannot lead a list it is not in, and the
|
|
212
|
+
* answer is then the one given no `preferred` at all.
|
|
213
|
+
*/
|
|
214
|
+
declare function selectPrimaryMthdsSource<T extends MthdsSource>(sources: readonly T[], preferred?: MthdsSource): T | undefined;
|
|
215
|
+
/**
|
|
216
|
+
* The files in the order the static builder should merge them: the primary
|
|
217
|
+
* file (see {@link selectPrimaryMthdsSource}, which also says how `preferred`
|
|
218
|
+
* is matched) first, then the rest in the order given. The rest keep their
|
|
219
|
+
* order so a host that wants a deterministic merge only has to list its files
|
|
220
|
+
* deterministically. Returns a new array.
|
|
221
|
+
*/
|
|
222
|
+
declare function orderMthdsSources<T extends MthdsSource>(sources: readonly T[], preferred?: MthdsSource): T[];
|
|
223
|
+
|
|
224
|
+
/** The id of the `<script type="application/json">` element carrying the files. */
|
|
225
|
+
declare const MTHDS_SOURCES_EMBED_ID = "mthds-sources";
|
|
226
|
+
/**
|
|
227
|
+
* The text a host places inside `<script type="application/json"
|
|
228
|
+
* id="mthds-sources">`: the files as a JSON array of `{ name, content }`,
|
|
229
|
+
* checked against the embed contract, with every `<` written as `\u003c`.
|
|
230
|
+
*
|
|
231
|
+
* The escape is what makes the text safe inside the element. `JSON.parse`
|
|
232
|
+
* reads it back as `<`, while the HTML parser never meets one, so no method
|
|
233
|
+
* text can end the element early, whichever spelling of `</script` it uses, or
|
|
234
|
+
* switch the element into the states a `<!--` opens. A prompt quoting a line of
|
|
235
|
+
* HTML is enough to need it. Neither `JSON.stringify` nor any platform API has
|
|
236
|
+
* an HTML-safe mode, which is why this function exists.
|
|
237
|
+
*
|
|
238
|
+
* Only `name` and `content` are written, whatever else a host's objects carry,
|
|
239
|
+
* and the files keep the order given, because the bundle puts them in merge
|
|
240
|
+
* order itself. Throws on a list the bundle would refuse, naming the entry at
|
|
241
|
+
* fault.
|
|
242
|
+
*/
|
|
243
|
+
declare function serializeMthdsSourcesEmbed(sources: readonly MthdsSource[]): string;
|
|
244
|
+
|
|
245
|
+
export { type ConceptRefParts, DEFAULT_BUNDLE_FILE_NAME, type Diagnostic, type DiagnosticCode, type DiagnosticSeverity, type DomainNamespace, type InputSlotParts, MTHDS_SOURCES_EMBED_ID, type MergedMethodSet, type MthdsSource, NATIVE_CONCEPT_CODES, NATIVE_DOMAIN, type ParseMthdsBundleResult, type ParsedBundle, type StaticGraphOptions, type StaticGraphResult, UNKNOWN_DOMAIN, buildStaticGraphSpec, buildStaticGraphSpecFromToml, hasTopLevelMainPipe, mergeBundles, orderMthdsSources, parseConceptRef, parseInputSlot, parseMthdsBundle, selectPrimaryMthdsSource, serializeMthdsSourcesEmbed, staticDiagnosticsToValidationIssues };
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "../chunk-2N65P32H.js";
|
|
5
5
|
import {
|
|
6
6
|
KNOWN_PIPE_TYPES
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-F3GBNU2I.js";
|
|
8
8
|
import {
|
|
9
9
|
__spreadProps,
|
|
10
10
|
__spreadValues
|
|
@@ -17,6 +17,9 @@ function isPlainObject(value) {
|
|
|
17
17
|
const proto = Object.getPrototypeOf(value);
|
|
18
18
|
return proto === Object.prototype || proto === null;
|
|
19
19
|
}
|
|
20
|
+
function authoredRecord() {
|
|
21
|
+
return /* @__PURE__ */ Object.create(null);
|
|
22
|
+
}
|
|
20
23
|
function strOrNull(value) {
|
|
21
24
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
22
25
|
}
|
|
@@ -70,6 +73,32 @@ function parseConceptRef(raw) {
|
|
|
70
73
|
presence: presenceFromSymbol(presence)
|
|
71
74
|
};
|
|
72
75
|
}
|
|
76
|
+
var INPUT_SLOT_KEYS = /* @__PURE__ */ new Set(["concept", "hints"]);
|
|
77
|
+
var CONCEPT_CODE_RE = /^[A-Z][A-Za-z0-9]*$/;
|
|
78
|
+
function looksLikeUnquotedDottedName(raw, unknownKeys) {
|
|
79
|
+
if (raw.concept !== void 0 || unknownKeys.length === 0) return false;
|
|
80
|
+
return unknownKeys.every((key) => {
|
|
81
|
+
const parts = parseConceptRef(raw[key]);
|
|
82
|
+
return parts !== null && CONCEPT_CODE_RE.test(parts.code);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function parseInputSlot(raw) {
|
|
86
|
+
if (!isPlainObject(raw)) {
|
|
87
|
+
return {
|
|
88
|
+
ref: parseConceptRef(raw),
|
|
89
|
+
missingConcept: false,
|
|
90
|
+
unknownKeys: [],
|
|
91
|
+
dottedName: false
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const unknownKeys = Object.keys(raw).filter((key) => !INPUT_SLOT_KEYS.has(key));
|
|
95
|
+
return {
|
|
96
|
+
ref: parseConceptRef(raw.concept),
|
|
97
|
+
missingConcept: raw.concept === void 0,
|
|
98
|
+
unknownKeys,
|
|
99
|
+
dottedName: looksLikeUnquotedDottedName(raw, unknownKeys)
|
|
100
|
+
};
|
|
101
|
+
}
|
|
73
102
|
function qualifiedStructureClassName(domain, code) {
|
|
74
103
|
return `${domain.replaceAll(".", "\xB7")}__${code}`;
|
|
75
104
|
}
|
|
@@ -98,22 +127,32 @@ function resolveConceptInfo(parts, currentDomain, localConcepts) {
|
|
|
98
127
|
if (parts.domain !== null && parts.domain !== currentDomain) {
|
|
99
128
|
return stubConceptInfo(parts.code, parts.domain);
|
|
100
129
|
}
|
|
101
|
-
|
|
102
|
-
if (local) return local;
|
|
130
|
+
if (Object.hasOwn(localConcepts, parts.code)) return localConcepts[parts.code];
|
|
103
131
|
if (parts.domain === null && isNativeConceptCode(parts.code)) {
|
|
104
132
|
return nativeConceptInfo(parts.code);
|
|
105
133
|
}
|
|
106
134
|
return stubConceptInfo(parts.code, currentDomain);
|
|
107
135
|
}
|
|
108
|
-
function
|
|
109
|
-
const parts = parseConceptRef(raw);
|
|
110
|
-
if (parts === null) return null;
|
|
136
|
+
function stuffSpecFromParts(parts, currentDomain, localConcepts) {
|
|
111
137
|
return {
|
|
112
138
|
concept: resolveConceptInfo(parts, currentDomain, localConcepts),
|
|
113
139
|
multiplicity: parts.multiplicity,
|
|
114
140
|
presence: parts.presence
|
|
115
141
|
};
|
|
116
142
|
}
|
|
143
|
+
function resolveStuffSpec(raw, currentDomain, localConcepts) {
|
|
144
|
+
const parts = parseConceptRef(raw);
|
|
145
|
+
return parts === null ? null : stuffSpecFromParts(parts, currentDomain, localConcepts);
|
|
146
|
+
}
|
|
147
|
+
function resolveInputSlot(raw, currentDomain, localConcepts) {
|
|
148
|
+
const { ref, missingConcept, unknownKeys, dottedName } = parseInputSlot(raw);
|
|
149
|
+
return {
|
|
150
|
+
spec: ref === null ? null : stuffSpecFromParts(ref, currentDomain, localConcepts),
|
|
151
|
+
missingConcept,
|
|
152
|
+
unknownKeys,
|
|
153
|
+
dottedName
|
|
154
|
+
};
|
|
155
|
+
}
|
|
117
156
|
|
|
118
157
|
// src/static-graph/parseMthdsBundle.ts
|
|
119
158
|
import { parse as parseToml } from "smol-toml";
|
|
@@ -135,7 +174,7 @@ function stringArrayOrNull(value) {
|
|
|
135
174
|
return value.filter((item) => typeof item === "string");
|
|
136
175
|
}
|
|
137
176
|
function normalizeInputs(raw, pipeCode, ctx) {
|
|
138
|
-
const inputs =
|
|
177
|
+
const inputs = authoredRecord();
|
|
139
178
|
if (raw === void 0 || raw === null) return inputs;
|
|
140
179
|
if (!isPlainObject(raw)) {
|
|
141
180
|
ctx.diagnostics.push({
|
|
@@ -146,13 +185,34 @@ function normalizeInputs(raw, pipeCode, ctx) {
|
|
|
146
185
|
});
|
|
147
186
|
return inputs;
|
|
148
187
|
}
|
|
149
|
-
for (const [name,
|
|
150
|
-
const spec
|
|
188
|
+
for (const [name, slot] of Object.entries(raw)) {
|
|
189
|
+
const { spec, missingConcept, unknownKeys, dottedName } = resolveInputSlot(
|
|
190
|
+
slot,
|
|
191
|
+
ctx.domain,
|
|
192
|
+
ctx.concepts
|
|
193
|
+
);
|
|
194
|
+
if (dottedName) {
|
|
195
|
+
ctx.diagnostics.push({
|
|
196
|
+
severity: "warning",
|
|
197
|
+
code: "invalid-concept-ref",
|
|
198
|
+
message: `pipe "${pipeCode}": input "${name}" reads as a slot table but looks like an unquoted dotted input name \u2014 write it as one quoted key ("${name}.${unknownKeys.join(".")}" = \u2026) \u2014 skipped`,
|
|
199
|
+
path: `pipe.${pipeCode}.inputs.${name}`
|
|
200
|
+
});
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (unknownKeys.length > 0) {
|
|
204
|
+
ctx.diagnostics.push({
|
|
205
|
+
severity: "warning",
|
|
206
|
+
code: "unknown-input-slot-key",
|
|
207
|
+
message: `pipe "${pipeCode}": input "${name}" declares ${unknownKeys.map((key) => `"${key}"`).join(", ")}, which the input slot form does not define \u2014 ignored here, and the runtime refuses the bundle`,
|
|
208
|
+
path: `pipe.${pipeCode}.inputs.${name}`
|
|
209
|
+
});
|
|
210
|
+
}
|
|
151
211
|
if (spec === null) {
|
|
152
212
|
ctx.diagnostics.push({
|
|
153
213
|
severity: "warning",
|
|
154
214
|
code: "invalid-concept-ref",
|
|
155
|
-
message: `pipe "${pipeCode}": input "${name}" has an uninterpretable concept ref \u2014 skipped`,
|
|
215
|
+
message: missingConcept ? `pipe "${pipeCode}": input "${name}" is a slot table with no "concept" \u2014 the key is required \u2014 skipped` : `pipe "${pipeCode}": input "${name}" has an uninterpretable concept ref \u2014 skipped`,
|
|
156
216
|
path: `pipe.${pipeCode}.inputs.${name}`
|
|
157
217
|
});
|
|
158
218
|
continue;
|
|
@@ -514,7 +574,7 @@ function fieldSchema(spec) {
|
|
|
514
574
|
}
|
|
515
575
|
function deriveJsonSchema(structure, title, description) {
|
|
516
576
|
if (!isPlainObject(structure)) return void 0;
|
|
517
|
-
const properties =
|
|
577
|
+
const properties = authoredRecord();
|
|
518
578
|
const required = [];
|
|
519
579
|
for (const [name, spec] of Object.entries(structure)) {
|
|
520
580
|
if (typeof spec === "string") {
|
|
@@ -552,7 +612,7 @@ function qualifyRefines(raw, domain, declaredCodes, conceptCode, diagnostics) {
|
|
|
552
612
|
}
|
|
553
613
|
function parseConcepts(raw, domain, diagnostics) {
|
|
554
614
|
var _a, _b;
|
|
555
|
-
const concepts =
|
|
615
|
+
const concepts = authoredRecord();
|
|
556
616
|
if (raw === void 0) return concepts;
|
|
557
617
|
if (!isPlainObject(raw)) {
|
|
558
618
|
diagnostics.push({
|
|
@@ -603,8 +663,8 @@ function emptyBundle() {
|
|
|
603
663
|
description: null,
|
|
604
664
|
main_pipe: null,
|
|
605
665
|
system_prompt: null,
|
|
606
|
-
concepts:
|
|
607
|
-
pipes:
|
|
666
|
+
concepts: authoredRecord(),
|
|
667
|
+
pipes: authoredRecord()
|
|
608
668
|
};
|
|
609
669
|
}
|
|
610
670
|
function parseMthdsBundle(tomlText) {
|
|
@@ -675,7 +735,7 @@ function enrichPipeConcepts(pipe, domains) {
|
|
|
675
735
|
const declared = (_a = domains[spec.concept.domain_code]) == null ? void 0 : _a.concepts[spec.concept.code];
|
|
676
736
|
return declared !== void 0 && declared !== spec.concept ? __spreadProps(__spreadValues({}, spec), { concept: declared }) : spec;
|
|
677
737
|
};
|
|
678
|
-
const inputs =
|
|
738
|
+
const inputs = authoredRecord();
|
|
679
739
|
for (const [name, spec] of Object.entries(pipe.inputs)) {
|
|
680
740
|
inputs[name] = enrichSpec(spec);
|
|
681
741
|
}
|
|
@@ -684,13 +744,17 @@ function enrichPipeConcepts(pipe, domains) {
|
|
|
684
744
|
function mergeBundles(bundles) {
|
|
685
745
|
var _a, _b, _c;
|
|
686
746
|
const diagnostics = [];
|
|
687
|
-
const domains =
|
|
747
|
+
const domains = authoredRecord();
|
|
688
748
|
let mainDomain = null;
|
|
689
749
|
let mainPipe = null;
|
|
690
750
|
let description = null;
|
|
691
751
|
for (const bundle of bundles) {
|
|
692
752
|
const domain = (_a = bundle.domain) != null ? _a : UNKNOWN_DOMAIN;
|
|
693
|
-
const namespace = (_b = domains[domain]) != null ? _b : domains[domain] = {
|
|
753
|
+
const namespace = (_b = domains[domain]) != null ? _b : domains[domain] = {
|
|
754
|
+
domain,
|
|
755
|
+
concepts: authoredRecord(),
|
|
756
|
+
pipes: authoredRecord()
|
|
757
|
+
};
|
|
694
758
|
if (mainDomain === null && bundle.domain !== null) mainDomain = bundle.domain;
|
|
695
759
|
if (mainPipe === null && bundle.main_pipe !== null) {
|
|
696
760
|
mainPipe = bundle.main_pipe;
|
|
@@ -1361,17 +1425,90 @@ function staticDiagnosticsToValidationIssues(diagnostics) {
|
|
|
1361
1425
|
origin: "static"
|
|
1362
1426
|
}, targetFromPath(diagnostic.path, diagnostic.domain_code)));
|
|
1363
1427
|
}
|
|
1428
|
+
|
|
1429
|
+
// src/static-graph/sourceOrder.ts
|
|
1430
|
+
var DEFAULT_BUNDLE_FILE_NAME = "bundle.mthds";
|
|
1431
|
+
var MAIN_PIPE_LINE = /^\s*main_pipe\s*=\s*(["'])[^"']+\1\s*(?:#.*)?$/;
|
|
1432
|
+
var TABLE_HEADER_LINE = /^\s*\[/;
|
|
1433
|
+
function hasTopLevelMainPipe(content) {
|
|
1434
|
+
for (const line of content.split(/\r\n|\r|\n/)) {
|
|
1435
|
+
if (TABLE_HEADER_LINE.test(line)) return false;
|
|
1436
|
+
if (MAIN_PIPE_LINE.test(line)) return true;
|
|
1437
|
+
}
|
|
1438
|
+
return false;
|
|
1439
|
+
}
|
|
1440
|
+
function isDefaultBundle(source) {
|
|
1441
|
+
const baseName = source.name.replace(/^.*[\\/]/, "");
|
|
1442
|
+
return baseName.toLowerCase() === DEFAULT_BUNDLE_FILE_NAME;
|
|
1443
|
+
}
|
|
1444
|
+
function selectPrimaryMthdsSource(sources, preferred) {
|
|
1445
|
+
var _a, _b, _c;
|
|
1446
|
+
const listed = preferred === void 0 ? void 0 : sources.find((source) => source.name === preferred.name);
|
|
1447
|
+
if (listed !== void 0 && hasTopLevelMainPipe(listed.content)) return listed;
|
|
1448
|
+
const withMainPipe = sources.filter((source) => hasTopLevelMainPipe(source.content));
|
|
1449
|
+
return (_c = (_b = (_a = withMainPipe.find(isDefaultBundle)) != null ? _a : withMainPipe[0]) != null ? _b : listed) != null ? _c : sources[0];
|
|
1450
|
+
}
|
|
1451
|
+
function orderMthdsSources(sources, preferred) {
|
|
1452
|
+
const primary = selectPrimaryMthdsSource(sources, preferred);
|
|
1453
|
+
const index = primary === void 0 ? -1 : sources.indexOf(primary);
|
|
1454
|
+
if (index <= 0) return [...sources];
|
|
1455
|
+
return [sources[index], ...sources.slice(0, index), ...sources.slice(index + 1)];
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
// src/static-graph/mthdsSourcesEmbed.ts
|
|
1459
|
+
var MTHDS_SOURCES_EMBED_ID = "mthds-sources";
|
|
1460
|
+
function describeEntry(index) {
|
|
1461
|
+
return `<script id="${MTHDS_SOURCES_EMBED_ID}"> entry ${index}`;
|
|
1462
|
+
}
|
|
1463
|
+
function parseMthdsSourcesEmbed(raw) {
|
|
1464
|
+
if (!Array.isArray(raw)) {
|
|
1465
|
+
throw new Error(
|
|
1466
|
+
`<script id="${MTHDS_SOURCES_EMBED_ID}"> must hold a JSON array of { "name", "content" } objects, one per .mthds file.`
|
|
1467
|
+
);
|
|
1468
|
+
}
|
|
1469
|
+
if (raw.length === 0) {
|
|
1470
|
+
throw new Error(`<script id="${MTHDS_SOURCES_EMBED_ID}"> lists no .mthds file.`);
|
|
1471
|
+
}
|
|
1472
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1473
|
+
return raw.map((entry, index) => {
|
|
1474
|
+
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) {
|
|
1475
|
+
throw new Error(`${describeEntry(index)} is not a { "name", "content" } object.`);
|
|
1476
|
+
}
|
|
1477
|
+
const { name, content } = entry;
|
|
1478
|
+
if (typeof name !== "string" || name.trim() === "") {
|
|
1479
|
+
throw new Error(`${describeEntry(index)} has no "name" string.`);
|
|
1480
|
+
}
|
|
1481
|
+
if (typeof content !== "string") {
|
|
1482
|
+
throw new Error(`${describeEntry(index)} ("${name}") has no "content" string.`);
|
|
1483
|
+
}
|
|
1484
|
+
if (seen.has(name)) {
|
|
1485
|
+
throw new Error(`${describeEntry(index)} repeats the name "${name}".`);
|
|
1486
|
+
}
|
|
1487
|
+
seen.add(name);
|
|
1488
|
+
return { name, content };
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
function serializeMthdsSourcesEmbed(sources) {
|
|
1492
|
+
return JSON.stringify(parseMthdsSourcesEmbed(sources)).replace(/</g, "\\u003c");
|
|
1493
|
+
}
|
|
1364
1494
|
export {
|
|
1495
|
+
DEFAULT_BUNDLE_FILE_NAME,
|
|
1496
|
+
MTHDS_SOURCES_EMBED_ID,
|
|
1365
1497
|
NATIVE_CONCEPT_CODES,
|
|
1366
1498
|
NATIVE_DOMAIN,
|
|
1367
1499
|
UNKNOWN_DOMAIN,
|
|
1368
1500
|
buildStaticGraphSpec,
|
|
1369
1501
|
buildStaticGraphSpecFromToml,
|
|
1502
|
+
hasTopLevelMainPipe,
|
|
1370
1503
|
makePipeRef,
|
|
1371
1504
|
mergeBundles,
|
|
1505
|
+
orderMthdsSources,
|
|
1372
1506
|
parseConceptRef,
|
|
1507
|
+
parseInputSlot,
|
|
1373
1508
|
parseMthdsBundle,
|
|
1374
1509
|
parsePipeRef,
|
|
1510
|
+
selectPrimaryMthdsSource,
|
|
1511
|
+
serializeMthdsSourcesEmbed,
|
|
1375
1512
|
staticDiagnosticsToValidationIssues
|
|
1376
1513
|
};
|
|
1377
1514
|
//# sourceMappingURL=index.js.map
|