chore:更换到主分支

This commit is contained in:
张益铭
2021-03-01 15:26:05 +08:00
parent 9064b372e8
commit 6a5f1810f9
3530 changed files with 59613 additions and 479452 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -3,9 +3,9 @@ import { ParserPlugin } from '@babel/parser';
import { RawSourceMap } from 'source-map';
import { SourceMapGenerator } from 'source-map';
export declare function advancePositionWithClone(pos: Position_2, source: string, numberOfCharacters?: number): Position_2;
export declare function advancePositionWithClone(pos: Position, source: string, numberOfCharacters?: number): Position;
export declare function advancePositionWithMutation(pos: Position_2, source: string, numberOfCharacters?: number): Position_2;
export declare function advancePositionWithMutation(pos: Position, source: string, numberOfCharacters?: number): Position;
export declare interface ArrayExpression extends Node_2 {
type: NodeTypes.JS_ARRAY_EXPRESSION;
@@ -43,7 +43,40 @@ export declare interface BaseElementNode extends Node_2 {
export declare function baseParse(content: string, options?: ParserOptions): RootNode;
export declare interface BindingMetadata {
[key: string]: 'data' | 'props' | 'setup' | 'options';
[key: string]: BindingTypes | undefined;
}
export declare const enum BindingTypes {
/**
* returned from data()
*/
DATA = "data",
/**
* decalred as a prop
*/
PROPS = "props",
/**
* a let binding (may or may not be a ref)
*/
SETUP_LET = "setup-let",
/**
* a const binding that can never be a ref.
* these bindings don't need `unref()` calls when processed in inlined
* template expressions.
*/
SETUP_CONST = "setup-const",
/**
* a const binding that may be a ref.
*/
SETUP_MAYBE_REF = "setup-maybe-ref",
/**
* bindings that are guaranteed to be refs
*/
SETUP_REF = "setup-ref",
/**
* declared by other options, e.g. computed, inject
*/
OPTIONS = "options"
}
export declare type BlockCodegenNode = VNodeCall | RenderSlotCall;
@@ -82,7 +115,7 @@ export declare const CAMELIZE: unique symbol;
export declare const CAPITALIZE: unique symbol;
export declare interface CodegenContext extends Omit<Required<CodegenOptions>, 'bindingMetadata'> {
export declare interface CodegenContext extends Omit<Required<CodegenOptions>, 'bindingMetadata' | 'inline' | 'isTS'> {
source: string;
code: string;
line: number;
@@ -100,7 +133,7 @@ export declare interface CodegenContext extends Omit<Required<CodegenOptions>, '
declare type CodegenNode = TemplateChildNode | JSChildNode | SSRCodegenNode;
export declare interface CodegenOptions {
export declare interface CodegenOptions extends SharedTransformCodegenOptions {
/**
* - `module` mode will generate ES module import statements for helpers
* and export the render function as the default export.
@@ -116,11 +149,6 @@ export declare interface CodegenOptions {
* @default false
*/
sourceMap?: boolean;
/**
* Filename for source map generation.
* @default 'template.vue.html'
*/
filename?: string;
/**
* SFC scoped styles ID
*/
@@ -142,13 +170,11 @@ export declare interface CodegenOptions {
* @default 'Vue'
*/
runtimeGlobalName?: string;
prefixIdentifiers?: boolean;
bindingMetadata?: BindingMetadata;
ssr?: boolean;
}
export declare interface CodegenResult {
code: string;
preamble: string;
ast: RootNode;
map?: RawSourceMap;
}
@@ -194,6 +220,18 @@ export declare interface ConditionalExpression extends Node_2 {
newline: boolean;
}
/**
* Static types have several levels.
* Higher levels implies lower levels. e.g. a node that can be stringified
* can always be hoisted and skipped for patch.
*/
export declare const enum ConstantTypes {
NOT_CONSTANT = 0,
CAN_SKIP_PATCH = 1,
CAN_HOIST = 2,
CAN_STRINGIFY = 3
}
export declare interface CoreCompilerError extends CompilerError {
code: ErrorCodes;
}
@@ -246,13 +284,13 @@ export declare function createRoot(children: TemplateChildNode[], loc?: SourceLo
export declare function createSequenceExpression(expressions: SequenceExpression['expressions']): SequenceExpression;
export declare function createSimpleExpression(content: SimpleExpressionNode['content'], isStatic: SimpleExpressionNode['isStatic'], loc?: SourceLocation, isConstant?: boolean): SimpleExpressionNode;
export declare function createSimpleExpression(content: SimpleExpressionNode['content'], isStatic: SimpleExpressionNode['isStatic'], loc?: SourceLocation, constType?: ConstantTypes): SimpleExpressionNode;
export declare function createStructuralDirectiveTransform(name: string | RegExp, fn: StructuralDirectiveTransform): NodeTransform;
export declare function createTemplateLiteral(elements: TemplateLiteral['elements']): TemplateLiteral;
export declare function createTransformContext(root: RootNode, { prefixIdentifiers, hoistStatic, cacheHandlers, nodeTransforms, directiveTransforms, transformHoist, isBuiltInComponent, isCustomElement, expressionPlugins, scopeId, ssr, ssrCssVars, bindingMetadata, onError }: TransformOptions): TransformContext;
export declare function createTransformContext(root: RootNode, { filename, prefixIdentifiers, hoistStatic, cacheHandlers, nodeTransforms, directiveTransforms, transformHoist, isBuiltInComponent, isCustomElement, expressionPlugins, scopeId, ssr, ssrCssVars, bindingMetadata, inline, isTS, onError }: TransformOptions): TransformContext;
export declare function createVNodeCall(context: TransformContext | null, tag: VNodeCall['tag'], props?: VNodeCall['props'], children?: VNodeCall['children'], patchFlag?: VNodeCall['patchFlag'], dynamicProps?: VNodeCall['dynamicProps'], directives?: VNodeCall['directives'], isBlock?: VNodeCall['isBlock'], disableTracking?: VNodeCall['disableTracking'], loc?: SourceLocation): VNodeCall;
@@ -476,6 +514,8 @@ export declare interface InterpolationNode extends Node_2 {
content: ExpressionNode;
}
export declare const IS_REF: unique symbol;
export declare function isBindKey(arg: DirectiveNode['arg'], name: string): boolean;
export declare const isBuiltInType: (tag: string, expected: string) => boolean;
@@ -621,12 +661,11 @@ export declare interface PlainElementNode extends BaseElementNode {
export declare const POP_SCOPE_ID: unique symbol;
declare interface Position_2 {
export declare interface Position {
offset: number;
line: number;
column: number;
}
export { Position_2 as Position }
export declare function processExpression(node: SimpleExpressionNode, context: TransformContext, asParams?: boolean, asRawStatements?: boolean): ExpressionNode;
@@ -696,11 +735,49 @@ export declare interface SequenceExpression extends Node_2 {
export declare const SET_BLOCK_TRACKING: unique symbol;
declare interface SharedTransformCodegenOptions {
/**
* Transform expressions like {{ foo }} to `_ctx.foo`.
* If this option is false, the generated code will be wrapped in a
* `with (this) { ... }` block.
* - This is force-enabled in module mode, since modules are by default strict
* and cannot use `with`
* @default mode === 'module'
*/
prefixIdentifiers?: boolean;
/**
* Generate SSR-optimized render functions instead.
* The resulting function must be attached to the component via the
* `ssrRender` option instead of `render`.
*/
ssr?: boolean;
/**
* Optional binding metadata analyzed from script - used to optimize
* binding access when `prefixIdentifiers` is enabled.
*/
bindingMetadata?: BindingMetadata;
/**
* Compile the function for inlining inside setup().
* This allows the function to directly access setup() local bindings.
*/
inline?: boolean;
/**
* Indicates that transforms and codegen should try to output valid TS code
*/
isTS?: boolean;
/**
* Filename for source map generation.
* Also used for self-recursive reference in templates
* @default 'template.vue.html'
*/
filename?: string;
}
export declare interface SimpleExpressionNode extends Node_2 {
type: NodeTypes.SIMPLE_EXPRESSION;
content: string;
isStatic: boolean;
isConstant: boolean;
constType: ConstantTypes;
/**
* Indicates this is an identifier for a hoist vnode call and points to the
* hoisted node.
@@ -711,11 +788,6 @@ export declare interface SimpleExpressionNode extends Node_2 {
* the identifiers declared inside the function body.
*/
identifiers?: string[];
/**
* some expressions (e.g. transformAssetUrls import identifiers) are constant,
* but cannot be stringified because they must be first evaluated at runtime.
*/
isRuntimeConstant?: boolean;
}
export declare type SlotFnBuilder = (slotProps: ExpressionNode | undefined, slotChildren: TemplateChildNode[], loc: SourceLocation) => FunctionExpression;
@@ -746,8 +818,8 @@ export declare interface SlotsObjectProperty extends Property {
}
export declare interface SourceLocation {
start: Position_2;
end: Position_2;
start: Position;
end: Position;
source: string;
}
@@ -808,13 +880,14 @@ export declare function transform(root: RootNode, options: TransformOptions): vo
export declare const transformBind: DirectiveTransform;
export declare interface TransformContext extends Required<TransformOptions> {
export declare interface TransformContext extends Required<Omit<TransformOptions, 'filename'>> {
selfName: string | null;
root: RootNode;
helpers: Set<symbol>;
components: Set<string>;
directives: Set<string>;
hoists: (JSChildNode | null)[];
imports: Set<ImportItem>;
imports: ImportItem[];
temps: number;
cached: number;
identifiers: {
@@ -838,6 +911,7 @@ export declare interface TransformContext extends Required<TransformOptions> {
removeIdentifiers(exp: ExpressionNode | string): void;
hoist(exp: JSChildNode): SimpleExpressionNode;
cache<T extends JSChildNode>(exp: T, isVNode?: boolean): CacheExpression | T;
constantCache: Map<TemplateChildNode, ConstantTypes>;
}
export declare const transformElement: NodeTransform;
@@ -848,7 +922,7 @@ export declare const transformModel: DirectiveTransform;
export declare const transformOn: DirectiveTransform;
export declare interface TransformOptions {
export declare interface TransformOptions extends SharedTransformCodegenOptions {
/**
* An array of node transforms to be applied to every AST node.
*/
@@ -911,22 +985,12 @@ export declare interface TransformOptions {
* SFC scoped styles ID
*/
scopeId?: string | null;
/**
* Generate SSR-optimized render functions instead.
* The resulting function must be attached to the component via the
* `ssrRender` option instead of `render`.
*/
ssr?: boolean;
/**
* SFC `<style vars>` injection string
* Should already be an object expression, e.g. `{ 'xxxx-color': color }`
* needed to render inline CSS variables on component root
*/
ssrCssVars?: string;
/**
* Optional binding metadata analyzed from script - used to optimize
* binding access when `prefixIdentifiers` is enabled.
*/
bindingMetadata?: BindingMetadata;
onError?: (error: CompilerError) => void;
}
@@ -937,6 +1001,8 @@ export declare type TransformPreset = [
export declare function traverseNode(node: RootNode | TemplateChildNode, context: TransformContext): void;
export declare const UNREF: unique symbol;
export declare interface VNodeCall extends Node_2 {
type: NodeTypes.VNODE_CALL;
tag: string | symbol | CallExpression;

File diff suppressed because it is too large Load Diff

View File

@@ -1,34 +1,33 @@
{
"_args": [
[
"@vue/compiler-core@3.0.2",
"@vue/compiler-core@3.0.6",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "@vue/compiler-core@3.0.2",
"_id": "@vue/compiler-core@3.0.2",
"_from": "@vue/compiler-core@3.0.6",
"_id": "@vue/compiler-core@3.0.6",
"_inBundle": false,
"_integrity": "sha1-d5C3ofy7pazk2BpwzlkJb6XJVzQ=",
"_integrity": "sha1-Jlu+BxGoGrTBNE+ClOIuLQjKFn0=",
"_location": "/@vue/compiler-core",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@vue/compiler-core@3.0.2",
"raw": "@vue/compiler-core@3.0.6",
"name": "@vue/compiler-core",
"escapedName": "@vue%2fcompiler-core",
"scope": "@vue",
"rawSpec": "3.0.2",
"rawSpec": "3.0.6",
"saveSpec": null,
"fetchSpec": "3.0.2"
"fetchSpec": "3.0.6"
},
"_requiredBy": [
"/@vue/compiler-dom",
"/@vue/compiler-sfc"
],
"_resolved": "http://192.168.250.101:4873/@vue%2fcompiler-core/-/compiler-core-3.0.2.tgz",
"_spec": "3.0.2",
"_resolved": "http://192.168.250.101:4873/@vue%2fcompiler-core/-/compiler-core-3.0.6.tgz",
"_spec": "3.0.6",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Evan You"
@@ -46,7 +45,7 @@
"dependencies": {
"@babel/parser": "^7.12.0",
"@babel/types": "^7.12.0",
"@vue/shared": "3.0.2",
"@vue/shared": "3.0.6",
"estree-walker": "^2.0.1",
"source-map": "^0.6.1"
},
@@ -69,5 +68,5 @@
"directory": "packages/compiler-core"
},
"types": "dist/compiler-core.d.ts",
"version": "3.0.2"
"version": "3.0.6"
}

View File

@@ -5,16 +5,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
var compilerCore = require('@vue/compiler-core');
var shared = require('@vue/shared');
const V_MODEL_RADIO = Symbol( `vModelRadio` );
const V_MODEL_CHECKBOX = Symbol( `vModelCheckbox` );
const V_MODEL_TEXT = Symbol( `vModelText` );
const V_MODEL_SELECT = Symbol( `vModelSelect` );
const V_MODEL_DYNAMIC = Symbol( `vModelDynamic` );
const V_ON_WITH_MODIFIERS = Symbol( `vOnModifiersGuard` );
const V_ON_WITH_KEYS = Symbol( `vOnKeysGuard` );
const V_SHOW = Symbol( `vShow` );
const TRANSITION = Symbol( `Transition` );
const TRANSITION_GROUP = Symbol( `TransitionGroup` );
const V_MODEL_RADIO = Symbol(`vModelRadio` );
const V_MODEL_CHECKBOX = Symbol(`vModelCheckbox` );
const V_MODEL_TEXT = Symbol(`vModelText` );
const V_MODEL_SELECT = Symbol(`vModelSelect` );
const V_MODEL_DYNAMIC = Symbol(`vModelDynamic` );
const V_ON_WITH_MODIFIERS = Symbol(`vOnModifiersGuard` );
const V_ON_WITH_KEYS = Symbol(`vOnKeysGuard` );
const V_SHOW = Symbol(`vShow` );
const TRANSITION = Symbol(`Transition` );
const TRANSITION_GROUP = Symbol(`TransitionGroup` );
compilerCore.registerRuntimeHelpers({
[V_MODEL_RADIO]: `vModelRadio`,
[V_MODEL_CHECKBOX]: `vModelCheckbox`,
@@ -2389,7 +2389,7 @@ const parserOptions = {
isVoidTag: shared.isVoidTag,
isNativeTag: tag => shared.isHTMLTag(tag) || shared.isSVGTag(tag),
isPreTag: tag => tag === 'pre',
decodeEntities: decodeHtml,
decodeEntities: decodeHtml,
isBuiltInComponent: (tag) => {
if (compilerCore.isBuiltInType(tag, `Transition`)) {
return TRANSITION;
@@ -2476,11 +2476,11 @@ const transformStyle = node => {
};
const parseInlineCSS = (cssText, loc) => {
const normalized = shared.parseStringStyle(cssText);
return compilerCore.createSimpleExpression(JSON.stringify(normalized), false, loc, true);
return compilerCore.createSimpleExpression(JSON.stringify(normalized), false, loc, 3 /* CAN_STRINGIFY */);
};
function createDOMCompilerError(code, loc) {
return compilerCore.createCompilerError(code, loc, DOMErrorMessages );
return compilerCore.createCompilerError(code, loc, DOMErrorMessages );
}
const DOMErrorMessages = {
[49 /* X_V_HTML_NO_EXPRESSION */]: `v-html is missing expression.`,
@@ -2574,7 +2574,7 @@ const transformModel = (dir, node, context) => {
break;
default:
// text type
checkDuplicatedValue();
checkDuplicatedValue();
break;
}
}
@@ -2586,7 +2586,7 @@ const transformModel = (dir, node, context) => {
}
else {
// text type
checkDuplicatedValue();
checkDuplicatedValue();
}
}
else if (tag === 'select') {
@@ -2594,7 +2594,7 @@ const transformModel = (dir, node, context) => {
}
else {
// textarea
checkDuplicatedValue();
checkDuplicatedValue();
}
// inject runtime directive
// by returning the helper symbol via needRuntime
@@ -3021,7 +3021,7 @@ const ignoreSideEffectTags = (node, context) => {
const DOMNodeTransforms = [
transformStyle,
...( [warnTransitionChildren] )
...([warnTransitionChildren] )
];
const DOMDirectiveTransforms = {
cloak: compilerCore.noopDirectiveTransform,
@@ -3042,16 +3042,13 @@ function compile(template, options = {}) {
...(options.nodeTransforms || [])
],
directiveTransforms: shared.extend({}, DOMDirectiveTransforms, options.directiveTransforms || {}),
transformHoist: stringifyStatic
transformHoist: stringifyStatic
}));
}
function parse(template, options = {}) {
return compilerCore.baseParse(template, shared.extend({}, parserOptions, options));
}
Object.keys(compilerCore).forEach(function (k) {
if (k !== 'default') exports[k] = compilerCore[k];
});
exports.DOMDirectiveTransforms = DOMDirectiveTransforms;
exports.DOMNodeTransforms = DOMNodeTransforms;
exports.TRANSITION = TRANSITION;
@@ -3069,3 +3066,6 @@ exports.createDOMCompilerError = createDOMCompilerError;
exports.parse = parse;
exports.parserOptions = parserOptions;
exports.transformStyle = transformStyle;
Object.keys(compilerCore).forEach(function (k) {
if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = compilerCore[k];
});

View File

@@ -5,16 +5,16 @@ Object.defineProperty(exports, '__esModule', { value: true });
var compilerCore = require('@vue/compiler-core');
var shared = require('@vue/shared');
const V_MODEL_RADIO = Symbol( ``);
const V_MODEL_CHECKBOX = Symbol( ``);
const V_MODEL_TEXT = Symbol( ``);
const V_MODEL_SELECT = Symbol( ``);
const V_MODEL_DYNAMIC = Symbol( ``);
const V_ON_WITH_MODIFIERS = Symbol( ``);
const V_ON_WITH_KEYS = Symbol( ``);
const V_SHOW = Symbol( ``);
const TRANSITION = Symbol( ``);
const TRANSITION_GROUP = Symbol( ``);
const V_MODEL_RADIO = Symbol(``);
const V_MODEL_CHECKBOX = Symbol(``);
const V_MODEL_TEXT = Symbol(``);
const V_MODEL_SELECT = Symbol(``);
const V_MODEL_DYNAMIC = Symbol(``);
const V_ON_WITH_MODIFIERS = Symbol(``);
const V_ON_WITH_KEYS = Symbol(``);
const V_SHOW = Symbol(``);
const TRANSITION = Symbol(``);
const TRANSITION_GROUP = Symbol(``);
compilerCore.registerRuntimeHelpers({
[V_MODEL_RADIO]: `vModelRadio`,
[V_MODEL_CHECKBOX]: `vModelCheckbox`,
@@ -2389,7 +2389,7 @@ const parserOptions = {
isVoidTag: shared.isVoidTag,
isNativeTag: tag => shared.isHTMLTag(tag) || shared.isSVGTag(tag),
isPreTag: tag => tag === 'pre',
decodeEntities: decodeHtml,
decodeEntities: decodeHtml,
isBuiltInComponent: (tag) => {
if (compilerCore.isBuiltInType(tag, `Transition`)) {
return TRANSITION;
@@ -2476,11 +2476,11 @@ const transformStyle = node => {
};
const parseInlineCSS = (cssText, loc) => {
const normalized = shared.parseStringStyle(cssText);
return compilerCore.createSimpleExpression(JSON.stringify(normalized), false, loc, true);
return compilerCore.createSimpleExpression(JSON.stringify(normalized), false, loc, 3 /* CAN_STRINGIFY */);
};
function createDOMCompilerError(code, loc) {
return compilerCore.createCompilerError(code, loc, DOMErrorMessages );
return compilerCore.createCompilerError(code, loc, DOMErrorMessages );
}
const DOMErrorMessages = {
[49 /* X_V_HTML_NO_EXPRESSION */]: `v-html is missing expression.`,
@@ -2979,7 +2979,7 @@ const ignoreSideEffectTags = (node, context) => {
const DOMNodeTransforms = [
transformStyle,
...( [])
...([])
];
const DOMDirectiveTransforms = {
cloak: compilerCore.noopDirectiveTransform,
@@ -3000,16 +3000,13 @@ function compile(template, options = {}) {
...(options.nodeTransforms || [])
],
directiveTransforms: shared.extend({}, DOMDirectiveTransforms, options.directiveTransforms || {}),
transformHoist: stringifyStatic
transformHoist: stringifyStatic
}));
}
function parse(template, options = {}) {
return compilerCore.baseParse(template, shared.extend({}, parserOptions, options));
}
Object.keys(compilerCore).forEach(function (k) {
if (k !== 'default') exports[k] = compilerCore[k];
});
exports.DOMDirectiveTransforms = DOMDirectiveTransforms;
exports.DOMNodeTransforms = DOMNodeTransforms;
exports.TRANSITION = TRANSITION;
@@ -3027,3 +3024,6 @@ exports.createDOMCompilerError = createDOMCompilerError;
exports.parse = parse;
exports.parserOptions = parserOptions;
exports.transformStyle = transformStyle;
Object.keys(compilerCore).forEach(function (k) {
if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = compilerCore[k];
});

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -37,7 +37,7 @@ const parserOptions = {
isVoidTag,
isNativeTag: tag => isHTMLTag(tag) || isSVGTag(tag),
isPreTag: tag => tag === 'pre',
decodeEntities: decodeHtmlBrowser ,
decodeEntities: decodeHtmlBrowser ,
isBuiltInComponent: (tag) => {
if (isBuiltInType(tag, `Transition`)) {
return TRANSITION;
@@ -124,7 +124,7 @@ const transformStyle = node => {
};
const parseInlineCSS = (cssText, loc) => {
const normalized = parseStringStyle(cssText);
return createSimpleExpression(JSON.stringify(normalized), false, loc, true);
return createSimpleExpression(JSON.stringify(normalized), false, loc, 3 /* CAN_STRINGIFY */);
};
function createDOMCompilerError(code, loc) {
@@ -438,7 +438,7 @@ function compile(template, options = {}) {
...(options.nodeTransforms || [])
],
directiveTransforms: extend({}, DOMDirectiveTransforms, options.directiveTransforms || {}),
transformHoist: null
transformHoist: null
}));
}
function parse(template, options = {}) {

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,36 +1,34 @@
{
"_args": [
[
"@vue/compiler-dom@3.0.2",
"@vue/compiler-dom@3.0.6",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "@vue/compiler-dom@3.0.2",
"_id": "@vue/compiler-dom@3.0.2",
"_from": "@vue/compiler-dom@3.0.6",
"_id": "@vue/compiler-dom@3.0.6",
"_inBundle": false,
"_integrity": "sha1-HUDeBLzfmqu3n7aoAt1wovPCmSo=",
"_integrity": "sha1-+Uw5WTIKElKRW9ArlD+Wp+4/yVE=",
"_location": "/@vue/compiler-dom",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@vue/compiler-dom@3.0.2",
"raw": "@vue/compiler-dom@3.0.6",
"name": "@vue/compiler-dom",
"escapedName": "@vue%2fcompiler-dom",
"scope": "@vue",
"rawSpec": "3.0.2",
"rawSpec": "3.0.6",
"saveSpec": null,
"fetchSpec": "3.0.2"
"fetchSpec": "3.0.6"
},
"_requiredBy": [
"/@vue/compiler-sfc",
"/@vue/compiler-ssr",
"/vite",
"/vue"
],
"_resolved": "http://192.168.250.101:4873/@vue%2fcompiler-dom/-/compiler-dom-3.0.2.tgz",
"_spec": "3.0.2",
"_resolved": "http://192.168.250.101:4873/@vue%2fcompiler-dom/-/compiler-dom-3.0.6.tgz",
"_spec": "3.0.6",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Evan You"
@@ -48,8 +46,8 @@
]
},
"dependencies": {
"@vue/compiler-core": "3.0.2",
"@vue/shared": "3.0.2"
"@vue/compiler-core": "3.0.6",
"@vue/shared": "3.0.6"
},
"description": "@vue/compiler-dom",
"files": [
@@ -57,7 +55,7 @@
"dist"
],
"homepage": "https://github.com/vuejs/vue-next/tree/master/packages/compiler-dom#readme",
"jsdelivr": "dist/compiler-dom/global.js",
"jsdelivr": "dist/compiler-dom.global.js",
"keywords": [
"vue"
],
@@ -72,6 +70,6 @@
},
"sideEffects": false,
"types": "dist/compiler-dom.d.ts",
"unpkg": "dist/compiler-dom/global.js",
"version": "3.0.2"
"unpkg": "dist/compiler-dom.global.js",
"version": "3.0.6"
}

View File

@@ -1,15 +1,83 @@
# @vue/compiler-sfc
> Lower level utilities for compiling Vue single file components
> Lower level utilities for compiling Vue Single File Components
This package contains lower level utilities that you can use if you are writing a plugin / transform for a bundler or module system that compiles Vue single file components into JavaScript. It is used in [vue-loader](https://github.com/vuejs/vue-loader).
This package contains lower level utilities that you can use if you are writing a plugin / transform for a bundler or module system that compiles Vue Single File Components (SFCs) into JavaScript. It is used in [vue-loader](https://github.com/vuejs/vue-loader), [rollup-plugin-vue](https://github.com/vuejs/rollup-plugin-vue) and [vite](https://github.com/vitejs/vite).
The API surface is intentionally minimal - the goal is to reuse as much as possible while being as flexible as possible.
## Browser Build Notes
## Browser Build Usage
This package relies on `postcss`, `postcss-selector-parser` and `postcss-modules`
The browser build relies on a browser-bundled build of `postcss` to be available under the global `postcss` (since it can't be properly bundled by Rollup).
## API
TODO
The API is intentionally low-level due to the various considerations when integrating Vue SFCs in a build system:
- Separate hot-module replacement (HMR) for script, template and styles
- template updates should not reset component state
- style updates should be performed without component re-render
- Leveraging the tool's plugin system for pre-processor handling. e.g. `<style lang="scss">` should be processed by the corresponding webpack loader.
- In some cases, transformers of each block in an SFC do not share the same execution context. For example, when used with `thread-loader` or other parallelized configurations, the template sub-loader in `vue-loader` may not have access to the full SFC and its descriptor.
The general idea is to generate a facade module that imports the individual blocks of the component. The trick is the module imports itself with different query strings so that the build system can handle each request as "virtual" modules:
```
+--------------------+
| |
| script transform |
+----->+ |
| +--------------------+
|
+--------------------+ | +--------------------+
| | | | |
| facade transform +----------->+ template transform |
| | | | |
+--------------------+ | +--------------------+
|
| +--------------------+
+----->+ |
| style transform |
| |
+--------------------+
```
Where the facade module looks like this:
```js
// main script
import script from '/project/foo.vue?vue&type=script'
// template compiled to render function
import { render } from '/project/foo.vue?vue&type=template&id=xxxxxx'
// css
import '/project/foo.vue?vue&type=style&index=0&id=xxxxxx'
// attach render function to script
script.render = render
// attach additional metadata
// some of these should be dev only
script.__file = 'example.vue'
script.__scopeId = 'xxxxxx'
// additional tooling-specific HMR handling code
// using __VUE_HMR_API__ global
export default script
```
### High Level Workflow
1. In facade transform, parse the source into descriptor with the `parse` API and generate the above facade module code based on the descriptor;
2. In script transform, use `compileScript` to process the script. This handles features like `<script setup>` and CSS variable injection. Alternatively, this can be done directly in the facade module (with the code inlined instead of imported), but it will require rewriting `export default` to a temp variable (a `rewriteDefault` convenience API is provided for this purpose) so additional options can be attached to the exported object.
3. In template transform, use `compileTemplate` to compile the raw template into render function code.
4. In style transform, use `compileStyle` to compile raw CSS to handle `<style scoped>`, `<style module>` and CSS variable injection.
Options needed for these APIs can be passed via the query string.
For detailed API references and options, check out the source type definitions. For actual usage of these APIs, check out [rollup-plugin-vue](https://github.com/vuejs/rollup-plugin-vue/tree/next) or [vue-loader](https://github.com/vuejs/vue-loader/tree/next).

File diff suppressed because it is too large Load Diff

View File

@@ -2,6 +2,7 @@ import { BindingMetadata } from '@vue/compiler-core';
import { CodegenResult } from '@vue/compiler-core';
import { CompilerError } from '@vue/compiler-core';
import { CompilerOptions } from '@vue/compiler-core';
import { ElementNode } from '@vue/compiler-core';
import { generateCodeFrame } from '@vue/compiler-core';
import { LazyResult } from 'postcss';
import { ParserOptions } from '@vue/compiler-core';
@@ -37,13 +38,26 @@ export { CompilerOptions }
* It requires the whole SFC descriptor because we need to handle and merge
* normal `<script>` + `<script setup>` if both are present.
*/
export declare function compileScript(sfc: SFCDescriptor, options?: SFCScriptCompileOptions): SFCScriptBlock;
export declare function compileScript(sfc: SFCDescriptor, options: SFCScriptCompileOptions): SFCScriptBlock;
export declare function compileStyle(options: SFCStyleCompileOptions): SFCStyleCompileResults;
export declare function compileStyleAsync(options: SFCAsyncStyleCompileOptions): Promise<SFCStyleCompileResults>;
export declare function compileTemplate(options: SFCTemplateCompileOptions): SFCTemplateCompileResults;
/**
* Aligns with postcss-modules
* https://github.com/css-modules/postcss-modules
*/
declare interface CSSModulesOptions {
scopeBehaviour?: 'global' | 'local';
generateScopedName?: string | ((name: string, filename: string, css: string) => string);
hashPrefix?: string;
localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly';
exportGlobals?: boolean;
globalModulePaths?: string[];
}
export { generateCodeFrame }
export declare function parse(source: string, { sourceMap, filename, sourceRoot, pad, compiler }?: SFCParseOptions): SFCParseResult;
@@ -59,13 +73,7 @@ export declare function rewriteDefault(input: string, as: string, parserPlugins?
export declare interface SFCAsyncStyleCompileOptions extends SFCStyleCompileOptions {
isAsync?: boolean;
modules?: boolean;
modulesOptions?: {
scopeBehaviour?: 'global' | 'local';
globalModulePaths?: string[];
generateScopedName?: string | ((name: string, filename: string, css: string) => string);
hashPrefix?: string;
localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly';
};
modulesOptions?: CSSModulesOptions;
}
export declare interface SFCBlock {
@@ -86,6 +94,7 @@ export declare interface SFCDescriptor {
scriptSetup: SFCScriptBlock | null;
styles: SFCStyleBlock[];
customBlocks: SFCBlock[];
cssVars: string[];
}
export declare interface SFCParseOptions {
@@ -110,16 +119,39 @@ export declare interface SFCScriptBlock extends SFCBlock {
}
export declare interface SFCScriptCompileOptions {
/**
* Scope ID for prefixing injected CSS varialbes.
* This must be consistent with the `id` passed to `compileStyle`.
*/
id: string;
/**
* Production mode. Used to determine whether to generate hashed CSS variables
*/
isProd?: boolean;
/**
* https://babeljs.io/docs/en/babel-parser#plugins
*/
babelParserPlugins?: ParserPlugin[];
/**
* Enable ref: label sugar
* https://github.com/vuejs/rfcs/pull/228
* @default true
*/
refSugar?: boolean;
/**
* Compile the template and inline the resulting render function
* directly inside setup().
* - Only affects <script setup>
* - This should only be used in production because it prevents the template
* from being hot-reloaded separately from component state.
*/
inlineTemplate?: boolean;
templateOptions?: Partial<SFCTemplateCompileOptions>;
}
export declare interface SFCStyleBlock extends SFCBlock {
type: 'style';
scoped?: boolean;
vars?: string;
module?: string | boolean;
}
@@ -127,21 +159,25 @@ export declare interface SFCStyleCompileOptions {
source: string;
filename: string;
id: string;
map?: RawSourceMap;
scoped?: boolean;
vars?: boolean;
trim?: boolean;
isProd?: boolean;
inMap?: RawSourceMap;
preprocessLang?: PreprocessLang;
preprocessOptions?: any;
preprocessCustomRequire?: (id: string) => any;
postcssOptions?: any;
postcssPlugins?: any[];
/**
* @deprecated
*/
map?: RawSourceMap;
}
export declare interface SFCStyleCompileResults {
code: string;
map: RawSourceMap | undefined;
rawResult: LazyResult | Result | undefined;
rawResult: Result | LazyResult | undefined;
errors: Error[];
modules?: Record<string, string>;
dependencies: Set<string>;
@@ -149,13 +185,17 @@ export declare interface SFCStyleCompileResults {
export declare interface SFCTemplateBlock extends SFCBlock {
type: 'template';
functional?: boolean;
ast: ElementNode;
}
export declare interface SFCTemplateCompileOptions {
source: string;
filename: string;
id: string;
scoped?: boolean;
isProd?: boolean;
ssr?: boolean;
ssrCssVars?: string[];
inMap?: RawSourceMap;
compiler?: TemplateCompiler;
compilerOptions?: CompilerOptions;
@@ -176,6 +216,8 @@ export declare interface SFCTemplateCompileOptions {
export declare interface SFCTemplateCompileResults {
code: string;
ast?: RootNode;
preamble?: string;
source: string;
tips: string[];
errors: (string | CompilerError)[];

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +0,0 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View File

@@ -1,166 +0,0 @@
# lru cache
A cache object that deletes the least-recently-used items.
[![Build Status](https://travis-ci.org/isaacs/node-lru-cache.svg?branch=master)](https://travis-ci.org/isaacs/node-lru-cache) [![Coverage Status](https://coveralls.io/repos/isaacs/node-lru-cache/badge.svg?service=github)](https://coveralls.io/github/isaacs/node-lru-cache)
## Installation:
```javascript
npm install lru-cache --save
```
## Usage:
```javascript
var LRU = require("lru-cache")
, options = { max: 500
, length: function (n, key) { return n * 2 + key.length }
, dispose: function (key, n) { n.close() }
, maxAge: 1000 * 60 * 60 }
, cache = new LRU(options)
, otherCache = new LRU(50) // sets just the max size
cache.set("key", "value")
cache.get("key") // "value"
// non-string keys ARE fully supported
// but note that it must be THE SAME object, not
// just a JSON-equivalent object.
var someObject = { a: 1 }
cache.set(someObject, 'a value')
// Object keys are not toString()-ed
cache.set('[object Object]', 'a different value')
assert.equal(cache.get(someObject), 'a value')
// A similar object with same keys/values won't work,
// because it's a different object identity
assert.equal(cache.get({ a: 1 }), undefined)
cache.reset() // empty the cache
```
If you put more stuff in it, then items will fall out.
If you try to put an oversized thing in it, then it'll fall out right
away.
## Options
* `max` The maximum size of the cache, checked by applying the length
function to all values in the cache. Not setting this is kind of
silly, since that's the whole purpose of this lib, but it defaults
to `Infinity`. Setting it to a non-number or negative number will
throw a `TypeError`. Setting it to 0 makes it be `Infinity`.
* `maxAge` Maximum age in ms. Items are not pro-actively pruned out
as they age, but if you try to get an item that is too old, it'll
drop it and return undefined instead of giving it to you.
Setting this to a negative value will make everything seem old!
Setting it to a non-number will throw a `TypeError`.
* `length` Function that is used to calculate the length of stored
items. If you're storing strings or buffers, then you probably want
to do something like `function(n, key){return n.length}`. The default is
`function(){return 1}`, which is fine if you want to store `max`
like-sized things. The item is passed as the first argument, and
the key is passed as the second argumnet.
* `dispose` Function that is called on items when they are dropped
from the cache. This can be handy if you want to close file
descriptors or do other cleanup tasks when items are no longer
accessible. Called with `key, value`. It's called *before*
actually removing the item from the internal cache, so if you want
to immediately put it back in, you'll have to do that in a
`nextTick` or `setTimeout` callback or it won't do anything.
* `stale` By default, if you set a `maxAge`, it'll only actually pull
stale items out of the cache when you `get(key)`. (That is, it's
not pre-emptively doing a `setTimeout` or anything.) If you set
`stale:true`, it'll return the stale value before deleting it. If
you don't set this, then it'll return `undefined` when you try to
get a stale entry, as if it had already been deleted.
* `noDisposeOnSet` By default, if you set a `dispose()` method, then
it'll be called whenever a `set()` operation overwrites an existing
key. If you set this option, `dispose()` will only be called when a
key falls out of the cache, not when it is overwritten.
* `updateAgeOnGet` When using time-expiring entries with `maxAge`,
setting this to `true` will make each item's effective time update
to the current time whenever it is retrieved from cache, causing it
to not expire. (It can still fall out of cache based on recency of
use, of course.)
## API
* `set(key, value, maxAge)`
* `get(key) => value`
Both of these will update the "recently used"-ness of the key.
They do what you think. `maxAge` is optional and overrides the
cache `maxAge` option if provided.
If the key is not found, `get()` will return `undefined`.
The key and val can be any value.
* `peek(key)`
Returns the key value (or `undefined` if not found) without
updating the "recently used"-ness of the key.
(If you find yourself using this a lot, you *might* be using the
wrong sort of data structure, but there are some use cases where
it's handy.)
* `del(key)`
Deletes a key out of the cache.
* `reset()`
Clear the cache entirely, throwing away all values.
* `has(key)`
Check if a key is in the cache, without updating the recent-ness
or deleting it for being stale.
* `forEach(function(value,key,cache), [thisp])`
Just like `Array.prototype.forEach`. Iterates over all the keys
in the cache, in order of recent-ness. (Ie, more recently used
items are iterated over first.)
* `rforEach(function(value,key,cache), [thisp])`
The same as `cache.forEach(...)` but items are iterated over in
reverse order. (ie, less recently used items are iterated over
first.)
* `keys()`
Return an array of the keys in the cache.
* `values()`
Return an array of the values in the cache.
* `length`
Return total length of objects in cache taking into account
`length` options function.
* `itemCount`
Return total quantity of objects currently in cache. Note, that
`stale` (see options) items are returned as part of this item
count.
* `dump()`
Return an array of the cache entries ready for serialization and usage
with 'destinationCache.load(arr)`.
* `load(cacheEntriesArray)`
Loads another cache entries array, obtained with `sourceCache.dump()`,
into the cache. The destination cache is reset before loading new entries
* `prune()`
Manually iterates over the entire cache proactively pruning old entries

View File

@@ -1,334 +0,0 @@
'use strict'
// A linked list to keep track of recently-used-ness
const Yallist = require('yallist')
const MAX = Symbol('max')
const LENGTH = Symbol('length')
const LENGTH_CALCULATOR = Symbol('lengthCalculator')
const ALLOW_STALE = Symbol('allowStale')
const MAX_AGE = Symbol('maxAge')
const DISPOSE = Symbol('dispose')
const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet')
const LRU_LIST = Symbol('lruList')
const CACHE = Symbol('cache')
const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet')
const naiveLength = () => 1
// lruList is a yallist where the head is the youngest
// item, and the tail is the oldest. the list contains the Hit
// objects as the entries.
// Each Hit object has a reference to its Yallist.Node. This
// never changes.
//
// cache is a Map (or PseudoMap) that matches the keys to
// the Yallist.Node object.
class LRUCache {
constructor (options) {
if (typeof options === 'number')
options = { max: options }
if (!options)
options = {}
if (options.max && (typeof options.max !== 'number' || options.max < 0))
throw new TypeError('max must be a non-negative number')
// Kind of weird to have a default max of Infinity, but oh well.
const max = this[MAX] = options.max || Infinity
const lc = options.length || naiveLength
this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc
this[ALLOW_STALE] = options.stale || false
if (options.maxAge && typeof options.maxAge !== 'number')
throw new TypeError('maxAge must be a number')
this[MAX_AGE] = options.maxAge || 0
this[DISPOSE] = options.dispose
this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false
this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false
this.reset()
}
// resize the cache when the max changes.
set max (mL) {
if (typeof mL !== 'number' || mL < 0)
throw new TypeError('max must be a non-negative number')
this[MAX] = mL || Infinity
trim(this)
}
get max () {
return this[MAX]
}
set allowStale (allowStale) {
this[ALLOW_STALE] = !!allowStale
}
get allowStale () {
return this[ALLOW_STALE]
}
set maxAge (mA) {
if (typeof mA !== 'number')
throw new TypeError('maxAge must be a non-negative number')
this[MAX_AGE] = mA
trim(this)
}
get maxAge () {
return this[MAX_AGE]
}
// resize the cache when the lengthCalculator changes.
set lengthCalculator (lC) {
if (typeof lC !== 'function')
lC = naiveLength
if (lC !== this[LENGTH_CALCULATOR]) {
this[LENGTH_CALCULATOR] = lC
this[LENGTH] = 0
this[LRU_LIST].forEach(hit => {
hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key)
this[LENGTH] += hit.length
})
}
trim(this)
}
get lengthCalculator () { return this[LENGTH_CALCULATOR] }
get length () { return this[LENGTH] }
get itemCount () { return this[LRU_LIST].length }
rforEach (fn, thisp) {
thisp = thisp || this
for (let walker = this[LRU_LIST].tail; walker !== null;) {
const prev = walker.prev
forEachStep(this, fn, walker, thisp)
walker = prev
}
}
forEach (fn, thisp) {
thisp = thisp || this
for (let walker = this[LRU_LIST].head; walker !== null;) {
const next = walker.next
forEachStep(this, fn, walker, thisp)
walker = next
}
}
keys () {
return this[LRU_LIST].toArray().map(k => k.key)
}
values () {
return this[LRU_LIST].toArray().map(k => k.value)
}
reset () {
if (this[DISPOSE] &&
this[LRU_LIST] &&
this[LRU_LIST].length) {
this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value))
}
this[CACHE] = new Map() // hash of items by key
this[LRU_LIST] = new Yallist() // list of items in order of use recency
this[LENGTH] = 0 // length of items in the list
}
dump () {
return this[LRU_LIST].map(hit =>
isStale(this, hit) ? false : {
k: hit.key,
v: hit.value,
e: hit.now + (hit.maxAge || 0)
}).toArray().filter(h => h)
}
dumpLru () {
return this[LRU_LIST]
}
set (key, value, maxAge) {
maxAge = maxAge || this[MAX_AGE]
if (maxAge && typeof maxAge !== 'number')
throw new TypeError('maxAge must be a number')
const now = maxAge ? Date.now() : 0
const len = this[LENGTH_CALCULATOR](value, key)
if (this[CACHE].has(key)) {
if (len > this[MAX]) {
del(this, this[CACHE].get(key))
return false
}
const node = this[CACHE].get(key)
const item = node.value
// dispose of the old one before overwriting
// split out into 2 ifs for better coverage tracking
if (this[DISPOSE]) {
if (!this[NO_DISPOSE_ON_SET])
this[DISPOSE](key, item.value)
}
item.now = now
item.maxAge = maxAge
item.value = value
this[LENGTH] += len - item.length
item.length = len
this.get(key)
trim(this)
return true
}
const hit = new Entry(key, value, len, now, maxAge)
// oversized objects fall out of cache automatically.
if (hit.length > this[MAX]) {
if (this[DISPOSE])
this[DISPOSE](key, value)
return false
}
this[LENGTH] += hit.length
this[LRU_LIST].unshift(hit)
this[CACHE].set(key, this[LRU_LIST].head)
trim(this)
return true
}
has (key) {
if (!this[CACHE].has(key)) return false
const hit = this[CACHE].get(key).value
return !isStale(this, hit)
}
get (key) {
return get(this, key, true)
}
peek (key) {
return get(this, key, false)
}
pop () {
const node = this[LRU_LIST].tail
if (!node)
return null
del(this, node)
return node.value
}
del (key) {
del(this, this[CACHE].get(key))
}
load (arr) {
// reset the cache
this.reset()
const now = Date.now()
// A previous serialized cache has the most recent items first
for (let l = arr.length - 1; l >= 0; l--) {
const hit = arr[l]
const expiresAt = hit.e || 0
if (expiresAt === 0)
// the item was created without expiration in a non aged cache
this.set(hit.k, hit.v)
else {
const maxAge = expiresAt - now
// dont add already expired items
if (maxAge > 0) {
this.set(hit.k, hit.v, maxAge)
}
}
}
}
prune () {
this[CACHE].forEach((value, key) => get(this, key, false))
}
}
const get = (self, key, doUse) => {
const node = self[CACHE].get(key)
if (node) {
const hit = node.value
if (isStale(self, hit)) {
del(self, node)
if (!self[ALLOW_STALE])
return undefined
} else {
if (doUse) {
if (self[UPDATE_AGE_ON_GET])
node.value.now = Date.now()
self[LRU_LIST].unshiftNode(node)
}
}
return hit.value
}
}
const isStale = (self, hit) => {
if (!hit || (!hit.maxAge && !self[MAX_AGE]))
return false
const diff = Date.now() - hit.now
return hit.maxAge ? diff > hit.maxAge
: self[MAX_AGE] && (diff > self[MAX_AGE])
}
const trim = self => {
if (self[LENGTH] > self[MAX]) {
for (let walker = self[LRU_LIST].tail;
self[LENGTH] > self[MAX] && walker !== null;) {
// We know that we're about to delete this one, and also
// what the next least recently used key will be, so just
// go ahead and set it now.
const prev = walker.prev
del(self, walker)
walker = prev
}
}
}
const del = (self, node) => {
if (node) {
const hit = node.value
if (self[DISPOSE])
self[DISPOSE](hit.key, hit.value)
self[LENGTH] -= hit.length
self[CACHE].delete(hit.key)
self[LRU_LIST].removeNode(node)
}
}
class Entry {
constructor (key, value, length, now, maxAge) {
this.key = key
this.value = value
this.length = length
this.now = now
this.maxAge = maxAge || 0
}
}
const forEachStep = (self, fn, node, thisp) => {
let hit = node.value
if (isStale(self, hit)) {
del(self, node)
if (!self[ALLOW_STALE])
hit = undefined
}
if (hit)
fn.call(thisp, hit.value, hit.key, self)
}
module.exports = LRUCache

View File

@@ -1,71 +0,0 @@
{
"_args": [
[
"lru-cache@5.1.1",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "lru-cache@5.1.1",
"_id": "lru-cache@5.1.1",
"_inBundle": false,
"_integrity": "sha1-HaJ+ZxAnGUdpXa9oSOhH8B2EuSA=",
"_location": "/@vue/compiler-sfc/lru-cache",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "lru-cache@5.1.1",
"name": "lru-cache",
"escapedName": "lru-cache",
"rawSpec": "5.1.1",
"saveSpec": null,
"fetchSpec": "5.1.1"
},
"_requiredBy": [
"/@vue/compiler-sfc"
],
"_resolved": "http://192.168.250.101:4873/lru-cache/-/lru-cache-5.1.1.tgz",
"_spec": "5.1.1",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me"
},
"bugs": {
"url": "https://github.com/isaacs/node-lru-cache/issues"
},
"dependencies": {
"yallist": "^3.0.2"
},
"description": "A cache object that deletes the least-recently-used items.",
"devDependencies": {
"benchmark": "^2.1.4",
"tap": "^12.1.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/isaacs/node-lru-cache#readme",
"keywords": [
"mru",
"lru",
"cache"
],
"license": "ISC",
"main": "index.js",
"name": "lru-cache",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/node-lru-cache.git"
},
"scripts": {
"coveragerport": "tap --coverage-report=html",
"postpublish": "git push origin --all; git push origin --tags",
"postversion": "npm publish",
"preversion": "npm test",
"snap": "TAP_SNAPSHOT=1 tap test/*.js -J",
"test": "tap test/*.js --100 -J"
},
"version": "5.1.1"
}

View File

@@ -1,36 +1,37 @@
{
"_args": [
[
"@vue/compiler-sfc@3.0.2",
"@vue/compiler-sfc@3.0.6",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "@vue/compiler-sfc@3.0.2",
"_id": "@vue/compiler-sfc@3.0.2",
"_from": "@vue/compiler-sfc@3.0.6",
"_id": "@vue/compiler-sfc@3.0.6",
"_inBundle": false,
"_integrity": "sha1-IscP7XLDR6TV+i2y6AWUsxk9zlc=",
"_integrity": "sha1-OUX3OpPVKGh5nx4zKnW7iEmXask=",
"_location": "/@vue/compiler-sfc",
"_phantomChildren": {
"yallist": "3.1.1"
"colorette": "1.2.1",
"nanoid": "3.1.20",
"source-map": "0.6.1"
},
"_requested": {
"type": "version",
"registry": true,
"raw": "@vue/compiler-sfc@3.0.2",
"raw": "@vue/compiler-sfc@3.0.6",
"name": "@vue/compiler-sfc",
"escapedName": "@vue%2fcompiler-sfc",
"scope": "@vue",
"rawSpec": "3.0.2",
"rawSpec": "3.0.6",
"saveSpec": null,
"fetchSpec": "3.0.2"
"fetchSpec": "3.0.6"
},
"_requiredBy": [
"/vite",
"/vitepress"
"#DEV:/"
],
"_resolved": "http://192.168.250.101:4873/@vue%2fcompiler-sfc/-/compiler-sfc-3.0.2.tgz",
"_spec": "3.0.2",
"_resolved": "http://192.168.250.101:4873/@vue%2fcompiler-sfc/-/compiler-sfc-3.0.6.tgz",
"_spec": "3.0.6",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Evan You"
@@ -42,8 +43,7 @@
"name": "VueCompilerSFC",
"formats": [
"cjs",
"global",
"esm-browser"
"global"
],
"prod": false,
"enableNonBrowserBranches": true
@@ -51,18 +51,18 @@
"dependencies": {
"@babel/parser": "^7.12.0",
"@babel/types": "^7.12.0",
"@vue/compiler-core": "3.0.2",
"@vue/compiler-dom": "3.0.2",
"@vue/compiler-ssr": "3.0.2",
"@vue/shared": "3.0.2",
"@vue/compiler-core": "3.0.6",
"@vue/compiler-dom": "3.0.6",
"@vue/compiler-ssr": "3.0.6",
"@vue/shared": "3.0.6",
"consolidate": "^0.16.0",
"estree-walker": "^2.0.1",
"hash-sum": "^2.0.0",
"lru-cache": "^5.1.1",
"magic-string": "^0.25.7",
"merge-source-map": "^1.1.0",
"postcss": "^7.0.32",
"postcss-modules": "^3.2.2",
"postcss": "^8.1.10",
"postcss-modules": "^4.0.0",
"postcss-selector-parser": "^6.0.4",
"source-map": "^0.6.1"
},
@@ -84,7 +84,7 @@
"main": "dist/compiler-sfc.cjs.js",
"name": "@vue/compiler-sfc",
"peerDependencies": {
"vue": "3.0.2"
"vue": "3.0.6"
},
"repository": {
"type": "git",
@@ -92,5 +92,5 @@
"directory": "packages/compiler-sfc"
},
"types": "dist/compiler-sfc.d.ts",
"version": "3.0.2"
"version": "3.0.6"
}

View File

@@ -21,7 +21,6 @@ const SSR_RENDER_DYNAMIC_MODEL = Symbol(`ssrRenderDynamicModel`);
const SSR_GET_DYNAMIC_MODEL_PROPS = Symbol(`ssrGetDynamicModelProps`);
const SSR_RENDER_TELEPORT = Symbol(`ssrRenderTeleport`);
const SSR_RENDER_SUSPENSE = Symbol(`ssrRenderSuspense`);
const SSR_RESOLVE_CSS_VARS = Symbol(`ssrResolveCssVars`);
const ssrHelpers = {
[SSR_INTERPOLATE]: `ssrInterpolate`,
[SSR_RENDER_VNODE]: `ssrRenderVNode`,
@@ -38,8 +37,7 @@ const ssrHelpers = {
[SSR_RENDER_DYNAMIC_MODEL]: `ssrRenderDynamicModel`,
[SSR_GET_DYNAMIC_MODEL_PROPS]: `ssrGetDynamicModelProps`,
[SSR_RENDER_TELEPORT]: `ssrRenderTeleport`,
[SSR_RENDER_SUSPENSE]: `ssrRenderSuspense`,
[SSR_RESOLVE_CSS_VARS]: `ssrResolveCssVars`
[SSR_RENDER_SUSPENSE]: `ssrRenderSuspense`
};
// Note: these are helpers imported from @vue/server-renderer
// make sure the names match!
@@ -49,14 +47,14 @@ compilerDom.registerRuntimeHelpers(ssrHelpers);
const ssrTransformIf = compilerDom.createStructuralDirectiveTransform(/^(if|else|else-if)$/, compilerDom.processIf);
// This is called during the 2nd transform pass to construct the SSR-specific
// codegen nodes.
function ssrProcessIf(node, context) {
function ssrProcessIf(node, context, disableNestedFragments = false) {
const [rootBranch] = node.branches;
const ifStatement = compilerDom.createIfStatement(rootBranch.condition, processIfBranch(rootBranch, context));
const ifStatement = compilerDom.createIfStatement(rootBranch.condition, processIfBranch(rootBranch, context, disableNestedFragments));
context.pushStatement(ifStatement);
let currentIf = ifStatement;
for (let i = 1; i < node.branches.length; i++) {
const branch = node.branches[i];
const branchBlockStatement = processIfBranch(branch, context);
const branchBlockStatement = processIfBranch(branch, context, disableNestedFragments);
if (branch.condition) {
// else-if
currentIf = currentIf.alternate = compilerDom.createIfStatement(branch.condition, branchBlockStatement);
@@ -72,9 +70,10 @@ function ssrProcessIf(node, context) {
]);
}
}
function processIfBranch(branch, context) {
function processIfBranch(branch, context, disableNestedFragments = false) {
const { children } = branch;
const needFragmentWrapper = (children.length !== 1 || children[0].type !== 1 /* ELEMENT */) &&
const needFragmentWrapper = !disableNestedFragments &&
(children.length !== 1 || children[0].type !== 1 /* ELEMENT */) &&
// optimize away nested fragments when the only child is a ForNode
!(children.length === 1 && children[0].type === 11 /* FOR */);
return processChildrenAsStatement(children, context, needFragmentWrapper);
@@ -84,17 +83,22 @@ function processIfBranch(branch, context) {
const ssrTransformFor = compilerDom.createStructuralDirectiveTransform('for', compilerDom.processFor);
// This is called during the 2nd transform pass to construct the SSR-specific
// codegen nodes.
function ssrProcessFor(node, context) {
const needFragmentWrapper = node.children.length !== 1 || node.children[0].type !== 1 /* ELEMENT */;
function ssrProcessFor(node, context, disableNestedFragments = false) {
const needFragmentWrapper = !disableNestedFragments &&
(node.children.length !== 1 || node.children[0].type !== 1 /* ELEMENT */);
const renderLoop = compilerDom.createFunctionExpression(compilerDom.createForLoopParams(node.parseResult));
renderLoop.body = processChildrenAsStatement(node.children, context, needFragmentWrapper);
// v-for always renders a fragment
context.pushStringPart(`<!--[-->`);
// v-for always renders a fragment unless explicitly disabled
if (!disableNestedFragments) {
context.pushStringPart(`<!--[-->`);
}
context.pushStatement(compilerDom.createCallExpression(context.helper(SSR_RENDER_LIST), [
node.source,
renderLoop
]));
context.pushStringPart(`<!--]-->`);
if (!disableNestedFragments) {
context.pushStringPart(`<!--]-->`);
}
}
const ssrTransformSlotOutlet = (node, context) => {
@@ -214,6 +218,39 @@ function ssrProcessSuspense(node, context) {
]));
}
function ssrProcessTransitionGroup(node, context) {
const tag = compilerDom.findProp(node, 'tag');
if (tag) {
if (tag.type === 7 /* DIRECTIVE */) {
// dynamic :tag
context.pushStringPart(`<`);
context.pushStringPart(tag.exp);
context.pushStringPart(`>`);
processChildren(node.children, context, false,
/**
* TransitionGroup has the special runtime behavior of flattening and
* concatenating all children into a single fragment (in order for them to
* be pathced using the same key map) so we need to account for that here
* by disabling nested fragment wrappers from being generated.
*/
true);
context.pushStringPart(`</`);
context.pushStringPart(tag.exp);
context.pushStringPart(`>`);
}
else {
// static tag
context.pushStringPart(`<${tag.value.content}>`);
processChildren(node.children, context, false, true);
context.pushStringPart(`</${tag.value.content}>`);
}
}
else {
// fragment
processChildren(node.children, context, true, true);
}
}
// We need to construct the slot functions in the 1st pass to ensure proper
// scope tracking, but the children of each slot cannot be processed until
// the 2nd pass, so we store the WIP slot functions in a weakmap during the 1st
@@ -309,9 +346,12 @@ function ssrProcessComponent(node, context) {
else if (component === compilerDom.SUSPENSE) {
return ssrProcessSuspense(node, context);
}
else if (component === compilerDom.TRANSITION_GROUP) {
return ssrProcessTransitionGroup(node, context);
}
else {
// real fall-through (e.g. KeepAlive): just render its children.
processChildren(node.children, context, component === compilerDom.TRANSITION_GROUP);
processChildren(node.children, context);
}
}
else {
@@ -395,11 +435,15 @@ function subTransform(node, options, parentContext) {
childContext.identifiers = { ...parentContext.identifiers };
// traverse
compilerDom.traverseNode(childRoot, childContext);
['helpers', 'components', 'directives', 'imports'].forEach(key => {
['helpers', 'components', 'directives'].forEach(key => {
childContext[key].forEach((value) => {
parentContext[key].add(value);
});
});
// imports/hoists are not merged because:
// - imports are only used for asset urls and should be consistent between
// node/client branches
// - hoists are not enabled for the client branch here
}
function clone(v) {
if (shared.isArray(v)) {
@@ -494,6 +538,10 @@ const ssrTransformElement = (node, context) => {
let dynamicStyleBinding = undefined;
for (let i = 0; i < node.props.length; i++) {
const prop = node.props[i];
// ignore true-value/false-value on input
if (node.tag === 'input' && isTrueFalseValue(prop)) {
continue;
}
// special cases with children override
if (prop.type === 7 /* DIRECTIVE */) {
if (prop.name === 'html' && prop.exp) {
@@ -527,6 +575,9 @@ const ssrTransformElement = (node, context) => {
if (compilerDom.isStaticExp(key)) {
let attrName = key.content;
// static key attr
if (attrName === 'key' || attrName === 'ref') {
continue;
}
if (attrName === 'class') {
openTag.push(` class="`, (dynamicClassBinding = compilerDom.createCallExpression(context.helper(SSR_RENDER_CLASS), [value])), `"`);
}
@@ -578,6 +629,9 @@ const ssrTransformElement = (node, context) => {
rawChildrenMap.set(node, shared.escapeHtml(prop.value.content));
}
else if (!hasDynamicVBind) {
if (prop.name === 'key' || prop.name === 'ref') {
continue;
}
// static prop
if (prop.name === 'class' && prop.value) {
staticClassBinding = JSON.stringify(prop.value.content);
@@ -598,6 +652,17 @@ const ssrTransformElement = (node, context) => {
node.ssrCodegenNode = compilerDom.createTemplateLiteral(openTag);
};
};
function isTrueFalseValue(prop) {
if (prop.type === 7 /* DIRECTIVE */) {
return (prop.name === 'bind' &&
prop.arg &&
compilerDom.isStaticExp(prop.arg) &&
(prop.arg.content === 'true-value' || prop.arg.content === 'false-value'));
}
else {
return prop.name === 'true-value' || prop.name === 'false-value';
}
}
function isTextareaWithValue(node, prop) {
return !!(node.tag === 'textarea' &&
prop.name === 'bind' &&
@@ -654,17 +719,12 @@ function ssrProcessElement(node, context) {
// passing it to codegen.
function ssrCodegenTransform(ast, options) {
const context = createSSRTransformContext(ast, options);
// inject <style vars> resolution
// inject SFC <style> CSS variables
// we do this instead of inlining the expression to ensure the vars are
// only resolved once per render
if (options.ssrCssVars) {
const varsExp = compilerDom.processExpression(compilerDom.createSimpleExpression(options.ssrCssVars, false), compilerDom.createTransformContext(compilerDom.createRoot([]), options));
context.body.push(compilerDom.createCompoundExpression([
`const _cssVars = _${ssrHelpers[SSR_RESOLVE_CSS_VARS]}(`,
varsExp,
options.scopeId ? `, ${JSON.stringify(options.scopeId)}` : ``,
`)`
]));
context.body.push(compilerDom.createCompoundExpression([`const _cssVars = { style: `, varsExp, `}`]));
}
const isFragment = ast.children.length > 1 && ast.children.some(c => !compilerDom.isText(c));
processChildren(ast.children, context, isFragment);
@@ -721,7 +781,7 @@ function createChildContext(parent, withSlotScopeId = parent.withSlotScopeId) {
// ensure child inherits parent helpers
return createSSRTransformContext(parent.root, parent.options, parent.helpers, withSlotScopeId);
}
function processChildren(children, context, asFragment = false) {
function processChildren(children, context, asFragment = false, disableNestedFragments = false) {
if (asFragment) {
context.pushStringPart(`<!--[-->`);
}
@@ -761,10 +821,10 @@ function processChildren(children, context, asFragment = false) {
context.pushStringPart(compilerDom.createCallExpression(context.helper(SSR_INTERPOLATE), [child.content]));
break;
case 9 /* IF */:
ssrProcessIf(child, context);
ssrProcessIf(child, context, disableNestedFragments);
break;
case 11 /* FOR */:
ssrProcessFor(child, context);
ssrProcessFor(child, context, disableNestedFragments);
break;
case 10 /* IF_BRANCH */:
// no-op - handled by ssrProcessIf
@@ -831,12 +891,26 @@ const ssrTransformModel = (dir, node, context) => {
];
break;
case 'checkbox':
res.props = [
compilerDom.createObjectProperty(`checked`, compilerDom.createConditionalExpression(compilerDom.createCallExpression(`Array.isArray`, [model]), compilerDom.createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [
model,
value
]), model))
];
const trueValueBinding = compilerDom.findProp(node, 'true-value');
if (trueValueBinding) {
const trueValue = trueValueBinding.type === 6 /* ATTRIBUTE */
? JSON.stringify(trueValueBinding.value.content)
: trueValueBinding.exp;
res.props = [
compilerDom.createObjectProperty(`checked`, compilerDom.createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
model,
trueValue
]))
];
}
else {
res.props = [
compilerDom.createObjectProperty(`checked`, compilerDom.createConditionalExpression(compilerDom.createCallExpression(`Array.isArray`, [model]), compilerDom.createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [
model,
value
]), model))
];
}
break;
case 'file':
context.onError(compilerDom.createDOMCompilerError(55 /* X_V_MODEL_ON_FILE_INPUT_ELEMENT */, dir.loc));
@@ -941,7 +1015,6 @@ const ssrInjectCssVars = (node, context) => {
if (!parent || parent.type !== 0 /* ROOT */) {
return;
}
context.helper(SSR_RESOLVE_CSS_VARS);
if (node.type === 10 /* IF_BRANCH */) {
for (const child of node.children) {
injectCssVars(child);
@@ -956,14 +1029,28 @@ function injectCssVars(node) {
(node.tagType === 0 /* ELEMENT */ ||
node.tagType === 1 /* COMPONENT */) &&
!compilerDom.findDir(node, 'for')) {
node.props.push({
type: 7 /* DIRECTIVE */,
name: 'bind',
arg: undefined,
exp: compilerDom.createSimpleExpression(`_cssVars`, false),
modifiers: [],
loc: compilerDom.locStub
});
if (compilerDom.isBuiltInType(node.tag, 'Suspense')) {
for (const child of node.children) {
if (child.type === 1 /* ELEMENT */ &&
child.tagType === 3 /* TEMPLATE */) {
// suspense slot
child.children.forEach(injectCssVars);
}
else {
injectCssVars(child);
}
}
}
else {
node.props.push({
type: 7 /* DIRECTIVE */,
name: 'bind',
arg: undefined,
exp: compilerDom.createSimpleExpression(`_cssVars`, false),
modifiers: [],
loc: compilerDom.locStub
});
}
}
}

View File

@@ -1,34 +1,33 @@
{
"_args": [
[
"@vue/compiler-ssr@3.0.2",
"@vue/compiler-ssr@3.0.6",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "@vue/compiler-ssr@3.0.2",
"_id": "@vue/compiler-ssr@3.0.2",
"_from": "@vue/compiler-ssr@3.0.6",
"_id": "@vue/compiler-ssr@3.0.6",
"_inBundle": false,
"_integrity": "sha1-c69NJ0p5v8xyqZaptF8QcufeqiY=",
"_integrity": "sha1-cVY2HkxGXL7icjJ17cYelAZ45Hw=",
"_location": "/@vue/compiler-ssr",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@vue/compiler-ssr@3.0.2",
"raw": "@vue/compiler-ssr@3.0.6",
"name": "@vue/compiler-ssr",
"escapedName": "@vue%2fcompiler-ssr",
"scope": "@vue",
"rawSpec": "3.0.2",
"rawSpec": "3.0.6",
"saveSpec": null,
"fetchSpec": "3.0.2"
"fetchSpec": "3.0.6"
},
"_requiredBy": [
"/@vue/compiler-sfc",
"/@vue/server-renderer"
"/@vue/compiler-sfc"
],
"_resolved": "http://192.168.250.101:4873/@vue%2fcompiler-ssr/-/compiler-ssr-3.0.2.tgz",
"_spec": "3.0.2",
"_resolved": "http://192.168.250.101:4873/@vue%2fcompiler-ssr/-/compiler-ssr-3.0.6.tgz",
"_spec": "3.0.6",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Evan You"
@@ -43,8 +42,8 @@
]
},
"dependencies": {
"@vue/compiler-dom": "3.0.2",
"@vue/shared": "3.0.2"
"@vue/compiler-dom": "3.0.6",
"@vue/shared": "3.0.6"
},
"description": "@vue/compiler-ssr",
"files": [
@@ -63,5 +62,5 @@
"directory": "packages/compiler-ssr"
},
"types": "dist/compiler-ssr.d.ts",
"version": "3.0.2"
"version": "3.0.6"
}

View File

@@ -7,8 +7,8 @@ var shared = require('@vue/shared');
const targetMap = new WeakMap();
const effectStack = [];
let activeEffect;
const ITERATE_KEY = Symbol( 'iterate' );
const MAP_KEY_ITERATE_KEY = Symbol( 'Map key iterate' );
const ITERATE_KEY = Symbol('iterate' );
const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
function isEffect(fn) {
return fn && fn._isEffect === true;
}
@@ -99,7 +99,7 @@ function track(target, type, key) {
if (!dep.has(activeEffect)) {
dep.add(activeEffect);
activeEffect.deps.push(dep);
if ( activeEffect.options.onTrack) {
if (activeEffect.options.onTrack) {
activeEffect.options.onTrack({
effect: activeEffect,
target,
@@ -172,7 +172,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
}
}
const run = (effect) => {
if ( effect.options.onTrigger) {
if (effect.options.onTrigger) {
effect.options.onTrigger({
effect,
target,
@@ -193,6 +193,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
effects.forEach(run);
}
const isNonTrackableKeys = /*#__PURE__*/ shared.makeMap(`__proto__,__v_isRef,__isVue`);
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
.map(key => Symbol[key])
.filter(shared.isSymbol));
@@ -241,13 +242,13 @@ function createGetter(isReadonly = false, shallow = false) {
return target;
}
const targetIsArray = shared.isArray(target);
if (targetIsArray && shared.hasOwn(arrayInstrumentations, key)) {
if (!isReadonly && targetIsArray && shared.hasOwn(arrayInstrumentations, key)) {
return Reflect.get(arrayInstrumentations, key, receiver);
}
const res = Reflect.get(target, key, receiver);
if (shared.isSymbol(key)
? builtInSymbols.has(key)
: key === `__proto__` || key === `__v_isRef`) {
: isNonTrackableKeys(key)) {
return res;
}
if (!isReadonly) {
@@ -396,11 +397,11 @@ function add(value) {
const target = toRaw(this);
const proto = getProto(target);
const hadKey = proto.has.call(target, value);
const result = target.add(value);
target.add(value);
if (!hadKey) {
trigger(target, "add" /* ADD */, value, value);
}
return result;
return this;
}
function set$1(key, value) {
value = toRaw(value);
@@ -415,14 +416,14 @@ function set$1(key, value) {
checkIdentityKeys(target, has, key);
}
const oldValue = get.call(target, key);
const result = target.set(key, value);
target.set(key, value);
if (!hadKey) {
trigger(target, "add" /* ADD */, key, value);
}
else if (shared.hasChanged(value, oldValue)) {
trigger(target, "set" /* SET */, key, value, oldValue);
}
return result;
return this;
}
function deleteEntry(key) {
const target = toRaw(this);
@@ -446,7 +447,7 @@ function deleteEntry(key) {
function clear() {
const target = toRaw(this);
const hadItems = target.size !== 0;
const oldTarget = shared.isMap(target)
const oldTarget = shared.isMap(target)
? new Map(target)
: new Set(target)
;
@@ -632,19 +633,27 @@ function reactive(target) {
}
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are reactive, and does NOT unwrap refs nor recursively convert
// returned properties.
/**
* Return a shallowly-reactive copy of the original object, where only the root
* level properties are reactive. It also does not auto-unwrap refs (even at the
* root level).
*/
function shallowReactive(target) {
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers);
}
/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
function readonly(target) {
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are readonly, and does NOT unwrap refs nor recursively convert
// returned properties.
// This is used for creating the props proxy object for stateful components.
/**
* Returns a reactive-copy of the original object, where only the root level
* properties are readonly, and does NOT unwrap refs nor recursively convert
* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
function shallowReadonly(target) {
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers);
}
@@ -732,7 +741,7 @@ function createRef(rawValue, shallow = false) {
return new RefImpl(rawValue, shallow);
}
function triggerRef(ref) {
trigger(toRaw(ref), "set" /* SET */, 'value', ref.value );
trigger(toRaw(ref), "set" /* SET */, 'value', ref.value );
}
function unref(ref) {
return isRef(ref) ? ref.value : ref;
@@ -773,7 +782,7 @@ function customRef(factory) {
return new CustomRefImpl(factory);
}
function toRefs(object) {
if ( !isProxy(object)) {
if (!isProxy(object)) {
console.warn(`toRefs() expects a reactive object but received a plain one.`);
}
const ret = shared.isArray(object) ? new Array(object.length) : {};
@@ -834,7 +843,7 @@ function computed(getterOrOptions) {
let setter;
if (shared.isFunction(getterOrOptions)) {
getter = getterOrOptions;
setter = () => {
setter = () => {
console.warn('Write operation failed: computed value is readonly');
}
;

View File

@@ -7,8 +7,8 @@ var shared = require('@vue/shared');
const targetMap = new WeakMap();
const effectStack = [];
let activeEffect;
const ITERATE_KEY = Symbol( '');
const MAP_KEY_ITERATE_KEY = Symbol( '');
const ITERATE_KEY = Symbol('');
const MAP_KEY_ITERATE_KEY = Symbol('');
function isEffect(fn) {
return fn && fn._isEffect === true;
}
@@ -174,6 +174,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
effects.forEach(run);
}
const isNonTrackableKeys = /*#__PURE__*/ shared.makeMap(`__proto__,__v_isRef,__isVue`);
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
.map(key => Symbol[key])
.filter(shared.isSymbol));
@@ -222,13 +223,13 @@ function createGetter(isReadonly = false, shallow = false) {
return target;
}
const targetIsArray = shared.isArray(target);
if (targetIsArray && shared.hasOwn(arrayInstrumentations, key)) {
if (!isReadonly && targetIsArray && shared.hasOwn(arrayInstrumentations, key)) {
return Reflect.get(arrayInstrumentations, key, receiver);
}
const res = Reflect.get(target, key, receiver);
if (shared.isSymbol(key)
? builtInSymbols.has(key)
: key === `__proto__` || key === `__v_isRef`) {
: isNonTrackableKeys(key)) {
return res;
}
if (!isReadonly) {
@@ -281,7 +282,7 @@ function createSetter(shallow = false) {
}
function deleteProperty(target, key) {
const hadKey = shared.hasOwn(target, key);
const oldValue = target[key];
target[key];
const result = Reflect.deleteProperty(target, key);
if (result && hadKey) {
trigger(target, "delete" /* DELETE */, key, undefined);
@@ -371,11 +372,11 @@ function add(value) {
const target = toRaw(this);
const proto = getProto(target);
const hadKey = proto.has.call(target, value);
const result = target.add(value);
target.add(value);
if (!hadKey) {
trigger(target, "add" /* ADD */, value, value);
}
return result;
return this;
}
function set$1(key, value) {
value = toRaw(value);
@@ -387,14 +388,14 @@ function set$1(key, value) {
hadKey = has.call(target, key);
}
const oldValue = get.call(target, key);
const result = target.set(key, value);
target.set(key, value);
if (!hadKey) {
trigger(target, "add" /* ADD */, key, value);
}
else if (shared.hasChanged(value, oldValue)) {
trigger(target, "set" /* SET */, key, value);
}
return result;
return this;
}
function deleteEntry(key) {
const target = toRaw(this);
@@ -404,7 +405,7 @@ function deleteEntry(key) {
key = toRaw(key);
hadKey = has.call(target, key);
}
const oldValue = get ? get.call(target, key) : undefined;
get ? get.call(target, key) : undefined;
// forward the operation before queueing reactions
const result = target.delete(key);
if (hadKey) {
@@ -582,19 +583,27 @@ function reactive(target) {
}
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are reactive, and does NOT unwrap refs nor recursively convert
// returned properties.
/**
* Return a shallowly-reactive copy of the original object, where only the root
* level properties are reactive. It also does not auto-unwrap refs (even at the
* root level).
*/
function shallowReactive(target) {
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers);
}
/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
function readonly(target) {
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are readonly, and does NOT unwrap refs nor recursively convert
// returned properties.
// This is used for creating the props proxy object for stateful components.
/**
* Returns a reactive-copy of the original object, where only the root level
* properties are readonly, and does NOT unwrap refs nor recursively convert
* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
function shallowReadonly(target) {
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers);
}
@@ -679,7 +688,7 @@ function createRef(rawValue, shallow = false) {
return new RefImpl(rawValue, shallow);
}
function triggerRef(ref) {
trigger(toRaw(ref), "set" /* SET */, 'value', void 0);
trigger(toRaw(ref), "set" /* SET */, 'value', void 0);
}
function unref(ref) {
return isRef(ref) ? ref.value : ref;
@@ -778,7 +787,7 @@ function computed(getterOrOptions) {
let setter;
if (shared.isFunction(getterOrOptions)) {
getter = getterOrOptions;
setter = shared.NOOP;
setter = shared.NOOP;
}
else {
getter = getterOrOptions.get;

View File

@@ -67,6 +67,28 @@ declare type Primitive = string | number | boolean | bigint | symbol | undefined
export declare function proxyRefs<T extends object>(objectWithRefs: T): ShallowUnwrapRef<T>;
/**
* Creates a reactive copy of the original object.
*
* The reactive conversion is "deep"—it affects all nested properties. In the
* ES2015 Proxy based implementation, the returned proxy is **not** equal to the
* original object. It is recommended to work exclusively with the reactive
* proxy and avoid relying on the original object.
*
* A reactive object also automatically unwraps refs contained in it, so you
* don't need to use `.value` when accessing and mutating their value:
*
* ```js
* const count = ref(0)
* const obj = reactive({
* count
* })
*
* obj.count++
* obj.count // -> 1
* count.value // -> 1
* ```
*/
export declare function reactive<T extends object>(target: T): UnwrapNestedRefs<T>;
export declare interface ReactiveEffect<T = any> {
@@ -96,6 +118,10 @@ export declare const enum ReactiveFlags {
RAW = "__v_raw"
}
/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
export declare function readonly<T extends object>(target: T): DeepReadonly<UnwrapNestedRefs<T>>;
export declare interface Ref<T = any> {
@@ -109,7 +135,7 @@ export declare interface Ref<T = any> {
/* Excluded from this release type: _shallow */
}
export declare function ref<T extends object>(value: T): T extends Ref ? T : Ref<UnwrapRef<T>>;
export declare function ref<T extends object>(value: T): ToRef<T>;
export declare function ref<T>(value: T): Ref<UnwrapRef<T>>;
@@ -139,8 +165,19 @@ export declare interface RefUnwrapBailTypes {
export declare function resetTracking(): void;
/**
* Return a shallowly-reactive copy of the original object, where only the root
* level properties are reactive. It also does not auto-unwrap refs (even at the
* root level).
*/
export declare function shallowReactive<T extends object>(target: T): T;
/**
* Returns a reactive-copy of the original object, where only the root level
* properties are readonly, and does NOT unwrap refs nor recursively convert
* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
export declare function shallowReadonly<T extends object>(target: T): Readonly<{
[K in keyof T]: UnwrapNestedRefs<T[K]>;
}>;
@@ -214,10 +251,12 @@ declare type SymbolExtract<T> = (T extends {
export declare function toRaw<T>(observed: T): T;
export declare function toRef<T extends object, K extends keyof T>(object: T, key: K): Ref<T[K]>;
declare type ToRef<T> = [T] extends [Ref] ? T : Ref<UnwrapRef<T>>;
export declare function toRef<T extends object, K extends keyof T>(object: T, key: K): ToRef<T[K]>;
export declare type ToRefs<T = any> = {
[K in keyof T]: Ref<T[K]>;
[K in keyof T]: T[K] extends Ref ? T[K] : Ref<UnwrapRef<T[K]>>;
};
export declare function toRefs<T extends object>(object: T): ToRefs<T>;

View File

@@ -1,6 +1,22 @@
const EMPTY_OBJ = Object.freeze({})
/**
* Make a map and return a function for checking if a key
* is in that map.
* IMPORTANT: all calls of this function must be prefixed with
* \/\*#\_\_PURE\_\_\*\/
* So that rollup can tree-shake them if necessary.
*/
function makeMap(str, expectsLowerCase) {
const map = Object.create(null);
const list = str.split(',');
for (let i = 0; i < list.length; i++) {
map[list[i]] = true;
}
return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
}
const EMPTY_OBJ = Object.freeze({})
;
const EMPTY_ARR = Object.freeze([]) ;
Object.freeze([]) ;
const extend = Object.assign;
const hasOwnProperty = Object.prototype.hasOwnProperty;
const hasOwn = (val, key) => hasOwnProperty.call(val, key);
@@ -44,8 +60,8 @@ const def = (obj, key, value) => {
const targetMap = new WeakMap();
const effectStack = [];
let activeEffect;
const ITERATE_KEY = Symbol( 'iterate' );
const MAP_KEY_ITERATE_KEY = Symbol( 'Map key iterate' );
const ITERATE_KEY = Symbol('iterate' );
const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
function isEffect(fn) {
return fn && fn._isEffect === true;
}
@@ -136,7 +152,7 @@ function track(target, type, key) {
if (!dep.has(activeEffect)) {
dep.add(activeEffect);
activeEffect.deps.push(dep);
if ( activeEffect.options.onTrack) {
if (activeEffect.options.onTrack) {
activeEffect.options.onTrack({
effect: activeEffect,
target,
@@ -209,7 +225,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
}
}
const run = (effect) => {
if ( effect.options.onTrigger) {
if (effect.options.onTrigger) {
effect.options.onTrigger({
effect,
target,
@@ -230,6 +246,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
effects.forEach(run);
}
const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
.map(key => Symbol[key])
.filter(isSymbol));
@@ -278,13 +295,13 @@ function createGetter(isReadonly = false, shallow = false) {
return target;
}
const targetIsArray = isArray(target);
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
return Reflect.get(arrayInstrumentations, key, receiver);
}
const res = Reflect.get(target, key, receiver);
if (isSymbol(key)
? builtInSymbols.has(key)
: key === `__proto__` || key === `__v_isRef`) {
: isNonTrackableKeys(key)) {
return res;
}
if (!isReadonly) {
@@ -433,11 +450,11 @@ function add(value) {
const target = toRaw(this);
const proto = getProto(target);
const hadKey = proto.has.call(target, value);
const result = target.add(value);
target.add(value);
if (!hadKey) {
trigger(target, "add" /* ADD */, value, value);
}
return result;
return this;
}
function set$1(key, value) {
value = toRaw(value);
@@ -452,14 +469,14 @@ function set$1(key, value) {
checkIdentityKeys(target, has, key);
}
const oldValue = get.call(target, key);
const result = target.set(key, value);
target.set(key, value);
if (!hadKey) {
trigger(target, "add" /* ADD */, key, value);
}
else if (hasChanged(value, oldValue)) {
trigger(target, "set" /* SET */, key, value, oldValue);
}
return result;
return this;
}
function deleteEntry(key) {
const target = toRaw(this);
@@ -483,7 +500,7 @@ function deleteEntry(key) {
function clear() {
const target = toRaw(this);
const hadItems = target.size !== 0;
const oldTarget = isMap(target)
const oldTarget = isMap(target)
? new Map(target)
: new Set(target)
;
@@ -669,19 +686,27 @@ function reactive(target) {
}
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are reactive, and does NOT unwrap refs nor recursively convert
// returned properties.
/**
* Return a shallowly-reactive copy of the original object, where only the root
* level properties are reactive. It also does not auto-unwrap refs (even at the
* root level).
*/
function shallowReactive(target) {
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers);
}
/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
function readonly(target) {
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are readonly, and does NOT unwrap refs nor recursively convert
// returned properties.
// This is used for creating the props proxy object for stateful components.
/**
* Returns a reactive-copy of the original object, where only the root level
* properties are readonly, and does NOT unwrap refs nor recursively convert
* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
function shallowReadonly(target) {
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers);
}
@@ -769,7 +794,7 @@ function createRef(rawValue, shallow = false) {
return new RefImpl(rawValue, shallow);
}
function triggerRef(ref) {
trigger(toRaw(ref), "set" /* SET */, 'value', ref.value );
trigger(toRaw(ref), "set" /* SET */, 'value', ref.value );
}
function unref(ref) {
return isRef(ref) ? ref.value : ref;
@@ -810,7 +835,7 @@ function customRef(factory) {
return new CustomRefImpl(factory);
}
function toRefs(object) {
if ( !isProxy(object)) {
if (!isProxy(object)) {
console.warn(`toRefs() expects a reactive object but received a plain one.`);
}
const ret = isArray(object) ? new Array(object.length) : {};
@@ -871,7 +896,7 @@ function computed(getterOrOptions) {
let setter;
if (isFunction(getterOrOptions)) {
getter = getterOrOptions;
setter = () => {
setter = () => {
console.warn('Write operation failed: computed value is readonly');
}
;

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
import { EMPTY_OBJ, isArray, isMap, isIntegerKey, isSymbol, extend, hasOwn, isObject, hasChanged, capitalize, toRawType, def, isFunction, NOOP } from '@vue/shared';
import { EMPTY_OBJ, isArray, isMap, isIntegerKey, isSymbol, extend, hasOwn, isObject, hasChanged, makeMap, capitalize, toRawType, def, isFunction, NOOP } from '@vue/shared';
const targetMap = new WeakMap();
const effectStack = [];
@@ -189,6 +189,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
effects.forEach(run);
}
const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
.map(key => Symbol[key])
.filter(isSymbol));
@@ -237,13 +238,13 @@ function createGetter(isReadonly = false, shallow = false) {
return target;
}
const targetIsArray = isArray(target);
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
return Reflect.get(arrayInstrumentations, key, receiver);
}
const res = Reflect.get(target, key, receiver);
if (isSymbol(key)
? builtInSymbols.has(key)
: key === `__proto__` || key === `__v_isRef`) {
: isNonTrackableKeys(key)) {
return res;
}
if (!isReadonly) {
@@ -392,11 +393,11 @@ function add(value) {
const target = toRaw(this);
const proto = getProto(target);
const hadKey = proto.has.call(target, value);
const result = target.add(value);
target.add(value);
if (!hadKey) {
trigger(target, "add" /* ADD */, value, value);
}
return result;
return this;
}
function set$1(key, value) {
value = toRaw(value);
@@ -411,14 +412,14 @@ function set$1(key, value) {
checkIdentityKeys(target, has, key);
}
const oldValue = get.call(target, key);
const result = target.set(key, value);
target.set(key, value);
if (!hadKey) {
trigger(target, "add" /* ADD */, key, value);
}
else if (hasChanged(value, oldValue)) {
trigger(target, "set" /* SET */, key, value, oldValue);
}
return result;
return this;
}
function deleteEntry(key) {
const target = toRaw(this);
@@ -629,19 +630,27 @@ function reactive(target) {
}
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are reactive, and does NOT unwrap refs nor recursively convert
// returned properties.
/**
* Return a shallowly-reactive copy of the original object, where only the root
* level properties are reactive. It also does not auto-unwrap refs (even at the
* root level).
*/
function shallowReactive(target) {
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers);
}
/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
function readonly(target) {
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are readonly, and does NOT unwrap refs nor recursively convert
// returned properties.
// This is used for creating the props proxy object for stateful components.
/**
* Returns a reactive-copy of the original object, where only the root level
* properties are readonly, and does NOT unwrap refs nor recursively convert
* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
function shallowReadonly(target) {
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers);
}

View File

@@ -1,9 +1,25 @@
var VueReactivity = (function (exports) {
'use strict';
const EMPTY_OBJ = Object.freeze({})
/**
* Make a map and return a function for checking if a key
* is in that map.
* IMPORTANT: all calls of this function must be prefixed with
* \/\*#\_\_PURE\_\_\*\/
* So that rollup can tree-shake them if necessary.
*/
function makeMap(str, expectsLowerCase) {
const map = Object.create(null);
const list = str.split(',');
for (let i = 0; i < list.length; i++) {
map[list[i]] = true;
}
return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
}
const EMPTY_OBJ = Object.freeze({})
;
const EMPTY_ARR = Object.freeze([]) ;
Object.freeze([]) ;
const extend = Object.assign;
const hasOwnProperty = Object.prototype.hasOwnProperty;
const hasOwn = (val, key) => hasOwnProperty.call(val, key);
@@ -47,8 +63,8 @@ var VueReactivity = (function (exports) {
const targetMap = new WeakMap();
const effectStack = [];
let activeEffect;
const ITERATE_KEY = Symbol( 'iterate' );
const MAP_KEY_ITERATE_KEY = Symbol( 'Map key iterate' );
const ITERATE_KEY = Symbol('iterate' );
const MAP_KEY_ITERATE_KEY = Symbol('Map key iterate' );
function isEffect(fn) {
return fn && fn._isEffect === true;
}
@@ -139,7 +155,7 @@ var VueReactivity = (function (exports) {
if (!dep.has(activeEffect)) {
dep.add(activeEffect);
activeEffect.deps.push(dep);
if ( activeEffect.options.onTrack) {
if (activeEffect.options.onTrack) {
activeEffect.options.onTrack({
effect: activeEffect,
target,
@@ -212,7 +228,7 @@ var VueReactivity = (function (exports) {
}
}
const run = (effect) => {
if ( effect.options.onTrigger) {
if (effect.options.onTrigger) {
effect.options.onTrigger({
effect,
target,
@@ -233,6 +249,7 @@ var VueReactivity = (function (exports) {
effects.forEach(run);
}
const isNonTrackableKeys = /*#__PURE__*/ makeMap(`__proto__,__v_isRef,__isVue`);
const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol)
.map(key => Symbol[key])
.filter(isSymbol));
@@ -281,13 +298,13 @@ var VueReactivity = (function (exports) {
return target;
}
const targetIsArray = isArray(target);
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
if (!isReadonly && targetIsArray && hasOwn(arrayInstrumentations, key)) {
return Reflect.get(arrayInstrumentations, key, receiver);
}
const res = Reflect.get(target, key, receiver);
if (isSymbol(key)
? builtInSymbols.has(key)
: key === `__proto__` || key === `__v_isRef`) {
: isNonTrackableKeys(key)) {
return res;
}
if (!isReadonly) {
@@ -436,11 +453,11 @@ var VueReactivity = (function (exports) {
const target = toRaw(this);
const proto = getProto(target);
const hadKey = proto.has.call(target, value);
const result = target.add(value);
target.add(value);
if (!hadKey) {
trigger(target, "add" /* ADD */, value, value);
}
return result;
return this;
}
function set$1(key, value) {
value = toRaw(value);
@@ -455,14 +472,14 @@ var VueReactivity = (function (exports) {
checkIdentityKeys(target, has, key);
}
const oldValue = get.call(target, key);
const result = target.set(key, value);
target.set(key, value);
if (!hadKey) {
trigger(target, "add" /* ADD */, key, value);
}
else if (hasChanged(value, oldValue)) {
trigger(target, "set" /* SET */, key, value, oldValue);
}
return result;
return this;
}
function deleteEntry(key) {
const target = toRaw(this);
@@ -486,7 +503,7 @@ var VueReactivity = (function (exports) {
function clear() {
const target = toRaw(this);
const hadItems = target.size !== 0;
const oldTarget = isMap(target)
const oldTarget = isMap(target)
? new Map(target)
: new Set(target)
;
@@ -672,19 +689,27 @@ var VueReactivity = (function (exports) {
}
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are reactive, and does NOT unwrap refs nor recursively convert
// returned properties.
/**
* Return a shallowly-reactive copy of the original object, where only the root
* level properties are reactive. It also does not auto-unwrap refs (even at the
* root level).
*/
function shallowReactive(target) {
return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers);
}
/**
* Creates a readonly copy of the original object. Note the returned copy is not
* made reactive, but `readonly` can be called on an already reactive object.
*/
function readonly(target) {
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers);
}
// Return a reactive-copy of the original object, where only the root level
// properties are readonly, and does NOT unwrap refs nor recursively convert
// returned properties.
// This is used for creating the props proxy object for stateful components.
/**
* Returns a reactive-copy of the original object, where only the root level
* properties are readonly, and does NOT unwrap refs nor recursively convert
* returned properties.
* This is used for creating the props proxy object for stateful components.
*/
function shallowReadonly(target) {
return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers);
}
@@ -772,7 +797,7 @@ var VueReactivity = (function (exports) {
return new RefImpl(rawValue, shallow);
}
function triggerRef(ref) {
trigger(toRaw(ref), "set" /* SET */, 'value', ref.value );
trigger(toRaw(ref), "set" /* SET */, 'value', ref.value );
}
function unref(ref) {
return isRef(ref) ? ref.value : ref;
@@ -813,7 +838,7 @@ var VueReactivity = (function (exports) {
return new CustomRefImpl(factory);
}
function toRefs(object) {
if ( !isProxy(object)) {
if (!isProxy(object)) {
console.warn(`toRefs() expects a reactive object but received a plain one.`);
}
const ret = isArray(object) ? new Array(object.length) : {};
@@ -874,7 +899,7 @@ var VueReactivity = (function (exports) {
let setter;
if (isFunction(getterOrOptions)) {
getter = getterOrOptions;
setter = () => {
setter = () => {
console.warn('Write operation failed: computed value is readonly');
}
;
@@ -914,6 +939,8 @@ var VueReactivity = (function (exports) {
exports.triggerRef = triggerRef;
exports.unref = unref;
Object.defineProperty(exports, '__esModule', { value: true });
return exports;
}({}));

File diff suppressed because one or more lines are too long

View File

@@ -1,33 +1,32 @@
{
"_args": [
[
"@vue/reactivity@3.0.2",
"@vue/reactivity@3.0.6",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "@vue/reactivity@3.0.2",
"_id": "@vue/reactivity@3.0.2",
"_from": "@vue/reactivity@3.0.6",
"_id": "@vue/reactivity@3.0.6",
"_inBundle": false,
"_integrity": "sha1-Qu1a9gJbSUpeabBRafzd8E7r/nc=",
"_integrity": "sha1-exbz1dBMxVAoCF//C7hHXMDjKZE=",
"_location": "/@vue/reactivity",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@vue/reactivity@3.0.2",
"raw": "@vue/reactivity@3.0.6",
"name": "@vue/reactivity",
"escapedName": "@vue%2freactivity",
"scope": "@vue",
"rawSpec": "3.0.2",
"rawSpec": "3.0.6",
"saveSpec": null,
"fetchSpec": "3.0.2"
"fetchSpec": "3.0.6"
},
"_requiredBy": [
"/@vue/runtime-core"
],
"_resolved": "http://192.168.250.101:4873/@vue%2freactivity/-/reactivity-3.0.2.tgz",
"_spec": "3.0.2",
"_resolved": "http://192.168.250.101:4873/@vue%2freactivity/-/reactivity-3.0.6.tgz",
"_spec": "3.0.6",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Evan You"
@@ -45,7 +44,7 @@
]
},
"dependencies": {
"@vue/shared": "3.0.2"
"@vue/shared": "3.0.6"
},
"description": "@vue/reactivity",
"files": [
@@ -69,5 +68,5 @@
"sideEffects": false,
"types": "dist/reactivity.d.ts",
"unpkg": "dist/reactivity.global.js",
"version": "3.0.2"
"version": "3.0.6"
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -55,7 +55,7 @@ export declare interface App<HostElement = any> {
directive(name: string): Directive | undefined;
directive(name: string, directive: Directive): this;
mount(rootContainer: HostElement | string, isHydrate?: boolean): ComponentPublicInstance;
unmount(rootContainer: HostElement | string): void;
unmount(): void;
provide<T>(key: InjectionKey<T> | string, value: T): this;
_uid: number;
_component: ConcreteComponent;
@@ -244,6 +244,7 @@ export declare interface ComponentInternalInstance {
*/
update: ReactiveEffect;
/* Excluded from this release type: render */
/* Excluded from this release type: ssrRender */
/* Excluded from this release type: provides */
/* Excluded from this release type: effects */
/* Excluded from this release type: accessCache */
@@ -253,6 +254,7 @@ export declare interface ComponentInternalInstance {
/* Excluded from this release type: propsOptions */
/* Excluded from this release type: emitsOptions */
proxy: ComponentPublicInstance | null;
exposed: Record<string, any> | null;
/* Excluded from this release type: withProxy */
/* Excluded from this release type: ctx */
data: Data;
@@ -306,7 +308,7 @@ export declare type ComponentObjectPropsOptions<P = Data> = {
export declare type ComponentOptions<Props = {}, RawBindings = any, D = any, C extends ComputedOptions = any, M extends MethodOptions = any, Mixin extends ComponentOptionsMixin = any, Extends extends ComponentOptionsMixin = any, E extends EmitsOptions = any> = ComponentOptionsBase<Props, RawBindings, D, C, M, Mixin, Extends, E> & ThisType<CreateComponentPublicInstance<{}, RawBindings, D, C, M, Mixin, Extends, E, Readonly<Props>>>;
export declare interface ComponentOptionsBase<Props, RawBindings, D, C extends ComputedOptions, M extends MethodOptions, Mixin extends ComponentOptionsMixin, Extends extends ComponentOptionsMixin, E extends EmitsOptions, EE extends string = string, Defaults = {}> extends LegacyOptions<Props, D, C, M, Mixin, Extends>, ComponentInternalOptions, ComponentCustomOptions {
setup?: (this: void, props: Props, ctx: SetupContext<E>) => Promise<RawBindings> | RawBindings | RenderFunction | void;
setup?: (this: void, props: Props & UnionToIntersection<ExtractOptionProp<Mixin>> & UnionToIntersection<ExtractOptionProp<Extends>>, ctx: SetupContext<E>) => Promise<RawBindings> | RawBindings | RenderFunction | void;
name?: string;
template?: string | object;
render?: Function;
@@ -314,8 +316,10 @@ export declare interface ComponentOptionsBase<Props, RawBindings, D, C extends C
directives?: Record<string, Directive>;
inheritAttrs?: boolean;
emits?: (E | EE[]) & ThisType<void>;
expose?: string[];
serverPrefetch?(): Promise<any>;
/* Excluded from this release type: ssrRender */
/* Excluded from this release type: __ssrInlineRender */
/* Excluded from this release type: __asyncLoader */
/* Excluded from this release type: __merged */
call?: (this: unknown, ...args: unknown[]) => never;
@@ -420,7 +424,7 @@ declare type CreateComponentPublicInstance<P = {}, B = {}, D = {}, C extends Com
export declare function createHydrationRenderer(options: RendererOptions<Node, Element>): HydrationRenderer;
declare function createRecord(id: string): boolean;
declare function createRecord(id: string, component: ComponentOptions | ClassComponent): boolean;
/**
* The createRenderer function accepts two generic arguments:
@@ -497,6 +501,19 @@ export declare function defineComponent<PropNames extends string, RawBindings, D
export declare function defineComponent<PropsOptions extends Readonly<ComponentPropsOptions>, RawBindings, D, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = Record<string, any>, EE extends string = string>(options: ComponentOptionsWithObjectProps<PropsOptions, RawBindings, D, C, M, Mixin, Extends, E, EE>): DefineComponent<PropsOptions, RawBindings, D, C, M, Mixin, Extends, E, EE>;
export declare function defineEmit<TypeEmit = undefined, E extends EmitsOptions = EmitsOptions, EE extends string = string, InferredEmit = EmitFn<E>>(emitOptions?: E | EE[]): TypeEmit extends undefined ? InferredEmit : TypeEmit;
/**
* Compile-time-only helper used for declaring props inside `<script setup>`.
* This is stripped away in the compiled code and should never be actually
* called at runtime.
*/
export declare function defineProps<TypeProps = undefined, PropNames extends string = string, InferredProps = {
[key in PropNames]?: any;
}>(props?: PropNames[]): Readonly<TypeProps extends undefined ? InferredProps : TypeProps>;
export declare function defineProps<TypeProps = undefined, PP extends ComponentObjectPropsOptions = ComponentObjectPropsOptions, InferredProps = ExtractPropTypes<PP>>(props?: PP): Readonly<TypeProps extends undefined ? InferredProps : TypeProps>;
export declare let devtools: DevtoolsHook;
declare interface DevtoolsHook {
@@ -568,6 +585,8 @@ declare type ExtractMixin<T> = {
Mixin: MixinToOptionTypes<T>;
}[T extends ComponentOptionsMixin ? 'Mixin' : never];
declare type ExtractOptionProp<T> = T extends ComponentOptionsBase<infer P, any, any, any, any, any, any, any> ? unknown extends P ? {} : P : {};
export declare type ExtractPropTypes<O> = O extends object ? {
[K in RequiredKeys<O>]: InferPropType<O[K]>;
} & {
@@ -584,7 +603,7 @@ export declare const Fragment: {
};
export declare interface FunctionalComponent<P = {}, E extends EmitsOptions = {}> extends ComponentInternalOptions {
(props: P, ctx: SetupContext<E>): any;
(props: P, ctx: Omit<SetupContext<E>, 'expose'>): any;
props?: ComponentPropsOptions<P>;
emits?: E | (keyof E)[];
inheritAttrs?: boolean;
@@ -653,7 +672,9 @@ declare type InferPropType<T> = T extends null ? any : T extends {
type: ObjectConstructor;
} ? Record<string, any> : T extends BooleanConstructor | {
type: BooleanConstructor;
} ? boolean : T extends Prop<infer V, infer D> ? (unknown extends V ? D : V) : T;
} ? boolean : T extends DateConstructor | {
type: DateConstructor;
} ? Date : T extends Prop<infer V, infer D> ? (unknown extends V ? D : V) : T;
export declare function initCustomFormatter(): void;
@@ -699,7 +720,7 @@ export declare interface KeepAliveProps {
declare interface LegacyOptions<Props, D, C extends ComputedOptions, M extends MethodOptions, Mixin extends ComponentOptionsMixin, Extends extends ComponentOptionsMixin> {
[key: string]: any;
data?: (this: CreateComponentPublicInstance<Props>, vm: CreateComponentPublicInstance<Props>) => D;
data?: (this: CreateComponentPublicInstance<Props, {}, {}, {}, MethodOptions, Mixin, Extends>, vm: CreateComponentPublicInstance<Props, {}, {}, {}, MethodOptions, Mixin, Extends>) => D;
computed?: C;
methods?: M;
watch?: ComponentWatchOptions;
@@ -774,6 +795,8 @@ declare const enum MoveType {
REORDER = 2
}
declare type MultiWatchSources = (WatchSource<unknown> | object)[];
declare type NextFn = (vnode: VNode) => RendererNode | null;
export declare function nextTick(this: ComponentPublicInstance | void, fn?: () => void): Promise<void>;
@@ -903,7 +926,7 @@ declare interface PropOptions<T = any, D = T> {
export declare type PropType<T> = PropConstructor<T> | PropConstructor<T>[];
export declare function provide<T>(key: InjectionKey<T> | string, value: T): void;
export declare function provide<T>(key: InjectionKey<T> | string | number, value: T): void;
export { proxyRefs }
declare type PublicProps = VNodeProps & AllowedComponentProps & ComponentCustomProps;
@@ -1093,6 +1116,7 @@ export declare interface SetupContext<E = EmitsOptions> {
attrs: Data;
slots: Slots;
emit: EmitFn<E>;
expose: (exposed: Record<string, any>) => void;
}
declare type SetupRenderEffectFn = (instance: ComponentInternalInstance, initialVNode: VNode, container: RendererElement, anchor: RendererNode | null, parentSuspense: SuspenseBoundary | null, isSVG: boolean, optimized: boolean) => void;
@@ -1242,6 +1266,8 @@ export { unref }
declare type UnwrapMixinsType<T, Type extends OptionTypesKeys> = T extends OptionTypesType ? T[Type] : never;
export { UnwrapRef }
export declare function useContext(): SetupContext;
export declare const useSSRContext: <T = Record<string, any>>() => T | undefined;
export declare function useTransitionState(): TransitionState;
@@ -1315,7 +1341,9 @@ declare type VNodeUpdateHook = (vnode: VNode, oldVNode: VNode) => void;
export declare function warn(msg: string, ...args: any[]): void;
export declare function watch<T extends Readonly<Array<WatchSource<unknown> | object>>, Immediate extends Readonly<boolean> = false>(sources: T, cb: WatchCallback<MapSources<T, false>, MapSources<T, Immediate>>, options?: WatchOptions<Immediate>): WatchStopHandle;
export declare function watch<T extends MultiWatchSources, Immediate extends Readonly<boolean> = false>(sources: [...T], cb: WatchCallback<MapSources<T, false>, MapSources<T, Immediate>>, options?: WatchOptions<Immediate>): WatchStopHandle;
export declare function watch<T extends Readonly<MultiWatchSources>, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<MapSources<T, false>, MapSources<T, Immediate>>, options?: WatchOptions<Immediate>): WatchStopHandle;
export declare function watch<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? (T | undefined) : T>, options?: WatchOptions<Immediate>): WatchStopHandle;

File diff suppressed because it is too large Load Diff

View File

@@ -1,33 +1,32 @@
{
"_args": [
[
"@vue/runtime-core@3.0.2",
"@vue/runtime-core@3.0.6",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "@vue/runtime-core@3.0.2",
"_id": "@vue/runtime-core@3.0.2",
"_from": "@vue/runtime-core@3.0.6",
"_id": "@vue/runtime-core@3.0.6",
"_inBundle": false,
"_integrity": "sha1-1+1GKvHLC/mDZmjk5vqz8vSxvAA=",
"_integrity": "sha1-0Wd5tWZFk/HSW+Z3+xsZaAJKpTI=",
"_location": "/@vue/runtime-core",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@vue/runtime-core@3.0.2",
"raw": "@vue/runtime-core@3.0.6",
"name": "@vue/runtime-core",
"escapedName": "@vue%2fruntime-core",
"scope": "@vue",
"rawSpec": "3.0.2",
"rawSpec": "3.0.6",
"saveSpec": null,
"fetchSpec": "3.0.2"
"fetchSpec": "3.0.6"
},
"_requiredBy": [
"/@vue/runtime-dom"
],
"_resolved": "http://192.168.250.101:4873/@vue%2fruntime-core/-/runtime-core-3.0.2.tgz",
"_spec": "3.0.2",
"_resolved": "http://192.168.250.101:4873/@vue%2fruntime-core/-/runtime-core-3.0.6.tgz",
"_spec": "3.0.6",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Evan You"
@@ -43,8 +42,8 @@
]
},
"dependencies": {
"@vue/reactivity": "3.0.2",
"@vue/shared": "3.0.2"
"@vue/reactivity": "3.0.6",
"@vue/shared": "3.0.6"
},
"description": "@vue/runtime-core",
"files": [
@@ -66,5 +65,5 @@
},
"sideEffects": false,
"types": "dist/runtime-core.d.ts",
"version": "3.0.2"
"version": "3.0.6"
}

View File

@@ -197,25 +197,34 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
}
return;
}
if (value === '' && typeof el[key] === 'boolean') {
// e.g. <select multiple> compiles to { multiple: '' }
el[key] = true;
}
else if (value == null && typeof el[key] === 'string') {
// e.g. <div :id="null">
el[key] = '';
el.removeAttribute(key);
}
else {
// some properties perform value validation and throw
try {
el[key] = value;
if (value === '' || value == null) {
const type = typeof el[key];
if (value === '' && type === 'boolean') {
// e.g. <select multiple> compiles to { multiple: '' }
el[key] = true;
return;
}
catch (e) {
{
runtimeCore.warn(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
`value ${value} is invalid.`, e);
}
else if (value == null && type === 'string') {
// e.g. <div :id="null">
el[key] = '';
el.removeAttribute(key);
return;
}
else if (type === 'number') {
// e.g. <img :width="null">
el[key] = 0;
el.removeAttribute(key);
return;
}
}
// some properties perform value validation and throw
try {
el[key] = value;
}
catch (e) {
{
runtimeCore.warn(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
`value ${value} is invalid.`, e);
}
}
}
@@ -280,7 +289,7 @@ function parseName(name) {
options[m[0].toLowerCase()] = true;
}
}
return [name.slice(2).toLowerCase(), options];
return [shared.hyphenate(name.slice(2)), options];
}
function createInvoker(initialValue, instance) {
const invoker = (e) => {
@@ -372,15 +381,19 @@ function shouldSetAsProp(el, key, value, isSVG) {
if (key === 'spellcheck' || key === 'draggable') {
return false;
}
// #1787 form as an attribute must be a string, while it accepts an Element as
// a prop
if (key === 'form' && typeof value === 'string') {
// #1787, #2840 form property on form elements is readonly and must be set as
// attribute.
if (key === 'form') {
return false;
}
// #1526 <input list> must be set as attribute
if (key === 'list' && el.tagName === 'INPUT') {
return false;
}
// #2766 <textarea type> must be set as attribute
if (key === 'type' && el.tagName === 'TEXTAREA') {
return false;
}
// native onclick with string value, must be set as attribute
if (nativeOnRE.test(key) && shared.isString(value)) {
return false;
@@ -393,62 +406,29 @@ function useCssModule(name = '$style') {
{
const instance = runtimeCore.getCurrentInstance();
if (!instance) {
runtimeCore.warn(`useCssModule must be called inside setup()`);
runtimeCore.warn(`useCssModule must be called inside setup()`);
return shared.EMPTY_OBJ;
}
const modules = instance.type.__cssModules;
if (!modules) {
runtimeCore.warn(`Current instance does not have CSS modules injected.`);
runtimeCore.warn(`Current instance does not have CSS modules injected.`);
return shared.EMPTY_OBJ;
}
const mod = modules[name];
if (!mod) {
runtimeCore.warn(`Current instance does not have CSS module named "${name}".`);
runtimeCore.warn(`Current instance does not have CSS module named "${name}".`);
return shared.EMPTY_OBJ;
}
return mod;
}
}
function useCssVars(getter, scoped = false) {
const instance = runtimeCore.getCurrentInstance();
/* istanbul ignore next */
if (!instance) {
runtimeCore.warn(`useCssVars is called without current active component instance.`);
return;
}
const prefix = scoped && instance.type.__scopeId
? `${instance.type.__scopeId.replace(/^data-v-/, '')}-`
: ``;
const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy), prefix);
runtimeCore.onMounted(() => runtimeCore.watchEffect(setVars));
runtimeCore.onUpdated(setVars);
}
function setVarsOnVNode(vnode, vars, prefix) {
if ( vnode.shapeFlag & 128 /* SUSPENSE */) {
const suspense = vnode.suspense;
vnode = suspense.activeBranch;
if (suspense.pendingBranch && !suspense.isHydrating) {
suspense.effects.push(() => {
setVarsOnVNode(suspense.activeBranch, vars, prefix);
});
}
}
// drill down HOCs until it's a non-component vnode
while (vnode.component) {
vnode = vnode.component.subTree;
}
if (vnode.shapeFlag & 1 /* ELEMENT */ && vnode.el) {
const style = vnode.el.style;
for (const key in vars) {
style.setProperty(`--${prefix}${key}`, runtimeCore.unref(vars[key]));
}
}
else if (vnode.type === runtimeCore.Fragment) {
vnode.children.forEach(c => setVarsOnVNode(c, vars, prefix));
}
/**
* Runtime helper for SFC's CSS variable injection feature.
* @private
*/
function useCssVars(getter) {
return;
}
const TRANSITION = 'transition';
@@ -510,12 +490,7 @@ function resolveTransitionProps(rawProps) {
removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
addTransitionClass(el, isAppear ? appearToClass : enterToClass);
if (!(hook && hook.length > 1)) {
if (enterDuration) {
setTimeout(resolve, enterDuration);
}
else {
whenTransitionEnds(el, type, resolve);
}
whenTransitionEnds(el, type, enterDuration, resolve);
}
});
};
@@ -523,30 +498,27 @@ function resolveTransitionProps(rawProps) {
return shared.extend(baseProps, {
onBeforeEnter(el) {
onBeforeEnter && onBeforeEnter(el);
addTransitionClass(el, enterActiveClass);
addTransitionClass(el, enterFromClass);
addTransitionClass(el, enterActiveClass);
},
onBeforeAppear(el) {
onBeforeAppear && onBeforeAppear(el);
addTransitionClass(el, appearActiveClass);
addTransitionClass(el, appearFromClass);
addTransitionClass(el, appearActiveClass);
},
onEnter: makeEnterHook(false),
onAppear: makeEnterHook(true),
onLeave(el, done) {
const resolve = () => finishLeave(el, done);
addTransitionClass(el, leaveActiveClass);
addTransitionClass(el, leaveFromClass);
// force reflow so *-leave-from classes immediately take effect (#2593)
forceReflow();
addTransitionClass(el, leaveActiveClass);
nextFrame(() => {
removeTransitionClass(el, leaveFromClass);
addTransitionClass(el, leaveToClass);
if (!(onLeave && onLeave.length > 1)) {
if (leaveDuration) {
setTimeout(resolve, leaveDuration);
}
else {
whenTransitionEnds(el, type, resolve);
}
whenTransitionEnds(el, type, leaveDuration, resolve);
}
});
onLeave && onLeave(el, resolve);
@@ -612,22 +584,30 @@ function nextFrame(cb) {
requestAnimationFrame(cb);
});
}
function whenTransitionEnds(el, expectedType, cb) {
let endId = 0;
function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
const id = (el._endId = ++endId);
const resolveIfNotStale = () => {
if (id === el._endId) {
resolve();
}
};
if (explicitTimeout) {
return setTimeout(resolveIfNotStale, explicitTimeout);
}
const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
if (!type) {
return cb();
return resolve();
}
const endEvent = type + 'end';
let ended = 0;
const end = () => {
el.removeEventListener(endEvent, onEnd);
cb();
resolveIfNotStale();
};
const onEnd = (e) => {
if (e.target === el) {
if (++ended >= propCount) {
end();
}
if (e.target === el && ++ended >= propCount) {
end();
}
};
setTimeout(() => {
@@ -701,9 +681,9 @@ function getTimeout(delays, durations) {
function toMs(s) {
return Number(s.slice(0, -1).replace(',', '.')) * 1000;
}
function toRaw(observed) {
return ((observed && toRaw(observed["__v_raw" /* RAW */])) || observed);
// synchronously force layout to put elements into a certain state
function forceReflow() {
return document.body.offsetHeight;
}
const positionMap = new WeakMap();
@@ -754,7 +734,7 @@ const TransitionGroupImpl = {
});
});
return () => {
const rawProps = toRaw(props);
const rawProps = runtimeCore.toRaw(props);
const cssTransitionProps = resolveTransitionProps(rawProps);
const tag = rawProps.tag || runtimeCore.Fragment;
prevChildren = children;
@@ -804,10 +784,6 @@ function applyTranslation(c) {
return c;
}
}
// this is put in a dedicated function to avoid the line from being treeshaken
function forceReflow() {
return document.body.offsetHeight;
}
function hasCSSTransform(el, root, moveClass) {
// Detect whether an element with the move class applied has
// CSS transitions. Since the element may be inside an entering
@@ -907,8 +883,7 @@ const vModelText = {
}
};
const vModelCheckbox = {
created(el, binding, vnode) {
setChecked(el, binding, vnode);
created(el, _, vnode) {
el._assign = getModelAssigner(vnode);
addEventListener(el, 'change', () => {
const modelValue = el._modelValue;
@@ -928,18 +903,22 @@ const vModelCheckbox = {
}
}
else if (shared.isSet(modelValue)) {
const cloned = new Set(modelValue);
if (checked) {
modelValue.add(elementValue);
cloned.add(elementValue);
}
else {
modelValue.delete(elementValue);
cloned.delete(elementValue);
}
assign(cloned);
}
else {
assign(getCheckboxValue(el, checked));
}
});
},
// set initial checked on mount to wait for true-value/false-value
mounted: setChecked,
beforeUpdate(el, binding, vnode) {
el._assign = getModelAssigner(vnode);
setChecked(el, binding, vnode);
@@ -973,12 +952,17 @@ const vModelRadio = {
}
};
const vModelSelect = {
created(el, { modifiers: { number } }, vnode) {
created(el, { value, modifiers: { number } }, vnode) {
const isSetModel = shared.isSet(value);
addEventListener(el, 'change', () => {
const selectedVal = Array.prototype.filter
.call(el.options, (o) => o.selected)
.map((o) => number ? shared.toNumber(getValue(o)) : getValue(o));
el._assign(el.multiple ? selectedVal : selectedVal[0]);
el._assign(el.multiple
? isSetModel
? new Set(selectedVal)
: selectedVal
: selectedVal[0]);
});
el._assign = getModelAssigner(vnode);
},
@@ -997,8 +981,7 @@ const vModelSelect = {
function setSelected(el, value) {
const isMultiple = el.multiple;
if (isMultiple && !shared.isArray(value) && !shared.isSet(value)) {
runtimeCore.warn(`<select multiple v-model> expects an Array or Set value for its binding, ` +
runtimeCore.warn(`<select multiple v-model> expects an Array or Set value for its binding, ` +
`but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
return;
}
@@ -1167,9 +1150,7 @@ const vShow = {
}
},
updated(el, { value, oldValue }, { transition }) {
if (!value === !oldValue)
return;
if (transition) {
if (transition && value !== oldValue) {
if (value) {
transition.beforeEnter(el);
setDisplay(el, true);
@@ -1239,8 +1220,10 @@ const createApp = ((...args) => {
// clear content before mounting
container.innerHTML = '';
const proxy = mount(container);
container.removeAttribute('v-cloak');
container.setAttribute('data-v-app', '');
if (container instanceof Element) {
container.removeAttribute('v-cloak');
container.setAttribute('data-v-app', '');
}
return proxy;
};
return app;
@@ -1270,17 +1253,18 @@ function injectNativeTagCheck(app) {
function normalizeContainer(container) {
if (shared.isString(container)) {
const res = document.querySelector(container);
if ( !res) {
runtimeCore.warn(`Failed to mount app: mount target selector returned null.`);
if (!res) {
runtimeCore.warn(`Failed to mount app: mount target selector "${container}" returned null.`);
}
return res;
}
if (container instanceof window.ShadowRoot &&
container.mode === 'closed') {
runtimeCore.warn(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
}
return container;
}
Object.keys(runtimeCore).forEach(function (k) {
if (k !== 'default') exports[k] = runtimeCore[k];
});
exports.Transition = Transition;
exports.TransitionGroup = TransitionGroup;
exports.createApp = createApp;
@@ -1297,3 +1281,6 @@ exports.vModelText = vModelText;
exports.vShow = vShow;
exports.withKeys = withKeys;
exports.withModifiers = withModifiers;
Object.keys(runtimeCore).forEach(function (k) {
if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = runtimeCore[k];
});

View File

@@ -197,22 +197,31 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
}
return;
}
if (value === '' && typeof el[key] === 'boolean') {
// e.g. <select multiple> compiles to { multiple: '' }
el[key] = true;
}
else if (value == null && typeof el[key] === 'string') {
// e.g. <div :id="null">
el[key] = '';
el.removeAttribute(key);
}
else {
// some properties perform value validation and throw
try {
el[key] = value;
if (value === '' || value == null) {
const type = typeof el[key];
if (value === '' && type === 'boolean') {
// e.g. <select multiple> compiles to { multiple: '' }
el[key] = true;
return;
}
catch (e) {
else if (value == null && type === 'string') {
// e.g. <div :id="null">
el[key] = '';
el.removeAttribute(key);
return;
}
else if (type === 'number') {
// e.g. <img :width="null">
el[key] = 0;
el.removeAttribute(key);
return;
}
}
// some properties perform value validation and throw
try {
el[key] = value;
}
catch (e) {
}
}
@@ -276,7 +285,7 @@ function parseName(name) {
options[m[0].toLowerCase()] = true;
}
}
return [name.slice(2).toLowerCase(), options];
return [shared.hyphenate(name.slice(2)), options];
}
function createInvoker(initialValue, instance) {
const invoker = (e) => {
@@ -368,15 +377,19 @@ function shouldSetAsProp(el, key, value, isSVG) {
if (key === 'spellcheck' || key === 'draggable') {
return false;
}
// #1787 form as an attribute must be a string, while it accepts an Element as
// a prop
if (key === 'form' && typeof value === 'string') {
// #1787, #2840 form property on form elements is readonly and must be set as
// attribute.
if (key === 'form') {
return false;
}
// #1526 <input list> must be set as attribute
if (key === 'list' && el.tagName === 'INPUT') {
return false;
}
// #2766 <textarea type> must be set as attribute
if (key === 'type' && el.tagName === 'TEXTAREA') {
return false;
}
// native onclick with string value, must be set as attribute
if (nativeOnRE.test(key) && shared.isString(value)) {
return false;
@@ -403,42 +416,12 @@ function useCssModule(name = '$style') {
}
}
function useCssVars(getter, scoped = false) {
const instance = runtimeCore.getCurrentInstance();
/* istanbul ignore next */
if (!instance) {
return;
}
const prefix = scoped && instance.type.__scopeId
? `${instance.type.__scopeId.replace(/^data-v-/, '')}-`
: ``;
const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy), prefix);
runtimeCore.onMounted(() => runtimeCore.watchEffect(setVars));
runtimeCore.onUpdated(setVars);
}
function setVarsOnVNode(vnode, vars, prefix) {
if ( vnode.shapeFlag & 128 /* SUSPENSE */) {
const suspense = vnode.suspense;
vnode = suspense.activeBranch;
if (suspense.pendingBranch && !suspense.isHydrating) {
suspense.effects.push(() => {
setVarsOnVNode(suspense.activeBranch, vars, prefix);
});
}
}
// drill down HOCs until it's a non-component vnode
while (vnode.component) {
vnode = vnode.component.subTree;
}
if (vnode.shapeFlag & 1 /* ELEMENT */ && vnode.el) {
const style = vnode.el.style;
for (const key in vars) {
style.setProperty(`--${prefix}${key}`, runtimeCore.unref(vars[key]));
}
}
else if (vnode.type === runtimeCore.Fragment) {
vnode.children.forEach(c => setVarsOnVNode(c, vars, prefix));
}
/**
* Runtime helper for SFC's CSS variable injection feature.
* @private
*/
function useCssVars(getter) {
return;
}
const TRANSITION = 'transition';
@@ -500,12 +483,7 @@ function resolveTransitionProps(rawProps) {
removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
addTransitionClass(el, isAppear ? appearToClass : enterToClass);
if (!(hook && hook.length > 1)) {
if (enterDuration) {
setTimeout(resolve, enterDuration);
}
else {
whenTransitionEnds(el, type, resolve);
}
whenTransitionEnds(el, type, enterDuration, resolve);
}
});
};
@@ -513,30 +491,27 @@ function resolveTransitionProps(rawProps) {
return shared.extend(baseProps, {
onBeforeEnter(el) {
onBeforeEnter && onBeforeEnter(el);
addTransitionClass(el, enterActiveClass);
addTransitionClass(el, enterFromClass);
addTransitionClass(el, enterActiveClass);
},
onBeforeAppear(el) {
onBeforeAppear && onBeforeAppear(el);
addTransitionClass(el, appearActiveClass);
addTransitionClass(el, appearFromClass);
addTransitionClass(el, appearActiveClass);
},
onEnter: makeEnterHook(false),
onAppear: makeEnterHook(true),
onLeave(el, done) {
const resolve = () => finishLeave(el, done);
addTransitionClass(el, leaveActiveClass);
addTransitionClass(el, leaveFromClass);
// force reflow so *-leave-from classes immediately take effect (#2593)
forceReflow();
addTransitionClass(el, leaveActiveClass);
nextFrame(() => {
removeTransitionClass(el, leaveFromClass);
addTransitionClass(el, leaveToClass);
if (!(onLeave && onLeave.length > 1)) {
if (leaveDuration) {
setTimeout(resolve, leaveDuration);
}
else {
whenTransitionEnds(el, type, resolve);
}
whenTransitionEnds(el, type, leaveDuration, resolve);
}
});
onLeave && onLeave(el, resolve);
@@ -591,22 +566,30 @@ function nextFrame(cb) {
requestAnimationFrame(cb);
});
}
function whenTransitionEnds(el, expectedType, cb) {
let endId = 0;
function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
const id = (el._endId = ++endId);
const resolveIfNotStale = () => {
if (id === el._endId) {
resolve();
}
};
if (explicitTimeout) {
return setTimeout(resolveIfNotStale, explicitTimeout);
}
const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
if (!type) {
return cb();
return resolve();
}
const endEvent = type + 'end';
let ended = 0;
const end = () => {
el.removeEventListener(endEvent, onEnd);
cb();
resolveIfNotStale();
};
const onEnd = (e) => {
if (e.target === el) {
if (++ended >= propCount) {
end();
}
if (e.target === el && ++ended >= propCount) {
end();
}
};
setTimeout(() => {
@@ -680,9 +663,9 @@ function getTimeout(delays, durations) {
function toMs(s) {
return Number(s.slice(0, -1).replace(',', '.')) * 1000;
}
function toRaw(observed) {
return ((observed && toRaw(observed["__v_raw" /* RAW */])) || observed);
// synchronously force layout to put elements into a certain state
function forceReflow() {
return document.body.offsetHeight;
}
const positionMap = new WeakMap();
@@ -733,7 +716,7 @@ const TransitionGroupImpl = {
});
});
return () => {
const rawProps = toRaw(props);
const rawProps = runtimeCore.toRaw(props);
const cssTransitionProps = resolveTransitionProps(rawProps);
const tag = rawProps.tag || runtimeCore.Fragment;
prevChildren = children;
@@ -780,10 +763,6 @@ function applyTranslation(c) {
return c;
}
}
// this is put in a dedicated function to avoid the line from being treeshaken
function forceReflow() {
return document.body.offsetHeight;
}
function hasCSSTransform(el, root, moveClass) {
// Detect whether an element with the move class applied has
// CSS transitions. Since the element may be inside an entering
@@ -883,8 +862,7 @@ const vModelText = {
}
};
const vModelCheckbox = {
created(el, binding, vnode) {
setChecked(el, binding, vnode);
created(el, _, vnode) {
el._assign = getModelAssigner(vnode);
addEventListener(el, 'change', () => {
const modelValue = el._modelValue;
@@ -904,18 +882,22 @@ const vModelCheckbox = {
}
}
else if (shared.isSet(modelValue)) {
const cloned = new Set(modelValue);
if (checked) {
modelValue.add(elementValue);
cloned.add(elementValue);
}
else {
modelValue.delete(elementValue);
cloned.delete(elementValue);
}
assign(cloned);
}
else {
assign(getCheckboxValue(el, checked));
}
});
},
// set initial checked on mount to wait for true-value/false-value
mounted: setChecked,
beforeUpdate(el, binding, vnode) {
el._assign = getModelAssigner(vnode);
setChecked(el, binding, vnode);
@@ -949,12 +931,17 @@ const vModelRadio = {
}
};
const vModelSelect = {
created(el, { modifiers: { number } }, vnode) {
created(el, { value, modifiers: { number } }, vnode) {
const isSetModel = shared.isSet(value);
addEventListener(el, 'change', () => {
const selectedVal = Array.prototype.filter
.call(el.options, (o) => o.selected)
.map((o) => number ? shared.toNumber(getValue(o)) : getValue(o));
el._assign(el.multiple ? selectedVal : selectedVal[0]);
el._assign(el.multiple
? isSetModel
? new Set(selectedVal)
: selectedVal
: selectedVal[0]);
});
el._assign = getModelAssigner(vnode);
},
@@ -1140,9 +1127,7 @@ const vShow = {
}
},
updated(el, { value, oldValue }, { transition }) {
if (!value === !oldValue)
return;
if (transition) {
if (transition && value !== oldValue) {
if (value) {
transition.beforeEnter(el);
setDisplay(el, true);
@@ -1209,8 +1194,10 @@ const createApp = ((...args) => {
// clear content before mounting
container.innerHTML = '';
const proxy = mount(container);
container.removeAttribute('v-cloak');
container.setAttribute('data-v-app', '');
if (container instanceof Element) {
container.removeAttribute('v-cloak');
container.setAttribute('data-v-app', '');
}
return proxy;
};
return app;
@@ -1234,9 +1221,6 @@ function normalizeContainer(container) {
return container;
}
Object.keys(runtimeCore).forEach(function (k) {
if (k !== 'default') exports[k] = runtimeCore[k];
});
exports.Transition = Transition;
exports.TransitionGroup = TransitionGroup;
exports.createApp = createApp;
@@ -1253,3 +1237,6 @@ exports.vModelText = vModelText;
exports.vShow = vShow;
exports.withKeys = withKeys;
exports.withModifiers = withModifiers;
Object.keys(runtimeCore).forEach(function (k) {
if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = runtimeCore[k];
});

View File

@@ -1,5 +1,4 @@
import { BaseTransitionProps } from '@vue/runtime-core';
import { ComponentPublicInstance } from '@vue/runtime-core';
import { CreateAppFunction } from '@vue/runtime-core';
import { FunctionalComponent } from '@vue/runtime-core';
import { ObjectDirective } from '@vue/runtime-core';
@@ -56,7 +55,11 @@ export declare interface TransitionProps extends BaseTransitionProps<Element> {
export declare function useCssModule(name?: string): Record<string, string>;
export declare function useCssVars(getter: (ctx: ComponentPublicInstance) => Record<string, string>, scoped?: boolean): void;
/**
* Runtime helper for SFC's CSS variable injection feature.
* @private
*/
export declare function useCssVars(getter: (ctx: any) => Record<string, string>): void;
export declare const vModelCheckbox: ModelDirective<HTMLInputElement>;
@@ -1304,6 +1307,8 @@ export interface Events {
// focus events
onFocus: FocusEvent
onFocusin: FocusEvent
onFocusout: FocusEvent
onBlur: FocusEvent
// form events

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
import { camelize, warn, callWithAsyncErrorHandling, getCurrentInstance, onMounted, watchEffect, onUpdated, unref, Fragment, h, BaseTransition, useTransitionState, getTransitionRawChildren, setTransitionHooks, resolveTransitionHooks, createVNode, createRenderer, createHydrationRenderer } from '@vue/runtime-core';
import { camelize, warn, callWithAsyncErrorHandling, getCurrentInstance, onMounted, watchEffect, onUpdated, Fragment, h, BaseTransition, useTransitionState, toRaw, getTransitionRawChildren, setTransitionHooks, resolveTransitionHooks, createVNode, createRenderer, createHydrationRenderer } from '@vue/runtime-core';
export * from '@vue/runtime-core';
import { isString, isArray, hyphenate, capitalize, isSpecialBooleanAttr, isOn, isModelListener, isFunction, EMPTY_OBJ, extend, isObject, toNumber, invokeArrayFns, looseIndexOf, isSet, looseEqual, isHTMLTag, isSVGTag } from '@vue/shared';
@@ -194,25 +194,34 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
}
return;
}
if (value === '' && typeof el[key] === 'boolean') {
// e.g. <select multiple> compiles to { multiple: '' }
el[key] = true;
}
else if (value == null && typeof el[key] === 'string') {
// e.g. <div :id="null">
el[key] = '';
el.removeAttribute(key);
}
else {
// some properties perform value validation and throw
try {
el[key] = value;
if (value === '' || value == null) {
const type = typeof el[key];
if (value === '' && type === 'boolean') {
// e.g. <select multiple> compiles to { multiple: '' }
el[key] = true;
return;
}
catch (e) {
if ((process.env.NODE_ENV !== 'production')) {
warn(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
`value ${value} is invalid.`, e);
}
else if (value == null && type === 'string') {
// e.g. <div :id="null">
el[key] = '';
el.removeAttribute(key);
return;
}
else if (type === 'number') {
// e.g. <img :width="null">
el[key] = 0;
el.removeAttribute(key);
return;
}
}
// some properties perform value validation and throw
try {
el[key] = value;
}
catch (e) {
if ((process.env.NODE_ENV !== 'production')) {
warn(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
`value ${value} is invalid.`, e);
}
}
}
@@ -277,7 +286,7 @@ function parseName(name) {
options[m[0].toLowerCase()] = true;
}
}
return [name.slice(2).toLowerCase(), options];
return [hyphenate(name.slice(2)), options];
}
function createInvoker(initialValue, instance) {
const invoker = (e) => {
@@ -369,15 +378,19 @@ function shouldSetAsProp(el, key, value, isSVG) {
if (key === 'spellcheck' || key === 'draggable') {
return false;
}
// #1787 form as an attribute must be a string, while it accepts an Element as
// a prop
if (key === 'form' && typeof value === 'string') {
// #1787, #2840 form property on form elements is readonly and must be set as
// attribute.
if (key === 'form') {
return false;
}
// #1526 <input list> must be set as attribute
if (key === 'list' && el.tagName === 'INPUT') {
return false;
}
// #2766 <textarea type> must be set as attribute
if (key === 'type' && el.tagName === 'TEXTAREA') {
return false;
}
// native onclick with string value, must be set as attribute
if (nativeOnRE.test(key) && isString(value)) {
return false;
@@ -408,7 +421,11 @@ function useCssModule(name = '$style') {
}
}
function useCssVars(getter, scoped = false) {
/**
* Runtime helper for SFC's CSS variable injection feature.
* @private
*/
function useCssVars(getter) {
const instance = getCurrentInstance();
/* istanbul ignore next */
if (!instance) {
@@ -416,20 +433,17 @@ function useCssVars(getter, scoped = false) {
warn(`useCssVars is called without current active component instance.`);
return;
}
const prefix = scoped && instance.type.__scopeId
? `${instance.type.__scopeId.replace(/^data-v-/, '')}-`
: ``;
const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy), prefix);
onMounted(() => watchEffect(setVars));
const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy));
onMounted(() => watchEffect(setVars, { flush: 'post' }));
onUpdated(setVars);
}
function setVarsOnVNode(vnode, vars, prefix) {
if ( vnode.shapeFlag & 128 /* SUSPENSE */) {
function setVarsOnVNode(vnode, vars) {
if (vnode.shapeFlag & 128 /* SUSPENSE */) {
const suspense = vnode.suspense;
vnode = suspense.activeBranch;
if (suspense.pendingBranch && !suspense.isHydrating) {
suspense.effects.push(() => {
setVarsOnVNode(suspense.activeBranch, vars, prefix);
setVarsOnVNode(suspense.activeBranch, vars);
});
}
}
@@ -440,11 +454,11 @@ function setVarsOnVNode(vnode, vars, prefix) {
if (vnode.shapeFlag & 1 /* ELEMENT */ && vnode.el) {
const style = vnode.el.style;
for (const key in vars) {
style.setProperty(`--${prefix}${key}`, unref(vars[key]));
style.setProperty(`--${key}`, vars[key]);
}
}
else if (vnode.type === Fragment) {
vnode.children.forEach(c => setVarsOnVNode(c, vars, prefix));
vnode.children.forEach(c => setVarsOnVNode(c, vars));
}
}
@@ -507,12 +521,7 @@ function resolveTransitionProps(rawProps) {
removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
addTransitionClass(el, isAppear ? appearToClass : enterToClass);
if (!(hook && hook.length > 1)) {
if (enterDuration) {
setTimeout(resolve, enterDuration);
}
else {
whenTransitionEnds(el, type, resolve);
}
whenTransitionEnds(el, type, enterDuration, resolve);
}
});
};
@@ -520,30 +529,27 @@ function resolveTransitionProps(rawProps) {
return extend(baseProps, {
onBeforeEnter(el) {
onBeforeEnter && onBeforeEnter(el);
addTransitionClass(el, enterActiveClass);
addTransitionClass(el, enterFromClass);
addTransitionClass(el, enterActiveClass);
},
onBeforeAppear(el) {
onBeforeAppear && onBeforeAppear(el);
addTransitionClass(el, appearActiveClass);
addTransitionClass(el, appearFromClass);
addTransitionClass(el, appearActiveClass);
},
onEnter: makeEnterHook(false),
onAppear: makeEnterHook(true),
onLeave(el, done) {
const resolve = () => finishLeave(el, done);
addTransitionClass(el, leaveActiveClass);
addTransitionClass(el, leaveFromClass);
// force reflow so *-leave-from classes immediately take effect (#2593)
forceReflow();
addTransitionClass(el, leaveActiveClass);
nextFrame(() => {
removeTransitionClass(el, leaveFromClass);
addTransitionClass(el, leaveToClass);
if (!(onLeave && onLeave.length > 1)) {
if (leaveDuration) {
setTimeout(resolve, leaveDuration);
}
else {
whenTransitionEnds(el, type, resolve);
}
whenTransitionEnds(el, type, leaveDuration, resolve);
}
});
onLeave && onLeave(el, resolve);
@@ -610,22 +616,30 @@ function nextFrame(cb) {
requestAnimationFrame(cb);
});
}
function whenTransitionEnds(el, expectedType, cb) {
let endId = 0;
function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
const id = (el._endId = ++endId);
const resolveIfNotStale = () => {
if (id === el._endId) {
resolve();
}
};
if (explicitTimeout) {
return setTimeout(resolveIfNotStale, explicitTimeout);
}
const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
if (!type) {
return cb();
return resolve();
}
const endEvent = type + 'end';
let ended = 0;
const end = () => {
el.removeEventListener(endEvent, onEnd);
cb();
resolveIfNotStale();
};
const onEnd = (e) => {
if (e.target === el) {
if (++ended >= propCount) {
end();
}
if (e.target === el && ++ended >= propCount) {
end();
}
};
setTimeout(() => {
@@ -699,9 +713,9 @@ function getTimeout(delays, durations) {
function toMs(s) {
return Number(s.slice(0, -1).replace(',', '.')) * 1000;
}
function toRaw(observed) {
return ((observed && toRaw(observed["__v_raw" /* RAW */])) || observed);
// synchronously force layout to put elements into a certain state
function forceReflow() {
return document.body.offsetHeight;
}
const positionMap = new WeakMap();
@@ -802,10 +816,6 @@ function applyTranslation(c) {
return c;
}
}
// this is put in a dedicated function to avoid the line from being treeshaken
function forceReflow() {
return document.body.offsetHeight;
}
function hasCSSTransform(el, root, moveClass) {
// Detect whether an element with the move class applied has
// CSS transitions. Since the element may be inside an entering
@@ -905,8 +915,7 @@ const vModelText = {
}
};
const vModelCheckbox = {
created(el, binding, vnode) {
setChecked(el, binding, vnode);
created(el, _, vnode) {
el._assign = getModelAssigner(vnode);
addEventListener(el, 'change', () => {
const modelValue = el._modelValue;
@@ -926,18 +935,22 @@ const vModelCheckbox = {
}
}
else if (isSet(modelValue)) {
const cloned = new Set(modelValue);
if (checked) {
modelValue.add(elementValue);
cloned.add(elementValue);
}
else {
modelValue.delete(elementValue);
cloned.delete(elementValue);
}
assign(cloned);
}
else {
assign(getCheckboxValue(el, checked));
}
});
},
// set initial checked on mount to wait for true-value/false-value
mounted: setChecked,
beforeUpdate(el, binding, vnode) {
el._assign = getModelAssigner(vnode);
setChecked(el, binding, vnode);
@@ -971,12 +984,17 @@ const vModelRadio = {
}
};
const vModelSelect = {
created(el, { modifiers: { number } }, vnode) {
created(el, { value, modifiers: { number } }, vnode) {
const isSetModel = isSet(value);
addEventListener(el, 'change', () => {
const selectedVal = Array.prototype.filter
.call(el.options, (o) => o.selected)
.map((o) => number ? toNumber(getValue(o)) : getValue(o));
el._assign(el.multiple ? selectedVal : selectedVal[0]);
el._assign(el.multiple
? isSetModel
? new Set(selectedVal)
: selectedVal
: selectedVal[0]);
});
el._assign = getModelAssigner(vnode);
},
@@ -1141,9 +1159,7 @@ const vShow = {
}
},
updated(el, { value, oldValue }, { transition }) {
if (!value === !oldValue)
return;
if (transition) {
if (transition && value !== oldValue) {
if (value) {
transition.beforeEnter(el);
setDisplay(el, true);
@@ -1206,8 +1222,10 @@ const createApp = ((...args) => {
// clear content before mounting
container.innerHTML = '';
const proxy = mount(container);
container.removeAttribute('v-cloak');
container.setAttribute('data-v-app', '');
if (container instanceof Element) {
container.removeAttribute('v-cloak');
container.setAttribute('data-v-app', '');
}
return proxy;
};
return app;
@@ -1238,10 +1256,15 @@ function normalizeContainer(container) {
if (isString(container)) {
const res = document.querySelector(container);
if ((process.env.NODE_ENV !== 'production') && !res) {
warn(`Failed to mount app: mount target selector returned null.`);
warn(`Failed to mount app: mount target selector "${container}" returned null.`);
}
return res;
}
if ((process.env.NODE_ENV !== 'production') &&
container instanceof window.ShadowRoot &&
container.mode === 'closed') {
warn(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
}
return container;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,33 +1,32 @@
{
"_args": [
[
"@vue/runtime-dom@3.0.2",
"@vue/runtime-dom@3.0.6",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "@vue/runtime-dom@3.0.2",
"_id": "@vue/runtime-dom@3.0.2",
"_from": "@vue/runtime-dom@3.0.6",
"_id": "@vue/runtime-dom@3.0.6",
"_inBundle": false,
"_integrity": "sha1-nRZtAyJVWAJdPYD1A5tkbgBRtxw=",
"_integrity": "sha1-59bGGRPYcfHwIKmoG1WMj8vrqMY=",
"_location": "/@vue/runtime-dom",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@vue/runtime-dom@3.0.2",
"raw": "@vue/runtime-dom@3.0.6",
"name": "@vue/runtime-dom",
"escapedName": "@vue%2fruntime-dom",
"scope": "@vue",
"rawSpec": "3.0.2",
"rawSpec": "3.0.6",
"saveSpec": null,
"fetchSpec": "3.0.2"
"fetchSpec": "3.0.6"
},
"_requiredBy": [
"/vue"
],
"_resolved": "http://192.168.250.101:4873/@vue%2fruntime-dom/-/runtime-dom-3.0.2.tgz",
"_spec": "3.0.2",
"_resolved": "http://192.168.250.101:4873/@vue%2fruntime-dom/-/runtime-dom-3.0.6.tgz",
"_spec": "3.0.6",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Evan You"
@@ -45,8 +44,8 @@
]
},
"dependencies": {
"@vue/runtime-core": "3.0.2",
"@vue/shared": "3.0.2",
"@vue/runtime-core": "3.0.6",
"@vue/shared": "3.0.6",
"csstype": "^2.6.8"
},
"description": "@vue/runtime-dom",
@@ -70,5 +69,5 @@
"sideEffects": false,
"types": "dist/runtime-dom.d.ts",
"unpkg": "dist/runtime-dom.global.js",
"version": "3.0.2"
"version": "3.0.6"
}

View File

@@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2018-present, Yuxi (Evan) You
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -1,16 +0,0 @@
# @vue/server-renderer
``` js
const { createSSRApp } = require('vue')
const { renderToString } = require('@vue/server-renderer')
const app = createSSRApp({
data: () => ({ msg: 'hello' }),
template: `<div>{{ msg }}</div>`
})
;(async () => {
const html = await renderToString(app)
console.log(html)
})()
```

View File

@@ -1,835 +0,0 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var shared = require('@vue/shared');
var compilerSsr = require('@vue/compiler-ssr');
var stream = require('stream');
// leading comma for empty string ""
const shouldIgnoreProp = shared.makeMap(`,key,ref,innerHTML,textContent`);
function ssrRenderAttrs(props, tag) {
let ret = '';
for (const key in props) {
if (shouldIgnoreProp(key) ||
shared.isOn(key) ||
(tag === 'textarea' && key === 'value')) {
continue;
}
const value = props[key];
if (key === 'class') {
ret += ` class="${ssrRenderClass(value)}"`;
}
else if (key === 'style') {
ret += ` style="${ssrRenderStyle(value)}"`;
}
else {
ret += ssrRenderDynamicAttr(key, value, tag);
}
}
return ret;
}
// render an attr with dynamic (unknown) key.
function ssrRenderDynamicAttr(key, value, tag) {
if (!isRenderableValue(value)) {
return ``;
}
const attrKey = tag && tag.indexOf('-') > 0
? key // preserve raw name on custom elements
: shared.propsToAttrMap[key] || key.toLowerCase();
if (shared.isBooleanAttr(attrKey)) {
return value === false ? `` : ` ${attrKey}`;
}
else if (shared.isSSRSafeAttrName(attrKey)) {
return value === '' ? ` ${attrKey}` : ` ${attrKey}="${shared.escapeHtml(value)}"`;
}
else {
console.warn(`[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`);
return ``;
}
}
// Render a v-bind attr with static key. The key is pre-processed at compile
// time and we only need to check and escape value.
function ssrRenderAttr(key, value) {
if (!isRenderableValue(value)) {
return ``;
}
return ` ${key}="${shared.escapeHtml(value)}"`;
}
function isRenderableValue(value) {
if (value == null) {
return false;
}
const type = typeof value;
return type === 'string' || type === 'number' || type === 'boolean';
}
function ssrRenderClass(raw) {
return shared.escapeHtml(shared.normalizeClass(raw));
}
function ssrRenderStyle(raw) {
if (!raw) {
return '';
}
if (shared.isString(raw)) {
return shared.escapeHtml(raw);
}
const styles = shared.normalizeStyle(raw);
return shared.escapeHtml(shared.stringifyStyle(styles));
}
const compileCache = Object.create(null);
function ssrCompile(template, instance) {
const cached = compileCache[template];
if (cached) {
return cached;
}
const { code } = compilerSsr.compile(template, {
isCustomElement: instance.appContext.config.isCustomElement || shared.NO,
isNativeTag: instance.appContext.config.isNativeTag || shared.NO,
onError(err) {
{
const message = `[@vue/server-renderer] Template compilation error: ${err.message}`;
const codeFrame = err.loc &&
shared.generateCodeFrame(template, err.loc.start.offset, err.loc.end.offset);
vue.warn(codeFrame ? `${message}\n${codeFrame}` : message);
}
}
});
return (compileCache[template] = Function('require', code)(require));
}
function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) {
parentPush('<!--teleport start-->');
let teleportContent;
if (disabled) {
contentRenderFn(parentPush);
teleportContent = `<!---->`;
}
else {
const { getBuffer, push } = createBuffer();
contentRenderFn(push);
push(`<!---->`); // teleport end anchor
teleportContent = getBuffer();
}
const context = parentComponent.appContext.provides[vue.ssrContextKey];
const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {});
if (teleportBuffers[target]) {
teleportBuffers[target].push(teleportContent);
}
else {
teleportBuffers[target] = [teleportContent];
}
parentPush('<!--teleport end-->');
}
const { createComponentInstance, setCurrentRenderingInstance, setupComponent, renderComponentRoot, normalizeVNode } = vue.ssrUtils;
// Each component has a buffer array.
// A buffer array can contain one of the following:
// - plain string
// - A resolved buffer (recursive arrays of strings that can be unrolled
// synchronously)
// - An async buffer (a Promise that resolves to a resolved buffer)
function createBuffer() {
let appendable = false;
const buffer = [];
return {
getBuffer() {
// Return static buffer and await on items during unroll stage
return buffer;
},
push(item) {
const isStringItem = shared.isString(item);
if (appendable && isStringItem) {
buffer[buffer.length - 1] += item;
}
else {
buffer.push(item);
}
appendable = isStringItem;
if (shared.isPromise(item) || (shared.isArray(item) && item.hasAsync)) {
// promise, or child buffer with async, mark as async.
// this allows skipping unnecessary await ticks during unroll stage
buffer.hasAsync = true;
}
}
};
}
function renderComponentVNode(vnode, parentComponent = null) {
const instance = createComponentInstance(vnode, parentComponent, null);
const res = setupComponent(instance, true /* isSSR */);
const hasAsyncSetup = shared.isPromise(res);
const prefetch = vnode.type.serverPrefetch;
if (hasAsyncSetup || prefetch) {
let p = hasAsyncSetup
? res.catch(err => {
vue.warn(`[@vue/server-renderer]: Uncaught error in async setup:\n`, err);
})
: Promise.resolve();
if (prefetch) {
p = p.then(() => prefetch.call(instance.proxy)).catch(err => {
vue.warn(`[@vue/server-renderer]: Uncaught error in serverPrefetch:\n`, err);
});
}
return p.then(() => renderComponentSubTree(instance));
}
else {
return renderComponentSubTree(instance);
}
}
function renderComponentSubTree(instance) {
const comp = instance.type;
const { getBuffer, push } = createBuffer();
if (shared.isFunction(comp)) {
renderVNode(push, (instance.subTree = renderComponentRoot(instance)), instance);
}
else {
if (!instance.render && !comp.ssrRender && shared.isString(comp.template)) {
comp.ssrRender = ssrCompile(comp.template, instance);
}
if (comp.ssrRender) {
// optimized
// resolve fallthrough attrs
let attrs = instance.type.inheritAttrs !== false ? instance.attrs : undefined;
// inherited scopeId
const scopeId = instance.vnode.scopeId;
const treeOwnerId = instance.parent && instance.parent.type.__scopeId;
const slotScopeId = treeOwnerId && treeOwnerId !== scopeId ? treeOwnerId + '-s' : null;
if (scopeId || slotScopeId) {
attrs = { ...attrs };
if (scopeId)
attrs[scopeId] = '';
if (slotScopeId)
attrs[slotScopeId] = '';
}
// set current rendering instance for asset resolution
setCurrentRenderingInstance(instance);
comp.ssrRender(instance.proxy, push, instance, attrs,
// compiler-optimized bindings
instance.props, instance.setupState, instance.data, instance.ctx);
setCurrentRenderingInstance(null);
}
else if (instance.render) {
renderVNode(push, (instance.subTree = renderComponentRoot(instance)), instance);
}
else {
vue.warn(`Component ${comp.name ? `${comp.name} ` : ``} is missing template or render function.`);
push(`<!---->`);
}
}
return getBuffer();
}
function renderVNode(push, vnode, parentComponent) {
const { type, shapeFlag, children } = vnode;
switch (type) {
case vue.Text:
push(shared.escapeHtml(children));
break;
case vue.Comment:
push(children ? `<!--${shared.escapeHtmlComment(children)}-->` : `<!---->`);
break;
case vue.Static:
push(children);
break;
case vue.Fragment:
push(`<!--[-->`); // open
renderVNodeChildren(push, children, parentComponent);
push(`<!--]-->`); // close
break;
default:
if (shapeFlag & 1 /* ELEMENT */) {
renderElementVNode(push, vnode, parentComponent);
}
else if (shapeFlag & 6 /* COMPONENT */) {
push(renderComponentVNode(vnode, parentComponent));
}
else if (shapeFlag & 64 /* TELEPORT */) {
renderTeleportVNode(push, vnode, parentComponent);
}
else if (shapeFlag & 128 /* SUSPENSE */) {
renderVNode(push, vnode.ssContent, parentComponent);
}
else {
vue.warn('[@vue/server-renderer] Invalid VNode type:', type, `(${typeof type})`);
}
}
}
function renderVNodeChildren(push, children, parentComponent) {
for (let i = 0; i < children.length; i++) {
renderVNode(push, normalizeVNode(children[i]), parentComponent);
}
}
function renderElementVNode(push, vnode, parentComponent) {
const tag = vnode.type;
let { props, children, shapeFlag, scopeId, dirs } = vnode;
let openTag = `<${tag}`;
if (dirs) {
props = applySSRDirectives(vnode, props, dirs);
}
if (props) {
openTag += ssrRenderAttrs(props, tag);
}
openTag += resolveScopeId(scopeId, vnode, parentComponent);
push(openTag + `>`);
if (!shared.isVoidTag(tag)) {
let hasChildrenOverride = false;
if (props) {
if (props.innerHTML) {
hasChildrenOverride = true;
push(props.innerHTML);
}
else if (props.textContent) {
hasChildrenOverride = true;
push(shared.escapeHtml(props.textContent));
}
else if (tag === 'textarea' && props.value) {
hasChildrenOverride = true;
push(shared.escapeHtml(props.value));
}
}
if (!hasChildrenOverride) {
if (shapeFlag & 8 /* TEXT_CHILDREN */) {
push(shared.escapeHtml(children));
}
else if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
renderVNodeChildren(push, children, parentComponent);
}
}
push(`</${tag}>`);
}
}
function resolveScopeId(scopeId, vnode, parentComponent) {
let res = ``;
if (scopeId) {
res = ` ${scopeId}`;
}
if (parentComponent) {
const treeOwnerId = parentComponent.type.__scopeId;
// vnode's own scopeId and the current rendering component's scopeId is
// different - this is a slot content node.
if (treeOwnerId && treeOwnerId !== scopeId) {
res += ` ${treeOwnerId}-s`;
}
if (vnode === parentComponent.subTree) {
res += resolveScopeId(parentComponent.vnode.scopeId, parentComponent.vnode, parentComponent.parent);
}
}
return res;
}
function applySSRDirectives(vnode, rawProps, dirs) {
const toMerge = [];
for (let i = 0; i < dirs.length; i++) {
const binding = dirs[i];
const { dir: { getSSRProps } } = binding;
if (getSSRProps) {
const props = getSSRProps(binding, vnode);
if (props)
toMerge.push(props);
}
}
return vue.mergeProps(rawProps || {}, ...toMerge);
}
function renderTeleportVNode(push, vnode, parentComponent) {
const target = vnode.props && vnode.props.to;
const disabled = vnode.props && vnode.props.disabled;
if (!target) {
vue.warn(`[@vue/server-renderer] Teleport is missing target prop.`);
return [];
}
if (!shared.isString(target)) {
vue.warn(`[@vue/server-renderer] Teleport target must be a query selector string.`);
return [];
}
ssrRenderTeleport(push, push => {
renderVNodeChildren(push, vnode.children, parentComponent);
}, target, disabled || disabled === '', parentComponent);
}
const { isVNode } = vue.ssrUtils;
async function unrollBuffer(buffer) {
if (buffer.hasAsync) {
let ret = '';
for (let i = 0; i < buffer.length; i++) {
let item = buffer[i];
if (shared.isPromise(item)) {
item = await item;
}
if (shared.isString(item)) {
ret += item;
}
else {
ret += await unrollBuffer(item);
}
}
return ret;
}
else {
// sync buffer can be more efficiently unrolled without unnecessary await
// ticks
return unrollBufferSync(buffer);
}
}
function unrollBufferSync(buffer) {
let ret = '';
for (let i = 0; i < buffer.length; i++) {
let item = buffer[i];
if (shared.isString(item)) {
ret += item;
}
else {
// since this is a sync buffer, child buffers are never promises
ret += unrollBufferSync(item);
}
}
return ret;
}
async function renderToString(input, context = {}) {
if (isVNode(input)) {
// raw vnode, wrap with app (for context)
return renderToString(vue.createApp({ render: () => input }), context);
}
// rendering an app
const vnode = vue.createVNode(input._component, input._props);
vnode.appContext = input._context;
// provide the ssr context to the tree
input.provide(vue.ssrContextKey, context);
const buffer = await renderComponentVNode(vnode);
await resolveTeleports(context);
return unrollBuffer(buffer);
}
async function resolveTeleports(context) {
if (context.__teleportBuffers) {
context.teleports = context.teleports || {};
for (const key in context.__teleportBuffers) {
// note: it's OK to await sequentially here because the Promises were
// created eagerly in parallel.
context.teleports[key] = await unrollBuffer((await Promise.all(context.__teleportBuffers[key])));
}
}
}
const { isVNode: isVNode$1 } = vue.ssrUtils;
async function unrollBuffer$1(buffer, stream) {
if (buffer.hasAsync) {
for (let i = 0; i < buffer.length; i++) {
let item = buffer[i];
if (shared.isPromise(item)) {
item = await item;
}
if (shared.isString(item)) {
stream.push(item);
}
else {
await unrollBuffer$1(item, stream);
}
}
}
else {
// sync buffer can be more efficiently unrolled without unnecessary await
// ticks
unrollBufferSync$1(buffer, stream);
}
}
function unrollBufferSync$1(buffer, stream) {
for (let i = 0; i < buffer.length; i++) {
let item = buffer[i];
if (shared.isString(item)) {
stream.push(item);
}
else {
// since this is a sync buffer, child buffers are never promises
unrollBufferSync$1(item, stream);
}
}
}
function renderToStream(input, context = {}) {
if (isVNode$1(input)) {
// raw vnode, wrap with app (for context)
return renderToStream(vue.createApp({ render: () => input }), context);
}
// rendering an app
const vnode = vue.createVNode(input._component, input._props);
vnode.appContext = input._context;
// provide the ssr context to the tree
input.provide(vue.ssrContextKey, context);
const stream$1 = new stream.Readable();
Promise.resolve(renderComponentVNode(vnode))
.then(buffer => unrollBuffer$1(buffer, stream$1))
.then(() => {
stream$1.push(null);
})
.catch(error => {
stream$1.destroy(error);
});
return stream$1;
}
function ssrRenderComponent(comp, props = null, children = null, parentComponent = null) {
return renderComponentVNode(vue.createVNode(comp, props, children), parentComponent);
}
function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent) {
// template-compiled slots are always rendered as fragments
push(`<!--[-->`);
const slotFn = slots[slotName];
if (slotFn) {
const scopeId = parentComponent && parentComponent.type.__scopeId;
const ret = slotFn(slotProps, push, parentComponent, scopeId ? ` ${scopeId}-s` : ``);
if (Array.isArray(ret)) {
// normal slot
renderVNodeChildren(push, ret, parentComponent);
}
}
else if (fallbackRenderFn) {
fallbackRenderFn();
}
push(`<!--]-->`);
}
function ssrInterpolate(value) {
return shared.escapeHtml(shared.toDisplayString(value));
}
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) {
if (shared.isArray(source) || shared.isString(source)) {
for (let i = 0, l = source.length; i < l; i++) {
renderItem(source[i], i);
}
}
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++) {
renderItem(i + 1, i);
}
}
else if (shared.isObject(source)) {
if (source[Symbol.iterator]) {
const arr = Array.from(source);
for (let i = 0, l = arr.length; i < l; i++) {
renderItem(arr[i], i);
}
}
else {
const keys = Object.keys(source);
for (let i = 0, l = keys.length; i < l; i++) {
const key = keys[i];
renderItem(source[key], key, i);
}
}
}
}
async function ssrRenderSuspense(push, { default: renderContent }) {
if (renderContent) {
renderContent();
}
else {
push(`<!---->`);
}
}
function ssrResolveCssVars(source, scopeId) {
const style = {};
const prefix = scopeId ? `${scopeId.replace(/^data-v-/, '')}-` : ``;
for (const key in source) {
style[`--${prefix}${key}`] = source[key];
}
return { style };
}
const ssrLooseEqual = shared.looseEqual;
function ssrLooseContain(arr, value) {
return shared.looseIndexOf(arr, value) > -1;
}
// for <input :type="type" v-model="model" value="value">
function ssrRenderDynamicModel(type, model, value) {
switch (type) {
case 'radio':
return shared.looseEqual(model, value) ? ' checked' : '';
case 'checkbox':
return (Array.isArray(model)
? ssrLooseContain(model, value)
: model)
? ' checked'
: '';
default:
// text types
return ssrRenderAttr('value', model);
}
}
// for <input v-bind="obj" v-model="model">
function ssrGetDynamicModelProps(existingProps = {}, model) {
const { type, value } = existingProps;
switch (type) {
case 'radio':
return shared.looseEqual(model, value) ? { checked: true } : null;
case 'checkbox':
return (Array.isArray(model)
? ssrLooseContain(model, value)
: model)
? { checked: true }
: null;
default:
// text types
return { value: model };
}
}
exports.renderToStream = renderToStream;
exports.renderToString = renderToString;
exports.ssrGetDynamicModelProps = ssrGetDynamicModelProps;
exports.ssrInterpolate = ssrInterpolate;
exports.ssrLooseContain = ssrLooseContain;
exports.ssrLooseEqual = ssrLooseEqual;
exports.ssrRenderAttr = ssrRenderAttr;
exports.ssrRenderAttrs = ssrRenderAttrs;
exports.ssrRenderClass = ssrRenderClass;
exports.ssrRenderComponent = ssrRenderComponent;
exports.ssrRenderDynamicAttr = ssrRenderDynamicAttr;
exports.ssrRenderDynamicModel = ssrRenderDynamicModel;
exports.ssrRenderList = ssrRenderList;
exports.ssrRenderSlot = ssrRenderSlot;
exports.ssrRenderStyle = ssrRenderStyle;
exports.ssrRenderSuspense = ssrRenderSuspense;
exports.ssrRenderTeleport = ssrRenderTeleport;
exports.ssrRenderVNode = renderVNode;
exports.ssrResolveCssVars = ssrResolveCssVars;

View File

@@ -1,592 +0,0 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var shared = require('@vue/shared');
var compilerSsr = require('@vue/compiler-ssr');
var stream = require('stream');
// leading comma for empty string ""
const shouldIgnoreProp = shared.makeMap(`,key,ref,innerHTML,textContent`);
function ssrRenderAttrs(props, tag) {
let ret = '';
for (const key in props) {
if (shouldIgnoreProp(key) ||
shared.isOn(key) ||
(tag === 'textarea' && key === 'value')) {
continue;
}
const value = props[key];
if (key === 'class') {
ret += ` class="${ssrRenderClass(value)}"`;
}
else if (key === 'style') {
ret += ` style="${ssrRenderStyle(value)}"`;
}
else {
ret += ssrRenderDynamicAttr(key, value, tag);
}
}
return ret;
}
// render an attr with dynamic (unknown) key.
function ssrRenderDynamicAttr(key, value, tag) {
if (!isRenderableValue(value)) {
return ``;
}
const attrKey = tag && tag.indexOf('-') > 0
? key // preserve raw name on custom elements
: shared.propsToAttrMap[key] || key.toLowerCase();
if (shared.isBooleanAttr(attrKey)) {
return value === false ? `` : ` ${attrKey}`;
}
else if (shared.isSSRSafeAttrName(attrKey)) {
return value === '' ? ` ${attrKey}` : ` ${attrKey}="${shared.escapeHtml(value)}"`;
}
else {
console.warn(`[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`);
return ``;
}
}
// Render a v-bind attr with static key. The key is pre-processed at compile
// time and we only need to check and escape value.
function ssrRenderAttr(key, value) {
if (!isRenderableValue(value)) {
return ``;
}
return ` ${key}="${shared.escapeHtml(value)}"`;
}
function isRenderableValue(value) {
if (value == null) {
return false;
}
const type = typeof value;
return type === 'string' || type === 'number' || type === 'boolean';
}
function ssrRenderClass(raw) {
return shared.escapeHtml(shared.normalizeClass(raw));
}
function ssrRenderStyle(raw) {
if (!raw) {
return '';
}
if (shared.isString(raw)) {
return shared.escapeHtml(raw);
}
const styles = shared.normalizeStyle(raw);
return shared.escapeHtml(shared.stringifyStyle(styles));
}
const compileCache = Object.create(null);
function ssrCompile(template, instance) {
const cached = compileCache[template];
if (cached) {
return cached;
}
const { code } = compilerSsr.compile(template, {
isCustomElement: instance.appContext.config.isCustomElement || shared.NO,
isNativeTag: instance.appContext.config.isNativeTag || shared.NO,
onError(err) {
{
throw err;
}
}
});
return (compileCache[template] = Function('require', code)(require));
}
function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) {
parentPush('<!--teleport start-->');
let teleportContent;
if (disabled) {
contentRenderFn(parentPush);
teleportContent = `<!---->`;
}
else {
const { getBuffer, push } = createBuffer();
contentRenderFn(push);
push(`<!---->`); // teleport end anchor
teleportContent = getBuffer();
}
const context = parentComponent.appContext.provides[vue.ssrContextKey];
const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {});
if (teleportBuffers[target]) {
teleportBuffers[target].push(teleportContent);
}
else {
teleportBuffers[target] = [teleportContent];
}
parentPush('<!--teleport end-->');
}
const { createComponentInstance, setCurrentRenderingInstance, setupComponent, renderComponentRoot, normalizeVNode } = vue.ssrUtils;
// Each component has a buffer array.
// A buffer array can contain one of the following:
// - plain string
// - A resolved buffer (recursive arrays of strings that can be unrolled
// synchronously)
// - An async buffer (a Promise that resolves to a resolved buffer)
function createBuffer() {
let appendable = false;
const buffer = [];
return {
getBuffer() {
// Return static buffer and await on items during unroll stage
return buffer;
},
push(item) {
const isStringItem = shared.isString(item);
if (appendable && isStringItem) {
buffer[buffer.length - 1] += item;
}
else {
buffer.push(item);
}
appendable = isStringItem;
if (shared.isPromise(item) || (shared.isArray(item) && item.hasAsync)) {
// promise, or child buffer with async, mark as async.
// this allows skipping unnecessary await ticks during unroll stage
buffer.hasAsync = true;
}
}
};
}
function renderComponentVNode(vnode, parentComponent = null) {
const instance = createComponentInstance(vnode, parentComponent, null);
const res = setupComponent(instance, true /* isSSR */);
const hasAsyncSetup = shared.isPromise(res);
const prefetch = vnode.type.serverPrefetch;
if (hasAsyncSetup || prefetch) {
let p = hasAsyncSetup
? res.catch(err => {
vue.warn(`[@vue/server-renderer]: Uncaught error in async setup:\n`, err);
})
: Promise.resolve();
if (prefetch) {
p = p.then(() => prefetch.call(instance.proxy)).catch(err => {
vue.warn(`[@vue/server-renderer]: Uncaught error in serverPrefetch:\n`, err);
});
}
return p.then(() => renderComponentSubTree(instance));
}
else {
return renderComponentSubTree(instance);
}
}
function renderComponentSubTree(instance) {
const comp = instance.type;
const { getBuffer, push } = createBuffer();
if (shared.isFunction(comp)) {
renderVNode(push, (instance.subTree = renderComponentRoot(instance)), instance);
}
else {
if (!instance.render && !comp.ssrRender && shared.isString(comp.template)) {
comp.ssrRender = ssrCompile(comp.template, instance);
}
if (comp.ssrRender) {
// optimized
// resolve fallthrough attrs
let attrs = instance.type.inheritAttrs !== false ? instance.attrs : undefined;
// inherited scopeId
const scopeId = instance.vnode.scopeId;
const treeOwnerId = instance.parent && instance.parent.type.__scopeId;
const slotScopeId = treeOwnerId && treeOwnerId !== scopeId ? treeOwnerId + '-s' : null;
if (scopeId || slotScopeId) {
attrs = { ...attrs };
if (scopeId)
attrs[scopeId] = '';
if (slotScopeId)
attrs[slotScopeId] = '';
}
// set current rendering instance for asset resolution
setCurrentRenderingInstance(instance);
comp.ssrRender(instance.proxy, push, instance, attrs,
// compiler-optimized bindings
instance.props, instance.setupState, instance.data, instance.ctx);
setCurrentRenderingInstance(null);
}
else if (instance.render) {
renderVNode(push, (instance.subTree = renderComponentRoot(instance)), instance);
}
else {
vue.warn(`Component ${comp.name ? `${comp.name} ` : ``} is missing template or render function.`);
push(`<!---->`);
}
}
return getBuffer();
}
function renderVNode(push, vnode, parentComponent) {
const { type, shapeFlag, children } = vnode;
switch (type) {
case vue.Text:
push(shared.escapeHtml(children));
break;
case vue.Comment:
push(children ? `<!--${shared.escapeHtmlComment(children)}-->` : `<!---->`);
break;
case vue.Static:
push(children);
break;
case vue.Fragment:
push(`<!--[-->`); // open
renderVNodeChildren(push, children, parentComponent);
push(`<!--]-->`); // close
break;
default:
if (shapeFlag & 1 /* ELEMENT */) {
renderElementVNode(push, vnode, parentComponent);
}
else if (shapeFlag & 6 /* COMPONENT */) {
push(renderComponentVNode(vnode, parentComponent));
}
else if (shapeFlag & 64 /* TELEPORT */) {
renderTeleportVNode(push, vnode, parentComponent);
}
else if (shapeFlag & 128 /* SUSPENSE */) {
renderVNode(push, vnode.ssContent, parentComponent);
}
else {
vue.warn('[@vue/server-renderer] Invalid VNode type:', type, `(${typeof type})`);
}
}
}
function renderVNodeChildren(push, children, parentComponent) {
for (let i = 0; i < children.length; i++) {
renderVNode(push, normalizeVNode(children[i]), parentComponent);
}
}
function renderElementVNode(push, vnode, parentComponent) {
const tag = vnode.type;
let { props, children, shapeFlag, scopeId, dirs } = vnode;
let openTag = `<${tag}`;
if (dirs) {
props = applySSRDirectives(vnode, props, dirs);
}
if (props) {
openTag += ssrRenderAttrs(props, tag);
}
openTag += resolveScopeId(scopeId, vnode, parentComponent);
push(openTag + `>`);
if (!shared.isVoidTag(tag)) {
let hasChildrenOverride = false;
if (props) {
if (props.innerHTML) {
hasChildrenOverride = true;
push(props.innerHTML);
}
else if (props.textContent) {
hasChildrenOverride = true;
push(shared.escapeHtml(props.textContent));
}
else if (tag === 'textarea' && props.value) {
hasChildrenOverride = true;
push(shared.escapeHtml(props.value));
}
}
if (!hasChildrenOverride) {
if (shapeFlag & 8 /* TEXT_CHILDREN */) {
push(shared.escapeHtml(children));
}
else if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
renderVNodeChildren(push, children, parentComponent);
}
}
push(`</${tag}>`);
}
}
function resolveScopeId(scopeId, vnode, parentComponent) {
let res = ``;
if (scopeId) {
res = ` ${scopeId}`;
}
if (parentComponent) {
const treeOwnerId = parentComponent.type.__scopeId;
// vnode's own scopeId and the current rendering component's scopeId is
// different - this is a slot content node.
if (treeOwnerId && treeOwnerId !== scopeId) {
res += ` ${treeOwnerId}-s`;
}
if (vnode === parentComponent.subTree) {
res += resolveScopeId(parentComponent.vnode.scopeId, parentComponent.vnode, parentComponent.parent);
}
}
return res;
}
function applySSRDirectives(vnode, rawProps, dirs) {
const toMerge = [];
for (let i = 0; i < dirs.length; i++) {
const binding = dirs[i];
const { dir: { getSSRProps } } = binding;
if (getSSRProps) {
const props = getSSRProps(binding, vnode);
if (props)
toMerge.push(props);
}
}
return vue.mergeProps(rawProps || {}, ...toMerge);
}
function renderTeleportVNode(push, vnode, parentComponent) {
const target = vnode.props && vnode.props.to;
const disabled = vnode.props && vnode.props.disabled;
if (!target) {
vue.warn(`[@vue/server-renderer] Teleport is missing target prop.`);
return [];
}
if (!shared.isString(target)) {
vue.warn(`[@vue/server-renderer] Teleport target must be a query selector string.`);
return [];
}
ssrRenderTeleport(push, push => {
renderVNodeChildren(push, vnode.children, parentComponent);
}, target, disabled || disabled === '', parentComponent);
}
const { isVNode } = vue.ssrUtils;
async function unrollBuffer(buffer) {
if (buffer.hasAsync) {
let ret = '';
for (let i = 0; i < buffer.length; i++) {
let item = buffer[i];
if (shared.isPromise(item)) {
item = await item;
}
if (shared.isString(item)) {
ret += item;
}
else {
ret += await unrollBuffer(item);
}
}
return ret;
}
else {
// sync buffer can be more efficiently unrolled without unnecessary await
// ticks
return unrollBufferSync(buffer);
}
}
function unrollBufferSync(buffer) {
let ret = '';
for (let i = 0; i < buffer.length; i++) {
let item = buffer[i];
if (shared.isString(item)) {
ret += item;
}
else {
// since this is a sync buffer, child buffers are never promises
ret += unrollBufferSync(item);
}
}
return ret;
}
async function renderToString(input, context = {}) {
if (isVNode(input)) {
// raw vnode, wrap with app (for context)
return renderToString(vue.createApp({ render: () => input }), context);
}
// rendering an app
const vnode = vue.createVNode(input._component, input._props);
vnode.appContext = input._context;
// provide the ssr context to the tree
input.provide(vue.ssrContextKey, context);
const buffer = await renderComponentVNode(vnode);
await resolveTeleports(context);
return unrollBuffer(buffer);
}
async function resolveTeleports(context) {
if (context.__teleportBuffers) {
context.teleports = context.teleports || {};
for (const key in context.__teleportBuffers) {
// note: it's OK to await sequentially here because the Promises were
// created eagerly in parallel.
context.teleports[key] = await unrollBuffer((await Promise.all(context.__teleportBuffers[key])));
}
}
}
const { isVNode: isVNode$1 } = vue.ssrUtils;
async function unrollBuffer$1(buffer, stream) {
if (buffer.hasAsync) {
for (let i = 0; i < buffer.length; i++) {
let item = buffer[i];
if (shared.isPromise(item)) {
item = await item;
}
if (shared.isString(item)) {
stream.push(item);
}
else {
await unrollBuffer$1(item, stream);
}
}
}
else {
// sync buffer can be more efficiently unrolled without unnecessary await
// ticks
unrollBufferSync$1(buffer, stream);
}
}
function unrollBufferSync$1(buffer, stream) {
for (let i = 0; i < buffer.length; i++) {
let item = buffer[i];
if (shared.isString(item)) {
stream.push(item);
}
else {
// since this is a sync buffer, child buffers are never promises
unrollBufferSync$1(item, stream);
}
}
}
function renderToStream(input, context = {}) {
if (isVNode$1(input)) {
// raw vnode, wrap with app (for context)
return renderToStream(vue.createApp({ render: () => input }), context);
}
// rendering an app
const vnode = vue.createVNode(input._component, input._props);
vnode.appContext = input._context;
// provide the ssr context to the tree
input.provide(vue.ssrContextKey, context);
const stream$1 = new stream.Readable();
Promise.resolve(renderComponentVNode(vnode))
.then(buffer => unrollBuffer$1(buffer, stream$1))
.then(() => {
stream$1.push(null);
})
.catch(error => {
stream$1.destroy(error);
});
return stream$1;
}
function ssrRenderComponent(comp, props = null, children = null, parentComponent = null) {
return renderComponentVNode(vue.createVNode(comp, props, children), parentComponent);
}
function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent) {
// template-compiled slots are always rendered as fragments
push(`<!--[-->`);
const slotFn = slots[slotName];
if (slotFn) {
const scopeId = parentComponent && parentComponent.type.__scopeId;
const ret = slotFn(slotProps, push, parentComponent, scopeId ? ` ${scopeId}-s` : ``);
if (Array.isArray(ret)) {
// normal slot
renderVNodeChildren(push, ret, parentComponent);
}
}
else if (fallbackRenderFn) {
fallbackRenderFn();
}
push(`<!--]-->`);
}
function ssrInterpolate(value) {
return shared.escapeHtml(shared.toDisplayString(value));
}
function ssrRenderList(source, renderItem) {
if (shared.isArray(source) || shared.isString(source)) {
for (let i = 0, l = source.length; i < l; i++) {
renderItem(source[i], i);
}
}
else if (typeof source === 'number') {
for (let i = 0; i < source; i++) {
renderItem(i + 1, i);
}
}
else if (shared.isObject(source)) {
if (source[Symbol.iterator]) {
const arr = Array.from(source);
for (let i = 0, l = arr.length; i < l; i++) {
renderItem(arr[i], i);
}
}
else {
const keys = Object.keys(source);
for (let i = 0, l = keys.length; i < l; i++) {
const key = keys[i];
renderItem(source[key], key, i);
}
}
}
}
async function ssrRenderSuspense(push, { default: renderContent }) {
if (renderContent) {
renderContent();
}
else {
push(`<!---->`);
}
}
function ssrResolveCssVars(source, scopeId) {
const style = {};
const prefix = scopeId ? `${scopeId.replace(/^data-v-/, '')}-` : ``;
for (const key in source) {
style[`--${prefix}${key}`] = source[key];
}
return { style };
}
const ssrLooseEqual = shared.looseEqual;
function ssrLooseContain(arr, value) {
return shared.looseIndexOf(arr, value) > -1;
}
// for <input :type="type" v-model="model" value="value">
function ssrRenderDynamicModel(type, model, value) {
switch (type) {
case 'radio':
return shared.looseEqual(model, value) ? ' checked' : '';
case 'checkbox':
return (Array.isArray(model)
? ssrLooseContain(model, value)
: model)
? ' checked'
: '';
default:
// text types
return ssrRenderAttr('value', model);
}
}
// for <input v-bind="obj" v-model="model">
function ssrGetDynamicModelProps(existingProps = {}, model) {
const { type, value } = existingProps;
switch (type) {
case 'radio':
return shared.looseEqual(model, value) ? { checked: true } : null;
case 'checkbox':
return (Array.isArray(model)
? ssrLooseContain(model, value)
: model)
? { checked: true }
: null;
default:
// text types
return { value: model };
}
}
exports.renderToStream = renderToStream;
exports.renderToString = renderToString;
exports.ssrGetDynamicModelProps = ssrGetDynamicModelProps;
exports.ssrInterpolate = ssrInterpolate;
exports.ssrLooseContain = ssrLooseContain;
exports.ssrLooseEqual = ssrLooseEqual;
exports.ssrRenderAttr = ssrRenderAttr;
exports.ssrRenderAttrs = ssrRenderAttrs;
exports.ssrRenderClass = ssrRenderClass;
exports.ssrRenderComponent = ssrRenderComponent;
exports.ssrRenderDynamicAttr = ssrRenderDynamicAttr;
exports.ssrRenderDynamicModel = ssrRenderDynamicModel;
exports.ssrRenderList = ssrRenderList;
exports.ssrRenderSlot = ssrRenderSlot;
exports.ssrRenderStyle = ssrRenderStyle;
exports.ssrRenderSuspense = ssrRenderSuspense;
exports.ssrRenderTeleport = ssrRenderTeleport;
exports.ssrRenderVNode = renderVNode;
exports.ssrResolveCssVars = ssrResolveCssVars;

View File

@@ -1,75 +0,0 @@
/// <reference types="node" />
import { App } from 'vue';
import { Component } from 'vue';
import { ComponentInternalInstance } from 'vue';
import { Readable } from 'stream';
import { Slots } from 'vue';
import { VNode } from 'vue';
declare type Props = Record<string, unknown>;
declare type PushFn = (item: SSRBufferItem) => void;
export declare function renderToStream(input: App | VNode, context?: SSRContext): Readable;
export declare function renderToString(input: App | VNode, context?: SSRContext): Promise<string>;
declare type SSRBuffer = SSRBufferItem[] & {
hasAsync?: boolean;
};
declare type SSRBufferItem = string | SSRBuffer | Promise<SSRBuffer>;
export declare type SSRContext = {
[key: string]: any;
teleports?: Record<string, string>;
__teleportBuffers?: Record<string, SSRBuffer>;
};
export declare function ssrGetDynamicModelProps(existingProps: any, model: unknown): {
checked: boolean;
value?: undefined;
} | {
value: unknown;
checked?: undefined;
} | null;
export declare function ssrInterpolate(value: unknown): string;
export declare function ssrLooseContain(arr: unknown[], value: unknown): boolean;
export declare const ssrLooseEqual: (a: unknown, b: unknown) => boolean;
export declare function ssrRenderAttr(key: string, value: unknown): string;
export declare function ssrRenderAttrs(props: Record<string, unknown>, tag?: string): string;
export declare function ssrRenderClass(raw: unknown): string;
export declare function ssrRenderComponent(comp: Component, props?: Props | null, children?: Slots | SSRSlots | null, parentComponent?: ComponentInternalInstance | null): SSRBuffer | Promise<SSRBuffer>;
export declare function ssrRenderDynamicAttr(key: string, value: unknown, tag?: string): string;
export declare function ssrRenderDynamicModel(type: unknown, model: unknown, value: unknown): string;
export declare function ssrRenderList(source: unknown, renderItem: (value: unknown, key: string | number, index?: number) => void): void;
export declare function ssrRenderSlot(slots: Slots | SSRSlots, slotName: string, slotProps: Props, fallbackRenderFn: (() => void) | null, push: PushFn, parentComponent: ComponentInternalInstance): void;
export declare function ssrRenderStyle(raw: unknown): string;
export declare function ssrRenderSuspense(push: PushFn, { default: renderContent }: Record<string, (() => void) | undefined>): Promise<void>;
export declare function ssrRenderTeleport(parentPush: PushFn, contentRenderFn: (push: PushFn) => void, target: string, disabled: boolean, parentComponent: ComponentInternalInstance): void;
export declare function ssrRenderVNode(push: PushFn, vnode: VNode, parentComponent: ComponentInternalInstance): void;
export declare function ssrResolveCssVars(source: Record<string, string>, scopeId?: string): {
style: Record<string, string>;
};
declare type SSRSlot = (props: Props, push: PushFn, parentComponent: ComponentInternalInstance | null, scopeId: string | null) => void;
declare type SSRSlots = Record<string, SSRSlot>;
export { }

View File

@@ -1,7 +0,0 @@
'use strict'
if (process.env.NODE_ENV === 'production') {
module.exports = require('./dist/server-renderer.cjs.prod.js')
} else {
module.exports = require('./dist/server-renderer.cjs.js')
}

View File

@@ -1,69 +0,0 @@
{
"_args": [
[
"@vue/server-renderer@3.0.2",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "@vue/server-renderer@3.0.2",
"_id": "@vue/server-renderer@3.0.2",
"_inBundle": false,
"_integrity": "sha1-jeRNMW459OIWa1dOelNSSdwLxUY=",
"_location": "/@vue/server-renderer",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@vue/server-renderer@3.0.2",
"name": "@vue/server-renderer",
"escapedName": "@vue%2fserver-renderer",
"scope": "@vue",
"rawSpec": "3.0.2",
"saveSpec": null,
"fetchSpec": "3.0.2"
},
"_requiredBy": [
"/vitepress"
],
"_resolved": "http://192.168.250.101:4873/@vue%2fserver-renderer/-/server-renderer-3.0.2.tgz",
"_spec": "3.0.2",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Evan You"
},
"bugs": {
"url": "https://github.com/vuejs/vue-next/issues"
},
"buildOptions": {
"formats": [
"cjs"
]
},
"dependencies": {
"@vue/compiler-ssr": "3.0.2",
"@vue/shared": "3.0.2"
},
"description": "@vue/server-renderer",
"files": [
"index.js",
"dist"
],
"homepage": "https://github.com/vuejs/vue-next/tree/master/packages/server-renderer#readme",
"keywords": [
"vue"
],
"license": "MIT",
"main": "index.js",
"name": "@vue/server-renderer",
"peerDependencies": {
"vue": "3.0.2"
},
"repository": {
"type": "git",
"url": "git+https://github.com/vuejs/vue-next.git",
"directory": "packages/server-renderer"
},
"types": "dist/server-renderer.d.ts",
"version": "3.0.2"
}

View File

@@ -18,12 +18,9 @@ function makeMap(str, expectsLowerCase) {
return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
}
// Patch flags are optimization hints generated by the compiler.
// when a block with dynamicChildren is encountered during diff, the algorithm
// enters "optimized mode". In this mode, we know that the vdom is produced by
// a render function generated by the compiler, so the algorithm only needs to
// handle updates explicitly marked by these patch flags.
// dev only flag -> name mapping
/**
* dev only flag -> name mapping
*/
const PatchFlagNames = {
[1 /* TEXT */]: `TEXT`,
[2 /* CLASS */]: `CLASS`,
@@ -34,15 +31,25 @@ const PatchFlagNames = {
[64 /* STABLE_FRAGMENT */]: `STABLE_FRAGMENT`,
[128 /* KEYED_FRAGMENT */]: `KEYED_FRAGMENT`,
[256 /* UNKEYED_FRAGMENT */]: `UNKEYED_FRAGMENT`,
[1024 /* DYNAMIC_SLOTS */]: `DYNAMIC_SLOTS`,
[512 /* NEED_PATCH */]: `NEED_PATCH`,
[1024 /* DYNAMIC_SLOTS */]: `DYNAMIC_SLOTS`,
[2048 /* DEV_ROOT_FRAGMENT */]: `DEV_ROOT_FRAGMENT`,
[-1 /* HOISTED */]: `HOISTED`,
[-2 /* BAIL */]: `BAIL`
};
/**
* Dev only
*/
const slotFlagsText = {
[1 /* STABLE */]: 'STABLE',
[2 /* DYNAMIC */]: 'DYNAMIC',
[3 /* FORWARDED */]: 'FORWARDED'
};
const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
'Object,Boolean,String,RegExp,Map,Set,JSON,Intl';
'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
const range = 2;
@@ -204,7 +211,10 @@ function normalizeClass(value) {
}
else if (isArray(value)) {
for (let i = 0; i < value.length; i++) {
res += normalizeClass(value[i]) + ' ';
const normalized = normalizeClass(value[i]);
if (normalized) {
res += normalized + ' ';
}
}
}
else if (isObject(value)) {
@@ -381,9 +391,9 @@ const babelParserDefaultPlugins = [
'optionalChaining',
'nullishCoalescingOperator'
];
const EMPTY_OBJ = Object.freeze({})
const EMPTY_OBJ = Object.freeze({})
;
const EMPTY_ARR = Object.freeze([]) ;
const EMPTY_ARR = Object.freeze([]) ;
const NOOP = () => { };
/**
* Always return false.
@@ -539,6 +549,7 @@ exports.objectToString = objectToString;
exports.parseStringStyle = parseStringStyle;
exports.propsToAttrMap = propsToAttrMap;
exports.remove = remove;
exports.slotFlagsText = slotFlagsText;
exports.stringifyStyle = stringifyStyle;
exports.toDisplayString = toDisplayString;
exports.toHandlerKey = toHandlerKey;

View File

@@ -18,12 +18,9 @@ function makeMap(str, expectsLowerCase) {
return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
}
// Patch flags are optimization hints generated by the compiler.
// when a block with dynamicChildren is encountered during diff, the algorithm
// enters "optimized mode". In this mode, we know that the vdom is produced by
// a render function generated by the compiler, so the algorithm only needs to
// handle updates explicitly marked by these patch flags.
// dev only flag -> name mapping
/**
* dev only flag -> name mapping
*/
const PatchFlagNames = {
[1 /* TEXT */]: `TEXT`,
[2 /* CLASS */]: `CLASS`,
@@ -34,15 +31,25 @@ const PatchFlagNames = {
[64 /* STABLE_FRAGMENT */]: `STABLE_FRAGMENT`,
[128 /* KEYED_FRAGMENT */]: `KEYED_FRAGMENT`,
[256 /* UNKEYED_FRAGMENT */]: `UNKEYED_FRAGMENT`,
[1024 /* DYNAMIC_SLOTS */]: `DYNAMIC_SLOTS`,
[512 /* NEED_PATCH */]: `NEED_PATCH`,
[1024 /* DYNAMIC_SLOTS */]: `DYNAMIC_SLOTS`,
[2048 /* DEV_ROOT_FRAGMENT */]: `DEV_ROOT_FRAGMENT`,
[-1 /* HOISTED */]: `HOISTED`,
[-2 /* BAIL */]: `BAIL`
};
/**
* Dev only
*/
const slotFlagsText = {
[1 /* STABLE */]: 'STABLE',
[2 /* DYNAMIC */]: 'DYNAMIC',
[3 /* FORWARDED */]: 'FORWARDED'
};
const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
'Object,Boolean,String,RegExp,Map,Set,JSON,Intl';
'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
const range = 2;
@@ -204,7 +211,10 @@ function normalizeClass(value) {
}
else if (isArray(value)) {
for (let i = 0; i < value.length; i++) {
res += normalizeClass(value[i]) + ' ';
const normalized = normalizeClass(value[i]);
if (normalized) {
res += normalized + ' ';
}
}
}
else if (isObject(value)) {
@@ -381,8 +391,8 @@ const babelParserDefaultPlugins = [
'optionalChaining',
'nullishCoalescingOperator'
];
const EMPTY_OBJ = {};
const EMPTY_ARR = [];
const EMPTY_OBJ = {};
const EMPTY_ARR = [];
const NOOP = () => { };
/**
* Always return false.
@@ -538,6 +548,7 @@ exports.objectToString = objectToString;
exports.parseStringStyle = parseStringStyle;
exports.propsToAttrMap = propsToAttrMap;
exports.remove = remove;
exports.slotFlagsText = slotFlagsText;
exports.stringifyStyle = stringifyStyle;
exports.toDisplayString = toDisplayString;
exports.toHandlerKey = toHandlerKey;

View File

@@ -139,23 +139,118 @@ export declare const objectToString: () => string;
export declare function parseStringStyle(cssText: string): NormalizedStyle;
/**
* dev only flag -> name mapping
*/
export declare const PatchFlagNames: {
[x: number]: string;
};
/**
* Patch flags are optimization hints generated by the compiler.
* when a block with dynamicChildren is encountered during diff, the algorithm
* enters "optimized mode". In this mode, we know that the vdom is produced by
* a render function generated by the compiler, so the algorithm only needs to
* handle updates explicitly marked by these patch flags.
*
* Patch flags can be combined using the | bitwise operator and can be checked
* using the & operator, e.g.
*
* ```js
* const flag = TEXT | CLASS
* if (flag & TEXT) { ... }
* ```
*
* Check the `patchElement` function in '../../runtime-core/src/renderer.ts' to see how the
* flags are handled during diff.
*/
export declare const enum PatchFlags {
/**
* Indicates an element with dynamic textContent (children fast path)
*/
TEXT = 1,
/**
* Indicates an element with dynamic class binding.
*/
CLASS = 2,
/**
* Indicates an element with dynamic style
* The compiler pre-compiles static string styles into static objects
* + detects and hoists inline static objects
* e.g. style="color: red" and :style="{ color: 'red' }" both get hoisted as
* const style = { color: 'red' }
* render() { return e('div', { style }) }
*/
STYLE = 4,
/**
* Indicates an element that has non-class/style dynamic props.
* Can also be on a component that has any dynamic props (includes
* class/style). when this flag is present, the vnode also has a dynamicProps
* array that contains the keys of the props that may change so the runtime
* can diff them faster (without having to worry about removed props)
*/
PROPS = 8,
/**
* Indicates an element with props with dynamic keys. When keys change, a full
* diff is always needed to remove the old key. This flag is mutually
* exclusive with CLASS, STYLE and PROPS.
*/
FULL_PROPS = 16,
/**
* Indicates an element with event listeners (which need to be attached
* during hydration)
*/
HYDRATE_EVENTS = 32,
/**
* Indicates a fragment whose children order doesn't change.
*/
STABLE_FRAGMENT = 64,
/**
* Indicates a fragment with keyed or partially keyed children
*/
KEYED_FRAGMENT = 128,
/**
* Indicates a fragment with unkeyed children.
*/
UNKEYED_FRAGMENT = 256,
/**
* Indicates an element that only needs non-props patching, e.g. ref or
* directives (onVnodeXXX hooks). since every patched vnode checks for refs
* and onVnodeXXX hooks, it simply marks the vnode so that a parent block
* will track it.
*/
NEED_PATCH = 512,
/**
* Indicates a component with dynamic slots (e.g. slot that references a v-for
* iterated value, or dynamic slot names).
* Components with this flag are always force updated.
*/
DYNAMIC_SLOTS = 1024,
/**
* Indicates a fragment that was created only because the user has placed
* comments at the root level of a template. This is a dev-only flag since
* comments are stripped in production.
*/
DEV_ROOT_FRAGMENT = 2048,
/**
* SPECIAL FLAGS -------------------------------------------------------------
* Special flags are negative integers. They are never matched against using
* bitwise operators (bitwise matching should only happen in branches where
* patchFlag > 0), and are mutually exclusive. When checking for a special
* flag, simply check patchFlag === FLAG.
*/
/**
* Indicates a hoisted static vnode. This is a hint for hydration to skip
* the entire sub tree since static content never needs to be updated.
*/
HOISTED = -1,
/**
* A special flag that indicates that the diffing algorithm should bail out
* of optimized mode. For example, on block fragments created by renderSlot()
* when encountering non-compiler generated slots (i.e. manually written
* render functions, which should always be fully diffed)
* OR manually cloneVNodes
*/
BAIL = -2
}
@@ -199,6 +294,15 @@ export declare const enum SlotFlags {
FORWARDED = 3
}
/**
* Dev only
*/
export declare const slotFlagsText: {
1: string;
2: string;
3: string;
};
export declare function stringifyStyle(styles: NormalizedStyle | undefined): string;
/**

View File

@@ -14,12 +14,9 @@ function makeMap(str, expectsLowerCase) {
return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];
}
// Patch flags are optimization hints generated by the compiler.
// when a block with dynamicChildren is encountered during diff, the algorithm
// enters "optimized mode". In this mode, we know that the vdom is produced by
// a render function generated by the compiler, so the algorithm only needs to
// handle updates explicitly marked by these patch flags.
// dev only flag -> name mapping
/**
* dev only flag -> name mapping
*/
const PatchFlagNames = {
[1 /* TEXT */]: `TEXT`,
[2 /* CLASS */]: `CLASS`,
@@ -30,15 +27,25 @@ const PatchFlagNames = {
[64 /* STABLE_FRAGMENT */]: `STABLE_FRAGMENT`,
[128 /* KEYED_FRAGMENT */]: `KEYED_FRAGMENT`,
[256 /* UNKEYED_FRAGMENT */]: `UNKEYED_FRAGMENT`,
[1024 /* DYNAMIC_SLOTS */]: `DYNAMIC_SLOTS`,
[512 /* NEED_PATCH */]: `NEED_PATCH`,
[1024 /* DYNAMIC_SLOTS */]: `DYNAMIC_SLOTS`,
[2048 /* DEV_ROOT_FRAGMENT */]: `DEV_ROOT_FRAGMENT`,
[-1 /* HOISTED */]: `HOISTED`,
[-2 /* BAIL */]: `BAIL`
};
/**
* Dev only
*/
const slotFlagsText = {
[1 /* STABLE */]: 'STABLE',
[2 /* DYNAMIC */]: 'DYNAMIC',
[3 /* FORWARDED */]: 'FORWARDED'
};
const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +
'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +
'Object,Boolean,String,RegExp,Map,Set,JSON,Intl';
'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
const range = 2;
@@ -200,7 +207,10 @@ function normalizeClass(value) {
}
else if (isArray(value)) {
for (let i = 0; i < value.length; i++) {
res += normalizeClass(value[i]) + ' ';
const normalized = normalizeClass(value[i]);
if (normalized) {
res += normalized + ' ';
}
}
}
else if (isObject(value)) {
@@ -486,4 +496,4 @@ const getGlobalThis = () => {
: {}));
};
export { EMPTY_ARR, EMPTY_OBJ, NO, NOOP, PatchFlagNames, babelParserDefaultPlugins, camelize, capitalize, def, escapeHtml, escapeHtmlComment, extend, generateCodeFrame, getGlobalThis, hasChanged, hasOwn, hyphenate, invokeArrayFns, isArray, isBooleanAttr, isDate, isFunction, isGloballyWhitelisted, isHTMLTag, isIntegerKey, isKnownAttr, isMap, isModelListener, isNoUnitNumericStyleProp, isObject, isOn, isPlainObject, isPromise, isReservedProp, isSSRSafeAttrName, isSVGTag, isSet, isSpecialBooleanAttr, isString, isSymbol, isVoidTag, looseEqual, looseIndexOf, makeMap, normalizeClass, normalizeStyle, objectToString, parseStringStyle, propsToAttrMap, remove, stringifyStyle, toDisplayString, toHandlerKey, toNumber, toRawType, toTypeString };
export { EMPTY_ARR, EMPTY_OBJ, NO, NOOP, PatchFlagNames, babelParserDefaultPlugins, camelize, capitalize, def, escapeHtml, escapeHtmlComment, extend, generateCodeFrame, getGlobalThis, hasChanged, hasOwn, hyphenate, invokeArrayFns, isArray, isBooleanAttr, isDate, isFunction, isGloballyWhitelisted, isHTMLTag, isIntegerKey, isKnownAttr, isMap, isModelListener, isNoUnitNumericStyleProp, isObject, isOn, isPlainObject, isPromise, isReservedProp, isSSRSafeAttrName, isSVGTag, isSet, isSpecialBooleanAttr, isString, isSymbol, isVoidTag, looseEqual, looseIndexOf, makeMap, normalizeClass, normalizeStyle, objectToString, parseStringStyle, propsToAttrMap, remove, slotFlagsText, stringifyStyle, toDisplayString, toHandlerKey, toNumber, toRawType, toTypeString };

View File

@@ -1,27 +1,26 @@
{
"_args": [
[
"@vue/shared@3.0.2",
"@vue/shared@3.0.6",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "@vue/shared@3.0.2",
"_id": "@vue/shared@3.0.2",
"_from": "@vue/shared@3.0.6",
"_id": "@vue/shared@3.0.6",
"_inBundle": false,
"_integrity": "sha1-QZvYWi69vU9Clj6YxaGxA0Uhdtk=",
"_integrity": "sha1-1lV2Qw/ErTg9x8gpEYeY5RaReNQ=",
"_location": "/@vue/shared",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@vue/shared@3.0.2",
"raw": "@vue/shared@3.0.6",
"name": "@vue/shared",
"escapedName": "@vue%2fshared",
"scope": "@vue",
"rawSpec": "3.0.2",
"rawSpec": "3.0.6",
"saveSpec": null,
"fetchSpec": "3.0.2"
"fetchSpec": "3.0.6"
},
"_requiredBy": [
"/@vue/compiler-core",
@@ -31,11 +30,10 @@
"/@vue/reactivity",
"/@vue/runtime-core",
"/@vue/runtime-dom",
"/@vue/server-renderer",
"/vue"
],
"_resolved": "http://192.168.250.101:4873/@vue%2fshared/-/shared-3.0.2.tgz",
"_spec": "3.0.2",
"_resolved": "http://192.168.250.101:4873/@vue%2fshared/-/shared-3.0.6.tgz",
"_spec": "3.0.6",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Evan You"
@@ -68,5 +66,5 @@
"directory": "packages/shared"
},
"types": "dist/shared.d.ts",
"version": "3.0.2"
"version": "3.0.6"
}