@superblocksteam/library 2.0.3-next.100 → 2.0.3-next.103

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 (22) hide show
  1. package/dist/{allPaths-BIcW22ON.js → allPaths-D17klCNI.js} +2 -2
  2. package/dist/{allPaths-BIcW22ON.js.map → allPaths-D17klCNI.js.map} +1 -1
  3. package/dist/{allPaths-TFa77ssf.js → allPaths-qwLVp8ey.js} +2 -2
  4. package/dist/{allPaths-TFa77ssf.js.map → allPaths-qwLVp8ey.js.map} +1 -1
  5. package/dist/{allPathsLoader-66hpXNFC.js → allPathsLoader-BBePZAWr.js} +3 -3
  6. package/dist/{allPathsLoader-NDdzt1-S.js.map → allPathsLoader-BBePZAWr.js.map} +1 -1
  7. package/dist/{allPathsLoader-NDdzt1-S.js → allPathsLoader-C6kYq5jL.js} +3 -3
  8. package/dist/{allPathsLoader-66hpXNFC.js.map → allPathsLoader-C6kYq5jL.js.map} +1 -1
  9. package/dist/{index-BBdi2OTU.js → index-Cf5B7k85.js} +297 -127
  10. package/dist/{index-BBdi2OTU.js.map → index-Cf5B7k85.js.map} +1 -1
  11. package/dist/index.js +2 -2
  12. package/dist/{splitPathsBySizeLoader-BQDszFo7.js → splitPathsBySizeLoader-Cy4Y9soq.js} +2 -2
  13. package/dist/{splitPathsBySizeLoader-BQDszFo7.js.map → splitPathsBySizeLoader-Cy4Y9soq.js.map} +1 -1
  14. package/dist/{splitPathsBySizeLoader-DF5UX5DW.js → splitPathsBySizeLoader-D3MLR09i.js} +2 -2
  15. package/dist/{splitPathsBySizeLoader-DF5UX5DW.js.map → splitPathsBySizeLoader-D3MLR09i.js.map} +1 -1
  16. package/dist-types/edit-mode/features/operation-store.d.ts +20 -21
  17. package/dist-types/edit-mode/features/runtime-entities-manager.d.ts +16 -7
  18. package/dist-types/edit-mode/features/runtime-widgets-manager.d.ts +5 -1
  19. package/dist-types/edit-mode/source-update-api.d.ts +2 -1
  20. package/dist-types/lib/index.d.ts +1 -0
  21. package/dist-types/lib/internal-details/lib/types.d.ts +2 -1
  22. package/package.json +3 -3
@@ -46,7 +46,7 @@ var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use
46
46
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
47
47
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
48
48
  var __privateMethod = (obj, member, method4) => (__accessCheck(obj, member, "access private method"), method4);
49
- var _removeSourceIdElement_dec, _setSourceIdElement_dec, _setActiveRootInstanceId_dec, _init, _runApi_dec, _init2, _setWidgetProperty_dec, _setWidgetProperties_dec, _writeRuntimeProperties_dec, _dropComponent_dec, _clearPendingTransactions_dec, _addPendingTransaction_dec, _init3, _processRootWidget_dec, _init4, _refreshPositionsAndGetDropConstraints_dec, _init5, _updateChildPositions_dec, _setWidgetPosition_dec, _setActiveTargetRect_dec, _setActiveDragRect_dec, _setDropTargetId_dec, _setInvalidDropTarget_dec, _setValidRootIds_dec, _cancelNewComponentDrag_dec, _startNewComponentDrag_dec, _setIsDragging_dec, _setWidgetFeatures_dec, _init6;
49
+ var _removeSourceIdElement_dec, _setSourceIdElement_dec, _setActiveRootInstanceId_dec, _init, _runApi_dec, _init2, _setWidgetProperty_dec, _setWidgetProperties_dec, _writeRuntimeProperties_dec, _ackDeletedComponents_dec, _dropComponent_dec, _createComponent_dec, _batchUpdate_dec, _clearPendingTransactions_dec, _addPendingTransaction_dec, _executeOrAddToBatch_dec, _init3, _addWidgetFromPayload_dec, _processRoot_dec, _init4, _addOptimisticCreateWidget_dec, _processRootWidget_dec, _init5, _refreshPositionsAndGetDropConstraints_dec, _init6, _updateChildPositions_dec, _setWidgetPosition_dec, _setActiveTargetRect_dec, _setActiveDragRect_dec, _setDropTargetId_dec, _setInvalidDropTarget_dec, _setValidRootIds_dec, _cancelNewComponentDrag_dec, _startNewComponentDrag_dec, _setIsDragging_dec, _setWidgetFeatures_dec, _init7;
50
50
  import * as React from "react";
51
51
  import React__default, { useMemo as useMemo$2, createContext, useContext, isValidElement as isValidElement$1, cloneElement as cloneElement$1, Children, useState, createElement, useRef, useLayoutEffect as useLayoutEffect$2, forwardRef, memo, useEffect, version as version$2, Component, useCallback, useImperativeHandle, useReducer, PureComponent, useSyncExternalStore, Suspense, createRef } from "react";
52
52
  import * as ReactDOM from "react-dom";
