Skip to content
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
43 changes: 19 additions & 24 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,29 @@ while getopts ":bpu" opt; do
esac
done

# If no options are provided, set all flags to true
# If no options are provided, default to build only
if [ "$OPTIND" -eq 1 ]; then
BUILD=true
PACKAGE=true
UPLOAD=true
# PACKAGE remains false (we'll prompt), UPLOAD remains false
fi

# Function to perform the build process
perform_build() {
echo -e "${INFO}Starting build process..."

# Remove existing build artifacts
rm -rf dist/bundle.js dist/typings/
if [[ $? -eq 0 ]]; then
echo -e "${INFO}Deleted old build artifacts."
else
echo -e "${WARNING}Could not delete old dist files, continuing..."
fi

# Run Rollup to build the project
npx rollup -c rollup.config.js
if [[ $? -ne 0 ]]; then
echo -e "${ERROR}Rollup build failed."
exit 1
fi

# Copy build outputs to the Python package directory
cp dist/bundle.js src/general/styles.css lightweight_charts_esistjosh/js
if [[ $? -eq 0 ]]; then
echo -e "${INFO}Copied bundle.js and styles.css into Python package."
Expand All @@ -78,10 +74,8 @@ perform_build() {
perform_package() {
echo -e "${INFO}Starting packaging and installation..."

# Define the path to the virtual environment's Python interpreter
VENV_PYTHON="/home/linux/lightweight-charts-python/venv/bin/python"

# Build source distribution and wheel
sudo "$VENV_PYTHON" -m build --sdist
if [[ $? -ne 0 ]]; then
echo -e "${ERROR}Failed to build source distribution."
Expand All @@ -94,7 +88,6 @@ perform_package() {
exit 1
fi

# Install the package
sudo "$VENV_PYTHON" -m pip install .
if [[ $? -ne 0 ]]; then
echo -e "${ERROR}Failed to install the package."
Expand All @@ -104,13 +97,11 @@ perform_package() {
echo -e "${GREEN}[PACKAGE & INSTALL SUCCESS]${NC}"
}

# Function to perform upload
perform_upload() {
echo -e "${INFO}Starting upload process..."

# Define output directory
OUTPUT_DIR="./output"

# Remove existing output directory if it exists
if [ -d "$OUTPUT_DIR" ]; then
echo -e "${INFO}Removing existing output directory..."
sudo rm -rf "$OUTPUT_DIR"
Expand All @@ -120,14 +111,12 @@ perform_upload() {
fi
fi

# Create output directory
mkdir -p "$OUTPUT_DIR"
if [[ $? -ne 0 ]]; then
echo -e "${ERROR}Failed to create output directory."
exit 1
fi

# Enable nullglob to handle cases where no files match the pattern
shopt -s nullglob
files=(./dist/*.tar.gz ./dist/*.whl)
shopt -u nullglob
Expand All @@ -137,14 +126,12 @@ perform_upload() {
return
fi

# Move distribution files to output directory
mv "${files[@]}" "$OUTPUT_DIR"/
if [[ $? -ne 0 ]]; then
echo -e "${ERROR}Failed to move distribution files to output directory."
exit 1
fi

# Upload distributions using twine
"$VENV_PYTHON" -m twine upload "$OUTPUT_DIR"/*
if [[ $? -ne 0 ]]; then
echo -e "${ERROR}Failed to upload distributions to PyPI."
Expand All @@ -154,19 +141,27 @@ perform_upload() {
echo -e "${GREEN}[UPLOAD SUCCESS]${NC}"
}



# Execute build if the BUILD flag is set
# Execute build if requested
if [ "$BUILD" = true ]; then
perform_build
fi

# Execute packaging if the PACKAGE flag is set
if [ "$PACKAGE" = true ]; then
perform_package
# If -p was given, package automatically; otherwise prompt
if [ "$PACKAGE" = true ]; then
perform_package
else
read -p "Do you want to package and install? (y/n): " answer
case "$answer" in
[Yy]* )
perform_package
;;
* )
echo -e "${INFO}Skipping packaging."
;;
esac
fi
fi

# Execute upload if the UPLOAD flag is set
# Execute upload only if -u was explicitly passed
if [ "$UPLOAD" = true ]; then
perform_upload
fi
4 changes: 2 additions & 2 deletions lightweight_charts_esistjosh/js/bundle.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lightweight_charts_esistjosh/toolbox.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import json

from .util import jbool

class ToolBox:
def __init__(self, chart):
def __init__(self, chart, toggle = True):
self.run_script = chart.run_script
self.id = chart.id
self._save_under = None
self.drawings = {}
chart.win.handlers[f'save_drawings{self.id}'] = self._save_drawings
self.run_script(f'{self.id}.createToolBox()')
self.run_script(f'{self.id}.createToolBox({jbool(toggle)})')

def save_drawings_under(self, widget: 'Widget'):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='lightweight_charts_esistjosh',
version='3.0.6',
version='3.0.7',
packages=find_packages(),
python_requires='>=3.8',
install_requires=[
Expand Down
2 changes: 1 addition & 1 deletion src/box/box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface BoxOptions extends DrawingOptions {
fillColor: string;
}

const defaultBoxOptions = {
export const defaultBoxOptions = {
fillEnabled: true,
fillColor: 'rgba(255, 255, 255, 0.2)',
...defaultOptions
Expand Down
2 changes: 1 addition & 1 deletion src/context-menu/data-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class DataMenu {
private handler: Handler;
private container: HTMLElement;
// Set the default active tab to "options" (primary).
private currentTab: "full" | "options" = "options";
private currentTab: "full" | "options" = "full";

constructor(options: DataMenuOptions) {
this.contextMenu = options.contextMenu;
Expand Down
1 change: 0 additions & 1 deletion src/drawing/two-point-drawing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Drawing } from './drawing';
import { TwoPointDrawingPaneView } from './pane-view';
import { PluginBase } from '../plugin-base';
import { ISeriesApiExtended } from '../helpers/series';
import { PluginRegistry } from '../helpers/general';
import { MouseEventParams } from 'lightweight-charts';


Expand Down
15 changes: 0 additions & 15 deletions src/example/example.ts

This file was deleted.

27 changes: 0 additions & 27 deletions src/example/index.html

This file was deleted.

5 changes: 2 additions & 3 deletions src/general/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -736,8 +736,8 @@ createSymbolSeries(
console.log(`✅ Series "${seriesName}" successfully removed.`);
}

createToolBox() {
this.toolBox = new ToolBox(this, this.chart, this.series, this.commandFunctions);
createToolBox(toggle: boolean = true) {
this.toolBox = new ToolBox(this, this.chart, this.series, this.commandFunctions, toggle);
this.div.appendChild(this.toolBox.div);
}

Expand All @@ -748,7 +748,6 @@ createSymbolSeries(
}



/**
* Extracts data from a series in a format suitable for indicators.
* @param series - The series to extract data from.
Expand Down
Loading