@design-edito/tools 0.1.41 → 0.1.43
Sign up to get free protection for your applications and to get access to all the features.
- package/agnostic/css/index.js +9 -9
- package/agnostic/errors/index.js +2 -2
- package/agnostic/html/hyper-json/cast/index.js +2 -2
- package/agnostic/html/hyper-json/index.js +3 -3
- package/agnostic/html/hyper-json/smart-tags/coalesced/add/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/addclass/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/and/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/append/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/at/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/call/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/clone/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/deleteproperties/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/equals/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/getattribute/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/getproperties/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/getproperty/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/if/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/initialize/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/join/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/length/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/map/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/negate/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/notrailing/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/or/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/pickrandom/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/populate/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/print/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/push/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/pusheach/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/recordtoarray/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/removeattribute/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/removeclass/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/renameproperty/index.d.ts +4 -1
- package/agnostic/html/hyper-json/smart-tags/coalesced/renameproperty/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/replace/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/select/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/set/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/setattribute/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/setproperties/index.js +3 -3
- package/agnostic/html/hyper-json/smart-tags/coalesced/setproperty/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/sorton/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/split/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/spread/index.d.ts +4 -0
- package/agnostic/html/hyper-json/smart-tags/coalesced/spread/index.js +21 -0
- package/agnostic/html/hyper-json/smart-tags/coalesced/toarray/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/toboolean/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/toelement/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/toggleclass/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/tonodelist/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/tonull/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/tonumber/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/torecord/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/toref/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/tostring/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/totext/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/transformselected/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/coalesced/trim/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/isolated/boolean/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/isolated/element/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/isolated/get/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/isolated/global/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/isolated/guess/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/isolated/nodelist/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/isolated/number/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/isolated/record/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/isolated/ref/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/isolated/string/index.js +2 -2
- package/agnostic/html/hyper-json/smart-tags/isolated/text/index.js +2 -2
- package/agnostic/html/hyper-json/tree/index.d.ts +3 -4
- package/agnostic/html/hyper-json/tree/index.js +2 -2
- package/agnostic/html/hyper-json/utils/index.js +2 -2
- package/agnostic/html/index.js +15 -15
- package/agnostic/html/sanitize/index.js +4 -4
- package/agnostic/html/selector-to-element/index.js +4 -4
- package/agnostic/html/string-to-nodes/index.js +5 -5
- package/agnostic/misc/index.js +13 -13
- package/agnostic/misc/lorem-ipsum/index.js +6 -6
- package/agnostic/numbers/index.js +8 -8
- package/agnostic/objects/index.js +8 -8
- package/agnostic/random/index.js +2 -2
- package/agnostic/strings/index.js +3 -3
- package/chunks/chunk-R23B2MRN.js +2405 -0
- package/chunks/chunk-UBFLFJMH.js +37 -0
- package/chunks/chunk-VZQ4WCBH.js +2391 -0
- package/chunks/chunk-WTAMA5WX.js +37 -0
- package/chunks/chunk-X7KWB2VQ.js +21 -0
- package/chunks/chunk-XDZD6C76.js +37 -0
- package/chunks/chunk-XH6TZMNR.js +211 -0
- package/chunks/chunk-XI2XIH6L.js +2391 -0
- package/node/files/index.js +4 -4
- package/package.json +1 -1
@@ -0,0 +1,2405 @@
|
|
1
|
+
import {
|
2
|
+
nullFunc
|
3
|
+
} from "./chunk-QAVYONH6.js";
|
4
|
+
import {
|
5
|
+
Types
|
6
|
+
} from "./chunk-XEQ2PBT2.js";
|
7
|
+
import {
|
8
|
+
array
|
9
|
+
} from "./chunk-VDNIN3V5.js";
|
10
|
+
import {
|
11
|
+
any
|
12
|
+
} from "./chunk-FHLCPVND.js";
|
13
|
+
import {
|
14
|
+
SmartTags
|
15
|
+
} from "./chunk-UT2J62LH.js";
|
16
|
+
import {
|
17
|
+
Serialize
|
18
|
+
} from "./chunk-SXRWMH3U.js";
|
19
|
+
import {
|
20
|
+
Transformer
|
21
|
+
} from "./chunk-BKO7GLC2.js";
|
22
|
+
import {
|
23
|
+
Method
|
24
|
+
} from "./chunk-RW7VAKJW.js";
|
25
|
+
import {
|
26
|
+
insertNode
|
27
|
+
} from "./chunk-XA4HVHJ4.js";
|
28
|
+
import {
|
29
|
+
isInEnum
|
30
|
+
} from "./chunk-E6MSDKON.js";
|
31
|
+
import {
|
32
|
+
isRecord
|
33
|
+
} from "./chunk-YDIBNEGA.js";
|
34
|
+
import {
|
35
|
+
recordMap
|
36
|
+
} from "./chunk-XNF5MLCQ.js";
|
37
|
+
import {
|
38
|
+
Outcome
|
39
|
+
} from "./chunk-JMU5PDBD.js";
|
40
|
+
import {
|
41
|
+
replaceAll
|
42
|
+
} from "./chunk-ZTDVUXPR.js";
|
43
|
+
import {
|
44
|
+
Window
|
45
|
+
} from "./chunk-RLJOYG64.js";
|
46
|
+
|
47
|
+
// src/agnostic/html/hyper-json/cast/index.ts
|
48
|
+
var Cast;
|
49
|
+
((Cast2) => {
|
50
|
+
Cast2.toNull = () => null;
|
51
|
+
Cast2.toBoolean = (input) => {
|
52
|
+
const { Text: Text2 } = Window.get();
|
53
|
+
if (input === null) return false;
|
54
|
+
if (typeof input === "boolean") return input;
|
55
|
+
if (typeof input === "number") return input !== 0;
|
56
|
+
if (typeof input === "string" || input instanceof Text2) {
|
57
|
+
const strInput = (0, Cast2.toString)(input);
|
58
|
+
if (strInput.trim() === "") return false;
|
59
|
+
if (strInput.trim().toLowerCase() === "false") return false;
|
60
|
+
return true;
|
61
|
+
}
|
62
|
+
return true;
|
63
|
+
};
|
64
|
+
Cast2.toNumber = (input) => {
|
65
|
+
const { Text: Text2 } = Window.get();
|
66
|
+
if (typeof input === "boolean") return input ? 1 : 0;
|
67
|
+
if (typeof input === "number") return input;
|
68
|
+
if (typeof input === "string") return parseFloat(`${input}`);
|
69
|
+
if (input instanceof Text2) return parseFloat(`${input.textContent}`);
|
70
|
+
return 0;
|
71
|
+
};
|
72
|
+
Cast2.toString = (input) => {
|
73
|
+
if (typeof input === "string") return input;
|
74
|
+
if (typeof input === "number" || typeof input === "boolean" || input === null) return `${input}`;
|
75
|
+
const { Element: Element2, Text: Text2, NodeList } = Window.get();
|
76
|
+
if (input instanceof Element2) return input.outerHTML;
|
77
|
+
if (input instanceof Text2) return input.textContent ?? "";
|
78
|
+
if (input instanceof NodeList) return Array.from(input).map((e) => {
|
79
|
+
if (e instanceof Element2) return e.outerHTML;
|
80
|
+
return e.textContent;
|
81
|
+
}).join("");
|
82
|
+
if (Array.isArray(input)) return input.map(Cast2.toString).join("");
|
83
|
+
if (input instanceof Method) return `[Method:${input.transformer.name}]`;
|
84
|
+
return `{${Object.entries(input).map(([key, val]) => `${key}:"${(0, Cast2.toString)(val)}"`).join(",")}}`;
|
85
|
+
};
|
86
|
+
Cast2.toText = (input) => {
|
87
|
+
const { Text: Text2, document: document2 } = Window.get();
|
88
|
+
if (input instanceof Text2) return input.cloneNode(true);
|
89
|
+
return document2.createTextNode((0, Cast2.toString)(input));
|
90
|
+
};
|
91
|
+
Cast2.toElement = (input) => {
|
92
|
+
const { Element: Element2, Text: Text2, NodeList, document: document2 } = Window.get();
|
93
|
+
if (input instanceof Element2) return input.cloneNode(true);
|
94
|
+
const returned = document2.createElement("div");
|
95
|
+
if (input instanceof Text2) {
|
96
|
+
returned.append(input.cloneNode(true));
|
97
|
+
return returned;
|
98
|
+
}
|
99
|
+
if (input instanceof NodeList) {
|
100
|
+
returned.append(...Array.from(input).map((e) => e.cloneNode(true)));
|
101
|
+
return returned;
|
102
|
+
}
|
103
|
+
if (Array.isArray(input)) return returned;
|
104
|
+
if (isRecord(input)) return returned;
|
105
|
+
returned.innerHTML = `${input}`;
|
106
|
+
return returned;
|
107
|
+
};
|
108
|
+
Cast2.toNodeList = (input) => {
|
109
|
+
const { Element: Element2, Text: Text2, NodeList, document: document2 } = Window.get();
|
110
|
+
const parentDiv = document2.createElement("div");
|
111
|
+
if (input instanceof NodeList) {
|
112
|
+
parentDiv.append(...Array.from(input).map((i) => i.cloneNode(true)));
|
113
|
+
return parentDiv.childNodes;
|
114
|
+
}
|
115
|
+
if (input instanceof Element2 || input instanceof Text2) {
|
116
|
+
parentDiv.append(input.cloneNode(true));
|
117
|
+
return parentDiv.childNodes;
|
118
|
+
}
|
119
|
+
if (Array.isArray(input)) {
|
120
|
+
input.forEach((item) => {
|
121
|
+
if (typeof item === "number" || typeof item === "boolean" || item === null) parentDiv.append(`${item}`);
|
122
|
+
else if (typeof item === "string" || item instanceof Text2 || item instanceof Element2) parentDiv.append(item);
|
123
|
+
else if (item instanceof NodeList) parentDiv.append(...Array.from(item));
|
124
|
+
else if (Array.isArray(item)) parentDiv.append(...Array.from((0, Cast2.toNodeList)(item)));
|
125
|
+
else parentDiv.append((0, Cast2.toString)(item));
|
126
|
+
});
|
127
|
+
return parentDiv.childNodes;
|
128
|
+
}
|
129
|
+
if (isRecord(input)) {
|
130
|
+
parentDiv.append((0, Cast2.toString)(input));
|
131
|
+
return parentDiv.childNodes;
|
132
|
+
}
|
133
|
+
parentDiv.innerHTML = `${input}`;
|
134
|
+
return parentDiv.childNodes;
|
135
|
+
};
|
136
|
+
Cast2.toArray = (input) => {
|
137
|
+
const { NodeList } = Window.get();
|
138
|
+
if (Array.isArray(input)) return [...input];
|
139
|
+
if (input instanceof NodeList) return Array.from(input);
|
140
|
+
return [input];
|
141
|
+
};
|
142
|
+
Cast2.toRecord = (input) => {
|
143
|
+
const isRecord2 = Utils.Tree.TypeChecks.typeCheck(input, "record");
|
144
|
+
if (isRecord2.success) return { ...isRecord2.payload };
|
145
|
+
return {};
|
146
|
+
};
|
147
|
+
})(Cast || (Cast = {}));
|
148
|
+
|
149
|
+
// src/agnostic/html/hyper-json/smart-tags/isolated/element/index.ts
|
150
|
+
var element = SmartTags.makeSmartTag({
|
151
|
+
name: "element",
|
152
|
+
defaultMode: "isolation",
|
153
|
+
isolationInitType: "array",
|
154
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text"),
|
155
|
+
argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "null", "boolean", "number", "string", "text", "element", "nodelist"),
|
156
|
+
func: (main, args) => {
|
157
|
+
const tagName = Cast.toString(main).trim().toLowerCase();
|
158
|
+
const { document: document2, NodeList } = Window.get();
|
159
|
+
const elt = document2.createElement(tagName);
|
160
|
+
for (const argVal of args) {
|
161
|
+
if (argVal instanceof NodeList) elt.append(...Array.from(argVal));
|
162
|
+
else if (argVal instanceof Element) elt.append(argVal);
|
163
|
+
else elt.append(Cast.toText(argVal));
|
164
|
+
}
|
165
|
+
return Outcome.makeSuccess(elt);
|
166
|
+
}
|
167
|
+
});
|
168
|
+
|
169
|
+
// src/agnostic/html/hyper-json/smart-tags/isolated/get/index.ts
|
170
|
+
var get = SmartTags.makeSmartTag({
|
171
|
+
name: "get",
|
172
|
+
defaultMode: "isolation",
|
173
|
+
isolationInitType: "array",
|
174
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text"),
|
175
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
176
|
+
func: (main, _args, { sourceTree }) => {
|
177
|
+
const { makeSuccess, makeFailure } = Outcome;
|
178
|
+
const { makeTransformationError } = Utils.SmartTags;
|
179
|
+
const strName = Cast.toString(main);
|
180
|
+
const found = sourceTree.getVariable(strName);
|
181
|
+
if (found === void 0) return makeFailure(makeTransformationError(`No variable stored under the name '${strName}'`));
|
182
|
+
return makeSuccess(found);
|
183
|
+
}
|
184
|
+
});
|
185
|
+
|
186
|
+
// src/agnostic/html/hyper-json/smart-tags/isolated/global/index.ts
|
187
|
+
var global = SmartTags.makeSmartTag({
|
188
|
+
name: "global",
|
189
|
+
defaultMode: "isolation",
|
190
|
+
isolationInitType: "array",
|
191
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
192
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
193
|
+
func: (_m, _a, { sourceTree }) => {
|
194
|
+
const globalObject = sourceTree.options.globalObject ?? {};
|
195
|
+
return Outcome.makeSuccess({ ...globalObject });
|
196
|
+
}
|
197
|
+
});
|
198
|
+
|
199
|
+
// src/agnostic/html/hyper-json/smart-tags/isolated/guess/index.ts
|
200
|
+
var guess = SmartTags.makeSmartTag({
|
201
|
+
name: "guess",
|
202
|
+
defaultMode: "isolation",
|
203
|
+
isolationInitType: "string",
|
204
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
205
|
+
argsValueCheck: (a) => Outcome.makeSuccess(a),
|
206
|
+
func: (main, args) => {
|
207
|
+
const { typeCheck } = Utils.Tree.TypeChecks;
|
208
|
+
const { makeSuccess } = Outcome;
|
209
|
+
let coalesced = main;
|
210
|
+
for (const arg of args) coalesced = Utils.coalesceValues(coalesced, 0, arg);
|
211
|
+
const { Text: Text2, Element: Element2, document: document2 } = Window.get();
|
212
|
+
if (typeof coalesced !== "string" && !(coalesced instanceof Text2)) return makeSuccess(coalesced);
|
213
|
+
const strCoalesced = Cast.toString(coalesced);
|
214
|
+
if (strCoalesced.trim().toLowerCase() === "true") return makeSuccess(true);
|
215
|
+
if (strCoalesced.trim().toLowerCase() === "false") return makeSuccess(false);
|
216
|
+
if (strCoalesced.trim().toLowerCase().match(/^\s*-?\s*(\d+(\.\d*)?|\.\d+)\s*$/)) return makeSuccess(parseFloat(strCoalesced));
|
217
|
+
if (strCoalesced.trim().toLowerCase() === "null") return makeSuccess(null);
|
218
|
+
try {
|
219
|
+
const parsed = JSON.parse(strCoalesced);
|
220
|
+
const arrayChecked = typeCheck(parsed, "array");
|
221
|
+
const recordChecked = typeCheck(parsed, "record");
|
222
|
+
if (arrayChecked.success) return makeSuccess(arrayChecked.payload);
|
223
|
+
if (recordChecked.success) return makeSuccess(recordChecked.payload);
|
224
|
+
} catch (err) {
|
225
|
+
}
|
226
|
+
const div = document2.createElement("div");
|
227
|
+
div.innerHTML = strCoalesced;
|
228
|
+
const divChildren = div.childNodes;
|
229
|
+
if (divChildren.length === 0) return makeSuccess(coalesced);
|
230
|
+
const validDivChildren = Cast.toNodeList(Array.from(divChildren).filter((e) => {
|
231
|
+
if (e instanceof Element2) return true;
|
232
|
+
if (e instanceof Text2) return true;
|
233
|
+
return false;
|
234
|
+
}));
|
235
|
+
if (validDivChildren.length > 1) return makeSuccess(validDivChildren);
|
236
|
+
const validDivFirstchild = validDivChildren.item(0);
|
237
|
+
if (validDivChildren.length === 1 && validDivFirstchild instanceof Element2) return makeSuccess(validDivFirstchild);
|
238
|
+
return makeSuccess(coalesced);
|
239
|
+
}
|
240
|
+
});
|
241
|
+
|
242
|
+
// src/agnostic/html/hyper-json/smart-tags/isolated/nodelist/index.ts
|
243
|
+
var nodelist = SmartTags.makeSmartTag({
|
244
|
+
name: "nodelist",
|
245
|
+
defaultMode: "isolation",
|
246
|
+
isolationInitType: "nodelist",
|
247
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
248
|
+
argsValueCheck: (a) => Outcome.makeSuccess(a),
|
249
|
+
func: (main, args) => {
|
250
|
+
const { document: document2 } = Window.get();
|
251
|
+
const returnedParent = document2.createDocumentFragment();
|
252
|
+
returnedParent.append(
|
253
|
+
...Array.from(Cast.toNodeList(main)),
|
254
|
+
...Array.from(Cast.toNodeList(args))
|
255
|
+
);
|
256
|
+
const returned = returnedParent.childNodes;
|
257
|
+
return Outcome.makeSuccess(returned);
|
258
|
+
}
|
259
|
+
});
|
260
|
+
|
261
|
+
// src/agnostic/html/hyper-json/smart-tags/isolated/number/index.ts
|
262
|
+
var number = SmartTags.makeSmartTag({
|
263
|
+
name: "number",
|
264
|
+
defaultMode: "isolation",
|
265
|
+
isolationInitType: "number",
|
266
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "null", "boolean", "number", "string", "text"),
|
267
|
+
argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "null", "boolean", "number", "string", "text"),
|
268
|
+
func: (main, args) => {
|
269
|
+
const all = [main, ...args];
|
270
|
+
const reduced = all.reduce((reduced2, curr) => {
|
271
|
+
return reduced2 + Cast.toNumber(curr);
|
272
|
+
}, 0);
|
273
|
+
return Outcome.makeSuccess(reduced);
|
274
|
+
}
|
275
|
+
});
|
276
|
+
|
277
|
+
// src/agnostic/html/hyper-json/smart-tags/isolated/record/index.ts
|
278
|
+
var record = SmartTags.makeSmartTag({
|
279
|
+
name: "record",
|
280
|
+
defaultMode: "isolation",
|
281
|
+
isolationInitType: "record",
|
282
|
+
mainValueCheck: (i) => Utils.Tree.TypeChecks.typeCheck(i, "record"),
|
283
|
+
argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "record"),
|
284
|
+
func: (main, args) => Outcome.makeSuccess(args.reduce((reduced, current) => ({
|
285
|
+
...reduced,
|
286
|
+
...current
|
287
|
+
}), main))
|
288
|
+
});
|
289
|
+
|
290
|
+
// src/agnostic/html/hyper-json/smart-tags/isolated/ref/index.ts
|
291
|
+
var func = (main, _args, { sourceTree }) => {
|
292
|
+
const { makeFailure, makeSuccess } = Outcome;
|
293
|
+
const { makeTransformationError } = Utils.SmartTags;
|
294
|
+
const strMain = Cast.toString(main);
|
295
|
+
const resolveFrom = strMain.startsWith("/") ? sourceTree.root : sourceTree;
|
296
|
+
const splitted = strMain.split("/").filter((e) => e.trim() !== "").map((e) => {
|
297
|
+
const looksLikeNumber = e.match(/^\d+$/igm);
|
298
|
+
if (looksLikeNumber === null) return e;
|
299
|
+
const parsed = parseInt(e);
|
300
|
+
if (Number.isNaN(parsed)) return e;
|
301
|
+
return parsed;
|
302
|
+
});
|
303
|
+
const resolved = resolveFrom.resolve(splitted);
|
304
|
+
if (resolved === void 0) return makeFailure(makeTransformationError(`No value was found at path: ${strMain}`));
|
305
|
+
if (resolved === sourceTree) return makeFailure(makeTransformationError("A ref node cannot reference itself."));
|
306
|
+
if (resolved.parents.includes(sourceTree)) return makeFailure(makeTransformationError("A ref node cannot reference one of its parents."));
|
307
|
+
if (sourceTree.parents.includes(resolved)) return makeFailure(makeTransformationError("A ref node cannot reference one of its children."));
|
308
|
+
const evaluated = resolved.evaluate();
|
309
|
+
const { getType } = Utils.Tree.TypeChecks;
|
310
|
+
if (getType(evaluated) === "transformer") {
|
311
|
+
const transformer = evaluated;
|
312
|
+
return makeSuccess(transformer.toMethod());
|
313
|
+
}
|
314
|
+
return makeSuccess(evaluated);
|
315
|
+
};
|
316
|
+
var ref = SmartTags.makeSmartTag({
|
317
|
+
name: "ref",
|
318
|
+
defaultMode: "isolation",
|
319
|
+
isolationInitType: "array",
|
320
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text"),
|
321
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
322
|
+
func
|
323
|
+
});
|
324
|
+
|
325
|
+
// src/agnostic/html/hyper-json/smart-tags/isolated/string/index.ts
|
326
|
+
var string = SmartTags.makeSmartTag({
|
327
|
+
name: "string",
|
328
|
+
defaultMode: "isolation",
|
329
|
+
isolationInitType: "string",
|
330
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "null", "boolean", "number", "string", "text", "element", "nodelist"),
|
331
|
+
argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "null", "boolean", "number", "string", "text", "element", "nodelist"),
|
332
|
+
func: (main, args) => {
|
333
|
+
const all = [main, ...args];
|
334
|
+
const reduced = all.reduce((reduced2, curr) => {
|
335
|
+
return `${reduced2}${Cast.toString(curr)}`;
|
336
|
+
}, "");
|
337
|
+
return Outcome.makeSuccess(reduced);
|
338
|
+
}
|
339
|
+
});
|
340
|
+
|
341
|
+
// src/agnostic/html/hyper-json/smart-tags/isolated/text/index.ts
|
342
|
+
var text = SmartTags.makeSmartTag({
|
343
|
+
name: "text",
|
344
|
+
defaultMode: "isolation",
|
345
|
+
isolationInitType: "text",
|
346
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "null", "boolean", "number", "string", "text", "element", "nodelist"),
|
347
|
+
argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "null", "boolean", "number", "string", "text", "element", "nodelist"),
|
348
|
+
func: (main, args) => {
|
349
|
+
const all = [main, ...args];
|
350
|
+
const reduced = all.reduce((reduced2, curr) => {
|
351
|
+
return Cast.toText(`${reduced2}${Cast.toText(curr)}`);
|
352
|
+
}, Cast.toText(""));
|
353
|
+
return Outcome.makeSuccess(reduced);
|
354
|
+
}
|
355
|
+
});
|
356
|
+
|
357
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/add/index.ts
|
358
|
+
var add = SmartTags.makeSmartTag({
|
359
|
+
name: "add",
|
360
|
+
defaultMode: "coalescion",
|
361
|
+
isolationInitType: "array",
|
362
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "number", "string", "text"),
|
363
|
+
argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "number", "string", "text"),
|
364
|
+
func: (main, args) => {
|
365
|
+
const numMain = Cast.toNumber(main);
|
366
|
+
const numArgs = args.map(Cast.toNumber);
|
367
|
+
return Outcome.makeSuccess(numArgs.reduce((reduced, arg) => reduced + arg, numMain));
|
368
|
+
}
|
369
|
+
});
|
370
|
+
|
371
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/addclass/index.ts
|
372
|
+
var addclass = SmartTags.makeSmartTag({
|
373
|
+
name: "addclass",
|
374
|
+
defaultMode: "coalescion",
|
375
|
+
isolationInitType: "array",
|
376
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "element"),
|
377
|
+
argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
|
378
|
+
func: (main, args) => {
|
379
|
+
main.classList.add(...args.map((arg) => Cast.toString(arg)));
|
380
|
+
return Outcome.makeSuccess(main);
|
381
|
+
}
|
382
|
+
});
|
383
|
+
|
384
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/and/index.ts
|
385
|
+
var and = SmartTags.makeSmartTag({
|
386
|
+
name: "and",
|
387
|
+
defaultMode: "coalescion",
|
388
|
+
isolationInitType: "array",
|
389
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
390
|
+
argsValueCheck: (a) => Outcome.makeSuccess(a),
|
391
|
+
func: (main, args) => {
|
392
|
+
const all = [main, ...args];
|
393
|
+
const returned = all.every(Cast.toBoolean);
|
394
|
+
return Outcome.makeSuccess(returned);
|
395
|
+
}
|
396
|
+
});
|
397
|
+
|
398
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/append/index.ts
|
399
|
+
var append = SmartTags.makeSmartTag({
|
400
|
+
name: "append",
|
401
|
+
defaultMode: "coalescion",
|
402
|
+
isolationInitType: "array",
|
403
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text", "nodelist", "element", "array"),
|
404
|
+
argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text", "nodelist", "element", "array"),
|
405
|
+
func: (main, args) => {
|
406
|
+
const { makeSuccess } = Outcome;
|
407
|
+
const { Text: Text2, Element: Element2, NodeList, document: document2 } = Window.get();
|
408
|
+
if (Array.isArray(main)) return makeSuccess([...main, ...args]);
|
409
|
+
if (main instanceof Element2) {
|
410
|
+
main.append(...Array.from(Cast.toNodeList(args)));
|
411
|
+
return makeSuccess(main);
|
412
|
+
}
|
413
|
+
if (main instanceof NodeList) {
|
414
|
+
const frag = document2.createDocumentFragment();
|
415
|
+
frag.append(
|
416
|
+
...Array.from(main),
|
417
|
+
...Array.from(Cast.toNodeList(args))
|
418
|
+
);
|
419
|
+
return makeSuccess(frag.childNodes);
|
420
|
+
}
|
421
|
+
if (main instanceof Text2) {
|
422
|
+
const reducedString = args.reduce((reduced, arg) => {
|
423
|
+
return `${reduced}${Cast.toString(arg)}`;
|
424
|
+
}, Cast.toString(main));
|
425
|
+
return makeSuccess(Cast.toText(reducedString));
|
426
|
+
}
|
427
|
+
return makeSuccess(args.reduce((reduced, arg) => {
|
428
|
+
return `${reduced}${Cast.toString(arg)}`;
|
429
|
+
}, main));
|
430
|
+
}
|
431
|
+
});
|
432
|
+
|
433
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/at/index.ts
|
434
|
+
var at = SmartTags.makeSmartTag({
|
435
|
+
name: "at",
|
436
|
+
defaultMode: "coalescion",
|
437
|
+
isolationInitType: "array",
|
438
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text", "array", "nodelist"),
|
439
|
+
argsValueCheck: (a) => {
|
440
|
+
const { makeFailure, makeSuccess } = Outcome;
|
441
|
+
const { makeArgsValueError } = Utils.SmartTags;
|
442
|
+
const { getType, typeCheckMany } = Utils.Tree.TypeChecks;
|
443
|
+
if (a.length === 0) return makeFailure(makeArgsValueError("number | string | text", "undefined", 0));
|
444
|
+
if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a[1]) ?? "undefined", 1));
|
445
|
+
const checked = typeCheckMany(a, "number", "string", "text");
|
446
|
+
if (checked.success) return makeSuccess(a);
|
447
|
+
return checked;
|
448
|
+
},
|
449
|
+
func: (main, args) => {
|
450
|
+
const { makeFailure, makeSuccess } = Outcome;
|
451
|
+
const { makeTransformationError } = Utils.SmartTags;
|
452
|
+
const pos = args[0];
|
453
|
+
const numPos = Cast.toNumber(pos);
|
454
|
+
let found;
|
455
|
+
const { NodeList } = Window.get();
|
456
|
+
if (typeof main === "string" || Array.isArray(main) || main instanceof NodeList) {
|
457
|
+
found = main[numPos];
|
458
|
+
} else {
|
459
|
+
const strMain = Cast.toString(main);
|
460
|
+
found = strMain[numPos];
|
461
|
+
}
|
462
|
+
if (found === void 0) return makeFailure(makeTransformationError({
|
463
|
+
message: "Property does not exist"
|
464
|
+
// [WIP] maybe more details here ?
|
465
|
+
}));
|
466
|
+
return makeSuccess(found);
|
467
|
+
}
|
468
|
+
});
|
469
|
+
|
470
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/call/index.ts
|
471
|
+
var call = SmartTags.makeSmartTag({
|
472
|
+
name: "call",
|
473
|
+
defaultMode: "coalescion",
|
474
|
+
isolationInitType: "array",
|
475
|
+
mainValueCheck: (m) => {
|
476
|
+
const { makeFailure } = Outcome;
|
477
|
+
const { typeCheck, typeCheckMany, getType } = Utils.Tree.TypeChecks;
|
478
|
+
const { makeMainValueError } = Utils.SmartTags;
|
479
|
+
const isMethodCheck = typeCheck(m, "method");
|
480
|
+
if (isMethodCheck.success) return isMethodCheck;
|
481
|
+
if (!Array.isArray(m)) return makeFailure({
|
482
|
+
expected: "method[]",
|
483
|
+
found: getType(m) ?? "undefined"
|
484
|
+
});
|
485
|
+
const isMethodsArrayCheck = typeCheckMany(m, "method");
|
486
|
+
if (isMethodsArrayCheck.success) return isMethodsArrayCheck;
|
487
|
+
return makeFailure(makeMainValueError("method | method[]", getType(m) ?? "undefined"));
|
488
|
+
},
|
489
|
+
argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "array"),
|
490
|
+
func: (main, args) => {
|
491
|
+
const { makeFailure, makeSuccess } = Outcome;
|
492
|
+
const { makeTransformationError } = Utils.SmartTags;
|
493
|
+
const mainArr = Array.isArray(main) ? main : [main];
|
494
|
+
let reduced = args;
|
495
|
+
for (const method of mainArr) {
|
496
|
+
const { transformer } = method;
|
497
|
+
const applied = transformer.apply(reduced);
|
498
|
+
if (applied.success) {
|
499
|
+
reduced = applied.payload;
|
500
|
+
}
|
501
|
+
return makeFailure(makeTransformationError({
|
502
|
+
message: "Subtransformation failure.",
|
503
|
+
onTransformed: reduced,
|
504
|
+
transformerAt: mainArr.indexOf(method),
|
505
|
+
transformerName: transformer.name,
|
506
|
+
transformerOutput: applied
|
507
|
+
}));
|
508
|
+
}
|
509
|
+
return makeSuccess(reduced);
|
510
|
+
}
|
511
|
+
});
|
512
|
+
|
513
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/clone/index.ts
|
514
|
+
var clone = SmartTags.makeSmartTag({
|
515
|
+
name: "clone",
|
516
|
+
defaultMode: "coalescion",
|
517
|
+
isolationInitType: "array",
|
518
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
519
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
520
|
+
func: (main) => Outcome.makeSuccess(Utils.clone(main))
|
521
|
+
});
|
522
|
+
|
523
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/deleteproperties/index.ts
|
524
|
+
var deleteproperties = SmartTags.makeSmartTag({
|
525
|
+
name: "deleteproperties",
|
526
|
+
defaultMode: "coalescion",
|
527
|
+
isolationInitType: "array",
|
528
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
|
529
|
+
argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
|
530
|
+
func: (main, args) => {
|
531
|
+
const { makeFailure, makeSuccess } = Outcome;
|
532
|
+
const { makeTransformationError } = Utils.SmartTags;
|
533
|
+
let returned = Utils.clone(main);
|
534
|
+
for (const arg of args) {
|
535
|
+
const strArg = Cast.toString(arg);
|
536
|
+
try {
|
537
|
+
returned = deepDeleteProperty(returned, strArg);
|
538
|
+
} catch (err) {
|
539
|
+
return makeFailure(makeTransformationError(`Cannot access ${strArg} from input record`));
|
540
|
+
}
|
541
|
+
}
|
542
|
+
return makeSuccess(returned);
|
543
|
+
}
|
544
|
+
});
|
545
|
+
function deepDeleteProperty(record2, pathString) {
|
546
|
+
const cloned = Utils.clone(record2);
|
547
|
+
const pathChunks = pathString.split(".");
|
548
|
+
let currentRecord = cloned;
|
549
|
+
pathChunks.forEach((chunk, pos) => {
|
550
|
+
const isLast = pos === pathChunks.length - 1;
|
551
|
+
if (isLast) delete currentRecord[chunk];
|
552
|
+
else {
|
553
|
+
const found = currentRecord[chunk];
|
554
|
+
if (isRecord(found)) currentRecord = found;
|
555
|
+
else throw "not a record";
|
556
|
+
}
|
557
|
+
});
|
558
|
+
return cloned;
|
559
|
+
}
|
560
|
+
|
561
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/equals/index.ts
|
562
|
+
var equals = SmartTags.makeSmartTag({
|
563
|
+
name: "equals",
|
564
|
+
defaultMode: "coalescion",
|
565
|
+
isolationInitType: "array",
|
566
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
567
|
+
argsValueCheck: (a) => {
|
568
|
+
const [first, ...others] = a;
|
569
|
+
if (first === void 0) return Outcome.makeFailure(Utils.SmartTags.makeArgsValueError(
|
570
|
+
"value",
|
571
|
+
"undefined",
|
572
|
+
0
|
573
|
+
));
|
574
|
+
const returned = [first, ...others];
|
575
|
+
return Outcome.makeSuccess(returned);
|
576
|
+
},
|
577
|
+
func: (main, args) => {
|
578
|
+
const { Text: Text2 } = Window.get();
|
579
|
+
const normalizedMain = main instanceof Text2 ? Cast.toString(main) : main;
|
580
|
+
const normalizedArgs = args.map((a) => a instanceof Text2 ? Cast.toString(a) : a);
|
581
|
+
return Outcome.makeSuccess(normalizedArgs.every((arg) => arg === normalizedMain));
|
582
|
+
}
|
583
|
+
});
|
584
|
+
|
585
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/getattribute/index.ts
|
586
|
+
var getattribute = SmartTags.makeSmartTag({
|
587
|
+
name: "getattribute",
|
588
|
+
defaultMode: "coalescion",
|
589
|
+
isolationInitType: "array",
|
590
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "element"),
|
591
|
+
argsValueCheck: (a) => {
|
592
|
+
const { makeFailure, makeSuccess } = Outcome;
|
593
|
+
const { typeCheckMany, getType } = Utils.Tree.TypeChecks;
|
594
|
+
const { makeArgsValueError } = Utils.SmartTags;
|
595
|
+
if (a.length === 0) return makeFailure(makeArgsValueError("string | Text", "undefined", 0));
|
596
|
+
if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a[2]) ?? "undefined", 1));
|
597
|
+
const checked = typeCheckMany(a, "string", "text");
|
598
|
+
if (checked.success) return makeSuccess(checked.payload);
|
599
|
+
return checked;
|
600
|
+
},
|
601
|
+
func: (main, args) => {
|
602
|
+
const name = Cast.toString(args[0]);
|
603
|
+
const found = main.getAttribute(name);
|
604
|
+
return Outcome.makeSuccess(found);
|
605
|
+
}
|
606
|
+
});
|
607
|
+
|
608
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/getproperties/index.ts
|
609
|
+
var getproperties = SmartTags.makeSmartTag({
|
610
|
+
name: "getproperties",
|
611
|
+
defaultMode: "coalescion",
|
612
|
+
isolationInitType: "array",
|
613
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
|
614
|
+
argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
|
615
|
+
func: (main, args) => {
|
616
|
+
const reduced = args.reduce((reduced2, curr) => {
|
617
|
+
const key = Cast.toString(curr);
|
618
|
+
const val = main[key];
|
619
|
+
if (val === void 0) return { ...reduced2 };
|
620
|
+
return { ...reduced2, [key]: val };
|
621
|
+
}, {});
|
622
|
+
return Outcome.makeSuccess(reduced);
|
623
|
+
}
|
624
|
+
});
|
625
|
+
|
626
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/getproperty/index.ts
|
627
|
+
var getproperty = SmartTags.makeSmartTag({
|
628
|
+
name: "getproperty",
|
629
|
+
defaultMode: "coalescion",
|
630
|
+
isolationInitType: "array",
|
631
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
|
632
|
+
argsValueCheck: (a) => {
|
633
|
+
const { makeFailure, makeSuccess } = Outcome;
|
634
|
+
const { makeArgsValueError } = Utils.SmartTags;
|
635
|
+
const { getType, typeCheckMany } = Utils.Tree.TypeChecks;
|
636
|
+
if (a.length === 0) return makeFailure(makeArgsValueError("string | Text", "undefined", 0));
|
637
|
+
if (a.length !== 1) return makeFailure(makeArgsValueError("undefined", getType(a.at(1)) ?? "undefined", 1));
|
638
|
+
const checked = typeCheckMany(a, "string", "text");
|
639
|
+
if (!checked.success) return checked;
|
640
|
+
return makeSuccess(checked.payload);
|
641
|
+
},
|
642
|
+
func: (main, args) => {
|
643
|
+
const { getType } = Utils.Tree.TypeChecks;
|
644
|
+
const { makeTransformationError } = Utils.SmartTags;
|
645
|
+
const { makeFailure, makeSuccess } = Outcome;
|
646
|
+
const [propName] = args;
|
647
|
+
const strPropName = Cast.toString(propName);
|
648
|
+
try {
|
649
|
+
const found = deepGetProperty(main, strPropName);
|
650
|
+
const foundType = getType(found);
|
651
|
+
if (foundType !== "transformer") return makeSuccess(found);
|
652
|
+
return makeFailure(makeTransformationError(`Forbidden access to key: '${strPropName}'`));
|
653
|
+
} catch (err) {
|
654
|
+
return makeFailure(makeTransformationError(`Impossible to access ${strPropName}`));
|
655
|
+
}
|
656
|
+
}
|
657
|
+
});
|
658
|
+
function deepGetProperty(record2, pathString) {
|
659
|
+
const pathChunks = pathString.split(".").map((e) => e.trim()).filter((e) => e !== "");
|
660
|
+
let currentRecord = record2;
|
661
|
+
let returned = currentRecord;
|
662
|
+
pathChunks.forEach((chunk, pos) => {
|
663
|
+
const isLast = pos === pathChunks.length - 1;
|
664
|
+
if (isLast) {
|
665
|
+
const val = currentRecord[chunk];
|
666
|
+
if (val === void 0) throw "PROP_UNDEFINED";
|
667
|
+
returned = val;
|
668
|
+
} else {
|
669
|
+
const found = currentRecord[chunk];
|
670
|
+
if (isRecord(found)) currentRecord = found;
|
671
|
+
else throw "NOT_A_RECORD";
|
672
|
+
}
|
673
|
+
});
|
674
|
+
return returned;
|
675
|
+
}
|
676
|
+
|
677
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/if/index.ts
|
678
|
+
var ifFunc = SmartTags.makeSmartTag({
|
679
|
+
name: "if",
|
680
|
+
defaultMode: "coalescion",
|
681
|
+
isolationInitType: "array",
|
682
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "boolean"),
|
683
|
+
argsValueCheck: (a) => {
|
684
|
+
const { makeFailure, makeSuccess } = Outcome;
|
685
|
+
const { makeArgsValueError } = Utils.SmartTags;
|
686
|
+
if (a.length > 2) return makeFailure(makeArgsValueError("value", "undefined", a.length));
|
687
|
+
if (a.length < 2) return makeFailure(makeArgsValueError("undefined", "value", 2));
|
688
|
+
return makeSuccess(a);
|
689
|
+
},
|
690
|
+
func: (main, args) => {
|
691
|
+
const [then, otherwise] = args;
|
692
|
+
return Outcome.makeSuccess(main ? then : otherwise);
|
693
|
+
}
|
694
|
+
});
|
695
|
+
|
696
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/initialize/index.ts
|
697
|
+
var initialize = SmartTags.makeSmartTag({
|
698
|
+
name: "initialize",
|
699
|
+
defaultMode: "coalescion",
|
700
|
+
isolationInitType: "array",
|
701
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
702
|
+
argsValueCheck: (a) => {
|
703
|
+
const { makeFailure, makeSuccess } = Outcome;
|
704
|
+
const { getType, typeCheck } = Utils.Tree.TypeChecks;
|
705
|
+
const { makeArgsValueError } = Utils.SmartTags;
|
706
|
+
const first = a[0];
|
707
|
+
if (first === void 0) return makeFailure(makeArgsValueError("string | text", "undefined", 0));
|
708
|
+
if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a[1]) ?? "undefined", 1));
|
709
|
+
const firstChecked = typeCheck(first, "string", "text");
|
710
|
+
if (!firstChecked.success) return makeFailure(makeArgsValueError(firstChecked.error.expected, firstChecked.error.found, 0));
|
711
|
+
return makeSuccess(a);
|
712
|
+
},
|
713
|
+
func: (_main, args) => {
|
714
|
+
const { makeFailure, makeSuccess } = Outcome;
|
715
|
+
const { makeTransformationError } = Utils.SmartTags;
|
716
|
+
const { getInitialValueFromTypeName } = Utils.Tree;
|
717
|
+
const { isValueTypeName } = Utils.Tree.TypeChecks;
|
718
|
+
const firstArg = args[0];
|
719
|
+
const strFirstArg = Cast.toString(firstArg).trim().toLowerCase();
|
720
|
+
const isValueType = isValueTypeName(strFirstArg);
|
721
|
+
if (!isValueType || strFirstArg === "transformer" || strFirstArg === "method") return makeFailure(makeTransformationError(`${strFirstArg} is not a valid type`));
|
722
|
+
const initialized = getInitialValueFromTypeName(strFirstArg);
|
723
|
+
return makeSuccess(initialized);
|
724
|
+
}
|
725
|
+
});
|
726
|
+
|
727
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/join/index.ts
|
728
|
+
var join = SmartTags.makeSmartTag({
|
729
|
+
name: "join",
|
730
|
+
defaultMode: "coalescion",
|
731
|
+
isolationInitType: "array",
|
732
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "array", "nodelist"),
|
733
|
+
argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
|
734
|
+
func: (main, args) => {
|
735
|
+
const { makeSuccess } = Outcome;
|
736
|
+
const joiner = Cast.toString(args);
|
737
|
+
if (Array.isArray(main)) return makeSuccess(main.map(Cast.toString).join(joiner));
|
738
|
+
return makeSuccess(Array.from(main).map(Cast.toString).join(joiner));
|
739
|
+
}
|
740
|
+
});
|
741
|
+
|
742
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/length/index.ts
|
743
|
+
var length = SmartTags.makeSmartTag({
|
744
|
+
name: "length",
|
745
|
+
defaultMode: "coalescion",
|
746
|
+
isolationInitType: "array",
|
747
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "nodelist"),
|
748
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
749
|
+
func: (main) => {
|
750
|
+
const { makeSuccess } = Outcome;
|
751
|
+
const { Text: Text2, NodeList, Element: Element2 } = Window.get();
|
752
|
+
if (typeof main === "string" || main instanceof NodeList || main instanceof Text2 || Array.isArray(main)) return makeSuccess(main.length);
|
753
|
+
if (main instanceof Element2) return makeSuccess(main.childNodes.length);
|
754
|
+
return makeSuccess(Object.keys(main).length);
|
755
|
+
}
|
756
|
+
});
|
757
|
+
|
758
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/map/index.ts
|
759
|
+
var map = SmartTags.makeSmartTag({
|
760
|
+
name: "map",
|
761
|
+
defaultMode: "coalescion",
|
762
|
+
isolationInitType: "array",
|
763
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "array"),
|
764
|
+
argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "method"),
|
765
|
+
func: (main, args) => {
|
766
|
+
const { makeTransformationError } = Utils.SmartTags;
|
767
|
+
let mapped = [];
|
768
|
+
for (const val of main) {
|
769
|
+
let reduced = val;
|
770
|
+
for (const arg of args) {
|
771
|
+
const { transformer } = arg;
|
772
|
+
const applied = transformer.apply(reduced);
|
773
|
+
if (!applied.success) return Outcome.makeFailure(makeTransformationError({
|
774
|
+
message: "Subtransformation failure.",
|
775
|
+
onTransformed: reduced,
|
776
|
+
transformerAt: args.indexOf(arg),
|
777
|
+
transformerName: transformer.name,
|
778
|
+
transformerInput: reduced,
|
779
|
+
transformerOutput: applied
|
780
|
+
}));
|
781
|
+
reduced = applied.payload;
|
782
|
+
}
|
783
|
+
mapped.push(reduced);
|
784
|
+
}
|
785
|
+
return Outcome.makeSuccess(mapped);
|
786
|
+
}
|
787
|
+
});
|
788
|
+
|
789
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/negate/index.ts
|
790
|
+
var negate = SmartTags.makeSmartTag({
|
791
|
+
name: "negate",
|
792
|
+
defaultMode: "coalescion",
|
793
|
+
isolationInitType: "array",
|
794
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "boolean"),
|
795
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
796
|
+
func: (main) => Outcome.makeSuccess(!main)
|
797
|
+
});
|
798
|
+
|
799
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/notrailing/index.ts
|
800
|
+
var notrailing = SmartTags.makeSmartTag({
|
801
|
+
name: "notrailing",
|
802
|
+
defaultMode: "coalescion",
|
803
|
+
isolationInitType: "array",
|
804
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text"),
|
805
|
+
argsValueCheck: (a) => {
|
806
|
+
const { makeSuccess, makeFailure } = Outcome;
|
807
|
+
const { makeArgsValueError } = Utils.SmartTags;
|
808
|
+
const { getType, typeCheck } = Utils.Tree.TypeChecks;
|
809
|
+
if (a.length === 0) return makeSuccess([]);
|
810
|
+
if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a[1]) ?? "undefined", 1));
|
811
|
+
const [first] = a;
|
812
|
+
const firstChecked = typeCheck(first, "string", "text");
|
813
|
+
if (!firstChecked.success) return makeFailure(makeArgsValueError(
|
814
|
+
firstChecked.error.expected,
|
815
|
+
firstChecked.error.found,
|
816
|
+
0
|
817
|
+
));
|
818
|
+
return makeSuccess([firstChecked.payload]);
|
819
|
+
},
|
820
|
+
func: (main, args) => {
|
821
|
+
const strMain = Cast.toString(main);
|
822
|
+
const firstArg = args[0];
|
823
|
+
const strFirstArg = Cast.toString(firstArg ?? "/");
|
824
|
+
let strOutput = strMain;
|
825
|
+
while (strOutput.endsWith(strFirstArg)) strOutput = strOutput.slice(0, -1);
|
826
|
+
if (typeof main === "string") return Outcome.makeSuccess(strOutput);
|
827
|
+
return Outcome.makeSuccess(Cast.toText(strOutput));
|
828
|
+
}
|
829
|
+
});
|
830
|
+
|
831
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/or/index.ts
|
832
|
+
var or = SmartTags.makeSmartTag({
|
833
|
+
name: "or",
|
834
|
+
defaultMode: "coalescion",
|
835
|
+
isolationInitType: "array",
|
836
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
837
|
+
argsValueCheck: (a) => Outcome.makeSuccess(a),
|
838
|
+
func: (main, args) => {
|
839
|
+
const all = [main, ...args];
|
840
|
+
const returned = all.some(Cast.toBoolean);
|
841
|
+
return Outcome.makeSuccess(returned);
|
842
|
+
}
|
843
|
+
});
|
844
|
+
|
845
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/pickrandom/index.ts
|
846
|
+
var pickrandom = SmartTags.makeSmartTag({
|
847
|
+
name: "pickrandom",
|
848
|
+
defaultMode: "coalescion",
|
849
|
+
isolationInitType: "array",
|
850
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "array"),
|
851
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
852
|
+
func: (main) => {
|
853
|
+
const { makeSuccess, makeFailure } = Outcome;
|
854
|
+
const { makeTransformationError } = Utils.SmartTags;
|
855
|
+
const pos = Math.floor(Math.random() * main.length);
|
856
|
+
const found = main[pos];
|
857
|
+
if (found === void 0) return makeFailure(makeTransformationError("Cannot pick inside empty array"));
|
858
|
+
return makeSuccess(found);
|
859
|
+
}
|
860
|
+
});
|
861
|
+
|
862
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/print/index.ts
|
863
|
+
var print = SmartTags.makeSmartTag({
|
864
|
+
name: "print",
|
865
|
+
defaultMode: "coalescion",
|
866
|
+
isolationInitType: "array",
|
867
|
+
mainValueCheck: (m) => {
|
868
|
+
const { getType } = Utils.Tree.TypeChecks;
|
869
|
+
const { makeSuccess, makeFailure } = Outcome;
|
870
|
+
const { makeMainValueError } = Utils.SmartTags;
|
871
|
+
return getType(m) === "transformer" ? makeFailure(makeMainValueError("Exclude<value, transformer>", "transformer")) : makeSuccess(m);
|
872
|
+
},
|
873
|
+
argsValueCheck: (a) => Outcome.makeSuccess(a),
|
874
|
+
func: (main, args, details) => {
|
875
|
+
console.group("print");
|
876
|
+
console.log("Main:", main);
|
877
|
+
console.log("Args:", ...args);
|
878
|
+
console.log("Tree:", details.sourceTree);
|
879
|
+
console.groupEnd();
|
880
|
+
return Outcome.makeSuccess(main);
|
881
|
+
}
|
882
|
+
});
|
883
|
+
|
884
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/populate/index.ts
|
885
|
+
var populate = SmartTags.makeSmartTag({
|
886
|
+
name: "populate",
|
887
|
+
defaultMode: "coalescion",
|
888
|
+
isolationInitType: "array",
|
889
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
|
890
|
+
argsValueCheck: (a) => {
|
891
|
+
const [first, ...others] = a;
|
892
|
+
const { makeFailure, makeSuccess } = Outcome;
|
893
|
+
const { makeArgsValueError } = Utils.SmartTags;
|
894
|
+
const { typeCheck, typeCheckMany, getType } = Utils.Tree.TypeChecks;
|
895
|
+
const firstChecked = typeCheck(first, "string", "text", "nodelist", "element");
|
896
|
+
if (!firstChecked.success) return makeFailure(makeArgsValueError(
|
897
|
+
firstChecked.error.expected,
|
898
|
+
firstChecked.error.found,
|
899
|
+
0
|
900
|
+
));
|
901
|
+
const othersChecked = typeCheckMany(others, "array");
|
902
|
+
if (!othersChecked.success) return makeFailure(makeArgsValueError(
|
903
|
+
othersChecked.error.expected,
|
904
|
+
othersChecked.error.found,
|
905
|
+
othersChecked.error.position + 1
|
906
|
+
));
|
907
|
+
for (const [argPos, arg] of Object.entries(othersChecked.payload)) {
|
908
|
+
const argPosNum = parseInt(argPos);
|
909
|
+
const [first2, second] = arg;
|
910
|
+
const firstChecked2 = typeCheck(first2, "string", "text");
|
911
|
+
const secondChecked = typeCheck(second, "string", "text");
|
912
|
+
if (!firstChecked2.success || !secondChecked.success) return makeFailure(makeArgsValueError(
|
913
|
+
"[string | Text, string | Text]",
|
914
|
+
`[${getType(first2)}, ${getType(second)}]`,
|
915
|
+
argPosNum + 1
|
916
|
+
));
|
917
|
+
}
|
918
|
+
return makeSuccess(a);
|
919
|
+
},
|
920
|
+
func: (main, args) => {
|
921
|
+
const { makeSuccess, makeFailure } = Outcome;
|
922
|
+
const { makeTransformationError } = Utils.SmartTags;
|
923
|
+
const record2 = main;
|
924
|
+
const [template, ...actions] = args;
|
925
|
+
let returnedStr = Cast.toString(template);
|
926
|
+
for (const [propName, toReplace] of actions) {
|
927
|
+
try {
|
928
|
+
const value = deepGetProperty(record2, Cast.toString(propName));
|
929
|
+
const replaced = replaceAll(returnedStr, Cast.toString(toReplace), Cast.toString(value));
|
930
|
+
returnedStr = replaced;
|
931
|
+
} catch (err) {
|
932
|
+
return makeFailure(makeTransformationError({
|
933
|
+
message: "Something went wrong",
|
934
|
+
subTransformerError: err
|
935
|
+
}));
|
936
|
+
}
|
937
|
+
}
|
938
|
+
const { Text: Text2, NodeList } = Window.get();
|
939
|
+
if (typeof template === "string") return makeSuccess(returnedStr);
|
940
|
+
if (template instanceof Text2) return makeSuccess(Cast.toText(returnedStr));
|
941
|
+
if (template instanceof NodeList) return makeSuccess(Cast.toNodeList(returnedStr));
|
942
|
+
return makeSuccess(Cast.toElement(returnedStr));
|
943
|
+
}
|
944
|
+
});
|
945
|
+
|
946
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/push/index.ts
|
947
|
+
var push = SmartTags.makeSmartTag({
|
948
|
+
name: "push",
|
949
|
+
defaultMode: "coalescion",
|
950
|
+
isolationInitType: "array",
|
951
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "array"),
|
952
|
+
argsValueCheck: (a) => Outcome.makeSuccess(a),
|
953
|
+
func: (main, args) => Outcome.makeSuccess([...main, ...args])
|
954
|
+
});
|
955
|
+
|
956
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/pusheach/index.ts
|
957
|
+
var pusheach = SmartTags.makeSmartTag({
|
958
|
+
name: "pusheach",
|
959
|
+
defaultMode: "coalescion",
|
960
|
+
isolationInitType: "array",
|
961
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "array"),
|
962
|
+
argsValueCheck: (a) => {
|
963
|
+
const { makeSuccess, makeFailure } = Outcome;
|
964
|
+
const { typeCheck } = Utils.Tree.TypeChecks;
|
965
|
+
const { makeArgsValueError } = Utils.SmartTags;
|
966
|
+
for (const [argPos, arg] of Object.entries(a)) {
|
967
|
+
const numPos = parseInt(argPos);
|
968
|
+
const checked = typeCheck(arg, "array");
|
969
|
+
if (!checked.success) return makeFailure(makeArgsValueError(
|
970
|
+
checked.error.expected,
|
971
|
+
checked.error.found,
|
972
|
+
numPos
|
973
|
+
));
|
974
|
+
}
|
975
|
+
return makeSuccess(a);
|
976
|
+
},
|
977
|
+
func: (main, args) => {
|
978
|
+
const returned = [...main];
|
979
|
+
for (const arg of args) {
|
980
|
+
returned.push(...arg);
|
981
|
+
}
|
982
|
+
return Outcome.makeSuccess(returned);
|
983
|
+
}
|
984
|
+
});
|
985
|
+
|
986
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/recordtoarray/index.ts
|
987
|
+
var recordtoarray = SmartTags.makeSmartTag({
|
988
|
+
name: "recordtoarray",
|
989
|
+
defaultMode: "coalescion",
|
990
|
+
isolationInitType: "array",
|
991
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
|
992
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
993
|
+
func: (main) => Outcome.makeSuccess(Object.values(main))
|
994
|
+
});
|
995
|
+
|
996
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/removeattribute/index.ts
|
997
|
+
var removeattribute = SmartTags.makeSmartTag({
|
998
|
+
name: "removeattribute",
|
999
|
+
defaultMode: "coalescion",
|
1000
|
+
isolationInitType: "array",
|
1001
|
+
mainValueCheck: (m) => {
|
1002
|
+
const { typeCheck, typeCheckMany } = Utils.Tree.TypeChecks;
|
1003
|
+
if (Array.isArray(m)) return typeCheckMany(m, "element");
|
1004
|
+
return typeCheck(m, "element");
|
1005
|
+
},
|
1006
|
+
argsValueCheck: (a) => {
|
1007
|
+
const { makeFailure, makeSuccess } = Outcome;
|
1008
|
+
const { typeCheckMany, getType } = Utils.Tree.TypeChecks;
|
1009
|
+
const { makeArgsValueError } = Utils.SmartTags;
|
1010
|
+
if (a.length === 0) return makeFailure(makeArgsValueError("string | Text", "undefined", 0));
|
1011
|
+
if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a[2]) ?? "undefined", 1));
|
1012
|
+
const checked = typeCheckMany(a, "string", "text");
|
1013
|
+
if (checked.success) return makeSuccess(checked.payload);
|
1014
|
+
return checked;
|
1015
|
+
},
|
1016
|
+
func: (main, args) => {
|
1017
|
+
const { makeSuccess } = Outcome;
|
1018
|
+
const mainArr = Array.isArray(main) ? main : [main];
|
1019
|
+
const mainArrCloned = mainArr.map((e) => Utils.clone(e));
|
1020
|
+
const name = Cast.toString(args[0]);
|
1021
|
+
mainArrCloned.forEach((e) => e.removeAttribute(name));
|
1022
|
+
if (Array.isArray(main)) return makeSuccess(mainArrCloned);
|
1023
|
+
return makeSuccess(mainArrCloned[0]);
|
1024
|
+
}
|
1025
|
+
});
|
1026
|
+
|
1027
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/removeclass/index.ts
|
1028
|
+
var removeclass = SmartTags.makeSmartTag({
|
1029
|
+
name: "removeclass",
|
1030
|
+
defaultMode: "coalescion",
|
1031
|
+
isolationInitType: "array",
|
1032
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "element"),
|
1033
|
+
argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
|
1034
|
+
func: (main, args) => {
|
1035
|
+
main.classList.remove(...args.map((arg) => Cast.toString(arg)));
|
1036
|
+
return Outcome.makeSuccess(main);
|
1037
|
+
}
|
1038
|
+
});
|
1039
|
+
|
1040
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/renameproperty/index.ts
|
1041
|
+
var renameproperty = SmartTags.makeSmartTag({
|
1042
|
+
name: "renameproperty",
|
1043
|
+
defaultMode: "coalescion",
|
1044
|
+
isolationInitType: "array",
|
1045
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
|
1046
|
+
argsValueCheck: (a) => {
|
1047
|
+
const { makeFailure, makeSuccess } = Outcome;
|
1048
|
+
const { typeCheck, typeCheckMany } = Utils.Tree.TypeChecks;
|
1049
|
+
const checked = typeCheckMany(a, "string", "text");
|
1050
|
+
if (!checked.success) return checked;
|
1051
|
+
const [first, second] = a;
|
1052
|
+
const firstChecked = typeCheck(first, "string", "text");
|
1053
|
+
if (!firstChecked.success) return makeFailure(Utils.SmartTags.makeArgsValueError(
|
1054
|
+
firstChecked.error.expected,
|
1055
|
+
firstChecked.error.found,
|
1056
|
+
0
|
1057
|
+
));
|
1058
|
+
const secondChecked = typeCheck(second, "string", "text");
|
1059
|
+
if (!secondChecked.success) return makeFailure(Utils.SmartTags.makeArgsValueError(
|
1060
|
+
secondChecked.error.expected,
|
1061
|
+
secondChecked.error.found,
|
1062
|
+
0
|
1063
|
+
));
|
1064
|
+
return makeSuccess([firstChecked.payload, secondChecked.payload]);
|
1065
|
+
},
|
1066
|
+
func: (main, args) => {
|
1067
|
+
const [oldKey, newKey] = args.map(Cast.toString);
|
1068
|
+
const returned = {};
|
1069
|
+
Object.entries(main).forEach(([key, value]) => {
|
1070
|
+
const targetKey = key === oldKey ? newKey : key;
|
1071
|
+
returned[targetKey] = value;
|
1072
|
+
});
|
1073
|
+
return Outcome.makeSuccess(returned);
|
1074
|
+
}
|
1075
|
+
});
|
1076
|
+
|
1077
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/replace/index.ts
|
1078
|
+
var replace = SmartTags.makeSmartTag({
|
1079
|
+
name: "replace",
|
1080
|
+
defaultMode: "coalescion",
|
1081
|
+
isolationInitType: "array",
|
1082
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text", "nodelist", "element"),
|
1083
|
+
argsValueCheck: (a) => {
|
1084
|
+
const { makeFailure, makeSuccess } = Outcome;
|
1085
|
+
const { getType, typeCheckMany } = Utils.Tree.TypeChecks;
|
1086
|
+
const { makeArgsValueError } = Utils.SmartTags;
|
1087
|
+
const expectedStr = "string | Text | NodeListOf<Element | Text> | Element";
|
1088
|
+
if (a.length === 0) return makeFailure(makeArgsValueError(expectedStr, "undefined", 0));
|
1089
|
+
if (a.length === 1) return makeFailure(makeArgsValueError(expectedStr, "undefined", 1));
|
1090
|
+
if (a.length > 2) return makeFailure(makeArgsValueError("undefined", getType(a.at(2)) ?? "undefined", 3));
|
1091
|
+
const checked = typeCheckMany(a, "string", "text", "nodelist", "element");
|
1092
|
+
if (!checked.success) return checked;
|
1093
|
+
return makeSuccess(checked.payload);
|
1094
|
+
},
|
1095
|
+
func: (main, args) => {
|
1096
|
+
const [toReplace, replacer] = args;
|
1097
|
+
const strMain = Cast.toString(main);
|
1098
|
+
const strToReplace = Cast.toString(toReplace);
|
1099
|
+
const strReplacer = Cast.toString(replacer);
|
1100
|
+
const strReplaced = replaceAll(strMain, strToReplace, strReplacer);
|
1101
|
+
let returned;
|
1102
|
+
if (typeof main === "string") {
|
1103
|
+
returned = strReplaced;
|
1104
|
+
} else if (main instanceof Text) {
|
1105
|
+
returned = Cast.toText(strReplaced);
|
1106
|
+
} else if (main instanceof Element) {
|
1107
|
+
returned = Cast.toElement(strReplaced);
|
1108
|
+
} else {
|
1109
|
+
returned = Cast.toNodeList(strReplaced);
|
1110
|
+
}
|
1111
|
+
return Outcome.makeSuccess(returned);
|
1112
|
+
}
|
1113
|
+
});
|
1114
|
+
|
1115
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/select/index.ts
|
1116
|
+
var select = SmartTags.makeSmartTag({
|
1117
|
+
name: "select",
|
1118
|
+
defaultMode: "coalescion",
|
1119
|
+
isolationInitType: "array",
|
1120
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "nodelist", "element"),
|
1121
|
+
argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
|
1122
|
+
func: (main, args) => {
|
1123
|
+
const selectedFragment = document.createDocumentFragment();
|
1124
|
+
if (main instanceof Window.get().Element) {
|
1125
|
+
for (const arg of args) {
|
1126
|
+
const selector = Cast.toString(arg);
|
1127
|
+
const found = main.querySelectorAll(selector);
|
1128
|
+
selectedFragment.append(...Array.from(found));
|
1129
|
+
}
|
1130
|
+
} else {
|
1131
|
+
const divWrapper = Window.get().document.createElement("div");
|
1132
|
+
divWrapper.append(...Array.from(main));
|
1133
|
+
for (const arg of args) {
|
1134
|
+
const selector = Cast.toString(arg);
|
1135
|
+
const found = divWrapper.querySelectorAll(selector);
|
1136
|
+
selectedFragment.append(...Array.from(found));
|
1137
|
+
}
|
1138
|
+
}
|
1139
|
+
const selected = selectedFragment.childNodes;
|
1140
|
+
return Outcome.makeSuccess(selected);
|
1141
|
+
}
|
1142
|
+
});
|
1143
|
+
|
1144
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/set/index.ts
|
1145
|
+
var set = SmartTags.makeSmartTag({
|
1146
|
+
name: "set",
|
1147
|
+
defaultMode: "coalescion",
|
1148
|
+
isolationInitType: "array",
|
1149
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
1150
|
+
argsValueCheck: (a) => {
|
1151
|
+
const { makeFailure, makeSuccess } = Outcome;
|
1152
|
+
const { makeArgsValueError } = Utils.SmartTags;
|
1153
|
+
const { getType, typeCheck } = Utils.Tree.TypeChecks;
|
1154
|
+
const first = a[0];
|
1155
|
+
if (first === void 0) return makeFailure(makeArgsValueError("string | text", "undefined", 0));
|
1156
|
+
if (a.length > 2) return makeFailure(makeArgsValueError("undefined", getType(a[2]) ?? "undefined", 2));
|
1157
|
+
const firstChecked = typeCheck(first, "string", "text");
|
1158
|
+
if (!firstChecked.success) return firstChecked;
|
1159
|
+
else return makeSuccess(a);
|
1160
|
+
},
|
1161
|
+
func: (main, args, { sourceTree }) => {
|
1162
|
+
const [first, second] = args;
|
1163
|
+
const strFirst = Cast.toString(first);
|
1164
|
+
sourceTree.setVariable(strFirst, second === void 0 ? main : second);
|
1165
|
+
return Outcome.makeSuccess(main);
|
1166
|
+
}
|
1167
|
+
});
|
1168
|
+
|
1169
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/setattribute/index.ts
|
1170
|
+
var setattribute = SmartTags.makeSmartTag({
|
1171
|
+
name: "setattribute",
|
1172
|
+
defaultMode: "coalescion",
|
1173
|
+
isolationInitType: "array",
|
1174
|
+
mainValueCheck: (m) => {
|
1175
|
+
const { typeCheck, typeCheckMany } = Utils.Tree.TypeChecks;
|
1176
|
+
if (Array.isArray(m)) return typeCheckMany(m, "element");
|
1177
|
+
return typeCheck(m, "element");
|
1178
|
+
},
|
1179
|
+
argsValueCheck: (a) => {
|
1180
|
+
const { makeFailure, makeSuccess } = Outcome;
|
1181
|
+
const { typeCheckMany, getType } = Utils.Tree.TypeChecks;
|
1182
|
+
const { makeArgsValueError } = Utils.SmartTags;
|
1183
|
+
if (a.length === 0) return makeFailure(makeArgsValueError("string | Text", "undefined", 0));
|
1184
|
+
if (a.length > 2) return makeFailure(makeArgsValueError("undefined", getType(a[2]) ?? "undefined", 2));
|
1185
|
+
const checked = typeCheckMany(a, "string", "text");
|
1186
|
+
if (checked.success) return makeSuccess(checked.payload);
|
1187
|
+
return checked;
|
1188
|
+
},
|
1189
|
+
func: (main, args) => {
|
1190
|
+
const mainArr = Array.isArray(main) ? main : [main];
|
1191
|
+
const mainArrCloned = mainArr.map((e) => Utils.clone(e));
|
1192
|
+
const argsStr = args.map((e) => Cast.toString(e));
|
1193
|
+
const [name, value = ""] = argsStr;
|
1194
|
+
mainArrCloned.forEach((e) => e.setAttribute(name, value));
|
1195
|
+
if (Array.isArray(main)) return Outcome.makeSuccess(mainArrCloned);
|
1196
|
+
return Outcome.makeSuccess(mainArrCloned[0]);
|
1197
|
+
}
|
1198
|
+
});
|
1199
|
+
|
1200
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/setproperties/index.ts
|
1201
|
+
var setproperties = SmartTags.makeSmartTag({
|
1202
|
+
name: "setproperties",
|
1203
|
+
defaultMode: "coalescion",
|
1204
|
+
isolationInitType: "array",
|
1205
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
|
1206
|
+
argsValueCheck: (a) => {
|
1207
|
+
const { makeFailure, makeSuccess } = Outcome;
|
1208
|
+
const { makeArgsValueError } = Utils.SmartTags;
|
1209
|
+
const { getType, typeCheck } = Utils.Tree.TypeChecks;
|
1210
|
+
if (a.length === 0) return makeFailure(makeArgsValueError("record", "undefined", 0));
|
1211
|
+
if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a.at(1)) ?? "undefined", 1));
|
1212
|
+
const [first] = a;
|
1213
|
+
const firstChecked = typeCheck(first, "record");
|
1214
|
+
if (!firstChecked.success) return makeFailure(makeArgsValueError(firstChecked.error.expected, firstChecked.error.found, 0));
|
1215
|
+
return makeSuccess([firstChecked.payload]);
|
1216
|
+
},
|
1217
|
+
func: (main, args) => Outcome.makeSuccess({ ...main, ...args[0] })
|
1218
|
+
});
|
1219
|
+
|
1220
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/setproperty/index.ts
|
1221
|
+
var setproperty = SmartTags.makeSmartTag({
|
1222
|
+
name: "setproperty",
|
1223
|
+
defaultMode: "coalescion",
|
1224
|
+
isolationInitType: "array",
|
1225
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "record"),
|
1226
|
+
argsValueCheck: (a) => {
|
1227
|
+
const { makeFailure, makeSuccess } = Outcome;
|
1228
|
+
const { makeArgsValueError } = Utils.SmartTags;
|
1229
|
+
const { getType, typeCheck } = Utils.Tree.TypeChecks;
|
1230
|
+
if (a.length === 0) return makeFailure(makeArgsValueError("string | Text", "undefined", 0));
|
1231
|
+
if (a.length === 1) return makeFailure(makeArgsValueError("value", "undefined", 1));
|
1232
|
+
if (a.length !== 2) return makeFailure(makeArgsValueError("undefined", getType(a.at(2)) ?? "undefined", 2));
|
1233
|
+
const [first, second] = a;
|
1234
|
+
const firstChecked = typeCheck(first, "string", "text");
|
1235
|
+
if (!firstChecked.success) return makeFailure(makeArgsValueError(firstChecked.error.expected, firstChecked.error.found, 0));
|
1236
|
+
return makeSuccess([firstChecked.payload, second]);
|
1237
|
+
},
|
1238
|
+
func: (main, args) => {
|
1239
|
+
const [key, val] = args;
|
1240
|
+
const { makeSuccess, makeFailure } = Outcome;
|
1241
|
+
const { makeTransformationError } = Utils.SmartTags;
|
1242
|
+
try {
|
1243
|
+
const withPropertySet = deepSetProperty(
|
1244
|
+
Utils.clone(main),
|
1245
|
+
Cast.toString(key),
|
1246
|
+
val
|
1247
|
+
);
|
1248
|
+
return makeSuccess(withPropertySet);
|
1249
|
+
} catch (err) {
|
1250
|
+
return makeFailure(makeTransformationError(`Impossible to access property :${key}`));
|
1251
|
+
}
|
1252
|
+
}
|
1253
|
+
});
|
1254
|
+
function deepSetProperty(record2, pathString, value) {
|
1255
|
+
const pathChunks = pathString.split(".");
|
1256
|
+
const clone2 = Utils.clone(record2);
|
1257
|
+
let currentRecord = clone2;
|
1258
|
+
pathChunks.forEach((chunk, pos) => {
|
1259
|
+
const isLast = pos === pathChunks.length - 1;
|
1260
|
+
if (isLast) {
|
1261
|
+
currentRecord[chunk] = value;
|
1262
|
+
} else {
|
1263
|
+
const found = currentRecord[chunk];
|
1264
|
+
if (isRecord(found)) currentRecord = found;
|
1265
|
+
else throw "NOT_A_RECORD";
|
1266
|
+
}
|
1267
|
+
});
|
1268
|
+
return clone2;
|
1269
|
+
}
|
1270
|
+
|
1271
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/sorton/index.ts
|
1272
|
+
var sorton = SmartTags.makeSmartTag({
|
1273
|
+
name: "sorton",
|
1274
|
+
defaultMode: "coalescion",
|
1275
|
+
isolationInitType: "array",
|
1276
|
+
mainValueCheck: (m) => {
|
1277
|
+
const { makeMainValueError } = Utils.SmartTags;
|
1278
|
+
const { getType } = Utils.Tree.TypeChecks;
|
1279
|
+
const { makeFailure, makeSuccess } = Outcome;
|
1280
|
+
if (!Array.isArray(m)) return makeFailure(makeMainValueError("array<record>", getType(m) ?? "undefined"));
|
1281
|
+
for (const [itemPos, itemVal] of Object.entries(m)) {
|
1282
|
+
if (isRecord(itemVal)) continue;
|
1283
|
+
return makeFailure(makeMainValueError("record", getType(itemVal), `At position ${parseInt(itemPos)} in main value`));
|
1284
|
+
}
|
1285
|
+
return makeSuccess(m);
|
1286
|
+
},
|
1287
|
+
argsValueCheck: (a) => {
|
1288
|
+
const { makeFailure, makeSuccess } = Outcome;
|
1289
|
+
const { makeArgsValueError } = Utils.SmartTags;
|
1290
|
+
const { getType, typeCheckMany } = Utils.Tree.TypeChecks;
|
1291
|
+
if (a.length === 0) return makeFailure(makeArgsValueError("[string | text]", "[]", 0));
|
1292
|
+
if (a.length > 1) return makeFailure(makeArgsValueError("undefined", getType(a[1]) ?? "undefined", 2));
|
1293
|
+
const checked = typeCheckMany(a, "string", "text");
|
1294
|
+
if (checked.success) return makeSuccess(checked.payload);
|
1295
|
+
return checked;
|
1296
|
+
},
|
1297
|
+
func: (main, args) => {
|
1298
|
+
const { makeFailure, makeSuccess } = Outcome;
|
1299
|
+
const strPropName = Cast.toString(args[0]);
|
1300
|
+
const { getType } = Utils.Tree.TypeChecks;
|
1301
|
+
const { makeTransformationError } = Utils.SmartTags;
|
1302
|
+
const map2 = main.map((record2) => {
|
1303
|
+
const prop = record2[strPropName];
|
1304
|
+
const type = getType(prop);
|
1305
|
+
return { record: record2, prop, type };
|
1306
|
+
});
|
1307
|
+
const firstItem = map2[0];
|
1308
|
+
if (firstItem === void 0) return makeSuccess([]);
|
1309
|
+
const firstItemType = firstItem.type;
|
1310
|
+
if (firstItemType === void 0) return makeFailure(makeTransformationError({
|
1311
|
+
message: "Invalid property type",
|
1312
|
+
onItem: 0,
|
1313
|
+
found: firstItemType
|
1314
|
+
}));
|
1315
|
+
for (const [daytumPos, daytumVal] of Object.entries(map2)) {
|
1316
|
+
if (daytumVal.type !== firstItemType) return makeFailure(makeTransformationError({
|
1317
|
+
message: "Invalid property type",
|
1318
|
+
onItem: parseInt(daytumPos),
|
1319
|
+
expected: firstItemType,
|
1320
|
+
found: daytumVal.type
|
1321
|
+
}));
|
1322
|
+
}
|
1323
|
+
const sorted = main.sort((a, b) => {
|
1324
|
+
const { Text: Text2, NodeList } = Window.get();
|
1325
|
+
const aProp = a[strPropName];
|
1326
|
+
const bProp = b[strPropName];
|
1327
|
+
if (aProp === null) return 0;
|
1328
|
+
if (typeof aProp === "boolean") {
|
1329
|
+
if (aProp === bProp) return 0;
|
1330
|
+
if (aProp) return 1;
|
1331
|
+
return -1;
|
1332
|
+
}
|
1333
|
+
if (typeof aProp === "string") return aProp.localeCompare(Cast.toString(bProp));
|
1334
|
+
if (aProp instanceof Text2) return Cast.toString(aProp).localeCompare(Cast.toString(bProp));
|
1335
|
+
if (typeof aProp === "number") return aProp - Cast.toNumber(bProp);
|
1336
|
+
if (Array.isArray(aProp)) return aProp.length - Cast.toArray(bProp).length;
|
1337
|
+
if (aProp instanceof NodeList) return aProp.length - Cast.toNodeList(bProp).length;
|
1338
|
+
return 0;
|
1339
|
+
});
|
1340
|
+
return makeSuccess(sorted);
|
1341
|
+
}
|
1342
|
+
});
|
1343
|
+
|
1344
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/split/index.ts
|
1345
|
+
var split = SmartTags.makeSmartTag({
|
1346
|
+
name: "split",
|
1347
|
+
defaultMode: "coalescion",
|
1348
|
+
isolationInitType: "array",
|
1349
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text"),
|
1350
|
+
argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
|
1351
|
+
func: (main, args) => {
|
1352
|
+
let strReturnedArr = [Cast.toString(main)];
|
1353
|
+
for (const arg of args) {
|
1354
|
+
strReturnedArr = strReturnedArr.map((e) => e.split(Cast.toString(arg))).flat();
|
1355
|
+
}
|
1356
|
+
if (typeof main === "string") return Outcome.makeSuccess(strReturnedArr);
|
1357
|
+
return Outcome.makeSuccess(strReturnedArr.map(Cast.toText));
|
1358
|
+
}
|
1359
|
+
});
|
1360
|
+
|
1361
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/toarray/index.ts
|
1362
|
+
var toarray = SmartTags.makeSmartTag({
|
1363
|
+
name: "toarray",
|
1364
|
+
defaultMode: "coalescion",
|
1365
|
+
isolationInitType: "array",
|
1366
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
1367
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
1368
|
+
func: (main) => Outcome.makeSuccess(Cast.toArray(main))
|
1369
|
+
});
|
1370
|
+
|
1371
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/toboolean/index.ts
|
1372
|
+
var toboolean = SmartTags.makeSmartTag({
|
1373
|
+
name: "toboolean",
|
1374
|
+
defaultMode: "coalescion",
|
1375
|
+
isolationInitType: "array",
|
1376
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
1377
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
1378
|
+
func: (m) => Outcome.makeSuccess(Cast.toBoolean(m))
|
1379
|
+
});
|
1380
|
+
|
1381
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/toelement/index.ts
|
1382
|
+
var toelement = SmartTags.makeSmartTag({
|
1383
|
+
name: "toelement",
|
1384
|
+
defaultMode: "coalescion",
|
1385
|
+
isolationInitType: "array",
|
1386
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
1387
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
1388
|
+
func: (m) => Outcome.makeSuccess(Cast.toElement(m))
|
1389
|
+
});
|
1390
|
+
|
1391
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/toggleclass/index.ts
|
1392
|
+
var toggleclass = SmartTags.makeSmartTag({
|
1393
|
+
name: "toggleclass",
|
1394
|
+
defaultMode: "coalescion",
|
1395
|
+
isolationInitType: "array",
|
1396
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "element"),
|
1397
|
+
argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "string", "text"),
|
1398
|
+
func: (main, args) => {
|
1399
|
+
for (const arg of args) main.classList.toggle(Cast.toString(arg));
|
1400
|
+
return Outcome.makeSuccess(main);
|
1401
|
+
}
|
1402
|
+
});
|
1403
|
+
|
1404
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/tonodelist/index.ts
|
1405
|
+
var tonodelist = SmartTags.makeSmartTag({
|
1406
|
+
name: "tonodelist",
|
1407
|
+
defaultMode: "coalescion",
|
1408
|
+
isolationInitType: "array",
|
1409
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
1410
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
1411
|
+
func: (m) => Outcome.makeSuccess(Cast.toNodeList(m))
|
1412
|
+
});
|
1413
|
+
|
1414
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/tonull/index.ts
|
1415
|
+
var tonull = SmartTags.makeSmartTag({
|
1416
|
+
name: "tonull",
|
1417
|
+
defaultMode: "coalescion",
|
1418
|
+
isolationInitType: "array",
|
1419
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
1420
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
1421
|
+
func: () => Outcome.makeSuccess(null)
|
1422
|
+
});
|
1423
|
+
|
1424
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/tonumber/index.ts
|
1425
|
+
var tonumber = SmartTags.makeSmartTag({
|
1426
|
+
name: "tonumber",
|
1427
|
+
defaultMode: "coalescion",
|
1428
|
+
isolationInitType: "array",
|
1429
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
1430
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
1431
|
+
func: (m) => Outcome.makeSuccess(Cast.toNumber(m))
|
1432
|
+
});
|
1433
|
+
|
1434
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/torecord/index.ts
|
1435
|
+
var torecord = SmartTags.makeSmartTag({
|
1436
|
+
name: "torecord",
|
1437
|
+
defaultMode: "coalescion",
|
1438
|
+
isolationInitType: "array",
|
1439
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
1440
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
1441
|
+
func: (main) => Outcome.makeSuccess(Cast.toRecord(main))
|
1442
|
+
});
|
1443
|
+
|
1444
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/toref/index.ts
|
1445
|
+
var toref = SmartTags.makeSmartTag({
|
1446
|
+
name: "toref",
|
1447
|
+
defaultMode: "coalescion",
|
1448
|
+
isolationInitType: "array",
|
1449
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
1450
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
1451
|
+
func: (main, args, details) => func(Cast.toString(main), args, details)
|
1452
|
+
});
|
1453
|
+
|
1454
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/tostring/index.ts
|
1455
|
+
var tostring = SmartTags.makeSmartTag({
|
1456
|
+
name: "tostring",
|
1457
|
+
defaultMode: "coalescion",
|
1458
|
+
isolationInitType: "array",
|
1459
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
1460
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
1461
|
+
func: (m) => Outcome.makeSuccess(Cast.toString(m))
|
1462
|
+
});
|
1463
|
+
|
1464
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/totext/index.ts
|
1465
|
+
var totext = SmartTags.makeSmartTag({
|
1466
|
+
name: "totext",
|
1467
|
+
defaultMode: "coalescion",
|
1468
|
+
isolationInitType: "array",
|
1469
|
+
mainValueCheck: (m) => Outcome.makeSuccess(m),
|
1470
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
1471
|
+
func: (m) => Outcome.makeSuccess(Cast.toText(m))
|
1472
|
+
});
|
1473
|
+
|
1474
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/transformselected/index.ts
|
1475
|
+
var transformselected = SmartTags.makeSmartTag({
|
1476
|
+
name: "transformselected",
|
1477
|
+
defaultMode: "coalescion",
|
1478
|
+
isolationInitType: "array",
|
1479
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "element", "nodelist"),
|
1480
|
+
argsValueCheck: (a) => {
|
1481
|
+
const { makeFailure, makeSuccess } = Outcome;
|
1482
|
+
const { typeCheck, typeCheckMany } = Utils.Tree.TypeChecks;
|
1483
|
+
const [first, ...others] = a;
|
1484
|
+
const firstChecked = typeCheck(first, "string", "text");
|
1485
|
+
if (!firstChecked.success) return makeFailure({ ...firstChecked.error, position: 0 });
|
1486
|
+
const othersChecked = typeCheckMany(others, "method");
|
1487
|
+
if (!othersChecked.success) return makeFailure({
|
1488
|
+
...othersChecked.error,
|
1489
|
+
position: othersChecked.error.position + 1
|
1490
|
+
});
|
1491
|
+
const returned = [firstChecked.payload, ...othersChecked.payload];
|
1492
|
+
return makeSuccess(returned);
|
1493
|
+
},
|
1494
|
+
func: (main, args) => {
|
1495
|
+
const { makeFailure, makeSuccess } = Outcome;
|
1496
|
+
const { makeTransformationError } = Utils.SmartTags;
|
1497
|
+
const { typeCheck } = Utils.Tree.TypeChecks;
|
1498
|
+
const mainClone = Cast.toElement(main);
|
1499
|
+
const [selector, ...methods] = args;
|
1500
|
+
const selectedElements = Array.from(mainClone.querySelectorAll(Cast.toString(selector)));
|
1501
|
+
const transformationMap = new Map(selectedElements.map((s) => [s, Utils.clone(s)]));
|
1502
|
+
for (const method of methods) {
|
1503
|
+
for (const [selected, value] of Array.from(transformationMap)) {
|
1504
|
+
const transformer = method.transformer;
|
1505
|
+
const applied = transformer.apply(value);
|
1506
|
+
if (!applied.success) return makeFailure(makeTransformationError({
|
1507
|
+
// [WIP] maybe a custom makeSubTransformationError ?
|
1508
|
+
message: "Subtransformation failure.",
|
1509
|
+
onSelected: selected,
|
1510
|
+
onTransformed: value,
|
1511
|
+
transformerAt: methods.indexOf(method),
|
1512
|
+
transformerName: transformer.name,
|
1513
|
+
transformerOutput: applied
|
1514
|
+
}));
|
1515
|
+
transformationMap.set(selected, applied.payload);
|
1516
|
+
}
|
1517
|
+
}
|
1518
|
+
for (const [selected, transformed] of Array.from(transformationMap)) {
|
1519
|
+
const transformedChecked = typeCheck(transformed, "element", "nodelist", "text", "string", "number", "boolean", "null");
|
1520
|
+
if (!transformedChecked.success) return makeFailure(makeTransformationError({
|
1521
|
+
// [WIP] maybe a custom makeBadTransformationOutputError ?
|
1522
|
+
message: "Bad transformation output",
|
1523
|
+
onSelected: selected,
|
1524
|
+
onTransformed: transformed,
|
1525
|
+
details: { ...transformedChecked.error }
|
1526
|
+
}));
|
1527
|
+
const { Element: Element2, NodeList, Text: Text2 } = Window.get();
|
1528
|
+
const replacer = transformedChecked.payload;
|
1529
|
+
if (replacer instanceof Element2 || replacer instanceof Text2) {
|
1530
|
+
insertNode(replacer, "after", selected);
|
1531
|
+
selected.remove();
|
1532
|
+
} else if (replacer instanceof NodeList) {
|
1533
|
+
replacer.forEach((item) => insertNode(item, "before", selected));
|
1534
|
+
selected.remove();
|
1535
|
+
} else {
|
1536
|
+
insertNode(Cast.toText(replacer), "after", selected);
|
1537
|
+
selected.remove();
|
1538
|
+
}
|
1539
|
+
transformedChecked.payload;
|
1540
|
+
}
|
1541
|
+
if (main instanceof Element) return makeSuccess(mainClone);
|
1542
|
+
const safeChildren = Array.from(mainClone.childNodes).filter((e) => e instanceof Element || e instanceof Text);
|
1543
|
+
return main instanceof Element ? makeSuccess(mainClone) : makeSuccess(Cast.toNodeList(safeChildren));
|
1544
|
+
}
|
1545
|
+
});
|
1546
|
+
|
1547
|
+
// src/agnostic/html/hyper-json/smart-tags/coalesced/trim/index.ts
|
1548
|
+
var trim = SmartTags.makeSmartTag({
|
1549
|
+
name: "trim",
|
1550
|
+
defaultMode: "coalescion",
|
1551
|
+
isolationInitType: "array",
|
1552
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "string", "text"),
|
1553
|
+
argsValueCheck: (a) => Utils.SmartTags.expectEmptyArgs(a),
|
1554
|
+
func: (main) => {
|
1555
|
+
return typeof main === "string" ? Outcome.makeSuccess(main.trim()) : Outcome.makeSuccess(Cast.toText(`${main}`.trim()));
|
1556
|
+
}
|
1557
|
+
});
|
1558
|
+
|
1559
|
+
// src/agnostic/html/hyper-json/tree/index.ts
|
1560
|
+
var Tree;
|
1561
|
+
((_Tree) => {
|
1562
|
+
class Tree2 {
|
1563
|
+
node;
|
1564
|
+
options;
|
1565
|
+
parent;
|
1566
|
+
parents;
|
1567
|
+
pathFromParent;
|
1568
|
+
root;
|
1569
|
+
isRoot;
|
1570
|
+
path;
|
1571
|
+
pathString;
|
1572
|
+
attributes;
|
1573
|
+
isMethod;
|
1574
|
+
tagName;
|
1575
|
+
smartTagName;
|
1576
|
+
smartTagsRegister;
|
1577
|
+
smartTagData;
|
1578
|
+
mode;
|
1579
|
+
isPreserved;
|
1580
|
+
isLiteral;
|
1581
|
+
isolationInitType;
|
1582
|
+
subtrees = /* @__PURE__ */ new Map();
|
1583
|
+
static actionAttribute = "_action";
|
1584
|
+
static keyAttribute = "_key";
|
1585
|
+
static methodAttribute = "_method";
|
1586
|
+
static initAttribute = "_init";
|
1587
|
+
static modeAttribute = "_mode";
|
1588
|
+
static preserveAttribute = "_preserve";
|
1589
|
+
static literalAttribute = "_literal";
|
1590
|
+
static defaultOptions = {
|
1591
|
+
globalObject: {},
|
1592
|
+
logger: null,
|
1593
|
+
loggerThread: "hyperjson"
|
1594
|
+
};
|
1595
|
+
static from(nodes, options) {
|
1596
|
+
const merged = Utils.Tree.mergeNodes(nodes);
|
1597
|
+
return new Tree2(merged, null, null, options);
|
1598
|
+
}
|
1599
|
+
constructor(node, parent, pathFromParent, options) {
|
1600
|
+
const { Element: Element2, Text: Text2 } = Window.get();
|
1601
|
+
this.resolve = this.resolve.bind(this);
|
1602
|
+
this.setVariable = this.setVariable.bind(this);
|
1603
|
+
this.getVariable = this.getVariable.bind(this);
|
1604
|
+
this.performSafetyChecks = this.performSafetyChecks.bind(this);
|
1605
|
+
this.computeValue = this.computeValue.bind(this);
|
1606
|
+
this.enforceEvaluation = this.enforceEvaluation.bind(this);
|
1607
|
+
this.getCachedValue = this.getCachedValue.bind(this);
|
1608
|
+
this.setCachedValue = this.setCachedValue.bind(this);
|
1609
|
+
this.getPerformanceData = this.getPerformanceData.bind(this);
|
1610
|
+
this.evaluate = this.evaluate.bind(this);
|
1611
|
+
this.node = node;
|
1612
|
+
this.options = options ?? Tree2.defaultOptions;
|
1613
|
+
if (parent !== null && pathFromParent !== null) {
|
1614
|
+
this.isRoot = false;
|
1615
|
+
this.parent = parent;
|
1616
|
+
this.parents = [parent, ...parent.parents];
|
1617
|
+
this.pathFromParent = pathFromParent;
|
1618
|
+
this.root = this.parent.root;
|
1619
|
+
} else {
|
1620
|
+
this.isRoot = true;
|
1621
|
+
this.parent = null;
|
1622
|
+
this.parents = [];
|
1623
|
+
this.pathFromParent = null;
|
1624
|
+
this.root = this;
|
1625
|
+
}
|
1626
|
+
this.path = this.isRoot ? [] : [...this.parent.path, this.pathFromParent];
|
1627
|
+
this.pathString = `/${this.path.join("/")}`;
|
1628
|
+
this.attributes = node instanceof Element2 ? Array.from(node.attributes) : null;
|
1629
|
+
if (node instanceof Element2) {
|
1630
|
+
const rawTagName = node.tagName.trim().toLowerCase();
|
1631
|
+
const hasTrailingUnderscore = rawTagName.endsWith("_");
|
1632
|
+
const hasMethodAttribute = this.attributes?.find((attr) => attr.name === Tree2.methodAttribute) !== void 0;
|
1633
|
+
const isMethod = hasTrailingUnderscore || hasMethodAttribute;
|
1634
|
+
this.isMethod = isMethod;
|
1635
|
+
this.tagName = rawTagName;
|
1636
|
+
this.smartTagName = hasTrailingUnderscore ? rawTagName.replace(/_+$/g, "") : rawTagName;
|
1637
|
+
} else {
|
1638
|
+
this.isMethod = false;
|
1639
|
+
this.tagName = null;
|
1640
|
+
this.smartTagName = null;
|
1641
|
+
}
|
1642
|
+
this.smartTagsRegister = new Map([
|
1643
|
+
any,
|
1644
|
+
array,
|
1645
|
+
boolean,
|
1646
|
+
element,
|
1647
|
+
get,
|
1648
|
+
global,
|
1649
|
+
guess,
|
1650
|
+
nodelist,
|
1651
|
+
nullFunc,
|
1652
|
+
number,
|
1653
|
+
record,
|
1654
|
+
ref,
|
1655
|
+
string,
|
1656
|
+
text,
|
1657
|
+
add,
|
1658
|
+
addclass,
|
1659
|
+
and,
|
1660
|
+
append,
|
1661
|
+
at,
|
1662
|
+
call,
|
1663
|
+
clone,
|
1664
|
+
deleteproperties,
|
1665
|
+
equals,
|
1666
|
+
getattribute,
|
1667
|
+
getproperties,
|
1668
|
+
getproperty,
|
1669
|
+
ifFunc,
|
1670
|
+
initialize,
|
1671
|
+
join,
|
1672
|
+
length,
|
1673
|
+
map,
|
1674
|
+
negate,
|
1675
|
+
notrailing,
|
1676
|
+
or,
|
1677
|
+
pickrandom,
|
1678
|
+
print,
|
1679
|
+
populate,
|
1680
|
+
push,
|
1681
|
+
pusheach,
|
1682
|
+
recordtoarray,
|
1683
|
+
removeattribute,
|
1684
|
+
removeclass,
|
1685
|
+
renameproperty,
|
1686
|
+
replace,
|
1687
|
+
select,
|
1688
|
+
set,
|
1689
|
+
setattribute,
|
1690
|
+
setproperties,
|
1691
|
+
setproperty,
|
1692
|
+
sorton,
|
1693
|
+
split,
|
1694
|
+
toarray,
|
1695
|
+
toboolean,
|
1696
|
+
toelement,
|
1697
|
+
toggleclass,
|
1698
|
+
tonodelist,
|
1699
|
+
tonull,
|
1700
|
+
tonumber,
|
1701
|
+
toref,
|
1702
|
+
torecord,
|
1703
|
+
tostring,
|
1704
|
+
totext,
|
1705
|
+
transformselected,
|
1706
|
+
trim
|
1707
|
+
]);
|
1708
|
+
if (this.smartTagName === null) {
|
1709
|
+
this.smartTagData = null;
|
1710
|
+
} else {
|
1711
|
+
this.smartTagData = this.smartTagsRegister.get(this.smartTagName) ?? null;
|
1712
|
+
}
|
1713
|
+
const hasModeAttribute = this.attributes?.find((attr) => {
|
1714
|
+
return attr.name === Tree2.modeAttribute && Utils.Tree.TypeChecks.isTreeMode(attr.value);
|
1715
|
+
});
|
1716
|
+
this.mode = hasModeAttribute?.value ?? this.smartTagData?.defaultMode ?? "isolation";
|
1717
|
+
const hasLiteralAttribute = this.attributes?.find((attr) => attr.name === Tree2.literalAttribute) !== void 0;
|
1718
|
+
this.isLiteral = hasLiteralAttribute;
|
1719
|
+
const hasPreservedAttribute = this.attributes?.find((attr) => attr.name === Tree2.preserveAttribute) !== void 0;
|
1720
|
+
this.isPreserved = hasPreservedAttribute;
|
1721
|
+
const hasInitAttribute = this.attributes?.find((attr) => {
|
1722
|
+
if (attr.name !== Tree2.initAttribute) return false;
|
1723
|
+
const val = attr.value.trim().toLowerCase();
|
1724
|
+
if (!Utils.Tree.TypeChecks.isValueTypeName(val)) return false;
|
1725
|
+
if (val === "transformer") return false;
|
1726
|
+
if (val === "method") return false;
|
1727
|
+
return true;
|
1728
|
+
});
|
1729
|
+
if (this.mode === "coalescion") {
|
1730
|
+
this.isolationInitType = "array";
|
1731
|
+
} else {
|
1732
|
+
const initAttributeValue = hasInitAttribute?.value;
|
1733
|
+
if (initAttributeValue !== void 0) {
|
1734
|
+
this.isolationInitType = initAttributeValue;
|
1735
|
+
} else if (this.smartTagData !== null) {
|
1736
|
+
this.isolationInitType = this.smartTagData?.isolationInitType ?? "array";
|
1737
|
+
} else {
|
1738
|
+
this.isolationInitType = "nodelist";
|
1739
|
+
}
|
1740
|
+
}
|
1741
|
+
const { childNodes } = node;
|
1742
|
+
let positionnedChildrenCount = 0;
|
1743
|
+
const mutableSubtrees = /* @__PURE__ */ new Map();
|
1744
|
+
Array.from(childNodes).filter((child, _, childNodes2) => {
|
1745
|
+
if (child instanceof Element2) return true;
|
1746
|
+
if (!(child instanceof Text2)) return false;
|
1747
|
+
const hasContent = (child.textContent ?? "").trim() !== "";
|
1748
|
+
if (hasContent) return true;
|
1749
|
+
if (childNodes2.some((n) => n instanceof Element2)) return false;
|
1750
|
+
return true;
|
1751
|
+
}).forEach((childNode) => {
|
1752
|
+
if (childNode instanceof Text2) {
|
1753
|
+
const hasContent = (childNode.textContent ?? "").trim() !== "";
|
1754
|
+
if (hasContent) {
|
1755
|
+
childNode.textContent = childNode.textContent?.trim() ?? "";
|
1756
|
+
}
|
1757
|
+
mutableSubtrees.set(
|
1758
|
+
positionnedChildrenCount,
|
1759
|
+
new Tree2(childNode, this, positionnedChildrenCount, this.options)
|
1760
|
+
);
|
1761
|
+
positionnedChildrenCount += 1;
|
1762
|
+
} else {
|
1763
|
+
const propertyName = childNode.getAttribute(Tree2.keyAttribute);
|
1764
|
+
if (propertyName === null) {
|
1765
|
+
mutableSubtrees.set(
|
1766
|
+
positionnedChildrenCount,
|
1767
|
+
new Tree2(childNode, this, positionnedChildrenCount, this.options)
|
1768
|
+
);
|
1769
|
+
positionnedChildrenCount += 1;
|
1770
|
+
} else {
|
1771
|
+
mutableSubtrees.set(
|
1772
|
+
propertyName,
|
1773
|
+
new Tree2(childNode, this, propertyName, this.options)
|
1774
|
+
);
|
1775
|
+
}
|
1776
|
+
}
|
1777
|
+
});
|
1778
|
+
this.subtrees = mutableSubtrees;
|
1779
|
+
}
|
1780
|
+
resolve = function(path) {
|
1781
|
+
let currentTree = this;
|
1782
|
+
for (const chunk of path) {
|
1783
|
+
if (chunk === ".") continue;
|
1784
|
+
if (chunk === "..") {
|
1785
|
+
currentTree = currentTree.parent ?? this;
|
1786
|
+
continue;
|
1787
|
+
}
|
1788
|
+
const { subtrees } = currentTree;
|
1789
|
+
const foundSubtree = subtrees.get(chunk);
|
1790
|
+
if (foundSubtree === void 0) return void 0;
|
1791
|
+
currentTree = foundSubtree;
|
1792
|
+
}
|
1793
|
+
return currentTree;
|
1794
|
+
};
|
1795
|
+
// [WIP] variablesStore is actually only used on root Tree
|
1796
|
+
variablesStore = /* @__PURE__ */ new Map();
|
1797
|
+
setVariable(name, value) {
|
1798
|
+
const { root, isRoot, variablesStore } = this;
|
1799
|
+
if (!isRoot) return root.setVariable(name, value);
|
1800
|
+
variablesStore.set(name, Serialize.serialize(value));
|
1801
|
+
}
|
1802
|
+
getVariable(name) {
|
1803
|
+
const { root } = this;
|
1804
|
+
const found = root.variablesStore.get(name);
|
1805
|
+
if (found === void 0) return void 0;
|
1806
|
+
const deserialized = Serialize.deserialize(found);
|
1807
|
+
if (deserialized instanceof Transformer) throw "A transformer should not be stored as a variable, this happening denotes an implementation error.";
|
1808
|
+
return deserialized;
|
1809
|
+
}
|
1810
|
+
performSafetyChecks() {
|
1811
|
+
const { node, smartTagData, isMethod, mode, isRoot } = this;
|
1812
|
+
const { Text: Text2 } = Window.get();
|
1813
|
+
if (node instanceof Text2 || smartTagData === null) {
|
1814
|
+
if (isMethod) throw new Error(`A Text or HTMLElement node cannot be used as a method @ ${this.pathString}`);
|
1815
|
+
if (mode === "coalescion") throw new Error(`A Text or HTMLElement node cannot be used in coalescion mode @ ${this.pathString}`);
|
1816
|
+
}
|
1817
|
+
if (isRoot && mode === "coalescion") throw new Error(`The root node cannot be used in coalescion mode @ ${this.pathString}`);
|
1818
|
+
}
|
1819
|
+
computeValue() {
|
1820
|
+
const {
|
1821
|
+
isolationInitType,
|
1822
|
+
subtrees,
|
1823
|
+
node,
|
1824
|
+
smartTagData,
|
1825
|
+
isMethod,
|
1826
|
+
mode,
|
1827
|
+
performSafetyChecks
|
1828
|
+
} = this;
|
1829
|
+
performSafetyChecks();
|
1830
|
+
const { Text: Text2 } = Window.get();
|
1831
|
+
if (node instanceof Text2) return node.cloneNode(true);
|
1832
|
+
const initialInnerValue = Utils.Tree.getInitialValueFromTypeName(isolationInitType);
|
1833
|
+
const innerValue = Array.from(subtrees).reduce((reduced, [subpath, subtree]) => {
|
1834
|
+
const subvalue = subtree.evaluate();
|
1835
|
+
const coalesced = Utils.coalesceValues(reduced, subpath, subvalue);
|
1836
|
+
return coalesced;
|
1837
|
+
}, initialInnerValue);
|
1838
|
+
if (smartTagData === null) {
|
1839
|
+
const nodelist2 = Cast.toNodeList(innerValue);
|
1840
|
+
const clone2 = node.cloneNode();
|
1841
|
+
clone2.append(...Array.from(nodelist2));
|
1842
|
+
return clone2;
|
1843
|
+
}
|
1844
|
+
const { transformer, method } = smartTagData.generator(innerValue, mode, this);
|
1845
|
+
if (isMethod) return method;
|
1846
|
+
if (mode === "isolation") {
|
1847
|
+
const applied = transformer.apply(null);
|
1848
|
+
if (applied.success) return applied.payload;
|
1849
|
+
throw {
|
1850
|
+
error: "Transformation error",
|
1851
|
+
details: applied.error,
|
1852
|
+
transformer: transformer.name,
|
1853
|
+
path: this.pathString
|
1854
|
+
};
|
1855
|
+
}
|
1856
|
+
return transformer;
|
1857
|
+
}
|
1858
|
+
enforceEvaluation() {
|
1859
|
+
const { isPreserved, node, computeValue, isLiteral, attributes } = this;
|
1860
|
+
const { Element: Element2 } = Window.get();
|
1861
|
+
if (isPreserved) return Utils.clone(node);
|
1862
|
+
const evaluated = computeValue();
|
1863
|
+
if (!isLiteral) return evaluated;
|
1864
|
+
const asLiteral = Utils.toHyperJson(evaluated);
|
1865
|
+
if (asLiteral instanceof Element2) attributes?.forEach(({ name, value }) => asLiteral.setAttribute(name, value));
|
1866
|
+
return asLiteral;
|
1867
|
+
}
|
1868
|
+
cachedValue = void 0;
|
1869
|
+
getCachedValue() {
|
1870
|
+
const { cachedValue } = this;
|
1871
|
+
if (cachedValue === void 0) return void 0;
|
1872
|
+
const deserialized = Serialize.deserialize(cachedValue);
|
1873
|
+
return deserialized;
|
1874
|
+
}
|
1875
|
+
setCachedValue(evaluated) {
|
1876
|
+
this.cachedValue = Serialize.serialize(evaluated);
|
1877
|
+
}
|
1878
|
+
perfCounters = {
|
1879
|
+
evaluations: 0,
|
1880
|
+
computeTime: 0,
|
1881
|
+
computeTimeAvg: 0,
|
1882
|
+
cached: 0,
|
1883
|
+
cacheTime: 0,
|
1884
|
+
cacheTimeAvg: 0,
|
1885
|
+
totalTime: 0
|
1886
|
+
};
|
1887
|
+
// [WIP] bind this
|
1888
|
+
getPerformanceData() {
|
1889
|
+
const { subtrees, cachedValue, tagName, perfCounters } = this;
|
1890
|
+
const subCounters = [];
|
1891
|
+
subCounters.push([this.pathString, {
|
1892
|
+
...perfCounters,
|
1893
|
+
tagName: tagName ?? "#text",
|
1894
|
+
evaluated: cachedValue
|
1895
|
+
}]);
|
1896
|
+
subtrees.forEach((subtree) => subCounters.push(...subtree.getPerformanceData()));
|
1897
|
+
return subCounters.sort((a, b) => {
|
1898
|
+
const aCalls = a[1].evaluations + a[1].cached;
|
1899
|
+
const bCalls = b[1].evaluations + b[1].cached;
|
1900
|
+
return bCalls - aCalls;
|
1901
|
+
});
|
1902
|
+
}
|
1903
|
+
evaluate() {
|
1904
|
+
const start = Date.now();
|
1905
|
+
const {
|
1906
|
+
getCachedValue,
|
1907
|
+
setCachedValue,
|
1908
|
+
enforceEvaluation,
|
1909
|
+
perfCounters
|
1910
|
+
} = this;
|
1911
|
+
const cached = getCachedValue();
|
1912
|
+
if (cached !== void 0) {
|
1913
|
+
const end2 = Date.now();
|
1914
|
+
const time2 = end2 - start;
|
1915
|
+
perfCounters.cached++;
|
1916
|
+
perfCounters.cacheTime += time2;
|
1917
|
+
perfCounters.cacheTimeAvg = perfCounters.cacheTime / perfCounters.cached;
|
1918
|
+
perfCounters.totalTime = perfCounters.computeTime + perfCounters.cacheTime;
|
1919
|
+
return cached;
|
1920
|
+
}
|
1921
|
+
const evaluated = enforceEvaluation();
|
1922
|
+
setCachedValue(evaluated);
|
1923
|
+
const end = Date.now();
|
1924
|
+
const time = end - start;
|
1925
|
+
perfCounters.evaluations++;
|
1926
|
+
perfCounters.computeTime += time;
|
1927
|
+
perfCounters.computeTimeAvg = perfCounters.computeTime / perfCounters.evaluations;
|
1928
|
+
perfCounters.totalTime = perfCounters.computeTime + perfCounters.cacheTime;
|
1929
|
+
return evaluated;
|
1930
|
+
}
|
1931
|
+
}
|
1932
|
+
_Tree.Tree = Tree2;
|
1933
|
+
})(Tree || (Tree = {}));
|
1934
|
+
|
1935
|
+
// src/agnostic/html/hyper-json/utils/index.ts
|
1936
|
+
var Utils;
|
1937
|
+
((Utils2) => {
|
1938
|
+
function clone2(value) {
|
1939
|
+
const { Element: Element2, Text: Text2, NodeList, document: document2 } = Window.get();
|
1940
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || value === null) return value;
|
1941
|
+
if (value instanceof Text2) return value.cloneNode(true);
|
1942
|
+
if (value instanceof NodeList) {
|
1943
|
+
const frag = document2.createDocumentFragment();
|
1944
|
+
const nodes = Array.from(value).map((e) => e.cloneNode(true));
|
1945
|
+
frag.append(...nodes);
|
1946
|
+
return frag.childNodes;
|
1947
|
+
}
|
1948
|
+
if (value instanceof Element2) return value.cloneNode(true);
|
1949
|
+
if (value instanceof Transformer) return Transformer.clone(value);
|
1950
|
+
if (value instanceof Method) return Method.clone(value);
|
1951
|
+
if (Array.isArray(value)) return [...value.map(clone2)];
|
1952
|
+
if (isRecord(value)) return recordMap(value, (prop) => clone2(prop));
|
1953
|
+
throw new Error(`Cannot clone value: ${value}`);
|
1954
|
+
}
|
1955
|
+
Utils2.clone = clone2;
|
1956
|
+
function coalesceValues(currentValue, subpath, subvalue) {
|
1957
|
+
const { Element: Element2, Text: Text2, NodeList, document: document2 } = Window.get();
|
1958
|
+
let actualSubvalue = subvalue;
|
1959
|
+
if (actualSubvalue instanceof Transformer) {
|
1960
|
+
const transformer = actualSubvalue;
|
1961
|
+
const transformationResult = transformer.apply(currentValue);
|
1962
|
+
if (!transformationResult.success) {
|
1963
|
+
console.warn({ ...transformationResult.error });
|
1964
|
+
return currentValue;
|
1965
|
+
}
|
1966
|
+
const evaluated = transformationResult.payload;
|
1967
|
+
if (transformer.mode === "isolation") {
|
1968
|
+
actualSubvalue = evaluated;
|
1969
|
+
} else {
|
1970
|
+
return evaluated;
|
1971
|
+
}
|
1972
|
+
}
|
1973
|
+
if (Array.isArray(currentValue)) return [...currentValue, actualSubvalue];
|
1974
|
+
if (currentValue === null) return actualSubvalue;
|
1975
|
+
if (typeof currentValue === "boolean") return actualSubvalue;
|
1976
|
+
if (typeof currentValue === "number") return actualSubvalue;
|
1977
|
+
if (currentValue instanceof Transformer) return actualSubvalue;
|
1978
|
+
if (currentValue instanceof Method) return actualSubvalue;
|
1979
|
+
if (typeof currentValue === "string") {
|
1980
|
+
if (actualSubvalue === null || typeof actualSubvalue === "boolean" || typeof actualSubvalue === "number" || typeof actualSubvalue === "string") return `${currentValue}${actualSubvalue}`;
|
1981
|
+
if (actualSubvalue instanceof Text2) return `${currentValue}${actualSubvalue.textContent}`;
|
1982
|
+
if (actualSubvalue instanceof Element2) {
|
1983
|
+
const frag = document2.createDocumentFragment();
|
1984
|
+
frag.append(currentValue, Utils2.clone(actualSubvalue));
|
1985
|
+
return frag.childNodes;
|
1986
|
+
}
|
1987
|
+
if (actualSubvalue instanceof NodeList) {
|
1988
|
+
const frag = document2.createDocumentFragment();
|
1989
|
+
frag.append(currentValue, ...Array.from(Utils2.clone(actualSubvalue)));
|
1990
|
+
return frag.childNodes;
|
1991
|
+
}
|
1992
|
+
return actualSubvalue;
|
1993
|
+
}
|
1994
|
+
if (currentValue instanceof Text2) {
|
1995
|
+
if (actualSubvalue === null || typeof actualSubvalue === "boolean" || typeof actualSubvalue === "number" || typeof actualSubvalue === "string") return document2.createTextNode(`${currentValue.textContent}${actualSubvalue}`);
|
1996
|
+
if (actualSubvalue instanceof Text2) return document2.createTextNode(`${currentValue.textContent}${actualSubvalue.textContent}`);
|
1997
|
+
if (actualSubvalue instanceof Element2) {
|
1998
|
+
const frag = document2.createDocumentFragment();
|
1999
|
+
frag.append(clone2(currentValue), clone2(actualSubvalue));
|
2000
|
+
return frag.childNodes;
|
2001
|
+
}
|
2002
|
+
if (actualSubvalue instanceof NodeList) {
|
2003
|
+
const frag = document2.createDocumentFragment();
|
2004
|
+
frag.append(clone2(currentValue), ...Array.from(clone2(actualSubvalue)));
|
2005
|
+
return frag.childNodes;
|
2006
|
+
}
|
2007
|
+
return actualSubvalue;
|
2008
|
+
}
|
2009
|
+
if (currentValue instanceof Element2) {
|
2010
|
+
if (actualSubvalue === null || typeof actualSubvalue === "boolean" || typeof actualSubvalue === "number" || typeof actualSubvalue === "string") {
|
2011
|
+
const frag = document2.createDocumentFragment();
|
2012
|
+
frag.append(clone2(currentValue), `${actualSubvalue}`);
|
2013
|
+
return frag.childNodes;
|
2014
|
+
}
|
2015
|
+
if (actualSubvalue instanceof Text2 || actualSubvalue instanceof Element2) {
|
2016
|
+
const frag = document2.createDocumentFragment();
|
2017
|
+
frag.append(clone2(currentValue), clone2(actualSubvalue));
|
2018
|
+
return frag.childNodes;
|
2019
|
+
}
|
2020
|
+
if (actualSubvalue instanceof NodeList) {
|
2021
|
+
const frag = document2.createDocumentFragment();
|
2022
|
+
frag.append(clone2(currentValue), ...Array.from(clone2(actualSubvalue)));
|
2023
|
+
return frag.childNodes;
|
2024
|
+
}
|
2025
|
+
return actualSubvalue;
|
2026
|
+
}
|
2027
|
+
if (currentValue instanceof NodeList) {
|
2028
|
+
if (actualSubvalue === null || typeof actualSubvalue === "boolean" || typeof actualSubvalue === "number" || typeof actualSubvalue === "string") {
|
2029
|
+
const frag = document2.createDocumentFragment();
|
2030
|
+
frag.append(...Array.from(clone2(currentValue)), `${actualSubvalue}`);
|
2031
|
+
return frag.childNodes;
|
2032
|
+
}
|
2033
|
+
if (actualSubvalue instanceof Text2 || actualSubvalue instanceof Element2) {
|
2034
|
+
const frag = document2.createDocumentFragment();
|
2035
|
+
frag.append(...Array.from(clone2(currentValue)), clone2(actualSubvalue));
|
2036
|
+
return frag.childNodes;
|
2037
|
+
}
|
2038
|
+
if (actualSubvalue instanceof NodeList) {
|
2039
|
+
const frag = document2.createDocumentFragment();
|
2040
|
+
frag.append(...Array.from(clone2(currentValue)), ...Array.from(clone2(actualSubvalue)));
|
2041
|
+
return frag.childNodes;
|
2042
|
+
}
|
2043
|
+
return actualSubvalue;
|
2044
|
+
}
|
2045
|
+
if (typeof subpath === "number") return { ...currentValue };
|
2046
|
+
return {
|
2047
|
+
...currentValue,
|
2048
|
+
[subpath]: actualSubvalue
|
2049
|
+
};
|
2050
|
+
}
|
2051
|
+
Utils2.coalesceValues = coalesceValues;
|
2052
|
+
Utils2.toHyperJson = (value) => {
|
2053
|
+
const { document: document2, Element: Element2, Text: Text2, NodeList } = Window.get();
|
2054
|
+
if (value instanceof Text2) {
|
2055
|
+
const elt2 = document2.createElement("text");
|
2056
|
+
elt2.innerHTML = value.textContent ?? "";
|
2057
|
+
return elt2;
|
2058
|
+
}
|
2059
|
+
if (value instanceof Element2) return value.cloneNode(true);
|
2060
|
+
if (value instanceof NodeList) {
|
2061
|
+
const elt2 = document2.createElement("nodelist");
|
2062
|
+
elt2.append(...Array.from(value).map((e) => e.cloneNode(true)));
|
2063
|
+
return elt2;
|
2064
|
+
}
|
2065
|
+
if (value === null) return document2.createElement("null");
|
2066
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
2067
|
+
const elt2 = document2.createElement(typeof value);
|
2068
|
+
elt2.innerHTML = `${value}`;
|
2069
|
+
return elt2;
|
2070
|
+
}
|
2071
|
+
if (Array.isArray(value)) {
|
2072
|
+
const elt2 = document2.createElement("array");
|
2073
|
+
elt2.append(...value.map((e) => (0, Utils2.toHyperJson)(e)));
|
2074
|
+
return elt2;
|
2075
|
+
}
|
2076
|
+
if (value instanceof Transformer) return clone2(value.sourceTree.node);
|
2077
|
+
if (value instanceof Method) return clone2(value.transformer.sourceTree.node);
|
2078
|
+
const elt = document2.createElement("record");
|
2079
|
+
Object.entries(value).forEach(([key, val]) => {
|
2080
|
+
const hjVal = (0, Utils2.toHyperJson)(val);
|
2081
|
+
if (hjVal instanceof Text2) return;
|
2082
|
+
hjVal.setAttribute(Tree.Tree.keyAttribute, key);
|
2083
|
+
elt.append(hjVal);
|
2084
|
+
});
|
2085
|
+
return elt;
|
2086
|
+
};
|
2087
|
+
let Transformations;
|
2088
|
+
((Transformations2) => {
|
2089
|
+
let TypeChecks;
|
2090
|
+
((TypeChecks2) => {
|
2091
|
+
function getType(value) {
|
2092
|
+
if (singleTypeCheck(value, "null")) return "null";
|
2093
|
+
if (singleTypeCheck(value, "boolean")) return "boolean";
|
2094
|
+
if (singleTypeCheck(value, "number")) return "number";
|
2095
|
+
if (singleTypeCheck(value, "string")) return "string";
|
2096
|
+
if (singleTypeCheck(value, "element")) return "element";
|
2097
|
+
if (singleTypeCheck(value, "text")) return "text";
|
2098
|
+
if (singleTypeCheck(value, "nodelist")) return "nodelist";
|
2099
|
+
if (singleTypeCheck(value, "method")) return "method";
|
2100
|
+
if (singleTypeCheck(value, "array")) return "array";
|
2101
|
+
if (singleTypeCheck(value, "record")) return "record";
|
2102
|
+
return void 0;
|
2103
|
+
}
|
2104
|
+
TypeChecks2.getType = getType;
|
2105
|
+
TypeChecks2.everyTypeName = [
|
2106
|
+
"null",
|
2107
|
+
"boolean",
|
2108
|
+
"number",
|
2109
|
+
"string",
|
2110
|
+
"text",
|
2111
|
+
"nodelist",
|
2112
|
+
"element",
|
2113
|
+
"method",
|
2114
|
+
"array",
|
2115
|
+
"record"
|
2116
|
+
];
|
2117
|
+
function singleTypeCheck(value, type) {
|
2118
|
+
const { Element: Element2, Text: Text2, NodeList } = Window.get();
|
2119
|
+
if (type === "null" && value === null) return true;
|
2120
|
+
if (type === "boolean" && typeof value === "boolean") return true;
|
2121
|
+
if (type === "number" && typeof value === "number") return true;
|
2122
|
+
if (type === "string" && typeof value === "string") return true;
|
2123
|
+
if (type === "element" && value instanceof Element2) return true;
|
2124
|
+
if (type === "text" && value instanceof Text2) return true;
|
2125
|
+
if (type === "nodelist" && value instanceof NodeList) {
|
2126
|
+
const children = Array.from(value);
|
2127
|
+
return children.every((child) => child instanceof Element2 || child instanceof Text2);
|
2128
|
+
}
|
2129
|
+
if (type === "method" && value instanceof Method) return true;
|
2130
|
+
if (type === "array" && Array.isArray(value)) {
|
2131
|
+
const childrenOk = value.every((child) => typeCheck(child, ...TypeChecks2.everyTypeName).success);
|
2132
|
+
return childrenOk;
|
2133
|
+
}
|
2134
|
+
if (type === "record" && isRecord(value)) {
|
2135
|
+
const childrenOk = Object.values(value).every((child) => typeCheck(child, ...TypeChecks2.everyTypeName).success);
|
2136
|
+
return childrenOk;
|
2137
|
+
}
|
2138
|
+
return false;
|
2139
|
+
}
|
2140
|
+
TypeChecks2.singleTypeCheck = singleTypeCheck;
|
2141
|
+
function typeCheck(value, ...types) {
|
2142
|
+
const matchesOneType = types.some((type) => singleTypeCheck(value, type));
|
2143
|
+
if (matchesOneType) return Outcome.makeSuccess(value);
|
2144
|
+
return Outcome.makeFailure({
|
2145
|
+
expected: types.join(" | "),
|
2146
|
+
found: getType(value) ?? "undefined"
|
2147
|
+
});
|
2148
|
+
}
|
2149
|
+
TypeChecks2.typeCheck = typeCheck;
|
2150
|
+
function typeCheckMany(values, ...types) {
|
2151
|
+
for (const [pos, val] of Object.entries(values)) {
|
2152
|
+
const checked = typeCheck(val, ...types);
|
2153
|
+
if (checked.success) continue;
|
2154
|
+
return Outcome.makeFailure({ position: parseInt(pos), ...checked.error });
|
2155
|
+
}
|
2156
|
+
return Outcome.makeSuccess(values);
|
2157
|
+
}
|
2158
|
+
TypeChecks2.typeCheckMany = typeCheckMany;
|
2159
|
+
})(TypeChecks = Transformations2.TypeChecks || (Transformations2.TypeChecks = {}));
|
2160
|
+
})(Transformations = Utils2.Transformations || (Utils2.Transformations = {}));
|
2161
|
+
let Tree2;
|
2162
|
+
((Tree3) => {
|
2163
|
+
function mergeNodes(nodes) {
|
2164
|
+
const clones = nodes.map((node) => node.cloneNode(true));
|
2165
|
+
const allChildren = [];
|
2166
|
+
clones.forEach((node) => {
|
2167
|
+
const actionAttribute = node.getAttribute(Tree.Tree.actionAttribute)?.trim().toLowerCase();
|
2168
|
+
const actionAttrIsValid = isInEnum(Types.Tree.Merge.Action, actionAttribute ?? "");
|
2169
|
+
const nodeAction = actionAttrIsValid ? actionAttribute : Types.Tree.Merge.Action.APPEND;
|
2170
|
+
const { Element: Element2, Text: Text2 } = Window.get();
|
2171
|
+
const children = Array.from(node.childNodes).filter((child) => child instanceof Text2 || child instanceof Element2).map((child) => {
|
2172
|
+
if (child instanceof Text2) return { node: child, key: void 0 };
|
2173
|
+
const childKey = child.getAttribute(Tree.Tree.keyAttribute) ?? void 0;
|
2174
|
+
return { node: child, key: childKey };
|
2175
|
+
});
|
2176
|
+
if (nodeAction === Types.Tree.Merge.Action.REPLACE) {
|
2177
|
+
allChildren.splice(0, allChildren.length);
|
2178
|
+
} else if (nodeAction === Types.Tree.Merge.Action.PREPEND) {
|
2179
|
+
allChildren.unshift(...children);
|
2180
|
+
} else {
|
2181
|
+
allChildren.push(...children);
|
2182
|
+
}
|
2183
|
+
});
|
2184
|
+
const mergedChildren = [];
|
2185
|
+
allChildren.forEach((childData) => {
|
2186
|
+
if (childData.key === void 0) mergedChildren.push(childData);
|
2187
|
+
else {
|
2188
|
+
const childKey = childData.key;
|
2189
|
+
const alreadyMerged = mergedChildren.find((dat) => dat.key === childKey);
|
2190
|
+
if (alreadyMerged) return;
|
2191
|
+
const toMerge = allChildren.filter((dat) => dat.key === childKey);
|
2192
|
+
if (toMerge.length === 0) return;
|
2193
|
+
const merged = mergeNodes(toMerge.map((dat) => dat.node));
|
2194
|
+
mergedChildren.push({ node: merged, key: childKey });
|
2195
|
+
}
|
2196
|
+
});
|
2197
|
+
const allAttributes = clones.reduce((attributes, node) => [
|
2198
|
+
...Array.from(attributes),
|
2199
|
+
...Array.from(node.attributes)
|
2200
|
+
], []);
|
2201
|
+
const outWrapper = clones[0]?.cloneNode() ?? document.createElement("div");
|
2202
|
+
allAttributes.forEach((attr) => outWrapper.setAttribute(attr.name, attr.value));
|
2203
|
+
outWrapper.append(...mergedChildren.map((e) => e.node));
|
2204
|
+
return outWrapper;
|
2205
|
+
}
|
2206
|
+
Tree3.mergeNodes = mergeNodes;
|
2207
|
+
function getInitialValueFromTypeName(name) {
|
2208
|
+
const { document: document2 } = Window.get();
|
2209
|
+
if (name === "null") return null;
|
2210
|
+
if (name === "boolean") return false;
|
2211
|
+
if (name === "number") return 0;
|
2212
|
+
if (name === "string") return "";
|
2213
|
+
if (name === "text") return document2.createTextNode("");
|
2214
|
+
if (name === "nodelist") return document2.createDocumentFragment().childNodes;
|
2215
|
+
if (name === "element") return document2.createElement("div");
|
2216
|
+
if (name === "array") return [];
|
2217
|
+
if (name === "record") return {};
|
2218
|
+
throw new Error(`Unknown value type name: ${name}`);
|
2219
|
+
}
|
2220
|
+
Tree3.getInitialValueFromTypeName = getInitialValueFromTypeName;
|
2221
|
+
let TypeChecks;
|
2222
|
+
((TypeChecks2) => {
|
2223
|
+
function getType(value) {
|
2224
|
+
if (singleTypeCheck(value, "null")) return "null";
|
2225
|
+
if (singleTypeCheck(value, "boolean")) return "boolean";
|
2226
|
+
if (singleTypeCheck(value, "number")) return "number";
|
2227
|
+
if (singleTypeCheck(value, "string")) return "string";
|
2228
|
+
if (singleTypeCheck(value, "element")) return "element";
|
2229
|
+
if (singleTypeCheck(value, "text")) return "text";
|
2230
|
+
if (singleTypeCheck(value, "nodelist")) return "nodelist";
|
2231
|
+
if (singleTypeCheck(value, "transformer")) return "transformer";
|
2232
|
+
if (singleTypeCheck(value, "method")) return "method";
|
2233
|
+
if (singleTypeCheck(value, "array")) return "array";
|
2234
|
+
if (singleTypeCheck(value, "record")) return "record";
|
2235
|
+
return void 0;
|
2236
|
+
}
|
2237
|
+
TypeChecks2.getType = getType;
|
2238
|
+
TypeChecks2.everyTypeName = [
|
2239
|
+
"null",
|
2240
|
+
"boolean",
|
2241
|
+
"number",
|
2242
|
+
"string",
|
2243
|
+
"text",
|
2244
|
+
"nodelist",
|
2245
|
+
"element",
|
2246
|
+
"transformer",
|
2247
|
+
"method",
|
2248
|
+
"array",
|
2249
|
+
"record"
|
2250
|
+
];
|
2251
|
+
function singleTypeCheck(value, type) {
|
2252
|
+
const { Element: Element2, Text: Text2, NodeList } = Window.get();
|
2253
|
+
if (type === "null" && value === null) return true;
|
2254
|
+
if (type === "boolean" && typeof value === "boolean") return true;
|
2255
|
+
if (type === "number" && typeof value === "number") return true;
|
2256
|
+
if (type === "string" && typeof value === "string") return true;
|
2257
|
+
if (type === "element" && value instanceof Element2) return true;
|
2258
|
+
if (type === "text" && value instanceof Text2) return true;
|
2259
|
+
if (type === "nodelist" && value instanceof NodeList) {
|
2260
|
+
const children = Array.from(value);
|
2261
|
+
return children.every((child) => child instanceof Element2 || child instanceof Text2);
|
2262
|
+
}
|
2263
|
+
if (type === "transformer" && value instanceof Transformer) return true;
|
2264
|
+
if (type === "method" && value instanceof Method) return true;
|
2265
|
+
if (type === "array" && Array.isArray(value)) {
|
2266
|
+
const childrenOk = value.every((child) => typeCheck(child, ...TypeChecks2.everyTypeName).success);
|
2267
|
+
return childrenOk;
|
2268
|
+
}
|
2269
|
+
if (type === "record" && isRecord(value)) {
|
2270
|
+
const childrenOk = Object.values(value).every((child) => typeCheck(child, ...TypeChecks2.everyTypeName).success);
|
2271
|
+
return childrenOk;
|
2272
|
+
}
|
2273
|
+
return false;
|
2274
|
+
}
|
2275
|
+
TypeChecks2.singleTypeCheck = singleTypeCheck;
|
2276
|
+
function typeCheck(value, ...types) {
|
2277
|
+
const matchesOneType = types.some((type) => singleTypeCheck(value, type));
|
2278
|
+
if (matchesOneType) return Outcome.makeSuccess(value);
|
2279
|
+
return Outcome.makeFailure({
|
2280
|
+
expected: types.join(" | "),
|
2281
|
+
found: getType(value) ?? "undefined"
|
2282
|
+
});
|
2283
|
+
}
|
2284
|
+
TypeChecks2.typeCheck = typeCheck;
|
2285
|
+
function typeCheckMany(values, ...types) {
|
2286
|
+
for (const [pos, val] of Object.entries(values)) {
|
2287
|
+
const checked = typeCheck(val, ...types);
|
2288
|
+
if (checked.success) continue;
|
2289
|
+
return Outcome.makeFailure({ position: parseInt(pos), ...checked.error });
|
2290
|
+
}
|
2291
|
+
return Outcome.makeSuccess(values);
|
2292
|
+
}
|
2293
|
+
TypeChecks2.typeCheckMany = typeCheckMany;
|
2294
|
+
TypeChecks2.isTreeMode = (name) => name === "isolation" || name === "coalescion";
|
2295
|
+
TypeChecks2.isValueTypeName = (name) => {
|
2296
|
+
const list = [
|
2297
|
+
"null",
|
2298
|
+
"boolean",
|
2299
|
+
"number",
|
2300
|
+
"string",
|
2301
|
+
"text",
|
2302
|
+
"nodelist",
|
2303
|
+
"element",
|
2304
|
+
"transformer",
|
2305
|
+
"method",
|
2306
|
+
"array",
|
2307
|
+
"record"
|
2308
|
+
];
|
2309
|
+
return list.includes(name);
|
2310
|
+
};
|
2311
|
+
})(TypeChecks = Tree3.TypeChecks || (Tree3.TypeChecks = {}));
|
2312
|
+
})(Tree2 = Utils2.Tree || (Utils2.Tree = {}));
|
2313
|
+
let SmartTags2;
|
2314
|
+
((SmartTags3) => {
|
2315
|
+
SmartTags3.expectEmptyArgs = (args) => {
|
2316
|
+
if (args.length === 0) return Outcome.makeSuccess([]);
|
2317
|
+
return Outcome.makeFailure({
|
2318
|
+
expected: "length: 0",
|
2319
|
+
found: `length: ${args.length}`
|
2320
|
+
});
|
2321
|
+
};
|
2322
|
+
SmartTags3.makeMainValueError = (expected, found, details) => ({ expected, found, details });
|
2323
|
+
SmartTags3.makeArgsValueError = (expected, found, position, details) => ({ expected, found, position, details });
|
2324
|
+
SmartTags3.makeTransformationError = (details) => ({ details });
|
2325
|
+
})(SmartTags2 = Utils2.SmartTags || (Utils2.SmartTags = {}));
|
2326
|
+
})(Utils || (Utils = {}));
|
2327
|
+
|
2328
|
+
// src/agnostic/html/hyper-json/smart-tags/isolated/boolean/index.ts
|
2329
|
+
var boolean = SmartTags.makeSmartTag({
|
2330
|
+
name: "boolean",
|
2331
|
+
defaultMode: "isolation",
|
2332
|
+
isolationInitType: "boolean",
|
2333
|
+
mainValueCheck: (m) => Utils.Tree.TypeChecks.typeCheck(m, "null", "boolean", "number", "string", "text"),
|
2334
|
+
argsValueCheck: (a) => Utils.Tree.TypeChecks.typeCheckMany(a, "null", "boolean", "number", "string", "text"),
|
2335
|
+
func: (main, args) => Outcome.makeSuccess([main, ...args].every((item) => Cast.toBoolean(item)))
|
2336
|
+
});
|
2337
|
+
|
2338
|
+
export {
|
2339
|
+
boolean,
|
2340
|
+
element,
|
2341
|
+
get,
|
2342
|
+
global,
|
2343
|
+
guess,
|
2344
|
+
nodelist,
|
2345
|
+
number,
|
2346
|
+
record,
|
2347
|
+
func,
|
2348
|
+
ref,
|
2349
|
+
string,
|
2350
|
+
text,
|
2351
|
+
add,
|
2352
|
+
addclass,
|
2353
|
+
and,
|
2354
|
+
append,
|
2355
|
+
at,
|
2356
|
+
call,
|
2357
|
+
clone,
|
2358
|
+
deleteproperties,
|
2359
|
+
equals,
|
2360
|
+
getattribute,
|
2361
|
+
getproperties,
|
2362
|
+
getproperty,
|
2363
|
+
deepGetProperty,
|
2364
|
+
ifFunc,
|
2365
|
+
initialize,
|
2366
|
+
join,
|
2367
|
+
length,
|
2368
|
+
map,
|
2369
|
+
negate,
|
2370
|
+
notrailing,
|
2371
|
+
or,
|
2372
|
+
pickrandom,
|
2373
|
+
print,
|
2374
|
+
populate,
|
2375
|
+
push,
|
2376
|
+
pusheach,
|
2377
|
+
recordtoarray,
|
2378
|
+
removeattribute,
|
2379
|
+
removeclass,
|
2380
|
+
renameproperty,
|
2381
|
+
replace,
|
2382
|
+
select,
|
2383
|
+
set,
|
2384
|
+
setattribute,
|
2385
|
+
setproperties,
|
2386
|
+
setproperty,
|
2387
|
+
sorton,
|
2388
|
+
split,
|
2389
|
+
toarray,
|
2390
|
+
toboolean,
|
2391
|
+
toelement,
|
2392
|
+
toggleclass,
|
2393
|
+
tonodelist,
|
2394
|
+
tonull,
|
2395
|
+
tonumber,
|
2396
|
+
torecord,
|
2397
|
+
toref,
|
2398
|
+
tostring,
|
2399
|
+
totext,
|
2400
|
+
transformselected,
|
2401
|
+
trim,
|
2402
|
+
Tree,
|
2403
|
+
Utils,
|
2404
|
+
Cast
|
2405
|
+
};
|