-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
116 changed files
with
1,067 additions
and
608 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
.DS_Store | ||
node_modules | ||
/build | ||
/.svelte-kit | ||
/package | ||
build | ||
.svelte-kit | ||
.env | ||
.env.* | ||
!.env.example | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
.DS_Store | ||
node_modules | ||
/build | ||
/.svelte-kit | ||
build | ||
.svelte-kit | ||
/package | ||
.env | ||
.env.* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = { | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:svelte/recommended", | ||
"prettier", | ||
], | ||
parserOptions: { | ||
sourceType: "module", | ||
ecmaVersion: 2020, | ||
extraFileExtensions: [".svelte"], | ||
}, | ||
overrides: [ | ||
{ | ||
files: ["*.svelte"], | ||
parser: "svelte-eslint-parser", | ||
parserOptions: { | ||
parser: "@typescript-eslint/parser", | ||
}, | ||
}, | ||
], | ||
}; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"], | ||
"overrides": [ | ||
{ | ||
"files": "*.svelte", | ||
"options": { "parser": "svelte" } | ||
} | ||
], | ||
"tailwindAttributes": ["extraProps", "containerClasses"], | ||
"tailwindFunctions": ["clsx"] | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { execSync } = require('child_process'); | ||
const archiver = require('archiver'); | ||
|
||
const buildDir = path.resolve(__dirname, '../build'); | ||
const firefoxDir = path.join(buildDir, 'firefox'); | ||
|
||
// Copy build directory to firefox directory | ||
function copyDir(src, dest) { | ||
execSync(`cp -r ${src} ${dest}`); | ||
} | ||
|
||
// Update manifest for Firefox | ||
function updateManifestForFirefox(directory) { | ||
const manifestPath = path.join(directory, 'manifest.json'); | ||
const data = fs.readFileSync(manifestPath, 'utf8'); | ||
const manifest = JSON.parse(data); | ||
const updatedManifest = { | ||
...manifest, | ||
background: { | ||
scripts: ['scripts/background.js'], | ||
type: 'module' | ||
} | ||
}; | ||
fs.writeFileSync(manifestPath, JSON.stringify(updatedManifest, null, 2), 'utf8'); | ||
} | ||
|
||
// Archive directory | ||
function archiveDirectory(sourceDir, outPath) { | ||
const archive = archiver('zip', { zlib: { level: 9 } }); | ||
const stream = fs.createWriteStream(outPath); | ||
|
||
return new Promise((resolve, reject) => { | ||
archive | ||
.directory(sourceDir, false) | ||
.on('error', (err) => reject(err)) | ||
.pipe(stream); | ||
|
||
stream.on('close', () => resolve()); | ||
archive.finalize(); | ||
}); | ||
} | ||
|
||
async function buildForFirefox() { | ||
// Ensure firefox directory does not exist | ||
if (fs.existsSync(firefoxDir)) { | ||
execSync(`rm -rf ${firefoxDir}`); | ||
} | ||
|
||
// Copy build directory to firefox directory | ||
copyDir(buildDir, firefoxDir); | ||
|
||
updateManifestForFirefox(firefoxDir); | ||
|
||
// Archive firefox directory | ||
await archiveDirectory(firefoxDir, path.join(buildDir, 'firefox.zip')); | ||
|
||
// Remove firefox directory | ||
execSync(`rm -rf ${firefoxDir}`); | ||
|
||
console.log('Firefox build is ready and archived.'); | ||
} | ||
|
||
buildForFirefox(); |
19 changes: 19 additions & 0 deletions
19
holo-key-manager-extension/build-scripts/removeExportFromScript.cjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
const removeExportStatement = (directory, fileName) => { | ||
console.log(`Removing "export {};" from ${fileName}`); | ||
const filePath = path.join(directory, fileName); | ||
const fileContent = fs.readFileSync(filePath, 'utf8').replace('export {};', ''); | ||
|
||
fs.writeFileSync(filePath, fileContent); | ||
console.log(`"export {};" removed from: ${filePath}`); | ||
}; | ||
|
||
['background.js', 'content.js'].forEach((file) => | ||
removeExportStatement( | ||
path.resolve(__dirname, '../build/holo-key-manager-extension/scripts'), | ||
file | ||
) | ||
); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"name": "holo-key-manager", | ||
"version": "0.0.3", | ||
"private": true, | ||
"scripts": { | ||
"build": "pnpm build:vite && pnpm build:script && pnpm build:removeExport && pnpm build:removeInline", | ||
"buildDev": "pnpm build:vite && pnpm build:script && pnpm build:removeExport && pnpm build:removeInline && pnpm build:buildForFirefoxDev", | ||
"build:vite": "vite build", | ||
"build:script": "tsc --p scripts/tsconfig.json", | ||
"build:removeExport": "node build-scripts/removeExportFromScript.cjs", | ||
"build:removeInline": "node build-scripts/removeInlineScript.cjs", | ||
"build:replaceForFirefox": "node build-scripts/replaceForFirefox.cjs", | ||
"build:buildForFirefoxDev": "node build-scripts/devFirefox.cjs", | ||
"preview": "vite preview", | ||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", | ||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", | ||
"lint": "prettier --check 'src/**/*.{js,ts,svelte,json}' && eslint --fix 'src/**/*.{js,ts,svelte}'", | ||
"format": "prettier --write 'src/**/*.{js,ts,svelte,json}'", | ||
"prepare": "cd .. && husky install" | ||
}, | ||
"devDependencies": { | ||
"@sveltejs/adapter-static": "^3.0.1", | ||
"@sveltejs/kit": "2.0.2", | ||
"@sveltejs/vite-plugin-svelte": "^3.0.2", | ||
"@tsconfig/node-lts": "^20.1.1", | ||
"@types/chrome": "^0.0.254", | ||
"@types/file-saver": "^2.0.7", | ||
"@typescript-eslint/eslint-plugin": "^6.21.0", | ||
"@typescript-eslint/parser": "^6.21.0", | ||
"archiver": "^7.0.1", | ||
"autoprefixer": "^10.4.18", | ||
"eslint": "^8.57.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-simple-import-sort": "^10.0.0", | ||
"eslint-plugin-svelte": "^2.35.1", | ||
"husky": "^8.0.3", | ||
"lint-staged": "^15.2.2", | ||
"postcss": "^8.4.35", | ||
"prettier": "^3.2.5", | ||
"prettier-plugin-svelte": "^3.2.2", | ||
"prettier-plugin-tailwindcss": "^0.5.11", | ||
"svelte-check": "^3.6.6", | ||
"svelte-file-dropzone": "^2.0.4", | ||
"tslib": "^2.6.2", | ||
"typescript": "^5.3.3", | ||
"vite": "^5.1.4" | ||
}, | ||
"type": "module", | ||
"dependencies": { | ||
"@tanstack/svelte-query": "^5.24.8", | ||
"clsx": "^2.1.0", | ||
"file-saver": "^2.0.5", | ||
"hcSeedBundle": "github:mrruby/hcSeedBundle", | ||
"jszip": "^3.10.1", | ||
"svelte": "^4.2.12", | ||
"tailwindcss": "^3.4.1", | ||
"tiny-glob": "^0.2.9", | ||
"zod": "^3.22.4" | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { Message } from '@sharedTypes'; | ||
|
||
console.log('Content script loaded'); | ||
const isMessageFromSelf = (event: MessageEvent) => event.source === window; | ||
const isSignInAction = (data: Message) => data.action === 'SignIn'; | ||
|
||
window.addEventListener('message', async (event: MessageEvent) => { | ||
if (!isMessageFromSelf(event)) return; | ||
if (isSignInAction(event.data)) { | ||
const response = await chrome.runtime.sendMessage(event.data); | ||
window.postMessage({ ...response, id: event.data.id }, '*'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "../build", | ||
"paths": { | ||
"@sharedTypes": ["../../shared/types"], | ||
"@sharedTypes/*": ["../../shared/types/*"] | ||
} | ||
}, | ||
"include": ["background.ts", "content.ts"] | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.