@angular/core 18.1.1 → 18.1.2

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 (35) hide show
  1. package/esm2022/primitives/event-dispatch/index.mjs +2 -1
  2. package/esm2022/primitives/event-dispatch/src/bootstrap_app_scoped.mjs +18 -3
  3. package/esm2022/primitives/event-dispatch/src/bootstrap_global.mjs +18 -7
  4. package/esm2022/primitives/event-dispatch/src/earlyeventcontract.mjs +25 -1
  5. package/esm2022/primitives/event-dispatch/src/event_type.mjs +2 -2
  6. package/esm2022/primitives/event-dispatch/src/eventcontract.mjs +40 -35
  7. package/esm2022/rxjs-interop/src/to_signal.mjs +6 -5
  8. package/esm2022/src/event_delegation_utils.mjs +7 -7
  9. package/esm2022/src/event_dispatch/event_delegation.mjs +2 -4
  10. package/esm2022/src/hydration/event_replay.mjs +6 -6
  11. package/esm2022/src/render3/after_render_hooks.mjs +2 -2
  12. package/esm2022/src/render3/component_ref.mjs +1 -1
  13. package/esm2022/src/version.mjs +1 -1
  14. package/esm2022/testing/src/logger.mjs +3 -3
  15. package/event-dispatch-contract.min.js +1 -1
  16. package/fesm2022/core.mjs +15 -16
  17. package/fesm2022/core.mjs.map +1 -1
  18. package/fesm2022/primitives/event-dispatch.mjs +144 -35
  19. package/fesm2022/primitives/event-dispatch.mjs.map +1 -1
  20. package/fesm2022/primitives/signals.mjs +1 -1
  21. package/fesm2022/rxjs-interop.mjs +6 -5
  22. package/fesm2022/rxjs-interop.mjs.map +1 -1
  23. package/fesm2022/testing.mjs +1 -1
  24. package/index.d.ts +2 -2
  25. package/package.json +1 -1
  26. package/primitives/event-dispatch/index.d.ts +28 -13
  27. package/primitives/signals/index.d.ts +1 -1
  28. package/rxjs-interop/index.d.ts +1 -1
  29. package/schematics/migrations/invalid-two-way-bindings/bundle.js +6 -3
  30. package/schematics/migrations/invalid-two-way-bindings/bundle.js.map +2 -2
  31. package/schematics/ng-generate/control-flow-migration/bundle.js +6 -3
  32. package/schematics/ng-generate/control-flow-migration/bundle.js.map +2 -2
  33. package/schematics/ng-generate/standalone-migration/bundle.js +15 -12
  34. package/schematics/ng-generate/standalone-migration/bundle.js.map +2 -2
  35. package/testing/index.d.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v18.1.1
