@vaadin/hilla-generator-plugin-push 24.8.8 → 24.8.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PushProcessor.js.map +1 -1
- package/index.js.map +1 -1
- package/package.json +4 -4
package/PushProcessor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,OAAO,yEAA0E;AACjF,OAAO,wFAAyF;AAChG,OAAO,4EAA6E;AACpF,OAAO,uDAAwD;AAC/D,OAAO,oBAAqB;AAE5B,MAAM,wBAAwB;AAO9B,OAAO,MAAM,cAAc;CACzB,AAASA,gBAAgB,IAAI,kBAAkB,IAAI,YAAY,EAAE,WAAW,MAAO;CACnF,AAASC;CACT,AAASC;CACT,AAASC;CAET,YAAYC,QAAuBC,YAAgC;AACjE,OAAKJ,cAAc;AACnB,OAAKC,UAAU;EAEf,MAAM,EAAE,SAAS,OAAO,GAAG,KAAKF;AAEhC,OAAKA,cAAc,QAAQ,SAAS,OAAO;AAC3C,OAAKG,kBAAkB,QAAQ,MAC7B,QAAQ,MAAM,IAAI,MAAM,qBAAqB,0BAA0B,MAAM,EAAE,eAAe,CAC/F;CACF;CAED,UAAyB;EACvB,MAAM,kBAAkB,KAAKD,QAAQ,WAClC,OAAO,CAAC,eAAe,GAAG,oBAAoB,UAAU,CAAC,CACzD,IAAI,CAAC,cAAc;AAClB,OAAI,GAAG,sBAAsB,UAAU,EAAE;IACvC,MAAM,eAAe,UAAU,MAAM;AAGrC,QAAI,gBAAgB,KAAKD,YAAY,eAAe,SAAS,aAAa,EAAE;AAC1E,YAAO,KAAKK,gBAAgB,UAAU;IACvC;GACF;AAED,UAAO;EACR,EAAC;EAEJ,IAAI,mBAAmB,KAAKN,cAAc,QAAQ,QAAQ;AAE1D,MAAI,KAAKC,YAAY,kBAAkB;GACrC,MAAM,sBAAsB,iBAAiB,KAC3C,CAAC,cACC,GAAG,oBAAoB,UAAU,IAChC,UAAU,gBA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Y;;GAEZ,yBAAyB,WAAW,MAAM,IAAI,EAAE,GAAG;GACnD,KAAKI,oBAAoB,YAAY;GACrC,cAAcC,oBAAoB,aAAa,uBAAuB;CACvE;CACF;CAED,OAAOA,oBAAoBF,aAAqCG,wBAA2C;EACzG,MAAM,kBAAkB,YAAY,KAAM,WAAW;EACrD,MAAM,EAAE,WAAW,MAAM,YAAY,eAAe,GAAG,gBAAgB;EACvE,MAAM,OAAO;AAEb,SAAO,GAAG,QAAQ,YAAY,CAC5B,GAAG,QAAQ,sBACT,GAAG,QAAQ;GACT,GAAG,QAAQ;IACT,KAAK;;IAEL,GAAG,QAAQ,iBAAiB,YAAY;CACzC;GACD;;GAEA,yBAAyB,KAAK,MAAM,IAAI,EAAE,GAAG;CAC9C,CACF,AACF,EAAC;CACH;AACF","names":["#dependencies","#operations","#source","#subscriptionId","source: ts.SourceFile","operations: EndpointOperations","#updateFunction","#removeInitImport","updatedStatements: readonly ts.Statement[]","#doesInitParameterExist","parameters: ts.NodeArray<ts.ParameterDeclaration>","importStatement: ts.ImportDeclaration","declaration: ts.FunctionDeclaration","#replacePromiseType","#updateFunctionBody","doesInitParameterExist: boolean"],"sources":["/opt/agent/work/
|
|
1
|
+
{"mappings":"AAAA,OAAO,yEAA0E;AACjF,OAAO,wFAAyF;AAChG,OAAO,4EAA6E;AACpF,OAAO,uDAAwD;AAC/D,OAAO,oBAAqB;AAE5B,MAAM,wBAAwB;AAO9B,OAAO,MAAM,cAAc;CACzB,AAASA,gBAAgB,IAAI,kBAAkB,IAAI,YAAY,EAAE,WAAW,MAAO;CACnF,AAASC;CACT,AAASC;CACT,AAASC;CAET,YAAYC,QAAuBC,YAAgC;AACjE,OAAKJ,cAAc;AACnB,OAAKC,UAAU;EAEf,MAAM,EAAE,SAAS,OAAO,GAAG,KAAKF;AAEhC,OAAKA,cAAc,QAAQ,SAAS,OAAO;AAC3C,OAAKG,kBAAkB,QAAQ,MAC7B,QAAQ,MAAM,IAAI,MAAM,qBAAqB,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,gBAAgB,cAChB,OACA,WACA,GAAG,QAAQ,mBAAmB,gBAAgB,CAC/C;AAED,UAAO,GAAG,QAAQ,wBAChB,iBACA,WACA,qBACA,gBAAgB,iBAChB,UACD;EACF;AAED,SAAO;CACR;;;;;CAMD,oBAAoBC,aAAqC;EACvD,MAAM,CAAC,YAAY,GAAI,YAAY,KAA8B;EACjE,MAAM,eAAgB,GAAG,gBAAgB,YAAY,GAAG,YAAY,MAAM,KAAK;AAE/E,SAAO,GAAG,QAAQ,wBAAwB,KAAKT,iBAAiB,EAAE,aAAa,cAAc;CAC9F;CAED,gBAAgBS,aAA6D;EAC3E,MAAM,EAAE,YAAY,GAAG;EACvB,MAAM,yBAAyB,cAAcH,wBAAwB,WAAW;AAEhF,SAAO,GAAG,QAAQ;GAChB;GACA,YAAY;GACZ,YAAY;GACZ,YAAY;;GAEZ,yBAAyB,WAAW,MAAM,IAAI,EAAE,GAAG;GACnD,KAAKI,oBAAoB,YAAY;GACrC,cAAcC,oBAAoB,aAAa,uBAAuB;CACvE;CACF;CAED,OAAOA,oBAAoBF,aAAqCG,wBAA2C;EACzG,MAAM,kBAAkB,YAAY,KAAM,WAAW;EACrD,MAAM,EAAE,WAAW,MAAM,YAAY,eAAe,GAAG,gBAAgB;EACvE,MAAM,OAAO;AAEb,SAAO,GAAG,QAAQ,YAAY,CAC5B,GAAG,QAAQ,sBACT,GAAG,QAAQ;GACT,GAAG,QAAQ;IACT,KAAK;;IAEL,GAAG,QAAQ,iBAAiB,YAAY;CACzC;GACD;;GAEA,yBAAyB,KAAK,MAAM,IAAI,EAAE,GAAG;CAC9C,CACF,AACF,EAAC;CACH;AACF","names":["#dependencies","#operations","#source","#subscriptionId","source: ts.SourceFile","operations: EndpointOperations","#updateFunction","#removeInitImport","updatedStatements: readonly ts.Statement[]","#doesInitParameterExist","parameters: ts.NodeArray<ts.ParameterDeclaration>","importStatement: ts.ImportDeclaration","declaration: ts.FunctionDeclaration","#replacePromiseType","#updateFunctionBody","doesInitParameterExist: boolean"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-plugin-push/src/PushProcessor.ts"],"sourcesContent":["import createSourceFile from '@vaadin/hilla-generator-utils/createSourceFile.js';\nimport DependencyManager from '@vaadin/hilla-generator-utils/dependencies/DependencyManager.js';\nimport PathManager from '@vaadin/hilla-generator-utils/dependencies/PathManager.js';\nimport memoize from '@vaadin/hilla-generator-utils/memoize.js';\nimport ts from 'typescript';\n\nconst initParameterTypeName = 'EndpointRequestInit';\n\nexport type EndpointOperations = {\n methodsToPatch: string[];\n removeInitImport: boolean;\n};\n\nexport class PushProcessor {\n readonly #dependencies = new DependencyManager(new PathManager({ extension: '.js' }));\n readonly #operations: EndpointOperations;\n readonly #source: ts.SourceFile;\n readonly #subscriptionId: () => ts.Identifier;\n\n constructor(source: ts.SourceFile, operations: EndpointOperations) {\n this.#operations = operations;\n this.#source = source;\n\n const { imports, paths } = this.#dependencies;\n\n this.#dependencies.imports.fromCode(source);\n this.#subscriptionId = memoize(() =>\n imports.named.add(paths.createBareModulePath('@vaadin/hilla-frontend', false), 'Subscription'),\n );\n }\n\n process(): ts.SourceFile {\n const otherStatements = this.#source.statements\n .filter((statement) => !ts.isImportDeclaration(statement))\n .map((statement) => {\n if (ts.isFunctionDeclaration(statement)) {\n const functionName = statement.name?.text;\n\n // Checks if the method is in the list of methods to patch\n if (functionName && this.#operations.methodsToPatch.includes(functionName)) {\n return this.#updateFunction(statement);\n }\n }\n\n return statement;\n });\n\n let importStatements = this.#dependencies.imports.toCode();\n\n if (this.#operations.removeInitImport) {\n const importHillaFrontend = importStatements.find(\n (statement) =>\n ts.isImportDeclaration(statement) &&\n (statement.moduleSpecifier as ts.StringLiteral).text === '@vaadin/hilla-frontend',\n );\n\n if (importHillaFrontend) {\n const updatedImportStatement = PushProcessor.#removeInitImport(importHillaFrontend as ts.ImportDeclaration);\n\n if (updatedImportStatement) {\n importStatements = importStatements.map((statement) => {\n if (statement === importHillaFrontend) {\n return updatedImportStatement;\n }\n\n return statement;\n });\n }\n }\n }\n\n const updatedStatements: readonly ts.Statement[] = [...importStatements, ...otherStatements];\n\n return createSourceFile(updatedStatements, this.#source.fileName);\n }\n\n static #doesInitParameterExist(parameters: ts.NodeArray<ts.ParameterDeclaration>): boolean {\n const last = parameters[parameters.length - 1];\n const lastType = last.type as ts.TypeReferenceNode;\n const lastTypeName = lastType.typeName as ts.Identifier;\n\n return lastTypeName.text === initParameterTypeName;\n }\n\n static #removeInitImport(importStatement: ts.ImportDeclaration): ts.Statement | undefined {\n const namedImports = importStatement.importClause?.namedBindings;\n if (namedImports && ts.isNamedImports(namedImports)) {\n const updatedElements = namedImports.elements.filter((element) => element.name.text !== 'EndpointRequestInit');\n\n const updatedImportClause = ts.factory.updateImportClause(\n importStatement.importClause,\n false, // FIXME: could be true, but it is false for regular endpoint calls, so sticking to that for now\n undefined,\n ts.factory.createNamedImports(updatedElements),\n );\n\n return ts.factory.updateImportDeclaration(\n importStatement,\n undefined,\n updatedImportClause,\n importStatement.moduleSpecifier,\n undefined,\n );\n }\n\n return undefined;\n }\n\n /**\n * Replace returned `Promise<Array<T>>` by the `Subscription<T>` type\n * @param declaration -\n */\n #replacePromiseType(declaration: ts.FunctionDeclaration) {\n const [promiseType] = (declaration.type as ts.TypeReferenceNode).typeArguments!;\n const promiseArray = (ts.isUnionTypeNode(promiseType) ? promiseType.types[0] : promiseType) as ts.TypeReferenceNode;\n\n return ts.factory.createTypeReferenceNode(this.#subscriptionId(), promiseArray.typeArguments);\n }\n\n #updateFunction(declaration: ts.FunctionDeclaration): ts.FunctionDeclaration {\n const { parameters } = declaration;\n const doesInitParameterExist = PushProcessor.#doesInitParameterExist(parameters);\n\n return ts.factory.createFunctionDeclaration(\n undefined, // no async\n declaration.asteriskToken,\n declaration.name,\n declaration.typeParameters,\n // Remove the `init` parameter\n doesInitParameterExist ? parameters.slice(0, -1) : parameters,\n this.#replacePromiseType(declaration),\n PushProcessor.#updateFunctionBody(declaration, doesInitParameterExist),\n );\n }\n\n static #updateFunctionBody(declaration: ts.FunctionDeclaration, doesInitParameterExist: boolean): ts.Block {\n const returnStatement = declaration.body!.statements[0] as ts.ReturnStatement;\n const { arguments: args, expression, typeArguments } = returnStatement.expression! as ts.CallExpression;\n const call = expression as ts.PropertyAccessExpression;\n\n return ts.factory.createBlock([\n ts.factory.createReturnStatement(\n ts.factory.createCallExpression(\n ts.factory.createPropertyAccessExpression(\n call.expression,\n // `subscribe` instead of `call`\n ts.factory.createIdentifier('subscribe'),\n ),\n typeArguments,\n // remove the `init` parameter\n doesInitParameterExist ? args.slice(0, -1) : args,\n ),\n ),\n ]);\n }\n}\n"],"version":3}
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,OAAO,oDAAqD;AAI5D,SAAkC,yCAA0C;AAK5E,MAAMA,mBAAsC,CAC1C,+CACA,6DACD;AAED,eAAe,MAAM,mBAAmB,OAAO;;;;CAI7C,OAAOC,yBAAyBC,OAAkD;AAChF,SAAO,OAAO,QAAQ,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,KAAK;GACxD,MAAM,WAAW,MAAM,MAAM,UAAU;GACvC,MAAM,SAAS,UAAU,UAAU,qBAAqB;GACxD,MAAM,YAAY,SAAS;GAC3B,MAAM,GAAG,UAAU,OAAO,GAAG,IAAI,MAAM,IAAI;AAE3C,OAAI,aAAa,iBAAiB,SAAS,UAAU,EAAE;AACrD,QAAI,IAAI,IAAI,SAAS,EAAE;AACrB,SAAI,IAAI,SAAS,CAAE,eAAe,KAAK,OAAO;IAC/C,OAAM;AACL,SAAI,IAAI,UAAU;MAAE,gBAAgB,CAAC,MAAO;MAAE,kBAAkB;KAAM,EAAC;IACxE;GACF,OAAM;AAGL,QAAI,IAAI,IAAI,SAAS,EAAE;AACrB,SAAI,IAAI,SAAS,CAAE,mBAAmB;IACvC,OAAM;AACL,SAAI,IAAI,UAAU;MAAE,gBAAgB,CAAE;MAAE,kBAAkB;KAAO,EAAC;IACnE;GACF;AAED,UAAO;EACR,GAAE,IAAI,MAAkC;CAC1C;CAID,IAAa,OAAe;AAC1B,SAAO,OAAO,KAAK;CACpB;CAGD,MAAe,QAAQC,SAAuC;EAC5D,MAAM,EAAE,KAAK,SAAS,GAAG;EACzB,MAAM,oBAAoB,KAAK,YAAYF,yBAAyB,IAAI,MAAM;AAE9E,OAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;GACvC,MAAM,EAAE,UAAU,GAAG,QAAQ;GAC7B,MAAM,WAAW,SAAS,UAAU,GAAG,SAAS,QAAQ,MAAM,CAAC;AAE/D,OAAI,kBAAkB,IAAI,SAAS,EAAE;AACnC,YAAQ,KAAK,IAAI,cAAc,QAAQ,IAAI,kBAAkB,IAAI,SAAS,EAAG,SAAS;GACvF;EACF;CACF;AACF","names":["classesToReplace: readonly string[]","#collectPatchableMethods","paths: ReadonlyObjectDeep<OpenAPIV3.PathsObject>","storage: SharedStorage"],"sources":["/opt/agent/work/
|
|
1
|
+
{"mappings":"AAAA,OAAO,oDAAqD;AAI5D,SAAkC,yCAA0C;AAK5E,MAAMA,mBAAsC,CAC1C,+CACA,6DACD;AAED,eAAe,MAAM,mBAAmB,OAAO;;;;CAI7C,OAAOC,yBAAyBC,OAAkD;AAChF,SAAO,OAAO,QAAQ,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,KAAK;GACxD,MAAM,WAAW,MAAM,MAAM,UAAU;GACvC,MAAM,SAAS,UAAU,UAAU,qBAAqB;GACxD,MAAM,YAAY,SAAS;GAC3B,MAAM,GAAG,UAAU,OAAO,GAAG,IAAI,MAAM,IAAI;AAE3C,OAAI,aAAa,iBAAiB,SAAS,UAAU,EAAE;AACrD,QAAI,IAAI,IAAI,SAAS,EAAE;AACrB,SAAI,IAAI,SAAS,CAAE,eAAe,KAAK,OAAO;IAC/C,OAAM;AACL,SAAI,IAAI,UAAU;MAAE,gBAAgB,CAAC,MAAO;MAAE,kBAAkB;KAAM,EAAC;IACxE;GACF,OAAM;AAGL,QAAI,IAAI,IAAI,SAAS,EAAE;AACrB,SAAI,IAAI,SAAS,CAAE,mBAAmB;IACvC,OAAM;AACL,SAAI,IAAI,UAAU;MAAE,gBAAgB,CAAE;MAAE,kBAAkB;KAAO,EAAC;IACnE;GACF;AAED,UAAO;EACR,GAAE,IAAI,MAAkC;CAC1C;CAID,IAAa,OAAe;AAC1B,SAAO,OAAO,KAAK;CACpB;CAGD,MAAe,QAAQC,SAAuC;EAC5D,MAAM,EAAE,KAAK,SAAS,GAAG;EACzB,MAAM,oBAAoB,KAAK,YAAYF,yBAAyB,IAAI,MAAM;AAE9E,OAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;GACvC,MAAM,EAAE,UAAU,GAAG,QAAQ;GAC7B,MAAM,WAAW,SAAS,UAAU,GAAG,SAAS,QAAQ,MAAM,CAAC;AAE/D,OAAI,kBAAkB,IAAI,SAAS,EAAE;AACnC,YAAQ,KAAK,IAAI,cAAc,QAAQ,IAAI,kBAAkB,IAAI,SAAS,EAAG,SAAS;GACvF;EACF;CACF;AACF","names":["classesToReplace: readonly string[]","#collectPatchableMethods","paths: ReadonlyObjectDeep<OpenAPIV3.PathsObject>","storage: SharedStorage"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-plugin-push/src/index.ts"],"sourcesContent":["import Plugin from '@vaadin/hilla-generator-core/Plugin.js';\nimport type { SharedStorage } from '@vaadin/hilla-generator-core/SharedStorage.js';\nimport type { OpenAPIV3 } from 'openapi-types';\nimport type { ReadonlyObjectDeep } from 'type-fest/source/readonly-deep';\nimport { type EndpointOperations, PushProcessor } from './PushProcessor.js';\n\ntype ExtendedMediaTypeSchema = Readonly<{ 'x-class-name': string }> &\n ReadonlyObjectDeep<OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject>;\n\nconst classesToReplace: readonly string[] = [\n 'com.vaadin.hilla.runtime.transfertypes.Flux',\n 'com.vaadin.hilla.runtime.transfertypes.EndpointSubscription',\n];\n\nexport default class PushPlugin extends Plugin {\n /**\n * Collects methods that must be patched by checking their `x-class-name` value\n */\n static #collectPatchableMethods(paths: ReadonlyObjectDeep<OpenAPIV3.PathsObject>) {\n return Object.entries(paths).reduce((acc, [key, path]) => {\n const response = path?.post?.responses[200] as ReadonlyObjectDeep<OpenAPIV3.ResponseObject> | undefined;\n const schema = response?.content?.['application/json']?.schema as ExtendedMediaTypeSchema | undefined;\n const className = schema?.['x-class-name'];\n const [, endpoint, method] = key.split('/');\n\n if (className && classesToReplace.includes(className)) {\n if (acc.has(endpoint)) {\n acc.get(endpoint)!.methodsToPatch.push(method);\n } else {\n acc.set(endpoint, { methodsToPatch: [method], removeInitImport: true });\n }\n } else {\n // Not all methods will be patched, let's keep the init import\n // eslint-disable-next-line no-lonely-if\n if (acc.has(endpoint)) {\n acc.get(endpoint)!.removeInitImport = false;\n } else {\n acc.set(endpoint, { methodsToPatch: [], removeInitImport: false });\n }\n }\n\n return acc;\n }, new Map<string, EndpointOperations>());\n }\n\n declare ['constructor']: typeof PushPlugin;\n\n override get path(): string {\n return import.meta.url;\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n override async execute(storage: SharedStorage): Promise<void> {\n const { api, sources } = storage;\n const endpointMethodMap = this.constructor.#collectPatchableMethods(api.paths);\n\n for (let i = 0; i < sources.length; i++) {\n const { fileName } = sources[i];\n const endpoint = fileName.substring(0, fileName.indexOf('.ts'));\n\n if (endpointMethodMap.has(endpoint)) {\n sources[i] = new PushProcessor(sources[i], endpointMethodMap.get(endpoint)!).process();\n }\n }\n }\n}\n"],"version":3}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/hilla-generator-plugin-push",
|
|
3
|
-
"version": "24.8.
|
|
3
|
+
"version": "24.8.10",
|
|
4
4
|
"description": "A Hilla TypeScript Generator plugin to add push support",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@vaadin/hilla-generator-core": "24.8.
|
|
53
|
-
"@vaadin/hilla-generator-plugin-client": "24.8.
|
|
54
|
-
"@vaadin/hilla-generator-utils": "24.8.
|
|
52
|
+
"@vaadin/hilla-generator-core": "24.8.10",
|
|
53
|
+
"@vaadin/hilla-generator-plugin-client": "24.8.10",
|
|
54
|
+
"@vaadin/hilla-generator-utils": "24.8.10",
|
|
55
55
|
"fast-deep-equal": "3.1.3",
|
|
56
56
|
"openapi-types": "12.1.3",
|
|
57
57
|
"typescript": "5.8.3"
|