@design-edito/tools 0.1.20 → 0.1.21

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.
@@ -3,9 +3,8 @@ export declare namespace Arrays {
3
3
  type Filler<T = any> = (pos?: number) => T;
4
4
  export function make<T>(filler: Filler<T>, length: number): T[];
5
5
  export function findDuplicates<T>(arr: T[], stopAtFirst?: boolean): T[];
6
- export const randomPickErrorSybol: unique symbol;
7
- export type RandomPickErrorSymbol = typeof randomPickErrorSybol;
8
- export function randomPick<T>(arr: T[], exclude?: T[]): T | RandomPickErrorSymbol;
6
+ export const ERR_SYMBOL: unique symbol;
7
+ export function randomPick<T>(arr: T[], exclude?: T[]): T | typeof ERR_SYMBOL;
9
8
  export const isArrayOf: typeof isArrayOfFunc;
10
9
  export {};
11
10
  }
@@ -1,23 +1,7 @@
1
1
  import {
2
- isConstructorFunction
3
- } from "../../../chunks/chunk-RCO57B6F.js";
4
-
5
- // src/agnostic/arrays/is-array-of/index.ts
6
- function isArrayOf(input, _types = []) {
7
- if (!Array.isArray(input)) return false;
8
- const types = Array.isArray(_types) ? _types : [_types];
9
- if (types.length === 0) return true;
10
- return input.every((entry) => {
11
- return types.some((typeChecker) => {
12
- const isConstructor = isConstructorFunction(typeChecker);
13
- if (!isConstructor) return typeChecker(entry);
14
- if (typeChecker === Number) return typeof entry === "number";
15
- if (typeChecker === String) return typeof entry === "string";
16
- if (typeChecker === Boolean) return typeof entry === "boolean";
17
- if (isConstructor) return entry instanceof typeChecker;
18
- });
19
- });
20
- }
2
+ isArrayOf
3
+ } from "../../../chunks/chunk-6RGDWX4A.js";
4
+ import "../../../chunks/chunk-RCO57B6F.js";
21
5
  export {
22
6
  isArrayOf
23
7
  };
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  Transitions
3
3
  } from "../../chunks/chunk-4GDNHUCZ.js";
4
- import {
5
- wait
6
- } from "../../chunks/chunk-DQNJQBC6.js";
7
4
  import {
8
5
  timeoutCall
9
6
  } from "../../chunks/chunk-4VC5PT5T.js";
7
+ import {
8
+ wait
9
+ } from "../../chunks/chunk-DQNJQBC6.js";
10
10
 
11
11
  // src/agnostic/async/index.ts
12
12
  var Async;
@@ -3,10 +3,17 @@ import {
3
3
  } from "../../chunks/chunk-WLL3FNVL.js";
4
4
  import {
5
5
  register
6
- } from "../../chunks/chunk-C5WKMLKU.js";
6
+ } from "../../chunks/chunk-ZMHKLIP2.js";
7
7
  import {
8
8
  Crossenv
9
9
  } from "../../chunks/chunk-GJOU3UAL.js";
10
+ import "../../chunks/chunk-WH6BPDAC.js";
11
+ import "../../chunks/chunk-QHLQVR3E.js";
12
+ import "../../chunks/chunk-FENXVJYO.js";
13
+ import {
14
+ generateNiceColor,
15
+ niceColors
16
+ } from "../../chunks/chunk-EDVNAV3G.js";
10
17
  import {
11
18
  Bem
12
19
  } from "../../chunks/chunk-KIONYWA7.js";
@@ -14,13 +21,6 @@ import {
14
21
  classNameRegex,
15
22
  isValidClassName
16
23
  } from "../../chunks/chunk-W5A2TON3.js";
17
- import {
18
- generateNiceColor,
19
- niceColors
20
- } from "../../chunks/chunk-EDVNAV3G.js";
21
- import "../../chunks/chunk-2KT7AKRW.js";
22
- import "../../chunks/chunk-FENXVJYO.js";
23
- import "../../chunks/chunk-QHLQVR3E.js";
24
24
  import "../../chunks/chunk-QXAJXTXV.js";
25
25
  import "../../chunks/chunk-HC6ZOHCS.js";
26
26
 
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  Errors
3
- } from "../../chunks/chunk-2KT7AKRW.js";
4
- import "../../chunks/chunk-FENXVJYO.js";
3
+ } from "../../chunks/chunk-WH6BPDAC.js";
5
4
  import "../../chunks/chunk-QHLQVR3E.js";
5
+ import "../../chunks/chunk-FENXVJYO.js";
6
6
  export {
7
7
  Errors
8
8
  };
@@ -0,0 +1,45 @@
1
+ export declare namespace HyperJson {
2
+ const isElement: (node: Node) => node is Element;
3
+ const isText: (node: Node) => node is Text;
4
+ enum TyperTagName {
5
+ NULL = "null",
6
+ BOOLEAN = "boolean",
7
+ NUMBER = "number",
8
+ STRING = "string",
9
+ TEXT = "text",
10
+ NODELIST = "nodelist",
11
+ ARRAY = "array",
12
+ RECORD = "record"
13
+ }
14
+ enum TransformerTagName {
15
+ MAP = "map",
16
+ REF = "ref",
17
+ ADD = "add",
18
+ MULT = "mult",
19
+ APPEND = "append"
20
+ }
21
+ type PrimitiveValue = null | string | number | boolean | Element | Text | NodeListOf<Text | Element>;
22
+ type Value = PrimitiveValue | Value[] | {
23
+ [k: string]: Value;
24
+ };
25
+ type Transformer = (input: Value) => Value;
26
+ class Tree<T extends Element | Text = Element | Text> {
27
+ readonly node: T;
28
+ readonly name: string | null;
29
+ readonly parent: Tree | null;
30
+ readonly root: Tree;
31
+ readonly path: ReadonlyArray<string | number>;
32
+ readonly pathString: string;
33
+ readonly tagName: T extends Element ? Element['tagName'] : null;
34
+ readonly attributes: T extends Element ? ReadonlyArray<Readonly<Attr>> : null;
35
+ readonly subtrees: ReadonlyMap<string | number, Tree>;
36
+ readonly children: ReadonlyArray<Tree>;
37
+ readonly type: 'element' | 'text' | 'null' | 'number' | 'string' | 'boolean' | 'nodelist' | 'array' | 'record' | 'transformer';
38
+ constructor(node: T);
39
+ constructor(node: T, parent: Tree, pathFromParent: number | string);
40
+ initValue(this: Tree<T>): Value;
41
+ getInnerValue(this: Tree<T>, initialValue: Value): Value;
42
+ wrapInnerValue(this: Tree<T>, innerValue: Value): Value | Transformer;
43
+ evaluate(this: Tree<T>): Value | Transformer;
44
+ }
45
+ }
@@ -0,0 +1,10 @@
1
+ import {
2
+ HyperJson
3
+ } from "../../../chunks/chunk-DMGR57KA.js";
4
+ import "../../../chunks/chunk-E6MSDKON.js";
5
+ import "../../../chunks/chunk-YDIBNEGA.js";
6
+ import "../../../chunks/chunk-QXAJXTXV.js";
7
+ import "../../../chunks/chunk-HC6ZOHCS.js";
8
+ export {
9
+ HyperJson
10
+ };
@@ -1,5 +1,6 @@
1
1
  import { getNodeAncestors as getNodeAncestorsFunc } from './get-node-ancestors';
2
2
  import { getPositionInsideParent as getPositionInsideParentFunc } from './get-position-inside-parent';
3
+ import { HyperJson as HyperJsonNamespace } from './hyper-json';
3
4
  import { InsertNodePosition as InsertNodePositionType, insertNode as insertNodeFunc } from './insert-node';
4
5
  import { Placeholders as PlaceholdersNamespace } from './placeholders';
5
6
  import { Sanitize as SanitizeNamespace } from './sanitize';
@@ -8,6 +9,7 @@ import { stringToNodes as stringToNodesFunc } from './string-to-nodes';
8
9
  export declare namespace Html {
9
10
  const getNodeAncestors: typeof getNodeAncestorsFunc;
10
11
  const getPositionInsideParent: typeof getPositionInsideParentFunc;
12
+ export import HyperJson = HyperJsonNamespace;
11
13
  type InsertNodePosition = InsertNodePositionType;
12
14
  const insertNode: typeof insertNodeFunc;
13
15
  export import Placeholders = PlaceholdersNamespace;
@@ -1,35 +1,43 @@
1
1
  import {
2
- getNodeAncestors
3
- } from "../../chunks/chunk-SQZGZ3VT.js";
2
+ Placeholders
3
+ } from "../../chunks/chunk-VYW4IADX.js";
4
4
  import {
5
5
  getPositionInsideParent
6
6
  } from "../../chunks/chunk-VTPRO4NJ.js";
7
7
  import {
8
- Placeholders
9
- } from "../../chunks/chunk-VYW4IADX.js";
8
+ getNodeAncestors
9
+ } from "../../chunks/chunk-SQZGZ3VT.js";
10
+ import {
11
+ selectorToElement
12
+ } from "../../chunks/chunk-LI5KVXAJ.js";
13
+ import {
14
+ HyperJson
15
+ } from "../../chunks/chunk-DMGR57KA.js";
16
+ import "../../chunks/chunk-E6MSDKON.js";
17
+ import "../../chunks/chunk-YDIBNEGA.js";
10
18
  import {
11
19
  insertNode
12
20
  } from "../../chunks/chunk-XA4HVHJ4.js";
13
- import {
14
- selectorToElement
15
- } from "../../chunks/chunk-FYHRUYTU.js";
16
21
  import {
17
22
  stringToNodes
18
- } from "../../chunks/chunk-6ETCY4VK.js";
23
+ } from "../../chunks/chunk-GL23YDEH.js";
19
24
  import {
20
25
  Sanitize
21
- } from "../../chunks/chunk-2H4QYFEP.js";
22
- import "../../chunks/chunk-C5WKMLKU.js";
26
+ } from "../../chunks/chunk-IFT6HLDW.js";
27
+ import "../../chunks/chunk-ZMHKLIP2.js";
23
28
  import "../../chunks/chunk-GJOU3UAL.js";
24
- import "../../chunks/chunk-2KT7AKRW.js";
25
- import "../../chunks/chunk-FENXVJYO.js";
29
+ import "../../chunks/chunk-WH6BPDAC.js";
26
30
  import "../../chunks/chunk-QHLQVR3E.js";
31
+ import "../../chunks/chunk-FENXVJYO.js";
32
+ import "../../chunks/chunk-QXAJXTXV.js";
33
+ import "../../chunks/chunk-HC6ZOHCS.js";
27
34
 
