{"version":3,"file":"angular-kit-rx-observe.mjs","sources":["../../../../libs/rx-observe/src/lib/rx-observe-directive-config.ts","../../../../libs/rx-observe/src/lib/types/render-strategies.ts","../../../../libs/rx-observe/src/lib/util/coerce-observable.ts","../../../../libs/rx-observe/src/lib/util/setup-operator.ts","../../../../libs/rx-observe/src/lib/util/create-intersection-observer.ts","../../../../libs/rx-observe/src/lib/util/supports-intersection-observer.ts","../../../../libs/rx-observe/src/lib/rx-observe.directive.ts","../../../../libs/rx-observe/src/angular-kit-rx-observe.ts"],"sourcesContent":["import { inject, InjectionToken, Provider, Type } from '@angular/core';\nimport { ObserveDirectiveContext } from './types/observe-directive-context';\nimport { RenderStrategies } from './types/render-strategies';\n\nexport interface RxObserveDirectiveConfig {\n  loadingComponent?: Type<any>;\n  errorComponent?: Type<any>;\n  completeComponent?: Type<any>;\n  keepValueOnLoading?: boolean;\n  lazyViewCreation?: boolean;\n  renderStrategy?: RenderStrategies;\n}\n\nexport const RX_OBSERVE_DIRECTIVE_CONFIG =\n  new InjectionToken<RxObserveDirectiveConfig>('RX_OBSERVE_DIRECTIVE_CONFIG');\n\n// todo fix any\nexport const RX_OBSERVE_DIRECTIVE_CONTEXT = new InjectionToken<\n  ObserveDirectiveContext<any>\n>('OBSERVE_DIRECTIVE_CONTEXT');\n\nexport function provideRxObserveDirectiveConfig(\n  config: RxObserveDirectiveConfig\n): Provider {\n  return { provide: RX_OBSERVE_DIRECTIVE_CONFIG, useValue: config };\n}\n\nexport function provideRxObserveDirectiveContext<T>(\n  context: ObserveDirectiveContext<T>\n): Provider {\n  return { provide: RX_OBSERVE_DIRECTIVE_CONTEXT, useValue: context };\n}\n\nexport function injectStreamDirectiveConfig(): RxObserveDirectiveConfig | null {\n  return inject(RX_OBSERVE_DIRECTIVE_CONFIG, { optional: true });\n}\n\nexport function injectStreamDirectiveContext<T>(): ObserveDirectiveContext<T> {\n  return inject(RX_OBSERVE_DIRECTIVE_CONTEXT);\n}\n","\nexport interface RenderStrategy {\n  type: 'default' | 'viewport' | 'throttle' | 'debounce';\n}\n\n/**\n * @publicApi\n *\n * @description\n * Default render strategy\n */\nexport interface DefaultRenderStategy extends RenderStrategy {\n  type: 'default';\n}\n\n/**\n * @publicApi\n *\n * @description\n * Viewport render strategy which configures to trigger change detection\n * only when the element is in the viewport.\n */\nexport interface ViewportRenderStrategy extends RenderStrategy {\n  type: 'viewport';\n  root?: HTMLElement\n  rootMargin?: string;\n  threshold?: number | number[];\n}\n\n/**\n * @publicApi\n *\n * @description\n * Throttle render strategy which will throttle down trigger change detection.\n *\n */\nexport interface ThrottleRenderStrategy extends RenderStrategy {\n  type: 'throttle';\n  throttleInMs: number;\n}\n\n/**\n * @publicApi\n *\n * @description\n * Debounce render strategy which will debounce to trigger change detection.\n */\nexport interface DebounceRenderStrategy extends RenderStrategy {\n  type: 'debounce';\n  debounceInMs: number;\n}\n\nexport type RenderStrategies = DefaultRenderStategy | ViewportRenderStrategy | ThrottleRenderStrategy | DebounceRenderStrategy;\n\n/**\n * @description\n * Checks if the strategy is a {@link DefaultRenderStategy}.\n * @param strategy\n */\nexport function isDefaultRenderStrategy(strategy: RenderStrategy): strategy is DefaultRenderStategy {\n  return strategy.type === 'default';\n}\n\n/**\n * @description\n * Checks if the strategy is a {@link ViewportRenderStrategy}.\n * @param strategy\n */\nexport function isViewportRenderStrategy(strategy: RenderStrategy): strategy is ViewportRenderStrategy {\n  return strategy.type === 'viewport';\n}\n\n/**\n * @description\n * Checks if the strategy is a {@link ThrottleRenderStrategy}.\n * @param strategy\n */\nexport function isThrottleRenderStrategy(strategy: RenderStrategy): strategy is ThrottleRenderStrategy {\n  return strategy.type === 'throttle';\n}\n\n/**\n * @description\n * Checks if the strategy is a {@link DebounceRenderStrategy}.\n * @param strategy\n */\nexport function isDebounceRenderStrategy(strategy: RenderStrategy): strategy is DebounceRenderStrategy {\n  return strategy.type === 'debounce';\n}\n","import { isObservable, Observable, of } from 'rxjs';\n\n/**\n * Coerces a value to an observable.\n */\nexport function coerceObservable<T = unknown>(potentialObservable: T | Observable<T>): Observable<T> {\n  return isObservable(potentialObservable) ? potentialObservable : of(potentialObservable);\n}\n","import {debounceTime, distinctUntilChanged, filter, map, mergeAll, throttleTime,} from 'rxjs/operators';\nimport { Observable, of, pipe } from 'rxjs';\nimport {\n    isDebounceRenderStrategy,\n    isThrottleRenderStrategy,\n    isViewportRenderStrategy,\n    RenderStrategies,\n} from '../types/render-strategies';\n\n/**\n * @internal\n * @description\n * Derive the operator for the render strategy.\n */\nexport function setupOperator$(renderStrategy$$: Observable<RenderStrategies>) {\n    return renderStrategy$$.pipe(\n        distinctUntilChanged(),\n        filter((strategy) => !isViewportRenderStrategy(strategy)),\n        map((strategy) => {\n            if (isThrottleRenderStrategy(strategy)) {\n                return of(throttleTime(strategy.throttleInMs));\n            }\n\n            if (isDebounceRenderStrategy(strategy)) {\n                return of(debounceTime(strategy.debounceInMs));\n            }\n\n            return of(pipe());\n        }),\n        mergeAll()\n    );\n}\n","import { debounceTime, share } from 'rxjs/operators';\nimport { Observable, ReplaySubject, SchedulerLike } from 'rxjs';\nimport { ElementRef } from '@angular/core';\n\nexport function isElementRef(value: unknown): value is ElementRef {\n  return value instanceof ElementRef;\n}\nconst DEFAULT_THROTTLE_TIME = 50;\n\nexport function supportsIntersectionObserver() {\n  return typeof window.IntersectionObserver !== 'undefined';\n}\n\nexport type IntersectionObserverConfig = {\n  /**throttle emissions, defaults to 50*/\n  throttleMs?: number;\n  /** scheduler to use for throttling */\n  scheduler?: SchedulerLike;\n};\n\nexport function createIntersectionObserver(\n  observeElement: ElementRef | Element,\n  options?: IntersectionObserverInit,\n  cfg?: IntersectionObserverConfig\n): Observable<IntersectionObserverEntry[]> {\n  if (!supportsIntersectionObserver()) {\n    throw new Error(\n      '[AngularKit] IntersectionObserver is not supported in this browser'\n    );\n  }\n  const obs$ = new Observable<IntersectionObserverEntry[]>((subscriber) => {\n    const intersectionObserver = new IntersectionObserver((entries) => {\n      subscriber.next(entries);\n    }, options ?? {});\n\n    intersectionObserver.observe(\n      isElementRef(observeElement)\n        ? observeElement.nativeElement\n        : observeElement\n    );\n\n    return () => intersectionObserver.disconnect();\n  });\n\n  return obs$.pipe(\n    cfg?.throttleMs\n      ? debounceTime(cfg?.throttleMs, cfg?.scheduler)\n      : debounceTime(DEFAULT_THROTTLE_TIME),\n    share({\n      connector: () => new ReplaySubject(1),\n      resetOnRefCountZero: true,\n    })\n  );\n}\n","/**\n * @internal\n * Checks if the browser supports IntersectionObserver.\n */\nexport function supportsIntersectionObserver() {\n  return typeof window.IntersectionObserver !== 'undefined';\n}\n","import {\n  Directive,\n  EmbeddedViewRef,\n  inject,\n  Injector,\n  Input,\n  OnDestroy,\n  OnInit,\n  TemplateRef,\n  ViewContainerRef,\n} from '@angular/core';\nimport {BehaviorSubject, Observable, of, ReplaySubject, Subject, Subscription, switchAll,} from 'rxjs';\nimport {\n  combineLatestWith,\n  distinctUntilChanged,\n  filter,\n  map,\n  startWith,\n  switchMap,\n  withLatestFrom,\n} from 'rxjs/operators';\nimport {\n  injectStreamDirectiveConfig,\n  RX_OBSERVE_DIRECTIVE_CONTEXT,\n  RxObserveDirectiveConfig,\n} from './rx-observe-directive-config';\nimport {isViewportRenderStrategy, RenderStrategies,} from './types/render-strategies';\nimport {coerceObservable} from './util/coerce-observable';\nimport {RenderContext} from './types/render-context';\nimport {ObserveDirectiveContext} from './types/observe-directive-context';\nimport {setupOperator$} from './util/setup-operator';\nimport {createIntersectionObserver} from './util/create-intersection-observer';\nimport {supportsIntersectionObserver} from './util/supports-intersection-observer';\n\n@Directive({\n  selector: '[rxObserve]',\n  standalone: true,\n})\nexport class RxObserveDirective<T> implements OnInit, OnDestroy {\n  private readonly config: RxObserveDirectiveConfig | null =\n    injectStreamDirectiveConfig();\n  private readonly templateRef: TemplateRef<ObserveDirectiveContext<T>> =\n    inject(TemplateRef<ObserveDirectiveContext<T>>);\n  private readonly viewContainerRef: ViewContainerRef =\n    inject(ViewContainerRef);\n\n  private source$$ = new ReplaySubject<Observable<T | null>>(1);\n  private refreshEffect$$ = new ReplaySubject<Subject<any>>(1);\n  private loadingTemplate$$ = new ReplaySubject<\n    TemplateRef<ObserveDirectiveContext<T>>\n  >(1);\n  private renderCallback$$: ReplaySubject<RenderContext<T>> | undefined;\n  private renderStrategy$$ = new BehaviorSubject<Observable<RenderStrategies>>(\n    of(this.config?.renderStrategy ?? { type: 'default' })\n  );\n\n  private detach = true;\n\n  /**\n   * @description\n   * The source of the values to be rendered.\n   * @param source\n   */\n  @Input() set rxObserve(source: Observable<T | null>) {\n    if (source) {\n      this.source$$.next(source);\n    }\n  }\n\n  /**\n   * @description\n   * A trigger to refresh the value stream.\n   * @param refreshEffect\n   */\n  @Input() set rxObserveRefreshSignal(refreshEffect: Subject<any>) {\n    if (refreshEffect) {\n      this.refreshEffect$$.next(refreshEffect);\n    }\n  }\n\n  /**\n   * @description\n   * A template to be rendered while the stream is in a loading state.\n   * @param tpl\n   */\n  @Input() set rxObserveLoadingTemplate(\n    tpl: TemplateRef<ObserveDirectiveContext<T>>\n  ) {\n    if (tpl) {\n      this.loadingTemplate$$.next(tpl);\n    }\n  }\n\n  /**\n   * @description\n   * A template to be rendered when the value source emits an error.\n   */\n  @Input() rxObserveErrorTemplate:\n    | TemplateRef<ObserveDirectiveContext<T>>\n    | undefined;\n  /**\n   * @description\n   * A template to be rendered when the value source completes.\n   */\n  @Input() rxObserveCompleteTemplate:\n    | TemplateRef<ObserveDirectiveContext<T>>\n    | undefined;\n\n  /**\n   * @description\n   * A trigger which emits every time the view is rendered/updated.\n   * @param cb\n   */\n  @Input() set rxObserveRenderCallback(cb: ReplaySubject<RenderContext<T>>) {\n    if (cb) {\n      this.renderCallback$$ = cb;\n    }\n  }\n\n  /**\n   * @description\n   * A render strategy to optimize change detection.\n   *\n   * Default: {@link DefaultRenderStrategy}\n   * @param strategy\n   */\n  @Input() set rxObserveRenderStrategy(\n    strategy: RenderStrategies | Observable<RenderStrategies>\n  ) {\n    if (strategy) {\n      this.renderStrategy$$.next(coerceObservable(strategy));\n    }\n  }\n\n  /**\n   * @description\n   * A flag to control whether the last value should still be displayed in the view when the value source\n   * is in a loading state or not.\n   *\n   * Default: false\n   */\n  @Input() rxObserveKeepValueOnLoading =\n    this.config?.keepValueOnLoading ?? false;\n  /**\n   * @description\n   * A flag to control if the view should be created lazily or not.\n   * Lazy does mean that no change detection will be triggered until the value source emits a value.\n   *\n   * Default: false\n   */\n  @Input() rxObserveLazyViewCreation = this.config?.lazyViewCreation ?? false;\n\n  private subscription = new Subscription();\n  private embeddedView!: EmbeddedViewRef<ObserveDirectiveContext<T>>;\n\n  private context: ObserveDirectiveContext<T> = {\n    $implicit: {} as T,\n    observe: {} as T,\n    error: undefined,\n    completed: false,\n    loading: false,\n    renderCount: 0,\n  };\n\n  readonly renderStrategy$ = this.renderStrategy$$\n    .asObservable()\n    .pipe(distinctUntilChanged(), switchAll(), distinctUntilChanged());\n  readonly isViewPortStrategy$ = this.renderStrategy$.pipe(\n    map((strategy) => strategy.type === 'viewport')\n  );\n  readonly renderStrategyOperator$ = setupOperator$(this.renderStrategy$);\n  readonly source$ = this.source$$.pipe(distinctUntilChanged());\n\n  /**\n   * todo\n   * when viewport strategy is used and before throttle or debounce was applied, they\n   * are somehow combined.\n   *\n   * when switching to/from viewPort strategy emit a signal and end respective observables\n   */\n  viewPortObserver$: Observable<IntersectionObserverEntry[] | null> =\n    this.renderStrategy$.pipe(\n      switchMap((strategy) => {\n        if (isViewportRenderStrategy(strategy)) {\n          if (!supportsIntersectionObserver()) {\n            return of(null);\n          }\n          return createIntersectionObserver(\n            this.viewContainerRef.element.nativeElement.parentElement,\n            {\n              threshold: strategy.threshold,\n              rootMargin: strategy.rootMargin,\n              root: strategy.root,\n            }\n          );\n          /*     .pipe(\n            takeUntil(this.renderStrategy$$.pipe(skip(1)))\n          )*/\n        }\n\n        return of(null);\n      })\n    );\n  visible$ = this.viewPortObserver$.pipe(\n    map((entries) => entries?.some((entry) => entry.isIntersecting))\n  );\n\n  readonly sourceWithOperator$ = this.renderStrategyOperator$.pipe(\n    withLatestFrom(this.source$),\n    /**\n     * unsubscribe from previous source and subscribe to new source\n     * apply operator from renderStrategy.\n     *\n     * when unsubscribe from previous source, the last value will be lost.\n     * We can fix this by providing context also via observable and\n     * withLatestFrom it here.\n     */\n    switchMap(([o, source$]) => {\n      return source$.pipe(\n        //@ts-ignore\n        o\n        //takeUntil(this.renderStrategy$$.pipe(skip(1)))\n      );\n    })\n  );\n  static ngTemplateGuard_rxObserve: 'binding';\n  static ngTemplateContextGuard<T>(\n    directive: RxObserveDirective<T>,\n    context: unknown\n  ): context is ObserveDirectiveContext<T> {\n    return true;\n  }\n\n  ngOnInit(): void {\n    if (!this.embeddedView) {\n      this.createEmbeddedView();\n    }\n\n    // todo refactor into smaller chunks\n    this.subscription.add(\n      this.refreshEffect$$\n        .pipe(\n          distinctUntilChanged(),\n          switchAll(),\n          withLatestFrom(this.loadingTemplate$$.pipe(startWith(null)))\n        )\n        .subscribe(([_, loadingTemplate]) => {\n          this.context.loading = true;\n          if (!this.rxObserveKeepValueOnLoading) {\n            this.viewContainerRef.clear();\n          }\n\n          if (this.config?.loadingComponent) {\n            this.viewContainerRef.createComponent(\n              this.config.loadingComponent,\n              {\n                injector: this.createInjector(),\n              }\n            );\n          } else {\n            this.embeddedView = this.viewContainerRef.createEmbeddedView(\n              loadingTemplate || this.templateRef,\n              this.context\n            );\n          }\n\n          this.embeddedView.detectChanges();\n          this.renderCallback$$?.next({\n            renderCycle: 'before-next',\n            value: this.context.$implicit,\n            error: this.context.error,\n          });\n        })\n    );\n\n    // todo refactor into smaller chunks\n    this.subscription.add(this.sourceWithOperator$\n      .pipe(\n        distinctUntilChanged(),\n        filter((v) => v !== undefined),\n        combineLatestWith(this.visible$)\n      )\n      .subscribe({\n        next: (val) => {\n          const v = val[0] as T;\n          const visible = val[1] ?? true;\n          /**\n           * only update the view if the value has changed and the view is visible\n           */\n          if (visible && v !== this.context.$implicit) {\n            if (v) {\n              this.context.$implicit = v;\n              this.context.observe = v;\n            }\n\n            this.context.loading = false;\n            this.context.renderCount++;\n\n            this.viewContainerRef.clear();\n            this.embeddedView = this.viewContainerRef.createEmbeddedView(\n              this.templateRef,\n              this.context\n            );\n\n            this.embeddedView.detectChanges();\n            this.renderCallback$$?.next({\n              renderCycle: 'next',\n              value: this.context.$implicit,\n              error: this.context.error,\n            });\n          }\n        },\n        error: (err) => {\n          this.context.error = err;\n          this.viewContainerRef.clear();\n          if (this.config?.errorComponent) {\n            this.viewContainerRef.createComponent(this.config.errorComponent, {\n              injector: this.createInjector(),\n            });\n          } else {\n            this.embeddedView = this.viewContainerRef.createEmbeddedView(\n              this.rxObserveErrorTemplate || this.templateRef,\n              this.context\n            );\n          }\n\n          this.embeddedView.detectChanges();\n          this.renderCallback$$?.next({\n            renderCycle: 'error',\n            value: this.context.$implicit,\n            error: this.context.error,\n          });\n        },\n        complete: () => {\n          this.context.completed = true;\n          this.viewContainerRef.clear();\n          if (this.config?.completeComponent) {\n            this.viewContainerRef.createComponent(\n              this.config.completeComponent,\n              {\n                injector: this.createInjector(),\n              }\n            );\n          } else {\n            this.embeddedView = this.viewContainerRef.createEmbeddedView(\n              this.rxObserveCompleteTemplate || this.templateRef,\n              this.context\n            );\n          }\n\n          this.embeddedView.detectChanges();\n          this.renderCallback$$?.next({\n            renderCycle: 'complete',\n            value: this.context.$implicit,\n            error: this.context.error,\n          });\n        },\n      }));\n  }\n\n  private createInjector() {\n    return Injector.create({\n      providers: [\n        {\n          provide: RX_OBSERVE_DIRECTIVE_CONTEXT,\n          useValue: this.context,\n        },\n      ],\n    });\n  }\n\n  ngOnDestroy(): void {\n    this.viewContainerRef.clear();\n    if (this.embeddedView) {\n      this.embeddedView.destroy();\n    }\n    this.subscription.unsubscribe();\n  }\n\n  private createEmbeddedView(): void {\n    this.embeddedView = this.viewContainerRef.createEmbeddedView(\n      this.templateRef,\n      this.context\n    );\n    if (!this.rxObserveLazyViewCreation) {\n      this.embeddedView.detectChanges();\n    }\n    if (this.detach) {\n      this.embeddedView.detach();\n    }\n  }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["supportsIntersectionObserver"],"mappings":";;;;;MAaa,2BAA2B,GACtC,IAAI,cAAc,CAA2B,6BAA6B,EAAE;AAE9E;MACa,4BAA4B,GAAG,IAAI,cAAc,CAE5D,2BAA2B,EAAE;AAEzB,SAAU,+BAA+B,CAC7C,MAAgC,EAAA;IAEhC,OAAO,EAAE,OAAO,EAAE,2BAA2B,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AACpE,CAAC;AAEK,SAAU,gCAAgC,CAC9C,OAAmC,EAAA;IAEnC,OAAO,EAAE,OAAO,EAAE,4BAA4B,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AACtE,CAAC;SAEe,2BAA2B,GAAA;IACzC,OAAO,MAAM,CAAC,2BAA2B,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AACjE,CAAC;SAEe,4BAA4B,GAAA;AAC1C,IAAA,OAAO,MAAM,CAAC,4BAA4B,CAAC,CAAC;AAC9C;;ACeA;;;;AAIG;AACG,SAAU,uBAAuB,CAAC,QAAwB,EAAA;AAC9D,IAAA,OAAO,QAAQ,CAAC,IAAI,KAAK,SAAS,CAAC;AACrC,CAAC;AAED;;;;AAIG;AACG,SAAU,wBAAwB,CAAC,QAAwB,EAAA;AAC/D,IAAA,OAAO,QAAQ,CAAC,IAAI,KAAK,UAAU,CAAC;AACtC,CAAC;AAED;;;;AAIG;AACG,SAAU,wBAAwB,CAAC,QAAwB,EAAA;AAC/D,IAAA,OAAO,QAAQ,CAAC,IAAI,KAAK,UAAU,CAAC;AACtC,CAAC;AAED;;;;AAIG;AACG,SAAU,wBAAwB,CAAC,QAAwB,EAAA;AAC/D,IAAA,OAAO,QAAQ,CAAC,IAAI,KAAK,UAAU,CAAC;AACtC;;ACtFA;;AAEG;AACG,SAAU,gB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