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

@ealmansi/jagger

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ealmansi/jagger - npm Package Compare versions

Comparing version 0.1.31 to 0.1.32

2

js/lib/computeResolution.d.ts

@@ -15,2 +15,3 @@ import ts from "typescript";

parameterTypeResolutions: TypeResolution[];
requiresAsync: boolean;
}

@@ -22,2 +23,3 @@ interface SetTypeResolution {

elementTypeResolutions: TypeResolution[];
requiresAsync: boolean;
}

@@ -24,0 +26,0 @@ export declare function buildResolution(typeChecker: ts.TypeChecker, graph: Graph): Resolution;

@@ -87,2 +87,14 @@ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {

const returnTypeResolution = orThrow(returnTypeResolutions.at(0));
if (returnTypeResolution.requiresAsync &&
returnType === getAwaitedType(typeChecker, returnType)) {
assert.fail([
"Type ",
typeChecker.typeToString(returnType),
" for ",
resolver.name.getText(),
" in ",
orThrow(component.name).text,
" cannot be resolved synchronously",
].join(""));
}
resolverTypeResolution.set(resolver, returnTypeResolution);

@@ -151,5 +163,9 @@ const moduleInstancesSet = orThrow(componentModuleInstancesSet.get(component));

const providers = orThrow(graph.moduleProviders.get(module));
const awaitedType = getAwaitedType(typeChecker, type);
for (const provider of providers) {
const returnType = orThrow(graph.providerReturnType.get(provider));
if (!typesAreConsideredEqual(typeChecker, returnType, type)) {
const awaitedReturnType = getAwaitedType(typeChecker, returnType);
if (!typesAreConsideredEqual(typeChecker, returnType, type) &&
!typesAreConsideredEqual(typeChecker, returnType, awaitedType) &&
!typesAreConsideredEqual(typeChecker, awaitedReturnType, type)) {
continue;

@@ -184,5 +200,30 @@ }

parameterTypeResolutions,
requiresAsync: returnType !== awaitedReturnType ||
parameterTypeResolutions.some((parameterTypeResolution) => parameterTypeResolution.requiresAsync),
};
}
}
function getAwaitedType(typeChecker, type) {
const typeSymbol = type.getSymbol();
if (typeSymbol === undefined) {
return type;
}
if (typeSymbol.getName() !== "Promise") {
return type;
}
if ((type.getFlags() & ts.TypeFlags.Object) === 0) {
return type;
}
const objectType = type;
if ((objectType.objectFlags & ts.ObjectFlags.Reference) === 0) {
return type;
}
const typeReference = type;
const typeArguments = typeChecker.getTypeArguments(typeReference);
if (typeArguments.length !== 1) {
return type;
}
const typeArgument = orThrow(typeArguments.at(0));
return typeArgument;
}
function* getSetTypeResolutions(typeChecker, graph, moduleStack, type, moduleUnresolvedTypes) {

@@ -216,2 +257,3 @@ const module = orThrow(moduleStack.at(-1));

elementTypeResolutions,
requiresAsync: elementTypeResolutions.some((elementTypeResolution) => elementTypeResolution.requiresAsync),
};

