map-2d-base 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # 乾坤库的底层基础
2
+
3
+
@@ -0,0 +1 @@
1
+ :host,:root{--ol-background-color:#fff;--ol-accent-background-color:#f5f5f5;--ol-subtle-background-color:hsla(0,0%,50%,.25);--ol-partial-background-color:hsla(0,0%,100%,.75);--ol-foreground-color:#333;--ol-subtle-foreground-color:#666;--ol-brand-color:#0af}.ol-box{background-color:var(--ol-partial-background-color);border:.00781rem solid var(--ol-background-color);border-radius:.01042rem;box-sizing:border-box}.ol-mouse-position{position:absolute;right:.04167rem;top:.04167rem}.ol-scale-line{background:var(--ol-partial-background-color);border-radius:.02083rem;bottom:.04167rem;left:.04167rem;padding:.01042rem;position:absolute}.ol-scale-line-inner{border:.00521rem solid var(--ol-subtle-foreground-color);border-top:none;color:var(--ol-foreground-color);font-size:.05208rem;margin:.00521rem;text-align:center;transition:all .25s;will-change:contents,width}.ol-scale-bar{bottom:.04167rem;left:.04167rem;position:absolute}.ol-scale-bar-inner{display:flex}.ol-scale-step-marker{background-color:var(--ol-foreground-color);float:right;height:.07813rem;width:.00521rem;z-index:10}.ol-scale-step-text{bottom:-.02604rem;font-size:.05208rem;z-index:11}.ol-scale-step-text,.ol-scale-text{color:var(--ol-foreground-color);position:absolute;text-shadow:-.00781rem 0 var(--ol-partial-background-color),0 .00781rem var(--ol-partial-background-color),.00781rem 0 var(--ol-partial-background-color),0 -.00781rem var(--ol-partial-background-color)}.ol-scale-text{bottom:.13021rem;font-size:.0625rem;text-align:center}.ol-scale-singlebar{border:.00521rem solid var(--ol-foreground-color);box-sizing:border-box;height:.05208rem;position:relative;z-index:9}.ol-scale-singlebar-even{background-color:var(--ol-subtle-foreground-color)}.ol-scale-singlebar-odd{background-color:var(--ol-background-color)}.ol-unsupported{display:none}.ol-unselectable,.ol-viewport{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}.ol-viewport canvas{all:unset;overflow:hidden}.ol-viewport{touch-action:pan-x pan-y}.ol-selectable{-webkit-touch-callout:default;-webkit-user-select:text;-moz-user-select:text;user-select:text}.ol-grabbing{cursor:grabbing}.ol-grab{cursor:move;cursor:grab}.ol-control{background-color:var(--ol-subtle-background-color);border-radius:.02083rem;position:absolute}.ol-zoom{left:.5em;top:.5em}.ol-rotate{right:.5em;top:.5em;transition:opacity .25s linear,visibility 0s linear}.ol-rotate.ol-hidden{opacity:0;transition:opacity .25s linear,visibility 0s linear .25s;visibility:hidden}.ol-zoom-extent{left:.5em;top:4.643em}.ol-full-screen{right:.5em;top:.5em}.ol-control button{background-color:var(--ol-background-color);border:none;border-radius:.01042rem;color:var(--ol-subtle-foreground-color);display:block;font-size:inherit;font-weight:700;height:1.375em;line-height:.4em;margin:.00521rem;padding:0;text-align:center;text-decoration:none;width:1.375em}.ol-control button::-moz-focus-inner{border:none;padding:0}.ol-zoom-extent button{line-height:1.4em}.ol-compass{display:block;font-weight:400;will-change:transform}.ol-touch .ol-control button{font-size:1.5em}.ol-touch .ol-zoom-extent{top:5.5em}.ol-control button:focus,.ol-control button:hover{color:var(--ol-foreground-color);outline:.00521rem solid var(--ol-subtle-foreground-color);text-decoration:none}.ol-zoom .ol-zoom-in{border-radius:.01042rem .01042rem 0 0}.ol-zoom .ol-zoom-out{border-radius:0 0 .01042rem .01042rem}.ol-attribution{align-items:center;bottom:.5em;display:flex;flex-flow:row-reverse;max-width:calc(100% - 1.3em);right:.5em;text-align:right}.ol-attribution a{color:var(--ol-subtle-foreground-color);text-decoration:none}.ol-attribution ul{color:var(--ol-foreground-color);font-size:.0625rem;margin:0;padding:.00521rem .5em;text-shadow:0 0 .01042rem var(--ol-background-color)}.ol-attribution li{display:inline;list-style:none}.ol-attribution li:not(:last-child):after{content:" "}.ol-attribution img{max-height:2em;max-width:inherit;vertical-align:middle}.ol-attribution button{flex-shrink:0}.ol-attribution.ol-collapsed ul{display:none}.ol-attribution:not(.ol-collapsed){background:var(--ol-partial-background-color)}.ol-attribution.ol-uncollapsible{border-radius:.02083rem 0 0;bottom:0;right:0}.ol-attribution.ol-uncollapsible img{margin-top:-.2em;max-height:1.6em}.ol-attribution.ol-uncollapsible button{display:none}.ol-zoomslider{height:1.04167rem;left:.5em;top:4.5em}.ol-zoomslider button{height:.05208rem;position:relative}.ol-touch .ol-zoomslider{top:5.5em}.ol-overviewmap{bottom:.5em;left:.5em}.ol-overviewmap.ol-uncollapsible{border-radius:0 .02083rem 0 0;bottom:0;left:0}.ol-overviewmap .ol-overviewmap-map,.ol-overviewmap button{display:block}.ol-overviewmap .ol-overviewmap-map{border:.00521rem solid var(--ol-subtle-foreground-color);height:.78125rem;width:.78125rem}.ol-overviewmap:not(.ol-collapsed) button{bottom:0;left:0;position:absolute}.ol-overviewmap.ol-collapsed .ol-overviewmap-map,.ol-overviewmap.ol-uncollapsible button{display:none}.ol-overviewmap:not(.ol-collapsed){background:var(--ol-subtle-background-color)}.ol-overviewmap-box{border:.00781rem dotted var(--ol-subtle-foreground-color)}.ol-overviewmap .ol-overviewmap-box:hover{cursor:move}.ol-overviewmap .ol-viewport:hover{cursor:pointer}
@@ -0,0 +1,713 @@
1
+ const ObjectEventType = {
2
+ /**
3
+ * Triggered when a property is changed.
4
+ * @event module:ol/Object.ObjectEvent#propertychange
5
+ * @api
6
+ */
7
+ PROPERTYCHANGE: "propertychange"
8
+ };
9
+ const EventType = {
10
+ /**
11
+ * Generic change event. Triggered when the revision counter is increased.
12
+ * @event module:ol/events/Event~BaseEvent#change
13
+ * @api
14
+ */
15
+ CHANGE: "change",
16
+ /**
17
+ * Generic error event. Triggered when an error occurs.
18
+ * @event module:ol/events/Event~BaseEvent#error
19
+ * @api
20
+ */
21
+ ERROR: "error",
22
+ CONTEXTMENU: "contextmenu",
23
+ CLICK: "click",
24
+ DBLCLICK: "dblclick",
25
+ KEYDOWN: "keydown",
26
+ KEYPRESS: "keypress",
27
+ LOAD: "load",
28
+ TOUCHMOVE: "touchmove",
29
+ WHEEL: "wheel"
30
+ };
31
+ class Disposable {
32
+ constructor() {
33
+ this.disposed = false;
34
+ }
35
+ /**
36
+ * Clean up.
37
+ */
38
+ dispose() {
39
+ if (!this.disposed) {
40
+ this.disposed = true;
41
+ this.disposeInternal();
42
+ }
43
+ }
44
+ /**
45
+ * Extension point for disposable objects.
46
+ * @protected
47
+ */
48
+ disposeInternal() {
49
+ }
50
+ }
51
+ function binarySearch(haystack, needle, comparator) {
52
+ let mid, cmp;
53
+ comparator = comparator || ascending;
54
+ let low = 0;
55
+ let high = haystack.length;
56
+ let found = false;
57
+ while (low < high) {
58
+ mid = low + (high - low >> 1);
59
+ cmp = +comparator(haystack[mid], needle);
60
+ if (cmp < 0) {
61
+ low = mid + 1;
62
+ } else {
63
+ high = mid;
64
+ found = !cmp;
65
+ }
66
+ }
67
+ return found ? low : ~low;
68
+ }
69
+ function ascending(a, b) {
70
+ return a > b ? 1 : a < b ? -1 : 0;
71
+ }
72
+ function descending(a, b) {
73
+ return a < b ? 1 : a > b ? -1 : 0;
74
+ }
75
+ function linearFindNearest(arr, target, direction) {
76
+ if (arr[0] <= target) {
77
+ return 0;
78
+ }
79
+ const n = arr.length;
80
+ if (target <= arr[n - 1]) {
81
+ return n - 1;
82
+ }
83
+ if (typeof direction === "function") {
84
+ for (let i = 1; i < n; ++i) {
85
+ const candidate = arr[i];
86
+ if (candidate === target) {
87
+ return i;
88
+ }
89
+ if (candidate < target) {
90
+ if (direction(target, arr[i - 1], candidate) > 0) {
91
+ return i - 1;
92
+ }
93
+ return i;
94
+ }
95
+ }
96
+ return n - 1;
97
+ }
98
+ if (direction > 0) {
99
+ for (let i = 1; i < n; ++i) {
100
+ if (arr[i] < target) {
101
+ return i - 1;
102
+ }
103
+ }
104
+ return n - 1;
105
+ }
106
+ if (direction < 0) {
107
+ for (let i = 1; i < n; ++i) {
108
+ if (arr[i] <= target) {
109
+ return i;
110
+ }
111
+ }
112
+ return n - 1;
113
+ }
114
+ for (let i = 1; i < n; ++i) {
115
+ if (arr[i] == target) {
116
+ return i;
117
+ }
118
+ if (arr[i] < target) {
119
+ if (arr[i - 1] - target < target - arr[i]) {
120
+ return i - 1;
121
+ }
122
+ return i;
123
+ }
124
+ }
125
+ return n - 1;
126
+ }
127
+ function reverseSubArray(arr, begin, end) {
128
+ while (begin < end) {
129
+ const tmp = arr[begin];
130
+ arr[begin] = arr[end];
131
+ arr[end] = tmp;
132
+ ++begin;
133
+ --end;
134
+ }
135
+ }
136
+ function extend(arr, data) {
137
+ const extension = Array.isArray(data) ? data : [data];
138
+ const length = extension.length;
139
+ for (let i = 0; i < length; i++) {
140
+ arr[arr.length] = extension[i];
141
+ }
142
+ }
143
+ function equals(arr1, arr2) {
144
+ const len1 = arr1.length;
145
+ if (len1 !== arr2.length) {
146
+ return false;
147
+ }
148
+ for (let i = 0; i < len1; i++) {
149
+ if (arr1[i] !== arr2[i]) {
150
+ return false;
151
+ }
152
+ }
153
+ return true;
154
+ }
155
+ function isSorted(arr, func, strict) {
156
+ const compare = func || ascending;
157
+ return arr.every(function(currentVal, index) {
158
+ if (index === 0) {
159
+ return true;
160
+ }
161
+ const res = compare(arr[index - 1], currentVal);
162
+ return !(res > 0 || res === 0);
163
+ });
164
+ }
165
+ function TRUE() {
166
+ return true;
167
+ }
168
+ function FALSE() {
169
+ return false;
170
+ }
171
+ function VOID() {
172
+ }
173
+ function memoizeOne(fn) {
174
+ let lastResult;
175
+ let lastArgs;
176
+ let lastThis;
177
+ return function() {
178
+ const nextArgs = Array.prototype.slice.call(arguments);
179
+ if (!lastArgs || this !== lastThis || !equals(nextArgs, lastArgs)) {
180
+ lastThis = this;
181
+ lastArgs = nextArgs;
182
+ lastResult = fn.apply(this, arguments);
183
+ }
184
+ return lastResult;
185
+ };
186
+ }
187
+ function toPromise(getter) {
188
+ function promiseGetter() {
189
+ let value;
190
+ try {
191
+ value = getter();
192
+ } catch (err) {
193
+ return Promise.reject(err);
194
+ }
195
+ if (value instanceof Promise) {
196
+ return value;
197
+ }
198
+ return Promise.resolve(value);
199
+ }
200
+ return promiseGetter();
201
+ }
202
+ function clear(object) {
203
+ for (const property in object) {
204
+ delete object[property];
205
+ }
206
+ }
207
+ function isEmpty(object) {
208
+ let property;
209
+ for (property in object) {
210
+ return false;
211
+ }
212
+ return !property;
213
+ }
214
+ class BaseEvent {
215
+ /**
216
+ * @param {string} type Type.
217
+ */
218
+ constructor(type) {
219
+ this.propagationStopped;
220
+ this.defaultPrevented;
221
+ this.type = type;
222
+ this.target = null;
223
+ }
224
+ /**
225
+ * Prevent default. This means that no emulated `click`, `singleclick` or `doubleclick` events
226
+ * will be fired.
227
+ * @api
228
+ */
229
+ preventDefault() {
230
+ this.defaultPrevented = true;
231
+ }
232
+ /**
233
+ * Stop event propagation.
234
+ * @api
235
+ */
236
+ stopPropagation() {
237
+ this.propagationStopped = true;
238
+ }
239
+ }
240
+ class Target extends Disposable {
241
+ /**
242
+ * @param {*} [target] Default event target for dispatched events.
243
+ */
244
+ constructor(target) {
245
+ super();
246
+ this.eventTarget_ = target;
247
+ this.pendingRemovals_ = null;
248
+ this.dispatching_ = null;
249
+ this.listeners_ = null;
250
+ }
251
+ /**
252
+ * @param {string} type Type.
253
+ * @param {import("../events.js").Listener} listener Listener.
254
+ */
255
+ addEventListener(type, listener) {
256
+ if (!type || !listener) {
257
+ return;
258
+ }
259
+ const listeners = this.listeners_ || (this.listeners_ = {});
260
+ const listenersForType = listeners[type] || (listeners[type] = []);
261
+ if (!listenersForType.includes(listener)) {
262
+ listenersForType.push(listener);
263
+ }
264
+ }
265
+ /**
266
+ * Dispatches an event and calls all listeners listening for events
267
+ * of this type. The event parameter can either be a string or an
268
+ * Object with a `type` property.
269
+ *
270
+ * @param {import("./Event.js").default|string} event Event object.
271
+ * @return {boolean|undefined} `false` if anyone called preventDefault on the
272
+ * event object or if any of the listeners returned false.
273
+ * @api
274
+ */
275
+ dispatchEvent(event) {
276
+ const isString = typeof event === "string";
277
+ const type = isString ? event : event.type;
278
+ const listeners = this.listeners_ && this.listeners_[type];
279
+ if (!listeners) {
280
+ return;
281
+ }
282
+ const evt = isString ? new BaseEvent(event) : (
283
+ /** @type {Event} */
284
+ event
285
+ );
286
+ if (!evt.target) {
287
+ evt.target = this.eventTarget_ || this;
288
+ }
289
+ const dispatching = this.dispatching_ || (this.dispatching_ = {});
290
+ const pendingRemovals = this.pendingRemovals_ || (this.pendingRemovals_ = {});
291
+ if (!(type in dispatching)) {
292
+ dispatching[type] = 0;
293
+ pendingRemovals[type] = 0;
294
+ }
295
+ ++dispatching[type];
296
+ let propagate;
297
+ for (let i = 0, ii = listeners.length; i < ii; ++i) {
298
+ if ("handleEvent" in listeners[i]) {
299
+ propagate = /** @type {import("../events.js").ListenerObject} */
300
+ listeners[i].handleEvent(evt);
301
+ } else {
302
+ propagate = /** @type {import("../events.js").ListenerFunction} */
303
+ listeners[i].call(this, evt);
304
+ }
305
+ if (propagate === false || evt.propagationStopped) {
306
+ propagate = false;
307
+ break;
308
+ }
309
+ }
310
+ if (--dispatching[type] === 0) {
311
+ let pr = pendingRemovals[type];
312
+ delete pendingRemovals[type];
313
+ while (pr--) {
314
+ this.removeEventListener(type, VOID);
315
+ }
316
+ delete dispatching[type];
317
+ }
318
+ return propagate;
319
+ }
320
+ /**
321
+ * Clean up.
322
+ * @override
323
+ */
324
+ disposeInternal() {
325
+ this.listeners_ && clear(this.listeners_);
326
+ }
327
+ /**
328
+ * Get the listeners for a specified event type. Listeners are returned in the
329
+ * order that they will be called in.
330
+ *
331
+ * @param {string} type Type.
332
+ * @return {Array<import("../events.js").Listener>|undefined} Listeners.
333
+ */
334
+ getListeners(type) {
335
+ return this.listeners_ && this.listeners_[type] || void 0;
336
+ }
337
+ /**
338
+ * @param {string} [type] Type. If not provided,
339
+ * `true` will be returned if this event target has any listeners.
340
+ * @return {boolean} Has listeners.
341
+ */
342
+ hasListener(type) {
343
+ if (!this.listeners_) {
344
+ return false;
345
+ }
346
+ return type ? type in this.listeners_ : Object.keys(this.listeners_).length > 0;
347
+ }
348
+ /**
349
+ * @param {string} type Type.
350
+ * @param {import("../events.js").Listener} listener Listener.
351
+ */
352
+ removeEventListener(type, listener) {
353
+ if (!this.listeners_) {
354
+ return;
355
+ }
356
+ const listeners = this.listeners_[type];
357
+ if (!listeners) {
358
+ return;
359
+ }
360
+ const index = listeners.indexOf(listener);
361
+ if (index !== -1) {
362
+ if (this.pendingRemovals_ && type in this.pendingRemovals_) {
363
+ listeners[index] = VOID;
364
+ ++this.pendingRemovals_[type];
365
+ } else {
366
+ listeners.splice(index, 1);
367
+ if (listeners.length === 0) {
368
+ delete this.listeners_[type];
369
+ }
370
+ }
371
+ }
372
+ }
373
+ }
374
+ function listen(target, type, listener, thisArg, once) {
375
+ if (once) {
376
+ const originalListener = listener;
377
+ listener = function(event) {
378
+ target.removeEventListener(type, listener);
379
+ return originalListener.call(thisArg != null ? thisArg : this, event);
380
+ };
381
+ } else if (thisArg && thisArg !== target) {
382
+ listener = listener.bind(thisArg);
383
+ }
384
+ const eventsKey = {
385
+ target,
386
+ type,
387
+ listener
388
+ };
389
+ target.addEventListener(type, listener);
390
+ return eventsKey;
391
+ }
392
+ function listenOnce(target, type, listener, thisArg) {
393
+ return listen(target, type, listener, thisArg, true);
394
+ }
395
+ function unlistenByKey(key) {
396
+ if (key && key.target) {
397
+ key.target.removeEventListener(key.type, key.listener);
398
+ clear(key);
399
+ }
400
+ }
401
+ class Observable extends Target {
402
+ constructor() {
403
+ super();
404
+ this.on = /** @type {ObservableOnSignature<import("./events").EventsKey>} */
405
+ this.onInternal;
406
+ this.once = /** @type {ObservableOnSignature<import("./events").EventsKey>} */
407
+ this.onceInternal;
408
+ this.un = /** @type {ObservableOnSignature<void>} */
409
+ this.unInternal;
410
+ this.revision_ = 0;
411
+ }
412
+ /**
413
+ * Increases the revision counter and dispatches a 'change' event.
414
+ * @api
415
+ */
416
+ changed() {
417
+ ++this.revision_;
418
+ this.dispatchEvent(EventType.CHANGE);
419
+ }
420
+ /**
421
+ * Get the version number for this object. Each time the object is modified,
422
+ * its version number will be incremented.
423
+ * @return {number} Revision.
424
+ * @api
425
+ */
426
+ getRevision() {
427
+ return this.revision_;
428
+ }
429
+ /**
430
+ * @param {string|Array<string>} type Type.
431
+ * @param {function((Event|import("./events/Event").default)): ?} listener Listener.
432
+ * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
433
+ * @protected
434
+ */
435
+ onInternal(type, listener) {
436
+ if (Array.isArray(type)) {
437
+ const len = type.length;
438
+ const keys = new Array(len);
439
+ for (let i = 0; i < len; ++i) {
440
+ keys[i] = listen(this, type[i], listener);
441
+ }
442
+ return keys;
443
+ }
444
+ return listen(
445
+ this,
446
+ /** @type {string} */
447
+ type,
448
+ listener
449
+ );
450
+ }
451
+ /**
452
+ * @param {string|Array<string>} type Type.
453
+ * @param {function((Event|import("./events/Event").default)): ?} listener Listener.
454
+ * @return {import("./events.js").EventsKey|Array<import("./events.js").EventsKey>} Event key.
455
+ * @protected
456
+ */
457
+ onceInternal(type, listener) {
458
+ let key;
459
+ if (Array.isArray(type)) {
460
+ const len = type.length;
461
+ key = new Array(len);
462
+ for (let i = 0; i < len; ++i) {
463
+ key[i] = listenOnce(this, type[i], listener);
464
+ }
465
+ } else {
466
+ key = listenOnce(
467
+ this,
468
+ /** @type {string} */
469
+ type,
470
+ listener
471
+ );
472
+ }
473
+ listener.ol_key = key;
474
+ return key;
475
+ }
476
+ /**
477
+ * Unlisten for a certain type of event.
478
+ * @param {string|Array<string>} type Type.
479
+ * @param {function((Event|import("./events/Event").default)): ?} listener Listener.
480
+ * @protected
481
+ */
482
+ unInternal(type, listener) {
483
+ const key = (
484
+ /** @type {Object} */
485
+ listener.ol_key
486
+ );
487
+ if (key) {
488
+ unByKey(key);
489
+ } else if (Array.isArray(type)) {
490
+ for (let i = 0, ii = type.length; i < ii; ++i) {
491
+ this.removeEventListener(type[i], listener);
492
+ }
493
+ } else {
494
+ this.removeEventListener(type, listener);
495
+ }
496
+ }
497
+ }
498
+ Observable.prototype.on;
499
+ Observable.prototype.once;
500
+ Observable.prototype.un;
501
+ function unByKey(key) {
502
+ if (Array.isArray(key)) {
503
+ for (let i = 0, ii = key.length; i < ii; ++i) {
504
+ unlistenByKey(key[i]);
505
+ }
506
+ } else {
507
+ unlistenByKey(
508
+ /** @type {import("./events.js").EventsKey} */
509
+ key
510
+ );
511
+ }
512
+ }
513
+ function abstract() {
514
+ throw new Error("Unimplemented abstract method.");
515
+ }
516
+ let uidCounter_ = 0;
517
+ function getUid(obj) {
518
+ return obj.ol_uid || (obj.ol_uid = String(++uidCounter_));
519
+ }
520
+ class ObjectEvent extends BaseEvent {
521
+ /**
522
+ * @param {string} type The event type.
523
+ * @param {string} key The property name.
524
+ * @param {*} oldValue The old value for `key`.
525
+ */
526
+ constructor(type, key, oldValue) {
527
+ super(type);
528
+ this.key = key;
529
+ this.oldValue = oldValue;
530
+ }
531
+ }
532
+ class BaseObject extends Observable {
533
+ /**
534
+ * @param {Object<string, *>} [values] An object with key-value pairs.
535
+ */
536
+ constructor(values) {
537
+ super();
538
+ this.on;
539
+ this.once;
540
+ this.un;
541
+ getUid(this);
542
+ this.values_ = null;
543
+ if (values !== void 0) {
544
+ this.setProperties(values);
545
+ }
546
+ }
547
+ /**
548
+ * Gets a value.
549
+ * @param {string} key Key name.
550
+ * @return {*} Value.
551
+ * @api
552
+ */
553
+ get(key) {
554
+ let value;
555
+ if (this.values_ && this.values_.hasOwnProperty(key)) {
556
+ value = this.values_[key];
557
+ }
558
+ return value;
559
+ }
560
+ /**
561
+ * Get a list of object property names.
562
+ * @return {Array<string>} List of property names.
563
+ * @api
564
+ */
565
+ getKeys() {
566
+ return this.values_ && Object.keys(this.values_) || [];
567
+ }
568
+ /**
569
+ * Get an object of all property names and values.
570
+ * @return {Object<string, *>} Object.
571
+ * @api
572
+ */
573
+ getProperties() {
574
+ return this.values_ && Object.assign({}, this.values_) || {};
575
+ }
576
+ /**
577
+ * Get an object of all property names and values.
578
+ * @return {Object<string, *>?} Object.
579
+ */
580
+ getPropertiesInternal() {
581
+ return this.values_;
582
+ }
583
+ /**
584
+ * @return {boolean} The object has properties.
585
+ */
586
+ hasProperties() {
587
+ return !!this.values_;
588
+ }
589
+ /**
590
+ * @param {string} key Key name.
591
+ * @param {*} oldValue Old value.
592
+ */
593
+ notify(key, oldValue) {
594
+ let eventType;
595
+ eventType = `change:${key}`;
596
+ if (this.hasListener(eventType)) {
597
+ this.dispatchEvent(new ObjectEvent(eventType, key, oldValue));
598
+ }
599
+ eventType = ObjectEventType.PROPERTYCHANGE;
600
+ if (this.hasListener(eventType)) {
601
+ this.dispatchEvent(new ObjectEvent(eventType, key, oldValue));
602
+ }
603
+ }
604
+ /**
605
+ * @param {string} key Key name.
606
+ * @param {import("./events.js").Listener} listener Listener.
607
+ */
608
+ addChangeListener(key, listener) {
609
+ this.addEventListener(`change:${key}`, listener);
610
+ }
611
+ /**
612
+ * @param {string} key Key name.
613
+ * @param {import("./events.js").Listener} listener Listener.
614
+ */
615
+ removeChangeListener(key, listener) {
616
+ this.removeEventListener(`change:${key}`, listener);
617
+ }
618
+ /**
619
+ * Sets a value.
620
+ * @param {string} key Key name.
621
+ * @param {*} value Value.
622
+ * @param {boolean} [silent] Update without triggering an event.
623
+ * @api
624
+ */
625
+ set(key, value, silent) {
626
+ const values = this.values_ || (this.values_ = {});
627
+ if (silent) {
628
+ values[key] = value;
629
+ } else {
630
+ const oldValue = values[key];
631
+ values[key] = value;
632
+ if (oldValue !== value) {
633
+ this.notify(key, oldValue);
634
+ }
635
+ }
636
+ }
637
+ /**
638
+ * Sets a collection of key-value pairs. Note that this changes any existing
639
+ * properties and adds new ones (it does not remove any existing properties).
640
+ * @param {Object<string, *>} values Values.
641
+ * @param {boolean} [silent] Update without triggering an event.
642
+ * @api
643
+ */
644
+ setProperties(values, silent) {
645
+ for (const key in values) {
646
+ this.set(key, values[key], silent);
647
+ }
648
+ }
649
+ /**
650
+ * Apply any properties from another object without triggering events.
651
+ * @param {BaseObject} source The source object.
652
+ * @protected
653
+ */
654
+ applyProperties(source) {
655
+ if (!source.values_) {
656
+ return;
657
+ }
658
+ Object.assign(this.values_ || (this.values_ = {}), source.values_);
659
+ }
660
+ /**
661
+ * Unsets a property.
662
+ * @param {string} key Key name.
663
+ * @param {boolean} [silent] Unset without triggering an event.
664
+ * @api
665
+ */
666
+ unset(key, silent) {
667
+ if (this.values_ && key in this.values_) {
668
+ const oldValue = this.values_[key];
669
+ delete this.values_[key];
670
+ if (isEmpty(this.values_)) {
671
+ this.values_ = null;
672
+ }
673
+ if (!silent) {
674
+ this.notify(key, oldValue);
675
+ }
676
+ }
677
+ }
678
+ }
679
+ function assert(assertion, errorMessage) {
680
+ if (!assertion) {
681
+ throw new Error(errorMessage);
682
+ }
683
+ }
684
+ export {
685
+ BaseObject as B,
686
+ Disposable as D,
687
+ EventType as E,
688
+ FALSE as F,
689
+ ObjectEventType as O,
690
+ Target as T,
691
+ VOID as V,
692
+ BaseEvent as a,
693
+ assert as b,
694
+ clear as c,
695
+ ascending as d,
696
+ extend as e,
697
+ linearFindNearest as f,
698
+ equals as g,
699
+ TRUE as h,
700
+ abstract as i,
701
+ getUid as j,
702
+ isEmpty as k,
703
+ listen as l,
704
+ descending as m,
705
+ Observable as n,
706
+ binarySearch as o,
707
+ memoizeOne as p,
708
+ isSorted as q,
709
+ reverseSubArray as r,
710
+ listenOnce as s,
711
+ toPromise as t,
712
+ unlistenByKey as u
713
+ };