init
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:import/recommended",
|
||||
"plugin:import/electron",
|
||||
"plugin:import/typescript"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser"
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
.DS_Store
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# Webpack
|
||||
.webpack/
|
||||
|
||||
# Vite
|
||||
.vite/
|
||||
|
||||
# Electron-Forge
|
||||
out/
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
<a href="javascript: window.parent.postMessage('YO', '*')">test</a>
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,37 @@
|
||||
import type { ForgeConfig } from '@electron-forge/shared-types';
|
||||
import { MakerSquirrel } from '@electron-forge/maker-squirrel';
|
||||
import { MakerZIP } from '@electron-forge/maker-zip';
|
||||
import { MakerDeb } from '@electron-forge/maker-deb';
|
||||
import { MakerRpm } from '@electron-forge/maker-rpm';
|
||||
import { WebpackPlugin } from '@electron-forge/plugin-webpack';
|
||||
|
||||
import { mainConfig } from './webpack.main.config';
|
||||
import { rendererConfig } from './webpack.renderer.config';
|
||||
|
||||
const config: ForgeConfig = {
|
||||
packagerConfig: {},
|
||||
rebuildConfig: {},
|
||||
makers: [new MakerSquirrel({}), new MakerZIP({}, ['darwin']), new MakerRpm({}), new MakerDeb({})],
|
||||
plugins: [
|
||||
new WebpackPlugin({
|
||||
mainConfig,
|
||||
devContentSecurityPolicy: `default-src * 'unsafe-inline' 'unsafe-eval' file:`,
|
||||
renderer: {
|
||||
config: rendererConfig,
|
||||
entryPoints: [
|
||||
{
|
||||
html: './src/index.html',
|
||||
js: './src/renderer.ts',
|
||||
name: 'main_window',
|
||||
preload: {
|
||||
js: './src/preload.ts',
|
||||
|
||||
},
|
||||
}
|
||||
],
|
||||
},
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
export default config;
|
||||
Generated
+19467
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "tür-browser",
|
||||
"productName": "tür-browser",
|
||||
"version": "1.0.0",
|
||||
"description": "My Electron application description",
|
||||
"main": ".webpack/main",
|
||||
"scripts": {
|
||||
"start": "electron-forge start",
|
||||
"package": "electron-forge package",
|
||||
"make": "electron-forge make",
|
||||
"publish": "electron-forge publish",
|
||||
"lint": "eslint --ext .ts,.tsx ."
|
||||
},
|
||||
"keywords": [],
|
||||
"author": {
|
||||
"name": "nitowa",
|
||||
"email": "frontblock.me@gmail.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@electron-forge/cli": "^6.1.1",
|
||||
"@electron-forge/maker-deb": "^6.1.1",
|
||||
"@electron-forge/maker-rpm": "^6.1.1",
|
||||
"@electron-forge/maker-squirrel": "^6.1.1",
|
||||
"@electron-forge/maker-zip": "^6.1.1",
|
||||
"@electron-forge/plugin-webpack": "^6.1.1",
|
||||
"@typescript-eslint/eslint-plugin": "^5.59.1",
|
||||
"@typescript-eslint/parser": "^5.59.1",
|
||||
"@vercel/webpack-asset-relocator-loader": "^1.7.3",
|
||||
"copy-webpack-plugin": "^11.0.0",
|
||||
"css-loader": "^6.7.3",
|
||||
"electron": "24.1.3",
|
||||
"eslint": "^8.39.0",
|
||||
"eslint-plugin-import": "^2.27.5",
|
||||
"fork-ts-checker-webpack-plugin": "^7.3.0",
|
||||
"node-loader": "^2.0.0",
|
||||
"style-loader": "^3.3.2",
|
||||
"ts-loader": "^9.4.2",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "~4.5.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"electron-squirrel-startup": "^1.0.0",
|
||||
"rjsvm": "^0.1.2",
|
||||
"tur-toolkit": "^0.0.9",
|
||||
"xrpio": "^0.2.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import { z } from "zod";
|
||||
import { RJSVM_Implementations, RJSVM_Interface, RJSVM, RJSVM_Config, RJSVM_Builder } from "rjsvm"
|
||||
|
||||
const shoutSchema = z.object({
|
||||
title: z.string(),
|
||||
body: z.string(),
|
||||
from: z.string(),
|
||||
id: z.optional(z.string())
|
||||
})
|
||||
|
||||
type Shout = z.infer<typeof shoutSchema>
|
||||
|
||||
type State_T = {
|
||||
shouts: Shout[]
|
||||
}
|
||||
|
||||
type RJSVM_Endpoints = {
|
||||
submit: (data: Shout) => void
|
||||
}
|
||||
|
||||
abstract class RJSVM_Base
|
||||
extends RJSVM<State_T, RJSVM_Endpoints>
|
||||
implements RJSVM_Interface<RJSVM_Base> {
|
||||
state: State_T = {
|
||||
shouts: []
|
||||
}
|
||||
}
|
||||
|
||||
const RJSVM_Contract: RJSVM_Implementations<RJSVM_Base> = {
|
||||
submit: {
|
||||
implementation: function (env, shout) {
|
||||
this.state.shouts.unshift(shout)
|
||||
console.log(shout)
|
||||
},
|
||||
visibility: 'public',
|
||||
fee: 10,
|
||||
parameterSchema: shoutSchema
|
||||
}
|
||||
}
|
||||
|
||||
const conf: RJSVM_Config = {
|
||||
listeningAddress: "rBGqUNVzrNJ6CNpTriBts8QCTNi5VqUMnZ",
|
||||
rippleNode: "wss://s.altnet.rippletest.net:51233"
|
||||
}
|
||||
const Rjsvm = RJSVM_Builder.from(RJSVM_Base, RJSVM_Contract);
|
||||
|
||||
export const tns_rjsvm = new Rjsvm(conf)
|
||||
tns_rjsvm.state.shouts
|
||||
@@ -0,0 +1,4 @@
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
|
||||
Arial, sans-serif;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<body>
|
||||
<div style="width:100%">
|
||||
<input style="width: 70%;" value="9C0F205A956F4D7EE6AB6D918E7E4D596CE05F08DBB5C4D16758BEF46F3FFC2D" type="text"
|
||||
placeholder="Resource hash" id="searchBar" /><input type="button" value="GO" id="searchButton" />
|
||||
<iframe id="contentFrame" frameBorder="0" style="width: 100%; height: 100%;"></iframe>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,87 @@
|
||||
import { app, BrowserWindow, ipcMain } from 'electron';
|
||||
import { xrpIO } from 'xrpio';
|
||||
import { writeFileSync, existsSync, mkdirSync } from 'fs';
|
||||
import { tns_rjsvm } from './RJSVMs/tns';
|
||||
|
||||
// This allows TypeScript to pick up the magic constants that's auto-generated by Forge's Webpack
|
||||
// plugin that tells the Electron app where to look for the Webpack-bundled app code (depending on
|
||||
// whether you're running in development or production).
|
||||
|
||||
declare const MAIN_WINDOW_WEBPACK_ENTRY: string;
|
||||
declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: string;
|
||||
|
||||
const tur_conf = {
|
||||
downloadsPath: '/home/caligvla/tur/tur-browser/downloads/',
|
||||
rippleNode: 'wss://s.altnet.rippletest.net:51233'
|
||||
}
|
||||
|
||||
const xrpio = new xrpIO(tur_conf.rippleNode)
|
||||
xrpio.connect()
|
||||
|
||||
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
||||
if (require('electron-squirrel-startup')) {
|
||||
app.quit();
|
||||
}
|
||||
|
||||
const createWindow = (): void => {
|
||||
// Create the browser window.
|
||||
const mainWindow = new BrowserWindow({
|
||||
|
||||
height: 600,
|
||||
width: 800,
|
||||
webPreferences: {
|
||||
preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,
|
||||
webSecurity: false,
|
||||
},
|
||||
});
|
||||
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);
|
||||
|
||||
// Open the DevTools.
|
||||
mainWindow.webContents.openDevTools();
|
||||
};
|
||||
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
app.on('ready', () => {
|
||||
ipcMain.handle('xrpioDownload', async (event, args) => {
|
||||
const path = `${tur_conf.downloadsPath}${args}.html`
|
||||
if(existsSync(path)){
|
||||
return path
|
||||
}
|
||||
const html = await xrpio.treeRead([args]);
|
||||
mkdirSync(tur_conf.downloadsPath, { recursive: true });
|
||||
writeFileSync(path, html);
|
||||
|
||||
return path
|
||||
})
|
||||
|
||||
createWindow()
|
||||
});
|
||||
|
||||
// Quit when all windows are closed, except on macOS. There, it's common
|
||||
// for applications and their menu bar to stay active until the user quits
|
||||
// explicitly with Cmd + Q.
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
app.on('activate', () => {
|
||||
// On OS X it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
// In this file you can include the rest of your app's specific main process
|
||||
// code. You can also put them in separate files and import them here.
|
||||
|
||||
tns_rjsvm.connect()
|
||||
@@ -0,0 +1,8 @@
|
||||
// See the Electron documentation for details on how to use preload scripts:
|
||||
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts
|
||||
|
||||
import { contextBridge, ipcRenderer } from "electron";
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
xrpioDownload: (hash: string) => ipcRenderer.invoke('xrpioDownload', hash),
|
||||
})
|
||||
@@ -0,0 +1,34 @@
|
||||
import './index.css';
|
||||
import { handleIpc } from 'tur-toolkit'
|
||||
declare const window: any
|
||||
|
||||
//window.document.getElementById('contentFrame').addEventListener('ipc-message', console.log)
|
||||
|
||||
handleIpc((event, source) => {
|
||||
console.log(event, source)
|
||||
switch(event.data.type){
|
||||
case "Navigation":
|
||||
httxrpNavigate(event.data.data)
|
||||
break;
|
||||
|
||||
case "Transaction":
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
})
|
||||
|
||||
const httxrpNavigate = async (resourceHash: string) => {
|
||||
try{
|
||||
const path = await window.electronAPI.xrpioDownload(resourceHash)
|
||||
window.document.getElementById('contentFrame').setAttribute("src", `file://${path}`);
|
||||
}catch(err){
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
window.httxrpNavigate = httxrpNavigate
|
||||
|
||||
window.document.getElementById('searchButton').addEventListener('click', async () => {
|
||||
await window.httxrpNavigate(window.document.getElementById('searchBar').value)
|
||||
})
|
||||
@@ -0,0 +1,3 @@
|
||||
export type AnyOf<T> = {
|
||||
[key in keyof T]?: T[key]
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES6",
|
||||
"allowJs": true,
|
||||
"module": "commonjs",
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"noImplicitAny": true,
|
||||
"sourceMap": true,
|
||||
"baseUrl": ".",
|
||||
"outDir": "dist",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"paths": {
|
||||
"*": ["node_modules/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { Configuration } from 'webpack';
|
||||
|
||||
import { rules } from './webpack.rules';
|
||||
|
||||
export const mainConfig: Configuration = {
|
||||
/**
|
||||
* This is the main entry point for your application, it's the first file
|
||||
* that runs in the main process.
|
||||
*/
|
||||
entry: './src/index.ts',
|
||||
// Put your normal webpack config below here
|
||||
module: {
|
||||
rules,
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.js', '.ts', '.jsx', '.tsx', '.css', '.json'],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
import type IForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
|
||||
const CopyPlugin = require('copy-webpack-plugin')
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const ForkTsCheckerWebpackPlugin: typeof IForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
||||
|
||||
export const plugins = [
|
||||
new ForkTsCheckerWebpackPlugin({
|
||||
logger: 'webpack-infrastructure',
|
||||
}),
|
||||
/*
|
||||
new CopyPlugin({
|
||||
patterns: [
|
||||
{
|
||||
from: './src/webview-preload.js',
|
||||
to: 'assets'
|
||||
}
|
||||
]
|
||||
})
|
||||
*/
|
||||
];
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { Configuration } from 'webpack';
|
||||
|
||||
import { rules } from './webpack.rules';
|
||||
import { plugins } from './webpack.plugins';
|
||||
|
||||
rules.push({
|
||||
test: /\.css$/,
|
||||
use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],
|
||||
});
|
||||
|
||||
export const rendererConfig: Configuration = {
|
||||
module: {
|
||||
rules,
|
||||
},
|
||||
plugins,
|
||||
resolve: {
|
||||
extensions: ['.js', '.ts', '.jsx', '.tsx', '.css'],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { ModuleOptions } from 'webpack';
|
||||
|
||||
export const rules: Required<ModuleOptions>['rules'] = [
|
||||
// Add support for native node modules
|
||||
{
|
||||
// We're specifying native_modules in the test because the asset relocator loader generates a
|
||||
// "fake" .node file which is really a cjs file.
|
||||
test: /native_modules[/\\].+\.node$/,
|
||||
use: 'node-loader',
|
||||
},
|
||||
{
|
||||
test: /[/\\]node_modules[/\\].+\.(m?js|node)$/,
|
||||
parser: { amd: false },
|
||||
use: {
|
||||
loader: '@vercel/webpack-asset-relocator-loader',
|
||||
options: {
|
||||
outputAssetBase: 'native_modules',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
exclude: /(node_modules|\.webpack)/,
|
||||
use: {
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
transpileOnly: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user