@unsetsoft/ryunixjs 0.4.9 → 0.4.10

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/dist/Ryunix.js CHANGED
@@ -1,8 +1,13 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Ryunix = {}));
5
- })(this, (function (exports) { 'use strict';
1
+ ;(function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined'
3
+ ? factory(exports)
4
+ : typeof define === 'function' && define.amd
5
+ ? define(['exports'], factory)
6
+ : ((global =
7
+ typeof globalThis !== 'undefined' ? globalThis : global || self),
8
+ factory((global.Ryunix = {})))
9
+ })(this, function (exports) {
10
+ 'use strict'
6
11
 
7
12
  const vars = {
8
13
  containerRoot: null,
@@ -12,29 +17,29 @@
12
17
  deletions: null,
13
18
  wipFiber: null,
14
19
  hookIndex: null,
15
- };
20
+ }
16
21
 
17
- const reg = /[A-Z]/g;
22
+ const reg = /[A-Z]/g
18
23
 
19
24
  const RYUNIX_TYPES = Object.freeze({
20
- TEXT_ELEMENT: Symbol("text.element"),
21
- RYUNIX_EFFECT: Symbol("ryunix.effect"),
22
- RYUNIX_CONTEXT: Symbol("ryunix.context"),
23
- });
25
+ TEXT_ELEMENT: Symbol('text.element'),
26
+ RYUNIX_EFFECT: Symbol('ryunix.effect'),
27
+ RYUNIX_CONTEXT: Symbol('ryunix.context'),
28
+ })
24
29
 
25
30
  const STRINGS = Object.freeze({
26
- object: "object",
27
- function: "function",
28
- style: "style",
29
- className: "className",
30
- children: "children",
31
- });
31
+ object: 'object',
32
+ function: 'function',
33
+ style: 'style',
34
+ className: 'className',
35
+ children: 'children',
36
+ })
32
37
 
33
38
  const EFFECT_TAGS = Object.freeze({
34
39
  PLACEMENT: Symbol(),
35
40
  UPDATE: Symbol(),
36
41
  DELETION: Symbol(),
37
- });
42
+ })
38
43
 
39
44
  /**
40
45
  * The function creates a new element with the given type, props, and children.
@@ -61,11 +66,11 @@
61
66
  children: children
62
67
  .flat()
63
68
  .map((child) =>
64
- typeof child === STRINGS.object ? child : createTextElement(child)
69
+ typeof child === STRINGS.object ? child : createTextElement(child),
65
70
  ),
66
71
  },
67
- };
68
- };
72
+ }
73
+ }
69
74
 
70
75
  /**
71
76
  * The function creates a text element with a given text value.
@@ -81,18 +86,18 @@
81
86
  nodeValue: text,
82
87
  children: [],
83
88
  },
84
- };
85
- };
89
+ }
90
+ }
86
91
 
87
92
  const Fragments = (props) => {
88
93
  if (props.style) {
89
- throw new Error("The style attribute is not supported");
94
+ throw new Error('The style attribute is not supported')
90
95
  }
91
- if (props.className === "") {
92
- throw new Error("className cannot be empty.");
96
+ if (props.className === '') {
97
+ throw new Error('className cannot be empty.')
93
98
  }
94
- return createElement("div", props, props.children);
95
- };
99
+ return createElement('div', props, props.children)
100
+ }
96
101
 
97
102
  /**
98
103
  * The function renders an element into a container using a work-in-progress root.
@@ -108,10 +113,10 @@
108
113
  children: [element],
109
114
  },
110
115
  alternate: vars.currentRoot,
111
- };
112
- vars.deletions = [];
113
- vars.nextUnitOfWork = vars.wipRoot;
114
- };
116
+ }
117
+ vars.deletions = []
118
+ vars.nextUnitOfWork = vars.wipRoot
119
+ }
115
120
 
116
121
  /**
117
122
  * @description The function creates a reference to a DOM element with the specified ID. This will be used to initialize the app.
@@ -120,19 +125,19 @@
120
125
  * for the root element.
121
126
  */
