targetj 1.0.256 → 1.0.258

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/Export.js CHANGED
@@ -1,26 +1,4 @@
1
- export {
2
- App,
3
- tApp,
4
- tRoot,
5
- isRunning,
6
- getEvents,
7
- getPager,
8
- getLoader,
9
- fetch,
10
- fetchImage,
11
- getManager,
12
- getTargetManager,
13
- getAnimationManager,
14
- getRunScheduler,
15
- getLocationManager,
16
- getScreenWidth,
17
- getScreenHeight,
18
- getVisibles,
19
- getResizeLastUpdate,
20
- getTModelById,
21
- getDomTModelById
22
- } from "./build/App.js";
23
-
1
+ export * from "./build/App.js";
24
2
  export * from "./build/TModel.js";
25
3
  export * from "./build/Moves.js";
26
4
  export * from "./build/SearchUtil.js";
@@ -40,53 +18,56 @@ export * from "./build/AnimationManager.js";
40
18
  export * from "./build/AnimationUtil.js";
41
19
  export * from "./build/VisibilityUtil.js";
42
20
  export * from "./build/ScheduleUtil.js";
21
+ export * from "./build/StateUtil.js";
43
22
 
44
- import * as AppModule from './build/App.js';
45
- import * as TModel from './build/TModel.js';
46
- import * as Moves from './build/Moves.js';
47
- import * as SearchUtil from './build/SearchUtil.js';
48
- import * as TargetData from './build/TargetData.js';
49
- import * as TargetUtil from './build/TargetUtil.js';
50
- import * as TargetParser from './build/TargetParser.js';
51
- import * as TModelUtil from './build/TModelUtil.js';
52
- import * as TUtil from './build/TUtil.js';
53
- import * as DomInit from './build/DomInit.js';
54
- import * as Dom from './build/$Dom.js';
55
- import * as Bracket from './build/Bracket.js';
56
- import * as BracketGenerator from './build/BracketGenerator.js';
57
- import * as ColorUtil from './build/ColorUtil.js';
58
- import * as Easing from './build/Easing.js';
59
- import * as TargetExecutor from './build/TargetExecutor.js';
60
- import * as AnimationManager from './build/AnimationManager.js';
61
- import * as AnimationUtil from './build/AnimationUtil.js';
62
- import * as VisibilityUtil from './build/VisibilityUtil.js';
63
- import * as ScheduleUtil from './build/ScheduleUtil.js';
23
+ import * as AppModule from "./build/App.js";
24
+ import * as TModelModule from "./build/TModel.js";
25
+ import * as MovesModule from "./build/Moves.js";
26
+ import * as SearchUtilModule from "./build/SearchUtil.js";
27
+ import * as TargetDataModule from "./build/TargetData.js";
28
+ import * as TargetUtilModule from "./build/TargetUtil.js";
29
+ import * as TargetParserModule from "./build/TargetParser.js";
30
+ import * as TModelUtilModule from "./build/TModelUtil.js";
31
+ import * as TUtilModule from "./build/TUtil.js";
32
+ import * as DomInitModule from "./build/DomInit.js";
33
+ import * as DomModule from "./build/$Dom.js";
34
+ import * as BracketModule from "./build/Bracket.js";
35
+ import * as BracketGeneratorModule from "./build/BracketGenerator.js";
36
+ import * as ColorUtilModule from "./build/ColorUtil.js";
37
+ import * as EasingModule from "./build/Easing.js";
38
+ import * as TargetExecutorModule from "./build/TargetExecutor.js";
39
+ import * as AnimationManagerModule from "./build/AnimationManager.js";
40
+ import * as AnimationUtilModule from "./build/AnimationUtil.js";
41
+ import * as VisibilityUtilModule from "./build/VisibilityUtil.js";
42
+ import * as ScheduleUtilModule from "./build/ScheduleUtil.js";
43
+ import * as StateUtilModule from "./build/StateUtil.js";
64
44
 
