Socket
Socket
Sign inDemoInstall

@cycle/history

Package Overview
Dependencies
25
Maintainers
3
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.0.0 to 7.1.0

6

CHANGELOG.md

@@ -0,1 +1,7 @@

## 7.1.0 (2018-12-10)
* fix(history): support TypeScript's strict mode ([1c25cab](https://github.com/cyclejs/cyclejs/commit/1c25cab))
## 7.0.0 (2018-10-17)

@@ -2,0 +8,0 @@

4

lib/cjs/captureClicks.js

@@ -62,3 +62,5 @@ "use strict";

}
return function () { return document.removeEventListener(CLICK_EVENT, listener); };
return function () {
return document.removeEventListener(CLICK_EVENT, listener);
};
}

@@ -65,0 +67,0 @@ function captureClicks(historyDriver) {

import { Stream, MemoryStream } from 'xstream';
import { Location, History } from 'history';
import { HistoryInput } from './types';
export declare function createHistory$(history: History, sink$: Stream<HistoryInput | string>): MemoryStream<Location>;
export declare function createHistory$(history: History, sink$: Stream<HistoryInput>): MemoryStream<Location>;

@@ -5,15 +5,3 @@ import { Stream, MemoryStream } from 'xstream';

export declare type Pathname = string;
export declare type HistoryDriver = Driver<Stream<HistoryInput | GenericInput | string>, MemoryStream<Location>>;
/**
* A "catch all" case that is necessary because sometimes the sink from the app
* is inferred by TypeScript to be {type: string, pathname: string} and this
* wouldn't match any of the other HistoryInput types below, because the
* property `type` was `string` and not e.g. `'push'`. Seems like a limitation
* in TypeScript for the time being.
*/
export declare type GenericInput = {
type: string;
pathname?: Pathname;
state?: any;
};
export declare type HistoryDriver = Driver<Stream<HistoryInput>, MemoryStream<Location>>;
export declare type PushHistoryInput = {

@@ -39,2 +27,2 @@ type: 'push';

};
export declare type HistoryInput = PushHistoryInput | ReplaceHistoryInput | GoHistoryInput | GoBackHistoryInput | GoForwardHistoryInput;
export declare type HistoryInput = PushHistoryInput | ReplaceHistoryInput | GoHistoryInput | GoBackHistoryInput | GoForwardHistoryInput | string;

@@ -60,3 +60,5 @@ import xs from 'xstream';

}
return function () { return document.removeEventListener(CLICK_EVENT, listener); };
return function () {
return document.removeEventListener(CLICK_EVENT, listener);
};
}

