From dd94fdb28b5292ad02aa151d55213cce802387da Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Sat, 28 Feb 2026 08:36:49 +0100 Subject: [PATCH] Migrate from tsup (deprecated) to tsdown tsup is deprecated in favor of tsdown. Follow https://github.com/symfony/ux/pull/2935, https://github.com/symfony/ux/pull/2944, and many (local) tries were I was not really happy with the files generated by tsdown/rolldown, we are finally having something extra good! We have the benefits from https://github.com/symfony/ux/pull/2935, https://github.com/symfony/ux/pull/2944, but without their drawbacks. The code correctly follow the `es2022` target and does not do anything weird anymore with static properties (needed by controllers). I (Claude) added a plugin to remove the region and JSDoc comments (except if they contain `@deprecated``), since I think we want to keep the code non-minified. --- assets/dist/abstract_map_controller.d.ts | 355 ++++++++++++----------- assets/dist/abstract_map_controller.js | 304 +++++++++---------- 2 files changed, 328 insertions(+), 331 deletions(-) diff --git a/assets/dist/abstract_map_controller.d.ts b/assets/dist/abstract_map_controller.d.ts index 63043bd..e7e3221 100644 --- a/assets/dist/abstract_map_controller.d.ts +++ b/assets/dist/abstract_map_controller.d.ts @@ -1,197 +1,216 @@ -import { Controller } from '@hotwired/stimulus'; - +import { Controller } from "@hotwired/stimulus"; type Point = { - lat: number; - lng: number; + lat: number; + lng: number; }; type Identifier = string; type WithIdentifier> = T & { - '@id': Identifier; + '@id': Identifier; }; type ExtraData = Record; declare const IconTypes: { - readonly Url: "url"; - readonly Svg: "svg"; - readonly UxIcon: "ux-icon"; + readonly Url: "url"; + readonly Svg: "svg"; + readonly UxIcon: "ux-icon"; }; type Icon = { - width: number; - height: number; + width: number; + height: number; } & ({ - type: typeof IconTypes.UxIcon; - name: string; - _generated_html: string; + type: typeof IconTypes.UxIcon; + name: string; + _generated_html: string; } | { - type: typeof IconTypes.Url; - url: string; + type: typeof IconTypes.Url; + url: string; } | { - type: typeof IconTypes.Svg; - html: string; + type: typeof IconTypes.Svg; + html: string; }); type MapDefinition = { - center: Point | null; - zoom: number | null; - minZoom: number | null; - maxZoom: number | null; - options: MapOptions; - bridgeOptions?: BridgeMapOptions; - extra: ExtraData; + center: Point | null; + zoom: number | null; + minZoom: number | null; + maxZoom: number | null; + options: MapOptions; + bridgeOptions?: BridgeMapOptions; + extra: ExtraData; }; type MarkerDefinition = WithIdentifier<{ - position: Point; - title: string | null; - infoWindow?: Omit, 'position'>; - icon?: Icon; - rawOptions?: BridgeMarkerOptions; - bridgeOptions?: BridgeMarkerOptions; - extra: ExtraData; + position: Point; + title: string | null; + infoWindow?: Omit, 'position'>; + icon?: Icon; + rawOptions?: BridgeMarkerOptions; + bridgeOptions?: BridgeMarkerOptions; + extra: ExtraData; }>; type PolygonDefinition = WithIdentifier<{ - infoWindow?: Omit, 'position'>; - points: Array | Array>; - title: string | null; - rawOptions?: BridgePolygonOptions; - bridgeOptions?: BridgePolygonOptions; - extra: ExtraData; + infoWindow?: Omit, 'position'>; + points: Array | Array>; + title: string | null; + rawOptions?: BridgePolygonOptions; + bridgeOptions?: BridgePolygonOptions; + extra: ExtraData; }>; type PolylineDefinition = WithIdentifier<{ - infoWindow?: Omit, 'position'>; - points: Array; - title: string | null; - rawOptions?: BridgePolylineOptions; - bridgeOptions?: BridgePolylineOptions; - extra: ExtraData; + infoWindow?: Omit, 'position'>; + points: Array; + title: string | null; + rawOptions?: BridgePolylineOptions; + bridgeOptions?: BridgePolylineOptions; + extra: ExtraData; }>; type CircleDefinition = WithIdentifier<{ - infoWindow?: Omit, 'position'>; - center: Point; - radius: number; - title: string | null; - rawOptions?: BridgeCircleOptions; - bridgeOptions?: BridgeCircleOptions; - extra: ExtraData; + infoWindow?: Omit, 'position'>; + center: Point; + radius: number; + title: string | null; + rawOptions?: BridgeCircleOptions; + bridgeOptions?: BridgeCircleOptions; + extra: ExtraData; }>; type RectangleDefinition = WithIdentifier<{ - infoWindow?: Omit, 'position'>; - southWest: Point; - northEast: Point; - title: string | null; - rawOptions?: BridgeRectangleOptions; - bridgeOptions?: BridgeRectangleOptions; - extra: ExtraData; + infoWindow?: Omit, 'position'>; + southWest: Point; + northEast: Point; + title: string | null; + rawOptions?: BridgeRectangleOptions; + bridgeOptions?: BridgeRectangleOptions; + extra: ExtraData; }>; type InfoWindowDefinition = { - headerContent: string | null; - content: string | null; - position: Point; - opened: boolean; - autoClose: boolean; - rawOptions?: BridgeInfoWindowOptions; - bridgeOptions?: BridgeInfoWindowOptions; - extra: ExtraData; + headerContent: string | null; + content: string | null; + position: Point; + opened: boolean; + autoClose: boolean; + rawOptions?: BridgeInfoWindowOptions; + bridgeOptions?: BridgeInfoWindowOptions; + extra: ExtraData; }; declare abstract class export_default extends Controller { - static values: { - providerOptions: ObjectConstructor; - center: ObjectConstructor; - zoom: NumberConstructor; - minZoom: NumberConstructor; - maxZoom: NumberConstructor; - fitBoundsToMarkers: BooleanConstructor; - markers: ArrayConstructor; - polygons: ArrayConstructor; - polylines: ArrayConstructor; - circles: ArrayConstructor; - rectangles: ArrayConstructor; - options: ObjectConstructor; - extra: ObjectConstructor; - }; - centerValue: Point | null; - zoomValue: number | null; - minZoomValue: number | null; - maxZoomValue: number | null; - fitBoundsToMarkersValue: boolean; - markersValue: Array>; - polygonsValue: Array>; - polylinesValue: Array>; - circlesValue: Array>; - rectanglesValue: Array>; - optionsValue: MapOptions; - extraValue: Record; - hasCenterValue: boolean; - hasZoomValue: boolean; - hasMinZoomValue: boolean; - hasMaxZoomValue: boolean; - hasFitBoundsToMarkersValue: boolean; - hasMarkersValue: boolean; - hasPolygonsValue: boolean; - hasPolylinesValue: boolean; - hasCirclesValue: boolean; - hasRectanglesValue: boolean; - hasOptionsValue: boolean; - hasExtraValue: boolean; - protected map: BridgeMap; - protected markers: Map; - protected polygons: Map; - protected polylines: Map; - protected circles: Map; - protected rectangles: Map; - protected infoWindows: Array; - private isConnected; - private createMarker; - private createPolygon; - private createPolyline; - private createCircle; - private createRectangle; - protected abstract dispatchEvent(name: string, payload: Record): void; - connect(): void; - createInfoWindow({ definition, element, }: { - definition: Omit, 'position'>; - element: BridgeMarker | BridgePolygon | BridgePolyline | BridgeCircle | BridgeRectangle; - }): BridgeInfoWindow; - abstract centerValueChanged(): void; - abstract zoomValueChanged(): void; - abstract minZoomValueChanged(): void; - abstract maxZoomValueChanged(): void; - markersValueChanged(): void; - polygonsValueChanged(): void; - polylinesValueChanged(): void; - circlesValueChanged(): void; - rectanglesValueChanged(): void; - protected abstract doCreateMap({ definition, }: { - definition: MapDefinition; - }): BridgeMap; - protected abstract doFitBoundsToMarkers(): void; - protected abstract doCreateMarker({ definition, }: { - definition: MarkerDefinition; - }): BridgeMarker; - protected abstract doRemoveMarker(marker: BridgeMarker): void; - protected abstract doCreatePolygon({ definition, }: { - definition: PolygonDefinition; - }): BridgePolygon; - protected abstract doRemovePolygon(polygon: BridgePolygon): void; - protected abstract doCreatePolyline({ definition, }: { - definition: PolylineDefinition; - }): BridgePolyline; - protected abstract doRemovePolyline(polyline: BridgePolyline): void; - protected abstract doCreateCircle({ definition, }: { - definition: CircleDefinition; - }): BridgeCircle; - protected abstract doRemoveCircle(circle: BridgeCircle): void; - protected abstract doCreateRectangle({ definition, }: { - definition: RectangleDefinition; - }): BridgeRectangle; - protected abstract doRemoveRectangle(rectangle: BridgeRectangle): void; - protected abstract doCreateInfoWindow({ definition, element, }: { - definition: Omit, 'position'>; - element: BridgeMarker | BridgePolygon | BridgePolyline | BridgeCircle | BridgeRectangle; - }): BridgeInfoWindow; - protected abstract doCreateIcon({ definition, element }: { - definition: Icon; - element: BridgeMarker; - }): void; - private createDrawingFactory; - private onDrawChanged; + static values: { + providerOptions: ObjectConstructor; + center: ObjectConstructor; + zoom: NumberConstructor; + minZoom: NumberConstructor; + maxZoom: NumberConstructor; + fitBoundsToMarkers: BooleanConstructor; + markers: ArrayConstructor; + polygons: ArrayConstructor; + polylines: ArrayConstructor; + circles: ArrayConstructor; + rectangles: ArrayConstructor; + options: ObjectConstructor; + extra: ObjectConstructor; + }; + centerValue: Point | null; + zoomValue: number | null; + minZoomValue: number | null; + maxZoomValue: number | null; + fitBoundsToMarkersValue: boolean; + markersValue: Array>; + polygonsValue: Array>; + polylinesValue: Array>; + circlesValue: Array>; + rectanglesValue: Array>; + optionsValue: MapOptions; + extraValue: Record; + hasCenterValue: boolean; + hasZoomValue: boolean; + hasMinZoomValue: boolean; + hasMaxZoomValue: boolean; + hasFitBoundsToMarkersValue: boolean; + hasMarkersValue: boolean; + hasPolygonsValue: boolean; + hasPolylinesValue: boolean; + hasCirclesValue: boolean; + hasRectanglesValue: boolean; + hasOptionsValue: boolean; + hasExtraValue: boolean; + protected map: BridgeMap; + protected markers: Map; + protected polygons: Map; + protected polylines: Map; + protected circles: Map; + protected rectangles: Map; + protected infoWindows: Array; + private isConnected; + private createMarker; + private createPolygon; + private createPolyline; + private createCircle; + private createRectangle; + protected abstract dispatchEvent(name: string, payload: Record): void; + connect(): void; + createInfoWindow({ + definition, + element + }: { + definition: Omit, 'position'>; + element: BridgeMarker | BridgePolygon | BridgePolyline | BridgeCircle | BridgeRectangle; + }): BridgeInfoWindow; + abstract centerValueChanged(): void; + abstract zoomValueChanged(): void; + abstract minZoomValueChanged(): void; + abstract maxZoomValueChanged(): void; + markersValueChanged(): void; + polygonsValueChanged(): void; + polylinesValueChanged(): void; + circlesValueChanged(): void; + rectanglesValueChanged(): void; + protected abstract doCreateMap({ + definition + }: { + definition: MapDefinition; + }): BridgeMap; + protected abstract doFitBoundsToMarkers(): void; + protected abstract doCreateMarker({ + definition + }: { + definition: MarkerDefinition; + }): BridgeMarker; + protected abstract doRemoveMarker(marker: BridgeMarker): void; + protected abstract doCreatePolygon({ + definition + }: { + definition: PolygonDefinition; + }): BridgePolygon; + protected abstract doRemovePolygon(polygon: BridgePolygon): void; + protected abstract doCreatePolyline({ + definition + }: { + definition: PolylineDefinition; + }): BridgePolyline; + protected abstract doRemovePolyline(polyline: BridgePolyline): void; + protected abstract doCreateCircle({ + definition + }: { + definition: CircleDefinition; + }): BridgeCircle; + protected abstract doRemoveCircle(circle: BridgeCircle): void; + protected abstract doCreateRectangle({ + definition + }: { + definition: RectangleDefinition; + }): BridgeRectangle; + protected abstract doRemoveRectangle(rectangle: BridgeRectangle): void; + protected abstract doCreateInfoWindow({ + definition, + element + }: { + definition: Omit, 'position'>; + element: BridgeMarker | BridgePolygon | BridgePolyline | BridgeCircle | BridgeRectangle; + }): BridgeInfoWindow; + protected abstract doCreateIcon({ + definition, + element + }: { + definition: Icon; + element: BridgeMarker; + }): void; + private createDrawingFactory; + private onDrawChanged; } - -export { type CircleDefinition, type Icon, IconTypes, type Identifier, type InfoWindowDefinition, type MapDefinition, type MarkerDefinition, type Point, type PolygonDefinition, type PolylineDefinition, type RectangleDefinition, type WithIdentifier, export_default as default }; +export { CircleDefinition, Icon, IconTypes, Identifier, InfoWindowDefinition, MapDefinition, MarkerDefinition, Point, PolygonDefinition, PolylineDefinition, RectangleDefinition, WithIdentifier, export_default as default }; \ No newline at end of file diff --git a/assets/dist/abstract_map_controller.js b/assets/dist/abstract_map_controller.js index 2bb9b5b..5351ad2 100644 --- a/assets/dist/abstract_map_controller.js +++ b/assets/dist/abstract_map_controller.js @@ -1,167 +1,145 @@ -// src/abstract_map_controller.ts import { Controller } from "@hotwired/stimulus"; -var IconTypes = { - Url: "url", - Svg: "svg", - UxIcon: "ux-icon" +const IconTypes = { + Url: "url", + Svg: "svg", + UxIcon: "ux-icon" }; -var abstract_map_controller_default = class extends Controller { - constructor() { - super(...arguments); - this.markers = /* @__PURE__ */ new Map(); - this.polygons = /* @__PURE__ */ new Map(); - this.polylines = /* @__PURE__ */ new Map(); - this.circles = /* @__PURE__ */ new Map(); - this.rectangles = /* @__PURE__ */ new Map(); - this.infoWindows = []; - this.isConnected = false; - } - connect() { - const extra = this.hasExtraValue ? this.extraValue : {}; - const mapDefinition = { - center: this.hasCenterValue ? this.centerValue : null, - zoom: this.hasZoomValue ? this.zoomValue : null, - minZoom: this.hasMinZoomValue ? this.minZoomValue : null, - maxZoom: this.hasMaxZoomValue ? this.maxZoomValue : null, - options: this.optionsValue, - extra - }; - this.dispatchEvent("pre-connect", mapDefinition); - this.createMarker = this.createDrawingFactory("marker", this.markers, this.doCreateMarker.bind(this)); - this.createPolygon = this.createDrawingFactory("polygon", this.polygons, this.doCreatePolygon.bind(this)); - this.createPolyline = this.createDrawingFactory("polyline", this.polylines, this.doCreatePolyline.bind(this)); - this.createCircle = this.createDrawingFactory("circle", this.circles, this.doCreateCircle.bind(this)); - this.createRectangle = this.createDrawingFactory( - "rectangle", - this.rectangles, - this.doCreateRectangle.bind(this) - ); - this.map = this.doCreateMap({ definition: mapDefinition }); - this.markersValue.forEach((definition) => { - this.createMarker({ definition }); - }); - this.polygonsValue.forEach((definition) => { - this.createPolygon({ definition }); - }); - this.polylinesValue.forEach((definition) => { - this.createPolyline({ definition }); - }); - this.circlesValue.forEach((definition) => { - this.createCircle({ definition }); - }); - this.rectanglesValue.forEach((definition) => { - this.createRectangle({ definition }); - }); - if (this.fitBoundsToMarkersValue) { - this.doFitBoundsToMarkers(); - } - this.dispatchEvent("connect", { - map: this.map, - markers: [...this.markers.values()], - polygons: [...this.polygons.values()], - polylines: [...this.polylines.values()], - circles: [...this.circles.values()], - rectangles: [...this.rectangles.values()], - infoWindows: this.infoWindows, - extra - }); - this.isConnected = true; - } - //region Public API - createInfoWindow({ - definition, - element - }) { - this.dispatchEvent("info-window:before-create", { definition, element }); - const infoWindow = this.doCreateInfoWindow({ definition, element }); - this.dispatchEvent("info-window:after-create", { infoWindow, definition, element }); - this.infoWindows.push(infoWindow); - return infoWindow; - } - markersValueChanged() { - if (!this.isConnected) { - return; - } - this.onDrawChanged(this.markers, this.markersValue, this.createMarker, this.doRemoveMarker); - if (this.fitBoundsToMarkersValue) { - this.doFitBoundsToMarkers(); - } - } - polygonsValueChanged() { - if (!this.isConnected) { - return; - } - this.onDrawChanged(this.polygons, this.polygonsValue, this.createPolygon, this.doRemovePolygon); - } - polylinesValueChanged() { - if (!this.isConnected) { - return; - } - this.onDrawChanged(this.polylines, this.polylinesValue, this.createPolyline, this.doRemovePolyline); - } - circlesValueChanged() { - if (!this.isConnected) { - return; - } - this.onDrawChanged(this.circles, this.circlesValue, this.createCircle, this.doRemoveCircle); - } - rectanglesValueChanged() { - if (!this.isConnected) { - return; - } - this.onDrawChanged(this.rectangles, this.rectanglesValue, this.createRectangle, this.doRemoveRectangle); - } - createDrawingFactory(type, draws, factory) { - const eventBefore = `${type}:before-create`; - const eventAfter = `${type}:after-create`; - return ({ definition }) => { - this.dispatchEvent(eventBefore, { definition }); - if (typeof definition.rawOptions !== "undefined") { - console.warn( - `[Symfony UX Map] The event "${eventBefore}" added a deprecated "rawOptions" property to the definition, it will be removed in a next major version, replace it with "bridgeOptions" instead.`, - definition - ); - } - const drawing = factory({ definition }); - this.dispatchEvent(eventAfter, { [type]: drawing, definition }); - draws.set(definition["@id"], drawing); - return drawing; - }; - } - onDrawChanged(draws, newDrawDefinitions, factory, remover) { - const idsToRemove = new Set(draws.keys()); - newDrawDefinitions.forEach((definition) => { - idsToRemove.delete(definition["@id"]); - }); - idsToRemove.forEach((id) => { - const draw = draws.get(id); - remover(draw); - draws.delete(id); - }); - newDrawDefinitions.forEach((definition) => { - if (!draws.has(definition["@id"])) { - factory({ definition }); - } - }); - } - //endregion +var _Class = class extends Controller { + constructor(..._args) { + super(..._args); + this.markers = /* @__PURE__ */ new Map(); + this.polygons = /* @__PURE__ */ new Map(); + this.polylines = /* @__PURE__ */ new Map(); + this.circles = /* @__PURE__ */ new Map(); + this.rectangles = /* @__PURE__ */ new Map(); + this.infoWindows = []; + this.isConnected = false; + } + connect() { + const extra = this.hasExtraValue ? this.extraValue : {}; + const mapDefinition = { + center: this.hasCenterValue ? this.centerValue : null, + zoom: this.hasZoomValue ? this.zoomValue : null, + minZoom: this.hasMinZoomValue ? this.minZoomValue : null, + maxZoom: this.hasMaxZoomValue ? this.maxZoomValue : null, + options: this.optionsValue, + extra + }; + this.dispatchEvent("pre-connect", mapDefinition); + this.createMarker = this.createDrawingFactory("marker", this.markers, this.doCreateMarker.bind(this)); + this.createPolygon = this.createDrawingFactory("polygon", this.polygons, this.doCreatePolygon.bind(this)); + this.createPolyline = this.createDrawingFactory("polyline", this.polylines, this.doCreatePolyline.bind(this)); + this.createCircle = this.createDrawingFactory("circle", this.circles, this.doCreateCircle.bind(this)); + this.createRectangle = this.createDrawingFactory("rectangle", this.rectangles, this.doCreateRectangle.bind(this)); + this.map = this.doCreateMap({ definition: mapDefinition }); + this.markersValue.forEach((definition) => { + this.createMarker({ definition }); + }); + this.polygonsValue.forEach((definition) => { + this.createPolygon({ definition }); + }); + this.polylinesValue.forEach((definition) => { + this.createPolyline({ definition }); + }); + this.circlesValue.forEach((definition) => { + this.createCircle({ definition }); + }); + this.rectanglesValue.forEach((definition) => { + this.createRectangle({ definition }); + }); + if (this.fitBoundsToMarkersValue) this.doFitBoundsToMarkers(); + this.dispatchEvent("connect", { + map: this.map, + markers: [...this.markers.values()], + polygons: [...this.polygons.values()], + polylines: [...this.polylines.values()], + circles: [...this.circles.values()], + rectangles: [...this.rectangles.values()], + infoWindows: this.infoWindows, + extra + }); + this.isConnected = true; + } + createInfoWindow({ definition, element }) { + this.dispatchEvent("info-window:before-create", { + definition, + element + }); + const infoWindow = this.doCreateInfoWindow({ + definition, + element + }); + this.dispatchEvent("info-window:after-create", { + infoWindow, + definition, + element + }); + this.infoWindows.push(infoWindow); + return infoWindow; + } + markersValueChanged() { + if (!this.isConnected) return; + this.onDrawChanged(this.markers, this.markersValue, this.createMarker, this.doRemoveMarker); + if (this.fitBoundsToMarkersValue) this.doFitBoundsToMarkers(); + } + polygonsValueChanged() { + if (!this.isConnected) return; + this.onDrawChanged(this.polygons, this.polygonsValue, this.createPolygon, this.doRemovePolygon); + } + polylinesValueChanged() { + if (!this.isConnected) return; + this.onDrawChanged(this.polylines, this.polylinesValue, this.createPolyline, this.doRemovePolyline); + } + circlesValueChanged() { + if (!this.isConnected) return; + this.onDrawChanged(this.circles, this.circlesValue, this.createCircle, this.doRemoveCircle); + } + rectanglesValueChanged() { + if (!this.isConnected) return; + this.onDrawChanged(this.rectangles, this.rectanglesValue, this.createRectangle, this.doRemoveRectangle); + } + createDrawingFactory(type, draws, factory) { + const eventBefore = `${type}:before-create`; + const eventAfter = `${type}:after-create`; + return ({ definition }) => { + this.dispatchEvent(eventBefore, { definition }); + if (typeof definition.rawOptions !== "undefined") console.warn(`[Symfony UX Map] The event "${eventBefore}" added a deprecated "rawOptions" property to the definition, it will be removed in a next major version, replace it with "bridgeOptions" instead.`, definition); + const drawing = factory({ definition }); + this.dispatchEvent(eventAfter, { + [type]: drawing, + definition + }); + draws.set(definition["@id"], drawing); + return drawing; + }; + } + onDrawChanged(draws, newDrawDefinitions, factory, remover) { + const idsToRemove = new Set(draws.keys()); + newDrawDefinitions.forEach((definition) => { + idsToRemove.delete(definition["@id"]); + }); + idsToRemove.forEach((id) => { + remover(draws.get(id)); + draws.delete(id); + }); + newDrawDefinitions.forEach((definition) => { + if (!draws.has(definition["@id"])) factory({ definition }); + }); + } }; -abstract_map_controller_default.values = { - providerOptions: Object, - center: Object, - zoom: Number, - minZoom: Number, - maxZoom: Number, - fitBoundsToMarkers: Boolean, - markers: Array, - polygons: Array, - polylines: Array, - circles: Array, - rectangles: Array, - options: Object, - extra: Object -}; -export { - IconTypes, - abstract_map_controller_default as default +_Class.values = { + providerOptions: Object, + center: Object, + zoom: Number, + minZoom: Number, + maxZoom: Number, + fitBoundsToMarkers: Boolean, + markers: Array, + polygons: Array, + polylines: Array, + circles: Array, + rectangles: Array, + options: Object, + extra: Object }; +export { IconTypes, _Class as default }; \ No newline at end of file