@plasmicapp/react-web 0.2.330 → 0.2.331
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/nextjs-app-router/index.d.ts +1 -0
- package/dist/nextjs-app-router/react-server/index.d.ts +15 -0
- package/lib/nextjs-app-router/index.cjs.js +11 -0
- package/lib/nextjs-app-router/index.cjs.js.map +1 -0
- package/lib/nextjs-app-router/index.d.ts +1 -0
- package/lib/nextjs-app-router/index.js +2 -0
- package/lib/nextjs-app-router/index.js.map +1 -0
- package/lib/nextjs-app-router/package.json +8 -0
- package/lib/nextjs-app-router/react-server/index.cjs.js +135 -0
- package/lib/nextjs-app-router/react-server/index.cjs.js.map +1 -0
- package/lib/nextjs-app-router/react-server/index.d.ts +15 -0
- package/lib/nextjs-app-router/react-server/index.js +130 -0
- package/lib/nextjs-app-router/react-server/index.js.map +1 -0
- package/lib/nextjs-app-router/react-server/package.json +8 -0
- package/package.json +13 -2
- package/skinny/dist/nextjs-app-router/index.d.ts +1 -0
- package/skinny/dist/nextjs-app-router/react-server/index.d.ts +15 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ExtractPlasmicQueryData as __EXPERMIENTAL__ExtractPlasmicQueryData } from "@plasmicapp/nextjs-app-router";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { fetchExtractedQueryData } from "@plasmicapp/nextjs-app-router/react-server";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export { fetchExtractedQueryData as __EXPERMIENTAL__fetchExtractedQueryData };
|
|
4
|
+
/**
|
|
5
|
+
* Helper function to extract Plasmic data.
|
|
6
|
+
*
|
|
7
|
+
* Given React element for your page and current pathname + search
|
|
8
|
+
* params, returns:
|
|
9
|
+
* - The extracted query data, if `plasmicSsr` search param is set
|
|
10
|
+
* - A copy of the page element wraped within PlasmicQueryDataProvider to provide the extracted query data, otherwise
|
|
11
|
+
*/
|
|
12
|
+
export declare function __EXPERMIENTAL__withExtractPlasmicQueryData(pageRootElt: React.ReactElement, { pathname, searchParams, }: {
|
|
13
|
+
pathname: string;
|
|
14
|
+
searchParams: Record<string, string | string[]> | undefined;
|
|
15
|
+
}): Promise<React.JSX.Element>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var nextjsAppRouter = require('@plasmicapp/nextjs-app-router');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, '__EXPERMIENTAL__ExtractPlasmicQueryData', {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return nextjsAppRouter.ExtractPlasmicQueryData; }
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ExtractPlasmicQueryData as __EXPERMIENTAL__ExtractPlasmicQueryData } from "@plasmicapp/nextjs-app-router";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var nextjsAppRouter = require('@plasmicapp/nextjs-app-router');
|
|
4
|
+
var reactServer = require('@plasmicapp/nextjs-app-router/react-server');
|
|
5
|
+
var query = require('@plasmicapp/query');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
|
|
8
|
+
/******************************************************************************
|
|
9
|
+
Copyright (c) Microsoft Corporation.
|
|
10
|
+
|
|
11
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
12
|
+
purpose with or without fee is hereby granted.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
15
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
16
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
17
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
18
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
19
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
20
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
21
|
+
***************************************************************************** */
|
|
22
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function __generator(thisArg, body) {
|
|
36
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
37
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
38
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
39
|
+
function step(op) {
|
|
40
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
41
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
42
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
43
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
44
|
+
switch (op[0]) {
|
|
45
|
+
case 0: case 1: t = op; break;
|
|
46
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
47
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
48
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
49
|
+
default:
|
|
50
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
51
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
52
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
53
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
54
|
+
if (t[2]) _.ops.pop();
|
|
55
|
+
_.trys.pop(); continue;
|
|
56
|
+
}
|
|
57
|
+
op = body.call(thisArg, _);
|
|
58
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
59
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function __read(o, n) {
|
|
64
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
65
|
+
if (!m) return o;
|
|
66
|
+
var i = m.call(o), r, ar = [], e;
|
|
67
|
+
try {
|
|
68
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
69
|
+
}
|
|
70
|
+
catch (error) { e = { error: error }; }
|
|
71
|
+
finally {
|
|
72
|
+
try {
|
|
73
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
74
|
+
}
|
|
75
|
+
finally { if (e) throw e.error; }
|
|
76
|
+
}
|
|
77
|
+
return ar;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
81
|
+
var e = new Error(message);
|
|
82
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Helper function to extract Plasmic data.
|
|
87
|
+
*
|
|
88
|
+
* Given React element for your page and current pathname + search
|
|
89
|
+
* params, returns:
|
|
90
|
+
* - The extracted query data, if `plasmicSsr` search param is set
|
|
91
|
+
* - A copy of the page element wraped within PlasmicQueryDataProvider to provide the extracted query data, otherwise
|
|
92
|
+
*/
|
|
93
|
+
function __EXPERMIENTAL__withExtractPlasmicQueryData(pageRootElt, _a) {
|
|
94
|
+
var _b, _c, _d;
|
|
95
|
+
var pathname = _a.pathname, searchParams = _a.searchParams;
|
|
96
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
97
|
+
var isPlasmicSsr, prepassHost, newSearchParams, prefetchedQueryData;
|
|
98
|
+
return __generator(this, function (_e) {
|
|
99
|
+
switch (_e.label) {
|
|
100
|
+
case 0:
|
|
101
|
+
isPlasmicSsr = !!(searchParams === null || searchParams === void 0 ? void 0 : searchParams["plasmicSsr"]) && (searchParams === null || searchParams === void 0 ? void 0 : searchParams["plasmicSsr"]) !== "false";
|
|
102
|
+
// If `plasmicSsr` search param is set, just wrap the page inside
|
|
103
|
+
// <ExtractPlasmicQueryData>
|
|
104
|
+
if (isPlasmicSsr) {
|
|
105
|
+
return [2 /*return*/, React.createElement(nextjsAppRouter.ExtractPlasmicQueryData, null, pageRootElt)];
|
|
106
|
+
}
|
|
107
|
+
prepassHost = (_c = (_b = process.env.PLASMIC_PREPASS_HOST) !== null && _b !== void 0 ? _b : (process.env.VERCEL_URL && "https://".concat(process.env.VERCEL_URL))) !== null && _c !== void 0 ? _c : "http://localhost:".concat((_d = process.env.PORT) !== null && _d !== void 0 ? _d : 3000);
|
|
108
|
+
newSearchParams = new URLSearchParams(Object.entries(searchParams !== null && searchParams !== void 0 ? searchParams : {}).flatMap(function (_a) {
|
|
109
|
+
var _b = __read(_a, 2), key = _b[0], values = _b[1];
|
|
110
|
+
return Array.isArray(values) ? values.map(function (v) { return [key, v]; }) : [[key, values]];
|
|
111
|
+
}));
|
|
112
|
+
// Set `plasmicSsr` search param to indicate you are using this endpoint
|
|
113
|
+
// to extract query data.
|
|
114
|
+
newSearchParams.set("plasmicSsr", "true");
|
|
115
|
+
if (process.env.VERCEL_AUTOMATION_BYPASS_SECRET) {
|
|
116
|
+
// If protection bypass is enabled, use it to ensure fetching from
|
|
117
|
+
// the SSR endpoint will not return the authentication page HTML
|
|
118
|
+
newSearchParams.set("x-vercel-protection-bypass", process.env.VERCEL_AUTOMATION_BYPASS_SECRET);
|
|
119
|
+
}
|
|
120
|
+
return [4 /*yield*/, reactServer.fetchExtractedQueryData("".concat(prepassHost).concat(pathname, "?").concat(newSearchParams.toString()))];
|
|
121
|
+
case 1:
|
|
122
|
+
prefetchedQueryData = _e.sent();
|
|
123
|
+
// Provide the query data to your page
|
|
124
|
+
return [2 /*return*/, (React.createElement(query.PlasmicQueryDataProvider, { prefetchedCache: prefetchedQueryData }, pageRootElt))];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
Object.defineProperty(exports, '__EXPERMIENTAL__fetchExtractedQueryData', {
|
|
131
|
+
enumerable: true,
|
|
132
|
+
get: function () { return reactServer.fetchExtractedQueryData; }
|
|
133
|
+
});
|
|
134
|
+
exports.__EXPERMIENTAL__withExtractPlasmicQueryData = __EXPERMIENTAL__withExtractPlasmicQueryData;
|
|
135
|
+
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../../src/nextjs-app-router/react-server/index.tsx"],"sourcesContent":["import { ExtractPlasmicQueryData } from \"@plasmicapp/nextjs-app-router\";\nimport { fetchExtractedQueryData } from \"@plasmicapp/nextjs-app-router/react-server\";\nimport { PlasmicQueryDataProvider } from \"@plasmicapp/query\";\nimport React from \"react\";\n\nexport { fetchExtractedQueryData as __EXPERMIENTAL__fetchExtractedQueryData };\n\n/**\n * Helper function to extract Plasmic data.\n *\n * Given React element for your page and current pathname + search\n * params, returns:\n * - The extracted query data, if `plasmicSsr` search param is set\n * - A copy of the page element wraped within PlasmicQueryDataProvider to provide the extracted query data, otherwise\n */\nexport async function __EXPERMIENTAL__withExtractPlasmicQueryData(\n pageRootElt: React.ReactElement,\n {\n pathname,\n searchParams,\n }: {\n pathname: string;\n searchParams: Record<string, string | string[]> | undefined;\n }\n) {\n const isPlasmicSsr =\n !!searchParams?.[\"plasmicSsr\"] && searchParams?.[\"plasmicSsr\"] !== \"false\";\n\n // If `plasmicSsr` search param is set, just wrap the page inside\n // <ExtractPlasmicQueryData>\n if (isPlasmicSsr) {\n return <ExtractPlasmicQueryData>{pageRootElt}</ExtractPlasmicQueryData>;\n }\n\n // Otherwise, fetch the same endpoint, but setting `plasmicSsr` to extract the\n // query data.\n const prepassHost =\n process.env.PLASMIC_PREPASS_HOST ??\n (process.env.VERCEL_URL && `https://${process.env.VERCEL_URL}`) ??\n `http://localhost:${process.env.PORT ?? 3000}`;\n\n // Build a copy of the search params\n const newSearchParams = new URLSearchParams(\n Object.entries(searchParams ?? {}).flatMap(([key, values]) =>\n Array.isArray(values) ? values.map((v) => [key, v]) : [[key, values]]\n )\n );\n\n // Set `plasmicSsr` search param to indicate you are using this endpoint\n // to extract query data.\n newSearchParams.set(\"plasmicSsr\", \"true\");\n\n if (process.env.VERCEL_AUTOMATION_BYPASS_SECRET) {\n // If protection bypass is enabled, use it to ensure fetching from\n // the SSR endpoint will not return the authentication page HTML\n newSearchParams.set(\n \"x-vercel-protection-bypass\",\n process.env.VERCEL_AUTOMATION_BYPASS_SECRET\n );\n }\n\n // Fetch the data from the endpoint using the new search params\n const prefetchedQueryData = await fetchExtractedQueryData(\n `${prepassHost}${pathname}?${newSearchParams.toString()}`\n );\n\n // Provide the query data to your page\n return (\n <PlasmicQueryDataProvider prefetchedCache={prefetchedQueryData}>\n {pageRootElt}\n </PlasmicQueryDataProvider>\n );\n}\n"],"names":["ExtractPlasmicQueryData","fetchExtractedQueryData","PlasmicQueryDataProvider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;;;;;;;AAOG;AACmB,SAAA,2CAA2C,CAC/D,WAA+B,EAC/B,EAMC,EAAA;;QALC,QAAQ,GAAA,EAAA,CAAA,QAAA,EACR,YAAY,GAAA,EAAA,CAAA,YAAA,CAAA;;;;;;oBAMR,YAAY,GAChB,CAAC,EAAC,YAAY,aAAZ,YAAY,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAZ,YAAY,CAAG,YAAY,CAAC,CAAA,IAAI,CAAA,YAAY,KAAA,IAAA,IAAZ,YAAY,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAZ,YAAY,CAAG,YAAY,CAAC,MAAK,OAAO,CAAC;;;AAI7E,oBAAA,IAAI,YAAY,EAAE;AAChB,wBAAA,OAAA,CAAA,CAAA,aAAO,KAAC,CAAA,aAAA,CAAAA,uCAAuB,EAAE,IAAA,EAAA,WAAW,CAA2B,CAAC,CAAA;AACzE,qBAAA;AAIK,oBAAA,WAAW,GACf,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,OAAO,CAAC,GAAG,CAAC,oBAAoB,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,IAC/B,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,UAAA,CAAA,MAAA,CAAW,OAAO,CAAC,GAAG,CAAC,UAAU,CAAE,CAAC,mCAC/D,mBAAoB,CAAA,MA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A,CAAAC,8BAAwB,EAAC,EAAA,eAAe,EAAE,mBAAmB,EAC3D,EAAA,WAAW,CACa,EAC3B,CAAA;;;;AACH;;;;;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { fetchExtractedQueryData } from "@plasmicapp/nextjs-app-router/react-server";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export { fetchExtractedQueryData as __EXPERMIENTAL__fetchExtractedQueryData };
|
|
4
|
+
/**
|
|
5
|
+
* Helper function to extract Plasmic data.
|
|
6
|
+
*
|
|
7
|
+
* Given React element for your page and current pathname + search
|
|
8
|
+
* params, returns:
|
|
9
|
+
* - The extracted query data, if `plasmicSsr` search param is set
|
|
10
|
+
* - A copy of the page element wraped within PlasmicQueryDataProvider to provide the extracted query data, otherwise
|
|
11
|
+
*/
|
|
12
|
+
export declare function __EXPERMIENTAL__withExtractPlasmicQueryData(pageRootElt: React.ReactElement, { pathname, searchParams, }: {
|
|
13
|
+
pathname: string;
|
|
14
|
+
searchParams: Record<string, string | string[]> | undefined;
|
|
15
|
+
}): Promise<React.JSX.Element>;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { ExtractPlasmicQueryData } from '@plasmicapp/nextjs-app-router';
|
|
2
|
+
import { fetchExtractedQueryData } from '@plasmicapp/nextjs-app-router/react-server';
|
|
3
|
+
export { fetchExtractedQueryData as __EXPERMIENTAL__fetchExtractedQueryData } from '@plasmicapp/nextjs-app-router/react-server';
|
|
4
|
+
import { PlasmicQueryDataProvider } from '@plasmicapp/query';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
/******************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
9
|
+
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
+
***************************************************************************** */
|
|
21
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
25
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
26
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
27
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
28
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
29
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
30
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function __generator(thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function __read(o, n) {
|
|
63
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
64
|
+
if (!m) return o;
|
|
65
|
+
var i = m.call(o), r, ar = [], e;
|
|
66
|
+
try {
|
|
67
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
68
|
+
}
|
|
69
|
+
catch (error) { e = { error: error }; }
|
|
70
|
+
finally {
|
|
71
|
+
try {
|
|
72
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
73
|
+
}
|
|
74
|
+
finally { if (e) throw e.error; }
|
|
75
|
+
}
|
|
76
|
+
return ar;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
80
|
+
var e = new Error(message);
|
|
81
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Helper function to extract Plasmic data.
|
|
86
|
+
*
|
|
87
|
+
* Given React element for your page and current pathname + search
|
|
88
|
+
* params, returns:
|
|
89
|
+
* - The extracted query data, if `plasmicSsr` search param is set
|
|
90
|
+
* - A copy of the page element wraped within PlasmicQueryDataProvider to provide the extracted query data, otherwise
|
|
91
|
+
*/
|
|
92
|
+
function __EXPERMIENTAL__withExtractPlasmicQueryData(pageRootElt, _a) {
|
|
93
|
+
var _b, _c, _d;
|
|
94
|
+
var pathname = _a.pathname, searchParams = _a.searchParams;
|
|
95
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
96
|
+
var isPlasmicSsr, prepassHost, newSearchParams, prefetchedQueryData;
|
|
97
|
+
return __generator(this, function (_e) {
|
|
98
|
+
switch (_e.label) {
|
|
99
|
+
case 0:
|
|
100
|
+
isPlasmicSsr = !!(searchParams === null || searchParams === void 0 ? void 0 : searchParams["plasmicSsr"]) && (searchParams === null || searchParams === void 0 ? void 0 : searchParams["plasmicSsr"]) !== "false";
|
|
101
|
+
// If `plasmicSsr` search param is set, just wrap the page inside
|
|
102
|
+
// <ExtractPlasmicQueryData>
|
|
103
|
+
if (isPlasmicSsr) {
|
|
104
|
+
return [2 /*return*/, React.createElement(ExtractPlasmicQueryData, null, pageRootElt)];
|
|
105
|
+
}
|
|
106
|
+
prepassHost = (_c = (_b = process.env.PLASMIC_PREPASS_HOST) !== null && _b !== void 0 ? _b : (process.env.VERCEL_URL && "https://".concat(process.env.VERCEL_URL))) !== null && _c !== void 0 ? _c : "http://localhost:".concat((_d = process.env.PORT) !== null && _d !== void 0 ? _d : 3000);
|
|
107
|
+
newSearchParams = new URLSearchParams(Object.entries(searchParams !== null && searchParams !== void 0 ? searchParams : {}).flatMap(function (_a) {
|
|
108
|
+
var _b = __read(_a, 2), key = _b[0], values = _b[1];
|
|
109
|
+
return Array.isArray(values) ? values.map(function (v) { return [key, v]; }) : [[key, values]];
|
|
110
|
+
}));
|
|
111
|
+
// Set `plasmicSsr` search param to indicate you are using this endpoint
|
|
112
|
+
// to extract query data.
|
|
113
|
+
newSearchParams.set("plasmicSsr", "true");
|
|
114
|
+
if (process.env.VERCEL_AUTOMATION_BYPASS_SECRET) {
|
|
115
|
+
// If protection bypass is enabled, use it to ensure fetching from
|
|
116
|
+
// the SSR endpoint will not return the authentication page HTML
|
|
117
|
+
newSearchParams.set("x-vercel-protection-bypass", process.env.VERCEL_AUTOMATION_BYPASS_SECRET);
|
|
118
|
+
}
|
|
119
|
+
return [4 /*yield*/, fetchExtractedQueryData("".concat(prepassHost).concat(pathname, "?").concat(newSearchParams.toString()))];
|
|
120
|
+
case 1:
|
|
121
|
+
prefetchedQueryData = _e.sent();
|
|
122
|
+
// Provide the query data to your page
|
|
123
|
+
return [2 /*return*/, (React.createElement(PlasmicQueryDataProvider, { prefetchedCache: prefetchedQueryData }, pageRootElt))];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export { __EXPERMIENTAL__withExtractPlasmicQueryData };
|
|
130
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/nextjs-app-router/react-server/index.tsx"],"sourcesContent":["import { ExtractPlasmicQueryData } from \"@plasmicapp/nextjs-app-router\";\nimport { fetchExtractedQueryData } from \"@plasmicapp/nextjs-app-router/react-server\";\nimport { PlasmicQueryDataProvider } from \"@plasmicapp/query\";\nimport React from \"react\";\n\nexport { fetchExtractedQueryData as __EXPERMIENTAL__fetchExtractedQueryData };\n\n/**\n * Helper function to extract Plasmic data.\n *\n * Given React element for your page and current pathname + search\n * params, returns:\n * - The extracted query data, if `plasmicSsr` search param is set\n * - A copy of the page element wraped within PlasmicQueryDataProvider to provide the extracted query data, otherwise\n */\nexport async function __EXPERMIENTAL__withExtractPlasmicQueryData(\n pageRootElt: React.ReactElement,\n {\n pathname,\n searchParams,\n }: {\n pathname: string;\n searchParams: Record<string, string | string[]> | undefined;\n }\n) {\n const isPlasmicSsr =\n !!searchParams?.[\"plasmicSsr\"] && searchParams?.[\"plasmicSsr\"] !== \"false\";\n\n // If `plasmicSsr` search param is set, just wrap the page inside\n // <ExtractPlasmicQueryData>\n if (isPlasmicSsr) {\n return <ExtractPlasmicQueryData>{pageRootElt}</ExtractPlasmicQueryData>;\n }\n\n // Otherwise, fetch the same endpoint, but setting `plasmicSsr` to extract the\n // query data.\n const prepassHost =\n process.env.PLASMIC_PREPASS_HOST ??\n (process.env.VERCEL_URL && `https://${process.env.VERCEL_URL}`) ??\n `http://localhost:${process.env.PORT ?? 3000}`;\n\n // Build a copy of the search params\n const newSearchParams = new URLSearchParams(\n Object.entries(searchParams ?? {}).flatMap(([key, values]) =>\n Array.isArray(values) ? values.map((v) => [key, v]) : [[key, values]]\n )\n );\n\n // Set `plasmicSsr` search param to indicate you are using this endpoint\n // to extract query data.\n newSearchParams.set(\"plasmicSsr\", \"true\");\n\n if (process.env.VERCEL_AUTOMATION_BYPASS_SECRET) {\n // If protection bypass is enabled, use it to ensure fetching from\n // the SSR endpoint will not return the authentication page HTML\n newSearchParams.set(\n \"x-vercel-protection-bypass\",\n process.env.VERCEL_AUTOMATION_BYPASS_SECRET\n );\n }\n\n // Fetch the data from the endpoint using the new search params\n const prefetchedQueryData = await fetchExtractedQueryData(\n `${prepassHost}${pathname}?${newSearchParams.toString()}`\n );\n\n // Provide the query data to your page\n return (\n <PlasmicQueryDataProvider prefetchedCache={prefetchedQueryData}>\n {pageRootElt}\n </PlasmicQueryD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"description": "plasmic library for rendering in the presentational style",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -65,6 +65,16 @@
|
|
|
65
65
|
},
|
|
66
66
|
"./additional-types-PlasmicImg": {
|
|
67
67
|
"types": "./dist/render/PlasmicImg/index.d.ts"
|
|
68
|
+
},
|
|
69
|
+
"./lib/nextjs-app-router": {
|
|
70
|
+
"types": "./lib/nextjs-app-router/index.d.ts",
|
|
71
|
+
"import": "./lib/nextjs-app-router/index.js",
|
|
72
|
+
"require": "./lib/nextjs-app-router/index.cjs.js"
|
|
73
|
+
},
|
|
74
|
+
"./lib/nextjs-app-router/react-server": {
|
|
75
|
+
"types": "./lib/nextjs-app-router/react-server/index.d.ts",
|
|
76
|
+
"import": "./lib/nextjs-app-router/react-server/index.js",
|
|
77
|
+
"require": "./lib/nextjs-app-router/react-server/index.cjs.js"
|
|
68
78
|
}
|
|
69
79
|
},
|
|
70
80
|
"files": [
|
|
@@ -91,6 +101,7 @@
|
|
|
91
101
|
"@plasmicapp/data-sources-context": "0.1.21",
|
|
92
102
|
"@plasmicapp/host": "1.0.192",
|
|
93
103
|
"@plasmicapp/loader-splits": "1.0.60",
|
|
104
|
+
"@plasmicapp/nextjs-app-router": "1.0.8",
|
|
94
105
|
"@plasmicapp/prepass": "1.0.16",
|
|
95
106
|
"@plasmicapp/query": "0.1.78",
|
|
96
107
|
"@react-aria/checkbox": "^3.11.2",
|
|
@@ -157,5 +168,5 @@
|
|
|
157
168
|
"react": ">=16.8.0",
|
|
158
169
|
"react-dom": ">=16.8.0"
|
|
159
170
|
},
|
|
160
|
-
"gitHead": "
|
|
171
|
+
"gitHead": "c6296df0e76f57a0d188ac1ef1358399ad56eab0"
|
|
161
172
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ExtractPlasmicQueryData as __EXPERMIENTAL__ExtractPlasmicQueryData } from "@plasmicapp/nextjs-app-router";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { fetchExtractedQueryData } from "@plasmicapp/nextjs-app-router/react-server";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export { fetchExtractedQueryData as __EXPERMIENTAL__fetchExtractedQueryData };
|
|
4
|
+
/**
|
|
5
|
+
* Helper function to extract Plasmic data.
|
|
6
|
+
*
|
|
7
|
+
* Given React element for your page and current pathname + search
|
|
8
|
+
* params, returns:
|
|
9
|
+
* - The extracted query data, if `plasmicSsr` search param is set
|
|
10
|
+
* - A copy of the page element wraped within PlasmicQueryDataProvider to provide the extracted query data, otherwise
|
|
11
|
+
*/
|
|
12
|
+
export declare function __EXPERMIENTAL__withExtractPlasmicQueryData(pageRootElt: React.ReactElement, { pathname, searchParams, }: {
|
|
13
|
+
pathname: string;
|
|
14
|
+
searchParams: Record<string, string | string[]> | undefined;
|
|
15
|
+
}): Promise<React.JSX.Element>;
|