@itwin/core-common 5.1.0-dev.64 → 5.1.0-dev.65

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.
@@ -7,6 +7,8 @@
7
7
  * @extensions
8
8
  */
9
9
  export declare enum CommonLoggerCategory {
10
+ /** The logger category used by common APIs relating to text annotations. */
11
+ Annotations = "core-common.Annotations",
10
12
  /** The logger category used by common classes relating to ElementProps. */
11
13
  ElementProps = "core-common.ElementProps",
12
14
  /** The logger category used by common classes relating to Geometry. */
@@ -1 +1 @@
1
- {"version":3,"file":"CommonLoggerCategory.d.ts","sourceRoot":"","sources":["../../src/CommonLoggerCategory.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;;GAIG;AACH,oBAAY,oBAAoB;IAC9B,2EAA2E;IAC3E,YAAY,6BAA6B;IACzC,uEAAuE;IACvE,QAAQ,yBAAyB;IACjC,sGAAsG;IACtG,mBAAmB,8BAA8B;IACjD,uGAAuG;IACvG,oBAAoB,+BAA+B;CACpD"}
1
+ {"version":3,"file":"CommonLoggerCategory.d.ts","sourceRoot":"","sources":["../../src/CommonLoggerCategory.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;;GAIG;AACH,oBAAY,oBAAoB;IAC9B,4EAA4E;IAC5E,WAAW,4BAA4B;IACvC,2EAA2E;IAC3E,YAAY,6BAA6B;IACzC,uEAAuE;IACvE,QAAQ,yBAAyB;IACjC,sGAAsG;IACtG,mBAAmB,8BAA8B;IACjD,uGAAuG;IACvG,oBAAoB,+BAA+B;CACpD"}
@@ -15,6 +15,8 @@ exports.CommonLoggerCategory = void 0;
15
15
  */
16
16
  var CommonLoggerCategory;
17
17
  (function (CommonLoggerCategory) {
18
+ /** The logger category used by common APIs relating to text annotations. */
19
+ CommonLoggerCategory["Annotations"] = "core-common.Annotations";
18
20
  /** The logger category used by common classes relating to ElementProps. */
19
21
  CommonLoggerCategory["ElementProps"] = "core-common.ElementProps";
20
22
  /** The logger category used by common classes relating to Geometry. */
@@ -1 +1 @@
1
- {"version":3,"file":"CommonLoggerCategory.js","sourceRoot":"","sources":["../../src/CommonLoggerCategory.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH;;;;GAIG;AACH,IAAY,oBASX;AATD,WAAY,oBAAoB;IAC9B,2EAA2E;IAC3E,iEAAyC,CAAA;IACzC,uEAAuE;IACvE,yDAAiC,CAAA;IACjC,sGAAsG;IACtG,yEAAiD,CAAA;IACjD,uGAAuG;IACvG,2EAAmD,CAAA;AACrD,CAAC,EATW,oBAAoB,oCAApB,oBAAoB,QAS/B","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Logging\n */\n\n/** Logger categories used by this package\n * @see [Logger]($bentley)\n * @public\n * @extensions\n */\nexport enum CommonLoggerCategory {\n /** The logger category used by common classes relating to ElementProps. */\n ElementProps = \"core-common.ElementProps\",\n /** The logger category used by common classes relating to Geometry. */\n Geometry = \"core-common.Geometry\",\n /** The logger category used by the portions of the RpcInterface framework that run on the backend. */\n RpcInterfaceBackend = \"core-backend.RpcInterface\",\n /** The logger category used by the portions of the RpcInterface framework that run on the frontend. */\n RpcInterfaceFrontend = \"core-frontend.RpcInterface\",\n}\n"]}
1
+ {"version":3,"file":"CommonLoggerCategory.js","sourceRoot":"","sources":["../../src/CommonLoggerCategory.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH;;;;GAIG;AACH,IAAY,oBAWX;AAXD,WAAY,oBAAoB;IAC9B,4EAA4E;IAC5E,+DAAuC,CAAA;IACvC,2EAA2E;IAC3E,iEAAyC,CAAA;IACzC,uEAAuE;IACvE,yDAAiC,CAAA;IACjC,sGAAsG;IACtG,yEAAiD,CAAA;IACjD,uGAAuG;IACvG,2EAAmD,CAAA;AACrD,CAAC,EAXW,oBAAoB,oCAApB,oBAAoB,QAW/B","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Logging\n */\n\n/** Logger categories used by this package\n * @see [Logger]($bentley)\n * @public\n * @extensions\n */\nexport enum CommonLoggerCategory {\n /** The logger category used by common APIs relating to text annotations. */\n Annotations = \"core-common.Annotations\",\n /** The logger category used by common classes relating to ElementProps. */\n ElementProps = \"core-common.ElementProps\",\n /** The logger category used by common classes relating to Geometry. */\n Geometry = \"core-common.Geometry\",\n /** The logger category used by the portions of the RpcInterface framework that run on the backend. */\n RpcInterfaceBackend = \"core-backend.RpcInterface\",\n /** The logger category used by the portions of the RpcInterface framework that run on the frontend. */\n RpcInterfaceFrontend = \"core-frontend.RpcInterface\",\n}\n"]}
@@ -74,15 +74,15 @@ export declare abstract class TextBlockComponent {
74
74
  /** Returns true if `this` is equivalent to `other`. */
75
75
  equals(other: TextBlockComponent): boolean;
76
76
  }
77
- /**
77
+ /** [[TextBlockComponent]]s contained within a [[Paragraph]].
78
78
  * @beta
79
79
  */
80
- export type Run = TextRun | FractionRun | TabRun | LineBreakRun;
80
+ export type Run = TextRun | FractionRun | TabRun | LineBreakRun | FieldRun;
81
81
  /** The JSON representation of a [[Run]].
82
82
  * Use the `type` field to discriminate between the different kinds of runs.
83
83
  * @beta
84
84
  */
85
- export type RunProps = TextRunProps | FractionRunProps | TabRunProps | LineBreakRunProps;
85
+ export type RunProps = TextRunProps | FractionRunProps | TabRunProps | LineBreakRunProps | FieldRunProps;
86
86
  /** A sequence of characters within a [[Paragraph]] that share a single style. Runs are the leaf nodes of a [[TextBlock]] document. When laid out for display, a single run may span
87
87
  * multiple lines, but it will never contain different styling.
88
88
  * Use the `type` field to discriminate between the different kinds of runs.
@@ -209,6 +209,108 @@ export declare class TabRun extends TextBlockComponent {
209
209
  stringify(options?: TextBlockStringifyOptions): string;
210
210
  equals(other: TextBlockComponent): boolean;
211
211
  }
212
+ /** A chain of property accesses that resolves to a primitive value that forms the basis of the displayed content
213
+ * of a [[FieldRun]].
214
+ * The simplest property paths consist of a [[propertyName]] and nothing else, where `propertyName` identifies
215
+ * a primitive property.
216
+ * If `propertyName` identifies a struct or array property, then additional [[accessors]] are required to identify the specific value.
217
+ * If `propertyName` (including any [[accessors]]) resolves to a JSON property, then additional [[jsonAccessors]] are required to identify a specific value within the JSON.
218
+ * Some examples:
219
+ * ```
220
+ * | Access String | propertyName | accessors | jsonAccessors |
221
+ * | ------------- | ------------ | --------- | ------------- |
222
+ * | name | "name" | undefined | undefined |
223
+ * | spouse.name | "spouse" | [name] | undefined |
224
+ * | colors[2] | "colors" | [2] | undefined |
225
+ * | spouse.favoriteRestaurants[1].address | "spouse" | ["favoriteRestaurants", 1, "address"] | undefined |
226
+ * | jsonProperties.contactInfo.email | "jsonProperties" | undefined | ["contactInfo", "email"] |
227
+ * | spouse.jsonProperties.contactInfo.phoneNumbers[0].areaCode | "spouse" | ["jsonProperties"] | ["contactInfo", "phoneNumbers", 0, "areaCode"] |
228
+ * ```
229
+ * @beta
230
+ */
231
+ export interface FieldPropertyPath {
232
+ /** The name of the BIS property of the [[FieldPropertyHost]] that serves as the root of the path. */
233
+ propertyName: string;
234
+ /** Property names and/or array indices describing the path from [[propertyName]] to the ultimate BIS property. */
235
+ accessors?: Array<string | number>;
236
+ /** If [[propertyName]] and [[accessors]] (if defined) resolve to a BIS property of extended type `Json`, property names and/or
237
+ * array indices for selecting a primitive value within the JSON.
238
+ */
239
+ jsonAccessors?: Array<string | number>;
240
+ }
241
+ /** Describes the source of the property value against which a [[FieldPropertyPath]] is evaluated.
242
+ * A field property is always hosted by an [Element]($backend). It may be a property of the element's BIS class itself,
243
+ * or that of one of its [ElementAspect]($backend)s.
244
+ * The [[schemaName]] and [[className]] should always identify the exact class that contains [[FieldPropertyPath.propertyName]] - not a subclass thereof.
245
+ * @beta
246
+ */
247
+ export interface FieldPropertyHost {
248
+ /** The Id of the [Element]($backend) that hosts the property. */
249
+ elementId: Id64String;
250
+ /** The name of the schema containing the class identified by [[className]]. */
251
+ schemaName: string;
252
+ /** The name of the exact class (not a subclass) containing the property identified by [[FieldPropertyPath.propertyName]]. */
253
+ className: string;
254
+ }
255
+ /** Placeholder type for a description of how to format the raw property value resolved by a [[FieldPropertyPath]] into a [[FieldRun]]'s display string.
256
+ * *** COMING SOON ***
257
+ * @beta
258
+ */
259
+ export interface FieldFormatter {
260
+ [k: string]: any;
261
+ }
262
+ /** JSON representation of a [[FieldRun]].
263
+ * @beta
264
+ */
265
+ export interface FieldRunProps extends TextBlockComponentProps {
266
+ /** Discriminator field for the [[RunProps]] union. */
267
+ readonly type: "field";
268
+ /** The element and BIS class containing the property described by [[propertyPath]]. */
269
+ propertyHost: FieldPropertyHost;
270
+ /** Describes how to obtain the property value from [[propertyHost]]. */
271
+ propertyPath: FieldPropertyPath;
272
+ /** Specifies how to format the property value obtained from [[propertyPath]] into a string to be stored in [[cachedContent]]. */
273
+ formatter?: FieldFormatter;
274
+ /** The field's most recently evaluated display string. */
275
+ cachedContent?: string;
276
+ }
277
+ /** A [[Run]] that displays the formatted value of a property of some [Element]($backend).
278
+ * When a [[TextBlock]] containing a [[FieldRun]] is written into the iModel as an [ITextAnnotation]($backend) element,
279
+ * a dependency is established between the two elements via the [ElementDrivesTextAnnotation]($backend) relationship such that
280
+ * whenever the source element specified by [[propertyHost]] is modified, the field(s) in the `ITextAnnotation` element are automatically
281
+ * recalculated, causing their [[cachedContent]] to update. If the field's display string cannot be evaluated (for example, because the specified element or
282
+ * property does not exist), then its cached content is set to [[FieldRun.invalidContentIndicator]].
283
+ * A [[FieldRun]] displays its [[cachedContent]] in the same way that [[TextRun]]s display their `content`, including word wrapping where appropriate.
284
+ * @beta
285
+ */
286
+ export declare class FieldRun extends TextBlockComponent {
287
+ /** Display string used to signal an error in computing the field's value. */
288
+ static invalidContentIndicator: string;
289
+ /** Discriminator field for the [[Run]] union. */
290
+ readonly type = "field";
291
+ /** The element and BIS class containing the property described by [[propertyPath]]. */
292
+ readonly propertyHost: Readonly<FieldPropertyHost>;
293
+ /** Describes how to obtain the property value from [[propertyHost]]. */
294
+ readonly propertyPath: Readonly<FieldPropertyPath>;
295
+ /** Specifies how to format the property value obtained from [[propertyPath]] into a string to be stored in [[cachedContent]]. */
296
+ readonly formatter?: FieldFormatter;
297
+ private _cachedContent;
298
+ /** The field's most recently evaluated display string. */
299
+ get cachedContent(): string;
300
+ /** @internal Used by core-backend when re-evaluating field content. */
301
+ setCachedContent(content: string | undefined): void;
302
+ private constructor();
303
+ /** Create a FieldRun from its JSON representation. */
304
+ static create(props: Omit<FieldRunProps, "type">): FieldRun;
305
+ /** Convert the FieldRun to its JSON representation. */
306
+ toJSON(): FieldRunProps;
307
+ /** Create a deep copy of this FieldRun. */
308
+ clone(): FieldRun;
309
+ /** Convert this FieldRun to a simple string representation. */
310
+ stringify(): string;
311
+ /** Returns true if `this` is equivalent to `other`. */
312
+ equals(other: TextBlockComponent): boolean;
313
+ }
212
314
  /** JSON representation of a [[Paragraph]].
213
315
  * @beta
214
316
  */
@@ -1 +1 @@
1
- {"version":3,"file":"TextBlock.d.ts","sourceRoot":"","sources":["../../../src/annotation/TextBlock.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAqB,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,cAAc,CAAC,EAAE,sBAAsB,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,cAAc,CAAC,EAAE,MA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O,EAAE,UAAU,CAAC;IAC3B;;;OAGG;IACI,KAAK,EAAE,MAAM,CAAC;IACrB,+CAA+C;IACxC,aAAa,EAAE,sBAAsB,CAAC;IAC7C,mCAAmC;IAC5B,OAAO,EAAE,gBAAgB,CAAC;IACjC,0DAA0D;IAC1D,SAAgB,UAAU,EAAE,SAAS,EAAE,CAAC;IAExC,OAAO;IAiBS,MAAM,IAAI,cAAc;IAWxC,wDAAwD;WAC1C,MAAM,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS;IAItD,wFAAwF;WAC1E,WAAW,IAAI,SAAS;IAItC,mEAAmE;IACnE,IAAW,OAAO,IAAI,OAAO,CAE5B;IAEe,KAAK,IAAI,SAAS;IAIlC;;;OAGG;IACa,mBAAmB,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,IAAI;IAU1E,uMAAuM;IAChM,SAAS,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,MAAM;IAI7D;;;OAGG;IACI,eAAe,CAAC,YAAY,GAAE,OAAe,GAAG,SAAS;IAgBhE;;OAEG;IACI,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI;IAKhB,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO;CAqB3D"}
@@ -7,7 +7,7 @@
7
7
  * @module Annotation
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.TextBlock = exports.Paragraph = exports.TabRun = exports.LineBreakRun = exports.FractionRun = exports.TextRun = exports.Run = exports.TextBlockComponent = void 0;
10
+ exports.TextBlock = exports.Paragraph = exports.FieldRun = exports.TabRun = exports.LineBreakRun = exports.FractionRun = exports.TextRun = exports.Run = exports.TextBlockComponent = void 0;
11
11
  const TextStyle_1 = require("./TextStyle");
12
12
  /** Abstract representation of any of the building blocks that make up a [[TextBlock]] document - namely [[Run]]s, [[Paragraph]]s, and [[TextBlock]] itself.
13
13
  * The [[TextBlock]] can specify an [AnnotationTextStyle]($backend) that formats its contents. Each component can specify an optional [[styleOverrides]] to customize that formatting.
@@ -84,6 +84,7 @@ var Run;
84
84
  case "fraction": return FractionRun.create(props);
85
85
  case "tab": return TabRun.create(props);
86
86
  case "linebreak": return LineBreakRun.create(props);
87
+ case "field": return FieldRun.create(props);
87
88
  }
88
89
  }
89
90
  Run.fromJSON = fromJSON;
@@ -231,6 +232,114 @@ class TabRun extends TextBlockComponent {
231
232
  }
232
233
  }
233
234
  exports.TabRun = TabRun;
235
+ /** A [[Run]] that displays the formatted value of a property of some [Element]($backend).
236
+ * When a [[TextBlock]] containing a [[FieldRun]] is written into the iModel as an [ITextAnnotation]($backend) element,
237
+ * a dependency is established between the two elements via the [ElementDrivesTextAnnotation]($backend) relationship such that
238
+ * whenever the source element specified by [[propertyHost]] is modified, the field(s) in the `ITextAnnotation` element are automatically
239
+ * recalculated, causing their [[cachedContent]] to update. If the field's display string cannot be evaluated (for example, because the specified element or
240
+ * property does not exist), then its cached content is set to [[FieldRun.invalidContentIndicator]].
241
+ * A [[FieldRun]] displays its [[cachedContent]] in the same way that [[TextRun]]s display their `content`, including word wrapping where appropriate.
242
+ * @beta
243
+ */
244
+ class FieldRun extends TextBlockComponent {
245
+ /** Display string used to signal an error in computing the field's value. */
246
+ static invalidContentIndicator = "####";
247
+ /** Discriminator field for the [[Run]] union. */
248
+ type = "field";
249
+ /** The element and BIS class containing the property described by [[propertyPath]]. */
250
+ propertyHost;
251
+ /** Describes how to obtain the property value from [[propertyHost]]. */
252
+ propertyPath;
253
+ /** Specifies how to format the property value obtained from [[propertyPath]] into a string to be stored in [[cachedContent]]. */
254
+ formatter;
255
+ _cachedContent;
256
+ /** The field's most recently evaluated display string. */
257
+ get cachedContent() {
258
+ return this._cachedContent;
259
+ }
260
+ /** @internal Used by core-backend when re-evaluating field content. */
261
+ setCachedContent(content) {
262
+ this._cachedContent = content ?? FieldRun.invalidContentIndicator;
263
+ }
264
+ constructor(props) {
265
+ super(props);
266
+ this._cachedContent = props.cachedContent ?? FieldRun.invalidContentIndicator;
267
+ this.propertyHost = props.propertyHost;
268
+ this.propertyPath = props.propertyPath;
269
+ this.formatter = props.formatter;
270
+ }
271
+ /** Create a FieldRun from its JSON representation. */
272
+ static create(props) {
273
+ return new FieldRun({
274
+ ...props,
275
+ propertyHost: { ...props.propertyHost },
276
+ propertyPath: structuredClone(props.propertyPath),
277
+ formatter: structuredClone(props.formatter),
278
+ });
279
+ }
280
+ /** Convert the FieldRun to its JSON representation. */
281
+ toJSON() {
282
+ const json = {
283
+ ...super.toJSON(),
284
+ type: "field",
285
+ propertyHost: { ...this.propertyHost },
286
+ propertyPath: structuredClone(this.propertyPath),
287
+ };
288
+ if (this.cachedContent !== FieldRun.invalidContentIndicator) {
289
+ json.cachedContent = this.cachedContent;
290
+ }
291
+ if (this.formatter) {
292
+ json.formatter = structuredClone(this.formatter);
293
+ }
294
+ return json;
295
+ }
296
+ /** Create a deep copy of this FieldRun. */
297
+ clone() {
298
+ return new FieldRun(this.toJSON());
299
+ }
300
+ /** Convert this FieldRun to a simple string representation. */
301
+ stringify() {
302
+ return this.cachedContent;
303
+ }
304
+ /** Returns true if `this` is equivalent to `other`. */
305
+ equals(other) {
306
+ if (!(other instanceof FieldRun) || !super.equals(other)) {
307
+ return false;
308
+ }
309
+ if (this.propertyHost.elementId !== other.propertyHost.elementId ||
310
+ this.propertyHost.className !== other.propertyHost.className ||
311
+ this.propertyHost.schemaName !== other.propertyHost.schemaName) {
312
+ return false;
313
+ }
314
+ if (this.propertyPath.propertyName !== other.propertyPath.propertyName) {
315
+ return false;
316
+ }
317
+ const thisAccessors = this.propertyPath.accessors ?? [];
318
+ const otherAccessors = other.propertyPath.accessors ?? [];
319
+ const thisJsonAccessors = this.propertyPath.jsonAccessors ?? [];
320
+ const otherJsonAccessors = other.propertyPath.jsonAccessors ?? [];
321
+ if (thisAccessors.length !== otherAccessors.length || thisJsonAccessors.length !== otherJsonAccessors.length) {
322
+ return false;
323
+ }
324
+ if (!thisAccessors.every((value, index) => value === otherAccessors[index])) {
325
+ return false;
326
+ }
327
+ if (!thisJsonAccessors.every((value, index) => value === otherJsonAccessors[index])) {
328
+ return false;
329
+ }
330
+ if (this.formatter && other.formatter) {
331
+ // ###TODO better comparison of formatter objects.
332
+ if (JSON.stringify(this.formatter) !== JSON.stringify(other.formatter)) {
333
+ return false;
334
+ }
335
+ }
336
+ else if (this.formatter || other.formatter) {
337
+ return false;
338
+ }
339
+ return true;
340
+ }
341
+ }
342
+ exports.FieldRun = FieldRun;
234
343
  /** A collection of [[Run]]s within a [[TextBlock]]. Each paragraph within a text block is laid out on a separate line.
235
344
  * @beta
236
345
  */
@@ -1 +1 @@
1
- {"version":3,"file":"TextBlock.js","sourceRoot":"","sources":["../../../src/annotation/TextBlock.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,2CAAwE;AA4CxE;;;GAGG;AACH,MAAsB,kBAAkB;IAC9B,eAAe,CAAyB;IAEhD,gBAAgB;IAChB,YAAsB,KAA+B;QACnD,IAAI,CAAC,eAAe,GAAG,6BAAiB,CAAC,UAAU,CAAC,KAAK,EAAE,cAAc,IAAI,EAAE,CAAC,CAAC;IACnF,CAAC;IAED;;;OAGG;IACH,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED,IAAW,cAAc,CAAC,SAAiC;QACzD,IAAI,CAAC,eAAe,GAAG,6BAAiB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACjE,CAAC;IAED,8DAA8D;IACvD,mBAAmB,CAAC,QAAgC;QACzD,IAAI,CAAC,cAAc,GAAG,EAAG,CAAC;IAC5B,CAAC;IAED,4HAA4H;IAC5H,IAAW,cAAc;QACvB,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IACrD,CAAC;IAQD;;;MAGE;IACF,IAAW,YAAY;QACrB,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,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AAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,aAAa,KAAK,KAAK,CAAC,aAAa,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YACnI,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAC1E,KAAK,KAAM,KAAK,CAAC,OAAe,CAAC,GAAG,CAAC,CACtC,CAAC;QAEF,IAAI,CAAC,eAAe;YAAE,OAAO,KAAK,CAAC;QAEnC,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChG,CAAC;CACF;AArID,8BAqIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Annotation\n */\n\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { TextStyleSettings, TextStyleSettingsProps } from \"./TextStyle\";\n\n/** Options supplied to [[TextBlockComponent.clearStyleOverrides]] to control how the style overrides are cleared on the component and its child components.\n * @beta\n */\nexport interface ClearTextStyleOptions {\n /** Controls whether the styleOverrides of any child components are retained.\n * By default, all overrides are cleared.\n */\n preserveChildrenOverrides?: boolean;\n}\n\n/** The JSON representation of a [[TextBlockComponent]].\n * @beta\n */\nexport interface TextBlockComponentProps {\n /** Deviations from the base [[TextStyleSettings]] defined by the [AnnotationTextStyle]($backend) applied to this component.\n * This permits you to, e.g., create a [[TextBlock]] using \"Arial\" font and override one of its [[TextRun]]s to use \"Comic Sans\" instead.\n */\n styleOverrides?: TextStyleSettingsProps;\n}\n\n/** Options supplied to [[TextBlockComponent.stringify]] to control how the content is formatted.\n * @beta\n */\nexport interface TextBlockStringifyOptions {\n /** A string to insert in between each [[Paragraph]].\n * Default: \" \" - a single space.\n */\n paragraphBreak?: string;\n /** A string to insert for each [[LineBreakRun]].\n * Default: \" \" - a single space.\n */\n lineBreak?: string;\n /** A string to insert between the numerator and denominator of each [[FractionRun]].\n * Default: \"/\"\n */\n fractionSeparator?: string;\n /** The number of spaces to use for tabs. If not provided, tabs will be represented by a tab character: \"\\t\".\n * Default: \"undefined\" - use \"\\t\".\n */\n tabsAsSpaces?: number;\n}\n\n/** Abstract representation of any of the building blocks that make up a [[TextBlock]] document - namely [[Run]]s, [[Paragraph]]s, and [[TextBlock]] itself.\n * The [[TextBlock]] can specify an [AnnotationTextStyle]($backend) that formats its contents. Each component can specify an optional [[styleOverrides]] to customize that formatting.\n * @beta\n */\nexport abstract class TextBlockComponent {\n private _styleOverrides: TextStyleSettingsProps;\n\n /** @internal */\n protected constructor(props?: TextBlockComponentProps) {\n this._styleOverrides = TextStyleSettings.cloneProps(props?.styleOverrides ?? {});\n }\n\n /** Deviations in individual properties of the [[TextStyleSettings]] in the [AnnotationTextStyle]($backend) specified by `styleId` on the [[TextBlock]].\n * For example, if the style uses the \"Arial\" font, you can override that by settings `styleOverrides.fontName` to \"Comic Sans\".\n * @see [[clearStyleOverrides]] to reset this to an empty object.\n */\n public get styleOverrides(): TextStyleSettingsProps {\n return this._styleOverrides;\n }\n\n public set styleOverrides(overrides: TextStyleSettingsProps) {\n this._styleOverrides = TextStyleSettings.cloneProps(overrides);\n }\n\n /** Reset any [[styleOverrides]] applied to this component. */\n public clearStyleOverrides(_options?: ClearTextStyleOptions): void {\n this.styleOverrides = { };\n }\n\n /** Returns true if [[styleOverrides]] specifies any deviations from the [[TextBlock]]'s [AnnotationTextStyle]($backend). */\n public get overridesStyle(): boolean {\n return Object.keys(this.styleOverrides).length > 0;\n }\n\n /** Create a deep copy of this component. */\n public abstract clone(): TextBlockComponent;\n\n /** Compute a string representation of the contents of this component and all of its sub-components. */\n public abstract stringify(options?: TextBlockStringifyOptions): string;\n\n /**\n * Returns true if the string representation of this component consists only of whitespace characters.\n * Useful for checking if the component is visually empty (producing no graphics) or contains only spaces, tabs, or line breaks.\n */\n public get isWhitespace(): boolean {\n return /^\\s*$/g.test(this.stringify());\n };\n\n /** Convert this component to its JSON representation. */\n public toJSON(): TextBlockComponentProps {\n return {\n styleOverrides: TextStyleSettings.cloneProps(this.styleOverrides),\n };\n }\n\n /** Returns true if `this` is equivalent to `other`. */\n public equals(other: TextBlockComponent): boolean {\n const myKeys = Object.keys(this.styleOverrides);\n const yrKeys = Object.keys(other._styleOverrides);\n if (myKeys.length !== yrKeys.length) {\n return false;\n }\n\n for (const name of myKeys) {\n const key = name as keyof TextStyleSettingsProps;\n if (this.styleOverrides[key] !== other.styleOverrides[key]) {\n return false;\n }\n }\n\n return true;\n }\n}\n\n/**\n * @beta\n */\nexport type Run = TextRun | FractionRun | TabRun | LineBreakRun;\n\n/** The JSON representation of a [[Run]].\n * Use the `type` field to discriminate between the different kinds of runs.\n * @beta\n */\nexport type RunProps = TextRunProps | FractionRunProps | TabRunProps | LineBreakRunProps;\n\n/** A sequence of characters within a [[Paragraph]] that share a single style. Runs are the leaf nodes of a [[TextBlock]] document. When laid out for display, a single run may span\n * multiple lines, but it will never contain different styling.\n * Use the `type` field to discriminate between the different kinds of runs.\n * @beta\n */\nexport namespace Run { // eslint-disable-line @typescript-eslint/no-redeclare\n /** Create a run from its JSON representation.\n * @see [[TextRun.create]], [[FractionRun.create]], and [[LineBreakRun.create]] to create a run directly.\n */\n export function fromJSON(props: RunProps): Run {\n switch (props.type) {\n case \"text\": return TextRun.create(props);\n case \"fraction\": return FractionRun.create(props);\n case \"tab\": return TabRun.create(props);\n case \"linebreak\": return LineBreakRun.create(props);\n }\n }\n}\n\n/** Describes whether the characters of a [[TextRun]] should be displayed normally, in subscript, or in superscript.\n * [[TextStyleSettings.superScriptScale]], [[TextStyleSettings.subScriptScale]], [[TextStyleSettings.superScriptOffsetFactor]], and [[TextStyleSettings.subScriptOffsetFactor]]\n * affect how the content is rendered.\n * @beta\n */\nexport type BaselineShift = \"subscript\" | \"superscript\" | \"none\";\n\n/** JSON representation of a [[TextRun]].\n * @beta\n */\nexport interface TextRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"text\";\n /** The characters displayed by the run.\n * Default: an empty string.\n */\n content?: string;\n /** Whether to display [[content]] as a subscript, superscript, or normally.\n * Default: \"none\"\n */\n baselineShift?: BaselineShift;\n}\n\n/** The most common type of [[Run]], containing a sequence of characters to be displayed using a single style.\n * @beta\n */\nexport class TextRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"text\";\n /** The sequence of characters to be displayed by the run. */\n public content: string;\n /** Whether to display [[content]] as a subscript, superscript, or normally. */\n public baselineShift: BaselineShift;\n\n private constructor(props?: Omit<TextRunProps, \"type\">) {\n super(props);\n this.content = props?.content ?? \"\";\n this.baselineShift = props?.baselineShift ?? \"none\";\n }\n\n public override clone(): TextRun {\n return new TextRun(this.toJSON());\n }\n\n public override toJSON(): TextRunProps {\n return {\n ...super.toJSON(),\n type: \"text\",\n content: this.content,\n baselineShift: this.baselineShift,\n };\n }\n\n public static create(props?: Omit<TextRunProps, \"type\">): TextRun {\n return new TextRun(props);\n }\n\n /** Simply returns [[content]]. */\n public override stringify(): string {\n return this.content;\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof TextRun && this.content === other.content && this.baselineShift === other.baselineShift && super.equals(other);\n }\n}\n\n/** JSON representation of a [[FractionRun]].\n * @beta\n */\nexport interface FractionRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"fraction\";\n /** The text displayed before or above the fraction separator, depending on [[TextStyleSettings.stackedFractionType]]. Default: an empty string. */\n numerator?: string;\n /** The text displayed after or below the fraction separator, depending on [[TextStyleSettings.stackedFractionType]]. Default: an empty string. */\n denominator?: string;\n}\n\n/** A [[Run]] containing a numeric ratio to be displayed as a numerator and denominator separated by a horizontal or diagonal bar.\n * @note The [[numerator]] and [[denominator]] are stored as strings. They are not technically required to contain a numeric representation.\n * @beta\n */\nexport class FractionRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"fraction\";\n /** The fraction's numerator. */\n public numerator: string;\n /** The fraction's denominator. */\n public denominator: string;\n\n private constructor(props?: Omit<FractionRunProps, \"type\">) {\n super(props);\n this.numerator = props?.numerator ?? \"\";\n this.denominator = props?.denominator ?? \"\";\n }\n\n public override toJSON(): FractionRunProps {\n return {\n ...super.toJSON(),\n type: \"fraction\",\n numerator: this.numerator,\n denominator: this.denominator,\n };\n }\n\n public override clone(): FractionRun {\n return new FractionRun(this.toJSON());\n }\n\n public static create(props?: Omit<FractionRunProps, \"type\">): FractionRun {\n return new FractionRun(props);\n }\n\n /** Formats the fraction as a string with the [[numerator]] and [[denominator]] separated by [[TextBlockStringifyOptions.fractionSeparator]]. */\n public override stringify(options?: TextBlockStringifyOptions): string {\n const sep = options?.fractionSeparator ?? \"/\";\n return `${this.numerator}${sep}${this.denominator}`;\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof FractionRun && this.numerator === other.numerator && this.denominator === other.denominator && super.equals(other);\n }\n}\n\n/** JSON representation of a [[LineBreakRun]].\n * @beta\n */\nexport interface LineBreakRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"linebreak\";\n}\n\n/** A [[Run]] that represents the end of a line of text within a [[Paragraph]]. It contains no content of its own - it simply causes subsequent content to display on a new line.\n * @beta\n */\nexport class LineBreakRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"linebreak\";\n\n private constructor(props?: TextBlockComponentProps) {\n super(props);\n }\n\n public override toJSON(): LineBreakRunProps {\n return {\n ...super.toJSON(),\n type: \"linebreak\",\n };\n }\n\n public static create(props?: TextBlockComponentProps) {\n return new LineBreakRun(props);\n }\n\n public override clone(): LineBreakRun {\n return new LineBreakRun(this.toJSON());\n }\n\n /** Simply returns [[TextBlockStringifyOptions.lineBreak]]. */\n public override stringify(options?: TextBlockStringifyOptions): string {\n return options?.lineBreak ?? \" \";\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof LineBreakRun && super.equals(other);\n }\n}\n\n/** JSON representation of a [[TabRun]].\n * @beta\n */\nexport interface TabRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"tab\";\n}\n\n/** A [[TabRun]] is used to shift the next tab stop.\n * @note Only left-justified tabs are supported at this tab.\n * @beta\n */\nexport class TabRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"tab\";\n\n public override toJSON(): TabRunProps {\n return {\n ...super.toJSON(),\n type: \"tab\",\n };\n }\n\n public override clone(): TabRun {\n return new TabRun(this.toJSON());\n }\n\n public static create(props?: Omit<TabRunProps, \"type\">): TabRun {\n return new TabRun(props);\n }\n\n /**\n * Converts a [[TabRun]] to its string representation.\n * If the `tabsAsSpaces` option is provided, returns a string of spaces of the specified length.\n * Otherwise, returns a tab character (\"\\t\").\n */\n public override stringify(options?: TextBlockStringifyOptions): string {\n if (options?.tabsAsSpaces) {\n return \" \".repeat(options.tabsAsSpaces);\n }\n\n return \"\\t\";\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof TabRun && super.equals(other);\n }\n}\n\n/** JSON representation of a [[Paragraph]].\n * @beta\n */\nexport interface ParagraphProps extends TextBlockComponentProps {\n /** The collection of [[Run]]s within the paragraph.\n * Default: an empty array.\n */\n runs?: RunProps[];\n}\n\n/** A collection of [[Run]]s within a [[TextBlock]]. Each paragraph within a text block is laid out on a separate line.\n * @beta\n */\nexport class Paragraph extends TextBlockComponent {\n /** The runs within the paragraph. You can modify the contents of this array to change the content of the paragraph. */\n public readonly runs: Run[];\n\n private constructor(props?: ParagraphProps) {\n super(props);\n this.runs = props?.runs?.map((run) => Run.fromJSON(run)) ?? [];\n }\n\n public override toJSON(): ParagraphProps {\n return {\n ...super.toJSON(),\n runs: this.runs.map((run) => run.toJSON()),\n };\n }\n\n /** Create a paragraph from its JSON representation. */\n public static create(props?: ParagraphProps): Paragraph {\n return new Paragraph(props);\n }\n\n public override clone(): Paragraph {\n return new Paragraph(this.toJSON());\n }\n\n /**\n * Clears any [[styleOverrides]] applied to this Paragraph.\n * Will also clear [[styleOverrides]] from all child components unless [[ClearTextStyleOptions.preserveChildrenOverrides]] is `true`.\n */\n public override clearStyleOverrides(options?: ClearTextStyleOptions): void {\n super.clearStyleOverrides();\n if (options?.preserveChildrenOverrides)\n return;\n\n for (const run of this.runs) {\n run.clearStyleOverrides();\n }\n }\n\n /** Compute a string representation of this paragraph by concatenating the string representations of all of its [[runs]]. */\n public override stringify(options?: TextBlockStringifyOptions): string {\n return this.runs.map((x) => x.stringify(options)).join(\"\");\n }\n\n public override equals(other: TextBlockComponent): boolean {\n if (!(other instanceof Paragraph)) {\n return false;\n }\n\n if (this.runs.length !== other.runs.length || !super.equals(other)) {\n return false;\n }\n\n return this.runs.every((run, index) => run.equals(other.runs[index]));\n }\n}\n\n/** Describes the relative alignment of the content of a [[TextBlock]].\n * @beta\n */\nexport type TextBlockJustification = \"left\" | \"center\" | \"right\";\n\n/** Describes the margins around the content inside a [[TextBlock]]. It's measured in meters.\n * @beta\n */\nexport interface TextBlockMargins {\n /** The left margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n left: number;\n /** The right margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n right: number;\n /** The top margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n top: number;\n /** The bottom margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n bottom: number;\n};\n\n/** JSON representation of a [[TextBlock]].\n * @beta\n */\nexport interface TextBlockProps extends TextBlockComponentProps {\n /** The ID of an [AnnotationTextStyle]($backend) stored in the iModel from which the base [[TextStyleSettings]] applied to the [[TextBlock]] originates. */\n styleId: Id64String;\n /** The width of the document in meters. Lines that would exceed this width are instead wrapped around to the next line if possible.\n * A value less than or equal to zero indicates no wrapping is to be applied.\n * Default: 0\n */\n width?: number;\n /** The alignment of the document content. Default: \"left\". */\n justification?: TextBlockJustification;\n /** The margins to surround the document content. Default: 0 margins on all sides */\n margins?: Partial<TextBlockMargins>;\n /** The paragraphs within the text block. Default: an empty array. */\n paragraphs?: ParagraphProps[];\n}\n\n/** Represents a formatted text document consisting of a series of [[Paragraph]]s, each laid out on a separate line and containing their own content in the form of [[Run]]s.\n * You can change the content of the document by directly modifying the contents of its [[paragraphs]], or via [[appendParagraph]] and [[appendRun]].\n * No word-wrapping is applied to the document unless a [[width]] greater than zero is specified.\n * @see [[TextAnnotation]] to position a text block as an annotation in 2d or 3d space.\n * @beta\n */\nexport class TextBlock extends TextBlockComponent {\n /** The ID of the [AnnotationTextStyle]($backend) that provides the base formatting for the contents of this TextBlock.\n * @note Assigning to this property retains all style overrides on the TextBlock and its child components.\n * Call [[clearStyleOverrides]] to clear the TextBlock's and optionally all children's style overrides.\n */\n public styleId: Id64String;\n /** The width of the document in meters. Lines that would exceed this width are instead wrapped around to the next line if possible.\n * A value less than or equal to zero indicates no wrapping is to be applied.\n * Default: 0\n */\n public width: number;\n /** The alignment of the document's content. */\n public justification: TextBlockJustification;\n /** The margins of the document. */\n public margins: TextBlockMargins;\n /** The ordered list of paragraphs within the document. */\n public readonly paragraphs: Paragraph[];\n\n private constructor(props: TextBlockProps) {\n super(props);\n this.styleId = props.styleId;\n this.width = props.width ?? 0;\n this.justification = props.justification ?? \"left\";\n\n // Assign default margins if not provided\n this.margins = {\n left: props.margins?.left ?? 0,\n right: props.margins?.right ?? 0,\n top: props.margins?.top ?? 0,\n bottom: props.margins?.bottom ?? 0,\n };\n\n this.paragraphs = props.paragraphs?.map((x) => Paragraph.create(x)) ?? [];\n }\n\n public override toJSON(): TextBlockProps {\n return {\n ...super.toJSON(),\n styleId: this.styleId,\n width: this.width,\n justification: this.justification,\n margins: this.margins,\n paragraphs: this.paragraphs.map((x) => x.toJSON()),\n };\n }\n\n /** Create a text block from its JSON representation. */\n public static create(props: TextBlockProps): TextBlock {\n return new TextBlock(props);\n }\n\n /** Create an empty text block containing no [[paragraphs]] and an empty [[styleId]]. */\n public static createEmpty(): TextBlock {\n return TextBlock.create({ styleId: \"\" });\n }\n\n /** Returns true if every paragraph in this text block is empty. */\n public get isEmpty(): boolean {\n return this.paragraphs.every((p) => p.runs.length === 0);\n }\n\n public override clone(): TextBlock {\n return new TextBlock(this.toJSON());\n }\n\n /**\n * Clears any [[styleOverrides]] applied to this TextBlock.\n * Will also clear [[styleOverrides]] from all child components unless [[ClearTextStyleOptions.preserveChildrenOverrides]] is `true`.\n */\n public override clearStyleOverrides(options?: ClearTextStyleOptions): void {\n super.clearStyleOverrides();\n if (options?.preserveChildrenOverrides)\n return;\n\n for (const paragraph of this.paragraphs) {\n paragraph.clearStyleOverrides();\n }\n }\n\n /** Compute a string representation of the document's contents by concatenating the string representations of each of its [[paragraphs]], separated by [[TextBlockStringifyOptions.paragraphBreak]]. */\n public stringify(options?: TextBlockStringifyOptions): string {\n return this.paragraphs.map((x) => x.stringify(options)).join(options?.paragraphBreak ?? \" \");\n }\n\n /** Add and return a new paragraph.\n * By default, the paragraph will be created with no [[styleOverrides]], so that it inherits the style of this block.\n * @param seedFromLast If true and [[paragraphs]] is not empty, the new paragraph will inherit the style overrides of the last [[Paragraph]] in this block.\n */\n public appendParagraph(seedFromLast: boolean = false): Paragraph {\n let styleOverrides: TextStyleSettingsProps = {};\n\n if (seedFromLast && this.paragraphs.length > 0) {\n const seed = this.paragraphs[this.paragraphs.length - 1];\n styleOverrides = { ...seed.styleOverrides };\n }\n\n const paragraph = Paragraph.create({\n styleOverrides\n });\n\n this.paragraphs.push(paragraph);\n return paragraph;\n }\n\n /** Append a run to the last [[Paragraph]] in this block.\n * If the block contains no [[paragraphs]], a new one will first be created using [[appendParagraph]].\n */\n public appendRun(run: Run): void {\n const paragraph = this.paragraphs[this.paragraphs.length - 1] ?? this.appendParagraph();\n paragraph.runs.push(run);\n }\n\n public override equals(other: TextBlockComponent): boolean {\n if (!(other instanceof TextBlock)) {\n return false;\n }\n\n if (this.styleId !== other.styleId || !super.equals(other)) {\n return false;\n }\n\n if (this.width !== other.width || this.justification !== other.justification || this.paragraphs.length !== other.paragraphs.length) {\n return false;\n }\n\n const marginsAreEqual = Object.entries(this.margins).every(([key, value]) =>\n value === (other.margins as any)[key]\n );\n\n if (!marginsAreEqual) return false;\n\n return this.paragraphs.every((paragraph, index) => paragraph.equals(other.paragraphs[index]));\n }\n}\n"]}
1
+ {"version":3,"file":"TextBlock.js","sourceRoot":"","sources":["../../../src/annotation/TextBlock.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,2CAAwE;AA4CxE;;;GAGG;AACH,MAAsB,kBAAkB;IAC9B,eAAe,CAAyB;IAEhD,gBAAgB;IAChB,YAAsB,KAA+B;QACnD,IAAI,CAAC,eAAe,GAAG,6BAAiB,CAAC,UAAU,CAAC,KAAK,EAAE,cAAc,IAAI,EAAE,CAAC,CAAC;IACnF,CAAC;IAED;;;OAGG;IACH,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED,IAAW,cAAc,CAAC,SAAiC;QACzD,IAAI,CAAC,eAAe,GAAG,6BAAiB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACjE,CAAC;IAED,8DAA8D;IACvD,mBAAmB,CAAC,QAAgC;QACzD,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;IAC3B,CAAC;IAED,4HAA4H;IAC5H,IAAW,cAAc;QACvB,OAAO,MAAM,CAAC,IAAI,CAAC,IAA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AI,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3D,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,aAAa,KAAK,KAAK,CAAC,aAAa,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YACnI,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAC1E,KAAK,KAAM,KAAK,CAAC,OAAe,CAAC,GAAG,CAAC,CACtC,CAAC;QAEF,IAAI,CAAC,eAAe;YAAE,OAAO,KAAK,CAAC;QAEnC,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChG,CAAC;CACF;AArID,8BAqIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Annotation\n */\n\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { TextStyleSettings, TextStyleSettingsProps } from \"./TextStyle\";\n\n/** Options supplied to [[TextBlockComponent.clearStyleOverrides]] to control how the style overrides are cleared on the component and its child components.\n * @beta\n */\nexport interface ClearTextStyleOptions {\n /** Controls whether the styleOverrides of any child components are retained.\n * By default, all overrides are cleared.\n */\n preserveChildrenOverrides?: boolean;\n}\n\n/** The JSON representation of a [[TextBlockComponent]].\n * @beta\n */\nexport interface TextBlockComponentProps {\n /** Deviations from the base [[TextStyleSettings]] defined by the [AnnotationTextStyle]($backend) applied to this component.\n * This permits you to, e.g., create a [[TextBlock]] using \"Arial\" font and override one of its [[TextRun]]s to use \"Comic Sans\" instead.\n */\n styleOverrides?: TextStyleSettingsProps;\n}\n\n/** Options supplied to [[TextBlockComponent.stringify]] to control how the content is formatted.\n * @beta\n */\nexport interface TextBlockStringifyOptions {\n /** A string to insert in between each [[Paragraph]].\n * Default: \" \" - a single space.\n */\n paragraphBreak?: string;\n /** A string to insert for each [[LineBreakRun]].\n * Default: \" \" - a single space.\n */\n lineBreak?: string;\n /** A string to insert between the numerator and denominator of each [[FractionRun]].\n * Default: \"/\"\n */\n fractionSeparator?: string;\n /** The number of spaces to use for tabs. If not provided, tabs will be represented by a tab character: \"\\t\".\n * Default: \"undefined\" - use \"\\t\".\n */\n tabsAsSpaces?: number;\n}\n\n/** Abstract representation of any of the building blocks that make up a [[TextBlock]] document - namely [[Run]]s, [[Paragraph]]s, and [[TextBlock]] itself.\n * The [[TextBlock]] can specify an [AnnotationTextStyle]($backend) that formats its contents. Each component can specify an optional [[styleOverrides]] to customize that formatting.\n * @beta\n */\nexport abstract class TextBlockComponent {\n private _styleOverrides: TextStyleSettingsProps;\n\n /** @internal */\n protected constructor(props?: TextBlockComponentProps) {\n this._styleOverrides = TextStyleSettings.cloneProps(props?.styleOverrides ?? {});\n }\n\n /** Deviations in individual properties of the [[TextStyleSettings]] in the [AnnotationTextStyle]($backend) specified by `styleId` on the [[TextBlock]].\n * For example, if the style uses the \"Arial\" font, you can override that by settings `styleOverrides.fontName` to \"Comic Sans\".\n * @see [[clearStyleOverrides]] to reset this to an empty object.\n */\n public get styleOverrides(): TextStyleSettingsProps {\n return this._styleOverrides;\n }\n\n public set styleOverrides(overrides: TextStyleSettingsProps) {\n this._styleOverrides = TextStyleSettings.cloneProps(overrides);\n }\n\n /** Reset any [[styleOverrides]] applied to this component. */\n public clearStyleOverrides(_options?: ClearTextStyleOptions): void {\n this.styleOverrides = {};\n }\n\n /** Returns true if [[styleOverrides]] specifies any deviations from the [[TextBlock]]'s [AnnotationTextStyle]($backend). */\n public get overridesStyle(): boolean {\n return Object.keys(this.styleOverrides).length > 0;\n }\n\n /** Create a deep copy of this component. */\n public abstract clone(): TextBlockComponent;\n\n /** Compute a string representation of the contents of this component and all of its sub-components. */\n public abstract stringify(options?: TextBlockStringifyOptions): string;\n\n /**\n * Returns true if the string representation of this component consists only of whitespace characters.\n * Useful for checking if the component is visually empty (producing no graphics) or contains only spaces, tabs, or line breaks.\n */\n public get isWhitespace(): boolean {\n return /^\\s*$/g.test(this.stringify());\n };\n\n /** Convert this component to its JSON representation. */\n public toJSON(): TextBlockComponentProps {\n return {\n styleOverrides: TextStyleSettings.cloneProps(this.styleOverrides),\n };\n }\n\n /** Returns true if `this` is equivalent to `other`. */\n public equals(other: TextBlockComponent): boolean {\n const myKeys = Object.keys(this.styleOverrides);\n const yrKeys = Object.keys(other._styleOverrides);\n if (myKeys.length !== yrKeys.length) {\n return false;\n }\n\n for (const name of myKeys) {\n const key = name as keyof TextStyleSettingsProps;\n if (this.styleOverrides[key] !== other.styleOverrides[key]) {\n return false;\n }\n }\n\n return true;\n }\n}\n\n/** [[TextBlockComponent]]s contained within a [[Paragraph]].\n * @beta\n */\nexport type Run = TextRun | FractionRun | TabRun | LineBreakRun | FieldRun;\n\n/** The JSON representation of a [[Run]].\n * Use the `type` field to discriminate between the different kinds of runs.\n * @beta\n */\nexport type RunProps = TextRunProps | FractionRunProps | TabRunProps | LineBreakRunProps | FieldRunProps;\n\n/** A sequence of characters within a [[Paragraph]] that share a single style. Runs are the leaf nodes of a [[TextBlock]] document. When laid out for display, a single run may span\n * multiple lines, but it will never contain different styling.\n * Use the `type` field to discriminate between the different kinds of runs.\n * @beta\n */\nexport namespace Run { // eslint-disable-line @typescript-eslint/no-redeclare\n /** Create a run from its JSON representation.\n * @see [[TextRun.create]], [[FractionRun.create]], and [[LineBreakRun.create]] to create a run directly.\n */\n export function fromJSON(props: RunProps): Run {\n switch (props.type) {\n case \"text\": return TextRun.create(props);\n case \"fraction\": return FractionRun.create(props);\n case \"tab\": return TabRun.create(props);\n case \"linebreak\": return LineBreakRun.create(props);\n case \"field\": return FieldRun.create(props);\n }\n }\n}\n\n/** Describes whether the characters of a [[TextRun]] should be displayed normally, in subscript, or in superscript.\n * [[TextStyleSettings.superScriptScale]], [[TextStyleSettings.subScriptScale]], [[TextStyleSettings.superScriptOffsetFactor]], and [[TextStyleSettings.subScriptOffsetFactor]]\n * affect how the content is rendered.\n * @beta\n */\nexport type BaselineShift = \"subscript\" | \"superscript\" | \"none\";\n\n/** JSON representation of a [[TextRun]].\n * @beta\n */\nexport interface TextRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"text\";\n /** The characters displayed by the run.\n * Default: an empty string.\n */\n content?: string;\n /** Whether to display [[content]] as a subscript, superscript, or normally.\n * Default: \"none\"\n */\n baselineShift?: BaselineShift;\n}\n\n/** The most common type of [[Run]], containing a sequence of characters to be displayed using a single style.\n * @beta\n */\nexport class TextRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"text\";\n /** The sequence of characters to be displayed by the run. */\n public content: string;\n /** Whether to display [[content]] as a subscript, superscript, or normally. */\n public baselineShift: BaselineShift;\n\n private constructor(props?: Omit<TextRunProps, \"type\">) {\n super(props);\n this.content = props?.content ?? \"\";\n this.baselineShift = props?.baselineShift ?? \"none\";\n }\n\n public override clone(): TextRun {\n return new TextRun(this.toJSON());\n }\n\n public override toJSON(): TextRunProps {\n return {\n ...super.toJSON(),\n type: \"text\",\n content: this.content,\n baselineShift: this.baselineShift,\n };\n }\n\n public static create(props?: Omit<TextRunProps, \"type\">): TextRun {\n return new TextRun(props);\n }\n\n /** Simply returns [[content]]. */\n public override stringify(): string {\n return this.content;\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof TextRun && this.content === other.content && this.baselineShift === other.baselineShift && super.equals(other);\n }\n}\n\n/** JSON representation of a [[FractionRun]].\n * @beta\n */\nexport interface FractionRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"fraction\";\n /** The text displayed before or above the fraction separator, depending on [[TextStyleSettings.stackedFractionType]]. Default: an empty string. */\n numerator?: string;\n /** The text displayed after or below the fraction separator, depending on [[TextStyleSettings.stackedFractionType]]. Default: an empty string. */\n denominator?: string;\n}\n\n/** A [[Run]] containing a numeric ratio to be displayed as a numerator and denominator separated by a horizontal or diagonal bar.\n * @note The [[numerator]] and [[denominator]] are stored as strings. They are not technically required to contain a numeric representation.\n * @beta\n */\nexport class FractionRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"fraction\";\n /** The fraction's numerator. */\n public numerator: string;\n /** The fraction's denominator. */\n public denominator: string;\n\n private constructor(props?: Omit<FractionRunProps, \"type\">) {\n super(props);\n this.numerator = props?.numerator ?? \"\";\n this.denominator = props?.denominator ?? \"\";\n }\n\n public override toJSON(): FractionRunProps {\n return {\n ...super.toJSON(),\n type: \"fraction\",\n numerator: this.numerator,\n denominator: this.denominator,\n };\n }\n\n public override clone(): FractionRun {\n return new FractionRun(this.toJSON());\n }\n\n public static create(props?: Omit<FractionRunProps, \"type\">): FractionRun {\n return new FractionRun(props);\n }\n\n /** Formats the fraction as a string with the [[numerator]] and [[denominator]] separated by [[TextBlockStringifyOptions.fractionSeparator]]. */\n public override stringify(options?: TextBlockStringifyOptions): string {\n const sep = options?.fractionSeparator ?? \"/\";\n return `${this.numerator}${sep}${this.denominator}`;\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof FractionRun && this.numerator === other.numerator && this.denominator === other.denominator && super.equals(other);\n }\n}\n\n/** JSON representation of a [[LineBreakRun]].\n * @beta\n */\nexport interface LineBreakRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"linebreak\";\n}\n\n/** A [[Run]] that represents the end of a line of text within a [[Paragraph]]. It contains no content of its own - it simply causes subsequent content to display on a new line.\n * @beta\n */\nexport class LineBreakRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"linebreak\";\n\n private constructor(props?: TextBlockComponentProps) {\n super(props);\n }\n\n public override toJSON(): LineBreakRunProps {\n return {\n ...super.toJSON(),\n type: \"linebreak\",\n };\n }\n\n public static create(props?: TextBlockComponentProps) {\n return new LineBreakRun(props);\n }\n\n public override clone(): LineBreakRun {\n return new LineBreakRun(this.toJSON());\n }\n\n /** Simply returns [[TextBlockStringifyOptions.lineBreak]]. */\n public override stringify(options?: TextBlockStringifyOptions): string {\n return options?.lineBreak ?? \" \";\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof LineBreakRun && super.equals(other);\n }\n}\n\n/** JSON representation of a [[TabRun]].\n * @beta\n */\nexport interface TabRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"tab\";\n}\n\n/** A [[TabRun]] is used to shift the next tab stop.\n * @note Only left-justified tabs are supported at this tab.\n * @beta\n */\nexport class TabRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"tab\";\n\n public override toJSON(): TabRunProps {\n return {\n ...super.toJSON(),\n type: \"tab\",\n };\n }\n\n public override clone(): TabRun {\n return new TabRun(this.toJSON());\n }\n\n public static create(props?: Omit<TabRunProps, \"type\">): TabRun {\n return new TabRun(props);\n }\n\n /**\n * Converts a [[TabRun]] to its string representation.\n * If the `tabsAsSpaces` option is provided, returns a string of spaces of the specified length.\n * Otherwise, returns a tab character (\"\\t\").\n */\n public override stringify(options?: TextBlockStringifyOptions): string {\n if (options?.tabsAsSpaces) {\n return \" \".repeat(options.tabsAsSpaces);\n }\n\n return \"\\t\";\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof TabRun && super.equals(other);\n }\n}\n\n/** A chain of property accesses that resolves to a primitive value that forms the basis of the displayed content\n * of a [[FieldRun]].\n * The simplest property paths consist of a [[propertyName]] and nothing else, where `propertyName` identifies\n * a primitive property.\n * If `propertyName` identifies a struct or array property, then additional [[accessors]] are required to identify the specific value.\n * If `propertyName` (including any [[accessors]]) resolves to a JSON property, then additional [[jsonAccessors]] are required to identify a specific value within the JSON.\n * Some examples:\n * ```\n * | Access String | propertyName | accessors | jsonAccessors |\n * | ------------- | ------------ | --------- | ------------- |\n * | name | \"name\" | undefined | undefined |\n * | spouse.name | \"spouse\" | [name] | undefined |\n * | colors[2] | \"colors\" | [2] | undefined |\n * | spouse.favoriteRestaurants[1].address | \"spouse\" | [\"favoriteRestaurants\", 1, \"address\"] | undefined |\n * | jsonProperties.contactInfo.email | \"jsonProperties\" | undefined | [\"contactInfo\", \"email\"] |\n * | spouse.jsonProperties.contactInfo.phoneNumbers[0].areaCode | \"spouse\" | [\"jsonProperties\"] | [\"contactInfo\", \"phoneNumbers\", 0, \"areaCode\"] |\n * ```\n * @beta\n */\nexport interface FieldPropertyPath {\n /** The name of the BIS property of the [[FieldPropertyHost]] that serves as the root of the path. */\n propertyName: string;\n /** Property names and/or array indices describing the path from [[propertyName]] to the ultimate BIS property. */\n accessors?: Array<string | number>;\n /** If [[propertyName]] and [[accessors]] (if defined) resolve to a BIS property of extended type `Json`, property names and/or\n * array indices for selecting a primitive value within the JSON.\n */\n jsonAccessors?: Array<string | number>;\n}\n\n/** Describes the source of the property value against which a [[FieldPropertyPath]] is evaluated.\n * A field property is always hosted by an [Element]($backend). It may be a property of the element's BIS class itself,\n * or that of one of its [ElementAspect]($backend)s.\n * The [[schemaName]] and [[className]] should always identify the exact class that contains [[FieldPropertyPath.propertyName]] - not a subclass thereof.\n * @beta\n */\nexport interface FieldPropertyHost {\n /** The Id of the [Element]($backend) that hosts the property. */\n elementId: Id64String;\n /** The name of the schema containing the class identified by [[className]]. */\n schemaName: string;\n /** The name of the exact class (not a subclass) containing the property identified by [[FieldPropertyPath.propertyName]]. */\n className: string;\n}\n\n/** Placeholder type for a description of how to format the raw property value resolved by a [[FieldPropertyPath]] into a [[FieldRun]]'s display string.\n * *** COMING SOON ***\n * @beta\n */\nexport interface FieldFormatter { [k: string]: any }\n\n/** JSON representation of a [[FieldRun]].\n * @beta\n */\nexport interface FieldRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"field\";\n /** The element and BIS class containing the property described by [[propertyPath]]. */\n propertyHost: FieldPropertyHost;\n /** Describes how to obtain the property value from [[propertyHost]]. */\n propertyPath: FieldPropertyPath;\n /** Specifies how to format the property value obtained from [[propertyPath]] into a string to be stored in [[cachedContent]]. */\n formatter?: FieldFormatter;\n /** The field's most recently evaluated display string. */\n cachedContent?: string;\n}\n\n/** A [[Run]] that displays the formatted value of a property of some [Element]($backend).\n * When a [[TextBlock]] containing a [[FieldRun]] is written into the iModel as an [ITextAnnotation]($backend) element,\n * a dependency is established between the two elements via the [ElementDrivesTextAnnotation]($backend) relationship such that\n * whenever the source element specified by [[propertyHost]] is modified, the field(s) in the `ITextAnnotation` element are automatically\n * recalculated, causing their [[cachedContent]] to update. If the field's display string cannot be evaluated (for example, because the specified element or\n * property does not exist), then its cached content is set to [[FieldRun.invalidContentIndicator]].\n * A [[FieldRun]] displays its [[cachedContent]] in the same way that [[TextRun]]s display their `content`, including word wrapping where appropriate.\n * @beta\n */\nexport class FieldRun extends TextBlockComponent {\n /** Display string used to signal an error in computing the field's value. */\n public static invalidContentIndicator = \"####\";\n\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"field\";\n /** The element and BIS class containing the property described by [[propertyPath]]. */\n public readonly propertyHost: Readonly<FieldPropertyHost>;\n /** Describes how to obtain the property value from [[propertyHost]]. */\n public readonly propertyPath: Readonly<FieldPropertyPath>;\n /** Specifies how to format the property value obtained from [[propertyPath]] into a string to be stored in [[cachedContent]]. */\n public readonly formatter?: FieldFormatter;\n private _cachedContent: string;\n\n /** The field's most recently evaluated display string. */\n public get cachedContent(): string {\n return this._cachedContent;\n }\n\n /** @internal Used by core-backend when re-evaluating field content. */\n public setCachedContent(content: string | undefined): void {\n this._cachedContent = content ?? FieldRun.invalidContentIndicator;\n }\n\n private constructor(props: Omit<FieldRunProps, \"type\">) {\n super(props);\n\n this._cachedContent = props.cachedContent ?? FieldRun.invalidContentIndicator;\n this.propertyHost = props.propertyHost\n this.propertyPath = props.propertyPath;\n this.formatter = props.formatter;\n }\n\n /** Create a FieldRun from its JSON representation. */\n public static create(props: Omit<FieldRunProps, \"type\">): FieldRun {\n return new FieldRun({\n ...props,\n propertyHost: { ...props.propertyHost },\n propertyPath: structuredClone(props.propertyPath),\n formatter: structuredClone(props.formatter),\n });\n }\n\n /** Convert the FieldRun to its JSON representation. */\n public override toJSON(): FieldRunProps {\n const json: FieldRunProps = {\n ...super.toJSON(),\n type: \"field\",\n propertyHost: { ...this.propertyHost },\n propertyPath: structuredClone(this.propertyPath),\n };\n\n if (this.cachedContent !== FieldRun.invalidContentIndicator) {\n json.cachedContent = this.cachedContent;\n }\n\n if (this.formatter) {\n json.formatter = structuredClone(this.formatter);\n }\n\n return json;\n }\n\n /** Create a deep copy of this FieldRun. */\n public override clone(): FieldRun {\n return new FieldRun(this.toJSON());\n }\n\n /** Convert this FieldRun to a simple string representation. */\n public override stringify(): string {\n return this.cachedContent;\n }\n\n /** Returns true if `this` is equivalent to `other`. */\n public override equals(other: TextBlockComponent): boolean {\n if (!(other instanceof FieldRun) || !super.equals(other)) {\n return false;\n }\n\n if (\n this.propertyHost.elementId !== other.propertyHost.elementId ||\n this.propertyHost.className !== other.propertyHost.className ||\n this.propertyHost.schemaName !== other.propertyHost.schemaName\n ) {\n return false;\n }\n\n if (this.propertyPath.propertyName !== other.propertyPath.propertyName) {\n return false;\n }\n\n const thisAccessors = this.propertyPath.accessors ?? [];\n const otherAccessors = other.propertyPath.accessors ?? [];\n const thisJsonAccessors = this.propertyPath.jsonAccessors ?? [];\n const otherJsonAccessors = other.propertyPath.jsonAccessors ?? [];\n\n if (thisAccessors.length !== otherAccessors.length || thisJsonAccessors.length !== otherJsonAccessors.length) {\n return false;\n }\n\n if (!thisAccessors.every((value, index) => value === otherAccessors[index])) {\n return false;\n }\n\n if (!thisJsonAccessors.every((value, index) => value === otherJsonAccessors[index])) {\n return false;\n }\n\n if (this.formatter && other.formatter) {\n // ###TODO better comparison of formatter objects.\n if (JSON.stringify(this.formatter) !== JSON.stringify(other.formatter)) {\n return false;\n }\n } else if (this.formatter || other.formatter) {\n return false;\n }\n\n return true;\n }\n}\n\n/** JSON representation of a [[Paragraph]].\n * @beta\n */\nexport interface ParagraphProps extends TextBlockComponentProps {\n /** The collection of [[Run]]s within the paragraph.\n * Default: an empty array.\n */\n runs?: RunProps[];\n}\n\n/** A collection of [[Run]]s within a [[TextBlock]]. Each paragraph within a text block is laid out on a separate line.\n * @beta\n */\nexport class Paragraph extends TextBlockComponent {\n /** The runs within the paragraph. You can modify the contents of this array to change the content of the paragraph. */\n public readonly runs: Run[];\n\n private constructor(props?: ParagraphProps) {\n super(props);\n this.runs = props?.runs?.map((run) => Run.fromJSON(run)) ?? [];\n }\n\n public override toJSON(): ParagraphProps {\n return {\n ...super.toJSON(),\n runs: this.runs.map((run) => run.toJSON()),\n };\n }\n\n /** Create a paragraph from its JSON representation. */\n public static create(props?: ParagraphProps): Paragraph {\n return new Paragraph(props);\n }\n\n public override clone(): Paragraph {\n return new Paragraph(this.toJSON());\n }\n\n /**\n * Clears any [[styleOverrides]] applied to this Paragraph.\n * Will also clear [[styleOverrides]] from all child components unless [[ClearTextStyleOptions.preserveChildrenOverrides]] is `true`.\n */\n public override clearStyleOverrides(options?: ClearTextStyleOptions): void {\n super.clearStyleOverrides();\n if (options?.preserveChildrenOverrides)\n return;\n\n for (const run of this.runs) {\n run.clearStyleOverrides();\n }\n }\n\n /** Compute a string representation of this paragraph by concatenating the string representations of all of its [[runs]]. */\n public override stringify(options?: TextBlockStringifyOptions): string {\n return this.runs.map((x) => x.stringify(options)).join(\"\");\n }\n\n public override equals(other: TextBlockComponent): boolean {\n if (!(other instanceof Paragraph)) {\n return false;\n }\n\n if (this.runs.length !== other.runs.length || !super.equals(other)) {\n return false;\n }\n\n return this.runs.every((run, index) => run.equals(other.runs[index]));\n }\n}\n\n/** Describes the relative alignment of the content of a [[TextBlock]].\n * @beta\n */\nexport type TextBlockJustification = \"left\" | \"center\" | \"right\";\n\n/** Describes the margins around the content inside a [[TextBlock]]. It's measured in meters.\n * @beta\n */\nexport interface TextBlockMargins {\n /** The left margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n left: number;\n /** The right margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n right: number;\n /** The top margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n top: number;\n /** The bottom margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n bottom: number;\n};\n\n/** JSON representation of a [[TextBlock]].\n * @beta\n */\nexport interface TextBlockProps extends TextBlockComponentProps {\n /** The ID of an [AnnotationTextStyle]($backend) stored in the iModel from which the base [[TextStyleSettings]] applied to the [[TextBlock]] originates. */\n styleId: Id64String;\n /** The width of the document in meters. Lines that would exceed this width are instead wrapped around to the next line if possible.\n * A value less than or equal to zero indicates no wrapping is to be applied.\n * Default: 0\n */\n width?: number;\n /** The alignment of the document content. Default: \"left\". */\n justification?: TextBlockJustification;\n /** The margins to surround the document content. Default: 0 margins on all sides */\n margins?: Partial<TextBlockMargins>;\n /** The paragraphs within the text block. Default: an empty array. */\n paragraphs?: ParagraphProps[];\n}\n\n/** Represents a formatted text document consisting of a series of [[Paragraph]]s, each laid out on a separate line and containing their own content in the form of [[Run]]s.\n * You can change the content of the document by directly modifying the contents of its [[paragraphs]], or via [[appendParagraph]] and [[appendRun]].\n * No word-wrapping is applied to the document unless a [[width]] greater than zero is specified.\n * @see [[TextAnnotation]] to position a text block as an annotation in 2d or 3d space.\n * @beta\n */\nexport class TextBlock extends TextBlockComponent {\n /** The ID of the [AnnotationTextStyle]($backend) that provides the base formatting for the contents of this TextBlock.\n * @note Assigning to this property retains all style overrides on the TextBlock and its child components.\n * Call [[clearStyleOverrides]] to clear the TextBlock's and optionally all children's style overrides.\n */\n public styleId: Id64String;\n /** The width of the document in meters. Lines that would exceed this width are instead wrapped around to the next line if possible.\n * A value less than or equal to zero indicates no wrapping is to be applied.\n * Default: 0\n */\n public width: number;\n /** The alignment of the document's content. */\n public justification: TextBlockJustification;\n /** The margins of the document. */\n public margins: TextBlockMargins;\n /** The ordered list of paragraphs within the document. */\n public readonly paragraphs: Paragraph[];\n\n private constructor(props: TextBlockProps) {\n super(props);\n this.styleId = props.styleId;\n this.width = props.width ?? 0;\n this.justification = props.justification ?? \"left\";\n\n // Assign default margins if not provided\n this.margins = {\n left: props.margins?.left ?? 0,\n right: props.margins?.right ?? 0,\n top: props.margins?.top ?? 0,\n bottom: props.margins?.bottom ?? 0,\n };\n\n this.paragraphs = props.paragraphs?.map((x) => Paragraph.create(x)) ?? [];\n }\n\n public override toJSON(): TextBlockProps {\n return {\n ...super.toJSON(),\n styleId: this.styleId,\n width: this.width,\n justification: this.justification,\n margins: this.margins,\n paragraphs: this.paragraphs.map((x) => x.toJSON()),\n };\n }\n\n /** Create a text block from its JSON representation. */\n public static create(props: TextBlockProps): TextBlock {\n return new TextBlock(props);\n }\n\n /** Create an empty text block containing no [[paragraphs]] and an empty [[styleId]]. */\n public static createEmpty(): TextBlock {\n return TextBlock.create({ styleId: \"\" });\n }\n\n /** Returns true if every paragraph in this text block is empty. */\n public get isEmpty(): boolean {\n return this.paragraphs.every((p) => p.runs.length === 0);\n }\n\n public override clone(): TextBlock {\n return new TextBlock(this.toJSON());\n }\n\n /**\n * Clears any [[styleOverrides]] applied to this TextBlock.\n * Will also clear [[styleOverrides]] from all child components unless [[ClearTextStyleOptions.preserveChildrenOverrides]] is `true`.\n */\n public override clearStyleOverrides(options?: ClearTextStyleOptions): void {\n super.clearStyleOverrides();\n if (options?.preserveChildrenOverrides)\n return;\n\n for (const paragraph of this.paragraphs) {\n paragraph.clearStyleOverrides();\n }\n }\n\n /** Compute a string representation of the document's contents by concatenating the string representations of each of its [[paragraphs]], separated by [[TextBlockStringifyOptions.paragraphBreak]]. */\n public stringify(options?: TextBlockStringifyOptions): string {\n return this.paragraphs.map((x) => x.stringify(options)).join(options?.paragraphBreak ?? \" \");\n }\n\n /** Add and return a new paragraph.\n * By default, the paragraph will be created with no [[styleOverrides]], so that it inherits the style of this block.\n * @param seedFromLast If true and [[paragraphs]] is not empty, the new paragraph will inherit the style overrides of the last [[Paragraph]] in this block.\n */\n public appendParagraph(seedFromLast: boolean = false): Paragraph {\n let styleOverrides: TextStyleSettingsProps = {};\n\n if (seedFromLast && this.paragraphs.length > 0) {\n const seed = this.paragraphs[this.paragraphs.length - 1];\n styleOverrides = { ...seed.styleOverrides };\n }\n\n const paragraph = Paragraph.create({\n styleOverrides\n });\n\n this.paragraphs.push(paragraph);\n return paragraph;\n }\n\n /** Append a run to the last [[Paragraph]] in this block.\n * If the block contains no [[paragraphs]], a new one will first be created using [[appendParagraph]].\n */\n public appendRun(run: Run): void {\n const paragraph = this.paragraphs[this.paragraphs.length - 1] ?? this.appendParagraph();\n paragraph.runs.push(run);\n }\n\n public override equals(other: TextBlockComponent): boolean {\n if (!(other instanceof TextBlock)) {\n return false;\n }\n\n if (this.styleId !== other.styleId || !super.equals(other)) {\n return false;\n }\n\n if (this.width !== other.width || this.justification !== other.justification || this.paragraphs.length !== other.paragraphs.length) {\n return false;\n }\n\n const marginsAreEqual = Object.entries(this.margins).every(([key, value]) =>\n value === (other.margins as any)[key]\n );\n\n if (!marginsAreEqual) return false;\n\n return this.paragraphs.every((paragraph, index) => paragraph.equals(other.paragraphs[index]));\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WebAppRpcLogging.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcLogging.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;A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,CAAC,OAAO,IAAI,CAAC,gBAAgB,CAAC,yCAAyC,EAAE,MAAM,CAAC,CAAC;QAC3H,CAAC;IACH,CAAC;IAEkB,WAAW;QAC5B,OAAO,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,IAAI,iBAAiB,CAAC;IAChE,CAAC;IAEO,gBAAgB,CAAC,OAAe,EAAE,OAAyB;QACjE,MAAM,mBAAmB,GAAG,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC7E,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE/C,qBAAM,CAAC,OAAO,CAAC,2CAAoB,CAAC,oBAAoB,EAAE,GAAG,OAAO,IAAI,mBAAmB,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;YACpG,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,uGAAuG;YACvG,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,2DAA2D;YACnF,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,2DAA2D;YAC5F,GAAG,OAAO;SACX,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AAED,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,wBAAwB,EAAE,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { BentleyStatus, Logger } from \"@itwin/core-bentley\";\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\nimport { IModelError } from \"../../IModelError\";\nimport { RpcInterfaceDefinition } from \"../../RpcInterface\";\nimport { RpcProtocolEvent } from \"../core/RpcConstants\";\nimport { RpcInvocation } from \"../core/RpcInvocation\";\nimport { RpcOperation } from \"../core/RpcOperation\";\nimport { SerializedRpcOperation, SerializedRpcRequest } from \"../core/RpcProtocol\";\nimport { RpcRequest } from \"../core/RpcRequest\";\nimport { WebAppRpcRequest } from \"./WebAppRpcRequest\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** @internal */\nconst BACKEND = Symbol.for(\"@itwin.WebAppRpcLogging.Backend\");\nconst FRONTEND = Symbol.for(\"@itwin.WebAppRpcLogging.Frontend\");\n\n/** @internal */\nexport abstract class WebAppRpcLogging {\n public static initializeBackend(instance: WebAppRpcLogging) {\n (globalThis as any)[BACKEND] = instance;\n }\n\n public static initializeFrontend(instance: WebAppRpcLogging) {\n (globalThis as any)[FRONTEND] = instance;\n }\n\n private static get backend(): WebAppRpcLogging {\n const instance = (globalThis as any)[BACKEND];\n if (typeof (instance) === \"undefined\") {\n throw new IModelError(BentleyStatus.ERROR, \"Backend logging is not initialized.\");\n }\n\n return instance;\n }\n\n private static get frontend(): WebAppRpcLogging {\n const instance = (globalThis as any)[FRONTEND];\n if (typeof (instance) === \"undefined\") {\n throw new IModelError(BentleyStatus.ERROR, \"Frontend logging is not initialized.\");\n }\n\n return instance;\n }\n\n public static async logProtocolEvent(event: RpcProtocolEvent, object: RpcRequest | RpcInvocation): Promise<void> {\n if (object instanceof WebAppRpcRequest) {\n await WebAppRpcLogging.frontend.logProtocolEvent(event, object);\n } else if (object instanceof RpcInvocation) {\n await WebAppRpcLogging.backend.logProtocolEvent(event, object);\n }\n }\n\n protected abstract logProtocolEvent(event: RpcProtocolEvent, object: RpcRequest | RpcInvocation): Promise<void>;\n\n protected abstract getHostname(): string;\n\n protected getRpcInterfaceName(g: string | RpcInterfaceDefinition): string {\n return (typeof g === \"string\") ? g : g.interfaceName;\n }\n\n protected findPathIds(path: string) {\n let iTwinId = \"\";\n let iModelId = \"\";\n\n const tokens = path.split(\"/\");\n for (let i = 0; i !== tokens.length; ++i) {\n // For backwards compatibility, find old \"context\" or current \"iTwin\" terminology\n if ((/^context$/i).test(tokens[i]) || (/^itwin$/i).test(tokens[i])) {\n iTwinId = tokens[i + 1] || \"\";\n }\n\n if ((/^imodel$/i).test(tokens[i])) {\n iModelId = tokens[i + 1] || \"\";\n }\n }\n\n return { iTwinId, iModelId };\n }\n\n protected buildOperationDescriptor(operation: RpcOperation | SerializedRpcOperation): string {\n if (!operation) {\n return \"unknown.unknown\";\n }\n\n const interfaceName = typeof (operation.interfaceDefinition) === \"string\" ? operation.interfaceDefinition : operation.interfaceDefinition.interfaceName;\n const operationName = operation.operationName;\n return `${interfaceName}.${operationName}`;\n }\n\n protected logRequest(loggerCategory: string, message: string, object: WebAppRpcRequest | SerializedRpcRequest): void {\n const operationDescriptor = this.buildOperationDescriptor(object.operation);\n const pathIds = this.findPathIds(object.path);\n\n Logger.logTrace(loggerCategory, `${message}.${operationDescriptor}`, () => ({\n method: object.method,\n path: object.path,\n operation: object.operation.operationName,\n rpcInterface: this.getRpcInterfaceName(object.operation.interfaceDefinition),\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\n ActivityId: object.id, // eslint-disable-line @typescript-eslint/naming-convention\n TimeElapsed: (\"elapsed\" in object) ? object.elapsed : 0, // eslint-disable-line @typescript-eslint/naming-convention\n MachineName: this.getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\n ...pathIds,\n }));\n }\n\n protected logResponse(loggerCategory: string, message: string, object: WebAppRpcRequest | SerializedRpcRequest, status: number, elapsed: number): void {\n const operationDescriptor = this.buildOperationDescriptor(object.operation);\n const pathIds = this.findPathIds(object.path);\n\n Logger.logTrace(loggerCategory, `${message}.${operationDescriptor}`, () => ({\n method: object.method,\n path: object.path,\n operation: object.operation.operationName,\n rpcInterface: this.getRpcInterfaceName(object.operation.interfaceDefinition),\n status,\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\n ActivityId: object.id, // eslint-disable-line @typescript-eslint/naming-convention\n TimeElapsed: elapsed, // eslint-disable-line @typescript-eslint/naming-convention\n MachineName: this.getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\n ...pathIds,\n }));\n }\n}\n\ndeclare global {\n // eslint-disable-next-line no-var\n var window: any;\n}\n\nclass WebAppRpcLoggingFrontend extends WebAppRpcLogging {\n protected override async logProtocolEvent(event: RpcProtocolEvent, object: WebAppRpcRequest): Promise<void> {\n switch (event) {\n case RpcProtocolEvent.RequestCreated: return this.logRequest(CommonLoggerCategory.RpcInterfaceFrontend, \"RpcInterface.frontend.request\", object);\n case RpcProtocolEvent.ResponseLoaded: return this.logResponse(CommonLoggerCategory.RpcInterfaceFrontend, \"RpcInterface.frontend.response\", object, object.metadata.status, object.elapsed);\n case RpcProtocolEvent.ConnectionErrorReceived: return this.logErrorFrontend(\"RpcInterface.frontend.connectionError\", object);\n case RpcProtocolEvent.ConnectionAborted: return this.logErrorFrontend(\"RpcInterface.frontend.connectionAborted\", object);\n }\n }\n\n protected override getHostname(): string {\n return globalThis.window?.location?.host ?? \"imodeljs-mobile\";\n }\n\n private logErrorFrontend(message: string, request: WebAppRpcRequest): void {\n const operationDescriptor = this.buildOperationDescriptor(request.operation);\n const pathIds = this.findPathIds(request.path);\n\n Logger.logInfo(CommonLoggerCategory.RpcInterfaceFrontend, `${message}.${operationDescriptor}`, () => ({\n method: request.method,\n path: request.path,\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\n ActivityId: request.id, // eslint-disable-line @typescript-eslint/naming-convention\n MachineName: this.getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\n ...pathIds,\n }));\n }\n}\n\nWebAppRpcLogging.initializeFrontend(new WebAppRpcLoggingFrontend());\n"]}
1
+ {"version":3,"file":"WebAppRpcLogging.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcLogging.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA4D;AAC5D,qEAAkE;AAClE,mDAAgD;AAEhD,uDAAwD;AACxD,yDAAsD;AAItD,yDAAsD;AAEtD,qDAAqD;AAErD,gBAAgB;AACh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W;QAC5B,OAAO,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,IAAI,iBAAiB,CAAC;IAChE,CAAC;IAEO,gBAAgB,CAAC,OAAe,EAAE,OAAyB;QACjE,MAAM,mBAAmB,GAAG,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC7E,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE/C,qBAAM,CAAC,OAAO,CAAC,2CAAoB,CAAC,oBAAoB,EAAE,GAAG,OAAO,IAAI,mBAAmB,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;YACpG,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,uGAAuG;YACvG,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,2DAA2D;YACnF,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,2DAA2D;YAC5F,GAAG,OAAO;SACX,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AAED,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,wBAAwB,EAAE,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { BentleyStatus, Logger } from \"@itwin/core-bentley\";\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\nimport { IModelError } from \"../../IModelError\";\nimport { RpcInterfaceDefinition } from \"../../RpcInterface\";\nimport { RpcProtocolEvent } from \"../core/RpcConstants\";\nimport { RpcInvocation } from \"../core/RpcInvocation\";\nimport { RpcOperation } from \"../core/RpcOperation\";\nimport { SerializedRpcOperation, SerializedRpcRequest } from \"../core/RpcProtocol\";\nimport { RpcRequest } from \"../core/RpcRequest\";\nimport { WebAppRpcRequest } from \"./WebAppRpcRequest\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** @internal */\nconst BACKEND = Symbol.for(\"@itwin.WebAppRpcLogging.Backend\");\nconst FRONTEND = Symbol.for(\"@itwin.WebAppRpcLogging.Frontend\");\n\n/** @internal */\nexport abstract class WebAppRpcLogging {\n public static initializeBackend(instance: WebAppRpcLogging) {\n (globalThis as any)[BACKEND] = instance;\n }\n\n public static initializeFrontend(instance: WebAppRpcLogging) {\n (globalThis as any)[FRONTEND] = instance;\n }\n\n private static get backend(): WebAppRpcLogging {\n const instance = (globalThis as any)[BACKEND];\n if (typeof (instance) === \"undefined\") {\n throw new IModelError(BentleyStatus.ERROR, \"Backend logging is not initialized.\");\n }\n\n return instance;\n }\n\n private static get frontend(): WebAppRpcLogging {\n const instance = (globalThis as any)[FRONTEND];\n if (typeof (instance) === \"undefined\") {\n throw new IModelError(BentleyStatus.ERROR, \"Frontend logging is not initialized.\");\n }\n\n return instance;\n }\n\n public static async logProtocolEvent(event: RpcProtocolEvent, object: RpcRequest | RpcInvocation): Promise<void> {\n if (object instanceof WebAppRpcRequest) {\n await WebAppRpcLogging.frontend.logProtocolEvent(event, object);\n } else if (object instanceof RpcInvocation) {\n await WebAppRpcLogging.backend.logProtocolEvent(event, object);\n }\n }\n\n protected abstract logProtocolEvent(event: RpcProtocolEvent, object: RpcRequest | RpcInvocation): Promise<void>;\n\n protected abstract getHostname(): string;\n\n protected getRpcInterfaceName(g: string | RpcInterfaceDefinition): string {\n return (typeof g === \"string\") ? g : g.interfaceName;\n }\n\n protected findPathIds(path: string) {\n let iTwinId = \"\";\n let iModelId = \"\";\n\n const tokens = path.split(\"/\");\n for (let i = 0; i !== tokens.length; ++i) {\n // For backwards compatibility, find old \"context\" or current \"iTwin\" terminology\n if ((/^context$/i).test(tokens[i]) || (/^itwin$/i).test(tokens[i])) {\n iTwinId = tokens[i + 1] || \"\";\n }\n\n if ((/^imodel$/i).test(tokens[i])) {\n iModelId = tokens[i + 1] || \"\";\n }\n }\n\n return { iTwinId, iModelId };\n }\n\n protected buildOperationDescriptor(operation: RpcOperation | SerializedRpcOperation): string {\n if (!operation) {\n return \"unknown.unknown\";\n }\n\n const interfaceName = typeof (operation.interfaceDefinition) === \"string\" ? operation.interfaceDefinition : operation.interfaceDefinition.interfaceName;\n const operationName = operation.operationName;\n return `${interfaceName}.${operationName}`;\n }\n\n protected logRequest(loggerCategory: string, message: string, object: WebAppRpcRequest | SerializedRpcRequest): void {\n const operationDescriptor = this.buildOperationDescriptor(object.operation);\n const pathIds = this.findPathIds(object.path);\n\n Logger.logTrace(loggerCategory, `${message}.${operationDescriptor}`, () => ({\n method: object.method,\n path: object.path,\n operation: object.operation.operationName,\n rpcInterface: this.getRpcInterfaceName(object.operation.interfaceDefinition),\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\n ActivityId: object.id, // eslint-disable-line @typescript-eslint/naming-convention\n TimeElapsed: (\"elapsed\" in object) ? object.elapsed : 0, // eslint-disable-line @typescript-eslint/naming-convention\n MachineName: this.getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\n ...pathIds,\n }));\n }\n\n protected logResponse(loggerCategory: string, message: string, object: WebAppRpcRequest | SerializedRpcRequest, status: number, elapsed: number): void {\n const operationDescriptor = this.buildOperationDescriptor(object.operation);\n const pathIds = this.findPathIds(object.path);\n\n Logger.logTrace(loggerCategory, `${message}.${operationDescriptor}`, () => ({\n method: object.method,\n path: object.path,\n operation: object.operation.operationName,\n rpcInterface: this.getRpcInterfaceName(object.operation.interfaceDefinition),\n status,\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\n ActivityId: object.id, // eslint-disable-line @typescript-eslint/naming-convention\n TimeElapsed: elapsed, // eslint-disable-line @typescript-eslint/naming-convention\n MachineName: this.getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\n ...pathIds,\n }));\n }\n}\n\ndeclare global {\n \n var window: any;\n}\n\nclass WebAppRpcLoggingFrontend extends WebAppRpcLogging {\n protected override async logProtocolEvent(event: RpcProtocolEvent, object: WebAppRpcRequest): Promise<void> {\n switch (event) {\n case RpcProtocolEvent.RequestCreated: return this.logRequest(CommonLoggerCategory.RpcInterfaceFrontend, \"RpcInterface.frontend.request\", object);\n case RpcProtocolEvent.ResponseLoaded: return this.logResponse(CommonLoggerCategory.RpcInterfaceFrontend, \"RpcInterface.frontend.response\", object, object.metadata.status, object.elapsed);\n case RpcProtocolEvent.ConnectionErrorReceived: return this.logErrorFrontend(\"RpcInterface.frontend.connectionError\", object);\n case RpcProtocolEvent.ConnectionAborted: return this.logErrorFrontend(\"RpcInterface.frontend.connectionAborted\", object);\n }\n }\n\n protected override getHostname(): string {\n return globalThis.window?.location?.host ?? \"imodeljs-mobile\";\n }\n\n private logErrorFrontend(message: string, request: WebAppRpcRequest): void {\n const operationDescriptor = this.buildOperationDescriptor(request.operation);\n const pathIds = this.findPathIds(request.path);\n\n Logger.logInfo(CommonLoggerCategory.RpcInterfaceFrontend, `${message}.${operationDescriptor}`, () => ({\n method: request.method,\n path: request.path,\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\n ActivityId: request.id, // eslint-disable-line @typescript-eslint/naming-convention\n MachineName: this.getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\n ...pathIds,\n }));\n }\n}\n\nWebAppRpcLogging.initializeFrontend(new WebAppRpcLoggingFrontend());\n"]}
@@ -7,6 +7,8 @@
7
7
  * @extensions
8
8
  */
9
9
  export declare enum CommonLoggerCategory {
10
+ /** The logger category used by common APIs relating to text annotations. */
11
+ Annotations = "core-common.Annotations",
10
12
  /** The logger category used by common classes relating to ElementProps. */
11
13
  ElementProps = "core-common.ElementProps",
12
14
  /** The logger category used by common classes relating to Geometry. */
@@ -1 +1 @@
1
- {"version":3,"file":"CommonLoggerCategory.d.ts","sourceRoot":"","sources":["../../src/CommonLoggerCategory.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;;GAIG;AACH,oBAAY,oBAAoB;IAC9B,2EAA2E;IAC3E,YAAY,6BAA6B;IACzC,uEAAuE;IACvE,QAAQ,yBAAyB;IACjC,sGAAsG;IACtG,mBAAmB,8BAA8B;IACjD,uGAAuG;IACvG,oBAAoB,+BAA+B;CACpD"}
1
+ {"version":3,"file":"CommonLoggerCategory.d.ts","sourceRoot":"","sources":["../../src/CommonLoggerCategory.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;;GAIG;AACH,oBAAY,oBAAoB;IAC9B,4EAA4E;IAC5E,WAAW,4BAA4B;IACvC,2EAA2E;IAC3E,YAAY,6BAA6B;IACzC,uEAAuE;IACvE,QAAQ,yBAAyB;IACjC,sGAAsG;IACtG,mBAAmB,8BAA8B;IACjD,uGAAuG;IACvG,oBAAoB,+BAA+B;CACpD"}
@@ -12,6 +12,8 @@
12
12
  */
13
13
  export var CommonLoggerCategory;
14
14
  (function (CommonLoggerCategory) {
15
+ /** The logger category used by common APIs relating to text annotations. */
16
+ CommonLoggerCategory["Annotations"] = "core-common.Annotations";
15
17
  /** The logger category used by common classes relating to ElementProps. */
16
18
  CommonLoggerCategory["ElementProps"] = "core-common.ElementProps";
17
19
  /** The logger category used by common classes relating to Geometry. */
@@ -1 +1 @@
1
- {"version":3,"file":"CommonLoggerCategory.js","sourceRoot":"","sources":["../../src/CommonLoggerCategory.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH;;;;GAIG;AACH,MAAM,CAAN,IAAY,oBASX;AATD,WAAY,oBAAoB;IAC9B,2EAA2E;IAC3E,iEAAyC,CAAA;IACzC,uEAAuE;IACvE,yDAAiC,CAAA;IACjC,sGAAsG;IACtG,yEAAiD,CAAA;IACjD,uGAAuG;IACvG,2EAAmD,CAAA;AACrD,CAAC,EATW,oBAAoB,KAApB,oBAAoB,QAS/B","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Logging\n */\n\n/** Logger categories used by this package\n * @see [Logger]($bentley)\n * @public\n * @extensions\n */\nexport enum CommonLoggerCategory {\n /** The logger category used by common classes relating to ElementProps. */\n ElementProps = \"core-common.ElementProps\",\n /** The logger category used by common classes relating to Geometry. */\n Geometry = \"core-common.Geometry\",\n /** The logger category used by the portions of the RpcInterface framework that run on the backend. */\n RpcInterfaceBackend = \"core-backend.RpcInterface\",\n /** The logger category used by the portions of the RpcInterface framework that run on the frontend. */\n RpcInterfaceFrontend = \"core-frontend.RpcInterface\",\n}\n"]}
1
+ {"version":3,"file":"CommonLoggerCategory.js","sourceRoot":"","sources":["../../src/CommonLoggerCategory.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH;;;;GAIG;AACH,MAAM,CAAN,IAAY,oBAWX;AAXD,WAAY,oBAAoB;IAC9B,4EAA4E;IAC5E,+DAAuC,CAAA;IACvC,2EAA2E;IAC3E,iEAAyC,CAAA;IACzC,uEAAuE;IACvE,yDAAiC,CAAA;IACjC,sGAAsG;IACtG,yEAAiD,CAAA;IACjD,uGAAuG;IACvG,2EAAmD,CAAA;AACrD,CAAC,EAXW,oBAAoB,KAApB,oBAAoB,QAW/B","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Logging\n */\n\n/** Logger categories used by this package\n * @see [Logger]($bentley)\n * @public\n * @extensions\n */\nexport enum CommonLoggerCategory {\n /** The logger category used by common APIs relating to text annotations. */\n Annotations = \"core-common.Annotations\",\n /** The logger category used by common classes relating to ElementProps. */\n ElementProps = \"core-common.ElementProps\",\n /** The logger category used by common classes relating to Geometry. */\n Geometry = \"core-common.Geometry\",\n /** The logger category used by the portions of the RpcInterface framework that run on the backend. */\n RpcInterfaceBackend = \"core-backend.RpcInterface\",\n /** The logger category used by the portions of the RpcInterface framework that run on the frontend. */\n RpcInterfaceFrontend = \"core-frontend.RpcInterface\",\n}\n"]}
@@ -74,15 +74,15 @@ export declare abstract class TextBlockComponent {
74
74
  /** Returns true if `this` is equivalent to `other`. */
75
75
  equals(other: TextBlockComponent): boolean;
76
76
  }
77
- /**
77
+ /** [[TextBlockComponent]]s contained within a [[Paragraph]].
78
78
  * @beta
79
79
  */
80
- export type Run = TextRun | FractionRun | TabRun | LineBreakRun;
80
+ export type Run = TextRun | FractionRun | TabRun | LineBreakRun | FieldRun;
81
81
  /** The JSON representation of a [[Run]].
82
82
  * Use the `type` field to discriminate between the different kinds of runs.
83
83
  * @beta
84
84
  */
85
- export type RunProps = TextRunProps | FractionRunProps | TabRunProps | LineBreakRunProps;
85
+ export type RunProps = TextRunProps | FractionRunProps | TabRunProps | LineBreakRunProps | FieldRunProps;
86
86
  /** A sequence of characters within a [[Paragraph]] that share a single style. Runs are the leaf nodes of a [[TextBlock]] document. When laid out for display, a single run may span
87
87
  * multiple lines, but it will never contain different styling.
88
88
  * Use the `type` field to discriminate between the different kinds of runs.
@@ -209,6 +209,108 @@ export declare class TabRun extends TextBlockComponent {
209
209
  stringify(options?: TextBlockStringifyOptions): string;
210
210
  equals(other: TextBlockComponent): boolean;
211
211
  }
212
+ /** A chain of property accesses that resolves to a primitive value that forms the basis of the displayed content
213
+ * of a [[FieldRun]].
214
+ * The simplest property paths consist of a [[propertyName]] and nothing else, where `propertyName` identifies
215
+ * a primitive property.
216
+ * If `propertyName` identifies a struct or array property, then additional [[accessors]] are required to identify the specific value.
217
+ * If `propertyName` (including any [[accessors]]) resolves to a JSON property, then additional [[jsonAccessors]] are required to identify a specific value within the JSON.
218
+ * Some examples:
219
+ * ```
220
+ * | Access String | propertyName | accessors | jsonAccessors |
221
+ * | ------------- | ------------ | --------- | ------------- |
222
+ * | name | "name" | undefined | undefined |
223
+ * | spouse.name | "spouse" | [name] | undefined |
224
+ * | colors[2] | "colors" | [2] | undefined |
225
+ * | spouse.favoriteRestaurants[1].address | "spouse" | ["favoriteRestaurants", 1, "address"] | undefined |
226
+ * | jsonProperties.contactInfo.email | "jsonProperties" | undefined | ["contactInfo", "email"] |
227
+ * | spouse.jsonProperties.contactInfo.phoneNumbers[0].areaCode | "spouse" | ["jsonProperties"] | ["contactInfo", "phoneNumbers", 0, "areaCode"] |
228
+ * ```
229
+ * @beta
230
+ */
231
+ export interface FieldPropertyPath {
232
+ /** The name of the BIS property of the [[FieldPropertyHost]] that serves as the root of the path. */
233
+ propertyName: string;
234
+ /** Property names and/or array indices describing the path from [[propertyName]] to the ultimate BIS property. */
235
+ accessors?: Array<string | number>;
236
+ /** If [[propertyName]] and [[accessors]] (if defined) resolve to a BIS property of extended type `Json`, property names and/or
237
+ * array indices for selecting a primitive value within the JSON.
238
+ */
239
+ jsonAccessors?: Array<string | number>;
240
+ }
241
+ /** Describes the source of the property value against which a [[FieldPropertyPath]] is evaluated.
242
+ * A field property is always hosted by an [Element]($backend). It may be a property of the element's BIS class itself,
243
+ * or that of one of its [ElementAspect]($backend)s.
244
+ * The [[schemaName]] and [[className]] should always identify the exact class that contains [[FieldPropertyPath.propertyName]] - not a subclass thereof.
245
+ * @beta
246
+ */
247
+ export interface FieldPropertyHost {
248
+ /** The Id of the [Element]($backend) that hosts the property. */
249
+ elementId: Id64String;
250
+ /** The name of the schema containing the class identified by [[className]]. */
251
+ schemaName: string;
252
+ /** The name of the exact class (not a subclass) containing the property identified by [[FieldPropertyPath.propertyName]]. */
253
+ className: string;
254
+ }
255
+ /** Placeholder type for a description of how to format the raw property value resolved by a [[FieldPropertyPath]] into a [[FieldRun]]'s display string.
256
+ * *** COMING SOON ***
257
+ * @beta
258
+ */
259
+ export interface FieldFormatter {
260
+ [k: string]: any;
261
+ }
262
+ /** JSON representation of a [[FieldRun]].
263
+ * @beta
264
+ */
265
+ export interface FieldRunProps extends TextBlockComponentProps {
266
+ /** Discriminator field for the [[RunProps]] union. */
267
+ readonly type: "field";
268
+ /** The element and BIS class containing the property described by [[propertyPath]]. */
269
+ propertyHost: FieldPropertyHost;
270
+ /** Describes how to obtain the property value from [[propertyHost]]. */
271
+ propertyPath: FieldPropertyPath;
272
+ /** Specifies how to format the property value obtained from [[propertyPath]] into a string to be stored in [[cachedContent]]. */
273
+ formatter?: FieldFormatter;
274
+ /** The field's most recently evaluated display string. */
275
+ cachedContent?: string;
276
+ }
277
+ /** A [[Run]] that displays the formatted value of a property of some [Element]($backend).
278
+ * When a [[TextBlock]] containing a [[FieldRun]] is written into the iModel as an [ITextAnnotation]($backend) element,
279
+ * a dependency is established between the two elements via the [ElementDrivesTextAnnotation]($backend) relationship such that
280
+ * whenever the source element specified by [[propertyHost]] is modified, the field(s) in the `ITextAnnotation` element are automatically
281
+ * recalculated, causing their [[cachedContent]] to update. If the field's display string cannot be evaluated (for example, because the specified element or
282
+ * property does not exist), then its cached content is set to [[FieldRun.invalidContentIndicator]].
283
+ * A [[FieldRun]] displays its [[cachedContent]] in the same way that [[TextRun]]s display their `content`, including word wrapping where appropriate.
284
+ * @beta
285
+ */
286
+ export declare class FieldRun extends TextBlockComponent {
287
+ /** Display string used to signal an error in computing the field's value. */
288
+ static invalidContentIndicator: string;
289
+ /** Discriminator field for the [[Run]] union. */
290
+ readonly type = "field";
291
+ /** The element and BIS class containing the property described by [[propertyPath]]. */
292
+ readonly propertyHost: Readonly<FieldPropertyHost>;
293
+ /** Describes how to obtain the property value from [[propertyHost]]. */
294
+ readonly propertyPath: Readonly<FieldPropertyPath>;
295
+ /** Specifies how to format the property value obtained from [[propertyPath]] into a string to be stored in [[cachedContent]]. */
296
+ readonly formatter?: FieldFormatter;
297
+ private _cachedContent;
298
+ /** The field's most recently evaluated display string. */
299
+ get cachedContent(): string;
300
+ /** @internal Used by core-backend when re-evaluating field content. */
301
+ setCachedContent(content: string | undefined): void;
302
+ private constructor();
303
+ /** Create a FieldRun from its JSON representation. */
304
+ static create(props: Omit<FieldRunProps, "type">): FieldRun;
305
+ /** Convert the FieldRun to its JSON representation. */
306
+ toJSON(): FieldRunProps;
307
+ /** Create a deep copy of this FieldRun. */
308
+ clone(): FieldRun;
309
+ /** Convert this FieldRun to a simple string representation. */
310
+ stringify(): string;
311
+ /** Returns true if `this` is equivalent to `other`. */
312
+ equals(other: TextBlockComponent): boolean;
313
+ }
212
314
  /** JSON representation of a [[Paragraph]].
213
315
  * @beta
214
316
  */
@@ -1 +1 @@
1
- {"version":3,"file":"TextBlock.d.ts","sourceRoot":"","sources":["../../../src/annotation/TextBlock.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAqB,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,cAAc,CAAC,EAAE,sBAAsB,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,8BAAsB,kBAAkB;IACtC,OAAO,CAAC,eAAe,CAAyB;IAEhD,gBAAgB;IAChB,SAAS,aAAa,KAAK,CAAC,EAAE,uBAAuB;IAIrD;;;OAGG;IACH,IAAW,cAAc,IAAI,sBAAsB,CAElD;IAED,IAAW,cAAc,CAAC,SAAS,EAAE,sBAAsB,EAE1D;IAED,8DAA8D;IACvD,mBAAmB,CAAC,QAAQ,CAAC,EAAE,qBAAqB,GAAG,IAAI;IAIlE,4HAA4H;IAC5H,IAAW,cAAc,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AG,IAAI;IAU1E,uMAAuM;IAChM,SAAS,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,MAAM;IAI7D;;;OAGG;IACI,eAAe,CAAC,YAAY,GAAE,OAAe,GAAG,SAAS;IAgBhE;;OAEG;IACI,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI;IAKhB,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO;CAqB3D"}
@@ -80,6 +80,7 @@ export var Run;
80
80
  case "fraction": return FractionRun.create(props);
81
81
  case "tab": return TabRun.create(props);
82
82
  case "linebreak": return LineBreakRun.create(props);
83
+ case "field": return FieldRun.create(props);
83
84
  }
84
85
  }
85
86
  Run.fromJSON = fromJSON;
@@ -223,6 +224,113 @@ export class TabRun extends TextBlockComponent {
223
224
  return other instanceof TabRun && super.equals(other);
224
225
  }
225
226
  }
227
+ /** A [[Run]] that displays the formatted value of a property of some [Element]($backend).
228
+ * When a [[TextBlock]] containing a [[FieldRun]] is written into the iModel as an [ITextAnnotation]($backend) element,
229
+ * a dependency is established between the two elements via the [ElementDrivesTextAnnotation]($backend) relationship such that
230
+ * whenever the source element specified by [[propertyHost]] is modified, the field(s) in the `ITextAnnotation` element are automatically
231
+ * recalculated, causing their [[cachedContent]] to update. If the field's display string cannot be evaluated (for example, because the specified element or
232
+ * property does not exist), then its cached content is set to [[FieldRun.invalidContentIndicator]].
233
+ * A [[FieldRun]] displays its [[cachedContent]] in the same way that [[TextRun]]s display their `content`, including word wrapping where appropriate.
234
+ * @beta
235
+ */
236
+ export class FieldRun extends TextBlockComponent {
237
+ /** Display string used to signal an error in computing the field's value. */
238
+ static invalidContentIndicator = "####";
239
+ /** Discriminator field for the [[Run]] union. */
240
+ type = "field";
241
+ /** The element and BIS class containing the property described by [[propertyPath]]. */
242
+ propertyHost;
243
+ /** Describes how to obtain the property value from [[propertyHost]]. */
244
+ propertyPath;
245
+ /** Specifies how to format the property value obtained from [[propertyPath]] into a string to be stored in [[cachedContent]]. */
246
+ formatter;
247
+ _cachedContent;
248
+ /** The field's most recently evaluated display string. */
249
+ get cachedContent() {
250
+ return this._cachedContent;
251
+ }
252
+ /** @internal Used by core-backend when re-evaluating field content. */
253
+ setCachedContent(content) {
254
+ this._cachedContent = content ?? FieldRun.invalidContentIndicator;
255
+ }
256
+ constructor(props) {
257
+ super(props);
258
+ this._cachedContent = props.cachedContent ?? FieldRun.invalidContentIndicator;
259
+ this.propertyHost = props.propertyHost;
260
+ this.propertyPath = props.propertyPath;
261
+ this.formatter = props.formatter;
262
+ }
263
+ /** Create a FieldRun from its JSON representation. */
264
+ static create(props) {
265
+ return new FieldRun({
266
+ ...props,
267
+ propertyHost: { ...props.propertyHost },
268
+ propertyPath: structuredClone(props.propertyPath),
269
+ formatter: structuredClone(props.formatter),
270
+ });
271
+ }
272
+ /** Convert the FieldRun to its JSON representation. */
273
+ toJSON() {
274
+ const json = {
275
+ ...super.toJSON(),
276
+ type: "field",
277
+ propertyHost: { ...this.propertyHost },
278
+ propertyPath: structuredClone(this.propertyPath),
279
+ };
280
+ if (this.cachedContent !== FieldRun.invalidContentIndicator) {
281
+ json.cachedContent = this.cachedContent;
282
+ }
283
+ if (this.formatter) {
284
+ json.formatter = structuredClone(this.formatter);
285
+ }
286
+ return json;
287
+ }
288
+ /** Create a deep copy of this FieldRun. */
289
+ clone() {
290
+ return new FieldRun(this.toJSON());
291
+ }
292
+ /** Convert this FieldRun to a simple string representation. */
293
+ stringify() {
294
+ return this.cachedContent;
295
+ }
296
+ /** Returns true if `this` is equivalent to `other`. */
297
+ equals(other) {
298
+ if (!(other instanceof FieldRun) || !super.equals(other)) {
299
+ return false;
300
+ }
301
+ if (this.propertyHost.elementId !== other.propertyHost.elementId ||
302
+ this.propertyHost.className !== other.propertyHost.className ||
303
+ this.propertyHost.schemaName !== other.propertyHost.schemaName) {
304
+ return false;
305
+ }
306
+ if (this.propertyPath.propertyName !== other.propertyPath.propertyName) {
307
+ return false;
308
+ }
309
+ const thisAccessors = this.propertyPath.accessors ?? [];
310
+ const otherAccessors = other.propertyPath.accessors ?? [];
311
+ const thisJsonAccessors = this.propertyPath.jsonAccessors ?? [];
312
+ const otherJsonAccessors = other.propertyPath.jsonAccessors ?? [];
313
+ if (thisAccessors.length !== otherAccessors.length || thisJsonAccessors.length !== otherJsonAccessors.length) {
314
+ return false;
315
+ }
316
+ if (!thisAccessors.every((value, index) => value === otherAccessors[index])) {
317
+ return false;
318
+ }
319
+ if (!thisJsonAccessors.every((value, index) => value === otherJsonAccessors[index])) {
320
+ return false;
321
+ }
322
+ if (this.formatter && other.formatter) {
323
+ // ###TODO better comparison of formatter objects.
324
+ if (JSON.stringify(this.formatter) !== JSON.stringify(other.formatter)) {
325
+ return false;
326
+ }
327
+ }
328
+ else if (this.formatter || other.formatter) {
329
+ return false;
330
+ }
331
+ return true;
332
+ }
333
+ }
226
334
  /** A collection of [[Run]]s within a [[TextBlock]]. Each paragraph within a text block is laid out on a separate line.
227
335
  * @beta
228
336
  */
@@ -1 +1 @@
1
- {"version":3,"file":"TextBlock.js","sourceRoot":"","sources":["../../../src/annotation/TextBlock.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAA0B,MAAM,aAAa,CAAC;AA4CxE;;;GAGG;AACH,MAAM,OAAgB,kBAAkB;IAC9B,eAAe,CAAyB;IAEhD,gBAAgB;IAChB,YAAsB,KAA+B;QACnD,IAAI,CAAC,eAAe,GAAG,iBAAiB,CAAC,UAAU,CAAC,KAAK,EAAE,cAAc,IAAI,EAAE,CAAC,CAAC;IACnF,CAAC;IAED;;;OAGG;IACH,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED,IAAW,cAAc,CAAC,SAAiC;QACzD,IAAI,CAAC,eAAe,GAAG,iBAAiB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACjE,CAAC;IAED,8DAA8D;IACvD,mBAAmB,CAAC,QAAg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yB;QAC9C,IAAI,CAAC,CAAC,KAAK,YAAY,SAAS,CAAC,EAAE,CAAC;YAClC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3D,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,aAAa,KAAK,KAAK,CAAC,aAAa,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YACnI,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAC1E,KAAK,KAAM,KAAK,CAAC,OAAe,CAAC,GAAG,CAAC,CACtC,CAAC;QAEF,IAAI,CAAC,eAAe;YAAE,OAAO,KAAK,CAAC;QAEnC,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChG,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Annotation\n */\n\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { TextStyleSettings, TextStyleSettingsProps } from \"./TextStyle\";\n\n/** Options supplied to [[TextBlockComponent.clearStyleOverrides]] to control how the style overrides are cleared on the component and its child components.\n * @beta\n */\nexport interface ClearTextStyleOptions {\n /** Controls whether the styleOverrides of any child components are retained.\n * By default, all overrides are cleared.\n */\n preserveChildrenOverrides?: boolean;\n}\n\n/** The JSON representation of a [[TextBlockComponent]].\n * @beta\n */\nexport interface TextBlockComponentProps {\n /** Deviations from the base [[TextStyleSettings]] defined by the [AnnotationTextStyle]($backend) applied to this component.\n * This permits you to, e.g., create a [[TextBlock]] using \"Arial\" font and override one of its [[TextRun]]s to use \"Comic Sans\" instead.\n */\n styleOverrides?: TextStyleSettingsProps;\n}\n\n/** Options supplied to [[TextBlockComponent.stringify]] to control how the content is formatted.\n * @beta\n */\nexport interface TextBlockStringifyOptions {\n /** A string to insert in between each [[Paragraph]].\n * Default: \" \" - a single space.\n */\n paragraphBreak?: string;\n /** A string to insert for each [[LineBreakRun]].\n * Default: \" \" - a single space.\n */\n lineBreak?: string;\n /** A string to insert between the numerator and denominator of each [[FractionRun]].\n * Default: \"/\"\n */\n fractionSeparator?: string;\n /** The number of spaces to use for tabs. If not provided, tabs will be represented by a tab character: \"\\t\".\n * Default: \"undefined\" - use \"\\t\".\n */\n tabsAsSpaces?: number;\n}\n\n/** Abstract representation of any of the building blocks that make up a [[TextBlock]] document - namely [[Run]]s, [[Paragraph]]s, and [[TextBlock]] itself.\n * The [[TextBlock]] can specify an [AnnotationTextStyle]($backend) that formats its contents. Each component can specify an optional [[styleOverrides]] to customize that formatting.\n * @beta\n */\nexport abstract class TextBlockComponent {\n private _styleOverrides: TextStyleSettingsProps;\n\n /** @internal */\n protected constructor(props?: TextBlockComponentProps) {\n this._styleOverrides = TextStyleSettings.cloneProps(props?.styleOverrides ?? {});\n }\n\n /** Deviations in individual properties of the [[TextStyleSettings]] in the [AnnotationTextStyle]($backend) specified by `styleId` on the [[TextBlock]].\n * For example, if the style uses the \"Arial\" font, you can override that by settings `styleOverrides.fontName` to \"Comic Sans\".\n * @see [[clearStyleOverrides]] to reset this to an empty object.\n */\n public get styleOverrides(): TextStyleSettingsProps {\n return this._styleOverrides;\n }\n\n public set styleOverrides(overrides: TextStyleSettingsProps) {\n this._styleOverrides = TextStyleSettings.cloneProps(overrides);\n }\n\n /** Reset any [[styleOverrides]] applied to this component. */\n public clearStyleOverrides(_options?: ClearTextStyleOptions): void {\n this.styleOverrides = { };\n }\n\n /** Returns true if [[styleOverrides]] specifies any deviations from the [[TextBlock]]'s [AnnotationTextStyle]($backend). */\n public get overridesStyle(): boolean {\n return Object.keys(this.styleOverrides).length > 0;\n }\n\n /** Create a deep copy of this component. */\n public abstract clone(): TextBlockComponent;\n\n /** Compute a string representation of the contents of this component and all of its sub-components. */\n public abstract stringify(options?: TextBlockStringifyOptions): string;\n\n /**\n * Returns true if the string representation of this component consists only of whitespace characters.\n * Useful for checking if the component is visually empty (producing no graphics) or contains only spaces, tabs, or line breaks.\n */\n public get isWhitespace(): boolean {\n return /^\\s*$/g.test(this.stringify());\n };\n\n /** Convert this component to its JSON representation. */\n public toJSON(): TextBlockComponentProps {\n return {\n styleOverrides: TextStyleSettings.cloneProps(this.styleOverrides),\n };\n }\n\n /** Returns true if `this` is equivalent to `other`. */\n public equals(other: TextBlockComponent): boolean {\n const myKeys = Object.keys(this.styleOverrides);\n const yrKeys = Object.keys(other._styleOverrides);\n if (myKeys.length !== yrKeys.length) {\n return false;\n }\n\n for (const name of myKeys) {\n const key = name as keyof TextStyleSettingsProps;\n if (this.styleOverrides[key] !== other.styleOverrides[key]) {\n return false;\n }\n }\n\n return true;\n }\n}\n\n/**\n * @beta\n */\nexport type Run = TextRun | FractionRun | TabRun | LineBreakRun;\n\n/** The JSON representation of a [[Run]].\n * Use the `type` field to discriminate between the different kinds of runs.\n * @beta\n */\nexport type RunProps = TextRunProps | FractionRunProps | TabRunProps | LineBreakRunProps;\n\n/** A sequence of characters within a [[Paragraph]] that share a single style. Runs are the leaf nodes of a [[TextBlock]] document. When laid out for display, a single run may span\n * multiple lines, but it will never contain different styling.\n * Use the `type` field to discriminate between the different kinds of runs.\n * @beta\n */\nexport namespace Run { // eslint-disable-line @typescript-eslint/no-redeclare\n /** Create a run from its JSON representation.\n * @see [[TextRun.create]], [[FractionRun.create]], and [[LineBreakRun.create]] to create a run directly.\n */\n export function fromJSON(props: RunProps): Run {\n switch (props.type) {\n case \"text\": return TextRun.create(props);\n case \"fraction\": return FractionRun.create(props);\n case \"tab\": return TabRun.create(props);\n case \"linebreak\": return LineBreakRun.create(props);\n }\n }\n}\n\n/** Describes whether the characters of a [[TextRun]] should be displayed normally, in subscript, or in superscript.\n * [[TextStyleSettings.superScriptScale]], [[TextStyleSettings.subScriptScale]], [[TextStyleSettings.superScriptOffsetFactor]], and [[TextStyleSettings.subScriptOffsetFactor]]\n * affect how the content is rendered.\n * @beta\n */\nexport type BaselineShift = \"subscript\" | \"superscript\" | \"none\";\n\n/** JSON representation of a [[TextRun]].\n * @beta\n */\nexport interface TextRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"text\";\n /** The characters displayed by the run.\n * Default: an empty string.\n */\n content?: string;\n /** Whether to display [[content]] as a subscript, superscript, or normally.\n * Default: \"none\"\n */\n baselineShift?: BaselineShift;\n}\n\n/** The most common type of [[Run]], containing a sequence of characters to be displayed using a single style.\n * @beta\n */\nexport class TextRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"text\";\n /** The sequence of characters to be displayed by the run. */\n public content: string;\n /** Whether to display [[content]] as a subscript, superscript, or normally. */\n public baselineShift: BaselineShift;\n\n private constructor(props?: Omit<TextRunProps, \"type\">) {\n super(props);\n this.content = props?.content ?? \"\";\n this.baselineShift = props?.baselineShift ?? \"none\";\n }\n\n public override clone(): TextRun {\n return new TextRun(this.toJSON());\n }\n\n public override toJSON(): TextRunProps {\n return {\n ...super.toJSON(),\n type: \"text\",\n content: this.content,\n baselineShift: this.baselineShift,\n };\n }\n\n public static create(props?: Omit<TextRunProps, \"type\">): TextRun {\n return new TextRun(props);\n }\n\n /** Simply returns [[content]]. */\n public override stringify(): string {\n return this.content;\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof TextRun && this.content === other.content && this.baselineShift === other.baselineShift && super.equals(other);\n }\n}\n\n/** JSON representation of a [[FractionRun]].\n * @beta\n */\nexport interface FractionRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"fraction\";\n /** The text displayed before or above the fraction separator, depending on [[TextStyleSettings.stackedFractionType]]. Default: an empty string. */\n numerator?: string;\n /** The text displayed after or below the fraction separator, depending on [[TextStyleSettings.stackedFractionType]]. Default: an empty string. */\n denominator?: string;\n}\n\n/** A [[Run]] containing a numeric ratio to be displayed as a numerator and denominator separated by a horizontal or diagonal bar.\n * @note The [[numerator]] and [[denominator]] are stored as strings. They are not technically required to contain a numeric representation.\n * @beta\n */\nexport class FractionRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"fraction\";\n /** The fraction's numerator. */\n public numerator: string;\n /** The fraction's denominator. */\n public denominator: string;\n\n private constructor(props?: Omit<FractionRunProps, \"type\">) {\n super(props);\n this.numerator = props?.numerator ?? \"\";\n this.denominator = props?.denominator ?? \"\";\n }\n\n public override toJSON(): FractionRunProps {\n return {\n ...super.toJSON(),\n type: \"fraction\",\n numerator: this.numerator,\n denominator: this.denominator,\n };\n }\n\n public override clone(): FractionRun {\n return new FractionRun(this.toJSON());\n }\n\n public static create(props?: Omit<FractionRunProps, \"type\">): FractionRun {\n return new FractionRun(props);\n }\n\n /** Formats the fraction as a string with the [[numerator]] and [[denominator]] separated by [[TextBlockStringifyOptions.fractionSeparator]]. */\n public override stringify(options?: TextBlockStringifyOptions): string {\n const sep = options?.fractionSeparator ?? \"/\";\n return `${this.numerator}${sep}${this.denominator}`;\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof FractionRun && this.numerator === other.numerator && this.denominator === other.denominator && super.equals(other);\n }\n}\n\n/** JSON representation of a [[LineBreakRun]].\n * @beta\n */\nexport interface LineBreakRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"linebreak\";\n}\n\n/** A [[Run]] that represents the end of a line of text within a [[Paragraph]]. It contains no content of its own - it simply causes subsequent content to display on a new line.\n * @beta\n */\nexport class LineBreakRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"linebreak\";\n\n private constructor(props?: TextBlockComponentProps) {\n super(props);\n }\n\n public override toJSON(): LineBreakRunProps {\n return {\n ...super.toJSON(),\n type: \"linebreak\",\n };\n }\n\n public static create(props?: TextBlockComponentProps) {\n return new LineBreakRun(props);\n }\n\n public override clone(): LineBreakRun {\n return new LineBreakRun(this.toJSON());\n }\n\n /** Simply returns [[TextBlockStringifyOptions.lineBreak]]. */\n public override stringify(options?: TextBlockStringifyOptions): string {\n return options?.lineBreak ?? \" \";\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof LineBreakRun && super.equals(other);\n }\n}\n\n/** JSON representation of a [[TabRun]].\n * @beta\n */\nexport interface TabRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"tab\";\n}\n\n/** A [[TabRun]] is used to shift the next tab stop.\n * @note Only left-justified tabs are supported at this tab.\n * @beta\n */\nexport class TabRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"tab\";\n\n public override toJSON(): TabRunProps {\n return {\n ...super.toJSON(),\n type: \"tab\",\n };\n }\n\n public override clone(): TabRun {\n return new TabRun(this.toJSON());\n }\n\n public static create(props?: Omit<TabRunProps, \"type\">): TabRun {\n return new TabRun(props);\n }\n\n /**\n * Converts a [[TabRun]] to its string representation.\n * If the `tabsAsSpaces` option is provided, returns a string of spaces of the specified length.\n * Otherwise, returns a tab character (\"\\t\").\n */\n public override stringify(options?: TextBlockStringifyOptions): string {\n if (options?.tabsAsSpaces) {\n return \" \".repeat(options.tabsAsSpaces);\n }\n\n return \"\\t\";\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof TabRun && super.equals(other);\n }\n}\n\n/** JSON representation of a [[Paragraph]].\n * @beta\n */\nexport interface ParagraphProps extends TextBlockComponentProps {\n /** The collection of [[Run]]s within the paragraph.\n * Default: an empty array.\n */\n runs?: RunProps[];\n}\n\n/** A collection of [[Run]]s within a [[TextBlock]]. Each paragraph within a text block is laid out on a separate line.\n * @beta\n */\nexport class Paragraph extends TextBlockComponent {\n /** The runs within the paragraph. You can modify the contents of this array to change the content of the paragraph. */\n public readonly runs: Run[];\n\n private constructor(props?: ParagraphProps) {\n super(props);\n this.runs = props?.runs?.map((run) => Run.fromJSON(run)) ?? [];\n }\n\n public override toJSON(): ParagraphProps {\n return {\n ...super.toJSON(),\n runs: this.runs.map((run) => run.toJSON()),\n };\n }\n\n /** Create a paragraph from its JSON representation. */\n public static create(props?: ParagraphProps): Paragraph {\n return new Paragraph(props);\n }\n\n public override clone(): Paragraph {\n return new Paragraph(this.toJSON());\n }\n\n /**\n * Clears any [[styleOverrides]] applied to this Paragraph.\n * Will also clear [[styleOverrides]] from all child components unless [[ClearTextStyleOptions.preserveChildrenOverrides]] is `true`.\n */\n public override clearStyleOverrides(options?: ClearTextStyleOptions): void {\n super.clearStyleOverrides();\n if (options?.preserveChildrenOverrides)\n return;\n\n for (const run of this.runs) {\n run.clearStyleOverrides();\n }\n }\n\n /** Compute a string representation of this paragraph by concatenating the string representations of all of its [[runs]]. */\n public override stringify(options?: TextBlockStringifyOptions): string {\n return this.runs.map((x) => x.stringify(options)).join(\"\");\n }\n\n public override equals(other: TextBlockComponent): boolean {\n if (!(other instanceof Paragraph)) {\n return false;\n }\n\n if (this.runs.length !== other.runs.length || !super.equals(other)) {\n return false;\n }\n\n return this.runs.every((run, index) => run.equals(other.runs[index]));\n }\n}\n\n/** Describes the relative alignment of the content of a [[TextBlock]].\n * @beta\n */\nexport type TextBlockJustification = \"left\" | \"center\" | \"right\";\n\n/** Describes the margins around the content inside a [[TextBlock]]. It's measured in meters.\n * @beta\n */\nexport interface TextBlockMargins {\n /** The left margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n left: number;\n /** The right margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n right: number;\n /** The top margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n top: number;\n /** The bottom margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n bottom: number;\n};\n\n/** JSON representation of a [[TextBlock]].\n * @beta\n */\nexport interface TextBlockProps extends TextBlockComponentProps {\n /** The ID of an [AnnotationTextStyle]($backend) stored in the iModel from which the base [[TextStyleSettings]] applied to the [[TextBlock]] originates. */\n styleId: Id64String;\n /** The width of the document in meters. Lines that would exceed this width are instead wrapped around to the next line if possible.\n * A value less than or equal to zero indicates no wrapping is to be applied.\n * Default: 0\n */\n width?: number;\n /** The alignment of the document content. Default: \"left\". */\n justification?: TextBlockJustification;\n /** The margins to surround the document content. Default: 0 margins on all sides */\n margins?: Partial<TextBlockMargins>;\n /** The paragraphs within the text block. Default: an empty array. */\n paragraphs?: ParagraphProps[];\n}\n\n/** Represents a formatted text document consisting of a series of [[Paragraph]]s, each laid out on a separate line and containing their own content in the form of [[Run]]s.\n * You can change the content of the document by directly modifying the contents of its [[paragraphs]], or via [[appendParagraph]] and [[appendRun]].\n * No word-wrapping is applied to the document unless a [[width]] greater than zero is specified.\n * @see [[TextAnnotation]] to position a text block as an annotation in 2d or 3d space.\n * @beta\n */\nexport class TextBlock extends TextBlockComponent {\n /** The ID of the [AnnotationTextStyle]($backend) that provides the base formatting for the contents of this TextBlock.\n * @note Assigning to this property retains all style overrides on the TextBlock and its child components.\n * Call [[clearStyleOverrides]] to clear the TextBlock's and optionally all children's style overrides.\n */\n public styleId: Id64String;\n /** The width of the document in meters. Lines that would exceed this width are instead wrapped around to the next line if possible.\n * A value less than or equal to zero indicates no wrapping is to be applied.\n * Default: 0\n */\n public width: number;\n /** The alignment of the document's content. */\n public justification: TextBlockJustification;\n /** The margins of the document. */\n public margins: TextBlockMargins;\n /** The ordered list of paragraphs within the document. */\n public readonly paragraphs: Paragraph[];\n\n private constructor(props: TextBlockProps) {\n super(props);\n this.styleId = props.styleId;\n this.width = props.width ?? 0;\n this.justification = props.justification ?? \"left\";\n\n // Assign default margins if not provided\n this.margins = {\n left: props.margins?.left ?? 0,\n right: props.margins?.right ?? 0,\n top: props.margins?.top ?? 0,\n bottom: props.margins?.bottom ?? 0,\n };\n\n this.paragraphs = props.paragraphs?.map((x) => Paragraph.create(x)) ?? [];\n }\n\n public override toJSON(): TextBlockProps {\n return {\n ...super.toJSON(),\n styleId: this.styleId,\n width: this.width,\n justification: this.justification,\n margins: this.margins,\n paragraphs: this.paragraphs.map((x) => x.toJSON()),\n };\n }\n\n /** Create a text block from its JSON representation. */\n public static create(props: TextBlockProps): TextBlock {\n return new TextBlock(props);\n }\n\n /** Create an empty text block containing no [[paragraphs]] and an empty [[styleId]]. */\n public static createEmpty(): TextBlock {\n return TextBlock.create({ styleId: \"\" });\n }\n\n /** Returns true if every paragraph in this text block is empty. */\n public get isEmpty(): boolean {\n return this.paragraphs.every((p) => p.runs.length === 0);\n }\n\n public override clone(): TextBlock {\n return new TextBlock(this.toJSON());\n }\n\n /**\n * Clears any [[styleOverrides]] applied to this TextBlock.\n * Will also clear [[styleOverrides]] from all child components unless [[ClearTextStyleOptions.preserveChildrenOverrides]] is `true`.\n */\n public override clearStyleOverrides(options?: ClearTextStyleOptions): void {\n super.clearStyleOverrides();\n if (options?.preserveChildrenOverrides)\n return;\n\n for (const paragraph of this.paragraphs) {\n paragraph.clearStyleOverrides();\n }\n }\n\n /** Compute a string representation of the document's contents by concatenating the string representations of each of its [[paragraphs]], separated by [[TextBlockStringifyOptions.paragraphBreak]]. */\n public stringify(options?: TextBlockStringifyOptions): string {\n return this.paragraphs.map((x) => x.stringify(options)).join(options?.paragraphBreak ?? \" \");\n }\n\n /** Add and return a new paragraph.\n * By default, the paragraph will be created with no [[styleOverrides]], so that it inherits the style of this block.\n * @param seedFromLast If true and [[paragraphs]] is not empty, the new paragraph will inherit the style overrides of the last [[Paragraph]] in this block.\n */\n public appendParagraph(seedFromLast: boolean = false): Paragraph {\n let styleOverrides: TextStyleSettingsProps = {};\n\n if (seedFromLast && this.paragraphs.length > 0) {\n const seed = this.paragraphs[this.paragraphs.length - 1];\n styleOverrides = { ...seed.styleOverrides };\n }\n\n const paragraph = Paragraph.create({\n styleOverrides\n });\n\n this.paragraphs.push(paragraph);\n return paragraph;\n }\n\n /** Append a run to the last [[Paragraph]] in this block.\n * If the block contains no [[paragraphs]], a new one will first be created using [[appendParagraph]].\n */\n public appendRun(run: Run): void {\n const paragraph = this.paragraphs[this.paragraphs.length - 1] ?? this.appendParagraph();\n paragraph.runs.push(run);\n }\n\n public override equals(other: TextBlockComponent): boolean {\n if (!(other instanceof TextBlock)) {\n return false;\n }\n\n if (this.styleId !== other.styleId || !super.equals(other)) {\n return false;\n }\n\n if (this.width !== other.width || this.justification !== other.justification || this.paragraphs.length !== other.paragraphs.length) {\n return false;\n }\n\n const marginsAreEqual = Object.entries(this.margins).every(([key, value]) =>\n value === (other.margins as any)[key]\n );\n\n if (!marginsAreEqual) return false;\n\n return this.paragraphs.every((paragraph, index) => paragraph.equals(other.paragraphs[index]));\n }\n}\n"]}
1
+ {"version":3,"file":"TextBlock.js","sourceRoot":"","sources":["../../../src/annotation/TextBlock.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,iBAAiB,EAA0B,MAAM,aAAa,CAAC;AA4CxE;;;GAGG;AACH,MAAM,OAAgB,kBAAkB;IAC9B,eAAe,CAAyB;IAEhD,gBAAgB;IAChB,YAAsB,KAA+B;QACnD,IAAI,CAAC,eAAe,GAAG,iBAAiB,CAAC,UAAU,CAAC,KAAK,EAAE,cAAc,IAAI,EAAE,CAAC,CAAC;IACnF,CAAC;IAED;;;OAGG;IACH,IAAW,cAAc;QACvB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED,IAAW,cAAc,CAAC,SAAiC;QACzD,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AI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAEe,MAAM,CAAC,KAAyB;QAC9C,IAAI,CAAC,CAAC,KAAK,YAAY,SAAS,CAAC,EAAE,CAAC;YAClC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3D,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,aAAa,KAAK,KAAK,CAAC,aAAa,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YACnI,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAC1E,KAAK,KAAM,KAAK,CAAC,OAAe,CAAC,GAAG,CAAC,CACtC,CAAC;QAEF,IAAI,CAAC,eAAe;YAAE,OAAO,KAAK,CAAC;QAEnC,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChG,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Annotation\n */\n\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { TextStyleSettings, TextStyleSettingsProps } from \"./TextStyle\";\n\n/** Options supplied to [[TextBlockComponent.clearStyleOverrides]] to control how the style overrides are cleared on the component and its child components.\n * @beta\n */\nexport interface ClearTextStyleOptions {\n /** Controls whether the styleOverrides of any child components are retained.\n * By default, all overrides are cleared.\n */\n preserveChildrenOverrides?: boolean;\n}\n\n/** The JSON representation of a [[TextBlockComponent]].\n * @beta\n */\nexport interface TextBlockComponentProps {\n /** Deviations from the base [[TextStyleSettings]] defined by the [AnnotationTextStyle]($backend) applied to this component.\n * This permits you to, e.g., create a [[TextBlock]] using \"Arial\" font and override one of its [[TextRun]]s to use \"Comic Sans\" instead.\n */\n styleOverrides?: TextStyleSettingsProps;\n}\n\n/** Options supplied to [[TextBlockComponent.stringify]] to control how the content is formatted.\n * @beta\n */\nexport interface TextBlockStringifyOptions {\n /** A string to insert in between each [[Paragraph]].\n * Default: \" \" - a single space.\n */\n paragraphBreak?: string;\n /** A string to insert for each [[LineBreakRun]].\n * Default: \" \" - a single space.\n */\n lineBreak?: string;\n /** A string to insert between the numerator and denominator of each [[FractionRun]].\n * Default: \"/\"\n */\n fractionSeparator?: string;\n /** The number of spaces to use for tabs. If not provided, tabs will be represented by a tab character: \"\\t\".\n * Default: \"undefined\" - use \"\\t\".\n */\n tabsAsSpaces?: number;\n}\n\n/** Abstract representation of any of the building blocks that make up a [[TextBlock]] document - namely [[Run]]s, [[Paragraph]]s, and [[TextBlock]] itself.\n * The [[TextBlock]] can specify an [AnnotationTextStyle]($backend) that formats its contents. Each component can specify an optional [[styleOverrides]] to customize that formatting.\n * @beta\n */\nexport abstract class TextBlockComponent {\n private _styleOverrides: TextStyleSettingsProps;\n\n /** @internal */\n protected constructor(props?: TextBlockComponentProps) {\n this._styleOverrides = TextStyleSettings.cloneProps(props?.styleOverrides ?? {});\n }\n\n /** Deviations in individual properties of the [[TextStyleSettings]] in the [AnnotationTextStyle]($backend) specified by `styleId` on the [[TextBlock]].\n * For example, if the style uses the \"Arial\" font, you can override that by settings `styleOverrides.fontName` to \"Comic Sans\".\n * @see [[clearStyleOverrides]] to reset this to an empty object.\n */\n public get styleOverrides(): TextStyleSettingsProps {\n return this._styleOverrides;\n }\n\n public set styleOverrides(overrides: TextStyleSettingsProps) {\n this._styleOverrides = TextStyleSettings.cloneProps(overrides);\n }\n\n /** Reset any [[styleOverrides]] applied to this component. */\n public clearStyleOverrides(_options?: ClearTextStyleOptions): void {\n this.styleOverrides = {};\n }\n\n /** Returns true if [[styleOverrides]] specifies any deviations from the [[TextBlock]]'s [AnnotationTextStyle]($backend). */\n public get overridesStyle(): boolean {\n return Object.keys(this.styleOverrides).length > 0;\n }\n\n /** Create a deep copy of this component. */\n public abstract clone(): TextBlockComponent;\n\n /** Compute a string representation of the contents of this component and all of its sub-components. */\n public abstract stringify(options?: TextBlockStringifyOptions): string;\n\n /**\n * Returns true if the string representation of this component consists only of whitespace characters.\n * Useful for checking if the component is visually empty (producing no graphics) or contains only spaces, tabs, or line breaks.\n */\n public get isWhitespace(): boolean {\n return /^\\s*$/g.test(this.stringify());\n };\n\n /** Convert this component to its JSON representation. */\n public toJSON(): TextBlockComponentProps {\n return {\n styleOverrides: TextStyleSettings.cloneProps(this.styleOverrides),\n };\n }\n\n /** Returns true if `this` is equivalent to `other`. */\n public equals(other: TextBlockComponent): boolean {\n const myKeys = Object.keys(this.styleOverrides);\n const yrKeys = Object.keys(other._styleOverrides);\n if (myKeys.length !== yrKeys.length) {\n return false;\n }\n\n for (const name of myKeys) {\n const key = name as keyof TextStyleSettingsProps;\n if (this.styleOverrides[key] !== other.styleOverrides[key]) {\n return false;\n }\n }\n\n return true;\n }\n}\n\n/** [[TextBlockComponent]]s contained within a [[Paragraph]].\n * @beta\n */\nexport type Run = TextRun | FractionRun | TabRun | LineBreakRun | FieldRun;\n\n/** The JSON representation of a [[Run]].\n * Use the `type` field to discriminate between the different kinds of runs.\n * @beta\n */\nexport type RunProps = TextRunProps | FractionRunProps | TabRunProps | LineBreakRunProps | FieldRunProps;\n\n/** A sequence of characters within a [[Paragraph]] that share a single style. Runs are the leaf nodes of a [[TextBlock]] document. When laid out for display, a single run may span\n * multiple lines, but it will never contain different styling.\n * Use the `type` field to discriminate between the different kinds of runs.\n * @beta\n */\nexport namespace Run { // eslint-disable-line @typescript-eslint/no-redeclare\n /** Create a run from its JSON representation.\n * @see [[TextRun.create]], [[FractionRun.create]], and [[LineBreakRun.create]] to create a run directly.\n */\n export function fromJSON(props: RunProps): Run {\n switch (props.type) {\n case \"text\": return TextRun.create(props);\n case \"fraction\": return FractionRun.create(props);\n case \"tab\": return TabRun.create(props);\n case \"linebreak\": return LineBreakRun.create(props);\n case \"field\": return FieldRun.create(props);\n }\n }\n}\n\n/** Describes whether the characters of a [[TextRun]] should be displayed normally, in subscript, or in superscript.\n * [[TextStyleSettings.superScriptScale]], [[TextStyleSettings.subScriptScale]], [[TextStyleSettings.superScriptOffsetFactor]], and [[TextStyleSettings.subScriptOffsetFactor]]\n * affect how the content is rendered.\n * @beta\n */\nexport type BaselineShift = \"subscript\" | \"superscript\" | \"none\";\n\n/** JSON representation of a [[TextRun]].\n * @beta\n */\nexport interface TextRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"text\";\n /** The characters displayed by the run.\n * Default: an empty string.\n */\n content?: string;\n /** Whether to display [[content]] as a subscript, superscript, or normally.\n * Default: \"none\"\n */\n baselineShift?: BaselineShift;\n}\n\n/** The most common type of [[Run]], containing a sequence of characters to be displayed using a single style.\n * @beta\n */\nexport class TextRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"text\";\n /** The sequence of characters to be displayed by the run. */\n public content: string;\n /** Whether to display [[content]] as a subscript, superscript, or normally. */\n public baselineShift: BaselineShift;\n\n private constructor(props?: Omit<TextRunProps, \"type\">) {\n super(props);\n this.content = props?.content ?? \"\";\n this.baselineShift = props?.baselineShift ?? \"none\";\n }\n\n public override clone(): TextRun {\n return new TextRun(this.toJSON());\n }\n\n public override toJSON(): TextRunProps {\n return {\n ...super.toJSON(),\n type: \"text\",\n content: this.content,\n baselineShift: this.baselineShift,\n };\n }\n\n public static create(props?: Omit<TextRunProps, \"type\">): TextRun {\n return new TextRun(props);\n }\n\n /** Simply returns [[content]]. */\n public override stringify(): string {\n return this.content;\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof TextRun && this.content === other.content && this.baselineShift === other.baselineShift && super.equals(other);\n }\n}\n\n/** JSON representation of a [[FractionRun]].\n * @beta\n */\nexport interface FractionRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"fraction\";\n /** The text displayed before or above the fraction separator, depending on [[TextStyleSettings.stackedFractionType]]. Default: an empty string. */\n numerator?: string;\n /** The text displayed after or below the fraction separator, depending on [[TextStyleSettings.stackedFractionType]]. Default: an empty string. */\n denominator?: string;\n}\n\n/** A [[Run]] containing a numeric ratio to be displayed as a numerator and denominator separated by a horizontal or diagonal bar.\n * @note The [[numerator]] and [[denominator]] are stored as strings. They are not technically required to contain a numeric representation.\n * @beta\n */\nexport class FractionRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"fraction\";\n /** The fraction's numerator. */\n public numerator: string;\n /** The fraction's denominator. */\n public denominator: string;\n\n private constructor(props?: Omit<FractionRunProps, \"type\">) {\n super(props);\n this.numerator = props?.numerator ?? \"\";\n this.denominator = props?.denominator ?? \"\";\n }\n\n public override toJSON(): FractionRunProps {\n return {\n ...super.toJSON(),\n type: \"fraction\",\n numerator: this.numerator,\n denominator: this.denominator,\n };\n }\n\n public override clone(): FractionRun {\n return new FractionRun(this.toJSON());\n }\n\n public static create(props?: Omit<FractionRunProps, \"type\">): FractionRun {\n return new FractionRun(props);\n }\n\n /** Formats the fraction as a string with the [[numerator]] and [[denominator]] separated by [[TextBlockStringifyOptions.fractionSeparator]]. */\n public override stringify(options?: TextBlockStringifyOptions): string {\n const sep = options?.fractionSeparator ?? \"/\";\n return `${this.numerator}${sep}${this.denominator}`;\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof FractionRun && this.numerator === other.numerator && this.denominator === other.denominator && super.equals(other);\n }\n}\n\n/** JSON representation of a [[LineBreakRun]].\n * @beta\n */\nexport interface LineBreakRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"linebreak\";\n}\n\n/** A [[Run]] that represents the end of a line of text within a [[Paragraph]]. It contains no content of its own - it simply causes subsequent content to display on a new line.\n * @beta\n */\nexport class LineBreakRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"linebreak\";\n\n private constructor(props?: TextBlockComponentProps) {\n super(props);\n }\n\n public override toJSON(): LineBreakRunProps {\n return {\n ...super.toJSON(),\n type: \"linebreak\",\n };\n }\n\n public static create(props?: TextBlockComponentProps) {\n return new LineBreakRun(props);\n }\n\n public override clone(): LineBreakRun {\n return new LineBreakRun(this.toJSON());\n }\n\n /** Simply returns [[TextBlockStringifyOptions.lineBreak]]. */\n public override stringify(options?: TextBlockStringifyOptions): string {\n return options?.lineBreak ?? \" \";\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof LineBreakRun && super.equals(other);\n }\n}\n\n/** JSON representation of a [[TabRun]].\n * @beta\n */\nexport interface TabRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"tab\";\n}\n\n/** A [[TabRun]] is used to shift the next tab stop.\n * @note Only left-justified tabs are supported at this tab.\n * @beta\n */\nexport class TabRun extends TextBlockComponent {\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"tab\";\n\n public override toJSON(): TabRunProps {\n return {\n ...super.toJSON(),\n type: \"tab\",\n };\n }\n\n public override clone(): TabRun {\n return new TabRun(this.toJSON());\n }\n\n public static create(props?: Omit<TabRunProps, \"type\">): TabRun {\n return new TabRun(props);\n }\n\n /**\n * Converts a [[TabRun]] to its string representation.\n * If the `tabsAsSpaces` option is provided, returns a string of spaces of the specified length.\n * Otherwise, returns a tab character (\"\\t\").\n */\n public override stringify(options?: TextBlockStringifyOptions): string {\n if (options?.tabsAsSpaces) {\n return \" \".repeat(options.tabsAsSpaces);\n }\n\n return \"\\t\";\n }\n\n public override equals(other: TextBlockComponent): boolean {\n return other instanceof TabRun && super.equals(other);\n }\n}\n\n/** A chain of property accesses that resolves to a primitive value that forms the basis of the displayed content\n * of a [[FieldRun]].\n * The simplest property paths consist of a [[propertyName]] and nothing else, where `propertyName` identifies\n * a primitive property.\n * If `propertyName` identifies a struct or array property, then additional [[accessors]] are required to identify the specific value.\n * If `propertyName` (including any [[accessors]]) resolves to a JSON property, then additional [[jsonAccessors]] are required to identify a specific value within the JSON.\n * Some examples:\n * ```\n * | Access String | propertyName | accessors | jsonAccessors |\n * | ------------- | ------------ | --------- | ------------- |\n * | name | \"name\" | undefined | undefined |\n * | spouse.name | \"spouse\" | [name] | undefined |\n * | colors[2] | \"colors\" | [2] | undefined |\n * | spouse.favoriteRestaurants[1].address | \"spouse\" | [\"favoriteRestaurants\", 1, \"address\"] | undefined |\n * | jsonProperties.contactInfo.email | \"jsonProperties\" | undefined | [\"contactInfo\", \"email\"] |\n * | spouse.jsonProperties.contactInfo.phoneNumbers[0].areaCode | \"spouse\" | [\"jsonProperties\"] | [\"contactInfo\", \"phoneNumbers\", 0, \"areaCode\"] |\n * ```\n * @beta\n */\nexport interface FieldPropertyPath {\n /** The name of the BIS property of the [[FieldPropertyHost]] that serves as the root of the path. */\n propertyName: string;\n /** Property names and/or array indices describing the path from [[propertyName]] to the ultimate BIS property. */\n accessors?: Array<string | number>;\n /** If [[propertyName]] and [[accessors]] (if defined) resolve to a BIS property of extended type `Json`, property names and/or\n * array indices for selecting a primitive value within the JSON.\n */\n jsonAccessors?: Array<string | number>;\n}\n\n/** Describes the source of the property value against which a [[FieldPropertyPath]] is evaluated.\n * A field property is always hosted by an [Element]($backend). It may be a property of the element's BIS class itself,\n * or that of one of its [ElementAspect]($backend)s.\n * The [[schemaName]] and [[className]] should always identify the exact class that contains [[FieldPropertyPath.propertyName]] - not a subclass thereof.\n * @beta\n */\nexport interface FieldPropertyHost {\n /** The Id of the [Element]($backend) that hosts the property. */\n elementId: Id64String;\n /** The name of the schema containing the class identified by [[className]]. */\n schemaName: string;\n /** The name of the exact class (not a subclass) containing the property identified by [[FieldPropertyPath.propertyName]]. */\n className: string;\n}\n\n/** Placeholder type for a description of how to format the raw property value resolved by a [[FieldPropertyPath]] into a [[FieldRun]]'s display string.\n * *** COMING SOON ***\n * @beta\n */\nexport interface FieldFormatter { [k: string]: any }\n\n/** JSON representation of a [[FieldRun]].\n * @beta\n */\nexport interface FieldRunProps extends TextBlockComponentProps {\n /** Discriminator field for the [[RunProps]] union. */\n readonly type: \"field\";\n /** The element and BIS class containing the property described by [[propertyPath]]. */\n propertyHost: FieldPropertyHost;\n /** Describes how to obtain the property value from [[propertyHost]]. */\n propertyPath: FieldPropertyPath;\n /** Specifies how to format the property value obtained from [[propertyPath]] into a string to be stored in [[cachedContent]]. */\n formatter?: FieldFormatter;\n /** The field's most recently evaluated display string. */\n cachedContent?: string;\n}\n\n/** A [[Run]] that displays the formatted value of a property of some [Element]($backend).\n * When a [[TextBlock]] containing a [[FieldRun]] is written into the iModel as an [ITextAnnotation]($backend) element,\n * a dependency is established between the two elements via the [ElementDrivesTextAnnotation]($backend) relationship such that\n * whenever the source element specified by [[propertyHost]] is modified, the field(s) in the `ITextAnnotation` element are automatically\n * recalculated, causing their [[cachedContent]] to update. If the field's display string cannot be evaluated (for example, because the specified element or\n * property does not exist), then its cached content is set to [[FieldRun.invalidContentIndicator]].\n * A [[FieldRun]] displays its [[cachedContent]] in the same way that [[TextRun]]s display their `content`, including word wrapping where appropriate.\n * @beta\n */\nexport class FieldRun extends TextBlockComponent {\n /** Display string used to signal an error in computing the field's value. */\n public static invalidContentIndicator = \"####\";\n\n /** Discriminator field for the [[Run]] union. */\n public readonly type = \"field\";\n /** The element and BIS class containing the property described by [[propertyPath]]. */\n public readonly propertyHost: Readonly<FieldPropertyHost>;\n /** Describes how to obtain the property value from [[propertyHost]]. */\n public readonly propertyPath: Readonly<FieldPropertyPath>;\n /** Specifies how to format the property value obtained from [[propertyPath]] into a string to be stored in [[cachedContent]]. */\n public readonly formatter?: FieldFormatter;\n private _cachedContent: string;\n\n /** The field's most recently evaluated display string. */\n public get cachedContent(): string {\n return this._cachedContent;\n }\n\n /** @internal Used by core-backend when re-evaluating field content. */\n public setCachedContent(content: string | undefined): void {\n this._cachedContent = content ?? FieldRun.invalidContentIndicator;\n }\n\n private constructor(props: Omit<FieldRunProps, \"type\">) {\n super(props);\n\n this._cachedContent = props.cachedContent ?? FieldRun.invalidContentIndicator;\n this.propertyHost = props.propertyHost\n this.propertyPath = props.propertyPath;\n this.formatter = props.formatter;\n }\n\n /** Create a FieldRun from its JSON representation. */\n public static create(props: Omit<FieldRunProps, \"type\">): FieldRun {\n return new FieldRun({\n ...props,\n propertyHost: { ...props.propertyHost },\n propertyPath: structuredClone(props.propertyPath),\n formatter: structuredClone(props.formatter),\n });\n }\n\n /** Convert the FieldRun to its JSON representation. */\n public override toJSON(): FieldRunProps {\n const json: FieldRunProps = {\n ...super.toJSON(),\n type: \"field\",\n propertyHost: { ...this.propertyHost },\n propertyPath: structuredClone(this.propertyPath),\n };\n\n if (this.cachedContent !== FieldRun.invalidContentIndicator) {\n json.cachedContent = this.cachedContent;\n }\n\n if (this.formatter) {\n json.formatter = structuredClone(this.formatter);\n }\n\n return json;\n }\n\n /** Create a deep copy of this FieldRun. */\n public override clone(): FieldRun {\n return new FieldRun(this.toJSON());\n }\n\n /** Convert this FieldRun to a simple string representation. */\n public override stringify(): string {\n return this.cachedContent;\n }\n\n /** Returns true if `this` is equivalent to `other`. */\n public override equals(other: TextBlockComponent): boolean {\n if (!(other instanceof FieldRun) || !super.equals(other)) {\n return false;\n }\n\n if (\n this.propertyHost.elementId !== other.propertyHost.elementId ||\n this.propertyHost.className !== other.propertyHost.className ||\n this.propertyHost.schemaName !== other.propertyHost.schemaName\n ) {\n return false;\n }\n\n if (this.propertyPath.propertyName !== other.propertyPath.propertyName) {\n return false;\n }\n\n const thisAccessors = this.propertyPath.accessors ?? [];\n const otherAccessors = other.propertyPath.accessors ?? [];\n const thisJsonAccessors = this.propertyPath.jsonAccessors ?? [];\n const otherJsonAccessors = other.propertyPath.jsonAccessors ?? [];\n\n if (thisAccessors.length !== otherAccessors.length || thisJsonAccessors.length !== otherJsonAccessors.length) {\n return false;\n }\n\n if (!thisAccessors.every((value, index) => value === otherAccessors[index])) {\n return false;\n }\n\n if (!thisJsonAccessors.every((value, index) => value === otherJsonAccessors[index])) {\n return false;\n }\n\n if (this.formatter && other.formatter) {\n // ###TODO better comparison of formatter objects.\n if (JSON.stringify(this.formatter) !== JSON.stringify(other.formatter)) {\n return false;\n }\n } else if (this.formatter || other.formatter) {\n return false;\n }\n\n return true;\n }\n}\n\n/** JSON representation of a [[Paragraph]].\n * @beta\n */\nexport interface ParagraphProps extends TextBlockComponentProps {\n /** The collection of [[Run]]s within the paragraph.\n * Default: an empty array.\n */\n runs?: RunProps[];\n}\n\n/** A collection of [[Run]]s within a [[TextBlock]]. Each paragraph within a text block is laid out on a separate line.\n * @beta\n */\nexport class Paragraph extends TextBlockComponent {\n /** The runs within the paragraph. You can modify the contents of this array to change the content of the paragraph. */\n public readonly runs: Run[];\n\n private constructor(props?: ParagraphProps) {\n super(props);\n this.runs = props?.runs?.map((run) => Run.fromJSON(run)) ?? [];\n }\n\n public override toJSON(): ParagraphProps {\n return {\n ...super.toJSON(),\n runs: this.runs.map((run) => run.toJSON()),\n };\n }\n\n /** Create a paragraph from its JSON representation. */\n public static create(props?: ParagraphProps): Paragraph {\n return new Paragraph(props);\n }\n\n public override clone(): Paragraph {\n return new Paragraph(this.toJSON());\n }\n\n /**\n * Clears any [[styleOverrides]] applied to this Paragraph.\n * Will also clear [[styleOverrides]] from all child components unless [[ClearTextStyleOptions.preserveChildrenOverrides]] is `true`.\n */\n public override clearStyleOverrides(options?: ClearTextStyleOptions): void {\n super.clearStyleOverrides();\n if (options?.preserveChildrenOverrides)\n return;\n\n for (const run of this.runs) {\n run.clearStyleOverrides();\n }\n }\n\n /** Compute a string representation of this paragraph by concatenating the string representations of all of its [[runs]]. */\n public override stringify(options?: TextBlockStringifyOptions): string {\n return this.runs.map((x) => x.stringify(options)).join(\"\");\n }\n\n public override equals(other: TextBlockComponent): boolean {\n if (!(other instanceof Paragraph)) {\n return false;\n }\n\n if (this.runs.length !== other.runs.length || !super.equals(other)) {\n return false;\n }\n\n return this.runs.every((run, index) => run.equals(other.runs[index]));\n }\n}\n\n/** Describes the relative alignment of the content of a [[TextBlock]].\n * @beta\n */\nexport type TextBlockJustification = \"left\" | \"center\" | \"right\";\n\n/** Describes the margins around the content inside a [[TextBlock]]. It's measured in meters.\n * @beta\n */\nexport interface TextBlockMargins {\n /** The left margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n left: number;\n /** The right margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n right: number;\n /** The top margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n top: number;\n /** The bottom margin measured in meters. Must be a positive number >= 0. Negative values are disregarded */\n bottom: number;\n};\n\n/** JSON representation of a [[TextBlock]].\n * @beta\n */\nexport interface TextBlockProps extends TextBlockComponentProps {\n /** The ID of an [AnnotationTextStyle]($backend) stored in the iModel from which the base [[TextStyleSettings]] applied to the [[TextBlock]] originates. */\n styleId: Id64String;\n /** The width of the document in meters. Lines that would exceed this width are instead wrapped around to the next line if possible.\n * A value less than or equal to zero indicates no wrapping is to be applied.\n * Default: 0\n */\n width?: number;\n /** The alignment of the document content. Default: \"left\". */\n justification?: TextBlockJustification;\n /** The margins to surround the document content. Default: 0 margins on all sides */\n margins?: Partial<TextBlockMargins>;\n /** The paragraphs within the text block. Default: an empty array. */\n paragraphs?: ParagraphProps[];\n}\n\n/** Represents a formatted text document consisting of a series of [[Paragraph]]s, each laid out on a separate line and containing their own content in the form of [[Run]]s.\n * You can change the content of the document by directly modifying the contents of its [[paragraphs]], or via [[appendParagraph]] and [[appendRun]].\n * No word-wrapping is applied to the document unless a [[width]] greater than zero is specified.\n * @see [[TextAnnotation]] to position a text block as an annotation in 2d or 3d space.\n * @beta\n */\nexport class TextBlock extends TextBlockComponent {\n /** The ID of the [AnnotationTextStyle]($backend) that provides the base formatting for the contents of this TextBlock.\n * @note Assigning to this property retains all style overrides on the TextBlock and its child components.\n * Call [[clearStyleOverrides]] to clear the TextBlock's and optionally all children's style overrides.\n */\n public styleId: Id64String;\n /** The width of the document in meters. Lines that would exceed this width are instead wrapped around to the next line if possible.\n * A value less than or equal to zero indicates no wrapping is to be applied.\n * Default: 0\n */\n public width: number;\n /** The alignment of the document's content. */\n public justification: TextBlockJustification;\n /** The margins of the document. */\n public margins: TextBlockMargins;\n /** The ordered list of paragraphs within the document. */\n public readonly paragraphs: Paragraph[];\n\n private constructor(props: TextBlockProps) {\n super(props);\n this.styleId = props.styleId;\n this.width = props.width ?? 0;\n this.justification = props.justification ?? \"left\";\n\n // Assign default margins if not provided\n this.margins = {\n left: props.margins?.left ?? 0,\n right: props.margins?.right ?? 0,\n top: props.margins?.top ?? 0,\n bottom: props.margins?.bottom ?? 0,\n };\n\n this.paragraphs = props.paragraphs?.map((x) => Paragraph.create(x)) ?? [];\n }\n\n public override toJSON(): TextBlockProps {\n return {\n ...super.toJSON(),\n styleId: this.styleId,\n width: this.width,\n justification: this.justification,\n margins: this.margins,\n paragraphs: this.paragraphs.map((x) => x.toJSON()),\n };\n }\n\n /** Create a text block from its JSON representation. */\n public static create(props: TextBlockProps): TextBlock {\n return new TextBlock(props);\n }\n\n /** Create an empty text block containing no [[paragraphs]] and an empty [[styleId]]. */\n public static createEmpty(): TextBlock {\n return TextBlock.create({ styleId: \"\" });\n }\n\n /** Returns true if every paragraph in this text block is empty. */\n public get isEmpty(): boolean {\n return this.paragraphs.every((p) => p.runs.length === 0);\n }\n\n public override clone(): TextBlock {\n return new TextBlock(this.toJSON());\n }\n\n /**\n * Clears any [[styleOverrides]] applied to this TextBlock.\n * Will also clear [[styleOverrides]] from all child components unless [[ClearTextStyleOptions.preserveChildrenOverrides]] is `true`.\n */\n public override clearStyleOverrides(options?: ClearTextStyleOptions): void {\n super.clearStyleOverrides();\n if (options?.preserveChildrenOverrides)\n return;\n\n for (const paragraph of this.paragraphs) {\n paragraph.clearStyleOverrides();\n }\n }\n\n /** Compute a string representation of the document's contents by concatenating the string representations of each of its [[paragraphs]], separated by [[TextBlockStringifyOptions.paragraphBreak]]. */\n public stringify(options?: TextBlockStringifyOptions): string {\n return this.paragraphs.map((x) => x.stringify(options)).join(options?.paragraphBreak ?? \" \");\n }\n\n /** Add and return a new paragraph.\n * By default, the paragraph will be created with no [[styleOverrides]], so that it inherits the style of this block.\n * @param seedFromLast If true and [[paragraphs]] is not empty, the new paragraph will inherit the style overrides of the last [[Paragraph]] in this block.\n */\n public appendParagraph(seedFromLast: boolean = false): Paragraph {\n let styleOverrides: TextStyleSettingsProps = {};\n\n if (seedFromLast && this.paragraphs.length > 0) {\n const seed = this.paragraphs[this.paragraphs.length - 1];\n styleOverrides = { ...seed.styleOverrides };\n }\n\n const paragraph = Paragraph.create({\n styleOverrides\n });\n\n this.paragraphs.push(paragraph);\n return paragraph;\n }\n\n /** Append a run to the last [[Paragraph]] in this block.\n * If the block contains no [[paragraphs]], a new one will first be created using [[appendParagraph]].\n */\n public appendRun(run: Run): void {\n const paragraph = this.paragraphs[this.paragraphs.length - 1] ?? this.appendParagraph();\n paragraph.runs.push(run);\n }\n\n public override equals(other: TextBlockComponent): boolean {\n if (!(other instanceof TextBlock)) {\n return false;\n }\n\n if (this.styleId !== other.styleId || !super.equals(other)) {\n return false;\n }\n\n if (this.width !== other.width || this.justification !== other.justification || this.paragraphs.length !== other.paragraphs.length) {\n return false;\n }\n\n const marginsAreEqual = Object.entries(this.margins).every(([key, value]) =>\n value === (other.margins as any)[key]\n );\n\n if (!marginsAreEqual) return false;\n\n return this.paragraphs.every((paragraph, index) => paragraph.equals(other.paragraphs[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ourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { BentleyStatus, Logger } from \"@itwin/core-bentley\";\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\nimport { IModelError } from \"../../IModelError\";\nimport { RpcInterfaceDefinition } from \"../../RpcInterface\";\nimport { RpcProtocolEvent } from \"../core/RpcConstants\";\nimport { RpcInvocation } from \"../core/RpcInvocation\";\nimport { RpcOperation } from \"../core/RpcOperation\";\nimport { SerializedRpcOperation, SerializedRpcRequest } from \"../core/RpcProtocol\";\nimport { RpcRequest } from \"../core/RpcRequest\";\nimport { WebAppRpcRequest } from \"./WebAppRpcRequest\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** @internal */\nconst BACKEND = Symbol.for(\"@itwin.WebAppRpcLogging.Backend\");\nconst FRONTEND = Symbol.for(\"@itwin.WebAppRpcLogging.Frontend\");\n\n/** @internal */\nexport abstract class WebAppRpcLogging {\n public static initializeBackend(instance: WebAppRpcLogging) {\n (globalThis as any)[BACKEND] = instance;\n }\n\n public static initializeFrontend(instance: WebAppRpcLogging) {\n (globalThis as any)[FRONTEND] = instance;\n }\n\n private static get backend(): WebAppRpcLogging {\n const instance = (globalThis as any)[BACKEND];\n if (typeof (instance) === \"undefined\") {\n throw new IModelError(BentleyStatus.ERROR, \"Backend logging is not initialized.\");\n }\n\n return instance;\n }\n\n private static get frontend(): WebAppRpcLogging {\n const instance = (globalThis as any)[FRONTEND];\n if (typeof (instance) === \"undefined\") {\n throw new IModelError(BentleyStatus.ERROR, \"Frontend logging is not initialized.\");\n }\n\n return instance;\n }\n\n public static async logProtocolEvent(event: RpcProtocolEvent, object: RpcRequest | RpcInvocation): Promise<void> {\n if (object instanceof WebAppRpcRequest) {\n await WebAppRpcLogging.frontend.logProtocolEvent(event, object);\n } else if (object instanceof RpcInvocation) {\n await WebAppRpcLogging.backend.logProtocolEvent(event, object);\n }\n }\n\n protected abstract logProtocolEvent(event: RpcProtocolEvent, object: RpcRequest | RpcInvocation): Promise<void>;\n\n protected abstract getHostname(): string;\n\n protected getRpcInterfaceName(g: string | RpcInterfaceDefinition): string {\n return (typeof g === \"string\") ? g : g.interfaceName;\n }\n\n protected findPathIds(path: string) {\n let iTwinId = \"\";\n let iModelId = \"\";\n\n const tokens = path.split(\"/\");\n for (let i = 0; i !== tokens.length; ++i) {\n // For backwards compatibility, find old \"context\" or current \"iTwin\" terminology\n if ((/^context$/i).test(tokens[i]) || (/^itwin$/i).test(tokens[i])) {\n iTwinId = tokens[i + 1] || \"\";\n }\n\n if ((/^imodel$/i).test(tokens[i])) {\n iModelId = tokens[i + 1] || \"\";\n }\n }\n\n return { iTwinId, iModelId };\n }\n\n protected buildOperationDescriptor(operation: RpcOperation | SerializedRpcOperation): string {\n if (!operation) {\n return \"unknown.unknown\";\n }\n\n const interfaceName = typeof (operation.interfaceDefinition) === \"string\" ? operation.interfaceDefinition : operation.interfaceDefinition.interfaceName;\n const operationName = operation.operationName;\n return `${interfaceName}.${operationName}`;\n }\n\n protected logRequest(loggerCategory: string, message: string, object: WebAppRpcRequest | SerializedRpcRequest): void {\n const operationDescriptor = this.buildOperationDescriptor(object.operation);\n const pathIds = this.findPathIds(object.path);\n\n Logger.logTrace(loggerCategory, `${message}.${operationDescriptor}`, () => ({\n method: object.method,\n path: object.path,\n operation: object.operation.operationName,\n rpcInterface: this.getRpcInterfaceName(object.operation.interfaceDefinition),\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\n ActivityId: object.id, // eslint-disable-line @typescript-eslint/naming-convention\n TimeElapsed: (\"elapsed\" in object) ? object.elapsed : 0, // eslint-disable-line @typescript-eslint/naming-convention\n MachineName: this.getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\n ...pathIds,\n }));\n }\n\n protected logResponse(loggerCategory: string, message: string, object: WebAppRpcRequest | SerializedRpcRequest, status: number, elapsed: number): void {\n const operationDescriptor = this.buildOperationDescriptor(object.operation);\n const pathIds = this.findPathIds(object.path);\n\n Logger.logTrace(loggerCategory, `${message}.${operationDescriptor}`, () => ({\n method: object.method,\n path: object.path,\n operation: object.operation.operationName,\n rpcInterface: this.getRpcInterfaceName(object.operation.interfaceDefinition),\n status,\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\n ActivityId: object.id, // eslint-disable-line @typescript-eslint/naming-convention\n TimeElapsed: elapsed, // eslint-disable-line @typescript-eslint/naming-convention\n MachineName: this.getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\n ...pathIds,\n }));\n }\n}\n\ndeclare global {\n // eslint-disable-next-line no-var\n var window: any;\n}\n\nclass WebAppRpcLoggingFrontend extends WebAppRpcLogging {\n protected override async logProtocolEvent(event: RpcProtocolEvent, object: WebAppRpcRequest): Promise<void> {\n switch (event) {\n case RpcProtocolEvent.RequestCreated: return this.logRequest(CommonLoggerCategory.RpcInterfaceFrontend, \"RpcInterface.frontend.request\", object);\n case RpcProtocolEvent.ResponseLoaded: return this.logResponse(CommonLoggerCategory.RpcInterfaceFrontend, \"RpcInterface.frontend.response\", object, object.metadata.status, object.elapsed);\n case RpcProtocolEvent.ConnectionErrorReceived: return this.logErrorFrontend(\"RpcInterface.frontend.connectionError\", object);\n case RpcProtocolEvent.ConnectionAborted: return this.logErrorFrontend(\"RpcInterface.frontend.connectionAborted\", object);\n }\n }\n\n protected override getHostname(): string {\n return globalThis.window?.location?.host ?? \"imodeljs-mobile\";\n }\n\n private logErrorFrontend(message: string, request: WebAppRpcRequest): void {\n const operationDescriptor = this.buildOperationDescriptor(request.operation);\n const pathIds = this.findPathIds(request.path);\n\n Logger.logInfo(CommonLoggerCategory.RpcInterfaceFrontend, `${message}.${operationDescriptor}`, () => ({\n method: request.method,\n path: request.path,\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\n ActivityId: request.id, // eslint-disable-line @typescript-eslint/naming-convention\n MachineName: this.getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\n ...pathIds,\n }));\n }\n}\n\nWebAppRpcLogging.initializeFrontend(new WebAppRpcLoggingFrontend());\n"]}
1
+ {"version":3,"file":"WebAppRpcLogging.js","sourceRoot":"","sources":["../../../../src/rpc/web/WebAppRpcLogging.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAItD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,qDAAqD;AAErD,gBAAgB;AAChB,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;AAC9D,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAEhE,gBAAgB;AAChB,MAAM,OAAgB,gBAAgB;IAC7B,MAAM,CAAC,iBAAiB,CAAC,QAA0B;QACvD,UAAkB,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC;IAC1C,CAAC;IAEM,MAAM,CAAC,kBAAkB,CAAC,QAA0B;QACxD,UAAkB,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;IAC3C,CAAC;IAEO,MAAM,KAAK,OAAO;QACxB,MAAM,QAAQ,GAAI,UAAkB,CAAC,OAAO,CAAC,CAAC;QAC9C,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,WAAW,EAAE,CAAC;YACtC,MAAM,IAAI,WAAW,CAAC,aAAa,CAAC,KAAK,EAAE,qCAAqC,CAAC,CAAC;QACp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;SACX,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AAED,gBAAgB,CAAC,kBAAkB,CAAC,IAAI,wBAAwB,EAAE,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RpcInterface\n */\n\nimport { BentleyStatus, Logger } from \"@itwin/core-bentley\";\nimport { CommonLoggerCategory } from \"../../CommonLoggerCategory\";\nimport { IModelError } from \"../../IModelError\";\nimport { RpcInterfaceDefinition } from \"../../RpcInterface\";\nimport { RpcProtocolEvent } from \"../core/RpcConstants\";\nimport { RpcInvocation } from \"../core/RpcInvocation\";\nimport { RpcOperation } from \"../core/RpcOperation\";\nimport { SerializedRpcOperation, SerializedRpcRequest } from \"../core/RpcProtocol\";\nimport { RpcRequest } from \"../core/RpcRequest\";\nimport { WebAppRpcRequest } from \"./WebAppRpcRequest\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** @internal */\nconst BACKEND = Symbol.for(\"@itwin.WebAppRpcLogging.Backend\");\nconst FRONTEND = Symbol.for(\"@itwin.WebAppRpcLogging.Frontend\");\n\n/** @internal */\nexport abstract class WebAppRpcLogging {\n public static initializeBackend(instance: WebAppRpcLogging) {\n (globalThis as any)[BACKEND] = instance;\n }\n\n public static initializeFrontend(instance: WebAppRpcLogging) {\n (globalThis as any)[FRONTEND] = instance;\n }\n\n private static get backend(): WebAppRpcLogging {\n const instance = (globalThis as any)[BACKEND];\n if (typeof (instance) === \"undefined\") {\n throw new IModelError(BentleyStatus.ERROR, \"Backend logging is not initialized.\");\n }\n\n return instance;\n }\n\n private static get frontend(): WebAppRpcLogging {\n const instance = (globalThis as any)[FRONTEND];\n if (typeof (instance) === \"undefined\") {\n throw new IModelError(BentleyStatus.ERROR, \"Frontend logging is not initialized.\");\n }\n\n return instance;\n }\n\n public static async logProtocolEvent(event: RpcProtocolEvent, object: RpcRequest | RpcInvocation): Promise<void> {\n if (object instanceof WebAppRpcRequest) {\n await WebAppRpcLogging.frontend.logProtocolEvent(event, object);\n } else if (object instanceof RpcInvocation) {\n await WebAppRpcLogging.backend.logProtocolEvent(event, object);\n }\n }\n\n protected abstract logProtocolEvent(event: RpcProtocolEvent, object: RpcRequest | RpcInvocation): Promise<void>;\n\n protected abstract getHostname(): string;\n\n protected getRpcInterfaceName(g: string | RpcInterfaceDefinition): string {\n return (typeof g === \"string\") ? g : g.interfaceName;\n }\n\n protected findPathIds(path: string) {\n let iTwinId = \"\";\n let iModelId = \"\";\n\n const tokens = path.split(\"/\");\n for (let i = 0; i !== tokens.length; ++i) {\n // For backwards compatibility, find old \"context\" or current \"iTwin\" terminology\n if ((/^context$/i).test(tokens[i]) || (/^itwin$/i).test(tokens[i])) {\n iTwinId = tokens[i + 1] || \"\";\n }\n\n if ((/^imodel$/i).test(tokens[i])) {\n iModelId = tokens[i + 1] || \"\";\n }\n }\n\n return { iTwinId, iModelId };\n }\n\n protected buildOperationDescriptor(operation: RpcOperation | SerializedRpcOperation): string {\n if (!operation) {\n return \"unknown.unknown\";\n }\n\n const interfaceName = typeof (operation.interfaceDefinition) === \"string\" ? operation.interfaceDefinition : operation.interfaceDefinition.interfaceName;\n const operationName = operation.operationName;\n return `${interfaceName}.${operationName}`;\n }\n\n protected logRequest(loggerCategory: string, message: string, object: WebAppRpcRequest | SerializedRpcRequest): void {\n const operationDescriptor = this.buildOperationDescriptor(object.operation);\n const pathIds = this.findPathIds(object.path);\n\n Logger.logTrace(loggerCategory, `${message}.${operationDescriptor}`, () => ({\n method: object.method,\n path: object.path,\n operation: object.operation.operationName,\n rpcInterface: this.getRpcInterfaceName(object.operation.interfaceDefinition),\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\n ActivityId: object.id, // eslint-disable-line @typescript-eslint/naming-convention\n TimeElapsed: (\"elapsed\" in object) ? object.elapsed : 0, // eslint-disable-line @typescript-eslint/naming-convention\n MachineName: this.getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\n ...pathIds,\n }));\n }\n\n protected logResponse(loggerCategory: string, message: string, object: WebAppRpcRequest | SerializedRpcRequest, status: number, elapsed: number): void {\n const operationDescriptor = this.buildOperationDescriptor(object.operation);\n const pathIds = this.findPathIds(object.path);\n\n Logger.logTrace(loggerCategory, `${message}.${operationDescriptor}`, () => ({\n method: object.method,\n path: object.path,\n operation: object.operation.operationName,\n rpcInterface: this.getRpcInterfaceName(object.operation.interfaceDefinition),\n status,\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\n ActivityId: object.id, // eslint-disable-line @typescript-eslint/naming-convention\n TimeElapsed: elapsed, // eslint-disable-line @typescript-eslint/naming-convention\n MachineName: this.getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\n ...pathIds,\n }));\n }\n}\n\ndeclare global {\n \n var window: any;\n}\n\nclass WebAppRpcLoggingFrontend extends WebAppRpcLogging {\n protected override async logProtocolEvent(event: RpcProtocolEvent, object: WebAppRpcRequest): Promise<void> {\n switch (event) {\n case RpcProtocolEvent.RequestCreated: return this.logRequest(CommonLoggerCategory.RpcInterfaceFrontend, \"RpcInterface.frontend.request\", object);\n case RpcProtocolEvent.ResponseLoaded: return this.logResponse(CommonLoggerCategory.RpcInterfaceFrontend, \"RpcInterface.frontend.response\", object, object.metadata.status, object.elapsed);\n case RpcProtocolEvent.ConnectionErrorReceived: return this.logErrorFrontend(\"RpcInterface.frontend.connectionError\", object);\n case RpcProtocolEvent.ConnectionAborted: return this.logErrorFrontend(\"RpcInterface.frontend.connectionAborted\", object);\n }\n }\n\n protected override getHostname(): string {\n return globalThis.window?.location?.host ?? \"imodeljs-mobile\";\n }\n\n private logErrorFrontend(message: string, request: WebAppRpcRequest): void {\n const operationDescriptor = this.buildOperationDescriptor(request.operation);\n const pathIds = this.findPathIds(request.path);\n\n Logger.logInfo(CommonLoggerCategory.RpcInterfaceFrontend, `${message}.${operationDescriptor}`, () => ({\n method: request.method,\n path: request.path,\n // Alert! The following properties are required by Bentley DevOps standards. Do not change their names!\n ActivityId: request.id, // eslint-disable-line @typescript-eslint/naming-convention\n MachineName: this.getHostname(), // eslint-disable-line @typescript-eslint/naming-convention\n ...pathIds,\n }));\n }\n}\n\nWebAppRpcLogging.initializeFrontend(new WebAppRpcLoggingFrontend());\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-common",
3
- "version": "5.1.0-dev.64",
3
+ "version": "5.1.0-dev.65",
4
4
  "description": "iTwin.js components common to frontend and backend",
5
5
  "main": "lib/cjs/core-common.js",
6
6
  "module": "lib/esm/core-common.js",
@@ -27,8 +27,8 @@
27
27
  "js-base64": "^3.6.1"
28
28
  },
29
29
  "peerDependencies": {
30
- "@itwin/core-bentley": "5.1.0-dev.64",
31
- "@itwin/core-geometry": "5.1.0-dev.64"
30
+ "@itwin/core-bentley": "5.1.0-dev.65",
31
+ "@itwin/core-geometry": "5.1.0-dev.65"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@itwin/eslint-plugin": "5.2.2-dev.2",
@@ -42,9 +42,9 @@
42
42
  "rimraf": "^6.0.1",
43
43
  "typescript": "~5.6.2",
44
44
  "vitest": "^3.0.6",
45
- "@itwin/build-tools": "5.1.0-dev.64",
46
- "@itwin/core-bentley": "5.1.0-dev.64",
47
- "@itwin/core-geometry": "5.1.0-dev.64"
45
+ "@itwin/build-tools": "5.1.0-dev.65",
46
+ "@itwin/core-bentley": "5.1.0-dev.65",
47
+ "@itwin/core-geometry": "5.1.0-dev.65"
48
48
  },
49
49
  "nyc": {
50
50
  "extends": "./node_modules/@itwin/build-tools/.nycrc",