122
127
  const init = (root) => {
123
- const rootElement = root || "__ryunix";
124
- vars.containerRoot = document.getElementById(rootElement);
125
- };
126
-
127
- const isEvent = (key) => key.startsWith("on");
128
- const isProperty = (key) => key !== STRINGS.children && !isEvent(key);
129
- const isNew = (prev, next) => (key) => prev[key] !== next[key];
130
- const isGone = (next) => (key) => !(key in next);
128
+ const rootElement = root || '__ryunix'
129
+ vars.containerRoot = document.getElementById(rootElement)
130
+ }
131
+
132
+ const isEvent = (key) => key.startsWith('on')
133
+ const isProperty = (key) => key !== STRINGS.children && !isEvent(key)
134
+ const isNew = (prev, next) => (key) => prev[key] !== next[key]
135
+ const isGone = (next) => (key) => !(key in next)
131
136
  const hasDepsChanged = (prevDeps, nextDeps) =>
132
137
  !prevDeps ||
133
138
  !nextDeps ||
134
139
  prevDeps.length !== nextDeps.length ||
135
- prevDeps.some((dep, index) => dep !== nextDeps[index]);
140
+ prevDeps.some((dep, index) => dep !== nextDeps[index])
136
141
 
137
142
  /**
138
143
  * The function cancels all effect hooks in a given fiber.
@@ -144,12 +149,14 @@
144
149
  const cancelEffects = (fiber) => {
145
150
  if (fiber.hooks) {
146
151
  fiber.hooks
147
- .filter((hook) => hook.tag === RYUNIX_TYPES.RYUNIX_EFFECT && hook.cancel)
152
+ .filter(
153
+ (hook) => hook.tag === RYUNIX_TYPES.RYUNIX_EFFECT && hook.cancel,
154
+ )
148
155
  .forEach((effectHook) => {
149
- effectHook.cancel();
150
- });
156
+ effectHook.cancel()
157
+ })
151
158
  }
152
- };
159
+ }
153
160
 
154
161
  /**
155
162
  * The function runs all effect hooks in a given fiber.
@@ -161,12 +168,14 @@
161
168
  const runEffects = (fiber) => {
162
169
  if (fiber.hooks) {
163
170
  fiber.hooks
164
- .filter((hook) => hook.tag === RYUNIX_TYPES.RYUNIX_EFFECT && hook.effect)
171
+ .filter(
172
+ (hook) => hook.tag === RYUNIX_TYPES.RYUNIX_EFFECT && hook.effect,
173
+ )
165
174
  .forEach((effectHook) => {
166
- effectHook.cancel = effectHook.effect();
167
- });
175
+ effectHook.cancel = effectHook.effect()
176
+ })
168
177
  }
169
- };
178
+ }
170
179
 
171
180
  /**
172
181
  * @description The function creates a state.
@@ -178,17 +187,17 @@
178
187
  const oldHook =
179
188
  vars.wipFiber.alternate &&
180
189
  vars.wipFiber.alternate.hooks &&
181
- vars.wipFiber.alternate.hooks[vars.hookIndex];
190
+ vars.wipFiber.alternate.hooks[vars.hookIndex]
182
191
  const hook = {
183
192
  state: oldHook ? oldHook.state : initial,
184
193
  queue: [],
185
- };
194
+ }
186
195
 
187
- const actions = oldHook ? oldHook.queue : [];
196
+ const actions = oldHook ? oldHook.queue : []
188
197
  actions.forEach((action) => {
189
198
  hook.state =
190
- typeof action === STRINGS.function ? action(hook.state) : action;
191
- });
199
+ typeof action === STRINGS.function ? action(hook.state) : action
200
+ })
192
201
 
193
202
  /**
194
203
  * The function `setState` updates the state of a component in Ryunix by adding an action to a queue
@@ -198,20 +207,20 @@
198
207
  * that needs to be applied to the component's state.
199
208
  */
