@micromag/core 0.4.85 → 0.4.86

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/es/contexts.d.ts CHANGED
@@ -195,6 +195,7 @@ declare class ComponentsManager extends EventEmitter {
195
195
 
196
196
  declare class DefinitionsManager<T extends Definition = Definition> extends EventEmitter {
197
197
  definitions: T[];
198
+ components: Record<string, Component> | null;
198
199
  constructor(definitions?: T[]);
199
200
  addDefinition(definition: T | T[]): this;
200
201
  addDefinitions(definitions: T[]): this;
package/es/contexts.js CHANGED
@@ -552,7 +552,7 @@ function _temp$3(t0) {
552
552
  const ScreensContext = /*#__PURE__*/createContext(null);
553
553
  const useScreensManager = () => use(ScreensContext);
554
554
  function ScreensProvider(t0) {
555
- const $ = c(17);
555
+ const $ = c(14);
556
556
  const {
557
557
  screens: t1,
558
558
  namespaces: t2,
@@ -595,58 +595,39 @@ function ScreensProvider(t0) {
595
595
  const [finalManager] = useState(t5);
596
596
  let t6;
597
597
  if ($[6] !== finalManager) {
598
- t6 = () => finalManager.getComponents();
598
+ t6 = finalManager.getComponents();
599
599
  $[6] = finalManager;
600
600
  $[7] = t6;
601
601
  } else {
602
602
  t6 = $[7];
603
603
  }
604
- const [components, setComponents] = useState(t6);
604
+ const components = t6;
605
605
  let t7;
606
- let t8;
607
- if ($[8] !== finalManager) {
608
- t7 = () => {
609
- const onChange = () => setComponents(finalManager.getComponents());
610
- finalManager.on("change", onChange);
611
- return () => {
612
- finalManager.off("change", onChange);
613
- };
614
- };
615
- t8 = [finalManager, setComponents];
616
- $[8] = finalManager;
617
- $[9] = t7;
618
- $[10] = t8;
619
- } else {
620
- t7 = $[9];
621
- t8 = $[10];
622
- }
623
- useEffect(t7, t8);
624
- let t9;
625
- if ($[11] !== children || $[12] !== components) {
626
- t9 = /*#__PURE__*/jsx(ComponentsProvider, {
606
+ if ($[8] !== children || $[9] !== components) {
607
+ t7 = /*#__PURE__*/jsx(ComponentsProvider, {
627
608
  namespace: SCREENS_NAMESPACE,
628
609
  components: components,
629
610
  children: children
630
611
  });
631
- $[11] = children;
632
- $[12] = components;
633
- $[13] = t9;
612
+ $[8] = children;
613
+ $[9] = components;
614
+ $[10] = t7;
634
615
  } else {
635
- t9 = $[13];
616
+ t7 = $[10];
636
617
  }
637
- let t10;
638
- if ($[14] !== finalManager || $[15] !== t9) {
639
- t10 = /*#__PURE__*/jsx(ScreensContext, {
618
+ let t8;
619
+ if ($[11] !== finalManager || $[12] !== t7) {
620
+ t8 = /*#__PURE__*/jsx(ScreensContext, {
640
621
  value: finalManager,
641
- children: t9
622
+ children: t7
642
623
  });
643
- $[14] = finalManager;
644
- $[15] = t9;
645
- $[16] = t10;
624
+ $[11] = finalManager;
625
+ $[12] = t7;
626
+ $[13] = t8;
646
627
  } else {
647
- t10 = $[16];
628
+ t8 = $[13];
648
629
  }
649
- return t10;
630
+ return t8;
650
631
  }
651
632
 
652
633
  const StoryContext = /*#__PURE__*/createContext(null);
package/es/index.d.ts CHANGED
@@ -492,6 +492,7 @@ declare class ComponentsManager extends EventEmitter {
492
492
 
493
493
  declare class DefinitionsManager<T extends Definition = Definition> extends EventEmitter {
494
494
  definitions: T[];
495
+ components: Record<string, Component> | null;
495
496
  constructor(definitions?: T[]);
496
497
  addDefinition(definition: T | T[]): this;
497
498
  addDefinitions(definitions: T[]): this;
package/es/index.js CHANGED
@@ -236,6 +236,7 @@ class DefinitionsManager extends EventEmitter {
236
236
  constructor(definitions = []) {
237
237
  super();
238
238
  this.definitions = definitions || [];
239
+ this.components = null;
239
240
  }
240
241
  addDefinition(definition) {
241
242
  this.addDefinitions(isArray(definition) ? definition : [definition]);
@@ -243,6 +244,7 @@ class DefinitionsManager extends EventEmitter {
243
244
  }
244
245
  addDefinitions(definitions) {
245
246
  this.definitions = uniqBy([...definitions, ...this.definitions], it => it.id);
247
+ this.components = null;
246
248
  this.emit('change');
247
249
  return this;
248
250
  }
@@ -273,13 +275,16 @@ class DefinitionsManager extends EventEmitter {
273
275
  return component;
274
276
  }
275
277
  getComponents() {
276
- return this.definitions.reduce((allComponents, {
277
- id,
278
- component = null
279
- }) => component !== null ? {
280
- ...allComponents,
281
- [id]: component
282
- } : allComponents, {});
278
+ if (this.components === null) {
279
+ this.components = this.definitions.reduce((allComponents, {
280
+ id,
281
+ component = null
282
+ }) => component !== null ? {
283
+ ...allComponents,
284
+ [id]: component
285
+ } : allComponents, {});
286
+ }
287
+ return this.components;
283
288
  }
284
289
  }
285
290
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/core",
3
- "version": "0.4.85",
3
+ "version": "0.4.86",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -157,6 +157,6 @@
157
157
  "access": "public",
158
158
  "registry": "https://registry.npmjs.org/"
159
159
  },
160
- "gitHead": "21705788dfb96bc235356c11501fae2365d02a58",
160
+ "gitHead": "24785d81e840b81c58dc101ba7305d088e61f0e0",
161
161
  "types": "es/index.d.ts"
162
162
  }