Skip to content

Commit e0f50fb

Browse files
committed
add missing common paths
add recursive file listing update example
1 parent 2d7060c commit e0f50fb

File tree

5 files changed

+364
-44
lines changed

5 files changed

+364
-44
lines changed

examples/example.c3p

142 Bytes
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"dependencies": {
3-
"@pipelab/core": "1.3.0",
3+
"@pipelab/core": "1.3.2",
44
"adm-zip": "0.5.16",
55
"chokidar": "4.0.1",
66
"cors": "2.8.5",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/instance.js

Lines changed: 193 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,78 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
126126
*/
127127
_userFolder
128128

129+
/**
130+
* @type {string}
131+
*/
132+
_homeFolder
133+
/**
134+
* @type {string}
135+
*/
136+
_appDataFolder
137+
/**
138+
* @type {string}
139+
*/
140+
_userDataFolder
141+
/**
142+
* @type {string}
143+
*/
144+
_sessionDataFolder
145+
/**
146+
* @type {string}
147+
*/
148+
_tempFolder
149+
/**
150+
* @type {string}
151+
*/
152+
_exeFolder
153+
/**
154+
* @type {string}
155+
*/
156+
_moduleFolder
157+
/**
158+
* @type {string}
159+
*/
160+
_desktopFolder
161+
/**
162+
* @type {string}
163+
*/
164+
_documentsFolder
165+
/**
166+
* @type {string}
167+
*/
168+
_downloadsFolder
169+
/**
170+
* @type {string}
171+
*/
172+
_musicFolder
173+
/**
174+
* @type {string}
175+
*/
176+
_picturesFolder
177+
/**
178+
* @type {string}
179+
*/
180+
_videosFolder
181+
/**
182+
* @type {string}
183+
*/
184+
_recentFolder
185+
/**
186+
* @type {string}
187+
*/
188+
_logsFolder
189+
/**
190+
* @type {string}
191+
*/
192+
_crashDumpsFolder
193+
/**
194+
* @type {string}
195+
*/
196+
_appFolder
197+
/**
198+
* @type {string}
199+
*/
200+
129201
/** @type {string} */
130202
_currentTag
131203

@@ -231,6 +303,7 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
231303
reconnectInterval: 5000
232304
});
233305

306+
// expose websocket instance
234307
window.pipelab = {
235308
ws: this.ws
236309
}
@@ -239,22 +312,50 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
239312

240313
console.log('this.ws', this.ws)
241314

242-
// -----------------------------------------------------------------------
243-
// Fetch user folder
244-
/** @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessagePaths, 'input'>} */
245-
const orderUserFolder = {
246-
url: '/paths',
247-
body: {
248-
name: 'home'
315+
const paths = [
316+
// app.getPath(name)
317+
['home', '_homeFolder' ],
318+
['appData', '_appDataFolder' ],
319+
['userData', '_userDataFolder' ],
320+
['sessionData', '_sessionDataFolder' ],
321+
['temp', '_tempFolder' ],
322+
['exe', '_exeFolder' ],
323+
['module', '_moduleFolder' ],
324+
['desktop', '_desktopFolder' ],
325+
['documents', '_documentsFolder' ],
326+
['downloads', '_downloadsFolder' ],
327+
['music', '_musicFolder' ],
328+
['pictures', '_picturesFolder' ],
329+
['videos', '_videosFolder' ],
330+
['recent', '_recentFolder' ],
331+
['logs', '_logsFolder' ],
332+
['crashDumps', '_crashDumpsFolder' ],
333+
// app.getAppPath
334+
['app', '_appFolder' ],
335+
]
336+
337+
const promises = paths.map(async (name) => {
338+
339+
// -----------------------------------------------------------------------
340+
// Fetch user folder
341+
/** @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessagePaths, 'input'>} */
342+
const orderPath = {
343+
url: '/paths',
344+
body: {
345+
name: name[0]
346+
}
249347
}
250-
}
251348

252-
/**
253-
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessagePaths, 'output'>}
254-
*/
255-
const userFolder = await this.ws.sendAndWaitForResponse(orderUserFolder)
256-
console.log('userFolder', userFolder.body.data)
257-
this._userFolder = userFolder.body.data
349+
/**
350+
* @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessagePaths, 'output'>}
351+
*/
352+
const pathFolder = await this.ws?.sendAndWaitForResponse(orderPath)
353+
console.log('pathFolder', pathFolder.body.data)
354+
this[name[1]] = pathFolder.body.data
355+
356+
})
357+
358+
await Promise.all(promises)
258359

259360
// -----------------------------------------------------------------------
260361
// Fetch engine
@@ -617,12 +718,13 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
617718
throw new Error('"_DeleteFile" Not implemented')
618719
}, this.unsupportedEngine)
619720

