@plasmicapp/loader-react 1.0.205 → 1.0.206
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/index-react-server.d.ts +5 -0
- package/dist/index-shared.d.ts +6 -0
- package/dist/index.d.ts +5 -4
- package/dist/loader-react-server.d.ts +72 -0
- package/dist/loader-react.cjs.development.js +484 -426
- 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 +484 -426
- package/dist/loader-react.esm.js.map +1 -1
- package/dist/loader.d.ts +8 -51
- package/dist/utils.d.ts +1 -0
- package/dist-react-server/PlasmicComponent.d.ts +19 -0
- package/dist-react-server/PlasmicRootProvider.d.ts +92 -0
- package/dist-react-server/bundles.d.ts +7 -0
- package/dist-react-server/component-lookup.d.ts +21 -0
- package/dist-react-server/global-variants.d.ts +13 -0
- package/dist-react-server/index-react-server.d.ts +5 -0
- package/dist-react-server/index-shared.d.ts +6 -0
- package/dist-react-server/index.d.ts +12 -0
- package/dist-react-server/index.js +8 -0
- package/dist-react-server/loader-react-server.d.ts +72 -0
- package/dist-react-server/loader-react.cjs.development.js +1315 -0
- package/dist-react-server/loader-react.cjs.development.js.map +1 -0
- package/dist-react-server/loader-react.cjs.production.min.js +2 -0
- package/dist-react-server/loader-react.cjs.production.min.js.map +1 -0
- package/dist-react-server/loader-react.esm.js +1306 -0
- package/dist-react-server/loader-react.esm.js.map +1 -0
- package/dist-react-server/loader.d.ts +168 -0
- package/dist-react-server/prepass.d.ts +43 -0
- package/dist-react-server/render.d.ts +27 -0
- package/dist-react-server/usePlasmicComponent.d.ts +15 -0
- package/dist-react-server/utils.d.ts +30 -0
- package/dist-react-server/variation.d.ts +9 -0
- package/index.d.ts +1 -0
- package/package.json +46 -9
- package/react-server-conditional.d.ts +4 -0
- package/react-server.d.ts +1 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
'use strict';
|
|
1
|
+
'use client';'use strict';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
6
|
|
|
7
|
+
var PlasmicDataSourcesContext = require('@plasmicapp/data-sources-context');
|
|
7
8
|
var PlasmicHost = require('@plasmicapp/host');
|
|
8
|
-
var PlasmicQuery = require('@plasmicapp/query');
|
|
9
9
|
var loaderCore = require('@plasmicapp/loader-core');
|
|
10
|
-
var PlasmicDataSourcesContext = require('@plasmicapp/data-sources-context');
|
|
11
10
|
var loaderSplits = require('@plasmicapp/loader-splits');
|
|
11
|
+
var PlasmicQuery = require('@plasmicapp/query');
|
|
12
12
|
var React = require('react');
|
|
13
13
|
var React__default = _interopDefault(React);
|
|
14
14
|
var ReactDOM = _interopDefault(require('react-dom'));
|
|
@@ -119,158 +119,6 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
119
119
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
function getUsedComps(allComponents, entryCompIds) {
|
|
123
|
-
var q = [].concat(entryCompIds);
|
|
124
|
-
var seenIds = new Set(entryCompIds);
|
|
125
|
-
var componentMetaById = new Map(allComponents.map(function (meta) {
|
|
126
|
-
return [meta.id, meta];
|
|
127
|
-
}));
|
|
128
|
-
var usedComps = [];
|
|
129
|
-
while (q.length > 0) {
|
|
130
|
-
var _q$splice = q.splice(0, 1),
|
|
131
|
-
id = _q$splice[0];
|
|
132
|
-
var meta = componentMetaById.get(id);
|
|
133
|
-
if (!meta) {
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
usedComps.push(meta);
|
|
137
|
-
meta.usedComponents.forEach(function (usedCompId) {
|
|
138
|
-
if (!seenIds.has(usedCompId)) {
|
|
139
|
-
seenIds.add(usedCompId);
|
|
140
|
-
q.push(usedCompId);
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
return usedComps;
|
|
145
|
-
}
|
|
146
|
-
function prepComponentData(bundle, compMetas, opts) {
|
|
147
|
-
if (compMetas.length === 0) {
|
|
148
|
-
return {
|
|
149
|
-
entryCompMetas: bundle.components,
|
|
150
|
-
bundle: bundle,
|
|
151
|
-
remoteFontUrls: []
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
var usedComps = getUsedComps(bundle.components, compMetas.map(function (compMeta) {
|
|
155
|
-
return compMeta.id;
|
|
156
|
-
}));
|
|
157
|
-
var compPaths = usedComps.map(function (compMeta) {
|
|
158
|
-
return compMeta.entry;
|
|
159
|
-
});
|
|
160
|
-
var subBundle = loaderCore.getBundleSubset(bundle, ['entrypoint.css'].concat(compPaths, ['root-provider.js'], bundle.projects.map(function (x) {
|
|
161
|
-
return x.globalContextsProviderFileName;
|
|
162
|
-
}).filter(function (x) {
|
|
163
|
-
return !!x;
|
|
164
|
-
}), bundle.components.filter(function (c) {
|
|
165
|
-
return c.isGlobalContextProvider;
|
|
166
|
-
}).map(function (c) {
|
|
167
|
-
return c.entry;
|
|
168
|
-
}), bundle.globalGroups.map(function (g) {
|
|
169
|
-
return g.contextFile;
|
|
170
|
-
})), opts);
|
|
171
|
-
var remoteFontUrls = [];
|
|
172
|
-
subBundle.projects.forEach(function (p) {
|
|
173
|
-
return remoteFontUrls.push.apply(remoteFontUrls, p.remoteFonts.map(function (f) {
|
|
174
|
-
return f.url;
|
|
175
|
-
}));
|
|
176
|
-
});
|
|
177
|
-
return {
|
|
178
|
-
entryCompMetas: compMetas,
|
|
179
|
-
bundle: subBundle,
|
|
180
|
-
remoteFontUrls: remoteFontUrls
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
function mergeBundles(target, from) {
|
|
184
|
-
var _from$activeSplits$fi;
|
|
185
|
-
var existingCompIds = new Set(target.components.map(function (c) {
|
|
186
|
-
return c.id;
|
|
187
|
-
}));
|
|
188
|
-
var newCompMetas = from.components.filter(function (m) {
|
|
189
|
-
return !existingCompIds.has(m.id);
|
|
190
|
-
});
|
|
191
|
-
if (newCompMetas.length > 0) {
|
|
192
|
-
target = _extends({}, target, {
|
|
193
|
-
components: [].concat(target.components, newCompMetas)
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
var existingProjects = new Set(target.projects.map(function (p) {
|
|
197
|
-
return p.id;
|
|
198
|
-
}));
|
|
199
|
-
var newProjects = from.projects.filter(function (p) {
|
|
200
|
-
return !existingProjects.has(p.id);
|
|
201
|
-
});
|
|
202
|
-
if (newProjects.length > 0) {
|
|
203
|
-
target = _extends({}, target, {
|
|
204
|
-
projects: [].concat(target.projects, newProjects)
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
var existingModules = {
|
|
208
|
-
browser: new Set(target.modules.browser.map(function (m) {
|
|
209
|
-
return m.fileName;
|
|
210
|
-
})),
|
|
211
|
-
server: new Set(target.modules.server.map(function (m) {
|
|
212
|
-
return m.fileName;
|
|
213
|
-
}))
|
|
214
|
-
};
|
|
215
|
-
var newModules = {
|
|
216
|
-
browser: from.modules.browser.filter(function (m) {
|
|
217
|
-
return !existingModules.browser.has(m.fileName);
|
|
218
|
-
}),
|
|
219
|
-
server: from.modules.server.filter(function (m) {
|
|
220
|
-
return !existingModules.server.has(m.fileName);
|
|
221
|
-
})
|
|
222
|
-
};
|
|
223
|
-
if (newModules.browser.length > 0 || newModules.server.length > 0) {
|
|
224
|
-
target = _extends({}, target, {
|
|
225
|
-
modules: {
|
|
226
|
-
browser: [].concat(target.modules.browser, newModules.browser),
|
|
227
|
-
server: [].concat(target.modules.server, newModules.server)
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
var existingGlobalIds = new Set(target.globalGroups.map(function (g) {
|
|
232
|
-
return g.id;
|
|
233
|
-
}));
|
|
234
|
-
var newGlobals = from.globalGroups.filter(function (g) {
|
|
235
|
-
return !existingGlobalIds.has(g.id);
|
|
236
|
-
});
|
|
237
|
-
if (newGlobals.length > 0) {
|
|
238
|
-
target = _extends({}, target, {
|
|
239
|
-
globalGroups: [].concat(target.globalGroups, newGlobals)
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
var existingExternals = new Set(target.external);
|
|
243
|
-
var newExternals = target.external.filter(function (x) {
|
|
244
|
-
return !existingExternals.has(x);
|
|
245
|
-
});
|
|
246
|
-
if (newExternals.length > 0) {
|
|
247
|
-
target = _extends({}, target, {
|
|
248
|
-
external: [].concat(target.external, newExternals)
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
var existingSplitIds = new Set(target.activeSplits.map(function (s) {
|
|
252
|
-
return s.id;
|
|
253
|
-
}));
|
|
254
|
-
var newSplits = (_from$activeSplits$fi = from.activeSplits.filter(function (s) {
|
|
255
|
-
return !existingSplitIds.has(s.id);
|
|
256
|
-
})) != null ? _from$activeSplits$fi : [];
|
|
257
|
-
if (newSplits.length > 0) {
|
|
258
|
-
target = _extends({}, target, {
|
|
259
|
-
activeSplits: [].concat(target.activeSplits, newSplits)
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
return target;
|
|
263
|
-
}
|
|
264
|
-
var convertBundlesToComponentRenderData = function convertBundlesToComponentRenderData(bundles, compMetas) {
|
|
265
|
-
if (bundles.length === 0) {
|
|
266
|
-
return null;
|
|
267
|
-
}
|
|
268
|
-
var mergedBundles = bundles.reduce(function (prev, cur) {
|
|
269
|
-
return mergeBundles(prev, cur);
|
|
270
|
-
});
|
|
271
|
-
return prepComponentData(mergedBundles, compMetas);
|
|
272
|
-
};
|
|
273
|
-
|
|
274
122
|
function createCommonjsModule(fn, module) {
|
|
275
123
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
276
124
|
}
|
|
@@ -929,6 +777,7 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
929
777
|
}
|
|
930
778
|
});
|
|
931
779
|
|
|
780
|
+
var isBrowser = typeof window !== 'undefined';
|
|
932
781
|
function useForceUpdate() {
|
|
933
782
|
var _React$useState = React.useState(0),
|
|
934
783
|
setTick = _React$useState[1];
|
|
@@ -1412,125 +1261,161 @@ function createUseGlobalVariant(name, projectId) {
|
|
|
1412
1261
|
};
|
|
1413
1262
|
}
|
|
1414
1263
|
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
var
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
projects: [],
|
|
1435
|
-
activeSplits: []
|
|
1436
|
-
};
|
|
1437
|
-
this.substitutedComponents = {};
|
|
1438
|
-
this.substitutedGlobalVariantHooks = {};
|
|
1439
|
-
this.registry = loaderCore.Registry.getInstance();
|
|
1440
|
-
this.fetcher = new loaderCore.PlasmicModulesFetcher(opts);
|
|
1441
|
-
this.tracker = new loaderCore.PlasmicTracker({
|
|
1442
|
-
projectIds: opts.projects.map(function (p) {
|
|
1443
|
-
return p.id;
|
|
1444
|
-
}),
|
|
1445
|
-
platform: opts.platform,
|
|
1446
|
-
preview: opts.preview
|
|
1447
|
-
});
|
|
1448
|
-
this.registerModules({
|
|
1449
|
-
react: React__default,
|
|
1450
|
-
'react-dom': ReactDOM,
|
|
1451
|
-
'react/jsx-runtime': jsxRuntime,
|
|
1452
|
-
'react/jsx-dev-runtime': jsxDevRuntime,
|
|
1453
|
-
// Also inject @plasmicapp/query and @plasmicapp/host to use the
|
|
1454
|
-
// same contexts here and in loader-downloaded code.
|
|
1455
|
-
'@plasmicapp/query': PlasmicQuery,
|
|
1456
|
-
'@plasmicapp/data-sources-context': PlasmicDataSourcesContext,
|
|
1457
|
-
'@plasmicapp/host': PlasmicHost,
|
|
1458
|
-
'@plasmicapp/loader-runtime-registry': {
|
|
1459
|
-
components: this.substitutedComponents,
|
|
1460
|
-
globalVariantHooks: this.substitutedGlobalVariantHooks
|
|
1264
|
+
function getUsedComps(allComponents, entryCompIds) {
|
|
1265
|
+
var q = [].concat(entryCompIds);
|
|
1266
|
+
var seenIds = new Set(entryCompIds);
|
|
1267
|
+
var componentMetaById = new Map(allComponents.map(function (meta) {
|
|
1268
|
+
return [meta.id, meta];
|
|
1269
|
+
}));
|
|
1270
|
+
var usedComps = [];
|
|
1271
|
+
while (q.length > 0) {
|
|
1272
|
+
var _q$splice = q.splice(0, 1),
|
|
1273
|
+
id = _q$splice[0];
|
|
1274
|
+
var meta = componentMetaById.get(id);
|
|
1275
|
+
if (!meta) {
|
|
1276
|
+
continue;
|
|
1277
|
+
}
|
|
1278
|
+
usedComps.push(meta);
|
|
1279
|
+
meta.usedComponents.forEach(function (usedCompId) {
|
|
1280
|
+
if (!seenIds.has(usedCompId)) {
|
|
1281
|
+
seenIds.add(usedCompId);
|
|
1282
|
+
q.push(usedCompId);
|
|
1461
1283
|
}
|
|
1462
1284
|
});
|
|
1463
1285
|
}
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
};
|
|
1496
|
-
_proto.registerComponent = function registerComponent(component, meta) {
|
|
1497
|
-
var _meta$importPath;
|
|
1498
|
-
this.substituteComponent(component, {
|
|
1499
|
-
name: meta.name,
|
|
1500
|
-
isCode: true
|
|
1501
|
-
});
|
|
1502
|
-
// Import path is not used as we will use component substitution
|
|
1503
|
-
PlasmicHost.registerComponent(component, _extends({}, meta, {
|
|
1504
|
-
importPath: (_meta$importPath = meta.importPath) != null ? _meta$importPath : ''
|
|
1286
|
+
return usedComps;
|
|
1287
|
+
}
|
|
1288
|
+
function prepComponentData(bundle, compMetas, opts) {
|
|
1289
|
+
if (compMetas.length === 0) {
|
|
1290
|
+
return {
|
|
1291
|
+
entryCompMetas: bundle.components,
|
|
1292
|
+
bundle: bundle,
|
|
1293
|
+
remoteFontUrls: []
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
var usedComps = getUsedComps(bundle.components, compMetas.map(function (compMeta) {
|
|
1297
|
+
return compMeta.id;
|
|
1298
|
+
}));
|
|
1299
|
+
var compPaths = usedComps.map(function (compMeta) {
|
|
1300
|
+
return compMeta.entry;
|
|
1301
|
+
});
|
|
1302
|
+
var subBundle = loaderCore.getBundleSubset(bundle, ['entrypoint.css'].concat(compPaths, ['root-provider.js'], bundle.projects.map(function (x) {
|
|
1303
|
+
return x.globalContextsProviderFileName;
|
|
1304
|
+
}).filter(function (x) {
|
|
1305
|
+
return !!x;
|
|
1306
|
+
}), bundle.components.filter(function (c) {
|
|
1307
|
+
return c.isGlobalContextProvider;
|
|
1308
|
+
}).map(function (c) {
|
|
1309
|
+
return c.entry;
|
|
1310
|
+
}), bundle.globalGroups.map(function (g) {
|
|
1311
|
+
return g.contextFile;
|
|
1312
|
+
})), opts);
|
|
1313
|
+
var remoteFontUrls = [];
|
|
1314
|
+
subBundle.projects.forEach(function (p) {
|
|
1315
|
+
return remoteFontUrls.push.apply(remoteFontUrls, p.remoteFonts.map(function (f) {
|
|
1316
|
+
return f.url;
|
|
1505
1317
|
}));
|
|
1318
|
+
});
|
|
1319
|
+
return {
|
|
1320
|
+
entryCompMetas: compMetas,
|
|
1321
|
+
bundle: subBundle,
|
|
1322
|
+
remoteFontUrls: remoteFontUrls
|
|
1506
1323
|
};
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1324
|
+
}
|
|
1325
|
+
function mergeBundles(target, from) {
|
|
1326
|
+
var _from$activeSplits$fi;
|
|
1327
|
+
var existingCompIds = new Set(target.components.map(function (c) {
|
|
1328
|
+
return c.id;
|
|
1329
|
+
}));
|
|
1330
|
+
var newCompMetas = from.components.filter(function (m) {
|
|
1331
|
+
return !existingCompIds.has(m.id);
|
|
1332
|
+
});
|
|
1333
|
+
if (newCompMetas.length > 0) {
|
|
1334
|
+
target = _extends({}, target, {
|
|
1335
|
+
components: [].concat(target.components, newCompMetas)
|
|
1512
1336
|
});
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1337
|
+
}
|
|
1338
|
+
var existingProjects = new Set(target.projects.map(function (p) {
|
|
1339
|
+
return p.id;
|
|
1340
|
+
}));
|
|
1341
|
+
var newProjects = from.projects.filter(function (p) {
|
|
1342
|
+
return !existingProjects.has(p.id);
|
|
1343
|
+
});
|
|
1344
|
+
if (newProjects.length > 0) {
|
|
1345
|
+
target = _extends({}, target, {
|
|
1346
|
+
projects: [].concat(target.projects, newProjects)
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1349
|
+
var existingModules = {
|
|
1350
|
+
browser: new Set(target.modules.browser.map(function (m) {
|
|
1351
|
+
return m.fileName;
|
|
1352
|
+
})),
|
|
1353
|
+
server: new Set(target.modules.server.map(function (m) {
|
|
1354
|
+
return m.fileName;
|
|
1355
|
+
}))
|
|
1526
1356
|
};
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1357
|
+
var newModules = {
|
|
1358
|
+
browser: from.modules.browser.filter(function (m) {
|
|
1359
|
+
return !existingModules.browser.has(m.fileName);
|
|
1360
|
+
}),
|
|
1361
|
+
server: from.modules.server.filter(function (m) {
|
|
1362
|
+
return !existingModules.server.has(m.fileName);
|
|
1363
|
+
})
|
|
1532
1364
|
};
|
|
1533
|
-
|
|
1365
|
+
if (newModules.browser.length > 0 || newModules.server.length > 0) {
|
|
1366
|
+
target = _extends({}, target, {
|
|
1367
|
+
modules: {
|
|
1368
|
+
browser: [].concat(target.modules.browser, newModules.browser),
|
|
1369
|
+
server: [].concat(target.modules.server, newModules.server)
|
|
1370
|
+
}
|
|
1371
|
+
});
|
|
1372
|
+
}
|
|
1373
|
+
var existingGlobalIds = new Set(target.globalGroups.map(function (g) {
|
|
1374
|
+
return g.id;
|
|
1375
|
+
}));
|
|
1376
|
+
var newGlobals = from.globalGroups.filter(function (g) {
|
|
1377
|
+
return !existingGlobalIds.has(g.id);
|
|
1378
|
+
});
|
|
1379
|
+
if (newGlobals.length > 0) {
|
|
1380
|
+
target = _extends({}, target, {
|
|
1381
|
+
globalGroups: [].concat(target.globalGroups, newGlobals)
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
var existingExternals = new Set(target.external);
|
|
1385
|
+
var newExternals = target.external.filter(function (x) {
|
|
1386
|
+
return !existingExternals.has(x);
|
|
1387
|
+
});
|
|
1388
|
+
if (newExternals.length > 0) {
|
|
1389
|
+
target = _extends({}, target, {
|
|
1390
|
+
external: [].concat(target.external, newExternals)
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1393
|
+
var existingSplitIds = new Set(target.activeSplits.map(function (s) {
|
|
1394
|
+
return s.id;
|
|
1395
|
+
}));
|
|
1396
|
+
var newSplits = (_from$activeSplits$fi = from.activeSplits.filter(function (s) {
|
|
1397
|
+
return !existingSplitIds.has(s.id);
|
|
1398
|
+
})) != null ? _from$activeSplits$fi : [];
|
|
1399
|
+
if (newSplits.length > 0) {
|
|
1400
|
+
target = _extends({}, target, {
|
|
1401
|
+
activeSplits: [].concat(target.activeSplits, newSplits)
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1404
|
+
return target;
|
|
1405
|
+
}
|
|
1406
|
+
var convertBundlesToComponentRenderData = function convertBundlesToComponentRenderData(bundles, compMetas) {
|
|
1407
|
+
if (bundles.length === 0) {
|
|
1408
|
+
return null;
|
|
1409
|
+
}
|
|
1410
|
+
var mergedBundles = bundles.reduce(function (prev, cur) {
|
|
1411
|
+
return mergeBundles(prev, cur);
|
|
1412
|
+
});
|
|
1413
|
+
return prepComponentData(mergedBundles, compMetas);
|
|
1414
|
+
};
|
|
1415
|
+
|
|
1416
|
+
/** Subset of loader functionality that works on React Server Components. */
|
|
1417
|
+
var ReactServerPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
1418
|
+
function ReactServerPlasmicComponentLoader(args) {
|
|
1534
1419
|
this.bundle = {
|
|
1535
1420
|
modules: {
|
|
1536
1421
|
browser: [],
|
|
@@ -1542,22 +1427,43 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1542
1427
|
projects: [],
|
|
1543
1428
|
activeSplits: []
|
|
1544
1429
|
};
|
|
1545
|
-
this.
|
|
1546
|
-
|
|
1430
|
+
this.opts = args.opts;
|
|
1431
|
+
this.fetcher = args.fetcher;
|
|
1432
|
+
this.tracker = args.tracker;
|
|
1433
|
+
this.onBundleMerged = args.onBundleMerged;
|
|
1434
|
+
this.onBundleFetched = args.onBundleFetched;
|
|
1435
|
+
}
|
|
1436
|
+
var _proto = ReactServerPlasmicComponentLoader.prototype;
|
|
1547
1437
|
_proto.maybeGetCompMetas = function maybeGetCompMetas() {
|
|
1438
|
+
var found = new Set();
|
|
1439
|
+
var missing = [];
|
|
1548
1440
|
for (var _len = arguments.length, specs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1549
1441
|
specs[_key] = arguments[_key];
|
|
1550
1442
|
}
|
|
1551
|
-
|
|
1443
|
+
for (var _i = 0, _specs = specs; _i < _specs.length; _i++) {
|
|
1444
|
+
var spec = _specs[_i];
|
|
1445
|
+
var filteredMetas = getCompMetas(this.bundle.components, spec);
|
|
1446
|
+
if (filteredMetas.length > 0) {
|
|
1447
|
+
filteredMetas.forEach(function (meta) {
|
|
1448
|
+
return found.add(meta);
|
|
1449
|
+
});
|
|
1450
|
+
} else {
|
|
1451
|
+
missing.push(spec);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
return {
|
|
1455
|
+
found: Array.from(found.keys()),
|
|
1456
|
+
missing: missing
|
|
1457
|
+
};
|
|
1552
1458
|
};
|
|
1553
1459
|
_proto.maybeFetchComponentData = /*#__PURE__*/function () {
|
|
1554
1460
|
var _maybeFetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
1555
|
-
var
|
|
1461
|
+
var _this = this;
|
|
1556
1462
|
var _parseFetchComponentD,
|
|
1557
1463
|
specs,
|
|
1558
1464
|
opts,
|
|
1559
1465
|
returnWithSpecsToFetch,
|
|
1560
|
-
_this$
|
|
1466
|
+
_this$maybeGetCompMet2,
|
|
1561
1467
|
existingMetas,
|
|
1562
1468
|
missingSpecs,
|
|
1563
1469
|
_args2 = arguments;
|
|
@@ -1568,24 +1474,24 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1568
1474
|
_parseFetchComponentD = parseFetchComponentDataArgs.apply(void 0, _args2), specs = _parseFetchComponentD.specs, opts = _parseFetchComponentD.opts;
|
|
1569
1475
|
returnWithSpecsToFetch = /*#__PURE__*/function () {
|
|
1570
1476
|
var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(specsToFetch) {
|
|
1571
|
-
var
|
|
1477
|
+
var _this$maybeGetCompMet, existingMetas2, missingSpecs2;
|
|
1572
1478
|
return runtime_1.wrap(function _callee$(_context) {
|
|
1573
1479
|
while (1) {
|
|
1574
1480
|
switch (_context.prev = _context.next) {
|
|
1575
1481
|
case 0:
|
|
1576
1482
|
_context.next = 2;
|
|
1577
|
-
return
|
|
1483
|
+
return _this.fetchMissingData({
|
|
1578
1484
|
missingSpecs: specsToFetch
|
|
1579
1485
|
});
|
|
1580
1486
|
case 2:
|
|
1581
|
-
|
|
1487
|
+
_this$maybeGetCompMet = _this.maybeGetCompMetas.apply(_this, specs), existingMetas2 = _this$maybeGetCompMet.found, missingSpecs2 = _this$maybeGetCompMet.missing;
|
|
1582
1488
|
if (!(missingSpecs2.length > 0)) {
|
|
1583
1489
|
_context.next = 5;
|
|
1584
1490
|
break;
|
|
1585
1491
|
}
|
|
1586
1492
|
return _context.abrupt("return", null);
|
|
1587
1493
|
case 5:
|
|
1588
|
-
return _context.abrupt("return", prepComponentData(
|
|
1494
|
+
return _context.abrupt("return", prepComponentData(_this.bundle, existingMetas2, opts));
|
|
1589
1495
|
case 6:
|
|
1590
1496
|
case "end":
|
|
1591
1497
|
return _context.stop();
|
|
@@ -1607,7 +1513,7 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1607
1513
|
return _context2.abrupt("return", _context2.sent);
|
|
1608
1514
|
case 6:
|
|
1609
1515
|
// Else we only fetch actually missing specs
|
|
1610
|
-
_this$
|
|
1516
|
+
_this$maybeGetCompMet2 = this.maybeGetCompMetas.apply(this, specs), existingMetas = _this$maybeGetCompMet2.found, missingSpecs = _this$maybeGetCompMet2.missing;
|
|
1611
1517
|
if (!(missingSpecs.length === 0)) {
|
|
1612
1518
|
_context2.next = 9;
|
|
1613
1519
|
break;
|
|
@@ -1636,7 +1542,7 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1636
1542
|
specs,
|
|
1637
1543
|
opts,
|
|
1638
1544
|
data,
|
|
1639
|
-
_this$
|
|
1545
|
+
_this$maybeGetCompMet3,
|
|
1640
1546
|
missingSpecs,
|
|
1641
1547
|
_args3 = arguments;
|
|
1642
1548
|
return runtime_1.wrap(function _callee3$(_context3) {
|
|
@@ -1652,7 +1558,7 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1652
1558
|
_context3.next = 7;
|
|
1653
1559
|
break;
|
|
1654
1560
|
}
|
|
1655
|
-
_this$
|
|
1561
|
+
_this$maybeGetCompMet3 = this.maybeGetCompMetas.apply(this, specs), missingSpecs = _this$maybeGetCompMet3.missing;
|
|
1656
1562
|
throw new Error("Unable to find components " + missingSpecs.map(getLookupSpecName).join(', '));
|
|
1657
1563
|
case 7:
|
|
1658
1564
|
return _context3.abrupt("return", data);
|
|
@@ -1724,23 +1630,10 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1724
1630
|
}
|
|
1725
1631
|
return fetchComponents;
|
|
1726
1632
|
}();
|
|
1727
|
-
_proto.getLookup = function getLookup() {
|
|
1728
|
-
return new ComponentLookup(this.bundle, this.registry);
|
|
1729
|
-
};
|
|
1730
1633
|
_proto.getActiveSplits = function getActiveSplits() {
|
|
1731
1634
|
return this.bundle.activeSplits;
|
|
1732
1635
|
};
|
|
1733
|
-
_proto.
|
|
1734
|
-
if (value === void 0) {
|
|
1735
|
-
value = 0;
|
|
1736
|
-
}
|
|
1737
|
-
this.tracker.trackConversion(value);
|
|
1738
|
-
}
|
|
1739
|
-
// @ts-ignore
|
|
1740
|
-
;
|
|
1741
|
-
_proto.fetchMissingData =
|
|
1742
|
-
/*#__PURE__*/
|
|
1743
|
-
function () {
|
|
1636
|
+
_proto.fetchMissingData = /*#__PURE__*/function () {
|
|
1744
1637
|
var _fetchMissingData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(opts) {
|
|
1745
1638
|
return runtime_1.wrap(function _callee6$(_context6) {
|
|
1746
1639
|
while (1) {
|
|
@@ -1775,83 +1668,285 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1775
1668
|
}
|
|
1776
1669
|
}
|
|
1777
1670
|
};
|
|
1778
|
-
_proto.
|
|
1779
|
-
var
|
|
1671
|
+
_proto.fetchAllData = /*#__PURE__*/function () {
|
|
1672
|
+
var _fetchAllData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7() {
|
|
1673
|
+
var _this$onBundleFetched;
|
|
1674
|
+
var bundle;
|
|
1780
1675
|
return runtime_1.wrap(function _callee7$(_context7) {
|
|
1781
1676
|
while (1) {
|
|
1782
1677
|
switch (_context7.prev = _context7.next) {
|
|
1783
1678
|
case 0:
|
|
1784
1679
|
_context7.next = 2;
|
|
1785
|
-
return this.fetchAllData();
|
|
1680
|
+
return this.fetcher.fetchAllData();
|
|
1786
1681
|
case 2:
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1682
|
+
bundle = _context7.sent;
|
|
1683
|
+
this.tracker.trackFetch();
|
|
1684
|
+
this.mergeBundle(bundle);
|
|
1685
|
+
(_this$onBundleFetched = this.onBundleFetched) == null ? void 0 : _this$onBundleFetched.call(this);
|
|
1686
|
+
return _context7.abrupt("return", bundle);
|
|
1687
|
+
case 7:
|
|
1791
1688
|
case "end":
|
|
1792
1689
|
return _context7.stop();
|
|
1793
1690
|
}
|
|
1794
1691
|
}
|
|
1795
1692
|
}, _callee7, this);
|
|
1796
1693
|
}));
|
|
1797
|
-
function
|
|
1798
|
-
return
|
|
1694
|
+
function fetchAllData() {
|
|
1695
|
+
return _fetchAllData.apply(this, arguments);
|
|
1799
1696
|
}
|
|
1800
|
-
return
|
|
1697
|
+
return fetchAllData;
|
|
1801
1698
|
}();
|
|
1802
|
-
_proto.
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1699
|
+
_proto.mergeBundle = function mergeBundle(bundle) {
|
|
1700
|
+
var _this$onBundleMerged;
|
|
1701
|
+
this.bundle = mergeBundles(bundle, this.bundle);
|
|
1702
|
+
(_this$onBundleMerged = this.onBundleMerged) == null ? void 0 : _this$onBundleMerged.call(this);
|
|
1703
|
+
};
|
|
1704
|
+
_proto.getBundle = function getBundle() {
|
|
1705
|
+
return this.bundle;
|
|
1706
|
+
};
|
|
1707
|
+
_proto.clearCache = function clearCache() {
|
|
1708
|
+
this.bundle = {
|
|
1709
|
+
modules: {
|
|
1710
|
+
browser: [],
|
|
1711
|
+
server: []
|
|
1712
|
+
},
|
|
1713
|
+
components: [],
|
|
1714
|
+
globalGroups: [],
|
|
1715
|
+
external: [],
|
|
1716
|
+
projects: [],
|
|
1717
|
+
activeSplits: []
|
|
1718
|
+
};
|
|
1719
|
+
};
|
|
1720
|
+
return ReactServerPlasmicComponentLoader;
|
|
1721
|
+
}();
|
|
1722
|
+
function parseFetchComponentDataArgs() {
|
|
1723
|
+
var specs;
|
|
1724
|
+
var opts;
|
|
1725
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
1726
|
+
args[_key2] = arguments[_key2];
|
|
1727
|
+
}
|
|
1728
|
+
if (Array.isArray(args[0])) {
|
|
1729
|
+
specs = args[0];
|
|
1730
|
+
opts = args[1];
|
|
1731
|
+
} else {
|
|
1732
|
+
specs = args;
|
|
1733
|
+
opts = undefined;
|
|
1734
|
+
}
|
|
1735
|
+
return {
|
|
1736
|
+
specs: specs,
|
|
1737
|
+
opts: opts
|
|
1738
|
+
};
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
1742
|
+
function InternalPlasmicComponentLoader(opts) {
|
|
1743
|
+
var _this = this;
|
|
1744
|
+
this.opts = opts;
|
|
1745
|
+
this.subs = [];
|
|
1746
|
+
this.roots = [];
|
|
1747
|
+
this.globalVariants = [];
|
|
1748
|
+
this.substitutedComponents = {};
|
|
1749
|
+
this.substitutedGlobalVariantHooks = {};
|
|
1750
|
+
this.registry = loaderCore.Registry.getInstance();
|
|
1751
|
+
this.tracker = new loaderCore.PlasmicTracker({
|
|
1752
|
+
projectIds: opts.projects.map(function (p) {
|
|
1753
|
+
return p.id;
|
|
1754
|
+
}),
|
|
1755
|
+
platform: opts.platform,
|
|
1756
|
+
preview: opts.preview
|
|
1757
|
+
});
|
|
1758
|
+
this.reactServerLoader = new ReactServerPlasmicComponentLoader({
|
|
1759
|
+
opts: opts,
|
|
1760
|
+
fetcher: new loaderCore.PlasmicModulesFetcher(opts),
|
|
1761
|
+
tracker: this.tracker,
|
|
1762
|
+
onBundleMerged: function onBundleMerged() {
|
|
1763
|
+
_this.refreshRegistry();
|
|
1764
|
+
},
|
|
1765
|
+
onBundleFetched: function onBundleFetched() {
|
|
1766
|
+
_this.roots.forEach(function (watcher) {
|
|
1767
|
+
return watcher.onDataFetched == null ? void 0 : watcher.onDataFetched();
|
|
1768
|
+
});
|
|
1769
|
+
}
|
|
1770
|
+
});
|
|
1771
|
+
this.registerModules({
|
|
1772
|
+
react: React__default,
|
|
1773
|
+
'react-dom': ReactDOM,
|
|
1774
|
+
'react/jsx-runtime': jsxRuntime,
|
|
1775
|
+
'react/jsx-dev-runtime': jsxDevRuntime,
|
|
1776
|
+
// Also inject @plasmicapp/query and @plasmicapp/host to use the
|
|
1777
|
+
// same contexts here and in loader-downloaded code.
|
|
1778
|
+
'@plasmicapp/query': PlasmicQuery,
|
|
1779
|
+
'@plasmicapp/data-sources-context': PlasmicDataSourcesContext,
|
|
1780
|
+
'@plasmicapp/host': PlasmicHost,
|
|
1781
|
+
'@plasmicapp/loader-runtime-registry': {
|
|
1782
|
+
components: this.substitutedComponents,
|
|
1783
|
+
globalVariantHooks: this.substitutedGlobalVariantHooks
|
|
1784
|
+
}
|
|
1785
|
+
});
|
|
1786
|
+
}
|
|
1787
|
+
var _proto = InternalPlasmicComponentLoader.prototype;
|
|
1788
|
+
_proto.getBundle = function getBundle() {
|
|
1789
|
+
return this.reactServerLoader.getBundle();
|
|
1790
|
+
};
|
|
1791
|
+
_proto.setGlobalVariants = function setGlobalVariants(globalVariants) {
|
|
1792
|
+
this.globalVariants = globalVariants;
|
|
1793
|
+
};
|
|
1794
|
+
_proto.getGlobalVariants = function getGlobalVariants() {
|
|
1795
|
+
return this.globalVariants;
|
|
1796
|
+
};
|
|
1797
|
+
_proto.registerModules = function registerModules(modules) {
|
|
1798
|
+
var _this2 = this;
|
|
1799
|
+
if (Object.keys(modules).some(function (name) {
|
|
1800
|
+
return _this2.registry.getRegisteredModule(name) !== modules[name];
|
|
1801
|
+
})) {
|
|
1802
|
+
if (!this.registry.isEmpty()) {
|
|
1803
|
+
console.warn('Calling PlasmicComponentLoader.registerModules() after Plasmic component has rendered; starting over.');
|
|
1804
|
+
this.registry.clear();
|
|
1805
|
+
}
|
|
1806
|
+
for (var _i = 0, _Object$keys = Object.keys(modules); _i < _Object$keys.length; _i++) {
|
|
1807
|
+
var key = _Object$keys[_i];
|
|
1808
|
+
this.registry.register(key, modules[key]);
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
_proto.substituteComponent = function substituteComponent(component, name) {
|
|
1813
|
+
if (!this.registry.isEmpty()) {
|
|
1814
|
+
console.warn('Calling PlasmicComponentLoader.registerSubstitution() after Plasmic component has rendered; starting over.');
|
|
1815
|
+
this.registry.clear();
|
|
1816
|
+
}
|
|
1817
|
+
this.subs.push({
|
|
1818
|
+
lookup: name,
|
|
1819
|
+
component: component
|
|
1820
|
+
});
|
|
1821
|
+
};
|
|
1822
|
+
_proto.registerComponent = function registerComponent(component, meta) {
|
|
1823
|
+
var _meta$importPath;
|
|
1824
|
+
this.substituteComponent(component, {
|
|
1825
|
+
name: meta.name,
|
|
1826
|
+
isCode: true
|
|
1827
|
+
});
|
|
1828
|
+
// Import path is not used as we will use component substitution
|
|
1829
|
+
PlasmicHost.registerComponent(component, _extends({}, meta, {
|
|
1830
|
+
importPath: (_meta$importPath = meta.importPath) != null ? _meta$importPath : ''
|
|
1807
1831
|
}));
|
|
1808
1832
|
};
|
|
1809
|
-
_proto.
|
|
1810
|
-
|
|
1811
|
-
|
|
1833
|
+
_proto.registerGlobalContext = function registerGlobalContext(context, meta) {
|
|
1834
|
+
var _meta$importPath2;
|
|
1835
|
+
this.substituteComponent(context, {
|
|
1836
|
+
name: meta.name,
|
|
1837
|
+
isCode: true
|
|
1838
|
+
});
|
|
1839
|
+
// Import path is not used as we will use component substitution
|
|
1840
|
+
PlasmicHost.registerGlobalContext(context, _extends({}, meta, {
|
|
1841
|
+
importPath: (_meta$importPath2 = meta.importPath) != null ? _meta$importPath2 : ''
|
|
1812
1842
|
}));
|
|
1813
1843
|
};
|
|
1814
|
-
_proto.
|
|
1815
|
-
|
|
1844
|
+
_proto.registerTrait = function registerTrait(trait, meta) {
|
|
1845
|
+
PlasmicHost.registerTrait(trait, meta);
|
|
1816
1846
|
};
|
|
1817
|
-
_proto.
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1847
|
+
_proto.registerPrefetchedBundle = function registerPrefetchedBundle(bundle) {
|
|
1848
|
+
// For React Server Components (Next.js 13+),
|
|
1849
|
+
// we need to pass server modules in LoaderBundleOutput from Server Components to Client Components.
|
|
1850
|
+
// We don't want to pass them via normal page props because that will be serialized to the browser.
|
|
1851
|
+
// Instead, we pass the bundle (including the server modules) via the Node `global` variable.
|
|
1852
|
+
//
|
|
1853
|
+
// This is the code that reads the stored bundle and merges it back into the loader.
|
|
1854
|
+
if (!isBrowser) {
|
|
1855
|
+
// Check if a bundle is stored with the corresponding ID.
|
|
1856
|
+
if (bundle.localId !== undefined) {
|
|
1857
|
+
var _global$__PLASMIC_BUN;
|
|
1858
|
+
// If it's there, merge this bundle first.
|
|
1859
|
+
var storedBundle = (_global$__PLASMIC_BUN = global.__PLASMIC_BUNDLES) == null ? void 0 : _global$__PLASMIC_BUN[bundle.localId];
|
|
1860
|
+
if (storedBundle) {
|
|
1861
|
+
this.reactServerLoader.mergeBundle(storedBundle);
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
this.reactServerLoader.mergeBundle(bundle);
|
|
1866
|
+
};
|
|
1867
|
+
_proto.subscribePlasmicRoot = function subscribePlasmicRoot(watcher) {
|
|
1868
|
+
this.roots.push(watcher);
|
|
1869
|
+
};
|
|
1870
|
+
_proto.unsubscribePlasmicRoot = function unsubscribePlasmicRoot(watcher) {
|
|
1871
|
+
var index = this.roots.indexOf(watcher);
|
|
1872
|
+
if (index >= 0) {
|
|
1873
|
+
this.roots.splice(index, 1);
|
|
1874
|
+
}
|
|
1875
|
+
};
|
|
1876
|
+
_proto.clearCache = function clearCache() {
|
|
1877
|
+
this.reactServerLoader.clearCache();
|
|
1878
|
+
this.registry.clear();
|
|
1879
|
+
};
|
|
1880
|
+
_proto.getLookup = function getLookup() {
|
|
1881
|
+
return new ComponentLookup(this.getBundle(), this.registry);
|
|
1882
|
+
};
|
|
1883
|
+
_proto.maybeFetchComponentData = function maybeFetchComponentData() {
|
|
1884
|
+
var _this$reactServerLoad;
|
|
1885
|
+
return (_this$reactServerLoad = this.reactServerLoader).maybeFetchComponentData.apply(_this$reactServerLoad, arguments);
|
|
1886
|
+
};
|
|
1887
|
+
_proto.fetchComponentData = function fetchComponentData() {
|
|
1888
|
+
var _this$reactServerLoad2;
|
|
1889
|
+
return (_this$reactServerLoad2 = this.reactServerLoader).fetchComponentData.apply(_this$reactServerLoad2, arguments);
|
|
1890
|
+
};
|
|
1891
|
+
_proto.fetchPages = function fetchPages(opts) {
|
|
1892
|
+
return this.reactServerLoader.fetchPages(opts);
|
|
1893
|
+
};
|
|
1894
|
+
_proto.fetchComponents = function fetchComponents() {
|
|
1895
|
+
return this.reactServerLoader.fetchComponents();
|
|
1896
|
+
};
|
|
1897
|
+
_proto.getActiveSplits = function getActiveSplits() {
|
|
1898
|
+
return this.reactServerLoader.getActiveSplits();
|
|
1899
|
+
};
|
|
1900
|
+
_proto.trackConversion = function trackConversion(value) {
|
|
1901
|
+
if (value === void 0) {
|
|
1902
|
+
value = 0;
|
|
1903
|
+
}
|
|
1904
|
+
this.tracker.trackConversion(value);
|
|
1905
|
+
};
|
|
1906
|
+
_proto.getActiveVariation = /*#__PURE__*/function () {
|
|
1907
|
+
var _getActiveVariation2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(opts) {
|
|
1908
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1821
1909
|
while (1) {
|
|
1822
|
-
switch (
|
|
1910
|
+
switch (_context.prev = _context.next) {
|
|
1823
1911
|
case 0:
|
|
1824
|
-
|
|
1825
|
-
return this.
|
|
1912
|
+
_context.next = 2;
|
|
1913
|
+
return this.reactServerLoader.fetchComponents();
|
|
1826
1914
|
case 2:
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
return watcher.onDataFetched == null ? void 0 : watcher.onDataFetched();
|
|
1832
|
-
});
|
|
1833
|
-
return _context8.abrupt("return", bundle);
|
|
1834
|
-
case 7:
|
|
1915
|
+
return _context.abrupt("return", loaderSplits.getActiveVariation(_extends({}, opts, {
|
|
1916
|
+
splits: this.getBundle().activeSplits
|
|
1917
|
+
})));
|
|
1918
|
+
case 3:
|
|
1835
1919
|
case "end":
|
|
1836
|
-
return
|
|
1920
|
+
return _context.stop();
|
|
1837
1921
|
}
|
|
1838
1922
|
}
|
|
1839
|
-
},
|
|
1923
|
+
}, _callee, this);
|
|
1840
1924
|
}));
|
|
1841
|
-
function
|
|
1842
|
-
return
|
|
1925
|
+
function getActiveVariation(_x) {
|
|
1926
|
+
return _getActiveVariation2.apply(this, arguments);
|
|
1843
1927
|
}
|
|
1844
|
-
return
|
|
1928
|
+
return getActiveVariation;
|
|
1845
1929
|
}();
|
|
1846
|
-
_proto.
|
|
1847
|
-
this.
|
|
1848
|
-
|
|
1930
|
+
_proto.getTeamIds = function getTeamIds() {
|
|
1931
|
+
return uniq(this.getBundle().projects.map(function (p) {
|
|
1932
|
+
return p.teamId ? "" + p.teamId + (p.indirect ? '@indirect' : '') : null;
|
|
1933
|
+
}).filter(function (x) {
|
|
1934
|
+
return !!x;
|
|
1935
|
+
}));
|
|
1936
|
+
};
|
|
1937
|
+
_proto.getProjectIds = function getProjectIds() {
|
|
1938
|
+
return uniq(this.getBundle().projects.map(function (p) {
|
|
1939
|
+
return "" + p.id + (p.indirect ? '@indirect' : '');
|
|
1940
|
+
}));
|
|
1941
|
+
};
|
|
1942
|
+
_proto.trackRender = function trackRender(opts) {
|
|
1943
|
+
this.tracker.trackRender(opts);
|
|
1849
1944
|
};
|
|
1850
1945
|
_proto.refreshRegistry = function refreshRegistry() {
|
|
1851
1946
|
var _this3 = this;
|
|
1852
1947
|
var _loop = function _loop() {
|
|
1853
1948
|
var sub = _step.value;
|
|
1854
|
-
var metas = getCompMetas(_this3.
|
|
1949
|
+
var metas = getCompMetas(_this3.getBundle().components, sub.lookup);
|
|
1855
1950
|
metas.forEach(function (meta) {
|
|
1856
1951
|
_this3.substitutedComponents[meta.id] = sub.component;
|
|
1857
1952
|
});
|
|
@@ -1869,41 +1964,16 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1869
1964
|
// context providers, but instead by <PlasmicRootProvider/> and by
|
|
1870
1965
|
// PlasmicComponentLoader.setGlobalVariants(), we redirect these
|
|
1871
1966
|
// hooks to read from them instead.
|
|
1872
|
-
for (var _iterator2 = _createForOfIteratorHelperLoose(this.
|
|
1967
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(this.getBundle().globalGroups), _step2; !(_step2 = _iterator2()).done;) {
|
|
1873
1968
|
var globalGroup = _step2.value;
|
|
1874
1969
|
if (globalGroup.type !== 'global-screen') {
|
|
1875
1970
|
this.substitutedGlobalVariantHooks[globalGroup.id] = createUseGlobalVariant(globalGroup.name, globalGroup.projectId);
|
|
1876
1971
|
}
|
|
1877
1972
|
}
|
|
1878
|
-
this.registry.updateModules(this.
|
|
1879
|
-
};
|
|
1880
|
-
_proto.ensureFetcher = function ensureFetcher() {
|
|
1881
|
-
if (!this.fetcher) {
|
|
1882
|
-
throw new Error("You must first call PlasmicComponentLoader.init()");
|
|
1883
|
-
}
|
|
1884
|
-
return this.fetcher;
|
|
1973
|
+
this.registry.updateModules(this.getBundle());
|
|
1885
1974
|
};
|
|
1886
1975
|
return InternalPlasmicComponentLoader;
|
|
1887
1976
|
}();
|
|
1888
|
-
function _maybeGetCompMetas(metas, specs) {
|
|
1889
|
-
var found = new Set();
|
|
1890
|
-
var missing = [];
|
|
1891
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose(specs), _step3; !(_step3 = _iterator3()).done;) {
|
|
1892
|
-
var spec = _step3.value;
|
|
1893
|
-
var filteredMetas = getCompMetas(metas, spec);
|
|
1894
|
-
if (filteredMetas.length > 0) {
|
|
1895
|
-
filteredMetas.forEach(function (meta) {
|
|
1896
|
-
return found.add(meta);
|
|
1897
|
-
});
|
|
1898
|
-
} else {
|
|
1899
|
-
missing.push(spec);
|
|
1900
|
-
}
|
|
1901
|
-
}
|
|
1902
|
-
return {
|
|
1903
|
-
found: Array.from(found.keys()),
|
|
1904
|
-
missing: missing
|
|
1905
|
-
};
|
|
1906
|
-
}
|
|
1907
1977
|
/**
|
|
1908
1978
|
* Library for fetching component data, and registering
|
|
1909
1979
|
* custom components.
|
|
@@ -1973,23 +2043,23 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1973
2043
|
_proto2.fetchComponentData =
|
|
1974
2044
|
/*#__PURE__*/
|
|
1975
2045
|
function () {
|
|
1976
|
-
var
|
|
2046
|
+
var _fetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
1977
2047
|
var _this$__internal;
|
|
1978
|
-
var
|
|
1979
|
-
return runtime_1.wrap(function
|
|
2048
|
+
var _args2 = arguments;
|
|
2049
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1980
2050
|
while (1) {
|
|
1981
|
-
switch (
|
|
2051
|
+
switch (_context2.prev = _context2.next) {
|
|
1982
2052
|
case 0:
|
|
1983
|
-
return
|
|
2053
|
+
return _context2.abrupt("return", (_this$__internal = this.__internal).fetchComponentData.apply(_this$__internal, _args2));
|
|
1984
2054
|
case 1:
|
|
1985
2055
|
case "end":
|
|
1986
|
-
return
|
|
2056
|
+
return _context2.stop();
|
|
1987
2057
|
}
|
|
1988
2058
|
}
|
|
1989
|
-
},
|
|
2059
|
+
}, _callee2, this);
|
|
1990
2060
|
}));
|
|
1991
2061
|
function fetchComponentData() {
|
|
1992
|
-
return
|
|
2062
|
+
return _fetchComponentData.apply(this, arguments);
|
|
1993
2063
|
}
|
|
1994
2064
|
return fetchComponentData;
|
|
1995
2065
|
}()
|
|
@@ -2002,23 +2072,23 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2002
2072
|
_proto2.maybeFetchComponentData =
|
|
2003
2073
|
/*#__PURE__*/
|
|
2004
2074
|
function () {
|
|
2005
|
-
var
|
|
2075
|
+
var _maybeFetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
2006
2076
|
var _this$__internal2;
|
|
2007
|
-
var
|
|
2008
|
-
return runtime_1.wrap(function
|
|
2077
|
+
var _args3 = arguments;
|
|
2078
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
2009
2079
|
while (1) {
|
|
2010
|
-
switch (
|
|
2080
|
+
switch (_context3.prev = _context3.next) {
|
|
2011
2081
|
case 0:
|
|
2012
|
-
return
|
|
2082
|
+
return _context3.abrupt("return", (_this$__internal2 = this.__internal).maybeFetchComponentData.apply(_this$__internal2, _args3));
|
|
2013
2083
|
case 1:
|
|
2014
2084
|
case "end":
|
|
2015
|
-
return
|
|
2085
|
+
return _context3.stop();
|
|
2016
2086
|
}
|
|
2017
2087
|
}
|
|
2018
|
-
},
|
|
2088
|
+
}, _callee3, this);
|
|
2019
2089
|
}));
|
|
2020
2090
|
function maybeFetchComponentData() {
|
|
2021
|
-
return
|
|
2091
|
+
return _maybeFetchComponentData.apply(this, arguments);
|
|
2022
2092
|
}
|
|
2023
2093
|
return maybeFetchComponentData;
|
|
2024
2094
|
}()
|
|
@@ -2029,21 +2099,21 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2029
2099
|
_proto2.fetchPages =
|
|
2030
2100
|
/*#__PURE__*/
|
|
2031
2101
|
function () {
|
|
2032
|
-
var
|
|
2033
|
-
return runtime_1.wrap(function
|
|
2102
|
+
var _fetchPages = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(opts) {
|
|
2103
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
2034
2104
|
while (1) {
|
|
2035
|
-
switch (
|
|
2105
|
+
switch (_context4.prev = _context4.next) {
|
|
2036
2106
|
case 0:
|
|
2037
|
-
return
|
|
2107
|
+
return _context4.abrupt("return", this.__internal.fetchPages(opts));
|
|
2038
2108
|
case 1:
|
|
2039
2109
|
case "end":
|
|
2040
|
-
return
|
|
2110
|
+
return _context4.stop();
|
|
2041
2111
|
}
|
|
2042
2112
|
}
|
|
2043
|
-
},
|
|
2113
|
+
}, _callee4, this);
|
|
2044
2114
|
}));
|
|
2045
|
-
function fetchPages(
|
|
2046
|
-
return
|
|
2115
|
+
function fetchPages(_x2) {
|
|
2116
|
+
return _fetchPages.apply(this, arguments);
|
|
2047
2117
|
}
|
|
2048
2118
|
return fetchPages;
|
|
2049
2119
|
}()
|
|
@@ -2054,50 +2124,50 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2054
2124
|
_proto2.fetchComponents =
|
|
2055
2125
|
/*#__PURE__*/
|
|
2056
2126
|
function () {
|
|
2057
|
-
var
|
|
2058
|
-
return runtime_1.wrap(function
|
|
2127
|
+
var _fetchComponents = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5() {
|
|
2128
|
+
return runtime_1.wrap(function _callee5$(_context5) {
|
|
2059
2129
|
while (1) {
|
|
2060
|
-
switch (
|
|
2130
|
+
switch (_context5.prev = _context5.next) {
|
|
2061
2131
|
case 0:
|
|
2062
|
-
return
|
|
2132
|
+
return _context5.abrupt("return", this.__internal.fetchComponents());
|
|
2063
2133
|
case 1:
|
|
2064
2134
|
case "end":
|
|
2065
|
-
return
|
|
2135
|
+
return _context5.stop();
|
|
2066
2136
|
}
|
|
2067
2137
|
}
|
|
2068
|
-
},
|
|
2138
|
+
}, _callee5, this);
|
|
2069
2139
|
}));
|
|
2070
2140
|
function fetchComponents() {
|
|
2071
|
-
return
|
|
2141
|
+
return _fetchComponents.apply(this, arguments);
|
|
2072
2142
|
}
|
|
2073
2143
|
return fetchComponents;
|
|
2074
2144
|
}();
|
|
2075
2145
|
_proto2._getActiveVariation = /*#__PURE__*/function () {
|
|
2076
|
-
var _getActiveVariation3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2077
|
-
return runtime_1.wrap(function
|
|
2146
|
+
var _getActiveVariation3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(opts) {
|
|
2147
|
+
return runtime_1.wrap(function _callee6$(_context6) {
|
|
2078
2148
|
while (1) {
|
|
2079
|
-
switch (
|
|
2149
|
+
switch (_context6.prev = _context6.next) {
|
|
2080
2150
|
case 0:
|
|
2081
|
-
return
|
|
2151
|
+
return _context6.abrupt("return", this.__internal.getActiveVariation(opts));
|
|
2082
2152
|
case 1:
|
|
2083
2153
|
case "end":
|
|
2084
|
-
return
|
|
2154
|
+
return _context6.stop();
|
|
2085
2155
|
}
|
|
2086
2156
|
}
|
|
2087
|
-
},
|
|
2157
|
+
}, _callee6, this);
|
|
2088
2158
|
}));
|
|
2089
|
-
function _getActiveVariation(
|
|
2159
|
+
function _getActiveVariation(_x3) {
|
|
2090
2160
|
return _getActiveVariation3.apply(this, arguments);
|
|
2091
2161
|
}
|
|
2092
2162
|
return _getActiveVariation;
|
|
2093
2163
|
}();
|
|
2094
2164
|
_proto2.getActiveVariation = /*#__PURE__*/function () {
|
|
2095
|
-
var _getActiveVariation4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function
|
|
2096
|
-
return runtime_1.wrap(function
|
|
2165
|
+
var _getActiveVariation4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(opts) {
|
|
2166
|
+
return runtime_1.wrap(function _callee7$(_context7) {
|
|
2097
2167
|
while (1) {
|
|
2098
|
-
switch (
|
|
2168
|
+
switch (_context7.prev = _context7.next) {
|
|
2099
2169
|
case 0:
|
|
2100
|
-
return
|
|
2170
|
+
return _context7.abrupt("return", this._getActiveVariation({
|
|
2101
2171
|
traits: opts.traits,
|
|
2102
2172
|
getKnownValue: function getKnownValue(key) {
|
|
2103
2173
|
if (opts.known) {
|
|
@@ -2115,12 +2185,12 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2115
2185
|
}));
|
|
2116
2186
|
case 1:
|
|
2117
2187
|
case "end":
|
|
2118
|
-
return
|
|
2188
|
+
return _context7.stop();
|
|
2119
2189
|
}
|
|
2120
2190
|
}
|
|
2121
|
-
},
|
|
2191
|
+
}, _callee7, this);
|
|
2122
2192
|
}));
|
|
2123
|
-
function getActiveVariation(
|
|
2193
|
+
function getActiveVariation(_x4) {
|
|
2124
2194
|
return _getActiveVariation4.apply(this, arguments);
|
|
2125
2195
|
}
|
|
2126
2196
|
return getActiveVariation;
|
|
@@ -2142,24 +2212,7 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2142
2212
|
};
|
|
2143
2213
|
return PlasmicComponentLoader;
|
|
2144
2214
|
}();
|
|
2145
|
-
|
|
2146
|
-
var specs;
|
|
2147
|
-
var opts;
|
|
2148
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2149
|
-
args[_key2] = arguments[_key2];
|
|
2150
|
-
}
|
|
2151
|
-
if (Array.isArray(args[0])) {
|
|
2152
|
-
specs = args[0];
|
|
2153
|
-
opts = args[1];
|
|
2154
|
-
} else {
|
|
2155
|
-
specs = args;
|
|
2156
|
-
opts = undefined;
|
|
2157
|
-
}
|
|
2158
|
-
return {
|
|
2159
|
-
specs: specs,
|
|
2160
|
-
opts: opts
|
|
2161
|
-
};
|
|
2162
|
-
}
|
|
2215
|
+
var global = globalThis;
|
|
2163
2216
|
|
|
2164
2217
|
/**
|
|
2165
2218
|
* Hook that fetches and returns a React component for rendering the argument
|
|
@@ -2570,6 +2623,11 @@ function makeElement(loader, lookup, opts) {
|
|
|
2570
2623
|
}));
|
|
2571
2624
|
}
|
|
2572
2625
|
|
|
2626
|
+
function initPlasmicLoader(opts) {
|
|
2627
|
+
var internal = new InternalPlasmicComponentLoader(opts);
|
|
2628
|
+
return new PlasmicComponentLoader(internal);
|
|
2629
|
+
}
|
|
2630
|
+
|
|
2573
2631
|
Object.defineProperty(exports, 'DataCtxReader', {
|
|
2574
2632
|
enumerable: true,
|
|
2575
2633
|
get: function () {
|