vue3-oop-static
Version:
1,096 lines (1,095 loc) • 34.5 kB
JavaScript
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
import { getCurrentInstance, inject, ref, computed, onServerPrefetch, onRenderTriggered, onRenderTracked, onErrorCaptured, onDeactivated, onActivated, onUnmounted, onBeforeUnmount, onUpdated, onBeforeUpdate, onMounted, onBeforeMount, provide, defineComponent } from "vue";
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function _typeof2(obj2) {
return typeof obj2;
};
} else {
_typeof = function _typeof2(obj2) {
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
};
}
return _typeof(obj);
}
function boundMethod(target, key, descriptor) {
var fn = descriptor.value;
if (typeof fn !== "function") {
throw new TypeError("@boundMethod decorator can only be applied to methods not: ".concat(_typeof(fn)));
}
var definingProperty = false;
return {
configurable: true,
get: function get() {
if (definingProperty || this === target.prototype || this.hasOwnProperty(key) || typeof fn !== "function") {
return fn;
}
var boundFn = fn.bind(this);
definingProperty = true;
Object.defineProperty(this, key, {
configurable: true,
get: function get2() {
return boundFn;
},
set: function set(value) {
fn = value;
delete this[key];
}
});
definingProperty = false;
return boundFn;
},
set: function set(value) {
fn = value;
}
};
}
function boundClass(target) {
var keys;
if (typeof Reflect !== "undefined" && typeof Reflect.ownKeys === "function") {
keys = Reflect.ownKeys(target.prototype);
} else {
keys = Object.getOwnPropertyNames(target.prototype);
if (typeof Object.getOwnPropertySymbols === "function") {
keys = keys.concat(Object.getOwnPropertySymbols(target.prototype));
}
}
keys.forEach(function(key) {
if (key === "constructor") {
return;
}
var descriptor = Object.getOwnPropertyDescriptor(target.prototype, key);
if (typeof descriptor.value === "function") {
Object.defineProperty(target.prototype, key, boundMethod(target, key, descriptor));
}
});
return target;
}
function autobind() {
if (arguments.length === 1) {
return boundClass.apply(void 0, arguments);
}
return boundMethod.apply(void 0, arguments);
}
function Autobind() {
return autobind;
}
function useProps() {
const instance = getCurrentInstance();
return instance.props;
}
function useCtx() {
const instance = getCurrentInstance();
return instance.setupContext;
}
function getCurrentApp() {
var _a;
return (_a = getCurrentInstance()) == null ? void 0 : _a.appContext.app;
}
function getProtoMetadata(target, key, returnDesc = false) {
if (!target)
return [];
const proto = Reflect.getPrototypeOf(target);
if (!proto)
return [];
let res = Reflect.getMetadata(key, proto) || [];
if (returnDesc) {
res = res.map((k) => {
if (typeof k === "string") {
return {
key: k,
desc: getDeepOwnDescriptor(proto, k)
};
}
if (typeof k === "object") {
return {
key: k,
desc: getDeepOwnDescriptor(proto, k.key)
};
}
});
}
return res;
}
function getDeepOwnDescriptor(proto, key) {
if (!proto)
return null;
const desc = Reflect.getOwnPropertyDescriptor(proto, key);
if (desc)
return desc;
return getDeepOwnDescriptor(Reflect.getPrototypeOf(proto), key);
}
function getEmitsFromProps(defaultProps) {
const keys = Array.isArray(defaultProps) ? defaultProps : Object.keys(defaultProps);
const emits = [];
for (let key of keys) {
if (!/^on/.test(key))
continue;
key = key.slice(2).replace(/Once$/, "");
emits.push(key[0].toLowerCase() + key.slice(1));
}
return emits;
}
function injectService(service, defaultService) {
return inject(service.ProviderKey, defaultService);
}
const MetadataKey$3 = Symbol("Ref");
function Ref() {
return function(target, key) {
let list = Reflect.getMetadata(MetadataKey$3, target) || [];
list = list.slice();
const hasItem = list.find((k) => k === key);
if (!hasItem)
list.push(key);
Reflect.defineMetadata(MetadataKey$3, list, target);
};
}
function handler$3(targetThis) {
const list = getProtoMetadata(targetThis, MetadataKey$3);
if (!list || !list.length)
return;
for (const item of list) {
const keyVal = ref();
Object.defineProperty(targetThis, item, {
enumerable: true,
configurable: true,
get() {
return keyVal.value;
},
set(v) {
keyVal.value = v;
}
});
}
}
const RefHandler = {
key: "Ref",
handler: handler$3
};
const MetadataKey$2 = Symbol("Computed");
function Computed() {
return function(target, key) {
let list = Reflect.getMetadata(MetadataKey$2, target) || [];
list = list.slice();
const hasItem = list.find((k) => k === key);
if (!hasItem)
list.push(key);
Reflect.defineMetadata(MetadataKey$2, list, target);
};
}
function handler$2(targetThis) {
const list = getProtoMetadata(targetThis, MetadataKey$2, true);
if (!list || !list.length)
return;
for (const item of list) {
const desc = item.desc;
const keyVal = computed({
get: () => {
var _a;
return (_a = desc.get) == null ? void 0 : _a.call(targetThis);
},
set: (v) => {
var _a;
return (_a = desc.set) == null ? void 0 : _a.call(targetThis, v);
}
});
Object.defineProperty(targetThis, item.key, {
enumerable: desc == null ? void 0 : desc.enumerable,
configurable: true,
get() {
return keyVal.value;
},
set(v) {
keyVal.value = v;
}
});
}
}
const ComputedHandler = {
key: "Computed",
handler: handler$2
};
const MetadataKey$1 = Symbol("Hook");
function Hook(lifecycle) {
return function(target, key) {
let list = Reflect.getMetadata(MetadataKey$1, target) || [];
list = list.slice();
const hasItem = list.find((k) => k.key === key && k.lifecycle === lifecycle);
if (!hasItem)
list.push({ key, lifecycle });
Reflect.defineMetadata(MetadataKey$1, list, target);
};
}
function handler$1(targetThis) {
const list = getProtoMetadata(targetThis, MetadataKey$1);
if (!list || !list.length)
return;
for (const item of list) {
let vueFn;
switch (item.lifecycle) {
case "BeforeMount":
vueFn = onBeforeMount;
break;
case "Mounted":
vueFn = onMounted;
break;
case "BeforeUpdate":
vueFn = onBeforeUpdate;
break;
case "Updated":
vueFn = onUpdated;
break;
case "BeforeUnmount":
vueFn = onBeforeUnmount;
break;
case "Unmounted":
vueFn = onUnmounted;
break;
case "Activated":
vueFn = onActivated;
break;
case "Deactivated":
vueFn = onDeactivated;
break;
case "ErrorCaptured":
vueFn = onErrorCaptured;
break;
case "RenderTracked":
vueFn = onRenderTracked;
break;
case "RenderTriggered":
vueFn = onRenderTriggered;
break;
case "ServerPrefetch":
vueFn = onServerPrefetch;
break;
}
vueFn(() => targetThis[item.key]());
}
}
const HookHandler = {
key: "Hook",
handler: handler$1
};
const MetadataKey = Symbol("Link");
function Link() {
return function(target, key) {
let list = Reflect.getMetadata(MetadataKey, target) || [];
list = list.slice();
const hasItem = list.find((k) => k === key);
if (!hasItem)
list.push(key);
Reflect.defineMetadata(MetadataKey, list, target);
};
}
function handler(targetThis) {
const list = getProtoMetadata(targetThis, MetadataKey);
if (!list || !list.length)
return;
for (const item of list) {
const instance = getCurrentInstance();
Object.defineProperty(targetThis, item, {
enumerable: true,
configurable: true,
get() {
return instance == null ? void 0 : instance.refs[item];
}
});
}
}
const LinkHandler = {
key: "Link",
handler
};
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
function noSideEffects(fn) {
return { toString: fn }.toString();
}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
function makeMetadataCtor(props) {
return function ctor(...args) {
if (props) {
const values = props(...args);
for (const propName in values) {
this[propName] = values[propName];
}
}
};
}
function makeParamDecorator(name, props) {
return noSideEffects(() => {
const metaCtor = makeMetadataCtor(props);
function ParamDecoratorFactory(...args) {
if (this instanceof ParamDecoratorFactory) {
metaCtor.apply(this, args);
return this;
}
}
return ParamDecoratorFactory;
});
}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
function getClosureSafeProperty(objWithPropertyToExtract) {
for (let key in objWithPropertyToExtract) {
if (objWithPropertyToExtract[key] === getClosureSafeProperty) {
return key;
}
}
throw Error("Could not find renamed property on target object.");
}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
function stringify(token) {
if (typeof token === "string") {
return token;
}
if (Array.isArray(token)) {
return "[" + token.map(stringify).join(", ") + "]";
}
if (token == null) {
return "" + token;
}
if (token.overriddenName) {
return `${token.overriddenName}`;
}
if (token.name) {
return `${token.name}`;
}
const res = token.toString();
if (res == null) {
return "" + res;
}
const newLineIndex = res.indexOf("\n");
return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
const __forward_ref__ = getClosureSafeProperty({
__forward_ref__: getClosureSafeProperty
});
function forwardRef(forwardRefFn) {
forwardRefFn.__forward_ref__ = forwardRef;
forwardRefFn.toString = function() {
return stringify(this());
};
return forwardRefFn;
}
function resolveForwardRef(type) {
return isForwardRef(type) ? type() : type;
}
function isForwardRef(fn) {
return typeof fn === "function" && fn.hasOwnProperty(__forward_ref__) && fn.__forward_ref__ === forwardRef;
}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
class RuntimeError extends Error {
constructor(code, message) {
super(formatRuntimeError(code, message));
this.code = code;
}
}
function formatRuntimeError(code, message) {
const fullCode = code ? `NG0${code}: ` : "";
let errorMessage = `${fullCode}${message}`;
return errorMessage;
}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
function renderStringify(value) {
if (typeof value === "string")
return value;
if (value == null)
return "";
return String(value);
}
function stringifyForError(value) {
if (typeof value === "function")
return value.name || value.toString();
if (typeof value === "object" && value != null && typeof value.type === "function") {
return value.type.name || value.type.toString();
}
return renderStringify(value);
}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
function throwProviderNotFoundError(token, injectorName) {
const injectorDetails = injectorName ? ` in ${injectorName}` : "";
throw new RuntimeError("201", `No provider for ${stringifyForError(token)} found${injectorDetails}`);
}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
function \u0275\u0275defineInjectable(opts) {
return {
token: opts.token,
providedIn: opts.providedIn || null,
factory: opts.factory,
value: void 0
};
}
function getInjectableDef(type) {
return getOwnDefinition(type, NG_PROV_DEF);
}
function getOwnDefinition(type, field) {
return type.hasOwnProperty(field) ? type[field] : null;
}
const NG_PROV_DEF = getClosureSafeProperty({
\u0275prov: getClosureSafeProperty
});
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
var InjectFlags;
(function(InjectFlags2) {
InjectFlags2[InjectFlags2["Default"] = 0] = "Default";
InjectFlags2[InjectFlags2["Self"] = 2] = "Self";
InjectFlags2[InjectFlags2["SkipSelf"] = 4] = "SkipSelf";
InjectFlags2[InjectFlags2["Optional"] = 8] = "Optional";
})(InjectFlags || (InjectFlags = {}));
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
function injectRootLimpMode(token, notFoundValue, flags) {
const injectableDef = getInjectableDef(token);
if (injectableDef && injectableDef.providedIn == "root") {
return injectableDef.value === void 0 ? injectableDef.value = injectableDef.factory() : injectableDef.value;
}
if (flags & InjectFlags.Optional)
return null;
if (notFoundValue !== void 0)
return notFoundValue;
throwProviderNotFoundError(stringify(token), "Injector");
}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
const _THROW_IF_NOT_FOUND = {};
const THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
const DI_DECORATOR_FLAG = "__NG_DI_FLAG__";
const NG_TEMP_TOKEN_PATH = "ngTempTokenPath";
const NG_TOKEN_PATH = "ngTokenPath";
const NEW_LINE = /\n/gm;
const NO_NEW_LINE = "\u0275";
const SOURCE = "__source";
const USE_VALUE = getClosureSafeProperty({
provide: String,
useValue: getClosureSafeProperty
});
let _currentInjector = void 0;
function setCurrentInjector(injector) {
const former = _currentInjector;
_currentInjector = injector;
return former;
}
function injectInjectorOnly(token, flags = InjectFlags.Default) {
if (_currentInjector === void 0) {
throw new Error(`inject() must be called from an injection context`);
} else if (_currentInjector === null) {
return injectRootLimpMode(token, void 0, flags);
} else {
return _currentInjector.get(token, flags & InjectFlags.Optional ? null : void 0, flags);
}
}
function \u0275\u0275inject(token, flags = InjectFlags.Default) {
return injectInjectorOnly(resolveForwardRef(token), flags);
}
function injectArgs(types) {
const args = [];
for (let i = 0; i < types.length; i++) {
const arg = resolveForwardRef(types[i]);
if (Array.isArray(arg)) {
if (arg.length === 0) {
throw new Error("Arguments array must have arguments.");
}
let type = void 0;
let flags = InjectFlags.Default;
for (let j = 0; j < arg.length; j++) {
const meta = arg[j];
const flag = getInjectFlag(meta);
if (typeof flag === "number") {
if (flag === -1) {
type = meta.token;
} else {
flags |= flag;
}
} else {
type = meta;
}
}
args.push(\u0275\u0275inject(type, flags));
} else {
args.push(\u0275\u0275inject(arg));
}
}
return args;
}
function attachInjectFlag(decorator, flag) {
decorator[DI_DECORATOR_FLAG] = flag;
decorator.prototype[DI_DECORATOR_FLAG] = flag;
return decorator;
}
function getInjectFlag(token) {
return token[DI_DECORATOR_FLAG];
}
function catchInjectorError(e, token, injectorErrorName, source) {
const tokenPath = e[NG_TEMP_TOKEN_PATH];
if (token[SOURCE]) {
tokenPath.unshift(token[SOURCE]);
}
e.message = formatError("\n" + e.message, tokenPath, injectorErrorName, source);
e[NG_TOKEN_PATH] = tokenPath;
e[NG_TEMP_TOKEN_PATH] = null;
throw e;
}
function formatError(text, obj, injectorErrorName, source = null) {
text = text && text.charAt(0) === "\n" && text.charAt(1) == NO_NEW_LINE ? text.substr(2) : text;
let context = stringify(obj);
if (Array.isArray(obj)) {
context = obj.map(stringify).join(" -> ");
} else if (typeof obj === "object") {
let parts = [];
for (let key in obj) {
if (obj.hasOwnProperty(key)) {
let value = obj[key];
parts.push(key + ":" + (typeof value === "string" ? JSON.stringify(value) : stringify(value)));
}
}
context = `{${parts.join(", ")}}`;
}
return `${injectorErrorName}${source ? "(" + source + ")" : ""}[${context}]: ${text.replace(NEW_LINE, "\n ")}`;
}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
attachInjectFlag(makeParamDecorator("Inject", (token) => ({ token })), -1);
attachInjectFlag(makeParamDecorator(), 8);
attachInjectFlag(makeParamDecorator(), 2);
attachInjectFlag(makeParamDecorator(), 4);
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
const NG_FACTORY_DEF = getClosureSafeProperty({
\u0275fac: getClosureSafeProperty
});
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
function getFactoryDef(type, throwNotFound) {
const hasFactoryDef = type.hasOwnProperty(NG_FACTORY_DEF);
return hasFactoryDef ? type[NG_FACTORY_DEF] : null;
}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
function deepForEach(input, fn) {
input.forEach((value) => Array.isArray(value) ? deepForEach(value, fn) : fn(value));
}
function newArray(size, value) {
const list = [];
for (let i = 0; i < size; i++) {
list.push(value);
}
return list;
}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
class InjectionToken {
constructor(_desc, options) {
this._desc = _desc;
this.\u0275prov = void 0;
if (typeof options == "number")
;
else if (options !== void 0) {
this.\u0275prov = \u0275\u0275defineInjectable({
token: this,
providedIn: options.providedIn || "root",
factory: options.factory
});
}
}
toString() {
return `InjectionToken ${this._desc}`;
}
}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
const INJECTOR = new InjectionToken("INJECTOR", -1);
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
class NullInjector {
get(token, notFoundValue = THROW_IF_NOT_FOUND) {
if (notFoundValue === THROW_IF_NOT_FOUND) {
const error = new Error(`NullInjectorError: No provider for ${stringify(token)}!`);
error.name = "NullInjectorError";
throw error;
}
return notFoundValue;
}
}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
const INJECTOR_SCOPE = new InjectionToken("Set Injector scope.");
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
const NOT_YET = {};
const CIRCULAR = {};
let NULL_INJECTOR = void 0;
function getNullInjector() {
if (NULL_INJECTOR === void 0) {
NULL_INJECTOR = new NullInjector();
}
return NULL_INJECTOR;
}
function createInjector(defType, parent = null, additionalProviders = null, name) {
const injector = createInjectorWithoutInjectorInstances(defType, parent, additionalProviders, name);
injector._resolveInjectorDefTypes();
return injector;
}
function createInjectorWithoutInjectorInstances(defType, parent = null, additionalProviders = null, name) {
return new R3Injector(defType, additionalProviders, parent || getNullInjector(), name);
}
class R3Injector {
constructor(def, additionalProviders, parent, source = null) {
this.parent = parent;
this.records = new Map();
this.injectorDefTypes = new Set();
this.onDestroy = new Set();
this._destroyed = false;
additionalProviders && deepForEach(additionalProviders, (provider) => this.processProvider(provider, def, additionalProviders));
this.records.set(INJECTOR, makeRecord(void 0, this));
const record = this.records.get(INJECTOR_SCOPE);
this.scope = record != null ? record.value : null;
this.source = source || (typeof def === "object" ? null : stringify(def));
}
get destroyed() {
return this._destroyed;
}
destroy() {
this.assertNotDestroyed();
this._destroyed = true;
try {
this.onDestroy.forEach((service) => service.ngOnDestroy());
} finally {
this.records.clear();
this.onDestroy.clear();
this.injectorDefTypes.clear();
}
}
get(token, notFoundValue = THROW_IF_NOT_FOUND, flags = InjectFlags.Default) {
this.assertNotDestroyed();
const previousInjector = setCurrentInjector(this);
try {
if (!(flags & InjectFlags.SkipSelf)) {
let record = this.records.get(token);
if (record === void 0) {
const def = couldBeInjectableType(token) && getInjectableDef(token);
if (def && this.injectableDefInScope(def)) {
record = makeRecord(injectableDefOrInjectorDefFactory(token), NOT_YET);
} else {
record = null;
}
this.records.set(token, record);
}
if (record != null) {
return this.hydrate(token, record);
}
}
const nextInjector = !(flags & InjectFlags.Self) ? this.parent : getNullInjector();
notFoundValue = flags & InjectFlags.Optional && notFoundValue === THROW_IF_NOT_FOUND ? null : notFoundValue;
return nextInjector.get(token, notFoundValue);
} catch (e) {
if (e.name === "NullInjectorError") {
const path = e[NG_TEMP_TOKEN_PATH] = e[NG_TEMP_TOKEN_PATH] || [];
path.unshift(stringify(token));
if (previousInjector) {
throw e;
} else {
return catchInjectorError(e, token, "R3InjectorError", this.source);
}
} else {
throw e;
}
} finally {
setCurrentInjector(previousInjector);
}
}
_resolveInjectorDefTypes() {
this.injectorDefTypes.forEach((defType) => this.get(defType));
}
toString() {
const tokens = [], records = this.records;
records.forEach((v, token) => tokens.push(stringify(token)));
return `R3Injector[${tokens.join(", ")}]`;
}
assertNotDestroyed() {
if (this._destroyed) {
throw new Error("Injector has already been destroyed.");
}
}
processProvider(provider, ngModuleType, providers) {
provider = resolveForwardRef(provider);
let token = isTypeProvider(provider) ? provider : resolveForwardRef(provider && provider.provide);
const record = providerToRecord(provider);
if (!isTypeProvider(provider) && provider.multi === true) {
let multiRecord = this.records.get(token);
if (multiRecord)
;
else {
multiRecord = makeRecord(void 0, NOT_YET, true);
multiRecord.factory = () => injectArgs(multiRecord.multi);
this.records.set(token, multiRecord);
}
token = provider;
multiRecord.multi.push(provider);
}
this.records.set(token, record);
}
hydrate(token, record) {
if (record.value === NOT_YET) {
record.value = CIRCULAR;
record.value = record.factory();
}
if (typeof record.value === "object" && record.value && hasOnDestroy(record.value)) {
this.onDestroy.add(record.value);
}
return record.value;
}
injectableDefInScope(def) {
if (!def.providedIn) {
return false;
}
const providedIn = resolveForwardRef(def.providedIn);
if (typeof providedIn === "string") {
return providedIn === "any" || providedIn === this.scope;
} else {
return this.injectorDefTypes.has(providedIn);
}
}
}
function injectableDefOrInjectorDefFactory(token) {
const injectableDef = getInjectableDef(token);
const factory = injectableDef !== null ? injectableDef.factory : getFactoryDef(token);
if (factory !== null) {
return factory;
}
if (token instanceof InjectionToken) {
throw new Error(`Token ${stringify(token)} is missing a \u0275prov definition.`);
}
if (token instanceof Function) {
return getUndecoratedInjectableFactory(token);
}
throw new Error("unreachable");
}
function getUndecoratedInjectableFactory(token) {
const paramLength = token.length;
if (paramLength > 0) {
const args = newArray(paramLength, "?");
throw new Error(`Can't resolve all parameters for ${stringify(token)}: (${args.join(", ")}).`);
}
return () => new token();
}
function providerToRecord(provider, ngModuleType, providers) {
if (isValueProvider(provider)) {
return makeRecord(void 0, provider.useValue);
} else {
const factory = providerToFactory(provider);
return makeRecord(factory, NOT_YET);
}
}
function providerToFactory(provider, ngModuleType, providers) {
let factory = void 0;
if (isTypeProvider(provider)) {
const unwrappedProvider = resolveForwardRef(provider);
return getFactoryDef(unwrappedProvider) || injectableDefOrInjectorDefFactory(unwrappedProvider);
} else {
if (isValueProvider(provider)) {
factory = () => resolveForwardRef(provider.useValue);
} else if (isFactoryProvider(provider)) {
factory = () => provider.useFactory(...injectArgs(provider.deps || []));
} else if (isExistingProvider(provider)) {
factory = () => \u0275\u0275inject(resolveForwardRef(provider.useExisting));
} else {
const classRef = resolveForwardRef(provider && (provider.useClass || provider.provide));
if (hasDeps(provider)) {
factory = () => new classRef(...injectArgs(provider.deps));
} else {
return getFactoryDef(classRef) || injectableDefOrInjectorDefFactory(classRef);
}
}
}
return factory;
}
function makeRecord(factory, value, multi = false) {
return {
factory,
value,
multi: multi ? [] : void 0
};
}
function isValueProvider(value) {
return value !== null && typeof value == "object" && USE_VALUE in value;
}
function isExistingProvider(value) {
return !!(value && value.useExisting);
}
function isFactoryProvider(value) {
return !!(value && value.useFactory);
}
function isTypeProvider(value) {
return typeof value === "function";
}
function hasDeps(value) {
return !!value.deps;
}
function hasOnDestroy(value) {
return value !== null && typeof value === "object" && typeof value.ngOnDestroy === "function";
}
function couldBeInjectableType(value) {
return typeof value === "function" || typeof value === "object" && value instanceof InjectionToken;
}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
function INJECTOR_IMPL__POST_R3__(providers, parent, name) {
return createInjector({ name }, parent, providers, name);
}
const INJECTOR_IMPL = INJECTOR_IMPL__POST_R3__;
class Injector {
static create(options, parent) {
if (Array.isArray(options)) {
return INJECTOR_IMPL(options, parent, "");
} else {
return INJECTOR_IMPL(options.providers, options.parent, options.name || "");
}
}
}
Injector.THROW_IF_NOT_FOUND = THROW_IF_NOT_FOUND;
Injector.NULL = new NullInjector();
Injector.\u0275prov = \u0275\u0275defineInjectable({
token: Injector,
providedIn: "any",
factory: () => \u0275\u0275inject(INJECTOR)
});
Injector.__NG_ELEMENT_ID__ = -1;
const InjectorKey = Symbol("Injector");
function resolveComponent(target) {
if (!target.\u0275fac)
return new target();
const parent = inject(InjectorKey, void 0);
const providers = [target].concat(target.providers || []);
const injector = Injector.create({
name: target.name,
providers,
parent
});
if (target.asStore) {
const current = getCurrentInstance();
const app = current.appContext.app;
app.provide(InjectorKey, injector);
app.getStore = () => injector;
app.getService = (token) => injector.get(token);
} else {
provide(InjectorKey, injector);
}
const compInstance = injector.get(target);
providers.forEach((k) => injector.get(k));
return compInstance;
}
const GlobalStoreKey = "GlobalStoreKey";
defineComponent({});
class VueComponent {
constructor() {
this.props = useProps();
this.context = useCtx();
this.context.expose(this);
const ThisConstructor = this.constructor;
if (ThisConstructor.ProviderKey)
provide(ThisConstructor.ProviderKey, this);
if (ThisConstructor.globalStore) {
const current = getCurrentInstance();
const app = current.appContext.app;
app.provide(GlobalStoreKey, this);
app.getStore = () => this;
app.getService = (token) => {
if ((typeof token === "function" || typeof token === "object") && "ProviderKey" in token) {
token = token.ProviderKey;
}
return current == null ? void 0 : current.provides[token];
};
}
VueComponent.handler.forEach((handler2) => handler2.handler(this));
}
static get __vccOpts() {
if (this.__vccOpts__value)
return this.__vccOpts__value;
const CompConstructor = this;
const _a = CompConstructor, { displayName, \u0275fac, \u0275prov, defaultProps, providers, ProviderKey: ProviderKey2, globalStore, asStore, emits } = _a, args = __objRest(_a, ["displayName", "\u0275fac", "\u0275prov", "defaultProps", "providers", "ProviderKey", "globalStore", "asStore", "emits"]);
console.log(args);
return this.__vccOpts__value = __spreadProps(__spreadValues({}, args), {
name: displayName || CompConstructor.name,
props: defaultProps || {},
emits: (emits || []).concat(getEmitsFromProps(CompConstructor.defaultProps || {})),
setup: (props, ctx) => {
const instance = CompConstructor.resolveComponent(CompConstructor);
return instance.render.bind(instance);
}
});
}
get $props() {
return this.props;
}
}
VueComponent.handler = [RefHandler, ComputedHandler, LinkHandler, HookHandler];
VueComponent.resolveComponent = resolveComponent;
const ProviderKey = "ProviderKey";
class VueService {
constructor() {
const ThisConstructor = this.constructor;
if (ThisConstructor.ProviderKey)
provide(ThisConstructor.ProviderKey, this);
VueService.handler.forEach((handler2) => handler2.handler(this));
}
}
VueService.handler = [RefHandler, ComputedHandler, LinkHandler, HookHandler];
export { Autobind, Computed, GlobalStoreKey, Hook, InjectorKey, Link, ProviderKey, Ref, VueComponent, VueService, getCurrentApp, getDeepOwnDescriptor, getEmitsFromProps, getProtoMetadata, injectService, useCtx, useProps };