Socket
Socket
Sign inDemoInstall

jwidget

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jwidget - npm Package Compare versions

Comparing version 2.0.6 to 2.0.7

CancelToken.d.ts

27

AbstractRestProvider.d.ts

@@ -21,3 +21,3 @@ /// <reference types="jquery" />

*/
import DestroyablePromise from "./DestroyablePromise";
import CancelToken from "./CancelToken";
import Dictionary from "./Dictionary";

@@ -33,9 +33,9 @@ declare abstract class AbstractRestProvider<C> {

getUrl(action: string | string[], type?: string): string;
get<T>(action: string | string[], data?: any, factory?: (response: any) => T, context?: C): DestroyablePromise<T>;
post(action: string | string[], data?: any, context?: C): DestroyablePromise<{}>;
put(action: string | string[], data?: any, context?: C): DestroyablePromise<{}>;
patch(action: string | string[], data?: any, context?: C): DestroyablePromise<{}>;
del(action: string | string[], data?: any, context?: C): DestroyablePromise<{}>;
upload(action: string | string[], data: File, context?: C): DestroyablePromise<{}>;
private send<T>(type, action, data, context, factory?, settings?);
get<T>(action: string | string[], config?: AbstractRestProvider.DataConfig<C, T>): Promise<T>;
post<T>(action: string | string[], config?: AbstractRestProvider.DataConfig<C, T>): Promise<T>;
put<T>(action: string | string[], config?: AbstractRestProvider.DataConfig<C, T>): Promise<T>;
patch<T>(action: string | string[], config?: AbstractRestProvider.DataConfig<C, T>): Promise<T>;
del<T>(action: string | string[], config?: AbstractRestProvider.DataConfig<C, T>): Promise<T>;
upload<T>(action: string | string[], config?: AbstractRestProvider.UploadConfig<C, T>): Promise<T>;
private send<T>(type, action, config?, settings?);
}

@@ -50,2 +50,13 @@ export default AbstractRestProvider;

}
interface BaseConfig<C, T> {
readonly cancelToken?: CancelToken;
readonly context?: C;
readonly factory?: (response: any) => T;
}
interface DataConfig<C, T> extends BaseConfig<C, T> {
readonly data?: any;
}
interface UploadConfig<C, T> extends BaseConfig<C, T> {
readonly data?: File;
}
}

@@ -23,3 +23,3 @@ "use strict";

