@shopify/remix-oxygen 3.0.2 → 3.0.3
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 +12 -3
- package/dist/development/index.cjs +1 -1
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +1 -1
- package/dist/development/index.js.map +1 -1
- package/dist/production/index.cjs +2 -2
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.d.cts +2 -0
- package/dist/production/index.d.ts +2 -0
- package/dist/production/index.js +2 -2
- package/dist/production/index.js.map +1 -1
- package/package.json +11 -9
package/README.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
# @shopify/remix-oxygen
|
|
1
|
+
# @shopify/remix-oxygen (Deprecated)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **This package is deprecated.** All types and utilities it re-exports are available directly from [`react-router`](https://reactrouter.com). For `createRequestHandler`, use [`@shopify/hydrogen`](https://shopify.dev/docs/storefronts/headless/hydrogen). For `getStorefrontHeaders`, use `@shopify/hydrogen/oxygen`.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Migration
|
|
6
|
+
|
|
7
|
+
Replace imports from `@shopify/remix-oxygen` as follows:
|
|
8
|
+
|
|
9
|
+
| Before | After |
|
|
10
|
+
| --------------------------------------------------------------- | --------------------------------------------------------------- |
|
|
11
|
+
| `import type {LoaderFunctionArgs} from '@shopify/remix-oxygen'` | `import type {LoaderFunctionArgs} from 'react-router'` |
|
|
12
|
+
| `import {redirect} from '@shopify/remix-oxygen'` | `import {redirect} from 'react-router'` |
|
|
13
|
+
| `import {createRequestHandler} from '@shopify/remix-oxygen'` | `import {createRequestHandler} from '@shopify/hydrogen'` |
|
|
14
|
+
| `import {getStorefrontHeaders} from '@shopify/remix-oxygen'` | `import {getStorefrontHeaders} from '@shopify/hydrogen/oxygen'` |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/event-logger.ts","../../src/server.ts"],"names":["createReactRouterRequestHandler"],"mappings":";;;;;;;AAEA,IAAI,SAAA,GAAY,KAAA;AAKT,SAAS,kBAAkB,cAAA,EAAyC;AACzE,EAAA,MAAM,OAAA,GAAW,kBAAkB,EAAC;AAKpC,EAAA,MAAM,kBAAA,GAAqB,SAAS,GAAA,EAAK,aAAA;AAIzC,EAAA,IAAI,OAAO,kBAAA,EAAoB,KAAA,KAAU,UAAA,EAAY;AAErD,EAAA,OAAO,CAAC;AAAA,IACN,GAAA;AAAA,IACA,OAAA,GAAU,KAAK,GAAA,EAAI;AAAA,IACnB,YAAY,OAAA,EAAS,SAAA;AAAA,IACrB,GAAG;AAAA,GACL,KAAgB;AACd,IAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,OAAA,EAAQ,CAAE,IAAA;AAAA,MAAK,MACrC,kBAAA,CACG,KAAA;AAAA,QACC,IAAI,QAAQ,GAAA,EAAK;AAAA,UACf,MAAA,EAAQ,MAAA;AAAA,UACR,IAAA,EAAM,KAAK,SAAA,CAAU;AAAA,YACnB,OAAA;AAAA,YACA,GAAG;AAAA,WACJ;AAAA,SACF;AAAA,OACH,CACC,KAAA,CAAM,CAAC,KAAA,KAAiB;AACvB,QAAA,IAAI,CAAC,SAAA,EAAW;AAGd,UAAA,OAAA,CAAQ,KAAA,CAAM,2BAAA,EAA6B,KAAA,CAAM,KAAK,CAAA;AACtD,UAAA,SAAA,GAAY,IAAA;AAAA,QACd;AAAA,MACF,CAAC;AAAA,KACL;AAEA,IAAA,OAAA,IAAW,YAAY,OAAO,CAAA;AAAA,EAChC,CAAA;AACF;;;ACxCA,IAAM,qBAAA,GAAwB,MAAM,SAAA,CAAU,QAAA;AAC9C,KAAA,CAAM,SAAA,CAAU,WAAW,WAAY;AACrC,EAAA,OAAO,IAAA,CAAK,KAAA,IAAS,qBAAA,CAAsB,IAAA,CAAK,IAAI,CAAA;AACtD,CAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/event-logger.ts","../../src/server.ts"],"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AAEA,IAA4C;AAC1C,MAAA,UAAA,CAAW,eAAA,GAAkB;AAAA,QAC3B,SAAA,EAAW,SAAA;AAAA,QACX,KAAK,OAAA,CAAQ,GAAA;AAAA,QACb,SAAA,EAAW,OAAA,CAAQ,OAAA,CAAQ,GAAA,CAAI,YAAY,CAAA;AAAA,QAC3C,OAAA,EAAS,OAAA,CAAQ,OAAA,CAAQ,GAAA,CAAI,SAAS,CAAA;AAAA,QACtC,SAAA;AAAA,QACA,YAAA,EAAc;AAAA,UACZ,QAAQ,QAAA,CAAS,MAAA;AAAA,UACjB,YAAY,QAAA,CAAS,UAAA;AAAA,UACrB,SAAS,KAAA,CAAM,IAAA,CAAK,QAAA,CAAS,OAAA,CAAQ,SAAS;AAAA;AAChD,OACD,CAAA;AAAA,IACH;AAEA,IAAA,OAAO,QAAA;AAAA,EACT,CAAA;AACF;AAUO,SAAS,qBAAqB,OAAA,EAAqC;AACxE,EAAA,MAAM,UAAU,OAAA,CAAQ,OAAA;AACxB,EAAA,OAAO;AAAA,IACL,cAAA,EAAgB,OAAA,CAAQ,GAAA,CAAI,YAAY,CAAA;AAAA,IACxC,OAAA,EAAS,OAAA,CAAQ,GAAA,CAAI,iBAAiB,CAAA;AAAA,IACtC,MAAA,EAAQ,OAAA,CAAQ,GAAA,CAAI,QAAQ,CAAA;AAAA,IAC5B,OAAA,EAAS,OAAA,CAAQ,GAAA,CAAI,SAAS;AAAA,GAChC;AACF","file":"index.cjs","sourcesContent":["type H2OEvent = Parameters<NonNullable<typeof __H2O_LOG_EVENT>>[0];\n\nlet hasWarned = false;\n\n/**\n * @deprecated Only used with the classic Remix compiler\n */\nexport function createEventLogger(appLoadContext: Record<string, unknown>) {\n const context = (appLoadContext || {}) as {\n env?: Record<string, any>;\n waitUntil?: (promise: Promise<any>) => void;\n };\n\n const eventLoggerService = context?.env?.H2O_LOG_EVENT as\n | undefined\n | {fetch: (req: Request) => Promise<Response>};\n\n if (typeof eventLoggerService?.fetch !== 'function') return;\n\n return ({\n url,\n endTime = Date.now(),\n waitUntil = context?.waitUntil,\n ...rest\n }: H2OEvent) => {\n const promise = Promise.resolve().then(() =>\n eventLoggerService\n .fetch(\n new Request(url, {\n method: 'POST',\n body: JSON.stringify({\n endTime,\n ...rest,\n }),\n }),\n )\n .catch((error: Error) => {\n if (!hasWarned) {\n // This might repeat a lot of times due to\n // the same issue, so we only warn once.\n console.debug('Failed to log H2O event\\n', error.stack);\n hasWarned = true;\n }\n }),\n );\n\n promise && waitUntil?.(promise);\n };\n}\n","/// <reference types=\"@shopify/hydrogen\" />\nimport {\n createRequestHandler as createReactRouterRequestHandler,\n type AppLoadContext,\n type ServerBuild,\n} from 'react-router';\nimport {createEventLogger} from './event-logger';\n\nconst originalErrorToString = Error.prototype.toString;\nError.prototype.toString = function () {\n return this.stack || originalErrorToString.call(this);\n};\n\n/** @deprecated Use `createRequestHandler` from `@shopify/hydrogen/oxygen` instead. */\nexport function createRequestHandler<Context = unknown>({\n build,\n mode,\n poweredByHeader = true,\n getLoadContext,\n}: {\n build: ServerBuild;\n mode?: string;\n poweredByHeader?: boolean;\n getLoadContext?: (request: Request) => Promise<Context> | Context;\n}) {\n const handleRequest = createReactRouterRequestHandler(build, mode);\n\n return async (request: Request) => {\n const method = request.method;\n\n if ((method === 'GET' || method === 'HEAD') && request.body) {\n return new Response(`${method} requests cannot have a body`, {\n status: 400,\n });\n }\n\n const url = new URL(request.url);\n\n if (url.pathname.includes('//')) {\n return new Response(null, {\n status: 301,\n headers: {\n location: url.pathname.replace(/\\/+/g, '/') + url.search,\n },\n });\n }\n\n const context = getLoadContext\n ? ((await getLoadContext(request)) as AppLoadContext)\n : undefined;\n\n if (process.env.NODE_ENV === 'development' && context) {\n // Store logger in globalThis so it can be accessed from the worker.\n // The global property must be different from the binding name,\n // otherwise Miniflare throws an error when accessing it.\n globalThis.__H2O_LOG_EVENT ??= createEventLogger(context);\n }\n\n const startTime = Date.now();\n\n const response = await handleRequest(request, context);\n\n if (poweredByHeader) {\n response.headers.append('powered-by', 'Shopify, Hydrogen');\n }\n\n if (process.env.NODE_ENV === 'development') {\n globalThis.__H2O_LOG_EVENT?.({\n eventType: 'request',\n url: request.url,\n requestId: request.headers.get('request-id'),\n purpose: request.headers.get('purpose'),\n startTime,\n responseInit: {\n status: response.status,\n statusText: response.statusText,\n headers: Array.from(response.headers.entries()),\n } satisfies ResponseInit,\n });\n }\n\n return response;\n };\n}\n\ntype StorefrontHeaders = {\n requestGroupId: string | null;\n buyerIp: string | null;\n cookie: string | null;\n purpose: string | null;\n};\n\n/** @deprecated Use `getStorefrontHeaders` from `@shopify/hydrogen/oxygen` instead. */\nexport function getStorefrontHeaders(request: Request): StorefrontHeaders {\n const headers = request.headers;\n return {\n requestGroupId: headers.get('request-id'),\n buyerIp: headers.get('oxygen-buyer-ip'),\n cookie: headers.get('cookie'),\n purpose: headers.get('purpose'),\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/event-logger.ts","../../src/server.ts"],"names":["createReactRouterRequestHandler"],"mappings":";;;;;;AAEA,IAAI,SAAA,GAAY,KAAA;AAKT,SAAS,kBAAkB,cAAA,EAAyC;AACzE,EAAA,MAAM,OAAA,GAAW,kBAAkB,EAAC;AAKpC,EAAA,MAAM,kBAAA,GAAqB,SAAS,GAAA,EAAK,aAAA;AAIzC,EAAA,IAAI,OAAO,kBAAA,EAAoB,KAAA,KAAU,UAAA,EAAY;AAErD,EAAA,OAAO,CAAC;AAAA,IACN,GAAA;AAAA,IACA,OAAA,GAAU,KAAK,GAAA,EAAI;AAAA,IACnB,YAAY,OAAA,EAAS,SAAA;AAAA,IACrB,GAAG;AAAA,GACL,KAAgB;AACd,IAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,OAAA,EAAQ,CAAE,IAAA;AAAA,MAAK,MACrC,kBAAA,CACG,KAAA;AAAA,QACC,IAAI,QAAQ,GAAA,EAAK;AAAA,UACf,MAAA,EAAQ,MAAA;AAAA,UACR,I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A;AACxB,EAAA,OAAO;AAAA,IACL,cAAA,EAAgB,OAAA,CAAQ,GAAA,CAAI,YAAY,CAAA;AAAA,IACxC,OAAA,EAAS,OAAA,CAAQ,GAAA,CAAI,iBAAiB,CAAA;AAAA,IACtC,MAAA,EAAQ,OAAA,CAAQ,GAAA,CAAI,QAAQ,CAAA;AAAA,IAC5B,OAAA,EAAS,OAAA,CAAQ,GAAA,CAAI,SAAS;AAAA,GAChC;AACF","file":"index.js","sourcesContent":["type H2OEvent = Parameters<NonNullable<typeof __H2O_LOG_EVENT>>[0];\n\nlet hasWarned = false;\n\n/**\n * @deprecated Only used with the classic Remix compiler\n */\nexport function createEventLogger(appLoadContext: Record<string, unknown>) {\n const context = (appLoadContext || {}) as {\n env?: Record<string, any>;\n waitUntil?: (promise: Promise<any>) => void;\n };\n\n const eventLoggerService = context?.env?.H2O_LOG_EVENT as\n | undefined\n | {fetch: (req: Request) => Promise<Response>};\n\n if (typeof eventLoggerService?.fetch !== 'function') return;\n\n return ({\n url,\n endTime = Date.now(),\n waitUntil = context?.waitUntil,\n ...rest\n }: H2OEvent) => {\n const promise = Promise.resolve().then(() =>\n eventLoggerService\n .fetch(\n new Request(url, {\n method: 'POST',\n body: JSON.stringify({\n endTime,\n ...rest,\n }),\n }),\n )\n .catch((error: Error) => {\n if (!hasWarned) {\n // This might repeat a lot of times due to\n // the same issue, so we only warn once.\n console.debug('Failed to log H2O event\\n', error.stack);\n hasWarned = true;\n }\n }),\n );\n\n promise && waitUntil?.(promise);\n };\n}\n","/// <reference types=\"@shopify/hydrogen\" />\nimport {\n createRequestHandler as createReactRouterRequestHandler,\n type AppLoadContext,\n type ServerBuild,\n} from 'react-router';\nimport {createEventLogger} from './event-logger';\n\nconst originalErrorToString = Error.prototype.toString;\nError.prototype.toString = function () {\n return this.stack || originalErrorToString.call(this);\n};\n\n/** @deprecated Use `createRequestHandler` from `@shopify/hydrogen/oxygen` instead. */\nexport function createRequestHandler<Context = unknown>({\n build,\n mode,\n poweredByHeader = true,\n getLoadContext,\n}: {\n build: ServerBuild;\n mode?: string;\n poweredByHeader?: boolean;\n getLoadContext?: (request: Request) => Promise<Context> | Context;\n}) {\n const handleRequest = createReactRouterRequestHandler(build, mode);\n\n return async (request: Request) => {\n const method = request.method;\n\n if ((method === 'GET' || method === 'HEAD') && request.body) {\n return new Response(`${method} requests cannot have a body`, {\n status: 400,\n });\n }\n\n const url = new URL(request.url);\n\n if (url.pathname.includes('//')) {\n return new Response(null, {\n status: 301,\n headers: {\n location: url.pathname.replace(/\\/+/g, '/') + url.search,\n },\n });\n }\n\n const context = getLoadContext\n ? ((await getLoadContext(request)) as AppLoadContext)\n : undefined;\n\n if (process.env.NODE_ENV === 'development' && context) {\n // Store logger in globalThis so it can be accessed from the worker.\n // The global property must be different from the binding name,\n // otherwise Miniflare throws an error when accessing it.\n globalThis.__H2O_LOG_EVENT ??= createEventLogger(context);\n }\n\n const startTime = Date.now();\n\n const response = await handleRequest(request, context);\n\n if (poweredByHeader) {\n response.headers.append('powered-by', 'Shopify, Hydrogen');\n }\n\n if (process.env.NODE_ENV === 'development') {\n globalThis.__H2O_LOG_EVENT?.({\n eventType: 'request',\n url: request.url,\n requestId: request.headers.get('request-id'),\n purpose: request.headers.get('purpose'),\n startTime,\n responseInit: {\n status: response.status,\n statusText: response.statusText,\n headers: Array.from(response.headers.entries()),\n } satisfies ResponseInit,\n });\n }\n\n return response;\n };\n}\n\ntype StorefrontHeaders = {\n requestGroupId: string | null;\n buyerIp: string | null;\n cookie: string | null;\n purpose: string | null;\n};\n\n/** @deprecated Use `getStorefrontHeaders` from `@shopify/hydrogen/oxygen` instead. */\nexport function getStorefrontHeaders(request: Request): StorefrontHeaders {\n const headers = request.headers;\n return {\n requestGroupId: headers.get('request-id'),\n buyerIp: headers.get('oxygen-buyer-ip'),\n cookie: headers.get('cookie'),\n purpose: headers.get('purpose'),\n };\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';var reactRouter=require('react-router');var
|
|
2
|
-
Object.defineProperty(exports,"createCookie",{enumerable:true,get:function(){return reactRouter.createCookie}});Object.defineProperty(exports,"createCookieSessionStorage",{enumerable:true,get:function(){return reactRouter.createCookieSessionStorage}});Object.defineProperty(exports,"createMemorySessionStorage",{enumerable:true,get:function(){return reactRouter.createMemorySessionStorage}});Object.defineProperty(exports,"createSession",{enumerable:true,get:function(){return reactRouter.createSession}});Object.defineProperty(exports,"createSessionStorage",{enumerable:true,get:function(){return reactRouter.createSessionStorage}});Object.defineProperty(exports,"data",{enumerable:true,get:function(){return reactRouter.data}});Object.defineProperty(exports,"isCookie",{enumerable:true,get:function(){return reactRouter.isCookie}});Object.defineProperty(exports,"isSession",{enumerable:true,get:function(){return reactRouter.isSession}});Object.defineProperty(exports,"redirect",{enumerable:true,get:function(){return reactRouter.redirect}});Object.defineProperty(exports,"redirectDocument",{enumerable:true,get:function(){return reactRouter.redirectDocument}});exports.createRequestHandler=
|
|
1
|
+
'use strict';var reactRouter=require('react-router');var m=Error.prototype.toString;Error.prototype.toString=function(){return this.stack||m.call(this)};function f({build:t,mode:e,poweredByHeader:a=true,getLoadContext:p}){let u=reactRouter.createRequestHandler(t,e);return async r=>{let o=r.method;if((o==="GET"||o==="HEAD")&&r.body)return new Response(`${o} requests cannot have a body`,{status:400});let n=new URL(r.url);if(n.pathname.includes("//"))return new Response(null,{status:301,headers:{location:n.pathname.replace(/\/+/g,"/")+n.search}});let i=p?await p(r):void 0,s=await u(r,i);return a&&s.headers.append("powered-by","Shopify, Hydrogen"),s}}function x(t){let e=t.headers;return {requestGroupId:e.get("request-id"),buyerIp:e.get("oxygen-buyer-ip"),cookie:e.get("cookie"),purpose:e.get("purpose")}}
|
|
2
|
+
Object.defineProperty(exports,"createCookie",{enumerable:true,get:function(){return reactRouter.createCookie}});Object.defineProperty(exports,"createCookieSessionStorage",{enumerable:true,get:function(){return reactRouter.createCookieSessionStorage}});Object.defineProperty(exports,"createMemorySessionStorage",{enumerable:true,get:function(){return reactRouter.createMemorySessionStorage}});Object.defineProperty(exports,"createSession",{enumerable:true,get:function(){return reactRouter.createSession}});Object.defineProperty(exports,"createSessionStorage",{enumerable:true,get:function(){return reactRouter.createSessionStorage}});Object.defineProperty(exports,"data",{enumerable:true,get:function(){return reactRouter.data}});Object.defineProperty(exports,"isCookie",{enumerable:true,get:function(){return reactRouter.isCookie}});Object.defineProperty(exports,"isSession",{enumerable:true,get:function(){return reactRouter.isSession}});Object.defineProperty(exports,"redirect",{enumerable:true,get:function(){return reactRouter.redirect}});Object.defineProperty(exports,"redirectDocument",{enumerable:true,get:function(){return reactRouter.redirectDocument}});exports.createRequestHandler=f;exports.getStorefrontHeaders=x;//# sourceMappingURL=index.cjs.map
|
|
3
3
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/server.ts"],"names":["originalErrorToString","createRequestHandler","build","mode","poweredByHeader","getLoadContext","handleRequest","createReactRouterRequestHandler","request","method","url","context","response","getStorefrontHeaders","headers"],"mappings":"qDAQA,IAAMA,
|
|
1
|
+
{"version":3,"sources":["../../src/server.ts"],"names":["originalErrorToString","createRequestHandler","build","mode","poweredByHeader","getLoadContext","handleRequest","createReactRouterRequestHandler","request","method","url","context","response","getStorefrontHeaders","headers"],"mappings":"qDAQA,IAAMA,EAAwB,KAAA,CAAM,SAAA,CAAU,SAC9C,KAAA,CAAM,SAAA,CAAU,SAAW,UAAY,CACrC,OAAO,IAAA,CAAK,KAAA,EAASA,EAAsB,IAAA,CAAK,IAAI,CACtD,CAAA,CAGO,SAASC,CAAAA,CAAwC,CACtD,KAAA,CAAAC,CAAAA,CACA,KAAAC,CAAAA,CACA,eAAA,CAAAC,EAAkB,IAAA,CAClB,cAAA,CAAAC,CACF,CAAA,CAKG,CACD,IAAMC,EAAgBC,gCAAAA,CAAgCL,CAAAA,CAAOC,CAAI,CAAA,CAEjE,aAAcK,CAAAA,EAAqB,CACjC,IAAMC,CAAAA,CAASD,CAAAA,CAAQ,MAAA,CAEvB,IAAKC,CAAAA,GAAW,KAAA,EAASA,IAAW,MAAA,GAAWD,CAAAA,CAAQ,KACrD,OAAO,IAAI,SAAS,CAAA,EAAGC,CAAM,+BAAgC,CAC3D,MAAA,CAAQ,GACV,CAAC,CAAA,CAGH,IAAMC,CAAAA,CAAM,IAAI,GAAA,CAAIF,CAAAA,CAAQ,GAAG,CAAA,CAE/B,GAAIE,CAAAA,CAAI,QAAA,CAAS,SAAS,IAAI,CAAA,CAC5B,OAAO,IAAI,QAAA,CAAS,IAAA,CAAM,CACxB,MAAA,CAAQ,GAAA,CACR,QAAS,CACP,QAAA,CAAUA,EAAI,QAAA,CAAS,OAAA,CAAQ,OAAQ,GAAG,CAAA,CAAIA,CAAAA,CAAI,MACpD,CACF,CAAC,EAGH,IAAMC,CAAAA,CAAUN,EACV,MAAMA,CAAAA,CAAeG,CAAO,CAAA,CAC9B,MAAA,CAWEI,CAAAA,CAAW,MAAMN,EAAcE,CAAAA,CAASG,CAAO,EAErD,OAAIP,CAAAA,EACFQ,CAAAA,CAAS,OAAA,CAAQ,MAAA,CAAO,YAAA,CAAc,mBAAmB,CAAA,CAkBpDA,CACT,CACF,CAUO,SAASC,EAAqBL,CAAAA,CAAqC,CACxE,IAAMM,CAAAA,CAAUN,CAAAA,CAAQ,OAAA,CACxB,OAAO,CACL,cAAA,CAAgBM,EAAQ,GAAA,CAAI,YAAY,EACxC,OAAA,CAASA,CAAAA,CAAQ,GAAA,CAAI,iBAAiB,CAAA,CACtC,MAAA,CAAQA,EAAQ,GAAA,CAAI,QAAQ,EAC5B,OAAA,CAASA,CAAAA,CAAQ,IAAI,SAAS,CAChC,CACF","file":"index.cjs","sourcesContent":["/// <reference types=\"@shopify/hydrogen\" />\nimport {\n createRequestHandler as createReactRouterRequestHandler,\n type AppLoadContext,\n type ServerBuild,\n} from 'react-router';\nimport {createEventLogger} from './event-logger';\n\nconst originalErrorToString = Error.prototype.toString;\nError.prototype.toString = function () {\n return this.stack || originalErrorToString.call(this);\n};\n\n/** @deprecated Use `createRequestHandler` from `@shopify/hydrogen/oxygen` instead. */\nexport function createRequestHandler<Context = unknown>({\n build,\n mode,\n poweredByHeader = true,\n getLoadContext,\n}: {\n build: ServerBuild;\n mode?: string;\n poweredByHeader?: boolean;\n getLoadContext?: (request: Request) => Promise<Context> | Context;\n}) {\n const handleRequest = createReactRouterRequestHandler(build, mode);\n\n return async (request: Request) => {\n const method = request.method;\n\n if ((method === 'GET' || method === 'HEAD') && request.body) {\n return new Response(`${method} requests cannot have a body`, {\n status: 400,\n });\n }\n\n const url = new URL(request.url);\n\n if (url.pathname.includes('//')) {\n return new Response(null, {\n status: 301,\n headers: {\n location: url.pathname.replace(/\\/+/g, '/') + url.search,\n },\n });\n }\n\n const context = getLoadContext\n ? ((await getLoadContext(request)) as AppLoadContext)\n : undefined;\n\n if (process.env.NODE_ENV === 'development' && context) {\n // Store logger in globalThis so it can be accessed from the worker.\n // The global property must be different from the binding name,\n // otherwise Miniflare throws an error when accessing it.\n globalThis.__H2O_LOG_EVENT ??= createEventLogger(context);\n }\n\n const startTime = Date.now();\n\n const response = await handleRequest(request, context);\n\n if (poweredByHeader) {\n response.headers.append('powered-by', 'Shopify, Hydrogen');\n }\n\n if (process.env.NODE_ENV === 'development') {\n globalThis.__H2O_LOG_EVENT?.({\n eventType: 'request',\n url: request.url,\n requestId: request.headers.get('request-id'),\n purpose: request.headers.get('purpose'),\n startTime,\n responseInit: {\n status: response.status,\n statusText: response.statusText,\n headers: Array.from(response.headers.entries()),\n } satisfies ResponseInit,\n });\n }\n\n return response;\n };\n}\n\ntype StorefrontHeaders = {\n requestGroupId: string | null;\n buyerIp: string | null;\n cookie: string | null;\n purpose: string | null;\n};\n\n/** @deprecated Use `getStorefrontHeaders` from `@shopify/hydrogen/oxygen` instead. */\nexport function getStorefrontHeaders(request: Request): StorefrontHeaders {\n const headers = request.headers;\n return {\n requestGroupId: headers.get('request-id'),\n buyerIp: headers.get('oxygen-buyer-ip'),\n cookie: headers.get('cookie'),\n purpose: headers.get('purpose'),\n };\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ServerBuild } from 'react-router';
|
|
2
2
|
export { ActionFunction, ActionFunctionArgs, AppLoadContext, Cookie, CookieOptions, CookieParseOptions, CookieSerializeOptions, CookieSignatureOptions, EntryContext, ErrorResponse, HandleDataRequestFunction, HandleDocumentRequestFunction, HandleErrorFunction, HeadersArgs, HeadersFunction, HtmlLinkDescriptor, LinkDescriptor, LinksFunction, LoaderFunction, LoaderFunctionArgs, MetaArgs, MetaDescriptor, MetaFunction, PageLinkDescriptor, RequestHandler, ServerBuild, ServerEntryModule, Session, SessionData, SessionIdStorageStrategy, SessionStorage, createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, data, isCookie, isSession, redirect, redirectDocument } from 'react-router';
|
|
3
3
|
|
|
4
|
+
/** @deprecated Use `createRequestHandler` from `@shopify/hydrogen/oxygen` instead. */
|
|
4
5
|
declare function createRequestHandler<Context = unknown>({ build, mode, poweredByHeader, getLoadContext, }: {
|
|
5
6
|
build: ServerBuild;
|
|
6
7
|
mode?: string;
|
|
@@ -13,6 +14,7 @@ type StorefrontHeaders = {
|
|
|
13
14
|
cookie: string | null;
|
|
14
15
|
purpose: string | null;
|
|
15
16
|
};
|
|
17
|
+
/** @deprecated Use `getStorefrontHeaders` from `@shopify/hydrogen/oxygen` instead. */
|
|
16
18
|
declare function getStorefrontHeaders(request: Request): StorefrontHeaders;
|
|
17
19
|
|
|
18
20
|
export { createRequestHandler, getStorefrontHeaders };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ServerBuild } from 'react-router';
|
|
2
2
|
export { ActionFunction, ActionFunctionArgs, AppLoadContext, Cookie, CookieOptions, CookieParseOptions, CookieSerializeOptions, CookieSignatureOptions, EntryContext, ErrorResponse, HandleDataRequestFunction, HandleDocumentRequestFunction, HandleErrorFunction, HeadersArgs, HeadersFunction, HtmlLinkDescriptor, LinkDescriptor, LinksFunction, LoaderFunction, LoaderFunctionArgs, MetaArgs, MetaDescriptor, MetaFunction, PageLinkDescriptor, RequestHandler, ServerBuild, ServerEntryModule, Session, SessionData, SessionIdStorageStrategy, SessionStorage, createCookie, createCookieSessionStorage, createMemorySessionStorage, createSession, createSessionStorage, data, isCookie, isSession, redirect, redirectDocument } from 'react-router';
|
|
3
3
|
|
|
4
|
+
/** @deprecated Use `createRequestHandler` from `@shopify/hydrogen/oxygen` instead. */
|
|
4
5
|
declare function createRequestHandler<Context = unknown>({ build, mode, poweredByHeader, getLoadContext, }: {
|
|
5
6
|
build: ServerBuild;
|
|
6
7
|
mode?: string;
|
|
@@ -13,6 +14,7 @@ type StorefrontHeaders = {
|
|
|
13
14
|
cookie: string | null;
|
|
14
15
|
purpose: string | null;
|
|
15
16
|
};
|
|
17
|
+
/** @deprecated Use `getStorefrontHeaders` from `@shopify/hydrogen/oxygen` instead. */
|
|
16
18
|
declare function getStorefrontHeaders(request: Request): StorefrontHeaders;
|
|
17
19
|
|
|
18
20
|
export { createRequestHandler, getStorefrontHeaders };
|
package/dist/production/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {createRequestHandler}from'react-router';export{createCookie,createCookieSessionStorage,createMemorySessionStorage,createSession,createSessionStorage,data,isCookie,isSession,redirect,redirectDocument}from'react-router';var
|
|
2
|
-
export{
|
|
1
|
+
import {createRequestHandler}from'react-router';export{createCookie,createCookieSessionStorage,createMemorySessionStorage,createSession,createSessionStorage,data,isCookie,isSession,redirect,redirectDocument}from'react-router';var m=Error.prototype.toString;Error.prototype.toString=function(){return this.stack||m.call(this)};function f({build:t,mode:e,poweredByHeader:a=true,getLoadContext:p}){let u=createRequestHandler(t,e);return async r=>{let o=r.method;if((o==="GET"||o==="HEAD")&&r.body)return new Response(`${o} requests cannot have a body`,{status:400});let n=new URL(r.url);if(n.pathname.includes("//"))return new Response(null,{status:301,headers:{location:n.pathname.replace(/\/+/g,"/")+n.search}});let i=p?await p(r):void 0,s=await u(r,i);return a&&s.headers.append("powered-by","Shopify, Hydrogen"),s}}function x(t){let e=t.headers;return {requestGroupId:e.get("request-id"),buyerIp:e.get("oxygen-buyer-ip"),cookie:e.get("cookie"),purpose:e.get("purpose")}}
|
|
2
|
+
export{f as createRequestHandler,x as getStorefrontHeaders};//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/server.ts"],"names":["originalErrorToString","createRequestHandler","build","mode","poweredByHeader","getLoadContext","handleRequest","createReactRouterRequestHandler","request","method","url","context","response","getStorefrontHeaders","headers"],"mappings":"kOAQA,IAAMA,
|
|
1
|
+
{"version":3,"sources":["../../src/server.ts"],"names":["originalErrorToString","createRequestHandler","build","mode","poweredByHeader","getLoadContext","handleRequest","createReactRouterRequestHandler","request","method","url","context","response","getStorefrontHeaders","headers"],"mappings":"kOAQA,IAAMA,EAAwB,KAAA,CAAM,SAAA,CAAU,SAC9C,KAAA,CAAM,SAAA,CAAU,SAAW,UAAY,CACrC,OAAO,IAAA,CAAK,KAAA,EAASA,EAAsB,IAAA,CAAK,IAAI,CACtD,CAAA,CAGO,SAASC,CAAAA,CAAwC,CACtD,KAAA,CAAAC,CAAAA,CACA,KAAAC,CAAAA,CACA,eAAA,CAAAC,EAAkB,IAAA,CAClB,cAAA,CAAAC,CACF,CAAA,CAKG,CACD,IAAMC,EAAgBC,oBAAAA,CAAgCL,CAAAA,CAAOC,CAAI,CAAA,CAEjE,aAAcK,CAAAA,EAAqB,CACjC,IAAMC,CAAAA,CAASD,CAAAA,CAAQ,MAAA,CAEvB,IAAKC,CAAAA,GAAW,KAAA,EAASA,IAAW,MAAA,GAAWD,CAAAA,CAAQ,KACrD,OAAO,IAAI,SAAS,CAAA,EAAGC,CAAM,+BAAgC,CAC3D,MAAA,CAAQ,GACV,CAAC,CAAA,CAGH,IAAMC,CAAAA,CAAM,IAAI,GAAA,CAAIF,CAAAA,CAAQ,GAAG,CAAA,CAE/B,GAAIE,CAAAA,CAAI,QAAA,CAAS,SAAS,IAAI,CAAA,CAC5B,OAAO,IAAI,QAAA,CAAS,IAAA,CAAM,CACxB,MAAA,CAAQ,GAAA,CACR,QAAS,CACP,QAAA,CAAUA,EAAI,QAAA,CAAS,OAAA,CAAQ,OAAQ,GAAG,CAAA,CAAIA,CAAAA,CAAI,MACpD,CACF,CAAC,EAGH,IAAMC,CAAAA,CAAUN,EACV,MAAMA,CAAAA,CAAeG,CAAO,CAAA,CAC9B,MAAA,CAWEI,CAAAA,CAAW,MAAMN,EAAcE,CAAAA,CAASG,CAAO,EAErD,OAAIP,CAAAA,EACFQ,CAAAA,CAAS,OAAA,CAAQ,MAAA,CAAO,YAAA,CAAc,mBAAmB,CAAA,CAkBpDA,CACT,CACF,CAUO,SAASC,EAAqBL,CAAAA,CAAqC,CACxE,IAAMM,CAAAA,CAAUN,CAAAA,CAAQ,OAAA,CACxB,OAAO,CACL,cAAA,CAAgBM,EAAQ,GAAA,CAAI,YAAY,EACxC,OAAA,CAASA,CAAAA,CAAQ,GAAA,CAAI,iBAAiB,CAAA,CACtC,MAAA,CAAQA,EAAQ,GAAA,CAAI,QAAQ,EAC5B,OAAA,CAASA,CAAAA,CAAQ,IAAI,SAAS,CAChC,CACF","file":"index.js","sourcesContent":["/// <reference types=\"@shopify/hydrogen\" />\nimport {\n createRequestHandler as createReactRouterRequestHandler,\n type AppLoadContext,\n type ServerBuild,\n} from 'react-router';\nimport {createEventLogger} from './event-logger';\n\nconst originalErrorToString = Error.prototype.toString;\nError.prototype.toString = function () {\n return this.stack || originalErrorToString.call(this);\n};\n\n/** @deprecated Use `createRequestHandler` from `@shopify/hydrogen/oxygen` instead. */\nexport function createRequestHandler<Context = unknown>({\n build,\n mode,\n poweredByHeader = true,\n getLoadContext,\n}: {\n build: ServerBuild;\n mode?: string;\n poweredByHeader?: boolean;\n getLoadContext?: (request: Request) => Promise<Context> | Context;\n}) {\n const handleRequest = createReactRouterRequestHandler(build, mode);\n\n return async (request: Request) => {\n const method = request.method;\n\n if ((method === 'GET' || method === 'HEAD') && request.body) {\n return new Response(`${method} requests cannot have a body`, {\n status: 400,\n });\n }\n\n const url = new URL(request.url);\n\n if (url.pathname.includes('//')) {\n return new Response(null, {\n status: 301,\n headers: {\n location: url.pathname.replace(/\\/+/g, '/') + url.search,\n },\n });\n }\n\n const context = getLoadContext\n ? ((await getLoadContext(request)) as AppLoadContext)\n : undefined;\n\n if (process.env.NODE_ENV === 'development' && context) {\n // Store logger in globalThis so it can be accessed from the worker.\n // The global property must be different from the binding name,\n // otherwise Miniflare throws an error when accessing it.\n globalThis.__H2O_LOG_EVENT ??= createEventLogger(context);\n }\n\n const startTime = Date.now();\n\n const response = await handleRequest(request, context);\n\n if (poweredByHeader) {\n response.headers.append('powered-by', 'Shopify, Hydrogen');\n }\n\n if (process.env.NODE_ENV === 'development') {\n globalThis.__H2O_LOG_EVENT?.({\n eventType: 'request',\n url: request.url,\n requestId: request.headers.get('request-id'),\n purpose: request.headers.get('purpose'),\n startTime,\n responseInit: {\n status: response.status,\n statusText: response.statusText,\n headers: Array.from(response.headers.entries()),\n } satisfies ResponseInit,\n });\n }\n\n return response;\n };\n}\n\ntype StorefrontHeaders = {\n requestGroupId: string | null;\n buyerIp: string | null;\n cookie: string | null;\n purpose: string | null;\n};\n\n/** @deprecated Use `getStorefrontHeaders` from `@shopify/hydrogen/oxygen` instead. */\nexport function getStorefrontHeaders(request: Request): StorefrontHeaders {\n const headers = request.headers;\n return {\n requestGroupId: headers.get('request-id'),\n buyerIp: headers.get('oxygen-buyer-ip'),\n cookie: headers.get('cookie'),\n purpose: headers.get('purpose'),\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopify/remix-oxygen",
|
|
3
|
+
"deprecated": "Import types/utilities from 'react-router'. Use createRequestHandler from '@shopify/hydrogen/oxygen' instead.",
|
|
3
4
|
"publishConfig": {
|
|
4
5
|
"access": "public",
|
|
5
6
|
"@shopify:registry": "https://registry.npmjs.org"
|
|
6
7
|
},
|
|
7
8
|
"type": "module",
|
|
8
|
-
"version": "3.0.
|
|
9
|
+
"version": "3.0.3",
|
|
9
10
|
"license": "MIT",
|
|
10
11
|
"main": "dist/index.cjs",
|
|
11
12
|
"module": "dist/production/index.js",
|
|
@@ -16,12 +17,6 @@
|
|
|
16
17
|
"url": "git+https://github.com/Shopify/hydrogen.git",
|
|
17
18
|
"directory": "packages/remix-oxygen"
|
|
18
19
|
},
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "tsup --clean",
|
|
21
|
-
"dev": "tsup --watch",
|
|
22
|
-
"prepack": "npm run build",
|
|
23
|
-
"typecheck": "tsc --noEmit"
|
|
24
|
-
},
|
|
25
20
|
"exports": {
|
|
26
21
|
".": {
|
|
27
22
|
"types": "./dist/production/index.d.ts",
|
|
@@ -46,10 +41,17 @@
|
|
|
46
41
|
],
|
|
47
42
|
"devDependencies": {
|
|
48
43
|
"@shopify/oxygen-workers-types": "^4.1.6",
|
|
49
|
-
"
|
|
44
|
+
"@types/node": "22.19.15",
|
|
45
|
+
"react-router": "7.12.0",
|
|
46
|
+
"@shopify/hydrogen": "2026.4.1"
|
|
50
47
|
},
|
|
51
48
|
"peerDependencies": {
|
|
52
49
|
"@shopify/oxygen-workers-types": "^3.17.3 || ^4.1.2",
|
|
53
50
|
"react-router": "7.12.0"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsup --clean",
|
|
54
|
+
"dev": "tsup --watch",
|
|
55
|
+
"typecheck": "tsc --noEmit"
|
|
54
56
|
}
|
|
55
|
-
}
|
|
57
|
+
}
|