@koordinates/xstate-tree 5.1.0-next.13 → 5.1.0-next.15

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/lib/utils.js CHANGED
@@ -121,9 +121,12 @@ function mergeMeta(meta) {
121
121
  }, {});
122
122
  }
123
123
  exports.mergeMeta = mergeMeta;
124
- function getCircularReplacer() {
124
+ function getCircularReplacer(stripKeys) {
125
125
  const seen = new WeakSet();
126
126
  return (key, value) => {
127
+ if (stripKeys.includes(key)) {
128
+ return;
129
+ }
127
130
  if (typeof value === "object" && value !== null) {
128
131
  if (seen.has(value)) {
129
132
  // Circular reference found, discard key
@@ -135,7 +138,7 @@ function getCircularReplacer() {
135
138
  return value;
136
139
  };
137
140
  }
138
- function toJSON(value) {
139
- return JSON.parse(JSON.stringify(value, getCircularReplacer()));
141
+ function toJSON(value, stripKeys = []) {
142
+ return JSON.parse(JSON.stringify(value, getCircularReplacer(stripKeys)));
140
143
  }
141
144
  exports.toJSON = toJSON;
@@ -712,7 +712,7 @@ export declare type View<TActionsOutput, TSelectorsOutput, TSlots extends readon
712
712
  * @param view - the React view you want to invoke in an xstate machine
713
713
  * @returns The view wrapped into an xstate-tree machine, ready to be invoked by other xstate machines or used with `buildRootComponent`
714
714
  */
715
- export declare function viewToMachine(view: () => JSX.Element): AnyXstateTreeMachine;
715
+ export declare function viewToMachine(view: (args?: any) => JSX.Element): AnyXstateTreeMachine;
716
716
 
717
717
  declare type WithParentPath<TCurrent extends string, TParentPath extends string> = `${TParentPath extends "" ? "" : `${TParentPath}.`}${TCurrent}`;
718
718
 
package/lib/xstateTree.js CHANGED
@@ -228,11 +228,12 @@ function buildRootComponent(options) {
228
228
  break;
229
229
  case "@xstate.snapshot":
230
230
  const lastSnapshot = lastSnapshotsRef.current[event.actorRef.sessionId];
231
+ const strippedKeys = ["_subscription"];
231
232
  if (!lastSnapshot) {
232
- console.log(`[xstate-tree] initial snapshot: ${event.actorRef.id}`, (0, utils_1.toJSON)(event.snapshot));
233
+ console.log(`[xstate-tree] initial snapshot: ${event.actorRef.id}`, (0, utils_1.toJSON)(event.snapshot, strippedKeys));
233
234
  }
234
235
  else {
235
- console.log(`[xstate-tree] snapshot: ${event.actorRef.id} transitioning to`, (0, utils_1.toJSON)(event.snapshot), "from", (0, utils_1.toJSON)(lastSnapshot));
236
+ console.log(`[xstate-tree] snapshot: ${event.actorRef.id} transitioning to`, (0, utils_1.toJSON)(event.snapshot, strippedKeys), "from", (0, utils_1.toJSON)(lastSnapshot, strippedKeys));
236
237
  }
237
238
  lastSnapshotsRef.current[event.actorRef.sessionId] = event.snapshot;
238
239
  break;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@koordinates/xstate-tree",
3
3
  "main": "lib/index.js",
4
4
  "types": "lib/xstate-tree.d.ts",
5
- "version": "5.1.0-next.13",
5
+ "version": "5.1.0-next.15",
6
6
  "license": "MIT",
7
7
  "description": "Build UIs with Actors using xstate and React",
8
8
  "keywords": [