jssm 5.79.1 → 5.79.4
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.
- package/CHANGELOG.md +60 -38
- package/README.md +2 -2
- package/dist/es6/jssm-dot.js +1 -1
- package/dist/es6/jssm.d.ts +1 -0
- package/dist/es6/jssm.js +35 -4
- package/dist/es6/jssm_types.d.ts +2 -0
- package/dist/es6/version.js +1 -1
- package/dist/jssm.es5.cjs.js +1 -1
- package/dist/jssm.es5.iife.js +1 -1
- package/jssm.d.ts +1 -0
- package/jssm_types.d.ts +2 -0
- package/package.json +6 -4
package/dist/es6/jssm.d.ts
CHANGED
|
@@ -253,6 +253,7 @@ declare class Machine<mDT> {
|
|
|
253
253
|
_property_keys: Set<string>;
|
|
254
254
|
_default_properties: Map<string, any>;
|
|
255
255
|
_state_properties: Map<string, any>;
|
|
256
|
+
_required_properties: Set<string>;
|
|
256
257
|
_history: JssmHistory<mDT>;
|
|
257
258
|
_history_length: number;
|
|
258
259
|
constructor({ start_states, complete, transitions, machine_author, machine_comment, machine_contributor, machine_definition, machine_language, machine_license, machine_name, machine_version, state_declaration, property_definition, state_property, fsl_version, dot_preamble, arrange_declaration, arrange_start_declaration, arrange_end_declaration, theme, flow, graph_layout, instance_name, history, data }: JssmGenericConfig<mDT>);
|
package/dist/es6/jssm.js
CHANGED
|
@@ -353,12 +353,14 @@ function compile_rule_handler(rule) {
|
|
|
353
353
|
}
|
|
354
354
|
// manually rehandled to make `undefined` as a property safe
|
|
355
355
|
if (rule.key === 'property_definition') {
|
|
356
|
+
const ret = { agg_as: 'property_definition', val: { name: rule.name } };
|
|
356
357
|
if (rule.hasOwnProperty('default_value')) {
|
|
357
|
-
|
|
358
|
+
ret.val.default_value = rule.default_value;
|
|
358
359
|
}
|
|
359
|
-
|
|
360
|
-
|
|
360
|
+
if (rule.hasOwnProperty('required')) {
|
|
361
|
+
ret.val.required = rule.required;
|
|
361
362
|
}
|
|
363
|
+
return ret;
|
|
362
364
|
}
|
|
363
365
|
// state properties are in here
|
|
364
366
|
if (rule.key === 'state_declaration') {
|
|
@@ -503,7 +505,6 @@ function compile(tree) {
|
|
|
503
505
|
sd.declarations.forEach(decl => {
|
|
504
506
|
if (decl.key === 'state_property') {
|
|
505
507
|
const label = name_bind_prop_and_state(decl.name, sd.state);
|
|
506
|
-
console.log(`Bind ${sd.state}:${decl.name} as ${label}`);
|
|
507
508
|
if (result_cfg.state_property.findIndex(c => c.name === label) !== -1) {
|
|
508
509
|
throw new JssmError(undefined, `A state may only bind a property once (${sd.state} re-binds ${decl.name})`);
|
|
509
510
|
}
|
|
@@ -641,6 +642,7 @@ class Machine {
|
|
|
641
642
|
this._property_keys = new Set();
|
|
642
643
|
this._default_properties = new Map();
|
|
643
644
|
this._state_properties = new Map();
|
|
645
|
+
this._required_properties = new Set();
|
|
644
646
|
this._history_length = history || 0;
|
|
645
647
|
this._history = new circular_buffer(this._history_length);
|
|
646
648
|
if (state_declaration) {
|
|
@@ -744,6 +746,9 @@ class Machine {
|
|
|
744
746
|
if (pr.hasOwnProperty('default_value')) {
|
|
745
747
|
this._default_properties.set(pr.name, pr.default_value);
|
|
746
748
|
}
|
|
749
|
+
if (pr.hasOwnProperty('required') && (pr.required === true)) {
|
|
750
|
+
this._required_properties.add(pr.name);
|
|
751
|
+
}
|
|
747
752
|
});
|
|
748
753
|
}
|
|
749
754
|
if (Array.isArray(state_property)) {
|
|
@@ -751,6 +756,32 @@ class Machine {
|
|
|
751
756
|
this._state_properties.set(sp.name, sp.default_value);
|
|
752
757
|
});
|
|
753
758
|
}
|
|
759
|
+
// done building, do checks
|
|
760
|
+
this._state_properties.forEach((_value, key) => {
|
|
761
|
+
const inside = JSON.parse(key);
|
|
762
|
+
if (Array.isArray(inside)) {
|
|
763
|
+
const j_property = inside[0];
|
|
764
|
+
if (typeof j_property === 'string') {
|
|
765
|
+
const j_state = inside[1];
|
|
766
|
+
if (typeof j_state === 'string') {
|
|
767
|
+
if (!(this.known_prop(j_property))) {
|
|
768
|
+
throw new JssmError(this, `State "${j_state}" has property "${j_property}" which is not globally declared`);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
});
|
|
774
|
+
this._required_properties.forEach(dp_key => {
|
|
775
|
+
if (this._default_properties.has(dp_key)) {
|
|
776
|
+
throw new JssmError(this, `The property "${dp_key}" is required, but also has a default; these conflict`);
|
|
777
|
+
}
|
|
778
|
+
this.states().forEach(s => {
|
|
779
|
+
const bound_name = name_bind_prop_and_state(dp_key, s);
|
|
780
|
+
if (!(this._state_properties.has(bound_name))) {
|
|
781
|
+
throw new JssmError(this, `State "${s}" is missing required property "${dp_key}"`);
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
});
|
|
754
785
|
}
|
|
755
786
|
/********
|
|
756
787
|
*
|
package/dist/es6/jssm_types.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ declare type JssmSerialization<DataType> = {
|
|
|
38
38
|
declare type JssmPropertyDefinition = {
|
|
39
39
|
name: string;
|
|
40
40
|
default_value?: any;
|
|
41
|
+
required?: boolean;
|
|
41
42
|
};
|
|
42
43
|
declare type JssmTransitionPermitter<DataType> = (OldState: StateType, NewState: StateType, OldData: DataType, NewData: DataType) => boolean;
|
|
43
44
|
declare type JssmTransitionPermitterMaybeArray<DataType> = JssmTransitionPermitter<DataType> | Array<JssmTransitionPermitter<DataType>>;
|
|
@@ -173,6 +174,7 @@ declare type JssmCompileSeStart<DataType> = {
|
|
|
173
174
|
name?: string;
|
|
174
175
|
state?: string;
|
|
175
176
|
default_value?: any;
|
|
177
|
+
required?: boolean;
|
|
176
178
|
};
|
|
177
179
|
declare type JssmParseTree = Array<JssmCompileSeStart<StateType>>;
|
|
178
180
|
declare type JssmParseFunctionType = (string: any) => JssmParseTree;
|
package/dist/es6/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const version = "5.79.
|
|
1
|
+
const version = "5.79.4";
|
|
2
2
|
export { version };
|