@plasmicapp/loader-react 1.0.101 → 1.0.102
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/loader-react.cjs.development.js +30 -18
- package/dist/loader-react.cjs.development.js.map +1 -1
- package/dist/loader-react.cjs.production.min.js +1 -1
- package/dist/loader-react.cjs.production.min.js.map +1 -1
- package/dist/loader-react.esm.js +30 -18
- package/dist/loader-react.esm.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +2 -2
package/dist/loader-react.esm.js
CHANGED
|
@@ -1129,9 +1129,9 @@ function matchesCompMeta(lookup, meta) {
|
|
|
1129
1129
|
return isNameSpec(lookup) ? (lookup.name === meta.name || lookup.rawName === meta.displayName) && (lookup.isCode == null || lookup.isCode === meta.isCode) : lookup.path === meta.path;
|
|
1130
1130
|
}
|
|
1131
1131
|
|
|
1132
|
-
function
|
|
1132
|
+
function getCompMetas(metas, lookup) {
|
|
1133
1133
|
var full = toFullLookup(lookup);
|
|
1134
|
-
return metas.
|
|
1134
|
+
return metas.filter(function (meta) {
|
|
1135
1135
|
return matchesCompMeta(full, meta);
|
|
1136
1136
|
});
|
|
1137
1137
|
}
|
|
@@ -1145,6 +1145,11 @@ function getLookupSpecName(lookup) {
|
|
|
1145
1145
|
}
|
|
1146
1146
|
}
|
|
1147
1147
|
|
|
1148
|
+
function getFirstCompMeta(metas, lookup) {
|
|
1149
|
+
var filtered = getCompMetas(metas, lookup);
|
|
1150
|
+
return filtered.length === 0 ? undefined : filtered[0];
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1148
1153
|
var ComponentLookup = /*#__PURE__*/function () {
|
|
1149
1154
|
function ComponentLookup(bundle, registry) {
|
|
1150
1155
|
this.bundle = bundle;
|
|
@@ -1158,7 +1163,7 @@ var ComponentLookup = /*#__PURE__*/function () {
|
|
|
1158
1163
|
opts = {};
|
|
1159
1164
|
}
|
|
1160
1165
|
|
|
1161
|
-
var compMeta =
|
|
1166
|
+
var compMeta = getFirstCompMeta(this.bundle.components, spec);
|
|
1162
1167
|
|
|
1163
1168
|
if (!compMeta) {
|
|
1164
1169
|
throw new Error("Component not found: " + spec);
|
|
@@ -1177,7 +1182,7 @@ var ComponentLookup = /*#__PURE__*/function () {
|
|
|
1177
1182
|
};
|
|
1178
1183
|
|
|
1179
1184
|
_proto.hasComponent = function hasComponent(spec) {
|
|
1180
|
-
var compMeta =
|
|
1185
|
+
var compMeta = getFirstCompMeta(this.bundle.components, spec);
|
|
1181
1186
|
|
|
1182
1187
|
if (compMeta) {
|
|
1183
1188
|
return this.registry.hasModule(compMeta.entry);
|
|
@@ -1201,7 +1206,7 @@ var ComponentLookup = /*#__PURE__*/function () {
|
|
|
1201
1206
|
};
|
|
1202
1207
|
|
|
1203
1208
|
_proto.getGlobalContextsProvider = function getGlobalContextsProvider(spec) {
|
|
1204
|
-
var compMeta =
|
|
1209
|
+
var compMeta = getFirstCompMeta(this.bundle.components, spec);
|
|
1205
1210
|
var projectMeta = compMeta ? this.bundle.projects.find(function (x) {
|
|
1206
1211
|
return x.id === compMeta.projectId;
|
|
1207
1212
|
}) : undefined;
|
|
@@ -1936,19 +1941,24 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1936
1941
|
};
|
|
1937
1942
|
|
|
1938
1943
|
_proto.refreshRegistry = function refreshRegistry() {
|
|
1944
|
+
var _this3 = this;
|
|
1945
|
+
|
|
1946
|
+
var _loop = function _loop() {
|
|
1947
|
+
var sub = _step.value;
|
|
1948
|
+
var metas = getCompMetas(_this3.bundle.components, sub.lookup);
|
|
1949
|
+
metas.forEach(function (meta) {
|
|
1950
|
+
return _this3.registry.register(meta.entry, {
|
|
1951
|
+
"default": sub.component
|
|
1952
|
+
});
|
|
1953
|
+
});
|
|
1954
|
+
};
|
|
1955
|
+
|
|
1939
1956
|
// Once we have received data, we register components to
|
|
1940
1957
|
// substitute. We had to wait for data to do this so
|
|
1941
1958
|
// that we can look up the right module name to substitute
|
|
1942
1959
|
// in component meta.
|
|
1943
1960
|
for (var _iterator = _createForOfIteratorHelperLoose(this.subs), _step; !(_step = _iterator()).done;) {
|
|
1944
|
-
|
|
1945
|
-
var meta = getCompMeta(this.bundle.components, sub.lookup);
|
|
1946
|
-
|
|
1947
|
-
if (meta) {
|
|
1948
|
-
this.registry.register(meta.entry, {
|
|
1949
|
-
"default": sub.component
|
|
1950
|
-
});
|
|
1951
|
-
}
|
|
1961
|
+
_loop();
|
|
1952
1962
|
} // We also swap global variants' useXXXGlobalVariant() hook with
|
|
1953
1963
|
// a fake one that just reads from the PlasmicRootContext. Because
|
|
1954
1964
|
// global variant values are not supplied by the generated global variant
|
|
@@ -1982,22 +1992,24 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1982
1992
|
}();
|
|
1983
1993
|
|
|
1984
1994
|
function _maybeGetCompMetas(metas, specs) {
|
|
1985
|
-
var found =
|
|
1995
|
+
var found = new Set();
|
|
1986
1996
|
var missing = [];
|
|
1987
1997
|
|
|
1988
1998
|
for (var _iterator3 = _createForOfIteratorHelperLoose(specs), _step3; !(_step3 = _iterator3()).done;) {
|
|
1989
1999
|
var spec = _step3.value;
|
|
1990
|
-
var
|
|
2000
|
+
var filteredMetas = getCompMetas(metas, spec);
|
|
1991
2001
|
|
|
1992
|
-
if (
|
|
1993
|
-
|
|
2002
|
+
if (filteredMetas.length > 0) {
|
|
2003
|
+
filteredMetas.forEach(function (meta) {
|
|
2004
|
+
return found.add(meta);
|
|
2005
|
+
});
|
|
1994
2006
|
} else {
|
|
1995
2007
|
missing.push(spec);
|
|
1996
2008
|
}
|
|
1997
2009
|
}
|
|
1998
2010
|
|
|
1999
2011
|
return {
|
|
2000
|
-
found: found,
|
|
2012
|
+
found: Array.from(found.keys()),
|
|
2001
2013
|
missing: missing
|
|
2002
2014
|
};
|
|
2003
2015
|
}
|