Skip to content

Commit 9b806c5

Browse files
SpencerWBarnescalebmshaferaruniversekckst8
authored
Add new extension api (#2743)
* Added extensions project * Added extension changes to core-frontend * Added extension test placeholder * Added extension ui-test-app * Set new extension exports to alpha * Change logs * Added extension package documentation * Updated code owners and removed unused test * Extract-api * Reverted changes to appui-react api * Removed some common types from extension access * Removed some frontend types from extensions * Added real frontend functions * Added more frontend exports * Removed real ToolSettings * Updated extensions to beta * Removed broken link to extension docs * Removed commented-out code * Simplified extension test tool * Merge fixes * clean up API * add kevin as codeowner for extensions * cleanup core-extension * core-frontend * react to PR comments * update lock file * update lock * update api docs * pr comment + dont lint * extract-api * move enum to Extension.ts * use proper types, cleanup tags * fix gnarly comment Co-authored-by: Caleb Shafer <[email protected]> Co-authored-by: Arun George <[email protected]> Co-authored-by: kckst8 <[email protected]>
1 parent b348598 commit 9b806c5

32 files changed

+3011
-935
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ rush.json @iTwin/itwinjs-core-admins
105105
/core/ecschema-* @calebmshafer @ColinKerr @wgoehrig
106106
/core/electron @wgoehrig @ramanujam-raman
107107
/core/express-server @calebmshafer @wgoehrig @ramanujam-raman
108+
/core/extension @calebmshafer @wgoehrig @aruniverse @kckst8
108109
/core/frontend @kabentley @bbastings @iTwin/itwinjs-core-display
109-
/core/frontend/src/extension @calebmshafer @wgoehrig
110+
/core/frontend/src/extension @calebmshafer @wgoehrig @aruniverse @kckst8
110111
/core/frontend-devtools @iTwin/itwinjs-core-display @Ellord207
111112
/core/geometry @bbastings @mgooding @dassaf4
112113
/core/hypermodeling @bbastings @iTwin/itwinjs-core-display
@@ -134,6 +135,7 @@ rush.json @iTwin/itwinjs-core-admins
134135
/example-code @iTwin/itwinjs-core-admins
135136

136137
/extensions @bsteinbk @calebmshafer
138+
/extensions/test-extension @calebmshafer @wgoehrig @aruniverse @kckst8
137139
/extensions/map-layers @bsteinbk @mdastous-bentley
138140

139141
/full-stack-tests/core @iTwin/itwinjs-core-admins
@@ -163,7 +165,7 @@ rush.json @iTwin/itwinjs-core-admins
163165
/tools/backend-webpack @calebmshafer @wgoehrig
164166
/tools/build @calebmshafer @wgoehrig
165167
/tools/certa @calebmshafer @wgoehrig
166-
/tools/webpack-core @calebmshafer @wgoehrig
168+
/tools/webpack-core @calebmshafer @wgoehrig @aruniverse
167169
/tools/ecschema2ts @calebmshafer @ColinKerr @wgoehrig
168170
/tools/eslint-plugin @calebmshafer @paulius-valiunas
169171
/tools/internal @calebmshafer @wgoehrig

common/api/core-frontend.api.md

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import { CodeSpec } from '@itwin/core-common';
5454
import { ColorDef } from '@itwin/core-common';
5555
import { ColorDefProps } from '@itwin/core-common';
5656
import { ColorIndex } from '@itwin/core-common';
57+
import { CommonToolbarItem } from '@itwin/appui-abstract';
5758
import { CompressedId64Set } from '@itwin/core-bentley';
5859
import { Constructor } from '@itwin/core-bentley';
5960
import { ContentIdProvider } from '@itwin/core-common';
@@ -292,12 +293,15 @@ import { TileHeader } from '@itwin/core-common';
292293
import { TileProps } from '@itwin/core-common';
293294
import { TileReadStatus } from '@itwin/core-common';
294295
import { TileVersionInfo } from '@itwin/core-common';
296+
import { ToolbarOrientation } from '@itwin/appui-abstract';
297+
import { ToolbarUsage } from '@itwin/appui-abstract';
295298
import { Transform } from '@itwin/core-geometry';
296299
import { TransformProps } from '@itwin/core-geometry';
297300
import { TransientIdSequence } from '@itwin/core-bentley';
298301
import { Tweens } from '@itwin/core-common';
299302
import { TxnNotifications } from '@itwin/core-common';
300303
import { UiAdmin } from '@itwin/appui-abstract';
304+
import { UiItemsProvider } from '@itwin/appui-abstract';
301305
import { UnitConversion } from '@itwin/core-quantity';
302306
import { UnitProps } from '@itwin/core-quantity';
303307
import { UnitsProvider } from '@itwin/core-quantity';
@@ -1022,6 +1026,12 @@ export enum ACSType {
10221026
Spherical = 3
10231027
}
10241028

1029+
// @beta (undocumented)
1030+
export enum ActivationEvent {
1031+
// (undocumented)
1032+
onStartup = "onStartup"
1033+
}
1034+
10251035
// @public
10261036
export class ActivityMessageDetails {
10271037
constructor(showProgressBar: boolean, showPercentInMessage: boolean, supportsCancellation: boolean, showDialogInitially?: boolean);
@@ -1755,6 +1765,19 @@ export class BriefcaseTxns extends BriefcaseNotificationHandler implements TxnNo
17551765
reverseTxns(numOperations: number): Promise<IModelStatus>;
17561766
}
17571767

1768+
// @beta (undocumented)
1769+
export interface BuildExtensionManifest extends ExtensionManifest {
1770+
readonly module: string;
1771+
}
1772+
1773+
// @beta (undocumented)
1774+
export interface BuiltInExtensionLoaderProps {
1775+
// (undocumented)
1776+
loader: ResolveFunc;
1777+
// (undocumented)
1778+
manifest: Promise<any>;
1779+
}
1780+
17581781
// @internal (undocumented)
17591782
export type CachedDecoration = {
17601783
type: "graphic";
@@ -3065,6 +3088,64 @@ export enum EventHandled {
30653088
Yes = 1
30663089
}
30673090

3091+
// @beta
3092+
export class ExtensionAdmin {
3093+
constructor();
3094+
addBuildExtension(manifestPromise: Promise<BuildExtensionManifest>, mainFunc?: ResolveFunc): Promise<void>;
3095+
addExtensionLoader(extensionLoader: ExtensionLoader): void;
3096+
addExtensionLoaderFront(extensionLoader: ExtensionLoader): void;
3097+
// @internal
3098+
onStartup: () => Promise<void>;
3099+
}
3100+
3101+
// @beta
3102+
export class ExtensionHost {
3103+
protected constructor();
3104+
// (undocumented)
3105+
static get accuSnap(): AccuSnap;
3106+
// (undocumented)
3107+
static get locateManager(): ElementLocateManager;
3108+
// (undocumented)
3109+
static get notifications(): NotificationManager;
3110+
// (undocumented)
3111+
static get renderSystem(): RenderSystem;
3112+
// (undocumented)
3113+
static get toolAdmin(): ToolAdmin;
3114+
// (undocumented)
3115+
static get viewManager(): ViewManager;
3116+
}
3117+
3118+
// @beta (undocumented)
3119+
export class ExtensionImpl {
3120+
constructor(_id: string);
3121+
// (undocumented)
3122+
registerTool(tool: ToolType, onRegistered?: () => any): Promise<void>;
3123+
}
3124+
3125+
// @beta
3126+
export interface ExtensionLoader {
3127+
downloadExtension(arg: ExtensionLoaderProps): Promise<LocalExtensionProps>;
3128+
getManifest(arg: ExtensionLoaderProps): Promise<ExtensionManifest>;
3129+
}
3130+
3131+
// @beta
3132+
export interface ExtensionLoaderProps {
3133+
// (undocumented)
3134+
name: string;
3135+
// (undocumented)
3136+
version: string;
3137+
}
3138+
3139+
// @beta
3140+
export interface ExtensionManifest {
3141+
readonly activationEvents: ActivationEvent[];
3142+
readonly description?: string;
3143+
readonly displayName?: string;
3144+
readonly main: string;
3145+
readonly name: string;
3146+
readonly version: string;
3147+
}
3148+
30683149
// @public
30693150
export interface ExtentLimits {
30703151
max: number;
@@ -4640,6 +4721,8 @@ export class IModelApp {
46404721
static authorizationClient?: AuthorizationClient;
46414722
// @internal (undocumented)
46424723
static createRenderSys(opts?: RenderSystem.Options): RenderSystem;
4724+
// @beta (undocumented)
4725+
static readonly extensionAdmin: ExtensionAdmin;
46434726
// @alpha
46444727
static formatElementToolTip(msg: string[]): HTMLElement;
46454728
static getAccessToken(): Promise<AccessToken>;
@@ -4650,7 +4733,7 @@ export class IModelApp {
46504733
// @internal (undocumented)
46514734
static get initialized(): boolean;
46524735
static get localization(): Localization;
4653-
// @internal (undocumented)
4736+
// (undocumented)
46544737
static get locateManager(): ElementLocateManager;
46554738
// @internal (undocumented)
46564739
static lookupEntityClass(classFullName: string): typeof EntityState | undefined;
@@ -4676,6 +4759,8 @@ export class IModelApp {
46764759
// @internal
46774760
static get mapLayerFormatRegistry(): MapLayerFormatRegistry;
46784761
static get notifications(): NotificationManager;
4762+
// @internal
4763+
static readonly onAfterStartup: BeEvent<() => void>;
46794764
static readonly onBeforeShutdown: BeEvent<() => void>;
46804765
// @beta
46814766
static get publicPath(): string;
@@ -5280,6 +5365,14 @@ export class LengthDescription extends FormattedQuantityDescription {
52805365
// @internal (undocumented)
52815366
export function linePlaneIntersect(outP: Point3d, linePt: Point3d, lineNormal: Vector3d | undefined, planePt: Point3d, planeNormal: Vector3d, perpendicular: boolean): void;
52825367

5368+
// @beta
5369+
export interface LocalExtensionProps {
5370+
// (undocumented)
5371+
readonly mainFunc?: ResolveFunc;
5372+
// (undocumented)
5373+
readonly manifest: ExtensionManifest;
5374+
}
5375+
52835376
// @internal
52845377
export class LocalhostIpcApp {
52855378
// (undocumented)
@@ -9013,6 +9106,9 @@ export abstract class RenderTextureDrape implements IDisposable {
90139106
// @internal (undocumented)
90149107
export type RequestTileTreePropsFunc = (iModel: IModelConnection, treeId: string) => Promise<IModelTileTreeProps>;
90159108

9109+
// @beta (undocumented)
9110+
export type ResolveFunc = () => Promise<any>;
9111+
90169112
// @internal
90179113
export type RootIModelTile = Tile & {
90189114
tileScreenSize: number;
@@ -11651,6 +11747,15 @@ export interface ToolAssistanceSection {
1165111747
// @public (undocumented)
1165211748
export type ToolList = ToolType[];
1165311749

11750+
// @beta (undocumented)
11751+
export class ToolProvider implements UiItemsProvider {
11752+
constructor(tool: ToolType);
11753+
// (undocumented)
11754+
readonly id: string;
11755+
// (undocumented)
11756+
provideToolbarButtonItems(_stageId: string, stageUsage: string, toolbarUsage: ToolbarUsage, toolbarOrientation: ToolbarOrientation): CommonToolbarItem[];
11757+
}
11758+
1165411759
// @public
1165511760
export class ToolRegistry {
1165611761
create(toolId: string, ...args: any[]): Tool | undefined;

common/api/summary/core-frontend.exports.csv

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public;AccuSnap
2424
public;AccuSnap
2525
public;ACSDisplayOptions
2626
public;ACSType
27+
beta;ActivationEvent
2728
public;ActivityMessageDetails
2829
public;ActivityMessageEndReason
2930
internal;addRangeGraphic(builder: GraphicBuilder, range: Range3d, is2d: boolean): void
@@ -73,6 +74,8 @@ public;BlankConnectionProps
7374
public;BriefcaseConnection
7475
public;class BriefcaseNotificationHandler
7576
public;BriefcaseTxns
77+
beta;BuildExtensionManifest
78+
beta;BuiltInExtensionLoaderProps
7679
internal;CachedDecoration =
7780
internal;CachedIModelCoordinatesResponseProps
7881
public;calculateEcefToDbTransformAtLocation(originIn: Point3d, iModel: IModelConnection): Promise
@@ -156,6 +159,12 @@ public;EntityState
156159
internal;EnvironmentDecorations
157160
public;EventController
158161
public;EventHandled
162+
beta;ExtensionAdmin
163+
beta;ExtensionHost
164+
beta;ExtensionImpl
165+
beta;ExtensionLoader
166+
beta;ExtensionLoaderProps
167+
beta;ExtensionManifest
159168
public;ExtentLimits
160169
internal;ExternalTileStatistics
161170
public;extractImageSourceDimensions(source: ImageSource): Promise
@@ -316,6 +325,7 @@ public;KeyinParseError
316325
internal;KeyinStatus
317326
beta;LengthDescription
318327
internal;linePlaneIntersect(outP: Point3d, linePt: Point3d, lineNormal: Vector3d | undefined, planePt: Point3d, planeNormal: Vector3d, perpendicular: boolean): void
328+
beta;LocalExtensionProps
319329
internal;LocalhostIpcApp
320330
internal;LocalHostIpcAppOpts
321331
beta;LocalUnitFormatProvider
@@ -511,6 +521,7 @@ internal;RenderTargetDebugControl
511521
internal;class RenderTerrainGeometry
512522
internal;class RenderTextureDrape
513523
internal;RequestTileTreePropsFunc = (iModel: IModelConnection, treeId: string) => Promise
524+
beta;ResolveFunc = () => Promise
514525
internal;RootIModelTile = Tile &
515526
public;RotateViewTool
516527
alpha;RotationMode
@@ -640,6 +651,7 @@ public;ToolAssistanceInstructions
640651
public;ToolAssistanceKeyboardInfo
641652
public;ToolAssistanceSection
642653
public;ToolList = ToolType[]
654+
beta;ToolProvider
643655
public;ToolRegistry
644656
public;ToolSettings
645657
internal;ToolSettingsState
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@itwin/core-extension",
5+
"comment": "Switched to more flexible extension api",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@itwin/core-extension"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@itwin/core-frontend",
5+
"comment": "Switched to more flexible extension api",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@itwin/core-frontend"
10+
}

0 commit comments

Comments
 (0)