@plasmicapp/loader-react 1.0.376 → 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
@@ -103,6 +103,7 @@ __export(src_exports, {
103
103
  renderToString: () => renderToString,
104
104
  repeatedElement: () => import_host3.repeatedElement,
105
105
  useDataEnv: () => import_host3.useDataEnv,
106
+ usePlasmicCanvasComponentInfo: () => import_host3.usePlasmicCanvasComponentInfo,
106
107
  usePlasmicCanvasContext: () => import_host3.usePlasmicCanvasContext,
107
108
  usePlasmicComponent: () => usePlasmicComponent,
108
109
  usePlasmicQueryData: () => import_query2.usePlasmicQueryData,
@@ -792,6 +793,9 @@ function customFunctionImportAlias(meta) {
792
793
  const customFunctionPrefix = `__fn_`;
793
794
  return meta.namespace ? `${customFunctionPrefix}${meta.namespace}__${meta.name}` : `${customFunctionPrefix}${meta.name}`;
794
795
  }
796
+ function internalSetRegisteredFunction(fn, meta) {
797
+ REGISTERED_CUSTOM_FUNCTIONS[customFunctionImportAlias(meta)] = fn;
798
+ }
795
799
  function parseFetchComponentDataArgs(...args) {
796
800
  let specs;
797
801
  let opts;
@@ -1056,6 +1060,9 @@ ${this.bundle.bundleKey}`
1056
1060
  trackRender(opts) {
1057
1061
  this.tracker.trackRender(opts);
1058
1062
  }
1063
+ loadServerQueriesModule(fileName) {
1064
+ return this.registry.load(fileName);
1065
+ }
1059
1066
  };
1060
1067
  var PlasmicComponentLoader = class {
1061
1068
  constructor(internal) {
@@ -1173,6 +1180,26 @@ var PlasmicComponentLoader = class {
1173
1180
  clearCache() {
1174
1181
  return this.__internal.clearCache();
1175
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
+ }
1176
1203
  };
1177
1204
 
1178
1205
  // src/loader-client.ts
@@ -1204,6 +1231,7 @@ var InternalPlasmicComponentLoader = class extends BaseInternalPlasmicComponentL
1204
1231
  "@plasmicapp/query": PlasmicQuery,
1205
1232
  "@plasmicapp/data-sources-context": PlasmicDataSourcesContext,
1206
1233
  "@plasmicapp/host": PlasmicHost,
1234
+ "@plasmicapp/host/registerFunction": internalSetRegisteredFunction,
1207
1235
  "@plasmicapp/loader-runtime-registry": {
1208
1236
  components: SUBSTITUTED_COMPONENTS,
1209
1237
  globalVariantHooks: SUBSTITUTED_GLOBAL_VARIANT_HOOKS,
@@ -1248,7 +1276,7 @@ var InternalPlasmicComponentLoader = class extends BaseInternalPlasmicComponentL
1248
1276
  (0, import_host2.registerFunction)(fn, __spreadProps(__spreadValues({}, meta), {
1249
1277
  importPath: (_a = meta.importPath) != null ? _a : ""
1250
1278
  }));
1251
- REGISTERED_CUSTOM_FUNCTIONS[customFunctionImportAlias(meta)] = fn;
1279
+ internalSetRegisteredFunction(fn, meta);
1252
1280
  }
1253
1281
  registerGlobalContext(context, meta) {
1254
1282
  var _a;