@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.d.ts +4 -0
- package/dist/index.esm.js +28 -8
- package/dist/index.esm.js.map +2 -2
- package/dist/index.js +28 -8
- package/dist/index.js.map +3 -3
- package/dist/react-server.d.ts +4 -0
- package/dist/react-server.esm.js +27 -0
- package/dist/react-server.esm.js.map +2 -2
- package/dist/react-server.js +27 -0
- package/dist/react-server.js.map +3 -3
- package/package.json +5 -5
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
|
@@ -231,12 +231,6 @@ function getPlasmicCookieValues() {
|
|
|
231
231
|
function updatePlasmicCookieValue(key, value) {
|
|
232
232
|
document.cookie = `plasmic:${key}=${value}`;
|
|
233
233
|
}
|
|
234
|
-
function ensureVariationCookies(variation = {}) {
|
|
235
|
-
Object.keys(variation).map((variationKey) => {
|
|
236
|
-
const sliceId = variation[variationKey];
|
|
237
|
-
updatePlasmicCookieValue(variationKey, sliceId);
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
234
|
var getGlobalVariantsFromSplits = (splits, variation) => {
|
|
241
235
|
const globalVariants = [];
|
|
242
236
|
Object.keys(variation).map((variationKey) => {
|
|
@@ -383,7 +377,6 @@ function PlasmicRootProvider(props) {
|
|
|
383
377
|
currentContextValue
|
|
384
378
|
]);
|
|
385
379
|
React2.useEffect(() => {
|
|
386
|
-
ensureVariationCookies(variation);
|
|
387
380
|
loader.trackRender({
|
|
388
381
|
renderCtx: {
|
|
389
382
|
// We track the provider as a single entity
|
|
@@ -745,6 +738,9 @@ function customFunctionImportAlias(meta) {
|
|
|
745
738
|
const customFunctionPrefix = `__fn_`;
|
|
746
739
|
return meta.namespace ? `${customFunctionPrefix}${meta.namespace}__${meta.name}` : `${customFunctionPrefix}${meta.name}`;
|
|
747
740
|
}
|
|
741
|
+
function internalSetRegisteredFunction(fn, meta) {
|
|
742
|
+
REGISTERED_CUSTOM_FUNCTIONS[customFunctionImportAlias(meta)] = fn;
|
|
743
|
+
}
|
|
748
744
|
function parseFetchComponentDataArgs(...args) {
|
|
749
745
|
let specs;
|
|
750
746
|
let opts;
|
|
@@ -1009,6 +1005,9 @@ ${this.bundle.bundleKey}`
|
|
|
1009
1005
|
trackRender(opts) {
|
|
1010
1006
|
this.tracker.trackRender(opts);
|
|
1011
1007
|
}
|
|
1008
|
+
loadServerQueriesModule(fileName) {
|
|
1009
|
+
return this.registry.load(fileName);
|
|
1010
|
+
}
|
|
1012
1011
|
};
|
|
1013
1012
|
var PlasmicComponentLoader = class {
|
|
1014
1013
|
constructor(internal) {
|
|
@@ -1126,6 +1125,26 @@ var PlasmicComponentLoader = class {
|
|
|
1126
1125
|
clearCache() {
|
|
1127
1126
|
return this.__internal.clearCache();
|
|
1128
1127
|
}
|
|
1128
|
+
unstable__getServerQueriesData(renderData, $ctx) {
|
|
1129
|
+
return __async(this, null, function* () {
|
|
1130
|
+
if (renderData.entryCompMetas.length === 0) {
|
|
1131
|
+
return {};
|
|
1132
|
+
}
|
|
1133
|
+
const fileName = renderData.entryCompMetas[0].serverQueriesExecFuncFileName;
|
|
1134
|
+
if (!fileName) {
|
|
1135
|
+
return {};
|
|
1136
|
+
}
|
|
1137
|
+
const module = this.__internal.loadServerQueriesModule(fileName);
|
|
1138
|
+
const { executeServerQueries } = module;
|
|
1139
|
+
try {
|
|
1140
|
+
const $serverQueries = yield executeServerQueries($ctx);
|
|
1141
|
+
return $serverQueries;
|
|
1142
|
+
} catch (err) {
|
|
1143
|
+
console.error("Error executing server queries function", err);
|
|
1144
|
+
return {};
|
|
1145
|
+
}
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1129
1148
|
};
|
|
1130
1149
|
|
|
1131
1150
|
// src/loader-client.ts
|
|
@@ -1157,6 +1176,7 @@ var InternalPlasmicComponentLoader = class extends BaseInternalPlasmicComponentL
|
|
|
1157
1176
|
"@plasmicapp/query": PlasmicQuery,
|
|
1158
1177
|
"@plasmicapp/data-sources-context": PlasmicDataSourcesContext,
|
|
1159
1178
|
"@plasmicapp/host": PlasmicHost,
|
|
1179
|
+
"@plasmicapp/host/registerFunction": internalSetRegisteredFunction,
|
|
1160
1180
|
"@plasmicapp/loader-runtime-registry": {
|
|
1161
1181
|
components: SUBSTITUTED_COMPONENTS,
|
|
1162
1182
|
globalVariantHooks: SUBSTITUTED_GLOBAL_VARIANT_HOOKS,
|
|
@@ -1201,7 +1221,7 @@ var InternalPlasmicComponentLoader = class extends BaseInternalPlasmicComponentL
|
|
|
1201
1221
|
registerFunction(fn, __spreadProps(__spreadValues({}, meta), {
|
|
1202
1222
|
importPath: (_a = meta.importPath) != null ? _a : ""
|
|
1203
1223
|
}));
|
|
1204
|
-
|
|
1224
|
+
internalSetRegisteredFunction(fn, meta);
|
|
1205
1225
|
}
|
|
1206
1226
|
registerGlobalContext(context, meta) {
|
|
1207
1227
|
var _a;
|