@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.
Files changed (59) hide show
  1. package/dist/build.js +20 -44
  2. package/dist/esm/build.d.ts +2 -0
  3. package/dist/esm/build.js +10 -0
  4. package/dist/esm/console-script/console-script.decorator.js +10 -0
  5. package/dist/esm/console-script/console-script.interface.js +4 -0
  6. package/dist/esm/console-script/index.js +3 -0
  7. package/dist/esm/esbuild/build.js +29 -0
  8. package/dist/esm/esbuild/plugins/xmonkey-output-stats-plugin.js +18 -0
  9. package/dist/esm/esbuild/plugins/xmonkey-strip-metadata-plugin.js +77 -0
  10. package/dist/esm/esbuild/plugins/xmonkey-styles-plugin.js +36 -0
  11. package/dist/esm/hooks/index.js +30 -0
  12. package/dist/esm/index.js +1 -0
  13. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
  14. package/dist/esm/types.js +2 -0
  15. package/dist/esm/ui-script/index.js +3 -0
  16. package/dist/esm/ui-script/ui-script.decorator.js +20 -0
  17. package/dist/esm/ui-script/ui-script.interface.js +2 -0
  18. package/dist/esm/utils/get-storage-key-id-from-string.js +4 -0
  19. package/dist/esm/utils/is-null-or-undefined.js +5 -0
  20. package/dist/esm/utils/sleep.js +4 -0
  21. package/dist/esm/x-monkey-window-component.js +17 -0
  22. package/dist/styles/_colors.scss +4 -1
  23. package/dist/styles/_xmonkey-wrapper.scss +15 -13
  24. package/package.json +23 -24
  25. package/dist/build.d.ts +0 -1
  26. package/dist/console-script/console-script.decorator.js +0 -9
  27. package/dist/console-script/console-script.interface.js +0 -3
  28. package/dist/console-script/index.js +0 -2
  29. package/dist/esbuild/build.js +0 -28
  30. package/dist/esbuild/plugins/xmonkey-output-stats-plugin.js +0 -17
  31. package/dist/esbuild/plugins/xmonkey-strip-metadata-plugin.js +0 -76
  32. package/dist/esbuild/plugins/xmonkey-styles-plugin.js +0 -34
  33. package/dist/hooks/index.js +0 -29
  34. package/dist/index.js +0 -0
  35. package/dist/types.js +0 -1
  36. package/dist/ui-script/index.js +0 -2
  37. package/dist/ui-script/ui-script.decorator.js +0 -19
  38. package/dist/ui-script/ui-script.interface.js +0 -1
  39. package/dist/utils/get-storage-key-id-from-string.js +0 -3
  40. package/dist/utils/is-null-or-undefined.js +0 -4
  41. package/dist/utils/sleep.js +0 -3
  42. package/dist/x-monkey-window-component.js +0 -16
  43. /package/dist/{console-script → esm/console-script}/console-script.decorator.d.ts +0 -0
  44. /package/dist/{console-script → esm/console-script}/console-script.interface.d.ts +0 -0
  45. /package/dist/{console-script → esm/console-script}/index.d.ts +0 -0
  46. /package/dist/{esbuild → esm/esbuild}/build.d.ts +0 -0
  47. /package/dist/{esbuild → esm/esbuild}/plugins/xmonkey-output-stats-plugin.d.ts +0 -0
  48. /package/dist/{esbuild → esm/esbuild}/plugins/xmonkey-strip-metadata-plugin.d.ts +0 -0
  49. /package/dist/{esbuild → esm/esbuild}/plugins/xmonkey-styles-plugin.d.ts +0 -0
  50. /package/dist/{hooks → esm/hooks}/index.d.ts +0 -0
  51. /package/dist/{index.d.ts → esm/index.d.ts} +0 -0
  52. /package/dist/{types.d.ts → esm/types.d.ts} +0 -0
  53. /package/dist/{ui-script → esm/ui-script}/index.d.ts +0 -0
  54. /package/dist/{ui-script → esm/ui-script}/ui-script.decorator.d.ts +0 -0
  55. /package/dist/{ui-script → esm/ui-script}/ui-script.interface.d.ts +0 -0
  56. /package/dist/{utils → esm/utils}/get-storage-key-id-from-string.d.ts +0 -0
  57. /package/dist/{utils → esm/utils}/is-null-or-undefined.d.ts +0 -0
  58. /package/dist/{utils → esm/utils}/sleep.d.ts +0 -0
  59. /package/dist/{x-monkey-window-component.d.ts → esm/x-monkey-window-component.d.ts} +0 -0
@@ -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 {};
@@ -1,2 +0,0 @@
1
- export * from "./ui-script.decorator.js";
2
- export * from "./ui-script.interface.js";
@@ -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 {};
@@ -1,3 +0,0 @@
1
- export function getStorageKeyIdFromString(data) {
2
- return "xmonkey-" + data.replace(/[^a-zA-Z0-9.-]/g, "").toLowerCase();
3
- }
@@ -1,4 +0,0 @@
1
- export const isNullOrUndefined = (value) => value === null || value === undefined;
2
- export function isNullOrEmptyOrUndefined(value) {
3
- return isNullOrUndefined(value) || value === "" || value.toString().trim() === "";
4
- }
@@ -1,3 +0,0 @@
1
- export function sleep(ms) {
2
- return new Promise((resolve) => setTimeout(resolve, ms));
3
- }
@@ -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