Skip to content
Open
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
25 changes: 0 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

226 changes: 226 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
// Copyright (c) 2021-2026 Littleton Robotics
// http://github.com/Mechanical-Advantage
//
// Use of this source code is governed by a BSD
// license that can be found in the LICENSE file
// at the root directory of this project.

import { getBabelOutputPlugin } from "@rollup/plugin-babel";
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import nodeResolve from "@rollup/plugin-node-resolve";
import replace from "@rollup/plugin-replace";
import terser from "@rollup/plugin-terser";
import typescript from "@rollup/plugin-typescript";
import fs from "fs";
import cleanup from "rollup-plugin-cleanup";
import replaceRegEx from "rollup-plugin-re";

const isWpilib = process.env.ASCOPE_DISTRIBUTION === "WPILIB";
const isLite = process.env.ASCOPE_DISTRIBUTION === "LITE";
const licenseHeader =
"// Copyright (c) 2021-2026 Littleton Robotics\n// http://github.com/Mechanical-Advantage\n//\n// Use of this source code is governed by a BSD\n// license that can be found in the LICENSE file\n// at the resources directory of this application.\n";

function bundle(input, output, isMain, isXRClient, external = []) {
const packageJson = JSON.parse(
fs.readFileSync("package.json", {
encoding: "utf-8"
})
);
return {
input: "src/" + input,
output: {
file: (isLite ? "lite/static/" : "") + "bundles/" + output,
format: isMain ? "cjs" : "es",
banner: licenseHeader
},
context: "this",
external: external,
plugins: [
typescript(),
nodeResolve({
preferBuiltins: true
}),
commonjs(),
...(isXRClient
? [
getBabelOutputPlugin({
presets: [["@babel/preset-env", { modules: false }]],
compact: true,
targets: "iOS 16" // AdvantageScope XR is built for iOS 16
}),
terser()
]
: isLite
? [
getBabelOutputPlugin({
presets: [["@babel/preset-env", { modules: false }]],
compact: true,
targets: "> 0.1%, not dead"
}),
terser({ mangle: { reserved: ["Module"] } })
]
: [cleanup()]),
json(),
replace({
preventAssignment: true,
values: {
__distribution__: isWpilib ? "WPILib" : isLite ? "Lite" : "FRC6328",
__version__: packageJson.version,
__build_date__: new Date().toLocaleString("en-US", {
timeZone: "UTC",
hour12: false,
year: "numeric",
month: "numeric",
day: "numeric",
hour: "numeric",
minute: "numeric",
second: "numeric",
timeZoneName: "short"
}),
__copyright__: packageJson.build.copyright
}
}),
replaceRegEx({
patterns: [
// Remove unused eval in protobufjs
// https://github.com/protobufjs/protobuf.js/issues/593
{
test: /eval.*\(moduleName\);/g,
replace: "undefined;"
},

// Remove dependency on node:sqlite (not actually
// used, so just replace with stand-in dependency)
{
test: /node:sqlite/g,
replace: "fs"
}
]
})
],
onwarn(message, warn) {
// Hide warnings about protobufjs circular dependencies
// https://github.com/protobufjs/protobuf.js/issues/1402
if (message.code === "CIRCULAR_DEPENDENCY") return;
warn(message);
}
};
}

const mainBundles = isLite
? [bundle("main/lite/main.ts", "main.js", false, false)]
: [
bundle("main/electron/main.ts", "main.js", true, false, [
"electron",
"electron-fetch",
"fs",
"jsonfile",
"net",
"os",
"ws",
"http",
"path",
"basic-ftp",
"download",
"youtube-dl-exec",
"tesseract.js",
"lzma-native",
"@rev-robotics/revlog-converter"
]),
bundle("preload.ts", "preload.js", true, false, ["electron"])
];
const largeRendererBundles = [
bundle("hub/hub.ts", "hub.js", false, false),
bundle("hub/controllers/LineGraphController.ts", "LineGraphController.js", false, false),
...(isLite ? [] : [bundle("satellite.ts", "satellite.js", false, false)])
];
const smallRendererBundles = [
bundle("editRange.ts", "editRange.js", false, false),
bundle("unitConversion.ts", "unitConversion.js", false, false),
bundle("renameTab.ts", "renameTab.js", false, false),
bundle("editFov.ts", "editFov.js", false, false),
bundle("sourceListHelp.ts", "sourceListHelp.js", false, false),
bundle("betaWelcome.ts", "betaWelcome.js", false, false),
bundle("preferences.ts", "preferences.js", false, false),
bundle("licenses.ts", "licenses.js", false, false),
bundle("download.ts", "download.js", false, false),
...(isLite
? [bundle("uploadAsset.ts", "uploadAsset.js", false, false)]
: [bundle("export.ts", "export.js", false, false)])
];
const workerBundles = [
bundle("hub/dataSources/csv/csvWorker.ts", "hub$csvWorker.js", false, false),
bundle("hub/dataSources/rlog/rlogWorker.ts", "hub$rlogWorker.js", false, false),
bundle("hub/dataSources/roadrunnerlog/roadRunnerWorker.ts", "hub$roadRunnerWorker.js", false, false),
bundle("hub/dataSources/wpilog/wpilogWorker.ts", "hub$wpilogWorker.js", false, false),
bundle("hub/dataSources/dslog/dsLogWorker.ts", "hub$dsLogWorker.js", false, false),
...(isLite ? [] : [bundle("hub/exportWorker.ts", "hub$exportWorker.js", false, false)]),
bundle("shared/renderers/field3d/workers/loadField.ts", "shared$loadField.js", false, false),
bundle("shared/renderers/field3d/workers/loadRobot.ts", "shared$loadRobot.js", false, false)
];
const xrBundles = [
bundle("xrClient/xrClient.ts", "xrClient.js", false, true),
bundle("xrControls.ts", "xrControls.js", false, false)
];
const runOwletDownload = {
input: "src/runOwletDownload.ts",
output: {
file: "runOwletDownload.js",
format: "cjs"
},
context: "this",
external: ["download"],
plugins: [
typescript(),
nodeResolve({
preferBuiltins: true
}),
commonjs(),
json()
],
onwarn() {}
};

export default (cliArgs) => {
let bundles = [];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any reason this had to be changed? Just wanted to ask as it seemed unrelated to me.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It wasn't strictly necessary, but the build was taking longer than I would have liked. I can remove it if you prefer, though I don't see any harm in keeping it since it provides useful functionality during builds.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi I just checked, and it looks like #509 made rollup.config.mjs obsolete. Would you like me to remove the file entirely?


if (cliArgs.configMain) {
bundles.push(...mainBundles);
}

if (cliArgs.oren) {
bundles.push(...oren);
}

if (cliArgs.configLargeRenderers) {
bundles.push(...largeRendererBundles);
}

if (cliArgs.configSmallRenderers) {
bundles.push(...smallRendererBundles);
}

if (cliArgs.configWorkers) {
bundles.push(...workerBundles);
}

if (cliArgs.configXR) {
if (!isLite) {
bundles.push(...xrBundles);
}
}

if (cliArgs.configRunOwletDownload) {
return runOwletDownload; // assuming this should stay exclusive
}

// If no flags were passed, return default behavior
if (bundles.length === 0) {
return isLite
? [...mainBundles, ...largeRendererBundles, ...smallRendererBundles, ...workerBundles]
: [...mainBundles, ...largeRendererBundles, ...smallRendererBundles, ...workerBundles, ...xrBundles];
}

return bundles;
};
25 changes: 16 additions & 9 deletions src/hub/SourceList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,16 +402,19 @@ export default class SourceList {
this.HAND_ICON.style.opacity = show ? "0.15" : "0";
}

