website: small fixes

This commit is contained in:
k
2024-11-25 11:28:28 +01:00
parent c8510dd45b
commit 4e9c5612ca
61 changed files with 111 additions and 1461 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

View File

@@ -1,44 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="icon" type="image/png" sizes="196x196" href="/assets/pwa/2024-09-17_09-06-03/favicon-196.png">
<link rel="apple-touch-icon" href="/assets/pwa/2024-09-17_09-06-03/apple-icon-180.png">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-2048-2732.jpg" media="(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-2732-2048.jpg" media="(device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-1668-2388.jpg" media="(device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-2388-1668.jpg" media="(device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-1536-2048.jpg" media="(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-2048-1536.jpg" media="(device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-1488-2266.jpg" media="(device-width: 744px) and (device-height: 1133px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-2266-1488.jpg" media="(device-width: 744px) and (device-height: 1133px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-1640-2360.jpg" media="(device-width: 820px) and (device-height: 1180px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-2360-1640.jpg" media="(device-width: 820px) and (device-height: 1180px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-1668-2224.jpg" media="(device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-2224-1668.jpg" media="(device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-1620-2160.jpg" media="(device-width: 810px) and (device-height: 1080px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-2160-1620.jpg" media="(device-width: 810px) and (device-height: 1080px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-1290-2796.jpg" media="(device-width: 430px) and (device-height: 932px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-2796-1290.jpg" media="(device-width: 430px) and (device-height: 932px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-1179-2556.jpg" media="(device-width: 393px) and (device-height: 852px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-2556-1179.jpg" media="(device-width: 393px) and (device-height: 852px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-1284-2778.jpg" media="(device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-2778-1284.jpg" media="(device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-1170-2532.jpg" media="(device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-2532-1170.jpg" media="(device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-1125-2436.jpg" media="(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-2436-1125.jpg" media="(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-1242-2688.jpg" media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-2688-1242.jpg" media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-828-1792.jpg" media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-1792-828.jpg" media="(device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-1242-2208.jpg" media="(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-2208-1242.jpg" media="(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-750-1334.jpg" media="(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-1334-750.jpg" media="(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-640-1136.jpg" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)">
<link rel="apple-touch-startup-image" href="/assets/pwa/2024-09-17_09-06-03/apple-splash-1136-640.jpg" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)">
</head>
<body>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -954,9 +954,9 @@
flex-direction: column;
flex: 1;
min-height: 0;
z-index: 20;
> .chart-wrapper {
z-index: 20;
position: relative;
min-height: 0px;
width: 100%;
@@ -1529,24 +1529,7 @@
</main>
<aside id="aside">
<section id="selected-frame">
<div id="charts" hidden>
<div class="shadow-left"></div>
<div class="shadow-right"></div>
<!-- TODO: Use utils.dom.createHeader; instead -->
<header id="selected-header" hidden>
<div>
<h1 style="display: flex; flex-direction: column">
<span id="selected-title" style="display: block"></span>
<small id="selected-description"></small>
</h1>
</div>
</header>
<fieldset id="legend"></fieldset>
<div id="charts-chart-list" class="chart-list">
<div class="shadow-top"></div>
<div class="shadow-bottom"></div>
</div>
</div>
<div id="charts" hidden></div>
<div id="simulation" hidden></div>
<div id="live-price" hidden></div>
<div id="moscow-time" hidden></div>

View File

@@ -1,908 +0,0 @@
// src/core/error.ts
var NotReadyError = class extends Error {
};
var NoOwnerError = class extends Error {
constructor() {
super(
""
);
}
};
var ContextNotFoundError = class extends Error {
constructor() {
super(
""
);
}
};
// src/utils.ts
function isUndefined(value) {
return typeof value === "undefined";
}
// src/core/constants.ts
var STATE_CLEAN = 0;
var STATE_CHECK = 1;
var STATE_DIRTY = 2;
var STATE_DISPOSED = 3;
// src/core/owner.ts
var currentOwner = null;
var defaultContext = {};
function getOwner() {
return currentOwner;
}
function setOwner(owner) {
const out = currentOwner;
currentOwner = owner;
return out;
}
var Owner = class {
// We flatten the owner tree into a linked list so that we don't need a pointer to .firstChild
// However, the children are actually added in reverse creation order
// See comment at the top of the file for an example of the _nextSibling traversal
p = null;
i = null;
m = null;
a = STATE_CLEAN;
f = null;
j = defaultContext;
g = null;
constructor(signal = false) {
if (currentOwner && !signal)
currentOwner.append(this);
}
append(child) {
child.p = this;
child.m = this;
if (this.i)
this.i.m = child;
child.i = this.i;
this.i = child;
if (child.j !== this.j) {
child.j = { ...this.j, ...child.j };
}
if (this.g) {
child.g = !child.g ? this.g : [...child.g, ...this.g];
}
}
dispose(self = true) {
if (this.a === STATE_DISPOSED)
return;
let head = self ? this.m || this.p : this, current = this.i, next = null;
while (current && current.p === this) {
current.dispose(true);
current.t();
next = current.i;
current.i = null;
current = next;
}
if (self)
this.t();
if (current)
current.m = !self ? this : this.m;
if (head)
head.i = current;
}
t() {
if (this.m)
this.m.i = null;
this.p = null;
this.m = null;
this.j = defaultContext;
this.g = null;
this.a = STATE_DISPOSED;
this.emptyDisposal();
}
emptyDisposal() {
if (!this.f)
return;
if (Array.isArray(this.f)) {
for (let i = 0; i < this.f.length; i++) {
const callable = this.f[i];
callable.call(callable);
}
} else {
this.f.call(this.f);
}
this.f = null;
}
handleError(error) {
if (!this.g)
throw error;
let i = 0, len = this.g.length;
for (i = 0; i < len; i++) {
try {
this.g[i](error);
break;
} catch (e) {
error = e;
}
}
if (i === len)
throw error;
}
};
function createContext(defaultValue, description) {
return { id: Symbol(description), defaultValue };
}
function getContext(context, owner = currentOwner) {
if (!owner) {
throw new NoOwnerError();
}
const value = hasContext(context, owner) ? owner.j[context.id] : context.defaultValue;
if (isUndefined(value)) {
throw new ContextNotFoundError();
}
return value;
}
function setContext(context, value, owner = currentOwner) {
if (!owner) {
throw new NoOwnerError();
}
owner.j = {
...owner.j,
[context.id]: isUndefined(value) ? context.defaultValue : value
};
}
function hasContext(context, owner = currentOwner) {
return !isUndefined(owner?.j[context.id]);
}
function onCleanup(disposable) {
if (!currentOwner)
return;
const node = currentOwner;
if (!node.f) {
node.f = disposable;
} else if (Array.isArray(node.f)) {
node.f.push(disposable);
} else {
node.f = [node.f, disposable];
}
}
// src/core/flags.ts
var ERROR_OFFSET = 0;
var ERROR_BIT = 1 << ERROR_OFFSET;
var LOADING_OFFSET = 1;
var LOADING_BIT = 1 << LOADING_OFFSET;
var DEFAULT_FLAGS = ERROR_BIT;
// src/core/scheduler.ts
var scheduled = false;
var runningScheduled = false;
var Computations = [];
var RenderEffects = [];
var Effects = [];
function flushSync() {
if (!runningScheduled)
runScheduled();
}
function flushQueue() {
if (scheduled)
return;
scheduled = true;
queueMicrotask(runScheduled);
}
function runTop(node) {
const ancestors = [];
for (let current = node; current !== null; current = current.p) {
if (current.a !== STATE_CLEAN) {
ancestors.push(current);
}
}
for (let i = ancestors.length - 1; i >= 0; i--) {
if (ancestors[i].a !== STATE_DISPOSED)
ancestors[i].q();
}
}
function runScheduled() {
if (!Effects.length && !RenderEffects.length && !Computations.length) {
scheduled = false;
return;
}
runningScheduled = true;
try {
runPureQueue(Computations);
runPureQueue(RenderEffects);
runPureQueue(Effects);
} finally {
const renderEffects = RenderEffects;
const effects = Effects;
Computations = [];
Effects = [];
RenderEffects = [];
scheduled = false;
runningScheduled = false;
incrementClock();
runEffectQueue(renderEffects);
runEffectQueue(effects);
}
}
function runPureQueue(queue) {
for (let i = 0; i < queue.length; i++) {
if (queue[i].a !== STATE_CLEAN)
runTop(queue[i]);
}
}
function runEffectQueue(queue) {
for (let i = 0; i < queue.length; i++) {
if (queue[i].x && queue[i].a !== STATE_DISPOSED) {
queue[i].y(queue[i].d, queue[i].v);
queue[i].x = false;
queue[i].v = queue[i].d;
}
}
}
// src/core/core.ts
var currentObserver = null;
var currentMask = DEFAULT_FLAGS;
var newSources = null;
var newSourcesIndex = 0;
var newFlags = 0;
var clock = 0;
var syncResolve = false;
var updateCheck = null;
function getObserver() {
return currentObserver;
}
function incrementClock() {
clock++;
}
var UNCHANGED = Symbol(0);
var Computation2 = class extends Owner {
b = null;
c = null;
d;
z;
// Used in __DEV__ mode, hopefully removed in production
L;
// Using false is an optimization as an alternative to _equals: () => false
// which could enable more efficient DIRTY notification
A = isEqual;
F;
/** Whether the computation is an error or has ancestors that are unresolved */
k = 0;
/** Which flags raised by sources are handled, vs. being passed through. */
w = DEFAULT_FLAGS;
B = null;
C = null;
D = -1;
constructor(initialValue, compute2, options) {
super(compute2 === null);
this.z = compute2;
this.a = compute2 ? STATE_DIRTY : STATE_CLEAN;
this.d = initialValue;
if (options?.equals !== void 0)
this.A = options.equals;
if (options?.unobserved)
this.F = options?.unobserved;
}
G() {
if (this.z)
this.q();
if (!this.b || this.b.length)
track(this);
newFlags |= this.k & ~currentMask;
if (this.k & ERROR_BIT) {
throw this.d;
} else {
return this.d;
}
}
/**
* Return the current value of this computation
* Automatically re-executes the surrounding computation when the value changes
*/
read() {
return this.G();
}
/**
* Return the current value of this computation
* Automatically re-executes the surrounding computation when the value changes
*
* If the computation has any unresolved ancestors, this function waits for the value to resolve
* before continuing
*/
wait() {
if (!syncResolve && this.loading()) {
throw new NotReadyError();
}
return this.G();
}
/**
* Return true if the computation is the value is dependent on an unresolved promise
* Triggers re-execution of the computation when the loading state changes
*
* This is useful especially when effects want to re-execute when a computation's
* loading state changes
*/
loading() {
if (this.C === null) {
this.C = loadingState(this);
}
return this.C.read();
}
/**
* Return true if the computation is the computation threw an error
* Triggers re-execution of the computation when the error state changes
*/
error() {
if (this.B === null) {
this.B = errorState(this);
}
return this.B.read();
}
/** Update the computation with a new value. */
write(value, flags = 0, raw = false) {
const newValue = !raw && typeof value === "function" ? value(this.d) : value;
const valueChanged = newValue !== UNCHANGED && (!!(flags & ERROR_BIT) || this.A === false || !this.A(this.d, newValue));
if (valueChanged)
this.d = newValue;
const changedFlagsMask = this.k ^ flags, changedFlags = changedFlagsMask & flags;
this.k = flags;
this.D = clock + 1;
if (this.c) {
for (let i = 0; i < this.c.length; i++) {
if (valueChanged) {
this.c[i].n(STATE_DIRTY);
} else if (changedFlagsMask) {
this.c[i].H(changedFlagsMask, changedFlags);
}
}
}
return this.d;
}
/**
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
*/
n(state) {
if (this.a >= state)
return;
this.a = state;
if (this.c) {
for (let i = 0; i < this.c.length; i++) {
this.c[i].n(STATE_CHECK);
}
}
}
/**
* Notify the computation that one of its sources has changed flags.
*
* @param mask A bitmask for which flag(s) were changed.
* @param newFlags The source's new flags, masked to just the changed ones.
*/
H(mask, newFlags2) {
if (this.a >= STATE_DIRTY)
return;
if (mask & this.w) {
this.n(STATE_DIRTY);
return;
}
if (this.a >= STATE_CHECK)
return;
const prevFlags = this.k & mask;
const deltaFlags = prevFlags ^ newFlags2;
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
this.n(STATE_CHECK);
} else {
this.k ^= deltaFlags;
if (this.c) {
for (let i = 0; i < this.c.length; i++) {
this.c[i].H(mask, newFlags2);
}
}
}
}
I(error) {
this.write(error, this.k | ERROR_BIT);
}
/**
* This is the core part of the reactivity system, which makes sure that the values are updated
* before they are read. We've also adapted it to return the loading state of the computation,
* so that we can propagate that to the computation's observers.
*
* This function will ensure that the value and states we read from the computation are up to date
*/
q() {
if (this.a === STATE_DISPOSED) {
throw new Error("Tried to read a disposed computation");
}
if (this.a === STATE_CLEAN) {
return;
}
let observerFlags = 0;
if (this.a === STATE_CHECK) {
for (let i = 0; i < this.b.length; i++) {
this.b[i].q();
observerFlags |= this.b[i].k;
if (this.a === STATE_DIRTY) {
break;
}
}
}
if (this.a === STATE_DIRTY) {
update(this);
} else {
this.write(UNCHANGED, observerFlags);
this.a = STATE_CLEAN;
}
}
/**
* Remove ourselves from the owner graph and the computation graph
*/
t() {
if (this.a === STATE_DISPOSED)
return;
if (this.b)
removeSourceObservers(this, 0);
super.t();
}
};
function loadingState(node) {
const prevOwner = setOwner(node.p);
const options = void 0;
const computation = new Computation2(
void 0,
() => {
track(node);
node.q();
return !!(node.k & LOADING_BIT);
},
options
);
computation.w = ERROR_BIT | LOADING_BIT;
setOwner(prevOwner);
return computation;
}
function errorState(node) {
const prevOwner = setOwner(node.p);
const options = void 0;
const computation = new Computation2(
void 0,
() => {
track(node);
node.q();
return !!(node.k & ERROR_BIT);
},
options
);
computation.w = ERROR_BIT;
setOwner(prevOwner);
return computation;
}
function track(computation) {
if (currentObserver) {
if (!newSources && currentObserver.b && currentObserver.b[newSourcesIndex] === computation) {
newSourcesIndex++;
} else if (!newSources)
newSources = [computation];
else if (computation !== newSources[newSources.length - 1]) {
newSources.push(computation);
}
if (updateCheck) {
updateCheck.d = computation.D > currentObserver.D;
}
}
}
function update(node) {
const prevSources = newSources, prevSourcesIndex = newSourcesIndex, prevFlags = newFlags;
newSources = null;
newSourcesIndex = 0;
newFlags = 0;
try {
node.dispose(false);
node.emptyDisposal();
const result = compute(node, node.z, node);
node.write(result, newFlags, true);
} catch (error) {
if (error instanceof NotReadyError) {
node.write(UNCHANGED, newFlags | LOADING_BIT);
} else {
node.I(error);
}
} finally {
if (newSources) {
if (node.b)
removeSourceObservers(node, newSourcesIndex);
if (node.b && newSourcesIndex > 0) {
node.b.length = newSourcesIndex + newSources.length;
for (let i = 0; i < newSources.length; i++) {
node.b[newSourcesIndex + i] = newSources[i];
}
} else {
node.b = newSources;
}
let source;
for (let i = newSourcesIndex; i < node.b.length; i++) {
source = node.b[i];
if (!source.c)
source.c = [node];
else
source.c.push(node);
}
} else if (node.b && newSourcesIndex < node.b.length) {
removeSourceObservers(node, newSourcesIndex);
node.b.length = newSourcesIndex;
}
newSources = prevSources;
newSourcesIndex = prevSourcesIndex;
newFlags = prevFlags;
node.a = STATE_CLEAN;
}
}
function removeSourceObservers(node, index) {
let source;
let swap;
for (let i = index; i < node.b.length; i++) {
source = node.b[i];
if (source.c) {
swap = source.c.indexOf(node);
source.c[swap] = source.c[source.c.length - 1];
source.c.pop();
if (!source.c.length)
source.F?.();
}
}
}
function isEqual(a, b) {
return a === b;
}
function untrack(fn) {
if (currentObserver === null)
return fn();
return compute(getOwner(), fn, null);
}
function hasUpdated(fn) {
const current = updateCheck;
updateCheck = { d: false };
try {
fn();
return updateCheck.d;
} finally {
updateCheck = current;
}
}
function isPending(fn) {
try {
fn();
return false;
} catch (e) {
return e instanceof NotReadyError;
}
}
function latest(fn) {
const prevFlags = newFlags;
syncResolve = true;
try {
return fn();
} catch {
} finally {
newFlags = prevFlags;
syncResolve = false;
}
}
function compute(owner, compute2, observer) {
const prevOwner = setOwner(owner), prevObserver = currentObserver, prevMask = currentMask;
currentObserver = observer;
currentMask = observer?.w ?? DEFAULT_FLAGS;
try {
return compute2(observer ? observer.d : void 0);
} finally {
setOwner(prevOwner);
currentObserver = prevObserver;
currentMask = prevMask;
}
}
var EagerComputation = class extends Computation2 {
constructor(initialValue, compute2, options) {
super(initialValue, compute2, options);
this.q();
Computations.push(this);
}
n(state) {
if (this.a >= state)
return;
if (this.a === STATE_CLEAN) {
Computations.push(this);
flushQueue();
}
super.n(state);
}
};
// src/core/effect.ts
var BaseEffect = class extends Computation2 {
y;
x = false;
v;
constructor(initialValue, compute2, effect, options) {
super(initialValue, compute2, options);
this.y = effect;
this.v = initialValue;
}
write(value) {
if (value === UNCHANGED)
return this.d;
this.d = value;
this.x = true;
return value;
}
I(error) {
this.handleError(error);
}
t() {
this.y = void 0;
this.v = void 0;
super.t();
}
};
var Effect = class extends BaseEffect {
constructor(initialValue, compute2, effect, options) {
super(initialValue, compute2, effect, options);
Effects.push(this);
flushQueue();
}
n(state) {
if (this.a >= state)
return;
if (this.a === STATE_CLEAN) {
Effects.push(this);
flushQueue();
}
this.a = state;
}
};
var RenderEffect = class extends BaseEffect {
constructor(initialValue, compute2, effect, options) {
super(initialValue, compute2, effect, options);
this.q();
RenderEffects.push(this);
}
n(state) {
if (this.a >= state)
return;
if (this.a === STATE_CLEAN) {
RenderEffects.push(this);
flushQueue();
}
this.a = state;
}
};
// src/signals.ts
function createSignal(first, second, third) {
if (typeof first === "function") {
const memo = createMemo((p) => {
const node2 = new Computation2(
first(p ? untrack(p[0]) : second),
null,
third
);
return [node2.read.bind(node2), node2.write.bind(node2)];
});
return [() => memo()[0](), (value) => memo()[1](value)];
}
const node = new Computation2(first, null, second);
return [node.read.bind(node), node.write.bind(node)];
}
function createAsync(fn, initial, options) {
const lhs = new EagerComputation(
{
d: initial
},
(p) => {
const value = p?.d;
const source = fn(value);
const isPromise = source instanceof Promise;
const iterator = source[Symbol.asyncIterator];
if (!isPromise && !iterator) {
return {
wait() {
return source;
},
d: source
};
}
const signal = new Computation2(value, null, options);
signal.write(UNCHANGED, LOADING_BIT);
if (isPromise) {
source.then(
(value2) => {
signal.write(value2, 0);
},
(error) => {
signal.write(error, ERROR_BIT);
}
);
} else {
let abort = false;
onCleanup(() => abort = true);
(async () => {
try {
for await (let value2 of source) {
if (abort)
return;
signal.write(value2, 0);
}
} catch (error) {
signal.write(error, ERROR_BIT);
}
})();
}
return signal;
}
);
return () => lhs.wait().wait();
}
function createMemo(compute2, initialValue, options) {
let node = new Computation2(initialValue, compute2, options);
let value;
return () => {
if (node) {
value = node.wait();
if (!node.b?.length)
node = void 0;
}
return value;
};
}
function createEffect(compute2, effect, initialValue, options) {
void new Effect(
initialValue,
compute2,
effect,
void 0
);
}
function createRenderEffect(compute2, effect, initialValue, options) {
void new RenderEffect(
initialValue,
compute2,
effect,
void 0
);
}
function createRoot(init) {
const owner = new Owner();
return compute(owner, !init.length ? init : () => init(() => owner.dispose()), null);
}
function runWithOwner(owner, run) {
try {
return compute(owner, run, null);
} catch (error) {
owner?.handleError(error);
return void 0;
}
}
function catchError(fn, handler) {
const owner = new Owner();
owner.g = owner.g ? [handler, ...owner.g] : [handler];
try {
compute(owner, fn, null);
} catch (error) {
owner.handleError(error);
}
}
// src/map.ts
function mapArray(list, map, options) {
const keyFn = typeof options?.keyed === "function" ? options.keyed : void 0;
return Computation2.prototype.read.bind(
new Computation2(
[],
updateKeyedMap.bind({
J: new Owner(),
r: 0,
K: list,
o: [],
E: map,
l: [],
s: [],
u: keyFn,
e: keyFn || options?.keyed === false ? [] : void 0,
h: map.length > 1 ? [] : void 0
}),
options
)
);
}
function updateKeyedMap() {
const newItems = this.K() || [];
runWithOwner(this.J, () => {
let newLen = newItems.length, i, j, mapper = this.e ? () => {
this.e[j] = new Computation2(newItems[j], null);
this.h[j] = new Computation2(j, null);
return this.E(
Computation2.prototype.read.bind(this.e[j]),
Computation2.prototype.read.bind(this.h[j])
);
} : this.h ? () => {
const item = newItems[j];
this.h[j] = new Computation2(j, null);
return this.E(() => item, Computation2.prototype.read.bind(this.h[j]));
} : () => {
const item = newItems[j];
return this.E(() => item);
};
if (newLen === 0) {
if (this.r !== 0) {
this.J.dispose(false);
this.s = [];
this.o = [];
this.l = [];
this.r = 0;
this.e && (this.e = []);
this.h && (this.h = []);
}
} else if (this.r === 0) {
this.l = new Array(newLen);
for (j = 0; j < newLen; j++) {
this.o[j] = newItems[j];
this.l[j] = compute(this.s[j] = new Owner(), mapper, null);
}
this.r = newLen;
} else {
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.e ? new Array(newLen) : void 0, tempIndexes = this.h ? new Array(newLen) : void 0;
for (start = 0, end = Math.min(this.r, newLen); start < end && (this.o[start] === newItems[start] || this.e && compare(this.u, this.o[start], newItems[start])); start++) {
if (this.e)
this.e[start].write(newItems[start]);
}
for (end = this.r - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.o[end] === newItems[newEnd] || this.e && compare(this.u, this.o[end], newItems[newEnd])); end--, newEnd--) {
temp[newEnd] = this.l[end];
tempNodes[newEnd] = this.s[end];
tempRows && (tempRows[newEnd] = this.e[end]);
tempIndexes && (tempIndexes[newEnd] = this.h[end]);
}
newIndices = /* @__PURE__ */ new Map();
newIndicesNext = new Array(newEnd + 1);
for (j = newEnd; j >= start; j--) {
item = newItems[j];
key = this.u ? this.u(item) : item;
i = newIndices.get(key);
newIndicesNext[j] = i === void 0 ? -1 : i;
newIndices.set(key, j);
}
for (i = start; i <= end; i++) {
item = this.o[i];
key = this.u ? this.u(item) : item;
j = newIndices.get(key);
if (j !== void 0 && j !== -1) {
temp[j] = this.l[i];
tempNodes[j] = this.s[i];
tempRows && (tempRows[j] = this.e[i]);
tempIndexes && (tempIndexes[j] = this.h[i]);
j = newIndicesNext[j];
newIndices.set(key, j);
} else
this.s[i].dispose();
}
for (j = start; j < newLen; j++) {
if (j in temp) {
this.l[j] = temp[j];
this.s[j] = tempNodes[j];
if (tempRows) {
this.e[j] = tempRows[j];
this.e[j].write(newItems[j]);
}
if (tempIndexes) {
this.h[j] = tempIndexes[j];
this.h[j].write(j);
}
} else {
this.l[j] = compute(this.s[j] = new Owner(), mapper, null);
}
}
this.l = this.l.slice(0, this.r = newLen);
this.o = newItems.slice(0);
}
});
return this.l;
}
function compare(key, a, b) {
return key ? key(a) === key(b) : true;
}
export { Computation2 as Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, catchError, createAsync, createContext, createEffect, createMemo, createRenderEffect, createRoot, createSignal, flushSync, getContext, getObserver, getOwner, hasContext, hasUpdated, isEqual, isPending, latest, mapArray, onCleanup, runWithOwner, setContext, untrack };

View File

@@ -1,10 +0,0 @@
/**
* See https://dev.to/modderme123/super-charging-fine-grained-reactive-performance-47ph
* State clean corresponds to a node where all the sources are fully up to date
* State check corresponds to a node where some sources (including grandparents) may have changed
* State dirty corresponds to a node where the direct parents of a node has changed
*/
export declare const STATE_CLEAN = 0;
export declare const STATE_CHECK = 1;
export declare const STATE_DIRTY = 2;
export declare const STATE_DISPOSED = 3;

View File

@@ -1,161 +0,0 @@
/**
* Nodes for constructing a graph of reactive values and reactive computations.
*
* - The graph is acyclic.
* - The user inputs new values into the graph by calling .write() on one more computation nodes.
* - The user retrieves computed results from the graph by calling .read() on one or more computation nodes.
* - The library is responsible for running any necessary computations so that .read() is up to date
* with all prior .write() calls anywhere in the graph.
* - We call the input nodes 'roots' and the output nodes 'leaves' of the graph here.
* - Changes flow from roots to leaves. It would be effective but inefficient to immediately
* propagate all changes from a root through the graph to descendant leaves. Instead, we defer
* change most change propagation computation until a leaf is accessed. This allows us to
* coalesce computations and skip altogether recalculating unused sections of the graph.
* - Each computation node tracks its sources and its observers (observers are other
* elements that have this node as a source). Source and observer links are updated automatically
* as observer computations re-evaluate and call get() on their sources.
* - Each node stores a cache state (clean/check/dirty) to support the change propagation algorithm:
*
* In general, execution proceeds in three passes:
*
* 1. write() propagates changes down the graph to the leaves
* direct children are marked as dirty and their deeper descendants marked as check
* (no computations are evaluated)
* 2. read() requests that parent nodes updateIfNecessary(), which proceeds recursively up the tree
* to decide whether the node is clean (parents unchanged) or dirty (parents changed)
* 3. updateIfNecessary() evaluates the computation if the node is dirty (the computations are
* executed in root to leaf order)
*/
import { type Flags } from "./flags.js";
import { Owner } from "./owner.js";
export interface SignalOptions<T> {
name?: string;
equals?: ((prev: T, next: T) => boolean) | false;
unobserved?: () => void;
}
interface SourceType {
_observers: ObserverType[] | null;
_unobserved?: () => void;
_updateIfNecessary: () => void;
_stateFlags: Flags;
_time: number;
}
interface ObserverType {
_sources: SourceType[] | null;
_notify: (state: number) => void;
_handlerMask: Flags;
_notifyFlags: (mask: Flags, newFlags: Flags) => void;
_time: number;
}
/**
* Returns the current observer.
*/
export declare function getObserver(): ObserverType | null;
export declare function incrementClock(): void;
export declare const UNCHANGED: unique symbol;
export type UNCHANGED = typeof UNCHANGED;
export declare class Computation<T = any> extends Owner implements SourceType, ObserverType {
_sources: SourceType[] | null;
_observers: ObserverType[] | null;
_value: T | undefined;
_compute: null | ((p?: T) => T);
_name: string | undefined;
_equals: false | ((a: T, b: T) => boolean);
_unobserved: (() => void) | undefined;
/** Whether the computation is an error or has ancestors that are unresolved */
_stateFlags: number;
/** Which flags raised by sources are handled, vs. being passed through. */
_handlerMask: number;
_error: Computation<boolean> | null;
_loading: Computation<boolean> | null;
_time: number;
constructor(initialValue: T | undefined, compute: null | ((p?: T) => T), options?: SignalOptions<T>);
_read(): T;
/**
* Return the current value of this computation
* Automatically re-executes the surrounding computation when the value changes
*/
read(): T;
/**
* Return the current value of this computation
* Automatically re-executes the surrounding computation when the value changes
*
* If the computation has any unresolved ancestors, this function waits for the value to resolve
* before continuing
*/
wait(): T;
/**
* Return true if the computation is the value is dependent on an unresolved promise
* Triggers re-execution of the computation when the loading state changes
*
* This is useful especially when effects want to re-execute when a computation's
* loading state changes
*/
loading(): boolean;
/**
* Return true if the computation is the computation threw an error
* Triggers re-execution of the computation when the error state changes
*/
error(): boolean;
/** Update the computation with a new value. */
write(value: T | ((currentValue: T) => T) | UNCHANGED, flags?: number, raw?: boolean): T;
/**
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
*/
_notify(state: number): void;
/**
* Notify the computation that one of its sources has changed flags.
*
* @param mask A bitmask for which flag(s) were changed.
* @param newFlags The source's new flags, masked to just the changed ones.
*/
_notifyFlags(mask: Flags, newFlags: Flags): void;
_setError(error: unknown): void;
/**
* This is the core part of the reactivity system, which makes sure that the values are updated
* before they are read. We've also adapted it to return the loading state of the computation,
* so that we can propagate that to the computation's observers.
*
* This function will ensure that the value and states we read from the computation are up to date
*/
_updateIfNecessary(): void;
/**
* Remove ourselves from the owner graph and the computation graph
*/
_disposeNode(): void;
}
/**
* Reruns a computation's _compute function, producing a new value and keeping track of dependencies.
*
* It handles the updating of sources and observers, disposal of previous executions,
* and error handling if the _compute function throws. It also sets the node as loading
* if it reads any parents that are currently loading.
*/
export declare function update<T>(node: Computation<T>): void;
export declare function isEqual<T>(a: T, b: T): boolean;
/**
* Returns the current value stored inside the given compute function without triggering any
* dependencies. Use `untrack` if you want to also disable owner tracking.
*/
export declare function untrack<T>(fn: () => T): T;
/**
* Returns true if the given functinon contains signals that have been updated since the last time
* the parent computation was run.
*/
export declare function hasUpdated(fn: () => any): boolean;
/**
* Returns true if the given function contains async signals that are not ready yet.
*/
export declare function isPending(fn: () => any): boolean;
export declare function latest<T>(fn: () => T): T | undefined;
/**
* A convenient wrapper that calls `compute` with the `owner` and `observer` and is guaranteed
* to reset the global context after the computation is finished even if an error is thrown.
*/
export declare function compute<T>(owner: Owner | null, compute: (val: T) => T, observer: Computation<T>): T;
export declare function compute<T>(owner: Owner | null, compute: (val: undefined) => T, observer: null): T;
export declare class EagerComputation<T = any> extends Computation<T> {
constructor(initialValue: T, compute: () => T, options?: SignalOptions<T>);
_notify(state: number): void;
}
export {};

View File

@@ -1,23 +0,0 @@
import { Computation, type SignalOptions } from "./core.js";
/**
* Effects are the leaf nodes of our reactive graph. When their sources change, they are
* automatically added to the queue of effects to re-execute, which will cause them to fetch their
* sources and recompute
*/
export declare class BaseEffect<T = any> extends Computation<T> {
_effect: (val: T, prev: T | undefined) => void;
_modified: boolean;
_prevValue: T | undefined;
constructor(initialValue: T, compute: () => T, effect: (val: T, prev: T | undefined) => void, options?: SignalOptions<T>);
write(value: T): T;
_setError(error: unknown): void;
_disposeNode(): void;
}
export declare class Effect<T = any> extends BaseEffect<T> {
constructor(initialValue: T, compute: () => T, effect: (val: T, prev: T | undefined) => void, options?: SignalOptions<T>);
_notify(state: number): void;
}
export declare class RenderEffect<T = any> extends BaseEffect<T> {
constructor(initialValue: T, compute: () => T, effect: (val: T, prev: T | undefined) => void, options?: SignalOptions<T>);
_notify(state: number): void;
}

View File

@@ -1,11 +0,0 @@
export declare class NotReadyError extends Error {
}
export declare class NoOwnerError extends Error {
constructor();
}
export declare class ContextNotFoundError extends Error {
constructor();
}
export interface ErrorHandler {
(error: unknown): void;
}

View File

@@ -1,8 +0,0 @@
export type Flags = number;
export declare const ERROR_OFFSET = 0;
export declare const ERROR_BIT: number;
export declare const ERROR: unique symbol;
export declare const LOADING_OFFSET = 1;
export declare const LOADING_BIT: number;
export declare const LOADING: unique symbol;
export declare const DEFAULT_FLAGS: number;

View File

@@ -1,6 +0,0 @@
export { ContextNotFoundError, NoOwnerError, NotReadyError, type ErrorHandler } from "./error.js";
export { Owner, createContext, getContext, setContext, hasContext, getOwner, onCleanup, type Context, type ContextRecord, type Disposable } from "./owner.js";
export { Computation, EagerComputation, getObserver, isEqual, untrack, hasUpdated, isPending, latest, UNCHANGED, compute, type SignalOptions } from "./core.js";
export { Effect, RenderEffect } from "./effect.js";
export { flushSync } from "./scheduler.js";
export * from "./flags.js";

View File

@@ -1,88 +0,0 @@
/**
* Owner tracking is used to enable nested tracking scopes with automatic cleanup.
* We also use owners to also keep track of which error handling context we are in.
*
* If you write the following
*
* const a = createOwner(() => {
* const b = createOwner(() => {});
*
* const c = createOwner(() => {
* const d = createOwner(() => {});
* });
*
* const e = createOwner(() => {});
* });
*
* The owner tree will look like this:
*
* a
* /|\
* b-c-e
* |
* d
*
* Following the _nextSibling pointers of each owner will first give you its children, and then its siblings (in reverse).
* a -> e -> c -> d -> b
*
* Note that the owner tree is largely orthogonal to the reactivity tree, and is much closer to the component tree.
*/
import { type ErrorHandler } from "./error.js";
export type ContextRecord = Record<string | symbol, unknown>;
export interface Disposable {
(): void;
}
/**
* Returns the currently executing parent owner.
*/
export declare function getOwner(): Owner | null;
export declare function setOwner(owner: Owner | null): Owner | null;
export declare class Owner {
_parent: Owner | null;
_nextSibling: Owner | null;
_prevSibling: Owner | null;
_state: number;
_disposal: Disposable | Disposable[] | null;
_context: ContextRecord;
_handlers: ErrorHandler[] | null;
constructor(signal?: boolean);
append(child: Owner): void;
dispose(this: Owner, self?: boolean): void;
_disposeNode(): void;
emptyDisposal(): void;
handleError(error: unknown): void;
}
export interface Context<T> {
readonly id: symbol;
readonly defaultValue: T | undefined;
}
/**
* Context provides a form of dependency injection. It is used to save from needing to pass
* data as props through intermediate components. This function creates a new context object
* that can be used with `getContext` and `setContext`.
*
* A default value can be provided here which will be used when a specific value is not provided
* via a `setContext` call.
*/
export declare function createContext<T>(defaultValue?: T, description?: string): Context<T>;
/**
* Attempts to get a context value for the given key.
*
* @throws `NoOwnerError` if there's no owner at the time of call.
* @throws `ContextNotFoundError` if a context value has not been set yet.
*/
export declare function getContext<T>(context: Context<T>, owner?: Owner | null): T;
/**
* Attempts to set a context value on the parent scope with the given key.
*
* @throws `NoOwnerError` if there's no owner at the time of call.
*/
export declare function setContext<T>(context: Context<T>, value?: T, owner?: Owner | null): void;
/**
* Whether the given context is currently defined.
*/
export declare function hasContext(context: Context<any>, owner?: Owner | null): boolean;
/**
* Runs the given function when the parent owner computation is being disposed.
*/
export declare function onCleanup(disposable: Disposable): void;

View File

@@ -1,9 +0,0 @@
import type { Effect, RenderEffect } from "./effect.js";
import { Computation } from "./core.js";
export declare let Computations: Computation[], RenderEffects: RenderEffect[], Effects: Effect[];
/**
* By default, changes are batched on the microtask queue which is an async process. You can flush
* the queue synchronously to get the latest updates by calling `flushSync()`.
*/
export declare function flushSync(): void;
export declare function flushQueue(): void;

View File

@@ -1,5 +0,0 @@
export { Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, createContext, getContext, setContext, hasContext, getOwner, onCleanup, getObserver, isEqual, untrack, hasUpdated, isPending, latest } from "./core/index.js";
export type { ErrorHandler, SignalOptions, Context, ContextRecord, Disposable } from "./core/index.js";
export { flushSync } from "./core/scheduler.js";
export { mapArray, type Maybe } from "./map.js";
export * from "./signals.js";

View File

@@ -1,12 +0,0 @@
import type { Accessor } from "./signals.js";
export type Maybe<T> = T | void | null | undefined | false;
/**
* Reactive map helper that caches each list item by reference to reduce unnecessary mapping on
* updates.
*
* @see {@link https://github.com/solidjs/x-reactivity#maparray}
*/
export declare function mapArray<Item, MappedItem>(list: Accessor<Maybe<readonly Item[]>>, map: (value: Accessor<Item>, index: Accessor<number>) => MappedItem, options?: {
keyed?: boolean | ((item: Item) => any);
name?: string;
}): Accessor<MappedItem[]>;

View File

@@ -1,56 +0,0 @@
import type { SignalOptions } from "./core/index.js";
import { Owner } from "./core/index.js";
export interface Accessor<T> {
(): T;
}
export interface Setter<T> {
(value: T | SetValue<T>): T;
}
export interface SetValue<T> {
(currentValue: T): T;
}
export type Signal<T> = [read: Accessor<T>, write: Setter<T>];
/**
* Wraps the given value into a signal. The signal will return the current value when invoked
* `fn()`, and provide a simple write API via `write()`. The value can now be observed
* when used inside other computations created with `computed` and `effect`.
*/
export declare function createSignal<T>(initialValue: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
export declare function createSignal<T>(fn: (prev?: T) => T, initialValue?: T, options?: SignalOptions<T>): Signal<T>;
export declare function createAsync<T>(fn: (prev?: T) => Promise<T> | AsyncIterable<T> | T, initial?: T, options?: SignalOptions<T>): Accessor<T>;
/**
* Creates a new computation whose value is computed and returned by the given function. The given
* compute function is _only_ re-run when one of it's dependencies are updated. Dependencies are
* are all signals that are read during execution.
*/
export declare function createMemo<T>(compute: (prev?: T) => T, initialValue?: T, options?: SignalOptions<T>): Accessor<T>;
/**
* Invokes the given function each time any of the signals that are read inside are updated
* (i.e., their value changes). The effect is immediately invoked on initialization.
*/
export declare function createEffect<T>(compute: () => T, effect: (v: T) => (() => void) | void, initialValue?: T, options?: {
name?: string;
}): void;
/**
* Invokes the given function each time any of the signals that are read inside are updated
* (i.e., their value changes). The effect is immediately invoked on initialization.
*/
export declare function createRenderEffect<T>(compute: () => T, effect: (v: T) => (() => void) | void, initialValue?: T, options?: {
name?: string;
}): void;
/**
* Creates a computation root which is given a `dispose()` function to dispose of all inner
* computations.
*/
export declare function createRoot<T>(init: ((dispose: () => void) => T) | (() => T)): T;
/**
* Runs the given function in the given owner so that error handling and cleanups continue to work.
*
* Warning: Usually there are simpler ways of modeling a problem that avoid using this function
*/
export declare function runWithOwner<T>(owner: Owner | null, run: () => T): T | undefined;
/**
* Runs the given function when an error is thrown in a child owner. If the error is thrown again
* inside the error handler, it will trigger the next available parent owner handler.
*/
export declare function catchError<T>(fn: () => T, handler: (error: unknown) => void): void;

View File

@@ -1 +0,0 @@
export * from "./store.js";

View File

@@ -1,31 +0,0 @@
export type Store<T> = Readonly<T>;
export type StoreSetter<T> = (fn: (state: T) => void) => void;
declare const $TRACK: unique symbol, $PROXY: unique symbol;
export { $PROXY, $TRACK };
export type StoreNode = Record<PropertyKey, any>;
export declare namespace SolidStore {
interface Unwrappable {
}
}
export type NotWrappable = string | number | bigint | symbol | boolean | Function | null | undefined | SolidStore.Unwrappable[keyof SolidStore.Unwrappable];
export declare function isWrappable<T>(obj: T | NotWrappable): obj is T;
/**
* Returns the underlying data in the store without a proxy.
* @param item store proxy object
* @example
* ```js
* const initial = {z...};
* const [state, setState] = createStore(initial);
* initial === state; // => false
* initial === unwrap(state); // => true
* ```
*/
export declare function unwrap<T>(item: T, set?: Set<unknown>): T;
export declare function createStore<T extends object = {}>(store: T | Store<T>): [get: Store<T>, set: StoreSetter<T>];
export declare function createStore<T extends object = {}>(fn: (store: T) => void, store: T | Store<T>): [get: Store<T>, set: StoreSetter<T>];
/**
* Creates a mutable derived value
*
* @see {@link https://github.com/solidjs/x-reactivity#createprojection}
*/
export declare function createProjection<T extends Object>(fn: (draft: T) => void, initialValue: T): Readonly<T>;

View File

@@ -1 +0,0 @@
export declare function isUndefined(value: any): value is undefined;

View File

@@ -39,6 +39,30 @@ export function init({
const scale = signals.createMemo(() => selected().scale);
elements.charts.append(utils.dom.createShadow("left"));
elements.charts.append(utils.dom.createShadow("right"));
const { headerElement, titleElement, descriptionElement } =
utils.dom.createHeader({
title: selected().title,
description: selected().serializedPath,
});
elements.charts.append(headerElement);
signals.createEffect(selected, (option) => {
titleElement.innerHTML = option.title;
descriptionElement.innerHTML = option.serializedPath;
});
const div = window.document.createElement("div");
elements.charts.append(div);
const legendElement = window.document.createElement("legend");
div.append(legendElement);
const chartListElement = window.document.createElement("div");
chartListElement.classList.add("chart-list");
div.append(chartListElement);
/**
* @returns {TimeRange}
*/
@@ -362,7 +386,7 @@ export function init({
});
}
elements.legend.prepend(div);
legendElement.prepend(div);
const { input, label } = utils.dom.createLabeledInput({
inputId: `legend-${series.title}`,
@@ -841,7 +865,7 @@ export function init({
charts = chartsBlueprints.map((seriesBlueprints, chartIndex) => {
const { chartDiv, unitName, chartMode } = createChartDiv(
elements.chartsChartList,
chartListElement,
chartIndex,
);
@@ -1167,16 +1191,14 @@ export function init({
}
function resetLegendElement() {
elements.legend.innerHTML = "";
legendElement.innerHTML = "";
}
function resetChartListElement() {
while (
elements.chartsChartList.lastElementChild?.classList.contains(
"chart-wrapper",
)
chartListElement.lastElementChild?.classList.contains("chart-wrapper")
) {
elements.chartsChartList.lastElementChild?.remove();
chartListElement.lastElementChild?.remove();
}
}

View File

@@ -1102,7 +1102,6 @@ const utils = {
createSelect({ id, list, signal }) {
const select = window.document.createElement("select");
select.name = id;
select.value = signal().value;
/** @type {Record<string, VoidFunction>} */
const setters = {};
@@ -1134,8 +1133,18 @@ const utils = {
}
});
select.value = signal().value;
return select;
},
/**
* @param {'left' | 'bottom' | 'top' | 'right'} position
*/
createShadow(position) {
const div = window.document.createElement("div");
div.classList.add(`shadow-${position}`);
return div;
},
},
url: {
chartParamsWhitelist: ["from", "to"],
@@ -1697,13 +1706,8 @@ const elements = {
),
searchSmall: utils.dom.getElementById("search-small"),
searchResults: utils.dom.getElementById("search-results"),
selectedTitle: utils.dom.getElementById("selected-title"),
selectedDescription: utils.dom.getElementById("selected-description"),
selectors: utils.dom.getElementById("frame-selectors"),
chartsChartList: utils.dom.getElementById("charts-chart-list"),
legend: utils.dom.getElementById("legend"),
style: getComputedStyle(window.document.documentElement),
selectedHeader: utils.dom.getElementById("selected-header"),
charts: utils.dom.getElementById("charts"),
simulation: utils.dom.getElementById("simulation"),
livePrice: utils.dom.getElementById("live-price"),
@@ -1843,7 +1847,7 @@ function createColors(dark) {
return getColor("avocado");
}
function lime() {
return getColor("line");
return getColor("lime");
}
function green() {
return getColor("green");
@@ -2635,18 +2639,6 @@ packages.signals().then((signals) =>
utils.url.replaceHistory({ pathname: option.id });
}
const hideTop =
option.kind === "home" ||
option.kind === "pdf" ||
option.kind === "live-price" ||
option.kind === "converter" ||
option.kind === "moscow-time";
elements.selectedHeader.hidden = hideTop;
elements.selectedTitle.innerHTML = option.title;
elements.selectedDescription.innerHTML = option.serializedPath;
/** @type {HTMLElement} */
let element;

View File

@@ -4992,7 +4992,7 @@ function createPartialOptions(colors) {
tree: [
{
kind: "simulation",
title: "Simulation: Save In Bitcoin",
title: "Save In Bitcoin",
name: "Save In Bitcoin",
},
],
@@ -5063,6 +5063,24 @@ function createPartialOptions(colors) {
},
],
},
{
name: "Lyn Alden",
tree: [
{
name: "Analyzing Bitcoin Consensus: Risks in Protocol Upgrades",
pdf: "multi-author/bcap_v1.0.pdf",
},
],
},
{
name: "Steve Lee",
tree: [
{
name: "Analyzing Bitcoin Consensus: Risks in Protocol Upgrades",
pdf: "multi-author/bcap_v1.0.pdf",
},
],
},
],
},
{
@@ -5521,7 +5539,7 @@ export function initOptions({
title = anyPartial.title;
} else if ("pdf" in anyPartial) {
kind = "pdf";
id = `${ids.fromString(anyPartial.name)}-pdf`;
id = `${path?.at(-1)?.name || ""}-${ids.fromString(anyPartial.name)}-pdf`;
title = anyPartial.name;
anyPartial.pdf = `/assets/pdfs/${anyPartial.pdf}`;
} else if ("url" in anyPartial) {

View File

@@ -23,61 +23,66 @@
}
}
> #legend {
> div {
flex: 1;
display: flex;
align-items: center;
gap: 1.5rem;
margin: 1rem var(--negative-main-padding);
padding: 1rem var(--main-padding);
overflow-x: auto;
min-width: 0;
flex-direction: column;
margin-top: 2rem;
min-height: 0;
> div {
flex: 0;
> legend {
display: flex;
align-items: center;
gap: 1.5rem;
margin-left: var(--negative-main-padding);
margin-right: var(--negative-main-padding);
margin-bottom: 0.5rem;
padding-left: var(--main-padding);
padding-right: var(--main-padding);
padding-bottom: 0.75rem;
overflow-x: auto;
min-width: 0;
> label {
margin: -0.375rem 0;
color: var(--color);
> div {
flex: 0;
display: flex;
align-items: center;
&:has(input:not(:checked)) {
color: var(--off-color);
> label {
margin: -0.375rem 0;
color: var(--color);
> span.main > span.name {
text-decoration-thickness: 1.5px;
text-decoration-color: var(--color);
text-decoration-line: line-through;
}
&:hover {
* {
color: var(--off-color) !important;
}
&:has(input:not(:checked)) {
color: var(--off-color);
> span.main > span.name {
text-decoration-color: var(--orange) !important;
text-decoration-thickness: 1.5px;
text-decoration-color: var(--color);
text-decoration-line: line-through;
}
&:hover {
* {
color: var(--off-color) !important;
}
> span.main > span.name {
text-decoration-color: var(--orange) !important;
}
}
}
}
}
> a {
padding: 0.375rem;
margin: -0.375rem;
> svg {
/* padding: 0.375rem; */
margin: 0rem;
width: 1rem;
height: 1rem;
> a {
padding: 0.375rem;
margin: -0.375rem;
}
}
}
}
.chart-list {
margin-left: var(--negative-main-padding);
margin-right: calc(var(--negative-main-padding) - 0.5rem);
.chart-list {
margin-left: var(--negative-main-padding);
margin-right: calc(var(--negative-main-padding) - 0.5rem);
}
}
}

View File

@@ -4,6 +4,10 @@
height: 100%;
width: 100%;
header {
margin-bottom: 0.5rem;
}
> div:first-child {
max-width: var(--default-main-width);
border-right: 1px;
@@ -35,7 +39,7 @@
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 2rem;
gap: 1.5rem;
padding: var(--main-padding);
> div {