This commit is contained in:
2024-11-28 23:08:17 +01:00
parent 8895fde030
commit 0dda8e760c
16116 changed files with 2866428 additions and 71 deletions

20
node_modules/alien-signals/cjs/computed.d.ts generated vendored Normal file
View File

@@ -0,0 +1,20 @@
import { DirtyLevels, IComputed } from './system.js';
export interface ISignal<T = any> {
get(): T;
}
export declare function computed<T>(getter: (cachedValue?: T) => T): ISignal<T>;
export declare class Computed<T = any> implements IComputed {
getter: (cachedValue?: T) => T;
cachedValue: T | undefined;
subs: undefined;
subsTail: undefined;
linkedTrackId: number;
deps: undefined;
depsTail: undefined;
trackId: number;
dirtyLevel: DirtyLevels;
canPropagate: boolean;
constructor(getter: (cachedValue?: T) => T);
get(): T;
update(): void;
}

61
node_modules/alien-signals/cjs/computed.js generated vendored Normal file
View File

@@ -0,0 +1,61 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Computed = void 0;
exports.computed = computed;
const system_js_1 = require("./system.js");
function computed(getter) {
return new Computed(getter);
}
class Computed {
constructor(getter) {
this.getter = getter;
this.cachedValue = undefined;
// Dependency
this.subs = undefined;
this.subsTail = undefined;
this.linkedTrackId = -1;
// Subscriber
this.deps = undefined;
this.depsTail = undefined;
this.trackId = 0;
this.dirtyLevel = 3 /* DirtyLevels.Dirty */;
this.canPropagate = false;
}
get() {
const dirtyLevel = this.dirtyLevel;
if (dirtyLevel === 2 /* DirtyLevels.MaybeDirty */) {
system_js_1.Subscriber.resolveMaybeDirty(this);
if (this.dirtyLevel === 3 /* DirtyLevels.Dirty */) {
this.update();
}
}
else if (dirtyLevel === 3 /* DirtyLevels.Dirty */ || dirtyLevel === 4 /* DirtyLevels.Released */) {
this.update();
}
const activeTrackId = system_js_1.System.activeTrackId;
if (activeTrackId !== 0 && this.linkedTrackId !== activeTrackId) {
this.linkedTrackId = activeTrackId;
system_js_1.Dependency.linkSubscriber(this, system_js_1.System.activeSub);
}
return this.cachedValue;
}
update() {
const prevSub = system_js_1.Subscriber.startTrackDependencies(this);
const oldValue = this.cachedValue;
let newValue;
try {
newValue = this.getter(oldValue);
}
finally {
system_js_1.Subscriber.endTrackDependencies(this, prevSub);
}
if (oldValue !== newValue) {
this.cachedValue = newValue;
const subs = this.subs;
if (subs !== undefined) {
system_js_1.Dependency.propagate(subs);
}
}
}
}
exports.Computed = Computed;

18
node_modules/alien-signals/cjs/effect.d.ts generated vendored Normal file
View File

@@ -0,0 +1,18 @@
import { DirtyLevels, IEffect } from './system.js';
export declare function effect(fn: () => void): Effect;
export declare class Effect implements IEffect {
fn: () => void;
nextNotify: undefined;
subs: undefined;
subsTail: undefined;
linkedTrackId: number;
deps: undefined;
depsTail: undefined;
trackId: number;
dirtyLevel: DirtyLevels;
canPropagate: boolean;
constructor(fn: () => void);
notify(): void;
run(): void;
stop(): void;
}

73
node_modules/alien-signals/cjs/effect.js generated vendored Normal file
View File

