@plasmicapp/loader-react 1.0.230 → 1.0.231

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