Skip to content

Commit

Permalink
looks like we have .d.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
StoneCypher committed Feb 1, 2020
1 parent 3047b38 commit b797c1e
Show file tree
Hide file tree
Showing 14 changed files with 278 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,5 @@
* [[`3047b388b9`](https://github.com/StoneCypher/jssm/commit/3047b388b9)] - Merge pull request #398 from StoneCypher/InvertRollupAndTypescript (John Haugeland)
* [[`44c69de2cd`](https://github.com/StoneCypher/jssm/commit/44c69de2cd)] - other small cleanup (John Haugeland)
* [[`f528dafa9f`](https://github.com/StoneCypher/jssm/commit/f528dafa9f)] - save and push the package too, john (John Haugeland)
* [[`8a535bfc47`](https://github.com/StoneCypher/jssm/commit/8a535bfc47)] - move shell surgery to node to get through mac (John Haugeland)
* [[`7f6f597044`](https://github.com/StoneCypher/jssm/commit/7f6f597044)] - fixing coverage, es6 package.json surgery (John Haugeland)
Expand Down
2 changes: 1 addition & 1 deletion dist/es6/version.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/jssm.es5.cjs.js
Expand Up @@ -15598,7 +15598,7 @@ function peg$parse(input, options) {
}
}

const version = "5.31.0";
const version = "5.31.1";

function arrow_direction(arrow) {
switch (String(arrow)) {
Expand Down
2 changes: 1 addition & 1 deletion dist/jssm.es5.cjs.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/jssm.iife.js
Expand Up @@ -15597,7 +15597,7 @@ var jssm = (function (exports) {
}
}

const version = "5.31.0";
const version = "5.31.1";

function arrow_direction(arrow) {
switch (String(arrow)) {
Expand Down
2 changes: 1 addition & 1 deletion dist/jssm.iife.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/lib/index.html
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset='utf-8'>
<title>jssm 5.31.0 | Documentation</title>
<title>jssm 5.31.1 | Documentation</title>
<meta name='description' content='A Javascript finite state machine (FSM) with a terse DSL and a simple API. Well tested, and typed with Flowtype. MIT License.'>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<link href='assets/bass.css' rel='stylesheet'>
Expand All @@ -15,7 +15,7 @@
<div id='split-left' class='overflow-auto fs0 height-viewport-100'>
<div class='py1 px2'>
<h3 class='mb0 no-anchor'>jssm</h3>
<div class='mb1'><code>5.31.0</code></div>
<div class='mb1'><code>5.31.1</code></div>
<input
placeholder='Filter'
id='filter-input'
Expand Down
6 changes: 6 additions & 0 deletions jssm-dot.d.ts
@@ -0,0 +1,6 @@
declare function peg$SyntaxError(message: any, expected: any, found: any, location: any): void;
declare namespace peg$SyntaxError {
var buildMessage: (expected: any, found: any) => string;
}
declare function peg$parse(input: any, options: any): any;
export { peg$SyntaxError as SyntaxError, peg$parse as parse };
99 changes: 99 additions & 0 deletions jssm.d.ts
@@ -0,0 +1,99 @@
declare type StateType = string;
import { JssmGenericState, JssmGenericConfig, JssmTransition, JssmTransitionList, JssmMachineInternalState, JssmParseTree, JssmStateDeclaration, JssmArrow, JssmArrowDirection, JssmArrowKind, JssmLayout, FslDirection, FslTheme } from './jssm_types';
import { seq, weighted_rand_select, weighted_sample_select, histograph, weighted_histo_key } from './jssm_util';
import { parse } from './jssm-dot';
import { version } from './version';
declare function arrow_direction(arrow: JssmArrow): JssmArrowDirection;
declare function arrow_left_kind(arrow: JssmArrow): JssmArrowKind;
declare function arrow_right_kind(arrow: JssmArrow): JssmArrowKind;
declare function compile<mDT>(tree: JssmParseTree): JssmGenericConfig<mDT>;
declare function make<mDT>(plan: string): JssmGenericConfig<mDT>;
declare function transfer_state_properties(state_decl: JssmStateDeclaration): JssmStateDeclaration;
declare class Machine<mDT> {
_state: StateType;
_states: Map<StateType, JssmGenericState>;
_edges: Array<JssmTransition<mDT>>;
_edge_map: Map<StateType, Map<StateType, number>>;
_named_transitions: Map<StateType, number>;
_actions: Map<StateType, Map<StateType, number>>;
_reverse_actions: Map<StateType, Map<StateType, number>>;
_reverse_action_targets: Map<StateType, Map<StateType, number>>;
_machine_author?: Array<string>;
_machine_comment?: string;
_machine_contributor?: Array<string>;
_machine_definition?: string;
_machine_language?: string;
_machine_license?: string;
_machine_name?: string;
_machine_version?: string;
_fsl_version?: string;
_raw_state_declaration?: Array<Object>;
_state_declarations: Map<StateType, JssmStateDeclaration>;
_graph_layout: JssmLayout;
_dot_preamble: string;
_arrange_declaration: Array<Array<StateType>>;
_arrange_start_declaration: Array<Array<StateType>>;
_arrange_end_declaration: Array<Array<StateType>>;
_theme: FslTheme;
_flow: FslDirection;
constructor({ start_states, complete, transitions, machine_author, machine_comment, machine_contributor, machine_definition, machine_language, machine_license, machine_name, machine_version, state_declaration, fsl_version, dot_preamble, arrange_declaration, arrange_start_declaration, arrange_end_declaration, theme, flow, graph_layout }: JssmGenericConfig<mDT>);
_new_state(state_config: JssmGenericState): StateType;
state(): StateType;
state_is_final(whichState: StateType): boolean;
is_final(): boolean;
graph_layout(): string;
dot_preamble(): string;
machine_author(): Array<string>;
machine_comment(): string;
machine_contributor(): Array<string>;
machine_definition(): string;
machine_language(): string;
machine_license(): string;
machine_name(): string;
machine_version(): string;
raw_state_declarations(): Array<Object>;
state_declaration(which: StateType): JssmStateDeclaration;
state_declarations(): Map<StateType, Object>;
fsl_version(): string;
machine_state(): JssmMachineInternalState<mDT>;
states(): Array<StateType>;
state_for(whichState: StateType): JssmGenericState;
has_state(whichState: StateType): boolean;
list_edges(): Array<JssmTransition<mDT>>;
list_named_transitions(): Map<StateType, number>;
list_actions(): Array<StateType>;
theme(): FslTheme;
flow(): FslDirection;
get_transition_by_state_names(from: StateType, to: StateType): number;
lookup_transition_for(from: StateType, to: StateType): JssmTransition<mDT>;
list_transitions(whichState?: StateType): JssmTransitionList;
list_entrances(whichState?: StateType): Array<StateType>;
list_exits(whichState?: StateType): Array<StateType>;
probable_exits_for(whichState: StateType): Array<JssmTransition<mDT>>;
probabilistic_transition(): boolean;
probabilistic_walk(n: number): Array<StateType>;
probabilistic_histo_walk(n: number): Map<StateType, number>;
actions(whichState?: StateType): Array<StateType>;
list_states_having_action(whichState: StateType): Array<StateType>;
list_exit_actions(whichState?: StateType): Array<StateType>;
probable_action_exits(whichState?: StateType): Array<any>;
is_unenterable(whichState: StateType): boolean;
has_unenterables(): boolean;
is_terminal(): boolean;
state_is_terminal(whichState: StateType): boolean;
has_terminals(): boolean;
is_complete(): boolean;
state_is_complete(whichState: StateType): boolean;
has_completes(): boolean;
action(name: StateType, newData?: mDT): boolean;
transition(newState: StateType, newData?: mDT): boolean;
force_transition(newState: StateType, newData?: mDT): boolean;
current_action_for(action: StateType): number;
current_action_edge_for(action: StateType): JssmTransition<mDT>;
valid_action(action: StateType, _newData?: mDT): boolean;
valid_transition(newState: StateType, _newData?: mDT): boolean;
valid_force_transition(newState: StateType, _newData?: mDT): boolean;
sm(template_strings: Array<string>, ...remainder: any[]): Machine<mDT>;
}
declare function sm<mDT>(template_strings: Array<string>, ...remainder: any[]): Machine<mDT>;
export { version, transfer_state_properties, Machine, make, parse, compile, sm, arrow_direction, arrow_left_kind, arrow_right_kind, seq, weighted_rand_select, histograph, weighted_sample_select, weighted_histo_key };
151 changes: 151 additions & 0 deletions jssm_types.d.ts
@@ -0,0 +1,151 @@
declare type StateType = string;
declare type JssmSuccess = {
success: true;
};
declare type JssmFailure = {
success: false;
error: any;
};
declare type JssmIncomplete = {
success: 'incomplete';
};
declare type JssmResult = JssmSuccess | JssmFailure | JssmIncomplete;
declare type JssmColor = string;
declare type JssmPermitted = 'required' | 'disallowed';
declare type JssmPermittedOpt = 'required' | 'disallowed' | 'optional';
declare type JssmArrow = '->' | '<->' | '<=->' | '<~->' | '=>' | '<=>' | '<-=>' | '<~=>' | '~>' | '<~>' | '<-~>' | '<=~>';
declare type JssmShape = "box" | "polygon" | "ellipse" | "oval" | "circle" | "point" | "egg" | "triangle" | "plaintext" | "plain" | "diamond" | "trapezium" | "parallelogram" | "house" | "pentagon" | "hexagon" | "septagon" | "octagon" | "doublecircle" | "doubleoctagon" | "tripleoctagon" | "invtriangle" | "invtrapezium" | "invhouse" | "Mdiamond" | "Msquare" | "Mcircle" | "rect" | "rectangle" | "square" | "star" | "none" | "underline" | "cylinder" | "note" | "tab" | "folder" | "box3d" | "component" | "promoter" | "cds" | "terminator" | "utr" | "primersite" | "restrictionsite" | "fivepoverhang" | "threepoverhang" | "noverhang" | "assembly" | "signature" | "insulator" | "ribosite" | "rnastab" | "proteasesite" | "proteinstab" | "rpromoter" | "rarrow" | "larrow" | "lpromoter" | "record";
declare type JssmArrowDirection = 'left' | 'right' | 'both';
declare type JssmArrowKind = 'none' | 'legal' | 'main' | 'forced';
declare type JssmLayout = 'dot' | 'circo' | 'twopi' | 'fdp';
declare type JssmCorner = 'regular' | 'rounded' | 'lined';
declare type JssmLineStyle = 'solid' | 'dashed' | 'dotted';
declare type FslDirection = 'up' | 'right' | 'down' | 'left';
declare type FslTheme = 'default' | 'ocean' | 'modern' | 'none';
declare type JssmTransitionPermitter<DataType> = (OldState: StateType, NewState: StateType, OldData: DataType, NewData: DataType) => boolean;
declare type JssmTransitionPermitterMaybeArray<DataType> = JssmTransitionPermitter<DataType> | Array<JssmTransitionPermitter<DataType>>;
declare type JssmTransition<DataType> = {
from: StateType;
to: StateType;
name?: string;
action?: StateType;
check?: JssmTransitionPermitterMaybeArray<DataType>;
probability?: number;
kind: JssmArrowKind;
forced_only: boolean;
main_path: boolean;
};
declare type JssmTransitions<DataType> = Array<JssmTransition<DataType>>;
declare type JssmTransitionList = {
entrances: Array<StateType>;
exits: Array<StateType>;
};
declare type JssmTransitionCycle = {
key: 'cycle';
value: StateType;
};
declare type JssmTransitionRule = StateType | JssmTransitionCycle;
declare type JssmGenericState = {
from: Array<StateType>;
name: StateType;
to: Array<StateType>;
complete: boolean;
};
declare type JssmMachineInternalState<DataType> = {
internal_state_impl_version: 1;
state: StateType;
states: Map<StateType, JssmGenericState>;
named_transitions: Map<StateType, number>;
edge_map: Map<StateType, Map<StateType, number>>;
actions: Map<StateType, Map<StateType, number>>;
reverse_actions: Map<StateType, Map<StateType, number>>;
edges: Array<JssmTransition<DataType>>;
};
declare type JssmStatePermitter<DataType> = (OldState: StateType, NewState: StateType, OldData: DataType, NewData: DataType) => boolean;
declare type JssmStatePermitterMaybeArray<DataType> = JssmStatePermitter<DataType> | Array<JssmStatePermitter<DataType>>;
declare type JssmGenericMachine<DataType> = {
name?: string;
state: StateType;
data?: DataType;
nodes?: Array<StateType>;
transitions: JssmTransitions<DataType>;
check?: JssmStatePermitterMaybeArray<DataType>;
min_transitions?: number;
max_transitions?: number;
allow_empty?: boolean;
allow_islands?: boolean;
allow_force?: boolean;
keep_history?: boolean | number;
};
declare type JssmStateDeclarationRule = {
key: string;
value: any;
};
declare type JssmStateDeclaration = {
declarations: Array<JssmStateDeclarationRule>;
shape?: JssmShape;
color?: JssmColor;
corners?: JssmCorner;
linestyle?: JssmLineStyle;
textColor?: JssmColor;
backgroundColor?: JssmColor;
borderColor?: JssmColor;
state: StateType;
};
declare type JssmGenericConfig<DataType> = {
graph_layout?: JssmLayout;
complete?: Array<StateType>;
transitions: JssmTransitions<DataType>;
theme?: FslTheme;
flow?: FslDirection;
name?: string;
data?: DataType;
nodes?: Array<StateType>;
check?: JssmStatePermitterMaybeArray<DataType>;
min_exits?: number;
max_exits?: number;
allow_islands?: false;
allow_force?: false;
actions?: JssmPermittedOpt;
simplify_bidi?: boolean;
dot_preamble?: string;
start_states: Array<StateType>;
end_states?: Array<StateType>;
state_declaration?: Array<Object>;
arrange_declaration?: Array<Array<StateType>>;
arrange_start_declaration?: Array<Array<StateType>>;
arrange_end_declaration?: Array<Array<StateType>>;
machine_author?: string | Array<string>;
machine_comment?: string;
machine_contributor?: string | Array<string>;
machine_definition?: string;
machine_language?: string;
machine_license?: string;
machine_name?: string;
machine_version?: string;
fsl_version?: string;
auto_api?: boolean | string;
};
declare type JssmCompileRule = {
agg_as: string;
val: any;
};
declare type JssmCompileSe = {
to: StateType;
se: JssmCompileSe;
kind: JssmArrow;
l_action?: StateType;
r_action?: StateType;
l_probability: number;
r_probability: number;
};
declare type JssmCompileSeStart<DataType> = {
from: DataType;
se: JssmCompileSe;
key: string;
value?: string | number;
name?: string;
};
declare type JssmParseTree = Array<JssmCompileSeStart<StateType>>;
declare type JssmParseFunctionType = (string: any) => JssmParseTree;
export { JssmColor, JssmTransition, JssmTransitions, JssmTransitionList, JssmTransitionRule, JssmArrow, JssmArrowKind, JssmArrowDirection, JssmGenericConfig, JssmGenericState, JssmGenericMachine, JssmParseTree, JssmCompileSe, JssmCompileSeStart, JssmCompileRule, JssmPermitted, JssmPermittedOpt, JssmResult, JssmStateDeclaration, JssmStateDeclarationRule, JssmLayout, JssmParseFunctionType, JssmMachineInternalState, FslDirection, FslTheme };
7 changes: 7 additions & 0 deletions jssm_util.d.ts
@@ -0,0 +1,7 @@
declare const array_box_if_string: (n: any) => any;
declare const weighted_rand_select: Function;
declare const seq: Function;
declare const histograph: Function;
declare const weighted_sample_select: Function;
declare const weighted_histo_key: Function;
export { seq, histograph, weighted_histo_key, weighted_rand_select, weighted_sample_select, array_box_if_string };
6 changes: 3 additions & 3 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "jssm",
"version": "5.31.0",
"version": "5.31.1",
"engines": {
"node": ">=6.0.0"
},
Expand All @@ -22,14 +22,14 @@
"module": "dist/es6/jssm.js",
"scripts": {
"test": "npm run make && npm run justtest",
"rmgenerated": "rm -f src/js/jssm-dot.ts && rm -f src/js/version.ts",
"rmgenerated": "rm -f src/js/jssm-dot.ts && rm -f src/js/version.ts && rm -f *.d.ts",
"justtest": "nyc ava src/js/tests/*.js -v && npm run nyc-html",
"removedir": "rm -rf build && rm -rf dist && rm -rf docs",
"createdir": "mkdir build && mkdir dist && mkdir docs",
"clean": "npm run removedir && npm run rmgenerated && npm run createdir",
"peg": "rm -f src/js/jssm-dot.js && pegjs src/js/jssm-dot.peg && node src/buildjs/fixparser.js && rm src/js/jssm-dot.js",
"rollup": "rollup -c",
"typescript": "tsc --build tsconfig.json",
"typescript": "tsc --build tsconfig.json && cp dist/es6/*.d.ts .",
"makever": "node src/buildjs/makever.js",
"make": "npm run clean && npm run makever && npm run peg && npm run typescript && npm run rollup",
"eslint": "eslint src/js/jssm.ts src/js/jssm_types.ts src/js/tests/*.js",
Expand Down
2 changes: 1 addition & 1 deletion src/js/version.ts
@@ -1,3 +1,3 @@

const version: string = "5.31.0";
const version: string = "5.31.1";
export { version };
2 changes: 2 additions & 0 deletions version.d.ts
@@ -0,0 +1,2 @@
declare const version: string;
export { version };

0 comments on commit b797c1e

Please sign in to comment.