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

ng-typeview

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-typeview - npm Package Compare versions

Comparing version 0.0.31 to 0.0.32

102

dist/src/controller-parser.js

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

var typeParamsInfo = function () {
return prelude_ts_1.Option.ofStruct(iface.typeParameters)
return prelude_ts_1.Option.of(iface.typeParameters)
.filter(function (p) { return p.length > 0; })

@@ -29,3 +29,3 @@ .map(function (p) { return "<" + p.map(function (_, idx) { return "T" + idx; }).join(", ") + ">"; })

var maybeNodeType = function (sKind) { return function (input) {
return (input && input.kind === sKind) ? prelude_ts_1.Option.ofStruct(input) : prelude_ts_1.Option.none();
return (input && input.kind === sKind) ? prelude_ts_1.Option.of(input) : prelude_ts_1.Option.none();
}; };

@@ -37,3 +37,3 @@ /**

if (nodes && nodes.length === 1) {
return prelude_ts_1.Option.ofStruct(nodes[0]);
return prelude_ts_1.Option.of(nodes[0]);
}

@@ -100,3 +100,3 @@ return prelude_ts_1.Option.none();

return exports.maybePropertyAssignment(field)
.flatMapStruct(function (pa) { return exports.maybeStringLiteral(pa.initializer); })
.flatMap(function (pa) { return exports.maybeStringLiteral(pa.initializer); })
.map(function (ini) { return ini.text; });

@@ -109,10 +109,10 @@ }

function parseModalOpen(callExpr) {
var paramObjectElements = prelude_ts_1.Option.ofStruct(callExpr)
var paramObjectElements = prelude_ts_1.Option.of(callExpr)
.filter(function (c) { return ["$modal.open", "this.$modal.open"]
.indexOf(c.expression.getText()) >= 0; })
.flatMapStruct(function (c) { return maybeSingleNode(c.arguments); })
.flatMapStruct(function (a) { return exports.maybeObjectLiteralExpression(a); })
.map(function (o) { return prelude_ts_1.Vector.ofIterableStruct(o.properties); });
.flatMap(function (c) { return maybeSingleNode(c.arguments); })
.flatMap(function (a) { return exports.maybeObjectLiteralExpression(a); })
.map(function (o) { return prelude_ts_1.Vector.ofIterable(o.properties); });
var getField = function (name) {
return paramObjectElements.flatMapStruct(function (oe) { return objectLiteralGetStringLiteralField(name, oe); });
return paramObjectElements.flatMap(function (oe) { return objectLiteralGetStringLiteralField(name, oe); });
};

@@ -124,3 +124,3 @@ var controllerName = getField("controller");

};
return prelude_ts_1.Option.liftA2Struct(buildCtrlViewInfo)(rawViewPath, controllerName);
return prelude_ts_1.Option.liftA2(buildCtrlViewInfo)(rawViewPath, controllerName);
}

@@ -136,8 +136,8 @@ function parseModuleState(prop) {

// seems like I got a state controller/view declaration
var controllerName = objectLiteralGetStringLiteralField("controller", prelude_ts_1.Vector.ofIterableStruct(prop.properties));
var rawViewPath = objectLiteralGetStringLiteralField("templateUrl", prelude_ts_1.Vector.ofIterableStruct(prop.properties));
var controllerName = objectLiteralGetStringLiteralField("controller", prelude_ts_1.Vector.ofIterable(prop.properties));
var rawViewPath = objectLiteralGetStringLiteralField("templateUrl", prelude_ts_1.Vector.ofIterable(prop.properties));
var buildCtrlViewInfo = function (rawViewPath, ctrlName) {
return ({ controllerName: ctrlName, viewPath: rawViewPath });
};
return prelude_ts_1.Option.liftA2Struct(buildCtrlViewInfo)(rawViewPath, controllerName);
return prelude_ts_1.Option.liftA2(buildCtrlViewInfo)(rawViewPath, controllerName);
}

@@ -149,11 +149,11 @@ return prelude_ts_1.Option.none();

var prop0 = callExpr
.flatMapStruct(function (callExpr) { return exports.maybePropertyAccessExpression(callExpr.expression); });
.flatMap(function (callExpr) { return exports.maybePropertyAccessExpression(callExpr.expression); });
var prop = prop0
.flatMapStruct(function (callProp) { return exports.maybeCallExpression(callProp.expression); })
.flatMapStruct(function (callPropCall) { return exports.maybePropertyAccessExpression(callPropCall.expression); });
.flatMap(function (callProp) { return exports.maybeCallExpression(callProp.expression); })
.flatMap(function (callPropCall) { return exports.maybePropertyAccessExpression(callPropCall.expression); });
var receiver1 = prop
.flatMapStruct(function (p) { return exports.maybeIdentifier(p.expression); })
.flatMap(function (p) { return exports.maybeIdentifier(p.expression); })
.map(function (r) { return r.text; });
var call1 = prop
.flatMapStruct(function (p) { return exports.maybeIdentifier(p.name); })
.flatMap(function (p) { return exports.maybeIdentifier(p.name); })
.map(function (r) { return r.text; });

@@ -166,11 +166,11 @@ if (receiver1.filter(function (v) { return v === "angular"; })

.filter(function (c) { return c.arguments.length > 0; })
.flatMapStruct(function (c) { return exports.maybeStringLiteral(c.arguments[0]); })
.flatMap(function (c) { return exports.maybeStringLiteral(c.arguments[0]); })
.map(function (a) { return a.text; });
var moduleName = prop0
.flatMapStruct(function (p) { return exports.maybeCallExpression(p.expression); })
.flatMap(function (p) { return exports.maybeCallExpression(p.expression); })
.filter(function (c) { return c.arguments.length > 0; })
.flatMapStruct(function (c) { return exports.maybeStringLiteral(c.arguments[0]); })
.flatMap(function (c) { return exports.maybeStringLiteral(c.arguments[0]); })
.map(function (s) { return s.text; });
var buildModuleCtrl = function (mod, ctrl) { return [mod, ctrl]; };
return prelude_ts_1.Option.liftA2Struct(buildModuleCtrl)(moduleName, ctrlName);
return prelude_ts_1.Option.liftA2(buildModuleCtrl)(moduleName, ctrlName);
}

@@ -181,3 +181,3 @@ }

function getPropertyByName(objLit, propName) {
return prelude_ts_1.Option.ofStruct(objLit.properties
return prelude_ts_1.Option.of(objLit.properties
.find(function (p) { return exports.maybeIdentifier(p.name).filter(function (i) { return i.getText() === propName; }).isSome(); }));

@@ -188,9 +188,9 @@ }

var prop = prop0
.flatMapStruct(function (callProp) { return exports.maybeCallExpression(callProp.expression); })
.flatMapStruct(function (callPropCall) { return exports.maybePropertyAccessExpression(callPropCall.expression); });
.flatMap(function (callProp) { return exports.maybeCallExpression(callProp.expression); })
.flatMap(function (callPropCall) { return exports.maybePropertyAccessExpression(callPropCall.expression); });
var receiver1 = prop
.flatMapStruct(function (p) { return exports.maybeIdentifier(p.expression); })
.flatMap(function (p) { return exports.maybeIdentifier(p.expression); })
.map(function (r) { return r.text; });
var call1 = prop
.flatMapStruct(function (p) { return exports.maybeIdentifier(p.name); })
.flatMap(function (p) { return exports.maybeIdentifier(p.name); })
.map(function (r) { return r.text; });

@@ -201,31 +201,31 @@ if (receiver1.filter(function (v) { return v === "angular"; })

if (moduleCall.filter(function (v) { return v === "directive"; }).isSome()) {
var directiveParam = prelude_ts_1.Option.ofStruct(callExpr)
var directiveParam = prelude_ts_1.Option.of(callExpr)
.filter(function (c) { return c.arguments.length > 1; })
.mapStruct(function (c) { return c.arguments[1]; });
.map(function (c) { return c.arguments[1]; });
var returnExpr = directiveParam
.flatMapStruct(exports.maybeArrayLiteralExpression)
.flatMap(exports.maybeArrayLiteralExpression)
.filter(function (l) { return l.elements.length > 0; })
.mapStruct(function (l) { return l.elements[l.elements.length - 1]; })
.map(function (l) { return l.elements[l.elements.length - 1]; })
.orElse(directiveParam);
var arrowBodyExpr = returnExpr
.flatMapStruct(exports.maybeArrowFunction)
.flatMapStruct(function (a) { return exports.maybeBlock(a.body); });
.flatMap(exports.maybeArrowFunction)
.flatMap(function (a) { return exports.maybeBlock(a.body); });
var fnBodyExpr = returnExpr
.flatMapStruct(exports.maybeFunctionExpression)
.mapStruct(function (fn) { return fn.body; });
.flatMap(exports.maybeFunctionExpression)
.map(function (fn) { return fn.body; });
var bodyExpr = arrowBodyExpr.orElse(fnBodyExpr);
var resultExpr = bodyExpr
.flatMapStruct(function (b) { return exports.maybeReturnStatement(b.statements[b.statements.length - 1]); })
.flatMapStruct(function (s) { return prelude_ts_1.Option.ofStruct(s.expression); });
.flatMap(function (b) { return exports.maybeReturnStatement(b.statements[b.statements.length - 1]); })
.flatMap(function (s) { return prelude_ts_1.Option.of(s.expression); });
var scopeObject = resultExpr
.flatMapStruct(exports.maybeAsExpression)
.mapStruct(function (a) { return a.expression; })
.flatMap(exports.maybeAsExpression)
.map(function (a) { return a.expression; })
.orElse(resultExpr);
var templateUrl = scopeObject
.flatMapStruct(exports.maybeObjectLiteralExpression)
.flatMapStruct(function (e) { return getPropertyByName(e, "templateUrl"); })
.flatMapStruct(exports.maybePropertyAssignment)
.flatMapStruct(function (a) { return exports.maybeStringLiteral(a.initializer); })
.flatMap(exports.maybeObjectLiteralExpression)
.flatMap(function (e) { return getPropertyByName(e, "templateUrl"); })
.flatMap(exports.maybePropertyAssignment)
.flatMap(function (a) { return exports.maybeStringLiteral(a.initializer); })
.map(function (s) { return s.text; });
return templateUrl.mapStruct(function (viewPath) { return ({ modelPath: modelPath, viewPath: viewPath }); });
return templateUrl.map(function (viewPath) { return ({ modelPath: modelPath, viewPath: viewPath }); });
}

@@ -283,9 +283,9 @@ }

}
controllerViewInfos = controllerViewInfos.concat(prelude_ts_1.Vector.ofIterableStruct(ctrlViewConnectors)
controllerViewInfos = controllerViewInfos.concat(prelude_ts_1.Vector.ofIterable(ctrlViewConnectors)
.filter(function (conn) { return conn.interceptAstNode === node.kind; })
.flatMapStruct(function (conn) { return prelude_ts_1.Vector.ofIterableStruct(conn.getControllerView(node, webappPath)); })
.flatMap(function (conn) { return prelude_ts_1.Vector.ofIterable(conn.getControllerView(node, webappPath)); })
.toArray());
modelViewInfos = modelViewInfos.concat(prelude_ts_1.Vector.ofIterableStruct(modelViewConnectors)
modelViewInfos = modelViewInfos.concat(prelude_ts_1.Vector.ofIterable(modelViewConnectors)
.filter(function (conn) { return conn.interceptAstNode === node.kind; })
.flatMapStruct(function (conn) { return prelude_ts_1.Vector.ofIterableStruct(conn.getModelView(fileName, node, webappPath)); })
.flatMap(function (conn) { return prelude_ts_1.Vector.ofIterable(conn.getModelView(fileName, node, webappPath)); })
.toArray());

@@ -300,3 +300,3 @@ ts.forEachChild(node, nodeExtractModuleOpenAngularModule);

function nodeIsExported(node) {
return prelude_ts_1.Option.ofStruct(node.modifiers)
return prelude_ts_1.Option.of(node.modifiers)
.filter(function (modifiers) { return modifiers.some(function (modifier) { return modifier.kind === ts.SyntaxKind.ExportKeyword; }); })

@@ -364,5 +364,5 @@ .isSome();

}
var ctrlViewFragments = prelude_ts_1.Vector.ofIterableStruct(ctrlViewFragmentExtractors)
var ctrlViewFragments = prelude_ts_1.Vector.ofIterable(ctrlViewFragmentExtractors)
.filter(function (extractor) { return extractor.interceptAstNode === node.kind; })
.flatMapStruct(function (extractor) { return prelude_ts_1.Vector.ofIterable(extractor.getViewFragments(node)); });
.flatMap(function (extractor) { return prelude_ts_1.Vector.ofIterable(extractor.getViewFragments(node)); });
viewFragments = viewFragments.concat(ctrlViewFragments.toArray());

@@ -369,0 +369,0 @@ ts.forEachChild(node, nodeExtractScopeInterface);

@@ -55,9 +55,9 @@ "use strict";

var sourceFile = ts.createSourceFile("", "const ___ = " + input, ts.ScriptTarget.ES2016, /*setParentNodes */ true);
return prelude_ts_1.Option.ofStruct(sourceFile)
.flatMapStruct(function (f) { return controller_parser_1.maybeSingleNode(f.statements); })
.flatMapStruct(function (st) { return controller_parser_1.maybeVariableStatement(st); })
.flatMapStruct(function (vs) { return controller_parser_1.maybeSingleNode(vs.declarationList.declarations); })
return prelude_ts_1.Option.of(sourceFile)
.flatMap(function (f) { return controller_parser_1.maybeSingleNode(f.statements); })
.flatMap(function (st) { return controller_parser_1.maybeVariableStatement(st); })
.flatMap(function (vs) { return controller_parser_1.maybeSingleNode(vs.declarationList.declarations); })
.filter(function (decl) { return decl.initializer !== undefined; })
.flatMapStruct(function (decl) { return controller_parser_1.maybeObjectLiteralExpression(decl.initializer); })
.flatMapStruct(function (objLit) { return prelude_ts_1.Option.sequence(prelude_ts_1.Vector.ofIterableStruct(objLit.properties.map(controller_parser_1.maybePropertyAssignment))); })
.flatMap(function (decl) { return controller_parser_1.maybeObjectLiteralExpression(decl.initializer); })
.flatMap(function (objLit) { return prelude_ts_1.Option.sequence(prelude_ts_1.Vector.ofIterable(objLit.properties.map(controller_parser_1.maybePropertyAssignment))); })
.map(function (props) { return props.filter(function (p) { return p.initializer !== undefined; }); })

