@milaboratories/pl-middle-layer 1.75.0 → 1.76.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/index.cjs +1 -0
  2. package/dist/index.d.ts +3 -2
  3. package/dist/index.js +2 -2
  4. package/dist/middle_layer/block_action_context.cjs +57 -0
  5. package/dist/middle_layer/block_action_context.cjs.map +1 -0
  6. package/dist/middle_layer/block_action_context.d.ts +47 -0
  7. package/dist/middle_layer/block_action_context.d.ts.map +1 -0
  8. package/dist/middle_layer/block_action_context.js +57 -0
  9. package/dist/middle_layer/block_action_context.js.map +1 -0
  10. package/dist/middle_layer/build_stamp.cjs +1 -1
  11. package/dist/middle_layer/build_stamp.js +1 -1
  12. package/dist/middle_layer/index.d.ts +2 -1
  13. package/dist/middle_layer/project.cjs +8 -0
  14. package/dist/middle_layer/project.cjs.map +1 -1
  15. package/dist/middle_layer/project.d.ts +6 -0
  16. package/dist/middle_layer/project.d.ts.map +1 -1
  17. package/dist/middle_layer/project.js +8 -0
  18. package/dist/middle_layer/project.js.map +1 -1
  19. package/dist/model/project_model.cjs +1 -1
  20. package/dist/model/project_model.cjs.map +1 -1
  21. package/dist/model/project_model.d.ts +1 -1
  22. package/dist/model/project_model.js +1 -1
  23. package/dist/model/project_model.js.map +1 -1
  24. package/dist/mutator/project.cjs +19 -4
  25. package/dist/mutator/project.cjs.map +1 -1
  26. package/dist/mutator/project.d.ts.map +1 -1
  27. package/dist/mutator/project.js +19 -4
  28. package/dist/mutator/project.js.map +1 -1
  29. package/dist/mutator/template/render_block.cjs +35 -2
  30. package/dist/mutator/template/render_block.cjs.map +1 -1
  31. package/dist/mutator/template/render_block.js +35 -4
  32. package/dist/mutator/template/render_block.js.map +1 -1
  33. package/dist/mutator/template/render_template.cjs +16 -1
  34. package/dist/mutator/template/render_template.cjs.map +1 -1
  35. package/dist/mutator/template/render_template.d.ts +12 -1
  36. package/dist/mutator/template/render_template.d.ts.map +1 -1
  37. package/dist/mutator/template/render_template.js +16 -2
  38. package/dist/mutator/template/render_template.js.map +1 -1
  39. package/package.json +7 -7
  40. package/src/middle_layer/block_action_context.test.ts +148 -0
  41. package/src/middle_layer/block_action_context.ts +162 -0
  42. package/src/middle_layer/index.ts +6 -0
  43. package/src/middle_layer/project.ts +13 -0
  44. package/src/model/project_model.ts +5 -2
  45. package/src/mutator/project.ts +47 -13
  46. package/src/mutator/project_action_context.test.ts +178 -0
  47. package/src/mutator/template/render_block.ts +70 -5
  48. package/src/mutator/template/render_template.ts +22 -2
