@emuanalytics/flow-rdf-core 4.0.4 → 4.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +1 -64
  2. package/dist/index.d.mts +36 -31
  3. package/dist/index.d.ts +36 -31
  4. package/dist/index.mjs +20 -3249
  5. package/dist/lib/context/context-registry.mjs +63 -0
  6. package/dist/lib/context/debugger.mjs +240 -0
  7. package/dist/lib/context/flow-context.mjs +61 -0
  8. package/dist/lib/context/global-state.mjs +70 -0
  9. package/dist/lib/context/map-registry.mjs +59 -0
  10. package/dist/lib/context/query-registry.mjs +53 -0
  11. package/dist/lib/errors/flow-error.mjs +10 -0
  12. package/dist/lib/errors/flow-expression-error.mjs +14 -0
  13. package/dist/lib/errors/flow-map-error.mjs +9 -0
  14. package/dist/lib/expressions/expression-parser.mjs +198 -0
  15. package/dist/lib/expressions/functions/from-palette.mjs +75 -0
  16. package/dist/lib/expressions/functions/regex.mjs +25 -0
  17. package/dist/lib/expressions/functions/state.mjs +25 -0
  18. package/dist/lib/expressions/parser-helpers.mjs +37 -0
  19. package/dist/lib/expressions/reactive-expression.mjs +253 -0
  20. package/dist/lib/map/flow-core-map.mjs +749 -0
  21. package/dist/lib/map/plugins/annotations/annotation-layers.mjs +163 -0
  22. package/dist/lib/map/plugins/annotations/annotation.events.mjs +27 -0
  23. package/dist/lib/map/plugins/annotations/annotation.plugin.mjs +498 -0
  24. package/dist/lib/map/plugins/annotations/maplibre-gl-draw-circle/lib/modes/DirectModeOverride.mjs +67 -0
  25. package/dist/lib/map/plugins/annotations/maplibre-gl-draw-circle/lib/modes/DragCircleMode.mjs +65 -0
  26. package/dist/lib/map/plugins/annotations/maplibre-gl-draw-circle/lib/utils/create_supplementary_points_circle.mjs +15 -0
  27. package/dist/lib/map/plugins/annotations/maplibre-gl-draw-circle/lib/utils/drag_pan.mjs +20 -0
  28. package/dist/lib/map/plugins/data-join.plugin.mjs +173 -0
  29. package/dist/lib/map/plugins/export/export.plugin.mjs +21 -0
  30. package/dist/lib/map/plugins/export/map-exporter.mjs +177 -0
  31. package/dist/lib/map/plugins/hover-effect.plugin.mjs +58 -0
  32. package/dist/lib/map/plugins/index.d.mts +37 -72
  33. package/dist/lib/map/plugins/index.d.ts +37 -72
  34. package/dist/lib/map/plugins/index.mjs +11 -1810
  35. package/dist/lib/map/plugins/keyboard-shortcut-manager.mjs +120 -0
  36. package/dist/lib/map/plugins/map-plugin-base.mjs +25 -0
  37. package/dist/lib/map/plugins/plugin-manager.mjs +135 -0
  38. package/dist/lib/map/plugins/popup.plugin.mjs +55 -0
  39. package/dist/lib/map/plugins/selection/selection.events.mjs +21 -0
  40. package/dist/lib/map/plugins/selection/selection.plugin.mjs +136 -0
  41. package/dist/lib/map/plugins/selection/source-selection.mjs +156 -0
  42. package/dist/lib/map/plugins/url-sync.plugin.mjs +55 -0
  43. package/dist/lib/map/support/image-registry.mjs +82 -0
  44. package/dist/lib/map/support/map-events.mjs +71 -0
  45. package/dist/lib/map/support/map-feature-stream.mjs +158 -0
  46. package/dist/lib/map/support/map-popup.mjs +159 -0
  47. package/dist/lib/map/types.mjs +7 -0
  48. package/dist/lib/map-style/map-data-source.mjs +192 -0
  49. package/dist/lib/map-style/map-layer-style-builder-generated.mjs +1307 -0
  50. package/dist/lib/map-style/map-layer-style-builder.mjs +86 -0
  51. package/dist/lib/map-style/map-layer.mjs +223 -0
  52. package/dist/lib/map-style/map-style.mjs +178 -0
  53. package/dist/lib/queries/async-committer.mjs +30 -0
  54. package/dist/lib/queries/query.mjs +172 -0
  55. package/dist/lib/state-store/decorators.mjs +83 -0
  56. package/dist/lib/state-store/state-store.mjs +534 -0
  57. package/dist/lib/state-store/utils.mjs +7 -0
  58. package/dist/lib/utils/announce.mjs +12 -0
  59. package/dist/lib/utils/assert.mjs +12 -0
  60. package/dist/{shared/flow-rdf-core.187cb345.mjs → lib/utils/debounce.mjs} +3 -39
  61. package/dist/lib/utils/decorators.mjs +59 -0
  62. package/dist/lib/utils/deferred.mjs +11 -0
  63. package/dist/lib/utils/ensure-array.mjs +16 -0
  64. package/dist/{shared/flow-rdf-core.1f0901c5.mjs → lib/utils/feature-type-checks.mjs} +2 -2
  65. package/dist/lib/utils/functional.mjs +22 -0
  66. package/dist/lib/utils/global.mjs +18 -0
  67. package/dist/lib/utils/index.mjs +8 -5
  68. package/dist/lib/utils/random-id.mjs +9 -0
  69. package/dist/lib/utils/string-utils.mjs +3 -0
  70. package/dist/lib/utils/throttle.mjs +20 -0
  71. package/dist/{shared/flow-rdf-core.25e5f6d7.mjs → lib/utils/type-checks.mjs} +1 -26
  72. package/dist/lib/utils/watchable-promise.mjs +55 -0
  73. package/dist/package.json.mjs +3 -0
  74. package/dist/shared/{flow-rdf-core.4dde996e.d.cts → flow-rdf-core.cef13c7e.d.mts} +1315 -172
  75. package/dist/shared/{flow-rdf-core.4dde996e.d.ts → flow-rdf-core.cef13c7e.d.ts} +1315 -172
  76. package/package.json +4 -8
  77. package/dist/index.cjs +0 -3316
  78. package/dist/index.d.cts +0 -90
  79. package/dist/lib/map/plugins/index.cjs +0 -1850
  80. package/dist/lib/map/plugins/index.d.cts +0 -345
  81. package/dist/lib/utils/index.cjs +0 -48
  82. package/dist/lib/utils/index.d.cts +0 -160
  83. package/dist/shared/flow-rdf-core.06e85a6c.cjs +0 -1394
  84. package/dist/shared/flow-rdf-core.4dde996e.d.mts +0 -1916
  85. package/dist/shared/flow-rdf-core.55c169ca.cjs +0 -150
  86. package/dist/shared/flow-rdf-core.63162669.d.cts +0 -10
  87. package/dist/shared/flow-rdf-core.65045caf.mjs +0 -1360
  88. package/dist/shared/flow-rdf-core.a82b9be4.cjs +0 -34
  89. package/dist/shared/flow-rdf-core.f50908f0.cjs +0 -102
