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

Revamp CSG functions, make curve canvases consistent & more #234

Merged
merged 43 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b55aef8
feat(src): Extract & update CSG's CSS constants
Cloud7050 Sep 4, 2023
3b57671
chore(csg): Remove V1 comments referencing fork issues
Cloud7050 Sep 4, 2023
ac9c122
feat(csg): Migrate to BlueprintJS Tooltips
Cloud7050 Sep 4, 2023
a597fc7
devfeat(csg): Update samples
Cloud7050 Sep 4, 2023
8559080
devfeat(curve): Add samples
Cloud7050 Sep 4, 2023
e8f73d9
docs(curve): Update animation function docs
Cloud7050 Sep 4, 2023
89da19e
ref(csg): Remove default colour
Cloud7050 Sep 4, 2023
1c8f2b4
fix(build): Fix `build modules` building no tabs
Cloud7050 Sep 5, 2023
41b4ec8
feat(): Enhance & make curve canvases consistent
Cloud7050 Sep 5, 2023
96cce00
feat(csg): Replace hint dots with colons
Cloud7050 Sep 5, 2023
d951c8a
ref(csg): Use real js-slang lists
Cloud7050 Sep 5, 2023
7509b9d
devfeat(csg): Update colours sample
Cloud7050 Sep 5, 2023
3ec40f5
devfeat(csg): Add primitives sample
Cloud7050 Sep 5, 2023
7453ce4
chore(pkg): Lock modeling version for patch file
Cloud7050 Sep 5, 2023
5ecb319
ref(build): Reorder config to match
Cloud7050 Sep 5, 2023
beb901e
ref(csg): Rename to Operable, no List, move/del funcs
Cloud7050 Sep 5, 2023
9a9644d
fix(csg): Fix primitive sample trailing comma
Cloud7050 Sep 5, 2023
63a5f35
devfeat(csg): Add Prof's Sierpinski fractal
Cloud7050 Sep 5, 2023
ac51bf8
FEAT(csg): Overhaul functions, documentation
Cloud7050 Sep 5, 2023
191f3ae
devfeat(csg): Update sample import names
Cloud7050 Sep 5, 2023
7dfcd36
ref(csg): Reorder sample functions
Cloud7050 Sep 5, 2023
dcb28d5
devfeat(csg): Add rotation sample
Cloud7050 Sep 5, 2023
4332332
devfeat(csg): Add summary snowglobe example as sample
Cloud7050 Sep 5, 2023
217756b
docs(csg): Plural categories, bulleted list, tweaks
Cloud7050 Sep 5, 2023
23a6eb4
ref(csg): Refactor operables
Cloud7050 Sep 5, 2023
be185d3
feat(csg): Improve error feedback for pitfalls
Cloud7050 Sep 5, 2023
c37f8b0
fix(csg): Implement proper ungroup
Cloud7050 Sep 5, 2023
e0be467
feat(csg): Improve error feedback for pitfalls
Cloud7050 Sep 5, 2023
dbcdbd5
feat(csg): Update sample utility funcs
Cloud7050 Sep 6, 2023
9624a26
feat(csg): Update sierpinski sample for new primitive
Cloud7050 Sep 6, 2023
ad2e694
fix(rune): Fix low resolution heart
Cloud7050 Sep 6, 2023
f4e7f3b
docs(csg): Link to GitHub samples in summary
Cloud7050 Sep 6, 2023
c0b7844
feat(csg): Update sierpinski sample
Cloud7050 Sep 6, 2023
3a2a016
feat(csg): Readd custom default colour due to bug #227
Cloud7050 Sep 6, 2023
9bc7c80
ref(build): Remove leftover from troubleshooting
Cloud7050 Sep 6, 2023
fd66e35
docs(csg): Tweak pyramid dimensions description
Cloud7050 Sep 6, 2023
48a1a3b
feat(sound): Throw error on invalid sound durations
Cloud7050 Sep 6, 2023
d1d8ac6
chore(pkg): Remove unused lodash
Cloud7050 Sep 6, 2023
636ff3e
feat(curve): Add Source version to canvases sample
Cloud7050 Sep 6, 2023
bb2137b
feat(tabs): Remove enforced spacing of MultiItemDisplay
Cloud7050 Sep 7, 2023
6b22b83
ref(csg): Default colour back in constants
Cloud7050 Sep 11, 2023
008d24b
fix(csg): Disallow negative scaling, update docs instead
Cloud7050 Sep 11, 2023
de0a9a8
ref(csg): Rename RGB components to values
Cloud7050 Sep 11, 2023
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
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"@types/eslint": "^8.4.10",
"@types/estree": "^1.0.0",
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.191",
"@types/node": "^17.0.23",
"@types/plotly.js-dist": "npm:@types/plotly.js",
"@types/react": "^17.0.43",
Expand Down Expand Up @@ -87,15 +86,14 @@
"@blueprintjs/popover2": "^1.4.3",
"@box2d/core": "^0.10.0",
"@box2d/debug-draw": "^0.10.0",
"@jscad/modeling": "^2.9.5",
"@jscad/modeling": "2.9.6",
"@jscad/regl-renderer": "^2.6.1",
"@jscad/stl-serializer": "^2.1.13",
"ace-builds": "^1.4.14",
"classnames": "^2.3.1",
"dayjs": "^1.10.4",
"gl-matrix": "^3.3.0",
"js-slang": "^1.0.20",
"lodash": "^4.17.21",
"patch-package": "^6.5.1",
"phaser": "^3.54.0",
"plotly.js-dist": "^2.17.1",
Expand All @@ -115,4 +113,4 @@
"scripts/src/jest.config.js"
]
}
}
}
84 changes: 47 additions & 37 deletions scripts/bin/build/buildUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,60 +165,70 @@ export const retrieveBundles = async (manifestFile, modules) => {
return knownBundles;
};
/**
* Function to determine which bundles and tabs to build based on the user's input.
* Determines which bundles and tabs to build based on the user's input.
*
* @param modules
* - Pass `null` to indicate that the user did not specify any modules. This
* will add all bundles currently registered in the manifest
* - Pass `[]` to indicate not to add any modules
* - Pass an array of strings to manually specify modules to process
* @param tabOpts
* - Pass `null` to indicate that the user did not specify any tabs. This
* will add all tabs currently registered in the manifest
* - Pass `[]` to indicate not to add any tabs
* - Pass an array of strings to manually specify tabs to process
* @param addTabs If `true`, then all tabs of selected bundles will be added to
* the list of tabs to build.
* If no modules and no tabs are specified, it is assumed the user wants to
* build everything.
*
* If modules but no tabs are specified, it is assumed the user only wants to
* build those bundles (and possibly those modules' tabs based on
* shouldAddModuleTabs).
*
* If tabs but no modules are specified, it is assumed the user only wants to
* build those tabs.
*
* If both modules and tabs are specified, both of the above apply and are
* combined.
*
* @param modules module names specified by the user
* @param tabOptions tab names specified by the user
* @param shouldAddModuleTabs whether to also automatically include the tabs of
* specified modules
*/
export const retrieveBundlesAndTabs = async (manifestFile, modules, tabOpts, addTabs = true) => {
export const retrieveBundlesAndTabs = async (manifestFile, modules, tabOptions, shouldAddModuleTabs = true) => {
const manifest = await retrieveManifest(manifestFile);
const knownBundles = Object.keys(manifest);
const knownTabs = Object.values(manifest)
const knownTabs = Object
.values(manifest)
.flatMap((x) => x.tabs);
let bundles;
let tabs;
if (modules !== null) {
// Some modules were specified
let bundles = [];
let tabs = [];
function addSpecificModules() {
// If unknown modules were specified, error
const unknownModules = modules.filter((m) => !knownBundles.includes(m));
if (unknownModules.length > 0) {
throw new Error(`Unknown modules: ${unknownModules.join(', ')}`);
}
bundles = modules;
if (addTabs) {
// If a bundle is being rebuilt, add its tabs
tabs = modules.flatMap((bundle) => manifest[bundle].tabs);
}
else {
tabs = [];
bundles = bundles.concat(modules);
if (shouldAddModuleTabs) {
// Add the modules' tabs too
tabs = [...tabs, ...modules.flatMap((bundle) => manifest[bundle].tabs)];
}
}
else {
// No modules were specified
bundles = knownBundles;
tabs = [];
}
if (tabOpts !== null) {
// Tabs were specified
const unknownTabs = tabOpts.filter((t) => !knownTabs.includes(t));
function addSpecificTabs() {
// If unknown tabs were specified, error
const unknownTabs = tabOptions.filter((t) => !knownTabs.includes(t));
if (unknownTabs.length > 0) {
throw new Error(`Unknown tabs: ${unknownTabs.join(', ')}`);
}
tabs = tabs.concat(tabOpts);
tabs = tabs.concat(tabOptions);
}
else {
// No tabs were specified
function addAllBundles() {
bundles = bundles.concat(knownBundles);
}
function addAllTabs() {
tabs = tabs.concat(knownTabs);
}
if (modules === null && tabOptions === null) {
addAllBundles();
addAllTabs();
}
else {
if (modules !== null)
addSpecificModules();
if (tabOptions !== null)
addSpecificTabs();
}
return {
bundles: [...new Set(bundles)],
tabs: [...new Set(tabs)],
Expand Down
4 changes: 2 additions & 2 deletions scripts/bin/build/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ const waitForQuit = () => new Promise((resolve, reject) => {
});
const getBundleContext = ({ srcDir, outDir }, bundles, app) => esbuild({
...bundleOptions,
entryPoints: bundles.map(bundleNameExpander(srcDir)),
outbase: outDir,
outdir: outDir,
entryPoints: bundles.map(bundleNameExpander(srcDir)),
plugins: [{
name: 'Bundle Compiler',
async setup(pluginBuild) {
Expand Down Expand Up @@ -55,9 +55,9 @@ const getBundleContext = ({ srcDir, outDir }, bundles, app) => esbuild({
});
const getTabContext = ({ srcDir, outDir }, tabs) => esbuild({
...tabOptions,
entryPoints: tabs.map(tabNameExpander(srcDir)),
outbase: outDir,
outdir: outDir,
entryPoints: tabs.map(tabNameExpander(srcDir)),
external: ['react*', 'react-dom'],
plugins: [{
name: 'Tab Compiler',
Expand Down
2 changes: 1 addition & 1 deletion scripts/bin/build/modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const getBuildModulesCommand = () => createBuildCommand('modules', true)
.description('Build modules and their tabs')
.action(async (modules, { manifest, ...opts }) => {
const [assets] = await Promise.all([
retrieveBundlesAndTabs(manifest, modules, []),
retrieveBundlesAndTabs(manifest, modules, null),
createOutDir(opts.outDir),
]);
await prebuild(opts, assets);
Expand Down
4 changes: 2 additions & 2 deletions scripts/src/build/__tests__/buildUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ describe('Test retrieveBundlesAndTabs', () => {
.toEqual(expect.arrayContaining(['tab0']));
});

it('should return only tabs when an empty array is passed for modules', async () => {
it('should return nothing when an empty array is passed for modules', async () => {
const result = await retrieveBundlesAndTabs('', [], null);

expect(result.bundles)
.toEqual([]);
expect(result.modulesSpecified)
.toBe(true);
expect(result.tabs)
.toEqual(expect.arrayContaining(['tab0', 'tab1']));
.toEqual([]);
});

it('should return tabs from the specified modules, and concatenate specified tabs', async () => {
Expand Down
88 changes: 49 additions & 39 deletions scripts/src/build/buildUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,69 +190,79 @@ export const retrieveBundles = async (manifestFile: string, modules: string[] |
};

/**
* Function to determine which bundles and tabs to build based on the user's input.
* Determines which bundles and tabs to build based on the user's input.
*
* @param modules
* - Pass `null` to indicate that the user did not specify any modules. This
* will add all bundles currently registered in the manifest
* - Pass `[]` to indicate not to add any modules
* - Pass an array of strings to manually specify modules to process
* @param tabOpts
* - Pass `null` to indicate that the user did not specify any tabs. This
* will add all tabs currently registered in the manifest
* - Pass `[]` to indicate not to add any tabs
* - Pass an array of strings to manually specify tabs to process
* @param addTabs If `true`, then all tabs of selected bundles will be added to
* the list of tabs to build.
* If no modules and no tabs are specified, it is assumed the user wants to
* build everything.
*
* If modules but no tabs are specified, it is assumed the user only wants to
* build those bundles (and possibly those modules' tabs based on
* shouldAddModuleTabs).
*
* If tabs but no modules are specified, it is assumed the user only wants to
* build those tabs.
*
* If both modules and tabs are specified, both of the above apply and are
* combined.
*
* @param modules module names specified by the user
* @param tabOptions tab names specified by the user
* @param shouldAddModuleTabs whether to also automatically include the tabs of
* specified modules
*/
export const retrieveBundlesAndTabs = async (
manifestFile: string,
modules: string[] | null,
tabOpts: string[] | null,
addTabs: boolean = true,
tabOptions: string[] | null,
shouldAddModuleTabs: boolean = true,
) => {
const manifest = await retrieveManifest(manifestFile);
const knownBundles = Object.keys(manifest);
const knownTabs = Object.values(manifest)
const knownTabs = Object
.values(manifest)
.flatMap((x) => x.tabs);

let bundles: string[];
let tabs: string[];
let bundles: string[] = [];
let tabs: string[] = [];

if (modules !== null) {
// Some modules were specified
function addSpecificModules() {
// If unknown modules were specified, error
const unknownModules = modules.filter((m) => !knownBundles.includes(m));

if (unknownModules.length > 0) {
throw new Error(`Unknown modules: ${unknownModules.join(', ')}`);
}
bundles = modules;

if (addTabs) {
// If a bundle is being rebuilt, add its tabs
tabs = modules.flatMap((bundle) => manifest[bundle].tabs);
} else {
tabs = [];
bundles = bundles.concat(modules);

if (shouldAddModuleTabs) {
// Add the modules' tabs too
tabs = [...tabs, ...modules.flatMap((bundle) => manifest[bundle].tabs)];
}
} else {
// No modules were specified
bundles = knownBundles;
tabs = [];
}

if (tabOpts !== null) {
// Tabs were specified
const unknownTabs = tabOpts.filter((t) => !knownTabs.includes(t));

function addSpecificTabs() {
// If unknown tabs were specified, error
const unknownTabs = tabOptions.filter((t) => !knownTabs.includes(t));
if (unknownTabs.length > 0) {
throw new Error(`Unknown tabs: ${unknownTabs.join(', ')}`);
}
tabs = tabs.concat(tabOpts);
} else {
// No tabs were specified

tabs = tabs.concat(tabOptions);
}
function addAllBundles() {
bundles = bundles.concat(knownBundles);
}
function addAllTabs() {
tabs = tabs.concat(knownTabs);
}

if (modules === null && tabOptions === null) {
addAllBundles();
addAllTabs();
} else {
if (modules !== null) addSpecificModules();
if (tabOptions !== null) addSpecificTabs();
}

return {
bundles: [...new Set(bundles)],
tabs: [...new Set(tabs)],
Expand Down
4 changes: 2 additions & 2 deletions scripts/src/build/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ const waitForQuit = () => new Promise<void>((resolve, reject) => {
type ContextOptions = Record<'srcDir' | 'outDir', string>;
const getBundleContext = ({ srcDir, outDir }: ContextOptions, bundles: string[], app?: Application) => esbuild({
...bundleOptions,
entryPoints: bundles.map(bundleNameExpander(srcDir)),
outbase: outDir,
outdir: outDir,
entryPoints: bundles.map(bundleNameExpander(srcDir)),
plugins: [{
name: 'Bundle Compiler',
async setup(pluginBuild) {
Expand Down Expand Up @@ -74,9 +74,9 @@ const getBundleContext = ({ srcDir, outDir }: ContextOptions, bundles: string[],

const getTabContext = ({ srcDir, outDir }: ContextOptions, tabs: string[]) => esbuild({
...tabOptions,
entryPoints: tabs.map(tabNameExpander(srcDir)),
outbase: outDir,
outdir: outDir,
entryPoints: tabs.map(tabNameExpander(srcDir)),
external: ['react*', 'react-dom'],
plugins: [{
name: 'Tab Compiler',
Expand Down
2 changes: 1 addition & 1 deletion scripts/src/build/modules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const getBuildModulesCommand = () => createBuildCommand('modules', true)
.description('Build modules and their tabs')
.action(async (modules: string[] | null, { manifest, ...opts }: BuildCommandInputs & LintCommandInputs) => {
const [assets] = await Promise.all([
retrieveBundlesAndTabs(manifest, modules, []),
retrieveBundlesAndTabs(manifest, modules, null),
createOutDir(opts.outDir),
]);

Expand Down
25 changes: 0 additions & 25 deletions src/bundles/csg/constants.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
/* [Imports] */
import { IconSize } from '@blueprintjs/core';

/* [Exports] */

//NOTE Silver is in here to avoid circular dependencies, instead of in
// functions.ts with the other colour strings
export const SILVER: string = '#AAAAAA';
export const DEFAULT_COLOR: string = SILVER;

// Values extracted from the styling of the frontend
export const SA_TAB_BUTTON_WIDTH: string = '40px';
export const SA_TAB_ICON_SIZE: number = IconSize.LARGE;

export const BP_TOOLTIP_PADDING: string = '10px 12px';
export const BP_TAB_BUTTON_MARGIN: string = '20px';
export const BP_TAB_PANEL_MARGIN: string = '20px';
export const BP_BORDER_RADIUS: string = '3px';
export const STANDARD_MARGIN: string = '10px';

export const BP_TEXT_COLOR: string = '#F5F8FA';
export const BP_TOOLTIP_BACKGROUND_COLOR: string = '#E1E8ED';
export const BP_ICON_COLOR: string = '#A7B6C2';
export const ACE_GUTTER_TEXT_COLOR: string = '#8091A0';
export const ACE_GUTTER_BACKGROUND_COLOR: string = '#34495E';
export const BP_TOOLTIP_TEXT_COLOR: string = '#394B59';

// Renderer grid constants
export const MAIN_TICKS: number = 1;
export const SUB_TICKS: number = MAIN_TICKS / 4;
Expand Down
Loading
Loading