targetj 1.0.257 → 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,16 +1,28 @@
1
1
  {
2
2
  "name": "targetj",
3
- "version": "1.0.257",
4
- "description": "TargetJS: JavaScript UI framework where state is a destination and code order defines the UI sequence",
3
+ "version": "1.0.259",
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
- ".": "./Export.js",
13
- "./Export.js": "./Export.js"
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/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">;
@@ -0,0 +1,45 @@
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";
29
+
30
+ declare const TargetJS: {
31
+ [exportName: string]: any;
32
+
33
+ App: typeof App;
34
+ TModel: typeof TModel;
35
+ state: typeof state;
36
+
37
+ Moves: typeof Moves;
38
+ Easing: typeof Easing;
39
+
40
+ TUtil: typeof TUtil;
41
+ TModelUtil: typeof TModelUtil;
42
+ StateUtil: typeof StateUtil;
43
+ };
44
+
45
+ export default TargetJS;
@@ -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;
@@ -0,0 +1,103 @@
1
+ import type { AttributeTargetName } from "./attributes.js";
2
+
3
+ export type TransformTargetName =
4
+ | "x"
5
+ | "y"
6
+ | "z"
7
+ | "translateX"
8
+ | "translateY"
9
+ | "translateZ"
10
+ | "perspective"
11
+ | "rotate"
12
+ | "rotateX"
13
+ | "rotateY"
14
+ | "rotateZ"
15
+ | "rotate3DX"
16
+ | "rotate3DY"
17
+ | "rotate3DZ"
18
+ | "rotate3DAngle"
19
+ | "scale"
20
+ | "scaleX"
21
+ | "scaleY"
22
+ | "scaleZ"
23
+ | "scale3DX"
24
+ | "scale3DY"
25
+ | "scale3DZ"
26
+ | "skew"
27
+ | "skewX"
28
+ | "skewY";
29
+
30
+ export type UnitStyleTargetName =
31
+ | "width"
32
+ | "height"
33
+ | "fontSize"
34
+ | "lineHeight"
35
+ | "borderRadius"
36
+ | "padding"
37
+ | "paddingLeft"
38
+ | "paddingRight"
39
+ | "paddingTop"
40
+ | "paddingBottom"
41
+ | "left"
42
+ | "top"
43
+ | "right"
44
+ | "bottom"
45
+ | "wordSpacing"
46
+ | "letterSpacing";
47
+
48
+ export type ColorStyleTargetName =
49
+ | "color"
50
+ | "backgroundColor"
51
+ | "borderColor"
52
+ | "background";
53
+
54
+ export type DirectStyleTargetName =
55
+ | "dim"
56
+ | "opacity"
57
+ | "zIndex"
58
+ | "border"
59
+ | "borderTop"
60
+ | "borderLeft"
61
+ | "borderRight"
62
+ | "borderBottom";
63
+
64
+ export type AsyncStyleTargetName =
65
+ | "position"
66
+ | "css"
67
+ | "style"
68
+ | "textAlign"
69
+ | "boxSizing"
70
+ | "transformStyle"
71
+ | "transformOrigin"
72
+ | "attributes"
73
+ | "justifyContent"
74
+ | "flexDirection"
75
+ | "alignItems"
76
+ | "display"
77
+ | "cursor"
78
+ | "fontFamily"
79
+ | "overflow"
80
+ | "overflowX"
81
+ | "overflowY"
82
+ | "textDecoration"
83
+ | "boxShadow"
84
+ | "fontWeight"
85
+ | "willChange"
86
+ | "backgroundImage"
87
+ | "backgroundSize"
88
+ | "flexWrap"
89
+ | "userSelect"
90
+ | "outline"
91
+ | "backfaceVisibility"
92
+ | "filter";
93
+
94
+ export type StyleTargetName =
95
+ | TransformTargetName
96
+ | UnitStyleTargetName
97
+ | ColorStyleTargetName
98
+ | DirectStyleTargetName
99
+ | AsyncStyleTargetName;
100
+
101
+ export type StylableTargetName =
102
+ | StyleTargetName
103
+ | AttributeTargetName;
@@ -0,0 +1,89 @@
1
+ import type {
2
+ EasingValue,
3
+ SetTargetMap,
4
+ TargetDefinition,
5
+ TargetInput
6
+ } from "./core.js";
7
+
8
+ export class TModel<
9
+ TTargets extends TargetDefinition = TargetDefinition
10
+ > {
11
+ constructor(
12
+ type: string,
13
+ targets: TTargets,
14
+ oid?: string,
15
+ options?: unknown
16
+ );
17
+
18
+ oid: string;
19
+ targets: TTargets;
20
+
21
+ parent?: TModel;
22
+
23
+ visibleChildren: TModel[];
24
+
25
+ $dom?: {
26
+ getScrollTop(): number;
27
+ getScrollLeft?(): number;
28
+ };
29
+
30
+ mount(element: string | Element): this;
31
+
32
+ val<T = unknown>(
33
+ targetName: string
34
+ ): T;
35
+
36
+ val<T = unknown>(
37
+ targetName: string,
38
+ value: T
39
+ ): T;
40
+
41
+ pval<T = unknown>(
42
+ targetName: string
43
+ ): T;
44
+
45
+ setTarget<T>(
46
+ targetName: string,
47
+ value: TargetInput<T>,
48
+ steps?: number,
49
+ interval?: number,
50
+ easing?: EasingValue
51
+ ): this;
52
+
53
+ setTarget(
54
+ targets: SetTargetMap,
55
+ steps?: number,
56
+ interval?: number,
57
+ easing?: EasingValue
58
+ ): this;
59
+
60
+ activateTarget(
61
+ targetName: string,
62
+ ...args: any[]
63
+ ): unknown;
64
+
65
+ getChild(
66
+ id: string | number
67
+ ): TModel | undefined;
68
+
69
+ getParent(): TModel | undefined;
70
+
71
+ getLastChild(): TModel | undefined;
72
+
73
+ getWidth(): number;
74
+ getHeight(): number;
75
+ getX(): number;
76
+ getY(): number;
77
+
78
+ isVisible(): boolean;
79
+
80
+ isTargetVisibleTreeComplete(
81
+ targetName?: string
82
+ ): boolean;
83
+
84
+ addChild(
85
+ definition: TargetDefinition | TModel
86
+ ): TModel;
87
+
88
+ removeChildren(): void;
89
+ }
@@ -0,0 +1,37 @@
1
+ export const Moves: any;
2
+
3
+ export const SearchUtil: any;
4
+
5
+ export const TargetData: any;
6
+
7
+ export const TargetUtil: any;
8
+
9
+ export const TargetParser: any;
10
+
11
+ export const TModelUtil: any;
12
+
13
+ export const TUtil: any;
14
+
15
+ export const DomInit: any;
16
+
17
+ export const $Dom: any;
18
+
19
+ export const Bracket: any;
20
+
21
+ export const BracketGenerator: any;
22
+
23
+ export const ColorUtil: any;
24
+
25
+ export const Easing: any;
26
+
27
+ export const TargetExecutor: any;
28
+
29
+ export const AnimationManager: any;
30
+
31
+ export const AnimationUtil: any;
32
+
33
+ export const VisibilityUtil: any;
34
+
35
+ export const ScheduleUtil: any;
36
+
37
+ export const StateUtil: any;