-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
188 additions
and
28 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/components/Editors/IframeTab/API/Requests/FileSystem/ReadAsDataUrl.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { IframeApi } from '../../IframeApi' | ||
import { GenericRequest } from '../GenericRequest' | ||
import { resolveFileReference } from './ResolveFileReference' | ||
import { loadHandleAsDataURL } from '/@/utils/loadAsDataUrl' | ||
|
||
export class ReadAsDataUrlRequest extends GenericRequest<string, string> { | ||
constructor(api: IframeApi) { | ||
super('fs.readAsDataUrl', api) | ||
} | ||
|
||
async handle(filePath: string, origin: string): Promise<string> { | ||
const fileHandle = await resolveFileReference(filePath, this.api) | ||
|
||
return await loadHandleAsDataURL(fileHandle) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/components/Editors/IframeTab/API/Requests/PackIndexer/Find.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { IframeApi } from '../../IframeApi' | ||
import { GenericRequest } from '../GenericRequest' | ||
|
||
interface IRequestData { | ||
findFileType: string | ||
whereCacheKey: string | ||
matchesOneOf: string[] | ||
fetchAll?: boolean | ||
} | ||
|
||
export class FindRequest extends GenericRequest<IRequestData, string[]> { | ||
constructor(api: IframeApi) { | ||
super('packIndexer.find', api) | ||
} | ||
|
||
async handle( | ||
{ findFileType, whereCacheKey, matchesOneOf, fetchAll }: IRequestData, | ||
origin: string | ||
) { | ||
const packIndexer = this.api.app.project.packIndexer | ||
await packIndexer.fired | ||
|
||
return await packIndexer.service.find( | ||
findFileType, | ||
whereCacheKey, | ||
matchesOneOf, | ||
fetchAll | ||
) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/components/Editors/IframeTab/API/Requests/PackIndexer/GetFile.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { IframeApi } from '../../IframeApi' | ||
import { GenericRequest } from '../GenericRequest' | ||
import { App } from '/@/App' | ||
|
||
export class GetFileRequest extends GenericRequest< | ||
string, | ||
Record<string, unknown> | ||
> { | ||
constructor(api: IframeApi) { | ||
super('packIndexer.getFile', api) | ||
} | ||
|
||
async handle(filePath: string, origin: string) { | ||
const packIndexer = this.api.app.project.packIndexer | ||
await packIndexer.fired | ||
|
||
const fileType = App.fileType.getId(filePath) | ||
|
||
return await packIndexer.service.getCacheDataFor(fileType, filePath) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.