declare module 'mmstudio/interfaces' { export interface EventObject { type: string; } export interface Handle { destroy(): void; } export interface Hash { [ key: string ]: T; } } declare module 'mmstudio/lang' { import { Handle } from 'mmstudio/interfaces'; /** * 生成一个唯一标识ID * @function * @access public * @param {number} [len=36] 长度 * @param {number} [salt=62] 随机数 * @return {string} 生成唯一标识ID(不带-) */ export function uuid(len?: number, salt?: number): string; /** * Returns an object with a destroy method that, when called, calls the passed-in destructor. * This is intended to provide a unified interface for creating "remove" / "destroy" handlers for * event listeners, timers, etc. * * @param destructor A function that will be called when the handle's `destroy` method is invoked * @return The handle object */ export function createHandle(destructor: () => void): Handle; /** * Returns a single handle that can be used to destroy multiple handles simultaneously. * * @param handles An array of handles with `destroy` methods * @return The handle object */ export function create_composite_handle(...handles: Handle[]): Handle; export function deep_mixin(target: {}, ...sources: {}[]): any; export function mixin(target: {}, ...sources: {}[]): any; export function is_identical(a: any, b: any): boolean; export function is_array(it: any): boolean; export function is_string(it: any): boolean; export function duplicate(source: {}): {}; } declare module 'mmstudio/aspect' { import { Handle } from 'mmstudio/interfaces'; /** * Attaches "after" advice to be executed after the original method. * The advising function will receive the original method's return value and arguments object. * The value it returns will be returned from the method when it is called (even if the return value is undefined). * @param target Object whose method will be aspected * @param methodName Name of method to aspect * @param advice Advising function which will receive the original method's return value and arguments object * @return A handle which will remove the aspect when destroy is called */ export function after(target: any, methodName: string, advice: (originalReturn: any, originalArgs: IArguments) => any): Handle; /** * Attaches "around" advice around the original method. * @param target Object whose method will be aspected * @param methodName Name of method to aspect * @param advice Advising function which will receive the original function * @return A handle which will remove the aspect when destroy is called */ export function around(target: any, methodName: string, advice: (previous: Function) => Function): Handle; /** * Attaches "before" advice to be executed before the original method. * @param target Object whose method will be aspected * @param methodName Name of method to aspect * @param advice Advising function which will receive the same arguments as the original, and may return new arguments * @return A handle which will remove the aspect when destroy is called */ export function before(target: any, methodName: string, advice: (...originalArgs: any[]) => any[] | void): Handle; /** * Attaches advice to be executed after the original method. * The advising function will receive the same arguments as the original method. * The value it returns will be returned from the method when it is called *unless* its return value is undefined. * @param target Object whose method will be aspected * @param methodName Name of method to aspect * @param advice Advising function which will receive the same arguments as the original method * @return A handle which will remove the aspect when destroy is called */ export function on(target: any, methodName: string, advice: (...originalArgs: any[]) => any): Handle; } declare module 'mmstudio/Evented' { import { Handle, EventObject } from 'mmstudio/interfaces'; export default class Evented { /** * Emits an event, firing listeners registered for it. * @param event The event object to emit */ emit(data: T): void; /** * Listens for an event, calling the listener whenever the event fires. * @param type Event type to listen for * @param listener Callback to handle the event when it fires * @return A handle which will remove the listener when destroy is called */ on(type: string, listener: (event: EventObject) => void): Handle; } } declare module 'mmstudio/global' { const globalObject: any; export default globalObject; } declare module 'mmstudio/dom' { export function by_id(id: string | HTMLElement): HTMLElement; } declare module 'mmstudio/acme' { let query: (query: any, root: any) => any; export = query; } declare module 'mmstudio/has' { import { Hash } from 'mmstudio/interfaces'; export const cache: Hash; /** * Register a new test for a named feature. * * @example * has.add('dom-addeventlistener', !!document.addEventListener); * * @example * has.add('touch-events', function () { * return 'ontouchstart' in document * }); */ export function add(feature: string, value: any, overwrite?: boolean): void; /** * Return the current value of a named feature. * * @param feature The name (if a string) or identifier (if an integer) of the feature to test. * @return The value of a given feature test */ export default function has(feature: string): any; } declare module 'mmstudio/queue' { import { Handle } from 'mmstudio/interfaces'; export interface QueueItem { isActive: boolean; callback: (...args: any[]) => any; } /** * Schedules a callback to the macrotask queue. * * @param callback the function to be queued and later executed. * @returns An object with a `destroy` method that, when called, prevents the registered callback from executing. */ export const queueTask: (callback: (...args: any[]) => any) => Handle; /** * Schedules an animation task with `window.requestAnimationFrame` if it exists, or with `queueTask` otherwise. * * Since requestAnimationFrame's behavior does not match that expected from `queueTask`, it is not used there. * However, at times it makes more sense to delegate to requestAnimationFrame; hence the following method. * * @param callback the function to be queued and later executed. * @returns An object with a `destroy` method that, when called, prevents the registered callback from executing. */ export const queueAnimationTask: (callback: (...args: any[]) => any) => Handle; /** * Schedules a callback to the microtask queue. * * Any callbacks registered with `queueMicroTask` will be executed before the next macrotask. If no native * mechanism for scheduling macrotasks is exposed, then any callbacks will be fired before any macrotask * registered with `queueTask` or `queueAnimationTask`. * * @param callback the function to be queued and later executed. * @returns An object with a `destroy` method that, when called, prevents the registered callback from executing. */ export let queueMicroTask: (callback: (...args: any[]) => any) => Handle; } declare module 'mmstudio/promise' { /** * Executor is the interface for functions used to initialize a Promise. */ export interface Executor { (resolve: (value?: T | Thenable) => void, reject: (reason?: any) => void): void; } /** * Returns true if a given value has a `then` method. * @param {any} value The value to check if is Thenable * @returns {is Thenable} A type guard if the value is thenable */ export function isThenable(value: any): value is Thenable; /** * PromiseShim is a partial implementation of the ES2015 Promise specification. It relies on Promise to do some safety * checks such as verifying that a Promise isn't resolved with itself. This class is exported for testability, and is * not intended to be used directly. * * @borrows Promise.all as PromiseShim.all * @borrows Promise.race as PromiseShim.race * @borrows Promise.reject as PromiseShim.reject * @borrows Promise.resolve as PromiseShim.resolve * @borrows Promise#catch as PromiseShim#catch * @borrows Promise#then as PromiseShim#then */ export class PromiseShim implements Thenable { static all(items: (T | Thenable)[]): PromiseShim; static race(items: (T | Thenable)[]): PromiseShim; static reject(reason?: Error): PromiseShim; static resolve(): PromiseShim; static resolve(value: (T | Thenable)): PromiseShim; /** * Creates a new PromiseShim. * * @constructor * * @param executor * The executor function is called immediately when the PromiseShim is instantiated. It is responsible for * starting the asynchronous operation when it is invoked. * * The executor must call either the passed `resolve` function when the asynchronous operation has completed * successfully, or the `reject` function when the operation fails. */ constructor(executor: Executor); /** * The current state of this promise. */ private state; /** * The resolved value for this promise. * * @type {T|Error} */ private resolvedValue; then: (onFulfilled?: (value?: T) => (U | Thenable), onRejected?: (reason?: Error) => (U | Thenable)) => PromiseShim; } /** * PlatformPromise is a very thin wrapper around either a native promise implementation or PromiseShim. */ export default class Promise implements Thenable { /** * Points to the promise constructor this platform should use. */ static PromiseConstructor: any; /** * Converts an iterable object containing promises into a single promise that resolves to a new iterable object * containing the fulfilled values of all the promises in the iterable, in the same order as the Promises in the * iterable. Iterable values that are not promises are converted to promises using PromiseShim.resolve. * * @example * PromiseShim.all([ PromiseShim.resolve('foo'), 'bar' ]).then(function (value) { * value[0] === 'foo'; // true * value[1] === 'bar'; // true * }); * * @example * PromiseShim.all({ * foo: PromiseShim.resolve('foo'), * bar: 'bar' * }).then((value) => { * value.foo === 'foo'; // true * value.bar === 'bar'; // true * }); */ static all(items: (T | Thenable)[]): Promise; /** * Converts an iterable object containing promises into a single promise that resolves or rejects as soon as one of * the promises in the iterable resolves or rejects, with the value of the resolved or rejected promise. Values in * the iterable that are not Promises are converted to Promises with PromiseShim.resolve. * * @example * PromiseShim.race([ PromiseShim.resolve('foo'), PromiseShim.resolve('bar') ]).then((value) => { * value === 'foo'; // true * }); * * @example * PromiseShim.race({ * foo: PromiseShim.resolve('foo'), * bar: PromiseShim.resolve('bar') * }).then((value) => { * value === 'foo'; // true * }); */ static race(items: (T | Thenable)[]): Promise; /** * Creates a new promise that is rejected with the given error. */ static reject(reason: Error): Promise; /** * Creates a new promise that is resolved with the given value. If the passed value is already a PromiseShim, it * will be returned as-is. */ static resolve(): Promise; static resolve(value: (T | Thenable)): Promise; /** * Copies another Promise, taking on its inner state. */ protected static copy(other: Promise): Promise; /** * Creates a new Promise. * * @constructor * * @param executor * The executor function is called immediately when the PromiseShim is instantiated. It is responsible for * starting the asynchronous operation when it is invoked. * * The executor must call either the passed `resolve` function when the asynchronous operation has completed * successfully, or the `reject` function when the operation fails. */ constructor(executor: Executor); /** * An object wrapped by this class that actually implements the Promise API. */ private promise; /** * The internal state of this promise. This may be updated directly by subclasses. */ protected _state: State; /** * Adds a callback to the promise to be invoked when the asynchronous operation throws an error. */ catch(onRejected: (reason?: Error) => (U | Thenable)): Promise; /** * Allows for cleanup actions to be performed after resolution of a Promise. */ finally(callback: () => void | Thenable): Promise; /** * The current Promise state. */ state: State; /** * Adds a callback to the promise to be invoked when the asynchronous operation completes successfully. */ then(onFulfilled?: (value?: T) => (U | Thenable), onRejected?: (reason?: Error) => (U | Thenable)): Promise; } /** * The State enum represents the possible states of a promise. */ export enum State { Fulfilled = 0, Pending = 1, Rejected = 2, } /** * Thenable represents any object with a callable `then` property. */ export interface Thenable { then(onFulfilled?: (value?: T) => U | Thenable, onRejected?: (error?: any) => U | Thenable): Thenable; } } declare module 'mmstudio/async/Task' { import Promise, { Executor, State, Thenable } from 'mmstudio/promise'; export const Canceled: State; /** * Task is an extension of Promise that supports cancelation. */ export default class Task extends Promise { static all(items: (T | Thenable)[]): Task; static race(items: (T | Thenable)[]): Task; static reject(reason: Error): Task; static resolve(): Task; static resolve(value: (T | Thenable)): Task; protected static copy(other: Promise): Task; constructor(executor: Executor, canceler?: () => void); /** * A cancelation handler that will be called if this task is canceled. */ private canceler; /** * Children of this Task (i.e., Tasks that were created from this Task with `then` or `catch`). */ private children; /** * The finally callback for this Task (if it was created by a call to `finally`). */ private _finally; /** * Propagates cancelation down through a Task tree. The Task's state is immediately set to canceled. If a Thenable * finally task was passed in, it is resolved before calling this Task's finally callback; otherwise, this Task's * finally callback is immediately executed. `_cancel` is called for each child Task, passing in the value returned * by this Task's finally callback or a Promise chain that will eventually resolve to that value. */ private _cancel(finallyTask?); /** * Immediately cancels this task if it has not already resolved. This Task and any descendants are synchronously set * to the Canceled state and any `finally` added downstream from the canceled Task are invoked. */ cancel(): void; finally(callback: () => void | Thenable): Task; then(onFulfilled?: (value: T) => U | Thenable, onRejected?: (error: Error) => U | Thenable): Task; catch(onRejected: (reason?: Error) => (U | Thenable)): Task; } } declare module 'mmstudio/on' { import { Handle, EventObject } from 'mmstudio/interfaces'; import Evented from 'mmstudio/Evented'; export interface EventCallback { (event: EventObject): void; } export interface EventEmitter { on(event: string, listener: EventCallback): EventEmitter; removeListener(event: string, listener: EventCallback): EventEmitter; } /** * Provides a normalized mechanism for dispatching events for event emitters, Evented objects, or DOM nodes. * @param target The target to emit the event from * @param event The event object to emit * @return Boolean indicating Whether the event was canceled (this will always be false for event emitters) */ export function emit(target: Evented | EventTarget | EventEmitter, event: T | EventObject): boolean; /** * Provides a normalized mechanism for listening to events from event emitters, Evented objects, or DOM nodes. * @param target Target to listen for event on * @param type Event event type(s) to listen for; may a string or an array of strings * @param listener Callback to handle the event when it fires * @param capture Whether the listener should be registered in the capture phase (DOM events only) * @return A handle which will remove the listener when destroy is called */ export default function on(target: EventTarget, type: string | string[], listener: EventCallback, capture?: boolean): Handle; export default function on(target: EventEmitter | Evented, type: string | string[], listener: EventCallback): Handle; /** * Provides a mechanism for listening to the next occurrence of an event from event * emitters, Evented objects, or DOM nodes. * @param target Target to listen for event on * @param type Event event type(s) to listen for; may be a string or an array of strings * @param listener Callback to handle the event when it fires * @param capture Whether the listener should be registered in the capture phase (DOM events only) * @return A handle which will remove the listener when destroy is called */ export function once(target: EventTarget, type: string | string[], listener: EventCallback, capture?: boolean): Handle; export function once(target: EventEmitter | Evented, type: string | string[], listener: EventCallback): Handle; export interface PausableHandle extends Handle { pause(): void; resume(): void; } /** * Provides a mechanism for creating pausable listeners for events from event emitters, Evented objects, or DOM nodes. * @param target Target to listen for event on * @param type Event event type(s) to listen for; may a string or an array of strings * @param listener Callback to handle the event when it fires * @param capture Whether the listener should be registered in the capture phase (DOM events only) * @return A handle with additional pause and resume methods; the listener will never fire when paused */ export function pausable(target: EventTarget, type: string | string[], listener: EventCallback, capture?: boolean): PausableHandle; export function pausable(target: EventEmitter | Evented, type: string | string[], listener: EventCallback): PausableHandle; } declare module 'mmstudio/parser' { import Component = require('mmstudio/component'); import Promise from 'mmstudio/promise'; export function parse(root?: HTMLElement): Promise; } declare module 'mmstudio/dom-construct' { export function empty(node: HTMLElement | string): void; export function to_dom(frag: string): HTMLElement; export enum enum_position { before = 0, after = 1, replace = 2, only = 3, first = 4, } export function place(id: HTMLElement | string, ref: HTMLElement | string, position?: string | enum_position | number): HTMLElement; } declare module 'mmstudio/dom-attr' { export function get(node: string | HTMLElement, name: string): string; export function has(node: string | HTMLElement, name: string): boolean; export function set(node: string | HTMLElement, name: string, value: any): HTMLElement; export function remove(node: string | HTMLElement, name: string): void; } declare module 'mmstudio/query' { import { Handle } from 'mmstudio/interfaces'; export class NodeList { length: number; private parent; private loop_body(f, a, o); private adapt_as_for_each(f, o); private adapt_as_map(f, o); adapt_as_filter(f: any, o: any): (...args: any[]) => NodeList; private adapt_with_condition(f, g, o); constructor(array: HTMLElement[] | NodeList); private wrap(a, parent?); toString(): string; private stash(parent); on(eventName: string, listener: any): Handle; end(): NodeList; every(callback: any): any; some(callback: any): any; map(func: (el: HTMLElement, idx?: number) => T): NodeList; forEach(callback: (el: HTMLElement, idx?: number) => void): this; filter(filter: string | Function): NodeList; at(...idx: number[]): NodeList; slice(): void; splice(): void; } let query: (query: any, root: any) => any; export default query; } declare module 'mmstudio/view' { export enum enum_render_type { only_no_data = 0, only_has_data = 1, always = 2, } export interface IView_def { name: string; data: string; parent: string; loop: boolean; keywords: string[]; autorender: boolean; rendertype: enum_render_type; } import Data from 'mmstudio/data'; export default class View { private get_ref_node(p_name, domNode); render(domNode: HTMLElement, recursion?: boolean, position?: string | number): HTMLElement; private parent; private _parents; private _children; private tpl; private keywords; private autorender; private name; private loop; private rendertype; private def; private data; constructor(def: IView_def, tpl: string, data: Data); set_parent(parent: View): void; add_child(child: View): void; parents: View[]; private children; replace_field(): void; } } declare module 'mmstudio/component' { import Base, { IPV } from 'mmstudio/base'; import { Handle } from 'mmstudio/interfaces'; import { EventEmitter, EventCallback } from 'mmstudio/on'; import Promise from 'mmstudio/promise'; class Component extends Base implements EventEmitter { on(event: string, listener: EventCallback): EventEmitter; removeListener(event: string, listener: EventCallback): EventEmitter; protected tpl: string; protected _attachPoints: string[]; protected _attachEvents: Handle[]; id: string; private _onMap; protected domNode: HTMLElement; protected _startupWidgets: Component[]; private _events; private views; private build_views(defs); private state; private rule; create(params: { [attr: string]: any; }, tpl: string, node: HTMLElement, state: any, rule: string, def: IPV): Promise<{}>; private init_data(); private start_ai(); protected bind_events(): void; private fsm; protected bind_fsm_event(event: string | string[]): void; protected buildRendering(): Promise<{}>; private do_render(); private _attachTemplateNodes(); private _processTemplateNode(base_node, getAttrFunc?, attachFunc?); protected _attach(node: HTMLElement, type: string, func: any): Handle; protected destroyRendering(): void; destroy(): void; } export = Component; } declare module 'mmstudio/registry' { import Component = require('mmstudio/component'); import { Handle } from 'mmstudio/interfaces'; /** * A registry of values tagged with matchers. */ export default class Registry { protected _defaultValue: T; private _entries; /** * Construct a new Registry, optionally containing a given default value. */ constructor(defaultValue?: T); /** * Return the first entry in this registry that matches the given arguments. If no entry matches and the registry * was created with a default value, that value will be returned. Otherwise, an exception is thrown. * * @param ...args Arguments that will be used to select a matching value. * @returns the matching value, or a default value if one exists. */ match(...args: any[]): T; /** * Register a test + value pair with this registry. * * @param test The test that will be used to determine if the registered value matches a set of arguments. * @param value A value being registered. * @param first If true, the newly registered test and value will be the first entry in the registry. */ register(test: Test, value: T, first?: boolean): Handle; } /** * The interface that a test function must implement. */ export interface Test { (...args: any[]): boolean; } export function add(widget: Component): void; export function remove(id: string): void; export function by_id(id: string): Component; } declare module 'mmstudio/load' { import Promise from 'mmstudio/promise'; export interface AMDRequire { (moduleIds: string[], callback: (...modules: any[]) => void): void; } export interface NodeRequire { (moduleId: string): any; } export type Require = AMDRequire | NodeRequire; export interface Load { (require: Require, ...moduleIds: string[]): Promise; (...moduleIds: string[]): Promise; } const load: Load; export default load; } declare module 'mmstudio/urlsearchparams' { import { Hash } from 'mmstudio/interfaces'; /** * Object with string keys and string or string array values that describes a query string. */ export type ParamList = Hash; /** * Represents a set of URL query search parameters. */ export default class UrlSearchParams { /** * Constructs a new UrlSearchParams from a query string, an object of parameters and values, or another * UrlSearchParams. */ constructor(input?: string | ParamList | UrlSearchParams); /** * Maps property keys to arrays of values. The value for any property that has been set will be an array containing * at least one item. Properties that have been deleted will have a value of 'undefined'. */ protected _list: Hash; /** * Appends a new value to the set of values for a key. * @param key The key to add a value for * @param value The value to add */ append(key: string, value: string): void; /** * Deletes all values for a key. * @param key The key whose values are to be removed */ delete(key: string): void; /** * Returns the first value associated with a key. * @param key The key to return the first value for * @return The first string value for the key */ get(key: string): string; /** * Returns all the values associated with a key. * @param key The key to return all values for * @return An array of strings containing all values for the key */ getAll(key: string): string[]; /** * Returns true if a key has been set to any value, false otherwise. * @param key The key to test for existence * @return A boolean indicating if the key has been set */ has(key: string): boolean; /** * Returns an array of all keys which have been set. * @return An array of strings containing all keys set in the UrlSearchParams instance */ keys(): string[]; /** * Sets the value associated with a key. * @param key The key to set the value of */ set(key: string, value: string): void; /** * Returns this object's data as an encoded query string. * @return A string in application/x-www-form-urlencoded format containing all of the set keys/values */ toString(): string; } } declare module 'mmstudio/request' { import Task from 'mmstudio/async/Task'; import { Handle } from 'mmstudio/interfaces'; import Registry, { Test } from 'mmstudio/registry'; import { ParamList } from 'mmstudio/urlsearchparams'; export class FilterRegistry extends Registry { register(test: string | RegExp | RequestFilterTest, value: RequestFilter, first?: boolean): Handle; } export class ProviderRegistry extends Registry { private _providerPromise; constructor(); register(test: string | RegExp | RequestProviderTest, value: RequestProvider, first?: boolean): Handle; } /** * Request filters, which filter or modify responses. The default filter simply passes a response through unchanged. */ export const filterRegistry: FilterRegistry; /** * Request providers, which fulfill requests. */ export const providerRegistry: ProviderRegistry; export interface RequestError extends Error { response: Response; } export interface RequestFilter { (response: Response, url: string, options?: RequestOptions): T; } export interface RequestFilterTest extends Test { (response: Response, url: string, options?: RequestOptions): boolean; } export interface RequestOptions { auth?: string; cacheBust?: any; data?: any; handleAs?: string; headers?: { [name: string]: string; }; method?: string; password?: string; query?: string | ParamList; responseType?: string; timeout?: number; user?: string; } export interface RequestProvider { (url: string, options?: RequestOptions): ResponsePromise; } export interface RequestProviderTest extends Test { (url: string, options?: RequestOptions): boolean; } export interface Response { data: T; nativeResponse?: any; requestOptions: RequestOptions; statusCode: number; statusText?: string; url: string; getHeader(name: string): string; } /** * The task returned by a request, which will resolve to a Response */ export interface ResponsePromise extends Task> { } const request: { (url: string, options?: RequestOptions): ResponsePromise; delete(url: string, options?: RequestOptions): ResponsePromise; get(url: string, options?: RequestOptions): ResponsePromise; post(url: string, options?: RequestOptions): ResponsePromise; put(url: string, options?: RequestOptions): ResponsePromise; }; export default request; } declare module 'mmstudio/data' { import { Hash } from 'mmstudio/interfaces'; export enum enum_param_relation { and = 0, or = 1, } export enum enum_param_op { _in = 0, not_in = 1, like = 2, not_like = 3, contains = 4, } export interface ICondition { op: enum_param_op; name: string; value: string | number | boolean | IParam; } export interface IParam { rel: enum_param_relation; conditions: ICondition[]; } export interface IData_def { name: string; modelid: string; editable: boolean; table_name: string; param: IParam; sort: Hash; paging_size: number; paging_index: number; auto_load_data: boolean; } import Promise from 'mmstudio/promise'; export default class Data { row_count: number; private def; auto_load_data: boolean; private data; load_data(): Promise<{}>; constructor(def: IData_def); } } declare module 'mmstudio/base' { import { Hash } from 'mmstudio/interfaces'; import Data, { IData_def } from 'mmstudio/data'; import { IView_def } from 'mmstudio/view'; export interface IPV { dts_def: IData_def[]; views_def: IView_def[]; } export default class Base { protected pv: IPV; protected dts: Hash; protected build_dts(defs: IData_def[]): void; } } declare module 'mmstudio/defines/feedback' { export default class Feedback { flag: boolean; msg: any; constructor(flag?: boolean, msg?: any); } } declare module 'mmstudio/defines/oav' { export interface Ioav { o: string; a: string; v: any; } export default class OAV implements Ioav { o: string; a: string; v: any; constructor(o: string, a: string, v?: any); } } declare module 'mmstudio/ai' { import Base from 'mmstudio/base'; import { Hash } from 'mmstudio/interfaces'; import * as nools from 'nools'; import * as StateMachine from 'state-machine'; export interface IFsmState { transitions: StateMachine.StateMachineEventDef[]; events?: Hash; states?: Hash<{ guard: string[]; exit: string[]; entry: string[]; do: string[]; done: string[]; }>; } export interface iscope { flow: nools.Session; me: Base; fsm: StateMachine.StateMachine; mm: ai_component | ai__service; } export interface ai_component { constructor(scope: iscope): any; } export interface ai__service { constructor(scope: iscope): any; } export default function ai(me: Base, rules: any, status: IFsmState, is_component: boolean): any; } declare module 'mmstudio/number' { export const EPSILON: number; export const MAX_SAFE_INTEGER: number; export const MIN_SAFE_INTEGER: number; export function is_nan(value: any): boolean; export function is_finite(value: any): boolean; export function is_integer(value: any): boolean; export function is_safe_integer(value: any): boolean; } declare module 'mmstudio/array' { export interface ArrayLike { length: number; [n: number]: T; } export interface MapCallback { (element: T, index: number): T; } export interface FindCallback { (element: T, index: number, array: ArrayLike): boolean; } export function from(arrayLike: string, mapFunction?: MapCallback, thisArg?: {}): ArrayLike; export function from(arrayLike: ArrayLike, mapFunction?: MapCallback, thisArg?: {}): ArrayLike; export function of(...items: any[]): any[]; /** * Fills elements of an array-like object with the specified value. * * @param target The target to fill * @param value The value to fill each element of the target with * @param [start] The first index to fill * @param [end] The (exclusive) index at which to stop filling * @return The filled target */ export function fill(target: ArrayLike, value: any, start?: number, end?: number): ArrayLike; /** * Performs a linear search and returns the first index whose value satisfies the passed callback, * or -1 if no values satisfy it. * * @param target An array-like object * @param callback A function returning true if the current value satisfies its criteria * @param [thisArg] The execution context for the find function * @return The first index whose value satisfies the passed callback, or -1 if no values satisfy it */ export function findIndex(target: ArrayLike, callback: FindCallback, thisArg?: {}): number; /** * Finds and returns the first instance matching the callback or undefined if one is not found. * * @param target An array-like object * @param callback A function returning if the current value matches a criteria * @param [thisArg] The execution context for the find function * @return The first element matching the callback, or undefined if one does not exist */ export function find(target: ArrayLike, callback: FindCallback, thisArg?: {}): T; /** * Copies data internally within an array or array-like object. * * @param target The target array-like object * @param offset The index to start copying values to; if negative, it counts backwards from length * @param start The first (inclusive) index to copy; if negative, it counts backwards from length * @param end The last (exclusive) index to copy; if negative, it counts backwards from length * @return The target */ export function copyWithin(target: ArrayLike, offset: number, start?: number, end?: number): ArrayLike; } declare module 'mmstudio/async/iteration' { import Promise, { Thenable } from 'mmstudio/promise'; /** * Test whether all elements in the array pass the provided callback * @param items a collection of synchronous/asynchronous values * @param callback a synchronous/asynchronous test * @return eventually returns true if all values pass; otherwise false */ export function every(items: (T | Promise)[], callback: Filterer): Promise; /** * Returns an array of elements which pass the provided callback * @param items a collection of synchronous/asynchronous values * @param callback a synchronous/asynchronous test * @return eventually returns a new array with only values that have passed */ export function filter(items: (T | Promise)[], callback: Filterer): Promise; /** * Find the first value matching a filter function * @param items a collection of synchronous/asynchronous values * @param callback a synchronous/asynchronous test * @return a promise eventually containing the item or undefined if a match is not found */ export function find(items: (T | Promise)[], callback: Filterer): Promise; /** * Find the first index with a value matching the filter function * @param items a collection of synchronous/asynchronous values * @param callback a synchronous/asynchronous test * @return a promise eventually containing the index of the matching item or -1 if a match is not found */ export function findIndex(items: (T | Promise)[], callback: Filterer): Promise; /** * transform a list of items using a mapper function * @param items a collection of synchronous/asynchronous values * @param callback a synchronous/asynchronous transform function * @return a promise eventually containing a collection of each transformed value */ export function map(items: (T | Promise)[], callback: Mapper): Promise; /** * reduce a list of items down to a single value * @param items a collection of synchronous/asynchronous values * @param callback a synchronous/asynchronous reducer function * @param [initialValue] the first value to pass to the callback * @return a promise eventually containing a value that is the result of the reduction */ export function reduce(items: (T | Promise)[], callback: Reducer, initialValue?: U): Promise; export function reduceRight(items: (T | Promise)[], callback: Reducer, initialValue?: U): Promise; export function series(items: (T | Promise)[], operation: Mapper): Promise; export function some(items: Array>, callback: Filterer): Promise; export interface Filterer extends Mapper { } export interface Mapper { (value: T, index: number, array: T[]): (U | Thenable); } export interface Reducer { (previousValue: U, currentValue: T, index: number, array: T[]): (U | Thenable); } } declare module 'mmstudio/async/timing' { import Promise from 'mmstudio/promise'; /** * Used for delaying a Promise chain for a specific number of milliseconds. * * @param milliseconds the number of milliseconds to delay * @return {function(T): Promise} a function producing a promise that eventually returns the value passed to it; usable with Thenable.then() */ export function delay(milliseconds: number): Identity; export interface Identity { (value: T): Promise; } /** * Reject a promise chain if a result hasn't been found before the timeout * * @param milliseconds after this number of milliseconds a rejection will be returned * @param reason The reason for the rejection * @return {function(T): Promise} a function that produces a promise that is rejected or resolved based on your timeout */ export function timeout(milliseconds: number, reason: Error): Identity; /** * A Promise that will reject itself automatically after a time. * Useful for combining with other promises in Promise.race. */ export class DelayedRejection extends Promise { /** * @param milliseconds the number of milliseconds to wait before triggering a rejection * @param reason the reason for the rejection */ constructor(milliseconds: number, reason?: Error); } } declare module 'mmstudio/math' { /** * Returns the hyperbolic arccosine of a number. * * @param n The number to use in calculation * @return The result */ export function acosh(n: number): number; /** * Returns the hyperbolic arcsine of a number. * * @param n The number to use in calculation * @return The result */ export function asinh(n: number): number; /** * Returns the hyperbolic arctangent of a number. * * @param n The number to use in calculation * @return The result */ export function atanh(n: number): number; /** * Returns the cube root of a number. * * @param n The number to use in calculation * @return The result */ export function cbrt(n: number): number; /** * Returns the number of leading zero bits in the 32-bit * binary representation of a number. * * @param n The number to use in calculation * @return The result */ export function clz32(n: number): number; /** * Returns the hyperbolic cosine of a number. * * @param n The number to use in calculation * @return The result */ export function cosh(n: number): number; /** * Returns e raised to the specified power minus one. * * @param n The number to use in calculation * @return The result */ export function expm1(n: number): number; /** * Returns the nearest single-precision float representation of a number. * * @param n The number to use in calculation * @return The result */ export const fround: (n: number) => number; /** * Returns the square root of the sum of squares of its arguments. * * @return The result */ export function hypot(...args: number[]): number; /** * Returns the result of the 32-bit multiplication of the two parameters. * * @param n The number to use in calculation * @param m The number to use in calculation * @return The result */ export function imul(n: number, m: number): number; /** * Returns the base 2 logarithm of a number. * * @param n The number to use in calculation * @return The result */ export function log2(n: number): number; /** * Returns the base 10 logarithm of a number. * * @param n The number to use in calculation * @return The result */ export function log10(n: number): number; /** * Returns the natural logarithm of 1 + a number. * * @param n The number to use in calculation * @return The result */ export function log1p(n: number): number; /** * Returns the sign of a number, indicating whether the number is positive. * * @param n The number to use in calculation * @return 1 if the number is positive, -1 if the number is negative, or 0 if the number is 0 */ export function sign(n: number): number; /** * Returns the hyperbolic sine of a number. * * @param n The number to use in calculation * @return The result */ export function sinh(n: number): number; /** * Returns the hyperbolic tangent of a number. * * @param n The number to use in calculation * @return The result */ export function tanh(n: number): number; /** * Returns the integral part of a number by removing any fractional digits. * * @param n The number to use in calculation * @return The result */ export function trunc(n: number): number; } declare module 'mmstudio/object' { /** * Determines whether two values are the same value. * @return true if the values are the same; false otherwise */ export function is(value1: any, value2: any): boolean; } declare module 'mmstudio/params' { export interface params { param: { [name: string]: string | number | boolean; }; paging: { index?: number; size?: number; }; sort: { [name: string]: string | number | boolean; }; } export function init_params(): params; /** * 设置当前分页页码 * @param {number} index 页码 */ export function chang_paging_index(params: params): Function; /** * 设置分页大小,默认12 * @param {number} size */ export function set_paging_size(params: params): Function; /** * 设置分页大小,默认12 * @param {number} size */ export function add_sort(params: params): Function; export function add_param(params: params): Function; } declare module 'mmstudio/request/errors/RequestTimeoutError' { import { RequestError, Response } from 'mmstudio/request'; export default class RequestTimeoutError implements RequestError { message: string; name: string; response: Response; constructor(message?: string); } } declare module 'mmstudio/request/util' { import { RequestOptions } from 'mmstudio/request'; /** * Returns a URL formatted with optional query string and cache-busting segments. * * @param url The base URL. * @param options The options hash that is used to generate the query string. */ export function generateRequestUrl(url: string, options: RequestOptions): string; } declare module 'mmstudio/util' { import { Handle } from 'mmstudio/interfaces'; /** * Wraps a setTimeout call in a handle, allowing the timeout to be cleared by calling destroy. * * @param callback Callback to be called when the timeout elapses * @param delay Number of milliseconds to wait before calling the callback * @return Handle which can be destroyed to clear the timeout */ export function createTimer(callback: (...args: any[]) => void, delay?: number): Handle; /** * Wraps a callback, returning a function which fires after no further calls are received over a set interval. * * @param callback Callback to wrap * @param delay Number of milliseconds to wait after any invocations before calling the original callback * @return Debounced function */ export function debounce void>(callback: T, delay: number): T; /** * Wraps a callback, returning a function which fires at most once per set interval. * * @param callback Callback to wrap * @param delay Number of milliseconds to wait before allowing the original callback to be called again * @return Throttled function */ export function throttle void>(callback: T, delay: number): T; /** * Like throttle, but calls the callback at the end of each interval rather than the beginning. * Useful for e.g. resize or scroll events, when debounce would appear unresponsive. * * @param callback Callback to wrap * @param delay Number of milliseconds to wait before calling the original callback and allowing it to be called again * @return Throttled function */ export function throttleAfter void>(callback: T, delay: number): T; } declare module 'mmstudio/request/xhr' { import { RequestOptions, ResponsePromise } from 'mmstudio/request'; export interface XhrRequestOptions extends RequestOptions { blockMainThread?: boolean; } export default function xhr(url: string, options?: XhrRequestOptions): ResponsePromise; } declare module 'mmstudio/streams/interfaces' { export interface Strategy { /** * Computes the number of items in a chunk. */ size?: (chunk: T) => number; /** * The number of chunks allowed in the queue before backpressure is applied. */ highWaterMark?: number; } } declare module 'mmstudio/streams/SizeQueue' { /** * This class is used internally by {@link ReadableStream} and {@link WritableStream} as a simple queue. * Each value in the queue includes a piece of metadata: the size of the value. */ export default class SizeQueue { totalSize: number; length: number; private _queue; empty(): void; enqueue(value: T, size: number): void; dequeue(): T; peek(): T; } } declare module 'mmstudio/streams/util' { import { Strategy } from 'mmstudio/streams/interfaces'; import Promise from 'mmstudio/promise'; export function getApproximateByteSize(object: any): number; /** * Calls the method or returns undefined. */ export function invokeOrNoop(O: any, P: string, args?: any[]): any; export function normalizeStrategy({size, highWaterMark}: Strategy): Strategy; export function promiseInvokeOrFallbackOrNoop(object: any, method1: string, args1: any[], method2: string, args2?: any[]): Promise; /** * Returns a promise that resolves the with result of the method call or undefined. */ export function promiseInvokeOrNoop(O: any, P: string, args?: any[]): Promise; } declare module 'mmstudio/streams/WritableStream' { import { Strategy } from 'mmstudio/streams/interfaces'; import Promise from 'mmstudio/promise'; import SizeQueue from 'mmstudio/streams/SizeQueue'; export interface Record { close?: boolean; chunk?: T; reject?: (error: Error) => void; resolve?: () => void; } /** * WritableStream's possible states */ export enum State { Closed = 0, Closing = 1, Errored = 2, Waiting = 3, Writable = 4, } /** * The Sink interface defines the methods a module can implement to create a target sink for a `WritableStream`. * * The Stream API provides a consistent stream API while `ReadableStream.Source` and `WritableStream.Sink` implementors * provide the logic to connect a stream to specific data sources & sinks. */ export interface Sink { /** * Indicates the stream is prematurely closing due to an error. The sink should do any necessary cleanup * and release resources. When a stream calls `abort` it will discard any queued chunks. If the sink does not * provide an `abort` method then the stream will call `close` instead. * * @param reason The reason the stream is closing. */ abort?(reason?: any): Promise; /** * Indicates the stream is closing. The sink should do any necessary cleanup and release resources. The stream * will not call this method until is has successfully written all queued chunks. */ close?(): Promise; /** * Requests the sink to prepare for receiving chunks. * * @param error An error callback that can be used at any time by the sink to indicate an error has occurred. * @returns A promise that resolves when the sink's start operation has finished. If the promise rejects, * the stream will be errored. */ start?(error: (error: Error) => void): Promise; /** * Requests the sink write a chunk. * * @param chunk The chunk to be written. * @returns A promise that resolves when the sink's write operation has finished. If the promise rejects, * the stream will be errored. */ write?(chunk: T): Promise; } /** * This class provides a writable stream implementation. Data written to a stream will be passed on to the underlying * sink (`WritableStream.Sink`), an instance of which must be supplied to the stream upon instantation. This class * provides the standard stream API, while implementations of the `Sink` API allow the data to be written to * various persistence layers. */ export default class WritableStream { /** * @returns A promise that is resolved when the stream is closed, or is rejected if the stream errors. */ closed: Promise; /** * @returns A promise that is resolved when the stream transitions away from the 'waiting' state. The stream will * use this to indicate backpressure - an unresolved `ready` promise indicates that writes should not yet be * performed. */ ready: Promise; /** * @returns The stream's current @State */ state: State; protected _advancing: boolean; protected _closedPromise: Promise; protected _readyPromise: Promise; protected _rejectClosedPromise: (error: Error) => void; protected _rejectReadyPromise: (error: Error) => void; protected _resolveClosedPromise: () => void; protected _resolveReadyPromise: () => void; protected _started: boolean; protected _startedPromise: Promise; protected _state: State; protected _storedError: Error; protected _strategy: Strategy; protected _underlyingSink: Sink; protected _queue: SizeQueue>; protected _writing: boolean; constructor(underlyingSink?: Sink, strategy?: Strategy); protected _advanceQueue(): void; protected _close(): void; protected _error(error: Error): void; protected _syncStateWithQueue(): void; /** * Signals that the producer can no longer write to the stream and it should be immediately moved to an "errored" * state. Any un-written data that is queued will be discarded. */ abort(reason: any): Promise; /** * Signals that the producer is done writing to the stream and wishes to move it to a "closed" state. The stream * may have un-writted data queued; until the data has been written the stream will remain in the "closing" state. */ close(): Promise; /** * Enqueue a chunk of data to be written to the underlying sink. `write` can be called successively without waiting * for the previous write's promise to resolve. To respect the stream's backpressure indicator, check if the stream * has entered the "waiting" state between writes. * * @returns A promise that will be fulfilled when the chunk has been written to the underlying sink. */ write(chunk: T): Promise; } } declare module 'mmstudio/streams/ArraySink' { import Promise from 'mmstudio/promise'; import { Sink } from 'mmstudio/streams/WritableStream'; /** * A WritableStream sink that collects the chunks it receives and * stores them into an array. Use the chunks property to retrieve * the collection of chunks. */ export default class ArraySink implements Sink { chunks: T[]; abort(reason: any): Promise; close(): Promise; start(error: () => void): Promise; write(chunk: T): Promise; } } declare module 'mmstudio/streams/ReadableStreamController' { import ReadableStream from 'mmstudio/streams/ReadableStream'; export function isReadableStreamController(x: any): boolean; export default class ReadableStreamController { private _controlledReadableStream; /** * Returns a number indicating how much additional data can be pushed by the source to the stream's queue before it * exceeds its `highWaterMark`. An underlying source should use this information to determine when and how to apply * backpressure. * * @returns The stream's strategy's `highWaterMark` value minus the queue size */ desiredSize: number; constructor(stream: ReadableStream); /** * A source should call this method when it has no more data to provide. After this method is called, the stream * will provided any queued data to the reader, but once the stream's queue is exhausted the stream will be closed * and no more data can be read from it. */ close(): void; /** * A source should call this method to provide data to the stream. * * @param chunk The data to provide to the stream */ enqueue(chunk: T): void; /** * A source should call this method to indicate an error condition to the stream that irreparably disrupts the * source's (and thus the stream's) ability to provide all the intended data. * * @param error An error object representing the error condition in the source */ error(error: Error): void; } } declare module 'mmstudio/streams/ReadableStreamReader' { import Promise from 'mmstudio/promise'; import ReadableStream, { State } from 'mmstudio/streams/ReadableStream'; /** * Represents the objects returned by {@link ReadableStreamReader#read}. The data is accessible on the `value` property. * If the `done` property is true, the stream has no more data to provide. */ export interface ReadResult { value: T; done: boolean; } /** * This class provides the interface for reading data from a stream. A reader can by acquired by calling * {@link ReadableStream#getReader}. A {@link ReadableStream} can only have a single reader at any time. A reader can * be released from the stream by calling {@link ReadableStreamReader.releaseLock}. If the stream still has data, a new * reader can be acquired to read from the stream. */ export default class ReadableStreamReader { closed: Promise; private _closedPromise; private _storedError; private _readRequests; private _resolveClosedPromise; private _rejectClosedPromise; protected _ownerReadableStream: ReadableStream; state: State; constructor(stream: ReadableStream); /** * Cancel a stream. The reader is released and the stream is closed. {@link ReadableStream.Source#cancel} is * called with the provided `reason`. * * @param reason The reason for canceling the stream */ cancel(reason: string): Promise; /** * Read data from the stream. * * @returns A promise that resolves to a {@link ReadResult}. */ read(): Promise>; /** * Release a reader's lock on the corresponding stream. The reader will no longer be readable. Further reading on * the stream can be done by acquiring a new `ReadableStreamReader`. */ releaseLock(): void; release(): void; /** * Resolves a pending read request, if any, with the provided chunk. * @param chunk * @return boolean True if a read request was resolved. */ resolveReadRequest(chunk: T): boolean; } } declare module 'mmstudio/streams/TransformStream' { import { Strategy } from 'mmstudio/streams/interfaces'; import ReadableStream from 'mmstudio/streams/ReadableStream'; import WritableStream from 'mmstudio/streams/WritableStream'; /** * The `Transform` interface defines the requirements for a transform object to be supplied to a * {@link TransformStream} instance. */ export interface Transform { /** * The `transform` method should accept a chunk, an `enqueueInReadable` function, and a `transformDone` function. * The chunk is the data to be transformed. The transform function should perform any transform logic on the chunk * and then call the supplied `enqueueInReadable` function, passing it the transformed data. After that it should * call the supplied `transformDone` function to notify the `TransformStream` that transformation is complete. */ transform(chunk: W, enqueueInReadable: (chunk: R) => void, transformDone: () => void): void; /** * The `flush` method will be called by the `TransformStream` when its {@link WritableStream} is closed. Any logic * the transformer may wish to run when the stream is closed can be supplied in this function. Any pending data * can still be enqueued using the supplied `enqueue` function. When the transformer has finished transforming all * data and is ready to close the {@link ReadableStream} it should call the supplied `close` function. */ flush(enqueue: Function, close: Function): void; /** * If supplied, this strategy will be used for the `Transformer`'s internal {@link ReadableStream} */ readableStrategy: Strategy; /** * If supplied, this strategy will be used for the `Transformer`'s internal {@link WritableStream} */ writableStrategy: Strategy; } /** * A `TransformStream` is both readable and writable. Its purpose is to apply some transform logic to everything that * is written to it and provide the transformed data via its reader. As such, it requires no `ReadableStream`, * `WritableStream`, or `Source` or `Sink` to be supplied - it provides its own. * * It does require an object that implements the {@link Transform} interface to be supplied. The `transform` method * will be applied to all data written to the stream. * * The readable stream API is available via the `TransformStream`'s `readable` property, which is a * {@link ReadableStream}. The writable stream API is available via the `TransformStream`'s `writable` property, which * is a {@link WritableStream}. */ export default class TransformStream { readable: ReadableStream; writable: WritableStream; constructor(transformer: Transform); } } declare module 'mmstudio/streams/ReadableStream' { import { Strategy } from 'mmstudio/streams/interfaces'; import Promise from 'mmstudio/promise'; import ReadableStreamController from 'mmstudio/streams/ReadableStreamController'; import ReadableStreamReader from 'mmstudio/streams/ReadableStreamReader'; import SizeQueue from 'mmstudio/streams/SizeQueue'; import TransformStream from 'mmstudio/streams/TransformStream'; import WritableStream from 'mmstudio/streams/WritableStream'; /** * Options used when piping a readable stream to a writable stream. */ export interface PipeOptions { /** * Prevents the writable stream from erroring if the readable stream encounters an error. */ preventAbort?: boolean; /** * Prevents the readable stream from erroring if the writable stream encounters an error. */ preventCancel?: boolean; /** * Prevents the writable stream from closing when the pipe operation completes. */ preventClose?: boolean; } /** * The Source interface defines the methods a module can implement to create a source for a {@link ReadableStream}. * * The Stream API provides a consistent stream API while {@link ReadableStream.Source} and {@link WritableStream.Sink} * implementations provide the logic to connect a stream to specific data sources & sinks. */ export interface Source { /** * Tells the source to prepare for providing chunks to the stream. While the source may enqueue chunks at this * point, it is not required. * * @param controller The source can use the controller to enqueue chunks, close the stream or report an error. * @returns A promise that resolves when the source's start operation has finished. If the promise rejects, * the stream will be errored. */ start?(controller: ReadableStreamController): Promise; /** * Requests that source enqueue chunks. Use the controller to close the stream when no more chunks can * be provided. * * @param controller The source can use the controller to enqueue chunks, close the stream or report an error. * @returns A promise that resolves when the source's pull operation has finished. If the promise rejects, * the stream will be errored. */ pull?(controller: ReadableStreamController): Promise; /** * Optional method implemented by seekable sources to set the seek position. Use the controller to report an error. * @param controller The source can use the controller to report an error. * @param position The position in the stream to seek to. * @returns A promise that resolves to the new seek position when the source's seek operation has finished. If the * promise rejects, the stream will be errored. */ seek?(controller: ReadableStreamController, position: number): Promise; /** * Indicates the stream is prematurely closing and allows the source to do any necessary clean up. * * @param reason The reason why the stream is closing. * @returns A promise that resolves when the source's pull operation has finished. If the promise rejects, * the stream will be errored. */ cancel?(reason?: any): Promise; } /** * `ReadableStream`'s possible states */ export enum State { Readable = 0, Closed = 1, Errored = 2, } /** * Implementation of a readable stream. */ export default class ReadableStream { protected _allowPull: boolean; /** * Returns a number indicating how much additional data can be pushed by the source to the stream's queue before it * exceeds its `highWaterMark`. An underlying source should use this information to determine when and how to apply * backpressure. * * @returns The stream's strategy's `highWaterMark` value minus the queue size */ desiredSize: number; hasSource: boolean; /** * A stream can only have one reader at a time. This value indicates if a stream already has a reader, and hence * cannot be read from other than by that reader. When a consumer is done with a reader they can dissociate it * by calling {@link ReadableStreamReader#releaseLock}. * * @returns True if the stream has a reader associated with it */ locked: boolean; readable: boolean; /** * This promise will resolve when the stream's underlying source has started and is ready to provide data. If * the {@link ReadableStreamReader#read} method is called before the stream has started it will not do anything. * Wait for this promise to resolve to ensure that your `read` calls are responded to as promptly as possible. * * @returns A promise that resolves when the stream is ready to be read from. */ started: Promise; queueSize: number; protected _pullingPromise: Promise; protected _started: boolean; protected _startedPromise: Promise; protected _strategy: Strategy; protected _underlyingSource: Source; closeRequested: boolean; controller: ReadableStreamController; pullScheduled: boolean; queue: SizeQueue; reader: ReadableStreamReader; state: State; storedError: Error; /** * A `ReadableStream` requires an underlying source to supply data. The source interacts with the stream through * a {@link ReadableStreamController} that is associated with the stream, and provided to the source. * * @constructor * @param underlyingSource The source object that supplies data to the stream by interacting with its controller. * @param strategy The strategy for this stream. */ constructor(underlyingSource: Source, strategy?: Strategy); protected _cancel(reason?: any): Promise; protected _shouldApplyBackPressure(): boolean; /** * * @param reason A description of the reason the stream is being canceled. * @returns A promise that resolves when the stream has closed and the call to the underlying source's `cancel` * method has completed. */ cancel(reason?: any): Promise; /** * Closes the stream without regard to the status of the queue. Use {@link requestClose} to close the * stream and allow the queue to flush. * */ close(): void; enqueue(chunk: T): void; error(error: Error): void; /** * create a new {@link ReadableStreamReader} and lock the stream to the new reader */ getReader(): ReadableStreamReader; pipeThrough(transformStream: TransformStream, options?: PipeOptions): ReadableStream; pipeTo(dest: WritableStream, options?: PipeOptions): Promise; pull(): void; /** * Requests the stream be closed. This method allows the queue to be emptied before the stream closes. * */ requestClose(): void; /** * Tee a readable stream, returning a two-element array containing * the two resulting ReadableStream instances */ tee(): [ReadableStream, ReadableStream]; } } declare module 'mmstudio/streams/ArraySource' { import Promise from 'mmstudio/promise'; import { Source } from 'mmstudio/streams/ReadableStream'; import ReadableStreamController from 'mmstudio/streams/ReadableStreamController'; /** * A seekable array source */ export default class ArraySource implements Source { currentPosition: number; data: Array; constructor(data: Array); seek(controller: ReadableStreamController, position: number): Promise; start(controller: ReadableStreamController): Promise; pull(controller: ReadableStreamController): Promise; cancel(reason?: any): Promise; } } declare module 'mmstudio/streams/QueuingStrategy' { import { Strategy } from 'mmstudio/streams/interfaces'; export default class QueuingStrategy implements Strategy { highWaterMark: number; constructor(kwArgs: KwArgs); } export interface KwArgs { highWaterMark: number; } } declare module 'mmstudio/streams/ByteLengthQueuingStrategy' { import QueuingStrategy from 'mmstudio/streams/QueuingStrategy'; export default class ByteLengthQueuingStrategy extends QueuingStrategy { size(chunk: T): number; } } declare module 'mmstudio/streams/CountQueuingStrategy' { import QueuingStrategy from 'mmstudio/streams/QueuingStrategy'; export default class CountQueuingStrategy extends QueuingStrategy { size(chunk: T): number; } } declare module 'mmstudio/streams/SeekableStreamReader' { import Promise from 'mmstudio/promise'; import ReadableStreamReader, { ReadResult } from 'mmstudio/streams/ReadableStreamReader'; import SeekableStream from 'mmstudio/streams/SeekableStream'; export default class SeekableStreamReader extends ReadableStreamReader { protected _currentPosition: number; protected _ownerReadableStream: SeekableStream; currentPosition: number; read(): Promise>; seek(position: number): Promise; } } declare module 'mmstudio/streams/SeekableStream' { import { Strategy } from 'mmstudio/streams/interfaces'; import Promise from 'mmstudio/promise'; import ReadableStream, { Source } from 'mmstudio/streams/ReadableStream'; import SeekableStreamReader from 'mmstudio/streams/SeekableStreamReader'; export default class SeekableStream extends ReadableStream { preventClose: boolean; reader: SeekableStreamReader; /** * @param preventClose (default=true) Prevent the stream from closing when it reaches the end. * If true, the stream will not close when requestClose is called on the controller (which is typically done by the * source when it reaches its end). This allows for re-seeking in a stream that has already been read to the end. * The stream can be closed by calling ReadableStream#close. */ constructor(underlyingSource: Source, strategy?: Strategy, preventClose?: boolean); getReader(): SeekableStreamReader; requestClose(): void; seek(position: number): Promise; strategy: Strategy; } } declare module 'mmstudio/streams/adapters/EventedStreamSource' { import Evented from 'mmstudio/Evented'; import { Handle } from 'mmstudio/interfaces'; import { EventEmitter } from 'mmstudio/on'; import Promise from 'mmstudio/promise'; import { Source } from 'mmstudio/streams/ReadableStream'; import ReadableStreamController from 'mmstudio/streams/ReadableStreamController'; export type EventTargetTypes = Evented | EventEmitter | EventTarget; export type EventTypes = string | string[]; export default class EventedStreamSource implements Source { protected _controller: ReadableStreamController; protected _target: EventTargetTypes; protected _events: string[]; protected _handles: Handle[]; constructor(target: EventTargetTypes, type: EventTypes); start(controller: ReadableStreamController): Promise; cancel(reason?: any): Promise; protected _handleEvent(event: Event): void; } }