Release 0.7.13-alpha
This commit is contained in:
commit
42bdab988d
10
Changelog.md
10
Changelog.md
|
|
@ -1,7 +1,17 @@
|
||||||
|
# 0.7.13-alpha:
|
||||||
|
Changes:
|
||||||
|
- changed file MIME type from text/plain to application/lightningbeam to prevent editor woes on Linux
|
||||||
|
|
||||||
|
Bugfixes:
|
||||||
|
- Port several live fixes to version control
|
||||||
|
- Fix opening files on macOS
|
||||||
|
- Improve rendering speed by 10x or more when multiple layers are present
|
||||||
|
|
||||||
# 0.7.12-alpha:
|
# 0.7.12-alpha:
|
||||||
New features:
|
New features:
|
||||||
- Add "New Window" command
|
- Add "New Window" command
|
||||||
- Enable files to be opened with Lightningbeam
|
- Enable files to be opened with Lightningbeam
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
- Fix error when an object is deleted from a frame
|
- Fix error when an object is deleted from a frame
|
||||||
- Fix parent references being lost
|
- Fix parent references being lost
|
||||||
|
|
|
||||||
|
|
@ -126,17 +126,15 @@ fn handle_file_associations(app: AppHandle, files: Vec<PathBuf>) {
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
let pkg_name = env!("CARGO_PKG_NAME").to_string();
|
let pkg_name = env!("CARGO_PKG_NAME").to_string();
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
|
.manage(Mutex::new(AppState::default()))
|
||||||
.setup(|app| {
|
.setup(|app| {
|
||||||
{
|
|
||||||
app.manage(Mutex::new(AppState::default()));
|
|
||||||
}
|
|
||||||
#[cfg(any(windows, target_os = "linux"))] // Windows/Linux needs different handling from macOS
|
#[cfg(any(windows, target_os = "linux"))] // Windows/Linux needs different handling from macOS
|
||||||
{
|
{
|
||||||
let mut files = Vec::new();
|
let mut files = Vec::new();
|
||||||
|
|
||||||
// NOTICE: `args` may include URL protocol (`your-app-protocol://`)
|
// NOTICE: `args` may include URL protocol (`your-app-protocol://`)
|
||||||
// or arguments (`--`) if your app supports them.
|
// or arguments (`--`) if your app supports them.
|
||||||
// files may aslo be passed as `file://path/to/file`
|
// files may also be passed as `file://path/to/file`
|
||||||
for maybe_file in std::env::args().skip(1) {
|
for maybe_file in std::env::args().skip(1) {
|
||||||
// skip flags like -f or --flag
|
// skip flags like -f or --flag
|
||||||
if maybe_file.starts_with('-') {
|
if maybe_file.starts_with('-') {
|
||||||
|
|
@ -199,12 +197,21 @@ pub fn run() {
|
||||||
|app, event| {
|
|app, event| {
|
||||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||||
if let tauri::RunEvent::Opened { urls } = event {
|
if let tauri::RunEvent::Opened { urls } = event {
|
||||||
|
let app = app.clone();
|
||||||
let files = urls
|
let files = urls
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|url| url.to_file_path().ok())
|
.filter_map(|url| url.to_file_path().ok())
|
||||||
|
.map(|f| {
|
||||||
|
let file = f.to_string_lossy().replace('\\', "\\\\"); // escape backslash
|
||||||
|
format!("\"{file}\"",) // wrap in quotes for JS array
|
||||||
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
handle_file_associations(app.clone(), files);
|
tauri::async_runtime::spawn(async move {
|
||||||
|
for path in files {
|
||||||
|
create_window(app.clone(), Some(path)).await;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "Lightningbeam",
|
"productName": "Lightningbeam",
|
||||||
"version": "0.7.12-alpha",
|
"version": "0.7.13-alpha",
|
||||||
"identifier": "org.lightningbeam.core",
|
"identifier": "org.lightningbeam.core",
|
||||||
"build": {
|
"build": {
|
||||||
"frontendDist": "../src"
|
"frontendDist": "../src"
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
"ext": [
|
"ext": [
|
||||||
"beam"
|
"beam"
|
||||||
],
|
],
|
||||||
"mimeType": "text/plain"
|
"mimeType": "application/lightningbeam"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
37
src/icon.js
37
src/icon.js
|
|
@ -3,27 +3,42 @@ class Icon {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.svgContent = '';
|
this.svgContent = '';
|
||||||
this.svgLoaded = false;
|
this.svgLoaded = false;
|
||||||
this.load()
|
this.cacheCanvas = null; // Offscreen canvas for caching
|
||||||
|
this.cacheContext = null;
|
||||||
|
this.cacheColor = null;
|
||||||
|
this.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
async load() {
|
async load() {
|
||||||
return fetch(this.url)
|
try {
|
||||||
.then(response => response.text())
|
const response = await fetch(this.url);
|
||||||
.then(svgContent => {
|
this.svgContent = await response.text();
|
||||||
this.svgContent = svgContent;
|
|
||||||
this.svgLoaded = true;
|
this.svgLoaded = true;
|
||||||
})
|
} catch (error) {
|
||||||
.catch(error => {
|
|
||||||
console.error('Error loading SVG:', error);
|
console.error('Error loading SVG:', error);
|
||||||
this.svgLoaded = false;
|
this.svgLoaded = false;
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render(ctx, x, y, w, h, color) {
|
render(ctx, x, y, w, h, color) {
|
||||||
if (this.svgLoaded) {
|
if (!this.svgLoaded) return; // Do nothing if SVG is not loaded
|
||||||
ctx.fillStyle = color
|
|
||||||
ctx.drawSvg(this.svgContent, x, y, w, h)
|
if (!this.cacheCanvas || this.cacheCanvas.width !== w || this.cacheCanvas.height !== h || this.cacheColor !== color) {
|
||||||
|
// Create or update the offscreen canvas for caching
|
||||||
|
this.cacheCanvas = document.createElement('canvas');
|
||||||
|
this.cacheCanvas.width = w;
|
||||||
|
this.cacheCanvas.height = h;
|
||||||
|
this.cacheContext = this.cacheCanvas.getContext('2d');
|
||||||
|
|
||||||
|
// Draw the SVG onto the offscreen canvas
|
||||||
|
this.cacheContext.clearRect(0, 0, w, h); // Clear previous contents
|
||||||
|
this.cacheContext.fillStyle = color;
|
||||||
|
this.cacheColor = color
|
||||||
|
this.cacheContext.drawSvg(this.svgContent, 0, 0, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw the cached result onto the main canvas
|
||||||
|
ctx.drawImage(this.cacheCanvas, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
60
src/main.js
60
src/main.js
|
|
@ -93,7 +93,7 @@ function forwardConsole(fnName, dest) {
|
||||||
const stackLines = error.stack.split("\n");
|
const stackLines = error.stack.split("\n");
|
||||||
|
|
||||||
let message = args.join(" "); // Join all arguments into a single string
|
let message = args.join(" "); // Join all arguments into a single string
|
||||||
const location = stackLines[1].match(/([a-zA-Z0-9_-]+\.js:\d+)/);
|
const location = stackLines.length>1 ? stackLines[1].match(/([a-zA-Z0-9_-]+\.js:\d+)/) : stackLines.toString();
|
||||||
|
|
||||||
if (fnName === "error") {
|
if (fnName === "error") {
|
||||||
// Send the full stack trace for errors
|
// Send the full stack trace for errors
|
||||||
|
|
@ -350,7 +350,6 @@ let context = {
|
||||||
let config = {
|
let config = {
|
||||||
shortcuts: {
|
shortcuts: {
|
||||||
playAnimation: " ",
|
playAnimation: " ",
|
||||||
// undo: "<ctrl>+z"
|
|
||||||
undo: "<mod>z",
|
undo: "<mod>z",
|
||||||
redo: "<mod>Z",
|
redo: "<mod>Z",
|
||||||
new: "<mod>n",
|
new: "<mod>n",
|
||||||
|
|
@ -379,6 +378,7 @@ let config = {
|
||||||
recentFiles: [],
|
recentFiles: [],
|
||||||
scrollSpeed: 1,
|
scrollSpeed: 1,
|
||||||
debug: false,
|
debug: false,
|
||||||
|
reopenLastSession: false
|
||||||
};
|
};
|
||||||
|
|
||||||
function getShortcut(shortcut) {
|
function getShortcut(shortcut) {
|
||||||
|
|
@ -421,14 +421,9 @@ async function saveConfig() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addRecentFile(filePath) {
|
async function addRecentFile(filePath) {
|
||||||
if (!config.recentFiles.includes(filePath)) {
|
config.recentFiles = [filePath, ...config.recentFiles.filter(file => file !== filePath)].slice(0, 10);
|
||||||
config.recentFiles.unshift(filePath);
|
|
||||||
if (config.recentFiles.length > 10) {
|
|
||||||
config.recentFiles = config.recentFiles.slice(0, 10);
|
|
||||||
}
|
|
||||||
await saveConfig(config);
|
await saveConfig(config);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Pointers to all objects
|
// Pointers to all objects
|
||||||
let pointerList = {};
|
let pointerList = {};
|
||||||
|
|
@ -1327,6 +1322,7 @@ let actions = {
|
||||||
for (let frameObj of action.selectedFrames) {
|
for (let frameObj of action.selectedFrames) {
|
||||||
let layer = object.layers[frameObj.layer];
|
let layer = object.layers[frameObj.layer];
|
||||||
let frame = layer.frames[frameObj.frameNum];
|
let frame = layer.frames[frameObj.frameNum];
|
||||||
|
if (frameObj) {
|
||||||
frameBuffer.push({
|
frameBuffer.push({
|
||||||
frame: frame,
|
frame: frame,
|
||||||
frameNum: frameObj.frameNum,
|
frameNum: frameObj.frameNum,
|
||||||
|
|
@ -1334,6 +1330,7 @@ let actions = {
|
||||||
});
|
});
|
||||||
layer.deleteFrame(frame.idx, undefined, frameObj.replacementUuid);
|
layer.deleteFrame(frame.idx, undefined, frameObj.replacementUuid);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (let frameObj of frameBuffer) {
|
for (let frameObj of frameBuffer) {
|
||||||
const layer_idx = frameObj.layer + action.offset.layers;
|
const layer_idx = frameObj.layer + action.offset.layers;
|
||||||
let layer = object.layers[layer_idx];
|
let layer = object.layers[layer_idx];
|
||||||
|
|
@ -1448,6 +1445,7 @@ let actions = {
|
||||||
let serializableShapes = [];
|
let serializableShapes = [];
|
||||||
let serializableObjects = [];
|
let serializableObjects = [];
|
||||||
let bbox;
|
let bbox;
|
||||||
|
const frame = context.activeObject.currentFrame
|
||||||
for (let shape of context.shapeselection) {
|
for (let shape of context.shapeselection) {
|
||||||
serializableShapes.push(shape.idx);
|
serializableShapes.push(shape.idx);
|
||||||
if (bbox == undefined) {
|
if (bbox == undefined) {
|
||||||
|
|
@ -1457,6 +1455,7 @@ let actions = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (let object of context.selection) {
|
for (let object of context.selection) {
|
||||||
|
if (object.idx in frame.keys) {
|
||||||
serializableObjects.push(object.idx);
|
serializableObjects.push(object.idx);
|
||||||
// TODO: rotated bbox
|
// TODO: rotated bbox
|
||||||
if (bbox == undefined) {
|
if (bbox == undefined) {
|
||||||
|
|
@ -1465,6 +1464,7 @@ let actions = {
|
||||||
growBoundingBox(bbox, object.bbox());
|
growBoundingBox(bbox, object.bbox());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
context.shapeselection = [];
|
context.shapeselection = [];
|
||||||
context.selection = [];
|
context.selection = [];
|
||||||
let action = {
|
let action = {
|
||||||
|
|
@ -1472,7 +1472,7 @@ let actions = {
|
||||||
objects: serializableObjects,
|
objects: serializableObjects,
|
||||||
groupUuid: uuidv4(),
|
groupUuid: uuidv4(),
|
||||||
parent: context.activeObject.idx,
|
parent: context.activeObject.idx,
|
||||||
frame: context.activeObject.currentFrame.idx,
|
frame: frame.idx,
|
||||||
layer: context.activeObject.activeLayer.idx,
|
layer: context.activeObject.activeLayer.idx,
|
||||||
position: {
|
position: {
|
||||||
x: (bbox.x.min + bbox.x.max) / 2,
|
x: (bbox.x.min + bbox.x.max) / 2,
|
||||||
|
|
@ -2637,7 +2637,6 @@ class Layer extends Widget {
|
||||||
ctx.setTransform(transform)
|
ctx.setTransform(transform)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (this.activeShape) {
|
if (this.activeShape) {
|
||||||
this.activeShape.draw(cxt)
|
this.activeShape.draw(cxt)
|
||||||
}
|
}
|
||||||
|
|
@ -2648,6 +2647,7 @@ class Layer extends Widget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
bbox() {
|
bbox() {
|
||||||
let bbox = super.bbox()
|
let bbox = super.bbox()
|
||||||
const frameInfo = this.getFrameValue(this.frameNum);
|
const frameInfo = this.getFrameValue(this.frameNum);
|
||||||
|
|
@ -2965,10 +2965,11 @@ class BaseShape {
|
||||||
ctx.lineCap = "round";
|
ctx.lineCap = "round";
|
||||||
|
|
||||||
// Create a repeating pattern for indicating selected shapes
|
// Create a repeating pattern for indicating selected shapes
|
||||||
let patternCanvas = document.createElement('canvas');
|
if (!this.patternCanvas) {
|
||||||
patternCanvas.width = 2;
|
this.patternCanvas = document.createElement('canvas');
|
||||||
patternCanvas.height = 2;
|
this.patternCanvas.width = 2;
|
||||||
let patternCtx = patternCanvas.getContext('2d');
|
this.patternCanvas.height = 2;
|
||||||
|
let patternCtx = this.patternCanvas.getContext('2d');
|
||||||
// Draw the pattern:
|
// Draw the pattern:
|
||||||
// black, transparent,
|
// black, transparent,
|
||||||
// transparent, white
|
// transparent, white
|
||||||
|
|
@ -2978,7 +2979,8 @@ class BaseShape {
|
||||||
patternCtx.clearRect(0, 1, 1, 1);
|
patternCtx.clearRect(0, 1, 1, 1);
|
||||||
patternCtx.fillStyle = 'white';
|
patternCtx.fillStyle = 'white';
|
||||||
patternCtx.fillRect(1, 1, 1, 1);
|
patternCtx.fillRect(1, 1, 1, 1);
|
||||||
let pattern = ctx.createPattern(patternCanvas, 'repeat'); // repeat the pattern across the canvas
|
}
|
||||||
|
let pattern = ctx.createPattern(this.patternCanvas, 'repeat'); // repeat the pattern across the canvas
|
||||||
|
|
||||||
// for (let region of this.regions) {
|
// for (let region of this.regions) {
|
||||||
// // if (region.filled) continue;
|
// // if (region.filled) continue;
|
||||||
|
|
@ -4114,9 +4116,11 @@ class GraphicsObject extends Widget {
|
||||||
for (let layer of this.layers) {
|
for (let layer of this.layers) {
|
||||||
layer.children = layer.children.filter(child => child.idx !== idx);
|
layer.children = layer.children.filter(child => child.idx !== idx);
|
||||||
for (let frame of layer.frames) {
|
for (let frame of layer.frames) {
|
||||||
|
if (frame) {
|
||||||
delete frame[idx];
|
delete frame[idx];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// this.children.splice(this.children.indexOf(childObject), 1);
|
// this.children.splice(this.children.indexOf(childObject), 1);
|
||||||
}
|
}
|
||||||
addLayer(layer) {
|
addLayer(layer) {
|
||||||
|
|
@ -5069,6 +5073,19 @@ async function setupVideoExport(ext, path, canvas, exportContext) {
|
||||||
|
|
||||||
// audioEncoder.configure(audioConfig)
|
// audioEncoder.configure(audioConfig)
|
||||||
|
|
||||||
|
async function finishEncoding() {
|
||||||
|
const progressText = document.getElementById('progressText');
|
||||||
|
progressText.innerText = 'Finalizing...';
|
||||||
|
const progressBar = document.getElementById('progressBar');
|
||||||
|
progressBar.value = 100;
|
||||||
|
await videoEncoder.flush();
|
||||||
|
muxer.finalize();
|
||||||
|
await writeFile(path, new Uint8Array(target.buffer));
|
||||||
|
const modal = document.getElementById('progressModal');
|
||||||
|
modal.style.display = 'none';
|
||||||
|
document.querySelector("body").style.cursor = "default";
|
||||||
|
}
|
||||||
|
|
||||||
const processFrame = async (currentFrame) => {
|
const processFrame = async (currentFrame) => {
|
||||||
if (currentFrame < root.maxFrame) {
|
if (currentFrame < root.maxFrame) {
|
||||||
// Update progress bar
|
// Update progress bar
|
||||||
|
|
@ -5971,7 +5988,7 @@ function stage() {
|
||||||
for (let child of context.selection) {
|
for (let child of context.selection) {
|
||||||
if (!context.activeObject.currentFrame) continue;
|
if (!context.activeObject.currentFrame) continue;
|
||||||
if (!context.activeObject.currentFrame.keys) continue;
|
if (!context.activeObject.currentFrame.keys) continue;
|
||||||
if (!child.idx in context.activeObject.currentFrame.keys) continue;
|
if (!(child.idx in context.activeObject.currentFrame.keys)) continue;
|
||||||
context.activeObject.currentFrame.keys[child.idx].x +=
|
context.activeObject.currentFrame.keys[child.idx].x +=
|
||||||
mouse.x - context.lastMouse.x;
|
mouse.x - context.lastMouse.x;
|
||||||
context.activeObject.currentFrame.keys[child.idx].y +=
|
context.activeObject.currentFrame.keys[child.idx].y +=
|
||||||
|
|
@ -6729,10 +6746,14 @@ function outliner(object = undefined) {
|
||||||
async function startup() {
|
async function startup() {
|
||||||
await loadConfig();
|
await loadConfig();
|
||||||
createNewFileDialog(_newFile, _open, config);
|
createNewFileDialog(_newFile, _open, config);
|
||||||
if (!window.openedFiles) {
|
if (!window.openedFiles?.length) {
|
||||||
|
if (config.reopenLastSession && config.recentFiles?.length) {
|
||||||
|
_open(config.recentFiles[0])
|
||||||
|
} else {
|
||||||
showNewFileDialog(config);
|
showNewFileDialog(config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
startup();
|
startup();
|
||||||
|
|
||||||
|
|
@ -7896,6 +7917,11 @@ async function renderMenu() {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
action: () => {},
|
action: () => {},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
text: "Close Window",
|
||||||
|
enabled: true,
|
||||||
|
action: quit,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
text: "Quit Lightningbeam",
|
text: "Quit Lightningbeam",
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue