Comparing version 2.0.0-build-6 to 2.0.0-build-7
{ | ||
"name": "ractive", | ||
"description": "Next-generation DOM manipulation", | ||
"version": "2.0.0-build-6", | ||
"version": "2.0.0-build-7", | ||
"homepage": "https://ractive.js.org", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -6,5 +6,2 @@ // Type definitions for Ractive edge | ||
// no need to run eslint on this file since we are converting the source to ts | ||
/* eslint-disable */ | ||
export interface ValueMap { | ||
@@ -19,3 +16,3 @@ [key: string]: any; | ||
* @param ractive the Ractive instance that is applying the value to the given keypath | ||
* @returns true if the adaptor should be applied, false otherwisej | ||
* @returns true if the adaptor should be applied, false otherwise | ||
*/ | ||
@@ -104,3 +101,3 @@ filter: (value: any, keypath: string, ractive: Ractive) => boolean; | ||
/** The source component for a bubbled event Context, if any. */ | ||
component?: Ractive; | ||
component?: ComponentItem; | ||
@@ -122,2 +119,42 @@ /** Add to the number at the given keypath | ||
/** | ||
* Find an element in the DOM controlled by this instance. | ||
* @param selector query used to find the first matching element | ||
* @param opts | ||
*/ | ||
find(selector: string, opts?: FindOpts): HTMLElement; | ||
/** | ||
* Find all of the elements in the DOM controlled by this instance that match the given selector. | ||
* @param selector query used to match elements | ||
* @param opts | ||
*/ | ||
findAll(selector: string, opts?: FindOpts): HTMLElement[]; | ||
/** | ||
* Find all of the components belonging to this instance. | ||
* @param opts | ||
*/ | ||
findAllComponents(opts?: FindOpts): Ractive[]; | ||
/** | ||
* Find all of the components with the given name belonging to this instance. | ||
* @param name | ||
* @param opts | ||
*/ | ||
findAllComponents(name: string, opts?: FindOpts): Ractive[]; | ||
/** | ||
* Find the first component belonging to this instance. | ||
* @param opts | ||
*/ | ||
findComponent(opts?: FindOpts): Ractive; | ||
/** | ||
* Find the first component with the given name belonging to this instance. | ||
* @param name | ||
* @param opts | ||
*/ | ||
findComponent(name: string, opts?: FindOpts): Ractive; | ||
/** | ||
* Retrieve the value associated with the current Context. | ||
@@ -236,3 +273,3 @@ * @param opts | ||
* @param map Context-relative keypath -> callback pairs to observe | ||
* @returns an observer handle that controls all of the created observersj | ||
* @returns an observer handle that controls all of the created observers | ||
*/ | ||
@@ -244,3 +281,3 @@ observeOnce(map: { [key: string]: ObserverCallback }, opts?: ObserverOpts): ObserverHandle; | ||
* @param map Context-relative keypath -> callback pairs to observe | ||
* @returns an observer handle that controls all of the created observersj | ||
* @returns an observer handle that controls all of the created observers | ||
*/ | ||
@@ -289,3 +326,3 @@ observeOnce( | ||
* Reverse the array at the given Context-relative keypath. | ||
* @param keypath keypath to the targret array | ||
* @param keypath keypath to the target array | ||
*/ | ||
@@ -295,3 +332,3 @@ reverse(keypath: string): ArraySplicePromise; | ||
/** | ||
* Set a value at the given Context-relative keypath. If any intermediate levels do not exist in the data, they will be created as appriate - objects for string keys and arrays for numeric keys. | ||
* Set a value at the given Context-relative keypath. If any intermediate levels do not exist in the data, they will be created as appropriate - objects for string keys and arrays for numeric keys. | ||
* @param keypath | ||
@@ -339,3 +376,3 @@ * @param value the value to set | ||
* @param keypath | ||
* @param amount the amount to subtrat from the value - defaults to 1 | ||
* @param amount the amount to subtract from the value - defaults to 1 | ||
*/ | ||
@@ -397,4 +434,9 @@ subtract(keypath: string, amount?: number): Promise<void>; | ||
export type Component = Static | Promise<Static>; | ||
export type Component = Static<any> | Promise<Static<any>>; | ||
export type ComponentItem = { | ||
instance: Ractive<any>; | ||
name: string; | ||
}; | ||
export interface ComputationDescriptor<T extends Ractive<T> = Ractive> { | ||
@@ -454,3 +496,3 @@ /** | ||
node: HTMLElement, | ||
fire: (event: Event) => void | ||
fire: (event?: ValueMap) => void | ||
) => { teardown: () => void }; | ||
@@ -498,5 +540,9 @@ | ||
export interface ListenerContextHelper extends ContextHelper { | ||
name: string; | ||
} | ||
export type ListenerCallback<T extends Ractive<T> = Ractive> = ( | ||
this: T, | ||
ctx: ContextHelper, | ||
ctx: ListenerContextHelper, | ||
...args: any[] | ||
@@ -524,3 +570,3 @@ ) => boolean | void | Promise<any>; | ||
/** | ||
* Removes the listener or observer. | ||
* Removes the listener or observer.j | ||
*/ | ||
@@ -554,3 +600,3 @@ cancel(): void; | ||
export type MacroFn = (MacroHelper) => MacroHandle; | ||
export type MacroFn = (helper: MacroHelper) => MacroHandle; | ||
@@ -738,19 +784,9 @@ export interface MacroHandle { | ||
export type PluginExtend = (PluginArgsExtend) => void; | ||
export type PluginInstance = (PluginArgsInstance) => void; | ||
export interface PluginArgsBase { | ||
export interface PluginArgs { | ||
Ractive: typeof Ractive; | ||
proto: Ractive | Static; | ||
instance: Ractive | Static; | ||
} | ||
export interface PluginArgsInstance { | ||
proto: Ractive; | ||
instance: Ractive; | ||
} | ||
export interface PluginArgsExtend { | ||
proto: Static; | ||
instance: Static; | ||
} | ||
export type Plugin = (args: PluginArgs) => void; | ||
export type Plugin = (PluginArgsBase) => void; | ||
export interface ReadLinkOpts { | ||
@@ -780,3 +816,3 @@ /** Whether or not to follow through any upstream links when resolving the source. */ | ||
/** Whether or not to keep the template sturctures removed by this set around for future reinstatement. This can be used to avoid throwing away and recreating components when hiding them. Defaults to false. */ | ||
/** Whether or not to keep the template structures removed by this set around for future reinstatement. This can be used to avoid throwing away and recreating components when hiding them. Defaults to false. */ | ||
keep?: boolean; | ||
@@ -860,3 +896,3 @@ | ||
* if any other string, 400ms | ||
* if a map, it is applied over defaultsj | ||
* if a map, it is applied over defaults | ||
*/ | ||
@@ -904,6 +940,6 @@ processParams( | ||
/** The regular mustach delimiters - defaults to {{ }}. */ | ||
/** The regular mustache delimiters - defaults to {{ }}. */ | ||
delimiters?: ParseDelimiters; | ||
/** Whether or not to collapse consective whitespace into a single space. */ | ||
/** Whether or not to collapse consecutive whitespace into a single space. */ | ||
preserveWhitespace?: boolean; | ||
@@ -951,2 +987,5 @@ | ||
/** True if this instance is being constructed as a component, which also means it will be initialized after the constructor. */ | ||
component?: true; | ||
/** A map of computations */ | ||
@@ -958,3 +997,3 @@ computed?: { [key: string]: Computation<T> }; | ||
/** Whether or not to use event delegation around suitabe iterative sections. Defaults to true. */ | ||
/** Whether or not to use event delegation around suitable iterative sections. Defaults to true. */ | ||
delegate?: boolean; | ||
@@ -980,3 +1019,3 @@ | ||
/** Whether or not to skip element intro transitions when the instance is being renered initially. */ | ||
/** Whether or not to skip element intro transitions when the instance is being rendered initially. */ | ||
noIntro?: boolean; | ||
@@ -1016,2 +1055,38 @@ | ||
warnAboutAmbiguity?: boolean; | ||
/** | ||
* A lifecycle event that is called when an instance is constructed but before any initialization option has been processed. | ||
* Accepts the instance's initialization options as argument. | ||
*/ | ||
onconstruct?(this: T, opts: InitOpts): void; | ||
/** A lifecycle event that is called when an instance is constructed and is ready to be rendered. */ | ||
oninit?(this: T): void; | ||
/** A lifecycle event that is called when an instance is constructed and all initialization options have been processed. */ | ||
onconfig?(this: T): void; | ||
/** A lifecycle event that is called when the instance is rendered but before transitions start. */ | ||
onrender?(this: T): void; | ||
/** A lifecycle event that is called when the instance is rendered and all the transitions have completed. */ | ||
oncomplete?(this: T): void; | ||
/** A lifecycle event that is called when ractive.insert() is called. */ | ||
oninsert?(this: T): void; | ||
/** | ||
* A lifecycle event that is called whenever `ractive.detach()` is called. | ||
* Note that `ractive.insert()` implicitly calls `ractive.detach()` if needed. | ||
*/ | ||
ondetach?(this: T): void; | ||
/** A lifecycle event that is called when ractive.update() is called. */ | ||
onupdate?(this: T): void; | ||
/** A lifecycle event that is called when an instance is constructed and is ready to be rendered. */ | ||
onunrender?(this: T): void; | ||
/** A lifecycle event that is called when an instance is constructed and is ready to be rendered. */ | ||
onteardown?(this: T): void; | ||
} | ||
@@ -1042,7 +1117,7 @@ | ||
/** An array of plugins to apply to the component. */ | ||
use?: PluginExtend[]; | ||
use?: Plugin[]; | ||
} | ||
export interface InitOpts<T extends Ractive<T> = Ractive> extends BaseInitOpts<T> { | ||
/** Initiial data for this instance. */ | ||
/** Initial data for this instance. */ | ||
data?: Data | DataFn<T>; | ||
@@ -1057,3 +1132,3 @@ | ||
/** An array of plugins to apply to the instance. */ | ||
use?: PluginInstance[]; | ||
use?: Plugin[]; | ||
@@ -1076,2 +1151,3 @@ /** If true, this instance can occupy the target element with other existing instances rather than cause them to unrender. Cannot be used with enhance. */ | ||
partials: Registry<Partial>; | ||
transitions: Registry<Transition>; | ||
} | ||
@@ -1087,3 +1163,3 @@ | ||
/** The registries that are inherited by all instance. */ | ||
defaults: Registries<T>; | ||
defaults: Registries<T> & ValueMap; | ||
@@ -1099,5 +1175,10 @@ adaptors: Registry<Adaptor>; | ||
partials: Registry<Partial>; | ||
transitions: Registry<Transition>; | ||
/** Create a new component with this constructor as a starting point. */ | ||
extend<U, V extends ExtendOpts<T> = ExtendOpts<T>>(opts?: V): Static<Ractive<T & U>>; | ||
extend(): Static<T>; | ||
extend<A extends ExtendOpts<T> & ValueMap, U extends Readonly<Array<ExtendOpts<T> & ValueMap>>>( | ||
opts: A, | ||
...more: U | ||
): Static<T & Merge<A, U, ExtendOpts>>; | ||
@@ -1112,3 +1193,3 @@ /** Create a new component with this constructor as a starting point using the given constructor. */ | ||
opts?: W | ||
): Static<Ractive<T & U>>; | ||
): Static<Ractive<U> & U>; | ||
@@ -1136,3 +1217,3 @@ /** Get a Context for the given node or selector. */ | ||
/** Install one or more plugins on the component. */ | ||
use(...plugins: PluginExtend[]): Static; | ||
use(...plugins: Plugin[]): Static; | ||
@@ -1146,3 +1227,3 @@ /** The Ractive constructor used to create this constructor. */ | ||
export interface Children extends Array<Ractive> { | ||
/** Lists of instances targetting anchors by name. */ | ||
/** Lists of instances targeting anchors by name. */ | ||
byName: { [key: string]: Ractive[] }; | ||
@@ -1175,3 +1256,6 @@ } | ||
partials: Registry<Partial>; | ||
transitions: Registry<Transition>; | ||
readonly event?: ContextHelper | Event | any; | ||
/** When overriding methods, the original method is available using this._super. */ | ||
@@ -1379,3 +1463,3 @@ _super(...args: any[]): any; | ||
* @param map keypath -> callback pairs to observe | ||
* @returns an observer handle that controls all of the created observersj | ||
* @returns an observer handle that controls all of the created observers | ||
*/ | ||
@@ -1387,3 +1471,3 @@ observeOnce(map: { [key: string]: ObserverCallback<T> }, opts?: ObserverOpts): ObserverHandle; | ||
* @param map keypath -> callback pairs to observe | ||
* @returns an observer handle that controls all of the created observersj | ||
* @returns an observer handle that controls all of the created observers | ||
*/ | ||
@@ -1473,3 +1557,3 @@ observeOnce( | ||
* Reverse the array at the given keypath. | ||
* @param keypath keypath to the targret array | ||
* @param keypath keypath to the target array | ||
*/ | ||
@@ -1605,3 +1689,3 @@ reverse(keypath: string): ArraySplicePromise; | ||
/** Install one or more plugins on the instance. */ | ||
use(...plugins: PluginInstance[]): Ractive; | ||
use(...plugins: Plugin[]): Ractive; | ||
@@ -1619,5 +1703,10 @@ /** The registries that are inherited by all instance. */ | ||
static partials: Registry<Partial>; | ||
static transitions: Registry<Transition>; | ||
/** Create a new component with this constructor as a starting point. */ | ||
static extend<U>(opts?: ExtendOpts<Ractive & U>): Static<Ractive<Ractive & U>>; | ||
static extend(): Static<Ractive>; | ||
static extend< | ||
T extends ExtendOpts<any> & ValueMap, | ||
U extends Readonly<Array<ExtendOpts<any> & ValueMap>> | ||
>(opts: T, ...more: U): Static<Ractive & Merge<T, U, ExtendOpts>>; | ||
@@ -1629,3 +1718,3 @@ /** Create a new component with this constructor as a starting point using the given constructor. */ | ||
W extends ExtendOpts<U> = ExtendOpts<U> | ||
>(c: Constructor<U, V>, opts?: W): Static<Ractive<Ractive & U>>; | ||
>(c: Constructor<U, V>, opts?: W): Static<Ractive<U> & U>; | ||
@@ -1652,3 +1741,3 @@ /** Get a Context for the given node or selector. */ | ||
static use(...args: PluginExtend[]): Static; | ||
static use(...args: Plugin[]): Static; | ||
@@ -1661,2 +1750,9 @@ /** The Ractive constructor used to create this constructor. */ | ||
type Merge<T, U extends readonly any[], X> = { | ||
0: T; | ||
1: ((...t: U) => any) extends (head: infer Head, ...tail: infer Tail) => any | ||
? Merge<Omit<T, keyof Head & keyof X> & Head, Tail, X> | ||
: never; | ||
}[U['length'] extends 0 ? 0 : 1]; | ||
export namespace Ractive { | ||
@@ -1676,5 +1772,15 @@ /** The prototype for Context objects. You can use this to add methods and properties to Contexts. */ | ||
/** The build version of Ractive. */ | ||
const VERSION: string; | ||
/** Setting this to false will prevent Ractive from printing a welcome console message when the first instance is created. */ | ||
let WELCOME_MESSAGE: false | undefined; | ||
/** | ||
* The current operation promise is available to things like observers and decorators using Ractive.tick, | ||
* which will return undefined if there is not currently an operation in progress. | ||
*/ | ||
const tick: undefined | Promise<void>; | ||
/** | ||
* Add Ractive-managed CSS to the managed style tag. This effectively global CSS managed by the Ractive constructor, | ||
@@ -1681,0 +1787,0 @@ * as opposed scoped CSS installed on a component constructor. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3055260
66317