@@ -64,0 +64,0 @@ .map(function (props) { return props.map(function (prop) { return prop.name.getText() + ": " + addScAccessors(prop.initializer.getText()); }); })

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

}
return [4 /*yield*/, view_parser_1.parseView(prjSettings.resolveImportsAsNonScope || false, viewPath, scopeContents.viewFragments, scopeContents.importNames, prelude_ts_1.Vector.ofIterableStruct(tagDirectives), prelude_ts_1.Vector.ofIterableStruct(attributeDirectives), prelude_ts_1.Vector.ofIterableStruct(ngFilters))];
return [4 /*yield*/, view_parser_1.parseView(prjSettings.resolveImportsAsNonScope || false, viewPath, scopeContents.viewFragments, scopeContents.importNames, prelude_ts_1.Vector.ofIterable(tagDirectives), prelude_ts_1.Vector.ofIterable(attributeDirectives), prelude_ts_1.Vector.ofIterable(ngFilters))];
case 2:

@@ -118,7 +118,7 @@ viewExprs = _a.sent();

viewInfos = _a.sent();
viewFilenameToControllerNames = prelude_ts_1.Vector.ofIterableStruct(viewInfos)
.flatMapStruct(function (vi) { return prelude_ts_1.Vector.ofIterableStruct(vi.controllerViewInfos); })
.appendAllStruct(prjSettings.extraCtrlViewConnections)
viewFilenameToControllerNames = prelude_ts_1.Vector.ofIterable(viewInfos)
.flatMap(function (vi) { return prelude_ts_1.Vector.ofIterable(vi.controllerViewInfos); })
.appendAll(prjSettings.extraCtrlViewConnections)
.groupBy(function (cvi) { return cvi.viewPath; });
controllerNameToFilename = prelude_ts_1.Vector.ofIterableStruct(viewInfos)
controllerNameToFilename = prelude_ts_1.Vector.ofIterable(viewInfos)
.filter(function (vi) { return vi.controllerName.isSome(); })

