targetj 1.0.258 → 1.0.259

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "targetj",
3
- "version": "1.0.258",
3
+ "version": "1.0.259",
4
4
  "description": "TargetJS: JavaScript UI framework where state includes the journey and code order defines the UI sequence",
5
5
  "keywords": [
6
6
  "targetjs",
package/types/app.d.ts ADDED
@@ -0,0 +1,56 @@
1
+ import type { TargetDefinition } from "./core.js";
2
+
3
+ import type { TModel } from "./tmodel.js";
4
+
5
+ export function App(targets: TargetDefinition): TModel;
6
+
7
+ export function App(tmodel: TModel): TModel;
8
+
9
+ export namespace App { function unmount(): Promise<void>; }
10
+
11
+ export const tApp: any;
12
+
13
+ export function tRoot(): TModel | undefined;
14
+
15
+ export function isRunning(): boolean;
16
+
17
+ export function getEvents(): any;
18
+
19
+ export function getPager(): any;
20
+
21
+ export function getLoader(): any;
22
+
23
+ export function getManager(): any;
24
+
25
+ export function getTargetManager(): any;
26
+
27
+ export function getAnimationManager(): any;
28
+
29
+ export function getRunScheduler(): any;
30
+
31
+ export function getLocationManager(): any;
32
+
33
+ export function getScreenWidth(): number;
34
+
35
+ export function getScreenHeight(): number;
36
+
37
+ export function getVisibles(): any;
38
+
39
+ export function getResizeLastUpdate(): number | undefined;
40
+
41
+ export function getTModelById(id: string): TModel | undefined;
42
+
43
+ export function getDomTModelById(id: string): TModel | undefined;
44
+
45
+ export function fetch(
46
+ tmodel: TModel,
47
+ url: string,
48
+ query?: unknown,
49
+ cacheId?: string
50
+ ): unknown;
51
+
52
+ export function fetchImage(
53
+ tmodel: TModel,
54
+ src: string,
55
+ cacheId?: string
56
+ ): unknown;
@@ -0,0 +1,37 @@
1
+ export type AttributeTargetName =
2
+ | "lang"
3
+ | "autoFocus"
4
+ | "placeholder"
5
+ | "autoComplete"
6
+ | "name"
7
+ | "type"
8
+ | "src"
9
+ | "href"
10
+ | "method"
11
+ | "size"
12
+ | "value"
13
+ | "maxLength"
14
+ | "minLength"
15
+ | "max"
16
+ | "min"
17
+ | "readOnly"
18
+ | "required"
19
+ | "alt"
20
+ | "disabled"
21
+ | "action"
22
+ | "accept"
23
+ | "selected"
24
+ | "rows"
25
+ | "cols"
26
+ | "tabIndex"
27
+ | "role"
28
+ | "ariaLabel"
29
+ | "ariaCurrent"
30
+ | "ariaPressed";
31
+
32
+ export type AttributeTargetValue =
33
+ | string
34
+ | number
35
+ | boolean
36
+ | null
37
+ | undefined;
@@ -0,0 +1,154 @@
1
+ import type {
2
+ TModel
3
+ } from "./tmodel.js";
4
+
5
+ import type {
6
+ StyleTargetName
7
+ } from "./styles.js";
8
+
9
+ import type {
10
+ AttributeTargetName,
11
+ AttributeTargetValue
12
+ } from "./attributes.js";
13
+
14
+ import type {
15
+ StandardEventTargetName
16
+ } from "./events.js";
17
+
18
+ export type TargetFunction<TResult = unknown> = (
19
+ this: TModel,
20
+ ...args: any[]
21
+ ) => TResult;
22
+
23
+ export type EventTargets = {
24
+ [TName in StandardEventTargetName]?:
25
+ | boolean
26
+ | TargetFunction<unknown>;
27
+ } & {
28
+ onResize?:
29
+ | boolean
30
+ | readonly string[]
31
+ | TargetFunction<unknown>;
32
+ };
33
+
34
+ export type EasingFunction = (
35
+ progress: number
36
+ ) => number;
37
+
38
+ export type EasingValue =
39
+ | string
40
+ | EasingFunction;
41
+
42
+ export type TargetOptions<T = unknown> = {
43
+ value?:
44
+ | T
45
+ | readonly T[]
46
+ | TargetFunction<T>;
47
+
48
+ list?: readonly T[];
49
+
50
+ steps?:
51
+ | number
52
+ | readonly number[];
53
+
54
+ interval?:
55
+ | number
56
+ | readonly number[]
57
+ | TargetFunction<number | readonly number[]>;
58
+
59
+ cycles?:
60
+ | number
61
+ | TargetFunction<number>;
62
+
63
+ loop?:
64
+ | boolean
65
+ | "passive";
66
+
67
+ active?: boolean;
68
+
69
+ enabledOn?:
70
+ | boolean
71
+ | string
72
+ | TargetFunction<boolean>;
73
+
74
+ pauseOn?:
75
+ | boolean
76
+ | string
77
+ | TargetFunction<boolean>;
78
+
79
+ easing?:
80
+ | EasingValue
81
+ | readonly EasingValue[];
82
+
83
+ onComplete?: TargetFunction<void>;
84
+ onValueChange?: TargetFunction<void>;
85
+ } & ThisType<TModel>;
86
+
87
+ export type TargetInput<T = unknown> =
88
+ | T
89
+ | readonly T[]
90
+ | TargetFunction<T>
91
+ | TargetOptions<T>;
92
+
93
+ export type ExecutionName<
94
+ TName extends string
95
+ > =
96
+ | TName
97
+ | `${TName}$`
98
+ | `${TName}$$`;
99
+
100
+ export type StyleTargetValue =
101
+ | string
102
+ | number
103
+ | boolean
104
+ | Record<string, unknown>;
105
+
106
+ export type StyleTargets = {
107
+ [TName in ExecutionName<StyleTargetName>]?:
108
+ TargetInput<StyleTargetValue>;
109
+ };
110
+
111
+ export type AttributeTargets = {
112
+ [TName in ExecutionName<AttributeTargetName>]?:
113
+ TargetInput<AttributeTargetValue>;
114
+ };
115
+
116
+ export type TargetEntry =
117
+ | string
118
+ | number
119
+ | boolean
120
+ | null
121
+ | undefined
122
+ | readonly unknown[]
123
+ | TargetFunction
124
+ | TargetOptions
125
+ | TargetDefinition
126
+ | readonly TargetDefinition[];
127
+
128
+ export type ChildrenTargetOptions =
129
+ Omit<
130
+ TargetOptions<readonly TargetDefinition[]>,
131
+ "value"
132
+ > & {
133
+ value?:
134
+ | readonly TargetDefinition[]
135
+ | TargetFunction<readonly TargetDefinition[]>;
136
+
137
+ onVisibleComplete?: TargetFunction<void>;
138
+ } &
139
+ ThisType<TModel>;
140
+
141
+ export type TargetDefinition =
142
+ StyleTargets &
143
+ AttributeTargets &
144
+ EventTargets & {
145
+ addChildren?: ChildrenTargetOptions;
146
+ children?: ChildrenTargetOptions;
147
+
148
+ [targetName: string]: TargetEntry;
149
+ } &
150
+ ThisType<TModel>;
151
+
152
+ export interface SetTargetMap {
153
+ [targetName: string]: TargetInput;
154
+ }
@@ -0,0 +1,41 @@
1
+ export type UserEventTargetName =
2
+ | "onStart"
3
+ | "onEnd"
4
+ | "onKey"
5
+ | "onKeyDown"
6
+ | "onAnyKey"
7
+ | "onBlur"
8
+ | "onFocus"
9
+ | "onClick"
10
+ | "onAnyClick"
11
+ | "onHover"
12
+ | "onSwipe"
13
+ | "onAnySwipe"
14
+ | "onPinch"
15
+ | "onEnter"
16
+ | "onLeave"
17
+ | "onScroll"
18
+ | "onScrollLeft"
19
+ | "onScrollTop"
20
+ | "onScrollLeftEnd"
21
+ | "onScrollTopEnd"
22
+ | "onWindowScroll"
23
+ | "onWindowScrollTopEnd"
24
+ | "onWindowScrollLeftEnd"
25
+ | "onPopState"
26
+ | "onChange"
27
+ | "onInput"
28
+ | "onSubmit";
29
+
30
+ export type InternalEventTargetName =
31
+ | "onDomEvent"
32
+ | "onVisible"
33
+ | "onInvisible";
34
+
35
+ export type EventTargetName =
36
+ | UserEventTargetName
37
+ | InternalEventTargetName
38
+ | "onResize";
39
+
40
+ export type StandardEventTargetName =
41
+ Exclude<EventTargetName, "onResize">;
package/types/index.d.ts CHANGED
@@ -1,290 +1,31 @@
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;
1
+ export * from "./styles.js";
2
+ export * from "./events.js";
3
+ export * from "./attributes.js";
4
+ export * from "./core.js";
5
+ export * from "./tmodel.js";
6
+ export * from "./app.js";
7
+ export * from "./state.js";
8
+ export * from "./utilities.js";
9
+
10
+ import {
11
+ App
12
+ } from "./app.js";
13
+
14
+ import {
15
+ state
16
+ } from "./state.js";
17
+
18
+ import {
19
+ TModel
20
+ } from "./tmodel.js";
21
+
22
+ import {
23
+ Easing,
24
+ Moves,
25
+ StateUtil,
26
+ TModelUtil,
27
+ TUtil
28
+ } from "./utilities.js";
288
29
 
289
30
  declare const TargetJS: {
290
31
  [exportName: string]: any;
@@ -295,6 +36,7 @@ declare const TargetJS: {
295
36
 
296
37
  Moves: typeof Moves;
297
38
  Easing: typeof Easing;
39
+
298
40
  TUtil: typeof TUtil;
299
41
  TModelUtil: typeof TModelUtil;
300
42
  StateUtil: typeof StateUtil;
@@ -0,0 +1,48 @@
1
+ export interface StateCheckpoint {
2
+ key: string;
3
+ capturedAt: number;
4
+
5
+ html: string;
6
+ domState: unknown;
7
+
8
+ oids: Record<string, unknown>;
9
+ rootSnapshot: unknown;
10
+ loaderSnapshot: unknown;
11
+
12
+ visibleOids: string[];
13
+
14
+ scrollLeft: number;
15
+ scrollTop: number;
16
+
17
+ runSnapshot: unknown;
18
+ }
19
+
20
+ export interface StateManager {
21
+ store(
22
+ key?: string
23
+ ): Promise<StateCheckpoint>;
24
+
25
+ restore(
26
+ key?: string
27
+ ): Promise<boolean>;
28
+
29
+ toggle(
30
+ key?: string
31
+ ): Promise<StateCheckpoint | boolean>;
32
+
33
+ has(
34
+ key?: string
35
+ ): boolean;
36
+
37
+ get(
38
+ key?: string
39
+ ): StateCheckpoint | undefined;
40
+
41
+ clear(
42
+ key?: string
43
+ ): boolean;
44
+
45
+ clearAll(): void;
46
+ }
47
+
48
+ export function state(): StateManager;