Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@karhu/react

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@karhu/react - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

16

lib/index.d.ts
import React from 'react';
import Karhu from '@karhu/core';
import { Command, UnregisteredCommand, EntryGraph } from '@karhu/core/lib/types';
declare type KarhuContextProps = {
karhu: Karhu;
};
declare type ChildrenProviderObject = {

@@ -11,13 +14,10 @@ commandsList: Command[];

};
export declare const AddCommand: (props: AddCommandProps) => JSX.Element;
export declare const AddCommand: (props: AddCommandProps) => null;
export declare function useKarhu(input: string): ChildrenProviderObject;
declare type Props = {
children: (obj: ChildrenProviderObject) => {};
children: (obj: ChildrenProviderObject) => JSX.Element;
input: string;
};
export declare class KarhuComponent extends React.Component<Props> {
karhu?: Karhu;
exec: (id: string) => EntryGraph;
render(): JSX.Element;
}
declare const Provider: React.ProviderExoticComponent<React.ProviderProps<Karhu>>, Consumer: React.ExoticComponent<React.ConsumerProps<Karhu>>;
export declare function KarhuComponent(props: Props): JSX.Element;
declare const Provider: React.ProviderExoticComponent<React.ProviderProps<Partial<KarhuContextProps>>>, Consumer: React.ExoticComponent<React.ConsumerProps<Partial<KarhuContextProps>>>;
export { Provider as KarhuProvider, Consumer as KarhuConsumer };
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importDefault(require("react"));
var core_1 = __importDefault(require("@karhu/core"));
var karhu = new core_1.default();
var KarhuContext = react_1.default.createContext(karhu);
var react_1 = __importStar(require("react"));
var KarhuContext = react_1.default.createContext({});
exports.AddCommand = function (props) {
return (react_1.default.createElement(Consumer, null, function (karhu) {
karhu.addCommand(props.command);
return null;
}));
var karhuContext = react_1.useContext(KarhuContext);
var karhu = karhuContext.karhu;
react_1.useEffect(function () {
if (karhu) {
karhu.addCommand(props.command);
}
}, []);
return null;
};
var KarhuComponent = (function (_super) {
__extends(KarhuComponent, _super);
function KarhuComponent() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.exec = function (id) {
if (!_this.karhu) {
throw new Error('Karhu not found');
}
var tree = _this.karhu.runCommand(id, _this.props.input);
return tree;
};
return _this;
function useKarhu(input) {
var karhuContext = react_1.useContext(KarhuContext);
var karhu = karhuContext.karhu;
var _a = __read(react_1.useState([]), 2), commandsList = _a[0], setCommandsList = _a[1];
if (!karhu) {
throw new Error('Karhu not found');
}
KarhuComponent.prototype.render = function () {
var _this = this;
var children = this.props.children;
var exec = this.exec;
return (react_1.default.createElement(Consumer, null, function (karhu) {
_this.karhu = karhu;
var commandsList = _this.karhu.findMatchingCommands(_this.props.input);
return children({ commandsList: commandsList, exec: exec });
}));
react_1.useEffect(function () {
var list = karhu.findMatchingCommands(input);
setCommandsList(list);
}, [input]);
var exec = function (id) {
return karhu.runCommand(id, input);
};
return KarhuComponent;
}(react_1.default.Component));
return { commandsList: commandsList, exec: exec };
}
exports.useKarhu = useKarhu;
function KarhuComponent(props) {
var children = props.children;
var _a = useKarhu(props.input), exec = _a.exec, commandsList = _a.commandsList;
return children({ commandsList: commandsList, exec: exec });
}
exports.KarhuComponent = KarhuComponent;

@@ -58,2 +64,2 @@ var Provider = KarhuContext.Provider, Consumer = KarhuContext.Consumer;

exports.KarhuConsumer = Consumer;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiLi8iLCJzb3VyY2VzIjpbImluZGV4LnRzeCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSxnREFBMEI7QUFDMUIscURBQWdDO0FBR2hDLElBQU0sS0FBSyxHQUFHLElBQUksY0FBSyxFQUFFLENBQUM7QUFFMUIsSUFBTSxZQUFZLEdBQUcsZUFBSyxDQUFDLGFBQWEsQ0FBQyxLQUFLLENBQUMsQ0FBQztBQVduQyxRQUFBLFVBQVUsR0FBRyxVQUFDLEtBQXNCO0lBQy9DLE9BQU8sQ0FDTCw4QkFBQyxRQUFRLFFBQ04sVUFBQSxLQUFLO1FBQ0osS0FBSyxDQUFDLFVBQVUsQ0FBQyxLQUFLLENBQUMsT0FBTyxDQUFDLENBQUM7UUFDaEMsT0FBTyxJQUFJLENBQUM7SUFDZCxDQUFDLENBQ1EsQ0FDWixDQUFDO0FBQ0osQ0FBQyxDQUFDO0FBTUY7SUFBb0Msa0NBQXNCO0lBQTFEO1FBQUEscUVBc0JDO1FBcEJDLFVBQUksR0FBRyxVQUFDLEVBQVU7WUFDaEIsSUFBSSxDQUFDLEtBQUksQ0FBQyxLQUFLLEVBQUU7Z0JBQ2YsTUFBTSxJQUFJLEtBQUssQ0FBQyxpQkFBaUIsQ0FBQyxDQ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YsT0FBTyxFQUFFLFlBQVksY0FBQSxFQUFFLElBQUksTUFBQSxFQUFFLENBQUM7QUFDaEMsQ0FBQztBQXJCRCw0QkFxQkM7QUFNRCxTQUFnQixjQUFjLENBQUMsS0FBWTtJQUNqQyxJQUFBLHlCQUFRLENBQVc7SUFDckIsSUFBQSwwQkFBOEMsRUFBNUMsY0FBSSxFQUFFLDhCQUFzQyxDQUFDO0lBQ3JELE9BQU8sUUFBUSxDQUFDLEVBQUUsWUFBWSxjQUFBLEVBQUUsSUFBSSxNQUFBLEVBQUUsQ0FBQyxDQUFDO0FBQzFDLENBQUM7QUFKRCx3Q0FJQztBQUVPLElBQUEsZ0NBQVEsRUFBRSxnQ0FBUSxDQUFrQjtBQUN2QixpQ0FBYTtBQUFjLGlDQUFhIn0=
{
"name": "@karhu/react",
"version": "0.6.0",
"version": "0.7.0",
"description": "React bindings and components for Karhu",

@@ -9,2 +9,4 @@ "main": "lib/index.js",

"tsc": "tsc",
"test": "jest --no-cache --coverage --config jest.config.js",
"dev": "jest --no-cache --config jest.config.js --watch",
"preparePublish": "echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc",

@@ -18,14 +20,14 @@ "prepublishOnly": "npm run preparePublish",

"devDependencies": {
"@types/react": "^16.7.6",
"@types/react-dom": "^16.0.11",
"react": "^16.6.3",
"react-dom": "^16.6.3"
"@types/jest": "^24.0.6",
"jest": "^24.1.0",
"react-testing-library": "^5.5.3",
"ts-jest": "^23.10.5"
},
"peerDependencies": {
"@karhu/core": "*",
"react": "^16.6.3",
"react-dom": "^16.6.3"
"react": "^16.8.2",
"react-dom": "^16.8.2"
},
"dependencies": {
"@karhu/core": "^0.6.0"
"@karhu/core": "^0.7.0"
},

@@ -43,3 +45,3 @@ "directories": {

},
"gitHead": "bae989e6ef95d299fff2e8b02b4ab6d397ac83f5"
"gitHead": "fcb9e1375421a1612eab80bb91fa9a093c73d491"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc