Infinite clones is now infinite

This commit is contained in:
Thomas Weber committed 2026-08-03 21:17:22 -05:00
1 parent 0867193f2e
commit 9a4854b238
3 files changed
+21 -12

No files matched your search

+1 -2
View File
@@ -19,8 +19,7 @@
<span class="badge">New!</span>
</p>
<p>
By default, Electron apps will no longer be throttled when minimized or hidden.
There is an option to restore the old behavior.
Infinite clones is now actually infinite instead of being limited to 9,999,999,999 (though you may encounter significant practical limitations long before reaching that limit).
</p>
</div>
</Section>
+15 -7
View File
@@ -1,5 +1,7 @@
<script>
import {onDestroy} from 'svelte';
// Standard JSON can't represent values such as Infinity, which some options use.
import * as ExtendedJSON from '@turbowarp/json';
import {_} from '../locales/';
import {slide, fade} from 'svelte/transition';
import Section from './Section.svelte';
@@ -26,9 +28,6 @@
export let projectData;
export let title;
// JSON can't easily parse Infinity, so we'll just store large numbers instead
const ALMOST_INFINITY = 9999999999;
const cloudVariables = projectData.project.analysis.stageVariables
.filter(i => i.isCloud)
.map(i => i.name);
@@ -49,6 +48,12 @@
return i;
});
// Infinite clones used to be stored as a big number instead of actual `Infinity`.
const ALMOST_INFINITY = 9999999999;
if ($options.maxClones === ALMOST_INFINITY) {
$options.maxClones = Infinity;
}
const hasMagicComment = (magic) => projectData.project.analysis.stageComments.find(
(text) => text.split('\n').find((line) => line.endsWith(magic))
);
@@ -221,7 +226,7 @@
const exportOptions = async () => {
const exported = await recursivelySerializeBlobs($options);
const blob = new Blob([JSON.stringify(exported)], {
const blob = new Blob([ExtendedJSON.stringify(exported)], {
type: 'application/json'
});
const url = URL.createObjectURL(blob);
@@ -253,10 +258,13 @@
}
try {
const text = await readAsText(file);
const parsed = JSON.parse(text);
const parsed = ExtendedJSON.parse(text);
const deserialized = recursivelyDeserializeBlobs(parsed);
const copiedDefaultOptions = deepClone(defaultOptions);
const mergedWithDefaults = merge(deserialized, copiedDefaultOptions);
if (mergedWithDefaults.maxClones === ALMOST_INFINITY) {
mergedWithDefaults.maxClones = Infinity;
}
const isUnsafe = Packager.usesUnsafeOptions(mergedWithDefaults);
if (!isUnsafe || confirm($_('options.confirmImportUnsafe'))) {
@@ -379,8 +387,8 @@
</div>
<div class="option">
<label>
<input type="checkbox" checked={$options.maxClones === ALMOST_INFINITY} on:change={(e) => {
$options.maxClones = e.target.checked ? ALMOST_INFINITY : 300;
<input type="checkbox" checked={$options.maxClones === Infinity} on:change={(e) => {
$options.maxClones = e.target.checked ? Infinity : 300;
}}>
{$_('options.infiniteClones')}
</label>
+5 -3
View File
@@ -1,10 +1,12 @@
import {writable} from 'svelte/store';
// Standard JSON can't represent values such as Infinity, which some options use.
import * as ExtendedJSON from '@turbowarp/json';
import merge from './merge';
import serialize from './serialize';
const writablePersistentStore = (key, defaultValue) => {
let value = JSON.parse(JSON.stringify(defaultValue));
const localValue = JSON.parse(localStorage.getItem(key));
let value = ExtendedJSON.parse(ExtendedJSON.stringify(defaultValue));
const localValue = ExtendedJSON.parse(localStorage.getItem(key));
if (localValue) {
value = merge(localValue, value);
}
@@ -14,7 +16,7 @@ const writablePersistentStore = (key, defaultValue) => {
if (serialized === null) {
localStorage.removeItem(key);
} else {
localStorage.setItem(key, JSON.stringify(serialized));
localStorage.setItem(key, ExtendedJSON.stringify(serialized));
}
});
return unsubscribe;