@fluidframework/tree 2.0.0-rc.5.0.1 → 2.1.0-274160
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/.vscode/settings.json +16 -0
- package/api-report/tree.alpha.api.md +0 -12
- package/api-report/tree.beta.api.md +0 -12
- package/api-report/tree.public.api.md +0 -12
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/dist/shared-tree/schematizingTreeView.js +9 -3
- package/dist/shared-tree/schematizingTreeView.js.map +1 -1
- package/dist/simple-tree/index.d.ts +2 -1
- package/dist/simple-tree/index.d.ts.map +1 -1
- package/dist/simple-tree/index.js +4 -1
- package/dist/simple-tree/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/shared-tree/schematizingTreeView.d.ts.map +1 -1
- package/lib/shared-tree/schematizingTreeView.js +11 -5
- package/lib/shared-tree/schematizingTreeView.js.map +1 -1
- package/lib/simple-tree/index.d.ts +2 -1
- package/lib/simple-tree/index.d.ts.map +1 -1
- package/lib/simple-tree/index.js +2 -1
- package/lib/simple-tree/index.js.map +1 -1
- package/package.json +21 -21
- package/src/packageVersion.ts +1 -1
- package/src/shared-tree/schematizingTreeView.ts +18 -5
- package/src/simple-tree/index.ts +6 -1
package/.vscode/settings.json
CHANGED
|
@@ -16,4 +16,20 @@
|
|
|
16
16
|
// mocha test config isn't sufficient; it also needs to be enabled here.
|
|
17
17
|
"mochaExplorer.nodeArgv": ["--conditions", "allow-ff-test-exports"],
|
|
18
18
|
"cSpell.words": ["deprioritized", "endregion", "insertable", "reentrantly", "unhydrated"],
|
|
19
|
+
|
|
20
|
+
// Enable biome as default formatter, and disable rules that disagree with it
|
|
21
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
22
|
+
"editor.insertSpaces": false,
|
|
23
|
+
// Also configure the formatter on a per-language basis for some common languages/file-types, to make sure it is applied
|
|
24
|
+
// even if someone's User Settings specify a different formatter at this level (which overrides the root-level
|
|
25
|
+
// 'editor.defaultFormatter').
|
|
26
|
+
"[json]": {
|
|
27
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
28
|
+
},
|
|
29
|
+
"[javascript]": {
|
|
30
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
31
|
+
},
|
|
32
|
+
"[typescript]": {
|
|
33
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
34
|
+
},
|
|
19
35
|
}
|
|
@@ -4,18 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
|
-
import type { ErasedType } from '@fluidframework/core-interfaces';
|
|
8
|
-
import type { IDisposable as IDisposable_2 } from '@fluidframework/core-interfaces';
|
|
9
|
-
import type { IFluidHandle } from '@fluidframework/core-interfaces';
|
|
10
|
-
import type { IFluidLoadable } from '@fluidframework/core-interfaces';
|
|
11
|
-
import type { ISharedObject } from '@fluidframework/shared-object-base/internal';
|
|
12
|
-
import { ISharedObjectKind } from '@fluidframework/shared-object-base/internal';
|
|
13
|
-
import type { SessionSpaceCompressedId } from '@fluidframework/id-compressor';
|
|
14
|
-
import type { SharedObjectKind } from '@fluidframework/shared-object-base';
|
|
15
|
-
import type { StableId } from '@fluidframework/id-compressor';
|
|
16
|
-
import type { Static } from '@sinclair/typebox';
|
|
17
|
-
import type { TSchema } from '@sinclair/typebox';
|
|
18
|
-
|
|
19
7
|
// @public
|
|
20
8
|
export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
|
|
21
9
|
|
|
@@ -4,18 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
|
-
import type { ErasedType } from '@fluidframework/core-interfaces';
|
|
8
|
-
import type { IDisposable as IDisposable_2 } from '@fluidframework/core-interfaces';
|
|
9
|
-
import type { IFluidHandle } from '@fluidframework/core-interfaces';
|
|
10
|
-
import type { IFluidLoadable } from '@fluidframework/core-interfaces';
|
|
11
|
-
import type { ISharedObject } from '@fluidframework/shared-object-base/internal';
|
|
12
|
-
import { ISharedObjectKind } from '@fluidframework/shared-object-base/internal';
|
|
13
|
-
import type { SessionSpaceCompressedId } from '@fluidframework/id-compressor';
|
|
14
|
-
import type { SharedObjectKind } from '@fluidframework/shared-object-base';
|
|
15
|
-
import type { StableId } from '@fluidframework/id-compressor';
|
|
16
|
-
import type { Static } from '@sinclair/typebox';
|
|
17
|
-
import type { TSchema } from '@sinclair/typebox';
|
|
18
|
-
|
|
19
7
|
// @public
|
|
20
8
|
export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
|
|
21
9
|
|
|
@@ -4,18 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
|
-
import type { ErasedType } from '@fluidframework/core-interfaces';
|
|
8
|
-
import type { IDisposable as IDisposable_2 } from '@fluidframework/core-interfaces';
|
|
9
|
-
import type { IFluidHandle } from '@fluidframework/core-interfaces';
|
|
10
|
-
import type { IFluidLoadable } from '@fluidframework/core-interfaces';
|
|
11
|
-
import type { ISharedObject } from '@fluidframework/shared-object-base/internal';
|
|
12
|
-
import { ISharedObjectKind } from '@fluidframework/shared-object-base/internal';
|
|
13
|
-
import type { SessionSpaceCompressedId } from '@fluidframework/id-compressor';
|
|
14
|
-
import type { SharedObjectKind } from '@fluidframework/shared-object-base';
|
|
15
|
-
import type { StableId } from '@fluidframework/id-compressor';
|
|
16
|
-
import type { Static } from '@sinclair/typebox';
|
|
17
|
-
import type { TSchema } from '@sinclair/typebox';
|
|
18
|
-
|
|
19
7
|
// @public
|
|
20
8
|
export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
|
|
21
9
|
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/tree";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.1.0-274160";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,yBAAyB,CAAC;AAC9C,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,yBAAyB,CAAC;AAC9C,eAAO,MAAM,UAAU,iBAAiB,CAAC"}
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/tree";
|
|
11
|
-
exports.pkgVersion = "2.
|
|
11
|
+
exports.pkgVersion = "2.1.0-274160";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,sBAAsB,CAAC;AACjC,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,sBAAsB,CAAC;AACjC,QAAA,UAAU,GAAG,cAAc,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/tree\";\nexport const pkgVersion = \"2.1.0-274160\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schematizingTreeView.d.ts","sourceRoot":"","sources":["../../src/shared-tree/schematizingTreeView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,UAAU,EAEf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,UAAU,
|
|
1
|
+
{"version":3,"file":"schematizingTreeView.d.ts","sourceRoot":"","sources":["../../src/shared-tree/schematizingTreeView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,UAAU,EAEf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,UAAU,EAIV,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAEN,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,oCAAoC,EAEzC,KAAK,iBAAiB,EACtB,KAAK,0BAA0B,EAC/B,KAAK,QAAQ,EACb,KAAK,cAAc,EAMnB,KAAK,qBAAqB,EAG1B,MAAM,yBAAyB,CAAC;AASjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD;;GAEG;AACH,qBAAa,0BAA0B,CAAC,EAAE,CAAC,GAAG,CAAC,WAAW,SAAS,mBAAmB,CACrF,YAAW,QAAQ,CAAC,WAAW,CAAC;aAkCf,QAAQ,EAAE,YAAY;aACtB,MAAM,EAC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AACH,wBAAgB,aAAa,CAAC,KAAK,SAAS,eAAe,EAC1D,QAAQ,EAAE,YAAY,EACtB,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,EAC7B,SAAS,EAAE,MAAM,IAAI,EACrB,cAAc,EAAE,cAAc,GAC5B,oBAAoB,CAAC,KAAK,CAAC,CA2B7B"}
|
|
@@ -59,11 +59,17 @@ class SchematizingSimpleTreeView {
|
|
|
59
59
|
throw new internal_2.UsageError("Tree cannot be initialized more than once.");
|
|
60
60
|
}
|
|
61
61
|
this.runSchemaEdit(() => {
|
|
62
|
+
const mapTree = (0, index_js_4.mapTreeFromNodeData)(content, this.rootFieldSchema.allowedTypes, this.nodeKeyManager, {
|
|
63
|
+
schema: this.checkout.storedSchema,
|
|
64
|
+
policy: {
|
|
65
|
+
...index_js_3.defaultSchemaPolicy,
|
|
66
|
+
validateSchema: this.config.enableSchemaValidation,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
(0, index_js_4.prepareContentForHydration)(mapTree, this.checkout.forest);
|
|
62
70
|
(0, schematizeTree_js_1.initialize)(this.checkout, {
|
|
63
71
|
schema: this.flexConfig.schema,
|
|
64
|
-
initialTree:
|
|
65
|
-
? undefined
|
|
66
|
-
: (0, index_js_4.cursorFromUnhydratedRoot)(this.config.schema, content, this.nodeKeyManager),
|
|
72
|
+
initialTree: mapTree === undefined ? undefined : (0, index_js_3.cursorForMapTreeNode)(mapTree),
|
|
67
73
|
});
|
|
68
74
|
});
|
|
69
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schematizingTreeView.js","sourceRoot":"","sources":["../../src/shared-tree/schematizingTreeView.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,uEAAsE;AAEtE,+CAAoE;AACpE,iDAK4B;AAC5B,4DAMuC;AACvC,sDAiBiC;AACjC,+CAAiD;AAEjD,2DAK6B;AAE7B,+CAAqD;AAErD;;GAEG;AACH,MAAa,0BAA0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AQ,CAAC,YAAY,CAAC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QACrE,UAAU,EAAE,CAAC;QACb,IAAI,CAAC,wBAAa,CAAC,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACb,CAAC;AAhCD,sCAgCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { AllowedUpdateType, Compatibility } from \"../core/index.js\";\nimport {\n\ttype HasListeners,\n\ttype IEmitter,\n\ttype Listenable,\n\tcreateEmitter,\n} from \"../events/index.js\";\nimport {\n\ttype FlexFieldSchema,\n\ttype NodeKeyManager,\n\tViewSchema,\n\tdefaultSchemaPolicy,\n\tContextSlot,\n} from \"../feature-libraries/index.js\";\nimport {\n\ttype FieldSchema,\n\ttype ImplicitFieldSchema,\n\ttype SchemaCompatibilityStatus,\n\ttype InsertableTreeFieldFromImplicitField,\n\t// eslint-disable-next-line import/no-deprecated\n\ttype TreeConfiguration,\n\ttype TreeFieldFromImplicitField,\n\ttype TreeView,\n\ttype TreeViewEvents,\n\tgetProxyForField,\n\ttoFlexConfig,\n\tsetField,\n\tnormalizeFieldSchema,\n\ttype InsertableContent,\n\tcursorFromUnhydratedRoot,\n\ttype TreeViewConfiguration,\n} from \"../simple-tree/index.js\";\nimport { disposeSymbol } from \"../util/index.js\";\n\nimport {\n\ttype TreeContent,\n\tcanInitialize,\n\tensureSchema,\n\tinitialize,\n} from \"./schematizeTree.js\";\nimport type { TreeCheckout } from \"./treeCheckout.js\";\nimport { CheckoutFlexTreeView } from \"./treeView.js\";\n\n/**\n * Implementation of TreeView wrapping a FlexTreeView.\n */\nexport class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitFieldSchema>\n\timplements TreeView<TRootSchema>\n{\n\t/**\n\t * The view is set to undefined when this object is disposed or the view schema does not support viewing the document's stored schema.\n\t *\n\t * The view schema may be incompatible with the stored schema. Use `compatibility` to check.\n\t */\n\tprivate view: CheckoutFlexTreeView<FlexFieldSchema> | undefined;\n\n\t/**\n\t * Undefined iff uninitialized or disposed.\n\t */\n\tprivate currentCompatibility: SchemaCompatibilityStatus | undefined;\n\tprivate readonly flexConfig: TreeContent;\n\tpublic readonly events: Listenable<TreeViewEvents> &\n\t\tIEmitter<TreeViewEvents> &\n\t\tHasListeners<TreeViewEvents> = createEmitter();\n\n\tprivate readonly viewSchema: ViewSchema;\n\n\tprivate readonly unregisterCallbacks = new Set<() => void>();\n\n\tpublic disposed = false;\n\t/**\n\t * This is set to true while an edit impacting the document schema is in progress.\n\t * This allows suppressing extra rootChanged / schemaChanged events until the edit concludes.\n\t * This is useful especially for some initialization edits, since document initialization can involve transient schemas\n\t * which are implementation details and should not be exposed to the user.\n\t */\n\tprivate midUpgrade = false;\n\n\tprivate readonly rootFieldSchema: FieldSchema;\n\n\tpublic constructor(\n\t\tpublic readonly checkout: TreeCheckout,\n\t\tpublic readonly config: // eslint-disable-next-line import/no-deprecated\n\t\tTreeConfiguration<TRootSchema> | TreeViewConfiguration<TRootSchema>,\n\t\tpublic readonly nodeKeyManager: NodeKeyManager,\n\t) {\n\t\tconst policy = {\n\t\t\t...defaultSchemaPolicy,\n\t\t\tvalidateSchema: config.enableSchemaValidation,\n\t\t};\n\t\tthis.rootFieldSchema = normalizeFieldSchema(config.schema);\n\t\tthis.flexConfig = toFlexConfig(config, nodeKeyManager, {\n\t\t\tschema: checkout.storedSchema,\n\t\t\tpolicy,\n\t\t});\n\t\tthis.viewSchema = new ViewSchema(policy, {}, this.flexConfig.schema);\n\t\t// This must be initialized before `update` can be called.\n\t\tthis.currentCompatibility = {\n\t\t\tcanView: false,\n\t\t\tcanUpgrade: true,\n\t\t\tisEquivalent: false,\n\t\t\tcanInitialize: true,\n\t\t};\n\t\tthis.update();\n\n\t\tthis.unregisterCallbacks.add(\n\t\t\tthis.checkout.events.on(\"commitApplied\", (data, getRevertible) =>\n\t\t\t\tthis.events.emit(\"commitApplied\", data, getRevertible),\n\t\t\t),\n\t\t);\n\t}\n\n\tpublic initialize(content: InsertableTreeFieldFromImplicitField<TRootSchema>): void {\n\t\tthis.ensureUndisposed();\n\n\t\tconst compatibility = this.compatibility;\n\t\tif (!compatibility.canInitialize) {\n\t\t\tthrow new UsageError(\"Tree cannot be initialized more than once.\");\n\t\t}\n\n\t\tthis.runSchemaEdit(() => {\n\t\t\tinitialize(this.checkout, {\n\t\t\t\tschema: this.flexConfig.schema,\n\t\t\t\tinitialTree:\n\t\t\t\t\tcontent === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: cursorFromUnhydratedRoot(this.config.schema, content, this.nodeKeyManager),\n\t\t\t});\n\t\t});\n\t}\n\n\tpublic upgradeSchema(): void {\n\t\tthis.ensureUndisposed();\n\n\t\tconst compatibility = this.compatibility;\n\t\tif (compatibility.isEquivalent) {\n\t\t\t// No-op\n\t\t\treturn;\n\t\t}\n\n\t\tif (!compatibility.canUpgrade) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Existing stored schema can not be upgraded (see TreeView.compatibility.canUpgrade).\",\n\t\t\t);\n\t\t}\n\n\t\tthis.runSchemaEdit(() => {\n\t\t\tconst result = ensureSchema(\n\t\t\t\tthis.viewSchema,\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tAllowedUpdateType.SchemaCompatible | AllowedUpdateType.Initialize,\n\t\t\t\tthis.checkout,\n\t\t\t\tthis.flexConfig,\n\t\t\t);\n\t\t\tassert(result, 0x8bf /* Schema upgrade should always work if canUpgrade is set. */);\n\t\t});\n\t}\n\n\t/**\n\t * Gets the view. Throws when disposed.\n\t */\n\tpublic getView(): CheckoutFlexTreeView<FlexFieldSchema> {\n\t\tthis.ensureUndisposed();\n\t\tassert(this.view !== undefined, 0x8c0 /* unexpected getViewOrError */);\n\t\treturn this.view;\n\t}\n\n\tprivate ensureUndisposed(): void {\n\t\tif (this.disposed) {\n\t\t\tthis.failDisposed();\n\t\t}\n\t}\n\n\tprivate failDisposed(): never {\n\t\tthrow new UsageError(\"Accessed a disposed TreeView.\");\n\t}\n\n\t/**\n\t * Updates `this.view` and the current compatibility status.\n\t * Invoked during initialization and when `this.view` needs to be replaced due to stored schema changes.\n\t * Handles re-registering for events to call update in the future.\n\t * @remarks\n\t * This does not check if the view needs to be replaced, it replaces it unconditionally:\n\t * callers should do any checking to detect if it's really needed before calling `update`.\n\t * @privateRemarks\n\t * This implementation avoids making any edits, which prevents it from being invoked reentrantly.\n\t * If implicit initialization (or some other edit) is desired, it should be done outside of this method.\n\t */\n\tprivate update(): void {\n\t\tthis.disposeView();\n\n\t\tconst result = this.viewSchema.checkCompatibility(this.checkout.storedSchema);\n\n\t\t// TODO: AB#8121: Weaken this check to support viewing under additional circumstances.\n\t\t// In the near term, this should support viewing documents with additional optional fields in their schema on object types.\n\t\t// Longer-term (as demand arises), we could also add APIs to constructing view schema to allow for more flexibility\n\t\t// (e.g. out-of-schema content handlers could allow support for viewing docs which have extra allowed types in a particular field)\n\t\tconst canView =\n\t\t\tresult.write === Compatibility.Compatible && result.read === Compatibility.Compatible;\n\t\tconst canUpgrade = result.read === Compatibility.Compatible;\n\t\tconst isEquivalent = canView && canUpgrade;\n\t\tconst compatibility: SchemaCompatibilityStatus = {\n\t\t\tcanView,\n\t\t\tcanUpgrade,\n\t\t\tisEquivalent,\n\t\t\tcanInitialize: canInitialize(this.checkout),\n\t\t};\n\t\tlet lastRoot =\n\t\t\tthis.compatibility.canView && this.view !== undefined ? this.root : undefined;\n\t\tthis.currentCompatibility = compatibility;\n\n\t\tif (compatibility.canView) {\n\t\t\t// Trigger \"rootChanged\" if the root changes in the future.\n\t\t\t// Currently there is no good way to do this as FlexTreeField has no events for changes.\n\t\t\t// this.view.flexTree.on(????)\n\t\t\t// As a workaround for the above, trigger \"rootChanged\" in \"afterBatch\"\n\t\t\t// which isn't the correct time since we normally do events during the batch when the forest is modified, but its better than nothing.\n\t\t\t// TODO: provide a better event: this.view.flexTree.on(????)\n\t\t\tconst cleanupCheckOutEvents = this.checkout.events.on(\"afterBatch\", () => {\n\t\t\t\t// In the initialization flow, this event is raised before the correct compatibility w.r.t the new schema is calculated.\n\t\t\t\t// Accessing `this.root` in that case can throw. It's OK to ignore this because:\n\t\t\t\t// - The rootChanged event will already be raised at the end of the current upgrade\n\t\t\t\t// - It doesn't matter that `lastRoot` isn't updated in this case, because `update` will be called again before the upgrade\n\t\t\t\t// completes (at which point this callback and the `lastRoot` captured here will be out of scope anyway)\n\t\t\t\tif (!this.midUpgrade && lastRoot !== this.root) {\n\t\t\t\t\tlastRoot = this.root;\n\t\t\t\t\tthis.events.emit(\"rootChanged\");\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst onViewDispose = (): void => {\n\t\t\t\tcleanupCheckOutEvents();\n\t\t\t\tthis.view = undefined;\n\t\t\t\tif (!this.disposed) {\n\t\t\t\t\tthis.update();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tthis.view = requireSchema(\n\t\t\t\tthis.checkout,\n\t\t\t\tthis.viewSchema,\n\t\t\t\tonViewDispose,\n\t\t\t\tthis.nodeKeyManager,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.view = undefined;\n\n\t\t\tconst unregister = this.checkout.storedSchema.on(\"afterSchemaChange\", () => {\n\t\t\t\tunregister();\n\t\t\t\tthis.unregisterCallbacks.delete(unregister);\n\t\t\t\tthis.update();\n\t\t\t});\n\t\t\tthis.unregisterCallbacks.add(unregister);\n\t\t}\n\n\t\tif (!this.midUpgrade) {\n\t\t\tthis.events.emit(\"schemaChanged\");\n\t\t\tthis.events.emit(\"rootChanged\");\n\t\t}\n\t}\n\n\tprivate runSchemaEdit(edit: () => void): void {\n\t\tthis.midUpgrade = true;\n\t\ttry {\n\t\t\tedit();\n\t\t} finally {\n\t\t\tthis.midUpgrade = false;\n\t\t}\n\t\tthis.events.emit(\"schemaChanged\");\n\t\tthis.events.emit(\"rootChanged\");\n\t}\n\n\tprivate disposeView(): void {\n\t\tif (this.view !== undefined) {\n\t\t\tthis.view[disposeSymbol]();\n\t\t\tthis.view = undefined;\n\t\t\tthis.unregisterCallbacks.forEach((unregister) => unregister());\n\t\t}\n\t}\n\n\tpublic get compatibility(): SchemaCompatibilityStatus {\n\t\tif (!this.currentCompatibility) {\n\t\t\tthis.failDisposed();\n\t\t}\n\t\treturn this.currentCompatibility;\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.disposed = true;\n\t\tthis.disposeView();\n\t\tthis.currentCompatibility = undefined;\n\t}\n\n\tpublic get root(): TreeFieldFromImplicitField<TRootSchema> {\n\t\tif (!this.compatibility.canView) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Document is out of schema. Check TreeView.compatibility before accessing TreeView.root.\",\n\t\t\t);\n\t\t}\n\t\tconst view = this.getView();\n\t\treturn getProxyForField(view.flexTree) as TreeFieldFromImplicitField<TRootSchema>;\n\t}\n\n\tpublic set root(newRoot: InsertableTreeFieldFromImplicitField<TRootSchema>) {\n\t\tif (!this.compatibility.canView) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Document is out of schema. Check TreeView.compatibility before accessing TreeView.root.\",\n\t\t\t);\n\t\t}\n\t\tconst view = this.getView();\n\t\tsetField(view.context.root, this.rootFieldSchema, newRoot as InsertableContent);\n\t}\n}\n\n/**\n * Creates a view that self-disposes whenenever the stored schema changes.\n * This may only be called when the schema is already known to be compatible (typically via ensureSchema).\n */\nexport function requireSchema<TRoot extends FlexFieldSchema>(\n\tcheckout: TreeCheckout,\n\tviewSchema: ViewSchema<TRoot>,\n\tonDispose: () => void,\n\tnodeKeyManager: NodeKeyManager,\n): CheckoutFlexTreeView<TRoot> {\n\tconst slots = checkout.forest.anchors.slots;\n\tassert(!slots.has(ContextSlot), 0x8c2 /* Cannot create second view from checkout */);\n\n\t{\n\t\tconst compatibility = viewSchema.checkCompatibility(checkout.storedSchema);\n\t\tassert(\n\t\t\tcompatibility.write === Compatibility.Compatible &&\n\t\t\t\tcompatibility.read === Compatibility.Compatible,\n\t\t\t0x8c3 /* requireSchema invoked with incompatible schema */,\n\t\t);\n\t}\n\n\tconst view = new CheckoutFlexTreeView(\n\t\tcheckout,\n\t\tviewSchema.schema,\n\t\tnodeKeyManager,\n\t\tonDispose,\n\t);\n\tassert(slots.has(ContextSlot), 0x90d /* Context should be tracked in slot */);\n\n\tconst unregister = checkout.storedSchema.on(\"afterSchemaChange\", () => {\n\t\tunregister();\n\t\tview[disposeSymbol]();\n\t});\n\n\treturn view;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"schematizingTreeView.js","sourceRoot":"","sources":["../../src/shared-tree/schematizingTreeView.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAC7D,uEAAsE;AAEtE,+CAAoE;AACpE,iDAK4B;AAC5B,4DAOuC;AACvC,sDAkBiC;AACjC,+CAAiD;AAEjD,2DAK6B;AAE7B,+CAAqD;AAErD;;GAEG;AACH,MAAa,0BAA0B;IAkCtC,YACiB,QAAsB,EACtB,MACmD,EACnD,cAA8B;QAH9B,aAAQ,GAAR,QAAQ,CAAc;QACtB,WAAM,GAAN,MAAM,CAC6C;QACnD,mBAAc,GAAd,cAAc,CAAgB;QAvB/B,WAAM,GAEU,IAAA,wBAAa,GAAE,CAAC;QAI/B,wBAAmB,GAAG,IAAI,GAAG,EAAc,CAAC;QAEtD,aAAQ,GAAG,KAAK,CAAC;QACxB;;;;;WAKG;QACK,eAAU,GAAG,KAAK,CAAC;QAU1B,MAAM,MAAM,GAAG;YACd,GAAG,8BAAmB;YACtB,cAAc,EAAE,MAAM,CAAC,sBAAsB;SAC7C,CAAC;QACF,IAAI,CAAC,eAAe,GAAG,IAAA,+BAAoB,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3D,IAAI,CAAC,UAAU,GAAG,IAAA,uBAAY,EAAC,MAAM,EAAE,cAAc,EAAE;YAC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IT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { AllowedUpdateType, Compatibility } from \"../core/index.js\";\nimport {\n\ttype HasListeners,\n\ttype IEmitter,\n\ttype Listenable,\n\tcreateEmitter,\n} from \"../events/index.js\";\nimport {\n\ttype FlexFieldSchema,\n\ttype NodeKeyManager,\n\tViewSchema,\n\tdefaultSchemaPolicy,\n\tContextSlot,\n\tcursorForMapTreeNode,\n} from \"../feature-libraries/index.js\";\nimport {\n\ttype FieldSchema,\n\ttype ImplicitFieldSchema,\n\ttype SchemaCompatibilityStatus,\n\ttype InsertableTreeFieldFromImplicitField,\n\t// eslint-disable-next-line import/no-deprecated\n\ttype TreeConfiguration,\n\ttype TreeFieldFromImplicitField,\n\ttype TreeView,\n\ttype TreeViewEvents,\n\tgetProxyForField,\n\ttoFlexConfig,\n\tsetField,\n\tnormalizeFieldSchema,\n\ttype InsertableContent,\n\ttype TreeViewConfiguration,\n\tmapTreeFromNodeData,\n\tprepareContentForHydration,\n} from \"../simple-tree/index.js\";\nimport { disposeSymbol } from \"../util/index.js\";\n\nimport {\n\ttype TreeContent,\n\tcanInitialize,\n\tensureSchema,\n\tinitialize,\n} from \"./schematizeTree.js\";\nimport type { TreeCheckout } from \"./treeCheckout.js\";\nimport { CheckoutFlexTreeView } from \"./treeView.js\";\n\n/**\n * Implementation of TreeView wrapping a FlexTreeView.\n */\nexport class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitFieldSchema>\n\timplements TreeView<TRootSchema>\n{\n\t/**\n\t * The view is set to undefined when this object is disposed or the view schema does not support viewing the document's stored schema.\n\t *\n\t * The view schema may be incompatible with the stored schema. Use `compatibility` to check.\n\t */\n\tprivate view: CheckoutFlexTreeView<FlexFieldSchema> | undefined;\n\n\t/**\n\t * Undefined iff uninitialized or disposed.\n\t */\n\tprivate currentCompatibility: SchemaCompatibilityStatus | undefined;\n\tprivate readonly flexConfig: TreeContent;\n\tpublic readonly events: Listenable<TreeViewEvents> &\n\t\tIEmitter<TreeViewEvents> &\n\t\tHasListeners<TreeViewEvents> = createEmitter();\n\n\tprivate readonly viewSchema: ViewSchema;\n\n\tprivate readonly unregisterCallbacks = new Set<() => void>();\n\n\tpublic disposed = false;\n\t/**\n\t * This is set to true while an edit impacting the document schema is in progress.\n\t * This allows suppressing extra rootChanged / schemaChanged events until the edit concludes.\n\t * This is useful especially for some initialization edits, since document initialization can involve transient schemas\n\t * which are implementation details and should not be exposed to the user.\n\t */\n\tprivate midUpgrade = false;\n\n\tprivate readonly rootFieldSchema: FieldSchema;\n\n\tpublic constructor(\n\t\tpublic readonly checkout: TreeCheckout,\n\t\tpublic readonly config: // eslint-disable-next-line import/no-deprecated\n\t\tTreeConfiguration<TRootSchema> | TreeViewConfiguration<TRootSchema>,\n\t\tpublic readonly nodeKeyManager: NodeKeyManager,\n\t) {\n\t\tconst policy = {\n\t\t\t...defaultSchemaPolicy,\n\t\t\tvalidateSchema: config.enableSchemaValidation,\n\t\t};\n\t\tthis.rootFieldSchema = normalizeFieldSchema(config.schema);\n\t\tthis.flexConfig = toFlexConfig(config, nodeKeyManager, {\n\t\t\tschema: checkout.storedSchema,\n\t\t\tpolicy,\n\t\t});\n\t\tthis.viewSchema = new ViewSchema(policy, {}, this.flexConfig.schema);\n\t\t// This must be initialized before `update` can be called.\n\t\tthis.currentCompatibility = {\n\t\t\tcanView: false,\n\t\t\tcanUpgrade: true,\n\t\t\tisEquivalent: false,\n\t\t\tcanInitialize: true,\n\t\t};\n\t\tthis.update();\n\n\t\tthis.unregisterCallbacks.add(\n\t\t\tthis.checkout.events.on(\"commitApplied\", (data, getRevertible) =>\n\t\t\t\tthis.events.emit(\"commitApplied\", data, getRevertible),\n\t\t\t),\n\t\t);\n\t}\n\n\tpublic initialize(content: InsertableTreeFieldFromImplicitField<TRootSchema>): void {\n\t\tthis.ensureUndisposed();\n\n\t\tconst compatibility = this.compatibility;\n\t\tif (!compatibility.canInitialize) {\n\t\t\tthrow new UsageError(\"Tree cannot be initialized more than once.\");\n\t\t}\n\n\t\tthis.runSchemaEdit(() => {\n\t\t\tconst mapTree = mapTreeFromNodeData(\n\t\t\t\tcontent as InsertableContent,\n\t\t\t\tthis.rootFieldSchema.allowedTypes,\n\t\t\t\tthis.nodeKeyManager,\n\t\t\t\t{\n\t\t\t\t\tschema: this.checkout.storedSchema,\n\t\t\t\t\tpolicy: {\n\t\t\t\t\t\t...defaultSchemaPolicy,\n\t\t\t\t\t\tvalidateSchema: this.config.enableSchemaValidation,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tprepareContentForHydration(mapTree, this.checkout.forest);\n\t\t\tinitialize(this.checkout, {\n\t\t\t\tschema: this.flexConfig.schema,\n\t\t\t\tinitialTree: mapTree === undefined ? undefined : cursorForMapTreeNode(mapTree),\n\t\t\t});\n\t\t});\n\t}\n\n\tpublic upgradeSchema(): void {\n\t\tthis.ensureUndisposed();\n\n\t\tconst compatibility = this.compatibility;\n\t\tif (compatibility.isEquivalent) {\n\t\t\t// No-op\n\t\t\treturn;\n\t\t}\n\n\t\tif (!compatibility.canUpgrade) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Existing stored schema can not be upgraded (see TreeView.compatibility.canUpgrade).\",\n\t\t\t);\n\t\t}\n\n\t\tthis.runSchemaEdit(() => {\n\t\t\tconst result = ensureSchema(\n\t\t\t\tthis.viewSchema,\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tAllowedUpdateType.SchemaCompatible | AllowedUpdateType.Initialize,\n\t\t\t\tthis.checkout,\n\t\t\t\tthis.flexConfig,\n\t\t\t);\n\t\t\tassert(result, 0x8bf /* Schema upgrade should always work if canUpgrade is set. */);\n\t\t});\n\t}\n\n\t/**\n\t * Gets the view. Throws when disposed.\n\t */\n\tpublic getView(): CheckoutFlexTreeView<FlexFieldSchema> {\n\t\tthis.ensureUndisposed();\n\t\tassert(this.view !== undefined, 0x8c0 /* unexpected getViewOrError */);\n\t\treturn this.view;\n\t}\n\n\tprivate ensureUndisposed(): void {\n\t\tif (this.disposed) {\n\t\t\tthis.failDisposed();\n\t\t}\n\t}\n\n\tprivate failDisposed(): never {\n\t\tthrow new UsageError(\"Accessed a disposed TreeView.\");\n\t}\n\n\t/**\n\t * Updates `this.view` and the current compatibility status.\n\t * Invoked during initialization and when `this.view` needs to be replaced due to stored schema changes.\n\t * Handles re-registering for events to call update in the future.\n\t * @remarks\n\t * This does not check if the view needs to be replaced, it replaces it unconditionally:\n\t * callers should do any checking to detect if it's really needed before calling `update`.\n\t * @privateRemarks\n\t * This implementation avoids making any edits, which prevents it from being invoked reentrantly.\n\t * If implicit initialization (or some other edit) is desired, it should be done outside of this method.\n\t */\n\tprivate update(): void {\n\t\tthis.disposeView();\n\n\t\tconst result = this.viewSchema.checkCompatibility(this.checkout.storedSchema);\n\n\t\t// TODO: AB#8121: Weaken this check to support viewing under additional circumstances.\n\t\t// In the near term, this should support viewing documents with additional optional fields in their schema on object types.\n\t\t// Longer-term (as demand arises), we could also add APIs to constructing view schema to allow for more flexibility\n\t\t// (e.g. out-of-schema content handlers could allow support for viewing docs which have extra allowed types in a particular field)\n\t\tconst canView =\n\t\t\tresult.write === Compatibility.Compatible && result.read === Compatibility.Compatible;\n\t\tconst canUpgrade = result.read === Compatibility.Compatible;\n\t\tconst isEquivalent = canView && canUpgrade;\n\t\tconst compatibility: SchemaCompatibilityStatus = {\n\t\t\tcanView,\n\t\t\tcanUpgrade,\n\t\t\tisEquivalent,\n\t\t\tcanInitialize: canInitialize(this.checkout),\n\t\t};\n\t\tlet lastRoot =\n\t\t\tthis.compatibility.canView && this.view !== undefined ? this.root : undefined;\n\t\tthis.currentCompatibility = compatibility;\n\n\t\tif (compatibility.canView) {\n\t\t\t// Trigger \"rootChanged\" if the root changes in the future.\n\t\t\t// Currently there is no good way to do this as FlexTreeField has no events for changes.\n\t\t\t// this.view.flexTree.on(????)\n\t\t\t// As a workaround for the above, trigger \"rootChanged\" in \"afterBatch\"\n\t\t\t// which isn't the correct time since we normally do events during the batch when the forest is modified, but its better than nothing.\n\t\t\t// TODO: provide a better event: this.view.flexTree.on(????)\n\t\t\tconst cleanupCheckOutEvents = this.checkout.events.on(\"afterBatch\", () => {\n\t\t\t\t// In the initialization flow, this event is raised before the correct compatibility w.r.t the new schema is calculated.\n\t\t\t\t// Accessing `this.root` in that case can throw. It's OK to ignore this because:\n\t\t\t\t// - The rootChanged event will already be raised at the end of the current upgrade\n\t\t\t\t// - It doesn't matter that `lastRoot` isn't updated in this case, because `update` will be called again before the upgrade\n\t\t\t\t// completes (at which point this callback and the `lastRoot` captured here will be out of scope anyway)\n\t\t\t\tif (!this.midUpgrade && lastRoot !== this.root) {\n\t\t\t\t\tlastRoot = this.root;\n\t\t\t\t\tthis.events.emit(\"rootChanged\");\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst onViewDispose = (): void => {\n\t\t\t\tcleanupCheckOutEvents();\n\t\t\t\tthis.view = undefined;\n\t\t\t\tif (!this.disposed) {\n\t\t\t\t\tthis.update();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tthis.view = requireSchema(\n\t\t\t\tthis.checkout,\n\t\t\t\tthis.viewSchema,\n\t\t\t\tonViewDispose,\n\t\t\t\tthis.nodeKeyManager,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.view = undefined;\n\n\t\t\tconst unregister = this.checkout.storedSchema.on(\"afterSchemaChange\", () => {\n\t\t\t\tunregister();\n\t\t\t\tthis.unregisterCallbacks.delete(unregister);\n\t\t\t\tthis.update();\n\t\t\t});\n\t\t\tthis.unregisterCallbacks.add(unregister);\n\t\t}\n\n\t\tif (!this.midUpgrade) {\n\t\t\tthis.events.emit(\"schemaChanged\");\n\t\t\tthis.events.emit(\"rootChanged\");\n\t\t}\n\t}\n\n\tprivate runSchemaEdit(edit: () => void): void {\n\t\tthis.midUpgrade = true;\n\t\ttry {\n\t\t\tedit();\n\t\t} finally {\n\t\t\tthis.midUpgrade = false;\n\t\t}\n\t\tthis.events.emit(\"schemaChanged\");\n\t\tthis.events.emit(\"rootChanged\");\n\t}\n\n\tprivate disposeView(): void {\n\t\tif (this.view !== undefined) {\n\t\t\tthis.view[disposeSymbol]();\n\t\t\tthis.view = undefined;\n\t\t\tthis.unregisterCallbacks.forEach((unregister) => unregister());\n\t\t}\n\t}\n\n\tpublic get compatibility(): SchemaCompatibilityStatus {\n\t\tif (!this.currentCompatibility) {\n\t\t\tthis.failDisposed();\n\t\t}\n\t\treturn this.currentCompatibility;\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.disposed = true;\n\t\tthis.disposeView();\n\t\tthis.currentCompatibility = undefined;\n\t}\n\n\tpublic get root(): TreeFieldFromImplicitField<TRootSchema> {\n\t\tif (!this.compatibility.canView) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Document is out of schema. Check TreeView.compatibility before accessing TreeView.root.\",\n\t\t\t);\n\t\t}\n\t\tconst view = this.getView();\n\t\treturn getProxyForField(view.flexTree) as TreeFieldFromImplicitField<TRootSchema>;\n\t}\n\n\tpublic set root(newRoot: InsertableTreeFieldFromImplicitField<TRootSchema>) {\n\t\tif (!this.compatibility.canView) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Document is out of schema. Check TreeView.compatibility before accessing TreeView.root.\",\n\t\t\t);\n\t\t}\n\t\tconst view = this.getView();\n\t\tsetField(view.context.root, this.rootFieldSchema, newRoot as InsertableContent);\n\t}\n}\n\n/**\n * Creates a view that self-disposes whenenever the stored schema changes.\n * This may only be called when the schema is already known to be compatible (typically via ensureSchema).\n */\nexport function requireSchema<TRoot extends FlexFieldSchema>(\n\tcheckout: TreeCheckout,\n\tviewSchema: ViewSchema<TRoot>,\n\tonDispose: () => void,\n\tnodeKeyManager: NodeKeyManager,\n): CheckoutFlexTreeView<TRoot> {\n\tconst slots = checkout.forest.anchors.slots;\n\tassert(!slots.has(ContextSlot), 0x8c2 /* Cannot create second view from checkout */);\n\n\t{\n\t\tconst compatibility = viewSchema.checkCompatibility(checkout.storedSchema);\n\t\tassert(\n\t\t\tcompatibility.write === Compatibility.Compatible &&\n\t\t\t\tcompatibility.read === Compatibility.Compatible,\n\t\t\t0x8c3 /* requireSchema invoked with incompatible schema */,\n\t\t);\n\t}\n\n\tconst view = new CheckoutFlexTreeView(\n\t\tcheckout,\n\t\tviewSchema.schema,\n\t\tnodeKeyManager,\n\t\tonDispose,\n\t);\n\tassert(slots.has(ContextSlot), 0x90d /* Context should be tracked in slot */);\n\n\tconst unregister = checkout.storedSchema.on(\"afterSchemaChange\", () => {\n\t\tunregister();\n\t\tview[disposeSymbol]();\n\t});\n\n\treturn view;\n}\n"]}
|
|
@@ -10,11 +10,12 @@ export { treeNodeApi, type TreeNodeApi, type TreeChangeEvents } from "./treeNode
|
|
|
10
10
|
export { toFlexConfig, cursorFromUnhydratedRoot } from "./toFlexSchema.js";
|
|
11
11
|
export type { FieldHasDefaultUnsafe, ObjectFromSchemaRecordUnsafe, TreeObjectNodeUnsafe, TreeFieldFromImplicitFieldUnsafe, TreeNodeFromImplicitAllowedTypesUnsafe, FieldSchemaUnsafe, InsertableTreeNodeFromImplicitAllowedTypesUnsafe, TreeArrayNodeUnsafe, TreeMapNodeUnsafe, InsertableObjectFromSchemaRecordUnsafe, InsertableTreeFieldFromImplicitFieldUnsafe, InsertableTypedNodeUnsafe, NodeBuilderDataUnsafe, NodeFromSchemaUnsafe, } from "./typesUnsafe.js";
|
|
12
12
|
export type { ValidateRecursiveSchema } from "./schemaFactoryRecursive.js";
|
|
13
|
-
export { getProxyForField, type InsertableContent } from "./proxies.js";
|
|
13
|
+
export { getProxyForField, type InsertableContent, prepareContentForHydration, } from "./proxies.js";
|
|
14
14
|
export { adaptEnum, enumFromStrings, singletonSchema, typedObjectValues, } from "./schemaCreationUtilities.js";
|
|
15
15
|
export { RecursiveObject as test_RecursiveObject, base as test_RecursiveObject_base, RecursiveObjectPojoMode as test_RecursiveObjectPojoMode, } from "./testRecursiveDomain.js";
|
|
16
16
|
export type { TreeNode, Unhydrated, InternalTreeNode } from "./types.js";
|
|
17
17
|
export { TreeArrayNode, IterableTreeArrayContent, type TreeArrayNodeBase, } from "./arrayNode.js";
|
|
18
18
|
export { type FieldHasDefault, type InsertableObjectFromSchemaRecord, type ObjectFromSchemaRecord, type TreeObjectNode, setField, } from "./objectNode.js";
|
|
19
19
|
export type { TreeMapNode } from "./mapNode.js";
|
|
20
|
+
export { mapTreeFromNodeData } from "./toMapTree.js";
|
|
20
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/simple-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,KAAK,EACV,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,GAC9B,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,QAAQ,EACR,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,gCAAgC,EACrC,KAAK,0CAA0C,EAC/C,KAAK,aAAa,EAClB,cAAc,EACd,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,SAAS,EACT,WAAW,EACX,KAAK,oCAAoC,EACzC,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,oBAAoB,EACpB,KAAK,SAAS,GACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAA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}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.setField = exports.IterableTreeArrayContent = exports.TreeArrayNode = exports.test_RecursiveObjectPojoMode = exports.test_RecursiveObject_base = exports.test_RecursiveObject = exports.typedObjectValues = exports.singletonSchema = exports.enumFromStrings = exports.adaptEnum = exports.getProxyForField = exports.cursorFromUnhydratedRoot = exports.toFlexConfig = exports.treeNodeApi = exports.getFlexNode = exports.SchemaFactory = exports.normalizeFieldSchema = exports.FieldSchema = exports.FieldKind = exports.typeNameSymbol = exports.NodeKind = exports.TreeViewConfiguration = exports.TreeConfiguration = void 0;
|
|
7
|
+
exports.mapTreeFromNodeData = exports.setField = exports.IterableTreeArrayContent = exports.TreeArrayNode = exports.test_RecursiveObjectPojoMode = exports.test_RecursiveObject_base = exports.test_RecursiveObject = exports.typedObjectValues = exports.singletonSchema = exports.enumFromStrings = exports.adaptEnum = exports.prepareContentForHydration = exports.getProxyForField = exports.cursorFromUnhydratedRoot = exports.toFlexConfig = exports.treeNodeApi = exports.getFlexNode = exports.SchemaFactory = exports.normalizeFieldSchema = exports.FieldSchema = exports.FieldKind = exports.typeNameSymbol = exports.NodeKind = exports.TreeViewConfiguration = exports.TreeConfiguration = void 0;
|
|
8
8
|
var tree_js_1 = require("./tree.js");
|
|
9
9
|
Object.defineProperty(exports, "TreeConfiguration", { enumerable: true, get: function () { return tree_js_1.TreeConfiguration; } });
|
|
10
10
|
Object.defineProperty(exports, "TreeViewConfiguration", { enumerable: true, get: function () { return tree_js_1.TreeViewConfiguration; } });
|
|
@@ -25,6 +25,7 @@ Object.defineProperty(exports, "toFlexConfig", { enumerable: true, get: function
|
|
|
25
25
|
Object.defineProperty(exports, "cursorFromUnhydratedRoot", { enumerable: true, get: function () { return toFlexSchema_js_1.cursorFromUnhydratedRoot; } });
|
|
26
26
|
var proxies_js_1 = require("./proxies.js");
|
|
27
27
|
Object.defineProperty(exports, "getProxyForField", { enumerable: true, get: function () { return proxies_js_1.getProxyForField; } });
|
|
28
|
+
Object.defineProperty(exports, "prepareContentForHydration", { enumerable: true, get: function () { return proxies_js_1.prepareContentForHydration; } });
|
|
28
29
|
var schemaCreationUtilities_js_1 = require("./schemaCreationUtilities.js");
|
|
29
30
|
Object.defineProperty(exports, "adaptEnum", { enumerable: true, get: function () { return schemaCreationUtilities_js_1.adaptEnum; } });
|
|
30
31
|
Object.defineProperty(exports, "enumFromStrings", { enumerable: true, get: function () { return schemaCreationUtilities_js_1.enumFromStrings; } });
|
|
@@ -41,4 +42,6 @@ Object.defineProperty(exports, "TreeArrayNode", { enumerable: true, get: functio
|
|
|
41
42
|
Object.defineProperty(exports, "IterableTreeArrayContent", { enumerable: true, get: function () { return arrayNode_js_1.IterableTreeArrayContent; } });
|
|
42
43
|
var objectNode_js_1 = require("./objectNode.js");
|
|
43
44
|
Object.defineProperty(exports, "setField", { enumerable: true, get: function () { return objectNode_js_1.setField; } });
|
|
45
|
+
var toMapTree_js_1 = require("./toMapTree.js");
|
|
46
|
+
Object.defineProperty(exports, "mapTreeFromNodeData", { enumerable: true, get: function () { return toMapTree_js_1.mapTreeFromNodeData; } });
|
|
44
47
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/simple-tree/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCASmB;AALlB,4GAAA,iBAAiB,OAAA;AACjB,gHAAA,qBAAqB,OAAA;AAKtB,mDAyB0B;AAtBzB,0GAAA,QAAQ,OAAA;AAUR,gHAAA,cAAc,OAAA;AAGd,2GAAA,SAAS,OAAA;AACT,6GAAA,WAAW,OAAA;AAMX,sHAAA,oBAAoB,OAAA;AAGrB,uDAA0E;AAAjE,iHAAA,aAAa,OAAA;AACtB,qDAAgD;AAAvC,8GAAA,WAAW,OAAA;AACpB,mDAAwF;AAA/E,6GAAA,WAAW,OAAA;AACpB,qDAA2E;AAAlE,+GAAA,YAAY,OAAA;AAAE,2HAAA,wBAAwB,OAAA;AAkB/C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/simple-tree/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qCASmB;AALlB,4GAAA,iBAAiB,OAAA;AACjB,gHAAA,qBAAqB,OAAA;AAKtB,mDAyB0B;AAtBzB,0GAAA,QAAQ,OAAA;AAUR,gHAAA,cAAc,OAAA;AAGd,2GAAA,SAAS,OAAA;AACT,6GAAA,WAAW,OAAA;AAMX,sHAAA,oBAAoB,OAAA;AAGrB,uDAA0E;AAAjE,iHAAA,aAAa,OAAA;AACtB,qDAAgD;AAAvC,8GAAA,WAAW,OAAA;AACpB,mDAAwF;AAA/E,6GAAA,WAAW,OAAA;AACpB,qDAA2E;AAAlE,+GAAA,YAAY,OAAA;AAAE,2HAAA,wBAAwB,OAAA;AAkB/C,2CAIsB;AAHrB,8GAAA,gBAAgB,OAAA;AAEhB,wHAAA,0BAA0B,OAAA;AAG3B,2EAKsC;AAJrC,uHAAA,SAAS,OAAA;AACT,6HAAA,eAAe,OAAA;AACf,6HAAA,eAAe,OAAA;AACf,+HAAA,iBAAiB,OAAA;AAGlB,6FAA6F;AAC7F,4IAA4I;AAC5I,mEAIkC;AAHjC,8HAAA,eAAe,OAAwB;AACvC,mIAAA,IAAI,OAA6B;AACjC,sIAAA,uBAAuB,OAAgC;AAMxD,+CAIwB;AAHvB,6GAAA,aAAa,OAAA;AACb,wHAAA,wBAAwB,OAAA;AAGzB,iDAMyB;AADxB,yGAAA,QAAQ,OAAA;AAGT,+CAAqD;AAA5C,mHAAA,mBAAmB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype ITree,\n\ttype TreeView,\n\ttype TreeViewEvents,\n\tTreeConfiguration,\n\tTreeViewConfiguration,\n\ttype ITreeViewConfiguration,\n\ttype SchemaCompatibilityStatus,\n\ttype ITreeConfigurationOptions,\n} from \"./tree.js\";\nexport {\n\ttype TreeNodeSchema,\n\ttype NodeFromSchema,\n\tNodeKind,\n\ttype TreeNodeSchemaClass,\n\ttype TreeNodeSchemaNonClass,\n\ttype TreeNodeSchemaCore,\n\ttype ImplicitFieldSchema,\n\ttype TreeFieldFromImplicitField,\n\ttype ImplicitAllowedTypes,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n\ttype TreeLeafValue,\n\ttypeNameSymbol,\n\ttype WithType,\n\ttype AllowedTypes,\n\tFieldKind,\n\tFieldSchema,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype InsertableTypedNode,\n\ttype NodeBuilderData,\n\ttype DefaultProvider,\n\ttype FieldProps,\n\tnormalizeFieldSchema,\n\ttype ApplyKind,\n} from \"./schemaTypes.js\";\nexport { SchemaFactory, type ScopedSchemaName } from \"./schemaFactory.js\";\nexport { getFlexNode } from \"./proxyBinding.js\";\nexport { treeNodeApi, type TreeNodeApi, type TreeChangeEvents } from \"./treeNodeApi.js\";\nexport { toFlexConfig, cursorFromUnhydratedRoot } from \"./toFlexSchema.js\";\nexport type {\n\tFieldHasDefaultUnsafe,\n\tObjectFromSchemaRecordUnsafe,\n\tTreeObjectNodeUnsafe,\n\tTreeFieldFromImplicitFieldUnsafe,\n\tTreeNodeFromImplicitAllowedTypesUnsafe,\n\tFieldSchemaUnsafe,\n\tInsertableTreeNodeFromImplicitAllowedTypesUnsafe,\n\tTreeArrayNodeUnsafe,\n\tTreeMapNodeUnsafe,\n\tInsertableObjectFromSchemaRecordUnsafe,\n\tInsertableTreeFieldFromImplicitFieldUnsafe,\n\tInsertableTypedNodeUnsafe,\n\tNodeBuilderDataUnsafe,\n\tNodeFromSchemaUnsafe,\n} from \"./typesUnsafe.js\";\nexport type { ValidateRecursiveSchema } from \"./schemaFactoryRecursive.js\";\nexport {\n\tgetProxyForField,\n\ttype InsertableContent,\n\tprepareContentForHydration,\n} from \"./proxies.js\";\n\nexport {\n\tadaptEnum,\n\tenumFromStrings,\n\tsingletonSchema,\n\ttypedObjectValues,\n} from \"./schemaCreationUtilities.js\";\n\n// Exporting the schema (RecursiveObject) to test that recursive types are working correctly.\n// These are `@internal` so they can't be included in the `InternalClassTreeTypes` due to https://github.com/microsoft/rushstack/issues/3639\nexport {\n\tRecursiveObject as test_RecursiveObject,\n\tbase as test_RecursiveObject_base,\n\tRecursiveObjectPojoMode as test_RecursiveObjectPojoMode,\n} from \"./testRecursiveDomain.js\";\n\n// TreeNode is only type exported, which prevents use of the class object for unsupported use-cases like direct sub-classing and instancof.\n// See docs on TreeNode for more details.\nexport type { TreeNode, Unhydrated, InternalTreeNode } from \"./types.js\";\nexport {\n\tTreeArrayNode,\n\tIterableTreeArrayContent,\n\ttype TreeArrayNodeBase,\n} from \"./arrayNode.js\";\nexport {\n\ttype FieldHasDefault,\n\ttype InsertableObjectFromSchemaRecord,\n\ttype ObjectFromSchemaRecord,\n\ttype TreeObjectNode,\n\tsetField,\n} from \"./objectNode.js\";\nexport type { TreeMapNode } from \"./mapNode.js\";\nexport { mapTreeFromNodeData } from \"./toMapTree.js\";\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/tree";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.1.0-274160";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,yBAAyB,CAAC;AAC9C,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,yBAAyB,CAAC;AAC9C,eAAO,MAAM,UAAU,iBAAiB,CAAC"}
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,sBAAsB,CAAC;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,sBAAsB,CAAC;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAG,cAAc,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/tree\";\nexport const pkgVersion = \"2.1.0-274160\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schematizingTreeView.d.ts","sourceRoot":"","sources":["../../src/shared-tree/schematizingTreeView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,UAAU,EAEf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,UAAU,
|
|
1
|
+
{"version":3,"file":"schematizingTreeView.d.ts","sourceRoot":"","sources":["../../src/shared-tree/schematizingTreeView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAA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Y,EACtB,MAAM,EACtB,AADwB,gDAAgD;IACxE,iBAAiB,CAAC,WAAW,CAAC,GAAG,qBAAqB,CAAC,WAAW,CAAC,EACnD,cAAc,EAAE,cAAc;IA4BxC,UAAU,CAAC,OAAO,EAAE,oCAAoC,CAAC,WAAW,CAAC,GAAG,IAAI;IA8B5E,aAAa,IAAI,IAAI;IA2B5B;;OAEG;IACI,OAAO,IAAI,oBAAoB,CAAC,eAAe,CAAC;IAMvD,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,YAAY;IAIpB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,MAAM;IAyEd,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,WAAW;IAQnB,IAAW,aAAa,IAAI,yBAAyB,CAKpD;IAEM,OAAO,IAAI,IAAI;IAMtB,IAAW,IAAI,IAAI,0BAA0B,CAAC,WAAW,CAAC,CAQzD;IAED,IAAW,IAAI,CAAC,OAAO,EAAE,oCAAoC,CAAC,WAAW,CAAC,EAQzE;CACD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,SAAS,eAAe,EAC1D,QAAQ,EAAE,YAAY,EACtB,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,EAC7B,SAAS,EAAE,MAAM,IAAI,EACrB,cAAc,EAAE,cAAc,GAC5B,oBAAoB,CAAC,KAAK,CAAC,CA2B7B"}
|
|
@@ -6,8 +6,8 @@ import { assert } from "@fluidframework/core-utils/internal";
|
|
|
6
6
|
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
7
7
|
import { AllowedUpdateType, Compatibility } from "../core/index.js";
|
|
8
8
|
import { createEmitter, } from "../events/index.js";
|
|
9
|
-
import { ViewSchema, defaultSchemaPolicy, ContextSlot, } from "../feature-libraries/index.js";
|
|
10
|
-
import { getProxyForField, toFlexConfig, setField, normalizeFieldSchema,
|
|
9
|
+
import { ViewSchema, defaultSchemaPolicy, ContextSlot, cursorForMapTreeNode, } from "../feature-libraries/index.js";
|
|
10
|
+
import { getProxyForField, toFlexConfig, setField, normalizeFieldSchema, mapTreeFromNodeData, prepareContentForHydration, } from "../simple-tree/index.js";
|
|
11
11
|
import { disposeSymbol } from "../util/index.js";
|
|
12
12
|
import { canInitialize, ensureSchema, initialize, } from "./schematizeTree.js";
|
|
13
13
|
import { CheckoutFlexTreeView } from "./treeView.js";
|
|
@@ -56,11 +56,17 @@ export class SchematizingSimpleTreeView {
|
|
|
56
56
|
throw new UsageError("Tree cannot be initialized more than once.");
|
|
57
57
|
}
|
|
58
58
|
this.runSchemaEdit(() => {
|
|
59
|
+
const mapTree = mapTreeFromNodeData(content, this.rootFieldSchema.allowedTypes, this.nodeKeyManager, {
|
|
60
|
+
schema: this.checkout.storedSchema,
|
|
61
|
+
policy: {
|
|
62
|
+
...defaultSchemaPolicy,
|
|
63
|
+
validateSchema: this.config.enableSchemaValidation,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
prepareContentForHydration(mapTree, this.checkout.forest);
|
|
59
67
|
initialize(this.checkout, {
|
|
60
68
|
schema: this.flexConfig.schema,
|
|
61
|
-
initialTree:
|
|
62
|
-
? undefined
|
|
63
|
-
: cursorFromUnhydratedRoot(this.config.schema, content, this.nodeKeyManager),
|
|
69
|
+
initialTree: mapTree === undefined ? undefined : cursorForMapTreeNode(mapTree),
|
|
64
70
|
});
|
|
65
71
|
});
|
|
66
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schematizingTreeView.js","sourceRoot":"","sources":["../../src/shared-tree/schematizingTreeView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAIN,aAAa,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGN,UA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C1D,CAAC;IACH,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,oBAAoB,CACpC,QAAQ,EACR,UAAU,CAAC,MAAM,EACjB,cAAc,EACd,SAAS,CACT,CAAC;IACF,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAE9E,MAAM,UAAU,GAAG,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QACrE,UAAU,EAAE,CAAC;QACb,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { AllowedUpdateType, Compatibility } from \"../core/index.js\";\nimport {\n\ttype HasListeners,\n\ttype IEmitter,\n\ttype Listenable,\n\tcreateEmitter,\n} from \"../events/index.js\";\nimport {\n\ttype FlexFieldSchema,\n\ttype NodeKeyManager,\n\tViewSchema,\n\tdefaultSchemaPolicy,\n\tContextSlot,\n} from \"../feature-libraries/index.js\";\nimport {\n\ttype FieldSchema,\n\ttype ImplicitFieldSchema,\n\ttype SchemaCompatibilityStatus,\n\ttype InsertableTreeFieldFromImplicitField,\n\t// eslint-disable-next-line import/no-deprecated\n\ttype TreeConfiguration,\n\ttype TreeFieldFromImplicitField,\n\ttype TreeView,\n\ttype TreeViewEvents,\n\tgetProxyForField,\n\ttoFlexConfig,\n\tsetField,\n\tnormalizeFieldSchema,\n\ttype InsertableContent,\n\tcursorFromUnhydratedRoot,\n\ttype TreeViewConfiguration,\n} from \"../simple-tree/index.js\";\nimport { disposeSymbol } from \"../util/index.js\";\n\nimport {\n\ttype TreeContent,\n\tcanInitialize,\n\tensureSchema,\n\tinitialize,\n} from \"./schematizeTree.js\";\nimport type { TreeCheckout } from \"./treeCheckout.js\";\nimport { CheckoutFlexTreeView } from \"./treeView.js\";\n\n/**\n * Implementation of TreeView wrapping a FlexTreeView.\n */\nexport class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitFieldSchema>\n\timplements TreeView<TRootSchema>\n{\n\t/**\n\t * The view is set to undefined when this object is disposed or the view schema does not support viewing the document's stored schema.\n\t *\n\t * The view schema may be incompatible with the stored schema. Use `compatibility` to check.\n\t */\n\tprivate view: CheckoutFlexTreeView<FlexFieldSchema> | undefined;\n\n\t/**\n\t * Undefined iff uninitialized or disposed.\n\t */\n\tprivate currentCompatibility: SchemaCompatibilityStatus | undefined;\n\tprivate readonly flexConfig: TreeContent;\n\tpublic readonly events: Listenable<TreeViewEvents> &\n\t\tIEmitter<TreeViewEvents> &\n\t\tHasListeners<TreeViewEvents> = createEmitter();\n\n\tprivate readonly viewSchema: ViewSchema;\n\n\tprivate readonly unregisterCallbacks = new Set<() => void>();\n\n\tpublic disposed = false;\n\t/**\n\t * This is set to true while an edit impacting the document schema is in progress.\n\t * This allows suppressing extra rootChanged / schemaChanged events until the edit concludes.\n\t * This is useful especially for some initialization edits, since document initialization can involve transient schemas\n\t * which are implementation details and should not be exposed to the user.\n\t */\n\tprivate midUpgrade = false;\n\n\tprivate readonly rootFieldSchema: FieldSchema;\n\n\tpublic constructor(\n\t\tpublic readonly checkout: TreeCheckout,\n\t\tpublic readonly config: // eslint-disable-next-line import/no-deprecated\n\t\tTreeConfiguration<TRootSchema> | TreeViewConfiguration<TRootSchema>,\n\t\tpublic readonly nodeKeyManager: NodeKeyManager,\n\t) {\n\t\tconst policy = {\n\t\t\t...defaultSchemaPolicy,\n\t\t\tvalidateSchema: config.enableSchemaValidation,\n\t\t};\n\t\tthis.rootFieldSchema = normalizeFieldSchema(config.schema);\n\t\tthis.flexConfig = toFlexConfig(config, nodeKeyManager, {\n\t\t\tschema: checkout.storedSchema,\n\t\t\tpolicy,\n\t\t});\n\t\tthis.viewSchema = new ViewSchema(policy, {}, this.flexConfig.schema);\n\t\t// This must be initialized before `update` can be called.\n\t\tthis.currentCompatibility = {\n\t\t\tcanView: false,\n\t\t\tcanUpgrade: true,\n\t\t\tisEquivalent: false,\n\t\t\tcanInitialize: true,\n\t\t};\n\t\tthis.update();\n\n\t\tthis.unregisterCallbacks.add(\n\t\t\tthis.checkout.events.on(\"commitApplied\", (data, getRevertible) =>\n\t\t\t\tthis.events.emit(\"commitApplied\", data, getRevertible),\n\t\t\t),\n\t\t);\n\t}\n\n\tpublic initialize(content: InsertableTreeFieldFromImplicitField<TRootSchema>): void {\n\t\tthis.ensureUndisposed();\n\n\t\tconst compatibility = this.compatibility;\n\t\tif (!compatibility.canInitialize) {\n\t\t\tthrow new UsageError(\"Tree cannot be initialized more than once.\");\n\t\t}\n\n\t\tthis.runSchemaEdit(() => {\n\t\t\tinitialize(this.checkout, {\n\t\t\t\tschema: this.flexConfig.schema,\n\t\t\t\tinitialTree:\n\t\t\t\t\tcontent === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: cursorFromUnhydratedRoot(this.config.schema, content, this.nodeKeyManager),\n\t\t\t});\n\t\t});\n\t}\n\n\tpublic upgradeSchema(): void {\n\t\tthis.ensureUndisposed();\n\n\t\tconst compatibility = this.compatibility;\n\t\tif (compatibility.isEquivalent) {\n\t\t\t// No-op\n\t\t\treturn;\n\t\t}\n\n\t\tif (!compatibility.canUpgrade) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Existing stored schema can not be upgraded (see TreeView.compatibility.canUpgrade).\",\n\t\t\t);\n\t\t}\n\n\t\tthis.runSchemaEdit(() => {\n\t\t\tconst result = ensureSchema(\n\t\t\t\tthis.viewSchema,\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tAllowedUpdateType.SchemaCompatible | AllowedUpdateType.Initialize,\n\t\t\t\tthis.checkout,\n\t\t\t\tthis.flexConfig,\n\t\t\t);\n\t\t\tassert(result, 0x8bf /* Schema upgrade should always work if canUpgrade is set. */);\n\t\t});\n\t}\n\n\t/**\n\t * Gets the view. Throws when disposed.\n\t */\n\tpublic getView(): CheckoutFlexTreeView<FlexFieldSchema> {\n\t\tthis.ensureUndisposed();\n\t\tassert(this.view !== undefined, 0x8c0 /* unexpected getViewOrError */);\n\t\treturn this.view;\n\t}\n\n\tprivate ensureUndisposed(): void {\n\t\tif (this.disposed) {\n\t\t\tthis.failDisposed();\n\t\t}\n\t}\n\n\tprivate failDisposed(): never {\n\t\tthrow new UsageError(\"Accessed a disposed TreeView.\");\n\t}\n\n\t/**\n\t * Updates `this.view` and the current compatibility status.\n\t * Invoked during initialization and when `this.view` needs to be replaced due to stored schema changes.\n\t * Handles re-registering for events to call update in the future.\n\t * @remarks\n\t * This does not check if the view needs to be replaced, it replaces it unconditionally:\n\t * callers should do any checking to detect if it's really needed before calling `update`.\n\t * @privateRemarks\n\t * This implementation avoids making any edits, which prevents it from being invoked reentrantly.\n\t * If implicit initialization (or some other edit) is desired, it should be done outside of this method.\n\t */\n\tprivate update(): void {\n\t\tthis.disposeView();\n\n\t\tconst result = this.viewSchema.checkCompatibility(this.checkout.storedSchema);\n\n\t\t// TODO: AB#8121: Weaken this check to support viewing under additional circumstances.\n\t\t// In the near term, this should support viewing documents with additional optional fields in their schema on object types.\n\t\t// Longer-term (as demand arises), we could also add APIs to constructing view schema to allow for more flexibility\n\t\t// (e.g. out-of-schema content handlers could allow support for viewing docs which have extra allowed types in a particular field)\n\t\tconst canView =\n\t\t\tresult.write === Compatibility.Compatible && result.read === Compatibility.Compatible;\n\t\tconst canUpgrade = result.read === Compatibility.Compatible;\n\t\tconst isEquivalent = canView && canUpgrade;\n\t\tconst compatibility: SchemaCompatibilityStatus = {\n\t\t\tcanView,\n\t\t\tcanUpgrade,\n\t\t\tisEquivalent,\n\t\t\tcanInitialize: canInitialize(this.checkout),\n\t\t};\n\t\tlet lastRoot =\n\t\t\tthis.compatibility.canView && this.view !== undefined ? this.root : undefined;\n\t\tthis.currentCompatibility = compatibility;\n\n\t\tif (compatibility.canView) {\n\t\t\t// Trigger \"rootChanged\" if the root changes in the future.\n\t\t\t// Currently there is no good way to do this as FlexTreeField has no events for changes.\n\t\t\t// this.view.flexTree.on(????)\n\t\t\t// As a workaround for the above, trigger \"rootChanged\" in \"afterBatch\"\n\t\t\t// which isn't the correct time since we normally do events during the batch when the forest is modified, but its better than nothing.\n\t\t\t// TODO: provide a better event: this.view.flexTree.on(????)\n\t\t\tconst cleanupCheckOutEvents = this.checkout.events.on(\"afterBatch\", () => {\n\t\t\t\t// In the initialization flow, this event is raised before the correct compatibility w.r.t the new schema is calculated.\n\t\t\t\t// Accessing `this.root` in that case can throw. It's OK to ignore this because:\n\t\t\t\t// - The rootChanged event will already be raised at the end of the current upgrade\n\t\t\t\t// - It doesn't matter that `lastRoot` isn't updated in this case, because `update` will be called again before the upgrade\n\t\t\t\t// completes (at which point this callback and the `lastRoot` captured here will be out of scope anyway)\n\t\t\t\tif (!this.midUpgrade && lastRoot !== this.root) {\n\t\t\t\t\tlastRoot = this.root;\n\t\t\t\t\tthis.events.emit(\"rootChanged\");\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst onViewDispose = (): void => {\n\t\t\t\tcleanupCheckOutEvents();\n\t\t\t\tthis.view = undefined;\n\t\t\t\tif (!this.disposed) {\n\t\t\t\t\tthis.update();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tthis.view = requireSchema(\n\t\t\t\tthis.checkout,\n\t\t\t\tthis.viewSchema,\n\t\t\t\tonViewDispose,\n\t\t\t\tthis.nodeKeyManager,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.view = undefined;\n\n\t\t\tconst unregister = this.checkout.storedSchema.on(\"afterSchemaChange\", () => {\n\t\t\t\tunregister();\n\t\t\t\tthis.unregisterCallbacks.delete(unregister);\n\t\t\t\tthis.update();\n\t\t\t});\n\t\t\tthis.unregisterCallbacks.add(unregister);\n\t\t}\n\n\t\tif (!this.midUpgrade) {\n\t\t\tthis.events.emit(\"schemaChanged\");\n\t\t\tthis.events.emit(\"rootChanged\");\n\t\t}\n\t}\n\n\tprivate runSchemaEdit(edit: () => void): void {\n\t\tthis.midUpgrade = true;\n\t\ttry {\n\t\t\tedit();\n\t\t} finally {\n\t\t\tthis.midUpgrade = false;\n\t\t}\n\t\tthis.events.emit(\"schemaChanged\");\n\t\tthis.events.emit(\"rootChanged\");\n\t}\n\n\tprivate disposeView(): void {\n\t\tif (this.view !== undefined) {\n\t\t\tthis.view[disposeSymbol]();\n\t\t\tthis.view = undefined;\n\t\t\tthis.unregisterCallbacks.forEach((unregister) => unregister());\n\t\t}\n\t}\n\n\tpublic get compatibility(): SchemaCompatibilityStatus {\n\t\tif (!this.currentCompatibility) {\n\t\t\tthis.failDisposed();\n\t\t}\n\t\treturn this.currentCompatibility;\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.disposed = true;\n\t\tthis.disposeView();\n\t\tthis.currentCompatibility = undefined;\n\t}\n\n\tpublic get root(): TreeFieldFromImplicitField<TRootSchema> {\n\t\tif (!this.compatibility.canView) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Document is out of schema. Check TreeView.compatibility before accessing TreeView.root.\",\n\t\t\t);\n\t\t}\n\t\tconst view = this.getView();\n\t\treturn getProxyForField(view.flexTree) as TreeFieldFromImplicitField<TRootSchema>;\n\t}\n\n\tpublic set root(newRoot: InsertableTreeFieldFromImplicitField<TRootSchema>) {\n\t\tif (!this.compatibility.canView) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Document is out of schema. Check TreeView.compatibility before accessing TreeView.root.\",\n\t\t\t);\n\t\t}\n\t\tconst view = this.getView();\n\t\tsetField(view.context.root, this.rootFieldSchema, newRoot as InsertableContent);\n\t}\n}\n\n/**\n * Creates a view that self-disposes whenenever the stored schema changes.\n * This may only be called when the schema is already known to be compatible (typically via ensureSchema).\n */\nexport function requireSchema<TRoot extends FlexFieldSchema>(\n\tcheckout: TreeCheckout,\n\tviewSchema: ViewSchema<TRoot>,\n\tonDispose: () => void,\n\tnodeKeyManager: NodeKeyManager,\n): CheckoutFlexTreeView<TRoot> {\n\tconst slots = checkout.forest.anchors.slots;\n\tassert(!slots.has(ContextSlot), 0x8c2 /* Cannot create second view from checkout */);\n\n\t{\n\t\tconst compatibility = viewSchema.checkCompatibility(checkout.storedSchema);\n\t\tassert(\n\t\t\tcompatibility.write === Compatibility.Compatible &&\n\t\t\t\tcompatibility.read === Compatibility.Compatible,\n\t\t\t0x8c3 /* requireSchema invoked with incompatible schema */,\n\t\t);\n\t}\n\n\tconst view = new CheckoutFlexTreeView(\n\t\tcheckout,\n\t\tviewSchema.schema,\n\t\tnodeKeyManager,\n\t\tonDispose,\n\t);\n\tassert(slots.has(ContextSlot), 0x90d /* Context should be tracked in slot */);\n\n\tconst unregister = checkout.storedSchema.on(\"afterSchemaChange\", () => {\n\t\tunregister();\n\t\tview[disposeSymbol]();\n\t});\n\n\treturn view;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"schematizingTreeView.js","sourceRoot":"","sources":["../../src/shared-tree/schematizingTreeView.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAIN,aAAa,GACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGN,UAAU,EACV,mBAAmB,EACnB,WAAW,EACX,oBAAoB,GACpB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAUN,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,oBAAoB,EAGpB,mBAAmB,EACnB,0BAA0B,GAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAEN,aAAa,E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I,KAAK,aAAa,CAAC,UAAU,EAChD,KAAK,CAAC,oDAAoD,CAC1D,CAAC;IACH,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,oBAAoB,CACpC,QAAQ,EACR,UAAU,CAAC,MAAM,EACjB,cAAc,EACd,SAAS,CACT,CAAC;IACF,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAE9E,MAAM,UAAU,GAAG,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QACrE,UAAU,EAAE,CAAC;QACb,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { AllowedUpdateType, Compatibility } from \"../core/index.js\";\nimport {\n\ttype HasListeners,\n\ttype IEmitter,\n\ttype Listenable,\n\tcreateEmitter,\n} from \"../events/index.js\";\nimport {\n\ttype FlexFieldSchema,\n\ttype NodeKeyManager,\n\tViewSchema,\n\tdefaultSchemaPolicy,\n\tContextSlot,\n\tcursorForMapTreeNode,\n} from \"../feature-libraries/index.js\";\nimport {\n\ttype FieldSchema,\n\ttype ImplicitFieldSchema,\n\ttype SchemaCompatibilityStatus,\n\ttype InsertableTreeFieldFromImplicitField,\n\t// eslint-disable-next-line import/no-deprecated\n\ttype TreeConfiguration,\n\ttype TreeFieldFromImplicitField,\n\ttype TreeView,\n\ttype TreeViewEvents,\n\tgetProxyForField,\n\ttoFlexConfig,\n\tsetField,\n\tnormalizeFieldSchema,\n\ttype InsertableContent,\n\ttype TreeViewConfiguration,\n\tmapTreeFromNodeData,\n\tprepareContentForHydration,\n} from \"../simple-tree/index.js\";\nimport { disposeSymbol } from \"../util/index.js\";\n\nimport {\n\ttype TreeContent,\n\tcanInitialize,\n\tensureSchema,\n\tinitialize,\n} from \"./schematizeTree.js\";\nimport type { TreeCheckout } from \"./treeCheckout.js\";\nimport { CheckoutFlexTreeView } from \"./treeView.js\";\n\n/**\n * Implementation of TreeView wrapping a FlexTreeView.\n */\nexport class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitFieldSchema>\n\timplements TreeView<TRootSchema>\n{\n\t/**\n\t * The view is set to undefined when this object is disposed or the view schema does not support viewing the document's stored schema.\n\t *\n\t * The view schema may be incompatible with the stored schema. Use `compatibility` to check.\n\t */\n\tprivate view: CheckoutFlexTreeView<FlexFieldSchema> | undefined;\n\n\t/**\n\t * Undefined iff uninitialized or disposed.\n\t */\n\tprivate currentCompatibility: SchemaCompatibilityStatus | undefined;\n\tprivate readonly flexConfig: TreeContent;\n\tpublic readonly events: Listenable<TreeViewEvents> &\n\t\tIEmitter<TreeViewEvents> &\n\t\tHasListeners<TreeViewEvents> = createEmitter();\n\n\tprivate readonly viewSchema: ViewSchema;\n\n\tprivate readonly unregisterCallbacks = new Set<() => void>();\n\n\tpublic disposed = false;\n\t/**\n\t * This is set to true while an edit impacting the document schema is in progress.\n\t * This allows suppressing extra rootChanged / schemaChanged events until the edit concludes.\n\t * This is useful especially for some initialization edits, since document initialization can involve transient schemas\n\t * which are implementation details and should not be exposed to the user.\n\t */\n\tprivate midUpgrade = false;\n\n\tprivate readonly rootFieldSchema: FieldSchema;\n\n\tpublic constructor(\n\t\tpublic readonly checkout: TreeCheckout,\n\t\tpublic readonly config: // eslint-disable-next-line import/no-deprecated\n\t\tTreeConfiguration<TRootSchema> | TreeViewConfiguration<TRootSchema>,\n\t\tpublic readonly nodeKeyManager: NodeKeyManager,\n\t) {\n\t\tconst policy = {\n\t\t\t...defaultSchemaPolicy,\n\t\t\tvalidateSchema: config.enableSchemaValidation,\n\t\t};\n\t\tthis.rootFieldSchema = normalizeFieldSchema(config.schema);\n\t\tthis.flexConfig = toFlexConfig(config, nodeKeyManager, {\n\t\t\tschema: checkout.storedSchema,\n\t\t\tpolicy,\n\t\t});\n\t\tthis.viewSchema = new ViewSchema(policy, {}, this.flexConfig.schema);\n\t\t// This must be initialized before `update` can be called.\n\t\tthis.currentCompatibility = {\n\t\t\tcanView: false,\n\t\t\tcanUpgrade: true,\n\t\t\tisEquivalent: false,\n\t\t\tcanInitialize: true,\n\t\t};\n\t\tthis.update();\n\n\t\tthis.unregisterCallbacks.add(\n\t\t\tthis.checkout.events.on(\"commitApplied\", (data, getRevertible) =>\n\t\t\t\tthis.events.emit(\"commitApplied\", data, getRevertible),\n\t\t\t),\n\t\t);\n\t}\n\n\tpublic initialize(content: InsertableTreeFieldFromImplicitField<TRootSchema>): void {\n\t\tthis.ensureUndisposed();\n\n\t\tconst compatibility = this.compatibility;\n\t\tif (!compatibility.canInitialize) {\n\t\t\tthrow new UsageError(\"Tree cannot be initialized more than once.\");\n\t\t}\n\n\t\tthis.runSchemaEdit(() => {\n\t\t\tconst mapTree = mapTreeFromNodeData(\n\t\t\t\tcontent as InsertableContent,\n\t\t\t\tthis.rootFieldSchema.allowedTypes,\n\t\t\t\tthis.nodeKeyManager,\n\t\t\t\t{\n\t\t\t\t\tschema: this.checkout.storedSchema,\n\t\t\t\t\tpolicy: {\n\t\t\t\t\t\t...defaultSchemaPolicy,\n\t\t\t\t\t\tvalidateSchema: this.config.enableSchemaValidation,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tprepareContentForHydration(mapTree, this.checkout.forest);\n\t\t\tinitialize(this.checkout, {\n\t\t\t\tschema: this.flexConfig.schema,\n\t\t\t\tinitialTree: mapTree === undefined ? undefined : cursorForMapTreeNode(mapTree),\n\t\t\t});\n\t\t});\n\t}\n\n\tpublic upgradeSchema(): void {\n\t\tthis.ensureUndisposed();\n\n\t\tconst compatibility = this.compatibility;\n\t\tif (compatibility.isEquivalent) {\n\t\t\t// No-op\n\t\t\treturn;\n\t\t}\n\n\t\tif (!compatibility.canUpgrade) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Existing stored schema can not be upgraded (see TreeView.compatibility.canUpgrade).\",\n\t\t\t);\n\t\t}\n\n\t\tthis.runSchemaEdit(() => {\n\t\t\tconst result = ensureSchema(\n\t\t\t\tthis.viewSchema,\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tAllowedUpdateType.SchemaCompatible | AllowedUpdateType.Initialize,\n\t\t\t\tthis.checkout,\n\t\t\t\tthis.flexConfig,\n\t\t\t);\n\t\t\tassert(result, 0x8bf /* Schema upgrade should always work if canUpgrade is set. */);\n\t\t});\n\t}\n\n\t/**\n\t * Gets the view. Throws when disposed.\n\t */\n\tpublic getView(): CheckoutFlexTreeView<FlexFieldSchema> {\n\t\tthis.ensureUndisposed();\n\t\tassert(this.view !== undefined, 0x8c0 /* unexpected getViewOrError */);\n\t\treturn this.view;\n\t}\n\n\tprivate ensureUndisposed(): void {\n\t\tif (this.disposed) {\n\t\t\tthis.failDisposed();\n\t\t}\n\t}\n\n\tprivate failDisposed(): never {\n\t\tthrow new UsageError(\"Accessed a disposed TreeView.\");\n\t}\n\n\t/**\n\t * Updates `this.view` and the current compatibility status.\n\t * Invoked during initialization and when `this.view` needs to be replaced due to stored schema changes.\n\t * Handles re-registering for events to call update in the future.\n\t * @remarks\n\t * This does not check if the view needs to be replaced, it replaces it unconditionally:\n\t * callers should do any checking to detect if it's really needed before calling `update`.\n\t * @privateRemarks\n\t * This implementation avoids making any edits, which prevents it from being invoked reentrantly.\n\t * If implicit initialization (or some other edit) is desired, it should be done outside of this method.\n\t */\n\tprivate update(): void {\n\t\tthis.disposeView();\n\n\t\tconst result = this.viewSchema.checkCompatibility(this.checkout.storedSchema);\n\n\t\t// TODO: AB#8121: Weaken this check to support viewing under additional circumstances.\n\t\t// In the near term, this should support viewing documents with additional optional fields in their schema on object types.\n\t\t// Longer-term (as demand arises), we could also add APIs to constructing view schema to allow for more flexibility\n\t\t// (e.g. out-of-schema content handlers could allow support for viewing docs which have extra allowed types in a particular field)\n\t\tconst canView =\n\t\t\tresult.write === Compatibility.Compatible && result.read === Compatibility.Compatible;\n\t\tconst canUpgrade = result.read === Compatibility.Compatible;\n\t\tconst isEquivalent = canView && canUpgrade;\n\t\tconst compatibility: SchemaCompatibilityStatus = {\n\t\t\tcanView,\n\t\t\tcanUpgrade,\n\t\t\tisEquivalent,\n\t\t\tcanInitialize: canInitialize(this.checkout),\n\t\t};\n\t\tlet lastRoot =\n\t\t\tthis.compatibility.canView && this.view !== undefined ? this.root : undefined;\n\t\tthis.currentCompatibility = compatibility;\n\n\t\tif (compatibility.canView) {\n\t\t\t// Trigger \"rootChanged\" if the root changes in the future.\n\t\t\t// Currently there is no good way to do this as FlexTreeField has no events for changes.\n\t\t\t// this.view.flexTree.on(????)\n\t\t\t// As a workaround for the above, trigger \"rootChanged\" in \"afterBatch\"\n\t\t\t// which isn't the correct time since we normally do events during the batch when the forest is modified, but its better than nothing.\n\t\t\t// TODO: provide a better event: this.view.flexTree.on(????)\n\t\t\tconst cleanupCheckOutEvents = this.checkout.events.on(\"afterBatch\", () => {\n\t\t\t\t// In the initialization flow, this event is raised before the correct compatibility w.r.t the new schema is calculated.\n\t\t\t\t// Accessing `this.root` in that case can throw. It's OK to ignore this because:\n\t\t\t\t// - The rootChanged event will already be raised at the end of the current upgrade\n\t\t\t\t// - It doesn't matter that `lastRoot` isn't updated in this case, because `update` will be called again before the upgrade\n\t\t\t\t// completes (at which point this callback and the `lastRoot` captured here will be out of scope anyway)\n\t\t\t\tif (!this.midUpgrade && lastRoot !== this.root) {\n\t\t\t\t\tlastRoot = this.root;\n\t\t\t\t\tthis.events.emit(\"rootChanged\");\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst onViewDispose = (): void => {\n\t\t\t\tcleanupCheckOutEvents();\n\t\t\t\tthis.view = undefined;\n\t\t\t\tif (!this.disposed) {\n\t\t\t\t\tthis.update();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tthis.view = requireSchema(\n\t\t\t\tthis.checkout,\n\t\t\t\tthis.viewSchema,\n\t\t\t\tonViewDispose,\n\t\t\t\tthis.nodeKeyManager,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.view = undefined;\n\n\t\t\tconst unregister = this.checkout.storedSchema.on(\"afterSchemaChange\", () => {\n\t\t\t\tunregister();\n\t\t\t\tthis.unregisterCallbacks.delete(unregister);\n\t\t\t\tthis.update();\n\t\t\t});\n\t\t\tthis.unregisterCallbacks.add(unregister);\n\t\t}\n\n\t\tif (!this.midUpgrade) {\n\t\t\tthis.events.emit(\"schemaChanged\");\n\t\t\tthis.events.emit(\"rootChanged\");\n\t\t}\n\t}\n\n\tprivate runSchemaEdit(edit: () => void): void {\n\t\tthis.midUpgrade = true;\n\t\ttry {\n\t\t\tedit();\n\t\t} finally {\n\t\t\tthis.midUpgrade = false;\n\t\t}\n\t\tthis.events.emit(\"schemaChanged\");\n\t\tthis.events.emit(\"rootChanged\");\n\t}\n\n\tprivate disposeView(): void {\n\t\tif (this.view !== undefined) {\n\t\t\tthis.view[disposeSymbol]();\n\t\t\tthis.view = undefined;\n\t\t\tthis.unregisterCallbacks.forEach((unregister) => unregister());\n\t\t}\n\t}\n\n\tpublic get compatibility(): SchemaCompatibilityStatus {\n\t\tif (!this.currentCompatibility) {\n\t\t\tthis.failDisposed();\n\t\t}\n\t\treturn this.currentCompatibility;\n\t}\n\n\tpublic dispose(): void {\n\t\tthis.disposed = true;\n\t\tthis.disposeView();\n\t\tthis.currentCompatibility = undefined;\n\t}\n\n\tpublic get root(): TreeFieldFromImplicitField<TRootSchema> {\n\t\tif (!this.compatibility.canView) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Document is out of schema. Check TreeView.compatibility before accessing TreeView.root.\",\n\t\t\t);\n\t\t}\n\t\tconst view = this.getView();\n\t\treturn getProxyForField(view.flexTree) as TreeFieldFromImplicitField<TRootSchema>;\n\t}\n\n\tpublic set root(newRoot: InsertableTreeFieldFromImplicitField<TRootSchema>) {\n\t\tif (!this.compatibility.canView) {\n\t\t\tthrow new UsageError(\n\t\t\t\t\"Document is out of schema. Check TreeView.compatibility before accessing TreeView.root.\",\n\t\t\t);\n\t\t}\n\t\tconst view = this.getView();\n\t\tsetField(view.context.root, this.rootFieldSchema, newRoot as InsertableContent);\n\t}\n}\n\n/**\n * Creates a view that self-disposes whenenever the stored schema changes.\n * This may only be called when the schema is already known to be compatible (typically via ensureSchema).\n */\nexport function requireSchema<TRoot extends FlexFieldSchema>(\n\tcheckout: TreeCheckout,\n\tviewSchema: ViewSchema<TRoot>,\n\tonDispose: () => void,\n\tnodeKeyManager: NodeKeyManager,\n): CheckoutFlexTreeView<TRoot> {\n\tconst slots = checkout.forest.anchors.slots;\n\tassert(!slots.has(ContextSlot), 0x8c2 /* Cannot create second view from checkout */);\n\n\t{\n\t\tconst compatibility = viewSchema.checkCompatibility(checkout.storedSchema);\n\t\tassert(\n\t\t\tcompatibility.write === Compatibility.Compatible &&\n\t\t\t\tcompatibility.read === Compatibility.Compatible,\n\t\t\t0x8c3 /* requireSchema invoked with incompatible schema */,\n\t\t);\n\t}\n\n\tconst view = new CheckoutFlexTreeView(\n\t\tcheckout,\n\t\tviewSchema.schema,\n\t\tnodeKeyManager,\n\t\tonDispose,\n\t);\n\tassert(slots.has(ContextSlot), 0x90d /* Context should be tracked in slot */);\n\n\tconst unregister = checkout.storedSchema.on(\"afterSchemaChange\", () => {\n\t\tunregister();\n\t\tview[disposeSymbol]();\n\t});\n\n\treturn view;\n}\n"]}
|
|
@@ -10,11 +10,12 @@ export { treeNodeApi, type TreeNodeApi, type TreeChangeEvents } from "./treeNode
|
|
|
10
10
|
export { toFlexConfig, cursorFromUnhydratedRoot } from "./toFlexSchema.js";
|
|
11
11
|
export type { FieldHasDefaultUnsafe, ObjectFromSchemaRecordUnsafe, TreeObjectNodeUnsafe, TreeFieldFromImplicitFieldUnsafe, TreeNodeFromImplicitAllowedTypesUnsafe, FieldSchemaUnsafe, InsertableTreeNodeFromImplicitAllowedTypesUnsafe, TreeArrayNodeUnsafe, TreeMapNodeUnsafe, InsertableObjectFromSchemaRecordUnsafe, InsertableTreeFieldFromImplicitFieldUnsafe, InsertableTypedNodeUnsafe, NodeBuilderDataUnsafe, NodeFromSchemaUnsafe, } from "./typesUnsafe.js";
|
|
12
12
|
export type { ValidateRecursiveSchema } from "./schemaFactoryRecursive.js";
|
|
13
|
-
export { getProxyForField, type InsertableContent } from "./proxies.js";
|
|
13
|
+
export { getProxyForField, type InsertableContent, prepareContentForHydration, } from "./proxies.js";
|
|
14
14
|
export { adaptEnum, enumFromStrings, singletonSchema, typedObjectValues, } from "./schemaCreationUtilities.js";
|
|
15
15
|
export { RecursiveObject as test_RecursiveObject, base as test_RecursiveObject_base, RecursiveObjectPojoMode as test_RecursiveObjectPojoMode, } from "./testRecursiveDomain.js";
|
|
16
16
|
export type { TreeNode, Unhydrated, InternalTreeNode } from "./types.js";
|
|
17
17
|
export { TreeArrayNode, IterableTreeArrayContent, type TreeArrayNodeBase, } from "./arrayNode.js";
|
|
18
18
|
export { type FieldHasDefault, type InsertableObjectFromSchemaRecord, type ObjectFromSchemaRecord, type TreeObjectNode, setField, } from "./objectNode.js";
|
|
19
19
|
export type { TreeMapNode } from "./mapNode.js";
|
|
20
|
+
export { mapTreeFromNodeData } from "./toMapTree.js";
|
|
20
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/simple-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,KAAK,EACV,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,GAC9B,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,KAAK,cAAc,EACnB,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Ae,EACf,iBAAiB,GACjB,MAAM,8BAA8B,CAAC;AAItC,OAAO,EACN,eAAe,IAAI,oBAAoB,EACvC,IAAI,IAAI,yBAAyB,EACjC,uBAAuB,IAAI,4BAA4B,GACvD,MAAM,0BAA0B,CAAC;AAIlC,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EACN,aAAa,EACb,wBAAwB,EACxB,KAAK,iBAAiB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,gCAAgC,EACrC,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACnB,QAAQ,GACR,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/lib/simple-tree/index.js
CHANGED
|
@@ -8,11 +8,12 @@ export { SchemaFactory } from "./schemaFactory.js";
|
|
|
8
8
|
export { getFlexNode } from "./proxyBinding.js";
|
|
9
9
|
export { treeNodeApi } from "./treeNodeApi.js";
|
|
10
10
|
export { toFlexConfig, cursorFromUnhydratedRoot } from "./toFlexSchema.js";
|
|
11
|
-
export { getProxyForField } from "./proxies.js";
|
|
11
|
+
export { getProxyForField, prepareContentForHydration, } from "./proxies.js";
|
|
12
12
|
export { adaptEnum, enumFromStrings, singletonSchema, typedObjectValues, } from "./schemaCreationUtilities.js";
|
|
13
13
|
// Exporting the schema (RecursiveObject) to test that recursive types are working correctly.
|
|
14
14
|
// These are `@internal` so they can't be included in the `InternalClassTreeTypes` due to https://github.com/microsoft/rushstack/issues/3639
|
|
15
15
|
export { RecursiveObject as test_RecursiveObject, base as test_RecursiveObject_base, RecursiveObjectPojoMode as test_RecursiveObjectPojoMode, } from "./testRecursiveDomain.js";
|
|
16
16
|
export { TreeArrayNode, IterableTreeArrayContent, } from "./arrayNode.js";
|
|
17
17
|
export { setField, } from "./objectNode.js";
|
|
18
|
+
export { mapTreeFromNodeData } from "./toMapTree.js";
|
|
18
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/simple-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIN,iBAAiB,EACjB,qBAAqB,GAIrB,MAAM,WAAW,CAAC;AACnB,OAAO,EAGN,QAAQ,EAUR,cAAc,EAGd,SAAS,EACT,WAAW,EAMX,oBAAoB,GAEpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAyB,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAA2C,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAkB3E,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/simple-tree/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIN,iBAAiB,EACjB,qBAAqB,GAIrB,MAAM,WAAW,CAAC;AACnB,OAAO,EAGN,QAAQ,EAUR,cAAc,EAGd,SAAS,EACT,WAAW,EAMX,oBAAoB,GAEpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAyB,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAA2C,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAkB3E,OAAO,EACN,gBAAgB,EAEhB,0BAA0B,GAC1B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACN,SAAS,EACT,eAAe,EACf,eAAe,EACf,iBAAiB,GACjB,MAAM,8BAA8B,CAAC;AAEtC,6FAA6F;AAC7F,4IAA4I;AAC5I,OAAO,EACN,eAAe,IAAI,oBAAoB,EACvC,IAAI,IAAI,yBAAyB,EACjC,uBAAuB,IAAI,4BAA4B,GACvD,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EACN,aAAa,EACb,wBAAwB,GAExB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAKN,QAAQ,GACR,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\ttype ITree,\n\ttype TreeView,\n\ttype TreeViewEvents,\n\tTreeConfiguration,\n\tTreeViewConfiguration,\n\ttype ITreeViewConfiguration,\n\ttype SchemaCompatibilityStatus,\n\ttype ITreeConfigurationOptions,\n} from \"./tree.js\";\nexport {\n\ttype TreeNodeSchema,\n\ttype NodeFromSchema,\n\tNodeKind,\n\ttype TreeNodeSchemaClass,\n\ttype TreeNodeSchemaNonClass,\n\ttype TreeNodeSchemaCore,\n\ttype ImplicitFieldSchema,\n\ttype TreeFieldFromImplicitField,\n\ttype ImplicitAllowedTypes,\n\ttype TreeNodeFromImplicitAllowedTypes,\n\ttype InsertableTreeNodeFromImplicitAllowedTypes,\n\ttype TreeLeafValue,\n\ttypeNameSymbol,\n\ttype WithType,\n\ttype AllowedTypes,\n\tFieldKind,\n\tFieldSchema,\n\ttype InsertableTreeFieldFromImplicitField,\n\ttype InsertableTypedNode,\n\ttype NodeBuilderData,\n\ttype DefaultProvider,\n\ttype FieldProps,\n\tnormalizeFieldSchema,\n\ttype ApplyKind,\n} from \"./schemaTypes.js\";\nexport { SchemaFactory, type ScopedSchemaName } from \"./schemaFactory.js\";\nexport { getFlexNode } from \"./proxyBinding.js\";\nexport { treeNodeApi, type TreeNodeApi, type TreeChangeEvents } from \"./treeNodeApi.js\";\nexport { toFlexConfig, cursorFromUnhydratedRoot } from \"./toFlexSchema.js\";\nexport type {\n\tFieldHasDefaultUnsafe,\n\tObjectFromSchemaRecordUnsafe,\n\tTreeObjectNodeUnsafe,\n\tTreeFieldFromImplicitFieldUnsafe,\n\tTreeNodeFromImplicitAllowedTypesUnsafe,\n\tFieldSchemaUnsafe,\n\tInsertableTreeNodeFromImplicitAllowedTypesUnsafe,\n\tTreeArrayNodeUnsafe,\n\tTreeMapNodeUnsafe,\n\tInsertableObjectFromSchemaRecordUnsafe,\n\tInsertableTreeFieldFromImplicitFieldUnsafe,\n\tInsertableTypedNodeUnsafe,\n\tNodeBuilderDataUnsafe,\n\tNodeFromSchemaUnsafe,\n} from \"./typesUnsafe.js\";\nexport type { ValidateRecursiveSchema } from \"./schemaFactoryRecursive.js\";\nexport {\n\tgetProxyForField,\n\ttype InsertableContent,\n\tprepareContentForHydration,\n} from \"./proxies.js\";\n\nexport {\n\tadaptEnum,\n\tenumFromStrings,\n\tsingletonSchema,\n\ttypedObjectValues,\n} from \"./schemaCreationUtilities.js\";\n\n// Exporting the schema (RecursiveObject) to test that recursive types are working correctly.\n// These are `@internal` so they can't be included in the `InternalClassTreeTypes` due to https://github.com/microsoft/rushstack/issues/3639\nexport {\n\tRecursiveObject as test_RecursiveObject,\n\tbase as test_RecursiveObject_base,\n\tRecursiveObjectPojoMode as test_RecursiveObjectPojoMode,\n} from \"./testRecursiveDomain.js\";\n\n// TreeNode is only type exported, which prevents use of the class object for unsupported use-cases like direct sub-classing and instancof.\n// See docs on TreeNode for more details.\nexport type { TreeNode, Unhydrated, InternalTreeNode } from \"./types.js\";\nexport {\n\tTreeArrayNode,\n\tIterableTreeArrayContent,\n\ttype TreeArrayNodeBase,\n} from \"./arrayNode.js\";\nexport {\n\ttype FieldHasDefault,\n\ttype InsertableObjectFromSchemaRecord,\n\ttype ObjectFromSchemaRecord,\n\ttype TreeObjectNode,\n\tsetField,\n} from \"./objectNode.js\";\nexport type { TreeMapNode } from \"./mapNode.js\";\nexport { mapTreeFromNodeData } from \"./toMapTree.js\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/tree",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0-274160",
|
|
4
4
|
"description": "Distributed tree",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -67,17 +67,17 @@
|
|
|
67
67
|
"temp-directory": "nyc/.nyc_output"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@fluid-internal/client-utils": "
|
|
71
|
-
"@fluidframework/container-runtime": "
|
|
72
|
-
"@fluidframework/core-interfaces": "
|
|
73
|
-
"@fluidframework/core-utils": "
|
|
74
|
-
"@fluidframework/datastore-definitions": "
|
|
75
|
-
"@fluidframework/driver-definitions": "
|
|
76
|
-
"@fluidframework/id-compressor": "
|
|
77
|
-
"@fluidframework/runtime-definitions": "
|
|
78
|
-
"@fluidframework/runtime-utils": "
|
|
79
|
-
"@fluidframework/shared-object-base": "
|
|
80
|
-
"@fluidframework/telemetry-utils": "
|
|
70
|
+
"@fluid-internal/client-utils": "2.1.0-274160",
|
|
71
|
+
"@fluidframework/container-runtime": "2.1.0-274160",
|
|
72
|
+
"@fluidframework/core-interfaces": "2.1.0-274160",
|
|
73
|
+
"@fluidframework/core-utils": "2.1.0-274160",
|
|
74
|
+
"@fluidframework/datastore-definitions": "2.1.0-274160",
|
|
75
|
+
"@fluidframework/driver-definitions": "2.1.0-274160",
|
|
76
|
+
"@fluidframework/id-compressor": "2.1.0-274160",
|
|
77
|
+
"@fluidframework/runtime-definitions": "2.1.0-274160",
|
|
78
|
+
"@fluidframework/runtime-utils": "2.1.0-274160",
|
|
79
|
+
"@fluidframework/shared-object-base": "2.1.0-274160",
|
|
80
|
+
"@fluidframework/telemetry-utils": "2.1.0-274160",
|
|
81
81
|
"@sinclair/typebox": "^0.32.29",
|
|
82
82
|
"@tylerbu/sorted-btree-es6": "^1.8.0",
|
|
83
83
|
"@ungap/structured-clone": "^1.2.0",
|
|
@@ -86,19 +86,19 @@
|
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@arethetypeswrong/cli": "^0.15.2",
|
|
88
88
|
"@biomejs/biome": "^1.7.3",
|
|
89
|
-
"@fluid-internal/mocha-test-setup": "
|
|
90
|
-
"@fluid-private/stochastic-test-utils": "
|
|
91
|
-
"@fluid-private/test-dds-utils": "
|
|
92
|
-
"@fluid-private/test-drivers": "
|
|
89
|
+
"@fluid-internal/mocha-test-setup": "2.1.0-274160",
|
|
90
|
+
"@fluid-private/stochastic-test-utils": "2.1.0-274160",
|
|
91
|
+
"@fluid-private/test-dds-utils": "2.1.0-274160",
|
|
92
|
+
"@fluid-private/test-drivers": "2.1.0-274160",
|
|
93
93
|
"@fluid-tools/benchmark": "^0.48.0",
|
|
94
94
|
"@fluid-tools/build-cli": "^0.39.0",
|
|
95
95
|
"@fluidframework/build-common": "^2.0.3",
|
|
96
96
|
"@fluidframework/build-tools": "^0.39.0",
|
|
97
|
-
"@fluidframework/container-definitions": "
|
|
98
|
-
"@fluidframework/container-loader": "
|
|
97
|
+
"@fluidframework/container-definitions": "2.1.0-274160",
|
|
98
|
+
"@fluidframework/container-loader": "2.1.0-274160",
|
|
99
99
|
"@fluidframework/eslint-config-fluid": "^5.3.0",
|
|
100
|
-
"@fluidframework/test-runtime-utils": "
|
|
101
|
-
"@fluidframework/test-utils": "
|
|
100
|
+
"@fluidframework/test-runtime-utils": "2.1.0-274160",
|
|
101
|
+
"@fluidframework/test-utils": "2.1.0-274160",
|
|
102
102
|
"@microsoft/api-extractor": "^7.45.1",
|
|
103
103
|
"@types/diff": "^3.5.1",
|
|
104
104
|
"@types/easy-table": "^0.0.32",
|
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
"test:snapshots:regen": "pnpm test:mocha:esm --snapshot",
|
|
191
191
|
"test:stress": "cross-env FUZZ_TEST_COUNT=20 FUZZ_STRESS_RUN=true mocha --ignore \"lib/test/memory/**/*\" --recursive \"lib/test/**/*.spec.js\"",
|
|
192
192
|
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
|
|
193
|
-
"typetests:gen": "flub generate typetests --dir . -v
|
|
193
|
+
"typetests:gen": "flub generate typetests --dir . -v",
|
|
194
194
|
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
|
|
195
195
|
}
|
|
196
196
|
}
|
package/src/packageVersion.ts
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
ViewSchema,
|
|
20
20
|
defaultSchemaPolicy,
|
|
21
21
|
ContextSlot,
|
|
22
|
+
cursorForMapTreeNode,
|
|
22
23
|
} from "../feature-libraries/index.js";
|
|
23
24
|
import {
|
|
24
25
|
type FieldSchema,
|
|
@@ -35,8 +36,9 @@ import {
|
|
|
35
36
|
setField,
|
|
36
37
|
normalizeFieldSchema,
|
|
37
38
|
type InsertableContent,
|
|
38
|
-
cursorFromUnhydratedRoot,
|
|
39
39
|
type TreeViewConfiguration,
|
|
40
|
+
mapTreeFromNodeData,
|
|
41
|
+
prepareContentForHydration,
|
|
40
42
|
} from "../simple-tree/index.js";
|
|
41
43
|
import { disposeSymbol } from "../util/index.js";
|
|
42
44
|
|
|
@@ -127,12 +129,23 @@ export class SchematizingSimpleTreeView<in out TRootSchema extends ImplicitField
|
|
|
127
129
|
}
|
|
128
130
|
|
|
129
131
|
this.runSchemaEdit(() => {
|
|
132
|
+
const mapTree = mapTreeFromNodeData(
|
|
133
|
+
content as InsertableContent,
|
|
134
|
+
this.rootFieldSchema.allowedTypes,
|
|
135
|
+
this.nodeKeyManager,
|
|
136
|
+
{
|
|
137
|
+
schema: this.checkout.storedSchema,
|
|
138
|
+
policy: {
|
|
139
|
+
...defaultSchemaPolicy,
|
|
140
|
+
validateSchema: this.config.enableSchemaValidation,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
prepareContentForHydration(mapTree, this.checkout.forest);
|
|
130
146
|
initialize(this.checkout, {
|
|
131
147
|
schema: this.flexConfig.schema,
|
|
132
|
-
initialTree:
|
|
133
|
-
content === undefined
|
|
134
|
-
? undefined
|
|
135
|
-
: cursorFromUnhydratedRoot(this.config.schema, content, this.nodeKeyManager),
|
|
148
|
+
initialTree: mapTree === undefined ? undefined : cursorForMapTreeNode(mapTree),
|
|
136
149
|
});
|
|
137
150
|
});
|
|
138
151
|
}
|
package/src/simple-tree/index.ts
CHANGED
|
@@ -60,7 +60,11 @@ export type {
|
|
|
60
60
|
NodeFromSchemaUnsafe,
|
|
61
61
|
} from "./typesUnsafe.js";
|
|
62
62
|
export type { ValidateRecursiveSchema } from "./schemaFactoryRecursive.js";
|
|
63
|
-
export {
|
|
63
|
+
export {
|
|
64
|
+
getProxyForField,
|
|
65
|
+
type InsertableContent,
|
|
66
|
+
prepareContentForHydration,
|
|
67
|
+
} from "./proxies.js";
|
|
64
68
|
|
|
65
69
|
export {
|
|
66
70
|
adaptEnum,
|
|
@@ -93,3 +97,4 @@ export {
|
|
|
93
97
|
setField,
|
|
94
98
|
} from "./objectNode.js";
|
|
95
99
|
export type { TreeMapNode } from "./mapNode.js";
|
|
100
|
+
export { mapTreeFromNodeData } from "./toMapTree.js";
|