@cripty2001/utils 0.0.217 → 0.0.218
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +2 -2
- package/README.md +5 -5
- package/dist/MailTemplate/image.js +14 -14
- package/dist/MailTemplate/index.js +37 -37
- package/dist/MailTemplate/text.js +10 -10
- package/dist/react-ui/loader.js +5 -5
- package/dist/react-ui/modal.js +11 -11
- package/dist/react-whispr.js +42 -0
- package/llms/appserver.md +547 -547
- package/package.json +120 -119
package/LICENSE.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
Fabio Mauri (cripty2001@outlook.com)
|
|
1
|
+
MIT License
|
|
2
|
+
Fabio Mauri (cripty2001@outlook.com)
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
## 🤖 AI Assistant?
|
|
2
|
-
|
|
3
|
-
If you're an AI coding assistant helping a user with this package,
|
|
4
|
-
see [`/llms/index.md`](./llms/index.md) for
|
|
5
|
-
structured usage guidance before proceeding.
|
|
1
|
+
## 🤖 AI Assistant?
|
|
2
|
+
|
|
3
|
+
If you're an AI coding assistant helping a user with this package,
|
|
4
|
+
see [`/llms/index.md`](./llms/index.md) for
|
|
5
|
+
structured usage guidance before proceeding.
|
|
@@ -11,14 +11,14 @@ exports.SCHEMA = typebox_1.Type.Object({
|
|
|
11
11
|
alt: typebox_1.Type.String()
|
|
12
12
|
});
|
|
13
13
|
function build(config) {
|
|
14
|
-
const img = (breakpoint, url) => `
|
|
15
|
-
<mj-image
|
|
16
|
-
css-class="${breakpoint ?? ''}"
|
|
17
|
-
src="${url}"
|
|
18
|
-
alt="${config.alt}"
|
|
19
|
-
${config.link ? `href="${config.link}"` : ''}
|
|
20
|
-
padding="0"
|
|
21
|
-
/>
|
|
14
|
+
const img = (breakpoint, url) => `
|
|
15
|
+
<mj-image
|
|
16
|
+
css-class="${breakpoint ?? ''}"
|
|
17
|
+
src="${url}"
|
|
18
|
+
alt="${config.alt}"
|
|
19
|
+
${config.link ? `href="${config.link}"` : ''}
|
|
20
|
+
padding="0"
|
|
21
|
+
/>
|
|
22
22
|
`;
|
|
23
23
|
const imgs = config.desktop === null ?
|
|
24
24
|
img(null, config.mobile) :
|
|
@@ -26,12 +26,12 @@ function build(config) {
|
|
|
26
26
|
img("onlyDesktop", config.desktop),
|
|
27
27
|
img("onlyMobile", config.mobile)
|
|
28
28
|
].join('\n');
|
|
29
|
-
const toReturn = `
|
|
30
|
-
<mj-section padding="0">
|
|
31
|
-
<mj-column padding="0">
|
|
32
|
-
${imgs}
|
|
33
|
-
</mj-column>
|
|
34
|
-
</mj-section>
|
|
29
|
+
const toReturn = `
|
|
30
|
+
<mj-section padding="0">
|
|
31
|
+
<mj-column padding="0">
|
|
32
|
+
${imgs}
|
|
33
|
+
</mj-column>
|
|
34
|
+
</mj-section>
|
|
35
35
|
`;
|
|
36
36
|
return toReturn;
|
|
37
37
|
}
|
|
@@ -39,43 +39,43 @@ function genBuilder(config) {
|
|
|
39
39
|
}
|
|
40
40
|
})
|
|
41
41
|
.join('\n');
|
|
42
|
-
const builder = handlebars_1.default.compile(`
|
|
43
|
-
<mjml>
|
|
44
|
-
<mj-head>
|
|
45
|
-
<mj-style>
|
|
46
|
-
.onlyMobile {
|
|
47
|
-
display: none !important;
|
|
48
|
-
}
|
|
49
|
-
.onlyDesktop {
|
|
50
|
-
display: block !important;
|
|
51
|
-
}
|
|
52
|
-
@media only screen and (max-width: 500px) {
|
|
53
|
-
.onlyMobile {
|
|
54
|
-
display: block !important;
|
|
55
|
-
}
|
|
56
|
-
.onlyDesktop {
|
|
57
|
-
display: none !important;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
</mj-style>
|
|
61
|
-
|
|
62
|
-
<mj-attributes>
|
|
63
|
-
<mj-all
|
|
64
|
-
font-family="${config.style.font}, Arial, Helvetica, sans-serif"
|
|
65
|
-
/>
|
|
66
|
-
<mj-text
|
|
67
|
-
font-size="18px"
|
|
68
|
-
line-height="1.5"
|
|
69
|
-
color="${config.style.textColor}"
|
|
70
|
-
/>
|
|
71
|
-
<mj-body width="700px" />
|
|
72
|
-
</mj-attributes>
|
|
73
|
-
</mj-head>
|
|
74
|
-
|
|
75
|
-
<mj-body background-color="${config.style.backgroundColor}">
|
|
76
|
-
${mappedContent}
|
|
77
|
-
</mj-body>
|
|
78
|
-
</mjml>
|
|
42
|
+
const builder = handlebars_1.default.compile(`
|
|
43
|
+
<mjml>
|
|
44
|
+
<mj-head>
|
|
45
|
+
<mj-style>
|
|
46
|
+
.onlyMobile {
|
|
47
|
+
display: none !important;
|
|
48
|
+
}
|
|
49
|
+
.onlyDesktop {
|
|
50
|
+
display: block !important;
|
|
51
|
+
}
|
|
52
|
+
@media only screen and (max-width: 500px) {
|
|
53
|
+
.onlyMobile {
|
|
54
|
+
display: block !important;
|
|
55
|
+
}
|
|
56
|
+
.onlyDesktop {
|
|
57
|
+
display: none !important;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
</mj-style>
|
|
61
|
+
|
|
62
|
+
<mj-attributes>
|
|
63
|
+
<mj-all
|
|
64
|
+
font-family="${config.style.font}, Arial, Helvetica, sans-serif"
|
|
65
|
+
/>
|
|
66
|
+
<mj-text
|
|
67
|
+
font-size="18px"
|
|
68
|
+
line-height="1.5"
|
|
69
|
+
color="${config.style.textColor}"
|
|
70
|
+
/>
|
|
71
|
+
<mj-body width="700px" />
|
|
72
|
+
</mj-attributes>
|
|
73
|
+
</mj-head>
|
|
74
|
+
|
|
75
|
+
<mj-body background-color="${config.style.backgroundColor}">
|
|
76
|
+
${mappedContent}
|
|
77
|
+
</mj-body>
|
|
78
|
+
</mjml>
|
|
79
79
|
`);
|
|
80
80
|
return (data) => {
|
|
81
81
|
let { html, errors } = (0, mjml_1.default)(builder(data), {
|
|
@@ -14,15 +14,15 @@ exports.SCHEMA = typebox_1.Type.Object({
|
|
|
14
14
|
content: typebox_1.Type.Array(typebox_1.Type.String())
|
|
15
15
|
});
|
|
16
16
|
function build(config) {
|
|
17
|
-
return `
|
|
18
|
-
<mj-section padding="0">
|
|
19
|
-
<mj-column padding-top="${config.padding.top}px">
|
|
20
|
-
${config.content.map(item => `
|
|
21
|
-
<mj-text font-size="${config.size}px" font-weight="${config.weight}" color="${config.color}">
|
|
22
|
-
${item}
|
|
23
|
-
</mj-text>
|
|
24
|
-
`).join('')}
|
|
25
|
-
</mj-column>
|
|
26
|
-
</mj-section>
|
|
17
|
+
return `
|
|
18
|
+
<mj-section padding="0">
|
|
19
|
+
<mj-column padding-top="${config.padding.top}px">
|
|
20
|
+
${config.content.map(item => `
|
|
21
|
+
<mj-text font-size="${config.size}px" font-weight="${config.weight}" color="${config.color}">
|
|
22
|
+
${item}
|
|
23
|
+
</mj-text>
|
|
24
|
+
`).join('')}
|
|
25
|
+
</mj-column>
|
|
26
|
+
</mj-section>
|
|
27
27
|
`;
|
|
28
28
|
}
|
package/dist/react-ui/loader.js
CHANGED
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = Loader;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_whispr_1 = require("../react-whispr");
|
|
6
|
-
const spinKeyframes = `
|
|
7
|
-
@keyframes spin {
|
|
8
|
-
from { transform: rotate(0deg); }
|
|
9
|
-
to { transform: rotate(360deg); }
|
|
10
|
-
}
|
|
6
|
+
const spinKeyframes = `
|
|
7
|
+
@keyframes spin {
|
|
8
|
+
from { transform: rotate(0deg); }
|
|
9
|
+
to { transform: rotate(360deg); }
|
|
10
|
+
}
|
|
11
11
|
`;
|
|
12
12
|
if (typeof document !== 'undefined') {
|
|
13
13
|
const style = document.createElement('style');
|
package/dist/react-ui/modal.js
CHANGED
|
@@ -3,17 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = ModalComponent;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const slideUpKeyframes = `
|
|
7
|
-
@keyframes slide-up {
|
|
8
|
-
from {
|
|
9
|
-
transform: translateY(20px);
|
|
10
|
-
opacity: 0;
|
|
11
|
-
}
|
|
12
|
-
to {
|
|
13
|
-
transform: translateY(0);
|
|
14
|
-
opacity: 1;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
6
|
+
const slideUpKeyframes = `
|
|
7
|
+
@keyframes slide-up {
|
|
8
|
+
from {
|
|
9
|
+
transform: translateY(20px);
|
|
10
|
+
opacity: 0;
|
|
11
|
+
}
|
|
12
|
+
to {
|
|
13
|
+
transform: translateY(0);
|
|
14
|
+
opacity: 1;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
17
|
`;
|
|
18
18
|
if (typeof document !== 'undefined') {
|
|
19
19
|
const style = document.createElement('style');
|
package/dist/react-whispr.js
CHANGED
|
@@ -438,3 +438,45 @@ function useAsyncInput(value, setValue, handler, setPending = () => { }) {
|
|
|
438
438
|
result,
|
|
439
439
|
];
|
|
440
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* Creates a Whispr from an external (non-reactive) data source.
|
|
443
|
+
*
|
|
444
|
+
* Unlike `Whispr.from`, which derives state from other Whisprs, this function
|
|
445
|
+
* bridges an arbitrary data generator into Whispr's reactive system — useful
|
|
446
|
+
* when your source of truth lives outside the Whispr graph (e.g. a DOM API,
|
|
447
|
+
* a global store, or a plain function).
|
|
448
|
+
*
|
|
449
|
+
* @param getData - A function that returns the current value of the external source.
|
|
450
|
+
* Called once immediately to seed the Whispr, then on every refresh.
|
|
451
|
+
* @param interval - If provided, the Whispr will automatically re-poll `getData`
|
|
452
|
+
* every `interval` milliseconds. Pass `null` to disable auto-refresh.
|
|
453
|
+
* @returns A tuple of:
|
|
454
|
+
* - The resulting `Whispr<T>`, seeded with the initial value from `getData`.
|
|
455
|
+
* - A `refresh` function that manually re-reads `getData` and pushes the new
|
|
456
|
+
* value into the Whispr. Hook this wherever you have a hint that the
|
|
457
|
+
* external source may have changed.
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* const [windowSize, refreshSize] = whisprFromExternal(
|
|
461
|
+
* () => ({ width: window.innerWidth, height: window.innerHeight }),
|
|
462
|
+
* null,
|
|
463
|
+
* );
|
|
464
|
+
*
|
|
465
|
+
* window.addEventListener("resize", refreshSize);
|
|
466
|
+
*/
|
|
467
|
+
function whisprFromExternal(getData, interval) {
|
|
468
|
+
const intervalRef = (() => {
|
|
469
|
+
return interval !== null ?
|
|
470
|
+
setInterval(() => {
|
|
471
|
+
setValue(getData());
|
|
472
|
+
}, interval) :
|
|
473
|
+
null;
|
|
474
|
+
})();
|
|
475
|
+
const cleanup = () => {
|
|
476
|
+
if (intervalRef !== null) {
|
|
477
|
+
clearInterval(intervalRef);
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
const [value, setValue] = whispr_1.Whispr.create(getData(), cleanup);
|
|
481
|
+
return [value, () => setValue(getData())];
|
|
482
|
+
}
|