@pack/hydrogen 2.1.1 → 3.0.0

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/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { PackClient } from '@pack/client';
2
2
  import { CacheCustom } from '@shopify/hydrogen';
3
- import { SessionStorage, Session } from '@shopify/remix-oxygen';
4
- import { ActionFunction, LoaderFunction } from '@remix-run/server-runtime';
3
+ import { SessionStorage, Session, ActionFunctionArgs, LoaderFunctionArgs } from 'react-router';
5
4
  import * as react from 'react';
6
5
  import react__default, { Dispatch, SetStateAction, PropsWithChildren } from 'react';
7
6
 
@@ -172,11 +171,11 @@ declare function usePackCookies(options?: UsePackCookiesOptions): void;
172
171
  * A `POST` request to this route will exit preview mode
173
172
  * POST /api/edit Content-Type: application/x-www-form-urlencoded
174
173
  */
175
- declare const action: ActionFunction;
174
+ declare function action({ request, context }: ActionFunctionArgs): Promise<Response>;
176
175
  /**
177
176
  * A `GET` request to this route will enter preview mode
178
177
  */
179
- declare const loader: LoaderFunction;
178
+ declare function loader({ request, context }: LoaderFunctionArgs): Promise<Response>;
180
179
 
181
180
  declare const PackTestRoute: () => null;
182
181
 
package/dist/index.js CHANGED
@@ -1317,12 +1317,12 @@ var require_ua_parser = __commonJS({
1317
1317
  }
1318
1318
  });
1319
1319
 
1320
- // ../../node_modules/cookie/index.js
1320
+ // node_modules/cookie/index.js
1321
1321
  var require_cookie = __commonJS({
1322
- "../../node_modules/cookie/index.js"(exports) {
1322
+ "node_modules/cookie/index.js"(exports) {
1323
1323
  "use strict";
1324
1324
  exports.parse = parse2;
1325
- exports.serialize = serialize2;
1325
+ exports.serialize = serialize3;
1326
1326
  var __toString = Object.prototype.toString;
1327
1327
  var __hasOwnProperty = Object.prototype.hasOwnProperty;
1328
1328
  var cookieNameRegExp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
@@ -1381,7 +1381,7 @@ var require_cookie = __commonJS({
1381
1381
  }
1382
1382
  return min;
1383
1383
  }
1384
- function serialize2(name, val, opt) {
1384
+ function serialize3(name, val, opt) {
1385
1385
  var enc = opt && opt.encode || encodeURIComponent;
1386
1386
  if (typeof enc !== "function") {
1387
1387
  throw new TypeError("option encode is invalid");
@@ -4609,7 +4609,7 @@ function getDevice(userAgent) {
4609
4609
  }
4610
4610
 
4611
4611
  // ../packlytics/dist/packlytics.js
4612
- import { getStorefrontHeaders } from "@shopify/remix-oxygen";
4612
+ import { getStorefrontHeaders } from "@shopify/hydrogen/oxygen";
4613
4613
 
4614
4614
  // ../packlytics/dist/utils/get-client-location.js
4615
4615
  function getClientLocation(locale) {
@@ -4683,14 +4683,9 @@ async function handleRequest(pack, request, handleRequest2) {
4683
4683
  }
4684
4684
 
4685
4685
  // src/session/usePackCookies.ts
4686
+ var import_cookie = __toESM(require_cookie(), 1);
4686
4687
  import { useEffect } from "react";
4687
4688
 
4688
- // ../../node_modules/worktop/cookie/index.mjs
4689
- function l(a, r, e = {}) {
4690
- let t = a + "=" + encodeURIComponent(r);
4691
- return e.expires && (t += "; Expires=" + new Date(e.expires).toUTCString()), e.maxage != null && e.maxage >= 0 && (t += "; Max-Age=" + (e.maxage | 0)), e.domain && (t += "; Domain=" + e.domain), e.path && (t += "; Path=" + e.path), e.samesite && (t += "; SameSite=" + e.samesite), (e.secure || e.samesite === "None") && (t += "; Secure"), e.httponly && (t += "; HttpOnly"), t;
4692
- }
4693
-
4694
4689
  // src/constants.ts
4695
4690
  var PACK_COOKIE_ID = "__pack";
4696
4691
  var PACK_USER_CONSENT_COOKIE_ID = "__pack_user_consent";
@@ -4710,10 +4705,10 @@ function usePackCookies(options) {
4710
4705
  }, [hasUserConsent2]);
4711
4706
  }
4712
4707
  function setCookie(name, value, maxage, domain) {
4713
- document.cookie = l(name, value, {
4714
- maxage,
4708
+ document.cookie = (0, import_cookie.serialize)(name, value, {
4709
+ maxAge: maxage,
4715
4710
  domain,
4716
- samesite: "Lax",
4711
+ sameSite: "lax",
4717
4712
  path: "/"
4718
4713
  });
4719
4714
  }
@@ -4722,7 +4717,7 @@ function setCookie(name, value, maxage, domain) {
4722
4717
  import {
4723
4718
  createCookie,
4724
4719
  createCookieSessionStorage
4725
- } from "@shopify/remix-oxygen";
4720
+ } from "react-router";
4726
4721
 
4727
4722
  // src/session/cookies-utils.tsx
4728
4723
  var import_cookie2 = __toESM(require_cookie(), 1);
@@ -4824,7 +4819,7 @@ var PackSession = class {
4824
4819
  import {
4825
4820
  createCookie as createCookie2,
4826
4821
  createCookieSessionStorage as createCookieSessionStorage2
4827
- } from "@shopify/remix-oxygen";
4822
+ } from "react-router";
4828
4823
  var import_debug = __toESM(require_browser(), 1);
4829
4824
  var debug = (0, import_debug.default)("pack:ab-testing:test-session");
4830
4825
  function isSafari2(userAgent) {
@@ -6397,7 +6392,7 @@ function isLocalPath(request, url) {
6397
6392
  const urlToCheck = new URL(url, currentUrl.origin);
6398
6393
  return currentUrl.origin === urlToCheck.origin;
6399
6394
  }
6400
- var action = async ({ request, context }) => {
6395
+ async function action({ request, context }) {
6401
6396
  const { session } = context.pack;
6402
6397
  if (!(request.method === "POST" && session)) {
6403
6398
  return json({ message: "Method not allowed" }, 405);
@@ -6407,8 +6402,8 @@ var action = async ({ request, context }) => {
6407
6402
  const redirectTo = isLocalPath(request, slug) ? slug : ROOT_PATH;
6408
6403
  await session.destroy();
6409
6404
  return redirect(redirectTo);
6410
- };
6411
- var loader = async function({ request, context }) {
6405
+ }
6406
+ async function loader({ request, context }) {
6412
6407
  const { pack } = context;
6413
6408
  if (!pack.session) return notFound();
6414
6409
  const { searchParams } = new URL(request.url);
@@ -6455,7 +6450,7 @@ var loader = async function({ request, context }) {
6455
6450
  return redirect(redirectTo, {
6456
6451
  status: 307
6457
6452
  });
6458
- };
6453
+ }
6459
6454
  var MissingTokenError = class extends Response {
6460
6455
  constructor() {
6461
6456
  super("Missing token", { status: 401, statusText: "Unauthorized" });
@@ -6468,7 +6463,7 @@ var InvalidTokenError = class extends Response {
6468
6463
  };
6469
6464
 
6470
6465
  // src/tests/pack-test-route.ts
6471
- import { useLoaderData, useMatches, useRevalidator } from "@remix-run/react";
6466
+ import { useLoaderData, useMatches, useRevalidator } from "react-router";
6472
6467
 
6473
6468
  // ../../node_modules/js-cookie/dist/js.cookie.mjs
6474
6469
  function assign(target) {
@@ -6687,7 +6682,7 @@ function PackTestProvider({
6687
6682
  }
6688
6683
 
6689
6684
  // src/tests/hooks.ts
6690
- import { useRouteLoaderData } from "@remix-run/react";
6685
+ import { useRouteLoaderData } from "react-router";
6691
6686
  function useAbTest() {
6692
6687
  const { abTest, packAbTest } = useRouteLoaderData("root");
6693
6688
  if (abTest === void 0 && packAbTest === void 0) {