@@ -238,2 +280,23 @@ }

}
const symbolA = typeA.getSymbol();
const symbolB = typeB.getSymbol();
if (symbolA !== undefined &&
symbolB !== undefined &&
symbolA.getName() === symbolB.getName()) {
let objectFlagsA;
if (typeA.getFlags() & ts.TypeFlags.Object) {
const objectTypeA = typeA;
objectFlagsA = objectTypeA.objectFlags;
}
let objectFlagsB;
if (typeB.getFlags() & ts.TypeFlags.Object) {
const objectTypeB = typeB;
objectFlagsB = objectTypeB.objectFlags;
}
const typeArgumentsA = getTypeArguments(typeChecker, typeA) ?? [];
const typeArgumentsB = getTypeArguments(typeChecker, typeB) ?? [];
return (objectFlagsA === objectFlagsB &&
typeArgumentsA.length === typeArgumentsB.length &&
typeArgumentsA.every((typeArgumentA, index) => typesAreConsideredEqual(typeChecker, typeArgumentA, orThrow(typeArgumentsB.at(index)))));
}
for (const type of [typeA, typeB]) {

@@ -254,2 +317,13 @@ if ((type.getFlags() & ts.TypeFlags.Any) !== 0) {

}
function getTypeArguments(typeChecker, type) {
if (type.getFlags() & ts.TypeFlags.Object) {
const objectType = type;
if (objectType.objectFlags & ts.ObjectFlags.Reference) {
const typeReference = type;
const typeArguments = typeChecker.getTypeArguments(typeReference);
return typeArguments;
}
}
return undefined;
}
function getTypeResolutionModules(typeResolution) {

@@ -256,0 +330,0 @@ const modules = new Set();

@@ -88,6 +88,14 @@ import assert from "node:assert/strict";

return [
factory.createMethodDeclaration([factory.createToken(ts.SyntaxKind.PrivateKeyword)], undefined, factory.createIdentifier(typeResolutionName), undefined, undefined, [], undefined, factory.createBlock([
factory.createReturnStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createThis(), factory.createIdentifier("_" + orThrow(typeResolution.module.name).text)), factory.createIdentifier(typeResolution.provider.name.getText())), undefined, [
factory.createMethodDeclaration([
factory.createToken(ts.SyntaxKind.PrivateKeyword),
...(typeResolution.requiresAsync
? [factory.createToken(ts.SyntaxKind.AsyncKeyword)]
: []),
], undefined, factory.createIdentifier(typeResolutionName), undefined, undefined, [], undefined, factory.createBlock([
factory.createReturnStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createThis(), factory.createIdentifier(buildModuleInstanceName(typeResolution.module))), factory.createIdentifier(typeResolution.provider.name.getText())), undefined, [
...typeResolution.parameterTypeResolutions.map((parameterTypeResolution) => {
return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createThis(), factory.createIdentifier(buildTypeResolutionName(parameterTypeResolution, syntheticTypeResolutionName))), undefined, []);
const callExpression = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createThis(), factory.createIdentifier(buildTypeResolutionName(parameterTypeResolution, syntheticTypeResolutionName))), undefined, []);
return parameterTypeResolution.requiresAsync
? factory.createAwaitExpression(callExpression)
: callExpression;
}),

@@ -99,7 +107,15 @@ ])),

return [
factory.createMethodDeclaration([factory.createToken(ts.SyntaxKind.PrivateKeyword)], undefined, factory.createIdentifier(buildTypeResolutionName(typeResolution, syntheticTypeResolutionName)), undefined, undefined, [], undefined, factory.createBlock([
factory.createMethodDeclaration([
factory.createToken(ts.SyntaxKind.PrivateKeyword),
...(typeResolution.requiresAsync
? [factory.createToken(ts.SyntaxKind.AsyncKeyword)]
: []),
], undefined, factory.createIdentifier(buildTypeResolutionName(typeResolution, syntheticTypeResolutionName)), undefined, undefined, [], undefined, factory.createBlock([
factory.createReturnStatement(factory.createNewExpression(factory.createIdentifier("Set"), undefined, [
factory.createArrayLiteralExpression([
...typeResolution.elementTypeResolutions.map((elementTypeResolution) => {
return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createThis(), factory.createIdentifier(buildTypeResolutionName(elementTypeResolution, syntheticTypeResolutionName))), undefined, []);
const callExpression = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createThis(), factory.createIdentifier(buildTypeResolutionName(elementTypeResolution, syntheticTypeResolutionName))), undefined, []);
return elementTypeResolution.requiresAsync
? factory.createAwaitExpression(callExpression)
: callExpression;
}),

@@ -106,0 +122,0 @@ ], false),

2

package.json
{
"name": "@ealmansi/jagger",
"version": "0.1.31",
"version": "0.1.32",
"description": "WIP",

@@ -5,0 +5,0 @@ "files": [

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