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 +46 -65
- package/README.md +52 -22
- package/build/AnimationManager.js +349 -155
- package/build/AnimationUtil.js +59 -6
- package/build/App.js +14 -3
- package/build/BaseModel.js +61 -50
- package/build/EventListener.js +24 -6
- package/build/LoadingManager.js +255 -52
- package/build/PageManager.js +170 -242
- package/build/RunScheduler.js +42 -26
- package/build/SearchUtil.js +10 -0
- package/build/StateManager.js +293 -0
- package/build/StateUtil.js +600 -0
- package/build/TModel.js +10 -2
- package/build/TModelUtil.js +366 -75
- package/build/TUtil.js +7 -0
- package/build/TargetExecutor.js +52 -31
- package/build/TargetUtil.js +54 -22
- package/build/index.js +2 -1
- package/dist/targetjs.js +1 -1
- package/dist/targetjs.js.gz +0 -0
- package/package.json +22 -6
- package/types/index.d.ts +303 -0
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
|
|
45
|
-
import * as
|
|
46
|
-
import * as
|
|
47
|
-
import * as
|
|
48
|
-
import * as
|
|
49
|
-
import * as
|
|
50
|
-
import * as
|
|
51
|
-
import * as
|
|
52
|
-
import * as
|
|
53
|
-
import * as
|
|
54
|
-
import * as
|
|
55
|
-
import * as
|
|
56
|
-
import * as
|
|
57
|
-
import * as
|
|
58
|
-
import * as
|
|
59
|
-
import * as
|
|
60
|
-
import * as
|
|
61
|
-
import * as
|
|
62
|
-
import * as
|
|
63
|
-
import * as
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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 !==
|
|
89
|
-
|
|
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
|
|
1
|
+
# TargetJS: State Includes the Journey
|
|
2
2
|
|
|
3
|
-
|
|
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
|
[](https://github.com/livetrails/targetjs/blob/main/LICENSE)
|
|
7
9
|
[](https://github.com/livetrails/targetjs/stargazers)
|
|
8
10
|
[](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".
|
|
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
|
|
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:
|
|
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:
|
|
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
|
|
70
|
-
scale: { value: [0.5, 1.2, 1], steps:
|
|
90
|
+
// Starts immediately.
|
|
91
|
+
scale: { value: [0.5, 1.2, 1], steps: 100 },
|
|
71
92
|
|
|
72
|
-
//
|
|
73
|
-
x$$: { value: [0, 180], steps:
|
|
93
|
+
// $$ waits for the previous target to finish.
|
|
94
|
+
x$$: { value: [0, 180], steps: 100 },
|
|
74
95
|
|
|
75
|
-
|
|
76
|
-
|
|
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
|
|
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
|
-
|
|
|
131
|
-
|
|
132
|
-
| `name`
|
|
133
|
-
| `name$`
|
|
134
|
-
| `name$$` | Deferred | Runs
|
|
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:
|