Skip to content

Commit

Permalink
prepare for build on github
Browse files Browse the repository at this point in the history
  • Loading branch information
steam0r committed Feb 27, 2024
1 parent f36f3b4 commit 4ca03ad
Show file tree
Hide file tree
Showing 19 changed files with 149 additions and 275 deletions.
8 changes: 2 additions & 6 deletions cables.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
"env": "electron",
"path": {
"ops": "../../cables/src/ops/",
"userops": "cables/src/ops/users/",
"teamops": "cables/src/ops/teams/",
"extensionops": "cables/src/ops/extensions/",
"patchops": "cables/src/ops/patches/",
"assets": "../public/assets/",
"libs": "../../public/libs/",
"corelibs": "../../public/libs_core/"
"libs": "../public/libs/",
"corelibs": "../public/libs_core/"
}
}
14 changes: 10 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import webpack from "webpack-stream";
import compiler from "webpack";
import webpackStandaloneConfig from "./webpack.standalone.config.js";

let configLocation = "./src/cables.json";
if (process.env.npm_config_apiconfig) configLocation = "./src/cables_env_" + process.env.npm_config_apiconfig + ".json";
let configLocation = "./cables.json";
if (process.env.npm_config_apiconfig) configLocation = "./cables_env_" + process.env.npm_config_apiconfig + ".json";

