tpmkms 9.5.1-beta.3 → 9.5.1-beta.30

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.
Files changed (108) hide show
  1. package/common/animals.instance.json +21 -61
  2. package/common/asking.js +112 -102
  3. package/common/can.instance.json +2174 -0
  4. package/common/can.js +254 -0
  5. package/common/can.test.json +51307 -0
  6. package/common/characters.js +3 -3
  7. package/common/colors.instance.json +10 -10
  8. package/common/comparable.instance.json +2 -2
  9. package/common/concept.test.json +54 -40
  10. package/common/conjunction.js +13 -5
  11. package/common/conjunction.test.json +32 -42
  12. package/common/crew.instance.json +164 -150
  13. package/common/crew.js +1 -1
  14. package/common/currency.js +1 -1
  15. package/common/dateTimeSelectors.instance.json +2 -2
  16. package/common/dateTimeSelectors.js +3 -3
  17. package/common/dateTimeSelectors.test.json +2229 -1560
  18. package/common/dates.instance.json +3 -3
  19. package/common/dates.test.json +284 -287
  20. package/common/dialogues.js +41 -119
  21. package/common/dialogues.test.json +1171 -996
  22. package/common/dimension.instance.json +45 -29
  23. package/common/dimension.js +105 -36
  24. package/common/dimension.test.json +2068 -3287
  25. package/common/edible.instance.json +23 -95
  26. package/common/emotions.instance.json +53 -80
  27. package/common/emotions.js +1 -1
  28. package/common/english_helpers.js +277 -67
  29. package/common/fastfood.instance.json +201 -873
  30. package/common/fastfood.js +4 -4
  31. package/common/fastfood.test.json +6970 -6829
  32. package/common/formulas.instance.json +1 -1
  33. package/common/gdefaults.js +94 -17
  34. package/common/help.js +11 -11
  35. package/common/help.test.json +65 -11
  36. package/common/helpers/concept.js +1 -1
  37. package/common/helpers/conjunction.js +54 -44
  38. package/common/helpers/dateTimeSelectors.js +2 -2
  39. package/common/helpers/dialogues.js +7 -2
  40. package/common/helpers/formulas.js +13 -11
  41. package/common/helpers/menus.js +12 -12
  42. package/common/helpers/meta.js +8 -8
  43. package/common/helpers/properties.js +104 -23
  44. package/common/helpers.js +112 -47
  45. package/common/hierarchy.js +4 -3
  46. package/common/kirk.instance.json +1 -1
  47. package/common/latin.instance.json +10 -10
  48. package/common/latin.js +5 -5
  49. package/common/length.instance.json +9782 -1868
  50. package/common/length.js +4 -1
  51. package/common/length.test.json +30646 -2860
  52. package/common/math.instance.json +20 -20
  53. package/common/math.js +45 -44
  54. package/common/menus.instance.json +6 -9
  55. package/common/menus.js +2 -9
  56. package/common/meta.js +49 -33
  57. package/common/numbers.js +1 -1
  58. package/common/ordering.instance.json +20 -30
  59. package/common/ordering.js +1 -1
  60. package/common/ordering.test.json +414 -426
  61. package/common/people.instance.json +82 -348
  62. package/common/people.js +1 -1
  63. package/common/people.test.json +952 -681
  64. package/common/pipboy.instance.json +16 -16
  65. package/common/pokemon.instance.json +8 -8
  66. package/common/pokemon.js +1 -1
  67. package/common/pressure.instance.json +157 -188
  68. package/common/pressure.test.json +433 -477
  69. package/common/properties.instance.json +6 -17
  70. package/common/properties.js +19 -6
  71. package/common/properties.test.json +8746 -6638
  72. package/common/rates.instance.json +59 -0
  73. package/common/rates.js +97 -0
  74. package/common/rates.test.json +27702 -0
  75. package/common/reminders.js +1 -1
  76. package/common/reminders.test.json +1641 -1601
  77. package/common/reports.instance.json +3 -3
  78. package/common/reports.js +18 -16
  79. package/common/scorekeeper.js +4 -4
  80. package/common/sdefaults.js +22 -2
  81. package/common/spock.instance.json +1 -1
  82. package/common/stgame.js +1 -1
  83. package/common/stm.js +2 -2
  84. package/common/tank.instance.json +14883 -0
  85. package/common/tank.js +408 -0
  86. package/common/tank.test.json +60424 -0
  87. package/common/tell.js +1 -1
  88. package/common/temperature.instance.json +300 -219
  89. package/common/temperature.test.json +433 -477
  90. package/common/tester.js +3 -3
  91. package/common/time.instance.json +20262 -0
  92. package/common/time.js +137 -141
  93. package/common/time.test.json +31876 -3757
  94. package/common/tokenize.js +1 -1
  95. package/common/ui.instance.json +2 -5
  96. package/common/ui.js +1 -8
  97. package/common/weight.instance.json +617 -335
  98. package/common/weight.test.json +2601 -2263
  99. package/common/words.instance.json +9 -0
  100. package/common/words.js +53 -0
  101. package/common/words.test.json +2 -0
  102. package/common/wp.instance.json +336 -8
  103. package/common/wp.js +8 -4
  104. package/common/wp.test.json +7385 -6906
  105. package/main.js +4 -2
  106. package/package.json +18 -5
  107. package/common/listener.js +0 -50
  108. package/common/listener.test.json +0 -142
