ngx-mq 2.0.5 → 2.0.6

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 CHANGED
@@ -30,6 +30,14 @@
30
30
 
31
31
  <br>
32
32
 
33
+ ## Features
34
+
35
+ - Lightweight
36
+ - SSR-safe
37
+ - Auto-cleanup
38
+ - Angular 16 — next
39
+ - Well-tested
40
+
33
41
  ## Introduction
34
42
 
35
43
  Built on the native [matchMedia](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia) API, NGX-MQ brings a signal-based and declarative way to handle breakpoints and media queries in Angular. Lifecycle management is fully automated via `DestroyRef`, removing the need for manual cleanup. Under the hood, it leverages the Multiton and Flyweight patterns for efficient instance reuse and consistent behavior across your app.
@@ -1,6 +1,81 @@
1
- import { signal, inject, DestroyRef, InjectionToken, isDevMode, assertInInjectionContext } from '@angular/core';
1
+ import { InjectionToken, inject, isDevMode, signal, DestroyRef, assertInInjectionContext } from '@angular/core';
2
2
  import { createComputed, SIGNAL } from '@angular/core/primitives/signals';
3
3
 
4
+ const TAILWIND_BREAKPOINTS = {
5
+ sm: 640,
6
+ md: 768,
7
+ lg: 1024,
8
+ xl: 1280,
9
+ '2xl': 1536,
10
+ };
11
+ const BOOTSTRAP_BREAKPOINTS = {
12
+ sm: 576,
13
+ md: 768,
14
+ lg: 992,
15
+ xl: 1200,
16
+ xxl: 1400,
17
+ };
18
+ const MATERIAL_BREAKPOINTS = {
19
+ sm: 600,
20
+ md: 905,
21
+ lg: 1240,
22
+ xl: 1440,
23
+ };
24
+ const DEFAULT_BREAKPOINT_EPSILON = 0.02;
25
+
26
+ const MQ_BREAKPOINTS = new InjectionToken('MQ_BREAKPOINTS');
27
+ const MQ_BREAKPOINT_EPSILON = new InjectionToken('MQ_BREAKPOINT_EPSILON', {
28
+ providedIn: 'root',
29
+ factory: () => DEFAULT_BREAKPOINT_EPSILON,
30
+ });
31
+
32
+ function assertBreakpointsProvided() {
33
+ const breakpoints = inject(MQ_BREAKPOINTS, { optional: true });
34
+ if (isDevMode() && !breakpoints) {
35
+ throw new Error('[ngx-mq]: No breakpoints provided.\n' +
36
+ 'Please configure your app with provideBreakpoints(), ' +
37
+ 'or use one of the built-in presets: ' +
38
+ 'provideTailwindBreakpoints(), provideBootstrapBreakpoints(), provideMaterialBreakpoints().');
39
+ }
40
+ return breakpoints;
41
+ }
42
+ function assertBreakpointExists(bp, breakpoints) {
43
+ if (isDevMode() && !(bp in breakpoints)) {
44
+ throw new Error(`[ngx-mq]: Breakpoint "${bp}" not found in provided configuration.\n` +
45
+ `Available breakpoints: ${Object.keys(breakpoints).join(', ')}.`);
46
+ }
47
+ return breakpoints[bp];
48
+ }
49
+ function resolveBreakpoint(bp) {
50
+ const breakpoints = assertBreakpointsProvided();
51
+ return assertBreakpointExists(bp, breakpoints);
52
+ }
53
+ function normalizeBreakpoints(bps) {
54
+ const out = {};
55
+ for (const [rawKey, value] of Object.entries(bps)) {
56
+ const key = rawKey.trim();
57
+ if (isDevMode()) {
58
+ if (!Number.isFinite(value)) {
59
+ throw new Error(`[ngx-mq] Breakpoint "${key}" must be a finite number, got ${value}.`);
60
+ }
61
+ if (value <= 0) {
62
+ throw new Error(`[ngx-mq] Breakpoint "${key}" must be > 0, got ${value}.`);
63
+ }
64
+ }
65
+ out[key] = value;
66
+ }
67
+ return Object.freeze(out);
68
+ }
69
+ function validateEpsilon(epsilon) {
70
+ if (!Number.isFinite(epsilon) || epsilon <= 0 || epsilon > 1) {
71
+ throw new Error(`[ngx-mq] Epsilon must be in (0, 1]. Got: ${epsilon}`);
72
+ }
73
+ }
74
+ function applyMaxEpsilon(value) {
75
+ const epsilon = inject(MQ_BREAKPOINT_EPSILON, { optional: true }) ?? 0.02;
76
+ return value - epsilon;
77
+ }
78
+
4
79
  function addChangeListenerToMql(mql, onChange) {
5
80
  if (typeof mql.addEventListener === 'function') {
6
81
  // Modern browsers
@@ -84,81 +159,6 @@ function retainUntilDestroy(query) {
84
159
  return querySignal;
85
160
  }
86
161
 
87
- const TAILWIND_BREAKPOINTS = {
88
- sm: 640,
89
- md: 768,
90
- lg: 1024,
91
- xl: 1280,
92
- '2xl': 1536,
93
- };
94
- const BOOTSTRAP_BREAKPOINTS = {
95
- sm: 576,
96
- md: 768,
97
- lg: 992,
98
- xl: 1200,
99
- xxl: 1400,
100
- };
101
- const MATERIAL_BREAKPOINTS = {
102
- sm: 600,
103
- md: 905,
104
- lg: 1240,
105
- xl: 1440,
106
- };
107
- const DEFAULT_BREAKPOINT_EPSILON = 0.02;
108
-
109
- const MQ_BREAKPOINTS = new InjectionToken('MQ_BREAKPOINTS');
110
- const MQ_BREAKPOINT_EPSILON = new InjectionToken('MQ_BREAKPOINT_EPSILON', {
111
- providedIn: 'root',
112
- factory: () => DEFAULT_BREAKPOINT_EPSILON,
113
- });
114
-
115
- function assertBreakpointsProvided() {
116
- const breakpoints = inject(MQ_BREAKPOINTS, { optional: true });
117
- if (isDevMode() && !breakpoints) {
118
- throw new Error('[ngx-mq]: No breakpoints provided.\n' +
119
- 'Please configure your app with provideBreakpoints(), ' +
120
- 'or use one of the built-in presets: ' +
121
- 'provideTailwindBreakpoints(), provideBootstrapBreakpoints(), provideMaterialBreakpoints().');
122
- }
123
- return breakpoints;
124
- }
125
- function assertBreakpointExists(bp, breakpoints) {
126
- if (isDevMode() && !(bp in breakpoints)) {
127
- throw new Error(`[ngx-mq]: Breakpoint "${bp}" not found in provided configuration.\n` +
128
- `Available breakpoints: ${Object.keys(breakpoints).join(', ')}.`);
129
- }
130
- return breakpoints[bp];
131
- }
132
- function resolveBreakpoint(bp) {
133
- const breakpoints = assertBreakpointsProvided();
134
- return assertBreakpointExists(bp, breakpoints);
135
- }
136
- function normalizeBreakpoints(bps) {
137
- const out = {};
138
- for (const [rawKey, value] of Object.entries(bps)) {
139
- const key = rawKey.trim();
140
- if (isDevMode()) {
141
- if (!Number.isFinite(value)) {
142
- throw new Error(`[ngx-mq] Breakpoint "${key}" must be a finite number, got ${value}.`);
143
- }
144
- if (value <= 0) {
145
- throw new Error(`[ngx-mq] Breakpoint "${key}" must be > 0, got ${value}.`);
146
- }
147
- }
148
- out[key] = value;
149
- }
150
- return Object.freeze(out);
151
- }
152
- function validateEpsilon(epsilon) {
153
- if (!Number.isFinite(epsilon) || epsilon <= 0 || epsilon > 1) {
154
- throw new Error(`[ngx-mq] Epsilon must be in (0, 1]. Got: ${epsilon}`);
155
- }
156
- }
157
- function applyMaxEpsilon(value) {
158
- const epsilon = inject(MQ_BREAKPOINT_EPSILON, { optional: true }) ?? 0.02;
159
- return value - epsilon;
160
- }
161
-
162
162
  function createConsumer(query, debugName) {
163
163
  const querySignal = retainUntilDestroy(query);
164
164
  const getter = createComputed(() => querySignal());
@@ -228,5 +228,5 @@ function provideBreakpointEpsilon(epsilon = DEFAULT_BREAKPOINT_EPSILON) {
228
228
  * Generated bundle index. Do not edit.
229
229
  */
230
230
 
231
- export { MQ_BREAKPOINTS, MQ_BREAKPOINT_EPSILON, between, down, matchMediaSignal, provideBootstrapBreakpoints, provideBreakpointEpsilon, provideBreakpoints, provideMaterialBreakpoints, provideTailwindBreakpoints, release, retainUntilDestroy, up };
231
+ export { MQ_BREAKPOINTS, MQ_BREAKPOINT_EPSILON, between, down, matchMediaSignal, provideBootstrapBreakpoints, provideBreakpointEpsilon, provideBreakpoints, provideMaterialBreakpoints, provideTailwindBreakpoints, up };
232
232
  //# sourceMappingURL=ngx-mq.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ngx-mq.mjs","sources":["../../src/lib/mql-registry/mql-registry.listeners.ts","../../src/lib/mql-registry/mql-registry.ts","../../src/lib/mql-registry/mql-registry.extensions.ts","../../src/lib/constants.ts","../../src/lib/tokens.ts","../../src/lib/utils/breakpoints.utils.ts","../../src/lib/core.ts","../../src/lib/utils/common.utils.ts","../../src/lib/api.ts","../../src/lib/providers.ts","../../src/ngx-mq.ts"],"sourcesContent":["export function addChangeListenerToMql(mql: MediaQueryList, onChange: (event?: MediaQueryListEvent) => void): void {\n if (typeof mql.addEventListener === 'function') {\n // Modern browsers\n mql.addEventListener('change', onChange);\n } else {\n // Legacy fallback (Safari < 14)\n (mql as any).addListener(onChange);\n }\n}\n\nexport function removeChangeListenerFromMql(\n mql: MediaQueryList,\n onChange: (event?: MediaQueryListEvent) => void\n): void {\n if (typeof mql.removeEventListener === 'function') {\n // Modern browsers\n mql.removeEventListener('change', onChange);\n } else {\n // Legacy fallback (Safari < 14)\n (mql as any).removeListener(onChange);\n }\n}\n","import { signal as createSignal, Signal, WritableSignal } from '@angular/core';\nimport { addChangeListenerToMql, removeChangeListenerFromMql } from './mql-registry.listeners';\nimport { MqlRegistry, MqRetainToken, MqHandle } from './mql-registry.models';\n\nconst REGISTRY_KEY: symbol = Symbol.for('ngx-mq:mql-registry');\n\nconst getRegistry = (): MqlRegistry => {\n const realmGlobal: Record<PropertyKey, unknown> = globalThis;\n\n return (realmGlobal[REGISTRY_KEY] ??= new Map()) as MqlRegistry;\n};\n\nconst createMqHandle = (query: string): MqHandle => {\n const mql: MediaQueryList = matchMedia(query);\n const signal: WritableSignal<boolean> = createSignal(mql.matches, { debugName: `ngx-mq: ${query}` });\n\n const onChange = (event?: MediaQueryListEvent) => signal.set(event?.matches ?? mql.matches);\n\n addChangeListenerToMql(mql, onChange);\n\n return { mql, signal, onChange, retainers: new Set() };\n};\n\nexport function retain(query: string, token: MqRetainToken): Signal<boolean> {\n // SSR-safe fallback\n if (typeof globalThis.matchMedia !== 'function') {\n return createSignal(false).asReadonly();\n }\n\n const registry: MqlRegistry = getRegistry();\n\n let handle: MqHandle | undefined = registry.get(query);\n\n if (!handle) {\n handle = createMqHandle(query);\n registry.set(query, handle);\n }\n\n handle.retainers.add(token);\n\n return handle.signal.asReadonly();\n}\n\nexport function release(query: string, token: MqRetainToken): boolean {\n const registry: MqlRegistry = getRegistry();\n\n let handle: MqHandle | undefined = registry.get(query);\n\n if (!handle) return false;\n\n const removed: boolean = handle.retainers.delete(token);\n\n if (handle.retainers.size === 0) {\n removeChangeListenerFromMql(handle.mql, handle.onChange);\n registry.delete(query);\n }\n\n return removed;\n}\n\n/* @internal\n * Returns the current registry (used only in tests).\n */\nexport function _getRegistry(): MqlRegistry {\n return getRegistry();\n}\n\n/* @internal\n * Clears all registry entries and removes media-query listeners.\n */\nexport function _resetRegistry(): void {\n const registry: MqlRegistry = getRegistry();\n\n registry.forEach((handle: MqHandle) => {\n removeChangeListenerFromMql(handle.mql, handle.onChange);\n });\n\n registry.clear();\n}\n","import { DestroyRef, inject, Signal } from '@angular/core';\nimport { retain, release } from './mql-registry';\n\nexport function retainUntilDestroy(query: string): Signal<boolean> {\n const destroyRef: DestroyRef = inject(DestroyRef);\n\n const querySignal: Signal<boolean> = retain(query, destroyRef);\n\n destroyRef.onDestroy(() => release(query, destroyRef));\n\n return querySignal;\n}\n","import { MqBreakpoints } from './models';\n\nexport const TAILWIND_BREAKPOINTS: MqBreakpoints = {\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n '2xl': 1536,\n};\n\nexport const BOOTSTRAP_BREAKPOINTS: MqBreakpoints = {\n sm: 576,\n md: 768,\n lg: 992,\n xl: 1200,\n xxl: 1400,\n};\n\nexport const MATERIAL_BREAKPOINTS: MqBreakpoints = {\n sm: 600,\n md: 905,\n lg: 1240,\n xl: 1440,\n};\n\nexport const DEFAULT_BREAKPOINT_EPSILON: number = 0.02;\n","import { InjectionToken } from '@angular/core';\nimport { DEFAULT_BREAKPOINT_EPSILON } from './constants';\nimport { MqBreakpoints } from './models';\n\nexport const MQ_BREAKPOINTS: InjectionToken<MqBreakpoints> = new InjectionToken('MQ_BREAKPOINTS');\n\nexport const MQ_BREAKPOINT_EPSILON: InjectionToken<number> = new InjectionToken('MQ_BREAKPOINT_EPSILON', {\n providedIn: 'root',\n factory: () => DEFAULT_BREAKPOINT_EPSILON,\n});\n","import { inject, isDevMode } from '@angular/core';\nimport { MQ_BREAKPOINT_EPSILON, MQ_BREAKPOINTS } from '../tokens';\nimport { MqBreakpoints } from '../models';\n\nfunction assertBreakpointsProvided(): MqBreakpoints {\n const breakpoints: MqBreakpoints | null = inject(MQ_BREAKPOINTS, { optional: true });\n\n if (isDevMode() && !breakpoints) {\n throw new Error(\n '[ngx-mq]: No breakpoints provided.\\n' +\n 'Please configure your app with provideBreakpoints(), ' +\n 'or use one of the built-in presets: ' +\n 'provideTailwindBreakpoints(), provideBootstrapBreakpoints(), provideMaterialBreakpoints().'\n );\n }\n\n return breakpoints!;\n}\n\nfunction assertBreakpointExists(bp: string, breakpoints: MqBreakpoints): number {\n if (isDevMode() && !(bp in breakpoints)) {\n throw new Error(\n `[ngx-mq]: Breakpoint \"${bp}\" not found in provided configuration.\\n` +\n `Available breakpoints: ${Object.keys(breakpoints).join(', ')}.`\n );\n }\n\n return breakpoints[bp];\n}\n\nexport function resolveBreakpoint(bp: string): number {\n const breakpoints: MqBreakpoints = assertBreakpointsProvided();\n\n return assertBreakpointExists(bp, breakpoints);\n}\n\nexport function normalizeBreakpoints(bps: MqBreakpoints): Readonly<MqBreakpoints> {\n const out: Record<string, number> = {};\n\n for (const [rawKey, value] of Object.entries(bps)) {\n const key = rawKey.trim();\n\n if (isDevMode()) {\n if (!Number.isFinite(value)) {\n throw new Error(`[ngx-mq] Breakpoint \"${key}\" must be a finite number, got ${value}.`);\n }\n\n if (value <= 0) {\n throw new Error(`[ngx-mq] Breakpoint \"${key}\" must be > 0, got ${value}.`);\n }\n }\n\n out[key] = value;\n }\n\n return Object.freeze(out);\n}\n\nexport function validateEpsilon(epsilon: number): void {\n if (!Number.isFinite(epsilon) || epsilon <= 0 || epsilon > 1) {\n throw new Error(`[ngx-mq] Epsilon must be in (0, 1]. Got: ${epsilon}`);\n }\n}\n\nexport function applyMaxEpsilon(value: number): number {\n const epsilon: number = inject(MQ_BREAKPOINT_EPSILON, { optional: true }) ?? 0.02;\n\n return value - epsilon;\n}\n","import { isDevMode, Signal } from '@angular/core';\nimport { createComputed, SIGNAL } from '@angular/core/primitives/signals';\nimport { retainUntilDestroy } from './mql-registry';\n\nexport function createConsumer(query: string, debugName?: string): Signal<boolean> {\n const querySignal: Signal<boolean> = retainUntilDestroy(query);\n\n const getter = createComputed(() => querySignal());\n\n if (isDevMode()) {\n getter[SIGNAL].debugName = debugName;\n }\n\n return getter satisfies Signal<boolean>;\n}\n\nexport function createConsumerLabel(descriptor: string): string {\n return `[NgxMq Signal: ${descriptor}]`;\n}\n","export function normalizeQuery(value: string): string {\n return value.trim().replace(/\\s+/g, ' ').toLowerCase();\n}\n","import { assertInInjectionContext, isDevMode, Signal } from '@angular/core';\nimport { applyMaxEpsilon, resolveBreakpoint } from './utils/breakpoints.utils';\nimport { createConsumer, createConsumerLabel } from './core';\nimport { normalizeQuery } from './utils/common.utils';\nimport { CreateMediaQueryOptions } from './models';\n\nexport function up(bp: string, options?: CreateMediaQueryOptions): Signal<boolean> {\n isDevMode() && assertInInjectionContext(up);\n\n const query: string = normalizeQuery(`(min-width: ${resolveBreakpoint(bp)}px)`);\n const consumer: Signal<boolean> = createConsumer(query, options?.debugName);\n\n consumer.toString = () => createConsumerLabel(`up(${bp})`);\n\n return consumer;\n}\n\nexport function down(bp: string, options?: CreateMediaQueryOptions): Signal<boolean> {\n isDevMode() && assertInInjectionContext(down);\n\n const query: string = normalizeQuery(`(max-width: ${applyMaxEpsilon(resolveBreakpoint(bp))}px)`);\n const consumer: Signal<boolean> = createConsumer(query, options?.debugName);\n\n consumer.toString = () => createConsumerLabel(`down(${bp})`);\n\n return consumer;\n}\n\nexport function between(minBp: string, maxBp: string, options?: CreateMediaQueryOptions): Signal<boolean> {\n isDevMode() && assertInInjectionContext(between);\n\n const minPx: number = resolveBreakpoint(minBp);\n const maxPx: number = resolveBreakpoint(maxBp);\n const query: string = normalizeQuery(`(min-width: ${minPx}px) and (max-width: ${applyMaxEpsilon(maxPx)}px)`);\n const consumer: Signal<boolean> = createConsumer(query, options?.debugName);\n\n consumer.toString = () => createConsumerLabel(`between(${minBp}, ${maxBp})`);\n\n return consumer;\n}\n\nexport function matchMediaSignal(query: string, options?: CreateMediaQueryOptions): Signal<boolean> {\n isDevMode() && assertInInjectionContext(matchMediaSignal);\n\n const media: string = normalizeQuery(query);\n const consumer: Signal<boolean> = createConsumer(media, options?.debugName);\n\n consumer.toString = () => createConsumerLabel(`matchMediaSignal(${query})`);\n\n return consumer;\n}\n","import { isDevMode, Provider } from '@angular/core';\nimport { MQ_BREAKPOINT_EPSILON, MQ_BREAKPOINTS } from './tokens';\nimport { normalizeBreakpoints, validateEpsilon } from './utils/breakpoints.utils';\nimport { MqBreakpoints } from './models';\nimport {\n BOOTSTRAP_BREAKPOINTS,\n DEFAULT_BREAKPOINT_EPSILON,\n MATERIAL_BREAKPOINTS,\n TAILWIND_BREAKPOINTS,\n} from './constants';\n\nexport function provideBreakpoints(bps: MqBreakpoints): Provider {\n return { provide: MQ_BREAKPOINTS, useValue: normalizeBreakpoints(bps) };\n}\n\nexport function provideTailwindBreakpoints(): Provider {\n return provideBreakpoints(TAILWIND_BREAKPOINTS);\n}\n\nexport function provideBootstrapBreakpoints(): Provider {\n return provideBreakpoints(BOOTSTRAP_BREAKPOINTS);\n}\n\nexport function provideMaterialBreakpoints(): Provider {\n return provideBreakpoints(MATERIAL_BREAKPOINTS);\n}\n\nexport function provideBreakpointEpsilon(epsilon: number = DEFAULT_BREAKPOINT_EPSILON): Provider {\n if (isDevMode()) validateEpsilon(epsilon);\n\n return { provide: MQ_BREAKPOINT_EPSILON, useValue: epsilon };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["signal","createSignal"],"mappings":";;;AAAM,SAAU,sBAAsB,CAAC,GAAmB,EAAE,QAA+C,EAAA;AACzG,IAAA,IAAI,OAAO,GAAG,CAAC,gBAAgB,KAAK,UAAU,EAAE;;AAE9C,QAAA,GAAG,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC1C;SAAO;;AAEJ,QAAA,GA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;AACjB;AAEM,SAAU,gBAAgB,CAAC,KAAa,EAAE,OAAiC,EAAA;AAC/E,IAAA,SAAS,EAAE,IAAI,wBAAwB,CAAC,gBAAgB,CAAC;AAEzD,IAAA,MAAM,KAAK,GAAW,cAAc,CAAC,KAAK,CAAC;IAC3C,MAAM,QAAQ,GAAoB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC;AAE3E,IAAA,QAAQ,CAAC,QAAQ,GAAG,MAAM,mBAAmB,CAAC,CAAA,iBAAA,EAAoB,KAAK,CAAA,CAAA,CAAG,CAAC;AAE3E,IAAA,OAAO,QAAQ;AACjB;;ACvCM,SAAU,kBAAkB,CAAC,GAAkB,EAAA;AACnD,IAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,oBAAoB,CAAC,GAAG,CAAC,EAAE;AACzE;SAEgB,0BAA0B,GAAA;AACxC,IAAA,OAAO,kBAAkB,CAAC,oBAAoB,CAAC;AACjD;SAEgB,2BAA2B,GAAA;AACzC,IAAA,OAAO,kBAAkB,CAAC,qBAAqB,CAAC;AAClD;SAEgB,0BAA0B,GAAA;AACxC,IAAA,OAAO,kBAAkB,CAAC,oBAAoB,CAAC;AACjD;AAEM,SAAU,wBAAwB,CAAC,OAAA,GAAkB,0BAA0B,EAAA;AACnF,IAAA,IAAI,SAAS,EAAE;QAAE,eAAe,CAAC,OAAO,CAAC;IAEzC,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,OAAO,EAAE;AAC9D;;AC/BA;;AAEG;;;;"}
1
+ {"version":3,"file":"ngx-mq.mjs","sources":["../../src/lib/constants.ts","../../src/lib/tokens.ts","../../src/lib/utils/breakpoints.utils.ts","../../src/lib/mql-registry/mql-registry.listeners.ts","../../src/lib/mql-registry/mql-registry.ts","../../src/lib/mql-registry/mql-registry.extensions.ts","../../src/lib/core.ts","../../src/lib/utils/common.utils.ts","../../src/lib/api.ts","../../src/lib/providers.ts","../../src/ngx-mq.ts"],"sourcesContent":["import { MqBreakpoints } from './models';\n\nexport const TAILWIND_BREAKPOINTS: MqBreakpoints = {\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n '2xl': 1536,\n};\n\nexport const BOOTSTRAP_BREAKPOINTS: MqBreakpoints = {\n sm: 576,\n md: 768,\n lg: 992,\n xl: 1200,\n xxl: 1400,\n};\n\nexport const MATERIAL_BREAKPOINTS: MqBreakpoints = {\n sm: 600,\n md: 905,\n lg: 1240,\n xl: 1440,\n};\n\nexport const DEFAULT_BREAKPOINT_EPSILON: number = 0.02;\n","import { InjectionToken } from '@angular/core';\nimport { DEFAULT_BREAKPOINT_EPSILON } from './constants';\nimport { MqBreakpoints } from './models';\n\nexport const MQ_BREAKPOINTS: InjectionToken<MqBreakpoints> = new InjectionToken('MQ_BREAKPOINTS');\n\nexport const MQ_BREAKPOINT_EPSILON: InjectionToken<number> = new InjectionToken('MQ_BREAKPOINT_EPSILON', {\n providedIn: 'root',\n factory: () => DEFAULT_BREAKPOINT_EPSILON,\n});\n","import { inject, isDevMode } from '@angular/core';\nimport { MQ_BREAKPOINT_EPSILON, MQ_BREAKPOINTS } from '../tokens';\nimport { MqBreakpoints } from '../models';\n\nfunction assertBreakpointsProvided(): MqBreakpoints {\n const breakpoints: MqBreakpoints | null = inject(MQ_BREAKPOINTS, { optional: true });\n\n if (isDevMode() && !breakpoints) {\n throw new Error(\n '[ngx-mq]: No breakpoints provided.\\n' +\n 'Please configure your app with provideBreakpoints(), ' +\n 'or use one of the built-in presets: ' +\n 'provideTailwindBreakpoints(), provideBootstrapBreakpoints(), provideMaterialBreakpoints().'\n );\n }\n\n return breakpoints!;\n}\n\nfunction assertBreakpointExists(bp: string, breakpoints: MqBreakpoints): number {\n if (isDevMode() && !(bp in breakpoints)) {\n throw new Error(\n `[ngx-mq]: Breakpoint \"${bp}\" not found in provided configuration.\\n` +\n `Available breakpoints: ${Object.keys(breakpoints).join(', ')}.`\n );\n }\n\n return breakpoints[bp];\n}\n\nexport function resolveBreakpoint(bp: string): number {\n const breakpoints: MqBreakpoints = assertBreakpointsProvided();\n\n return assertBreakpointExists(bp, breakpoints);\n}\n\nexport function normalizeBreakpoints(bps: MqBreakpoints): Readonly<MqBreakpoints> {\n const out: Record<string, number> = {};\n\n for (const [rawKey, value] of Object.entries(bps)) {\n const key = rawKey.trim();\n\n if (isDevMode()) {\n if (!Number.isFinite(value)) {\n throw new Error(`[ngx-mq] Breakpoint \"${key}\" must be a finite number, got ${value}.`);\n }\n\n if (value <= 0) {\n throw new Error(`[ngx-mq] Breakpoint \"${key}\" must be > 0, got ${value}.`);\n }\n }\n\n out[key] = value;\n }\n\n return Object.freeze(out);\n}\n\nexport function validateEpsilon(epsilon: number): void {\n if (!Number.isFinite(epsilon) || epsilon <= 0 || epsilon > 1) {\n throw new Error(`[ngx-mq] Epsilon must be in (0, 1]. Got: ${epsilon}`);\n }\n}\n\nexport function applyMaxEpsilon(value: number): number {\n const epsilon: number = inject(MQ_BREAKPOINT_EPSILON, { optional: true }) ?? 0.02;\n\n return value - epsilon;\n}\n","export function addChangeListenerToMql(mql: MediaQueryList, onChange: (event?: MediaQueryListEvent) => void): void {\n if (typeof mql.addEventListener === 'function') {\n // Modern browsers\n mql.addEventListener('change', onChange);\n } else {\n // Legacy fallback (Safari < 14)\n (mql as any).addListener(onChange);\n }\n}\n\nexport function removeChangeListenerFromMql(\n mql: MediaQueryList,\n onChange: (event?: MediaQueryListEvent) => void\n): void {\n if (typeof mql.removeEventListener === 'function') {\n // Modern browsers\n mql.removeEventListener('change', onChange);\n } else {\n // Legacy fallback (Safari < 14)\n (mql as any).removeListener(onChange);\n }\n}\n","import { signal as createSignal, Signal, WritableSignal } from '@angular/core';\nimport { addChangeListenerToMql, removeChangeListenerFromMql } from './mql-registry.listeners';\nimport { MqlRegistry, MqRetainToken, MqHandle } from './mql-registry.models';\n\nconst REGISTRY_KEY: symbol = Symbol.for('ngx-mq:mql-registry');\n\nconst getRegistry = (): MqlRegistry => {\n const realmGlobal: Record<PropertyKey, unknown> = globalThis;\n\n return (realmGlobal[REGISTRY_KEY] ??= new Map()) as MqlRegistry;\n};\n\nconst createMqHandle = (query: string): MqHandle => {\n const mql: MediaQueryList = matchMedia(query);\n const signal: WritableSignal<boolean> = createSignal(mql.matches, { debugName: `ngx-mq: ${query}` });\n\n const onChange = (event?: MediaQueryListEvent) => signal.set(event?.matches ?? mql.matches);\n\n addChangeListenerToMql(mql, onChange);\n\n return { mql, signal, onChange, retainers: new Set() };\n};\n\nexport function retain(query: string, token: MqRetainToken): Signal<boolean> {\n // SSR-safe fallback\n if (typeof globalThis.matchMedia !== 'function') {\n return createSignal(false).asReadonly();\n }\n\n const registry: MqlRegistry = getRegistry();\n\n let handle: MqHandle | undefined = registry.get(query);\n\n if (!handle) {\n handle = createMqHandle(query);\n registry.set(query, handle);\n }\n\n handle.retainers.add(token);\n\n return handle.signal.asReadonly();\n}\n\nexport function release(query: string, token: MqRetainToken): boolean {\n const registry: MqlRegistry = getRegistry();\n\n let handle: MqHandle | undefined = registry.get(query);\n\n if (!handle) return false;\n\n const removed: boolean = handle.retainers.delete(token);\n\n if (handle.retainers.size === 0) {\n removeChangeListenerFromMql(handle.mql, handle.onChange);\n registry.delete(query);\n }\n\n return removed;\n}\n\n/* @internal\n * Returns the current registry (used only in tests).\n */\nexport function _getRegistry(): MqlRegistry {\n return getRegistry();\n}\n\n/* @internal\n * Clears all registry entries and removes media-query listeners.\n */\nexport function _resetRegistry(): void {\n const registry: MqlRegistry = getRegistry();\n\n registry.forEach((handle: MqHandle) => {\n removeChangeListenerFromMql(handle.mql, handle.onChange);\n });\n\n registry.clear();\n}\n","import { DestroyRef, inject, Signal } from '@angular/core';\nimport { retain, release } from './mql-registry';\n\nexport function retainUntilDestroy(query: string): Signal<boolean> {\n const destroyRef: DestroyRef = inject(DestroyRef);\n\n const querySignal: Signal<boolean> = retain(query, destroyRef);\n\n destroyRef.onDestroy(() => release(query, destroyRef));\n\n return querySignal;\n}\n","import { isDevMode, Signal } from '@angular/core';\nimport { createComputed, SIGNAL } from '@angular/core/primitives/signals';\nimport { retainUntilDestroy } from './mql-registry';\n\nexport function createConsumer(query: string, debugName?: string): Signal<boolean> {\n const querySignal: Signal<boolean> = retainUntilDestroy(query);\n\n const getter = createComputed(() => querySignal());\n\n if (isDevMode()) {\n getter[SIGNAL].debugName = debugName;\n }\n\n return getter satisfies Signal<boolean>;\n}\n\nexport function createConsumerLabel(descriptor: string): string {\n return `[NgxMq Signal: ${descriptor}]`;\n}\n","export function normalizeQuery(value: string): string {\n return value.trim().replace(/\\s+/g, ' ').toLowerCase();\n}\n","import { assertInInjectionContext, isDevMode, Signal } from '@angular/core';\nimport { applyMaxEpsilon, resolveBreakpoint } from './utils/breakpoints.utils';\nimport { createConsumer, createConsumerLabel } from './core';\nimport { normalizeQuery } from './utils/common.utils';\nimport { CreateMediaQueryOptions } from './models';\n\nexport function up(bp: string, options?: CreateMediaQueryOptions): Signal<boolean> {\n isDevMode() && assertInInjectionContext(up);\n\n const query: string = normalizeQuery(`(min-width: ${resolveBreakpoint(bp)}px)`);\n const consumer: Signal<boolean> = createConsumer(query, options?.debugName);\n\n consumer.toString = () => createConsumerLabel(`up(${bp})`);\n\n return consumer;\n}\n\nexport function down(bp: string, options?: CreateMediaQueryOptions): Signal<boolean> {\n isDevMode() && assertInInjectionContext(down);\n\n const query: string = normalizeQuery(`(max-width: ${applyMaxEpsilon(resolveBreakpoint(bp))}px)`);\n const consumer: Signal<boolean> = createConsumer(query, options?.debugName);\n\n consumer.toString = () => createConsumerLabel(`down(${bp})`);\n\n return consumer;\n}\n\nexport function between(minBp: string, maxBp: string, options?: CreateMediaQueryOptions): Signal<boolean> {\n isDevMode() && assertInInjectionContext(between);\n\n const minPx: number = resolveBreakpoint(minBp);\n const maxPx: number = resolveBreakpoint(maxBp);\n const query: string = normalizeQuery(`(min-width: ${minPx}px) and (max-width: ${applyMaxEpsilon(maxPx)}px)`);\n const consumer: Signal<boolean> = createConsumer(query, options?.debugName);\n\n consumer.toString = () => createConsumerLabel(`between(${minBp}, ${maxBp})`);\n\n return consumer;\n}\n\nexport function matchMediaSignal(query: string, options?: CreateMediaQueryOptions): Signal<boolean> {\n isDevMode() && assertInInjectionContext(matchMediaSignal);\n\n const media: string = normalizeQuery(query);\n const consumer: Signal<boolean> = createConsumer(media, options?.debugName);\n\n consumer.toString = () => createConsumerLabel(`matchMediaSignal(${query})`);\n\n return consumer;\n}\n","import { isDevMode, Provider } from '@angular/core';\nimport { MQ_BREAKPOINT_EPSILON, MQ_BREAKPOINTS } from './tokens';\nimport { normalizeBreakpoints, validateEpsilon } from './utils/breakpoints.utils';\nimport { MqBreakpoints } from './models';\nimport {\n BOOTSTRAP_BREAKPOINTS,\n DEFAULT_BREAKPOINT_EPSILON,\n MATERIAL_BREAKPOINTS,\n TAILWIND_BREAKPOINTS,\n} from './constants';\n\nexport function provideBreakpoints(bps: MqBreakpoints): Provider {\n return { provide: MQ_BREAKPOINTS, useValue: normalizeBreakpoints(bps) };\n}\n\nexport function provideTailwindBreakpoints(): Provider {\n return provideBreakpoints(TAILWIND_BREAKPOINTS);\n}\n\nexport function provideBootstrapBreakpoints(): Provider {\n return provideBreakpoints(BOOTSTRAP_BREAKPOINTS);\n}\n\nexport function provideMaterialBreakpoints(): Provider {\n return provideBreakpoints(MATERIAL_BREAKPOINTS);\n}\n\nexport function provideBreakpointEpsilon(epsilon: number = DEFAULT_BREAKPOINT_EPSILON): Provider {\n if (isDevMode()) validateEpsilon(epsilon);\n\n return { provide: MQ_BREAKPOINT_EPSILON, useValue: epsilon };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["signal","createSignal"],"mappings":";;;AAEO,MAAM,oBAAoB,GAAkB;AACjD,IAAA,EAAE,EAAE,GAAG;AACP,IAAA,EAAE,EAAE,GAAG;AACP,IAAA,EAAE,EAAE,IAAI;AACR,IAAA,EAAE,EAAE,IAAI;AACR,IAAA,KAAK,E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K,CAAA,CAAA,CAAG,CAAC;AAE5E,IAAA,OAAO,QAAQ;AACjB;AAEM,SAAU,gBAAgB,CAAC,KAAa,EAAE,OAAiC,EAAA;AAC/E,IAAA,SAAS,EAAE,IAAI,wBAAwB,CAAC,gBAAgB,CAAC;AAEzD,IAAA,MAAM,KAAK,GAAW,cAAc,CAAC,KAAK,CAAC;IAC3C,MAAM,QAAQ,GAAoB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC;AAE3E,IAAA,QAAQ,CAAC,QAAQ,GAAG,MAAM,mBAAmB,CAAC,CAAA,iBAAA,EAAoB,KAAK,CAAA,CAAA,CAAG,CAAC;AAE3E,IAAA,OAAO,QAAQ;AACjB;;ACvCM,SAAU,kBAAkB,CAAC,GAAkB,EAAA;AACnD,IAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,oBAAoB,CAAC,GAAG,CAAC,EAAE;AACzE;SAEgB,0BAA0B,GAAA;AACxC,IAAA,OAAO,kBAAkB,CAAC,oBAAoB,CAAC;AACjD;SAEgB,2BAA2B,GAAA;AACzC,IAAA,OAAO,kBAAkB,CAAC,qBAAqB,CAAC;AAClD;SAEgB,0BAA0B,GAAA;AACxC,IAAA,OAAO,kBAAkB,CAAC,oBAAoB,CAAC;AACjD;AAEM,SAAU,wBAAwB,CAAC,OAAA,GAAkB,0BAA0B,EAAA;AACnF,IAAA,IAAI,SAAS,EAAE;QAAE,eAAe,CAAC,OAAO,CAAC;IAEzC,OAAO,EAAE,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,OAAO,EAAE;AAC9D;;AC/BA;;AAEG;;;;"}
package/index.d.ts CHANGED
@@ -1,10 +1,4 @@
1
- import { DestroyRef, Signal, InjectionToken, Provider } from '@angular/core';
2
-
3
- type MqRetainToken = DestroyRef;
4
-
5
- declare function release(query: string, token: MqRetainToken): boolean;
6
-
7
- declare function retainUntilDestroy(query: string): Signal<boolean>;
1
+ import { Signal, InjectionToken, Provider } from '@angular/core';
8
2
 
9
3
  type MqBreakpoints = Record<string, number>;
10
4
  interface CreateMediaQueryOptions {
@@ -28,5 +22,5 @@ declare function provideBootstrapBreakpoints(): Provider;
28
22
  declare function provideMaterialBreakpoints(): Provider;
29
23
  declare function provideBreakpointEpsilon(epsilon?: number): Provider;
30
24
 
31
- export { MQ_BREAKPOINTS, MQ_BREAKPOINT_EPSILON, between, down, matchMediaSignal, provideBootstrapBreakpoints, provideBreakpointEpsilon, provideBreakpoints, provideMaterialBreakpoints, provideTailwindBreakpoints, release, retainUntilDestroy, up };
25
+ export { MQ_BREAKPOINTS, MQ_BREAKPOINT_EPSILON, between, down, matchMediaSignal, provideBootstrapBreakpoints, provideBreakpointEpsilon, provideBreakpoints, provideMaterialBreakpoints, provideTailwindBreakpoints, up };
32
26
  export type { CreateMediaQueryOptions, MqBreakpoints };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngx-mq",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "description": "Signal-powered breakpoints and media queries for Angular.",
5
5
  "repository": {
6
6
  "type": "git",