@@ -1,345 +0,0 @@
1
- import { a8 as MapEvent, K as FlowCoreMap, I as MapSourceIdentifier, a9 as MapFeatureId, aa as MapPluginBase, ab as PluginManager, ac as MapSourceEvent, ad as MapMouseEvent, ae as MapFeatureStream, af as PartialBy, x as MapAnimationOptions, ag as MapStyleChangeEvent, M as MapStyleSpecification, S as StateStore, E as MapFeatureIdentifier, z as MapFeature } from '../../../shared/flow-rdf-core.4dde996e.cjs';
2
- export { ak as EventHandlers, aj as PluginConstructor, ai as PluginEventsType, ah as PluginOptionsType } from '../../../shared/flow-rdf-core.4dde996e.cjs';
3
- import { F as Func } from '../../../shared/flow-rdf-core.63162669.cjs';
4
- import EventEmitter from 'eventemitter3';
5
- import * as lit from 'lit-html';
6
- import '@emuanalytics/flow-engine-client';
7
- import 'mobx-utils';
8
- import '@emuanalytics/maplibre-gl';
9
-
10
- type AnnotationMode = 'creating' | 'editing' | 'idle';
11
- type AnnotationFeatureType = 'Polygon' | 'Circle' | 'LineString' | 'Point';
12
- interface AnnotationStyle {
13
- labelSize: number;
14
- labelColor: string;
15
- labelMaxWidth: number;
16
- labelOffset: number[];
17
- labelJustify: string;
18
- labelAnchor: string;
19
- polygonLabelAnchor: string;
20
- radius: number;
21
- fillColor: string;
22
- strokeWidth: number;
23
- strokeColor: string;
24
- selectionStrokeColor: string;
25
- selectionStrokeOpacity: number;
26
- selectionWidth: number;
27
- hoverStrokeColor: string;
28
- }
29
- interface AnnotationFeatureProps extends AnnotationStyle {
30
- id: string;
31
- name: string;
32
- type: AnnotationFeatureType;
33
- selected: boolean;
34
- visible: boolean;
35
- labelText: string;
36
- [extras: string]: any;
37
- }
38
- interface AnnotationsServiceConfig {
39
- style: AnnotationStyle;
40
- }
41
- type AnnotationFeature = GeoJSON.Feature<GeoJSON.Geometry, Partial<AnnotationFeatureProps>> & {
42
- id: string;
43
- };
44
-
45
- interface AnnotationEventTypes {
46
- annotationStateChanged: (event: AnnotationEvent) => void;
47
- }
48
- type AnnotationEventType = keyof AnnotationEventTypes;
49
- interface AnnotationEventData {
50
- features: AnnotationFeature[];
51
- mode: AnnotationMode;
52
- canUndo: boolean;
53
- canRedo: boolean;
54
- activeFeatureId: string | null;
55
- activeFeatureType: AnnotationFeatureType | null;
56
- }
57
- declare class AnnotationEvent extends MapEvent<AnnotationEventType> {
58
- mode: AnnotationMode;
59
- canUndo: boolean;
60
- canRedo: boolean;
61
- activeFeatureId: string | null;
62
- activeFeatureType: AnnotationFeatureType | null;
63
- features: AnnotationFeature[];
64
- constructor(type: AnnotationEventType, map: FlowCoreMap, data: AnnotationEventData);
65
- }
66
-
67
- type SelectionEventType = 'selectionChanged';
68
- interface SelectionEventTypes {
69
- selectionChanged: (event: SelectionEvent) => void;
70
- }
71
- declare class SelectionEvent extends MapEvent<SelectionEventType> implements MapSourceIdentifier {
72
- source: string;
73
- sourceLayer?: string;
74
- features: MapFeatureId[];
75
- constructor(type: SelectionEventType, map: FlowCoreMap, sourceIdentifier: MapSourceIdentifier, features: MapFeatureId[]);
76
- }
77
-
78
- type SelectionMode = 'single' | 'multi' | 'none';
79
- interface SelectionOptions {
80
- clear?: boolean | 'group';
81
- group?: string;
82
- mode: SelectionMode;
83
- popup?: string;
84
- selectionState?: string;
85
- sourceLayer?: string;
86
- }
87
- declare class SelectionPlugin extends MapPluginBase<undefined, SelectionEventTypes> {
88
- private _sourceSelections;
89
- private _enablePopups;
90
- readonly name = "SelectionPlugin";
91
- constructor(pluginManager: PluginManager);
92
- clearSelection(source: string): void;
93
- deselectFeatures(source: string, features: MapFeatureId | MapFeatureId[]): void;
94
- destroy(): void;
95
- disableSelection(source: string): void;
96
- enableSelection(source: string, options: SelectionOptions): void;
97
- handleBeforeSourceRemoved(event: MapSourceEvent): void;
98
- handleClick(event: MapMouseEvent): void;
99
- selectFeatures(source: string, features: MapFeatureId | MapFeatureId[]): void;
100
- selectedFeatureIds(source: string): MapFeatureId[];
101
- selectedFeatureStream(source: string): MapFeatureStream;
102
- enablePopups(enabled?: boolean): void;
103
- disablePopups(): void;
104
- }
105
-
106
- interface AnnotationOperation {
107
- do: Func;
108
- undo: Func;
109
- }
110
- interface AnnotationPluginOptions {
111
- interactive?: boolean;
112
- defaultStyle?: Partial<AnnotationStyle>;
113
- selectionOptions?: SelectionOptions;
114
- }
115
- declare class AnnotationPlugin extends MapPluginBase<AnnotationPluginOptions, AnnotationEventTypes> {
116
- readonly name = "AnnotationPlugin";
117
- private static _defaultOptions;
118
- private _features;
119
- private _featureIds;
120
- private _undoStack;
121
- private _redoStack;
122
- private _mode;
123
- private _activeFeatureId;
124
- private _activeFeatureType;
125
- private _onCommitCleanup;
126
- private _annotationDataSource;
127
- private _drawControl;
128
- private _removeKeyboardShortcuts;
129
- constructor(pluginManager: PluginManager, options?: AnnotationPluginOptions);
130
- initialize(): void;
131
- destroy(): void;
132
- clear(): this;
133
- undo(): this;
134
- /**
135
- * Redo the last undone operation.
136
- */
137
- redo(): this;
138
- getFeature(featureId: string): AnnotationFeature;
139
- getFeatures(): AnnotationFeature[];
140
- setFeatures(features: Array<PartialBy<AnnotationFeature, 'id'>>): this;
141
- addFeature(feature: PartialBy<AnnotationFeature, 'id'>): AnnotationFeature;
142
- deleteFeature(featureId: string): this;
143
- createFeature(featureType: AnnotationFeatureType): void;
144
- editFeature(featureId: string): void;
145
- zoomToFeature(featureId: string, animationOptions: MapAnimationOptions): this;
146
- setFeatureProperty(featureId: string, property: string, value: any): this;
147
- setFeatureProperties(featureId: string, properties: Record<string, any>): this;
148
- commit(): this;
149
- cancel(): this;
150
- render(): this;
151
- handleDblClick?(event: MapMouseEvent): void;
152
- handleBeforeStyleChanged(event: MapStyleChangeEvent): MapStyleSpecification;
153
- private startDrawing;
154
- private endDrawing;
155
- private applyDefaults;
156
- private generateFeatureId;
157
- private generateFeatureName;
158
- private performOperation;
159
- private deselectFeature;
160
- private deleteSelectedFeature;
161
- private editModeForFeature;
162
- private drawModeForFeatureType;
163
- private setFeatureGeometry;
164
- private isValidGeometry;
165
- private emitStateChange;
166
- }
167
-
168
- interface DataJoinOptions {
169
- /** Set to `true` to clear feature state before applying data join. */
170
- clear?: boolean;
171
- data: string | any[];
172
- /** Data join foreign key. */
173
- foreignKey: string;
174
- parameters?: DataJoinParameter[];
175
- source: string;
176
- sourceLayer?: string;
177
- }
178
- interface DataJoinParameter {
179
- name: string;
180
- required?: boolean;
181
- value: string | number | boolean;
182
- }
183
- declare class DataJoin {
184
- readonly id: string;
185
- readonly map: FlowCoreMap;
186
- private static defaultOptions;
187
- private autorunDisposer;
188
- private dataExpression;
189
- private options;
190
- private parameterExpressions;
191
- constructor(id: string, map: FlowCoreMap, options: DataJoinOptions);
192
- get source(): string;
193
- start(): void;
194
- stop(): void;
195
- private doDataJoin;
196
- private loadData;
197
- }
198
- declare class DataJoinPlugin extends MapPluginBase {
199
- private _joins;
200
- readonly name = "DataJoinPlugin";
201
- constructor(pluginManager: PluginManager);
202
- addDataJoin(id: string, options: DataJoinOptions): void;
203
- bindState(state: StateStore): void;
204
- destroy(): void;
205
- handleSourceRemoved(event: MapSourceEvent): void;
206
- removeDataJoin(id: string): void;
207
- }
208
-
209
- /** Callback function to indicate map export overlay drawing has finished. */
210
- type DrawOverlayCallback = (error: Error) => void;
211
- /** Function to draw an overlay on an exported map. */
212
- type DrawOverlayFn = (ctx: CanvasRenderingContext2D, width: number, height: number, dpmm: number, callback: DrawOverlayCallback) => void;
213
- /**
214
- * Options for [[FlowCoreMap.export]].
215
- */
216
- interface FlowMapExportOptions {
217
- /** Name of exported file. */
218
- name: string;
219
- /** Width of exported map in millimeters. */
220
- width: number;
221
- /** Height of exported map in millimeters. */
222
- height: number;
223
- /** Resolution of exported map. Dots/mm. */
224
- dpmm: number;
225
- /** Format of exported map. */
226
- format: 'png' | 'pdf';
227
- /**
228
- * Geographic bounds of area to export ([left, bottom, right top]).
229
- *
230
- * This should be a subregion of the full map area.
231
- */
232
- bounds?: number[];
233
- /** Function called to draw overlay on exported map. */
234
- drawOverlayFn?: DrawOverlayFn;
235
- }
236
-
237
- interface ExportPluginOptions {
238
- }
239
- declare class ExportPlugin extends MapPluginBase<ExportPluginOptions> {
240
- readonly name = "ExportPlugin";
241
- constructor(pluginManager: PluginManager);
242
- exportMap(options: FlowMapExportOptions): Promise<string>;
243
- }
244
-
245
- declare class HoverEffectPlugin extends MapPluginBase {
246
- private hoveredFeature;
247
- readonly name = "HoverEffectPlugin";
248
- constructor(pluginManager: PluginManager);
249
- handleMouseMove(event: MapMouseEvent): void;
250
- handleMouseOut(event: MapEvent): void;
251
- handleSetExclusivePlugin(exclusivePlugins: MapPluginBase[]): void;
252
- private compareFeatures;
253
- private clearHover;
254
- }
255
-
256
- type MapPopupTemplateFn<TState extends StateStore = StateStore> = (feature: MapFeature | null, state: TState) => string | Node | lit.TemplateResult;
257
- interface MapPopupEvents {
258
- closed: (popup: MapPopup) => void;
259
- }
260
- /**
261
- * [[MapPopup]] options.
262
- */
263
- interface MapPopupOptions {
264
- /** Specify a CSS class to add to the popup. */
265
- class?: string;
266
- /** Enable 'close' button. */
267
- closeButton?: boolean;
268
- /** Enable closing popup on click on map. */
269
- closeOnClick?: boolean;
270
- /** Enable closing pop when map is moved. */
271
- closeOnMove?: boolean;
272
- /** Specify popup content as HTML string or HTML node. */
273
- content: string | Node | MapPopupTemplateFn;
274
- /** Maximum width of popup in CSS units. */
275
- maxWidth?: string;
276
- trackFeature?: boolean;
277
- }
278
- /**
279
- * Core functionality for Flo.w map popups.
280
- *
281
- * @noInheritDoc
282
- */
283
- declare class MapPopup extends EventEmitter<MapPopupEvents> {
284
- readonly map: FlowCoreMap;
285
- readonly options: MapPopupOptions;
286
- private _feature?;
287
- private _contentContainer;
288
- private _featureStream;
289
- private _maplibrePopup;
290
- private _featureStreamDisposer?;
291
- /**
292
- * Constructs a new `MapPopup` instance.
293
- *
294
- * This is called by the `FlowMap::openPopup` method.
295
- *
296
- * @param map Parent Flo.w map.
297
- * @param options Popup options.
298
- */
299
- constructor(map: FlowCoreMap, options: MapPopupOptions);
300
- get feature(): MapFeatureIdentifier | undefined;
301
- /**
302
- * Close the popup.
303
- */
304
- close(): void;
305
- /**
306
- * Move the popup to a new location.
307
- *
308
- * @param lngLat New location.
309
- */
310
- moveTo(lngLat: [number, number]): void;
311
- /**
312
- * Open the popup at the specified location.
313
- *
314
- * @param lngLat Popup location.
315
- */
316
- open(event: MapMouseEvent): void;
317
- open(lngLat: [number, number], feature?: MapFeatureIdentifier): void;
318
- private cssClasses;
319
- private handleFeatureUpdate;
320
- private popupCloseHandler;
321
- private renderContent;
322
- }
323
-
324
- declare class PopupPlugin extends MapPluginBase {
325
- private _popupTemplates;
326
- private _popups;
327
- readonly name = "PopupPlugin";
328
- constructor(pluginManager: PluginManager);
329
- registerPopup(id: string, options: MapPopupOptions): void;
330
- openPopup(id: string, event: MapMouseEvent): MapPopup;
331
- openPopup(id: string, lngLat: [number, number], feature?: MapFeatureIdentifier): MapPopup;
332
- closeAllPopups(): void;
333
- closePopupsForSources(sources: string | string[]): void;
334
- }
335
-
336
- declare class UrlSyncPlugin extends MapPluginBase {
337
- readonly name = "UrlSyncPlugin";
338
- constructor(pluginManager: PluginManager);
339
- initialize(): void;
340
- handleMoveEnd(event: MapEvent): void;
341
- private mapStateToHash;
342
- private hashToMapState;
343
- }
344
-
345
- export { AnnotationEvent, type AnnotationEventData, type AnnotationEventType, type AnnotationEventTypes, type AnnotationFeature, type AnnotationFeatureProps, type AnnotationFeatureType, type AnnotationMode, type AnnotationOperation, AnnotationPlugin, type AnnotationPluginOptions, type AnnotationStyle, type AnnotationsServiceConfig, DataJoin, type DataJoinOptions, DataJoinPlugin, type DrawOverlayCallback, type DrawOverlayFn, ExportPlugin, type ExportPluginOptions, type FlowMapExportOptions, HoverEffectPlugin, MapPluginBase, PluginManager, PopupPlugin, SelectionEvent, type SelectionEventType, type SelectionEventTypes, type SelectionMode, type SelectionOptions, SelectionPlugin, UrlSyncPlugin };
@@ -1,48 +0,0 @@
1
- 'use strict';
2
-
3
- const randomId = require('../../shared/flow-rdf-core.f50908f0.cjs');
4
- const featureTypeChecks = require('../../shared/flow-rdf-core.a82b9be4.cjs');
5
- const throttle = require('../../shared/flow-rdf-core.55c169ca.cjs');
6
- const lit = require('lit-html');
7
- require('nanoid');
8
- require('@turf/invariant');
9
-
10
-
11
-
12
- exports.capitalize = randomId.capitalize;
13
- exports.ensureArray = randomId.ensureArray;
14
- exports.hasLength = randomId.hasLength;
15
- exports.hasValue = randomId.hasValue;
16
- exports.isArray = randomId.isArray;
17
- exports.isArrayFull = randomId.isArrayFull;
18
- exports.isArrayStrings = randomId.isArrayStrings;
19
- exports.isBoolean = randomId.isBoolean;
20
- exports.isDate = randomId.isDate;
21
- exports.isDefined = randomId.isDefined;
22
- exports.isFalse = randomId.isFalse;
23
- exports.isFunction = randomId.isFunction;
24
- exports.isIn = randomId.isIn;
25
- exports.isNil = randomId.isNil;
26
- exports.isNull = randomId.isNull;
27
- exports.isNumber = randomId.isNumber;
28
- exports.isNumeric = randomId.isNumeric;
29
- exports.isObject = randomId.isObject;
30
- exports.isObjectFull = randomId.isObjectFull;
31
- exports.isPlainObject = randomId.isPlainObject;
32
- exports.isString = randomId.isString;
33
- exports.isStringFull = randomId.isStringFull;
34
- exports.isTrue = randomId.isTrue;
35
- exports.isURL = randomId.isURL;
36
- exports.isUndefined = randomId.isUndefined;
37
- exports.isValue = randomId.isValue;
38
- exports.randomId = randomId.randomId;
39
- exports.isLineString = featureTypeChecks.isLineString;
40
- exports.isMultiPolygon = featureTypeChecks.isMultiPolygon;
41
- exports.isPoint = featureTypeChecks.isPoint;
42
- exports.isPolygon = featureTypeChecks.isPolygon;
43
- exports.debounce = throttle.debounce;
44
- exports.debounceWithArgs = throttle.debounceWithArgs;
45
- exports.memoize = throttle.memoize;
46
- exports.throttle = throttle.throttle;
47
- exports.throttleWithArgs = throttle.throttleWithArgs;
48
- exports.html = lit.html;
@@ -1,160 +0,0 @@
1
- import * as GeoJSON from 'geojson';
2
- import { N as NoReturn, F as Func, M as MemoizeOptions } from '../../shared/flow-rdf-core.63162669.cjs';
3
- export { m as memoize } from '../../shared/flow-rdf-core.63162669.cjs';
4
- export { html } from 'lit-html';
5
-
6
- declare const isUndefined: (val: unknown) => val is undefined;
7
- declare const isNull: (val: unknown) => val is null;
8
- declare const isNil: (val: unknown) => val is null | undefined;
9
- declare const isDefined: <T>(val: T) => val is Exclude<T, null | undefined>;
10
- declare const isString: (val: unknown) => val is string;
11
- declare const hasLength: (val: unknown) => boolean;
12
- declare const isStringFull: (val: unknown) => val is string;
13
- declare const isArray: (val: unknown) => val is unknown[];
14
- declare const isArrayFull: (val: unknown) => val is unknown[];
15
- declare const isArrayStrings: (val: unknown) => val is string[];
16
- declare const isObject: (val: unknown) => val is object;
17
- declare const isObjectFull: (val: unknown) => boolean;
18
- declare const isNumber: (val: unknown) => val is number;
19
- declare const isFalse: (val: unknown) => val is false;
20
- declare const isTrue: (val: unknown) => val is true;
21
- declare const isIn: (val: unknown, arr: any[]) => boolean;
22
- declare const isBoolean: (val: unknown) => val is boolean;
23
- declare const isNumeric: (val: unknown) => boolean;
24
- declare const isDate: (val: unknown) => val is Date;
25
- declare const isValue: (val: unknown) => boolean;
26
- declare const hasValue: (val: unknown) => boolean;
27
- declare const isFunction: (val: unknown) => val is Function;
28
- declare function isPlainObject(o: unknown): boolean;
29
- declare function isURL(val: unknown): val is string;
30
-
31
- declare function ensureArray<T>(a: T | T[], ...rest: T[]): T[];
32
-
33
- declare const isPoint: (val: unknown) => val is GeoJSON.Feature<GeoJSON.Point> | GeoJSON.Point;
34
- declare const isLineString: (val: any) => val is GeoJSON.Feature<GeoJSON.LineString> | GeoJSON.LineString;
35
- declare const isPolygon: (val: any) => val is GeoJSON.Feature<GeoJSON.Polygon> | GeoJSON.Polygon;
36
- declare const isMultiPolygon: (val: any) => val is GeoJSON.Feature<GeoJSON.MultiPolygon> | GeoJSON.MultiPolygon;
37
-
38
- /**
39
- * Creates a debounced function that delays invoking `func` until after `wait`
40
- * milliseconds have elapsed since the last time the debounced function was
41
- * invoked. The debounced function comes with a `cancel` method to cancel
42
- * delayed `func` invocations and a `flush` method to immediately invoke them.
43
- * Provide `options` to indicate whether `func` should be invoked on the
44
- * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
45
- * with the last arguments provided to the debounced function. Subsequent
46
- * calls to the debounced function return the result of the last `func`
47
- * invocation.
48
- *
49
- * **Note:** If `leading` and `trailing` options are `true`, `func` is
50
- * invoked on the trailing edge of the timeout only if the debounced function
51
- * is invoked more than once during the `wait` timeout.
52
- *
53
- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
54
- * until to the next tick, similar to `setTimeout` with a timeout of `0`.
55
- *
56
- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
57
- * for details over the differences between `_.debounce` and `_.throttle`.
58
- *
59
- * @param {Function} func The function to debounce.
60
- * @param {number} [wait=0] The number of milliseconds to delay.
61
- * @param {Object} [options={}] The options object.
62
- * @param {boolean} [options.leading=false]
63
- * Specify invoking on the leading edge of the timeout.
64
- * @param {number} [options.maxWait]
65
- * The maximum time `func` is allowed to be delayed before it's invoked.
66
- * @param {boolean} [options.trailing=true]
67
- * Specify invoking on the trailing edge of the timeout.
68
- * @returns {Function} Returns the new debounced function.
69
- * @example
70
- *
71
- * // Avoid costly calculations while the window size is in flux.
72
- * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
73
- *
74
- * // Invoke `sendMail` when clicked, debouncing subsequent calls.
75
- * jQuery(element).on('click', _.debounce(sendMail, 300, {
76
- * 'leading': true,
77
- * 'trailing': false
78
- * }));
79
- *
80
- * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
81
- * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
82
- * var source = new EventSource('/stream');
83
- * jQuery(source).on('message', debounced);
84
- *
85
- * // Cancel the trailing debounced invocation.
86
- * jQuery(window).on('popstate', debounced.cancel);
87
- */
88
-
89
- interface CancelOptions {
90
- upcomingOnly?: boolean;
91
- }
92
- interface Cancel {
93
- cancel: (options?: CancelOptions) => void;
94
- }
95
- interface DebounceOptions {
96
- leading?: boolean;
97
- trailing?: boolean;
98
- maxWait?: number;
99
- context?: any;
100
- }
101
- declare function debounce<TFunc extends (...args: any[]) => any>(func: TFunc, wait: number, options?: DebounceOptions): NoReturn<TFunc> & Cancel;
102
- type MemoizedDebounceOptions<TArgs extends any[], TKey> = DebounceOptions & MemoizeOptions<TArgs, TKey>;
103
- declare function debounceWithArgs<TArgs extends any[], TKey>(fn: Func<TArgs, any>, wait: number, options: MemoizedDebounceOptions<TArgs, TKey>): Func<TArgs, void>;
104
-
105
- /**
106
- * Creates a throttled function that only invokes `func` at most once per
107
- * every `wait` milliseconds. The throttled function comes with a `cancel`
108
- * method to cancel delayed `func` invocations and a `flush` method to
109
- * immediately invoke them. Provide `options` to indicate whether `func`
110
- * should be invoked on the leading and/or trailing edge of the `wait`
111
- * timeout. The `func` is invoked with the last arguments provided to the
112
- * throttled function. Subsequent calls to the throttled function return the
113
- * result of the last `func` invocation.
114
- *
115
- * **Note:** If `leading` and `trailing` options are `true`, `func` is
116
- * invoked on the trailing edge of the timeout only if the throttled function
117
- * is invoked more than once during the `wait` timeout.
118
- *
119
- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
120
- * until to the next tick, similar to `setTimeout` with a timeout of `0`.
121
- *
122
- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
123
- * for details over the differences between `_.throttle` and `_.debounce`.
124
- *
125
- * @param {Function} func The function to throttle.
126
- * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
127
- * @param {Object} [options={}] The options object.
128
- * @param {boolean} [options.leading=true]
129
- * Specify invoking on the leading edge of the timeout.
130
- * @param {boolean} [options.trailing=true]
131
- * Specify invoking on the trailing edge of the timeout.
132
- * @returns {Function} Returns the new throttled function.
133
- * @example
134
- *
135
- * // Avoid excessively updating the position while scrolling.
136
- * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
137
- *
138
- * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
139
- * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
140
- * jQuery(element).on('click', throttled);
141
- *
142
- * // Cancel the trailing throttled invocation.
143
- * jQuery(window).on('popstate', throttled.cancel);
144
- */
145
- declare function throttle<TFunc extends (...args: any[]) => any>(func: TFunc, wait: number, options?: Omit<DebounceOptions, 'maxWait'>): NoReturn<TFunc> & Cancel;
146
- type MemoizedThrottleOptions<TArgs extends any[], TKey> = Omit<DebounceOptions, 'maxWait'> & MemoizeOptions<TArgs, TKey>;
147
- declare function throttleWithArgs<TArgs extends any[], TKey>(fn: Func<TArgs, any>, wait: number, options: MemoizedThrottleOptions<TArgs, TKey>): Func<TArgs, void>;
148
-
149
- declare const capitalize: (str: string, lowerRest?: boolean) => string;
150
-
151
- /**
152
- * Generate a random ID of `length` characters and prepending the given prefix.
153
- *
154
- * @param prefix Fixed prefix to prepend to the generated ID.
155
- * @param length Number of characters in the generated ID.
156
- *
157
- */
158
- declare function randomId(prefix?: string, length?: number): string;
159
-
160
- export { capitalize, debounce, debounceWithArgs, ensureArray, hasLength, hasValue, isArray, isArrayFull, isArrayStrings, isBoolean, isDate, isDefined, isFalse, isFunction, isIn, isLineString, isMultiPolygon, isNil, isNull, isNumber, isNumeric, isObject, isObjectFull, isPlainObject, isPoint, isPolygon, isString, isStringFull, isTrue, isURL, isUndefined, isValue, randomId, throttle, throttleWithArgs };