tosijs 1.0.3
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/LICENSE +29 -0
- package/README.md +385 -0
- package/dist/bind.d.ts +9 -0
- package/dist/bindings.d.ts +4 -0
- package/dist/blueprint-loader.d.ts +19 -0
- package/dist/by-path.d.ts +8 -0
- package/dist/color.d.ts +46 -0
- package/dist/component.d.ts +37 -0
- package/dist/css-colors.d.ts +3 -0
- package/dist/css-system-color.d.ts +1 -0
- package/dist/css-types.d.ts +250 -0
- package/dist/css.d.ts +22 -0
- package/dist/deep-clone.d.ts +5 -0
- package/dist/dom.d.ts +9 -0
- package/dist/elements.d.ts +142 -0
- package/dist/get-css-var.d.ts +1 -0
- package/dist/hot-reload.d.ts +2 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +33 -0
- package/dist/list-binding.d.ts +37 -0
- package/dist/main.js +13 -0
- package/dist/main.js.map +33 -0
- package/dist/make-component.d.ts +39 -0
- package/dist/make-error.d.ts +1 -0
- package/dist/metadata.d.ts +32 -0
- package/dist/module.js +13 -0
- package/dist/module.js.map +33 -0
- package/dist/more-math.d.ts +10 -0
- package/dist/object-property-list.d.ts +8 -0
- package/dist/path-listener.d.ts +13 -0
- package/dist/settings.d.ts +4 -0
- package/dist/string-case.d.ts +2 -0
- package/dist/throttle.d.ts +4 -0
- package/dist/version.d.ts +1 -0
- package/dist/xin-proxy.d.ts +4 -0
- package/dist/xin-types.d.ts +111 -0
- package/dist/xin.d.ts +16 -0
- package/package.json +71 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const version = "1.0.3";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { XinProxy, BoxedProxy } from './xin-types';
|
|
2
|
+
export declare function tosi<T extends object>(obj: T): BoxedProxy<T>;
|
|
3
|
+
export declare function boxedProxy<T extends object>(obj: T): BoxedProxy<T>;
|
|
4
|
+
export declare function xinProxy<T extends object>(obj: T, boxed?: boolean): XinProxy<T>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { XIN_PATH, XIN_VALUE, XIN_OBSERVE, XIN_BIND } from './metadata';
|
|
2
|
+
import { XinStyleRule } from './css-types';
|
|
3
|
+
export type AnyFunction = (...args: any[]) => any | Promise<any>;
|
|
4
|
+
export type XinScalar = string | boolean | number | symbol | AnyFunction;
|
|
5
|
+
export type XinArray = any[];
|
|
6
|
+
export interface XinObject {
|
|
7
|
+
[key: string | number | symbol]: any;
|
|
8
|
+
}
|
|
9
|
+
export type XinProxyTarget = XinObject | XinArray;
|
|
10
|
+
export type XinValue = XinObject | XinArray | XinScalar | null | undefined;
|
|
11
|
+
type ProxyObserveFunc = ((path: string) => void);
|
|
12
|
+
type ProxyBindFunc<T extends Element = Element> = (element: T, binding: XinBinding<T>, options?: XinObject) => VoidFunction;
|
|
13
|
+
export interface XinProps<T = any> {
|
|
14
|
+
[XIN_PATH]: string;
|
|
15
|
+
[XIN_VALUE]: T;
|
|
16
|
+
[XIN_OBSERVE]: ProxyObserveFunc;
|
|
17
|
+
[XIN_BIND]: ProxyBindFunc;
|
|
18
|
+
}
|
|
19
|
+
export interface OptionalXinProps<T = any> {
|
|
20
|
+
[XIN_PATH]?: string;
|
|
21
|
+
[XIN_VALUE]?: T;
|
|
22
|
+
[XIN_OBSERVE]?: ProxyObserveFunc;
|
|
23
|
+
[XIN_BIND]?: ProxyBindFunc;
|
|
24
|
+
}
|
|
25
|
+
export type BoxedProxy<T = any> = T extends Array<infer U> ? Array<BoxedProxy<U>> : T extends Function ? T & OptionalXinProps<Function> : T extends object ? {
|
|
26
|
+
[K in keyof T]: BoxedProxy<T[K]>;
|
|
27
|
+
} : T extends string ? String & OptionalXinProps<string> : T extends number ? Number & OptionalXinProps<number> : T extends boolean ? Boolean & OptionalXinProps<boolean> : T;
|
|
28
|
+
export type Unboxed<T = any> = T extends String ? string : T extends Number ? number : T extends Boolean ? boolean : T;
|
|
29
|
+
export type XinProxy<T = any> = T extends Array<infer U> ? Array<XinProxy<U>> : T extends Function ? T : T extends object ? {
|
|
30
|
+
[K in keyof T]: T[K] extends object ? XinProxy<T[K]> : T[K];
|
|
31
|
+
} : T;
|
|
32
|
+
export type XinProxyObject = XinProps<object> & {
|
|
33
|
+
[key: string]: XinProxyObject | XinProxyArray | XinObject | XinArray | XinScalar;
|
|
34
|
+
};
|
|
35
|
+
export type XinProxyArray = XinProps<[]> & {
|
|
36
|
+
[key: string]: XinProxyObject;
|
|
37
|
+
} & (XinProxyObject[] | XinScalar[]);
|
|
38
|
+
export type XinTouchableType = string | XinProxy | BoxedProxy | String | Number | Boolean;
|
|
39
|
+
export type EventType = keyof HTMLElementEventMap;
|
|
40
|
+
export type XinEventHandler<T extends Event = Event, E extends Element = Element> = ((evt: T & {
|
|
41
|
+
target: E;
|
|
42
|
+
}) => void) | ((evt: T & {
|
|
43
|
+
target: E;
|
|
44
|
+
}) => Promise<void>) | string;
|
|
45
|
+
export type XinBindingShortcut = XinTouchableType | XinBindingSpec;
|
|
46
|
+
type _BooleanFunction = () => boolean;
|
|
47
|
+
type _PathTestFunction = (path: string) => boolean | symbol;
|
|
48
|
+
export type PathTestFunction = _BooleanFunction | _PathTestFunction;
|
|
49
|
+
type OptionalSymbol = symbol | undefined;
|
|
50
|
+
type _CallbackFunction = (() => void) | (() => OptionalSymbol);
|
|
51
|
+
type _PathCallbackFunction = ((path: string) => void) | ((path: string) => OptionalSymbol);
|
|
52
|
+
export type ObserverCallbackFunction = _PathCallbackFunction | _CallbackFunction;
|
|
53
|
+
export interface XinBindingSpec {
|
|
54
|
+
value: XinTouchableType | any;
|
|
55
|
+
[key: string]: any;
|
|
56
|
+
}
|
|
57
|
+
export type XinBindingSetter<T extends Element = Element> = (element: T, value: any, options?: XinObject) => void;
|
|
58
|
+
export type XinBindingGetter<T extends Element = Element> = (element: T, options?: XinObject) => any;
|
|
59
|
+
export interface XinBinding<T extends Element = Element> {
|
|
60
|
+
toDOM?: XinBindingSetter<T>;
|
|
61
|
+
fromDOM?: XinBindingGetter<T>;
|
|
62
|
+
}
|
|
63
|
+
export interface XinInlineBinding<T extends Element = Element> {
|
|
64
|
+
value: XinTouchableType;
|
|
65
|
+
binding: XinBinding<T> | XinBindingSetter<T> | string;
|
|
66
|
+
}
|
|
67
|
+
export interface ElementProps<T extends Element = Element> {
|
|
68
|
+
onClick?: XinEventHandler<MouseEvent, T>;
|
|
69
|
+
onMousedown?: XinEventHandler<MouseEvent, T>;
|
|
70
|
+
onMouseenter?: XinEventHandler<MouseEvent, T>;
|
|
71
|
+
onMouseleave?: XinEventHandler<MouseEvent, T>;
|
|
72
|
+
onMouseup?: XinEventHandler<MouseEvent, T>;
|
|
73
|
+
onTouchstart?: XinEventHandler<TouchEvent, T>;
|
|
74
|
+
onTouchmove?: XinEventHandler<TouchEvent, T>;
|
|
75
|
+
onTouchend?: XinEventHandler<TouchEvent, T>;
|
|
76
|
+
onTouchcancel?: XinEventHandler<TouchEvent, T>;
|
|
77
|
+
onDragstart?: XinEventHandler<DragEvent, T>;
|
|
78
|
+
onDragover?: XinEventHandler<DragEvent, T>;
|
|
79
|
+
onDragend?: XinEventHandler<DragEvent, T>;
|
|
80
|
+
onDragenter?: XinEventHandler<DragEvent, T>;
|
|
81
|
+
onDragleave?: XinEventHandler<DragEvent, T>;
|
|
82
|
+
onInput?: XinEventHandler<InputEvent, T>;
|
|
83
|
+
onChange?: XinEventHandler<InputEvent, T>;
|
|
84
|
+
onSubmit?: XinEventHandler<SubmitEvent, T>;
|
|
85
|
+
onKeydown?: XinEventHandler<KeyboardEvent, T>;
|
|
86
|
+
onKeyup?: XinEventHandler<KeyboardEvent, T>;
|
|
87
|
+
bind?: XinInlineBinding<T>;
|
|
88
|
+
bindValue?: XinBindingShortcut;
|
|
89
|
+
bindText?: XinBindingShortcut;
|
|
90
|
+
bindList?: XinBindingShortcut;
|
|
91
|
+
bindEnabled?: XinBindingShortcut;
|
|
92
|
+
bindDisabled?: XinBindingShortcut;
|
|
93
|
+
style?: XinStyleRule;
|
|
94
|
+
class?: string;
|
|
95
|
+
apply?: (element: Element) => void | Promise<void>;
|
|
96
|
+
[key: string]: any;
|
|
97
|
+
}
|
|
98
|
+
export interface StringMap {
|
|
99
|
+
[key: string]: any;
|
|
100
|
+
}
|
|
101
|
+
export interface PartsMap {
|
|
102
|
+
[key: string]: Element;
|
|
103
|
+
}
|
|
104
|
+
export type ValueElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
|
|
105
|
+
export type ElementPart<T extends Element = Element> = Element | DocumentFragment | ElementProps<T> | string | number;
|
|
106
|
+
export type HTMLElementCreator<T extends Element = Element> = (...contents: ElementPart<T>[]) => T;
|
|
107
|
+
export type FragmentCreator = (...contents: ElementPart<Element>[]) => DocumentFragment;
|
|
108
|
+
export type ElementCreator<T extends Element = Element> = (...contents: ElementPart<T>[]) => T;
|
|
109
|
+
export type ContentPart = Element | DocumentFragment | string;
|
|
110
|
+
export type ContentType = ContentPart | ContentPart[];
|
|
111
|
+
export {};
|
package/dist/xin.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PathTestFunction, ObserverCallbackFunction } from './xin-types';
|
|
2
|
+
import { settings } from './settings';
|
|
3
|
+
import { Listener, touch, unobserve, updates } from './path-listener';
|
|
4
|
+
declare const isValidPath: (path: string) => boolean;
|
|
5
|
+
declare const observe: (test: string | RegExp | PathTestFunction, callback: string | ObserverCallbackFunction) => Listener;
|
|
6
|
+
declare const xin: {
|
|
7
|
+
[x: string]: any;
|
|
8
|
+
[x: number]: any;
|
|
9
|
+
[x: symbol]: any;
|
|
10
|
+
};
|
|
11
|
+
declare const boxed: {
|
|
12
|
+
[x: string]: any;
|
|
13
|
+
[x: number]: any;
|
|
14
|
+
[x: symbol]: any;
|
|
15
|
+
};
|
|
16
|
+
export { xin, boxed, updates, touch, observe, unobserve, settings, isValidPath };
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tosijs",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "path-based state management for web apps",
|
|
5
|
+
"source": "src/index.ts",
|
|
6
|
+
"main": "dist/main.js",
|
|
7
|
+
"module": "dist/module.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
"import": "./dist/module.js",
|
|
11
|
+
"require": "./dist/main.js",
|
|
12
|
+
"browser": "./dist/index.js",
|
|
13
|
+
"default": "./dist/module.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://tosijs.net",
|
|
17
|
+
"keywords": [
|
|
18
|
+
"javascript",
|
|
19
|
+
"typescript",
|
|
20
|
+
"bun",
|
|
21
|
+
"front-end",
|
|
22
|
+
"back-end",
|
|
23
|
+
"web-components",
|
|
24
|
+
"css-variables"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"start": "bun --watch dev.ts",
|
|
28
|
+
"format": "bun eslint src demo --fix && bun prettier --write .",
|
|
29
|
+
"test": "bun test",
|
|
30
|
+
"latest": "rm -rf node_modules && bun update",
|
|
31
|
+
"free-port": "lsof -ti:8018 | xargs kill -9"
|
|
32
|
+
},
|
|
33
|
+
"author": "Tonio Loewald",
|
|
34
|
+
"license": "BSD-3-CLAUSE",
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@happy-dom/global-registrator": "^18.0.1",
|
|
37
|
+
"@types/jsdom": "^21.1.7",
|
|
38
|
+
"@types/node": "^20.19.7",
|
|
39
|
+
"@types/react": "^19.1.8",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
41
|
+
"bun-types": "^1.2.18",
|
|
42
|
+
"caniuse-lite": "^1.0.30001727",
|
|
43
|
+
"chokidar": "^4.0.3",
|
|
44
|
+
"eslint": "^8.57.1",
|
|
45
|
+
"marked": "^5.1.2",
|
|
46
|
+
"prettier": "^2.8.8",
|
|
47
|
+
"typescript": "^5.8.3",
|
|
48
|
+
"tosijs": "file:.",
|
|
49
|
+
"tosijs-ui": "^0.9.15"
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"/dist",
|
|
53
|
+
"/LICENSE",
|
|
54
|
+
"/README.md"
|
|
55
|
+
],
|
|
56
|
+
"repository": {
|
|
57
|
+
"type": "git",
|
|
58
|
+
"url": "https://github.com/tonioloewald/tosijs.git"
|
|
59
|
+
},
|
|
60
|
+
"ts-standard": {
|
|
61
|
+
"ignore": [
|
|
62
|
+
"dist",
|
|
63
|
+
"cdn",
|
|
64
|
+
"public",
|
|
65
|
+
"www",
|
|
66
|
+
"**/*.js",
|
|
67
|
+
"**/*.mjs",
|
|
68
|
+
"**/*.d.ts"
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
}
|