veryfront 0.1.32 → 0.1.34
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/esm/deno.js +1 -1
- package/esm/src/server/handlers/preview/markdown-html-generator.d.ts.map +1 -1
- package/esm/src/server/handlers/preview/markdown-html-generator.js +6 -3
- package/esm/src/server/handlers/preview/markdown-preview.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/preview/markdown-preview.handler.js +2 -1
- package/package.json +1 -1
- package/src/deno.js +1 -1
- package/src/src/server/handlers/preview/markdown-html-generator.ts +6 -2
- package/src/src/server/handlers/preview/markdown-preview.handler.ts +2 -1
package/esm/deno.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-html-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/server/handlers/preview/markdown-html-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAMrD,oDAAoD;AACpD,MAAM,WAAW,mBAAmB;IAClC,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;IACzB,gDAAgD;IAChD,GAAG,EAAE,GAAG,CAAC;IACT,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;
|
|
1
|
+
{"version":3,"file":"markdown-html-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/server/handlers/preview/markdown-html-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAMrD,oDAAoD;AACpD,MAAM,WAAW,mBAAmB;IAClC,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;IACzB,gDAAgD;IAChD,GAAG,EAAE,GAAG,CAAC;IACT,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,oDAAoD;IACpD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAoED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CA2FzE"}
|
|
@@ -25,7 +25,7 @@ function detectTheme(req, url) {
|
|
|
25
25
|
* Injected when embedded in Studio (`studio_embed=true`) or for standalone
|
|
26
26
|
* markdown/MDX pages so the edit button and editor features are available.
|
|
27
27
|
*/
|
|
28
|
-
function buildStudioScript(url, projectId, filePath, branchId, requestHost) {
|
|
28
|
+
function buildStudioScript(req, url, projectId, filePath, branchId, requestHost) {
|
|
29
29
|
const studioEmbed = url.searchParams.get("studio_embed") === "true";
|
|
30
30
|
const isMarkdown = /\.mdx?$/i.test(filePath);
|
|
31
31
|
if (!studioEmbed && !isMarkdown)
|
|
@@ -37,7 +37,10 @@ function buildStudioScript(url, projectId, filePath, branchId, requestHost) {
|
|
|
37
37
|
const canonicalProjectId = queryProjectId || projectId;
|
|
38
38
|
const canonicalPageId = queryFileId || filePath;
|
|
39
39
|
// Compute Yjs connection config for the bridge to self-connect
|
|
40
|
-
|
|
40
|
+
// Use x-forwarded-proto to detect the public-facing protocol (internal K8s URL is always http)
|
|
41
|
+
const forwardedProto = req.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();
|
|
42
|
+
const isSecure = forwardedProto === "https" || url.protocol === "https:";
|
|
43
|
+
const wsProtocol = isSecure ? "wss" : "ws";
|
|
41
44
|
const host = requestHost || url.host;
|
|
42
45
|
const wsUrl = `${wsProtocol}://${host}/api/ws/${canonicalProjectId}/yjs`;
|
|
43
46
|
const yjsGuid = branchId ? `${canonicalProjectId}:${branchId}` : canonicalProjectId;
|
|
@@ -59,7 +62,7 @@ function buildStudioScript(url, projectId, filePath, branchId, requestHost) {
|
|
|
59
62
|
export function generateMarkdownHtml(options) {
|
|
60
63
|
const { rawHtml, title, description, request, url, projectId, filePath, branchId, requestHost } = options;
|
|
61
64
|
const theme = detectTheme(request, url);
|
|
62
|
-
const studioScript = buildStudioScript(url, projectId, filePath, branchId, requestHost);
|
|
65
|
+
const studioScript = buildStudioScript(request, url, projectId, filePath, branchId, requestHost);
|
|
63
66
|
const themeAttrs = theme ? ` data-theme="${theme}" style="color-scheme: ${theme};"` : "";
|
|
64
67
|
return `<!DOCTYPE html>
|
|
65
68
|
<html lang="en"${themeAttrs}>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-preview.handler.d.ts","sourceRoot":"","sources":["../../../../../src/src/server/handlers/preview/markdown-preview.handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAmB,aAAa,EAAE,MAAM,aAAa,CAAC;AAgBnG,qBAAa,sBAAuB,SAAQ,WAAW;IACrD,QAAQ,EAAE,eAAe,CAKvB;IAEI,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;YAiEjE,cAAc;
|
|
1
|
+
{"version":3,"file":"markdown-preview.handler.d.ts","sourceRoot":"","sources":["../../../../../src/src/server/handlers/preview/markdown-preview.handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAGrD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAmB,aAAa,EAAE,MAAM,aAAa,CAAC;AAgBnG,qBAAa,sBAAuB,SAAQ,WAAW;IACrD,QAAQ,EAAE,eAAe,CAKvB;IAEI,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;YAiEjE,cAAc;CAmF7B"}
|
|
@@ -109,7 +109,8 @@ export class MarkdownPreviewHandler extends BaseHandler {
|
|
|
109
109
|
projectId: ctx.projectSlug || ctx.projectId || "markdown-preview",
|
|
110
110
|
filePath,
|
|
111
111
|
branchId: ctx.parsedDomain?.branch ?? null,
|
|
112
|
-
requestHost:
|
|
112
|
+
requestHost: req.headers.get("x-forwarded-host")?.split(",")[0]?.trim() ||
|
|
113
|
+
req.headers.get("host") || url.host,
|
|
113
114
|
});
|
|
114
115
|
const responseBuilder = this.createResponseBuilder(ctx)
|
|
115
116
|
.withCache("no-cache")
|
package/package.json
CHANGED
package/src/deno.js
CHANGED
|
@@ -63,6 +63,7 @@ function detectTheme(req: dntShim.Request, url: URL): "light" | "dark" | null {
|
|
|
63
63
|
* markdown/MDX pages so the edit button and editor features are available.
|
|
64
64
|
*/
|
|
65
65
|
function buildStudioScript(
|
|
66
|
+
req: dntShim.Request,
|
|
66
67
|
url: URL,
|
|
67
68
|
projectId: string,
|
|
68
69
|
filePath: string,
|
|
@@ -81,7 +82,10 @@ function buildStudioScript(
|
|
|
81
82
|
const canonicalPageId = queryFileId || filePath;
|
|
82
83
|
|
|
83
84
|
// Compute Yjs connection config for the bridge to self-connect
|
|
84
|
-
|
|
85
|
+
// Use x-forwarded-proto to detect the public-facing protocol (internal K8s URL is always http)
|
|
86
|
+
const forwardedProto = req.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();
|
|
87
|
+
const isSecure = forwardedProto === "https" || url.protocol === "https:";
|
|
88
|
+
const wsProtocol = isSecure ? "wss" : "ws";
|
|
85
89
|
const host = requestHost || url.host;
|
|
86
90
|
const wsUrl = `${wsProtocol}://${host}/api/ws/${canonicalProjectId}/yjs`;
|
|
87
91
|
const yjsGuid = branchId ? `${canonicalProjectId}:${branchId}` : canonicalProjectId;
|
|
@@ -109,7 +113,7 @@ export function generateMarkdownHtml(options: MarkdownHtmlOptions): string {
|
|
|
109
113
|
options;
|
|
110
114
|
|
|
111
115
|
const theme = detectTheme(request, url);
|
|
112
|
-
const studioScript = buildStudioScript(url, projectId, filePath, branchId, requestHost);
|
|
116
|
+
const studioScript = buildStudioScript(request, url, projectId, filePath, branchId, requestHost);
|
|
113
117
|
const themeAttrs = theme ? ` data-theme="${theme}" style="color-scheme: ${theme};"` : "";
|
|
114
118
|
|
|
115
119
|
return `<!DOCTYPE html>
|
|
@@ -160,7 +160,8 @@ export class MarkdownPreviewHandler extends BaseHandler {
|
|
|
160
160
|
projectId: ctx.projectSlug || ctx.projectId || "markdown-preview",
|
|
161
161
|
filePath,
|
|
162
162
|
branchId: ctx.parsedDomain?.branch ?? null,
|
|
163
|
-
requestHost:
|
|
163
|
+
requestHost: req.headers.get("x-forwarded-host")?.split(",")[0]?.trim() ||
|
|
164
|
+
req.headers.get("host") || url.host,
|
|
164
165
|
});
|
|
165
166
|
|
|
166
167
|
const responseBuilder = this.createResponseBuilder(ctx)
|