@@ -0,0 +1,73 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Effect = void 0;
exports.effect = effect;
const system_js_1 = require("./system.js");
function effect(fn) {
const e = new Effect(fn);
e.run();
return e;
}
class Effect {
constructor(fn) {
this.fn = fn;
this.nextNotify = undefined;
// Dependency
this.subs = undefined;
this.subsTail = undefined;
this.linkedTrackId = -1;
// Subscriber
this.deps = undefined;
this.depsTail = undefined;
this.trackId = 0;
this.dirtyLevel = 3 /* DirtyLevels.Dirty */;
this.canPropagate = false;
const subVersion = system_js_1.System.activeTrackId;
if (subVersion !== 0 && this.linkedTrackId !== subVersion) {
this.linkedTrackId = subVersion;
system_js_1.Dependency.linkSubscriber(this, system_js_1.System.activeSub);
return;
}
const activeTrackId = system_js_1.System.activeEffectScopeTrackId;
if (activeTrackId !== 0 && this.linkedTrackId !== activeTrackId) {
this.linkedTrackId = activeTrackId;
system_js_1.Dependency.linkSubscriber(this, system_js_1.System.activeEffectScope);
}
}
notify() {
const dirtyLevel = this.dirtyLevel;
if (dirtyLevel === 1 /* DirtyLevels.SideEffectsOnly */) {
this.dirtyLevel = 0 /* DirtyLevels.None */;
system_js_1.Subscriber.runInnerEffects(this.deps);
}
else {
if (dirtyLevel === 2 /* DirtyLevels.MaybeDirty */) {
system_js_1.Subscriber.resolveMaybeDirty(this);
}
if (this.dirtyLevel === 3 /* DirtyLevels.Dirty */) {
this.run();
}
else {
system_js_1.Subscriber.runInnerEffects(this.deps);
}
}
}
run() {
const prevSub = system_js_1.Subscriber.startTrackDependencies(this);
try {
this.fn();
}
finally {
system_js_1.Subscriber.endTrackDependencies(this, prevSub);
}
}
stop() {
if (this.deps !== undefined) {
system_js_1.Subscriber.clearTrack(this.deps);
this.deps = undefined;
this.depsTail = undefined;
}
this.dirtyLevel = 3 /* DirtyLevels.Dirty */;
}
}
exports.Effect = Effect;

13
node_modules/alien-signals/cjs/effectScope.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import { DirtyLevels, IEffectScope } from './system.js';
export declare function effectScope(): EffectScope;
export declare class EffectScope implements IEffectScope {
nextNotify: undefined;
deps: undefined;
depsTail: undefined;
trackId: number;
dirtyLevel: DirtyLevels;
canPropagate: boolean;
notify(): void;
run<T>(fn: () => T): T;
stop(): void;
}

43
node_modules/alien-signals/cjs/effectScope.js generated vendored Normal file
View File

@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EffectScope = void 0;
exports.effectScope = effectScope;
const system_js_1 = require("./system.js");
function effectScope() {
return new EffectScope();
}
class EffectScope {
constructor() {
this.nextNotify = undefined;
// Subscriber
this.deps = undefined;
this.depsTail = undefined;
this.trackId = 0;
this.dirtyLevel = 0 /* DirtyLevels.None */;
this.canPropagate = false;
}
notify() {
if (this.dirtyLevel !== 0 /* DirtyLevels.None */) {
this.dirtyLevel = 0 /* DirtyLevels.None */;
system_js_1.Subscriber.runInnerEffects(this.deps);
}
}
run(fn) {
const prevSub = system_js_1.Subscriber.startTrackEffects(this);
try {
return fn();
}
finally {
system_js_1.Subscriber.endTrackEffects(this, prevSub);
}
}
stop() {
if (this.deps !== undefined) {
system_js_1.Subscriber.clearTrack(this.deps);
this.deps = undefined;
this.depsTail = undefined;
}
this.dirtyLevel = 0 /* DirtyLevels.None */;
}
}
exports.EffectScope = EffectScope;

6
node_modules/alien-signals/cjs/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
export * from './computed.js';
export * from './effect.js';
export * from './effectScope.js';
export * from './signal.js';
export * from './system.js';
export * as Unstable from './unstable/index.js';

23
node_modules/alien-signals/cjs/index.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Unstable = void 0;
__exportStar(require("./computed.js"), exports);
__exportStar(require("./effect.js"), exports);
__exportStar(require("./effectScope.js"), exports);
__exportStar(require("./signal.js"), exports);
__exportStar(require("./system.js"), exports);
exports.Unstable = require("./unstable/index.js");