200
209
  const setState = (action) => {
201
- hook.queue.push(action);
210
+ hook.queue.push(action)
202
211
  vars.wipRoot = {
203
212
  dom: vars.currentRoot.dom,
204
213
  props: vars.currentRoot.props,
205
214
  alternate: vars.currentRoot,
206
- };
207
- vars.nextUnitOfWork = vars.wipRoot;
208
- vars.deletions = [];
209
- };
215
+ }
216
+ vars.nextUnitOfWork = vars.wipRoot
217
+ vars.deletions = []
218
+ }
210
219
 
211
- vars.wipFiber.hooks.push(hook);
212
- vars.hookIndex++;
213
- return [hook.state, setState];
214
- };
220
+ vars.wipFiber.hooks.push(hook)
221
+ vars.hookIndex++
222
+ return [hook.state, setState]
223
+ }
215
224
 
216
225
  /**
217
226
  * This is a function that creates a hook for managing side effects in Ryunix components.
@@ -226,105 +235,105 @@
226
235
  const oldHook =
227
236
  vars.wipFiber.alternate &&
228
237
  vars.wipFiber.alternate.hooks &&
229
- vars.wipFiber.alternate.hooks[vars.hookIndex];
238
+ vars.wipFiber.alternate.hooks[vars.hookIndex]
230
239
 
231
- const hasChanged = hasDepsChanged(oldHook ? oldHook.deps : undefined, deps);
240
+ const hasChanged = hasDepsChanged(oldHook ? oldHook.deps : undefined, deps)
232
241
 
233
242
  const hook = {
234
243
  tag: RYUNIX_TYPES.RYUNIX_EFFECT,
235
244
  effect: hasChanged ? effect : null,
236
245
  cancel: hasChanged && oldHook && oldHook.cancel,
237
246
  deps,
238
- };
247
+ }
239
248
 
240
- vars.wipFiber.hooks.push(hook);
241
- vars.hookIndex++;
242
- };
249
+ vars.wipFiber.hooks.push(hook)
250
+ vars.hookIndex++
251
+ }
243
252
 
244
253
  const useQuery = () => {
245
- vars.hookIndex++;
254
+ vars.hookIndex++
246
255
 
247
256
  const oldHook =
248
257
  vars.wipFiber.alternate &&
249
258
  vars.wipFiber.alternate.hooks &&
250
- vars.wipFiber.alternate.hooks[vars.hookIndex];
259
+ vars.wipFiber.alternate.hooks[vars.hookIndex]
251
260
 
252
- const hasOld = oldHook ? oldHook : undefined;
261
+ const hasOld = oldHook ? oldHook : undefined
253
262
 
254
- const urlSearchParams = new URLSearchParams(window.location.search);
255
- const params = Object.fromEntries(urlSearchParams.entries());
256
- const Query = hasOld ? hasOld : params;
263
+ const urlSearchParams = new URLSearchParams(window.location.search)
264
+ const params = Object.fromEntries(urlSearchParams.entries())
265
+ const Query = hasOld ? hasOld : params
257
266
 
258
267
  const hook = {
259
268
  tag: RYUNIX_TYPES.RYUNIX_EFFECT,
260
269
  query: Query,
261
- };
270
+ }
262
271
 
263
- vars.wipFiber.hooks.push(hook);
272
+ vars.wipFiber.hooks.push(hook)
264
273
 
265
- return hook.query;
266
- };
274
+ return hook.query
275
+ }
267
276
 
268
277
  const Router = ({ path, component }) => {
269
- const [currentPath, setCurrentPath] = useStore(window.location.pathname);
278
+ const [currentPath, setCurrentPath] = useStore(window.location.pathname)
270
279
 
271
280
  useEffect(() => {
272
281
  const onLocationChange = () => {
273
- setCurrentPath(() => window.location.pathname);
274
- };
282
+ setCurrentPath(() => window.location.pathname)
283
+ }
275
284
 
276
- window.addEventListener("navigate", onLocationChange);
277
- window.addEventListener("pushsatate", onLocationChange);
278
- window.addEventListener("popstate", onLocationChange);
285
+ window.addEventListener('navigate', onLocationChange)
286
+ window.addEventListener('pushsatate', onLocationChange)
287
+ window.addEventListener('popstate', onLocationChange)
279
288
 
280
289
  return () => {
281
- window.removeEventListener("navigate", onLocationChange);
282
- window.removeEventListener("pushsatate", onLocationChange);
283
- window.removeEventListener("popstate", onLocationChange);
284
- };
285
- }, [currentPath]);
290
+ window.removeEventListener('navigate', onLocationChange)
291
+ window.removeEventListener('pushsatate', onLocationChange)
292
+ window.removeEventListener('popstate', onLocationChange)
293
+ }
294
+ }, [currentPath])
286
295
 
287
- return currentPath === path ? component() : null;
288
- };
296
+ return currentPath === path ? component() : null
297
+ }
289
298
 
290
299
  const Navigate = (props) => {
291
300
  if (props.style) {
292
301
  throw new Error(
293
- "The style attribute is not supported on internal components, use className."
294
- );
302
+ 'The style attribute is not supported on internal components, use className.',
303
+ )
295
304
  }
296
- if (props.to === "") {
297
- throw new Error("'to=' cannot be empty.");
305
+ if (props.to === '') {
306
+ throw new Error("'to=' cannot be empty.")
298
307
  }
299
- if (props.className === "") {
300
- throw new Error("className cannot be empty.");
308
+ if (props.className === '') {
309
+ throw new Error('className cannot be empty.')
301
310
  }
302
- if (props.label === "" && !props.children) {
303
- throw new Error("'label=' cannot be empty.");
311
+ if (props.label === '' && !props.children) {
312
+ throw new Error("'label=' cannot be empty.")
304
313
  }
305
314
 
306
315
  if (!props.to) {
307
- throw new Error("Missig 'to' param.");
316
+ throw new Error("Missig 'to' param.")
308
317
  }
309
318
  const preventReload = (event) => {
310
- event.preventDefault();
319
+ event.preventDefault()
311
320
  if (window.location.pathname !== props.to) {
312
- window.history.pushState({}, "", props.to);
313
- const navigationEvent = new Event("pushsatate");
314
- window.dispatchEvent(navigationEvent);
321
+ window.history.pushState({}, '', props.to)
322
+ const navigationEvent = new Event('pushsatate')
323
+ window.dispatchEvent(navigationEvent)
315
324
  }
316
- };
325
+ }
317
326
 
318
327
  const anchor = {
319
328
  href: props.to,
320
329
  onClick: preventReload,
321
330
  ...props,
322
- };
331
+ }
323
332
 
324
- const children = props.label ? props.label : props.children;
333
+ const children = props.label ? props.label : props.children
325
334
 
326
- return createElement("a", anchor, children);
327
- };
335
+ return createElement('a', anchor, children)
336
+ }
328
337
 
329
338
  /**
330
339
  * The function creates a new DOM element based on the given fiber object and updates its properties.
@@ -339,13 +348,13 @@
339
348
  const createDom = (fiber) => {
340
349
  const dom =
341
350
  fiber.type == RYUNIX_TYPES.TEXT_ELEMENT
342
- ? document.createTextNode("")
343
- : document.createElement(fiber.type);
351
+ ? document.createTextNode('')
352
+ : document.createElement(fiber.type)
344
353
 
345
- updateDom(dom, {}, fiber.props);
354
+ updateDom(dom, {}, fiber.props)
346
355
 
347
- return dom;
348
- };
356
+ return dom
357
+ }
349
358
 
350
359
  /**
351
360
  * The function updates the DOM by removing old event listeners and properties, and adding new ones
@@ -357,72 +366,74 @@
357
366
  const updateDom = (dom, prevProps, nextProps) => {
358
367
  Object.keys(prevProps)
359
368
  .filter(isEvent)
360
- .filter((key) => isGone(nextProps)(key) || isNew(prevProps, nextProps)(key))
369
+ .filter(
370
+ (key) => isGone(nextProps)(key) || isNew(prevProps, nextProps)(key),
371
+ )
361
372
  .forEach((name) => {
362
- const eventType = name.toLowerCase().substring(2);
363
- dom.removeEventListener(eventType, prevProps[name]);
364
- });
373
+ const eventType = name.toLowerCase().substring(2)
374
+ dom.removeEventListener(eventType, prevProps[name])
375
+ })
365
376
 
366
377
  Object.keys(prevProps)
367
378
  .filter(isProperty)
368
379
  .filter(isGone(nextProps))
369
380
  .forEach((name) => {
370
- dom[name] = "";
371
- });
381
+ dom[name] = ''
382
+ })
372
383
 
373
384
  Object.keys(nextProps)
374
385
  .filter(isProperty)
375
386
  .filter(isNew(prevProps, nextProps))
376
387
  .forEach((name) => {
377
388
  if (name === STRINGS.style) {
378
- DomStyle(dom, nextProps.style);
389
+ DomStyle(dom, nextProps.style)
379
390
  } else if (name === STRINGS.className) {
380
- if (nextProps.className === "") {
381
- throw new Error("className cannot be empty.");
391
+ if (nextProps.className === '') {
392
+ throw new Error('className cannot be empty.')
382
393
  }
383
394
  prevProps.className &&
384
- dom.classList.remove(...prevProps.className.split(/\s+/));
385
- dom.classList.add(...nextProps.className.split(/\s+/));
395
+ dom.classList.remove(...prevProps.className.split(/\s+/))
396
+ dom.classList.add(...nextProps.className.split(/\s+/))
386
397
  } else {
387
- dom[name] = nextProps[name];
398
+ dom[name] = nextProps[name]
388
399
  }
389
- });
400
+ })
390
401
 
391
402
  Object.keys(nextProps)
392
403
  .filter(isEvent)
393
404
  .filter(isNew(prevProps, nextProps))
394
405
  .forEach((name) => {
395
- const eventType = name.toLowerCase().substring(2);
396
- dom.addEventListener(eventType, nextProps[name]);
397
- });
398
- };
406
+ const eventType = name.toLowerCase().substring(2)
407
+ dom.addEventListener(eventType, nextProps[name])
408
+ })
409
+ }
399
410
 
400
411
  const DomStyle = (dom, style) => {
401
412
  dom.style = Object.keys(style).reduce((acc, styleName) => {
402
413
  const key = styleName.replace(reg, function (v) {
403
- return "-" + v.toLowerCase();
404
- });
405
- acc += `${key}: ${style[styleName]};`;
406
- return acc;
407
- }, "");
408
- };
409
-
410
- var Dom = /*#__PURE__*/Object.freeze({
414
+ return '-' + v.toLowerCase()
415
+ })
416
+ acc += `${key}: ${style[styleName]};`
417
+ return acc
418
+ }, '')
419
+ }
420
+
421
+ var Dom = /*#__PURE__*/ Object.freeze({
411
422
  __proto__: null,
412
423
  DomStyle: DomStyle,
413
424
  createDom: createDom,
414
- updateDom: updateDom
415
- });
425
+ updateDom: updateDom,
426
+ })
416
427
 