@@ -474,7 +474,7 @@
474
474
  "text": "birds and mammals",
475
475
  "range": {
476
476
  "start": 0,
477
- "end": 28
477
+ "end": 16
478
478
  },
479
479
  "types": [
480
480
  "list",
@@ -1416,7 +1416,7 @@
1416
1416
  "word": "mammals",
1417
1417
  "range": {
1418
1418
  "start": 0,
1419
- "end": 16
1419
+ "end": 6
1420
1420
  },
1421
1421
  "dead": true,
1422
1422
  "types": [
@@ -1442,12 +1442,7 @@
1442
1442
  },
1443
1443
  "do": {
1444
1444
  "left": "object",
1445
- "right": "property",
1446
- "range": {
1447
- "start": 0,
1448
- "end": 16
1449
- },
1450
- "text": "mammals have ears"
1445
+ "right": "property"
1451
1446
  },
1452
1447
  "dead": true,
1453
1448
  "level": 2,
@@ -2167,7 +2162,7 @@
2167
2162
  "word": "mammals",
2168
2163
  "range": {
2169
2164
  "start": 0,
2170
- "end": 16
2165
+ "end": 6
2171
2166
  },
2172
2167
  "dead": true,
2173
2168
  "types": [
@@ -2193,12 +2188,7 @@
2193
2188
  },
2194
2189
  "do": {
2195
2190
  "left": "object",
2196
- "right": "property",
2197
- "range": {
2198
- "start": 0,
2199
- "end": 16
2200
- },
2201
- "text": "mammals have hair"
2191
+ "right": "property"
2202
2192
  },
2203
2193
  "dead": true,
2204
2194
  "level": 2,
@@ -2948,7 +2938,7 @@
2948
2938
  "word": "mammals",
2949
2939
  "range": {
2950
2940
  "start": 0,
2951
- "end": 22
2941
+ "end": 6
2952
2942
  },
2953
2943
  "dead": true,
2954
2944
  "types": [
@@ -2974,12 +2964,7 @@
2974
2964
  },
2975
2965
  "do": {
2976
2966
  "left": "object",
2977
- "right": "property",
2978
- "range": {
2979
- "start": 0,
2980
- "end": 22
2981
- },
2982
- "text": "mammals dont have wings"
2967
+ "right": "property"
2983
2968
  },
2984
2969
  "negation": true,
2985
2970
  "level": 2,
@@ -3782,7 +3767,7 @@
3782
3767
  "word": "animals",
3783
3768
  "range": {
3784
3769
  "start": 0,
3785
- "end": 16
3770
+ "end": 6
3786
3771
  },
3787
3772
  "dead": true,
3788
3773
  "types": [
@@ -3808,12 +3793,7 @@
3808
3793
  },
3809
3794
  "do": {
3810
3795
  "left": "object",
3811
- "right": "property",
3812
- "range": {
3813
- "start": 0,
3814
- "end": 16
3815
- },
3816
- "text": "animals have skin"
3796
+ "right": "property"
3817
3797
  },
3818
3798
  "dead": true,
3819
3799
  "level": 2,
@@ -4533,7 +4513,7 @@
4533
4513
  "word": "animals",
4534
4514
  "range": {
4535
4515
  "start": 0,
4536
- "end": 16
4516
+ "end": 6
4537
4517
  },
4538
4518
  "dead": true,
4539
4519
  "types": [
@@ -4559,12 +4539,7 @@
4559
4539
  },
4560
4540
  "do": {
4561
4541
  "left": "object",
4562
- "right": "property",
4563
- "range": {
4564
- "start": 0,
4565
- "end": 16
4566
- },
4567
- "text": "animals have eyes"
4542
+ "right": "property"
4568
4543
  },
4569
4544
  "dead": true,
4570
4545
  "level": 2,
@@ -5284,7 +5259,7 @@
5284
5259
  "word": "birds",
5285
5260
  "range": {
5286
5261
  "start": 0,
5287
- "end": 15
5262
+ "end": 4
5288
5263
  },
5289
5264
  "dead": true,
5290
5265
  "types": [
@@ -5310,12 +5285,7 @@
5310
5285
  },
5311
5286
  "do": {
5312
5287
  "left": "object",
5313
- "right": "property",
5314
- "range": {
5315
- "start": 0,
5316
- "end": 15
5317
- },
5318
- "text": "birds have wings"
5288
+ "right": "property"
5319
5289
  },
5320
5290
  "dead": true,
5321
5291
  "level": 2,
@@ -6035,7 +6005,7 @@
6035
6005
  "word": "birds",
6036
6006
  "range": {
6037
6007
  "start": 0,
6038
- "end": 15
6008
+ "end": 4
6039
6009
  },
6040
6010
  "dead": true,
6041
6011
  "types": [
@@ -6061,12 +6031,7 @@
6061
6031
  },
6062
6032
  "do": {
6063
6033
  "left": "object",
6064
- "right": "property",
6065
- "range": {
6066
- "start": 0,
6067
- "end": 15
6068
- },
6069
- "text": "birds have beaks"
6034
+ "right": "property"
6070
6035
  },
6071
6036
  "dead": true,
6072
6037
  "level": 2,
@@ -6951,7 +6916,7 @@
6951
6916
  "text": "humans bats felines and canines",
6952
6917
  "range": {
6953
6918
  "start": 0,
6954
- "end": 42
6919
+ "end": 30
6955
6920
  },
6956
6921
  "types": [
6957
6922
  "list",
@@ -8562,7 +8527,7 @@
8562
8527
  "text": "owls eagles pidgeons and parrots",
8563
8528
  "range": {
8564
8529
  "start": 0,
8565
- "end": 41
8530
+ "end": 31
8566
8531
  },
8567
8532
  "types": [
8568
8533
  "list",
@@ -10168,7 +10133,7 @@
10168
10133
  "word": "cats",
10169
10134
  "range": {
10170
10135
  "start": 0,
10171
- "end": 15
10136
+ "end": 3
10172
10137
  },
10173
10138
  "dead": true,
10174
10139
  "types": [
@@ -11323,7 +11288,7 @@
11323
11288
  "text": "dogs and wolves",
11324
11289
  "range": {
11325
11290
  "start": 0,
11326
- "end": 26
11291
+ "end": 14
11327
11292
  },
11328
11293
  "types": [
11329
11294
  "list",
@@ -12689,7 +12654,7 @@
12689
12654
  "word": "bats",
12690
12655
  "range": {
12691
12656
  "start": 0,
12692
- "end": 14
12657
+ "end": 3
12693
12658
  },
12694
12659
  "dead": true,
12695
12660
  "types": [
@@ -12715,12 +12680,7 @@
12715
12680
  },
12716
12681
  "do": {
12717
12682
  "left": "object",
12718
- "right": "property",
12719
- "range": {
12720
- "start": 0,
12721
- "end": 14
12722
- },
12723
- "text": "bats have wings"
12683
+ "right": "property"
12724
12684
  },
12725
12685
  "dead": true,
12726
12686
  "level": 2,
package/common/asking.js CHANGED
@@ -22,17 +22,22 @@ const config = {
22
22
  semantic: (args) => {
23
23
  const {config, context} = args
24
24
  // stop asking all questions
25
- for (const semantic of config.semantics) {
25
+ const remove = []
26
+ for (const semantic of config.semantics()) {
26
27
  if (semantic.isQuestion) {
27
28
  let doRemove = true
28
29
  if (semantic.onNevermind && semantic.getWasAsked() && !semantic.getWasApplied()) {
29
30
  doRemove = semantic.onNevermind(args)
30
31
  }
31
32
  if (doRemove) {
32
- config.removeSemantic(semantic)
33
+ remove.push(semantic)
34
+ // config.removeSemantic(semantic)
33
35
  }
34
36
  }
35
37
  }
38
+ for (const semantic of remove) {
39
+ config.removeSemantic(semantic)
40
+ }
36
41
  }
37
42
  },
38
43
 
@@ -43,11 +48,11 @@ const config = {
43
48
  bridge: "{ ...next(operator), choices: after[0] }",
44
49
  semantic: ({askWhich, context}) => {
45
50
  const choices = context.choices
46
- const chosen = ({ choice, objects }) => {
51
+ function chosen({ choice, objects }) {
47
52
  objects.choice = choice
48
53
  }
49
54
 
50
- const question = async ({choices, g, gs, wasAsked, state}) => {
55
+ async function question({choices, g, gs, wasAsked, state}) {
51
56
  if (wasAsked) {
52
57
  return `${await g(state.lastChoice)} is not a choice. The choices are: ${await gs(choices, ' ', ' or ')}`
53
58
  } else {
@@ -55,7 +60,7 @@ const config = {
55
60
  }
56
61
  }
57
62
 
58
- const isChoice = ({context, choices, state}) => {
63
+ function isChoice({context, choices, state}) {
59
64
  state.lastChoice = context
60
65
  for (const choice of choices) {
61
66
  if (choice.value == context.value) {
@@ -64,7 +69,7 @@ const config = {
64
69
  }
65
70
  }
66
71
 
67
- const onNevermind = ({objects, context}) => {
72
+ function onNevermind({objects, context}) {
68
73
  objects.onNevermindWasCalled = true
69
74
  return true
70
75
  }
@@ -94,115 +99,120 @@ const config = {
94
99
  ],
95
100
  };
96
101
 
97
- const getAsk = (config) => (uuid) => {
98
- return (asks) => {
99
- const ask = (ask, s_ids) => {
100
- let oneShot = true // default
101
- if (ask.oneShot === false) {
102
- oneShot = false
103
- }
102
+ function getAsk(config) {
103
+ return (uuid) => {
104
+ return (asks) => {
105
+ function ask(ask, s_ids) {
106
+ let oneShot = true // default
107
+ if (ask.oneShot === false) {
108
+ oneShot = false
109
+ }
104
110
 
105
- const id_q = stableId('semantic')
106
- s_ids.push(id_q)
107
- const id_rs = []
108
- let wasAsked = false
109
- let wasApplied = false
110
- const getWasAsked = () => {
111
- return wasAsked
112
- }
113
- const setWasAsked = (value) => {
114
- wasAsked = value
115
- }
116
- const getWasApplied = () => {
117
- return wasApplied
118
- }
119
- const setWasApplied = (value) => {
120
- wasApplied = value
121
- }
111
+ const id_q = stableId('semantic')
112
+ s_ids.push(id_q)
113
+ const id_rs = []
114
+ let wasAsked = false
115
+ let wasApplied = false
116
+ function getWasAsked() {
117
+ return wasAsked
118
+ }
119
+ function setWasAsked(value) {
120
+ wasAsked = value
121
+ }
122
+ function getWasApplied() {
123
+ return wasApplied
124
+ }
125
+ function setWasApplied(value) {
126
+ wasApplied = value
127
+ }
128
+
129
+ const semanticsr = ask.semanticsr || []
130
+ if (semanticsr.length == 0) {
131
+ semanticsr.push({ match: ask.matchr, apply: ask.applyr })
132
+ }
133
+ for (const semantic of semanticsr) {
134
+ const id_r = stableId('semantic')
135
+ id_rs.push(id_r)
136
+ s_ids.push(id_r)
137
+ config.addSemantic({
138
+ uuid,
139
+ id: id_r,
140
+ tied_ids: [id_q],
141
+ // tied_ids: s_ids,
142
+ onDelete: ask.onDelete,
143
+ oneShot,
144
+ where: semantic.where || ask.where || where(2),
145
+ source: 'response',
146
+ match: (args) => semantic.match(args),
147
+ apply: async (args) => {
148
+ setWasApplied(true)
149
+ await semantic.apply(args)
150
+ },
151
+ })
152
+ }
122
153
 
123
- const semanticsr = ask.semanticsr || []
124
- if (semanticsr.length == 0) {
125
- semanticsr.push({ match: ask.matchr, apply: ask.applyr })
126
- }
127
- for (const semantic of semanticsr) {
128
- const id_r = stableId('semantic')
129
- id_rs.push(id_r)
130
- s_ids.push(id_r)
131
- // debugger
132
154
  config.addSemantic({
133
155
  uuid,
134
- id: id_r,
135
- tied_ids: [id_q],
156
+ oneShot,
157
+ id: id_q,
158
+ tied_ids: id_rs,
136
159
  // tied_ids: s_ids,
160
+ where: ask.where,
161
+ isQuestion: true, // do one question at a time
162
+ getWasAsked,
163
+ getWasApplied,
137
164
  onDelete: ask.onDelete,
138
- oneShot,
139
- where: semantic.where || ask.where || where(2),
140
- source: 'response',
141
- match: (args) => semantic.match(args),
165
+ onNevermind: ask.onNevermind,
166
+ source: 'question',
167
+ match: ({ context }) => context.marker == 'controlEnd' || context.marker == 'controlBetween',
142
168
  apply: async (args) => {
143
- setWasApplied(true)
144
- await semantic.apply(args)
145
- },
146
- })
147
- }
148
-
149
- config.addSemantic({
150
- uuid,
151
- oneShot,
152
- id: id_q,
153
- tied_ids: id_rs,
154
- // tied_ids: s_ids,
155
- where: ask.where,
156
- isQuestion: true, // do one question at a time
157
- getWasAsked,
158
- getWasApplied,
159
- onDelete: ask.onDelete,
160
- onNevermind: ask.onNevermind,
161
- source: 'question',
162
- match: ({ context }) => context.marker == 'controlEnd' || context.marker == 'controlBetween',
163
- apply: async (args) => {
164
- let matchq = ask.matchq
165
- let applyq = ask.applyq
166
- if (!matchq) {
167
- let wasAsked = false
168
- matchq = () => !wasAsked,
169
- applyq = (args) => {
170
- wasAsked = true
171
- return ask.applyq(args)
169
+ let matchq = ask.matchq
170
+ let applyq = ask.applyq
171
+ if (!matchq) {
172
+ let wasAsked = false
173
+ matchq = () => !wasAsked,
174
+ applyq = (args) => {
175
+ wasAsked = true
176
+ return ask.applyq(args)
177
+ }
172
178
  }
179
+ if (await matchq(args)) {
180
+ setWasApplied(false)
181
+ // args.context.motivationKeep = true
182
+ const query = await applyq({ ...args, wasAsked: getWasAsked() })
183
+ if (typeof query != 'string') {
184
+ throw new Error(`ask expects the value return from applyq to be a string. ${ask.where}`)
185
+ }
186
+ args.verbatim(query)
187
+ setWasAsked(true)
188
+ args.context.controlKeepMotivation = true
189
+ } else {
190
+ args._continue()
191
+ }
192
+ args.context.cascade = true
173
193
  }
174
- if (await matchq(args)) {
175
- setWasApplied(false)
176
- // args.context.motivationKeep = true
177
- args.verbatim(await applyq({ ...args, wasAsked: getWasAsked() }))
178
- setWasAsked(true)
179
- args.context.controlKeepMotivation = true
180
- } else {
181
- args._continue()
182
- }
183
- args.context.cascade = true
184
- }
185
- })
186
- }
187
- if (!Array.isArray(asks)) {
188
- asks = [asks]
189
- }
194
+ })
195
+ }
196
+ if (!Array.isArray(asks)) {
197
+ asks = [asks]
198
+ }
190
199
 
191
- const s_ids = []
192
- for (const a of [...asks].reverse()) {
193
- // debugger
194
- ask(a, s_ids)
195
- }
196
-
197
- const cleanUp = () => {
198
- config.removeSemantic(s_ids)
200
+ const s_ids = []
201
+ for (const a of [...asks].reverse()) {
202
+ // debugger
203
+ ask(a, s_ids)
204
+ }
205
+
206
+ function cleanUp() {
207
+ config.removeSemantic(s_ids)
208
+ }
209
+ return cleanUp
199
210
  }
200
- return cleanUp
201
211
  }
202
212
  }
203
213
 
204
214
 
205
- const initializer = ({objects, config, isModule}) => {
215
+ function initializer({objects, config, isModule}) {
206
216
  config.addArgs(({config, api, isA}) => ({
207
217
  getUUIDScoped: (uuid) => {
208
218
  const ask = getAsk(config)(uuid)
@@ -221,7 +231,7 @@ const initializer = ({objects, config, isModule}) => {
221
231
  }
222
232
 
223
233
  if (!question) {
224
- const question = async ({choices, g, gs, wasAsked, state}) => {
234
+ async function question({choices, g, gs, wasAsked, state}) {
225
235
  if (wasAsked) {
226
236
  return `${await g(state.lastChoice)} is not a choice. The choices are: ${await gs(choices, ' ', ' or ')}`
227
237
  } else {
@@ -231,7 +241,7 @@ const initializer = ({objects, config, isModule}) => {
231
241
  }
232
242
 
233
243
  if (!isChoice) {
234
- const isChoice = ({context, choices, state}) => {
244
+ function isChoice({context, choices, state}) {
235
245
  state.lastChoice = context
236
246
  for (const choice of choices) {
237
247
  if (choice.value == context.value) {