/**
* Adds a new field to the list, if the type is valid.
*
* @param logKey The key for the field to add
* @param parentIndex The index of the parent item (optional)
*/
addField(logKey: string, parentIndex?: number) {
/**
* Adds a new field to the list, if the type is valid.
*
* @param logKey The key for the field to add
* @param option The optional configuration for the field to add
* @param option.parentIndex The index of the parent item (optional)
* @param option.type The type of the field to add (optional)
*/
addField(logKey: string, option?: { parentIndex?: number; type?: string }) {
let logType = window.log.getType(logKey);
let logTypeString = logType === null ? null : LoggableType[logType];
let structuredType = window.log.getStructuredType(logKey);
const parentIndex = option?.parentIndex;

// Get memory entry
let memory: SourceListTypeMemoryEntry | null = null;
Expand Down Expand Up @@ -492,7 +495,7 @@ export default class SourceList {
}
});
let state: SourceListItemState = {
type: bestType.typeConfig.key,
type: option?.type || bestType.typeConfig.key,
logKey: logKey,
logType: bestType.logType,
visible: true,
Expand Down Expand Up @@ -702,7 +705,7 @@ export default class SourceList {
if (!typeValidAsChild) parentIndex = null;
if (parentIndex !== null || typeValidAsRoot) {
draggedFields.forEach((field) => {
this.addField(field, parentIndex === null ? undefined : parentIndex);
this.addField(field, { parentIndex: parentIndex === null ? undefined : parentIndex });
});
}
Array.from(this.LIST.children).forEach((element) => {
Expand Down Expand Up @@ -1262,4 +1265,8 @@ export default class SourceList {
valueText.innerText = text;
}
}

public getUUID() {
return this.UUID;
}
}
7 changes: 7 additions & 0 deletions src/hub/Tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,13 @@ export default class Tabs {
}
}

/** Runs the "Add from all logs" action on the selected line graph. */
addFromAllLogs(data?: any) {
if (this.tabList[this.selectedTab].type === TabType.LineGraph) {
(this.tabList[this.selectedTab].controller as LineGraphController).addFromAllLogs(data);
}
}

/** Switches the selected camera for the selected 3D field. */
set3DCamera(index: number) {
if (this.tabList[this.selectedTab].type === TabType.Field3d) {
Expand Down
34 changes: 32 additions & 2 deletions src/hub/controllers/LineGraphController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ensureThemeContrast } from "../../shared/Colors";
import LineGraphFilter from "../../shared/LineGraphFilter";
import { SelectionMode } from "../../shared/Selection";
import { SourceListState } from "../../shared/SourceListConfig";
import { getLogValueText } from "../../shared/log/LogUtil";
import { getLogValueText,keyPresent } from "../../shared/log/LogUtil";
import { LogValueSetNumber } from "../../shared/log/LogValueSets";
import { AKIT_TIMESTAMP_KEYS, getRobotStateRanges } from "../../shared/log/RobotState";
import {
Expand Down Expand Up @@ -310,7 +310,7 @@ export default class LineGraphController implements TabController {
break;
}
}

/** Sets the state of the robot mode visualization. */
setRobotModeVisible(showRobotMode: boolean) {
this.showRobotMode = showRobotMode;
Expand All @@ -337,6 +337,36 @@ export default class LineGraphController implements TabController {
return false;
}


addFromAllLogs(data?: any) {
let uuid = typeof data.uuid === "string" ? (data.uuid as string) : "";
let sourceList: SourceList;
if (uuid.match(this.rightSourceList.getUUID())) {
sourceList = this.rightSourceList;
} else if (uuid.match(this.leftSourceList.getUUID())) {
sourceList = this.leftSourceList;
} else if (uuid.match(this.discreteSourceList.getUUID())) {
sourceList = this.discreteSourceList;
} else {
return;
}

let logKey = typeof data.logKey === "string" ? data.logKey : "";
logKey = logKey.replace(/^\/Log[^/]+/, "");
let newLogKey = logKey;
let existingKeys = sourceList
.getState()
.filter((source) => source.logKey.includes(logKey))
.map((source) => source.logKey);
let logNum = 1;
newLogKey = "/Log" + logNum + logKey;
while (keyPresent(window.log, [newLogKey])) {
if (!existingKeys.includes(newLogKey)) sourceList.addField(newLogKey, {type: data.type});
logNum++;
newLogKey = "/Log" + logNum + logKey;
}
}

private getPreview(
key: string,
time: number,
Expand Down
Loading