前端代码

This commit is contained in:
ChloeChen0423
2025-05-12 16:42:36 +09:00
commit 7c63f2f07b
4531 changed files with 656010 additions and 0 deletions

View File

@ -0,0 +1,17 @@
/// <reference path="./scheduler.ts" />
module Rx {
export interface ICurrentThreadScheduler extends IScheduler {
scheduleRequired(): boolean;
}
export interface SchedulerStatic {
currentThread: ICurrentThreadScheduler;
}
}
(function() {
var a: Rx.ICurrentThreadScheduler;
a.scheduleRequired();
a = Rx.Scheduler.currentThread;
})

View File

@ -0,0 +1,13 @@
/// <reference path="./scheduler.ts" />
module Rx {
export interface SchedulerStatic {
default: IScheduler;
async: IScheduler;
}
}
(function() {
var s : Rx.IScheduler;
s = Rx.Scheduler.async;
s = Rx.Scheduler.default;
})

View File

@ -0,0 +1,19 @@
/// <reference path="./virtualtimescheduler.ts" />
module Rx {
export interface HistoricalScheduler extends VirtualTimeScheduler<number, number> {
}
export var HistoricalScheduler: {
/**
* Creates a new historical scheduler with the specified initial clock value.
* @constructor
* @param {Number} initialClock Initial value for the clock.
* @param {Function} comparer Comparer to determine causality of events based on absolute time.
*/
new (initialClock: number, comparer: _Comparer<number, number>): HistoricalScheduler;
};
}
(function() {
var a: Rx.HistoricalScheduler = new Rx.HistoricalScheduler(1, (a, b) => 1);
})

View File

@ -0,0 +1,11 @@
/// <reference path="./scheduler.ts" />
module Rx {
export interface SchedulerStatic {
immediate: IScheduler;
}
}
(function() {
var s : Rx.IScheduler;
s = Rx.Scheduler.immediate;
})

42
node_modules/rx/ts/core/concurrency/scheduleditem.ts generated vendored Normal file
View File

@ -0,0 +1,42 @@
/// <reference path="./scheduler.ts" />
/// <reference path="../disposables/booleandisposable.ts" />
module Rx {
export module internals {
export interface ScheduledItem<TTime> {
scheduler: IScheduler;
state: TTime;
action: (scheduler: IScheduler, state: any) => IDisposable;
dueTime: TTime;
comparer: (x: TTime, y: TTime) => number;
disposable: SingleAssignmentDisposable;
invoke(): void;
compareTo(other: ScheduledItem<TTime>): number;
isCancelled(): boolean;
invokeCore(): IDisposable;
}
interface ScheduledItemStatic {
new <TTime>(scheduler: IScheduler, state: any, action: (scheduler: IScheduler, state: any) => IDisposable, dueTime: TTime, comparer?: _Comparer<TTime, number>):ScheduledItem<TTime>;
}
export var ScheduledItem: ScheduledItemStatic
}
}
(function() {
var item = new Rx.internals.ScheduledItem(Rx.Scheduler.default, {}, (sc, s) => Rx.Disposable.create(() => {}), 100);
var item = new Rx.internals.ScheduledItem(Rx.Scheduler.default, {}, (sc, s) => Rx.Disposable.create(() => {}), 100, (x, y) => 500);
item.scheduler
item.state;
item.action;
item.dueTime;
item.comparer;
item.disposable;
item.invoke();
var n: number = item.compareTo(item);
var b: boolean = item.isCancelled();
var d : Rx.IDisposable= item.invokeCore();
})

View File

@ -0,0 +1,20 @@
/// <reference path="./scheduler.ts" />
module Rx {
export module internals {
export interface SchedulePeriodicRecursive {
start(): IDisposable;
}
interface SchedulePeriodicRecursiveStatic {
new (scheduler: any, state: any, period: any, action: any) : SchedulePeriodicRecursive;
}
export var SchedulePeriodicRecursive: SchedulePeriodicRecursiveStatic;
}
}
(function() {
var item = new Rx.internals.SchedulePeriodicRecursive(undefined, undefined, undefined, undefined);
var d : Rx.IDisposable = item.start();
})

View File

@ -0,0 +1,19 @@
/// <reference path="../disposables/disposable.ts" />
module Rx {
export interface IScheduler {
/**
* Schedules a periodic piece of work by dynamically discovering the scheduler's capabilities. The periodic task will be scheduled using window.setInterval for the base implementation.
* @param {Mixed} state Initial state passed to the action upon the first iteration.
* @param {Number} period Period for running the work periodically.
* @param {Function} action Action to be executed, potentially updating the state.
* @returns {Disposable} The disposable object used to cancel the scheduled recurring action (best effort).
*/
schedulePeriodic<TState>(state: TState, period: number, action: (state: TState) => TState): IDisposable;
}
}
(function() {
var s : Rx.IScheduler;
var d : Rx.IDisposable = s.schedulePeriodic('state', 100, (s) => s);
})

View File

