Socket
Socket
Sign inDemoInstall

@nuxt/vue-app

Package Overview
Dependencies
Maintainers
3
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuxt/vue-app - npm Package Compare versions

Comparing version 2.4.5 to 2.5.0

36

CHANGELOG.md

@@ -6,2 +6,38 @@ # Change Log

# [2.5.0](https://github.com/nuxt/nuxt.js/compare/v2.4.5...v2.5.0) (2019-03-21)
### Bug Fixes
* **builder, vue-app:** order of plugin execution based on order in array ([#5163](https://github.com/nuxt/nuxt.js/issues/5163)) ([a867dbd](https://github.com/nuxt/nuxt.js/commit/a867dbd))
* **ts:** deprecate `isClient`, `isServer`, `isStatic` ([#5211](https://github.com/nuxt/nuxt.js/issues/5211)) ([29c3c42](https://github.com/nuxt/nuxt.js/commit/29c3c42))
* **types:** reflect chainlable NuxtLoading methods ([#5104](https://github.com/nuxt/nuxt.js/issues/5104)) ([a6756a4](https://github.com/nuxt/nuxt.js/commit/a6756a4))
* **vua-app:** clone mount error to prevent mutating read-only error object ([#5214](https://github.com/nuxt/nuxt.js/issues/5214)) ([37006f6](https://github.com/nuxt/nuxt.js/commit/37006f6))
* **vue-app:** avoid css chunk error ([#5173](https://github.com/nuxt/nuxt.js/issues/5173)) ([41028a4](https://github.com/nuxt/nuxt.js/commit/41028a4))
* **vue-app:** decode router base to support unicode characters ([#5297](https://github.com/nuxt/nuxt.js/issues/5297)) ([3ac01df](https://github.com/nuxt/nuxt.js/commit/3ac01df))
* **vue-app:** duplicated router.base when using context.redirect(object) ([#5290](https://github.com/nuxt/nuxt.js/issues/5290)) ([cf02e82](https://github.com/nuxt/nuxt.js/commit/cf02e82))
* **vue-app:** multiple named views cause invalid syntax ([#5262](https://github.com/nuxt/nuxt.js/issues/5262)) ([d03a61b](https://github.com/nuxt/nuxt.js/commit/d03a61b))
* keep-alive component data should not be updated ([#5188](https://github.com/nuxt/nuxt.js/issues/5188)) ([1ea8661](https://github.com/nuxt/nuxt.js/commit/1ea8661))
* respect namespaced in store module ([#5189](https://github.com/nuxt/nuxt.js/issues/5189)) ([9e1ef88](https://github.com/nuxt/nuxt.js/commit/9e1ef88))
* **vue-app:** use browser to handle scrolling position on page reload and back-navigation from other sites ([#5080](https://github.com/nuxt/nuxt.js/issues/5080)) ([ee87f4c](https://github.com/nuxt/nuxt.js/commit/ee87f4c))
### Features
* loading screen ([#5251](https://github.com/nuxt/nuxt.js/issues/5251)) ([ef41e20](https://github.com/nuxt/nuxt.js/commit/ef41e20))
* **ts:** nuxt configuration typedefs ([#4854](https://github.com/nuxt/nuxt.js/issues/4854)) ([92f81e0](https://github.com/nuxt/nuxt.js/commit/92f81e0))
* **vue-app:** universal fetch ([#5028](https://github.com/nuxt/nuxt.js/issues/5028)) ([2015140](https://github.com/nuxt/nuxt.js/commit/2015140))
* **vue-renderer:** improvements ([#4722](https://github.com/nuxt/nuxt.js/issues/4722)) ([2929716](https://github.com/nuxt/nuxt.js/commit/2929716))
* .nuxtignore ([#4647](https://github.com/nuxt/nuxt.js/issues/4647)) ([59be77a](https://github.com/nuxt/nuxt.js/commit/59be77a))
* upgrade vue to 2.6 ([#4953](https://github.com/nuxt/nuxt.js/issues/4953)) ([9308954](https://github.com/nuxt/nuxt.js/commit/9308954))
### Performance Improvements
* await routeData promises in parallel ([#5027](https://github.com/nuxt/nuxt.js/issues/5027)) ([0826d7e](https://github.com/nuxt/nuxt.js/commit/0826d7e))
## [2.4.4](https://github.com/nuxt/nuxt.js/compare/v2.4.3...v2.4.4) (2019-02-26)

@@ -8,0 +44,0 @@

8

dist/vue-app.js
/*!
* @nuxt/vue-app v2.4.5 (c) 2016-2019
* @nuxt/vue-app v2.5.0 (c) 2016-2019

@@ -17,7 +17,9 @@ * - All the amazing contributors

var dependencies = {
vue: "^2.5.22",
"node-fetch": "^2.3.0",
unfetch: "^4.1.0",
vue: "^2.6.10",
"vue-meta": "^1.5.8",
"vue-no-ssr": "^1.1.1",
"vue-router": "^3.0.2",
"vue-template-compiler": "^2.5.22",
"vue-template-compiler": "^2.6.10",
vuex: "^3.1.0"

@@ -24,0 +26,0 @@ };

{
"name": "@nuxt/vue-app",
"version": "2.4.5",
"version": "2.5.0",
"repository": "nuxt/nuxt.js",

@@ -15,7 +15,9 @@ "license": "MIT",

"dependencies": {
"vue": "^2.5.22",
"node-fetch": "^2.3.0",
"unfetch": "^4.1.0",
"vue": "^2.6.10",
"vue-meta": "^1.5.8",
"vue-no-ssr": "^1.1.1",
"vue-router": "^3.0.2",
"vue-template-compiler": "^2.5.22",
"vue-template-compiler": "^2.6.10",
"vuex": "^3.1.0"

@@ -22,0 +24,0 @@ },

import Vue from 'vue'
<% if (fetch.client) { %>import fetch from 'unfetch'<% } %>
import middleware from './middleware.js'

@@ -25,2 +26,4 @@ import {

<% if (fetch.client) { %>if (!global.fetch) { global.fetch = fetch }<% } %>
// Global shared references

@@ -82,4 +85,5 @@ let _lastPaths = []

.catch((err) => {
err.message = '[nuxt] Error while mounting app: ' + err.message
errorHandler(err)
const wrapperError = new Error(err)
wrapperError.message = '[nuxt] Error while mounting app: ' + wrapperError.message
errorHandler(wrapperError)
})

@@ -159,3 +163,3 @@

// This may be due to a new deployment or a network problem
if (/^Loading chunk (\d)+ failed\./.test(message)) {
if (/^Loading( CSS)? chunk (\d)+ failed\./.test(message)) {
window.location.reload(true /* skip cache */)

@@ -494,2 +498,3 @@ return // prevent error page blinking for user

Components[i] === instance.constructor &&
instance.$vnode.data.keepAlive !== true &&
typeof instance.constructor.options.data === 'function'

@@ -496,0 +501,0 @@ ) {

@@ -126,3 +126,4 @@ import Vue from 'vue'

res: ssrContext ? ssrContext.res : undefined,
beforeRenderFns: ssrContext ? ssrContext.beforeRenderFns : undefined
beforeRenderFns: ssrContext ? ssrContext.beforeRenderFns : undefined,
ssrContext
})

@@ -169,16 +170,17 @@

<%= isTest ? '/* eslint-disable camelcase */' : '' %>
<% plugins.filter(p => p.mode === 'all').forEach((plugin) => { %>
if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(app.context, inject)<% }) %>
<% if (plugins.filter(p => p.mode === 'client').length) { %>
if (process.client) {
<% plugins.filter(p => p.mode === 'client').forEach((plugin) => { %>
if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(app.context, inject)<% }) %>
}<% } %>
<% if (plugins.filter(p => p.mode === 'server').length) { %>
if (process.server) {
<% plugins.filter(p => p.mode === 'server').forEach((plugin) => { %>
if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(app.context, inject)<% }) %>
}<% } %>
<% plugins.forEach((plugin) => { %>
<% if (plugin.mode == 'client') { %>
if (process.client && typeof <%= plugin.name %> === 'function') {
await <%= plugin.name %>(app.context, inject)
}
<% } else if (plugin.mode == 'server') { %>
if (process.server && typeof <%= plugin.name %> === 'function') {
await <%= plugin.name %>(app.context, inject)
}
<% } else { %>
if (typeof <%= plugin.name %> === 'function') {
await <%= plugin.name %>(app.context, inject)
}
<% } %>
<% }) %>
<%= isTest ? '/* eslint-enable camelcase */' : '' %>

@@ -185,0 +187,0 @@

@@ -1,18 +0,8 @@

<% if (middleware) { %>
const files = require.context('@/<%= dir.middleware %>', false, /^\.\/(?!<%= ignorePrefix %>)[^.]+\.(<%= extensions %>)$/)
const filenames = files.keys()
function getModule(filename) {
const file = files(filename)
return file.default || file
}
const middleware = {}
// Generate the middleware
for (const filename of filenames) {
const name = filename.replace(/^\.\//, '').replace(/\.(<%= extensions %>)$/, '')
middleware[name] = getModule(filename)
}
<% middleware.forEach(m => {
const name = m.src.replace(new RegExp(`\\.(${extensions})$`), '')
%>
middleware['<%= name %>'] = require('@/<%= dir.middleware %>/<%= m.src %>');
middleware['<%= name %>'] = middleware['<%= name %>'].default || middleware['<%= name %>']
<% }) %>
export default middleware
<% } else { %>export default {}<% } %>

@@ -6,3 +6,3 @@ import Vue from 'vue'

<% function recursiveRoutes(routes, tab, components, indentCount) {
let res = '', resMap = ''
let res = ''
const baseIndent = tab.repeat(indentCount)

@@ -12,2 +12,3 @@ const firstIndent = '\n' + tab.repeat(indentCount + 1)

routes.forEach((route, i) => {
let resMap = ''
// If need to handle named views

@@ -158,3 +159,3 @@ if (route.components) {

mode: '<%= router.mode %>',
base: '<%= router.base %>',
base: decodeURI('<%= router.base %>'),
linkActiveClass: '<%= router.linkActiveClass %>',

@@ -161,0 +162,0 @@ linkExactActiveClass: '<%= router.linkExactActiveClass %>',

import { stringify } from 'querystring'
import Vue from 'vue'
<% if (fetch.server) { %>import fetch from 'node-fetch'<% } %>
import middleware from './middleware.js'

@@ -12,2 +13,4 @@ import { applyAsyncData, getMatchedComponents, middlewareSeries, promisify, urlJoin, sanitizeComponent } from './utils.js'

<% if (fetch.server) { %>if (!global.fetch) { global.fetch = fetch }<% } %>
const debug = require('debug')('nuxt:render')

@@ -14,0 +17,0 @@ debug.color = 4 // force blue color

@@ -9,30 +9,14 @@ import Vue from 'vue'

let store = {}
let fileResolver
void (function updateModules() {
fileResolver = require.context('@/<%= dir.store %>', true, /^\.\/(?!<%= ignorePrefix %>)[^.]+\.(<%= extensions %>)$/)
<% storeModules.some(s => {
if(s.src.indexOf('index.') === 0) { %>
store = normalizeRoot(require('@/<%= dir.store %>/<%= s.src %>'), '<%= dir.store %>/<%= s.src %>')
<% return true }}) %>
// Paths are sorted from low to high priority (for overwriting properties)
const paths = fileResolver.keys().sort((p1, p2) => {
let res = p1.split('/').length - p2.split('/').length
if (res === 0 && p1.includes('/index.')) {
res = -1
} else if (res === 0 && p2.includes('/index.')) {
res = 1
}
return res
})
// Check if {dir.store}/index.js exists
const indexPath = paths.find(path => path.includes('./index.'))
if (indexPath) {
store = requireModule(indexPath, { isRoot: true })
}
// If store is an exported method = classic mode (deprecated)
<% if (isDev) { %>
if (typeof store === 'function') {
return log.warn('Classic mode for store/ is deprecated and will be removed in Nuxt 3.')
}
}<% } %>

@@ -42,38 +26,6 @@ // Enforce store modules

for (const path of paths) {
// Remove store path + extension (./foo/index.js -> foo/index)
const namespace = path.replace(/^\.\//, '').replace(/\.(<%= extensions %>)$/, '')
<% storeModules.forEach(s => {
if(s.src.indexOf('index.') !== 0) { %>
resolveStoreModules(require('@/<%= dir.store %>/<%= s.src %>'), '<%= s.src %>')<% }}) %>
// Ignore indexFile, handled before
if (namespace === 'index') {
continue
}
const namespaces = namespace.split('/')
let moduleName = namespaces[namespaces.length - 1]
const moduleData = requireModule(path, { isState: moduleName === 'state' })
// If path is a known Vuex property
if (VUEX_PROPERTIES.includes(moduleName)) {
const property = moduleName
const storeModule = getStoreModule(store, namespaces, { isProperty: true })
// Replace state since it's a function
mergeProperty(storeModule, moduleData, property)
continue
}
// If file is foo/index.js, it should be saved as foo
const isIndexModule = (moduleName === 'index')
if (isIndexModule) {
namespaces.pop()
moduleName = namespaces[namespaces.length - 1]
}
const storeModule = getStoreModule(store, namespaces)
for (const property of VUEX_PROPERTIES) {
mergeProperty(storeModule, moduleData[property], property)
}
}
// If the environment supports hot reloading...

@@ -83,3 +35,5 @@ <% if (isDev) { %>

// Whenever any Vuex module is updated...
module.hot.accept(fileResolver.id, () => {
module.hot.accept([<% storeModules.forEach(s => { %>
'@/<%= dir.store %>/<%= s.src %>',<% }) %>
], () => {
// Update `root.modules` with the latest definitions.

@@ -100,22 +54,68 @@ updateModules()

// Dynamically require module
function requireModule(path, { isRoot = false, isState = false } = {}) {
const file = fileResolver(path)
let moduleData = file.default || file
function resolveStoreModules(moduleData, filename) {
moduleData = moduleData.default || moduleData
// Remove store src + extension (./foo/index.js -> foo/index)
const namespace = filename.replace(/\.(<%= extensions %>)$/, '')
const namespaces = namespace.split('/')
let moduleName = namespaces[namespaces.length - 1]
const filePath = `<%= dir.store %>/${filename}`
if (isState && typeof moduleData !== 'function') {
log.warn(`${path} should export a method that returns an object`)
const state = Object.assign({}, moduleData)
return () => state
moduleData = moduleName === 'state'
? normalizeState(moduleData, filePath)
: normalizeModule(moduleData, filePath)
// If src is a known Vuex property
if (VUEX_PROPERTIES.includes(moduleName)) {
const property = moduleName
const storeModule = getStoreModule(store, namespaces, { isProperty: true })
// Replace state since it's a function
mergeProperty(storeModule, moduleData, property)
return
}
if (isRoot && moduleData.commit) {
throw new Error('[nuxt] <%= dir.store %>/' + path.replace('./', '') + ' should export a method that returns a Vuex instance.')
// If file is foo/index.js, it should be saved as foo
const isIndexModule = (moduleName === 'index')
if (isIndexModule) {
namespaces.pop()
moduleName = namespaces[namespaces.length - 1]
}
if (isRoot && typeof moduleData !== 'function') {
const storeModule = getStoreModule(store, namespaces)
for (const property of VUEX_PROPERTIES) {
mergeProperty(storeModule, moduleData[property], property)
}
if (moduleData.namespaced === false) {
delete storeModule.namespaced
}
}
function normalizeRoot(moduleData, filePath) {
moduleData = moduleData.default || moduleData
if (moduleData.commit) {
throw new Error(`[nuxt] ${filePath} should export a method that returns a Vuex instance.`)
}
if (typeof moduleData !== 'function') {
// Avoid TypeError: setting a property that has only a getter when overwriting top level keys
moduleData = Object.assign({}, moduleData)
}
return normalizeModule(moduleData, filePath)
}
function normalizeState(moduleData, filePath) {
if (typeof moduleData !== 'function') {
log.warn(`${filePath} should export a method that returns an object`)
const state = Object.assign({}, moduleData)
return () => state
}
return normalizeModule(moduleData, filePath)
}
function normalizeModule(moduleData, filePath) {
if (moduleData.state && typeof moduleData.state !== 'function') {
log.warn(`'state' should be a method that returns an object in ${path}`)
log.warn(`'state' should be a method that returns an object in ${filePath}`)
const state = Object.assign({}, moduleData.state)

@@ -122,0 +122,0 @@ // Avoid TypeError: setting a property that has only a getter when overwriting top level keys

@@ -115,2 +115,5 @@ import Vue from 'vue'

export async function getRouteData(route) {
if (!route) {
return
}
// Make sure the components are resolved (code-splitting)

@@ -142,4 +145,11 @@ await resolveRouteComponents(route)

// Only set once
if (context.req) app.context.req = context.req
if (context.res) app.context.res = context.res
if (context.req) {
app.context.req = context.req
}
if (context.res) {
app.context.res = context.res
}
if (context.ssrContext) {
app.context.ssrContext = context.ssrContext
}
app.context.redirect = (status, path, query) => {

@@ -159,3 +169,3 @@ if (!status) {

if (pathType === 'object') {
path = app.router.resolve(path).href
path = app.router.resolve(path).route.fullPath
}

@@ -193,3 +203,17 @@ // "/absolute/route", "./relative/route" or "../relative/route"

}
// Dynamic keys
const [currentRouteData, fromRouteData] = await Promise.all([
getRouteData(context.route),
getRouteData(context.from)
])
if (context.route) {
app.context.route = currentRouteData
}
if (context.from) {
app.context.from = fromRouteData
}
app.context.next = context.next

@@ -199,10 +223,4 @@ app.context._redirected = false

app.context.isHMR = !!context.isHMR
if (context.route) {
app.context.route = await getRouteData(context.route)
}
app.context.params = app.context.route.params || {}
app.context.query = app.context.route.query || {}
if (context.from) {
app.context.from = await getRouteData(context.from)
}
}

@@ -209,0 +227,0 @@

@@ -1,34 +0,44 @@

import Vue from "vue";
import VueRouter, { Route } from "vue-router";
import { Store } from "vuex";
import Vue from 'vue'
import VueRouter, { Route } from 'vue-router'
import { Store } from 'vuex'
// augment typings of NodeJS.Process
import "./process";
import './process'
// augment typings of Vue.js
import "./vue";
import './vue'
type Dictionary<T> = { [key: string]: T };
type Dictionary<T> = { [key: string]: T }
type NuxtState = Dictionary<any>;
type NuxtState = Dictionary<any>
export interface Context {
app: Vue;
app: Vue
/**
* @deprecated Use process.client instead
*/
isClient: boolean;
/**
* @deprecated Use process.server instead
*/
isServer: boolean;
/**
* @deprecated Use process.static instead
*/
isStatic: boolean;
isDev: boolean;
isHMR: boolean;
route: Route;
store: Store<any>;
env: Dictionary<any>;
params: Route['params'];
query: Route['query'];
req: Request;
res: Response;
redirect(status: number, path: string, query?: Route['query']): void;
redirect(path: string, query?: Route['query']): void;
error(params: ErrorParams): void;
nuxtState: NuxtState;
beforeNuxtRender(fn: (params: { Components: VueRouter['getMatchedComponents'], nuxtState: NuxtState }) => void): void
isDev: boolean
isHMR: boolean
route: Route
store: Store<any>
env: Dictionary<any>
params: Route['params']
payload: any
query: Route['query']
req: Request
res: Response
redirect (status: number, path: string, query?: Route['query']): void
redirect (path: string, query?: Route['query']): void
error (params: ErrorParams): void
nuxtState: NuxtState
beforeNuxtRender (fn: (params: { Components: VueRouter['getMatchedComponents'], nuxtState: NuxtState }) => void): void
}

@@ -39,40 +49,40 @@

export interface Transition {
name?: string;
mode?: string;
css?: boolean;
duration?: number;
type?: string;
enterClass?: string;
enterToClass?: string;
enterActiveClass?: string;
leaveClass?: string;
leaveToClass?: string;
leaveActiveClass?: string;
beforeEnter?(el: HTMLElement): void;
enter?(el: HTMLElement, done: Function): void;
afterEnter?(el: HTMLElement): void;
enterCancelled?(el: HTMLElement): void;
beforeLeave?(el: HTMLElement): void;
leave?(el: HTMLElement, done: Function): void;
afterLeave?(el: HTMLElement): void;
leaveCancelled?(el: HTMLElement): void;
name?: string
mode?: string
css?: boolean
duration?: number
type?: string
enterClass?: string
enterToClass?: string
enterActiveClass?: string
leaveClass?: string
leaveToClass?: string
leaveActiveClass?: string
beforeEnter?(el: HTMLElement): void
enter?(el: HTMLElement, done: Function): void
afterEnter?(el: HTMLElement): void
enterCancelled?(el: HTMLElement): void
beforeLeave?(el: HTMLElement): void
leave?(el: HTMLElement, done: Function): void
afterLeave?(el: HTMLElement): void
leaveCancelled?(el: HTMLElement): void
}
export interface ErrorParams {
statusCode?: number;
message?: string;
statusCode?: number
message?: string
}
export interface NuxtLoading extends Vue {
fail?(): NuxtLoading;
finish(): NuxtLoading;
increase?(num: number): NuxtLoading;
pause?(): NuxtLoading;
start(): NuxtLoading;
fail?(): NuxtLoading
finish(): NuxtLoading
increase?(num: number): NuxtLoading
pause?(): NuxtLoading
start(): NuxtLoading
}
export interface NuxtApp extends Vue {
$loading: NuxtLoading;
isOffline: boolean;
isOnline: boolean;
$loading: NuxtLoading
isOffline: boolean
isOnline: boolean
}

@@ -7,9 +7,9 @@ /**

interface Process {
browser: boolean;
client: boolean;
mode: 'universal' | 'spa';
modern: boolean;
server: boolean;
static: boolean;
browser: boolean
client: boolean
mode: 'spa' | 'universal'
modern: boolean
server: boolean
static: boolean
}
}

@@ -5,27 +5,27 @@ /**

import Vue, { ComponentOptions } from "vue";
import { Route } from "vue-router";
import { MetaInfo } from "vue-meta";
import { Context, Middleware, Transition, NuxtApp } from "./index";
import Vue, { ComponentOptions } from 'vue'
import { Route } from 'vue-router'
import { MetaInfo } from 'vue-meta'
import { Context, Middleware, Transition, NuxtApp } from './index'
declare module "vue/types/options" {
declare module 'vue/types/options' {
interface ComponentOptions<V extends Vue> {
asyncData?(ctx: Context): object | undefined;
fetch?(ctx: Context): Promise<void> | void;
head?: MetaInfo | (() => MetaInfo);
key?: string | ((to: Route) => string);
layout?: string | ((ctx: Context) => string);
loading?: boolean;
middleware?: Middleware | Middleware[];
scrollToTop?: boolean;
transition?: string | Transition | ((to: Route, from: Route) => string);
validate?(ctx: Context): Promise<boolean> | boolean;
watchQuery?: boolean | string[];
asyncData?(ctx: Context): object | undefined
fetch?(ctx: Context): Promise<void> | void
head?: MetaInfo | (() => MetaInfo)
key?: string | ((to: Route) => string)
layout?: string | ((ctx: Context) => string)
loading?: boolean
middleware?: Middleware | Middleware[]
scrollToTop?: boolean
transition?: string | Transition | ((to: Route, from: Route) => string)
validate?(ctx: Context): Promise<boolean> | boolean
watchQuery?: boolean | string[]
}
}
declare module "vue/types/vue" {
declare module 'vue/types/vue' {
interface Vue {
$nuxt: NuxtApp;
$nuxt: NuxtApp
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc