pinokiod 3.2.220 → 3.2.222

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.
@@ -24,6 +24,7 @@ class Api {
24
24
  this.done = {}
25
25
  this.waiter = {}
26
26
  this.proxies = {}
27
+ this.mods = {}
27
28
  this.lproxy = new Lproxy()
28
29
  }
29
30
  get_proxy_url(root, port) {
@@ -411,6 +412,16 @@ class Api {
411
412
  if (req.uri) {
412
413
  modpath = this.resolvePath(cwd, req.uri)
413
414
  let m = (await this.loader.load(modpath))
415
+ if (this.mods[modpath]) {
416
+ console.log("Same, used the cached object")
417
+ // use the cached module if unchanged
418
+ m = this.mods[modpath]
419
+ } else {
420
+ m = (await this.loader.load(modpath))
421
+ // cache the mods so the module can be stateful
422
+ // the modules can set attributes on itself
423
+ this.mods[modpath] = m
424
+ }
414
425
  mod = m.resolved
415
426
  dirname = m.dirname
416
427
  method = mod[req.method].bind(mod)
@@ -670,7 +681,16 @@ class Api {
670
681
  } else {
671
682
  should_run = false
672
683
  }
684
+
673
685
  if (!should_run) {
686
+ // the current step is skipped, therefore the next value should be ignored as well
687
+ if (i < script.run.length-1) {
688
+ rpc.next = i+1
689
+ } else {
690
+ rpc.next = null
691
+ }
692
+
693
+
674
694
  //if (!rpc.when) {
675
695
  if (typeof rpc.next === "undefined" || rpc.next === null) {
676
696
  // last call
@@ -41,19 +41,28 @@ class Script {
41
41
  - absolute path
42
42
  - http path
43
43
  */
44
- let uri = await this.download(req, ondata, kernel)
45
- let res = await new Promise((resolve, reject) => {
46
- kernel.api.process({
47
- uri,
48
- input: req.params.params,
49
- client: req.client,
50
- caller: req.parent.path,
51
- }, (r) => {
52
- resolve(r.input)
44
+ // if already running, print that it's already running
45
+ let id = kernel.api.filePath(req.params.uri, req.cwd)
46
+ if (kernel.api.running[id]) {
47
+ let msg = `${req.params.uri} already running. Continuing...\r\n`
48
+ ondata({ raw: msg })
49
+ } else {
50
+ // if not already running, start.
51
+ let uri = await this.download(req, ondata, kernel)
52
+ let res = await new Promise((resolve, reject) => {
53
+ kernel.api.process({
54
+ uri,
55
+ input: req.params.params,
56
+ client: req.client,
57
+ caller: req.parent.path,
58
+ }, (r) => {
59
+ resolve(r.input)
60
+ })
53
61
  })
54
- })
55
- // need to call api.linkGit() so the git repositories list is up to date
56
- return res
62
+ // need to call api.linkGit() so the git repositories list is up to date
63
+ return res
64
+ }
65
+
57
66
  }
58
67
  async return(req, ondata, kernel) {
59
68
  /*
package/kernel/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const fs = require('fs')
2
2
  const os = require("os")
3
3
  const jsdom = require("jsdom");
4
+ const randomUseragent = require('random-useragent');
4
5
  const path = require('path')
5
6
  const fastq = require('fastq')
6
7
  const fetch = require('cross-fetch');
@@ -88,6 +89,15 @@ class Kernel {
88
89
  }
89
90
  return Environment.get2(folderpath, this)
90
91
  }
92
+ async userAgent(browser) {
93
+ if (browser) {
94
+ return randomUseragent.getRandom((ua) => {
95
+ return ua.browserName === browser;
96
+ });
97
+ } else {
98
+ return randomUseragent.getRandom()
99
+ }
100
+ }
91
101
  resumeprocess(uri) {
92
102
  let proc = this.procs[uri]
93
103
  if (proc && proc.resolve) {
@@ -100,6 +110,7 @@ class Kernel {
100
110
  type := "local" | "global"
101
111
  */
102
112
  let o = {}
113
+ console.log("IMPORT", params)
103
114
  for(let key in params) {
104
115
  // get memory for each uri
105
116
  let uri = params[key]
@@ -312,6 +323,14 @@ class Kernel {
312
323
  path: folder,
313
324
  })
314
325
  }
326
+
327
+
328
+ // get env
329
+ let env_path = path.resolve(this.api.userdir, folder)
330
+ let e = await Util.get(env_path)
331
+ if (e.PINOKIO_SCRIPT_AUTOLAUNCH) {
332
+
333
+ }
315
334
  }
316
335
  for(let key in this.bin.installed) {
317
336
  let s = this.bin.installed[key]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.2.220",
3
+ "version": "3.2.222",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -55,7 +55,7 @@
55
55
  "sanitize-filename": "^1.6.3",
56
56
  "semver": "^7.5.4",
57
57
  "shell-path": "^2.0.0",
58
- "sudo-prompt-programfiles-x86": "^9.2.8",
58
+ "sudo-prompt-programfiles-x86": "^9.2.9",
59
59
  "symlink-dir": "^5.2.1",
60
60
  "systeminformation": "^5.18.4",
61
61
  "uuid": "^9.0.0",