@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.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';
@@ -48,6 +49,7 @@ import { TrackRenderOptions } from '@plasmicapp/loader-core';
48
49
  import { TraitMeta } from '@plasmicapp/host';
49
50
  import { useDataEnv } from '@plasmicapp/host';
50
51
  import type { useMutablePlasmicQueryData } from '@plasmicapp/query';
52
+ import { usePlasmicCanvasComponentInfo } from '@plasmicapp/host';
51
53
  import { usePlasmicCanvasContext } from '@plasmicapp/host';
52
54
  import { usePlasmicQueryData } from '@plasmicapp/query';
53
55
  import { useSelector } from '@plasmicapp/host';
@@ -109,6 +111,7 @@ declare abstract class BaseInternalPlasmicComponentLoader {
109
111
  getTeamIds(): string[];
110
112
  getProjectIds(): string[];
111
113
  trackRender(opts?: TrackRenderOptions): void;
114
+ loadServerQueriesModule(fileName: string): any;
112
115
  }
113
116
 
114
117
  declare interface BuiltinRegisteredModules {
@@ -119,6 +122,7 @@ declare interface BuiltinRegisteredModules {
119
122
  "@plasmicapp/query": plasmicappQuery;
120
123
  "@plasmicapp/data-sources-context": plasmicappDataSourcesContext;
121
124
  "@plasmicapp/host": plasmicappHost;
125
+ "@plasmicapp/host/registerFunction": registerFunction;
122
126
  "@plasmicapp/loader-runtime-registry": {
123
127
  components: Record<string, React.ComponentType<any>>;
124
128
  globalVariantHooks: Record<string, () => any>;
@@ -483,6 +487,7 @@ export declare class PlasmicComponentLoader {
483
487
  getActiveSplits(): Split[];
484
488
  trackConversion(value?: number): void;
485
489
  clearCache(): void;
490
+ unstable__getServerQueriesData(renderData: ComponentRenderData, $ctx: Record<string, any>): Promise<any>;
486
491
  }
487
492
 
488
493
  /**
@@ -687,6 +692,8 @@ export { TokenRegistration }
687
692
 
688
693
  export { useDataEnv }
689
694
 
695
+ export { usePlasmicCanvasComponentInfo }
696
+
690
697
  export { usePlasmicCanvasContext }
691
698
 
692
699
  /**
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;
@@ -1247,6 +1274,7 @@ import {
1247
1274
  PlasmicTranslatorContext,
1248
1275
  repeatedElement,
1249
1276
  useDataEnv,
1277
+ usePlasmicCanvasComponentInfo,
1250
1278
  usePlasmicCanvasContext,
1251
1279
  useSelector,
1252
1280
  useSelectors
@@ -1478,6 +1506,7 @@ export {
1478
1506
  renderToString,
1479
1507
  repeatedElement,
1480
1508
  useDataEnv,
1509
+ usePlasmicCanvasComponentInfo,
1481
1510
  usePlasmicCanvasContext,
1482
1511
  usePlasmicComponent,
1483
1512
  usePlasmicQueryData,