1 line
14 KiB
Plaintext
1 line
14 KiB
Plaintext
{"version":3,"file":"vue-property-decorator.min.js","sources":["../src/vue-property-decorator.js"],"sourcesContent":["/* eslint-disable */\n/*eslint no-unused-vars: \"off\" */\n/** vue-property-decorator verson 9.0.0 MIT LICENSE copyright 2020 kaorun343 */\n/// <reference types='reflect-metadata'/>\n'use strict';\nimport Vue from './vue';\nimport {Component, createDecorator, mixins } from './vue-class-component';\nexport { Component, Vue, mixins as Mixins };\n/** Used for keying reactive provide/inject properties */\nvar reactiveInjectKey = '__reactiveInject__';\n/**\n * decorator of an inject\n * @param from key\n * @return PropertyDecorator\n */\nexport function Inject(options) {\n return createDecorator(function (componentOptions, key) {\n if (typeof componentOptions.inject === 'undefined') {\n componentOptions.inject = {};\n }\n if (!Array.isArray(componentOptions.inject)) {\n componentOptions.inject[key] = options || key;\n }\n });\n}\n/**\n * decorator of a reactive inject\n * @param from key\n * @return PropertyDecorator\n */\nexport function InjectReactive(options) {\n return createDecorator(function (componentOptions, key) {\n if (typeof componentOptions.inject === 'undefined') {\n componentOptions.inject = {};\n }\n if (!Array.isArray(componentOptions.inject)) {\n var fromKey_1 = !!options ? options.from || options : key;\n var defaultVal_1 = (!!options && options.default) || undefined;\n if (!componentOptions.computed)\n componentOptions.computed = {};\n componentOptions.computed[key] = function () {\n var obj = this[reactiveInjectKey];\n return obj ? obj[fromKey_1] : defaultVal_1;\n };\n componentOptions.inject[reactiveInjectKey] = reactiveInjectKey;\n }\n });\n}\nfunction produceProvide(original) {\n var provide = function () {\n var _this = this;\n var rv = typeof original === 'function' ? original.call(this) : original;\n rv = Object.create(rv || null);\n // set reactive services (propagates previous services if necessary)\n rv[reactiveInjectKey] = this[reactiveInjectKey] || {};\n for (var i in provide.managed) {\n rv[provide.managed[i]] = this[i];\n }\n var _loop_1 = function (i) {\n rv[provide.managedReactive[i]] = this_1[i]; // Duplicates the behavior of `@Provide`\n Object.defineProperty(rv[reactiveInjectKey], provide.managedReactive[i], {\n enumerable: true,\n get: function () { return _this[i]; },\n });\n };\n var this_1 = this;\n for (var i in provide.managedReactive) {\n _loop_1(i);\n }\n return rv;\n };\n provide.managed = {};\n provide.managedReactive = {};\n return provide;\n}\nfunction needToProduceProvide(original) {\n return (typeof original !== 'function' ||\n (!original.managed && !original.managedReactive));\n}\n/**\n * decorator of a provide\n * @param key key\n * @return PropertyDecorator | void\n */\nexport function Provide(key) {\n return createDecorator(function (componentOptions, k) {\n var provide = componentOptions.provide;\n if (needToProduceProvide(provide)) {\n provide = componentOptions.provide = produceProvide(provide);\n }\n provide.managed[k] = key || k;\n });\n}\n/**\n * decorator of a reactive provide\n * @param key key\n * @return PropertyDecorator | void\n */\nexport function ProvideReactive(key) {\n return createDecorator(function (componentOptions, k) {\n var provide = componentOptions.provide;\n // inject parent reactive services (if any)\n if (!Array.isArray(componentOptions.inject)) {\n componentOptions.inject = componentOptions.inject || {};\n componentOptions.inject[reactiveInjectKey] = {\n from: reactiveInjectKey,\n default: {},\n };\n }\n if (needToProduceProvide(provide)) {\n provide = componentOptions.provide = produceProvide(provide);\n }\n provide.managedReactive[k] = key || k;\n });\n}\n/** @see {@link https://github.com/vuejs/vue-class-component/blob/master/src/reflect.ts} */\nvar reflectMetadataIsSupported = typeof Reflect !== 'undefined' && typeof Reflect.getMetadata !== 'undefined';\nfunction applyMetadata(options, target, key) {\n if (reflectMetadataIsSupported) {\n if (!Array.isArray(options) &&\n typeof options !== 'function' &&\n typeof options.type === 'undefined') {\n var type = Reflect.getMetadata('design:type', target, key);\n if (type !== Object) {\n options.type = type;\n }\n }\n }\n}\n/**\n * decorator of model\n * @param event event name\n * @param options options\n * @return PropertyDecorator\n */\nexport function Model(event, options) {\n if (options === void 0) { options = {}; }\n return function (target, key) {\n applyMetadata(options, target, key);\n createDecorator(function (componentOptions, k) {\n ;\n (componentOptions.props || (componentOptions.props = {}))[k] = options;\n componentOptions.model = { prop: k, event: event || k };\n })(target, key);\n };\n}\n/**\n * decorator of a prop\n * @param options the options for the prop\n * @return PropertyDecorator | void\n */\nexport function Prop(options) {\n if (options === void 0) { options = {}; }\n return function (target, key) {\n applyMetadata(options, target, key);\n createDecorator(function (componentOptions, k) {\n ;\n (componentOptions.props || (componentOptions.props = {}))[k] = options;\n })(target, key);\n };\n}\n/**\n * decorator of a synced prop\n * @param propName the name to interface with from outside, must be different from decorated property\n * @param options the options for the synced prop\n * @return PropertyDecorator | void\n */\nexport function PropSync(propName, options) {\n if (options === void 0) { options = {}; }\n // @ts-ignore\n return function (target, key) {\n applyMetadata(options, target, key);\n createDecorator(function (componentOptions, k) {\n ;\n (componentOptions.props || (componentOptions.props = {}))[propName] = options;\n (componentOptions.computed || (componentOptions.computed = {}))[k] = {\n get: function () {\n return this[propName];\n },\n set: function (value) {\n // @ts-ignore\n this.$emit(\"update:\" + propName, value);\n },\n };\n })(target, key);\n };\n}\n/**\n * decorator of a watch function\n * @param path the path or the expression to observe\n * @param WatchOption\n * @return MethodDecorator\n */\nexport function Watch(path, options) {\n if (options === void 0) { options = {}; }\n var _a = options.deep, deep = _a === void 0 ? false : _a, _b = options.immediate, immediate = _b === void 0 ? false : _b;\n return createDecorator(function (componentOptions, handler) {\n if (typeof componentOptions.watch !== 'object') {\n componentOptions.watch = Object.create(null);\n }\n var watch = componentOptions.watch;\n if (typeof watch[path] === 'object' && !Array.isArray(watch[path])) {\n watch[path] = [watch[path]];\n }\n else if (typeof watch[path] === 'undefined') {\n watch[path] = [];\n }\n watch[path].push({ handler: handler, deep: deep, immediate: immediate });\n });\n}\n// Code copied from Vue/src/shared/util.js\nvar hyphenateRE = /\\B([A-Z])/g;\nvar hyphenate = function (str) { return str.replace(hyphenateRE, '-$1').toLowerCase(); };\n/**\n * decorator of an event-emitter function\n * @param event The name of the event\n * @return MethodDecorator\n */\nexport function Emit(event) {\n return function (_target, propertyKey, descriptor) {\n var key = hyphenate(propertyKey);\n var original = descriptor.value;\n descriptor.value = function emitter() {\n var _this = this;\n var args = [];\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n }\n var emit = function (returnValue) {\n var emitName = event || key;\n if (returnValue === undefined) {\n if (args.length === 0) {\n _this.$emit(emitName);\n }\n else if (args.length === 1) {\n _this.$emit(emitName, args[0]);\n }\n else {\n _this.$emit.apply(_this, [emitName].concat(args));\n }\n }\n else {\n if (args.length === 0) {\n _this.$emit(emitName, returnValue);\n }\n else if (args.length === 1) {\n _this.$emit(emitName, returnValue, args[0]);\n }\n else {\n _this.$emit.apply(_this, [emitName, returnValue].concat(args));\n }\n }\n };\n var returnValue = original.apply(this, args);\n if (isPromise(returnValue)) {\n returnValue.then(emit);\n }\n else {\n emit(returnValue);\n }\n return returnValue;\n };\n };\n}\n/**\n * decorator of a ref prop\n * @param refKey the ref key defined in template\n */\nexport function Ref(refKey) {\n return createDecorator(function (options, key) {\n options.computed = options.computed || {};\n options.computed[key] = {\n cache: false,\n get: function () {\n return this.$refs[refKey || key];\n },\n };\n });\n}\nfunction isPromise(obj) {\n return obj instanceof Promise || (obj && typeof obj.then === 'function');\n}\n"],"names":["event","_target","propertyKey","descriptor","key","hyphenate","original","value","_this","this","args","_i","arguments","length","obj","emit","returnValue","emitName","undefined","$emit","apply","concat","Promise","then","options","componentOptions","inject","Array","isArray","fromKey_1","from","defaultVal_1","default","computed","reactiveInjectKey","target","applyMetadata","k","props","model","prop","propName","get","set","provide","needToProduceProvide","produceProvide","managed","managedReactive","refKey","cache","$refs","path","_a","deep","_b","immediate","handler","_typeof","watch","Object","create","push","rv","call","i","_loop_1","this_1","defineProperty","enumerable","reflectMetadataIsSupported","Reflect","getMetadata","type","hyphenateRE","str","replace","toLowerCase"],"mappings":"6lBA0NqBA,cACV,SAAUC,QAASC,YAAaC,gBAC/BC,IAAMC,UAAUH,aAChBI,SAAWH,WAAWI,MAC1BJ,WAAWI,MAAQ,mBACXC,MAAQC,KACRC,KAAO,GACFC,GAAK,EAAGA,GAAKC,UAAUC,OAAQF,KACpCD,KAAKC,IAAMC,UAAUD,QAqDlB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