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

ng1-shift

Package Overview
Dependencies
Maintainers
7
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng1-shift - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

dist/helpers/is-class.d.ts

253

dist/index.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['ng1-shift'] = {}));
}(this, (function (exports) { 'use strict';
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["ng1-shift"] = {}));
})(this, (function (exports) { 'use strict';
var Metakeys = {
const Metakeys = {
type: "ng1-shift:type",

@@ -12,47 +12,38 @@ componentOptions: "ng1-shift:componentOptions"

var ComponentMetadataService = /** @class */ (function () {
function ComponentMetadataService(target) {
class ComponentMetadataService {
constructor(target) {
this.target = target;
}
ComponentMetadataService.prototype.addInput = function (componentProp, inputName) {
var options = this.metadata;
options.inputs.push({ componentProp: componentProp, inputName: inputName });
addInput(componentProp, inputName) {
const options = this.metadata;
options.inputs.push({ componentProp, inputName });
this.metadata = options;
};
ComponentMetadataService.prototype.addOutput = function (componentProp, outputName) {
var options = this.metadata;
options.outputs.push({ componentProp: componentProp, outputName: outputName });
}
addOutput(componentProp, outputName) {
const options = this.metadata;
options.outputs.push({ componentProp, outputName });
this.metadata = options;
};
ComponentMetadataService.prototype.getInputs = function () {
}
getInputs() {
return this.metadata.inputs;
};
ComponentMetadataService.prototype.getOutputs = function () {
}
getOutputs() {
return this.metadata.outputs;
};
Object.defineProperty(ComponentMetadataService.prototype, "hasMetadata", {
get: function () {
return Reflect.hasMetadata(Metakeys.componentOptions, this.target);
},
enumerable: false,
configurable: true
});
Object.defineProperty(ComponentMetadataService.prototype, "metadata", {
get: function () {
if (this.hasMetadata) {
return Reflect.getMetadata(Metakeys.componentOptions, this.target);
}
return {
inputs: [],
outputs: []
};
},
set: function (value) {
Reflect.defineMetadata(Metakeys.componentOptions, value, this.target);
},
enumerable: false,
configurable: true
});
return ComponentMetadataService;
}());
}
get hasMetadata() {
return Reflect.hasMetadata(Metakeys.componentOptions, this.target);
}
get metadata() {
if (this.hasMetadata) {
return Reflect.getMetadata(Metakeys.componentOptions, this.target);
}
return {
inputs: [],
outputs: []
};
}
set metadata(value) {
Reflect.defineMetadata(Metakeys.componentOptions, value, this.target);
}
}

@@ -62,3 +53,3 @@ function findFirst(array, expression) {

if (!angular.isFunction(expression)) {
var first = array[0];
const first = array[0];
if (!first) {

@@ -69,3 +60,3 @@ return null;

}
for (var i = 0; i < array.length; i++) {
for (let i = 0; i < array.length; i++) {
if (expression(array[i])) {

@@ -78,14 +69,33 @@ return array[i];

// Solution from: https://stackoverflow.com/questions/30758961/how-to-check-if-a-variable-is-an-es6-class-declaration#answer-68708710
function isClass(value) {
return typeof value === "function" && (/^\s*class[^\w]+/.test(value.toString()) ||
// 1. native classes don't have `class` in their name
// 2. However, they are globals and start with a capital letter.
(window[value.name] === value && /^[A-Z]/.test(value.name)));
}
function wrapRouterConfig(routerConfig) {
if (isClass(routerConfig)) {
const wrapperFunction = (...args) => {
// @ts-ignore
return new routerConfig(...args);
};
wrapperFunction.$inject = routerConfig.$inject;
return wrapperFunction;
}
return routerConfig;
}
function importHandler(imports) {
var ng1ModuleIds = [];
var modules = imports.filter(function (mdl) {
let ng1ModuleIds = [];
const modules = imports.filter((mdl) => {
return !(mdl.$inject
&& findFirst(mdl.$inject, function (i) { return i === "$stateProvider"; }));
&& findFirst(mdl.$inject, (i) => i === "$stateProvider"));
});
var ng1RouterConfig = findFirst(imports, function (mdl) {
const ng1RouterConfig = findFirst(imports, (mdl) => {
return mdl.$inject
&& findFirst(mdl.$inject, function (i) { return i === "$stateProvider"; });
&& findFirst(mdl.$inject, (i) => i === "$stateProvider");
});
if (modules.length) {
ng1ModuleIds = modules.map(function (mdl) {
ng1ModuleIds = modules.map((mdl) => {
if (mdl.ng1ShiftModuleName) {

@@ -98,4 +108,4 @@ return mdl.ng1ShiftModuleName;

return {
ng1ModuleIds: ng1ModuleIds,
ng1RouterConfig: ng1RouterConfig
ng1ModuleIds,
ng1RouterConfig: wrapRouterConfig(ng1RouterConfig),
};

@@ -106,5 +116,5 @@ }

if (str.indexOf("-") !== -1) {
var newArr = str.toLowerCase().split("-");
const newArr = str.toLowerCase().split("-");
// We are starting from 1 because the first letter in camelCase word is in lowercase
for (var i = 1; i < newArr.length; i++) {
for (let i = 1; i < newArr.length; i++) {
newArr[i] = newArr[i].charAt(0).toUpperCase() + newArr[i].substr(1);

@@ -117,3 +127,3 @@ }

var DeclarationType = {
const DeclarationType = {
component: "component",

@@ -129,4 +139,4 @@ directive: "directive"

function getRestrictFromSelector(selector) {
var firstSign = selector.substr(0, 1);
var restrict = "E";
const firstSign = selector.substr(0, 1);
let restrict = "E";
switch (firstSign) {

@@ -143,39 +153,13 @@ case "[":

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function DirectiveFactory(type) {
return function () { return Object(__assign({}, type)); };
return () => Object(Object.assign({}, type));
}
function daclarationHandler(ng1Module, declarations) {
declarations.forEach(function (declaration) {
var hasNg1Meta = Reflect.hasMetadata(Metakeys.type, declaration);
declarations.forEach((declaration) => {
const hasNg1Meta = Reflect.hasMetadata(Metakeys.type, declaration);
if (hasNg1Meta) {
var declarationType = Reflect.getMetadata(Metakeys.type, declaration);
var selectorNg2 = declaration.selector;
var selectorNg1 = void 0;
const declarationType = Reflect.getMetadata(Metakeys.type, declaration);
const selectorNg2 = declaration.selector;
let selectorNg1;
switch (declarationType) {

@@ -196,15 +180,12 @@ case DeclarationType.component:

function providerHandler(ng1Module, providers, declarations) {
declarations.forEach(function (declaration) {
var injections = Reflect.getMetadata("design:paramtypes", declaration);
declarations.forEach((declaration) => {
const injections = Reflect.getMetadata("design:paramtypes", declaration);
if (injections) {
var injectedServices_1 = injections.map(function (_a) {
var name = _a.name;
return name;
});
const injectedServices = injections.map(({ name }) => name);
if (!declaration.$inject) {
declaration.$inject = [];
}
providers.forEach(function (provider) {
var serviceToken = provider.name;
var injectIndex = injectedServices_1.indexOf(serviceToken);
providers.forEach((provider) => {
const serviceToken = provider.name;
const injectIndex = injectedServices.indexOf(serviceToken);
declaration.$inject[injectIndex] = serviceToken;

@@ -217,5 +198,5 @@ ng1Module.service(serviceToken, provider);

var entityCounters = {};
const entityCounters = {};
function counter(entity) {
var registeredEntity = entity in entityCounters;
const registeredEntity = entity in entityCounters;
if (!registeredEntity) {

@@ -227,14 +208,13 @@ entityCounters[entity] = 0;

function NgModule(_a) {
var id = _a.id, imports = _a.imports, declarations = _a.declarations, providers = _a.providers, directRegister = _a.directRegister;
function NgModule({ id, imports, declarations, providers, directRegister }) {
return function (target) {
var ng1ModuleIds = [];
var ng1RouterConfig;
var hasImports = imports && imports.length;
let ng1ModuleIds = [];
let ng1RouterConfig;
const hasImports = imports && imports.length;
if (hasImports) {
var handledImports = importHandler(imports);
const handledImports = importHandler(imports);
ng1ModuleIds = handledImports.ng1ModuleIds;
ng1RouterConfig = handledImports.ng1RouterConfig;
}
target.ng1ShiftModuleName = target.name + "-" + counter("moduleName");
target.ng1ShiftModuleName = `${target.name}-${counter("moduleName")}`;
if (id === "app-module") {

@@ -244,3 +224,3 @@ target.ng1ShiftModuleName = id;

// @ts-ignore
var ng1Module = angular.module(target.ng1ShiftModuleName, ng1ModuleIds);
const ng1Module = angular.module(target.ng1ShiftModuleName, ng1ModuleIds);
if (ng1RouterConfig) {

@@ -262,7 +242,7 @@ ng1Module.config(ng1RouterConfig);

function replaceTwoWayBindings(target) {
var componentMetadata = new ComponentMetadataService(target), inputs = componentMetadata.getInputs(), outputs = componentMetadata.getOutputs();
const componentMetadata = new ComponentMetadataService(target), inputs = componentMetadata.getInputs(), outputs = componentMetadata.getOutputs();
if (inputs.length > 0 && outputs.length > 0) {
inputs.forEach(function (input) {
var requiredOutput = input.inputName + "Change";
var hasOutput = outputs.some(function (output) { return output.outputName === requiredOutput; });
inputs.forEach(input => {
const requiredOutput = `${input.inputName}Change`;
const hasOutput = outputs.some(output => output.outputName === requiredOutput);
if (hasOutput && target.bindings) {

@@ -306,5 +286,4 @@ target.bindings[input.componentProp] = target.bindings[input.componentProp].replace(/^</, "=");

function Directive(_a) {
var selector = _a.selector;
return function (target) {
function Directive({ selector }) {
return (target) => {
if (selector) {

@@ -341,8 +320,8 @@ target.selector = kebabCaseToCamelCase(selector);

return function (target, property) {
var componentMetadata = new ComponentMetadataService(target.constructor);
const componentMetadata = new ComponentMetadataService(target.constructor);
if (!target.constructor.bindings) {
target.constructor.bindings = {};
}
var propName = String(property);
var attrBinding = alias ? alias : propName;
const propName = String(property);
const attrBinding = alias ? alias : propName;
target.constructor.bindings[propName] = "<" + attrBinding;

@@ -354,10 +333,10 @@ componentMetadata.addInput(propName, attrBinding);

return function (target, property) {
var componentMetadata = new ComponentMetadataService(target.constructor);
const componentMetadata = new ComponentMetadataService(target.constructor);
if (!target.constructor.bindings) {
target.constructor.bindings = {};
}
var propName = String(property);
var privateCallbackName = "__" + propName;
var attrBinding = alias ? alias : propName;
target.constructor.bindings[privateCallbackName] = "&" + attrBinding;
const propName = String(property);
const privateCallbackName = `__${propName}`;
const attrBinding = alias ? alias : propName;
target.constructor.bindings[privateCallbackName] = `&${attrBinding}`;
componentMetadata.addOutput(propName, attrBinding);

@@ -378,3 +357,2 @@ Object.defineProperty(target, privateCallbackName, {

set: function (eventEmitterInstance) {
var _this = this;
if (!this.__eventEmitterCache) {

@@ -384,5 +362,5 @@ this.__eventEmitterCache = {};

if (eventEmitterInstance && eventEmitterInstance.subscribe) {
eventEmitterInstance.subscribe(function (eventData) {
if (typeof _this.__callbackCache[propName] === "function") {
_this.__callbackCache[propName]({ $event: eventData });
eventEmitterInstance.subscribe((eventData) => {
if (typeof this.__callbackCache[propName] === "function") {
this.__callbackCache[propName]({ $event: eventData });
}

@@ -406,3 +384,3 @@ });

}
var injectionToken = typeof dependencyName === "string"
const injectionToken = typeof dependencyName === "string"
? dependencyName

@@ -413,14 +391,13 @@ : dependencyName.$injectionToken;

}
var EventEmitter = /** @class */ (function () {
function EventEmitter() {
class EventEmitter {
constructor() {
this.listeners = [];
}
EventEmitter.prototype.emit = function (event) {
this.listeners.forEach(function (callback) { return callback.call(null, event); });
};
EventEmitter.prototype.subscribe = function (callback) {
emit(event) {
this.listeners.forEach(callback => callback.call(null, event));
}
subscribe(callback) {
this.listeners.push(callback);
};
return EventEmitter;
}());
}
}

@@ -437,3 +414,3 @@ exports.Component = Component;

})));
}));
//# sourceMappingURL=index.js.map
{
"name": "ng1-shift",
"version": "0.1.1",
"version": "0.1.2",
"description": "Angular 1.5+ decorators for writing Angular2 like.",

@@ -46,3 +46,4 @@ "files": [

"dependencies": {
"reflect-metadata": "^0.1.13"
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2"
},

@@ -52,3 +53,3 @@ "peerDependencies": {

"typescript": "^4.0.5",
"tslib": "^1.11.1"
"tslib": "^1.14.0"
},

@@ -63,3 +64,2 @@ "devDependencies": {

"onchange": "^5.0.2",
"rimraf": "^3.0.2",
"rollup": "^2.33.3",

@@ -71,3 +71,3 @@ "rollup-plugin-commonjs": "^10.1.0",

"ts-jest": "^26.4.4",
"tslib": "^1.11.1",
"tslib": "^1.14.0",
"tslint": "^5.9.1",

@@ -74,0 +74,0 @@ "typescript": "^4.0.5"

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