417
428
  /**
418
429
  * The function commits changes made to the virtual DOM to the actual DOM.
419
430
  */
420
431
  const commitRoot = () => {
421
- vars.deletions.forEach(commitWork);
422
- commitWork(vars.wipRoot.child);
423
- vars.currentRoot = vars.wipRoot;
424
- vars.wipRoot = null;
425
- };
432
+ vars.deletions.forEach(commitWork)
433
+ commitWork(vars.wipRoot.child)
434
+ vars.currentRoot = vars.wipRoot
435
+ vars.wipRoot = null
436
+ }
426
437
 
427
438
  /**
428
439
  * The function commits changes made to the DOM based on the effect tag of the fiber.
@@ -433,35 +444,35 @@
433
444
  */
434
445
  const commitWork = (fiber) => {
435
446
  if (!fiber) {
436
- return;
447
+ return
437
448
  }
438
449
 
439
- let domParentFiber = fiber.parent;
450
+ let domParentFiber = fiber.parent
440
451
  while (!domParentFiber.dom) {
441
- domParentFiber = domParentFiber.parent;
452
+ domParentFiber = domParentFiber.parent
442
453
  }
443
- const domParent = domParentFiber.dom;
454
+ const domParent = domParentFiber.dom
444
455
 
445
456
  if (fiber.effectTag === EFFECT_TAGS.PLACEMENT) {
446
457
  if (fiber.dom != null) {
447
- domParent.appendChild(fiber.dom);
458
+ domParent.appendChild(fiber.dom)
448
459
  }
449
- runEffects(fiber);
460
+ runEffects(fiber)
450
461
  } else if (fiber.effectTag === EFFECT_TAGS.UPDATE) {
451
- cancelEffects(fiber);
462
+ cancelEffects(fiber)
452
463
  if (fiber.dom != null) {
453
- updateDom(fiber.dom, fiber.alternate.props, fiber.props);
464
+ updateDom(fiber.dom, fiber.alternate.props, fiber.props)
454
465
  }
455
- runEffects(fiber);
466
+ runEffects(fiber)
456
467
  } else if (fiber.effectTag === EFFECT_TAGS.DELETION) {
457
- cancelEffects(fiber);
458
- commitDeletion(fiber, domParent);
459
- return;
468
+ cancelEffects(fiber)
469
+ commitDeletion(fiber, domParent)
470
+ return
460
471
  }
461
472
 
462
- commitWork(fiber.child);
463
- commitWork(fiber.sibling);
464
- };
473
+ commitWork(fiber.child)
474
+ commitWork(fiber.sibling)
475
+ }
465
476
 
