Skip to content

Commit

Permalink
✨ Pluto v1.5
Browse files Browse the repository at this point in the history
Changes:
- Large file support (finally)
- New custom resize cursors
- Theme transition should work better on WebKit browsers
- App store caching issue fixed
- Added AudioPlayer and VideoPlayer as modified versions of ImageViewer
- Loading screen can be stopped if it doesn't finish in time
- Proper file mappings for MP4, MOV, MKV, AVI, WebM, WAV, MPEG and MP3.

Co-authored-by: Lap <[email protected]>
Co-authored-by: tuck <[email protected]>
  • Loading branch information
3 people committed Jan 14, 2024
1 parent 8f41a0c commit 6e5940d
Show file tree
Hide file tree
Showing 16 changed files with 810 additions and 195 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Pluto v1.4
# Pluto v1.5

![Pluto banner](assets/images/banner.svg)

Expand Down
12 changes: 9 additions & 3 deletions assets/icons.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 37 additions & 29 deletions core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
(async () => {
try {
const coreDetails = {
version: 1.45,
versionString: (1.4).toFixed(1),
version: 1.5,
versionString: (1.5).toFixed(1),
codename: "Elysium",
};
const knownLibraries = [];
Expand Down Expand Up @@ -282,6 +282,31 @@
}
}
},
randomString: (_) => {
if (crypto && crypto.randomUUID) return crypto.randomUUID();
else {
var d = new Date().getTime();
var d2 =
(typeof performance !== "undefined" &&
performance.now &&
performance.now() * 1000) ||
0;
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
/[xy]/g,
function (c) {
var r = Math.random() * 16;
if (d > 0) {
r = (d + r) % 16 | 0;
d = Math.floor(d / 16);
} else {
r = (d2 + r) % 16 | 0;
d2 = Math.floor(d2 / 16);
}
return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
}
);
}
},
loadLibrary: async function (lib) {
if (lib.includes(":")) return false;
knownLibraries.push(lib);
Expand Down Expand Up @@ -343,16 +368,24 @@
};

this.html = GlobalLib.html;
this.randomString = GlobalLib.randomString;
this.icons = GlobalLib.icons;
this.systemInfo = coreDetails;

this.langs = supportedLangs;
this.launch = async (app, parent = "body") => {
let appName = "";

if (Core.processList[Pid].proc !== null) {
appName = Core.processList[Pid].proc.name;
} else {
appName = "???";
}
if (
(await Modal.prompt(
getString("notice"),
getString("core_appLaunch_notification", {
suspectedApp: Core.processList[Pid].proc.name,
suspectedApp: appName,
targetApp: app.split(":").pop(),
}),
parent
Expand Down Expand Up @@ -457,31 +490,6 @@
Core.processList[pid] = null;
console.groupEnd();
},
randomString: (_) => {
if (crypto && crypto.randomUUID) return crypto.randomUUID();
else {
var d = new Date().getTime();
var d2 =
(typeof performance !== "undefined" &&
performance.now &&
performance.now() * 1000) ||
0;
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
/[xy]/g,
function (c) {
var r = Math.random() * 16;
if (d > 0) {
r = (d + r) % 16 | 0;
d = Math.floor(d / 16);
} else {
r = (d2 + r) % 16 | 0;
d2 = Math.floor(d2 / 16);
}
return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
}
);
}
},
};

let Modal;
Expand Down Expand Up @@ -587,7 +595,7 @@
pid: PID,
proc: null,
};
const Token = ProcLib.randomString();
const Token = GlobalLib.randomString();
const newLib = new processLib(url, PID, Token, pkg.strings);
if (Core.processList[PID]) Core.processList[PID].token = Token;
let result;
Expand Down
8 changes: 4 additions & 4 deletions pkgs/apps/AppStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default {

let host = "https://zeondev.github.io/Pluto-AppStore/";

const appStoreModule = (await import(`${host}import.js`)).default;
const appStoreModule = (await import(`${host}import.js?t=` + performance.now())).default;

// Check if this is the right app store module
if (appStoreModule.init) {
Expand Down Expand Up @@ -117,7 +117,7 @@ export default {
}

async function installApp(pkg, app, force = false) {
await fetch(`${host}pkgs/${pkg}/${app.assets.path}`)
await fetch(`${host}pkgs/${pkg}/${app.assets.path}?t=` + performance.now())
.then(async (e) => {
console.log(await vfs.whatIs(`Root/Pluto/apps/${app.name}.app`));
if (
Expand Down Expand Up @@ -194,7 +194,7 @@ export default {
for (let pkg of packageList) {
const app = await appStoreModule.fetch(pkg);

console.log("pkgResult", app);
console.log(pkg, "pkgResult", app);

const { appCompatibleColor, appCompatibleIcon } =
getAppCompatibility(app.compatibleWith, sysInfo.version);
Expand Down Expand Up @@ -274,7 +274,7 @@ export default {
await vfs.readFile(`Root/Pluto/apps/${app.name}.app`)
);
const appHash = await fetch(
`${host}pkgs/${pkg}/${app.assets.path}`
`${host}pkgs/${pkg}/${app.assets.path}?t=` + performance.now()
).then(async (e) => {
return new Hashes.MD5().hex(await e.text());
});
Expand Down
106 changes: 106 additions & 0 deletions pkgs/apps/AudioPlayer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
export default {
name: "Audio Player",
description: "Listen to your music in this app.",
ver: 1, // Compatible with core v1
type: "process",
exec: async function (Root) {
let wrapper; // Lib.html | undefined
let MyWindow;

console.log("Hello from example package", Root.Lib);

Root.Lib.setOnEnd(function () {
MyWindow.close();
});
const Win = (await Root.Lib.loadLibrary("WindowSystem")).win;

MyWindow = new Win({
title: "Audio Player",
pid: Root.PID,
onclose: () => {
Root.Lib.onEnd();
},
});

// initializing wrappers and vfs
wrapper = MyWindow.window.querySelector(".win-content");

const vfs = await Root.Lib.loadLibrary("VirtualFS");
const FileDialog = await Root.Lib.loadLibrary("FileDialog");

await vfs.importFS();

wrapper.classList.add("with-sidebar", "row", "o-h", "h-100");

const Sidebar = await Root.Lib.loadComponent("Sidebar");

// this function opens the file and changes the title to the file name,
// we load the file into a buffer
async function openFile(path) {
let file;
if (path) file = path;
else file = await FileDialog.pickFile("Root");
if (file === false) return;
let result = updateAudio(await vfs.readFile(file));
if (result === false) return;
MyWindow.window.querySelector(".win-titlebar .title").innerText =
"Audio Player - " + file.split("/").pop();
MyWindow.focus();
}

// creates sidebar
Sidebar.new(wrapper, [
{
onclick: async (_) => {
openFile();
},
html: Root.Lib.icons.fileAudio,
title: "Select Audio...",
},
{
style: {
"margin-top": "auto",
},
onclick: (_) => {
alert("Not implemented");
},
html: Root.Lib.icons.help,
title: "Help",
},
]);

// creates the wrapper that the image is in
let vidWrapper = new Root.Lib.html("div")
.class("ovh", "fg", "fc", "row")
.appendTo(wrapper);

// creates the actual img element
let img = new Root.Lib.html("audio")
.appendTo(vidWrapper)
.style({
width: "100%",
"object-fit": "contain",
border: "none",
})
.attr({ draggable: "false", controls: 'on' });

// updates the video on the next load
function updateAudio(content) {
if (!content.startsWith("data:audio/") && !content.startsWith("blob:")) {
Root.Modal.alert("Error", "This does not look like an audio file").then(
(_) => {
MyWindow.focus();
}
);
return false;
}
img.elm.src = content;
}

return Root.Lib.setupReturns((m) => {
if (typeof m === "object" && m.type && m.type === "loadFile" && m.path) {
openFile(m.path);
}
});
},
};
Loading

0 comments on commit 6e5940d

Please sign in to comment.