16
node_modules/alien-signals/cjs/signal.d.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
import { ISignal } from './computed.js';
import { Dependency } from './system.js';
export interface IWritableSignal<T = any> extends ISignal<T> {
set(value: T): void;
}
export declare function signal<T>(): Signal<T | undefined>;
export declare function signal<T>(oldValue: T): Signal<T>;
export declare class Signal<T = any> implements Dependency {
currentValue: T;
subs: undefined;
subsTail: undefined;
linkedTrackId: number;
constructor(currentValue: T);
get(): NonNullable<T>;
set(value: T): void;
}

36
node_modules/alien-signals/cjs/signal.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Signal = void 0;
exports.signal = signal;
const system_js_1 = require("./system.js");
function signal(oldValue) {
return new Signal(oldValue);
}
class Signal {
constructor(currentValue) {
this.currentValue = currentValue;
// Dependency
this.subs = undefined;
this.subsTail = undefined;
this.linkedTrackId = -1;
}
get() {
const activeTrackId = system_js_1.System.activeTrackId;
if (activeTrackId !== 0 && this.linkedTrackId !== activeTrackId) {
this.linkedTrackId = activeTrackId;
system_js_1.Dependency.linkSubscriber(this, system_js_1.System.activeSub);
}
return this.currentValue;
}
set(value) {
if (this.currentValue !== (this.currentValue = value)) {
const subs = this.subs;
if (subs !== undefined) {
(0, system_js_1.startBatch)();
system_js_1.Dependency.propagate(subs);
(0, system_js_1.endBatch)();
}
}
}
}
exports.Signal = Signal;

65
node_modules/alien-signals/cjs/system.d.ts generated vendored Normal file
View File

@@ -0,0 +1,65 @@
export interface IEffectScope extends Subscriber {
nextNotify: IEffectScope | undefined;
notify(): void;
}
export interface IEffect extends Dependency, IEffectScope {
}
export interface IComputed extends Dependency, Subscriber {
update(): void;
}
export interface Dependency {
subs: Link | undefined;
subsTail: Link | undefined;
linkedTrackId: number;
}
export interface Subscriber {
trackId: number;
canPropagate: boolean;
dirtyLevel: DirtyLevels;
deps: Link | undefined;
depsTail: Link | undefined;
}
export interface Link {
dep: Dependency | IComputed | IEffect;
sub: IComputed | IEffect | IEffectScope;
trackId: number;
prevSub: Link | undefined;
nextSub: Link | undefined;
nextDep: Link | undefined;
}
export declare const enum DirtyLevels {
None = 0,
SideEffectsOnly = 1,
MaybeDirty = 2,
Dirty = 3,
Released = 4
}
export declare namespace System {
let activeSub: IComputed | IEffect | undefined;
let activeEffectScope: IEffectScope | undefined;
let activeTrackId: number;
let activeEffectScopeTrackId: number;
let batchDepth: number;
let lastTrackId: number;
let queuedEffects: IEffectScope | undefined;
let queuedEffectsTail: IEffectScope | undefined;
}
export declare function startBatch(): void;
export declare function endBatch(): void;
export declare namespace Link {
let pool: Link | undefined;
}
export declare namespace Dependency {
function linkSubscriber(dep: Link['dep'], sub: Link['sub']): void;
function propagate(subs: Link): void;
}
export declare namespace Subscriber {
function runInnerEffects(link: Link | undefined): void;
function resolveMaybeDirty(sub: IComputed | IEffect, depth?: number): void;
function resolveMaybeDirtyNonRecursive(sub: IComputed | IEffect): void;
function startTrackDependencies(sub: IComputed | IEffect): IEffect | IComputed | undefined;
function endTrackDependencies(sub: IComputed | IEffect, prevSub: IComputed | IEffect | undefined): void;
function clearTrack(link: Link): void;
function startTrackEffects(sub: IEffectScope): IEffectScope | undefined;
function endTrackEffects(sub: IEffectScope, prevSub: IEffectScope | undefined): void;
}

406
node_modules/alien-signals/cjs/system.js generated vendored Normal file
View File

