pinokiod 7.1.49 → 7.1.50

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.
@@ -133,21 +133,50 @@ class Api {
133
133
  let p3
134
134
  let api_path
135
135
  let api_name
136
- if (typeof name === "object") {
137
- // if (name.path) {
138
- // api_path = name.path
139
- // api_name = path.relative(this.kernel.path("api"), api_path)
140
- // p1 = path.resolve(name.path, "pinokio.js")
141
- // p2 = path.resolve(name.path, "pinokio_meta.json")
142
- // p3 = path.resolve(name.path, "pinokio.json")
143
- // }
136
+ let api_root_path
137
+ const api_root = this.userdir || this.kernel.path("api")
138
+ const isWithinApiRoot = (candidatePath) => {
139
+ if (typeof candidatePath !== "string" || !candidatePath) {
140
+ return false
141
+ }
142
+ const relativePath = path.relative(api_root, candidatePath)
143
+ return relativePath === "" || (!relativePath.startsWith("..") && !path.isAbsolute(relativePath))
144
+ }
145
+ if (typeof name === "object" && name) {
146
+ if (name.name) {
147
+ api_root_path = this.kernel.path("api", name.name)
148
+ api_path = await this.launcher_path(name.name)
149
+ api_name = name.name
150
+ } else if (name.path) {
151
+ const resolvedPath = path.resolve(name.path)
152
+ const launcher = await this.launcher({ path: resolvedPath })
153
+ api_path = (launcher && launcher.script && launcher.launcher_root)
154
+ ? path.resolve(launcher.root, launcher.launcher_root)
155
+ : resolvedPath
156
+ if (isWithinApiRoot(resolvedPath)) {
157
+ const relativeToApiRoot = path.relative(api_root, resolvedPath)
158
+ const segments = relativeToApiRoot.split(path.sep).filter(Boolean)
159
+ api_name = segments[0] || path.basename(resolvedPath)
160
+ api_root_path = path.resolve(api_root, api_name)
161
+ } else {
162
+ api_name = path.basename(resolvedPath)
163
+ api_root_path = resolvedPath
164
+ }
165
+ }
144
166
  } else {
167
+ api_root_path = this.kernel.path("api", name)
145
168
  api_path = await this.launcher_path(name)
146
169
  api_name = name
147
- p1 = path.resolve(api_path, "pinokio.js")
148
- p2 = path.resolve(api_path, "pinokio_meta.json")
149
- p3 = path.resolve(api_path, "pinokio.json")
150
170
  }
171
+ if (!api_path) {
172
+ api_path = api_root_path
173
+ }
174
+ if (!api_root_path) {
175
+ api_root_path = api_path
176
+ }
177
+ p1 = path.resolve(api_path, "pinokio.js")
178
+ p2 = path.resolve(api_path, "pinokio_meta.json")
179
+ p3 = path.resolve(api_path, "pinokio.json")
151
180
  let pinokio = (await this.kernel.loader.load(p1)).resolved
152
181
  if (pinokio && pinokio.menu && !(Array.isArray(pinokio.menu) || typeof pinokio.menu === "function")) {
153
182
  delete pinokio.menu
@@ -176,12 +205,13 @@ class Api {
176
205
  // }
177
206
  // }
178
207
 
208
+ meta.declared_path = typeof meta.path === "string" ? meta.path : ""
179
209
  meta.iconpath = meta.icon ? meta.icon : null
180
210
  //meta.iconpath = meta.icon ? path.resolve(api_path, meta.icon) : null
181
211
  meta.path = api_path
182
212
  meta.name = meta.title
183
213
 
184
- let relpath = path.relative(this.kernel.path("api", name), api_path)
214
+ let relpath = path.relative(api_root_path, api_path)
185
215
  if (relpath === ".") {
186
216
  meta.icon = meta.icon ? `/asset/api/${api_name}/${meta.icon}` : "/pinokio-black.png"
187
217
  meta.link = `/p/${api_name}/dev#n1`
package/kernel/shell.js CHANGED
@@ -532,8 +532,12 @@ class Shell {
532
532
  // console.log("RESIZE", { cols, rows })
533
533
  this.cols = cols
534
534
  this.rows = rows
535
- this.ptyProcess.resize(cols, rows)
536
- this.vt.resize(cols, rows)
535
+ if (this.ptyProcess && typeof this.ptyProcess.resize === "function") {
536
+ this.ptyProcess.resize(cols, rows)
537
+ }
538
+ if (this.vt && typeof this.vt.resize === "function") {
539
+ this.vt.resize(cols, rows)
540
+ }
537
541
  this.stateSync.invalidate()
538
542
  }
539
543
  async emit2(message) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "7.1.49",
3
+ "version": "7.1.50",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {