@vue-storefront/nuxt 2.7.2 → 2.7.4
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/lib/index.cjs.js +1 -1
- package/lib/index.es.js +1 -1
- package/package.json +1 -1
- package/plugins/i18n-cookies.js +10 -5
package/lib/index.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("fs"),t=require("path"),n=require("consola"),r=require("chalk"),s=require("lodash");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=o(e),i=o(t),c=o(n),l=o(r),a=Object.freeze({info:function(e){return c.default.info(l.default.bold("VSF"),e)},success:function(e){return c.default.success(l.default.bold("VSF"),e)},warning:function(e){return c.default.warn(l.default.bold("VSF"),e)},error:function(e){return c.default.error(l.default.bold("VSF"),e)}}),d=function(e,t){return s.mergeWith(e,t,(function(e,t){if(s.isArray(e))return e.concat(t)}))};function p(e){try{return require.resolve(e,{paths:[process.cwd()]})}catch(e){return""}}function f(){this.options.render=s.merge(this.options.render,{http2:{push:!0,pushAssets:function(e,t,n,r){return r.filter((function(e){return"script"===e.asType})).map((function(e){var t=e.file,r=e.asType;return"<".concat(n).concat(t,">; rel=preload; as=").concat(r)}))}}})}function h(e){this.nuxt.hook("modules:done",(function(t){return t.addModule(["nuxt-purgecss",e])}))}function g(e){var t=e.performance,n=t.httpPush,r=t.purgeCSS;n&&f.call(this),r&&r.enabled&&h.call(this,r)}function v(e){var t=["@storefront-ui/vue","@storefront-ui/shared"];e.useRawSource=d(e.useRawSource,{dev:t,prod:t})}function m(e){v.call(this,e)}function S(e){var t=this;e.useRawSource[function(e){return"production"===process.env.NODE_ENV||e.coreDevelopment}(e)?"prod":"dev"].map((function(e){return function(e){var n=p("".concat(e,"/package.json")),r=require(n||"");r.module&&t.extendBuild((function(t){t.resolve.alias[r.name+"$"]=p("".concat(e,"/").concat(r.module))})),t.options.build.transpile.push(e),a.info("Using raw source/ESM for ".concat(r.name))}(e)}))}var x={name:"@vue-storefront/nuxt",version:"2.7.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("fs"),t=require("path"),n=require("consola"),r=require("chalk"),s=require("lodash");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=o(e),i=o(t),c=o(n),l=o(r),a=Object.freeze({info:function(e){return c.default.info(l.default.bold("VSF"),e)},success:function(e){return c.default.success(l.default.bold("VSF"),e)},warning:function(e){return c.default.warn(l.default.bold("VSF"),e)},error:function(e){return c.default.error(l.default.bold("VSF"),e)}}),d=function(e,t){return s.mergeWith(e,t,(function(e,t){if(s.isArray(e))return e.concat(t)}))};function p(e){try{return require.resolve(e,{paths:[process.cwd()]})}catch(e){return""}}function f(){this.options.render=s.merge(this.options.render,{http2:{push:!0,pushAssets:function(e,t,n,r){return r.filter((function(e){return"script"===e.asType})).map((function(e){var t=e.file,r=e.asType;return"<".concat(n).concat(t,">; rel=preload; as=").concat(r)}))}}})}function h(e){this.nuxt.hook("modules:done",(function(t){return t.addModule(["nuxt-purgecss",e])}))}function g(e){var t=e.performance,n=t.httpPush,r=t.purgeCSS;n&&f.call(this),r&&r.enabled&&h.call(this,r)}function v(e){var t=["@storefront-ui/vue","@storefront-ui/shared"];e.useRawSource=d(e.useRawSource,{dev:t,prod:t})}function m(e){v.call(this,e)}function S(e){var t=this;e.useRawSource[function(e){return"production"===process.env.NODE_ENV||e.coreDevelopment}(e)?"prod":"dev"].map((function(e){return function(e){var n=p("".concat(e,"/package.json")),r=require(n||"");r.module&&t.extendBuild((function(t){t.resolve.alias[r.name+"$"]=p("".concat(e,"/").concat(r.module))})),t.options.build.transpile.push(e),a.info("Using raw source/ESM for ".concat(r.name))}(e)}))}var x={name:"@vue-storefront/nuxt",version:"2.7.4",main:"lib/index.cjs.js",module:"lib/index.es.js",types:"lib/src/index.d.ts",scripts:{build:"rimraf lib && rollup -c",test:'echo "Error: no test specified" && exit 1',prepublish:"yarn build"},author:"Vue Storefront",license:"MIT",dependencies:{"@nuxt/typescript-build":"^2.0.0","@nuxtjs/composition-api":"^0.29.3","@nuxtjs/style-resources":"^1.0.0",chalk:"^2.4.2",chokidar:"^3.3.1",consola:"^2.10.1",lodash:"^4.17.15","nuxt-purgecss":"^1.0.0"},devDependencies:{"@nuxt/types":"^2.15.8","@rollup/plugin-json":"~4.1.0"},publishConfig:{access:"public"},files:["lib/**/*","plugins/**/*"],engines:{node:">=14 <=16"}};exports.default=function(e){var t=d({coreDevelopment:!1,i18nExtension:!0,e2e:!0,logger:!0,ssr:!0,context:!0,sfui:!0,performance:{httpPush:!0,purgeCSS:{enabled:!1,paths:["**/*.vue"]}},useRawSource:{dev:[],prod:[]}},e);this.options.head.meta.push({name:"generator",content:"Vue Storefront 2"}),a.info("Starting Vue Storefront Nuxt Module"),t.performance.httpPush&&(this.options.render=d(this.options.render,{http2:{push:!0,pushAssets:function(e,t,n,r){return r.filter((function(e){return"script"===e.asType})).map((function(e){var t=e.file,r=e.asType;return"<".concat(n).concat(t,">; rel=preload; as=").concat(r)}))}}})),t.context&&(this.addPlugin(i.default.resolve(__dirname,"../plugins/context.js")),a.success("Installed Vue Storefront Context plugin")),t.ssr&&(this.addPlugin(i.default.resolve(__dirname,"../plugins/ssr.js")),a.success("Installed Vue Storefront SSR plugin")),t.logger&&(this.addPlugin({src:i.default.resolve(__dirname,"../plugins/logger.js"),options:e.logger||{}}),a.success("Installed VSF Logger plugin")),t.e2e&&(this.addPlugin(i.default.resolve(__dirname,"../plugins/e2e-testing.js")),a.success("Installed Vue Storefront E2E testing plugin")),t.i18nExtension&&(this.addPlugin({src:i.default.resolve(__dirname,"../plugins/i18n-cookies.js"),options:this.options.i18n}),a.success("Installed Internationalization Cookies plugin")),u.default.existsSync(p("@storefront-ui/vue"))&&t.sfui&&(m.call(this,t),a.success("Installed StorefrontUI Module")),g.call(this,t),a.success("Installed Performance Module"),S.call(this,t)},exports.meta=x;
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|
package/lib/index.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"fs";import n from"path";import t from"consola";import s from"chalk";import{mergeWith as o,isArray as r,merge as i}from"lodash";var u=Object.freeze({info:function(e){return t.info(s.bold("VSF"),e)},success:function(e){return t.success(s.bold("VSF"),e)},warning:function(e){return t.warn(s.bold("VSF"),e)},error:function(e){return t.error(s.bold("VSF"),e)}}),c=function(e,n){return o(e,n,(function(e,n){if(r(e))return e.concat(n)}))};function l(e){try{return require.resolve(e,{paths:[process.cwd()]})}catch(e){return""}}function a(){this.options.render=i(this.options.render,{http2:{push:!0,pushAssets:function(e,n,t,s){return s.filter((function(e){return"script"===e.asType})).map((function(e){var n=e.file,s=e.asType;return"<".concat(t).concat(n,">; rel=preload; as=").concat(s)}))}}})}function p(e){this.nuxt.hook("modules:done",(function(n){return n.addModule(["nuxt-purgecss",e])}))}function d(e){var n=e.performance,t=n.httpPush,s=n.purgeCSS;t&&a.call(this),s&&s.enabled&&p.call(this,s)}function f(e){var n=["@storefront-ui/vue","@storefront-ui/shared"];e.useRawSource=c(e.useRawSource,{dev:n,prod:n})}function h(e){f.call(this,e)}function g(e){var n=this;e.useRawSource[function(e){return"production"===process.env.NODE_ENV||e.coreDevelopment}(e)?"prod":"dev"].map((function(e){return function(e){var t=l("".concat(e,"/package.json")),s=require(t||"");s.module&&n.extendBuild((function(n){n.resolve.alias[s.name+"$"]=l("".concat(e,"/").concat(s.module))})),n.options.build.transpile.push(e),u.info("Using raw source/ESM for ".concat(s.name))}(e)}))}var m={name:"@vue-storefront/nuxt",version:"2.7.
|
|
1
|
+
import e from"fs";import n from"path";import t from"consola";import s from"chalk";import{mergeWith as o,isArray as r,merge as i}from"lodash";var u=Object.freeze({info:function(e){return t.info(s.bold("VSF"),e)},success:function(e){return t.success(s.bold("VSF"),e)},warning:function(e){return t.warn(s.bold("VSF"),e)},error:function(e){return t.error(s.bold("VSF"),e)}}),c=function(e,n){return o(e,n,(function(e,n){if(r(e))return e.concat(n)}))};function l(e){try{return require.resolve(e,{paths:[process.cwd()]})}catch(e){return""}}function a(){this.options.render=i(this.options.render,{http2:{push:!0,pushAssets:function(e,n,t,s){return s.filter((function(e){return"script"===e.asType})).map((function(e){var n=e.file,s=e.asType;return"<".concat(t).concat(n,">; rel=preload; as=").concat(s)}))}}})}function p(e){this.nuxt.hook("modules:done",(function(n){return n.addModule(["nuxt-purgecss",e])}))}function d(e){var n=e.performance,t=n.httpPush,s=n.purgeCSS;t&&a.call(this),s&&s.enabled&&p.call(this,s)}function f(e){var n=["@storefront-ui/vue","@storefront-ui/shared"];e.useRawSource=c(e.useRawSource,{dev:n,prod:n})}function h(e){f.call(this,e)}function g(e){var n=this;e.useRawSource[function(e){return"production"===process.env.NODE_ENV||e.coreDevelopment}(e)?"prod":"dev"].map((function(e){return function(e){var t=l("".concat(e,"/package.json")),s=require(t||"");s.module&&n.extendBuild((function(n){n.resolve.alias[s.name+"$"]=l("".concat(e,"/").concat(s.module))})),n.options.build.transpile.push(e),u.info("Using raw source/ESM for ".concat(s.name))}(e)}))}var m={name:"@vue-storefront/nuxt",version:"2.7.4",main:"lib/index.cjs.js",module:"lib/index.es.js",types:"lib/src/index.d.ts",scripts:{build:"rimraf lib && rollup -c",test:'echo "Error: no test specified" && exit 1',prepublish:"yarn build"},author:"Vue Storefront",license:"MIT",dependencies:{"@nuxt/typescript-build":"^2.0.0","@nuxtjs/composition-api":"^0.29.3","@nuxtjs/style-resources":"^1.0.0",chalk:"^2.4.2",chokidar:"^3.3.1",consola:"^2.10.1",lodash:"^4.17.15","nuxt-purgecss":"^1.0.0"},devDependencies:{"@nuxt/types":"^2.15.8","@rollup/plugin-json":"~4.1.0"},publishConfig:{access:"public"},files:["lib/**/*","plugins/**/*"],engines:{node:">=14 <=16"}};function v(t){var s=c({coreDevelopment:!1,i18nExtension:!0,e2e:!0,logger:!0,ssr:!0,context:!0,sfui:!0,performance:{httpPush:!0,purgeCSS:{enabled:!1,paths:["**/*.vue"]}},useRawSource:{dev:[],prod:[]}},t);this.options.head.meta.push({name:"generator",content:"Vue Storefront 2"}),u.info("Starting Vue Storefront Nuxt Module"),s.performance.httpPush&&(this.options.render=c(this.options.render,{http2:{push:!0,pushAssets:function(e,n,t,s){return s.filter((function(e){return"script"===e.asType})).map((function(e){var n=e.file,s=e.asType;return"<".concat(t).concat(n,">; rel=preload; as=").concat(s)}))}}})),s.context&&(this.addPlugin(n.resolve(__dirname,"../plugins/context.js")),u.success("Installed Vue Storefront Context plugin")),s.ssr&&(this.addPlugin(n.resolve(__dirname,"../plugins/ssr.js")),u.success("Installed Vue Storefront SSR plugin")),s.logger&&(this.addPlugin({src:n.resolve(__dirname,"../plugins/logger.js"),options:t.logger||{}}),u.success("Installed VSF Logger plugin")),s.e2e&&(this.addPlugin(n.resolve(__dirname,"../plugins/e2e-testing.js")),u.success("Installed Vue Storefront E2E testing plugin")),s.i18nExtension&&(this.addPlugin({src:n.resolve(__dirname,"../plugins/i18n-cookies.js"),options:this.options.i18n}),u.success("Installed Internationalization Cookies plugin")),e.existsSync(l("@storefront-ui/vue"))&&s.sfui&&(h.call(this,s),u.success("Installed StorefrontUI Module")),d.call(this,s),u.success("Installed Performance Module"),g.call(this,s)}export{v as default,m as meta};
|
|
2
2
|
//# sourceMappingURL=index.es.js.map
|
package/package.json
CHANGED
package/plugins/i18n-cookies.js
CHANGED
|
@@ -23,14 +23,19 @@ const i18nCookiesPlugin = ({ $cookies, i18n, app, redirect }) => {
|
|
|
23
23
|
...i18nOptions.autoChangeCookie,
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
const getDefaultLocale = () => app.$config.defaultLocale;
|
|
27
|
+
const getDefaultCurrency = () => app.$config.defaultCurrency;
|
|
28
|
+
const getDefaultCountry = () => app.$config.defaultCountry;
|
|
29
|
+
|
|
26
30
|
const getCurrencyByLocale = (locale) =>
|
|
27
31
|
i18n.numberFormats?.[locale]?.currency?.currency
|
|
28
32
|
|| i18nOptions.currency
|
|
29
33
|
|| (i18nOptions.currencies.length && i18nOptions.currencies[0].name);
|
|
30
34
|
|
|
35
|
+
|
|
31
36
|
const utils = i18nRedirectsUtil({
|
|
32
37
|
path: app.context.route.path,
|
|
33
|
-
defaultLocale: i18nOptions.defaultLocale,
|
|
38
|
+
defaultLocale: getDefaultLocale() ?? i18nOptions.defaultLocale,
|
|
34
39
|
availableLocales: i18nOptions.locales.map((item) => item.code),
|
|
35
40
|
acceptedLanguages: isServer ? acceptedLanguage.split(',').map((item) => item.split(';')[0]) : acceptedLanguage,
|
|
36
41
|
cookieLocale,
|
|
@@ -47,7 +52,7 @@ const i18nCookiesPlugin = ({ $cookies, i18n, app, redirect }) => {
|
|
|
47
52
|
if (isServer) {
|
|
48
53
|
app.i18n.cookieValues = {
|
|
49
54
|
...(autoChangeCookie.locale && { [cookieNames.locale]: targetLocale }),
|
|
50
|
-
...(autoChangeCookie.currency && { [cookieNames.currency]: getCurrencyByLocale(targetLocale) })
|
|
55
|
+
...(autoChangeCookie.currency && { [cookieNames.currency]: getDefaultCurrency() || getCurrencyByLocale(targetLocale) })
|
|
51
56
|
};
|
|
52
57
|
|
|
53
58
|
if (autoRedirectByLocale && redirectPath) {
|
|
@@ -64,8 +69,8 @@ const i18nCookiesPlugin = ({ $cookies, i18n, app, redirect }) => {
|
|
|
64
69
|
};
|
|
65
70
|
const settings = {
|
|
66
71
|
locale: targetLocale,
|
|
67
|
-
currency: getCurrencyByLocale(targetLocale),
|
|
68
|
-
country: i18nOptions.country || (i18nOptions.countries.length && i18nOptions.countries[0].name)
|
|
72
|
+
currency: getDefaultCurrency() || getCurrencyByLocale(targetLocale),
|
|
73
|
+
country: getDefaultCountry() || i18nOptions.country || (i18nOptions.countries.length && i18nOptions.countries[0].name)
|
|
69
74
|
};
|
|
70
75
|
|
|
71
76
|
const missingFields = Object
|
|
@@ -99,7 +104,7 @@ const i18nCookiesPlugin = ({ $cookies, i18n, app, redirect }) => {
|
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
if (autoChangeCookie.currency) {
|
|
102
|
-
$cookies.set(cookieNames.currency, getCurrencyByLocale(newLocale), cookieOptions);
|
|
107
|
+
$cookies.set(cookieNames.currency, getDefaultCurrency() || getCurrencyByLocale(newLocale), cookieOptions);
|
|
103
108
|
}
|
|
104
109
|
|
|
105
110
|
if (reloadOnLanguageChange) {
|