@@ -0,0 +1,406 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Subscriber = exports.Dependency = exports.Link = exports.System = void 0;
exports.startBatch = startBatch;
exports.endBatch = endBatch;
var System;
(function (System) {
System.activeSub = undefined;
System.activeEffectScope = undefined;
System.activeTrackId = 0;
System.activeEffectScopeTrackId = 0;
System.batchDepth = 0;
System.lastTrackId = 0;
System.queuedEffects = undefined;
System.queuedEffectsTail = undefined;
})(System || (exports.System = System = {}));
function startBatch() {
System.batchDepth++;
}
function endBatch() {
System.batchDepth--;
if (System.batchDepth === 0) {
while (System.queuedEffects !== undefined) {
const effect = System.queuedEffects;
const queuedNext = System.queuedEffects.nextNotify;
if (queuedNext !== undefined) {
System.queuedEffects.nextNotify = undefined;
System.queuedEffects = queuedNext;
}
else {
System.queuedEffects = undefined;
System.queuedEffectsTail = undefined;
}
effect.notify();
}
}
}
var Link;
(function (Link) {
Link.pool = undefined;
})(Link || (exports.Link = Link = {}));
var Dependency;
(function (Dependency) {
const system = System;
function linkSubscriber(dep, sub) {
const depsTail = sub.depsTail;
const old = depsTail !== undefined
? depsTail.nextDep
: sub.deps;
if (old === undefined || old.dep !== dep) {
let newLink;
if (Link.pool !== undefined) {
newLink = Link.pool;
Link.pool = newLink.nextDep;
newLink.nextDep = old;
newLink.dep = dep;
newLink.sub = sub;
newLink.trackId = sub.trackId;
}
else {
newLink = {
dep,
sub,
trackId: sub.trackId,
nextDep: old,
prevSub: undefined,
nextSub: undefined,
};
}
if (depsTail === undefined) {
sub.deps = newLink;
}
else {
depsTail.nextDep = newLink;
}
if (dep.subs === undefined) {
dep.subs = newLink;
}
else {
const oldTail = dep.subsTail;
newLink.prevSub = oldTail;
oldTail.nextSub = newLink;
}
sub.depsTail = newLink;
dep.subsTail = newLink;
}
else {
old.trackId = sub.trackId;
sub.depsTail = old;
}
}
Dependency.linkSubscriber = linkSubscriber;
function propagate(subs) {
let link = subs;
let dep = subs.dep;
let dirtyLevel = 3 /* DirtyLevels.Dirty */;
let remainingQuantity = 0;
do {
if (link !== undefined) {
const sub = link.sub;
if (sub.trackId > 0) {
if (sub.trackId === link.trackId) {
const subDirtyLevel = sub.dirtyLevel;
if (subDirtyLevel < dirtyLevel) {
sub.dirtyLevel = dirtyLevel;
if (subDirtyLevel === 0 /* DirtyLevels.None */) {
sub.canPropagate = true;
}
}
}
}
else if (sub.trackId === -link.trackId) {
const subDirtyLevel = sub.dirtyLevel;
const notDirty = subDirtyLevel === 0 /* DirtyLevels.None */;
if (subDirtyLevel < dirtyLevel) {
sub.dirtyLevel = dirtyLevel;
}
if (notDirty || sub.canPropagate) {
if (!notDirty) {
sub.canPropagate = false;
}
const subIsEffect = 'notify' in sub;
if ('subs' in sub && sub.subs !== undefined) {
sub.depsTail.nextDep = link;
dep = sub;
link = sub.subs;
if (subIsEffect) {
dirtyLevel = 1 /* DirtyLevels.SideEffectsOnly */;
}
else {
dirtyLevel = 2 /* DirtyLevels.MaybeDirty */;
}
remainingQuantity++;
continue;
}
else if (subIsEffect) {
const queuedEffectsTail = system.queuedEffectsTail;
if (queuedEffectsTail !== undefined) {
queuedEffectsTail.nextNotify = sub;
}
else {
system.queuedEffects = sub;
}
system.queuedEffectsTail = sub;
}
}
}
link = link.nextSub;
continue;
}
if (remainingQuantity !== 0) {
const depsTail = dep.depsTail;
const prevLink = depsTail.nextDep;
const prevSub = prevLink.sub;
depsTail.nextDep = undefined;
dep = prevLink.dep;
link = prevLink.nextSub;
remainingQuantity--;
if (remainingQuantity === 0) {
dirtyLevel = 3 /* DirtyLevels.Dirty */;
}
else if ('notify' in dep) {
dirtyLevel = 1 /* DirtyLevels.SideEffectsOnly */;
}
else {
dirtyLevel = 2 /* DirtyLevels.MaybeDirty */;
}
if ('notify' in prevSub) {
const queuedEffectsTail = system.queuedEffectsTail;
if (queuedEffectsTail !== undefined) {
queuedEffectsTail.nextNotify = prevSub;
}
else {
system.queuedEffects = prevSub;
}
system.queuedEffectsTail = prevSub;
}
continue;
}
break;
} while (true);
}
Dependency.propagate = propagate;
})(Dependency || (exports.Dependency = Dependency = {}));
var Subscriber;
(function (Subscriber) {
const system = System;
function runInnerEffects(link) {
while (link !== undefined) {
const dep = link.dep;
if ('notify' in dep) {
dep.notify();
}
link = link.nextDep;
}
}
Subscriber.runInnerEffects = runInnerEffects;
function resolveMaybeDirty(sub, depth = 0) {
let link = sub.deps;
while (link !== undefined) {
const dep = link.dep;
if ('update' in dep) {
const dirtyLevel = dep.dirtyLevel;
if (dirtyLevel === 2 /* DirtyLevels.MaybeDirty */) {
if (depth >= 4) {
resolveMaybeDirtyNonRecursive(dep);
}
else {
resolveMaybeDirty(dep, depth + 1);
}
if (dep.dirtyLevel === 3 /* DirtyLevels.Dirty */) {
dep.update();
if (sub.dirtyLevel === 3 /* DirtyLevels.Dirty */) {
break;
}
}
}
else if (dirtyLevel === 3 /* DirtyLevels.Dirty */) {
dep.update();
if (sub.dirtyLevel === 3 /* DirtyLevels.Dirty */) {
break;
}
}
}
link = link.nextDep;
}
if (sub.dirtyLevel === 2 /* DirtyLevels.MaybeDirty */) {
sub.dirtyLevel = 0 /* DirtyLevels.None */;
}
}
Subscriber.resolveMaybeDirty = resolveMaybeDirty;
function resolveMaybeDirtyNonRecursive(sub) {
let link = sub.deps;
let remaining = 0;
do {
if (link !== undefined) {
const dep = link.dep;
if ('update' in dep) {
const depDirtyLevel = dep.dirtyLevel;
if (depDirtyLevel === 2 /* DirtyLevels.MaybeDirty */) {
dep.subs.prevSub = link;
sub = dep;
link = dep.deps;
remaining++;
continue;
}
else if (depDirtyLevel === 3 /* DirtyLevels.Dirty */) {
dep.update();
if (sub.dirtyLevel === 3 /* DirtyLevels.Dirty */) {
if (remaining !== 0) {
const subSubs = sub.subs;
const prevLink = subSubs.prevSub;
sub.update();
subSubs.prevSub = undefined;
sub = prevLink.sub;
link = prevLink.nextDep;
remaining--;
continue;
}
break;
}
}
}
link = link.nextDep;
continue;
}
const dirtyLevel = sub.dirtyLevel;
if (dirtyLevel === 2 /* DirtyLevels.MaybeDirty */) {
sub.dirtyLevel = 0 /* DirtyLevels.None */;
if (remaining !== 0) {
const subSubs = sub.subs;
const prevLink = subSubs.prevSub;
subSubs.prevSub = undefined;
sub = prevLink.sub;
link = prevLink.nextDep;
remaining--;
continue;
}
}
else if (remaining !== 0) {
if (dirtyLevel === 3 /* DirtyLevels.Dirty */) {
sub.update();
}
const subSubs = sub.subs;
const prevLink = subSubs.prevSub;
subSubs.prevSub = undefined;
sub = prevLink.sub;
link = prevLink.nextDep;
remaining--;
continue;
}
break;
} while (true);
}
Subscriber.resolveMaybeDirtyNonRecursive = resolveMaybeDirtyNonRecursive;
function startTrackDependencies(sub) {
const newVersion = system.lastTrackId + 1;
const prevSub = system.activeSub;
system.activeSub = sub;
system.activeTrackId = newVersion;
system.lastTrackId = newVersion;
sub.depsTail = undefined;
sub.trackId = newVersion;
sub.dirtyLevel = 0 /* DirtyLevels.None */;
return prevSub;
}
Subscriber.startTrackDependencies = startTrackDependencies;
function endTrackDependencies(sub, prevSub) {
if (prevSub !== undefined) {
system.activeSub = prevSub;
system.activeTrackId = prevSub.trackId;
}
else {
system.activeSub = undefined;
system.activeTrackId = 0;
}
const depsTail = sub.depsTail;
if (depsTail !== undefined) {
if (depsTail.nextDep !== undefined) {
clearTrack(depsTail.nextDep);
depsTail.nextDep = undefined;
}
}
else if (sub.deps !== undefined) {
clearTrack(sub.deps);
sub.deps = undefined;
}
sub.trackId = -sub.trackId;
}
Subscriber.endTrackDependencies = endTrackDependencies;
function clearTrack(link) {
do {
const nextDep = link.nextDep;
const dep = link.dep;
const nextSub = link.nextSub;
const prevSub = link.prevSub;
if (nextSub !== undefined) {
nextSub.prevSub = prevSub;
}
if (prevSub !== undefined) {
prevSub.nextSub = nextSub;
}
if (nextSub === undefined) {
dep.subsTail = prevSub;
}
if (prevSub === undefined) {
dep.subs = nextSub;
}
// @ts-ignore
link.dep = undefined;
// @ts-ignore
link.sub = undefined;
link.prevSub = undefined;
link.nextSub = undefined;
link.nextDep = Link.pool;
Link.pool = link;
if (dep.subs === undefined && 'deps' in dep) {
dep.dirtyLevel = 4 /* DirtyLevels.Released */;
if (dep.deps !== undefined) {
link = dep.deps;
dep.depsTail.nextDep = nextDep;
dep.deps = undefined;
dep.depsTail = undefined;
continue;
}
}
link = nextDep;
} while (link !== undefined);
}
Subscriber.clearTrack = clearTrack;
function startTrackEffects(sub) {
const newVersion = system.lastTrackId + 1;
const prevSub = system.activeEffectScope;
system.activeEffectScope = sub;
system.activeEffectScopeTrackId = newVersion;
system.lastTrackId = newVersion;
sub.depsTail = undefined;
sub.trackId = newVersion;
sub.dirtyLevel = 0 /* DirtyLevels.None */;
return prevSub;
}
Subscriber.startTrackEffects = startTrackEffects;
function endTrackEffects(sub, prevSub) {
if (prevSub !== undefined) {
system.activeEffectScope = prevSub;
system.activeEffectScopeTrackId = prevSub.trackId;
}
else {
system.activeEffectScope = undefined;
system.activeEffectScopeTrackId = 0;
}
const depsTail = sub.depsTail;
if (depsTail !== undefined) {
if (depsTail.nextDep !== undefined) {
clearTrack(depsTail.nextDep);
depsTail.nextDep = undefined;
}
}
else if (sub.deps !== undefined) {
clearTrack(sub.deps);
sub.deps = undefined;
}
sub.trackId = -sub.trackId;
}
Subscriber.endTrackEffects = endTrackEffects;
})(Subscriber || (exports.Subscriber = Subscriber = {}));