if (!fs.existsSync(configLocation))
{
Expand Down Expand Up @@ -39,8 +39,12 @@ function getBuildInfo()

function _api_copy()
{
const apiPath = path.join(config.path.api, "/src/base/");
return gulp.src("../cables_api/src/utils/base/*/**", { "base": apiPath }).pipe(gulp.dest("api/"));
return gulp.src("../cables_api/public/libs/**").pipe(gulp.dest("public/libs/"));
}

function _core_copy()
{
return gulp.src("../cables/build/libs/**").pipe(gulp.dest("public/libs_core/"));
}

function _ui_copy()
Expand Down Expand Up @@ -87,6 +91,8 @@ function _editor_scripts_webpack(done)
gulp.task("build", gulp.series(
gulp.parallel(
_editor_scripts_webpack,
_core_copy,
_api_copy,
_ui_copy
),
));
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
window.ipcRenderer = ipcRenderer;
const store = ipcRenderer.sendSync("store");

document.addEventListener('DOMContentLoaded', function (event) {
document.addEventListener('DOMContentLoaded', () => {
const editorIframe = document.getElementById("editorIframe");
let src = "ui/index.html" + window.location.search;
if (window.location.hash) {
Expand All @@ -47,7 +47,7 @@
}
}, false);

window.addEventListener("hashchange", (event) => {
window.addEventListener("hashchange", () => {
const patchIframe = document.getElementById("editorIframe");
if (patchIframe) {
patchIframe.contentWindow.postMessage({"type": "hashchange", "data": window.location.hash}, "*");
Expand Down
29 changes: 5 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"url": "[email protected]:cables-gl/cables_electron.git"
},
"license": "MIT",
"main": "src/main/index.js",
"main": "src/electron/main.js",
"type": "module",
"engines": {
"node": "18.14.2"
Expand Down Expand Up @@ -56,32 +56,13 @@
"electronLanguages": "en"
},
"dependencies": {
"@elastic/elasticsearch": "7.17.0",
"basename": "0.1.2",
"cables-shared": "file:../shared",
"discord-webhook-node": "1.1.8",
"eslint": "7.32.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-plugin-import": "2.27.5",
"ffmpeg": "^0.0.4",
"fs-extra": "11.1.0",
"geoip-lite": "1.4.7",
"http-server": "^14.1.1",
"jsonfile": "6.1.0",
"marked": "1.2.9",
"mkdirp": "2.1.3",
"moment": "2.29.4",
"node-osc": "^9.1.0",
"pako": "2.1.0",
"path-browserify": "^1.0.1",
"pmx": "1.6.7",
"sanitize-filename": "1.6.3",
"source-map-support": "^0.5.16",
"uuid-v4": "0.1.0",
"xml-writer": "1.7.0"
"marked": "1.2.9",
"jsonfile": "6.1.0",
"cables-shared": "file:../shared",
"electron": "29.0.0"
},
"devDependencies": {
"electron": "29.0.0",
"electron-builder": "24.12.0",
"git-repo-info": "2.1.1",
"gulp": "4.0.2",
Expand Down
48 changes: 42 additions & 6 deletions src/cables.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,51 @@
// hallo1234
import { Cables } from "cables-shared";
import { utilProvider, Cables } from "cables-shared";
import { app } from "electron";
import electronUtilProvider from "./utils/electron_util_provider.js";
import logger from "./utils/electron_logger.js";
import path from "path";
import fs from "fs";
import mkdirp from "mkdirp";
import logger from "./utils/logger.js";
import store from "./electron/electron_store.js";

logger.info("starting up cables");

class CablesStandalone extends Cables
{
get utilName()
getGenPath()
{
if (!store.getCurrentPatchDir()) return path.join(this._writeableDirName, "caches/");
return path.join(store.getCurrentPatchDir(), "caches/");
}

getOpDocsCachePath()
{
const cachePath = path.join(this.getGenPath(), "opdocs_collections/");
if (!fs.existsSync(cachePath)) mkdirp.sync(cachePath);
return cachePath;
}

getUserOpsPath()
{
if (!store.getCurrentPatchDir()) return path.join(this.getOpsPath(), "/users/");
return path.join(store.getCurrentPatchDir(), "/ops/users/");
}

getTeamOpsPath()
{
if (!store.getCurrentPatchDir()) return path.join(this.getOpsPath(), "/teams/");
return path.join(store.getCurrentPatchDir(), "/ops/teams/");
}

getExtensionOpsPath()
{
if (!store.getCurrentPatchDir()) return path.join(this.getOpsPath(), "/extensions/");
return path.join(store.getCurrentPatchDir(), "/ops/extensions/");
}

getPatchOpsPath()
{
return electronUtilProvider.CABLES_NAME;
if (!store.getCurrentPatchDir()) return path.join(this.getOpsPath(), "/patches/");
return path.join(store.getCurrentPatchDir(), "/ops/patches/");
}
}
export default new CablesStandalone(electronUtilProvider, decodeURIComponent(new URL(".", import.meta.url).pathname), app.getPath("userData"));
export default new CablesStandalone(utilProvider, decodeURIComponent(new URL(".", import.meta.url).pathname), app.getPath("userData"));
136 changes: 20 additions & 116 deletions src/endpoints/electron_endpoint.js → src/electron/electron_endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import marked from "marked";
import jsonfile from "jsonfile";
import crypto from "crypto";
import pako from "pako";
import mkdirp from "mkdirp";
import cables from "../cables.js";
import opsUtil from "../utils/electron_ops_util.js";
import doc from "../utils/electron_doc_util.js";
import helper from "../utils/electron_helper_util.js";
import subPatchOpUtil from "../utils/electron_subpatchop_util.js";
import Store from "../electron_store.js";
import logger from "../utils/electron_logger.js";
import logger from "../utils/logger.js";
import doc from "../utils/doc_util.js";
import helper from "../utils/helper_util.js";
import opsUtil from "../utils/ops_util.js";
import subPatchOpUtil from "../utils/subpatchop_util.js";
import store from "./electron_store.js";

protocol.registerSchemesAsPrivileged([{ "scheme": "cables", "privileges": { "bypassCSP": true, "supportFetchAPI": true } }]);

class ElectronEndpoint
{
constructor()
{
const store = new Store(path.join(app.getPath("userData"), "patches"));
this._log = logger;
this._store = store;
this._store.set("currentUser", this.getCurrentUser());
Expand Down Expand Up @@ -115,7 +115,6 @@ class ElectronEndpoint

async talkerMessage(cmd, data)
{
this._log.info("calling", cmd);
let response = null;
if (!cmd) return null;
if (typeof this[cmd] === "function")
Expand Down Expand Up @@ -172,13 +171,8 @@ class ElectronEndpoint
const ops = subPatchOpUtil.getOpsUsedInSubPatches(project);
missingOps = missingOps.concat(ops);
missingOps = missingOps.filter((op) => { return !opDocs.some((d) => { return d.id === op.opId; }); });
missingOps = missingOps.filter((obj, index) => { return missingOps.findIndex((item) => { return item.opId == obj.opId; }) === index; });
missingOps = missingOps.filter((obj, index) => { return missingOps.findIndex((item) => { return item.opId === obj.opId; }) === index; });
code = opsUtil.buildFullCode(missingOps, opsUtil.PREFIX_OPS, opDocs);
const opsJs = path.join(this._store.getCurrentPatchDir(), "/js/ops.js");
if (fs.existsSync(opsJs))
{
code += fs.readFileSync(opsJs);
}
return code;
}
else
Expand All @@ -187,10 +181,6 @@ class ElectronEndpoint
}
}

patchCreateBackup()
{
}

savePatch(patch)
{
const project = this.getPatch();
Expand Down Expand Up @@ -286,17 +276,6 @@ class ElectronEndpoint
return project;
}

saveProjectAs()
{
}

saveScreenshot()
{
}

setProjectName()
{
}

getBuildInfo()
{
Expand Down Expand Up @@ -335,30 +314,6 @@ class ElectronEndpoint
};
}

getFilelist()
{
}

fileConvert()
{
}

getFileDetails()
{
}

getLibraryFileInfo()
{
}

deleteFile()
{
}

createFile()
{
}

fileUploadStr(data)
{
const target = path.join(this._store.getCurrentPatchDir(), "/assets/");
Expand Down Expand Up @@ -432,9 +387,6 @@ class ElectronEndpoint
return opDocs;
}

getAllOps()
{
}

async getOpDocsAll()
{
Expand Down Expand Up @@ -513,17 +465,14 @@ class ElectronEndpoint
return result;
}

getCollectionOpDocs()
{
}

opCreate()
{
}

saveOpCode(data)
{
const opName = opsUtil.getOpNameById(data.opname);
const opDir = opsUtil.getOpSourceDir(opName);
if (!fs.existsSync(opDir))
{
mkdirp.sync(opDir);
}
const fn = opsUtil.getOpAbsoluteFileName(opName);
this._log.info("save op ", opName, fn);

Expand Down Expand Up @@ -695,46 +644,6 @@ class ElectronEndpoint
}
}

opSaveLayout()
{
}

opAddLib()
{
}

opRemoveLib()
{
}

opAddCoreLib()
{
}

opRemoveCoreLib()
{
}

opClone()
{
}

opAttachmentAdd()
{
}

opAttachmentGet()
{
}

opAttachmentDelete()
{
}

opAttachmentSave()
{
}

saveUserSettings(data)
{
if (data && data.settings)
Expand All @@ -743,18 +652,6 @@ class ElectronEndpoint
}
}

checkOpName()
{
}

setIconUnsaved()
{
}

setIconSaved()
{
}

checkProjectUpdated(data)
{
const project = this.getPatch();
Expand Down Expand Up @@ -809,6 +706,13 @@ class ElectronEndpoint
return obj;
}

opAttachmentSave(data)
{
opsUtil.updateAttachment(data.opname, data.name, data.content, false);
return true;
}


_generateRandomId()
{
// https://gist.github.com/solenoid/1372386
Expand Down
Loading

0 comments on commit 4ca03ad

Please sign in to comment.