@plasmicapp/loader-react 1.0.230 → 1.0.232

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.
@@ -1739,6 +1739,7 @@ function parseFetchComponentDataArgs() {
1739
1739
  }
1740
1740
 
1741
1741
  var SUBSTITUTED_COMPONENTS = {};
1742
+ var REGISTERED_CODE_COMPONENT_HELPERS = {};
1742
1743
  var SUBSTITUTED_GLOBAL_VARIANT_HOOKS = {};
1743
1744
  var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
1744
1745
  function InternalPlasmicComponentLoader(opts) {
@@ -1780,7 +1781,8 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
1780
1781
  '@plasmicapp/host': PlasmicHost,
1781
1782
  '@plasmicapp/loader-runtime-registry': {
1782
1783
  components: SUBSTITUTED_COMPONENTS,
1783
- globalVariantHooks: SUBSTITUTED_GLOBAL_VARIANT_HOOKS
1784
+ globalVariantHooks: SUBSTITUTED_GLOBAL_VARIANT_HOOKS,
1785
+ codeComponentHelpers: REGISTERED_CODE_COMPONENT_HELPERS
1784
1786
  }
1785
1787
  });
1786
1788
  }
@@ -1810,21 +1812,21 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
1810
1812
  }
1811
1813
  };
1812
1814
  _proto.substituteComponent = function substituteComponent(component, name) {
1815
+ this.internalSubstituteComponent(component, name, undefined);
1816
+ };
1817
+ _proto.internalSubstituteComponent = function internalSubstituteComponent(component, name, codeComponentHelpers) {
1813
1818
  if (!this.registry.isEmpty()) {
1814
1819
  console.warn('Calling PlasmicComponentLoader.registerSubstitution() after Plasmic component has rendered; starting over.');
1815
1820
  this.registry.clear();
1816
1821
  }
1817
1822
  this.subs.push({
1818
1823
  lookup: name,
1819
- component: component
1824
+ component: component,
1825
+ codeComponentHelpers: codeComponentHelpers
1820
1826
  });
1821
1827
  };
1822
1828
  _proto.registerComponent = function registerComponent$1(component, meta) {
1823
1829
  var _meta$states, _meta$importPath;
1824
- this.substituteComponent(component, {
1825
- name: meta.name,
1826
- isCode: true
1827
- });
1828
1830
  // making the component meta consistent between codegen and loader
1829
1831
  var stateHelpers = Object.fromEntries(Object.entries((_meta$states = meta.states) != null ? _meta$states : {}).filter(function (_ref) {
1830
1832
  var stateSpec = _ref[1];
@@ -1838,14 +1840,19 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
1838
1840
  onChangeArgsToValue: stateSpec.onChangeArgsToValue
1839
1841
  } : {})];
1840
1842
  }));
1843
+ var helpers = {
1844
+ states: stateHelpers
1845
+ };
1846
+ this.internalSubstituteComponent(component, {
1847
+ name: meta.name,
1848
+ isCode: true
1849
+ }, Object.keys(stateHelpers).length > 0 ? helpers : undefined);
1841
1850
  registerComponent(component, _extends({}, meta, {
1842
1851
  // Import path is not used as we will use component substitution
1843
1852
  importPath: (_meta$importPath = meta.importPath) != null ? _meta$importPath : ''
1844
1853
  }, Object.keys(stateHelpers).length > 0 ? {
1845
1854
  componentHelpers: {
1846
- helpers: {
1847
- states: stateHelpers
1848
- },
1855
+ helpers: helpers,
1849
1856
  importPath: '',
1850
1857
  importName: ''
1851
1858
  }
@@ -1970,6 +1977,9 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
1970
1977
  var metas = getCompMetas(_this3.getBundle().components, sub.lookup);
1971
1978
  metas.forEach(function (meta) {
1972
1979
  SUBSTITUTED_COMPONENTS[meta.id] = sub.component;
1980
+ if (sub.codeComponentHelpers) {
1981
+ REGISTERED_CODE_COMPONENT_HELPERS[meta.id] = sub.codeComponentHelpers;
1982
+ }
1973
1983
  });
1974
1984
  };
1975
1985
  // Once we have received data, we register components to