tpmkms_4wp 8.9.0-beta.2 → 8.9.0-beta.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/common/wp.js CHANGED
@@ -3,6 +3,8 @@ const { defaultContextCheck } = require('./helpers')
3
3
  const helpers = require("./helpers")
4
4
  const ui = require("./ui")
5
5
  const countable = require("./countable")
6
+ const colors = require("./colors")
7
+ const errors = require("./errors")
6
8
  const wp_tests = require('./wp.test.json')
7
9
  const instance = require('./wp.instance.json')
8
10
 
@@ -20,6 +22,10 @@ class API {
20
22
  initialize({ objects }) {
21
23
  this._objects = objects
22
24
  }
25
+
26
+ changeColor(unit, scope, color) {
27
+ this._objects.changeColor = { unit, scope, color }
28
+ }
23
29
  }
24
30
 
25
31
  const api = new API()
@@ -27,8 +33,29 @@ const api = new API()
27
33
  let config = {
28
34
  name: 'wp',
29
35
  operators: [
36
+ // TODO write a parser for this so I can use statefulElement as the id
37
+ "([changeState|make] ([statefulelement]) ([stateValue|]))",
30
38
  ],
31
39
  bridges: [
40
+ {
41
+ id: 'changeState',
42
+ parents: ['verb'],
43
+ bridge: "{ ...next(operator), element: after[0], state: after[1], operator: operator, generate: ['operator', 'element', 'state'] }",
44
+ semantic: ({api, context}) => {
45
+ debugger
46
+ const unit = context.element.marker
47
+ const scope = context.element.quantity.quantity
48
+ const color = context.state.value
49
+ api.changeColor({ unit, scope, color })
50
+ }
51
+ },
52
+ {
53
+ id: 'statefulelement',
54
+ },
55
+ {
56
+ id: 'stateValue',
57
+ children: ['color_colors'],
58
+ },
32
59
  ],
33
60
  semantics: [
34
61
  ]
@@ -36,7 +63,7 @@ let config = {
36
63
 
37
64
  template = {
38
65
  configs: [
39
- 'words are countable',
66
+ 'words are countable and statefulElements',
40
67
  'characters are countable',
41
68
  'paragraphs are countable',
42
69
  ],
@@ -44,7 +71,7 @@ template = {
44
71
 
45
72
  knowledgeModule({
46
73
  config,
47
- includes: [ui, countable],
74
+ includes: [ui, countable, colors, errors],
48
75
  api: () => new API(),
49
76
 
50
77
  module,
@@ -56,7 +83,10 @@ knowledgeModule({
56
83
  context: [
57
84
  ...defaultContextCheck(),
58
85
  ],
59
- objects: [{ km: 'ui' }],
86
+ objects: [
87
+ 'changeColor',
88
+ { km: 'ui' },
89
+ ],
60
90
  },
61
91
  },
62
92
  template: {