Update 11/14

This commit is contained in:
deterge
2025-11-14 23:01:35 -05:00
parent 60eacaace4
commit d7d34e4f7b
8 changed files with 147 additions and 7 deletions

View File

@@ -53,6 +53,24 @@ const customFetch: typeof fetch = (input, init) => {
return Promise.resolve(response);
}
if (isLocalResource(input, "current-date")) {
const now = new Date();
// Normalize to midnight UTC to prevent hydration mismatches
const startOfDay = new Date(
Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())
);
const data = {
iso: startOfDay.toISOString(),
year: startOfDay.getUTCFullYear(),
month: startOfDay.getUTCMonth() + 1, // 1-12 instead of 0-11
day: startOfDay.getUTCDate(),
timestamp: startOfDay.getTime(),
};
const response = new Response(JSON.stringify(data));
response.headers.set("content-type", "application/json; charset=utf-8");
return Promise.resolve(response);
}
return cachedFetch(projectId, input, init);
};
@@ -70,6 +88,7 @@ export const loader = async (arg: LoaderFunctionArgs) => {
params,
search: Object.fromEntries(url.searchParams),
origin: url.origin,
pathname: url.pathname,
};
const resources = await loadResources(
@@ -203,6 +222,7 @@ export const action = async ({
params: {},
search: {},
origin: url.origin,
pathname: url.pathname,
};
const resourceName = formData.get(formIdFieldName);

View File

@@ -53,6 +53,24 @@ const customFetch: typeof fetch = (input, init) => {
return Promise.resolve(response);
}
if (isLocalResource(input, "current-date")) {
const now = new Date();
// Normalize to midnight UTC to prevent hydration mismatches
const startOfDay = new Date(
Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())
);
const data = {
iso: startOfDay.toISOString(),
year: startOfDay.getUTCFullYear(),
month: startOfDay.getUTCMonth() + 1, // 1-12 instead of 0-11
day: startOfDay.getUTCDate(),
timestamp: startOfDay.getTime(),
};
const response = new Response(JSON.stringify(data));
response.headers.set("content-type", "application/json; charset=utf-8");
return Promise.resolve(response);
}
return cachedFetch(projectId, input, init);
};
@@ -70,6 +88,7 @@ export const loader = async (arg: LoaderFunctionArgs) => {
params,
search: Object.fromEntries(url.searchParams),
origin: url.origin,
pathname: url.pathname,
};
const resources = await loadResources(
@@ -203,6 +222,7 @@ export const action = async ({
params: {},
search: {},
origin: url.origin,
pathname: url.pathname,
};
const resourceName = formData.get(formIdFieldName);

View File

@@ -53,6 +53,24 @@ const customFetch: typeof fetch = (input, init) => {
return Promise.resolve(response);
}
if (isLocalResource(input, "current-date")) {
const now = new Date();
// Normalize to midnight UTC to prevent hydration mismatches
const startOfDay = new Date(
Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())
);
const data = {
iso: startOfDay.toISOString(),
year: startOfDay.getUTCFullYear(),
month: startOfDay.getUTCMonth() + 1, // 1-12 instead of 0-11
day: startOfDay.getUTCDate(),
timestamp: startOfDay.getTime(),
};
const response = new Response(JSON.stringify(data));
response.headers.set("content-type", "application/json; charset=utf-8");
return Promise.resolve(response);
}
return cachedFetch(projectId, input, init);
};
@@ -70,6 +88,7 @@ export const loader = async (arg: LoaderFunctionArgs) => {
params,
search: Object.fromEntries(url.searchParams),
origin: url.origin,
pathname: url.pathname,
};
const resources = await loadResources(
@@ -203,6 +222,7 @@ export const action = async ({
params: {},
search: {},
origin: url.origin,
pathname: url.pathname,
};
const resourceName = formData.get(formIdFieldName);

View File

@@ -53,6 +53,24 @@ const customFetch: typeof fetch = (input, init) => {
return Promise.resolve(response);
}
if (isLocalResource(input, "current-date")) {
const now = new Date();
// Normalize to midnight UTC to prevent hydration mismatches
const startOfDay = new Date(
Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())
);
const data = {
iso: startOfDay.toISOString(),
year: startOfDay.getUTCFullYear(),
month: startOfDay.getUTCMonth() + 1, // 1-12 instead of 0-11
day: startOfDay.getUTCDate(),
timestamp: startOfDay.getTime(),
};
const response = new Response(JSON.stringify(data));
response.headers.set("content-type", "application/json; charset=utf-8");
return Promise.resolve(response);
}
return cachedFetch(projectId, input, init);
};
@@ -70,6 +88,7 @@ export const loader = async (arg: LoaderFunctionArgs) => {
params,
search: Object.fromEntries(url.searchParams),
origin: url.origin,
pathname: url.pathname,
};
const resources = await loadResources(
@@ -203,6 +222,7 @@ export const action = async ({
params: {},
search: {},
origin: url.origin,
pathname: url.pathname,
};
const resourceName = formData.get(formIdFieldName);

View File

@@ -53,6 +53,24 @@ const customFetch: typeof fetch = (input, init) => {
return Promise.resolve(response);
}
if (isLocalResource(input, "current-date")) {
const now = new Date();
// Normalize to midnight UTC to prevent hydration mismatches
const startOfDay = new Date(
Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())
);
const data = {
iso: startOfDay.toISOString(),
year: startOfDay.getUTCFullYear(),
month: startOfDay.getUTCMonth() + 1, // 1-12 instead of 0-11
day: startOfDay.getUTCDate(),
timestamp: startOfDay.getTime(),
};
const response = new Response(JSON.stringify(data));
response.headers.set("content-type", "application/json; charset=utf-8");
return Promise.resolve(response);
}
return cachedFetch(projectId, input, init);
};
@@ -70,6 +88,7 @@ export const loader = async (arg: LoaderFunctionArgs) => {
params,
search: Object.fromEntries(url.searchParams),
origin: url.origin,
pathname: url.pathname,
};
const resources = await loadResources(
@@ -203,6 +222,7 @@ export const action = async ({
params: {},
search: {},
origin: url.origin,
pathname: url.pathname,
};
const resourceName = formData.get(formIdFieldName);

View File

@@ -53,6 +53,24 @@ const customFetch: typeof fetch = (input, init) => {
return Promise.resolve(response);
}
if (isLocalResource(input, "current-date")) {
const now = new Date();
// Normalize to midnight UTC to prevent hydration mismatches
const startOfDay = new Date(
Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())
);
const data = {
iso: startOfDay.toISOString(),
year: startOfDay.getUTCFullYear(),
month: startOfDay.getUTCMonth() + 1, // 1-12 instead of 0-11
day: startOfDay.getUTCDate(),
timestamp: startOfDay.getTime(),
};
const response = new Response(JSON.stringify(data));
response.headers.set("content-type", "application/json; charset=utf-8");
return Promise.resolve(response);
}
return cachedFetch(projectId, input, init);
};
@@ -70,6 +88,7 @@ export const loader = async (arg: LoaderFunctionArgs) => {
params,
search: Object.fromEntries(url.searchParams),
origin: url.origin,
pathname: url.pathname,
};
const resources = await loadResources(
@@ -203,6 +222,7 @@ export const action = async ({
params: {},
search: {},
origin: url.origin,
pathname: url.pathname,
};
const resourceName = formData.get(formIdFieldName);

View File

@@ -53,6 +53,24 @@ const customFetch: typeof fetch = (input, init) => {
return Promise.resolve(response);
}
if (isLocalResource(input, "current-date")) {
const now = new Date();
// Normalize to midnight UTC to prevent hydration mismatches
const startOfDay = new Date(
Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())
);
const data = {
iso: startOfDay.toISOString(),
year: startOfDay.getUTCFullYear(),
month: startOfDay.getUTCMonth() + 1, // 1-12 instead of 0-11
day: startOfDay.getUTCDate(),
timestamp: startOfDay.getTime(),
};
const response = new Response(JSON.stringify(data));
response.headers.set("content-type", "application/json; charset=utf-8");
return Promise.resolve(response);
}
return cachedFetch(projectId, input, init);
};
@@ -70,6 +88,7 @@ export const loader = async (arg: LoaderFunctionArgs) => {
params,
search: Object.fromEntries(url.searchParams),
origin: url.origin,
pathname: url.pathname,
};
const resources = await loadResources(
@@ -203,6 +222,7 @@ export const action = async ({
params: {},
search: {},
origin: url.origin,
pathname: url.pathname,
};
const resourceName = formData.get(formIdFieldName);

View File

@@ -11,13 +11,13 @@
"dependencies": {
"@react-router/dev": "^7.5.3",
"@react-router/fs-routes": "^7.5.3",
"@webstudio-is/image": "0.231.0",
"@webstudio-is/react-sdk": "0.231.0",
"@webstudio-is/sdk": "0.231.0",
"@webstudio-is/sdk-components-animation": "0.231.0",
"@webstudio-is/sdk-components-react-radix": "0.231.0",
"@webstudio-is/sdk-components-react-router": "0.231.0",
"@webstudio-is/sdk-components-react": "0.231.0",
"@webstudio-is/image": "0.234.0",
"@webstudio-is/react-sdk": "0.234.0",
"@webstudio-is/sdk": "0.234.0",
"@webstudio-is/sdk-components-animation": "0.234.0",
"@webstudio-is/sdk-components-react-radix": "0.234.0",
"@webstudio-is/sdk-components-react-router": "0.234.0",
"@webstudio-is/sdk-components-react": "0.234.0",
"isbot": "^5.1.25",
"react": "18.3.0-canary-14898b6a9-20240318",
"react-dom": "18.3.0-canary-14898b6a9-20240318",