Skip to content

Commit

Permalink
devop: temp push
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Oct 18, 2024
1 parent bf09586 commit bafb995
Show file tree
Hide file tree
Showing 13 changed files with 407 additions and 327 deletions.
3 changes: 0 additions & 3 deletions packages/extension-vite/configs/empty-polyfill.js

This file was deleted.

14 changes: 14 additions & 0 deletions packages/extension-vite/configs/vite/assets-rewrite.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Plugin } from 'vite'
import { dirname, relative } from 'node:path'

const assetsRewritePlugin: Plugin = {
name: 'assets-rewrite',
enforce: 'post',
apply: 'build',
transformIndexHtml(html, { path }) {
const assetsPath = relative(dirname(path), '/assets').replace(/\\/g, '/')
return html.replace(/"\/assets\//g, `"${assetsPath}/`)
},
}

export default assetsRewritePlugin
15 changes: 15 additions & 0 deletions packages/extension-vite/configs/vite/manifest-hack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Plugin } from 'vite'

const viteManifestHackIssue846: Plugin & {
renderCrxManifest: (manifest: any, bundle: any) => void
} = {
// Workaround from https://github.com/crxjs/chrome-extension-tools/issues/846#issuecomment-1861880919.
name: 'manifestHackIssue846',
renderCrxManifest(_manifest, bundle) {
bundle['manifest.json'] = bundle['.vite/manifest.json']
bundle['manifest.json'].fileName = 'manifest.json'
delete bundle['.vite/manifest.json']
},
}

export default viteManifestHackIssue846
25 changes: 25 additions & 0 deletions packages/extension-vite/configs/vite/transform-manifest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Plugin, ResolvedConfig } from 'vite'
import path from 'path'
import fs from 'fs-extra'

function myPlugin(): Plugin {
let config: ResolvedConfig

return {
name: 'my-plugin:build',
apply: 'build',
async configResolved(_config) {
config = _config
},
writeBundle() {
const filePath = path.resolve(
config.root,
config.build.outDir,
'sprite.svg',
)
fs.ensureFileSync(filePath)
fs.writeFileSync(filePath, 'abc')
},
}
}
export default myPlugin
87 changes: 49 additions & 38 deletions packages/extension-vite/manifest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,50 @@ import type { ManifestV3Export } from '@crxjs/vite-plugin'
import packageJson from './package.json'

const { version } = packageJson
// Convert from Semver (example: 0.1.0-beta6)
const [major, minor, patch, label = '0'] = version
// can only contain digits, dots, or dash
.replace(/[^\d.-]+/g, '')
// split into version parts
.split(/[.-]/)

export default {
name: 'Enkrypt',
description: 'Enkrypt: best wallet',
// up to four numbers separated by dots
version: `${major}.${minor}.${patch}.${label}`,
// semver is OK in "version_name"
version_name: version,
author: 'https://www.enkrypt.com',
homepage_url: 'https://www.enkrypt.com',
version,
name: 'Enkrypt: ETH, BTC and Solana Wallet',
short_name: 'Enkrypt',
description: 'Everything in the blockchain made easy',
manifest_version: 3,
// key: '',
action: {
default_icon: {
'16': 'assets/img/icons/icon16.png',
'32': 'assets/img/icons/icon32.png',
'64': 'assets/img/icons/icon64.png',
'192': 'assets/img/icons/icon192.png',
},
default_title: 'Enkrypt',
default_popup: 'action.html',
},
background: {
service_worker: 'src/scripts/chrome/background.ts',
type: 'module',
},
content_scripts: [
{
all_frames: true,
js: ['src/scripts/contentscript.ts'],
matches: ['*://*/*'],
run_at: 'document_end',
},
],
permissions: [
'storage',
'unlimitedStorage',
'tabs',
'clipboardRead',
'clipboardWrite',
],
web_accessible_resources: [
commands: {
_execute_action: {
suggested_key: {
windows: 'Alt+Shift+E',
mac: 'Alt+Shift+E',
chromeos: 'Alt+Shift+E',
linux: 'Alt+Shift+E',
},
},
},
content_scripts: [
// {
// matches: ['file://*/*', 'http://*/*', 'https://*/*'],
// js: ['src/scripts/inject.ts'],
// run_at: 'document_start',
// all_frames: false,
// world: 'MAIN',
// },
{
matches: ['file://*/*', 'http://*/*', 'https://*/*'],
js: ['src/scripts/contentscript.ts'],
run_at: 'document_start',
all_frames: false,
},
{
matches: ['*://*/*'],
resources: ['src/scripts/contentscript.ts'],
matches: ['*://connect.trezor.io/*/*'],
js: ['public/vendor/trezor-content-script.js'],
run_at: 'document_start',
},
],
icons: {
Expand All @@ -59,6 +54,22 @@ export default {
64: 'assets/img/icons/icon64.png',
192: 'assets/img/icons/icon192.png',
},
action: {
default_icon: {
'16': 'assets/img/icons/icon16.png',
'32': 'assets/img/icons/icon32.png',
'64': 'assets/img/icons/icon64.png',
'192': 'assets/img/icons/icon192.png',
},
default_title: 'Enkrypt',
default_popup: 'action.html',
},
background: {
service_worker: 'src/scripts/chrome/background.ts',
type: 'module',
},
web_accessible_resources: [],
minimum_chrome_version: '111',
content_security_policy: {
extension_pages: "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'",
},
Expand Down
2 changes: 2 additions & 0 deletions packages/extension-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"@types/chrome": "^0.0.273",
"@types/ethereumjs-abi": "^0.6.5",
"@types/events": "^3.0.3",
"@types/fs-extra": "^11.0.4",
"@types/less": "^3.0.6",
"@types/lodash": "^4.17.9",
"@types/mocha": "^10.0.8",
Expand All @@ -121,6 +122,7 @@
"cross-env": "^7.0.3",
"eslint": "^9.12.0",
"eslint-plugin-vue": "^9.28.0",
"fs-extra": "^11.2.0",
"less": "^4.2.0",
"less-loader": "^12.2.0",
"mocha": "^10.7.3",
Expand Down
Loading

1 comment on commit bafb995

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.