targetj 1.0.257 → 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/README.md +40 -25
- package/build/App.js +31 -27
- 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/dist/targetjs.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "targetj",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "TargetJS: JavaScript UI framework where state
|
|
3
|
+
"version": "1.0.258",
|
|
4
|
+
"description": "TargetJS: JavaScript UI framework where state includes the journey and code order defines the UI sequence",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"targetjs"
|
|
6
|
+
"targetjs",
|
|
7
|
+
"javascript",
|
|
8
|
+
"ui",
|
|
9
|
+
"framework",
|
|
10
|
+
"frontend",
|
|
11
|
+
"reactive",
|
|
12
|
+
"animation",
|
|
13
|
+
"state-management",
|
|
14
|
+
"web-framework"
|
|
7
15
|
],
|
|
8
16
|
"type": "module",
|
|
9
17
|
"main": "./Export.js",
|
|
10
18
|
"module": "./Export.js",
|
|
19
|
+
"types": "./types/index.d.ts",
|
|
11
20
|
"exports": {
|
|
12
|
-
".":
|
|
13
|
-
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./types/index.d.ts",
|
|
23
|
+
"import": "./Export.js",
|
|
24
|
+
"default": "./Export.js"
|
|
25
|
+
}
|
|
14
26
|
},
|
|
15
27
|
"homepage": "https://targetjs.io",
|
|
16
28
|
"license": "MIT",
|
|
@@ -29,9 +41,12 @@
|
|
|
29
41
|
"scripts": {
|
|
30
42
|
"prod": "webpack --config webpack.config.cjs --mode production && gzip -kf ./dist/targetjs.js",
|
|
31
43
|
"dev": "webpack --config webpack.config.cjs --mode development",
|
|
32
|
-
"build": "babel src --out-dir build"
|
|
44
|
+
"build": "babel src --out-dir build",
|
|
45
|
+
"test:types": "tsc --noEmit --strict --lib ES2022,DOM types/index.d.ts",
|
|
46
|
+
"prepack": "npm run build && npm run prod && npm run test:types"
|
|
33
47
|
},
|
|
34
48
|
"files": [
|
|
49
|
+
"types",
|
|
35
50
|
"Export.js",
|
|
36
51
|
"build/",
|
|
37
52
|
"dist/",
|
|
@@ -45,6 +60,7 @@
|
|
|
45
60
|
"@babel/preset-env": "^7.25.4",
|
|
46
61
|
"babel-loader": "^9.1.0",
|
|
47
62
|
"eslint-webpack-plugin": "^4.2.0",
|
|
63
|
+
"typescript": "^7.0.2",
|
|
48
64
|
"webpack": "^5.91.0",
|
|
49
65
|
"webpack-cli": "^5.1.4"
|
|
50
66
|
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
export type TargetFunction<TResult = unknown> = (
|
|
2
|
+
this: TModel,
|
|
3
|
+
...args: any[]
|
|
4
|
+
) => TResult;
|
|
5
|
+
|
|
6
|
+
export type EasingFunction = (
|
|
7
|
+
progress: number
|
|
8
|
+
) => number;
|
|
9
|
+
|
|
10
|
+
export type EasingValue =
|
|
11
|
+
| string
|
|
12
|
+
| EasingFunction;
|
|
13
|
+
|
|
14
|
+
export interface TargetOptions<T = unknown> {
|
|
15
|
+
value?:
|
|
16
|
+
| T
|
|
17
|
+
| readonly T[]
|
|
18
|
+
| TargetFunction<T>;
|
|
19
|
+
|
|
20
|
+
list?: readonly T[];
|
|
21
|
+
|
|
22
|
+
steps?:
|
|
23
|
+
| number
|
|
24
|
+
| readonly number[];
|
|
25
|
+
|
|
26
|
+
interval?:
|
|
27
|
+
| number
|
|
28
|
+
| readonly number[];
|
|
29
|
+
|
|
30
|
+
cycles?:
|
|
31
|
+
| number
|
|
32
|
+
| TargetFunction<number>;
|
|
33
|
+
|
|
34
|
+
loop?:
|
|
35
|
+
| boolean
|
|
36
|
+
| "passive";
|
|
37
|
+
|
|
38
|
+
active?: boolean;
|
|
39
|
+
|
|
40
|
+
enabledOn?:
|
|
41
|
+
| boolean
|
|
42
|
+
| string
|
|
43
|
+
| TargetFunction<boolean>;
|
|
44
|
+
|
|
45
|
+
pauseOn?:
|
|
46
|
+
| boolean
|
|
47
|
+
| string
|
|
48
|
+
| TargetFunction<boolean>;
|
|
49
|
+
|
|
50
|
+
easing?:
|
|
51
|
+
| EasingValue
|
|
52
|
+
| readonly EasingValue[];
|
|
53
|
+
|
|
54
|
+
onComplete?: TargetFunction<void>;
|
|
55
|
+
onValueChange?: TargetFunction<void>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type TargetInput<T = unknown> =
|
|
59
|
+
| T
|
|
60
|
+
| readonly T[]
|
|
61
|
+
| TargetFunction<T>
|
|
62
|
+
| TargetOptions<T>;
|
|
63
|
+
|
|
64
|
+
export type ExecutionName<TName extends string> =
|
|
65
|
+
| TName
|
|
66
|
+
| `${TName}$`
|
|
67
|
+
| `${TName}$$`;
|
|
68
|
+
|
|
69
|
+
export type StyleTargetName =
|
|
70
|
+
| "width"
|
|
71
|
+
| "height"
|
|
72
|
+
| "opacity"
|
|
73
|
+
| "x"
|
|
74
|
+
| "y"
|
|
75
|
+
| "z"
|
|
76
|
+
| "scale"
|
|
77
|
+
| "rotate"
|
|
78
|
+
| "backgroundColor"
|
|
79
|
+
| "color";
|
|
80
|
+
|
|
81
|
+
export type StyleTargets = {
|
|
82
|
+
[TName in ExecutionName<StyleTargetName>]?:
|
|
83
|
+
TargetInput<number | string>;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export interface EventTargets {
|
|
87
|
+
onClick?: (
|
|
88
|
+
this: TModel,
|
|
89
|
+
event: MouseEvent
|
|
90
|
+
) => void;
|
|
91
|
+
|
|
92
|
+
onKey?: (
|
|
93
|
+
this: TModel,
|
|
94
|
+
event: KeyboardEvent
|
|
95
|
+
) => void;
|
|
96
|
+
|
|
97
|
+
onKeyDown?: (
|
|
98
|
+
this: TModel,
|
|
99
|
+
event: KeyboardEvent
|
|
100
|
+
) => void;
|
|
101
|
+
|
|
102
|
+
onInput?: (
|
|
103
|
+
this: TModel,
|
|
104
|
+
event: InputEvent
|
|
105
|
+
) => void;
|
|
106
|
+
|
|
107
|
+
onSubmit?: (
|
|
108
|
+
this: TModel,
|
|
109
|
+
event: SubmitEvent
|
|
110
|
+
) => void;
|
|
111
|
+
|
|
112
|
+
onResize?:
|
|
113
|
+
| readonly string[]
|
|
114
|
+
| TargetFunction<void>;
|
|
115
|
+
|
|
116
|
+
onEnter?: TargetFunction<void>;
|
|
117
|
+
onLeave?: TargetFunction<void>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export type TargetEntry =
|
|
121
|
+
| string
|
|
122
|
+
| number
|
|
123
|
+
| boolean
|
|
124
|
+
| null
|
|
125
|
+
| undefined
|
|
126
|
+
| readonly unknown[]
|
|
127
|
+
| TargetFunction
|
|
128
|
+
| TargetOptions
|
|
129
|
+
| TargetDefinition
|
|
130
|
+
| readonly TargetDefinition[];
|
|
131
|
+
|
|
132
|
+
/*
|
|
133
|
+
* Declare TargetDefinition only once.
|
|
134
|
+
*/
|
|
135
|
+
export type TargetDefinition =
|
|
136
|
+
StyleTargets &
|
|
137
|
+
EventTargets & {
|
|
138
|
+
[targetName: string]: TargetEntry;
|
|
139
|
+
} &
|
|
140
|
+
ThisType<TModel>;
|
|
141
|
+
|
|
142
|
+
export interface SetTargetMap {
|
|
143
|
+
[targetName: string]: TargetInput;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export class TModel<
|
|
147
|
+
TTargets extends TargetDefinition = TargetDefinition
|
|
148
|
+
> {
|
|
149
|
+
constructor(
|
|
150
|
+
type: string,
|
|
151
|
+
targets: TTargets,
|
|
152
|
+
oid?: string,
|
|
153
|
+
options?: unknown
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
oid: string;
|
|
157
|
+
targets: TTargets;
|
|
158
|
+
|
|
159
|
+
mount(element: string | Element): this;
|
|
160
|
+
|
|
161
|
+
val<T = unknown>(targetName: string): T;
|
|
162
|
+
val<T = unknown>(targetName: string, value: T): T;
|
|
163
|
+
|
|
164
|
+
pval<T = unknown>(targetName: string): T;
|
|
165
|
+
|
|
166
|
+
setTarget<T>(
|
|
167
|
+
targetName: string,
|
|
168
|
+
value: TargetInput<T>,
|
|
169
|
+
steps?: number,
|
|
170
|
+
interval?: number,
|
|
171
|
+
easing?: EasingValue
|
|
172
|
+
): this;
|
|
173
|
+
|
|
174
|
+
setTarget(
|
|
175
|
+
targets: SetTargetMap,
|
|
176
|
+
steps?: number,
|
|
177
|
+
interval?: number,
|
|
178
|
+
easing?: EasingValue
|
|
179
|
+
): this;
|
|
180
|
+
|
|
181
|
+
activateTarget(
|
|
182
|
+
targetName: string,
|
|
183
|
+
...args: any[]
|
|
184
|
+
): unknown;
|
|
185
|
+
|
|
186
|
+
getChild(
|
|
187
|
+
id: string | number
|
|
188
|
+
): TModel | undefined;
|
|
189
|
+
|
|
190
|
+
getParent(): TModel | undefined;
|
|
191
|
+
|
|
192
|
+
getWidth(): number;
|
|
193
|
+
getHeight(): number;
|
|
194
|
+
getX(): number;
|
|
195
|
+
getY(): number;
|
|
196
|
+
|
|
197
|
+
addChild(
|
|
198
|
+
definition: TargetDefinition | TModel
|
|
199
|
+
): TModel;
|
|
200
|
+
|
|
201
|
+
removeChildren(): void;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function App<
|
|
205
|
+
TTargets extends TargetDefinition
|
|
206
|
+
>(
|
|
207
|
+
targets: TTargets & ThisType<TModel<TTargets>>
|
|
208
|
+
): TModel<TTargets>;
|
|
209
|
+
|
|
210
|
+
export function App(
|
|
211
|
+
tmodel: TModel
|
|
212
|
+
): TModel;
|
|
213
|
+
|
|
214
|
+
export namespace App {
|
|
215
|
+
function unmount(): Promise<void>;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export interface StateManager {
|
|
219
|
+
store(key?: string): unknown;
|
|
220
|
+
restore(key?: string): Promise<boolean>;
|
|
221
|
+
toggle(key?: string): Promise<unknown>;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export function state(): StateManager;
|
|
225
|
+
|
|
226
|
+
export function tRoot(): TModel | undefined;
|
|
227
|
+
export function isRunning(): boolean;
|
|
228
|
+
|
|
229
|
+
export function getScreenWidth(): number;
|
|
230
|
+
export function getScreenHeight(): number;
|
|
231
|
+
|
|
232
|
+
export function getTModelById(
|
|
233
|
+
id: string
|
|
234
|
+
): TModel | undefined;
|
|
235
|
+
|
|
236
|
+
export function getDomTModelById(
|
|
237
|
+
id: string
|
|
238
|
+
): TModel | undefined;
|
|
239
|
+
|
|
240
|
+
/*
|
|
241
|
+
* These exports exist at runtime. They can be typed more precisely later.
|
|
242
|
+
*/
|
|
243
|
+
export const tApp: any;
|
|
244
|
+
|
|
245
|
+
export const Moves: any;
|
|
246
|
+
export const SearchUtil: any;
|
|
247
|
+
export const TargetData: any;
|
|
248
|
+
export const TargetUtil: any;
|
|
249
|
+
export const TargetParser: any;
|
|
250
|
+
export const TModelUtil: any;
|
|
251
|
+
export const TUtil: any;
|
|
252
|
+
export const DomInit: any;
|
|
253
|
+
export const $Dom: any;
|
|
254
|
+
export const Bracket: any;
|
|
255
|
+
export const BracketGenerator: any;
|
|
256
|
+
export const ColorUtil: any;
|
|
257
|
+
export const Easing: any;
|
|
258
|
+
export const TargetExecutor: any;
|
|
259
|
+
export const AnimationManager: any;
|
|
260
|
+
export const AnimationUtil: any;
|
|
261
|
+
export const VisibilityUtil: any;
|
|
262
|
+
export const ScheduleUtil: any;
|
|
263
|
+
export const StateUtil: any;
|
|
264
|
+
|
|
265
|
+
export function getEvents(): any;
|
|
266
|
+
export function getPager(): any;
|
|
267
|
+
export function getLoader(): any;
|
|
268
|
+
export function getManager(): any;
|
|
269
|
+
export function getTargetManager(): any;
|
|
270
|
+
export function getAnimationManager(): any;
|
|
271
|
+
export function getRunScheduler(): any;
|
|
272
|
+
export function getLocationManager(): any;
|
|
273
|
+
export function getVisibles(): any;
|
|
274
|
+
export function getResizeLastUpdate(): number | undefined;
|
|
275
|
+
|
|
276
|
+
export function fetch(
|
|
277
|
+
tmodel: TModel,
|
|
278
|
+
url: string,
|
|
279
|
+
query?: unknown,
|
|
280
|
+
cacheId?: string
|
|
281
|
+
): unknown;
|
|
282
|
+
|
|
283
|
+
export function fetchImage(
|
|
284
|
+
tmodel: TModel,
|
|
285
|
+
src: string,
|
|
286
|
+
cacheId?: string
|
|
287
|
+
): unknown;
|
|
288
|
+
|
|
289
|
+
declare const TargetJS: {
|
|
290
|
+
[exportName: string]: any;
|
|
291
|
+
|
|
292
|
+
App: typeof App;
|
|
293
|
+
TModel: typeof TModel;
|
|
294
|
+
state: typeof state;
|
|
295
|
+
|
|
296
|
+
Moves: typeof Moves;
|
|
297
|
+
Easing: typeof Easing;
|
|
298
|
+
TUtil: typeof TUtil;
|
|
299
|
+
TModelUtil: typeof TModelUtil;
|
|
300
|
+
StateUtil: typeof StateUtil;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
export default TargetJS;
|