{"version":3,"file":"angularity-theming.mjs","sources":["../../../packages/theming/src/builders/vanilla.ts","../../../packages/theming/src/theme.ts","../../../packages/theming/src/token.ts","../../../packages/theming/src/provide.ts","../../../packages/theming/src/token-build.ts","../../../packages/theming/src/angularity-theming.ts"],"sourcesContent":["import { Injectable } from '@angular/core';\n\nimport { ThemeTokens } from '../token';\nimport { TokenBuilder, TokenBuilderContext } from '../token-builder';\n\nexport interface VanillaBuilderConfig extends ThemeTokens {}\n\n/**\n * An implementation of `TokenBuilder` that simply accepts an object of\n * pre-defined theme tokens as configuration and returns them as is when\n * requested to generate tokens.\n *\n * @remarks\n * The `name` assigned to this builder will be used as the prefix for the\n * tokens. An empty string can be used to avoid prefixing the tokens.\n *\n * @example\n *  ```ts\n *  scheduleTokenBuild(\"tokens-\", VanillaBuilder, {\n *    \"primary-color\": \"#ff0000\",\n *  }),\n *  ```\n *\n * @example\n *  ```ts\n *  scheduleTokenBuild(\"\", VanillaBuilder, {\n *    \"primary-color\": \"#ff0000\",\n *  }),\n *  ```\n */\n@Injectable({ providedIn: 'root' })\nexport class VanillaBuilder implements TokenBuilder<VanillaBuilderConfig> {\n  build(context: TokenBuilderContext<VanillaBuilderConfig>): ThemeTokens {\n    const tokens: ThemeTokens = {};\n    for (const [key, value] of Object.entries(context.config))\n      tokens[`${context.name}${key}`] = value;\n    return tokens;\n  }\n}\n","import { Injector } from '@angular/core';\nimport { combineLatest, map, Observable } from 'rxjs';\n\nimport { ThemeTokens } from './token';\nimport { TokenBuild } from './token-build';\n\n/**\n * Specifications about how a visual theme can be generated.\n */\nexport interface Theme {\n  readonly spec: Observable<TokenBuild[]>;\n}\n\n/**\n * Create a `Theme` object from a list of `TokenBuild` specifications.\n */\nexport function createTheme(...builds: Observable<TokenBuild>[]): Theme {\n  return { spec: combineLatest(builds) };\n}\n\n/**\n * Consume a `Theme` object to generate a set of theme tokens.\n */\nexport function buildTheme(\n  injector: Injector,\n  theme: Theme,\n): Observable<ThemeTokens> {\n  return theme.spec.pipe(\n    map((specs) => {\n      const tokens: ThemeTokens = {};\n      specs.forEach((specs) => {\n        const { name, builder: builderToken, config } = specs;\n        const builder = injector.get(builderToken);\n        const result = builder.build({ name, config });\n        Object.assign(tokens, result);\n      });\n      return tokens;\n    }),\n  );\n}\n","import { isPlatformBrowser, isPlatformServer } from '@angular/common';\nimport {\n  DOCUMENT,\n  inject,\n  Injectable,\n  makeStateKey,\n  PLATFORM_ID,\n  TransferState,\n} from '@angular/core';\nimport { Exception } from '@angularity/core';\n\n/**\n * Name-value pairs that represent the small, repeated design decisions that make\n * up a design system's visual style.\n * @see https://m3.material.io/foundations/design-tokens/overview\n * @see `TokenBuilder`\n */\nexport interface ThemeTokens {\n  [name: string]: string;\n}\n\n/**\n * Registry for active theme tokens in the current application.\n *\n * On server, the tokens will be written to `TransferState`, and\n * can be later reused on browser via the `transfer` method.\n *\n * @remarks\n * By default, uses `InMemoryThemeTokenRegistry`\n * decorated with `WriteTokensToRootCssVariables`.\n */\n@Injectable({\n  providedIn: 'root',\n  useFactory: () => {\n    let instance: ThemeTokenRegistry;\n    instance = new InMemoryThemeTokenRegistry();\n    instance = new WriteTokensToRootCssVariables(instance);\n    return instance;\n  },\n})\nexport abstract class ThemeTokenRegistry {\n  /**\n   * Retrieve the value of a theme token.\n   * @param name the name of the theme token\n   * @returns the value if registered, or `null` if not found\n   */\n  abstract get(name: string): string | null;\n\n  /**\n   * Retrieve all theme tokens.\n   * @returns copy of all theme tokens\n   */\n  abstract getAll(): ThemeTokens;\n\n  /**\n   * Define a new value for a theme token. Duplicate defines overwrite the\n   * previous value.\n   * @param name the name of the theme token\n   * @param value new value for the theme token\n   */\n  abstract set(name: string, value: string | null): void;\n\n  /**\n   * Define all theme tokens, replacing all existing tokens.\n   * @param tokens new theme tokens\n   */\n  abstract setAll(tokens: ThemeTokens): void;\n\n  /**\n   * Transfer theme tokens from `TransferState` to this registry,\n   * if `TransferState` is available and contains theme tokens.\n   * This will clear all existing tokens in this registry.\n   * @returns `true` if tokens are transferred, `false` otherwise\n   */\n  abstract transfer(): boolean;\n}\n\n/**\n * Exception thrown when a theme token is not found in the registry.\n */\nexport class ThemeTokenNotFoundException extends Exception {\n  constructor(name: string) {\n    super(`Theme token ${name} is not defined`);\n  }\n}\n\nconst SERVER_TOKENS = makeStateKey<ThemeTokens>('THEME_TOKENS');\n\n/**\n * Implementation of `ThemeTokenRegistry` that\n * stores theme tokens in memory.\n */\n@Injectable()\nexport class InMemoryThemeTokenRegistry implements ThemeTokenRegistry {\n  #transferState = inject(TransferState, { optional: true });\n\n  #tokens: ThemeTokens = {};\n\n  constructor() {\n    this.#transferState?.onSerialize(SERVER_TOKENS, () => this.getAll());\n  }\n\n  get(name: string): string | null {\n    return this.#tokens[name] ?? null;\n  }\n  getAll(): ThemeTokens {\n    return { ...this.#tokens };\n  }\n  set(name: string, value: string | null): void {\n    if (value === null) delete this.#tokens[name];\n    else this.#tokens[name] = value;\n  }\n  setAll(tokens: ThemeTokens): void {\n    this.#tokens = { ...tokens };\n  }\n  transfer(): boolean {\n    if (!this.#transferState) return false;\n    const serverTokens = this.#transferState.get(SERVER_TOKENS, null);\n    if (!serverTokens) return false;\n    this.setAll(serverTokens);\n    return true;\n  }\n}\n\n/**\n * Decorator of `ThemeTokenRegistry` that\n * writes theme tokens to the root element as CSS variables.\n *\n * - On server, the tokens will be written to\n * the root element's style properties as CSS variables.\n * - On modern browser, the tokens will be written to\n * a constructed `CSSStyleSheet` object adopted by the document.\n * - On legacy browser, the tokens will be written to\n * a `<style>` element appended to the document head.\n */\nexport class WriteTokensToRootCssVariables implements ThemeTokenRegistry {\n  #document = inject(DOCUMENT);\n  #platform = inject(PLATFORM_ID);\n\n  #delegate: ThemeTokenRegistry;\n  #stylesheet?: CSSStyleSheet | HTMLStyleElement;\n\n  constructor(delegate: ThemeTokenRegistry) {\n    this.#delegate = delegate;\n    if (isPlatformBrowser(this.#platform))\n      try {\n        this.#stylesheet = new window.CSSStyleSheet();\n        this.#document.adoptedStyleSheets = [\n          ...(this.#document.adoptedStyleSheets ?? []),\n          this.#stylesheet,\n        ];\n      } catch (error) {\n        if (!(error instanceof TypeError)) throw error;\n        // constructable CSSStyleSheet not supported\n        // fallback to legacy style element\n        this.#stylesheet = this.#document.createElement('style');\n        this.#document.head.append(this.#stylesheet);\n      }\n  }\n\n  get(name: string): string | null {\n    return this.#delegate.get(name);\n  }\n  getAll(): ThemeTokens {\n    return this.#delegate.getAll();\n  }\n  set(name: string, value: string | null): void {\n    this.#delegate.set(name, value);\n    if (isPlatformBrowser(this.#platform)) this.#writeAllToStylesheet();\n    else if (isPlatformServer(this.#platform))\n      this.#writeToInlineStyles(name, value);\n  }\n  setAll(tokens: ThemeTokens): void {\n    this.#delegate.setAll(tokens);\n    if (isPlatformBrowser(this.#platform)) this.#writeAllToStylesheet();\n    else if (isPlatformServer(this.#platform))\n      for (const [name, value] of Object.entries(tokens))\n        this.#writeToInlineStyles(name, value);\n  }\n\n  transfer(): boolean {\n    const transferred = this.#delegate.transfer();\n    if (!transferred) return false;\n    const tokens = this.getAll();\n    // On server, the tokens are written to the root element's style properties,\n    // which should be removed after transfer.\n    for (const tokenName in tokens) this.#writeToInlineStyles(tokenName, null);\n    this.setAll(tokens); // write to stylesheet\n    return true;\n  }\n\n  #writeAllToStylesheet() {\n    if (this.#stylesheet instanceof HTMLElement)\n      this.#stylesheet.innerText = this.#buildCssText();\n    else this.#stylesheet?.replaceSync(this.#buildCssText());\n  }\n  #writeToInlineStyles(name: string, value: string | null) {\n    this.#document.documentElement.style.setProperty(\n      this.#toVarName(name),\n      value ?? '',\n    );\n  }\n\n  #buildCssText() {\n    const tokens = Object.entries(this.#delegate.getAll())\n      .map(([name, value]) => `${this.#toVarName(name)}: ${value};`)\n      .join('\\n');\n    return `:root {\\n${tokens}\\n}`;\n  }\n\n  #toVarName(name: string): string {\n    return `--${name}`;\n  }\n}\n","import {\n  DestroyRef,\n  EnvironmentProviders,\n  inject,\n  Injector,\n  provideAppInitializer,\n  runInInjectionContext,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { filter, firstValueFrom, map, shareReplay, startWith } from 'rxjs';\n\nimport { buildTheme, Theme } from './theme';\nimport { ThemeTokenRegistry } from './token';\n\n/**\n * Make providers that consume the given theme.\n *\n * The application initialization process will be blocked until the\n * the initial theme tokens are available. The initial theme tokens\n * might be the pre-built tokens from the server (SSR environment),\n * or be built from scratch if no server tokens exist.\n *\n * For CSR applications, async theme is discouraged, since it slows\n * down application bootstrap. For SSR applications, using async theme\n * can help reduce the size of the initial bundle as well as accelerate\n * bootstrap, because the theme is pre-built on server and immediately\n * available on browser.\n *\n * @example\n * Theme File:\n *  ```ts\n *  export const appTheme = createTheme(\n *    scheduleTokenBuild(\"typography\", TypographyBuilder, {\n *      font: \"OpenSans\"\n *    }),\n *    scheduleTokenBuild(\n *      'color',\n *      ColorBuilder,\n *      defer((schemeObserver = inject(PreferredColorSchemeObserver)) =>\n *        schemeObserver\n *          .observe()\n *          .pipe(map((isDark) => ({ primaryColor: PRIMARY_COLOR, dark: isDark }))),\n *      ),\n *    ),\n *  )\n *  ```\n *  ```ts\n *  provideTheme(appTheme) // sync\n *  provideTheme(import('./app.theme.ts').then(m => m.appTheme)) // async\n *  ```\n *\n * @see `TokenBuilder`\n * @see `scheduleTokenBuild`\n */\nexport function provideTheme(\n  theme: Theme | Promise<Theme>,\n): EnvironmentProviders {\n  return provideAppInitializer(async () => {\n    const injector = inject(Injector);\n    const destroyRef = inject(DestroyRef);\n    const registry = inject(ThemeTokenRegistry);\n    const transferred = registry.transfer();\n    const build$ = buildTheme(injector, await theme).pipe(\n      takeUntilDestroyed(destroyRef),\n      map((tokens) => {\n        registry.setAll(tokens);\n        return true;\n      }),\n      startWith(transferred),\n      filter(Boolean),\n      shareReplay(1),\n    );\n    runInInjectionContext(injector, () => {\n      build$.subscribe();\n    });\n    return firstValueFrom(build$);\n  });\n}\n","import { ProviderToken } from '@angular/core';\nimport { map, Observable, of } from 'rxjs';\n\nimport { TokenBuilder, TokenBuilderConfigOf } from './token-builder';\n\n/**\n * Represents a token generation specification, which specifies the target `TokenBuilder`\n * and relevant configurations to be passed to the builder.\n * @see `scheduleTokenBuild`\n */\nexport interface TokenBuild {\n  /**\n   * The name that will be passed to the theme builder.\n   */\n  name: string;\n\n  /**\n   * The token that can be used to retrieve the theme builder instance from\n   * the injector.\n   */\n  builder: ProviderToken<TokenBuilder<any>>;\n\n  /**\n   * The configuration object that will be passed to the theme builder.\n   */\n  config: unknown;\n}\n\n/**\n * Creates a token generation specification, which specifies the target `TokenBuilder`\n * and relevant configurations to be passed to the builder.\n * @param name The name that will be passed to the theme builder.\n * @param builder The token that can be used to retrieve the theme builder\n * @param config The configuration object that will be passed to the theme builder.\n * @returns\n *\n * @see `provideTheme`\n *\n * @usageNotes\n *\n * A builder class can be passed to the `builder` parameter because constructor\n * classes are valid tokens for dependency injection. It is worthy noting that\n * you need to make sure that there is a provider for the token. This function\n * does not register providers for the token.\n *\n *  ```ts\n *  provide({ token: ColorBuilder, useClass: MyColorBuilder }),\n *  ```\n *  ```ts\n *  scheduleTokenBuild('color', ColorBuilder, { primaryColor: PRIMARY_COLOR }),\n *  ```\n *\n * An observable can be passed as the `config` parameter, in which case the\n * theme is expected to be updated on every value emission.\n *\n *  ```ts\n *  scheduleTokenBuild(\n *    'color',\n *    ColorBuilder,\n *    observePreferredColorScheme().pipe(\n *      map((isDark) => ({ primaryColor: PRIMARY_COLOR, dark: isDark })),\n *    ),\n *  );\n *  ```\n *\n * In order to gain access to the injection context, use the `defer` RxJS\n * operator, which defers the invocation of the observable factory until\n * the observable is subscribed during the environment initialization, where\n * an injection context is available.\n *\n * ```ts\n * scheduleTokenBuild(\n *   'color',\n *   ColorBuilder,\n *   defer((schemeObserver = inject(PreferredColorSchemeObserver)) =>\n *     schemeObserver\n *       .observe()\n *       .pipe(map((isDark) => ({ primaryColor: PRIMARY_COLOR, dark: isDark }))),\n *   ),\n * );\n * ```\n */\nexport function scheduleTokenBuild<Builder extends TokenBuilder<any>>(\n  name: string,\n  builder: ProviderToken<Builder>,\n  config:\n    | TokenBuilderConfigOf<Builder>\n    | Observable<TokenBuilderConfigOf<Builder>>,\n): Observable<TokenBuild> {\n  const config$ = config instanceof Observable ? config : of(config);\n  return config$.pipe(map((config) => ({ name, builder, config })));\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAOA;;;;;;;;;;;;;;;;;;;;;;AAsBG;MAEU,cAAc,CAAA;AACzB,IAAA,KAAK,CAAC,OAAkD,EAAA;QACtD,MAAM,MAAM,GAAgB,EAAE;AAC9B,QAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC;YACvD,MAAM,CAAC,CAAA,EAAG,OAAO,CAAC,IAAI,CAAA,EAAG,GAAG,CAAA,CAAE,CAAC,GAAG,KAAK;AACzC,QAAA,OAAO,MAAM;IACf;8GANW,cAAc,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAd,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,cAAc,cADD,MAAM,EAAA,CAAA,CAAA;;2FACnB,cAAc,EAAA,UAAA,EAAA,CAAA;kBAD1B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACjBlC;;AAEG;AACG,SAAU,WAAW,CAAC,GAAG,MAAgC,EAAA;IAC7D,OAAO,EAAE,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE;AACxC;AAEA;;AAEG;AACG,SAAU,UAAU,CACxB,QAAkB,EAClB,KAAY,EAAA;IAEZ,OA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