@plasmicapp/loader-react 1.0.36 → 1.0.37
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 +59 -29
- 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 +59 -29
- package/dist/loader-react.esm.js.map +1 -1
- package/package.json +3 -3
|
@@ -9,6 +9,8 @@ var loaderCore = require('@plasmicapp/loader-core');
|
|
|
9
9
|
var React = require('react');
|
|
10
10
|
var React__default = _interopDefault(React);
|
|
11
11
|
var ReactDOM = _interopDefault(require('react-dom'));
|
|
12
|
+
var jsxDevRuntime = require('react/jsx-dev-runtime');
|
|
13
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
12
14
|
var pascalcase = _interopDefault(require('pascalcase'));
|
|
13
15
|
var ReactDOMServer = _interopDefault(require('react-dom/server'));
|
|
14
16
|
|
|
@@ -195,16 +197,29 @@ function mergeBundles(target, from) {
|
|
|
195
197
|
});
|
|
196
198
|
}
|
|
197
199
|
|
|
198
|
-
var existingModules =
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
200
|
+
var existingModules = {
|
|
201
|
+
browser: new Set(target.modules.browser.map(function (m) {
|
|
202
|
+
return m.fileName;
|
|
203
|
+
})),
|
|
204
|
+
server: new Set(target.modules.server.map(function (m) {
|
|
205
|
+
return m.fileName;
|
|
206
|
+
}))
|
|
207
|
+
};
|
|
208
|
+
var newModules = {
|
|
209
|
+
browser: from.modules.browser.filter(function (m) {
|
|
210
|
+
return !existingModules.browser.has(m.fileName);
|
|
211
|
+
}),
|
|
212
|
+
server: from.modules.server.filter(function (m) {
|
|
213
|
+
return !existingModules.server.has(m.fileName);
|
|
214
|
+
})
|
|
215
|
+
};
|
|
204
216
|
|
|
205
|
-
if (newModules.length > 0) {
|
|
217
|
+
if (newModules.browser.length > 0 || newModules.server.length > 0) {
|
|
206
218
|
target = _extends({}, target, {
|
|
207
|
-
modules:
|
|
219
|
+
modules: {
|
|
220
|
+
browser: [].concat(target.modules.browser, newModules.browser),
|
|
221
|
+
server: [].concat(target.modules.server, newModules.server)
|
|
222
|
+
}
|
|
208
223
|
});
|
|
209
224
|
}
|
|
210
225
|
|
|
@@ -1155,7 +1170,8 @@ var ComponentLookup = /*#__PURE__*/function () {
|
|
|
1155
1170
|
};
|
|
1156
1171
|
|
|
1157
1172
|
_proto.getCss = function getCss() {
|
|
1158
|
-
|
|
1173
|
+
// We can probably always get the modules from the browser build
|
|
1174
|
+
return this.bundle.modules.browser.filter(function (mod) {
|
|
1159
1175
|
return mod.type === 'asset' && mod.fileName.endsWith('css');
|
|
1160
1176
|
});
|
|
1161
1177
|
};
|
|
@@ -1309,7 +1325,9 @@ function initPlasmicLoader(opts) {
|
|
|
1309
1325
|
var internal = new InternalPlasmicComponentLoader(opts);
|
|
1310
1326
|
internal.registerModules({
|
|
1311
1327
|
react: React__default,
|
|
1312
|
-
'react-dom': ReactDOM
|
|
1328
|
+
'react-dom': ReactDOM,
|
|
1329
|
+
'react/jsx-runtime': jsxRuntime,
|
|
1330
|
+
'react/jsx-dev-runtime': jsxDevRuntime
|
|
1313
1331
|
});
|
|
1314
1332
|
return new PlasmicComponentLoader(internal);
|
|
1315
1333
|
}
|
|
@@ -1320,13 +1338,16 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1320
1338
|
this.roots = [];
|
|
1321
1339
|
this.globalVariants = [];
|
|
1322
1340
|
this.bundle = {
|
|
1323
|
-
modules:
|
|
1341
|
+
modules: {
|
|
1342
|
+
browser: [],
|
|
1343
|
+
server: []
|
|
1344
|
+
},
|
|
1324
1345
|
components: [],
|
|
1325
1346
|
globalGroups: [],
|
|
1326
1347
|
external: [],
|
|
1327
1348
|
projects: []
|
|
1328
1349
|
};
|
|
1329
|
-
this.registry =
|
|
1350
|
+
this.registry = loaderCore.Registry.getInstance();
|
|
1330
1351
|
this.fetcher = new loaderCore.PlasmicModulesFetcher(opts);
|
|
1331
1352
|
}
|
|
1332
1353
|
|
|
@@ -1341,14 +1362,20 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1341
1362
|
};
|
|
1342
1363
|
|
|
1343
1364
|
_proto.registerModules = function registerModules(modules) {
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1365
|
+
var _this = this;
|
|
1366
|
+
|
|
1367
|
+
if (Object.keys(modules).some(function (name) {
|
|
1368
|
+
return _this.registry.getRegisteredModule(name) !== modules[name];
|
|
1369
|
+
})) {
|
|
1370
|
+
if (!this.registry.isEmpty()) {
|
|
1371
|
+
console.warn('Calling PlasmicComponentLoader.registerModules() after Plasmic component has rendered; starting over.');
|
|
1372
|
+
this.registry.clear();
|
|
1373
|
+
}
|
|
1348
1374
|
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1375
|
+
for (var _i = 0, _Object$keys = Object.keys(modules); _i < _Object$keys.length; _i++) {
|
|
1376
|
+
var key = _Object$keys[_i];
|
|
1377
|
+
this.registry.register(key, modules[key]);
|
|
1378
|
+
}
|
|
1352
1379
|
}
|
|
1353
1380
|
};
|
|
1354
1381
|
|
|
@@ -1395,7 +1422,10 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1395
1422
|
|
|
1396
1423
|
_proto.clearCache = function clearCache() {
|
|
1397
1424
|
this.bundle = {
|
|
1398
|
-
modules:
|
|
1425
|
+
modules: {
|
|
1426
|
+
browser: [],
|
|
1427
|
+
server: []
|
|
1428
|
+
},
|
|
1399
1429
|
components: [],
|
|
1400
1430
|
globalGroups: [],
|
|
1401
1431
|
external: [],
|
|
@@ -1414,13 +1444,13 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1414
1444
|
|
|
1415
1445
|
_proto.maybeFetchComponentData = /*#__PURE__*/function () {
|
|
1416
1446
|
var _maybeFetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
1417
|
-
var
|
|
1447
|
+
var _this2 = this;
|
|
1418
1448
|
|
|
1419
1449
|
var _len2,
|
|
1420
1450
|
specs,
|
|
1421
1451
|
_key2,
|
|
1422
1452
|
returnWithSpecsToFetch,
|
|
1423
|
-
_this$
|
|
1453
|
+
_this$maybeGetCompMet,
|
|
1424
1454
|
existingMetas,
|
|
1425
1455
|
missingSpecs,
|
|
1426
1456
|
_args2 = arguments;
|
|
@@ -1435,19 +1465,19 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1435
1465
|
|
|
1436
1466
|
returnWithSpecsToFetch = /*#__PURE__*/function () {
|
|
1437
1467
|
var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(specsToFetch) {
|
|
1438
|
-
var
|
|
1468
|
+
var _this2$maybeGetCompMe, existingMetas2, missingSpecs2;
|
|
1439
1469
|
|
|
1440
1470
|
return runtime_1.wrap(function _callee$(_context) {
|
|
1441
1471
|
while (1) {
|
|
1442
1472
|
switch (_context.prev = _context.next) {
|
|
1443
1473
|
case 0:
|
|
1444
1474
|
_context.next = 2;
|
|
1445
|
-
return
|
|
1475
|
+
return _this2.fetchMissingData({
|
|
1446
1476
|
missingSpecs: specsToFetch
|
|
1447
1477
|
});
|
|
1448
1478
|
|
|
1449
1479
|
case 2:
|
|
1450
|
-
|
|
1480
|
+
_this2$maybeGetCompMe = _this2.maybeGetCompMetas.apply(_this2, specs), existingMetas2 = _this2$maybeGetCompMe.found, missingSpecs2 = _this2$maybeGetCompMe.missing;
|
|
1451
1481
|
|
|
1452
1482
|
if (!(missingSpecs2.length > 0)) {
|
|
1453
1483
|
_context.next = 5;
|
|
@@ -1457,7 +1487,7 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1457
1487
|
return _context.abrupt("return", null);
|
|
1458
1488
|
|
|
1459
1489
|
case 5:
|
|
1460
|
-
return _context.abrupt("return", prepComponentData.apply(void 0, [
|
|
1490
|
+
return _context.abrupt("return", prepComponentData.apply(void 0, [_this2.bundle].concat(existingMetas2)));
|
|
1461
1491
|
|
|
1462
1492
|
case 6:
|
|
1463
1493
|
case "end":
|
|
@@ -1485,7 +1515,7 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1485
1515
|
|
|
1486
1516
|
case 6:
|
|
1487
1517
|
// Else we only fetch actually missing specs
|
|
1488
|
-
_this$
|
|
1518
|
+
_this$maybeGetCompMet = this.maybeGetCompMetas.apply(this, specs), existingMetas = _this$maybeGetCompMet.found, missingSpecs = _this$maybeGetCompMet.missing;
|
|
1489
1519
|
|
|
1490
1520
|
if (!(missingSpecs.length === 0)) {
|
|
1491
1521
|
_context2.next = 9;
|
|
@@ -1519,7 +1549,7 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1519
1549
|
_proto.fetchComponentData = /*#__PURE__*/function () {
|
|
1520
1550
|
var _fetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
1521
1551
|
var data,
|
|
1522
|
-
_this$
|
|
1552
|
+
_this$maybeGetCompMet2,
|
|
1523
1553
|
missingSpecs,
|
|
1524
1554
|
_args3 = arguments;
|
|
1525
1555
|
|
|
@@ -1538,7 +1568,7 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1538
1568
|
break;
|
|
1539
1569
|
}
|
|
1540
1570
|
|
|
1541
|
-
_this$
|
|
1571
|
+
_this$maybeGetCompMet2 = this.maybeGetCompMetas.apply(this, _args3), missingSpecs = _this$maybeGetCompMet2.missing;
|
|
1542
1572
|
throw new Error("Unable to find components " + missingSpecs.map(getLookupSpecName).join(', '));
|
|
1543
1573
|
|
|
1544
1574
|
case 6:
|