cradova 3.3.3 → 3.3.4

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 CHANGED
@@ -511,9 +511,9 @@ Join Us on [telegram](https://t.me/UiedbookHQ).
511
511
 
512
512
  If you contribute code to this project, you are implicitly allowing your code to be distributed under same license. You are also implicitly verifying that all code is your original work.
513
513
 
514
- ## Supporting Exabase development
514
+ ## Supporting Cradova development
515
515
 
516
- Your Support is a good force for change anytime you do it, you can ensure Our projects, growth, Cradova, Exabase, JetPath etc, growth and improvement by making a re-occuring or fixed sponsorship
516
+ Your Support is a good force for change anytime you do it, you can ensure Our projects, growth, Cradova, Cradova, JetPath etc, growth and improvement by making a re-occuring or fixed sponsorship
517
517
  to [github sponsors](https://github.com/sponsors/FridayCandour):
518
518
  or crypto using
519
519
  etheruen: `0xD7DDD4312A4e514751A582AF725238C7E6dF206c`,
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "cradova",
3
- "version": "3.3.3",
3
+ "version": "3.3.4",
4
4
  "description": "Web framework for building powerful web apps",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
7
7
  "files": [
8
8
  "dist/index.d.ts",
9
+ "dist/primitives/**",
9
10
  "dist/index.js"
10
11
  ],
11
12
  "repository": {
@@ -65,9 +66,7 @@
65
66
  "eslint": "^8.30.0",
66
67
  "eslint-config-prettier": "^8.5.0",
67
68
  "eslint-plugin-prettier": "^4.2.1",
68
- "prettier": "^2.8.1",
69
- "tsup": "^6.7.0",
70
- "typescript": "^4.9.4"
69
+ "prettier": "^2.8.1"
71
70
  },
72
71
  "dependencies": {
73
72
  "csstype": "^3.1.2"
package/dist/index.d.ts DELETED
@@ -1,624 +0,0 @@
1
- import * as CSS from 'csstype';
2
-
3
- /*! *****************************************************************************
4
- Copyright 2022 Friday Candour. All rights reserved.
5
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
6
- this file except in compliance with the License. You may obtain a copy of the
7
- License at http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- See the Apache Version 2.0 License for specific language governing permissions
10
- and limitations under the License.
11
- ********************************************************************************/
12
-
13
- /**
14
- * Cradova event
15
- */
16
- declare class cradovaEvent {
17
- private listeners;
18
- private active_listeners;
19
- addEventListener(eventName: string, callback: () => void): Promise<void>;
20
- addActiveEventListener(eventName: string, callback: () => void): Promise<void>;
21
- dispatchEvent(eventName: string, eventArgs?: unknown): Promise<void>;
22
- /**
23
- * Active refs is a concept for delegated screens to keep their active refs alive
24
- * even in the case of naviagtion
25
- * @param eventName
26
- * @param eventArgs
27
- */
28
- dispatchActiveEvent(eventName: string, eventArgs?: unknown): Promise<void>;
29
- }
30
- declare const CradovaEvent: cradovaEvent;
31
- /**
32
- * Cradova Ref
33
- * -------
34
- * create dynamic components
35
- */
36
- declare class Ref<Prop extends Record<string, any> = any> {
37
- private component;
38
- private effects;
39
- private effectuate;
40
- methods: Record<string, Function>;
41
- private rendered;
42
- private published;
43
- private preRendered;
44
- private reference;
45
- Signal: createSignal<any> | undefined;
46
- _state: Prop[];
47
- _state_track: {
48
- [x: number]: boolean;
49
- };
50
- _state_index: number;
51
- stash: Prop | undefined;
52
- constructor(component: (this: Ref<Prop>, data: Prop) => HTMLElement | DocumentFragment);
53
- preRender(data?: Prop, stash?: boolean): void;
54
- destroyPreRendered(): void;
55
- /**
56
- * Cradova Ref
57
- * ---
58
- * construct to add custom methods to Refs
59
- * @param methodName
60
- * @param method
61
- * @returns void
62
- */
63
- define(methodName: string, method: (this: this, ...arg: any) => void): void;
64
- /**
65
- * Cradova Ref
66
- * ---
67
- * returns html with cradova reference
68
- * @param data
69
- * @returns () => HTMLElement
70
- */
71
- render(data?: Prop, stash?: boolean): HTMLElement | DocumentFragment;
72
- instance(): HTMLElement;
73
- _setExtra(Extra: createSignal<any>): void;
74
- _roll_state(data: any, idx: number, get?: boolean): Prop;
75
- _effect(fn: () => Promise<void> | void): void;
76
- private effector;
77
- /**
78
- * Cradova Ref
79
- * ---
80
- * update ref component with new data and update the dom.
81
- * @param data
82
- * @returns
83
- */
84
- updateState(data?: Prop, stash?: boolean): void;
85
- private Activate;
86
- }
87
- /**
88
- * cradova
89
- * ---
90
- * lazy load a file
91
- */
92
- declare class lazy<Type> {
93
- content: Type | undefined;
94
- private _cb;
95
- constructor(cb: () => Promise<unknown>);
96
- load(): Promise<void>;
97
- }
98
- /**
99
- * Cradova
100
- * ---
101
- * make reference to dom elements
102
- */
103
- declare class reference {
104
- tree: Record<string, any>;
105
- globalTree: Record<string, HTMLElement>;
106
- /**
107
- * Bind a DOM element to a reference name.
108
- * @param name - The name to reference the DOM element by.
109
- */
110
- bindAs(name: string): reference;
111
- /**
112
- * Retrieve a referenced DOM element.
113
- * @param name - The name of the referenced DOM element.
114
- */
115
- current<ElementType extends HTMLElement = HTMLElement>(name: string): ElementType;
116
- /**
117
- * Append a DOM element to the reference, overwriting any existing reference.
118
- * @param name - The name to reference the DOM element by.
119
- * @param element - The DOM element to reference.
120
- */
121
- _appendDomForce(name: string, Element: HTMLElement): void;
122
- _appendDomForceGlobal(name: string, Element: HTMLElement): void;
123
- }
124
- /**
125
- * Cradova Signal
126
- * ----
127
- * Create stateful data store.
128
- * Features:
129
- * - create a store
130
- * - create actions and fire them
131
- * - bind a Ref and elements
132
- * - listen to updates
133
- * - set object keys instead of all values
134
- * - persist changes to localStorage
135
- * - update a cradova Ref automatically
136
- * @constructor initial: unknown, props: {useHistory, persist}
137
- */
138
- declare class createSignal<Type extends Record<string, any>> {
139
- private callback;
140
- private persistName;
141
- private actions;
142
- private ref;
143
- value: Type;
144
- constructor(initial: Type, props?: {
145
- persistName?: string | undefined;
146
- });
147
- /**
148
- * Cradova Signal
149
- * ----
150
- * set signal value
151
- * @param value - signal value
152
- * @returns void
153
- */
154
- set(value: Type | ((value: Type) => Type), shouldRefRender?: boolean): void;
155
- /**
156
- * Cradova Signal
157
- * ----
158
- * set a key value if it's an object
159
- * @param key - key of the key
160
- * @param value - value of the key
161
- * @returns void
162
- */
163
- setKey<k extends keyof Type>(key: k, value: unknown, shouldRefRender?: boolean): void;
164
- /**
165
- * Cradova Signal
166
- * ----
167
- * set a key to signal an action
168
- * @param name - name of the action
169
- * @param action function to execute
170
- */
171
- createAction(name: string, action: (data?: unknown) => void): void;
172
- /**
173
- * Cradova Signal
174
- * ----
175
- * creates man y actions at a time
176
- * @param name - name of the action
177
- * @param action function to execute
178
- */
179
- createActions(Actions: Record<string, (data?: unknown) => void>): void;
180
- /**
181
- * Cradova Signal
182
- * ----
183
- * fires an action if available
184
- * @param key - string key of the action
185
- * @param data - data for the action
186
- */
187
- fireAction(key: string, data?: Type): Type;
188
- /**
189
- * Cradova
190
- * ---
191
- * is used to bind signal data to elements and Refs
192
- *
193
- * @param prop
194
- * @returns something
195
- */
196
- bind(prop: string): any;
197
- private _updateState;
198
- /**
199
- * Cradova Signal
200
- * ----
201
- * set a auto - rendering component for this store
202
- *
203
- * @param Ref component to bind to.
204
- * @param path a property in the object to send to attached ref
205
- */
206
- bindRef(ref: Partial<Ref>, binding?: {
207
- event?: string;
208
- signalProperty: string;
209
- _element_property: string;
210
- }): void;
211
- /**
212
- * Cradova Signal
213
- * ----
214
- * set a update listener on value changes
215
- * @param callback
216
- */
217
- listen(callback: (a: Type) => void): void;
218
- /**
219
- * Cradova Signal
220
- * ----
221
- * clear the history on local storage
222
- *
223
- */
224
- clearPersist(): void;
225
- }
226
- /**
227
- * Cradova Screen
228
- * ---
229
- * create instances of manageable pages
230
- * @param name
231
- * @param template
232
- */
233
- declare class Screen$1 {
234
- /**
235
- * used internally
236
- */
237
- private _name;
238
- /**
239
- * this should be a cradova screen component
240
- */
241
- _html: ((this: Screen$1, data?: unknown) => HTMLElement | DocumentFragment) | HTMLElement | DocumentFragment;
242
- _packed: boolean;
243
- private _template;
244
- private _callBack;
245
- private _deCallBack;
246
- private _persist;
247
- private _delegatedRoutesCount;
248
- private _dropped;
249
- /**
250
- * error handler for the screen
251
- */
252
- _errorHandler: ((err: unknown) => void) | null;
253
- constructor(cradova_screen_initials: CradovaScreenType);
254
- _derive(): {
255
- _name: string;
256
- _callBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
257
- _deCallBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
258
- };
259
- _apply_derivation(derivation: {
260
- _name: string;
261
- _callBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
262
- _deCallBack: ((cradovaScreenSet: HTMLElement) => void | Promise<void>) | undefined;
263
- }): void;
264
- get _delegatedRoutes(): number;
265
- set _delegatedRoutes(count: number);
266
- setErrorHandler(errorHandler: (err: unknown) => void): void;
267
- _package(): Promise<void>;
268
- onActivate(cb: () => Promise<void> | void): void;
269
- onDeactivate(cb: () => Promise<void> | void): void;
270
- _deActivate(): Promise<void>;
271
- drop(state?: boolean): boolean | undefined;
272
- _Activate(force?: boolean): Promise<void>;
273
- }
274
- /** cradova router
275
- * ---
276
- * Registers a route.
277
- *
278
- * @param {string} path Route path.
279
- * @param screen the cradova document tree for the route.
280
- */
281
- declare class Router {
282
- /** cradova router
283
- * ---
284
- * Registers a route.
285
- *
286
- * accepts an object containing
287
- *
288
- * @param {string} path Route path.
289
- * @param screen the cradova screen.
290
- */
291
- static BrowserRoutes(obj: Record<string, any>): void;
292
- /**
293
- Go back in Navigation history
294
- */
295
- static back(): void;
296
- /**
297
- Go forward in Navigation history
298
- */
299
- static forward(): void;
300
- /**
301
- Pause navigation
302
- */
303
- static pauseNaviagtion(): void;
304
- /**
305
- resume navigation
306
- */
307
- static resumeNaviagtion(): void;
308
- /**
309
- * Cradova Router
310
- * ------
311
- *
312
- * Navigates to a designated screen in your app
313
- *
314
- * @param href string
315
- * @param data object
316
- * @param force boolean
317
- */
318
- static navigate(href: string, data?: Record<string, unknown> | null, force?: boolean): void;
319
- /**
320
- * Cradova Router
321
- * ------
322
- *
323
- * Navigates to a designated screen in your app by loading a seperate page;
324
- *
325
- * @param pathname string
326
- */
327
- static navigateNauturally(pathname: string): void;
328
- /**
329
- * Cradova
330
- * ---
331
- * Loading screen for your app
332
- *
333
- * lazy loaded loading use
334
- *
335
- * @param screen
336
- */
337
- static setLoadingScreen(screen: Screen$1): void;
338
- /** cradova router
339
- * ---
340
- * Listen for navigation events
341
- *
342
- * @param callback () => void
343
- */
344
- static onPageEvent(callback: () => void): void;
345
- /** cradova router
346
- * ---
347
- * get a screen ready before time.
348
- *
349
- * @param {string} path Route path.
350
- * @param data data for the screen.
351
- */
352
- static packageScreen(path: string): Promise<void>;
353
- /**
354
- * Cradova Router
355
- * ------
356
- *
357
- * return last set router params
358
- *
359
- * .
360
- */
361
- static getParams(): Record<string, unknown>;
362
- /**
363
- * Cradova
364
- * ---
365
- * Error Handler for your app
366
- *
367
- * @param callback
368
- * @param path? page path
369
- */
370
- static addErrorHandler(callback: (err: unknown) => void): void;
371
- static _mount(): void;
372
- }
373
-
374
- /*! *****************************************************************************
375
- Copyright 2022 Friday Candour. All rights reserved.
376
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
377
- this file except in compliance with the License. You may obtain a copy of the
378
- License at http://www.apache.org/licenses/LICENSE-2.0
379
-
380
- See the Apache Version 2.0 License for specific language governing permissions
381
- and limitations under the License.
382
- ***************************************************************************** */
383
-
384
- type DataAttributes = {
385
- [key: `data-${string}`]: string;
386
- };
387
- type AriaAttributes = {
388
- [key: `aria-${string}`]: string;
389
- };
390
- type VJSType<T> = (...VJS: (undefined | string | HTMLElement | HTMLElement[] | Ref | Ref[] | DocumentFragment | DocumentFragment[] | TemplateStringsArray | Partial<T> | (() => HTMLElement) | Partial<DataAttributes> | Partial<AriaAttributes> | CSS.Properties | {
391
- style?: CSS.Properties;
392
- onmount?: (this: T) => void;
393
- reference?: reference;
394
- })[]) => T;
395
- type VJS_params_TYPE<T> = (undefined | string | HTMLElement | HTMLElement[] | Ref | Ref[] | DocumentFragment | DocumentFragment[] | TemplateStringsArray | Partial<T> | (() => HTMLElement) | Partial<DataAttributes> | Partial<AriaAttributes> | CSS.Properties<string | number> | {
396
- src?: string;
397
- href?: string;
398
- placeholder?: string;
399
- type?: string;
400
- action?: string;
401
- name?: string;
402
- alt?: string;
403
- for?: string;
404
- method?: string;
405
- rows?: string;
406
- value?: string;
407
- target?: string;
408
- rel?: string;
409
- required?: string;
410
- frameBorder?: string;
411
- style?: CSS.Properties;
412
- onmount?: (this: T) => void;
413
- reference?: reference;
414
- })[];
415
- type VJS_Child_TYPE<T> = undefined | string | T | (() => T);
416
- type VJS_props_TYPE = {
417
- style?: CSS.Properties;
418
- onmount?: () => void;
419
- reference?: reference;
420
- };
421
- type CradovaScreenType<T = unknown> = {
422
- /**
423
- * Cradova screen
424
- * ---
425
- * title of the page
426
- * .
427
- */
428
- name?: string;
429
- /**
430
- * Cradova screen
431
- * ---
432
- * a css className to add to screen when rendering it
433
- * Usually for adding css transitions
434
- * .
435
- */
436
- /**
437
- * Cradova screen
438
- * ---
439
- * The component for the screen
440
- * @param data
441
- * @returns void
442
- * .
443
- */
444
- template: ((this: Screen, data?: T | unknown) => HTMLElement | DocumentFragment) | HTMLElement | DocumentFragment | Ref<any>;
445
- /**
446
- * Cradova screen
447
- * ---
448
- * Allows this screen render in parallel for unique routes
449
- *
450
- * limit is 1000
451
- *
452
- * .
453
- */
454
- renderInParallel?: boolean;
455
- /**
456
- * Cradova screen
457
- * ---
458
- * Should this screen be cached after first render?
459
- * you can use Route.navigate(url, null, true) to force later
460
- *
461
- * .
462
- */
463
- persist?: boolean;
464
- };
465
-
466
- /*! *****************************************************************************
467
- Copyright 2022 Friday Candour. All rights reserved.
468
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
469
- this file except in compliance with the License. You may obtain a copy of the
470
- License at http://www.apache.org/licenses/LICENSE-2.0
471
-
472
- See the Apache Version 2.0 License for specific language governing permissions
473
- and limitations under the License.
474
- ********************************************************************************/
475
-
476
- declare const makeElement: <E extends HTMLElement>(element: E & HTMLElement, ElementChildrenAndPropertyList: VJS_params_TYPE<E>) => E;
477
- declare const make: (descriptor: any) => any[];
478
- declare const cra: <E extends HTMLElement>(tag: string) => VJSType<E>;
479
- declare function Rhoda(l: VJSType<HTMLElement>[] | (() => any)[] | Ref[] | HTMLElement[]): DocumentFragment;
480
- declare function css(identifier: string | TemplateStringsArray): void;
481
- /**
482
- *
483
- * @param {expression} condition
484
- * @param {function} elements[]
485
- */
486
- declare function $if<Type>(condition: boolean, ...elements: VJS_Child_TYPE<Type | HTMLElement>[]): HTMLElement[] | undefined;
487
- declare function $ifelse<Type>(condition: boolean, ifTrue: VJS_Child_TYPE<Type | HTMLElement> | VJS_Child_TYPE<Type | HTMLElement>[], ifFalse: VJS_Child_TYPE<Type | HTMLElement> | VJS_Child_TYPE<Type | HTMLElement>[]): VJS_Child_TYPE<HTMLElement | Type> | VJS_Child_TYPE<HTMLElement | Type>[];
488
- declare function $case<Type>(value: any, ...elements: VJS_Child_TYPE<Type | HTMLElement>[]): (key: any) => HTMLElement[] | undefined;
489
- declare function $switch(key: unknown, ...cases: ((key: any) => HTMLElement[] | undefined)[]): HTMLElement[] | undefined;
490
- type LoopData<Type> = Type[];
491
- declare function loop<Type>(datalist: LoopData<Type>, component: (value: Type, index?: number, array?: LoopData<Type>) => HTMLElement | DocumentFragment | undefined): HTMLElement[] | undefined;
492
- /** Calculate a simple numerical representation of the URL */
493
- declare const SNRU: {
494
- snru: string;
495
- memo_SNRU(): void;
496
- };
497
- /**
498
- * Document fragment
499
- * @param children
500
- * @returns
501
- */
502
- declare const frag: (children: VJSType<HTMLElement>[]) => DocumentFragment;
503
- /**
504
- * Cradova
505
- * ---
506
- * Allows functional components to manage state by providing a state value and a function to update it.
507
- * @param initialValue
508
- * @param ActiveRef
509
- * @returns [state, setState]
510
- */
511
- declare function useState<S = unknown>(initialValue: S, ActiveRef: Ref): [S, (newState: S) => void];
512
- /**
513
- * Cradova
514
- * ---
515
- Allows side effects to be performed in functional components (Refs), such as fetching data or subscribing to events.
516
- * @param effect
517
- * @returns
518
- */
519
- declare function useEffect(effect: () => void, ActiveRef: Ref): void;
520
- /**
521
- * Cradova
522
- * ---
523
- Returns a mutable reference object of dom elements that persists across component renders.
524
- * @returns reference
525
- */
526
- declare function useRef(): Record<string, HTMLElement | undefined>;
527
-
528
- declare const a: VJSType<HTMLAnchorElement>;
529
- declare const article: VJSType<HTMLElement>;
530
- declare const audio: VJSType<HTMLAudioElement>;
531
- declare const br: VJSType<HTMLBRElement>;
532
- declare const button: VJSType<HTMLButtonElement>;
533
- declare const canvas: VJSType<HTMLCanvasElement>;
534
- declare const caption: VJSType<HTMLTableCaptionElement>;
535
- declare const col: VJSType<HTMLTableColElement>;
536
- declare const colgroup: VJSType<HTMLOptGroupElement>;
537
- declare const datalist: VJSType<HTMLDataListElement>;
538
- declare const details: VJSType<HTMLDetailsElement>;
539
- declare const dialog: VJSType<HTMLDialogElement>;
540
- declare const div: VJSType<HTMLDivElement>;
541
- declare const em: VJSType<HTMLElement>;
542
- declare const embed: VJSType<HTMLEmbedElement>;
543
- declare const figure: VJSType<HTMLElement>;
544
- declare const footer: VJSType<HTMLElement>;
545
- declare const form: VJSType<HTMLFormElement>;
546
- declare const h1: VJSType<HTMLHeadingElement>;
547
- declare const h2: VJSType<HTMLHeadingElement>;
548
- declare const h3: VJSType<HTMLHeadingElement>;
549
- declare const h4: VJSType<HTMLHeadingElement>;
550
- declare const h5: VJSType<HTMLHeadingElement>;
551
- declare const h6: VJSType<HTMLHeadingElement>;
552
- declare const head: VJSType<HTMLHeadElement>;
553
- declare const header: VJSType<HTMLHeadElement>;
554
- declare const hr: VJSType<HTMLHRElement>;
555
- declare const i: VJSType<HTMLLIElement>;
556
- declare const iframe: VJSType<HTMLIFrameElement>;
557
- declare const img: VJSType<HTMLImageElement>;
558
- declare const input: VJSType<HTMLInputElement>;
559
- declare const label: VJSType<HTMLLabelElement>;
560
- declare const li: VJSType<HTMLLIElement>;
561
- declare const main: VJSType<HTMLElement>;
562
- declare const nav: VJSType<HTMLElement>;
563
- declare const ol: VJSType<HTMLOListElement>;
564
- declare const optgroup: VJSType<HTMLOptGroupElement>;
565
- declare const option: VJSType<HTMLOptionElement>;
566
- declare const p: VJSType<HTMLParagraphElement>;
567
- declare const progress: VJSType<HTMLProgressElement>;
568
- declare const q: VJSType<HTMLQuoteElement>;
569
- declare const section: VJSType<HTMLElement>;
570
- declare const select: VJSType<HTMLSelectElement>;
571
- declare const source: VJSType<HTMLSourceElement>;
572
- declare const span: VJSType<HTMLSpanElement>;
573
- declare const strong: VJSType<HTMLElement>;
574
- declare const summary: VJSType<HTMLElement>;
575
- declare const table: VJSType<HTMLTableElement>;
576
- declare const tbody: VJSType<HTMLTableColElement>;
577
- declare const td: VJSType<HTMLTableCellElement>;
578
- declare const template: VJSType<HTMLTemplateElement>;
579
- declare const textarea: VJSType<HTMLTextAreaElement>;
580
- declare const th: VJSType<HTMLTableSectionElement>;
581
- declare const title: VJSType<HTMLTitleElement>;
582
- declare const tr: VJSType<HTMLTableRowElement>;
583
- declare const track: VJSType<HTMLTrackElement>;
584
- declare const u: VJSType<HTMLUListElement>;
585
- declare const ul: VJSType<HTMLUListElement>;
586
- declare const video: VJSType<HTMLVideoElement>;
587
- declare const svg: (svg: string, properties?: VJS_props_TYPE) => HTMLSpanElement;
588
- declare const raw: (html: string) => HTMLElement[];
589
-
590
- /*! *****************************************************************************
591
- Copyright 2022 Friday Candour. All rights reserved.
592
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
593
- this file except in compliance with the License. You may obtain a copy of the
594
- License at http://www.apache.org/licenses/LICENSE-2.0
595
-
596
- See the Apache Version 2.0 License for specific language governing permissions
597
- and limitations under the License.
598
- ********************************************************************************/
599
-
600
- type TemplateType = <E extends HTMLElement>(...element_initials: VJS_params_TYPE<E | HTMLElement>) => E | HTMLElement | DocumentFragment;
601
- /**
602
- * Cradova
603
- * ---
604
- * Creates new cradova HTML element
605
- * @example
606
- * // using template
607
- * const p = _("p");
608
- * _("p.foo.bar#poo.loo");
609
- *
610
- * // full example
611
- * _("p", // template first
612
- * // property next if wanted
613
- * {style: {color: "brown"}, // optional
614
- * // the rest should be children or text
615
- * _("span", " am a span tag text like so"),
616
- * ...
617
- * )
618
- *
619
- * @param element_initials
620
- * @returns function - cradova element
621
- */
622
- declare const _: TemplateType;
623
-
624
- export { $case, $if, $ifelse, $switch, CradovaEvent, Ref, Rhoda, Router, SNRU, Screen$1 as Screen, a, article, audio, br, button, canvas, caption, col, colgroup, cra, createSignal, css, datalist, _ as default, details, dialog, div, em, embed, figure, footer, form, frag, h1, h2, h3, h4, h5, h6, head, header, hr, i, iframe, img, input, label, lazy, li, loop, main, make, makeElement, nav, ol, optgroup, option, p, progress, q, raw, reference, section, select, source, span, strong, summary, svg, table, tbody, td, template, textarea, th, title, tr, track, u, ul, useEffect, useRef, useState, video };
package/dist/index.js DELETED
@@ -1,3 +0,0 @@
1
- var v=class{constructor(){this.listeners={};this.active_listeners={};}async addEventListener(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t);}async addActiveEventListener(e,t){this.active_listeners[e]||(this.active_listeners[e]=[]),this.active_listeners[e].push(t);}async dispatchEvent(e,t){let n=this.listeners[e]||[];for(;n.length!==0;)n.shift()(t);}async dispatchActiveEvent(e,t){let n=this.active_listeners[e]||[];n.length&&p.memo_SNRU();for(let o=0;o<n.length;o++)n[o](t);}},f=new v,h=class{constructor(e){this.effects=[];this.effectuate=null;this.methods={};this.rendered=!1;this.published=!1;this.preRendered=null;this.reference=new u;this._state=[];this._state_track={};this._state_index=0;this.component=e.bind(this),f.addActiveEventListener("active-Refs",()=>{this._state_index=0,this.published=!1;});}preRender(e,t){this.preRendered=this.render(e,t);}destroyPreRendered(){this.preRendered=null;}define(e,t){typeof e=="string"&&typeof t=="function"&&!Object.prototype.hasOwnProperty.call(this,e)?this.methods[e]=t.bind(this):console.error(" \u2718 Cradova err : Invalid Ref.define parameters");}render(e,t){if(this.effects=[],this.rendered=!1,t&&(this.stash=e),this.preRendered)return this.preRendered;{let n=this.component(e);return n instanceof HTMLElement||n instanceof DocumentFragment?(this.reference._appendDomForce("html",n),this.effector.apply(this),this.rendered=!0,this.published=!0):console.error(" \u2718 Cradova err : Invalid html content, got - "+n),n}}instance(){return this.reference.current("html")}_setExtra(e){this.Signal=e;}_roll_state(e,t,n=!1){return n||(this._state[t]=e),this._state[t]}_effect(e){this.rendered||this.effects.push(e.bind(this));}async effector(){console.log("yoohoo 2");for(let e=0;e<this.effects.length;e++)await this.effects[e].apply(this);this.effects=[],this.effectuate&&(this.effectuate(),this.effectuate=null);}updateState(e,t){this.rendered?this.published&&this.Activate(e):this.effectuate=()=>{this.published&&this.Activate(e);},t&&(this.stash=e);}async Activate(e){if(this._state_index=0,this.published=!1,!this.rendered)return;let t=this.component(e);if(t instanceof HTMLElement||t instanceof DocumentFragment){let n=this.reference.current("html");n&&(n.insertAdjacentElement("beforebegin",t),n.remove()),this.published=!0,this.reference._appendDomForce("html",t),f.dispatchEvent("onmountEvent");}else console.error(" \u2718 Cradova err : Invalid html content, got - "+t);}},w=class{constructor(e){this._cb=e;}async load(){let e=await this._cb();typeof e=="function"?e=await e():e=await e;let t=e;t.default&&(this.content=t?.default);}},u=class{constructor(){this.tree={};this.globalTree={};}bindAs(e){return [this,e]}current(e){return this.tree[p.snru]?this.tree[p.snru][e]:null}_appendDomForce(e,t){this.tree[p.snru]?this.tree[p.snru][e]=t:(this.tree[p.snru]={},this.tree[p.snru][e]=t);}_appendDomForceGlobal(e,t){this.globalTree[e]=t;}},d=new u,T=class{constructor(e,t){this.persistName="";this.actions={};this.ref=[];if(this.value=e,t&&t.persistName){this.persistName=t.persistName;let n=localStorage.getItem(t.persistName);if(n&&n!=="undefined"&&(this.value=JSON.parse(n)),typeof e=="object")for(let o in e)Object.prototype.hasOwnProperty.call(this.value,o)||(this.value[o]=e[o]);}}set(e,t){typeof e=="function"?this.value=e(this.value):this.value=e,this.persistName&&localStorage.setItem(this.persistName,JSON.stringify(this.value)),this.ref.length&&t!==!1&&this._updateState(),this.callback&&this.callback(this.value);}setKey(e,t,n){if(typeof this.value=="object"&&!Array.isArray(this.value))this.value[e]=t,this.persistName&&localStorage.setItem(this.persistName,JSON.stringify(this.value)),this.ref.length&&n!==!1&&this._updateState(),this.callback&&this.callback(this.value);else throw new Error(`\u2718 Cradova err : can't set key ${String(e)} . store.value is not a javascript object`)}createAction(e,t){if(typeof e=="string"&&typeof t=="function")this.actions[e]=t;else throw new Error(`\u2718 Cradova err : can't create action, ${e} is not a function`)}createActions(e){for(let[t,n]of Object.entries(e))if(typeof t=="string"&&typeof n=="function")this.actions[t]=n;else throw new Error(`\u2718 Cradova err : can't create action, ${t} is not a function`)}fireAction(e,t){if(this._updateState(e,t),typeof this.actions[e]=="function")return this.actions[e].call(this,t);throw Error("\u2718 Cradova err : action "+e+" does not exist!")}bind(e){if(typeof this.value=="object"&&typeof this.value[e]<"u")return [this,e];throw new Error("\u2718 Cradova err : can't bind an unavailable property! "+e)}_updateState(e,t){if(e&&t)this.ref.map(n=>{if(n._event===e){if(n._element_property&&n._signalProperty){n.ref?.updateState({[n._element_property]:t[n._signalProperty]});return}if(n._element_property){n.ref.updateState({[n._element_property]:t});return}if(n._signalProperty){n.ref.updateState(t[n._signalProperty]);return}}});else for(let n=0;n<this.ref.length;n++){let o=this.ref[n];if(o._element_property&&o._signalProperty){o.ref.updateState({[o._element_property]:this.value[o._signalProperty]});continue}if(o._element_property){o.ref.updateState({[o._element_property]:this.value});continue}if(o._signalProperty){o.ref.updateState(this.value[o._signalProperty]);continue}if(!o._element_property&&!o._signalProperty){o.ref.updateState(this.value);continue}}}bindRef(e,t={signalProperty:"",_element_property:""}){if(e.render&&(e.render=e.render.bind(e,this.value)),e._setExtra&&e._setExtra(this),e&&e.updateState){this.ref.push({ref:e,_signalProperty:t.signalProperty,_element_property:t._element_property,_event:t.event});return}throw new Error("\u2718 Cradova err : Invalid parameters for binding ref to Signal")}listen(e){this.callback=e;}clearPersist(){this.persistName&&localStorage.removeItem(this.persistName);}},m=class{constructor(e){this._packed=!1;this._template=document.createElement("div");this._persist=!0;this._delegatedRoutesCount=-1;this._dropped=!1;this._errorHandler=null;let{template:t,name:n,persist:o,renderInParallel:i}=e;t instanceof h?this._html=()=>t.render({}):this._html=t,this._name=n||"Document",this._template.setAttribute("id","cradova-screen-set"),i===!0?(this._delegatedRoutesCount=0,this._persist=!1):typeof o=="boolean"&&(this._persist=o);}_derive(){return {_name:this._name,_callBack:this._callBack,_deCallBack:this._deCallBack}}_apply_derivation(e){this._name=e._name,this._callBack=e._callBack,this._deCallBack=e._deCallBack;}get _delegatedRoutes(){return this._delegatedRoutesCount>100?-1:this._delegatedRoutesCount}set _delegatedRoutes(e){e&&(this._delegatedRoutesCount+=1);}setErrorHandler(e){this._errorHandler=e;}async _package(){if(p.memo_SNRU(),typeof this._html=="function"){let e=await this._html.apply(this);if(typeof e=="function")e=e(),(e instanceof HTMLElement||e instanceof DocumentFragment)&&(this._template.innerHTML="",this._template.appendChild(e));else if(e instanceof HTMLElement||e instanceof DocumentFragment)this._template.innerHTML="",this._template.appendChild(e);else throw new Error(` \u2718 Cradova err: template function for the screen with name '${this._name}' returned ${e} instead of html`)}}onActivate(e){this._callBack=e;}onDeactivate(e){this._deCallBack=e;}async _deActivate(){this._deCallBack&&await this._deCallBack(d.globalTree.doc);}drop(e){if(typeof e=="boolean"){this._dropped=e;return}else return this._dropped}async _Activate(e=!1){if(this._dropped){history.go(-1);return}f.dispatchActiveEvent("active-Refs"),(!this._persist||e||!this._packed)&&(await this._package(),this._packed=!0),document.title=this._name,d.globalTree.doc.innerHTML="",d.globalTree.doc.appendChild(this._template),f.dispatchEvent("onmountEvent"),window.scrollTo({top:0,left:0,behavior:"instant"}),this._callBack&&await this._callBack(d.globalTree.doc);}},E=class{constructor(){this.pageShow=null;this.pageHide=null;this.loadingScreen=null;this.params={};this.routes={};this.pageevents=[];this.paused=!1;}async start_pageevents(e){setTimeout(()=>{for(let t=0;t<this.pageevents.length;t++)this.pageevents[t](e);},100);}route(e,t){if(typeof t<"u"){if(t&&!t)throw console.error(" \u2718 Cradova err: not a valid screen ",t),new Error(" \u2718 Cradova err: Not a valid cradova screen component");return this.routes[e]=t}}async router(e,t){let n=window.location.pathname,o,i;if(this.paused){window.location.hash="paused";return}if(n!==this.lastNavigatedRoute)if(this.nextRouteController?(o=this.nextRouteController,this.nextRouteController=void 0):[o,i]=this.checker(n),typeof o<"u")try{if(typeof o=="function"&&(this.loadingScreen instanceof m&&await this.loadingScreen._Activate(),o=await o(),!o)){this.lastNavigatedRoute&&history.pushState({},n,this.lastNavigatedRoute);return}if(o._delegatedRoutes!==-1){o._delegatedRoutes=1;let l=o._derive();o=new m({template:o._html}),o._apply_derivation(l),this.routes[n]=o;}i&&(this.params.params=i),await o._Activate(t),this.start_pageevents(n),this.lastNavigatedRouteController&&this.lastNavigatedRouteController._deActivate(),this.lastNavigatedRoute=n,this.lastNavigatedRouteController=o;}catch(l){if(o&&o._errorHandler)o._errorHandler(l);else if(typeof this.errorHandler=="function")this.errorHandler(Error);else throw console.error(l),new Error(" \u2718 Cradova err: consider adding error boundary to the specific screen ")}else this.routes["*"]&&await this.routes["*"]._Activate(t);}checker(e){if(this.routes[e])return [this.routes[e],{path:e}];if(this.routes[e+"/"])return [this.routes[e],{path:e}];for(let t in this.routes){if(!t.includes(":"))continue;let n=e.split("/"),o=t.split("/");e.endsWith("/")&&n.pop();let i=0,l=0;if(n.shift(),o.shift(),o.length===n.length){let y={_path:""};for(let c=0;c<o.length;c++){if(o[c].includes(":")){l++;continue}n[c]===o[c]&&i++;}if(i+l===o.length){for(let c=0;c<o.length;c++)o[c].includes(":")&&(y[o[c].split(":")[1]]=n[c]);return y._path=t,[this.routes[t],y]}}}return []}},s=new E,g=class{static BrowserRoutes(e){for(let t in e){let n=e[t];typeof n=="object"&&typeof n.then=="function"||typeof n=="function"?s.routes[t]=async()=>(n=await(typeof n=="function"?await n():await n),s.route(t,n?.default||n)):s.route(t,n);}g._mount();}static back(){history.go(-1);}static forward(){history.go(1);}static pauseNaviagtion(){s.paused=!0,window.location.hash="paused";}static resumeNaviagtion(){s.paused=!1,window.location.replace(window.location.pathname+window.location.search),history.go(-1);}static navigate(e,t=null,n=!1){if(typeof e!="string")throw new TypeError(" \u2718 Cradova err: href must be a defined path but got "+e+" instead");let o=null,i;if(e.includes("://"))window.location.href=e;else {if(e===window.location.pathname)return;[o,i]=s.checker(e),o&&(s.nextRouteController=o,window.history.pushState({},"",e)),s.params.params=i,s.params.data=t,s.router(null,n);}}static navigateNauturally(e){if(typeof e!="string")throw new TypeError(" \u2718 Cradova err: pathname must be a defined path but got "+e+" instead");window.location.pathname=e;}static setLoadingScreen(e){if(e instanceof m)s.loadingScreen=e;else throw new Error(" \u2718 Cradova err: Loading Screen should be a cradova screen class")}static onPageEvent(e){if(typeof e=="function")s.pageevents.push(e);else throw new Error(" \u2718 Cradova err: callback for pageShow event is not a function")}static async packageScreen(e){if(!s.routes[e])throw console.error(" \u2718 Cradova err: no screen with path "+e),new Error(" \u2718 Cradova err: cradova err: Not a defined screen path");let[t]=s.checker(e);if(typeof t=="function"&&(t=await t()),t._delegatedRoutes!==-1){t._delegatedRoutes=1;let n=t._derive();t=new m({template:t._html}),t._apply_derivation(n),s.routes[e]=t;}t._package(),t._packed=!0;}static getParams(){return s.params}static addErrorHandler(e){if(typeof e=="function")s.errorHandler=e;else throw new Error(" \u2718 Cradova err: callback for error event is not a function")}static _mount(){let e=document.querySelector("[data-wrapper=app]");e||(e=document.createElement("div"),e.setAttribute("data-wrapper","app"),document.body.appendChild(e)),d._appendDomForceGlobal("doc",e),window.addEventListener("pageshow",()=>s.router()),window.addEventListener("popstate",t=>{t.preventDefault(),s.router();});}};var _=(r,e)=>{let t={},n=null;if(e.length!==0)for(let o=0;o<e.length;o++){let i=e[o];if(typeof i=="function"&&(i=i()),i instanceof h&&(i=i.render()),i instanceof HTMLElement||i instanceof DocumentFragment){r.appendChild(i);continue}if(Array.isArray(i)){r.appendChild(L(i));continue}if(typeof i=="string"||typeof i=="number"){n=i;continue}if(typeof i=="object"){t=Object.assign(t,i);continue}}else return r;if(typeof t=="object"&&r)for(let[o,i]of Object.entries(t)){if(o==="style"&&typeof i=="object"){Object.assign(r.style,i);continue}if(Array.isArray(i)){if(o=="reference"&&i[0]instanceof u){i[0]._appendDomForce(i[1],r);continue}if(i[0]instanceof T){i[0].bindRef(r,{_element_property:o,signalProperty:i[1]});continue}}if(o==="onmount"&&typeof t.onmount=="function"){let l=()=>{t.onmount?.apply(r),t.onmount=void 0;};f.addEventListener("onmountEvent",l);continue}if(o.includes("data-")){r.setAttribute(o,i);continue}if(o.includes("aria-")){r.setAttribute(o,i);continue}if(o==="href"&&typeof i=="string"){let l=i||"";l.includes("://")||r.addEventListener("click",y=>{y.preventDefault(),g.navigate(r.pathname);if(l.includes("#")){let c=l.split("#").at(-1);document.getElementById("#"+c)?.scrollIntoView();}}),r.setAttribute(o,i);continue}if(typeof r.style[o]<"u"&&o!=="src"){r.style[o]=i;continue}r[o]=i;}return n&&r.appendChild(document.createTextNode(n)),r},H=function(r){if(Array.isArray(r)&&(r=r[0]),typeof r!="string")return [];let e="";if(r.includes("|")&&([r,e]=r.split("|"),!r))return ["P",void 0,void 0,e];let t;if(r.includes("#")){if(!r.includes("."))return r=r.split("#"),t=r.shift(),t||(t="DIV"),r[0].includes(" ")&&(r=[r[0].split(" ")[1]]),[t,r[0],void 0,e]}else return r=r.split("."),t=r.shift(),t||(t="DIV"),[t,void 0,r.join(" "),e];r=r.split(".");let n=[],o=[];t=!r[0].includes("#")&&r.shift(),t||(t="DIV");for(let i=0;i<r.length;i++){if(r[i].includes("#")){let l=r[i].split("#");if(o.push(l[1]),i===0){t=l[0];continue}n.push(l[0]);continue}n.push(r[i]);}return [t,o[0],n.join(" "),e]},a=r=>(...t)=>_(document.createElement(r),t);function L(r){let e=new DocumentFragment;for(let t of r)if(Array.isArray(t))e.appendChild(L(t));else {if(t instanceof h&&(t=t.render(void 0)),typeof t=="function"&&(t=t(),typeof t=="function"&&(t=t())),typeof t=="string"||typeof t=="number"){e.appendChild(document.createTextNode(t));continue}if(t instanceof HTMLElement||t instanceof DocumentFragment)e.appendChild(t);else if(typeof t<"u")throw new Error(" \u2718 Cradova err: invalid child type: "+t+" ("+typeof t+")")}return e}function C(r){if(Array.isArray(r)&&(r=r[0]),typeof r=="string"){let e=document.querySelector("style");if(e!==null){e.textContent=r+e.textContent;return}e=document.createElement("style"),e.textContent=r,document.head.appendChild(e);}}function P(r,...e){if(r)return e}function R(r,e,t){return r?e:t}function D(r,...e){return t=>{if(t===r)return e}}function A(r,...e){if(e.length)for(let t=0;t<e.length;t++){let n=e[t],o=n(r);if(o)return o}}function N(r,e){if(typeof e!="function")throw new Error(" \u2718 Cradova err : Invalid component type, must be a function that returns html ");return Array.isArray(r)?r.map(e):void 0}var p={snru:"",memo_SNRU(){let r=0,e=window.location.href;for(let t=0;t<e.length;t++)r+=e.charCodeAt(t);this.snru=r.toString();}},F=function(r){let e=document.createDocumentFragment();for(let t=0;t<r.length;t++){let n=r[t];if(typeof n=="function"&&(n=n()),n instanceof HTMLElement||n instanceof DocumentFragment){e.appendChild(n);continue}if(n instanceof String){e.appendChild(document.createTextNode(n));continue}throw console.error(" \u2718 Cradova err: wrong element type"+n),new TypeError(" \u2718 Cradova err: invalid element")}return e};function V(r,e){e._state_index+=1;let t=e._state_index;e._state_track[t]||(e._roll_state(r,t),e._state_track[t]=!0);function n(o){e._roll_state(o,t),e.updateState();}return [e._roll_state(null,t,!0),n]}function J(r,e){e._effect(r);}function B(){return new u}var Y=a("a"),O=a("article"),$=a("audio"),U=a("br"),G=a("button"),q=a("canvas"),K=a("caption"),Q=a("col"),W=a("colgroup"),X=a("datalist"),Z=a("details"),z=a("dialog"),ee=a("div"),te=a("em"),ne=a("embed"),re=a("figure"),oe=a("footer"),ae=a("form"),ie=a("h1"),se=a("h2"),le=a("h3"),ce=a("h4"),pe=a("h5"),ue=a("h6"),de=a("head"),fe=a("header"),he=a("hr"),me=a("i"),ge=a("iframe"),ye=a("img"),_e=a("input"),Te=a("label"),ve=a("li"),Ee=a("main"),we=a("nav"),He=a("ol"),Le=a("optgroup"),xe=a("option"),Me=a("p"),be=a("progress"),Se=a("q"),ke=a("section"),Ce=a("select"),Pe=a("source"),Re=a("span"),De=a("strong"),Ae=a("summary"),Ne=a("table"),Fe=a("tbody"),Ve=a("td"),Je=a("template"),Be=a("textarea"),Ie=a("th"),je=a("title"),Ye=a("tr"),Oe=a("track"),$e=a("u"),Ue=a("ul"),Ge=a("video"),qe=(r,e)=>{let t=document.createElement("span");return t.innerHTML=r,_(t,[e])},Ke=r=>{let e=document.createElement("div");return e.innerHTML=r,Array.from(e.children)};var x=(...r)=>{let{0:e,1:t,2:n,3:o}=H(r[0]),i=e?document.createElement(e):new DocumentFragment;return e&&(n&&(i.className=n),t&&(i.id=t),o&&(i.innerText=o),r.shift()),_(i,r)},Xe=x;
2
-
3
- export { D as $case, P as $if, R as $ifelse, A as $switch, f as CradovaEvent, h as Ref, L as Rhoda, g as Router, p as SNRU, m as Screen, Y as a, O as article, $ as audio, U as br, G as button, q as canvas, K as caption, Q as col, W as colgroup, a as cra, T as createSignal, C as css, X as datalist, Xe as default, Z as details, z as dialog, ee as div, te as em, ne as embed, re as figure, oe as footer, ae as form, F as frag, ie as h1, se as h2, le as h3, ce as h4, pe as h5, ue as h6, de as head, fe as header, he as hr, me as i, ge as iframe, ye as img, _e as input, Te as label, w as lazy, ve as li, N as loop, Ee as main, H as make, _ as makeElement, we as nav, He as ol, Le as optgroup, xe as option, Me as p, be as progress, Se as q, Ke as raw, u as reference, ke as section, Ce as select, Pe as source, Re as span, De as strong, Ae as summary, qe as svg, Ne as table, Fe as tbody, Ve as td, Je as template, Be as textarea, Ie as th, je as title, Ye as tr, Oe as track, $e as u, Ue as ul, J as useEffect, B as useRef, V as useState, Ge as video };