@plasmicapp/loader-react 1.0.99 → 1.0.103

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.
@@ -1133,9 +1133,9 @@ function matchesCompMeta(lookup, meta) {
1133
1133
  return isNameSpec(lookup) ? (lookup.name === meta.name || lookup.rawName === meta.displayName) && (lookup.isCode == null || lookup.isCode === meta.isCode) : lookup.path === meta.path;
1134
1134
  }
1135
1135
 
1136
- function getCompMeta(metas, lookup) {
1136
+ function getCompMetas(metas, lookup) {
1137
1137
  var full = toFullLookup(lookup);
1138
- return metas.find(function (meta) {
1138
+ return metas.filter(function (meta) {
1139
1139
  return matchesCompMeta(full, meta);
1140
1140
  });
1141
1141
  }
@@ -1149,6 +1149,11 @@ function getLookupSpecName(lookup) {
1149
1149
  }
1150
1150
  }
1151
1151
 
1152
+ function getFirstCompMeta(metas, lookup) {
1153
+ var filtered = getCompMetas(metas, lookup);
1154
+ return filtered.length === 0 ? undefined : filtered[0];
1155
+ }
1156
+
1152
1157
  var ComponentLookup = /*#__PURE__*/function () {
1153
1158
  function ComponentLookup(bundle, registry) {
1154
1159
  this.bundle = bundle;
@@ -1162,7 +1167,7 @@ var ComponentLookup = /*#__PURE__*/function () {
1162
1167
  opts = {};
1163
1168
  }
1164
1169
 
1165
- var compMeta = getCompMeta(this.bundle.components, spec);
1170
+ var compMeta = getFirstCompMeta(this.bundle.components, spec);
1166
1171
 
1167
1172
  if (!compMeta) {
1168
1173
  throw new Error("Component not found: " + spec);
@@ -1181,7 +1186,7 @@ var ComponentLookup = /*#__PURE__*/function () {
1181
1186
  };
1182
1187
 
1183
1188
  _proto.hasComponent = function hasComponent(spec) {
1184
- var compMeta = getCompMeta(this.bundle.components, spec);
1189
+ var compMeta = getFirstCompMeta(this.bundle.components, spec);
1185
1190
 
1186
1191
  if (compMeta) {
1187
1192
  return this.registry.hasModule(compMeta.entry);
@@ -1205,7 +1210,7 @@ var ComponentLookup = /*#__PURE__*/function () {
1205
1210
  };
1206
1211
 
1207
1212
  _proto.getGlobalContextsProvider = function getGlobalContextsProvider(spec) {
1208
- var compMeta = getCompMeta(this.bundle.components, spec);
1213
+ var compMeta = getFirstCompMeta(this.bundle.components, spec);
1209
1214
  var projectMeta = compMeta ? this.bundle.projects.find(function (x) {
1210
1215
  return x.id === compMeta.projectId;
1211
1216
  }) : undefined;
@@ -1940,19 +1945,24 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
1940
1945
  };
1941
1946
 
1942
1947
  _proto.refreshRegistry = function refreshRegistry() {
1948
+ var _this3 = this;
1949
+
1950
+ var _loop = function _loop() {
1951
+ var sub = _step.value;
1952
+ var metas = getCompMetas(_this3.bundle.components, sub.lookup);
1953
+ metas.forEach(function (meta) {
1954
+ return _this3.registry.register(meta.entry, {
1955
+ "default": sub.component
1956
+ });
1957
+ });
1958
+ };
1959
+
1943
1960
  // Once we have received data, we register components to
1944
1961
  // substitute. We had to wait for data to do this so
1945
1962
  // that we can look up the right module name to substitute
1946
1963
  // in component meta.
1947
1964
  for (var _iterator = _createForOfIteratorHelperLoose(this.subs), _step; !(_step = _iterator()).done;) {
1948
- var sub = _step.value;
1949
- var meta = getCompMeta(this.bundle.components, sub.lookup);
1950
-
1951
- if (meta) {
1952
- this.registry.register(meta.entry, {
1953
- "default": sub.component
1954
- });
1955
- }
1965
+ _loop();
1956
1966
  } // We also swap global variants' useXXXGlobalVariant() hook with
1957
1967
  // a fake one that just reads from the PlasmicRootContext. Because
1958
1968
  // global variant values are not supplied by the generated global variant
@@ -1986,22 +1996,24 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
1986
1996
  }();
1987
1997
 
1988
1998
  function _maybeGetCompMetas(metas, specs) {
1989
- var found = [];
1999
+ var found = new Set();
1990
2000
  var missing = [];
1991
2001
 
1992
2002
  for (var _iterator3 = _createForOfIteratorHelperLoose(specs), _step3; !(_step3 = _iterator3()).done;) {
1993
2003
  var spec = _step3.value;
1994
- var meta = getCompMeta(metas, spec);
2004
+ var filteredMetas = getCompMetas(metas, spec);
1995
2005
 
1996
- if (meta) {
1997
- found.push(meta);
2006
+ if (filteredMetas.length > 0) {
2007
+ filteredMetas.forEach(function (meta) {
2008
+ return found.add(meta);
2009
+ });
1998
2010
  } else {
1999
2011
  missing.push(spec);
2000
2012
  }
2001
2013
  }
2002
2014
 
2003
2015
  return {
2004
- found: found,
2016
+ found: Array.from(found.keys()),
2005
2017
  missing: missing
2006
2018
  };
2007
2019
  }