@plasmicapp/loader-react 1.0.184 → 1.0.186
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/bundles.d.ts +3 -1
- package/dist/loader-react.cjs.development.js +45 -23
- 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 +45 -23
- package/dist/loader-react.esm.js.map +1 -1
- package/dist/loader.d.ts +19 -0
- package/package.json +5 -4
package/dist/loader-react.esm.js
CHANGED
|
@@ -5,6 +5,7 @@ import * as PlasmicQuery from '@plasmicapp/query';
|
|
|
5
5
|
import { PlasmicQueryDataProvider, PlasmicPrepassContext } from '@plasmicapp/query';
|
|
6
6
|
export { usePlasmicQueryData } from '@plasmicapp/query';
|
|
7
7
|
import { getBundleSubset, Registry, PlasmicModulesFetcher, PlasmicTracker } from '@plasmicapp/loader-core';
|
|
8
|
+
import * as PlasmicDataSourcesContext from '@plasmicapp/data-sources-context';
|
|
8
9
|
import { getExternalIds, getActiveVariation } from '@plasmicapp/loader-splits';
|
|
9
10
|
import React__default, { useState, useCallback, useEffect, useRef, useMemo, createElement, memo, useContext, createContext } from 'react';
|
|
10
11
|
import ReactDOM from 'react-dom';
|
|
@@ -168,11 +169,7 @@ function getUsedComps(allComponents, entryCompIds) {
|
|
|
168
169
|
return usedComps;
|
|
169
170
|
}
|
|
170
171
|
|
|
171
|
-
function prepComponentData(bundle) {
|
|
172
|
-
for (var _len = arguments.length, compMetas = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
173
|
-
compMetas[_key - 1] = arguments[_key];
|
|
174
|
-
}
|
|
175
|
-
|
|
172
|
+
function prepComponentData(bundle, compMetas, opts) {
|
|
176
173
|
if (compMetas.length === 0) {
|
|
177
174
|
return {
|
|
178
175
|
entryCompMetas: bundle.components,
|
|
@@ -187,7 +184,7 @@ function prepComponentData(bundle) {
|
|
|
187
184
|
var compPaths = usedComps.map(function (compMeta) {
|
|
188
185
|
return compMeta.entry;
|
|
189
186
|
});
|
|
190
|
-
var subBundle = getBundleSubset
|
|
187
|
+
var subBundle = getBundleSubset(bundle, ['entrypoint.css'].concat(compPaths, ['root-provider.js'], bundle.projects.map(function (x) {
|
|
191
188
|
return x.globalContextsProviderFileName;
|
|
192
189
|
}).filter(function (x) {
|
|
193
190
|
return !!x;
|
|
@@ -197,7 +194,7 @@ function prepComponentData(bundle) {
|
|
|
197
194
|
return c.entry;
|
|
198
195
|
}), bundle.globalGroups.map(function (g) {
|
|
199
196
|
return g.contextFile;
|
|
200
|
-
})));
|
|
197
|
+
})), opts);
|
|
201
198
|
var remoteFontUrls = [];
|
|
202
199
|
subBundle.projects.forEach(function (p) {
|
|
203
200
|
return remoteFontUrls.push.apply(remoteFontUrls, p.remoteFonts.map(function (f) {
|
|
@@ -312,7 +309,7 @@ var convertBundlesToComponentRenderData = function convertBundlesToComponentRend
|
|
|
312
309
|
var mergedBundles = bundles.reduce(function (prev, cur) {
|
|
313
310
|
return mergeBundles(prev, cur);
|
|
314
311
|
});
|
|
315
|
-
return prepComponentData
|
|
312
|
+
return prepComponentData(mergedBundles, compMetas);
|
|
316
313
|
};
|
|
317
314
|
|
|
318
315
|
function createCommonjsModule(fn, module) {
|
|
@@ -1628,6 +1625,7 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1628
1625
|
// Also inject @plasmicapp/query and @plasmicapp/host to use the
|
|
1629
1626
|
// same contexts here and in loader-downloaded code.
|
|
1630
1627
|
'@plasmicapp/query': PlasmicQuery,
|
|
1628
|
+
'@plasmicapp/data-sources-context': PlasmicDataSourcesContext,
|
|
1631
1629
|
'@plasmicapp/host': PlasmicHost,
|
|
1632
1630
|
'@plasmicapp/loader-runtime-registry': {
|
|
1633
1631
|
components: this.substitutedComponents,
|
|
@@ -1749,9 +1747,9 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1749
1747
|
var _maybeFetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
1750
1748
|
var _this2 = this;
|
|
1751
1749
|
|
|
1752
|
-
var
|
|
1750
|
+
var _parseFetchComponentD,
|
|
1753
1751
|
specs,
|
|
1754
|
-
|
|
1752
|
+
opts,
|
|
1755
1753
|
returnWithSpecsToFetch,
|
|
1756
1754
|
_this$maybeGetCompMet,
|
|
1757
1755
|
existingMetas,
|
|
@@ -1762,9 +1760,7 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1762
1760
|
while (1) {
|
|
1763
1761
|
switch (_context2.prev = _context2.next) {
|
|
1764
1762
|
case 0:
|
|
1765
|
-
|
|
1766
|
-
specs[_key2] = _args2[_key2];
|
|
1767
|
-
}
|
|
1763
|
+
_parseFetchComponentD = parseFetchComponentDataArgs.apply(void 0, _args2), specs = _parseFetchComponentD.specs, opts = _parseFetchComponentD.opts;
|
|
1768
1764
|
|
|
1769
1765
|
returnWithSpecsToFetch = /*#__PURE__*/function () {
|
|
1770
1766
|
var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(specsToFetch) {
|
|
@@ -1790,7 +1786,7 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1790
1786
|
return _context.abrupt("return", null);
|
|
1791
1787
|
|
|
1792
1788
|
case 5:
|
|
1793
|
-
return _context.abrupt("return", prepComponentData
|
|
1789
|
+
return _context.abrupt("return", prepComponentData(_this2.bundle, existingMetas2, opts));
|
|
1794
1790
|
|
|
1795
1791
|
case 6:
|
|
1796
1792
|
case "end":
|
|
@@ -1825,7 +1821,7 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1825
1821
|
break;
|
|
1826
1822
|
}
|
|
1827
1823
|
|
|
1828
|
-
return _context2.abrupt("return", prepComponentData
|
|
1824
|
+
return _context2.abrupt("return", prepComponentData(this.bundle, existingMetas, opts));
|
|
1829
1825
|
|
|
1830
1826
|
case 9:
|
|
1831
1827
|
_context2.next = 11;
|
|
@@ -1851,7 +1847,10 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1851
1847
|
|
|
1852
1848
|
_proto.fetchComponentData = /*#__PURE__*/function () {
|
|
1853
1849
|
var _fetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
1854
|
-
var
|
|
1850
|
+
var _parseFetchComponentD2,
|
|
1851
|
+
specs,
|
|
1852
|
+
opts,
|
|
1853
|
+
data,
|
|
1855
1854
|
_this$maybeGetCompMet2,
|
|
1856
1855
|
missingSpecs,
|
|
1857
1856
|
_args3 = arguments;
|
|
@@ -1860,24 +1859,25 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1860
1859
|
while (1) {
|
|
1861
1860
|
switch (_context3.prev = _context3.next) {
|
|
1862
1861
|
case 0:
|
|
1863
|
-
|
|
1864
|
-
|
|
1862
|
+
_parseFetchComponentD2 = parseFetchComponentDataArgs.apply(void 0, _args3), specs = _parseFetchComponentD2.specs, opts = _parseFetchComponentD2.opts;
|
|
1863
|
+
_context3.next = 3;
|
|
1864
|
+
return this.maybeFetchComponentData(specs, opts);
|
|
1865
1865
|
|
|
1866
|
-
case
|
|
1866
|
+
case 3:
|
|
1867
1867
|
data = _context3.sent;
|
|
1868
1868
|
|
|
1869
1869
|
if (data) {
|
|
1870
|
-
_context3.next =
|
|
1870
|
+
_context3.next = 7;
|
|
1871
1871
|
break;
|
|
1872
1872
|
}
|
|
1873
1873
|
|
|
1874
|
-
_this$maybeGetCompMet2 = this.maybeGetCompMetas.apply(this,
|
|
1874
|
+
_this$maybeGetCompMet2 = this.maybeGetCompMetas.apply(this, specs), missingSpecs = _this$maybeGetCompMet2.missing;
|
|
1875
1875
|
throw new Error("Unable to find components " + missingSpecs.map(getLookupSpecName).join(', '));
|
|
1876
1876
|
|
|
1877
|
-
case
|
|
1877
|
+
case 7:
|
|
1878
1878
|
return _context3.abrupt("return", data);
|
|
1879
1879
|
|
|
1880
|
-
case
|
|
1880
|
+
case 8:
|
|
1881
1881
|
case "end":
|
|
1882
1882
|
return _context3.stop();
|
|
1883
1883
|
}
|
|
@@ -2457,6 +2457,28 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2457
2457
|
return PlasmicComponentLoader;
|
|
2458
2458
|
}();
|
|
2459
2459
|
|
|
2460
|
+
function parseFetchComponentDataArgs() {
|
|
2461
|
+
var specs;
|
|
2462
|
+
var opts;
|
|
2463
|
+
|
|
2464
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2465
|
+
args[_key2] = arguments[_key2];
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2468
|
+
if (Array.isArray(args[0])) {
|
|
2469
|
+
specs = args[0];
|
|
2470
|
+
opts = args[1];
|
|
2471
|
+
} else {
|
|
2472
|
+
specs = args;
|
|
2473
|
+
opts = undefined;
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
return {
|
|
2477
|
+
specs: specs,
|
|
2478
|
+
opts: opts
|
|
2479
|
+
};
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2460
2482
|
/**
|
|
2461
2483
|
* Hook that fetches and returns a React component for rendering the argument
|
|
2462
2484
|
* Plasmic component. Returns undefined if the component data is still
|