@angular-wave/angular.ts 0.14.0 → 0.14.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.
@@ -1,4 +1,4 @@
1
- /* Version: 0.14.0 - December 5, 2025 23:43:29 */
1
+ /* Version: 0.14.2 - December 7, 2025 03:52:37 */
2
2
  const VALID_CLASS = "ng-valid";
3
3
  const INVALID_CLASS = "ng-invalid";
4
4
  const PRISTINE_CLASS = "ng-pristine";
@@ -57,7 +57,6 @@ function isPromise(obj) {
57
57
 
58
58
  const isProxySymbol = Symbol("isProxy");
59
59
  const BADARG = "badarg";
60
- const BADARGKEY = "badarg: key";
61
60
  const BADARGVALUE = "badarg: value";
62
61
 
63
62
  /**
@@ -219,10 +218,7 @@ function isNumber(value) {
219
218
  }
220
219
 
221
220
  /**
222
- * @module angular
223
- * @function isDate
224
221
  *
225
- * @description
226
222
  * Determines if a value is a date.
227
223
  *
228
224
  * @param {*} value Reference to check.
@@ -981,7 +977,7 @@ function assert(argument, errorMsg = "Assertion failed") {
981
977
 
982
978
  /** @type {Map<ng.Validator, string>} */
983
979
  const reasons = new Map([
984
- [isNullOrUndefined, "required"],
980
+ [notNullOrUndefined, "required"],
985
981
  [Array.isArray, "notarray"],
986
982
  [isInjectable, "notinjectable"],
987
983
  [isDefined, "required"],
@@ -1000,6 +996,7 @@ function getReason(val) {
1000
996
  /**
1001
997
  * Validate a value using a predicate function.
1002
998
  * Throws if the predicate returns false.
999
+ * IMPORTANT: use this function only for developper errors and not for user/data errors
1003
1000
  *
1004
1001
  * @param {ng.Validator} fn - Predicate validator function.
1005
1002
  * @param {*} arg - The value to validate.
@@ -1041,6 +1038,16 @@ function validateArray(arg, name) {
1041
1038
  return validate(Array.isArray, arg, name);
1042
1039
  }
1043
1040
 
1041
+ /**
1042
+ * @param {*} arg - The value to validate.
1043
+ * @param {string} name - Parameter name (included in error message).
1044
+ * @returns {*} The validated value.
1045
+ * @throws {TypeError} If the value does not satisfy the validator.
1046
+ */
1047
+ function validateIsString(arg, name) {
1048
+ return validate(isString, arg, name);
1049
+ }
1050
+
1044
1051
  /**
1045
1052
  * Throw error if the argument is falsy.
1046
1053
  */
@@ -1447,6 +1454,14 @@ async function instantiateWasm(src, imports = {}) {
1447
1454
  return { instance, exports: instance.exports, module };
1448
1455
  }
1449
1456
 
1457
+ /**
1458
+ * @param {*} fn
1459
+ * @returns {boolean}
1460
+ */
1461
+ function isArrowFunction(fn) {
1462
+ return typeof fn === "function" && !fn.prototype;
1463
+ }
1464
+
1450
1465
  /**
1451
1466
  * Expando cache for adding properties to DOM nodes with JavaScript.
1452
1467
  * This used to be an Object in JQLite decorator, but swapped out for a Map
@@ -2782,7 +2797,16 @@ class AbstractInjector {
2782
2797
  // Empty object at position 0 is ignored for invocation with `new`, but required.
2783
2798
  args.unshift(null);
2784
2799
 
2785
- return new (Function.prototype.bind.apply(ctor, args))();
2800
+ try {
2801
+ return new (Function.prototype.bind.apply(ctor, args))();
2802
+ } catch (err) {
2803
+ // try arrow function
2804
+ if (isArrowFunction(ctor)) {
2805
+ return ctor(args);
2806
+ } else {
2807
+ throw err;
2808
+ }
2809
+ }
2786
2810
  }
2787
2811
 
2788
2812
  /**
@@ -5375,6 +5399,8 @@ class NgModule {
5375
5399
  * @returns {NgModule}
5376
5400
  */
5377
5401
  factory(name, providerFunction) {
5402
+ validate(isString, name, "name");
5403
+ validateRequired(providerFunction, "providerFunction");
5378
5404
  this.invokeQueue.push([$injectTokens.$provide, "factory", [name, providerFunction]]);
5379
5405
 
5380
5406
  return this;
@@ -5386,6 +5412,8 @@ class NgModule {
5386
5412
  * @returns {NgModule}
5387
5413
  */
5388
5414
  service(name, serviceFunction) {
5415
+ validate(isString, name, "name");
5416
+ validateRequired(serviceFunction, "serviceFunction");
5389
5417
  this.services.push(name);
5390
5418
  this.invokeQueue.push([$injectTokens.$provide, "service", [name, serviceFunction]]);
5391
5419
 
@@ -5398,9 +5426,8 @@ class NgModule {
5398
5426
  * @returns {NgModule}
5399
5427
  */
5400
5428
  provider(name, providerType) {
5401
- if (providerType && isFunction(providerType)) {
5402
- providerType.$$moduleName = name;
5403
- }
5429
+ validate(isString, name, "name");
5430
+ validateRequired(providerType, "providerType");
5404
5431
  this.invokeQueue.push([$injectTokens.$provide, "provider", [name, providerType]]);
5405
5432
 
5406
5433
  return this;
@@ -5412,9 +5439,8 @@ class NgModule {
5412
5439
  * @returns {NgModule}
5413
5440
  */
5414
5441
  decorator(name, decorFn) {
5415
- if (decorFn && isFunction(decorFn)) {
5416
- decorFn.$$moduleName = name;
5417
- }
5442
+ validate(isString, name, "name");
5443
+ validateRequired(decorFn, "decorFn");
5418
5444
  this.configBlocks.push([$injectTokens.$provide, "decorator", [name, decorFn]]);
5419
5445
 
5420
5446
  return this;
@@ -5426,6 +5452,8 @@ class NgModule {
5426
5452
  * @returns {NgModule}
5427
5453
  */
5428
5454
  directive(name, directiveFactory) {
5455
+ validate(isString, name, "name");
5456
+ validateRequired(directiveFactory, "directiveFactory");
5429
5457
  this.invokeQueue.push([
5430
5458
  $injectTokens.$compileProvider,
5431
5459
  "directive",
@@ -5441,6 +5469,8 @@ class NgModule {
5441
5469
  * @returns {NgModule}
5442
5470
  */
5443
5471
  animation(name, animationFactory) {
5472
+ validate(isString, name, "name");
5473
+ validateRequired(animationFactory, "animationFactory");
5444
5474
  this.invokeQueue.push([
5445
5475
  $injectTokens.$animateProvider,
5446
5476
  "register",
@@ -5472,6 +5502,8 @@ class NgModule {
5472
5502
  * @returns {NgModule}
5473
5503
  */
5474
5504
  controller(name, ctlFn) {
5505
+ validate(isString, name, "name");
5506
+ validateRequired(ctlFn, `fictlFnlterFn`);
5475
5507
  this.invokeQueue.push([$injectTokens.$controllerProvider, "register", [name, ctlFn]]);
5476
5508
 
5477
5509
  return this;
@@ -5499,6 +5531,8 @@ class NgModule {
5499
5531
  * @returns {NgModule}
5500
5532
  */
5501
5533
  wasm(name, src, imports = {}, opts = {}) {
5534
+ validate(isString, name, "name");
5535
+ validate(isString, src, "src");
5502
5536
  const raw = !!opts.raw;
5503
5537
 
5504
5538
  this.invokeQueue.push([
@@ -5528,6 +5562,8 @@ class NgModule {
5528
5562
  * @returns {NgModule}
5529
5563
  */
5530
5564
  worker(name, scriptPath, config) {
5565
+ validate(isString, name, "name");
5566
+ validate(isString, scriptPath, "scriptPath");
5531
5567
  this.invokeQueue.push([
5532
5568
  $injectTokens.$provide,
5533
5569
  "provider",
@@ -5544,16 +5580,18 @@ class NgModule {
5544
5580
 
5545
5581
  /**
5546
5582
  * @param {string} name
5547
- * @param {Function} ctor
5583
+ * @param {Function|Object} ctor - A regular function, an arrow function or an object
5548
5584
  * @param {ng.StorageType} type
5549
5585
  * @param {ng.StorageBackend} [backendOrConfig]
5550
5586
  * @returns {NgModule}
5551
5587
  */
5552
5588
  store(name, ctor, type, backendOrConfig) {
5589
+ validate(isString, name, "name");
5590
+ validateRequired(ctor, "ctor");
5553
5591
  this.invokeQueue.push([
5554
5592
  $injectTokens.$provide,
5555
5593
  "store",
5556
- [name, ctor, type, backendOrConfig],
5594
+ [name, isObject(ctor) ? () => ctor : ctor, type, backendOrConfig],
5557
5595
  ]);
5558
5596
 
5559
5597
  return this;
@@ -5569,6 +5607,9 @@ class NgModule {
5569
5607
  * @returns {NgModule}
5570
5608
  */
5571
5609
  rest(name, url, entityClass, options = {}) {
5610
+ validate(isString, name, "name");
5611
+ validate(isString, url, "url");
5612
+ validate(isFunction, entityClass, "entityClass");
5572
5613
  const def = { name, url, entityClass, options };
5573
5614
 
5574
5615
  this.restDefinitions.push(def);
@@ -31774,357 +31815,179 @@ class PubSubProvider {
31774
31815
  this.eventBus = EventBus;
31775
31816
  }
31776
31817
 
31777
- /**
31778
- * @returns {PubSub}
31779
- */
31780
- $get = () => this.eventBus;
31781
- }
31782
-
31783
- class PubSub {
31784
- static $nonscope;
31785
- /**
31786
- * Topic-based publish/subscribe channel. Maintains a map of topics to
31787
- * subscriptions. When a message is published to a topic, all functions
31788
- * subscribed to that topic are invoked in the order they were added.
31789
- * Uncaught errors abort publishing.
31790
- *
31791
- * Topics may be identified by any nonempty string, <strong>except</strong>
31792
- * strings corresponding to native Object properties, e.g. "constructor",
31793
- * "toString", "hasOwnProperty", etc.
31794
- *
31795
- * @param {boolean=} async Enable asynchronous behavior. Recommended for
31796
- * new code. See notes on the publish() method.
31797
- */
31798
- constructor(async = false) {
31799
- this.disposed = false;
31800
-
31801
- /**
31802
- * The next available subscription key. Internally, this is an index into the
31803
- * sparse array of subscriptions.
31804
- *
31805
- * @private {number}
31806
- */
31807
- this.key = 1;
31808
-
31818
+ $get = [
31819
+ $injectTokens.$exceptionHandler,
31809
31820
  /**
31810
- * Array of subscription keys pending removal once publishing is done.
31811
- *
31812
- * @private {!Array<number>}
31813
- * @const
31821
+ * @param {ng.ExceptionHandlerService} $exceptionHandler
31822
+ * @returns {PubSub}
31814
31823
  */
31815
- this.pendingKeys = [];
31824
+ ($exceptionHandler) => {
31825
+ this.$exceptionHandler = $exceptionHandler;
31816
31826
 
31817
- /**
31818
- * Lock to prevent the removal of subscriptions during publishing. Incremented
31819
- * at the beginning of {@link #publish}, and decremented at the end.
31820
- *
31821
- * @private {number}
31822
- */
31823
- this.publishDepth = 0;
31827
+ return this.eventBus;
31828
+ },
31829
+ ];
31830
+ }
31824
31831
 
31825
- /**
31826
- * Sparse array of subscriptions. Each subscription is represented by a tuple
31827
- * comprising a topic identifier, a function, and an optional context object.
31828
- * Each tuple occupies three consecutive positions in the array, with the
31829
- * topic identifier at index n, the function at index (n + 1), the context
31830
- * object at index (n + 2), the next topic at index (n + 3), etc. (This
31831
- * representation minimizes the number of object allocations and has been
31832
- * shown to be faster than an array of objects with three key-value pairs or
31833
- * three parallel arrays, especially on IE.) Once a subscription is removed
31834
- * via {@link unsubscribe} or {@link unsubscribeByKey}, the three
31835
- * corresponding array elements are deleted, and never reused. This means the
31836
- * total number of subscriptions during the lifetime of the pubsub channel is
31837
- * limited by the maximum length of a JavaScript array to (2^32 - 1) / 3 =
31838
- * 1,431,655,765 subscriptions, which should suffice for most applications.
31839
- *
31840
- * @private {!Array<?>}
31841
- * @const
31842
- */
31843
- this.subscriptions = [];
31832
+ class PubSub {
31833
+ constructor() {
31834
+ /** @private {Object<string, Array<{fn: Function, context: any}>>} */
31835
+ this._topics = Object.create(null);
31844
31836
 
31845
- /**
31846
- * Map of topics to arrays of subscription keys.
31847
- *
31848
- * @private {!Object<!Array<number>>}
31849
- */
31850
- this.topics = {};
31837
+ /** @private */
31838
+ this._disposed = false;
31851
31839
 
31852
- /**
31853
- * @private @const {boolean}
31854
- */
31855
- this.async_ = Boolean(async);
31840
+ /** @type {ng.ExceptionHandlerService} */
31841
+ this.$exceptionHandler = undefined;
31856
31842
  }
31857
31843
 
31858
31844
  /**
31859
- * Subscribes a function to a topic. The function is invoked as a method on
31860
- * the given `opt_context` object, or in the global scope if no context
31861
- * is specified. Subscribing the same function to the same topic multiple
31862
- * times will result in multiple function invocations while publishing.
31863
- * Returns a subscription key that can be used to unsubscribe the function from
31864
- * the topic via {@link unsubscribeByKey}.
31865
- *
31866
- * @param {string} topic Topic to subscribe to.
31867
- * @param {Function} fn Function to be invoked when a message is published to
31868
- * the given topic.
31869
- * @param {Object=} opt_context Object in whose context the function is to be
31870
- * called (the global scope if none).
31871
- * @return {number} Subscription key.
31845
+ * Set instance to initial state
31872
31846
  */
31873
- subscribe(topic, fn, opt_context = null) {
31874
- let keys = this.topics[topic];
31847
+ reset() {
31848
+ /** @private {Object<string, Array<{fn: Function, context: any}>>} */
31849
+ this._topics = Object.create(null);
31875
31850
 
31876
- if (!keys) {
31877
- // First subscription to this topic; initialize subscription key array.
31878
- keys = this.topics[topic] = [];
31879
- }
31880
-
31881
- // Push the tuple representing the subscription onto the subscription array.
31882
- const { key } = this;
31883
-
31884
- this.subscriptions[key] = topic;
31885
- this.subscriptions[key + 1] = fn;
31886
- this.subscriptions[key + 2] = opt_context;
31887
- this.key = key + 3;
31888
-
31889
- // Push the subscription key onto the list of subscriptions for the topic.
31890
- keys.push(key);
31891
-
31892
- // Return the subscription key.
31893
- return key;
31851
+ /** @private */
31852
+ this._disposed = false;
31894
31853
  }
31895
31854
 
31896
31855
  /**
31897
- * Subscribes a single-use function to a topic. The function is invoked as a
31898
- * method on the given `opt_context` object, or in the global scope if
31899
- * no context is specified, and is then unsubscribed. Returns a subscription
31900
- * key that can be used to unsubscribe the function from the topic via
31901
- * {@link unsubscribeByKey}.
31902
- *
31903
- * @param {string} topic Topic to subscribe to.
31904
- * @param {Function} fn Function to be invoked once and then unsubscribed when
31905
- * a message is published to the given topic.
31906
- * @param {Object=} opt_context Object in whose context the function is to be
31907
- * called (the global scope if none).
31908
- * @return {number} Subscription key.
31856
+ * Checks if instance has been disposed.
31857
+ * @returns {boolean} True if disposed.
31909
31858
  */
31910
- subscribeOnce(topic, fn, opt_context = null) {
31911
- let called = false;
31912
-
31913
- // Behold the power of lexical closures!
31914
- const key = this.subscribe(
31915
- topic,
31916
- (...args) => {
31917
- if (!called) {
31918
- called = true;
31919
-
31920
- // Unsubscribe before calling function so the function is unsubscribed
31921
- // even if it throws an exception.
31922
- this.unsubscribeByKey(key);
31923
-
31924
- fn.apply(opt_context, args);
31925
- }
31926
- },
31927
- this,
31928
- );
31929
-
31930
- return key;
31859
+ isDisposed() {
31860
+ return this._disposed;
31931
31861
  }
31932
31862
 
31933
31863
  /**
31934
- * Runs a function asynchronously.
31935
- *
31936
- * @private
31937
- * @param {Function} fn Function to run.
31938
- * @param {Object} context Context in which to run the function.
31939
- * @param {Array} args Arguments to pass to the function.
31864
+ * Dispose the instance, removing all topics and listeners.
31940
31865
  */
31941
- static runAsync_(fn, context, args) {
31942
- queueMicrotask(() => {
31943
- fn.apply(context, args);
31944
- });
31866
+ dispose() {
31867
+ if (this._disposed) return;
31868
+ this._disposed = true;
31869
+ this._topics = Object.create(null);
31945
31870
  }
31946
31871
 
31947
31872
  /**
31948
- * Unsubscribes a function from a topic. Only deletes the first match found.
31949
- * Returns a Boolean indicating whether a subscription was removed.
31950
- *
31951
- * @param {string} topic Topic to unsubscribe from.
31952
- * @param {Function} fn Function to unsubscribe.
31953
- * @param {Object=} opt_context Object in whose context the function was to be
31954
- * called (the global scope if none).
31955
- * @return {boolean} Whether a matching subscription was removed.
31873
+ * Subscribe a function to a topic.
31874
+ * @param {string} topic - The topic to subscribe to.
31875
+ * @param {Function} fn - The callback function to invoke when published.
31876
+ * @param {*} [context] - Optional `this` context for the callback.
31877
+ * @returns {() => boolean} A function that unsubscribes this listener.
31956
31878
  */
31957
- unsubscribe(topic, fn, opt_context = null) {
31958
- const keys = this.topics[topic];
31879
+ subscribe(topic, fn, context = undefined) {
31880
+ if (this._disposed) return () => false;
31959
31881
 
31960
- if (keys) {
31961
- const { subscriptions } = this;
31882
+ /** @type {Array<{fn: Function, context: any}>} */
31883
+ let listeners = this._topics[topic];
31962
31884
 
31963
- const key = keys.find(
31964
- (k) =>
31965
- subscriptions[k + 1] === fn && subscriptions[k + 2] === opt_context,
31966
- );
31885
+ if (!listeners) this._topics[topic] = listeners = [];
31967
31886
 
31968
- if (key !== undefined) {
31969
- return this.unsubscribeByKey(key);
31970
- }
31971
- }
31887
+ const entry = { fn, context };
31972
31888
 
31973
- return false;
31889
+ listeners.push(entry);
31890
+
31891
+ return () => this.unsubscribe(topic, fn, context);
31974
31892
  }
31975
31893
 
31976
31894
  /**
31977
- * Removes a subscription based on the key returned by {@link subscribe}.
31978
- * No-op if no matching subscription is found. Returns a Boolean indicating
31979
- * whether a subscription was removed.
31980
- *
31981
- * @param {number} key Subscription key.
31982
- * @return {boolean} Whether a matching subscription was removed.
31895
+ * Subscribe a function to a topic only once.
31896
+ * Listener is removed before the first invocation.
31897
+ * @param {string} topic - The topic to subscribe to.
31898
+ * @param {Function} fn - The callback function.
31899
+ * @param {*} [context] - Optional `this` context for the callback.
31900
+ * @returns {() => boolean} A function that unsubscribes this listener.
31983
31901
  */
31984
- unsubscribeByKey(key) {
31985
- const topic = this.subscriptions[key];
31902
+ subscribeOnce(topic, fn, context = undefined) {
31903
+ if (this._disposed) return () => false;
31986
31904
 
31987
- if (topic) {
31988
- const keys = this.topics[topic];
31905
+ let called = false;
31989
31906
 
31990
- if (this.publishDepth !== 0) {
31991
- // Defer removal until after publishing is complete, but replace the
31992
- // function with a no-op so it isn't called.
31993
- this.pendingKeys.push(key);
31994
- this.subscriptions[key + 1] = () => {
31995
- /* empty */
31996
- };
31997
- } else {
31998
- if (keys) {
31999
- this.topics[topic] = keys.filter((k) => k !== key);
32000
- }
32001
- delete this.subscriptions[key];
32002
- delete this.subscriptions[key + 1];
32003
- delete this.subscriptions[key + 2];
32004
- }
32005
- }
31907
+ const wrapper = (...args) => {
31908
+ if (called) return;
31909
+ called = true;
31910
+
31911
+ unsub(); // unsubscribe before running
31912
+ fn.apply(context, args);
31913
+ };
32006
31914
 
32007
- return !!topic;
31915
+ const unsub = this.subscribe(topic, wrapper);
31916
+
31917
+ return unsub;
32008
31918
  }
32009
31919
 
32010
31920
  /**
32011
- * Publishes a message to a topic. Calls functions subscribed to the topic in
32012
- * the order in which they were added, passing all arguments along.
32013
- *
32014
- * If this object was created with async=true, subscribed functions are called
32015
- * via `queueMicrotask`. Otherwise, the functions are called directly, and if
32016
- * any of them throw an uncaught error, publishing is aborted.
32017
- *
32018
- * @param {string} topic Topic to publish to.
32019
- * @param {...*} var_args Arguments that are applied to each subscription
32020
- * function.
32021
- * @return {boolean} Whether any subscriptions were called.
31921
+ * Unsubscribe a specific function from a topic.
31922
+ * Matches by function reference and optional context.
31923
+ * @param {string} topic - The topic to unsubscribe from.
31924
+ * @param {Function} fn - The listener function.
31925
+ * @param {*} [context] - Optional `this` context.
31926
+ * @returns {boolean} True if the listener was found and removed.
32022
31927
  */
32023
- publish(topic, ...var_args) {
32024
- const keys = this.topics[topic];
31928
+ unsubscribe(topic, fn, context = undefined) {
31929
+ if (this._disposed) return false;
32025
31930
 
32026
- if (keys) {
32027
- const args = var_args;
31931
+ const listeners = this._topics[topic];
32028
31932
 
32029
- if (this.async_) {
32030
- // For each key in the list of subscription keys for the topic, schedule
32031
- // the function to be applied to the arguments in the appropriate context.
32032
- for (let i = 0; i < keys.length; i++) {
32033
- const key = keys[i];
31933
+ if (!listeners || listeners.length === 0) return false;
32034
31934
 
32035
- PubSub.runAsync_(
32036
- this.subscriptions[key + 1],
32037
- this.subscriptions[key + 2],
32038
- args,
32039
- );
32040
- }
32041
- } else {
32042
- this.publishDepth++;
32043
-
32044
- try {
32045
- for (
32046
- let i = 0, len = keys.length;
32047
- i < len && !this.isDisposed();
32048
- i++
32049
- ) {
32050
- const key = keys[i];
32051
-
32052
- this.subscriptions[key + 1].apply(
32053
- this.subscriptions[key + 2],
32054
- args,
32055
- );
32056
- }
32057
- } finally {
32058
- this.publishDepth--;
31935
+ for (let i = 0; i < listeners.length; i++) {
31936
+ const l = listeners[i];
32059
31937
 
32060
- if (this.pendingKeys.length > 0 && this.publishDepth === 0) {
32061
- let pendingKey;
31938
+ if (l.fn === fn && l.context === context) {
31939
+ listeners.splice(i, 1);
32062
31940
 
32063
- while ((pendingKey = this.pendingKeys.pop())) {
32064
- this.unsubscribeByKey(pendingKey);
32065
- }
32066
- }
32067
- }
31941
+ return true;
32068
31942
  }
32069
-
32070
- return true;
32071
31943
  }
32072
31944
 
32073
31945
  return false;
32074
31946
  }
32075
31947
 
32076
31948
  /**
32077
- * Clears the subscription list for a topic, or all topics if unspecified.
32078
- * @param {string=} opt_topic Topic to clear (all topics if unspecified).
31949
+ * Get the number of subscribers for a topic.
31950
+ * @param {string} topic
31951
+ * @returns {number}
32079
31952
  */
32080
- clear(opt_topic) {
32081
- if (opt_topic) {
32082
- const keys = this.topics[opt_topic];
31953
+ getCount(topic) {
31954
+ const listeners = this._topics[topic];
32083
31955
 
32084
- if (keys) {
32085
- keys.forEach(this.unsubscribeByKey, this);
32086
- delete this.topics[opt_topic];
32087
- }
32088
- } else {
32089
- this.subscriptions.length = 0;
32090
- this.topics = {};
32091
- }
31956
+ return listeners ? listeners.length : 0;
32092
31957
  }
32093
31958
 
32094
31959
  /**
32095
- * Returns the number of subscriptions to the given topic (or all topics if
32096
- * unspecified). This number will not change while publishing any messages.
32097
- * @param {string=} opt_topic The topic (all topics if unspecified).
32098
- * @return {number} Number of subscriptions to the topic.
31960
+ * Publish a value to a topic asynchronously.
31961
+ * All listeners are invoked in the order they were added.
31962
+ * @param {string} topic - The topic to publish.
31963
+ * @param {...*} args - Arguments to pass to listeners.
31964
+ * @returns {boolean} True if any listeners exist for this topic.
32099
31965
  */
32100
- getCount(opt_topic) {
32101
- if (opt_topic) {
32102
- const keys = this.topics[opt_topic];
31966
+ publish(topic, ...args) {
31967
+ if (this._disposed) return false;
32103
31968
 
32104
- return keys ? keys.length : 0;
32105
- }
31969
+ const listeners = this._topics[topic];
32106
31970
 
32107
- let count = 0;
31971
+ if (!listeners || listeners.length === 0) return false;
32108
31972
 
32109
- for (const topic in this.topics) {
32110
- count += this.getCount(topic);
32111
- }
32112
-
32113
- return count;
32114
- }
31973
+ // snapshot to prevent modifications during publish from affecting this call
31974
+ const snapshot = listeners.slice();
32115
31975
 
32116
- isDisposed() {
32117
- return this.disposed;
32118
- }
31976
+ queueMicrotask(() => {
31977
+ for (const { fn, context } of snapshot) {
31978
+ try {
31979
+ fn.apply(context, args);
31980
+ } catch (err) {
31981
+ this.$exceptionHandler(err);
31982
+ }
31983
+ }
31984
+ });
32119
31985
 
32120
- dispose() {
32121
- this.clear();
32122
- this.pendingKeys.length = 0;
32123
- this.disposed = true;
31986
+ return true;
32124
31987
  }
32125
31988
  }
32126
31989
 
32127
- const EventBus = new PubSub(true);
31990
+ const EventBus = new PubSub();
32128
31991
 
32129
31992
  const defaultOptions = {
32130
31993
  current: () => {
@@ -39160,7 +39023,7 @@ function ngChannelDirective($eventBus) {
39160
39023
 
39161
39024
  const hasTemplateContent = element.childNodes.length > 0;
39162
39025
 
39163
- const key = $eventBus.subscribe(channel, (value) => {
39026
+ const unsubscribe = $eventBus.subscribe(channel, (value) => {
39164
39027
  if (hasTemplateContent) {
39165
39028
  if (isObject(value)) {
39166
39029
  scope.$merge(value);
@@ -39170,9 +39033,7 @@ function ngChannelDirective($eventBus) {
39170
39033
  }
39171
39034
  });
39172
39035
 
39173
- scope.$on("$destroy", () => {
39174
- $eventBus.unsubscribeByKey(key);
39175
- });
39036
+ scope.$on("$destroy", () => unsubscribe());
39176
39037
  },
39177
39038
  };
39178
39039
  }
@@ -39567,8 +39428,6 @@ class CookieService {
39567
39428
  * @param {ng.ExceptionHandlerService} $exceptionHandler
39568
39429
  */
39569
39430
  constructor(defaults, $exceptionHandler) {
39570
- assert(isObject(defaults), BADARG);
39571
- assert(isFunction($exceptionHandler), BADARG);
39572
39431
  /** @type {ng.CookieOptions} */
39573
39432
  this.defaults = Object.freeze({ ...defaults });
39574
39433
  this.$exceptionHandler = $exceptionHandler;
@@ -39582,7 +39441,7 @@ class CookieService {
39582
39441
  * @throws {URIError} – If decodeURIComponent fails.
39583
39442
  */
39584
39443
  get(key) {
39585
- assert(isString(key), BADARG);
39444
+ validateIsString(key, "key");
39586
39445
 
39587
39446
  try {
39588
39447
  const all = parseCookies();
@@ -39602,7 +39461,8 @@ class CookieService {
39602
39461
  * @throws {SyntaxError} if cookie JSON is invalid
39603
39462
  */
39604
39463
  getObject(key) {
39605
- assert(isString(key), BADARG);
39464
+ validateIsString(key, "key");
39465
+
39606
39466
  const raw = this.get(key);
39607
39467
 
39608
39468
  if (!raw) return null;
@@ -39638,8 +39498,8 @@ class CookieService {
39638
39498
  * @param {ng.CookieOptions} [options]
39639
39499
  */
39640
39500
  put(key, value, options = {}) {
39641
- assert(isString(key), BADARGKEY);
39642
- assert(isString(value), BADARGVALUE);
39501
+ validateIsString(key, "key");
39502
+ validateIsString(value, "value");
39643
39503
  const encodedKey = encodeURIComponent(key);
39644
39504
 
39645
39505
  const encodedVal = encodeURIComponent(value);
@@ -39663,7 +39523,8 @@ class CookieService {
39663
39523
  * @throws {TypeError} if Object cannot be converted to JSON
39664
39524
  */
39665
39525
  putObject(key, value, options) {
39666
- assert(isString(key), BADARGKEY);
39526
+ validateIsString(key, "key");
39527
+ validateRequired(value, "value");
39667
39528
  assert(!isNullOrUndefined(value), BADARGVALUE);
39668
39529
 
39669
39530
  try {
@@ -39684,7 +39545,7 @@ class CookieService {
39684
39545
  * @param {ng.CookieOptions} [options]
39685
39546
  */
39686
39547
  remove(key, options = {}) {
39687
- assert(isString(key), BADARG);
39548
+ validateIsString(key, "key");
39688
39549
  this.put(key, "", {
39689
39550
  ...this.defaults,
39690
39551
  ...options,
@@ -40501,7 +40362,7 @@ class Angular {
40501
40362
  /**
40502
40363
  * @type {string} `version` from `package.json`
40503
40364
  */
40504
- this.version = "0.14.0"; //inserted via rollup plugin
40365
+ this.version = "0.14.2"; //inserted via rollup plugin
40505
40366
 
40506
40367
  /** @type {!Array<string|any>} */
40507
40368
  this.bootsrappedModules = [];