@plasmicapp/loader-react 1.0.377 → 1.0.379

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.js CHANGED
@@ -285,12 +285,6 @@ function getPlasmicCookieValues() {
285
285
  function updatePlasmicCookieValue(key, value) {
286
286
  document.cookie = `plasmic:${key}=${value}`;
287
287
  }
288
- function ensureVariationCookies(variation = {}) {
289
- Object.keys(variation).map((variationKey) => {
290
- const sliceId = variation[variationKey];
291
- updatePlasmicCookieValue(variationKey, sliceId);
292
- });
293
- }
294
288
  var getGlobalVariantsFromSplits = (splits, variation) => {
295
289
  const globalVariants = [];
296
290
  Object.keys(variation).map((variationKey) => {
@@ -437,7 +431,6 @@ function PlasmicRootProvider(props) {
437
431
  currentContextValue
438
432
  ]);
439
433
  React2.useEffect(() => {
440
- ensureVariationCookies(variation);
441
434
  loader.trackRender({
442
435
  renderCtx: {
443
436
  // We track the provider as a single entity
@@ -793,6 +786,9 @@ function customFunctionImportAlias(meta) {
793
786
  const customFunctionPrefix = `__fn_`;
794
787
  return meta.namespace ? `${customFunctionPrefix}${meta.namespace}__${meta.name}` : `${customFunctionPrefix}${meta.name}`;
795
788
  }
789
+ function internalSetRegisteredFunction(fn, meta) {
790
+ REGISTERED_CUSTOM_FUNCTIONS[customFunctionImportAlias(meta)] = fn;
791
+ }
796
792
  function parseFetchComponentDataArgs(...args) {
797
793
  let specs;
798
794
  let opts;
@@ -1057,6 +1053,9 @@ ${this.bundle.bundleKey}`
1057
1053
  trackRender(opts) {
1058
1054
  this.tracker.trackRender(opts);
1059
1055
  }
1056
+ loadServerQueriesModule(fileName) {
1057
+ return this.registry.load(fileName);
1058
+ }
1060
1059
  };
1061
1060
  var PlasmicComponentLoader = class {
1062
1061
  constructor(internal) {
@@ -1174,6 +1173,26 @@ var PlasmicComponentLoader = class {
1174
1173
  clearCache() {
1175
1174
  return this.__internal.clearCache();
1176
1175
  }
1176
+ unstable__getServerQueriesData(renderData, $ctx) {
1177
+ return __async(this, null, function* () {
1178
+ if (renderData.entryCompMetas.length === 0) {
1179
+ return {};
1180
+ }
1181
+ const fileName = renderData.entryCompMetas[0].serverQueriesExecFuncFileName;
1182
+ if (!fileName) {
1183
+ return {};
1184
+ }
1185
+ const module2 = this.__internal.loadServerQueriesModule(fileName);
1186
+ const { executeServerQueries } = module2;
1187
+ try {
1188
+ const $serverQueries = yield executeServerQueries($ctx);
1189
+ return $serverQueries;
1190
+ } catch (err) {
1191
+ console.error("Error executing server queries function", err);
1192
+ return {};
1193
+ }
1194
+ });
1195
+ }
1177
1196
  };
1178
1197
 
1179
1198
  // src/loader-client.ts
@@ -1205,6 +1224,7 @@ var InternalPlasmicComponentLoader = class extends BaseInternalPlasmicComponentL
1205
1224
  "@plasmicapp/query": PlasmicQuery,
1206
1225
  "@plasmicapp/data-sources-context": PlasmicDataSourcesContext,
1207
1226
  "@plasmicapp/host": PlasmicHost,
1227
+ "@plasmicapp/host/registerFunction": internalSetRegisteredFunction,
1208
1228
  "@plasmicapp/loader-runtime-registry": {
1209
1229
  components: SUBSTITUTED_COMPONENTS,
1210
1230
  globalVariantHooks: SUBSTITUTED_GLOBAL_VARIANT_HOOKS,
@@ -1249,7 +1269,7 @@ var InternalPlasmicComponentLoader = class extends BaseInternalPlasmicComponentL
1249
1269
  (0, import_host2.registerFunction)(fn, __spreadProps(__spreadValues({}, meta), {
1250
1270
  importPath: (_a = meta.importPath) != null ? _a : ""
1251
1271
  }));
1252
- REGISTERED_CUSTOM_FUNCTIONS[customFunctionImportAlias(meta)] = fn;
1272
+ internalSetRegisteredFunction(fn, meta);
1253
1273
  }
1254
1274
  registerGlobalContext(context, meta) {
1255
1275
  var _a;