@design-edito/tools 0.1.29 → 0.1.31
Sign up to get free protection for your applications and to get access to all the features.
- package/agnostic/css/index.js +5 -4
- package/agnostic/html/get-node-ancestors/index.d.ts +1 -1
- package/agnostic/html/get-node-ancestors/index.js +1 -1
- package/agnostic/html/hyper-json/cast/index.js +3 -3
- package/agnostic/html/hyper-json/index.d.ts +0 -2
- package/agnostic/html/hyper-json/index.js +4 -4
- package/agnostic/html/hyper-json/serialize/index.js +2 -2
- package/agnostic/html/hyper-json/transformers/append/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/classList/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/join/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/length/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/print/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/push/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/querySelector/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/ref/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/replace/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/split/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/toArray/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/toBoolean/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/toElement/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/toNodeList/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/toNull/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/toNumber/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/toRecord/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/toRef/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/toString/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/toText/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/toTransformer/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/transformSelected/index.js +3 -3
- package/agnostic/html/hyper-json/transformers/trim/index.js +3 -3
- package/agnostic/html/hyper-json/tree/index.js +3 -3
- package/agnostic/html/hyper-json/utils/index.js +3 -3
- package/agnostic/html/index.js +18 -18
- package/agnostic/html/sanitize/index.js +6 -5
- package/agnostic/html/selector-to-element/index.js +6 -5
- package/agnostic/html/string-to-nodes/index.js +7 -6
- package/agnostic/misc/cast/index.d.ts +1 -0
- package/agnostic/misc/cast/index.js +1 -1
- package/agnostic/misc/crossenv/detect-runtime/index.d.ts +2 -0
- package/agnostic/misc/crossenv/detect-runtime/index.js +7 -0
- package/agnostic/misc/crossenv/index.d.ts +6 -14
- package/agnostic/misc/crossenv/index.js +4 -3
- package/agnostic/misc/crossenv/types/index.d.ts +19 -0
- package/agnostic/misc/crossenv/types/index.js +6 -0
- package/agnostic/misc/crossenv/window/index.d.ts +7 -0
- package/agnostic/misc/crossenv/window/index.js +6 -0
- package/agnostic/misc/index.js +11 -10
- package/agnostic/misc/lorem-ipsum/index.js +2 -2
- package/agnostic/numbers/index.js +5 -5
- package/agnostic/numbers/interpolate/index.d.ts +1 -0
- package/agnostic/numbers/interpolate/index.js +3 -1
- package/agnostic/objects/flatten-getters/index.js +2 -2
- package/agnostic/objects/index.d.ts +2 -0
- package/agnostic/objects/index.js +10 -6
- package/agnostic/objects/record-format/index.d.ts +1 -1
- package/agnostic/objects/record-format/index.js +4 -14
- package/agnostic/optim/index.js +3 -3
- package/agnostic/strings/index.js +5 -5
- package/agnostic/time/index.js +3 -3
- package/chunks/chunk-BJAYUP7M.js +13 -0
- package/chunks/chunk-BQV4DOSE.js +1108 -0
- package/chunks/chunk-BVCWBTHQ.js +35 -0
- package/chunks/chunk-C5753KUP.js +127 -0
- package/chunks/chunk-CAMYGA44.js +22 -0
- package/chunks/chunk-CB52KVOZ.js +22 -0
- package/chunks/chunk-EVOTJ7SU.js +35 -0
- package/chunks/chunk-FR5H2OCV.js +21 -0
- package/chunks/chunk-G2NZXHW6.js +21 -0
- package/chunks/chunk-GPWFYPER.js +211 -0
- package/chunks/chunk-HP3OH2K7.js +27 -0
- package/chunks/chunk-KN4RZPDY.js +211 -0
- package/chunks/chunk-LUPVHC73.js +17 -0
- package/chunks/chunk-LV2VMOWR.js +18 -0
- package/chunks/chunk-MUGIN5OW.js +211 -0
- package/chunks/chunk-NFUY7SLX.js +211 -0
- package/chunks/chunk-NWFX6TEY.js +28 -0
- package/chunks/chunk-OVG5RGI3.js +29 -0
- package/chunks/chunk-RLJOYG64.js +33 -0
- package/chunks/chunk-S2NMAH7K.js +19 -0
- package/chunks/chunk-SNJJII7A.js +65 -0
- package/chunks/chunk-UFKH5WD2.js +21 -0
- package/chunks/chunk-VFJYLXCI.js +23 -0
- package/chunks/chunk-VKURVIRV.js +28 -0
- package/chunks/chunk-WABWQCFE.js +127 -0
- package/chunks/chunk-YP64J65L.js +17 -0
- package/chunks/chunk-ZCPGE7H7.js +64 -0
- package/node/files/index.js +4 -4
- package/package.json +1 -1
@@ -0,0 +1,29 @@
|
|
1
|
+
import {
|
2
|
+
randomHash,
|
3
|
+
randomHashPattern,
|
4
|
+
randomUUID
|
5
|
+
} from "./chunk-75BICI4L.js";
|
6
|
+
import {
|
7
|
+
hexChars,
|
8
|
+
randomHexChar
|
9
|
+
} from "./chunk-OGBUSUE6.js";
|
10
|
+
import {
|
11
|
+
random,
|
12
|
+
randomInt
|
13
|
+
} from "./chunk-D3ERTRDW.js";
|
14
|
+
|
15
|
+
// src/agnostic/random/index.ts
|
16
|
+
var Random;
|
17
|
+
((Random2) => {
|
18
|
+
Random2.random = random;
|
19
|
+
Random2.randomInt = randomInt;
|
20
|
+
Random2.hexChars = hexChars;
|
21
|
+
Random2.randomHexChar = randomHexChar;
|
22
|
+
Random2.randomHash = randomHash;
|
23
|
+
Random2.randomHashPattern = randomHashPattern;
|
24
|
+
Random2.randomUUID = randomUUID;
|
25
|
+
})(Random || (Random = {}));
|
26
|
+
|
27
|
+
export {
|
28
|
+
Random
|
29
|
+
};
|
@@ -0,0 +1,33 @@
|
|
1
|
+
// src/agnostic/misc/crossenv/window/index.ts
|
2
|
+
var Window;
|
3
|
+
((Window2) => {
|
4
|
+
function exists() {
|
5
|
+
return typeof globalThis !== "undefined" && "window" in globalThis;
|
6
|
+
}
|
7
|
+
Window2.exists = exists;
|
8
|
+
let _window = exists() ? globalThis["window"] ?? null : null;
|
9
|
+
function set(customWindow) {
|
10
|
+
_window = customWindow;
|
11
|
+
return customWindow;
|
12
|
+
}
|
13
|
+
Window2.set = set;
|
14
|
+
function unset() {
|
15
|
+
if (exists()) {
|
16
|
+
_window = globalThis["window"];
|
17
|
+
} else {
|
18
|
+
_window = null;
|
19
|
+
}
|
20
|
+
return _window;
|
21
|
+
}
|
22
|
+
Window2.unset = unset;
|
23
|
+
function get() {
|
24
|
+
if (_window !== null) return _window;
|
25
|
+
const message = "Window is undefined. Please call Window.setWindow(windowObj) before using Window.get.";
|
26
|
+
throw new Error(message);
|
27
|
+
}
|
28
|
+
Window2.get = get;
|
29
|
+
})(Window || (Window = {}));
|
30
|
+
|
31
|
+
export {
|
32
|
+
Window
|
33
|
+
};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import {
|
2
|
+
Types
|
3
|
+
} from "./chunk-LV2VMOWR.js";
|
4
|
+
|
5
|
+
// src/agnostic/misc/crossenv/detect-runtime/index.ts
|
6
|
+
function detectRuntime() {
|
7
|
+
if (typeof process !== "undefined" && typeof process.versions !== "undefined" && typeof process.versions.node !== "undefined") return Types.RuntimeName.NODE;
|
8
|
+
if (typeof window !== "undefined" && typeof window.document !== "undefined") return Types.RuntimeName.BROWSER;
|
9
|
+
if (typeof Deno !== "undefined") return Types.RuntimeName.DENO;
|
10
|
+
if (typeof process !== "undefined" && typeof navigator.userAgent === "string" && /ReactNative/.test(navigator.userAgent)) return Types.RuntimeName.REACT_NATIVE;
|
11
|
+
if (typeof process !== "undefined" && typeof process.versions !== "undefined" && typeof process.version.electron !== "undefined") return Types.RuntimeName.ELECTRON;
|
12
|
+
if (typeof self !== "undefined" && typeof self.addEventListener === "function" && typeof Headers !== "undefined") return Types.RuntimeName.CLOUDFLARE;
|
13
|
+
if (typeof AWS !== "undefined" && typeof AWS.Lambda !== "undefined") return Types.RuntimeName.AWS_LAMBDA;
|
14
|
+
return null;
|
15
|
+
}
|
16
|
+
|
17
|
+
export {
|
18
|
+
detectRuntime
|
19
|
+
};
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import {
|
2
|
+
isFalsy
|
3
|
+
} from "./chunk-QXAJXTXV.js";
|
4
|
+
|
5
|
+
// src/agnostic/misc/cast/index.ts
|
6
|
+
var Cast;
|
7
|
+
((Cast2) => {
|
8
|
+
function toBoolean(value) {
|
9
|
+
if (typeof value === "boolean") return value;
|
10
|
+
if (typeof value === "string") {
|
11
|
+
if (value.toLowerCase().trim() === "true") return true;
|
12
|
+
return false;
|
13
|
+
}
|
14
|
+
return !isFalsy(value);
|
15
|
+
}
|
16
|
+
Cast2.toBoolean = toBoolean;
|
17
|
+
function toNumber(value) {
|
18
|
+
if (typeof value === "number") return value;
|
19
|
+
if (typeof value === "string") return parseFloat(value);
|
20
|
+
return 0;
|
21
|
+
}
|
22
|
+
Cast2.toNumber = toNumber;
|
23
|
+
function toString(value) {
|
24
|
+
if (typeof value === "string") return value;
|
25
|
+
return String(value);
|
26
|
+
}
|
27
|
+
Cast2.toString = toString;
|
28
|
+
function toNull(_value) {
|
29
|
+
return null;
|
30
|
+
}
|
31
|
+
Cast2.toNull = toNull;
|
32
|
+
function toArray(value) {
|
33
|
+
if (Array.isArray(value)) return value;
|
34
|
+
if (typeof value === "object" && value !== null) return Object.entries(value).map((key, value2) => ({ key, value: value2 }));
|
35
|
+
return [value];
|
36
|
+
}
|
37
|
+
Cast2.toArray = toArray;
|
38
|
+
function toNumberArr(value) {
|
39
|
+
const arrValue = toArray(value);
|
40
|
+
return arrValue.map((val) => toNumber(val));
|
41
|
+
}
|
42
|
+
Cast2.toNumberArr = toNumberArr;
|
43
|
+
function toRecord(value) {
|
44
|
+
const record = {};
|
45
|
+
try {
|
46
|
+
Object.keys(value).forEach((key) => {
|
47
|
+
record[key] = value[key];
|
48
|
+
});
|
49
|
+
} catch (err) {
|
50
|
+
return record;
|
51
|
+
}
|
52
|
+
return record;
|
53
|
+
}
|
54
|
+
Cast2.toRecord = toRecord;
|
55
|
+
function toError(value) {
|
56
|
+
if (value instanceof Error) return value;
|
57
|
+
if (typeof value === "string") return new Error(value);
|
58
|
+
return new Error(toString(value));
|
59
|
+
}
|
60
|
+
Cast2.toError = toError;
|
61
|
+
})(Cast || (Cast = {}));
|
62
|
+
|
63
|
+
export {
|
64
|
+
Cast
|
65
|
+
};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import {
|
2
|
+
Window
|
3
|
+
} from "./chunk-RLJOYG64.js";
|
4
|
+
import {
|
5
|
+
detectRuntime
|
6
|
+
} from "./chunk-S2NMAH7K.js";
|
7
|
+
import {
|
8
|
+
Types
|
9
|
+
} from "./chunk-LV2VMOWR.js";
|
10
|
+
|
11
|
+
// src/agnostic/misc/crossenv/index.ts
|
12
|
+
var Crossenv;
|
13
|
+
((Crossenv2) => {
|
14
|
+
Crossenv2.detectRuntime = detectRuntime;
|
15
|
+
Crossenv2.Types = Types;
|
16
|
+
Crossenv2.Window = Window;
|
17
|
+
})(Crossenv || (Crossenv = {}));
|
18
|
+
|
19
|
+
export {
|
20
|
+
Crossenv
|
21
|
+
};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import {
|
2
|
+
Cast
|
3
|
+
} from "./chunk-SNJJII7A.js";
|
4
|
+
|
5
|
+
// src/agnostic/objects/flatten-getters/index.ts
|
6
|
+
function flattenGetters(obj) {
|
7
|
+
try {
|
8
|
+
const { entries, getOwnPropertyDescriptors } = Object;
|
9
|
+
const properties = Cast.toRecord(obj);
|
10
|
+
const getters = entries(getOwnPropertyDescriptors(obj)).filter(([_, desc]) => typeof desc.get === "function").map(([key]) => key);
|
11
|
+
const returned = { ...properties };
|
12
|
+
getters.forEach((getter) => {
|
13
|
+
returned[getter] = obj[getter];
|
14
|
+
});
|
15
|
+
return returned;
|
16
|
+
} catch (err) {
|
17
|
+
return {};
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
export {
|
22
|
+
flattenGetters
|
23
|
+
};
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import {
|
2
|
+
Sanitize
|
3
|
+
} from "./chunk-C5753KUP.js";
|
4
|
+
import {
|
5
|
+
register
|
6
|
+
} from "./chunk-CAMYGA44.js";
|
7
|
+
|
8
|
+
// src/agnostic/html/string-to-nodes/index.ts
|
9
|
+
function stringToNodes(dirtyStr, options) {
|
10
|
+
const actualDocument = options?.documentObj ?? window.document;
|
11
|
+
if (actualDocument === null) throw register.getError("no-window-document-on-runtime-please-provide" /* NO_DOCUMENT_PLEASE_PROVIDE */, "See documentObj in the options object");
|
12
|
+
const sanitizeOptions = {
|
13
|
+
...options?.sanitize,
|
14
|
+
documentObj: options?.sanitize?.documentObj ?? options?.documentObj
|
15
|
+
};
|
16
|
+
const str = options?.sanitize !== void 0 ? Sanitize.sanitize(dirtyStr, sanitizeOptions) : dirtyStr;
|
17
|
+
const wrapperDiv = actualDocument.createElement("div");
|
18
|
+
wrapperDiv.innerHTML = str;
|
19
|
+
const nodes = Array.from(wrapperDiv.childNodes).filter((node) => {
|
20
|
+
const allowedNodeTypes = [Node.ELEMENT_NODE, Node.TEXT_NODE];
|
21
|
+
return allowedNodeTypes.includes(node.nodeType);
|
22
|
+
});
|
23
|
+
return nodes;
|
24
|
+
}
|
25
|
+
|
26
|
+
export {
|
27
|
+
stringToNodes
|
28
|
+
};
|
@@ -0,0 +1,127 @@
|
|
1
|
+
import {
|
2
|
+
register
|
3
|
+
} from "./chunk-CB52KVOZ.js";
|
4
|
+
|
5
|
+
// src/agnostic/html/sanitize/index.ts
|
6
|
+
var Sanitize;
|
7
|
+
((Sanitize2) => {
|
8
|
+
Sanitize2.defaultOptions = { depth: 20 };
|
9
|
+
function sanitize(inputStr, options = Sanitize2.defaultOptions) {
|
10
|
+
const actualDocument = options.documentObj ?? window.document;
|
11
|
+
if (actualDocument === null) throw register.getError("no-window-document-on-runtime-please-provide" /* NO_DOCUMENT_PLEASE_PROVIDE */, "See documentObj in the options object");
|
12
|
+
const wrapperDiv = actualDocument.createElement("div");
|
13
|
+
const { inputFreeTransform } = options;
|
14
|
+
wrapperDiv.innerHTML = inputFreeTransform !== void 0 ? inputFreeTransform(inputStr) : inputStr;
|
15
|
+
const sanitizedWrapper = sanitizeElement(wrapperDiv, options);
|
16
|
+
const returned = sanitizedWrapper?.innerHTML;
|
17
|
+
return returned ?? "";
|
18
|
+
}
|
19
|
+
Sanitize2.sanitize = sanitize;
|
20
|
+
function sanitizeElement(element, options = Sanitize2.defaultOptions) {
|
21
|
+
const actualDocument = options.documentObj ?? window.document;
|
22
|
+
if (actualDocument === null) throw register.getError("no-window-document-on-runtime-please-provide" /* NO_DOCUMENT_PLEASE_PROVIDE */, "See documentObj in the options object");
|
23
|
+
const { tagName, attributes, childNodes } = element;
|
24
|
+
const {
|
25
|
+
allowedTags = [],
|
26
|
+
allowedAttributes = {},
|
27
|
+
forbiddenTags = [],
|
28
|
+
forbiddenAttributes = {},
|
29
|
+
depth = 20,
|
30
|
+
verbose = false
|
31
|
+
} = options;
|
32
|
+
if (depth <= 0) {
|
33
|
+
console.warn("Max depth reached");
|
34
|
+
return null;
|
35
|
+
}
|
36
|
+
const normalizedTagName = tagName.toLowerCase().trim();
|
37
|
+
const tagIsInForbidden = forbiddenTags.includes("*") || forbiddenTags.includes(normalizedTagName);
|
38
|
+
if (tagIsInForbidden) {
|
39
|
+
if (verbose === true) console.warn(tagName, "tag is forbidden");
|
40
|
+
return null;
|
41
|
+
}
|
42
|
+
const tagIsInAllowed = allowedTags.includes("*") || allowedTags.includes(normalizedTagName);
|
43
|
+
if (!tagIsInAllowed) {
|
44
|
+
if (verbose === true) console.warn(tagName, "tag is not allowed");
|
45
|
+
return null;
|
46
|
+
}
|
47
|
+
const returnedElement = actualDocument.createElement(tagName);
|
48
|
+
const returnedAttributes = Array.from(attributes).filter(({ name: attributeName, value: attributeValue }) => {
|
49
|
+
const allTagsForbiddenAttributes = forbiddenAttributes["*"] ?? [];
|
50
|
+
const thisTagForbiddenAttributes = forbiddenAttributes[normalizedTagName] ?? [];
|
51
|
+
const mergedForbiddenAttributes = [...allTagsForbiddenAttributes, ...thisTagForbiddenAttributes];
|
52
|
+
const isInForbidden = mergedForbiddenAttributes.some(({
|
53
|
+
attributeName: nameTester,
|
54
|
+
attributeValues: valTesters
|
55
|
+
}) => {
|
56
|
+
if (typeof nameTester === "string" && nameTester !== "*" && attributeName !== nameTester) return false;
|
57
|
+
if (typeof nameTester !== "string" && !nameTester.test(attributeName)) return false;
|
58
|
+
if (valTesters === void 0) {
|
59
|
+
if (verbose === true) console.warn(attributeName, "attribute on", tagName, "tag is forbidden");
|
60
|
+
return true;
|
61
|
+
}
|
62
|
+
if (valTesters.includes("*")) {
|
63
|
+
if (verbose === true) console.warn(attributeName, "attribute on", tagName, "tag is forbidden");
|
64
|
+
return true;
|
65
|
+
}
|
66
|
+
return valTesters.some((valTester) => {
|
67
|
+
if (typeof valTester === "string" && attributeValue === valTester) {
|
68
|
+
if (verbose === true) console.warn(attributeValue, "value for", attributeName, "attribute on", tagName, "tag is forbidden. Rule:", valTester);
|
69
|
+
return true;
|
70
|
+
}
|
71
|
+
if (typeof valTester !== "string" && valTester.test(attributeValue)) {
|
72
|
+
if (verbose === true) console.warn(attributeValue, "value for", attributeName, "attribute on", tagName, "tag is forbidden. Rule:", valTester);
|
73
|
+
return true;
|
74
|
+
}
|
75
|
+
return false;
|
76
|
+
});
|
77
|
+
});
|
78
|
+
if (isInForbidden) return false;
|
79
|
+
const allTagsAllowedAttributes = allowedAttributes["*"] ?? [];
|
80
|
+
const thisTagAllowedAttributes = allowedAttributes[normalizedTagName] ?? [];
|
81
|
+
const mergedAllowedAttributes = [...allTagsAllowedAttributes, ...thisTagAllowedAttributes];
|
82
|
+
let latestNotAllowedReason = [tagName, "has no allowed attributes"];
|
83
|
+
const isInAllowed = mergedAllowedAttributes.some(({
|
84
|
+
attributeName: nameTester,
|
85
|
+
attributeValues: valTesters
|
86
|
+
}) => {
|
87
|
+
if (typeof nameTester === "string" && nameTester !== "*" && attributeName !== nameTester) {
|
88
|
+
latestNotAllowedReason = [attributeName, "attribute on", tagName, "tag is not allowed"];
|
89
|
+
return false;
|
90
|
+
}
|
91
|
+
if (typeof nameTester !== "string" && !nameTester.test(attributeName)) {
|
92
|
+
latestNotAllowedReason = [attributeName, "attribute on", tagName, "tag is not allowed"];
|
93
|
+
return false;
|
94
|
+
}
|
95
|
+
if (valTesters === void 0) return true;
|
96
|
+
if (valTesters.includes("*")) return true;
|
97
|
+
return valTesters.some((valTester) => {
|
98
|
+
if (typeof valTester === "string" && attributeValue === valTester) return true;
|
99
|
+
if (typeof valTester !== "string" && valTester.test(attributeValue)) return true;
|
100
|
+
latestNotAllowedReason = [attributeValue, "value for", attributeName, "attribute on", tagName, "tag is not allowed"];
|
101
|
+
return false;
|
102
|
+
});
|
103
|
+
});
|
104
|
+
if (!isInAllowed) {
|
105
|
+
if (verbose === true) console.warn(...latestNotAllowedReason);
|
106
|
+
return false;
|
107
|
+
}
|
108
|
+
return true;
|
109
|
+
});
|
110
|
+
returnedAttributes.forEach(({ name, value }) => {
|
111
|
+
returnedElement.setAttribute(name, value);
|
112
|
+
});
|
113
|
+
const sanitizedChildNodes = Array.from(childNodes).map((node) => {
|
114
|
+
if (node.nodeType === Node.ELEMENT_NODE) return sanitizeElement(node, { ...options, depth: depth - 1 });
|
115
|
+
else if (node.nodeType === Node.TEXT_NODE) return node;
|
116
|
+
else if (options.keepComments === true && node.nodeType === Node.COMMENT_NODE) return node;
|
117
|
+
return null;
|
118
|
+
}).filter((elt) => elt !== null);
|
119
|
+
returnedElement.replaceChildren(...sanitizedChildNodes);
|
120
|
+
return returnedElement;
|
121
|
+
}
|
122
|
+
Sanitize2.sanitizeElement = sanitizeElement;
|
123
|
+
})(Sanitize || (Sanitize = {}));
|
124
|
+
|
125
|
+
export {
|
126
|
+
Sanitize
|
127
|
+
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
// src/agnostic/objects/record-format/index.ts
|
2
|
+
async function recordFormat(input, format) {
|
3
|
+
const result = {};
|
4
|
+
for (const key in format) {
|
5
|
+
const formatter = format[key];
|
6
|
+
if (typeof formatter === "function") {
|
7
|
+
result[key] = await formatter(input[key]);
|
8
|
+
} else {
|
9
|
+
result[key] = formatter;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
return result;
|
13
|
+
}
|
14
|
+
|
15
|
+
export {
|
16
|
+
recordFormat
|
17
|
+
};
|
@@ -0,0 +1,64 @@
|
|
1
|
+
import {
|
2
|
+
Window
|
3
|
+
} from "./chunk-RLJOYG64.js";
|
4
|
+
|
5
|
+
// src/agnostic/html/hyper-json/serialize/index.ts
|
6
|
+
var Serialize;
|
7
|
+
((Serialize2) => {
|
8
|
+
function serialize(value) {
|
9
|
+
const { Text, Element, NodeList } = Window.get();
|
10
|
+
if (value === null) return { type: "null", value: null };
|
11
|
+
if (typeof value === "boolean" || typeof value === "number" || typeof value === "string") return { type: typeof value, value };
|
12
|
+
if (value instanceof Text) return { type: "text", value: value.textContent ?? "" };
|
13
|
+
if (value instanceof Element) return { type: "text", value: value.outerHTML };
|
14
|
+
if (value instanceof NodeList) return {
|
15
|
+
type: "text",
|
16
|
+
value: Array.from(value).map((e) => {
|
17
|
+
if (e instanceof Text) return e.textContent;
|
18
|
+
return e.outerHTML;
|
19
|
+
}).join("")
|
20
|
+
};
|
21
|
+
if (Array.isArray(value)) return { type: "array", value: value.map(serialize) };
|
22
|
+
if (typeof value === "function") return { type: "transformer", value };
|
23
|
+
return {
|
24
|
+
type: "record",
|
25
|
+
value: Object.entries(value).reduce((reduced, [key, val]) => ({
|
26
|
+
...reduced,
|
27
|
+
[key]: serialize(val)
|
28
|
+
}), {})
|
29
|
+
};
|
30
|
+
}
|
31
|
+
Serialize2.serialize = serialize;
|
32
|
+
function deserialize(serialized) {
|
33
|
+
const { document } = Window.get();
|
34
|
+
if (serialized.type === "null") return null;
|
35
|
+
if (serialized.type === "boolean") return serialized.value;
|
36
|
+
if (serialized.type === "number") return serialized.value;
|
37
|
+
if (serialized.type === "string") return serialized.value;
|
38
|
+
if (serialized.type === "text") return document.createTextNode(serialized.value);
|
39
|
+
if (serialized.type === "element") {
|
40
|
+
const elt = document.createElement("div");
|
41
|
+
elt.innerHTML = serialized.value;
|
42
|
+
const firstChild = elt.firstElementChild;
|
43
|
+
return firstChild ?? document.createElement("div");
|
44
|
+
}
|
45
|
+
if (serialized.type === "nodelist") {
|
46
|
+
const elt = document.createElement("div");
|
47
|
+
elt.innerHTML = serialized.value;
|
48
|
+
return elt.childNodes;
|
49
|
+
}
|
50
|
+
if (serialized.type === "array") return serialized.value.map((val) => deserialize(val));
|
51
|
+
if (serialized.type === "transformer") return serialized.value;
|
52
|
+
return Object.entries(serialized.value).reduce((reduced, [key, serialized2]) => {
|
53
|
+
return {
|
54
|
+
...reduced,
|
55
|
+
[key]: deserialize(serialized2)
|
56
|
+
};
|
57
|
+
}, {});
|
58
|
+
}
|
59
|
+
Serialize2.deserialize = deserialize;
|
60
|
+
})(Serialize || (Serialize = {}));
|
61
|
+
|
62
|
+
export {
|
63
|
+
Serialize
|
64
|
+
};
|
package/node/files/index.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
import {
|
2
|
-
|
3
|
-
} from "../../chunks/chunk-
|
2
|
+
isInDirectory
|
3
|
+
} from "../../chunks/chunk-NRITRUZW.js";
|
4
4
|
import {
|
5
5
|
Subpaths
|
6
6
|
} from "../../chunks/chunk-HGCG2J77.js";
|
7
7
|
import {
|
8
|
-
|
9
|
-
} from "../../chunks/chunk-
|
8
|
+
readWrite
|
9
|
+
} from "../../chunks/chunk-7DBNMU6N.js";
|
10
10
|
import "../../chunks/chunk-LQFKUNVQ.js";
|
11
11
|
|
12
12
|
// src/node/files/index.ts
|