fix: 141125/fix_bug_module_wasm_not_found
This commit is contained in:
parent
264b138f1c
commit
cfe54b3662
@ -4,7 +4,66 @@ import path from 'path'
|
||||
import { encrypt, fromEncryptedJson } from './utils/keystore'
|
||||
import logger from './logger'
|
||||
|
||||
const neptuneNative = require('@neptune/native')
|
||||
let neptuneNative: any = null
|
||||
|
||||
function loadNativeModule() {
|
||||
try {
|
||||
// Try normal require first (works in dev)
|
||||
neptuneNative = require('@neptune/native')
|
||||
logger.info('[Native] Loaded native module')
|
||||
return
|
||||
} catch (err) {
|
||||
logger.error('[Native] Failed to load native module')
|
||||
}
|
||||
|
||||
// Fallback: load from Resources in packaged app
|
||||
try {
|
||||
const platform = process.platform
|
||||
const arch = process.arch
|
||||
|
||||
// Determine the correct .node file
|
||||
let nodeFileName = ''
|
||||
if (platform === 'win32' && arch === 'x64') {
|
||||
nodeFileName = 'neptune-native.win32-x64-msvc.node'
|
||||
} else if (platform === 'linux' && arch === 'x64') {
|
||||
nodeFileName = 'neptune-native.linux-x64-gnu.node'
|
||||
} else if (platform === 'darwin' && arch === 'arm64') {
|
||||
nodeFileName = 'neptune-native.darwin-arm64.node'
|
||||
} else {
|
||||
throw new Error(`Unsupported platform: ${platform}-${arch}`)
|
||||
}
|
||||
|
||||
// Try multiple possible locations
|
||||
const possiblePaths = [
|
||||
path.join(process.resourcesPath, 'packages', 'neptune-native', nodeFileName),
|
||||
path.join(process.resourcesPath, 'neptune-native', nodeFileName),
|
||||
path.join(process.resourcesPath, nodeFileName),
|
||||
path.join(process.resourcesPath, 'app.asar.unpacked', 'packages', 'neptune-native', nodeFileName),
|
||||
path.join(process.resourcesPath, 'app.asar.unpacked', 'node_modules', '@neptune', 'native', nodeFileName),
|
||||
]
|
||||
|
||||
let nativeBinding: any = null
|
||||
for (const nodePath of possiblePaths) {
|
||||
if (fs.existsSync(nodePath)) {
|
||||
nativeBinding = require(nodePath)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (!nativeBinding) {
|
||||
throw new Error(`Native module not found`)
|
||||
}
|
||||
|
||||
neptuneNative = nativeBinding
|
||||
logger.info('[Native] Successfully loaded native module')
|
||||
} catch (error) {
|
||||
logger.error('[Native] Failed to load native module:')
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the native module
|
||||
loadNativeModule()
|
||||
|
||||
const WALLETS_DIR = path.resolve(app.getPath('userData'), 'wallets')
|
||||
fs.mkdirSync(WALLETS_DIR, { recursive: true })
|
||||
|
||||
@ -85,18 +85,6 @@ const createWindow = () => {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
if (!isDev) {
|
||||
mainWindow.removeMenu()
|
||||
mainWindow.webContents.on('before-input-event', (event, input) => {
|
||||
if (input.control && input.shift && input.key.toLowerCase() === 'i') {
|
||||
event.preventDefault()
|
||||
}
|
||||
})
|
||||
}
|
||||
mainWindow.webContents.on('devtools-opened', () => {
|
||||
if (!isDev) mainWindow.webContents.closeDevTools()
|
||||
})
|
||||
}
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
|
||||
@ -6,14 +6,26 @@ import { MakerRpm } from '@electron-forge/maker-rpm';
|
||||
import { VitePlugin } from '@electron-forge/plugin-vite';
|
||||
import { FusesPlugin } from '@electron-forge/plugin-fuses';
|
||||
import { FuseV1Options, FuseVersion } from '@electron/fuses';
|
||||
import { AutoUnpackNativesPlugin } from '@electron-forge/plugin-auto-unpack-natives';
|
||||
|
||||
const config: ForgeConfig = {
|
||||
packagerConfig: {
|
||||
asar: true,
|
||||
extraResource: [
|
||||
'./packages/neptune-native',
|
||||
'./packages/neptune-wasm',
|
||||
]
|
||||
},
|
||||
rebuildConfig: {
|
||||
onlyModules: ['@neptune/native'],
|
||||
force: true,
|
||||
},
|
||||
rebuildConfig: {},
|
||||
makers: [
|
||||
new MakerSquirrel({}),
|
||||
new MakerSquirrel({
|
||||
name: 'neptune-web-wallet',
|
||||
authors: 'Neptune Team',
|
||||
description: 'Neptune Blockchain Wallet - Secure cryptocurrency wallet for Neptune network',
|
||||
}),
|
||||
new MakerZIP({}, ['darwin']),
|
||||
new MakerRpm({}),
|
||||
new MakerDeb({}),
|
||||
@ -53,6 +65,9 @@ const config: ForgeConfig = {
|
||||
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
|
||||
[FuseV1Options.OnlyLoadAppFromAsar]: true,
|
||||
}),
|
||||
new AutoUnpackNativesPlugin({
|
||||
packageJsonPropNames: ['@neptune/native'],
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
@ -4,14 +4,6 @@
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="default-src 'self';
|
||||
script-src 'self';
|
||||
style-src 'self';
|
||||
connect-src 'self' ;
|
||||
img-src 'self' data:;"
|
||||
/>
|
||||
|
||||
<title>Neptune Web Wallet</title>
|
||||
</head>
|
||||
|
||||
17
package-lock.json
generated
17
package-lock.json
generated
@ -4401,9 +4401,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/baseline-browser-mapping": {
|
||||
"version": "2.8.27",
|
||||
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.27.tgz",
|
||||
"integrity": "sha512-2CXFpkjVnY2FT+B6GrSYxzYf65BJWEqz5tIRHCvNsZZ2F3CmsCB37h8SpYgKG7y9C4YAeTipIPWG7EmFmhAeXA==",
|
||||
"version": "2.8.28",
|
||||
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.28.tgz",
|
||||
"integrity": "sha512-gYjt7OIqdM0PcttNYP2aVrr2G0bMALkBaoehD4BuRGjAOtipg0b6wHg1yNL+s5zSnLZZrGHOw4IrND8CD+3oIQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
@ -8763,10 +8763,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/neptune-native": {
|
||||
"resolved": "packages/neptune-native",
|
||||
"link": true
|
||||
},
|
||||
"node_modules/nice-try": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz",
|
||||
@ -8775,9 +8771,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/node-abi": {
|
||||
"version": "3.80.0",
|
||||
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.80.0.tgz",
|
||||
"integrity": "sha512-LyPuZJcI9HVwzXK1GPxWNzrr+vr8Hp/3UqlmWxxh8p54U1ZbclOqbSog9lWHaCX+dBaiGi6n/hIX+mKu74GmPA==",
|
||||
"version": "3.82.0",
|
||||
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.82.0.tgz",
|
||||
"integrity": "sha512-aQuSU0xnqUUNU7rVmEB8M8pAJ/1SA/DL0tdAtr+X63+x61UJMo1Ulsp/3liX33EuA4kM8GG762/pyHtgag5PmQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@ -12326,6 +12322,7 @@
|
||||
}
|
||||
},
|
||||
"packages/neptune-native": {
|
||||
"name": "@neptune/native",
|
||||
"version": "0.1.0",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
{
|
||||
"name": "neptune-web-wallet",
|
||||
"version": "0.0.0",
|
||||
"description": "Neptune Blockchain Wallet - Secure cryptocurrency wallet for Neptune network",
|
||||
"author": "Neptune Team",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"workspaces": [
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "neptune-native",
|
||||
"name": "@neptune/native",
|
||||
"version": "0.1.0",
|
||||
"description": "Native Node.js addon for Neptune transaction building",
|
||||
"main": "index.js",
|
||||
|
||||
4
src/lang/en/notFound.ts
Normal file
4
src/lang/en/notFound.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export default {
|
||||
title: 'The page you requested was not found.',
|
||||
back: 'Back to Home',
|
||||
}
|
||||
@ -1,15 +1,13 @@
|
||||
import { createI18n } from 'vue3-i18n'
|
||||
import { en } from './en'
|
||||
import { jp } from './jp'
|
||||
|
||||
const messages = {
|
||||
en: en,
|
||||
jp: jp,
|
||||
}
|
||||
|
||||
const i18n = createI18n({
|
||||
locale: 'jp',
|
||||
fallbackLocale: 'jp',
|
||||
locale: 'en',
|
||||
fallbackLocale: 'en',
|
||||
messages,
|
||||
} as any)
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
|
||||
import { routes } from './route'
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
history: import.meta.env.DEV ? createWebHistory() : createWebHashHistory(),
|
||||
routes,
|
||||
})
|
||||
|
||||
|
||||
@ -17,9 +17,9 @@ const { t } = useI18n()
|
||||
<h3 class="h2">
|
||||
{{ t('notFound.title') }}
|
||||
</h3>
|
||||
<a href="/reservations" class="link_404">
|
||||
<router-link to="/auth" class="link_404">
|
||||
{{ t('notFound.back') }}
|
||||
</a>
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -22,11 +22,14 @@ export default defineConfig({
|
||||
}),
|
||||
],
|
||||
optimizeDeps: {
|
||||
exclude: ['@neptune/wasm', '@neptune/native'],
|
||||
exclude: ['@neptune/native'],
|
||||
},
|
||||
build: {
|
||||
rollupOptions: {
|
||||
external: ['@neptune/wasm', '@neptune/native'],
|
||||
external: ['@neptune/native'],
|
||||
output: {
|
||||
format: 'es',
|
||||
},
|
||||
},
|
||||
},
|
||||
css: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user