-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
209 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './integrations.module'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { DynamicNgModule, IntegrationsConfig } from '@apex/client'; | ||
import { SupabaseModule } from '@apex/integrations/supabase/client'; | ||
|
||
export class IntegrationsModule extends DynamicNgModule<IntegrationsModule> { | ||
constructor(private readonly config: IntegrationsConfig) { | ||
super(); | ||
} | ||
|
||
process() { | ||
if (this.config.supabase) { | ||
this.addImport(SupabaseModule); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
/* eslint-disable import/no-internal-modules */ | ||
export * from './lib/config'; | ||
export * from './lib/auth'; | ||
export * from './lib/utils'; | ||
export * from './lib/dynamic-module'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { InjectionToken } from '@angular/core'; | ||
import { ClassType } from '@deepkit/core'; | ||
|
||
export const AUTH_DIALOG_COMPONENT = new InjectionToken< | ||
ClassType<AuthDialogComponent> | ||
>('AUTH_DIALOG_COMPONENT'); | ||
|
||
export interface AuthDialogComponent {} | ||
|
||
export abstract class AuthService {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { | ||
EnvironmentProviders, | ||
importProvidersFrom, | ||
ModuleWithProviders, | ||
Provider, | ||
} from '@angular/core'; | ||
import { ClassType } from '@deepkit/core'; | ||
|
||
import { setFactoryDef, setInjectorDef, setNgModuleDef } from './utils'; | ||
|
||
export type NgModuleProvider = Provider | EnvironmentProviders; | ||
|
||
export function importProvidersDynamicallyFrom( | ||
...modules: readonly DynamicNgModule<unknown>[] | ||
): EnvironmentProviders { | ||
return importProvidersFrom(...modules.map(module => module.configure())); | ||
} | ||
|
||
export abstract class DynamicNgModule<T> { | ||
private readonly imports = new Set<ClassType>(); | ||
private readonly providers = new Set<NgModuleProvider>(); | ||
|
||
protected addProvider(provider: NgModuleProvider) { | ||
this.providers.add(provider); | ||
} | ||
|
||
protected addImport(module: ClassType) { | ||
this.imports.add(module); | ||
} | ||
|
||
protected abstract process(): void; | ||
|
||
configure(): ModuleWithProviders<T> { | ||
this.process(); | ||
|
||
setNgModuleDef(this.constructor, { | ||
type: this.constructor, | ||
imports: [...this.imports], | ||
}); | ||
|
||
setInjectorDef(this.constructor, { | ||
imports: [...this.imports], | ||
providers: [...this.providers], | ||
}); | ||
|
||
setFactoryDef(this.constructor, () => this); | ||
|
||
return { | ||
ngModule: this.constructor as ClassType<T>, | ||
providers: [], | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { | ||
ɵNG_INJ_DEF, | ||
ɵNG_MOD_DEF, | ||
ɵɵdefineInjector, | ||
ɵɵdefineNgModule, | ||
} from '@angular/core'; | ||
|
||
export const ɵNG_FAC_DEF = 'ɵfac' as const; | ||
|
||
export function setInjectorDef( | ||
type: any, | ||
def: Parameters<typeof ɵɵdefineInjector>[0], | ||
) { | ||
type[ɵNG_INJ_DEF] = ɵɵdefineInjector(def); | ||
} | ||
|
||
export function setNgModuleDef( | ||
type: any, | ||
def: Parameters<typeof ɵɵdefineNgModule>[0], | ||
) { | ||
type[ɵNG_MOD_DEF] = ɵɵdefineNgModule(def); | ||
} | ||
|
||
export function setFactoryDef(type: any, fac: () => any) { | ||
Object.defineProperty(type, ɵNG_FAC_DEF, { | ||
configurable: true, | ||
get: () => fac, | ||
}); | ||
} |
Empty file.
Oops, something went wrong.