new license file version [CI SKIP]
This commit is contained in:
@@ -0,0 +1 @@
|
||||
import 'rxjs-compat/add/operator/windowWhen';
|
||||
@@ -0,0 +1,52 @@
|
||||
import { Observable } from '../Observable';
|
||||
import { ObservedValueOf, ObservableInput } from '../types';
|
||||
/**
|
||||
* Creates an Observable that, on subscribe, calls an Observable factory to
|
||||
* make an Observable for each new Observer.
|
||||
*
|
||||
* <span class="informal">Creates the Observable lazily, that is, only when it
|
||||
* is subscribed.
|
||||
* </span>
|
||||
*
|
||||
* 
|
||||
*
|
||||
* `defer` allows you to create the Observable only when the Observer
|
||||
* subscribes, and create a fresh Observable for each Observer. It waits until
|
||||
* an Observer subscribes to it, and then it generates an Observable,
|
||||
* typically with an Observable factory function. It does this afresh for each
|
||||
* subscriber, so although each subscriber may think it is subscribing to the
|
||||
* same Observable, in fact each subscriber gets its own individual
|
||||
* Observable.
|
||||
*
|
||||
* ## Example
|
||||
* ### Subscribe to either an Observable of clicks or an Observable of interval, at random
|
||||
* ```ts
|
||||
* import { defer, fromEvent, interval } from 'rxjs';
|
||||
*
|
||||
* const clicksOrInterval = defer(function () {
|
||||
* return Math.random() > 0.5
|
||||
* ? fromEvent(document, 'click')
|
||||
* : interval(1000);
|
||||
* });
|
||||
* clicksOrInterval.subscribe(x => console.log(x));
|
||||
*
|
||||
* // Results in the following behavior:
|
||||
* // If the result of Math.random() is greater than 0.5 it will listen
|
||||
* // for clicks anywhere on the "document"; when document is clicked it
|
||||
* // will log a MouseEvent object to the console. If the result is less
|
||||
* // than 0.5 it will emit ascending numbers, one every second(1000ms).
|
||||
* ```
|
||||
*
|
||||
* @see {@link Observable}
|
||||
*
|
||||
* @param {function(): SubscribableOrPromise} observableFactory The Observable
|
||||
* factory function to invoke for each Observer that subscribes to the output
|
||||
* Observable. May also return a Promise, which will be converted on the fly
|
||||
* to an Observable.
|
||||
* @return {Observable} An Observable whose Observers' subscriptions trigger
|
||||
* an invocation of the given Observable factory function.
|
||||
* @static true
|
||||
* @name defer
|
||||
* @owner Observable
|
||||
*/
|
||||
export declare function defer<R extends ObservableInput<any> | void>(observableFactory: () => R): Observable<ObservedValueOf<R>>;
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"zip.js","sources":["../src/operator/zip.ts"],"names":[],"mappings":";;;;;AAAA,8CAAyC"}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"bufferCount.js","sources":["../../../src/internal/operators/bufferCount.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AA2D3C,MAAM,UAAU,WAAW,CAAI,UAAkB,EAAE,gBAA+B;IAA/B,iCAAA,EAAA,uBAA+B;IAChF,OAAO,SAAS,2BAA2B,CAAC,MAAqB;QAC/D,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,mBAAmB,CAAI,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAC/E,CAAC,CAAC;AACJ,CAAC;AAED;IAGE,6BAAoB,UAAkB,EAAU,gBAAwB;QAApD,eAAU,GAAV,UAAU,CAAQ;QAAU,qBAAgB,GAAhB,gBAAgB,CAAQ;QACtE,IAAI,CAAC,gBAAgB,IAAI,UAAU,KAAK,gBAAgB,EAAE;YACxD,IAAI,CAAC,eAAe,GAAG,qBAAqB,CAAC;SAC9C;aAAM;YACL,IAAI,CAAC,eAAe,GAAG,yBAAyB,CAAC;SAClD;IACH,CAAC;IAED,kCAAI,GAAJ,UAAK,UAA2B,EAAE,MAAW;QAC3C,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACxG,CAAC;IACH,0BAAC;AAAD,CAAC,AAdD,IAcC;AAOD;IAAuC,iDAAa;IAGlD,+BAAY,WAA4B,EAAU,UAAkB;QAApE,YACE,kBAAM,WAAW,CAAC,SACnB;QAFiD,gBAAU,GAAV,UAAU,CAAQ;QAF5D,YAAM,GAAQ,EAAE,CAAC;;IAIzB,CAAC;IAES,qCAAK,GAAf,UAAgB,KAAQ;QACtB,IAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAE3B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEnB,IAAI,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,UAAU,EAAE;YACpC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC9B,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;SAClB;IACH,CAAC;IAES,yCAAS,GAAnB;QACE,IAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YACrB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAC/B;QACD,iBAAM,SAAS,WAAE,CAAC;IACpB,CAAC;IACH,4BAAC;AAAD,CAAC,AAzBD,CAAuC,UAAU,GAyBhD;AAOD;IAA2C,qDAAa;IAItD,mCAAY,WAA4B,EAAU,UAAkB,EAAU,gBAAwB;QAAtG,YACE,kBAAM,WAAW,CAAC,SACnB;QAFiD,gBAAU,GAAV,UAAU,CAAQ;QAAU,sBAAgB,GAAhB,gBAAgB,CAAQ;QAH9F,aAAO,GAAe,EAAE,CAAC;QACzB,WAAK,GAAW,CAAC,CAAC;;IAI1B,CAAC;IAES,yCAAK,GAAf,UAAgB,KAAQ;QAChB,IAAA,SAAuD,EAArD,0BAAU,EAAE,sCAAgB,EAAE,oBAAO,EAAE,gBAAK,CAAU;QAE9D,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,KAAK,GAAG,gBAAgB,KAAK,CAAC,EAAE;YAClC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SAClB;QAED,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,GAAI;YAClC,IAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YAC1B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;gBAChC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACrB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aAC/B;SACF;IACH,CAAC;IAES,6CAAS,GAAnB;QACQ,IAAA,SAA+B,EAA7B,oBAAO,EAAE,4BAAW,CAAU;QAEtC,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACzB,IAAI,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;YAC7B,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;gBACrB,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aAC1B;SACF;QACD,iBAAM,SAAS,WAAE,CAAC;IACpB,CAAC;IAEH,gCAAC;AAAD,CAAC,AAtCD,CAA2C,UAAU,GAsCpD"}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0.00147,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0.00147,"42":0,"43":0.00294,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0.00294,"56":0,"57":0.00147,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0.00735,"85":0,"86":0.00147,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0.00147,"98":0,"99":0,"100":0,"101":0,"102":0.00441,"103":0.00441,"104":0.00294,"105":0,"106":0.00147,"107":0.01322,"108":0.10136,"109":0.06464,"110":0.00294,"111":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0.00294,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0.00147,"41":0,"42":0,"43":0.00294,"44":0,"45":0,"46":0.00147,"47":0,"48":0,"49":0,"50":0.00147,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0.00294,"57":0,"58":0.00147,"59":0,"60":0,"61":0,"62":0.00147,"63":0,"64":0.00294,"65":0,"66":0,"67":0,"68":0.00294,"69":0,"70":0.00441,"71":0,"72":0,"73":0,"74":0.00147,"75":0.00147,"76":0,"77":0,"78":0.00735,"79":0.03232,"80":0.00147,"81":0.00881,"83":0,"84":0,"85":0.00294,"86":0.00147,"87":0.00147,"88":0.00588,"89":0.00441,"90":0.00147,"91":0.00147,"92":0.00147,"93":0,"94":0,"95":0.00294,"96":0.00147,"97":0,"98":0.01175,"99":0.00735,"100":0.00294,"101":0,"102":0.01469,"103":0.00588,"104":0.00147,"105":0.00441,"106":0.0235,"107":0.01175,"108":0.39957,"109":0.31584,"110":0.00881,"111":0,"112":0},F:{"9":0,"11":0,"12":0,"15":0.00147,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0.00588,"28":0.00588,"29":0,"30":0.00147,"31":0,"32":0.01175,"33":0.00441,"34":0,"35":0.00147,"36":0,"37":0,"38":0.01322,"39":0,"40":0,"41":0,"42":0.00294,"43":0,"44":0,"45":0,"46":0.00147,"47":0,"48":0,"49":0,"50":0.00441,"51":0.00441,"52":0,"53":0,"54":0,"55":0,"56":0.00294,"57":0,"58":0.00147,"60":0.02497,"62":0,"63":0.01469,"64":0.00735,"65":0.00441,"66":0.01028,"67":0.01322,"68":0,"69":0,"70":0.00147,"71":0.00147,"72":0.00294,"73":0.00735,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0.00147,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0.00147,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0.00588,"94":0.09108,"9.5-9.6":0,"10.0-10.1":0,"10.5":0,"10.6":0,"11.1":0,"11.5":0,"11.6":0,"12.1":0.01175},B:{"12":0.00588,"13":0,"14":0,"15":0,"16":0.00147,"17":0.00881,"18":0.00294,"79":0,"80":0,"81":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0.00147,"91":0,"92":0.01028,"93":0,"94":0,"95":0,"96":0.00147,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0.00294,"104":0,"105":0,"106":0.00147,"107":0.00441,"108":0.0852,"109":0.07786},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,_:"0","3.1":0,"3.2":0,"5.1":0,"6.1":0,"7.1":0,"9.1":0,"10.1":0,"11.1":0,"12.1":0,"13.1":0,"14.1":0,"15.1":0,"15.2-15.3":0,"15.4":0,"15.5":0,"15.6":0,"16.0":0,"16.1":0,"16.2":0,"16.3":0},G:{"8":0,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0,"6.0-6.1":0,"7.0-7.1":0.02281,"8.1-8.4":0,"9.0-9.2":0.00107,"9.3":0.14276,"10.0-10.2":0.00321,"10.3":0.0524,"11.0-11.2":0.00553,"11.3-11.4":0.00107,"12.0-12.1":0.16771,"12.2-12.5":0.50742,"13.0-13.1":0.00267,"13.2":0.01426,"13.3":0.02959,"13.4-13.7":0.0164,"14.0-14.4":0.05685,"14.5-14.8":0.05311,"15.0-15.1":0.00374,"15.2-15.3":0.09731,"15.4":0.07325,"15.5":0.14383,"15.6":0.05579,"16.0":0.03725,"16.1":0.05792,"16.2":0.09179,"16.3":0.01961},P:{"4":0.61783,"5.0-5.4":0.19244,"6.2-6.4":0.05064,"7.2-7.4":0.62795,"8.2":0,"9.2":0.02026,"10.1":0,"11.1-11.2":0.02026,"12.0":0.02026,"13.0":0.02026,"14.0":0.02026,"15.0":0.01013,"16.0":0.25321,"17.0":0.04051,"18.0":0.09115,"19.0":0.38488},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0.0007,"4.2-4.3":0.04541,"4.4":0,"4.4.3-4.4.4":0.32033},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0,"9":0,"10":0,"11":0.00588,"5.5":0},J:{"7":0,"10":0},N:{"10":0,"11":0},R:{_:"0"},M:{"0":0.06825},Q:{"13.1":0.02559},O:{"0":1.11756},H:{"0":7.43047},L:{"0":83.00661},S:{"2.5":0.00853}};
|
||||
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
require("rxjs-compat/add/observable/empty");
|
||||
//# sourceMappingURL=empty.js.map
|
||||
@@ -0,0 +1,126 @@
|
||||
import { Observable } from '../Observable';
|
||||
import { OperatorFunction } from '../types';
|
||||
import { Subject } from '../Subject';
|
||||
import { Subscriber } from '../Subscriber';
|
||||
import { Operator } from '../Operator';
|
||||
import { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';
|
||||
|
||||
/**
|
||||
* Branch out the source Observable values as a nested Observable whenever
|
||||
* `windowBoundaries` emits.
|
||||
*
|
||||
* <span class="informal">It's like {@link buffer}, but emits a nested Observable
|
||||
* instead of an array.</span>
|
||||
*
|
||||
* 
|
||||
*
|
||||
* Returns an Observable that emits windows of items it collects from the source
|
||||
* Observable. The output Observable emits connected, non-overlapping
|
||||
* windows. It emits the current window and opens a new one whenever the
|
||||
* Observable `windowBoundaries` emits an item. Because each window is an
|
||||
* Observable, the output is a higher-order Observable.
|
||||
*
|
||||
* ## Example
|
||||
* In every window of 1 second each, emit at most 2 click events
|
||||
* ```ts
|
||||
* import { fromEvent, interval } from 'rxjs';
|
||||
* import { window, mergeAll, map, take } from 'rxjs/operators';
|
||||
*
|
||||
* const clicks = fromEvent(document, 'click');
|
||||
* const sec = interval(1000);
|
||||
* const result = clicks.pipe(
|
||||
* window(sec),
|
||||
* map(win => win.pipe(take(2))), // each window has at most 2 emissions
|
||||
* mergeAll(), // flatten the Observable-of-Observables
|
||||
* );
|
||||
* result.subscribe(x => console.log(x));
|
||||
* ```
|
||||
* @see {@link windowCount}
|
||||
* @see {@link windowTime}
|
||||
* @see {@link windowToggle}
|
||||
* @see {@link windowWhen}
|
||||
* @see {@link buffer}
|
||||
*
|
||||
* @param {Observable<any>} windowBoundaries An Observable that completes the
|
||||
* previous window and starts a new window.
|
||||
* @return {Observable<Observable<T>>} An Observable of windows, which are
|
||||
* Observables emitting values of the source Observable.
|
||||
* @method window
|
||||
* @owner Observable
|
||||
*/
|
||||
export function window<T>(windowBoundaries: Observable<any>): OperatorFunction<T, Observable<T>> {
|
||||
return function windowOperatorFunction(source: Observable<T>) {
|
||||
return source.lift(new WindowOperator(windowBoundaries));
|
||||
};
|
||||
}
|
||||
|
||||
class WindowOperator<T> implements Operator<T, Observable<T>> {
|
||||
|
||||
constructor(private windowBoundaries: Observable<any>) {
|
||||
}
|
||||
|
||||
call(subscriber: Subscriber<Observable<T>>, source: any): any {
|
||||
const windowSubscriber = new WindowSubscriber(subscriber);
|
||||
const sourceSubscription = source.subscribe(windowSubscriber);
|
||||
if (!sourceSubscription.closed) {
|
||||
windowSubscriber.add(innerSubscribe(this.windowBoundaries, new SimpleInnerSubscriber(windowSubscriber)));
|
||||
}
|
||||
return sourceSubscription;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We need this JSDoc comment for affecting ESDoc.
|
||||
* @ignore
|
||||
* @extends {Ignored}
|
||||
*/
|
||||
class WindowSubscriber<T> extends SimpleOuterSubscriber<T, any> {
|
||||
|
||||
private window: Subject<T> = new Subject<T>();
|
||||
|
||||
constructor(destination: Subscriber<Observable<T>>) {
|
||||
super(destination);
|
||||
destination.next(this.window);
|
||||
}
|
||||
|
||||
notifyNext(): void {
|
||||
this.openWindow();
|
||||
}
|
||||
|
||||
notifyError(error: any): void {
|
||||
this._error(error);
|
||||
}
|
||||
|
||||
notifyComplete(): void {
|
||||
this._complete();
|
||||
}
|
||||
|
||||
protected _next(value: T): void {
|
||||
this.window.next(value);
|
||||
}
|
||||
|
||||
protected _error(err: any): void {
|
||||
this.window.error(err);
|
||||
this.destination.error!(err);
|
||||
}
|
||||
|
||||
protected _complete(): void {
|
||||
this.window.complete();
|
||||
this.destination.complete!();
|
||||
}
|
||||
|
||||
/** @deprecated This is an internal implementation detail, do not use. */
|
||||
_unsubscribe() {
|
||||
this.window = null!;
|
||||
}
|
||||
|
||||
private openWindow(): void {
|
||||
const prevWindow = this.window;
|
||||
if (prevWindow) {
|
||||
prevWindow.complete();
|
||||
}
|
||||
const destination = this.destination;
|
||||
const newWindow = this.window = new Subject<T>();
|
||||
destination.next!(newWindow);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J E F G A BC","388":"B"},B:{"257":"P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t","260":"C K L","769":"H M N O"},C:{"2":"CC tB I u DC EC","4":"0 1 2 3 4 5 6 7 8 9 J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB","257":"UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB"},D:{"2":"I u J E F G A B C K L H M N O v w","4":"0 1 2 3 4 5 6 7 8 9 x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB","257":"RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB FC"},E:{"1":"A B C K L H 0B qB rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC","2":"I u J E GC zB HC IC","4":"F G JC KC"},F:{"2":"G B C OC PC QC RC qB 9B SC rB","4":"0 1 2 3 4 5 6 7 8 9 H M N O v w x y z AB BB CB DB","257":"EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d"},G:{"1":"aC bC cC dC eC fC gC hC iC jC kC lC mC 2B 3B 4B 5B sB 6B 7B 8B","2":"zB TC AC UC VC","4":"F WC XC YC ZC"},H:{"2":"nC"},I:{"2":"tB I oC pC qC rC AC","4":"sC tC","257":"D"},J:{"2":"E","4":"A"},K:{"2":"A B C qB 9B rB","257":"e"},L:{"257":"D"},M:{"257":"D"},N:{"2":"A","388":"B"},O:{"257":"uC"},P:{"4":"I","257":"vC wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C"},Q:{"257":"1B"},R:{"257":"8C"},S:{"4":"9C"}},B:6,C:"ECMAScript 2015 (ES6)"};
|
||||
@@ -0,0 +1,20 @@
|
||||
import AwaitBlock from '../AwaitBlock';
|
||||
import Body from '../Body';
|
||||
import Comment from '../Comment';
|
||||
import EachBlock from '../EachBlock';
|
||||
import Element from '../Element';
|
||||
import Head from '../Head';
|
||||
import IfBlock from '../IfBlock';
|
||||
import InlineComponent from '../InlineComponent';
|
||||
import KeyBlock from '../KeyBlock';
|
||||
import MustacheTag from '../MustacheTag';
|
||||
import Options from '../Options';
|
||||
import RawMustacheTag from '../RawMustacheTag';
|
||||
import DebugTag from '../DebugTag';
|
||||
import SlotTemplate from '../SlotTemplate';
|
||||
import Text from '../Text';
|
||||
import Title from '../Title';
|
||||
import Window from '../Window';
|
||||
import { TemplateNode } from '../../../interfaces';
|
||||
export declare type Children = ReturnType<typeof map_children>;
|
||||
export default function map_children(component: any, parent: any, scope: any, children: TemplateNode[]): (AwaitBlock | Body | Comment | DebugTag | EachBlock | Element | Head | IfBlock | InlineComponent | KeyBlock | MustacheTag | Options | RawMustacheTag | SlotTemplate | Text | Title | Window)[];
|
||||
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__export(require("rxjs-compat/observable/ArrayLikeObservable"));
|
||||
//# sourceMappingURL=ArrayLikeObservable.js.map
|
||||
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = isAlphanumeric;
|
||||
exports.locales = void 0;
|
||||
|
||||
var _assertString = _interopRequireDefault(require("./util/assertString"));
|
||||
|
||||
var _alpha = require("./alpha");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function isAlphanumeric(str) {
|
||||
var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US';
|
||||
(0, _assertString.default)(str);
|
||||
|
||||
if (locale in _alpha.alphanumeric) {
|
||||
return _alpha.alphanumeric[locale].test(str);
|
||||
}
|
||||
|
||||
throw new Error("Invalid locale '".concat(locale, "'"));
|
||||
}
|
||||
|
||||
var locales = Object.keys(_alpha.alphanumeric);
|
||||
exports.locales = locales;
|
||||
@@ -0,0 +1,224 @@
|
||||
import { isArray } from './util/isArray';
|
||||
import { isObject } from './util/isObject';
|
||||
import { isFunction } from './util/isFunction';
|
||||
import { UnsubscriptionError } from './util/UnsubscriptionError';
|
||||
import { SubscriptionLike, TeardownLogic } from './types';
|
||||
|
||||
/**
|
||||
* Represents a disposable resource, such as the execution of an Observable. A
|
||||
* Subscription has one important method, `unsubscribe`, that takes no argument
|
||||
* and just disposes the resource held by the subscription.
|
||||
*
|
||||
* Additionally, subscriptions may be grouped together through the `add()`
|
||||
* method, which will attach a child Subscription to the current Subscription.
|
||||
* When a Subscription is unsubscribed, all its children (and its grandchildren)
|
||||
* will be unsubscribed as well.
|
||||
*
|
||||
* @class Subscription
|
||||
*/
|
||||
export class Subscription implements SubscriptionLike {
|
||||
/** @nocollapse */
|
||||
public static EMPTY: Subscription = (function(empty: any) {
|
||||
empty.closed = true;
|
||||
return empty;
|
||||
}(new Subscription()));
|
||||
|
||||
/**
|
||||
* A flag to indicate whether this Subscription has already been unsubscribed.
|
||||
* @type {boolean}
|
||||
*/
|
||||
public closed: boolean = false;
|
||||
|
||||
/** @internal */
|
||||
protected _parentOrParents: Subscription | Subscription[] = null;
|
||||
/** @internal */
|
||||
private _subscriptions: SubscriptionLike[] = null;
|
||||
|
||||
/**
|
||||
* @param {function(): void} [unsubscribe] A function describing how to
|
||||
* perform the disposal of resources when the `unsubscribe` method is called.
|
||||
*/
|
||||
constructor(unsubscribe?: () => void) {
|
||||
if (unsubscribe) {
|
||||
(this as any)._ctorUnsubscribe = true;
|
||||
(this as any)._unsubscribe = unsubscribe;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes the resources held by the subscription. May, for instance, cancel
|
||||
* an ongoing Observable execution or cancel any other type of work that
|
||||
* started when the Subscription was created.
|
||||
* @return {void}
|
||||
*/
|
||||
unsubscribe(): void {
|
||||
let errors: any[];
|
||||
|
||||
if (this.closed) {
|
||||
return;
|
||||
}
|
||||
|
||||
let { _parentOrParents, _ctorUnsubscribe, _unsubscribe, _subscriptions } = (this as any);
|
||||
|
||||
this.closed = true;
|
||||
this._parentOrParents = null;
|
||||
// null out _subscriptions first so any child subscriptions that attempt
|
||||
// to remove themselves from this subscription will noop
|
||||
this._subscriptions = null;
|
||||
|
||||
if (_parentOrParents instanceof Subscription) {
|
||||
_parentOrParents.remove(this);
|
||||
} else if (_parentOrParents !== null) {
|
||||
for (let index = 0; index < _parentOrParents.length; ++index) {
|
||||
const parent = _parentOrParents[index];
|
||||
parent.remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
if (isFunction(_unsubscribe)) {
|
||||
// It's only possible to null _unsubscribe - to release the reference to
|
||||
// any teardown function passed in the constructor - if the property was
|
||||
// actually assigned in the constructor, as there are some classes that
|
||||
// are derived from Subscriber (which derives from Subscription) that
|
||||
// implement an _unsubscribe method as a mechanism for obtaining
|
||||
// unsubscription notifications and some of those subscribers are
|
||||
// recycled. Also, in some of those subscribers, _unsubscribe switches
|
||||
// from a prototype method to an instance property - see notifyNext in
|
||||
// RetryWhenSubscriber.
|
||||
if (_ctorUnsubscribe) {
|
||||
(this as any)._unsubscribe = undefined;
|
||||
}
|
||||
try {
|
||||
_unsubscribe.call(this);
|
||||
} catch (e) {
|
||||
errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
|
||||
}
|
||||
}
|
||||
|
||||
if (isArray(_subscriptions)) {
|
||||
let index = -1;
|
||||
let len = _subscriptions.length;
|
||||
|
||||
while (++index < len) {
|
||||
const sub = _subscriptions[index];
|
||||
if (isObject(sub)) {
|
||||
try {
|
||||
sub.unsubscribe();
|
||||
} catch (e) {
|
||||
errors = errors || [];
|
||||
if (e instanceof UnsubscriptionError) {
|
||||
errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
|
||||
} else {
|
||||
errors.push(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (errors) {
|
||||
throw new UnsubscriptionError(errors);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a tear down to be called during the unsubscribe() of this
|
||||
* Subscription. Can also be used to add a child subscription.
|
||||
*
|
||||
* If the tear down being added is a subscription that is already
|
||||
* unsubscribed, is the same reference `add` is being called on, or is
|
||||
* `Subscription.EMPTY`, it will not be added.
|
||||
*
|
||||
* If this subscription is already in an `closed` state, the passed
|
||||
* tear down logic will be executed immediately.
|
||||
*
|
||||
* When a parent subscription is unsubscribed, any child subscriptions that were added to it are also unsubscribed.
|
||||
*
|
||||
* @param {TeardownLogic} teardown The additional logic to execute on
|
||||
* teardown.
|
||||
* @return {Subscription} Returns the Subscription used or created to be
|
||||
* added to the inner subscriptions list. This Subscription can be used with
|
||||
* `remove()` to remove the passed teardown logic from the inner subscriptions
|
||||
* list.
|
||||
*/
|
||||
add(teardown: TeardownLogic): Subscription {
|
||||
let subscription = (<Subscription>teardown);
|
||||
|
||||
if (!teardown) {
|
||||
return Subscription.EMPTY;
|
||||
}
|
||||
|
||||
switch (typeof teardown) {
|
||||
case 'function':
|
||||
subscription = new Subscription(<(() => void)>teardown);
|
||||
case 'object':
|
||||
if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
|
||||
// This also covers the case where `subscription` is `Subscription.EMPTY`, which is always in `closed` state.
|
||||
return subscription;
|
||||
} else if (this.closed) {
|
||||
subscription.unsubscribe();
|
||||
return subscription;
|
||||
} else if (!(subscription instanceof Subscription)) {
|
||||
const tmp = subscription;
|
||||
subscription = new Subscription();
|
||||
subscription._subscriptions = [tmp];
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
|
||||
}
|
||||
}
|
||||
|
||||
// Add `this` as parent of `subscription` if that's not already the case.
|
||||
let { _parentOrParents } = subscription;
|
||||
if (_parentOrParents === null) {
|
||||
// If we don't have a parent, then set `subscription._parents` to
|
||||
// the `this`, which is the common case that we optimize for.
|
||||
subscription._parentOrParents = this;
|
||||
} else if (_parentOrParents instanceof Subscription) {
|
||||
if (_parentOrParents === this) {
|
||||
// The `subscription` already has `this` as a parent.
|
||||
return subscription;
|
||||
}
|
||||
// If there's already one parent, but not multiple, allocate an
|
||||
// Array to store the rest of the parent Subscriptions.
|
||||
subscription._parentOrParents = [_parentOrParents, this];
|
||||
} else if (_parentOrParents.indexOf(this) === -1) {
|
||||
// Only add `this` to the _parentOrParents list if it's not already there.
|
||||
_parentOrParents.push(this);
|
||||
} else {
|
||||
// The `subscription` already has `this` as a parent.
|
||||
return subscription;
|
||||
}
|
||||
|
||||
// Optimize for the common case when adding the first subscription.
|
||||
const subscriptions = this._subscriptions;
|
||||
if (subscriptions === null) {
|
||||
this._subscriptions = [subscription];
|
||||
} else {
|
||||
subscriptions.push(subscription);
|
||||
}
|
||||
|
||||
return subscription;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a Subscription from the internal list of subscriptions that will
|
||||
* unsubscribe during the unsubscribe process of this Subscription.
|
||||
* @param {Subscription} subscription The subscription to remove.
|
||||
* @return {void}
|
||||
*/
|
||||
remove(subscription: Subscription): void {
|
||||
const subscriptions = this._subscriptions;
|
||||
if (subscriptions) {
|
||||
const subscriptionIndex = subscriptions.indexOf(subscription);
|
||||
if (subscriptionIndex !== -1) {
|
||||
subscriptions.splice(subscriptionIndex, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function flattenUnsubscriptionErrors(errors: any[]) {
|
||||
return errors.reduce((errs, err) => errs.concat((err instanceof UnsubscriptionError) ? err.errors : err), []);
|
||||
}
|
||||
@@ -0,0 +1,530 @@
|
||||
# tinro
|
||||
|
||||
   
|
||||
|
||||
|
||||
tinro is a highly declarative, [tiny](https://github.com/AlexxNB/tinro/blob/master/COMPARE.md)), dependency free router for [Svelte](https://svelte.dev) web applications.
|
||||
|
||||
## Features
|
||||
|
||||
* Just one component to declare routes in your app
|
||||
* Links are just common native `<a>` elements
|
||||
* History API, Hash-based, or in-memory navigation
|
||||
* Simple nested routes
|
||||
* Routes with parameters (`/hello/:name`)
|
||||
* Redirects
|
||||
* Fallbacks on any nested level
|
||||
* Parsing query parameters (`?x=42&hello=world&fruits=apple,banana,orange`)
|
||||
* Manage URL's hash and query parts
|
||||
* [Svelte's REPL](https://svelte.dev/repl/4bc37ff40ada4111b71fe292a4eb90f6) compatible
|
||||
|
||||
## Documentation
|
||||
|
||||
* [Install](#install)
|
||||
* [Getting started](#getting-started)
|
||||
* [Nesting](#nesting)
|
||||
* [Links](#links)
|
||||
* [Redirects](#redirects)
|
||||
* [Fallbacks](#fallbacks)
|
||||
* [Route meta](#route-meta)
|
||||
- [url](#metaurl)
|
||||
- [pattern](#metapattern)
|
||||
- [match](#metamatch)
|
||||
- [from](#metafrom)
|
||||
- [query](#metaquery)
|
||||
- [params](#metaparams)
|
||||
- [breadcrumbs](#metabreadcrumbs)
|
||||
* [~~Parameters~~ (Deprecated since 0.5.0)](#parameters)
|
||||
* [Navigation method](#navigation-method)
|
||||
* [Manage hash and query](#manage-hash-and-query)
|
||||
* [API](#api)
|
||||
* [Recipes](#recipes)
|
||||
- [Lazy loading](#lazy-loading-components)
|
||||
- [Transitions](#transitions)
|
||||
- [Guarded routes](#guarded-routes)
|
||||
- [Scroll to top](#scroll-to-top)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
Install tinro as a dev dependency in your Svelte project:
|
||||
|
||||
```shell
|
||||
$ npm i -D tinro
|
||||
```
|
||||
|
||||
## Getting started
|
||||
|
||||
**tinro is very simple!** It provides just *one component* — `<Route>`. A common app structure looks like this:
|
||||
|
||||
```html
|
||||
<script>
|
||||
import {Route} from 'tinro';
|
||||
import Contacts from './Contacts.svelte'; // <h1>Contacts</h1>
|
||||
</script>
|
||||
|
||||
<nav>
|
||||
<a href="/">Home</a>
|
||||
<a href="/portfolio">Portfolio</a>
|
||||
<a href="/contacts">Contacts</a>
|
||||
</nav>
|
||||
|
||||
<Route path="/"><h1>This is the main page</h1></Route>
|
||||
<Route path="/portfolio/*">
|
||||
<Route path="/">
|
||||
<h1>Portfolio introduction</h1>
|
||||
<nav>
|
||||
<a href="/portfolio/sites">Sites</a>
|
||||
<a href="/portfolio/photos">Photos</a>
|
||||
</nav>
|
||||
</Route>
|
||||
<Route path="/sites"><h1>Portfolio: Sites</h1></Route>
|
||||
<Route path="/photos"><h1>Portfolio: Photos</h1></Route>
|
||||
</Route>
|
||||
<Route path="/contacts"><Contacts /></Route>
|
||||
```
|
||||
See the example in action in [Svelte's REPL](https://svelte.dev/repl/4bc37ff40ada4111b71fe292a4eb90f6)
|
||||
|
||||
## Nesting
|
||||
|
||||
There are two types of routes you can declare in the `<Route>` component's `path` property:
|
||||
|
||||
### Exact path
|
||||
|
||||
Shows its content only when `path` matches the URL of the page *exactly*. You can't place a nested `<Route>` inside these components.
|
||||
|
||||
```html
|
||||
<Route path="/">...</Route>
|
||||
<Route path="/page">...</Route>
|
||||
<Route path="/page/subpage">...</Route>
|
||||
```
|
||||
|
||||
### Non-exact path
|
||||
|
||||
`<Route>` components with a `path` property that ends with `/*` show their content when a part of the page's URL matches with the path before the `/*`. A nested `<Route>` can be placed inside components with a non-exact path only.
|
||||
|
||||
```html
|
||||
<Route path="/books/*">
|
||||
Books list:
|
||||
<Route path="/fiction">...</Route>
|
||||
<Route path="/drama">...</Route>
|
||||
</Route>
|
||||
```
|
||||
|
||||
The `path` property of a nested `<Route>` is relative to its parent. To see the _Fiction_ category in the above example, you would point your browser to `http://mysite.com/books/fiction`.
|
||||
|
||||
Nested routes also work inside child components. So, we can rewrite the example this way:
|
||||
|
||||
```html
|
||||
<!-- Bookslist.svelte-->
|
||||
...
|
||||
Books list:
|
||||
<Route path="/fiction">...</Route>
|
||||
<Route path="/drama">...</Route>
|
||||
|
||||
<!-- App.svelte-->
|
||||
...
|
||||
<Route path="/books/*">
|
||||
<Bookslist/>
|
||||
</Route>
|
||||
```
|
||||
|
||||
### Show first matched nested route only
|
||||
|
||||
Sometimes, you need to show only the first nested route from all those matched with a given URL. Use the `firstmatch` property on the parent `Route`:
|
||||
|
||||
```html
|
||||
<Route path="/user/*" firstmatch>
|
||||
|
||||
<!-- Will be open when URL is /user/add -->
|
||||
<Route path="/add">Add new user</Route>
|
||||
|
||||
<!-- Will be open when URL is /user/alex or /user/bob, but not /user/add -->
|
||||
<Route path="/:username" let:meta>Show user {meta.params.username}'s profile</Route>
|
||||
|
||||
</Route>
|
||||
```
|
||||
|
||||
## Links
|
||||
|
||||
There is no special component for links. Just use native `<a>` elements. When the `href` attribute starts with a single `/` (like `/mypage` or just `/`), it will be treated as an internal link which will be matched with defined routes. Other cases do not affect the links' behavior.
|
||||
|
||||
All internal links will be passed into the tinro router. However, it is possible to prevent this by adding the `tinro-ignore` or `data-tinro-ignore` attributes:
|
||||
|
||||
```html
|
||||
<a href="/api/auth" tinro-ignore>Go to API page</a>
|
||||
```
|
||||
|
||||
If you need to add the `active` class to links where the path corresponds to the current URL, use the `active` action from the `tinro` package:
|
||||
|
||||
```html
|
||||
<script>
|
||||
import {active} from 'tinro';
|
||||
</script>
|
||||
|
||||
<!-- Common usage:
|
||||
class `active` will be added when URL is '/page' or any relative path like '/page/sub/sub' -->
|
||||
<a href="/page" use:active>Link</a>
|
||||
|
||||
<!-- Exact match:
|
||||
class `active` will be added only when URL exactly equals '/page' (but NOT '/page/sub') -->
|
||||
<a href="/page" use:active exact>Link</a>
|
||||
|
||||
<!-- Custom class:
|
||||
class `myactive` will be added if link is active -->
|
||||
<a href="/page" use:active active-class="myactive">Link</a>
|
||||
|
||||
<!-- Valid HTML usage:
|
||||
if you prefer to have valid HTML use `data-` prefix -->
|
||||
<a href="/page" use:active data-exact data-active-class="myactive">Link</a>
|
||||
```
|
||||
|
||||
## Redirects
|
||||
|
||||
You can redirect the browser to any path by using the `redirect` property:
|
||||
|
||||
```html
|
||||
<!-- Exact redirect -->
|
||||
<Route path="/noenter" redirect="/newurl"/>
|
||||
|
||||
<!-- Non-exact redirect will also work for any nested path -->
|
||||
<Route path="/noenter/*" redirect="/newurl"/>
|
||||
```
|
||||
|
||||
You can also redirect to a relative path — just write the new URL without `/` in front of it:
|
||||
|
||||
```html
|
||||
<!-- This will redirect to /subpage/newurl -->
|
||||
<Route path="/subpage/*">
|
||||
<Route path="/" redirect="newurl"/>
|
||||
</Route>
|
||||
```
|
||||
|
||||
## Fallbacks
|
||||
|
||||
Routes with the `fallback` property show their content when no matched address was found. Fallbacks may be placed inside a non-exact `<Route>` only. Fallbacks bubble, so if there is no fallback on the current level, the router will try to find one on any parent levels. See the example:
|
||||
|
||||
```html
|
||||
<Route> <!-- same as <Route path="/*"> -->
|
||||
<Route path="/">Root page</Route>
|
||||
<Route path="/page">Page</Route>
|
||||
<Route path="/sub1/*">
|
||||
<Route path="/subpage">Subpage1</Route>
|
||||
</Route>
|
||||
<Route path="/sub2/*">
|
||||
<Route path="/subpage">Subpage2</Route>
|
||||
<Route fallback>No subpage found</Route>
|
||||
</Route>
|
||||
<Route fallback>No page found</Route>
|
||||
</Route>
|
||||
|
||||
<a href="/">...</a> <!-- shows Root page -->
|
||||
<a href="/page">...</a> <!-- shows Page -->
|
||||
<a href="/blah">...</a> <!-- shows No page found -->
|
||||
<a href="/sub1/subpage">...</a> <!-- shows Subpage1 -->
|
||||
<a href="/sub1/blah">...</a> <!-- shows No page found -->
|
||||
<a href="/sub1/blah/blah">...</a> <!-- shows No page found -->
|
||||
<a href="/sub2/subpage">...</a> <!-- shows Subpage2 -->
|
||||
<a href="/sub2/blah">...</a> <!-- shows No subpage found -->
|
||||
<a href="/sub2/blah/blah">...</a> <!-- shows No subpage found -->
|
||||
```
|
||||
|
||||
## Route meta
|
||||
|
||||
You can get useful meta data for each route by importing and calling `meta` from the `tinro` package. Notice, that `meta()` must be called only inside any `<Route>`'s child component.
|
||||
|
||||
```html
|
||||
<script>
|
||||
import {meta} from 'tinro';
|
||||
const route = meta();
|
||||
</script>
|
||||
|
||||
<h1>My URL is {route.url}!</h1>
|
||||
|
||||
<!-- If you need reactive updates, use it as a store -->
|
||||
<h1>My URL is {$route.url}!</h1>
|
||||
```
|
||||
|
||||
You can also get meta data with the `let:meta` directive:
|
||||
|
||||
```html
|
||||
<Route path="/hello" let:meta>
|
||||
<h1>My URL is {meta.url}!</h1>
|
||||
</Route>
|
||||
```
|
||||
|
||||
### `meta.url`
|
||||
|
||||
Current browser URL (includes query).
|
||||
|
||||
*Example: `/books/stanislaw_lem/page2?order=descend`*
|
||||
|
||||
|
||||
### `meta.pattern`
|
||||
|
||||
The pattern of the route path, including parameter placeholders. It is a combination of the `path` properties of all parent routes.
|
||||
|
||||
*Example: `/books/:author`*
|
||||
|
||||
### `meta.match`
|
||||
|
||||
Part of the browser URL that is matched with the route pattern.
|
||||
|
||||
*Example: `/books/stanislaw_lem`*
|
||||
|
||||
### `meta.from`
|
||||
|
||||
If present, the value of the browser URL before navigation to the current page. Useful to make a back button, for example.
|
||||
|
||||
*Example: `/books/stanislaw_lem/page1?order=descend`*
|
||||
|
||||
### `meta.query`
|
||||
|
||||
Object containing keys/values from the browser URL query string (if present).
|
||||
|
||||
*Example: `{order: "descend"}`*
|
||||
|
||||
### `meta.params`
|
||||
|
||||
If the route pattern has parameters, their values will be in the `meta.params` object.
|
||||
|
||||
```html
|
||||
<!-- Example for URL "/books/stanislaw_lem/solaris"> -->
|
||||
<Route path="/books/:author/*" let:meta>
|
||||
|
||||
<!-- meta.params here {author:stanislaw_lem} -->
|
||||
Author: {meta.params.author}
|
||||
|
||||
<Route path="/:title" let:meta>
|
||||
|
||||
<!-- meta.params here {author:stanislaw_lem, title:solaris} -->
|
||||
Book: {meta.params.title}
|
||||
|
||||
</Route>
|
||||
</Route>
|
||||
```
|
||||
|
||||
### `meta.breadcrumbs`
|
||||
|
||||
All parent routes that have a `breadcrumb` property will add a breadcrumb to the `meta.breadcrumbs` array. Each breadcrumb is an object with `name` and `path` fields.
|
||||
|
||||
|
||||
```html
|
||||
<Route path="/*" breadcrumb="Home">
|
||||
<Route path="/portfolio" breadcrumb="My Portfolio" let:meta>
|
||||
<ul class="breadcrumbs">
|
||||
{#each meta.breadcrumbs as bc}
|
||||
<li><a href={bc.path}>{bc.name}</a></li>
|
||||
{/each}
|
||||
</ul>
|
||||
|
||||
This is my portfolio
|
||||
</Route>
|
||||
</Route>
|
||||
```
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
> **!** *`route.params` and `let:params` are DEPRECATED since v.0.5.0. and will be deleted in future versions!*
|
||||
|
||||
See [meta.params](#metaparams) section
|
||||
|
||||
## Navigation method
|
||||
|
||||
By default, navigation uses the `History API` which allows you to have clean page URLs, although it needs some setup on the server side. Instead, you may choose to use `hash` or `memory` navigation methods. There is no need to change links or paths in your app, everything else will still work the same.
|
||||
|
||||
```html
|
||||
<!-- Root file of your project, ex. App.svelte -->
|
||||
<script>
|
||||
import {Route,router} from 'tinro';
|
||||
|
||||
router.mode.hash(); // enables hash navigation method
|
||||
|
||||
// - OR -
|
||||
|
||||
router.mode.memory(); // enables in-memory navigation method
|
||||
</script>
|
||||
|
||||
<!-- Link will point browser to '/#/page/subpage' -->
|
||||
<a href="/page/subpage">Subpage</a>
|
||||
|
||||
<!-- Route shows content when URL is '/#/page/subpage' -->
|
||||
<Route path="/page/subpage">Subpage content</Route>
|
||||
```
|
||||
|
||||
*Note: default navigation method in non-browser environment or inside iframes is `memory`*
|
||||
|
||||
### Server side setup for History API method
|
||||
|
||||
When you use the `History API` and point the browser to the root path `/` (usually `/index.html`) all links and Routes will work properly. But when you start your app on any subpage, like `/page/subpage`, you will see the `404 Not found` error. Because of this, you need to setup your server to point all requests to `/index.html`.
|
||||
|
||||
This is easy if you use the [official Svelte template](https://github.com/sveltejs/template). Just open `package.json` and find this NPM script:
|
||||
|
||||
```json
|
||||
"start": "sirv public"
|
||||
```
|
||||
|
||||
Replace it with this line:
|
||||
|
||||
```json
|
||||
"start": "sirv public --single"
|
||||
```
|
||||
|
||||
Now, start your app with `npm run dev` and open a URL like `http://localhost:5000/page/subpage`. You should see the app page, instead of the "Not found" error.
|
||||
|
||||
*For other servers you can read the following links: [Nginx](https://www.nginx.com/blog/creating-nginx-rewrite-rules/#Example %E2%80%93-Enabling-Pretty-Permalinks-for-WordPress-Websites), [Apache](https://httpd.apache.org/docs/2.4/rewrite/remapping.html#fallback-Resource), [Caddy](https://caddyserver.com/docs/caddyfile/directives/rewrite#examples)*
|
||||
|
||||
## Manage hash and query
|
||||
|
||||
You can change URL's parts (such as query and hash) using `router.location` methods:
|
||||
|
||||
```javascript
|
||||
import {router} from 'tinro';
|
||||
|
||||
router.goto('/foo'); //URL: /foo
|
||||
router.location.query.set('name','alex'); //URL: /foo?name=alex
|
||||
router.location.hash.set('bar'); //URL: /foo?name=alex#bar
|
||||
router.location.query.set('page',1); //URL: /foo?name=alex&page=1#bar
|
||||
router.location.query.replace({hello: 'world'}); //URL: /foo?hello=world#bar
|
||||
router.location.query.clear(); //URL: /foo#bar
|
||||
router.location.hash.clear(); //URL: /foo
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
You can import the `router` object from the `tinro` package:
|
||||
|
||||
### `router.goto(href)`
|
||||
Programmatically change the URL of the current page.
|
||||
|
||||
### `router.mode`
|
||||
Methods to change curent router mode:
|
||||
|
||||
* `history()` - set HistoryAPI navigation method
|
||||
* `hash()` - set hash navigation method
|
||||
* `memory()` - set memory navigation method
|
||||
|
||||
### `router.location.hash`
|
||||
Methods, which allows to get or set current value of the URL's hash part:
|
||||
|
||||
* `get()` - get current hash value
|
||||
* `set(value)` - set new hash value
|
||||
* `clear()` - remove hash from the current URL
|
||||
|
||||
### `router.location.query`
|
||||
Methods, which allows to get or modify current value of the URL's query part:
|
||||
|
||||
* `get(name?)` - get current query object, or its property value when `name` specified
|
||||
* `set(name,value)` - update or add query property by `name`
|
||||
* `delete(name)` - remove property with specified `name` from the query object
|
||||
* `replace(object)` - replace current query object with new one
|
||||
* `clear()` - remove query from the current URL
|
||||
|
||||
### `router.subscribe(func)`
|
||||
The `router` object is a valid Svelte store, so you can subscribe to get the changing navigation data. `func` gets an object with page data:
|
||||
|
||||
* `url` - current browser URL (with query string)
|
||||
* `from` - previous URL before navigation to current page (if present)
|
||||
* `path` - current browser URL
|
||||
* `hash` - the hash part of the URL, after `#` sign
|
||||
* `query` - object, containing parsed query string
|
||||
|
||||
Note: you can use Svelte's auto-subscription to retrieve data from the `router` store:
|
||||
|
||||
```html
|
||||
<script>
|
||||
import {router} from 'tinro';
|
||||
</script>
|
||||
|
||||
Current page URL is: {$router.path}
|
||||
```
|
||||
### `router.mode.[history()|hash()|memory()]`
|
||||
Run this in the app's root file to set the navigation method you need.
|
||||
|
||||
### `router.params()`
|
||||
Deprecated. See `router.meta` instead.
|
||||
|
||||
## Recipes
|
||||
|
||||
tinro is not the most powerful router among all those available for Svelte applications. We prefer a smaller footprint in your bundles over having all possible features out of the box. But you can easily code some features yourself using the recipies below:
|
||||
|
||||
### Lazy loading components
|
||||
|
||||
If you want to have code-splitting and load components only when that page is requested, make this little component:
|
||||
|
||||
```html
|
||||
<!-- Lazy.svelte-->
|
||||
<script>
|
||||
export let component;
|
||||
</script>
|
||||
|
||||
{#await component.then ? component : component()}
|
||||
Loading component...
|
||||
{:then Cmp}
|
||||
<svelte:component this={Cmp.default} />
|
||||
{/await}
|
||||
```
|
||||
|
||||
And use it when you need a lazy loaded component in your routes:
|
||||
|
||||
```html
|
||||
<Route path="/lazypage">
|
||||
<Lazy component={()=>import('./mypage.svelte')}/>
|
||||
<!-- OR -->
|
||||
<Lazy component={import('./mypage.svelte')}/>
|
||||
</Route>
|
||||
```
|
||||
|
||||
### Transitions
|
||||
|
||||
If you want a transiton when the path changes, create a component like this:
|
||||
|
||||
```html
|
||||
<!-- Transition.svelte -->
|
||||
<script>
|
||||
import {router} from 'tinro';
|
||||
import {fade} from 'svelte/transition';
|
||||
</script>
|
||||
|
||||
{#key $router.path}
|
||||
<div in:fade="{{ duration: 700}}">
|
||||
<slot></slot>
|
||||
</div>
|
||||
{/key}
|
||||
```
|
||||
|
||||
Then, put your routes inside the *Transition* component:
|
||||
|
||||
```html
|
||||
<Transition>
|
||||
<Route path="/">...</Route>
|
||||
<Route path="/page1">...</Route>
|
||||
<Route path="/page2">...</Route>
|
||||
</Transition>
|
||||
```
|
||||
|
||||
### Guarded routes
|
||||
|
||||
You can protect routes from being loaded using only Svelte's logic blocks, like the `{#if}` statement:
|
||||
|
||||
```html
|
||||
{#if user.authed}
|
||||
<Route path="/profile">This is a private page...</Route>
|
||||
{:else}
|
||||
<Route path="/profile"><a href="/login">Please sign in first</a></Route>
|
||||
<Route path="/login">This is the sign in form...</Route>
|
||||
{/if}
|
||||
```
|
||||
|
||||
You can also create a special guard component as shown in [this example](https://svelte.dev/repl/5673ff403af14411b0cd1785be3d996f).
|
||||
|
||||
|
||||
### Scroll to top
|
||||
|
||||
tinro doesn't control scrolling in your app, but sometimes you need to scroll to the top of the page after navigation. To do this, just add the `router` store subscription to your root component (ex. `App.svelte`). This way you can run any actions (not just scrolling) every time the `URL` changes.
|
||||
|
||||
```javascript
|
||||
import {router} from `tinro`;
|
||||
router.subscribe( _ => window.scrollTo(0, 0));
|
||||
```
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"isDate.js","sources":["../src/util/isDate.ts"],"names":[],"mappings":";;;;;AAAA,6CAAwC"}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={C:{"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0.01858,"53":0,"54":0,"55":0,"56":0,"57":0.00465,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0.00232,"69":0.00232,"70":0.00465,"71":0,"72":0.00232,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0.00697,"79":0,"80":0,"81":0.00232,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0.00232,"92":0,"93":0,"94":0,"95":0.00232,"96":0,"97":0,"98":0,"99":0.00232,"100":0.00232,"101":0,"102":0.00697,"103":0.00232,"104":0.00232,"105":0.00232,"106":0.00232,"107":0.00929,"108":0.26947,"109":0.1719,"110":0,"111":0,"3.5":0,"3.6":0},D:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0.00232,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0.00232,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0.00232,"32":0,"33":0.00232,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0.00232,"41":0,"42":0.00232,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0.00697,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0.00232,"61":0,"62":0,"63":0,"64":0.00232,"65":0.00465,"66":0,"67":0,"68":0.00232,"69":0.00465,"70":0.00232,"71":0.00232,"72":0,"73":0,"74":0.00232,"75":0.00232,"76":0.00232,"77":0.00232,"78":0,"79":0.00697,"80":0.00232,"81":0.01626,"83":0,"84":0,"85":0.00232,"86":0.00232,"87":0.00465,"88":0.00465,"89":0,"90":0.00465,"91":0.00465,"92":0.00232,"93":0.01162,"94":0.00232,"95":0.00232,"96":0.00232,"97":0.00232,"98":0.00232,"99":0.00232,"100":0.00232,"101":0.00232,"102":0.00697,"103":0.04646,"104":0.00465,"105":0.00697,"106":0.00697,"107":0.01858,"108":1.22887,"109":1.35896,"110":0,"111":0,"112":0},F:{"9":0,"11":0,"12":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0.00465,"47":0,"48":0,"49":0,"50":0.00697,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"60":0,"62":0,"63":0.00232,"64":0.00232,"65":0,"66":0.00232,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0.00465,"80":0,"81":0,"82":0,"83":0,"84":0.00232,"85":0.00232,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0.00465,"94":0.08595,"9.5-9.6":0,"10.0-10.1":0,"10.5":0.00232,"10.6":0.00232,"11.1":0,"11.5":0,"11.6":0,"12.1":0},B:{"12":0.00232,"13":0.00232,"14":0.00232,"15":0.01394,"16":0,"17":0.00232,"18":0.01162,"79":0,"80":0,"81":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0.00232,"92":0.00232,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0.00232,"101":0,"102":0,"103":0,"104":0.00232,"105":0.00232,"106":0.00697,"107":0.01394,"108":0.27411,"109":0.31825},E:{"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0.00232,"14":0.00697,"15":0.00232,_:"0","3.1":0,"3.2":0,"5.1":0,"6.1":0,"7.1":0,"9.1":0,"10.1":0,"11.1":0,"12.1":0.00465,"13.1":0.01162,"14.1":0.01626,"15.1":0,"15.2-15.3":0.00232,"15.4":0.00232,"15.5":0.00929,"15.6":0.03949,"16.0":0.00697,"16.1":0.01626,"16.2":0.03485,"16.3":0.00232},G:{"8":0.02514,"3.2":0,"4.0-4.1":0,"4.2-4.3":0,"5.0-5.1":0,"6.0-6.1":0,"7.0-7.1":0.07263,"8.1-8.4":0,"9.0-9.2":0.06146,"9.3":0.0866,"10.0-10.2":0.06984,"10.3":0.32963,"11.0-11.2":0.07822,"11.3-11.4":0.00838,"12.0-12.1":0.18716,"12.2-12.5":1.94145,"13.0-13.1":0.05028,"13.2":0.05308,"13.3":0.14805,"13.4-13.7":0.41622,"14.0-14.4":1.44142,"14.5-14.8":2.12023,"15.0-15.1":0.68719,"15.2-15.3":0.65925,"15.4":0.69278,"15.5":1.27102,"15.6":2.46382,"16.0":2.35767,"16.1":5.10643,"16.2":4.15945,"16.3":0.39108},P:{"4":0.40348,"5.0-5.4":0.02017,"6.2-6.4":0.03026,"7.2-7.4":0.37322,"8.2":0,"9.2":0.04035,"10.1":0.02017,"11.1-11.2":0.12104,"12.0":0.02017,"13.0":0.06052,"14.0":0.05043,"15.0":0.05043,"16.0":0.13113,"17.0":0.14122,"18.0":0.16139,"19.0":1.49287},I:{"0":0,"3":0,"4":0,"2.1":0,"2.2":0,"2.3":0,"4.1":0.00185,"4.2-4.3":0.00296,"4.4":0,"4.4.3-4.4.4":0.07538},K:{_:"0 10 11 12 11.1 11.5 12.1"},A:{"6":0,"7":0,"8":0,"9":0,"10":0,"11":0.01858,"5.5":0},J:{"7":0,"10":0.00768},N:{"10":0,"11":0},S:{"2.5":0.06142},R:{_:"0"},M:{"0":0.15354},Q:{"13.1":0},O:{"0":0.03071},H:{"0":0.3634},L:{"0":65.99809}};
|
||||
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"name": "@octokit/rest",
|
||||
"description": "GitHub REST API client for Node.js",
|
||||
"version": "18.5.2",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"dist-*/",
|
||||
"bin/"
|
||||
],
|
||||
"pika": true,
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"octokit",
|
||||
"github",
|
||||
"rest",
|
||||
"api-client"
|
||||
],
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Mike de Boer",
|
||||
"email": "info@mikedeboer.nl"
|
||||
},
|
||||
{
|
||||
"name": "Fabian Jakobs",
|
||||
"email": "fabian@c9.io"
|
||||
},
|
||||
{
|
||||
"name": "Joe Gallo",
|
||||
"email": "joe@brassafrax.com"
|
||||
},
|
||||
{
|
||||
"name": "Gregor Martynus",
|
||||
"url": "https://github.com/gr2m"
|
||||
}
|
||||
],
|
||||
"repository": "github:octokit/rest.js",
|
||||
"dependencies": {
|
||||
"@octokit/core": "^3.2.3",
|
||||
"@octokit/plugin-paginate-rest": "^2.6.2",
|
||||
"@octokit/plugin-request-log": "^1.0.2",
|
||||
"@octokit/plugin-rest-endpoint-methods": "5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@octokit/auth": "^3.0.1",
|
||||
"@octokit/fixtures-server": "^6.0.11",
|
||||
"@octokit/request": "^5.2.0",
|
||||
"@pika/pack": "^0.5.0",
|
||||
"@pika/plugin-build-node": "^0.9.2",
|
||||
"@pika/plugin-build-web": "^0.9.2",
|
||||
"@pika/plugin-ts-standard-pkg": "^0.9.2",
|
||||
"@types/jest": "^26.0.0",
|
||||
"@types/node": "^14.0.1",
|
||||
"fetch-mock": "^9.0.0",
|
||||
"jest": "^26.0.0",
|
||||
"prettier": "^2.0.0",
|
||||
"semantic-release": "^17.0.0",
|
||||
"semantic-release-plugin-update-version-in-files": "^1.0.0",
|
||||
"ts-jest": "^26.0.0",
|
||||
"typescript": "^4.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"source": "dist-src/index.js",
|
||||
"types": "dist-types/index.d.ts",
|
||||
"main": "dist-node/index.js",
|
||||
"module": "dist-web/index.js"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"2":"J E F G A B BC"},B:{"2":"C K L H M N O P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t"},C:{"2":"0 1 2 3 4 5 6 7 8 9 CC tB I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB DC EC"},D:{"1":"xB yB FC","2":"0 1 2 3 4 5 6 7 8 9 I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t"},E:{"1":"G A B C K L H KC 0B qB rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC","2":"I u J E F GC zB HC IC JC"},F:{"2":"0 1 2 3 4 5 6 7 8 9 G B C H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d OC PC QC RC qB 9B SC rB"},G:{"1":"YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC 2B 3B 4B 5B sB 6B 7B 8B","2":"F zB TC AC UC VC WC XC"},H:{"2":"nC"},I:{"2":"tB I D oC pC qC rC AC sC tC"},J:{"2":"E A"},K:{"2":"A B C e qB 9B rB"},L:{"2":"D"},M:{"2":"D"},N:{"2":"A B"},O:{"2":"uC"},P:{"2":"I vC wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C"},Q:{"2":"1B"},R:{"2":"8C"},S:{"2":"9C"}},B:5,C:"selector list argument of :nth-child and :nth-last-child CSS pseudo-classes"};
|
||||
@@ -0,0 +1,309 @@
|
||||
// Type definitions for commander 2.11
|
||||
// Project: https://github.com/visionmedia/commander.js
|
||||
// Definitions by: Alan Agius <https://github.com/alan-agius4>, Marcelo Dezem <https://github.com/mdezem>, vvakame <https://github.com/vvakame>, Jules Randolph <https://github.com/sveinburne>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace local {
|
||||
|
||||
class Option {
|
||||
flags: string;
|
||||
required: boolean;
|
||||
optional: boolean;
|
||||
bool: boolean;
|
||||
short?: string;
|
||||
long: string;
|
||||
description: string;
|
||||
|
||||
/**
|
||||
* Initialize a new `Option` with the given `flags` and `description`.
|
||||
*
|
||||
* @param {string} flags
|
||||
* @param {string} [description]
|
||||
*/
|
||||
constructor(flags: string, description?: string);
|
||||
}
|
||||
|
||||
class Command extends NodeJS.EventEmitter {
|
||||
[key: string]: any;
|
||||
|
||||
args: string[];
|
||||
|
||||
/**
|
||||
* Initialize a new `Command`.
|
||||
*
|
||||
* @param {string} [name]
|
||||
*/
|
||||
constructor(name?: string);
|
||||
|
||||
/**
|
||||
* Set the program version to `str`.
|
||||
*
|
||||
* This method auto-registers the "-V, --version" flag
|
||||
* which will print the version number when passed.
|
||||
*
|
||||
* @param {string} str
|
||||
* @param {string} [flags]
|
||||
* @returns {Command} for chaining
|
||||
*/
|
||||
version(str: string, flags?: string): Command;
|
||||
|
||||
/**
|
||||
* Add command `name`.
|
||||
*
|
||||
* The `.action()` callback is invoked when the
|
||||
* command `name` is specified via __ARGV__,
|
||||
* and the remaining arguments are applied to the
|
||||
* function for access.
|
||||
*
|
||||
* When the `name` is "*" an un-matched command
|
||||
* will be passed as the first arg, followed by
|
||||
* the rest of __ARGV__ remaining.
|
||||
*
|
||||
* @example
|
||||
* program
|
||||
* .version('0.0.1')
|
||||
* .option('-C, --chdir <path>', 'change the working directory')
|
||||
* .option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')
|
||||
* .option('-T, --no-tests', 'ignore test hook')
|
||||
*
|
||||
* program
|
||||
* .command('setup')
|
||||
* .description('run remote setup commands')
|
||||
* .action(function() {
|
||||
* console.log('setup');
|
||||
* });
|
||||
*
|
||||
* program
|
||||
* .command('exec <cmd>')
|
||||
* .description('run the given remote command')
|
||||
* .action(function(cmd) {
|
||||
* console.log('exec "%s"', cmd);
|
||||
* });
|
||||
*
|
||||
* program
|
||||
* .command('teardown <dir> [otherDirs...]')
|
||||
* .description('run teardown commands')
|
||||
* .action(function(dir, otherDirs) {
|
||||
* console.log('dir "%s"', dir);
|
||||
* if (otherDirs) {
|
||||
* otherDirs.forEach(function (oDir) {
|
||||
* console.log('dir "%s"', oDir);
|
||||
* });
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* program
|
||||
* .command('*')
|
||||
* .description('deploy the given env')
|
||||
* .action(function(env) {
|
||||
* console.log('deploying "%s"', env);
|
||||
* });
|
||||
*
|
||||
* program.parse(process.argv);
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {string} [desc] for git-style sub-commands
|
||||
* @param {CommandOptions} [opts] command options
|
||||
* @returns {Command} the new command
|
||||
*/
|
||||
command(name: string, desc?: string, opts?: commander.CommandOptions): Command;
|
||||
|
||||
/**
|
||||
* Define argument syntax for the top-level command.
|
||||
*
|
||||
* @param {string} desc
|
||||
* @returns {Command} for chaining
|
||||
*/
|
||||
arguments(desc: string): Command;
|
||||
|
||||
/**
|
||||
* Parse expected `args`.
|
||||
*
|
||||
* For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`.
|
||||
*
|
||||
* @param {string[]} args
|
||||
* @returns {Command} for chaining
|
||||
*/
|
||||
parseExpectedArgs(args: string[]): Command;
|
||||
|
||||
/**
|
||||
* Register callback `fn` for the command.
|
||||
*
|
||||
* @example
|
||||
* program
|
||||
* .command('help')
|
||||
* .description('display verbose help')
|
||||
* .action(function() {
|
||||
* // output help here
|
||||
* });
|
||||
*
|
||||
* @param {(...args: any[]) => void} fn
|
||||
* @returns {Command} for chaining
|
||||
*/
|
||||
action(fn: (...args: any[]) => void): Command;
|
||||
|
||||
/**
|
||||
* Define option with `flags`, `description` and optional
|
||||
* coercion `fn`.
|
||||
*
|
||||
* The `flags` string should contain both the short and long flags,
|
||||
* separated by comma, a pipe or space. The following are all valid
|
||||
* all will output this way when `--help` is used.
|
||||
*
|
||||
* "-p, --pepper"
|
||||
* "-p|--pepper"
|
||||
* "-p --pepper"
|
||||
*
|
||||
* @example
|
||||
* // simple boolean defaulting to false
|
||||
* program.option('-p, --pepper', 'add pepper');
|
||||
*
|
||||
* --pepper
|
||||
* program.pepper
|
||||
* // => Boolean
|
||||
*
|
||||
* // simple boolean defaulting to true
|
||||
* program.option('-C, --no-cheese', 'remove cheese');
|
||||
*
|
||||
* program.cheese
|
||||
* // => true
|
||||
*
|
||||
* --no-cheese
|
||||
* program.cheese
|
||||
* // => false
|
||||
*
|
||||
* // required argument
|
||||
* program.option('-C, --chdir <path>', 'change the working directory');
|
||||
*
|
||||
* --chdir /tmp
|
||||
* program.chdir
|
||||
* // => "/tmp"
|
||||
*
|
||||
* // optional argument
|
||||
* program.option('-c, --cheese [type]', 'add cheese [marble]');
|
||||
*
|
||||
* @param {string} flags
|
||||
* @param {string} [description]
|
||||
* @param {((arg1: any, arg2: any) => void) | RegExp} [fn] function or default
|
||||
* @param {*} [defaultValue]
|
||||
* @returns {Command} for chaining
|
||||
*/
|
||||
option(flags: string, description?: string, fn?: ((arg1: any, arg2: any) => void) | RegExp, defaultValue?: any): Command;
|
||||
option(flags: string, description?: string, defaultValue?: any): Command;
|
||||
|
||||
/**
|
||||
* Allow unknown options on the command line.
|
||||
*
|
||||
* @param {boolean} [arg] if `true` or omitted, no error will be thrown for unknown options.
|
||||
* @returns {Command} for chaining
|
||||
*/
|
||||
allowUnknownOption(arg?: boolean): Command;
|
||||
|
||||
/**
|
||||
* Parse `argv`, settings options and invoking commands when defined.
|
||||
*
|
||||
* @param {string[]} argv
|
||||
* @returns {Command} for chaining
|
||||
*/
|
||||
parse(argv: string[]): Command;
|
||||
|
||||
/**
|
||||
* Parse options from `argv` returning `argv` void of these options.
|
||||
*
|
||||
* @param {string[]} argv
|
||||
* @returns {ParseOptionsResult}
|
||||
*/
|
||||
parseOptions(argv: string[]): commander.ParseOptionsResult;
|
||||
|
||||
/**
|
||||
* Return an object containing options as key-value pairs
|
||||
*
|
||||
* @returns {{[key: string]: string}}
|
||||
*/
|
||||
opts(): { [key: string]: string };
|
||||
|
||||
/**
|
||||
* Set the description to `str`.
|
||||
*
|
||||
* @param {string} str
|
||||
* @return {(Command | string)}
|
||||
*/
|
||||
description(str: string): Command;
|
||||
description(): string;
|
||||
|
||||
/**
|
||||
* Set an alias for the command.
|
||||
*
|
||||
* @param {string} alias
|
||||
* @return {(Command | string)}
|
||||
*/
|
||||
alias(alias: string): Command;
|
||||
alias(): string;
|
||||
|
||||
/**
|
||||
* Set or get the command usage.
|
||||
*
|
||||
* @param {string} str
|
||||
* @return {(Command | string)}
|
||||
*/
|
||||
usage(str: string): Command;
|
||||
usage(): string;
|
||||
|
||||
/**
|
||||
* Set the name of the command.
|
||||
*
|
||||
* @param {string} str
|
||||
* @return {Command}
|
||||
*/
|
||||
name(str: string): Command;
|
||||
|
||||
/**
|
||||
* Get the name of the command.
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
name(): string;
|
||||
|
||||
/**
|
||||
* Output help information for this command.
|
||||
*
|
||||
* @param {(str: string) => string} [cb]
|
||||
*/
|
||||
outputHelp(cb?: (str: string) => string): void;
|
||||
|
||||
/** Output help information and exit.
|
||||
*
|
||||
* @param {(str: string) => string} [cb]
|
||||
*/
|
||||
help(cb?: (str: string) => string): void;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare namespace commander {
|
||||
|
||||
type Command = local.Command
|
||||
|
||||
type Option = local.Option
|
||||
|
||||
interface CommandOptions {
|
||||
noHelp?: boolean;
|
||||
isDefault?: boolean;
|
||||
}
|
||||
|
||||
interface ParseOptionsResult {
|
||||
args: string[];
|
||||
unknown: string[];
|
||||
}
|
||||
|
||||
interface CommanderStatic extends Command {
|
||||
Command: typeof local.Command;
|
||||
Option: typeof local.Option;
|
||||
CommandOptions: CommandOptions;
|
||||
ParseOptionsResult: ParseOptionsResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare const commander: commander.CommanderStatic;
|
||||
export = commander;
|
||||
@@ -0,0 +1,33 @@
|
||||
import { AsyncAction } from './AsyncAction';
|
||||
import { Subscription } from '../Subscription';
|
||||
import { AsyncScheduler } from './AsyncScheduler';
|
||||
import { SchedulerAction } from '../types';
|
||||
export declare class VirtualTimeScheduler extends AsyncScheduler {
|
||||
maxFrames: number;
|
||||
protected static frameTimeFactor: number;
|
||||
frame: number;
|
||||
index: number;
|
||||
constructor(SchedulerAction?: typeof AsyncAction, maxFrames?: number);
|
||||
/**
|
||||
* Prompt the Scheduler to execute all of its queued actions, therefore
|
||||
* clearing its queue.
|
||||
* @return {void}
|
||||
*/
|
||||
flush(): void;
|
||||
}
|
||||
/**
|
||||
* We need this JSDoc comment for affecting ESDoc.
|
||||
* @nodoc
|
||||
*/
|
||||
export declare class VirtualAction<T> extends AsyncAction<T> {
|
||||
protected scheduler: VirtualTimeScheduler;
|
||||
protected work: (this: SchedulerAction<T>, state?: T) => void;
|
||||
protected index: number;
|
||||
protected active: boolean;
|
||||
constructor(scheduler: VirtualTimeScheduler, work: (this: SchedulerAction<T>, state?: T) => void, index?: number);
|
||||
schedule(state?: T, delay?: number): Subscription;
|
||||
protected requestAsyncId(scheduler: VirtualTimeScheduler, id?: any, delay?: number): any;
|
||||
protected recycleAsyncId(scheduler: VirtualTimeScheduler, id?: any, delay?: number): any;
|
||||
protected _execute(state: T, delay: number): any;
|
||||
static sortActions<T>(a: VirtualAction<T>, b: VirtualAction<T>): 1 | 0 | -1;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports={A:{A:{"1":"G A B","2":"J E BC","132":"F"},B:{"1":"C K L H M N O P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t"},C:{"1":"0 1 2 3 4 5 6 7 8 9 CC tB I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB DC EC"},D:{"1":"0 1 2 3 4 5 6 7 8 9 I u J E F G A B C K L H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB uB ZB vB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R S T U V W X Y Z a b c d f g h i j k l m n o p q r s D t xB yB FC"},E:{"1":"I u J E F G A B C K L H GC zB HC IC JC KC 0B qB rB 1B LC MC 2B 3B 4B 5B sB 6B 7B 8B NC"},F:{"1":"0 1 2 3 4 5 6 7 8 9 G B C H M N O v w x y z AB BB CB DB EB FB GB HB IB JB KB LB MB NB OB PB QB RB SB TB UB VB WB XB YB ZB aB bB cB dB eB fB gB hB iB jB kB e lB mB nB oB pB P Q R wB S T U V W X Y Z a b c d OC PC QC RC qB 9B SC rB"},G:{"1":"F zB TC AC UC VC WC XC YC ZC aC bC cC dC eC fC gC hC iC jC kC lC mC 2B 3B 4B 5B sB 6B 7B 8B"},H:{"1":"nC"},I:{"1":"tB I D oC pC qC rC AC sC tC"},J:{"1":"E A"},K:{"1":"A B C e qB 9B rB"},L:{"1":"D"},M:{"1":"D"},N:{"1":"A B"},O:{"1":"uC"},P:{"1":"I vC wC xC yC zC 0B 0C 1C 2C 3C 4C sB 5C 6C 7C"},Q:{"1":"1B"},R:{"1":"8C"},S:{"1":"9C"}},B:2,C:"CSS Generated content for pseudo-elements"};
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`.
|
||||
*/
|
||||
export type TypedArray =
|
||||
| Int8Array
|
||||
| Uint8Array
|
||||
| Uint8ClampedArray
|
||||
| Int16Array
|
||||
| Uint16Array
|
||||
| Int32Array
|
||||
| Uint32Array
|
||||
| Float32Array
|
||||
| Float64Array
|
||||
| BigInt64Array
|
||||
| BigUint64Array;
|
||||
Reference in New Issue
Block a user