65
45
  const TargetJS = {
66
- ...AppModule,
67
- ...TModel,
68
- ...Moves,
69
- ...SearchUtil,
70
- ...TargetData,
71
- ...TargetUtil,
72
- ...TargetParser,
73
- ...TModelUtil,
74
- ...TUtil,
75
- ...DomInit,
76
- ...Dom,
77
- ...Bracket,
78
- ...BracketGenerator,
79
- ...ColorUtil,
80
- ...Easing,
81
- ...TargetExecutor,
82
- ...AnimationManager,
83
- ...AnimationUtil,
84
- ...VisibilityUtil,
85
- ...ScheduleUtil
46
+ ...AppModule,
47
+ ...TModelModule,
48
+ ...MovesModule,
49
+ ...SearchUtilModule,
50
+ ...TargetDataModule,
51
+ ...TargetUtilModule,
52
+ ...TargetParserModule,
53
+ ...TModelUtilModule,
54
+ ...TUtilModule,
55
+ ...DomInitModule,
56
+ ...DomModule,
57
+ ...BracketModule,
58
+ ...BracketGeneratorModule,
59
+ ...ColorUtilModule,
60
+ ...EasingModule,
61
+ ...TargetExecutorModule,
62
+ ...AnimationManagerModule,
63
+ ...AnimationUtilModule,
64
+ ...VisibilityUtilModule,
65
+ ...ScheduleUtilModule,
66
+ ...StateUtilModule
86
67
  };
87
68
 
