@unsetsoft/ryunixjs 1.2.5-canary.5 → 1.2.5-canary.7

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.
@@ -1,929 +0,0 @@
1
- !(function (e, t) {
2
- 'object' == typeof exports && 'undefined' != typeof module
3
- ? t(exports)
4
- : 'function' == typeof define && define.amd
5
- ? define(['exports'], t)
6
- : t(
7
- ((e =
8
- 'undefined' != typeof globalThis ? globalThis : e || self).Ryunix =
9
- {}),
10
- )
11
- })(this, function (e) {
12
- 'use strict'
13
- let t = {
14
- containerRoot: null,
15
- nextUnitOfWork: null,
16
- currentRoot: null,
17
- wipRoot: null,
18
- deletions: [],
19
- wipFiber: null,
20
- hookIndex: 0,
21
- effects: [],
22
- }
23
- const o = () => t,
24
- n = /[A-Z]/g,
25
- r = Object.freeze({
26
- TEXT_ELEMENT: Symbol.for('ryunix.text.element'),
27
- RYUNIX_ELEMENT: Symbol.for('ryunix.element'),
28
- RYUNIX_EFFECT: Symbol.for('ryunix.effect'),
29
- RYUNIX_MEMO: Symbol.for('ryunix.memo'),
30
- RYUNIX_URL_QUERY: Symbol.for('ryunix.urlQuery'),
31
- RYUNIX_REF: Symbol.for('ryunix.ref'),
32
- RYUNIX_STORE: Symbol.for('ryunix.store'),
33
- RYUNIX_REDUCE: Symbol.for('ryunix.reduce'),
34
- RYUNIX_FRAGMENT: Symbol.for('ryunix.fragment'),
35
- RYUNIX_CONTEXT: Symbol.for('ryunix.context'),
36
- }),
37
- s = Object.freeze({
38
- OBJECT: 'object',
39
- FUNCTION: 'function',
40
- STYLE: 'ryunix-style',
41
- CLASS_NAME: 'ryunix-class',
42
- CHILDREN: 'children',
43
- BOOLEAN: 'boolean',
44
- STRING: 'string',
45
- UNDEFINED: 'undefined',
46
- }),
47
- i = Object.freeze({ STYLE: 'style', CLASS_NAME: 'className' }),
48
- c = Object.freeze({
49
- PLACEMENT: Symbol.for('ryunix.reconciler.status.placement'),
50
- UPDATE: Symbol.for('ryunix.reconciler.status.update'),
51
- DELETION: Symbol.for('ryunix.reconciler.status.deletion'),
52
- NO_EFFECT: Symbol.for('ryunix.reconciler.status.no_effect'),
53
- }),
54
- a = (e) => null !== e && typeof e === s.OBJECT,
55
- l = (e) => typeof e === s.FUNCTION,
56
- u = (e) => typeof e === s.STRING,
57
- d = (e) => null === e,
58
- p = (e, t, ...o) => ({
59
- type: e,
60
- props: {
61
- ...(t || {}),
62
- children: o.flat().map((e) => {
63
- return typeof e === s.OBJECT
64
- ? e
65
- : ((t = e),
66
- { type: r.TEXT_ELEMENT, props: { nodeValue: t, children: [] } })
67
- var t
68
- }),
69
- },
70
- }),
71
- f = (e) => {
72
- const t = Array.isArray(e.children) ? e.children : [e.children]
73
- return p(r.RYUNIX_FRAGMENT, {}, ...t)
74
- },
75
- h = (e) => e.startsWith('on'),
76
- m = (e) => e !== s.CHILDREN && !h(e),
77
- E = (e, t) => (o) => !Object.is(e[o], t[o]),
78
- y = (e) => (t) => !(t in e),
79
- N = (e) => {
80
- e &&
81
- (e.hooks?.length > 0 &&
82
- e.hooks
83
- .filter((e) => e.type === r.RYUNIX_EFFECT && l(e.cancel))
84
- .forEach((e) => {
85
- try {
86
- ;(e.cancel(), (e.cancel = null))
87
- } catch (e) {
88
- 'production' !== process.env.NODE_ENV &&
89
- console.error('Error in deep effect cleanup:', e)
90
- }
91
- }),
92
- e.child && N(e.child),
93
- e.sibling && N(e.sibling))
94
- },
95
- w = (e) => {
96
- if (e?.hooks?.length)
97
- for (let t = 0; t < e.hooks.length; t++) {
98
- const o = e.hooks[t]
99
- if (o.type === r.RYUNIX_EFFECT && l(o.effect)) {
100
- if (l(o.cancel))
101
- try {
102
- o.cancel()
103
- } catch (e) {
104
- 'production' !== process.env.NODE_ENV &&
105
- console.error('Error in effect cleanup:', e)
106
- }
107
- try {
108
- const e = o.effect()
109
- l(e) ? (o.cancel = e) : (o.cancel = null)
110
- } catch (e) {
111
- ;('production' !== process.env.NODE_ENV &&
112
- console.error('Error in effect:', e),
113
- (o.cancel = null))
114
- }
115
- o.effect = null
116
- }
117
- }
118
- },
119
- b = (e, t) => {
120
- if (a(t) && !d(t))
121
- try {
122
- const o = Object.entries(t)
123
- .filter(([e, t]) => null != t)
124
- .map(
125
- ([e, t]) => `${e.replace(n, (e) => `-${e.toLowerCase()}`)}: ${t}`,
126
- )
127
- .join('; ')
128
- e.style.cssText = o
129
- } catch (e) {
130
- 'production' !== process.env.NODE_ENV &&
131
- console.error('Error applying styles:', e)
132
- }
133
- else e.style.cssText = ''
134
- },
135
- g = (e, t, o) => {
136
- if (!o || '' === o.trim()) {
137
- if (t) {
138
- const o = t.split(/\s+/).filter(Boolean)
139
- e.classList.remove(...o)
140
- }
141
- return
142
- }
143
- if (t) {
144
- const o = t.split(/\s+/).filter(Boolean)
145
- e.classList.remove(...o)
146
- }
147
- const n = o.split(/\s+/).filter(Boolean)
148
- n.length > 0 && e.classList.add(...n)
149
- },
150
- x = (e, t = {}, o = {}) => {
151
- ;(Object.keys(t)
152
- .filter(h)
153
- .filter((e) => y(o)(e) || E(t, o)(e))
154
- .forEach((o) => {
155
- const n = o.toLowerCase().substring(2)
156
- try {
157
- e.removeEventListener(n, t[o])
158
- } catch (e) {
159
- 'production' !== process.env.NODE_ENV &&
160
- console.warn('Error removing event listener:', e)
161
- }
162
- }),
163
- Object.keys(t)
164
- .filter(m)
165
- .filter(y(o))
166
- .forEach((t) => {
167
- ;[s.STYLE, i.STYLE, s.CLASS_NAME, i.CLASS_NAME].includes(t) ||
168
- (e[t] = '')
169
- }),
170
- Object.keys(o)
171
- .filter(m)
172
- .filter(E(t, o))
173
- .forEach((n) => {
174
- try {
175
- if (n === s.STYLE || n === i.STYLE) {
176
- const t = o[n]
177
- b(e, t)
178
- } else
179
- n === s.CLASS_NAME
180
- ? g(e, t[s.CLASS_NAME], o[s.CLASS_NAME])
181
- : n === i.CLASS_NAME
182
- ? g(e, t[i.CLASS_NAME], o[i.CLASS_NAME])
183
- : 'value' === n || 'checked' === n
184
- ? e[n] !== o[n] && (e[n] = o[n])
185
- : (e[n] = o[n])
186
- } catch (e) {
187
- 'production' !== process.env.NODE_ENV &&
188
- console.warn(`Error setting property ${n}:`, e)
189
- }
190
- }),
191
- Object.keys(o)
192
- .filter(h)
193
- .filter(E(t, o))
194
- .forEach((t) => {
195
- const n = t.toLowerCase().substring(2)
196
- try {
197
- e.addEventListener(n, o[t])
198
- } catch (e) {
199
- 'production' !== process.env.NODE_ENV &&
200
- console.warn('Error adding event listener:', e)
201
- }
202
- }))
203
- },
204
- _ = (e) => {
205
- if (!e) return
206
- let t = e.parent
207
- for (; !t.dom; ) t = t.parent
208
- const o = t.dom
209
- if (e.effectTag === c.PLACEMENT)
210
- (null != e.dom && o.appendChild(e.dom), w(e))
211
- else if (e.effectTag === c.UPDATE)
212
- (((e) => {
213
- e?.hooks?.length &&
214
- e.hooks
215
- .filter((e) => e.type === r.RYUNIX_EFFECT && l(e.cancel))
216
- .forEach((e) => {
217
- try {
218
- ;(e.cancel(), (e.cancel = null))
219
- } catch (e) {
220
- 'production' !== process.env.NODE_ENV &&
221
- console.error('Error in effect cleanup:', e)
222
- }
223
- })
224
- })(e),
225
- null != e.dom && x(e.dom, e.alternate.props, e.props),
226
- w(e))
227
- else if (e.effectTag === c.DELETION) return (N(e), void v(e, o))
228
- ;(_(e.child), _(e.sibling))
229
- },
230
- v = (e, t) => {
231
- if (e.dom) t.removeChild(e.dom)
232
- else {
233
- let o = e.child
234
- for (; o; ) (v(o, t), (o = o.sibling))
235
- }
236
- },
237
- T = (e, t) => {
238
- const n = o()
239
- let r,
240
- s = 0
241
- const i = new Map()
242
- let a = e.alternate?.child,
243
- l = 0
244
- for (; a; ) {
245
- const e = a.key ?? `__index_${l}__`
246
- ;(i.set(e, a), (a = a.sibling), l++)
247
- }
248
- for (; s < t.length; ) {
249
- const o = t[s]
250
- if (!o) {
251
- s++
252
- continue
253
- }
254
- const a = o.key ?? `__index_${s}__`,
255
- l = i.get(a)
256
- let u
257
- ;(l && o.type === l.type
258
- ? ((u = {
259
- type: l.type,
260
- props: o.props,
261
- dom: l.dom,
262
- parent: e,
263
- alternate: l,
264
- effectTag: c.UPDATE,
265
- hooks: l.hooks,
266
- key: o.key,
267
- }),
268
- i.delete(a))
269
- : ((u = {
270
- type: o.type,
271
- props: o.props,
272
- dom: null,
273
- parent: e,
274
- alternate: null,
275
- effectTag: c.PLACEMENT,
276
- key: o.key,
277
- }),
278
- l &&
279
- ((l.effectTag = c.DELETION), n.deletions.push(l), i.delete(a))),
280
- 0 === s ? (e.child = u) : u && (r.sibling = u),
281
- (r = u),
282
- s++)
283
- }
284
- i.forEach((e) => {
285
- ;((e.effectTag = c.DELETION), n.deletions.push(e))
286
- })
287
- },
288
- R = (e) => {
289
- e.dom ||
290
- (e.dom = ((e) => {
291
- if (e.type === r.RYUNIX_FRAGMENT) return null
292
- let t
293
- try {
294
- if (e.type === r.TEXT_ELEMENT) t = document.createTextNode('')
295
- else {
296
- if (!u(e.type))
297
- return (
298
- 'production' !== process.env.NODE_ENV &&
299
- console.warn(
300
- 'Attempted to create DOM for non-host component:',
301
- e.type,
302
- ),
303
- null
304
- )
305
- t = document.createElement(e.type)
306
- }
307
- return (x(t, {}, e.props), t)
308
- } catch (t) {
309
- return (
310
- 'production' !== process.env.NODE_ENV &&
311
- console.error('Error creating DOM element:', t, e),
312
- null
313
- )
314
- }
315
- })(e))
316
- const t = e.props?.children || []
317
- T(e, t)
318
- },
319
- k = { IMMEDIATE: 1, USER_BLOCKING: 2, NORMAL: 3, LOW: 4, IDLE: 5 }
320
- const I = new (class {
321
- constructor() {
322
- ;((this.enabled = 'production' !== process.env.NODE_ENV),
323
- (this.measures = new Map()),
324
- (this.renderTimes = []),
325
- (this.maxSamples = 100))
326
- }
327
- startMeasure(e) {
328
- this.enabled && this.measures.set(e, performance.now())
329
- }
330
- endMeasure(e) {
331
- if (!this.enabled) return
332
- const t = this.measures.get(e)
333
- if (!t) return
334
- const o = performance.now() - t
335
- return (this.measures.delete(e), o)
336
- }
337
- recordRender(e, t) {
338
- this.enabled &&
339
- (this.renderTimes.push({
340
- component: e,
341
- duration: t,
342
- timestamp: Date.now(),
343
- }),
344
- this.renderTimes.length > this.maxSamples && this.renderTimes.shift())
345
- }
346
- getStats() {
347
- if (!this.enabled) return null
348
- const e = this.renderTimes.reduce((e, t) => e + t.duration, 0)
349
- return {
350
- total: e,
351
- avg: e / this.renderTimes.length,
352
- max: Math.max(...this.renderTimes.map((e) => e.duration)),
353
- min: Math.min(...this.renderTimes.map((e) => e.duration)),
354
- count: this.renderTimes.length,
355
- }
356
- }
357
- getSlowestComponents(e = 10) {
358
- if (!this.enabled) return []
359
- const t = new Map()
360
- return (
361
- this.renderTimes.forEach(({ component: e, duration: o }) => {
362
- t.has(e) || t.set(e, { total: 0, count: 0, max: 0 })
363
- const n = t.get(e)
364
- ;((n.total += o), n.count++, (n.max = Math.max(n.max, o)))
365
- }),
366
- Array.from(t.entries())
367
- .map(([e, t]) => ({
368
- name: e,
369
- avg: t.total / t.count,
370
- max: t.max,
371
- count: t.count,
372
- }))
373
- .sort((e, t) => t.avg - e.avg)
374
- .slice(0, e)
375
- )
376
- }
377
- logStats() {
378
- if (!this.enabled) return
379
- const e = this.getStats()
380
- if (!e) return
381
- ;(console.group('🔍 Ryunix Performance Stats'),
382
- console.log(`Total renders: ${e.count}`),
383
- console.log(`Avg render time: ${e.avg.toFixed(2)}ms`),
384
- console.log(
385
- `Min: ${e.min.toFixed(2)}ms | Max: ${e.max.toFixed(2)}ms`,
386
- ))
387
- const t = this.getSlowestComponents(5)
388
- ;(t.length > 0 &&
389
- (console.log('\n⚠️ Slowest components:'),
390
- t.forEach((e, t) => {
391
- console.log(
392
- `${t + 1}. ${e.name}: ${e.avg.toFixed(2)}ms avg (${e.count} renders)`,
393
- )
394
- })),
395
- console.groupEnd())
396
- }
397
- clear() {
398
- ;((this.renderTimes = []), this.measures.clear())
399
- }
400
- enable() {
401
- this.enabled = !0
402
- }
403
- disable() {
404
- this.enabled = !1
405
- }
406
- })(),
407
- O = (e) => {
408
- const t = performance.now()
409
- return () => {
410
- const o = performance.now() - t
411
- I.recordRender(e, o)
412
- }
413
- },
414
- S = (e, t) => (o) => {
415
- I.startMeasure(t)
416
- const n = e(o),
417
- r = I.endMeasure(t)
418
- return (r && I.recordRender(t, r), n)
419
- },
420
- A = (e) => {
421
- const t = o()
422
- let n = !1
423
- for (; t.nextUnitOfWork && !n; )
424
- ((t.nextUnitOfWork = L(t.nextUnitOfWork)), (n = e.timeRemaining() < 1))
425
- ;(!t.nextUnitOfWork &&
426
- t.wipRoot &&
427
- (() => {
428
- const e = o()
429
- ;(e.deletions.forEach(_),
430
- _(e.wipRoot.child),
431
- (e.currentRoot = e.wipRoot),
432
- (e.wipRoot = null))
433
- })(),
434
- requestIdleCallback(A))
435
- }
436
- requestIdleCallback(A)
437
- const L = (e) => {
438
- const t = e.type?.name || e.type?.displayName || 'Unknown'
439
- I.startMeasure(t)
440
- e.type instanceof Function
441
- ? ((e) => {
442
- const t = o()
443
- ;((t.wipFiber = e), (t.hookIndex = 0), (t.wipFiber.hooks = []))
444
- const n = [e.type(e.props)]
445
- ;(e.type._contextId &&
446
- void 0 !== e.props.value &&
447
- ((e._contextId = e.type._contextId),
448
- (e._contextValue = e.props.value)),
449
- T(e, n))
450
- })(e)
451
- : R(e)
452
- const n = I.endMeasure(t)
453
- if ((n && I.recordRender(t, n), e.child)) return e.child
454
- let r = e
455
- for (; r; ) {
456
- if (r.sibling) return r.sibling
457
- r = r.parent
458
- }
459
- },
460
- M = (e, t = k.NORMAL) => {
461
- const n = o()
462
- ;((n.nextUnitOfWork = e),
463
- (n.wipRoot = e),
464
- (n.deletions = []),
465
- (n.hookIndex = 0),
466
- (n.effects = []),
467
- t <= k.USER_BLOCKING
468
- ? requestIdleCallback(A)
469
- : setTimeout(() => requestIdleCallback(A), 0))
470
- },
471
- C = (e, t) => {
472
- const n = o()
473
- return (
474
- (n.wipRoot = {
475
- dom: t,
476
- props: { children: [e] },
477
- alternate: n.currentRoot,
478
- }),
479
- (n.nextUnitOfWork = n.wipRoot),
480
- (n.deletions = []),
481
- M(n.wipRoot),
482
- n.wipRoot
483
- )
484
- },
485
- U = (e, t = '__ryunix') => {
486
- const n = o()
487
- n.containerRoot = document.getElementById(t)
488
- return C(e, n.containerRoot)
489
- },
490
- D = (e, t, o) => {
491
- try {
492
- return e(t)
493
- } catch (e) {
494
- return (
495
- 'production' !== process.env.NODE_ENV &&
496
- console.error('Component error:', e),
497
- o && o(e),
498
- null
499
- )
500
- }
501
- },
502
- F = () => {
503
- const e = o()
504
- if (!e.wipFiber)
505
- throw new Error(
506
- 'Hooks can only be called inside the body of a function component.',
507
- )
508
- Array.isArray(e.wipFiber.hooks) || (e.wipFiber.hooks = [])
509
- },
510
- Y = (e, t) =>
511
- !e ||
512
- !t ||
513
- e.length !== t.length ||
514
- e.some((e, o) => !Object.is(e, t[o])),
515
- X = (e) => V((e, t) => (l(t) ? t(e) : t), e),
516
- V = (e, t, n) => {
517
- F()
518
- const s = o(),
519
- { wipFiber: i, hookIndex: c } = s,
520
- a = i.alternate?.hooks?.[c],
521
- l = {
522
- hookID: c,
523
- type: r.RYUNIX_STORE,
524
- state: a ? a.state : n ? n(t) : t,
525
- queue: [],
526
- }
527
- a?.queue &&
528
- a.queue.forEach((t) => {
529
- try {
530
- l.state = e(l.state, t)
531
- } catch (e) {
532
- 'production' !== process.env.NODE_ENV &&
533
- console.error('Error in reducer:', e)
534
- }
535
- })
536
- return (
537
- (i.hooks[c] = l),
538
- s.hookIndex++,
539
- [
540
- l.state,
541
- (e) => {
542
- if (void 0 === e)
543
- return void (
544
- 'production' !== process.env.NODE_ENV &&
545
- console.warn('dispatch called with undefined action')
546
- )
547
- l.queue.push(e)
548
- const t = o()
549
- ;((t.wipRoot = {
550
- dom: t.currentRoot.dom,
551
- props: t.currentRoot.props,
552
- alternate: t.currentRoot,
553
- }),
554
- (t.deletions = []),
555
- (t.hookIndex = 0),
556
- M(t.wipRoot))
557
- },
558
- ]
559
- )
560
- },
561
- j = (e, t) => {
562
- if ((F(), !l(e))) throw new Error('useEffect callback must be a function')
563
- if (void 0 !== t && !Array.isArray(t))
564
- throw new Error('useEffect dependencies must be an array or undefined')
565
- const n = o(),
566
- { wipFiber: s, hookIndex: i } = n,
567
- c = s.alternate?.hooks?.[i],
568
- a = Y(c?.deps, t),
569
- u = {
570
- hookID: i,
571
- type: r.RYUNIX_EFFECT,
572
- deps: t,
573
- effect: a ? e : null,
574
- cancel: c?.cancel,
575
- }
576
- ;((s.hooks[i] = u), n.hookIndex++)
577
- },
578
- P = (e, t) => {
579
- if ((F(), !l(e))) throw new Error('useMemo callback must be a function')
580
- if (!Array.isArray(t))
581
- throw new Error('useMemo requires a dependencies array')
582
- const n = o(),
583
- { wipFiber: s, hookIndex: i } = n,
584
- c = s.alternate?.hooks?.[i]
585
- let a
586
- if (c && !Y(c.deps, t)) a = c.value
587
- else
588
- try {
589
- a = e()
590
- } catch (e) {
591
- ;('production' !== process.env.NODE_ENV &&
592
- console.error('Error in useMemo computation:', e),
593
- (a = void 0))
594
- }
595
- const u = { hookID: i, type: r.RYUNIX_MEMO, value: a, deps: t }
596
- return ((s.hooks[i] = u), n.hookIndex++, a)
597
- },
598
- $ = (e = r.RYUNIX_CONTEXT, t = {}) => {
599
- const n = ({ children: t, value: o }) => {
600
- const n = f({ children: t })
601
- return ((n._contextId = e), (n._contextValue = o), n)
602
- }
603
- n._contextId = e
604
- return {
605
- Provider: n,
606
- useContext: (n = e) => {
607
- F()
608
- let r = o().wipFiber
609
- for (; r; ) {
610
- if (r._contextId === n && void 0 !== r._contextValue)
611
- return r._contextValue
612
- if (r.type?._contextId === n && void 0 !== r.props?.value)
613
- return r.props.value
614
- r = r.parent
615
- }
616
- return t
617
- },
618
- }
619
- },
620
- q = () => {
621
- if ('undefined' == typeof window) return {}
622
- const e = new URLSearchParams(window.location.search),
623
- t = {}
624
- for (const [o, n] of e.entries()) t[o] = n
625
- return t
626
- },
627
- W = () => {
628
- if ('undefined' == typeof window) return ''
629
- const [e, t] = X(window.location.hash)
630
- return (
631
- j(() => {
632
- const e = () => t(window.location.hash)
633
- return (
634
- window.addEventListener('hashchange', e),
635
- () => window.removeEventListener('hashchange', e)
636
- )
637
- }, []),
638
- e
639
- )
640
- },
641
- B = $('ryunix.navigation', {
642
- location: '/',
643
- params: {},
644
- query: {},
645
- navigate: (e) => {},
646
- route: null,
647
- }),
648
- z = (e, t) => {
649
- const o = t.split('?')[0].split('#')[0],
650
- n = e.find((e) => e.NotFound),
651
- r = n
652
- ? { route: { component: n.NotFound }, params: {} }
653
- : { route: { component: null }, params: {} }
654
- for (const n of e) {
655
- if (n.subRoutes) {
656
- const e = z(n.subRoutes, t)
657
- if (e) return e
658
- }
659
- if ('*' === n.path) return r
660
- if (!n.path || 'string' != typeof n.path) continue
661
- const e = [],
662
- s = new RegExp(
663
- `^${n.path.replace(/:\w+/g, (t) => (e.push(t.substring(1)), '([^/]+)'))}$`,
664
- ),
665
- i = o.match(s)
666
- if (i) {
667
- return {
668
- route: n,
669
- params: e.reduce((e, t, o) => ((e[t] = i[o + 1]), e), {}),
670
- }
671
- }
672
- }
673
- return r
674
- },
675
- G = () => B.useContext('ryunix.navigation'),
676
- H = (e) => {
677
- const [t, o] = V(
678
- (e, t) => ('function' == typeof t ? t.value(e) : t.value),
679
- e,
680
- )
681
- return [
682
- t,
683
- (e, t = k.NORMAL) => {
684
- o({ value: e, priority: t })
685
- },
686
- ]
687
- }
688
- var J = Object.freeze({
689
- __proto__: null,
690
- Children: () => {
691
- const { route: e, params: t, query: o, location: n } = G()
692
- if (!e || !e.component) return null
693
- const r = W()
694
- return (
695
- j(() => {
696
- if (r) {
697
- const e = r.slice(1),
698
- t = document.getElementById(e)
699
- t && t.scrollIntoView({ block: 'start', behavior: 'smooth' })
700
- }
701
- }, [r]),
702
- p(e.component, { key: n, params: t, query: o, hash: r })
703
- )
704
- },
705
- NavLink: ({ to: e, exact: t = !1, ...o }) => {
706
- const { location: n, navigate: r } = G(),
707
- s = t ? n === e : n.startsWith(e),
708
- i = o['ryunix-class'] ? 'ryunix-class' : 'className',
709
- c =
710
- 'function' == typeof (a = o['ryunix-class'] || o.className)
711
- ? a({ isActive: s })
712
- : a || ''
713
- var a
714
- const { 'ryunix-class': l, className: u, ...d } = o
715
- return p(
716
- 'a',
717
- {
718
- href: e,
719
- onClick: (t) => {
720
- ;(t.preventDefault(), r(e))
721
- },
722
- [i]: c,
723
- ...d,
724
- },
725
- o.children,
726
- )
727
- },
728
- RouterProvider: ({ routes: e, children: t }) => {
729
- const [o, n] = X(window.location.pathname)
730
- j(() => {
731
- const e = () => n(window.location.pathname)
732
- return (
733
- window.addEventListener('popstate', e),
734
- window.addEventListener('hashchange', e),
735
- () => {
736
- ;(window.removeEventListener('popstate', e),
737
- window.removeEventListener('hashchange', e))
738
- }
739
- )
740
- }, [o])
741
- const r = z(e, o) || {},
742
- s = q(),
743
- i = {
744
- location: o,
745
- params: r.params || {},
746
- query: s,
747
- navigate: (e) => {
748
- ;(window.history.pushState({}, '', e), n(e))
749
- },
750
- route: r.route,
751
- }
752
- return p(B.Provider, { value: i }, f({ children: t }))
753
- },
754
- createContext: $,
755
- useCallback: (e, t) => {
756
- if (!l(e))
757
- throw new Error('useCallback requires a function as first argument')
758
- return P(() => e, t)
759
- },
760
- useDeferredValue: (e) => {
761
- const [t, o] = H(e)
762
- return (
763
- j(() => {
764
- const t = setTimeout(() => {
765
- o(e, k.LOW)
766
- }, 100)
767
- return () => clearTimeout(t)
768
- }, [e]),
769
- t
770
- )
771
- },
772
- useEffect: j,
773
- useHash: W,
774
- useMemo: P,
775
- useMetadata: (e = {}, t = {}) => {
776
- j(() => {
777
- if ('undefined' == typeof document) return
778
- let o = 'Ryunix App'
779
- const n = t.title?.template,
780
- r = t.title?.prefix || 'Ryunix App',
781
- s = e.pageTitle || e.title
782
- if (
783
- ((o =
784
- u(s) && s.trim()
785
- ? n?.includes('%s')
786
- ? n.replace('%s', s)
787
- : s
788
- : r),
789
- (document.title = o),
790
- e.canonical)
791
- ) {
792
- let t = document.querySelector('link[rel="canonical"]')
793
- ;(t ||
794
- ((t = document.createElement('link')),
795
- t.setAttribute('rel', 'canonical'),
796
- document.head.appendChild(t)),
797
- t.setAttribute('href', e.canonical))
798
- }
799
- Object.entries(e).forEach(([e, t]) => {
800
- if (['title', 'pageTitle', 'canonical'].includes(e)) return
801
- const o = e.startsWith('og:') || e.startsWith('twitter:'),
802
- n = `meta[${o ? 'property' : 'name'}='${e}']`
803
- let r = document.head.querySelector(n)
804
- ;(r ||
805
- ((r = document.createElement('meta')),
806
- r.setAttribute(o ? 'property' : 'name', e),
807
- document.head.appendChild(r)),
808
- r.setAttribute('content', t))
809
- })
810
- }, [JSON.stringify(e), JSON.stringify(t)])
811
- },
812
- useQuery: q,
813
- useReducer: V,
814
- useRef: (e) => {
815
- F()
816
- const t = o(),
817
- { wipFiber: n, hookIndex: s } = t,
818
- i = n.alternate?.hooks?.[s],
819
- c = {
820
- hookID: s,
821
- type: r.RYUNIX_REF,
822
- value: i ? i.value : { current: e },
823
- }
824
- return ((n.hooks[s] = c), t.hookIndex++, c.value)
825
- },
826
- useRouter: G,
827
- useStore: X,
828
- useStorePriority: H,
829
- useTransition: () => {
830
- const [e, t] = H(!1)
831
- return [
832
- e,
833
- (e) => {
834
- ;(t(!0, k.IMMEDIATE),
835
- setTimeout(() => {
836
- ;(e(), t(!1, k.IMMEDIATE))
837
- }, 0))
838
- },
839
- ]
840
- },
841
- })
842
- const Q = (e, t) => (t) => P(() => e(t), [...Object.values(t)]),
843
- K = (e) => {
844
- let t = null,
845
- o = null,
846
- n = null
847
- return (r) => {
848
- const [, s] = X(0)
849
- if (
850
- (j(() => {
851
- t ||
852
- n ||
853
- o ||
854
- (o = e()
855
- .then((e) => {
856
- ;((t = e.default || e), s((e) => e + 1))
857
- })
858
- .catch((e) => {
859
- ;((n = e), s((e) => e + 1))
860
- }))
861
- }, []),
862
- n)
863
- )
864
- throw n
865
- return t ? p(t, r) : null
866
- }
867
- },
868
- Z = ({ fallback: e, children: t }) => {
869
- const [o, n] = X(!0)
870
- return (
871
- j(() => {
872
- n(!1)
873
- }, []),
874
- o && e ? e : t
875
- )
876
- }
877
- let ee = !1,
878
- te = []
879
- const oe = (e) => {
880
- const t = ee
881
- ee = !0
882
- try {
883
- e()
884
- } finally {
885
- ;((ee = t), !ee && te.length > 0 && ne())
886
- }
887
- },
888
- ne = () => {
889
- if (0 === te.length) return
890
- const e = te
891
- ;((te = []), e.forEach((e) => e()))
892
- }
893
- var re = Object.freeze({
894
- __proto__: null,
895
- Fragment: f,
896
- Hooks: J,
897
- Priority: k,
898
- Suspense: Z,
899
- batchUpdates: oe,
900
- createElement: p,
901
- init: U,
902
- lazy: K,
903
- memo: Q,
904
- profiler: I,
905
- render: C,
906
- safeRender: D,
907
- useProfiler: O,
908
- withProfiler: S,
909
- })
910
- ;((window.Ryunix = re),
911
- (e.Fragment = f),
912
- (e.Hooks = J),
913
- (e.Image = ({ src: e, ...t }) => p('img', { ...t, src: e })),
914
- (e.Priority = k),
915
- (e.Suspense = Z),
916
- (e.batchUpdates = oe),
917
- (e.createElement = p),
918
- (e.default = re),
919
- (e.init = U),
920
- (e.lazy = K),
921
- (e.memo = Q),
922
- (e.profiler = I),
923
- (e.render = C),
924
- (e.safeRender = D),
925
- (e.useProfiler = O),
926
- (e.withProfiler = S),
927
- Object.defineProperty(e, '__esModule', { value: !0 }))
928
- })
929
- //# sourceMappingURL=Ryunix.min.js.map