466
477
  /**
467
478
  * The function removes a fiber's corresponding DOM node from its parent node or recursively removes
@@ -472,18 +483,18 @@
472
483
  */
473
484
  const commitDeletion = (fiber, domParent) => {
474
485
  if (fiber.dom) {
475
- domParent.removeChild(fiber.dom);
486
+ domParent.removeChild(fiber.dom)
476
487
  } else {
477
- commitDeletion(fiber.child, domParent);
488
+ commitDeletion(fiber.child, domParent)
478
489
  }
479
- };
490
+ }
480
491
 
481
- var Commits = /*#__PURE__*/Object.freeze({
492
+ var Commits = /*#__PURE__*/ Object.freeze({
482
493
  __proto__: null,
483
494
  commitDeletion: commitDeletion,
484
495
  commitRoot: commitRoot,
485
- commitWork: commitWork
486
- });
496
+ commitWork: commitWork,
497
+ })
487
498
 
488
499
  /**
489
500
  * This function reconciles the children of a fiber node with a new set of elements, creating new
@@ -495,15 +506,15 @@
495
506
  * fiber's subtree
496
507
  */
497
508
  const reconcileChildren = (wipFiber, elements) => {
498
- let index = 0;
499
- let oldFiber = wipFiber.alternate && wipFiber.alternate.child;
500
- let prevSibling;
509
+ let index = 0
510
+ let oldFiber = wipFiber.alternate && wipFiber.alternate.child
511
+ let prevSibling
501
512
 
502
513
  while (index < elements.length || oldFiber != null) {
503
- const element = elements[index];
504
- let newFiber;
514
+ const element = elements[index]
515
+ let newFiber
505
516
 
506
- const sameType = oldFiber && element && element.type == oldFiber.type;
517
+ const sameType = oldFiber && element && element.type == oldFiber.type
507
518
 
508
519
  if (sameType) {
509
520
  newFiber = {
@@ -513,7 +524,7 @@
513
524
  parent: wipFiber,
514
525
  alternate: oldFiber,
515
526
  effectTag: EFFECT_TAGS.UPDATE,
516
- };
527
+ }
517
528
  }
518
529
  if (element && !sameType) {
519
530
  newFiber = {
@@ -523,32 +534,32 @@
523
534
  parent: wipFiber,
524
535
  alternate: null,
525
536
  effectTag: EFFECT_TAGS.PLACEMENT,
526
- };
537
+ }
527
538
  }
