feat(core): Added debug as event type
This commit is contained in:
parent
f93119fc33
commit
b360359cf6
2 changed files with 34 additions and 24 deletions
|
@ -23,25 +23,6 @@ export default function Pattern(config = { options: {} }) {
|
||||||
this.Snippet = Snippet // Snippet constructor
|
this.Snippet = Snippet // Snippet constructor
|
||||||
this.Attributes = Attributes // Attributes constructor
|
this.Attributes = Attributes // Attributes constructor
|
||||||
|
|
||||||
// Store events
|
|
||||||
this.events = {
|
|
||||||
info: [],
|
|
||||||
warning: [],
|
|
||||||
error: []
|
|
||||||
}
|
|
||||||
const events = this.events
|
|
||||||
this.events.raise = {
|
|
||||||
event: function (data) {
|
|
||||||
events.info.push(data)
|
|
||||||
},
|
|
||||||
warning: function (data) {
|
|
||||||
events.warning.push(data)
|
|
||||||
},
|
|
||||||
error: function (data) {
|
|
||||||
events.error.push(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default settings
|
// Default settings
|
||||||
this.settings = {
|
this.settings = {
|
||||||
complete: true,
|
complete: true,
|
||||||
|
@ -50,6 +31,7 @@ export default function Pattern(config = { options: {} }) {
|
||||||
units: 'metric',
|
units: 'metric',
|
||||||
margin: 2,
|
margin: 2,
|
||||||
layout: true,
|
layout: true,
|
||||||
|
debug: false,
|
||||||
options: {}
|
options: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +57,31 @@ export default function Pattern(config = { options: {} }) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store events
|
||||||
|
this.events = {
|
||||||
|
info: [],
|
||||||
|
warning: [],
|
||||||
|
error: [],
|
||||||
|
debug: []
|
||||||
|
}
|
||||||
|
const events = this.events
|
||||||
|
this.events.raise = {
|
||||||
|
event: function (data) {
|
||||||
|
events.info.push(data)
|
||||||
|
},
|
||||||
|
warning: function (data) {
|
||||||
|
events.warning.push(data)
|
||||||
|
},
|
||||||
|
error: function (data) {
|
||||||
|
events.error.push(data)
|
||||||
|
},
|
||||||
|
debug: function (data) {
|
||||||
|
if (this.settings.debug) events.debug.push(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Debug helper
|
||||||
|
this.debug = this.events.raise.debug
|
||||||
|
|
||||||
// Macros
|
// Macros
|
||||||
this.macros = {}
|
this.macros = {}
|
||||||
|
|
||||||
|
@ -114,6 +121,7 @@ Pattern.prototype.apply = function (settings) {
|
||||||
}
|
}
|
||||||
} else this.settings[key] = settings[key]
|
} else this.settings[key] = settings[key]
|
||||||
}
|
}
|
||||||
|
if (this.settings.debug) this.debug('Debug enabled')
|
||||||
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
@ -575,6 +583,7 @@ Pattern.prototype.getRenderProps = function () {
|
||||||
props.height = this.height
|
props.height = this.height
|
||||||
props.settings = this.settings
|
props.settings = this.settings
|
||||||
props.events = {
|
props.events = {
|
||||||
|
debug: this.events.debug,
|
||||||
info: this.events.info,
|
info: this.events.info,
|
||||||
warning: this.events.warning,
|
warning: this.events.warning,
|
||||||
error: this.events.error
|
error: this.events.error
|
||||||
|
|
|
@ -4,10 +4,11 @@ const defaultGist = {
|
||||||
sa: 0,
|
sa: 0,
|
||||||
complete: true,
|
complete: true,
|
||||||
paperless: false,
|
paperless: false,
|
||||||
locale: "en",
|
locale: 'en',
|
||||||
units: "metric",
|
units: 'metric',
|
||||||
margin: 2
|
margin: 2,
|
||||||
|
debug: false
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
export default defaultGist;
|
export default defaultGist
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue