Modernize platform, structure, and UX
CI / build (push) Canceled after 0s

Phase 3:
- Declare PowerPointApi 1.5 and replace template manifest values
- Remove the dead command pipeline and the tracked Babel/polyfill setup
- Extract constants, status/settings contexts, PowerPoint services, and an error boundary
- Build with ES2020 and strict TypeScript; hash production assets and drop prod source maps
- Add Vitest tests, CI, LICENSE, Node 20 pinning, and prune unused dependencies
- Correct the README, user guide, developer guide, and audit notes

Phase 4:
- Add a persisted 16:9/4:3 slide size setting used by all layout tools
- Add dark mode with Office/system theme detection
- Make sections collapsible and move to accessible Fluent controls
- Announce status through aria-live and add semantic status icons
- Add a progress counter with cooperative cancellation and a Stop button
- Update the tracked dependency tree for the pruned packages
This commit is contained in:
schihei committed 2026-11-25 12:01:40 +01:00
1 parent e57258afe9
commit 89989c04e9
6211 files changed
+7028 -274819

No files matched your search

+95 -16
View File
@@ -14,8 +14,18 @@
// fact, when sorting with a comparator, these costs outweigh the benefits of
// sorting in C++. By using our own JS-implemented Quick Sort (below), we get
// a ~3500ms mean speed-up in `bench/bench.html`.
function SortTemplate(comparator) {
//
// That only pays off while the JIT can inline the comparator, i.e. while the
// comparator call site in the sort sees a single comparator. The library sorts
// with four different comparators, so each one gets its own copy of the sort
// function (`doQuickSort0` .. `doQuickSort3` below). The copies have to be
// separate function literals in the source: closures created from the same
// literal share type feedback, and so did copies cloned with `new Function`
// from identical source text. Cloning with `new Function` also violates
// Content Security Policies that don't allow 'unsafe-eval', so the copies are
// written out by hand. Keep them identical. See:
// https://github.com/7rulnik/source-map-js/pull/29
// https://github.com/7rulnik/source-map-js/issues/81
/**
* Swap the elements indexed by `x` and `y` in the array `ary`.
@@ -42,7 +52,7 @@ function swap(ary, x, y) {
* The upper bound on the range.
*/
function randomIntInRange(low, high) {
return Math.round(low + (Math.random() * (high - low)));
return Math.round(low + Math.random() * (high - low));
}
/**
@@ -57,7 +67,7 @@ function randomIntInRange(low, high) {
* @param {Number} r
* End index of the array
*/
function doQuickSort(ary, comparator, p, r) {
function doQuickSort0(ary, comparator, p, r) {
// If our lower bound is less than our upper bound, we (1) partition the
// array into two pieces and (2) recurse on each half. If it is not, this is
// the empty array and our base case.
@@ -98,20 +108,86 @@ function doQuickSort(ary, comparator, p, r) {
// (2) Recurse on each half.
doQuickSort(ary, comparator, p, q - 1);
doQuickSort(ary, comparator, q + 1, r);
doQuickSort0(ary, comparator, p, q - 1);
doQuickSort0(ary, comparator, q + 1, r);
}
}
return doQuickSort;
// Identical copies of `doQuickSort0`, see the comment at the top of the file.
function doQuickSort1(ary, comparator, p, r) {
if (p < r) {
var pivotIndex = randomIntInRange(p, r);
var i = p - 1;
swap(ary, pivotIndex, r);
var pivot = ary[r];
for (var j = p; j < r; j++) {
if (comparator(ary[j], pivot, false) <= 0) {
i += 1;
swap(ary, i, j);
}
}
swap(ary, i + 1, j);
var q = i + 1;
doQuickSort1(ary, comparator, p, q - 1);
doQuickSort1(ary, comparator, q + 1, r);
}
}
function cloneSort(comparator) {
let template = SortTemplate.toString();
let templateFn = new Function(`return ${template}`)();
return templateFn(comparator);
function doQuickSort2(ary, comparator, p, r) {
if (p < r) {
var pivotIndex = randomIntInRange(p, r);
var i = p - 1;
swap(ary, pivotIndex, r);
var pivot = ary[r];
for (var j = p; j < r; j++) {
if (comparator(ary[j], pivot, false) <= 0) {
i += 1;
swap(ary, i, j);
}
}
swap(ary, i + 1, j);
var q = i + 1;
doQuickSort2(ary, comparator, p, q - 1);
doQuickSort2(ary, comparator, q + 1, r);
}
}
function doQuickSort3(ary, comparator, p, r) {
if (p < r) {
var pivotIndex = randomIntInRange(p, r);
var i = p - 1;
swap(ary, pivotIndex, r);
var pivot = ary[r];
for (var j = p; j < r; j++) {
if (comparator(ary[j], pivot, false) <= 0) {
i += 1;
swap(ary, i, j);
}
}
swap(ary, i + 1, j);
var q = i + 1;
doQuickSort3(ary, comparator, p, q - 1);
doQuickSort3(ary, comparator, q + 1, r);
}
}
var sortCopies = [doQuickSort0, doQuickSort1, doQuickSort2, doQuickSort3];
var nextSortCopy = 0;
var sortCache = new WeakMap();
/**
* Sort the given array in-place with the given comparator function.
*
@@ -119,13 +195,16 @@ function cloneSort(comparator) {
* An array to sort.
* @param {function} comparator
* Function to use to compare two items.
* @param {Number} start
* Index to start sorting from; items before it are left untouched.
*/
let sortCache = new WeakMap();
exports.quickSort = function (ary, comparator, start = 0) {
let doQuickSort = sortCache.get(comparator);
if (doQuickSort === void 0) {
doQuickSort = cloneSort(comparator);
var doQuickSort = sortCache.get(comparator);
if (doQuickSort === undefined) {
// Each comparator claims the next free copy. Should there ever be more
// comparators than copies, the extra ones share the last copy: still
// correct, just slower for the comparators sharing it.
doQuickSort = sortCopies[Math.min(nextSortCopy++, sortCopies.length - 1)];
sortCache.set(comparator, doQuickSort);
}
doQuickSort(ary, comparator, start, ary.length - 1);