28
35
  // src/agnostic/html/index.ts
29
36
  var Html;
30
37
  ((Html2) => {
31
38
  Html2.getNodeAncestors = getNodeAncestors;
32
39
  Html2.getPositionInsideParent = getPositionInsideParent;
40
+ Html2.HyperJson = HyperJson;
33
41
  Html2.insertNode = insertNode;
34
42
  Html2.Placeholders = Placeholders;
35
43
  Html2.Sanitize = Sanitize;
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  Sanitize
3
- } from "../../../chunks/chunk-2H4QYFEP.js";
4
- import "../../../chunks/chunk-C5WKMLKU.js";
3
+ } from "../../../chunks/chunk-IFT6HLDW.js";
4
+ import "../../../chunks/chunk-ZMHKLIP2.js";
5
5
  import "../../../chunks/chunk-GJOU3UAL.js";
6
- import "../../../chunks/chunk-2KT7AKRW.js";
7
- import "../../../chunks/chunk-FENXVJYO.js";
6
+ import "../../../chunks/chunk-WH6BPDAC.js";
8
7
  import "../../../chunks/chunk-QHLQVR3E.js";
8
+ import "../../../chunks/chunk-FENXVJYO.js";
9
9
  export {
10
10
  Sanitize
11
11
  };
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  selectorToElement
3
- } from "../../../chunks/chunk-FYHRUYTU.js";
4
- import "../../../chunks/chunk-C5WKMLKU.js";
3
+ } from "../../../chunks/chunk-LI5KVXAJ.js";
4
+ import "../../../chunks/chunk-ZMHKLIP2.js";
5
5
  import "../../../chunks/chunk-GJOU3UAL.js";
6
- import "../../../chunks/chunk-2KT7AKRW.js";
7
- import "../../../chunks/chunk-FENXVJYO.js";
6
+ import "../../../chunks/chunk-WH6BPDAC.js";
8
7
  import "../../../chunks/chunk-QHLQVR3E.js";
8
+ import "../../../chunks/chunk-FENXVJYO.js";
9
9
  export {
10
10
  selectorToElement
11
11
  };
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  stringToNodes
3
- } from "../../../chunks/chunk-6ETCY4VK.js";
4
- import "../../../chunks/chunk-2H4QYFEP.js";
5
- import "../../../chunks/chunk-C5WKMLKU.js";
3
+ } from "../../../chunks/chunk-GL23YDEH.js";
4
+ import "../../../chunks/chunk-IFT6HLDW.js";
5
+ import "../../../chunks/chunk-ZMHKLIP2.js";
6
6
  import "../../../chunks/chunk-GJOU3UAL.js";
7
- import "../../../chunks/chunk-2KT7AKRW.js";
8
- import "../../../chunks/chunk-FENXVJYO.js";
7
+ import "../../../chunks/chunk-WH6BPDAC.js";
9
8
  import "../../../chunks/chunk-QHLQVR3E.js";
9
+ import "../../../chunks/chunk-FENXVJYO.js";
10
10
  export {
11
11
  stringToNodes
12
12
  };
@@ -5,6 +5,7 @@ import { getCurrentDownlink as getCurrentDownlinkFunc } from './get-current-down
5
5
  import { ConstructorFunction as ConstructorFunctionType, isConstructorFunction as isConstructorFunctionFunc } from './is-constructor-function';
6
6
  import { Nullish as NullishType, isNullish as isNullishFunc, isNotNullish as isNotNullishFunc } from './is-nullish';
7
7
  import { Logs as LogsNamespace } from './logs';
8
+ import { LoremIpsum as LoremIpsumNamespace } from './lorem-ipsum';
8
9
  import { Random as RandomNamespace } from './random';
9
10
  export declare namespace Misc {
10
11
  export import Assert = AssertNamespace;
@@ -18,5 +19,6 @@ export declare namespace Misc {
18
19
  const isNullish: typeof isNullishFunc;
19
20
  const isNotNullish: typeof isNotNullishFunc;
20
21
  export import Logs = LogsNamespace;
22
+ export import LoremIpsum = LoremIpsumNamespace;
21
23
  export import Random = RandomNamespace;
22
24
  }
@@ -1,21 +1,25 @@
1
1
  import {
2
- Logs
3
- } from "../../chunks/chunk-HEJV6JIO.js";
4
- import {
5
- Assert
6
- } from "../../chunks/chunk-W7YBGJ4H.js";
2
+ LoremIpsum
3
+ } from "../../chunks/chunk-UCV2AZZV.js";
7
4
  import {
8
5
  Cast
9
6
  } from "../../chunks/chunk-4QQBKBYH.js";
10
7
  import {
11
8
  getCurrentDownlink
12
9
  } from "../../chunks/chunk-7AWTHZLY.js";
10
+ import {
11
+ Assert
12
+ } from "../../chunks/chunk-W7YBGJ4H.js";
13
+ import {
14
+ Logs
15
+ } from "../../chunks/chunk-HEJV6JIO.js";
13
16
  import {
14
17
  Random
15
18
  } from "../../chunks/chunk-WLL3FNVL.js";
16
19
  import {
17
20
  Crossenv
18
21
  } from "../../chunks/chunk-GJOU3UAL.js";
