@itwin/core-backend 5.3.0-dev.9 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -1
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +14 -0
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/CloudSqlite.d.ts +2 -0
- package/lib/cjs/CloudSqlite.d.ts.map +1 -1
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +2 -2
- package/lib/cjs/DisplayStyle.d.ts.map +1 -1
- package/lib/cjs/DisplayStyle.js +4 -4
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.js +1 -1
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/Element.d.ts +31 -3
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +55 -3
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts +24 -1
- package/lib/cjs/ElementAspect.d.ts.map +1 -1
- package/lib/cjs/ElementAspect.js +102 -1
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +26 -3
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +60 -5
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelElementCloneContext.d.ts +1 -1
- package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -1
- package/lib/cjs/IModelElementCloneContext.js +2 -2
- package/lib/cjs/IModelElementCloneContext.js.map +1 -1
- package/lib/cjs/Material.d.ts +1 -1
- package/lib/cjs/Material.d.ts.map +1 -1
- package/lib/cjs/Material.js +2 -2
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/NavigationRelationship.d.ts +15 -0
- package/lib/cjs/NavigationRelationship.d.ts.map +1 -1
- package/lib/cjs/NavigationRelationship.js +22 -1
- package/lib/cjs/NavigationRelationship.js.map +1 -1
- package/lib/cjs/Relationship.d.ts +5 -0
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +7 -0
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +8 -0
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +30 -2
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +1 -1
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +2 -2
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +15 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.js +36 -23
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/cjs/annotations/LeaderGeometry.d.ts +13 -1
- package/lib/cjs/annotations/LeaderGeometry.d.ts.map +1 -1
- package/lib/cjs/annotations/LeaderGeometry.js +88 -10
- package/lib/cjs/annotations/LeaderGeometry.js.map +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.d.ts +6 -5
- package/lib/cjs/annotations/TextAnnotationElement.d.ts.map +1 -1
- package/lib/cjs/annotations/TextAnnotationElement.js +33 -14
- package/lib/cjs/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/cjs/annotations/TextBlockLayout.d.ts.map +1 -1
- package/lib/cjs/annotations/TextBlockLayout.js +2 -1
- package/lib/cjs/annotations/TextBlockLayout.js.map +1 -1
- package/lib/cjs/internal/annotations/fields.d.ts +3 -2
- package/lib/cjs/internal/annotations/fields.d.ts.map +1 -1
- package/lib/cjs/internal/annotations/fields.js +12 -5
- package/lib/cjs/internal/annotations/fields.js.map +1 -1
- package/lib/esm/BriefcaseManager.d.ts.map +1 -1
- package/lib/esm/BriefcaseManager.js +14 -0
- package/lib/esm/BriefcaseManager.js.map +1 -1
- package/lib/esm/CloudSqlite.d.ts +2 -0
- package/lib/esm/CloudSqlite.d.ts.map +1 -1
- package/lib/esm/CloudSqlite.js.map +1 -1
- package/lib/esm/DisplayStyle.d.ts +2 -2
- package/lib/esm/DisplayStyle.d.ts.map +1 -1
- package/lib/esm/DisplayStyle.js +4 -4
- package/lib/esm/DisplayStyle.js.map +1 -1
- package/lib/esm/ECDb.js +1 -1
- package/lib/esm/ECDb.js.map +1 -1
- package/lib/esm/Element.d.ts +31 -3
- package/lib/esm/Element.d.ts.map +1 -1
- package/lib/esm/Element.js +55 -4
- package/lib/esm/Element.js.map +1 -1
- package/lib/esm/ElementAspect.d.ts +24 -1
- package/lib/esm/ElementAspect.d.ts.map +1 -1
- package/lib/esm/ElementAspect.js +101 -1
- package/lib/esm/ElementAspect.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +26 -3
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +60 -5
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/IModelElementCloneContext.d.ts +1 -1
- package/lib/esm/IModelElementCloneContext.d.ts.map +1 -1
- package/lib/esm/IModelElementCloneContext.js +2 -2
- package/lib/esm/IModelElementCloneContext.js.map +1 -1
- package/lib/esm/Material.d.ts +1 -1
- package/lib/esm/Material.d.ts.map +1 -1
- package/lib/esm/Material.js +2 -2
- package/lib/esm/Material.js.map +1 -1
- package/lib/esm/NavigationRelationship.d.ts +15 -0
- package/lib/esm/NavigationRelationship.d.ts.map +1 -1
- package/lib/esm/NavigationRelationship.js +19 -0
- package/lib/esm/NavigationRelationship.js.map +1 -1
- package/lib/esm/Relationship.d.ts +5 -0
- package/lib/esm/Relationship.d.ts.map +1 -1
- package/lib/esm/Relationship.js +7 -0
- package/lib/esm/Relationship.js.map +1 -1
- package/lib/esm/TxnManager.d.ts +8 -0
- package/lib/esm/TxnManager.d.ts.map +1 -1
- package/lib/esm/TxnManager.js +30 -2
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/ViewDefinition.d.ts +1 -1
- package/lib/esm/ViewDefinition.d.ts.map +1 -1
- package/lib/esm/ViewDefinition.js +2 -2
- package/lib/esm/ViewDefinition.js.map +1 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +15 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.js +37 -24
- package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.d.ts +13 -1
- package/lib/esm/annotations/LeaderGeometry.d.ts.map +1 -1
- package/lib/esm/annotations/LeaderGeometry.js +89 -12
- package/lib/esm/annotations/LeaderGeometry.js.map +1 -1
- package/lib/esm/annotations/TextAnnotationElement.d.ts +6 -5
- package/lib/esm/annotations/TextAnnotationElement.d.ts.map +1 -1
- package/lib/esm/annotations/TextAnnotationElement.js +33 -14
- package/lib/esm/annotations/TextAnnotationElement.js.map +1 -1
- package/lib/esm/annotations/TextBlockLayout.d.ts.map +1 -1
- package/lib/esm/annotations/TextBlockLayout.js +2 -1
- package/lib/esm/annotations/TextBlockLayout.js.map +1 -1
- package/lib/esm/internal/annotations/fields.d.ts +3 -2
- package/lib/esm/internal/annotations/fields.d.ts.map +1 -1
- package/lib/esm/internal/annotations/fields.js +11 -5
- package/lib/esm/internal/annotations/fields.js.map +1 -1
- package/lib/esm/test/ElementDrivesElement.test.d.ts +93 -0
- package/lib/esm/test/ElementDrivesElement.test.d.ts.map +1 -0
- package/lib/esm/test/ElementDrivesElement.test.js +862 -0
- package/lib/esm/test/ElementDrivesElement.test.js.map +1 -0
- package/lib/esm/test/ElementLRUCache.test.js +13 -0
- package/lib/esm/test/ElementLRUCache.test.js.map +1 -1
- package/lib/esm/test/annotations/Fields.test.js +44 -0
- package/lib/esm/test/annotations/Fields.test.js.map +1 -1
- package/lib/esm/test/annotations/LeaderGeometry.test.js +47 -2
- package/lib/esm/test/annotations/LeaderGeometry.test.js.map +1 -1
- package/lib/esm/test/annotations/TextAnnotation.test.js +120 -31
- package/lib/esm/test/annotations/TextAnnotation.test.js.map +1 -1
- package/lib/esm/test/ecdb/ConcurrentQuery.test.js +2 -2
- package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlStatement.test.js +33 -2
- package/lib/esm/test/ecdb/ECSqlStatement.test.js.map +1 -1
- package/lib/esm/test/element/ProjectInformationRecord.test.d.ts +2 -0
- package/lib/esm/test/element/ProjectInformationRecord.test.d.ts.map +1 -0
- package/lib/esm/test/element/ProjectInformationRecord.test.js +80 -0
- package/lib/esm/test/element/ProjectInformationRecord.test.js.map +1 -0
- package/lib/esm/test/element/SheetInformationAspect.test.d.ts +2 -0
- package/lib/esm/test/element/SheetInformationAspect.test.d.ts.map +1 -0
- package/lib/esm/test/element/SheetInformationAspect.test.js +182 -0
- package/lib/esm/test/element/SheetInformationAspect.test.js.map +1 -0
- package/lib/esm/test/hubaccess/Rebase.test.js +169 -2
- package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -1
- package/lib/esm/test/imodel/IModel.test.js +175 -2
- package/lib/esm/test/imodel/IModel.test.js.map +1 -1
- package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangesetReader.test.js +63 -60
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/lib/esm/test/standalone/DisplayStyle.test.js +6 -6
- package/lib/esm/test/standalone/DisplayStyle.test.js.map +1 -1
- package/lib/esm/test/standalone/ElementGraphics.test.js +75 -6
- package/lib/esm/test/standalone/ElementGraphics.test.js.map +1 -1
- package/lib/esm/test/standalone/RenderMaterialElement.test.js +4 -4
- package/lib/esm/test/standalone/RenderMaterialElement.test.js.map +1 -1
- package/lib/esm/test/standalone/TxnManager.test.js +33 -5
- package/lib/esm/test/standalone/TxnManager.test.js.map +1 -1
- package/package.json +13 -13
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { expect } from "chai";
|
|
6
6
|
import { Angle, Point3d, Range2d, Range3d, YawPitchRollAngles } from "@itwin/core-geometry";
|
|
7
|
-
import { FieldRun, FractionRun, SubCategoryAppearance, TextAnnotation, TextBlock, TextRun, TextStyleSettings } from "@itwin/core-common";
|
|
7
|
+
import { FieldRun, FontType, FractionRun, SubCategoryAppearance, TextAnnotation, TextBlock, TextRun, TextStyleSettings } from "@itwin/core-common";
|
|
8
8
|
import { StandaloneDb } from "../../IModelDb";
|
|
9
9
|
import { AnnotationTextStyle, parseTextAnnotationData, TEXT_ANNOTATION_JSON_VERSION, TEXT_STYLE_SETTINGS_JSON_VERSION, TextAnnotation2d, TextAnnotation3d } from "../../annotations/TextAnnotationElement";
|
|
10
10
|
import { IModelTestUtils } from "../IModelTestUtils";
|
|
@@ -20,6 +20,7 @@ import { TextAnnotationUsesTextStyleByDefault } from "../../annotations/ElementD
|
|
|
20
20
|
import { layoutTextBlock, TextStyleResolver } from "../../annotations/TextBlockLayout";
|
|
21
21
|
import { appendTextAnnotationGeometry } from "../../annotations/TextAnnotationGeometry";
|
|
22
22
|
import { IModelElementCloneContext } from "../../IModelElementCloneContext";
|
|
23
|
+
import * as fs from "fs";
|
|
23
24
|
function mockIModel() {
|
|
24
25
|
const iModel = {
|
|
25
26
|
fonts: {
|
|
@@ -461,8 +462,9 @@ describe("TextAnnotation element", () => {
|
|
|
461
462
|
return elem;
|
|
462
463
|
}
|
|
463
464
|
describe("within a single iModel", () => {
|
|
464
|
-
it("leaves property hosts intact", () => {
|
|
465
|
+
it("leaves property hosts intact", async () => {
|
|
465
466
|
const textBlock = TextBlock.create({
|
|
467
|
+
styleOverrides: { font: { name: "Karla" } },
|
|
466
468
|
children: [{
|
|
467
469
|
children: [{
|
|
468
470
|
type: "field",
|
|
@@ -483,7 +485,7 @@ describe("TextAnnotation element", () => {
|
|
|
483
485
|
}],
|
|
484
486
|
}],
|
|
485
487
|
});
|
|
486
|
-
const annotation = TextAnnotation.create({ textBlock });
|
|
488
|
+
const annotation = TextAnnotation.create({ textBlock, });
|
|
487
489
|
const elem = createElement2d(imodel, { ...createElement2dArgs, textAnnotationProps: annotation.toJSON() });
|
|
488
490
|
elem.insert();
|
|
489
491
|
imodel.saveChanges();
|
|
@@ -491,32 +493,32 @@ describe("TextAnnotation element", () => {
|
|
|
491
493
|
context.remapElement("0x123", "0x456");
|
|
492
494
|
context.remapElement("0xabc", "0xdef");
|
|
493
495
|
context.remapElement(createElement2dArgs.model, createElement2dArgs.model);
|
|
494
|
-
const props = context.cloneElement(elem);
|
|
496
|
+
const props = await context.cloneElement(elem);
|
|
495
497
|
expect(props.textAnnotationData).not.to.be.undefined;
|
|
496
498
|
const anno = TextAnnotation.fromJSON(parseTextAnnotationData(props.textAnnotationData)?.data);
|
|
497
499
|
const para = anno.textBlock.children[0];
|
|
498
500
|
expect(para.children[0].propertyHost.elementId).to.equal("0x123");
|
|
499
501
|
expect(para.children[1].propertyHost.elementId).to.equal("0xabc");
|
|
500
502
|
});
|
|
501
|
-
it("leaves default text style intact", () => {
|
|
502
|
-
function clone(styleId, expectedStyleId) {
|
|
503
|
+
it("leaves default text style intact", async () => {
|
|
504
|
+
async function clone(styleId, expectedStyleId) {
|
|
503
505
|
const elem = insertStyledElement(styleId, imodel);
|
|
504
506
|
const context = new IModelElementCloneContext(imodel);
|
|
505
507
|
context.remapElement(createElement2dArgs.model, createElement2dArgs.model);
|
|
506
|
-
const props = context.cloneElement(elem);
|
|
508
|
+
const props = await context.cloneElement(elem);
|
|
507
509
|
expect(props.defaultTextStyle?.id).to.equal(expectedStyleId);
|
|
508
510
|
if (styleId) {
|
|
509
511
|
// Even an explicit remapping is ignored when cloning within a single iModel
|
|
510
512
|
// (per the examples set by most other elements, excluding RenderMaterial).
|
|
511
513
|
context.remapElement(styleId, "0x99887");
|
|
512
|
-
const props2 = context.cloneElement(elem);
|
|
514
|
+
const props2 = await context.cloneElement(elem);
|
|
513
515
|
expect(props2.defaultTextStyle?.id).to.equal(expectedStyleId);
|
|
514
516
|
}
|
|
515
517
|
}
|
|
516
|
-
clone(seedStyleId, seedStyleId);
|
|
517
|
-
clone(undefined, undefined);
|
|
518
|
-
clone("0x12345", "0x12345");
|
|
519
|
-
clone(Id64.invalid, undefined);
|
|
518
|
+
await clone(seedStyleId, seedStyleId);
|
|
519
|
+
await clone(undefined, undefined);
|
|
520
|
+
await clone("0x12345", "0x12345");
|
|
521
|
+
await clone(Id64.invalid, undefined);
|
|
520
522
|
});
|
|
521
523
|
});
|
|
522
524
|
describe("between iModels", () => {
|
|
@@ -533,8 +535,9 @@ describe("TextAnnotation element", () => {
|
|
|
533
535
|
dstElemArgs = { category, model };
|
|
534
536
|
});
|
|
535
537
|
after(() => dstDb.close());
|
|
536
|
-
it("remaps property hosts", () => {
|
|
538
|
+
it("remaps property hosts", async () => {
|
|
537
539
|
const textBlock = TextBlock.create({
|
|
540
|
+
styleOverrides: { font: { name: "Karla" } },
|
|
538
541
|
children: [{
|
|
539
542
|
children: [{
|
|
540
543
|
type: "field",
|
|
@@ -563,47 +566,47 @@ describe("TextAnnotation element", () => {
|
|
|
563
566
|
context.remapElement("0x123", "0x456");
|
|
564
567
|
context.remapElement("0xabc", "0xdef");
|
|
565
568
|
context.remapElement(createElement2dArgs.model, dstElemArgs.model);
|
|
566
|
-
const props = context.cloneElement(elem);
|
|
569
|
+
const props = await context.cloneElement(elem);
|
|
567
570
|
expect(props.textAnnotationData).not.to.be.undefined;
|
|
568
571
|
const anno = TextAnnotation.fromJSON(parseTextAnnotationData(props.textAnnotationData)?.data);
|
|
569
572
|
const para = anno.textBlock.children[0];
|
|
570
573
|
expect(para.children[0].propertyHost.elementId).to.equal("0x456");
|
|
571
574
|
expect(para.children[1].propertyHost.elementId).to.equal("0xdef");
|
|
572
575
|
});
|
|
573
|
-
it("sets default text style to undefined if source style does not exist", () => {
|
|
576
|
+
it("sets default text style to undefined if source style does not exist", async () => {
|
|
574
577
|
const elem = insertStyledElement("0x12345", imodel);
|
|
575
578
|
const context = new IModelElementCloneContext(imodel, dstDb);
|
|
576
579
|
context.remapElement(createElement2dArgs.model, dstElemArgs.model);
|
|
577
|
-
const props = context.cloneElement(elem);
|
|
580
|
+
const props = await context.cloneElement(elem);
|
|
578
581
|
expect(props.defaultTextStyle).to.be.undefined;
|
|
579
582
|
});
|
|
580
|
-
it("remaps to an existing text style with the same code if present", () => {
|
|
583
|
+
it("remaps to an existing text style with the same code if present", async () => {
|
|
581
584
|
const dstStyleId = createAnnotationTextStyle(dstDb, dstDefModel, "test", { font: { name: "Karla" } }).insert();
|
|
582
585
|
expect(dstStyleId).not.to.equal(seedStyleId);
|
|
583
586
|
const srcElem = insertStyledElement(seedStyleId, imodel);
|
|
584
587
|
const context = new IModelElementCloneContext(imodel, dstDb);
|
|
585
588
|
context.remapElement(createElement2dArgs.model, dstElemArgs.model);
|
|
586
|
-
const props = context.cloneElement(srcElem);
|
|
589
|
+
const props = await context.cloneElement(srcElem);
|
|
587
590
|
expect(props.defaultTextStyle?.id).to.equal(dstStyleId);
|
|
588
591
|
});
|
|
589
|
-
it("throws an error if definition model is not remapped", () => {
|
|
592
|
+
it("throws an error if definition model is not remapped", async () => {
|
|
590
593
|
const srcElem = insertStyledElement(seedStyleId2, imodel);
|
|
591
594
|
const context = new IModelElementCloneContext(imodel, dstDb);
|
|
592
595
|
context.remapElement(createElement2dArgs.model, dstElemArgs.model);
|
|
593
|
-
expect(
|
|
596
|
+
await expect(context.cloneElement(srcElem)).to.be.rejectedWith("Invalid target model");
|
|
594
597
|
});
|
|
595
|
-
it("imports default text style if necessary", () => {
|
|
598
|
+
it("imports default text style if necessary", async () => {
|
|
596
599
|
const srcElem = insertStyledElement(seedStyleId2, imodel);
|
|
597
600
|
const context = new IModelElementCloneContext(imodel, dstDb);
|
|
598
601
|
context.remapElement(createElement2dArgs.model, dstElemArgs.model);
|
|
599
602
|
context.remapElement(seedDefinitionModelId, dstDefModel);
|
|
600
|
-
const props = context.cloneElement(srcElem);
|
|
603
|
+
const props = await context.cloneElement(srcElem);
|
|
601
604
|
const dstStyleId = props.defaultTextStyle.id;
|
|
602
605
|
expect(dstStyleId).not.to.be.undefined;
|
|
603
606
|
expect(dstStyleId).not.to.equal(seedStyleId2);
|
|
604
607
|
expect(dstDb.elements.tryGetElement(dstStyleId)).not.to.be.undefined;
|
|
605
608
|
});
|
|
606
|
-
it("remaps multiple occurrences of same style to same Id", () => {
|
|
609
|
+
it("remaps multiple occurrences of same style to same Id", async () => {
|
|
607
610
|
const srcStyleId = createAnnotationTextStyle(imodel, seedDefinitionModelId, "styyyle", { font: { name: "Karla" } }).insert();
|
|
608
611
|
const srcElem1 = insertStyledElement(srcStyleId, imodel);
|
|
609
612
|
const srcElem2 = insertStyledElement(srcStyleId, imodel);
|
|
@@ -611,15 +614,15 @@ describe("TextAnnotation element", () => {
|
|
|
611
614
|
const context = new IModelElementCloneContext(imodel, dstDb);
|
|
612
615
|
context.remapElement(createElement2dArgs.model, dstElemArgs.model);
|
|
613
616
|
context.remapElement(seedDefinitionModelId, dstDefModel);
|
|
614
|
-
const props1 = context.cloneElement(srcElem1);
|
|
615
|
-
const props2 = context.cloneElement(srcElem2);
|
|
617
|
+
const props1 = await context.cloneElement(srcElem1);
|
|
618
|
+
const props2 = await context.cloneElement(srcElem2);
|
|
616
619
|
expect(props1.defaultTextStyle).not.to.be.undefined;
|
|
617
620
|
expect(props1.defaultTextStyle?.id).not.to.equal(srcStyleId);
|
|
618
621
|
expect(props2.defaultTextStyle?.id).to.equal(props1.defaultTextStyle?.id);
|
|
619
622
|
const context2 = new IModelElementCloneContext(imodel, dstDb);
|
|
620
623
|
context2.remapElement(createElement2dArgs.model, dstElemArgs.model);
|
|
621
624
|
context2.remapElement(seedDefinitionModelId, dstDefModel);
|
|
622
|
-
const props3 = context2.cloneElement(srcElem3);
|
|
625
|
+
const props3 = await context2.cloneElement(srcElem3);
|
|
623
626
|
expect(props3.defaultTextStyle?.id).to.equal(props1.defaultTextStyle?.id);
|
|
624
627
|
});
|
|
625
628
|
});
|
|
@@ -786,13 +789,99 @@ describe("AnnotationTextStyle", () => {
|
|
|
786
789
|
}),
|
|
787
790
|
})).to.throw(`JSON version 999.999.999 is newer than supported version ${TEXT_STYLE_SETTINGS_JSON_VERSION}. Application update required to understand data.`);
|
|
788
791
|
});
|
|
789
|
-
it("
|
|
790
|
-
|
|
792
|
+
it("should migrate text style settings from 1.0.0", () => {
|
|
793
|
+
const oldStyleData = {
|
|
794
|
+
...TextStyleSettings.defaultProps,
|
|
795
|
+
leader: {
|
|
796
|
+
...TextStyleSettings.defaultProps.leader,
|
|
797
|
+
// Explicitly remove terminatorShape to simulate old data
|
|
798
|
+
terminatorShape: undefined
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
const migratedStyle = makeStyle({
|
|
791
802
|
settings: JSON.stringify({
|
|
792
|
-
version: "0.0
|
|
793
|
-
data:
|
|
803
|
+
version: "1.0.0",
|
|
804
|
+
data: oldStyleData
|
|
794
805
|
}),
|
|
795
|
-
})
|
|
806
|
+
});
|
|
807
|
+
const jsonStyleData = migratedStyle.toJSON();
|
|
808
|
+
if (jsonStyleData.settings) {
|
|
809
|
+
const jsonVersion = JSON.parse(jsonStyleData.settings).version;
|
|
810
|
+
expect(jsonVersion).to.equal(TEXT_STYLE_SETTINGS_JSON_VERSION);
|
|
811
|
+
}
|
|
812
|
+
expect(migratedStyle.settings.leader.terminatorShape).to.not.be.undefined;
|
|
813
|
+
});
|
|
814
|
+
it("should return same data when version is 1.0.1", () => {
|
|
815
|
+
const styleData = {
|
|
816
|
+
version: "1.0.1",
|
|
817
|
+
data: TextStyleSettings.defaultProps
|
|
818
|
+
};
|
|
819
|
+
const migratedStyle = makeStyle({
|
|
820
|
+
settings: JSON.stringify({
|
|
821
|
+
version: styleData.version,
|
|
822
|
+
data: styleData.data
|
|
823
|
+
}),
|
|
824
|
+
});
|
|
825
|
+
const jsonStyleData = migratedStyle.toJSON();
|
|
826
|
+
if (jsonStyleData.settings) {
|
|
827
|
+
const parsedJson = JSON.parse(jsonStyleData.settings);
|
|
828
|
+
expect(parsedJson.version).to.equal(styleData.version);
|
|
829
|
+
expect(parsedJson.data).to.deep.equal(styleData.data);
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
it("should return defaultProps when styleData is unrecognized", () => {
|
|
833
|
+
const textStyle = makeStyle({
|
|
834
|
+
settings: JSON.stringify({
|
|
835
|
+
version: "1.0.1",
|
|
836
|
+
data: { invalid: "data" }
|
|
837
|
+
}),
|
|
838
|
+
});
|
|
839
|
+
expect(textStyle.settings).to.be.deep.equal(TextStyleSettings.defaultProps);
|
|
840
|
+
});
|
|
841
|
+
});
|
|
842
|
+
describe("onCloned", () => {
|
|
843
|
+
let targetDb;
|
|
844
|
+
let targetDefModel;
|
|
845
|
+
before(async () => {
|
|
846
|
+
// The source and target iModel will both contain the Karla font family.
|
|
847
|
+
targetDb = await createIModel("AnnotationTextStyleTargetDb");
|
|
848
|
+
const jobSubjectId = createJobSubjectElement(targetDb, "Job").insert();
|
|
849
|
+
targetDefModel = DefinitionModel.insert(targetDb, jobSubjectId, "Definition");
|
|
850
|
+
// Embed a font into the source iModel that doesn't exist in the target iModel.
|
|
851
|
+
const shxName = IModelTestUtils.resolveFontFile("Cdm.shx");
|
|
852
|
+
const shxBlob = fs.readFileSync(shxName);
|
|
853
|
+
const shxFile = FontFile.createFromShxFontBlob({ blob: shxBlob, familyName: "Cdm" });
|
|
854
|
+
await imodel.fonts.embedFontFile({ file: shxFile });
|
|
855
|
+
});
|
|
856
|
+
after(() => targetDb.close());
|
|
857
|
+
it("embeds font into target Db if not already embedded", async () => {
|
|
858
|
+
const getFontCounts = () => {
|
|
859
|
+
let files = 0;
|
|
860
|
+
for (const _ of targetDb.fonts.queryEmbeddedFontFiles()) {
|
|
861
|
+
files++;
|
|
862
|
+
}
|
|
863
|
+
let families = 0;
|
|
864
|
+
for (const _ of targetDb.fonts.queryMappedFamilies()) {
|
|
865
|
+
families++;
|
|
866
|
+
}
|
|
867
|
+
return { files, families };
|
|
868
|
+
};
|
|
869
|
+
const initialCounts = getFontCounts();
|
|
870
|
+
const karlaStyle = createAnnotationTextStyle(imodel, seedDefinitionModel, "karla-style", TextStyleSettings.fromJSON({ font: { name: "Karla" } }));
|
|
871
|
+
karlaStyle.insert();
|
|
872
|
+
const cdmStyle = createAnnotationTextStyle(imodel, seedDefinitionModel, "cdm-style", TextStyleSettings.fromJSON({ font: { name: "Cdm", type: FontType.Shx } }));
|
|
873
|
+
cdmStyle.insert();
|
|
874
|
+
const context = new IModelElementCloneContext(imodel, targetDb);
|
|
875
|
+
context.remapElement(seedDefinitionModel, targetDefModel);
|
|
876
|
+
expect(targetDb.fonts.findId({ name: "Karla" })).not.to.be.undefined;
|
|
877
|
+
await context.cloneElement(karlaStyle);
|
|
878
|
+
expect(getFontCounts()).to.deep.equal(initialCounts);
|
|
879
|
+
expect(targetDb.fonts.findId({ name: "Cdm", type: FontType.Shx })).to.be.undefined;
|
|
880
|
+
await context.cloneElement(cdmStyle);
|
|
881
|
+
expect(targetDb.fonts.findId({ name: "Cdm", type: FontType.Shx })).not.to.be.undefined;
|
|
882
|
+
const finalCounts = getFontCounts();
|
|
883
|
+
expect(finalCounts.files).greaterThan(initialCounts.files);
|
|
884
|
+
expect(finalCounts.families).greaterThan(initialCounts.families);
|
|
796
885
|
});
|
|
797
886
|
});
|
|
798
887
|
});
|