620-
_ListFiles = this.wrap(super._ListFiles, async (path) => {
721+
_ListFiles = this.wrap(super._ListFiles, async (path, recursive) => {
621722
/** @type {import('@pipelab/core').MakeInputOutput<import('@pipelab/core').MessageListFiles, 'input'>} */
622723
const order = {
623724
url: '/fs/list',
624725
body: {
625-
path
726+
path,
727+
recursive,
626728
}
627729
}
628730
const files = await this.ws?.sendAndWaitForResponse(order)
@@ -854,6 +956,80 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
854956
return this._userFolder ?? ''
855957
})
856958

959+
_HomeFolder = this.wrap(super._HomeFolder, () => {
960+
console.log('this', this)
961+
return this._homeFolder ?? ''
962+
})
963+
_AppDataFolder = this.wrap(super._AppDataFolder, () => {
964+
console.log('this', this)
965+
return this._appDataFolder ?? ''
966+
})
967+
_UserDataFolder = this.wrap(super._UserDataFolder, () => {
968+
console.log('this', this)
969+
return this._userFolder ?? ''
970+
})
971+
_SessionDataFolder = this.wrap(super._SessionDataFolder, () => {
972+
console.log('this', this)
973+
return this._sessionDataFolder ?? ''
974+
})
975+
_TempFolder = this.wrap(super._TempFolder, () => {
976+
console.log('this', this)
977+
return this._tempFolder ?? ''
978+
})
979+
_ExeFolder = this.wrap(super._ExeFolder, () => {
980+
console.log('this', this)
981+
return this._exeFolder ?? ''
982+
})
983+
_ModuleFolder = this.wrap(super._ModuleFolder, () => {
984+
console.log('this', this)
985+
return this._moduleFolder ?? ''
986+
})
987+
_DesktopFolder = this.wrap(super._DesktopFolder, () => {
988+
console.log('this', this)
989+
return this._desktopFolder ?? ''
990+
})
991+
_DocumentsFolder = this.wrap(super._DocumentsFolder, () => {
992+
console.log('this', this)
993+
return this._documentsFolder ?? ''
994+
})
995+
_DownloadsFolder = this.wrap(super._DownloadsFolder, () => {
996+
console.log('this', this)
997+
return this._downloadsFolder ?? ''
998+
})
999+
_MusicFolder = this.wrap(super._MusicFolder, () => {
1000+
console.log('this', this)
1001+
return this._musicFolder ?? ''
1002+
})
1003+
_PicturesFolder = this.wrap(super._PicturesFolder, () => {
1004+
console.log('this', this)
1005+
return this._picturesFolder ?? ''
1006+
})
1007+
_VideosFolder = this.wrap(super._VideosFolder, () => {
1008+
console.log('this', this)
1009+
return this._videosFolder ?? ''
1010+
})
1011+
_RecentFolder = this.wrap(super._RecentFolder, () => {
1012+
console.log('this', this)
1013+
return this._recentFolder ?? ''
1014+
})
1015+
_LogsFolder = this.wrap(super._LogsFolder, () => {
1016+
console.log('this', this)
1017+
return this._logsFolder ?? ''
1018+
})
1019+
_CrashDumpsFolder = this.wrap(super._CrashDumpsFolder, () => {
1020+
console.log('this', this)
1021+
return this._crashDumpsFolder ?? ''
1022+
})
1023+
1024+
_AppFolder = this.wrap(super._AppFolder, () => {
1025+
console.log('this', this)
1026+
return this._appFolder ?? ''
1027+
})
1028+
1029+
_AppFolderURL = this.wrap(super._AppFolderURL, () => {
1030+
return 'deprecrated'
1031+
})
1032+
8571033
_ArgumentAt = this.wrap(super._ArgumentAt, () => {
8581034
console.error('"_ArgumentAt" Not implemented')
8591035
return ''
@@ -868,16 +1044,6 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
8681044
return this._chosenPath ?? ''
8691045
})
8701046

871-
_AppFolder = this.wrap(super._AppFolder, () => {
872-
console.error('"_AppFolder" Not implemented')
873-
return ''
874-
})
875-
876-
_AppFolderURL = this.wrap(super._AppFolderURL, () => {
877-
console.error('"_AppFolderURL" Not implemented')
878-
return ''
879-
})
880-
8811047
_DroppedFile = this.wrap(super._DroppedFile, () => {
8821048
console.error('"_DroppedFile" Not implemented')
8831049
return ''
@@ -896,7 +1062,7 @@ function getInstanceJs(parentClass, addonTriggers, C3) {
8961062
})
8971063

8981064
_ListAt = this.wrap(super._ListAt, (index) => {
899-
return this._fileList[index]?.name ?? ''
1065+
return this._fileList[index]?.path ?? ''
9001066
})
9011067

9021068
_ListCount = this.wrap(super._ListCount, () => {

0 commit comments

Comments
 (0)