22
+ import "../../chunks/chunk-6RGDWX4A.js";
19
23
  import {
20
24
  isConstructorFunction
21
25
  } from "../../chunks/chunk-RCO57B6F.js";
@@ -38,6 +42,7 @@ var Misc;
38
42
  Misc2.isNullish = isNullish;
39
43
  Misc2.isNotNullish = isNotNullish;
40
44
  Misc2.Logs = Logs;
45
+ Misc2.LoremIpsum = LoremIpsum;
41
46
  Misc2.Random = Random;
42
47
  })(Misc || (Misc = {}));
43
48
  export {
@@ -0,0 +1,5 @@
1
+ export declare namespace LoremIpsum {
2
+ const words: string[];
3
+ const generateSentence: (wordCount: number) => string;
4
+ const generateSentences: (sentencesCount: number, maxSentenceLength?: number, minSentenceLength?: number) => string[];
5
+ }
@@ -0,0 +1,9 @@
1
+ import {
2
+ LoremIpsum
3
+ } from "../../../chunks/chunk-UCV2AZZV.js";
4
+ import "../../../chunks/chunk-WLL3FNVL.js";
5
+ import "../../../chunks/chunk-6RGDWX4A.js";
6
+ import "../../../chunks/chunk-RCO57B6F.js";
7
+ export {
8
+ LoremIpsum
9
+ };
@@ -1,12 +1,6 @@
1
- import {
2
- absoluteModulo
3
- } from "../../chunks/chunk-DNIOWD7K.js";
4
1
  import {
5
2
  clamp
6
3
  } from "../../chunks/chunk-OSAXBA7G.js";
7
- import {
8
- interpolate
9
- } from "../../chunks/chunk-EW46EXFB.js";
10
4
  import {
11
5
  createScale,
12
6
  getHarmonic
@@ -14,6 +8,12 @@ import {
14
8
  import {
15
9
  round
16
10
  } from "../../chunks/chunk-32IRF4OP.js";
11
+ import {
12
+ absoluteModulo
13
+ } from "../../chunks/chunk-DNIOWD7K.js";
14
+ import {
15
+ interpolate
16
+ } from "../../chunks/chunk-EW46EXFB.js";
17
17
 
18
18
  // src/agnostic/numbers/index.ts
19
19
  var Numbers;
@@ -1,21 +1,21 @@
1
+ import {
2
+ Validation
3
+ } from "../../chunks/chunk-FPEW3A27.js";
1
4
  import {
2
5
  Enums
3
6
  } from "../../chunks/chunk-WOAYU6LB.js";
4
- import "../../chunks/chunk-E6MSDKON.js";
5
- import {
6
- flattenGetters
7
- } from "../../chunks/chunk-PO3V3I57.js";
8
- import {
9
- isRecord
10
- } from "../../chunks/chunk-YDIBNEGA.js";
11
7
  import {
12
8
  isNonNullObject,
13
9
  isObject
14
10
  } from "../../chunks/chunk-HQLRJ7XW.js";
15
11
  import {
16
- Validation
17
- } from "../../chunks/chunk-FPEW3A27.js";
12
+ flattenGetters
13
+ } from "../../chunks/chunk-PO3V3I57.js";
18
14
  import "../../chunks/chunk-4QQBKBYH.js";
15
+ import "../../chunks/chunk-E6MSDKON.js";
16
+ import {
17
+ isRecord
18
+ } from "../../chunks/chunk-YDIBNEGA.js";
19
19
  import "../../chunks/chunk-QXAJXTXV.js";
20
20
  import "../../chunks/chunk-HC6ZOHCS.js";
21
21
 
@@ -1,6 +1,6 @@
1
1
  import {
2
- toAlphanum
3
- } from "../../chunks/chunk-COVPTTAD.js";
2
+ normalizeIndent
3
+ } from "../../chunks/chunk-JQXNEJAP.js";
4
4
  import {
5
5
  replaceAll
6
6
  } from "../../chunks/chunk-MF56TTC5.js";
@@ -8,8 +8,8 @@ import {
8
8
  CharCodes
9
9
  } from "../../chunks/chunk-34U4HX4V.js";
10
10
  import {
11
- normalizeIndent
12
- } from "../../chunks/chunk-JQXNEJAP.js";
11
+ toAlphanum
12
+ } from "../../chunks/chunk-COVPTTAD.js";
13
13
  import {
14
14
  matches,
15
15
  matchesEvery,
@@ -0,0 +1,24 @@
1
+ import {
2
+ isConstructorFunction
3
+ } from "./chunk-RCO57B6F.js";
4
+
5
+ // src/agnostic/arrays/is-array-of/index.ts
6
+ function isArrayOf(input, _types = []) {
7
+ if (!Array.isArray(input)) return false;
8
+ const types = Array.isArray(_types) ? _types : [_types];
9
+ if (types.length === 0) return true;
10
+ return input.every((entry) => {
11
+ return types.some((typeChecker) => {
12
+ const isConstructor = isConstructorFunction(typeChecker);
13
+ if (!isConstructor) return typeChecker(entry);
14
+ if (typeChecker === Number) return typeof entry === "number";
15
+ if (typeChecker === String) return typeof entry === "string";
16
+ if (typeChecker === Boolean) return typeof entry === "boolean";
17
+ if (isConstructor) return entry instanceof typeChecker;
18
+ });
19
+ });
20
+ }
21
+
22
+ export {
23
+ isArrayOf
24
+ };
@@ -0,0 +1,276 @@
1
+ import {
2
+ isInEnum
3
+ } from "./chunk-E6MSDKON.js";
4
+ import {
5
+ isRecord
6
+ } from "./chunk-YDIBNEGA.js";
7
+ import {
8
+ isFalsy
9
+ } from "./chunk-QXAJXTXV.js";
10
+
11
+ // src/agnostic/html/hyper-json/index.ts
12
+ var htmlString = `<tag attr="val">
13
+ <child>text</child>
14
+ TRUC !!
15
+ <child>text</child>
16
+ <!-- Comment -->
17
+ </tag>`;
18
+ var htmlElement = document.createElement("div");
19
+ htmlElement.innerHTML = htmlString;
20
+ var HyperJson;
21
+ ((HyperJson2) => {
22
+ HyperJson2.isElement = (node) => node.nodeType === Node.ELEMENT_NODE;
23
+ HyperJson2.isText = (node) => node.nodeType === Node.TEXT_NODE;
24
+ let TyperTagName;
25
+ ((TyperTagName2) => {
26
+ TyperTagName2["NULL"] = "null";
27
+ TyperTagName2["BOOLEAN"] = "boolean";
28
+ TyperTagName2["NUMBER"] = "number";
29
+ TyperTagName2["STRING"] = "string";
30
+ TyperTagName2["TEXT"] = "text";
31
+ TyperTagName2["NODELIST"] = "nodelist";
32
+ TyperTagName2["ARRAY"] = "array";
33
+ TyperTagName2["RECORD"] = "record";
34
+ })(TyperTagName = HyperJson2.TyperTagName || (HyperJson2.TyperTagName = {}));
35
+ let TransformerTagName;
36
+ ((TransformerTagName2) => {
37
+ TransformerTagName2["MAP"] = "map";
38
+ TransformerTagName2["REF"] = "ref";
39
+ TransformerTagName2["ADD"] = "add";
40
+ TransformerTagName2["MULT"] = "mult";
41
+ TransformerTagName2["APPEND"] = "append";
42
+ })(TransformerTagName = HyperJson2.TransformerTagName || (HyperJson2.TransformerTagName = {}));
43
+ class Tree {
44
+ node;
45
+ name;
46
+ parent;
47
+ root;
48
+ path;
49
+ pathString;
50
+ tagName;
51
+ attributes;
52
+ subtrees = /* @__PURE__ */ new Map();
53
+ children;
54
+ type;
55
+ constructor(node, parent, pathFromParent) {
56
+ this.node = node;
57
+ this.name = this.node instanceof Element ? this.node.getAttribute("_name") : null;
58
+ this.parent = parent ?? null;
59
+ this.root = this.parent === null ? this : this.parent.root;
60
+ if (this.parent === null) this.path = [];
61
+ else if (pathFromParent === void 0) {
62
+ this.path = [...this.parent.path, 0];
63
+ } else {
64
+ this.path = [...this.parent.path, pathFromParent];
65
+ }
66
+ this.pathString = `/${this.path.join("/")}`;
67
+ this.tagName = node instanceof Element ? node.tagName.toLowerCase() : null;
68
+ this.attributes = (0, HyperJson2.isElement)(node) ? Array.from(node.attributes) : null;
69
+ const { childNodes } = node;
70
+ let positionnedChildrenCount = 0;
71
+ const mutableSubtrees = /* @__PURE__ */ new Map();
72
+ Array.from(childNodes).filter((node2) => {
73
+ if ((0, HyperJson2.isElement)(node2)) return true;
74
+ if ((0, HyperJson2.isText)(node2)) return true;
75
+ return false;
76
+ }).forEach((childNode) => {
77
+ if (childNode instanceof Text) {
78
+ mutableSubtrees.set(
79
+ positionnedChildrenCount,
80
+ new Tree(childNode, this, positionnedChildrenCount)
81
+ );
82
+ positionnedChildrenCount += 1;
83
+ } else {
84
+ const propertyName = childNode.getAttribute("_name");
85
+ if (propertyName === null) {
86
+ mutableSubtrees.set(
87
+ positionnedChildrenCount,
88
+ new Tree(childNode, this, positionnedChildrenCount)
89
+ );
90
+ positionnedChildrenCount += 1;
91
+ } else {
92
+ mutableSubtrees.set(
93
+ propertyName,
94
+ new Tree(childNode, this, propertyName)
95
+ );
96
+ }
97
+ }
98
+ });
99
+ this.subtrees = mutableSubtrees;
100
+ this.children = Array.from(this.subtrees.values());
101
+ if (this.tagName === null) {
102
+ this.type = "text";
103
+ } else if (this.tagName === "null" /* NULL */) {
104
+ this.type = "null";
105
+ } else if (this.tagName === "boolean" /* BOOLEAN */) {
106
+ this.type = "boolean";
107
+ } else if (this.tagName === "number" /* NUMBER */) {
108
+ this.type = "number";
109
+ } else if (this.tagName === "string" /* STRING */) {
110
+ this.type = "string";
111
+ } else if (this.tagName === "text" /* TEXT */) {
112
+ this.type = "text";
113
+ } else if (this.tagName === "nodelist" /* NODELIST */) {
114
+ this.type = "nodelist";
115
+ } else if (this.tagName === "array" /* ARRAY */) {
116
+ this.type = "array";
117
+ } else if (this.tagName === "record" /* RECORD */) {
118
+ this.type = "record";
119
+ } else if (isInEnum(TransformerTagName, this.tagName)) {
120
+ this.type = "transformer";
121
+ } else {
122
+ this.type = "element";
123
+ }
124
+ }
125
+ initValue() {
126
+ const { type } = this;
127
+ let currentValue;
128
+ if (type === "null") {
129
+ currentValue = null;
130
+ } else if (type === "boolean") {
131
+ currentValue = false;
132
+ } else if (type === "number") {
133
+ currentValue = 0;
134
+ } else if (type === "string") {
135
+ currentValue = "";
136
+ } else if (type === "text") {
137
+ currentValue = this.node.textContent;
138
+ } else if (type === "element") {
139
+ currentValue = document.createDocumentFragment().childNodes;
140
+ } else if (type === "nodelist") {
141
+ currentValue = document.createDocumentFragment().childNodes;
142
+ } else if (type === "array") {
143
+ currentValue = [];
144
+ } else if (type === "record") {
145
+ currentValue = {};
146
+ } else if (type === "transformer") {
147
+ currentValue = [];
148
+ } else {
149
+ currentValue = null;
150
+ }
151
+ return currentValue;
152
+ }
153
+ getInnerValue(initialValue) {
154
+ const { subtrees } = this;
155
+ const innerValue = Array.from(subtrees.entries()).reduce((currentValue, [subpath, subTree]) => {
156
+ if (subTree.type === "transformer") {
157
+ const evaluated = subTree.evaluate();
158
+ return evaluated(currentValue);
159
+ }
160
+ if (currentValue === null || typeof currentValue === "boolean" || typeof currentValue === "number" || typeof currentValue === "string" || currentValue instanceof Text || currentValue instanceof Element) {
161
+ const evaluated = subTree.evaluate();
162
+ if (evaluated === null || typeof evaluated === "boolean" || typeof evaluated === "number" || typeof evaluated === "string" || Array.isArray(evaluated) || isRecord(evaluated)) {
163
+ return evaluated;
164
+ }
165
+ const frag = document.createDocumentFragment();
166
+ frag.append(`${currentValue}`);
167
+ if (evaluated instanceof Element || evaluated instanceof Text) {
168
+ frag.append(evaluated);
169
+ return frag.childNodes;
170
+ }
171
+ frag.append(...Array.from(evaluated));
172
+ return frag.childNodes;
173
+ }
174
+ if (Array.isArray(currentValue)) {
175
+ if (typeof subpath === "string") return currentValue;
176
+ return [...currentValue, subTree.evaluate()];
177
+ }
178
+ if (currentValue instanceof NodeList) {
179
+ const evaluated = subTree.evaluate();
180
+ if (evaluated instanceof Element || evaluated instanceof Text) {
181
+ const frag = document.createDocumentFragment();
182
+ frag.append(...Array.from(currentValue), evaluated);
183
+ return frag.childNodes;
184
+ }
185
+ if (evaluated instanceof NodeList) {
186
+ const frag = document.createDocumentFragment();
187
+ frag.append(
188
+ ...Array.from(currentValue),
189
+ ...Array.from(evaluated)
190
+ );
191
+ return frag.childNodes;
192
+ }
193
+ if (evaluated === null || typeof evaluated === "string" || typeof evaluated === "number" || typeof evaluated === "boolean") {
194
+ const frag = document.createDocumentFragment();
195
+ frag.append(...Array.from(currentValue), `${evaluated}`);
196
+ return frag.childNodes;
197
+ }
198
+ if (Array.isArray(evaluated)) return [...Array.from(currentValue), ...evaluated];
199
+ return { ...evaluated };
200
+ }
201
+ if (typeof subpath === "number") return currentValue;
202
+ return {
203
+ ...currentValue,
204
+ [subpath]: subTree.evaluate()
205
+ };
206
+ }, initialValue);
207
+ return innerValue;
208
+ }
209
+ wrapInnerValue(innerValue) {
210
+ const { type, node } = this;
211
+ if (type === "transformer") return (input) => {
212
+ console.log("I am a transformer. I was given those params");
213
+ console.log(innerValue);
214
+ console.log("And this input");
215
+ console.log(input);
216
+ return input;
217
+ };
218
+ if (type === "null") return null;
219
+ if (type === "boolean") return !isFalsy(innerValue);
220
+ if (type === "number") return parseFloat(`${innerValue}`);
221
+ if (type === "string") return `${innerValue}`;
222
+ if (type === "array") {
223
+ if (Array.isArray(innerValue)) return innerValue;
224
+ if (innerValue instanceof NodeList) {
225
+ return [...Array.from(innerValue)];
226
+ }
227
+ return [innerValue];
228
+ }
229
+ if (type === "record") {
230
+ if (isRecord(innerValue)) return innerValue;
231
+ return {};
232
+ }
233
+ if (type === "text") return document.createTextNode(`${innerValue}`);
234
+ if (type === "element") {
235
+ const wrapper = node.cloneNode();
236
+ if (innerValue instanceof NodeList) {
237
+ wrapper.append(...Array.from(innerValue));
238
+ return wrapper;
239
+ }
240
+ if (innerValue instanceof Element || innerValue instanceof Text || typeof innerValue === "string") {
241
+ wrapper.append(innerValue);
242
+ return wrapper;
243
+ }
244
+ if (innerValue === null || typeof innerValue === "number" || typeof innerValue === "boolean") {
245
+ wrapper.append(`${innerValue}`);
246
+ return wrapper;
247
+ }
248
+ return wrapper;
249
+ }
250
+ if (innerValue instanceof NodeList) return innerValue;
251
+ if (innerValue instanceof Element || innerValue instanceof Text || typeof innerValue === "string") {
252
+ const frag2 = document.createDocumentFragment();
253
+ frag2.append(innerValue);
254
+ return frag2.childNodes;
255
+ }
256
+ if (innerValue === null || typeof innerValue === "string" || typeof innerValue === "number" || typeof innerValue === "boolean") {
257
+ const frag2 = document.createDocumentFragment();
258
+ frag2.append(`${innerValue}`);
259
+ return frag2.childNodes;
260
+ }
261
+ const frag = document.createDocumentFragment();
262
+ return frag.childNodes;
263
+ }
264
+ evaluate() {
265
+ const init = this.initValue();
266
+ const inner = this.getInnerValue(init);
267
+ const wrapped = this.wrapInnerValue(inner);
268
+ return wrapped;
269
+ }
270
+ }
271
+ HyperJson2.Tree = Tree;
272
+ })(HyperJson || (HyperJson = {}));
273
+
274
+ export {
275
+ HyperJson
276
+ };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Sanitize
3
- } from "./chunk-2H4QYFEP.js";
3
+ } from "./chunk-IFT6HLDW.js";
4
4
  import {
5
5
  register
6
- } from "./chunk-C5WKMLKU.js";
6
+ } from "./chunk-ZMHKLIP2.js";
7
7
  import {
8
8
  Crossenv
9
9
  } from "./chunk-GJOU3UAL.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  register
