@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/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;
|
|
@@ -7,6 +7,7 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
|
|
|
7
7
|
var PlasmicHost = require('@plasmicapp/host');
|
|
8
8
|
var PlasmicQuery = require('@plasmicapp/query');
|
|
9
9
|
var loaderCore = require('@plasmicapp/loader-core');
|
|
10
|
+
var PlasmicDataSourcesContext = require('@plasmicapp/data-sources-context');
|
|
10
11
|
var loaderSplits = require('@plasmicapp/loader-splits');
|
|
11
12
|
var React = require('react');
|
|
12
13
|
var React__default = _interopDefault(React);
|
|
@@ -171,11 +172,7 @@ function getUsedComps(allComponents, entryCompIds) {
|
|
|
171
172
|
return usedComps;
|
|
172
173
|
}
|
|
173
174
|
|
|
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
|
-
|
|
175
|
+
function prepComponentData(bundle, compMetas, opts) {
|
|
179
176
|
if (compMetas.length === 0) {
|
|
180
177
|
return {
|
|
181
178
|
entryCompMetas: bundle.components,
|
|
@@ -190,7 +187,7 @@ function prepComponentData(bundle) {
|
|
|
190
187
|
var compPaths = usedComps.map(function (compMeta) {
|
|
191
188
|
return compMeta.entry;
|
|
192
189
|
});
|
|
193
|
-
var subBundle = loaderCore.getBundleSubset
|
|
190
|
+
var subBundle = loaderCore.getBundleSubset(bundle, ['entrypoint.css'].concat(compPaths, ['root-provider.js'], bundle.projects.map(function (x) {
|
|
194
191
|
return x.globalContextsProviderFileName;
|
|
195
192
|
}).filter(function (x) {
|
|
196
193
|
return !!x;
|
|
@@ -200,7 +197,7 @@ function prepComponentData(bundle) {
|
|
|
200
197
|
return c.entry;
|
|
201
198
|
}), bundle.globalGroups.map(function (g) {
|
|
202
199
|
return g.contextFile;
|
|
203
|
-
})));
|
|
200
|
+
})), opts);
|
|
204
201
|
var remoteFontUrls = [];
|
|
205
202
|
subBundle.projects.forEach(function (p) {
|
|
206
203
|
return remoteFontUrls.push.apply(remoteFontUrls, p.remoteFonts.map(function (f) {
|
|
@@ -315,7 +312,7 @@ var convertBundlesToComponentRenderData = function convertBundlesToComponentRend
|
|
|
315
312
|
var mergedBundles = bundles.reduce(function (prev, cur) {
|
|
316
313
|
return mergeBundles(prev, cur);
|
|
317
314
|
});
|
|
318
|
-
return prepComponentData
|
|
315
|
+
return prepComponentData(mergedBundles, compMetas);
|
|
319
316
|
};
|
|
320
317
|
|
|
321
318
|
function createCommonjsModule(fn, module) {
|
|
@@ -1631,6 +1628,7 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1631
1628
|
// Also inject @plasmicapp/query and @plasmicapp/host to use the
|
|
1632
1629
|
// same contexts here and in loader-downloaded code.
|
|
1633
1630
|
'@plasmicapp/query': PlasmicQuery,
|
|
1631
|
+
'@plasmicapp/data-sources-context': PlasmicDataSourcesContext,
|
|
1634
1632
|
'@plasmicapp/host': PlasmicHost,
|
|
1635
1633
|
'@plasmicapp/loader-runtime-registry': {
|
|
1636
1634
|
components: this.substitutedComponents,
|
|
@@ -1752,9 +1750,9 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1752
1750
|
var _maybeFetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
1753
1751
|
var _this2 = this;
|
|
1754
1752
|
|
|
1755
|
-
var
|
|
1753
|
+
var _parseFetchComponentD,
|
|
1756
1754
|
specs,
|
|
1757
|
-
|
|
1755
|
+
opts,
|
|
1758
1756
|
returnWithSpecsToFetch,
|
|
1759
1757
|
_this$maybeGetCompMet,
|
|
1760
1758
|
existingMetas,
|
|
@@ -1765,9 +1763,7 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1765
1763
|
while (1) {
|
|
1766
1764
|
switch (_context2.prev = _context2.next) {
|
|
1767
1765
|
case 0:
|
|
1768
|
-
|
|
1769
|
-
specs[_key2] = _args2[_key2];
|
|
1770
|
-
}
|
|
1766
|
+
_parseFetchComponentD = parseFetchComponentDataArgs.apply(void 0, _args2), specs = _parseFetchComponentD.specs, opts = _parseFetchComponentD.opts;
|
|
1771
1767
|
|
|
1772
1768
|
returnWithSpecsToFetch = /*#__PURE__*/function () {
|
|
1773
1769
|
var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(specsToFetch) {
|
|
@@ -1793,7 +1789,7 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1793
1789
|
return _context.abrupt("return", null);
|
|
1794
1790
|
|
|
1795
1791
|
case 5:
|
|
1796
|
-
return _context.abrupt("return", prepComponentData
|
|
1792
|
+
return _context.abrupt("return", prepComponentData(_this2.bundle, existingMetas2, opts));
|
|
1797
1793
|
|
|
1798
1794
|
case 6:
|
|
1799
1795
|
case "end":
|
|
@@ -1828,7 +1824,7 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1828
1824
|
break;
|
|
1829
1825
|
}
|
|
1830
1826
|
|
|
1831
|
-
return _context2.abrupt("return", prepComponentData
|
|
1827
|
+
return _context2.abrupt("return", prepComponentData(this.bundle, existingMetas, opts));
|
|
1832
1828
|
|
|
1833
1829
|
case 9:
|
|
1834
1830
|
_context2.next = 11;
|
|
@@ -1854,7 +1850,10 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1854
1850
|
|
|
1855
1851
|
_proto.fetchComponentData = /*#__PURE__*/function () {
|
|
1856
1852
|
var _fetchComponentData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
1857
|
-
var
|
|
1853
|
+
var _parseFetchComponentD2,
|
|
1854
|
+
specs,
|
|
1855
|
+
opts,
|
|
1856
|
+
data,
|
|
1858
1857
|
_this$maybeGetCompMet2,
|
|
1859
1858
|
missingSpecs,
|
|
1860
1859
|
_args3 = arguments;
|
|
@@ -1863,24 +1862,25 @@ var InternalPlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
1863
1862
|
while (1) {
|
|
1864
1863
|
switch (_context3.prev = _context3.next) {
|
|
1865
1864
|
case 0:
|
|
1866
|
-
|
|
1867
|
-
|
|
1865
|
+
_parseFetchComponentD2 = parseFetchComponentDataArgs.apply(void 0, _args3), specs = _parseFetchComponentD2.specs, opts = _parseFetchComponentD2.opts;
|
|
1866
|
+
_context3.next = 3;
|
|
1867
|
+
return this.maybeFetchComponentData(specs, opts);
|
|
1868
1868
|
|
|
1869
|
-
case
|
|
1869
|
+
case 3:
|
|
1870
1870
|
data = _context3.sent;
|
|
1871
1871
|
|
|
1872
1872
|
if (data) {
|
|
1873
|
-
_context3.next =
|
|
1873
|
+
_context3.next = 7;
|
|
1874
1874
|
break;
|
|
1875
1875
|
}
|
|
1876
1876
|
|
|
1877
|
-
_this$maybeGetCompMet2 = this.maybeGetCompMetas.apply(this,
|
|
1877
|
+
_this$maybeGetCompMet2 = this.maybeGetCompMetas.apply(this, specs), missingSpecs = _this$maybeGetCompMet2.missing;
|
|
1878
1878
|
throw new Error("Unable to find components " + missingSpecs.map(getLookupSpecName).join(', '));
|
|
1879
1879
|
|
|
1880
|
-
case
|
|
1880
|
+
case 7:
|
|
1881
1881
|
return _context3.abrupt("return", data);
|
|
1882
1882
|
|
|
1883
|
-
case
|
|
1883
|
+
case 8:
|
|
1884
1884
|
case "end":
|
|
1885
1885
|
return _context3.stop();
|
|
1886
1886
|
}
|
|
@@ -2460,6 +2460,28 @@ var PlasmicComponentLoader = /*#__PURE__*/function () {
|
|
|
2460
2460
|
return PlasmicComponentLoader;
|
|
2461
2461
|
}();
|
|
2462
2462
|
|
|
2463
|
+
function parseFetchComponentDataArgs() {
|
|
2464
|
+
var specs;
|
|
2465
|
+
var opts;
|
|
2466
|
+
|
|
2467
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2468
|
+
args[_key2] = arguments[_key2];
|
|
2469
|
+
}
|
|
2470
|
+
|
|
2471
|
+
if (Array.isArray(args[0])) {
|
|
2472
|
+
specs = args[0];
|
|
2473
|
+
opts = args[1];
|
|
2474
|
+
} else {
|
|
2475
|
+
specs = args;
|
|
2476
|
+
opts = undefined;
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2479
|
+
return {
|
|
2480
|
+
specs: specs,
|
|
2481
|
+
opts: opts
|
|
2482
|
+
};
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2463
2485
|
/**
|
|
2464
2486
|
* Hook that fetches and returns a React component for rendering the argument
|
|
2465
2487
|
* Plasmic component. Returns undefined if the component data is still
|