@karhu/core
Advanced tools
Comparing version 0.1.3-alpha.0 to 0.2.1
@@ -7,8 +7,8 @@ import { Command, UnregisteredCommand, EntryGraph } from './types'; | ||
entryGraph: EntryGraph; | ||
constructor(); | ||
constructor(entryGraph?: EntryGraph); | ||
reset(): void; | ||
addCommand(command: UnregisteredCommand): Command; | ||
updateCommand(id: string): (command: Command) => Command; | ||
removeCommand(commandId: string): void; | ||
getCommands(): Command[]; | ||
getEntryGraph(): EntryGraph; | ||
findMatchingCommands(input?: string): Command[]; | ||
@@ -15,0 +15,0 @@ runCommand(id: string, input: string): EntryGraph; |
@@ -37,3 +37,3 @@ "use strict"; | ||
var Karhu = (function () { | ||
function Karhu() { | ||
function Karhu(entryGraph) { | ||
this.commands = []; | ||
@@ -43,2 +43,5 @@ this.contexts = ['default']; | ||
this.reset(); | ||
if (entryGraph) { | ||
this.entryGraph = entryGraph; | ||
} | ||
} | ||
@@ -53,18 +56,15 @@ Karhu.prototype.reset = function () { | ||
var preparedCommand = this._prepareCommand(command); | ||
this.commands.push(preparedCommand); | ||
return preparedCommand; | ||
}; | ||
Karhu.prototype.updateCommand = function (id) { | ||
var _this = this; | ||
return function (command) { | ||
var merged = command; | ||
_this.commands.map(function (c) { | ||
if (c.id === id) { | ||
merged = __assign({}, c, command); | ||
return merged; | ||
var idExists = this.commands.filter(function (c) { return c.id === preparedCommand.id; }).length > 0; | ||
if (!idExists) { | ||
this.commands.push(preparedCommand); | ||
} | ||
else { | ||
this.commands = this.commands.map(function (c) { | ||
if (c.id === preparedCommand.id) { | ||
return preparedCommand; | ||
} | ||
return c; | ||
}); | ||
return merged; | ||
}; | ||
} | ||
return preparedCommand; | ||
}; | ||
@@ -77,2 +77,5 @@ Karhu.prototype.removeCommand = function (commandId) { | ||
}; | ||
Karhu.prototype.getEntryGraph = function () { | ||
return this.entryGraph; | ||
}; | ||
Karhu.prototype.findMatchingCommands = function (input) { | ||
@@ -140,2 +143,2 @@ var _this = this; | ||
exports.default = Karhu; | ||
//# s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QUksR0FBRyxDQUFDLEVBQUUsS0FBSyxFQUFFLEVBQUU7Z0JBQ2pCLEdBQUcsQ0FBQyxJQUFJLENBQUMsS0FBSyxJQUFJLENBQUMsQ0FBQztnQkFDcEIsTUFBTTthQUNQO1NBQ0Y7SUFDSCxDQUFDO0lBRUQsK0JBQWUsR0FBZixVQUFnQixPQUE0QjtRQUMxQyxJQUFNLFVBQVUsR0FBWSxLQUFLLENBQUMsYUFBYSxDQUFDLE9BQU8sQ0FBQyxDQUFDO1FBQ3pELE9BQU8sVUFBVSxDQUFDO0lBQ3BCLENBQUM7SUFuR00sZUFBUyxHQUFXLENBQUMsQ0FBQztJQXFHdEIsbUJBQWEsR0FBRyxVQUFDLE9BQTRCO1FBQ2xELElBQUksQ0FBQyxPQUFPLENBQUMsRUFBRSxFQUFFO1lBQ2YsS0FBSyxDQUFDLFNBQVMsSUFBSSxDQUFDLENBQUM7U0FDdEI7UUFDRCxJQUFNLEVBQUUsR0FBVyxPQUFPLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxPQUFPLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxhQUFXLEtBQUssQ0FBQyxTQUFXLENBQUM7UUFDMUUsSUFBTSxJQUFJLEdBQW9CO1lBQzVCLEtBQUssRUFBRSxDQUFDO1NBQ1QsQ0FBQztRQUNGLGtCQUNFLEVBQUUsSUFBQSxJQUNDLE9BQU8sSUFDVixJQUFJLE1BQUEsSUFDSjtJQUNKLENBQUMsQ0FBQztJQUNKLFlBQUM7Q0FBQSxBQXBIRCxJQW9IQztrQkFwSG9CLEtBQUsifQ== |
/// <reference types="react" /> | ||
export declare type UnregisteredCommand = { | ||
export interface UnregisteredCommand { | ||
id?: string; | ||
@@ -9,6 +9,6 @@ name: string; | ||
render: (c: Command) => JSX.Element | string; | ||
}; | ||
export declare type CommandMetadata = { | ||
} | ||
export interface CommandMetadata { | ||
calls: number; | ||
}; | ||
} | ||
export interface Command extends UnregisteredCommand { | ||
@@ -26,15 +26,15 @@ id: string; | ||
} | ||
export declare type ClassifiedMatch = { | ||
export interface ClassifiedMatch { | ||
id: string; | ||
score: MatchClass; | ||
}; | ||
} | ||
export declare type ClassifiedMatches = ClassifiedMatch[]; | ||
export declare type EntryGraph = any; | ||
export declare type EntryGraphRecord = { | ||
export interface EntryGraphRecord { | ||
id: string; | ||
calls: number; | ||
}; | ||
export declare type ActionsObject = { | ||
} | ||
export interface ActionsObject { | ||
onExec: () => void; | ||
onShow?: (id: string) => void; | ||
}; | ||
} |
{ | ||
"name": "@karhu/core", | ||
"version": "0.1.3-alpha.0", | ||
"description": "> TODO: description", | ||
"version": "0.2.1", | ||
"description": "Core package for Karhu, the lib for powering web app productivity tools", | ||
"author": "Oskar Hane <oh@oskarhane.com>", | ||
@@ -22,3 +22,3 @@ "scripts": { | ||
}, | ||
"gitHead": "182442cb67ae1502ab27f4616a494596454198b9" | ||
"gitHead": "07e2e0cf3fbb9cc1e9903f150beef8345cbdf563" | ||
} |
@@ -1,11 +0,85 @@ | ||
# `karhu` | ||
# `@karhu/core` | ||
> TODO: description | ||
Karhu is a productivity tool for web applications. This package has the core functionality | ||
as the command register and entry graph to adapt command listing to users habits and learn over time. | ||
## Install | ||
```bash | ||
npm install @karhu/core | ||
``` | ||
## Usage | ||
```js | ||
import Karhu from '@karhu/core'; | ||
const karhu = new Karhu(); | ||
``` | ||
const karhu = require('karhu'); | ||
// TODO: DEMONSTRATE API | ||
## API | ||
### `Karhu` | ||
#### `karhu.addCommand()` | ||
Adds a command to the current Karhu instance. | ||
```ts | ||
karhu.addCommand(command: UnregisteredCommand): Command | ||
``` | ||
### `karhu.removeCommand` | ||
Removes a command from teh current Karhu instance. | ||
```ts | ||
karhu.removeCommand(commandId: string): void | ||
``` | ||
### `karhu.findMatchingCommands` | ||
Searches through the existing commands keywords and the current entry graph to | ||
find commands that matches the provided input, and returns them. | ||
```ts | ||
karhu.findMatchingCommands(input?: string): Command[] | ||
``` | ||
### `karhu.runCommand` | ||
Call the command with the provided id's `.actions.onExec()` function. | ||
Returns the updated entry graph. | ||
The input is needed to better sort the commands next time `karhu.findMatchingCommands()` is called. | ||
**Note**: Even though this method is synchronous, the `.onExec()` | ||
function is **not** being called synchronously. It's bering called using `setTimeout(fn, 0)` to not block further executing. | ||
```ts | ||
karhu.runCommand(id: string, input: string): EntryGraph | ||
``` | ||
### `karhu.getCommands` | ||
Returns a list of all registered commands for the Karhu instance. | ||
```ts | ||
karhu.getCommands(): Command[] | ||
``` | ||
### `karhu.getEntryGraph` | ||
Returns the current Entry Graph for the Karhu instance. | ||
```ts | ||
karhu.getEntryGraph(): EntryGraph | ||
``` | ||
### Static `Karhu.createCommand` | ||
Makes an `UnregisteredCommand` -> `Command`. Mostly used internally but can be useful in | ||
some situations. | ||
```ts | ||
Karhu.createCommand (command: UnregisteredCommand): Command | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34677
324
86