View File

@@ -0,0 +1,2 @@
import { ISignal } from '../index.js';
export declare function computedArray<I, O>(arr: ISignal<I[]>, getGetter: (item: ISignal<I>, index: number) => () => O): readonly Readonly<O>[];

View File

@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.computedArray = computedArray;
const index_js_1 = require("../index.js");
function computedArray(arr, getGetter) {
const length = (0, index_js_1.computed)(() => arr.get().length);
const keys = (0, index_js_1.computed)(() => {
const keys = [];
for (let i = 0; i < length.get(); i++) {
keys.push(String(i));
}
return keys;
});
const items = (0, index_js_1.computed)((array) => {
array ??= [];
while (array.length < length.get()) {
const index = array.length;
const item = (0, index_js_1.computed)(() => arr.get()[index]);
array.push((0, index_js_1.computed)(getGetter(item, index)));
}
if (array.length > length.get()) {
array.length = length.get();
}
return array;
});
return new Proxy({}, {
get(_, p, receiver) {
if (p === 'length') {
return length.get();
}
if (typeof p === 'string' && !isNaN(Number(p))) {
return items.get()[Number(p)]?.get();
}
return Reflect.get(items.get(), p, receiver);
},
has(_, p) {
return Reflect.has(items.get(), p);
},
ownKeys() {
return keys.get();
},
});
}

