Comparing version 5.0.0-21 to 5.0.0-22
@@ -8,5 +8,8 @@ import { TaskEither } from 'fp-ts/lib/TaskEither'; | ||
}; | ||
export declare const requestConfirmationToUpdateLocation: () => () => void; | ||
export declare const location: import("../Query").CachedQuery<void, void, HistoryLocation>; | ||
export declare const doUpdateLocation: (a: HistoryLocation, ia?: undefined) => TaskEither<void, void>; | ||
export declare const pendingUpdateLocation: import("../Query").CachedQuery<void, void, boolean>; | ||
export declare const doResolvePendingUpdateLocation: (a: boolean, ia?: void | undefined) => TaskEither<void, void>; | ||
export declare function getCurrentView<A>(f: (location: HistoryLocation) => A): import("../Query").ObservableQuery<void, void, A>; | ||
export declare function getDoUpdateCurrentView<A>(f: (currentView: A) => HistoryLocation): (a: A) => TaskEither<void, void>; |
@@ -14,5 +14,14 @@ "use strict"; | ||
var qs_1 = require("qs"); | ||
var trim = require("lodash.trim"); | ||
var IO_1 = require("fp-ts/lib/IO"); | ||
var _setListener = false; | ||
var history = history_1.createBrowserHistory(); | ||
var _historyBlockCallback = null; | ||
exports.requestConfirmationToUpdateLocation = function () { | ||
return history.block(function () { return ''; }); | ||
}; | ||
var history = history_1.createBrowserHistory({ | ||
getUserConfirmation: function (_, callback) { | ||
_historyBlockCallback = callback; | ||
invalidate_1.invalidate({ pendingUpdateLocation: exports.pendingUpdateLocation }); | ||
} | ||
}); | ||
exports.location = Query_1.query(function () { | ||
@@ -22,3 +31,5 @@ if (!_setListener) { | ||
} | ||
var search = qs_1.parse(trim(history.location.search, '?')); | ||
var search = qs_1.parse(history.location.search, { | ||
ignoreQueryPrefix: true | ||
}); | ||
return TaskEither_1.taskEither.of({ | ||
@@ -45,5 +56,8 @@ pathname: history.location.pathname, | ||
: ''; | ||
if (trim(pathname, ' /') !== trim(history.location.pathname, ' /') || | ||
trim(searchQuery, ' ?') !== trim(history.location.search, ' ?')) { | ||
var url = "/" + trim(pathname, ' /') + searchQuery; | ||
var sanitizedPathname = "/" + pathname | ||
.trim() | ||
.replace(/^[\/]+/, ''); | ||
if (sanitizedPathname !== history.location.pathname || | ||
searchQuery !== history.location.search) { | ||
var url = "" + sanitizedPathname + searchQuery; | ||
history.push(url); | ||
@@ -55,2 +69,14 @@ } | ||
}); | ||
exports.pendingUpdateLocation = Query_1.query(function () { | ||
return TaskEither_1.taskEither.of(!!_historyBlockCallback); | ||
})(Strategy_1.refetch(Strategy_1.setoidStrict, CacheValue_1.getSetoid(Strategy_1.setoidStrict, Setoid_1.setoidBoolean))); | ||
exports.doResolvePendingUpdateLocation = command_1.command(function (confirm) { | ||
return TaskEither_1.fromIO(new IO_1.IO(function () { | ||
var callback = _historyBlockCallback; | ||
_historyBlockCallback = null; | ||
if (callback) { | ||
callback(confirm); | ||
} | ||
})); | ||
}, { location: exports.location, pendingUpdateLocation: exports.pendingUpdateLocation }); | ||
function getCurrentView(f) { | ||
@@ -57,0 +83,0 @@ return Query_1.map(exports.location, f); |
import * as React from 'react'; | ||
import { QueryResult } from '../QueryResult'; | ||
import { Omit, ObservableQueries, EnforceNonEmptyRecord, ProductA, ProductL, ProductP } from '../util'; | ||
import { ObservableQueries, EnforceNonEmptyRecord, ProductA, ProductL, ProductP } from '../util'; | ||
import { Monoid } from 'fp-ts/lib/Monoid'; | ||
@@ -12,3 +12,3 @@ declare type QueryInputProps<A> = A extends void ? {} : { | ||
declare type InputProps<Props, A> = Omit<Props, 'queries'> & QueryInputProps<A>; | ||
interface DeclareQueriesReturn<A, L, P> { | ||
export interface DeclareQueriesReturn<A, L, P> { | ||
<Props extends QueryOutputProps<L, P>>(component: React.ComponentType<Props>): React.ComponentType<InputProps<Props, A>>; | ||
@@ -15,0 +15,0 @@ InputProps: QueryInputProps<A>; |
@@ -39,3 +39,3 @@ "use strict"; | ||
var React = require("react"); | ||
var useQuery_1 = require("./useQuery"); | ||
var QueryResult_1 = require("../QueryResult"); | ||
var Observable_1 = require("../Observable"); | ||
@@ -45,4 +45,14 @@ var observe_1 = require("../observe"); | ||
var Option_1 = require("fp-ts/lib/Option"); | ||
function defaultMonoidResult() { | ||
return { | ||
empty: QueryResult_1.loading, | ||
concat: function (a, b) { | ||
return a.type === 'Success' && b.type === 'Loading' | ||
? QueryResult_1.success(a.value, true) | ||
: b; | ||
} | ||
}; | ||
} | ||
function declareQueries(queries, resultMonoid) { | ||
var _resultMonoid = resultMonoid || useQuery_1.defaultMonoidResult(); | ||
var _resultMonoid = resultMonoid || defaultMonoidResult(); | ||
return (function (Component) { | ||
@@ -49,0 +59,0 @@ return (function (_super) { |
@@ -1,3 +0,1 @@ | ||
export * from './useQuery'; | ||
export * from './WithQuery'; | ||
export * from './declareQueries'; |
@@ -6,4 +6,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./useQuery")); | ||
__export(require("./WithQuery")); | ||
__export(require("./declareQueries")); |
import { ObservableQuery } from './Query'; | ||
export declare type EnforceNonEmptyRecord<R> = keyof R extends never ? never : R; | ||
export declare type Omit<O, K> = Pick<O, Exclude<keyof O, K>>; | ||
declare type MatchingPropNames<T, X> = { | ||
@@ -5,0 +4,0 @@ [K in keyof T]: T[K] extends X ? K : never; |
{ | ||
"name": "avenger", | ||
"version": "5.0.0-21", | ||
"description": "A CQRS-flavoured data fetching and caching layer in JavaScript. Batching, caching, data-dependecies and manual invalidations in a declarative fashion for node and the browser", | ||
"version": "5.0.0-22", | ||
"description": "A CQRS-flavoured data fetching and caching layer in TypeScript. Batching, caching, data-dependecies and manual invalidations in a declarative fashion for browser UIs", | ||
"scripts": { | ||
@@ -18,5 +18,4 @@ "test": "jest", | ||
"dependencies": { | ||
"fp-ts": "^1.18.2", | ||
"fp-ts": "^1.19.4", | ||
"history": "^4.9.0", | ||
"lodash.trim": "^4.5.1", | ||
"qs": "^6.7.0", | ||
@@ -28,3 +27,2 @@ "rxjs": "^6.5.2" | ||
"@types/jest": "^24.0.13", | ||
"@types/lodash.trim": "^4.5.6", | ||
"@types/qs": "^6.5.3", | ||
@@ -31,0 +29,0 @@ "@types/react": "^16.8.19", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
71329
4
15
1
500
39
1189
- Removedlodash.trim@^4.5.1
- Removedlodash.trim@4.5.1(transitive)
Updatedfp-ts@^1.19.4