88
- if (typeof window !== 'undefined') {
89
- window.TargetJS = TargetJS;
69
+ if (typeof window !== "undefined") {
70
+ window.TargetJS = TargetJS;
90
71
  }
91
72
 
92
73
  export default TargetJS;
package/README.md CHANGED
@@ -1,24 +1,34 @@
1
- # TargetJS: State as Destination, Code Order as UI Sequence
1
+ # TargetJS: State Includes the Journey
2
2
 
3
- ### Most frameworks are great at rendering state. TargetJS is designed for the journey between states.
3
+ **Code order defines the UI sequence.**
4
+
5
+ Most frameworks are great at rendering state. TargetJS is designed for the journey between states.
4
6
 
5
7
  **[targetjs.io](https://targetjs.io)**
6
8
  [![MIT LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/livetrails/targetjs/blob/main/LICENSE)
7
9
  [![Stars](https://img.shields.io/github/stars/livetrails/targetjs.svg)](https://github.com/livetrails/targetjs/stargazers)
8
10
  [![npm version](https://img.shields.io/npm/v/targetj.svg)](https://www.npmjs.com/package/targetj)
9
11
 
10
- TargetJS is a JavaScript UI framework that replaces the "State → Render" model with "State → Transition → Render". It also lets code order directly define the UI sequence. It unifies UI, animations, API calls, event handling, and state into self-contained "Targets" that stack together like Lego pieces using Code-Ordered Reactivity.
12
+ TargetJS is a JavaScript UI framework that replaces the "State → Render" model with "State → Transition → Render".
13
+
14
+ Transitions are part of the state itself. This allows the entire UI, including an animation in progress, to be captured and later restored from the exact point at which it was saved.
15
+
16
+ TargetJS also lets code order directly define the UI sequence. UI, transitions, API calls, event handling, and state are unified into self-contained Targets that chain together through Code-Ordered Reactivity.
11
17
 
12
18
  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).
13
19
 
14
20
 
15
21
  ## What problems TargetJS solves
16
22
 
17
- **UI frameworks model the final result, not transition**
23
+ **UI frameworks model the final result, not the transition**
18
24
 
19
25
  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.
20
26
 
21
- 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.
27
+ TargetJS makes that transition part of the state change itself. Values are not limited to being assigned immediately. They can move toward their destination over configurable steps, intervals, and easing. Transitions therefore become a native part of the UI model rather than effects added after rendering. TargetJS also delivers CSS-level transition efficiency.
28
+
29
+ Because each Target has its own lifecycle, transitions can also adapt dynamically. For example, pausing when an element leaves the screen or changing speed on scroll.
30
+
31
+ Since the transition belongs to the runtime state, the UI can be captured while a transition is in progress. That state can later be restored, allowing the transition to resume from the point at which it was saved.
22
32
 
23
33
  **Fragmentation across multiple mental models**
24
34
 
@@ -41,10 +51,12 @@ With its compact style, TargetJS makes the journey from A → B explicit and eff
41
51
  ## 🚀 Why TargetJS?
42
52
 
43
53
  1. Unified State: One single state. Transitions are state too.
54
+ 1. Adaptive Transitions: Transitions can pause, resume, change speed, and respond to input.
55
+ 1. Restorable UI: Capture the UI during a transition and later resume the complete state including the transition from the saved point.
44
56
  1. UI as Sequence: Code describes the UI story from top to bottom, just like the user experiences the interaction: "When this finishes, do that."
45
57
  1. Ultra-Compact: Minimal code, with no coordination variables.
46
58
  1. Zero Boilerplate Async: Targets handle waiting for nested asynchronous operations automatically.
47
- 1. Animation by Default: High-performance animations are baked into the logic.
59
+ 1. Animation by Default: Turn value into high-performance animations simply by adding `steps`.
48
60
 
49
61
  ## ⚡ Quick Start (30 Seconds)
50
62
 
@@ -56,28 +68,44 @@ npm install targetj
56
68
 
57
69
  **2. Example**
58
70
 
59
- This creates the following sequence: bounce → move → turn red → log. Notice how the code read like the UI sequence. The `$$` suffix makes each step wait for the preceding ones. There is only one state. The transitions are part of that state.
71
+ This creates the following sequence:
72
+
73
+ ```text
74
+ bounce → move → turn red → log
75
+ ```
76
+
77
+ Notice how the code reads in the same order as the UI sequence. The `$$` suffix makes each target wait for all preceding targets to complete.
78
+
79
+ There is only one state, and the transitions are part of that state. Click the square while it is animating to save its current state. Click it again to restore the state and resume the animation from the exact point at which it was saved.
60
80
 
61
81
  ```javascript
62
- import { App } from "targetj";
82
+ import { App, state } from "targetj";
63
83
 
64
84
  App({
65
85
  width: 100,
66
86
  height: 100,
67
87
  backgroundColor: "blue",
88
+ cursor: "pointer",
68
89
 
69
- // Starts immediately: bounce.
70
- scale: { value: [0.5, 1.2, 1], steps: 24, interval: 12 },
90
+ // Starts immediately.
91
+ scale: { value: [0.5, 1.2, 1], steps: 100 },
71
92
 
72
- // Waits for scale to finish, then moves right.
73
- x$$: { value: [0, 180], steps: 40, interval: 8 },
93
+ // $$ waits for the previous target to finish.
94
+ x$$: { value: [0, 180], steps: 100 },
74
95
 
75
- // Waits for x to finish, then turns red.
76
- backgroundColor$$: { value: "crimson", steps: 30, interval: 8 },
96
+ backgroundColor$$: {
97
+ value: "crimson",
98
+ steps: 100
99
+ },
77
100
 
78
- // Waits for the color change to finish.
79
101
  done$$() {
80
102
  console.log("Sequence complete");
103
+ },
104
+
105
+ // Click once to save the state.
106
+ // Click again to restore it including animation progress.
107
+ onClick() {
108
+ state().toggle();
81
109
  }
82
110
  }).mount("#app");
83
111
  ```
@@ -125,15 +153,15 @@ A target can also be defined as an object with optional controls that manage its
125
153
 
126
154
  ### Compact Execution Syntax
127
155
 
128
- Target names can include special symbols that define when they execute. This provides a compact alternative to implementing the same behavior with callbacks.
156
+ Target names can include special suffixes that determine when they execute. This provides a compact alternative to coordinating the same behavior with callbacks.
129
157
 
130
- | Symbol | Name | Behavior |
131
- |------|------|------|
132
- | `name` | Standard | Runs immediately in the order it appears. |
133
- | `name$` | Reactive | Runs every time the previous sibling target updates. Equivalent to using `on<PropertyName>Step()` or `onValueChange()` to activate the next target . |
134
- | `name$$` | Deferred | Runs only after the entire preceding target chain, including children, animations, and API calls, completes. Equivalent to using `onComplete()` to activate the next target. |
135
- | `_name` | Inactive | Does not run automatically. Trigger it manually with `.activateTarget()`. Equivalent to `{ active: false }`. |
158
+ | Syntax | Name | Behavior |
159
+ | -------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
160
+ | `name` | Standard | Runs immediately in code order unless `active` is `false`. |
161
+ | `name$` | Reactive | Runs whenever the preceding sibling Target updates. Similar to activating the next Target from `onValueChange()` or `on<PropertyName>Step()`. |
162
+ | `name$$` | Deferred | Runs after the entire preceding Target chain—including children, animations, and API calls—has completed. Similar to activating the next Target from `onComplete()`. |
136
163
 
164
+ To prevent a Target from running automatically, set `active: false` and activate it later with `.activateTarget()`.
137
165
 
138
166
  ## Examples: Like Button → Animated Like (in 3 Steps)
139
167
 
@@ -552,6 +580,8 @@ These targets update CSS properties and transforms:
552
580
 
553
581
  These can be animated simply by adding `steps`.
554
582
 
583
+ For custom CSS, use the `css` Target.
584
+
555
585
  **Structure**
556
586
 
557
587
  These targets define the structure of the interface: