@angular-wave/angular.ts 0.7.5 → 0.7.7

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 (33) hide show
  1. package/@types/core/scope/scope.d.ts +0 -2
  2. package/@types/directive/setter/setter.d.ts +2 -2
  3. package/@types/shared/utils.d.ts +8 -0
  4. package/dist/angular-ts.esm.js +208 -176
  5. package/dist/angular-ts.umd.js +208 -176
  6. package/dist/angular-ts.umd.min.js +1 -1
  7. package/docs/assets/scss/index.scss +12 -0
  8. package/docs/content/_index.md +15 -4
  9. package/docs/content/docs/directive/bind.md +70 -0
  10. package/docs/content/docs/directive/click.md +3 -0
  11. package/docs/content/docs/directive/dblclick.md +3 -0
  12. package/docs/content/docs/directive/keydown.md +38 -0
  13. package/docs/content/docs/directive/keyup.md +38 -0
  14. package/docs/content/docs/directive/load.md +43 -0
  15. package/docs/static/examples/ng-bind/ng-bind.html +9 -0
  16. package/docs/static/examples/ng-keydown/ng-keydown.html +9 -0
  17. package/docs/static/examples/ng-keyup/ng-keyup.html +9 -0
  18. package/docs/static/examples/ng-load/ng-load.html +8 -0
  19. package/legacy.d.ts +0 -4
  20. package/package.json +1 -1
  21. package/src/core/location/location.js +1 -1
  22. package/src/core/scope/scope.js +0 -5
  23. package/src/directive/bind/bind.js +16 -4
  24. package/src/directive/bind/bind.spec.js +13 -0
  25. package/src/directive/events/events.js +1 -1
  26. package/src/directive/events/events.md +0 -41
  27. package/src/directive/messages/messages.js +1 -1
  28. package/src/directive/repeat/repeat.js +175 -153
  29. package/src/directive/setter/setter.js +1 -1
  30. package/src/directive/switch/switch.spec.js +1 -1
  31. package/src/router/directives/state-directives.js +4 -6
  32. package/src/services/anchor-scroll.js +1 -1
  33. package/src/shared/utils.js +19 -1
@@ -1,4 +1,4 @@
1
- /* Version: 0.7.5 - July 12, 2025 01:24:05 */
1
+ /* Version: 0.7.7 - July 13, 2025 16:59:16 */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
4
4
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
@@ -247,7 +247,7 @@
247
247
  * @returns {boolean}
248
248
  */
249
249
  function isScope(obj) {
250
- return obj && obj.$evalAsync && obj.$watch;
250
+ return obj && obj.$watch;
251
251
  }
252
252
 
253
253
  /**
@@ -1136,6 +1136,24 @@
1136
1136
  return Object.prototype.hasOwnProperty.call(obj, key);
1137
1137
  }
1138
1138
 
1139
+ /**
1140
+ * Wraps a function so it can only be called once.
1141
+ * Subsequent calls do nothing and return undefined.
1142
+ *
1143
+ * @param {Function} fn - The function to wrap.
1144
+ * @returns {Function} A new function that will call `fn` only once.
1145
+ */
1146
+ function callBackOnce(fn) {
1147
+ let called = false;
1148
+
1149
+ return function (...args) {
1150
+ if (!called) {
1151
+ called = true;
1152
+ return fn.apply(this, args);
1153
+ }
1154
+ };
1155
+ }
1156
+
1139
1157
  /**
1140
1158
  * Expando cache for adding properties to DOM nodes with JavaScript.
1141
1159
  * This used to be an Object in JQLite decorator, but swapped out for a Map
@@ -3968,7 +3986,7 @@
3968
3986
  */
3969
3987
  const ngEventDirectives = {};
3970
3988
 
3971
- "click copy cut dblclick focus blur keydown keyup keypress load mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup paste submit touchstart touchend touchmove"
3989
+ "click copy cut dblclick focus blur keydown keyup load mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup paste submit touchstart touchend touchmove"
3972
3990
  .split(" ")
3973
3991
  .forEach((eventName) => {
3974
3992
  const directiveName = directiveNormalize(`ng-${eventName}`);
@@ -11222,9 +11240,15 @@
11222
11240
  * @param {import('../../core/compile/attributes.js').Attributes} attr
11223
11241
  */
11224
11242
  link(scope, element, attr) {
11225
- scope.$watch(attr["ngBind"], (value) => {
11226
- element.textContent = stringify$1(isProxy(value) ? value.$target : value);
11227
- });
11243
+ scope.$watch(
11244
+ attr["ngBind"],
11245
+ (value) => {
11246
+ element.textContent = stringify$1(
11247
+ isProxy(value) ? value.$target : value,
11248
+ );
11249
+ },
11250
+ isDefined(attr["lazy"]),
11251
+ );
11228
11252
  },
11229
11253
  };
11230
11254
  }
