@makeswift/runtime 0.5.1 → 0.5.2

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.es.js CHANGED
@@ -192,6 +192,43 @@ async function introspect(element, client, store) {
192
192
  pageIds: [...pageIds]
193
193
  };
194
194
  }
195
+ function is(x, y) {
196
+ if (x === y)
197
+ return x !== 0 || y !== 0 || 1 / x === 1 / y;
198
+ return x !== x && y !== y;
199
+ }
200
+ const { hasOwnProperty: hasOwnProperty$1 } = Object.prototype;
201
+ const shallowEqual = (a, b) => {
202
+ if (is(a, b))
203
+ return true;
204
+ if (typeof a !== "object" || a === null || typeof b !== "object" || b === null)
205
+ return false;
206
+ const keysA = Object.keys(a);
207
+ const keysB = Object.keys(b);
208
+ if (keysA.length !== keysB.length)
209
+ return false;
210
+ for (let i = 0; i < keysA.length; i += 1) {
211
+ if (!hasOwnProperty$1.call(b, keysA[i]) || !is(a[keysA[i]], b[keysA[i]]))
212
+ return false;
213
+ }
214
+ return true;
215
+ };
216
+ const { hasOwnProperty } = Object.prototype;
217
+ const deepEqual = (a, b) => {
218
+ if (shallowEqual(a, b))
219
+ return true;
220
+ if (typeof a !== "object" || a === null || typeof b !== "object" || b === null)
221
+ return false;
222
+ const keysA = Object.keys(a);
223
+ const keysB = Object.keys(b);
224
+ if (keysA.length !== keysB.length)
225
+ return false;
226
+ for (let i = 0; i < keysA.length; i += 1) {
227
+ if (!hasOwnProperty.call(b, keysA[i]) || !deepEqual(a[keysA[i]], b[keysA[i]]))
228
+ return false;
229
+ }
230
+ return true;
231
+ };
195
232
  function getInitialState(serializedState = []) {
196
233
  return new Map(serializedState.map(([resourceType, resources]) => [resourceType, new Map(resources)]));
197
234
  }
@@ -255,8 +292,12 @@ function reducer$1(state = getInitialState(), action) {
255
292
  });
256
293
  return new Map(state).set(APIResourceType.Typography, typographies);
257
294
  }
258
- case ActionTypes.CHANGE_API_RESOURCE:
295
+ case ActionTypes.CHANGE_API_RESOURCE: {
296
+ const existingApiResource = getAPIResource$1(state, action.payload.resource.__typename, action.payload.resource.id);
297
+ if (deepEqual(existingApiResource, action.payload.resource))
298
+ return state;
259
299
  return new Map(state).set(action.payload.resource.__typename, new Map(state.get(action.payload.resource.__typename)).set(action.payload.resource.id, action.payload.resource));
300
+ }
260
301
  case ActionTypes.EVICT_API_RESOURCE: {
261
302
  const [resourceType, resourceId] = action.payload.id.split(":");
262
303
  if (!(resourceType in APIResourceType))
@@ -662,43 +703,6 @@ function MakeswiftProvider({
662
703
  children
663
704
  });
664
705
  }
665
- function is(x, y) {
666
- if (x === y)
667
- return x !== 0 || y !== 0 || 1 / x === 1 / y;
668
- return x !== x && y !== y;
669
- }
670
- const { hasOwnProperty: hasOwnProperty$1 } = Object.prototype;
671
- const shallowEqual = (a, b) => {
672
- if (is(a, b))
673
- return true;
674
- if (typeof a !== "object" || a === null || typeof b !== "object" || b === null)
675
- return false;
676
- const keysA = Object.keys(a);
677
- const keysB = Object.keys(b);
678
- if (keysA.length !== keysB.length)
679
- return false;
680
- for (let i = 0; i < keysA.length; i += 1) {
681
- if (!hasOwnProperty$1.call(b, keysA[i]) || !is(a[keysA[i]], b[keysA[i]]))
682
- return false;
683
- }
684
- return true;
685
- };
686
- const { hasOwnProperty } = Object.prototype;
687
- const deepEqual = (a, b) => {
688
- if (shallowEqual(a, b))
689
- return true;
690
- if (typeof a !== "object" || a === null || typeof b !== "object" || b === null)
691
- return false;
692
- const keysA = Object.keys(a);
693
- const keysB = Object.keys(b);
694
- if (keysA.length !== keysB.length)
695
- return false;
696
- for (let i = 0; i < keysA.length; i += 1) {
697
- if (!hasOwnProperty.call(b, keysA[i]) || !deepEqual(a[keysA[i]], b[keysA[i]]))
698
- return false;
699
- }
700
- return true;
701
- };
702
706
  const SnippetLocation = {
703
707
  Body: "BODY",
704
708
  Head: "HEAD"
@@ -1050,7 +1054,7 @@ class Document$1 extends NextDocument {
1050
1054
  });
1051
1055
  }
1052
1056
  }
1053
- const version = "0.5.1";
1057
+ const version = "0.5.2";
1054
1058
  function isErrorWithMessage(error) {
1055
1059
  return typeof error === "object" && error !== null && "message" in error && typeof error.message === "string";
1056
1060
  }