-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Milansuman/js_extensions
[FEAT] Added multiple js extension polyfills.
- Loading branch information
Showing
27 changed files
with
574 additions
and
18 deletions.
There are no files selected for viewing
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,3 @@ | ||
[submodule "extensions/spotlight"] | ||
path = extensions/spotlight | ||
url = https://github.com/Jovit-Mathew236/project-web-spotlight.git |
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,22 @@ | ||
# Flux Browser JS API Docs | ||
|
||
## Tab Management | ||
|
||
```ts | ||
window.tabs.requestSplitTab(url: string): null | ||
window.tabs.requestSplitTab(): null | ||
window.tabs.requestFlipTabs(): null | ||
window.tabs.requestNewGroup(url: string): null | ||
window.tabs.addTabs(tabs: Array<Array<string>>): boolean | ||
``` | ||
## File API | ||
|
||
```ts | ||
window.fs.listDir(path: string, subdir?: boolean) : Array<{path: string, isDir: boolean, dirs: Array<{path: string, isDir: boolean}>}> | ||
window.fs.getFileUrl(): string | ||
window.fs.getFolderUrl(): string | ||
``` | ||
## Dialog API | ||
```ts | ||
window.dialog.closeDialog() | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
set(SOURCES ${SOURCES} | ||
src/api/TabApi.h | ||
src/api/TabApi.cpp | ||
src/api/TerminalApi.h | ||
src/api/TerminalApi.cpp | ||
src/api/HistoryApi.h | ||
src/api/HistoryApi.cpp | ||
src/api/FileApi.h | ||
src/api/FileApi.cpp | ||
src/api/DialogApi.h | ||
src/api/DialogApi.cpp | ||
PARENT_SCOPE | ||
) |
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,9 @@ | ||
#include "DialogApi.h" | ||
|
||
DialogApi::DialogApi(QObject *parent): QObject(parent){} | ||
|
||
void DialogApi::closeDialog(){ | ||
emit this->closeDialogRequested(); | ||
} | ||
|
||
DialogApi::~DialogApi() = default; |
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,13 @@ | ||
#pragma once | ||
|
||
#include <QObject> | ||
|
||
class DialogApi: public QObject{ | ||
Q_OBJECT | ||
public: | ||
DialogApi(QObject *parent=nullptr); | ||
Q_INVOKABLE void closeDialog(); | ||
~DialogApi(); | ||
signals: | ||
void closeDialogRequested(); | ||
}; |
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,66 @@ | ||
#include "FileApi.h" | ||
|
||
#include <QDir> | ||
#include <QJsonArray> | ||
#include <QDirIterator> | ||
#include <QFile> | ||
#include <QStringList> | ||
#include <QFileDialog> | ||
#include <QJsonObject> | ||
|
||
FileApi::FileApi(QObject *parent): QObject(parent){} | ||
|
||
QJsonDocument FileApi::listDir(QString path, bool subdir){ | ||
QJsonDocument folderData; | ||
|
||
QDir directory(path); | ||
directory.setFilter(QDir::AllEntries | QDir::NoDotAndDotDot); | ||
QJsonArray entries; | ||
for(QFileInfo path: directory.entryInfoList()){ | ||
QJsonObject fileData; | ||
fileData.insert("path", path.filePath()); | ||
fileData.insert("isDir", path.isDir()); | ||
|
||
if(subdir && path.isDir()){ | ||
QJsonArray subdirEntries; | ||
for(QFileInfo subPath: QDir(path.filePath()).entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot)){ | ||
QJsonObject subFileData; | ||
|
||
subFileData.insert("path", subPath.filePath()); | ||
subFileData.insert("isDir", subPath.isDir()); | ||
subdirEntries.append(subFileData); | ||
} | ||
fileData.insert("dirs", subdirEntries); | ||
} | ||
|
||
entries.append(fileData); | ||
} | ||
|
||
folderData.setArray(entries); | ||
return folderData; | ||
} | ||
|
||
QJsonDocument FileApi::search(QString fuzz){ | ||
QJsonDocument filesData; | ||
|
||
QDirIterator iter(QDir::homePath(), QStringList(fuzz), QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); | ||
|
||
QJsonArray files; | ||
while(iter.hasNext()){ | ||
QFile file(iter.next()); | ||
files.append(file.fileName()); | ||
} | ||
|
||
filesData.setArray(files); | ||
return filesData; | ||
} | ||
|
||
QString FileApi::getFileURL(){ | ||
return QFileDialog::getOpenFileUrl(nullptr, "Open a file", QDir::homePath(), "").toString(); | ||
} | ||
|
||
QString FileApi::getFolderURL(){ | ||
return QFileDialog::getExistingDirectoryUrl(nullptr, "Open a file", QDir::homePath()).toString(); | ||
} | ||
|
||
FileApi::~FileApi() = default; |
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 @@ | ||
#pragma once | ||
|
||
#include <QObject> | ||
#include <QJsonDocument> | ||
|
||
/* | ||
listDir(string path, boolean subdir?) : Array<string> | ||
getFileUrl(): string | ||
getFolderUrl(): string | ||
*/ | ||
|
||
class FileApi: public QObject{ | ||
Q_OBJECT | ||
public: | ||
FileApi(QObject *parent=nullptr); | ||
Q_INVOKABLE QJsonDocument listDir(QString path, bool subdir=false); | ||
QJsonDocument search(QString fuzz); | ||
Q_INVOKABLE QString getFileURL(); | ||
Q_INVOKABLE QString getFolderURL(); | ||
~FileApi(); | ||
}; |
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,23 @@ | ||
#include "HistoryApi.h" | ||
|
||
#include <QWebEngineHistoryItem> | ||
#include <QJsonArray> | ||
#include <QJsonObject> | ||
#include <QJsonValue> | ||
|
||
HistoryApi::HistoryApi(QWebEngineHistory *history, QObject *parent): QObject(parent), history(history){} | ||
|
||
QJsonDocument HistoryApi::getHistory(){ | ||
QJsonDocument result; | ||
QJsonArray array; | ||
for(QWebEngineHistoryItem item: this->history->items()){ | ||
QJsonObject historyItem; | ||
historyItem.insert(item.title(), QJsonValue(item.url().toString())); | ||
array.append(historyItem); | ||
} | ||
result.setArray(array); | ||
|
||
return result; | ||
} | ||
|
||
HistoryApi::~HistoryApi() = default; |
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,19 @@ | ||
#pragma once | ||
|
||
#include <QObject> | ||
#include <QWebEngineHistory> | ||
#include <QJsonDocument> | ||
|
||
/* | ||
window.tabHistory.getHistory() : Array<{ title: string, url: string}> | ||
*/ | ||
|
||
class HistoryApi: public QObject{ | ||
Q_OBJECT | ||
private: | ||
QWebEngineHistory *history; | ||
public: | ||
HistoryApi(QWebEngineHistory *history, QObject *parent=nullptr); | ||
Q_INVOKABLE QJsonDocument getHistory(); | ||
~HistoryApi(); | ||
}; |
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,45 @@ | ||
#include "TabApi.h" | ||
|
||
#include <QJsonArray> | ||
|
||
TabsApi::TabsApi(QObject *parent): QObject(parent){} | ||
|
||
bool TabsApi::addTabs(QJsonDocument tabs){ | ||
if(tabs.isArray()){ | ||
QList<QList<QUrl>> tabsList; | ||
for(QJsonValueRef group: tabs.array()){ | ||
if(group.isArray()){ | ||
QList<QUrl> urls; | ||
|
||
for(QJsonValueRef url: group.toArray()){ | ||
urls.append(QUrl(url.toString())); | ||
} | ||
tabsList.append(urls); | ||
}else{ | ||
return false; | ||
} | ||
} | ||
emit this->addTabsRequested(tabsList); | ||
}else{ | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
void TabsApi::requestSplitTab(QString url){ | ||
emit this->splitTabRequested(QUrl(url)); | ||
} | ||
|
||
void TabsApi::requestSplitTab(){ | ||
emit this->splitTabHomeRequested(); | ||
} | ||
|
||
void TabsApi::requestFlipTabs(){ | ||
emit this->splitTabFlipRequested(); | ||
} | ||
|
||
void TabsApi::requestNewGroup(QString url){ | ||
emit this->newTabRequested(QUrl(url)); | ||
} | ||
|
||
TabsApi::~TabsApi() = default; |
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,31 @@ | ||
#pragma once | ||
|
||
#include <QObject> | ||
#include <QUrl> | ||
#include <QJsonDocument> | ||
#include <QList> | ||
#include <QUrl> | ||
|
||
/* | ||
window.tabs.requestSplitTab(string url) | ||
window.tabs.requestFlipTabs() | ||
window.tabs.requestNewGroup(string url) | ||
*/ | ||
|
||
class TabsApi: public QObject{ | ||
Q_OBJECT | ||
public: | ||
TabsApi(QObject *parent=nullptr); | ||
Q_INVOKABLE bool addTabs(QJsonDocument tabs); | ||
Q_INVOKABLE void requestSplitTab(QString url); | ||
Q_INVOKABLE void requestSplitTab(); | ||
Q_INVOKABLE void requestFlipTabs(); | ||
Q_INVOKABLE void requestNewGroup(QString url); | ||
~TabsApi(); | ||
signals: | ||
void splitTabRequested(QUrl url); | ||
void splitTabHomeRequested(); | ||
void splitTabFlipRequested(); | ||
void newTabRequested(QUrl url); | ||
void addTabsRequested(QList<QList<QUrl>>); | ||
}; |
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,17 @@ | ||
#include "TerminalApi.h" | ||
|
||
#include <cstdlib> | ||
|
||
#ifdef __linux__ | ||
#include <pty.h> | ||
#endif | ||
|
||
TerminalApi::TerminalApi(QObject *parent): QObject(parent){ | ||
#ifdef __linux__ | ||
|
||
QString shell = QString(std::getenv("SHELL")); | ||
|
||
#endif | ||
} | ||
|
||
TerminalApi::~TerminalApi() = default; |
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,10 @@ | ||
#pragma once | ||
|
||
#include <QObject> | ||
|
||
class TerminalApi: public QObject{ | ||
Q_OBJECT | ||
public: | ||
TerminalApi(QObject *parent=nullptr); | ||
~TerminalApi(); | ||
}; |
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.