Skip to content

Commit

Permalink
Refactor fontLoader module to add FontWatcher and Watcher classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Abourass committed Sep 19, 2024
1 parent d2c79e4 commit 909a5cd
Show file tree
Hide file tree
Showing 35 changed files with 2,889 additions and 21 deletions.
8 changes: 7 additions & 1 deletion dist/class/Tome.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
type HookableEvents = "renderChatLog" | "renderChatMessage";
type CoreLifeCycleHooks = 'init' | 'ready' | 'error' | 'setup' | 'i18nInit';
type HookableEvents = "renderChatLog" | "renderChatMessage" | 'renderApplication' | CoreLifeCycleHooks;
type HookEvent = (app: Application, html: JQuery, data?: any) => void | Promise<void>;
interface RuleMenu extends ClientSettings.PartialSettingSubmenuConfig {
}
Expand All @@ -14,6 +15,7 @@ interface Rule {
* @comment false if you dont want it to show in module config
*/
config?: boolean;
choices?: Record<string, string>;
}
type NumberRule = Rule & {
type: typeof Number;
Expand Down Expand Up @@ -65,6 +67,10 @@ export declare abstract class Tome {
ready: boolean;
get name(): string;
get lowercaseName(): string;
get hasHooks(): boolean;
get hasSettings(): boolean;
get hasSocketFns(): boolean;
get needsEarlyInitialization(): boolean;
constructor(pTome: Pick<Tome, "moduleDescription" | "moduleName"> & {
settings?: TomeRuleConstructor;
hooks?: Tome["hooks"];
Expand Down
2 changes: 1 addition & 1 deletion dist/class/Tome.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions dist/modules/fontLoader/CustomLoader.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { FontLoader, Font, CustomFamilies, ParsedFont } from './types';
export declare class CustomLoader implements FontLoader {
private readonly fonts_;
private readonly uris_;
constructor(config: CustomFamilies);
/**
* Returns parsed uris strings
*/
getUris(): string[];
/**
* Return all font's that should be loaded
*/
getFonts(): Font[];
/**
* Returns font object array
*/
getParsedFonts(): ParsedFont[];
/**
* Parsing config to separate string and object families
* @param families
* @private
*/
private parseFamilyConfig_;
}
//# sourceMappingURL=CustomLoader.d.ts.map
1 change: 1 addition & 0 deletions dist/modules/fontLoader/CustomLoader.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions dist/modules/fontLoader/FontLoader.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { FontsLoaderConfig } from './types';
/**
* Main function that loads all the fonts to <link /> tag
* @param fontsLoaderConfig
*/
export declare const FontsLoader: (fontsLoaderConfig: FontsLoaderConfig) => Promise<void>;
//# sourceMappingURL=FontLoader.d.ts.map
1 change: 1 addition & 0 deletions dist/modules/fontLoader/FontLoader.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions dist/modules/fontLoader/GoogleLoader.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { FontLoader, FontFamilies, Font, ParsedFont } from './types';
export declare class GoogleFontApi {
private apiUrl_;
private fonts_;
private version_;
/**
* @param fonts
* @param version
*/
constructor(fonts: string[], version?: 1 | 2);
/**
* Builds font googleapis url from given fonts in constructor
* @return string
*/
buildUri(): string;
}
export declare class GoogleLoader implements FontLoader {
private fonts_;
private uri_;
constructor(fonts: FontFamilies);
/**
* Returns google uri to get all the fonts
*/
getUris(): string[];
/**
* Return all google font's that should be loaded
*/
getFonts(): Font[];
/**
* Returns ParsedFont array for native font loading
*/
getParsedFonts(): Promise<ParsedFont[]>;
/**
* Generates google font api url from given array of fonts
*/
private generateUri_;
}
//# sourceMappingURL=GoogleLoader.d.ts.map
1 change: 1 addition & 0 deletions dist/modules/fontLoader/GoogleLoader.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions dist/modules/fontLoader/utils/CSSParser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { ParsedFont } from '../types';
export declare class CssParser {
private css_;
private rules_;
constructor(fontFaceResponseText: string);
/**
* Returns ParsedFont array of parsed CSS
*/
getParsedFonts(): ParsedFont[];
/**
* Parses CSS into array of ParsedFont object
*/
parseCSS(): void;
/**
* Parsing css block
* @param css
* @private
*/
private parseCSSBlock_;
/**
* Removes all empty lines from CSS
* @param css
* @private
*/
private removeNewLines_;
}
//# sourceMappingURL=CSSParser.d.ts.map
1 change: 1 addition & 0 deletions dist/modules/fontLoader/utils/CSSParser.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions dist/modules/fontLoader/utils/EventBus.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { FontsLoaderConfig } from '../types';
export declare enum FontEvents {
LOADING = "loading",
ACTIVE = "active",
INACTIVE = "inactive",
FONT_LOADING = "fontloading",
FONT_ACTIVE = "fontactive",
FONT_INACTIVE = "fontinactive"
}
export declare class EventBus {
private namespace_;
private classSeparator_;
private event_;
private config_;
private htmlElement_;
constructor(config: FontsLoaderConfig);
private handleLoading_;
private handleActive_;
private handleInactive_;
private handleFontLoading_;
private handleFontActive_;
private handleFontInactive_;
private addClassToHtml_;
private removeClassFromHtml_;
private sanitizeClassName_;
}
//# sourceMappingURL=EventBus.d.ts.map
1 change: 1 addition & 0 deletions dist/modules/fontLoader/utils/EventBus.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions dist/modules/fontLoader/utils/FontParser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/** Source: https://github.com/typekit/webfontloader/blob/master/src/modules/google/fontapiparser.js */
import type { Font } from '../types';
export declare class FontParser {
private fontFamilies;
private parsedFonts;
private fontTestStrings;
private INT_FONTS;
private WEIGHTS;
private STYLES;
private VARIATION_MATCH;
constructor(fontFamilies: string[]);
parse(): void;
private generateFontVariationDescription;
private normalizeStyle;
private normalizeWeight;
private parseVariations;
parseSubsets<T extends string = string>(subsets: T): T[];
getFonts(): Font[];
getFontTestStrings(): Record<string, string>;
}
//# sourceMappingURL=FontParser.d.ts.map
1 change: 1 addition & 0 deletions dist/modules/fontLoader/utils/FontParser.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions dist/modules/fontLoader/utils/FontWatcher.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Font, LoadingMethod } from '../types';
export declare class FontWatcher {
private font_;
private load_;
constructor(font: Font, load: LoadingMethod);
private loading_;
getFont(): Font;
watch(): boolean;
}
//# sourceMappingURL=FontWatcher.d.ts.map
1 change: 1 addition & 0 deletions dist/modules/fontLoader/utils/FontWatcher.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions dist/modules/fontLoader/utils/Watcher.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Font, LoadingMethod } from '../types';
export declare class Watcher {
private fontWatchers_;
private loadedFonts_;
private watched_;
add(font: Font, load: LoadingMethod): void;
fontLoaded(fontName: string): void;
watchFonts(): void;
}
//# sourceMappingURL=Watcher.d.ts.map
1 change: 1 addition & 0 deletions dist/modules/fontLoader/utils/Watcher.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 909a5cd

Please sign in to comment.