@vue/server-renderer
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -492,2 +492,238 @@ 'use strict'; | ||
function toRaw(observed) { | ||
return ((observed && toRaw(observed["__v_raw" /* RAW */])) || observed); | ||
} | ||
function isRef(r) { | ||
return Boolean(r && r.__v_isRef === true); | ||
} | ||
const stack = []; | ||
function pushWarningContext(vnode) { | ||
stack.push(vnode); | ||
} | ||
function popWarningContext() { | ||
stack.pop(); | ||
} | ||
function warn(msg, ...args) { | ||
const instance = stack.length ? stack[stack.length - 1].component : null; | ||
const appWarnHandler = instance && instance.appContext.config.warnHandler; | ||
const trace = getComponentTrace(); | ||
if (appWarnHandler) { | ||
callWithErrorHandling(appWarnHandler, instance, 11 /* APP_WARN_HANDLER */, [ | ||
msg + args.join(''), | ||
instance && instance.proxy, | ||
trace | ||
.map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`) | ||
.join('\n'), | ||
trace | ||
]); | ||
} | ||
else { | ||
const warnArgs = [`[Vue warn]: ${msg}`, ...args]; | ||
/* istanbul ignore if */ | ||
if (trace.length && | ||
// avoid spamming console during tests | ||
!false) { | ||
warnArgs.push(`\n`, ...formatTrace(trace)); | ||
} | ||
console.warn(...warnArgs); | ||
} | ||
} | ||
function getComponentTrace() { | ||
let currentVNode = stack[stack.length - 1]; | ||
if (!currentVNode) { | ||
return []; | ||
} | ||
// we can't just use the stack because it will be incomplete during updates | ||
// that did not start from the root. Re-construct the parent chain using | ||
// instance parent pointers. | ||
const normalizedStack = []; | ||
while (currentVNode) { | ||
const last = normalizedStack[0]; | ||
if (last && last.vnode === currentVNode) { | ||
last.recurseCount++; | ||
} | ||
else { | ||
normalizedStack.push({ | ||
vnode: currentVNode, | ||
recurseCount: 0 | ||
}); | ||
} | ||
const parentInstance = currentVNode.component && currentVNode.component.parent; | ||
currentVNode = parentInstance && parentInstance.vnode; | ||
} | ||
return normalizedStack; | ||
} | ||
/* istanbul ignore next */ | ||
function formatTrace(trace) { | ||
const logs = []; | ||
trace.forEach((entry, i) => { | ||
logs.push(...(i === 0 ? [] : [`\n`]), ...formatTraceEntry(entry)); | ||
}); | ||
return logs; | ||
} | ||
function formatTraceEntry({ vnode, recurseCount }) { | ||
const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``; | ||
const isRoot = vnode.component ? vnode.component.parent == null : false; | ||
const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`; | ||
const close = `>` + postfix; | ||
return vnode.props | ||
? [open, ...formatProps(vnode.props), close] | ||
: [open + close]; | ||
} | ||
/* istanbul ignore next */ | ||
function formatProps(props) { | ||
const res = []; | ||
const keys = Object.keys(props); | ||
keys.slice(0, 3).forEach(key => { | ||
res.push(...formatProp(key, props[key])); | ||
}); | ||
if (keys.length > 3) { | ||
res.push(` ...`); | ||
} | ||
return res; | ||
} | ||
/* istanbul ignore next */ | ||
function formatProp(key, value, raw) { | ||
if (shared.isString(value)) { | ||
value = JSON.stringify(value); | ||
return raw ? value : [`${key}=${value}`]; | ||
} | ||
else if (typeof value === 'number' || | ||
typeof value === 'boolean' || | ||
value == null) { | ||
return raw ? value : [`${key}=${value}`]; | ||
} | ||
else if (isRef(value)) { | ||
value = formatProp(key, toRaw(value.value), true); | ||
return raw ? value : [`${key}=Ref<`, value, `>`]; | ||
} | ||
else if (shared.isFunction(value)) { | ||
return [`${key}=fn${value.name ? `<${value.name}>` : ``}`]; | ||
} | ||
else { | ||
value = toRaw(value); | ||
return raw ? value : [`${key}=`, value]; | ||
} | ||
} | ||
const ErrorTypeStrings = { | ||
["bc" /* BEFORE_CREATE */]: 'beforeCreate hook', | ||
["c" /* CREATED */]: 'created hook', | ||
["bm" /* BEFORE_MOUNT */]: 'beforeMount hook', | ||
["m" /* MOUNTED */]: 'mounted hook', | ||
["bu" /* BEFORE_UPDATE */]: 'beforeUpdate hook', | ||
["u" /* UPDATED */]: 'updated', | ||
["bum" /* BEFORE_UNMOUNT */]: 'beforeUnmount hook', | ||
["um" /* UNMOUNTED */]: 'unmounted hook', | ||
["a" /* ACTIVATED */]: 'activated hook', | ||
["da" /* DEACTIVATED */]: 'deactivated hook', | ||
["ec" /* ERROR_CAPTURED */]: 'errorCaptured hook', | ||
["rtc" /* RENDER_TRACKED */]: 'renderTracked hook', | ||
["rtg" /* RENDER_TRIGGERED */]: 'renderTriggered hook', | ||
[0 /* SETUP_FUNCTION */]: 'setup function', | ||
[1 /* RENDER_FUNCTION */]: 'render function', | ||
[2 /* WATCH_GETTER */]: 'watcher getter', | ||
[3 /* WATCH_CALLBACK */]: 'watcher callback', | ||
[4 /* WATCH_CLEANUP */]: 'watcher cleanup function', | ||
[5 /* NATIVE_EVENT_HANDLER */]: 'native event handler', | ||
[6 /* COMPONENT_EVENT_HANDLER */]: 'component event handler', | ||
[7 /* VNODE_HOOK */]: 'vnode hook', | ||
[8 /* DIRECTIVE_HOOK */]: 'directive hook', | ||
[9 /* TRANSITION_HOOK */]: 'transition hook', | ||
[10 /* APP_ERROR_HANDLER */]: 'app errorHandler', | ||
[11 /* APP_WARN_HANDLER */]: 'app warnHandler', | ||
[12 /* FUNCTION_REF */]: 'ref function', | ||
[13 /* ASYNC_COMPONENT_LOADER */]: 'async component loader', | ||
[14 /* SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' + | ||
'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/vue-next' | ||
}; | ||
function callWithErrorHandling(fn, instance, type, args) { | ||
let res; | ||
try { | ||
res = args ? fn(...args) : fn(); | ||
} | ||
catch (err) { | ||
handleError(err, instance, type); | ||
} | ||
return res; | ||
} | ||
function handleError(err, instance, type, throwInDev = true) { | ||
const contextVNode = instance ? instance.vnode : null; | ||
if (instance) { | ||
let cur = instance.parent; | ||
// the exposed instance is the render proxy to keep it consistent with 2.x | ||
const exposedInstance = instance.proxy; | ||
// in production the hook receives only the error code | ||
const errorInfo = ErrorTypeStrings[type] ; | ||
while (cur) { | ||
const errorCapturedHooks = cur.ec; | ||
if (errorCapturedHooks) { | ||
for (let i = 0; i < errorCapturedHooks.length; i++) { | ||
if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) { | ||
return; | ||
} | ||
} | ||
} | ||
cur = cur.parent; | ||
} | ||
// app-level handling | ||
const appErrorHandler = instance.appContext.config.errorHandler; | ||
if (appErrorHandler) { | ||
callWithErrorHandling(appErrorHandler, null, 10 /* APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]); | ||
return; | ||
} | ||
} | ||
logError(err, type, contextVNode, throwInDev); | ||
} | ||
function logError(err, type, contextVNode, throwInDev = true) { | ||
{ | ||
const info = ErrorTypeStrings[type]; | ||
if (contextVNode) { | ||
pushWarningContext(contextVNode); | ||
} | ||
warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`); | ||
if (contextVNode) { | ||
popWarningContext(); | ||
} | ||
// crash in dev by default so it's more noticeable | ||
if (throwInDev) { | ||
throw err; | ||
} | ||
else { | ||
console.error(err); | ||
} | ||
} | ||
} | ||
const classifyRE = /(?:^|[-_])(\w)/g; | ||
const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, ''); | ||
/* istanbul ignore next */ | ||
function formatComponentName(instance, Component, isRoot = false) { | ||
let name = shared.isFunction(Component) | ||
? Component.displayName || Component.name | ||
: Component.name; | ||
if (!name && Component.__file) { | ||
const match = Component.__file.match(/([^/\\]+)\.vue$/); | ||
if (match) { | ||
name = match[1]; | ||
} | ||
} | ||
if (!name && instance && instance.parent) { | ||
// try to infer the name based on reverse resolution | ||
const inferFromRegistry = (registry) => { | ||
for (const key in registry) { | ||
if (registry[key] === Component) { | ||
return key; | ||
} | ||
} | ||
}; | ||
name = | ||
inferFromRegistry(instance.components || | ||
instance.parent.type.components) || inferFromRegistry(instance.appContext.components); | ||
} | ||
return name ? classify(name) : isRoot ? `App` : `Anonymous`; | ||
} | ||
function ssrRenderList(source, renderItem) { | ||
@@ -500,2 +736,6 @@ if (shared.isArray(source) || shared.isString(source)) { | ||
else if (typeof source === 'number') { | ||
if ( !Number.isInteger(source)) { | ||
warn(`The v-for range expect an integer value but got ${source}.`); | ||
return; | ||
} | ||
for (let i = 0; i < source; i++) { | ||
@@ -502,0 +742,0 @@ renderItem(i + 1, i); |
{ | ||
"name": "@vue/server-renderer", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "@vue/server-renderer", | ||
@@ -31,8 +31,8 @@ "main": "index.js", | ||
"peerDependencies": { | ||
"vue": "3.0.0" | ||
"vue": "3.0.1" | ||
}, | ||
"dependencies": { | ||
"@vue/shared": "3.0.0", | ||
"@vue/compiler-ssr": "3.0.0" | ||
"@vue/shared": "3.0.1", | ||
"@vue/compiler-ssr": "3.0.1" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56003
1442
+ Added@vue/compiler-core@3.0.1(transitive)
+ Added@vue/compiler-dom@3.0.1(transitive)
+ Added@vue/compiler-ssr@3.0.1(transitive)
+ Added@vue/reactivity@3.0.1(transitive)
+ Added@vue/runtime-core@3.0.1(transitive)
+ Added@vue/runtime-dom@3.0.1(transitive)
+ Added@vue/shared@3.0.1(transitive)
+ Addedvue@3.0.1(transitive)
- Removed@vue/compiler-core@3.0.0(transitive)
- Removed@vue/compiler-dom@3.0.0(transitive)
- Removed@vue/compiler-ssr@3.0.0(transitive)
- Removed@vue/reactivity@3.0.0(transitive)
- Removed@vue/runtime-core@3.0.0(transitive)
- Removed@vue/runtime-dom@3.0.0(transitive)
- Removed@vue/shared@3.0.0(transitive)
- Removedvue@3.0.0(transitive)
Updated@vue/compiler-ssr@3.0.1
Updated@vue/shared@3.0.1