@merchi/cart 1.4.46 → 1.4.48

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.
@@ -2,8 +2,10 @@ import * as React from 'react';
2
2
  import { Suspense, lazy } from 'react';
3
3
  import { useCartContext } from '../CartProvider';
4
4
  import { LoadingTemplateSm } from '../components/LoadingTemplate';
5
+ import { hardenStitchesCssom } from '../square/hardenStitchesCssom';
5
6
  import { jsx as _jsx } from "react/jsx-runtime";
6
7
  var SquareCard = /*#__PURE__*/lazy(function () {
8
+ hardenStitchesCssom();
7
9
  return import('../square/SquareCard');
8
10
  });
9
11
  function FormSquarePayment() {
@@ -0,0 +1,34 @@
1
+ var patched = new WeakSet();
2
+ function emptyRules() {
3
+ return [];
4
+ }
5
+ function coerceCssRules(proto) {
6
+ if (patched.has(proto)) return;
7
+ var desc = Object.getOwnPropertyDescriptor(proto, 'cssRules');
8
+ var getter = desc === null || desc === void 0 ? void 0 : desc.get;
9
+ if (!getter) return;
10
+ try {
11
+ Object.defineProperty(proto, 'cssRules', {
12
+ configurable: true,
13
+ enumerable: desc.enumerable,
14
+ get: function get() {
15
+ var rules = getter.call(this);
16
+ return rules == null ? emptyRules() : rules;
17
+ }
18
+ });
19
+ patched.add(proto);
20
+ } catch (_unused) {
21
+ // Some browsers lock the CSSOM descriptor.
22
+ }
23
+ }
24
+
25
+ /**
26
+ * Square's payment form initialises Stitches while the module evaluates.
27
+ * Stitches reads `rule.cssRules.length` and throws if that list is missing.
28
+ */
29
+ export function hardenStitchesCssom() {
30
+ if (typeof window === 'undefined') return;
31
+ if (typeof CSSGroupingRule !== 'undefined') {
32
+ coerceCssRules(CSSGroupingRule.prototype);
33
+ }
34
+ }
@@ -9,9 +9,11 @@ var _react = _interopRequireWildcard(require("react"));
9
9
  var React = _react;
10
10
  var _CartProvider = require("../CartProvider");
11
11
  var _LoadingTemplate = require("../components/LoadingTemplate");
12
+ var _hardenStitchesCssom = require("../square/hardenStitchesCssom");
12
13
  var _jsxRuntime = require("react/jsx-runtime");
13
14
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
14
15
  var SquareCard = /*#__PURE__*/(0, _react.lazy)(function () {
16
+ (0, _hardenStitchesCssom.hardenStitchesCssom)();
15
17
  return import('../square/SquareCard');
16
18
  });
17
19
  function FormSquarePayment() {
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Square's payment form initialises Stitches while the module evaluates.
3
+ * Stitches reads `rule.cssRules.length` and throws if that list is missing.
4
+ */
5
+ export declare function hardenStitchesCssom(): void;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hardenStitchesCssom = hardenStitchesCssom;
7
+ var patched = new WeakSet();
8
+ function emptyRules() {
9
+ return [];
10
+ }
11
+ function coerceCssRules(proto) {
12
+ if (patched.has(proto)) return;
13
+ var desc = Object.getOwnPropertyDescriptor(proto, 'cssRules');
14
+ var getter = desc === null || desc === void 0 ? void 0 : desc.get;
15
+ if (!getter) return;
16
+ try {
17
+ Object.defineProperty(proto, 'cssRules', {
18
+ configurable: true,
19
+ enumerable: desc.enumerable,
20
+ get: function get() {
21
+ var rules = getter.call(this);
22
+ return rules == null ? emptyRules() : rules;
23
+ }
24
+ });
25
+ patched.add(proto);
26
+ } catch (_unused) {
27
+ // Some browsers lock the CSSOM descriptor.
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Square's payment form initialises Stitches while the module evaluates.
33
+ * Stitches reads `rule.cssRules.length` and throws if that list is missing.
34
+ */
35
+ function hardenStitchesCssom() {
36
+ if (typeof window === 'undefined') return;
37
+ if (typeof CSSGroupingRule !== 'undefined') {
38
+ coerceCssRules(CSSGroupingRule.prototype);
39
+ }
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merchi/cart",
3
- "version": "1.4.46",
3
+ "version": "1.4.48",
4
4
  "description": "Merchi's cart",
5
5
  "source": "src/index.ts",
6
6
  "main": "lib/index.js",
@@ -93,8 +93,8 @@
93
93
  "@fortawesome/fontawesome-svg-core": "6.4.2",
94
94
  "@fortawesome/free-solid-svg-icons": "6.4.2",
95
95
  "@fortawesome/react-fontawesome": "^0.2.0",
96
- "@merchi/error-catch": "^0.1.5",
97
- "@merchi/invoice": "^1.3.9",
96
+ "@merchi/error-catch": "^0.1.6",
97
+ "@merchi/invoice": "^1.3.11",
98
98
  "@merchi/product-form": "^1.19.47",
99
99
  "@merchi/product-form-sdk": "^1.0.31",
100
100
  "@merchi/sdk": "^1.42.20",
@@ -2,8 +2,12 @@ import * as React from 'react';
2
2
  import { Suspense, lazy } from 'react';
3
3
  import { useCartContext } from '../CartProvider';
4
4
  import { LoadingTemplateSm } from '../components/LoadingTemplate';
5
+ import { hardenStitchesCssom } from '../square/hardenStitchesCssom';
5
6
 
6
- const SquareCard = lazy(() => import('../square/SquareCard'));
7
+ const SquareCard = lazy(() => {
8
+ hardenStitchesCssom();
9
+ return import('../square/SquareCard');
10
+ });
7
11
 
8
12
  function FormSquarePayment() {
9
13
  const { cart } = useCartContext();
@@ -0,0 +1,36 @@
1
+ const patched = new WeakSet<object>();
2
+
3
+ function emptyRules(): CSSRuleList {
4
+ return [] as unknown as CSSRuleList;
5
+ }
6
+
7
+ function coerceCssRules(proto: object) {
8
+ if (patched.has(proto)) return;
9
+ const desc = Object.getOwnPropertyDescriptor(proto, 'cssRules');
10
+ const getter = desc?.get;
11
+ if (!getter) return;
12
+ try {
13
+ Object.defineProperty(proto, 'cssRules', {
14
+ configurable: true,
15
+ enumerable: desc.enumerable,
16
+ get() {
17
+ const rules = getter.call(this) as CSSRuleList | null | undefined;
18
+ return rules == null ? emptyRules() : rules;
19
+ },
20
+ });
21
+ patched.add(proto);
22
+ } catch {
23
+ // Some browsers lock the CSSOM descriptor.
24
+ }
25
+ }
26
+
27
+ /**
28
+ * Square's payment form initialises Stitches while the module evaluates.
29
+ * Stitches reads `rule.cssRules.length` and throws if that list is missing.
30
+ */
31
+ export function hardenStitchesCssom() {
32
+ if (typeof window === 'undefined') return;
33
+ if (typeof CSSGroupingRule !== 'undefined') {
34
+ coerceCssRules(CSSGroupingRule.prototype);
35
+ }
36
+ }