@linkdlab/funcnodes_react_flow 2.2.0 → 2.2.1-a0

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/index.d.ts CHANGED
@@ -2024,10 +2024,13 @@ declare class WorkerSyncManager extends AbstractWorkerHandler {
2024
2024
  _local_nodeupdates: Map<string, PartialSerializedNodeType>;
2025
2025
  _local_groupupdates: Map<string, Partial<NodeGroup>>;
2026
2026
  _groupupdatetimer: ReturnType<typeof setTimeout> | undefined;
2027
+ _after_next_sync: ((worker: FuncNodesWorker) => Promise<void>)[];
2027
2028
  constructor(context: WorkerSyncManagerContext);
2028
2029
  start(): void;
2029
2030
  stop(): void;
2030
2031
  stepwise_fullsync(): Promise<void>;
2032
+ add_after_next_sync(callback: (worker: FuncNodesWorker) => Promise<void>): void;
2033
+ remove_after_next_sync(callback: (worker: FuncNodesWorker) => Promise<void>): void;
2031
2034
  sync_lib(): Promise<void>;
2032
2035
  sync_external_worker(): Promise<void>;
2033
2036
  sync_funcnodes_plugins(): Promise<void>;
package/dist/index.es.js CHANGED
@@ -49007,7 +49007,7 @@ const aV = (e, t) => {
49007
49007
  }, sV = 2e3, lV = 2e3;
49008
49008
  class $Se extends Cp {
49009
49009
  constructor(t) {
49010
- super(t), this._local_nodeupdates = /* @__PURE__ */ new Map(), this._local_groupupdates = /* @__PURE__ */ new Map(), this.on_sync_complete = t.on_sync_complete || (async () => {
49010
+ super(t), this._local_nodeupdates = /* @__PURE__ */ new Map(), this._local_groupupdates = /* @__PURE__ */ new Map(), this._after_next_sync = [], this.on_sync_complete = t.on_sync_complete || (async () => {
49011
49011
  });
49012
49012
  }
49013
49013
  start() {
@@ -49021,7 +49021,19 @@ class $Se extends Cp {
49021
49021
  this._nodeupdatetimer && clearTimeout(this._nodeupdatetimer), this._groupupdatetimer && clearTimeout(this._groupupdatetimer);
49022
49022
  }
49023
49023
  async stepwise_fullsync() {
49024
- this.context.worker._zustand && this.context.worker.is_open && (await this.sync_lib(), await this.sync_external_worker(), await this.sync_funcnodes_plugins(), await this.sync_nodespace(), await this.sync_view_state(), await this.on_sync_complete(this.context.worker));
49024
+ if (!this.context.worker._zustand || !this.context.worker.is_open) return;
49025
+ await this.sync_lib(), await this.sync_external_worker(), await this.sync_funcnodes_plugins(), await this.sync_nodespace(), await this.sync_view_state(), await this.on_sync_complete(this.context.worker);
49026
+ const t = this._after_next_sync.splice(0);
49027
+ for (const n of t)
49028
+ await n(this.context.worker), this._after_next_sync.includes(n) && this._after_next_sync.splice(this._after_next_sync.indexOf(n), 1);
49029
+ }
49030
+ add_after_next_sync(t) {
49031
+ this._after_next_sync.push(t);
49032
+ }
49033
+ remove_after_next_sync(t) {
49034
+ this._after_next_sync = this._after_next_sync.filter(
49035
+ (n) => n !== t
49036
+ );
49025
49037
  }
49026
49038
  async sync_lib() {
49027
49039
  if (!this.context.worker._zustand || !this.context.worker.is_open) return;
@@ -98090,11 +98102,9 @@ const uoe = (e) => {
98090
98102
  } else
98091
98103
  o(u), u.options.debug = t.debug;
98092
98104
  }, [t?.id, t?.debug]), F.useEffect(() => {
98093
- if (!(!t || !r) && !(t.useWorkerManager || !t.worker_url))
98094
- if (t.logger?.debug("Worker effect running"), t.worker) {
98095
- t.worker.set_zustand(r);
98096
- return;
98097
- } else {
98105
+ if (!(!t || !r) && !(t.useWorkerManager || // a) a worker manager is used
98106
+ !t.worker_url && !t.worker))
98107
+ if (t.logger?.debug("Worker effect running"), !t.worker && t.worker_url) {
98098
98108
  t.logger?.debug("Creating WebSocket worker");
98099
98109
  const u = new KZ({
98100
98110
  url: t.worker_url,
@@ -98106,6 +98116,9 @@ const uoe = (e) => {
98106
98116
  ), () => {
98107
98117
  t.logger?.debug("Disconnecting worker"), u.disconnect(), n((f) => f && { ...f, worker: void 0 });
98108
98118
  };
98119
+ } else {
98120
+ t.worker?.set_zustand(r);
98121
+ return;
98109
98122
  }
98110
98123
  }, [
98111
98124
  t?.worker_url,
@@ -98117,21 +98130,23 @@ const uoe = (e) => {
98117
98130
  if (!t?.fnw_url || !t.worker) return;
98118
98131
  t.logger?.debug("Loading fnw_url data");
98119
98132
  let u = !1;
98120
- const f = t.worker.getSyncManager().on_sync_complete;
98133
+ const f = t.worker.getSyncManager();
98134
+ let p;
98121
98135
  return (async () => {
98122
98136
  try {
98123
- const m = await oae(t.fnw_url);
98124
- !u && t.worker && (t.worker.getSyncManager().on_sync_complete = async (g) => {
98125
- await g.update_from_export(m), t.worker.getSyncManager().on_sync_complete = f, f && f(g);
98126
- });
98127
- } catch (m) {
98128
- m instanceof Error ? t.logger?.error("Failed to load fnw_url:", m) : t.logger?.error(
98137
+ const g = await oae(t.fnw_url);
98138
+ if (u) return;
98139
+ p = async (v) => {
98140
+ u || await v.update_from_export(g);
98141
+ }, f.add_after_next_sync(p);
98142
+ } catch (g) {
98143
+ g instanceof Error ? t.logger?.error("Failed to load fnw_url:", g) : t.logger?.error(
98129
98144
  "Failed to load fnw_url:",
98130
- new Error(String(m))
98145
+ new Error(String(g))
98131
98146
  );
98132
98147
  }
98133
98148
  })(), () => {
98134
- u = !0, t.worker && (t.worker.getSyncManager().on_sync_complete = f);
98149
+ u = !0, p && f.remove_after_next_sync(p);
98135
98150
  };
98136
98151
  }, [t?.fnw_url, t?.worker]), F.useEffect(() => {
98137
98152
  if (!t || !r || !t.useWorkerManager) return;
@@ -98200,7 +98215,7 @@ const uoe = (e) => {
98200
98215
  );
98201
98216
  };
98202
98217
  window.FuncNodes = coe;
98203
- window.FuncNodes.version = "2.2.0";
98218
+ window.FuncNodes.version = "2.2.1a0";
98204
98219
  window.FuncNodes.utils = {
98205
98220
  logger: {
98206
98221
  ConsoleLogger: v5,