@magmonium/cli 0.8.28 → 0.8.30

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/codegen/index.js CHANGED
@@ -230,6 +230,7 @@ __export(index_exports, {
230
230
  ONE_FUNCTIONS: () => ONE_FUNCTIONS,
231
231
  ONE_FUNCTION_CATALOG: () => ONE_FUNCTION_CATALOG,
232
232
  ONE_FUNCTION_DATA_PARAM: () => ONE_FUNCTION_DATA_PARAM,
233
+ ONE_FUNCTION_IDS_MAP_PARAM: () => ONE_FUNCTION_IDS_MAP_PARAM,
233
234
  ONE_FUNCTION_IDS_PARAM: () => ONE_FUNCTION_IDS_PARAM,
234
235
  ONE_FUNCTION_ID_PARAM: () => ONE_FUNCTION_ID_PARAM,
235
236
  ONE_FUNCTION_KEY_PARAM: () => ONE_FUNCTION_KEY_PARAM,
@@ -511,6 +512,7 @@ __export(index_exports, {
511
512
  checkedFieldIds: () => checkedFieldIds,
512
513
  checksUsingFunction: () => checksUsingFunction,
513
514
  childNavId: () => childNavId,
515
+ classCallOutcomes: () => classCallOutcomes,
514
516
  classCardScope: () => classCardScope,
515
517
  clearOutputCallRows: () => clearOutputCallRows,
516
518
  clearOutputGroupRows: () => clearOutputGroupRows,
@@ -586,6 +588,7 @@ __export(index_exports, {
586
588
  controlUsesOverlayRef: () => controlUsesOverlayRef,
587
589
  controlVariantIds: () => controlVariantIds,
588
590
  controlVariants: () => controlVariants,
591
+ controlWireOutcomes: () => controlWireOutcomes,
589
592
  countFormResetReferences: () => countFormResetReferences,
590
593
  countIconReferences: () => countIconReferences,
591
594
  countOptionSetReferences: () => countOptionSetReferences,
@@ -616,6 +619,7 @@ __export(index_exports, {
616
619
  customReadme: () => customReadme,
617
620
  dataTypeFits: () => dataTypeFits,
618
621
  dataTypeMismatch: () => dataTypeMismatch,
622
+ declaredPayload: () => declaredPayload,
619
623
  declaresOutputs: () => declaresOutputs,
620
624
  declaresShapeInput: () => declaresShapeInput,
621
625
  decodeKeySource: () => decodeKeySource,
@@ -777,6 +781,7 @@ __export(index_exports, {
777
781
  formModelSourceType: () => formModelSourceType,
778
782
  formModelStateOptions: () => formModelStateOptions,
779
783
  formModelTransforms: () => formModelTransforms,
784
+ formQueryReaches: () => formQueryReaches,
780
785
  formRefName: () => formRefName,
781
786
  formRefNames: () => formRefNames,
782
787
  formResetDepths: () => formResetDepths,
@@ -965,6 +970,7 @@ __export(index_exports, {
965
970
  isNavInstanceFunction: () => isNavInstanceFunction,
966
971
  isNavRowShape: () => isNavRowShape,
967
972
  isNavVisibilityFunction: () => isNavVisibilityFunction,
973
+ isObjectRepeatSource: () => isObjectRepeatSource,
968
974
  isOnChange: () => isOnChange,
969
975
  isOneFunctionComputed: () => isOneFunctionComputed,
970
976
  isOneFunctionStateComputed: () => isOneFunctionStateComputed,
@@ -989,6 +995,7 @@ __export(index_exports, {
989
995
  isPathResolved: () => isPathResolved,
990
996
  isPrimitiveType: () => isPrimitiveType,
991
997
  isPureFunctionComplete: () => isPureFunctionComplete,
998
+ isReactionAutoCall: () => isReactionAutoCall,
992
999
  isRedirectRoute: () => isRedirectRoute,
993
1000
  isReferencedByRule: () => isReferencedByRule,
994
1001
  isReleaseVersion: () => isReleaseVersion,
@@ -1135,6 +1142,7 @@ __export(index_exports, {
1135
1142
  methodArms: () => methodArms,
1136
1143
  methodConfirmKeys: () => methodConfirmKeys,
1137
1144
  methodSignature: () => methodSignature,
1145
+ methodSpecShapes: () => methodSpecShapes,
1138
1146
  methodUsage: () => methodUsage,
1139
1147
  methodsPersist: () => methodsPersist,
1140
1148
  migrateStored: () => migrateStored,
@@ -1204,6 +1212,7 @@ __export(index_exports, {
1204
1212
  needsKey: () => needsKey,
1205
1213
  needsValueTranslation: () => needsValueTranslation,
1206
1214
  nestMenuItem: () => nestMenuItem,
1215
+ nestedOutcomeCalls: () => nestedOutcomeCalls,
1207
1216
  newCardAliases: () => newCardAliases,
1208
1217
  newComputedOption: () => newComputedOption,
1209
1218
  newInstanceFunctionOption: () => newInstanceFunctionOption,
@@ -1232,6 +1241,7 @@ __export(index_exports, {
1232
1241
  normalizeThemeName: () => normalizeThemeName,
1233
1242
  normalizeTranslationKey: () => normalizeTranslationKey,
1234
1243
  normalizeVariantName: () => normalizeVariantName,
1244
+ objectMemberShapeId: () => objectMemberShapeId,
1235
1245
  offersOutputArms: () => offersOutputArms,
1236
1246
  oneFunctionArgFits: () => oneFunctionArgFits,
1237
1247
  oneFunctionBoundSignature: () => oneFunctionBoundSignature,
@@ -1247,6 +1257,7 @@ __export(index_exports, {
1247
1257
  oneFunctionSiteFits: () => oneFunctionSiteFits,
1248
1258
  oneParamFixedHeld: () => oneParamFixedHeld,
1249
1259
  oneParamStatePathOnly: () => oneParamStatePathOnly,
1260
+ oneParamTakesAnyRow: () => oneParamTakesAnyRow,
1250
1261
  oneParamTakesFixed: () => oneParamTakesFixed,
1251
1262
  oneParamTypeText: () => oneParamTypeText,
1252
1263
  openError: () => openError,
@@ -1273,6 +1284,7 @@ __export(index_exports, {
1273
1284
  outcomeNavStatement: () => outcomeNavStatement,
1274
1285
  outcomeReadsArgs: () => outcomeReadsArgs,
1275
1286
  outcomeReport: () => outcomeReport,
1287
+ outcomeTransformArgFits: () => outcomeTransformArgFits,
1276
1288
  outcomeTransformError: () => outcomeTransformError,
1277
1289
  outcomeTransformFailure: () => outcomeTransformFailure,
1278
1290
  outcomeTransformFunction: () => outcomeTransformFunction,
@@ -1451,6 +1463,7 @@ __export(index_exports, {
1451
1463
  renameMenuItemId: () => renameMenuItemId,
1452
1464
  renameScreenMethodParamReads: () => renameScreenMethodParamReads,
1453
1465
  repairCallOutcome: () => repairCallOutcome,
1466
+ repairClassCallSites: () => repairClassCallSites,
1454
1467
  repairFieldCheckSignatures: () => repairFieldCheckSignatures,
1455
1468
  repairMarkdownLinkUrls: () => repairMarkdownLinkUrls,
1456
1469
  repairMessageVariables: () => repairMessageVariables,
@@ -1526,6 +1539,7 @@ __export(index_exports, {
1526
1539
  scaffoldFiles: () => scaffoldFiles,
1527
1540
  scanForCode: () => scanForCode,
1528
1541
  scannedOutputArms: () => scannedOutputArms,
1542
+ screenAutoCallDoesAnything: () => screenAutoCallDoesAnything,
1529
1543
  screenAutoCallError: () => screenAutoCallError,
1530
1544
  screenAutoCallWhen: () => screenAutoCallWhen,
1531
1545
  screenComponentSite: () => screenComponentSite,
@@ -1799,9 +1813,12 @@ __export(index_exports, {
1799
1813
  validationTest: () => validationTest,
1800
1814
  valueSourceOf: () => valueSourceOf,
1801
1815
  variableDrift: () => variableDrift,
1816
+ variantCheckCountable: () => variantCheckCountable,
1802
1817
  variantCheckError: () => variantCheckError,
1803
1818
  variantCheckId: () => variantCheckId,
1804
1819
  variantCheckLeaf: () => variantCheckLeaf,
1820
+ variantCheckOperand: () => variantCheckOperand,
1821
+ variantCheckOperatorFits: () => variantCheckOperatorFits,
1805
1822
  variantCheckOperators: () => variantCheckOperators,
1806
1823
  variantCheckType: () => variantCheckType,
1807
1824
  variantError: () => variantError,
@@ -1818,6 +1835,8 @@ __export(index_exports, {
1818
1835
  variantsForCode: () => variantsForCode,
1819
1836
  variantsForNewControl: () => variantsForNewControl,
1820
1837
  variantsReferencing: () => variantsReferencing,
1838
+ watchFields: () => watchFields,
1839
+ watchKey: () => watchKey,
1821
1840
  wcClassName: () => wcClassName,
1822
1841
  wcSelector: () => wcSelector,
1823
1842
  widgetDir: () => widgetDir,
@@ -1827,6 +1846,7 @@ __export(index_exports, {
1827
1846
  withCallArgOptional: () => withCallArgOptional,
1828
1847
  withCases: () => withCases,
1829
1848
  withDefaultRow: () => withDefaultRow,
1849
+ withDerivedWatch: () => withDerivedWatch,
1830
1850
  withEmittedTests: () => withEmittedTests,
1831
1851
  withEventTransform: () => withEventTransform,
1832
1852
  withFormShapes: () => withFormShapes,
@@ -1939,15 +1959,16 @@ var isLinkedKeySource = (source) => source.source === "input" || source.source =
1939
1959
  var isLinkedFormModel = (model) => Object.values(model.keys).some(isLinkedKeySource);
1940
1960
  var screenAutoCallWhen = (call) => call.when ?? (call.args.some((row) => row.source === "input") || (call.emits ?? []).some(isMovingScreenEmit) || !!call.reads?.length ? "on-change" : "once");
1941
1961
  var isMovingScreenEmit = (emit) => emit.value?.kind === "input" || emit.value?.kind === "binding";
1962
+ var screenAutoCallDoesAnything = (call) => !!call.methodId || !!call.emits?.length || !!call.writes?.length || !!call.screenWrites?.length || !!call.screenMethodId;
1942
1963
  var screenAutoCallError = (call) => {
1943
- if (!call.methodId && !call.emits?.length) return "auto-call-empty";
1964
+ if (!screenAutoCallDoesAnything(call)) return "auto-call-empty";
1944
1965
  if (screenAutoCallWhen(call) !== "on-change") return void 0;
1945
1966
  return call.args.some(
1946
1967
  (row) => row.source === "input" || row.source === "binding"
1947
1968
  ) || (call.emits ?? []).some(isMovingScreenEmit) || !!call.reads?.length ? void 0 : "auto-call-never-fires";
1948
1969
  };
1949
1970
  var isOutputSelfEmit = (call) => {
1950
- if (call.methodId || call.reads?.length || call.emits?.length !== 1)
1971
+ if (call.methodId || call.reads?.length || call.emits?.length !== 1 || call.writes?.length || call.screenWrites?.length || call.screenMethodId)
1951
1972
  return false;
1952
1973
  if (!call.emits[0].value) return false;
1953
1974
  const { when: _drop, ...derived } = call;
@@ -1969,6 +1990,30 @@ var withOutputSelfEmit = (calls, outputId, value, mintId) => {
1969
1990
  }
1970
1991
  ];
1971
1992
  };
1993
+ var withDerivedWatch = (calls, inputs = {}) => calls.map((call) => {
1994
+ if (screenAutoCallWhen(call) !== "on-change" || isOutputSelfEmit(call))
1995
+ return call;
1996
+ const inputRead = (id) => id ? { root: { kind: "input", id }, path: [] } : void 0;
1997
+ const derived = [
1998
+ ...call.args.map(
1999
+ (row) => row.source === "input" ? inputRead(
2000
+ Object.values(inputs).find((one) => one.name === row.input)?.id
2001
+ ) : row.source === "binding" ? row.binding : void 0
2002
+ ),
2003
+ ...(call.emits ?? []).map(
2004
+ (emit) => emit.value?.kind === "input" ? inputRead(emit.value.inputId) : emit.value?.kind === "binding" ? emit.value.binding : void 0
2005
+ )
2006
+ ];
2007
+ const reads = [...call.reads ?? []];
2008
+ const seen = new Set(reads.map((read) => JSON.stringify(read)));
2009
+ for (const read of derived) {
2010
+ if (!read || seen.has(JSON.stringify(read))) continue;
2011
+ seen.add(JSON.stringify(read));
2012
+ reads.push(read);
2013
+ }
2014
+ return reads.length === (call.reads ?? []).length ? call : { ...call, reads };
2015
+ });
2016
+ var isReactionAutoCall = (call) => !!call.reads?.length || !!call.writes?.length || !!call.screenWrites?.length || !!call.screenMethodId;
1972
2017
  var splitAutoCallEmits = (calls, inputs = {}) => {
1973
2018
  const result = [];
1974
2019
  const selfFired = /* @__PURE__ */ new Set();
@@ -1982,7 +2027,7 @@ var splitAutoCallEmits = (calls, inputs = {}) => {
1982
2027
  };
1983
2028
  for (const call of calls) {
1984
2029
  const emits = call.emits ?? [];
1985
- if (!emits.length || !call.methodId && emits.length === 1) {
2030
+ if (!emits.length || !call.methodId && emits.length === 1 || isReactionAutoCall(call)) {
1986
2031
  push(call);
1987
2032
  continue;
1988
2033
  }
@@ -5241,7 +5286,9 @@ var screenMethodCalls = (method) => method ? [
5241
5286
  {
5242
5287
  methodId: method.methodId,
5243
5288
  functionId: method.functionId,
5244
- args: method.args
5289
+ args: method.args,
5290
+ // The handler's own call's settling (ADR 0219), filed on the handler.
5291
+ ...method.outcome ? { outcome: method.outcome } : {}
5245
5292
  },
5246
5293
  ...method.calls ?? []
5247
5294
  ] : [];
@@ -5249,6 +5296,7 @@ var screenMethodCalls = (method) => method ? [
5249
5296
  // libs/codegen/src/model/one-function-catalog.ts
5250
5297
  var ONE_FUNCTION_ID_PARAM = "id";
5251
5298
  var ONE_FUNCTION_IDS_PARAM = "ids";
5299
+ var ONE_FUNCTION_IDS_MAP_PARAM = "idsMap";
5252
5300
  var ONE_FUNCTION_MAP_PARAM = "map";
5253
5301
  var ONE_FUNCTION_DATA_PARAM = "data";
5254
5302
  var ONE_FUNCTION_KEY_PARAM = "key";
@@ -5289,6 +5337,25 @@ var ONE_FUNCTION_SPECS = {
5289
5337
  ],
5290
5338
  returns: { type: "T", cardinality: "many", liftsTo: "many" }
5291
5339
  },
5340
+ // `getManyViaMap<T>(id, idsMap: Record<string, string[]>, map:
5341
+ // Record<string, T>): T[]` — `getManyFromMaps` over the ids `idsMap` lists
5342
+ // under one id: a strategy's holding ids, then each holding. Over a
5343
+ // `map-many` its return stays `many`, every id's list joined, as
5344
+ // `getManyFromMaps`' does.
5345
+ getManyViaMap: {
5346
+ params: [
5347
+ ID,
5348
+ {
5349
+ id: ONE_FUNCTION_IDS_MAP_PARAM,
5350
+ name: "idsMap",
5351
+ type: "string",
5352
+ cardinality: "map-many",
5353
+ statePathOnly: true
5354
+ },
5355
+ MAP
5356
+ ],
5357
+ returns: { type: "T", cardinality: "many", liftsTo: "many" }
5358
+ },
5292
5359
  // `existsInMap(id, map: Record<string, unknown>): boolean` — whether a
5293
5360
  // `map` holds anything under an id (ADR 0202). `false` rather than
5294
5361
  // `undefined` while either is, so a gate on an unloaded store reads "not
@@ -5380,6 +5447,57 @@ var ONE_FUNCTION_SPECS = {
5380
5447
  returns: { type: "T", cardinality: "map-many" },
5381
5448
  narrowTo: ["outcome-transform"]
5382
5449
  },
5450
+ // `extendMap<T>(data: T[], key: keyof T, map: Record<string, T>):
5451
+ // Record<string, T>` — a flat list of rows landed into a `map`, each row
5452
+ // held under its `key` member: `loadCoins()` answers a list, each row
5453
+ // naming itself in `id`. A row the map already holds is extended — its
5454
+ // members merged over the held row's — and every other entry is kept. The
5455
+ // key is picked from the row's `string` / `number` members.
5456
+ extendMap: {
5457
+ params: [
5458
+ {
5459
+ id: ONE_FUNCTION_DATA_PARAM,
5460
+ name: "data",
5461
+ type: "T",
5462
+ cardinality: "many"
5463
+ },
5464
+ {
5465
+ id: ONE_FUNCTION_KEY_PARAM,
5466
+ name: "key",
5467
+ type: "string",
5468
+ cardinality: "one"
5469
+ },
5470
+ MAP
5471
+ ],
5472
+ returns: { type: "T", cardinality: "map" },
5473
+ narrowTo: ["outcome-transform"]
5474
+ },
5475
+ // `setPluckedInMap<T>(id, data: T[], key: string, map: Record<string,
5476
+ // string[]>): Record<string, string[]>` — the `key` member of each row of
5477
+ // one id's list landed as that id's list of ids: `loadHoldings(sid)`
5478
+ // answers a strategy's holdings, `holdingIdsById[sid]` takes their ids.
5479
+ // The list under `id` is replaced, every other entry kept. The key is
5480
+ // picked from the row's `string` / `number` members like `extendMap`'s.
5481
+ setPluckedInMap: {
5482
+ params: [
5483
+ ID,
5484
+ {
5485
+ id: ONE_FUNCTION_DATA_PARAM,
5486
+ name: "data",
5487
+ type: "T",
5488
+ cardinality: "many"
5489
+ },
5490
+ {
5491
+ id: ONE_FUNCTION_KEY_PARAM,
5492
+ name: "key",
5493
+ type: "string",
5494
+ cardinality: "one"
5495
+ },
5496
+ { ...MAP, type: "string", cardinality: "map-many" }
5497
+ ],
5498
+ returns: { type: "string", cardinality: "map-many" },
5499
+ narrowTo: ["outcome-transform"]
5500
+ },
5383
5501
  // `pluckStrings<T>(items: T[], key: string): string[]` — the `string`
5384
5502
  // values one member of each row holds, in row order: the ids of a list a
5385
5503
  // later lookup reads by. `key` is typed in like `mapMany`'s, prefilled with
@@ -5442,7 +5560,9 @@ var lifts = (spec) => slots(spec).some((slot) => slot.type === "T") && slots(spe
5442
5560
  var liftOf = (slot) => slot.liftsTo ?? LIFT[slot.cardinality];
5443
5561
  var liftedCardinality = (slot, lifted) => lifted && slot.type === "T" ? liftOf(slot) ?? slot.cardinality : slot.cardinality;
5444
5562
  var slotDataType = (slot, row) => slot.type === "T" ? row : { type: slot.type };
5445
- var oneFunctionSiteFits = (spec, reach) => reach === "call-condition" ? spec.returns.type === "boolean" && spec.returns.cardinality === "one" : reach === "outcome-transform" ? spec.returns.type === "T" : true;
5563
+ var oneFunctionSiteFits = (spec, reach) => reach === "call-condition" ? spec.returns.type === "boolean" && spec.returns.cardinality === "one" : reach === "outcome-transform" ? spec.returns.type === "T" || (spec.returns.cardinality === "many" || spec.returns.cardinality === "map-many") && spec.params.some(
5564
+ (param) => param.type === "T" && param.cardinality === "many"
5565
+ ) : true;
5446
5566
  var REACHES = [
5447
5567
  "screen-computed",
5448
5568
  "state-computed",
@@ -5513,7 +5633,8 @@ var liftedBy = (entry2, paramId, cardinality) => {
5513
5633
  return !!param?.liftsTo && cardinality === param.liftsTo;
5514
5634
  };
5515
5635
  var oneFunctionLiftedAt = (entry2, cardinality) => entry2.returnsRow && !!entry2.params.some((param) => param.liftsTo) && cardinality !== entry2.returns.cardinality && cardinality === liftOf(entry2.returns);
5516
- var oneFunctionFitsLanding = (entry2, cardinality) => entry2.returnsRow && (cardinality === entry2.returns.cardinality || oneFunctionLiftedAt(entry2, cardinality));
5636
+ var oneFunctionFitsLanding = (entry2, landing) => entry2.returnsRow ? landing.cardinality === entry2.returns.cardinality || oneFunctionLiftedAt(entry2, landing.cardinality) : landing.dataType?.type === entry2.returns.type && landing.cardinality === entry2.returns.cardinality;
5637
+ var oneParamTakesAnyRow = (entry2, param) => !entry2.returnsRow && param.type === "T";
5517
5638
  var oneFunctionMintsKey = (entry2) => entry2.returnsRow && (entry2.returns.cardinality === "map" || entry2.returns.cardinality === "map-many");
5518
5639
  function oneFunctionReturns(entry2, row, heldCardinality) {
5519
5640
  const signature = entry2.signature(
@@ -6886,6 +7007,13 @@ function outcomeTransformFunction(transform, landing, functions) {
6886
7007
  cardinality: landing.cardinality
6887
7008
  });
6888
7009
  }
7010
+ function outcomeTransformArgFits(transform, index, held, heldShapes, param, shapes) {
7011
+ const one = outcomeTransformOneFunction(transform);
7012
+ const slot = one?.params[index];
7013
+ if (one && slot && oneParamTakesAnyRow(one, slot))
7014
+ return !!held.dataType && held.cardinality === param.cardinality;
7015
+ return dataTypeFits(held, heldShapes, param, shapes);
7016
+ }
6889
7017
  var statePathValue = (path, roots, shapes) => {
6890
7018
  const [propertyId, ...keys] = path;
6891
7019
  const property = roots[propertyId];
@@ -7039,7 +7167,9 @@ function outcomeTransformFailure(mapping, method, op, properties, shapes, functi
7039
7167
  detail: `${label} \u2014 ${bindingLabel(binding)}`
7040
7168
  };
7041
7169
  }
7042
- if (!dataTypeFits(
7170
+ if (!outcomeTransformArgFits(
7171
+ transform,
7172
+ index,
7043
7173
  source.value,
7044
7174
  source.shapes,
7045
7175
  { dataType: param.dataType, cardinality: param.cardinality },
@@ -8043,6 +8173,39 @@ var bindingPathKey = (binding) => {
8043
8173
  const head = root.kind === "alias" ? `alias:${root.repeatId}:${root.alias}` : root.kind === "auth" ? `${root.kind}:${root.property}` : root.kind === "none" ? root.kind : `${root.kind}:${root.id}`;
8044
8174
  return binding.path.length ? `${head}.${binding.path.join(".")}` : head;
8045
8175
  };
8176
+ var watchKey = (binding, scope) => {
8177
+ if (binding.path.length || binding.transform) return void 0;
8178
+ const root = binding.root;
8179
+ if (root.kind === "input") return scope.inputs?.[root.id]?.name;
8180
+ if (root.kind === "screen_computed")
8181
+ return scope.screenComputeds?.[root.id]?.name;
8182
+ if (root.kind === "screen_variable") return scope.variables?.[root.id]?.name;
8183
+ if (root.kind === "property" || root.kind === "computed")
8184
+ return scope.properties?.[root.id]?.name;
8185
+ return void 0;
8186
+ };
8187
+ var watchFields = (reads, scope) => {
8188
+ const keys = [];
8189
+ const fields = {};
8190
+ for (const binding of reads ?? []) {
8191
+ const key2 = watchKey(binding, scope);
8192
+ if (!key2 || keys.includes(key2)) continue;
8193
+ keys.push(key2);
8194
+ const root = binding.root;
8195
+ const held = root.kind === "input" ? scope.inputs?.[root.id] : root.kind === "property" ? scope.properties?.[root.id] : void 0;
8196
+ if (held) {
8197
+ fields[key2] = { dataType: held.dataType, cardinality: held.cardinality };
8198
+ } else if (root.kind === "screen_variable") {
8199
+ const variable = scope.variables?.[root.id];
8200
+ if (variable)
8201
+ fields[key2] = {
8202
+ dataType: screenVariableDataType(variable),
8203
+ cardinality: variable.cardinality
8204
+ };
8205
+ }
8206
+ }
8207
+ return { keys, fields };
8208
+ };
8046
8209
 
8047
8210
  // libs/codegen/src/model/global-rule-catalog.ts
8048
8211
  var GLOBAL_RULE_STORES = {
@@ -9044,6 +9207,12 @@ var rootShapeId = (binding, scope, seen) => {
9044
9207
  seen.add(root.repeatId);
9045
9208
  const holder = scope.controlMap?.[root.repeatId];
9046
9209
  const source = holder?.bindings?.[aliasSourceSlot(holder)];
9210
+ if (source && holder?.type === "repeat" /* REPEAT */ && isObjectRepeatSource(source, scope, seen)) {
9211
+ return objectMemberShapeId(
9212
+ bindingShapeId(source, scope, seen),
9213
+ shapesOf(scope)
9214
+ );
9215
+ }
9047
9216
  if (source) return bindingShapeId(source, scope, seen);
9048
9217
  return holder?.type === "list" /* LIST */ && toListItemRows(holder.configs?.[LIST_ITEMS_KEY]).length ? LIST_ROW_SHAPE_ID : void 0;
9049
9218
  }
@@ -9189,8 +9358,19 @@ var bindingCardinality = (binding, scope, seen = /* @__PURE__ */ new Set()) => {
9189
9358
  var isKeyedRepeat = (control, scope) => {
9190
9359
  if (control.type !== "repeat" /* REPEAT */) return false;
9191
9360
  const source = control.bindings?.[BINDING_SLOT.source];
9192
- return !!source && isMapCardinality(bindingCardinality(source, scope));
9193
- };
9361
+ if (!source) return false;
9362
+ return isMapCardinality(bindingCardinality(source, scope)) || isObjectRepeatSource(source, scope);
9363
+ };
9364
+ var objectMemberShapeId = (shapeId, shapes) => {
9365
+ const keys = shapeId ? shapes[shapeId]?.keys : void 0;
9366
+ if (!keys?.length) return void 0;
9367
+ const first = keys[0].dataType;
9368
+ const memberShapeId = first?.type === "shape" ? first.shapeId : void 0;
9369
+ return memberShapeId && keys.every(
9370
+ (key2) => key2.cardinality === "one" && key2.dataType?.type === "shape" && key2.dataType.shapeId === memberShapeId
9371
+ ) ? memberShapeId : void 0;
9372
+ };
9373
+ var isObjectRepeatSource = (source, scope, seen = /* @__PURE__ */ new Set()) => bindingCardinality(source, scope, new Set(seen)) === "one" && !!bindingShapeId(source, scope, new Set(seen));
9194
9374
  var aliasDisplayName = (repeatId, alias, scope) => {
9195
9375
  const holder = scope.controlMap?.[repeatId];
9196
9376
  const spec = aliasNames(holder);
@@ -9649,6 +9829,9 @@ var holderRowShapeId = (holder, scope, seen = /* @__PURE__ */ new Set()) => {
9649
9829
  scope,
9650
9830
  holder ? /* @__PURE__ */ new Set([...seen, holder.id]) : seen
9651
9831
  );
9832
+ if (holder && isObjectRepeat(holder, scope)) {
9833
+ return objectMemberShapeId(shapeId, scope.shapes);
9834
+ }
9652
9835
  if (shapeId) return shapeId;
9653
9836
  return holder?.type === "list" /* LIST */ && toListItemRows(holder.configs?.[LIST_ITEMS_KEY]).length ? LIST_ROW_SHAPE_ID : void 0;
9654
9837
  };
@@ -9662,6 +9845,10 @@ var asBindingScope = (scope) => ({
9662
9845
  functions: scope.functions,
9663
9846
  controlMap: scope.controlMap
9664
9847
  });
9848
+ var isObjectRepeat = (holder, scope) => {
9849
+ const source = holder.bindings?.[aliasSourceSlot(holder)];
9850
+ return holder.type === "repeat" /* REPEAT */ && !!source && isObjectRepeatSource(source, asBindingScope(scope));
9851
+ };
9665
9852
  var holderSourceCardinality = (holder, scope) => {
9666
9853
  const source = holder.bindings?.[aliasSourceSlot(holder)];
9667
9854
  return source ? bindingCardinality(source, asBindingScope(scope)) : void 0;
@@ -9674,7 +9861,7 @@ var aliasRoots = (scope) => {
9674
9861
  const spec = aliasNames(holder);
9675
9862
  const rowShapeId = holderRowShapeId(holder, scope);
9676
9863
  const sourceCardinality = holder.type === "repeat" /* REPEAT */ ? holderSourceCardinality(holder, scope) : void 0;
9677
- const keyed = sourceCardinality === "map" || sourceCardinality === "map-many";
9864
+ const keyed = sourceCardinality === "map" || sourceCardinality === "map-many" || isObjectRepeat(holder, scope);
9678
9865
  return [
9679
9866
  {
9680
9867
  root: {
@@ -13898,7 +14085,15 @@ function shapeMemberDiff(spec, specShapes, twin, shapes) {
13898
14085
  continue;
13899
14086
  }
13900
14087
  const ours = typeLabel(mine.dataType, mine.cardinality, shapes);
13901
- if (ours !== theirs) details.push(`${key2.name}: ${ours} \u2192 ${theirs}`);
14088
+ const sameNestedShape = mine.dataType?.type === "shape" && key2.dataType?.type === "shape" && mine.cardinality === key2.cardinality && dataTypeFits(
14089
+ mine,
14090
+ shapes,
14091
+ key2,
14092
+ specShapes
14093
+ ) && dataTypeFits(key2, specShapes, mine, shapes);
14094
+ if (!sameNestedShape && ours !== theirs) {
14095
+ details.push(`${key2.name}: ${ours} \u2192 ${theirs}`);
14096
+ }
13902
14097
  }
13903
14098
  const answered = new Set(spec.keys.map((key2) => key2.name));
13904
14099
  for (const key2 of twin.keys) {
@@ -14038,7 +14233,7 @@ function importShapes(dataType, from, existing, mintId, overwriteExisting = fals
14038
14233
  ])
14039
14234
  );
14040
14235
  const pool = () => ({ ...reachable, ...shapes });
14041
- const importOne = (shapeId, held) => {
14236
+ const importOne = (shapeId, held, parentId) => {
14042
14237
  if (reachable[shapeId] && from[shapeId] === reachable[shapeId]) {
14043
14238
  return shapeId;
14044
14239
  }
@@ -14072,9 +14267,16 @@ function importShapes(dataType, from, existing, mintId, overwriteExisting = fals
14072
14267
  )?.id;
14073
14268
  const kept = overwriteExisting && held && candidates[held] ? held : void 0;
14074
14269
  const reused = byOrigin ?? kept ?? structural ?? named;
14075
- if (reused && (!overwriteExisting || reachable[reused])) return reused;
14076
- const id2 = reused ?? mintId();
14077
- const heldKeys = shapes[id2]?.keys ?? [];
14270
+ const copiedForOtherParent = overwriteExisting && !!held && !!parentId && Object.values(candidates).some(
14271
+ (parent) => parent.id !== parentId && parent.keys.some(
14272
+ (key2) => key2.dataType?.type === "shape" && key2.dataType.shapeId === held
14273
+ )
14274
+ );
14275
+ if (!copiedForOtherParent && reused && (!overwriteExisting || reachable[reused])) {
14276
+ return reused;
14277
+ }
14278
+ const id2 = copiedForOtherParent ? mintId() : reused ?? mintId();
14279
+ const heldKeys = overwriteExisting && held ? shapes[held]?.keys ?? [] : shapes[id2]?.keys ?? [];
14078
14280
  byName.set(source.name, id2);
14079
14281
  const shape = {
14080
14282
  id: id2,
@@ -14094,7 +14296,8 @@ function importShapes(dataType, from, existing, mintId, overwriteExisting = fals
14094
14296
  const heldKey = heldKeys.find((k) => k.name === key2.name);
14095
14297
  const nested = importOne(
14096
14298
  key2.dataType.shapeId,
14097
- heldKey?.dataType.type === "shape" ? heldKey.dataType.shapeId : void 0
14299
+ heldKey?.dataType.type === "shape" ? heldKey.dataType.shapeId : void 0,
14300
+ id2
14098
14301
  );
14099
14302
  if (!nested) continue;
14100
14303
  shape.keys.push({
@@ -15829,21 +16032,44 @@ function variantCheckType(check, method, op, roots, shapes, functions) {
15829
16032
  );
15830
16033
  return inferred.ok ? inferred.type : void 0;
15831
16034
  }
16035
+ var PRIMITIVES2 = ["string", "number", "boolean"];
15832
16036
  function variantCheckLeaf(type) {
15833
16037
  if (!type || type.cardinality !== "one") return void 0;
15834
16038
  return type.dataType.type === "shape" ? void 0 : type.dataType.type;
15835
16039
  }
15836
- var variantCheckOperators = (type) => operatorsFor(variantCheckLeaf(type), false, !!type);
16040
+ var variantCheckCountable = (type) => type?.cardinality === "many";
16041
+ var LIST_OPERATORS = ["contains", "not_contains"];
16042
+ var variantCheckOperators = (type, count = false) => {
16043
+ if (count && variantCheckCountable(type)) return operatorsFor(void 0, true);
16044
+ if (type?.cardinality === "many") {
16045
+ const unary = operatorsFor(void 0, false, true);
16046
+ return PRIMITIVES2.includes(type.dataType.type) ? [...LIST_OPERATORS, ...unary] : unary;
16047
+ }
16048
+ return operatorsFor(variantCheckLeaf(type), false, !!type);
16049
+ };
16050
+ var variantCheckOperand = (type, count = false) => {
16051
+ if (!type) return void 0;
16052
+ if (count && variantCheckCountable(type)) {
16053
+ return { dataType: { type: "number" }, cardinality: "one" };
16054
+ }
16055
+ return type.cardinality === "many" ? { ...type, cardinality: "one" } : type;
16056
+ };
16057
+ var variantCheckOperatorFits = (check, type) => (!check.count || variantCheckCountable(type)) && variantCheckOperators(type, !!check.count).includes(check.operator);
15837
16058
  function variantCheckError(check, method, op, roots, shapes, functions) {
15838
16059
  const unsourced = check.source === "store" && !check.path?.length || check.source === "args" && !check.arg || check.source === "compute" && !check.compute || check.source === "response" && !check.code;
15839
16060
  if (unsourced) return "variant-check-no-source";
15840
16061
  const type = variantCheckType(check, method, op, roots, shapes, functions);
15841
16062
  if (!type) return "variant-check-bad-transform";
15842
- if (!variantCheckOperators(type).includes(check.operator)) {
16063
+ if (!variantCheckOperatorFits(check, type)) {
15843
16064
  return "variant-check-bad-operator";
15844
16065
  }
15845
16066
  if (isUnaryOperator(check.operator)) return void 0;
15846
- return validateLiteral(check.value ?? "", type.dataType, type.cardinality);
16067
+ const operand = variantCheckOperand(type, check.count) ?? type;
16068
+ return validateLiteral(
16069
+ check.value ?? "",
16070
+ operand.dataType,
16071
+ operand.cardinality
16072
+ );
15847
16073
  }
15848
16074
  function variantError(variant, method, op, roots, shapes, functions) {
15849
16075
  if (variantNameError(method, variant.name, variant.id)) {
@@ -15866,13 +16092,18 @@ function landsUnconditionally(mapping) {
15866
16092
  return !mapping.landsWhen;
15867
16093
  }
15868
16094
  function generateVariantCheckExpression(check, subject, type, optional = false) {
15869
- if (isUnaryOperator(check.operator)) {
16095
+ const counted = !!check.count && variantCheckCountable(type);
16096
+ if (isUnaryOperator(check.operator) && !counted) {
15870
16097
  return comparisonSource(subject, check.operator, "");
15871
16098
  }
16099
+ const left = counted ? optional ? `(${subject}?.length ?? 0)` : `${subject}.length` : !optional ? subject : type?.cardinality === "many" ? `(${subject} ?? [])` : guardOptional(subject, check.operator);
15872
16100
  return comparisonSource(
15873
- optional ? guardOptional(subject, check.operator) : subject,
16101
+ left,
15874
16102
  check.operator,
15875
- literalExpression(check.value ?? "", operandDataType(type))
16103
+ literalExpression(
16104
+ check.value ?? "",
16105
+ operandDataType(variantCheckOperand(type, check.count))
16106
+ )
15876
16107
  );
15877
16108
  }
15878
16109
  var operandDataType = (type) => type && type.dataType.type !== "shape" ? type.dataType : { type: "string" };
@@ -15928,11 +16159,16 @@ function checkError2(check, args, properties, shapes, computes, functions) {
15928
16159
  functions
15929
16160
  );
15930
16161
  if (!type) return "condition-check-subject";
15931
- if (!variantCheckOperators(type).includes(check.operator)) {
16162
+ if (!variantCheckOperatorFits(check, type)) {
15932
16163
  return "condition-check-operator";
15933
16164
  }
15934
16165
  if (isUnaryOperator(check.operator)) return void 0;
15935
- return validateLiteral(check.value ?? "", type.dataType, type.cardinality) ? "condition-check-value" : void 0;
16166
+ const operand = variantCheckOperand(type, check.count) ?? type;
16167
+ return validateLiteral(
16168
+ check.value ?? "",
16169
+ operand.dataType,
16170
+ operand.cardinality
16171
+ ) ? "condition-check-value" : void 0;
15936
16172
  }
15937
16173
  function conditionError(condition, args, functions, properties, shapes, computes = []) {
15938
16174
  const valueOf = (binding) => conditionArgValue(binding, args, properties, shapes, computes, functions);
@@ -16363,7 +16599,7 @@ var refReaches = (button, buttonChain, form, controls) => {
16363
16599
  const buttonSide = armChildOf(scope.id, button, controls);
16364
16600
  return !!formSide && !!buttonSide && projectionSlotOf(formSide) === projectionSlotOf(buttonSide);
16365
16601
  };
16366
- var queryReaches = (form, controls) => ![form, ...ancestors(form, controls)].some(
16602
+ var formQueryReaches = (form, controls) => ![form, ...ancestors(form, controls)].some(
16367
16603
  (node) => isRepeatFamily(node.type) || node.type === "content" /* CONTENT */
16368
16604
  );
16369
16605
  var accessTo = (button, form, controls) => {
@@ -16373,7 +16609,7 @@ var accessTo = (button, form, controls) => {
16373
16609
  ...ancestors(button, controls).map((parent) => parent.id)
16374
16610
  ]);
16375
16611
  if (refReaches(button, buttonChain, form, controls)) return "ref";
16376
- return queryReaches(form, controls) ? "query" : void 0;
16612
+ return formQueryReaches(form, controls) ? "query" : void 0;
16377
16613
  };
16378
16614
  function submitTargetForms(button, controls) {
16379
16615
  if (!canNameSubmitTarget(button, controls)) return [];
@@ -16432,8 +16668,18 @@ function formResetRows(outcomes, key2, arm) {
16432
16668
  function hasCallOutcome(outcome) {
16433
16669
  return OUTCOME_ARMS.some((arm) => armHasRows(outcome?.[arm]));
16434
16670
  }
16671
+ function nestedOutcomeCalls(outcome) {
16672
+ return OUTCOME_ARMS.flatMap(
16673
+ (arm) => (outcome?.[arm]?.calls ?? []).flatMap(
16674
+ (call) => OUTCOME_ARMS.flatMap(
16675
+ (inner) => (call.outcome?.[inner]?.calls ?? []).map((nested) => nested.id)
16676
+ )
16677
+ )
16678
+ );
16679
+ }
16435
16680
  function armHasRows(arm) {
16436
- return !!(arm?.writes?.length || arm?.screenWrites?.length || arm?.formResets?.length || arm?.closesOverlay || arm?.nav || isOutcomeReportDrawn(arm?.report) || arm?.dialog);
16681
+ return !!(arm?.writes?.length || arm?.screenWrites?.length || // An arm that only tells the host something happened is an arm (ADR 0143).
16682
+ arm?.emits?.length || arm?.formResets?.length || arm?.closesOverlay || arm?.nav || isOutcomeReportDrawn(arm?.report) || arm?.dialog || arm?.calls?.some((call) => !!call.methodId || !!call.screenMethodId));
16437
16683
  }
16438
16684
  function denialDialogOf(arm) {
16439
16685
  const dialog = arm?.dialog;
@@ -16442,17 +16688,46 @@ function denialDialogOf(arm) {
16442
16688
  function setArmDialog(arm, dialog) {
16443
16689
  return { ...arm ?? {}, dialog };
16444
16690
  }
16445
- function denialTranslationKeys(controls) {
16446
- return Object.values(controls).flatMap((control) => [
16447
- ...Object.values(control.outputOutcomes ?? {})
16448
- ]).flatMap((outcome) => {
16691
+ function controlWireOutcomes(control) {
16692
+ return Object.values(control.outputOpens ?? {}).flatMap(
16693
+ (open) => Object.values(open?.outputs ?? {}).map((wire) => ({
16694
+ methodId: wire?.binding?.methodId,
16695
+ outcome: wire?.outcome
16696
+ }))
16697
+ );
16698
+ }
16699
+ function classCallOutcomes(sites) {
16700
+ return [
16701
+ ...Object.values(sites.methods ?? {}).flatMap(
16702
+ (handler) => screenMethodCalls(handler).map((one) => ({
16703
+ methodId: one.methodId,
16704
+ outcome: one.outcome
16705
+ }))
16706
+ ),
16707
+ ...(sites.autoCalls ?? []).map((call) => ({
16708
+ methodId: call.methodId,
16709
+ outcome: call.outcome
16710
+ }))
16711
+ ];
16712
+ }
16713
+ function denialTranslationKeys(controls, sites = []) {
16714
+ return [
16715
+ ...Object.values(controls).flatMap((control) => [
16716
+ ...Object.values(control.outputOutcomes ?? {}),
16717
+ ...controlWireOutcomes(control).map((entry2) => entry2.outcome)
16718
+ ]),
16719
+ ...sites.flatMap(
16720
+ (site) => classCallOutcomes(site).map((entry2) => entry2.outcome)
16721
+ )
16722
+ ].flatMap((outcome) => {
16449
16723
  const dialog = outcome?.denied?.dialog;
16450
16724
  return dialog ? [dialog.header, dialog.body, dialog.confirmLabel] : [];
16451
16725
  }).filter((value) => !!value && !!value.trim()).map((value) => parseLabelValue(value).key).filter((key2) => !!key2);
16452
16726
  }
16453
16727
  function controlDrawsDenial(control) {
16454
16728
  return [
16455
- ...Object.values(control.outputOutcomes ?? {})
16729
+ ...Object.values(control.outputOutcomes ?? {}),
16730
+ ...controlWireOutcomes(control).map((entry2) => entry2.outcome)
16456
16731
  ].some((outcome) => armHasRows(outcome?.denied));
16457
16732
  }
16458
16733
  function isOutcomeReportDrawn(report) {
@@ -16575,7 +16850,34 @@ function repairCallOutcome(controls, outcome, constantIds = /* @__PURE__ */ new
16575
16850
  }
16576
16851
  return moved ? repaired : void 0;
16577
16852
  }
16578
- function methodArms(controlMaps) {
16853
+ function repairClassCallSites(controls, sites) {
16854
+ let moved = false;
16855
+ const fix = (outcome) => {
16856
+ if (!outcome) return void 0;
16857
+ const next = repairCallOutcome(controls, outcome);
16858
+ if (!next) return outcome;
16859
+ moved = true;
16860
+ return hasCallOutcome(next) ? next : void 0;
16861
+ };
16862
+ const strip = (entry2) => {
16863
+ const outcome = fix(entry2.outcome);
16864
+ if (outcome === entry2.outcome) return entry2;
16865
+ const { outcome: _drop, ...rest } = entry2;
16866
+ return outcome ? { ...rest, outcome } : rest;
16867
+ };
16868
+ const methods = sites.methods ? Object.fromEntries(
16869
+ Object.entries(sites.methods).map(([id, handler]) => {
16870
+ const own = strip(handler);
16871
+ return [
16872
+ id,
16873
+ handler.calls ? { ...own, calls: handler.calls.map(strip) } : own
16874
+ ];
16875
+ })
16876
+ ) : void 0;
16877
+ const autoCalls = sites.autoCalls?.map(strip);
16878
+ return moved ? { methods, autoCalls } : void 0;
16879
+ }
16880
+ function methodArms(controlMaps, sites = []) {
16579
16881
  const arms = {};
16580
16882
  const mark = (methodId, outcome) => {
16581
16883
  if (!methodId) return;
@@ -16593,6 +16895,14 @@ function methodArms(controlMaps) {
16593
16895
  )) {
16594
16896
  mark(control.outputs?.[output], outcome);
16595
16897
  }
16898
+ for (const { methodId, outcome } of controlWireOutcomes(control)) {
16899
+ if (outcome) mark(methodId, outcome);
16900
+ }
16901
+ }
16902
+ }
16903
+ for (const site of sites) {
16904
+ for (const { methodId, outcome } of classCallOutcomes(site)) {
16905
+ if (outcome) mark(methodId, outcome);
16596
16906
  }
16597
16907
  }
16598
16908
  return arms;
@@ -17155,7 +17465,7 @@ function patchLiteral(mappings, properties, shapes, functions, subject, cast = f
17155
17465
  );
17156
17466
  if (!fn) return void 0;
17157
17467
  const one = oneFunctionOf(mapping.transform.oneFunction);
17158
- const typeArgs = one && !one.spell ? `<${spell(
17468
+ const typeArgs = one && !one.spell && one.returnsRow ? `<${spell(
17159
17469
  property.dataType,
17160
17470
  oneFunctionLiftedAt(one, property.cardinality) ? "many" : "one"
17161
17471
  )}>` : "";
@@ -17490,9 +17800,43 @@ function emissionLookup(list, operationOf, shapes) {
17490
17800
  function emissionShapeLookup(methods, operationOf, shapes) {
17491
17801
  return emissionLookup(Object.values(methods), operationOf, shapes);
17492
17802
  }
17803
+ function methodSpecShapes(methods, operationOf, shapes) {
17804
+ const ops = Object.values(methods).filter((method) => !isCacheMethod(method)).map(operationOf).filter((op) => !!op);
17805
+ const taken = new Set(
17806
+ Object.values(shapes).map((shape) => shapeInterfaceName(shape.name))
17807
+ );
17808
+ const from = specShapeMap(ops);
17809
+ const offered = {};
17810
+ for (const shape of Object.values(from)) {
17811
+ const name3 = shapeInterfaceName(shape.name);
17812
+ if (taken.has(name3)) continue;
17813
+ taken.add(name3);
17814
+ offered[shape.id] = shape;
17815
+ }
17816
+ return { offered, from };
17817
+ }
17493
17818
  function partitionReferencedShapes(roots, lookup, shapes) {
17494
17819
  return partitionShapes(roots, lookup, shapes, false);
17495
17820
  }
17821
+ function declaredPayload(dataType, cardinality, specShapes, shapes) {
17822
+ const lookup = { ...specShapes, ...shapes };
17823
+ const head = `// ${tsTypeExpression(lookup, dataType, cardinality)}`;
17824
+ if (dataType?.type !== "shape") return head;
17825
+ const { drawn, spec } = partitionShapes([dataType.shapeId], lookup, shapes);
17826
+ const drawnIds = reachableShapes(
17827
+ drawn.map((shape) => shape.id),
17828
+ shapes
17829
+ );
17830
+ const declare = (shape, where) => `// ${shape.name} \u2014 ${where}
17831
+ ${generateShapeInterface(lookup, shape, {
17832
+ imports: false
17833
+ })}`;
17834
+ return [
17835
+ head,
17836
+ ...spec.map((shape) => declare(shape, "api type")),
17837
+ ...drawnIds.map((id) => shapes[id]).sort((a, b) => a.name.localeCompare(b.name)).map((shape) => declare(shape, `StateShape (${TYPE_SEGMENT}/${shape.name})`))
17838
+ ].join("\n");
17839
+ }
17496
17840
  function signatureShapeIds2(list, operationOf) {
17497
17841
  const used = /* @__PURE__ */ new Set();
17498
17842
  for (const method of list) {
@@ -23296,7 +23640,7 @@ function tagAttrs(node, ctx, storeProp) {
23296
23640
  }
23297
23641
  if (node.type === "form" /* FORM */) {
23298
23642
  const member = validationMemberFor(node, ctx);
23299
- const ref = formRefNames(ctx.controlMap ?? {}).get(node.id);
23643
+ const ref = formRefNames(ctx.controlMap ?? {}).get(node.id) ?? (classResetForms(ctx).some((form) => form.id === node.id) ? formRefName(node) : void 0);
23300
23644
  return `${ref ? ` #${ref}` : ""}${inlineAttrs(node)}${member ? ` [validation]="${member}"` : ""}${boundAttrs(node, ctx, storeProp)}`;
23301
23645
  }
23302
23646
  const submitReads = submitTargetReads(node, ctx);
@@ -24677,6 +25021,223 @@ var localBase2 = (binding, scope) => {
24677
25021
  (segment, index) => index === 0 ? segment.charAt(0).toLowerCase() + segment.slice(1) : segment.charAt(0).toUpperCase() + segment.slice(1)
24678
25022
  ).join("");
24679
25023
  };
25024
+ var resetTargetMember = (form) => `${formRefName(form).replace(/Ref$/, "")}ResetTarget`;
25025
+ function classResetForms(ctx) {
25026
+ const controls = ctx.controlMap ?? {};
25027
+ const outcomes = [
25028
+ ...Object.values(ctx.screenMethods ?? {}).flatMap(
25029
+ (handler) => screenMethodCalls(handler).map((one) => one.outcome)
25030
+ ),
25031
+ ...(ctx.autoCalls ?? []).map((call) => call.outcome),
25032
+ // A wire's arms emit into the class body too, inside the open's callback,
25033
+ // where no template hands a ref in (ADR 0144).
25034
+ ...Object.values(controls).flatMap(
25035
+ (control) => controlWireOutcomes(control).map((entry2) => entry2.outcome)
25036
+ )
25037
+ ];
25038
+ const forms = /* @__PURE__ */ new Map();
25039
+ for (const outcome of outcomes) {
25040
+ for (const arm of OUTCOME_ARMS) {
25041
+ for (const row of outcome?.[arm]?.formResets ?? []) {
25042
+ const form = controls[row.controlId];
25043
+ if (!form || form.type !== "form" /* FORM */) continue;
25044
+ if (!formQueryReaches(form, controls)) continue;
25045
+ forms.set(form.id, form);
25046
+ }
25047
+ }
25048
+ }
25049
+ return [...forms.values()];
25050
+ }
25051
+ function resetTargetQueriesBlock(ctx) {
25052
+ return classResetForms(ctx).map(
25053
+ (form) => `
25054
+ protected readonly ${resetTargetMember(
25055
+ form
25056
+ )} = viewChild<SectionFormComponent>('${formRefName(form)}');
25057
+ `
25058
+ ).join("");
25059
+ }
25060
+ function classArmStatements(arm, rows, ctx, selfStore, constants, reads, argsLocal, site) {
25061
+ const controls = ctx.controlMap ?? {};
25062
+ const { payload, fieldNames, eventRoot, eventMember } = reads;
25063
+ const resets = (rows.formResets ?? []).filter((row) => {
25064
+ const form = controls[row.controlId];
25065
+ return !!form && form.type === "form" /* FORM */ && formQueryReaches(form, controls);
25066
+ });
25067
+ const clears = resets.map((row) => formResetPropertyId(controls[row.controlId])).filter((propertyId) => !!propertyId).map((propertyId) => ({ propertyId, value: { kind: "clear" } }));
25068
+ const modelClears = resets.flatMap((row) => {
25069
+ const model = formResetModel(row.controlId, ctx.formModels ?? {});
25070
+ if (!model) return [];
25071
+ const keys = formModelShapeKeys(controls, row.controlId).map((key2) => {
25072
+ const type = formModelKeyType(key2);
25073
+ return type ? `${key2.name}: ${formModelKeyZero(type)}` : void 0;
25074
+ }).filter((entry2) => !!entry2);
25075
+ return [`this.${model.name}.set({ ${keys.join(", ")} })`];
25076
+ });
25077
+ const writes = [...rows.writes ?? [], ...clears].filter(
25078
+ (write, index, all) => all.findIndex((other) => other.propertyId === write.propertyId) === index
25079
+ );
25080
+ const statements = [
25081
+ ...arm === "denied" ? [denialDialogCall(denialDialogOf(rows))] : [],
25082
+ ...screenWriteStatements(
25083
+ ctx.variables ?? {},
25084
+ rows.screenWrites ?? [],
25085
+ payload,
25086
+ fieldNames,
25087
+ ctx.inputs ?? {},
25088
+ constants,
25089
+ eventRoot,
25090
+ "class",
25091
+ eventMember,
25092
+ void 0,
25093
+ ctx.functions ?? {}
25094
+ ),
25095
+ ...screenEmitStatements(
25096
+ ctx.outputs ?? {},
25097
+ rows.emits ?? [],
25098
+ payload,
25099
+ fieldNames,
25100
+ ctx.inputs ?? {},
25101
+ constants,
25102
+ eventRoot,
25103
+ "class",
25104
+ eventMember,
25105
+ reads.emitBindings
25106
+ )
25107
+ ];
25108
+ if (ctx.properties && selfStore) {
25109
+ const patch = stateWritePatchExpression(
25110
+ ctx.properties,
25111
+ writes,
25112
+ payload,
25113
+ fieldNames,
25114
+ ctx.inputs ?? {},
25115
+ selfStore,
25116
+ constants,
25117
+ eventRoot,
25118
+ "class",
25119
+ eventMember,
25120
+ void 0,
25121
+ ctx.functions ?? {}
25122
+ );
25123
+ if (patch) statements.push(patch);
25124
+ }
25125
+ statements.push(...modelClears);
25126
+ for (const row of resets) {
25127
+ if (row.depth === "value") continue;
25128
+ statements.push(
25129
+ `this.${resetTargetMember(controls[row.controlId])}()?.reset()`
25130
+ );
25131
+ }
25132
+ statements.push(
25133
+ ...outcomeCallStatements(rows, site, ctx, selfStore, constants, reads)
25134
+ );
25135
+ const answer = isOutcomeReportDrawn(rows.report) ? armReportExpr(
25136
+ rows.report,
25137
+ { id: "" },
25138
+ ctx,
25139
+ selfStore,
25140
+ payload,
25141
+ eventRoot,
25142
+ (path) => payload === "void" ? void 0 : path.length ? eventMember ? eventMember(path, `$event?.${path.join("?.")}`, eventRoot) : `$event?.${path.join("?.")}` : eventRoot
25143
+ ) : void 0;
25144
+ if (rows.closesOverlay) {
25145
+ statements.push(`${OVERLAY_REF_MEMBER}?.close(${answer ?? "undefined"})`);
25146
+ } else if (answer) {
25147
+ statements.push(`${OVERLAY_REF_MEMBER}?.change(${answer})`);
25148
+ }
25149
+ const linkRead = outputLinkRead(ctx, selfStore.replace(/^this\./, ""));
25150
+ const nav = outcomeNavStatement(
25151
+ rows.nav,
25152
+ ctx.navMap ?? {},
25153
+ (arg) => arg.source === "args" ? argsLocal ? `${argsLocal}.${arg.arg.join("?.")}` : void 0 : linkRead(arg)
25154
+ );
25155
+ if (nav) statements.push(nav);
25156
+ return statements;
25157
+ }
25158
+ var withoutOutcomeCalls = (outcome) => outcome && Object.fromEntries(
25159
+ Object.entries(outcome).map(([key2, arm]) => {
25160
+ if (!arm) return [key2, arm];
25161
+ const { calls: _drop, ...rest } = arm;
25162
+ return [key2, rest];
25163
+ })
25164
+ );
25165
+ function outcomeCallStatements(arm, site, ctx, selfStore, constants, reads) {
25166
+ if (!site) return [];
25167
+ const statements = [];
25168
+ for (const call of arm.calls ?? []) {
25169
+ const handler = call.screenMethodId ? ctx.screenMethods?.[call.screenMethodId] : void 0;
25170
+ if (handler) {
25171
+ const args2 = site.handlerArgs(handler, call.args ?? []);
25172
+ if (args2 !== void 0) statements.push(`this.${handler.name}(${args2})`);
25173
+ continue;
25174
+ }
25175
+ const method = call.methodId ? site.methods[call.methodId] : void 0;
25176
+ if (!method || (method.kind ?? "http") !== "http") continue;
25177
+ const args = site.storeArgs(method, call.args ?? []);
25178
+ if (args === void 0) continue;
25179
+ statements.push(
25180
+ ...classOutcomeCall(
25181
+ `this.${methodReceiver(method, site.storeProp, ctx)}.${method.name}`,
25182
+ args,
25183
+ method,
25184
+ withoutOutcomeCalls(call.outcome),
25185
+ ctx,
25186
+ selfStore,
25187
+ constants,
25188
+ reads,
25189
+ "outcomeArgs",
25190
+ { line: " ", close: " " }
25191
+ )
25192
+ );
25193
+ }
25194
+ return statements;
25195
+ }
25196
+ var classOutcomeCallSite = (methods, operationOf, storeProp, ctx, payload, options) => ({
25197
+ methods,
25198
+ storeProp,
25199
+ storeArgs: (method, rows) => isStorageMethod(method) || operationOf(method) ? callArgumentsExpression(
25200
+ methodArgsOf(method, operationOf, ctx),
25201
+ rows,
25202
+ payload,
25203
+ options
25204
+ ) : void 0,
25205
+ handlerArgs: (handler, rows) => callArgumentsExpression(screenMethodArgs(handler), rows, payload, {
25206
+ ...options,
25207
+ positional: true
25208
+ })
25209
+ });
25210
+ function classOutcomeCall(callee, args, method, outcome, ctx, selfStore, constants, reads, argsLocalName, indent2, site) {
25211
+ if (!method || (method.kind ?? "http") !== "http" || !hasCallOutcome(outcome))
25212
+ return [`${callee}(${args})`];
25213
+ const argsLocal = outcomeReadsArgs(outcome) && args && args !== "{}" ? argsLocalName : void 0;
25214
+ const callbacks = OUTCOME_ARMS.map((arm) => {
25215
+ const rows = outcome?.[arm];
25216
+ if (!rows || !armHasRows(rows)) return "";
25217
+ const lines = classArmStatements(
25218
+ arm,
25219
+ rows,
25220
+ ctx,
25221
+ selfStore,
25222
+ constants,
25223
+ reads,
25224
+ argsLocal,
25225
+ site
25226
+ );
25227
+ if (!lines.length) return "";
25228
+ return `${ARM_CALLBACK[arm]}: ${armParams(arm)} => {
25229
+ ${lines.map((line) => `${indent2.line}${line};`).join("\n")}
25230
+ ${indent2.close}}`;
25231
+ }).filter(Boolean);
25232
+ if (!callbacks.length) return [`${callee}(${args})`];
25233
+ return [
25234
+ ...argsLocal ? [`const ${argsLocal} = ${args}`] : [],
25235
+ `${callee}({ ${[
25236
+ ...argsLocal ? [`...${argsLocal}`] : args && args !== "{}" ? [spreadArgs(args)] : [],
25237
+ ...callbacks
25238
+ ].join(", ")} })`
25239
+ ];
25240
+ }
24680
25241
  function screenMethodsBlock(screenMethods, methods, operationOf, storeProp, ctx, constants) {
24681
25242
  const declared = Object.values(screenMethods).sort(
24682
25243
  (a, b) => a.name.localeCompare(b.name)
@@ -24787,9 +25348,38 @@ function screenMethodsBlock(screenMethods, methods, operationOf, storeProp, ctx,
24787
25348
  statements.push(`const ${local} = ${expr}`);
24788
25349
  }
24789
25350
  const tested = read.filter(([, local]) => hoists.guarded.has(local));
25351
+ const fired = classOutcomeCall(
25352
+ call.callee,
25353
+ args,
25354
+ method,
25355
+ one.outcome,
25356
+ ctx,
25357
+ selfStore,
25358
+ constants,
25359
+ {
25360
+ payload,
25361
+ fieldNames,
25362
+ eventRoot,
25363
+ eventMember: screenMethodParamRead
25364
+ },
25365
+ mintLocal2("callArgs", taken),
25366
+ several && tested.length ? { line: " ", close: " " } : { line: " ", close: " " },
25367
+ classOutcomeCallSite(methods, operationOf, storeProp, ctx, payload, {
25368
+ constants,
25369
+ scope: "class",
25370
+ functions: ctx.functions ?? {},
25371
+ ...bindings,
25372
+ eventRoot,
25373
+ eventMember: screenMethodParamRead,
25374
+ fields: screenMethodFields(handler)
25375
+ })
25376
+ );
24790
25377
  if (tested.length && several) {
25378
+ const test = tested.map(([, local]) => `${local} !== undefined`).join(" && ");
24791
25379
  statements.push(
24792
- `if (${tested.map(([, local]) => `${local} !== undefined`).join(" && ")}) ${call.callee}(${args})`
25380
+ fired.length === 1 ? `if (${test}) ${fired[0]}` : `if (${test}) {
25381
+ ${fired.map((line) => ` ${line};`).join("\n")}
25382
+ }`
24793
25383
  );
24794
25384
  } else {
24795
25385
  if (tested.length) {
@@ -24797,7 +25387,7 @@ function screenMethodsBlock(screenMethods, methods, operationOf, storeProp, ctx,
24797
25387
  `if (${tested.map(([, local]) => `${local} === undefined`).join(" || ")}) return`
24798
25388
  );
24799
25389
  }
24800
- statements.push(`${call.callee}(${args})`);
25390
+ statements.push(...fired);
24801
25391
  }
24802
25392
  }
24803
25393
  }
@@ -24813,6 +25403,9 @@ ${statements.map((line) => ` ${line};`).join("\n")}
24813
25403
  });
24814
25404
  return emitted.join("");
24815
25405
  }
25406
+ var bindingReadsAlias = (binding) => binding.root.kind === "alias" || transformBindingLeaves(binding.transform).some(
25407
+ (leaf) => leaf.root.kind === "alias"
25408
+ );
24816
25409
  function outputOpenEmit(node, output, ctx, storeProp, indent2 = " ", methods = {}, operationOf = () => void 0, aliasArgs = false) {
24817
25410
  const open = outputOpenOf(node.outputOpens, output);
24818
25411
  if (!open?.screenId) return void 0;
@@ -24823,9 +25416,7 @@ function outputOpenEmit(node, output, ctx, storeProp, indent2 = " ", methods
24823
25416
  return void 0;
24824
25417
  const payload = nodePayloadShape(node, output, ctx);
24825
25418
  const aliasParams = /* @__PURE__ */ new Map();
24826
- const readsAlias = (binding) => binding.root.kind === "alias" || transformBindingLeaves(binding.transform).some(
24827
- (leaf) => leaf.root.kind === "alias"
24828
- );
25419
+ const readsAlias = bindingReadsAlias;
24829
25420
  const entries = outputOpenInputEntries(
24830
25421
  open,
24831
25422
  ref.inputs,
@@ -24965,7 +25556,34 @@ function overlayOutputEmits(open, ref, node, output, ctx, storeProp, methods, op
24965
25556
  "class"
24966
25557
  );
24967
25558
  if (patch) lines.push(patch);
24968
- for (const binding of wireBindings(wire)) {
25559
+ wireBindings(wire).forEach((binding, index) => {
25560
+ if (!index && wire.binding && hasCallOutcome(wire.outcome)) {
25561
+ const parts = wireCallParts(
25562
+ binding,
25563
+ key2,
25564
+ payload,
25565
+ methods,
25566
+ operationOf,
25567
+ storeProp,
25568
+ ctx
25569
+ );
25570
+ if (!parts) return;
25571
+ lines.push(
25572
+ ...classOutcomeCall(
25573
+ `${storeProp ? `this.${storeProp}` : ""}.${parts.method.name}`,
25574
+ parts.args,
25575
+ parts.method,
25576
+ wire.outcome,
25577
+ ctx,
25578
+ storeProp ? `this.${storeProp}` : "",
25579
+ ctx.constants ?? {},
25580
+ { payload, fieldNames: [], eventRoot: "$event" },
25581
+ "callArgs",
25582
+ { line: " ", close: " " }
25583
+ )
25584
+ );
25585
+ return;
25586
+ }
24969
25587
  const call = wireCall(
24970
25588
  binding,
24971
25589
  key2,
@@ -24976,7 +25594,7 @@ function overlayOutputEmits(open, ref, node, output, ctx, storeProp, methods, op
24976
25594
  ctx
24977
25595
  );
24978
25596
  if (call) lines.push(call);
24979
- }
25597
+ });
24980
25598
  return [
24981
25599
  {
24982
25600
  name: target.name,
@@ -25625,8 +26243,8 @@ function armSubjectExpr(check, node, ctx, storeProp, payload, eventRoot) {
25625
26243
  const path = (check.event ?? []).filter(Boolean);
25626
26244
  return payload !== "record" || !path.length ? eventRoot : `$event?.${path.join("?.")}`;
25627
26245
  }
25628
- function armReportExpr(report, node, ctx, storeProp, payload, eventRoot) {
25629
- const subject = armSubjectExpr(
26246
+ function armReportExpr(report, node, ctx, storeProp, payload, eventRoot, eventRead) {
26247
+ const subject = eventRead && report.source === "event" ? eventRead((report.event ?? []).filter(Boolean)) : armSubjectExpr(
25630
26248
  { ...report, id: "", operator: "==" },
25631
26249
  node,
25632
26250
  ctx,
@@ -25977,7 +26595,44 @@ function classCallStatements(node, key2, payload, eventRoot, methods, operationO
25977
26595
  eventRoot,
25978
26596
  selfStore,
25979
26597
  ctx,
25980
- argsLocal
26598
+ argsLocal,
26599
+ {
26600
+ methods,
26601
+ storeProp,
26602
+ storeArgs: (one, rows) => callArguments(
26603
+ one,
26604
+ operationOf,
26605
+ key2,
26606
+ rows,
26607
+ ctx.constants ?? {},
26608
+ ctx.functions ?? {},
26609
+ ctx.properties ?? {},
26610
+ node.type,
26611
+ callArgBindings(ctx, storeProp, {
26612
+ controlId: node.id,
26613
+ memberPrefix: "this."
26614
+ }),
26615
+ filterGroupEventMember(node),
26616
+ node.configs,
26617
+ screenPayloadOf(node, key2, ctx)
26618
+ ),
26619
+ handlerArgs: (handler, rows) => argsExpressionAt(
26620
+ screenMethodArgs(handler),
26621
+ true,
26622
+ key2,
26623
+ rows,
26624
+ ctx.constants ?? {},
26625
+ ctx.functions ?? {},
26626
+ node.type,
26627
+ callArgBindings(ctx, storeProp, {
26628
+ controlId: node.id,
26629
+ memberPrefix: "this."
26630
+ }),
26631
+ filterGroupEventMember(node),
26632
+ node.configs,
26633
+ screenPayloadOf(node, key2, ctx)
26634
+ )
26635
+ }
25981
26636
  );
25982
26637
  if (!lines.length) return "";
25983
26638
  return `${ARM_CALLBACK[arm]}: ${armParams(arm)} => {
@@ -26005,7 +26660,7 @@ function denialDialogCall(dialog) {
26005
26660
  ];
26006
26661
  return `this.modal.ask({ ${options.join(", ")} }).subscribe()`;
26007
26662
  }
26008
- function armStatements(node, output, arm, payload, eventRoot, selfStore, ctx, argsLocal) {
26663
+ function armStatements(node, output, arm, payload, eventRoot, selfStore, ctx, argsLocal, site) {
26009
26664
  const controls = ctx.controlMap ?? {};
26010
26665
  const rows = node.outputOutcomes?.[output]?.[arm];
26011
26666
  if (!rows) return [];
@@ -26079,6 +26734,14 @@ function armStatements(node, output, arm, payload, eventRoot, selfStore, ctx, ar
26079
26734
  `${formRefName(controls[row.controlId])}.reset()`
26080
26735
  );
26081
26736
  }
26737
+ statements.push(
26738
+ ...outcomeCallStatements(rows, site, ctx, selfStore, ctx.constants ?? {}, {
26739
+ payload,
26740
+ fieldNames: [],
26741
+ eventRoot,
26742
+ eventMember: filterGroupEventMember(node)
26743
+ })
26744
+ );
26082
26745
  const answer = isOutcomeReportDrawn(rows.report) ? armReportExpr(
26083
26746
  rows.report,
26084
26747
  node,
@@ -26101,7 +26764,7 @@ function armStatements(node, output, arm, payload, eventRoot, selfStore, ctx, ar
26101
26764
  if (nav) statements.push(nav);
26102
26765
  return statements;
26103
26766
  }
26104
- function outputLinkRead(ctx, storeProp) {
26767
+ function outputLinkRead(ctx, storeProp, aliasParam) {
26105
26768
  const selfStore = storeProp ? `this.${storeProp}` : "";
26106
26769
  return (arg) => {
26107
26770
  switch (arg.source) {
@@ -26116,6 +26779,8 @@ function outputLinkRead(ctx, storeProp) {
26116
26779
  false
26117
26780
  ) : void 0;
26118
26781
  case "binding":
26782
+ if (bindingReadsAlias(arg.binding))
26783
+ return aliasParam?.(arg.binding);
26119
26784
  return bindingExpression(arg.binding, {
26120
26785
  ...bindingScope(ctx, storeProp),
26121
26786
  memberPrefix: "this."
@@ -26126,13 +26791,24 @@ function outputLinkRead(ctx, storeProp) {
26126
26791
  };
26127
26792
  }
26128
26793
  function outputLinkStatements(node, output, ctx, storeProp) {
26129
- const read = outputLinkRead(ctx, storeProp);
26794
+ return outputLinkEmit(node, output, ctx, storeProp, false).statements;
26795
+ }
26796
+ function outputLinkEmit(node, output, ctx, storeProp, aliasArgs) {
26797
+ const aliasParams = /* @__PURE__ */ new Map();
26798
+ const read = outputLinkRead(ctx, storeProp, (binding) => {
26799
+ if (!aliasArgs || binding.transform) return void 0;
26800
+ const expr = bindingExpression(binding, bindingScope(ctx, storeProp));
26801
+ if (!expr) return void 0;
26802
+ const param = aliasParams.get(expr) ?? `$row${aliasParams.size}`;
26803
+ aliasParams.set(expr, param);
26804
+ return param;
26805
+ });
26130
26806
  const nav = outputNavStatement(
26131
26807
  outputNavOf(node.outputNavs, output),
26132
26808
  ctx.navMap ?? {},
26133
26809
  read
26134
26810
  );
26135
- return [
26811
+ const statements = [
26136
26812
  ...outputNewTabStatements(
26137
26813
  outputNewTabOf(node.outputNewTabs, output),
26138
26814
  read,
@@ -26140,11 +26816,14 @@ function outputLinkStatements(node, output, ctx, storeProp) {
26140
26816
  ),
26141
26817
  ...nav ? [nav] : []
26142
26818
  ];
26819
+ return { statements, aliasReads: [...aliasParams.keys()] };
26143
26820
  }
26144
26821
  function outputLinkCall(node, output, ctx, scope, storeProp) {
26145
- if (!outputLinkStatements(node, output, ctx, storeProp).length) return "";
26822
+ const emit = outputLinkEmit(node, output, ctx, storeProp, true);
26823
+ if (!emit.statements.length) return "";
26824
+ if (scope === "class" && emit.aliasReads.length) return "";
26146
26825
  const self = scope === "class" ? "this." : "";
26147
- return `${self}${outputLinkMemberName(node.id, output)}()`;
26826
+ return `${self}${outputLinkMemberName(node.id, output)}(${emit.aliasReads.join(", ")})`;
26148
26827
  }
26149
26828
  function outputLinkMembersBlock(tree, ctx, storeProp) {
26150
26829
  const emitted = [];
@@ -26156,10 +26835,17 @@ function outputLinkMembersBlock(tree, ctx, storeProp) {
26156
26835
  ]);
26157
26836
  for (const output of [...outputs].sort()) {
26158
26837
  if (isOutputArmKey(output) || isMenuActionKey(output)) continue;
26159
- const lines = outputLinkStatements(node, output, ctx, storeProp);
26838
+ const { statements: lines, aliasReads } = outputLinkEmit(
26839
+ node,
26840
+ output,
26841
+ ctx,
26842
+ storeProp,
26843
+ true
26844
+ );
26160
26845
  if (!lines.length) continue;
26846
+ const params = aliasReads.map((_, index) => `$row${index}: unknown`).join(", ");
26161
26847
  emitted.push(`
26162
- protected readonly ${outputLinkMemberName(node.id, output)} = (): void => {
26848
+ protected readonly ${outputLinkMemberName(node.id, output)} = (${params}): void => {
26163
26849
  ${lines.map((line) => ` ${line};`).join("\n")}
26164
26850
  };
26165
26851
  `);
@@ -26177,7 +26863,7 @@ function methodArgsOf(method, operationOf, ctx) {
26177
26863
  }
26178
26864
  return op ? methodArgs(method, op) : authoredArgs(method);
26179
26865
  }
26180
- function autoCallsBlock(calls, methods, operationOf, storeProp, inputs, constants, functions = {}, bindings = {}, storePropOf, outputs = {}) {
26866
+ function autoCallsBlock(calls, methods, operationOf, storeProp, inputs, constants, functions = {}, bindings = {}, storePropOf, outputs = {}, ctx) {
26181
26867
  const byName = new Map(
26182
26868
  Object.values(inputs).map((input) => [input.id, input.name])
26183
26869
  );
@@ -26201,14 +26887,50 @@ function autoCallsBlock(calls, methods, operationOf, storeProp, inputs, constant
26201
26887
  if (call.methodId && !method) return "";
26202
26888
  const op = method ? operationOf(method) : void 0;
26203
26889
  if (method && !op) return "";
26890
+ const handler = call.screenMethodId ? ctx?.screenMethods?.[call.screenMethodId] : void 0;
26891
+ if (call.screenMethodId && !handler) return "";
26204
26892
  const taken = new Set(Object.values(functions).map((fn) => fn.name));
26893
+ const watchScope = {
26894
+ inputs,
26895
+ screenComputeds: ctx?.screenComputeds,
26896
+ variables: ctx?.variables,
26897
+ properties: ctx?.properties
26898
+ };
26899
+ const { fields } = watchFields(call.reads, watchScope);
26900
+ const watched = /* @__PURE__ */ new Map();
26901
+ const watchKeys = [];
26902
+ for (const binding of call.reads ?? []) {
26903
+ if (binding.root.kind === "alias") return "";
26904
+ const expr = bindingExpression(binding, classScope);
26905
+ if (!expr) return "";
26906
+ if (watched.has(expr)) continue;
26907
+ const key2 = watchKey(binding, watchScope);
26908
+ const local = mintLocal2(key2 ?? localBase2(binding, classScope), taken);
26909
+ watched.set(expr, local);
26910
+ if (key2 && !watchKeys.some(([seen]) => seen === key2))
26911
+ watchKeys.push([key2, local]);
26912
+ }
26913
+ const keyed = watched.size > 0;
26914
+ const payload = keyed ? "record" : "void";
26915
+ const fieldNames = watchKeys.map(([key2]) => key2);
26916
+ const localOfKey = new Map(watchKeys);
26917
+ const eventRoot = keyed ? `{ ${watchKeys.map(([key2, local]) => key2 === local ? key2 : `${key2}: ${local}`).join(", ")} }` : "$event";
26918
+ const eventMember = keyed ? (path, expr) => path.length === 1 ? localOfKey.get(path[0]) ?? expr : expr : void 0;
26205
26919
  const localByInput = /* @__PURE__ */ new Map();
26206
26920
  const locals = /* @__PURE__ */ new Map();
26207
- const guarded = /* @__PURE__ */ new Set();
26208
- const callRows = method ? call.args : [];
26921
+ const guarded = new Set(watched.values());
26922
+ const callRows = [
26923
+ ...method ? call.args : [],
26924
+ ...handler ? call.screenMethodArgs ?? [] : []
26925
+ ];
26209
26926
  for (const row of callRows) {
26210
26927
  if (row.source !== "input" || !row.input) continue;
26211
26928
  const name3 = byName.get(row.input) ?? row.input;
26929
+ const watchedLocal = watched.get(`this.${name3}()`);
26930
+ if (watchedLocal) {
26931
+ locals.set(row, watchedLocal);
26932
+ continue;
26933
+ }
26212
26934
  let local = localByInput.get(name3);
26213
26935
  if (!local) {
26214
26936
  local = mintLocal2(name3, taken);
@@ -26223,31 +26945,51 @@ function autoCallsBlock(calls, methods, operationOf, storeProp, inputs, constant
26223
26945
  functions,
26224
26946
  taken
26225
26947
  );
26226
- for (const [row, local] of bound.locals) locals.set(row, local);
26948
+ const boundExpr = new Map(
26949
+ bound.reads.map(([expr, local]) => [local, expr])
26950
+ );
26951
+ for (const [row, local] of bound.locals) {
26952
+ const expr = boundExpr.get(local);
26953
+ locals.set(row, expr && watched.get(expr) || local);
26954
+ }
26227
26955
  for (const local of bound.guarded) guarded.add(local);
26228
- const args = method && op ? callArgumentsExpression(methodArgs(method, op), call.args, "void", {
26956
+ const argCtx = {
26229
26957
  constants,
26230
26958
  scope: "class",
26231
26959
  functions,
26232
26960
  ...bindings,
26233
- locals
26234
- }) : "";
26961
+ locals,
26962
+ ...keyed ? { eventRoot, eventMember, fields } : {}
26963
+ };
26964
+ const args = method && op ? callArgumentsExpression(
26965
+ methodArgs(method, op),
26966
+ call.args,
26967
+ payload,
26968
+ argCtx
26969
+ ) : "";
26235
26970
  if (args === void 0) return "";
26971
+ const handlerArgs2 = handler ? callArgumentsExpression(
26972
+ screenMethodArgs(handler),
26973
+ call.screenMethodArgs ?? [],
26974
+ payload,
26975
+ { ...argCtx, positional: true }
26976
+ ) : "";
26977
+ if (handlerArgs2 === void 0) return "";
26236
26978
  const read = new Map([
26237
26979
  ...[...localByInput.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([name3, local]) => [`this.${name3}()`, local]),
26238
- ...bound.reads
26980
+ ...bound.reads.filter(([expr]) => !watched.has(expr))
26239
26981
  ]);
26240
26982
  const emitRows = call.emits ?? [];
26241
26983
  let emits = emitRows.length ? screenEmitStatements(
26242
26984
  outputs,
26243
26985
  emitRows,
26244
- "void",
26245
- [],
26986
+ payload,
26987
+ fieldNames,
26246
26988
  inputs,
26247
26989
  constants,
26248
- "$event",
26990
+ eventRoot,
26249
26991
  "class",
26250
- void 0,
26992
+ eventMember,
26251
26993
  { scope: bindings.bindingScope ?? {} }
26252
26994
  ) : [];
26253
26995
  if (emitRows.length && !emits.length) return "";
@@ -26270,7 +27012,7 @@ function autoCallsBlock(calls, methods, operationOf, storeProp, inputs, constant
26270
27012
  base2 = localBase2(value.binding, bindings.bindingScope ?? {});
26271
27013
  }
26272
27014
  if (!expr) continue;
26273
- let local = read.get(expr);
27015
+ let local = watched.get(expr) ?? read.get(expr);
26274
27016
  if (!local) {
26275
27017
  local = mintLocal2(base2, taken);
26276
27018
  read.set(expr, local);
@@ -26282,24 +27024,45 @@ function autoCallsBlock(calls, methods, operationOf, storeProp, inputs, constant
26282
27024
  (line) => line.endsWith(spelled) ? line.replace(spelled, hoisted) : line
26283
27025
  );
26284
27026
  }
26285
- for (const binding of call.reads ?? []) {
26286
- if (binding.root.kind === "alias") return "";
26287
- const expr = bindingExpression(binding, classScope);
26288
- if (!expr) return "";
26289
- let local = read.get(expr);
26290
- if (!local) {
26291
- local = mintLocal2(localBase2(binding, classScope), taken);
26292
- read.set(expr, local);
26293
- }
26294
- guarded.add(local);
26295
- }
26296
- const reads = [...read.entries()];
26297
- const hoists = reads.length ? `
26298
- ${reads.map(([expr, local]) => ` const ${local} = ${expr};`).join("\n")}` : "";
26299
- const tested = reads.filter(([, local]) => guarded.has(local));
26300
- const guard = tested.length ? `
26301
- if (${tested.map(([, local]) => `${local} === undefined`).join(" || ")}) return;` : "";
26302
- const base = method ? `${method.name}Call` : `${[...emitRows].map((row) => outputs[row.outputId]?.name ?? "").filter(Boolean).sort()[0] ?? "auto"}Emit`;
27027
+ const screenWriteLines = screenWriteStatements(
27028
+ ctx?.variables ?? {},
27029
+ call.screenWrites ?? [],
27030
+ payload,
27031
+ fieldNames,
27032
+ inputs,
27033
+ constants,
27034
+ eventRoot,
27035
+ "class",
27036
+ eventMember,
27037
+ void 0,
27038
+ functions
27039
+ );
27040
+ if (call.screenWrites?.length && !screenWriteLines.length) return "";
27041
+ const patch = ctx?.properties && call.writes?.length ? stateWritePatchExpression(
27042
+ ctx.properties,
27043
+ call.writes,
27044
+ payload,
27045
+ fieldNames,
27046
+ inputs,
27047
+ storeProp ? `this.${storeProp}` : "",
27048
+ constants,
27049
+ eventRoot,
27050
+ "class",
27051
+ eventMember,
27052
+ void 0,
27053
+ functions
27054
+ ) : void 0;
27055
+ if (call.writes?.length && !patch) return "";
27056
+ const hoist = (entries, pad2) => entries.map(([expr, local]) => `
27057
+ ${pad2}const ${local} = ${expr};`).join("");
27058
+ const guardOf = (entries, pad2) => {
27059
+ const tested = entries.filter(([, local]) => guarded.has(local));
27060
+ return tested.length ? `
27061
+ ${pad2}if (${tested.map(([, local]) => `${local} === undefined`).join(" || ")}) return;` : "";
27062
+ };
27063
+ const watchReads = [...watched.entries()];
27064
+ const otherReads = [...read.entries()];
27065
+ const base = method ? `${method.name}Call` : handler ? `${handler.name}Call` : emitRows.length ? `${[...emitRows].map((row) => outputs[row.outputId]?.name ?? "").filter(Boolean).sort()[0] ?? "auto"}Emit` : "reaction";
26303
27066
  let member = base;
26304
27067
  for (let n = 2; members.has(member); n++) member = `${base}${n}`;
26305
27068
  members.add(member);
@@ -26311,14 +27074,59 @@ ${reads.map(([expr, local]) => ` const ${local} = ${expr};`).join("\n")}` :
26311
27074
  const flagDecl = once ? `
26312
27075
  private ${flag} = false;
26313
27076
  ` : "";
26314
- const emitBlock = emits.length ? `
27077
+ const syncLines = [
27078
+ ...screenWriteLines,
27079
+ ...emits,
27080
+ ...patch ? [patch] : [],
27081
+ ...handler ? [`this.${handler.name}(${handlerArgs2})`] : []
27082
+ ];
27083
+ const callLines = (pad2) => method ? classOutcomeCall(
27084
+ `this.${storePropOf?.(method.id) ?? storeProp}.${method.name}`,
27085
+ args,
27086
+ method,
27087
+ ctx ? call.outcome : void 0,
27088
+ ctx ?? {},
27089
+ storeProp ? `this.${storeProp}` : "",
27090
+ constants,
27091
+ {
27092
+ payload,
27093
+ fieldNames,
27094
+ eventRoot,
27095
+ ...eventMember ? { eventMember } : {},
27096
+ emitBindings: { scope: bindings.bindingScope ?? {} }
27097
+ },
27098
+ mintLocal2("callArgs", taken),
27099
+ { line: `${pad2} `, close: `${pad2} ` },
27100
+ classOutcomeCallSite(
27101
+ methods,
27102
+ operationOf,
27103
+ storeProp,
27104
+ ctx ?? {},
27105
+ payload,
27106
+ { ...argCtx, locals: /* @__PURE__ */ new Map() }
27107
+ )
27108
+ ).map((line) => `${pad2}${line};`) : [];
27109
+ if (keyed) {
27110
+ const inner = [
27111
+ ...syncLines.map((line) => ` ${line};`),
27112
+ ...callLines(" ")
27113
+ ];
27114
+ return `${flagDecl}
27115
+ private readonly ${member} = effect(() => {${hoist(watchReads, " ")}${guardOf(watchReads, " ")}${latch}
27116
+ untracked(() => {${hoist(otherReads, " ")}${guardOf(otherReads, " ")}
27117
+ ${inner.join("\n")}
27118
+ });
27119
+ });
27120
+ `;
27121
+ }
27122
+ const syncBlock = syncLines.length ? `
26315
27123
  untracked(() => {
26316
- ${emits.map((line) => ` ${line};`).join("\n")}
27124
+ ${syncLines.map((line) => ` ${line};`).join("\n")}
26317
27125
  });` : "";
26318
- const callLine = method ? `
26319
- this.${storePropOf?.(method.id) ?? storeProp}.${method.name}(${args});` : "";
27126
+ const callBlock = method ? `
27127
+ ${callLines(" ").join("\n")}` : "";
26320
27128
  return `${flagDecl}
26321
- private readonly ${member} = effect(() => {${hoists}${guard}${latch}${emitBlock}${callLine}
27129
+ private readonly ${member} = effect(() => {${hoist(otherReads, " ")}${guardOf(otherReads, " ")}${latch}${syncBlock}${callBlock}
26322
27130
  });
26323
27131
  `;
26324
27132
  }).filter(Boolean);
@@ -27160,7 +27968,7 @@ function generateTs(tree, naming, featureName, variants = {}, methods = {}, oper
27160
27968
  featureStoreProp(featureName)
27161
27969
  );
27162
27970
  const autoCalls = (ctx.autoCalls ?? []).filter(
27163
- (call) => call.methodId ? !!methods[call.methodId] : !!call.emits?.length
27971
+ (call) => call.methodId ? !!methods[call.methodId] : screenAutoCallDoesAnything(call)
27164
27972
  );
27165
27973
  const storeProp = featureStoreProp(featureName);
27166
27974
  const transformRefs = templateTransformRefs(
@@ -27463,7 +28271,29 @@ ${tables.map(
27463
28271
  ctx,
27464
28272
  payloads
27465
28273
  );
27466
- const usesModal = `${outputOpenBody}${menuActionHandlersBody}${outputArmHandlersBody}`.includes(
28274
+ const screenMethodsBody = screenMethodsBlock(
28275
+ ctx.screenMethods ?? {},
28276
+ methods,
28277
+ operationOf,
28278
+ storeProp,
28279
+ ctx,
28280
+ constants
28281
+ );
28282
+ const autoCallsBody = autoCallsBlock(
28283
+ autoCalls,
28284
+ methods,
28285
+ operationOf,
28286
+ storeProp,
28287
+ ctx.inputs ?? {},
28288
+ constants,
28289
+ ctx.functions ?? {},
28290
+ callArgBindings(ctx, storeProp, { memberPrefix: "this." }),
28291
+ ctx.storePropOf,
28292
+ ctx.outputs ?? {},
28293
+ ctx
28294
+ );
28295
+ const classArmsBody = `${screenMethodsBody}${autoCallsBody}`;
28296
+ const usesModal = `${outputOpenBody}${menuActionHandlersBody}${outputArmHandlersBody}${classArmsBody}`.includes(
27467
28297
  "this.modal."
27468
28298
  ) || Object.values(ctx.controlMap ?? {}).some(controlDrawsDenial);
27469
28299
  const drawsOverlayClose = Object.values(ctx.controlMap ?? {}).some(
@@ -27477,21 +28307,9 @@ ${tables.map(
27477
28307
  const classReadsNavRef = `${screenVariantsBody}${screenComputedsBody}`.includes(
27478
28308
  `${NAV_REF_MEMBER}?.`
27479
28309
  );
27480
- const autoCallsBody = autoCallsBlock(
27481
- autoCalls,
27482
- methods,
27483
- operationOf,
27484
- storeProp,
27485
- ctx.inputs ?? {},
27486
- constants,
27487
- ctx.functions ?? {},
27488
- callArgBindings(ctx, storeProp, { memberPrefix: "this." }),
27489
- ctx.storePropOf,
27490
- ctx.outputs ?? {}
27491
- );
27492
- const submitTargetQueriesBody = submitTargetQueriesBlock(
28310
+ const submitTargetQueriesBody = `${submitTargetQueriesBlock(
27493
28311
  ctx.controlMap ?? {}
27494
- );
28312
+ )}${resetTargetQueriesBlock(ctx)}`;
27495
28313
  const angularCore = [
27496
28314
  "ChangeDetectionStrategy",
27497
28315
  "Component",
@@ -27499,7 +28317,7 @@ ${tables.map(
27499
28317
  ...screenComputedsBody || screenVariantsBody || cardsBody || messageParamsBody ? ["computed"] : [],
27500
28318
  ...autoCalls.length ? ["effect"] : [],
27501
28319
  ...autoCallsBody.includes("untracked(") ? ["untracked"] : [],
27502
- ...needsStore || usesAuth || injectedGlobalStores.length > 0 || usesModal || drawsOverlayClose || drawsOutcomeNav || classReadsNavRef || `${outputLinkBody}${menuActionHandlersBody}${outputArmHandlersBody}`.includes(
28320
+ ...needsStore || usesAuth || injectedGlobalStores.length > 0 || usesModal || drawsOverlayClose || drawsOutcomeNav || classReadsNavRef || `${classArmsBody}${outputOpenBody}`.includes(`${OVERLAY_REF_MEMBER}?.`) || `${classArmsBody}${outputOpenBody}`.includes(`${NAV_REF_MEMBER}?.`) || `${outputLinkBody}${menuActionHandlersBody}${outputArmHandlersBody}`.includes(
27503
28321
  `${NAV_REF_MEMBER}?.`
27504
28322
  ) ? ["inject"] : [],
27505
28323
  ...inputs.length ? ["input"] : [],
@@ -27693,7 +28511,7 @@ ${tables.map(
27693
28511
  const modalBody = usesModal ? `
27694
28512
  protected readonly modal = inject(ModalStore);
27695
28513
  ` : "";
27696
- const usesOverlayRef = `${outcomeHandlersBody}${menuActionHandlersBody}${outputArmHandlersBody}`.includes(
28514
+ const usesOverlayRef = `${outcomeHandlersBody}${menuActionHandlersBody}${outputArmHandlersBody}${classArmsBody}${outputOpenBody}`.includes(
27697
28515
  `${OVERLAY_REF_MEMBER}?.`
27698
28516
  );
27699
28517
  const overlayRefImport = usesOverlayRef ? `import { MODAL_REF } from '@magmonium/one';
@@ -27701,7 +28519,7 @@ ${tables.map(
27701
28519
  const overlayRefBody = usesOverlayRef ? `
27702
28520
  private readonly overlay = inject(MODAL_REF, { optional: true });
27703
28521
  ` : "";
27704
- const usesNavRef = `${outcomeHandlersBody}${menuActionHandlersBody}${outputArmHandlersBody}${screenVariantsBody}${screenComputedsBody}${outputLinkBody}`.includes(
28522
+ const usesNavRef = `${outcomeHandlersBody}${menuActionHandlersBody}${outputArmHandlersBody}${screenVariantsBody}${screenComputedsBody}${outputLinkBody}${classArmsBody}${outputOpenBody}`.includes(
27705
28523
  `${NAV_REF_MEMBER}?.`
27706
28524
  );
27707
28525
  const navRefImport = usesNavRef ? `import { NAV_STORE_REF, type NavStoreRef } from '@magmonium/one';
@@ -27720,7 +28538,7 @@ ${tables.map(
27720
28538
  })
27721
28539
  | null;
27722
28540
  ` : "";
27723
- const usesNavRouter = `${outcomeHandlersBody}${menuActionHandlersBody}${outputArmHandlersBody}${outputLinkBody}`.includes(
28541
+ const usesNavRouter = `${outcomeHandlersBody}${menuActionHandlersBody}${outputArmHandlersBody}${outputLinkBody}${classArmsBody}${outputOpenBody}`.includes(
27724
28542
  `${NAV_ROUTER_MEMBER}.`
27725
28543
  );
27726
28544
  const navRouterImport = usesNavRouter ? `import { ActivatedRoute, Router } from '@angular/router';
@@ -27730,14 +28548,6 @@ ${tables.map(
27730
28548
 
27731
28549
  private readonly navRoute = inject(ActivatedRoute);
27732
28550
  ` : "";
27733
- const screenMethodsBody = screenMethodsBlock(
27734
- ctx.screenMethods ?? {},
27735
- methods,
27736
- operationOf,
27737
- storeProp,
27738
- ctx,
27739
- constants
27740
- );
27741
28551
  const payloadsBody = payloadPropsBlock(payloads);
27742
28552
  const transformMembersBody = transformMembersBlock(
27743
28553
  templateRefs,
@@ -28129,7 +28939,7 @@ __export(package_exports, {
28129
28939
  version: () => version
28130
28940
  });
28131
28941
  var name = "@magmonium/one";
28132
- var version = "0.4.114";
28942
+ var version = "0.4.129";
28133
28943
  var description = "Magmonium One \u2014 Angular design-system primitives for mm Apps";
28134
28944
  var author = "magmonium";
28135
28945
  var license = "MIT";
@@ -28197,7 +29007,7 @@ __export(package_exports2, {
28197
29007
  version: () => version2
28198
29008
  });
28199
29009
  var name2 = "@magmonium/cli";
28200
- var version2 = "0.8.28";
29010
+ var version2 = "0.8.30";
28201
29011
  var description2 = "A powerful and extensible asset compilation tool that can be shared across multiple projects";
28202
29012
  var bin = {
28203
29013
  "mag-cli": "bin/cli.js"
@@ -29673,6 +30483,7 @@ var navAssetFiles = (navMap, { appName } = {}) => {
29673
30483
  const nav = navMap[navId];
29674
30484
  return !!(nav && (nav.platform === true || nav.label && nav.label.trim() !== "" || drawsRows(navId) || namesInstance(navId)));
29675
30485
  };
30486
+ const isRouteParam = (navId) => navMap[navId]?.presentation === "dynamic";
29676
30487
  const landing = landingNavId(navMap);
29677
30488
  const menuChildren = (navId) => (navMap[navId]?.children ?? []).flatMap((childId) => {
29678
30489
  if (isDefaultNavId(childId)) return menuChildren(childId);
@@ -29697,9 +30508,9 @@ var navAssetFiles = (navMap, { appName } = {}) => {
29697
30508
  // out of the Address. An asset for it would be fetched once and used
29698
30509
  // for nothing.
29699
30510
  !isDefaultNavId(nav.navId) && // Only emit App Navs with labels; Platform Navs always have labels,
29700
- // and a row-drawing `dynamic` Nav is exempt for the reason `hasLabel`
29701
- // gives.
29702
- hasLabel(nav.navId)
30511
+ // a row-drawing `dynamic` Nav is exempt for the reason `hasLabel`
30512
+ // gives, and every `dynamic` Nav for the reason `isRouteParam` gives.
30513
+ (hasLabel(nav.navId) || isRouteParam(nav.navId))
29703
30514
  ).sort((a, b) => a.navId.localeCompare(b.navId)).forEach((nav) => {
29704
30515
  files3.push({
29705
30516
  path: `navs/${nav.navId}.yml`,
@@ -30884,6 +31695,7 @@ function sanitizeMethods(methods, properties, functions = {}) {
30884
31695
  ...path ? { path } : {},
30885
31696
  ...arg ? { arg } : {},
30886
31697
  ...compute ? { compute } : {},
31698
+ ...check.count === true ? { count: true } : {},
30887
31699
  ...typeof check.value === "string" ? { value: check.value } : {}
30888
31700
  }
30889
31701
  };
@@ -30902,8 +31714,12 @@ function sanitizeMethods(methods, properties, functions = {}) {
30902
31714
  (check) => !!check && typeof check.id === "string" && !!check.id && METHOD_VARIANT_SOURCES.includes(check.source) && RULE_OPERATORS.includes(check.operator) && (check.source !== "store" || Array.isArray(check.path) && check.path.every((segment) => typeof segment === "string") && !!check.path.length && !!properties[check.path[0]]) && (check.source !== "args" || !!check.arg) && (check.source !== "compute" || computes.some((compute) => compute.name === check.compute)) && (check.source !== "response" || typeof check.code === "string" && /^\d{3}$/.test(check.code))
30903
31715
  ).map((check) => {
30904
31716
  const transform = sanitizeTransform(check.transform, functions);
30905
- const { transform: _drop, ...rest } = check;
30906
- return transform ? { ...rest, transform } : rest;
31717
+ const { transform: _drop, count, ...rest } = check;
31718
+ return {
31719
+ ...rest,
31720
+ ...count === true ? { count: true } : {},
31721
+ ...transform ? { transform } : {}
31722
+ };
30907
31723
  })
30908
31724
  }));
30909
31725
  const paramNames = /* @__PURE__ */ new Set();
@@ -31495,6 +32311,15 @@ function sanitizeStoreHook(value, properties, methods, roots = properties) {
31495
32311
  if (!reads.length && !writes.length && !calls.length) return void 0;
31496
32312
  return { reads, writes, calls };
31497
32313
  }
32314
+ function storedCallOutcome(value, methodId) {
32315
+ if (!methodId || !value || typeof value !== "object" || Array.isArray(value))
32316
+ return {};
32317
+ const outcome = value;
32318
+ const arms = ["success", "denied", "failure"].filter(
32319
+ (arm) => !!outcome[arm] && typeof outcome[arm] === "object"
32320
+ );
32321
+ return arms.length ? { outcome: Object.fromEntries(arms.map((arm) => [arm, outcome[arm]])) } : {};
32322
+ }
31498
32323
  function sanitizeAutoCalls(calls, kind) {
31499
32324
  if (!Array.isArray(calls)) return [];
31500
32325
  const result = [];
@@ -31505,7 +32330,11 @@ function sanitizeAutoCalls(calls, kind) {
31505
32330
  if (typeof call.id !== "string" || !call.id) continue;
31506
32331
  const methodId = hasStore(kind) && typeof call.methodId === "string" && call.methodId ? call.methodId : void 0;
31507
32332
  const emits = screenEmitRows({ emits: call.emits }, "emits");
31508
- if (!methodId && !emits.length) continue;
32333
+ const writes = hasStore(kind) && Array.isArray(call.writes) ? call.writes : [];
32334
+ const screenWrites = Array.isArray(call.screenWrites) ? call.screenWrites : [];
32335
+ const screenMethodId = typeof call.screenMethodId === "string" && call.screenMethodId ? call.screenMethodId : void 0;
32336
+ if (!methodId && !emits.length && !writes.length && !screenWrites.length && !screenMethodId)
32337
+ continue;
31509
32338
  const reads = Array.isArray(call.reads) ? call.reads.filter(
31510
32339
  (read) => !!read && typeof read === "object" && !!read.root && Array.isArray(read.path)
31511
32340
  ) : [];
@@ -31520,9 +32349,16 @@ function sanitizeAutoCalls(calls, kind) {
31520
32349
  // Rows answer a method's parameters, so a call-less auto-call keeps none.
31521
32350
  args: methodId && Array.isArray(call.args) ? call.args : [],
31522
32351
  ...emits.length ? { emits } : {},
32352
+ ...writes.length ? { writes } : {},
32353
+ ...screenWrites.length ? { screenWrites } : {},
32354
+ ...screenMethodId ? {
32355
+ screenMethodId,
32356
+ screenMethodArgs: Array.isArray(call.screenMethodArgs) ? call.screenMethodArgs : []
32357
+ } : {},
31523
32358
  // Trusted like `args`: a read naming something gone drops at emit and is
31524
32359
  // reported as an EmitGap (ADR 0206).
31525
32360
  ...reads.length ? { reads } : {},
32361
+ ...storedCallOutcome(call.outcome, methodId),
31526
32362
  // Kept only where it was drawn: an absent `when` is derived from the rows
31527
32363
  // by screenAutoCallWhen, so a Screen saved before ADR 0080 loads exactly
31528
32364
  // as it emitted then.
@@ -31552,7 +32388,11 @@ function sanitizeScreenMethods(value, taken) {
31552
32388
  ...Array.isArray(method.params) && method.params.length ? { params: sanitizeScreenMethodParams(method.params) } : {},
31553
32389
  // The further calls (GLOSSARY.md OutputCall), each trusted the way the
31554
32390
  // handler's own call is: an object, one of the two ids at most.
31555
- ...Array.isArray(method.calls) && method.calls.length ? { calls: sanitizeScreenMethodCalls(method.calls) } : {}
32391
+ ...Array.isArray(method.calls) && method.calls.length ? { calls: sanitizeScreenMethodCalls(method.calls) } : {},
32392
+ ...storedCallOutcome(
32393
+ method.outcome,
32394
+ typeof method.methodId === "string" ? method.methodId : void 0
32395
+ )
31556
32396
  };
31557
32397
  }
31558
32398
  return result;
@@ -31560,7 +32400,11 @@ function sanitizeScreenMethods(value, taken) {
31560
32400
  function sanitizeScreenMethodCalls(value) {
31561
32401
  return value.filter((raw) => !!raw && typeof raw === "object").map((call) => ({
31562
32402
  ...typeof call.methodId === "string" && call.methodId ? { methodId: call.methodId } : typeof call.functionId === "string" && call.functionId ? { functionId: call.functionId } : {},
31563
- ...Array.isArray(call.args) && call.args.length ? { args: call.args } : {}
32403
+ ...Array.isArray(call.args) && call.args.length ? { args: call.args } : {},
32404
+ ...storedCallOutcome(
32405
+ call.outcome,
32406
+ typeof call.methodId === "string" ? call.methodId : void 0
32407
+ )
31564
32408
  }));
31565
32409
  }
31566
32410
  function sanitizeScreenMethodParams(value) {
@@ -31823,8 +32667,8 @@ function sanitizeScreens(screens, features, appFunctions, sharedShapes = {}, enu
31823
32667
  if (Object.keys(variants).length) meta.variants = variants;
31824
32668
  const outputs = sanitizeScreenOutputs(screen.outputs, kind);
31825
32669
  if (Object.keys(outputs).length) meta.outputs = outputs;
31826
- const autoCalls = splitAutoCallEmits(
31827
- sanitizeAutoCalls(screen.autoCalls, kind),
32670
+ const autoCalls = withDerivedWatch(
32671
+ splitAutoCallEmits(sanitizeAutoCalls(screen.autoCalls, kind), inputs),
31828
32672
  inputs
31829
32673
  );
31830
32674
  if (autoCalls.length) meta.autoCalls = autoCalls;
@@ -36104,7 +36948,13 @@ var featureContextOf = (ws, feature) => ({
36104
36948
  var featureMethodArms = (ws, featureId) => featureId ? methodArms(
36105
36949
  ws.screens.filter(
36106
36950
  ({ meta }) => meta.kind === "feature" && meta.featureId === featureId
36107
- ).map(({ state }) => state.controlMap)
36951
+ ).map(({ state }) => state.controlMap),
36952
+ ws.screens.filter(
36953
+ ({ meta }) => meta.kind === "feature" && meta.featureId === featureId
36954
+ ).map(({ meta }) => ({
36955
+ methods: meta.methods,
36956
+ autoCalls: meta.autoCalls
36957
+ }))
36108
36958
  ) : {};
36109
36959
  var featureUsesBusy = (ws, featureId) => !!featureId && ws.screens.some(
36110
36960
  ({ meta, state }) => meta.kind === "feature" && meta.featureId === featureId && controlMapUsesBusy(state.controlMap)
@@ -36391,7 +37241,13 @@ var emitAuthoredAssets = (ws, stringify) => {
36391
37241
  (feature) => methodConfirmKeys(feature.methods)
36392
37242
  ),
36393
37243
  // A DenialDialog's messages, handed to the dialog the same way.
36394
- ...denialTranslationKeys(map)
37244
+ ...denialTranslationKeys(
37245
+ map,
37246
+ ws.screens.map(({ meta }) => ({
37247
+ methods: meta.methods,
37248
+ autoCalls: meta.autoCalls
37249
+ }))
37250
+ )
36395
37251
  ]).forEach((asset) => {
36396
37252
  files3.push({
36397
37253
  path: `mag_assets/${asset.path}`,
@@ -36679,6 +37535,7 @@ var HISTORY_LABELS = [
36679
37535
  // the Undo button reads the Fix it takes back (ADR 0192).
36680
37536
  "fix-cast",
36681
37537
  "fix-prune",
37538
+ "fix-remove-method",
36682
37539
  "fix-retype-parameters",
36683
37540
  "fix-route-inputs"
36684
37541
  ];
@@ -36920,6 +37777,7 @@ var HISTORY_SELECTION_KEYS = [
36920
37777
  ONE_FUNCTIONS,
36921
37778
  ONE_FUNCTION_CATALOG,
36922
37779
  ONE_FUNCTION_DATA_PARAM,
37780
+ ONE_FUNCTION_IDS_MAP_PARAM,
36923
37781
  ONE_FUNCTION_IDS_PARAM,
36924
37782
  ONE_FUNCTION_ID_PARAM,
36925
37783
  ONE_FUNCTION_KEY_PARAM,
@@ -37201,6 +38059,7 @@ var HISTORY_SELECTION_KEYS = [
37201
38059
  checkedFieldIds,
37202
38060
  checksUsingFunction,
37203
38061
  childNavId,
38062
+ classCallOutcomes,
37204
38063
  classCardScope,
37205
38064
  clearOutputCallRows,
37206
38065
  clearOutputGroupRows,
@@ -37276,6 +38135,7 @@ var HISTORY_SELECTION_KEYS = [
37276
38135
  controlUsesOverlayRef,
37277
38136
  controlVariantIds,
37278
38137
  controlVariants,
38138
+ controlWireOutcomes,
37279
38139
  countFormResetReferences,
37280
38140
  countIconReferences,
37281
38141
  countOptionSetReferences,
@@ -37306,6 +38166,7 @@ var HISTORY_SELECTION_KEYS = [
37306
38166
  customReadme,
37307
38167
  dataTypeFits,
37308
38168
  dataTypeMismatch,
38169
+ declaredPayload,
37309
38170
  declaresOutputs,
37310
38171
  declaresShapeInput,
37311
38172
  decodeKeySource,
@@ -37467,6 +38328,7 @@ var HISTORY_SELECTION_KEYS = [
37467
38328
  formModelSourceType,
37468
38329
  formModelStateOptions,
37469
38330
  formModelTransforms,
38331
+ formQueryReaches,
37470
38332
  formRefName,
37471
38333
  formRefNames,
37472
38334
  formResetDepths,
@@ -37655,6 +38517,7 @@ var HISTORY_SELECTION_KEYS = [
37655
38517
  isNavInstanceFunction,
37656
38518
  isNavRowShape,
37657
38519
  isNavVisibilityFunction,
38520
+ isObjectRepeatSource,
37658
38521
  isOnChange,
37659
38522
  isOneFunctionComputed,
37660
38523
  isOneFunctionStateComputed,
@@ -37679,6 +38542,7 @@ var HISTORY_SELECTION_KEYS = [
37679
38542
  isPathResolved,
37680
38543
  isPrimitiveType,
37681
38544
  isPureFunctionComplete,
38545
+ isReactionAutoCall,
37682
38546
  isRedirectRoute,
37683
38547
  isReferencedByRule,
37684
38548
  isReleaseVersion,
@@ -37825,6 +38689,7 @@ var HISTORY_SELECTION_KEYS = [
37825
38689
  methodArms,
37826
38690
  methodConfirmKeys,
37827
38691
  methodSignature,
38692
+ methodSpecShapes,
37828
38693
  methodUsage,
37829
38694
  methodsPersist,
37830
38695
  migrateStored,
@@ -37894,6 +38759,7 @@ var HISTORY_SELECTION_KEYS = [
37894
38759
  needsKey,
37895
38760
  needsValueTranslation,
37896
38761
  nestMenuItem,
38762
+ nestedOutcomeCalls,
37897
38763
  newCardAliases,
37898
38764
  newComputedOption,
37899
38765
  newInstanceFunctionOption,
@@ -37922,6 +38788,7 @@ var HISTORY_SELECTION_KEYS = [
37922
38788
  normalizeThemeName,
37923
38789
  normalizeTranslationKey,
37924
38790
  normalizeVariantName,
38791
+ objectMemberShapeId,
37925
38792
  offersOutputArms,
37926
38793
  oneFunctionArgFits,
37927
38794
  oneFunctionBoundSignature,
@@ -37937,6 +38804,7 @@ var HISTORY_SELECTION_KEYS = [
37937
38804
  oneFunctionSiteFits,
37938
38805
  oneParamFixedHeld,
37939
38806
  oneParamStatePathOnly,
38807
+ oneParamTakesAnyRow,
37940
38808
  oneParamTakesFixed,
37941
38809
  oneParamTypeText,
37942
38810
  openError,
@@ -37963,6 +38831,7 @@ var HISTORY_SELECTION_KEYS = [
37963
38831
  outcomeNavStatement,
37964
38832
  outcomeReadsArgs,
37965
38833
  outcomeReport,
38834
+ outcomeTransformArgFits,
37966
38835
  outcomeTransformError,
37967
38836
  outcomeTransformFailure,
37968
38837
  outcomeTransformFunction,
@@ -38141,6 +39010,7 @@ var HISTORY_SELECTION_KEYS = [
38141
39010
  renameMenuItemId,
38142
39011
  renameScreenMethodParamReads,
38143
39012
  repairCallOutcome,
39013
+ repairClassCallSites,
38144
39014
  repairFieldCheckSignatures,
38145
39015
  repairMarkdownLinkUrls,
38146
39016
  repairMessageVariables,
@@ -38216,6 +39086,7 @@ var HISTORY_SELECTION_KEYS = [
38216
39086
  scaffoldFiles,
38217
39087
  scanForCode,
38218
39088
  scannedOutputArms,
39089
+ screenAutoCallDoesAnything,
38219
39090
  screenAutoCallError,
38220
39091
  screenAutoCallWhen,
38221
39092
  screenComponentSite,
@@ -38489,9 +39360,12 @@ var HISTORY_SELECTION_KEYS = [
38489
39360
  validationTest,
38490
39361
  valueSourceOf,
38491
39362
  variableDrift,
39363
+ variantCheckCountable,
38492
39364
  variantCheckError,
38493
39365
  variantCheckId,
38494
39366
  variantCheckLeaf,
39367
+ variantCheckOperand,
39368
+ variantCheckOperatorFits,
38495
39369
  variantCheckOperators,
38496
39370
  variantCheckType,
38497
39371
  variantError,
@@ -38508,6 +39382,8 @@ var HISTORY_SELECTION_KEYS = [
38508
39382
  variantsForCode,
38509
39383
  variantsForNewControl,
38510
39384
  variantsReferencing,
39385
+ watchFields,
39386
+ watchKey,
38511
39387
  wcClassName,
38512
39388
  wcSelector,
38513
39389
  widgetDir,
@@ -38517,6 +39393,7 @@ var HISTORY_SELECTION_KEYS = [
38517
39393
  withCallArgOptional,
38518
39394
  withCases,
38519
39395
  withDefaultRow,
39396
+ withDerivedWatch,
38520
39397
  withEmittedTests,
38521
39398
  withEventTransform,
38522
39399
  withFormShapes,