3
- } from "./chunk-C5WKMLKU.js";
3
+ } from "./chunk-ZMHKLIP2.js";
4
4
  import {
5
5
  Crossenv
6
6
  } from "./chunk-GJOU3UAL.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  register
3
- } from "./chunk-C5WKMLKU.js";
3
+ } from "./chunk-ZMHKLIP2.js";
4
4
  import {
5
5
  Crossenv
6
6
  } from "./chunk-GJOU3UAL.js";
@@ -0,0 +1,222 @@
1
+ import {
2
+ Random
3
+ } from "./chunk-WLL3FNVL.js";
4
+ import {
5
+ isArrayOf
6
+ } from "./chunk-6RGDWX4A.js";
7
+
8
+ // src/agnostic/arrays/index.tsx
9
+ var Arrays;
10
+ ((Arrays2) => {
11
+ function make(filler, length) {
12
+ return new Array(length).fill(null).map((_, pos) => filler(pos));
13
+ }
14
+ Arrays2.make = make;
15
+ function findDuplicates(arr, stopAtFirst = false) {
16
+ const seen = /* @__PURE__ */ new Set();
17
+ const duplicates = /* @__PURE__ */ new Set();
18
+ for (const item of arr) {
19
+ if (seen.has(item) && stopAtFirst) return [item];
20
+ if (seen.has(item)) duplicates.add(item);
21
+ seen.add(item);
22
+ }
23
+ return Array.from(duplicates);
24
+ }
25
+ Arrays2.findDuplicates = findDuplicates;
26
+ Arrays2.ERR_SYMBOL = Symbol();
27
+ function randomPick(arr, exclude = []) {
28
+ const filteredArr = [...arr].filter((elt) => !exclude.includes(elt));
29
+ const length = filteredArr.length;
30
+ if (length === 0) return Arrays2.ERR_SYMBOL;
31
+ const pos = Math.floor(Math.random() * length);
32
+ const found = filteredArr[pos];
33
+ return found;
34
+ }
35
+ Arrays2.randomPick = randomPick;
36
+ Arrays2.isArrayOf = isArrayOf;
37
+ })(Arrays || (Arrays = {}));
38
+
39
+ // src/agnostic/misc/lorem-ipsum/index.ts
40
+ var LoremIpsum;
41
+ ((LoremIpsum2) => {
42
+ LoremIpsum2.words = [
43
+ "a",
44
+ "ac",
45
+ "accumsan",
46
+ "adipiscing",
47
+ "aenean",
48
+ "aliquam",
49
+ "aliquet",
50
+ "amet",
51
+ "ante",
52
+ "arcu",
53
+ "at",
54
+ "auctor",
55
+ "augue",
56
+ "bibendum",
57
+ "blandit",
58
+ "condimentum",
59
+ "consectetur",
60
+ "consequat",
61
+ "convallis",
62
+ "cras",
63
+ "curabitur",
64
+ "cursus",
65
+ "dapibus",
66
+ "diam",
67
+ "dictum",
68
+ "dictumst",
69
+ "dignissim",
70
+ "dolor",
71
+ "donec",
72
+ "dui",
73
+ "duis",
74
+ "efficitur",
75
+ "egestas",
76
+ "eget",
77
+ "eleifend",
78
+ "elementum",
79
+ "elit",
80
+ "enim",
81
+ "erat",
82
+ "eros",
83
+ "est",
84
+ "et",
85
+ "eu",
86
+ "euismod",
87
+ "ex",
88
+ "facilisis",
89
+ "faucibus",
90
+ "felis",
91
+ "feugiat",
92
+ "finibus",
93
+ "fringilla",
94
+ "fusce",
95
+ "gravida",
96
+ "habitasse",
97
+ "hac",
98
+ "hendrerit",
99
+ "iaculis",
100
+ "id",
101
+ "imperdiet",
102
+ "in",
103
+ "integer",
104
+ "interdum",
105
+ "ipsum",
106
+ "justo",
107
+ "lacinia",
108
+ "lacus",
109
+ "laoreet",
110
+ "lectus",
111
+ "leo",
112
+ "libero",
113
+ "ligula",
114
+ "lobortis",
115
+ "lorem",
116
+ "luctus",
117
+ "maecenas",
118
+ "magna",
119
+ "malesuada",
120
+ "massa",
121
+ "mattis",
122
+ "mauris",
123
+ "maximus",
124
+ "metus",
125
+ "mi",
126
+ "molestie",
127
+ "mollis",
128
+ "morbi",
129
+ "nam",
130
+ "nec",
131
+ "neque",
132
+ "nibh",
133
+ "nisi",
134
+ "nisl",
135
+ "non",
136
+ "nulla",
137
+ "nullam",
138
+ "nunc",
139
+ "odio",
140
+ "orci",
141
+ "ornare",
142
+ "pellentesque",
143
+ "pharetra",
144
+ "phasellus",
145
+ "placerat",
146
+ "platea",
147
+ "porta",
148
+ "porttitor",
149
+ "posuere",
150
+ "praesent",
151
+ "pulvinar",
152
+ "purus",
153
+ "quam",
154
+ "quis",
155
+ "quisque",
156
+ "risus",
157
+ "rutrum",
158
+ "sagittis",
159
+ "sapien",
160
+ "sed",
161
+ "sem",
162
+ "semper",
163
+ "sit",
164
+ "sodales",
165
+ "sollicitudin",
166
+ "suscipit",
167
+ "suspendisse",
168
+ "tellus",
169
+ "tempor",
170
+ "tempus",
171
+ "tincidunt",
172
+ "tortor",
173
+ "tristique",
174
+ "turpis",
175
+ "ultrices",
176
+ "ultricies",
177
+ "urna",
178
+ "ut",
179
+ "vehicula",
180
+ "vel",
181
+ "velit",
182
+ "venenatis",
183
+ "vestibulum",
184
+ "vitae",
185
+ "vivamus",
186
+ "viverra",
187
+ "volutpat",
188
+ "vulputate"
189
+ ];
190
+ LoremIpsum2.generateSentence = (wordCount) => {
191
+ const resultArr = [];
192
+ let currentWordCound = wordCount;
193
+ for (let i = 0; i < currentWordCound; i++) {
194
+ const picked = Arrays.randomPick(LoremIpsum2.words);
195
+ if (typeof picked === "string") resultArr.push(picked);
196
+ else {
197
+ currentWordCound += 1;
198
+ }
199
+ }
200
+ const [firstWord, ...otherWords] = resultArr;
201
+ if (firstWord === void 0) return "";
202
+ const capFirstLetter = firstWord?.charAt(0).toUpperCase();
203
+ const restOfFirstWord = firstWord?.slice(1);
204
+ const sentence = [
205
+ `${capFirstLetter}${restOfFirstWord}`,
206
+ ...otherWords
207
+ ].join(" ");
208
+ return `${sentence}.`;
209
+ };
210
+ LoremIpsum2.generateSentences = (sentencesCount, maxSentenceLength = 12, minSentenceLength = 4) => {
211
+ const sentences = [];
212
+ for (let i = 0; i < sentencesCount; i++) {
213
+ const length = Random.randomInt(maxSentenceLength, minSentenceLength) ?? 8;
214
+ sentences.push((0, LoremIpsum2.generateSentence)(length));
215
+ }
216
+ return sentences;
217
+ };
218
+ })(LoremIpsum || (LoremIpsum = {}));
219
+
220
+ export {
221
+ LoremIpsum
222
+ };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-GJOU3UAL.js";
4
4
  import {
5
5
  Errors
6
- } from "./chunk-2KT7AKRW.js";
6
+ } from "./chunk-WH6BPDAC.js";
7
7
 
8
8
  // src/shared/errors/index.ts
9
9
  var register = Errors.Register.from({
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  isInDirectory
3
3
  } from "../../chunks/chunk-NRITRUZW.js";
4
- import {
5
- readWrite
6
- } from "../../chunks/chunk-7DBNMU6N.js";
7
4
  import {
8
5
  Subpaths
9
6
  } from "../../chunks/chunk-HGCG2J77.js";
7
+ import {
8
+ readWrite
9
+ } from "../../chunks/chunk-7DBNMU6N.js";
10
10
  import "../../chunks/chunk-LQFKUNVQ.js";
11
11
 
12
12
  // src/node/files/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@design-edito/tools",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "",
5
5
  "author": "Maxime Fabas",
6
6
  "license": "ISC",
@@ -1,9 +1,9 @@
1
- import {
2
- unknownToString
3
- } from "./chunk-FENXVJYO.js";
4
1
  import {
5
2
  Register
6
3
  } from "./chunk-QHLQVR3E.js";
4
+ import {
5
+ unknownToString
6
+ } from "./chunk-FENXVJYO.js";
7
7
 
8
8
  // src/agnostic/errors/index.ts
9
9
  var Errors;