@plasmicapp/loader-react 1.0.183 → 1.0.185
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 +43 -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 +43 -23
- package/dist/loader-react.esm.js.map +1 -1
- package/dist/loader.d.ts +19 -0
- package/package.json +4 -4
package/dist/bundles.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ComponentMeta, LoaderBundleOutput } from '@plasmicapp/loader-core';
|
|
2
2
|
import type { ComponentRenderData } from './loader';
|
|
3
|
-
export declare function prepComponentData(bundle: LoaderBundleOutput,
|
|
3
|
+
export declare function prepComponentData(bundle: LoaderBundleOutput, compMetas: ComponentMeta[], opts?: {
|
|
4
|
+
target?: 'browser' | 'server';
|
|
5
|
+
}): ComponentRenderData;
|
|
4
6
|
export declare function mergeBundles(target: LoaderBundleOutput, from: LoaderBundleOutput): LoaderBundleOutput;
|
|
5
7
|
export declare const convertBundlesToComponentRenderData: (bundles: LoaderBundleOutput[], compMetas: ComponentMeta[]) => ComponentRenderData | null;
|
|
@@ -171,11 +171,7 @@ function getUsedComps(allComponents, entryCompIds) {
|
|
|
171
171
|
return usedComps;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
function prepComponentData(bundle) {
|
|
175
|
-
for (var _len = arguments.length, compMetas = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
176
|
-
compMetas[_key - 1] = arguments[_key];
|
|
177
|
-
}
|
|
178
|
-
|
|
174
|
+
function prepComponentData(bundle, compMetas, opts) {
|
|
179
175
|
if (compMetas.length === 0) {
|
|
180
176
|
return {
|
|
181
177
|
entryCompMetas: bundle.components,
|
|
@@ -190,7 +186,7 @@ function prepComponentData(bundle) {
|
|
|
190
186
|
var compPaths = usedComps.map(function (compMeta) {
|
|
191
187
|
return compMeta.entry;
|
|
192
188
|
});
|
|
193
|
-
var subBundle = loaderCore.getBundleSubset
|
|
189
|
+
var subBundle = loaderCore.getBundleSubset(bundle, ['entrypoint.css'].concat(compPaths, ['root-provider.js'], bundle.projects.map(function (x) {
|
|
194
190
|
return x.globalContextsProviderFileName;
|
|
195
191
|
}).filter(function (x) {
|
|
196
192
|
return !!x;
|
|
@@ -200,7 +196,7 @@ function prepComponentData(bundle) {
|
|
|
200
196
|
return c.entry;
|
|
201
197
|
}), bundle.globalGroups.map(function (g) {
|
|
202
198
|
return g.contextFile;
|
|
203
|
-
})));
|
|
199
|
+
})), opts);
|
|
204
200
|
var remoteFontUrls = [];
|
|
205
201
|
subBundle.projects.forEach(function (p) {
|
|
206
202
|
return remoteFontUrls.push.apply(remoteFontUrls, p.remoteFonts.map(function (f) {
|
|
@@ -315,7 +311,7 @@ var convertBundlesToComponentRenderData = function convertBundlesToComponentRend
|
|
|
315
311
|
var mergedBundles = bundles.reduce(function (prev, cur) {
|
|
316
312
|
return mergeBundles(prev, cur);
|
|
317
313
|
});
|
|
318
|
-
return prepComponentData
|
|
314
|
+
return prepComponentData(mergedBundles, compMetas);
|
|
319
315
|
};
|
|
320
316
|
|
|
321
317
|
function createCommonjsModule(fn, module) {
|
|
@@ -1752,9 +1748,9 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1752
1748
|
var _maybeFetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
1753
1749
|
var _this2 = this;
|
|
1754
1750
|
|
|
1755
|
-
var
|
|
1751
|
+
var _parseFetchComponentD,
|
|
1756
1752
|
specs,
|
|
1757
|
-
|
|
1753
|
+
opts,
|
|
1758
1754
|
returnWithSpecsToFetch,
|
|
1759
1755
|
_this$maybeGetCompMet,
|
|
1760
1756
|
existingMetas,
|
|
@@ -1765,9 +1761,7 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1765
1761
|
while (1) {
|
|
1766
1762
|
switch (_context2.prev = _context2.next) {
|
|
1767
1763
|
case 0:
|
|
1768
|
-
|
|
1769
|
-
specs[_key2] = _args2[_key2];
|
|
1770
|
-
}
|
|
1764
|
+
_parseFetchComponentD = parseFetchComponentDataArgs.apply(void 0, _args2), specs = _parseFetchComponentD.specs, opts = _parseFetchComponentD.opts;
|
|
1771
1765
|
|
|
1772
1766
|
returnWithSpecsToFetch = /*#__PURE__*/function () {
|
|
1773
1767
|
var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(specsToFetch) {
|
|
@@ -1793,7 +1787,7 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1793
1787
|
return _context.abrupt("return", null);
|
|
1794
1788
|
|
|
1795
1789
|
case 5:
|
|
1796
|
-
return _context.abrupt("return", prepComponentData
|
|
1790
|
+
return _context.abrupt("return", prepComponentData(_this2.bundle, existingMetas2, opts));
|
|
1797
1791
|
|
|
1798
1792
|
case 6:
|
|
1799
1793
|
case "end":
|
|
@@ -1828,7 +1822,7 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1828
1822
|
break;
|
|
1829
1823
|
}
|
|
1830
1824
|
|
|
1831
|
-
return _context2.abrupt("return", prepComponentData
|
|
1825
|
+
return _context2.abrupt("return", prepComponentData(this.bundle, existingMetas, opts));
|
|
1832
1826
|
|
|
1833
1827
|
case 9:
|
|
1834
1828
|
_context2.next = 11;
|
|
@@ -1854,7 +1848,10 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1854
1848
|
|
|
1855
1849
|
_proto.fetchComponentData = /*#__PURE__*/function () {
|
|
1856
1850
|
var _fetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
1857
|
-
var
|
|
1851
|
+
var _parseFetchComponentD2,
|
|
1852
|
+
specs,
|
|
1853
|
+
opts,
|
|
1854
|
+
data,
|
|
1858
1855
|
_this$maybeGetCompMet2,
|
|
1859
1856
|
missingSpecs,
|
|
1860
1857
|
_args3 = arguments;
|
|
@@ -1863,24 +1860,25 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1863
1860
|
while (1) {
|
|
1864
1861
|
switch (_context3.prev = _context3.next) {
|
|
1865
1862
|
case 0:
|
|
1866
|
-
|
|
1867
|
-
|
|
1863
|
+
_parseFetchComponentD2 = parseFetchComponentDataArgs.apply(void 0, _args3), specs = _parseFetchComponentD2.specs, opts = _parseFetchComponentD2.opts;
|
|
1864
|
+
_context3.next = 3;
|
|
1865
|
+
return this.maybeFetchComponentData(specs, opts);
|
|
1868
1866
|
|
|
1869
|
-
case
|
|
1867
|
+
case 3:
|
|
1870
1868
|
data = _context3.sent;
|
|
1871
1869
|
|
|
1872
1870
|
if (data) {
|
|
1873
|
-
_context3.next =
|
|
1871
|
+
_context3.next = 7;
|
|
1874
1872
|
break;
|
|
1875
1873
|
}
|
|
1876
1874
|
|
|
1877
|
-
_this$maybeGetCompMet2 = this.maybeGetCompMetas.apply(this,
|
|
1875
|
+
_this$maybeGetCompMet2 = this.maybeGetCompMetas.apply(this, specs), missingSpecs = _this$maybeGetCompMet2.missing;
|
|
1878
1876
|
throw new Error("Unable to find components " + missingSpecs.map(getLookupSpecName).join(', '));
|
|
1879
1877
|
|
|
1880
|
-
case
|
|
1878
|
+
case 7:
|
|
1881
1879
|
return _context3.abrupt("return", data);
|
|
1882
1880
|
|
|
1883
|
-
case
|
|
1881
|
+
case 8:
|
|
1884
1882
|
case "end":
|
|
1885
1883
|
return _context3.stop();
|
|
1886
1884
|
}
|
|
@@ -2460,6 +2458,28 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2460
2458
|
return PlasmicComponentLoader;
|
|
2461
2459
|
}();
|
|
2462
2460
|
|
|
2461
|
+
function parseFetchComponentDataArgs() {
|
|
2462
|
+
var specs;
|
|
2463
|
+
var opts;
|
|
2464
|
+
|
|
2465
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2466
|
+
args[_key2] = arguments[_key2];
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
if (Array.isArray(args[0])) {
|
|
2470
|
+
specs = args[0];
|
|
2471
|
+
opts = args[1];
|
|
2472
|
+
} else {
|
|
2473
|
+
specs = args;
|
|
2474
|
+
opts = undefined;
|
|
2475
|
+
}
|
|
2476
|
+
|
|
2477
|
+
return {
|
|
2478
|
+
specs: specs,
|
|
2479
|
+
opts: opts
|
|
2480
|
+
};
|
|
2481
|
+
}
|
|
2482
|
+
|
|
2463
2483
|
/**
|
|
2464
2484
|
* Hook that fetches and returns a React component for rendering the argument
|
|
2465
2485
|
* Plasmic component. Returns undefined if the component data is still
|