528
539
  if (oldFiber && !sameType) {
529
- oldFiber.effectTag = EFFECT_TAGS.DELETION;
530
- vars.deletions.push(oldFiber);
540
+ oldFiber.effectTag = EFFECT_TAGS.DELETION
541
+ vars.deletions.push(oldFiber)
531
542
  }
532
543
 
533
544
  if (oldFiber) {
534
- oldFiber = oldFiber.sibling;
545
+ oldFiber = oldFiber.sibling
535
546
  }
536
547
 
537
548
  if (index === 0) {
538
- wipFiber.child = newFiber;
549
+ wipFiber.child = newFiber
539
550
  } else if (element) {
540
- prevSibling.sibling = newFiber;
551
+ prevSibling.sibling = newFiber
541
552
  }
542
553
 
543
- prevSibling = newFiber;
544
- index++;
554
+ prevSibling = newFiber
555
+ index++
545
556
  }
546
- };
557
+ }
547
558
 
548
- var Reconciler = /*#__PURE__*/Object.freeze({
559
+ var Reconciler = /*#__PURE__*/ Object.freeze({
549
560
  __proto__: null,
550
- reconcileChildren: reconcileChildren
551
- });
561
+ reconcileChildren: reconcileChildren,
562
+ })
552
563
 
553
564
  /**
554
565
  * This function updates a function component by setting up a work-in-progress fiber, resetting the
@@ -558,12 +569,12 @@
558
569
  * used to update the state of the component and its children.
559
570
  */
