ziko 1.6.0 → 1.7.0

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/ziko.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Fri Jul 31 2026 17:26:32 GMT+0100 (UTC+01:00)
5
+ Date : Fri Aug 07 2026 20:07:58 GMT+0100 (UTC+01:00)
6
6
  Git-Repo : https://github.com/zakarialaoui10/ziko.js
7
7
  Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
8
8
  Released under MIT License
@@ -11,11 +11,11 @@
11
11
  const { PI: PI$1, E } = Math;
12
12
  const EPSILON=Number.EPSILON;
13
13
 
14
- const is_primitive = value => typeof value !== 'object' && typeof value !== 'function' || value === null;
14
+ const is_primitive$1 = value => typeof value !== 'object' && typeof value !== 'function' || value === null;
15
15
 
16
16
  const mapfun$1=(fun,...X)=>{
17
17
  const Y=X.map(x=>{
18
- if(is_primitive(x) || x?.__mapfun__) return fun(x)
18
+ if(is_primitive$1(x) || x?.__mapfun__) return fun(x)
19
19
  if(x instanceof Array) return x.map(n=>mapfun$1(fun,n));
20
20
  if(ArrayBuffer.isView(x)) return x.map(n=>fun(n));
21
21
  if(x instanceof Set) return new Set(mapfun$1(fun,...[...x]));
@@ -2227,12 +2227,39 @@ function __init__global__(){
2227
2227
  }
2228
2228
  }
2229
2229
 
2230
+ const parse_props = (props = {}) => {
2231
+
2232
+ const result = {
2233
+ methods: {},
2234
+ events: {},
2235
+ style: {},
2236
+ attrs: {}
2237
+ };
2238
+
2239
+ for (const [key, value] of Object.entries(props)) {
2240
+ if (key === "style") {
2241
+ result.style = value;
2242
+ }
2243
+ else if (key.startsWith("$")) {
2244
+ result.methods[key.slice(1)] = value;
2245
+ }
2246
+ else if (/^on[A-Z]/.test(key)) {
2247
+ result.events[key] = value;
2248
+ }
2249
+ else {
2250
+ result.attrs[key] = value;
2251
+ }
2252
+ }
2253
+
2254
+ return result;
2255
+ };
2256
+
2230
2257
  __init__global__();
2231
2258
  class UIElementCore extends UINode{
2232
2259
  constructor(){
2233
2260
  super();
2234
2261
  }
2235
- init(element, name, type, render){
2262
+ init({element, name, type, render, props = {}, items = []} = {}){
2236
2263
  this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
2237
2264
  if(typeof element === "string") {
2238
2265
  switch(type){
@@ -2280,9 +2307,26 @@ class UIElementCore extends UINode{
2280
2307
  };
2281
2308
  if(element) Object.assign(this.cache,{element});
2282
2309
  this.items = new UIStore();
2283
- globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
2310
+ globalThis.__Ziko__.__UI__[this.cache.name]
2311
+ ? globalThis.__Ziko__.__UI__[this.cache.name]?.push(this)
2312
+ : globalThis.__Ziko__.__UI__[this.cache.name]=[this];
2284
2313
  element && render && this?.render?.();
2285
2314
  globalThis.__Ziko__.__UI__.push(this);
2315
+
2316
+ // console.log({props})
2317
+ const parsed_props = parse_props(props);
2318
+
2319
+ this.parsed_props = parsed_props;
2320
+
2321
+ this.style(parsed_props.style);
2322
+ this.setAttr(parsed_props.attrs);
2323
+
2324
+ const Events = Object.entries(parsed_props.events);
2325
+
2326
+ Events.forEach(([ev, callback]) => this[ev](callback.bind(this)));
2327
+
2328
+
2329
+ if(items.length > 0) this.append(...items);
2286
2330
  }
2287
2331
  get element(){
2288
2332
  return this.cache.element;
@@ -2390,8 +2434,9 @@ var LifecycleMethods = /*#__PURE__*/Object.freeze({
2390
2434
 
2391
2435
  // if (!globalThis.__Ziko__) __init__global__();
2392
2436
 
2437
+ const STATE_GETTER = Symbol.for("ziko.stateGetter");
2438
+
2393
2439
  function useState(initialValue) {
2394
-
2395
2440
  const state = {
2396
2441
  value: initialValue,
2397
2442
  subscribers: new Set(),
@@ -2401,7 +2446,6 @@ function useState(initialValue) {
2401
2446
  function getValue() {
2402
2447
  return {
2403
2448
  value: state.value,
2404
- isStateGetter: () => true,
2405
2449
  _subscribe: (fn) => {
2406
2450
  state.subscribers.add(fn);
2407
2451
  return () => state.subscribers.delete(fn);
@@ -2409,6 +2453,8 @@ function useState(initialValue) {
2409
2453
  };
2410
2454
  }
2411
2455
 
2456
+ getValue[STATE_GETTER] = true;
2457
+
2412
2458
  function setValue(newValue) {
2413
2459
  if (state.paused) return;
2414
2460
 
@@ -2430,6 +2476,7 @@ function useState(initialValue) {
2430
2476
  if (typeof newValue === "function") {
2431
2477
  newValue = newValue(state.value);
2432
2478
  }
2479
+
2433
2480
  state.value = newValue;
2434
2481
  state.subscribers.forEach((fn) => fn(state.value));
2435
2482
  },
@@ -2439,9 +2486,7 @@ function useState(initialValue) {
2439
2486
  return [getValue, setValue, controller];
2440
2487
  }
2441
2488
 
2442
- const isStateGetter = (arg) => {
2443
- return typeof arg === "function" && arg?.()?.isStateGetter?.() === true;
2444
- };
2489
+ const isStateGetter = (arg) => typeof arg === "function" && arg[STATE_GETTER] === true;
2445
2490
 
2446
2491
  const camel2hyphencase = (text = '') => text.replace(/[A-Z]/g, match => '-' + match.toLowerCase());
2447
2492
 
@@ -2592,8 +2637,8 @@ async function __addItem__(adder, pusher, ...ele) {
2592
2637
  if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
2593
2638
  // Fix Items Latter
2594
2639
  if (ele[i] instanceof Function) {
2595
- const getter = ele[i]();
2596
- if (getter.isStateGetter) {
2640
+ if (isStateGetter(ele[i])) {
2641
+ const getter = ele[i]();
2597
2642
  ele[i] = text(getter.value);
2598
2643
  getter._subscribe(
2599
2644
  (newValue) => (ele[i].element.textContent = newValue),
@@ -3083,7 +3128,7 @@ function register_swipe_event(
3083
3128
  }
3084
3129
 
3085
3130
  let UIElement$1 = class UIElement extends UIElementCore{
3086
- constructor({element, name ='', type='html', render = __Ziko__.__Config__.default.render}={}){
3131
+ constructor({element, name ='', type = 'html', render = __Ziko__.__Config__.default.render, props}={}){
3087
3132
  super();
3088
3133
  this.exp = {
3089
3134
  events : {
@@ -3103,7 +3148,7 @@ let UIElement$1 = class UIElement extends UIElementCore{
3103
3148
  ViewListeners,
3104
3149
  );
3105
3150
 
3106
- if(element)this.init(element, name, type, render);
3151
+ if(element) this.init({element, name, type, render, props});
3107
3152
  }
3108
3153
  on(event_name, callback, {details_setter, category = 'global', isCustom = false, preventDefault = false} = {}){
3109
3154
  if(event_name instanceof Array) event_name.forEach(
@@ -3196,15 +3241,22 @@ let UIElement$1 = class UIElement extends UIElementCore{
3196
3241
 
3197
3242
  };
3198
3243
 
3244
+ const is_primitive = (value) => typeof value !== 'object' && typeof value !== 'function' || value === null;
3245
+
3199
3246
  const call_with_optional_props = (Component) => {
3200
3247
  return (...args) => {
3201
3248
  const first = args[0];
3202
- const isChild = first?.isUIElement?.() || isPrimitive(first) ;
3203
- return isChild
3204
- ? new Component({}, ...args)
3205
- : new Component(first, ...args.slice(1))
3249
+
3250
+ const isChild = first?.isUIElement?.() || is_primitive(first);
3251
+
3252
+ if (isChild) {
3253
+ return new Component({}, ...args);
3254
+ }
3255
+
3256
+ return new Component(first, ...args.slice(1));
3206
3257
  };
3207
- };
3258
+ };
3259
+
3208
3260
  function add_vendor_prefix(property) {
3209
3261
  const propertyUC = property.slice(0, 1).toUpperCase() + property.slice(1);
3210
3262
  const vendors = ['Webkit', 'Moz', 'O', 'ms'];
@@ -3257,9 +3309,9 @@ const CloneElement = (UIElement) => {
3257
3309
  const cloneUI=UIElement=>{
3258
3310
  return Object.assign(Object.create(Object.getPrototypeOf(UIElement)),UIElement)
3259
3311
  };
3260
- function isPrimitive(value) {
3261
- return typeof value !== 'object' && typeof value !== 'function' || value === null;
3262
- }
3312
+ // function isPrimitive(value) {
3313
+ // return typeof value !== 'object' && typeof value !== 'function' || value === null;
3314
+ // }
3263
3315
  const waitElm=(UIElement)=>{
3264
3316
  return new Promise(resolve => {
3265
3317
  if (UIElement) {
@@ -3431,40 +3483,18 @@ const tags = new Proxy({}, {
3431
3483
  if(HTMLTags.includes(tag)) type = 'html';
3432
3484
  if(SVGTags.includes(tag)) type = 'svg';
3433
3485
  if(MathMLTags.includes(tag)) type = 'mathml';
3434
- return (...args)=>{
3435
- // Fix undefined
3436
- // console.log(isStateGetter(args[0]))
3437
- // console.log(!!args)
3486
+ return (...args) => {
3438
3487
  if(args.length === 0) {
3439
- // console.log('length 0')
3440
3488
  return new UIElement$1({element : tag, name : tag, type})
3441
3489
  }
3442
3490
  if(
3443
3491
  ['string', 'number'].includes(typeof args[0])
3444
3492
  || args[0] instanceof UIElement$1
3445
- || (typeof args[0] === 'function' && args[0]().isStateGetter())
3493
+ || isStateGetter(args[0])
3494
+ || args[0] instanceof HTMLElement
3446
3495
  ) return new UIElement$1({element : tag, name : tag, type}).append(...args);
3447
- // console.log(args[0])
3448
- return new UIElement$1({element : tag, type}).setAttr(args.shift()).append(...args)
3449
- }
3450
- // if(SVGTags.includes(tag)) return (...args) => new UIElement(tag,"",{el_type : "svg"}).append(...args);
3451
- // return (...args)=>{
3452
- // if(!(args[0] instanceof UIElement) && args[0] instanceof Object){
3453
- // let attributes = args.shift()
3454
- // return new UIElement(tag).setAttr(attributes).append(...args)
3455
- // }
3456
- // return new UIElement(tag).append(...args);
3457
- // }
3458
- // // switch(tag){
3459
- // case "html" : globalThis?.document?.createElement("html")
3460
- // case "head" :
3461
- // case "style" :
3462
- // case "link" :
3463
- // case "meta" :
3464
- // case "srcipt":
3465
- // case "body" : return null; break;
3466
- // default : return new UIElement(tag);
3467
- // }
3496
+ return new UIElement$1({element : tag, type, props : args.shift()}).append(...args)
3497
+ }
3468
3498
  }
3469
3499
  });
3470
3500
 
@@ -3748,7 +3778,9 @@ class UISwap extends UIElement$1 {
3748
3778
  };
3749
3779
 
3750
3780
  this.append(...items);
3751
- this.render();
3781
+ requestAnimationFrame(() => {
3782
+ this.render();
3783
+ });
3752
3784
  }
3753
3785
  get activeItem(){
3754
3786
  return this.items[this.states.activeIndex]
@@ -3756,7 +3788,7 @@ class UISwap extends UIElement$1 {
3756
3788
  render() {
3757
3789
  this.items.forEach((n, i) => {
3758
3790
 
3759
- const initialDisplay = n.element?.style?.display || '';
3791
+ const initialDisplay = getComputedStyle(n.element).display;
3760
3792
  this.#DISPLAYS_MAP.set(n, initialDisplay);
3761
3793
 
3762
3794
  if (i !== this.states.activeIndex) {
@@ -3764,6 +3796,9 @@ class UISwap extends UIElement$1 {
3764
3796
  }
3765
3797
  });
3766
3798
  }
3799
+ get DS(){
3800
+ return this.#DISPLAYS_MAP
3801
+ }
3767
3802
  next(n = 1) {
3768
3803
  return this.activate(this.states.activeIndex + n);
3769
3804
  }
@@ -4391,13 +4426,15 @@ const csv2object = (csv, delimiter = ",") => {
4391
4426
  };
4392
4427
  const csv2json = (csv, delimiter = ",") => JSON.stringify(csv2object(csv,delimiter));
4393
4428
  const csv2sql=(csv, Table)=>{
4429
+ const sanitizeId = s => s.trim().replace(/[^a-zA-Z0-9_]/g, '');
4430
+ const escapeVal = s => "'" + s.trim().replace(/'/g, "''") + "'";
4394
4431
  const lines = csv.trim().trimEnd().split('\n').filter(n=>n);
4395
- const columns = lines[0].split(',');
4396
- let sqlQuery = `INSERT INTO ${Table} (${columns.join(', ')}) Values `;
4432
+ const columns = lines[0].split(',').map(sanitizeId);
4433
+ let sqlQuery = "INSERT INTO " + sanitizeId(Table) + " (" + columns.join(', ') + ") Values ";
4397
4434
  let sqlValues = [];
4398
4435
  for (let i = 1; i < lines.length; i++) {
4399
- const values = lines[i].split(',');
4400
- sqlValues.push(`(${values})`);
4436
+ const values = lines[i].split(',').map(escapeVal);
4437
+ sqlValues.push("(" + values.join(', ') + ")");
4401
4438
  }
4402
4439
  return sqlQuery+sqlValues.join(",\n");
4403
4440
  };
@@ -4514,6 +4551,35 @@ function trimKeys(obj) {
4514
4551
  }, Array.isArray(obj) ? [] : {});
4515
4552
  }
4516
4553
 
4554
+ function parseXML(xmlString) {
4555
+ const parser = new DOMParser();
4556
+ const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
4557
+ const rootNode = xmlDoc.documentElement;
4558
+ const result = parseNode(rootNode);
4559
+ return result;
4560
+ }
4561
+
4562
+ function parseNode(node) {
4563
+ const obj = {
4564
+ type: node.nodeName,
4565
+ attributes: {},
4566
+ children: []
4567
+ };
4568
+ for (let i = 0; i < node.attributes.length; i++) {
4569
+ const attr = node.attributes[i];
4570
+ obj.attributes[attr.name] = attr.value;
4571
+ }
4572
+ for (let i = 0; i < node.childNodes.length; i++) {
4573
+ const child = node.childNodes[i];
4574
+ if (child.nodeType === Node.ELEMENT_NODE) {
4575
+ obj.children.push(parseNode(child));
4576
+ } else if (child.nodeType === Node.TEXT_NODE) {
4577
+ obj.text = child.textContent.trim();
4578
+ }
4579
+ }
4580
+ return obj;
4581
+ }
4582
+
4517
4583
  // import { ZikoHead , useHead} from "../reactivity/hooks/head/index.js";
4518
4584
  class ZikoApp {
4519
4585
  constructor({head = null, wrapper = null, target = null}){
@@ -5227,4 +5293,4 @@ if(globalThis?.document){
5227
5293
  document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
5228
5294
  }
5229
5295
 
5230
- export { App, ClickAwayEvent, ClickListeners, Clock, CloneElement, Complex, E, EPSILON, EventController, FileBasedRouting, Flex, For, Fragment, HTMLWrapper, KeyListeners, Matrix, PI$1 as PI, PtrListeners, Random, SPA, SVGWrapper, Scheduler, Suspense, Swap, SwipeEvent, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIFlex, UIFragment, UIHTMLWrapper, UINode, UISVGWrapper, UISwap, UISwitch, UIView, UseRoot, UseThread, View, ViewEvent, ViewListeners, ZikoApp, ZikoSPA, ZikoUISuspense, ZikoUIText, abs, accum_max, accum_min, accum_prod, accum_product, accum_sum, acos$1 as acos, acosh, acot, add, add_class, add_vendor_prefix, and, animation, apply_fun, arc, asin, asinh, atan, atan2, atanh, back, binomial, call_with_optional_props, cbrt, ceil, clamp, clock, cloneUI, complex, contraharmonic_mean, cos$3 as cos, cosh$2 as cosh, coth, croot, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, discret, div, elastic, ema, exp$1 as exp, floor, fract, geo_mean, harmonic_mean, hypot, in_back, in_bounce, in_circ, in_cubic, in_elastic, in_expo, in_out_back, in_out_bounce, in_out_circ, in_out_cubic, in_out_elastic, in_out_expo, in_out_quad, in_out_quart, in_out_quint, in_out_sin, in_quad, in_quart, in_quint, in_sin, interquartile_mean, iqr, isPrimitive, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linear, linkStyle, ln, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, mean, median, midhinge, midrange, min, modulo, mul, nand, nor, norm, normalize_css_value, not, nthr, or, out_back, out_bounce, out_circ, out_cubic, out_elastic, out_expo, out_quad, out_quart, out_quint, out_sin, percentile, pow$1 as pow, power_mean, q1, q3, rad2deg, register_click_away_event, register_swipe_event, register_view_event, remove_class, rms, rolling_std, rolling_variance, round, sample_std, sample_variance, script, sec, sig, sign, sin$3 as sin, sinh$1 as sinh, sleep, sma, sqrt$2 as sqrt, std, step, step_fps, style, sub, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, trimmed_mean, trunc, useDerived, useEventEmitter, useIPC, useLocalStorage, useMediaQuery, useQueryParams, useReactive, useRoot, useSessionStorage, useState, useThread, useTitle, variance, wait, waitElm, waitForUIElm, waitForUIElmSync, watchQueryParams, weighted_mean, weighted_std, weighted_variance, winsorized_mean, wma, xnor, xor };
5296
+ export { App, ClickAwayEvent, ClickListeners, Clock, CloneElement, Complex, E, EPSILON, EventController, FileBasedRouting, Flex, For, Fragment, HTMLWrapper, KeyListeners, Matrix, PI$1 as PI, PtrListeners, Random, SPA, STATE_GETTER, SVGWrapper, Scheduler, Suspense, Swap, SwipeEvent, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIFlex, UIFragment, UIHTMLWrapper, UINode, UISVGWrapper, UISwap, UISwitch, UIView, UseRoot, UseThread, View, ViewEvent, ViewListeners, ZikoApp, ZikoSPA, ZikoUISuspense, ZikoUIText, abs, accum_max, accum_min, accum_prod, accum_product, accum_sum, acos$1 as acos, acosh, acot, add, add_class, add_vendor_prefix, and, animation, apply_fun, arc, asin, asinh, atan, atan2, atanh, back, binomial, call_with_optional_props, cbrt, ceil, clamp, clock, cloneUI, complex, contraharmonic_mean, cos$3 as cos, cosh$2 as cosh, coth, croot, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, discret, div, elastic, ema, exp$1 as exp, floor, fract, geo_mean, harmonic_mean, hypot, in_back, in_bounce, in_circ, in_cubic, in_elastic, in_expo, in_out_back, in_out_bounce, in_out_circ, in_out_cubic, in_out_elastic, in_out_expo, in_out_quad, in_out_quart, in_out_quint, in_out_sin, in_quad, in_quart, in_quint, in_sin, interquartile_mean, iqr, isStateGetter, is_primitive, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linear, linkStyle, ln, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, mean, median, midhinge, midrange, min, modulo, mul, nand, nor, norm, normalize_css_value, not, nthr, or, out_back, out_bounce, out_circ, out_cubic, out_elastic, out_expo, out_quad, out_quart, out_quint, out_sin, parseXML, parse_props, percentile, pow$1 as pow, power_mean, q1, q3, rad2deg, register_click_away_event, register_swipe_event, register_view_event, remove_class, rms, rolling_std, rolling_variance, round, sample_std, sample_variance, script, sec, sig, sign, sin$3 as sin, sinh$1 as sinh, sleep, sma, sqrt$2 as sqrt, std, step, step_fps, style, sub, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, trimmed_mean, trunc, useDerived, useEventEmitter, useIPC, useLocalStorage, useMediaQuery, useQueryParams, useReactive, useRoot, useSessionStorage, useState, useThread, useTitle, variance, wait, waitElm, waitForUIElm, waitForUIElmSync, watchQueryParams, weighted_mean, weighted_std, weighted_variance, winsorized_mean, wma, xnor, xor };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ziko",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "A versatile JavaScript library offering a rich set of Hyperscript Based UI components, advanced mathematical utilities, interactivity ,animations, client side routing and more ...",
5
5
  "keywords": [
6
6
  "front-end",
@@ -14,13 +14,15 @@ const csv2object = (csv, delimiter = ",") => {
14
14
  };
15
15
  const csv2json = (csv, delimiter = ",") => JSON.stringify(csv2object(csv,delimiter));
16
16
  const csv2sql=(csv, Table)=>{
17
+ const sanitizeId = s => s.trim().replace(/[^a-zA-Z0-9_]/g, '');
18
+ const escapeVal = s => "'" + s.trim().replace(/'/g, "''") + "'";
17
19
  const lines = csv.trim().trimEnd().split('\n').filter(n=>n);
18
- const columns = lines[0].split(',');
19
- let sqlQuery = `INSERT INTO ${Table} (${columns.join(', ')}) Values `
20
+ const columns = lines[0].split(',').map(sanitizeId);
21
+ let sqlQuery = "INSERT INTO " + sanitizeId(Table) + " (" + columns.join(', ') + ") Values ";
20
22
  let sqlValues = []
21
23
  for (let i = 1; i < lines.length; i++) {
22
- const values = lines[i].split(',');
23
- sqlValues.push(`(${values})`)
24
+ const values = lines[i].split(',').map(escapeVal);
25
+ sqlValues.push("(" + values.join(', ') + ")")
24
26
  }
25
27
  return sqlQuery+sqlValues.join(",\n");
26
28
  }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Represents a parsed XML node.
3
+ */
4
+ export interface XMLNode {
5
+ /**
6
+ * The XML tag name of the node.
7
+ */
8
+ type: string;
9
+
10
+ /**
11
+ * The attributes of the XML node.
12
+ */
13
+ attributes: Record<string, string>;
14
+
15
+ /**
16
+ * The child elements of the XML node.
17
+ */
18
+ children: XMLNode[];
19
+
20
+ /**
21
+ * The text content of the node, if available.
22
+ */
23
+ text?: string;
24
+ }
25
+
26
+ /**
27
+ * Parses an XML string into a tree-like JavaScript object representation.
28
+ *
29
+ * @param xmlString - The XML document as a string.
30
+ * @returns The parsed XML node tree.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const xml = `<root><item id="1">Hello</item></root>`;
35
+ * const tree = parseXML(xml);
36
+ *
37
+ * console.log(tree.type); // "root"
38
+ * console.log(tree.children[0].attributes.id); // "1"
39
+ * ```
40
+ */
41
+ export declare function parseXML(xmlString: string): XMLNode;
@@ -1 +1,28 @@
1
- export * from "./xml"
1
+ export function parseXML(xmlString) {
2
+ const parser = new DOMParser();
3
+ const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
4
+ const rootNode = xmlDoc.documentElement;
5
+ const result = parseNode(rootNode);
6
+ return result;
7
+ }
8
+
9
+ function parseNode(node) {
10
+ const obj = {
11
+ type: node.nodeName,
12
+ attributes: {},
13
+ children: []
14
+ };
15
+ for (let i = 0; i < node.attributes.length; i++) {
16
+ const attr = node.attributes[i];
17
+ obj.attributes[attr.name] = attr.value;
18
+ }
19
+ for (let i = 0; i < node.childNodes.length; i++) {
20
+ const child = node.childNodes[i];
21
+ if (child.nodeType === Node.ELEMENT_NODE) {
22
+ obj.children.push(parseNode(child));
23
+ } else if (child.nodeType === Node.TEXT_NODE) {
24
+ obj.text = child.textContent.trim();
25
+ }
26
+ }
27
+ return obj;
28
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Checks if a string follows camelCase notation.
3
+ *
4
+ * @param text - The string to check.
5
+ * @returns `true` if the string is camelCase, otherwise `false`.
6
+ */
7
+ export declare const is_camelcase: (text?: string) => boolean;
8
+
9
+ /**
10
+ * Checks if a string follows kebab-case (hyphen-case) notation.
11
+ *
12
+ * @param text - The string to check.
13
+ * @returns `true` if the string contains a hyphen separator, otherwise `false`.
14
+ */
15
+ export declare const is_hyphencase: (text?: string) => boolean;
16
+
17
+ /**
18
+ * Checks if a string follows snake_case notation.
19
+ *
20
+ * @param text - The string to check.
21
+ * @returns `true` if the string contains an underscore separator, otherwise `false`.
22
+ */
23
+ export declare const is_snakeCase: (text?: string) => boolean;
24
+
25
+ /**
26
+ * Checks if a string follows PascalCase notation.
27
+ *
28
+ * @param text - The string to check.
29
+ * @returns `true` if the string is PascalCase, otherwise `false`.
30
+ */
31
+ export declare const is_pascalcase: (text?: string) => boolean;
32
+
33
+ /**
34
+ * Checks whether a string is a palindrome.
35
+ *
36
+ * A palindrome is a string that reads the same forward and backward.
37
+ *
38
+ * @param text - The string to check.
39
+ * @returns `true` if the string is a palindrome, otherwise `false`.
40
+ */
41
+ export declare const is_palindrome: (text: string) => boolean;
42
+
43
+ /**
44
+ * Checks whether two words are anagrams.
45
+ *
46
+ * Two words are anagrams if they contain the same characters with the same frequency.
47
+ *
48
+ * @param word - The first word.
49
+ * @param words - The second word to compare with.
50
+ * @returns `true` if both words are anagrams, otherwise `false`.
51
+ */
52
+ export declare const is_anagram: (word: string, words: string) => boolean;
53
+
54
+ /**
55
+ * Checks whether a string is an isogram.
56
+ *
57
+ * An isogram is a word with no repeating characters.
58
+ *
59
+ * @param text - The string to check.
60
+ * @returns `true` if the string has no repeated characters, otherwise `false`.
61
+ */
62
+ export declare const is_isogram: (text?: string) => boolean;
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Converts a camelCase string to hyphen-case.
3
+ *
4
+ * @param text - The camelCase string.
5
+ * @returns The converted hyphen-case string.
6
+ */
7
+ export declare const camel2hyphencase: (text?: string) => string;
8
+
9
+ /**
10
+ * Converts a camelCase string to snake_case.
11
+ *
12
+ * @param text - The camelCase string.
13
+ * @returns The converted snake_case string.
14
+ */
15
+ export declare const camel2snakecase: (text?: string) => string;
16
+
17
+ /**
18
+ * Converts a camelCase string to PascalCase.
19
+ *
20
+ * @param text - The camelCase string.
21
+ * @returns The converted PascalCase string.
22
+ */
23
+ export declare const camel2pascalcase: (text?: string) => string;
24
+
25
+ /**
26
+ * Converts a camelCase string to CONSTANT_CASE.
27
+ *
28
+ * @param text - The camelCase string.
29
+ * @returns The converted CONSTANT_CASE string.
30
+ */
31
+ export declare const camel2constantcase: (text?: string) => string;
32
+
33
+ /**
34
+ * Converts a PascalCase string to snake_case.
35
+ *
36
+ * @param text - The PascalCase string.
37
+ * @returns The converted snake_case string.
38
+ */
39
+ export declare const pascal2snakecase: (text?: string) => string;
40
+
41
+ /**
42
+ * Converts a PascalCase string to hyphen-case.
43
+ *
44
+ * @param text - The PascalCase string.
45
+ * @returns The converted hyphen-case string.
46
+ */
47
+ export declare const pascal2hyphencase: (text?: string) => string;
48
+
49
+ /**
50
+ * Converts a PascalCase string to camelCase.
51
+ *
52
+ * @param text - The PascalCase string.
53
+ * @returns The converted camelCase string.
54
+ */
55
+ export declare const pascal2camelcase: (text?: string) => string;
56
+
57
+ /**
58
+ * Converts a PascalCase string to CONSTANT_CASE.
59
+ *
60
+ * @param text - The PascalCase string.
61
+ * @returns The converted CONSTANT_CASE string.
62
+ */
63
+ export declare const pascal2constantcase: (text?: string) => string;
64
+
65
+ /**
66
+ * Converts a snake_case string to camelCase.
67
+ *
68
+ * @param text - The snake_case string.
69
+ * @returns The converted camelCase string.
70
+ */
71
+ export declare const snake2camelcase: (text?: string) => string;
72
+
73
+ /**
74
+ * Converts a snake_case string to hyphen-case.
75
+ *
76
+ * @param text - The snake_case string.
77
+ * @returns The converted hyphen-case string.
78
+ */
79
+ export declare const snake2hyphencase: (text?: string) => string;
80
+
81
+ /**
82
+ * Converts a snake_case string to PascalCase.
83
+ *
84
+ * @param text - The snake_case string.
85
+ * @returns The converted PascalCase string.
86
+ */
87
+ export declare const snake2pascalcase: (text?: string) => string;
88
+
89
+ /**
90
+ * Converts a snake_case string to CONSTANT_CASE.
91
+ *
92
+ * @param text - The snake_case string.
93
+ * @returns The converted CONSTANT_CASE string.
94
+ */
95
+ export declare const snake2constantcase: (text?: string) => string;
96
+
97
+ /**
98
+ * Converts a hyphen-case string to camelCase.
99
+ *
100
+ * @param text - The hyphen-case string.
101
+ * @returns The converted camelCase string.
102
+ */
103
+ export declare const hyphen2camelcase: (text?: string) => string;
104
+
105
+ /**
106
+ * Converts a hyphen-case string to snake_case.
107
+ *
108
+ * @param text - The hyphen-case string.
109
+ * @returns The converted snake_case string.
110
+ */
111
+ export declare const hyphen2snakecase: (text?: string) => string;
112
+
113
+ /**
114
+ * Converts a hyphen-case string to PascalCase.
115
+ *
116
+ * @param text - The hyphen-case string.
117
+ * @returns The converted PascalCase string.
118
+ */
119
+ export declare const hyphen2pascalcase: (text?: string) => string;
120
+
121
+ /**
122
+ * Converts a hyphen-case string to CONSTANT_CASE.
123
+ *
124
+ * @param text - The hyphen-case string.
125
+ * @returns The converted CONSTANT_CASE string.
126
+ */
127
+ export declare const hyphen2constantcase: (text?: string) => string;
128
+
129
+ /**
130
+ * Converts a CONSTANT_CASE string to camelCase.
131
+ *
132
+ * @param text - The CONSTANT_CASE string.
133
+ * @returns The converted camelCase string.
134
+ */
135
+ export declare const constant2camelcase: (text?: string) => string;
136
+
137
+ /**
138
+ * Converts a CONSTANT_CASE string to snake_case.
139
+ *
140
+ * @param text - The CONSTANT_CASE string.
141
+ * @returns The converted snake_case string.
142
+ */
143
+ export declare const constant2snakecase: (text?: string) => string;
144
+
145
+ /**
146
+ * Converts a CONSTANT_CASE string to PascalCase.
147
+ *
148
+ * @param text - The CONSTANT_CASE string.
149
+ * @returns The converted PascalCase string.
150
+ */
151
+ export declare const constant2pascalcase: (text?: string) => string;
152
+
153
+ /**
154
+ * Converts a CONSTANT_CASE string to hyphen-case.
155
+ *
156
+ * @param text - The CONSTANT_CASE string.
157
+ * @returns The converted hyphen-case string.
158
+ */
159
+ export declare const constant2hyphencase: (text?: string) => string;
@@ -0,0 +1,2 @@
1
+ export * from './checkers/index.d.ts'
2
+ export * from './converters/index.d.ts'
@@ -1,2 +1,2 @@
1
- export * from './converters.js';
2
- export * from './checkers.js'
1
+ export * from './converters/index.js';
2
+ export * from './checkers/index.js'
@@ -0,0 +1,2 @@
1
+ export * from './fragment/index.d.ts'
2
+ export * from './swap/index.d.ts'