/** * Dependency Injection System */ /** * Service container */ declare class Container { private services; private parent; constructor(parent?: Container); set(key: string, value: any): void; get(key: string): T; has(key: string): boolean; createChild(): Container; } /** * Get or create injector for element */ export declare function getInjector(el: HTMLElement): Container; /** * Provide a service globally * * @example * // Provide API service * Gyos.provide('api', { * fetchUser: () => fetch('/api/user').then(r => r.json()) * }); */ export declare function provide(key: string, value: any): void; /** * Inject a service from global DI container * * NOTE: This only works with globally provided services via Gyos.provide(). * To use element-scoped services (g-provide), use this.$inject() inside scopes. * * @example * // Global provide + inject * Gyos.provide('api', apiService); * const api = Gyos.inject('api'); // Works * * @example * // Element-scoped provide + inject * //
* Gyos.scope('Demo', { * onMount() { * const theme = this.$inject('theme'); // Use this.$inject, not Gyos.inject * } * }); */ export declare function inject(key: string, defaultValue?: T): T; /** * Get global container (for internal use) */ export declare function getGlobalContainer(): Container; export {}; //# sourceMappingURL=di.d.ts.map