560
571
  const updateFunctionComponent = (fiber) => {
561
- vars.wipFiber = fiber;
562
- vars.hookIndex = 0;
563
- vars.wipFiber.hooks = [];
564
- const children = [fiber.type(fiber.props)];
565
- reconcileChildren(fiber, children);
566
- };
572
+ vars.wipFiber = fiber
573
+ vars.hookIndex = 0
574
+ vars.wipFiber.hooks = []
575
+ const children = [fiber.type(fiber.props)]
576
+ reconcileChildren(fiber, children)
577
+ }
567
578
 
568
579
  /**
569
580
  * This function updates a host component's DOM element and reconciles its children.
@@ -573,16 +584,16 @@
573
584
  */
574
585
  const updateHostComponent = (fiber) => {
575
586
  if (!fiber.dom) {
576
- fiber.dom = createDom(fiber);
587
+ fiber.dom = createDom(fiber)
577
588
  }
578
- reconcileChildren(fiber, fiber.props.children.flat());
579
- };
589
+ reconcileChildren(fiber, fiber.props.children.flat())
590
+ }
580
591
 
581
- var Components = /*#__PURE__*/Object.freeze({
592
+ var Components = /*#__PURE__*/ Object.freeze({
582
593
  __proto__: null,
583
594
  updateFunctionComponent: updateFunctionComponent,
584
- updateHostComponent: updateHostComponent
585
- });
595
+ updateHostComponent: updateHostComponent,
596
+ })
586
597
 
