cradova 3.3.4 → 3.3.5

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.
@@ -0,0 +1,350 @@
1
+ import { type CradovaScreenType } from "./types";
2
+ /**
3
+ * Cradova event
4
+ */
5
+ declare class cradovaEvent {
6
+ private listeners;
7
+ private active_listeners;
8
+ addEventListener(eventName: string, callback: () => void): Promise<void>;
9
+ addActiveEventListener(eventName: string, callback: () => void): Promise<void>;
10
+ dispatchEvent(eventName: string, eventArgs?: unknown): Promise<void>;
11
+ /**
12
+ * Active refs is a concept for delegated screens to keep their active refs alive
13
+ * even in the case of naviagtion
14
+ * @param eventName
15
+ * @param eventArgs
16
+ */
17
+ dispatchActiveEvent(eventName: string, eventArgs?: unknown): Promise<void>;
18
+ }
19
+ export declare const CradovaEvent: cradovaEvent;
20
+ /**
21
+ * Cradova Ref
22
+ * -------
23
+ * create dynamic components
24
+ */
25
+ export declare class Ref<Prop extends Record<string, any> = any> {
26
+ private component;
27
+ private effects;
28
+ private effectuate;
29
+ methods: Record<string, Function>;
30
+ private rendered;
31
+ private published;
32
+ private preRendered;
33
+ private reference;
34
+ Signal: createSignal<any> | undefined;
35
+ _state: Prop[];
36
+ _state_track: {
37
+ [x: number]: boolean;
38
+ };
39
+ _state_index: number;
40
+ stash: Prop | undefined;
41
+ constructor(component: (this: Ref<Prop>, data: Prop) => HTMLElement);
42
+ preRender(data?: Prop, stash?: boolean): void;
43
+ destroyPreRendered(): void;
44
+ /**
45
+ * Cradova Ref
46
+ * ---
47
+ * construct to add custom methods to Refs
48
+ * @param methodName
49
+ * @param method
50
+ * @returns void
51
+ */
52
+ define(methodName: string, method: (this: this, ...arg: any) => void): void;
53
+ /**
54
+ * Cradova Ref
55
+ * ---
56
+ * returns html with cradova reference
57
+ * @param data
58
+ * @returns () => HTMLElement
59
+ */
60
+ render(data?: Prop, stash?: boolean): any;
61
+ instance(): HTMLElement;
62
+ _setExtra(Extra: createSignal<any>): void;
63
+ _roll_state(data: any, idx: number, get?: boolean): Prop;
64
+ _effect(fn: () => Promise<void> | void): void;
65
+ private effector;
66
+ /**
67
+ * Cradova Ref
68
+ * ---
69
+ * update ref component with new data and update the dom.
70
+ * @param data
71
+ * @returns
72
+ */
73
+ updateState(data?: Prop, stash?: boolean): void;
74
+ private Activate;
75
+ }
76
+ /**
77
+ * cradova
78
+ * ---
79
+ * lazy load a file
80
+ */
81
+ export declare class lazy<Type> {
82
+ content: Type | undefined;
83
+ private _cb;
84
+ constructor(cb: () => Promise<unknown>);
85
+ load(): Promise<void>;
86
+ }
87
+ /**
88
+ * Cradova
89
+ * ---
90
+ * make reference to dom elements
91
+ */
92
+ export declare class reference {
93
+ tree: Record<string, any>;
94
+ globalTree: Record<string, HTMLElement>;
95
+ /**
96
+ * Bind a DOM element to a reference name.
97
+ * @param name - The name to reference the DOM element by.
98
+ */
99
+ bindAs(name: string): reference;
100
+ /**
101
+ * Retrieve a referenced DOM element.
102
+ * @param name - The name of the referenced DOM element.
103
+ */
104
+ current<ElementType extends HTMLElement = HTMLElement>(name: string): ElementType;
105
+ /**
106
+ * Append a DOM element to the reference, overwriting any existing reference.
107
+ * @param name - The name to reference the DOM element by.
108
+ * @param element - The DOM element to reference.
109
+ */
110
+ _appendDomForce(name: string, Element: HTMLElement): void;
111
+ _appendDomForceGlobal(name: string, Element: HTMLElement): void;
112
+ }
113
+ /**
114
+ * Cradova Signal
115
+ * ----
116
+ * Create stateful data store.
117
+ * Features:
118
+ * - create a store
119
+ * - create actions and fire them
120
+ * - bind a Ref and elements
121
+ * - listen to updates
122
+ * - set object keys instead of all values
123
+ * - persist changes to localStorage
124
+ * - update a cradova Ref automatically
125
+ * @constructor initial: unknown, props: {useHistory, persist}
126
+ */
127
+ export declare class createSignal<Type extends Record<string, any>> {
128
+ private callback;
129
+ private persistName;
130
+ private actions;
131
+ private ref;
132
+ value: Type;
133
+ constructor(initial: Type, props?: {
134
+ persistName?: string | undefined;
135
+ });
136
+ /**
137
+ * Cradova Signal
138
+ * ----
139
+ * set signal value
140
+ * @param value - signal value
141
+ * @returns void
142
+ */
143
+ set(value: Type | ((value: Type) => Type), shouldRefRender?: boolean): void;
144
+ /**
145
+ * Cradova Signal
146
+ * ----
147
+ * set a key value if it's an object
148
+ * @param key - key of the key
149
+ * @param value - value of the key
150
+ * @returns void
151
+ */
152
+ setKey<k extends keyof Type>(key: k, value: unknown, shouldRefRender?: boolean): void;
153
+ /**
154
+ * Cradova Signal
155
+ * ----
156
+ * set a key to signal an action
157
+ * @param name - name of the action
158
+ * @param action function to execute
159
+ */
160
+ createAction(name: string, action: (data?: unknown) => void): void;
161
+ /**
162
+ * Cradova Signal
163
+ * ----
164
+ * creates man y actions at a time
165
+ * @param name - name of the action
166
+ * @param action function to execute
167
+ */
168
+ createActions(Actions: Record<string, (data?: unknown) => void>): void;
169
+ /**
170
+ * Cradova Signal
171
+ * ----
172
+ * fires an action if available
173
+ * @param key - string key of the action
174
+ * @param data - data for the action
175
+ */
176
+ fireAction(key: string, data?: Type): Type;
177
+ /**
178
+ * Cradova
179
+ * ---
180
+ * is used to bind signal data to elements and Refs
181
+ *
182
+ * @param prop
183
+ * @returns something
184
+ */
185
+ bind(prop: string): any;
186
+ private _updateState;
187
+ /**
188
+ * Cradova Signal
189
+ * ----
190
+ * set a auto - rendering component for this store
191
+ *
192
+ * @param Ref component to bind to.
193
+ */
194
+ bindRef(ref: Ref, binding?: {
195
+ event?: string;
196
+ signalProperty: string;
197
+ _element_property: string;
198
+ }): void;
199
+ /**
200
+ * Cradova Signal
201
+ * ----
202
+ * set a update listener on value changes
203
+ * @param callback
204
+ */
205
+ listen(callback: (a: Type) => void): void;
206
+ /**
207
+ * Cradova Signal
208
+ * ----
209
+ * clear the history on local storage
210
+ *
211
+ */
212
+ clearPersist(): void;
213
+ }
214
+ /**
215
+ * Cradova Screen
216
+ * ---
217
+ * create instances of manageable pages
218
+ * @param name
219
+ * @param template
220
+ */
221
+ export declare class Screen {
222
+ /**
223
+ * used internally
224
+ */
225
+ private _name;
226
+ /**
227
+ * this should be a cradova screen component
228
+ */
229
+ _html: ((this: Screen, data?: unknown) => HTMLElement | DocumentFragment) | HTMLElement | DocumentFragment;
230
+ _packed: boolean;
231
+ private _template;
232
+ private _callBack;
233
+ private _deCallBack;
234
+ private _persist;
235
+ private _delegatedRoutesCount;
236
+ private _dropped;
237
+ /**
238
+ * error handler for the screen
239
+ */
240
+ _errorHandler: ((err: unknown) => void) | null;
241
+ constructor(cradova_screen_initials: CradovaScreenType);
242
+ _derive(): {
243
+ _name: string;
244
+ _callBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
245
+ _deCallBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
246
+ };
247
+ _apply_derivation(derivation: {
248
+ _name: string;
249
+ _callBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
250
+ _deCallBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
251
+ }): void;
252
+ get _delegatedRoutes(): number;
253
+ set _delegatedRoutes(count: number);
254
+ setErrorHandler(errorHandler: (err: unknown) => void): void;
255
+ _package(): Promise<void>;
256
+ onActivate(cb: () => Promise<void> | void): void;
257
+ onDeactivate(cb: () => Promise<void> | void): void;
258
+ _deActivate(): Promise<void>;
259
+ drop(state?: boolean): boolean | undefined;
260
+ _Activate(force?: boolean): Promise<void>;
261
+ }
262
+ /** cradova router
263
+ * ---
264
+ * Registers a route.
265
+ *
266
+ * @param {string} path Route path.
267
+ * @param screen the cradova document tree for the route.
268
+ */
269
+ export declare class Router {
270
+ /**
271
+ * cradova router
272
+ * ---
273
+ * Registers a route.
274
+ *
275
+ * accepts an object containing pat and screen
276
+ */
277
+ static BrowserRoutes(obj: Record<string, any>): void;
278
+ /**
279
+ Go back in Navigation history
280
+ */
281
+ static back(): void;
282
+ /**
283
+ Go forward in Navigation history
284
+ */
285
+ static forward(): void;
286
+ /**
287
+ Pause navigation
288
+ */
289
+ static pauseNaviagtion(): void;
290
+ /**
291
+ resume navigation
292
+ */
293
+ static resumeNaviagtion(): void;
294
+ /**
295
+ * Cradova Router
296
+ * ------
297
+ *
298
+ * Navigates to a designated screen in your app
299
+ *
300
+ * @param href string
301
+ * @param data object
302
+ * @param force boolean
303
+ */
304
+ static navigate(href: string, data?: Record<string, unknown> | null, force?: boolean): void;
305
+ /**
306
+ * Cradova
307
+ * ---
308
+ * Loading screen for your app
309
+ *
310
+ * lazy loaded loading use
311
+ *
312
+ * @param screen
313
+ */
314
+ static setLoadingScreen(screen: Screen): void;
315
+ /** cradova router
316
+ * ---
317
+ * Listen for navigation events
318
+ *
319
+ * @param callback () => void
320
+ */
321
+ static onPageEvent(callback: () => void): void;
322
+ /** cradova router
323
+ * ---
324
+ * get a screen ready before time.
325
+ *
326
+ * @param {string} path Route path.
327
+ * @param data data for the screen.
328
+ */
329
+ static packageScreen(path: string): Promise<void>;
330
+ /**
331
+ * Cradova Router
332
+ * ------
333
+ *
334
+ * return last set router params
335
+ *
336
+ * .
337
+ */
338
+ static get Params(): any;
339
+ /**
340
+ * Cradova
341
+ * ---
342
+ * Error Handler for your app
343
+ *
344
+ * @param callback
345
+ * @param path? page path
346
+ */
347
+ static addErrorHandler(callback: (err: unknown) => void): void;
348
+ static _mount(): void;
349
+ }
350
+ export {};
@@ -0,0 +1,60 @@
1
+ import { type VJS_params_TYPE } from "./types";
2
+ export declare const a: (...Children_and_Properties: VJS_params_TYPE) => HTMLAnchorElement;
3
+ export declare const article: (...Children_and_Properties: VJS_params_TYPE) => HTMLElement;
4
+ export declare const audio: (...Children_and_Properties: VJS_params_TYPE) => HTMLAudioElement;
5
+ export declare const br: (...Children_and_Properties: VJS_params_TYPE) => HTMLBRElement;
6
+ export declare const button: (...Children_and_Properties: VJS_params_TYPE) => HTMLButtonElement;
7
+ export declare const canvas: (...Children_and_Properties: VJS_params_TYPE) => HTMLCanvasElement;
8
+ export declare const caption: (...Children_and_Properties: VJS_params_TYPE) => HTMLTableCaptionElement;
9
+ export declare const col: (...Children_and_Properties: VJS_params_TYPE) => HTMLTableColElement;
10
+ export declare const colgroup: (...Children_and_Properties: VJS_params_TYPE) => HTMLOptGroupElement;
11
+ export declare const datalist: (...Children_and_Properties: VJS_params_TYPE) => HTMLDataListElement;
12
+ export declare const details: (...Children_and_Properties: VJS_params_TYPE) => HTMLDetailsElement;
13
+ export declare const dialog: (...Children_and_Properties: VJS_params_TYPE) => HTMLDialogElement;
14
+ export declare const div: (...Children_and_Properties: VJS_params_TYPE) => HTMLDivElement;
15
+ export declare const figure: (...Children_and_Properties: VJS_params_TYPE) => HTMLElement;
16
+ export declare const footer: (...Children_and_Properties: VJS_params_TYPE) => HTMLElement;
17
+ export declare const form: (...Children_and_Properties: VJS_params_TYPE) => HTMLFormElement;
18
+ export declare const h1: (...Children_and_Properties: VJS_params_TYPE) => HTMLHeadingElement;
19
+ export declare const h2: (...Children_and_Properties: VJS_params_TYPE) => HTMLHeadingElement;
20
+ export declare const h3: (...Children_and_Properties: VJS_params_TYPE) => HTMLHeadingElement;
21
+ export declare const h4: (...Children_and_Properties: VJS_params_TYPE) => HTMLHeadingElement;
22
+ export declare const h5: (...Children_and_Properties: VJS_params_TYPE) => HTMLHeadingElement;
23
+ export declare const h6: (...Children_and_Properties: VJS_params_TYPE) => HTMLHeadingElement;
24
+ export declare const head: (...Children_and_Properties: VJS_params_TYPE) => HTMLHeadElement;
25
+ export declare const header: (...Children_and_Properties: VJS_params_TYPE) => HTMLHeadElement;
26
+ export declare const hr: (...Children_and_Properties: VJS_params_TYPE) => HTMLHRElement;
27
+ export declare const i: (...Children_and_Properties: VJS_params_TYPE) => HTMLLIElement;
28
+ export declare const iframe: (...Children_and_Properties: VJS_params_TYPE) => HTMLIFrameElement;
29
+ export declare const img: (...Children_and_Properties: VJS_params_TYPE) => HTMLImageElement;
30
+ export declare const input: (...Children_and_Properties: VJS_params_TYPE) => HTMLInputElement;
31
+ export declare const label: (...Children_and_Properties: VJS_params_TYPE) => HTMLLabelElement;
32
+ export declare const li: (...Children_and_Properties: VJS_params_TYPE) => HTMLLIElement;
33
+ export declare const main: (...Children_and_Properties: VJS_params_TYPE) => HTMLElement;
34
+ export declare const nav: (...Children_and_Properties: VJS_params_TYPE) => HTMLElement;
35
+ export declare const ol: (...Children_and_Properties: VJS_params_TYPE) => HTMLOListElement;
36
+ export declare const optgroup: (...Children_and_Properties: VJS_params_TYPE) => HTMLOptGroupElement;
37
+ export declare const option: (...Children_and_Properties: VJS_params_TYPE) => HTMLOptionElement;
38
+ export declare const p: (...Children_and_Properties: VJS_params_TYPE) => HTMLParagraphElement;
39
+ export declare const progress: (...Children_and_Properties: VJS_params_TYPE) => HTMLProgressElement;
40
+ export declare const q: (...Children_and_Properties: VJS_params_TYPE) => HTMLQuoteElement;
41
+ export declare const section: (...Children_and_Properties: VJS_params_TYPE) => HTMLElement;
42
+ export declare const select: (...Children_and_Properties: VJS_params_TYPE) => HTMLSelectElement;
43
+ export declare const source: (...Children_and_Properties: VJS_params_TYPE) => HTMLSourceElement;
44
+ export declare const span: (...Children_and_Properties: VJS_params_TYPE) => HTMLSpanElement;
45
+ export declare const strong: (...Children_and_Properties: VJS_params_TYPE) => HTMLElement;
46
+ export declare const summary: (...Children_and_Properties: VJS_params_TYPE) => HTMLElement;
47
+ export declare const table: (...Children_and_Properties: VJS_params_TYPE) => HTMLTableElement;
48
+ export declare const tbody: (...Children_and_Properties: VJS_params_TYPE) => HTMLTableColElement;
49
+ export declare const td: (...Children_and_Properties: VJS_params_TYPE) => HTMLTableCellElement;
50
+ export declare const template: (...Children_and_Properties: VJS_params_TYPE) => HTMLTemplateElement;
51
+ export declare const textarea: (...Children_and_Properties: VJS_params_TYPE) => HTMLTextAreaElement;
52
+ export declare const th: (...Children_and_Properties: VJS_params_TYPE) => HTMLTableSectionElement;
53
+ export declare const title: (...Children_and_Properties: VJS_params_TYPE) => HTMLTitleElement;
54
+ export declare const tr: (...Children_and_Properties: VJS_params_TYPE) => HTMLTableRowElement;
55
+ export declare const track: (...Children_and_Properties: VJS_params_TYPE) => HTMLTrackElement;
56
+ export declare const u: (...Children_and_Properties: VJS_params_TYPE) => HTMLUListElement;
57
+ export declare const ul: (...Children_and_Properties: VJS_params_TYPE) => HTMLUListElement;
58
+ export declare const video: (...Children_and_Properties: VJS_params_TYPE) => HTMLVideoElement;
59
+ export declare const svg: (svg: string, properties?: VJS_params_TYPE) => HTMLSpanElement;
60
+ export declare const raw: (html: string) => DocumentFragment;
@@ -0,0 +1,52 @@
1
+ import { type VJS_params_TYPE } from "./types";
2
+ import { Ref } from "./classes";
3
+ export declare const makeElement: <E extends HTMLElement>(element: E & HTMLElement, ElementChildrenAndPropertyList: VJS_params_TYPE) => E;
4
+ export declare const cra: <E extends HTMLElement>(tag: string) => (...Children_and_Properties: VJS_params_TYPE) => E;
5
+ export declare function Rhoda(l: VJS_params_TYPE): DocumentFragment;
6
+ /**
7
+ *
8
+ * @param {expression} condition
9
+ * @param {function} elements[]
10
+ */
11
+ export declare function $if(condition: any, ...elements: VJS_params_TYPE): any;
12
+ export declare function $ifelse(condition: any, ifTrue: any, ifFalse?: any): any;
13
+ export declare function $case(value: any, ...elements: VJS_params_TYPE): (key: any) => VJS_params_TYPE | undefined;
14
+ export declare function $switch(key: unknown, ...cases: ((key: any) => HTMLElement[] | undefined)[]): HTMLElement[] | undefined;
15
+ type LoopData<Type> = Type[];
16
+ export declare function loop<Type>(datalist: LoopData<Type>, component: (value: Type, index?: number, array?: LoopData<Type>) => HTMLElement | DocumentFragment | undefined): HTMLElement[] | undefined;
17
+ /** Calculate a simple numerical representation of the URL */
18
+ export declare const SNRU: {
19
+ snru: string;
20
+ memo_SNRU(): void;
21
+ };
22
+ /**
23
+ * Document fragment
24
+ * @param children
25
+ * @returns
26
+ */
27
+ export declare const frag: (children: VJS_params_TYPE) => DocumentFragment;
28
+ /**
29
+ * Cradova
30
+ * ---
31
+ * Allows functional components to manage state by providing a state value and a function to update it.
32
+ * @param initialValue
33
+ * @param ActiveRef
34
+ * @returns [state, setState]
35
+ */
36
+ export declare function useState<S = unknown>(initialValue: S, ActiveRef: Ref): [S, (newState: S) => void];
37
+ /**
38
+ * Cradova
39
+ * ---
40
+ Allows side effects to be performed in functional components (Refs), such as fetching data or subscribing to events.
41
+ * @param effect
42
+ * @returns
43
+ */
44
+ export declare function useEffect(effect: () => void, ActiveRef: Ref): void;
45
+ /**
46
+ * Cradova
47
+ * ---
48
+ Returns a mutable reference object of dom elements that persists across component renders.
49
+ * @returns reference
50
+ */
51
+ export declare function useRef(): Record<string, HTMLElement | undefined>;
52
+ export {};
@@ -0,0 +1,89 @@
1
+ import * as CSS from "csstype";
2
+ import { Ref, Screen, reference } from "./classes";
3
+ type DataAttributes = {
4
+ [key: `data-${string}`]: string;
5
+ };
6
+ type AriaAttributes = {
7
+ [key: `aria-${string}`]: string;
8
+ };
9
+ type Attributes = {
10
+ src?: string;
11
+ alt?: string;
12
+ for?: string;
13
+ rel?: string;
14
+ href?: string;
15
+ type?: string;
16
+ name?: string;
17
+ rows?: string;
18
+ value?: string;
19
+ accept: string;
20
+ action?: string;
21
+ target?: string;
22
+ method?: string;
23
+ checked?: boolean;
24
+ required?: string;
25
+ frameBorder?: string;
26
+ placeholder?: string;
27
+ reference?: reference;
28
+ autocomplete?: string;
29
+ style?: CSS.Properties;
30
+ updateState?: (P: any) => void;
31
+ onmount?: (this: HTMLElement & Attributes) => void;
32
+ };
33
+ export type VJS_params_TYPE = (Ref | Ref[] | string | undefined | HTMLElement | HTMLElement[] | DocumentFragment | Attributes | (() => HTMLElement) | Partial<Attributes> | Partial<HTMLDivElement> | Partial<DataAttributes> | Partial<AriaAttributes> | CSS.Properties<string | number>)[];
34
+ export interface RouterRouteObject {
35
+ _html: ((this: Screen, data?: unknown) => HTMLElement | DocumentFragment) | HTMLElement | DocumentFragment;
36
+ _delegatedRoutes: number | boolean;
37
+ _Activate: (force: boolean) => Promise<void>;
38
+ _deActivate: (params: object) => void;
39
+ _package: (params: unknown) => void;
40
+ _errorHandler: ((err: unknown) => void) | null;
41
+ _derive(): {
42
+ _name: string;
43
+ _callBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
44
+ _deCallBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
45
+ };
46
+ _apply_derivation(data: {
47
+ _name: string;
48
+ _callBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
49
+ _deCallBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
50
+ }): unknown;
51
+ }
52
+ export type CradovaScreenType = {
53
+ /**
54
+ * Cradova screen
55
+ * ---
56
+ * title of the page
57
+ * .
58
+ */
59
+ name?: string;
60
+ /**
61
+ * Cradova screen
62
+ * ---
63
+ * The component for the screen
64
+ * @param data
65
+ * @returns void
66
+ * .
67
+ */
68
+ template: (this: Screen) => Element | Ref;
69
+ /**
70
+ * Cradova screen
71
+ * ---
72
+ * Allows this screen render in parallel for unique routes
73
+ *
74
+ * limit is 1000
75
+ *
76
+ * .
77
+ */
78
+ renderInParallel?: boolean;
79
+ /**
80
+ * Cradova screen
81
+ * ---
82
+ * Should this screen be cached after first render?
83
+ * you can use Route.navigate(url, null, true) to force later
84
+ *
85
+ * .
86
+ */
87
+ persist?: boolean;
88
+ };
89
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cradova",
3
- "version": "3.3.4",
3
+ "version": "3.3.5",
4
4
  "description": "Web framework for building powerful web apps",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",