@shopify/hydrogen 2025.7.0 → 2025.7.2
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/dev/{get-virtual-routes-KWSSQH4L.js → get-virtual-routes-ZEUPNZWL.js} +0 -36
- package/dist/dev/hydrogen-routes.js +1 -1
- package/dist/development/{get-virtual-routes-6PVSMJPH.js → get-virtual-routes-XE7G57DS.js} +3 -36
- package/dist/development/get-virtual-routes-XE7G57DS.js.map +1 -0
- package/dist/development/index.cjs +406 -124
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +395 -81
- package/dist/development/index.js.map +1 -1
- package/dist/development/react-router-preset.d.ts +5 -5
- package/dist/development/react-router-preset.js +4 -4
- package/dist/development/react-router-preset.js.map +1 -1
- package/dist/oxygen/index.d.ts +120 -3
- package/dist/oxygen/index.js +111 -5
- package/dist/production/get-virtual-routes-MYYLGSAS.js +3 -0
- package/dist/production/get-virtual-routes-MYYLGSAS.js.map +1 -0
- package/dist/production/index.cjs +76 -76
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.d.cts +76 -15
- package/dist/production/index.d.ts +76 -15
- package/dist/production/index.js +76 -76
- package/dist/production/index.js.map +1 -1
- package/dist/production/react-router-preset.d.ts +5 -5
- package/dist/production/react-router-preset.js +2 -2
- package/dist/vite/get-virtual-routes.d.ts +1 -17
- package/dist/vite/get-virtual-routes.js +0 -36
- package/package.json +6 -6
- package/dist/development/get-virtual-routes-6PVSMJPH.js.map +0 -1
- package/dist/oxygen/chunk-RVXKHOUX.js +0 -39
- package/dist/oxygen/chunk-T4YWBSCF.js +0 -14
- package/dist/oxygen/createRequestHandler.d.ts +0 -10
- package/dist/oxygen/createRequestHandler.js +0 -6
- package/dist/oxygen/getStorefrontHeaders-BqPh5S1b.d.ts +0 -69
- package/dist/oxygen/getStorefrontHeaders.d.ts +0 -1
- package/dist/oxygen/getStorefrontHeaders.js +0 -6
- package/dist/production/get-virtual-routes-JVKSNI4M.js +0 -3
- package/dist/production/get-virtual-routes-JVKSNI4M.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Preset } from '@react-router/dev/config';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Official Hydrogen Preset for React Router 7.
|
|
4
|
+
* Official Hydrogen Preset for React Router 7.12.x
|
|
5
5
|
*
|
|
6
6
|
* Provides optimal React Router configuration for Hydrogen applications on Oxygen.
|
|
7
7
|
* Enables validated performance optimizations while ensuring CLI compatibility.
|
|
8
8
|
*
|
|
9
|
-
* React Router 7.
|
|
9
|
+
* React Router 7.12.x Feature Support Matrix for Hydrogen 2025.7.0
|
|
10
10
|
*
|
|
11
11
|
* +----------------------------------+----------+----------------------------------+
|
|
12
12
|
* | Feature | Status | Notes |
|
|
@@ -19,9 +19,9 @@ import { Preset } from '@react-router/dev/config';
|
|
|
19
19
|
* +----------------------------------+----------+----------------------------------+
|
|
20
20
|
* | PERFORMANCE FLAGS |
|
|
21
21
|
* +----------------------------------+----------+----------------------------------+
|
|
22
|
-
* | unstable_optimizeDeps | Enabled | Build performance optimization |
|
|
23
22
|
* | v8_middleware | Enabled | Required for Hydrogen context |
|
|
24
|
-
* |
|
|
23
|
+
* | v8_splitRouteModules | Enabled | Route code splitting |
|
|
24
|
+
* | unstable_optimizeDeps | Enabled | Build performance optimization |
|
|
25
25
|
* +----------------------------------+----------+----------------------------------+
|
|
26
26
|
* | ROUTE DISCOVERY |
|
|
27
27
|
* +----------------------------------+----------+----------------------------------+
|
|
@@ -35,7 +35,7 @@ import { Preset } from '@react-router/dev/config';
|
|
|
35
35
|
* | serverBundles: () => {} | Blocked | Manifest incompatibility |
|
|
36
36
|
* | buildEnd: () => {} | Blocked | CLI bypasses hook execution |
|
|
37
37
|
* | unstable_subResourceIntegrity | Blocked | CSP nonce/hash conflict |
|
|
38
|
-
* |
|
|
38
|
+
* | v8_viteEnvironmentApi | Blocked | CLI fallback detection used |
|
|
39
39
|
* +----------------------------------+----------+----------------------------------+
|
|
40
40
|
*
|
|
41
41
|
* @version 2025.7.0
|
|
@@ -8,10 +8,10 @@ function hydrogenPreset() {
|
|
|
8
8
|
ssr: true,
|
|
9
9
|
future: {
|
|
10
10
|
v8_middleware: true,
|
|
11
|
+
v8_splitRouteModules: true,
|
|
12
|
+
v8_viteEnvironmentApi: false,
|
|
11
13
|
unstable_optimizeDeps: true,
|
|
12
|
-
|
|
13
|
-
unstable_subResourceIntegrity: false,
|
|
14
|
-
unstable_viteEnvironmentApi: false
|
|
14
|
+
unstable_subResourceIntegrity: false
|
|
15
15
|
}
|
|
16
16
|
}),
|
|
17
17
|
reactRouterConfigResolved: ({ reactRouterConfig }) => {
|
|
@@ -27,7 +27,7 @@ function hydrogenPreset() {
|
|
|
27
27
|
}
|
|
28
28
|
if (reactRouterConfig.serverBundles) {
|
|
29
29
|
throw new Error(
|
|
30
|
-
"[Hydrogen Preset] serverBundles is not supported in Hydrogen 2025.7.0.\nReason: React Router plugin manifest incompatibility with Hydrogen CLI.\nAlternative: Route-level code splitting via
|
|
30
|
+
"[Hydrogen Preset] serverBundles is not supported in Hydrogen 2025.7.0.\nReason: React Router plugin manifest incompatibility with Hydrogen CLI.\nAlternative: Route-level code splitting via v8_splitRouteModules is enabled."
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
if (reactRouterConfig.buildEnd) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react-router-preset.ts"],"sourcesContent":["import type {Preset} from '@react-router/dev/config';\n\n/**\n * Official Hydrogen Preset for React Router 7.
|
|
1
|
+
{"version":3,"sources":["../../src/react-router-preset.ts"],"sourcesContent":["import type {Preset} from '@react-router/dev/config';\n\n/**\n * Official Hydrogen Preset for React Router 7.12.x\n *\n * Provides optimal React Router configuration for Hydrogen applications on Oxygen.\n * Enables validated performance optimizations while ensuring CLI compatibility.\n *\n * React Router 7.12.x Feature Support Matrix for Hydrogen 2025.7.0\n *\n * +----------------------------------+----------+----------------------------------+\n * | Feature | Status | Notes |\n * +----------------------------------+----------+----------------------------------+\n * | CORE CONFIGURATION |\n * +----------------------------------+----------+----------------------------------+\n * | appDirectory: 'app' | Enabled | Core application structure |\n * | buildDirectory: 'dist' | Enabled | Build output configuration |\n * | ssr: true | Enabled | Server-side rendering |\n * +----------------------------------+----------+----------------------------------+\n * | PERFORMANCE FLAGS |\n * +----------------------------------+----------+----------------------------------+\n * | v8_middleware | Enabled | Required for Hydrogen context |\n * | v8_splitRouteModules | Enabled | Route code splitting |\n * | unstable_optimizeDeps | Enabled | Build performance optimization |\n * +----------------------------------+----------+----------------------------------+\n * | ROUTE DISCOVERY |\n * +----------------------------------+----------+----------------------------------+\n * | routeDiscovery: { mode: 'lazy' } | Default | Lazy route loading |\n * | routeDiscovery: { mode: 'init' } | Allowed | Eager route loading |\n * +----------------------------------+----------+----------------------------------+\n * | UNSUPPORTED FEATURES |\n * +----------------------------------+----------+----------------------------------+\n * | basename: '/path' | Blocked | CLI infrastructure limitation |\n * | prerender: ['/routes'] | Blocked | Plugin incompatibility |\n * | serverBundles: () => {} | Blocked | Manifest incompatibility |\n * | buildEnd: () => {} | Blocked | CLI bypasses hook execution |\n * | unstable_subResourceIntegrity | Blocked | CSP nonce/hash conflict |\n * | v8_viteEnvironmentApi | Blocked | CLI fallback detection used |\n * +----------------------------------+----------+----------------------------------+\n *\n * @version 2025.7.0\n */\nexport function hydrogenPreset(): Preset {\n return {\n name: 'hydrogen-2025.7.0',\n\n reactRouterConfig: () => ({\n appDirectory: 'app',\n buildDirectory: 'dist',\n ssr: true,\n\n future: {\n v8_middleware: true,\n v8_splitRouteModules: true,\n v8_viteEnvironmentApi: false,\n unstable_optimizeDeps: true,\n unstable_subResourceIntegrity: false,\n },\n }),\n\n reactRouterConfigResolved: ({reactRouterConfig}) => {\n if (reactRouterConfig.basename && reactRouterConfig.basename !== '/') {\n throw new Error(\n '[Hydrogen Preset] basename is not supported in Hydrogen 2025.7.0.\\n' +\n 'Reason: Requires major CLI infrastructure modernization.\\n' +\n 'Workaround: Use reverse proxy or CDN path rewriting for subdirectory hosting.',\n );\n }\n\n if (reactRouterConfig.prerender) {\n throw new Error(\n '[Hydrogen Preset] prerender is not supported in Hydrogen 2025.7.0.\\n' +\n 'Reason: React Router plugin incompatibility with Hydrogen CLI build pipeline.\\n' +\n 'Workaround: Use external static generation tools or server-side caching.',\n );\n }\n\n if (reactRouterConfig.serverBundles) {\n throw new Error(\n '[Hydrogen Preset] serverBundles is not supported in Hydrogen 2025.7.0.\\n' +\n 'Reason: React Router plugin manifest incompatibility with Hydrogen CLI.\\n' +\n 'Alternative: Route-level code splitting via v8_splitRouteModules is enabled.',\n );\n }\n\n if (reactRouterConfig.buildEnd) {\n throw new Error(\n '[Hydrogen Preset] buildEnd is not supported in Hydrogen 2025.7.0.\\n' +\n 'Reason: Hydrogen CLI bypasses React Router buildEnd hook execution.\\n' +\n 'Workaround: Use external build scripts or package.json post-build hooks.',\n );\n }\n\n if (reactRouterConfig.future?.unstable_subResourceIntegrity === true) {\n throw new Error(\n '[Hydrogen Preset] unstable_subResourceIntegrity cannot be enabled.\\n' +\n 'Reason: Conflicts with Hydrogen CSP nonce-based authentication.\\n' +\n 'Impact: Would break Content Security Policy and cause script execution failures.',\n );\n }\n },\n };\n}\n"],"mappings":";AA0CO,SAAS,iBAAyB;AACvC,SAAO;AAAA,IACL,MAAM;AAAA,IAEN,mBAAmB,OAAO;AAAA,MACxB,cAAc;AAAA,MACd,gBAAgB;AAAA,MAChB,KAAK;AAAA,MAEL,QAAQ;AAAA,QACN,eAAe;AAAA,QACf,sBAAsB;AAAA,QACtB,uBAAuB;AAAA,QACvB,uBAAuB;AAAA,QACvB,+BAA+B;AAAA,MACjC;AAAA,IACF;AAAA,IAEA,2BAA2B,CAAC,EAAC,kBAAiB,MAAM;AAClD,UAAI,kBAAkB,YAAY,kBAAkB,aAAa,KAAK;AACpE,cAAM,IAAI;AAAA,UACR;AAAA,QAGF;AAAA,MACF;AAEA,UAAI,kBAAkB,WAAW;AAC/B,cAAM,IAAI;AAAA,UACR;AAAA,QAGF;AAAA,MACF;AAEA,UAAI,kBAAkB,eAAe;AACnC,cAAM,IAAI;AAAA,UACR;AAAA,QAGF;AAAA,MACF;AAEA,UAAI,kBAAkB,UAAU;AAC9B,cAAM,IAAI;AAAA,UACR;AAAA,QAGF;AAAA,MACF;AAEA,UAAI,kBAAkB,QAAQ,kCAAkC,MAAM;AACpE,cAAM,IAAI;AAAA,UACR;AAAA,QAGF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/oxygen/index.d.ts
CHANGED
|
@@ -1,3 +1,120 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ServerBuild } from 'react-router';
|
|
2
|
+
|
|
3
|
+
type CreateRequestHandlerOptions<Context = unknown> = {
|
|
4
|
+
/** React Router's server build */
|
|
5
|
+
build: ServerBuild;
|
|
6
|
+
/** React Router's mode */
|
|
7
|
+
mode?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Function to provide the load context for each request.
|
|
10
|
+
* It must contain Hydrogen's storefront client instance
|
|
11
|
+
* for other Hydrogen utilities to work properly.
|
|
12
|
+
*/
|
|
13
|
+
getLoadContext?: (request: Request) => Promise<Context> | Context;
|
|
14
|
+
/**
|
|
15
|
+
* Whether to include the `powered-by` header in responses
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
poweredByHeader?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Collect tracking information from subrequests such as cookies
|
|
21
|
+
* and forward them to the browser. Disable this if you are not
|
|
22
|
+
* using Hydrogen's built-in analytics.
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
collectTrackingInformation?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Whether to proxy standard routes such as `/api/.../graphql.json` (Storefront API).
|
|
28
|
+
* You can disable this if you are handling these routes yourself. Ensure that
|
|
29
|
+
* the proxy works if you rely on Hydrogen's built-in behaviors such as analytics.
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
proxyStandardRoutes?: boolean;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Creates a request handler for Hydrogen apps using React Router.
|
|
36
|
+
*/
|
|
37
|
+
declare function createRequestHandler<Context = unknown>({ build, mode, poweredByHeader, getLoadContext, collectTrackingInformation, proxyStandardRoutes, }: CreateRequestHandlerOptions<Context>): (request: Request) => Promise<Response>;
|
|
38
|
+
|
|
39
|
+
type RequestEventPayload = {
|
|
40
|
+
__fromVite?: boolean;
|
|
41
|
+
url: string;
|
|
42
|
+
eventType: 'request' | 'subrequest';
|
|
43
|
+
requestId?: string | null;
|
|
44
|
+
purpose?: string | null;
|
|
45
|
+
startTime: number;
|
|
46
|
+
endTime?: number;
|
|
47
|
+
cacheStatus?: 'MISS' | 'HIT' | 'STALE' | 'PUT';
|
|
48
|
+
waitUntil?: WaitUntil;
|
|
49
|
+
graphql?: string | null;
|
|
50
|
+
stackInfo?: {
|
|
51
|
+
file?: string;
|
|
52
|
+
func?: string;
|
|
53
|
+
line?: number;
|
|
54
|
+
column?: number;
|
|
55
|
+
};
|
|
56
|
+
responsePayload?: any;
|
|
57
|
+
responseInit?: Omit<ResponseInit, 'headers'> & {
|
|
58
|
+
headers?: [string, string][];
|
|
59
|
+
};
|
|
60
|
+
cache?: {
|
|
61
|
+
status?: string;
|
|
62
|
+
strategy?: string;
|
|
63
|
+
key?: string | readonly unknown[];
|
|
64
|
+
};
|
|
65
|
+
displayName?: string;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
type WaitUntil = (promise: Promise<unknown>) => void;
|
|
69
|
+
|
|
70
|
+
type StorefrontHeaders = {
|
|
71
|
+
/** A unique ID that correlates all sub-requests together. */
|
|
72
|
+
requestGroupId: string | null;
|
|
73
|
+
/** The IP address of the client. */
|
|
74
|
+
buyerIp: string | null;
|
|
75
|
+
/** The signature of the client's IP address for verification. */
|
|
76
|
+
buyerIpSig: string | null;
|
|
77
|
+
/** The cookie header from the client */
|
|
78
|
+
cookie: string | null;
|
|
79
|
+
/** The sec-purpose or purpose header value */
|
|
80
|
+
purpose: string | null;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
declare global {
|
|
84
|
+
interface Window {
|
|
85
|
+
privacyBanner: PrivacyBanner;
|
|
86
|
+
Shopify: {
|
|
87
|
+
customerPrivacy: CustomerPrivacy;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
interface Document {
|
|
91
|
+
addEventListener<K extends keyof CustomEventMap>(
|
|
92
|
+
type: K,
|
|
93
|
+
listener: (this: Document, ev: CustomEventMap[K]) => void,
|
|
94
|
+
): void;
|
|
95
|
+
removeEventListener<K extends keyof CustomEventMap>(
|
|
96
|
+
type: K,
|
|
97
|
+
listener: (this: Document, ev: CustomEventMap[K]) => void,
|
|
98
|
+
): void;
|
|
99
|
+
dispatchEvent<K extends keyof CustomEventMap>(ev: CustomEventMap[K]): void;
|
|
100
|
+
}
|
|
101
|
+
var __H2O_LOG_EVENT: undefined | ((event: RequestEventPayload) => void);
|
|
102
|
+
var __remix_devServerHooks:
|
|
103
|
+
| undefined
|
|
104
|
+
| {getCriticalCss: (...args: unknown[]) => any};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
type CrossRuntimeRequest = {
|
|
108
|
+
url?: string;
|
|
109
|
+
method?: string;
|
|
110
|
+
headers: {
|
|
111
|
+
get?: (key: string) => string | null | undefined;
|
|
112
|
+
[key: string]: any;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Extracts relevant Storefront headers from the given Oxygen request.
|
|
117
|
+
*/
|
|
118
|
+
declare function getStorefrontHeaders(request: CrossRuntimeRequest): StorefrontHeaders;
|
|
119
|
+
|
|
120
|
+
export { type StorefrontHeaders, createRequestHandler, getStorefrontHeaders };
|
package/dist/oxygen/index.js
CHANGED
|
@@ -1,9 +1,115 @@
|
|
|
1
|
+
// src/createRequestHandler.ts
|
|
1
2
|
import {
|
|
2
|
-
createRequestHandler
|
|
3
|
-
} from "
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "
|
|
3
|
+
createRequestHandler as createReactRouterRequestHandler
|
|
4
|
+
} from "react-router";
|
|
5
|
+
|
|
6
|
+
// src/context-keys.ts
|
|
7
|
+
import { createContext } from "react-router";
|
|
8
|
+
var storefrontContext = createContext();
|
|
9
|
+
var cartContext = createContext();
|
|
10
|
+
var customerAccountContext = createContext();
|
|
11
|
+
var envContext = createContext();
|
|
12
|
+
var sessionContext = createContext();
|
|
13
|
+
var waitUntilContext = createContext();
|
|
14
|
+
|
|
15
|
+
// src/constants.ts
|
|
16
|
+
var SHOPIFY_CLIENT_IP_SIG_HEADER = "X-Shopify-Client-IP-Sig";
|
|
17
|
+
var HYDROGEN_SFAPI_PROXY_KEY = "_sfapi_proxy";
|
|
18
|
+
|
|
19
|
+
// src/utils/server-timing.ts
|
|
20
|
+
function buildServerTimingHeader(values) {
|
|
21
|
+
return Object.entries(values).map(([key, value]) => value ? `${key};desc=${value}` : void 0).filter(Boolean).join(", ");
|
|
22
|
+
}
|
|
23
|
+
function appendServerTimingHeader(response, values) {
|
|
24
|
+
const header = typeof values === "string" ? values : buildServerTimingHeader(values);
|
|
25
|
+
if (header) {
|
|
26
|
+
response.headers.append("Server-Timing", header);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// src/utils/warning.ts
|
|
31
|
+
var warnings = /* @__PURE__ */ new Set();
|
|
32
|
+
var warnOnce = (string) => {
|
|
33
|
+
if (!warnings.has(string)) {
|
|
34
|
+
console.warn(string);
|
|
35
|
+
warnings.add(string);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/createRequestHandler.ts
|
|
40
|
+
function createRequestHandler({
|
|
41
|
+
build,
|
|
42
|
+
mode,
|
|
43
|
+
poweredByHeader = true,
|
|
44
|
+
getLoadContext,
|
|
45
|
+
collectTrackingInformation = true,
|
|
46
|
+
proxyStandardRoutes = true
|
|
47
|
+
}) {
|
|
48
|
+
const handleRequest = createReactRouterRequestHandler(build, mode);
|
|
49
|
+
const appendPoweredByHeader = poweredByHeader ? (response) => response.headers.append("powered-by", "Shopify, Hydrogen") : void 0;
|
|
50
|
+
return async (request) => {
|
|
51
|
+
const method = request.method;
|
|
52
|
+
if ((method === "GET" || method === "HEAD") && request.body) {
|
|
53
|
+
return new Response(`${method} requests cannot have a body`, {
|
|
54
|
+
status: 400
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const url = new URL(request.url);
|
|
58
|
+
if (url.pathname.includes("//")) {
|
|
59
|
+
return new Response(null, {
|
|
60
|
+
status: 301,
|
|
61
|
+
headers: {
|
|
62
|
+
location: url.pathname.replace(/\/+/g, "/")
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const context = await getLoadContext?.(request);
|
|
67
|
+
const storefront = context?.storefront || context?.get?.(storefrontContext);
|
|
68
|
+
if (proxyStandardRoutes) {
|
|
69
|
+
if (!storefront) {
|
|
70
|
+
warnOnce(
|
|
71
|
+
"[h2:createRequestHandler] Storefront instance is required to proxy standard routes."
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
if (storefront?.isStorefrontApiUrl(request)) {
|
|
75
|
+
const response2 = await storefront.forward(request);
|
|
76
|
+
appendPoweredByHeader?.(response2);
|
|
77
|
+
return response2;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const response = await handleRequest(request, context);
|
|
81
|
+
if (storefront && proxyStandardRoutes) {
|
|
82
|
+
if (collectTrackingInformation) {
|
|
83
|
+
storefront.setCollectedSubrequestHeaders(response);
|
|
84
|
+
}
|
|
85
|
+
const fetchDest = request.headers.get("sec-fetch-dest");
|
|
86
|
+
if (fetchDest && fetchDest === "document" || request.headers.get("accept")?.includes("text/html")) {
|
|
87
|
+
appendServerTimingHeader(response, { [HYDROGEN_SFAPI_PROXY_KEY]: "1" });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
appendPoweredByHeader?.(response);
|
|
91
|
+
return response;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// src/utils/request.ts
|
|
96
|
+
function getHeader(request, key) {
|
|
97
|
+
return getHeaderValue(request.headers, key);
|
|
98
|
+
}
|
|
99
|
+
function getHeaderValue(headers, key) {
|
|
100
|
+
const value = headers?.get?.(key) ?? headers?.[key];
|
|
101
|
+
return typeof value === "string" ? value : null;
|
|
102
|
+
}
|
|
103
|
+
function getStorefrontHeaders(request) {
|
|
104
|
+
return {
|
|
105
|
+
requestGroupId: getHeader(request, "request-id"),
|
|
106
|
+
buyerIp: getHeader(request, "oxygen-buyer-ip"),
|
|
107
|
+
buyerIpSig: getHeader(request, SHOPIFY_CLIENT_IP_SIG_HEADER),
|
|
108
|
+
cookie: getHeader(request, "cookie"),
|
|
109
|
+
// sec-purpose is added by browsers automatically when using link/prefetch or Speculation Rules
|
|
110
|
+
purpose: getHeader(request, "sec-purpose") || getHeader(request, "purpose")
|
|
111
|
+
};
|
|
112
|
+
}
|
|
7
113
|
export {
|
|
8
114
|
createRequestHandler,
|
|
9
115
|
getStorefrontHeaders
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var t="vite/virtual-routes/routes",r=["vite","virtual-routes","routes"],u=["vite","virtual-routes"];function e(o,i){let s=new URL("../",import.meta.url),n=o.reduce((l,a)=>new URL(`${a}/`,l),s);return new URL(i,n).pathname.replace(/^\/[a-zA-Z]:\//,"/")}async function p(){return {routes:[{id:`${t}/graphiql`,path:"graphiql",file:e(r,"graphiql.jsx"),index:false},{id:`${t}/subrequest-profiler`,path:"subrequest-profiler",file:e(r,"subrequest-profiler.jsx"),index:false},{id:`${t}/[.]well-known.appspecific.com[.]chrome[.]devtools[.]json`,path:".well-known/appspecific/com.chrome.devtools.json",file:e(r,"[.]well-known.appspecific.com[.]chrome[.]devtools[.]json.jsx"),index:false},{id:`${t}/index`,path:"",file:e(r,"index.jsx"),index:true}],layout:{file:e(u,"layout.jsx")}}}
|
|
2
|
+
export{t as VIRTUAL_ROUTES_DIR,u as VIRTUAL_ROUTES_DIR_PARTS,r as VIRTUAL_ROUTES_ROUTES_DIR_PARTS,p as getVirtualRoutesV3};//# sourceMappingURL=get-virtual-routes-MYYLGSAS.js.map
|
|
3
|
+
//# sourceMappingURL=get-virtual-routes-MYYLGSAS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/vite/get-virtual-routes.ts"],"names":["VIRTUAL_ROUTES_DIR","VIRTUAL_ROUTES_ROUTES_DIR_PARTS","VIRTUAL_ROUTES_DIR_PARTS","getVirtualRoutesPath","pathParts","forFile","basePath","virtualRoutesPath","working","dirPart","getVirtualRoutesV3"],"mappings":"AACO,IAAMA,CAAAA,CAAqB,4BAAA,CACrBC,CAAAA,CAAkC,CAC7C,MAAA,CACA,gBAAA,CACA,QACF,CAAA,CACaC,CAAAA,CAA2B,CAAC,MAAA,CAAQ,gBAAgB,EAEjE,SAASC,CAAAA,CACPC,CAAAA,CACAC,CAAAA,CACQ,CACR,IAAMC,CAAAA,CAAW,IAAI,GAAA,CAAI,KAAA,CAAO,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA,CACzCC,CAAAA,CAAoBH,CAAAA,CAAU,OAAO,CAACI,CAAAA,CAASC,CAAAA,GAC5C,IAAI,GAAA,CAAI,CAAA,EAAGA,CAAO,CAAA,CAAA,CAAA,CAAKD,CAAO,CAAA,CACpCF,CAAQ,CAAA,CAGX,OAAO,IAAI,GAAA,CAAID,CAAAA,CAASE,CAAiB,CAAA,CAAE,QAAA,CAAS,OAAA,CAClD,gBAAA,CACA,GACF,CACF,CAEA,eAAsBG,CAAAA,EAAqB,CACzC,OAAO,CACL,MAAA,CAAQ,CACN,CACE,GAAI,CAAA,EAAGV,CAAkB,CAAA,SAAA,CAAA,CACzB,IAAA,CAAM,UAAA,CACN,IAAA,CAAMG,CAAAA,CACJF,CAAAA,CACA,cACF,CAAA,CACA,KAAA,CAAO,KACT,CAAA,CACA,CACE,EAAA,CAAI,CAAA,EAAGD,CAAkB,CAAA,oBAAA,CAAA,CACzB,IAAA,CAAM,qBAAA,CACN,IAAA,CAAMG,CAAAA,CACJF,CAAAA,CACA,yBACF,CAAA,CACA,KAAA,CAAO,KACT,CAAA,CACA,CACE,EAAA,CAAI,CAAA,EAAGD,CAAkB,4DACzB,IAAA,CAAM,kDAAA,CACN,IAAA,CAAMG,CAAAA,CACJF,CAAAA,CACA,8DACF,CAAA,CACA,KAAA,CAAO,KACT,CAAA,CACA,CACE,EAAA,CAAI,CAAA,EAAGD,CAAkB,CAAA,MAAA,CAAA,CACzB,IAAA,CAAM,GACN,IAAA,CAAMG,CAAAA,CACJF,CAAAA,CACA,WACF,CAAA,CACA,KAAA,CAAO,IACT,CACF,CAAA,CACA,MAAA,CAAQ,CACN,IAAA,CAAME,CAAAA,CAAqBD,CAAAA,CAA0B,YAAY,CACnE,CACF,CACF","file":"get-virtual-routes-MYYLGSAS.js","sourcesContent":["// v3_routeConfig virtual routes constants\nexport const VIRTUAL_ROUTES_DIR = 'vite/virtual-routes/routes';\nexport const VIRTUAL_ROUTES_ROUTES_DIR_PARTS = [\n 'vite',\n 'virtual-routes',\n 'routes',\n];\nexport const VIRTUAL_ROUTES_DIR_PARTS = ['vite', 'virtual-routes'];\n\nfunction getVirtualRoutesPath(\n pathParts: Array<string>,\n forFile: string,\n): string {\n const basePath = new URL('../', import.meta.url);\n const virtualRoutesPath = pathParts.reduce((working, dirPart) => {\n return new URL(`${dirPart}/`, working);\n }, basePath);\n\n // Getting rid of the drive path (ie. '/C:/') in windows\n return new URL(forFile, virtualRoutesPath).pathname.replace(\n /^\\/[a-zA-Z]:\\//,\n '/',\n );\n}\n\nexport async function getVirtualRoutesV3() {\n return {\n routes: [\n {\n id: `${VIRTUAL_ROUTES_DIR}/graphiql`,\n path: 'graphiql',\n file: getVirtualRoutesPath(\n VIRTUAL_ROUTES_ROUTES_DIR_PARTS,\n 'graphiql.jsx',\n ),\n index: false,\n },\n {\n id: `${VIRTUAL_ROUTES_DIR}/subrequest-profiler`,\n path: 'subrequest-profiler',\n file: getVirtualRoutesPath(\n VIRTUAL_ROUTES_ROUTES_DIR_PARTS,\n 'subrequest-profiler.jsx',\n ),\n index: false,\n },\n {\n id: `${VIRTUAL_ROUTES_DIR}/[.]well-known.appspecific.com[.]chrome[.]devtools[.]json`,\n path: '.well-known/appspecific/com.chrome.devtools.json',\n file: getVirtualRoutesPath(\n VIRTUAL_ROUTES_ROUTES_DIR_PARTS,\n '[.]well-known.appspecific.com[.]chrome[.]devtools[.]json.jsx',\n ),\n index: false,\n },\n {\n id: `${VIRTUAL_ROUTES_DIR}/index`,\n path: '',\n file: getVirtualRoutesPath(\n VIRTUAL_ROUTES_ROUTES_DIR_PARTS,\n 'index.jsx',\n ),\n index: true,\n },\n ],\n layout: {\n file: getVirtualRoutesPath(VIRTUAL_ROUTES_DIR_PARTS, 'layout.jsx'),\n },\n };\n}\n"]}
|