Skip to content

Commit

Permalink
Shadow DOM: prune bundle size impact (#30709)
Browse files Browse the repository at this point in the history
Co-authored-by: KHMakoto <Humberto.Morimoto@microsoft.com>
  • Loading branch information
spmonahan and khmakoto authored Mar 22, 2024
1 parent 7386d73 commit 83888be
Show file tree
Hide file tree
Showing 39 changed files with 1,084 additions and 854 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.bundlesize.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pr:
- master
- shadow-dom
- shadow-dom # temporary to get preliminary results

trigger:
- master
Expand Down
58 changes: 38 additions & 20 deletions packages/merge-styles/etc/merge-styles.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
```ts

// @public (undocumented)
export type AddSheetCallback = ({ key, sheet }: {
key: string;
sheet: ExtendedCSSStyleSheet;
}) => void;

// @public (undocumented)
export const cloneCSSStyleSheet: (srcSheet: CSSStyleSheet, targetSheet: CSSStyleSheet) => CSSStyleSheet;

Expand Down Expand Up @@ -36,10 +42,8 @@ export type DeepPartial<T> = {
[P in keyof T]?: T[P] extends (infer U)[] ? DeepPartial<U>[] : T[P] extends object ? DeepPartial<T[P]> : T[P];
};

// Warning: (ae-forgotten-export) The symbol "EventArgs" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export type EventHandler<T> = (args: EventArgs<T>) => void;
export const DEFAULT_SHADOW_CONFIG: ShadowConfig;

// @public (undocumented)
export type ExtendedCSSStyleSheet = CSSStyleSheet & {
Expand Down Expand Up @@ -99,6 +103,11 @@ export const InjectionMode: {
// @public (undocumented)
export type InjectionMode = (typeof InjectionMode)[keyof typeof InjectionMode];

// Warning: (ae-forgotten-export) The symbol "InsertRuleArgs" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export type InsertRuleCallback = ({ key, sheet, rule }: InsertRuleArgs) => void;

// @public
export type IProcessedStyleSet<TStyleSet extends IStyleSet<TStyleSet>> = {
[P in keyof Omit_2<TStyleSet, 'subComponentStyles'>]: string;
Expand Down Expand Up @@ -424,7 +433,7 @@ export interface ISerializedStylesheet {
// (undocumented)
classNameToArgs: Stylesheet['_classNameToArgs'];
// (undocumented)
counter: Stylesheet['_styleCounter'];
counter: Stylesheet['_counter'];
// (undocumented)
keyToClassName: Stylesheet['_keyToClassName'];
// (undocumented)
Expand Down Expand Up @@ -559,40 +568,49 @@ export type ShadowConfig = {
__isShadowConfig__: true;
};

// @public (undocumented)
export class ShadowDomStylesheet extends Stylesheet {
constructor(config?: IStyleSheetConfig, serializedStylesheet?: ISerializedStylesheet);
// (undocumented)
protected _createStyleElement(): HTMLStyleElement;
// (undocumented)
getAdoptedSheets(): Map<string, ExtendedCSSStyleSheet>;
// (undocumented)
protected _getCacheKey(key: string): string;
// (undocumented)
static getInstance(shadowConfig?: ShadowConfig): ShadowDomStylesheet;
// (undocumented)
insertRule(rule: string, preserve?: boolean): void;
// (undocumented)
onAddSheet(callback: AddSheetCallback): Function;
}

// @public
export class Stylesheet {
constructor(config?: IStyleSheetConfig, serializedStylesheet?: ISerializedStylesheet);
// (undocumented)
addAdoptableStyleSheet(key: string, sheet: ExtendedCSSStyleSheet): void;
argsFromClassName(className: string): IStyle[] | undefined;
cacheClassName(className: string, key: string, args: IStyle[], rules: string[]): void;
classNameFromKey(key: string): string | undefined;
// (undocumented)
forEachAdoptedStyleSheet(callback: (value: ExtendedCSSStyleSheet, key: string, map: Map<string, ExtendedCSSStyleSheet>) => void): void;
protected _config: IStyleSheetConfig;
// (undocumented)
getAdoptableStyleSheet(key: string): ExtendedCSSStyleSheet;
protected _createStyleElement(): HTMLStyleElement;
// (undocumented)
protected _getCacheKey(key: string): string;
getClassName(displayName?: string): string;
getClassNameCache(): {
[key: string]: string;
};
static getInstance(shadowConfig?: ShadowConfig): Stylesheet;
getRules(includePreservedRules?: boolean): string;
insertedRulesFromClassName(className: string): string[] | undefined;
insertRule(rule: string, preserve?: boolean): void;
// (undocumented)
makeCSSStyleSheet(win: Window): ExtendedCSSStyleSheet;
insertRule(rule: string, preserve?: boolean, stylesheetKey?: string): void;
// (undocumented)
offAddConstructableStyleSheet(callback: EventHandler<ExtendedCSSStyleSheet>): void;
protected _insertRuleIntoSheet(sheet: CSSStyleSheet | undefined | null, rule: string): boolean;
// (undocumented)
offInsertRuleIntoConstructableStyleSheet(callback: EventHandler<ExtendedCSSStyleSheet>): void;
// (undocumented)
onAddConstructableStyleSheet(callback: EventHandler<ExtendedCSSStyleSheet>): void;
onInsertRule(callback: Function): Function;
// (undocumented)
onInsertRuleIntoConstructableStyleSheet(callback: EventHandler<ExtendedCSSStyleSheet>): void;
protected _lastStyleElement?: HTMLStyleElement;
onInsertRule(callback: Function | InsertRuleCallback): Function;
onReset(callback: Function): Function;
// (undocumented)
projectStylesToWindow(targetWindow: Window): void;
reset(): void;
// (undocumented)
resetKeys(): void;
Expand Down
60 changes: 0 additions & 60 deletions packages/merge-styles/src/EventMap.ts

This file was deleted.

Loading

0 comments on commit 83888be

Please sign in to comment.