@vaadin/hilla-generator-plugin-signals 24.7.0-alpha10 → 24.7.0-alpha12
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/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js.map +1 -1
- package/package.json +5 -5
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Plugin from '@vaadin/hilla-generator-core/Plugin.js';
|
|
2
|
-
import type SharedStorage from '@vaadin/hilla-generator-core/SharedStorage.js';
|
|
2
|
+
import type { SharedStorage } from '@vaadin/hilla-generator-core/SharedStorage.js';
|
|
3
3
|
export type PathSignalType = Readonly<{
|
|
4
4
|
path: string;
|
|
5
5
|
signalType: string;
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,wCAAwC,CAAC;AAC5D,OAAO,KAAK,aAAa,MAAM,+CAA+C,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,wCAAwC,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAC;AAUnF,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC,CAAC;AAwCH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,MAAM;IAEhC,OAAO,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB3D,CAAC,aAAa,CAAC,EAAE,OAAO,aAAa,CAAC;IAE9C,IAAa,IAAI,IAAI,MAAM,CAE1B;CACF"}
|
package/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/index.ts"],
|
|
4
|
-
"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 SignalProcessor from './SignalProcessor.js';\n\n// Polyfill for iterator helpers (Stage 3 proposal)\nif (!('Iterator' in globalThis)) {\n const { installIntoGlobal } = await import('iterator-helpers-polyfill');\n installIntoGlobal();\n}\n\nexport type PathSignalType = Readonly<{\n path: string;\n signalType: string;\n}>;\n\nconst SIGNAL_CLASSES = [\n '#/components/schemas/com.vaadin.hilla.signals.NumberSignal',\n '#/components/schemas/com.vaadin.hilla.signals.ValueSignal',\n '#/components/schemas/com.vaadin.hilla.signals.ListSignal',\n];\n\nfunction extractEndpointMethodsWithSignalsAsReturnType(storage: SharedStorage): PathSignalType[] {\n return Object.entries(storage.api.paths)\n .filter(([_, pathObject]) => {\n const response200 = pathObject?.post?.responses['200'];\n return response200 && !('$ref' in response200);\n })\n .flatMap(([path, pathObject]) => {\n const response200 = pathObject?.post?.responses['200'];\n const responseSchema = (response200 as OpenAPIV3.ResponseObject).content?.['application/json']?.schema;\n\n return responseSchema && 'anyOf' in responseSchema\n ? responseSchema.anyOf\n ?.filter((c) => '$ref' in c && c.$ref && SIGNAL_CLASSES.includes(c.$ref))\n .map((c: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject) => ({\n path,\n signalType: '$ref' in c ? c.$ref : '',\n }))\n : [];\n })\n .filter((signalArray) => signalArray != null);\n}\n\nfunction groupByService(signals: readonly PathSignalType[]): Map<string, Map<string, string>> {\n return signals.reduce((serviceMap, signal) => {\n const [_, service, method] = signal.path.split('/');\n const serviceMethods = serviceMap.get(service) ?? new Map<string, string>();\n serviceMethods.set(method, signal.signalType);\n serviceMap.set(service, serviceMethods);\n return serviceMap;\n }, new Map<string, Map<string, string>>());\n}\n\nexport default class SignalsPlugin extends Plugin {\n // eslint-disable-next-line @typescript-eslint/require-await\n override async execute(sharedStorage: SharedStorage): Promise<void> {\n const methodsWithSignals = extractEndpointMethodsWithSignalsAsReturnType(sharedStorage);\n const services = groupByService(methodsWithSignals);\n services.forEach((methods, service) => {\n const index = sharedStorage.sources.findIndex((source) => source.fileName === `${service}.ts`);\n if (index >= 0) {\n sharedStorage.sources[index] = new SignalProcessor(\n service,\n methods,\n sharedStorage.sources[index],\n this,\n ).process();\n }\n });\n }\n\n declare ['constructor']: typeof SignalsPlugin;\n\n override get path(): string {\n return import.meta.url;\n }\n}\n"],
|
|
4
|
+
"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 SignalProcessor from './SignalProcessor.js';\n\n// Polyfill for iterator helpers (Stage 3 proposal)\nif (!('Iterator' in globalThis)) {\n const { installIntoGlobal } = await import('iterator-helpers-polyfill');\n installIntoGlobal();\n}\n\nexport type PathSignalType = Readonly<{\n path: string;\n signalType: string;\n}>;\n\nconst SIGNAL_CLASSES = [\n '#/components/schemas/com.vaadin.hilla.signals.NumberSignal',\n '#/components/schemas/com.vaadin.hilla.signals.ValueSignal',\n '#/components/schemas/com.vaadin.hilla.signals.ListSignal',\n];\n\nfunction extractEndpointMethodsWithSignalsAsReturnType(storage: SharedStorage): PathSignalType[] {\n return Object.entries(storage.api.paths)\n .filter(([_, pathObject]) => {\n const response200 = pathObject?.post?.responses['200'];\n return response200 && !('$ref' in response200);\n })\n .flatMap(([path, pathObject]) => {\n const response200 = pathObject?.post?.responses['200'];\n const responseSchema = (response200 as OpenAPIV3.ResponseObject).content?.['application/json']?.schema;\n\n return responseSchema && 'anyOf' in responseSchema\n ? responseSchema.anyOf\n ?.filter((c) => '$ref' in c && c.$ref && SIGNAL_CLASSES.includes(c.$ref))\n .map((c: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject) => ({\n path,\n signalType: '$ref' in c ? c.$ref : '',\n }))\n : [];\n })\n .filter((signalArray) => signalArray != null);\n}\n\nfunction groupByService(signals: readonly PathSignalType[]): Map<string, Map<string, string>> {\n return signals.reduce((serviceMap, signal) => {\n const [_, service, method] = signal.path.split('/');\n const serviceMethods = serviceMap.get(service) ?? new Map<string, string>();\n serviceMethods.set(method, signal.signalType);\n serviceMap.set(service, serviceMethods);\n return serviceMap;\n }, new Map<string, Map<string, string>>());\n}\n\nexport default class SignalsPlugin extends Plugin {\n // eslint-disable-next-line @typescript-eslint/require-await\n override async execute(sharedStorage: SharedStorage): Promise<void> {\n const methodsWithSignals = extractEndpointMethodsWithSignalsAsReturnType(sharedStorage);\n const services = groupByService(methodsWithSignals);\n services.forEach((methods, service) => {\n const index = sharedStorage.sources.findIndex((source) => source.fileName === `${service}.ts`);\n if (index >= 0) {\n sharedStorage.sources[index] = new SignalProcessor(\n service,\n methods,\n sharedStorage.sources[index],\n this,\n ).process();\n }\n });\n }\n\n declare ['constructor']: typeof SignalsPlugin;\n\n override get path(): string {\n return import.meta.url;\n }\n}\n"],
|
|
5
5
|
"mappings": "AAAA,OAAO,YAAY;AAGnB,OAAO,qBAAqB;AAG5B,IAAI,EAAE,cAAc,aAAa;AAC/B,QAAM,EAAE,kBAAkB,IAAI,MAAM,OAAO,2BAA2B;AACtE,oBAAkB;AACpB;AAOA,MAAM,iBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,8CAA8C,SAA0C;AAC/F,SAAO,OAAO,QAAQ,QAAQ,IAAI,KAAK,EACpC,OAAO,CAAC,CAAC,GAAG,UAAU,MAAM;AAC3B,UAAM,cAAc,YAAY,MAAM,UAAU,KAAK;AACrD,WAAO,eAAe,EAAE,UAAU;AAAA,EACpC,CAAC,EACA,QAAQ,CAAC,CAAC,MAAM,UAAU,MAAM;AAC/B,UAAM,cAAc,YAAY,MAAM,UAAU,KAAK;AACrD,UAAM,iBAAkB,YAA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
|
2
2
|
"name": "@vaadin/hilla-generator-plugin-signals",
|
|
3
|
-
"version": "24.7.0-
|
|
3
|
+
"version": "24.7.0-alpha12",
|
|
4
4
|
"description": "A Hilla TypeScript Generator plugin to add Shared Signals support",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@vaadin/hilla-generator-core": "24.7.0-
|
|
56
|
-
"@vaadin/hilla-generator-plugin-backbone": "24.7.0-
|
|
57
|
-
"@vaadin/hilla-generator-plugin-client": "24.7.0-
|
|
58
|
-
"@vaadin/hilla-generator-utils": "24.7.0-
|
|
55
|
+
"@vaadin/hilla-generator-core": "24.7.0-alpha12",
|
|
56
|
+
"@vaadin/hilla-generator-plugin-backbone": "24.7.0-alpha12",
|
|
57
|
+
"@vaadin/hilla-generator-plugin-client": "24.7.0-alpha12",
|
|
58
|
+
"@vaadin/hilla-generator-utils": "24.7.0-alpha12",
|
|
59
59
|
"fast-deep-equal": "3.1.3",
|
|
60
60
|
"iterator-helpers-polyfill": "3.0.1",
|
|
61
61
|
"openapi-types": "12.1.3",
|