@mints-cloud/cxf-codegen 1.0.3 → 1.0.5
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/README.md +52 -1
- package/dist/components/ApiCall.d.ts.map +1 -1
- package/dist/components/ApiCall.js +14 -1
- package/dist/components/JsonLdSchemas.d.ts +104 -0
- package/dist/components/JsonLdSchemas.d.ts.map +1 -0
- package/dist/components/JsonLdSchemas.js +380 -0
- package/dist/components/MetadataOverrides.d.ts +84 -0
- package/dist/components/MetadataOverrides.d.ts.map +1 -0
- package/dist/components/MetadataOverrides.js +270 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -1
- package/dist/lib/api-route-helpers.d.ts +2 -0
- package/dist/lib/api-route-helpers.d.ts.map +1 -1
- package/dist/lib/api-route-helpers.js +9 -3
- package/dist/lib/assets-query-params.d.ts +11 -0
- package/dist/lib/assets-query-params.d.ts.map +1 -0
- package/dist/lib/assets-query-params.js +130 -0
- package/dist/lib/cxf-auth.d.ts +3 -0
- package/dist/lib/cxf-auth.d.ts.map +1 -1
- package/dist/lib/cxf-auth.js +11 -1
- package/dist/lib/seo-utils.d.ts +22 -0
- package/dist/lib/seo-utils.d.ts.map +1 -0
- package/dist/lib/seo-utils.js +228 -0
- package/dist/pages/api/assets.d.ts.map +1 -1
- package/dist/pages/api/assets.js +27 -1
- package/dist/pages/app.d.ts +3 -1
- package/dist/pages/app.d.ts.map +1 -1
- package/dist/pages/app.js +3 -1
- package/dist/pages/plasmic-host.d.ts +16 -1
- package/dist/pages/plasmic-host.d.ts.map +1 -1
- package/dist/pages/plasmic-host.js +46 -0
- package/dist/register.d.ts.map +1 -1
- package/dist/register.js +169 -3
- package/package.json +13 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cxf-auth.d.ts","sourceRoot":"","sources":["../../src/lib/cxf-auth.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAA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
61
|
async function makeAuthenticatedRequest(url, options = {}) {
|
|
62
|
-
const { method = "GET", body, rawBody, contentType, tokens: providedTokens, apiKey, userToken, cookieHeader, retryOnAuthError = true, } = options;
|
|
62
|
+
const { method = "GET", body, rawBody, contentType, extraHeaders, tokens: providedTokens, apiKey, userToken, cookieHeader, retryOnAuthError = true, } = options;
|
|
63
63
|
const tokens = providedTokens || getTokensFromCookies(cookieHeader);
|
|
64
64
|
const buildRequestOptions = (reqTokens, cookieStr) => {
|
|
65
65
|
const headers = buildAuthHeaders(reqTokens, apiKey, userToken);
|
|
66
|
+
if (extraHeaders) {
|
|
67
|
+
for (const [key, value] of Object.entries(extraHeaders)) {
|
|
68
|
+
if (value)
|
|
69
|
+
headers[key] = value;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
66
72
|
if (cookieStr) {
|
|
67
73
|
headers.Cookie = cookieStr;
|
|
68
74
|
}
|
|
@@ -120,11 +126,15 @@ function extractTokensFromSetCookie(setCookieHeaders) {
|
|
|
120
126
|
continue;
|
|
121
127
|
const name = match[1].trim();
|
|
122
128
|
const value = match[2].trim();
|
|
129
|
+
const maxAgeMatch = header.match(/Max-Age=(\d+)/i);
|
|
130
|
+
const maxAge = maxAgeMatch ? parseInt(maxAgeMatch[1], 10) : null;
|
|
123
131
|
if (name === exports.CXF_COOKIE_NAMES.ACCESS_TOKEN) {
|
|
124
132
|
tokens.accessToken = value;
|
|
133
|
+
tokens.accessTokenMaxAge = maxAge;
|
|
125
134
|
}
|
|
126
135
|
else if (name === exports.CXF_COOKIE_NAMES.REFRESH_TOKEN) {
|
|
127
136
|
tokens.refreshToken = value;
|
|
137
|
+
tokens.refreshTokenMaxAge = maxAge;
|
|
128
138
|
}
|
|
129
139
|
}
|
|
130
140
|
return tokens;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type MaybeString = string | null | undefined;
|
|
2
|
+
export type MaybeStringList = string[] | string | null | undefined;
|
|
3
|
+
type ParseJsonFn = (value: string) => unknown;
|
|
4
|
+
interface ParseOptions {
|
|
5
|
+
parseJson?: ParseJsonFn;
|
|
6
|
+
}
|
|
7
|
+
export declare function cleanString(value: unknown): string | undefined;
|
|
8
|
+
export declare function pickFirstString(...values: unknown[]): string | undefined;
|
|
9
|
+
export declare function parseObject<T extends object>(value: T | string | null | undefined, options?: ParseOptions): T | undefined;
|
|
10
|
+
export declare function parseObjectArray<T extends object>(value: T[] | string | null | undefined, options?: ParseOptions): T[];
|
|
11
|
+
export declare function parseStringList(value: unknown): string[];
|
|
12
|
+
export declare function toOriginUrl(url: MaybeString): string | undefined;
|
|
13
|
+
export declare function resolveUrlBase(...candidates: MaybeString[]): string | undefined;
|
|
14
|
+
export declare function getCurrentOrigin(): string | undefined;
|
|
15
|
+
export declare function buildOrganizationId(baseUrl: MaybeString): string | undefined;
|
|
16
|
+
export declare function toAbsoluteUrl(pathOrUrl: MaybeString, baseUrl: MaybeString): string | undefined;
|
|
17
|
+
export declare function safeJsonForInlineScript(value: unknown): string;
|
|
18
|
+
export declare function toDomId(value: string): string;
|
|
19
|
+
export declare function removeDuplicateJsonLdScripts(scriptId: string, scriptKey: string, json: string): void;
|
|
20
|
+
export declare function tryParseLooseJson(value: string): unknown;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=seo-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seo-utils.d.ts","sourceRoot":"","sources":["../../src/lib/seo-utils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AACpD,MAAM,MAAM,eAAe,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAEnE,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;AAE9C,UAAU,YAAY;IACpB,SAAS,CAAC,EAAE,WAAW,CAAC;CACzB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAA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0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cleanString = cleanString;
|
|
4
|
+
exports.pickFirstString = pickFirstString;
|
|
5
|
+
exports.parseObject = parseObject;
|
|
6
|
+
exports.parseObjectArray = parseObjectArray;
|
|
7
|
+
exports.parseStringList = parseStringList;
|
|
8
|
+
exports.toOriginUrl = toOriginUrl;
|
|
9
|
+
exports.resolveUrlBase = resolveUrlBase;
|
|
10
|
+
exports.getCurrentOrigin = getCurrentOrigin;
|
|
11
|
+
exports.buildOrganizationId = buildOrganizationId;
|
|
12
|
+
exports.toAbsoluteUrl = toAbsoluteUrl;
|
|
13
|
+
exports.safeJsonForInlineScript = safeJsonForInlineScript;
|
|
14
|
+
exports.toDomId = toDomId;
|
|
15
|
+
exports.removeDuplicateJsonLdScripts = removeDuplicateJsonLdScripts;
|
|
16
|
+
exports.tryParseLooseJson = tryParseLooseJson;
|
|
17
|
+
function cleanString(value) {
|
|
18
|
+
if (typeof value !== "string")
|
|
19
|
+
return undefined;
|
|
20
|
+
const trimmed = value.trim();
|
|
21
|
+
return trimmed.length > 0 ? trimmed : undefined;
|
|
22
|
+
}
|
|
23
|
+
function pickFirstString(...values) {
|
|
24
|
+
for (const value of values) {
|
|
25
|
+
const cleaned = cleanString(value);
|
|
26
|
+
if (cleaned)
|
|
27
|
+
return cleaned;
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
function parseObject(value, options) {
|
|
32
|
+
if (value == null)
|
|
33
|
+
return undefined;
|
|
34
|
+
if (typeof value === "object" && !Array.isArray(value)) {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
if (typeof value !== "string")
|
|
38
|
+
return undefined;
|
|
39
|
+
const maybeJson = value.trim();
|
|
40
|
+
if (!maybeJson)
|
|
41
|
+
return undefined;
|
|
42
|
+
const parseJson = options?.parseJson ?? JSON.parse;
|
|
43
|
+
try {
|
|
44
|
+
const parsed = parseJson(maybeJson);
|
|
45
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
46
|
+
return parsed;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
function parseObjectArray(value, options) {
|
|
55
|
+
if (Array.isArray(value))
|
|
56
|
+
return value;
|
|
57
|
+
if (typeof value !== "string")
|
|
58
|
+
return [];
|
|
59
|
+
const maybeJson = value.trim();
|
|
60
|
+
if (!maybeJson)
|
|
61
|
+
return [];
|
|
62
|
+
const parseJson = options?.parseJson ?? JSON.parse;
|
|
63
|
+
try {
|
|
64
|
+
const parsed = parseJson(maybeJson);
|
|
65
|
+
if (Array.isArray(parsed)) {
|
|
66
|
+
return parsed.filter((item) => item && typeof item === "object");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
function parseStringList(value) {
|
|
75
|
+
if (Array.isArray(value)) {
|
|
76
|
+
return value
|
|
77
|
+
.map((item) => cleanString(item))
|
|
78
|
+
.filter((item) => Boolean(item));
|
|
79
|
+
}
|
|
80
|
+
const raw = cleanString(value);
|
|
81
|
+
if (!raw)
|
|
82
|
+
return [];
|
|
83
|
+
try {
|
|
84
|
+
const parsed = JSON.parse(raw);
|
|
85
|
+
if (Array.isArray(parsed)) {
|
|
86
|
+
return parsed
|
|
87
|
+
.map((item) => cleanString(item))
|
|
88
|
+
.filter((item) => Boolean(item));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
// Fall back to comma-separated values.
|
|
93
|
+
}
|
|
94
|
+
return raw
|
|
95
|
+
.split(",")
|
|
96
|
+
.map((item) => item.trim())
|
|
97
|
+
.filter(Boolean);
|
|
98
|
+
}
|
|
99
|
+
function toOriginUrl(url) {
|
|
100
|
+
const cleaned = cleanString(url);
|
|
101
|
+
if (!cleaned)
|
|
102
|
+
return undefined;
|
|
103
|
+
const withProtocol = cleaned.startsWith("//") ? `https:${cleaned}` : cleaned;
|
|
104
|
+
try {
|
|
105
|
+
return new URL(withProtocol).origin;
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function resolveUrlBase(...candidates) {
|
|
112
|
+
for (const candidate of candidates) {
|
|
113
|
+
const origin = toOriginUrl(candidate);
|
|
114
|
+
if (origin)
|
|
115
|
+
return origin;
|
|
116
|
+
}
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
function getCurrentOrigin() {
|
|
120
|
+
if (typeof window === "undefined")
|
|
121
|
+
return undefined;
|
|
122
|
+
return toOriginUrl(window.location.origin);
|
|
123
|
+
}
|
|
124
|
+
function buildOrganizationId(baseUrl) {
|
|
125
|
+
const origin = toOriginUrl(baseUrl);
|
|
126
|
+
if (!origin)
|
|
127
|
+
return undefined;
|
|
128
|
+
return `${origin}/#organization`;
|
|
129
|
+
}
|
|
130
|
+
function toAbsoluteUrl(pathOrUrl, baseUrl) {
|
|
131
|
+
const value = cleanString(pathOrUrl);
|
|
132
|
+
if (!value)
|
|
133
|
+
return undefined;
|
|
134
|
+
if (/^https?:\/\//i.test(value))
|
|
135
|
+
return value;
|
|
136
|
+
if (value.startsWith("//"))
|
|
137
|
+
return `https:${value}`;
|
|
138
|
+
const normalizedBase = resolveUrlBase(baseUrl);
|
|
139
|
+
const relativePath = value.startsWith("/") ? value : `/${value}`;
|
|
140
|
+
if (!normalizedBase)
|
|
141
|
+
return relativePath;
|
|
142
|
+
try {
|
|
143
|
+
return new URL(relativePath, `${normalizedBase}/`).href;
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return relativePath;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function safeJsonForInlineScript(value) {
|
|
150
|
+
return JSON.stringify(value).replace(/</g, "\\u003c");
|
|
151
|
+
}
|
|
152
|
+
function toDomId(value) {
|
|
153
|
+
return value.replace(/[^a-zA-Z0-9\-_:.]/g, "-");
|
|
154
|
+
}
|
|
155
|
+
function removeDuplicateJsonLdScripts(scriptId, scriptKey, json) {
|
|
156
|
+
if (typeof document === "undefined")
|
|
157
|
+
return;
|
|
158
|
+
const canonical = document.getElementById(scriptId);
|
|
159
|
+
const allJsonLdScripts = Array.from(document.querySelectorAll("script[type='application/ld+json']"));
|
|
160
|
+
allJsonLdScripts.forEach((script) => {
|
|
161
|
+
if (script === canonical)
|
|
162
|
+
return;
|
|
163
|
+
const sameId = script.id === scriptId;
|
|
164
|
+
const sameKey = script.getAttribute("data-jsonld-key") === scriptKey;
|
|
165
|
+
const samePayloadOutsideHead = script.parentElement !== document.head && (script.textContent ?? "") === json;
|
|
166
|
+
if (sameId || sameKey || samePayloadOutsideHead) {
|
|
167
|
+
script.remove();
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function isEscaped(input, index) {
|
|
172
|
+
let slashCount = 0;
|
|
173
|
+
for (let i = index - 1; i >= 0 && input[i] === "\\"; i -= 1) {
|
|
174
|
+
slashCount += 1;
|
|
175
|
+
}
|
|
176
|
+
return slashCount % 2 === 1;
|
|
177
|
+
}
|
|
178
|
+
function repairJsonInnerQuotes(input) {
|
|
179
|
+
let repaired = "";
|
|
180
|
+
let inString = false;
|
|
181
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
182
|
+
const ch = input[i];
|
|
183
|
+
if (ch !== "\"") {
|
|
184
|
+
repaired += ch;
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (isEscaped(input, i)) {
|
|
188
|
+
repaired += ch;
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (!inString) {
|
|
192
|
+
inString = true;
|
|
193
|
+
repaired += ch;
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
let nextNonSpace = i + 1;
|
|
197
|
+
while (nextNonSpace < input.length && /\s/.test(input[nextNonSpace])) {
|
|
198
|
+
nextNonSpace += 1;
|
|
199
|
+
}
|
|
200
|
+
const next = input[nextNonSpace];
|
|
201
|
+
const closesString = nextNonSpace >= input.length ||
|
|
202
|
+
next === "," ||
|
|
203
|
+
next === "}" ||
|
|
204
|
+
next === "]" ||
|
|
205
|
+
next === ":";
|
|
206
|
+
if (closesString) {
|
|
207
|
+
inString = false;
|
|
208
|
+
repaired += ch;
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
// Heuristic: treat inner raw quotes (commonly from HTML attributes) as escaped.
|
|
212
|
+
repaired += "\\\"";
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return repaired;
|
|
216
|
+
}
|
|
217
|
+
function tryParseLooseJson(value) {
|
|
218
|
+
try {
|
|
219
|
+
return JSON.parse(value);
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
const repaired = repairJsonInnerQuotes(value);
|
|
223
|
+
if (repaired !== value) {
|
|
224
|
+
return JSON.parse(repaired);
|
|
225
|
+
}
|
|
226
|
+
throw new Error("Invalid JSON");
|
|
227
|
+
}
|
|
228
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../../src/pages/api/assets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../../src/pages/api/assets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAoB5D,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,eAAe,iBAwC/E;AAED,eAAe,gBAAgB,CAAC"}
|
package/dist/pages/api/assets.js
CHANGED
|
@@ -3,6 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.assetsApiHandler = assetsApiHandler;
|
|
4
4
|
const cxf_auth_1 = require("../../lib/cxf-auth");
|
|
5
5
|
const api_route_helpers_1 = require("../../lib/api-route-helpers");
|
|
6
|
+
const assets_query_params_1 = require("../../lib/assets-query-params");
|
|
7
|
+
const CONDITIONAL_REQUEST_HEADERS = ["if-none-match", "if-modified-since"];
|
|
8
|
+
const CACHE_RESPONSE_HEADERS = ["cache-control", "etag", "last-modified", "expires", "vary"];
|
|
9
|
+
function getHeaderValue(header) {
|
|
10
|
+
if (Array.isArray(header))
|
|
11
|
+
return header.join(", ");
|
|
12
|
+
return header;
|
|
13
|
+
}
|
|
14
|
+
function forwardResponseHeaders(res, response) {
|
|
15
|
+
for (const headerName of CACHE_RESPONSE_HEADERS) {
|
|
16
|
+
const value = response.headers.get(headerName);
|
|
17
|
+
if (value)
|
|
18
|
+
res.setHeader(headerName, value);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
6
21
|
async function assetsApiHandler(req, res) {
|
|
7
22
|
if (req.method !== "GET") {
|
|
8
23
|
res.setHeader("Allow", "GET");
|
|
@@ -11,15 +26,26 @@ async function assetsApiHandler(req, res) {
|
|
|
11
26
|
try {
|
|
12
27
|
const baseUrl = (0, cxf_auth_1.getCxfBaseUrl)();
|
|
13
28
|
const normalizedPath = (0, api_route_helpers_1.normalizePath)(req.query.path);
|
|
14
|
-
const
|
|
29
|
+
const paramsFromCookie = (0, assets_query_params_1.extractAssetQueryParamsFromCookie)(req.headers.cookie || null);
|
|
30
|
+
const mergedQuery = {
|
|
31
|
+
...paramsFromCookie,
|
|
32
|
+
...req.query,
|
|
33
|
+
};
|
|
34
|
+
const targetUrl = `${baseUrl}/assets/${normalizedPath}${(0, api_route_helpers_1.buildQueryString)(mergedQuery)}`;
|
|
35
|
+
const extraHeaders = CONDITIONAL_REQUEST_HEADERS.reduce((acc, headerName) => {
|
|
36
|
+
acc[headerName] = getHeaderValue(req.headers[headerName]);
|
|
37
|
+
return acc;
|
|
38
|
+
}, {});
|
|
15
39
|
const { response, newTokens } = await (0, cxf_auth_1.makeAuthenticatedRequest)(targetUrl, {
|
|
16
40
|
method: "GET",
|
|
17
41
|
cookieHeader: req.headers.cookie || null,
|
|
18
42
|
retryOnAuthError: false,
|
|
43
|
+
extraHeaders,
|
|
19
44
|
});
|
|
20
45
|
const setCookieHeaders = (0, cxf_auth_1.extractSetCookieHeaders)(response);
|
|
21
46
|
const tokens = (0, cxf_auth_1.extractTokensFromSetCookie)(setCookieHeaders);
|
|
22
47
|
const finalTokens = tokens.accessToken || tokens.refreshToken ? tokens : newTokens;
|
|
48
|
+
forwardResponseHeaders(res, response);
|
|
23
49
|
(0, api_route_helpers_1.setAuthCookies)(res, finalTokens);
|
|
24
50
|
return (0, api_route_helpers_1.sendResponse)(res, response);
|
|
25
51
|
}
|
package/dist/pages/app.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { AppProps } from "next/app";
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
import { type AssetQueryParams } from "../lib/assets-query-params";
|
|
3
4
|
type CxfAppProps = AppProps & {
|
|
4
5
|
tokenClass?: string;
|
|
5
6
|
appRootId?: string;
|
|
7
|
+
assetsQueryParams?: AssetQueryParams;
|
|
6
8
|
};
|
|
7
|
-
export declare function CxfApp({ Component, pageProps, tokenClass, appRootId }: CxfAppProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<React.AwaitedReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
9
|
+
export declare function CxfApp({ Component, pageProps, tokenClass, appRootId, assetsQueryParams, }: CxfAppProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<React.AwaitedReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
8
10
|
export default CxfApp;
|
|
9
11
|
//# sourceMappingURL=app.d.ts.map
|
package/dist/pages/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/pages/app.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/pages/app.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,gBAAgB,EAA2B,MAAM,4BAA4B,CAAC;AAE5F,KAAK,WAAW,GAAG,QAAQ,GAAG;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,gBAAgB,CAAC;CACtC,CAAC;AAYF,wBAAgB,MAAM,CAAC,EACrB,SAAS,EACT,SAAS,EACT,UAAU,EACV,SAAyB,EACzB,iBAAiB,GAClB,EAAE,WAAW,iKAoLb;AAED,eAAe,MAAM,CAAC"}
|
package/dist/pages/app.js
CHANGED
|
@@ -43,15 +43,17 @@ const query_1 = require("@plasmicapp/react-web/lib/query");
|
|
|
43
43
|
const head_1 = __importDefault(require("next/head"));
|
|
44
44
|
const link_1 = __importDefault(require("next/link"));
|
|
45
45
|
const React = __importStar(require("react"));
|
|
46
|
+
const assets_query_params_1 = require("../lib/assets-query-params");
|
|
46
47
|
function isNonEmptyObject(value) {
|
|
47
48
|
return !!value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length > 0;
|
|
48
49
|
}
|
|
49
|
-
function CxfApp({ Component, pageProps, tokenClass, appRootId = "plasmic-app" }) {
|
|
50
|
+
function CxfApp({ Component, pageProps, tokenClass, appRootId = "plasmic-app", assetsQueryParams, }) {
|
|
50
51
|
const storeRef = React.useRef({
|
|
51
52
|
endpointData: {},
|
|
52
53
|
queryCache: {},
|
|
53
54
|
meta: {},
|
|
54
55
|
});
|
|
56
|
+
(0, assets_query_params_1.useSyncAssetQueryParams)(assetsQueryParams);
|
|
55
57
|
// Merge page props from hard loads / direct SSR navigation.
|
|
56
58
|
const incoming = pageProps;
|
|
57
59
|
if (isNonEmptyObject(incoming.endpointData)) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { GetServerSideProps } from 'next';
|
|
1
2
|
export interface PlasmicHostProps {
|
|
2
3
|
/**
|
|
3
4
|
* The Plasmic token class to apply to document elements.
|
|
@@ -12,6 +13,20 @@ export interface PlasmicHostProps {
|
|
|
12
13
|
*/
|
|
13
14
|
appRootId?: string;
|
|
14
15
|
}
|
|
15
|
-
export declare
|
|
16
|
+
export declare const PLASMIC_HOST_ENABLED_ENV_VAR = "NEXT_PUBLIC_ENABLE_PLASMIC_HOST";
|
|
17
|
+
/**
|
|
18
|
+
* Determines if the Plasmic host page should be exposed.
|
|
19
|
+
*
|
|
20
|
+
* - Defaults to enabled in non-production
|
|
21
|
+
* - Defaults to disabled in production
|
|
22
|
+
* - Can be explicitly overridden with NEXT_PUBLIC_ENABLE_PLASMIC_HOST
|
|
23
|
+
*/
|
|
24
|
+
export declare function isPlasmicHostEnabled(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Optional helper for Next.js pages router:
|
|
27
|
+
* `export { getPlasmicHostServerSideProps as getServerSideProps } from '@mints-cloud/cxf-codegen/pages/plasmic-host';`
|
|
28
|
+
*/
|
|
29
|
+
export declare const getPlasmicHostServerSideProps: GetServerSideProps;
|
|
30
|
+
export declare function PlasmicHost({ tokenClass, appRootId }: PlasmicHostProps): import("react/jsx-runtime").JSX.Element | null;
|
|
16
31
|
export default PlasmicHost;
|
|
17
32
|
//# sourceMappingURL=plasmic-host.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plasmic-host.d.ts","sourceRoot":"","sources":["../../src/pages/plasmic-host.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plasmic-host.d.ts","sourceRoot":"","sources":["../../src/pages/plasmic-host.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAS/C,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,4BAA4B,oCAAoC,CAAC;AAqB9E;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAI9C;AAED;;;GAGG;AACH,eAAO,MAAM,6BAA6B,EAAE,kBAG3C,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAAE,UAAU,EAAE,SAAyB,EAAE,EAAE,gBAAgB,kDA6BtF;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -33,11 +33,57 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getPlasmicHostServerSideProps = exports.PLASMIC_HOST_ENABLED_ENV_VAR = void 0;
|
|
37
|
+
exports.isPlasmicHostEnabled = isPlasmicHostEnabled;
|
|
36
38
|
exports.PlasmicHost = PlasmicHost;
|
|
37
39
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
40
|
const React = __importStar(require("react"));
|
|
39
41
|
const host_1 = require("@plasmicapp/host");
|
|
42
|
+
exports.PLASMIC_HOST_ENABLED_ENV_VAR = 'NEXT_PUBLIC_ENABLE_PLASMIC_HOST';
|
|
43
|
+
function parseOptionalBoolean(value) {
|
|
44
|
+
if (!value)
|
|
45
|
+
return undefined;
|
|
46
|
+
switch (value.trim().toLowerCase()) {
|
|
47
|
+
case '1':
|
|
48
|
+
case 'true':
|
|
49
|
+
case 'yes':
|
|
50
|
+
case 'on':
|
|
51
|
+
return true;
|
|
52
|
+
case '0':
|
|
53
|
+
case 'false':
|
|
54
|
+
case 'no':
|
|
55
|
+
case 'off':
|
|
56
|
+
return false;
|
|
57
|
+
default:
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Determines if the Plasmic host page should be exposed.
|
|
63
|
+
*
|
|
64
|
+
* - Defaults to enabled in non-production
|
|
65
|
+
* - Defaults to disabled in production
|
|
66
|
+
* - Can be explicitly overridden with NEXT_PUBLIC_ENABLE_PLASMIC_HOST
|
|
67
|
+
*/
|
|
68
|
+
function isPlasmicHostEnabled() {
|
|
69
|
+
const envValue = parseOptionalBoolean(process.env[exports.PLASMIC_HOST_ENABLED_ENV_VAR]);
|
|
70
|
+
if (envValue != null)
|
|
71
|
+
return envValue;
|
|
72
|
+
return process.env.NODE_ENV !== 'production';
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Optional helper for Next.js pages router:
|
|
76
|
+
* `export { getPlasmicHostServerSideProps as getServerSideProps } from '@mints-cloud/cxf-codegen/pages/plasmic-host';`
|
|
77
|
+
*/
|
|
78
|
+
const getPlasmicHostServerSideProps = async () => {
|
|
79
|
+
if (!isPlasmicHostEnabled())
|
|
80
|
+
return { notFound: true };
|
|
81
|
+
return { props: {} };
|
|
82
|
+
};
|
|
83
|
+
exports.getPlasmicHostServerSideProps = getPlasmicHostServerSideProps;
|
|
40
84
|
function PlasmicHost({ tokenClass, appRootId = 'plasmic-app' }) {
|
|
85
|
+
if (!isPlasmicHostEnabled())
|
|
86
|
+
return null;
|
|
41
87
|
React.useEffect(() => {
|
|
42
88
|
if (!tokenClass)
|
|
43
89
|
return;
|
package/dist/register.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../src/register.ts"],"names":[],"mappings":"AAKA,wBAAgB,sBAAsB,SA6RrC"}
|