wiki-plugin-mech 0.1.6 → 0.1.8
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/client/mech.js +30 -8
- package/package.json +1 -1
package/client/mech.js
CHANGED
|
@@ -189,14 +189,17 @@
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
function walk_emit ({elem,command,args,state}) {
|
|
192
|
-
const steps =
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
elem.innerHTML = command
|
|
192
|
+
const steps = walks(state.neighborhood)
|
|
193
|
+
const aspects = steps.filter(({graph})=>graph)
|
|
194
|
+
if(state.debug) console.log({steps})
|
|
195
|
+
elem.innerHTML = command
|
|
196
|
+
const nodes = aspects.map(({graph}) => graph.nodes).flat()
|
|
197
|
+
elem.innerHTML += ` ⇒ ${aspects.length} aspects, ${nodes.length} nodes`
|
|
198
|
+
if(steps.find(({graph}) => !graph)) trouble(elem,"WALK skipped sites with no links in sitemaps")
|
|
196
199
|
const item = elem.closest('.item')
|
|
197
200
|
item.classList.add('aspect-source')
|
|
198
|
-
item.aspectData = () =>
|
|
199
|
-
state.aspect = [{div:item,result:
|
|
201
|
+
item.aspectData = () => aspects
|
|
202
|
+
state.aspect = [{div:item,result:aspects}]
|
|
200
203
|
}
|
|
201
204
|
|
|
202
205
|
function tick_emit ({elem,args,body,state}) {
|
|
@@ -216,7 +219,7 @@
|
|
|
216
219
|
run(body,state)
|
|
217
220
|
clock = setInterval(()=>{
|
|
218
221
|
if(state.debug) console.log({tick:state.tick})
|
|
219
|
-
if(--state.tick > 0)
|
|
222
|
+
if(('tick' in state) && --state.tick > 0)
|
|
220
223
|
run(body,state)
|
|
221
224
|
else
|
|
222
225
|
clock = clearInterval(clock)
|
|
@@ -225,6 +228,24 @@
|
|
|
225
228
|
})
|
|
226
229
|
}
|
|
227
230
|
|
|
231
|
+
function until_emit ({elem,command,args,body,state}) {
|
|
232
|
+
if(!args.length) return trouble(elem,`UNTIL expects an argument, a word to stop running.`)
|
|
233
|
+
if(!state.tick) return trouble(elem,`UNTIL expects to indented below an iterator, like TICKS.`)
|
|
234
|
+
if(!state.aspect) return trouble(elem,`UNTIL expects "aspect", like from WALK.`)
|
|
235
|
+
elem.innerHTML = command + ` ⇒ ${state.tick}`
|
|
236
|
+
const word = args[0]
|
|
237
|
+
for(const {div,result} of state.aspect)
|
|
238
|
+
for(const {name,graph} of result)
|
|
239
|
+
for(const node of graph.nodes)
|
|
240
|
+
if(node.type.includes(word) || node.props.name.includes(word)) {
|
|
241
|
+
if(state.debug) console.log({div,result,name,graph,node})
|
|
242
|
+
delete state.tick
|
|
243
|
+
elem.innerHTML += ' done'
|
|
244
|
+
if (body) run(body,state)
|
|
245
|
+
return
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
228
249
|
const blocks = {
|
|
229
250
|
CLICK: {emit:click_emit},
|
|
230
251
|
HELLO: {emit:hello_emit},
|
|
@@ -235,7 +256,8 @@
|
|
|
235
256
|
PREVIEW: {emit:preview_emit},
|
|
236
257
|
NEIGHBORS:{emit:neighbors_emit},
|
|
237
258
|
WALK: {emit:walk_emit},
|
|
238
|
-
TICK: {emit:tick_emit}
|
|
259
|
+
TICK: {emit:tick_emit},
|
|
260
|
+
UNTIL: {emit:until_emit}
|
|
239
261
|
}
|
|
240
262
|
|
|
241
263
|
function run (nest,state={}) {
|