ngwr 10.1.0 → 10.2.1

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.
Files changed (172) hide show
  1. package/alert/styles/_index.scss +7 -3
  2. package/breadcrumbs/styles/_index.scss +1 -1
  3. package/dialog/styles/_index.scss +31 -0
  4. package/fesm2022/ngwr-action-sheet.mjs +3 -3
  5. package/fesm2022/ngwr-affix.mjs +3 -3
  6. package/fesm2022/ngwr-alert.mjs +3 -3
  7. package/fesm2022/ngwr-anchor.mjs +3 -3
  8. package/fesm2022/ngwr-aurora.mjs +3 -3
  9. package/fesm2022/ngwr-avatar.mjs +3 -3
  10. package/fesm2022/ngwr-back-top.mjs +3 -3
  11. package/fesm2022/ngwr-badge.mjs +6 -6
  12. package/fesm2022/ngwr-bar-chart.mjs +3 -3
  13. package/fesm2022/ngwr-blur-text.mjs +3 -3
  14. package/fesm2022/ngwr-border-glow.mjs +4 -4
  15. package/fesm2022/ngwr-breadcrumbs.mjs +9 -8
  16. package/fesm2022/ngwr-breadcrumbs.mjs.map +1 -1
  17. package/fesm2022/ngwr-burger.mjs +3 -3
  18. package/fesm2022/ngwr-button.mjs +59 -11
  19. package/fesm2022/ngwr-button.mjs.map +1 -1
  20. package/fesm2022/ngwr-calendar-heatmap.mjs +3 -3
  21. package/fesm2022/ngwr-calendar.mjs +88 -8
  22. package/fesm2022/ngwr-calendar.mjs.map +1 -1
  23. package/fesm2022/ngwr-card.mjs +10 -10
  24. package/fesm2022/ngwr-carousel.mjs +6 -6
  25. package/fesm2022/ngwr-cascader.mjs +4 -4
  26. package/fesm2022/ngwr-checkbox.mjs +6 -6
  27. package/fesm2022/ngwr-circular-text.mjs +4 -4
  28. package/fesm2022/ngwr-click-spark.mjs +3 -3
  29. package/fesm2022/ngwr-clipboard.mjs +18 -4
  30. package/fesm2022/ngwr-clipboard.mjs.map +1 -1
  31. package/fesm2022/ngwr-collapse.mjs +9 -9
  32. package/fesm2022/ngwr-color-picker.mjs +6 -6
  33. package/fesm2022/ngwr-command-palette.mjs +3 -3
  34. package/fesm2022/ngwr-compare.mjs +3 -3
  35. package/fesm2022/ngwr-confetti.mjs +3 -3
  36. package/fesm2022/ngwr-context-menu.mjs +12 -12
  37. package/fesm2022/ngwr-cookie.mjs +3 -3
  38. package/fesm2022/ngwr-counter.mjs +6 -6
  39. package/fesm2022/ngwr-date-adapter-fns.mjs +3 -3
  40. package/fesm2022/ngwr-date-adapter-luxon.mjs +3 -3
  41. package/fesm2022/ngwr-date-adapter.mjs +3 -3
  42. package/fesm2022/ngwr-date-picker.mjs +336 -54
  43. package/fesm2022/ngwr-date-picker.mjs.map +1 -1
  44. package/fesm2022/ngwr-decrypt-text.mjs +3 -3
  45. package/fesm2022/ngwr-density.mjs +6 -6
  46. package/fesm2022/ngwr-descriptions.mjs +6 -6
  47. package/fesm2022/ngwr-dialog.mjs +33 -17
  48. package/fesm2022/ngwr-dialog.mjs.map +1 -1
  49. package/fesm2022/ngwr-directives.mjs +12 -12
  50. package/fesm2022/ngwr-divider.mjs +3 -3
  51. package/fesm2022/ngwr-donut-chart.mjs +3 -3
  52. package/fesm2022/ngwr-drag-drop.mjs +7 -7
  53. package/fesm2022/ngwr-drawer.mjs +37 -19
  54. package/fesm2022/ngwr-drawer.mjs.map +1 -1
  55. package/fesm2022/ngwr-dropdown.mjs +9 -9
  56. package/fesm2022/ngwr-empty.mjs +3 -3
  57. package/fesm2022/ngwr-event-calendar.mjs +6 -6
  58. package/fesm2022/ngwr-falling-text.mjs +4 -4
  59. package/fesm2022/ngwr-file-upload.mjs +3 -3
  60. package/fesm2022/ngwr-form.mjs +9 -9
  61. package/fesm2022/ngwr-fuzzy-text.mjs +3 -3
  62. package/fesm2022/ngwr-gauge.mjs +3 -3
  63. package/fesm2022/ngwr-glitch-text.mjs +4 -4
  64. package/fesm2022/ngwr-gradient-text.mjs +4 -4
  65. package/fesm2022/ngwr-hotkey.mjs +31 -10
  66. package/fesm2022/ngwr-hotkey.mjs.map +1 -1
  67. package/fesm2022/ngwr-i18n-en.mjs +11 -0
  68. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  69. package/fesm2022/ngwr-i18n-ru.mjs +11 -0
  70. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  71. package/fesm2022/ngwr-i18n.mjs +9 -9
  72. package/fesm2022/ngwr-icon.mjs +6 -6
  73. package/fesm2022/ngwr-image-cropper.mjs +3 -3
  74. package/fesm2022/ngwr-input-number.mjs +3 -3
  75. package/fesm2022/ngwr-input-otp.mjs +3 -3
  76. package/fesm2022/ngwr-input.mjs +15 -15
  77. package/fesm2022/ngwr-keyboard.mjs +3 -3
  78. package/fesm2022/ngwr-knob.mjs +3 -3
  79. package/fesm2022/ngwr-layout.mjs +15 -15
  80. package/fesm2022/ngwr-lightbox.mjs +4 -4
  81. package/fesm2022/ngwr-line-chart.mjs +3 -3
  82. package/fesm2022/ngwr-list.mjs +14 -9
  83. package/fesm2022/ngwr-list.mjs.map +1 -1
  84. package/fesm2022/ngwr-loading-bar.mjs +71 -31
  85. package/fesm2022/ngwr-loading-bar.mjs.map +1 -1
  86. package/fesm2022/ngwr-marquee.mjs +4 -4
  87. package/fesm2022/ngwr-media.mjs +3 -3
  88. package/fesm2022/ngwr-mention.mjs +6 -6
  89. package/fesm2022/ngwr-meta.mjs +6 -6
  90. package/fesm2022/ngwr-meter-group.mjs +3 -3
  91. package/fesm2022/ngwr-overlay.mjs +16 -7
  92. package/fesm2022/ngwr-overlay.mjs.map +1 -1
  93. package/fesm2022/ngwr-page-header.mjs +3 -3
  94. package/fesm2022/ngwr-pagination.mjs +13 -9
  95. package/fesm2022/ngwr-pagination.mjs.map +1 -1
  96. package/fesm2022/ngwr-pipes.mjs +21 -21
  97. package/fesm2022/ngwr-platform.mjs +9 -9
  98. package/fesm2022/ngwr-popconfirm.mjs +6 -6
  99. package/fesm2022/ngwr-popover.mjs +28 -8
  100. package/fesm2022/ngwr-popover.mjs.map +1 -1
  101. package/fesm2022/ngwr-progress.mjs +3 -3
  102. package/fesm2022/ngwr-pull-to-refresh.mjs +3 -3
  103. package/fesm2022/ngwr-qr.mjs +3 -3
  104. package/fesm2022/ngwr-radio.mjs +6 -6
  105. package/fesm2022/ngwr-rating.mjs +3 -3
  106. package/fesm2022/ngwr-result.mjs +12 -12
  107. package/fesm2022/ngwr-rotating-text.mjs +3 -3
  108. package/fesm2022/ngwr-scroll.mjs +3 -3
  109. package/fesm2022/ngwr-segmented.mjs +3 -3
  110. package/fesm2022/ngwr-select.mjs +9 -9
  111. package/fesm2022/ngwr-shiny-text.mjs +7 -7
  112. package/fesm2022/ngwr-sidebar.mjs +3 -3
  113. package/fesm2022/ngwr-skeleton.mjs +3 -3
  114. package/fesm2022/ngwr-slider.mjs +3 -3
  115. package/fesm2022/ngwr-sparkline.mjs +3 -3
  116. package/fesm2022/ngwr-speed-dial.mjs +3 -3
  117. package/fesm2022/ngwr-spinner.mjs +3 -3
  118. package/fesm2022/ngwr-splash-cursor.mjs +3 -3
  119. package/fesm2022/ngwr-split-text.mjs +3 -3
  120. package/fesm2022/ngwr-splitter.mjs +3 -3
  121. package/fesm2022/ngwr-spotlight-card.mjs +7 -7
  122. package/fesm2022/ngwr-squircle.mjs +6 -6
  123. package/fesm2022/ngwr-star-border.mjs +4 -4
  124. package/fesm2022/ngwr-statistic.mjs +9 -9
  125. package/fesm2022/ngwr-stepper.mjs +6 -6
  126. package/fesm2022/ngwr-storage.mjs +27 -17
  127. package/fesm2022/ngwr-storage.mjs.map +1 -1
  128. package/fesm2022/ngwr-switch.mjs +3 -3
  129. package/fesm2022/ngwr-table.mjs +19 -31
  130. package/fesm2022/ngwr-table.mjs.map +1 -1
  131. package/fesm2022/ngwr-tabs.mjs +6 -6
  132. package/fesm2022/ngwr-textarea.mjs +3 -3
  133. package/fesm2022/ngwr-theme.mjs +3 -3
  134. package/fesm2022/ngwr-tilt-card.mjs +7 -7
  135. package/fesm2022/ngwr-timeline.mjs +6 -6
  136. package/fesm2022/ngwr-toast.mjs +54 -20
  137. package/fesm2022/ngwr-toast.mjs.map +1 -1
  138. package/fesm2022/ngwr-toolbar.mjs +3 -3
  139. package/fesm2022/ngwr-tour.mjs +6 -6
  140. package/fesm2022/ngwr-transfer.mjs +3 -3
  141. package/fesm2022/ngwr-tree.mjs +3 -3
  142. package/fesm2022/ngwr-typewriter.mjs +4 -4
  143. package/fesm2022/ngwr-typography.mjs +3 -3
  144. package/fesm2022/ngwr-version.mjs +1 -1
  145. package/fesm2022/ngwr-version.mjs.map +1 -1
  146. package/fesm2022/ngwr-virtual-scroll.mjs +4 -4
  147. package/fesm2022/ngwr-waves.mjs +4 -4
  148. package/fesm2022/ngwr-window.mjs +80 -18
  149. package/fesm2022/ngwr-window.mjs.map +1 -1
  150. package/i18n/en.json +8 -0
  151. package/i18n/ru.json +8 -0
  152. package/package.json +1 -1
  153. package/sidebar/styles/_index.scss +3 -3
  154. package/stepper/styles/_index.scss +3 -3
  155. package/tabs/styles/_index.scss +1 -1
  156. package/theme/styles/_colors.scss +29 -8
  157. package/types/ngwr-button.d.ts +32 -0
  158. package/types/ngwr-calendar.d.ts +27 -1
  159. package/types/ngwr-clipboard.d.ts +8 -1
  160. package/types/ngwr-date-picker.d.ts +124 -8
  161. package/types/ngwr-dialog.d.ts +13 -0
  162. package/types/ngwr-drawer.d.ts +15 -0
  163. package/types/ngwr-hotkey.d.ts +2 -0
  164. package/types/ngwr-list.d.ts +7 -2
  165. package/types/ngwr-loading-bar.d.ts +4 -7
  166. package/types/ngwr-pagination.d.ts +6 -1
  167. package/types/ngwr-popover.d.ts +10 -2
  168. package/types/ngwr-storage.d.ts +10 -1
  169. package/types/ngwr-toast.d.ts +19 -4
  170. package/types/ngwr-version.d.ts +1 -1
  171. package/types/ngwr-window.d.ts +23 -2
  172. package/typography/styles/_index.scss +2 -2
