@kwirthmagnify/kwirth-common-front 0.5.3 → 0.5.7

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.
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ interface IMarkdownViewerProps {
3
+ content: string;
4
+ style?: React.CSSProperties;
5
+ }
6
+ declare const MarkdownViewer: React.FC<IMarkdownViewerProps>;
7
+ export { MarkdownViewer };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MarkdownViewer = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const react_markdown_1 = __importDefault(require("react-markdown"));
9
+ const MarkdownViewer = ({ content, style }) => {
10
+ return (react_1.default.createElement("div", { style: Object.assign({ fontSize: 14, lineHeight: 1.6 }, style) },
11
+ react_1.default.createElement(react_markdown_1.default, null, content)));
12
+ };
13
+ exports.MarkdownViewer = MarkdownViewer;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  import { FC, ReactNode } from 'react';
2
2
  import { EInstanceConfigView, EChannelRefreshAction, ENotifyLevel, IChannelMessageAction, IChannelSettings, IChannelRequirements } from '@kwirthmagnify/kwirth-common';
3
+ type CloseWithId = (id: string) => void;
4
+ type CloseNoId = () => void;
5
+ export declare const useKeyboard: (onEscape?: CloseWithId | CloseNoId, id?: string) => void;
3
6
  export { EChannelRefreshAction, ENotifyLevel };
4
7
  export type { EInstanceConfigView, IChannelMessageAction, IChannelSettings, IChannelRequirements };
5
8
  export type TChannelConstructor = (new () => IChannel) | undefined;
@@ -15,7 +18,7 @@ export interface IChannelObject {
15
18
  config: any;
16
19
  data: any;
17
20
  accessString?: string;
18
- isElectron: boolean;
21
+ isDesktop: boolean;
19
22
  channelId: string;
20
23
  frontChannels?: Map<string, TChannelConstructor>;
21
24
  notifications?: any[];
@@ -30,6 +33,7 @@ export interface IChannelObject {
30
33
  setPalette?: (palette: string) => void;
31
34
  notify?: (channelId: string | undefined, level: ENotifyLevel, message: string) => void;
32
35
  exit?: () => void;
36
+ stopChannel?: () => void;
33
37
  }
34
38
  export interface ISetupProps {
35
39
  onChannelSetupClosed: (channel: IChannel, channelSettings: IChannelSettings, start: boolean, defaultValues: boolean) => void;
@@ -67,3 +71,5 @@ export interface IChannel {
67
71
  getExternalHelpContent?: () => ReactNode;
68
72
  onExternalConfigApply?: (channelObject: IChannelObject, values: any) => boolean;
69
73
  }
74
+ export declare const cleanANSI: (text: string) => string;
75
+ export { MarkdownViewer } from './MarkdownViewer';
package/dist/index.js CHANGED
@@ -1,6 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ENotifyLevel = exports.EChannelRefreshAction = void 0;
3
+ exports.MarkdownViewer = exports.cleanANSI = exports.ENotifyLevel = exports.EChannelRefreshAction = exports.useKeyboard = void 0;
4
+ const react_1 = require("react");
4
5
  const kwirth_common_1 = require("@kwirthmagnify/kwirth-common");
5
6
  Object.defineProperty(exports, "EChannelRefreshAction", { enumerable: true, get: function () { return kwirth_common_1.EChannelRefreshAction; } });
6
7
  Object.defineProperty(exports, "ENotifyLevel", { enumerable: true, get: function () { return kwirth_common_1.ENotifyLevel; } });
8
+ const useKeyboard = (onEscape, id) => {
9
+ (0, react_1.useEffect)(() => {
10
+ const handleKeyDown = (event) => {
11
+ event.stopPropagation();
12
+ if (event.key === 'Escape' && onEscape) {
13
+ if (id)
14
+ onEscape(id);
15
+ else
16
+ onEscape();
17
+ }
18
+ };
19
+ const handleKeyUp = (event) => {
20
+ event.stopPropagation();
21
+ };
22
+ window.addEventListener('keydown', handleKeyDown, true);
23
+ window.addEventListener('keyup', handleKeyUp, true);
24
+ return () => {
25
+ window.removeEventListener('keydown', handleKeyDown, true);
26
+ window.removeEventListener('keyup', handleKeyUp, true);
27
+ };
28
+ }, [onEscape, id]);
29
+ };
30
+ exports.useKeyboard = useKeyboard;
31
+ const cleanANSI = (text) => text.replace(/\x1b\[[0-9;]*[mKHVfJrcegH]|\x1b\[\d*n/g, '');
32
+ exports.cleanANSI = cleanANSI;
33
+ var MarkdownViewer_1 = require("./MarkdownViewer");
34
+ Object.defineProperty(exports, "MarkdownViewer", { enumerable: true, get: function () { return MarkdownViewer_1.MarkdownViewer; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kwirthmagnify/kwirth-common-front",
3
- "version": "0.5.3",
3
+ "version": "0.5.7",
4
4
  "description": "Frontend channel interfaces for Kwirth plugins and channels",
5
5
  "scripts": {
6
6
  "build": "del .\\dist\\* /s /q && tsc"
@@ -18,7 +18,8 @@
18
18
  "author": "Julio Fernandez",
19
19
  "license": "ISC",
20
20
  "dependencies": {
21
- "@kwirthmagnify/kwirth-common": "^0.5.1"
21
+ "@kwirthmagnify/kwirth-common": "^0.5.1",
22
+ "react-markdown": "^10.1.0"
22
23
  },
23
24
  "peerDependencies": {
24
25
  "react": ">=18.0.0"