targetj 1.0.229 → 1.0.230

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 high-performance JavaScript UI framework with ultra-compact syntax. It replaces the "State → Render" model with a Code-Ordered Reactivity. It unifies UI, animations, APIs, event handling, and state into self-contained "Targets" that stack together like intelligent Lego pieces.
8
+ TargetJS is a high-performance JavaScript UI framework with ultra-compact syntax. It replaces the "State → Render" model with "State transition → Render". It unifies UI, animations, APIs, event handling, and state into self-contained "Targets" that stack together like intelligent Lego pieces using Code-Ordered Reactivity.
9
9
 
10
10
  It can be used as a full-featured framework or as a lightweight library alongside other frameworks. It is also a highly performant web framework, as shown in the [framework benchmark](https://krausest.github.io/js-framework-benchmark/current.html).
11
11
 
@@ -16,7 +16,7 @@ It can be used as a full-featured framework or as a lightweight library alongsid
16
16
 
17
17
  Traditional frameworks model the UI as a function of state: change state, re-render the UI. When state changes from A → B, the UI immediately jumps to B. The framework doesn’t naturally represent the journey from A → B. But modern, rich user experiences are more like: A → transition → B.
18
18
 
19
- TargetJS treats state as a destination. Values are not only assigned. They can be approached over time through configurable steps. This makes transitions a native part of state change rather than an afterthought. TargetJS also delivers CSS-level transition efficiency.
19
+ TargetJS treats state as a destination. Values are not only assigned. They can be approached over time through configurable steps. This makes transitions a native part of state change. TargetJS also delivers CSS-level transition efficiency.
20
20
 
21
21
  **Fragmentation across multiple mental models**
22
22
 
@@ -34,7 +34,7 @@ In traditional code, that sequence is often scattered across different places su
34
34
 
35
35
  TargetJS code order and target reactivity allow the implementation to more closely mirror the actual UI sequence.
36
36
 
37
- With its compact style, TargetJS makes the journey from A → B efficient and explicit, with significantly less code than traditional frameworks.
37
+ With its compact style, TargetJS makes the journey from A → B explicit and efficient, with significantly less code than traditional frameworks.
38
38
 
39
39
  ## ⚡ Quick Start (30 Seconds)
40
40
 
@@ -53,17 +53,17 @@ import { App } from "targetj";
53
53
 
54
54
  App({
55
55
  backgroundColor: 'blue', // Starts immediately
56
- width: { value: [100, 200], steps: 100 }, // Starts immediately: animate width from 100px to 200px in 100 steps with 8 ms interval per step.
57
- height: { value: [100, 200], steps: 100 }, // Starts immediately: animate height.
58
- backgroundColor$$: { value: 'red', steps: 100 }, // Wait ($$) for width/height to finish
59
- done$$() { console.log("Hello World!"); } // 3. Waits ($$) for the background color
56
+ width: { value: [100, 200], steps: 100, interval: 8 }, // Starts immediately: animate width from 100px to 200px in 100 steps with 8 ms interval per step.
57
+ height: { value: [100, 200], steps: 100, interval: 8 }, // Starts immediately: animate height.
58
+ backgroundColor$$: { value: 'red', steps: 100, interval: 8 }, // Wait ($$) for width/height to finish
59
+ done$$() { console.log("Hello World!"); } // 3. Waits ($$) for the background color, width/height to finish
60
60
  }).mount("#app");
61
61
  ```
62
62
 
63
63
  ## Targets
64
64
 
65
- In TargetJS, targets are the fundamental unit of behavior.
66
- Methods, properties, and objects are internally transformed into targets that the framework schedules and executes.
65
+ In TargetJS, targets are the fundamental unit of behavior instead of methods.
66
+ Methods and properties both are internally transformed into targets that the framework schedules and executes.
67
67
 
68
68
 
69
69
  ### Execution Syntax
@@ -89,6 +89,7 @@ A target can also be defined as an object with optional controls that manage its
89
89
  | `interval` | Delay (ms) between steps or executions. |
90
90
  | `cycles` | Number of times the target repeats. |
91
91
  | `loop` | Boolean form of repetition for continuous execution. |
92
+ | `active` | Boolean property controlling when `value` is executed. |
92
93
  | `enabledOn` | Determines whether the target is enabled for execution. |
93
94
  | `easing` | Predefined easing function controlling how values update over steps. |
94
95
  | `onComplete` | Callback triggered when this target (and its children) finishes. |
@@ -96,7 +97,7 @@ A target can also be defined as an object with optional controls that manage its
96
97
 
97
98
  ## Examples: Like Button → Animated Like (in 3 Steps)
98
99
 
99
- Let’s see how TargetJS handles a complex interaction that would usually require 50+ lines of React/CSS. The example demonstrates how to run four asynchronous operations in a strict sequential sequence, where each step waits for the previous ones to complete.
100
+ Let’s see how TargetJS handles a complex interaction that would usually require 50+ lines of React/CSS. The example demonstrates how to run four asynchronous operations in a strict sequential sequence. In other words, each step has to wait for all the previous ones to complete.
100
101
 
101
102
  ### 1) Like button
102
103
 
@@ -257,7 +258,7 @@ TargetJS can run inside an existing app mounted into a DOM element managed by an
257
258
 
258
259
  ```javascript
259
260
  import React, { useLayoutEffect, useRef } from "react";
260
- import { App as TJApp } from "targetj";
261
+ import { App as TApp } from "targetj";
261
262
 
262
263
  export default function TargetIsland() {
263
264
  const hostRef = useRef(null);
@@ -266,7 +267,7 @@ export default function TargetIsland() {
266
267
  const el = hostRef.current;
267
268
  if (!el) return;
268
269
 
269
- TJApp({
270
+ TApp({
270
271
  width: { value: [100, 500], steps: 100 },
271
272
  height: 200,
272
273
  backgroundColor: "purple",
@@ -274,7 +275,7 @@ export default function TargetIsland() {
274
275
  }).mount(el);
275
276
 
276
277
  return () => {
277
- TJApp.unmount();
278
+ TApp.unmount();
278
279
  };
279
280
  }, []);
280
281
 
@@ -409,7 +410,6 @@ App({
409
410
  bottomMargin: 8,
410
411
  borderRadius: 12,
411
412
  backgroundColor: "white",
412
- validateVisibilityInParent: true,
413
413
  boxShadow: "0 8px 20px rgba(0,0,0,0.08)",
414
414
  photo: {
415
415
  x: 10, y: 10, width: 34, height: 34,
@@ -501,9 +501,9 @@ TargetJS.tApp.start(); // Restart the application
501
501
  TargetJS.tApp.throttle = 0; // Slow down execution (milliseconds between cycles)
502
502
  TargetJS.tApp.debugLevel = 1; // Log cycle execution
503
503
  ```
504
- - Use `t()` in the browser console to find an object by its oid.
505
- - Use `t(oid).bug()` to inspect all the vital properties.
506
- - Use `t(oid).logTree()` to inspect the UI structure.
504
+ - Use `t(id)` in the browser console to find an object by its element id.
505
+ - Use `t(id).bug()` to inspect all the vital properties.
506
+ - Use `t(id).logTree()` to inspect the UI structure.
507
507
 
508
508
  ## Documentation
509
509
  Explore the potential of TargetJS and dive into our interactive documentation at www.targetjs.io.
@@ -446,20 +446,22 @@ var LocationManager = exports.LocationManager = /*#__PURE__*/function () {
446
446
  tmodel.visibilityStatus = {};
447
447
  }
448
448
  tmodel.visibilityStatus.lastIsVisible = tmodel.visibilityStatus.isVisible;
449
- var nowVisibleTest = tmodel.calcVisibility();
450
449
  if (_TUtil.TUtil.isDefined(tmodel.targets.isVisible)) {
451
450
  if (typeof tmodel.targets.isVisible.value === 'function') {
452
451
  nowVisible = tmodel.targets.isVisible.value.call(tmodel);
453
452
  } else {
454
453
  nowVisible = !!tmodel.targets.isVisible;
455
454
  }
455
+ tmodel.isNowVisible = !wasVisible && nowVisible;
456
+ tmodel.isNowInvisible = (wasVisible || wasVisible === undefined) && !nowVisible;
456
457
  } else {
458
+ var nowVisibleTest = tmodel.calcVisibility();
457
459
  nowVisible = nowVisibleTest;
460
+ tmodel.isNowVisible = !wasVisible && nowVisible || !lastVisibleTest && nowVisibleTest;
461
+ tmodel.isNowInvisible = (wasVisible || wasVisible === undefined) && !nowVisible || lastVisibleTest && !nowVisibleTest;
462
+ tmodel.actualValues.isVisible = nowVisible;
458
463
  }
459
- tmodel.actualValues.isVisible = nowVisible;
460
- tmodel.isNowVisible = !wasVisible && nowVisible || !lastVisibleTest && nowVisibleTest;
461
- tmodel.isNowInvisible = (wasVisible || wasVisible === undefined) && !nowVisible || lastVisibleTest && !nowVisibleTest;
462
- if (tmodel.isNowVisible) {
464
+ if (tmodel.isNowVisible || tmodel.isNowInvisible) {
463
465
  tmodel.markLayoutDirty('isNowVisible');
464
466
  }
465
467
  if (tmodel.isNowInvisible) {
@@ -189,16 +189,19 @@ var TModelManager = exports.TModelManager = /*#__PURE__*/function () {
189
189
  }, {
190
190
  key: "shouldPreserveDom",
191
191
  value: function shouldPreserveDom(tmodel) {
192
+ if (!tmodel.isVisible() && _TUtil.TUtil.isDefined(tmodel.targets.isVisible)) {
193
+ return false;
194
+ }
192
195
  var parent = tmodel.parent;
193
196
  if (!tmodel.isIncluded()) {
194
197
  return false;
195
198
  }
196
199
  while (parent && parent !== (0, _App.tRoot)()) {
197
- if (_TUtil.TUtil.isDefined(parent.targets.canDeleteDom) && parent.val('canDeleteDom') === false) {
198
- return true;
200
+ if (_TUtil.TUtil.isDefined(parent.targets.canDeleteDom)) {
201
+ return parent.val('canDeleteDom') === false;
199
202
  }
200
- if (_TUtil.TUtil.isDefined(parent.targets.isVisible) && parent.val('isVisible') === true) {
201
- return true;
203
+ if (_TUtil.TUtil.isDefined(parent.targets.isVisible)) {
204
+ return parent.val('isVisible') === true;
202
205
  }
203
206
  parent = parent.parent;
204
207
  }
@@ -714,6 +714,7 @@ _defineProperty(TargetData, "attributesToTargets", {
714
714
  oninput: 'onInput',
715
715
  onsubmit: 'onSubmit',
716
716
  onvisible: 'onVisible',
717
+ oninvisible: 'oInVisible',
717
718
  onresize: 'onResize',
718
719
  textalign: 'textAlign',
719
720
  preventdefault: 'preventDefault',
@@ -808,6 +809,9 @@ _defineProperty(TargetData, "internalEventMap", {
808
809
  onVisible: function onVisible(tmodel) {
809
810
  return tmodel.isNowVisible;
810
811
  },
812
+ onInVisible: function onInVisible(tmodel) {
813
+ return tmodel.isNowInvisible;
814
+ },
811
815
  onResize: function onResize(tmodel) {
812
816
  var lastUpdate = tmodel.getDimLastUpdate();
813
817
  if (!lastUpdate) {
@@ -161,7 +161,7 @@ var TargetParser = exports.TargetParser = /*#__PURE__*/function () {
161
161
  if (target.isInterval && _TUtil.TUtil.isDefined(target.interval)) {
162
162
  return true;
163
163
  }
164
- return _TUtil.TUtil.isDefined(target.interval) && !_TUtil.TUtil.isDefined(target.steps) && !_TUtil.TUtil.isDefined(target.cycles);
164
+ return _TUtil.TUtil.isDefined(target.interval) && !_TUtil.TUtil.isDefined(target.loop) && !_TUtil.TUtil.isDefined(target.steps) && !_TUtil.TUtil.isDefined(target.cycles);
165
165
  }
166
166
  }, {
167
167
  key: "isPrimitiveArray",