@@ -54,10 +54,10 @@ class WrStep {
54
54
  stepper = inject(WR_STEPPER);
55
55
  isActive = computed(() => this._index() === this.stepper.active(), /* @ts-ignore */
56
56
  ...(ngDevMode ? [{ debugName: "isActive" }] : /* istanbul ignore next */ []));
57
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrStep, deps: [], target: i0.ɵɵFactoryTarget.Component });
58
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.0", type: WrStep, isStandalone: true, selector: "wr-step", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, description: { classPropertyName: "description", publicName: "description", isSignal: true, isRequired: false, transformFunction: null }, optional: { classPropertyName: "optional", publicName: "optional", isSignal: true, isRequired: false, transformFunction: null }, completed: { classPropertyName: "completed", publicName: "completed", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.wr-step--active": "isActive()" }, classAttribute: "wr-step" }, ngImport: i0, template: '<ng-content />', isInline: true, encapsulation: i0.ViewEncapsulation.None });
57
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrStep, deps: [], target: i0.ɵɵFactoryTarget.Component });
58
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.1", type: WrStep, isStandalone: true, selector: "wr-step", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, description: { classPropertyName: "description", publicName: "description", isSignal: true, isRequired: false, transformFunction: null }, optional: { classPropertyName: "optional", publicName: "optional", isSignal: true, isRequired: false, transformFunction: null }, completed: { classPropertyName: "completed", publicName: "completed", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.wr-step--active": "isActive()" }, classAttribute: "wr-step" }, ngImport: i0, template: '<ng-content />', isInline: true, encapsulation: i0.ViewEncapsulation.None });
59
59
  }
