@plasmicapp/loader-react 1.0.343 → 1.0.345
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.esm.js +47 -56
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +47 -56
- package/dist/index.js.map +2 -2
- package/dist/react-server.esm.js +147 -154
- package/dist/react-server.esm.js.map +2 -2
- package/dist/react-server.js +147 -154
- package/dist/react-server.js.map +3 -3
- package/package.json +5 -5
package/dist/index.esm.js
CHANGED
|
@@ -217,17 +217,9 @@ function MaybeWrap(props) {
|
|
|
217
217
|
function uniq(elements) {
|
|
218
218
|
return Array.from(new Set(elements));
|
|
219
219
|
}
|
|
220
|
-
function
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
for (const elt of elements) {
|
|
224
|
-
const key = iterator(elt);
|
|
225
|
-
if (!vis.has(key)) {
|
|
226
|
-
vis.add(key);
|
|
227
|
-
filtered.push(elt);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return filtered;
|
|
220
|
+
function intersect(a, b) {
|
|
221
|
+
const setB = new Set(b);
|
|
222
|
+
return a.filter((elt) => setB.has(elt));
|
|
231
223
|
}
|
|
232
224
|
|
|
233
225
|
// src/variation.ts
|
|
@@ -576,14 +568,7 @@ function prepComponentData(bundle, compMetas, opts) {
|
|
|
576
568
|
};
|
|
577
569
|
}
|
|
578
570
|
function mergeBundles(target, from) {
|
|
579
|
-
var _a;
|
|
580
|
-
const existingCompIds = new Set(target.components.map((c) => c.id));
|
|
581
|
-
const newCompMetas = from.components.filter(
|
|
582
|
-
(m) => !existingCompIds.has(m.id)
|
|
583
|
-
);
|
|
584
|
-
if (newCompMetas.length > 0) {
|
|
585
|
-
target = __spreadProps(__spreadValues({}, target), { components: [...target.components, ...newCompMetas] });
|
|
586
|
-
}
|
|
571
|
+
var _a, _b, _c, _d, _e;
|
|
587
572
|
const existingProjects = new Set(target.projects.map((p) => p.id));
|
|
588
573
|
const newProjects = from.projects.filter((p) => !existingProjects.has(p.id));
|
|
589
574
|
if (newProjects.length > 0) {
|
|
@@ -591,6 +576,35 @@ function mergeBundles(target, from) {
|
|
|
591
576
|
projects: [...target.projects, ...newProjects]
|
|
592
577
|
});
|
|
593
578
|
}
|
|
579
|
+
const existingCompIds = new Set(target.components.map((c) => c.id));
|
|
580
|
+
function shouldIncludeComponentInBundle(c) {
|
|
581
|
+
if (existingCompIds.has(c.id)) {
|
|
582
|
+
return false;
|
|
583
|
+
}
|
|
584
|
+
if (!existingProjects.has(c.projectId)) {
|
|
585
|
+
return true;
|
|
586
|
+
}
|
|
587
|
+
if (!target.filteredIds[c.projectId]) {
|
|
588
|
+
return true;
|
|
589
|
+
}
|
|
590
|
+
return target.filteredIds[c.projectId].includes(c.id);
|
|
591
|
+
}
|
|
592
|
+
const newCompMetas = from.components.filter(
|
|
593
|
+
(m) => shouldIncludeComponentInBundle(m)
|
|
594
|
+
);
|
|
595
|
+
if (newCompMetas.length > 0) {
|
|
596
|
+
target = __spreadProps(__spreadValues({}, target), { components: [...target.components, ...newCompMetas] });
|
|
597
|
+
Object.entries(from.filteredIds).forEach(([projectId, ids]) => {
|
|
598
|
+
if (!target.filteredIds[projectId]) {
|
|
599
|
+
target.filteredIds[projectId] = [...ids];
|
|
600
|
+
} else {
|
|
601
|
+
target.filteredIds[projectId] = intersect(
|
|
602
|
+
target.filteredIds[projectId],
|
|
603
|
+
ids
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
}
|
|
594
608
|
const existingModules = {
|
|
595
609
|
browser: new Set(target.modules.browser.map((m) => m.fileName)),
|
|
596
610
|
server: new Set(target.modules.server.map((m) => m.fileName))
|
|
@@ -621,12 +635,18 @@ function mergeBundles(target, from) {
|
|
|
621
635
|
});
|
|
622
636
|
}
|
|
623
637
|
const existingSplitIds = new Set(target.activeSplits.map((s) => s.id));
|
|
624
|
-
const newSplits = (_a = from.activeSplits.filter(
|
|
638
|
+
const newSplits = (_a = from.activeSplits.filter(
|
|
639
|
+
// Don't include splits belonging to projects already present
|
|
640
|
+
// in the target bundle
|
|
641
|
+
(s) => !existingSplitIds.has(s.id) && !existingProjects.has(s.projectId)
|
|
642
|
+
)) != null ? _a : [];
|
|
625
643
|
if (newSplits.length > 0) {
|
|
626
644
|
target = __spreadProps(__spreadValues({}, target), {
|
|
627
645
|
activeSplits: [...target.activeSplits, ...newSplits]
|
|
628
646
|
});
|
|
629
647
|
}
|
|
648
|
+
target.bundleKey = (_c = (_b = target.bundleKey) != null ? _b : from.bundleKey) != null ? _c : null;
|
|
649
|
+
target.deferChunksByDefault = (_e = (_d = target.deferChunksByDefault) != null ? _d : from.deferChunksByDefault) != null ? _e : false;
|
|
630
650
|
return target;
|
|
631
651
|
}
|
|
632
652
|
var convertBundlesToComponentRenderData = (bundles, compMetas) => {
|
|
@@ -742,7 +762,8 @@ var BaseInternalPlasmicComponentLoader = class {
|
|
|
742
762
|
projects: [],
|
|
743
763
|
activeSplits: [],
|
|
744
764
|
bundleKey: null,
|
|
745
|
-
deferChunksByDefault: false
|
|
765
|
+
deferChunksByDefault: false,
|
|
766
|
+
filteredIds: {}
|
|
746
767
|
};
|
|
747
768
|
this.opts = args.opts;
|
|
748
769
|
this.fetcher = args.fetcher;
|
|
@@ -853,7 +874,7 @@ var BaseInternalPlasmicComponentLoader = class {
|
|
|
853
874
|
});
|
|
854
875
|
}
|
|
855
876
|
mergeBundle(newBundle) {
|
|
856
|
-
var _a, _b
|
|
877
|
+
var _a, _b;
|
|
857
878
|
newBundle.bundleKey = (_a = newBundle.bundleKey) != null ? _a : null;
|
|
858
879
|
if (newBundle.bundleKey && this.bundle.bundleKey && newBundle.bundleKey !== this.bundle.bundleKey) {
|
|
859
880
|
console.warn(
|
|
@@ -863,39 +884,8 @@ ${newBundle.bundleKey}
|
|
|
863
884
|
${this.bundle.bundleKey}`
|
|
864
885
|
);
|
|
865
886
|
}
|
|
866
|
-
|
|
867
|
-
this.
|
|
868
|
-
activeSplits: uniqBy(
|
|
869
|
-
bundles.flatMap((bundle) => bundle.activeSplits),
|
|
870
|
-
(split) => split.id
|
|
871
|
-
),
|
|
872
|
-
components: uniqBy(
|
|
873
|
-
bundles.flatMap((bundle) => bundle.components),
|
|
874
|
-
(c) => c.id
|
|
875
|
-
),
|
|
876
|
-
globalGroups: uniqBy(
|
|
877
|
-
bundles.flatMap((bundle) => bundle.globalGroups),
|
|
878
|
-
(g) => g.id
|
|
879
|
-
),
|
|
880
|
-
modules: {
|
|
881
|
-
browser: uniqBy(
|
|
882
|
-
bundles.flatMap((bundle) => bundle.modules.browser),
|
|
883
|
-
(m) => m.fileName
|
|
884
|
-
),
|
|
885
|
-
server: uniqBy(
|
|
886
|
-
bundles.flatMap((bundle) => bundle.modules.server),
|
|
887
|
-
(m) => m.fileName
|
|
888
|
-
)
|
|
889
|
-
},
|
|
890
|
-
projects: uniqBy(
|
|
891
|
-
bundles.flatMap((bundle) => bundle.projects),
|
|
892
|
-
(p) => p.id
|
|
893
|
-
),
|
|
894
|
-
// Avoid `undefined` as it cannot be serialized as JSON
|
|
895
|
-
bundleKey: (_c = (_b = newBundle.bundleKey) != null ? _b : this.bundle.bundleKey) != null ? _c : null,
|
|
896
|
-
deferChunksByDefault: (_d = newBundle.deferChunksByDefault) != null ? _d : false
|
|
897
|
-
};
|
|
898
|
-
(_e = this.onBundleMerged) == null ? void 0 : _e.call(this);
|
|
887
|
+
this.bundle = mergeBundles(newBundle, this.bundle);
|
|
888
|
+
(_b = this.onBundleMerged) == null ? void 0 : _b.call(this);
|
|
899
889
|
}
|
|
900
890
|
getBundle() {
|
|
901
891
|
return this.bundle;
|
|
@@ -911,7 +901,8 @@ ${this.bundle.bundleKey}`
|
|
|
911
901
|
projects: [],
|
|
912
902
|
activeSplits: [],
|
|
913
903
|
bundleKey: null,
|
|
914
|
-
deferChunksByDefault: false
|
|
904
|
+
deferChunksByDefault: false,
|
|
905
|
+
filteredIds: {}
|
|
915
906
|
};
|
|
916
907
|
this.registry.clear();
|
|
917
908
|
}
|