@@ -63,0 +65,0 @@ export function captureClicks(historyDriver) {

import { Stream, MemoryStream } from 'xstream';
import { Location, History } from 'history';
import { HistoryInput } from './types';
export declare function createHistory$(history: History, sink$: Stream<HistoryInput | string>): MemoryStream<Location>;
export declare function createHistory$(history: History, sink$: Stream<HistoryInput>): MemoryStream<Location>;

@@ -5,15 +5,3 @@ import { Stream, MemoryStream } from 'xstream';

export declare type Pathname = string;
export declare type HistoryDriver = Driver<Stream<HistoryInput | GenericInput | string>, MemoryStream<Location>>;
/**
* A "catch all" case that is necessary because sometimes the sink from the app
* is inferred by TypeScript to be {type: string, pathname: string} and this
* wouldn't match any of the other HistoryInput types below, because the
* property `type` was `string` and not e.g. `'push'`. Seems like a limitation
* in TypeScript for the time being.
*/
export declare type GenericInput = {
type: string;
pathname?: Pathname;
state?: any;
};
export declare type HistoryDriver = Driver<Stream<HistoryInput>, MemoryStream<Location>>;
export declare type PushHistoryInput = {

@@ -39,2 +27,2 @@ type: 'push';

};
export declare type HistoryInput = PushHistoryInput | ReplaceHistoryInput | GoHistoryInput | GoBackHistoryInput | GoForwardHistoryInput;
export declare type HistoryInput = PushHistoryInput | ReplaceHistoryInput | GoHistoryInput | GoBackHistoryInput | GoForwardHistoryInput | string;
{
"name": "@cycle/history",
"version": "7.0.0",
"version": "7.1.0",
"description": "The standard history driver for Cycle.js",

@@ -18,4 +18,4 @@ "main": "lib/cjs/index.js",

"dependencies": {
"@cycle/run": "^5.1.0",
"@types/history": "^4.7.1",
"@cycle/run": "^5.2.0",
"@types/history": "^4.7.2",
"history": "4.7.x",

@@ -25,8 +25,8 @@ "xstream": "*"

"devDependencies": {
"@cycle/rxjs-run": "^10.0.0",
"@cycle/rxjs-run": "^10.2.0",
"@types/mocha": "^5.2.5",
"@types/node": "^10.11.7",
"@types/sinon": "^5.0.5",
"@types/node": "^10.12.11",
"@types/sinon": "^5.0.7",
"deepmerge": "^2.2.1",
"karma": "3.0.0",
"karma": "3.1.3",
"karma-browserstack-launcher": "^1.3.0",

@@ -39,6 +39,6 @@ "karma-chrome-launcher": "^2.2.0",

"rxjs": "6.3.x",
"sinon": "^6.3.5",
"sinon": "^7.1.1",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"typescript": "^3.1.3",
"typescript": "^3.2.1",
"xstream": "11.x"

@@ -45,0 +45,0 @@ },

@@ -86,13 +86,12 @@ import xs, {Stream, MemoryStream} from 'xstream';

if (typeof window !== 'undefined') {
document.addEventListener(CLICK_EVENT, listener, false);
document.addEventListener(CLICK_EVENT, listener as EventListener, false);
}
return () => document.removeEventListener(CLICK_EVENT, listener);
return () =>
document.removeEventListener(CLICK_EVENT, listener as EventListener);
}
export function captureClicks(historyDriver: HistoryDriver): HistoryDriver {
return function historyDriverWithClickCapture(
sink$: Stream<HistoryInput | string>
) {
return function historyDriverWithClickCapture(sink$: Stream<HistoryInput>) {
let cleanup: Function | undefined;
const internalSink$ = xs.create<HistoryInput | string>({
const internalSink$ = xs.create<HistoryInput>({
start: () => {},

@@ -99,0 +98,0 @@ stop: () => typeof cleanup === 'function' && cleanup(),

@@ -5,5 +5,7 @@ import xs, {Stream, MemoryStream, Listener} from 'xstream';

type Narrow<S> = S extends string ? never : S;
export function createHistory$(
history: History,
sink$: Stream<HistoryInput | string>
sink$: Stream<HistoryInput>
): MemoryStream<Location> {

@@ -24,3 +26,3 @@ const history$ = xs.createWithMemory<Location>().startWith(history.location);

function makeCallOnHistory(history: History) {
return function call(input: HistoryInput): void {
return function call(input: Narrow<HistoryInput>): void {
if (input.type === 'push') {

@@ -49,7 +51,7 @@ history.push(input.pathname, input.state);

function createObserver(
call: (input: HistoryInput) => void,
call: (input: Narrow<HistoryInput>) => void,
unlisten: UnregisterCallback
): Listener<HistoryInput | string> {
): Listener<HistoryInput> {
return {
next(input: HistoryInput | string) {
next(input: HistoryInput) {
if (typeof input === 'string') {

@@ -56,0 +58,0 @@ call({type: 'push', pathname: input});

@@ -7,19 +7,6 @@ import {Stream, MemoryStream} from 'xstream';

export type HistoryDriver = Driver<
Stream<HistoryInput | GenericInput | string>,
Stream<HistoryInput>,
MemoryStream<Location>
>;
/**
* A "catch all" case that is necessary because sometimes the sink from the app
* is inferred by TypeScript to be {type: string, pathname: string} and this
* wouldn't match any of the other HistoryInput types below, because the
* property `type` was `string` and not e.g. `'push'`. Seems like a limitation
* in TypeScript for the time being.
*/
export type GenericInput = {
type: string;
pathname?: Pathname;
state?: any;
};
export type PushHistoryInput = {

@@ -55,2 +42,3 @@ type: 'push';

| GoBackHistoryInput
| GoForwardHistoryInput;
| GoForwardHistoryInput
| string;
import * as assert from 'assert';
import {
HistoryInput,
PushHistoryInput,
ReplaceHistoryInput,
Location,

@@ -32,3 +34,3 @@ captureClicks,

return {
history: never(),
history: never() as Observable<string>,
};

@@ -66,3 +68,3 @@ }

return {
history: of({type: 'push', pathname: '/test'}),
history: of<PushHistoryInput>({type: 'push', pathname: '/test'}),
};

@@ -89,3 +91,3 @@ }

return {
history: of({type: 'replace', pathname: '/test'}),
history: of<ReplaceHistoryInput>({type: 'replace', pathname: '/test'}),
};

@@ -92,0 +94,0 @@ }

import * as assert from 'assert';
import {
HistoryInput,
PushHistoryInput,
ReplaceHistoryInput,
Location,

@@ -64,3 +66,3 @@ captureClicks,

return {
history: xs.of({type: 'push', pathname: '/test'}),
history: xs.of<PushHistoryInput>({type: 'push', pathname: '/test'}),
};

@@ -87,3 +89,6 @@ }

return {
history: xs.of({type: 'replace', pathname: '/test'}),
history: xs.of<ReplaceHistoryInput>({
type: 'replace',
pathname: '/test',
}),
};

@@ -90,0 +95,0 @@ }

@@ -5,3 +5,9 @@ import * as assert from 'assert';

import {setup} from '@cycle/rxjs-run';
import {makeServerHistoryDriver, Location, HistoryInput} from '../../src';
import {
makeServerHistoryDriver,
Location,
HistoryInput,
PushHistoryInput,
ReplaceHistoryInput,
} from '../../src';

@@ -13,9 +19,11 @@ describe('serverHistoryDriver - RxJS', function() {

return {
history: never(),
history: never() as Observable<string>,
};
}
const {sources, run} = setup(main, {
const drivers = {
history: makeServerHistoryDriver(),
});
};
const {sources, run} = setup(main, drivers);
assert.strictEqual(typeof sources.history.pipe, 'function');

@@ -51,3 +59,3 @@ });

return {
history: of({type: 'push', pathname: '/test'}),
history: of<PushHistoryInput>({type: 'push', pathname: '/test'}),
};

@@ -76,3 +84,3 @@ }

return {
history: of({type: 'replace', pathname: '/test'}),
history: of<ReplaceHistoryInput>({type: 'replace', pathname: '/test'}),
};

@@ -79,0 +87,0 @@ }

@@ -5,3 +5,9 @@ import * as assert from 'assert';

import {setAdapt} from '@cycle/run/lib/adapt';
import {makeServerHistoryDriver, Location, HistoryInput} from '../../src';
import {
makeServerHistoryDriver,
Location,
HistoryInput,
PushHistoryInput,
ReplaceHistoryInput,
} from '../../src';

@@ -54,3 +60,3 @@ describe('serverHistoryDriver - xstream', function() {

return {
history: xs.of({type: 'push', pathname: '/test'}),
history: xs.of<PushHistoryInput>({type: 'push', pathname: '/test'}),
};

@@ -79,3 +85,6 @@ }

return {
history: xs.of({type: 'replace', pathname: '/test'}),
history: xs.of<ReplaceHistoryInput>({
type: 'replace',
pathname: '/test',
}),
};

@@ -82,0 +91,0 @@ }

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 not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc