Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
fix: Bump to ESM and update all deps (#1851)
Browse files Browse the repository at this point in the history
* chore: Bump various packages

* feat: Update everything to ESM

* fix: building and porting js to cjs
  • Loading branch information
coredev-uk authored May 18, 2024
1 parent 89ee84b commit 05d3208
Show file tree
Hide file tree
Showing 32 changed files with 5,946 additions and 5,906 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
src/renderer/*hls*.js
build/*
dist/*
src/renderer/lib/*
*.min.*
.pnpm-store
28 changes: 0 additions & 28 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

This file was deleted.

8 changes: 4 additions & 4 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
nodeLinker: node-modules
compressionLevel: mixed

enableGlobalCache: false

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
nodeLinker: node-modules
94 changes: 50 additions & 44 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
"version": "1.6.2",
"description": "A new cross-platform Apple Music experience based on Electron and Vue.js written from scratch with performance in mind.",
"license": "AGPL-3.0",
"exports": "./build/index.js",
"main": "./build/index.js",
"author": "Cider Collective <[email protected]> (https://cider.sh)",
"repository": "github:ciderapp/Cider",
"type": "module",
"bugs": {
"url": "https://github.com/ciderapp/Cider/issues?q=is%3Aopen+is%3Aissue+label%3Abug"
},
Expand All @@ -29,29 +31,29 @@
"format:write": "npx prettier --write \"src/**/*.{js,json,ts,less}\""
},
"dependencies": {
"@achingbrain/ssdp": "^4.0.4",
"@crowdin/ota-client": "^1.1.0",
"@sentry/electron": "^4.6.0",
"@sentry/integrations": "^7.69.0",
"adm-zip": "^0.5.10",
"airtunes2": "github:ciderapp/node_airtunes2",
"castv2-client": "^1.2.0",
"chokidar": "^3.5.3",
"@achingbrain/ssdp": "^4.0.6",
"@crowdin/ota-client": "^1.1.1",
"@sentry/electron": "^4.24.0",
"@sentry/integrations": "7.114.0",
"adm-zip": "^0.5.12",
"airtunes2": "ciderapp/node_airtunes2",
"castv2-client": "ciderapp/node-castv2-client",
"chokidar": "^3.6.0",
"discord-auto-rpc": "^1.0.17",
"ejs": "^3.1.9",
"electron-fetch": "^1.9.1",
"electron-log": "^4.4.8",
"ejs": "^3.1.10",
"electron-log": "^5.1.4",
"electron-notarize": "^1.2.2",
"electron-store": "^8.1.0",
"electron-updater": "^5.3.0",
"electron-store": "^9.0.0",
"electron-updater": "6.2.1",
"electron-window-state": "^5.0.3",
"express": "^4.18.2",
"get-port": "5.1.1",
"jimp": "^0.22.8",
"express": "^4.19.2",
"get-port": "7.1.0",
"jimp": "^0.22.12",
"lastfmapi": "^0.1.1",
"mdns-js": "github:ciderapp/node-mdns-js",
"mpris-service": "^2.1.2",
"music-metadata": "7.12.6",
"mdns-js": "ciderapp/node-mdns-js",
"mpris-service": "ciderapp/mpris-service",
"music-metadata": "7.14.0",
"node-fetch": "^3.3.2",
"node-ssdp": "^4.0.1",
"node-ssdp-js": "^0.9.6",
"qrcode": "^1.5.3",
Expand All @@ -60,31 +62,35 @@
"source-map-support": "^0.5.21",
"ssdp-js": "^1.0.1",
"ts-md5": "1.3.1",
"upnp-mediarenderer-client": "github:vapormusic/node-upnp-mediarenderer-client",
"v8-compile-cache": "^2.3.0",
"wallpaper": "5.0.1",
"ws": "^8.14.1",
"xml2js": "^0.6.0",
"youtube-search-without-api-key": "^1.1.0"
"upnp-mediarenderer-client": "vapormusic/node-upnp-mediarenderer-client",
"v8-compile-cache": "^2.4.0",
"wallpaper": "7.2.1",
"ws": "^8.17.0",
"xml2js": "^0.6.2",
"youtube-search-without-api-key": "^2.0.1"
},
"devDependencies": {
"@types/adm-zip": "^0.5.0",
"@types/discord-rpc": "4.0.4",
"@types/express": "^4.17.17",
"@types/musickit": "github:ciderapp/musickit-types",
"@types/node": "^20.2.5",
"@types/qrcode-terminal": "^0.12.0",
"@types/ws": "^8.5.4",
"electron": "github:castlabs/electron-releases",
"electron-builder": "^23.6.0",
"@types/adm-zip": "^0.5.5",
"@types/discord-rpc": "4.0.8",
"@types/express": "^4.17.21",
"@types/musickit": "ciderapp/musickit-types",
"@types/node": "^20.12.12",
"@types/node-ssdp": "^4.0.4",
"@types/qrcode-terminal": "^0.12.2",
"@types/request": "^2.48.12",
"@types/upnp-mediarenderer-client": "^1.4.3",
"@types/ws": "^8.5.10",
"@types/xml2js": "^0.4.14",
"electron": "github:castlabs/electron-releases#v30.0.4+wvcus",
"electron-builder": "^24.13.3",
"electron-builder-notarize-pkg": "^1.2.0",
"electron-webpack": "^2.8.2",
"less": "^4.1.3",
"node-gyp": "^9.4.0",
"prettier": "2.8.8",
"typescript": "^5.1.3",
"less": "^4.2.0",
"node-gyp": "^10.1.0",
"prettier": "3.2.5",
"typescript": "^5.4.5",
"vue-devtools": "^5.1.4",
"webpack": "~5.85.0"
"webpack": "~5.91.0"
},
"fileAssociations": [
{
Expand All @@ -109,14 +115,14 @@
}
],
"build": {
"electronVersion": "25.0.0",
"electronVersion": "30.0.6",
"electronDownload": {
"version": "25.0.0+wvcus",
"version": "30.0.6+wvcus",
"mirror": "https://github.com/castlabs/electron-releases/releases/download/v"
},
"appId": "cider",
"afterPack": "./resources/afterPack.js",
"afterSign": "./resources/notarize.js",
"afterPack": "./resources/afterPack.cjs",
"afterSign": "./resources/notarize.cjs",
"protocols": [
{
"name": "Cider",
Expand Down Expand Up @@ -224,7 +230,7 @@
"devtool": "source-map"
},
"engines": {
"node": ">= 16",
"node": ">= 18",
"npm": ">= 6.13.4",
"yarn": ">= 1.21.1"
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
25 changes: 13 additions & 12 deletions src/main/base/app.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { app, Menu, nativeImage, Tray, ipcMain, clipboard, shell } from "electron";
import { readFileSync } from "fs";
import * as path from "path";
import * as log from "electron-log";
import * as os from "os";
import { utils } from "./utils";
import { Menu, Tray, app, clipboard, ipcMain, nativeImage, shell } from "electron";
import log from "electron-log";
import { readFileSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import os from "os";
import { utils } from "../base/utils.js";

/**
* @file Creates App instance
Expand Down Expand Up @@ -45,7 +46,7 @@ export class AppEvents {

// Log File Location
if (app.commandLine.hasSwitch("log") || app.commandLine.hasSwitch("l")) {
console.log(path.join(app.getPath("userData"), "logs"));
console.log(join(app.getPath("userData"), "logs"));
app.exit();
}

Expand Down Expand Up @@ -107,7 +108,7 @@ export class AppEvents {
if (process.defaultApp) {
if (process.argv.length >= 2) {
this.protocols.forEach((protocol: string) => {
app.setAsDefaultProtocolClient(protocol, process.execPath, [path.resolve(process.argv[1])]);
app.setAsDefaultProtocolClient(protocol, process.execPath, [resolve(process.argv[1])]);
});
}
} else {
Expand Down Expand Up @@ -263,15 +264,15 @@ export class AppEvents {
*/
private InitTray() {
const icons = {
win32: nativeImage.createFromPath(path.join(__dirname, `../../resources/icons/icon.ico`)).resize({
win32: nativeImage.createFromPath(join(dirname(fileURLToPath(import.meta.url)), `../../resources/icons/icon.ico`)).resize({
width: 32,
height: 32,
}),
linux: nativeImage.createFromPath(path.join(__dirname, `../../resources/icons/icon.png`)).resize({
linux: nativeImage.createFromPath(join(dirname(fileURLToPath(import.meta.url)), `../../resources/icons/icon.png`)).resize({
width: 32,
height: 32,
}),
darwin: nativeImage.createFromPath(path.join(__dirname, `../../resources/icons/icon.png`)).resize({
darwin: nativeImage.createFromPath(join(dirname(fileURLToPath(import.meta.url)), `../../resources/icons/icon.png`)).resize({
width: 20,
height: 20,
}),
Expand Down Expand Up @@ -314,7 +315,7 @@ export class AppEvents {
private setTray(visible: boolean = utils.getWindow().isVisible()) {
this.i18n = utils.getLocale(utils.getStoreValue("general.language"));

const ciderIcon = nativeImage.createFromPath(path.join(__dirname, `../../resources/icons/icon.png`)).resize({
const ciderIcon = nativeImage.createFromPath(join(dirname(fileURLToPath(import.meta.url)), `../../resources/icons/icon.png`)).resize({
width: 24,
height: 24,
});
Expand Down
48 changes: 24 additions & 24 deletions src/main/base/browserwindow.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import AdmZip from "adm-zip";
import { watch } from "chokidar";
import { ShareMenu, app, BrowserWindow as bw, dialog, ipcMain, nativeTheme, screen, shell } from "electron";
import windowStateKeeper from "electron-window-state";
import express from "express";
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, rmSync, rmdirSync, statSync, unlinkSync, writeFileSync } from "fs";
import getPort from "get-port";
import { LocalFiles } from "../providers/local/index.js";
import mm from "music-metadata";
import fetch from "node-fetch";
import os, { networkInterfaces } from "os";
import { join } from "path";
import { app, BrowserWindow as bw, ipcMain, ShareMenu, shell, screen, dialog, nativeTheme, ipcRenderer } from "electron";
import * as windowStateKeeper from "electron-window-state";
import * as express from "express";
import * as getPort from "get-port";
import { search } from "youtube-search-without-api-key";
import { existsSync, rmSync, mkdirSync, readdirSync, readFileSync, writeFileSync, statSync, unlinkSync, rmdirSync, lstatSync } from "fs";
import { Stream } from "stream";
import { networkInterfaces } from "os";
import * as mm from "music-metadata";
import fetch from "electron-fetch";
import { wsapi } from "./wsapi";
import { utils } from "./utils";
import { Plugins } from "./plugins";
import { watch } from "chokidar";
import * as os from "os";
import wallpaper from "wallpaper";
import * as AdmZip from "adm-zip";
import { LocalFiles } from "../providers/local/";
import { getWallpaper } from "wallpaper";
import { search } from "youtube-search-without-api-key";
import { Plugins } from "./plugins.js";
import { utils } from "./utils.js";
import { wsapi } from "./wsapi.js";

/**
* @file Creates the BrowserWindow
Expand Down Expand Up @@ -792,8 +791,8 @@ export class BrowserWindow {
});

ipcMain.on("get-wallpaper", async (event, args) => {
const wpPath: string = await wallpaper.get();
const Jimp = require("jimp");
const wpPath: string = await getWallpaper();
const Jimp = (await import("jimp")).default;
const img = await Jimp.read(wpPath);
const blurAmount = args.blurAmount ?? 256;
if (blurAmount) {
Expand Down Expand Up @@ -885,7 +884,7 @@ export class BrowserWindow {
if (url.endsWith("/")) url = url.slice(0, -1);
let response = await utils.fetch(`${url}/archive/refs/heads/main.zip`);
let repo = url.split("/").slice(-2).join("/");
let apiRepo = await utils.fetch(`https://api.github.com/repos/${repo}`).then((res) => res.json());
let apiRepo = await utils.fetch(`https://api.github.com/repos/${repo}`).then((res) => res.json()) as { id: number};
console.debug(`REPO ID: ${apiRepo.id}`);
// extract the files from the first folder in the zip response
let zip = new AdmZip(await response.buffer());
Expand All @@ -895,7 +894,7 @@ export class BrowserWindow {
}
console.log(join(utils.getPath("plugins"), "gh_" + apiRepo.id));
zip.extractEntryTo(entry, join(utils.getPath("plugins"), "gh_" + apiRepo.id), false, true);
let commit = await utils.fetch(`https://api.github.com/repos/${repo}/commits`).then((res) => res.json());
let commit = await utils.fetch(`https://api.github.com/repos/${repo}/commits`).then((res) => res.json()) as { sha: string }[];
console.debug(`COMMIT SHA: ${commit[0].sha}`);
let theme = JSON.parse(readFileSync(join(utils.getPath("plugins"), "gh_" + apiRepo.id, "package.json"), "utf8"));
theme.id = apiRepo.id;
Expand Down Expand Up @@ -928,7 +927,7 @@ export class BrowserWindow {
"User-Agent": utils.getWindow().webContents.getUserAgent(),
},
})
.then((res) => res.json());
.then((res) => res.json()) as { id: number}
console.error(apiRepo);
console.debug(`REPO ID: ${apiRepo.id}`);
// extract the files from the first folder in the zip response
Expand All @@ -942,7 +941,7 @@ export class BrowserWindow {
let subFolder = entry.entryName.split("/").slice(1, -1).join("/");
zip.extractEntryTo(entry, join(utils.getPath("themes"), "gh_" + apiRepo.id, "/", subFolder), false, true);
});
let commit = await utils.fetch(`https://api.github.com/repos/${repo}/commits`).then((res) => res.json());
let commit = await utils.fetch(`https://api.github.com/repos/${repo}/commits`).then((res) => res.json()) as { sha: string }[];
console.debug(`COMMIT SHA: ${commit[0].sha}`);
let theme = JSON.parse(readFileSync(join(utils.getPath("themes"), "gh_" + apiRepo.id, "theme.json"), "utf8"));
theme.id = apiRepo.id;
Expand Down Expand Up @@ -1355,6 +1354,7 @@ export class BrowserWindow {
}
// Get previews for normalization
ipcMain.on("getPreviewURL", (_event, url) => {

fetch(url)
.then((res) => res.buffer())
.then(async (buffer) => {
Expand Down Expand Up @@ -1664,7 +1664,7 @@ export class BrowserWindow {
*/
private async broadcastRemote() {
const myString = `http://${BrowserWindow.getIP()}:${this.remotePort}`;
const mdns = require("mdns-js");
const mdns = (await import("mdns-js")).default;
const encoded = Buffer.from(myString).toString("base64");
const x = mdns.tcp("cider-remote");
const txt_record = {
Expand Down
32 changes: 0 additions & 32 deletions src/main/base/castcontroller.js

This file was deleted.

32 changes: 32 additions & 0 deletions src/main/base/castcontroller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// @ts-nocheck
import castv2Cli from "castv2-client";
const RequestResponseController = castv2Cli.RequestResponseController;



export class CiderCastController extends RequestResponseController {
constructor(client: string, sourceId: string, destinationId: string) {
super(client, sourceId, destinationId, "urn:x-cast:com.ciderapp.customdata");
this.once("close", onclose);
var self = this;
function onclose() {
self.stop();
}
}

sendIp(ip: string) {
// TODO: Implement Callback
let data = {
ip: ip,
};
this.request(data);
}

kill() {
// TODO: Implement Callback
let data = {
action: "stop",
};
this.request(data);
}
}
Loading

0 comments on commit 05d3208

Please sign in to comment.