New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

htmlrapier

Package Overview
Dependencies
Maintainers
1
Versions
246
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

htmlrapier - npm Package Compare versions

Comparing version
27.0.1
to
28.0.0
+1
-1
package.json
{
"name": "htmlrapier",
"version": "27.0.1",
"version": "28.0.0",
"private": false,

@@ -5,0 +5,0 @@ "dependencies": {

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

*/
public getView<T>(name: string, createElement?: view.CreateElementFunc<T>): view.IView<T> {
public getView<T>(name: string): view.IView<T> {
var query = '[data-hr-view=' + name + ']';

@@ -214,3 +214,3 @@ var targetElement = this.findElement(query);

return view.build<T>(targetElement, createElement);
return view.build<T>(targetElement);
}

@@ -262,4 +262,2 @@

}
};
view.setBindingCollectionShimConstructor(BindingCollection);
};

@@ -13,9 +13,5 @@ "use strict";

export { IView } from './view';
import * as components from './components';
import { noData } from './textstream';
// This block will import a polyfill to use if the code is compiled as es5
// This will enable the web components to call our constructors.
import * as es5component from './es5component';
es5component.setupPolyfill();
// End polyfill block
/**

@@ -114,7 +110,18 @@ * This class provides a way to get a handle to the data provided by the

const foundElement = (element) => {
const foundElement = (element: HTMLElement) => {
if (!ignoredNodes.isIgnored(element)) {
const controllerComponent = element.getAttribute('data-hr-controller-component');
let bindings: BindingCollection;
if(controllerComponent) {
//Replace element with the component that is created.
var parent = element.parentNode;
bindings = components.one(controllerComponent, noData, parent, element);
parent.removeChild(element);
}
else {
bindings = new BindingCollection(element);
}
const services = new di.ServiceCollection();
const scope = this.baseScope.createChildScope(services);
const bindings = new BindingCollection(element);
services.addTransient(BindingCollection, s => bindings);

@@ -138,46 +145,2 @@ element.removeAttribute('data-hr-controller');

/**
* Create a new controller instance on the named nodes in the document.This will replace the elements it finds with the element provided
* by the callback function.
* @param name The name of the data-hr-controller nodes to lookup.
* @param controllerConstructor The controller to create when a node is found.
* @param parentBindings The parent bindings to restrict the controller search.
*/
public createElement<T, TId>(name: string, controllerConstructor: di.DiFunction<T>, elementCreator: () => Element, parentBindings?: BindingCollection): T[] {
return this.createElementId(undefined, name, controllerConstructor, elementCreator, parentBindings);
}
/**
* Create a new controller instance on the named nodes in the document using an id based service. This will replace the elements it finds with the element provided
* by the callback function.
* @param name The name of the data-hr-controller nodes to lookup.
* @param controllerConstructor The controller to create when a node is found.
* @param parentBindings The parent bindings to restrict the controller search.
*/
public createElementId<T, TId>(id: TId, name: string, controllerConstructor: di.DiFunction<T>, elementCreator: () => Element, parentBindings?: BindingCollection): T[] {
const createdControllers: T[] = [];
const foundElement = (element) => {
if (!ignoredNodes.isIgnored(element)) {
const replacementElement = elementCreator();
const services = new di.ServiceCollection();
const scope = this.baseScope.createChildScope(services);
const bindings = new BindingCollection(replacementElement);
services.addTransient(BindingCollection, s => bindings);
element.replaceWith(replacementElement);//.removeAttribute('data-hr-controller');
const controller = this.createController(id, controllerConstructor, services, scope, bindings);
createdControllers.push(controller);
}
}
if (parentBindings) {
parentBindings.iterateControllers(name, foundElement);
}
else {
domQuery.iterate('[data-hr-controller="' + name + '"]', null, foundElement);
}
return createdControllers;
}
/**
* This will create a single instance of the service that resolves to constructorFunc

@@ -248,59 +211,2 @@ * without looking for html elements, it will not have a binding collection.

/**
* Register a controller to be created when the custom elements are found. Note that your class is not a HTMLElement like a normal
* web component class. Instead a web component is created that forwards the events to your class. Your class's constructor is called
* after the component is fully formed with the dependencies injected from DI. This happens during the web component connectedCallback.
* Before then nothing is created. This also alters the expected lifecycle. Normally you would expect
* constructed -> attributeChangedCallback -> connectedCallback for a new component, but now it will be constructor -> connectedCallback. The
* component is not fully formed enough on the first attributeChangedCallback to respond usefully.
* @param elementName
* @param controllerConstructor
* @param options
*/
public registerWebComponent<T>(elementName: string, controllerConstructor: di.DiFunction<T>, options?: any): void {
this.registerWebComponentId(undefined, elementName, controllerConstructor, options);
}
public registerWebComponentId<T, TId>(id: TId, elementName: string, controllerConstructor: di.DiFunction<T>, options?: ElementDefinitionOptions): void {
//Stuff we need to pass into the class defined below.
var self = this;
class ControllerElement extends HTMLElement {
private controller: any;
connectedCallback() {
if (!this.controller) {
const services = new di.ServiceCollection();
const scope = self.baseScope.createChildScope(services);
const bindings = new BindingCollection(this);
services.addTransient(BindingCollection, s => bindings);
this.removeAttribute('data-hr-controller');
this.controller = self.createController(id, controllerConstructor, services, scope, bindings);
}
if (this.controller.connectedCallback) {
this.controller.connectedCallback();
}
}
disconnectedCallback() {
if (this.controller.disconnectedCallback) {
this.controller.disconnectedCallback();
}
}
adoptedCallback() {
if (this.controller.adoptedCallback) {
this.controller.adoptedCallback();
}
}
attributeChangedCallback() {
if (this.controller.attributeChangedCallback) {
this.controller.attributeChangedCallback();
}
}
}
window.customElements.define(elementName, ControllerElement, options)
}
private createController(id: any, controllerConstructor: di.DiFunction<any>, services: di.ServiceCollection, scope: di.Scope, bindings: BindingCollection) {

@@ -307,0 +213,0 @@ services.addTransient(InjectedControllerBuilder, s => new InjectedControllerBuilder(scope));

@@ -18,7 +18,2 @@ export interface ErrorMap {[key: string]: string};

/**
* Get the raw error object.
*/
getValidationErrors() : ErrorMap;
/**
* Determine if there are any validation errors.

@@ -31,3 +26,2 @@ */

return (<ValidationError>test).getValidationError !== undefined
&& (<ValidationError>test).getValidationErrors !== undefined
&& (<ValidationError>test).hasValidationError !== undefined

@@ -34,0 +28,0 @@ && (<ValidationError>test).hasValidationErrors !== undefined;

@@ -17,3 +17,7 @@ "use strict";

/**
* This event dispatcher does not handle event listeners returning values.
* Track listeners and fire events. If an event handler throws an error the error
* will be printed to the console, but all other listeners will still fire and the caller
* will not know about the error. This is intended to make consuming events this handler
* fires work like an event coming off an html element where the exception will be logged,
* but the page itself does not break.
*/

@@ -44,46 +48,10 @@ export class ActionEventDispatcher<T>{

for (var i = 0; i < this.listeners.length; ++i) {
this.listeners[i](arg);
}
}
}
/**
* This is class is for events that return a value.
*/
export class FuncEventDispatcher<TRet, TArg>{
protected listeners: FuncEventListener<TRet, TArg>[] = <any>[];
add(listener: FuncEventListener<TRet, TArg>) {
if(!typeId.isFunction(listener)){
throw new Error("Listener must be a function, instead got " + typeof(listener));
}
this.listeners.push(listener);
}
remove(listener: FuncEventListener<TRet, TArg>) {
for (var i = 0; i < this.listeners.length; ++i) {
if (this.listeners[i] === listener) {
this.listeners.splice(i--, 1);
try {
this.listeners[i](arg);
}
}
}
get modifier(): EventModifier<FuncEventListener<TRet, TArg>>{
return this;
}
fire(arg:TArg){
var result : TRet[] = undefined;
var nextResult : TRet;
for (var i = 0; i < this.listeners.length; ++i) {
var listener = this.listeners[i];
nextResult = listener(arg);
if (nextResult !== undefined) {
if (result === undefined) {
result = [];
}
result.push(nextResult);
catch (e) {
console.error("An error occured firing an ActionEventDispatcher.");
console.error(e);
}
}
return result;
}

@@ -94,3 +62,6 @@ }

* This event dispatcher will return a promise that will resolve when all events
* are finished running. Allows async work to stay in the event flow.
* are finished running. Allows async work to stay in the event flow. This will handle
* errors in the same way as the ActionEventDispatcher where they are printed, but not
* bubbled up to the caller. Any results that do go through will be returned even if others
* return errors.
*/

@@ -119,8 +90,3 @@ export class PromiseEventDispatcher<TRet, TArg>{

/**
* Fire the event. The listeners can return values, if they do the values will be added
* to an array that is returned by the promise returned by this function.
* @returns {Promise} a promise that will resolve when all fired events resolve.
*/
fire(arg:TArg): Promise<TRet[]> {
async fire(arg:TArg): Promise<TRet[]> {
var result: TRet[];

@@ -143,7 +109,14 @@ var promises:Promise<void>[] = [];

return Promise.all(promises)
.then(function (data) {
return result;
});
for (var i = 0; i < promises.length; ++i) {
try {
await promises[i];
}
catch (e) {
console.error("An error occured firing a PromiseEventDispatcher.");
console.error(e);
}
}
return result;
}
}

@@ -335,9 +335,2 @@ import * as domQuery from './domquery';

/**
* Get all validation errors.
*/
getValidationErrors() {
return {};
}
/**
* Determine if there are any validation errors.

@@ -344,0 +337,0 @@ */

@@ -11,2 +11,3 @@ "use strict";

export interface ITextStreamData {
getDataObject(): any;
getRawData(address: exprTree.IDataAddress): any;

@@ -21,2 +22,6 @@ getFormatted(data: any, address: exprTree.IDataAddress): any;

getDataObject(): any {
this.data.getDataObject();
}
getRawData(address: exprTree.IDataAddress) {

@@ -239,2 +244,3 @@ if (address.isInScope(this.scopeName) || this.parent === null) {

var itemScope = new NodeScope(data, this.scopeName, {
getDataObject: () => item,
getRawData: a => a.readScoped(item),

@@ -285,2 +291,6 @@ getFormatted: (d, a) => d //Doesn't really do anything, won't get called

class NoDataStream implements ITextStreamData {
getDataObject() {
return undefined;
}
public getFormatted(val, address) {

@@ -295,3 +305,3 @@ return val;

const noData: ITextStreamData = new NoDataStream();
export const noData: ITextStreamData = new NoDataStream();

@@ -298,0 +308,0 @@ function format(data: ITextStreamData, streamNodes: IStreamNode[]) {

@@ -228,63 +228,2 @@ import { TextStream, ITextStreamData } from './textstream';

export type CreateElementFunc<TData> = (data: TData) => Element;
// Binding collection uses view, so this overcomes the circular import.
interface BindingCollectionShimConstructor {
new (element: Element): BindingCollectionShim;
}
interface BindingCollectionShim {}
let BindingCollection: BindingCollectionShimConstructor;
export function setBindingCollectionShimConstructor(bindingCollectionMaker: BindingCollectionShimConstructor){
BindingCollection = bindingCollectionMaker;
}
class ElementView<T> implements IView<T> {
constructor(private element: HTMLElement, private createElement: CreateElementFunc<T>){
}
public setData(data: T, createdCallback?: components.CreatedCallback<T>): void {
components.empty(this.element);
this.insertData(data, null, createdCallback);
}
public appendData(data: T, createdCallback?: components.CreatedCallback<T>): void {
this.insertData(data, null, createdCallback);
}
public insertData(data: T | T[] | iter.IterableInterface<T>, insertBeforeSibling: Node, createdCallback?: components.CreatedCallback<T>): void{
this.bindData(data, insertBeforeSibling, createdCallback);
}
public clear(): void {
components.empty(this.element);
}
public setFormatter(formatter: IViewDataFormatter<T>): void {
}
private bindData(data: T | T[] | iter.IterableInterface<T>, insertBeforeSibling: Node, createdCallback: components.CreatedCallback<T>): void {
if (Array.isArray(data) || typeId.isForEachable(data)) {
data.forEach(i => {
this.createItemElement(i, insertBeforeSibling, createdCallback);
});
}
else if (data !== undefined && data !== null) {
this.createItemElement(data, insertBeforeSibling, createdCallback);
}
}
private createItemElement(item: T, insertBeforeSibling: Node, createdCallback: components.CreatedCallback<T>){
const element = this.createElement(item);
this.element.insertBefore(element, insertBeforeSibling);
const bindingCollection = new BindingCollection(element);
if (createdCallback) {
createdCallback(bindingCollection, item);
}
}
}
function IsHTMLElement(element: Node): element is HTMLElement{

@@ -295,8 +234,4 @@ //Just check a couple functions, no need to go overboard, only comparing to node anyway

export function build<T>(element: Node, createElement?: CreateElementFunc<T>) : IView<T> {
export function build<T>(element: Node) : IView<T> {
if(IsHTMLElement(element)){
if(createElement) {
return new ElementView(element, createElement);
}
var component: string;

@@ -303,0 +238,0 @@ if(element.hasAttribute('data-hr-view-component')){

@@ -54,2 +54,6 @@ import * as schema from './schema';

getDataObject() {
return this.original;
}
getRawData(address: exprTree.IDataAddress) {

@@ -56,0 +60,0 @@ return address.read(this.original);

/**
* @license
* Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
declare var Reflect;
/**
* This shim allows elements written in, or compiled to, ES5 to work on native
* implementations of Custom Elements v1. It sets new.target to the value of
* this.constructor so that the native HTMLElement constructor can access the
* current under-construction element's definition.
*/
export function setupPolyfill() {
if (
// No Reflect, no classes, no need for shim because native custom elements
// require ES2015 classes or Reflect.
(<any>window).Reflect === undefined ||
window.customElements === undefined ||
// The webcomponentsjs custom elements polyfill doesn't require
// ES2015-compatible construction (`super()` or `Reflect.construct`).
(<any>window.customElements).polyfillWrapFlushCallback
) {
return;
}
const BuiltInHTMLElement = HTMLElement;
/**
* With jscompiler's RECOMMENDED_FLAGS the function name will be optimized away.
* However, if we declare the function as a property on an object literal, and
* use quotes for the property name, then closure will leave that much intact,
* which is enough for the JS VM to correctly set Function.prototype.name.
*/
const wrapperForTheName = {
'HTMLElement': /** @this {!Object} */ function HTMLElement() {
return Reflect.construct(
BuiltInHTMLElement, [], /** @type {!Function} */(this.constructor));
}
};
(<any>window).HTMLElement = wrapperForTheName['HTMLElement'];
HTMLElement.prototype = BuiltInHTMLElement.prototype;
HTMLElement.prototype.constructor = HTMLElement;
(<any>Object).setPrototypeOf(HTMLElement, BuiltInHTMLElement);
};