60
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrStep, decorators: [{
60
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrStep, decorators: [{
61
61
  type: Component,
62
62
  args: [{
63
63
  selector: 'wr-step',
@@ -167,8 +167,8 @@ class WrStepper {
167
167
  prev() {
168
168
  this.goTo(this.active() - 1);
169
169
  }
170
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrStepper, deps: [], target: i0.ɵɵFactoryTarget.Component });
171
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.0", type: WrStepper, isStandalone: true, selector: "wr-stepper", inputs: { active: { classPropertyName: "active", publicName: "active", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, linear: { classPropertyName: "linear", publicName: "linear", isSignal: true, isRequired: false, transformFunction: null }, responsive: { classPropertyName: "responsive", publicName: "responsive", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { active: "activeChange" }, host: { properties: { "class": "classes()" } }, providers: [
170
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrStepper, deps: [], target: i0.ɵɵFactoryTarget.Component });
171
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.1", type: WrStepper, isStandalone: true, selector: "wr-stepper", inputs: { active: { classPropertyName: "active", publicName: "active", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, linear: { classPropertyName: "linear", publicName: "linear", isSignal: true, isRequired: false, transformFunction: null }, responsive: { classPropertyName: "responsive", publicName: "responsive", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { active: "activeChange" }, host: { properties: { "class": "classes()" } }, providers: [
172
172
  {
173
173
  provide: WR_STEPPER,
174
174
  // eslint-disable-next-line @angular-eslint/no-forward-ref
@@ -176,7 +176,7 @@ class WrStepper {
176
176
  },
177
177
  ], queries: [{ propertyName: "steps", predicate: WrStep, isSignal: true }], ngImport: i0, template: "<ol class=\"wr-stepper__headers\" role=\"list\">\n @for (step of steps(); track $index) {\n <li\n class=\"wr-stepper__header\"\n [class.wr-stepper__header--active]=\"$index === active()\"\n [class.wr-stepper__header--completed]=\"isCompleted($index)\"\n [class.wr-stepper__header--reachable]=\"isReachable($index)\"\n [class.wr-stepper__header--disabled]=\"step.disabled()\"\n >\n <button\n type=\"button\"\n class=\"wr-stepper__header-button\"\n [disabled]=\"!isReachable($index) || step.disabled()\"\n [attr.aria-current]=\"$index === active() ? 'step' : null\"\n (click)=\"onHeaderClick($index)\"\n >\n <span class=\"wr-stepper__indicator\" aria-hidden=\"true\">\n @if (isCompleted($index)) {\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 14 14\">\n <path\n d=\"M3 7.5 L6 10.5 L11 4.5\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.75\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n } @else {\n {{ $index + 1 }}\n }\n </span>\n <span class=\"wr-stepper__label\">\n {{ step.label() }}\n @if (step.optional()) {\n <small class=\"wr-stepper__optional\">optional</small>\n }\n @if (step.description()) {\n <small class=\"wr-stepper__description\">{{ step.description() }}</small>\n }\n </span>\n </button>\n @if (!$last) {\n <span class=\"wr-stepper__connector\" aria-hidden=\"true\"></span>\n }\n </li>\n }\n</ol>\n\n<div class=\"wr-stepper__body\">\n <ng-content />\n</div>\n", encapsulation: i0.ViewEncapsulation.None });
178
178
  }
