@shopify/remix-oxygen 3.0.0 → 3.0.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/event-logger.ts","../../src/server.ts"],"names":["createReactRouterRequestHandler"],"mappings":";;;;;;;AAEA,IAAI,
|
|
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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>>[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\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, '/'),\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\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,
|
|
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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A;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;AASO,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.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\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, '/'),\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\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/server.ts"],"names":["originalErrorToString","createRequestHandler","build","mode","poweredByHeader","getLoadContext","handleRequest","createReactRouterRequestHandler","request","method","url","context","response","getStorefrontHeaders","headers"],"mappings":"qDAQA,IAAMA,CAAwB,
|
|
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,CAAAA,CAAwB,KAAA,CAAM,UAAU,QAAA,CAC9C,KAAA,CAAM,UAAU,QAAA,CAAW,UAAY,CACrC,OAAO,IAAA,CAAK,OAASA,CAAAA,CAAsB,IAAA,CAAK,IAAI,CACtD,CAAA,CAEO,SAASC,CAAAA,CAAwC,CACtD,KAAA,CAAAC,CAAAA,CACA,KAAAC,CAAAA,CACA,eAAA,CAAAC,EAAkB,IAAA,CAClB,cAAA,CAAAC,CACF,CAAA,CAKG,CACD,IAAMC,CAAAA,CAAgBC,gCAAAA,CAAgCL,EAAOC,CAAI,CAAA,CAEjE,OAAO,MAAOK,CAAAA,EAAqB,CACjC,IAAMC,EAASD,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,EAAI,QAAA,CAAS,QAAA,CAAS,IAAI,CAAA,CAC5B,OAAO,IAAI,QAAA,CAAS,IAAA,CAAM,CACxB,MAAA,CAAQ,GAAA,CACR,QAAS,CACP,QAAA,CAAUA,CAAAA,CAAI,QAAA,CAAS,QAAQ,MAAA,CAAQ,GAAG,CAC5C,CACF,CAAC,EAGH,IAAMC,CAAAA,CAAUN,EACV,MAAMA,CAAAA,CAAeG,CAAO,CAAA,CAC9B,MAAA,CAWEI,CAAAA,CAAW,MAAMN,CAAAA,CAAcE,CAAAA,CAASG,CAAO,EAErD,OAAIP,GACFQ,CAAAA,CAAS,OAAA,CAAQ,OAAO,YAAA,CAAc,mBAAmB,EAkBpDA,CACT,CACF,CASO,SAASC,CAAAA,CAAqBL,EAAqC,CACxE,IAAMM,EAAUN,CAAAA,CAAQ,OAAA,CACxB,OAAO,CACL,eAAgBM,CAAAA,CAAQ,GAAA,CAAI,YAAY,CAAA,CACxC,OAAA,CAASA,EAAQ,GAAA,CAAI,iBAAiB,EACtC,MAAA,CAAQA,CAAAA,CAAQ,IAAI,QAAQ,CAAA,CAC5B,QAASA,CAAAA,CAAQ,GAAA,CAAI,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\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, '/'),\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\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/server.ts"],"names":["originalErrorToString","createRequestHandler","build","mode","poweredByHeader","getLoadContext","handleRequest","createReactRouterRequestHandler","request","method","url","context","response","getStorefrontHeaders","headers"],"mappings":"kOAQA,IAAMA,CAAwB,
|
|
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,CAAAA,CAAwB,KAAA,CAAM,UAAU,QAAA,CAC9C,KAAA,CAAM,UAAU,QAAA,CAAW,UAAY,CACrC,OAAO,IAAA,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AAA,CAAQ,IAAI,QAAQ,CAAA,CAC5B,QAASA,CAAAA,CAAQ,GAAA,CAAI,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\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, '/'),\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\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
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"@shopify:registry": "https://registry.npmjs.org"
|
|
6
6
|
},
|
|
7
7
|
"type": "module",
|
|
8
|
-
"version": "3.0.
|
|
8
|
+
"version": "3.0.2",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"main": "dist/index.cjs",
|
|
11
11
|
"module": "dist/production/index.js",
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
],
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@shopify/oxygen-workers-types": "^4.1.6",
|
|
49
|
-
"react-router": "7.
|
|
49
|
+
"react-router": "7.12.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@shopify/oxygen-workers-types": "^3.17.3 || ^4.1.2",
|
|
53
|
-
"react-router": "7.
|
|
53
|
+
"react-router": "7.12.0"
|
|
54
54
|
}
|
|
55
55
|
}
|