@plasmicapp/loader-react 1.0.341 → 1.0.343
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.d.ts +242 -70
- package/dist/index.esm.js +382 -318
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +376 -313
- package/dist/index.js.map +4 -4
- package/dist/react-server.d.ts +377 -32
- package/dist/react-server.esm.js +1089 -38
- package/dist/react-server.esm.js.map +4 -4
- package/dist/react-server.js +1084 -37
- package/dist/react-server.js.map +4 -4
- package/package.json +6 -6
package/dist/index.esm.js
CHANGED
|
@@ -51,7 +51,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
51
51
|
});
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
// src/loader.ts
|
|
54
|
+
// src/loader-client.ts
|
|
55
55
|
import * as PlasmicDataSourcesContext from "@plasmicapp/data-sources-context";
|
|
56
56
|
import * as PlasmicHost from "@plasmicapp/host";
|
|
57
57
|
import {
|
|
@@ -62,21 +62,18 @@ import {
|
|
|
62
62
|
registerTrait,
|
|
63
63
|
stateHelpersKeys
|
|
64
64
|
} from "@plasmicapp/host";
|
|
65
|
-
import {
|
|
66
|
-
PlasmicModulesFetcher,
|
|
67
|
-
PlasmicTracker,
|
|
68
|
-
Registry
|
|
69
|
-
} from "@plasmicapp/loader-core";
|
|
70
|
-
import {
|
|
71
|
-
internal_getCachedBundleInNodeServer
|
|
72
|
-
} from "@plasmicapp/loader-fetcher";
|
|
73
|
-
import { getActiveVariation, getExternalIds } from "@plasmicapp/loader-splits";
|
|
65
|
+
import { PlasmicModulesFetcher as PlasmicModulesFetcher2, PlasmicTracker as PlasmicTracker2 } from "@plasmicapp/loader-core";
|
|
74
66
|
import * as PlasmicQuery from "@plasmicapp/query";
|
|
75
67
|
import React3 from "react";
|
|
76
68
|
import ReactDOM from "react-dom";
|
|
77
69
|
import * as jsxDevRuntime from "react/jsx-dev-runtime";
|
|
78
70
|
import * as jsxRuntime from "react/jsx-runtime";
|
|
79
71
|
|
|
72
|
+
// src/PlasmicRootProvider.tsx
|
|
73
|
+
import { PageParamsProvider } from "@plasmicapp/host";
|
|
74
|
+
import { PlasmicQueryDataProvider } from "@plasmicapp/query";
|
|
75
|
+
import * as React2 from "react";
|
|
76
|
+
|
|
80
77
|
// src/utils.tsx
|
|
81
78
|
import pascalcase from "pascalcase";
|
|
82
79
|
import * as React from "react";
|
|
@@ -220,80 +217,18 @@ function MaybeWrap(props) {
|
|
|
220
217
|
function uniq(elements) {
|
|
221
218
|
return Array.from(new Set(elements));
|
|
222
219
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
this.bundle = bundle;
|
|
232
|
-
this.registry = registry;
|
|
233
|
-
}
|
|
234
|
-
getComponentMeta(spec) {
|
|
235
|
-
const compMeta = getFirstCompMeta(this.bundle.components, spec);
|
|
236
|
-
return compMeta;
|
|
237
|
-
}
|
|
238
|
-
getComponent(spec, opts = {}) {
|
|
239
|
-
const compMeta = getFirstCompMeta(this.bundle.components, spec);
|
|
240
|
-
if (!compMeta) {
|
|
241
|
-
throw new Error(`Component not found: ${spec}`);
|
|
242
|
-
}
|
|
243
|
-
const moduleName = compMeta.entry;
|
|
244
|
-
if (!this.registry.hasModule(moduleName, opts)) {
|
|
245
|
-
throw new Error(`Component not yet fetched: ${compMeta.name}`);
|
|
246
|
-
}
|
|
247
|
-
const entry = this.registry.load(moduleName, {
|
|
248
|
-
forceOriginal: opts.forceOriginal
|
|
249
|
-
});
|
|
250
|
-
return !opts.forceOriginal && typeof (entry == null ? void 0 : entry.getPlasmicComponent) === "function" ? entry.getPlasmicComponent() : entry.default;
|
|
251
|
-
}
|
|
252
|
-
hasComponent(spec) {
|
|
253
|
-
const compMeta = getFirstCompMeta(this.bundle.components, spec);
|
|
254
|
-
if (compMeta) {
|
|
255
|
-
return this.registry.hasModule(compMeta.entry);
|
|
256
|
-
}
|
|
257
|
-
return false;
|
|
258
|
-
}
|
|
259
|
-
getGlobalContexts() {
|
|
260
|
-
const customGlobalMetas = this.bundle.globalGroups.filter(
|
|
261
|
-
(m) => m.type === "global-user-defined"
|
|
262
|
-
);
|
|
263
|
-
return customGlobalMetas.map((meta) => ({
|
|
264
|
-
meta,
|
|
265
|
-
context: this.registry.load(meta.contextFile).default
|
|
266
|
-
}));
|
|
267
|
-
}
|
|
268
|
-
getGlobalContextsProvider(spec) {
|
|
269
|
-
const compMeta = getFirstCompMeta(this.bundle.components, spec);
|
|
270
|
-
const projectMeta = compMeta ? this.bundle.projects.find((x) => x.id === compMeta.projectId) : void 0;
|
|
271
|
-
if (!projectMeta || !projectMeta.globalContextsProviderFileName || !this.registry.hasModule(projectMeta.globalContextsProviderFileName)) {
|
|
272
|
-
return void 0;
|
|
220
|
+
function uniqBy(elements, iterator) {
|
|
221
|
+
const vis = /* @__PURE__ */ new Set();
|
|
222
|
+
const filtered = [];
|
|
223
|
+
for (const elt of elements) {
|
|
224
|
+
const key = iterator(elt);
|
|
225
|
+
if (!vis.has(key)) {
|
|
226
|
+
vis.add(key);
|
|
227
|
+
filtered.push(elt);
|
|
273
228
|
}
|
|
274
|
-
const entry = this.registry.load(
|
|
275
|
-
projectMeta.globalContextsProviderFileName
|
|
276
|
-
);
|
|
277
|
-
return typeof (entry == null ? void 0 : entry.getPlasmicComponent) === "function" ? entry.getPlasmicComponent() : entry.default;
|
|
278
|
-
}
|
|
279
|
-
getRootProvider() {
|
|
280
|
-
const entry = this.registry.load("root-provider.js");
|
|
281
|
-
return entry.default;
|
|
282
|
-
}
|
|
283
|
-
getCss() {
|
|
284
|
-
return this.bundle.modules.browser.filter(
|
|
285
|
-
(mod) => mod.type === "asset" && mod.fileName.endsWith("css")
|
|
286
|
-
);
|
|
287
229
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
// src/PlasmicRootProvider.tsx
|
|
294
|
-
import { PageParamsProvider } from "@plasmicapp/host";
|
|
295
|
-
import { PlasmicQueryDataProvider } from "@plasmicapp/query";
|
|
296
|
-
import * as React2 from "react";
|
|
230
|
+
return filtered;
|
|
231
|
+
}
|
|
297
232
|
|
|
298
233
|
// src/variation.ts
|
|
299
234
|
function getPlasmicCookieValues() {
|
|
@@ -377,7 +312,7 @@ function PlasmicRootProvider(props) {
|
|
|
377
312
|
} = props;
|
|
378
313
|
const loader = props.loader.__internal;
|
|
379
314
|
if (prefetchedData) {
|
|
380
|
-
loader.registerPrefetchedBundle(prefetchedData
|
|
315
|
+
loader.registerPrefetchedBundle(prefetchedData.bundle);
|
|
381
316
|
}
|
|
382
317
|
const [splits, setSplits] = React2.useState(loader.getActiveSplits());
|
|
383
318
|
const forceUpdate = useForceUpdate();
|
|
@@ -394,6 +329,66 @@ function PlasmicRootProvider(props) {
|
|
|
394
329
|
loader.subscribePlasmicRoot(watcher);
|
|
395
330
|
return () => loader.unsubscribePlasmicRoot(watcher);
|
|
396
331
|
}, [watcher, loader]);
|
|
332
|
+
const currentContextValue = React2.useContext(PlasmicRootContext);
|
|
333
|
+
const { user, userAuthToken, isUserLoading, authRedirectUri } = props;
|
|
334
|
+
const value = React2.useMemo(() => {
|
|
335
|
+
var _a, _b, _c;
|
|
336
|
+
const withCurrentContextValueFallback = (v, key) => {
|
|
337
|
+
return v !== void 0 ? v : currentContextValue == null ? void 0 : currentContextValue[key];
|
|
338
|
+
};
|
|
339
|
+
return {
|
|
340
|
+
globalVariants: [
|
|
341
|
+
...mergeGlobalVariantsSpec(
|
|
342
|
+
globalVariants != null ? globalVariants : [],
|
|
343
|
+
getGlobalVariantsFromSplits(splits, variation != null ? variation : {})
|
|
344
|
+
),
|
|
345
|
+
...(_a = currentContextValue == null ? void 0 : currentContextValue.globalVariants) != null ? _a : []
|
|
346
|
+
],
|
|
347
|
+
globalContextsProps: __spreadValues(__spreadValues({}, (_b = currentContextValue == null ? void 0 : currentContextValue.globalContextsProps) != null ? _b : {}), globalContextsProps != null ? globalContextsProps : {}),
|
|
348
|
+
loader: withCurrentContextValueFallback(loader, "loader"),
|
|
349
|
+
variation: __spreadValues(__spreadValues({}, (_c = currentContextValue == null ? void 0 : currentContextValue.variation) != null ? _c : {}), variation != null ? variation : {}),
|
|
350
|
+
translator: withCurrentContextValueFallback(translator, "translator"),
|
|
351
|
+
Head: withCurrentContextValueFallback(Head, "Head"),
|
|
352
|
+
Link: withCurrentContextValueFallback(Link, "Link"),
|
|
353
|
+
user: withCurrentContextValueFallback(user, "user"),
|
|
354
|
+
userAuthToken: withCurrentContextValueFallback(
|
|
355
|
+
userAuthToken,
|
|
356
|
+
"userAuthToken"
|
|
357
|
+
),
|
|
358
|
+
isUserLoading: withCurrentContextValueFallback(
|
|
359
|
+
isUserLoading,
|
|
360
|
+
"isUserLoading"
|
|
361
|
+
),
|
|
362
|
+
authRedirectUri: withCurrentContextValueFallback(
|
|
363
|
+
authRedirectUri,
|
|
364
|
+
"authRedirectUri"
|
|
365
|
+
),
|
|
366
|
+
suspenseFallback: withCurrentContextValueFallback(
|
|
367
|
+
suspenseFallback,
|
|
368
|
+
"suspenseFallback"
|
|
369
|
+
),
|
|
370
|
+
disableLoadingBoundary: withCurrentContextValueFallback(
|
|
371
|
+
disableLoadingBoundary,
|
|
372
|
+
"disableLoadingBoundary"
|
|
373
|
+
)
|
|
374
|
+
};
|
|
375
|
+
}, [
|
|
376
|
+
globalVariants,
|
|
377
|
+
variation,
|
|
378
|
+
globalContextsProps,
|
|
379
|
+
loader,
|
|
380
|
+
splits,
|
|
381
|
+
translator,
|
|
382
|
+
Head,
|
|
383
|
+
Link,
|
|
384
|
+
user,
|
|
385
|
+
userAuthToken,
|
|
386
|
+
isUserLoading,
|
|
387
|
+
authRedirectUri,
|
|
388
|
+
suspenseFallback,
|
|
389
|
+
disableLoadingBoundary,
|
|
390
|
+
currentContextValue
|
|
391
|
+
]);
|
|
397
392
|
React2.useEffect(() => {
|
|
398
393
|
ensureVariationCookies(variation);
|
|
399
394
|
loader.trackRender({
|
|
@@ -403,46 +398,9 @@ function PlasmicRootProvider(props) {
|
|
|
403
398
|
teamIds: loader.getTeamIds(),
|
|
404
399
|
projectIds: loader.getProjectIds()
|
|
405
400
|
},
|
|
406
|
-
variation
|
|
401
|
+
variation: value.variation
|
|
407
402
|
});
|
|
408
|
-
}, [loader,
|
|
409
|
-
const { user, userAuthToken, isUserLoading, authRedirectUri } = props;
|
|
410
|
-
const value = React2.useMemo(
|
|
411
|
-
() => ({
|
|
412
|
-
globalVariants: mergeGlobalVariantsSpec(
|
|
413
|
-
globalVariants != null ? globalVariants : [],
|
|
414
|
-
getGlobalVariantsFromSplits(splits, variation != null ? variation : {})
|
|
415
|
-
),
|
|
416
|
-
globalContextsProps,
|
|
417
|
-
loader,
|
|
418
|
-
variation,
|
|
419
|
-
translator,
|
|
420
|
-
Head,
|
|
421
|
-
Link,
|
|
422
|
-
user,
|
|
423
|
-
userAuthToken,
|
|
424
|
-
isUserLoading,
|
|
425
|
-
authRedirectUri,
|
|
426
|
-
suspenseFallback,
|
|
427
|
-
disableLoadingBoundary
|
|
428
|
-
}),
|
|
429
|
-
[
|
|
430
|
-
globalVariants,
|
|
431
|
-
variation,
|
|
432
|
-
globalContextsProps,
|
|
433
|
-
loader,
|
|
434
|
-
splits,
|
|
435
|
-
translator,
|
|
436
|
-
Head,
|
|
437
|
-
Link,
|
|
438
|
-
user,
|
|
439
|
-
userAuthToken,
|
|
440
|
-
isUserLoading,
|
|
441
|
-
authRedirectUri,
|
|
442
|
-
suspenseFallback,
|
|
443
|
-
disableLoadingBoundary
|
|
444
|
-
]
|
|
445
|
-
);
|
|
403
|
+
}, [loader, value]);
|
|
446
404
|
const reactMajorVersion = +React2.version.split(".")[0];
|
|
447
405
|
return /* @__PURE__ */ React2.createElement(
|
|
448
406
|
PlasmicQueryDataProvider,
|
|
@@ -537,6 +495,15 @@ function createUseGlobalVariant(name, projectId) {
|
|
|
537
495
|
};
|
|
538
496
|
}
|
|
539
497
|
|
|
498
|
+
// src/loader-shared.ts
|
|
499
|
+
import {
|
|
500
|
+
Registry
|
|
501
|
+
} from "@plasmicapp/loader-core";
|
|
502
|
+
import {
|
|
503
|
+
internal_getCachedBundleInNodeServer
|
|
504
|
+
} from "@plasmicapp/loader-fetcher";
|
|
505
|
+
import { getActiveVariation, getExternalIds } from "@plasmicapp/loader-splits";
|
|
506
|
+
|
|
540
507
|
// src/bundles.ts
|
|
541
508
|
import {
|
|
542
509
|
getBundleSubset
|
|
@@ -653,11 +620,6 @@ function mergeBundles(target, from) {
|
|
|
653
620
|
globalGroups: [...target.globalGroups, ...newGlobals]
|
|
654
621
|
});
|
|
655
622
|
}
|
|
656
|
-
const existingExternals = new Set(target.external);
|
|
657
|
-
const newExternals = target.external.filter((x) => !existingExternals.has(x));
|
|
658
|
-
if (newExternals.length > 0) {
|
|
659
|
-
target = __spreadProps(__spreadValues({}, target), { external: [...target.external, ...newExternals] });
|
|
660
|
-
}
|
|
661
623
|
const existingSplitIds = new Set(target.activeSplits.map((s) => s.id));
|
|
662
624
|
const newSplits = (_a = from.activeSplits.filter((s) => !existingSplitIds.has(s.id))) != null ? _a : [];
|
|
663
625
|
if (newSplits.length > 0) {
|
|
@@ -675,9 +637,101 @@ var convertBundlesToComponentRenderData = (bundles, compMetas) => {
|
|
|
675
637
|
return prepComponentData(mergedBundles, compMetas);
|
|
676
638
|
};
|
|
677
639
|
|
|
678
|
-
// src/
|
|
679
|
-
|
|
640
|
+
// src/component-lookup.ts
|
|
641
|
+
function getFirstCompMeta(metas, lookup) {
|
|
642
|
+
const filtered = getCompMetas(metas, lookup);
|
|
643
|
+
return filtered.length === 0 ? void 0 : filtered[0];
|
|
644
|
+
}
|
|
645
|
+
var ComponentLookup = class {
|
|
646
|
+
constructor(bundle, registry) {
|
|
647
|
+
this.bundle = bundle;
|
|
648
|
+
this.registry = registry;
|
|
649
|
+
}
|
|
650
|
+
getComponentMeta(spec) {
|
|
651
|
+
const compMeta = getFirstCompMeta(this.bundle.components, spec);
|
|
652
|
+
return compMeta;
|
|
653
|
+
}
|
|
654
|
+
getComponent(spec, opts = {}) {
|
|
655
|
+
const compMeta = getFirstCompMeta(this.bundle.components, spec);
|
|
656
|
+
if (!compMeta) {
|
|
657
|
+
throw new Error(`Component not found: ${spec}`);
|
|
658
|
+
}
|
|
659
|
+
const moduleName = compMeta.entry;
|
|
660
|
+
if (!this.registry.hasModule(moduleName, opts)) {
|
|
661
|
+
throw new Error(`Component not yet fetched: ${compMeta.name}`);
|
|
662
|
+
}
|
|
663
|
+
const entry = this.registry.load(moduleName, {
|
|
664
|
+
forceOriginal: opts.forceOriginal
|
|
665
|
+
});
|
|
666
|
+
return !opts.forceOriginal && typeof (entry == null ? void 0 : entry.getPlasmicComponent) === "function" ? entry.getPlasmicComponent() : entry.default;
|
|
667
|
+
}
|
|
668
|
+
hasComponent(spec) {
|
|
669
|
+
const compMeta = getFirstCompMeta(this.bundle.components, spec);
|
|
670
|
+
if (compMeta) {
|
|
671
|
+
return this.registry.hasModule(compMeta.entry);
|
|
672
|
+
}
|
|
673
|
+
return false;
|
|
674
|
+
}
|
|
675
|
+
getGlobalContexts() {
|
|
676
|
+
const customGlobalMetas = this.bundle.globalGroups.filter(
|
|
677
|
+
(m) => m.type === "global-user-defined"
|
|
678
|
+
);
|
|
679
|
+
return customGlobalMetas.map((meta) => ({
|
|
680
|
+
meta,
|
|
681
|
+
context: this.registry.load(meta.contextFile).default
|
|
682
|
+
}));
|
|
683
|
+
}
|
|
684
|
+
getGlobalContextsProvider(spec) {
|
|
685
|
+
const compMeta = getFirstCompMeta(this.bundle.components, spec);
|
|
686
|
+
const projectMeta = compMeta ? this.bundle.projects.find((x) => x.id === compMeta.projectId) : void 0;
|
|
687
|
+
if (!projectMeta || !projectMeta.globalContextsProviderFileName || !this.registry.hasModule(projectMeta.globalContextsProviderFileName)) {
|
|
688
|
+
return void 0;
|
|
689
|
+
}
|
|
690
|
+
const entry = this.registry.load(
|
|
691
|
+
projectMeta.globalContextsProviderFileName
|
|
692
|
+
);
|
|
693
|
+
return typeof (entry == null ? void 0 : entry.getPlasmicComponent) === "function" ? entry.getPlasmicComponent() : entry.default;
|
|
694
|
+
}
|
|
695
|
+
getRootProvider() {
|
|
696
|
+
const entry = this.registry.load("root-provider.js");
|
|
697
|
+
return entry.default;
|
|
698
|
+
}
|
|
699
|
+
getCss() {
|
|
700
|
+
return this.bundle.modules.browser.filter(
|
|
701
|
+
(mod) => mod.type === "asset" && mod.fileName.endsWith("css")
|
|
702
|
+
);
|
|
703
|
+
}
|
|
704
|
+
getRemoteFonts() {
|
|
705
|
+
return this.bundle.projects.flatMap((p) => p.remoteFonts);
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
// src/loader-shared.ts
|
|
710
|
+
var SUBSTITUTED_COMPONENTS = {};
|
|
711
|
+
var REGISTERED_CODE_COMPONENT_HELPERS = {};
|
|
712
|
+
var SUBSTITUTED_GLOBAL_VARIANT_HOOKS = {};
|
|
713
|
+
var REGISTERED_CUSTOM_FUNCTIONS = {};
|
|
714
|
+
function customFunctionImportAlias(meta) {
|
|
715
|
+
const customFunctionPrefix = `__fn_`;
|
|
716
|
+
return meta.namespace ? `${customFunctionPrefix}${meta.namespace}__${meta.name}` : `${customFunctionPrefix}${meta.name}`;
|
|
717
|
+
}
|
|
718
|
+
function parseFetchComponentDataArgs(...args) {
|
|
719
|
+
let specs;
|
|
720
|
+
let opts;
|
|
721
|
+
if (Array.isArray(args[0])) {
|
|
722
|
+
specs = args[0];
|
|
723
|
+
opts = args[1];
|
|
724
|
+
} else {
|
|
725
|
+
specs = args;
|
|
726
|
+
opts = void 0;
|
|
727
|
+
}
|
|
728
|
+
return { specs, opts };
|
|
729
|
+
}
|
|
730
|
+
var BaseInternalPlasmicComponentLoader = class {
|
|
680
731
|
constructor(args) {
|
|
732
|
+
this.registry = new Registry();
|
|
733
|
+
this.globalVariants = [];
|
|
734
|
+
this.subs = [];
|
|
681
735
|
this.bundle = {
|
|
682
736
|
modules: {
|
|
683
737
|
browser: [],
|
|
@@ -685,7 +739,6 @@ var ReactServerPlasmicComponentLoader = class {
|
|
|
685
739
|
},
|
|
686
740
|
components: [],
|
|
687
741
|
globalGroups: [],
|
|
688
|
-
external: [],
|
|
689
742
|
projects: [],
|
|
690
743
|
activeSplits: [],
|
|
691
744
|
bundleKey: null,
|
|
@@ -696,6 +749,7 @@ var ReactServerPlasmicComponentLoader = class {
|
|
|
696
749
|
this.tracker = args.tracker;
|
|
697
750
|
this.onBundleMerged = args.onBundleMerged;
|
|
698
751
|
this.onBundleFetched = args.onBundleFetched;
|
|
752
|
+
this.registerModules(args.builtinModules);
|
|
699
753
|
}
|
|
700
754
|
maybeGetCompMetas(...specs) {
|
|
701
755
|
const found = /* @__PURE__ */ new Set();
|
|
@@ -798,11 +852,50 @@ var ReactServerPlasmicComponentLoader = class {
|
|
|
798
852
|
return bundle;
|
|
799
853
|
});
|
|
800
854
|
}
|
|
801
|
-
mergeBundle(
|
|
802
|
-
var _a, _b;
|
|
803
|
-
|
|
804
|
-
this.bundle.bundleKey
|
|
805
|
-
|
|
855
|
+
mergeBundle(newBundle) {
|
|
856
|
+
var _a, _b, _c, _d, _e;
|
|
857
|
+
newBundle.bundleKey = (_a = newBundle.bundleKey) != null ? _a : null;
|
|
858
|
+
if (newBundle.bundleKey && this.bundle.bundleKey && newBundle.bundleKey !== this.bundle.bundleKey) {
|
|
859
|
+
console.warn(
|
|
860
|
+
`Plasmic Error: Different code export hashes. This can happen if your app is using different loaders with different project IDs or project versions.
|
|
861
|
+
Conflicting values:
|
|
862
|
+
${newBundle.bundleKey}
|
|
863
|
+
${this.bundle.bundleKey}`
|
|
864
|
+
);
|
|
865
|
+
}
|
|
866
|
+
const bundles = [this.bundle, newBundle];
|
|
867
|
+
this.bundle = {
|
|
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);
|
|
806
899
|
}
|
|
807
900
|
getBundle() {
|
|
808
901
|
return this.bundle;
|
|
@@ -815,89 +908,12 @@ var ReactServerPlasmicComponentLoader = class {
|
|
|
815
908
|
},
|
|
816
909
|
components: [],
|
|
817
910
|
globalGroups: [],
|
|
818
|
-
external: [],
|
|
819
911
|
projects: [],
|
|
820
912
|
activeSplits: [],
|
|
821
913
|
bundleKey: null,
|
|
822
914
|
deferChunksByDefault: false
|
|
823
915
|
};
|
|
824
|
-
|
|
825
|
-
};
|
|
826
|
-
function parseFetchComponentDataArgs(...args) {
|
|
827
|
-
let specs;
|
|
828
|
-
let opts;
|
|
829
|
-
if (Array.isArray(args[0])) {
|
|
830
|
-
specs = args[0];
|
|
831
|
-
opts = args[1];
|
|
832
|
-
} else {
|
|
833
|
-
specs = args;
|
|
834
|
-
opts = void 0;
|
|
835
|
-
}
|
|
836
|
-
return { specs, opts };
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
// src/loader.ts
|
|
840
|
-
var SUBSTITUTED_COMPONENTS = {};
|
|
841
|
-
var REGISTERED_CODE_COMPONENT_HELPERS = {};
|
|
842
|
-
var SUBSTITUTED_GLOBAL_VARIANT_HOOKS = {};
|
|
843
|
-
var REGISTERED_CUSTOM_FUNCTIONS = {};
|
|
844
|
-
function customFunctionImportAlias(meta) {
|
|
845
|
-
const customFunctionPrefix = `__fn_`;
|
|
846
|
-
return meta.namespace ? `${customFunctionPrefix}${meta.namespace}__${meta.name}` : `${customFunctionPrefix}${meta.name}`;
|
|
847
|
-
}
|
|
848
|
-
var InternalPlasmicComponentLoader = class {
|
|
849
|
-
constructor(opts) {
|
|
850
|
-
this.opts = opts;
|
|
851
|
-
this.registry = new Registry();
|
|
852
|
-
this.subs = [];
|
|
853
|
-
this.roots = [];
|
|
854
|
-
this.globalVariants = [];
|
|
855
|
-
this.tracker = new PlasmicTracker({
|
|
856
|
-
projectIds: opts.projects.map((p) => p.id),
|
|
857
|
-
platform: opts.platform,
|
|
858
|
-
preview: opts.preview,
|
|
859
|
-
nativeFetch: opts.nativeFetch
|
|
860
|
-
});
|
|
861
|
-
this.reactServerLoader = new ReactServerPlasmicComponentLoader({
|
|
862
|
-
opts,
|
|
863
|
-
fetcher: new PlasmicModulesFetcher(opts),
|
|
864
|
-
tracker: this.tracker,
|
|
865
|
-
onBundleMerged: () => {
|
|
866
|
-
this.refreshRegistry();
|
|
867
|
-
},
|
|
868
|
-
onBundleFetched: () => {
|
|
869
|
-
this.roots.forEach((watcher) => {
|
|
870
|
-
var _a;
|
|
871
|
-
return (_a = watcher.onDataFetched) == null ? void 0 : _a.call(watcher);
|
|
872
|
-
});
|
|
873
|
-
}
|
|
874
|
-
});
|
|
875
|
-
this.registerModules({
|
|
876
|
-
react: React3,
|
|
877
|
-
"react-dom": ReactDOM,
|
|
878
|
-
"react/jsx-runtime": jsxRuntime,
|
|
879
|
-
"react/jsx-dev-runtime": jsxDevRuntime,
|
|
880
|
-
// Also inject @plasmicapp/query and @plasmicapp/host to use the
|
|
881
|
-
// same contexts here and in loader-downloaded code.
|
|
882
|
-
"@plasmicapp/query": PlasmicQuery,
|
|
883
|
-
"@plasmicapp/data-sources-context": PlasmicDataSourcesContext,
|
|
884
|
-
"@plasmicapp/host": PlasmicHost,
|
|
885
|
-
"@plasmicapp/loader-runtime-registry": {
|
|
886
|
-
components: SUBSTITUTED_COMPONENTS,
|
|
887
|
-
globalVariantHooks: SUBSTITUTED_GLOBAL_VARIANT_HOOKS,
|
|
888
|
-
codeComponentHelpers: REGISTERED_CODE_COMPONENT_HELPERS,
|
|
889
|
-
functions: REGISTERED_CUSTOM_FUNCTIONS
|
|
890
|
-
}
|
|
891
|
-
});
|
|
892
|
-
}
|
|
893
|
-
getBundle() {
|
|
894
|
-
return this.reactServerLoader.getBundle();
|
|
895
|
-
}
|
|
896
|
-
setGlobalVariants(globalVariants) {
|
|
897
|
-
this.globalVariants = globalVariants;
|
|
898
|
-
}
|
|
899
|
-
getGlobalVariants() {
|
|
900
|
-
return this.globalVariants;
|
|
916
|
+
this.registry.clear();
|
|
901
917
|
}
|
|
902
918
|
registerModules(modules) {
|
|
903
919
|
if (Object.keys(modules).some(
|
|
@@ -918,112 +934,56 @@ var InternalPlasmicComponentLoader = class {
|
|
|
918
934
|
this.internalSubstituteComponent(component, name, void 0);
|
|
919
935
|
}
|
|
920
936
|
internalSubstituteComponent(component, name, codeComponentHelpers) {
|
|
921
|
-
if (!this.
|
|
937
|
+
if (!this.isRegistryEmpty()) {
|
|
922
938
|
console.warn(
|
|
923
939
|
"Calling PlasmicComponentLoader.registerSubstitution() after Plasmic component has rendered; starting over."
|
|
924
940
|
);
|
|
925
|
-
this.
|
|
941
|
+
this.clearRegistry();
|
|
926
942
|
}
|
|
927
943
|
this.subs.push({ lookup: name, component, codeComponentHelpers });
|
|
928
944
|
}
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
);
|
|
941
|
-
const helpers = { states: stateHelpers };
|
|
942
|
-
this.internalSubstituteComponent(
|
|
943
|
-
component,
|
|
944
|
-
{ name: meta.name, isCode: true },
|
|
945
|
-
Object.keys(stateHelpers).length > 0 ? helpers : void 0
|
|
946
|
-
);
|
|
947
|
-
registerComponent(component, __spreadValues(__spreadProps(__spreadValues({}, meta), {
|
|
948
|
-
// Import path is not used as we will use component substitution
|
|
949
|
-
importPath: (_b = meta.importPath) != null ? _b : ""
|
|
950
|
-
}), Object.keys(stateHelpers).length > 0 ? {
|
|
951
|
-
componentHelpers: {
|
|
952
|
-
helpers,
|
|
953
|
-
importPath: "",
|
|
954
|
-
importName: ""
|
|
955
|
-
}
|
|
956
|
-
} : {}));
|
|
945
|
+
refreshRegistry() {
|
|
946
|
+
for (const sub of this.subs) {
|
|
947
|
+
const metas = getCompMetas(this.getBundle().components, sub.lookup);
|
|
948
|
+
metas.forEach((meta) => {
|
|
949
|
+
SUBSTITUTED_COMPONENTS[meta.id] = sub.component;
|
|
950
|
+
if (sub.codeComponentHelpers) {
|
|
951
|
+
REGISTERED_CODE_COMPONENT_HELPERS[meta.id] = sub.codeComponentHelpers;
|
|
952
|
+
}
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
this.registry.updateModules(this.getBundle());
|
|
957
956
|
}
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
registerFunction(fn, __spreadProps(__spreadValues({}, meta), {
|
|
961
|
-
importPath: (_a = meta.importPath) != null ? _a : ""
|
|
962
|
-
}));
|
|
963
|
-
REGISTERED_CUSTOM_FUNCTIONS[customFunctionImportAlias(meta)] = fn;
|
|
957
|
+
isRegistryEmpty() {
|
|
958
|
+
return this.registry.isEmpty();
|
|
964
959
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
this.substituteComponent(context, { name: meta.name, isCode: true });
|
|
968
|
-
registerGlobalContext(context, __spreadProps(__spreadValues({}, meta), {
|
|
969
|
-
importPath: (_a = meta.importPath) != null ? _a : ""
|
|
970
|
-
}));
|
|
960
|
+
clearRegistry() {
|
|
961
|
+
this.registry.clear();
|
|
971
962
|
}
|
|
972
|
-
|
|
973
|
-
|
|
963
|
+
setGlobalVariants(globalVariants) {
|
|
964
|
+
this.globalVariants = globalVariants;
|
|
974
965
|
}
|
|
975
|
-
|
|
976
|
-
|
|
966
|
+
getGlobalVariants() {
|
|
967
|
+
return this.globalVariants;
|
|
977
968
|
}
|
|
978
969
|
registerPrefetchedBundle(bundle) {
|
|
979
970
|
if (!isBrowser) {
|
|
980
971
|
const cachedBundle = internal_getCachedBundleInNodeServer(this.opts);
|
|
981
972
|
if (cachedBundle) {
|
|
982
|
-
this.
|
|
973
|
+
this.mergeBundle(cachedBundle);
|
|
983
974
|
}
|
|
984
975
|
}
|
|
985
|
-
this.
|
|
986
|
-
}
|
|
987
|
-
subscribePlasmicRoot(watcher) {
|
|
988
|
-
this.roots.push(watcher);
|
|
989
|
-
}
|
|
990
|
-
unsubscribePlasmicRoot(watcher) {
|
|
991
|
-
const index = this.roots.indexOf(watcher);
|
|
992
|
-
if (index >= 0) {
|
|
993
|
-
this.roots.splice(index, 1);
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
clearCache() {
|
|
997
|
-
this.reactServerLoader.clearCache();
|
|
998
|
-
this.registry.clear();
|
|
976
|
+
this.mergeBundle(bundle);
|
|
999
977
|
}
|
|
1000
978
|
getLookup() {
|
|
1001
979
|
return new ComponentLookup(this.getBundle(), this.registry);
|
|
1002
980
|
}
|
|
1003
|
-
maybeFetchComponentData(...args) {
|
|
1004
|
-
return this.reactServerLoader.maybeFetchComponentData(...args);
|
|
1005
|
-
}
|
|
1006
|
-
fetchComponentData(...args) {
|
|
1007
|
-
return this.reactServerLoader.fetchComponentData(...args);
|
|
1008
|
-
}
|
|
1009
|
-
fetchPages(opts) {
|
|
1010
|
-
return this.reactServerLoader.fetchPages(opts);
|
|
1011
|
-
}
|
|
1012
|
-
fetchComponents() {
|
|
1013
|
-
return this.reactServerLoader.fetchComponents();
|
|
1014
|
-
}
|
|
1015
|
-
getActiveSplits() {
|
|
1016
|
-
return this.reactServerLoader.getActiveSplits();
|
|
1017
|
-
}
|
|
1018
|
-
getChunksUrl(bundle, modules) {
|
|
1019
|
-
return this.reactServerLoader.getChunksUrl(bundle, modules);
|
|
1020
|
-
}
|
|
1021
981
|
trackConversion(value = 0) {
|
|
1022
982
|
this.tracker.trackConversion(value);
|
|
1023
983
|
}
|
|
1024
984
|
getActiveVariation(opts) {
|
|
1025
985
|
return __async(this, null, function* () {
|
|
1026
|
-
yield this.
|
|
986
|
+
yield this.fetchComponents();
|
|
1027
987
|
return getActiveVariation(__spreadProps(__spreadValues({}, opts), {
|
|
1028
988
|
splits: this.getBundle().activeSplits
|
|
1029
989
|
}));
|
|
@@ -1046,23 +1006,6 @@ var InternalPlasmicComponentLoader = class {
|
|
|
1046
1006
|
trackRender(opts) {
|
|
1047
1007
|
this.tracker.trackRender(opts);
|
|
1048
1008
|
}
|
|
1049
|
-
refreshRegistry() {
|
|
1050
|
-
for (const sub of this.subs) {
|
|
1051
|
-
const metas = getCompMetas(this.getBundle().components, sub.lookup);
|
|
1052
|
-
metas.forEach((meta) => {
|
|
1053
|
-
SUBSTITUTED_COMPONENTS[meta.id] = sub.component;
|
|
1054
|
-
if (sub.codeComponentHelpers) {
|
|
1055
|
-
REGISTERED_CODE_COMPONENT_HELPERS[meta.id] = sub.codeComponentHelpers;
|
|
1056
|
-
}
|
|
1057
|
-
});
|
|
1058
|
-
}
|
|
1059
|
-
for (const globalGroup of this.getBundle().globalGroups) {
|
|
1060
|
-
if (globalGroup.type !== "global-screen") {
|
|
1061
|
-
SUBSTITUTED_GLOBAL_VARIANT_HOOKS[globalGroup.id] = createUseGlobalVariant(globalGroup.name, globalGroup.projectId);
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
this.registry.updateModules(this.getBundle());
|
|
1065
|
-
}
|
|
1066
1009
|
};
|
|
1067
1010
|
var PlasmicComponentLoader = class {
|
|
1068
1011
|
constructor(internal) {
|
|
@@ -1182,6 +1125,116 @@ var PlasmicComponentLoader = class {
|
|
|
1182
1125
|
}
|
|
1183
1126
|
};
|
|
1184
1127
|
|
|
1128
|
+
// src/loader-client.ts
|
|
1129
|
+
var InternalPlasmicComponentLoader = class extends BaseInternalPlasmicComponentLoader {
|
|
1130
|
+
constructor(opts) {
|
|
1131
|
+
const tracker = new PlasmicTracker2({
|
|
1132
|
+
projectIds: opts.projects.map((p) => p.id),
|
|
1133
|
+
platform: opts.platform,
|
|
1134
|
+
preview: opts.preview,
|
|
1135
|
+
nativeFetch: opts.nativeFetch
|
|
1136
|
+
});
|
|
1137
|
+
super({
|
|
1138
|
+
opts,
|
|
1139
|
+
tracker,
|
|
1140
|
+
fetcher: new PlasmicModulesFetcher2(opts),
|
|
1141
|
+
onBundleMerged: () => {
|
|
1142
|
+
this.refreshRegistry();
|
|
1143
|
+
},
|
|
1144
|
+
onBundleFetched: () => {
|
|
1145
|
+
this.roots.forEach((watcher) => {
|
|
1146
|
+
var _a;
|
|
1147
|
+
return (_a = watcher.onDataFetched) == null ? void 0 : _a.call(watcher);
|
|
1148
|
+
});
|
|
1149
|
+
},
|
|
1150
|
+
builtinModules: {
|
|
1151
|
+
react: React3,
|
|
1152
|
+
"react-dom": ReactDOM,
|
|
1153
|
+
"react/jsx-runtime": jsxRuntime,
|
|
1154
|
+
"react/jsx-dev-runtime": jsxDevRuntime,
|
|
1155
|
+
// Also inject @plasmicapp/query and @plasmicapp/host to use the
|
|
1156
|
+
// same contexts here and in loader-downloaded code.
|
|
1157
|
+
"@plasmicapp/query": PlasmicQuery,
|
|
1158
|
+
"@plasmicapp/data-sources-context": PlasmicDataSourcesContext,
|
|
1159
|
+
"@plasmicapp/host": PlasmicHost,
|
|
1160
|
+
"@plasmicapp/loader-runtime-registry": {
|
|
1161
|
+
components: SUBSTITUTED_COMPONENTS,
|
|
1162
|
+
globalVariantHooks: SUBSTITUTED_GLOBAL_VARIANT_HOOKS,
|
|
1163
|
+
codeComponentHelpers: REGISTERED_CODE_COMPONENT_HELPERS,
|
|
1164
|
+
functions: REGISTERED_CUSTOM_FUNCTIONS
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
});
|
|
1168
|
+
this.roots = [];
|
|
1169
|
+
}
|
|
1170
|
+
registerComponent(component, meta) {
|
|
1171
|
+
var _a, _b;
|
|
1172
|
+
const stateHelpers = Object.fromEntries(
|
|
1173
|
+
Object.entries((_a = meta.states) != null ? _a : {}).filter(
|
|
1174
|
+
([_, stateSpec]) => Object.keys(stateSpec).some((key) => stateHelpersKeys.includes(key))
|
|
1175
|
+
).map(([stateName, stateSpec]) => [
|
|
1176
|
+
stateName,
|
|
1177
|
+
Object.fromEntries(
|
|
1178
|
+
stateHelpersKeys.filter((key) => key in stateSpec).map((key) => [key, stateSpec[key]])
|
|
1179
|
+
)
|
|
1180
|
+
])
|
|
1181
|
+
);
|
|
1182
|
+
const helpers = { states: stateHelpers };
|
|
1183
|
+
this.internalSubstituteComponent(
|
|
1184
|
+
component,
|
|
1185
|
+
{ name: meta.name, isCode: true },
|
|
1186
|
+
Object.keys(stateHelpers).length > 0 ? helpers : void 0
|
|
1187
|
+
);
|
|
1188
|
+
registerComponent(component, __spreadValues(__spreadProps(__spreadValues({}, meta), {
|
|
1189
|
+
// Import path is not used as we will use component substitution
|
|
1190
|
+
importPath: (_b = meta.importPath) != null ? _b : ""
|
|
1191
|
+
}), Object.keys(stateHelpers).length > 0 ? {
|
|
1192
|
+
componentHelpers: {
|
|
1193
|
+
helpers,
|
|
1194
|
+
importPath: "",
|
|
1195
|
+
importName: ""
|
|
1196
|
+
}
|
|
1197
|
+
} : {}));
|
|
1198
|
+
}
|
|
1199
|
+
registerFunction(fn, meta) {
|
|
1200
|
+
var _a;
|
|
1201
|
+
registerFunction(fn, __spreadProps(__spreadValues({}, meta), {
|
|
1202
|
+
importPath: (_a = meta.importPath) != null ? _a : ""
|
|
1203
|
+
}));
|
|
1204
|
+
REGISTERED_CUSTOM_FUNCTIONS[customFunctionImportAlias(meta)] = fn;
|
|
1205
|
+
}
|
|
1206
|
+
registerGlobalContext(context, meta) {
|
|
1207
|
+
var _a;
|
|
1208
|
+
this.substituteComponent(context, { name: meta.name, isCode: true });
|
|
1209
|
+
registerGlobalContext(context, __spreadProps(__spreadValues({}, meta), {
|
|
1210
|
+
importPath: (_a = meta.importPath) != null ? _a : ""
|
|
1211
|
+
}));
|
|
1212
|
+
}
|
|
1213
|
+
registerTrait(trait, meta) {
|
|
1214
|
+
registerTrait(trait, meta);
|
|
1215
|
+
}
|
|
1216
|
+
registerToken(token) {
|
|
1217
|
+
registerToken(token);
|
|
1218
|
+
}
|
|
1219
|
+
subscribePlasmicRoot(watcher) {
|
|
1220
|
+
this.roots.push(watcher);
|
|
1221
|
+
}
|
|
1222
|
+
unsubscribePlasmicRoot(watcher) {
|
|
1223
|
+
const index = this.roots.indexOf(watcher);
|
|
1224
|
+
if (index >= 0) {
|
|
1225
|
+
this.roots.splice(index, 1);
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
refreshRegistry() {
|
|
1229
|
+
for (const globalGroup of this.getBundle().globalGroups) {
|
|
1230
|
+
if (globalGroup.type !== "global-screen") {
|
|
1231
|
+
SUBSTITUTED_GLOBAL_VARIANT_HOOKS[globalGroup.id] = createUseGlobalVariant(globalGroup.name, globalGroup.projectId);
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
super.refreshRegistry();
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1185
1238
|
// src/index.ts
|
|
1186
1239
|
import {
|
|
1187
1240
|
DataCtxReader,
|
|
@@ -1197,7 +1250,6 @@ import {
|
|
|
1197
1250
|
useSelector,
|
|
1198
1251
|
useSelectors
|
|
1199
1252
|
} from "@plasmicapp/host";
|
|
1200
|
-
import { extractPlasmicQueryData as extractPlasmicQueryData2, plasmicPrepass } from "@plasmicapp/prepass";
|
|
1201
1253
|
import { usePlasmicQueryData } from "@plasmicapp/query";
|
|
1202
1254
|
|
|
1203
1255
|
// src/PlasmicComponent.tsx
|
|
@@ -1285,7 +1337,7 @@ function PlasmicComponent(props) {
|
|
|
1285
1337
|
if (!Component) {
|
|
1286
1338
|
return null;
|
|
1287
1339
|
}
|
|
1288
|
-
let
|
|
1340
|
+
let elt = /* @__PURE__ */ React5.createElement(Component, __spreadValues({}, componentProps));
|
|
1289
1341
|
if (isRootLoader) {
|
|
1290
1342
|
const lookup = loader.getLookup();
|
|
1291
1343
|
const ReactWebRootProvider = lookup.getRootProvider();
|
|
@@ -1293,7 +1345,7 @@ function PlasmicComponent(props) {
|
|
|
1293
1345
|
name: component,
|
|
1294
1346
|
projectId
|
|
1295
1347
|
});
|
|
1296
|
-
|
|
1348
|
+
elt = /* @__PURE__ */ React5.createElement(
|
|
1297
1349
|
ReactWebRootProvider,
|
|
1298
1350
|
__spreadProps(__spreadValues({}, rest), {
|
|
1299
1351
|
userAuthToken,
|
|
@@ -1310,11 +1362,11 @@ function PlasmicComponent(props) {
|
|
|
1310
1362
|
cond: !!GlobalContextsProvider,
|
|
1311
1363
|
wrapper: (children) => /* @__PURE__ */ React5.createElement(GlobalContextsProvider, __spreadValues({}, globalContextsProps), children)
|
|
1312
1364
|
},
|
|
1313
|
-
/* @__PURE__ */ React5.createElement(PlasmicComponentContext.Provider, { value: true },
|
|
1365
|
+
/* @__PURE__ */ React5.createElement(PlasmicComponentContext.Provider, { value: true }, elt)
|
|
1314
1366
|
)
|
|
1315
1367
|
);
|
|
1316
1368
|
}
|
|
1317
|
-
return
|
|
1369
|
+
return elt;
|
|
1318
1370
|
}, [
|
|
1319
1371
|
Component,
|
|
1320
1372
|
componentProps,
|
|
@@ -1331,11 +1383,23 @@ function PlasmicComponent(props) {
|
|
|
1331
1383
|
return element;
|
|
1332
1384
|
}
|
|
1333
1385
|
|
|
1386
|
+
// src/prepass-client.ts
|
|
1387
|
+
import {
|
|
1388
|
+
extractPlasmicQueryData as internalExtractQueryData,
|
|
1389
|
+
plasmicPrepass as internalPlasmicPrepass
|
|
1390
|
+
} from "@plasmicapp/prepass";
|
|
1391
|
+
function extractPlasmicQueryData(element) {
|
|
1392
|
+
return internalExtractQueryData(element);
|
|
1393
|
+
}
|
|
1394
|
+
function plasmicPrepass(element) {
|
|
1395
|
+
return internalPlasmicPrepass(element);
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1334
1398
|
// src/render.tsx
|
|
1399
|
+
import { extractPlasmicQueryData as extractPlasmicQueryData2 } from "@plasmicapp/prepass";
|
|
1335
1400
|
import React6 from "react";
|
|
1336
1401
|
import ReactDOM2 from "react-dom";
|
|
1337
1402
|
import { renderToString as reactRenderToString } from "react-dom/server";
|
|
1338
|
-
import { extractPlasmicQueryData } from "@plasmicapp/prepass";
|
|
1339
1403
|
function renderToElement(_0, _1, _2) {
|
|
1340
1404
|
return __async(this, arguments, function* (loader, target, lookup, opts = {}) {
|
|
1341
1405
|
return new Promise((resolve) => {
|
|
@@ -1351,7 +1415,7 @@ function renderToString(loader, lookup, opts = {}) {
|
|
|
1351
1415
|
function extractPlasmicQueryDataFromElement(_0, _1) {
|
|
1352
1416
|
return __async(this, arguments, function* (loader, lookup, opts = {}) {
|
|
1353
1417
|
const element = makeElement(loader, lookup, opts);
|
|
1354
|
-
return
|
|
1418
|
+
return extractPlasmicQueryData2(element);
|
|
1355
1419
|
});
|
|
1356
1420
|
}
|
|
1357
1421
|
function hydrateFromElement(_0, _1, _2) {
|
|
@@ -1402,7 +1466,7 @@ export {
|
|
|
1402
1466
|
PlasmicComponentLoader,
|
|
1403
1467
|
PlasmicRootProvider,
|
|
1404
1468
|
convertBundlesToComponentRenderData,
|
|
1405
|
-
|
|
1469
|
+
extractPlasmicQueryData,
|
|
1406
1470
|
extractPlasmicQueryDataFromElement,
|
|
1407
1471
|
hydrateFromElement,
|
|
1408
1472
|
initPlasmicLoader,
|