{"version":3,"sources":["../src/_graph.ts","../src/inject.ts","../src/injector.ts","../src/inject_react.tsx","../src/testing.ts","../src/with_new_resolution_provider.tsx"],"names":["Scopes","registration","resolved","instance","jsx"],"mappings":";;;;;;;;;;;;;AAAA,IAAM,OAAN,MAAiB;AAAA,EAIhB,YAA4B,MAAS;AAAT;AAAA,EAE5B;AAAA,EALgB,WAAW,oBAAI,IAAmB;AAAA,EAClC,WAAW,oBAAI,IAAmB;AAKnD;AAEO,IAAM,QAAN,MAA4B;AAAA,EAGlC,YAA6B,UAAgC;AAAhC;AAAA,EAE7B;AAAA,EAJiB,QAAQ,oBAAI,IAAmB;AAAA,EAMzC,WAAW,MAAS,IAAa;AACvC,UAAM,WAAW,KAAK,mBAAmB,IAAI;AAC7C,UAAM,SAAS,KAAK,mBAAmB,EAAE;AAEzC,aAAS,SAAS,IAAI,KAAK,SAAS,EAAE,GAAG,MAAM;AAC/C,WAAO,SAAS,IAAI,KAAK,SAAS,IAAI,GAAG,QAAQ;AAAA,EAClD;AAAA,EAEO,OAAO,KAA2B;AACxC,WAAO,KAAK,MAAM,IAAI,GAAG,KAAK;AAAA,EAC/B;AAAA,EAEO,mBAAmB,MAAqB;AAC9C,UAAM,MAAM,KAAK,SAAS,IAAI;AAC9B,QAAI,OAAO,KAAK,MAAM,IAAI,GAAG;AAE7B,QAAI,CAAC,MAAM;AACV,aAAO,IAAI,KAAK,IAAI;AACpB,WAAK,MAAM,IAAI,KAAK,IAAI;AAAA,IACzB;AAEA,WAAO;AAAA,EACR;AAAA,EAEO,WAAW,KAAc;AAC/B,SAAK,MAAM,OAAO,GAAG;AAErB,eAAW,QAAQ,KAAK,MAAM,OAAO,GAAG;AACvC,WAAK,SAAS,OAAO,GAAG;AACxB,WAAK,SAAS,OAAO,GAAG;AAAA,IACzB;AAAA,EACD;AAAA,EAEO,QAAsB;AAC5B,UAAM,QAAsB,CAAC;AAC7B,eAAW,QAAQ,KAAK,MAAM,OAAO,GAAG;AACvC,UAAI,KAA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G,OAAO,GAAG;AAAA,EAChD;AACD","sourcesContent":["class Node<T, K> {\n\tpublic readonly incoming = new Map<K, Node<T, K>>();\n\tpublic readonly outgoing = new Map<K, Node<T, K>>();\n\n\tconstructor(public readonly data: T) {\n\t\t// Empty\n\t}\n}\n\nexport class Graph<T, K = unknown> {\n\tprivate readonly nodes = new Map<K, Node<T, K>>();\n\n\tconstructor(private readonly lookupFn: (dependency: T) => K) {\n\t\t// Empty\n\t}\n\n\tpublic insertEdge(from: T, to: T): void {\n\t\tconst fromNode = this.lookupOrInsertNode(from);\n\t\tconst toNode = this.lookupOrInsertNode(to);\n\n\t\tfromNode.outgoing.set(this.lookupFn(to), toNode);\n\t\ttoNode.incoming.set(this.lookupFn(from), fromNode);\n\t}\n\n\tpublic lookup(key: K): Node<T, K> | null {\n\t\treturn this.nodes.get(key) ?? null;\n\t}\n\n\tpublic lookupOrInsertNode(data: T): Node<T, K> {\n\t\tconst key = this.lookupFn(data);\n\t\tlet node = this.nodes.get(key);\n\n\t\tif (!node) {\n\t\t\tnode = new Node(data);\n\t\t\tthis.nodes.set(key, node);\n\t\t}\n\n\t\treturn node;\n\t}\n\n\tpublic removeNode(key: K): void {\n\t\tthis.nodes.delete(key);\n\n\t\tfor (const node of this.nodes.values()) {\n\t\t\tnode.outgoing.delete(key);\n\t\t\tnode.incoming.delete(key);\n\t\t}\n\t}\n\n\tpublic edges(): Node<T, K>[] {\n\t\tconst nodes: Node<T, K>[] = [];\n\t\tfor (const node of this.nodes.values()) {\n\t\t\tif (node.outgoing.size === 0) {\n\t\t\t\tnodes.push(node);\n\t\t\t}\n\t\t}\n\n\t\treturn nodes;\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn this.nodes.size === 0;\n\t}\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Graph } from './_graph';\nimport { todo } from '@wox-team/wox-app-vitals';\n\nlet currentResolution: Resolution | null = null;\n\nconst NOOP = () => {\n\t/* noop */\n};\nconst MAX_RECURSION_DEPTH_BEFORE_FLAGGING_CIRCULAR_NODES = 0xffff;\n\nexport type Ctor<T> = {\n\tnew (...args: any[]): T;\n};\n\nexport type GenericClassDecorator<T> = (target: T) => void;\n\nexport type Token<T = unknown> = Ctor<T> | symbol;\n\nexport enum Scopes {\n\tSingleton,\n\tTransient,\n\tScoped,\n\t/* @Internal */\n\tUnknown,\n}\n\nexport type ScopesLoose = 'singleton' | 'transient' | 'scoped';\n\ninterface RegistrationSettings {\n\treadonly scope: Scopes;\n}\n\ninterface Registration<T> {\n\treadonly token: Token<T>;\n\treadonly someValue: Token<T>;\n\treadonly settings: RegistrationSettings;\n}\n\nconst registry: Registration<any>[] = [];\n\nfunction INTERNAL_register<T>(\n\ttoken: Token<any>,\n\tsomeValue: Ctor<T>,\n\tsettings: RegistrationSettings,\n\t__fake__reflection?: any[],\n): void {\n\tregistry.push({\n\t\ttoken,\n\t\tsomeValue,\n\t\tsettings,\n\t});\n\n\tif (__fake__reflection != null) {\n\t\tINTERNAL_setCachedReflection(token, __fake__reflection);\n\t}\n}\n\nexport function getResolveScopeRef(): Resolution {\n\tif (currentResolution == null) throw new Error('Could not reach the current injector');\n\n\treturn currentResolution;\n}\n\nexport function resolve<T>(token: Token<T>): T {\n\treturn getResolveScopeRef().resolve(token);\n}\n\nexport function clearRegistry(): void {\n\twhile (registry.length) {\n\t\tregistry.pop();\n\t}\n}\n\ninterface ReflectedData {\n\tkey: Token;\n\tvalue: Token[];\n}\n\nconst REFLECTED_DATA_REGISTRY_CACHE: ReflectedData[] = [];\n\nfunction INTERNAL_getCachedReflection<T extends Token<any>>(reflector: T): Token[] {\n\tconst cachedReflection = REFLECTED_DATA_REGISTRY_CACHE.find((x) => x.key === reflector);\n\tif (cachedReflection != null) return cachedReflection.value;\n\n\tif (Injectable.lookup !== (NOOP as any)) {\n\t\tconst reflectedData = INTERNAL_setCachedReflection(reflector, Injectable.lookup<T>(reflector));\n\n\t\treturn reflectedData.value;\n\t}\n\n\treturn [];\n}\n\ninterface ConcreteClassSymbol<K, T extends K> {\n\tnew (...args: any): T;\n}\n\ntype ConcreteMappedSymbols<Type extends (abstract new (...args: any) => any)[]> = {\n\t[Property in keyof Type]: ConcreteClassSymbol<any, Type[Property]>;\n};\n\nfunction INTERNAL_setCachedReflection<T extends Token<any>>(\n\treflector: T,\n\treflectedTokens: T extends Ctor<any> ? ConcreteMappedSymbols<ConstructorParameters<T>> : Token[],\n): ReflectedData {\n\tconst cachedReflection = REFLECTED_DATA_REGISTRY_CACHE.find((x) => x.key === reflector);\n\tif (cachedReflection != null) return cachedReflection;\n\n\tconst newCachedReflectionData: ReflectedData = {\n\t\tkey: reflector,\n\t\tvalue: reflectedTokens,\n\t};\n\tREFLECTED_DATA_REGISTRY_CACHE.push(newCachedReflectionData);\n\n\treturn newCachedReflectionData;\n}\n\ninterface InjectableSettingsStrict {\n\t/**\n\t * @deprecated Use `scope` instead.\n\t */\n\treadonly lifetime?: Scopes;\n\treadonly scope?: Scopes;\n}\ninterface InjectableSettingsLoose {\n\treadonly scope?: ScopesLoose;\n}\n\ntype InjectableSettings = InjectableSettingsStrict | InjectableSettingsLoose;\n\n/**\n * Returns a decorator that that marks a class as available to be provided and injected as a dependency.\n */\nexport function Injectable(settings?: InjectableSettings): GenericClassDecorator<Ctor<any>>;\n// @internal\nexport function Injectable(settings?: InjectableSettings, __fake__reflection?: Token<any>[]): GenericClassDecorator<Ctor<any>> {\n\tconst scope = unwrapScope(settings);\n\n\treturn function decorate<T>(ctor: Ctor<T>) {\n\t\tINTERNAL_register(\n\t\t\tctor,\n\t\t\tctor,\n\t\t\t{\n\t\t\t\tscope: scope,\n\t\t\t},\n\t\t\t__fake__reflection,\n\t\t);\n\t};\n}\n\nfunction unwrapScope(unknownScope?: InjectableSettings): Scopes {\n\tif (unknownScope == null) return Scopes.Scoped;\n\n\tif (typeof unknownScope.scope === 'string') {\n\t\tswitch (unknownScope.scope) {\n\t\t\tcase 'singleton':\n\t\t\t\treturn Scopes.Singleton;\n\t\t\tcase 'transient':\n\t\t\t\treturn Scopes.Transient;\n\t\t\tcase 'scoped':\n\t\t\t\treturn Scopes.Scoped;\n\t\t\tdefault:\n\t\t\t\treturn Scopes.Unknown;\n\t\t}\n\t}\n\n\tif ('lifetime' in unknownScope) {\n\t\treturn unknownScope.lifetime ?? Scopes.Scoped;\n\t}\n\n\treturn unknownScope.scope ?? Scopes.Scoped;\n}\n\nexport type LookupImpl = <T>(token: Token<T>) => T extends Ctor<any> ? ConcreteMappedSymbols<ConstructorParameters<T>> : Token[];\n\nexport function register<T>(token: Token<any>, someValue: Ctor<T>, scope?: Scopes): void {\n\tINTERNAL_register(token, someValue, {\n\t\tscope: scope ?? Scopes.Scoped,\n\t});\n}\n\nInjectable.naughtyReflection = INTERNAL_setCachedReflection;\nInjectable.lookup = NOOP as unknown as LookupImpl;\nInjectable.register = register;\n\ninterface Resolved<T> {\n\ttoken: Token<T>;\n\tinstance: T;\n}\n\n/**\n * The Container class has the responsibility is to hold onto all the resolved instances during runtime and providing easy to access\n */\nexport class Container {\n\tprivate static instanceCounter = 0;\n\tpublic readonly id: number;\n\n\tpublic singletons: Resolved<unknown>[];\n\tpublic scoped: Resolved<unknown>[];\n\tpublic parentScope: (Container | Readonly<Container>) | null;\n\tpublic hotRegistrationRegister: Registration<any>[];\n\n\tconstructor(parentScope?: Container | Readonly<Container>, shouldInherit = true) {\n\t\tthis.id = Container.instanceCounter++;\n\n\t\tthis.scoped = [];\n\t\tthis.parentScope = shouldInherit ? parentScope ?? null : null;\n\t\tthis.singletons = parentScope?.singletons ?? [];\n\t\tthis.hotRegistrationRegister = parentScope?.hotRegistrationRegister ?? [];\n\t}\n\n\t/**\n\t * Given the current context, it'll try to find any resolved Singletons or Scoped instances.\n\t *\n\t * @throws Will throw an error if dependency is not registered.\n\t */\n\tpublic getPotentialResolvedDependency<T>(dependencyToken: Token<T>): [resolved: T | null, registration: Registration<T>] {\n\t\tconst registration = this.scanRegistration(dependencyToken);\n\t\tif (registration == null) {\n\t\t\tthrow new Error(`Dependency not registered: ${dependencyToken.toString()}`);\n\t\t}\n\n\t\tconst resolved = this.scanResolved(registration);\n\t\tif (resolved != null) return [resolved.instance, registration];\n\n\t\treturn [null, registration];\n\t}\n\n\tpublic scanRegistration<T>(dependencyToken: Token<T>): Registration<T> | null {\n\t\t// Goes backwards to make it simpler compatible with testing.\n\t\tlet registration: Registration<T> | null = null;\n\t\tfor (let index = registry.length; index > 0; index--) {\n\t\t\tconst item = registry[index - 1];\n\t\t\tif (item.token === dependencyToken) {\n\t\t\t\tregistration = item;\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (this.hotRegistrationRegister.length > 0) {\n\t\t\tfor (const hotRegistration of this.hotRegistrationRegister) {\n\t\t\t\tif (hotRegistration.token === dependencyToken) {\n\t\t\t\t\tif (registration) {\n\t\t\t\t\t\t(registration.someValue as any) = hotRegistration.someValue;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tregistration = hotRegistration;\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (registration != null) {\n\t\t\treturn registration;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tpublic scanRegistrationStrict<T>(dependencyToken: Token<T>): Registration<T> {\n\t\tconst registration = this.scanRegistration(dependencyToken);\n\t\tif (registration == null) throw new Error(`Could not retrieve registration. \"${unwrapTokenForPrint(dependencyToken)}\"`);\n\n\t\treturn registration;\n\t}\n\n\tpublic scanResolved<T>(registration: Registration<T>): Resolved<T> | null {\n\t\tif (registration.settings.scope === Scopes.Singleton) {\n\t\t\treturn (this.singletons.find((x) => x.token === registration.token) as Resolved<T>) ?? null;\n\t\t}\n\n\t\tif (registration.settings.scope === Scopes.Scoped) {\n\t\t\treturn (\n\t\t\t\t(this.scoped.find((x) => x.token === registration.token) as Resolved<T>) ??\n\t\t\t\tthis.lookThroughInheritedScopesToFindResolved(registration) ??\n\t\t\t\tnull\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tpublic addHotRegistration<T>(dependencyToken: Token<T>, value: any, scope?: Scopes): void {\n\t\tthis.hotRegistrationRegister.push({\n\t\t\ttoken: dependencyToken,\n\t\t\tsomeValue: value as any,\n\t\t\tsettings: {\n\t\t\t\tscope: scope ?? Scopes.Unknown,\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * **NOTE**\n\t * Don't use this in application code. Mocks are for testing only, expect lot of side effects if used in application code.\n\t */\n\tpublic clearHotRegistration(): void {\n\t\tthis.hotRegistrationRegister = [];\n\t}\n\n\t/**\n\t * **NOTE**\n\t * Don't use this in application code. It's for specifically running certain tests, expect lot of side effects.\n\t */\n\tpublic clearSingletons(): void {\n\t\tthis.singletons = [];\n\t}\n\n\t/**\n\t * **NOTE**\n\t * Don't use this in application code. It's for specifically running certain tests, expect lot of side effects.\n\t */\n\tpublic clearScoped(): void {\n\t\tthis.scoped = [];\n\t}\n\n\t/**\n\t * **NOTE**\n\t * Don't use this in application code. It's for specifically running certain tests, expect lot of side effects.\n\t */\n\tpublic clearInheritedScoped(): void {\n\t\tthis.parentScope = null;\n\t}\n\n\t/**\n\t * **NOTE**\n\t * Don't use this in application code. It's for specifically running certain tests, expect lot of side effects.\n\t */\n\tpublic clearAll(): void {\n\t\tthis.clearSingletons();\n\t\tthis.clearScoped();\n\t\tthis.clearInheritedScoped();\n\t\tthis.clearHotRegistration();\n\t}\n\n\tprivate lookThroughInheritedScopesToFindResolved<T>(registration: Registration<T>): Resolved<T> | null {\n\t\tlet parent = this.parentScope;\n\n\t\twhile (parent != null) {\n\t\t\tconst resolved = parent.scoped.find((x) => x.token === registration.token) as Resolved<T>;\n\t\t\tif (resolved) {\n\t\t\t\treturn resolved;\n\t\t\t}\n\n\t\t\tparent = parent.parentScope;\n\t\t}\n\n\t\treturn null;\n\t}\n}\n\nexport class Resolution {\n\tprivate static instanceCounter = 0;\n\n\tpublic readonly id: number;\n\tpublic readonly container: Container;\n\n\tconstructor(container: Readonly<Container>) {\n\t\tthis.id = Resolution.instanceCounter++;\n\n\t\tthis.container = container as Container;\n\t}\n\n\tpublic resolve<T>(dependencyToken: Token<T>): T {\n\t\t// eslint-disable-next-line @typescript-eslint/no-this-alias\n\t\tcurrentResolution = this;\n\n\t\t// If the token, for this depth, has already been resolved. Return it.\n\t\tconst [resolved, registration] = this.container.getPotentialResolvedDependency(dependencyToken);\n\t\tif (resolved != null) return resolved;\n\n\t\tconst dependenciesForEachDependency = new Map<Token, Registration<unknown>[]>();\n\n\t\t// Here we're setting up a graph to plot out all the included dependencies of the resolving dependency.\n\t\tconst dependencyGraph = new Graph<NodeData>((node) => node.id);\n\n\t\tconst transients: Resolved<unknown>[] = [];\n\n\t\t// -- Step one - Branch Step --\n\n\t\tconst nodeStack = [this.step_one_createNode(registration, null)];\n\n\t\t// Keeping track of the depth might seem redundant but it does provide an early sign that something is wrong.\n\t\t// If a tree structure is approaching the maximum depth, something is up...\n\t\tlet depth = 0;\n\t\twhile (nodeStack.length > 0) {\n\t\t\tconst node = nodeStack.pop();\n\t\t\tif (node == null) throw new Error('Undefined behavior, how did you end up here?');\n\t\t\tif (depth++ > MAX_RECURSION_DEPTH_BEFORE_FLAGGING_CIRCULAR_NODES) throw new Error('Reach max depth, recursive dependency?');\n\n\t\t\tdependencyGraph.lookupOrInsertNode(node);\n\n\t\t\tconst dependencies = INTERNAL_getCachedReflection(node.registration.token);\n\t\t\tconst registrations = dependencies.map((dependency) => this.container.scanRegistrationStrict(dependency));\n\n\t\t\tfor (const registration of registrations) {\n\t\t\t\tif (registration == null) throw new Error('A dependency was not registered.');\n\n\t\t\t\tconst newEdge = this.step_one_createNode(registration, node.parent);\n\t\t\t\tdependencyGraph.insertEdge(node, newEdge);\n\n\t\t\t\tnodeStack.push(newEdge);\n\t\t\t}\n\n\t\t\tdependenciesForEachDependency.set(node.registration.token, registrations);\n\t\t}\n\n\t\t// -- Step two - Producer Step --\n\n\t\tdepth = 0;\n\t\twhile (true) {\n\t\t\tif (depth++ > MAX_RECURSION_DEPTH_BEFORE_FLAGGING_CIRCULAR_NODES) throw new Error('Reach max depth, recursive dependency?');\n\n\t\t\tconst edges = dependencyGraph.edges();\n\n\t\t\tif (edges.length === 0) {\n\t\t\t\tif (!dependencyGraph.isEmpty()) throw new Error('Graph contains nodes which never got removed.');\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tfor (const edge of edges) {\n\t\t\t\tconst registration = edge.data.registration;\n\t\t\t\tconst token = registration.token;\n\t\t\t\tconst factory = registration.someValue;\n\n\t\t\t\tdependencyGraph.removeNode(edge.data.id);\n\n\t\t\t\tif (typeof token === 'symbol') {\n\t\t\t\t\ttodo('Non ctor injection');\n\t\t\t\t} else {\n\t\t\t\t\tlet resolved = registration ? this.container.scanResolved(registration) : null;\n\t\t\t\t\tif (resolved == null) {\n\t\t\t\t\t\tconst args = this.step_two_retrieveArgs(token, dependenciesForEachDependency, transients);\n\t\t\t\t\t\tconst instance = new /* As Ctor */ (factory as any)(...args);\n\n\t\t\t\t\t\tresolved = {\n\t\t\t\t\t\t\tinstance: instance,\n\t\t\t\t\t\t\ttoken: token,\n\t\t\t\t\t\t} satisfies Resolved<unknown>;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (registration.settings.scope === Scopes.Singleton) {\n\t\t\t\t\t\tthis.container.singletons.push(resolved);\n\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (registration.settings.scope === Scopes.Scoped) {\n\t\t\t\t\t\tthis.container.scoped.push(resolved);\n\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (registration.settings.scope === Scopes.Transient) {\n\t\t\t\t\t\ttransients.push(resolved);\n\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow new Error('Unknown scope');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// -- Step three - Retrieve step --\n\n\t\tlet instance: T;\n\t\tif (registration.settings.scope === Scopes.Transient) {\n\t\t\tinstance = transients[transients.length - 1].instance as T;\n\t\t} else {\n\t\t\tconst newResolved = this.container.scanResolved(registration);\n\t\t\tif (newResolved == null) {\n\t\t\t\ttodo('Cannot get the complete resolution');\n\t\t\t}\n\n\t\t\tinstance = newResolved.instance;\n\t\t}\n\n\t\tcurrentResolution = null;\n\n\t\treturn instance;\n\t}\n\n\tprivate step_one_createNode<T>(registration: Registration<T>, parent: Registration<unknown> | null): NodeData {\n\t\tlet id = registration.token;\n\t\tif (registration.settings.scope === Scopes.Transient) {\n\t\t\tid = Symbol('force new edge');\n\t\t}\n\n\t\treturn {\n\t\t\tid,\n\t\t\tregistration,\n\t\t\tparent,\n\t\t};\n\t}\n\n\tprivate step_two_retrieveArgs(\n\t\ttoken: Ctor<unknown>,\n\t\tdepRef: Map<Token, Registration<unknown>[]>,\n\t\ttransients: Resolved<unknown>[],\n\t): unknown[] {\n\t\tconst lookupDependencies = depRef.get(token) ?? [];\n\n\t\tconst args: unknown[] = [];\n\n\t\tfor (const dep of lookupDependencies) {\n\t\t\tlet instance: unknown;\n\t\t\tif (dep.settings.scope === Scopes.Transient) {\n\t\t\t\tconst i = transients.findIndex((x) => x.token === dep.token);\n\t\t\t\tif (i === -1) {\n\t\t\t\t\tthrow new Error('Could not find a transient instance');\n\t\t\t\t}\n\n\t\t\t\tinstance = transients[i].instance;\n\t\t\t\ttransients.splice(i, 1);\n\t\t\t} else {\n\t\t\t\tconst resolved = this.container.scanResolved(dep);\n\t\t\t\tif (resolved == null) {\n\t\t\t\t\ttodo('Failed to a resolved dep');\n\t\t\t\t}\n\n\t\t\t\tinstance = resolved.instance;\n\t\t\t}\n\n\t\t\targs.push(instance);\n\t\t}\n\n\t\treturn args;\n\t}\n}\n\ninterface NodeData {\n\tid: Token<unknown>;\n\tregistration: Registration<unknown>;\n\tparent: Registration<unknown> | null;\n}\n\nfunction unwrapTokenForPrint(token: Token): string {\n\tif (token instanceof Symbol) {\n\t\treturn token.toString();\n\t}\n\n\treturn token.toString();\n}\n","import { Injectable, Token, getResolveScopeRef } from './inject';\n\n@Injectable()\nexport class Injector {\n\tprivate readonly currentResolution = getResolveScopeRef();\n\n\tpublic resolve<T>(dependencyToken: Token<T>): T {\n\t\treturn this.currentResolution.resolve(dependencyToken);\n\t}\n}\nInjectable.naughtyReflection(Injector, []);\n","// Reason: For abstract inheritance usage for ControllerProtocol, this module can't imposed the method shape on the implementor.\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport { useConstant } from '@wox-team/wox-app-vitals';\nimport { createContext, useContext, useLayoutEffect, useRef } from 'react';\nimport { Container, Resolution } from './inject';\nimport type { Token } from './inject';\n\nconst GlobalResolutionContext = createContext(new Resolution(new Container()));\n\ninterface NewContainerProps extends React.PropsWithChildren {\n\t/**\n\t * If provided, Singletons and Scoped instances from this container will be inherited by the new container.\n\t */\n\tinheritFrom?: Container;\n\n\t/**\n\t * Whether the new container should inherit the parent container's Scoped instances.\n\t */\n\tshouldInheritScopes?: boolean;\n\n\t/**\n\t * @deprecated\n\t * Use `inheritContainer` instead.\n\t */\n\tparentContainer?: Resolution;\n\n\t/**\n\t * @deprecated\n\t * Use `shouldInheritScopes` instead.\n\t */\n\tuseInheritanceLink?: boolean;\n}\n\n/**\n * A React component that provides an optional dependency resolution scope to its child components.\n * When used, it creates a new dependency injection container and sets it as the context value,\n * allowing for isolated dependency management within its subtree.\n *\n * @param {NewContainerProps} props - The properties and children to be rendered.\n * @returns {JSX.Element} A JSX element that wraps its children with an optional dependency resolution context.\n *\n * @example\n * // To enable isolated dependency resolution within a component subtree, wrap it with NewContainer.\n * <NewContainer>\n *   <ComponentWithDependencies />\n * </NewContainer>\n *\n * // Alternatively, the app can still function without using NewContainer.\n * // In this case, dependency resolution will use the parent container's scope.\n * <ComponentWithDependencies />\n */\nexport function NewContainer(props: NewContainerProps) {\n\tlet backwards_compatible__inheritFrom: Readonly<Container> | null;\n\tif (props.parentContainer != null) {\n\t\tbackwards_compatible__inheritFrom = props.parentContainer.container;\n\t} else if (props.inheritFrom != null) {\n\t\tbackwards_compatible__inheritFrom = props.inheritFrom;\n\t} else {\n\t\tbackwards_compatible__inheritFrom = null;\n\t}\n\n\tlet backwards_compatible__useInheritanceLink: boolean;\n\tif (props.useInheritanceLink != null) {\n\t\tbackwards_compatible__useInheritanceLink = props.useInheritanceLink;\n\t} else if (props.shouldInheritScopes != null) {\n\t\tbackwards_compatible__useInheritanceLink = props.shouldInheritScopes;\n\t} else {\n\t\tbackwards_compatible__useInheritanceLink = true;\n\t}\n\n\tconst globalResolutionCtx = useContext(GlobalResolutionContext);\n\tconst container = useConstant(\n\t\t() =>\n\t\t\tnew Resolution(\n\t\t\t\tnew Container(backwards_compatible__inheritFrom ?? globalResolutionCtx.container, backwards_compatible__useInheritanceLink),\n\t\t\t),\n\t);\n\n\treturn <GlobalResolutionContext.Provider value={container}>{props.children}</GlobalResolutionContext.Provider>;\n}\n\n/**\n * A custom React hook for resolving and using dependencies from the dependency injection container.\n *\n * @param {Token<T>} dependencyToken - The token representing the desired dependency to resolve.\n * @returns {T} The resolved dependency value.\n *\n * @template T\n *\n * @example\n * // Use useResolve to resolve and use a dependency in a functional component.\n * function MyComponent() {\n *   const someService = useResolve(SomeServiceToken);\n *   // Now you can use someService within your component.\n * }\n */\nexport function useResolve<T>(dependencyToken: Token<T>): T {\n\tconst globalResolutionCtx = useContext(GlobalResolutionContext);\n\tconst value = useConstant(() => globalResolutionCtx.resolve(dependencyToken));\n\n\treturn value;\n}\n\nexport interface Lifecycle<T extends any[] = any[]> {\n\twhenMount?(...args: T): any;\n\twhenRepeatedlyMount?(...args: T): any;\n\twhenUpdate?(...args: T): any;\n\twhenDemount?(...args: T): any;\n}\n\ntype ControllerCtor<T> = {\n\tnew (...args: any[]): T & Lifecycle;\n};\n\n/**\n * A custom React hook for resolving and using a controller instance from the dependency injection container.\n *\n * @param {ControllerCtor<T>} dependencyToken - The token representing the controller's constructor function.\n * @returns {T} The resolved controller instance.\n *\n * @template T\n *\n * @example\n * // Use useResolveLifecycle to resolve and use a controller in a React component.\n * function MyComponent() {\n *   const controller = useResolveLifecycle(MyControllerToken);\n *   // Now you can use the controller instance within your component.\n * }\n */\nexport function useResolveLifecycle<T extends Lifecycle>(\n\tdependencyToken: ControllerCtor<T>,\n\t...params: T['whenMount'] extends (...args: any) => any\n\t\t? Parameters<T['whenMount']>\n\t\t: T['whenUpdate'] extends (...args: any) => any\n\t\t  ? Parameters<T['whenUpdate']>\n\t\t  : T['whenDemount'] extends (...args: any) => any\n\t\t    ? Parameters<T['whenDemount']>\n\t\t    : T['whenRepeatedlyMount'] extends (...args: any) => any\n\t\t      ? Parameters<T['whenRepeatedlyMount']>\n\t\t      : never[]\n): T {\n\tconst globalResolutionCtx = useContext(GlobalResolutionContext);\n\tconst hasBeenResolved = useConstant(() => {\n\t\tconst container = globalResolutionCtx.container;\n\t\tconst registration = container.scanRegistration(dependencyToken);\n\t\tif (registration == null) return false;\n\n\t\tconst instance = container.scanResolved(registration);\n\t\treturn instance != null;\n\t});\n\tconst instance = useConstant(() => globalResolutionCtx.resolve(dependencyToken));\n\n\tconst hasCalledMount = useRef(false);\n\tconst latestParams = useRef(params);\n\n\tuseLayoutEffect(\n\t\tfunction ReactLifeCycleTapIn() {\n\t\t\tif (hasCalledMount.current) {\n\t\t\t\tlatestParams.current = params;\n\t\t\t\tboxFn(instance.whenUpdate?.bind(instance), latestParams.current);\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\thasCalledMount.current = true;\n\n\t\t\tif (hasBeenResolved) {\n\t\t\t\tboxFn(instance.whenRepeatedlyMount?.bind(instance), params);\n\t\t\t} else {\n\t\t\t\tboxFn(instance.whenMount?.bind(instance), params);\n\t\t\t}\n\t\t},\n\t\t[instance, params],\n\t);\n\n\tuseLayoutEffect(() => {\n\t\treturn () => {\n\t\t\tboxFn(instance.whenDemount?.bind(instance), latestParams.current);\n\t\t};\n\t}, [instance]);\n\n\treturn instance;\n}\n\nfunction boxFn(fn: ((...args: any[]) => any) | undefined, params: any[]) {\n\ttry {\n\t\tconst response = fn?.(...params);\n\t\tif (response instanceof Promise) {\n\t\t\tresponse.catch((error) => {\n\t\t\t\tprintBoxedError(error);\n\t\t\t});\n\t\t}\n\t} catch (error) {\n\t\tprintBoxedError(error);\n\t}\n}\n\nfunction printBoxedError(exception: unknown) {\n\tlet error: Error;\n\tif (exception instanceof Error) {\n\t\terror = exception;\n\t} else {\n\t\terror = new Error('unknown', {\n\t\t\tcause: exception,\n\t\t});\n\t}\n\n\tconsole.error(error);\n}\n","import { Scopes, type Token } from './inject';\nimport { Container, Resolution } from './inject';\n\n/**\n * Creates a new TestBed instance, which is a container for\n * managing dependencies and facilitating dependency injection.\n */\nexport function createTestBed() {\n\treturn new TestBed();\n}\n\nclass TestBed {\n\tpublic readonly resolution: Resolution;\n\tpublic readonly container: Container;\n\n\tconstructor() {\n\t\tthis.container = new Container();\n\t\tthis.resolution = new Resolution(this.container);\n\t}\n\n\tpublic resolve<T>(dependencyToken: Token<T>) {\n\t\treturn this.resolution.resolve(dependencyToken);\n\t}\n\n\tpublic mockRegister<T>(token: Token<any>, factory: T, lifeTime?: Scopes): void {\n\t\tthis.container.addHotRegistration(token, factory, lifeTime);\n\t}\n\n\tpublic clearMocks() {\n\t\tthis.container.clearHotRegistration();\n\t}\n}\n","import { NewContainer } from './inject_react';\nimport { type ComponentType } from 'react';\n\nexport function withNewContainer<T extends Record<string, unknown>>(Component: ComponentType<T>) {\n\treturn function (props: T) {\n\t\treturn <NewContainer>{<Component {...props} />}</NewContainer>;\n\t};\n}\n"]}