2
+ * @license Angular v18.1.2
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -407,7 +407,7 @@ const CAPTURE_EVENT_TYPES = [
407
407
  */
408
408
  const isCaptureEventType = (eventType) => CAPTURE_EVENT_TYPES.indexOf(eventType) >= 0;
409
409
  /** All event types that are registered early. */
410
- const EARLY_EVENT_TYPES = [...BUBBLE_EVENT_TYPES, ...CAPTURE_EVENT_TYPES];
410
+ const EARLY_EVENT_TYPES = BUBBLE_EVENT_TYPES.concat(CAPTURE_EVENT_TYPES);
411
411
  /**
412
412
  * Whether or not an event type is registered in the early contract.
413
413
  */
@@ -1660,7 +1660,7 @@ function shouldPreventDefaultBeforeDispatching(actionElement, eventInfoWrapper)
1660
1660
  * Registers deferred functionality for an EventContract and a Jsaction
1661
1661
  * Dispatcher.
1662
1662
  */
1663
- function registerDispatcher$1(eventContract, dispatcher) {
1663
+ function registerDispatcher$2(eventContract, dispatcher) {
1664
1664
  eventContract.ecrd((eventInfo) => {
1665
1665
  dispatcher.dispatch(eventInfo);
1666
1666
  }, Restriction.I_AM_THE_JSACTION_FRAMEWORK);
@@ -1778,18 +1778,110 @@ function patchEventInstance(event, property, value, { configurable = false } = {
1778
1778
  * Registers deferred functionality for an EventContract and a Jsaction
1779
1779
  * Dispatcher.
1780
1780
  */
1781
- function registerDispatcher(eventContract, dispatcher) {
1781
+ function registerDispatcher$1(eventContract, dispatcher) {
1782
1782
  eventContract.ecrd((eventInfo) => {
1783
1783
  dispatcher.dispatch(eventInfo);
1784
1784
  }, Restriction.I_AM_THE_JSACTION_FRAMEWORK);
1785
1785
  }
1786
1786
 
1787
+ /**
1788
+ * EarlyEventContract intercepts events in the bubbling phase at the
1789
+ * boundary of the document body. This mapping will be passed to the
1790
+ * late-loaded EventContract.
1791
+ */
1792
+ class EarlyEventContract {
1793
+ constructor(dataContainer = window, container = window.document.documentElement) {
1794
+ this.dataContainer = dataContainer;
1795
+ dataContainer._ejsa = createEarlyJsactionData(container);
1796
+ }
1797
+ /**
1798
+ * Installs a list of event types for container .
1799
+ */
1800
+ addEvents(types, capture) {
1801
+ addEvents(this.dataContainer._ejsa, types, capture);
1802
+ }
1803
+ }
1804
+ /** Creates an `EarlyJsactionData` object. */
1805
+ function createEarlyJsactionData(container) {
1806
+ const q = [];
1807
+ const d = (eventInfo) => {
1808
+ q.push(eventInfo);
1809
+ };
1810
+ const h = (event) => {
1811
+ d(createEventInfoFromParameters(event.type, event, event.target, container, Date.now()));
1812
+ };
1813
+ return {
1814
+ c: container,
1815
+ q,
1816
+ et: [],
1817
+ etc: [],
1818
+ d,
1819
+ h,
1820
+ };
1821
+ }
1822
+ /** Add all the events to the container stored in the `EarlyJsactionData`. */
1823
+ function addEvents(earlyJsactionData, types, capture) {
1824
+ for (let i = 0; i < types.length; i++) {
1825
+ const eventType = types[i];
1826
+ const eventTypes = capture ? earlyJsactionData.etc : earlyJsactionData.et;
1827
+ eventTypes.push(eventType);
1828
+ earlyJsactionData.c.addEventListener(eventType, earlyJsactionData.h, capture);
1829
+ }
1830
+ }
1831
+ /** Get the queued `EventInfo` objects that were dispatched before a dispatcher was registered. */
1832
+ function getQueuedEventInfos(earlyJsactionData) {
1833
+ return earlyJsactionData?.q ?? [];
1834
+ }
1835
+ /** Register a different dispatcher function on the `EarlyJsactionData`. */
1836
+ function registerDispatcher(earlyJsactionData, dispatcher) {
1837
+ if (!earlyJsactionData) {
1838
+ return;
1839
+ }
1840
+ earlyJsactionData.d = dispatcher;
1841
+ }
1842
+ /** Removes all event listener handlers. */
1843
+ function removeAllEventListeners(earlyJsactionData) {
1844
+ if (!earlyJsactionData) {
1845
+ return;
1846
+ }
1847
+ removeEventListeners(earlyJsactionData.c, earlyJsactionData.et, earlyJsactionData.h);
1848
+ removeEventListeners(earlyJsactionData.c, earlyJsactionData.etc, earlyJsactionData.h, true);
1849
+ }
1850
+ function removeEventListeners(container, eventTypes, earlyEventHandler, capture) {
1851
+ for (let i = 0; i < eventTypes.length; i++) {
1852
+ container.removeEventListener(eventTypes[i], earlyEventHandler, /* useCapture */ capture);
1853
+ }
1854
+ }
1855
+
1787
1856
  /**
1788
1857
  * @define Support for the non-bubbling mouseenter and mouseleave events. This
1789
1858
  * flag can be overridden in a build rule.
1790
1859
  */
1791
1860
  const MOUSE_SPECIAL_SUPPORT = false;
1792
1861
 
1862
+ /**
1863
+ * @fileoverview Implements the local event handling contract. This
1864
+ * allows DOM objects in a container that enters into this contract to
1865
+ * define event handlers which are executed in a local context.
1866
+ *
1867
+ * One EventContract instance can manage the contract for multiple
1868
+ * containers, which are added using the addContainer() method.
1869
+ *
1870
+ * Events can be registered using the addEvent() method.
1871
+ *
1872
+ * A Dispatcher is added using the registerDispatcher() method. Until there is
1873
+ * a dispatcher, events are queued. The idea is that the EventContract
1874
+ * class is inlined in the HTML of the top level page and instantiated
1875
+ * right after the start of <body>. The Dispatcher class is contained
1876
+ * in the external deferred js, and instantiated and registered with
1877
+ * EventContract when the external javascript in the page loads. The
1878
+ * external javascript will also register the jsaction handlers, which
1879
+ * then pick up the queued events at the time of registration.
1880
+ *
1881
+ * Since this class is meant to be inlined in the main page HTML, the
1882
+ * size of the binary compiled from this file MUST be kept as small as
1883
+ * possible and thus its dependencies to a minimum.
1884
+ */
1793
1885
  /**
1794
1886
  * EventContract intercepts events in the bubbling phase at the
1795
1887
  * boundary of a container element, and maps them to generic actions
@@ -1806,8 +1898,7 @@ const MOUSE_SPECIAL_SUPPORT = false;
1806
1898
  */
1807
1899
  class EventContract {
1808
1900
  static { this.MOUSE_SPECIAL_SUPPORT = MOUSE_SPECIAL_SUPPORT; }
1809
- constructor(containerManager, useActionResolver) {
1810
- this.useActionResolver = useActionResolver;
1901
+ constructor(containerManager) {
1811
1902
  /**
1812
1903
  * The DOM events which this contract covers. Used to prevent double
1813
1904
  * registration of event types. The value of the map is the
@@ -1902,23 +1993,27 @@ class EventContract {
1902
1993
  return;
1903
1994
  }
1904
1995
  // Replay the early contract events.
1905
- const earlyEventInfos = earlyJsactionData.q;
1906
- for (let idx = 0; idx < earlyEventInfos.length; idx++) {
1907
- const earlyEventInfo = earlyEventInfos[idx];
1996
+ this.replayEarlyEventInfos(earlyJsactionData.q);
1997
+ // Clean up the early contract.
1998
+ removeAllEventListeners(earlyJsactionData);
1999
+ delete window._ejsa;
2000
+ }
2001
+ /**
2002
+ * Replays all the early `EventInfo` objects, dispatching them through the normal
2003
+ * `EventContract` flow.
2004
+ */
2005
+ replayEarlyEventInfos(earlyEventInfos) {
2006
+ for (let i = 0; i < earlyEventInfos.length; i++) {
2007
+ const earlyEventInfo = earlyEventInfos[i];
1908
2008
  const eventTypes = this.getEventTypesForBrowserEventType(earlyEventInfo.eventType);
1909
- for (let i = 0; i < eventTypes.length; i++) {
2009
+ for (let j = 0; j < eventTypes.length; j++) {
1910
2010
  const eventInfo = cloneEventInfo(earlyEventInfo);
1911
2011
  // EventInfo eventType maps to JSAction's internal event type,
1912
2012
  // rather than the browser event type.
1913
- setEventType(eventInfo, eventTypes[i]);
2013
+ setEventType(eventInfo, eventTypes[j]);
1914
2014
  this.handleEventInfo(eventInfo);
1915
2015
  }
1916
2016
  }
1917
- // Clean up the early contract.
1918
- const earlyEventHandler = earlyJsactionData.h;
1919
- removeEventListeners(earlyJsactionData.c, earlyJsactionData.et, earlyEventHandler);
1920
- removeEventListeners(earlyJsactionData.c, earlyJsactionData.etc, earlyEventHandler, true);
1921
- delete window._ejsa;
1922
2017
  }
1923
2018
  /**
1924
2019
  * Returns all JSAction event types that have been registered for a given
@@ -1979,29 +2074,43 @@ class EventContract {
1979
2074
  this.queuedEventInfos = null;
1980
2075
  }
1981
2076
  }
1982
- /**
1983
- * Adds a11y click support to the given `EventContract`. Meant to be called in
1984
- * the same compilation unit as the `EventContract`.
1985
- */
1986
- addA11yClickSupport() { }
1987
- /**
1988
- * Enables a11y click support to be deferred. Meant to be called in the same
1989
- * compilation unit as the `EventContract`.
1990
- */
1991
- exportAddA11yClickSupport() { }
1992
2077
  }
1993
- function removeEventListeners(container, eventTypes, earlyEventHandler, capture) {
1994
- for (let idx = 0; idx < eventTypes.length; idx++) {
1995
- container.removeEventListener(eventTypes[idx], earlyEventHandler, /* useCapture */ capture);
2078
+
2079
+ /**
2080
+ * Creates an `EarlyJsactionData`, adds events to it, and populates it on a nested object on
2081
+ * the window.
2082
+ */
2083
+ function bootstrapAppScopedEarlyEventContract(container, appId, bubbleEventTypes, captureEventTypes, dataContainer = window) {
2084
+ const earlyJsactionData = createEarlyJsactionData(container);
2085
+ if (!dataContainer._ejsas) {
2086
+ dataContainer._ejsas = {};
1996
2087
  }
2088
+ dataContainer._ejsas[appId] = earlyJsactionData;
2089
+ addEvents(earlyJsactionData, bubbleEventTypes);
2090
+ addEvents(earlyJsactionData, captureEventTypes, /* capture= */ true);
2091
+ }
2092
+ /** Get the queued `EventInfo` objects that were dispatched before a dispatcher was registered. */
2093
+ function getAppScopedQueuedEventInfos(appId, dataContainer = window) {
2094
+ return getQueuedEventInfos(dataContainer._ejsas?.[appId]);
1997
2095
  }
1998
2096
  /**
1999
- * Adds a11y click support to the given `EventContract`. Meant to be called
2000
- * in a different compilation unit from the `EventContract`. The `EventContract`
2001
- * must have called `exportAddA11yClickSupport` in its compilation unit for this
2002
- * to have any effect.
2097
+ * Registers a dispatcher function on the `EarlyJsactionData` present on the nested object on the
2098
+ * window.
2003
2099
  */
2004
- function addDeferredA11yClickSupport(eventContract) { }
2100
+ function registerAppScopedDispatcher(restriction, appId, dispatcher, dataContainer = window) {
2101
+ registerDispatcher(dataContainer._ejsas?.[appId], dispatcher);
2102
+ }
2103
+ /** Removes all event listener handlers. */
2104
+ function removeAllAppScopedEventListeners(appId, dataContainer = window) {
2105
+ removeAllEventListeners(dataContainer._ejsas?.[appId]);
2106
+ }
2107
+ /** Clear the early event contract. */
2108
+ function clearAppScopedEarlyEventContract(appId, dataContainer = window) {
2109
+ if (!dataContainer._ejsas) {
2110
+ return;
2111
+ }
2112
+ dataContainer._ejsas[appId] = undefined;
2113
+ }
2005
2114
 
2006
- export { Attribute, EventContract, EventContractContainer, EventDispatcher, EventInfoWrapper, EventPhase, getDefaulted as getActionCache, isCaptureEventType, isEarlyEventType, registerDispatcher };
2115
+ export { Attribute, EventContract, EventContractContainer, EventDispatcher, EventInfoWrapper, EventPhase, bootstrapAppScopedEarlyEventContract, clearAppScopedEarlyEventContract, getDefaulted as getActionCache, getAppScopedQueuedEventInfos, isCaptureEventType, isEarlyEventType, registerAppScopedDispatcher, registerDispatcher$1 as registerDispatcher, removeAllAppScopedEventListeners };
2007
2116
  //# sourceMappingURL=event-dispatch.mjs.map