@@ -1 +1 @@
1
- {"version":3,"file":"project.d.ts","names":[],"sources":["../../src/mutator/project.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;wBA2oEsB,iBACpB,IAAI,eACJ,WAAW,kBACX;EAAY;;;;;;;;AAOZ,gBAAgB,gBACf,QAAQ"}
1
+ {"version":3,"file":"project.d.ts","names":[],"sources":["../../src/mutator/project.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;wBA6qEsB,iBACpB,IAAI,eACJ,WAAW,kBACX;EAAY;;;;;;;;AAOZ,gBAAgB,gBACf,QAAQ"}
@@ -376,6 +376,14 @@ var ProjectMutator = class ProjectMutator {
376
376
  status: "Ready"
377
377
  };
378
378
  }
379
+ /** Baggage of the root action context of a block render. */
380
+ blockActionContextBaggage(blockId, info) {
381
+ return {
382
+ name: this.getBlock(blockId).label,
383
+ blockPack: JSON.stringify(info.source),
384
+ blockId
385
+ };
386
+ }
379
387
  getBlock(blockId) {
380
388
  for (const block of allBlocks(this.struct)) if (block.id === blockId) return block;
381
389
  throw new Error("block not found");
@@ -449,6 +457,7 @@ var ProjectMutator = class ProjectMutator {
449
457
  this.setBlockFieldObj(blockId, "stagingCtxPrevious", fields.stagingCtx);
450
458
  this.setBlockFieldObj(blockId, "stagingUiCtxPrevious", fields.stagingUiCtx);
451
459
  }
460
+ this.deleteBlockFields(blockId, "stagingActionContext");
452
461
  if (this.deleteBlockFields(blockId, "stagingOutput", "stagingCtx", "stagingUiCtx")) this.resetStagingRefreshTimestamp();
453
462
  }
454
463
  resetProduction(blockId) {
@@ -461,7 +470,7 @@ var ProjectMutator = class ProjectMutator {
461
470
  this.setBlockFieldObj(blockId, "prodCtxPrevious", fields.prodCtx);
462
471
  this.setBlockFieldObj(blockId, "prodUiCtxPrevious", fields.prodUiCtx);
463
472
  }
464
- this.deleteBlockFields(blockId, "prodOutput", "prodCtx", "prodUiCtx", "prodArgs");
473
+ this.deleteBlockFields(blockId, "prodOutput", "prodCtx", "prodUiCtx", "prodArgs", "prodActionContext");
465
474
  }
466
475
  /** Running blocks are reset, settled ones (Ready or finished Error) moved to limbo. Returns if
467
476
  * either of the actions were actually performed.
@@ -474,7 +483,10 @@ var ProjectMutator = class ProjectMutator {
474
483
  this.renderingStateChanged = true;
475
484
  this.deleteBlockFields(blockId, "prodOutputPrevious", "prodCtxPrevious", "prodUiCtxPrevious");
476
485
  return true;
477
- } else return this.deleteBlockFields(blockId, "prodOutput", "prodCtx", "prodUiCtx", "prodArgs", "prodOutputPrevious", "prodCtxPrevious", "prodUiCtxPrevious");
486
+ } else {
487
+ this.deleteBlockFields(blockId, "prodActionContext");
488
+ return this.deleteBlockFields(blockId, "prodOutput", "prodCtx", "prodUiCtx", "prodArgs", "prodOutputPrevious", "prodCtxPrevious", "prodUiCtxPrevious");
489
+ }
478
490
  }
479
491
  /**
480
492
  * Gets current block state and merges with partial updates.
@@ -651,10 +663,11 @@ var ProjectMutator = class ProjectMutator {
651
663
  blockId: this.tx.createValue(Pl.JsonString, JSON.stringify(blockId)),
652
664
  isProduction: this.tx.createValue(Pl.JsonBool, JSON.stringify(false)),
653
665
  context: ctx
654
- });
666
+ }, this.blockActionContextBaggage(blockId, info));
655
667
  this.setBlockField(blockId, "stagingCtx", Pl.wrapInEphHolder(this.tx, ctx), "NotReady");
656
668
  this.setBlockField(blockId, "stagingUiCtx", this.exportCtx(results.context), "NotReady");
657
669
  this.setBlockField(blockId, "stagingOutput", results.result, "NotReady");
670
+ if (results.actionContext !== void 0) this.setBlockField(blockId, "stagingActionContext", results.actionContext, "NotReady");
658
671
  }
659
672
  renderProductionFor(blockId) {
660
673
  this.resetProduction(blockId);
@@ -673,10 +686,11 @@ var ProjectMutator = class ProjectMutator {
673
686
  blockId: this.tx.createValue(Pl.JsonString, JSON.stringify(blockId)),
674
687
  isProduction: this.tx.createValue(Pl.JsonBool, JSON.stringify(true)),
675
688
  context: ctx
676
- });
689
+ }, this.blockActionContextBaggage(blockId, info));
677
690
  this.setBlockField(blockId, "prodCtx", Pl.wrapInEphHolder(this.tx, results.context), "NotReady");
678
691
  this.setBlockField(blockId, "prodUiCtx", this.exportCtx(results.context), "NotReady");
679
692
  this.setBlockField(blockId, "prodOutput", results.result, "NotReady");
693
+ if (results.actionContext !== void 0) this.setBlockField(blockId, "prodActionContext", results.actionContext, "NotReady");
680
694
  this.setBlockFieldObj(blockId, "prodArgs", info.fields.currentArgs);
681
695
  if (this.blocksInLimbo.delete(blockId)) this.renderingStateChanged = true;
682
696
  }
@@ -946,6 +960,7 @@ var ProjectMutator = class ProjectMutator {
946
960
  const blockId = queue.shift();
947
961
  const fields = this.getBlockInfo(blockId).fields;
948
962
  if (fields.prodOutput?.status === "Ready" && fields.prodCtx?.status === "Ready") continue;
963
+ this.deleteBlockFields(blockId, "prodActionContext");
949
964
  if (this.deleteBlockFields(blockId, "prodOutput", "prodCtx", "prodUiCtx", "prodArgs")) {
950
965
  stopped.push(blockId);
951
966
  for (const downstream of activeProdGraph.traverseIdsExcludingRoots("downstream", blockId)) {