Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More build cleanup #165

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "HyperChat",
"version": "69.42.0",
"version": "3.0.4",
"private": true,
"scripts": {
"build": "npm run build:chrome && npm run build:firefox",
Expand Down
10 changes: 2 additions & 8 deletions src/components/Hyperchat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,9 @@
// paramsTabId,
// paramsFrameId,
// paramsIsReplay,
getBrowser,
Browser,
Theme,
YoutubeEmojiRenderMode,
chatUserActionsItems,

ChatReportUserOptions

} from '../ts/chat-constants';
import {
isAllEmoji,
Expand Down Expand Up @@ -57,7 +52,6 @@
enableHighlightedMentions,
ytDark
} from '../ts/storage';
import { version } from '../manifest.json';

const welcome = { welcome: true, message: { messageId: 'welcome' } };
type Welcome = typeof welcome;
Expand Down Expand Up @@ -102,7 +96,7 @@
$: hasBanner = pinned || redirect || (summary && $showChatSummary);
let div: HTMLElement;
let isAtBottom = true;
let truncateInterval: number;
let truncateInterval: number | undefined;
const isReplay = paramsIsReplay;
const smelteDark = dark();

Expand Down Expand Up @@ -314,7 +308,7 @@
// Doesn't work well with onMount, so onLoad will have to do
// Update: use onMount because hc now mounts in content script
const onLoad = (): (() => void) | undefined => {
$lastOpenedVersion = version;
$lastOpenedVersion = __VERSION__;
document.body.classList.add('overflow-hidden');

if (paramsTabId == null || paramsFrameId == null || paramsTabId.length < 1 || paramsFrameId.length < 1) {
Expand Down
15 changes: 7 additions & 8 deletions src/components/HyperchatButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { hcEnabled, lastOpenedVersion } from '../ts/storage';
import { createPopup } from '../ts/chat-utils';
import { mdiChevronRight, mdiClose, mdiCogOutline } from '@mdi/js';
import { version } from '../manifest.json';

$: disabled = !$hcEnabled;

Expand All @@ -24,7 +23,7 @@
let updated = false;

lastOpenedVersion.ready().then(() => {
updated = !$hcEnabled && $lastOpenedVersion !== version;
updated = !$hcEnabled && $lastOpenedVersion !== __VERSION__;
});
</script>

Expand All @@ -37,7 +36,7 @@
</svg>
<div style="cursor: pointer;" on:click={() => {
updated = false;
$lastOpenedVersion = version;
$lastOpenedVersion = __VERSION__;
}}>
<svg height="20" width="24" viewBox="0 0 24 24" class="close">
<path d={mdiClose} fill="black"/>
Expand Down Expand Up @@ -214,15 +213,15 @@
position: absolute;
visibility: hidden;
opacity: 0;
-webkit-transition:
-webkit-transition:
opacity 0.2s ease-in-out,
visibility 0.2s ease-in-out,
-webkit-transform 0.2s cubic-bezier(0.71, 1.7, 0.77, 1.24);
-moz-transition:
-moz-transition:
opacity 0.2s ease-in-out,
visibility 0.2s ease-in-out,
-moz-transform 0.2s cubic-bezier(0.71, 1.7, 0.77, 1.24);
transition:
transition:
opacity 0.2s ease-in-out,
visibility 0.2s ease-in-out,
transform 0.2s cubic-bezier(0.71, 1.7, 0.77, 1.24);
Expand Down Expand Up @@ -289,7 +288,7 @@
[data-tooltip]:focus:after {
-webkit-transform: translateY(-12px);
-moz-transform: translateY(-12px);
transform: translateY(-12px);
transform: translateY(-12px);
}

/* Bottom */
Expand All @@ -314,7 +313,7 @@
.tooltip-bottom:focus:after {
-webkit-transform: translateY(12px);
-moz-transform: translateY(12px);
transform: translateY(12px);
transform: translateY(12px);
}

.update-notification {
Expand Down
15 changes: 7 additions & 8 deletions src/components/WelcomeMessage.svelte
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<script lang="ts">
import { lastClosedVersion, refreshScroll } from '../ts/storage';
import { Browser, getBrowser, isLiveTL } from '../ts/chat-constants';
import { isLiveTL } from '../ts/chat-constants';
import Changelog from './changelog/Changelog.svelte';
import { version } from '../manifest.json';
import Icon from './common/Icon.svelte';

const logo = chrome.runtime.getURL(
(isLiveTL ? 'hyperchat' : 'assets') + '/logo.png'
);
const reviewLink = getBrowser() === Browser.FIREFOX
const reviewLink = __BROWSER__ === 'firefox'
? 'https://addons.mozilla.org/en-US/firefox/addon/hyperchat/'
: 'https://chrome.google.com/webstore/detail/hyperchat-optimized-youtu/naipgebhooiiccifflecbffmnjbabdbh';
const classes = 'p-2 rounded inline-flex flex-col overflow-hidden ' +
Expand Down Expand Up @@ -36,7 +35,7 @@
}
];

$: showChangelog = $lastClosedVersion !== version;
$: showChangelog = $lastClosedVersion !== __VERSION__;
</script>

<div class={classes}>
Expand All @@ -55,16 +54,16 @@
$refreshScroll = true;
e.preventDefault();
}} class="underline text-primary-900 dark:text-primary-50">
v{version}
v{__VERSION__}
</a>
{:else}
v{version}
v{__VERSION__}
{/if}
</p>
<div class="flex flex-wrap">
{#each badges as badge, i}
<p>
<a
<a
href={badge.href}
class="underline text-primary-900 dark:text-primary-50"
target="_blank"
Expand All @@ -82,7 +81,7 @@
{#if showChangelog}
<p class="leading-tight mt-1.5 flex flex-row">
<span href="/" on:click={(e) => {
$lastClosedVersion = version;
$lastClosedVersion = __VERSION__;
$refreshScroll = true;
e.preventDefault();
}}
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "HyperChat [Improved YouTube Chat]",
"homepage_url": "https://livetl.app/hyperchat",
"description": "Improved YouTube chat with CPU/RAM optimizations, customization options, and cutting-edge features!",
"version": "3.0.4",
"version": "0.0.0",
"permissions": [
"storage"
],
Expand Down
16 changes: 0 additions & 16 deletions src/ts/chat-constants.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
export const isLiveTL = false;
// DO NOT EDIT THE ABOVE LINE. It is updated by webpack.

export const enum Browser {
FIREFOX,
CHROME,
SAFARI
}

export const getBrowser = (): Browser => {
if (navigator.userAgent.includes('Firefox')) {
return Browser.FIREFOX;
}
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
return Browser.SAFARI;
}
return Browser.CHROME;
};

// const params = new URLSearchParams(window.location.search);
// export const paramsTabId = params.get('tabid');
// export const paramsFrameId = params.get('frameid');
Expand Down
3 changes: 3 additions & 0 deletions src/ts/typings/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* eslint-disable @typescript-eslint/naming-convention */
declare const __BROWSER__: 'chrome' | 'firefox';
declare const __VERSION__: string;
24 changes: 16 additions & 8 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import { svelte } from '@sveltejs/vite-plugin-svelte';
import path from 'path';
import copy from 'rollup-plugin-copy';
import { defineConfig } from 'vite';
import browserExtension from 'vite-plugin-web-extension';
import webExtension, { readJsonFile } from 'vite-plugin-web-extension';
import zipPack from 'vite-plugin-zip-pack';

import manifest from './src/manifest.json';
const pkg = readJsonFile('package.json');
const manifest = readJsonFile('src/manifest.json');

const buildDir = `build/${process.env.BROWSER}`;
const browser = process.env.BROWSER ?? 'chrome';
const version = process.env.VERSION ?? pkg.version;

const buildDir = `build/${browser}`;

export default defineConfig({
root: 'src',
Expand All @@ -16,11 +20,15 @@ export default defineConfig({
emptyOutDir: true,
minify: process.env.MINIFY !== 'false' ? 'terser' : false
},
define: {
__BROWSER__: JSON.stringify(browser),
__VERSION__: JSON.stringify(version)
},
plugins: [
browserExtension({
webExtension({
manifest: () => ({
...manifest,
version: process.env.VERSION ?? manifest.version,
version
}),
assets: 'assets',
watchFilePaths: [
Expand All @@ -32,7 +40,7 @@ export default defineConfig({
'scripts/chat-metagetter.ts'
],
disableAutoLaunch: process.env.HC_AUTOLAUNCH === undefined,
browser: process.env.BROWSER === undefined ? 'chrome' : process.env.BROWSER,
browser,
webExtConfig: {
startUrl: 'https://www.youtube.com/watch?v=jfKfPfyJRdk'
}
Expand All @@ -51,7 +59,7 @@ export default defineConfig({
zipPack({
inDir: buildDir,
outDir: 'build',
outFileName: `HyperChat-${process.env.BROWSER}.zip`
}),
outFileName: `HyperChat-${browser}.zip`
})
]
});
Loading