@@ -129,12 +129,12 @@ .filter(function (vi) { return vi.fileName.toLowerCase().endsWith(".ts"); })

.map(function (viewFname, ctrlViewInfos) {
return [viewFname, view_parser_1.collectionKeepDefined(ctrlViewInfos.mapStruct(function (cvi) { return controllerNameToFilename.get(cvi.controllerName).getOrUndefined(); }))];
return [viewFname, view_parser_1.collectionKeepDefined(ctrlViewInfos.map(function (cvi) { return controllerNameToFilename.get(cvi.controllerName).getOrUndefined(); }))];
});
viewFilenameToCtrlFilenamesModelConns = prelude_ts_1.Vector.ofIterableStruct(viewInfos)
.flatMapStruct(function (vi) { return prelude_ts_1.Vector.ofIterableStruct(vi.modelViewInfos); })
viewFilenameToCtrlFilenamesModelConns = prelude_ts_1.Vector.ofIterable(viewInfos)
.flatMap(function (vi) { return prelude_ts_1.Vector.ofIterable(vi.modelViewInfos); })
.groupBy(function (mvi) { return mvi.viewPath; })
.mapValues(function (mvis) { return mvis.map(function (mvi) { return mvi.modelPath; }); });
viewFilenameToCtrlFilenames = viewFilenameToCtrlFilenamesViewConns.mergeWith(viewFilenameToCtrlFilenamesModelConns, function (views1, views2) { return views1.appendAll(views2); });
return [2 /*return*/, Promise.all(viewFilenameToCtrlFilenames.toVector().mapStruct(function (_a) {
return [2 /*return*/, Promise.all(viewFilenameToCtrlFilenames.toVector().map(function (_a) {
var viewName = _a[0], ctrlNames = _a[1];
return Promise.all(ctrlNames.mapStruct(function (ctrlName) { return processControllerView(prjSettings, ctrlName, prjSettings.path + "/" + viewName, prjSettings.ngFilters, prjSettings.tagDirectives, prjSettings.attributeDirectives); }).toArray());
return Promise.all(ctrlNames.map(function (ctrlName) { return processControllerView(prjSettings, ctrlName, prjSettings.path + "/" + viewName, prjSettings.ngFilters, prjSettings.tagDirectives, prjSettings.attributeDirectives); }).toArray());
}).toArray())];

@@ -141,0 +141,0 @@ }

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

this.addScopeAccessors = function (js) {
return addScopeAccessors(_this.ngScopeInfo.soFar.prependStruct({
return addScopeAccessors(_this.ngScopeInfo.soFar.prepend({
// hardcoding 1...I just need to let addScopeAccessors

@@ -31,0 +31,0 @@ // know about these local variables. a bit of a hack.

@@ -29,7 +29,7 @@ "use strict";

function collectionKeepDefined(l) {
return l.filter(function (x) { return x !== undefined; }).mapStruct(requireDefined);
return l.filter(function (x) { return x !== undefined; }).map(requireDefined);
}
exports.collectionKeepDefined = collectionKeepDefined;
function listKeepDefined(l) {
return l.filter(function (x) { return x !== undefined; }).mapStruct(requireDefined);
return l.filter(function (x) { return x !== undefined; }).map(requireDefined);
}

@@ -54,3 +54,3 @@ exports.listKeepDefined = listKeepDefined;

codegenHelpers.ngScopeInfo.curScopeVars.length > 0; })
.mapStruct(function (r) { return ({
.map(function (r) { return ({
xpathDepth: xpath.length(),

@@ -64,3 +64,3 @@ closeSource: r.closeSource || (function () { return ""; }),

var xpath = prelude_ts_1.Vector.of();
var activeScopes = prelude_ts_1.Vector.ofIterableStruct([{
var activeScopes = prelude_ts_1.Vector.ofIterable([{
xpathDepth: 0,

@@ -87,5 +87,5 @@ closeSource: function () { return ""; },

.filter(function (d) { return d.forTags.length === 0 || d.forTags.indexOf(name) >= 0; });
var tagDirectiveResps = listKeepDefined(relevantTagHandlers.mapStruct(function (handler) { return handler.handleTag(name, attribs, codegenHelpersTag); }));
var tagDirectiveResps = listKeepDefined(relevantTagHandlers.map(function (handler) { return handler.handleTag(name, attribs, codegenHelpersTag); }));
expressions += tagDirectiveResps.map(function (x) { return x.source; }).mkString("");
activeScopes = activeScopes.appendAllStruct(handleDirectiveResponses(xpath, codegenHelpersTag, tagDirectiveResps));
activeScopes = activeScopes.appendAll(handleDirectiveResponses(xpath, codegenHelpersTag, tagDirectiveResps));
var _loop_1 = function (attrName) {

@@ -97,5 +97,5 @@ var codegenHelpersAttr = new view_ngexpression_parser_1.CodegenHelper(ngFilters, activeScopes, getNewVariableName);

if (!handlers.isEmpty()) {
var attrDirectiveResps = listKeepDefined(handlers.mapStruct(function (handler) { return handler.handleAttribute(attrName, attrValue, attribs, codegenHelpersAttr); }));
var attrDirectiveResps = listKeepDefined(handlers.map(function (handler) { return handler.handleAttribute(attrName, attrValue, attribs, codegenHelpersAttr); }));
expressions += attrDirectiveResps.map(function (x) { return x.source; }).mkString("");
activeScopes = activeScopes.appendAllStruct(handleDirectiveResponses(xpath, codegenHelpersAttr, attrDirectiveResps));
activeScopes = activeScopes.appendAll(handleDirectiveResponses(xpath, codegenHelpersAttr, attrDirectiveResps));
}

@@ -102,0 +102,0 @@ else if (attrName.startsWith("ng-") &&

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

it("should add $scope properly", function () {
var fakeScopeInfo = prelude_ts_1.Vector.ofStruct({
var fakeScopeInfo = prelude_ts_1.Vector.of({
xpathDepth: 1,

@@ -11,0 +11,0 @@ closeSource: function () { return ""; },

{
"name": "ng-typeview",
"version": "0.0.31",
"version": "0.0.32",
"description": "library to enable type-checking of angular views when using typescript",

@@ -33,3 +33,3 @@ "keywords": [

"@types/parsimmon": "1.3.0",
"prelude.ts": "0.2.2"
"prelude.ts": "0.3.0"
},

@@ -36,0 +36,0 @@ "devDependencies": {

@@ -8,3 +8,3 @@ import * as assert from 'assert'

it ("should add $scope properly", () => {
const fakeScopeInfo: Vector<NgScope> = Vector.ofStruct(
const fakeScopeInfo: Vector<NgScope> = Vector.of(
{

@@ -11,0 +11,0 @@ xpathDepth: 1,

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