587
598
  /**
588
599
  * This function uses requestIdleCallback to perform work on a fiber tree until it is complete or the
@@ -593,20 +604,20 @@
593
604
  * is used to determine
594
605
  */
595
606
  const workLoop = (deadline) => {
596
- let shouldYield = false;
607
+ let shouldYield = false
597
608
  while (vars.nextUnitOfWork && !shouldYield) {
598
- vars.nextUnitOfWork = performUnitOfWork(vars.nextUnitOfWork);
599
- shouldYield = deadline.timeRemaining() < 1;
609
+ vars.nextUnitOfWork = performUnitOfWork(vars.nextUnitOfWork)
610
+ shouldYield = deadline.timeRemaining() < 1
600
611
  }
601
612
 
602
613
  if (!vars.nextUnitOfWork && vars.wipRoot) {
603
- commitRoot();
614
+ commitRoot()
604
615
  }
605
616
 
606
- requestIdleCallback(workLoop);
607
- };
617
+ requestIdleCallback(workLoop)
618
+ }
608
619
 
609
- requestIdleCallback(workLoop);
620
+ requestIdleCallback(workLoop)
610
621
 
611
622
  /**
612
623
  * The function performs a unit of work by updating either a function component or a host component and
@@ -621,29 +632,29 @@
621
632
  * sibling of the parent. The function returns `null` if there are no more fibers to process.
622
633
  */
623
634
  const performUnitOfWork = (fiber) => {
624
- const isFunctionComponent = fiber.type instanceof Function;
635
+ const isFunctionComponent = fiber.type instanceof Function
625
636
  if (isFunctionComponent) {
626
- updateFunctionComponent(fiber);
637
+ updateFunctionComponent(fiber)
627
638
  } else {
628
- updateHostComponent(fiber);
639
+ updateHostComponent(fiber)
629
640
  }
630
641
  if (fiber.child) {
631
- return fiber.child;
642
+ return fiber.child
632
643
  }
633
- let nextFiber = fiber;
644
+ let nextFiber = fiber
634
645
  while (nextFiber) {
635
646
  if (nextFiber.sibling) {
636
- return nextFiber.sibling;
647
+ return nextFiber.sibling
637
648
  }
638
- nextFiber = nextFiber.parent;
649
+ nextFiber = nextFiber.parent
639
650
  }
640
- };
651
+ }
641
652
 
642
- var Workers = /*#__PURE__*/Object.freeze({
653
+ var Workers = /*#__PURE__*/ Object.freeze({
643
654
  __proto__: null,
644
655
  performUnitOfWork: performUnitOfWork,
645
- workLoop: workLoop
646
- });
656
+ workLoop: workLoop,
657
+ })
647
658
 
648
659
  var Ryunix = {
649
660
  createElement,
@@ -655,18 +666,17 @@
655
666
  Reconciler,
656
667
  Components,
657
668
  Commits,
658
- };
659
-
660
- window.Ryunix = Ryunix;
669
+ }
661
670
 
662
- exports.Fragments = Fragments;
663
- exports.Navigate = Navigate;
664
- exports.Router = Router;
665
- exports.default = Ryunix;
666
- exports.useEffect = useEffect;
667
- exports.useQuery = useQuery;
668
- exports.useStore = useStore;
671
+ window.Ryunix = Ryunix
669
672
 
670
- Object.defineProperty(exports, '__esModule', { value: true });
673
+ exports.Fragments = Fragments
674
+ exports.Navigate = Navigate
675
+ exports.Router = Router
676
+ exports.default = Ryunix
677
+ exports.useEffect = useEffect
678
+ exports.useQuery = useQuery
679
+ exports.useStore = useStore
671
680
 
672
- }));
681
+ Object.defineProperty(exports, '__esModule', { value: true })
682
+ })