@edynamix/mf-isolation 0.0.32 → 0.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/angular.d.ts.map +1 -1
- package/dist/angular.js +10 -8
- package/dist/angular.js.map +1 -1
- package/dist/hosted-module-styles.d.ts +4 -2
- package/dist/hosted-module-styles.d.ts.map +1 -1
- package/dist/hosted-module-styles.js +89 -5
- package/dist/hosted-module-styles.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,7 +50,8 @@ At runtime, `provideMfOverlayRoot()` and `provideMfOverlayRootFromToken()` start
|
|
|
50
50
|
A host calls `adaptHostedModuleStyles(shadowRoot)` from `@edynamix/mf-isolation` on each module shadow root it creates, and the function it returns on unmount. It adapts what a module brings into that root at runtime, with no module rebuild:
|
|
51
51
|
|
|
52
52
|
- rem follows the module's own root font size, as `followModuleRootFontSize()` does above;
|
|
53
|
-
- rules a library injects at runtime for the document root never match inside a shadow root (Angular Material's `html { --mat-focus-indicator-display: block; }` left keyboard focus rings off), so they move onto the shadow host, as the PostCSS plugins do at build time: `html`, `body`, `:root` and `html body` become `:host`, and `html .x`, `body > .x` or `:root .x` become `:host .x` and `:host > .x`. A root with conditions of its own (`html.dark`, `body#app`, `:root[dir=rtl]`) is left alone, as is any rule that already names `:host` or `data-edyn-mf`. `rescopeDocumentRootSelectors(selectorText)` is the pure selector step and also reports how many qualified roots it left
|
|
53
|
+
- rules a library injects at runtime for the document root never match inside a shadow root (Angular Material's `html { --mat-focus-indicator-display: block; }` left keyboard focus rings off), so they move onto the shadow host, as the PostCSS plugins do at build time: `html`, `body`, `:root` and `html body` become `:host`, and `html .x`, `body > .x` or `:root .x` become `:host .x` and `:host > .x`. A root with conditions of its own (`html.dark`, `body#app`, `:root[dir=rtl]`) is left alone, as is any rule that already names `:host` or `data-edyn-mf`. `rescopeDocumentRootSelectors(selectorText)` is the pure selector step and also reports how many qualified roots it left;
|
|
54
|
+
- sticky headers written for the legacy navigation's top bar stick to the top of the host's content area: old pages scrolled under that 49px bar, so a sticky `top` of 49px or more (`top: 49px`, `top: 50px`) moves up by 49px, in stylesheet rules and in inline styles a module sets from code (the position-sticky directives' `position: sticky; top: 50px`), with its priority kept and once per value the module writes (0.0.34 or later). Smaller tops (`0`, `1px`, for pages and panels that already scrolled below the bar), `var()`, `%` and `calc()` values, and non-sticky rules are left alone.
|
|
54
55
|
|
|
55
56
|
It is safe beside a module's own `followModuleRootFontSize()` on the same root (0.0.31 or later): stylesheet changes go through the CSSOM, which no mutation observer sees, every step is idempotent, and an inline style already followed never looks like work again, so neither side acts on the other's writes.
|
|
56
57
|
|
package/dist/angular.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular.d.ts","sourceRoot":"","sources":["../src/angular.ts"],"names":[],"mappings":"AAUA,OAAO,EAAuC,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AA6T7G,eAAO,MAAM,oBAAoB,GAAI,cAAc,WAAW,KAAG,cAAc,EAwB9E,CAAC;AAEF,eAAO,MAAM,6BAA6B,GAAI,kBAAkB,aAAa,CAAC,WAAW,CAAC,KAAG,cAAc,EAE1G,CAAC;AAEF,OAAO,EAAE,uCAAuC,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["import {\n FlexibleConnectedPositionStrategy,\n type FlexibleConnectedPositionStrategyOrigin,\n GlobalPositionStrategy,\n OverlayContainer,\n OverlayPositionBuilder,\n} from '@angular/cdk/overlay';\nimport { Platform } from '@angular/cdk/platform';\nimport { ViewportRuler } from '@angular/cdk/scrolling';\nimport { DOCUMENT } from '@angular/common';\nimport { DestroyRef, ENVIRONMENT_INITIALIZER, type ProviderToken, type StaticProvider } from '@angular/core';\nimport { followModuleRootFontSize } from './hosted-module-styles.js';\n\n// Mirrors the CDK 19 overlay-prebuilt.css structural rules while intentionally excluding document-level scroll blocking.\nconst CDK_OVERLAY_STRUCTURAL_CSS = `\n.cdk-overlay-container,.cdk-global-overlay-wrapper{pointer-events:none;top:0;left:0;height:100%;width:100%}\n.cdk-overlay-container{position:fixed;z-index:1000}\n.cdk-overlay-container:empty{display:none}\n.cdk-global-overlay-wrapper{display:flex;position:absolute;z-index:1000}\n.cdk-overlay-pane{position:absolute;pointer-events:auto;box-sizing:border-box;display:flex;max-width:100%;max-height:100%;z-index:1000}\n.cdk-overlay-backdrop{position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:auto;-webkit-tap-highlight-color:rgba(0,0,0,0);opacity:0;touch-action:manipulation;z-index:1000;transition:opacity 400ms cubic-bezier(0.25,0.8,0.25,1)}\n@media(prefers-reduced-motion){.cdk-overlay-backdrop{transition-duration:1ms}}\n.cdk-overlay-backdrop-showing{opacity:1}\n@media(forced-colors:active){.cdk-overlay-backdrop-showing{opacity:.6}}\n.cdk-overlay-dark-backdrop{background:rgba(0,0,0,.32)}\n.cdk-overlay-transparent-backdrop{transition:visibility 1ms linear,opacity 1ms linear;visibility:hidden;opacity:1}\n.cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing,.cdk-high-contrast-active .cdk-overlay-transparent-backdrop{opacity:0;visibility:visible}\n.cdk-overlay-backdrop-noop-animation{transition:none}\n.cdk-overlay-connected-position-bounding-box{position:absolute;display:flex;flex-direction:column;min-width:1px;min-height:1px;z-index:1000}\n`;\n\ninterface IClientRect {\n bottom: number;\n height: number;\n left: number;\n right: number;\n top: number;\n width: number;\n x?: number;\n y?: number;\n}\n\ninterface IFlexibleConnectedPositionStrategyInternals {\n _getOriginPoint: (originRect: IClientRect, containerRect: IClientRect, position: unknown) => { x: number; y: number };\n _getOriginRect: () => IClientRect;\n}\n\nconst translateRectToBoundary = (rect: IClientRect, boundary: IClientRect): IClientRect => {\n const left = rect.left - boundary.left;\n const top = rect.top - boundary.top;\n\n return {\n bottom: top + rect.height,\n height: rect.height,\n left,\n right: left + rect.width,\n top,\n width: rect.width,\n x: left,\n y: top,\n };\n};\n\nconst getBoundaryRect = (overlayRoot: HTMLElement): IClientRect => {\n const { height, width } = overlayRoot.getBoundingClientRect();\n return {\n bottom: height,\n height,\n left: 0,\n right: width,\n top: 0,\n width,\n x: 0,\n y: 0,\n };\n};\n\nconst createBoundaryDocument = (document: Document, overlayRoot: HTMLElement): Document => {\n const boundaryDocumentElement = new Proxy(document.documentElement, {\n get: (target, property, receiver) => {\n if (property === 'clientHeight') {\n return overlayRoot.getBoundingClientRect().height;\n }\n if (property === 'clientWidth') {\n return overlayRoot.getBoundingClientRect().width;\n }\n return Reflect.get(target, property, receiver);\n },\n });\n\n return new Proxy(document, {\n get: (target, property, receiver) => {\n if (property === 'documentElement') {\n return boundaryDocumentElement;\n }\n return Reflect.get(target, property, receiver);\n },\n });\n};\n\nconst createBoundaryViewportRuler = (viewportRuler: ViewportRuler, overlayRoot: HTMLElement): ViewportRuler => {\n const boundaryViewportRuler = Object.create(viewportRuler) as ViewportRuler;\n boundaryViewportRuler.getViewportRect = () => getBoundaryRect(overlayRoot);\n boundaryViewportRuler.getViewportScrollPosition = () => ({ left: 0, top: 0 });\n boundaryViewportRuler.getViewportSize = () => {\n const { height, width } = getBoundaryRect(overlayRoot);\n return { height, width };\n };\n return boundaryViewportRuler;\n};\n\nconst adaptConnectedPositionStrategy = (\n strategy: FlexibleConnectedPositionStrategy,\n overlayRoot: HTMLElement,\n observeBoundary: (callback: () => void) => () => void,\n): FlexibleConnectedPositionStrategy => {\n const internals = strategy as unknown as IFlexibleConnectedPositionStrategyInternals;\n const getOriginRect = internals._getOriginRect.bind(strategy);\n const getOriginPoint = internals._getOriginPoint.bind(strategy);\n const attach = strategy.attach.bind(strategy);\n const detach = strategy.detach.bind(strategy);\n const dispose = strategy.dispose.bind(strategy);\n let stopObserving = () => {};\n internals._getOriginRect = () => {\n return translateRectToBoundary(getOriginRect(), overlayRoot.getBoundingClientRect());\n };\n internals._getOriginPoint = (originRect, _containerRect, position) => {\n return getOriginPoint(originRect, getBoundaryRect(overlayRoot), position);\n };\n strategy.attach = (overlayRef) => {\n attach(overlayRef);\n stopObserving();\n stopObserving = observeBoundary(() => strategy.apply());\n };\n strategy.detach = () => {\n stopObserving();\n stopObserving = () => {};\n detach();\n };\n strategy.dispose = () => {\n stopObserving();\n stopObserving = () => {};\n dispose();\n };\n\n return strategy;\n};\n\nclass MfOverlayPositionBuilder extends OverlayPositionBuilder {\n readonly #document: Document;\n readonly #overlayContainer: OverlayContainer;\n readonly #overlayRoot: HTMLElement;\n readonly #platform: Platform;\n readonly #viewportRuler: ViewportRuler;\n\n constructor(viewportRuler: ViewportRuler, document: Document, platform: Platform, overlayContainer: OverlayContainer, overlayRoot: HTMLElement) {\n super();\n this.#viewportRuler = viewportRuler;\n this.#document = document;\n this.#platform = platform;\n this.#overlayContainer = overlayContainer;\n this.#overlayRoot = overlayRoot;\n }\n\n override global(): GlobalPositionStrategy {\n return new GlobalPositionStrategy();\n }\n\n override flexibleConnectedTo(origin: FlexibleConnectedPositionStrategyOrigin): FlexibleConnectedPositionStrategy {\n const boundaryDocument = createBoundaryDocument(this.#document, this.#overlayRoot);\n const boundaryViewportRuler = createBoundaryViewportRuler(this.#viewportRuler, this.#overlayRoot);\n const strategy = new FlexibleConnectedPositionStrategy(origin, boundaryViewportRuler, boundaryDocument, this.#platform, this.#overlayContainer);\n\n const overlayContainer = this.#overlayContainer as MfOverlayContainer;\n return adaptConnectedPositionStrategy(strategy, this.#overlayRoot, (callback) => overlayContainer.observeBoundary(callback));\n }\n}\n\nclass MfOverlayContainer extends OverlayContainer {\n readonly #boundaryObservers = new Set<() => void>();\n readonly #overlayRoot: HTMLElement;\n #animationFrame: number | null = null;\n #boundaryRect: IClientRect | null = null;\n #restoreRootPosition: (() => void) | null = null;\n #shadowStyle: HTMLStyleElement | null = null;\n\n constructor(overlayRoot: HTMLElement) {\n super();\n this.#overlayRoot = overlayRoot;\n }\n\n override ngOnDestroy(): void {\n if (this.#animationFrame !== null) {\n this.#overlayRoot.ownerDocument.defaultView?.cancelAnimationFrame(this.#animationFrame);\n }\n this.#animationFrame = null;\n this.#boundaryObservers.clear();\n super.ngOnDestroy();\n this.#shadowStyle?.remove();\n this.#shadowStyle = null;\n this.#restoreRootPosition?.();\n this.#restoreRootPosition = null;\n }\n\n observeBoundary(callback: () => void): () => void {\n this.#boundaryObservers.add(callback);\n if (this.#boundaryObservers.size === 1) {\n this.#boundaryRect = this.#overlayRoot.getBoundingClientRect();\n this.#scheduleBoundaryCheck();\n }\n\n return () => {\n this.#boundaryObservers.delete(callback);\n if (this.#boundaryObservers.size === 0 && this.#animationFrame !== null) {\n this.#overlayRoot.ownerDocument.defaultView?.cancelAnimationFrame(this.#animationFrame);\n this.#animationFrame = null;\n this.#boundaryRect = null;\n }\n };\n }\n\n protected override _createContainer(): void {\n if (this.#overlayRoot.ownerDocument.defaultView?.getComputedStyle(this.#overlayRoot).position === 'static') {\n const previousPosition = this.#overlayRoot.style.position;\n this.#overlayRoot.style.position = 'relative';\n this.#restoreRootPosition = () => {\n this.#overlayRoot.style.position = previousPosition;\n };\n }\n\n const rootNode = this.#overlayRoot.getRootNode();\n const ShadowRootConstructor = this.#overlayRoot.ownerDocument.defaultView?.ShadowRoot;\n if (ShadowRootConstructor && rootNode instanceof ShadowRootConstructor) {\n const style = this._document.createElement('style');\n style.setAttribute('data-edyn-mf-cdk-overlay-styles', '');\n style.textContent = CDK_OVERLAY_STRUCTURAL_CSS;\n rootNode.appendChild(style);\n this.#shadowStyle = style;\n }\n\n const container = this._document.createElement('div');\n container.classList.add('cdk-overlay-container');\n container.style.inset = '0';\n container.style.position = 'absolute';\n this.#overlayRoot.appendChild(container);\n this._containerElement = container;\n }\n\n #scheduleBoundaryCheck(): void {\n const window = this.#overlayRoot.ownerDocument.defaultView;\n if (!window || this.#animationFrame !== null || this.#boundaryObservers.size === 0) {\n return;\n }\n\n this.#animationFrame = window.requestAnimationFrame(() => {\n this.#animationFrame = null;\n const previous = this.#boundaryRect;\n const current = this.#overlayRoot.getBoundingClientRect();\n this.#boundaryRect = current;\n\n if (\n previous &&\n (previous.height !== current.height || previous.left !== current.left || previous.top !== current.top || previous.width !== current.width)\n ) {\n for (const observer of this.#boundaryObservers) {\n observer();\n }\n }\n\n this.#scheduleBoundaryCheck();\n });\n }\n}\n\nconst isDocumentViewportRoot = (overlayRoot: HTMLElement): boolean => {\n return overlayRoot === overlayRoot.ownerDocument.body || overlayRoot === overlayRoot.ownerDocument.documentElement;\n};\n\nconst createOverlayContainer = (overlayRoot: HTMLElement): OverlayContainer => {\n return isDocumentViewportRoot(overlayRoot) ? new OverlayContainer() : new MfOverlayContainer(overlayRoot);\n};\n\nconst createOverlayPositionBuilder = (\n viewportRuler: ViewportRuler,\n document: Document,\n platform: Platform,\n overlayContainer: OverlayContainer,\n overlayRoot: HTMLElement,\n): OverlayPositionBuilder => {\n if (isDocumentViewportRoot(overlayRoot)) {\n return new OverlayPositionBuilder();\n }\n return new MfOverlayPositionBuilder(viewportRuler, document, platform, overlayContainer, overlayRoot);\n};\n\n// Hosted, the overlay root sits in the module's shadow root, so the providers every module already uses for overlays also\n// make rem lengths there follow the module's own root font size. They start with the module's injector, before its\n// first component renders and Angular adds component styles, and stop with it.\nconst followRootFontSizeOf = (overlayRoot: HTMLElement, destroyRef: DestroyRef): void => {\n const rootNode = overlayRoot.getRootNode();\n const ShadowRootConstructor = overlayRoot.ownerDocument.defaultView?.ShadowRoot;\n if (ShadowRootConstructor && rootNode instanceof ShadowRootConstructor) {\n destroyRef.onDestroy(followModuleRootFontSize(rootNode));\n }\n};\n\nconst createTokenProviders = (overlayRootToken: ProviderToken<HTMLElement>): StaticProvider[] => {\n return [\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useFactory: (overlayRoot: HTMLElement, destroyRef: DestroyRef) => () => followRootFontSizeOf(overlayRoot, destroyRef),\n deps: [overlayRootToken, DestroyRef],\n },\n {\n provide: OverlayContainer,\n useFactory: createOverlayContainer,\n deps: [overlayRootToken],\n },\n {\n provide: OverlayPositionBuilder,\n useFactory: createOverlayPositionBuilder,\n deps: [ViewportRuler, DOCUMENT, Platform, OverlayContainer, overlayRootToken],\n },\n ];\n};\n\nexport const provideMfOverlayRoot = (overlayRoot?: HTMLElement): StaticProvider[] => {\n if (!overlayRoot) {\n return [];\n }\n\n return [\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useFactory: (destroyRef: DestroyRef) => () => followRootFontSizeOf(overlayRoot, destroyRef),\n deps: [DestroyRef],\n },\n {\n provide: OverlayContainer,\n useFactory: () => createOverlayContainer(overlayRoot),\n },\n {\n provide: OverlayPositionBuilder,\n useFactory: (viewportRuler: ViewportRuler, document: Document, platform: Platform, overlayContainer: OverlayContainer) => {\n return createOverlayPositionBuilder(viewportRuler, document, platform, overlayContainer, overlayRoot);\n },\n deps: [ViewportRuler, DOCUMENT, Platform, OverlayContainer],\n },\n ];\n};\n\nexport const provideMfOverlayRootFromToken = (overlayRootToken: ProviderToken<HTMLElement>): StaticProvider[] => {\n return createTokenProviders(overlayRootToken);\n};\n\nexport { CaseInsensitiveBasePathLocationStrategy, provideCaseInsensitiveBasePath } from './angular-location.js';\n"]}
|
|
1
|
+
{"version":3,"file":"angular.d.ts","sourceRoot":"","sources":["../src/angular.ts"],"names":[],"mappings":"AAUA,OAAO,EAA+C,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AA+TrH,eAAO,MAAM,oBAAoB,GAAI,cAAc,WAAW,KAAG,cAAc,EAwB9E,CAAC;AAEF,eAAO,MAAM,6BAA6B,GAAI,kBAAkB,aAAa,CAAC,WAAW,CAAC,KAAG,cAAc,EAE1G,CAAC;AAEF,OAAO,EAAE,uCAAuC,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["import {\n FlexibleConnectedPositionStrategy,\n type FlexibleConnectedPositionStrategyOrigin,\n GlobalPositionStrategy,\n OverlayContainer,\n OverlayPositionBuilder,\n} from '@angular/cdk/overlay';\nimport { Platform } from '@angular/cdk/platform';\nimport { ViewportRuler } from '@angular/cdk/scrolling';\nimport { DOCUMENT } from '@angular/common';\nimport { DestroyRef, ENVIRONMENT_INITIALIZER, NgZone, type ProviderToken, type StaticProvider } from '@angular/core';\nimport { followModuleRootFontSize } from './hosted-module-styles.js';\n\n// Mirrors the CDK 19 overlay-prebuilt.css structural rules while intentionally excluding document-level scroll blocking.\nconst CDK_OVERLAY_STRUCTURAL_CSS = `\n.cdk-overlay-container,.cdk-global-overlay-wrapper{pointer-events:none;top:0;left:0;height:100%;width:100%}\n.cdk-overlay-container{position:fixed;z-index:1000}\n.cdk-overlay-container:empty{display:none}\n.cdk-global-overlay-wrapper{display:flex;position:absolute;z-index:1000}\n.cdk-overlay-pane{position:absolute;pointer-events:auto;box-sizing:border-box;display:flex;max-width:100%;max-height:100%;z-index:1000}\n.cdk-overlay-backdrop{position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:auto;-webkit-tap-highlight-color:rgba(0,0,0,0);opacity:0;touch-action:manipulation;z-index:1000;transition:opacity 400ms cubic-bezier(0.25,0.8,0.25,1)}\n@media(prefers-reduced-motion){.cdk-overlay-backdrop{transition-duration:1ms}}\n.cdk-overlay-backdrop-showing{opacity:1}\n@media(forced-colors:active){.cdk-overlay-backdrop-showing{opacity:.6}}\n.cdk-overlay-dark-backdrop{background:rgba(0,0,0,.32)}\n.cdk-overlay-transparent-backdrop{transition:visibility 1ms linear,opacity 1ms linear;visibility:hidden;opacity:1}\n.cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing,.cdk-high-contrast-active .cdk-overlay-transparent-backdrop{opacity:0;visibility:visible}\n.cdk-overlay-backdrop-noop-animation{transition:none}\n.cdk-overlay-connected-position-bounding-box{position:absolute;display:flex;flex-direction:column;min-width:1px;min-height:1px;z-index:1000}\n`;\n\ninterface IClientRect {\n bottom: number;\n height: number;\n left: number;\n right: number;\n top: number;\n width: number;\n x?: number;\n y?: number;\n}\n\ninterface IFlexibleConnectedPositionStrategyInternals {\n _getOriginPoint: (originRect: IClientRect, containerRect: IClientRect, position: unknown) => { x: number; y: number };\n _getOriginRect: () => IClientRect;\n}\n\nconst translateRectToBoundary = (rect: IClientRect, boundary: IClientRect): IClientRect => {\n const left = rect.left - boundary.left;\n const top = rect.top - boundary.top;\n\n return {\n bottom: top + rect.height,\n height: rect.height,\n left,\n right: left + rect.width,\n top,\n width: rect.width,\n x: left,\n y: top,\n };\n};\n\nconst getBoundaryRect = (overlayRoot: HTMLElement): IClientRect => {\n const { height, width } = overlayRoot.getBoundingClientRect();\n return {\n bottom: height,\n height,\n left: 0,\n right: width,\n top: 0,\n width,\n x: 0,\n y: 0,\n };\n};\n\nconst createBoundaryDocument = (document: Document, overlayRoot: HTMLElement): Document => {\n const boundaryDocumentElement = new Proxy(document.documentElement, {\n get: (target, property, receiver) => {\n if (property === 'clientHeight') {\n return overlayRoot.getBoundingClientRect().height;\n }\n if (property === 'clientWidth') {\n return overlayRoot.getBoundingClientRect().width;\n }\n return Reflect.get(target, property, receiver);\n },\n });\n\n return new Proxy(document, {\n get: (target, property, receiver) => {\n if (property === 'documentElement') {\n return boundaryDocumentElement;\n }\n return Reflect.get(target, property, receiver);\n },\n });\n};\n\nconst createBoundaryViewportRuler = (viewportRuler: ViewportRuler, overlayRoot: HTMLElement): ViewportRuler => {\n const boundaryViewportRuler = Object.create(viewportRuler) as ViewportRuler;\n boundaryViewportRuler.getViewportRect = () => getBoundaryRect(overlayRoot);\n boundaryViewportRuler.getViewportScrollPosition = () => ({ left: 0, top: 0 });\n boundaryViewportRuler.getViewportSize = () => {\n const { height, width } = getBoundaryRect(overlayRoot);\n return { height, width };\n };\n return boundaryViewportRuler;\n};\n\nconst adaptConnectedPositionStrategy = (\n strategy: FlexibleConnectedPositionStrategy,\n overlayRoot: HTMLElement,\n observeBoundary: (callback: () => void) => () => void,\n): FlexibleConnectedPositionStrategy => {\n const internals = strategy as unknown as IFlexibleConnectedPositionStrategyInternals;\n const getOriginRect = internals._getOriginRect.bind(strategy);\n const getOriginPoint = internals._getOriginPoint.bind(strategy);\n const attach = strategy.attach.bind(strategy);\n const detach = strategy.detach.bind(strategy);\n const dispose = strategy.dispose.bind(strategy);\n let stopObserving = () => {};\n internals._getOriginRect = () => {\n return translateRectToBoundary(getOriginRect(), overlayRoot.getBoundingClientRect());\n };\n internals._getOriginPoint = (originRect, _containerRect, position) => {\n return getOriginPoint(originRect, getBoundaryRect(overlayRoot), position);\n };\n strategy.attach = (overlayRef) => {\n attach(overlayRef);\n stopObserving();\n stopObserving = observeBoundary(() => strategy.apply());\n };\n strategy.detach = () => {\n stopObserving();\n stopObserving = () => {};\n detach();\n };\n strategy.dispose = () => {\n stopObserving();\n stopObserving = () => {};\n dispose();\n };\n\n return strategy;\n};\n\nclass MfOverlayPositionBuilder extends OverlayPositionBuilder {\n readonly #document: Document;\n readonly #overlayContainer: OverlayContainer;\n readonly #overlayRoot: HTMLElement;\n readonly #platform: Platform;\n readonly #viewportRuler: ViewportRuler;\n\n constructor(viewportRuler: ViewportRuler, document: Document, platform: Platform, overlayContainer: OverlayContainer, overlayRoot: HTMLElement) {\n super();\n this.#viewportRuler = viewportRuler;\n this.#document = document;\n this.#platform = platform;\n this.#overlayContainer = overlayContainer;\n this.#overlayRoot = overlayRoot;\n }\n\n override global(): GlobalPositionStrategy {\n return new GlobalPositionStrategy();\n }\n\n override flexibleConnectedTo(origin: FlexibleConnectedPositionStrategyOrigin): FlexibleConnectedPositionStrategy {\n const boundaryDocument = createBoundaryDocument(this.#document, this.#overlayRoot);\n const boundaryViewportRuler = createBoundaryViewportRuler(this.#viewportRuler, this.#overlayRoot);\n const strategy = new FlexibleConnectedPositionStrategy(origin, boundaryViewportRuler, boundaryDocument, this.#platform, this.#overlayContainer);\n\n const overlayContainer = this.#overlayContainer as MfOverlayContainer;\n return adaptConnectedPositionStrategy(strategy, this.#overlayRoot, (callback) => overlayContainer.observeBoundary(callback));\n }\n}\n\nclass MfOverlayContainer extends OverlayContainer {\n readonly #boundaryObservers = new Set<() => void>();\n readonly #overlayRoot: HTMLElement;\n #animationFrame: number | null = null;\n #boundaryRect: IClientRect | null = null;\n #restoreRootPosition: (() => void) | null = null;\n #shadowStyle: HTMLStyleElement | null = null;\n\n constructor(overlayRoot: HTMLElement) {\n super();\n this.#overlayRoot = overlayRoot;\n }\n\n override ngOnDestroy(): void {\n if (this.#animationFrame !== null) {\n this.#overlayRoot.ownerDocument.defaultView?.cancelAnimationFrame(this.#animationFrame);\n }\n this.#animationFrame = null;\n this.#boundaryObservers.clear();\n super.ngOnDestroy();\n this.#shadowStyle?.remove();\n this.#shadowStyle = null;\n this.#restoreRootPosition?.();\n this.#restoreRootPosition = null;\n }\n\n observeBoundary(callback: () => void): () => void {\n this.#boundaryObservers.add(callback);\n if (this.#boundaryObservers.size === 1) {\n this.#boundaryRect = this.#overlayRoot.getBoundingClientRect();\n this.#scheduleBoundaryCheck();\n }\n\n return () => {\n this.#boundaryObservers.delete(callback);\n if (this.#boundaryObservers.size === 0 && this.#animationFrame !== null) {\n this.#overlayRoot.ownerDocument.defaultView?.cancelAnimationFrame(this.#animationFrame);\n this.#animationFrame = null;\n this.#boundaryRect = null;\n }\n };\n }\n\n protected override _createContainer(): void {\n if (this.#overlayRoot.ownerDocument.defaultView?.getComputedStyle(this.#overlayRoot).position === 'static') {\n const previousPosition = this.#overlayRoot.style.position;\n this.#overlayRoot.style.position = 'relative';\n this.#restoreRootPosition = () => {\n this.#overlayRoot.style.position = previousPosition;\n };\n }\n\n const rootNode = this.#overlayRoot.getRootNode();\n const ShadowRootConstructor = this.#overlayRoot.ownerDocument.defaultView?.ShadowRoot;\n if (ShadowRootConstructor && rootNode instanceof ShadowRootConstructor) {\n const style = this._document.createElement('style');\n style.setAttribute('data-edyn-mf-cdk-overlay-styles', '');\n style.textContent = CDK_OVERLAY_STRUCTURAL_CSS;\n rootNode.appendChild(style);\n this.#shadowStyle = style;\n }\n\n const container = this._document.createElement('div');\n container.classList.add('cdk-overlay-container');\n container.style.inset = '0';\n container.style.position = 'absolute';\n this.#overlayRoot.appendChild(container);\n this._containerElement = container;\n }\n\n #scheduleBoundaryCheck(): void {\n const window = this.#overlayRoot.ownerDocument.defaultView;\n if (!window || this.#animationFrame !== null || this.#boundaryObservers.size === 0) {\n return;\n }\n\n this.#animationFrame = window.requestAnimationFrame(() => {\n this.#animationFrame = null;\n const previous = this.#boundaryRect;\n const current = this.#overlayRoot.getBoundingClientRect();\n this.#boundaryRect = current;\n\n if (\n previous &&\n (previous.height !== current.height || previous.left !== current.left || previous.top !== current.top || previous.width !== current.width)\n ) {\n for (const observer of this.#boundaryObservers) {\n observer();\n }\n }\n\n this.#scheduleBoundaryCheck();\n });\n }\n}\n\nconst isDocumentViewportRoot = (overlayRoot: HTMLElement): boolean => {\n return overlayRoot === overlayRoot.ownerDocument.body || overlayRoot === overlayRoot.ownerDocument.documentElement;\n};\n\nconst createOverlayContainer = (overlayRoot: HTMLElement): OverlayContainer => {\n return isDocumentViewportRoot(overlayRoot) ? new OverlayContainer() : new MfOverlayContainer(overlayRoot);\n};\n\nconst createOverlayPositionBuilder = (\n viewportRuler: ViewportRuler,\n document: Document,\n platform: Platform,\n overlayContainer: OverlayContainer,\n overlayRoot: HTMLElement,\n): OverlayPositionBuilder => {\n if (isDocumentViewportRoot(overlayRoot)) {\n return new OverlayPositionBuilder();\n }\n return new MfOverlayPositionBuilder(viewportRuler, document, platform, overlayContainer, overlayRoot);\n};\n\n// Hosted, the overlay root sits in the module's shadow root, so the providers every module already uses for overlays also\n// make rem lengths there follow the module's own root font size. They start with the module's injector, before its\n// first component renders and Angular adds component styles, and stop with it. The observers only rewrite CSS, so they\n// start outside Angular's zone: inside it, every DOM change in the module would run change detection, and a template\n// that renders new nodes on each check (an *ngFor over a getter, without trackBy) would never settle.\nconst followRootFontSizeOf = (overlayRoot: HTMLElement, destroyRef: DestroyRef, ngZone: NgZone): void => {\n const rootNode = overlayRoot.getRootNode();\n const ShadowRootConstructor = overlayRoot.ownerDocument.defaultView?.ShadowRoot;\n if (ShadowRootConstructor && rootNode instanceof ShadowRootConstructor) {\n destroyRef.onDestroy(ngZone.runOutsideAngular(() => followModuleRootFontSize(rootNode)));\n }\n};\n\nconst createTokenProviders = (overlayRootToken: ProviderToken<HTMLElement>): StaticProvider[] => {\n return [\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useFactory: (overlayRoot: HTMLElement, destroyRef: DestroyRef, ngZone: NgZone) => () => followRootFontSizeOf(overlayRoot, destroyRef, ngZone),\n deps: [overlayRootToken, DestroyRef, NgZone],\n },\n {\n provide: OverlayContainer,\n useFactory: createOverlayContainer,\n deps: [overlayRootToken],\n },\n {\n provide: OverlayPositionBuilder,\n useFactory: createOverlayPositionBuilder,\n deps: [ViewportRuler, DOCUMENT, Platform, OverlayContainer, overlayRootToken],\n },\n ];\n};\n\nexport const provideMfOverlayRoot = (overlayRoot?: HTMLElement): StaticProvider[] => {\n if (!overlayRoot) {\n return [];\n }\n\n return [\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useFactory: (destroyRef: DestroyRef, ngZone: NgZone) => () => followRootFontSizeOf(overlayRoot, destroyRef, ngZone),\n deps: [DestroyRef, NgZone],\n },\n {\n provide: OverlayContainer,\n useFactory: () => createOverlayContainer(overlayRoot),\n },\n {\n provide: OverlayPositionBuilder,\n useFactory: (viewportRuler: ViewportRuler, document: Document, platform: Platform, overlayContainer: OverlayContainer) => {\n return createOverlayPositionBuilder(viewportRuler, document, platform, overlayContainer, overlayRoot);\n },\n deps: [ViewportRuler, DOCUMENT, Platform, OverlayContainer],\n },\n ];\n};\n\nexport const provideMfOverlayRootFromToken = (overlayRootToken: ProviderToken<HTMLElement>): StaticProvider[] => {\n return createTokenProviders(overlayRootToken);\n};\n\nexport { CaseInsensitiveBasePathLocationStrategy, provideCaseInsensitiveBasePath } from './angular-location.js';\n"]}
|
package/dist/angular.js
CHANGED
|
@@ -2,7 +2,7 @@ import { FlexibleConnectedPositionStrategy, GlobalPositionStrategy, OverlayConta
|
|
|
2
2
|
import { Platform } from '@angular/cdk/platform';
|
|
3
3
|
import { ViewportRuler } from '@angular/cdk/scrolling';
|
|
4
4
|
import { DOCUMENT } from '@angular/common';
|
|
5
|
-
import { DestroyRef, ENVIRONMENT_INITIALIZER } from '@angular/core';
|
|
5
|
+
import { DestroyRef, ENVIRONMENT_INITIALIZER, NgZone } from '@angular/core';
|
|
6
6
|
import { followModuleRootFontSize } from './hosted-module-styles.js';
|
|
7
7
|
// Mirrors the CDK 19 overlay-prebuilt.css structural rules while intentionally excluding document-level scroll blocking.
|
|
8
8
|
const CDK_OVERLAY_STRUCTURAL_CSS = `
|
|
@@ -231,12 +231,14 @@ const createOverlayPositionBuilder = (viewportRuler, document, platform, overlay
|
|
|
231
231
|
};
|
|
232
232
|
// Hosted, the overlay root sits in the module's shadow root, so the providers every module already uses for overlays also
|
|
233
233
|
// make rem lengths there follow the module's own root font size. They start with the module's injector, before its
|
|
234
|
-
// first component renders and Angular adds component styles, and stop with it.
|
|
235
|
-
|
|
234
|
+
// first component renders and Angular adds component styles, and stop with it. The observers only rewrite CSS, so they
|
|
235
|
+
// start outside Angular's zone: inside it, every DOM change in the module would run change detection, and a template
|
|
236
|
+
// that renders new nodes on each check (an *ngFor over a getter, without trackBy) would never settle.
|
|
237
|
+
const followRootFontSizeOf = (overlayRoot, destroyRef, ngZone) => {
|
|
236
238
|
const rootNode = overlayRoot.getRootNode();
|
|
237
239
|
const ShadowRootConstructor = overlayRoot.ownerDocument.defaultView?.ShadowRoot;
|
|
238
240
|
if (ShadowRootConstructor && rootNode instanceof ShadowRootConstructor) {
|
|
239
|
-
destroyRef.onDestroy(followModuleRootFontSize(rootNode));
|
|
241
|
+
destroyRef.onDestroy(ngZone.runOutsideAngular(() => followModuleRootFontSize(rootNode)));
|
|
240
242
|
}
|
|
241
243
|
};
|
|
242
244
|
const createTokenProviders = (overlayRootToken) => {
|
|
@@ -244,8 +246,8 @@ const createTokenProviders = (overlayRootToken) => {
|
|
|
244
246
|
{
|
|
245
247
|
provide: ENVIRONMENT_INITIALIZER,
|
|
246
248
|
multi: true,
|
|
247
|
-
useFactory: (overlayRoot, destroyRef) => () => followRootFontSizeOf(overlayRoot, destroyRef),
|
|
248
|
-
deps: [overlayRootToken, DestroyRef],
|
|
249
|
+
useFactory: (overlayRoot, destroyRef, ngZone) => () => followRootFontSizeOf(overlayRoot, destroyRef, ngZone),
|
|
250
|
+
deps: [overlayRootToken, DestroyRef, NgZone],
|
|
249
251
|
},
|
|
250
252
|
{
|
|
251
253
|
provide: OverlayContainer,
|
|
@@ -267,8 +269,8 @@ export const provideMfOverlayRoot = (overlayRoot) => {
|
|
|
267
269
|
{
|
|
268
270
|
provide: ENVIRONMENT_INITIALIZER,
|
|
269
271
|
multi: true,
|
|
270
|
-
useFactory: (destroyRef) => () => followRootFontSizeOf(overlayRoot, destroyRef),
|
|
271
|
-
deps: [DestroyRef],
|
|
272
|
+
useFactory: (destroyRef, ngZone) => () => followRootFontSizeOf(overlayRoot, destroyRef, ngZone),
|
|
273
|
+
deps: [DestroyRef, NgZone],
|
|
272
274
|
},
|
|
273
275
|
{
|
|
274
276
|
provide: OverlayContainer,
|
package/dist/angular.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular.js","sourceRoot":"","sources":["../src/angular.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EAEjC,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAA2C,MAAM,eAAe,CAAC;AAC7G,OAAO,EAAE,wBAAwB,EAAE,MAAM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YACxG,CAAC;YACD,IAAI,EAAE,CAAC,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,CAAC;SAC5D;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,gBAA4C,EAAoB,EAAE;IAC9G,OAAO,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF,OAAO,EAAE,uCAAuC,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["import {\n FlexibleConnectedPositionStrategy,\n type FlexibleConnectedPositionStrategyOrigin,\n GlobalPositionStrategy,\n OverlayContainer,\n OverlayPositionBuilder,\n} from '@angular/cdk/overlay';\nimport { Platform } from '@angular/cdk/platform';\nimport { ViewportRuler } from '@angular/cdk/scrolling';\nimport { DOCUMENT } from '@angular/common';\nimport { DestroyRef, ENVIRONMENT_INITIALIZER, type ProviderToken, type StaticProvider } from '@angular/core';\nimport { followModuleRootFontSize } from './hosted-module-styles.js';\n\n// Mirrors the CDK 19 overlay-prebuilt.css structural rules while intentionally excluding document-level scroll blocking.\nconst CDK_OVERLAY_STRUCTURAL_CSS = `\n.cdk-overlay-container,.cdk-global-overlay-wrapper{pointer-events:none;top:0;left:0;height:100%;width:100%}\n.cdk-overlay-container{position:fixed;z-index:1000}\n.cdk-overlay-container:empty{display:none}\n.cdk-global-overlay-wrapper{display:flex;position:absolute;z-index:1000}\n.cdk-overlay-pane{position:absolute;pointer-events:auto;box-sizing:border-box;display:flex;max-width:100%;max-height:100%;z-index:1000}\n.cdk-overlay-backdrop{position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:auto;-webkit-tap-highlight-color:rgba(0,0,0,0);opacity:0;touch-action:manipulation;z-index:1000;transition:opacity 400ms cubic-bezier(0.25,0.8,0.25,1)}\n@media(prefers-reduced-motion){.cdk-overlay-backdrop{transition-duration:1ms}}\n.cdk-overlay-backdrop-showing{opacity:1}\n@media(forced-colors:active){.cdk-overlay-backdrop-showing{opacity:.6}}\n.cdk-overlay-dark-backdrop{background:rgba(0,0,0,.32)}\n.cdk-overlay-transparent-backdrop{transition:visibility 1ms linear,opacity 1ms linear;visibility:hidden;opacity:1}\n.cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing,.cdk-high-contrast-active .cdk-overlay-transparent-backdrop{opacity:0;visibility:visible}\n.cdk-overlay-backdrop-noop-animation{transition:none}\n.cdk-overlay-connected-position-bounding-box{position:absolute;display:flex;flex-direction:column;min-width:1px;min-height:1px;z-index:1000}\n`;\n\ninterface IClientRect {\n bottom: number;\n height: number;\n left: number;\n right: number;\n top: number;\n width: number;\n x?: number;\n y?: number;\n}\n\ninterface IFlexibleConnectedPositionStrategyInternals {\n _getOriginPoint: (originRect: IClientRect, containerRect: IClientRect, position: unknown) => { x: number; y: number };\n _getOriginRect: () => IClientRect;\n}\n\nconst translateRectToBoundary = (rect: IClientRect, boundary: IClientRect): IClientRect => {\n const left = rect.left - boundary.left;\n const top = rect.top - boundary.top;\n\n return {\n bottom: top + rect.height,\n height: rect.height,\n left,\n right: left + rect.width,\n top,\n width: rect.width,\n x: left,\n y: top,\n };\n};\n\nconst getBoundaryRect = (overlayRoot: HTMLElement): IClientRect => {\n const { height, width } = overlayRoot.getBoundingClientRect();\n return {\n bottom: height,\n height,\n left: 0,\n right: width,\n top: 0,\n width,\n x: 0,\n y: 0,\n };\n};\n\nconst createBoundaryDocument = (document: Document, overlayRoot: HTMLElement): Document => {\n const boundaryDocumentElement = new Proxy(document.documentElement, {\n get: (target, property, receiver) => {\n if (property === 'clientHeight') {\n return overlayRoot.getBoundingClientRect().height;\n }\n if (property === 'clientWidth') {\n return overlayRoot.getBoundingClientRect().width;\n }\n return Reflect.get(target, property, receiver);\n },\n });\n\n return new Proxy(document, {\n get: (target, property, receiver) => {\n if (property === 'documentElement') {\n return boundaryDocumentElement;\n }\n return Reflect.get(target, property, receiver);\n },\n });\n};\n\nconst createBoundaryViewportRuler = (viewportRuler: ViewportRuler, overlayRoot: HTMLElement): ViewportRuler => {\n const boundaryViewportRuler = Object.create(viewportRuler) as ViewportRuler;\n boundaryViewportRuler.getViewportRect = () => getBoundaryRect(overlayRoot);\n boundaryViewportRuler.getViewportScrollPosition = () => ({ left: 0, top: 0 });\n boundaryViewportRuler.getViewportSize = () => {\n const { height, width } = getBoundaryRect(overlayRoot);\n return { height, width };\n };\n return boundaryViewportRuler;\n};\n\nconst adaptConnectedPositionStrategy = (\n strategy: FlexibleConnectedPositionStrategy,\n overlayRoot: HTMLElement,\n observeBoundary: (callback: () => void) => () => void,\n): FlexibleConnectedPositionStrategy => {\n const internals = strategy as unknown as IFlexibleConnectedPositionStrategyInternals;\n const getOriginRect = internals._getOriginRect.bind(strategy);\n const getOriginPoint = internals._getOriginPoint.bind(strategy);\n const attach = strategy.attach.bind(strategy);\n const detach = strategy.detach.bind(strategy);\n const dispose = strategy.dispose.bind(strategy);\n let stopObserving = () => {};\n internals._getOriginRect = () => {\n return translateRectToBoundary(getOriginRect(), overlayRoot.getBoundingClientRect());\n };\n internals._getOriginPoint = (originRect, _containerRect, position) => {\n return getOriginPoint(originRect, getBoundaryRect(overlayRoot), position);\n };\n strategy.attach = (overlayRef) => {\n attach(overlayRef);\n stopObserving();\n stopObserving = observeBoundary(() => strategy.apply());\n };\n strategy.detach = () => {\n stopObserving();\n stopObserving = () => {};\n detach();\n };\n strategy.dispose = () => {\n stopObserving();\n stopObserving = () => {};\n dispose();\n };\n\n return strategy;\n};\n\nclass MfOverlayPositionBuilder extends OverlayPositionBuilder {\n readonly #document: Document;\n readonly #overlayContainer: OverlayContainer;\n readonly #overlayRoot: HTMLElement;\n readonly #platform: Platform;\n readonly #viewportRuler: ViewportRuler;\n\n constructor(viewportRuler: ViewportRuler, document: Document, platform: Platform, overlayContainer: OverlayContainer, overlayRoot: HTMLElement) {\n super();\n this.#viewportRuler = viewportRuler;\n this.#document = document;\n this.#platform = platform;\n this.#overlayContainer = overlayContainer;\n this.#overlayRoot = overlayRoot;\n }\n\n override global(): GlobalPositionStrategy {\n return new GlobalPositionStrategy();\n }\n\n override flexibleConnectedTo(origin: FlexibleConnectedPositionStrategyOrigin): FlexibleConnectedPositionStrategy {\n const boundaryDocument = createBoundaryDocument(this.#document, this.#overlayRoot);\n const boundaryViewportRuler = createBoundaryViewportRuler(this.#viewportRuler, this.#overlayRoot);\n const strategy = new FlexibleConnectedPositionStrategy(origin, boundaryViewportRuler, boundaryDocument, this.#platform, this.#overlayContainer);\n\n const overlayContainer = this.#overlayContainer as MfOverlayContainer;\n return adaptConnectedPositionStrategy(strategy, this.#overlayRoot, (callback) => overlayContainer.observeBoundary(callback));\n }\n}\n\nclass MfOverlayContainer extends OverlayContainer {\n readonly #boundaryObservers = new Set<() => void>();\n readonly #overlayRoot: HTMLElement;\n #animationFrame: number | null = null;\n #boundaryRect: IClientRect | null = null;\n #restoreRootPosition: (() => void) | null = null;\n #shadowStyle: HTMLStyleElement | null = null;\n\n constructor(overlayRoot: HTMLElement) {\n super();\n this.#overlayRoot = overlayRoot;\n }\n\n override ngOnDestroy(): void {\n if (this.#animationFrame !== null) {\n this.#overlayRoot.ownerDocument.defaultView?.cancelAnimationFrame(this.#animationFrame);\n }\n this.#animationFrame = null;\n this.#boundaryObservers.clear();\n super.ngOnDestroy();\n this.#shadowStyle?.remove();\n this.#shadowStyle = null;\n this.#restoreRootPosition?.();\n this.#restoreRootPosition = null;\n }\n\n observeBoundary(callback: () => void): () => void {\n this.#boundaryObservers.add(callback);\n if (this.#boundaryObservers.size === 1) {\n this.#boundaryRect = this.#overlayRoot.getBoundingClientRect();\n this.#scheduleBoundaryCheck();\n }\n\n return () => {\n this.#boundaryObservers.delete(callback);\n if (this.#boundaryObservers.size === 0 && this.#animationFrame !== null) {\n this.#overlayRoot.ownerDocument.defaultView?.cancelAnimationFrame(this.#animationFrame);\n this.#animationFrame = null;\n this.#boundaryRect = null;\n }\n };\n }\n\n protected override _createContainer(): void {\n if (this.#overlayRoot.ownerDocument.defaultView?.getComputedStyle(this.#overlayRoot).position === 'static') {\n const previousPosition = this.#overlayRoot.style.position;\n this.#overlayRoot.style.position = 'relative';\n this.#restoreRootPosition = () => {\n this.#overlayRoot.style.position = previousPosition;\n };\n }\n\n const rootNode = this.#overlayRoot.getRootNode();\n const ShadowRootConstructor = this.#overlayRoot.ownerDocument.defaultView?.ShadowRoot;\n if (ShadowRootConstructor && rootNode instanceof ShadowRootConstructor) {\n const style = this._document.createElement('style');\n style.setAttribute('data-edyn-mf-cdk-overlay-styles', '');\n style.textContent = CDK_OVERLAY_STRUCTURAL_CSS;\n rootNode.appendChild(style);\n this.#shadowStyle = style;\n }\n\n const container = this._document.createElement('div');\n container.classList.add('cdk-overlay-container');\n container.style.inset = '0';\n container.style.position = 'absolute';\n this.#overlayRoot.appendChild(container);\n this._containerElement = container;\n }\n\n #scheduleBoundaryCheck(): void {\n const window = this.#overlayRoot.ownerDocument.defaultView;\n if (!window || this.#animationFrame !== null || this.#boundaryObservers.size === 0) {\n return;\n }\n\n this.#animationFrame = window.requestAnimationFrame(() => {\n this.#animationFrame = null;\n const previous = this.#boundaryRect;\n const current = this.#overlayRoot.getBoundingClientRect();\n this.#boundaryRect = current;\n\n if (\n previous &&\n (previous.height !== current.height || previous.left !== current.left || previous.top !== current.top || previous.width !== current.width)\n ) {\n for (const observer of this.#boundaryObservers) {\n observer();\n }\n }\n\n this.#scheduleBoundaryCheck();\n });\n }\n}\n\nconst isDocumentViewportRoot = (overlayRoot: HTMLElement): boolean => {\n return overlayRoot === overlayRoot.ownerDocument.body || overlayRoot === overlayRoot.ownerDocument.documentElement;\n};\n\nconst createOverlayContainer = (overlayRoot: HTMLElement): OverlayContainer => {\n return isDocumentViewportRoot(overlayRoot) ? new OverlayContainer() : new MfOverlayContainer(overlayRoot);\n};\n\nconst createOverlayPositionBuilder = (\n viewportRuler: ViewportRuler,\n document: Document,\n platform: Platform,\n overlayContainer: OverlayContainer,\n overlayRoot: HTMLElement,\n): OverlayPositionBuilder => {\n if (isDocumentViewportRoot(overlayRoot)) {\n return new OverlayPositionBuilder();\n }\n return new MfOverlayPositionBuilder(viewportRuler, document, platform, overlayContainer, overlayRoot);\n};\n\n// Hosted, the overlay root sits in the module's shadow root, so the providers every module already uses for overlays also\n// make rem lengths there follow the module's own root font size. They start with the module's injector, before its\n// first component renders and Angular adds component styles, and stop with it.\nconst followRootFontSizeOf = (overlayRoot: HTMLElement, destroyRef: DestroyRef): void => {\n const rootNode = overlayRoot.getRootNode();\n const ShadowRootConstructor = overlayRoot.ownerDocument.defaultView?.ShadowRoot;\n if (ShadowRootConstructor && rootNode instanceof ShadowRootConstructor) {\n destroyRef.onDestroy(followModuleRootFontSize(rootNode));\n }\n};\n\nconst createTokenProviders = (overlayRootToken: ProviderToken<HTMLElement>): StaticProvider[] => {\n return [\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useFactory: (overlayRoot: HTMLElement, destroyRef: DestroyRef) => () => followRootFontSizeOf(overlayRoot, destroyRef),\n deps: [overlayRootToken, DestroyRef],\n },\n {\n provide: OverlayContainer,\n useFactory: createOverlayContainer,\n deps: [overlayRootToken],\n },\n {\n provide: OverlayPositionBuilder,\n useFactory: createOverlayPositionBuilder,\n deps: [ViewportRuler, DOCUMENT, Platform, OverlayContainer, overlayRootToken],\n },\n ];\n};\n\nexport const provideMfOverlayRoot = (overlayRoot?: HTMLElement): StaticProvider[] => {\n if (!overlayRoot) {\n return [];\n }\n\n return [\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useFactory: (destroyRef: DestroyRef) => () => followRootFontSizeOf(overlayRoot, destroyRef),\n deps: [DestroyRef],\n },\n {\n provide: OverlayContainer,\n useFactory: () => createOverlayContainer(overlayRoot),\n },\n {\n provide: OverlayPositionBuilder,\n useFactory: (viewportRuler: ViewportRuler, document: Document, platform: Platform, overlayContainer: OverlayContainer) => {\n return createOverlayPositionBuilder(viewportRuler, document, platform, overlayContainer, overlayRoot);\n },\n deps: [ViewportRuler, DOCUMENT, Platform, OverlayContainer],\n },\n ];\n};\n\nexport const provideMfOverlayRootFromToken = (overlayRootToken: ProviderToken<HTMLElement>): StaticProvider[] => {\n return createTokenProviders(overlayRootToken);\n};\n\nexport { CaseInsensitiveBasePathLocationStrategy, provideCaseInsensitiveBasePath } from './angular-location.js';\n"]}
|
|
1
|
+
{"version":3,"file":"angular.js","sourceRoot":"","sources":["../src/angular.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EAEjC,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,EAA2C,MAAM,eAAe,CAAC;AACrH,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAErE,yHAAyH;AACzH,MAAM,0BAA0B,GAAG;;;;;;;;;;;;;;;CAelC,CAAC;AAkBF,MAAM,uBAAuB,GAAG,CAAC,IAAiB,EAAE,QAAqB,EAAe,EAAE;IACxF,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;IACvC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;IAEpC,OAAO;QACL,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC,MAAM;QACzB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,IAAI;QACJ,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC,KAAK;QACxB,GAAG;QACH,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,CAAC,EAAE,IAAI;QACP,CAAC,EAAE,GAAG;KACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,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ositionBuilder,\n} from '@angular/cdk/overlay';\nimport { Platform } from '@angular/cdk/platform';\nimport { ViewportRuler } from '@angular/cdk/scrolling';\nimport { DOCUMENT } from '@angular/common';\nimport { DestroyRef, ENVIRONMENT_INITIALIZER, NgZone, type ProviderToken, type StaticProvider } from '@angular/core';\nimport { followModuleRootFontSize } from './hosted-module-styles.js';\n\n// Mirrors the CDK 19 overlay-prebuilt.css structural rules while intentionally excluding document-level scroll blocking.\nconst CDK_OVERLAY_STRUCTURAL_CSS = `\n.cdk-overlay-container,.cdk-global-overlay-wrapper{pointer-events:none;top:0;left:0;height:100%;width:100%}\n.cdk-overlay-container{position:fixed;z-index:1000}\n.cdk-overlay-container:empty{display:none}\n.cdk-global-overlay-wrapper{display:flex;position:absolute;z-index:1000}\n.cdk-overlay-pane{position:absolute;pointer-events:auto;box-sizing:border-box;display:flex;max-width:100%;max-height:100%;z-index:1000}\n.cdk-overlay-backdrop{position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:auto;-webkit-tap-highlight-color:rgba(0,0,0,0);opacity:0;touch-action:manipulation;z-index:1000;transition:opacity 400ms cubic-bezier(0.25,0.8,0.25,1)}\n@media(prefers-reduced-motion){.cdk-overlay-backdrop{transition-duration:1ms}}\n.cdk-overlay-backdrop-showing{opacity:1}\n@media(forced-colors:active){.cdk-overlay-backdrop-showing{opacity:.6}}\n.cdk-overlay-dark-backdrop{background:rgba(0,0,0,.32)}\n.cdk-overlay-transparent-backdrop{transition:visibility 1ms linear,opacity 1ms linear;visibility:hidden;opacity:1}\n.cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing,.cdk-high-contrast-active .cdk-overlay-transparent-backdrop{opacity:0;visibility:visible}\n.cdk-overlay-backdrop-noop-animation{transition:none}\n.cdk-overlay-connected-position-bounding-box{position:absolute;display:flex;flex-direction:column;min-width:1px;min-height:1px;z-index:1000}\n`;\n\ninterface IClientRect {\n bottom: number;\n height: number;\n left: number;\n right: number;\n top: number;\n width: number;\n x?: number;\n y?: number;\n}\n\ninterface IFlexibleConnectedPositionStrategyInternals {\n _getOriginPoint: (originRect: IClientRect, containerRect: IClientRect, position: unknown) => { x: number; y: number };\n _getOriginRect: () => IClientRect;\n}\n\nconst translateRectToBoundary = (rect: IClientRect, boundary: IClientRect): IClientRect => {\n const left = rect.left - boundary.left;\n const top = rect.top - boundary.top;\n\n return {\n bottom: top + rect.height,\n height: rect.height,\n left,\n right: left + rect.width,\n top,\n width: rect.width,\n x: left,\n y: top,\n };\n};\n\nconst getBoundaryRect = (overlayRoot: HTMLElement): IClientRect => {\n const { height, width } = overlayRoot.getBoundingClientRect();\n return {\n bottom: height,\n height,\n left: 0,\n right: width,\n top: 0,\n width,\n x: 0,\n y: 0,\n };\n};\n\nconst createBoundaryDocument = (document: Document, overlayRoot: HTMLElement): Document => {\n const boundaryDocumentElement = new Proxy(document.documentElement, {\n get: (target, property, receiver) => {\n if (property === 'clientHeight') {\n return overlayRoot.getBoundingClientRect().height;\n }\n if (property === 'clientWidth') {\n return overlayRoot.getBoundingClientRect().width;\n }\n return Reflect.get(target, property, receiver);\n },\n });\n\n return new Proxy(document, {\n get: (target, property, receiver) => {\n if (property === 'documentElement') {\n return boundaryDocumentElement;\n }\n return Reflect.get(target, property, receiver);\n },\n });\n};\n\nconst createBoundaryViewportRuler = (viewportRuler: ViewportRuler, overlayRoot: HTMLElement): ViewportRuler => {\n const boundaryViewportRuler = Object.create(viewportRuler) as ViewportRuler;\n boundaryViewportRuler.getViewportRect = () => getBoundaryRect(overlayRoot);\n boundaryViewportRuler.getViewportScrollPosition = () => ({ left: 0, top: 0 });\n boundaryViewportRuler.getViewportSize = () => {\n const { height, width } = getBoundaryRect(overlayRoot);\n return { height, width };\n };\n return boundaryViewportRuler;\n};\n\nconst adaptConnectedPositionStrategy = (\n strategy: FlexibleConnectedPositionStrategy,\n overlayRoot: HTMLElement,\n observeBoundary: (callback: () => void) => () => void,\n): FlexibleConnectedPositionStrategy => {\n const internals = strategy as unknown as IFlexibleConnectedPositionStrategyInternals;\n const getOriginRect = internals._getOriginRect.bind(strategy);\n const getOriginPoint = internals._getOriginPoint.bind(strategy);\n const attach = strategy.attach.bind(strategy);\n const detach = strategy.detach.bind(strategy);\n const dispose = strategy.dispose.bind(strategy);\n let stopObserving = () => {};\n internals._getOriginRect = () => {\n return translateRectToBoundary(getOriginRect(), overlayRoot.getBoundingClientRect());\n };\n internals._getOriginPoint = (originRect, _containerRect, position) => {\n return getOriginPoint(originRect, getBoundaryRect(overlayRoot), position);\n };\n strategy.attach = (overlayRef) => {\n attach(overlayRef);\n stopObserving();\n stopObserving = observeBoundary(() => strategy.apply());\n };\n strategy.detach = () => {\n stopObserving();\n stopObserving = () => {};\n detach();\n };\n strategy.dispose = () => {\n stopObserving();\n stopObserving = () => {};\n dispose();\n };\n\n return strategy;\n};\n\nclass MfOverlayPositionBuilder extends OverlayPositionBuilder {\n readonly #document: Document;\n readonly #overlayContainer: OverlayContainer;\n readonly #overlayRoot: HTMLElement;\n readonly #platform: Platform;\n readonly #viewportRuler: ViewportRuler;\n\n constructor(viewportRuler: ViewportRuler, document: Document, platform: Platform, overlayContainer: OverlayContainer, overlayRoot: HTMLElement) {\n super();\n this.#viewportRuler = viewportRuler;\n this.#document = document;\n this.#platform = platform;\n this.#overlayContainer = overlayContainer;\n this.#overlayRoot = overlayRoot;\n }\n\n override global(): GlobalPositionStrategy {\n return new GlobalPositionStrategy();\n }\n\n override flexibleConnectedTo(origin: FlexibleConnectedPositionStrategyOrigin): FlexibleConnectedPositionStrategy {\n const boundaryDocument = createBoundaryDocument(this.#document, this.#overlayRoot);\n const boundaryViewportRuler = createBoundaryViewportRuler(this.#viewportRuler, this.#overlayRoot);\n const strategy = new FlexibleConnectedPositionStrategy(origin, boundaryViewportRuler, boundaryDocument, this.#platform, this.#overlayContainer);\n\n const overlayContainer = this.#overlayContainer as MfOverlayContainer;\n return adaptConnectedPositionStrategy(strategy, this.#overlayRoot, (callback) => overlayContainer.observeBoundary(callback));\n }\n}\n\nclass MfOverlayContainer extends OverlayContainer {\n readonly #boundaryObservers = new Set<() => void>();\n readonly #overlayRoot: HTMLElement;\n #animationFrame: number | null = null;\n #boundaryRect: IClientRect | null = null;\n #restoreRootPosition: (() => void) | null = null;\n #shadowStyle: HTMLStyleElement | null = null;\n\n constructor(overlayRoot: HTMLElement) {\n super();\n this.#overlayRoot = overlayRoot;\n }\n\n override ngOnDestroy(): void {\n if (this.#animationFrame !== null) {\n this.#overlayRoot.ownerDocument.defaultView?.cancelAnimationFrame(this.#animationFrame);\n }\n this.#animationFrame = null;\n this.#boundaryObservers.clear();\n super.ngOnDestroy();\n this.#shadowStyle?.remove();\n this.#shadowStyle = null;\n this.#restoreRootPosition?.();\n this.#restoreRootPosition = null;\n }\n\n observeBoundary(callback: () => void): () => void {\n this.#boundaryObservers.add(callback);\n if (this.#boundaryObservers.size === 1) {\n this.#boundaryRect = this.#overlayRoot.getBoundingClientRect();\n this.#scheduleBoundaryCheck();\n }\n\n return () => {\n this.#boundaryObservers.delete(callback);\n if (this.#boundaryObservers.size === 0 && this.#animationFrame !== null) {\n this.#overlayRoot.ownerDocument.defaultView?.cancelAnimationFrame(this.#animationFrame);\n this.#animationFrame = null;\n this.#boundaryRect = null;\n }\n };\n }\n\n protected override _createContainer(): void {\n if (this.#overlayRoot.ownerDocument.defaultView?.getComputedStyle(this.#overlayRoot).position === 'static') {\n const previousPosition = this.#overlayRoot.style.position;\n this.#overlayRoot.style.position = 'relative';\n this.#restoreRootPosition = () => {\n this.#overlayRoot.style.position = previousPosition;\n };\n }\n\n const rootNode = this.#overlayRoot.getRootNode();\n const ShadowRootConstructor = this.#overlayRoot.ownerDocument.defaultView?.ShadowRoot;\n if (ShadowRootConstructor && rootNode instanceof ShadowRootConstructor) {\n const style = this._document.createElement('style');\n style.setAttribute('data-edyn-mf-cdk-overlay-styles', '');\n style.textContent = CDK_OVERLAY_STRUCTURAL_CSS;\n rootNode.appendChild(style);\n this.#shadowStyle = style;\n }\n\n const container = this._document.createElement('div');\n container.classList.add('cdk-overlay-container');\n container.style.inset = '0';\n container.style.position = 'absolute';\n this.#overlayRoot.appendChild(container);\n this._containerElement = container;\n }\n\n #scheduleBoundaryCheck(): void {\n const window = this.#overlayRoot.ownerDocument.defaultView;\n if (!window || this.#animationFrame !== null || this.#boundaryObservers.size === 0) {\n return;\n }\n\n this.#animationFrame = window.requestAnimationFrame(() => {\n this.#animationFrame = null;\n const previous = this.#boundaryRect;\n const current = this.#overlayRoot.getBoundingClientRect();\n this.#boundaryRect = current;\n\n if (\n previous &&\n (previous.height !== current.height || previous.left !== current.left || previous.top !== current.top || previous.width !== current.width)\n ) {\n for (const observer of this.#boundaryObservers) {\n observer();\n }\n }\n\n this.#scheduleBoundaryCheck();\n });\n }\n}\n\nconst isDocumentViewportRoot = (overlayRoot: HTMLElement): boolean => {\n return overlayRoot === overlayRoot.ownerDocument.body || overlayRoot === overlayRoot.ownerDocument.documentElement;\n};\n\nconst createOverlayContainer = (overlayRoot: HTMLElement): OverlayContainer => {\n return isDocumentViewportRoot(overlayRoot) ? new OverlayContainer() : new MfOverlayContainer(overlayRoot);\n};\n\nconst createOverlayPositionBuilder = (\n viewportRuler: ViewportRuler,\n document: Document,\n platform: Platform,\n overlayContainer: OverlayContainer,\n overlayRoot: HTMLElement,\n): OverlayPositionBuilder => {\n if (isDocumentViewportRoot(overlayRoot)) {\n return new OverlayPositionBuilder();\n }\n return new MfOverlayPositionBuilder(viewportRuler, document, platform, overlayContainer, overlayRoot);\n};\n\n// Hosted, the overlay root sits in the module's shadow root, so the providers every module already uses for overlays also\n// make rem lengths there follow the module's own root font size. They start with the module's injector, before its\n// first component renders and Angular adds component styles, and stop with it. The observers only rewrite CSS, so they\n// start outside Angular's zone: inside it, every DOM change in the module would run change detection, and a template\n// that renders new nodes on each check (an *ngFor over a getter, without trackBy) would never settle.\nconst followRootFontSizeOf = (overlayRoot: HTMLElement, destroyRef: DestroyRef, ngZone: NgZone): void => {\n const rootNode = overlayRoot.getRootNode();\n const ShadowRootConstructor = overlayRoot.ownerDocument.defaultView?.ShadowRoot;\n if (ShadowRootConstructor && rootNode instanceof ShadowRootConstructor) {\n destroyRef.onDestroy(ngZone.runOutsideAngular(() => followModuleRootFontSize(rootNode)));\n }\n};\n\nconst createTokenProviders = (overlayRootToken: ProviderToken<HTMLElement>): StaticProvider[] => {\n return [\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useFactory: (overlayRoot: HTMLElement, destroyRef: DestroyRef, ngZone: NgZone) => () => followRootFontSizeOf(overlayRoot, destroyRef, ngZone),\n deps: [overlayRootToken, DestroyRef, NgZone],\n },\n {\n provide: OverlayContainer,\n useFactory: createOverlayContainer,\n deps: [overlayRootToken],\n },\n {\n provide: OverlayPositionBuilder,\n useFactory: createOverlayPositionBuilder,\n deps: [ViewportRuler, DOCUMENT, Platform, OverlayContainer, overlayRootToken],\n },\n ];\n};\n\nexport const provideMfOverlayRoot = (overlayRoot?: HTMLElement): StaticProvider[] => {\n if (!overlayRoot) {\n return [];\n }\n\n return [\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useFactory: (destroyRef: DestroyRef, ngZone: NgZone) => () => followRootFontSizeOf(overlayRoot, destroyRef, ngZone),\n deps: [DestroyRef, NgZone],\n },\n {\n provide: OverlayContainer,\n useFactory: () => createOverlayContainer(overlayRoot),\n },\n {\n provide: OverlayPositionBuilder,\n useFactory: (viewportRuler: ViewportRuler, document: Document, platform: Platform, overlayContainer: OverlayContainer) => {\n return createOverlayPositionBuilder(viewportRuler, document, platform, overlayContainer, overlayRoot);\n },\n deps: [ViewportRuler, DOCUMENT, Platform, OverlayContainer],\n },\n ];\n};\n\nexport const provideMfOverlayRootFromToken = (overlayRootToken: ProviderToken<HTMLElement>): StaticProvider[] => {\n return createTokenProviders(overlayRootToken);\n};\n\nexport { CaseInsensitiveBasePathLocationStrategy, provideCaseInsensitiveBasePath } from './angular-location.js';\n"]}
|
|
@@ -10,8 +10,10 @@ export declare const followModuleRootFontSize: (root: ShadowRoot) => (() => void
|
|
|
10
10
|
* Adapts the CSS a module brings into its shadow root at runtime to the hosted page, for a host to call on each module
|
|
11
11
|
* shadow root it creates and stop on unmount: rem follows the module's own root font size (as followModuleRootFontSize
|
|
12
12
|
* does), and rules a library injects for the document root (`html { --mat-focus-indicator-display: block; }`), which
|
|
13
|
-
* never match inside a shadow root, move onto `:host` (see rescopeDocumentRootSelectors)
|
|
14
|
-
*
|
|
13
|
+
* never match inside a shadow root, move onto `:host` (see rescopeDocumentRootSelectors), and sticky tops written for
|
|
14
|
+
* the legacy navigation's top bar (`top: 49px`), in rules and inline styles, move up by that bar, which a hosted page
|
|
15
|
+
* does not have. Safe beside a module's own followModuleRootFontSize on the same root: every step is idempotent, and
|
|
16
|
+
* neither writes anything the other acts on.
|
|
15
17
|
*/
|
|
16
18
|
export declare const adaptHostedModuleStyles: (root: ShadowRoot) => (() => void);
|
|
17
19
|
//# sourceMappingURL=hosted-module-styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-module-styles.d.ts","sourceRoot":"","sources":["../src/hosted-module-styles.ts"],"names":[],"mappings":"AAiPA;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GAAI,MAAM,UAAU,KAAG,CAAC,MAAM,IAAI,CAEtE,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAAI,MAAM,UAAU,KAAG,CAAC,MAAM,IAAI,CAErE,CAAC","sourcesContent":["import { rescopeDocumentRootSelectors } from './document-root-selectors.js';\nimport {\n MF_ROOT_FONT_SIZE_PROPERTY,\n REM_LENGTH_HINT_PATTERN,\n ROOT_FONT_SIZE_DECLARATION_PATTERN,\n rewriteRemLengths,\n UNFOLLOWED_REM_PATTERN,\n} from './root-font-size.js';\n\nconst INLINE_REM_SELECTOR = '[style*=\"rem\" i]';\n\n// By class name, not instanceof: a root in another window (a frame, or a test's own window) has its own CSSFontFaceRule.\nconst isFontFaceRule = (rule: CSSRule): boolean => {\n return rule.constructor?.name === 'CSSFontFaceRule';\n};\n\n// Rule kinds are told apart by what they carry, not by class: @import has a sheet, style and keyframe rules have\n// declarations, and grouping rules (@media, @supports, @container, @layer, @keyframes, nesting) have child rules.\nconst importedSheetOf = (rule: CSSRule): CSSStyleSheet | undefined => {\n return 'styleSheet' in rule && rule.styleSheet ? (rule.styleSheet as CSSStyleSheet) : undefined;\n};\n\nconst declarationsOf = (rule: CSSRule): CSSStyleDeclaration | undefined => {\n return 'style' in rule && rule.style && !isFontFaceRule(rule) ? (rule.style as CSSStyleDeclaration) : undefined;\n};\n\nconst childRulesOf = (rule: CSSRule): CSSRuleList | undefined => {\n return 'cssRules' in rule && rule.cssRules ? (rule.cssRules as CSSRuleList) : undefined;\n};\n\nconst readRules = (sheet: CSSStyleSheet): CSSRuleList | undefined => {\n try {\n return sheet.cssRules;\n } catch {\n // A cross-origin sheet (a font service's @font-face list) cannot be read, and none of its rules are module rules.\n return undefined;\n }\n};\n\nconst walkRules = (sheet: CSSStyleSheet, visit: (rule: CSSRule) => void): void => {\n const walk = (rules: CSSRuleList): void => {\n for (const rule of Array.from(rules)) {\n const importedSheet = importedSheetOf(rule);\n const importedRules = importedSheet ? readRules(importedSheet) : undefined;\n if (importedRules) {\n walk(importedRules);\n }\n visit(rule);\n const childRules = childRulesOf(rule);\n if (childRules) {\n walk(childRules);\n }\n }\n };\n const rules = readRules(sheet);\n if (rules) {\n walk(rules);\n }\n};\n\n// Only declaration blocks change, through the CSSOM: @media, @container and @supports conditions keep their rem (var()\n// is invalid there, and a media query rem is the browser's initial size anyway), and !important stays with its value.\n// CSSOM changes are not DOM mutations, so no observer, this one or another on the same root, sees them.\nconst followRemInSheet = (sheet: CSSStyleSheet): void => {\n walkRules(sheet, (rule) => {\n const declarations = declarationsOf(rule);\n if (declarations && REM_LENGTH_HINT_PATTERN.test(declarations.cssText)) {\n const rewritten = rewriteRemLengths(declarations.cssText);\n if (rewritten !== declarations.cssText) {\n declarations.cssText = rewritten;\n }\n }\n });\n};\n\nconst rescopeDocumentRootRules = (sheet: CSSStyleSheet): void => {\n walkRules(sheet, (rule) => {\n if (!('selectorText' in rule) || typeof rule.selectorText !== 'string') {\n return;\n }\n const { selectorText } = rescopeDocumentRootSelectors(rule.selectorText);\n if (selectorText !== rule.selectorText) {\n (rule as CSSStyleRule).selectorText = selectorText;\n }\n });\n};\n\nconst declaresRootFontSize = (sheet: CSSStyleSheet): boolean => {\n let declares = false;\n walkRules(sheet, (rule) => {\n declares ||= !!declarationsOf(rule)?.getPropertyValue(MF_ROOT_FONT_SIZE_PROPERTY);\n });\n return declares;\n};\n\n// Inline styles carry rem too, from templates (`style=\"padding-bottom: 0.25rem !important\"`) and from style bindings\n// and code. The whole declaration block is rewritten through element.style, as for sheet rules: !important stays with\n// its value, and a shorthand that also holds var() (whose longhands read empty) is still seen. Material sets inline\n// styles constantly (ripples, overlay positions), so anything without an unfollowed rem length returns at once, and a\n// followed value never looks like work again, which is also why a second observer on the same root writes nothing.\nconst followInlineStyle = (element: Element): void => {\n const attribute = element.getAttribute('style');\n if (!attribute || !UNFOLLOWED_REM_PATTERN.test(attribute)) {\n return;\n }\n const style = (element as HTMLElement).style;\n const declarations = style?.cssText;\n if (!declarations) {\n return;\n }\n const rewritten = rewriteRemLengths(declarations);\n if (rewritten !== declarations) {\n style.cssText = rewritten;\n }\n};\n\nconst followInlineStylesWithin = (node: Node): void => {\n if (node.nodeType !== 1) {\n return;\n }\n const element = node as Element;\n followInlineStyle(element);\n if (element.firstElementChild) {\n for (const descendant of Array.from(element.querySelectorAll(INLINE_REM_SELECTOR))) {\n followInlineStyle(descendant);\n }\n }\n};\n\ntype TStyleOwner = HTMLLinkElement | HTMLStyleElement;\n\nconst isStyleOwner = (node: Node): node is TStyleOwner => {\n return node.nodeName === 'STYLE' || (node.nodeName === 'LINK' && (node as HTMLLinkElement).rel.split(/\\s+/).includes('stylesheet'));\n};\n\ninterface IAdaptStylesOptions {\n documentRootRules: boolean;\n}\n\nconst adaptShadowRootStyles = (root: ShadowRoot, { documentRootRules }: IAdaptStylesOptions): (() => void) => {\n // The root's own window, which need not be the global one (a frame, or a test's own window).\n const RootMutationObserver = root.ownerDocument.defaultView?.MutationObserver ?? MutationObserver;\n let followingRem = false;\n const remSheets = new WeakSet<CSSStyleSheet>();\n const rescopedSheets = new WeakSet<CSSStyleSheet>();\n const watchedStyles = new WeakSet<HTMLStyleElement>();\n\n const owners = (): TStyleOwner[] => Array.from(root.childNodes).filter(isStyleOwner);\n\n const sheetsOf = (styleOwners: TStyleOwner[]): CSSStyleSheet[] => {\n return [...(root.adoptedStyleSheets ?? []), ...styleOwners.map((owner) => owner.sheet).filter((sheet): sheet is CSSStyleSheet => !!sheet)];\n };\n\n // A <style>'s own text is the cheap check; linked and adopted sheets have only their rules.\n const findsRootFontSize = (styleOwners: TStyleOwner[]): boolean => {\n const styles = styleOwners.filter((owner): owner is HTMLStyleElement => owner.nodeName === 'STYLE');\n if (styles.some((style) => ROOT_FONT_SIZE_DECLARATION_PATTERN.test(style.textContent ?? ''))) {\n return true;\n }\n const linkedSheets = styleOwners.filter((owner) => owner.nodeName === 'LINK').map((owner) => owner.sheet);\n return [...(root.adoptedStyleSheets ?? []), ...linkedSheets].some((sheet) => !!sheet && declaresRootFontSize(sheet));\n };\n\n // Started only once the module's CSS declares a root size, so a module without one pays nothing. An element gets its\n // template styles before it is inserted, so insertions are scanned as well as later style attribute changes.\n let inlineObserver: MutationObserver | undefined;\n const followInlineStyles = (): void => {\n for (const element of Array.from(root.querySelectorAll(INLINE_REM_SELECTOR))) {\n followInlineStyle(element);\n }\n inlineObserver = new RootMutationObserver((records) => {\n for (const record of records) {\n if (record.type === 'attributes') {\n followInlineStyle(record.target as Element);\n } else {\n for (const node of Array.from(record.addedNodes)) {\n followInlineStylesWithin(node);\n }\n }\n }\n // Only this callback ran since the records were delivered, so what is queued now are its own rewrites.\n inlineObserver?.takeRecords();\n });\n inlineObserver.observe(root, { attributeFilter: ['style'], attributes: true, childList: true, subtree: true });\n };\n\n const observer = new RootMutationObserver(() => update());\n\n const update = (): void => {\n const styleOwners = owners();\n for (const owner of styleOwners) {\n if (owner.nodeName === 'STYLE' && !watchedStyles.has(owner as HTMLStyleElement)) {\n // Replacing a <style>'s text gives it a new sheet, which must be adapted again.\n observer.observe(owner, { characterData: true, childList: true, subtree: true });\n watchedStyles.add(owner as HTMLStyleElement);\n }\n }\n\n const sheets = sheetsOf(styleOwners);\n if (documentRootRules) {\n for (const sheet of sheets) {\n if (!rescopedSheets.has(sheet)) {\n rescopeDocumentRootRules(sheet);\n rescopedSheets.add(sheet);\n }\n }\n }\n\n followingRem ||= findsRootFontSize(styleOwners);\n if (!followingRem) {\n return;\n }\n if (!inlineObserver) {\n followInlineStyles();\n }\n for (const sheet of sheets) {\n if (!remSheets.has(sheet)) {\n followRemInSheet(sheet);\n remSheets.add(sheet);\n }\n }\n };\n\n // A <link> sheet has no rules until it loads; load does not bubble, so it is caught on the way down.\n const onLoad = (event: Event): void => {\n if (event.target instanceof Node && isStyleOwner(event.target)) {\n update();\n }\n };\n\n observer.observe(root, { childList: true });\n root.addEventListener('load', onLoad, true);\n update();\n\n return () => {\n observer.disconnect();\n inlineObserver?.disconnect();\n root.removeEventListener('load', onLoad, true);\n };\n};\n\n/**\n * Makes rem lengths in a hosted module's shadow root follow the root font size its own page had, once the module's\n * CSS declares one (see MF_ROOT_FONT_SIZE_PROPERTY): in stylesheets already in the root and every one added or changed\n * later, such as the component styles Angular adds as components first render, and in inline style attributes,\n * including ones inserted or changed later. A module whose CSS never sizes its root is left untouched. Returns a\n * function that stops following; rewritten rules and styles stay rewritten.\n */\nexport const followModuleRootFontSize = (root: ShadowRoot): (() => void) => {\n return adaptShadowRootStyles(root, { documentRootRules: false });\n};\n\n/**\n * Adapts the CSS a module brings into its shadow root at runtime to the hosted page, for a host to call on each module\n * shadow root it creates and stop on unmount: rem follows the module's own root font size (as followModuleRootFontSize\n * does), and rules a library injects for the document root (`html { --mat-focus-indicator-display: block; }`), which\n * never match inside a shadow root, move onto `:host` (see rescopeDocumentRootSelectors). Safe beside a module's own\n * followModuleRootFontSize on the same root: every step is idempotent, and neither writes anything the other acts on.\n */\nexport const adaptHostedModuleStyles = (root: ShadowRoot): (() => void) => {\n return adaptShadowRootStyles(root, { documentRootRules: true });\n};\n"]}
|
|
1
|
+
{"version":3,"file":"hosted-module-styles.d.ts","sourceRoot":"","sources":["../src/hosted-module-styles.ts"],"names":[],"mappings":"AAyUA;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GAAI,MAAM,UAAU,KAAG,CAAC,MAAM,IAAI,CAEtE,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,GAAI,MAAM,UAAU,KAAG,CAAC,MAAM,IAAI,CAErE,CAAC","sourcesContent":["import { rescopeDocumentRootSelectors } from './document-root-selectors.js';\nimport {\n MF_ROOT_FONT_SIZE_PROPERTY,\n REM_LENGTH_HINT_PATTERN,\n ROOT_FONT_SIZE_DECLARATION_PATTERN,\n rewriteRemLengths,\n UNFOLLOWED_REM_PATTERN,\n} from './root-font-size.js';\n\nconst INLINE_REM_SELECTOR = '[style*=\"rem\" i]';\nconst INLINE_STICKY_SELECTOR = '[style*=\"sticky\" i]';\n\n// The legacy navigation's top bar (@edyn/navigation: `.mat-sidenav-container { padding-top: 49px }`). Old pages scrolled\n// under it, so their sticky headers stuck below it with `top: 49px` (or 50px, one pixel lower). Hosted, a module scrolls\n// in the host's content area, which has no bar inside it, so those headers would stick 49px too low.\nconst LEGACY_NAVIGATION_BAR_HEIGHT = 49;\nconst PIXEL_LENGTH_PATTERN = /^(\\d+(?:\\.\\d+)?)px$/i;\n\n// A sticky top of at least the bar's height moves up by the bar; smaller ones (0, 1px) belong to pages or panels that\n// scrolled below the bar already, and anything else (var(), %, calc()) is a module's own choice. Returns whether the\n// declarations changed.\nconst liftStickyTop = (declarations: CSSStyleDeclaration): boolean => {\n if (!/sticky/i.test(declarations.getPropertyValue('position'))) {\n return false;\n }\n const top = PIXEL_LENGTH_PATTERN.exec(declarations.getPropertyValue('top').trim());\n const pixels = top ? Number(top[1]) : Number.NaN;\n if (!(pixels >= LEGACY_NAVIGATION_BAR_HEIGHT)) {\n return false;\n }\n declarations.setProperty('top', `${pixels - LEGACY_NAVIGATION_BAR_HEIGHT}px`, declarations.getPropertyPriority('top'));\n return true;\n};\n\n// By class name, not instanceof: a root in another window (a frame, or a test's own window) has its own CSSFontFaceRule.\nconst isFontFaceRule = (rule: CSSRule): boolean => {\n return rule.constructor?.name === 'CSSFontFaceRule';\n};\n\n// Rule kinds are told apart by what they carry, not by class: @import has a sheet, style and keyframe rules have\n// declarations, and grouping rules (@media, @supports, @container, @layer, @keyframes, nesting) have child rules.\nconst importedSheetOf = (rule: CSSRule): CSSStyleSheet | undefined => {\n return 'styleSheet' in rule && rule.styleSheet ? (rule.styleSheet as CSSStyleSheet) : undefined;\n};\n\nconst declarationsOf = (rule: CSSRule): CSSStyleDeclaration | undefined => {\n return 'style' in rule && rule.style && !isFontFaceRule(rule) ? (rule.style as CSSStyleDeclaration) : undefined;\n};\n\nconst childRulesOf = (rule: CSSRule): CSSRuleList | undefined => {\n return 'cssRules' in rule && rule.cssRules ? (rule.cssRules as CSSRuleList) : undefined;\n};\n\nconst readRules = (sheet: CSSStyleSheet): CSSRuleList | undefined => {\n try {\n return sheet.cssRules;\n } catch {\n // A cross-origin sheet (a font service's @font-face list) cannot be read, and none of its rules are module rules.\n return undefined;\n }\n};\n\nconst walkRules = (sheet: CSSStyleSheet, visit: (rule: CSSRule) => void): void => {\n const walk = (rules: CSSRuleList): void => {\n for (const rule of Array.from(rules)) {\n const importedSheet = importedSheetOf(rule);\n const importedRules = importedSheet ? readRules(importedSheet) : undefined;\n if (importedRules) {\n walk(importedRules);\n }\n visit(rule);\n const childRules = childRulesOf(rule);\n if (childRules) {\n walk(childRules);\n }\n }\n };\n const rules = readRules(sheet);\n if (rules) {\n walk(rules);\n }\n};\n\n// Only declaration blocks change, through the CSSOM: @media, @container and @supports conditions keep their rem (var()\n// is invalid there, and a media query rem is the browser's initial size anyway), and !important stays with its value.\n// CSSOM changes are not DOM mutations, so no observer, this one or another on the same root, sees them.\nconst followRemInSheet = (sheet: CSSStyleSheet): void => {\n walkRules(sheet, (rule) => {\n const declarations = declarationsOf(rule);\n if (declarations && REM_LENGTH_HINT_PATTERN.test(declarations.cssText)) {\n const rewritten = rewriteRemLengths(declarations.cssText);\n if (rewritten !== declarations.cssText) {\n declarations.cssText = rewritten;\n }\n }\n });\n};\n\nconst rescopeDocumentRootRules = (sheet: CSSStyleSheet): void => {\n walkRules(sheet, (rule) => {\n if (!('selectorText' in rule) || typeof rule.selectorText !== 'string') {\n return;\n }\n const { selectorText } = rescopeDocumentRootSelectors(rule.selectorText);\n if (selectorText !== rule.selectorText) {\n (rule as CSSStyleRule).selectorText = selectorText;\n }\n });\n};\n\nconst liftStickyTopsInSheet = (sheet: CSSStyleSheet): void => {\n walkRules(sheet, (rule) => {\n const declarations = declarationsOf(rule);\n if (declarations && /sticky/i.test(declarations.cssText)) {\n liftStickyTop(declarations);\n }\n });\n};\n\nconst declaresRootFontSize = (sheet: CSSStyleSheet): boolean => {\n let declares = false;\n walkRules(sheet, (rule) => {\n declares ||= !!declarationsOf(rule)?.getPropertyValue(MF_ROOT_FONT_SIZE_PROPERTY);\n });\n return declares;\n};\n\n// Inline styles carry rem too, from templates (`style=\"padding-bottom: 0.25rem !important\"`) and from style bindings\n// and code. The whole declaration block is rewritten through element.style, as for sheet rules: !important stays with\n// its value, and a shorthand that also holds var() (whose longhands read empty) is still seen. Material sets inline\n// styles constantly (ripples, overlay positions), so anything without an unfollowed rem length returns at once, and a\n// followed value never looks like work again, which is also why a second observer on the same root writes nothing.\nconst followInlineStyle = (element: Element): void => {\n const attribute = element.getAttribute('style');\n if (!attribute || !UNFOLLOWED_REM_PATTERN.test(attribute)) {\n return;\n }\n const style = (element as HTMLElement).style;\n const declarations = style?.cssText;\n if (!declarations) {\n return;\n }\n const rewritten = rewriteRemLengths(declarations);\n if (rewritten !== declarations) {\n style.cssText = rewritten;\n }\n};\n\nconst followInlineStylesWithin = (node: Node): void => {\n if (node.nodeType !== 1) {\n return;\n }\n const element = node as Element;\n followInlineStyle(element);\n if (element.firstElementChild) {\n for (const descendant of Array.from(element.querySelectorAll(INLINE_REM_SELECTOR))) {\n followInlineStyle(descendant);\n }\n }\n};\n\ntype TStyleOwner = HTMLLinkElement | HTMLStyleElement;\n\nconst isStyleOwner = (node: Node): node is TStyleOwner => {\n return node.nodeName === 'STYLE' || (node.nodeName === 'LINK' && (node as HTMLLinkElement).rel.split(/\\s+/).includes('stylesheet'));\n};\n\ninterface IAdaptStylesOptions {\n documentRootRules: boolean;\n stickyTops: boolean;\n}\n\n// Sticky headers set from code carry their top inline (`style.cssText = 'position: sticky; top: 50px'` in the modules'\n// position-sticky directives). Each value a module writes moves up once: the attribute this wrote is remembered, so its\n// own change, which the observer sees too, is not lifted again, while a value the module writes later is.\nconst liftInlineStickyTops = (root: ShadowRoot, RootMutationObserver: typeof MutationObserver): MutationObserver => {\n const lifted = new WeakMap<Element, string>();\n const lift = (element: Element): void => {\n const attribute = element.getAttribute('style');\n if (!attribute || !/sticky/i.test(attribute) || lifted.get(element) === attribute) {\n return;\n }\n const style = (element as HTMLElement).style;\n if (style && liftStickyTop(style)) {\n lifted.set(element, element.getAttribute('style') ?? '');\n }\n };\n const liftWithin = (node: Node): void => {\n if (node.nodeType !== 1) {\n return;\n }\n lift(node as Element);\n for (const descendant of Array.from((node as Element).querySelectorAll(INLINE_STICKY_SELECTOR))) {\n lift(descendant);\n }\n };\n\n for (const element of Array.from(root.querySelectorAll(INLINE_STICKY_SELECTOR))) {\n lift(element);\n }\n const observer = new RootMutationObserver((records) => {\n for (const record of records) {\n if (record.type === 'attributes') {\n lift(record.target as Element);\n } else {\n for (const node of Array.from(record.addedNodes)) {\n liftWithin(node);\n }\n }\n }\n });\n observer.observe(root, { attributeFilter: ['style'], attributes: true, childList: true, subtree: true });\n return observer;\n};\n\nconst adaptShadowRootStyles = (root: ShadowRoot, { documentRootRules, stickyTops }: IAdaptStylesOptions): (() => void) => {\n // The root's own window, which need not be the global one (a frame, or a test's own window).\n const RootMutationObserver = root.ownerDocument.defaultView?.MutationObserver ?? MutationObserver;\n let followingRem = false;\n const remSheets = new WeakSet<CSSStyleSheet>();\n const rescopedSheets = new WeakSet<CSSStyleSheet>();\n const stickySheets = new WeakSet<CSSStyleSheet>();\n const watchedStyles = new WeakSet<HTMLStyleElement>();\n\n const owners = (): TStyleOwner[] => Array.from(root.childNodes).filter(isStyleOwner);\n\n const sheetsOf = (styleOwners: TStyleOwner[]): CSSStyleSheet[] => {\n return [...(root.adoptedStyleSheets ?? []), ...styleOwners.map((owner) => owner.sheet).filter((sheet): sheet is CSSStyleSheet => !!sheet)];\n };\n\n // A <style>'s own text is the cheap check; linked and adopted sheets have only their rules.\n const findsRootFontSize = (styleOwners: TStyleOwner[]): boolean => {\n const styles = styleOwners.filter((owner): owner is HTMLStyleElement => owner.nodeName === 'STYLE');\n if (styles.some((style) => ROOT_FONT_SIZE_DECLARATION_PATTERN.test(style.textContent ?? ''))) {\n return true;\n }\n const linkedSheets = styleOwners.filter((owner) => owner.nodeName === 'LINK').map((owner) => owner.sheet);\n return [...(root.adoptedStyleSheets ?? []), ...linkedSheets].some((sheet) => !!sheet && declaresRootFontSize(sheet));\n };\n\n // Started only once the module's CSS declares a root size, so a module without one pays nothing. An element gets its\n // template styles before it is inserted, so insertions are scanned as well as later style attribute changes.\n let inlineObserver: MutationObserver | undefined;\n const followInlineStyles = (): void => {\n for (const element of Array.from(root.querySelectorAll(INLINE_REM_SELECTOR))) {\n followInlineStyle(element);\n }\n inlineObserver = new RootMutationObserver((records) => {\n for (const record of records) {\n if (record.type === 'attributes') {\n followInlineStyle(record.target as Element);\n } else {\n for (const node of Array.from(record.addedNodes)) {\n followInlineStylesWithin(node);\n }\n }\n }\n // Only this callback ran since the records were delivered, so what is queued now are its own rewrites.\n inlineObserver?.takeRecords();\n });\n inlineObserver.observe(root, { attributeFilter: ['style'], attributes: true, childList: true, subtree: true });\n };\n\n const observer = new RootMutationObserver(() => update());\n\n const update = (): void => {\n const styleOwners = owners();\n for (const owner of styleOwners) {\n if (owner.nodeName === 'STYLE' && !watchedStyles.has(owner as HTMLStyleElement)) {\n // Replacing a <style>'s text gives it a new sheet, which must be adapted again.\n observer.observe(owner, { characterData: true, childList: true, subtree: true });\n watchedStyles.add(owner as HTMLStyleElement);\n }\n }\n\n const sheets = sheetsOf(styleOwners);\n if (documentRootRules) {\n for (const sheet of sheets) {\n if (!rescopedSheets.has(sheet)) {\n rescopeDocumentRootRules(sheet);\n rescopedSheets.add(sheet);\n }\n }\n }\n\n if (stickyTops) {\n for (const sheet of sheets) {\n if (!stickySheets.has(sheet)) {\n liftStickyTopsInSheet(sheet);\n stickySheets.add(sheet);\n }\n }\n }\n\n followingRem ||= findsRootFontSize(styleOwners);\n if (!followingRem) {\n return;\n }\n if (!inlineObserver) {\n followInlineStyles();\n }\n for (const sheet of sheets) {\n if (!remSheets.has(sheet)) {\n followRemInSheet(sheet);\n remSheets.add(sheet);\n }\n }\n };\n\n // A <link> sheet has no rules until it loads; load does not bubble, so it is caught on the way down.\n const onLoad = (event: Event): void => {\n if (event.target instanceof Node && isStyleOwner(event.target)) {\n update();\n }\n };\n\n observer.observe(root, { childList: true });\n root.addEventListener('load', onLoad, true);\n update();\n const stickyObserver = stickyTops ? liftInlineStickyTops(root, RootMutationObserver) : undefined;\n\n return () => {\n observer.disconnect();\n inlineObserver?.disconnect();\n stickyObserver?.disconnect();\n root.removeEventListener('load', onLoad, true);\n };\n};\n\n/**\n * Makes rem lengths in a hosted module's shadow root follow the root font size its own page had, once the module's\n * CSS declares one (see MF_ROOT_FONT_SIZE_PROPERTY): in stylesheets already in the root and every one added or changed\n * later, such as the component styles Angular adds as components first render, and in inline style attributes,\n * including ones inserted or changed later. A module whose CSS never sizes its root is left untouched. Returns a\n * function that stops following; rewritten rules and styles stay rewritten.\n */\nexport const followModuleRootFontSize = (root: ShadowRoot): (() => void) => {\n return adaptShadowRootStyles(root, { documentRootRules: false, stickyTops: false });\n};\n\n/**\n * Adapts the CSS a module brings into its shadow root at runtime to the hosted page, for a host to call on each module\n * shadow root it creates and stop on unmount: rem follows the module's own root font size (as followModuleRootFontSize\n * does), and rules a library injects for the document root (`html { --mat-focus-indicator-display: block; }`), which\n * never match inside a shadow root, move onto `:host` (see rescopeDocumentRootSelectors), and sticky tops written for\n * the legacy navigation's top bar (`top: 49px`), in rules and inline styles, move up by that bar, which a hosted page\n * does not have. Safe beside a module's own followModuleRootFontSize on the same root: every step is idempotent, and\n * neither writes anything the other acts on.\n */\nexport const adaptHostedModuleStyles = (root: ShadowRoot): (() => void) => {\n return adaptShadowRootStyles(root, { documentRootRules: true, stickyTops: true });\n};\n"]}
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import { rescopeDocumentRootSelectors } from './document-root-selectors.js';
|
|
2
2
|
import { MF_ROOT_FONT_SIZE_PROPERTY, REM_LENGTH_HINT_PATTERN, ROOT_FONT_SIZE_DECLARATION_PATTERN, rewriteRemLengths, UNFOLLOWED_REM_PATTERN, } from './root-font-size.js';
|
|
3
3
|
const INLINE_REM_SELECTOR = '[style*="rem" i]';
|
|
4
|
+
const INLINE_STICKY_SELECTOR = '[style*="sticky" i]';
|
|
5
|
+
// The legacy navigation's top bar (@edyn/navigation: `.mat-sidenav-container { padding-top: 49px }`). Old pages scrolled
|
|
6
|
+
// under it, so their sticky headers stuck below it with `top: 49px` (or 50px, one pixel lower). Hosted, a module scrolls
|
|
7
|
+
// in the host's content area, which has no bar inside it, so those headers would stick 49px too low.
|
|
8
|
+
const LEGACY_NAVIGATION_BAR_HEIGHT = 49;
|
|
9
|
+
const PIXEL_LENGTH_PATTERN = /^(\d+(?:\.\d+)?)px$/i;
|
|
10
|
+
// A sticky top of at least the bar's height moves up by the bar; smaller ones (0, 1px) belong to pages or panels that
|
|
11
|
+
// scrolled below the bar already, and anything else (var(), %, calc()) is a module's own choice. Returns whether the
|
|
12
|
+
// declarations changed.
|
|
13
|
+
const liftStickyTop = (declarations) => {
|
|
14
|
+
if (!/sticky/i.test(declarations.getPropertyValue('position'))) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const top = PIXEL_LENGTH_PATTERN.exec(declarations.getPropertyValue('top').trim());
|
|
18
|
+
const pixels = top ? Number(top[1]) : Number.NaN;
|
|
19
|
+
if (!(pixels >= LEGACY_NAVIGATION_BAR_HEIGHT)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
declarations.setProperty('top', `${pixels - LEGACY_NAVIGATION_BAR_HEIGHT}px`, declarations.getPropertyPriority('top'));
|
|
23
|
+
return true;
|
|
24
|
+
};
|
|
4
25
|
// By class name, not instanceof: a root in another window (a frame, or a test's own window) has its own CSSFontFaceRule.
|
|
5
26
|
const isFontFaceRule = (rule) => {
|
|
6
27
|
return rule.constructor?.name === 'CSSFontFaceRule';
|
|
@@ -70,6 +91,14 @@ const rescopeDocumentRootRules = (sheet) => {
|
|
|
70
91
|
}
|
|
71
92
|
});
|
|
72
93
|
};
|
|
94
|
+
const liftStickyTopsInSheet = (sheet) => {
|
|
95
|
+
walkRules(sheet, (rule) => {
|
|
96
|
+
const declarations = declarationsOf(rule);
|
|
97
|
+
if (declarations && /sticky/i.test(declarations.cssText)) {
|
|
98
|
+
liftStickyTop(declarations);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
};
|
|
73
102
|
const declaresRootFontSize = (sheet) => {
|
|
74
103
|
let declares = false;
|
|
75
104
|
walkRules(sheet, (rule) => {
|
|
@@ -112,12 +141,55 @@ const followInlineStylesWithin = (node) => {
|
|
|
112
141
|
const isStyleOwner = (node) => {
|
|
113
142
|
return node.nodeName === 'STYLE' || (node.nodeName === 'LINK' && node.rel.split(/\s+/).includes('stylesheet'));
|
|
114
143
|
};
|
|
115
|
-
|
|
144
|
+
// Sticky headers set from code carry their top inline (`style.cssText = 'position: sticky; top: 50px'` in the modules'
|
|
145
|
+
// position-sticky directives). Each value a module writes moves up once: the attribute this wrote is remembered, so its
|
|
146
|
+
// own change, which the observer sees too, is not lifted again, while a value the module writes later is.
|
|
147
|
+
const liftInlineStickyTops = (root, RootMutationObserver) => {
|
|
148
|
+
const lifted = new WeakMap();
|
|
149
|
+
const lift = (element) => {
|
|
150
|
+
const attribute = element.getAttribute('style');
|
|
151
|
+
if (!attribute || !/sticky/i.test(attribute) || lifted.get(element) === attribute) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const style = element.style;
|
|
155
|
+
if (style && liftStickyTop(style)) {
|
|
156
|
+
lifted.set(element, element.getAttribute('style') ?? '');
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const liftWithin = (node) => {
|
|
160
|
+
if (node.nodeType !== 1) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
lift(node);
|
|
164
|
+
for (const descendant of Array.from(node.querySelectorAll(INLINE_STICKY_SELECTOR))) {
|
|
165
|
+
lift(descendant);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
for (const element of Array.from(root.querySelectorAll(INLINE_STICKY_SELECTOR))) {
|
|
169
|
+
lift(element);
|
|
170
|
+
}
|
|
171
|
+
const observer = new RootMutationObserver((records) => {
|
|
172
|
+
for (const record of records) {
|
|
173
|
+
if (record.type === 'attributes') {
|
|
174
|
+
lift(record.target);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
for (const node of Array.from(record.addedNodes)) {
|
|
178
|
+
liftWithin(node);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
observer.observe(root, { attributeFilter: ['style'], attributes: true, childList: true, subtree: true });
|
|
184
|
+
return observer;
|
|
185
|
+
};
|
|
186
|
+
const adaptShadowRootStyles = (root, { documentRootRules, stickyTops }) => {
|
|
116
187
|
// The root's own window, which need not be the global one (a frame, or a test's own window).
|
|
117
188
|
const RootMutationObserver = root.ownerDocument.defaultView?.MutationObserver ?? MutationObserver;
|
|
118
189
|
let followingRem = false;
|
|
119
190
|
const remSheets = new WeakSet();
|
|
120
191
|
const rescopedSheets = new WeakSet();
|
|
192
|
+
const stickySheets = new WeakSet();
|
|
121
193
|
const watchedStyles = new WeakSet();
|
|
122
194
|
const owners = () => Array.from(root.childNodes).filter(isStyleOwner);
|
|
123
195
|
const sheetsOf = (styleOwners) => {
|
|
@@ -174,6 +246,14 @@ const adaptShadowRootStyles = (root, { documentRootRules }) => {
|
|
|
174
246
|
}
|
|
175
247
|
}
|
|
176
248
|
}
|
|
249
|
+
if (stickyTops) {
|
|
250
|
+
for (const sheet of sheets) {
|
|
251
|
+
if (!stickySheets.has(sheet)) {
|
|
252
|
+
liftStickyTopsInSheet(sheet);
|
|
253
|
+
stickySheets.add(sheet);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
177
257
|
followingRem ||= findsRootFontSize(styleOwners);
|
|
178
258
|
if (!followingRem) {
|
|
179
259
|
return;
|
|
@@ -197,9 +277,11 @@ const adaptShadowRootStyles = (root, { documentRootRules }) => {
|
|
|
197
277
|
observer.observe(root, { childList: true });
|
|
198
278
|
root.addEventListener('load', onLoad, true);
|
|
199
279
|
update();
|
|
280
|
+
const stickyObserver = stickyTops ? liftInlineStickyTops(root, RootMutationObserver) : undefined;
|
|
200
281
|
return () => {
|
|
201
282
|
observer.disconnect();
|
|
202
283
|
inlineObserver?.disconnect();
|
|
284
|
+
stickyObserver?.disconnect();
|
|
203
285
|
root.removeEventListener('load', onLoad, true);
|
|
204
286
|
};
|
|
205
287
|
};
|
|
@@ -211,16 +293,18 @@ const adaptShadowRootStyles = (root, { documentRootRules }) => {
|
|
|
211
293
|
* function that stops following; rewritten rules and styles stay rewritten.
|
|
212
294
|
*/
|
|
213
295
|
export const followModuleRootFontSize = (root) => {
|
|
214
|
-
return adaptShadowRootStyles(root, { documentRootRules: false });
|
|
296
|
+
return adaptShadowRootStyles(root, { documentRootRules: false, stickyTops: false });
|
|
215
297
|
};
|
|
216
298
|
/**
|
|
217
299
|
* Adapts the CSS a module brings into its shadow root at runtime to the hosted page, for a host to call on each module
|
|
218
300
|
* shadow root it creates and stop on unmount: rem follows the module's own root font size (as followModuleRootFontSize
|
|
219
301
|
* does), and rules a library injects for the document root (`html { --mat-focus-indicator-display: block; }`), which
|
|
220
|
-
* never match inside a shadow root, move onto `:host` (see rescopeDocumentRootSelectors)
|
|
221
|
-
*
|
|
302
|
+
* never match inside a shadow root, move onto `:host` (see rescopeDocumentRootSelectors), and sticky tops written for
|
|
303
|
+
* the legacy navigation's top bar (`top: 49px`), in rules and inline styles, move up by that bar, which a hosted page
|
|
304
|
+
* does not have. Safe beside a module's own followModuleRootFontSize on the same root: every step is idempotent, and
|
|
305
|
+
* neither writes anything the other acts on.
|
|
222
306
|
*/
|
|
223
307
|
export const adaptHostedModuleStyles = (root) => {
|
|
224
|
-
return adaptShadowRootStyles(root, { documentRootRules: true });
|
|
308
|
+
return adaptShadowRootStyles(root, { documentRootRules: true, stickyTops: true });
|
|
225
309
|
};
|
|
226
310
|
//# sourceMappingURL=hosted-module-styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-module-styles.js","sourceRoot":"","sources":["../src/hosted-module-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,kCAAkC,EAClC,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAE/C,yHAAyH;AACzH,MAAM,cAAc,GAAG,CAAC,IAAa,EAAW,EAAE;IAChD,OAAO,IAAI,CAAC,WAAW,EAAE,IAAI,KAAK,iBAAiB,CAA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E,MAAM,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,IAAgB,EAAgB,EAAE;IACzE,OAAO,qBAAqB,CAAC,IAAI,EAAE,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,CAAC;AACnE,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,IAAgB,EAAgB,EAAE;IACxE,OAAO,qBAAqB,CAAC,IAAI,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;AAClE,CAAC,CAAC","sourcesContent":["import { rescopeDocumentRootSelectors } from './document-root-selectors.js';\nimport {\n MF_ROOT_FONT_SIZE_PROPERTY,\n REM_LENGTH_HINT_PATTERN,\n ROOT_FONT_SIZE_DECLARATION_PATTERN,\n rewriteRemLengths,\n UNFOLLOWED_REM_PATTERN,\n} from './root-font-size.js';\n\nconst INLINE_REM_SELECTOR = '[style*=\"rem\" i]';\n\n// By class name, not instanceof: a root in another window (a frame, or a test's own window) has its own CSSFontFaceRule.\nconst isFontFaceRule = (rule: CSSRule): boolean => {\n return rule.constructor?.name === 'CSSFontFaceRule';\n};\n\n// Rule kinds are told apart by what they carry, not by class: @import has a sheet, style and keyframe rules have\n// declarations, and grouping rules (@media, @supports, @container, @layer, @keyframes, nesting) have child rules.\nconst importedSheetOf = (rule: CSSRule): CSSStyleSheet | undefined => {\n return 'styleSheet' in rule && rule.styleSheet ? (rule.styleSheet as CSSStyleSheet) : undefined;\n};\n\nconst declarationsOf = (rule: CSSRule): CSSStyleDeclaration | undefined => {\n return 'style' in rule && rule.style && !isFontFaceRule(rule) ? (rule.style as CSSStyleDeclaration) : undefined;\n};\n\nconst childRulesOf = (rule: CSSRule): CSSRuleList | undefined => {\n return 'cssRules' in rule && rule.cssRules ? (rule.cssRules as CSSRuleList) : undefined;\n};\n\nconst readRules = (sheet: CSSStyleSheet): CSSRuleList | undefined => {\n try {\n return sheet.cssRules;\n } catch {\n // A cross-origin sheet (a font service's @font-face list) cannot be read, and none of its rules are module rules.\n return undefined;\n }\n};\n\nconst walkRules = (sheet: CSSStyleSheet, visit: (rule: CSSRule) => void): void => {\n const walk = (rules: CSSRuleList): void => {\n for (const rule of Array.from(rules)) {\n const importedSheet = importedSheetOf(rule);\n const importedRules = importedSheet ? readRules(importedSheet) : undefined;\n if (importedRules) {\n walk(importedRules);\n }\n visit(rule);\n const childRules = childRulesOf(rule);\n if (childRules) {\n walk(childRules);\n }\n }\n };\n const rules = readRules(sheet);\n if (rules) {\n walk(rules);\n }\n};\n\n// Only declaration blocks change, through the CSSOM: @media, @container and @supports conditions keep their rem (var()\n// is invalid there, and a media query rem is the browser's initial size anyway), and !important stays with its value.\n// CSSOM changes are not DOM mutations, so no observer, this one or another on the same root, sees them.\nconst followRemInSheet = (sheet: CSSStyleSheet): void => {\n walkRules(sheet, (rule) => {\n const declarations = declarationsOf(rule);\n if (declarations && REM_LENGTH_HINT_PATTERN.test(declarations.cssText)) {\n const rewritten = rewriteRemLengths(declarations.cssText);\n if (rewritten !== declarations.cssText) {\n declarations.cssText = rewritten;\n }\n }\n });\n};\n\nconst rescopeDocumentRootRules = (sheet: CSSStyleSheet): void => {\n walkRules(sheet, (rule) => {\n if (!('selectorText' in rule) || typeof rule.selectorText !== 'string') {\n return;\n }\n const { selectorText } = rescopeDocumentRootSelectors(rule.selectorText);\n if (selectorText !== rule.selectorText) {\n (rule as CSSStyleRule).selectorText = selectorText;\n }\n });\n};\n\nconst declaresRootFontSize = (sheet: CSSStyleSheet): boolean => {\n let declares = false;\n walkRules(sheet, (rule) => {\n declares ||= !!declarationsOf(rule)?.getPropertyValue(MF_ROOT_FONT_SIZE_PROPERTY);\n });\n return declares;\n};\n\n// Inline styles carry rem too, from templates (`style=\"padding-bottom: 0.25rem !important\"`) and from style bindings\n// and code. The whole declaration block is rewritten through element.style, as for sheet rules: !important stays with\n// its value, and a shorthand that also holds var() (whose longhands read empty) is still seen. Material sets inline\n// styles constantly (ripples, overlay positions), so anything without an unfollowed rem length returns at once, and a\n// followed value never looks like work again, which is also why a second observer on the same root writes nothing.\nconst followInlineStyle = (element: Element): void => {\n const attribute = element.getAttribute('style');\n if (!attribute || !UNFOLLOWED_REM_PATTERN.test(attribute)) {\n return;\n }\n const style = (element as HTMLElement).style;\n const declarations = style?.cssText;\n if (!declarations) {\n return;\n }\n const rewritten = rewriteRemLengths(declarations);\n if (rewritten !== declarations) {\n style.cssText = rewritten;\n }\n};\n\nconst followInlineStylesWithin = (node: Node): void => {\n if (node.nodeType !== 1) {\n return;\n }\n const element = node as Element;\n followInlineStyle(element);\n if (element.firstElementChild) {\n for (const descendant of Array.from(element.querySelectorAll(INLINE_REM_SELECTOR))) {\n followInlineStyle(descendant);\n }\n }\n};\n\ntype TStyleOwner = HTMLLinkElement | HTMLStyleElement;\n\nconst isStyleOwner = (node: Node): node is TStyleOwner => {\n return node.nodeName === 'STYLE' || (node.nodeName === 'LINK' && (node as HTMLLinkElement).rel.split(/\\s+/).includes('stylesheet'));\n};\n\ninterface IAdaptStylesOptions {\n documentRootRules: boolean;\n}\n\nconst adaptShadowRootStyles = (root: ShadowRoot, { documentRootRules }: IAdaptStylesOptions): (() => void) => {\n // The root's own window, which need not be the global one (a frame, or a test's own window).\n const RootMutationObserver = root.ownerDocument.defaultView?.MutationObserver ?? MutationObserver;\n let followingRem = false;\n const remSheets = new WeakSet<CSSStyleSheet>();\n const rescopedSheets = new WeakSet<CSSStyleSheet>();\n const watchedStyles = new WeakSet<HTMLStyleElement>();\n\n const owners = (): TStyleOwner[] => Array.from(root.childNodes).filter(isStyleOwner);\n\n const sheetsOf = (styleOwners: TStyleOwner[]): CSSStyleSheet[] => {\n return [...(root.adoptedStyleSheets ?? []), ...styleOwners.map((owner) => owner.sheet).filter((sheet): sheet is CSSStyleSheet => !!sheet)];\n };\n\n // A <style>'s own text is the cheap check; linked and adopted sheets have only their rules.\n const findsRootFontSize = (styleOwners: TStyleOwner[]): boolean => {\n const styles = styleOwners.filter((owner): owner is HTMLStyleElement => owner.nodeName === 'STYLE');\n if (styles.some((style) => ROOT_FONT_SIZE_DECLARATION_PATTERN.test(style.textContent ?? ''))) {\n return true;\n }\n const linkedSheets = styleOwners.filter((owner) => owner.nodeName === 'LINK').map((owner) => owner.sheet);\n return [...(root.adoptedStyleSheets ?? []), ...linkedSheets].some((sheet) => !!sheet && declaresRootFontSize(sheet));\n };\n\n // Started only once the module's CSS declares a root size, so a module without one pays nothing. An element gets its\n // template styles before it is inserted, so insertions are scanned as well as later style attribute changes.\n let inlineObserver: MutationObserver | undefined;\n const followInlineStyles = (): void => {\n for (const element of Array.from(root.querySelectorAll(INLINE_REM_SELECTOR))) {\n followInlineStyle(element);\n }\n inlineObserver = new RootMutationObserver((records) => {\n for (const record of records) {\n if (record.type === 'attributes') {\n followInlineStyle(record.target as Element);\n } else {\n for (const node of Array.from(record.addedNodes)) {\n followInlineStylesWithin(node);\n }\n }\n }\n // Only this callback ran since the records were delivered, so what is queued now are its own rewrites.\n inlineObserver?.takeRecords();\n });\n inlineObserver.observe(root, { attributeFilter: ['style'], attributes: true, childList: true, subtree: true });\n };\n\n const observer = new RootMutationObserver(() => update());\n\n const update = (): void => {\n const styleOwners = owners();\n for (const owner of styleOwners) {\n if (owner.nodeName === 'STYLE' && !watchedStyles.has(owner as HTMLStyleElement)) {\n // Replacing a <style>'s text gives it a new sheet, which must be adapted again.\n observer.observe(owner, { characterData: true, childList: true, subtree: true });\n watchedStyles.add(owner as HTMLStyleElement);\n }\n }\n\n const sheets = sheetsOf(styleOwners);\n if (documentRootRules) {\n for (const sheet of sheets) {\n if (!rescopedSheets.has(sheet)) {\n rescopeDocumentRootRules(sheet);\n rescopedSheets.add(sheet);\n }\n }\n }\n\n followingRem ||= findsRootFontSize(styleOwners);\n if (!followingRem) {\n return;\n }\n if (!inlineObserver) {\n followInlineStyles();\n }\n for (const sheet of sheets) {\n if (!remSheets.has(sheet)) {\n followRemInSheet(sheet);\n remSheets.add(sheet);\n }\n }\n };\n\n // A <link> sheet has no rules until it loads; load does not bubble, so it is caught on the way down.\n const onLoad = (event: Event): void => {\n if (event.target instanceof Node && isStyleOwner(event.target)) {\n update();\n }\n };\n\n observer.observe(root, { childList: true });\n root.addEventListener('load', onLoad, true);\n update();\n\n return () => {\n observer.disconnect();\n inlineObserver?.disconnect();\n root.removeEventListener('load', onLoad, true);\n };\n};\n\n/**\n * Makes rem lengths in a hosted module's shadow root follow the root font size its own page had, once the module's\n * CSS declares one (see MF_ROOT_FONT_SIZE_PROPERTY): in stylesheets already in the root and every one added or changed\n * later, such as the component styles Angular adds as components first render, and in inline style attributes,\n * including ones inserted or changed later. A module whose CSS never sizes its root is left untouched. Returns a\n * function that stops following; rewritten rules and styles stay rewritten.\n */\nexport const followModuleRootFontSize = (root: ShadowRoot): (() => void) => {\n return adaptShadowRootStyles(root, { documentRootRules: false });\n};\n\n/**\n * Adapts the CSS a module brings into its shadow root at runtime to the hosted page, for a host to call on each module\n * shadow root it creates and stop on unmount: rem follows the module's own root font size (as followModuleRootFontSize\n * does), and rules a library injects for the document root (`html { --mat-focus-indicator-display: block; }`), which\n * never match inside a shadow root, move onto `:host` (see rescopeDocumentRootSelectors). Safe beside a module's own\n * followModuleRootFontSize on the same root: every step is idempotent, and neither writes anything the other acts on.\n */\nexport const adaptHostedModuleStyles = (root: ShadowRoot): (() => void) => {\n return adaptShadowRootStyles(root, { documentRootRules: true });\n};\n"]}
|
|
1
|
+
{"version":3,"file":"hosted-module-styles.js","sourceRoot":"","sources":["../src/hosted-module-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,kCAAkC,EAClC,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,mB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AAmB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,IAAgB,EAAgB,EAAE;IACzE,OAAO,qBAAqB,CAAC,IAAI,EAAE,EAAE,iBAAiB,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;AACtF,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,IAAgB,EAAgB,EAAE;IACxE,OAAO,qBAAqB,CAAC,IAAI,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;AACpF,CAAC,CAAC","sourcesContent":["import { rescopeDocumentRootSelectors } from './document-root-selectors.js';\nimport {\n MF_ROOT_FONT_SIZE_PROPERTY,\n REM_LENGTH_HINT_PATTERN,\n ROOT_FONT_SIZE_DECLARATION_PATTERN,\n rewriteRemLengths,\n UNFOLLOWED_REM_PATTERN,\n} from './root-font-size.js';\n\nconst INLINE_REM_SELECTOR = '[style*=\"rem\" i]';\nconst INLINE_STICKY_SELECTOR = '[style*=\"sticky\" i]';\n\n// The legacy navigation's top bar (@edyn/navigation: `.mat-sidenav-container { padding-top: 49px }`). Old pages scrolled\n// under it, so their sticky headers stuck below it with `top: 49px` (or 50px, one pixel lower). Hosted, a module scrolls\n// in the host's content area, which has no bar inside it, so those headers would stick 49px too low.\nconst LEGACY_NAVIGATION_BAR_HEIGHT = 49;\nconst PIXEL_LENGTH_PATTERN = /^(\\d+(?:\\.\\d+)?)px$/i;\n\n// A sticky top of at least the bar's height moves up by the bar; smaller ones (0, 1px) belong to pages or panels that\n// scrolled below the bar already, and anything else (var(), %, calc()) is a module's own choice. Returns whether the\n// declarations changed.\nconst liftStickyTop = (declarations: CSSStyleDeclaration): boolean => {\n if (!/sticky/i.test(declarations.getPropertyValue('position'))) {\n return false;\n }\n const top = PIXEL_LENGTH_PATTERN.exec(declarations.getPropertyValue('top').trim());\n const pixels = top ? Number(top[1]) : Number.NaN;\n if (!(pixels >= LEGACY_NAVIGATION_BAR_HEIGHT)) {\n return false;\n }\n declarations.setProperty('top', `${pixels - LEGACY_NAVIGATION_BAR_HEIGHT}px`, declarations.getPropertyPriority('top'));\n return true;\n};\n\n// By class name, not instanceof: a root in another window (a frame, or a test's own window) has its own CSSFontFaceRule.\nconst isFontFaceRule = (rule: CSSRule): boolean => {\n return rule.constructor?.name === 'CSSFontFaceRule';\n};\n\n// Rule kinds are told apart by what they carry, not by class: @import has a sheet, style and keyframe rules have\n// declarations, and grouping rules (@media, @supports, @container, @layer, @keyframes, nesting) have child rules.\nconst importedSheetOf = (rule: CSSRule): CSSStyleSheet | undefined => {\n return 'styleSheet' in rule && rule.styleSheet ? (rule.styleSheet as CSSStyleSheet) : undefined;\n};\n\nconst declarationsOf = (rule: CSSRule): CSSStyleDeclaration | undefined => {\n return 'style' in rule && rule.style && !isFontFaceRule(rule) ? (rule.style as CSSStyleDeclaration) : undefined;\n};\n\nconst childRulesOf = (rule: CSSRule): CSSRuleList | undefined => {\n return 'cssRules' in rule && rule.cssRules ? (rule.cssRules as CSSRuleList) : undefined;\n};\n\nconst readRules = (sheet: CSSStyleSheet): CSSRuleList | undefined => {\n try {\n return sheet.cssRules;\n } catch {\n // A cross-origin sheet (a font service's @font-face list) cannot be read, and none of its rules are module rules.\n return undefined;\n }\n};\n\nconst walkRules = (sheet: CSSStyleSheet, visit: (rule: CSSRule) => void): void => {\n const walk = (rules: CSSRuleList): void => {\n for (const rule of Array.from(rules)) {\n const importedSheet = importedSheetOf(rule);\n const importedRules = importedSheet ? readRules(importedSheet) : undefined;\n if (importedRules) {\n walk(importedRules);\n }\n visit(rule);\n const childRules = childRulesOf(rule);\n if (childRules) {\n walk(childRules);\n }\n }\n };\n const rules = readRules(sheet);\n if (rules) {\n walk(rules);\n }\n};\n\n// Only declaration blocks change, through the CSSOM: @media, @container and @supports conditions keep their rem (var()\n// is invalid there, and a media query rem is the browser's initial size anyway), and !important stays with its value.\n// CSSOM changes are not DOM mutations, so no observer, this one or another on the same root, sees them.\nconst followRemInSheet = (sheet: CSSStyleSheet): void => {\n walkRules(sheet, (rule) => {\n const declarations = declarationsOf(rule);\n if (declarations && REM_LENGTH_HINT_PATTERN.test(declarations.cssText)) {\n const rewritten = rewriteRemLengths(declarations.cssText);\n if (rewritten !== declarations.cssText) {\n declarations.cssText = rewritten;\n }\n }\n });\n};\n\nconst rescopeDocumentRootRules = (sheet: CSSStyleSheet): void => {\n walkRules(sheet, (rule) => {\n if (!('selectorText' in rule) || typeof rule.selectorText !== 'string') {\n return;\n }\n const { selectorText } = rescopeDocumentRootSelectors(rule.selectorText);\n if (selectorText !== rule.selectorText) {\n (rule as CSSStyleRule).selectorText = selectorText;\n }\n });\n};\n\nconst liftStickyTopsInSheet = (sheet: CSSStyleSheet): void => {\n walkRules(sheet, (rule) => {\n const declarations = declarationsOf(rule);\n if (declarations && /sticky/i.test(declarations.cssText)) {\n liftStickyTop(declarations);\n }\n });\n};\n\nconst declaresRootFontSize = (sheet: CSSStyleSheet): boolean => {\n let declares = false;\n walkRules(sheet, (rule) => {\n declares ||= !!declarationsOf(rule)?.getPropertyValue(MF_ROOT_FONT_SIZE_PROPERTY);\n });\n return declares;\n};\n\n// Inline styles carry rem too, from templates (`style=\"padding-bottom: 0.25rem !important\"`) and from style bindings\n// and code. The whole declaration block is rewritten through element.style, as for sheet rules: !important stays with\n// its value, and a shorthand that also holds var() (whose longhands read empty) is still seen. Material sets inline\n// styles constantly (ripples, overlay positions), so anything without an unfollowed rem length returns at once, and a\n// followed value never looks like work again, which is also why a second observer on the same root writes nothing.\nconst followInlineStyle = (element: Element): void => {\n const attribute = element.getAttribute('style');\n if (!attribute || !UNFOLLOWED_REM_PATTERN.test(attribute)) {\n return;\n }\n const style = (element as HTMLElement).style;\n const declarations = style?.cssText;\n if (!declarations) {\n return;\n }\n const rewritten = rewriteRemLengths(declarations);\n if (rewritten !== declarations) {\n style.cssText = rewritten;\n }\n};\n\nconst followInlineStylesWithin = (node: Node): void => {\n if (node.nodeType !== 1) {\n return;\n }\n const element = node as Element;\n followInlineStyle(element);\n if (element.firstElementChild) {\n for (const descendant of Array.from(element.querySelectorAll(INLINE_REM_SELECTOR))) {\n followInlineStyle(descendant);\n }\n }\n};\n\ntype TStyleOwner = HTMLLinkElement | HTMLStyleElement;\n\nconst isStyleOwner = (node: Node): node is TStyleOwner => {\n return node.nodeName === 'STYLE' || (node.nodeName === 'LINK' && (node as HTMLLinkElement).rel.split(/\\s+/).includes('stylesheet'));\n};\n\ninterface IAdaptStylesOptions {\n documentRootRules: boolean;\n stickyTops: boolean;\n}\n\n// Sticky headers set from code carry their top inline (`style.cssText = 'position: sticky; top: 50px'` in the modules'\n// position-sticky directives). Each value a module writes moves up once: the attribute this wrote is remembered, so its\n// own change, which the observer sees too, is not lifted again, while a value the module writes later is.\nconst liftInlineStickyTops = (root: ShadowRoot, RootMutationObserver: typeof MutationObserver): MutationObserver => {\n const lifted = new WeakMap<Element, string>();\n const lift = (element: Element): void => {\n const attribute = element.getAttribute('style');\n if (!attribute || !/sticky/i.test(attribute) || lifted.get(element) === attribute) {\n return;\n }\n const style = (element as HTMLElement).style;\n if (style && liftStickyTop(style)) {\n lifted.set(element, element.getAttribute('style') ?? '');\n }\n };\n const liftWithin = (node: Node): void => {\n if (node.nodeType !== 1) {\n return;\n }\n lift(node as Element);\n for (const descendant of Array.from((node as Element).querySelectorAll(INLINE_STICKY_SELECTOR))) {\n lift(descendant);\n }\n };\n\n for (const element of Array.from(root.querySelectorAll(INLINE_STICKY_SELECTOR))) {\n lift(element);\n }\n const observer = new RootMutationObserver((records) => {\n for (const record of records) {\n if (record.type === 'attributes') {\n lift(record.target as Element);\n } else {\n for (const node of Array.from(record.addedNodes)) {\n liftWithin(node);\n }\n }\n }\n });\n observer.observe(root, { attributeFilter: ['style'], attributes: true, childList: true, subtree: true });\n return observer;\n};\n\nconst adaptShadowRootStyles = (root: ShadowRoot, { documentRootRules, stickyTops }: IAdaptStylesOptions): (() => void) => {\n // The root's own window, which need not be the global one (a frame, or a test's own window).\n const RootMutationObserver = root.ownerDocument.defaultView?.MutationObserver ?? MutationObserver;\n let followingRem = false;\n const remSheets = new WeakSet<CSSStyleSheet>();\n const rescopedSheets = new WeakSet<CSSStyleSheet>();\n const stickySheets = new WeakSet<CSSStyleSheet>();\n const watchedStyles = new WeakSet<HTMLStyleElement>();\n\n const owners = (): TStyleOwner[] => Array.from(root.childNodes).filter(isStyleOwner);\n\n const sheetsOf = (styleOwners: TStyleOwner[]): CSSStyleSheet[] => {\n return [...(root.adoptedStyleSheets ?? []), ...styleOwners.map((owner) => owner.sheet).filter((sheet): sheet is CSSStyleSheet => !!sheet)];\n };\n\n // A <style>'s own text is the cheap check; linked and adopted sheets have only their rules.\n const findsRootFontSize = (styleOwners: TStyleOwner[]): boolean => {\n const styles = styleOwners.filter((owner): owner is HTMLStyleElement => owner.nodeName === 'STYLE');\n if (styles.some((style) => ROOT_FONT_SIZE_DECLARATION_PATTERN.test(style.textContent ?? ''))) {\n return true;\n }\n const linkedSheets = styleOwners.filter((owner) => owner.nodeName === 'LINK').map((owner) => owner.sheet);\n return [...(root.adoptedStyleSheets ?? []), ...linkedSheets].some((sheet) => !!sheet && declaresRootFontSize(sheet));\n };\n\n // Started only once the module's CSS declares a root size, so a module without one pays nothing. An element gets its\n // template styles before it is inserted, so insertions are scanned as well as later style attribute changes.\n let inlineObserver: MutationObserver | undefined;\n const followInlineStyles = (): void => {\n for (const element of Array.from(root.querySelectorAll(INLINE_REM_SELECTOR))) {\n followInlineStyle(element);\n }\n inlineObserver = new RootMutationObserver((records) => {\n for (const record of records) {\n if (record.type === 'attributes') {\n followInlineStyle(record.target as Element);\n } else {\n for (const node of Array.from(record.addedNodes)) {\n followInlineStylesWithin(node);\n }\n }\n }\n // Only this callback ran since the records were delivered, so what is queued now are its own rewrites.\n inlineObserver?.takeRecords();\n });\n inlineObserver.observe(root, { attributeFilter: ['style'], attributes: true, childList: true, subtree: true });\n };\n\n const observer = new RootMutationObserver(() => update());\n\n const update = (): void => {\n const styleOwners = owners();\n for (const owner of styleOwners) {\n if (owner.nodeName === 'STYLE' && !watchedStyles.has(owner as HTMLStyleElement)) {\n // Replacing a <style>'s text gives it a new sheet, which must be adapted again.\n observer.observe(owner, { characterData: true, childList: true, subtree: true });\n watchedStyles.add(owner as HTMLStyleElement);\n }\n }\n\n const sheets = sheetsOf(styleOwners);\n if (documentRootRules) {\n for (const sheet of sheets) {\n if (!rescopedSheets.has(sheet)) {\n rescopeDocumentRootRules(sheet);\n rescopedSheets.add(sheet);\n }\n }\n }\n\n if (stickyTops) {\n for (const sheet of sheets) {\n if (!stickySheets.has(sheet)) {\n liftStickyTopsInSheet(sheet);\n stickySheets.add(sheet);\n }\n }\n }\n\n followingRem ||= findsRootFontSize(styleOwners);\n if (!followingRem) {\n return;\n }\n if (!inlineObserver) {\n followInlineStyles();\n }\n for (const sheet of sheets) {\n if (!remSheets.has(sheet)) {\n followRemInSheet(sheet);\n remSheets.add(sheet);\n }\n }\n };\n\n // A <link> sheet has no rules until it loads; load does not bubble, so it is caught on the way down.\n const onLoad = (event: Event): void => {\n if (event.target instanceof Node && isStyleOwner(event.target)) {\n update();\n }\n };\n\n observer.observe(root, { childList: true });\n root.addEventListener('load', onLoad, true);\n update();\n const stickyObserver = stickyTops ? liftInlineStickyTops(root, RootMutationObserver) : undefined;\n\n return () => {\n observer.disconnect();\n inlineObserver?.disconnect();\n stickyObserver?.disconnect();\n root.removeEventListener('load', onLoad, true);\n };\n};\n\n/**\n * Makes rem lengths in a hosted module's shadow root follow the root font size its own page had, once the module's\n * CSS declares one (see MF_ROOT_FONT_SIZE_PROPERTY): in stylesheets already in the root and every one added or changed\n * later, such as the component styles Angular adds as components first render, and in inline style attributes,\n * including ones inserted or changed later. A module whose CSS never sizes its root is left untouched. Returns a\n * function that stops following; rewritten rules and styles stay rewritten.\n */\nexport const followModuleRootFontSize = (root: ShadowRoot): (() => void) => {\n return adaptShadowRootStyles(root, { documentRootRules: false, stickyTops: false });\n};\n\n/**\n * Adapts the CSS a module brings into its shadow root at runtime to the hosted page, for a host to call on each module\n * shadow root it creates and stop on unmount: rem follows the module's own root font size (as followModuleRootFontSize\n * does), and rules a library injects for the document root (`html { --mat-focus-indicator-display: block; }`), which\n * never match inside a shadow root, move onto `:host` (see rescopeDocumentRootSelectors), and sticky tops written for\n * the legacy navigation's top bar (`top: 49px`), in rules and inline styles, move up by that bar, which a hosted page\n * does not have. Safe beside a module's own followModuleRootFontSize on the same root: every step is idempotent, and\n * neither writes anything the other acts on.\n */\nexport const adaptHostedModuleStyles = (root: ShadowRoot): (() => void) => {\n return adaptShadowRootStyles(root, { documentRootRules: true, stickyTops: true });\n};\n"]}
|