var index_1 = require("./index");
var HttpRequest_1 = require("./HttpRequest");
var request_1 = require("./request");
var AbstractRestProvider = /** @class */ (function () {

@@ -45,19 +45,19 @@ function AbstractRestProvider(config) {

};
AbstractRestProvider.prototype.get = function (action, data, factory, context) {
return this.send("GET", action, data, context, factory);
AbstractRestProvider.prototype.get = function (action, config) {
return this.send("GET", action, config);
};
AbstractRestProvider.prototype.post = function (action, data, context) {
return this.send("POST", action, data, context);
AbstractRestProvider.prototype.post = function (action, config) {
return this.send("POST", action, config);
};
AbstractRestProvider.prototype.put = function (action, data, context) {
return this.send("PUT", action, data, context);
AbstractRestProvider.prototype.put = function (action, config) {
return this.send("PUT", action, config);
};
AbstractRestProvider.prototype.patch = function (action, data, context) {
return this.send("PATCH", action, data, context);
AbstractRestProvider.prototype.patch = function (action, config) {
return this.send("PATCH", action, config);
};
AbstractRestProvider.prototype.del = function (action, data, context) {
return this.send("DELETE", action, data, context);
AbstractRestProvider.prototype.del = function (action, config) {
return this.send("DELETE", action, config);
};
AbstractRestProvider.prototype.upload = function (action, data, context) {
return this.send("POST", action, data, context, null, {
AbstractRestProvider.prototype.upload = function (action, config) {
return this.send("POST", action, config, {
processData: false,

@@ -67,17 +67,19 @@ contentType: false

};
AbstractRestProvider.prototype.send = function (type, action, data, context, factory, settings) {
AbstractRestProvider.prototype.send = function (type, action, config, settings) {
if (config === void 0) { config = {}; }
var url = this.getUrl(action, type);
if (url === null) {
return new HttpRequest_1.default();
return request_1.default();
}
var contentType = (settings && settings.contentType != null) ?
settings.contentType : this.getContentType(context);
var data = config.data, contentType = (settings && settings.contentType != null) ?
settings.contentType : this.getContentType(config.context);
settings = $.extend({}, this.settings, settings, {
url: url,
type: type,
headers: this.getHeaders(context),
headers: this.getHeaders(config.context),
contentType: contentType,
data: (contentType === "application/json" && data != null) ? JSON.stringify(data) : data
data: (type !== "GET" && type !== "DELETE" && contentType === "application/json" && data != null) ?
JSON.stringify(data) : data
});
return new HttpRequest_1.default($.ajax(settings), factory);
return request_1.default($.ajax(settings), config.factory, config.cancelToken);
};

@@ -84,0 +86,0 @@ return AbstractRestProvider;

@@ -50,3 +50,3 @@ /*!

*/
listen(handler: (params: P) => void, scope?: any): Destroyable;
listen(handler: (params: P) => any, scope?: any): Destroyable;
/**

@@ -53,0 +53,0 @@ * Triggers event, i.e. calls all bound handlers.

@@ -28,7 +28,7 @@ /*!

private _event;
readonly handler: (params: P) => void;
readonly handler: (params: P) => any;
readonly scope: any;
readonly iid: number;
constructor(_event: Event<P>, handler: (params: P) => void, scope: any);
constructor(_event: Event<P>, handler: (params: P) => any, scope: any);
destroy(): void;
}

@@ -40,4 +40,4 @@ /*!

*/
listen(handler: (params: P) => void, scope?: any): Destroyable;
listen(handler: (params: P) => any, scope?: any): Destroyable;
}
export default Listenable;
{
"name": "jwidget",
"version": "2.0.6",
"version": "2.0.7",
"description": "Object-oriented FrontEnd MV framework",

@@ -5,0 +5,0 @@ "homepage": "http://enepomnyaschih.github.io/jwidget",

@@ -32,11 +32,12 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var index_1 = require("./index");
var ArrayUtils = require("./ArrayUtils");
var CancelToken_1 = require("./CancelToken");
var Class_1 = require("./Class");
var Component_1 = require("./Component");
var Copier_1 = require("./Copier");
var defer_1 = require("./defer");
var DictionaryUtils = require("./DictionaryUtils");
var hash_1 = require("./hash");
var index_1 = require("./index");
var Property_1 = require("./Property");
var Timeout_1 = require("./Timeout");
var ArrayUtils = require("./ArrayUtils");
var DictionaryUtils = require("./DictionaryUtils");
/**

@@ -259,5 +260,5 @@ * This router can handle complicated router hierarchies (something more than a single stack of routers) in exchange

_this.replaceState = replaceState;
_this.own(new Timeout_1.default().then(function () {
defer_1.default(0, _this.own(new CancelToken_1.default())).then(function () {
redirect(_this.path, _this.router, index_1.defn(_this.replaceState, true));
}));
});
return _this;

@@ -354,3 +355,5 @@ }

expanded.set(true);
_this.own(expanded.changeEvent.listen(function () { _this.router.redirect(""); }));
_this.own(expanded.changeEvent.listen(function () {
_this.router.redirect("");
}));
return _this;

@@ -357,0 +360,0 @@ }

@@ -21,8 +21,9 @@ /*!

import DestroyablePromise from "./DestroyablePromise";
import CancelToken from "./CancelToken";
import Dictionary from "./Dictionary";
import {isNil} from "./index";
import HttpRequest from "./HttpRequest";
import request from "./request";
abstract class AbstractRestProvider<C> {
private mock: Dictionary<string>;

@@ -57,24 +58,24 @@ private url: string;

get<T>(action: string | string[], data?: any, factory?: (response: any) => T, context?: C) {
return this.send("GET", action, data, context, factory);
get<T>(action: string | string[], config?: AbstractRestProvider.DataConfig<C, T>) {
return this.send("GET", action, config);
}
post(action: string | string[], data?: any, context?: C) {
return this.send("POST", action, data, context);
post<T>(action: string | string[], config?: AbstractRestProvider.DataConfig<C, T>) {
return this.send("POST", action, config);
}
put(action: string | string[], data?: any, context?: C) {
return this.send("PUT", action, data, context);
put<T>(action: string | string[], config?: AbstractRestProvider.DataConfig<C, T>) {
return this.send("PUT", action, config);
}
patch(action: string | string[], data?: any, context?: C) {
return this.send("PATCH", action, data, context);
patch<T>(action: string | string[], config?: AbstractRestProvider.DataConfig<C, T>) {
return this.send("PATCH", action, config);
}
del(action: string | string[], data?: any, context?: C) {
return this.send("DELETE", action, data, context);
del<T>(action: string | string[], config?: AbstractRestProvider.DataConfig<C, T>) {
return this.send("DELETE", action, config);
}
upload(action: string | string[], data: File, context?: C) {
return this.send("POST", action, data, context, null, {
upload<T>(action: string | string[], config?: AbstractRestProvider.UploadConfig<C, T>) {
return this.send("POST", action, config, {
processData: false,

@@ -85,18 +86,19 @@ contentType: false

private send<T>(type: string, action: string | string[], data: any, context: C,
factory?: (response: any) => T, settings?: JQueryAjaxSettings): DestroyablePromise<T> {
private send<T>(type: string, action: string | string[], config: AbstractRestProvider.DataConfig<C, T> = {}, settings?: JQueryAjaxSettings): Promise<T> {
const url = this.getUrl(action, type);
if (url === null) {
return new HttpRequest<T>();
return request<T>();
}
const contentType = (settings && settings.contentType != null) ?
settings.contentType : this.getContentType(context);
const data = config.data,
contentType = (settings && settings.contentType != null) ?
settings.contentType : this.getContentType(config.context);
settings = $.extend({}, this.settings, settings, {
url: url,
type: type,
headers: this.getHeaders(context),
headers: this.getHeaders(config.context),
contentType: contentType,
data: (contentType === "application/json" && data != null) ? JSON.stringify(data) : data
data: (type !== "GET" && type !== "DELETE" && contentType === "application/json" && data != null) ?
JSON.stringify(data) : data
});
return new HttpRequest<T>($.ajax(settings), factory);
return request<T>($.ajax(settings), config.factory, config.cancelToken);
}

@@ -114,2 +116,16 @@ }

}
export interface BaseConfig<C, T> {
readonly cancelToken?: CancelToken;
readonly context?: C;
readonly factory?: (response: any) => T;
}
export interface DataConfig<C, T> extends BaseConfig<C, T> {
readonly data?: any;
}
export interface UploadConfig<C, T> extends BaseConfig<C, T> {
readonly data?: File;
}
}

@@ -32,3 +32,3 @@ /*!

listen(_handler: (params: any) => void, _scope?: any): Destroyable {
listen(_handler: (params: any) => any, _scope?: any): Destroyable {
return dummyDestroyable;

@@ -35,0 +35,0 @@ }

@@ -61,3 +61,3 @@ /*!

*/
listen(handler: (params: P) => void, scope?: any): Destroyable {
listen(handler: (params: P) => any, scope?: any): Destroyable {
if (this._attachments === null) {

@@ -64,0 +64,0 @@ this._attachments = {};

@@ -21,6 +21,6 @@ /*!

import {newIid} from './index';
import Destroyable from './Destroyable';
import Event from './Event';
import Identifiable from './Identifiable';
import {newIid} from './index';

@@ -33,3 +33,3 @@ /**

constructor(private _event: Event<P>, readonly handler: (params: P) => void, readonly scope: any) {
constructor(private _event: Event<P>, readonly handler: (params: P) => any, readonly scope: any) {
}

@@ -36,0 +36,0 @@

@@ -43,5 +43,5 @@ /*!

*/
listen(handler: (params: P) => void, scope?: any): Destroyable;
listen(handler: (params: P) => any, scope?: any): Destroyable;
}
export default Listenable;

@@ -21,15 +21,16 @@ /*!

import {defn, identity, isNotNil} from './index';
import * as ArrayUtils from './ArrayUtils';
import Bindable from './Bindable';
import CancelToken from "./CancelToken";
import Class from './Class';
import Component from './Component';
import Copier from './Copier';
import defer from "./defer";
import Destroyable from './Destroyable';
import Dictionary from './Dictionary';
import * as DictionaryUtils from './DictionaryUtils';
import hash from './hash';
import {defn, identity, isNotNil} from './index';
import IProperty from './IProperty';
import Property from './Property';
import Timeout from './Timeout';
import * as ArrayUtils from './ArrayUtils';
import * as DictionaryUtils from './DictionaryUtils';

@@ -180,3 +181,3 @@ /**

}
return function(path: string) {
return function (path: string) {
const result = separator.exec(path || "");

@@ -214,3 +215,3 @@ return result ? [result[1], defn(ArrayUtils.find(result.slice(2), isNotNil), null)] : null;

var trimmer = new RegExp("^(?:" + joiner.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&') + ")*");
return function(route, arg) {
return function (route, arg) {
return !arg ? route : (arg.charAt(0) === "?") ? (route + arg) : (route + joiner + arg.replace(trimmer, ""));

@@ -251,3 +252,3 @@ };

const routes = handler.routes || {};
return function(this: any, route: string, arg: Bindable<string>): T {
return function (this: any, route: string, arg: Bindable<string>): T {
return routes[route] ? routes[route].call(this, arg) :

@@ -278,3 +279,3 @@ handler.notFound ? handler.notFound.call(this, route, arg) : null;

component.bindRouting ? component.bindRouting(path) :
component.path ? new Copier(path, component.path) : null;
component.path ? new Copier(path, component.path) : null;
}

@@ -285,5 +286,5 @@

super();
this.own(new Timeout().then(() => {
defer(0, this.own(new CancelToken())).then(() => {
redirect(this.path, this.router, defn(this.replaceState, true));
}));
});
}

@@ -321,3 +322,3 @@ }

constructor(config: Node.Config) {
constructor(config: Node.Config) {
super();

@@ -327,3 +328,3 @@ this.defaultRoute = config.defaultRoute;

const routeMap = ArrayUtils.index(config.routes, identity);
this._paths = DictionaryUtils.map(routeMap, () => new Property<string>());
this._paths = DictionaryUtils.map(routeMap, () => new Property<string>());
this._expanded = DictionaryUtils.map(routeMap, () => new Property(config.expanded === true));

@@ -387,9 +388,11 @@

constructor(private router: Router<any>, sourcePath: Bindable<string>,
targetPath: IProperty<string>, expanded: IProperty<boolean>) {
targetPath: IProperty<string>, expanded: IProperty<boolean>) {
super();
this.own(new Copier(sourcePath, targetPath));
expanded.set(true);
this.own(expanded.changeEvent.listen(() => {this.router.redirect("")}));
this.own(expanded.changeEvent.listen(() => {
this.router.redirect("")
}));
}
}
}

@@ -21,3 +21,3 @@ /*!

import AbstractDestroyablePromise from "../AbstractDestroyablePromise";
import AbstractDestroyablePromise from "../experimental/AbstractDestroyablePromise";

@@ -24,0 +24,0 @@ class Timeout extends AbstractDestroyablePromise<number> {

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc