@design-edito/tools 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- package/agnostic/css/index.js +50 -27
- package/agnostic/css/styles-set/index.d.ts +6 -4
- package/agnostic/errors/index.d.ts +15 -15
- package/agnostic/errors/index.js +1 -1
- package/agnostic/html/index.js +12 -12
- package/agnostic/html/sanitize/index.js +3 -3
- package/agnostic/html/selector-to-element/index.js +3 -3
- package/agnostic/html/string-to-nodes/index.js +4 -4
- package/agnostic/misc/index.js +7 -7
- package/agnostic/misc/outcome/index.d.ts +22 -0
- package/agnostic/misc/outcome/index.js +22 -0
- package/agnostic/numbers/index.js +3 -3
- package/agnostic/objects/index.js +8 -8
- package/agnostic/optim/index.js +3 -3
- package/chunks/{chunk-XN3PZIVL.js → chunk-5FU3AIZ4.js} +1 -1
- package/chunks/{chunk-KQT5CTGF.js → chunk-B27DVNRX.js} +1 -1
- package/chunks/{chunk-IFD7GSGK.js → chunk-RASYEJ6T.js} +1 -1
- package/chunks/{chunk-MT74WIQR.js → chunk-RLESUSTH.js} +4 -4
- package/chunks/{chunk-NRJQKVQV.js → chunk-XPM2OFLI.js} +2 -2
- package/node/files/index.js +3 -3
- package/package.json +1 -1
package/agnostic/css/index.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
import {
|
2
|
-
Bem
|
3
|
-
} from "../../chunks/chunk-KIONYWA7.js";
|
4
1
|
import {
|
5
2
|
generateNiceColor,
|
6
3
|
niceColors
|
7
4
|
} from "../../chunks/chunk-EDVNAV3G.js";
|
5
|
+
import {
|
6
|
+
Bem
|
7
|
+
} from "../../chunks/chunk-KIONYWA7.js";
|
8
8
|
import {
|
9
9
|
classNameRegex,
|
10
10
|
isValidClassName
|
@@ -14,38 +14,32 @@ import {
|
|
14
14
|
} from "../../chunks/chunk-WLL3FNVL.js";
|
15
15
|
import {
|
16
16
|
register
|
17
|
-
} from "../../chunks/chunk-
|
17
|
+
} from "../../chunks/chunk-B27DVNRX.js";
|
18
18
|
import {
|
19
19
|
Crossenv
|
20
20
|
} from "../../chunks/chunk-GJOU3UAL.js";
|
21
|
-
import "../../chunks/chunk-
|
21
|
+
import "../../chunks/chunk-RLESUSTH.js";
|
22
22
|
import "../../chunks/chunk-QXAJXTXV.js";
|
23
23
|
import "../../chunks/chunk-HC6ZOHCS.js";
|
24
24
|
|
25
25
|
// src/agnostic/css/styles-set/index.tsx
|
26
26
|
import { Component } from "react";
|
27
|
-
import {
|
28
|
-
import {
|
29
|
-
createRoot as reactCreateRoot
|
30
|
-
} from "react-dom/client";
|
27
|
+
import { createRoot as reactCreateRoot } from "react-dom/client";
|
31
28
|
import { Fragment, jsx } from "react/jsx-runtime";
|
32
29
|
var StylesSet = class _StylesSet {
|
33
30
|
static defaultPrivateIDAttribute = "data-styleset-private-id";
|
34
31
|
static defaultPublicIDAttribute = "data-styleset-public-id";
|
32
|
+
tagsPrivateIDAttribute = _StylesSet.defaultPrivateIDAttribute;
|
33
|
+
tagsPublicIDAttribute = _StylesSet.defaultPublicIDAttribute;
|
35
34
|
_items = /* @__PURE__ */ new Map();
|
36
35
|
get items() {
|
37
36
|
const sortedItemsArray = Array.from(this._items).map(([privateId, item]) => {
|
38
|
-
|
39
|
-
|
40
|
-
privateId,
|
41
|
-
item
|
42
|
-
};
|
37
|
+
const targetPosition = this.getTargetPosition(privateId) ?? 0;
|
38
|
+
return { targetPosition, privateId, item };
|
43
39
|
}).sort((a, b) => a.targetPosition - b.targetPosition).map(({ item, privateId }) => [privateId, item]);
|
44
40
|
const sortedItemsMap = new Map(sortedItemsArray);
|
45
41
|
return sortedItemsMap;
|
46
42
|
}
|
47
|
-
tagsPrivateIDAttribute = _StylesSet.defaultPrivateIDAttribute;
|
48
|
-
tagsPublicIDAttribute = _StylesSet.defaultPublicIDAttribute;
|
49
43
|
getTargetPosition(privateId) {
|
50
44
|
const orderedStyles = Array.from(this._items).map(([privateId2, data]) => ({ privateId: privateId2, data })).sort((a, b) => {
|
51
45
|
const aPos = a.data.position ?? 0;
|
@@ -74,22 +68,18 @@ var StylesSet = class _StylesSet {
|
|
74
68
|
if (existingIds.includes(generated)) return this.generateUniquePrivateId();
|
75
69
|
return generated;
|
76
70
|
}
|
77
|
-
|
71
|
+
_rendered = /* @__PURE__ */ new Map();
|
72
|
+
render(element) {
|
73
|
+
const root = reactCreateRoot(element);
|
78
74
|
const items = this.items;
|
79
|
-
|
75
|
+
root.render(/* @__PURE__ */ jsx(
|
80
76
|
StylesSetComp,
|
81
77
|
{
|
82
78
|
items,
|
83
79
|
privateIDAttribute: this.tagsPrivateIDAttribute,
|
84
80
|
publicIDAttribute: this.tagsPublicIDAttribute
|
85
81
|
}
|
86
|
-
);
|
87
|
-
return comp;
|
88
|
-
}
|
89
|
-
_rendered = /* @__PURE__ */ new Map();
|
90
|
-
render(element) {
|
91
|
-
const root = reactCreateRoot(element);
|
92
|
-
root.render(this.getComp());
|
82
|
+
));
|
93
83
|
this._rendered.set(element, root);
|
94
84
|
return this;
|
95
85
|
}
|
@@ -102,7 +92,15 @@ var StylesSet = class _StylesSet {
|
|
102
92
|
return this;
|
103
93
|
}
|
104
94
|
updateRendered() {
|
105
|
-
|
95
|
+
const { items } = this;
|
96
|
+
this._rendered.forEach((root) => root.render(/* @__PURE__ */ jsx(
|
97
|
+
StylesSetComp,
|
98
|
+
{
|
99
|
+
items,
|
100
|
+
privateIDAttribute: this.tagsPrivateIDAttribute,
|
101
|
+
publicIDAttribute: this.tagsPublicIDAttribute
|
102
|
+
}
|
103
|
+
)));
|
106
104
|
return this;
|
107
105
|
}
|
108
106
|
addItem(item, abortIfIdExists = true) {
|
@@ -135,11 +133,36 @@ var StylesSet = class _StylesSet {
|
|
135
133
|
if (actualDocumentObj === null) throw register.getError("no-window-document-on-runtime" /* NO_DOCUMENT */);
|
136
134
|
return new Promise((resolve) => {
|
137
135
|
const tempElt = actualDocumentObj.createElement("div");
|
138
|
-
|
136
|
+
const tempRoot = reactCreateRoot(tempElt);
|
137
|
+
const { items } = this;
|
138
|
+
const onRendered = () => {
|
139
|
+
resolve(tempElt.innerHTML);
|
140
|
+
tempRoot.unmount();
|
141
|
+
tempElt.remove();
|
142
|
+
};
|
143
|
+
tempRoot.render(/* @__PURE__ */ jsx(
|
144
|
+
StylesSetComp,
|
145
|
+
{
|
146
|
+
items,
|
147
|
+
privateIDAttribute: this.tagsPrivateIDAttribute,
|
148
|
+
publicIDAttribute: this.tagsPublicIDAttribute,
|
149
|
+
onRendered
|
150
|
+
}
|
151
|
+
));
|
139
152
|
});
|
140
153
|
}
|
141
154
|
};
|
142
155
|
var StylesSetComp = class extends Component {
|
156
|
+
componentDidMount() {
|
157
|
+
const { props } = this;
|
158
|
+
const { onRendered } = props;
|
159
|
+
if (onRendered !== void 0) onRendered();
|
160
|
+
}
|
161
|
+
componentDidUpdate() {
|
162
|
+
const { props } = this;
|
163
|
+
const { onRendered } = props;
|
164
|
+
if (onRendered !== void 0) onRendered();
|
165
|
+
}
|
143
166
|
render() {
|
144
167
|
const { props } = this;
|
145
168
|
const items = props.items ?? /* @__PURE__ */ new Map();
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { Component } from 'react';
|
2
2
|
export type StylesSetItem = {
|
3
3
|
type: 'string' | 'url';
|
4
4
|
content: string;
|
@@ -9,16 +9,15 @@ export type StylesSetItem = {
|
|
9
9
|
export declare class StylesSet {
|
10
10
|
static defaultPrivateIDAttribute: string;
|
11
11
|
static defaultPublicIDAttribute: string;
|
12
|
-
private _items;
|
13
|
-
get items(): Map<string, StylesSetItem>;
|
14
12
|
tagsPrivateIDAttribute: string;
|
15
13
|
tagsPublicIDAttribute: string;
|
14
|
+
private _items;
|
15
|
+
get items(): Map<string, StylesSetItem>;
|
16
16
|
private getTargetPosition;
|
17
17
|
setTagsPrivateIDAttribute(str: string): this;
|
18
18
|
setTagsPublicIDAttribute(str: string): this;
|
19
19
|
getById(id: string): StylesSetItem | undefined;
|
20
20
|
generateUniquePrivateId(): string;
|
21
|
-
getComp(): JSX.Element;
|
22
21
|
private _rendered;
|
23
22
|
render(element: Element): this;
|
24
23
|
unmount(element: Element): this;
|
@@ -31,7 +30,10 @@ export type StylesSetCompProps = {
|
|
31
30
|
items?: StylesSet['items'];
|
32
31
|
privateIDAttribute?: StylesSet['tagsPrivateIDAttribute'];
|
33
32
|
publicIDAttribute?: StylesSet['tagsPublicIDAttribute'];
|
33
|
+
onRendered?: (...any: any[]) => any;
|
34
34
|
};
|
35
35
|
export declare class StylesSetComp extends Component<StylesSetCompProps> {
|
36
|
+
componentDidMount(): void;
|
37
|
+
componentDidUpdate(): void;
|
36
38
|
render(): import("react/jsx-runtime").JSX.Element;
|
37
39
|
}
|
@@ -2,29 +2,29 @@ type AnyFunc = (...args: any[]) => any;
|
|
2
2
|
type ParamsOfNullableFunc<F extends AnyFunc | undefined | null> = F extends AnyFunc ? Parameters<F> : [];
|
3
3
|
type ReturnTypeOfNullableFunc<F extends AnyFunc | undefined | null> = F extends AnyFunc ? ReturnType<F> : undefined;
|
4
4
|
export declare namespace Errors {
|
5
|
-
type
|
5
|
+
type Factory<Params extends any[] = any[], Details = any> = {
|
6
6
|
message: string;
|
7
7
|
makeDetails?: (...params: Params) => Details;
|
8
8
|
};
|
9
|
-
type
|
9
|
+
type Index<Params extends any[] = any[], Details = any> = {
|
10
|
+
[code: string]: Factory<Params, Details>;
|
11
|
+
};
|
12
|
+
type Data<RS extends Index, C extends keyof RS> = {
|
10
13
|
code: C;
|
11
14
|
message: RS[C]['message'];
|
12
15
|
details: ReturnTypeOfNullableFunc<RS[C]['makeDetails']>;
|
13
16
|
};
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
code: ErrData<RS, C>['code'];
|
19
|
-
details: ErrData<RS, C>['details'];
|
20
|
-
constructor(data: ErrData<RS, C>);
|
17
|
+
class CustomError<Idx extends Index, Code extends keyof Idx> extends Error {
|
18
|
+
code: Data<Idx, Code>['code'];
|
19
|
+
details: Data<Idx, Code>['details'];
|
20
|
+
constructor(data: Data<Idx, Code>);
|
21
21
|
}
|
22
|
-
class Register<
|
23
|
-
|
24
|
-
constructor(
|
25
|
-
getFactory<C extends keyof
|
26
|
-
getData<C extends keyof
|
27
|
-
getError<C extends keyof
|
22
|
+
class Register<Idx extends Index> {
|
23
|
+
index: Idx;
|
24
|
+
constructor(index: Idx);
|
25
|
+
getFactory<C extends keyof Idx>(code: C): Idx[C];
|
26
|
+
getData<C extends keyof Idx>(code: C, ...params: ParamsOfNullableFunc<Idx[C]['makeDetails']>): Data<Idx, C>;
|
27
|
+
getError<C extends keyof Idx>(code: C, ...params: ParamsOfNullableFunc<Idx[C]['makeDetails']>): CustomError<Idx, C>;
|
28
28
|
}
|
29
29
|
}
|
30
30
|
export {};
|
package/agnostic/errors/index.js
CHANGED
package/agnostic/html/index.js
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
+
import {
|
2
|
+
stringToNodes
|
3
|
+
} from "../../chunks/chunk-XPM2OFLI.js";
|
1
4
|
import {
|
2
5
|
getNodeAncestors
|
3
6
|
} from "../../chunks/chunk-SQZGZ3VT.js";
|
4
7
|
import {
|
5
8
|
insertNode
|
6
9
|
} from "../../chunks/chunk-XA4HVHJ4.js";
|
7
|
-
import {
|
8
|
-
getPositionInsideParent
|
9
|
-
} from "../../chunks/chunk-VTPRO4NJ.js";
|
10
|
-
import {
|
11
|
-
Placeholders
|
12
|
-
} from "../../chunks/chunk-VYW4IADX.js";
|
13
10
|
import {
|
14
11
|
selectorToElement
|
15
|
-
} from "../../chunks/chunk-
|
12
|
+
} from "../../chunks/chunk-5FU3AIZ4.js";
|
16
13
|
import {
|
17
|
-
|
18
|
-
} from "../../chunks/chunk-
|
14
|
+
getPositionInsideParent
|
15
|
+
} from "../../chunks/chunk-VTPRO4NJ.js";
|
19
16
|
import {
|
20
17
|
Sanitize
|
21
|
-
} from "../../chunks/chunk-
|
22
|
-
import "../../chunks/chunk-
|
18
|
+
} from "../../chunks/chunk-RASYEJ6T.js";
|
19
|
+
import "../../chunks/chunk-B27DVNRX.js";
|
23
20
|
import "../../chunks/chunk-GJOU3UAL.js";
|
24
|
-
import
|
21
|
+
import {
|
22
|
+
Placeholders
|
23
|
+
} from "../../chunks/chunk-VYW4IADX.js";
|
24
|
+
import "../../chunks/chunk-RLESUSTH.js";
|
25
25
|
|
26
26
|
// src/agnostic/html/index.ts
|
27
27
|
var Html;
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import {
|
2
2
|
Sanitize
|
3
|
-
} from "../../../chunks/chunk-
|
4
|
-
import "../../../chunks/chunk-
|
3
|
+
} from "../../../chunks/chunk-RASYEJ6T.js";
|
4
|
+
import "../../../chunks/chunk-B27DVNRX.js";
|
5
5
|
import "../../../chunks/chunk-GJOU3UAL.js";
|
6
|
-
import "../../../chunks/chunk-
|
6
|
+
import "../../../chunks/chunk-RLESUSTH.js";
|
7
7
|
export {
|
8
8
|
Sanitize
|
9
9
|
};
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import {
|
2
2
|
selectorToElement
|
3
|
-
} from "../../../chunks/chunk-
|
4
|
-
import "../../../chunks/chunk-
|
3
|
+
} from "../../../chunks/chunk-5FU3AIZ4.js";
|
4
|
+
import "../../../chunks/chunk-B27DVNRX.js";
|
5
5
|
import "../../../chunks/chunk-GJOU3UAL.js";
|
6
|
-
import "../../../chunks/chunk-
|
6
|
+
import "../../../chunks/chunk-RLESUSTH.js";
|
7
7
|
export {
|
8
8
|
selectorToElement
|
9
9
|
};
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import {
|
2
2
|
stringToNodes
|
3
|
-
} from "../../../chunks/chunk-
|
4
|
-
import "../../../chunks/chunk-
|
5
|
-
import "../../../chunks/chunk-
|
3
|
+
} from "../../../chunks/chunk-XPM2OFLI.js";
|
4
|
+
import "../../../chunks/chunk-RASYEJ6T.js";
|
5
|
+
import "../../../chunks/chunk-B27DVNRX.js";
|
6
6
|
import "../../../chunks/chunk-GJOU3UAL.js";
|
7
|
-
import "../../../chunks/chunk-
|
7
|
+
import "../../../chunks/chunk-RLESUSTH.js";
|
8
8
|
export {
|
9
9
|
stringToNodes
|
10
10
|
};
|
package/agnostic/misc/index.js
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
import {
|
2
|
-
|
3
|
-
} from "../../chunks/chunk-
|
4
|
-
import {
|
5
|
-
Cast
|
6
|
-
} from "../../chunks/chunk-4QQBKBYH.js";
|
2
|
+
Assert
|
3
|
+
} from "../../chunks/chunk-W7YBGJ4H.js";
|
7
4
|
import {
|
8
5
|
Logs
|
9
6
|
} from "../../chunks/chunk-5LNUCDQ6.js";
|
@@ -11,8 +8,11 @@ import {
|
|
11
8
|
Random
|
12
9
|
} from "../../chunks/chunk-WLL3FNVL.js";
|
13
10
|
import {
|
14
|
-
|
15
|
-
} from "../../chunks/chunk-
|
11
|
+
Cast
|
12
|
+
} from "../../chunks/chunk-4QQBKBYH.js";
|
13
|
+
import {
|
14
|
+
getCurrentDownlink
|
15
|
+
} from "../../chunks/chunk-7AWTHZLY.js";
|
16
16
|
import {
|
17
17
|
Crossenv
|
18
18
|
} from "../../chunks/chunk-GJOU3UAL.js";
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { Errors } from '../../errors';
|
2
|
+
export declare namespace Outcome {
|
3
|
+
type Success<Payload = unknown> = {
|
4
|
+
success: true;
|
5
|
+
returned: Payload;
|
6
|
+
};
|
7
|
+
type Failure<Payload = unknown, ErrorsIndex extends Errors.Index = {
|
8
|
+
[key: string]: any;
|
9
|
+
}> = {
|
10
|
+
success: false;
|
11
|
+
returned: Payload;
|
12
|
+
errorCode: keyof ErrorsIndex;
|
13
|
+
};
|
14
|
+
type Outcome<SuccesPayload = unknown, FailurePayload = SuccesPayload, ErrorsIndex extends Errors.Index = {
|
15
|
+
[key: string]: any;
|
16
|
+
}> = Success<SuccesPayload> | Failure<FailurePayload, ErrorsIndex>;
|
17
|
+
function makeSuccess<S = any>(returned: S): Success<S>;
|
18
|
+
function makeFailure<FailurePayload = any, ErrorsIndex extends Errors.Index = {
|
19
|
+
[key: string]: any;
|
20
|
+
}>(returned: FailurePayload, code: keyof ErrorsIndex): Failure<FailurePayload, ErrorsIndex>;
|
21
|
+
type Outcomer<SuccesPayload, FailurePayload, Params extends any[]> = (...params: Params) => Outcome<SuccesPayload, FailurePayload> | Promise<Outcome<SuccesPayload, FailurePayload>>;
|
22
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
// src/agnostic/misc/outcome/index.ts
|
2
|
+
var Outcome;
|
3
|
+
((Outcome2) => {
|
4
|
+
function makeSuccess(returned) {
|
5
|
+
return {
|
6
|
+
success: true,
|
7
|
+
returned
|
8
|
+
};
|
9
|
+
}
|
10
|
+
Outcome2.makeSuccess = makeSuccess;
|
11
|
+
function makeFailure(returned, code) {
|
12
|
+
return {
|
13
|
+
success: false,
|
14
|
+
returned,
|
15
|
+
errorCode: code
|
16
|
+
};
|
17
|
+
}
|
18
|
+
Outcome2.makeFailure = makeFailure;
|
19
|
+
})(Outcome || (Outcome = {}));
|
20
|
+
export {
|
21
|
+
Outcome
|
22
|
+
};
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import {
|
2
2
|
absoluteModulo
|
3
3
|
} from "../../chunks/chunk-DNIOWD7K.js";
|
4
|
-
import {
|
5
|
-
clamp
|
6
|
-
} from "../../chunks/chunk-OSAXBA7G.js";
|
7
4
|
import {
|
8
5
|
interpolate
|
9
6
|
} from "../../chunks/chunk-EW46EXFB.js";
|
7
|
+
import {
|
8
|
+
clamp
|
9
|
+
} from "../../chunks/chunk-OSAXBA7G.js";
|
10
10
|
import {
|
11
11
|
createScale,
|
12
12
|
getHarmonic
|
@@ -1,7 +1,9 @@
|
|
1
1
|
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
isRecord
|
3
|
+
} from "../../chunks/chunk-YDIBNEGA.js";
|
4
|
+
import {
|
5
|
+
flattenGetters
|
6
|
+
} from "../../chunks/chunk-PO3V3I57.js";
|
5
7
|
import {
|
6
8
|
Validation
|
7
9
|
} from "../../chunks/chunk-FPEW3A27.js";
|
@@ -10,11 +12,9 @@ import {
|
|
10
12
|
} from "../../chunks/chunk-WOAYU6LB.js";
|
11
13
|
import "../../chunks/chunk-E6MSDKON.js";
|
12
14
|
import {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
isRecord
|
17
|
-
} from "../../chunks/chunk-YDIBNEGA.js";
|
15
|
+
isNonNullObject,
|
16
|
+
isObject
|
17
|
+
} from "../../chunks/chunk-HQLRJ7XW.js";
|
18
18
|
import "../../chunks/chunk-4QQBKBYH.js";
|
19
19
|
import "../../chunks/chunk-QXAJXTXV.js";
|
20
20
|
import "../../chunks/chunk-HC6ZOHCS.js";
|
package/agnostic/optim/index.js
CHANGED
@@ -13,12 +13,12 @@ var Errors;
|
|
13
13
|
}
|
14
14
|
Errors2.CustomError = CustomError;
|
15
15
|
class Register {
|
16
|
-
|
17
|
-
constructor(
|
18
|
-
this.
|
16
|
+
index;
|
17
|
+
constructor(index) {
|
18
|
+
this.index = index;
|
19
19
|
}
|
20
20
|
getFactory(code) {
|
21
|
-
return this.
|
21
|
+
return this.index[code];
|
22
22
|
}
|
23
23
|
getData(code, ...params) {
|
24
24
|
const core = this.getFactory(code);
|
package/node/files/index.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
isInDirectory
|
3
|
-
} from "../../chunks/chunk-NRITRUZW.js";
|
4
1
|
import {
|
5
2
|
readWrite
|
6
3
|
} from "../../chunks/chunk-7DBNMU6N.js";
|
7
4
|
import {
|
8
5
|
Subpaths
|
9
6
|
} from "../../chunks/chunk-HGCG2J77.js";
|
7
|
+
import {
|
8
|
+
isInDirectory
|
9
|
+
} from "../../chunks/chunk-NRITRUZW.js";
|
10
10
|
import "../../chunks/chunk-LQFKUNVQ.js";
|
11
11
|
|
12
12
|
// src/node/files/index.ts
|