@@ -11951,7 +11975,7 @@
11951
11975
  transclude: "element",
11952
11976
  priority: 1000,
11953
11977
  terminal: true,
11954
- compile: (_$element, $attr) => {
11978
+ compile: ($element, $attr) => {
11955
11979
  const expression = $attr["ngRepeat"];
11956
11980
  const hasAnimate = !!$attr["animate"];
11957
11981
 
@@ -11997,6 +12021,14 @@
11997
12021
  );
11998
12022
  }
11999
12023
 
12024
+ const swap = callBackOnce(() => {
12025
+ if (isDefined($attr["lazy"]) && isDefined($attr["swap"])) {
12026
+ document
12027
+ .querySelectorAll($attr["swap"])
12028
+ .forEach((x) => removeElement(x));
12029
+ }
12030
+ });
12031
+
12000
12032
  return function ngRepeatLink($scope, $element, $attr, ctrl, $transclude) {
12001
12033
  // Store a list of elements from previous run. This is a hash where key is the item from the
12002
12034
  // iterator, and the value is objects with following properties.
@@ -12008,174 +12040,181 @@
12008
12040
  // hasOwnProperty.
12009
12041
  let lastBlockMap = Object.create(null);
12010
12042
  // watch props
12011
- $scope.$watch(rhs, (collection) => {
12012
- let index,
12013
- length,
12014
- previousNode = $element, // node that cloned nodes should be inserted after
12015
- // initialized to the comment node anchor
12016
- nextNode;
12017
- const // Same as lastBlockMap but it has the current state. It will become the
12018
- // lastBlockMap on the next iteration.
12019
- nextBlockMap = Object.create(null);
12020
- let collectionLength,
12021
- key,
12022
- value, // key/value of iteration
12023
- trackById,
12024
- trackByIdFn,
12025
- collectionKeys,
12026
- block, // last object information {scope, element, id}
12027
- nextBlockOrder,
12028
- elementsToRemove;
12029
-
12030
- if (aliasAs) {
12031
- $scope[aliasAs] = collection;
12032
- }
12033
-
12034
- if (isArrayLike(collection)) {
12035
- collectionKeys = collection;
12036
- trackByIdFn = trackByIdArrayFn;
12037
- } else {
12038
- trackByIdFn = trackByIdObjFn;
12039
- // if object, extract keys, in enumeration order, unsorted
12040
- collectionKeys = [];
12041
- for (const itemKey in collection) {
12042
- if (hasOwn(collection, itemKey) && itemKey.charAt(0) !== "$") {
12043
- collectionKeys.push(itemKey);
12044
- }
12043
+ $scope.$watch(
12044
+ rhs,
12045
+ (collection) => {
12046
+ swap();
12047
+ let index,
12048
+ length,
12049
+ previousNode = $element, // node that cloned nodes should be inserted after
12050
+ // initialized to the comment node anchor
12051
+ nextNode;
12052
+ const // Same as lastBlockMap but it has the current state. It will become the
12053
+ // lastBlockMap on the next iteration.
12054
+ nextBlockMap = Object.create(null);
12055
+ let collectionLength,
12056
+ key,
12057
+ value, // key/value of iteration
12058
+ trackById,
12059
+ trackByIdFn,
12060
+ collectionKeys,
12061
+ block, // last object information {scope, element, id}
12062
+ nextBlockOrder,
12063
+ elementsToRemove;
12064
+
12065
+ if (aliasAs) {
12066
+ $scope[aliasAs] = collection;
12045
12067
  }
12046
- }
12047
12068
 
12048
- collectionLength = collectionKeys.length;
12049
- nextBlockOrder = new Array(collectionLength);
12050
-
12051
- // locate existing items
12052
- for (index = 0; index < collectionLength; index++) {
12053
- key = collection === collectionKeys ? index : collectionKeys[index];
12054
- value = collection[key];
12055
- trackById = trackByIdFn($scope, key, value);
12056
- if (lastBlockMap[trackById]) {
12057
- // found previously seen block
12058
- block = lastBlockMap[trackById];
12059
- delete lastBlockMap[trackById];
12060
- nextBlockMap[trackById] = block;
12061
- nextBlockOrder[index] = block;
12062
- } else if (nextBlockMap[trackById]) {
12063
- // if collision detected. restore lastBlockMap and throw an error
12064
- Object.values(nextBlockOrder).forEach((block) => {
12065
- if (block && block.scope) lastBlockMap[block.id] = block;
12066
- });
12067
- throw ngRepeatMinErr(
12068
- "dupes",
12069
- "Duplicates keys in a repeater are not allowed. Repeater: {0}, Duplicate key: {1} for value: {2}",
12070
- expression,
12071
- trackById,
12072
- value,
12073
- );
12069
+ if (isArrayLike(collection)) {
12070
+ collectionKeys = collection;
12071
+ trackByIdFn = trackByIdArrayFn;
12074
12072
  } else {
12075
- // new never before seen block
12076
- nextBlockOrder[index] = {
12077
- id: trackById,
12078
- scope: undefined,
12079
- clone: undefined,
12080
- };
12081
- nextBlockMap[trackById] = true;
12073
+ trackByIdFn = trackByIdObjFn;
12074
+ // if object, extract keys, in enumeration order, unsorted
12075
+ collectionKeys = [];
12076
+ for (const itemKey in collection) {
12077
+ if (hasOwn(collection, itemKey) && itemKey.charAt(0) !== "$") {
12078
+ collectionKeys.push(itemKey);
12079
+ }
12080
+ }
12082
12081
  }
12083
- }
12084
12082
 
12085
- // remove leftover items
12086
- for (let blockKey in lastBlockMap) {
12087
- block = lastBlockMap[blockKey];
12088
- elementsToRemove = block.clone;
12089
- if (hasAnimate) {
12090
- $animate.leave(elementsToRemove);
12091
- } else {
12092
- elementsToRemove.remove();
12083
+ collectionLength = collectionKeys.length;
12084
+ nextBlockOrder = new Array(collectionLength);
12085
+
12086
+ // locate existing items
12087
+ for (index = 0; index < collectionLength; index++) {
12088
+ key =
12089
+ collection === collectionKeys ? index : collectionKeys[index];
12090
+ value = collection[key];
12091
+ trackById = trackByIdFn($scope, key, value);
12092
+ if (lastBlockMap[trackById]) {
12093
+ // found previously seen block
12094
+ block = lastBlockMap[trackById];
12095
+ delete lastBlockMap[trackById];
12096
+ nextBlockMap[trackById] = block;
12097
+ nextBlockOrder[index] = block;
12098
+ } else if (nextBlockMap[trackById]) {
12099
+ // if collision detected. restore lastBlockMap and throw an error
12100
+ Object.values(nextBlockOrder).forEach((block) => {
12101
+ if (block && block.scope) lastBlockMap[block.id] = block;
12102
+ });
12103
+ throw ngRepeatMinErr(
12104
+ "dupes",
12105
+ "Duplicates keys in a repeater are not allowed. Repeater: {0}, Duplicate key: {1} for value: {2}",
12106
+ expression,
12107
+ trackById,
12108
+ value,
12109
+ );
12110
+ } else {
12111
+ // new never before seen block
12112
+ nextBlockOrder[index] = {
12113
+ id: trackById,
12114
+ scope: undefined,
12115
+ clone: undefined,
12116
+ };
12117
+ nextBlockMap[trackById] = true;
12118
+ }
12093
12119
  }
12094
- if (elementsToRemove.parentNode) {
12095
- // if the element was not removed yet because of pending animation, mark it as deleted
12096
- // so that we can ignore it later
12097
- for (
12098
- index = 0, length = elementsToRemove.length;
12099
- index < length;
12100
- index++
12101
- ) {
12102
- elementsToRemove[index][NG_REMOVED] = true;
12120
+
12121
+ // remove leftover items
12122
+ for (let blockKey in lastBlockMap) {
12123
+ block = lastBlockMap[blockKey];
12124
+ elementsToRemove = block.clone;
12125
+ if (hasAnimate) {
12126
+ $animate.leave(elementsToRemove);
12127
+ } else {
12128
+ elementsToRemove.remove();
12103
12129
  }
12130
+ if (elementsToRemove.parentNode) {
12131
+ // if the element was not removed yet because of pending animation, mark it as deleted
12132
+ // so that we can ignore it later
12133
+ for (
12134
+ index = 0, length = elementsToRemove.length;
12135
+ index < length;
12136
+ index++
12137
+ ) {
12138
+ elementsToRemove[index][NG_REMOVED] = true;
12139
+ }
12140
+ }
12141
+ block.scope.$destroy();
12104
12142
  }
12105
- block.scope.$destroy();
12106
- }
12107
12143
 
12108
- for (index = 0; index < collectionLength; index++) {
12109
- key = collection === collectionKeys ? index : collectionKeys[index];
12110
- value = collection[key];
12111
- block = nextBlockOrder[index];
12144
+ for (index = 0; index < collectionLength; index++) {
12145
+ key =
12146
+ collection === collectionKeys ? index : collectionKeys[index];
12147
+ value = collection[key];
12148
+ block = nextBlockOrder[index];
12112
12149
 
12113
- if (block.scope) {
12114
- // if we have already seen this object, then we need to reuse the
12115
- // associated scope/element
12150
+ if (block.scope) {
12151
+ // if we have already seen this object, then we need to reuse the
12152
+ // associated scope/element
12116
12153
 
12117
- nextNode = previousNode;
12154
+ nextNode = previousNode;
12118
12155
 
12119
- // skip nodes that are already pending removal via leave animation
12120
- do {
12121
- nextNode = nextNode.nextSibling;
12122
- } while (nextNode && nextNode[NG_REMOVED]);
12156
+ // skip nodes that are already pending removal via leave animation
12157
+ do {
12158
+ nextNode = nextNode.nextSibling;
12159
+ } while (nextNode && nextNode[NG_REMOVED]);
12123
12160
 
12124
- if (getBlockStart(block) !== nextNode) {
12125
- // existing item which got moved
12126
- $animate.move(getBlockNodes(block.clone), null, previousNode);
12127
- }
12128
- previousNode = getBlockEnd(block);
12129
- updateScope(
12130
- block.scope,
12131
- index,
12132
- valueIdentifier,
12133
- value,
12134
- keyIdentifier,
12135
- key,
12136
- collectionLength,
12137
- );
12138
- } else {
12139
- // new item which we don't know about
12140
- $transclude(
12141
- /**
12142
- * Clone attach function
12143
- * @param {Array<NodeList>} clone
12144
- * @param {import("../../core/scope/scope.js").Scope} scope
12145
- */
12146
-
12147
- (clone, scope) => {
12148
- block.scope = scope;
12149
- const endNode = clone;
12150
- if (hasAnimate) {
12151
- $animate.enter(clone, null, previousNode);
12152
- } else {
12153
- // @ts-ignore
12154
- previousNode.after(clone);
12155
- }
12161
+ if (getBlockStart(block) !== nextNode) {
12162
+ // existing item which got moved
12163
+ $animate.move(getBlockNodes(block.clone), null, previousNode);
12164
+ }
12165
+ previousNode = getBlockEnd(block);
12166
+ updateScope(
12167
+ block.scope,
12168
+ index,
12169
+ valueIdentifier,
12170
+ value,
12171
+ keyIdentifier,
12172
+ key,
12173
+ collectionLength,
12174
+ );
12175
+ } else {
12176
+ // new item which we don't know about
12177
+ $transclude(
12178
+ /**
12179
+ * Clone attach function
12180
+ * @param {Array<NodeList>} clone
12181
+ * @param {import("../../core/scope/scope.js").Scope} scope
12182
+ */
12156
12183
 
12157
- // @ts-ignore
12158
- previousNode = endNode;
12159
- // Note: We only need the first/last node of the cloned nodes.
12160
- // However, we need to keep the reference to the dom wrapper as it might be changed later
12161
- // by a directive with templateUrl when its template arrives.
12162
- block.clone = clone;
12163
- nextBlockMap[block.id] = block;
12164
- updateScope(
12165
- block.scope,
12166
- index,
12167
- valueIdentifier,
12168
- value,
12169
- keyIdentifier,
12170
- key,
12171
- collectionLength,
12172
- );
12173
- },
12174
- );
12184
+ (clone, scope) => {
12185
+ block.scope = scope;
12186
+ const endNode = clone;
12187
+ if (hasAnimate) {
12188
+ $animate.enter(clone, null, previousNode);
12189
+ } else {
12190
+ // @ts-ignore
12191
+ previousNode.after(clone);
12192
+ }
12193
+
12194
+ // @ts-ignore
12195
+ previousNode = endNode;
12196
+ // Note: We only need the first/last node of the cloned nodes.
12197
+ // However, we need to keep the reference to the dom wrapper as it might be changed later
12198
+ // by a directive with templateUrl when its template arrives.
12199
+ block.clone = clone;
12200
+ nextBlockMap[block.id] = block;
12201
+ updateScope(
12202
+ block.scope,
12203
+ index,
12204
+ valueIdentifier,
12205
+ value,
12206
+ keyIdentifier,
12207
+ key,
12208
+ collectionLength,
12209
+ );
12210
+ },
12211
+ );
12212
+ }
12175
12213
  }
12176
- }
12177
- lastBlockMap = nextBlockMap;
12178
- });
12214
+ lastBlockMap = nextBlockMap;
12215
+ },
12216
+ isDefined($attr["lazy"]),
12217
+ );
12179
12218
  };
12180
12219
  },
12181
12220
  };
@@ -13559,7 +13598,7 @@
13559
13598
  // skip the initial scroll if $location.hash is empty
13560
13599
  if (newVal === oldVal && newVal === "") return;
13561
13600
 
13562
- const action = () => $rootScope.$evalAsync(scroll);
13601
+ const action = () => Promise.resolve().then(scroll);
13563
13602
  if (document.readyState === "complete") {
13564
13603
  // Force the action to be run async for consistent behavior
13565
13604
  // from the action's point of view
@@ -20001,7 +20040,7 @@
20001
20040
  return;
20002
20041
  }
20003
20042
 
20004
- $rootScope.$evalAsync(() => {
20043
+ Promise.resolve().then(() => {
20005
20044
  const oldUrl = $location.absUrl();
20006
20045
  const oldState = $location.$$state;
20007
20046
  let defaultPrevented;
@@ -20729,7 +20768,6 @@
20729
20768
  $destroy: this.$destroy.bind(this),
20730
20769
  $eval: this.$eval.bind(this),
20731
20770
  $apply: this.$apply.bind(this),
20732
- $evalAsync: this.$evalAsync.bind(this),
20733
20771
  $postUpdate: this.$postUpdate.bind(this),
20734
20772
  $isRoot: this.#isRoot.bind(this),
20735
20773
  $target: target,
@@ -21235,10 +21273,6 @@
21235
21273
  return res;
21236
21274
  }
21237
21275
 
21238
- async $evalAsync(expr, locals) {
21239
- return await this.$eval(expr, locals);
21240
- }
21241
-
21242
21276
  /**
21243
21277
  * @param {Object} newTarget
21244
21278
  */
@@ -21981,7 +22015,7 @@
21981
22015
  reRender() {
21982
22016
  if (!this.renderLater) {
21983
22017
  this.renderLater = true;
21984
- this.$scope.$evalAsync(() => {
22018
+ Promise.resolve().then(() => {
21985
22019
  if (this.renderLater && this.cachedCollection) {
21986
22020
  this.render(this.cachedCollection);
21987
22021
  }
@@ -35096,12 +35130,10 @@
35096
35130
  const removeClasses = allClasses.filter(
35097
35131
  (cls) => !addClasses.includes(cls),
35098
35132
  );
35099
- $scope.$evalAsync(() => {
35100
- addClasses.forEach((className) => $element.classList.add(className));
35101
- removeClasses.forEach((className) =>
35102
- $element.classList.remove(className),
35103
- );
35104
- });
35133
+ addClasses.forEach((className) => $element.classList.add(className));
35134
+ removeClasses.forEach((className) =>
35135
+ $element.classList.remove(className),
35136
+ );
35105
35137
  }
35106
35138
  update();
35107
35139
  },
@@ -35609,7 +35641,7 @@
35609
35641
  /**
35610
35642
  * @param {import('../../core/parse/interface.ts').ParseService} $parse
35611
35643
  * @param {import('../../services/log/interface.ts').LogService} $log
35612
- * @returns {import('../../interface.ts').Directive}
35644
+ * @returns {import('interface.ts').Directive}
35613
35645
  */
35614
35646
  function ngSetterDirective($parse, $log) {
35615
35647
  return {
@@ -36094,7 +36126,7 @@
36094
36126
  /**
36095
36127
  * @type {string} `version` from `package.json`
36096
36128
  */
36097
- this.version = "0.7.5"; //inserted via rollup plugin
36129
+ this.version = "0.7.7"; //inserted via rollup plugin
36098
36130
 
36099
36131
  /** @type {!Array<string|any>} */
36100
36132
  this.bootsrappedModules = [];