@angular/core 18.0.0-next.4 → 18.0.0-next.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/esm2022/primitives/event-dispatch/contract_binary.mjs +10 -0
- package/esm2022/primitives/event-dispatch/index.mjs +13 -0
- package/esm2022/primitives/event-dispatch/src/a11y_click.mjs +54 -0
- package/esm2022/primitives/event-dispatch/src/accessibility.mjs +35 -0
- package/esm2022/primitives/event-dispatch/src/attribute.mjs +72 -0
- package/esm2022/primitives/event-dispatch/src/base_dispatcher.mjs +196 -0
- package/esm2022/primitives/event-dispatch/src/cache.mjs +95 -0
- package/esm2022/primitives/event-dispatch/src/char.mjs +35 -0
- package/esm2022/primitives/event-dispatch/src/custom_events.mjs +63 -0
- package/esm2022/primitives/event-dispatch/src/dispatcher.mjs +254 -0
- package/esm2022/primitives/event-dispatch/src/dom.mjs +48 -0
- package/esm2022/primitives/event-dispatch/src/earlyeventcontract.mjs +36 -0
- package/esm2022/primitives/event-dispatch/src/event.mjs +638 -0
- package/esm2022/primitives/event-dispatch/src/event_contract_container.mjs +63 -0
- package/esm2022/primitives/event-dispatch/src/event_contract_defines.mjs +48 -0
- package/esm2022/primitives/event-dispatch/src/event_contract_multi_container.mjs +192 -0
- package/esm2022/primitives/event-dispatch/src/event_handler.mjs +9 -0
- package/esm2022/primitives/event-dispatch/src/event_info.mjs +199 -0
- package/esm2022/primitives/event-dispatch/src/event_type.mjs +244 -0
- package/esm2022/primitives/event-dispatch/src/eventcontract.mjs +675 -0
- package/esm2022/primitives/event-dispatch/src/key_code.mjs +21 -0
- package/esm2022/primitives/event-dispatch/src/legacy_dispatcher.mjs +9 -0
- package/esm2022/primitives/event-dispatch/src/property.mjs +35 -0
- package/esm2022/primitives/event-dispatch/src/register_events.mjs +32 -0
- package/esm2022/primitives/event-dispatch/src/replay.mjs +389 -0
- package/esm2022/primitives/event-dispatch/src/restriction.mjs +15 -0
- package/esm2022/primitives/signals/index.mjs +3 -3
- package/esm2022/primitives/signals/src/computed.mjs +5 -3
- package/esm2022/primitives/signals/src/graph.mjs +14 -9
- package/esm2022/primitives/signals/src/signal.mjs +2 -2
- package/esm2022/primitives/signals/src/watch.mjs +2 -2
- package/esm2022/src/application/application_ref.mjs +4 -2
- package/esm2022/src/change_detection/scheduling/flags.mjs +10 -0
- package/esm2022/src/change_detection/scheduling/ng_zone_scheduling.mjs +18 -33
- package/esm2022/src/change_detection/scheduling/zoneless_scheduling.mjs +1 -1
- package/esm2022/src/change_detection/scheduling/zoneless_scheduling_impl.mjs +111 -9
- package/esm2022/src/core.mjs +3 -1
- package/esm2022/src/core_private_export.mjs +2 -3
- package/esm2022/src/debug/debug_node.mjs +1 -1
- package/esm2022/src/defer/instructions.mjs +31 -8
- package/esm2022/src/di/host_tag_name_token.mjs +65 -0
- package/esm2022/src/di/index.mjs +2 -1
- package/esm2022/src/errors.mjs +1 -1
- package/esm2022/src/hydration/annotate.mjs +15 -1
- package/esm2022/src/hydration/event_replay.mjs +181 -0
- package/esm2022/src/hydration/tokens.mjs +6 -1
- package/esm2022/src/metadata/directives.mjs +1 -62
- package/esm2022/src/pending_tasks.mjs +54 -11
- package/esm2022/src/platform/platform_ref.mjs +3 -3
- package/esm2022/src/render3/component_ref.mjs +1 -1
- package/esm2022/src/render3/context_discovery.mjs +15 -1
- package/esm2022/src/render3/instructions/control_flow.mjs +55 -8
- package/esm2022/src/render3/list_reconciliation.mjs +41 -1
- package/esm2022/src/testability/testability.mjs +2 -30
- package/esm2022/src/util/callback_scheduler.mjs +14 -3
- package/esm2022/src/version.mjs +1 -1
- package/esm2022/src/zone/ng_zone.mjs +22 -6
- package/esm2022/testing/src/async.mjs +2 -10
- package/esm2022/testing/src/component_fixture.mjs +7 -12
- package/esm2022/testing/src/defer.mjs +1 -2
- package/esm2022/testing/src/logger.mjs +3 -3
- package/esm2022/testing/src/test_bed_common.mjs +1 -6
- package/esm2022/testing/src/testing.mjs +1 -2
- package/event-dispatch-contract.min.js +1 -0
- package/fesm2022/core.mjs +608 -174
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +3044 -0
- package/fesm2022/primitives/event-dispatch.mjs.map +1 -0
- package/fesm2022/primitives/signals.mjs +17 -10
- package/fesm2022/primitives/signals.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +1 -1
- package/fesm2022/testing.mjs +35 -54
- package/fesm2022/testing.mjs.map +1 -1
- package/index.d.ts +199 -115
- package/package.json +10 -1
- package/primitives/event-dispatch/index.d.ts +627 -0
- package/primitives/signals/index.d.ts +1 -1
- package/rxjs-interop/index.d.ts +1 -1
- package/schematics/migrations/{transfer-state → http-providers}/bundle.js +254 -68
- package/schematics/migrations/http-providers/bundle.js.map +7 -0
- package/schematics/migrations/invalid-two-way-bindings/bundle.js +690 -413
- package/schematics/migrations/invalid-two-way-bindings/bundle.js.map +3 -3
- package/schematics/migrations.json +6 -16
- package/schematics/ng-generate/control-flow-migration/bundle.js +693 -417
- package/schematics/ng-generate/control-flow-migration/bundle.js.map +3 -3
- package/schematics/ng-generate/standalone-migration/bundle.js +1072 -735
- package/schematics/ng-generate/standalone-migration/bundle.js.map +3 -3
- package/testing/index.d.ts +2 -15
- package/esm2022/testing/src/private_export.mjs +0 -9
- package/schematics/migrations/block-template-entities/bundle.js +0 -22853
- package/schematics/migrations/block-template-entities/bundle.js.map +0 -7
- package/schematics/migrations/compiler-options/bundle.js +0 -582
- package/schematics/migrations/compiler-options/bundle.js.map +0 -7
- package/schematics/migrations/transfer-state/bundle.js.map +0 -7
|
@@ -0,0 +1,627 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Angular v18.0.0-next.6
|
|
3
|
+
* (c) 2010-2024 Google LLC. https://angular.io/
|
|
4
|
+
* License: MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
declare namespace a11yClickLib {
|
|
9
|
+
export {
|
|
10
|
+
updateEventInfoForA11yClick,
|
|
11
|
+
preventDefaultForA11yClick,
|
|
12
|
+
populateClickOnlyAction
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Records information about the action that should handle a given `Event`.
|
|
19
|
+
*/
|
|
20
|
+
declare interface ActionInfo {
|
|
21
|
+
name: string;
|
|
22
|
+
element: Element;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
declare type ActionInfoInternal = [name: string, element: Element];
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Provides a factory function for bootstrapping an event contract on a
|
|
29
|
+
* window object.
|
|
30
|
+
* @param field The property on the window that the event contract will be placed on.
|
|
31
|
+
* @param container The container that listens to events
|
|
32
|
+
* @param appId A given identifier for an application. If there are multiple apps on the page
|
|
33
|
+
* then this is how contracts can be initialized for each one.
|
|
34
|
+
* @param events An array of event names that should be listened to.
|
|
35
|
+
* @param anyWindow The global window object that should receive the event contract.
|
|
36
|
+
* @returns The `event` contract. This is both assigned to `anyWindow` and returned for testing.
|
|
37
|
+
*/
|
|
38
|
+
export declare function bootstrapEventContract(field: string, container: Element, appId: string, events: string[], anyWindow?: any): EventContract;
|
|
39
|
+
|
|
40
|
+
/** Clones an `EventInfo` */
|
|
41
|
+
declare function cloneEventInfo(eventInfo: EventInfo): EventInfo;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Utility function for creating an `EventInfo`.
|
|
45
|
+
*
|
|
46
|
+
* This should be used in compilation units that are less sensitive to code
|
|
47
|
+
* size.
|
|
48
|
+
*/
|
|
49
|
+
declare function createEventInfo({ eventType, event, targetElement, container, timestamp, action, isReplay, a11yClickKey, }: {
|
|
50
|
+
eventType: string;
|
|
51
|
+
event: Event;
|
|
52
|
+
targetElement: Element;
|
|
53
|
+
container: Element;
|
|
54
|
+
timestamp: number;
|
|
55
|
+
action?: ActionInfo;
|
|
56
|
+
isReplay?: boolean;
|
|
57
|
+
a11yClickKey?: boolean;
|
|
58
|
+
}): EventInfo;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Utility function for creating an `EventInfo`.
|
|
62
|
+
*
|
|
63
|
+
* This can be used from code-size sensitive compilation units, as taking
|
|
64
|
+
* parameters vs. an `Object` literal reduces code size.
|
|
65
|
+
*/
|
|
66
|
+
declare function createEventInfoFromParameters(eventType: string, event: Event, targetElement: Element, container: Element, timestamp: number, action?: ActionInfoInternal, isReplay?: boolean, a11yClickKey?: boolean): EventInfo;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Receives a DOM event, determines the jsaction associated with the source
|
|
70
|
+
* element of the DOM event, and invokes the handler associated with the
|
|
71
|
+
* jsaction.
|
|
72
|
+
*/
|
|
73
|
+
export declare class Dispatcher {
|
|
74
|
+
private readonly getHandler?;
|
|
75
|
+
private readonly baseDispatcher;
|
|
76
|
+
/** Whether to stop propagation for an `EventInfo`. */
|
|
77
|
+
private readonly stopPropagation;
|
|
78
|
+
/**
|
|
79
|
+
* The actions that are registered for this Dispatcher instance.
|
|
80
|
+
* This should be the primary one used once migration off of registerHandlers
|
|
81
|
+
* is done.
|
|
82
|
+
*/
|
|
83
|
+
private readonly actions;
|
|
84
|
+
/** A map of global event handlers, where each key is an event type. */
|
|
85
|
+
private readonly globalHandlers;
|
|
86
|
+
/** The event replayer. */
|
|
87
|
+
private eventReplayer?;
|
|
88
|
+
/**
|
|
89
|
+
* Receives a DOM event, determines the jsaction associated with the source
|
|
90
|
+
* element of the DOM event, and invokes the handler associated with the
|
|
91
|
+
* jsaction.
|
|
92
|
+
*
|
|
93
|
+
* @param getHandler A function that knows how to get the handler for a
|
|
94
|
+
* given event info.
|
|
95
|
+
*/
|
|
96
|
+
constructor(getHandler?: ((eventInfoWrapper: EventInfoWrapper) => EventInfoWrapperHandler | void) | undefined, { stopPropagation, eventReplayer, }?: {
|
|
97
|
+
stopPropagation?: boolean;
|
|
98
|
+
eventReplayer?: Replayer;
|
|
99
|
+
});
|
|
100
|
+
/**
|
|
101
|
+
* Receives an event or the event queue from the EventContract. The event
|
|
102
|
+
* queue is copied and it attempts to replay.
|
|
103
|
+
* If event info is passed in it looks for an action handler that can handle
|
|
104
|
+
* the given event. If there is no handler registered queues the event and
|
|
105
|
+
* checks if a loader is registered for the given namespace. If so, calls it.
|
|
106
|
+
*
|
|
107
|
+
* Alternatively, if in global dispatch mode, calls all registered global
|
|
108
|
+
* handlers for the appropriate event type.
|
|
109
|
+
*
|
|
110
|
+
* The three functionalities of this call are deliberately not split into
|
|
111
|
+
* three methods (and then declared as an abstract interface), because the
|
|
112
|
+
* interface is used by EventContract, which lives in a different jsbinary.
|
|
113
|
+
* Therefore the interface between the three is defined entirely in terms that
|
|
114
|
+
* are invariant under jscompiler processing (Function and Array, as opposed
|
|
115
|
+
* to a custom type with method names).
|
|
116
|
+
*
|
|
117
|
+
* @param eventInfo The info for the event that triggered this call or the
|
|
118
|
+
* queue of events from EventContract.
|
|
119
|
+
* @param isGlobalDispatch If true, dispatches a global event instead of a
|
|
120
|
+
* regular jsaction handler.
|
|
121
|
+
* @return An `EventInfo` for the `EventContract` to handle again if the
|
|
122
|
+
* `Dispatcher` tried to resolve an a11y event as a click but failed.
|
|
123
|
+
*/
|
|
124
|
+
dispatch(eventInfo: EventInfo, isGlobalDispatch?: boolean): EventInfo | void;
|
|
125
|
+
/**
|
|
126
|
+
* Dispatches an `EventInfoWrapper`.
|
|
127
|
+
*/
|
|
128
|
+
private dispatchToHandler;
|
|
129
|
+
/**
|
|
130
|
+
* Registers multiple methods all bound to the same object
|
|
131
|
+
* instance. This is a common case: an application module binds
|
|
132
|
+
* multiple of its methods under public names to the event contract of
|
|
133
|
+
* the application. So we provide a shortcut for it.
|
|
134
|
+
* Attempts to replay the queued events after registering the handlers.
|
|
135
|
+
*
|
|
136
|
+
* @param namespace The namespace of the jsaction name.
|
|
137
|
+
*
|
|
138
|
+
* @param instance The object to bind the methods to. If this is null, then
|
|
139
|
+
* the functions are not bound, but directly added under the public names.
|
|
140
|
+
*
|
|
141
|
+
* @param methods A map from public name to functions that will be bound to
|
|
142
|
+
* instance and registered as action under the public name. I.e. the
|
|
143
|
+
* property names are the public names. The property values are the
|
|
144
|
+
* methods of instance.
|
|
145
|
+
*/
|
|
146
|
+
registerEventInfoHandlers<T>(namespace: string, instance: T | null, methods: {
|
|
147
|
+
[key: string]: EventInfoWrapperHandler;
|
|
148
|
+
}): void;
|
|
149
|
+
/**
|
|
150
|
+
* Unregisters an action. Provided as an easy way to reverse the effects of
|
|
151
|
+
* registerHandlers.
|
|
152
|
+
* @param namespace The namespace of the jsaction name.
|
|
153
|
+
* @param name The action name to unbind.
|
|
154
|
+
*/
|
|
155
|
+
unregisterHandler(namespace: string, name: string): void;
|
|
156
|
+
/** Registers a global event handler. */
|
|
157
|
+
registerGlobalHandler(eventType: string, handler: GlobalHandler): void;
|
|
158
|
+
/** Unregisters a global event handler. */
|
|
159
|
+
unregisterGlobalHandler(eventType: string, handler: GlobalHandler): void;
|
|
160
|
+
/**
|
|
161
|
+
* Checks whether there is an action registered under the given
|
|
162
|
+
* name. This returns true if there is a namespace handler, even
|
|
163
|
+
* if it can not yet handle the event.
|
|
164
|
+
*
|
|
165
|
+
* @param name Action name.
|
|
166
|
+
* @return Whether the name is registered.
|
|
167
|
+
* @see #canDispatch
|
|
168
|
+
*/
|
|
169
|
+
hasAction(name: string): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Whether this dispatcher can dispatch the event. This can be used by
|
|
172
|
+
* event replayer to check whether the dispatcher can replay an event.
|
|
173
|
+
*/
|
|
174
|
+
canDispatch(eventInfoWrapper: EventInfoWrapper): boolean;
|
|
175
|
+
/**
|
|
176
|
+
* Sets the event replayer, enabling queued events to be replayed when actions
|
|
177
|
+
* are bound. To replay events, you must register the dispatcher to the
|
|
178
|
+
* contract after setting the `EventReplayer`. The event replayer takes as
|
|
179
|
+
* parameters the queue of events and the dispatcher (used to check whether
|
|
180
|
+
* actions have handlers registered and can be replayed). The event replayer
|
|
181
|
+
* is also responsible for dequeuing events.
|
|
182
|
+
*
|
|
183
|
+
* Example: An event replayer that replays only the last event.
|
|
184
|
+
*
|
|
185
|
+
* const dispatcher = new Dispatcher();
|
|
186
|
+
* // ...
|
|
187
|
+
* dispatcher.setEventReplayer((queue, dispatcher) => {
|
|
188
|
+
* const lastEventInfoWrapper = queue[queue.length -1];
|
|
189
|
+
* if (dispatcher.canDispatch(lastEventInfoWrapper.getAction())) {
|
|
190
|
+
* jsaction.replay.replayEvent(
|
|
191
|
+
* lastEventInfoWrapper.getEvent(),
|
|
192
|
+
* lastEventInfoWrapper.getTargetElement(),
|
|
193
|
+
* lastEventInfoWrapper.getEventType(),
|
|
194
|
+
* );
|
|
195
|
+
* queue.length = 0;
|
|
196
|
+
* }
|
|
197
|
+
* });
|
|
198
|
+
*
|
|
199
|
+
* @param eventReplayer It allows elements to be replayed and dequeuing.
|
|
200
|
+
*/
|
|
201
|
+
setEventReplayer(eventReplayer: Replayer): void;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** A function that is called to handle events captured by the EventContract. */
|
|
205
|
+
declare type Dispatcher_2 = (eventInfo: eventInfoLib.EventInfo, globalDispatch?: boolean) => eventInfoLib.EventInfo | void;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* EventContract intercepts events in the bubbling phase at the
|
|
209
|
+
* boundary of a container element, and maps them to generic actions
|
|
210
|
+
* which are specified using the custom jsaction attribute in
|
|
211
|
+
* HTML. Behavior of the application is then specified in terms of
|
|
212
|
+
* handler for such actions, cf. jsaction.Dispatcher in dispatcher.js.
|
|
213
|
+
*
|
|
214
|
+
* This has several benefits: (1) No DOM event handlers need to be
|
|
215
|
+
* registered on the specific elements in the UI. (2) The set of
|
|
216
|
+
* events that the application has to handle can be specified in terms
|
|
217
|
+
* of the semantics of the application, rather than in terms of DOM
|
|
218
|
+
* events. (3) Invocation of handlers can be delayed and handlers can
|
|
219
|
+
* be delay loaded in a generic way.
|
|
220
|
+
*/
|
|
221
|
+
export declare class EventContract implements UnrenamedEventContract {
|
|
222
|
+
static CUSTOM_EVENT_SUPPORT: boolean;
|
|
223
|
+
static STOP_PROPAGATION: boolean;
|
|
224
|
+
static A11Y_SUPPORT_IN_DISPATCHER: boolean;
|
|
225
|
+
static A11Y_CLICK_SUPPORT: boolean;
|
|
226
|
+
static MOUSE_SPECIAL_SUPPORT: boolean;
|
|
227
|
+
static JSNAMESPACE_SUPPORT: boolean;
|
|
228
|
+
private containerManager;
|
|
229
|
+
/**
|
|
230
|
+
* The DOM events which this contract covers. Used to prevent double
|
|
231
|
+
* registration of event types. The value of the map is the
|
|
232
|
+
* internally created DOM event handler function that handles the
|
|
233
|
+
* DOM events. See addEvent().
|
|
234
|
+
*
|
|
235
|
+
*/
|
|
236
|
+
private eventHandlers;
|
|
237
|
+
private browserEventTypeToExtraEventTypes;
|
|
238
|
+
/**
|
|
239
|
+
* The dispatcher function. Events are passed to this function for
|
|
240
|
+
* handling once it was set using the registerDispatcher() method. This is
|
|
241
|
+
* done because the function is passed from another jsbinary, so passing the
|
|
242
|
+
* instance and invoking the method here would require to leave the method
|
|
243
|
+
* unobfuscated.
|
|
244
|
+
*/
|
|
245
|
+
private dispatcher;
|
|
246
|
+
/**
|
|
247
|
+
* The list of suspended `EventInfo` that will be dispatched
|
|
248
|
+
* as soon as the `Dispatcher` is registered.
|
|
249
|
+
*/
|
|
250
|
+
private queuedEventInfos;
|
|
251
|
+
/** Whether a11y click support has been loaded or not. */
|
|
252
|
+
private hasA11yClickSupport;
|
|
253
|
+
/** Whether to add an a11y click listener. */
|
|
254
|
+
private addA11yClickListener;
|
|
255
|
+
private updateEventInfoForA11yClick?;
|
|
256
|
+
private preventDefaultForA11yClick?;
|
|
257
|
+
private populateClickOnlyAction?;
|
|
258
|
+
ecaacs?: (updateEventInfoForA11yClick: typeof a11yClickLib.updateEventInfoForA11yClick, preventDefaultForA11yClick: typeof a11yClickLib.preventDefaultForA11yClick, populateClickOnlyAction: typeof a11yClickLib.populateClickOnlyAction) => void;
|
|
259
|
+
constructor(containerManager: EventContractContainerManager);
|
|
260
|
+
private handleEvent;
|
|
261
|
+
/**
|
|
262
|
+
* Handle an `EventInfo`.
|
|
263
|
+
* @param allowRehandling Used in the case of a11y click casting to prevent
|
|
264
|
+
* us from trying to rehandle in an infinite loop.
|
|
265
|
+
*/
|
|
266
|
+
private handleEventInfo;
|
|
267
|
+
/**
|
|
268
|
+
* Searches for a jsaction that the DOM event maps to and creates an
|
|
269
|
+
* object containing event information used for dispatching by
|
|
270
|
+
* jsaction.Dispatcher. This method populates the `action` and `actionElement`
|
|
271
|
+
* fields of the EventInfo object passed in by finding the first
|
|
272
|
+
* jsaction attribute above the target Node of the event, and below
|
|
273
|
+
* the container Node, that specifies a jsaction for the event
|
|
274
|
+
* type. If no such jsaction is found, then action is undefined.
|
|
275
|
+
*
|
|
276
|
+
* @param eventInfo `EventInfo` to set `action` and `actionElement` if an
|
|
277
|
+
* action is found on any `Element` in the path of the `Event`.
|
|
278
|
+
*/
|
|
279
|
+
private populateAction;
|
|
280
|
+
/**
|
|
281
|
+
* Accesses the jsaction map on a node and retrieves the name of the
|
|
282
|
+
* action the given event is mapped to, if any. It parses the
|
|
283
|
+
* attribute value and stores it in a property on the node for
|
|
284
|
+
* subsequent retrieval without re-parsing and re-accessing the
|
|
285
|
+
* attribute. In order to fully qualify jsaction names using a
|
|
286
|
+
* namespace, the DOM is searched starting at the current node and
|
|
287
|
+
* going through ancestor nodes until a jsnamespace attribute is
|
|
288
|
+
* found.
|
|
289
|
+
*
|
|
290
|
+
* @param actionElement The DOM node to retrieve the jsaction map from.
|
|
291
|
+
* @param eventInfo `EventInfo` to set `action` and `actionElement` if an
|
|
292
|
+
* action is found on the `actionElement`.
|
|
293
|
+
*/
|
|
294
|
+
private populateActionOnElement;
|
|
295
|
+
/**
|
|
296
|
+
* Enables jsaction handlers to be called for the event type given by
|
|
297
|
+
* name.
|
|
298
|
+
*
|
|
299
|
+
* If the event is already registered, this does nothing.
|
|
300
|
+
*
|
|
301
|
+
* @param prefixedEventType If supplied, this event is used in
|
|
302
|
+
* the actual browser event registration instead of the name that is
|
|
303
|
+
* exposed to jsaction. Use this if you e.g. want users to be able
|
|
304
|
+
* to subscribe to jsaction="transitionEnd:foo" while the underlying
|
|
305
|
+
* event is webkitTransitionEnd in one browser and mozTransitionEnd
|
|
306
|
+
* in another.
|
|
307
|
+
*/
|
|
308
|
+
addEvent(eventType: string, prefixedEventType?: string): void;
|
|
309
|
+
/**
|
|
310
|
+
* Gets the queued early events and replay them using the appropriate handler
|
|
311
|
+
* in the provided event contract. Once all the events are replayed, it cleans
|
|
312
|
+
* up the early contract.
|
|
313
|
+
*/
|
|
314
|
+
replayEarlyEvents(): void;
|
|
315
|
+
/**
|
|
316
|
+
* Returns all JSAction event types that have been registered for a given
|
|
317
|
+
* browser event type.
|
|
318
|
+
*/
|
|
319
|
+
private getEventTypesForBrowserEventType;
|
|
320
|
+
/**
|
|
321
|
+
* Returns the event handler function for a given event type.
|
|
322
|
+
*/
|
|
323
|
+
handler(eventType: string): EventHandler | undefined;
|
|
324
|
+
/**
|
|
325
|
+
* Cleans up the event contract. This resets all of the `EventContract`'s
|
|
326
|
+
* internal state. Users are responsible for not using this `EventContract`
|
|
327
|
+
* after it has been cleaned up.
|
|
328
|
+
*/
|
|
329
|
+
cleanUp(): void;
|
|
330
|
+
/**
|
|
331
|
+
* Register a dispatcher function. Event info of each event mapped to
|
|
332
|
+
* a jsaction is passed for handling to this callback. The queued
|
|
333
|
+
* events are passed as well to the dispatcher for later replaying
|
|
334
|
+
* once the dispatcher is registered. Clears the event queue to null.
|
|
335
|
+
*
|
|
336
|
+
* @param dispatcher The dispatcher function.
|
|
337
|
+
* @param restriction
|
|
338
|
+
*/
|
|
339
|
+
registerDispatcher(dispatcher: Dispatcher_2, restriction: Restriction): void;
|
|
340
|
+
/**
|
|
341
|
+
* Unrenamed alias for registerDispatcher. Necessary for any codebases that
|
|
342
|
+
* split the `EventContract` and `Dispatcher` code into different compilation
|
|
343
|
+
* units.
|
|
344
|
+
*/
|
|
345
|
+
ecrd(dispatcher: Dispatcher_2, restriction: Restriction): void;
|
|
346
|
+
/**
|
|
347
|
+
* Adds a11y click support to the given `EventContract`. Meant to be called in
|
|
348
|
+
* the same compilation unit as the `EventContract`.
|
|
349
|
+
*/
|
|
350
|
+
addA11yClickSupport(): void;
|
|
351
|
+
/**
|
|
352
|
+
* Enables a11y click support to be deferred. Meant to be called in the same
|
|
353
|
+
* compilation unit as the `EventContract`.
|
|
354
|
+
*/
|
|
355
|
+
exportAddA11yClickSupport(): void;
|
|
356
|
+
/**
|
|
357
|
+
* Unrenamed function that loads a11yClickSupport.
|
|
358
|
+
*/
|
|
359
|
+
private addA11yClickSupportImpl;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* A class representing a container node and all the event handlers
|
|
364
|
+
* installed on it. Used so that handlers can be cleaned up if the
|
|
365
|
+
* container is removed from the contract.
|
|
366
|
+
*/
|
|
367
|
+
export declare class EventContractContainer implements EventContractContainerManager {
|
|
368
|
+
readonly element: Element;
|
|
369
|
+
/**
|
|
370
|
+
* Array of event handlers and their corresponding event types that are
|
|
371
|
+
* installed on this container.
|
|
372
|
+
*
|
|
373
|
+
*/
|
|
374
|
+
private handlerInfos;
|
|
375
|
+
/**
|
|
376
|
+
* @param element The container Element.
|
|
377
|
+
*/
|
|
378
|
+
constructor(element: Element);
|
|
379
|
+
/**
|
|
380
|
+
* Installs the provided installer on the element owned by this container,
|
|
381
|
+
* and maintains a reference to resulting handler in order to remove it
|
|
382
|
+
* later if desired.
|
|
383
|
+
*/
|
|
384
|
+
addEventListener(eventType: string, getHandler: (element: Element) => (event: Event) => void): void;
|
|
385
|
+
/**
|
|
386
|
+
* Removes all the handlers installed on this container.
|
|
387
|
+
*/
|
|
388
|
+
cleanUp(): void;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* An `EventContractContainerManager` provides the common interface for managing
|
|
394
|
+
* containers.
|
|
395
|
+
*/
|
|
396
|
+
declare interface EventContractContainerManager {
|
|
397
|
+
addEventListener(eventType: string, getHandler: (element: Element) => (event: Event) => void): void;
|
|
398
|
+
cleanUp(): void;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* A function that handles an event dispatched from the browser.
|
|
403
|
+
*
|
|
404
|
+
* eventType: May differ from `event.type` if JSAction uses a
|
|
405
|
+
* short-hand name or is patching over an non-bubbling event with a bubbling
|
|
406
|
+
* variant.
|
|
407
|
+
* event: The native browser event.
|
|
408
|
+
* container: The container for this dispatch.
|
|
409
|
+
*/
|
|
410
|
+
declare type EventHandler = (eventType: string, event: Event, container: Element) => void;
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Records information for later handling of events. This type is
|
|
414
|
+
* shared, and instances of it are passed, between the eventcontract
|
|
415
|
+
* and the dispatcher jsbinary. Therefore, the fields of this type are
|
|
416
|
+
* referenced by string literals rather than property literals
|
|
417
|
+
* throughout the code.
|
|
418
|
+
*
|
|
419
|
+
* 'targetElement' is the element the action occurred on, 'actionElement'
|
|
420
|
+
* is the element that has the jsaction handler.
|
|
421
|
+
*
|
|
422
|
+
* A null 'actionElement' identifies an EventInfo instance that didn't match a
|
|
423
|
+
* jsaction attribute. This allows us to execute global event handlers with the
|
|
424
|
+
* appropriate event type (including a11y clicks and custom events).
|
|
425
|
+
* The declare portion of this interface creates a set of externs that make sure
|
|
426
|
+
* renaming doesn't happen for EventInfo. This is important since EventInfo
|
|
427
|
+
* is shared across multiple binaries.
|
|
428
|
+
*/
|
|
429
|
+
declare interface EventInfo {
|
|
430
|
+
eventType: string;
|
|
431
|
+
event: Event;
|
|
432
|
+
targetElement: Element;
|
|
433
|
+
/** The element that is the container for this Event. */
|
|
434
|
+
eic: Element;
|
|
435
|
+
timeStamp: number;
|
|
436
|
+
/**
|
|
437
|
+
* The action parsed from the JSAction element.
|
|
438
|
+
*/
|
|
439
|
+
eia?: ActionInfoInternal;
|
|
440
|
+
/**
|
|
441
|
+
* Whether this `Event` is a replay event, meaning no dispatcher was
|
|
442
|
+
* installed when this `Event` was originally dispatched.
|
|
443
|
+
*/
|
|
444
|
+
eirp?: boolean;
|
|
445
|
+
/**
|
|
446
|
+
* Whether this `Event` represents a `keydown` event that should be processed
|
|
447
|
+
* as a `click`. Only used when a11y click events is on.
|
|
448
|
+
*/
|
|
449
|
+
eiack?: boolean;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
declare namespace eventInfoLib {
|
|
453
|
+
export {
|
|
454
|
+
getEventType,
|
|
455
|
+
setEventType,
|
|
456
|
+
getEvent,
|
|
457
|
+
setEvent,
|
|
458
|
+
getTargetElement,
|
|
459
|
+
setTargetElement,
|
|
460
|
+
getContainer,
|
|
461
|
+
setContainer,
|
|
462
|
+
getTimestamp,
|
|
463
|
+
setTimestamp,
|
|
464
|
+
getAction,
|
|
465
|
+
setAction,
|
|
466
|
+
unsetAction,
|
|
467
|
+
getActionName,
|
|
468
|
+
getActionElement,
|
|
469
|
+
getIsReplay,
|
|
470
|
+
setIsReplay,
|
|
471
|
+
getA11yClickKey,
|
|
472
|
+
setA11yClickKey,
|
|
473
|
+
cloneEventInfo,
|
|
474
|
+
createEventInfoFromParameters,
|
|
475
|
+
createEventInfo,
|
|
476
|
+
ActionInfo,
|
|
477
|
+
EventInfo,
|
|
478
|
+
EventInfoWrapper
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Utility class around an `EventInfo`.
|
|
484
|
+
*
|
|
485
|
+
* This should be used in compilation units that are less sensitive to code
|
|
486
|
+
* size.
|
|
487
|
+
*/
|
|
488
|
+
export declare class EventInfoWrapper {
|
|
489
|
+
readonly eventInfo: EventInfo;
|
|
490
|
+
constructor(eventInfo: EventInfo);
|
|
491
|
+
getEventType(): string;
|
|
492
|
+
setEventType(eventType: string): void;
|
|
493
|
+
getEvent(): Event;
|
|
494
|
+
setEvent(event: Event): void;
|
|
495
|
+
getTargetElement(): Element;
|
|
496
|
+
setTargetElement(targetElement: Element): void;
|
|
497
|
+
getContainer(): Element;
|
|
498
|
+
setContainer(container: Element): void;
|
|
499
|
+
getTimestamp(): number;
|
|
500
|
+
setTimestamp(timestamp: number): void;
|
|
501
|
+
getAction(): {
|
|
502
|
+
name: string;
|
|
503
|
+
element: Element;
|
|
504
|
+
} | undefined;
|
|
505
|
+
setAction(action: ActionInfo | undefined): void;
|
|
506
|
+
getIsReplay(): boolean | undefined;
|
|
507
|
+
setIsReplay(replay: boolean): void;
|
|
508
|
+
clone(): EventInfoWrapper;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* A handler is dispatched to during normal handling.
|
|
513
|
+
*/
|
|
514
|
+
declare type EventInfoWrapperHandler = (eventInfoWrapper: EventInfoWrapper) => void;
|
|
515
|
+
|
|
516
|
+
/** Added for readability when accessing stable property names. */
|
|
517
|
+
declare function getA11yClickKey(eventInfo: EventInfo): boolean | undefined;
|
|
518
|
+
|
|
519
|
+
/** Added for readability when accessing stable property names. */
|
|
520
|
+
declare function getAction(eventInfo: EventInfo): ActionInfoInternal | undefined;
|
|
521
|
+
|
|
522
|
+
/** Added for readability when accessing stable property names. */
|
|
523
|
+
declare function getActionElement(actionInfo: ActionInfoInternal): Element;
|
|
524
|
+
|
|
525
|
+
/** Added for readability when accessing stable property names. */
|
|
526
|
+
declare function getActionName(actionInfo: ActionInfoInternal): string;
|
|
527
|
+
|
|
528
|
+
/** Added for readability when accessing stable property names. */
|
|
529
|
+
declare function getContainer(eventInfo: EventInfo): Element;
|
|
530
|
+
|
|
531
|
+
/** Added for readability when accessing stable property names. */
|
|
532
|
+
declare function getEvent(eventInfo: EventInfo): Event;
|
|
533
|
+
|
|
534
|
+
/** Added for readability when accessing stable property names. */
|
|
535
|
+
declare function getEventType(eventInfo: EventInfo): string;
|
|
536
|
+
|
|
537
|
+
/** Added for readability when accessing stable property names. */
|
|
538
|
+
declare function getIsReplay(eventInfo: EventInfo): boolean | undefined;
|
|
539
|
+
|
|
540
|
+
/** Added for readability when accessing stable property names. */
|
|
541
|
+
declare function getTargetElement(eventInfo: EventInfo): Element;
|
|
542
|
+
|
|
543
|
+
/** Added for readability when accessing stable property names. */
|
|
544
|
+
declare function getTimestamp(eventInfo: EventInfo): number;
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* A global handler is dispatched to before normal handler dispatch. Returning
|
|
548
|
+
* false will `preventDefault` on the event.
|
|
549
|
+
*/
|
|
550
|
+
declare type GlobalHandler = (event: Event) => boolean | void;
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Sets the `action` to `clickonly` for a click event that is not an a11y click
|
|
554
|
+
* and if there is not already a click action.
|
|
555
|
+
*/
|
|
556
|
+
declare function populateClickOnlyAction(actionElement: Element, eventInfo: eventInfoLib.EventInfo, actionMap: {
|
|
557
|
+
[key: string]: string;
|
|
558
|
+
}): void;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Call `preventDefault` on an a11y click if it is space key or to prevent the
|
|
562
|
+
* browser's default action for native HTML controls.
|
|
563
|
+
*/
|
|
564
|
+
declare function preventDefaultForA11yClick(eventInfo: eventInfoLib.EventInfo): void;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Registers deferred functionality for an EventContract and a Jsaction
|
|
568
|
+
* Dispatcher.
|
|
569
|
+
*/
|
|
570
|
+
export declare function registerDispatcher(eventContract: UnrenamedEventContract, dispatcher: Dispatcher): void;
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* A replayer is a function that is called when there are queued events,
|
|
574
|
+
* either from the `EventContract` or when there are no detected handlers.
|
|
575
|
+
*/
|
|
576
|
+
declare type Replayer = (eventInfoWrappers: EventInfoWrapper[], dispatcher: Dispatcher) => void;
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* @fileoverview An enum to control who can call certain jsaction APIs.
|
|
581
|
+
*/
|
|
582
|
+
declare enum Restriction {
|
|
583
|
+
I_AM_THE_JSACTION_FRAMEWORK = 1
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/** Added for readability when accessing stable property names. */
|
|
587
|
+
declare function setA11yClickKey(eventInfo: EventInfo, a11yClickKey: boolean): void;
|
|
588
|
+
|
|
589
|
+
/** Added for readability when accessing stable property names. */
|
|
590
|
+
declare function setAction(eventInfo: EventInfo, actionName: string, actionElement: Element): void;
|
|
591
|
+
|
|
592
|
+
/** Added for readability when accessing stable property names. */
|
|
593
|
+
declare function setContainer(eventInfo: EventInfo, container: Element): void;
|
|
594
|
+
|
|
595
|
+
/** Added for readability when accessing stable property names. */
|
|
596
|
+
declare function setEvent(eventInfo: EventInfo, event: Event): void;
|
|
597
|
+
|
|
598
|
+
/** Added for readability when accessing stable property names. */
|
|
599
|
+
declare function setEventType(eventInfo: EventInfo, eventType: string): void;
|
|
600
|
+
|
|
601
|
+
/** Added for readability when accessing stable property names. */
|
|
602
|
+
declare function setIsReplay(eventInfo: EventInfo, replay: boolean): void;
|
|
603
|
+
|
|
604
|
+
/** Added for readability when accessing stable property names. */
|
|
605
|
+
declare function setTargetElement(eventInfo: EventInfo, targetElement: Element): void;
|
|
606
|
+
|
|
607
|
+
/** Added for readability when accessing stable property names. */
|
|
608
|
+
declare function setTimestamp(eventInfo: EventInfo, timestamp: number): void;
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* The API of an EventContract that is safe to call from any compilation unit.
|
|
612
|
+
*/
|
|
613
|
+
declare interface UnrenamedEventContract {
|
|
614
|
+
ecrd(dispatcher: Dispatcher_2, restriction: Restriction): void;
|
|
615
|
+
ecaacs?: (updateEventInfoForA11yClick: typeof a11yClickLib.updateEventInfoForA11yClick, preventDefaultForA11yClick: typeof a11yClickLib.preventDefaultForA11yClick, populateClickOnlyAction: typeof a11yClickLib.populateClickOnlyAction) => void;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/** Added for readability when accessing stable property names. */
|
|
619
|
+
declare function unsetAction(eventInfo: EventInfo): void;
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Update `EventInfo` to be `eventType = 'click'` and sets `a11yClickKey` if it
|
|
623
|
+
* is a a11y click.
|
|
624
|
+
*/
|
|
625
|
+
declare function updateEventInfoForA11yClick(eventInfo: eventInfoLib.EventInfo): void;
|
|
626
|
+
|
|
627
|
+
export { }
|
package/rxjs-interop/index.d.ts
CHANGED