Upgrade typescript/svelte/esbuild

This commit is contained in:
hensm
2026-02-28 15:34:03 +00:00
committed by Matt Hensman
parent 11e3ad06aa
commit 5a18907dba
26 changed files with 1610 additions and 789 deletions

View File

@@ -95,7 +95,36 @@ const buildOpts = {
src: srcPath,
dest: outPath,
excludePattern: /^(manifest\.json|.*\.(ts|js|svelte))$/
})
}),
// Write manifest after each build
{
name: "write-manifest",
setup(build) {
build.onEnd(result => {
if (result.errors.length) {
console.error("Build error!");
return;
}
const manifest = JSON.parse(
fs.readFileSync(`${srcPath}/manifest.json`, {
encoding: "utf-8"
})
);
manifest.content_security_policy =
argv.mode === "production"
? "script-src 'self'; object-src 'self'"
: "script-src 'self' 'unsafe-eval'; object-src 'self'";
fs.writeFileSync(
`${outPath}/manifest.json`,
JSON.stringify(manifest)
);
});
}
}
]
};
@@ -105,47 +134,15 @@ if (argv.mode === "production") {
buildOpts.sourcemap = false;
}
/**
* Handle build results.
*
* @param {esbuild.BuildResult | null} result
*/
function onBuildResult(result) {
if (result?.errors.length) {
console.error("Build error!");
return;
}
const manifest = JSON.parse(
fs.readFileSync(`${srcPath}/manifest.json`, { encoding: "utf-8" })
);
manifest.content_security_policy =
argv.mode === "production"
? "script-src 'self'; object-src 'self'"
: "script-src 'self' 'unsafe-eval'; object-src 'self'";
fs.writeFileSync(`${outPath}/manifest.json`, JSON.stringify(manifest));
}
// Clean
fs.removeSync(distPath);
if (argv.watch) {
esbuild
.build({
...buildOpts,
watch: {
onRebuild(_err, result) {
return onBuildResult(result);
}
}
})
.then(onBuildResult);
const ctx = await esbuild.context(buildOpts);
await ctx.watch();
console.info("Watching for changes...");
} else {
esbuild.build(buildOpts).then(result => {
onBuildResult(result);
esbuild.build(buildOpts).then(() => {
if (argv.package) {
webExt.cmd
.build(

File diff suppressed because it is too large Load Diff

View File

@@ -11,15 +11,15 @@
"@types/firefox-webext-browser": "^94.0.1",
"@types/semver": "^7.3.9",
"@types/uuid": "^8.3.4",
"esbuild": "^0.14.38",
"esbuild-svelte": "^0.7.1",
"esbuild": "^0.25.0",
"esbuild-svelte": "^0.8.0",
"fs-extra": "^10.1.0",
"fuzzysort": "^2.0.3",
"semver": "^7.3.7",
"svelte": "^3.49.0",
"svelte-preprocess": "^4.10.6",
"svelte": "^4.0.0",
"svelte-preprocess": "^5.0.0",
"ts-loader": "^9.2.8",
"typescript": "^4.6.3",
"typescript": "^5.7.0",
"uuid": "^8.3.2",
"web-ext": "^7.5.0",
"yargs": "^17.5.1"

View File

@@ -1,5 +1,5 @@
import logger from "../lib/logger";
import messaging, { Port, Message } from "../messaging";
import messaging, { type Port, type Message } from "../messaging";
import options from "../lib/options";
import { TypedEventTarget } from "../lib/TypedEventTarget";

View File

@@ -1,6 +1,6 @@
import logger from "../lib/logger";
import options from "../lib/options";
import bridge, { BridgeInfo } from "../lib/bridge";
import bridge, { type BridgeInfo } from "../lib/bridge";
import { baseConfigStorage, fetchBaseConfig } from "../lib/chromecastConfigApi";
import defaultOptions from "../defaultOptions";

View File

@@ -1,19 +1,19 @@
import bridge from "../lib/bridge";
import {
BaseConfig,
type BaseConfig,
baseConfigStorage,
getAppTag
} from "../lib/chromecastConfigApi";
import logger from "../lib/logger";
import messaging, { Message, Port } from "../messaging";
import messaging, { type Message, type Port } from "../messaging";
import options from "../lib/options";
import type { TypedMessagePort } from "../lib/TypedMessagePort";
import {
ReceiverDevice,
ReceiverSelectorAppInfo,
type ReceiverDevice,
type ReceiverSelectorAppInfo,
ReceiverSelectorMediaType,
ReceiverSelectorPageInfo
type ReceiverSelectorPageInfo
} from "../types";
import type { ApiConfig } from "../cast/sdk/classes";
@@ -21,10 +21,10 @@ import { AutoJoinPolicy, ReceiverAction } from "../cast/sdk/enums";
import { createReceiver } from "../cast/utils";
import ReceiverSelector, {
ReceiverSelection,
ReceiverSelectorMediaMessage,
ReceiverSelectorReceiverMessage
} from "./ReceiverSelector";
type ReceiverSelection,
type ReceiverSelectorMediaMessage,
type ReceiverSelectorReceiverMessage
} from "./receiverSelector";
import deviceManager from "./deviceManager";
import { ActionState, updateActionState } from "./action";

View File

@@ -1,4 +1,4 @@
import bridge, { BridgeInfo } from "../lib/bridge";
import bridge, { type BridgeInfo } from "../lib/bridge";
import logger from "../lib/logger";
import { TypedEventTarget } from "../lib/TypedEventTarget";

View File

@@ -1,4 +1,4 @@
import messaging, { Message } from "../messaging";
import messaging, { type Message } from "../messaging";
import pageMessaging from "./pageMessaging";
// Message port to cast manager in background script

View File

@@ -1,5 +1,5 @@
import type { TypedMessagePort } from "../lib/TypedMessagePort";
import messaging, { Message } from "../messaging";
import messaging, { type Message } from "../messaging";
import type { ReceiverDevice } from "../types";
import pageMessaging from "./pageMessaging";

View File

@@ -8,7 +8,7 @@ import { AutoJoinPolicy, ReceiverAvailability } from "../sdk/enums";
import type Session from "../sdk/Session";
import type Media from "../sdk/media/Media";
import cast, { ensureInit, CastPort } from "../export";
import cast, { ensureInit, type CastPort } from "../export";
const logger = new Logger("fx_cast [media sender]");

View File

@@ -1,4 +1,4 @@
import { ReceiverDevice, ReceiverDeviceCapabilities } from "../types";
import { type ReceiverDevice, ReceiverDeviceCapabilities } from "../types";
import { Receiver } from "./sdk/classes";
import { Capability, ReceiverType } from "./sdk/enums";
import { MediaCommand } from "./sdk/media/enums";

View File

@@ -1,5 +1,5 @@
import defaultOptions, { Options } from "../defaultOptions";
export { Options };
import defaultOptions, { type Options } from "../defaultOptions";
export type { Options };
import logger from "./logger";

View File

@@ -3,8 +3,8 @@
import MirroringSender from "../../cast/senders/mirroring";
import logger from "../../lib/logger";
import options, { Options } from "../../lib/options";
import messaging, { Port } from "../../messaging";
import options, { type Options } from "../../lib/options";
import messaging, { type Port } from "../../messaging";
import type { ReceiverDevice } from "../../types";
import LoadingIndicator from "../LoadingIndicator.svelte";

View File

@@ -5,7 +5,7 @@
import LoadingIndicator from "../LoadingIndicator.svelte";
import bridge, {
BridgeInfo,
type BridgeInfo,
BridgeTimedOutError,
BridgeAuthenticationError
} from "../../lib/bridge";

View File

@@ -7,7 +7,7 @@
import logger from "../../lib/logger";
import options, { Options } from "../../lib/options";
import options, { type Options } from "../../lib/options";
import defaultOptions from "../../defaultOptions";
import { getChromeUserAgentString } from "../../lib/userAgents";

View File

@@ -6,7 +6,7 @@
import { REMOTE_MATCH_PATTERN_REGEX } from "../../lib/matchPattern";
import type { Options } from "../../lib/options";
import knownApps, { KnownApp } from "../../cast/knownApps";
import knownApps, { type KnownApp } from "../../cast/knownApps";
import Option from "./Option.svelte";
const _ = browser.i18n.getMessage;

View File

@@ -2,21 +2,21 @@
import { afterUpdate, onDestroy, onMount, tick } from "svelte";
import fuzzysort from "fuzzysort";
import messaging, { Message, Port } from "../../messaging";
import options, { Options } from "../../lib/options";
import messaging, { type Message, type Port } from "../../messaging";
import options, { type Options } from "../../lib/options";
import { RemoteMatchPattern } from "../../lib/matchPattern";
import { receiverMenuIds } from "../../menuIds";
import {
ReceiverDevice,
type ReceiverDevice,
ReceiverDeviceCapabilities,
ReceiverSelectorAppInfo,
type ReceiverSelectorAppInfo,
ReceiverSelectorMediaType,
ReceiverSelectorPageInfo
type ReceiverSelectorPageInfo
} from "../../types";
import knownApps, { KnownApp } from "../../cast/knownApps";
import knownApps, { type KnownApp } from "../../cast/knownApps";
import { hasRequiredCapabilities } from "../../cast/utils";
import Receiver from "./Receiver.svelte";

View File

@@ -4,18 +4,18 @@
import type { Options } from "../../lib/options";
import { ReceiverDevice, ReceiverDeviceCapabilities } from "../../types";
import { type ReceiverDevice, ReceiverDeviceCapabilities } from "../../types";
import type { Port } from "../../messaging";
import * as menuIds from "../../menuIds";
import type { Volume } from "../../cast/sdk/classes";
import { PlayerState, TrackType } from "../../cast/sdk/media/enums";
import {
import type {
SenderMediaMessage,
SenderMessage,
_MediaCommand
SenderMessage
} from "../../cast/sdk/types";
import { _MediaCommand } from "../../cast/sdk/types";
import LoadingIndicator from "../LoadingIndicator.svelte";
import ReceiverMedia from "./ReceiverMedia.svelte";

View File

@@ -3,7 +3,8 @@
import type { ReceiverDevice } from "../../types";
import { MediaStatus, _MediaCommand } from "../../cast/sdk/types";
import type { MediaStatus } from "../../cast/sdk/types";
import { _MediaCommand } from "../../cast/sdk/types";
import type { Volume } from "../../cast/sdk/classes";
import {
MetadataType,