Comparing version 1.4.0-build-48 to 1.4.0-build-49
{ | ||
"name": "ractive", | ||
"description": "Next-generation DOM manipulation", | ||
"version": "1.4.0-build-48", | ||
"version": "1.4.0-build-49", | ||
"homepage": "https://ractive.js.org", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -99,3 +99,3 @@ // Type definitions for Ractive edge | ||
/** The source component for a bubbled event Context, if any. */ | ||
component?: Ractive; | ||
component?: ComponentItem; | ||
@@ -117,2 +117,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. | ||
@@ -376,4 +416,9 @@ * @param opts | ||
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> { | ||
@@ -419,3 +464,3 @@ /** | ||
export type EventPlugin<T extends Ractive<T> = Ractive> = (this: T, node: HTMLElement, fire: (event: Event) => void) => { teardown: () => void }; | ||
export type EventPlugin<T extends Ractive<T> = Ractive> = (this: T, node: HTMLElement, fire: (event?: ValueMap) => void) => { teardown: () => void }; | ||
@@ -516,3 +561,3 @@ export interface FindOpts { | ||
export type MacroFn = (MacroHelper) => MacroHandle; | ||
export type MacroFn = (helper: MacroHelper) => MacroHandle; | ||
@@ -689,19 +734,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 { | ||
@@ -889,2 +924,5 @@ /** Whether or not to follow through any upstream links when resolving the source. */ | ||
/** 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 */ | ||
@@ -1013,3 +1051,3 @@ computed?: { [key: string]: Computation<T> }; | ||
/** An array of plugins to apply to the component. */ | ||
use?: PluginExtend[]; | ||
use?: Plugin[]; | ||
} | ||
@@ -1028,3 +1066,3 @@ | ||
/** An array of plugins to apply to the instance. */ | ||
use?: PluginInstance[]; | ||
use?: Plugin[]; | ||
@@ -1047,2 +1085,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>; | ||
} | ||
@@ -1058,3 +1097,3 @@ | ||
/** The registries that are inherited by all instance. */ | ||
defaults: Registries<T>; | ||
defaults: Registries<T> & ValueMap; | ||
@@ -1070,8 +1109,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>>; | ||
/** Create a new component with this constructor as a starting point using the given constructor. */ | ||
extendWith<U extends Ractive<U>, V extends InitOpts<U> = InitOpts<U>, W extends ExtendOpts<U> = ExtendOpts<U>>(c: Constructor<U, V>, opts?: W): Static<Ractive<T & U>>; | ||
extendWith<U extends Ractive<U>, V extends InitOpts<U> = InitOpts<U>, W extends ExtendOpts<U> = ExtendOpts<U>>(c: Constructor<U, V>, opts?: W): Static<Ractive<U> & U>; | ||
@@ -1099,3 +1140,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; | ||
@@ -1137,3 +1178,6 @@ /** The Ractive constructor used to create this constructor. */ | ||
partials: Registry<Partial>; | ||
transitions: Registry<Transition>; | ||
readonly event?: ContextHelper|Event|any; | ||
/** When overriding methods, the original method is available using this._super. */ | ||
@@ -1546,3 +1590,3 @@ _super(...args: any[]): any; | ||
/** Install one or more plugins on the instance. */ | ||
use(...plugins: PluginInstance[]): Ractive; | ||
use(...plugins: Plugin[]): Ractive; | ||
@@ -1560,8 +1604,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>>; | ||
/** Create a new component with this constructor as a starting point using the given constructor. */ | ||
static extendWith<U extends Ractive<U>, V extends InitOpts<U> = InitOpts<U>, W extends ExtendOpts<U> = ExtendOpts<U>>(c: Constructor<U, V>, opts?: W): Static<Ractive<Ractive & U>>; | ||
static extendWith<U extends Ractive<U>, V extends InitOpts<U> = InitOpts<U>, W extends ExtendOpts<U> = ExtendOpts<U>>(c: Constructor<U, V>, opts?: W): Static<Ractive<U> & U>; | ||
@@ -1588,3 +1634,3 @@ /** Get a Context for the given node or selector. */ | ||
static use(...args: PluginExtend[]): Static; | ||
static use(...args: Plugin[]): Static; | ||
@@ -1597,2 +1643,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 module Ractive { | ||
@@ -1612,4 +1665,8 @@ /** 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; | ||
/** | ||
@@ -1616,0 +1673,0 @@ * The current operation promise is available to things like observers and decorators using Ractive.tick, |
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 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
Sorry, the diff of this file is not supported yet
8057647
61186