@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.d.ts CHANGED
@@ -38,6 +38,7 @@ import { default as React_3 } from 'react';
38
38
  import { reactDom } from 'react-dom';
39
39
  import { reactJsxDevRuntime } from 'react/jsx-dev-runtime';
40
40
  import { reactJsxRuntime } from 'react/jsx-runtime';
41
+ import { registerFunction } from '@plasmicapp/host';
41
42
  import { Registry } from '@plasmicapp/loader-core';
42
43
  import { repeatedElement } from '@plasmicapp/host';
43
44
  import { Split } from '@plasmicapp/loader-fetcher';
@@ -110,6 +111,7 @@ declare abstract class BaseInternalPlasmicComponentLoader {
110
111
  getTeamIds(): string[];
111
112
  getProjectIds(): string[];
112
113
  trackRender(opts?: TrackRenderOptions): void;
114
+ loadServerQueriesModule(fileName: string): any;
113
115
  }
114
116
 
115
117
  declare interface BuiltinRegisteredModules {
@@ -120,6 +122,7 @@ declare interface BuiltinRegisteredModules {
120
122
  "@plasmicapp/query": plasmicappQuery;
121
123
  "@plasmicapp/data-sources-context": plasmicappDataSourcesContext;
122
124
  "@plasmicapp/host": plasmicappHost;
125
+ "@plasmicapp/host/registerFunction": registerFunction;
123
126
  "@plasmicapp/loader-runtime-registry": {
124
127
  components: Record<string, React.ComponentType<any>>;
125
128
  globalVariantHooks: Record<string, () => any>;
@@ -484,6 +487,7 @@ export declare class PlasmicComponentLoader {
484
487
  getActiveSplits(): Split[];
485
488
  trackConversion(value?: number): void;
486
489
  clearCache(): void;
490
+ unstable__getServerQueriesData(renderData: ComponentRenderData, $ctx: Record<string, any>): Promise<any>;
487
491
  }
488
492
 
489
493
  /**
package/dist/index.esm.js CHANGED
@@ -745,6 +745,9 @@ function customFunctionImportAlias(meta) {
745
745
  const customFunctionPrefix = `__fn_`;
746
746
  return meta.namespace ? `${customFunctionPrefix}${meta.namespace}__${meta.name}` : `${customFunctionPrefix}${meta.name}`;
747
747
  }
748
+ function internalSetRegisteredFunction(fn, meta) {
749
+ REGISTERED_CUSTOM_FUNCTIONS[customFunctionImportAlias(meta)] = fn;
750
+ }
748
751
  function parseFetchComponentDataArgs(...args) {
749
752
  let specs;
750
753
  let opts;
@@ -1009,6 +1012,9 @@ ${this.bundle.bundleKey}`
1009
1012
  trackRender(opts) {
1010
1013
  this.tracker.trackRender(opts);
1011
1014
  }
1015
+ loadServerQueriesModule(fileName) {
1016
+ return this.registry.load(fileName);
1017
+ }
1012
1018
  };
1013
1019
  var PlasmicComponentLoader = class {
1014
1020
  constructor(internal) {
@@ -1126,6 +1132,26 @@ var PlasmicComponentLoader = class {
1126
1132
  clearCache() {
1127
1133
  return this.__internal.clearCache();
1128
1134
  }
1135
+ unstable__getServerQueriesData(renderData, $ctx) {
1136
+ return __async(this, null, function* () {
1137
+ if (renderData.entryCompMetas.length === 0) {
1138
+ return {};
1139
+ }
1140
+ const fileName = renderData.entryCompMetas[0].serverQueriesExecFuncFileName;
1141
+ if (!fileName) {
1142
+ return {};
1143
+ }
1144
+ const module = this.__internal.loadServerQueriesModule(fileName);
1145
+ const { executeServerQueries } = module;
1146
+ try {
1147
+ const $serverQueries = yield executeServerQueries($ctx);
1148
+ return $serverQueries;
1149
+ } catch (err) {
1150
+ console.error("Error executing server queries function", err);
1151
+ return {};
1152
+ }
1153
+ });
1154
+ }
1129
1155
  };
1130
1156
 
1131
1157
  // src/loader-client.ts
@@ -1157,6 +1183,7 @@ var InternalPlasmicComponentLoader = class extends BaseInternalPlasmicComponentL
1157
1183
  "@plasmicapp/query": PlasmicQuery,
1158
1184
  "@plasmicapp/data-sources-context": PlasmicDataSourcesContext,
1159
1185
  "@plasmicapp/host": PlasmicHost,
1186
+ "@plasmicapp/host/registerFunction": internalSetRegisteredFunction,
1160
1187
  "@plasmicapp/loader-runtime-registry": {
1161
1188
  components: SUBSTITUTED_COMPONENTS,
1162
1189
  globalVariantHooks: SUBSTITUTED_GLOBAL_VARIANT_HOOKS,
@@ -1201,7 +1228,7 @@ var InternalPlasmicComponentLoader = class extends BaseInternalPlasmicComponentL
1201
1228
  registerFunction(fn, __spreadProps(__spreadValues({}, meta), {
1202
1229
  importPath: (_a = meta.importPath) != null ? _a : ""
1203
1230
  }));
1204
- REGISTERED_CUSTOM_FUNCTIONS[customFunctionImportAlias(meta)] = fn;
1231
+ internalSetRegisteredFunction(fn, meta);
1205
1232
  }
1206
1233
  registerGlobalContext(context, meta) {
1207
1234
  var _a;