diff --git a/packages/saved-views-react/src/SavedViewsClient/ITwinSavedViewsClient.ts b/packages/saved-views-react/src/SavedViewsClient/ITwinSavedViewsClient.ts index ddf8f5de..8a6dcb78 100644 --- a/packages/saved-views-react/src/SavedViewsClient/ITwinSavedViewsClient.ts +++ b/packages/saved-views-react/src/SavedViewsClient/ITwinSavedViewsClient.ts @@ -48,7 +48,7 @@ export class ITwinSavedViewsClient implements SavedViewsClient { public async getSingularSavedView(args: GetSingularSavedViewParams): Promise { const response = await this.client.getSavedViewRepresentation({ savedViewId: args.savedViewId, - signal: args.signal + signal: args.signal, }); return response.savedView; } diff --git a/packages/saved-views-react/src/SavedViewsWidget/SavedViewTile/SavedViewTile.tsx b/packages/saved-views-react/src/SavedViewsWidget/SavedViewTile/SavedViewTile.tsx index 981abcd7..0fd9de3f 100644 --- a/packages/saved-views-react/src/SavedViewsWidget/SavedViewTile/SavedViewTile.tsx +++ b/packages/saved-views-react/src/SavedViewsWidget/SavedViewTile/SavedViewTile.tsx @@ -186,11 +186,8 @@ function renderSavedView(onRenderSelectedView: ((selectedView: string) => void) if (onRenderSelectedView) { return () => onRenderSelectedView(savedViewId) } else { - // alert("No view renderer defined"); - console.log("No view renderer defined"); return () => {}; } - } function isOverflowing(element: HTMLElement): boolean { diff --git a/packages/saved-views-react/src/api/utilities/translation/SavedViewTranslation.ts b/packages/saved-views-react/src/api/utilities/translation/SavedViewTranslation.ts index bf2baddc..68299c98 100644 --- a/packages/saved-views-react/src/api/utilities/translation/SavedViewTranslation.ts +++ b/packages/saved-views-react/src/api/utilities/translation/SavedViewTranslation.ts @@ -1,25 +1,25 @@ // Copyright (c) Bentley Systems, Incorporated. All rights reserved. -import { IModelReadRpcInterface, ViewQueryParams, ViewStateProps } from '@itwin/core-common'; +import { IModelReadRpcInterface, ViewQueryParams, ViewStateProps } from "@itwin/core-common"; import { - DrawingViewState, IModelConnection, SheetViewState, SpatialViewState, ViewState -} from '@itwin/core-frontend'; + DrawingViewState, IModelConnection, SheetViewState, SpatialViewState, ViewState, +} from "@itwin/core-frontend"; import { Extension, SavedViewWithDataRepresentation, ViewData, ViewDataItwin3d, ViewDataITwinDrawing, - ViewDataITwinSheet -} from '@itwin/saved-views-client'; + ViewDataITwinSheet, +} from "@itwin/saved-views-client"; -import { ViewTypes } from '../../../SavedViewTypes.js'; +import { ViewTypes } from "../../../SavedViewTypes.js"; import { - isDrawingSavedView, isSheetSavedView, isSpatialSavedView -} from '../../clients/ISavedViewsClient.js'; + isDrawingSavedView, isSheetSavedView, isSpatialSavedView, +} from "../../clients/ISavedViewsClient.js"; import { SavedView as LegacySavedView, SavedView2d as LegacySavedView2d, - SavedViewBase as LegacySavedViewBase -} from '../SavedViewTypes.js'; + SavedViewBase as LegacySavedViewBase, +} from "../SavedViewTypes.js"; import { cleanLegacyViewModelSelectorPropsModels, savedViewITwin3dToLegacy3dSavedView, - savedViewItwinDrawingToLegacyDrawingView, savedViewItwinSheetToLegacySheetSavedView -} from './viewExtractorSavedViewToLegacySavedView.js'; + savedViewItwinDrawingToLegacyDrawingView, savedViewItwinSheetToLegacySheetSavedView, +} from "./viewExtractorSavedViewToLegacySavedView.js"; /* * Converts a Saved View into an iTwin.js-style ViewState @@ -73,7 +73,7 @@ async function translateSavedViewToLegacySavedView( const actual = savedViewITwin3dToLegacy3dSavedView( savedView, - iModelViewData as SpatialViewState + iModelViewData as SpatialViewState, ); legacySavedView = actual; } else if (isSavedViewItwinDrawing(savedViewData)) { @@ -83,7 +83,7 @@ async function translateSavedViewToLegacySavedView( ); const actual = savedViewItwinDrawingToLegacyDrawingView( savedView, - iModelViewData as DrawingViewState + iModelViewData as DrawingViewState, ); legacySavedView = actual; } else if (isSavedViewItwinSheet(savedViewData)) { @@ -93,12 +93,12 @@ async function translateSavedViewToLegacySavedView( ); const actual = savedViewItwinSheetToLegacySheetSavedView( savedView, - iModelViewData as SheetViewState + iModelViewData as SheetViewState, ); legacySavedView = actual; } else { throw new Error( - "Could not translate itwin-saved-views API response to a SavedViewBaseSetting" + "Could not translate itwin-saved-views API response to a SavedViewBaseSetting", ); } @@ -130,9 +130,9 @@ async function fetchIModelViewData(viewClassName: ViewTypes, iModelConnection: I // } const viewId = await getDefaultViewIdFromClassName( iModelConnection, - viewClassName + viewClassName, ); - let seedViewState = await iModelConnection.views.load(viewId); + const seedViewState = await iModelConnection.views.load(viewId); // this._seedViewStates.set(viewClassName, seedViewState); return seedViewState; } @@ -141,7 +141,7 @@ async function fetchIModelViewData(viewClassName: ViewTypes, iModelConnection: I // method shared some implementation with getDefaultViewId async function getDefaultViewIdFromClassName( iModelConnection: IModelConnection, - savedViewType: ViewTypes + savedViewType: ViewTypes, ) { let viewFullName = undefined; switch (savedViewType) { @@ -157,7 +157,6 @@ async function getDefaultViewIdFromClassName( default: throw new Error("Unrecognized View Type"); } - // eslint-disable-next-line deprecation/deprecation const viewId = await iModelConnection.views.queryDefaultViewId(); const params: ViewQueryParams = {}; params.from = viewFullName; @@ -167,7 +166,7 @@ async function getDefaultViewIdFromClassName( const viewProps = await IModelReadRpcInterface.getClient().queryElementProps( iModelConnection.getRpcProps(), - params + params, ); if (viewProps.length === 0) { // Return the first view we can find diff --git a/packages/saved-views-react/src/api/utilities/translation/clipVectorsExtractor.ts b/packages/saved-views-react/src/api/utilities/translation/clipVectorsExtractor.ts index 0632dd6a..2d7c1b30 100644 --- a/packages/saved-views-react/src/api/utilities/translation/clipVectorsExtractor.ts +++ b/packages/saved-views-react/src/api/utilities/translation/clipVectorsExtractor.ts @@ -17,7 +17,7 @@ const isPoint = (val: unknown): val is [number, number, number] => val.every((num: unknown) => typeof num === "number"); const isTransformRow = ( - value: unknown + value: unknown, ): value is [number, number, number, number] => Array.isArray(value) && value.length === 4 && @@ -33,7 +33,7 @@ const clipPrimitiveShapeMappings: ExtractionFunc[] = [ extractBoolean("mask"), extractBoolean("invisible"), ], - "shape" + "shape", ), ]; @@ -47,7 +47,7 @@ const clipPlaneMappings: ExtractionFunc[] = [ const clipPrimitivePlaneMappings: ExtractionFunc[] = [ extractObject( [extractArray2d(clipPlaneMappings, "clips"), extractBoolean("invisible")], - "planes" + "planes", ), ]; @@ -64,7 +64,7 @@ const clipVectorMappings: ExtractionFunc[] = [ }, ], "clip", - "clipVectors" + "clipVectors", ), ]; @@ -78,6 +78,7 @@ export const extractClipVectors = (input: object) => { return undefined; } + // eslint-disable-next-line @typescript-eslint/no-explicit-any const output: any = {}; applyExtraction(viewDetails, output, clipVectorMappings); return output.clipVectors; diff --git a/packages/saved-views-react/src/api/utilities/translation/displayStyleExtractor.ts b/packages/saved-views-react/src/api/utilities/translation/displayStyleExtractor.ts index f482e06d..0c21d64d 100644 --- a/packages/saved-views-react/src/api/utilities/translation/displayStyleExtractor.ts +++ b/packages/saved-views-react/src/api/utilities/translation/displayStyleExtractor.ts @@ -94,7 +94,7 @@ const backgroundMapMappings: ExtractionFunc[] = [ extractNumber("heightOrigin"), extractNumber("heightOriginMode"), ], - "terrainSettings" + "terrainSettings", ), extractNumber("globeMode"), extractBoolean("nonLocatable"), @@ -150,7 +150,7 @@ const contextRealityModelsMappings: ExtractionFunc[] = [ extractString("iTwinId"), ], "rdSourceKey", - "realityDataSourceKey" + "realityDataSourceKey", ), extractString("tilesetUrl"), extractString("realityDataId"), @@ -166,12 +166,12 @@ const contextRealityModelsMappings: ExtractionFunc[] = [ extractNumber("outside"), extractBoolean("isVolumeClassifier"), ], - "flags" + "flags", ), extractString("name"), extractBoolean("isActive"), ], - "classifiers" + "classifiers", ), extractObject(planarClipMaskMappings, "planarClipMask"), extractObject(featureAppearanceMappings, "appearanceOverrides"), @@ -186,7 +186,7 @@ const contextRealityModelsLegacyMappings: ExtractionFunc[] = [ extractString("iTwinId"), ], "rdSourceKey", - "realityDataSourceKey" + "realityDataSourceKey", ), extractString("tilesetUrl"), extractString("realityDataId"), @@ -202,12 +202,12 @@ const contextRealityModelsLegacyMappings: ExtractionFunc[] = [ extractNumber("outside"), extractBoolean("isVolumeClassifier"), ], - "flags" + "flags", ), extractString("name"), extractBoolean("isActive"), ], - "classifiers" + "classifiers", ), extractObject(planarClipMaskMappings, "planarClipMask"), extractObject(featureAppearanceLegacyMappings, "appearanceOverrides"), @@ -258,7 +258,7 @@ const mapImageryMapping: ExtractionFunc[] = [ mappings: baseMapLayerPropsMapping, }, ], - "backgroundBase" + "backgroundBase", ), extractArrayConditionally( [ @@ -271,7 +271,7 @@ const mapImageryMapping: ExtractionFunc[] = [ mappings: imageMapLayerPropsMapping, }, ], - "backgroundLayers" + "backgroundLayers", ), extractArrayConditionally( [ @@ -284,7 +284,7 @@ const mapImageryMapping: ExtractionFunc[] = [ mappings: imageMapLayerPropsMapping, }, ], - "overlayLayers" + "overlayLayers", ), ]; @@ -388,7 +388,7 @@ const displayStylesMapping: ExtractionFunc[] = [ extractArray( displayStyleSubCategoryMappings, "subCategoryOverrides", - "subCategoryOvr" + "subCategoryOvr", ), extractObject(backgroundMapMappings, "backgroundMap"), extractArray(contextRealityModelsMappings, "contextRealityModels"), @@ -397,13 +397,13 @@ const displayStylesMapping: ExtractionFunc[] = [ extractArray( displayStyleModelAppearanceMappings, "modelOverrides", - "modelOvr" + "modelOvr", ), extractObject(clipStyleMappings, "clipStyle"), extractArray( displayStylePlanarClipMaskMappings, "planarClipOverrides", - "planarClipOvr" + "planarClipOvr", ), ]; @@ -417,7 +417,7 @@ const displayStylesLegacyMapping: ExtractionFunc[] = [ extractArray( displayStyleSubCategoryMappings, "subCategoryOvr", - "subCategoryOverrides" + "subCategoryOverrides", ), extractObject(backgroundMapMappings, "backgroundMap"), extractArray(contextRealityModelsLegacyMappings, "contextRealityModels"), @@ -426,13 +426,13 @@ const displayStylesLegacyMapping: ExtractionFunc[] = [ extractArray( displayStyleModelAppearanceLegacyMappings, "modelOvr", - "modelOverrides" + "modelOverrides", ), extractObject(clipStyleLegacyMappings, "clipStyle"), extractArray( displayStylePlanarClipMaskMappings, "planarClipOvr", - "planarClipOverrides" + "planarClipOverrides", ), ]; @@ -444,7 +444,7 @@ const environmentMappings: ExtractionFunc[] = [ extractColor("aboveColor"), extractColor("belowColor"), ], - "ground" + "ground", ), extractObject( [ @@ -469,13 +469,13 @@ const environmentMappings: ExtractionFunc[] = [ extractString("right"), extractString("left"), ], - "textures" + "textures", ), ], - "image" + "image", ), ], - "sky" + "sky", ), ]; @@ -487,7 +487,7 @@ const environmentLegacyMappings: ExtractionFunc[] = [ extractColorLegacy("aboveColor"), extractColorLegacy("belowColor"), ], - "ground" + "ground", ), extractObject( [ @@ -512,13 +512,13 @@ const environmentLegacyMappings: ExtractionFunc[] = [ extractString("right"), extractString("left"), ], - "textures" + "textures", ), ], - "image" + "image", ), ], - "sky" + "sky", ), ]; @@ -546,7 +546,7 @@ const lightsMappings: ExtractionFunc[] = [ extractBoolean("alwaysEnabled"), extractNumber("timePoint"), ], - "solar" + "solar", ), extractObject( [ @@ -554,14 +554,14 @@ const lightsMappings: ExtractionFunc[] = [ extractColor("lowerColor"), extractNumber("intensity"), ], - "hemisphere" + "hemisphere", ), extractObject([extractColor("color"), extractNumber("intensity")], "ambient"), extractNumber("specularIntensity"), extractNumber("numCels"), extractObject( [extractNumber("intensity"), extractBoolean("invert")], - "fresnel" + "fresnel", ), ]; @@ -581,7 +581,7 @@ const displayStyle3dMapping: ExtractionFunc[] = [ extractPlainTypedMap( planProjectionSettingsMappings, simpleTypeOf("string"), - "planProjections" + "planProjections", ), ]; @@ -594,7 +594,7 @@ const displayStyle3dLegacyMapping: ExtractionFunc[] = [ extractPlainTypedMap( planProjectionSettingsMappings, simpleTypeOf("string"), - "planProjections" + "planProjections", ), ]; @@ -606,6 +606,7 @@ const displayStyle3dLegacyMapping: ExtractionFunc[] = [ */ export const extractDisplayStyle = (data: object, viewState?: ViewState) => { let styles; + // eslint-disable-next-line @typescript-eslint/no-explicit-any const output: any = {}; if ("displayStyle" in data) { styles = (data as ViewITwin2d).displayStyle; @@ -631,6 +632,7 @@ export const extractDisplayStyle = (data: object, viewState?: ViewState) => { */ export const extractDisplayStyle3d = (data: object) => { let styles; + // eslint-disable-next-line @typescript-eslint/no-explicit-any const output: any = {}; if ("displayStyle" in data) { styles = (data as ViewITwin3d).displayStyle; @@ -649,7 +651,8 @@ export const extractDisplayStyle3d = (data: object) => { function appendAcsAndGridViewFlagsToOutput( drawingViewState: ViewState, - output: any + // eslint-disable-next-line @typescript-eslint/no-explicit-any + output: any, ) { output.viewflags.acs = false; output.viewflags.grid = true; diff --git a/packages/saved-views-react/src/api/utilities/translation/extensionExtractor.ts b/packages/saved-views-react/src/api/utilities/translation/extensionExtractor.ts index c9462057..4cc08177 100644 --- a/packages/saved-views-react/src/api/utilities/translation/extensionExtractor.ts +++ b/packages/saved-views-react/src/api/utilities/translation/extensionExtractor.ts @@ -60,7 +60,7 @@ const perModelCategoryVisibilityMapping: ExtractionFunc[] = [ * @param extensionData */ export const extractEmphasizeElements = ( - extensionData: string + extensionData: string, ): EmphasizeElementsProps | undefined => { const dataObj = JSON.parse(extensionData); if (dataObj === undefined || dataObj.emphasizeElementsProps === undefined) { @@ -71,7 +71,7 @@ export const extractEmphasizeElements = ( applyExtraction( dataObj.emphasizeElementsProps, output, - emphasizeElementsMapping + emphasizeElementsMapping, ); return output; }; @@ -81,7 +81,7 @@ export const extractEmphasizeElements = ( * @param extensionData */ export const extractPerModelCategoryVisibility = ( - extensionData: string + extensionData: string, ): PerModelCategoryVisibilityProps[] => { const dataObjArray = JSON.parse(extensionData); if ( @@ -93,6 +93,7 @@ export const extractPerModelCategoryVisibility = ( const outputArray: PerModelCategoryVisibilityProps[] = []; for (const dataObj of dataObjArray.perModelCategoryVisibilityProps) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any const output: any = {}; applyExtraction(dataObj, output, perModelCategoryVisibilityMapping); outputArray.push(output); diff --git a/packages/saved-views-react/src/api/utilities/translation/extractionUtilities.ts b/packages/saved-views-react/src/api/utilities/translation/extractionUtilities.ts index 06fb3135..fdb536b2 100644 --- a/packages/saved-views-react/src/api/utilities/translation/extractionUtilities.ts +++ b/packages/saved-views-react/src/api/utilities/translation/extractionUtilities.ts @@ -72,7 +72,7 @@ export const isAnyColorFormat = (value: unknown) => // BB GG RR are the color bits (BB =blue GG= green RR= red) // something that if fully one color would be FF or 1111 1111 const mapColorsToBitShiftedEquivalent = ( - color: RgbatColorProps + color: RgbatColorProps, ): RgbatColorProps => { const colorCodeRed = color.red; //0x 00 00 00 RR Binary 0000 0000 0000 0000 0000 0000 RRRR RRRR const colorCodeGreen = color.green << 8; //0x 00 00 GG 00 Binary 0000 0000 0000 0000 GGGG GGGG 0000 0000 @@ -105,6 +105,7 @@ const transformSchemaColor = (value: RgbatColorProps) => { colorsBitShifted.red | colorsBitShifted.green | colorsBitShifted.blue | + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion color.transparency! ); }; @@ -239,8 +240,9 @@ export const createExtractionFunc = ( from: string, to: string, typeCheck?: (value: unknown) => boolean, - transform?: (value: unknown) => unknown + transform?: (value: unknown) => unknown, ) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any return (input: any, output: any) => { if (input[from] !== undefined && (!typeCheck || typeCheck(input[from]))) { output[to] = transform ? transform(input[from]) : input[from]; @@ -268,7 +270,7 @@ export type ExtractionFuncCreator = ( */ export const extractNumber = ( from: string, - to?: string + to?: string, ): ExtractionFunc => { return createExtractionFunc(from, to ?? from, simpleTypeOf("number")); }; @@ -282,7 +284,7 @@ export const extractNumber = ( */ export const extractBoolean = ( from: string, - to?: string + to?: string, ): ExtractionFunc => { return createExtractionFunc(from, to ?? from, simpleTypeOf("boolean")); }; @@ -295,12 +297,12 @@ export const extractBoolean = ( */ export const extractNumberOrBool = ( from: string, - to?: string + to?: string, ): ExtractionFunc => { return createExtractionFunc( from, to ?? from, - (value) => typeof value === "number" || typeof value === "boolean" + (value) => typeof value === "number" || typeof value === "boolean", ); }; @@ -313,7 +315,7 @@ export const extractNumberOrBool = ( */ export const extractString = ( from: string, - to?: string + to?: string, ): ExtractionFunc => { return createExtractionFunc(from, to ?? from, simpleTypeOf("string")); }; @@ -326,12 +328,12 @@ export const extractString = ( */ export const extractStringOrNumber = ( from: string, - to?: string + to?: string, ): ExtractionFunc => { return createExtractionFunc( from, to ?? from, - (value: unknown) => typeof value === "number" || typeof value === "string" + (value: unknown) => typeof value === "number" || typeof value === "string", ); }; @@ -344,7 +346,7 @@ export const extractStringOrNumber = ( */ export const extractStringOrArray = ( from: string, - to?: string + to?: string, ): ExtractionFunc => { return createExtractionFunc( from, @@ -352,7 +354,7 @@ export const extractStringOrArray = ( (value: unknown) => typeof value === "string" || (Array.isArray(value) && - value.every((inner: unknown) => typeof inner === "string")) + value.every((inner: unknown) => typeof inner === "string")), ); }; @@ -364,7 +366,7 @@ export const extractStringOrArray = ( */ export const extractStringOrNumberArray = ( from: string, - to?: string + to?: string, ): ExtractionFunc => { return createExtractionFunc( from, @@ -372,8 +374,8 @@ export const extractStringOrNumberArray = ( (value: unknown) => Array.isArray(value) && value.every( - (val: unknown) => typeof val === "number" || typeof val === "string" - ) + (val: unknown) => typeof val === "number" || typeof val === "string", + ), ); }; @@ -388,13 +390,13 @@ export const extractStringOrNumberArray = ( export const extractSimpleArray = ( typeCheck: (value: unknown) => boolean, from: string, - to?: string + to?: string, ): ExtractionFunc => { return createExtractionFunc( from, to ?? from, (value: unknown) => - Array.isArray(value) && value.every((val: unknown) => typeCheck(val)) + Array.isArray(value) && value.every((val: unknown) => typeCheck(val)), ); }; @@ -413,13 +415,13 @@ export const extractSimpleArray = ( */ export const extractColor = ( from: string, - to?: string + to?: string, ): ExtractionFunc => { return createExtractionFunc( from, to ?? from, isAnyColorFormat, - transformColor + transformColor, ); }; @@ -438,13 +440,13 @@ export const extractColor = ( */ export const extractColorLegacy = ( from: string, - to?: string + to?: string, ): ExtractionFunc => { return createExtractionFunc( from, to ?? from, isAnyColorFormat, - transformColorLegacy + transformColorLegacy, ); }; @@ -457,7 +459,7 @@ export const extractColorLegacy = ( */ export const extractRGB = ( from: string, - to?: string + to?: string, ): ExtractionFunc => { return createExtractionFunc(from, to ?? from, isAnyColorFormat, transformRGB); }; @@ -472,14 +474,15 @@ export const extractRGB = ( export const extractObject = ( extractionFuncs: ExtractionFunc[], from: string, - to?: string + to?: string, ): ExtractionFunc => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any return (input: any, output: any) => { const adjustedTo = to ?? from; if (input[from] !== undefined) { output[adjustedTo] = {}; extractionFuncs.forEach((func: ExtractionFunc) => - func(input[from], output[adjustedTo]) + func(input[from], output[adjustedTo]), ); } }; @@ -505,8 +508,9 @@ export interface ConditionalExtractParams { * @param discriminator String to check for an accessor or function that determines whether or not a value is proper */ const objectMatchesDiscriminator = ( + // eslint-disable-next-line @typescript-eslint/no-explicit-any value: any, - discriminator: string | ((value: unknown) => boolean) + discriminator: string | ((value: unknown) => boolean), ) => { if (typeof discriminator === "string") { return value[discriminator] !== undefined; @@ -526,8 +530,9 @@ const objectMatchesDiscriminator = ( export const extractConditionally = ( params: ConditionalExtractParams[], from: string, - to?: string + to?: string, ): ExtractionFunc => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any return (input: any, output: any) => { const adjustedTo = to ?? from; if (input[from] !== undefined) { @@ -539,7 +544,7 @@ export const extractConditionally = ( if (Array.isArray(param.mappings)) { // Apply each extraction func to the inner object param.mappings.forEach((func: ExtractionFunc) => - func(input[from], output[adjustedTo]) + func(input[from], output[adjustedTo]), ); } else { // Apply the extraction func to the object directly @@ -559,8 +564,9 @@ export const extractConditionally = ( export const extractArray = ( extractionFunc: ExtractionFunc[], from: string, - to?: string + to?: string, ) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any return (input: any, output: any) => { const adjustedTo = to ?? from; if (input[from] !== undefined && Array.isArray(input[from])) { @@ -568,7 +574,7 @@ export const extractArray = ( (input[from] as unknown[]).forEach((_: unknown, index: number) => { output[adjustedTo].push({}); extractionFunc.forEach((func: ExtractionFunc) => - func(input[from][index], output[adjustedTo][index]) + func(input[from][index], output[adjustedTo][index]), ); }); } @@ -584,8 +590,9 @@ export const extractArray = ( export const extractArray2d = ( extractionFunc: ExtractionFunc[], from: string, - to?: string + to?: string, ) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any return (input: any, output: any) => { if ( Array.isArray(input[from]) && @@ -598,7 +605,7 @@ export const extractArray2d = ( for (let j = 0; j < input[from][i].length; ++j) { output[adjustedTo][i].push({}); extractionFunc.forEach((func: ExtractionFunc) => - func(input[from][i][j], output[adjustedTo][i][j]) + func(input[from][i][j], output[adjustedTo][i][j]), ); } } @@ -614,8 +621,9 @@ export const extractArray2d = ( export const extractArrayConditionally = ( params: ConditionalExtractParams[], from: string, - to?: string + to?: string, ) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any return (input: any, output: any) => { const adjustedTo = to ?? from; if (input[from] !== undefined && Array.isArray(input[from])) { @@ -630,12 +638,13 @@ export const extractArrayConditionally = ( // If so, then apply the necessary extraction functions if (Array.isArray(param.mappings)) { param.mappings.forEach((func: ExtractionFunc) => - func(input[from][index], output[adjustedTo][index]) + func(input[from][index], output[adjustedTo][index]), ); } else { + // eslint-disable-next-line @typescript-eslint/no-explicit-any param.mappings(index as any, index as any)( input[from], - output[adjustedTo] + output[adjustedTo], ); } } @@ -657,8 +666,9 @@ export const extractPlainTypedMap = ( extractionFuncs: ExtractionFunc[], isValidKey: (key: unknown) => boolean, from: string, - to?: string + to?: string, ) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any return (input: any, output: any) => { if (input[from] !== undefined) { const adjustedTo = to ?? from; @@ -667,7 +677,7 @@ export const extractPlainTypedMap = ( if (isValidKey(prop)) { output[adjustedTo][prop] = {}; extractionFuncs.forEach((func: ExtractionFunc) => - func(input[from][prop], output[adjustedTo][prop]) + func(input[from][prop], output[adjustedTo][prop]), ); } } @@ -683,11 +693,13 @@ export const extractPlainTypedMap = ( * @param extractionFuncs Array of extraction functions */ export const applyExtraction = ( + // eslint-disable-next-line @typescript-eslint/no-explicit-any input: any, + // eslint-disable-next-line @typescript-eslint/no-explicit-any output: any, - extractionFuncs: ExtractionFunc[] + extractionFuncs: ExtractionFunc[], ) => { extractionFuncs.forEach((func: ExtractionFunc) => - func(input, output) + func(input, output), ); }; diff --git a/packages/saved-views-react/src/api/utilities/translation/urlConverter.ts b/packages/saved-views-react/src/api/utilities/translation/urlConverter.ts index 0c3a928d..674207e8 100644 --- a/packages/saved-views-react/src/api/utilities/translation/urlConverter.ts +++ b/packages/saved-views-react/src/api/utilities/translation/urlConverter.ts @@ -1,6 +1,7 @@ +/* eslint-disable @typescript-eslint/comma-dangle */ // Copyright (c) Bentley Systems, Incorporated. All rights reserved. import { BaseMapLayerProps, ImageMapLayerProps } from "@itwin/core-common"; -import { ViewData, ViewDataITwinDrawing, ViewDataITwinSheet, ViewDataItwin3d, } from "@itwin/saved-views-client"; +import { ViewData, ViewDataITwinDrawing, ViewDataITwinSheet, ViewDataItwin3d } from "@itwin/saved-views-client"; /** * Convert url that potentially contains restricted characters ('&' or '.') to use unrestricated substitute characters ('++and++' or '++dot++') diff --git a/packages/saved-views-react/src/api/utilities/translation/viewExtractorSavedViewToLegacySavedView.ts b/packages/saved-views-react/src/api/utilities/translation/viewExtractorSavedViewToLegacySavedView.ts index 5c4916ee..f5bf3a71 100644 --- a/packages/saved-views-react/src/api/utilities/translation/viewExtractorSavedViewToLegacySavedView.ts +++ b/packages/saved-views-react/src/api/utilities/translation/viewExtractorSavedViewToLegacySavedView.ts @@ -9,15 +9,15 @@ import { } from "@itwin/core-frontend"; import { SavedViewApiBase, SavedViewTag, SavedViewWithDataRepresentation, ViewDataItwin3d, - ViewDataITwinDrawing, ViewDataITwinSheet, ViewITwin3d -} from '@itwin/saved-views-client'; + ViewDataITwinDrawing, ViewDataITwinSheet, ViewITwin3d, +} from "@itwin/saved-views-client"; import { - SavedView as LegacySavedView, SavedView2d as LegacySavedView2d, Tag as LegacyTag -} from '../SavedViewTypes'; -import { extractClipVectors } from './clipVectorsExtractor'; -import { extractDisplayStyle, extractDisplayStyle3d } from './displayStyleExtractor'; -import { convertAllLegacyUrlsToUrls, urlToLegacyUrl } from './urlConverter'; + SavedView as LegacySavedView, SavedView2d as LegacySavedView2d, Tag as LegacyTag, +} from "../SavedViewTypes"; +import { extractClipVectors } from "./clipVectorsExtractor"; +import { extractDisplayStyle, extractDisplayStyle3d } from "./displayStyleExtractor"; +import { convertAllLegacyUrlsToUrls, urlToLegacyUrl } from "./urlConverter"; const UNGROUPED_ID = "-1"; @@ -53,7 +53,7 @@ const extractTags = (creator: string, tags?: SavedViewTag[]) => { */ export function savedViewItwinDrawingToLegacyDrawingView( savedViewRsp: SavedViewWithDataRepresentation, - seedDrawingViewState: DrawingViewState + seedDrawingViewState: DrawingViewState, ): LegacySavedView2d { convertAllLegacyUrlsToUrls(savedViewRsp.savedViewData, urlToLegacyUrl); const iTwinDrawingView = (savedViewRsp.savedViewData as ViewDataITwinDrawing).itwinDrawingView; @@ -133,7 +133,7 @@ export function savedViewItwinDrawingToLegacyDrawingView( */ export function savedViewItwinSheetToLegacySheetSavedView( savedViewRsp: SavedViewWithDataRepresentation, - seedSheetViewState: SheetViewState + seedSheetViewState: SheetViewState, ): LegacySavedView2d { convertAllLegacyUrlsToUrls(savedViewRsp.savedViewData, urlToLegacyUrl); const itwinSheetView = (savedViewRsp.savedViewData as ViewDataITwinSheet).itwinSheetView; @@ -223,7 +223,7 @@ export function savedViewItwinSheetToLegacySheetSavedView( */ export function savedViewITwin3dToLegacy3dSavedView( savedViewRsp: SavedViewWithDataRepresentation, - seedSpatialViewState: SpatialViewState + seedSpatialViewState: SpatialViewState, ): LegacySavedView { convertAllLegacyUrlsToUrls(savedViewRsp.savedViewData, urlToLegacyUrl); const modelSelector = seedSpatialViewState.modelSelector; @@ -243,6 +243,7 @@ export function savedViewITwin3dToLegacy3dSavedView( origin: itwin3dView.origin, extents: itwin3dView.extents, angles: itwin3dView.angles ?? {}, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion camera: itwin3dView.camera!, jsonProperties: { viewDetails: extractClipVectors(itwin3dView) ?? {}, @@ -298,7 +299,7 @@ export function savedViewITwin3dToLegacy3dSavedView( */ function appendHiddenCategoriesToLegacyView( iTwinView: SavedViewApiBase, - legacyView: LegacySavedView | LegacySavedView2d + legacyView: LegacySavedView | LegacySavedView2d, ) { if (iTwinView.categories && iTwinView.categories.disabled) { legacyView.hiddenCategories = iTwinView.categories.disabled as Id64Array; @@ -313,7 +314,7 @@ function appendHiddenCategoriesToLegacyView( */ function appendHiddenModelsTo3dLegacySavedView( view: ViewITwin3d, - legacyView: LegacySavedView + legacyView: LegacySavedView, ) { if (view.models && view.models.disabled) { legacyView.hiddenModels = view.models?.disabled as Id64Array; @@ -326,7 +327,7 @@ function appendHiddenModelsTo3dLegacySavedView( * @returns SavedViewWithData */ export const cleanLegacyViewModelSelectorPropsModels = ( - savedView: SavedViewWithDataRepresentation + savedView: SavedViewWithDataRepresentation, ) => { if ((savedView.savedViewData.legacyView as LegacySavedView)?.modelSelectorProps) { const savedViewCopy = _.cloneDeep(savedView); diff --git a/packages/test-app-frontend/src/App/App.tsx b/packages/test-app-frontend/src/App/App.tsx index eb448ad3..5158667f 100644 --- a/packages/test-app-frontend/src/App/App.tsx +++ b/packages/test-app-frontend/src/App/App.tsx @@ -6,7 +6,7 @@ import { SvgImodelHollow, SvgPalette, SvgUser } from "@itwin/itwinui-icons-react import { PageLayout } from "@itwin/itwinui-layouts-react"; import { Button, SidenavButton, SideNavigation, Surface, ThemeProvider } from "@itwin/itwinui-react"; import { PropsWithChildren, ReactElement, useEffect, useState } from "react"; -import { Navigate, Outlet, Route, Routes, useLocation, useMatch, useNavigate, useParams } from "react-router-dom"; +import { Navigate, Outlet, Route, Routes, useMatch, useNavigate, useParams } from "react-router-dom"; import { applyUrlPrefix, clientId } from "../environment"; import { AppContext, appContext } from "./AppContext"; @@ -22,8 +22,6 @@ import type { ITwinJsApp } from "./ITwinJsApp/ITwinJsApp"; import "./App.css"; import { ComponentsCatalogRoutes } from "./ComponentsCatalog/ComponentsCatalog"; -import { IModelConnection } from "@itwin/core-frontend"; -import { ViewportComponent } from "@itwin/imodel-components-react"; export function App(): ReactElement { const [appContextValue, setAppContextValue] = useState({ @@ -201,41 +199,3 @@ function OpenIModel(props: OpenIModelProps): ReactElement | null { return ; } - -function RenderIModel(): ReactElement | null { - const {state} = useLocation(); - - return -} - -// function RenderIModelFromViewId(): ReactElement | null { -// // const { userAuthorizationClient } = useAuthorization(); -// // const { iTwinId, iModelId } = useParams<{ iTwinId: string; iModelId: string; }>(); -// // if (iTwinId === undefined || iModelId === undefined) { -// // return null; -// // } - -// const {state} = useLocation(); - -// // const iModel: IModelConnection = state.iModel; -// // iModel.views.load() - -// // // const iModel = UiFramework.getIModelConnection(); -// // // iModel?.views.load(savedView.id); -// // // return - -// const iModel: IModelConnection = state.iModel; -// const savedViewId: string = state.savedViewId; - -// const viewState = async () => await iModel.views.load(savedViewId); - -// return -// } diff --git a/packages/test-app-frontend/src/App/ITwinJsApp/ITwinJsApp.tsx b/packages/test-app-frontend/src/App/ITwinJsApp/ITwinJsApp.tsx index cb741316..b036e59f 100644 --- a/packages/test-app-frontend/src/App/ITwinJsApp/ITwinJsApp.tsx +++ b/packages/test-app-frontend/src/App/ITwinJsApp/ITwinJsApp.tsx @@ -91,9 +91,10 @@ export function ITwinJsApp(props: ITwinJsAppProps): ReactElement | null { if (selectedViewId && selectedViewId !== "") { setLoadingState("rendering-imodel"); - renderSavedView(iModel, selectedViewId, client); + void renderSavedView(iModel, selectedViewId, client); } }, + // eslint-disable-next-line react-hooks/exhaustive-deps [selectedViewId], ); @@ -128,6 +129,7 @@ export function ITwinJsApp(props: ITwinJsAppProps): ReactElement | null { if (selectedViewState) { return