mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
cli: update deps
This commit is contained in:
3
apps/web/.open-next/cloudflare/cache-assets-manifest.sql
Normal file
3
apps/web/.open-next/cloudflare/cache-assets-manifest.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
CREATE TABLE IF NOT EXISTS tags (tag TEXT NOT NULL, path TEXT NOT NULL, UNIQUE(tag, path) ON CONFLICT REPLACE);
|
||||
CREATE TABLE IF NOT EXISTS revalidations (tag TEXT NOT NULL, revalidatedAt INTEGER NOT NULL, UNIQUE(tag) ON CONFLICT REPLACE);
|
||||
INSERT INTO tags (tag, path) VALUES ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/layout", "pYUMJqQmqlh8C9DCzFGyK/_not-found"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/_not-found/layout", "pYUMJqQmqlh8C9DCzFGyK/_not-found"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/_not-found/page", "pYUMJqQmqlh8C9DCzFGyK/_not-found"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/_not-found", "pYUMJqQmqlh8C9DCzFGyK/_not-found"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/layout", "pYUMJqQmqlh8C9DCzFGyK/analytics"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/(home)/layout", "pYUMJqQmqlh8C9DCzFGyK/analytics"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/(home)/analytics/layout", "pYUMJqQmqlh8C9DCzFGyK/analytics"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/(home)/analytics/page", "pYUMJqQmqlh8C9DCzFGyK/analytics"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/analytics", "pYUMJqQmqlh8C9DCzFGyK/analytics"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/layout", "pYUMJqQmqlh8C9DCzFGyK/api/search"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/api/layout", "pYUMJqQmqlh8C9DCzFGyK/api/search"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/api/search/layout", "pYUMJqQmqlh8C9DCzFGyK/api/search"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/api/search/route", "pYUMJqQmqlh8C9DCzFGyK/api/search"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/api/search", "pYUMJqQmqlh8C9DCzFGyK/api/search"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/layout", "pYUMJqQmqlh8C9DCzFGyK/docs"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/docs/layout", "pYUMJqQmqlh8C9DCzFGyK/docs"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/docs/[[...slug]]/layout", "pYUMJqQmqlh8C9DCzFGyK/docs"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/docs/[[...slug]]/page", "pYUMJqQmqlh8C9DCzFGyK/docs"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/docs", "pYUMJqQmqlh8C9DCzFGyK/docs"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/layout", "pYUMJqQmqlh8C9DCzFGyK/index"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/(home)/layout", "pYUMJqQmqlh8C9DCzFGyK/index"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/(home)/page", "pYUMJqQmqlh8C9DCzFGyK/index"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/", "pYUMJqQmqlh8C9DCzFGyK/index"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/layout", "pYUMJqQmqlh8C9DCzFGyK/manifest.webmanifest"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/manifest.webmanifest/layout", "pYUMJqQmqlh8C9DCzFGyK/manifest.webmanifest"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/manifest.webmanifest/route", "pYUMJqQmqlh8C9DCzFGyK/manifest.webmanifest"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/manifest.webmanifest", "pYUMJqQmqlh8C9DCzFGyK/manifest.webmanifest"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/layout", "pYUMJqQmqlh8C9DCzFGyK/new"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/(home)/layout", "pYUMJqQmqlh8C9DCzFGyK/new"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/(home)/new/layout", "pYUMJqQmqlh8C9DCzFGyK/new"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/(home)/new/page", "pYUMJqQmqlh8C9DCzFGyK/new"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/new", "pYUMJqQmqlh8C9DCzFGyK/new"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/layout", "pYUMJqQmqlh8C9DCzFGyK/robots.txt"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/robots.txt/layout", "pYUMJqQmqlh8C9DCzFGyK/robots.txt"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/robots.txt/route", "pYUMJqQmqlh8C9DCzFGyK/robots.txt"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/robots.txt", "pYUMJqQmqlh8C9DCzFGyK/robots.txt"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/layout", "pYUMJqQmqlh8C9DCzFGyK/showcase"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/(home)/layout", "pYUMJqQmqlh8C9DCzFGyK/showcase"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/(home)/showcase/layout", "pYUMJqQmqlh8C9DCzFGyK/showcase"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/(home)/showcase/page", "pYUMJqQmqlh8C9DCzFGyK/showcase"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/showcase", "pYUMJqQmqlh8C9DCzFGyK/showcase"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/layout", "pYUMJqQmqlh8C9DCzFGyK/sitemap.xml"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/sitemap.xml/layout", "pYUMJqQmqlh8C9DCzFGyK/sitemap.xml"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/sitemap.xml/route", "pYUMJqQmqlh8C9DCzFGyK/sitemap.xml"), ("pYUMJqQmqlh8C9DCzFGyK/_N_T_/sitemap.xml", "pYUMJqQmqlh8C9DCzFGyK/sitemap.xml");
|
||||
146
apps/web/.open-next/cloudflare/images.js
Normal file
146
apps/web/.open-next/cloudflare/images.js
Normal file
@@ -0,0 +1,146 @@
|
||||
var define_IMAGES_LOCAL_PATTERNS_default = [];
|
||||
var define_IMAGES_REMOTE_PATTERNS_default = [];
|
||||
async function fetchImage(fetcher, imageUrl, ctx) {
|
||||
if (!imageUrl || imageUrl.length > 3072 || imageUrl.startsWith("//")) {
|
||||
return getUrlErrorResponse();
|
||||
}
|
||||
if (imageUrl.startsWith("/")) {
|
||||
let pathname;
|
||||
let url2;
|
||||
try {
|
||||
url2 = new URL(imageUrl, "http://n");
|
||||
pathname = decodeURIComponent(url2.pathname);
|
||||
} catch {
|
||||
return getUrlErrorResponse();
|
||||
}
|
||||
if (/\/_next\/image($|\/)/.test(pathname)) {
|
||||
return getUrlErrorResponse();
|
||||
}
|
||||
if (define_IMAGES_LOCAL_PATTERNS_default.length > 0 && !define_IMAGES_LOCAL_PATTERNS_default.some((p) => matchLocalPattern(p, url2))) {
|
||||
return getUrlErrorResponse();
|
||||
}
|
||||
return fetcher?.fetch(`http://assets.local${imageUrl}`);
|
||||
}
|
||||
let url;
|
||||
try {
|
||||
url = new URL(imageUrl);
|
||||
} catch {
|
||||
return getUrlErrorResponse();
|
||||
}
|
||||
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
||||
return getUrlErrorResponse();
|
||||
}
|
||||
if (!define_IMAGES_REMOTE_PATTERNS_default.some((p) => matchRemotePattern(p, url))) {
|
||||
return getUrlErrorResponse();
|
||||
}
|
||||
const imgResponse = await fetch(imageUrl, { cf: { cacheEverything: true } });
|
||||
if (!imgResponse.body) {
|
||||
return imgResponse;
|
||||
}
|
||||
const buffer = new ArrayBuffer(32);
|
||||
try {
|
||||
let contentType;
|
||||
const [body1, body2] = imgResponse.body.tee();
|
||||
const reader = body2.getReader({ mode: "byob" });
|
||||
const { value } = await reader.read(new Uint8Array(buffer));
|
||||
ctx.waitUntil(reader.cancel());
|
||||
if (value) {
|
||||
contentType = detectContentType(value);
|
||||
}
|
||||
if (!contentType) {
|
||||
const header = imgResponse.headers.get("content-type") ?? "";
|
||||
if (header.startsWith("image/") && !header.includes(",")) {
|
||||
contentType = header;
|
||||
}
|
||||
}
|
||||
if (contentType && !(contentType === SVG && true)) {
|
||||
const headers = new Headers(imgResponse.headers);
|
||||
headers.set("content-type", contentType);
|
||||
headers.set("content-disposition", "attachment");
|
||||
headers.set("content-security-policy", "script-src 'none'; frame-src 'none'; sandbox;");
|
||||
return new Response(body1, { ...imgResponse, headers });
|
||||
}
|
||||
return new Response('"url" parameter is valid but image type is not allowed', {
|
||||
status: 400
|
||||
});
|
||||
} catch {
|
||||
return new Response('"url" parameter is valid but upstream response is invalid', {
|
||||
status: 400
|
||||
});
|
||||
}
|
||||
}
|
||||
function matchRemotePattern(pattern, url) {
|
||||
if (pattern.protocol !== void 0 && pattern.protocol.replace(/:$/, "") !== url.protocol.replace(/:$/, "")) {
|
||||
return false;
|
||||
}
|
||||
if (pattern.port !== void 0 && pattern.port !== url.port) {
|
||||
return false;
|
||||
}
|
||||
if (pattern.hostname === void 0 || !new RegExp(pattern.hostname).test(url.hostname)) {
|
||||
return false;
|
||||
}
|
||||
if (pattern.search !== void 0 && pattern.search !== url.search) {
|
||||
return false;
|
||||
}
|
||||
return new RegExp(pattern.pathname).test(url.pathname);
|
||||
}
|
||||
function matchLocalPattern(pattern, url) {
|
||||
if (pattern.search !== void 0 && pattern.search !== url.search) {
|
||||
return false;
|
||||
}
|
||||
return new RegExp(pattern.pathname).test(url.pathname);
|
||||
}
|
||||
function getUrlErrorResponse() {
|
||||
return new Response(`"url" parameter is not allowed`, { status: 400 });
|
||||
}
|
||||
const AVIF = "image/avif";
|
||||
const WEBP = "image/webp";
|
||||
const PNG = "image/png";
|
||||
const JPEG = "image/jpeg";
|
||||
const GIF = "image/gif";
|
||||
const SVG = "image/svg+xml";
|
||||
const ICO = "image/x-icon";
|
||||
const ICNS = "image/x-icns";
|
||||
const TIFF = "image/tiff";
|
||||
const BMP = "image/bmp";
|
||||
function detectContentType(buffer) {
|
||||
if ([255, 216, 255].every((b, i) => buffer[i] === b)) {
|
||||
return JPEG;
|
||||
}
|
||||
if ([137, 80, 78, 71, 13, 10, 26, 10].every((b, i) => buffer[i] === b)) {
|
||||
return PNG;
|
||||
}
|
||||
if ([71, 73, 70, 56].every((b, i) => buffer[i] === b)) {
|
||||
return GIF;
|
||||
}
|
||||
if ([82, 73, 70, 70, 0, 0, 0, 0, 87, 69, 66, 80].every((b, i) => !b || buffer[i] === b)) {
|
||||
return WEBP;
|
||||
}
|
||||
if ([60, 63, 120, 109, 108].every((b, i) => buffer[i] === b)) {
|
||||
return SVG;
|
||||
}
|
||||
if ([60, 115, 118, 103].every((b, i) => buffer[i] === b)) {
|
||||
return SVG;
|
||||
}
|
||||
if ([0, 0, 0, 0, 102, 116, 121, 112, 97, 118, 105, 102].every((b, i) => !b || buffer[i] === b)) {
|
||||
return AVIF;
|
||||
}
|
||||
if ([0, 0, 1, 0].every((b, i) => buffer[i] === b)) {
|
||||
return ICO;
|
||||
}
|
||||
if ([105, 99, 110, 115].every((b, i) => buffer[i] === b)) {
|
||||
return ICNS;
|
||||
}
|
||||
if ([73, 73, 42, 0].every((b, i) => buffer[i] === b)) {
|
||||
return TIFF;
|
||||
}
|
||||
if ([66, 77].every((b, i) => buffer[i] === b)) {
|
||||
return BMP;
|
||||
}
|
||||
}
|
||||
export {
|
||||
detectContentType,
|
||||
fetchImage,
|
||||
matchLocalPattern,
|
||||
matchRemotePattern
|
||||
};
|
||||
87
apps/web/.open-next/cloudflare/init.js
Normal file
87
apps/web/.open-next/cloudflare/init.js
Normal file
@@ -0,0 +1,87 @@
|
||||
import { AsyncLocalStorage } from "node:async_hooks";
|
||||
import process from "node:process";
|
||||
import stream from "node:stream";
|
||||
import * as nextEnvVars from "./next-env.mjs";
|
||||
const cloudflareContextALS = new AsyncLocalStorage();
|
||||
Object.defineProperty(globalThis, Symbol.for("__cloudflare-context__"), {
|
||||
get() {
|
||||
return cloudflareContextALS.getStore();
|
||||
}
|
||||
});
|
||||
async function runWithCloudflareRequestContext(request, env, ctx, handler) {
|
||||
init(request, env);
|
||||
return cloudflareContextALS.run({ env, ctx, cf: request.cf }, handler);
|
||||
}
|
||||
let initialized = false;
|
||||
function init(request, env) {
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
initialized = true;
|
||||
const url = new URL(request.url);
|
||||
initRuntime();
|
||||
populateProcessEnv(url, env);
|
||||
}
|
||||
function initRuntime() {
|
||||
Object.assign(process, { version: process.version || "v22.14.0" });
|
||||
Object.assign(process.versions, { node: "22.14.0", ...process.versions });
|
||||
globalThis.__dirname ??= "";
|
||||
globalThis.__filename ??= "";
|
||||
import.meta.url ??= "file:///worker.js";
|
||||
const __original_fetch = globalThis.fetch;
|
||||
globalThis.fetch = (input, init2) => {
|
||||
if (init2) {
|
||||
delete init2.cache;
|
||||
}
|
||||
return __original_fetch(input, init2);
|
||||
};
|
||||
const CustomRequest = class extends globalThis.Request {
|
||||
constructor(input, init2) {
|
||||
if (init2) {
|
||||
delete init2.cache;
|
||||
Object.defineProperty(init2, "body", {
|
||||
// @ts-ignore
|
||||
value: init2.body instanceof stream.Readable ? ReadableStream.from(init2.body) : init2.body
|
||||
});
|
||||
}
|
||||
super(input, init2);
|
||||
}
|
||||
};
|
||||
Object.assign(globalThis, {
|
||||
Request: CustomRequest,
|
||||
__BUILD_TIMESTAMP_MS__: 1752392720870,
|
||||
__NEXT_BASE_PATH__: "",
|
||||
__ASSETS_RUN_WORKER_FIRST__: false,
|
||||
// The external middleware will use the convertTo function of the `edge` converter
|
||||
// by default it will try to fetch the request, but since we are running everything in the same worker
|
||||
// we need to use the request as is.
|
||||
__dangerous_ON_edge_converter_returns_request: true
|
||||
});
|
||||
}
|
||||
function populateProcessEnv(url, env) {
|
||||
for (const [key, value] of Object.entries(env)) {
|
||||
if (typeof value === "string") {
|
||||
process.env[key] = value;
|
||||
}
|
||||
}
|
||||
const mode = env.NEXTJS_ENV ?? "production";
|
||||
if (nextEnvVars[mode]) {
|
||||
for (const key in nextEnvVars[mode]) {
|
||||
process.env[key] ??= nextEnvVars[mode][key];
|
||||
}
|
||||
}
|
||||
process.env.OPEN_NEXT_ORIGIN = JSON.stringify({
|
||||
default: {
|
||||
host: url.hostname,
|
||||
protocol: url.protocol.slice(0, -1),
|
||||
port: url.port
|
||||
}
|
||||
});
|
||||
process.env.__NEXT_PRIVATE_ORIGIN = url.origin;
|
||||
if ("") {
|
||||
process.env.DEPLOYMENT_ID = "";
|
||||
}
|
||||
}
|
||||
export {
|
||||
runWithCloudflareRequestContext
|
||||
};
|
||||
3
apps/web/.open-next/cloudflare/next-env.mjs
Normal file
3
apps/web/.open-next/cloudflare/next-env.mjs
Normal file
@@ -0,0 +1,3 @@
|
||||
export const production = {"NEXT_PUBLIC_POSTHOG_KEY":"phc_8ZUxEwwfKMajJLvxz1daGd931dYbQrwKNficBmsdIrs","NEXT_PUBLIC_POSTHOG_HOST":"https://us.i.posthog.com"};
|
||||
export const development = {"NEXT_PUBLIC_POSTHOG_KEY":"phc_8ZUxEwwfKMajJLvxz1daGd931dYbQrwKNficBmsdIrs","NEXT_PUBLIC_POSTHOG_HOST":"https://us.i.posthog.com"};
|
||||
export const test = {"NEXT_PUBLIC_POSTHOG_KEY":"phc_8ZUxEwwfKMajJLvxz1daGd931dYbQrwKNficBmsdIrs","NEXT_PUBLIC_POSTHOG_HOST":"https://us.i.posthog.com"};
|
||||
33
apps/web/.open-next/cloudflare/skew-protection.js
Normal file
33
apps/web/.open-next/cloudflare/skew-protection.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import process from "node:process";
|
||||
const DEPLOYMENT_MAPPING_ENV_NAME = "CF_DEPLOYMENT_MAPPING";
|
||||
const CURRENT_VERSION_ID = "current";
|
||||
function maybeGetSkewProtectionResponse(request) {
|
||||
if (false) {
|
||||
const url = new URL(request.url);
|
||||
if (url.hostname === "localhost" || url.hostname.endsWith(".workers.dev")) {
|
||||
return void 0;
|
||||
}
|
||||
const requestDeploymentId = request.headers.get("x-deployment-id") ?? url.searchParams.get("dpl");
|
||||
if (!requestDeploymentId || requestDeploymentId === process.env.DEPLOYMENT_ID) {
|
||||
return void 0;
|
||||
}
|
||||
const mapping = process.env[DEPLOYMENT_MAPPING_ENV_NAME] ? JSON.parse(process.env[DEPLOYMENT_MAPPING_ENV_NAME]) : {};
|
||||
if (!(requestDeploymentId in mapping)) {
|
||||
return void 0;
|
||||
}
|
||||
const version = mapping[requestDeploymentId];
|
||||
if (!version || version === CURRENT_VERSION_ID) {
|
||||
return void 0;
|
||||
}
|
||||
const versionDomain = version.split("-")[0];
|
||||
const hostname = `${versionDomain}-${process.env.CF_WORKER_NAME}.${process.env.CF_PREVIEW_DOMAIN}.workers.dev`;
|
||||
url.hostname = hostname;
|
||||
const requestToOlderDeployment = new Request(url, request);
|
||||
return fetch(requestToOlderDeployment);
|
||||
}
|
||||
}
|
||||
export {
|
||||
CURRENT_VERSION_ID,
|
||||
DEPLOYMENT_MAPPING_ENV_NAME,
|
||||
maybeGetSkewProtectionResponse
|
||||
};
|
||||
Reference in New Issue
Block a user