@lukaskj/xmonkey 2.2.6 → 2.2.8
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/dist/build.js +20 -44
- package/dist/esm/build.d.ts +2 -0
- package/dist/esm/build.js +10 -0
- package/dist/esm/console-script/console-script.decorator.js +10 -0
- package/dist/esm/console-script/console-script.interface.js +4 -0
- package/dist/esm/console-script/index.js +3 -0
- package/dist/esm/esbuild/build.js +29 -0
- package/dist/esm/esbuild/plugins/xmonkey-output-stats-plugin.js +18 -0
- package/dist/esm/esbuild/plugins/xmonkey-strip-metadata-plugin.js +77 -0
- package/dist/esm/esbuild/plugins/xmonkey-styles-plugin.js +36 -0
- package/dist/esm/hooks/index.js +30 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/ui-script/index.js +3 -0
- package/dist/esm/ui-script/ui-script.decorator.js +20 -0
- package/dist/esm/ui-script/ui-script.interface.js +2 -0
- package/dist/esm/utils/get-storage-key-id-from-string.js +4 -0
- package/dist/esm/utils/is-null-or-undefined.js +5 -0
- package/dist/esm/utils/sleep.js +4 -0
- package/dist/esm/x-monkey-window-component.js +17 -0
- package/dist/styles/_colors.scss +4 -1
- package/dist/styles/_xmonkey-wrapper.scss +15 -13
- package/package.json +23 -24
- package/dist/build.d.ts +0 -1
- package/dist/console-script/console-script.decorator.js +0 -9
- package/dist/console-script/console-script.interface.js +0 -3
- package/dist/console-script/index.js +0 -2
- package/dist/esbuild/build.js +0 -28
- package/dist/esbuild/plugins/xmonkey-output-stats-plugin.js +0 -17
- package/dist/esbuild/plugins/xmonkey-strip-metadata-plugin.js +0 -76
- package/dist/esbuild/plugins/xmonkey-styles-plugin.js +0 -34
- package/dist/hooks/index.js +0 -29
- package/dist/index.js +0 -0
- package/dist/types.js +0 -1
- package/dist/ui-script/index.js +0 -2
- package/dist/ui-script/ui-script.decorator.js +0 -19
- package/dist/ui-script/ui-script.interface.js +0 -1
- package/dist/utils/get-storage-key-id-from-string.js +0 -3
- package/dist/utils/is-null-or-undefined.js +0 -4
- package/dist/utils/sleep.js +0 -3
- package/dist/x-monkey-window-component.js +0 -16
- /package/dist/{console-script → esm/console-script}/console-script.decorator.d.ts +0 -0
- /package/dist/{console-script → esm/console-script}/console-script.interface.d.ts +0 -0
- /package/dist/{console-script → esm/console-script}/index.d.ts +0 -0
- /package/dist/{esbuild → esm/esbuild}/build.d.ts +0 -0
- /package/dist/{esbuild → esm/esbuild}/plugins/xmonkey-output-stats-plugin.d.ts +0 -0
- /package/dist/{esbuild → esm/esbuild}/plugins/xmonkey-strip-metadata-plugin.d.ts +0 -0
- /package/dist/{esbuild → esm/esbuild}/plugins/xmonkey-styles-plugin.d.ts +0 -0
- /package/dist/{hooks → esm/hooks}/index.d.ts +0 -0
- /package/dist/{index.d.ts → esm/index.d.ts} +0 -0
- /package/dist/{types.d.ts → esm/types.d.ts} +0 -0
- /package/dist/{ui-script → esm/ui-script}/index.d.ts +0 -0
- /package/dist/{ui-script → esm/ui-script}/ui-script.decorator.d.ts +0 -0
- /package/dist/{ui-script → esm/ui-script}/ui-script.interface.d.ts +0 -0
- /package/dist/{utils → esm/utils}/get-storage-key-id-from-string.d.ts +0 -0
- /package/dist/{utils → esm/utils}/is-null-or-undefined.d.ts +0 -0
- /package/dist/{utils → esm/utils}/sleep.d.ts +0 -0
- /package/dist/{x-monkey-window-component.d.ts → esm/x-monkey-window-component.d.ts} +0 -0
package/dist/hooks/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { useCallback, useState, useEffect } from "preact/hooks";
|
|
2
|
-
export function useLocalStorage(key, defaultValue) {
|
|
3
|
-
return useStorage(key, defaultValue, window.localStorage);
|
|
4
|
-
}
|
|
5
|
-
export function useSessionStorage(key, defaultValue) {
|
|
6
|
-
return useStorage(key, defaultValue, window.sessionStorage);
|
|
7
|
-
}
|
|
8
|
-
function useStorage(key, defaultValue, storageObject) {
|
|
9
|
-
const [value, setValue] = useState(() => {
|
|
10
|
-
const jsonValue = storageObject.getItem(key);
|
|
11
|
-
if (jsonValue != null)
|
|
12
|
-
return JSON.parse(jsonValue);
|
|
13
|
-
if (typeof defaultValue === "function") {
|
|
14
|
-
return defaultValue();
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
return defaultValue;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
if (value === undefined)
|
|
22
|
-
return storageObject.removeItem(key);
|
|
23
|
-
storageObject.setItem(key, JSON.stringify(value));
|
|
24
|
-
}, [key, value, storageObject]);
|
|
25
|
-
const remove = useCallback(() => {
|
|
26
|
-
setValue(undefined);
|
|
27
|
-
}, []);
|
|
28
|
-
return [value, setValue, remove];
|
|
29
|
-
}
|
package/dist/index.js
DELETED
|
File without changes
|
package/dist/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/ui-script/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { h, render } from "preact";
|
|
2
|
-
import { XMonkeyWindowComponent } from "../x-monkey-window-component.js";
|
|
3
|
-
export function UiScript(_metadata) {
|
|
4
|
-
return function (_target) {
|
|
5
|
-
const scriptObject = new _target();
|
|
6
|
-
const rootComponent = xMonkeyWrapperElement();
|
|
7
|
-
render(h(XMonkeyWindowComponent, { title: scriptObject.title ?? "" }, scriptObject.render()), rootComponent);
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
function xMonkeyWrapperElement() {
|
|
11
|
-
const ID = "__xmwr";
|
|
12
|
-
let div = document.getElementById(ID);
|
|
13
|
-
if (div)
|
|
14
|
-
return div;
|
|
15
|
-
div = document.createElement("div");
|
|
16
|
-
div.id = ID;
|
|
17
|
-
document.body.appendChild(div);
|
|
18
|
-
return div;
|
|
19
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/utils/sleep.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
-
import { useSessionStorage } from "./hooks";
|
|
3
|
-
import { useMemo } from "preact/hooks";
|
|
4
|
-
import { getStorageKeyIdFromString } from "./utils/get-storage-key-id-from-string";
|
|
5
|
-
export function XMonkeyWindowComponent(props) {
|
|
6
|
-
const storageKey = useMemo(() => getStorageKeyIdFromString(props.title), [props.title]);
|
|
7
|
-
const [minimized, setMinimized] = useSessionStorage(storageKey, false);
|
|
8
|
-
function toggleMinimize() {
|
|
9
|
-
setMinimized(!minimized);
|
|
10
|
-
}
|
|
11
|
-
return (_jsxs("div", { className: `xmwr_c d-f fd-c ai-c jc-sb` + (minimized ? " minim" : ""), children: [_jsxs("div", { className: "xmwr-h w-100 m0 d-f fd-r jc-c bg-primary noselect", children: [_jsx("div", { className: "xmwr-title m0", children: props.title }), _jsx(MinimizeButton, { toggleMinimize: toggleMinimize, minimized: minimized })] }), _jsx("div", { className: "xmwr-b w-100 d-f jc-c", children: props.children })] }));
|
|
12
|
-
}
|
|
13
|
-
function MinimizeButton({ minimized, toggleMinimize }) {
|
|
14
|
-
const minimizeChar = minimized ? "+" : "-";
|
|
15
|
-
return (_jsx("div", { className: "xmwr-x m0", onClick: () => toggleMinimize(), children: minimizeChar }));
|
|
16
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|