@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
@@ -150,7 +150,6 @@ export class Scope {
150
150
  $destroy: any;
151
151
  $eval: any;
152
152
  $apply: any;
153
- $evalAsync: any;
154
153
  $postUpdate: any;
155
154
  $isRoot: any;
156
155
  $target: any;
@@ -185,7 +184,6 @@ export class Scope {
185
184
  $newIsolate(instance: any): any;
186
185
  $transcluded(parentInstance: any): any;
187
186
  $eval(expr: any, locals: any): any;
188
- $evalAsync(expr: any, locals: any): Promise<any>;
189
187
  /**
190
188
  * @param {Object} newTarget
191
189
  */
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * @param {import('../../core/parse/interface.ts').ParseService} $parse
3
3
  * @param {import('../../services/log/interface.ts').LogService} $log
4
- * @returns {import('../../interface.ts').Directive}
4
+ * @returns {import('interface.ts').Directive}
5
5
  */
6
6
  export function ngSetterDirective(
7
7
  $parse: import("../../core/parse/interface.ts").ParseService,
8
8
  $log: import("../../services/log/interface.ts").LogService,
9
- ): import("../../interface.ts").Directive;
9
+ ): any;
10
10
  export namespace ngSetterDirective {
11
11
  let $inject: string[];
12
12
  }
@@ -525,6 +525,14 @@ export function isObjectEmpty(obj: any | null | undefined): boolean;
525
525
  * hasOwn({}, 'bar'); // false
526
526
  */
527
527
  export function hasOwn(obj: object, key: string | number | symbol): boolean;
528
+ /**
529
+ * Wraps a function so it can only be called once.
530
+ * Subsequent calls do nothing and return undefined.
531
+ *
532
+ * @param {Function} fn - The function to wrap.
533
+ * @returns {Function} A new function that will call `fn` only once.
534
+ */
535
+ export function callBackOnce(fn: Function): Function;
528
536
  export const isProxySymbol: unique symbol;
529
537
  export const ngAttrPrefixes: string[];
530
538
  /**
@@ -1,4 +1,4 @@
1
- /* Version: 0.7.5 - July 12, 2025 01:24:07 */
1
+ /* Version: 0.7.7 - July 13, 2025 16:59:18 */
2
2
  const VALID_CLASS = "ng-valid";
3
3
  const INVALID_CLASS = "ng-invalid";
4
4
  const PRISTINE_CLASS = "ng-pristine";
@@ -241,7 +241,7 @@ function isWindow(obj) {
241
241
  * @returns {boolean}
242
242
  */
243
243
  function isScope(obj) {
244
- return obj && obj.$evalAsync && obj.$watch;
244
+ return obj && obj.$watch;
245
245
  }
246
246
 
247
247
  /**
@@ -1130,6 +1130,24 @@ function hasOwn(obj, key) {
1130
1130
  return Object.prototype.hasOwnProperty.call(obj, key);
1131
1131
  }
1132
1132
 
1133
+ /**
1134
+ * Wraps a function so it can only be called once.
1135
+ * Subsequent calls do nothing and return undefined.
1136
+ *
1137
+ * @param {Function} fn - The function to wrap.
1138
+ * @returns {Function} A new function that will call `fn` only once.
1139
+ */
1140
+ function callBackOnce(fn) {
1141
+ let called = false;
1142
+
1143
+ return function (...args) {
1144
+ if (!called) {
1145
+ called = true;
1146
+ return fn.apply(this, args);
1147
+ }
1148
+ };
1149
+ }
1150
+
1133
1151
  /**
1134
1152
  * Expando cache for adding properties to DOM nodes with JavaScript.
1135
1153
  * This used to be an Object in JQLite decorator, but swapped out for a Map
@@ -3962,7 +3980,7 @@ function SceProvider() {
3962
3980
  */
3963
3981
  const ngEventDirectives = {};
3964
3982
 
3965
- "click copy cut dblclick focus blur keydown keyup keypress load mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup paste submit touchstart touchend touchmove"
3983
+ "click copy cut dblclick focus blur keydown keyup load mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup paste submit touchstart touchend touchmove"
3966
3984
  .split(" ")
3967
3985
  .forEach((eventName) => {
3968
3986
  const directiveName = directiveNormalize(`ng-${eventName}`);
@@ -11216,9 +11234,15 @@ function ngBindDirective() {
11216
11234
  * @param {import('../../core/compile/attributes.js').Attributes} attr
11217
11235
  */
11218
11236
  link(scope, element, attr) {
11219
- scope.$watch(attr["ngBind"], (value) => {
11220
- element.textContent = stringify$1(isProxy(value) ? value.$target : value);
11221
- });
11237
+ scope.$watch(
11238
+ attr["ngBind"],
11239
+ (value) => {
11240
+ element.textContent = stringify$1(
11241
+ isProxy(value) ? value.$target : value,
11242
+ );
11243
+ },
11244
+ isDefined(attr["lazy"]),
11245
+ );
11222
11246
  },
11223
11247
  };
11224
11248
  }
@@ -11945,7 +11969,7 @@ function ngRepeatDirective($animate) {
11945
11969
  transclude: "element",
11946
11970
  priority: 1000,
11947
11971
  terminal: true,
11948
- compile: (_$element, $attr) => {
11972
+ compile: ($element, $attr) => {
11949
11973
  const expression = $attr["ngRepeat"];
11950
11974
  const hasAnimate = !!$attr["animate"];
11951
11975
 
@@ -11991,6 +12015,14 @@ function ngRepeatDirective($animate) {
11991
12015
  );
11992
12016
  }
11993
12017
 
12018
+ const swap = callBackOnce(() => {
12019
+ if (isDefined($attr["lazy"]) && isDefined($attr["swap"])) {
12020
+ document
12021
+ .querySelectorAll($attr["swap"])
12022
+ .forEach((x) => removeElement(x));
12023
+ }
12024
+ });
12025
+
11994
12026
  return function ngRepeatLink($scope, $element, $attr, ctrl, $transclude) {
11995
12027
  // Store a list of elements from previous run. This is a hash where key is the item from the
11996
12028
  // iterator, and the value is objects with following properties.
@@ -12002,174 +12034,181 @@ function ngRepeatDirective($animate) {
12002
12034
  // hasOwnProperty.
12003
12035
  let lastBlockMap = Object.create(null);
12004
12036
  // watch props
12005
- $scope.$watch(rhs, (collection) => {
12006
- let index,
12007
- length,
12008
- previousNode = $element, // node that cloned nodes should be inserted after
12009
- // initialized to the comment node anchor
12010
- nextNode;
12011
- const // Same as lastBlockMap but it has the current state. It will become the
12012
- // lastBlockMap on the next iteration.
12013
- nextBlockMap = Object.create(null);
12014
- let collectionLength,
12015
- key,
12016
- value, // key/value of iteration
12017
- trackById,
12018
- trackByIdFn,
12019
- collectionKeys,
12020
- block, // last object information {scope, element, id}
12021
- nextBlockOrder,
12022
- elementsToRemove;
12023
-
12024
- if (aliasAs) {
12025
- $scope[aliasAs] = collection;
12026
- }
12027
-
12028
- if (isArrayLike(collection)) {
12029
- collectionKeys = collection;
12030
- trackByIdFn = trackByIdArrayFn;
12031
- } else {
12032
- trackByIdFn = trackByIdObjFn;
12033
- // if object, extract keys, in enumeration order, unsorted
12034
- collectionKeys = [];
12035
- for (const itemKey in collection) {
12036
- if (hasOwn(collection, itemKey) && itemKey.charAt(0) !== "$") {
12037
- collectionKeys.push(itemKey);
12038
- }
12037
+ $scope.$watch(
12038
+ rhs,
12039
+ (collection) => {
12040
+ swap();
12041
+ let index,
12042
+ length,
12043
+ previousNode = $element, // node that cloned nodes should be inserted after
12044
+ // initialized to the comment node anchor
12045
+ nextNode;
12046
+ const // Same as lastBlockMap but it has the current state. It will become the
12047
+ // lastBlockMap on the next iteration.
12048
+ nextBlockMap = Object.create(null);
12049
+ let collectionLength,
12050
+ key,
12051
+ value, // key/value of iteration
12052
+ trackById,
12053
+ trackByIdFn,
12054
+ collectionKeys,
12055
+ block, // last object information {scope, element, id}
12056
+ nextBlockOrder,
12057
+ elementsToRemove;
12058
+
12059
+ if (aliasAs) {
12060
+ $scope[aliasAs] = collection;
12039
12061
  }
12040
- }
12041
12062
 
12042
- collectionLength = collectionKeys.length;
12043
- nextBlockOrder = new Array(collectionLength);
12044
-
12045
- // locate existing items
12046
- for (index = 0; index < collectionLength; index++) {
12047
- key = collection === collectionKeys ? index : collectionKeys[index];
12048
- value = collection[key];
12049
- trackById = trackByIdFn($scope, key, value);
12050
- if (lastBlockMap[trackById]) {
12051
- // found previously seen block
12052
- block = lastBlockMap[trackById];
12053
- delete lastBlockMap[trackById];
12054
- nextBlockMap[trackById] = block;
12055
- nextBlockOrder[index] = block;
12056
- } else if (nextBlockMap[trackById]) {
12057
- // if collision detected. restore lastBlockMap and throw an error
12058
- Object.values(nextBlockOrder).forEach((block) => {
12059
- if (block && block.scope) lastBlockMap[block.id] = block;
12060
- });
12061
- throw ngRepeatMinErr(
12062
- "dupes",
12063
- "Duplicates keys in a repeater are not allowed. Repeater: {0}, Duplicate key: {1} for value: {2}",
12064
- expression,
12065
- trackById,
12066
- value,
12067
- );
12063
+ if (isArrayLike(collection)) {
12064
+ collectionKeys = collection;
12065
+ trackByIdFn = trackByIdArrayFn;
12068
12066
  } else {
12069
- // new never before seen block
12070
- nextBlockOrder[index] = {
12071
- id: trackById,
12072
- scope: undefined,
12073
- clone: undefined,
12074
- };
12075
- nextBlockMap[trackById] = true;
12067
+ trackByIdFn = trackByIdObjFn;
12068
+ // if object, extract keys, in enumeration order, unsorted
12069
+ collectionKeys = [];
12070
+ for (const itemKey in collection) {
12071
+ if (hasOwn(collection, itemKey) && itemKey.charAt(0) !== "$") {
12072
+ collectionKeys.push(itemKey);
12073
+ }
12074
+ }
12076
12075
  }
12077
- }
12078
12076
 
12079
- // remove leftover items
12080
- for (let blockKey in lastBlockMap) {
12081
- block = lastBlockMap[blockKey];
12082
- elementsToRemove = block.clone;
12083
- if (hasAnimate) {
12084
- $animate.leave(elementsToRemove);
12085
- } else {
12086
- elementsToRemove.remove();
12077
+ collectionLength = collectionKeys.length;
12078
+ nextBlockOrder = new Array(collectionLength);
12079
+
12080
+ // locate existing items
12081
+ for (index = 0; index < collectionLength; index++) {
12082
+ key =
12083
+ collection === collectionKeys ? index : collectionKeys[index];
12084
+ value = collection[key];
12085
+ trackById = trackByIdFn($scope, key, value);
12086
+ if (lastBlockMap[trackById]) {
12087
+ // found previously seen block
12088
+ block = lastBlockMap[trackById];
12089
+ delete lastBlockMap[trackById];
12090
+ nextBlockMap[trackById] = block;
12091
+ nextBlockOrder[index] = block;
12092
+ } else if (nextBlockMap[trackById]) {
12093
+ // if collision detected. restore lastBlockMap and throw an error
12094
+ Object.values(nextBlockOrder).forEach((block) => {
12095
+ if (block && block.scope) lastBlockMap[block.id] = block;
12096
+ });
12097
+ throw ngRepeatMinErr(
12098
+ "dupes",
12099
+ "Duplicates keys in a repeater are not allowed. Repeater: {0}, Duplicate key: {1} for value: {2}",
12100
+ expression,
12101
+ trackById,
12102
+ value,
12103
+ );
12104
+ } else {
12105
+ // new never before seen block
12106
+ nextBlockOrder[index] = {
12107
+ id: trackById,
12108
+ scope: undefined,
12109
+ clone: undefined,
12110
+ };
12111
+ nextBlockMap[trackById] = true;
12112
+ }
12087
12113
  }
12088
- if (elementsToRemove.parentNode) {
12089
- // if the element was not removed yet because of pending animation, mark it as deleted
12090
- // so that we can ignore it later
12091
- for (
12092
- index = 0, length = elementsToRemove.length;
12093
- index < length;
12094
- index++
12095
- ) {
12096
- elementsToRemove[index][NG_REMOVED] = true;
12114
+
12115
+ // remove leftover items
12116
+ for (let blockKey in lastBlockMap) {
12117
+ block = lastBlockMap[blockKey];
12118
+ elementsToRemove = block.clone;
12119
+ if (hasAnimate) {
12120
+ $animate.leave(elementsToRemove);
12121
+ } else {
12122
+ elementsToRemove.remove();
12097
12123
  }
12124
+ if (elementsToRemove.parentNode) {
12125
+ // if the element was not removed yet because of pending animation, mark it as deleted
12126
+ // so that we can ignore it later
12127
+ for (
12128
+ index = 0, length = elementsToRemove.length;
12129
+ index < length;
12130
+ index++
12131
+ ) {
12132
+ elementsToRemove[index][NG_REMOVED] = true;
12133
+ }
12134
+ }
12135
+ block.scope.$destroy();
12098
12136
  }
12099
- block.scope.$destroy();
12100
- }
12101
12137
 
12102
- for (index = 0; index < collectionLength; index++) {
12103
- key = collection === collectionKeys ? index : collectionKeys[index];
12104
- value = collection[key];
12105
- block = nextBlockOrder[index];
12138
+ for (index = 0; index < collectionLength; index++) {
12139
+ key =
12140
+ collection === collectionKeys ? index : collectionKeys[index];
12141
+ value = collection[key];
12142
+ block = nextBlockOrder[index];
12106
12143
 
12107
- if (block.scope) {
12108
- // if we have already seen this object, then we need to reuse the
12109
- // associated scope/element
12144
+ if (block.scope) {
12145
+ // if we have already seen this object, then we need to reuse the
12146
+ // associated scope/element
12110
12147
 
12111
- nextNode = previousNode;
12148
+ nextNode = previousNode;
12112
12149
 
12113
- // skip nodes that are already pending removal via leave animation
12114
- do {
12115
- nextNode = nextNode.nextSibling;
12116
- } while (nextNode && nextNode[NG_REMOVED]);
12150
+ // skip nodes that are already pending removal via leave animation
12151
+ do {
12152
+ nextNode = nextNode.nextSibling;
12153
+ } while (nextNode && nextNode[NG_REMOVED]);
12117
12154
 
12118
- if (getBlockStart(block) !== nextNode) {
12119
- // existing item which got moved
12120
- $animate.move(getBlockNodes(block.clone), null, previousNode);
12121
- }
12122
- previousNode = getBlockEnd(block);
12123
- updateScope(
12124
- block.scope,
12125
- index,
12126
- valueIdentifier,
12127
- value,
12128
- keyIdentifier,
12129
- key,
12130
- collectionLength,
12131
- );
12132
- } else {
12133
- // new item which we don't know about
12134
- $transclude(
12135
- /**
12136
- * Clone attach function
12137
- * @param {Array<NodeList>} clone
12138
- * @param {import("../../core/scope/scope.js").Scope} scope
12139
- */
12140
-
12141
- (clone, scope) => {
12142
- block.scope = scope;
12143
- const endNode = clone;
12144
- if (hasAnimate) {
12145
- $animate.enter(clone, null, previousNode);
12146
- } else {
12147
- // @ts-ignore
12148
- previousNode.after(clone);
12149
- }
12155
+ if (getBlockStart(block) !== nextNode) {
12156
+ // existing item which got moved
12157
+ $animate.move(getBlockNodes(block.clone), null, previousNode);
12158
+ }
12159
+ previousNode = getBlockEnd(block);
12160
+ updateScope(
12161
+ block.scope,
12162
+ index,
12163
+ valueIdentifier,
12164
+ value,
12165
+ keyIdentifier,
12166
+ key,
12167
+ collectionLength,
12168
+ );
12169
+ } else {
12170
+ // new item which we don't know about
12171
+ $transclude(
12172
+ /**
12173
+ * Clone attach function
12174
+ * @param {Array<NodeList>} clone
12175
+ * @param {import("../../core/scope/scope.js").Scope} scope
12176
+ */
12150
12177
 
12151
- // @ts-ignore
12152
- previousNode = endNode;
12153
- // Note: We only need the first/last node of the cloned nodes.
12154
- // However, we need to keep the reference to the dom wrapper as it might be changed later
12155
- // by a directive with templateUrl when its template arrives.
12156
- block.clone = clone;
12157
- nextBlockMap[block.id] = block;
12158
- updateScope(
12159
- block.scope,
12160
- index,
12161
- valueIdentifier,
12162
- value,
12163
- keyIdentifier,
12164
- key,
12165
- collectionLength,
12166
- );
12167
- },
12168
- );
12178
+ (clone, scope) => {
12179
+ block.scope = scope;
12180
+ const endNode = clone;
12181
+ if (hasAnimate) {
12182
+ $animate.enter(clone, null, previousNode);
12183
+ } else {
12184
+ // @ts-ignore
12185
+ previousNode.after(clone);
12186
+ }
12187
+
12188
+ // @ts-ignore
12189
+ previousNode = endNode;
12190
+ // Note: We only need the first/last node of the cloned nodes.
12191
+ // However, we need to keep the reference to the dom wrapper as it might be changed later
12192
+ // by a directive with templateUrl when its template arrives.
12193
+ block.clone = clone;
12194
+ nextBlockMap[block.id] = block;
12195
+ updateScope(
12196
+ block.scope,
12197
+ index,
12198
+ valueIdentifier,
12199
+ value,
12200
+ keyIdentifier,
12201
+ key,
12202
+ collectionLength,
12203
+ );
12204
+ },
12205
+ );
12206
+ }
12169
12207
  }
12170
- }
12171
- lastBlockMap = nextBlockMap;
12172
- });
12208
+ lastBlockMap = nextBlockMap;
12209
+ },
12210
+ isDefined($attr["lazy"]),
12211
+ );
12173
12212
  };
12174
12213
  },
12175
12214
  };
@@ -13553,7 +13592,7 @@ class AnchorScrollProvider {
13553
13592
  // skip the initial scroll if $location.hash is empty
13554
13593
  if (newVal === oldVal && newVal === "") return;
13555
13594
 
13556
- const action = () => $rootScope.$evalAsync(scroll);
13595
+ const action = () => Promise.resolve().then(scroll);
13557
13596
  if (document.readyState === "complete") {
13558
13597
  // Force the action to be run async for consistent behavior
13559
13598
  // from the action's point of view
@@ -19995,7 +20034,7 @@ class LocationProvider {
19995
20034
  return;
19996
20035
  }
19997
20036
 
19998
- $rootScope.$evalAsync(() => {
20037
+ Promise.resolve().then(() => {
19999
20038
  const oldUrl = $location.absUrl();
20000
20039
  const oldState = $location.$$state;
20001
20040
  let defaultPrevented;
@@ -20723,7 +20762,6 @@ class Scope {
20723
20762
  $destroy: this.$destroy.bind(this),
20724
20763
  $eval: this.$eval.bind(this),
20725
20764
  $apply: this.$apply.bind(this),
20726
- $evalAsync: this.$evalAsync.bind(this),
20727
20765
  $postUpdate: this.$postUpdate.bind(this),
20728
20766
  $isRoot: this.#isRoot.bind(this),
20729
20767
  $target: target,
@@ -21229,10 +21267,6 @@ class Scope {
21229
21267
  return res;
21230
21268
  }
21231
21269
 
21232
- async $evalAsync(expr, locals) {
21233
- return await this.$eval(expr, locals);
21234
- }
21235
-
21236
21270
  /**
21237
21271
  * @param {Object} newTarget
21238
21272
  */
@@ -21975,7 +22009,7 @@ class NgMessageCtrl {
21975
22009
  reRender() {
21976
22010
  if (!this.renderLater) {
21977
22011
  this.renderLater = true;
21978
- this.$scope.$evalAsync(() => {
22012
+ Promise.resolve().then(() => {
21979
22013
  if (this.renderLater && this.cachedCollection) {
21980
22014
  this.render(this.cachedCollection);
21981
22015
  }
@@ -35090,12 +35124,10 @@ function $StateRefActiveDirective(
35090
35124
  const removeClasses = allClasses.filter(
35091
35125
  (cls) => !addClasses.includes(cls),
35092
35126
  );
35093
- $scope.$evalAsync(() => {
35094
- addClasses.forEach((className) => $element.classList.add(className));
35095
- removeClasses.forEach((className) =>
35096
- $element.classList.remove(className),
35097
- );
35098
- });
35127
+ addClasses.forEach((className) => $element.classList.add(className));
35128
+ removeClasses.forEach((className) =>
35129
+ $element.classList.remove(className),
35130
+ );
35099
35131
  }
35100
35132
  update();
35101
35133
  },
@@ -35603,7 +35635,7 @@ ngSetterDirective.$inject = ["$parse", "$log"];
35603
35635
  /**
35604
35636
  * @param {import('../../core/parse/interface.ts').ParseService} $parse
35605
35637
  * @param {import('../../services/log/interface.ts').LogService} $log
35606
- * @returns {import('../../interface.ts').Directive}
35638
+ * @returns {import('interface.ts').Directive}
35607
35639
  */
35608
35640
  function ngSetterDirective($parse, $log) {
35609
35641
  return {
@@ -36088,7 +36120,7 @@ class Angular {
36088
36120
  /**
36089
36121
  * @type {string} `version` from `package.json`
36090
36122
  */
36091
- this.version = "0.7.5"; //inserted via rollup plugin
36123
+ this.version = "0.7.7"; //inserted via rollup plugin
36092
36124
 
36093
36125
  /** @type {!Array<string|any>} */
36094
36126
  this.bootsrappedModules = [];