@plasmicapp/loader-react 1.0.161 → 1.0.164
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 +54 -1
- 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 +54 -1
- package/dist/loader-react.esm.js.map +1 -1
- package/dist/loader.d.ts +3 -1
- package/dist/utils.d.ts +17 -1
- package/package.json +5 -5
package/dist/loader-react.esm.js
CHANGED
|
@@ -1126,19 +1126,72 @@ function useIsMounted() {
|
|
|
1126
1126
|
}, []);
|
|
1127
1127
|
return isMounted;
|
|
1128
1128
|
}
|
|
1129
|
+
/**
|
|
1130
|
+
* Check if `lookup` resolves to `pagePath`. If it's a match, return an object
|
|
1131
|
+
* containing path params; otherwise, returns false.
|
|
1132
|
+
*
|
|
1133
|
+
* For example,
|
|
1134
|
+
* - `matchesPagePath("/hello/[name]", "/hello/world")` -> `{params: {name:
|
|
1135
|
+
* "world"}}`
|
|
1136
|
+
* - `matchesPagePath("/hello/[name]", "/")` -> `false`
|
|
1137
|
+
* - `matchesPagePath("/", "")` -> `{params: {}}`
|
|
1138
|
+
*/
|
|
1139
|
+
|
|
1140
|
+
function matchesPagePath(pagePath, lookup) {
|
|
1141
|
+
var _lookup$match;
|
|
1142
|
+
|
|
1143
|
+
// Remove trailing slashes from both `pagePath` and `lookup`.
|
|
1144
|
+
pagePath = pagePath.replace(/^\/*/, '').replace(/\/*$/, '');
|
|
1145
|
+
lookup = lookup.replace(/^\/*/, '').replace(/\/*$/, ''); // paramNames will contain a list of parameter names; e.g. if pagePath
|
|
1146
|
+
// is "/products/[slug]/[variant]" it will contain ["slug", "variant"].
|
|
1147
|
+
|
|
1148
|
+
var paramNames = (pagePath.match(/\[([^\]]*)\]/g) || []).map(function (group) {
|
|
1149
|
+
return group.slice(1, -1);
|
|
1150
|
+
});
|
|
1151
|
+
var pagePathRegExp = new RegExp('^' + pagePath.replace(/\[[^\]]*\]/g, '([^/]+)') + '$');
|
|
1152
|
+
var maybeVals = (_lookup$match = lookup.match(pagePathRegExp)) == null ? void 0 : _lookup$match.slice(1);
|
|
1153
|
+
|
|
1154
|
+
if (!maybeVals) {
|
|
1155
|
+
return false;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
var params = {};
|
|
1159
|
+
|
|
1160
|
+
for (var i = 0; i < paramNames.length; i++) {
|
|
1161
|
+
params[paramNames[i]] = maybeVals[i];
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
return {
|
|
1165
|
+
params: params
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1129
1168
|
|
|
1130
1169
|
function matchesCompMeta(lookup, meta) {
|
|
1131
1170
|
if (lookup.projectId && meta.projectId !== lookup.projectId) {
|
|
1132
1171
|
return false;
|
|
1133
1172
|
}
|
|
1134
1173
|
|
|
1135
|
-
return isNameSpec(lookup) ? (lookup.name === meta.name || lookup.rawName === meta.name || lookup.rawName === meta.displayName) && (lookup.isCode == null || lookup.isCode === meta.isCode) :
|
|
1174
|
+
return isNameSpec(lookup) ? (lookup.name === meta.name || lookup.rawName === meta.name || lookup.rawName === meta.displayName) && (lookup.isCode == null || lookup.isCode === meta.isCode) : !!(meta.path && matchesPagePath(meta.path, lookup.path));
|
|
1136
1175
|
}
|
|
1137
1176
|
|
|
1138
1177
|
function getCompMetas(metas, lookup) {
|
|
1139
1178
|
var full = toFullLookup(lookup);
|
|
1140
1179
|
return metas.filter(function (meta) {
|
|
1141
1180
|
return matchesCompMeta(full, meta);
|
|
1181
|
+
}).map(function (meta) {
|
|
1182
|
+
if (isNameSpec(full) || !meta.path) {
|
|
1183
|
+
return meta;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
var match = matchesPagePath(meta.path, full.path);
|
|
1187
|
+
|
|
1188
|
+
if (!match) {
|
|
1189
|
+
return meta;
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
return _extends({}, meta, {
|
|
1193
|
+
params: match.params
|
|
1194
|
+
});
|
|
1142
1195
|
});
|
|
1143
1196
|
}
|
|
1144
1197
|
function getLookupSpecName(lookup) {
|