@plasmicapp/loader-react 1.0.377 → 1.0.378

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
@@ -793,6 +793,9 @@ function customFunctionImportAlias(meta) {
793
793
  const customFunctionPrefix = `__fn_`;
794
794
  return meta.namespace ? `${customFunctionPrefix}${meta.namespace}__${meta.name}` : `${customFunctionPrefix}${meta.name}`;
795
795
  }
796
+ function internalSetRegisteredFunction(fn, meta) {
797
+ REGISTERED_CUSTOM_FUNCTIONS[customFunctionImportAlias(meta)] = fn;
798
+ }
796
799
  function parseFetchComponentDataArgs(...args) {
797
800
  let specs;
798
801
  let opts;
@@ -1057,6 +1060,9 @@ ${this.bundle.bundleKey}`
1057
1060
  trackRender(opts) {
1058
1061
  this.tracker.trackRender(opts);
1059
1062
  }
1063
+ loadServerQueriesModule(fileName) {
1064
+ return this.registry.load(fileName);
1065
+ }
1060
1066
  };
1061
1067
  var PlasmicComponentLoader = class {
1062
1068
  constructor(internal) {
@@ -1174,6 +1180,26 @@ var PlasmicComponentLoader = class {
1174
1180
  clearCache() {
1175
1181
  return this.__internal.clearCache();
1176
1182
  }
1183
+ unstable__getServerQueriesData(renderData, $ctx) {
1184
+ return __async(this, null, function* () {
1185
+ if (renderData.entryCompMetas.length === 0) {
1186
+ return {};
1187
+ }
1188
+ const fileName = renderData.entryCompMetas[0].serverQueriesExecFuncFileName;
1189
+ if (!fileName) {
1190
+ return {};
1191
+ }
1192
+ const module2 = this.__internal.loadServerQueriesModule(fileName);
1193
+ const { executeServerQueries } = module2;
1194
+ try {
1195
+ const $serverQueries = yield executeServerQueries($ctx);
1196
+ return $serverQueries;
1197
+ } catch (err) {
1198
+ console.error("Error executing server queries function", err);
1199
+ return {};
1200
+ }
1201
+ });
1202
+ }
1177
1203
  };
1178
1204
 
1179
1205
  // src/loader-client.ts
@@ -1205,6 +1231,7 @@ var InternalPlasmicComponentLoader = class extends BaseInternalPlasmicComponentL
1205
1231
  "@plasmicapp/query": PlasmicQuery,
1206
1232
  "@plasmicapp/data-sources-context": PlasmicDataSourcesContext,
1207
1233
  "@plasmicapp/host": PlasmicHost,
1234
+ "@plasmicapp/host/registerFunction": internalSetRegisteredFunction,
1208
1235
  "@plasmicapp/loader-runtime-registry": {
1209
1236
  components: SUBSTITUTED_COMPONENTS,
1210
1237
  globalVariantHooks: SUBSTITUTED_GLOBAL_VARIANT_HOOKS,
@@ -1249,7 +1276,7 @@ var InternalPlasmicComponentLoader = class extends BaseInternalPlasmicComponentL
1249
1276
  (0, import_host2.registerFunction)(fn, __spreadProps(__spreadValues({}, meta), {
1250
1277
  importPath: (_a = meta.importPath) != null ? _a : ""
1251
1278
  }));
1252
- REGISTERED_CUSTOM_FUNCTIONS[customFunctionImportAlias(meta)] = fn;
1279
+ internalSetRegisteredFunction(fn, meta);
1253
1280
  }
1254
1281
  registerGlobalContext(context, meta) {
1255
1282
  var _a;