statelyai 0.12.3 → 0.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.mjs +1 -1
- package/dist/{cli-RFjHJYb3.mjs → cli-_FAuSk1y.mjs} +377 -70
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +4 -4
package/dist/bin.mjs
CHANGED
|
@@ -6877,13 +6877,13 @@ function getDefaultPathId(graph, node) {
|
|
|
6877
6877
|
if (!node.parentId) return getRootEmittedId(graph, node) ?? "(machine)";
|
|
6878
6878
|
const parentNode = graph.nodes.find((candidate) => candidate.id === node.parentId);
|
|
6879
6879
|
if (!parentNode) return node.data.key;
|
|
6880
|
-
return `${
|
|
6880
|
+
return `${getDefaultPathId(graph, parentNode)}.${node.data.key}`;
|
|
6881
6881
|
}
|
|
6882
6882
|
function getEmittedNodeId(graph, node) {
|
|
6883
6883
|
const authored = getAuthoredNodeId(node);
|
|
6884
6884
|
if (!node.parentId) return getRootEmittedId(graph, node);
|
|
6885
6885
|
if (!authored) return void 0;
|
|
6886
|
-
return authored
|
|
6886
|
+
return authored;
|
|
6887
6887
|
}
|
|
6888
6888
|
function getResolvedNodeId(graph, node) {
|
|
6889
6889
|
return getEmittedNodeId(graph, node) ?? getDefaultPathId(graph, node);
|
|
@@ -7059,7 +7059,7 @@ function resolveTransitionTarget(graph, sourceNode, targetNode) {
|
|
|
7059
7059
|
const keys = [];
|
|
7060
7060
|
let current = targetNode;
|
|
7061
7061
|
while (current) {
|
|
7062
|
-
keys.unshift(current.data.key);
|
|
7062
|
+
keys.unshift(current.data.key.replace(/\\/g, "\\\\").replace(/\./g, "\\."));
|
|
7063
7063
|
if (current.parentId === baseId) {
|
|
7064
7064
|
if (isRootSource) return `.${keys.join(".")}`;
|
|
7065
7065
|
return keys.join(".");
|
|
@@ -7446,8 +7446,11 @@ function tagToString(tag) {
|
|
|
7446
7446
|
}
|
|
7447
7447
|
function graphToMachineConfig(graph, options = {}) {
|
|
7448
7448
|
const v6 = isXStateV6Profile(graph.data.profile);
|
|
7449
|
-
const { showDescriptions = true, showMeta = true, showStatelyMeta = true, inlineGuardsAsTypeRef = false, keepChooseStructured = false } = options;
|
|
7450
|
-
const serializeAction = (action) =>
|
|
7449
|
+
const { showDescriptions = true, showMeta = true, showStatelyMeta = true, inlineGuardsAsTypeRef = false, keepChooseStructured = false, timerActionsAsTypeRef = false } = options;
|
|
7450
|
+
const serializeAction = (action) => timerActionsAsTypeRef && ["xstate.raise", "xstate.cancel"].includes(action.type) ? {
|
|
7451
|
+
type: action.type,
|
|
7452
|
+
params: action.params
|
|
7453
|
+
} : serializeActionItem(action, keepChooseStructured);
|
|
7451
7454
|
const config = {};
|
|
7452
7455
|
function getNodeConfig(node) {
|
|
7453
7456
|
const nodeConfig = node.parentId ? {} : config;
|
|
@@ -7460,7 +7463,15 @@ function graphToMachineConfig(graph, options = {}) {
|
|
|
7460
7463
|
"choice"
|
|
7461
7464
|
].includes(node.data.type) ? node.data.type : void 0;
|
|
7462
7465
|
const tags = node.data.tags;
|
|
7463
|
-
const stateMeta = showMeta ? buildMeta(
|
|
7466
|
+
const stateMeta = showMeta ? buildMeta({
|
|
7467
|
+
...node.data.meta,
|
|
7468
|
+
...node.data.assets?.length ? { "@statelyai.assets": node.data.assets.map(({ type, url, size }) => ({
|
|
7469
|
+
type,
|
|
7470
|
+
url,
|
|
7471
|
+
...size ? { size } : {}
|
|
7472
|
+
})) } : {},
|
|
7473
|
+
...node.data.appearance ? { "@statelyai.appearance": node.data.appearance } : {}
|
|
7474
|
+
}, node.data.color, showStatelyMeta) : void 0;
|
|
7464
7475
|
Object.assign(nodeConfig, {
|
|
7465
7476
|
id: resolvedNodeId,
|
|
7466
7477
|
type: nodeType === "normal" ? void 0 : nodeType ?? void 0,
|
|
@@ -7492,6 +7503,8 @@ function graphToMachineConfig(graph, options = {}) {
|
|
|
7492
7503
|
const edges = graph.edges.filter((edge) => edge.sourceId === node.id && !edge.data.temp);
|
|
7493
7504
|
if (edges.length > 0) {
|
|
7494
7505
|
const on = {};
|
|
7506
|
+
const transitionOrder = /* @__PURE__ */ new Map();
|
|
7507
|
+
const scxmlTransitions = [];
|
|
7495
7508
|
const after = {};
|
|
7496
7509
|
const alwaysArr = [];
|
|
7497
7510
|
const choiceArr = [];
|
|
@@ -7507,7 +7520,15 @@ function graphToMachineConfig(graph, options = {}) {
|
|
|
7507
7520
|
return additionalTarget ? [resolveTransitionTarget(graph, node, additionalTarget)] : [];
|
|
7508
7521
|
})].filter(Boolean);
|
|
7509
7522
|
const type = edge.data.eventType ?? "";
|
|
7510
|
-
const transitionMeta = showMeta ? buildMeta(
|
|
7523
|
+
const transitionMeta = showMeta ? buildMeta({
|
|
7524
|
+
...edge.data.meta,
|
|
7525
|
+
...edge.data.assets?.length ? { "@statelyai.assets": edge.data.assets.map(({ type, url, size }) => ({
|
|
7526
|
+
type,
|
|
7527
|
+
url,
|
|
7528
|
+
...size ? { size } : {}
|
|
7529
|
+
})) } : {},
|
|
7530
|
+
...edge.data.appearance ? { "@statelyai.appearance": edge.data.appearance } : {}
|
|
7531
|
+
}, edge.data.color, showStatelyMeta) : void 0;
|
|
7511
7532
|
const transitionObject = {
|
|
7512
7533
|
...edge.data.matches ? { matches: edge.data.matches } : void 0,
|
|
7513
7534
|
target: edge.data.transitionType === "targetless" ? void 0 : resolvedTargets.length > 1 ? resolvedTargets : `${resolvedTarget}`,
|
|
@@ -7519,6 +7540,7 @@ function graphToMachineConfig(graph, options = {}) {
|
|
|
7519
7540
|
description: showDescriptions ? edge.data.description ?? void 0 : void 0,
|
|
7520
7541
|
...transitionMeta ? { meta: transitionMeta } : void 0
|
|
7521
7542
|
};
|
|
7543
|
+
transitionOrder.set(transitionObject, transitionOrder.size);
|
|
7522
7544
|
const pushOn = (key) => {
|
|
7523
7545
|
if (!on[key]) on[key] = [];
|
|
7524
7546
|
on[key].push(transitionObject);
|
|
@@ -7561,7 +7583,11 @@ function graphToMachineConfig(graph, options = {}) {
|
|
|
7561
7583
|
const delayKey = getDelayKeyFromEventType(type, edge.sourceId);
|
|
7562
7584
|
if (!after[delayKey]) after[delayKey] = [];
|
|
7563
7585
|
after[delayKey].push(transitionObject);
|
|
7564
|
-
} else if (
|
|
7586
|
+
} else if (edge.data.meta?.["@statelyai.scxml.eventDescriptor"]) scxmlTransitions.push({
|
|
7587
|
+
descriptor: type,
|
|
7588
|
+
transition: transitionObject
|
|
7589
|
+
});
|
|
7590
|
+
else if (type === "*") pushOn("*");
|
|
7565
7591
|
else if (type.startsWith("xstate.done.state")) {
|
|
7566
7592
|
if (!onDone[type]) onDone[type] = [];
|
|
7567
7593
|
onDone[type].push(transitionObject);
|
|
@@ -7572,6 +7598,16 @@ function graphToMachineConfig(graph, options = {}) {
|
|
|
7572
7598
|
else pushOn(type);
|
|
7573
7599
|
} else pushOn(type);
|
|
7574
7600
|
}
|
|
7601
|
+
const descriptorBase = (descriptor) => descriptor.replace(/\.\*$/, "");
|
|
7602
|
+
const scxmlKeys = new Set([...Object.keys(on), ...scxmlTransitions.flatMap(({ descriptor }) => descriptor === "*" ? ["*"] : descriptorBase(descriptor) ? [descriptorBase(descriptor), `${descriptorBase(descriptor)}.*`] : [])]);
|
|
7603
|
+
for (const key of scxmlKeys) {
|
|
7604
|
+
const base = descriptorBase(key);
|
|
7605
|
+
const matching = scxmlTransitions.filter(({ descriptor }) => {
|
|
7606
|
+
const prefix = descriptorBase(descriptor);
|
|
7607
|
+
return descriptor === "*" || base === prefix || base.startsWith(`${prefix}.`);
|
|
7608
|
+
}).map(({ transition }) => transition);
|
|
7609
|
+
on[key] = [...new Set([...on[key] ?? [], ...matching])].sort((a, b) => (transitionOrder.get(a) ?? 0) - (transitionOrder.get(b) ?? 0));
|
|
7610
|
+
}
|
|
7575
7611
|
if (Object.keys(on).length > 0) nodeConfig.on = singleOrArrayRecord(on);
|
|
7576
7612
|
if (Object.keys(after).length > 0) nodeConfig.after = singleOrArrayRecord(after);
|
|
7577
7613
|
if (alwaysArr.length > 0) nodeConfig.always = singleOrArray(alwaysArr);
|
|
@@ -8543,6 +8579,10 @@ function transitionFromValue(value, actions) {
|
|
|
8543
8579
|
}
|
|
8544
8580
|
if (!value || typeof value !== "object" || Array.isArray(value)) return actions.length ? { actions } : null;
|
|
8545
8581
|
const record = { ...value };
|
|
8582
|
+
if ((Array.isArray(record.target) ? record.target : [record.target]).some(isCodeExpression)) record.meta = {
|
|
8583
|
+
...record.meta,
|
|
8584
|
+
[XSTATE_V6_UNRESOLVED_TARGET_META]: true
|
|
8585
|
+
};
|
|
8546
8586
|
if (actions.length) record.actions = mergeActions(Array.isArray(record.actions) ? record.actions : record.actions ? [record.actions] : void 0, actions);
|
|
8547
8587
|
return record;
|
|
8548
8588
|
}
|
|
@@ -10975,6 +11015,51 @@ function isCompleteFunctionExpression(code) {
|
|
|
10975
11015
|
if (!expression) return false;
|
|
10976
11016
|
return ts.isFunctionExpression(expression) || ts.isArrowFunction(expression);
|
|
10977
11017
|
}
|
|
11018
|
+
function isMachineCode(value) {
|
|
11019
|
+
return !!value && typeof value === "object" && typeof value["@code"] === "string" && typeof value["@lang"] === "string";
|
|
11020
|
+
}
|
|
11021
|
+
function hasMachineCode(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
11022
|
+
if (isMachineCode(value)) return true;
|
|
11023
|
+
if (!value || typeof value !== "object" || seen.has(value)) return false;
|
|
11024
|
+
seen.add(value);
|
|
11025
|
+
return Object.values(value).some((child) => hasMachineCode(child, seen));
|
|
11026
|
+
}
|
|
11027
|
+
function parse$2(source) {
|
|
11028
|
+
return ts.createSourceFile("inspection.ts", source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
11029
|
+
}
|
|
11030
|
+
function expressionSource(source) {
|
|
11031
|
+
if (!parse$2(`const value = (${source});`).parseDiagnostics.length) return source;
|
|
11032
|
+
const methodFile = parse$2(`const value = {${source}};`);
|
|
11033
|
+
const statement = methodFile.statements[0];
|
|
11034
|
+
if (!methodFile.parseDiagnostics.length && statement && ts.isVariableStatement(statement)) {
|
|
11035
|
+
const initializer = statement.declarationList.declarations[0]?.initializer;
|
|
11036
|
+
const method = initializer && ts.isObjectLiteralExpression(initializer) ? initializer.properties[0] : void 0;
|
|
11037
|
+
if (method && ts.isMethodDeclaration(method) && method.body) return `${method.modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword) ? "async " : ""}function${method.asteriskToken ? "*" : ""}(${method.parameters.map((param) => param.getText(methodFile)).join(", ")}) ${method.body.getText(methodFile)}`;
|
|
11038
|
+
}
|
|
11039
|
+
return "() => __stately_inspection_unknown__()";
|
|
11040
|
+
}
|
|
11041
|
+
/** Project runtime MachineJSON code through the same static parser as authored v6 source. */
|
|
11042
|
+
function projectMachineJSON(config) {
|
|
11043
|
+
if (!hasMachineCode(config)) return config;
|
|
11044
|
+
function expressions(value) {
|
|
11045
|
+
if (isMachineCode(value)) return raw(["ts", "js"].includes(value["@lang"]) ? expressionSource(value["@code"]) : "() => __stately_inspection_unknown__()");
|
|
11046
|
+
if (Array.isArray(value)) return value.map(expressions);
|
|
11047
|
+
if (!value || typeof value !== "object") return value;
|
|
11048
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, expressions(item)]));
|
|
11049
|
+
}
|
|
11050
|
+
const projected = xstateSourceToConfig(`createMachine(${serializeJS(expressions(config))});`, { profile: "xstate-v6-alpha" });
|
|
11051
|
+
function restoreSchemas(original, parsed) {
|
|
11052
|
+
if (!original || !parsed || typeof original !== "object" || typeof parsed !== "object") return;
|
|
11053
|
+
const source = original;
|
|
11054
|
+
const result = parsed;
|
|
11055
|
+
if (Object.hasOwn(source, "schemas")) result.schemas = source.schemas;
|
|
11056
|
+
const states = source.states;
|
|
11057
|
+
const parsedStates = result.states;
|
|
11058
|
+
for (const key of Object.keys(states ?? {})) restoreSchemas(states[key], parsedStates?.[key]);
|
|
11059
|
+
}
|
|
11060
|
+
restoreSchemas(config, projected);
|
|
11061
|
+
return projected;
|
|
11062
|
+
}
|
|
10978
11063
|
/**
|
|
10979
11064
|
* A compound state node with no usable `initial` cannot be simulated (XState
|
|
10980
11065
|
* throws "No initial state specified for compound state node"). This walks a
|
|
@@ -11094,6 +11179,7 @@ function actorImplementationItems(value) {
|
|
|
11094
11179
|
}));
|
|
11095
11180
|
}
|
|
11096
11181
|
function machineConfigToGraph(config, options = {}) {
|
|
11182
|
+
if (isXStateV6Profile(options.profile)) config = projectMachineJSON(config);
|
|
11097
11183
|
const rootState = config;
|
|
11098
11184
|
const rootConfig = config;
|
|
11099
11185
|
const rootKey = String(rootState.id ?? "machine");
|
|
@@ -13065,31 +13151,9 @@ var ParseErrorCode;
|
|
|
13065
13151
|
function modify(text, path, value, options) {
|
|
13066
13152
|
return setProperty(text, path, value, options);
|
|
13067
13153
|
}
|
|
13068
|
-
/**
|
|
13069
|
-
* Applies edits to an input string.
|
|
13070
|
-
* @param text The input text
|
|
13071
|
-
* @param edits Edit operations following the format described in {@linkcode EditResult}.
|
|
13072
|
-
* @returns The text with the applied edits.
|
|
13073
|
-
* @throws An error if the edit operations are not well-formed as described in {@linkcode EditResult}.
|
|
13074
|
-
*/
|
|
13075
|
-
function applyEdits(text, edits) {
|
|
13076
|
-
let sortedEdits = edits.slice(0).sort((a, b) => {
|
|
13077
|
-
const diff = a.offset - b.offset;
|
|
13078
|
-
if (diff === 0) return a.length - b.length;
|
|
13079
|
-
return diff;
|
|
13080
|
-
});
|
|
13081
|
-
let lastModifiedOffset = text.length;
|
|
13082
|
-
for (let i = sortedEdits.length - 1; i >= 0; i--) {
|
|
13083
|
-
let e = sortedEdits[i];
|
|
13084
|
-
if (e.offset + e.length <= lastModifiedOffset) text = applyEdit(text, e);
|
|
13085
|
-
else throw new Error("Overlapping edit");
|
|
13086
|
-
lastModifiedOffset = e.offset;
|
|
13087
|
-
}
|
|
13088
|
-
return text;
|
|
13089
|
-
}
|
|
13090
13154
|
|
|
13091
13155
|
//#endregion
|
|
13092
|
-
//#region ../editor-sync/dist/adapters-
|
|
13156
|
+
//#region ../editor-sync/dist/adapters-Dt77BFUa.mjs
|
|
13093
13157
|
const sourceFileUris = /* @__PURE__ */ new WeakMap();
|
|
13094
13158
|
function collectXStateSourceLocations(sourceText, document, options = {}) {
|
|
13095
13159
|
const sourceFile = ts$1.createSourceFile(document.fileName, sourceText, ts$1.ScriptTarget.Latest, true, getScriptKind$2$1(document.fileName));
|
|
@@ -17180,6 +17244,138 @@ function stripPresentationPatches(patches) {
|
|
|
17180
17244
|
return [sourcePatch];
|
|
17181
17245
|
});
|
|
17182
17246
|
}
|
|
17247
|
+
const tokenKind = {
|
|
17248
|
+
comma: 5,
|
|
17249
|
+
lineComment: 12,
|
|
17250
|
+
blockComment: 13,
|
|
17251
|
+
lineBreak: 14,
|
|
17252
|
+
eof: 17
|
|
17253
|
+
};
|
|
17254
|
+
/** Move authored values and same-line comments together, retaining array trivia. */
|
|
17255
|
+
function reorderedActionArray(text, array, order, inserted = /* @__PURE__ */ new Map()) {
|
|
17256
|
+
const items = array.children ?? [];
|
|
17257
|
+
if (!items.length || order.some((index, position) => index < 0 ? !inserted.has(position) : !items[index])) return null;
|
|
17258
|
+
const prefixes = [text.slice(array.offset + 1, items[0].offset)];
|
|
17259
|
+
const comments = [];
|
|
17260
|
+
let closing = "";
|
|
17261
|
+
let trailingComma = false;
|
|
17262
|
+
for (let index = 0; index < items.length; index++) {
|
|
17263
|
+
const item = items[index];
|
|
17264
|
+
const end = items[index + 1]?.offset ?? array.offset + array.length - 1;
|
|
17265
|
+
const gap = text.slice(item.offset + item.length, end);
|
|
17266
|
+
const scanner = createScanner(gap, false);
|
|
17267
|
+
let comma = -1;
|
|
17268
|
+
let commentEnd = 0;
|
|
17269
|
+
let onSameLine = true;
|
|
17270
|
+
for (let token = scanner.scan(); token !== tokenKind.eof; token = scanner.scan()) {
|
|
17271
|
+
if (token === tokenKind.comma && comma < 0) comma = scanner.getTokenOffset();
|
|
17272
|
+
if (token === tokenKind.lineBreak) onSameLine = false;
|
|
17273
|
+
if (onSameLine && (token === tokenKind.lineComment || token === tokenKind.blockComment)) {
|
|
17274
|
+
commentEnd = scanner.getTokenOffset() + scanner.getTokenLength();
|
|
17275
|
+
if (scanner.getTokenValue().includes("\n")) onSameLine = false;
|
|
17276
|
+
}
|
|
17277
|
+
}
|
|
17278
|
+
const withoutComma = (value, offset) => comma >= offset && comma < offset + value.length ? value.slice(0, comma - offset) + value.slice(comma - offset + 1) : value;
|
|
17279
|
+
comments.push(withoutComma(gap.slice(0, commentEnd), 0));
|
|
17280
|
+
const remainder = withoutComma(gap.slice(commentEnd), commentEnd);
|
|
17281
|
+
if (index < items.length - 1) prefixes.push(remainder);
|
|
17282
|
+
else {
|
|
17283
|
+
closing = remainder;
|
|
17284
|
+
trailingComma = comma >= 0;
|
|
17285
|
+
}
|
|
17286
|
+
}
|
|
17287
|
+
const defaultPrefix = prefixes[0].match(/\r?\n[ \t]*$/)?.[0] ?? prefixes.find((prefix) => /^\s*$/.test(prefix)) ?? "";
|
|
17288
|
+
let interior = "";
|
|
17289
|
+
for (let index = 0; index < order.length; index++) {
|
|
17290
|
+
const oldIndex = order[index];
|
|
17291
|
+
const item = items[oldIndex];
|
|
17292
|
+
const ownPrefix = oldIndex > 0 ? prefixes[oldIndex] ?? defaultPrefix : defaultPrefix;
|
|
17293
|
+
let prefix = index === 0 ? prefixes[0] : ownPrefix;
|
|
17294
|
+
if (index === 0 && oldIndex > 0 && stripComments(ownPrefix) !== ownPrefix) prefix += ownPrefix.trimStart();
|
|
17295
|
+
interior += prefix + (item ? text.slice(item.offset, item.offset + item.length) : inserted.get(index));
|
|
17296
|
+
if (index < order.length - 1 || trailingComma) interior += ",";
|
|
17297
|
+
interior += comments[oldIndex] ?? "";
|
|
17298
|
+
}
|
|
17299
|
+
return {
|
|
17300
|
+
start: array.offset + 1,
|
|
17301
|
+
end: array.offset + array.length - 1,
|
|
17302
|
+
text: interior + closing
|
|
17303
|
+
};
|
|
17304
|
+
}
|
|
17305
|
+
/** Keep unchanged source spans as anchors while composing successive tree edits. */
|
|
17306
|
+
var PreservedText = class {
|
|
17307
|
+
pieces;
|
|
17308
|
+
constructor(original) {
|
|
17309
|
+
this.original = original;
|
|
17310
|
+
this.pieces = [{
|
|
17311
|
+
text: original,
|
|
17312
|
+
originalOffset: 0
|
|
17313
|
+
}];
|
|
17314
|
+
}
|
|
17315
|
+
replace(start, end, text) {
|
|
17316
|
+
const before = [];
|
|
17317
|
+
const after = [];
|
|
17318
|
+
let offset = 0;
|
|
17319
|
+
for (const piece of this.pieces) {
|
|
17320
|
+
const pieceEnd = offset + piece.text.length;
|
|
17321
|
+
if (offset < start) before.push({
|
|
17322
|
+
...piece,
|
|
17323
|
+
text: piece.text.slice(0, Math.min(start, pieceEnd) - offset)
|
|
17324
|
+
});
|
|
17325
|
+
if (pieceEnd > end) {
|
|
17326
|
+
const skip = Math.max(end - offset, 0);
|
|
17327
|
+
after.push({
|
|
17328
|
+
text: piece.text.slice(skip),
|
|
17329
|
+
originalOffset: piece.originalOffset === void 0 ? void 0 : piece.originalOffset + skip
|
|
17330
|
+
});
|
|
17331
|
+
}
|
|
17332
|
+
offset = pieceEnd;
|
|
17333
|
+
}
|
|
17334
|
+
this.pieces = [
|
|
17335
|
+
...before,
|
|
17336
|
+
...text ? [{ text }] : [],
|
|
17337
|
+
...after
|
|
17338
|
+
];
|
|
17339
|
+
}
|
|
17340
|
+
replacements(document) {
|
|
17341
|
+
const edits = [];
|
|
17342
|
+
let cursor = 0;
|
|
17343
|
+
let pending = "";
|
|
17344
|
+
const flush = (end) => {
|
|
17345
|
+
let start = cursor;
|
|
17346
|
+
let replacement = pending;
|
|
17347
|
+
while (start < end && replacement && this.original[start] === replacement[0]) {
|
|
17348
|
+
start++;
|
|
17349
|
+
replacement = replacement.slice(1);
|
|
17350
|
+
}
|
|
17351
|
+
while (end > start && replacement && this.original[end - 1] === replacement.at(-1)) {
|
|
17352
|
+
end--;
|
|
17353
|
+
replacement = replacement.slice(0, -1);
|
|
17354
|
+
}
|
|
17355
|
+
if (start !== end || replacement) {
|
|
17356
|
+
const from = document.positionAt(start);
|
|
17357
|
+
const to = document.positionAt(end);
|
|
17358
|
+
edits.push({
|
|
17359
|
+
range: {
|
|
17360
|
+
startLine: from.line,
|
|
17361
|
+
startChar: from.character,
|
|
17362
|
+
endLine: to.line,
|
|
17363
|
+
endChar: to.character
|
|
17364
|
+
},
|
|
17365
|
+
newText: replacement
|
|
17366
|
+
});
|
|
17367
|
+
}
|
|
17368
|
+
pending = "";
|
|
17369
|
+
};
|
|
17370
|
+
for (const piece of this.pieces) if (piece.originalOffset === void 0) pending += piece.text;
|
|
17371
|
+
else {
|
|
17372
|
+
flush(piece.originalOffset);
|
|
17373
|
+
cursor = piece.originalOffset + piece.text.length;
|
|
17374
|
+
}
|
|
17375
|
+
flush(this.original.length);
|
|
17376
|
+
return edits;
|
|
17377
|
+
}
|
|
17378
|
+
};
|
|
17183
17379
|
function isRecord$2(value) {
|
|
17184
17380
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
17185
17381
|
}
|
|
@@ -17243,6 +17439,36 @@ function collectPropertyRenames(previousGraph, nextGraph, patches) {
|
|
|
17243
17439
|
}
|
|
17244
17440
|
return renames;
|
|
17245
17441
|
}
|
|
17442
|
+
/** Recover authored IDs and discard retained implicit runtime IDs using the source. */
|
|
17443
|
+
function recoverSourceNodeIds(graph, previousGraph, source, authoredIdChanges = /* @__PURE__ */ new Set()) {
|
|
17444
|
+
const previousById = new Map(previousGraph.nodes.map((node) => [node.id, node]));
|
|
17445
|
+
const defaultIds = /* @__PURE__ */ new Map();
|
|
17446
|
+
const implicitIds = /* @__PURE__ */ new Map();
|
|
17447
|
+
const authoredIds = /* @__PURE__ */ new Map();
|
|
17448
|
+
const resolve = (id) => {
|
|
17449
|
+
const cached = defaultIds.get(id);
|
|
17450
|
+
if (cached !== void 0) return cached;
|
|
17451
|
+
const node = previousById.get(id);
|
|
17452
|
+
const authoredId = findNodeAtLocation(source, [...node.parentId ? [...statePath(previousGraph, id), node.data.key] : [], "id"]);
|
|
17453
|
+
const implicitId = node.parentId ? `${resolve(node.parentId)}.${node.data.key}` : "(machine)";
|
|
17454
|
+
const defaultId = !node.parentId && authoredId ? getNodeValue(authoredId) : implicitId;
|
|
17455
|
+
defaultIds.set(id, defaultId);
|
|
17456
|
+
if (authoredId) authoredIds.set(id, getNodeValue(authoredId));
|
|
17457
|
+
else implicitIds.set(id, implicitId);
|
|
17458
|
+
return defaultId;
|
|
17459
|
+
};
|
|
17460
|
+
for (const node of previousGraph.nodes) resolve(node.id);
|
|
17461
|
+
const updates = /* @__PURE__ */ new Map();
|
|
17462
|
+
for (const node of graph.nodes) {
|
|
17463
|
+
if (authoredIdChanges.has(node.id)) continue;
|
|
17464
|
+
if (node.data.nodeId == null && authoredIds.has(node.id)) updates.set(node.id, authoredIds.get(node.id));
|
|
17465
|
+
else if (node.data.nodeId != null && node.data.nodeId === implicitIds.get(node.id)) updates.set(node.id, void 0);
|
|
17466
|
+
}
|
|
17467
|
+
if (!updates.size) return graph;
|
|
17468
|
+
const normalized = structuredClone(graph);
|
|
17469
|
+
for (const node of normalized.nodes) if (updates.has(node.id)) node.data.nodeId = updates.get(node.id);
|
|
17470
|
+
return normalized;
|
|
17471
|
+
}
|
|
17246
17472
|
function onlyTargetChanged(previous, next) {
|
|
17247
17473
|
if (typeof previous.target !== "string" || typeof next.target !== "string") return false;
|
|
17248
17474
|
const { target: _previousTarget, ...previousRest } = previous;
|
|
@@ -17263,12 +17489,24 @@ function formattingOptions(text) {
|
|
|
17263
17489
|
};
|
|
17264
17490
|
}
|
|
17265
17491
|
/** Apply graph-level semantic changes to the source JSON tree, not to an export. */
|
|
17266
|
-
function preserveXStateJson(document, previousGraph, nextGraph, machineConfig, patches, preserveStatelyMetadata) {
|
|
17492
|
+
function preserveXStateJson(document, previousGraph, nextGraph, machineConfig, patches, preserveStatelyMetadata, authoredIdChanges) {
|
|
17267
17493
|
if (!isGraph$1(previousGraph) || !isGraph$1(nextGraph) || !isRecord$2(machineConfig)) return null;
|
|
17268
17494
|
const original = document.getText();
|
|
17269
17495
|
let text = original;
|
|
17270
|
-
const
|
|
17271
|
-
const
|
|
17496
|
+
const preservedText = new PreservedText(original);
|
|
17497
|
+
const replace = (start, end, value) => {
|
|
17498
|
+
preservedText.replace(start, end, value);
|
|
17499
|
+
text = text.slice(0, start) + value + text.slice(end);
|
|
17500
|
+
};
|
|
17501
|
+
const originalTree = parseTree(original, [], { allowTrailingComma: true });
|
|
17502
|
+
if (!originalTree) return null;
|
|
17503
|
+
const normalizedPrevious = recoverSourceNodeIds(previousGraph, previousGraph, originalTree);
|
|
17504
|
+
const previousIds = new Map(previousGraph.nodes.map((node) => [node.id, node.data.nodeId ?? null]));
|
|
17505
|
+
const intentionalIds = authoredIdChanges ?? nextGraph.nodes.filter((node) => previousIds.has(node.id) && previousIds.get(node.id) !== (node.data.nodeId ?? null)).map((node) => node.id);
|
|
17506
|
+
const normalizedNext = recoverSourceNodeIds(nextGraph, previousGraph, originalTree, new Set(intentionalIds));
|
|
17507
|
+
const previousConfig = preserveStatelyMetadata ? graphToMachineConfig(normalizedPrevious) : stripStatelyMetadata(graphToMachineConfig(normalizedPrevious));
|
|
17508
|
+
const nextMachineConfig = normalizedNext === nextGraph ? machineConfig : graphToMachineConfig(normalizedNext);
|
|
17509
|
+
const nextConfig = preserveStatelyMetadata ? nextMachineConfig : stripStatelyMetadata(nextMachineConfig);
|
|
17272
17510
|
const renames = collectPropertyRenames(previousGraph, nextGraph, patches);
|
|
17273
17511
|
const treeAt = (path) => {
|
|
17274
17512
|
const errors = [];
|
|
@@ -17278,12 +17516,39 @@ function preserveXStateJson(document, previousGraph, nextGraph, machineConfig, p
|
|
|
17278
17516
|
};
|
|
17279
17517
|
if (!treeAt([])) return null;
|
|
17280
17518
|
const setValue = (path, value) => {
|
|
17281
|
-
|
|
17519
|
+
let containerPath = path.slice(0, -1);
|
|
17520
|
+
let container = treeAt(containerPath);
|
|
17521
|
+
while (!container && containerPath.length) {
|
|
17522
|
+
containerPath = containerPath.slice(0, -1);
|
|
17523
|
+
container = treeAt(containerPath);
|
|
17524
|
+
}
|
|
17525
|
+
const compact = container && !text.slice(container.offset, container.offset + container.length).includes("\n");
|
|
17526
|
+
const edits = modify(text, path, value, { ...compact ? {} : { formattingOptions: formattingOptions(text) } });
|
|
17527
|
+
for (const edit of [...edits].sort((a, b) => b.offset - a.offset)) {
|
|
17528
|
+
let content = edit.content;
|
|
17529
|
+
if (compact && container) {
|
|
17530
|
+
const authored = text.slice(container.offset, container.offset + container.length);
|
|
17531
|
+
const colonSpace = authored.match(/"[^"\r\n]+"\s*:([ \t]*)/)?.[1] ?? "";
|
|
17532
|
+
const commaSpace = authored.match(/,([ \t]*)/)?.[1] ?? "";
|
|
17533
|
+
const scanner = createScanner(content, false);
|
|
17534
|
+
const insertions = [];
|
|
17535
|
+
for (let token = scanner.scan(); token !== 17; token = scanner.scan()) {
|
|
17536
|
+
const spacing = token === 6 ? colonSpace : token === 5 ? commaSpace : "";
|
|
17537
|
+
const offset = scanner.getTokenOffset() + scanner.getTokenLength();
|
|
17538
|
+
if (spacing && !/\s/.test(content[offset] ?? "")) insertions.push({
|
|
17539
|
+
offset,
|
|
17540
|
+
text: spacing
|
|
17541
|
+
});
|
|
17542
|
+
}
|
|
17543
|
+
for (const insertion of insertions.reverse()) content = content.slice(0, insertion.offset) + insertion.text + content.slice(insertion.offset);
|
|
17544
|
+
}
|
|
17545
|
+
replace(edit.offset, edit.offset + edit.length, content);
|
|
17546
|
+
}
|
|
17282
17547
|
};
|
|
17283
17548
|
const renameKey = (path, oldKey, newKey) => {
|
|
17284
17549
|
const keyNode = treeAt([...path, oldKey])?.parent?.children?.[0];
|
|
17285
17550
|
if (!keyNode || keyNode.type !== "string") return false;
|
|
17286
|
-
|
|
17551
|
+
replace(keyNode.offset, keyNode.offset + keyNode.length, JSON.stringify(newKey));
|
|
17287
17552
|
return true;
|
|
17288
17553
|
};
|
|
17289
17554
|
const removePropertyWithoutFormatting = (path, key) => {
|
|
@@ -17302,14 +17567,14 @@ function preserveXStateJson(document, previousGraph, nextGraph, machineConfig, p
|
|
|
17302
17567
|
const lineStart = text.lastIndexOf("\n", property.offset - 1) + 1;
|
|
17303
17568
|
const nextLineStart = text.lastIndexOf("\n", next.offset - 1) + 1;
|
|
17304
17569
|
if (nextLineStart <= lineStart || text.slice(lineStart, property.offset).trim() !== "" || !/^\s*,\s*$/.test(text.slice(propertyEnd, nextLineStart))) return false;
|
|
17305
|
-
|
|
17570
|
+
replace(lineStart, nextLineStart, "");
|
|
17306
17571
|
return true;
|
|
17307
17572
|
}
|
|
17308
17573
|
const previous = properties[index - 1];
|
|
17309
17574
|
if (!previous || trailingLine.trim() !== "") return false;
|
|
17310
17575
|
const previousEnd = previous.offset + previous.length;
|
|
17311
17576
|
if (!/^\s*,\s*$/.test(text.slice(previousEnd, property.offset))) return false;
|
|
17312
|
-
|
|
17577
|
+
replace(previousEnd, propertyEnd, "");
|
|
17313
17578
|
return true;
|
|
17314
17579
|
};
|
|
17315
17580
|
const removeArrayItem = (path, index) => {
|
|
@@ -17333,7 +17598,7 @@ function preserveXStateJson(document, previousGraph, nextGraph, machineConfig, p
|
|
|
17333
17598
|
const nextLineStart = next && text.lastIndexOf("\n", next.offset - 1) + 1;
|
|
17334
17599
|
const separatorOnNextLine = itemLineEnd >= 0 && nextLineStart !== void 0 && /^[ \t]*,[ \t]*\r?\n$/.test(text.slice(itemLineEnd + 1, nextLineStart));
|
|
17335
17600
|
if (next && next.offset > lineEnd && (/^\s*,\s*\/\//.test(inlineSuffix) || /^\s*\/\//.test(inlineSuffix) && separatorOnNextLine)) {
|
|
17336
|
-
|
|
17601
|
+
replace(itemLineStart, separatorOnNextLine ? nextLineStart : itemLineEnd < 0 ? lineEnd : lineEnd + 1, "");
|
|
17337
17602
|
return true;
|
|
17338
17603
|
}
|
|
17339
17604
|
} else {
|
|
@@ -17343,7 +17608,7 @@ function preserveXStateJson(document, previousGraph, nextGraph, machineConfig, p
|
|
|
17343
17608
|
const withoutComma = beforeItem.replace(/^(\s*),/, "$1");
|
|
17344
17609
|
if (previousEnd !== void 0 && itemLineEnd >= 0 && itemLineStart > previousEnd && withoutComma !== beforeItem && stripComments(withoutComma).trim() === "") {
|
|
17345
17610
|
const separator = /^\s*$/.test(withoutComma) ? formattingOptions(text).eol : withoutComma;
|
|
17346
|
-
|
|
17611
|
+
replace(previousEnd, itemLineEnd + 1, separator);
|
|
17347
17612
|
return true;
|
|
17348
17613
|
}
|
|
17349
17614
|
}
|
|
@@ -17370,7 +17635,7 @@ function preserveXStateJson(document, previousGraph, nextGraph, machineConfig, p
|
|
|
17370
17635
|
end = nextLineStart;
|
|
17371
17636
|
} else if (!text.slice(end, nextItem.offset).includes("\n") && text.slice(end, nextItem.offset).trim() === "") end = nextItem.offset;
|
|
17372
17637
|
} else end = item.offset + item.length;
|
|
17373
|
-
|
|
17638
|
+
replace(start, end, "");
|
|
17374
17639
|
return true;
|
|
17375
17640
|
};
|
|
17376
17641
|
const appendArrayItemWithoutFormatting = (path, value) => {
|
|
@@ -17390,7 +17655,7 @@ function preserveXStateJson(document, previousGraph, nextGraph, machineConfig, p
|
|
|
17390
17655
|
if (indentation.trim() !== "") return false;
|
|
17391
17656
|
separator = `,${formattingOptions(text).eol}${indentation}`;
|
|
17392
17657
|
}
|
|
17393
|
-
|
|
17658
|
+
replace(lastEnd, lastEnd, separator + serialized);
|
|
17394
17659
|
return true;
|
|
17395
17660
|
};
|
|
17396
17661
|
const authoredBranchText = (path, index) => {
|
|
@@ -17407,6 +17672,39 @@ function preserveXStateJson(document, previousGraph, nextGraph, machineConfig, p
|
|
|
17407
17672
|
}
|
|
17408
17673
|
return `${leadingText}${text.slice(branchNode.offset, branchNode.offset + branchNode.length)}`;
|
|
17409
17674
|
};
|
|
17675
|
+
const actionOrder = (previous, next, path) => {
|
|
17676
|
+
const group = path.at(-1);
|
|
17677
|
+
if (group !== "entry" && group !== "exit" && group !== "actions") return void 0;
|
|
17678
|
+
const owner = nextGraph.nodes.filter((node) => {
|
|
17679
|
+
return (node.parentId ? [...statePath(nextGraph, node.id), node.data.key] : []).every((key, index) => path[index] === key);
|
|
17680
|
+
}).sort((a, b) => (statePath(nextGraph, b.id)?.length ?? 0) - (statePath(nextGraph, a.id)?.length ?? 0))[0];
|
|
17681
|
+
if (!owner) return void 0;
|
|
17682
|
+
const previousNode = previousGraph.nodes.find((node) => node.id === owner.id);
|
|
17683
|
+
const serialize = (actions) => actions.map(({ type, params }) => ({
|
|
17684
|
+
type,
|
|
17685
|
+
...params && Object.keys(params).length ? { params } : {}
|
|
17686
|
+
}));
|
|
17687
|
+
const normalized = (values) => values.map((value) => typeof value === "string" ? { type: value } : value);
|
|
17688
|
+
const ownerPath = owner.parentId ? [...statePath(nextGraph, owner.id), owner.data.key] : [];
|
|
17689
|
+
const transitionPath = path.slice(ownerPath.length);
|
|
17690
|
+
const event = transitionPath[0] === "on" ? transitionPath[1] : transitionPath[0] === "always" ? "" : void 0;
|
|
17691
|
+
const matchingEdges = nextGraph.edges.filter((edge) => edge.sourceId === owner.id && (event === void 0 || edge.data.eventType === event));
|
|
17692
|
+
const branchIndex = typeof path.at(-2) === "number" ? path.at(-2) : 0;
|
|
17693
|
+
const edgeId = event === void 0 ? void 0 : matchingEdges[branchIndex]?.id;
|
|
17694
|
+
const matches = (group === "actions" ? previousGraph.edges.filter((edge) => edge.sourceId === owner.id && (event === void 0 || edge.id === edgeId)).map((edge) => ({
|
|
17695
|
+
previous: edge.data.actions ?? [],
|
|
17696
|
+
next: nextGraph.edges.find((candidate) => candidate.id === edge.id)?.data.actions ?? []
|
|
17697
|
+
})) : [{
|
|
17698
|
+
previous: previousNode?.data[group] ?? [],
|
|
17699
|
+
next: owner.data[group] ?? []
|
|
17700
|
+
}]).filter((candidate) => sameValue(serialize(candidate.previous), normalized(previous)) && sameValue(serialize(candidate.next), normalized(next)));
|
|
17701
|
+
if (matches.length !== 1) return void 0;
|
|
17702
|
+
const candidate = matches[0];
|
|
17703
|
+
const ids = candidate.previous.map((action) => action.id);
|
|
17704
|
+
if (ids.some((id) => !id) || new Set(ids).size !== ids.length) return void 0;
|
|
17705
|
+
const order = candidate.next.map((action) => ids.indexOf(action.id));
|
|
17706
|
+
return candidate.next.every((action) => action.id) ? order : void 0;
|
|
17707
|
+
};
|
|
17410
17708
|
const visit = (previous, next, path) => {
|
|
17411
17709
|
if (sameValue(previous, next)) return true;
|
|
17412
17710
|
const sourceNode = treeAt(path);
|
|
@@ -17426,10 +17724,15 @@ function preserveXStateJson(document, previousGraph, nextGraph, machineConfig, p
|
|
|
17426
17724
|
const authoredAction = Object.keys(next).length === 1 ? next.type : next;
|
|
17427
17725
|
if (text.slice(sourceNode.offset + 1, sourceNode.offset + sourceNode.length - 1) === "") {
|
|
17428
17726
|
const insertion = sourceNode.offset + 1;
|
|
17429
|
-
|
|
17727
|
+
replace(insertion, insertion, JSON.stringify(authoredAction));
|
|
17430
17728
|
} else setValue(path, [authoredAction]);
|
|
17431
17729
|
return true;
|
|
17432
17730
|
}
|
|
17731
|
+
if (sourceNode?.type === "array" && sourceNode.children?.length === 1 && isRecord$2(previous) && Array.isArray(next) && [
|
|
17732
|
+
"entry",
|
|
17733
|
+
"exit",
|
|
17734
|
+
"actions"
|
|
17735
|
+
].includes(String(path.at(-1)))) return visit([previous], next, path);
|
|
17433
17736
|
if (sourceNode?.type === "array" && sourceNode.children?.length === 1 && isRecord$2(previous) && isRecord$2(next)) return visit(previous, next, [...path, 0]);
|
|
17434
17737
|
if (isRecord$2(previous) && isRecord$2(next) && sourceNode?.type === "object") {
|
|
17435
17738
|
const handledOld = /* @__PURE__ */ new Set();
|
|
@@ -17490,14 +17793,14 @@ function preserveXStateJson(document, previousGraph, nextGraph, machineConfig, p
|
|
|
17490
17793
|
index
|
|
17491
17794
|
]);
|
|
17492
17795
|
if (!insertedNode) return false;
|
|
17493
|
-
|
|
17796
|
+
replace(insertedNode.offset, insertedNode.offset + insertedNode.length, authoredText);
|
|
17494
17797
|
}
|
|
17495
17798
|
continue;
|
|
17496
17799
|
}
|
|
17497
17800
|
if (!visit(previous[key], next[key], [...path, key])) return false;
|
|
17498
17801
|
} else {
|
|
17499
17802
|
const existing = key === "actions" ? treeAt([...path, key]) : void 0;
|
|
17500
|
-
if (existing?.type === "array")
|
|
17803
|
+
if (existing?.type === "array") replace(existing.offset, existing.offset + existing.length, "[]");
|
|
17501
17804
|
else if ((key === "entry" || key === "exit") && removePropertyWithoutFormatting(path, key)) {} else setValue([...path, key], void 0);
|
|
17502
17805
|
}
|
|
17503
17806
|
}
|
|
@@ -17510,11 +17813,33 @@ function preserveXStateJson(document, previousGraph, nextGraph, machineConfig, p
|
|
|
17510
17813
|
if (originalBranch !== void 0) {
|
|
17511
17814
|
const insertedNode = treeAt([...path, key]);
|
|
17512
17815
|
if (!insertedNode) return false;
|
|
17513
|
-
|
|
17816
|
+
replace(insertedNode.offset, insertedNode.offset + insertedNode.length, originalBranch);
|
|
17514
17817
|
}
|
|
17515
17818
|
}
|
|
17516
17819
|
return true;
|
|
17517
17820
|
}
|
|
17821
|
+
if (Array.isArray(previous) && sourceNode?.type === "array" && (Array.isArray(next) || isRecord$2(next))) {
|
|
17822
|
+
const nextValues = Array.isArray(next) ? next : [next];
|
|
17823
|
+
const order = actionOrder(previous, nextValues, path);
|
|
17824
|
+
const pureDeletion = previous.length === nextValues.length + 1 && previous.some((_, index) => sameValue(previous.filter((_, candidate) => candidate !== index), nextValues));
|
|
17825
|
+
const lastSourceItem = sourceNode.children?.at(-1);
|
|
17826
|
+
const sourceSuffix = lastSourceItem ? text.slice(lastSourceItem.offset + lastSourceItem.length, sourceNode.offset + sourceNode.length - 1) : "";
|
|
17827
|
+
const pureAppend = !(stripComments(sourceSuffix) !== sourceSuffix) && order && nextValues.length > previous.length && order.slice(0, previous.length).every((oldIndex, index) => oldIndex === index);
|
|
17828
|
+
if (order && !pureDeletion && !pureAppend && (previous.length !== nextValues.length || order.some((oldIndex, index) => oldIndex !== index))) {
|
|
17829
|
+
for (const [index, oldIndex] of order.entries()) if (oldIndex >= 0 && !visit(previous[oldIndex], nextValues[index], [...path, oldIndex])) return false;
|
|
17830
|
+
const array = treeAt(path);
|
|
17831
|
+
if (!array) return false;
|
|
17832
|
+
const inserted = new Map(order.flatMap((oldIndex, index) => {
|
|
17833
|
+
if (oldIndex >= 0) return [];
|
|
17834
|
+
const value = nextValues[index];
|
|
17835
|
+
return [[index, JSON.stringify(value)]];
|
|
17836
|
+
}));
|
|
17837
|
+
const edit = reorderedActionArray(text, array, order, inserted);
|
|
17838
|
+
if (!edit) return false;
|
|
17839
|
+
replace(edit.start, edit.end, edit.text);
|
|
17840
|
+
return true;
|
|
17841
|
+
}
|
|
17842
|
+
}
|
|
17518
17843
|
if (Array.isArray(previous) && isRecord$2(next) && sourceNode?.type === "array") {
|
|
17519
17844
|
if (previous.length === 1 && isRecord$2(previous[0])) return visit(previous[0], next, [...path, 0]);
|
|
17520
17845
|
const matches = previous.flatMap((value, index) => sameValue(value, next) ? [index] : []);
|
|
@@ -17546,25 +17871,7 @@ function preserveXStateJson(document, previousGraph, nextGraph, machineConfig, p
|
|
|
17546
17871
|
parseTree(text, errors, { allowTrailingComma: true });
|
|
17547
17872
|
if (errors.length) return null;
|
|
17548
17873
|
if (text === original) return [];
|
|
17549
|
-
|
|
17550
|
-
while (start < original.length && start < text.length && original[start] === text[start]) start++;
|
|
17551
|
-
let oldEnd = original.length;
|
|
17552
|
-
let newEnd = text.length;
|
|
17553
|
-
while (oldEnd > start && newEnd > start && original[oldEnd - 1] === text[newEnd - 1]) {
|
|
17554
|
-
oldEnd--;
|
|
17555
|
-
newEnd--;
|
|
17556
|
-
}
|
|
17557
|
-
const startPosition = document.positionAt(start);
|
|
17558
|
-
const endPosition = document.positionAt(oldEnd);
|
|
17559
|
-
return [{
|
|
17560
|
-
range: {
|
|
17561
|
-
startLine: startPosition.line,
|
|
17562
|
-
startChar: startPosition.character,
|
|
17563
|
-
endLine: endPosition.line,
|
|
17564
|
-
endChar: endPosition.character
|
|
17565
|
-
},
|
|
17566
|
-
newText: text.slice(start, newEnd)
|
|
17567
|
-
}];
|
|
17874
|
+
return preservedText.replacements(document);
|
|
17568
17875
|
}
|
|
17569
17876
|
const xstateAdapter = {
|
|
17570
17877
|
id: "xstate",
|
|
@@ -17653,7 +17960,7 @@ const xstateJsonAdapter = {
|
|
|
17653
17960
|
if (options?.sourceUpdateStrategy === "rewrite") return createSerializedDocumentReplacement(document, options, "xstate-json");
|
|
17654
17961
|
const patches = options?.preserveStatelyMetadata === false ? stripPresentationPatches(options.patches ?? []) : options?.patches ?? [];
|
|
17655
17962
|
if (!options || !patches.length) return [];
|
|
17656
|
-
return preserveXStateJson(document, options.prevGraph, options.nextGraph, machineConfig, patches, options.preserveStatelyMetadata ?? true) ?? [];
|
|
17963
|
+
return preserveXStateJson(document, options.prevGraph, options.nextGraph, machineConfig, patches, options.preserveStatelyMetadata ?? true, options.authoredIdChanges) ?? [];
|
|
17657
17964
|
}
|
|
17658
17965
|
};
|
|
17659
17966
|
const asyncAdapter = createSerializedExportAdapter("async", (document, text) => isJavaScriptOrTypeScriptFile(document.fileName) && looksLikeAsyncWorkflow(text));
|
|
@@ -17936,7 +18243,7 @@ function diagnosticKey$1(diagnostic) {
|
|
|
17936
18243
|
}
|
|
17937
18244
|
|
|
17938
18245
|
//#endregion
|
|
17939
|
-
//#region ../editor-sync/dist/localBackend-
|
|
18246
|
+
//#region ../editor-sync/dist/localBackend-DH1qEsOz.mjs
|
|
17940
18247
|
var LocalEditorSyncBackend = class {
|
|
17941
18248
|
constructor(access) {
|
|
17942
18249
|
this.access = access;
|
|
@@ -19183,7 +19490,7 @@ const editorSyncApplyResponseSchema = z$1.object({ replacements: z$1.array(edito
|
|
|
19183
19490
|
const editorSyncAccessResponseSchema = z$1.object({ access: editorSyncAccessSchema });
|
|
19184
19491
|
|
|
19185
19492
|
//#endregion
|
|
19186
|
-
//#region ../editor-sync/dist/host-
|
|
19493
|
+
//#region ../editor-sync/dist/host-BX7mLyHj.mjs
|
|
19187
19494
|
let diagnosticSequence = 0;
|
|
19188
19495
|
function presentationsEqual(first, second) {
|
|
19189
19496
|
return JSON.stringify(createPresentationSnapshot(first)) === JSON.stringify(createPresentationSnapshot(second));
|
|
@@ -20150,7 +20457,7 @@ function sourceLocationUris(sourceLocations) {
|
|
|
20150
20457
|
|
|
20151
20458
|
//#endregion
|
|
20152
20459
|
//#region src/version.ts
|
|
20153
|
-
const CLI_VERSION = "0.12.
|
|
20460
|
+
const CLI_VERSION = "0.12.4";
|
|
20154
20461
|
|
|
20155
20462
|
//#endregion
|
|
20156
20463
|
//#region src/cliHost.ts
|
|
@@ -21251,7 +21558,7 @@ function getScriptKind$1(fileName) {
|
|
|
21251
21558
|
}
|
|
21252
21559
|
|
|
21253
21560
|
//#endregion
|
|
21254
|
-
//#region ../../node_modules/.pnpm/@statelyai+graph@2.1.0_@statelyai+layout@0.
|
|
21561
|
+
//#region ../../node_modules/.pnpm/@statelyai+graph@2.1.0_@statelyai+layout@0.3.0_cytoscape@3.34.0_d3-force@3.0.0_d3-hiera_7624816e5d9226bed30c68417318a8b7/node_modules/@statelyai/graph/dist/index.mjs
|
|
21255
21562
|
const LAYOUT_KEYS = {
|
|
21256
21563
|
node: [
|
|
21257
21564
|
"x",
|
package/dist/index.d.mts
CHANGED
|
@@ -71,7 +71,7 @@ declare function createStatelyProjectConfig(options: {
|
|
|
71
71
|
defaultXStateVersion?: number;
|
|
72
72
|
}): StatelyProjectConfig;
|
|
73
73
|
//#endregion
|
|
74
|
-
//#region ../../node_modules/.pnpm/@statelyai+graph@2.1.0_@statelyai+layout@0.
|
|
74
|
+
//#region ../../node_modules/.pnpm/@statelyai+graph@2.1.0_@statelyai+layout@0.3.0_cytoscape@3.34.0_d3-force@3.0.0_d3-hiera_7624816e5d9226bed30c68417318a8b7/node_modules/@statelyai/graph/dist/types-BAEQTwK_.d.mts
|
|
75
75
|
//#region src/types.d.ts
|
|
76
76
|
/**
|
|
77
77
|
* Directedness of a graph or an individual edge.
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { C as run, D as verifyProject, E as resolveVerificationRequest, O as formatVerificationJUnit, S as resolveProjectStatus, T as scanProjectSources, _ as isFileGitDirty, a as discoverMachinesInSource, b as resolveCredentialStatus, c as formatDiscoveredMachines, d as formatProjectStatus, f as formatStoredCredentialSource, g as initProject, h as inferInitProjectName, i as discoverLinkedPullTargets, k as createStatelyProjectConfig, l as formatMissingNewMachineDirMessage, m as getEnvCredential, n as buildOAuthLoginStart, o as discoverOAuthLogin, p as getEnvApiKey, r as classifyPushCandidates, s as discoverRemoteProjectMachineTargets, t as COMMANDS, u as formatPlanSummary, v as resolveApiKey, w as scanProjectMachines, x as resolveOpenRootDir, y as resolveConfiguredPullTargets } from "./cli-
|
|
1
|
+
import { C as run, D as verifyProject, E as resolveVerificationRequest, O as formatVerificationJUnit, S as resolveProjectStatus, T as scanProjectSources, _ as isFileGitDirty, a as discoverMachinesInSource, b as resolveCredentialStatus, c as formatDiscoveredMachines, d as formatProjectStatus, f as formatStoredCredentialSource, g as initProject, h as inferInitProjectName, i as discoverLinkedPullTargets, k as createStatelyProjectConfig, l as formatMissingNewMachineDirMessage, m as getEnvCredential, n as buildOAuthLoginStart, o as discoverOAuthLogin, p as getEnvApiKey, r as classifyPushCandidates, s as discoverRemoteProjectMachineTargets, t as COMMANDS, u as formatPlanSummary, v as resolveApiKey, w as scanProjectMachines, x as resolveOpenRootDir, y as resolveConfiguredPullTargets } from "./cli-_FAuSk1y.mjs";
|
|
2
2
|
|
|
3
3
|
export { COMMANDS, buildOAuthLoginStart, classifyPushCandidates, createStatelyProjectConfig, discoverLinkedPullTargets, discoverMachinesInSource, discoverOAuthLogin, discoverRemoteProjectMachineTargets, formatDiscoveredMachines, formatMissingNewMachineDirMessage, formatPlanSummary, formatProjectStatus, formatStoredCredentialSource, formatVerificationJUnit, getEnvApiKey, getEnvCredential, inferInitProjectName, initProject, isFileGitDirty, resolveApiKey, resolveConfiguredPullTargets, resolveCredentialStatus, resolveOpenRootDir, resolveProjectStatus, resolveVerificationRequest, run, scanProjectMachines, scanProjectSources, verifyProject };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "statelyai",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.4",
|
|
4
4
|
"description": "Command-line tools for Stately",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"typescript": "^5.9.3",
|
|
25
25
|
"ws": "^8.21.0",
|
|
26
26
|
"zod": "^4.4.1",
|
|
27
|
-
"@statelyai/sdk": "0.37.
|
|
27
|
+
"@statelyai/sdk": "0.37.3"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/ws": "^8.18.1",
|
|
31
31
|
"tsdown": "0.21.0-beta.2",
|
|
32
32
|
"vitest": "^3.2.4",
|
|
33
|
-
"@statelyai/api-contract": "0.5.
|
|
34
|
-
"@statelyai/editor-sync": "0.1.
|
|
33
|
+
"@statelyai/api-contract": "0.5.6",
|
|
34
|
+
"@statelyai/editor-sync": "0.1.46"
|
|
35
35
|
},
|
|
36
36
|
"oclif": {
|
|
37
37
|
"bin": "statelyai",
|