@plasmicapp/loader-react 1.0.416 → 1.0.417
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.esm.js +51 -48
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +46 -43
- package/dist/index.js.map +4 -4
- package/dist/react-server.esm.js +51 -28
- package/dist/react-server.esm.js.map +4 -4
- package/dist/react-server.js +29 -6
- package/dist/react-server.js.map +4 -4
- package/package.json +5 -5
package/dist/react-server.esm.js
CHANGED
|
@@ -55,7 +55,7 @@ import "server-only";
|
|
|
55
55
|
|
|
56
56
|
// src/loader-server.tsx
|
|
57
57
|
import { PlasmicModulesFetcher as PlasmicModulesFetcher2 } from "@plasmicapp/loader-core";
|
|
58
|
-
import
|
|
58
|
+
import React3 from "react";
|
|
59
59
|
import ReactDOM from "react-dom";
|
|
60
60
|
import * as jsxDevRuntime from "react/jsx-dev-runtime";
|
|
61
61
|
import * as jsxRuntime from "react/jsx-runtime";
|
|
@@ -926,6 +926,19 @@ var PlasmicComponentLoader = class {
|
|
|
926
926
|
}
|
|
927
927
|
};
|
|
928
928
|
|
|
929
|
+
// src/react-utils.ts
|
|
930
|
+
import * as React2 from "react";
|
|
931
|
+
var REACT_MAJOR_VERSION = +React2.version.split(".")[0];
|
|
932
|
+
function reactCurrentDispatcher() {
|
|
933
|
+
var _a2, _b, _c, _d, _e;
|
|
934
|
+
const r = React2;
|
|
935
|
+
if (REACT_MAJOR_VERSION <= 18) {
|
|
936
|
+
return (_b = (_a2 = r["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"]) == null ? void 0 : _a2.ReactCurrentDispatcher) == null ? void 0 : _b.current;
|
|
937
|
+
} else {
|
|
938
|
+
return (_e = (_c = r["__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE"]) == null ? void 0 : _c.H) != null ? _e : (_d = r["__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE"]) == null ? void 0 : _d.H;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
|
|
929
942
|
// src/swr-util.ts
|
|
930
943
|
function swrSerialize(key) {
|
|
931
944
|
if (typeof key === "function") {
|
|
@@ -1017,13 +1030,13 @@ function FakeDataProvider({
|
|
|
1017
1030
|
const { readContextValue, setContextValue } = getPrepassContextEnv();
|
|
1018
1031
|
const existingEnv = (_a2 = readContextValue(FakeDataContext)) != null ? _a2 : {};
|
|
1019
1032
|
if (!name) {
|
|
1020
|
-
return /* @__PURE__ */
|
|
1033
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, children);
|
|
1021
1034
|
} else {
|
|
1022
1035
|
setContextValue(FakeDataContext, __spreadProps(__spreadValues({}, existingEnv), {
|
|
1023
1036
|
[name]: data,
|
|
1024
1037
|
[mkMetaName(name)]: { hidden, advanced, label }
|
|
1025
1038
|
}));
|
|
1026
|
-
return /* @__PURE__ */
|
|
1039
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, children);
|
|
1027
1040
|
}
|
|
1028
1041
|
}
|
|
1029
1042
|
var fakeApplySelector = (rawData, selector) => {
|
|
@@ -1100,7 +1113,7 @@ var FakeReactComponent = (_a = class {
|
|
|
1100
1113
|
}
|
|
1101
1114
|
initRender(props) {
|
|
1102
1115
|
this.props = props;
|
|
1103
|
-
const dispatcher =
|
|
1116
|
+
const dispatcher = reactCurrentDispatcher();
|
|
1104
1117
|
const [state, setState] = dispatcher.useState({});
|
|
1105
1118
|
this.state = state;
|
|
1106
1119
|
this.setState = setState;
|
|
@@ -1130,14 +1143,14 @@ var InternalPrepassPlasmicLoader = class extends BaseInternalPlasmicComponentLoa
|
|
|
1130
1143
|
},
|
|
1131
1144
|
fetcher: new PlasmicModulesFetcher2(opts),
|
|
1132
1145
|
builtinModules: {
|
|
1133
|
-
react: __spreadProps(__spreadValues(__spreadProps(__spreadValues(__spreadValues({},
|
|
1146
|
+
react: __spreadProps(__spreadValues(__spreadProps(__spreadValues(__spreadValues({}, React3), { isRSC: true }), {
|
|
1134
1147
|
createContext: (defaultValue) => {
|
|
1135
1148
|
const context = {
|
|
1136
1149
|
_currentValue: defaultValue,
|
|
1137
1150
|
displayName: "FakeContext",
|
|
1138
1151
|
Provider: ({ value, children }) => {
|
|
1139
1152
|
getPrepassContextEnv().setContextValue(context, value);
|
|
1140
|
-
return /* @__PURE__ */
|
|
1153
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, children);
|
|
1141
1154
|
},
|
|
1142
1155
|
Consumer: ({ children }) => children(getPrepassContextEnv().readContextValue(context))
|
|
1143
1156
|
};
|
|
@@ -1147,24 +1160,34 @@ var InternalPrepassPlasmicLoader = class extends BaseInternalPlasmicComponentLoa
|
|
|
1147
1160
|
[
|
|
1148
1161
|
"useCallback",
|
|
1149
1162
|
"useContext",
|
|
1163
|
+
"useDebugValue",
|
|
1150
1164
|
"useEffect",
|
|
1151
1165
|
"useImperativeHandle",
|
|
1152
|
-
"useDebugValue",
|
|
1153
|
-
"useInsertionEffect",
|
|
1154
1166
|
"useLayoutEffect",
|
|
1155
1167
|
"useMemo",
|
|
1156
|
-
"useSyncExternalStore",
|
|
1157
1168
|
"useReducer",
|
|
1158
1169
|
"useRef",
|
|
1159
|
-
"useState"
|
|
1170
|
+
"useState",
|
|
1171
|
+
// React 18+
|
|
1172
|
+
"useId",
|
|
1173
|
+
"useInsertionEffect",
|
|
1174
|
+
"useSyncExternalStore",
|
|
1175
|
+
// React 19+
|
|
1176
|
+
"use",
|
|
1177
|
+
"useActionState",
|
|
1178
|
+
"useEffectEvent",
|
|
1179
|
+
"useOptimistic"
|
|
1160
1180
|
].map((hook) => [
|
|
1161
1181
|
hook,
|
|
1162
1182
|
(...args) => {
|
|
1163
|
-
const dispatcher =
|
|
1183
|
+
const dispatcher = reactCurrentDispatcher();
|
|
1164
1184
|
return dispatcher[hook](...args);
|
|
1165
1185
|
}
|
|
1166
1186
|
])
|
|
1167
1187
|
)), {
|
|
1188
|
+
// TODO: ensure correct implementation in react-ssr-prepass and
|
|
1189
|
+
// merge with above array to rely on dispatcher
|
|
1190
|
+
// React 18+
|
|
1168
1191
|
useDeferredValue: (v) => v,
|
|
1169
1192
|
useTransition: () => [
|
|
1170
1193
|
false,
|
|
@@ -1172,10 +1195,10 @@ var InternalPrepassPlasmicLoader = class extends BaseInternalPlasmicComponentLoa
|
|
|
1172
1195
|
f();
|
|
1173
1196
|
}
|
|
1174
1197
|
],
|
|
1175
|
-
createFactory: (type) =>
|
|
1198
|
+
createFactory: (type) => React3.createElement.bind(null, type),
|
|
1176
1199
|
Component: FakeReactComponent,
|
|
1177
1200
|
PureComponent: FakeReactComponent,
|
|
1178
|
-
createElement: fakeCreateElement(
|
|
1201
|
+
createElement: fakeCreateElement(React3.createElement)
|
|
1179
1202
|
}),
|
|
1180
1203
|
"react-dom": ReactDOM,
|
|
1181
1204
|
"react/jsx-runtime": __spreadValues(__spreadValues(__spreadValues(__spreadValues({}, jsxRuntime), jsxRuntime.jsx ? { jsx: fakeCreateElement(jsxRuntime.jsx) } : {}), jsxRuntime.jsxs ? { jsxs: fakeCreateElement(jsxRuntime.jsxs) } : {}), jsxRuntime.jsxDEV ? { jsxDEV: fakeCreateElement(jsxRuntime.jsxDEV) } : {}),
|
|
@@ -1184,7 +1207,7 @@ var InternalPrepassPlasmicLoader = class extends BaseInternalPlasmicComponentLoa
|
|
|
1184
1207
|
addLoadingStateListener: () => noop,
|
|
1185
1208
|
isPlasmicPrepass: () => true,
|
|
1186
1209
|
PlasmicPrepassContext: {},
|
|
1187
|
-
PlasmicQueryDataProvider: ({ children }) => /* @__PURE__ */
|
|
1210
|
+
PlasmicQueryDataProvider: ({ children }) => /* @__PURE__ */ React3.createElement(React3.Fragment, null, children),
|
|
1188
1211
|
useMutablePlasmicQueryData: fakeUseMutablePlasmicQueryData,
|
|
1189
1212
|
usePlasmicDataConfig: fakeUsePlasmicDataConfig,
|
|
1190
1213
|
usePlasmicQueryData: fakeUseMutablePlasmicQueryData,
|
|
@@ -1193,7 +1216,7 @@ var InternalPrepassPlasmicLoader = class extends BaseInternalPlasmicComponentLoa
|
|
|
1193
1216
|
HeadMetadataContext: {
|
|
1194
1217
|
_currentValue: {},
|
|
1195
1218
|
displayName: "FakeHeadMetadataContext",
|
|
1196
|
-
Provider: ({ children }) => /* @__PURE__ */
|
|
1219
|
+
Provider: ({ children }) => /* @__PURE__ */ React3.createElement(React3.Fragment, null, children),
|
|
1197
1220
|
Consumer: ({ children }) => children({})
|
|
1198
1221
|
}
|
|
1199
1222
|
},
|
|
@@ -1207,7 +1230,7 @@ var InternalPrepassPlasmicLoader = class extends BaseInternalPlasmicComponentLoa
|
|
|
1207
1230
|
({ children, value }) => {
|
|
1208
1231
|
const { setContextValue } = getPrepassContextEnv();
|
|
1209
1232
|
setContextValue(FakePlasmicDataSourceContext, value);
|
|
1210
|
-
return /* @__PURE__ */
|
|
1233
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, children);
|
|
1211
1234
|
},
|
|
1212
1235
|
{
|
|
1213
1236
|
$$typeof: REACT_PROVIDER_TYPE,
|
|
@@ -1238,13 +1261,13 @@ var InternalPrepassPlasmicLoader = class extends BaseInternalPlasmicComponentLoa
|
|
|
1238
1261
|
_currentValue: void 0
|
|
1239
1262
|
// default value
|
|
1240
1263
|
},
|
|
1241
|
-
GlobalActionsProvider: ({ children }) => /* @__PURE__ */
|
|
1264
|
+
GlobalActionsProvider: ({ children }) => /* @__PURE__ */ React3.createElement(React3.Fragment, null, children),
|
|
1242
1265
|
mkMetaName,
|
|
1243
1266
|
mkMetaValue: identity,
|
|
1244
|
-
PageParamsProvider: ({ children }) => /* @__PURE__ */
|
|
1267
|
+
PageParamsProvider: ({ children }) => /* @__PURE__ */ React3.createElement(React3.Fragment, null, children),
|
|
1245
1268
|
PlasmicCanvasContext: { _currentValue: false },
|
|
1246
1269
|
PlasmicCanvasHost: () => null,
|
|
1247
|
-
PlasmicLinkProvider: ({ children }) => /* @__PURE__ */
|
|
1270
|
+
PlasmicLinkProvider: ({ children }) => /* @__PURE__ */ React3.createElement(React3.Fragment, null, children),
|
|
1248
1271
|
registerComponent: noop,
|
|
1249
1272
|
registerFunction: noop,
|
|
1250
1273
|
registerGlobalContext: noop,
|
|
@@ -1263,7 +1286,7 @@ var InternalPrepassPlasmicLoader = class extends BaseInternalPlasmicComponentLoa
|
|
|
1263
1286
|
usePlasmicTranslator: () => void 0,
|
|
1264
1287
|
PlasmicTranslatorContext: { _currentValue: void 0 },
|
|
1265
1288
|
usePlasmicCanvasContext: () => false,
|
|
1266
|
-
usePlasmicLink: () => (props) => /* @__PURE__ */
|
|
1289
|
+
usePlasmicLink: () => (props) => /* @__PURE__ */ React3.createElement("a", __spreadValues({}, props)),
|
|
1267
1290
|
usePlasmicLinkMaybe: () => void 0,
|
|
1268
1291
|
useSelector: fakeUseSelector,
|
|
1269
1292
|
useSelectors: fakeUseSelectors,
|
|
@@ -1312,18 +1335,18 @@ var InternalPrepassPlasmicLoader = class extends BaseInternalPlasmicComponentLoa
|
|
|
1312
1335
|
const children = Array.isArray(serverInfo.children) ? serverInfo.children : [serverInfo.children];
|
|
1313
1336
|
children.forEach((childData) => {
|
|
1314
1337
|
contents.push(
|
|
1315
|
-
/* @__PURE__ */
|
|
1338
|
+
/* @__PURE__ */ React3.createElement(ContextAndDataProviderWrapper, { contextAndData: childData }, childData.node)
|
|
1316
1339
|
);
|
|
1317
1340
|
});
|
|
1318
|
-
return /* @__PURE__ */
|
|
1341
|
+
return /* @__PURE__ */ React3.createElement(ContextAndDataProviderWrapper, { contextAndData: serverInfo }, contents);
|
|
1319
1342
|
} else {
|
|
1320
|
-
return /* @__PURE__ */
|
|
1343
|
+
return /* @__PURE__ */ React3.createElement(
|
|
1321
1344
|
ContextAndDataProviderWrapper,
|
|
1322
1345
|
{
|
|
1323
1346
|
contextAndData: serverInfo != null ? serverInfo : {}
|
|
1324
1347
|
},
|
|
1325
1348
|
Object.values(props).flat(Infinity).filter(
|
|
1326
|
-
(v) => v && typeof v == "object" && v.$$typeof &&
|
|
1349
|
+
(v) => v && typeof v == "object" && v.$$typeof && React3.isValidElement(v)
|
|
1327
1350
|
)
|
|
1328
1351
|
);
|
|
1329
1352
|
}
|
|
@@ -1482,7 +1505,7 @@ function handlePrepassPlasmicComponent(props) {
|
|
|
1482
1505
|
return null;
|
|
1483
1506
|
}
|
|
1484
1507
|
const Component = lookup.getComponent(spec, opts);
|
|
1485
|
-
let element = /* @__PURE__ */
|
|
1508
|
+
let element = /* @__PURE__ */ React3.createElement(Component, __spreadValues({}, componentProps));
|
|
1486
1509
|
if (isRootLoader) {
|
|
1487
1510
|
const ReactWebRootProvider = lookup.getRootProvider();
|
|
1488
1511
|
const GlobalContextsProvider = lookup.getGlobalContextsProvider({
|
|
@@ -1490,7 +1513,7 @@ function handlePrepassPlasmicComponent(props) {
|
|
|
1490
1513
|
projectId
|
|
1491
1514
|
});
|
|
1492
1515
|
setContextValue(FakePlasmicComponentContext, true);
|
|
1493
|
-
element = /* @__PURE__ */
|
|
1516
|
+
element = /* @__PURE__ */ React3.createElement(
|
|
1494
1517
|
ReactWebRootProvider,
|
|
1495
1518
|
__spreadProps(__spreadValues({}, rest), {
|
|
1496
1519
|
userAuthToken,
|
|
@@ -1504,7 +1527,7 @@ function handlePrepassPlasmicComponent(props) {
|
|
|
1504
1527
|
element
|
|
1505
1528
|
);
|
|
1506
1529
|
if (GlobalContextsProvider) {
|
|
1507
|
-
element = /* @__PURE__ */
|
|
1530
|
+
element = /* @__PURE__ */ React3.createElement(GlobalContextsProvider, __spreadValues({}, globalContextsProps), element);
|
|
1508
1531
|
}
|
|
1509
1532
|
}
|
|
1510
1533
|
return element;
|
|
@@ -1535,7 +1558,7 @@ function ContextAndDataProviderWrapper({
|
|
|
1535
1558
|
});
|
|
1536
1559
|
});
|
|
1537
1560
|
setContextValue(FakeDataContext, $ctx);
|
|
1538
|
-
return /* @__PURE__ */
|
|
1561
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, children);
|
|
1539
1562
|
}
|
|
1540
1563
|
|
|
1541
1564
|
// src/prepass-server.ts
|