179
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrStepper, decorators: [{
179
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrStepper, decorators: [{
180
180
  type: Component,
181
181
  args: [{ selector: 'wr-stepper', encapsulation: ViewEncapsulation.None, host: { '[class]': 'classes()' }, providers: [
182
182
  {
@@ -132,7 +132,16 @@ class WrStorage {
132
132
  engine = inject(WR_STORAGE_ENGINE);
133
133
  config = inject(WR_STORAGE_CONFIG);
134
134
  isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
135
- /** Per-key watchers. Shared so multiple `watch(k)` calls reuse one signal. */
135
+ /**
136
+ * Per-key watchers. Shared so multiple `watch(k)` calls reuse one signal.
137
+ *
138
+ * The fallback is kept alongside the signal because every refresh has to read
139
+ * the key the same way `watch` first did. Refreshing without it made `get` and
140
+ * `watch` disagree about what an ABSENT key means: after a `remove()` the
141
+ * signal went to `null` while `get(key, fallback)` still answered with the
142
+ * default, so a consumer watching `'theme'` with a `'light'` fallback got no
143
+ * theme at all rather than the light one.
144
+ */
136
145
  watchers = new Map();
137
146
  listenerInstalled = false;
138
147
  // Public API
@@ -220,8 +229,8 @@ class WrStorage {
220
229
  this.engine.clear();
221
230
  }
222
231
  // Refresh every active watcher — they may have just been cleared.
223
- for (const [k, sig] of this.watchers)
224
- sig.set(this.get(k));
232
+ for (const [k, entry] of this.watchers)
233
+ entry.sig.set(this.get(k, entry.fallback));
225
234
  }
226
235
  /** All known keys under our prefix, with the prefix stripped. */
227
236
  keys() {
@@ -235,12 +244,13 @@ class WrStorage {
235
244
  * `watch(k)` twice returns the same signal.
236
245
  */
237
246
  watch(key, fallback = null) {
238
- let sig = this.watchers.get(key);
239
- if (!sig) {
240
- sig = signal(this.get(key, fallback));
241
- this.watchers.set(key, sig);
242
- this.installCrossTabListener();
243
- }
247
+ const existing = this.watchers.get(key);
248
+ if (existing)
249
+ return existing.sig.asReadonly();
250
+ const sig = signal(this.get(key, fallback), /* @ts-ignore */
251
+ ...(ngDevMode ? [{ debugName: "sig" }] : /* istanbul ignore next */ []));
252
+ this.watchers.set(key, { sig: sig, fallback });
253
+ this.installCrossTabListener();
244
254
  return sig.asReadonly();
245
255
  }
246
256
  // Internals
@@ -248,9 +258,9 @@ class WrStorage {
248
258
  return this.config.prefix + key;
249
259
  }
250
260
  notify(key) {
251
- const sig = this.watchers.get(key);
252
- if (sig)
253
- sig.set(this.get(key));
261
+ const entry = this.watchers.get(key);
262
+ if (entry)
263
+ entry.sig.set(this.get(key, entry.fallback));
254
264
  }
255
265
  rawKeys() {
256
266
  const p = this.config.prefix;
@@ -274,8 +284,8 @@ class WrStorage {
274
284
  // `notify()` in `set`/`remove`/`clear`.
275
285
  if (event.key === null) {
276
286
  // Storage cleared from another tab.
277
- for (const [k, sig] of this.watchers)
278
- sig.set(this.get(k));
287
+ for (const [k, entry] of this.watchers)
288
+ entry.sig.set(this.get(k, entry.fallback));
279
289
  return;
280
290
  }
281
291
  const p = this.config.prefix;
@@ -284,10 +294,10 @@ class WrStorage {
284
294
  this.notify(p ? event.key.slice(p.length) : event.key);
285
295
  });
286
296
  }
287
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrStorage, deps: [], target: i0.ɵɵFactoryTarget.Service });
288
- static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.1.0", ngImport: i0, type: WrStorage });
297
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrStorage, deps: [], target: i0.ɵɵFactoryTarget.Service });
298
+ static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.1.1", ngImport: i0, type: WrStorage });
289
299
  }
290
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrStorage, decorators: [{
300
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrStorage, decorators: [{
291
301
  type: Service
292
302
  }] });
293
303
 
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-storage.mjs","sources":["../../../projects/lib/storage/storage-config.ts","../../../projects/lib/storage/storage-engine.ts","../../../projects/lib/storage/storage.ts","../../../projects/lib/storage/provide-wr-storage.ts","../../../projects/lib/storage/ngwr-storage.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrStorageConfigResolved } from './interfaces';\n\nexport const DEFAULT_WR_STORAGE_CONFIG: WrStorageConfigResolved = {\n prefix: '',\n json: true,\n ttl: 0,\n};\n\nexport const WR_STORAGE_CONFIG = new InjectionToken<WrStorageConfigResolved>('WR_STORAGE_CONFIG', {\n providedIn: 'root',\n factory: () => DEFAULT_WR_STORAGE_CONFIG,\n});\n\nexport type { WrStorageConfig, WrStorageConfigResolved } from './interfaces';\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrStorageEngine } from './interfaces';\n\n/**\n * Probe a `Storage` candidate to confirm it's writable. Safari private\n * mode, disabled cookies, and storage-blocked iframes all throw on\n * `setItem` — fall back to memory in those cases.\n */\nfunction probe(engine: WrStorageEngine): boolean {\n try {\n const k = '__wr_storage_probe__';\n engine.setItem(k, '1');\n engine.removeItem(k);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * In-memory implementation of `Storage`. Used as the SSR / private-mode\n * fallback. Exported so consumers can opt into it explicitly for tests.\n */\nexport function createMemoryStorage(): WrStorageEngine {\n const map = new Map<string, string>();\n return {\n get length(): number {\n return map.size;\n },\n clear(): void {\n map.clear();\n },\n getItem(key: string): string | null {\n return map.has(key) ? map.get(key)! : null;\n },\n key(i: number): string | null {\n return Array.from(map.keys())[i] ?? null;\n },\n removeItem(key: string): void {\n map.delete(key);\n },\n setItem(key: string, value: string): void {\n map.set(key, value);\n },\n };\n}\n\n/**\n * Injection token for the active storage engine. Override at any\n * injector level to swap engines (e.g. a feature module uses\n * `sessionStorage`; the rest uses `localStorage`):\n *\n * ```ts\n * providers: [{ provide: WR_STORAGE_ENGINE, useValue: sessionStorage }]\n * ```\n *\n * The default factory returns `localStorage` in the browser when it's\n * actually writable, an in-memory map otherwise.\n */\nexport const WR_STORAGE_ENGINE = new InjectionToken<WrStorageEngine>('WR_STORAGE_ENGINE', {\n providedIn: 'root',\n factory: () => {\n if (typeof localStorage === 'undefined') return createMemoryStorage();\n return probe(localStorage) ? localStorage : createMemoryStorage();\n },\n});\n\nexport type { WrStorageEngine } from './interfaces';\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { isPlatformBrowser } from '@angular/common';\nimport { Service, PLATFORM_ID, type Signal, type WritableSignal, inject, signal } from '@angular/core';\n\nimport { WR_STORAGE_CONFIG } from './storage-config';\nimport { WR_STORAGE_ENGINE } from './storage-engine';\n\n/** Envelope written when `json` mode is on. `e` is epoch-ms expiry. @internal */\ninterface Envelope<T> {\n readonly v: T;\n readonly e?: number;\n}\n\nfunction isEnvelope(x: unknown): x is Envelope<unknown> {\n return x !== null && typeof x === 'object' && 'v' in x;\n}\n\n/**\n * Reactive key/value storage on top of any `Storage`-compatible engine.\n *\n * - **Swap engines** through {@link WR_STORAGE_ENGINE} or\n * {@link provideWrStorage}. Default: `localStorage` with an in-memory\n * fallback for SSR / private mode.\n * - **Namespacing** via `prefix` (config) — every key is transparently\n * prefixed on read / write.\n * - **TTL** per-call or default — values past their expiry are removed\n * lazily on the next `get` / `watch` read.\n * - **Reactive watch** — `watch(key)` returns a `Signal` that updates on\n * local writes and cross-tab `storage` events.\n *\n * SSR-safe: the default engine factory returns an in-memory shim when\n * `localStorage` is unavailable, so reads always work.\n *\n * @example\n * ```ts\n * const store = inject(WrStorage);\n *\n * store.set('user', { name: 'Ada' });\n * store.get<{ name: string }>('user'); // { name: 'Ada' }\n *\n * store.set('cart', items, { ttl: 60_000 }); // expires in 60s\n *\n * const theme = store.watch<'light' | 'dark'>('theme', 'light');\n * effect(() => console.log('theme is', theme()));\n * ```\n *\n * @see https://ngwr.dev/reference/services/storage\n */\n@Service()\nexport class WrStorage {\n private readonly engine = inject(WR_STORAGE_ENGINE);\n private readonly config = inject(WR_STORAGE_CONFIG);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n /** Per-key watchers. Shared so multiple `watch(k)` calls reuse one signal. */\n private readonly watchers = new Map<string, WritableSignal<unknown>>();\n private listenerInstalled = false;\n\n // Public API\n\n /** Is `key` present (regardless of value / expiry)? */\n has(key: string): boolean {\n return this.engine.getItem(this.fullKey(key)) !== null;\n }\n\n /**\n * Read `key`. Returns `fallback` (default `null`) when the key is\n * missing or expired. Expired values are also removed as a side effect.\n */\n get<T = unknown>(key: string, fallback: T | null = null): T | null {\n const fk = this.fullKey(key);\n const raw = this.engine.getItem(fk);\n if (raw === null) return fallback;\n\n if (!this.config.json) return raw as unknown as T;\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n // Non-JSON value written by external code — return as-is.\n return raw as unknown as T;\n }\n\n if (!isEnvelope(parsed)) return parsed as T;\n\n if (parsed.e !== undefined && parsed.e < Date.now()) {\n this.remove(key);\n return fallback;\n }\n return parsed.v as T;\n }\n\n /**\n * Write `value` at `key`. Per-call `ttl` (ms) overrides the config\n * default. JSON-serializable values only when `json` is on (the default).\n */\n set<T = unknown>(key: string, value: T, opts?: { ttl?: number }): void {\n const fk = this.fullKey(key);\n let serialized: string;\n\n if (this.config.json) {\n const ttl = opts?.ttl ?? this.config.ttl;\n const env: Envelope<T> = ttl ? { v: value, e: Date.now() + ttl } : { v: value };\n try {\n serialized = JSON.stringify(env);\n } catch (err) {\n // eslint-disable-next-line no-console -- intentional diagnostic for unserialisable values\n console.warn('[ngwr/storage] value not JSON-serializable', err);\n return;\n }\n } else {\n serialized = String(value);\n }\n\n try {\n this.engine.setItem(fk, serialized);\n } catch (err) {\n // Quota exceeded / disabled / cleared mid-write — log + carry on.\n // eslint-disable-next-line no-console -- intentional diagnostic on storage write failure\n console.warn('[ngwr/storage] setItem failed', err);\n return;\n }\n this.notify(key);\n }\n\n /** Remove `key`. No-op when absent. */\n remove(key: string): void {\n this.engine.removeItem(this.fullKey(key));\n this.notify(key);\n }\n\n /**\n * Clear every key owned by this prefix. When `prefix` is empty this\n * defers to `engine.clear()` (clears everything — be careful with\n * shared storage).\n */\n clear(): void {\n const p = this.config.prefix;\n if (p) {\n for (const fk of this.rawKeys()) this.engine.removeItem(fk);\n } else {\n this.engine.clear();\n }\n // Refresh every active watcher — they may have just been cleared.\n for (const [k, sig] of this.watchers) sig.set(this.get(k));\n }\n\n /** All known keys under our prefix, with the prefix stripped. */\n keys(): readonly string[] {\n const p = this.config.prefix;\n return this.rawKeys().map(k => (p ? k.slice(p.length) : k));\n }\n\n /**\n * Reactive read of `key`. Updates when this instance writes to the key,\n * when `clear()` runs, and when another tab updates `localStorage`\n * under the same prefix. Returned signal is shared per key — calling\n * `watch(k)` twice returns the same signal.\n */\n watch<T = unknown>(key: string, fallback: T | null = null): Signal<T | null> {\n let sig = this.watchers.get(key) as WritableSignal<T | null> | undefined;\n if (!sig) {\n sig = signal<T | null>(this.get<T>(key, fallback));\n this.watchers.set(key, sig);\n this.installCrossTabListener();\n }\n return sig.asReadonly();\n }\n\n // Internals\n\n private fullKey(key: string): string {\n return this.config.prefix + key;\n }\n\n private notify(key: string): void {\n const sig = this.watchers.get(key);\n if (sig) sig.set(this.get(key));\n }\n\n private rawKeys(): string[] {\n const p = this.config.prefix;\n const out: string[] = [];\n for (let i = 0; i < this.engine.length; i++) {\n const k = this.engine.key(i);\n if (k === null) continue;\n if (!p || k.startsWith(p)) out.push(k);\n }\n return out;\n }\n\n private installCrossTabListener(): void {\n if (!this.isBrowser || this.listenerInstalled) return;\n this.listenerInstalled = true;\n window.addEventListener('storage', (event: StorageEvent) => {\n // `storage` only fires for `localStorage` / `sessionStorage`, and\n // only for changes from OTHER tabs. Local writes are handled by\n // `notify()` in `set`/`remove`/`clear`.\n if (event.key === null) {\n // Storage cleared from another tab.\n for (const [k, sig] of this.watchers) sig.set(this.get(k));\n return;\n }\n const p = this.config.prefix;\n if (p && !event.key.startsWith(p)) return;\n this.notify(p ? event.key.slice(p.length) : event.key);\n });\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type EnvironmentProviders, type Provider, makeEnvironmentProviders } from '@angular/core';\n\nimport {\n DEFAULT_WR_STORAGE_CONFIG,\n WR_STORAGE_CONFIG,\n type WrStorageConfig,\n type WrStorageConfigResolved,\n} from './storage-config';\nimport { WR_STORAGE_ENGINE, type WrStorageEngine } from './storage-engine';\n\n/**\n * Configure {@link WrStorage}. All fields optional — merged with defaults.\n *\n * @example Override the engine globally (e.g. session storage)\n * ```ts\n * provideWrStorage({ engine: sessionStorage })\n * ```\n *\n * @example Lazy engine factory (e.g. wrap localStorage with encryption)\n * ```ts\n * provideWrStorage({ engine: () => new EncryptedStorage(localStorage, key) })\n * ```\n *\n * @example Namespace + auto-expire\n * ```ts\n * provideWrStorage({ prefix: 'myapp:', ttl: 24 * 60 * 60 * 1000 })\n * ```\n */\nexport interface ProvideWrStorageOptions extends WrStorageConfig {\n /**\n * Storage engine. Either an instance (eager) or a factory (lazy —\n * called inside the injection context the first time `WR_STORAGE_ENGINE`\n * is read). Defaults to {@link WR_STORAGE_ENGINE}'s factory\n * (`localStorage` with in-memory fallback).\n */\n readonly engine?: WrStorageEngine | (() => WrStorageEngine);\n}\n\nexport function provideWrStorage(options: ProvideWrStorageOptions = {}): EnvironmentProviders {\n const { engine, ...config } = options;\n\n const merged: WrStorageConfigResolved = { ...DEFAULT_WR_STORAGE_CONFIG, ...config };\n\n const providers: Provider[] = [{ provide: WR_STORAGE_CONFIG, useValue: merged }];\n\n if (engine !== undefined) {\n providers.push(\n typeof engine === 'function'\n ? { provide: WR_STORAGE_ENGINE, useFactory: engine }\n : { provide: WR_STORAGE_ENGINE, useValue: engine }\n );\n }\n\n return makeEnvironmentProviders(providers);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAAA;;;;;AAKG;AAMI,MAAM,yBAAyB,GAA4B;AAChE,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,IAAI,EAAE,IAAI;AACV,IAAA,GAAG,EAAE,CAAC;;MAGK,iBAAiB,GAAG,IAAI,cAAc,CAA0B,mBAAmB,EAAE;AAChG,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,MAAM,yBAAyB;AACzC,CAAA;;ACpBD;;;;;AAKG;AAMH;;;;AAIG;AACH,SAAS,KAAK,CAAC,MAAuB,EAAA;AACpC,IAAA,IAAI;QACF,MAAM,CAAC,GAAG,sBAAsB;AAChC,QAAA,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG,CAAC;AACtB,QAAA,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;AACpB,QAAA,OAAO,IAAI;IACb;AAAE,IAAA,MAAM;AACN,QAAA,OAAO,KAAK;IACd;AACF;AAEA;;;AAGG;SACa,mBAAmB,GAAA;AACjC,IAAA,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkB;IACrC,OAAO;AACL,QAAA,IAAI,MAAM,GAAA;YACR,OAAO,GAAG,CAAC,IAAI;QACjB,CAAC;QACD,KAAK,GAAA;YACH,GAAG,CAAC,KAAK,EAAE;QACb,CAAC;AACD,QAAA,OAAO,CAAC,GAAW,EAAA;AACjB,YAAA,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAE,GAAG,IAAI;QAC5C,CAAC;AACD,QAAA,GAAG,CAAC,CA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MAAM,MAAM,GAA4B,EAAE,GAAG,yBAAyB,EAAE,GAAG,MAAM,EAAE;AAEnF,IAAA,MAAM,SAAS,GAAe,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAEhF,IAAA,IAAI,MAAM,KAAK,SAAS,EAAE;AACxB,QAAA,SAAS,CAAC,IAAI,CACZ,OAAO,MAAM,KAAK;cACd,EAAE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM;cAChD,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,EAAE,CACrD;IACH;AAEA,IAAA,OAAO,wBAAwB,CAAC,SAAS,CAAC;AAC5C;;AC7DA;;AAEG;;;;"}
1
+ {"version":3,"file":"ngwr-storage.mjs","sources":["../../../projects/lib/storage/storage-config.ts","../../../projects/lib/storage/storage-engine.ts","../../../projects/lib/storage/storage.ts","../../../projects/lib/storage/provide-wr-storage.ts","../../../projects/lib/storage/ngwr-storage.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrStorageConfigResolved } from './interfaces';\n\nexport const DEFAULT_WR_STORAGE_CONFIG: WrStorageConfigResolved = {\n prefix: '',\n json: true,\n ttl: 0,\n};\n\nexport const WR_STORAGE_CONFIG = new InjectionToken<WrStorageConfigResolved>('WR_STORAGE_CONFIG', {\n providedIn: 'root',\n factory: () => DEFAULT_WR_STORAGE_CONFIG,\n});\n\nexport type { WrStorageConfig, WrStorageConfigResolved } from './interfaces';\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrStorageEngine } from './interfaces';\n\n/**\n * Probe a `Storage` candidate to confirm it's writable. Safari private\n * mode, disabled cookies, and storage-blocked iframes all throw on\n * `setItem` — fall back to memory in those cases.\n */\nfunction probe(engine: WrStorageEngine): boolean {\n try {\n const k = '__wr_storage_probe__';\n engine.setItem(k, '1');\n engine.removeItem(k);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * In-memory implementation of `Storage`. Used as the SSR / private-mode\n * fallback. Exported so consumers can opt into it explicitly for tests.\n */\nexport function createMemoryStorage(): WrStorageEngine {\n const map = new Map<string, string>();\n return {\n get length(): number {\n return map.size;\n },\n clear(): void {\n map.clear();\n },\n getItem(key: string): string | null {\n return map.has(key) ? map.get(key)! : null;\n },\n key(i: number): string | null {\n return Array.from(map.keys())[i] ?? null;\n },\n removeItem(key: string): void {\n map.delete(key);\n },\n setItem(key: string, value: string): void {\n map.set(key, value);\n },\n };\n}\n\n/**\n * Injection token for the active storage engine. Override at any\n * injector level to swap engines (e.g. a feature module uses\n * `sessionStorage`; the rest uses `localStorage`):\n *\n * ```ts\n * providers: [{ provide: WR_STORAGE_ENGINE, useValue: sessionStorage }]\n * ```\n *\n * The default factory returns `localStorage` in the browser when it's\n * actually writable, an in-memory map otherwise.\n */\nexport const WR_STORAGE_ENGINE = new InjectionToken<WrStorageEngine>('WR_STORAGE_ENGINE', {\n providedIn: 'root',\n factory: () => {\n if (typeof localStorage === 'undefined') return createMemoryStorage();\n return probe(localStorage) ? localStorage : createMemoryStorage();\n },\n});\n\nexport type { WrStorageEngine } from './interfaces';\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { isPlatformBrowser } from '@angular/common';\nimport { Service, PLATFORM_ID, type Signal, type WritableSignal, inject, signal } from '@angular/core';\n\nimport { WR_STORAGE_CONFIG } from './storage-config';\nimport { WR_STORAGE_ENGINE } from './storage-engine';\n\n/** Envelope written when `json` mode is on. `e` is epoch-ms expiry. @internal */\ninterface Envelope<T> {\n readonly v: T;\n readonly e?: number;\n}\n\nfunction isEnvelope(x: unknown): x is Envelope<unknown> {\n return x !== null && typeof x === 'object' && 'v' in x;\n}\n\n/**\n * Reactive key/value storage on top of any `Storage`-compatible engine.\n *\n * - **Swap engines** through {@link WR_STORAGE_ENGINE} or\n * {@link provideWrStorage}. Default: `localStorage` with an in-memory\n * fallback for SSR / private mode.\n * - **Namespacing** via `prefix` (config) — every key is transparently\n * prefixed on read / write.\n * - **TTL** per-call or default — values past their expiry are removed\n * lazily on the next `get` / `watch` read.\n * - **Reactive watch** — `watch(key)` returns a `Signal` that updates on\n * local writes and cross-tab `storage` events.\n *\n * SSR-safe: the default engine factory returns an in-memory shim when\n * `localStorage` is unavailable, so reads always work.\n *\n * @example\n * ```ts\n * const store = inject(WrStorage);\n *\n * store.set('user', { name: 'Ada' });\n * store.get<{ name: string }>('user'); // { name: 'Ada' }\n *\n * store.set('cart', items, { ttl: 60_000 }); // expires in 60s\n *\n * const theme = store.watch<'light' | 'dark'>('theme', 'light');\n * effect(() => console.log('theme is', theme()));\n * ```\n *\n * @see https://ngwr.dev/reference/services/storage\n */\n@Service()\nexport class WrStorage {\n private readonly engine = inject(WR_STORAGE_ENGINE);\n private readonly config = inject(WR_STORAGE_CONFIG);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n /**\n * Per-key watchers. Shared so multiple `watch(k)` calls reuse one signal.\n *\n * The fallback is kept alongside the signal because every refresh has to read\n * the key the same way `watch` first did. Refreshing without it made `get` and\n * `watch` disagree about what an ABSENT key means: after a `remove()` the\n * signal went to `null` while `get(key, fallback)` still answered with the\n * default, so a consumer watching `'theme'` with a `'light'` fallback got no\n * theme at all rather than the light one.\n */\n private readonly watchers = new Map<string, { readonly sig: WritableSignal<unknown>; readonly fallback: unknown }>();\n private listenerInstalled = false;\n\n // Public API\n\n /** Is `key` present (regardless of value / expiry)? */\n has(key: string): boolean {\n return this.engine.getItem(this.fullKey(key)) !== null;\n }\n\n /**\n * Read `key`. Returns `fallback` (default `null`) when the key is\n * missing or expired. Expired values are also removed as a side effect.\n */\n get<T = unknown>(key: string, fallback: T | null = null): T | null {\n const fk = this.fullKey(key);\n const raw = this.engine.getItem(fk);\n if (raw === null) return fallback;\n\n if (!this.config.json) return raw as unknown as T;\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch {\n // Non-JSON value written by external code — return as-is.\n return raw as unknown as T;\n }\n\n if (!isEnvelope(parsed)) return parsed as T;\n\n if (parsed.e !== undefined && parsed.e < Date.now()) {\n this.remove(key);\n return fallback;\n }\n return parsed.v as T;\n }\n\n /**\n * Write `value` at `key`. Per-call `ttl` (ms) overrides the config\n * default. JSON-serializable values only when `json` is on (the default).\n */\n set<T = unknown>(key: string, value: T, opts?: { ttl?: number }): void {\n const fk = this.fullKey(key);\n let serialized: string;\n\n if (this.config.json) {\n const ttl = opts?.ttl ?? this.config.ttl;\n const env: Envelope<T> = ttl ? { v: value, e: Date.now() + ttl } : { v: value };\n try {\n serialized = JSON.stringify(env);\n } catch (err) {\n // eslint-disable-next-line no-console -- intentional diagnostic for unserialisable values\n console.warn('[ngwr/storage] value not JSON-serializable', err);\n return;\n }\n } else {\n serialized = String(value);\n }\n\n try {\n this.engine.setItem(fk, serialized);\n } catch (err) {\n // Quota exceeded / disabled / cleared mid-write — log + carry on.\n // eslint-disable-next-line no-console -- intentional diagnostic on storage write failure\n console.warn('[ngwr/storage] setItem failed', err);\n return;\n }\n this.notify(key);\n }\n\n /** Remove `key`. No-op when absent. */\n remove(key: string): void {\n this.engine.removeItem(this.fullKey(key));\n this.notify(key);\n }\n\n /**\n * Clear every key owned by this prefix. When `prefix` is empty this\n * defers to `engine.clear()` (clears everything — be careful with\n * shared storage).\n */\n clear(): void {\n const p = this.config.prefix;\n if (p) {\n for (const fk of this.rawKeys()) this.engine.removeItem(fk);\n } else {\n this.engine.clear();\n }\n // Refresh every active watcher — they may have just been cleared.\n for (const [k, entry] of this.watchers) entry.sig.set(this.get(k, entry.fallback));\n }\n\n /** All known keys under our prefix, with the prefix stripped. */\n keys(): readonly string[] {\n const p = this.config.prefix;\n return this.rawKeys().map(k => (p ? k.slice(p.length) : k));\n }\n\n /**\n * Reactive read of `key`. Updates when this instance writes to the key,\n * when `clear()` runs, and when another tab updates `localStorage`\n * under the same prefix. Returned signal is shared per key — calling\n * `watch(k)` twice returns the same signal.\n */\n watch<T = unknown>(key: string, fallback: T | null = null): Signal<T | null> {\n const existing = this.watchers.get(key);\n if (existing) return (existing.sig as WritableSignal<T | null>).asReadonly();\n\n const sig = signal<T | null>(this.get<T>(key, fallback));\n this.watchers.set(key, { sig: sig, fallback });\n this.installCrossTabListener();\n return sig.asReadonly();\n }\n\n // Internals\n\n private fullKey(key: string): string {\n return this.config.prefix + key;\n }\n\n private notify(key: string): void {\n const entry = this.watchers.get(key);\n if (entry) entry.sig.set(this.get(key, entry.fallback));\n }\n\n private rawKeys(): string[] {\n const p = this.config.prefix;\n const out: string[] = [];\n for (let i = 0; i < this.engine.length; i++) {\n const k = this.engine.key(i);\n if (k === null) continue;\n if (!p || k.startsWith(p)) out.push(k);\n }\n return out;\n }\n\n private installCrossTabListener(): void {\n if (!this.isBrowser || this.listenerInstalled) return;\n this.listenerInstalled = true;\n window.addEventListener('storage', (event: StorageEvent) => {\n // `storage` only fires for `localStorage` / `sessionStorage`, and\n // only for changes from OTHER tabs. Local writes are handled by\n // `notify()` in `set`/`remove`/`clear`.\n if (event.key === null) {\n // Storage cleared from another tab.\n for (const [k, entry] of this.watchers) entry.sig.set(this.get(k, entry.fallback));\n return;\n }\n const p = this.config.prefix;\n if (p && !event.key.startsWith(p)) return;\n this.notify(p ? event.key.slice(p.length) : event.key);\n });\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type EnvironmentProviders, type Provider, makeEnvironmentProviders } from '@angular/core';\n\nimport {\n DEFAULT_WR_STORAGE_CONFIG,\n WR_STORAGE_CONFIG,\n type WrStorageConfig,\n type WrStorageConfigResolved,\n} from './storage-config';\nimport { WR_STORAGE_ENGINE, type WrStorageEngine } from './storage-engine';\n\n/**\n * Configure {@link WrStorage}. All fields optional — merged with defaults.\n *\n * @example Override the engine globally (e.g. session storage)\n * ```ts\n * provideWrStorage({ engine: sessionStorage })\n * ```\n *\n * @example Lazy engine factory (e.g. wrap localStorage with encryption)\n * ```ts\n * provideWrStorage({ engine: () => new EncryptedStorage(localStorage, key) })\n * ```\n *\n * @example Namespace + auto-expire\n * ```ts\n * provideWrStorage({ prefix: 'myapp:', ttl: 24 * 60 * 60 * 1000 })\n * ```\n */\nexport interface ProvideWrStorageOptions extends WrStorageConfig {\n /**\n * Storage engine. Either an instance (eager) or a factory (lazy —\n * called inside the injection context the first time `WR_STORAGE_ENGINE`\n * is read). Defaults to {@link WR_STORAGE_ENGINE}'s factory\n * (`localStorage` with in-memory fallback).\n */\n readonly engine?: WrStorageEngine | (() => WrStorageEngine);\n}\n\nexport function provideWrStorage(options: ProvideWrStorageOptions = {}): EnvironmentProviders {\n const { engine, ...config } = options;\n\n const merged: WrStorageConfigResolved = { ...DEFAULT_WR_STORAGE_CONFIG, ...config };\n\n const providers: Provider[] = [{ provide: WR_STORAGE_CONFIG, useValue: merged }];\n\n if (engine !== undefined) {\n providers.push(\n typeof engine === 'function'\n ? { provide: WR_STORAGE_ENGINE, useFactory: engine }\n : { provide: WR_STORAGE_ENGINE, useValue: engine }\n );\n }\n\n return makeEnvironmentProviders(providers);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAAA;;;;;AAKG;AAMI,MAAM,yBAAyB,GAA4B;AAChE,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,IAAI,EAAE,IAAI;AACV,IAAA,GAAG,EAAE,CAAC;;MAGK,iBAAiB,GAAG,IAAI,cAAc,CAA0B,mBAAmB,EAAE;AAChG,IAAA,UAAU,EAAE,MAAM;A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C,IAAI,CACZ,OAAO,MAAM,KAAK;cACd,EAAE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM;cAChD,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,EAAE,CACrD;IACH;AAEA,IAAA,OAAO,wBAAwB,CAAC,SAAS,CAAC;AAC5C;;AC7DA;;AAEG;;;;"}
@@ -54,10 +54,10 @@ class WrSwitch {
54
54
  onInputBlur() {
55
55
  this.touch.emit();
56
56
  }
57
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrSwitch, deps: [], target: i0.ɵɵFactoryTarget.Component });
58
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.0", type: WrSwitch, isStandalone: true, selector: "wr-switch", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checked: "checkedChange", touch: "touch" }, host: { properties: { "class": "classes()" } }, ngImport: i0, template: "<label class=\"wr-switch__label\" [for]=\"id()\">\n <input\n class=\"wr-switch__input\"\n type=\"checkbox\"\n role=\"switch\"\n [id]=\"id()\"\n [attr.aria-label]=\"ariaLabel()\"\n [checked]=\"checked()\"\n [disabled]=\"disabled()\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur()\"\n />\n\n <span class=\"wr-switch__track\" aria-hidden=\"true\">\n <span class=\"wr-switch__thumb\"></span>\n </span>\n\n <span class=\"wr-switch__text\">\n <ng-content />\n </span>\n</label>\n", encapsulation: i0.ViewEncapsulation.None });
57
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrSwitch, deps: [], target: i0.ɵɵFactoryTarget.Component });
58
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.1.1", type: WrSwitch, isStandalone: true, selector: "wr-switch", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checked: "checkedChange", touch: "touch" }, host: { properties: { "class": "classes()" } }, ngImport: i0, template: "<label class=\"wr-switch__label\" [for]=\"id()\">\n <input\n class=\"wr-switch__input\"\n type=\"checkbox\"\n role=\"switch\"\n [id]=\"id()\"\n [attr.aria-label]=\"ariaLabel()\"\n [checked]=\"checked()\"\n [disabled]=\"disabled()\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur()\"\n />\n\n <span class=\"wr-switch__track\" aria-hidden=\"true\">\n <span class=\"wr-switch__thumb\"></span>\n </span>\n\n <span class=\"wr-switch__text\">\n <ng-content />\n </span>\n</label>\n", encapsulation: i0.ViewEncapsulation.None });
59
59
  }
60
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.0", ngImport: i0, type: WrSwitch, decorators: [{
60
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrSwitch, decorators: [{
61
61
  type: Component,
62
62
  args: [{ selector: 'wr-switch', encapsulation: ViewEncapsulation.None, host: { '[class]': 'classes()' }, template: "<label class=\"wr-switch__label\" [for]=\"id()\">\n <input\n class=\"wr-switch__input\"\n type=\"checkbox\"\n role=\"switch\"\n [id]=\"id()\"\n [attr.aria-label]=\"ariaLabel()\"\n [checked]=\"checked()\"\n [disabled]=\"disabled()\"\n (change)=\"onInputChange($event)\"\n (blur)=\"onInputBlur()\"\n />\n\n <span class=\"wr-switch__track\" aria-hidden=\"true\">\n <span class=\"wr-switch__thumb\"></span>\n </span>\n\n <span class=\"wr-switch__text\">\n <ng-content />\n </span>\n</label>\n" }]
63
63
  }], propDecorators: { ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }, { type: i0.Output, args: ["checkedChange"] }], touch: [{ type: i0.Output, args: ["touch"] }] } });