@@ -2703,14 +2703,14 @@ function getLoaderFn$1(options) {
2703
2703
  if (!(loader === "all")) return [3, 3];
2704
2704
  return [4, import(
2705
2705
  /* webpackChunkName: "blueprint-icons-all-paths-loader" */
2706
- "./allPathsLoader-66hpXNFC.js"
2706
+ "./allPathsLoader-C6kYq5jL.js"
2707
2707
  )];
2708
2708
  case 2:
2709
2709
  return [2, _b2.sent().allPathsLoader];
2710
2710
  case 3:
2711
2711
  return [4, import(
2712
2712
  /* webpackChunkName: "blueprint-icons-split-paths-by-size-loader" */
2713
- "./splitPathsBySizeLoader-BQDszFo7.js"
2713
+ "./splitPathsBySizeLoader-Cy4Y9soq.js"
2714
2714
  )];
2715
2715
  case 4:
2716
2716
  return [2, _b2.sent().splitPathsBySizeLoader];
@@ -63982,6 +63982,10 @@ class OperationAPI {
63982
63982
  var _a2;
63983
63983
  return (_a2 = this.socket) == null ? void 0 : _a2.call.editor.createComponent(payload);
63984
63984
  });
63985
+ __publicField(this, "editorDeleteComponents", async (payload) => {
63986
+ var _a2;
63987
+ return (_a2 = this.socket) == null ? void 0 : _a2.call.editor.deleteComponents(payload);
63988
+ });
63985
63989
  __publicField(this, "editorSetProperty", async (payload) => {
63986
63990
  var _a2;
63987
63991
  return (_a2 = this.socket) == null ? void 0 : _a2.call.editor.setProperty(payload);
@@ -64156,11 +64160,14 @@ async function connectSocket(serverUrl, peerId, userId) {
64156
64160
  return void 0;
64157
64161
  }
64158
64162
  }
64159
- _addPendingTransaction_dec = [action], _clearPendingTransactions_dec = [action], _dropComponent_dec = [action], _writeRuntimeProperties_dec = [action], _setWidgetProperties_dec = [action], _setWidgetProperty_dec = [action];
64163
+ _executeOrAddToBatch_dec = [action], _addPendingTransaction_dec = [action], _clearPendingTransactions_dec = [action], _batchUpdate_dec = [action], _createComponent_dec = [action], _dropComponent_dec = [action], _ackDeletedComponents_dec = [action], _writeRuntimeProperties_dec = [action], _setWidgetProperties_dec = [action], _setWidgetProperty_dec = [action];
64160
64164
  class OperationManager {
64161
64165
  constructor() {
64162
64166
  __runInitializers(_init3, 5, this);
64163
64167
  __publicField(this, "pendingTransactions", []);
64168
+ __publicField(this, "waitingForBatch", false);
64169
+ __publicField(this, "batchOperations", []);
64170
+ __publicField(this, "batchOperationTransactionId");
64164
64171
  __publicField(this, "visibleSourceIds", []);
64165
64172
  makeAutoObservable(this);
64166
64173
  registerStores({
@@ -64172,23 +64179,70 @@ class OperationManager {
64172
64179
  }
64173
64180
  get pendingReparentOperations() {
64174
64181
  return this.pendingTransactions.filter(
64175
- (t3) => t3.type === "reparent"
64182
+ (t3) => t3.type === "editor:moveComponent"
64176
64183
  );
64177
64184
  }
64178
- get pendingSetPropertiesOperations() {
64185
+ get pendingDeleteOperations() {
64179
64186
  return this.pendingTransactions.filter(
64180
- (t3) => t3.type === "setProperties"
64187
+ (t3) => t3.type === "editor:deleteComponents"
64181
64188
  );
64182
64189
  }
64183
- get pendingSetPropertyOperations() {
64190
+ get pendingSetPropertiesOperations() {
64184
64191
  return this.pendingTransactions.filter(
64185
- (t3) => t3.type === "setProperty"
64192
+ (t3) => t3.type === "editor:setProperties"
64186
64193
  );
64187
64194
  }
64195
+ get hasPendingOperations() {
64196
+ return this.pendingTransactions.length > 0;
64197
+ }
64188
64198
  get allNames() {
64189
64199
  return [];
64190
64200
  }
64201
+ executeOrAddToBatch(operation) {
64202
+ const transactionId = this.batchOperationTransactionId ?? generateId$1();
64203
+ const payload = this.waitingForBatch ? operation.payload : {
64204
+ ...operation.payload,
64205
+ transaction: {
64206
+ id: transactionId
64207
+ }
64208
+ };
64209
+ const opWithId = {
64210
+ ...operation,
64211
+ id: transactionId,
64212
+ payload
64213
+ };
64214
+ this.addPendingTransaction(opWithId);
64215
+ if (this.waitingForBatch) {
64216
+ this.batchOperations.push(opWithId);
64217
+ } else {
64218
+ switch (operation.type) {
64219
+ case "editor:moveComponent":
64220
+ return sourceUpdateApi.editorMoveComponent(
64221
+ payload
64222
+ ).catch((e3) => {
64223
+ console.error("Error during operation", e3);
64224
+ });
64225
+ case "editor:setProperties":
64226
+ return sourceUpdateApi.editorSetProperties(
64227
+ payload
64228
+ ).catch((e3) => {
64229
+ console.error("Error during operation", e3);
64230
+ });
64231
+ case "editor:createComponent":
64232
+ return sourceUpdateApi.editorCreateComponent(
64233
+ payload
64234
+ ).catch((e3) => {
64235
+ console.error("Error during operation", e3);
64236
+ });
64237
+ }
64238
+ }
64239
+ }
64191
64240
  addPendingTransaction(transaction2) {
64241
+ if (transaction2.type === "editor:createComponent") {
64242
+ getEditStore().runtimeEntitiesManager.addOptimisticCreateWidget(
64243
+ transaction2.payload
64244
+ );
64245
+ }
64192
64246
  this.pendingTransactions.push(transaction2);
64193
64247
  }
64194
64248
  clearPendingTransactions(transactionIds) {
@@ -64214,53 +64268,70 @@ class OperationManager {
64214
64268
  }
64215
64269
  });
64216
64270
  }
64271
+ batchUpdate(performOperations) {
64272
+ this.waitingForBatch = true;
64273
+ this.batchOperationTransactionId = generateId$1();
64274
+ performOperations();
64275
+ sourceUpdateApi.editorBatchUpdate({
64276
+ updates: this.batchOperations,
64277
+ transaction: {
64278
+ id: this.batchOperationTransactionId
64279
+ }
64280
+ });
64281
+ this.waitingForBatch = false;
64282
+ this.batchOperations = [];
64283
+ this.batchOperationTransactionId = void 0;
64284
+ }
64285
+ createComponent(payload) {
64286
+ this.executeOrAddToBatch({
64287
+ type: "editor:createComponent",
64288
+ payload
64289
+ });
64290
+ }
64217
64291
  dropComponent(action2) {
64218
64292
  const { from: from2, to: to2, propsToChange } = action2;
64219
- const transactionId = generateId$1();
64220
- this.addPendingTransaction({
64221
- type: "reparent",
64222
- id: transactionId,
64223
- payload: { from: from2, to: to2, changedProps: propsToChange ?? {} },
64224
- affectedSourceIds: [from2.source.id, to2.source.id]
64225
- });
64226
- sourceUpdateApi.editorMoveComponent({
64293
+ const payload = {
64227
64294
  from: from2,
64228
64295
  to: to2,
64229
- changedProps: propsToChange ?? {},
64230
- transaction: {
64231
- id: transactionId
64232
- }
64233
- }).catch((e3) => {
64234
- console.error("Error during drop on stack", e3);
64296
+ changedProps: propsToChange ?? {}
64297
+ };
64298
+ this.executeOrAddToBatch({
64299
+ type: "editor:moveComponent",
64300
+ payload
64301
+ });
64302
+ }
64303
+ ackDeletedComponents(payload) {
64304
+ var _a2, _b2;
64305
+ if (!((_a2 = payload == null ? void 0 : payload.transaction) == null ? void 0 : _a2.id)) {
64306
+ console.error("No transaction id in delete request", payload);
64307
+ return;
64308
+ }
64309
+ this.addPendingTransaction({
64310
+ type: "editor:deleteComponents",
64311
+ id: (_b2 = payload == null ? void 0 : payload.transaction) == null ? void 0 : _b2.id,
64312
+ payload
64235
64313
  });
64236
64314
  }
64237
64315
  writeRuntimeProperties(sourceId, transactionId, updates) {
64238
64316
  this.addPendingTransaction({
64239
- type: "setProperties",
64317
+ type: "editor:setProperties",
64240
64318
  id: transactionId,
64241
- sourceId,
64242
64319
  payload: { element: { source: { id: sourceId } }, properties: updates }
64243
64320
  });
64244
64321
  }
64245
64322
  setWidgetProperties(sourceId, properties2, callback) {
64246
- const transactionId = generateId$1();
64247
- this.addPendingTransaction({
64248
- type: "setProperties",
64249
- id: transactionId,
64250
- sourceId,
64251
- payload: { element: { source: { id: sourceId } }, properties: properties2 },
64252
- callback
64253
- });
64254
- sourceUpdateApi.editorSetProperties({
64323
+ const payload = {
64255
64324
  element: {
64256
64325
  source: {
64257
64326
  id: sourceId
64258
64327
  }
64259
64328
  },
64260
- properties: properties2,
64261
- transaction: {
64262
- id: transactionId
64263
- }
64329
+ properties: properties2
64330
+ };
64331
+ this.executeOrAddToBatch({
64332
+ type: "editor:setProperties",
64333
+ payload,
64334
+ callback
64264
64335
  });
64265
64336
  }
64266
64337
  setWidgetProperty(sourceId, property, value, callback) {
@@ -64269,11 +64340,18 @@ class OperationManager {
64269
64340
  async ensureFilesSynced() {
64270
64341
  await sourceUpdateApi.ensureFilesSynced();
64271
64342
  }
64343
+ generateSourceId() {
64344
+ return `SB-${generateId$1()}`;
64345
+ }
64272
64346
  }
64273
64347
  _init3 = __decoratorStart(null);
64348
+ __decorateElement(_init3, 1, "executeOrAddToBatch", _executeOrAddToBatch_dec, OperationManager);
64274
64349
  __decorateElement(_init3, 1, "addPendingTransaction", _addPendingTransaction_dec, OperationManager);
64275
64350
  __decorateElement(_init3, 1, "clearPendingTransactions", _clearPendingTransactions_dec, OperationManager);
64351
+ __decorateElement(_init3, 1, "batchUpdate", _batchUpdate_dec, OperationManager);
64352
+ __decorateElement(_init3, 1, "createComponent", _createComponent_dec, OperationManager);
64276
64353
  __decorateElement(_init3, 1, "dropComponent", _dropComponent_dec, OperationManager);
64354
+ __decorateElement(_init3, 1, "ackDeletedComponents", _ackDeletedComponents_dec, OperationManager);
64277
64355
  __decorateElement(_init3, 1, "writeRuntimeProperties", _writeRuntimeProperties_dec, OperationManager);
64278
64356
  __decorateElement(_init3, 1, "setWidgetProperties", _setWidgetProperties_dec, OperationManager);
64279
64357
  __decorateElement(_init3, 1, "setWidgetProperty", _setWidgetProperty_dec, OperationManager);
@@ -64498,8 +64576,10 @@ function isSbComponent(child) {
64498
64576
  return typeof child === "object" && ((_a2 = child.type) == null ? void 0 : _a2.isSb) === superblocksComponentSymbol;
64499
64577
  }
64500
64578
  const BindingMetaSymbol = Symbol("binding-meta");
64579
+ _processRoot_dec = [action], _addWidgetFromPayload_dec = [action];
64501
64580
  class RuntimeWidgetsManager {
64502
64581
  constructor(nameManager) {
64582
+ __runInitializers(_init4, 5, this);
64503
64583
  __publicField(this, "widgets", {});
64504
64584
  __publicField(this, "sourceIdCount", {});
64505
64585
  __publicField(this, "sourceToInstanceIdSample", {});
@@ -64607,6 +64687,61 @@ class RuntimeWidgetsManager {
64607
64687
  isSbComponent: true
64608
64688
  });
64609
64689
  }
64690
+ addWidgetFromPayload(details, createRequest) {
64691
+ const parentMeta = this.widgets[details.parentInstanceId];
64692
+ if (!parentMeta || !parentMeta.scopeId) {
64693
+ return;
64694
+ }
64695
+ const parentScopeId = parentMeta.scopeId;
64696
+ const traverse = (params) => {
64697
+ var _a2;
64698
+ const { child } = params;
64699
+ const childName = typeof ((_a2 = child.properties.name) == null ? void 0 : _a2.value) === "string" ? child.properties.name.value : void 0;
64700
+ const childIdentifier = this.nameManager.registerAndGetIdentifiers({
64701
+ sourceId: child.id ?? getEditStore().operationManager.generateSourceId(),
64702
+ name: childName,
64703
+ scopeId: parentScopeId,
64704
+ rootId: details.rootInstanceId
64705
+ });
64706
+ const childProps = Object.entries(child.properties).reduce(
64707
+ (acc, [key2, value]) => {
64708
+ if (typeof (value == null ? void 0 : value.value) === "string") {
64709
+ acc[key2] = value.value;
64710
+ }
64711
+ return acc;
64712
+ },
64713
+ {}
64714
+ );
64715
+ const children = child.children.map(
64716
+ (child2) => traverse({
64717
+ child: child2,
64718
+ parentInstanceId: childIdentifier.instanceId
64719
+ })
64720
+ );
64721
+ this.setWidgetMeta(childIdentifier.instanceId, {
64722
+ instanceId: childIdentifier.instanceId,
64723
+ isSbComponent: true,
64724
+ isInCustomComponent: false,
64725
+ sourceId: childIdentifier.sourceId,
64726
+ rootInstanceId: details.rootInstanceId,
64727
+ scopeId: parentScopeId,
64728
+ type: child.tagName,
64729
+ name: childIdentifier.name,
64730
+ props: childProps,
64731
+ parentInstanceId: params.parentInstanceId,
64732
+ children
64733
+ });
64734
+ return {
64735
+ isSupportedElement: true,
64736
+ isSbComponent: true,
64737
+ value: childIdentifier.instanceId
64738
+ };
64739
+ };
64740
+ traverse({
64741
+ child: createRequest,
64742
+ parentInstanceId: details.parentInstanceId
64743
+ });
64744
+ }
64610
64745
  getMeta(id2) {
64611
64746
  return this.widgets[id2];
64612
64747
  }
@@ -64646,10 +64781,14 @@ class RuntimeWidgetsManager {
64646
64781
  return this.getClosestAncestorByType(currentWidget.parentInstanceId, type5);
64647
64782
  }
64648
64783
  }
64649
- _processRootWidget_dec = [action];
64784
+ _init4 = __decoratorStart(null);
64785
+ __decorateElement(_init4, 1, "processRoot", _processRoot_dec, RuntimeWidgetsManager);
64786
+ __decorateElement(_init4, 1, "addWidgetFromPayload", _addWidgetFromPayload_dec, RuntimeWidgetsManager);
64787
+ __decoratorMetadata(_init4, RuntimeWidgetsManager);
64788
+ _processRootWidget_dec = [action], _addOptimisticCreateWidget_dec = [action];
64650
64789
  class RuntimeEntitiesManager {
64651
64790
  constructor(nameManager, entityManager) {
64652
- __runInitializers(_init4, 5, this);
64791
+ __runInitializers(_init5, 5, this);
64653
64792
  __publicField(this, "widgets");
64654
64793
  __publicField(this, "entitiesWithLocalBindings", /* @__PURE__ */ new Set());
64655
64794
  __publicField(this, "getOptimisticWidgetMeta", makeMobxCachedGetter((id2) => {
@@ -64720,25 +64859,6 @@ class RuntimeEntitiesManager {
64720
64859
  props: mergedProps
64721
64860
  };
64722
64861
  }
64723
- const singlePropUpdates = getEditStore().operationManager.pendingSetPropertyOperations.filter(
64724
- (op2) => op2.payload.element.source.id === sourceId
64725
- );
64726
- if (singlePropUpdates.length > 0) {
64727
- const mergedProps = { ...merged.props ?? {} };
64728
- singlePropUpdates.forEach((update) => {
64729
- const { property, value } = update.payload;
64730
- mergedProps[property] = getPropertyValue$1({
64731
- entityKey: property,
64732
- property: value,
64733
- name,
64734
- scopeId
64735
- });
64736
- });
64737
- merged = {
64738
- ...merged,
64739
- props: mergedProps
64740
- };
64741
- }
64742
64862
  const pendingResize = getEditStore().ui.resizing.pendingResize(sourceId);
64743
64863
  if (pendingResize) {
64744
64864
  const { width, height, marginLeft, marginTop } = pendingResize;
@@ -64808,6 +64928,21 @@ class RuntimeEntitiesManager {
64808
64928
  processRootWidget(params) {
64809
64929
  this.widgets.processRoot(params);
64810
64930
  }
64931
+ addOptimisticCreateWidget(createRequest) {
64932
+ const parentMeta = this.getAnyEditorWidgetMeta(
64933
+ createRequest.parentElement.source.id
64934
+ );
64935
+ if (!parentMeta) {
64936
+ return;
64937
+ }
64938
+ this.widgets.addWidgetFromPayload(
64939
+ {
64940
+ rootInstanceId: parentMeta.rootInstanceId,
64941
+ parentInstanceId: parentMeta.instanceId
64942
+ },
64943
+ createRequest
64944
+ );
64945
+ }
64811
64946
  getEditorWidgetMeta(instanceId) {
64812
64947
  return this.getOptimisticWidgetMeta(instanceId);
64813
64948
  }
@@ -64882,28 +65017,52 @@ class RuntimeEntitiesManager {
64882
65017
  return (_b2 = this.widgets.getMeta(parentInstanceId)) == null ? void 0 : _b2.sourceId;
64883
65018
  }
64884
65019
  get relevantChildrenOperationsMap() {
64885
- const reparentOperations = getEditStore().operationManager.pendingReparentOperations;
64886
- if (reparentOperations.length === 0) {
64887
- return {};
64888
- }
65020
+ const allPending = getEditStore().operationManager.allPendingTransactions;
64889
65021
  const ops = {};
64890
- for (const op2 of reparentOperations) {
64891
- const movedSource = op2.payload.from.source.id;
64892
- const fromParentSource = this.getParentSourceId(movedSource);
64893
- const toSource = op2.payload.to.source.id;
64894
- if (fromParentSource) {
64895
- ops[fromParentSource] ?? (ops[fromParentSource] = []);
64896
- ops[fromParentSource].push({
64897
- type: "REMOVE",
64898
- sourceId: movedSource
65022
+ for (const op2 of allPending) {
65023
+ if (op2.type === "editor:moveComponent") {
65024
+ const payload = op2.payload;
65025
+ const movedSource = payload.from.source.id;
65026
+ const fromParentSource = this.getParentSourceId(movedSource);
65027
+ const toSource = payload.to.source.id;
65028
+ if (fromParentSource) {
65029
+ ops[fromParentSource] ?? (ops[fromParentSource] = []);
65030
+ ops[fromParentSource].push({
65031
+ type: "REMOVE",
65032
+ sourceId: movedSource
65033
+ });
65034
+ }
65035
+ ops[toSource] ?? (ops[toSource] = []);
65036
+ ops[toSource].push({
65037
+ type: "ADD",
65038
+ sourceId: movedSource,
65039
+ index: payload.to.source.index ?? -1
65040
+ });
65041
+ } else if (op2.type === "editor:deleteComponents") {
65042
+ const payload = op2.payload;
65043
+ payload.elements.forEach((element) => {
65044
+ const deletedSource = element.source.id;
65045
+ const parentSourceId = this.getParentSourceId(deletedSource);
65046
+ if (parentSourceId) {
65047
+ ops[parentSourceId] ?? (ops[parentSourceId] = []);
65048
+ ops[parentSourceId].push({
65049
+ type: "REMOVE",
65050
+ sourceId: deletedSource
65051
+ });
65052
+ }
64899
65053
  });
65054
+ } else if (op2.type === "editor:createComponent") {
65055
+ const payload = op2.payload;
65056
+ const parentSourceId = payload.parentElement.source.id;
65057
+ if (parentSourceId && payload.id) {
65058
+ ops[parentSourceId] ?? (ops[parentSourceId] = []);
65059
+ ops[parentSourceId].push({
65060
+ type: "ADD",
65061
+ sourceId: payload.id,
65062
+ index: payload.parentElement.source.index ?? -1
65063
+ });
65064
+ }
64900
65065
  }
64901
- ops[toSource] ?? (ops[toSource] = []);
64902
- ops[toSource].push({
64903
- type: "ADD",
64904
- sourceId: movedSource,
64905
- index: op2.payload.to.source.index ?? -1
64906
- });
64907
65066
  }
64908
65067
  return ops;
64909
65068
  }
@@ -64913,12 +65072,10 @@ class RuntimeEntitiesManager {
64913
65072
  // TODO will need to include all other operations like
64914
65073
  // widget creation/deletion, etc.
64915
65074
  get hasEditOperationsPending() {
64916
- const reparentOperations = getEditStore().operationManager.pendingReparentOperations;
64917
- const propUpdates = getEditStore().operationManager.pendingSetPropertiesOperations;
64918
- const propertyOperations = getEditStore().operationManager.pendingSetPropertyOperations;
65075
+ const hasPendingOperations = getEditStore().operationManager.hasPendingOperations;
64919
65076
  const hasPendingResize = getEditStore().ui.resizing.hasAnyPendingResize;
64920
65077
  const shouldRezisePage = getEditStore().ui.dnd.shouldResizePage;
64921
- return reparentOperations.length > 0 || propUpdates.length > 0 || propertyOperations.length > 0 || hasPendingResize || shouldRezisePage;
65078
+ return hasPendingOperations || hasPendingResize || shouldRezisePage;
64922
65079
  }
64923
65080
  get getPendingOperations() {
64924
65081
  const pendingResizes = getEditStore().ui.resizing.pendingResizes;
@@ -64957,9 +65114,10 @@ class RuntimeEntitiesManager {
64957
65114
  return this.widgets.getClosestAncestorByType(id2, type5);
64958
65115
  }
64959
65116
  }
64960
- _init4 = __decoratorStart(null);
64961
- __decorateElement(_init4, 1, "processRootWidget", _processRootWidget_dec, RuntimeEntitiesManager);
64962
- __decoratorMetadata(_init4, RuntimeEntitiesManager);
65117
+ _init5 = __decoratorStart(null);
65118
+ __decorateElement(_init5, 1, "processRootWidget", _processRootWidget_dec, RuntimeEntitiesManager);
65119
+ __decorateElement(_init5, 1, "addOptimisticCreateWidget", _addOptimisticCreateWidget_dec, RuntimeEntitiesManager);
65120
+ __decoratorMetadata(_init5, RuntimeEntitiesManager);
64963
65121
  const WithLayoutContainerTypes = /* @__PURE__ */ new Set([
64964
65122
  "SbContainer",
64965
65123
  "SbColumn",
@@ -65112,7 +65270,7 @@ _refreshPositionsAndGetDropConstraints_dec = [action];
65112
65270
  class GridManager {
65113
65271
  // cannot derive dnd from root because it may not be initialized yet
65114
65272
  constructor(root2, dnd) {
65115
- __runInitializers(_init5, 5, this);
65273
+ __runInitializers(_init6, 5, this);
65116
65274
  __publicField(this, "root");
65117
65275
  __publicField(this, "dnd");
65118
65276
  this.root = root2;
@@ -65357,9 +65515,9 @@ class GridManager {
65357
65515
  return activeDragRect;
65358
65516
  }
65359
65517
  }
65360
- _init5 = __decoratorStart(null);
65361
- __decorateElement(_init5, 1, "refreshPositionsAndGetDropConstraints", _refreshPositionsAndGetDropConstraints_dec, GridManager);
65362
- __decoratorMetadata(_init5, GridManager);
65518
+ _init6 = __decoratorStart(null);
65519
+ __decorateElement(_init6, 1, "refreshPositionsAndGetDropConstraints", _refreshPositionsAndGetDropConstraints_dec, GridManager);
65520
+ __decoratorMetadata(_init6, GridManager);
65363
65521
  const isWidgetVStack = (widget) => {
65364
65522
  var _a2, _b2;
65365
65523
  if (!widget || !widget.type) {
@@ -65704,7 +65862,7 @@ const getWidgetNode = (instanceId) => {
65704
65862
  _setWidgetFeatures_dec = [action], _setIsDragging_dec = [action], _startNewComponentDrag_dec = [action], _cancelNewComponentDrag_dec = [action], _setValidRootIds_dec = [action], _setInvalidDropTarget_dec = [action], _setDropTargetId_dec = [action], _setActiveDragRect_dec = [action], _setActiveTargetRect_dec = [action], _setWidgetPosition_dec = [action], _updateChildPositions_dec = [action];
65705
65863
  class DragAndDropManager {
65706
65864
  constructor(root2) {
65707
- __runInitializers(_init6, 5, this);
65865
+ __runInitializers(_init7, 5, this);
65708
65866
  __publicField(this, "root");
65709
65867
  __publicField(this, "stack");
65710
65868
  __publicField(this, "grid");
@@ -65921,19 +66079,19 @@ class DragAndDropManager {
65921
66079
  this._shouldResizePage = false;
65922
66080
  }
65923
66081
  }
65924
- _init6 = __decoratorStart(null);
65925
- __decorateElement(_init6, 1, "setWidgetFeatures", _setWidgetFeatures_dec, DragAndDropManager);
65926
- __decorateElement(_init6, 1, "setIsDragging", _setIsDragging_dec, DragAndDropManager);
65927
- __decorateElement(_init6, 1, "startNewComponentDrag", _startNewComponentDrag_dec, DragAndDropManager);
65928
- __decorateElement(_init6, 1, "cancelNewComponentDrag", _cancelNewComponentDrag_dec, DragAndDropManager);
65929
- __decorateElement(_init6, 1, "setValidRootIds", _setValidRootIds_dec, DragAndDropManager);
65930
- __decorateElement(_init6, 1, "setInvalidDropTarget", _setInvalidDropTarget_dec, DragAndDropManager);
65931
- __decorateElement(_init6, 1, "setDropTargetId", _setDropTargetId_dec, DragAndDropManager);
65932
- __decorateElement(_init6, 1, "setActiveDragRect", _setActiveDragRect_dec, DragAndDropManager);
65933
- __decorateElement(_init6, 1, "setActiveTargetRect", _setActiveTargetRect_dec, DragAndDropManager);
65934
- __decorateElement(_init6, 1, "setWidgetPosition", _setWidgetPosition_dec, DragAndDropManager);
65935
- __decorateElement(_init6, 1, "updateChildPositions", _updateChildPositions_dec, DragAndDropManager);
65936
- __decoratorMetadata(_init6, DragAndDropManager);
66082
+ _init7 = __decoratorStart(null);
66083
+ __decorateElement(_init7, 1, "setWidgetFeatures", _setWidgetFeatures_dec, DragAndDropManager);
66084
+ __decorateElement(_init7, 1, "setIsDragging", _setIsDragging_dec, DragAndDropManager);
66085
+ __decorateElement(_init7, 1, "startNewComponentDrag", _startNewComponentDrag_dec, DragAndDropManager);
66086
+ __decorateElement(_init7, 1, "cancelNewComponentDrag", _cancelNewComponentDrag_dec, DragAndDropManager);
66087
+ __decorateElement(_init7, 1, "setValidRootIds", _setValidRootIds_dec, DragAndDropManager);
66088
+ __decorateElement(_init7, 1, "setInvalidDropTarget", _setInvalidDropTarget_dec, DragAndDropManager);
66089
+ __decorateElement(_init7, 1, "setDropTargetId", _setDropTargetId_dec, DragAndDropManager);
66090
+ __decorateElement(_init7, 1, "setActiveDragRect", _setActiveDragRect_dec, DragAndDropManager);
66091
+ __decorateElement(_init7, 1, "setActiveTargetRect", _setActiveTargetRect_dec, DragAndDropManager);
66092
+ __decorateElement(_init7, 1, "setWidgetPosition", _setWidgetPosition_dec, DragAndDropManager);
66093
+ __decorateElement(_init7, 1, "updateChildPositions", _updateChildPositions_dec, DragAndDropManager);
66094
+ __decoratorMetadata(_init7, DragAndDropManager);
65937
66095
  const VERTICAL_ALIGNMENT_MAP = {
65938
66096
  top: "flex-start",
65939
66097
  center: "center",
@@ -113282,12 +113440,14 @@ function getSectionChildren() {
113282
113440
  function getTriggerComponent({
113283
113441
  componentType,
113284
113442
  parentElement,
113285
- primaryComponentName
113443
+ primaryComponentName,
113444
+ triggerComponentId
113286
113445
  }) {
113287
113446
  if (componentType === "SbModal") {
113288
113447
  return {
113289
113448
  parentElement,
113290
113449
  tagName: "SbButton",
113450
+ id: triggerComponentId,
113291
113451
  properties: {
113292
113452
  label: Property.Static("Open Modal"),
113293
113453
  onClick: Property.Event([
@@ -113305,6 +113465,7 @@ function getTriggerComponent({
113305
113465
  return {
113306
113466
  parentElement,
113307
113467
  tagName: "SbButton",
113468
+ id: triggerComponentId,
113308
113469
  properties: {
113309
113470
  label: Property.Static("Open Slideout"),
113310
113471
  onClick: Property.Event([
@@ -113484,12 +113645,14 @@ async function createComponent({
113484
113645
  console.log("creating component", { tagName, properties: properties2 });
113485
113646
  const parentElement = { source: parent };
113486
113647
  const needTriggerComponent = componentType === "SbModal" || componentType === "SbSlideout";
113648
+ const editStore2 = getEditStore();
113487
113649
  let primaryComponent = {
113488
113650
  parentElement,
113489
113651
  tagName,
113490
113652
  properties: properties2,
113491
113653
  children,
113492
- scopeName
113654
+ scopeName,
113655
+ id: editStore2.operationManager.generateSourceId()
113493
113656
  };
113494
113657
  if (willWrapInSectionAndColumn) {
113495
113658
  primaryComponent = wrapInSectionColumnIfDroppingOnPage(
@@ -113501,25 +113664,17 @@ async function createComponent({
113501
113664
  const triggerComponent = getTriggerComponent({
113502
113665
  componentType,
113503
113666
  parentElement,
113504
- primaryComponentName: name
113667
+ primaryComponentName: name,
113668
+ triggerComponentId: editStore2.operationManager.generateSourceId()
113505
113669
  });
113506
- const result = await sourceUpdateApi.editorBatchUpdate({
113507
- updates: [
113508
- {
113509
- type: "editor:createComponent",
113510
- payload: triggerComponent
113511
- },
113512
- {
113513
- type: "editor:createComponent",
113514
- payload: primaryComponent
113515
- }
113516
- ]
113670
+ editStore2.operationManager.batchUpdate(() => {
113671
+ editStore2.operationManager.createComponent(triggerComponent);
113672
+ editStore2.operationManager.createComponent(primaryComponent);
113517
113673
  });
113518
- if (Array.isArray(result) && result.length > 0 && typeof result[0] === "string") {
113519
- return result[0];
113520
- }
113674
+ return triggerComponent.id;
113521
113675
  } else {
113522
- return sourceUpdateApi.editorCreateComponent(primaryComponent);
113676
+ editStore2.operationManager.createComponent(primaryComponent);
113677
+ return primaryComponent.id;
113523
113678
  }
113524
113679
  }
113525
113680
  function wrapInSectionColumnIfDroppingOnPage(primaryComponent, parentType) {
@@ -113534,6 +113689,7 @@ function wrapInSectionColumnIfDroppingOnPage(primaryComponent, parentType) {
113534
113689
  return {
113535
113690
  parentElement: primaryComponent.parentElement,
113536
113691
  tagName: "SbSection",
113692
+ id: getEditStore().operationManager.generateSourceId(),
113537
113693
  properties: sectionProperties,
113538
113694
  children: [primaryComponent]
113539
113695
  };
@@ -113549,6 +113705,7 @@ function wrapInSectionColumnIfDroppingOnPage(primaryComponent, parentType) {
113549
113705
  return {
113550
113706
  parentElement: primaryComponent.parentElement,
113551
113707
  tagName: "SbColumn",
113708
+ id: getEditStore().operationManager.generateSourceId(),
113552
113709
  properties: columnProperties,
113553
113710
  children: [primaryComponent]
113554
113711
  };
@@ -113556,10 +113713,12 @@ function wrapInSectionColumnIfDroppingOnPage(primaryComponent, parentType) {
113556
113713
  return {
113557
113714
  parentElement: primaryComponent.parentElement,
113558
113715
  tagName: "SbSection",
113716
+ id: getEditStore().operationManager.generateSourceId(),
113559
113717
  properties: sectionProperties,
113560
113718
  children: [
113561
113719
  {
113562
113720
  tagName: "SbColumn",
113721
+ id: getEditStore().operationManager.generateSourceId(),
113563
113722
  properties: {
113564
113723
  ...columnProperties,
113565
113724
  layout: Property.Static("vertical")
@@ -147351,14 +147510,14 @@ function getLoaderFn(options) {
147351
147510
  if (!(loader === "all")) return [3, 3];
147352
147511
  return [4, import(
147353
147512
  /* webpackChunkName: "blueprint-icons-all-paths-loader" */
147354
- "./allPathsLoader-NDdzt1-S.js"
147513
+ "./allPathsLoader-BBePZAWr.js"
147355
147514
  )];
147356
147515
  case 2:
147357
147516
  return [2, _b2.sent().allPathsLoader];
147358
147517
  case 3:
147359
147518
  return [4, import(
147360
147519
  /* webpackChunkName: "blueprint-icons-split-paths-by-size-loader" */
147361
- "./splitPathsBySizeLoader-DF5UX5DW.js"
147520
+ "./splitPathsBySizeLoader-D3MLR09i.js"
147362
147521
  )];
147363
147522
  case 4:
147364
147523
  return [2, _b2.sent().splitPathsBySizeLoader];
@@ -164705,17 +164864,17 @@ function system(constructor, dependencies2 = [], { singleton: singleton2 } = { s
164705
164864
  const id = () => Symbol();
164706
164865
  function init(systemSpec) {
164707
164866
  const singletons = /* @__PURE__ */ new Map();
164708
- const _init7 = ({ id: id2, constructor, dependencies: dependencies2, singleton: singleton2 }) => {
164867
+ const _init8 = ({ id: id2, constructor, dependencies: dependencies2, singleton: singleton2 }) => {
164709
164868
  if (singleton2 && singletons.has(id2)) {
164710
164869
  return singletons.get(id2);
164711
164870
  }
164712
- const system2 = constructor(dependencies2.map((e3) => _init7(e3)));
164871
+ const system2 = constructor(dependencies2.map((e3) => _init8(e3)));
164713
164872
  if (singleton2) {
164714
164873
  singletons.set(id2, system2);
164715
164874
  }
164716
164875
  return system2;
164717
164876
  };
164718
- return _init7(systemSpec);
164877
+ return _init8(systemSpec);
164719
164878
  }
164720
164879
  function omit(keys2, obj) {
164721
164880
  const result = {};
@@ -182179,6 +182338,13 @@ const EmbedWrapper = (props) => {
182179
182338
  "sb-retrieve-property-panel-props",
182180
182339
  retrievePropertyPanelPropsListener
182181
182340
  );
182341
+ const deleteComponentsListener = (event) => {
182342
+ getEditStore().operationManager.ackDeletedComponents(event.data.payload);
182343
+ };
182344
+ iframeMessageHandler.addEventListener(
182345
+ "sb-delete-components",
182346
+ deleteComponentsListener
182347
+ );
182182
182348
  const updatePropertyWithEffectsListener = (event) => {
182183
182349
  const payload = {
182184
182350
  sourceId: event.data.payload.sourceId,
@@ -182228,6 +182394,10 @@ const EmbedWrapper = (props) => {
182228
182394
  "sb-bootstrap-response",
182229
182395
  bootstrapResponseListener
182230
182396
  );
182397
+ iframeMessageHandler.removeEventListener(
182398
+ "sb-delete-components",
182399
+ deleteComponentsListener
182400
+ );
182231
182401
  iframeMessageHandler.removeEventListener(
182232
182402
  "sb-update-property-with-effects",
182233
182403
  updatePropertyWithEffectsListener
@@ -195665,4 +195835,4 @@ export {
195665
195835
  SbProvider as y,
195666
195836
  SbEventFlow as z
195667
195837
  };
195668
- //# sourceMappingURL=index-BBdi2OTU.js.map
195838
+ //# sourceMappingURL=index-Cf5B7k85.js.map