mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-08-28 17:21:05 +00:00
Fix CI errors
This commit is contained in:
@@ -33,10 +33,10 @@ outputs:
|
|||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
- name: Use Node.js 20.x
|
- name: Use Node.js 22.x
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20.x
|
node-version: 22.x
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
@@ -6,14 +6,18 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
runs-on: ubuntu-latest
|
# windows-latest: Vite/Svelte build fails on Linux CI for layerchart vendor .svelte (see nightly.yml).
|
||||||
|
runs-on: windows-latest
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Use Node.js 20.x
|
- name: Use Node.js 22.x
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 20.x
|
node-version: 22.x
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm install --legacy-peer-deps
|
run: npm install --legacy-peer-deps
|
||||||
|
|||||||
+3
-2
@@ -5,12 +5,13 @@
|
|||||||
"description": "Enhance SEQTA Learn's usability and aesthetics! A fork of BetterSEQTA to continue development and add heaps more features!",
|
"description": "Enhance SEQTA Learn's usability and aesthetics! A fork of BetterSEQTA to continue development and add heaps more features!",
|
||||||
"browserslist": "> 0.5%, last 2 versions, not dead",
|
"browserslist": "> 0.5%, last 2 versions, not dead",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "node scripts/copy-pdfjs-assets.mjs",
|
"compile:layerchart": "node scripts/compile-layerchart-vendor.mjs",
|
||||||
|
"postinstall": "node scripts/copy-pdfjs-assets.mjs && npm run compile:layerchart",
|
||||||
"autoaudit": "npm audit && npm audit fix && npm run build",
|
"autoaudit": "npm audit && npm audit fix && npm run build",
|
||||||
"dev": "cross-env MODE=chrome vite dev",
|
"dev": "cross-env MODE=chrome vite dev",
|
||||||
"dev:firefox": "cross-env MODE=firefox vite build --watch",
|
"dev:firefox": "cross-env MODE=firefox vite build --watch",
|
||||||
"compile": "npm i && npm run build",
|
"compile": "npm i && npm run build",
|
||||||
"build": "cross-env MODE=chrome vite build && cross-env MODE=firefox vite build",
|
"build": "npm run compile:layerchart && cross-env MODE=chrome vite build && cross-env MODE=firefox vite build",
|
||||||
"build:chrome": "cross-env MODE=chrome vite build",
|
"build:chrome": "cross-env MODE=chrome vite build",
|
||||||
"build:firefox": "cross-env MODE=firefox vite build",
|
"build:firefox": "cross-env MODE=firefox vite build",
|
||||||
"build:safari": "cross-env MODE=safari vite build",
|
"build:safari": "cross-env MODE=safari vite build",
|
||||||
|
|||||||
@@ -0,0 +1,113 @@
|
|||||||
|
/**
|
||||||
|
* layerchart ships raw `.svelte` sources in `dist/`. Vite/Svelte compilation is
|
||||||
|
* unreliable for this package on CI (Rollup parses vendor sources as JS). Compile
|
||||||
|
* to plain `.js` at install/build time and rewrite internal imports.
|
||||||
|
*/
|
||||||
|
import { compile } from "svelte/compiler";
|
||||||
|
import {
|
||||||
|
readFileSync,
|
||||||
|
readdirSync,
|
||||||
|
statSync,
|
||||||
|
writeFileSync,
|
||||||
|
} from "node:fs";
|
||||||
|
import { dirname, join } from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
|
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
||||||
|
const layerchartRoot = join(root, "node_modules", "layerchart");
|
||||||
|
const layerchartDist = join(layerchartRoot, "dist");
|
||||||
|
const stampPath = join(layerchartDist, ".bsplus-compiled");
|
||||||
|
|
||||||
|
function exists(path) {
|
||||||
|
try {
|
||||||
|
statSync(path);
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!exists(layerchartDist)) {
|
||||||
|
console.log("compile-layerchart-vendor: layerchart not installed, skipping");
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const COMPILE_ALGO_VERSION = "2";
|
||||||
|
|
||||||
|
const layerchartVersion = JSON.parse(
|
||||||
|
readFileSync(join(layerchartRoot, "package.json"), "utf8"),
|
||||||
|
).version;
|
||||||
|
|
||||||
|
const stampContent = `${layerchartVersion}\n${COMPILE_ALGO_VERSION}`;
|
||||||
|
|
||||||
|
if (
|
||||||
|
exists(stampPath) &&
|
||||||
|
readFileSync(stampPath, "utf8").trim() === stampContent
|
||||||
|
) {
|
||||||
|
console.log(
|
||||||
|
`compile-layerchart-vendor: layerchart@${layerchartVersion} already compiled, skipping`,
|
||||||
|
);
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function walkFiles(dir, files = []) {
|
||||||
|
for (const name of readdirSync(dir)) {
|
||||||
|
if (name === "node_modules") continue;
|
||||||
|
const path = join(dir, name);
|
||||||
|
if (statSync(path).isDirectory()) {
|
||||||
|
walkFiles(path, files);
|
||||||
|
} else {
|
||||||
|
files.push(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
const importSuffixPattern = /\.svelte(?=['"])/g;
|
||||||
|
|
||||||
|
function patchSvelteImports(content) {
|
||||||
|
return content.replace(importSuffixPattern, ".js");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Rollup CJS resolver chokes on TS optional params (`name?`) in vendor `.js`. */
|
||||||
|
function stripRollupBreakingSyntax(code) {
|
||||||
|
return code
|
||||||
|
.replace(/(\w+)\?(?=\s*[,)\]])/g, "$1")
|
||||||
|
.replace(/(\w+)\?(?=\s*:)/g, "$1");
|
||||||
|
}
|
||||||
|
|
||||||
|
const svelteFiles = walkFiles(layerchartDist).filter((f) => f.endsWith(".svelte"));
|
||||||
|
|
||||||
|
for (const sveltePath of svelteFiles) {
|
||||||
|
const source = readFileSync(sveltePath, "utf8");
|
||||||
|
if (!source.includes("<script")) continue;
|
||||||
|
|
||||||
|
const compiled = compile(source, {
|
||||||
|
filename: sveltePath,
|
||||||
|
generate: "client",
|
||||||
|
css: "injected",
|
||||||
|
});
|
||||||
|
|
||||||
|
const jsPath = sveltePath.replace(/\.svelte$/, ".js");
|
||||||
|
const jsCode = stripRollupBreakingSyntax(patchSvelteImports(compiled.js.code));
|
||||||
|
writeFileSync(jsPath, jsCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
const patchable = walkFiles(layerchartDist).filter((f) =>
|
||||||
|
/\.(js|svelte|ts|mjs)$/.test(f),
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const filePath of patchable) {
|
||||||
|
const content = readFileSync(filePath, "utf8");
|
||||||
|
if (!content.includes(".svelte")) continue;
|
||||||
|
const patched = patchSvelteImports(content);
|
||||||
|
if (patched !== content) {
|
||||||
|
writeFileSync(filePath, patched);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
writeFileSync(stampPath, stampContent);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`compile-layerchart-vendor: compiled ${svelteFiles.length} Svelte files`,
|
||||||
|
);
|
||||||
@@ -260,7 +260,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
const hideModal = (relatedTheme?: Theme | null) => {
|
const hideModal = (relatedTheme = null) => {
|
||||||
|
|
||||||
animate(
|
animate(
|
||||||
|
|
||||||
|
|||||||
@@ -101,10 +101,15 @@
|
|||||||
showCloudPanel = true;
|
showCloudPanel = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const showDisclaimer = (onConfirm: () => void, onCancel: () => void, title?: string, message?: string) => {
|
const showDisclaimer = (
|
||||||
|
onConfirm: () => void,
|
||||||
|
onCancel: () => void,
|
||||||
|
title = "Confirm",
|
||||||
|
message = "",
|
||||||
|
) => {
|
||||||
disclaimerCallbacks = { onConfirm, onCancel };
|
disclaimerCallbacks = { onConfirm, onCancel };
|
||||||
disclaimerTitle = title ?? "Confirm";
|
disclaimerTitle = title;
|
||||||
disclaimerMessage = message ?? "";
|
disclaimerMessage = message;
|
||||||
showDisclaimerModal = true;
|
showDisclaimerModal = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
const segments = $derived(getSegments(text, term, matches));
|
const segments = $derived(getSegments(text, term, matches));
|
||||||
|
|
||||||
// Build highlight map (copied and adapted from highlightMatch)
|
// Build highlight map (copied and adapted from highlightMatch)
|
||||||
function getSegments(text: string, term: string, matches?: readonly FuseResultMatch[]) {
|
function getSegments(text: string, term: string, matches = undefined) {
|
||||||
if (!term.trim() || !matches || matches.length === 0) return [{ text, highlight: false }];
|
if (!term.trim() || !matches || matches.length === 0) return [{ text, highlight: false }];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
+22
-17
@@ -72,13 +72,26 @@ export default defineConfig(({ command }) => ({
|
|||||||
__BUILD_LABEL__: JSON.stringify(process.env.BUILD_LABEL ?? ""),
|
__BUILD_LABEL__: JSON.stringify(process.env.BUILD_LABEL ?? ""),
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
svelte({
|
||||||
|
emitCss: false,
|
||||||
|
configFile: join(__dirname, "src", "svelte.config.js"),
|
||||||
|
}),
|
||||||
extensionChunkUrls(),
|
extensionChunkUrls(),
|
||||||
base64Loader,
|
base64Loader,
|
||||||
InlineWorkerPlugin(),
|
InlineWorkerPlugin(),
|
||||||
svelte({
|
...(useMillion && command !== "build"
|
||||||
emitCss: false,
|
? [
|
||||||
|
million.vite({
|
||||||
|
auto: true,
|
||||||
|
filter: {
|
||||||
|
exclude: [
|
||||||
|
"**/*.svelte",
|
||||||
|
"node_modules/**/*.{jsx,tsx,ts,js,mjs,cjs}",
|
||||||
|
],
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
...(useMillion ? [million.vite({ auto: true })] : []),
|
]
|
||||||
|
: []),
|
||||||
crx({
|
crx({
|
||||||
manifest: withDevManifestCsp(
|
manifest: withDevManifestCsp(
|
||||||
targets.find((t) => t.browser === mode.toLowerCase())?.manifest ??
|
targets.find((t) => t.browser === mode.toLowerCase())?.manifest ??
|
||||||
@@ -115,6 +128,12 @@ export default defineConfig(({ command }) => ({
|
|||||||
include: [
|
include: [
|
||||||
"@babel/runtime/helpers/extends",
|
"@babel/runtime/helpers/extends",
|
||||||
"@babel/runtime/helpers/interopRequireDefault",
|
"@babel/runtime/helpers/interopRequireDefault",
|
||||||
|
"layerchart",
|
||||||
|
"d3-scale",
|
||||||
|
"d3-shape",
|
||||||
|
"d3-array",
|
||||||
|
"d3-format",
|
||||||
|
"d3-time",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
legacy: {
|
legacy: {
|
||||||
@@ -133,20 +152,6 @@ export default defineConfig(({ command }) => ({
|
|||||||
input: {
|
input: {
|
||||||
settings: join(__dirname, "src", "interface", "index.html"),
|
settings: join(__dirname, "src", "interface", "index.html"),
|
||||||
pageState: join(__dirname, "src", "pageState.js"),
|
pageState: join(__dirname, "src", "pageState.js"),
|
||||||
seqtaMenuColourPatch: join(
|
|
||||||
__dirname,
|
|
||||||
"src",
|
|
||||||
"seqta",
|
|
||||||
"utils",
|
|
||||||
"seqtaMenuColourPatch.js",
|
|
||||||
),
|
|
||||||
themeImagePagePatch: join(
|
|
||||||
__dirname,
|
|
||||||
"src",
|
|
||||||
"seqta",
|
|
||||||
"utils",
|
|
||||||
"themeImagePagePatch.js",
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
assetFileNames: "assets/[name]-[hash][extname]",
|
assetFileNames: "assets/[name]-[hash][extname]",
|
||||||
|
|||||||
Reference in New Issue
Block a user