@plasmicapp/loader-react 1.0.340 → 1.0.342

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 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";
@@ -221,80 +218,6 @@ function uniq(elements) {
221
218
  return Array.from(new Set(elements));
222
219
  }
223
220
 
224
- // src/component-lookup.ts
225
- function getFirstCompMeta(metas, lookup) {
226
- const filtered = getCompMetas(metas, lookup);
227
- return filtered.length === 0 ? void 0 : filtered[0];
228
- }
229
- var ComponentLookup = class {
230
- constructor(bundle, registry) {
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;
273
- }
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
- }
288
- getRemoteFonts() {
289
- return this.bundle.projects.flatMap((p) => p.remoteFonts);
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";
297
-
298
221
  // src/variation.ts
299
222
  function getPlasmicCookieValues() {
300
223
  return Object.fromEntries(
@@ -537,6 +460,15 @@ function createUseGlobalVariant(name, projectId) {
537
460
  };
538
461
  }
539
462
 
463
+ // src/loader-shared.ts
464
+ import {
465
+ Registry
466
+ } from "@plasmicapp/loader-core";
467
+ import {
468
+ internal_getCachedBundleInNodeServer
469
+ } from "@plasmicapp/loader-fetcher";
470
+ import { getActiveVariation, getExternalIds } from "@plasmicapp/loader-splits";
471
+
540
472
  // src/bundles.ts
541
473
  import {
542
474
  getBundleSubset
@@ -675,9 +607,101 @@ var convertBundlesToComponentRenderData = (bundles, compMetas) => {
675
607
  return prepComponentData(mergedBundles, compMetas);
676
608
  };
677
609
 
678
- // src/loader-react-server.ts
679
- var ReactServerPlasmicComponentLoader = class {
610
+ // src/component-lookup.ts
611
+ function getFirstCompMeta(metas, lookup) {
612
+ const filtered = getCompMetas(metas, lookup);
613
+ return filtered.length === 0 ? void 0 : filtered[0];
614
+ }
615
+ var ComponentLookup = class {
616
+ constructor(bundle, registry) {
617
+ this.bundle = bundle;
618
+ this.registry = registry;
619
+ }
620
+ getComponentMeta(spec) {
621
+ const compMeta = getFirstCompMeta(this.bundle.components, spec);
622
+ return compMeta;
623
+ }
624
+ getComponent(spec, opts = {}) {
625
+ const compMeta = getFirstCompMeta(this.bundle.components, spec);
626
+ if (!compMeta) {
627
+ throw new Error(`Component not found: ${spec}`);
628
+ }
629
+ const moduleName = compMeta.entry;
630
+ if (!this.registry.hasModule(moduleName, opts)) {
631
+ throw new Error(`Component not yet fetched: ${compMeta.name}`);
632
+ }
633
+ const entry = this.registry.load(moduleName, {
634
+ forceOriginal: opts.forceOriginal
635
+ });
636
+ return !opts.forceOriginal && typeof (entry == null ? void 0 : entry.getPlasmicComponent) === "function" ? entry.getPlasmicComponent() : entry.default;
637
+ }
638
+ hasComponent(spec) {
639
+ const compMeta = getFirstCompMeta(this.bundle.components, spec);
640
+ if (compMeta) {
641
+ return this.registry.hasModule(compMeta.entry);
642
+ }
643
+ return false;
644
+ }
645
+ getGlobalContexts() {
646
+ const customGlobalMetas = this.bundle.globalGroups.filter(
647
+ (m) => m.type === "global-user-defined"
648
+ );
649
+ return customGlobalMetas.map((meta) => ({
650
+ meta,
651
+ context: this.registry.load(meta.contextFile).default
652
+ }));
653
+ }
654
+ getGlobalContextsProvider(spec) {
655
+ const compMeta = getFirstCompMeta(this.bundle.components, spec);
656
+ const projectMeta = compMeta ? this.bundle.projects.find((x) => x.id === compMeta.projectId) : void 0;
657
+ if (!projectMeta || !projectMeta.globalContextsProviderFileName || !this.registry.hasModule(projectMeta.globalContextsProviderFileName)) {
658
+ return void 0;
659
+ }
660
+ const entry = this.registry.load(
661
+ projectMeta.globalContextsProviderFileName
662
+ );
663
+ return typeof (entry == null ? void 0 : entry.getPlasmicComponent) === "function" ? entry.getPlasmicComponent() : entry.default;
664
+ }
665
+ getRootProvider() {
666
+ const entry = this.registry.load("root-provider.js");
667
+ return entry.default;
668
+ }
669
+ getCss() {
670
+ return this.bundle.modules.browser.filter(
671
+ (mod) => mod.type === "asset" && mod.fileName.endsWith("css")
672
+ );
673
+ }
674
+ getRemoteFonts() {
675
+ return this.bundle.projects.flatMap((p) => p.remoteFonts);
676
+ }
677
+ };
678
+
679
+ // src/loader-shared.ts
680
+ var SUBSTITUTED_COMPONENTS = {};
681
+ var REGISTERED_CODE_COMPONENT_HELPERS = {};
682
+ var SUBSTITUTED_GLOBAL_VARIANT_HOOKS = {};
683
+ var REGISTERED_CUSTOM_FUNCTIONS = {};
684
+ function customFunctionImportAlias(meta) {
685
+ const customFunctionPrefix = `__fn_`;
686
+ return meta.namespace ? `${customFunctionPrefix}${meta.namespace}__${meta.name}` : `${customFunctionPrefix}${meta.name}`;
687
+ }
688
+ function parseFetchComponentDataArgs(...args) {
689
+ let specs;
690
+ let opts;
691
+ if (Array.isArray(args[0])) {
692
+ specs = args[0];
693
+ opts = args[1];
694
+ } else {
695
+ specs = args;
696
+ opts = void 0;
697
+ }
698
+ return { specs, opts };
699
+ }
700
+ var BaseInternalPlasmicComponentLoader = class {
680
701
  constructor(args) {
702
+ this.registry = new Registry();
703
+ this.globalVariants = [];
704
+ this.subs = [];
681
705
  this.bundle = {
682
706
  modules: {
683
707
  browser: [],
@@ -696,6 +720,7 @@ var ReactServerPlasmicComponentLoader = class {
696
720
  this.tracker = args.tracker;
697
721
  this.onBundleMerged = args.onBundleMerged;
698
722
  this.onBundleFetched = args.onBundleFetched;
723
+ this.registerModules(args.builtinModules);
699
724
  }
700
725
  maybeGetCompMetas(...specs) {
701
726
  const found = /* @__PURE__ */ new Set();
@@ -821,83 +846,7 @@ var ReactServerPlasmicComponentLoader = class {
821
846
  bundleKey: null,
822
847
  deferChunksByDefault: false
823
848
  };
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;
849
+ this.registry.clear();
901
850
  }
902
851
  registerModules(modules) {
903
852
  if (Object.keys(modules).some(
@@ -918,112 +867,56 @@ var InternalPlasmicComponentLoader = class {
918
867
  this.internalSubstituteComponent(component, name, void 0);
919
868
  }
920
869
  internalSubstituteComponent(component, name, codeComponentHelpers) {
921
- if (!this.registry.isEmpty()) {
870
+ if (!this.isRegistryEmpty()) {
922
871
  console.warn(
923
872
  "Calling PlasmicComponentLoader.registerSubstitution() after Plasmic component has rendered; starting over."
924
873
  );
925
- this.registry.clear();
874
+ this.clearRegistry();
926
875
  }
927
876
  this.subs.push({ lookup: name, component, codeComponentHelpers });
928
877
  }
929
- registerComponent(component, meta) {
930
- var _a, _b;
931
- const stateHelpers = Object.fromEntries(
932
- Object.entries((_a = meta.states) != null ? _a : {}).filter(
933
- ([_, stateSpec]) => Object.keys(stateSpec).some((key) => stateHelpersKeys.includes(key))
934
- ).map(([stateName, stateSpec]) => [
935
- stateName,
936
- Object.fromEntries(
937
- stateHelpersKeys.filter((key) => key in stateSpec).map((key) => [key, stateSpec[key]])
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
- } : {}));
878
+ refreshRegistry() {
879
+ for (const sub of this.subs) {
880
+ const metas = getCompMetas(this.getBundle().components, sub.lookup);
881
+ metas.forEach((meta) => {
882
+ SUBSTITUTED_COMPONENTS[meta.id] = sub.component;
883
+ if (sub.codeComponentHelpers) {
884
+ REGISTERED_CODE_COMPONENT_HELPERS[meta.id] = sub.codeComponentHelpers;
885
+ }
886
+ });
887
+ }
888
+ this.registry.updateModules(this.getBundle());
957
889
  }
958
- registerFunction(fn, meta) {
959
- var _a;
960
- registerFunction(fn, __spreadProps(__spreadValues({}, meta), {
961
- importPath: (_a = meta.importPath) != null ? _a : ""
962
- }));
963
- REGISTERED_CUSTOM_FUNCTIONS[customFunctionImportAlias(meta)] = fn;
890
+ isRegistryEmpty() {
891
+ return this.registry.isEmpty();
964
892
  }
965
- registerGlobalContext(context, meta) {
966
- var _a;
967
- this.substituteComponent(context, { name: meta.name, isCode: true });
968
- registerGlobalContext(context, __spreadProps(__spreadValues({}, meta), {
969
- importPath: (_a = meta.importPath) != null ? _a : ""
970
- }));
893
+ clearRegistry() {
894
+ this.registry.clear();
971
895
  }
972
- registerTrait(trait, meta) {
973
- registerTrait(trait, meta);
896
+ setGlobalVariants(globalVariants) {
897
+ this.globalVariants = globalVariants;
974
898
  }
975
- registerToken(token) {
976
- registerToken(token);
899
+ getGlobalVariants() {
900
+ return this.globalVariants;
977
901
  }
978
902
  registerPrefetchedBundle(bundle) {
979
903
  if (!isBrowser) {
980
904
  const cachedBundle = internal_getCachedBundleInNodeServer(this.opts);
981
905
  if (cachedBundle) {
982
- this.reactServerLoader.mergeBundle(cachedBundle);
906
+ this.mergeBundle(cachedBundle);
983
907
  }
984
908
  }
985
- this.reactServerLoader.mergeBundle(bundle);
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();
909
+ this.mergeBundle(bundle);
999
910
  }
1000
911
  getLookup() {
1001
912
  return new ComponentLookup(this.getBundle(), this.registry);
1002
913
  }
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
914
  trackConversion(value = 0) {
1022
915
  this.tracker.trackConversion(value);
1023
916
  }
1024
917
  getActiveVariation(opts) {
1025
918
  return __async(this, null, function* () {
1026
- yield this.reactServerLoader.fetchComponents();
919
+ yield this.fetchComponents();
1027
920
  return getActiveVariation(__spreadProps(__spreadValues({}, opts), {
1028
921
  splits: this.getBundle().activeSplits
1029
922
  }));
@@ -1046,23 +939,6 @@ var InternalPlasmicComponentLoader = class {
1046
939
  trackRender(opts) {
1047
940
  this.tracker.trackRender(opts);
1048
941
  }
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
942
  };
1067
943
  var PlasmicComponentLoader = class {
1068
944
  constructor(internal) {
@@ -1182,6 +1058,116 @@ var PlasmicComponentLoader = class {
1182
1058
  }
1183
1059
  };
1184
1060
 
1061
+ // src/loader-client.ts
1062
+ var InternalPlasmicComponentLoader = class extends BaseInternalPlasmicComponentLoader {
1063
+ constructor(opts) {
1064
+ const tracker = new PlasmicTracker2({
1065
+ projectIds: opts.projects.map((p) => p.id),
1066
+ platform: opts.platform,
1067
+ preview: opts.preview,
1068
+ nativeFetch: opts.nativeFetch
1069
+ });
1070
+ super({
1071
+ opts,
1072
+ tracker,
1073
+ fetcher: new PlasmicModulesFetcher2(opts),
1074
+ onBundleMerged: () => {
1075
+ this.refreshRegistry();
1076
+ },
1077
+ onBundleFetched: () => {
1078
+ this.roots.forEach((watcher) => {
1079
+ var _a;
1080
+ return (_a = watcher.onDataFetched) == null ? void 0 : _a.call(watcher);
1081
+ });
1082
+ },
1083
+ builtinModules: {
1084
+ react: React3,
1085
+ "react-dom": ReactDOM,
1086
+ "react/jsx-runtime": jsxRuntime,
1087
+ "react/jsx-dev-runtime": jsxDevRuntime,
1088
+ // Also inject @plasmicapp/query and @plasmicapp/host to use the
1089
+ // same contexts here and in loader-downloaded code.
1090
+ "@plasmicapp/query": PlasmicQuery,
1091
+ "@plasmicapp/data-sources-context": PlasmicDataSourcesContext,
1092
+ "@plasmicapp/host": PlasmicHost,
1093
+ "@plasmicapp/loader-runtime-registry": {
1094
+ components: SUBSTITUTED_COMPONENTS,
1095
+ globalVariantHooks: SUBSTITUTED_GLOBAL_VARIANT_HOOKS,
1096
+ codeComponentHelpers: REGISTERED_CODE_COMPONENT_HELPERS,
1097
+ functions: REGISTERED_CUSTOM_FUNCTIONS
1098
+ }
1099
+ }
1100
+ });
1101
+ this.roots = [];
1102
+ }
1103
+ registerComponent(component, meta) {
1104
+ var _a, _b;
1105
+ const stateHelpers = Object.fromEntries(
1106
+ Object.entries((_a = meta.states) != null ? _a : {}).filter(
1107
+ ([_, stateSpec]) => Object.keys(stateSpec).some((key) => stateHelpersKeys.includes(key))
1108
+ ).map(([stateName, stateSpec]) => [
1109
+ stateName,
1110
+ Object.fromEntries(
1111
+ stateHelpersKeys.filter((key) => key in stateSpec).map((key) => [key, stateSpec[key]])
1112
+ )
1113
+ ])
1114
+ );
1115
+ const helpers = { states: stateHelpers };
1116
+ this.internalSubstituteComponent(
1117
+ component,
1118
+ { name: meta.name, isCode: true },
1119
+ Object.keys(stateHelpers).length > 0 ? helpers : void 0
1120
+ );
1121
+ registerComponent(component, __spreadValues(__spreadProps(__spreadValues({}, meta), {
1122
+ // Import path is not used as we will use component substitution
1123
+ importPath: (_b = meta.importPath) != null ? _b : ""
1124
+ }), Object.keys(stateHelpers).length > 0 ? {
1125
+ componentHelpers: {
1126
+ helpers,
1127
+ importPath: "",
1128
+ importName: ""
1129
+ }
1130
+ } : {}));
1131
+ }
1132
+ registerFunction(fn, meta) {
1133
+ var _a;
1134
+ registerFunction(fn, __spreadProps(__spreadValues({}, meta), {
1135
+ importPath: (_a = meta.importPath) != null ? _a : ""
1136
+ }));
1137
+ REGISTERED_CUSTOM_FUNCTIONS[customFunctionImportAlias(meta)] = fn;
1138
+ }
1139
+ registerGlobalContext(context, meta) {
1140
+ var _a;
1141
+ this.substituteComponent(context, { name: meta.name, isCode: true });
1142
+ registerGlobalContext(context, __spreadProps(__spreadValues({}, meta), {
1143
+ importPath: (_a = meta.importPath) != null ? _a : ""
1144
+ }));
1145
+ }
1146
+ registerTrait(trait, meta) {
1147
+ registerTrait(trait, meta);
1148
+ }
1149
+ registerToken(token) {
1150
+ registerToken(token);
1151
+ }
1152
+ subscribePlasmicRoot(watcher) {
1153
+ this.roots.push(watcher);
1154
+ }
1155
+ unsubscribePlasmicRoot(watcher) {
1156
+ const index = this.roots.indexOf(watcher);
1157
+ if (index >= 0) {
1158
+ this.roots.splice(index, 1);
1159
+ }
1160
+ }
1161
+ refreshRegistry() {
1162
+ for (const globalGroup of this.getBundle().globalGroups) {
1163
+ if (globalGroup.type !== "global-screen") {
1164
+ SUBSTITUTED_GLOBAL_VARIANT_HOOKS[globalGroup.id] = createUseGlobalVariant(globalGroup.name, globalGroup.projectId);
1165
+ }
1166
+ }
1167
+ super.refreshRegistry();
1168
+ }
1169
+ };
1170
+
1185
1171
  // src/index.ts
1186
1172
  import {
1187
1173
  DataCtxReader,
@@ -1197,7 +1183,6 @@ import {
1197
1183
  useSelector,
1198
1184
  useSelectors
1199
1185
  } from "@plasmicapp/host";
1200
- import { extractPlasmicQueryData as extractPlasmicQueryData2, plasmicPrepass } from "@plasmicapp/prepass";
1201
1186
  import { usePlasmicQueryData } from "@plasmicapp/query";
1202
1187
 
1203
1188
  // src/PlasmicComponent.tsx
@@ -1285,7 +1270,7 @@ function PlasmicComponent(props) {
1285
1270
  if (!Component) {
1286
1271
  return null;
1287
1272
  }
1288
- let element2 = /* @__PURE__ */ React5.createElement(Component, __spreadValues({}, componentProps));
1273
+ let elt = /* @__PURE__ */ React5.createElement(Component, __spreadValues({}, componentProps));
1289
1274
  if (isRootLoader) {
1290
1275
  const lookup = loader.getLookup();
1291
1276
  const ReactWebRootProvider = lookup.getRootProvider();
@@ -1293,7 +1278,7 @@ function PlasmicComponent(props) {
1293
1278
  name: component,
1294
1279
  projectId
1295
1280
  });
1296
- element2 = /* @__PURE__ */ React5.createElement(
1281
+ elt = /* @__PURE__ */ React5.createElement(
1297
1282
  ReactWebRootProvider,
1298
1283
  __spreadProps(__spreadValues({}, rest), {
1299
1284
  userAuthToken,
@@ -1310,11 +1295,11 @@ function PlasmicComponent(props) {
1310
1295
  cond: !!GlobalContextsProvider,
1311
1296
  wrapper: (children) => /* @__PURE__ */ React5.createElement(GlobalContextsProvider, __spreadValues({}, globalContextsProps), children)
1312
1297
  },
1313
- /* @__PURE__ */ React5.createElement(PlasmicComponentContext.Provider, { value: true }, element2)
1298
+ /* @__PURE__ */ React5.createElement(PlasmicComponentContext.Provider, { value: true }, elt)
1314
1299
  )
1315
1300
  );
1316
1301
  }
1317
- return element2;
1302
+ return elt;
1318
1303
  }, [
1319
1304
  Component,
1320
1305
  componentProps,
@@ -1331,11 +1316,23 @@ function PlasmicComponent(props) {
1331
1316
  return element;
1332
1317
  }
1333
1318
 
1319
+ // src/prepass-client.ts
1320
+ import {
1321
+ extractPlasmicQueryData as internalExtractQueryData,
1322
+ plasmicPrepass as internalPlasmicPrepass
1323
+ } from "@plasmicapp/prepass";
1324
+ function extractPlasmicQueryData(element) {
1325
+ return internalExtractQueryData(element);
1326
+ }
1327
+ function plasmicPrepass(element) {
1328
+ return internalPlasmicPrepass(element);
1329
+ }
1330
+
1334
1331
  // src/render.tsx
1332
+ import { extractPlasmicQueryData as extractPlasmicQueryData2 } from "@plasmicapp/prepass";
1335
1333
  import React6 from "react";
1336
1334
  import ReactDOM2 from "react-dom";
1337
1335
  import { renderToString as reactRenderToString } from "react-dom/server";
1338
- import { extractPlasmicQueryData } from "@plasmicapp/prepass";
1339
1336
  function renderToElement(_0, _1, _2) {
1340
1337
  return __async(this, arguments, function* (loader, target, lookup, opts = {}) {
1341
1338
  return new Promise((resolve) => {
@@ -1351,7 +1348,7 @@ function renderToString(loader, lookup, opts = {}) {
1351
1348
  function extractPlasmicQueryDataFromElement(_0, _1) {
1352
1349
  return __async(this, arguments, function* (loader, lookup, opts = {}) {
1353
1350
  const element = makeElement(loader, lookup, opts);
1354
- return extractPlasmicQueryData(element);
1351
+ return extractPlasmicQueryData2(element);
1355
1352
  });
1356
1353
  }
1357
1354
  function hydrateFromElement(_0, _1, _2) {
@@ -1402,7 +1399,7 @@ export {
1402
1399
  PlasmicComponentLoader,
1403
1400
  PlasmicRootProvider,
1404
1401
  convertBundlesToComponentRenderData,
1405
- extractPlasmicQueryData2 as extractPlasmicQueryData,
1402
+ extractPlasmicQueryData,
1406
1403
  extractPlasmicQueryDataFromElement,
1407
1404
  hydrateFromElement,
1408
1405
  initPlasmicLoader,