@jetshop/core 3.13.3 → 3.13.5-non-polyfill
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/boot/addMissingConfig.d.ts +1 -0
- package/boot/server/createRenderer.js +4 -3
- package/boot/server/createRenderer.js.map +1 -1
- package/components/Auth/formFieldsFromSettings.d.ts +10 -10
- package/components/Auth/useAddressFields.d.ts +3 -3
- package/components/Auth/useCustomer.d.ts +6 -6
- package/components/Auth/useLoginFields.d.ts +3 -3
- package/components/ConfigProvider.d.ts +2 -0
- package/components/ConfigProvider.js.map +1 -1
- package/components/ProductVariationProvider/ProductVariationProvider.d.ts +4 -4
- package/components/ProductVariationProvider/ProductVariationProvider.js +3 -36
- package/components/ProductVariationProvider/ProductVariationProvider.js.map +1 -1
- package/components/ProductVariationProvider/ProductVariationProvider.test.js +1 -1
- package/components/ProductVariationProvider/getDefaultValuesFromUrl.d.ts +5 -0
- package/components/ProductVariationProvider/getDefaultValuesFromUrl.js +37 -0
- package/components/ProductVariationProvider/getDefaultValuesFromUrl.js.map +1 -0
- package/helpers/decodeUrlQuery.js +9 -1
- package/helpers/decodeUrlQuery.js.map +1 -1
- package/hooks/ProductList/list-transforms.d.ts +38 -29
- package/hooks/usePreconnectLinks.d.ts +1 -1
- package/hooks/usePreconnectLinks.js +3 -3
- package/hooks/usePreconnectLinks.js.map +1 -1
- package/hooks/usePrice.d.ts +1 -1
- package/hooks/useProductVariants/useProductVariants.js +2 -1
- package/hooks/useProductVariants/useProductVariants.js.map +1 -1
- package/hooks/useProductVariants/useVariantFromUrl.d.ts +5 -0
- package/hooks/useProductVariants/useVariantFromUrl.js +17 -0
- package/hooks/useProductVariants/useVariantFromUrl.js.map +1 -0
- package/hooks/useProductVariants/useVariantFromUrl.test.js +52 -0
- package/package.json +2 -3
- package/polyfills.d.ts +1 -1
- package/polyfills.js +18 -4
- package/polyfills.js.map +1 -1
- package/types.d.ts +1091 -551
- package/analytics/README.md +0 -81
@@ -0,0 +1,52 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { renderHook } from '@testing-library/react-hooks';
|
3
|
+
import { useVariantFromUrl } from './useVariantFromUrl';
|
4
|
+
import { createMemoryHistory } from 'history';
|
5
|
+
import { Router } from 'react-router';
|
6
|
+
|
7
|
+
function MockHistory({ children, initialEntries = ['/'] }) {
|
8
|
+
const history = createMemoryHistory({ initialEntries });
|
9
|
+
|
10
|
+
return <Router history={history}>{children}</Router>;
|
11
|
+
}
|
12
|
+
|
13
|
+
describe('useVariantFromUrl', () => {
|
14
|
+
it('returns an empty object if there is no `att` param', () => {
|
15
|
+
const MockWithParams = props => (
|
16
|
+
<MockHistory initialEntries={['/yo?wow=hey']} {...props} />
|
17
|
+
);
|
18
|
+
|
19
|
+
const { result } = renderHook(() => useVariantFromUrl(), {
|
20
|
+
wrapper: MockWithParams
|
21
|
+
});
|
22
|
+
|
23
|
+
expect(result.current).toEqual({});
|
24
|
+
});
|
25
|
+
it('returns an array with a single value', () => {
|
26
|
+
const MockWithParams = props => (
|
27
|
+
<MockHistory initialEntries={['/yo?att=ODAwIG1t']} {...props} />
|
28
|
+
);
|
29
|
+
|
30
|
+
const { result } = renderHook(() => useVariantFromUrl(), {
|
31
|
+
wrapper: MockWithParams
|
32
|
+
});
|
33
|
+
|
34
|
+
expect(result.current.values).toEqual(['800 mm']);
|
35
|
+
});
|
36
|
+
it('returns an array of values when the encoded string is separated by pipes', () => {
|
37
|
+
// 800 mm|900 mm
|
38
|
+
|
39
|
+
const MockWithParams = props => (
|
40
|
+
<MockHistory
|
41
|
+
initialEntries={['/yo?att=ODAwIG1tfDkwMCBtbQ==']}
|
42
|
+
{...props}
|
43
|
+
/>
|
44
|
+
);
|
45
|
+
|
46
|
+
const { result } = renderHook(() => useVariantFromUrl(), {
|
47
|
+
wrapper: MockWithParams
|
48
|
+
});
|
49
|
+
|
50
|
+
expect(result.current.values).toEqual(['800 mm', '900 mm']);
|
51
|
+
});
|
52
|
+
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jetshop/core",
|
3
|
-
"version": "3.13.
|
3
|
+
"version": "3.13.5-non-polyfill",
|
4
4
|
"license": "MIT",
|
5
5
|
"files": [
|
6
6
|
"**/*.js",
|
@@ -138,6 +138,5 @@
|
|
138
138
|
"peerDependencies": {
|
139
139
|
"react": "^16.9.0",
|
140
140
|
"react-dom": "^16.9.0"
|
141
|
-
}
|
142
|
-
"gitHead": "65a57be4ceaae678de5065f2b2055bd5b2c24b49"
|
141
|
+
}
|
143
142
|
}
|
package/polyfills.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export declare const createPolyfill: (locale: string) => string;
|
1
|
+
export declare const createPolyfill: (locale: string, usePolyfilling: boolean) => string;
|
package/polyfills.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
const polyfills = (locale) => [
|
2
|
-
'
|
2
|
+
'es2015',
|
3
3
|
'Object.values',
|
4
4
|
'Object.entries',
|
5
5
|
'Object.keys',
|
@@ -21,16 +21,30 @@ const polyfills = (locale) => [
|
|
21
21
|
'Symbol',
|
22
22
|
'ResizeObserver'
|
23
23
|
];
|
24
|
-
export const createPolyfill = (locale) => {
|
24
|
+
export const createPolyfill = (locale, usePolyfilling) => {
|
25
25
|
const features = polyfills(locale).join(',');
|
26
26
|
// Here we add two script tags to be run once the client is loaded. One sets a global variable 'polyFillsLoaded' to false and adds a function bootShop which, when called will set 'polyFillsLoaded' to true. The second script will load the polyfills and once they are loaded will call the bootShop function to let the client know that the polyfills have been loaded and that the shop can be started.
|
27
27
|
return `
|
28
28
|
<script>
|
29
29
|
window.polyFillsLoaded = false;
|
30
|
+
|
30
31
|
window.bootShop = function() {
|
31
32
|
window.polyFillsLoaded = true;
|
32
|
-
};
|
33
|
+
};
|
34
|
+
|
35
|
+
// If polyfill.io does not respond, start the shop anyway
|
36
|
+
if (${usePolyfilling}) {
|
37
|
+
setTimeout(function () {
|
38
|
+
if(!window.polyFillsLoaded) {
|
39
|
+
window.bootShop();
|
40
|
+
}
|
41
|
+
}, 5000);
|
42
|
+
}
|
33
43
|
</script>
|
34
|
-
|
44
|
+
|
45
|
+
${usePolyfilling
|
46
|
+
? `<script async defer src='https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?version=4.8.0${process.env.NODE_ENV === 'production' ? '.min' : ''}.js&callback=bootShop&features=${features}'></script>`
|
47
|
+
: '<script>window.bootShop();</script>'}
|
48
|
+
`;
|
35
49
|
};
|
36
50
|
//# sourceMappingURL=polyfills.js.map
|
package/polyfills.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"polyfills.js","sourceRoot":"","sources":["polyfills.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC;IACpC,
|
1
|
+
{"version":3,"file":"polyfills.js","sourceRoot":"","sources":["polyfills.ts"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC;IACpC,QAAQ;IACR,eAAe;IACf,gBAAgB;IAChB,aAAa;IACb,eAAe;IACf,sBAAsB;IACtB,2BAA2B;IAC3B,yBAAyB;IACzB,0BAA0B;IAC1B,sBAAsB;IACtB,YAAY;IACZ,sBAAsB;IACtB,2BAA2B;IAC3B,6BAA6B;IAC7B,KAAK;IACL,sBAAsB;IACtB,gBAAgB,MAAM,EAAE;IACxB,SAAS;IACT,OAAO;IACP,QAAQ;IACR,gBAAgB;CACjB,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,cAAuB,EAAE,EAAE;IACxE,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,6YAA6Y;IAC7Y,OAAO;;;;;;;;;QASD,cAAc;;;;;;;;;IAUlB,cAAc;QACZ,CAAC,CAAC,kGACE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EACnD,kCAAkC,QAAQ,aAAa;QACzD,CAAC,CAAC,qCACN;CACD,CAAC;AACF,CAAC,CAAC"}
|