@inditextech/weave-sdk 0.14.3 → 0.15.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.
package/dist/sdk.cjs CHANGED
@@ -15506,6 +15506,7 @@ var WeaveStore = class {
15506
15506
  this.instance = instance;
15507
15507
  this.logger = this.instance.getChildLogger(this.getName());
15508
15508
  this.instance.getMainLogger().info(`Store with name [${this.getName()}] registered`);
15509
+ this.instance.emitEvent("onRoomLoaded", this.isRoomLoaded);
15509
15510
  return this;
15510
15511
  }
15511
15512
  getUser() {
@@ -15530,8 +15531,7 @@ var WeaveStore = class {
15530
15531
  return JSON.parse(JSON.stringify(this.state, void 0, 2));
15531
15532
  }
15532
15533
  setup() {
15533
- const config = this.instance.getConfiguration();
15534
- config.callbacks?.onRoomLoaded?.(this.isRoomLoaded);
15534
+ this.isRoomLoaded = false;
15535
15535
  this.instance.emitEvent("onRoomLoaded", this.isRoomLoaded);
15536
15536
  if (this.supportsUndoManager) {
15537
15537
  const weaveStateValues = (0, __syncedstore_core.getYjsValue)(
@@ -15552,7 +15552,6 @@ var WeaveStore = class {
15552
15552
  redoStackLength: this.undoManager.redoStack.length,
15553
15553
  undoStackLength: this.undoManager.undoStack.length
15554
15554
  };
15555
- config.callbacks?.onUndoManagerStatusChange?.(change);
15556
15555
  this.instance.emitEvent("onUndoManagerStatusChange", change);
15557
15556
  });
15558
15557
  this.undoManager.on("stack-item-popped", () => {
@@ -15562,14 +15561,12 @@ var WeaveStore = class {
15562
15561
  redoStackLength: this.undoManager.redoStack.length,
15563
15562
  undoStackLength: this.undoManager.undoStack.length
15564
15563
  };
15565
- config.callbacks?.onUndoManagerStatusChange?.(change);
15566
15564
  this.instance.emitEvent("onUndoManagerStatusChange", change);
15567
15565
  });
15568
15566
  }
15569
15567
  }