View File

@@ -0,0 +1,2 @@
import { ISignal } from '../index.js';
export declare function computedSet<T>(source: ISignal<Set<T>>): ISignal<Set<T>>;

13
node_modules/alien-signals/cjs/unstable/computedSet.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.computedSet = computedSet;
const index_js_1 = require("../index.js");
function computedSet(source) {
return (0, index_js_1.computed)((oldValue) => {
const newValue = source.get();
if (oldValue?.size === newValue.size && [...oldValue].every(c => newValue.has(c))) {
return oldValue;
}
return newValue;
});
}

View File

@@ -0,0 +1,6 @@
import { Computed, ISignal } from '../index.js';
export declare function equalityComputed<T>(getter: () => T): ISignal<T>;
export declare class EqualityComputed<T = any> extends Computed<T> {
constructor(getter: () => T);
equals(a: any, b: any): boolean;
}

View File

@@ -0,0 +1,58 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EqualityComputed = void 0;
exports.equalityComputed = equalityComputed;
const index_js_1 = require("../index.js");
function equalityComputed(getter) {
return new EqualityComputed(getter);
}
class EqualityComputed extends index_js_1.Computed {
constructor(getter) {
super(oldValue => {
const newValue = getter();
if (this.equals(oldValue, newValue)) {
return oldValue;
}
return newValue;
});
}
equals(a, b) {
if (a === b) {
return true;
}
if (a === null || b === null || typeof a !== typeof b) {
return false;
}
if (typeof a === 'object') {
if (Array.isArray(a) && Array.isArray(b)) {
if (a.length !== b.length) {
return false;
}
for (let i = 0; i < a.length; i++) {
if (!this.equals(a[i], b[i])) {
return false;
}
}
return true;
}
if (!Array.isArray(a) && !Array.isArray(b)) {
for (const key in a) {
if (a.hasOwnProperty(key)) {
if (!b.hasOwnProperty(key) || !this.equals(a[key], b[key])) {
return false;
}
}
}
for (const key in b) {
if (b.hasOwnProperty(key) && !a.hasOwnProperty(key)) {
return false;
}
}
return true;
}
return false; // One is array and the other is not
}
return false;
}
}
exports.EqualityComputed = EqualityComputed;

