@magmonium/cli 0.8.27 → 0.8.28

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.
Files changed (2) hide show
  1. package/codegen/index.js +679 -253
  2. package/package.json +1 -1
package/codegen/index.js CHANGED
@@ -209,6 +209,7 @@ __export(index_exports, {
209
209
  METHOD_VARIANT_SOURCES: () => METHOD_VARIANT_SOURCES,
210
210
  MIGRATION_FLOOR: () => MIGRATION_FLOOR,
211
211
  MODAL_STORE: () => MODAL_STORE,
212
+ NATIVE_ONE_FUNCTION_SPECS: () => NATIVE_ONE_FUNCTION_SPECS,
212
213
  NAV_ID_SEP: () => NAV_ID_SEP2,
213
214
  NAV_LINK_KINDS: () => NAV_LINK_KINDS,
214
215
  NAV_PRESENTATIONS: () => NAV_PRESENTATIONS,
@@ -229,9 +230,12 @@ __export(index_exports, {
229
230
  ONE_FUNCTIONS: () => ONE_FUNCTIONS,
230
231
  ONE_FUNCTION_CATALOG: () => ONE_FUNCTION_CATALOG,
231
232
  ONE_FUNCTION_DATA_PARAM: () => ONE_FUNCTION_DATA_PARAM,
233
+ ONE_FUNCTION_IDS_PARAM: () => ONE_FUNCTION_IDS_PARAM,
232
234
  ONE_FUNCTION_ID_PARAM: () => ONE_FUNCTION_ID_PARAM,
235
+ ONE_FUNCTION_KEY_PARAM: () => ONE_FUNCTION_KEY_PARAM,
233
236
  ONE_FUNCTION_MAP_PARAM: () => ONE_FUNCTION_MAP_PARAM,
234
237
  ONE_FUNCTION_PREFIX: () => ONE_FUNCTION_PREFIX,
238
+ ONE_FUNCTION_SPECS: () => ONE_FUNCTION_SPECS,
235
239
  ONE_IMPORT_MODULE: () => ONE_IMPORT_MODULE,
236
240
  ONE_PACKAGE_VERSION: () => ONE_PACKAGE_VERSION,
237
241
  OPEN_SCREEN_INPUT_SOURCES: () => OPEN_SCREEN_INPUT_SOURCES,
@@ -542,22 +546,27 @@ __export(index_exports, {
542
546
  composeFunctionBinding: () => composeFunctionBinding,
543
547
  composeLabelValue: () => composeLabelValue,
544
548
  computeError: () => computeError,
549
+ computeFunction: () => computeFunction,
545
550
  computeId: () => computeId,
546
551
  computeInputMemberError: () => computeInputMemberError,
547
552
  computeInputPaths: () => computeInputPaths,
548
553
  computeIsRead: () => computeIsRead,
549
554
  computeMemberRead: () => computeMemberRead,
550
555
  computeNameTaken: () => computeNameTaken,
556
+ computeOneFunction: () => computeOneFunction,
557
+ computeOneReturns: () => computeOneReturns,
551
558
  computeReadable: () => computeReadable,
552
559
  computeTextPaths: () => computeTextPaths,
553
560
  computedAsProperty: () => computedAsProperty,
554
561
  computedLocalNames: () => computedLocalNames,
555
562
  computedRootIds: () => computedRootIds,
563
+ conditionArgValue: () => conditionArgValue,
556
564
  conditionCheckType: () => conditionCheckType,
557
565
  conditionError: () => conditionError,
558
566
  conditionFunction: () => conditionFunction,
559
567
  conditionId: () => conditionId,
560
568
  conditionKind: () => conditionKind,
569
+ conditionReadsCompute: () => conditionReadsCompute,
561
570
  configurableResponses: () => configurableResponses,
562
571
  confirmError: () => confirmError,
563
572
  confirmId: () => confirmId,
@@ -951,12 +960,14 @@ __export(index_exports, {
951
960
  isMethodInUse: () => isMethodInUse,
952
961
  isMountable: () => isMountable,
953
962
  isMovingScreenEmit: () => isMovingScreenEmit,
963
+ isNativeOneFunction: () => isNativeOneFunction,
954
964
  isNavAtOrBelow: () => isNavAtOrBelow,
955
965
  isNavInstanceFunction: () => isNavInstanceFunction,
956
966
  isNavRowShape: () => isNavRowShape,
957
967
  isNavVisibilityFunction: () => isNavVisibilityFunction,
958
968
  isOnChange: () => isOnChange,
959
969
  isOneFunctionComputed: () => isOneFunctionComputed,
970
+ isOneFunctionStateComputed: () => isOneFunctionStateComputed,
960
971
  isOptionRowShape: () => isOptionRowShape,
961
972
  isOrderingMenuActionOperator: () => isOrderingMenuActionOperator,
962
973
  isOrderingOutputArmOperator: () => isOrderingOutputArmOperator,
@@ -1223,12 +1234,21 @@ __export(index_exports, {
1223
1234
  normalizeVariantName: () => normalizeVariantName,
1224
1235
  offersOutputArms: () => offersOutputArms,
1225
1236
  oneFunctionArgFits: () => oneFunctionArgFits,
1237
+ oneFunctionBoundSignature: () => oneFunctionBoundSignature,
1238
+ oneFunctionFitsLanding: () => oneFunctionFitsLanding,
1226
1239
  oneFunctionFromPickValue: () => oneFunctionFromPickValue,
1240
+ oneFunctionLiftedAt: () => oneFunctionLiftedAt,
1241
+ oneFunctionMintsKey: () => oneFunctionMintsKey,
1227
1242
  oneFunctionOf: () => oneFunctionOf,
1228
1243
  oneFunctionPickValue: () => oneFunctionPickValue,
1229
1244
  oneFunctionReturns: () => oneFunctionReturns,
1230
1245
  oneFunctionSignature: () => oneFunctionSignature,
1231
1246
  oneFunctionSignatureText: () => oneFunctionSignatureText,
1247
+ oneFunctionSiteFits: () => oneFunctionSiteFits,
1248
+ oneParamFixedHeld: () => oneParamFixedHeld,
1249
+ oneParamStatePathOnly: () => oneParamStatePathOnly,
1250
+ oneParamTakesFixed: () => oneParamTakesFixed,
1251
+ oneParamTypeText: () => oneParamTypeText,
1232
1252
  openError: () => openError,
1233
1253
  openId: () => openId,
1234
1254
  openInputAnswered: () => openInputAnswered,
@@ -1640,6 +1660,7 @@ __export(index_exports, {
1640
1660
  starterFunction: () => starterFunction,
1641
1661
  stateComputedArgExpression: () => stateComputedArgExpression,
1642
1662
  stateComputedArgHeldType: () => stateComputedArgHeldType,
1663
+ stateComputedFunction: () => stateComputedFunction,
1643
1664
  stateInterfaceName: () => stateInterfaceName,
1644
1665
  statePathHeldType: () => statePathHeldType,
1645
1666
  statePathRead: () => statePathRead,
@@ -5227,87 +5248,249 @@ var screenMethodCalls = (method) => method ? [
5227
5248
 
5228
5249
  // libs/codegen/src/model/one-function-catalog.ts
5229
5250
  var ONE_FUNCTION_ID_PARAM = "id";
5251
+ var ONE_FUNCTION_IDS_PARAM = "ids";
5230
5252
  var ONE_FUNCTION_MAP_PARAM = "map";
5231
5253
  var ONE_FUNCTION_DATA_PARAM = "data";
5254
+ var ONE_FUNCTION_KEY_PARAM = "key";
5232
5255
  var ONE_FUNCTION_PREFIX = "one:";
5233
- var signatureParam = (param, row) => ({
5234
- id: param.id,
5235
- name: param.name,
5236
- dataType: param.rule === "string-one" ? { type: "string" } : row,
5237
- cardinality: param.rule === "map-path" ? "map" : "one",
5238
- acceptsUndefined: true
5239
- });
5240
- var defineOneFunction = (spec) => {
5241
- const { returns, ...entry2 } = spec;
5242
- return {
5243
- ...entry2,
5244
- importFrom: ONE_IMPORT_MODULE,
5245
- returnsRow: returns !== "boolean",
5246
- signature: (row) => ({
5247
- params: entry2.params.map((param) => signatureParam(param, row)),
5248
- ...returns === "boolean" ? { returnType: { type: "boolean" }, returnCardinality: "one" } : returns === "row" ? { returnType: row, returnCardinality: "one", returnUndefined: true } : { returnType: row, returnCardinality: "map" }
5249
- })
5250
- };
5256
+ var ID = {
5257
+ id: ONE_FUNCTION_ID_PARAM,
5258
+ name: "id",
5259
+ type: "string",
5260
+ cardinality: "one"
5251
5261
  };
5252
- var ONE_FUNCTIONS = [
5262
+ var MAP = {
5263
+ id: ONE_FUNCTION_MAP_PARAM,
5264
+ name: "map",
5265
+ type: "T",
5266
+ cardinality: "map",
5267
+ statePathOnly: true
5268
+ };
5269
+ var ONE_FUNCTION_SPECS = {
5253
5270
  // `getFromMap<T>(id, map: Record<string, T>): T | undefined` — the row a
5254
5271
  // `map` holds under an id, typically a ScreenInput a Page was handed.
5255
- defineOneFunction({
5256
- name: "getFromMap",
5257
- reach: ["screen-computed"],
5258
- returns: "row",
5272
+ getFromMap: {
5273
+ params: [ID, MAP],
5274
+ returns: { type: "T", cardinality: "one", optional: true }
5275
+ },
5276
+ // `getManyFromMaps<T>(ids: string[], map: Record<string, T>): T[]` — the
5277
+ // rows a `map` holds under each id, in id order, a miss skipped. Over a
5278
+ // `map-many` it answers every id's list joined into one flat list, so its
5279
+ // return stays `many` where the record lifts.
5280
+ getManyFromMaps: {
5259
5281
  params: [
5260
- { id: ONE_FUNCTION_ID_PARAM, name: "id", rule: "string-one" },
5261
- { id: ONE_FUNCTION_MAP_PARAM, name: "map", rule: "map-path" }
5282
+ {
5283
+ id: ONE_FUNCTION_IDS_PARAM,
5284
+ name: "ids",
5285
+ type: "string",
5286
+ cardinality: "many"
5287
+ },
5288
+ MAP
5262
5289
  ],
5263
- rowParamId: ONE_FUNCTION_MAP_PARAM,
5264
- rowCardinality: "map"
5265
- }),
5290
+ returns: { type: "T", cardinality: "many", liftsTo: "many" }
5291
+ },
5266
5292
  // `existsInMap(id, map: Record<string, unknown>): boolean` — whether a
5267
5293
  // `map` holds anything under an id (ADR 0202). `false` rather than
5268
5294
  // `undefined` while either is, so a gate on an unloaded store reads "not
5269
5295
  // there yet" and a computed over it never needs `?.`.
5270
- defineOneFunction({
5271
- name: "existsInMap",
5272
- reach: ["screen-computed", "call-condition"],
5273
- returns: "boolean",
5296
+ existsInMap: {
5297
+ params: [ID, MAP],
5298
+ returns: { type: "boolean", cardinality: "one" }
5299
+ },
5300
+ // `notExistsInMap(id, map: Record<string, unknown>): boolean` — the named
5301
+ // inverse, for a CallCondition alone: a computed reads `!existsInMap`.
5302
+ notExistsInMap: {
5303
+ params: [ID, MAP],
5304
+ returns: { type: "boolean", cardinality: "one" },
5305
+ narrowTo: ["call-condition"]
5306
+ },
5307
+ // `missingFromMap(ids: string[], map: Record<string, unknown>): string[] |
5308
+ // undefined` — the ids a `map` does not hold yet, in id order and each
5309
+ // once: what is still to fetch. `undefined` while the ids are missing or
5310
+ // empty and once the map holds every one; every id while the map is
5311
+ // missing. A ScreenComputed or a CallCompute by its signature: it answers
5312
+ // neither a `boolean` nor `T` (ADR 0216).
5313
+ missingFromMap: {
5274
5314
  params: [
5275
- { id: ONE_FUNCTION_ID_PARAM, name: "id", rule: "string-one" },
5276
- { id: ONE_FUNCTION_MAP_PARAM, name: "map", rule: "map-path" }
5315
+ {
5316
+ id: ONE_FUNCTION_IDS_PARAM,
5317
+ name: "ids",
5318
+ type: "string",
5319
+ cardinality: "many"
5320
+ },
5321
+ MAP
5277
5322
  ],
5278
- rowParamId: ONE_FUNCTION_MAP_PARAM,
5279
- rowCardinality: "map"
5280
- }),
5281
- // `notExistsInMap(id, map: Record<string, unknown>): boolean` — the
5282
- // named inverse, offered on CallConditions (ADR 0202).
5283
- defineOneFunction({
5284
- name: "notExistsInMap",
5285
- reach: ["call-condition"],
5286
- returns: "boolean",
5323
+ returns: { type: "string", cardinality: "many", optional: true }
5324
+ },
5325
+ // `anyMissingFromMap(ids: string[], map: Record<string, unknown>): boolean`
5326
+ // — whether `missingFromMap` would answer any id: the gate a batch call is
5327
+ // dropped by once every row is held (ADR 0216). For a CallCondition alone:
5328
+ // a computed reads `missingFromMap` itself.
5329
+ anyMissingFromMap: {
5287
5330
  params: [
5288
- { id: ONE_FUNCTION_ID_PARAM, name: "id", rule: "string-one" },
5289
- { id: ONE_FUNCTION_MAP_PARAM, name: "map", rule: "map-path" }
5331
+ {
5332
+ id: ONE_FUNCTION_IDS_PARAM,
5333
+ name: "ids",
5334
+ type: "string",
5335
+ cardinality: "many"
5336
+ },
5337
+ MAP
5290
5338
  ],
5291
- rowParamId: ONE_FUNCTION_MAP_PARAM,
5292
- rowCardinality: "map"
5293
- }),
5339
+ returns: { type: "boolean", cardinality: "one" },
5340
+ narrowTo: ["call-condition"]
5341
+ },
5294
5342
  // `setInMap<T>(id, data: T, map: Record<string, T>): Record<string, T>` —
5295
5343
  // the map with `data` held under `id`, every other entry kept (ADR 0205).
5296
- // `loadCoin(id)` answers one coin and `coinsById[id]` is where it lands.
5297
- // Offered on an OutcomeTransform alone, where the landing names `T`.
5298
- defineOneFunction({
5299
- name: "setInMap",
5300
- reach: ["outcome-transform"],
5301
- returns: "row-map",
5344
+ // For an OutcomeTransform alone: a computed has no landing to keep entries of.
5345
+ setInMap: {
5302
5346
  params: [
5303
- { id: ONE_FUNCTION_ID_PARAM, name: "id", rule: "string-one" },
5304
- { id: ONE_FUNCTION_DATA_PARAM, name: "data", rule: "row-one" },
5305
- { id: ONE_FUNCTION_MAP_PARAM, name: "map", rule: "map-path" }
5347
+ ID,
5348
+ {
5349
+ id: ONE_FUNCTION_DATA_PARAM,
5350
+ name: "data",
5351
+ type: "T",
5352
+ cardinality: "one"
5353
+ },
5354
+ MAP
5306
5355
  ],
5307
- rowParamId: ONE_FUNCTION_DATA_PARAM,
5308
- rowCardinality: "one"
5309
- })
5356
+ returns: { type: "T", cardinality: "map" },
5357
+ narrowTo: ["outcome-transform"]
5358
+ },
5359
+ // `mapMany<T>(data: T[], key: keyof T, map: Record<string, T[]>):
5360
+ // Record<string, T[]>` — a flat list of rows landed into a `map-many`, each
5361
+ // row grouped under its `key` member: a batch `loadCurves(ids)` answers
5362
+ // every strategy's points in one list, each naming its strategy in `sid`.
5363
+ // A key the list names has its list replaced, every other entry is kept.
5364
+ mapMany: {
5365
+ params: [
5366
+ {
5367
+ id: ONE_FUNCTION_DATA_PARAM,
5368
+ name: "data",
5369
+ type: "T",
5370
+ cardinality: "many"
5371
+ },
5372
+ {
5373
+ id: ONE_FUNCTION_KEY_PARAM,
5374
+ name: "key",
5375
+ type: "string",
5376
+ cardinality: "one"
5377
+ },
5378
+ { ...MAP, cardinality: "map-many" }
5379
+ ],
5380
+ returns: { type: "T", cardinality: "map-many" },
5381
+ narrowTo: ["outcome-transform"]
5382
+ },
5383
+ // `pluckStrings<T>(items: T[], key: string): string[]` — the `string`
5384
+ // values one member of each row holds, in row order: the ids of a list a
5385
+ // later lookup reads by. `key` is typed in like `mapMany`'s, prefilled with
5386
+ // the row's id-named `string` member; a value that is not a string is
5387
+ // skipped, and missing items or key answer `[]` (ADR 0218).
5388
+ pluckStrings: {
5389
+ params: [
5390
+ {
5391
+ id: ONE_FUNCTION_DATA_PARAM,
5392
+ name: "items",
5393
+ type: "T",
5394
+ cardinality: "many"
5395
+ },
5396
+ {
5397
+ id: ONE_FUNCTION_KEY_PARAM,
5398
+ name: "key",
5399
+ type: "string",
5400
+ cardinality: "one"
5401
+ }
5402
+ ],
5403
+ returns: { type: "string", cardinality: "many" }
5404
+ }
5405
+ };
5406
+ var NATIVE_ONE_FUNCTION_SPECS = {
5407
+ // `Object.assign({}, target, source)` — a keyed answer merged into a keyed
5408
+ // landing: every entry of `source` held over `target`, every other entry of
5409
+ // `target` kept. Spelled onto a fresh `{}` so the store's own state object
5410
+ // is never written in place. Lifts like `setInMap`, so `{ [id]: points }`
5411
+ // merges into a `map-many` whole.
5412
+ "Object.assign": {
5413
+ params: [
5414
+ {
5415
+ id: ONE_FUNCTION_MAP_PARAM,
5416
+ name: "target",
5417
+ type: "T",
5418
+ cardinality: "map",
5419
+ statePathOnly: true
5420
+ },
5421
+ {
5422
+ id: ONE_FUNCTION_DATA_PARAM,
5423
+ name: "source",
5424
+ type: "T",
5425
+ cardinality: "map"
5426
+ }
5427
+ ],
5428
+ returns: { type: "T", cardinality: "map" },
5429
+ narrowTo: ["outcome-transform"],
5430
+ spell: (args) => `Object.assign({}, ${args.join(", ")})`
5431
+ }
5432
+ };
5433
+ var LIFT = {
5434
+ one: "many",
5435
+ map: "map-many"
5436
+ };
5437
+ var slots = (spec) => [
5438
+ ...spec.params,
5439
+ spec.returns
5440
+ ];
5441
+ var lifts = (spec) => slots(spec).some((slot) => slot.type === "T") && slots(spec).every((slot) => slot.type !== "T" || !!liftOf(slot));
5442
+ var liftOf = (slot) => slot.liftsTo ?? LIFT[slot.cardinality];
5443
+ var liftedCardinality = (slot, lifted) => lifted && slot.type === "T" ? liftOf(slot) ?? slot.cardinality : slot.cardinality;
5444
+ 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;
5446
+ var REACHES = [
5447
+ "screen-computed",
5448
+ "state-computed",
5449
+ "call-condition",
5450
+ "call-compute",
5451
+ "outcome-transform"
5310
5452
  ];
5453
+ var defineOneFunction = (name3, spec) => {
5454
+ const liftable = lifts(spec);
5455
+ const params = spec.params.map(
5456
+ ({ liftsTo: _declared, ...param }) => ({
5457
+ ...param,
5458
+ ...liftable && param.type === "T" ? { liftsTo: liftOf(param) } : {}
5459
+ })
5460
+ );
5461
+ const rowParam = params.find((param) => param.type === "T" && param.statePathOnly) ?? params.find((param) => param.type === "T");
5462
+ return {
5463
+ name: name3,
5464
+ ..."spell" in spec ? { spell: spec.spell } : { importFrom: ONE_IMPORT_MODULE },
5465
+ reach: REACHES.filter(
5466
+ (reach) => oneFunctionSiteFits(spec, reach) && (!spec.narrowTo || spec.narrowTo.includes(reach))
5467
+ ),
5468
+ ...spec.narrowTo ? { narrowTo: spec.narrowTo } : {},
5469
+ returnsRow: spec.returns.type === "T",
5470
+ params,
5471
+ returns: spec.returns,
5472
+ rowParamId: rowParam?.id ?? "",
5473
+ signature: (row, lifted = false) => ({
5474
+ params: params.map(
5475
+ (param) => ({
5476
+ id: param.id,
5477
+ name: param.name,
5478
+ dataType: slotDataType(param, row),
5479
+ cardinality: liftedCardinality(param, lifted),
5480
+ acceptsUndefined: true
5481
+ })
5482
+ ),
5483
+ returnType: slotDataType(spec.returns, row),
5484
+ returnCardinality: liftedCardinality(spec.returns, lifted),
5485
+ ...spec.returns.optional ? { returnUndefined: true } : {}
5486
+ })
5487
+ };
5488
+ };
5489
+ var ONE_FUNCTIONS = [
5490
+ ...Object.entries(ONE_FUNCTION_SPECS),
5491
+ ...Object.entries(NATIVE_ONE_FUNCTION_SPECS)
5492
+ ].map(([name3, spec]) => defineOneFunction(name3, spec));
5493
+ var isNativeOneFunction = (entry2) => !!entry2?.spell;
5311
5494
  var ONE_FUNCTION_CATALOG = Object.fromEntries(ONE_FUNCTIONS.map((entry2) => [entry2.name, entry2]));
5312
5495
  var oneFunctionOf = (name3) => name3 ? ONE_FUNCTIONS.find((entry2) => entry2.name === name3) : void 0;
5313
5496
  var listOneFunctions = (reach = "screen-computed") => ONE_FUNCTIONS.filter((entry2) => entry2.reach.includes(reach)).sort(
@@ -5315,26 +5498,28 @@ var listOneFunctions = (reach = "screen-computed") => ONE_FUNCTIONS.filter((entr
5315
5498
  );
5316
5499
  var oneFunctionPickValue = (name3) => `${ONE_FUNCTION_PREFIX}${name3}`;
5317
5500
  var oneFunctionFromPickValue = (value) => value?.startsWith(ONE_FUNCTION_PREFIX) ? oneFunctionOf(value.slice(ONE_FUNCTION_PREFIX.length)) : void 0;
5501
+ var oneParamStatePathOnly = (param) => !!param.statePathOnly;
5502
+ var oneParamTakesFixed = (param) => param.type !== "T" && param.cardinality === "one" && !param.statePathOnly;
5503
+ var oneParamFixedHeld = (param, value) => oneParamTakesFixed(param) && param.type !== "T" && typeof value === param.type ? { dataType: { type: param.type }, cardinality: "one" } : void 0;
5318
5504
  function oneFunctionArgFits(param, held, fromPath) {
5319
5505
  if (!held) return false;
5320
- if (param.rule === "string-one")
5321
- return held.dataType.type === "string" && held.cardinality === "one";
5322
- if (param.rule === "row-one") return held.cardinality === "one";
5323
- return fromPath && isKeyedCardinality(held.cardinality);
5324
- }
5325
- var isKeyedCardinality = (cardinality) => cardinality === "map" || cardinality === "map-many";
5326
- function listedSignature(entry2, signature) {
5327
- return {
5328
- ...signature,
5329
- params: signature.params.map(
5330
- (param, index) => param.cardinality === "map" ? { ...param, cardinality: "map-many" } : entry2.params[index]?.rule === "row-one" ? { ...param, cardinality: "many" } : param
5331
- ),
5332
- returnCardinality: !entry2.returnsRow ? signature.returnCardinality : signature.returnCardinality === "map" ? "map-many" : "many"
5333
- };
5334
- }
5335
- var isListed = (entry2, cardinality) => entry2.returnsRow && (cardinality === "many" || cardinality === "map-many");
5336
- function oneFunctionReturns(entry2, row, mapCardinality = "map") {
5337
- const signature = mapCardinality === "map-many" ? listedSignature(entry2, entry2.signature(row)) : entry2.signature(row);
5506
+ if (param.statePathOnly && !fromPath) return false;
5507
+ if (param.type !== "T")
5508
+ return held.dataType.type === param.type && held.cardinality === param.cardinality;
5509
+ return held.cardinality === param.cardinality || held.cardinality === param.liftsTo;
5510
+ }
5511
+ var liftedBy = (entry2, paramId, cardinality) => {
5512
+ const param = entry2.params.find((candidate) => candidate.id === paramId);
5513
+ return !!param?.liftsTo && cardinality === param.liftsTo;
5514
+ };
5515
+ 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));
5517
+ var oneFunctionMintsKey = (entry2) => entry2.returnsRow && (entry2.returns.cardinality === "map" || entry2.returns.cardinality === "map-many");
5518
+ function oneFunctionReturns(entry2, row, heldCardinality) {
5519
+ const signature = entry2.signature(
5520
+ row,
5521
+ liftedBy(entry2, entry2.rowParamId, heldCardinality)
5522
+ );
5338
5523
  return {
5339
5524
  dataType: signature.returnType,
5340
5525
  cardinality: signature.returnCardinality,
@@ -5342,26 +5527,38 @@ function oneFunctionReturns(entry2, row, mapCardinality = "map") {
5342
5527
  };
5343
5528
  }
5344
5529
  function oneFunctionSignature(entry2, returns) {
5345
- const signature = entry2.signature(returns.dataType);
5346
5530
  return {
5347
5531
  id: "",
5348
5532
  name: entry2.name,
5349
5533
  // An entry answering a fixed type stores that type, not the row: its
5350
5534
  // `map` is spelled `Record<string, unknown>` by the library, so the stand-in
5351
5535
  // over the stored type reads the same at every reader.
5352
- ...isListed(entry2, returns.cardinality) ? listedSignature(entry2, signature) : signature,
5536
+ ...entry2.signature(
5537
+ returns.dataType,
5538
+ oneFunctionLiftedAt(entry2, returns.cardinality)
5539
+ ),
5540
+ body: ""
5541
+ };
5542
+ }
5543
+ function oneFunctionBoundSignature(entry2, row, heldCardinality) {
5544
+ return {
5545
+ id: "",
5546
+ name: entry2.name,
5547
+ ...entry2.signature(row, liftedBy(entry2, entry2.rowParamId, heldCardinality)),
5353
5548
  body: ""
5354
5549
  };
5355
5550
  }
5551
+ function oneParamTypeText(entry2, param, rowLabel) {
5552
+ const t = param.type !== "T" ? param.type : entry2.returnsRow ? rowLabel ?? "T" : "unknown";
5553
+ return param.cardinality === "map" ? `Record<string, ${t}>` : param.cardinality === "map-many" ? `Record<string, ${t}[]>` : param.cardinality === "many" ? `${t}[]` : t;
5554
+ }
5356
5555
  function oneFunctionSignatureText(entry2, rowLabel) {
5357
5556
  const generic = entry2.returnsRow && !rowLabel;
5358
- const t = entry2.returnsRow ? rowLabel ?? "T" : "unknown";
5359
5557
  const params = entry2.params.map(
5360
- (param) => param.rule === "string-one" ? `${param.name}: string` : param.rule === "row-one" ? `${param.name}: ${t}` : `${param.name}: Record<string, ${t}>`
5558
+ (param) => `${param.name}: ${oneParamTypeText(entry2, param, rowLabel)}`
5361
5559
  ).join(", ");
5362
- const signature = entry2.signature({ type: "string" });
5363
- const returns = !entry2.returnsRow ? "boolean" : signature.returnCardinality === "map" ? `Record<string, ${t}>` : `${t} | undefined`;
5364
- return `${entry2.name}${generic ? "<T>" : ""}(${params}): ${returns}`;
5560
+ const returns = oneParamTypeText(entry2, entry2.returns, rowLabel);
5561
+ return `${entry2.name}${generic ? "<T>" : ""}(${params}): ${entry2.returns.optional ? `${returns} | undefined` : returns}`;
5365
5562
  }
5366
5563
 
5367
5564
  // libs/codegen/src/lib/pure-function-helper.ts
@@ -5569,6 +5766,13 @@ function screenComputedFunction(computed, functions) {
5569
5766
  body: `return ${PASSTHROUGH_PARAM_ID};`
5570
5767
  };
5571
5768
  }
5769
+ function stateComputedFunction(computed, functions) {
5770
+ if (computed.functionId) return functions[computed.functionId];
5771
+ if (!computed.oneFunction || !computed.returns) return void 0;
5772
+ const entry2 = oneFunctionOf(computed.oneFunction);
5773
+ return entry2 ? oneFunctionSignature(entry2, computed.returns) : void 0;
5774
+ }
5775
+ var isOneFunctionStateComputed = (computed) => !computed.functionId && !!computed.oneFunction;
5572
5776
  var isPassthroughComputed = (computed) => !computed.functionId && !computed.oneFunction;
5573
5777
  var isOneFunctionComputed = (computed) => !computed.functionId && !!computed.oneFunction;
5574
5778
  function screenComputedNavIds(computed) {
@@ -5766,7 +5970,7 @@ function propertiesWithComputeds(properties, computeds = {}, functions = {}) {
5766
5970
  for (const computed of Object.values(computeds ?? {})) {
5767
5971
  const asProperty = computedAsProperty(
5768
5972
  computed,
5769
- functions[computed.functionId]
5973
+ stateComputedFunction(computed, functions)
5770
5974
  );
5771
5975
  if (asProperty) result[computed.id] = asProperty;
5772
5976
  }
@@ -6653,6 +6857,20 @@ var BINDING_TRANSFORM_LEAVES = [
6653
6857
  "binding"
6654
6858
  ];
6655
6859
 
6860
+ // libs/codegen/src/lib/compute-function.ts
6861
+ function computeFunction(compute, functions) {
6862
+ if (!compute) return void 0;
6863
+ if (compute.oneFunction) {
6864
+ const entry2 = computeOneFunction(compute);
6865
+ return entry2 && compute.returns ? oneFunctionSignature(entry2, compute.returns) : void 0;
6866
+ }
6867
+ return functions[compute.functionId];
6868
+ }
6869
+ var computeOneFunction = (compute) => {
6870
+ const entry2 = oneFunctionOf(compute.oneFunction);
6871
+ return entry2?.reach.includes("call-compute") ? entry2 : void 0;
6872
+ };
6873
+
6656
6874
  // libs/codegen/src/lib/outcome-transform-helper.ts
6657
6875
  var outcomeTransformOneFunction = (transform) => {
6658
6876
  const entry2 = oneFunctionOf(transform?.oneFunction);
@@ -6690,7 +6908,7 @@ var argValue = (binding, mapping, method, op, roots, shapes, functions) => {
6690
6908
  const compute = (method.computes ?? []).find(
6691
6909
  (candidate) => candidate.name === binding.name
6692
6910
  );
6693
- const fn = compute && functions[compute.functionId];
6911
+ const fn = computeFunction(compute, functions);
6694
6912
  return fn ? {
6695
6913
  value: {
6696
6914
  dataType: fn.returnType,
@@ -6797,7 +7015,8 @@ function outcomeTransformFailure(mapping, method, op, properties, shapes, functi
6797
7015
  }
6798
7016
  continue;
6799
7017
  }
6800
- if (one?.params[index]?.rule === "map-path" && binding?.source !== "state") {
7018
+ const oneParam = one?.params[index];
7019
+ if (oneParam && oneParamStatePathOnly(oneParam) && binding?.source !== "state") {
6801
7020
  return {
6802
7021
  error: "emit-gap-outcome-transform-source",
6803
7022
  paramIndex: index,
@@ -7448,22 +7667,7 @@ function sanitizeLeaf(leaf) {
7448
7667
  }
7449
7668
  }
7450
7669
 
7451
- // libs/codegen/src/lib/binding-helper.ts
7452
- var screenComputedPresent = (id, screenComputeds, functions, inputs) => {
7453
- const computed = screenComputeds?.[id];
7454
- const fn = computed ? screenComputedFunction(computed, functions ?? {}) : void 0;
7455
- if (!computed || !fn) return false;
7456
- if (fn.returnUndefined === true || returnCardinalityOf(fn) !== "one") {
7457
- return false;
7458
- }
7459
- return !screenComputedIsOptional(
7460
- computed,
7461
- fn,
7462
- inputs ?? {},
7463
- screenComputeds ?? {},
7464
- functions ?? {}
7465
- );
7466
- };
7670
+ // libs/codegen/src/lib/binding-slot.ts
7467
7671
  var BINDING_SLOT = {
7468
7672
  // A `text` Control's label, and a Stat's (libs/one ADR 0022). Renders
7469
7673
  // verbatim — the case where a bound value *is* a translation key is what a
@@ -7529,6 +7733,23 @@ var BINDING_SLOT = {
7529
7733
  // `configs.selection`, a Button's Control id.
7530
7734
  selection: "selection"
7531
7735
  };
7736
+
7737
+ // libs/codegen/src/lib/binding-helper.ts
7738
+ var screenComputedPresent = (id, screenComputeds, functions, inputs) => {
7739
+ const computed = screenComputeds?.[id];
7740
+ const fn = computed ? screenComputedFunction(computed, functions ?? {}) : void 0;
7741
+ if (!computed || !fn) return false;
7742
+ if (fn.returnUndefined === true || returnCardinalityOf(fn) !== "one") {
7743
+ return false;
7744
+ }
7745
+ return !screenComputedIsOptional(
7746
+ computed,
7747
+ fn,
7748
+ inputs ?? {},
7749
+ screenComputeds ?? {},
7750
+ functions ?? {}
7751
+ );
7752
+ };
7532
7753
  var USER_VALUE_SLOTS = [
7533
7754
  BINDING_SLOT.id,
7534
7755
  BINDING_SLOT.firstName,
@@ -8839,8 +9060,8 @@ var rootShapeId = (binding, scope, seen) => {
8839
9060
  return scope.formModels?.[root.id]?.formId;
8840
9061
  }
8841
9062
  if (root.kind === "computed") {
8842
- const functionId = scope.computeds?.[root.id]?.functionId;
8843
- const returnType = functionId ? scope.functions?.[functionId]?.returnType : void 0;
9063
+ const computed = scope.computeds?.[root.id];
9064
+ const returnType = computed ? stateComputedFunction(computed, scope.functions ?? {})?.returnType : void 0;
8844
9065
  if (returnType?.type === "shape") return returnType.shapeId;
8845
9066
  const folded = scope.properties?.[root.id]?.dataType;
8846
9067
  return folded?.type === "shape" ? folded.shapeId : void 0;
@@ -8908,7 +9129,7 @@ var bindingCardinality = (binding, scope, seen = /* @__PURE__ */ new Set()) => {
8908
9129
  }
8909
9130
  case "computed": {
8910
9131
  const computed = scope.computeds?.[root.id];
8911
- const fn = computed ? scope.functions?.[computed.functionId] : void 0;
9132
+ const fn = computed ? stateComputedFunction(computed, scope.functions ?? {}) : void 0;
8912
9133
  const folded = fn ? void 0 : scope.properties?.[root.id];
8913
9134
  dataType = fn?.returnType ?? folded?.dataType;
8914
9135
  cardinality = fn ? returnCardinalityOf(fn) : folded?.cardinality;
@@ -12914,40 +13135,40 @@ var isMenuActionSlotComplete = (slot) => slot.checks.length > 0 && slot.checks.e
12914
13135
  var menuActionSlot = (control, slotId) => menuActionSlots(control).find((slot) => slot.id === slotId);
12915
13136
  var menuActionCheckLabel = (check) => isUnaryMenuActionOperator(check.operator) ? `${check.member} ${check.operator.replace("_", " ")}` : `${check.member} ${check.operator} ${(check.value ?? "").trim()}`;
12916
13137
  var menuActionSummary = (slot) => slot.checks.map(menuActionCheckLabel).join(" and ");
12917
- var withSlots = (control, slots) => ({
13138
+ var withSlots = (control, slots2) => ({
12918
13139
  ...control,
12919
- menuActions: slots.length ? slots : void 0
13140
+ menuActions: slots2.length ? slots2 : void 0
12920
13141
  });
12921
13142
  function mintMenuActionSlot(control) {
12922
13143
  const slotId = genId();
12923
- const slots = [...menuActionSlots(control), { id: slotId, checks: [] }];
12924
- return { control: withSlots(control, slots), slotId };
13144
+ const slots2 = [...menuActionSlots(control), { id: slotId, checks: [] }];
13145
+ return { control: withSlots(control, slots2), slotId };
12925
13146
  }
12926
13147
  function setMenuActionChecks(control, slotId, checks) {
12927
- const slots = menuActionSlots(control);
12928
- if (!slots.some((slot) => slot.id === slotId)) return control;
13148
+ const slots2 = menuActionSlots(control);
13149
+ if (!slots2.some((slot) => slot.id === slotId)) return control;
12929
13150
  return withSlots(
12930
13151
  control,
12931
- slots.map((slot) => slot.id === slotId ? { ...slot, checks } : slot)
13152
+ slots2.map((slot) => slot.id === slotId ? { ...slot, checks } : slot)
12932
13153
  );
12933
13154
  }
12934
13155
  function moveMenuActionSlot(control, slotId, delta) {
12935
- const slots = menuActionSlots(control);
12936
- const from = slots.findIndex((slot) => slot.id === slotId);
13156
+ const slots2 = menuActionSlots(control);
13157
+ const from = slots2.findIndex((slot) => slot.id === slotId);
12937
13158
  if (from < 0) return control;
12938
- const to = Math.min(Math.max(from + delta, 0), slots.length - 1);
13159
+ const to = Math.min(Math.max(from + delta, 0), slots2.length - 1);
12939
13160
  if (to === from) return control;
12940
- const next = [...slots];
13161
+ const next = [...slots2];
12941
13162
  const [moved] = next.splice(from, 1);
12942
13163
  next.splice(to, 0, moved);
12943
13164
  return withSlots(control, next);
12944
13165
  }
12945
13166
  function removeMenuActionSlot(control, slotId) {
12946
- const slots = menuActionSlots(control);
12947
- if (!slots.some((slot) => slot.id === slotId)) return control;
13167
+ const slots2 = menuActionSlots(control);
13168
+ if (!slots2.some((slot) => slot.id === slotId)) return control;
12948
13169
  const dropped = withSlots(
12949
13170
  control,
12950
- slots.filter((slot) => slot.id !== slotId)
13171
+ slots2.filter((slot) => slot.id !== slotId)
12951
13172
  );
12952
13173
  return clearOutputGroupRows(dropped, menuActionKey(slotId));
12953
13174
  }
@@ -12955,9 +13176,9 @@ function renameMenuItemId(control, from, to) {
12955
13176
  const before = from.trim();
12956
13177
  const after = to.trim();
12957
13178
  if (!before || !after || before === after) return control;
12958
- const slots = menuActionSlots(control);
13179
+ const slots2 = menuActionSlots(control);
12959
13180
  let touched = false;
12960
- const next = slots.map((slot) => {
13181
+ const next = slots2.map((slot) => {
12961
13182
  if (!namesItem(slot, before)) return slot;
12962
13183
  touched = true;
12963
13184
  return {
@@ -13195,7 +13416,7 @@ function methodArgs(method, op) {
13195
13416
  out.push({
13196
13417
  name: param.name,
13197
13418
  dataType: param.dataType,
13198
- cardinality: "one",
13419
+ cardinality: param.cardinality ?? "one",
13199
13420
  shapes: {},
13200
13421
  optional: !param.required
13201
13422
  });
@@ -13213,7 +13434,7 @@ function argSubjectType(method, op, arg) {
13213
13434
  );
13214
13435
  }
13215
13436
  const param = (method.params ?? []).find((one) => one.name === arg);
13216
- return param ? { dataType: param.dataType, cardinality: "one" } : void 0;
13437
+ return param ? { dataType: param.dataType, cardinality: param.cardinality ?? "one" } : void 0;
13217
13438
  }
13218
13439
  function methodSignature(args) {
13219
13440
  if (!args.length) return "f()";
@@ -13475,7 +13696,7 @@ function authoredArgs(method) {
13475
13696
  out.push({
13476
13697
  name: param.name,
13477
13698
  dataType: param.dataType,
13478
- cardinality: "one",
13699
+ cardinality: param.cardinality ?? "one",
13479
13700
  shapes: {},
13480
13701
  optional: !param.required
13481
13702
  });
@@ -15235,6 +15456,65 @@ var createCompute = () => ({
15235
15456
  functionId: "",
15236
15457
  args: {}
15237
15458
  });
15459
+ function oneArgHeld(binding, compute, method, args, functions, properties, shapes) {
15460
+ if (binding.source === "fixed") return void 0;
15461
+ if (binding.source === "compute") {
15462
+ const computes = method.computes ?? [];
15463
+ if (!computeReadable(computes, compute.id, binding.name)) return void 0;
15464
+ const earlier = computeFunction(
15465
+ computes.find(
15466
+ (candidate) => candidate.name.trim() === binding.name.trim()
15467
+ ),
15468
+ functions
15469
+ );
15470
+ return earlier ? { dataType: earlier.returnType, cardinality: earlier.returnCardinality } : void 0;
15471
+ }
15472
+ const read = argValue2(binding, args, properties, shapes);
15473
+ return read?.value.dataType ? { dataType: read.value.dataType, cardinality: read.value.cardinality } : void 0;
15474
+ }
15475
+ function computeOneReturns(compute, method, args, functions, properties, shapes) {
15476
+ const entry2 = computeOneFunction(compute);
15477
+ const binding = entry2 && compute.args[entry2.rowParamId];
15478
+ const held = binding && oneArgHeld(binding, compute, method, args, functions, properties, shapes);
15479
+ return held ? oneFunctionReturns(entry2, held.dataType, held.cardinality) : void 0;
15480
+ }
15481
+ function oneComputeError(compute, method, args, functions, properties, shapes) {
15482
+ const entry2 = computeOneFunction(compute);
15483
+ if (!entry2 || !compute.returns) return "emit-gap-call-compute-function";
15484
+ for (const param of entry2.params) {
15485
+ const binding = compute.args[param.id];
15486
+ if (!binding) return "emit-gap-call-compute-args";
15487
+ if (binding.source === "fixed") {
15488
+ if (!oneParamFixedHeld(param, binding.value)) {
15489
+ return "emit-gap-call-compute-type";
15490
+ }
15491
+ continue;
15492
+ }
15493
+ const held = oneArgHeld(
15494
+ binding,
15495
+ compute,
15496
+ method,
15497
+ args,
15498
+ functions,
15499
+ properties,
15500
+ shapes
15501
+ );
15502
+ if (!held) return "emit-gap-call-compute-args";
15503
+ if (!oneFunctionArgFits(param, held, binding.source === "store")) {
15504
+ return "emit-gap-call-compute-type";
15505
+ }
15506
+ }
15507
+ const expected = computeOneReturns(
15508
+ compute,
15509
+ method,
15510
+ args,
15511
+ functions,
15512
+ properties,
15513
+ shapes
15514
+ );
15515
+ const stored = compute.returns;
15516
+ return expected && JSON.stringify(expected.dataType) === JSON.stringify(stored.dataType) && expected.cardinality === stored.cardinality && !!expected.optional === !!stored.optional ? void 0 : "emit-gap-call-compute-type";
15517
+ }
15238
15518
  function computeNameTaken(method, name3, args, ownId) {
15239
15519
  const wanted = name3.trim();
15240
15520
  if (!wanted) return false;
@@ -15268,6 +15548,16 @@ function computeError(compute, method, args, functions, properties, shapes) {
15268
15548
  if (computeNameTaken(method, compute.name, args, compute.id)) {
15269
15549
  return "emit-gap-call-compute-name";
15270
15550
  }
15551
+ if (compute.oneFunction) {
15552
+ return oneComputeError(
15553
+ compute,
15554
+ method,
15555
+ args,
15556
+ functions,
15557
+ properties,
15558
+ shapes
15559
+ );
15560
+ }
15271
15561
  const fn = functions[compute.functionId];
15272
15562
  if (!fn) return "emit-gap-call-compute-function";
15273
15563
  const computes = method.computes ?? [];
@@ -15291,7 +15581,7 @@ function computeError(compute, method, args, functions, properties, shapes) {
15291
15581
  const earlier = computes.find(
15292
15582
  (candidate) => candidate.name.trim() === binding.name.trim()
15293
15583
  );
15294
- const earlierFn = earlier && functions[earlier.functionId];
15584
+ const earlierFn = computeFunction(earlier, functions);
15295
15585
  if (!earlierFn) return "emit-gap-call-compute-args";
15296
15586
  if (!dataTypeFits(
15297
15587
  {
@@ -15355,7 +15645,7 @@ function computeMemberRead(fn, member, shapes) {
15355
15645
  function computeTextPaths(computes, functions, shapes) {
15356
15646
  const out = [];
15357
15647
  for (const compute of computes) {
15358
- const fn = functions[compute.functionId];
15648
+ const fn = computeFunction(compute, functions);
15359
15649
  const name3 = compute.name.trim();
15360
15650
  if (!fn || !name3 || fn.returnCardinality !== "one") continue;
15361
15651
  if (fn.returnType.type !== "shape") {
@@ -15386,7 +15676,7 @@ function computeTextPaths(computes, functions, shapes) {
15386
15676
  function computeInputPaths(computes, functions, shapes) {
15387
15677
  const out = [];
15388
15678
  for (const compute of computes) {
15389
- const fn = functions[compute.functionId];
15679
+ const fn = computeFunction(compute, functions);
15390
15680
  const name3 = compute.name.trim();
15391
15681
  if (!fn || !name3) continue;
15392
15682
  const walk = (member, label, dataType, cardinality, seen) => {
@@ -15415,7 +15705,7 @@ function computeInputMemberError(method, functions, shapes) {
15415
15705
  const compute = (method.computes ?? []).find(
15416
15706
  (c) => c.name === mapping.compute
15417
15707
  );
15418
- const fn = compute && functions[compute.functionId];
15708
+ const fn = computeFunction(compute, functions);
15419
15709
  if (!fn || !computeMemberRead(fn, mapping.member, shapes)) {
15420
15710
  return "input-incomplete";
15421
15711
  }
@@ -15433,6 +15723,13 @@ function computeIsRead(method, name3) {
15433
15723
  )) {
15434
15724
  return true;
15435
15725
  }
15726
+ if ((method.conditions ?? []).some(
15727
+ (condition) => condition.kind === "check" ? condition.check?.source === "compute" && condition.check.compute === wanted : Object.values(condition.args).some(
15728
+ (binding) => binding.source === "compute" && binding.name === wanted
15729
+ )
15730
+ )) {
15731
+ return true;
15732
+ }
15436
15733
  return (method.computes ?? []).some(
15437
15734
  (compute) => Object.values(compute.args).some(
15438
15735
  (binding) => binding.source === "compute" && binding.name === wanted
@@ -15510,7 +15807,7 @@ function variantCheckType(check, method, op, roots, shapes, functions) {
15510
15807
  const compute = (method.computes ?? []).find(
15511
15808
  (one) => one.name === check.compute
15512
15809
  );
15513
- const fn = compute ? functions[compute.functionId] : void 0;
15810
+ const fn = computeFunction(compute, functions);
15514
15811
  return fn ? { dataType: fn.returnType, cardinality: fn.returnCardinality } : void 0;
15515
15812
  }
15516
15813
  return responsePathAt(
@@ -15599,21 +15896,37 @@ function conditionFunction(condition, functions) {
15599
15896
  return functions[condition.functionId];
15600
15897
  }
15601
15898
  var answersBoolean = (fn) => fn.returnType.type === "boolean" && fn.returnCardinality === "one";
15602
- function conditionCheckType(check, args, properties, shapes) {
15603
- const read = check.source === "args" ? check.arg ? argValue2({ source: "args", arg: check.arg }, args, properties, shapes) : void 0 : check.path?.length ? argValue2(
15604
- { source: "store", path: check.path },
15605
- args,
15606
- properties,
15899
+ var conditionArgValue = (binding, args, properties, shapes, computes, functions) => {
15900
+ if (binding.source !== "compute") {
15901
+ return argValue2(binding, args, properties, shapes);
15902
+ }
15903
+ const fn = computeFunction(
15904
+ computes.find((compute) => compute.name.trim() === binding.name.trim()),
15905
+ functions
15906
+ );
15907
+ return fn ? {
15908
+ value: { dataType: fn.returnType, cardinality: fn.returnCardinality },
15607
15909
  shapes
15608
- ) : void 0;
15910
+ } : void 0;
15911
+ };
15912
+ function conditionCheckType(check, args, properties, shapes, computes = [], functions = {}) {
15913
+ const binding = check.source === "args" ? check.arg ? { source: "args", arg: check.arg } : void 0 : check.source === "compute" ? check.compute ? { source: "compute", name: check.compute } : void 0 : check.path?.length ? { source: "store", path: check.path } : void 0;
15914
+ const read = binding ? conditionArgValue(binding, args, properties, shapes, computes, functions) : void 0;
15609
15915
  return read ? {
15610
15916
  dataType: read.value.dataType ?? { type: "string" },
15611
15917
  cardinality: read.value.cardinality
15612
15918
  } : void 0;
15613
15919
  }
15614
- function checkError2(check, args, properties, shapes) {
15920
+ function checkError2(check, args, properties, shapes, computes, functions) {
15615
15921
  if (!check) return "condition-check-subject";
15616
- const type = conditionCheckType(check, args, properties, shapes);
15922
+ const type = conditionCheckType(
15923
+ check,
15924
+ args,
15925
+ properties,
15926
+ shapes,
15927
+ computes,
15928
+ functions
15929
+ );
15617
15930
  if (!type) return "condition-check-subject";
15618
15931
  if (!variantCheckOperators(type).includes(check.operator)) {
15619
15932
  return "condition-check-operator";
@@ -15621,9 +15934,17 @@ function checkError2(check, args, properties, shapes) {
15621
15934
  if (isUnaryOperator(check.operator)) return void 0;
15622
15935
  return validateLiteral(check.value ?? "", type.dataType, type.cardinality) ? "condition-check-value" : void 0;
15623
15936
  }
15624
- function conditionError(condition, args, functions, properties, shapes) {
15937
+ function conditionError(condition, args, functions, properties, shapes, computes = []) {
15938
+ const valueOf = (binding) => conditionArgValue(binding, args, properties, shapes, computes, functions);
15625
15939
  if (conditionKind(condition) === "check") {
15626
- return checkError2(condition.check, args, properties, shapes);
15940
+ return checkError2(
15941
+ condition.check,
15942
+ args,
15943
+ properties,
15944
+ shapes,
15945
+ computes,
15946
+ functions
15947
+ );
15627
15948
  }
15628
15949
  const entry2 = condition.oneFunction ? oneFunctionOf(condition.oneFunction) : void 0;
15629
15950
  if (condition.oneFunction) {
@@ -15633,11 +15954,10 @@ function conditionError(condition, args, functions, properties, shapes) {
15633
15954
  const binding = condition.args[param.id];
15634
15955
  if (!binding) return "condition-args";
15635
15956
  if (binding.source === "fixed") {
15636
- if (param.rule !== "string-one" || typeof binding.value !== "string")
15637
- return "condition-type";
15957
+ if (!oneParamFixedHeld(param, binding.value)) return "condition-type";
15638
15958
  continue;
15639
15959
  }
15640
- const read = argValue2(binding, args, properties, shapes);
15960
+ const read = valueOf(binding);
15641
15961
  if (!read) return "condition-args";
15642
15962
  const held = read.value.dataType ? { dataType: read.value.dataType, cardinality: read.value.cardinality } : void 0;
15643
15963
  if (!oneFunctionArgFits(param, held, binding.source === "store"))
@@ -15661,7 +15981,7 @@ function conditionError(condition, args, functions, properties, shapes) {
15661
15981
  if (invalid) return "condition-type";
15662
15982
  continue;
15663
15983
  }
15664
- const read = argValue2(binding, args, properties, shapes);
15984
+ const read = valueOf(binding);
15665
15985
  if (!read) return "condition-args";
15666
15986
  if (!dataTypeFits(
15667
15987
  read.value,
@@ -15674,9 +15994,22 @@ function conditionError(condition, args, functions, properties, shapes) {
15674
15994
  }
15675
15995
  return void 0;
15676
15996
  }
15677
- var drawnConditions = (method, args, functions, properties, shapes) => (method.conditions ?? []).filter(
15678
- (condition) => !conditionError(condition, args, functions, properties, shapes)
15679
- );
15997
+ var drawnConditions = (method, args, functions, properties, shapes) => {
15998
+ const computes = drawnComputes(method, args, functions, properties, shapes);
15999
+ return (method.conditions ?? []).filter(
16000
+ (condition) => !conditionError(condition, args, functions, properties, shapes, computes)
16001
+ );
16002
+ };
16003
+ var conditionReadsCompute = (condition, name3) => {
16004
+ const wanted = name3.trim();
16005
+ if (!wanted) return false;
16006
+ if (conditionKind(condition) === "check") {
16007
+ return condition.check?.source === "compute" && condition.check.compute?.trim() === wanted;
16008
+ }
16009
+ return Object.values(condition.args).some(
16010
+ (binding) => binding.source === "compute" && binding.name.trim() === wanted
16011
+ );
16012
+ };
15680
16013
 
15681
16014
  // libs/codegen/src/lib/translation-asset-helper.ts
15682
16015
  var SOURCE_LANG = "en";
@@ -16574,7 +16907,7 @@ function mappingExpression(mapping, target, properties, shapes, functions, compu
16574
16907
  if (mapping.source === "args") source = `${mapping.arg}`;
16575
16908
  else if (mapping.source === "compute") {
16576
16909
  const compute = computes.find((c) => c.name === mapping.compute);
16577
- const fn = compute && functions[compute.functionId];
16910
+ const fn = computeFunction(compute, functions);
16578
16911
  const absent = !!fn?.returnUndefined;
16579
16912
  const waits = absent && target.required;
16580
16913
  source = `compute.${mapping.compute}`;
@@ -16821,11 +17154,13 @@ function patchLiteral(mappings, properties, shapes, functions, subject, cast = f
16821
17154
  functions
16822
17155
  );
16823
17156
  if (!fn) return void 0;
16824
- const typeArgs = mapping.transform.oneFunction ? `<${spell(
17157
+ const one = oneFunctionOf(mapping.transform.oneFunction);
17158
+ const typeArgs = one && !one.spell ? `<${spell(
16825
17159
  property.dataType,
16826
- property.cardinality === "map-many" ? "many" : "one"
17160
+ oneFunctionLiftedAt(one, property.cardinality) ? "many" : "one"
16827
17161
  )}>` : "";
16828
- if (mapping.transform.oneFunction) oneFunctionNames.add(fn.name);
17162
+ if (mapping.transform.oneFunction && !one?.spell)
17163
+ oneFunctionNames.add(fn.name);
16829
17164
  const args = mapping.transform.args.map((binding, index) => {
16830
17165
  if (binding.source === "response") {
16831
17166
  return binding.path.length ? {
@@ -16884,7 +17219,10 @@ function patchLiteral(mappings, properties, shapes, functions, subject, cast = f
16884
17219
  }
16885
17220
  locals.set(index, local);
16886
17221
  });
16887
- const call = `${fn.name}${typeArgs}(${args.map((arg, index) => locals.get(index) ?? arg.expression).join(", ")})`;
17222
+ const argExpressions = args.map(
17223
+ (arg, index) => locals.get(index) ?? arg.expression
17224
+ );
17225
+ const call = one?.spell ? one.spell(argExpressions) : `${fn.name}${typeArgs}(${argExpressions.join(", ")})`;
16888
17226
  if (!locals.size) return { receiver, key: property.name, value: call };
16889
17227
  const guard = [...new Set(locals.values())].map((local) => `${local} === undefined`).join(" || ");
16890
17228
  const passTerms = [...new Set(locals.values())].map(
@@ -17627,79 +17965,10 @@ ${failureArms.map(
17627
17965
  const guardHead = guardArgs.size ? `(${guardReceiver}): ${guardReceiver} is ${argObjectType(true)} =>` : "() =>";
17628
17966
  const guardBlock = guards.length ? `
17629
17967
  filter(${guardHead} ${guards.join(" && ")}),` : "";
17630
- let conditionReadsArgs = false;
17631
- const conditions = drawnConditions(
17632
- method,
17633
- args,
17634
- functions,
17635
- roots,
17636
- shapes
17637
- ).map((condition) => {
17638
- const check = condition.check;
17639
- if (conditionKind(condition) === "check" && check) {
17640
- const type = conditionCheckType(check, args, roots, shapes);
17641
- if (check.source === "args") {
17642
- conditionReadsArgs = true;
17643
- return generateVariantCheckExpression(
17644
- check,
17645
- `${guardReceiver}.${check.arg}`,
17646
- type,
17647
- !!args.find((arg) => arg.name === check.arg)?.optional
17648
- );
17649
- }
17650
- return generateVariantCheckExpression(
17651
- check,
17652
- statePathExpression(
17653
- check.path ?? [],
17654
- roots,
17655
- shapes,
17656
- false,
17657
- receiverOf
17658
- ),
17659
- type,
17660
- true
17661
- );
17662
- }
17663
- const fn = conditionFunction(condition, functions);
17664
- if (condition.oneFunction && fn) oneFunctionNames.add(fn.name);
17665
- const waits = [];
17666
- const callArgs2 = (fn?.params ?? []).map((param) => {
17667
- const binding = condition.args[param.id];
17668
- if (!binding) return "undefined";
17669
- if (binding.source === "fixed") {
17670
- return literalExpression(String(binding.value), param.dataType);
17671
- }
17672
- if (binding.source === "args") {
17673
- conditionReadsArgs = true;
17674
- const read2 = `${guardReceiver}.${binding.arg}`;
17675
- if (!requiredArgs.has(binding.arg) && !param.acceptsUndefined) {
17676
- waits.push(`${read2} !== undefined`);
17677
- }
17678
- return read2;
17679
- }
17680
- const held = statePathValue(binding.path, roots, shapes);
17681
- const read = statePathExpression(
17682
- binding.path,
17683
- roots,
17684
- shapes,
17685
- false,
17686
- receiverOf
17687
- );
17688
- if (held?.cardinality === "many") return `${read} ?? []`;
17689
- if (isMapCardinality(held?.cardinality)) return `${read} ?? {}`;
17690
- if (param.acceptsUndefined) return read;
17691
- waits.push(`${read} !== undefined`);
17692
- return statePathExpression(binding.path, roots, shapes, true, receiverOf);
17693
- });
17694
- const negate = condition.oneFunction && condition.negate ? "!" : "";
17695
- return [
17696
- ...Array.from(new Set(waits)),
17697
- `${negate}${fn?.name}(${callArgs2.join(", ")})`
17698
- ].join(" && ");
17699
- });
17700
- const conditionBlock = conditions.length ? `
17701
- filter(${conditionReadsArgs ? guardReceiver : "()"} => ${conditions.join(" && ")}),` : "";
17702
- const readsCompute = (name3) => method.inputs.some((m) => m.source === "compute" && m.compute === name3) || method.response.some(
17968
+ const drawnConds = drawnConditions(method, args, functions, roots, shapes);
17969
+ const readsCompute = (name3) => drawnConds.some(
17970
+ (condition) => conditionReadsCompute(condition, name3)
17971
+ ) || method.inputs.some((m) => m.source === "compute" && m.compute === name3) || method.response.some(
17703
17972
  (mapping) => (mapping.transform?.args ?? []).some(
17704
17973
  (binding) => binding.source === "compute" && binding.name === name3
17705
17974
  )
@@ -17741,7 +18010,8 @@ ${failureArms.map(
17741
18010
  const computeGuards = [];
17742
18011
  let computeGuardsReadArgs = false;
17743
18012
  const computeLines = computes.map((compute) => {
17744
- const fn = functions[compute.functionId];
18013
+ const fn = computeFunction(compute, functions);
18014
+ if (compute.oneFunction && fn) oneFunctionNames.add(fn.name);
17745
18015
  const callArgs2 = (fn?.params ?? []).map((param) => {
17746
18016
  const binding = compute.args[param.id];
17747
18017
  if (!binding) return "undefined";
@@ -17788,6 +18058,104 @@ ${computeLines.map((line) => ` ${line}`).join("\n")}
17788
18058
  return { ${args.length ? `...${guardReceiver}, ` : ""}compute: { ${computes.map((compute) => compute.name).join(", ")} } };
17789
18059
  }),` : "";
17790
18060
  if (computes.length) emitsMap = true;
18061
+ let conditionReadsArgs = false;
18062
+ const conditions = drawnConds.map((condition) => {
18063
+ const check = condition.check;
18064
+ if (conditionKind(condition) === "check" && check) {
18065
+ const type = conditionCheckType(
18066
+ check,
18067
+ args,
18068
+ roots,
18069
+ shapes,
18070
+ computes,
18071
+ functions
18072
+ );
18073
+ if (check.source === "compute") {
18074
+ conditionReadsArgs = true;
18075
+ const fn2 = computeFunction(
18076
+ computes.find((compute) => compute.name === check.compute),
18077
+ functions
18078
+ );
18079
+ return generateVariantCheckExpression(
18080
+ check,
18081
+ `${guardReceiver}.${COMPUTE_BAG}.${check.compute}`,
18082
+ type,
18083
+ !!fn2?.returnUndefined
18084
+ );
18085
+ }
18086
+ if (check.source === "args") {
18087
+ conditionReadsArgs = true;
18088
+ return generateVariantCheckExpression(
18089
+ check,
18090
+ `${guardReceiver}.${check.arg}`,
18091
+ type,
18092
+ !!args.find((arg) => arg.name === check.arg)?.optional
18093
+ );
18094
+ }
18095
+ return generateVariantCheckExpression(
18096
+ check,
18097
+ statePathExpression(
18098
+ check.path ?? [],
18099
+ roots,
18100
+ shapes,
18101
+ false,
18102
+ receiverOf
18103
+ ),
18104
+ type,
18105
+ true
18106
+ );
18107
+ }
18108
+ const fn = conditionFunction(condition, functions);
18109
+ if (condition.oneFunction && fn) oneFunctionNames.add(fn.name);
18110
+ const waits = [];
18111
+ const callArgs2 = (fn?.params ?? []).map((param) => {
18112
+ const binding = condition.args[param.id];
18113
+ if (!binding) return "undefined";
18114
+ if (binding.source === "fixed") {
18115
+ return literalExpression(String(binding.value), param.dataType);
18116
+ }
18117
+ if (binding.source === "compute") {
18118
+ conditionReadsArgs = true;
18119
+ const read2 = `${guardReceiver}.${COMPUTE_BAG}.${binding.name}`;
18120
+ const held2 = computeFunction(
18121
+ computes.find((compute) => compute.name === binding.name),
18122
+ functions
18123
+ );
18124
+ if (held2?.returnUndefined && !param.acceptsUndefined) {
18125
+ waits.push(`${read2} !== undefined`);
18126
+ }
18127
+ return read2;
18128
+ }
18129
+ if (binding.source === "args") {
18130
+ conditionReadsArgs = true;
18131
+ const read2 = `${guardReceiver}.${binding.arg}`;
18132
+ if (!requiredArgs.has(binding.arg) && !param.acceptsUndefined) {
18133
+ waits.push(`${read2} !== undefined`);
18134
+ }
18135
+ return read2;
18136
+ }
18137
+ const held = statePathValue(binding.path, roots, shapes);
18138
+ const read = statePathExpression(
18139
+ binding.path,
18140
+ roots,
18141
+ shapes,
18142
+ false,
18143
+ receiverOf
18144
+ );
18145
+ if (held?.cardinality === "many") return `${read} ?? []`;
18146
+ if (isMapCardinality(held?.cardinality)) return `${read} ?? {}`;
18147
+ if (param.acceptsUndefined) return read;
18148
+ waits.push(`${read} !== undefined`);
18149
+ return statePathExpression(binding.path, roots, shapes, true, receiverOf);
18150
+ });
18151
+ const negate = condition.oneFunction && condition.negate ? "!" : "";
18152
+ return [
18153
+ ...Array.from(new Set(waits)),
18154
+ `${negate}${fn?.name}(${callArgs2.join(", ")})`
18155
+ ].join(" && ");
18156
+ });
18157
+ const conditionBlock = conditions.length ? `
18158
+ filter(${conditionReadsArgs ? guardReceiver : "()"} => ${conditions.join(" && ")}),` : "";
17791
18159
  const computeValueGuards = method.inputs.flatMap((mapping) => {
17792
18160
  if (mapping.source !== "compute" || !mapping.compute) return [];
17793
18161
  const target = targets.find(
@@ -17795,7 +18163,7 @@ ${computeLines.map((line) => ` ${line}`).join("\n")}
17795
18163
  );
17796
18164
  if (!target) return [];
17797
18165
  const compute = computes.find((c) => c.name === mapping.compute);
17798
- const fn = compute && functions[compute.functionId];
18166
+ const fn = computeFunction(compute, functions);
17799
18167
  if (!fn?.returnUndefined) return [];
17800
18168
  const read = `${COMPUTE_BAG}.${mapping.compute}`;
17801
18169
  return [
@@ -17811,7 +18179,7 @@ ${computeLines.map((line) => ` ${line}`).join("\n")}
17811
18179
  for (const [slot, binding] of Object.entries(confirm?.params ?? {})) {
17812
18180
  if (binding.source === "compute") {
17813
18181
  const compute = computes.find((c) => c.name === binding.name);
17814
- const fn = compute && functions[compute.functionId];
18182
+ const fn = computeFunction(compute, functions);
17815
18183
  if (!fn) continue;
17816
18184
  const member = computeMemberRead(fn, binding.member, shapes);
17817
18185
  if (!member) continue;
@@ -17928,7 +18296,7 @@ ${beforePersists.map((line) => ` ${line}`).join("\n")}
17928
18296
  // ends — `finalize` fires on success, on error and when a later call
17929
18297
  // replaces it, so the wait never outlives the request (ADR 0139).
17930
18298
  ` ${method.name}: rxMethod<${argType}>(
17931
- pipe(${debounceBlock}${guardBlock}${conditionBlock}${computeGuardBlock}${computeBlock}${computeValueGuardBlock}${confirmBlock}${beforeBlock}
18299
+ pipe(${debounceBlock}${guardBlock}${computeGuardBlock}${computeBlock}${conditionBlock}${computeValueGuardBlock}${confirmBlock}${beforeBlock}
17932
18300
  switchMap(${callArgName} => {${settleOnly ? `
17933
18301
  const { onSent, onSettled } = (input || {}) as { ${SETTLE_MEMBERS.join("; ")} };` : ""}
17934
18302
  onSent?.();
@@ -17939,7 +18307,7 @@ ${beforePersists.map((line) => ` ${line}`).join("\n")}
17939
18307
  )
17940
18308
  ),`
17941
18309
  ) : ` ${method.name}: rxMethod<${argType}>(
17942
- pipe(${debounceBlock}${guardBlock}${conditionBlock}${computeGuardBlock}${computeBlock}${computeValueGuardBlock}${confirmBlock}${beforeBlock}
18310
+ pipe(${debounceBlock}${guardBlock}${computeGuardBlock}${computeBlock}${conditionBlock}${computeValueGuardBlock}${confirmBlock}${beforeBlock}
17943
18311
  switchMap(${callArgName} =>
17944
18312
  ${apiCall}.pipe(${tapBlock}${catchBlock}
17945
18313
  )
@@ -20415,8 +20783,9 @@ function limitSources(scope) {
20415
20783
  });
20416
20784
  });
20417
20785
  Object.values(scope.computeds ?? {}).forEach((computed) => {
20418
- const fn = functions[computed.functionId];
20419
- if (fn && isNumberScalar(fn.returnType, returnCardinalityOf(fn)))
20786
+ const fn = computed.functionId ? functions[computed.functionId] : void 0;
20787
+ const held = fn ? { dataType: fn.returnType, cardinality: returnCardinalityOf(fn) } : computed.returns;
20788
+ if (held && isNumberScalar(held.dataType, held.cardinality))
20420
20789
  add({
20421
20790
  id: computed.id,
20422
20791
  name: computed.name,
@@ -22217,7 +22586,7 @@ function renderBranch(node, indent2, names, methods, operationOf, storeProp, ctx
22217
22586
  return render(chain[0].arm.childrens, indent2).join("\n");
22218
22587
  }
22219
22588
  const pad2 = " ".repeat(indent2);
22220
- const slots = branchSlots(chain.map((entry2) => entry2.arm));
22589
+ const slots2 = branchSlots(chain.map((entry2) => entry2.arm));
22221
22590
  const chainFor = (slot) => {
22222
22591
  const lines = [];
22223
22592
  chain.forEach((entry2, index) => {
@@ -22243,7 +22612,7 @@ function renderBranch(node, indent2, names, methods, operationOf, storeProp, ctx
22243
22612
  lines.push(`${pad2}}`);
22244
22613
  return lines.join("\n");
22245
22614
  };
22246
- return slots.map(chainFor).join("\n");
22615
+ return slots2.map(chainFor).join("\n");
22247
22616
  }
22248
22617
  function branchSlots(arms) {
22249
22618
  const named = /* @__PURE__ */ new Set();
@@ -22502,10 +22871,10 @@ var optionsGapReason = (binding, ctx, storeProp) => {
22502
22871
  function bindingGapComments(node, ctx, storeProp, pad2) {
22503
22872
  const bindings = ctx.controlMap?.[node.id]?.bindings;
22504
22873
  if (!bindings) return "";
22505
- const slots = attrBindingSlots(node.type);
22506
- if (!slots.length) return "";
22874
+ const slots2 = attrBindingSlots(node.type);
22875
+ if (!slots2.length) return "";
22507
22876
  const scope = bindingScope(ctx, storeProp);
22508
- return slots.map((slot) => {
22877
+ return slots2.map((slot) => {
22509
22878
  const binding = bindings[slot];
22510
22879
  if (!binding) return "";
22511
22880
  const reason = slot === BINDING_SLOT.options && node.type !== "context_menu" /* CONTEXT_MENU */ ? optionsGapReason(binding, ctx, storeProp) : bindingGapReason(binding, scope);
@@ -22643,7 +23012,7 @@ var boundCardinality = (binding, ctx) => {
22643
23012
  }
22644
23013
  case "computed": {
22645
23014
  const computed = ctx.computeds?.[binding.root.id];
22646
- const fn = computed ? ctx.functions?.[computed.functionId] : void 0;
23015
+ const fn = computed ? stateComputedFunction(computed, ctx.functions ?? {}) : void 0;
22647
23016
  dataType = fn?.returnType;
22648
23017
  cardinality = fn ? returnCardinalityOf(fn) : void 0;
22649
23018
  break;
@@ -25178,13 +25547,13 @@ function menuActionHandlersBlock(tree, methods, operationOf, storeProp, ctx, pay
25178
25547
  walk(node.childrens);
25179
25548
  continue;
25180
25549
  }
25181
- const slots = menuActionSlots(node).filter(
25550
+ const slots2 = menuActionSlots(node).filter(
25182
25551
  isMenuActionSlotComplete
25183
25552
  );
25184
- if (!slots.length) continue;
25553
+ if (!slots2.length) continue;
25185
25554
  const payload = payloadShape(MENU_ACTION_OUTPUT, node.type, node.configs);
25186
25555
  const arms = [];
25187
- for (const slot of slots) {
25556
+ for (const slot of slots2) {
25188
25557
  const key2 = menuActionKey(slot.id);
25189
25558
  const statements = gatedCallSiteStatements(
25190
25559
  node,
@@ -26285,7 +26654,10 @@ ${record(" ")}
26285
26654
  )
26286
26655
  ).sort();
26287
26656
  const levels = computedLevels.map((level) => {
26288
- const entries = level.map((computed) => ({ computed, fn: functions[computed.functionId] })).filter(
26657
+ const entries = level.map((computed) => ({
26658
+ computed,
26659
+ fn: stateComputedFunction(computed, functions)
26660
+ })).filter(
26289
26661
  (pair) => !!pair.fn
26290
26662
  );
26291
26663
  const destructured = Array.from(
@@ -26381,8 +26753,15 @@ ${lines.join("\n")}
26381
26753
  ...drawn.needsModal ? [MODAL_STORE] : [],
26382
26754
  // A `denied` arm's refusal is claimed off the library (api ADR 0005).
26383
26755
  ...drawn.needsDenial ? ["claimDenial"] : [],
26384
- // A CallCondition asking a OneFunction (ADR 0202).
26385
- ...drawn.oneFunctions ?? [],
26756
+ // A CallCondition asking a OneFunction (ADR 0202), and a StateComputed
26757
+ // calling one (ADR 0218) — one name imported once.
26758
+ .../* @__PURE__ */ new Set([
26759
+ ...drawn.oneFunctions ?? [],
26760
+ ...Object.values(computeds).filter(isOneFunctionStateComputed).flatMap((computed) => {
26761
+ const entry2 = oneFunctionOf(computed.oneFunction);
26762
+ return entry2 && !isNativeOneFunction(entry2) ? [entry2.name] : [];
26763
+ })
26764
+ ]),
26386
26765
  ...hooks.needsStorage || drawn.needsStorage || storageMethods.needsStorage ? [STORAGE_SERVICE] : [],
26387
26766
  // What the host's search box is read through, drawn per row the way every
26388
26767
  // other source's import is (ADR 0184).
@@ -26398,7 +26777,9 @@ ${lines.join("\n")}
26398
26777
  const storageImport = oneImports.length ? `import { ${oneImports.join(", ")} } from '@magmonium/one';
26399
26778
  ` : "";
26400
26779
  const functionImports = Array.from(
26401
- Object.values(computeds).map((computed) => functions[computed.functionId]).concat((drawn.functionIds ?? []).map((id) => functions[id])).concat(hooks.feedFunctionId ? [functions[hooks.feedFunctionId]] : []).concat(
26780
+ Object.values(computeds).map(
26781
+ (computed) => computed.functionId ? functions[computed.functionId] : void 0
26782
+ ).concat((drawn.functionIds ?? []).map((id) => functions[id])).concat(hooks.feedFunctionId ? [functions[hooks.feedFunctionId]] : []).concat(
26402
26783
  ruleFunctionImports(
26403
26784
  variantList.map((variant) => variant.rule),
26404
26785
  rootProperties,
@@ -27748,7 +28129,7 @@ __export(package_exports, {
27748
28129
  version: () => version
27749
28130
  });
27750
28131
  var name = "@magmonium/one";
27751
- var version = "0.4.109";
28132
+ var version = "0.4.114";
27752
28133
  var description = "Magmonium One \u2014 Angular design-system primitives for mm Apps";
27753
28134
  var author = "magmonium";
27754
28135
  var license = "MIT";
@@ -27816,7 +28197,7 @@ __export(package_exports2, {
27816
28197
  version: () => version2
27817
28198
  });
27818
28199
  var name2 = "@magmonium/cli";
27819
- var version2 = "0.8.27";
28200
+ var version2 = "0.8.28";
27820
28201
  var description2 = "A powerful and extensible asset compilation tool that can be shared across multiple projects";
27821
28202
  var bin = {
27822
28203
  "mag-cli": "bin/cli.js"
@@ -28398,7 +28779,7 @@ function navRowSourceOptions(feature, owner) {
28398
28779
  const value = owner && storeOwnerValue(owner);
28399
28780
  return storesOf(feature).filter((store) => !value || storeOwnerValue(store.owner) === value).flatMap(
28400
28781
  (store) => Object.values(store.computeds).filter((computed) => {
28401
- const fn = feature.functions?.[computed.functionId];
28782
+ const fn = stateComputedFunction(computed, feature.functions ?? {});
28402
28783
  return !!fn && isNavRowShape(fn.returnType, fn.returnCardinality, feature.shapes);
28403
28784
  }).map((computed) => ({
28404
28785
  value: computed.id,
@@ -30433,9 +30814,10 @@ function sanitizeMethods(methods, properties, functions = {}) {
30433
30814
  (persist) => (persist.sourceKind !== "clear" && persist.sourceKind !== "function" || persist.timing === "before" && persist.shelf === "store") && (persist.sourceKind !== "function" || !!persist.transform) && (persist.sourceKind !== "response" || persist.timing === "after") && (persist.sourceKind !== "state" || !!persist.source.length && !!properties[persist.source[0]]) && (persist.sourceKind !== "args" || !!persist.arg) && (persist.sourceKind !== "fixed" || typeof persist.value === "string") && (persist.shelf === "store" ? persist.sourceKind !== "state" && !!properties[persist.propertyId ?? ""] : !!persist.key.trim())
30434
30815
  );
30435
30816
  const computes = (Array.isArray(method.computes) ? method.computes : []).filter(
30436
- (compute) => !!compute && typeof compute.id === "string" && !!compute.id && typeof compute.name === "string" && !!compute.name.trim() && typeof compute.functionId === "string" && !!functions[compute.functionId] && !!compute.args && typeof compute.args === "object"
30437
- ).map((compute) => ({
30817
+ (compute) => !!compute && typeof compute.id === "string" && !!compute.id && typeof compute.name === "string" && !!compute.name.trim() && (compute.oneFunction ? !!computeOneFunction(compute) && !!compute.returns && typeof compute.returns === "object" && !!compute.returns.dataType && typeof compute.returns.cardinality === "string" : typeof compute.functionId === "string" && !!functions[compute.functionId]) && !!compute.args && typeof compute.args === "object"
30818
+ ).map(({ oneFunction, returns, ...compute }) => ({
30438
30819
  ...compute,
30820
+ ...oneFunction ? { functionId: "", oneFunction, returns } : {},
30439
30821
  args: Object.fromEntries(
30440
30822
  Object.entries(compute.args).filter(([, binding]) => {
30441
30823
  if (!binding) return false;
@@ -30476,18 +30858,21 @@ function sanitizeMethods(methods, properties, functions = {}) {
30476
30858
  if (!binding) return false;
30477
30859
  if (binding.source === "args") return !!binding.arg;
30478
30860
  if (binding.source === "fixed") return binding.value !== void 0;
30861
+ if (binding.source === "compute")
30862
+ return typeof binding.name === "string" && !!binding.name;
30479
30863
  return binding.source === "store" && Array.isArray(binding.path) && !!binding.path.length && !!properties[binding.path[0]];
30480
30864
  })
30481
30865
  )
30482
30866
  });
30483
30867
  const conditions = (Array.isArray(method.conditions) ? method.conditions : []).filter(
30484
- (condition) => !!condition && typeof condition.id === "string" && !!condition.id && (condition.kind === "check" ? !!condition.check && (condition.check.source === "store" || condition.check.source === "args") && RULE_OPERATORS.includes(condition.check.operator) : (typeof condition.oneFunction === "string" ? !!condition.oneFunction : typeof condition.functionId === "string" && !!functions[condition.functionId]) && !!condition.args && typeof condition.args === "object")
30868
+ (condition) => !!condition && typeof condition.id === "string" && !!condition.id && (condition.kind === "check" ? !!condition.check && (condition.check.source === "store" || condition.check.source === "args" || condition.check.source === "compute") && RULE_OPERATORS.includes(condition.check.operator) : (typeof condition.oneFunction === "string" ? !!condition.oneFunction : typeof condition.functionId === "string" && !!functions[condition.functionId]) && !!condition.args && typeof condition.args === "object")
30485
30869
  ).map((condition) => {
30486
30870
  const check = condition.check;
30487
30871
  if (condition.kind !== "check" || !check)
30488
30872
  return functionCondition(condition);
30489
30873
  const path = check.source === "store" && Array.isArray(check.path) && check.path.every((segment) => typeof segment === "string") && !!check.path.length && !!properties[check.path[0]] ? check.path : void 0;
30490
30874
  const arg = check.source === "args" && typeof check.arg === "string" ? check.arg : void 0;
30875
+ const compute = check.source === "compute" && typeof check.compute === "string" ? check.compute : void 0;
30491
30876
  return {
30492
30877
  id: condition.id,
30493
30878
  kind: "check",
@@ -30498,6 +30883,7 @@ function sanitizeMethods(methods, properties, functions = {}) {
30498
30883
  operator: check.operator,
30499
30884
  ...path ? { path } : {},
30500
30885
  ...arg ? { arg } : {},
30886
+ ...compute ? { compute } : {},
30501
30887
  ...typeof check.value === "string" ? { value: check.value } : {}
30502
30888
  }
30503
30889
  };
@@ -30534,6 +30920,7 @@ function sanitizeMethods(methods, properties, functions = {}) {
30534
30920
  id: param.id,
30535
30921
  name: param.name.trim(),
30536
30922
  dataType: { type: param.dataType.type },
30923
+ ...param.cardinality === "many" ? { cardinality: "many" } : {},
30537
30924
  // The one axis the User answers for a parameter nothing sends, so the
30538
30925
  // load is where it would otherwise be lost silently (GLOSSARY.md
30539
30926
  // MethodParam).
@@ -30857,9 +31244,27 @@ function sanitizeStateComputeds(value, functions, reservedNames) {
30857
31244
  if (typeof computed.name !== "string" || !isValidPropertyName(computed.name) || taken.has(computed.name)) {
30858
31245
  continue;
30859
31246
  }
31247
+ const args = computed.args ?? {};
31248
+ const returns = computed.functionId ? void 0 : sanitizeComputedReturns(computed.returns);
31249
+ const oneFunction = !computed.functionId && typeof computed.oneFunction === "string" ? computed.oneFunction : void 0;
31250
+ if (oneFunction && returns) {
31251
+ const stored = {
31252
+ id,
31253
+ name: computed.name,
31254
+ oneFunction,
31255
+ args,
31256
+ returns
31257
+ };
31258
+ const fn2 = stateComputedFunction(stored, {});
31259
+ if (fn2 && fn2.params.some((param) => args[param.id] === void 0)) {
31260
+ continue;
31261
+ }
31262
+ taken.add(computed.name);
31263
+ result[id] = stored;
31264
+ continue;
31265
+ }
30860
31266
  const fn = computed.functionId ? functions[computed.functionId] : void 0;
30861
31267
  if (!fn) continue;
30862
- const args = computed.args ?? {};
30863
31268
  if (fn.params.some((param) => args[param.id] === void 0)) continue;
30864
31269
  taken.add(computed.name);
30865
31270
  result[id] = { id, name: computed.name, functionId: fn.id, args };
@@ -36494,6 +36899,7 @@ var HISTORY_SELECTION_KEYS = [
36494
36899
  METHOD_VARIANT_SOURCES,
36495
36900
  MIGRATION_FLOOR,
36496
36901
  MODAL_STORE,
36902
+ NATIVE_ONE_FUNCTION_SPECS,
36497
36903
  NAV_ID_SEP,
36498
36904
  NAV_LINK_KINDS,
36499
36905
  NAV_PRESENTATIONS,
@@ -36514,9 +36920,12 @@ var HISTORY_SELECTION_KEYS = [
36514
36920
  ONE_FUNCTIONS,
36515
36921
  ONE_FUNCTION_CATALOG,
36516
36922
  ONE_FUNCTION_DATA_PARAM,
36923
+ ONE_FUNCTION_IDS_PARAM,
36517
36924
  ONE_FUNCTION_ID_PARAM,
36925
+ ONE_FUNCTION_KEY_PARAM,
36518
36926
  ONE_FUNCTION_MAP_PARAM,
36519
36927
  ONE_FUNCTION_PREFIX,
36928
+ ONE_FUNCTION_SPECS,
36520
36929
  ONE_IMPORT_MODULE,
36521
36930
  ONE_PACKAGE_VERSION,
36522
36931
  OPEN_SCREEN_INPUT_SOURCES,
@@ -36827,22 +37236,27 @@ var HISTORY_SELECTION_KEYS = [
36827
37236
  composeFunctionBinding,
36828
37237
  composeLabelValue,
36829
37238
  computeError,
37239
+ computeFunction,
36830
37240
  computeId,
36831
37241
  computeInputMemberError,
36832
37242
  computeInputPaths,
36833
37243
  computeIsRead,
36834
37244
  computeMemberRead,
36835
37245
  computeNameTaken,
37246
+ computeOneFunction,
37247
+ computeOneReturns,
36836
37248
  computeReadable,
36837
37249
  computeTextPaths,
36838
37250
  computedAsProperty,
36839
37251
  computedLocalNames,
36840
37252
  computedRootIds,
37253
+ conditionArgValue,
36841
37254
  conditionCheckType,
36842
37255
  conditionError,
36843
37256
  conditionFunction,
36844
37257
  conditionId,
36845
37258
  conditionKind,
37259
+ conditionReadsCompute,
36846
37260
  configurableResponses,
36847
37261
  confirmError,
36848
37262
  confirmId,
@@ -37236,12 +37650,14 @@ var HISTORY_SELECTION_KEYS = [
37236
37650
  isMethodInUse,
37237
37651
  isMountable,
37238
37652
  isMovingScreenEmit,
37653
+ isNativeOneFunction,
37239
37654
  isNavAtOrBelow,
37240
37655
  isNavInstanceFunction,
37241
37656
  isNavRowShape,
37242
37657
  isNavVisibilityFunction,
37243
37658
  isOnChange,
37244
37659
  isOneFunctionComputed,
37660
+ isOneFunctionStateComputed,
37245
37661
  isOptionRowShape,
37246
37662
  isOrderingMenuActionOperator,
37247
37663
  isOrderingOutputArmOperator,
@@ -37508,12 +37924,21 @@ var HISTORY_SELECTION_KEYS = [
37508
37924
  normalizeVariantName,
37509
37925
  offersOutputArms,
37510
37926
  oneFunctionArgFits,
37927
+ oneFunctionBoundSignature,
37928
+ oneFunctionFitsLanding,
37511
37929
  oneFunctionFromPickValue,
37930
+ oneFunctionLiftedAt,
37931
+ oneFunctionMintsKey,
37512
37932
  oneFunctionOf,
37513
37933
  oneFunctionPickValue,
37514
37934
  oneFunctionReturns,
37515
37935
  oneFunctionSignature,
37516
37936
  oneFunctionSignatureText,
37937
+ oneFunctionSiteFits,
37938
+ oneParamFixedHeld,
37939
+ oneParamStatePathOnly,
37940
+ oneParamTakesFixed,
37941
+ oneParamTypeText,
37517
37942
  openError,
37518
37943
  openId,
37519
37944
  openInputAnswered,
@@ -37925,6 +38350,7 @@ var HISTORY_SELECTION_KEYS = [
37925
38350
  starterFunction,
37926
38351
  stateComputedArgExpression,
37927
38352
  stateComputedArgHeldType,
38353
+ stateComputedFunction,
37928
38354
  stateInterfaceName,
37929
38355
  statePathHeldType,
37930
38356
  statePathRead,