15570
15568
  (0, __syncedstore_core.observeDeep)(this.getState(), () => {
15571
15569
  const newState = JSON.parse(JSON.stringify(this.getState()));
15572
- config.callbacks?.onStateChange?.(newState);
15573
15570
  this.instance.emitEvent("onStateChange", newState);
15574
15571
  const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
15575
15572
  if (this.isRoomLoaded && nodesSelectionPlugin && nodesSelectionPlugin.getSelectedNodes().length === 1) {
@@ -15583,7 +15580,6 @@ var WeaveStore = class {
15583
15580
  if (!this.isRoomLoaded && !(0, import_lodash.isEmpty)(this.state.weave)) {
15584
15581
  this.instance.setupRenderer();
15585
15582
  this.isRoomLoaded = true;
15586
- config.callbacks?.onRoomLoaded?.(this.isRoomLoaded);
15587
15583
  this.instance.emitEvent("onRoomLoaded", this.isRoomLoaded);
15588
15584
  }
15589
15585
  if (this.isRoomLoaded && !(0, import_lodash.isEmpty)(this.state.weave)) this.instance.render();
@@ -17916,7 +17912,7 @@ var WeaveRegisterManager = class {
17916
17912
 
17917
17913
  //#endregion
17918
17914
  //#region package.json
17919
- var version = "0.14.3";
17915
+ var version = "0.15.0";
17920
17916
 
17921
17917
  //#endregion
17922
17918
  //#region src/managers/setup.ts
@@ -18035,7 +18031,6 @@ var WeaveActionsManager = class {
18035
18031
  return this.activeAction;
18036
18032
  }
18037
18033
  triggerAction(actionName, params) {
18038
- const config = this.instance.getConfiguration();
18039
18034
  const actionsHandlers = this.instance.getActionsHandlers();
18040
18035
  if (!actionsHandlers[actionName]) {
18041
18036
  const msg = `Action handler with name [${actionName}] not registered`;
@@ -18045,7 +18040,6 @@ var WeaveActionsManager = class {
18045
18040
  if (typeof this.activeAction !== "undefined") this.cancelAction(this.activeAction);
18046
18041
  this.activeAction = actionName;
18047
18042
  const payload = actionsHandlers[actionName].trigger(this.cancelActionCallback(actionName), params);
18048
- config.callbacks?.onActiveActionChange?.(this.activeAction);
18049
18043
  this.instance.emitEvent("onActiveActionChange", this.activeAction);
18050
18044
  return payload;
18051
18045
  }
@@ -18080,7 +18074,6 @@ var WeaveActionsManager = class {
18080
18074
  return actionsHandlers[actionName].getProps?.();
18081
18075
  }
18082
18076
  cancelAction(actionName) {
18083
- const config = this.instance.getConfiguration();
18084
18077
  const actionsHandlers = this.instance.getActionsHandlers();
18085
18078
  if (!actionsHandlers[actionName]) {
18086
18079
  const msg = `Action handler with name [${actionName}] not registered`;
@@ -18089,7 +18082,6 @@ var WeaveActionsManager = class {
18089
18082
  }
18090
18083
  this.activeAction = void 0;
18091
18084
  actionsHandlers[actionName].cleanup?.();
18092
- config.callbacks?.onActiveActionChange?.(this.activeAction);
18093
18085
  this.instance.emitEvent("onActiveActionChange", this.activeAction);
18094
18086
  }
18095
18087
  cancelActionCallback(actionName) {
@@ -18313,7 +18305,6 @@ var Weave = class extends Emittery {
18313
18305
  this.setupManager.setupActions();
18314
18306
  this.moduleLogger.info("Instance started");
18315
18307
  this.status = __inditextech_weave_types.WEAVE_INSTANCE_STATUS.RUNNING;
18316
- this.getConfiguration().callbacks?.onInstanceStatus?.(this.status);
18317
18308
  this.emitEvent("onInstanceStatus", this.status);
18318
18309
  });
18319
18310
  }
@@ -18328,15 +18319,14 @@ var Weave = class extends Emittery {
18328
18319
  }
18329
18320
  async start() {
18330
18321
  this.moduleLogger.info("Start instance");
18322
+ this.emitEvent("onRoomLoaded", false);
18331
18323
  this.status = __inditextech_weave_types.WEAVE_INSTANCE_STATUS.STARTING;
18332
- this.getConfiguration().callbacks?.onInstanceStatus?.(this.status);
18333
18324
  this.emitEvent("onInstanceStatus", this.status);
18334
18325
  this.registerManager.registerNodesHandlers();
18335
18326
  this.registerManager.registerPlugins();
18336
18327
  this.registerManager.registerActionsHandlers();
18337
18328
  this.storeManager.registerStore(this.config.store);
18338
18329
  this.status = __inditextech_weave_types.WEAVE_INSTANCE_STATUS.LOADING_FONTS;
18339
- this.getConfiguration().callbacks?.onInstanceStatus?.(this.status);
18340
18330
  this.emitEvent("onInstanceStatus", this.status);
18341
18331
  await this.fontsManager.loadFonts();
18342
18332
  this.setupManager.setupLog();
@@ -18345,6 +18335,17 @@ var Weave = class extends Emittery {
18345
18335
  store.setup();
18346
18336
  store.connect();
18347
18337
  }
18338
+ destroy() {
18339
+ this.moduleLogger.info(`Destroying the instance`);
18340
+ this.clearListeners();
18341
+ this.status = __inditextech_weave_types.WEAVE_INSTANCE_STATUS.IDLE;
18342
+ this.emitEvent("onInstanceStatus", this.status);
18343
+ const store = this.storeManager.getStore();
18344
+ store.disconnect();
18345
+ const stage = this.getStage();
18346
+ if (stage) stage.destroy();
18347
+ this.moduleLogger.info(`Instance destroyed`);
18348
+ }
18348
18349
  getId() {
18349
18350
  return this.id;
18350
18351
  }
@@ -18459,13 +18460,11 @@ var Weave = class extends Emittery {
18459
18460
  update(newState) {
18460
18461
  this.getStore().setState(newState);
18461
18462
  this.renderer.render(() => {
18462
- this.config.callbacks?.onRender?.();
18463
18463
  this.emitEvent("onRender", {});
18464
18464
  });
18465
18465
  }
18466
18466
  render() {
18467
18467
  this.renderer.render(() => {
18468
- this.config.callbacks?.onRender?.();
18469
18468
  this.emitEvent("onRender", {});
18470
18469
  });
18471
18470
  }
package/dist/sdk.d.cts CHANGED
@@ -63,7 +63,6 @@ type WeaveConfig = {
63
63
  actions?: WeaveActionBase[];
64
64
  plugins?: WeavePluginBase[];
65
65
  fonts?: WeaveFont[];
66
- callbacks?: WeaveCallbacks;
67
66
  logger?: WeaveLoggerConfig;
68
67
  };
69
68
  type WeaveStatusKeys = keyof typeof WEAVE_INSTANCE_STATUS;
@@ -141,20 +140,6 @@ type WeaveUndoManagerOptions = {
141
140
  captureTimeout?: number;
142
141
  trackedOrigins?: Set<any>;
143
142
  };
144
- type WeaveUndoRedoChange = {
145
- canRedo: boolean;
146
- canUndo: boolean;
147
- redoStackLength: number;
148
- undoStackLength: number;
149
- };
150
- type WeaveCallbacks = {
151
- onRender?: () => void;
152
- onRoomLoaded?: (loaded: boolean) => void;
153
- onInstanceStatus?: (status: WeaveStatus) => void;
154
- onActiveActionChange?: (actionName: string | undefined) => void;
155
- onStateChange?: (state: WeaveState) => void;
156
- onUndoManagerStatusChange?: (undoManagerStatus: WeaveUndoRedoChange) => void;
157
- };
158
143
  declare type docElementTypeDescription = "xml" | "text" | Array<any> | object;
159
144
  declare type DocTypeDescription = {
160
145
  [key: string]: docElementTypeDescription;
@@ -393,6 +378,7 @@ declare class Weave extends Emittery {
393
378
  getStatus(): WeaveStatus;
394
379
  setStore(store: WeaveStore): void;
395
380
  start(): Promise<void>;
381
+ destroy(): void;
396
382
  getId(): string;
397
383
  getConfiguration(): WeaveConfig;
398
384
  emitEvent<T>(event: string, payload?: T): void;
package/dist/sdk.d.ts CHANGED
@@ -63,7 +63,6 @@ type WeaveConfig = {
63
63
  actions?: WeaveActionBase[];
64
64
  plugins?: WeavePluginBase[];
65
65
  fonts?: WeaveFont[];
66
- callbacks?: WeaveCallbacks;
67
66
  logger?: WeaveLoggerConfig;
68
67
  };
69
68
  type WeaveStatusKeys = keyof typeof WEAVE_INSTANCE_STATUS;
@@ -141,20 +140,6 @@ type WeaveUndoManagerOptions = {
141
140
  captureTimeout?: number;
142
141
  trackedOrigins?: Set<any>;
143
142
  };
144
- type WeaveUndoRedoChange = {
145
- canRedo: boolean;
146
- canUndo: boolean;
147
- redoStackLength: number;
148
- undoStackLength: number;
149
- };
150
- type WeaveCallbacks = {
151
- onRender?: () => void;
152
- onRoomLoaded?: (loaded: boolean) => void;
153
- onInstanceStatus?: (status: WeaveStatus) => void;
154
- onActiveActionChange?: (actionName: string | undefined) => void;
155
- onStateChange?: (state: WeaveState) => void;
156
- onUndoManagerStatusChange?: (undoManagerStatus: WeaveUndoRedoChange) => void;
157
- };
158
143
  declare type docElementTypeDescription = "xml" | "text" | Array<any> | object;
159
144
  declare type DocTypeDescription = {
160
145
  [key: string]: docElementTypeDescription;
@@ -393,6 +378,7 @@ declare class Weave extends Emittery {
393
378
  getStatus(): WeaveStatus;
394
379
  setStore(store: WeaveStore): void;
395
380
  start(): Promise<void>;
381
+ destroy(): void;
396
382
  getId(): string;
397
383
  getConfiguration(): WeaveConfig;
398
384
  emitEvent<T>(event: string, payload?: T): void;
package/dist/sdk.js CHANGED
@@ -15506,6 +15506,7 @@ var WeaveStore = class {
15506
15506
  this.instance = instance;
15507
15507
  this.logger = this.instance.getChildLogger(this.getName());
15508
15508
  this.instance.getMainLogger().info(`Store with name [${this.getName()}] registered`);
15509
+ this.instance.emitEvent("onRoomLoaded", this.isRoomLoaded);
15509
15510
  return this;
15510
15511
  }
15511
15512
  getUser() {
@@ -15530,8 +15531,7 @@ var WeaveStore = class {
15530
15531
  return JSON.parse(JSON.stringify(this.state, void 0, 2));
15531
15532
  }
15532
15533
  setup() {
15533
- const config = this.instance.getConfiguration();
15534
- config.callbacks?.onRoomLoaded?.(this.isRoomLoaded);
15534
+ this.isRoomLoaded = false;
15535
15535
  this.instance.emitEvent("onRoomLoaded", this.isRoomLoaded);
15536
15536
  if (this.supportsUndoManager) {
15537
15537
  const weaveStateValues = getYjsValue(
@@ -15552,7 +15552,6 @@ var WeaveStore = class {
15552
15552
  redoStackLength: this.undoManager.redoStack.length,
15553
15553
  undoStackLength: this.undoManager.undoStack.length
15554
15554
  };
15555
- config.callbacks?.onUndoManagerStatusChange?.(change);
15556
15555
  this.instance.emitEvent("onUndoManagerStatusChange", change);
15557
15556
  });
15558
15557
  this.undoManager.on("stack-item-popped", () => {
@@ -15562,14 +15561,12 @@ var WeaveStore = class {
15562
15561
  redoStackLength: this.undoManager.redoStack.length,
15563
15562
  undoStackLength: this.undoManager.undoStack.length
15564
15563
  };
15565
- config.callbacks?.onUndoManagerStatusChange?.(change);
15566
15564
  this.instance.emitEvent("onUndoManagerStatusChange", change);
15567
15565
  });
15568
15566
  }
15569
15567
  }
15570
15568
  observeDeep(this.getState(), () => {
15571
15569
  const newState = JSON.parse(JSON.stringify(this.getState()));
15572
- config.callbacks?.onStateChange?.(newState);
15573
15570
  this.instance.emitEvent("onStateChange", newState);
15574
15571
  const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
15575
15572
  if (this.isRoomLoaded && nodesSelectionPlugin && nodesSelectionPlugin.getSelectedNodes().length === 1) {
@@ -15583,7 +15580,6 @@ var WeaveStore = class {
15583
15580
  if (!this.isRoomLoaded && !(0, import_lodash.isEmpty)(this.state.weave)) {
15584
15581
  this.instance.setupRenderer();
15585
15582
  this.isRoomLoaded = true;
15586
- config.callbacks?.onRoomLoaded?.(this.isRoomLoaded);
15587
15583
  this.instance.emitEvent("onRoomLoaded", this.isRoomLoaded);
15588
15584
  }
15589
15585
  if (this.isRoomLoaded && !(0, import_lodash.isEmpty)(this.state.weave)) this.instance.render();
@@ -17916,7 +17912,7 @@ var WeaveRegisterManager = class {
17916
17912
 
17917
17913
  //#endregion
17918
17914
  //#region package.json
17919
- var version = "0.14.3";
17915
+ var version = "0.15.0";
17920
17916
 
17921
17917
  //#endregion
17922
17918
  //#region src/managers/setup.ts
@@ -18035,7 +18031,6 @@ var WeaveActionsManager = class {
18035
18031
  return this.activeAction;
18036
18032
  }
18037
18033
  triggerAction(actionName, params) {
18038
- const config = this.instance.getConfiguration();
18039
18034
  const actionsHandlers = this.instance.getActionsHandlers();
18040
18035
  if (!actionsHandlers[actionName]) {
18041
18036
  const msg = `Action handler with name [${actionName}] not registered`;
@@ -18045,7 +18040,6 @@ var WeaveActionsManager = class {
18045
18040
  if (typeof this.activeAction !== "undefined") this.cancelAction(this.activeAction);
18046
18041
  this.activeAction = actionName;
18047
18042
  const payload = actionsHandlers[actionName].trigger(this.cancelActionCallback(actionName), params);
18048
- config.callbacks?.onActiveActionChange?.(this.activeAction);
18049
18043
  this.instance.emitEvent("onActiveActionChange", this.activeAction);
18050
18044
  return payload;
18051
18045
  }
@@ -18080,7 +18074,6 @@ var WeaveActionsManager = class {
18080
18074
  return actionsHandlers[actionName].getProps?.();
18081
18075
  }
18082
18076
  cancelAction(actionName) {
18083
- const config = this.instance.getConfiguration();
18084
18077
  const actionsHandlers = this.instance.getActionsHandlers();
18085
18078
  if (!actionsHandlers[actionName]) {
18086
18079
  const msg = `Action handler with name [${actionName}] not registered`;
@@ -18089,7 +18082,6 @@ var WeaveActionsManager = class {
18089
18082
  }
18090
18083
  this.activeAction = void 0;
18091
18084
  actionsHandlers[actionName].cleanup?.();
18092
- config.callbacks?.onActiveActionChange?.(this.activeAction);
18093
18085
  this.instance.emitEvent("onActiveActionChange", this.activeAction);
18094
18086
  }
18095
18087
  cancelActionCallback(actionName) {
@@ -18313,7 +18305,6 @@ var Weave = class extends Emittery {
18313
18305
  this.setupManager.setupActions();
18314
18306
  this.moduleLogger.info("Instance started");
18315
18307
  this.status = WEAVE_INSTANCE_STATUS.RUNNING;
18316
- this.getConfiguration().callbacks?.onInstanceStatus?.(this.status);
18317
18308
  this.emitEvent("onInstanceStatus", this.status);
18318
18309
  });
18319
18310
  }
@@ -18328,15 +18319,14 @@ var Weave = class extends Emittery {
18328
18319
  }
18329
18320
  async start() {
18330
18321
  this.moduleLogger.info("Start instance");
18322
+ this.emitEvent("onRoomLoaded", false);
18331
18323
  this.status = WEAVE_INSTANCE_STATUS.STARTING;
18332
- this.getConfiguration().callbacks?.onInstanceStatus?.(this.status);
18333
18324
  this.emitEvent("onInstanceStatus", this.status);
18334
18325
  this.registerManager.registerNodesHandlers();
18335
18326
  this.registerManager.registerPlugins();
18336
18327
  this.registerManager.registerActionsHandlers();
18337
18328
  this.storeManager.registerStore(this.config.store);
18338
18329
  this.status = WEAVE_INSTANCE_STATUS.LOADING_FONTS;
18339
- this.getConfiguration().callbacks?.onInstanceStatus?.(this.status);
18340
18330
  this.emitEvent("onInstanceStatus", this.status);
18341
18331
  await this.fontsManager.loadFonts();
18342
18332
  this.setupManager.setupLog();
@@ -18345,6 +18335,17 @@ var Weave = class extends Emittery {
18345
18335
  store.setup();
18346
18336
  store.connect();
18347
18337
  }
18338
+ destroy() {
18339
+ this.moduleLogger.info(`Destroying the instance`);
18340
+ this.clearListeners();
18341
+ this.status = WEAVE_INSTANCE_STATUS.IDLE;
18342
+ this.emitEvent("onInstanceStatus", this.status);
18343
+ const store = this.storeManager.getStore();
18344
+ store.disconnect();
18345
+ const stage = this.getStage();
18346
+ if (stage) stage.destroy();
18347
+ this.moduleLogger.info(`Instance destroyed`);
18348
+ }
18348
18349
  getId() {
18349
18350
  return this.id;
18350
18351
  }
@@ -18459,13 +18460,11 @@ var Weave = class extends Emittery {
18459
18460
  update(newState) {
18460
18461
  this.getStore().setState(newState);
18461
18462
  this.renderer.render(() => {
18462
- this.config.callbacks?.onRender?.();
18463
18463
  this.emitEvent("onRender", {});
18464
18464
  });
18465
18465
  }
18466
18466
  render() {
18467
18467
  this.renderer.render(() => {
18468
- this.config.callbacks?.onRender?.();
18469
18468
  this.emitEvent("onRender", {});
18470
18469
  });
18471
18470
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inditextech/weave-sdk",
3
- "version": "0.14.3",
3
+ "version": "0.15.0",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Jesus Manuel Piñeiro Cid <jesusmpc@inditex.com>",
@@ -43,7 +43,7 @@
43
43
  "version:release": "npm version $RELEASE_VERSION -m \"[npm-scripts] prepare release $RELEASE_VERSION\" --tag-version-prefix \"\""
44
44
  },
45
45
  "dependencies": {
46
- "@inditextech/weave-types": "0.14.3",
46
+ "@inditextech/weave-types": "0.15.0",
47
47
  "@syncedstore/core": "0.6.0",
48
48
  "canvas": "3.1.0",
49
49
  "konva": "9.3.20",