targetj 1.0.153 → 1.0.155

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 CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Stars](https://img.shields.io/github/stars/livetrails/targetjs.svg)](https://github.com/livetrails/targetjs/stargazers)
6
6
  [![npm version](https://img.shields.io/npm/v/targetj.svg)](https://www.npmjs.com/package/targetj)
7
7
 
8
- TargetJS is a modern JavaScript UI framework designed to simplify front-end development by introducing a unique paradigm centered around Targets, which function as **enhanced variables and methods** with **lifecycles**. This approach provides a unified solution for UI rendering, animations, API interactions, state management, and event handling, leading to more compact code and a stronger focus on user experience. TargetJS is also a highly performant web framework, as shown in the [framework benchmark](https://krausest.github.io/js-framework-benchmark/current.html).
8
+ TargetJS is a modern JavaScript UI framework designed to simplify front-end development by introducing a unique paradigm based on literal objects and extending their properties and methods with lifecycles and functional pipelines. The framework provides a unified solution for UI rendering, animations, API interactions, state management, and event handling, leading to more compact code and a stronger focus on user experience. TargetJS is also a highly performant web framework, as shown in the [framework benchmark](https://krausest.github.io/js-framework-benchmark/current.html).
9
9
  ## What Problems Does TargetJS Solve?
10
10
 
11
11
  TargetJS addresses several common pain points in front-end development:
@@ -55,7 +55,7 @@ npm install targetj
55
55
 
56
56
  ## Key Features and Concepts
57
57
 
58
- * **Targets:** The fundamental building blocks of TargetJS. Targets provide a unified interface for variables and methods with built-in lifecycles. They can:
58
+ * **Targets:** The fundamental building blocks of TargetJS. Targets provide a unified interface for properties and methods with built-in lifecycles. They can:
59
59
  * Iterate towards values (useful for animations and transitions).
60
60
  * Execute conditionally.
61
61
  * Manage repeated executions.
@@ -70,7 +70,7 @@ npm install targetj
70
70
 
71
71
  * **Unique computational paradigm:** TargetJS introduces a novel computational model by integrating multiple paradigms: Turing Completeness, the Von Neumann Execution Model, and Functional Programming. This results in:
72
72
 
73
- * Deterministic Execution Flow: Targets execute based on their activation order, initially following their order in the code. They run in sequence as part of the task processing cycle. Everything in TargetJS is synchronous, and targets cannot be called directly.
73
+ * Deterministic Execution Flow: Targets execute based on their activation order, initially following their order in the code. They run in sequence as part of the framework execution cycle. Everything in TargetJS is synchronous, and targets cannot be called directly.
74
74
  * Powerful Functional Pipeline: Targets can be structured as a functional pipeline with enhanced capabilities.
75
75
 
76
76
  * **Easy Integration:** Can be used as a library within existing projects.
@@ -83,7 +83,7 @@ npm install targetj
83
83
  - Targets run initially in the order they appear in the code, so `background` runs first, followed by `width`. The `_` prefix indicates that a target is inactive by default, meaning `height` does not run initially.
84
84
  - `background` sets the background to purple, and its lifecycle ends.
85
85
  - `width` animates from 100 → 250 → 100px, in 50 steps with 10ms pauses.
86
- - `height` follows `width` and scales dynamically with its value. The `$` postfix means it is activated each time the proceding target executes. `prevTargetValue` refers to the previous target's value, which in this case is `width`.
86
+ - `height` follows `width` and scales dynamically with its value. The `$` postfix means it is activated each time the preceding target executes. `prevTargetValue` refers to the previous target's value, which in this case is `width`.
87
87
 
88
88
  ![first example](https://targetjs.io/img/quick1_3.gif)
89
89
 
@@ -154,9 +154,9 @@ App({
154
154
 
155
155
  | Feature | TargetJS | Reactive Model Frameworks |
156
156
  |--------------------------------------|-----------------------------------------------------------------|------------------------------------------------------|
157
- | **Component Basic Structure** | Components consist of Targets, providing a unified interface for methods and variables. | Components consist of methods and variables.
158
- | **Execution Order** | Components consist of Targets, providing a unified interface for methods and variables. | Primarily data-driven, less predictable. |
159
- | **Function Calls** | Targets cannot be called directly. Execution is part of a task cycle. | Functions execute reactively or are called imperatively. |
157
+ | **Component Basic Structure** | Components consist of Targets, providing a unified interface for methods and properties. | Components consist of methods and variables.
158
+ | **Execution Order** | Targets are executed based on their activation order, which initially follows their appearance in the code. They run in a sequential and predictable manner | Primarily data-driven, less predictable. |
159
+ | **Function Calls** | Targets cannot be called directly. Execution is part of a framework execution cycle. | Functions execute reactively or are called imperatively. |
160
160
  | **Autonomous Execution** | Targets can self-activate and operate autonomously. | Functions do not execute autonomously. |
161
161
  | **Execution Pipeline** | Targets can form controlled pipelines; a target can activate when the preceding target executes or completes. | Functions are called whenever dependencies update. Execution order is not based on code appearance. |
162
162
  | **Event Handling** | Primarily by activating Targets, making event handling consistent with the core execution model. | Events are handled through event listeners, subscriptions, or reactive bindings. |
@@ -177,7 +177,7 @@ TargetJS leverages ES2015's guaranteed property order to ensure that target exec
177
177
  ## Anatomy of a Target
178
178
 
179
179
  Each target consists of the following:
180
- 1. Target Value and Actual Value. The target value refers to the value assigned to a variable or the output produced by the `value()` method associated with the target defined in your program. The actual value is the value used by the rest of the application. When the target value differs from the actual value, TargetJS iteratively updates the actual value until it matches the target value. This process is managed by two additional variables: `step`, which dictates the number of iterations, and `interval`, which specifies the duration (in milliseconds) the system waits before executing the next iteration.
180
+ 1. Target Value and Actual Value. The target value refers to the value assigned to a property or the output produced by the `value()` method associated with the target defined in your program. The actual value is the value used by the rest of the application. When the target value differs from the actual value, TargetJS iteratively updates the actual value until it matches the target value. This process is managed by two additional variables: `step`, which dictates the number of iterations, and `interval`, which specifies the duration (in milliseconds) the system waits before executing the next iteration.
181
181
 
182
182
  2. State: Targets have four states that control their lifecycles: `active`, `inactive`, `updating`, and `complete`.
183
183
  - `active`: This is the default state for all targets. It indicates that the target is ready to be executed, and the target value needs to be initialized from the variable it represents or its `value()` method needs to be executed to calculate its output.
@@ -407,26 +407,25 @@ If you inspect the HTML elements in the browser's developer tools, you'll notice
407
407
  ![Single page app](https://targetjs.io/img/infiniteScrolling11.gif)
408
408
 
409
409
  ```bash
410
- import { App, TModel, getEvents, getLoader, getScreenWidth, getScreenHeight } from "targetj";
410
+ import { App, getEvents, getLoader, getScreenWidth, getScreenHeight } from "targetj";
411
411
 
412
412
  App({
413
413
  containerOverflowMode: "always",
414
414
  children() {
415
415
  const childrenCount = this.getChildren().length;
416
- return Array.from({ length: 20 }, (_, i) =>
417
- new TModel("scrollItem", {
418
- width: [{list: [100, 250]}, 15],
419
- background: [{list: ["#FCE961", "#B388FF"]}, 15, 15],
420
- height: 48,
421
- color: "#C2FC61",
422
- textAlign: "center",
423
- lineHeight: 48,
424
- bottomMargin: 2,
425
- x() { return this.getCenterX(); },
426
- validateVisibilityInParent: true,
427
- html: childrenCount + i
428
- })
429
- );
416
+ return Array.from({ length: 20 }, (_, i) => ({
417
+ id: 'scrollItem',
418
+ width: [{list: [100, 250]}, 15],
419
+ background: [{list: ["#FCE961", "#B388FF"]}, 15, 15],
420
+ height: 48,
421
+ color: "#C2FC61",
422
+ textAlign: "center",
423
+ lineHeight: 48,
424
+ bottomMargin: 2,
425
+ x() { return this.getCenterX(); },
426
+ validateVisibilityInParent: true,
427
+ html: childrenCount + i
428
+ }));
430
429
  },
431
430
  _load$() {
432
431
  this.prevTargetValue.forEach(data =>
@@ -520,7 +519,7 @@ App({
520
519
  },
521
520
  page2() {
522
521
  return {
523
- ...this.val('page').targets,
522
+ ...this.val('page'),
524
523
  background: "#B388FF",
525
524
  html: 'page2'
526
525
  };
package/build/App.js CHANGED
@@ -4,7 +4,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.tRoot = exports.tApp = exports.isRunning = exports.getVisibles = exports.getScreenWidth = exports.getScreenHeight = exports.getRunScheduler = exports.getResizeLastUpdate = exports.getPager = exports.getManager = exports.getLocationManager = exports.getLoader = exports.getEvents = exports.getBrowser = exports.App = void 0;
7
+ exports.tRoot = exports.tApp = exports.isRunning = exports.getVisibles = exports.getScreenWidth = exports.getScreenHeight = exports.getRunScheduler = exports.getResizeLastUpdate = exports.getPager = exports.getManager = exports.getLocationManager = exports.getLoader = exports.getEvents = exports.getBrowser = exports.fetchImage = exports.fetch = exports.App = void 0;
8
8
  var _$Dom = require("./$Dom.js");
9
9
  var _TModel = require("./TModel.js");
10
10
  var _Browser = require("./Browser.js");
@@ -194,36 +194,44 @@ var getLoader = exports.getLoader = function getLoader() {
194
194
  var _tApp4;
195
195
  return (_tApp4 = tApp) === null || _tApp4 === void 0 ? void 0 : _tApp4.loader;
196
196
  };
197
- var getManager = exports.getManager = function getManager() {
197
+ var fetch = exports.fetch = function fetch(tmodel, url, query, cacheId) {
198
198
  var _tApp5;
199
- return (_tApp5 = tApp) === null || _tApp5 === void 0 ? void 0 : _tApp5.manager;
199
+ return (_tApp5 = tApp) === null || _tApp5 === void 0 || (_tApp5 = _tApp5.loader) === null || _tApp5 === void 0 ? void 0 : _tApp5.fetch(tmodel, url, query, cacheId);
200
200
  };
201
- var getRunScheduler = exports.getRunScheduler = function getRunScheduler() {
201
+ var fetchImage = exports.fetchImage = function fetchImage(tmodel, src) {
202
202
  var _tApp6;
203
- return (_tApp6 = tApp) === null || _tApp6 === void 0 ? void 0 : _tApp6.runScheduler;
203
+ return (_tApp6 = tApp) === null || _tApp6 === void 0 || (_tApp6 = _tApp6.loader) === null || _tApp6 === void 0 ? void 0 : _tApp6.fetchImage(tmodel, src);
204
204
  };
205
- var getLocationManager = exports.getLocationManager = function getLocationManager() {
205
+ var getManager = exports.getManager = function getManager() {
206
206
  var _tApp7;
207
- return (_tApp7 = tApp) === null || _tApp7 === void 0 ? void 0 : _tApp7.locationManager;
207
+ return (_tApp7 = tApp) === null || _tApp7 === void 0 ? void 0 : _tApp7.manager;
208
208
  };
209
- var getBrowser = exports.getBrowser = function getBrowser() {
209
+ var getRunScheduler = exports.getRunScheduler = function getRunScheduler() {
210
210
  var _tApp8;
211
- return (_tApp8 = tApp) === null || _tApp8 === void 0 ? void 0 : _tApp8.browser;
211
+ return (_tApp8 = tApp) === null || _tApp8 === void 0 ? void 0 : _tApp8.runScheduler;
212
+ };
213
+ var getLocationManager = exports.getLocationManager = function getLocationManager() {
214
+ var _tApp9;
215
+ return (_tApp9 = tApp) === null || _tApp9 === void 0 ? void 0 : _tApp9.locationManager;
216
+ };
217
+ var getBrowser = exports.getBrowser = function getBrowser() {
218
+ var _tApp10;
219
+ return (_tApp10 = tApp) === null || _tApp10 === void 0 ? void 0 : _tApp10.browser;
212
220
  };
213
221
  var getScreenWidth = exports.getScreenWidth = function getScreenWidth() {
214
- var _tApp$tRoot$getWidth, _tApp9;
215
- return (_tApp$tRoot$getWidth = (_tApp9 = tApp) === null || _tApp9 === void 0 || (_tApp9 = _tApp9.tRoot) === null || _tApp9 === void 0 ? void 0 : _tApp9.getWidth()) !== null && _tApp$tRoot$getWidth !== void 0 ? _tApp$tRoot$getWidth : 0;
222
+ var _tApp$tRoot$getWidth, _tApp11;
223
+ return (_tApp$tRoot$getWidth = (_tApp11 = tApp) === null || _tApp11 === void 0 || (_tApp11 = _tApp11.tRoot) === null || _tApp11 === void 0 ? void 0 : _tApp11.getWidth()) !== null && _tApp$tRoot$getWidth !== void 0 ? _tApp$tRoot$getWidth : 0;
216
224
  };
217
225
  var getScreenHeight = exports.getScreenHeight = function getScreenHeight() {
218
- var _tApp$tRoot$getHeight, _tApp10;
219
- return (_tApp$tRoot$getHeight = (_tApp10 = tApp) === null || _tApp10 === void 0 || (_tApp10 = _tApp10.tRoot) === null || _tApp10 === void 0 ? void 0 : _tApp10.getHeight()) !== null && _tApp$tRoot$getHeight !== void 0 ? _tApp$tRoot$getHeight : 0;
226
+ var _tApp$tRoot$getHeight, _tApp12;
227
+ return (_tApp$tRoot$getHeight = (_tApp12 = tApp) === null || _tApp12 === void 0 || (_tApp12 = _tApp12.tRoot) === null || _tApp12 === void 0 ? void 0 : _tApp12.getHeight()) !== null && _tApp$tRoot$getHeight !== void 0 ? _tApp$tRoot$getHeight : 0;
220
228
  };
221
229
  var getVisibles = exports.getVisibles = function getVisibles() {
222
- var _tApp11;
223
- return (_tApp11 = tApp) === null || _tApp11 === void 0 || (_tApp11 = _tApp11.manager) === null || _tApp11 === void 0 ? void 0 : _tApp11.lists.visible;
230
+ var _tApp13;
231
+ return (_tApp13 = tApp) === null || _tApp13 === void 0 || (_tApp13 = _tApp13.manager) === null || _tApp13 === void 0 ? void 0 : _tApp13.lists.visible;
224
232
  };
225
233
  var getResizeLastUpdate = exports.getResizeLastUpdate = function getResizeLastUpdate() {
226
- var _tApp12;
227
- return (_tApp12 = tApp) === null || _tApp12 === void 0 ? void 0 : _tApp12.resizeLastUpdate;
234
+ var _tApp14;
235
+ return (_tApp14 = tApp) === null || _tApp14 === void 0 ? void 0 : _tApp14.resizeLastUpdate;
228
236
  };
229
237
  window.t = window.t || _SearchUtil.SearchUtil.find;
@@ -168,7 +168,6 @@ var BaseModel = exports.BaseModel = /*#__PURE__*/function () {
168
168
  key: "deactivate",
169
169
  value: function deactivate() {
170
170
  this.currentStatus = undefined;
171
- this.activatedTargets.length = 0;
172
171
  }
173
172
  }, {
174
173
  key: "shouldExecuteCyclesInParallel",
@@ -90,6 +90,7 @@ var LocationManager = exports.LocationManager = /*#__PURE__*/function () {
90
90
  if (!_this2.hasLocationMap[child.oid]) {
91
91
  _this2.addToLocationList(child);
92
92
  }
93
+ child.activatedTargets.length = 0;
93
94
  };
94
95
  while (i < this.activatedList.length) {
95
96
  _loop();
@@ -226,12 +227,12 @@ var LocationManager = exports.LocationManager = /*#__PURE__*/function () {
226
227
  _App.tApp.targetManager.setActualValues(tmodel);
227
228
  if (tmodel.hasDom()) {
228
229
  if (_TModelUtil.TModelUtil.shouldMeasureWidthFromDom(tmodel)) {
229
- _TargetUtil.TargetUtil.setWidthFromDom(tmodel);
230
+ _TModelUtil.TModelUtil.setWidthFromDom(tmodel);
230
231
  }
231
232
  }
232
233
  if (tmodel.hasDom()) {
233
234
  if (_TModelUtil.TModelUtil.shouldMeasureHeightFromDom(tmodel)) {
234
- _TargetUtil.TargetUtil.setHeightFromDom(tmodel);
235
+ _TModelUtil.TModelUtil.setHeightFromDom(tmodel);
235
236
  }
236
237
  }
237
238
  tmodel.isNowVisible = false;
@@ -274,7 +275,14 @@ var LocationManager = exports.LocationManager = /*#__PURE__*/function () {
274
275
  var target = tmodel.targets[targetName];
275
276
  if (tmodel.isTargetEnabled(targetName)) {
276
277
  if (typeof target.value === 'function') {
277
- target.value.call(tmodel, originalEventTarget);
278
+ var result = target.value.call(tmodel, originalEventTarget);
279
+ if (Array.isArray(result)) {
280
+ result.forEach(function (t) {
281
+ return _TargetUtil.TargetUtil.activateSingleTarget(tmodel, t);
282
+ });
283
+ } else if (typeof result === 'string') {
284
+ _TargetUtil.TargetUtil.activateSingleTarget(tmodel, result);
285
+ }
278
286
  } else if (Array.isArray(target.value)) {
279
287
  target.value.forEach(function (t) {
280
288
  return _TargetUtil.TargetUtil.activateSingleTarget(tmodel, t);
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.TModelUtil = void 0;
7
7
  var _TUtil = require("./TUtil.js");
8
8
  var _TargetData = require("./TargetData.js");
9
+ var _App = require("./App.js");
9
10
  var _$Dom = require("./$Dom.js");
11
+ var _ColorUtil = require("./ColorUtil.js");
10
12
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
11
13
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
12
14
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
@@ -148,6 +150,70 @@ var TModelUtil = exports.TModelUtil = /*#__PURE__*/function () {
148
150
  tmodel.styleTargetMap = {};
149
151
  tmodel.styleTargetList.length = 0;
150
152
  }
153
+ }, {
154
+ key: "setWidthFromDom",
155
+ value: function setWidthFromDom(child) {
156
+ var timestamp = child.domWidthTimestamp;
157
+ var parent = child.getParent();
158
+ var domParent = child.getDomParent();
159
+ var rerender = false;
160
+ if ((0, _App.getManager)().needsRerender(child)) {
161
+ child.isTextOnly() ? child.$dom.text(child.getHtml()) : child.$dom.html(child.getHtml());
162
+ rerender = true;
163
+ }
164
+ if (rerender || parent && timestamp <= parent.getDimLastUpdate() || domParent && timestamp <= domParent.getDimLastUpdate()) {
165
+ child.$dom.width('auto');
166
+ var width = child.$dom.width();
167
+ child.domWidthTimestamp = _TUtil.TUtil.now();
168
+ child.val('width', width);
169
+ if (width > 0 || width === 0 && child.lastVal('width') > 0) {
170
+ child.addToStyleTargetList('width');
171
+ }
172
+ (0, _App.getRunScheduler)().schedule(15, 'resize');
173
+ }
174
+ }
175
+ }, {
176
+ key: "setHeightFromDom",
177
+ value: function setHeightFromDom(child) {
178
+ var timestamp = child.domHeightTimestamp;
179
+ var parent = child.getParent();
180
+ var domParent = child.getDomParent();
181
+ var rerender = false;
182
+ if ((0, _App.getManager)().needsRerender(child)) {
183
+ child.isTextOnly() ? child.$dom.text(child.getHtml()) : child.$dom.html(child.getHtml());
184
+ rerender = true;
185
+ }
186
+ if (rerender || parent && timestamp <= parent.getDimLastUpdate() || domParent && timestamp <= domParent.getDimLastUpdate()) {
187
+ child.$dom.height('auto');
188
+ var height = child.$dom.height();
189
+ child.domHeightTimestamp = _TUtil.TUtil.now();
190
+ child.val('height', height);
191
+ if (height > 0 || height === 0 && child.lastVal('height') > 0) {
192
+ child.addToStyleTargetList('height');
193
+ }
194
+ (0, _App.getRunScheduler)().schedule(15, 'resize');
195
+ }
196
+ }
197
+ }, {
198
+ key: "morph",
199
+ value: function morph(tmodel, key, fromValue, toValue, step) {
200
+ var easing = tmodel.getTargetEasing(key);
201
+ var easingStep = easing ? easing(tmodel.getTargetStepPercent(key, step)) : tmodel.getTargetStepPercent(key, step);
202
+ if (_TargetData.TargetData.colorMap[key]) {
203
+ var targetColors = _ColorUtil.ColorUtil.color2Integers(toValue);
204
+ var lastColors = fromValue ? _ColorUtil.ColorUtil.color2Integers(fromValue) : _ColorUtil.ColorUtil.color2Integers('#fff');
205
+ if (targetColors && lastColors) {
206
+ var red = Math.floor(targetColors[0] * easingStep + lastColors[0] * (1 - easingStep));
207
+ var green = Math.floor(targetColors[1] * easingStep + lastColors[1] * (1 - easingStep));
208
+ var blue = Math.floor(targetColors[2] * easingStep + lastColors[2] * (1 - easingStep));
209
+ return "rgb(".concat(red, ",").concat(green, ",").concat(blue, ")");
210
+ } else {
211
+ return toValue;
212
+ }
213
+ } else {
214
+ return typeof toValue === 'number' ? toValue * easingStep + fromValue * (1 - easingStep) : toValue;
215
+ }
216
+ }
151
217
  }, {
152
218
  key: "fixAsyncStyle",
153
219
  value: function fixAsyncStyle(tmodel) {
@@ -8,6 +8,7 @@ var _TargetExecutor = require("./TargetExecutor.js");
8
8
  var _App = require("./App.js");
9
9
  var _TUtil = require("./TUtil.js");
10
10
  var _TargetUtil = require("./TargetUtil.js");
11
+ var _TModelUtil = require("./TModelUtil.js");
11
12
  var _SearchUtil = require("./SearchUtil.js");
12
13
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
13
14
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
@@ -175,7 +176,7 @@ var TargetManager = exports.TargetManager = /*#__PURE__*/function () {
175
176
  initialValue = _TUtil.TUtil.isDefined(tmodel.val(key)) ? tmodel.val(key) : typeof theValue === 'number' ? 0 : undefined;
176
177
  tmodel.setTargetInitialValue(key, initialValue);
177
178
  }
178
- tmodel.val(key, _TargetUtil.TargetUtil.morph(tmodel, key, initialValue, theValue, step, steps));
179
+ tmodel.val(key, _TModelUtil.TModelUtil.morph(tmodel, key, initialValue, theValue, step, steps));
179
180
  tmodel.addToStyleTargetList(key);
180
181
  tmodel.setActualValueLastUpdate(key);
181
182
  tmodel.setTargetMethodName(key, 'value');
@@ -7,7 +7,6 @@ exports.TargetUtil = void 0;
7
7
  var _TargetData = require("./TargetData.js");
8
8
  var _App = require("./App.js");
9
9
  var _TUtil = require("./TUtil.js");
10
- var _ColorUtil = require("./ColorUtil.js");
11
10
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
12
11
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
13
12
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
@@ -111,26 +110,40 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
111
110
  var doesNextTargetUsePrevValue = nextKey && nextKey.endsWith('$') ? true : false;
112
111
  target.originalTargetName = TargetUtil.currentTargetName;
113
112
  target.originalTModel = TargetUtil.currentTModel;
114
- if (doesNextTargetUsePrevValue) {
113
+ var cleanKey = TargetUtil.getTargetName(key);
114
+ if (doesNextTargetUsePrevValue && !target.activateNextTarget) {
115
115
  target.activateNextTarget = nextKey.slice(0, -1);
116
116
  }
117
117
  var stepPattern = /^on[A-Za-z]+Step$/;
118
118
  var endPattern = /^on[A-Za-z]+End$/;
119
119
  var methods = ['value', 'enabledOn', 'onStepsEnd', 'onValueChange', 'loop', 'onImperativeEnd', 'onImperativeStep', 'onSuccess', 'onError'];
120
120
  Object.keys(target).forEach(function (method) {
121
- if (typeof target[method] === 'function' && (methods.includes(method) || stepPattern.test(method) || endPattern.test(method))) {
121
+ if (method === 'value') {
122
122
  var originalMethod = target[method];
123
123
  target[method] = function () {
124
124
  var _getPrevUpdateTime;
125
- TargetUtil.currentTargetName = TargetUtil.getTargetName(key);
125
+ TargetUtil.currentTargetName = cleanKey;
126
126
  TargetUtil.currentTModel = tmodel;
127
- this.key = TargetUtil.getTargetName(key);
127
+ this.key = cleanKey;
128
128
  this.prevTargetValue = getPrevValue();
129
129
  this.isPrevTargetUpdated = isPrevTargetUpdated;
130
- var result = originalMethod.apply(this, arguments);
130
+ var result = typeof originalMethod === 'function' ? originalMethod.apply(this, arguments) : originalMethod;
131
131
  lastPrevUpdateTime = (_getPrevUpdateTime = getPrevUpdateTime()) !== null && _getPrevUpdateTime !== void 0 ? _getPrevUpdateTime : lastPrevUpdateTime;
132
132
  return result;
133
133
  };
134
+ } else if (typeof target[method] === 'function' && (methods.includes(method) || stepPattern.test(method) || endPattern.test(method))) {
135
+ var _originalMethod = target[method];
136
+ target[method] = function () {
137
+ var _getPrevUpdateTime2;
138
+ TargetUtil.currentTargetName = cleanKey;
139
+ TargetUtil.currentTModel = tmodel;
140
+ this.key = cleanKey;
141
+ this.prevTargetValue = getPrevValue();
142
+ this.isPrevTargetUpdated = isPrevTargetUpdated;
143
+ var result = typeof _originalMethod === 'function' ? _originalMethod.apply(this, arguments) : _originalMethod;
144
+ lastPrevUpdateTime = (_getPrevUpdateTime2 = getPrevUpdateTime()) !== null && _getPrevUpdateTime2 !== void 0 ? _getPrevUpdateTime2 : lastPrevUpdateTime;
145
+ return result;
146
+ };
134
147
  }
135
148
  });
136
149
  }
@@ -366,69 +379,5 @@ var TargetUtil = exports.TargetUtil = /*#__PURE__*/function () {
366
379
  }
367
380
  }
368
381
  }
369
- }, {
370
- key: "morph",
371
- value: function morph(tmodel, key, fromValue, toValue, step) {
372
- var easing = tmodel.getTargetEasing(key);
373
- var easingStep = easing ? easing(tmodel.getTargetStepPercent(key, step)) : tmodel.getTargetStepPercent(key, step);
374
- if (_TargetData.TargetData.colorMap[key]) {
375
- var targetColors = _ColorUtil.ColorUtil.color2Integers(toValue);
376
- var lastColors = fromValue ? _ColorUtil.ColorUtil.color2Integers(fromValue) : _ColorUtil.ColorUtil.color2Integers('#fff');
377
- if (targetColors && lastColors) {
378
- var red = Math.floor(targetColors[0] * easingStep + lastColors[0] * (1 - easingStep));
379
- var green = Math.floor(targetColors[1] * easingStep + lastColors[1] * (1 - easingStep));
380
- var blue = Math.floor(targetColors[2] * easingStep + lastColors[2] * (1 - easingStep));
381
- return "rgb(".concat(red, ",").concat(green, ",").concat(blue, ")");
382
- } else {
383
- return toValue;
384
- }
385
- } else {
386
- return typeof toValue === 'number' ? toValue * easingStep + fromValue * (1 - easingStep) : toValue;
387
- }
388
- }
389
- }, {
390
- key: "setWidthFromDom",
391
- value: function setWidthFromDom(child) {
392
- var timestamp = child.domWidthTimestamp;
393
- var parent = child.getParent();
394
- var domParent = child.getDomParent();
395
- var rerender = false;
396
- if ((0, _App.getManager)().needsRerender(child)) {
397
- child.isTextOnly() ? child.$dom.text(child.getHtml()) : child.$dom.html(child.getHtml());
398
- rerender = true;
399
- }
400
- if (rerender || parent && timestamp <= parent.getDimLastUpdate() || domParent && timestamp <= domParent.getDimLastUpdate()) {
401
- child.$dom.width('auto');
402
- var width = child.$dom.width();
403
- child.domWidthTimestamp = _TUtil.TUtil.now();
404
- child.val('width', width);
405
- if (width > 0 || width === 0 && child.lastVal('width') > 0) {
406
- child.addToStyleTargetList('width');
407
- }
408
- (0, _App.getRunScheduler)().schedule(15, 'resize');
409
- }
410
- }
411
- }, {
412
- key: "setHeightFromDom",
413
- value: function setHeightFromDom(child) {
414
- var timestamp = child.domHeightTimestamp;
415
- var parent = child.getParent();
416
- var domParent = child.getDomParent();
417
- var rerender = false;
418
- if ((0, _App.getManager)().needsRerender(child)) {
419
- child.isTextOnly() ? child.$dom.text(child.getHtml()) : child.$dom.html(child.getHtml());
420
- rerender = true;
421
- }
422
- if (rerender || parent && timestamp <= parent.getDimLastUpdate() || domParent && timestamp <= domParent.getDimLastUpdate()) {
423
- child.$dom.height('auto');
424
- var height = child.$dom.height();
425
- child.domHeightTimestamp = _TUtil.TUtil.now();
426
- child.val('height', height);
427
- if (height > 0 || height === 0 && child.lastVal('height') > 0) {
428
- child.addToStyleTargetList('height');
429
- }
430
- (0, _App.getRunScheduler)().schedule(15, 'resize');
431
- }
432
- }
433
382
  }]);
434
383
  }();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "targetj",
3
- "version": "1.0.153",
3
+ "version": "1.0.155",
4
4
  "keywords": [
5
5
  "targetjs"
6
6
  ],