@pipelex/mthds-ui 0.24.0 → 0.26.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-FD4PKRGZ.js → chunk-K3BWHQVX.js} +38 -20
- package/dist/chunk-K3BWHQVX.js.map +1 -0
- package/dist/{chunk-RJVEDP7M.js → chunk-VCO4GZDZ.js} +12 -2
- package/dist/chunk-VCO4GZDZ.js.map +1 -0
- package/dist/{chunk-HASMGCVK.js → chunk-XBHDA3PQ.js} +2 -2
- package/dist/form/react/RunPanel.css +5 -5
- 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 +6 -4
- package/dist/graph/index.js +7 -3
- package/dist/graph/react/detail/DetailPanel.css +5 -0
- package/dist/graph/react/graph-core.css +4 -1
- package/dist/graph/react/index.css +6 -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 +35 -8
- 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 +7 -3
- package/dist/standalone/graph-standalone.html +155 -86
- package/dist/standalone/graph-viewer.css +15 -3
- package/dist/standalone/graph-viewer.js +140 -83
- package/dist/static-graph/index.d.ts +80 -2
- package/dist/static-graph/index.js +100 -15
- package/dist/static-graph/index.js.map +1 -1
- package/dist/styles/form-kernel.css +38 -38
- package/dist/styles/tailwind.css +51 -0
- package/dist/{types-Cn2FttBC.d.ts → types-DgqW3Jg4.d.ts} +87 -56
- package/package.json +7 -5
- package/dist/chunk-FD4PKRGZ.js.map +0 -1
- package/dist/chunk-RJVEDP7M.js.map +0 -1
- /package/dist/{chunk-HASMGCVK.js.map → chunk-XBHDA3PQ.js.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
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-DgqW3Jg4.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";
|
|
@@ -164,4 +164,82 @@ declare function buildStaticGraphSpecFromToml(tomlTexts: string | string[], opti
|
|
|
164
164
|
*/
|
|
165
165
|
declare function staticDiagnosticsToValidationIssues(diagnostics: Diagnostic[]): ValidationIssue[];
|
|
166
166
|
|
|
167
|
-
|
|
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 };
|
|
@@ -3,8 +3,9 @@ import {
|
|
|
3
3
|
parsePipeRef
|
|
4
4
|
} from "../chunk-2N65P32H.js";
|
|
5
5
|
import {
|
|
6
|
-
KNOWN_PIPE_TYPES
|
|
7
|
-
|
|
6
|
+
KNOWN_PIPE_TYPES,
|
|
7
|
+
isPluralMultiplicity
|
|
8
|
+
} from "../chunk-VCO4GZDZ.js";
|
|
8
9
|
import {
|
|
9
10
|
__spreadProps,
|
|
10
11
|
__spreadValues
|
|
@@ -986,13 +987,19 @@ function registerConcept(ctx, concept) {
|
|
|
986
987
|
function mintStuff(ctx, digest, name, concept, multiplicity) {
|
|
987
988
|
const existing = ctx.stuffByDigest.get(digest);
|
|
988
989
|
if (existing !== void 0) return existing;
|
|
989
|
-
const record = { digest, name, concept, multiplicity };
|
|
990
|
+
const record = { digest, name, concept, multiplicity: multiplicity != null ? multiplicity : null };
|
|
990
991
|
ctx.stuffByDigest.set(digest, record);
|
|
991
992
|
registerConcept(ctx, concept);
|
|
992
993
|
return record;
|
|
993
994
|
}
|
|
994
995
|
function ioItem(stuff, slotName) {
|
|
995
|
-
|
|
996
|
+
const item = {
|
|
997
|
+
name: slotName != null ? slotName : stuff.name,
|
|
998
|
+
digest: stuff.digest,
|
|
999
|
+
concept: stuff.concept.code
|
|
1000
|
+
};
|
|
1001
|
+
if (isPluralMultiplicity(stuff.multiplicity)) item.multiplicity = stuff.multiplicity;
|
|
1002
|
+
return item;
|
|
996
1003
|
}
|
|
997
1004
|
function addEdge(ctx, kind, source, target, extras) {
|
|
998
1005
|
const edge = { id: `static:edge_${ctx.edgeSeq++}`, source, target, kind };
|
|
@@ -1128,13 +1135,16 @@ function walkPipe(ctx, ref, currentDomain, nodeId, parentId, scope, inv) {
|
|
|
1128
1135
|
ctx.stack.pop();
|
|
1129
1136
|
}
|
|
1130
1137
|
}
|
|
1131
|
-
function walkSubPipe(ctx, sub, domain, nodeId, parentId, scope) {
|
|
1132
|
-
|
|
1138
|
+
function walkSubPipe(ctx, sub, domain, nodeId, parentId, scope, inheritedMultiplicity = null) {
|
|
1139
|
+
var _a, _b;
|
|
1140
|
+
if (sub.batch_params != null) {
|
|
1133
1141
|
return walkInlineBatch(ctx, sub, domain, nodeId, parentId, scope);
|
|
1134
1142
|
}
|
|
1135
1143
|
return walkPipe(ctx, sub.pipe_code, domain, nodeId, parentId, scope, {
|
|
1136
|
-
resultName: sub.output_name,
|
|
1137
|
-
|
|
1144
|
+
resultName: (_a = sub.output_name) != null ? _a : null,
|
|
1145
|
+
// A step with no `nb_output`/`multiple_output` of its own runs under the one
|
|
1146
|
+
// its controller was invoked with, as the runtime copies the run params down.
|
|
1147
|
+
outputMultiplicity: (_b = sub.output_multiplicity) != null ? _b : inheritedMultiplicity
|
|
1138
1148
|
});
|
|
1139
1149
|
}
|
|
1140
1150
|
function finishLeaf(ctx, node, blueprint, nodeId, inv) {
|
|
@@ -1175,11 +1185,12 @@ function finishSequence(ctx, node, blueprint, nodeId, scope, inv) {
|
|
|
1175
1185
|
blueprint.domain_code,
|
|
1176
1186
|
`${nodeId}/step_${index + 1}`,
|
|
1177
1187
|
nodeId,
|
|
1178
|
-
scope
|
|
1188
|
+
scope,
|
|
1189
|
+
inv.outputMultiplicity
|
|
1179
1190
|
);
|
|
1180
1191
|
if (result === null) return;
|
|
1181
1192
|
if (result.output !== null) {
|
|
1182
|
-
if (sub.output_name
|
|
1193
|
+
if (sub.output_name != null) scope.set(sub.output_name, result.output);
|
|
1183
1194
|
lastOutput = result.output;
|
|
1184
1195
|
}
|
|
1185
1196
|
for (const [name, stuff] of result.eachOutputs) scope.set(name, stuff);
|
|
@@ -1204,7 +1215,7 @@ function finishParallel(ctx, node, blueprint, nodeId, scope, inv) {
|
|
|
1204
1215
|
const eachOutputs = [];
|
|
1205
1216
|
if (blueprint.add_each_output) {
|
|
1206
1217
|
for (const { sub, result } of branchResults) {
|
|
1207
|
-
if (sub.output_name
|
|
1218
|
+
if (sub.output_name != null && result.output !== null) {
|
|
1208
1219
|
eachOutputs.push([sub.output_name, result.output]);
|
|
1209
1220
|
}
|
|
1210
1221
|
}
|
|
@@ -1231,7 +1242,7 @@ function finishParallel(ctx, node, blueprint, nodeId, scope, inv) {
|
|
|
1231
1242
|
function finishCondition(ctx, node, blueprint, nodeId, scope, inv) {
|
|
1232
1243
|
var _a, _b, _c, _d;
|
|
1233
1244
|
const conditionScope = new Map(scope);
|
|
1234
|
-
if (blueprint.add_alias_from_expression_to
|
|
1245
|
+
if (blueprint.add_alias_from_expression_to != null) {
|
|
1235
1246
|
const alias = blueprint.add_alias_from_expression_to;
|
|
1236
1247
|
conditionScope.set(
|
|
1237
1248
|
alias,
|
|
@@ -1270,7 +1281,9 @@ function finishCondition(ctx, node, blueprint, nodeId, scope, inv) {
|
|
|
1270
1281
|
// The runtime stores whichever branch runs under the condition's own
|
|
1271
1282
|
// slot name, so every branch's output carries it (dry-run parity).
|
|
1272
1283
|
resultName: inv.resultName,
|
|
1273
|
-
|
|
1284
|
+
// The chosen outcome runs under the condition's own run params, its
|
|
1285
|
+
// invocation's `nb_output`/`multiple_output` included.
|
|
1286
|
+
outputMultiplicity: inv.outputMultiplicity,
|
|
1274
1287
|
outcomeValue: entry.values.join(" | ")
|
|
1275
1288
|
}
|
|
1276
1289
|
);
|
|
@@ -1348,7 +1361,7 @@ function finishBatch(ctx, node, blueprint, nodeId, scope, inv) {
|
|
|
1348
1361
|
return { nodeId, output: aggregate, eachOutputs: [] };
|
|
1349
1362
|
}
|
|
1350
1363
|
function walkInlineBatch(ctx, sub, domain, nodeId, parentId, scope) {
|
|
1351
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1364
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1352
1365
|
const params = sub.batch_params;
|
|
1353
1366
|
const aliasIdx = sub.pipe_code.lastIndexOf("->");
|
|
1354
1367
|
const refTail = aliasIdx === -1 ? sub.pipe_code : sub.pipe_code.slice(aliasIdx + 2);
|
|
@@ -1390,7 +1403,7 @@ function walkInlineBatch(ctx, sub, domain, nodeId, parentId, scope) {
|
|
|
1390
1403
|
(_g = (_e = ctx.pipeRegistry)[_f = `${domain}.${code}`]) != null ? _g : _e[_f] = blueprint;
|
|
1391
1404
|
const ioInputs = bindInputs(ctx, blueprint, scope);
|
|
1392
1405
|
const inv = {
|
|
1393
|
-
resultName: sub.output_name,
|
|
1406
|
+
resultName: (_h = sub.output_name) != null ? _h : null,
|
|
1394
1407
|
outputMultiplicity: sub.output_multiplicity
|
|
1395
1408
|
};
|
|
1396
1409
|
const node = emitNode(ctx, {
|
|
@@ -1425,18 +1438,90 @@ function staticDiagnosticsToValidationIssues(diagnostics) {
|
|
|
1425
1438
|
origin: "static"
|
|
1426
1439
|
}, targetFromPath(diagnostic.path, diagnostic.domain_code)));
|
|
1427
1440
|
}
|
|
1441
|
+
|
|
1442
|
+
// src/static-graph/sourceOrder.ts
|
|
1443
|
+
var DEFAULT_BUNDLE_FILE_NAME = "bundle.mthds";
|
|
1444
|
+
var MAIN_PIPE_LINE = /^\s*main_pipe\s*=\s*(["'])[^"']+\1\s*(?:#.*)?$/;
|
|
1445
|
+
var TABLE_HEADER_LINE = /^\s*\[/;
|
|
1446
|
+
function hasTopLevelMainPipe(content) {
|
|
1447
|
+
for (const line of content.split(/\r\n|\r|\n/)) {
|
|
1448
|
+
if (TABLE_HEADER_LINE.test(line)) return false;
|
|
1449
|
+
if (MAIN_PIPE_LINE.test(line)) return true;
|
|
1450
|
+
}
|
|
1451
|
+
return false;
|
|
1452
|
+
}
|
|
1453
|
+
function isDefaultBundle(source) {
|
|
1454
|
+
const baseName = source.name.replace(/^.*[\\/]/, "");
|
|
1455
|
+
return baseName.toLowerCase() === DEFAULT_BUNDLE_FILE_NAME;
|
|
1456
|
+
}
|
|
1457
|
+
function selectPrimaryMthdsSource(sources, preferred) {
|
|
1458
|
+
var _a, _b, _c;
|
|
1459
|
+
const listed = preferred === void 0 ? void 0 : sources.find((source) => source.name === preferred.name);
|
|
1460
|
+
if (listed !== void 0 && hasTopLevelMainPipe(listed.content)) return listed;
|
|
1461
|
+
const withMainPipe = sources.filter((source) => hasTopLevelMainPipe(source.content));
|
|
1462
|
+
return (_c = (_b = (_a = withMainPipe.find(isDefaultBundle)) != null ? _a : withMainPipe[0]) != null ? _b : listed) != null ? _c : sources[0];
|
|
1463
|
+
}
|
|
1464
|
+
function orderMthdsSources(sources, preferred) {
|
|
1465
|
+
const primary = selectPrimaryMthdsSource(sources, preferred);
|
|
1466
|
+
const index = primary === void 0 ? -1 : sources.indexOf(primary);
|
|
1467
|
+
if (index <= 0) return [...sources];
|
|
1468
|
+
return [sources[index], ...sources.slice(0, index), ...sources.slice(index + 1)];
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
// src/static-graph/mthdsSourcesEmbed.ts
|
|
1472
|
+
var MTHDS_SOURCES_EMBED_ID = "mthds-sources";
|
|
1473
|
+
function describeEntry(index) {
|
|
1474
|
+
return `<script id="${MTHDS_SOURCES_EMBED_ID}"> entry ${index}`;
|
|
1475
|
+
}
|
|
1476
|
+
function parseMthdsSourcesEmbed(raw) {
|
|
1477
|
+
if (!Array.isArray(raw)) {
|
|
1478
|
+
throw new Error(
|
|
1479
|
+
`<script id="${MTHDS_SOURCES_EMBED_ID}"> must hold a JSON array of { "name", "content" } objects, one per .mthds file.`
|
|
1480
|
+
);
|
|
1481
|
+
}
|
|
1482
|
+
if (raw.length === 0) {
|
|
1483
|
+
throw new Error(`<script id="${MTHDS_SOURCES_EMBED_ID}"> lists no .mthds file.`);
|
|
1484
|
+
}
|
|
1485
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1486
|
+
return raw.map((entry, index) => {
|
|
1487
|
+
if (entry === null || typeof entry !== "object" || Array.isArray(entry)) {
|
|
1488
|
+
throw new Error(`${describeEntry(index)} is not a { "name", "content" } object.`);
|
|
1489
|
+
}
|
|
1490
|
+
const { name, content } = entry;
|
|
1491
|
+
if (typeof name !== "string" || name.trim() === "") {
|
|
1492
|
+
throw new Error(`${describeEntry(index)} has no "name" string.`);
|
|
1493
|
+
}
|
|
1494
|
+
if (typeof content !== "string") {
|
|
1495
|
+
throw new Error(`${describeEntry(index)} ("${name}") has no "content" string.`);
|
|
1496
|
+
}
|
|
1497
|
+
if (seen.has(name)) {
|
|
1498
|
+
throw new Error(`${describeEntry(index)} repeats the name "${name}".`);
|
|
1499
|
+
}
|
|
1500
|
+
seen.add(name);
|
|
1501
|
+
return { name, content };
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
1504
|
+
function serializeMthdsSourcesEmbed(sources) {
|
|
1505
|
+
return JSON.stringify(parseMthdsSourcesEmbed(sources)).replace(/</g, "\\u003c");
|
|
1506
|
+
}
|
|
1428
1507
|
export {
|
|
1508
|
+
DEFAULT_BUNDLE_FILE_NAME,
|
|
1509
|
+
MTHDS_SOURCES_EMBED_ID,
|
|
1429
1510
|
NATIVE_CONCEPT_CODES,
|
|
1430
1511
|
NATIVE_DOMAIN,
|
|
1431
1512
|
UNKNOWN_DOMAIN,
|
|
1432
1513
|
buildStaticGraphSpec,
|
|
1433
1514
|
buildStaticGraphSpecFromToml,
|
|
1515
|
+
hasTopLevelMainPipe,
|
|
1434
1516
|
makePipeRef,
|
|
1435
1517
|
mergeBundles,
|
|
1518
|
+
orderMthdsSources,
|
|
1436
1519
|
parseConceptRef,
|
|
1437
1520
|
parseInputSlot,
|
|
1438
1521
|
parseMthdsBundle,
|
|
1439
1522
|
parsePipeRef,
|
|
1523
|
+
selectPrimaryMthdsSource,
|
|
1524
|
+
serializeMthdsSourcesEmbed,
|
|
1440
1525
|
staticDiagnosticsToValidationIssues
|
|
1441
1526
|
};
|
|
1442
1527
|
//# sourceMappingURL=index.js.map
|