4
node_modules/alien-signals/cjs/unstable/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
export * from './computedArray.js';
export * from './computedSet.js';
export * from './equalityComputed.js';
export * as Vue from './vue.js';

21
node_modules/alien-signals/cjs/unstable/index.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Vue = void 0;
__exportStar(require("./computedArray.js"), exports);
__exportStar(require("./computedSet.js"), exports);
__exportStar(require("./equalityComputed.js"), exports);
exports.Vue = require("./vue.js");

34
node_modules/alien-signals/cjs/unstable/vue.d.ts generated vendored Normal file
View File

@@ -0,0 +1,34 @@
import { Effect, EffectScope, Signal } from '../index.js';
export { EffectScope };
export declare function effect(fn: () => void): ReactiveEffect;
declare class VueEffectScope extends EffectScope {
onDispose: (() => void)[];
run<T>(fn: () => T): T;
stop(): void;
}
export declare function effectScope(): VueEffectScope;
export declare function triggerRef(ref: ShallowRef): void;
export declare function pauseTracking(): void;
export declare function resetTracking(): void;
export declare function shallowRef<T = any>(): ShallowRef<T | undefined>;
export declare function shallowRef<T = any>(oldValue: T): ShallowRef<T>;
export declare function computed<T>(options: {
get(): T;
set(value: T): void;
}): {
value: T;
};
export declare function computed<T>(fn: () => T): {
readonly value: T;
};
export declare function getCurrentScope(): VueEffectScope | undefined;
export declare class ShallowRef<T = any> extends Signal<T> {
get value(): T;
set value(value: T);
}
export declare class ReactiveEffect extends Effect {
get dirty(): boolean;
set scheduler(fn: () => void);
stop(): void;
}
export declare function onScopeDispose(cb: () => void): void;

118
node_modules/alien-signals/cjs/unstable/vue.js generated vendored Normal file
View File

@@ -0,0 +1,118 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReactiveEffect = exports.ShallowRef = exports.EffectScope = void 0;
exports.effect = effect;
exports.effectScope = effectScope;
exports.triggerRef = triggerRef;
exports.pauseTracking = pauseTracking;
exports.resetTracking = resetTracking;
exports.shallowRef = shallowRef;
exports.computed = computed;
exports.getCurrentScope = getCurrentScope;
exports.onScopeDispose = onScopeDispose;
const index_js_1 = require("../index.js");
Object.defineProperty(exports, "EffectScope", { enumerable: true, get: function () { return index_js_1.EffectScope; } });
function effect(fn) {
const e = new ReactiveEffect(fn);
e.run();
return e;
}
let currentEffectScope = undefined;
class VueEffectScope extends index_js_1.EffectScope {
constructor() {
super(...arguments);
this.onDispose = [];
}
run(fn) {
const prevScope = currentEffectScope;
currentEffectScope = this;
const res = super.run(fn);
currentEffectScope = prevScope;
return res;
}
stop() {
super.stop();
this.onDispose.forEach(cb => cb());
}
}
function effectScope() {
return new VueEffectScope();
}
function triggerRef(ref) {
if (ref.subs !== undefined) {
(0, index_js_1.startBatch)();
index_js_1.Dependency.propagate(ref.subs);
(0, index_js_1.endBatch)();
}
}
const pausedSubs = [];
function pauseTracking() {
pausedSubs.push(index_js_1.System.activeSub);
index_js_1.System.activeSub = undefined;
index_js_1.System.activeTrackId = -1;
}
function resetTracking() {
const prevSub = pausedSubs.pop();
index_js_1.System.activeSub = prevSub;
index_js_1.System.activeTrackId = prevSub.trackId;
}
function shallowRef(value) {
return new ShallowRef(value);
}
function computed(fn) {
if (typeof fn === 'function') {
return new VueComputed(fn);
}
else {
const { get, set } = fn;
const c = new VueComputed(get);
return {
get value() {
return c.get();
},
set value(value) {
set(value);
},
};
}
}
function getCurrentScope() {
return currentEffectScope;
}
class ShallowRef extends index_js_1.Signal {
get value() {
return this.get();
}
set value(value) {
this.set(value);
}
}
exports.ShallowRef = ShallowRef;
class VueComputed extends index_js_1.Computed {
get value() {
return this.get();
}
}
class ReactiveEffect extends index_js_1.Effect {
get dirty() {
if (this.dirtyLevel === 2 /* DirtyLevels.MaybeDirty */) {
index_js_1.Subscriber.resolveMaybeDirty(this);
}
return this.dirtyLevel === 3 /* DirtyLevels.Dirty */;
}
set scheduler(fn) {
this.notify = fn;
}
stop() {
if (this.deps !== undefined) {
index_js_1.Subscriber.clearTrack(this.deps);
this.deps = undefined;
this.depsTail = undefined;
}
this.dirtyLevel = 0 /* DirtyLevels.None */;
}
}
exports.ReactiveEffect = ReactiveEffect;
function onScopeDispose(cb) {
currentEffectScope?.onDispose.push(cb);
}