@ -0,0 +1,28 @@
/// <reference path="../disposables/disposable.ts" />
module Rx {
export interface IScheduler {
/**
* Schedules an action to be executed recursively.
* @param {Mixed} state State passed to the action to be executed.
* @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state.
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
*/
scheduleRecursive<TState>(state: TState, action: (state: TState, action: (state: TState) => void) => void): IDisposable;
/**
* Schedules an action to be executed recursively after a specified relative due time.
* @param {Mixed} state State passed to the action to be executed.
* @param {Function} action Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in the recursive due time and invocation state.
* @param {Number}dueTime Relative time after which to execute the action for the first time.
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
*/
scheduleRecursiveFuture<TState, TTime extends number | Date>(state: TState, dueTime: TTime, action: (state: TState, action: (state: TState, dueTime: TTime) => void) => void): IDisposable;
}
}
(function() {
var s: Rx.IScheduler;
var d: Rx.IDisposable = s.scheduleRecursive('state', (s, a) => Rx.Disposable.empty);
var d: Rx.IDisposable = s.scheduleRecursiveFuture('state', 100, (s, a) => Rx.Disposable.empty);
})

51
node_modules/rx/ts/core/concurrency/scheduler.ts generated vendored Normal file
View File

@ -0,0 +1,51 @@
/// <reference path="../disposables/disposable.ts" />
module Rx {
export interface IScheduler {
/** Gets the current time according to the local machine's system clock. */
now(): number;
/**
* Schedules an action to be executed.
* @param state State passed to the action to be executed.
* @param {Function} action Action to be executed.
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
*/
schedule<TState>(state: TState, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable;
/**
* Schedules an action to be executed after dueTime.
* @param state State passed to the action to be executed.
* @param {Function} action Action to be executed.
* @param {Number} dueTime Relative time after which to execute the action.
* @returns {Disposable} The disposable object used to cancel the scheduled action (best effort).
*/
scheduleFuture<TState>(state: TState, dueTime: number | Date, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable;
}
export interface SchedulerStatic {
/** Gets the current time according to the local machine's system clock. */
now(): number;
/**
* Normalizes the specified TimeSpan value to a positive value.
* @param {Number} timeSpan The time span value to normalize.
* @returns {Number} The specified TimeSpan value if it is zero or positive; otherwise, 0
*/
normalize(timeSpan: number): number;
/** Determines whether the given object is a scheduler */
isScheduler(s: any): boolean;
}
/** Provides a set of static properties to access commonly used schedulers. */
export var Scheduler: SchedulerStatic;
}
(function() {
var s: Rx.IScheduler;
var d: Rx.IDisposable = s.schedule('state', (sh, s ) => Rx.Disposable.empty);
var d: Rx.IDisposable = s.scheduleFuture('state', 100, (sh, s ) => Rx.Disposable.empty);
var n : () => number = Rx.Scheduler.now;
var a : number = Rx.Scheduler.normalize(1000);
})

View File

@ -0,0 +1,15 @@
/// <reference path="../disposables/disposable.ts" />
module Rx {
export interface IScheduler {
/**
* Returns a scheduler that wraps the original scheduler, adding exception handling for scheduled actions.
* @param {Function} handler Handler that's run if an exception is caught. The exception will be rethrown if the handler returns false.
* @returns {Scheduler} Wrapper around the original scheduler, enforcing exception handling.
*/
catch(handler: Function): IScheduler;
}
}
(function() {
var s : Rx.IScheduler = Rx.Scheduler.default.catch(() => {});
})

View File

@ -0,0 +1,82 @@
/// <reference path="../disposables/disposable.ts" />
/// <reference path="./scheduler.ts" />
/// <reference path="./scheduleditem.ts" />
module Rx {
export interface VirtualTimeScheduler<TAbsolute, TRelative> extends IScheduler {
/**
* Adds a relative time value to an absolute time value.
* @param {Number} absolute Absolute virtual time value.
* @param {Number} relative Relative virtual time value to add.
* @return {Number} Resulting absolute virtual time sum value.
*/
add(from: TAbsolute, by: TRelative): TAbsolute;
/**
* Converts an absolute time to a number
* @param {Any} The absolute time.
* @returns {Number} The absolute time in ms
*/
toAbsoluteTime(duetime: TAbsolute): number;
/**
* Converts the TimeSpan value to a relative virtual time value.
* @param {Number} timeSpan TimeSpan value to convert.
* @return {Number} Corresponding relative virtual time value.
*/
toRelativeTime(duetime: number): TRelative;
/**
* Starts the virtual time scheduler.
*/
start(): IDisposable;
/**
* Stops the virtual time scheduler.
*/
stop(): void;
/**
* Advances the scheduler's clock to the specified time, running all work till that point.
* @param {Number} time Absolute time to advance the scheduler's clock to.
*/
advanceTo(time: TAbsolute): void;
/**
* Advances the scheduler's clock by the specified relative time, running all work scheduled for that timespan.
* @param {Number} time Relative time to advance the scheduler's clock by.
*/
advanceBy(time: TRelative): void;
/**
* Advances the scheduler's clock by the specified relative time.
* @param {Number} time Relative time to advance the scheduler's clock by.
*/
sleep(time: TRelative): void;
isEnabled: boolean;
/**
* Gets the next scheduled item to be executed.
* @returns {ScheduledItem} The next scheduled item.
*/
getNext(): internals.ScheduledItem<TAbsolute>;
}
}
(function() {
interface TA { }
interface TR { }
var vts: Rx.VirtualTimeScheduler<TA, TR>;
var b: boolean = vts.isEnabled;
var a: TA = vts.add(100, 500);
var n: number = vts.toAbsoluteTime(1000);
var r: TR = vts.toRelativeTime(1000);
var d: Rx.IDisposable = vts.start();
vts.stop();
vts.advanceTo(<TA>null);
vts.advanceBy(<TR>null);
vts.sleep(<TR>null);
var i: Rx.internals.ScheduledItem<TA> = vts.getNext();
b = vts.isEnabled;
})