Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pickle-ts

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pickle-ts - npm Package Compare versions

Comparing version 0.9.7 to 0.9.8

10

dist/app.d.ts
import { TimeTravel } from './timeTravel';
import { Storage } from './storage';
import { Component } from './component';
import { ClassTransformOptions } from 'class-transformer';
export declare type AppOptions = {
rootComponent?: Component;
isVdomRendered?: boolean;
};
export declare class App {

@@ -23,6 +28,6 @@ private _rootComponent;

*/
constructor(rootComponentConstructor: new () => Component, containerId: string, rootComponent?: Component, isVdomRendered?: boolean);
constructor(rootComponentConstructor: new () => Component, containerId: string, options?: AppOptions);
/** Root component of updates, view and serialization */
readonly rootComponent: Component;
private setRootComponent(rootComponent, deserialize?, doSave?, doTimeSnapshot?);
private setRootComponent;
/** Whether snapshots occur by default after each update */

@@ -38,2 +43,3 @@ timeTravelOn: boolean;

refresh(deserialize?: boolean): void;
serializerOptions: ClassTransformOptions;
}

25

dist/app.js

@@ -15,4 +15,4 @@ "use strict";

*/
function App(rootComponentConstructor, containerId, rootComponent, isVdomRendered) {
if (isVdomRendered === void 0) { isVdomRendered = false; }
function App(rootComponentConstructor, containerId, options) {
if (options === void 0) { options = {}; }
var _this = this;

@@ -24,11 +24,16 @@ this.lock = false;

this.activeUpdates = 0;
this.isVdomRendered = isVdomRendered;
this.serializerOptions = {
enableCircularCheck: true
};
this.isVdomRendered = options.isVdomRendered == true;
this.rootElement = document.getElementById(containerId);
this.time = new timeTravel_1.TimeTravel(function (state) {
return _this.setRootComponent(class_transformer_1.plainToClass(rootComponentConstructor, state, { enableCircularCheck: true }), true, false, false);
return _this.setRootComponent(class_transformer_1.plainToClass(rootComponentConstructor, state, _this.serializerOptions), true, false, false);
});
var newRoot = (rootComponent || new rootComponentConstructor());
// We need to create a root component early (even if we don't use the instance), to run initDecorators,
// initDecorators automatically create @Type decorators. These type decorators must be created before deserialization occurs
var newRoot = (options.rootComponent || new rootComponentConstructor());
newRoot.initDecorators();
this.storage = new storage_1.Storage(containerId, function () { return class_transformer_1.serialize(_this.rootComponent); }, function (serialized) {
_this.setRootComponent(class_transformer_1.deserialize(rootComponentConstructor, serialized), true, false);
this.storage = new storage_1.Storage(containerId, function () { return class_transformer_1.serialize(_this.rootComponent, _this.serializerOptions); }, function (serialized) {
_this.setRootComponent(class_transformer_1.deserialize(rootComponentConstructor, serialized, _this.serializerOptions), true, false);
});

@@ -77,6 +82,8 @@ this.storage.load();

if (doTimeSnapshot || (this.timeTravelOn && doTimeSnapshot !== false)) {
json = class_transformer_1.classToPlain(this.rootComponent);
json = class_transformer_1.classToPlain(this.rootComponent, this.serializerOptions);
this.time.push(json);
}
this.storage.save(doSave, function () { return json != null ? class_transformer_1.serialize(json) : class_transformer_1.serialize(_this.rootComponent); });
this.storage.save(doSave, function () { return json != null ?
class_transformer_1.serialize(json, _this.serializerOptions) :
class_transformer_1.serialize(_this.rootComponent, _this.serializerOptions); });
};

@@ -83,0 +90,0 @@ /** internal use only */

@@ -18,6 +18,6 @@ import { App } from './app';

updated(payload: any): void;
private branchUpdated(payload?);
private preUpdate(payload?);
private postUpdate();
private appRefresh();
private branchUpdated;
private preUpdate;
private postUpdate;
private appRefresh;
/** Call with action that updates the component's state, with optional payload object */

@@ -44,2 +44,4 @@ update(updater: () => void, payload?: any): void;

initDecorators(): void;
/** Returns properties not marked with the `isSystemProperty()` decorator. */
properties(): string[];
}

@@ -153,4 +153,9 @@ "use strict";

};
/** Returns properties not marked with the `isSystemProperty()` decorator. */
Component.prototype.properties = function () {
var _this = this;
return Object.keys(this).filter(function (k) { return !util_1.isSystemProperty(_this, k); });
};
__decorate([
class_transformer_1.Exclude(),
util_1.IsSystemProperty(), class_transformer_1.Exclude(),
__metadata("design:type", app_1.App

@@ -161,7 +166,7 @@ /** The parent component; undefined if the root component - use judiciously - main purpose is internal use by update method */

__decorate([
class_transformer_1.Exclude(),
util_1.IsSystemProperty(), class_transformer_1.Exclude(),
__metadata("design:type", Component)
], Component.prototype, "parent", void 0);
__decorate([
class_transformer_1.Exclude(),
util_1.IsSystemProperty(), class_transformer_1.Exclude(),
__metadata("design:type", Array)

@@ -168,0 +173,0 @@ ], Component.prototype, "refreshQueue", void 0);

@@ -18,4 +18,4 @@ "use strict";

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -22,0 +22,0 @@ case 0: case 1: t = op; break;

@@ -17,4 +17,4 @@ "use strict";

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -21,0 +21,0 @@ case 0: case 1: t = op; break;

@@ -26,3 +26,3 @@ import { Component } from './component';

clearCurrent(recurse?: boolean): void;
private setChildPath(childPath, action?);
private setChildPath;
readonly isActive: boolean;

@@ -44,3 +44,3 @@ /** The current child component of this route */

protected setHistory(action?: Action): void;
private followHistory();
private followHistory;
findChildRoute(name: string): IRouted | undefined;

@@ -47,0 +47,0 @@ }

@@ -26,4 +26,4 @@ "use strict";

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -30,0 +30,0 @@ case 0: case 1: t = op; break;

@@ -22,1 +22,6 @@ import 'reflect-metadata';

export declare function ensureFieldsNums(obj: object): void;
export declare function IsSystemProperty(): {
(target: Function): void;
(target: Object, propertyKey: string | symbol): void;
};
export declare function isSystemProperty(target: any, propertyKey: string): any;

@@ -81,2 +81,10 @@ "use strict";

exports.ensureFieldsNums = ensureFieldsNums;
function IsSystemProperty() {
return Reflect.metadata("isSystemProperty", true);
}
exports.IsSystemProperty = IsSystemProperty;
function isSystemProperty(target, propertyKey) {
return Reflect.getMetadata("isSystemProperty", target, propertyKey);
}
exports.isSystemProperty = isSystemProperty;
//# sourceMappingURL=util.js.map

@@ -26,4 +26,4 @@ "use strict";

while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {

@@ -57,3 +57,3 @@ case 0: case 1: t = op; break;

return __awaiter(this, void 0, void 0, function () {
var _a, _b, _c, _i, _d, c, _e, _f;
var _a, _b, _c, _d, _e, _i, _f, c;
return __generator(this, function (_g) {

@@ -63,16 +63,16 @@ switch (_g.label) {

this.validationErrors = [];
(_e = this.validationErrors).push.apply(_e, class_validator_1.validateSync(this.form));
(_a = this.validationErrors).push.apply(_a, class_validator_1.validateSync(this.form));
if (!this.form.customValidationErrors) return [3 /*break*/, 2];
_b = (_a = (_f = this.validationErrors).push).apply;
_c = [_f];
_d = (_c = (_b = this.validationErrors).push).apply;
_e = [_b];
return [4 /*yield*/, this.form.customValidationErrors()];
case 1:
_b.apply(_a, _c.concat([_g.sent()]));
_d.apply(_c, _e.concat([_g.sent()]));
_g.label = 2;
case 2:
_i = 0, _d = this.validatedChildren();
_i = 0, _f = this.validatedChildren();
_g.label = 3;
case 3:
if (!(_i < _d.length)) return [3 /*break*/, 6];
c = _d[_i];
if (!(_i < _f.length)) return [3 /*break*/, 6];
c = _f[_i];
return [4 /*yield*/, c.validator.validate()];

@@ -79,0 +79,0 @@ case 4:

{
"name": "pickle-ts",
"version": "0.9.7",
"version": "0.9.8",
"author": "pickle",

@@ -12,11 +12,13 @@ "license": "MIT",

"types": "dist/index.d.ts",
"dependencies": {
"class-transformer": "^0.1.8",
"devDependencies": {
"typescript": "^3.0.0",
"@types/history": "^4.7.0"
},
"peerDependencies": {
"reflect-metadata": "^0.1.12",
"class-transformer": "^0.2.0",
"class-validator": "^0.9.1",
"history": "^4.7.2",
"reflect-metadata": "^0.1.12",
"typescript": "^2.7.0",
"typestyle": "^2.0.1",
"@types/history": "^4.7.0"
"typestyle": "^2.0.1"
}
}
import { TimeTravel } from './timeTravel'
import { Storage } from './storage'
import { Component } from './component'
import { patch, VElement } from './dom'
import { serialize, deserialize, plainToClass, classToPlain} from 'class-transformer'
import { patch } from './dom'
import { serialize, deserialize, plainToClass, classToPlain, ClassTransformOptions } from 'class-transformer'
export type AppOptions = {
rootComponent?: Component,
isVdomRendered?: boolean
}
export class App

@@ -31,5 +36,5 @@ {

*/
constructor (rootComponentConstructor : new() => Component, containerId: string, rootComponent?: Component, isVdomRendered = false)
constructor (rootComponentConstructor : new() => Component, containerId: string, options: AppOptions = {})
{
this.isVdomRendered = isVdomRendered
this.isVdomRendered = options.isVdomRendered == true
this.rootElement = document.getElementById (containerId)!

@@ -39,7 +44,9 @@

this.setRootComponent (
<Component><any> plainToClass(rootComponentConstructor, state, {enableCircularCheck:true}), true, false, false
<Component><any> plainToClass(rootComponentConstructor, state, this.serializerOptions), true, false, false
)
)
var newRoot = (rootComponent || new rootComponentConstructor())
// We need to create a root component early (even if we don't use the instance), to run initDecorators,
// initDecorators automatically create @Type decorators. These type decorators must be created before deserialization occurs
var newRoot = (options.rootComponent || new rootComponentConstructor())
newRoot.initDecorators()

@@ -50,5 +57,9 @@

containerId,
() => serialize (this.rootComponent),
() => serialize (this.rootComponent, this.serializerOptions),
serialized => {
this.setRootComponent (<Component> deserialize (rootComponentConstructor, serialized), true, false)
this.setRootComponent (<Component>
deserialize (rootComponentConstructor, serialized, this.serializerOptions),
true,
false
)
}

@@ -97,6 +108,9 @@ )

if (doTimeSnapshot || (this.timeTravelOn && doTimeSnapshot !== false)) {
json = classToPlain (this.rootComponent)
json = classToPlain (this.rootComponent, this.serializerOptions)
this.time.push (json)
}
this.storage.save (doSave, () => json != null ? serialize (json) : serialize (this.rootComponent))
this.storage.save (doSave, () => json != null ?
serialize (json, this.serializerOptions) :
serialize (this.rootComponent, this.serializerOptions)
)
}

@@ -135,2 +149,6 @@

}
serializerOptions: ClassTransformOptions = {
enableCircularCheck: true
}
}
import { App } from './app';
import { div } from './html'
import { VElement } from './dom'
import { parseTyped, KeyValue, ensureFieldsNums } from './util'
import { parseTyped, KeyValue, ensureFieldsNums, IsSystemProperty, isSystemProperty } from './util'
import { Exclude, Type } from 'class-transformer'

@@ -10,8 +10,8 @@

/** The app associated with the component; undefined if not yet attached - use judiciously - main purpose is internal use by update method */
@Exclude() app?: App
@IsSystemProperty() @Exclude() app?: App
/** The parent component; undefined if the root component - use judiciously - main purpose is internal use by update method */
@Exclude() parent?: Component
@IsSystemProperty() @Exclude() parent?: Component
@Exclude() private refreshQueue: Function[] = []
@IsSystemProperty() @Exclude() private refreshQueue: Function[] = []

@@ -103,3 +103,3 @@ /** Called after construction, with a flag indicating if deserialization occured */

for (var aChild of child)
if (aChild != this.parent && aChild instanceof Component)
if (aChild != this.parent && aChild instanceof Component)
childrenFromArrayProperties.push (aChild)

@@ -154,2 +154,7 @@ }

}
/** Returns properties not marked with the `isSystemProperty()` decorator. */
properties() {
return Object.keys (this).filter(k => ! isSystemProperty (this, k))
}
}

@@ -84,2 +84,10 @@ import 'reflect-metadata'

}
}
export function IsSystemProperty() {
return Reflect.metadata("isSystemProperty", true);
}
export function isSystemProperty(target: any, propertyKey: string) {
return Reflect.getMetadata("isSystemProperty", target, propertyKey);
}

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

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